From cd09a7cb67ae6854e0b95bb4e2740defe7e4d837 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 7 Jul 2014 17:18:15 +0100 Subject: [PATCH] Imported Upstream version 0.5.0+svn5294~dfsg1 --- applications/dashcast/Makefile | 7 +- applications/dashcast/audio_data.h | 8 + applications/dashcast/audio_decoder.c | 147 +- applications/dashcast/audio_decoder.h | 12 +- applications/dashcast/audio_encoder.c | 204 +- applications/dashcast/audio_encoder.h | 16 +- applications/dashcast/audio_muxer.c | 71 +- applications/dashcast/audio_muxer.h | 3 - applications/dashcast/circular_buffer.c | 2 +- applications/dashcast/circular_buffer.h | 36 +- applications/dashcast/cmd_data.c | 199 +- applications/dashcast/cmd_data.h | 2 +- applications/dashcast/controler.c | 182 +- applications/dashcast/controler.h | 8 +- applications/dashcast/libav_compat.h | 10 +- applications/dashcast/register.c | 18 +- applications/dashcast/register.h | 4 +- applications/dashcast/video_data.h | 2 + applications/dashcast/video_decoder.c | 38 +- applications/dashcast/video_encoder.c | 54 +- applications/dashcast/video_muxer.c | 322 +- applications/dashcast/video_muxer.h | 2 +- applications/dashcast/video_scaler.c | 24 +- applications/generators/MPEG4/main.c | 180 +- applications/generators/SVG/html.c | 16 +- applications/generators/SVG/laser.c | 40 +- applications/generators/SVG/main.c | 367 +- applications/generators/SVG/svggen.h | 48 +- applications/generators/SVG/v1.c | 228 +- applications/generators/SVG/v2.c | 94 +- applications/generators/SVG/v3.c | 94 +- applications/generators/X3D/main.c | 118 +- applications/m3u82mpd/main.c | 28 +- applications/mp42avi/main.c | 100 +- applications/mp42ts/main.c | 1250 +-- applications/mp42ts/mp42ts.h | 30 +- applications/mp4box/filedump.c | 599 +- applications/mp4box/fileimport.c | 251 +- applications/mp4box/live.c | 229 +- applications/mp4box/main.c | 1623 ++-- applications/mp4box/wrapper.c | 42 +- applications/mp4client/extract.c | 192 +- applications/mp4client/main.c | 1047 ++- applications/mp4client/resource.h | 2 +- .../testapps/bmp4demux/bmp4demux.vcxproj | 5 +- .../bmp4demux/bmp4demux.vcxproj.filters | 3 + applications/testapps/bmp4demux/main.c | 8 +- .../testapps/broadcaster/RTP_serv_generator.c | 108 +- .../testapps/broadcaster/RTP_serv_generator.h | 8 +- .../broadcaster/RTP_serv_packetizer.c | 30 +- .../testapps/broadcaster/RTP_serv_sender.c | 14 +- .../testapps/broadcaster/RTP_serv_sender.h | 4 +- .../testapps/broadcaster/broadcaster.c | 116 +- .../testapps/broadcaster/broadcaster.h | 2 +- .../testapps/broadcaster/sdp_generator.c | 16 +- .../testapps/broadcaster/sdp_generator.h | 4 +- applications/testapps/dmbrs/main.c | 90 +- .../testapps/fmp4demux/fmp4demux.vcxproj | 9 +- .../fmp4demux/fmp4demux.vcxproj.filters | 3 + applications/testapps/fmp4demux/main.c | 26 +- applications/testapps/hevcbench/defbench.h | 8 +- applications/testapps/hevcbench/main.c | 67 +- applications/testapps/largefile/main.c | 24 +- .../testapps/loadcompare/loadcompare.c | 50 +- applications/testapps/mpedemux/main.c | 16 +- applications/testapps/mpeg2ts/main.c | 2 +- applications/testapps/segmp4demux/main.c | 6 +- .../testapps/segmp4demux/segmp4demux.vcxproj | 7 +- .../segmp4demux/segmp4demux.vcxproj.filters | 3 + applications/testapps/svg2bifs/main.c | 982 +-- applications/ts2hds/f4m.c | 66 +- applications/ts2hds/f4v.c | 6 +- applications/ts2hds/main.c | 28 +- applications/ts2hds/ts2hds.h | 6 +- applications/udptsseg/main.c | 130 +- configure | 88 +- doc/CODING_STYLE | 11 +- doc/configuration.html | 19 +- extra_lib/include/libavdevice/avdevice.h | 164 + extra_lib/include/libavdevice/version.h | 4 +- extra_lib/include/libavfilter/asrc_abuffer.h | 91 + extra_lib/include/libavfilter/avcodec.h | 110 + extra_lib/include/libavfilter/avfilter.h | 1529 ++++ extra_lib/include/libavfilter/avfiltergraph.h | 28 + extra_lib/include/libavfilter/buffersink.h | 204 + extra_lib/include/libavfilter/buffersrc.h | 160 + extra_lib/include/libavfilter/version.h | 95 + extra_lib/include/libavresample/avresample.h | 417 + extra_lib/include/libavresample/version.h | 54 + extra_lib/include/libswresample/swresample.h | 318 + extra_lib/include/libswresample/version.h | 45 + extra_lib/include/openHevcWrapper.h | 33 +- include/gpac/ait.h | 26 +- include/gpac/avparse.h | 74 +- include/gpac/base_coding.h | 8 +- include/gpac/bifs.h | 10 +- include/gpac/bitstream.h | 78 +- include/gpac/cache.h | 364 +- include/gpac/color.h | 30 +- include/gpac/compositor.h | 16 +- include/gpac/config_file.h | 32 +- include/gpac/configuration.h | 55 +- include/gpac/constants.h | 226 +- include/gpac/crypt.h | 40 +- include/gpac/dash.h | 52 +- include/gpac/download.h | 978 +-- include/gpac/dsmcc.h | 226 +- include/gpac/dvb_mpe.h | 8 +- include/gpac/esi.h | 16 +- include/gpac/events.h | 10 +- include/gpac/events_constants.h | 54 +- include/gpac/filestreamer.h | 10 +- include/gpac/html5_media.h | 306 +- include/gpac/html5_mse.h | 174 +- include/gpac/ietf.h | 208 +- include/gpac/internal/avilib.h | 334 +- include/gpac/internal/bifs_dev.h | 18 +- include/gpac/internal/bifs_tables.h | 198 +- include/gpac/internal/camera.h | 8 +- include/gpac/internal/compositor_dev.h | 86 +- include/gpac/internal/crypt_dev.h | 8 +- include/gpac/internal/dvb_mpe_dev.h | 20 +- include/gpac/internal/ietf_dev.h | 34 +- include/gpac/internal/isomedia_dev.h | 141 +- include/gpac/internal/laser_dev.h | 36 +- include/gpac/internal/m3u8.h | 49 +- include/gpac/internal/media_dev.h | 92 +- include/gpac/internal/mesh.h | 36 +- include/gpac/internal/mpd.h | 111 +- include/gpac/internal/odf_dev.h | 8 +- include/gpac/internal/odf_parse_common.h | 16 +- include/gpac/internal/ogg.h | 86 +- include/gpac/internal/reedsolomon.h | 10 +- include/gpac/internal/scenegraph_dev.h | 90 +- include/gpac/internal/smjs_api.h | 26 +- include/gpac/internal/swf_dev.h | 40 +- include/gpac/internal/terminal_dev.h | 121 +- include/gpac/internal/vobsub.h | 6 +- include/gpac/ismacryp.h | 16 +- include/gpac/iso639.h | 16 +- include/gpac/isomedia.h | 311 +- include/gpac/laser.h | 8 +- include/gpac/list.h | 12 +- include/gpac/map.h | 14 +- include/gpac/math.h | 50 +- include/gpac/media_tools.h | 64 +- include/gpac/mediaobject.h | 26 +- include/gpac/module.h | 20 +- include/gpac/modules/audio_out.h | 44 +- include/gpac/modules/codec.h | 82 +- include/gpac/modules/font.h | 12 +- include/gpac/modules/hardcoded_proto.h | 6 +- include/gpac/modules/ipmp.h | 8 +- include/gpac/modules/js_usr.h | 10 +- include/gpac/modules/raster2d.h | 26 +- include/gpac/modules/service.h | 133 +- include/gpac/modules/term_ext.h | 10 +- include/gpac/modules/video_out.h | 40 +- include/gpac/mpeg4_odf.h | 126 +- include/gpac/mpegts.h | 168 +- include/gpac/network.h | 58 +- include/gpac/nodes_mpeg4.h | 4 +- include/gpac/nodes_svg.h | 12 +- include/gpac/nodes_x3d.h | 4 +- include/gpac/nodes_xbl.h | 6 +- include/gpac/options.h | 32 +- include/gpac/path2d.h | 48 +- include/gpac/ringbuffer.h | 22 +- include/gpac/rtp_streamer.h | 54 +- include/gpac/scene_engine.h | 26 +- include/gpac/scene_manager.h | 38 +- include/gpac/scenegraph.h | 68 +- include/gpac/scenegraph_svg.h | 138 +- include/gpac/scenegraph_vrml.h | 44 +- include/gpac/setup.h | 4 +- include/gpac/svg_types.h | 84 +- include/gpac/sync_layer.h | 10 +- include/gpac/term_info.h | 24 +- include/gpac/terminal.h | 30 +- include/gpac/thread.h | 22 +- include/gpac/token.h | 26 +- include/gpac/tools.h | 22 +- include/gpac/unicode.h | 10 +- include/gpac/user.h | 16 +- include/gpac/utf.h | 10 +- include/gpac/version.h | 2 +- include/gpac/webvtt.h | 40 +- include/gpac/xml.h | 30 +- include/win32/inttypes.h | 18 +- modules/Makefile | 2 + modules/aac_in/aac_in.c | 200 +- modules/aac_in/faad_dec.c | 208 +- modules/ac3_in/ac3_in.c | 84 +- modules/ac3_in/liba52_dec.c | 102 +- modules/alsa/alsa.c | 32 +- modules/amr_dec/amr_dec.c | 91 +- modules/amr_dec/amr_in.c | 68 +- modules/amr_dec/amr_nb/typedefs.h | 16 +- modules/amr_dec/amr_nb_api.h | 64 +- modules/amr_float_dec/amr_api.h | 18 +- modules/amr_float_dec/amr_float_dec.c | 51 +- modules/audio_filter/audio_filter.c | 18 +- modules/avcap/avcap.cpp | 70 +- modules/bifs_dec/bifs_dec.c | 24 +- modules/ctx_load/ctx_load.c | 84 +- modules/demo_is/demo_is.c | 12 +- modules/directfb_out/directfb_out.c | 40 +- modules/directfb_out/directfb_out.h | 8 +- modules/directfb_out/directfb_wrapper.c | 783 +- modules/droid_audio/droidaudio.c | 139 +- modules/droid_audio/javaenv.c | 18 +- modules/droid_audio/javaenv.h | 6 +- modules/droid_cam/droid_cam.c | 104 +- modules/droid_mpegv/droid_mpegv.c | 78 +- modules/droid_out/droid_vout-bitmap.c | 28 +- modules/droid_out/droid_vout.c | 280 +- modules/dummy_in/dummy_in.c | 118 +- modules/dx_hw/copy_pixels.c | 28 +- modules/dx_hw/dx_2d.c | 110 +- modules/dx_hw/dx_audio.c | 91 +- modules/dx_hw/dx_hw.h | 26 +- modules/dx_hw/dx_video.c | 124 +- modules/dx_hw/dx_window.c | 553 +- modules/dx_hw/resource.h | 2 +- modules/epoc_hw/epoc_aout.cpp | 56 +- modules/epoc_hw/epoc_codec.cpp | 38 +- modules/epoc_hw/epoc_vout.cpp | 111 +- modules/ffmpeg_in/ffmpeg_decode.c | 203 +- modules/ffmpeg_in/ffmpeg_demux.c | 205 +- modules/ffmpeg_in/ffmpeg_in.h | 20 +- modules/ffmpeg_in/ffmpeg_load.c | 11 +- modules/freenect/freenect.c | 124 +- modules/ft_font/ft_font.c | 64 +- modules/ft_font/ft_font.h | 8 +- modules/gapi/gapi.cpp | 558 +- modules/gapi/gapi.h | 24 +- modules/gdip_raster/gdip_font.cpp | 31 +- modules/gdip_raster/gdip_grad.cpp | 52 +- modules/gdip_raster/gdip_priv.h | 8 +- modules/gdip_raster/gdip_rend.cpp | 61 +- modules/gdip_raster/gdip_texture.cpp | 117 +- modules/gpac_js/gpac_js.c | 523 +- modules/hyb_in/fm_fake_pull.c | 2 +- modules/hyb_in/fm_fake_push.c | 40 +- modules/hyb_in/hyb_in.c | 22 +- modules/hyb_in/hyb_in.h | 8 +- modules/img_in/bmp_dec.c | 22 +- modules/img_in/img_dec.c | 28 +- modules/img_in/img_in.c | 86 +- modules/img_in/img_in.h | 22 +- modules/img_in/jp2_dec.c | 216 +- modules/img_in/jpeg_dec.c | 28 +- modules/img_in/png_dec.c | 34 +- modules/ios_cam/CameraObject.h | 36 +- modules/ios_cam/cam_wrap.h | 2 +- modules/ios_cam/ios_cam.c | 222 +- modules/ios_mpegv/SensorAccess.h | 8 +- modules/ios_mpegv/ios_mpegv.c | 97 +- modules/ios_mpegv/sensor_wrap.h | 48 +- modules/ismacryp/isma_ea.c | 189 +- modules/isom_in/isom_cache.c | 59 +- modules/isom_in/isom_in.h | 14 +- modules/isom_in/load.c | 58 +- modules/isom_in/read.c | 282 +- modules/isom_in/read_ch.c | 132 +- modules/jack/jack.c | 753 +- modules/laser_dec/laser_dec.c | 26 +- modules/libplayer/libplayer.c | 212 +- modules/modules_export.cpp | 10 +- modules/mp3_in/mad_dec.c | 46 +- modules/mp3_in/mp3_in.c | 102 +- modules/mpd_in/mpd_in.c | 470 +- modules/mpegts_in/mpegts_in.c | 375 +- modules/mse_in/mse_in.c | 368 +- modules/odf_dec/odf_dec.c | 26 +- modules/ogg/ogg_in.c | 153 +- modules/ogg/ogg_in.h | 8 +- modules/ogg/ogg_load.c | 40 +- modules/ogg/theora_dec.c | 54 +- modules/ogg/vorbis_dec.c | 56 +- modules/opencv_is/opencv_is.c | 130 +- modules/openhevc_dec/openhevc_dec.c | 203 +- modules/opensvc_dec/opensvc_dec.c | 86 +- modules/osd/osd.c | 16 +- modules/oss_audio/oss.c | 58 +- modules/platinum/GPACFileMediaServer.cpp | 426 +- modules/platinum/GPACFileMediaServer.h | 72 +- modules/platinum/GPACMediaController.cpp | 272 +- modules/platinum/GPACMediaController.h | 82 +- modules/platinum/GPACMediaRenderer.cpp | 634 +- modules/platinum/GPACMediaRenderer.h | 74 +- modules/platinum/GPACPlatinum.cpp | 163 +- modules/platinum/GPACPlatinum.h | 22 +- modules/platinum/GenericDevice.cpp | 84 +- modules/platinum/GenericDevice.h | 39 +- modules/pulseaudio/pulseaudio.c | 410 +- modules/raw_out/raw_video.c | 18 +- modules/redirect_av/ffmpeg_ts_muxer.c | 612 +- modules/redirect_av/gpac_ts_muxer.c | 268 +- modules/redirect_av/redirect_av.c | 1133 ++- modules/redirect_av/ts_muxer.h | 78 +- modules/rtp_in/rtp_in.c | 73 +- modules/rtp_in/rtp_in.h | 26 +- modules/rtp_in/rtp_session.c | 56 +- modules/rtp_in/rtp_signaling.c | 114 +- modules/rtp_in/rtp_stream.c | 108 +- modules/rtp_in/sdp_fetch.c | 44 +- modules/rtp_in/sdp_load.c | 78 +- modules/rvc_dec/rvc_dec.c | 98 +- modules/saf_in/saf_in.c | 68 +- modules/sdl_out/audio.c | 32 +- modules/sdl_out/cursors.c | 14 +- modules/sdl_out/sdl_out.c | 14 +- modules/sdl_out/sdl_out.h | 12 +- modules/sdl_out/video.c | 682 +- modules/sdl_out/video2d.c | 10 +- modules/soft_raster/ftgrays.c | 146 +- modules/soft_raster/rast_soft.h | 20 +- modules/soft_raster/raster_565.c | 16 +- modules/soft_raster/raster_argb.c | 35 +- modules/soft_raster/raster_load.c | 14 +- modules/soft_raster/raster_rgb.c | 16 +- modules/soft_raster/stencil.c | 110 +- modules/soft_raster/surface.c | 24 +- modules/svg_in/svg_in.c | 82 +- modules/timedtext/timedtext_dec.c | 130 +- modules/timedtext/timedtext_in.c | 140 +- modules/ui_rec/ui_rec.c | 26 +- modules/validator/validator.c | 1482 ++-- modules/vtt_in/vtt_dec.c | 44 +- modules/vtt_in/vtt_in.c | 65 +- modules/wav_out/wav_out.c | 60 +- modules/widgetman/unzip.c | 2151 ++--- modules/widgetman/unzip.h | 200 +- modules/widgetman/wgt_load.c | 46 +- modules/widgetman/widget.c | 136 +- modules/widgetman/widgetman.c | 792 +- modules/widgetman/widgetman.h | 58 +- modules/wiiis/wiiis.c | 36 +- modules/x11_out/x11_out.c | 1440 ++-- modules/x11_out/x11_out.h | 16 +- modules/xvid_dec/xvid_dec.c | 47 +- modules/xvid_dec/xvid_dec_wce.cpp | 32 +- packagers/win32_64/nsis/gpac_installer.nsi | 3 +- src/Makefile | 6 +- src/bifs/arith_decoder.c | 2 +- src/bifs/bifs_codec.c | 46 +- src/bifs/bifs_node_tables.c | 7 +- src/bifs/com_dec.c | 58 +- src/bifs/com_enc.c | 66 +- src/bifs/conditional.c | 8 +- src/bifs/field_decode.c | 98 +- src/bifs/field_encode.c | 89 +- src/bifs/memory_decoder.c | 32 +- src/bifs/predictive_mffield.c | 108 +- src/bifs/quant.h | 38 +- src/bifs/quantize.c | 38 +- src/bifs/script.h | 24 +- src/bifs/script_dec.c | 40 +- src/bifs/script_enc.c | 444 +- src/bifs/unquantize.c | 6 +- src/compositor/audio_input.c | 40 +- src/compositor/audio_mixer.c | 54 +- src/compositor/audio_render.c | 64 +- src/compositor/bindable.c | 115 +- src/compositor/camera.c | 76 +- src/compositor/compositor.c | 856 +- src/compositor/compositor_2d.c | 188 +- src/compositor/compositor_3d.c | 171 +- src/compositor/compositor_node_init.c | 477 +- src/compositor/drawable.c | 221 +- src/compositor/drawable.h | 31 +- src/compositor/events.c | 156 +- src/compositor/font_engine.c | 100 +- src/compositor/gl_inc.h | 15 +- src/compositor/hardcoded_protos.c | 135 +- src/compositor/hc_flash_shape.c | 78 +- src/compositor/mesh.c | 440 +- src/compositor/mesh_collide.c | 72 +- src/compositor/mesh_tesselate.c | 131 +- src/compositor/mpeg4_animstream.c | 24 +- src/compositor/mpeg4_audio.c | 30 +- src/compositor/mpeg4_background.c | 126 +- src/compositor/mpeg4_background2d.c | 73 +- src/compositor/mpeg4_bitmap.c | 32 +- src/compositor/mpeg4_composite.c | 82 +- src/compositor/mpeg4_form.c | 38 +- src/compositor/mpeg4_geometry_2d.c | 11 +- src/compositor/mpeg4_geometry_3d.c | 27 +- src/compositor/mpeg4_geometry_ifs2d.c | 20 +- src/compositor/mpeg4_geometry_ils2d.c | 5 +- src/compositor/mpeg4_gradients.c | 38 +- src/compositor/mpeg4_grouping.c | 147 +- src/compositor/mpeg4_grouping.h | 22 +- src/compositor/mpeg4_grouping_2d.c | 57 +- src/compositor/mpeg4_grouping_3d.c | 54 +- src/compositor/mpeg4_layer_2d.c | 69 +- src/compositor/mpeg4_layer_3d.c | 139 +- src/compositor/mpeg4_layout.c | 56 +- src/compositor/mpeg4_lighting.c | 49 +- src/compositor/mpeg4_path_layout.c | 41 +- src/compositor/mpeg4_sensors.c | 297 +- src/compositor/mpeg4_sound.c | 20 +- src/compositor/mpeg4_text.c | 40 +- src/compositor/mpeg4_textures.c | 56 +- src/compositor/mpeg4_timesensor.c | 14 +- src/compositor/mpeg4_viewport.c | 64 +- src/compositor/navigate.c | 80 +- src/compositor/nodes_stacks.h | 12 +- src/compositor/offscreen_cache.c | 183 +- src/compositor/offscreen_cache.h | 9 +- src/compositor/svg_base.c | 167 +- src/compositor/svg_filters.c | 68 +- src/compositor/svg_font.c | 80 +- src/compositor/svg_geometry.c | 88 +- src/compositor/svg_grouping.c | 179 +- src/compositor/svg_media.c | 128 +- src/compositor/svg_paint_servers.c | 44 +- src/compositor/svg_text.c | 270 +- src/compositor/texturing.c | 52 +- src/compositor/texturing.h | 8 +- src/compositor/texturing_gl.c | 313 +- src/compositor/visual_manager.c | 36 +- src/compositor/visual_manager.h | 48 +- src/compositor/visual_manager_2d.c | 134 +- src/compositor/visual_manager_2d.h | 18 +- src/compositor/visual_manager_2d_draw.c | 93 +- src/compositor/visual_manager_3d.c | 671 +- src/compositor/visual_manager_3d.h | 125 +- src/compositor/visual_manager_3d_gl.c | 1591 ++-- src/compositor/x3d_geometry.c | 97 +- src/export.cpp | 115 +- src/ietf/rtcp.c | 128 +- src/ietf/rtp.c | 142 +- src/ietf/rtp_depacketizer.c | 237 +- src/ietf/rtp_packetizer.c | 152 +- src/ietf/rtp_pck_3gpp.c | 66 +- src/ietf/rtp_pck_mpeg12.c | 46 +- src/ietf/rtp_pck_mpeg4.c | 138 +- src/ietf/rtp_streamer.c | 162 +- src/ietf/rtsp_command.c | 130 +- src/ietf/rtsp_common.c | 34 +- src/ietf/rtsp_response.c | 126 +- src/ietf/rtsp_session.c | 66 +- src/ietf/sdp.c | 56 +- src/isomedia/avc_ext.c | 293 +- src/isomedia/box_code_3gpp.c | 45 +- src/isomedia/box_code_adobe.c | 38 +- src/isomedia/box_code_apple.c | 30 +- src/isomedia/box_code_base.c | 621 +- src/isomedia/box_code_drm.c | 66 +- src/isomedia/box_code_meta.c | 76 +- src/isomedia/box_dump.c | 542 +- src/isomedia/box_funcs.c | 2975 ++++--- src/isomedia/data_map.c | 48 +- src/isomedia/drm_sample.c | 136 +- src/isomedia/hint_track.c | 88 +- src/isomedia/hinting.c | 50 +- src/isomedia/isom_intern.c | 68 +- src/isomedia/isom_read.c | 304 +- src/isomedia/isom_store.c | 88 +- src/isomedia/isom_write.c | 512 +- src/isomedia/media.c | 142 +- src/isomedia/media_odf.c | 27 +- src/isomedia/meta.c | 44 +- src/isomedia/movie_fragments.c | 164 +- src/isomedia/sample_descs.c | 52 +- src/isomedia/stbl_read.c | 40 +- src/isomedia/stbl_write.c | 58 +- src/isomedia/track.c | 121 +- src/isomedia/ttml.c | 121 +- src/isomedia/tx3g.c | 69 +- src/laser/lsr_dec.c | 1037 ++- src/laser/lsr_enc.c | 1060 ++- src/laser/lsr_tables.c | 1205 ++- src/mcrypt/cbc.c | 52 +- src/mcrypt/cfb.c | 40 +- src/mcrypt/ctr.c | 66 +- src/mcrypt/des.c | 94 +- src/mcrypt/ecb.c | 20 +- src/mcrypt/g_crypt.c | 127 +- src/mcrypt/ncfb.c | 98 +- src/mcrypt/nofb.c | 64 +- src/mcrypt/ofb.c | 38 +- src/mcrypt/rijndael-128.c | 104 +- src/mcrypt/rijndael-192.c | 104 +- src/mcrypt/rijndael-256.c | 104 +- src/mcrypt/stream.c | 20 +- src/mcrypt/tripledes.c | 118 +- src/media_tools/ait.c | 868 +- src/media_tools/av_parsers.c | 1309 +-- src/media_tools/avilib.c | 4260 +++++----- src/media_tools/dash_client.c | 416 +- src/media_tools/dash_segmenter.c | 644 +- src/media_tools/dsmcc.c | 1622 ++-- src/media_tools/dvb_mpe.c | 726 +- src/media_tools/filestreamer.c | 78 +- src/media_tools/gpac_ogg.c | 2054 ++--- src/media_tools/html5_media.c | 214 +- src/media_tools/html5_mse.c | 860 +- src/media_tools/img.c | 86 +- src/media_tools/ismacryp.c | 292 +- src/media_tools/isom_hinter.c | 130 +- src/media_tools/isom_tools.c | 620 +- src/media_tools/m2ts_mux.c | 730 +- src/media_tools/m3u8.c | 95 +- src/media_tools/media_export.c | 478 +- src/media_tools/media_import.c | 1608 ++-- src/media_tools/mpd.c | 102 +- src/media_tools/mpeg2_ps.c | 2740 +++---- src/media_tools/mpeg2_ps.h | 282 +- src/media_tools/mpegts.c | 1201 +-- src/media_tools/reedsolomon.c | 822 +- src/media_tools/saf.c | 12 +- src/media_tools/text_import.c | 514 +- src/media_tools/vobsub.c | 324 +- src/media_tools/webvtt.c | 2292 +++--- src/odf/desc_private.c | 36 +- src/odf/descriptors.c | 187 +- src/odf/ipmpx_code.c | 632 +- src/odf/ipmpx_dump.c | 105 +- src/odf/ipmpx_parse.c | 250 +- src/odf/oci_codec.c | 36 +- src/odf/odf_code.c | 78 +- src/odf/odf_codec.c | 65 +- src/odf/odf_command.c | 20 +- src/odf/odf_dump.c | 78 +- src/odf/odf_parse.c | 601 +- src/odf/qos.c | 14 +- src/odf/slc.c | 56 +- src/scene_manager/encode_isom.c | 64 +- src/scene_manager/loader_bt.c | 165 +- src/scene_manager/loader_isom.c | 32 +- src/scene_manager/loader_qt.c | 8 +- src/scene_manager/loader_svg.c | 235 +- src/scene_manager/loader_xmt.c | 221 +- src/scene_manager/scene_dump.c | 606 +- src/scene_manager/scene_engine.c | 300 +- src/scene_manager/scene_manager.c | 128 +- src/scene_manager/scene_stats.c | 200 +- src/scene_manager/swf_bifs.c | 84 +- src/scene_manager/swf_parse.c | 441 +- src/scene_manager/swf_svg.c | 606 +- src/scene_manager/text_to_bifs.c | 112 +- src/scenegraph/base_scenegraph.c | 192 +- src/scenegraph/commands.c | 68 +- src/scenegraph/dom_events.c | 250 +- src/scenegraph/dom_smjs.c | 2098 ++--- src/scenegraph/html5_media_smjs.c | 2295 +++--- src/scenegraph/html5_mse_smjs.c | 1136 +-- src/scenegraph/mpeg4_animators.c | 134 +- src/scenegraph/mpeg4_nodes.c | 7147 +++++++++++------ src/scenegraph/mpeg4_valuator.c | 36 +- src/scenegraph/smil_anim.c | 632 +- src/scenegraph/smil_timing.c | 222 +- src/scenegraph/svg_attributes.c | 1747 ++-- src/scenegraph/svg_properties.c | 1128 ++- src/scenegraph/svg_smjs.c | 829 +- src/scenegraph/svg_types.c | 114 +- src/scenegraph/vrml_interpolators.c | 92 +- src/scenegraph/vrml_proto.c | 124 +- src/scenegraph/vrml_route.c | 44 +- src/scenegraph/vrml_script.c | 20 +- src/scenegraph/vrml_smjs.c | 1784 ++-- src/scenegraph/vrml_tools.c | 481 +- src/scenegraph/webvtt_smjs.c | 28 +- src/scenegraph/x3d_nodes.c | 2493 +++--- src/scenegraph/xbl_process.c | 14 +- src/scenegraph/xml_ns.c | 68 +- src/terminal/channel.c | 146 +- src/terminal/clock.c | 25 +- src/terminal/decoder.c | 158 +- src/terminal/input_sensor.c | 173 +- src/terminal/input_sensor.h | 6 +- src/terminal/media_control.c | 46 +- src/terminal/media_control.h | 8 +- src/terminal/media_manager.c | 54 +- src/terminal/media_memory.c | 82 +- src/terminal/media_memory.h | 20 +- src/terminal/media_object.c | 276 +- src/terminal/media_sensor.c | 22 +- src/terminal/mpeg4_inline.c | 44 +- src/terminal/network_service.c | 221 +- src/terminal/object_browser.c | 45 +- src/terminal/object_manager.c | 258 +- src/terminal/scene.c | 338 +- src/terminal/svg_external.c | 12 +- src/terminal/term_node_init.c | 98 +- src/terminal/terminal.c | 177 +- src/utils/alloc.c | 26 +- src/utils/base_encoding.c | 121 +- src/utils/bitstream.c | 103 +- src/utils/cache.c | 28 +- src/utils/color.c | 202 +- src/utils/configfile.c | 78 +- src/utils/dlmalloc.c | 4276 +++++----- src/utils/downloader.c | 3716 ++++----- src/utils/error.c | 115 +- src/utils/gzio.cpp | 1233 +-- src/utils/list.c | 36 +- src/utils/map.c | 44 +- src/utils/math.c | 733 +- src/utils/module.c | 64 +- src/utils/module_wrap.h | 10 +- src/utils/os_config_init.c | 57 +- src/utils/os_divers.c | 648 +- src/utils/os_module.c | 44 +- src/utils/os_net.c | 88 +- src/utils/os_thread.c | 29 +- src/utils/path2d.c | 152 +- src/utils/path2d_stroker.c | 754 +- src/utils/ringbuffer.c | 186 +- src/utils/sha1.c | 836 +- src/utils/symbian_net.cpp | 131 +- src/utils/symbian_os.cpp | 66 +- src/utils/token.c | 13 +- src/utils/uni_bidi.c | 62 +- src/utils/unicode.c | 61 +- src/utils/url.c | 42 +- src/utils/utf.c | 424 +- src/utils/xml_parser.c | 182 +- src/utils/zlib_symbian_ext.h | 4 +- src/utils/zutil.c | 309 +- src/utils/zutil.h | 54 +- version.bat | 8 +- 625 files changed, 77282 insertions(+), 60968 deletions(-) create mode 100644 extra_lib/include/libavfilter/asrc_abuffer.h create mode 100644 extra_lib/include/libavfilter/avcodec.h create mode 100644 extra_lib/include/libavfilter/avfilter.h create mode 100644 extra_lib/include/libavfilter/avfiltergraph.h create mode 100644 extra_lib/include/libavfilter/buffersink.h create mode 100644 extra_lib/include/libavfilter/buffersrc.h create mode 100644 extra_lib/include/libavfilter/version.h create mode 100644 extra_lib/include/libavresample/avresample.h create mode 100644 extra_lib/include/libavresample/version.h create mode 100644 extra_lib/include/libswresample/swresample.h create mode 100644 extra_lib/include/libswresample/version.h diff --git a/applications/dashcast/Makefile b/applications/dashcast/Makefile index a68e927..0b2bb02 100644 --- a/applications/dashcast/Makefile +++ b/applications/dashcast/Makefile @@ -20,10 +20,15 @@ ifeq ($(GPACREADONLY), yes) CFLAGS+=-DGPAC_READ_ONLY endif -ifeq ($(CONFIG_LIBAV),yes) +ifneq ($(CONFIG_LIBAV),no) CFLAGS+=-DGPAC_USE_LIBAV endif +ifneq ($(CONFIG_LIBAVRESAMPLE),no) +CFLAGS+=-DDC_AUDIO_RESAMPLER +LINKLIBS+=-lavresample +endif + #common obj OBJS= dashcast.o audio_data.o audio_decoder.o audio_encoder.o audio_muxer.o circular_buffer.o cmd_data.o controler.o message_queue.o register.o video_data.o video_decoder.o video_encoder.o video_muxer.o video_scaler.o task.o diff --git a/applications/dashcast/audio_data.h b/applications/dashcast/audio_data.h index d322e5a..2c78c3e 100644 --- a/applications/dashcast/audio_data.h +++ b/applications/dashcast/audio_data.h @@ -40,6 +40,14 @@ #include +//we force the number of channels between the decoder and the encoder: interleaved 16 bits stereo 44100Hz +#define DC_AUDIO_SAMPLE_RATE 44100 +#define DC_AUDIO_NUM_CHANNELS 2 +#define DC_AUDIO_CHANNEL_LAYOUT AV_CH_LAYOUT_STEREO +#define DC_AUDIO_SAMPLE_FORMAT AV_SAMPLE_FMT_S16 + +#define DC_AUDIO_MAX_CHUNCK_SIZE 192000 + /* * AudioInputData is designed to keep the data of input audio in a circular buffer. diff --git a/applications/dashcast/audio_decoder.c b/applications/dashcast/audio_decoder.c index ee18bbf..76a84c8 100644 --- a/applications/dashcast/audio_decoder.c +++ b/applications/dashcast/audio_decoder.c @@ -99,6 +99,9 @@ int dc_audio_decoder_open(AudioInputFile *audio_input_file, AudioDataConf *audio return -1; } +#ifdef DC_AUDIO_RESAMPLER + audio_input_file->aresampler = NULL; +#endif audio_input_file->fifo = av_fifo_alloc(2 * MAX_AUDIO_PACKET_SIZE); audio_data_conf->channels = codec_ctx->channels; @@ -110,12 +113,57 @@ int dc_audio_decoder_open(AudioInputFile *audio_input_file, AudioDataConf *audio return 0; } +#ifdef DC_AUDIO_RESAMPLER +static int ensure_resampler(AudioInputFile *audio_input_file, int sample_rate, int num_channels, u64 channel_layout, enum AVSampleFormat sample_format) +{ + if (!audio_input_file->aresampler) { + audio_input_file->aresampler = avresample_alloc_context(); + if (!audio_input_file->aresampler) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot allocate the audio resampler. Aborting.\n")); + return -1; + } + av_opt_set_int(audio_input_file->aresampler, "in_channel_layout", channel_layout, 0); + av_opt_set_int(audio_input_file->aresampler, "out_channel_layout", DC_AUDIO_CHANNEL_LAYOUT, 0); + av_opt_set_int(audio_input_file->aresampler, "in_sample_fmt", sample_format, 0); + av_opt_set_int(audio_input_file->aresampler, "out_sample_fmt", DC_AUDIO_SAMPLE_FORMAT, 0); + av_opt_set_int(audio_input_file->aresampler, "in_sample_rate", sample_rate, 0); + av_opt_set_int(audio_input_file->aresampler, "out_sample_rate", DC_AUDIO_SAMPLE_RATE, 0); + av_opt_set_int(audio_input_file->aresampler, "in_channels", num_channels, 0); + av_opt_set_int(audio_input_file->aresampler, "out_channels", DC_AUDIO_NUM_CHANNELS, 0); + + if (avresample_open(audio_input_file->aresampler)) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not open the audio resampler. Aborting.\n")); + return -1; + } + } + + return 0; +} + +//resample - see http://ffmpeg.org/pipermail/libav-user/2012-June/002164.html +static int resample_audio(AudioInputFile *audio_input_file, AudioInputData *audio_input_data, AVCodecContext *audio_codec_ctx, uint8_t ***output, int *num_planes_out, int num_channels, enum AVSampleFormat sample_format) +{ + int i; + *num_planes_out = av_sample_fmt_is_planar(DC_AUDIO_SAMPLE_FORMAT) ? DC_AUDIO_NUM_CHANNELS : 1; + *output = (uint8_t**)av_malloc(*num_planes_out*sizeof(uint8_t*)); + for (i=0; i<*num_planes_out; i++) { + *output[i] = (uint8_t*)av_malloc(DC_AUDIO_MAX_CHUNCK_SIZE); //FIXME: fix using size below av_samples_get_buffer_size() + } + + if (avresample_convert(audio_input_file->aresampler, *output, DC_AUDIO_MAX_CHUNCK_SIZE, audio_input_data->aframe->nb_samples, audio_input_data->aframe->extended_data, audio_input_data->aframe->linesize[0], audio_input_data->aframe->nb_samples) < 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not resample audio frame. Aborting.\n")); + return -1; + } + + return 0; +} +#endif + int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audio_input_data) { int ret; AVPacket packet; int got_frame = 0; - //int locked_already = 0; AVCodecContext *codec_ctx; AudioDataNode *audio_data_node; @@ -155,14 +203,20 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi /* Flush decoder */ packet.data = NULL; packet.size = 0; + +#ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(audio_input_data->aframe); +#else + av_frame_unref(audio_input_data->aframe); +#endif + avcodec_decode_audio4(codec_ctx, audio_input_data->aframe, &got_frame, &packet); if (got_frame) { dc_producer_lock(&audio_input_data->producer, &audio_input_data->circular_buf); dc_producer_unlock_previous(&audio_input_data->producer, &audio_input_data->circular_buf); audio_data_node = (AudioDataNode*)dc_producer_produce(&audio_input_data->producer, &audio_input_data->circular_buf); - + audio_data_node->abuf_size = audio_input_data->aframe->linesize[0]; memcpy(audio_data_node->abuf, audio_input_data->aframe->data[0], audio_data_node->abuf_size); @@ -184,7 +238,12 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi /* Is this a packet from the audio stream? */ if (packet.stream_index == audio_input_file->astream_idx) { /* Set audio frame to default */ + +#ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(audio_input_data->aframe); +#else + av_frame_unref(audio_input_data->aframe); +#endif /* Decode audio frame */ if (avcodec_decode_audio4(codec_ctx, audio_input_data->aframe, &got_frame, &packet) < 0) { @@ -200,9 +259,54 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi audio_input_data->next_pts += ((int64_t)AV_TIME_BASE * audio_input_data->aframe->nb_samples) / codec_ctx->sample_rate; - /* Did we get a video frame? */ + /* Did we get an audio frame? */ if (got_frame) { - av_fifo_generic_write(audio_input_file->fifo, audio_input_data->aframe->data[0], audio_input_data->aframe->linesize[0], NULL); + uint8_t **data; + int data_size; +#ifdef DC_AUDIO_RESAMPLER + int num_planes_out; +#endif +#ifdef GPAC_USE_LIBAV + int sample_rate = codec_ctx->sample_rate; + int num_channels = codec_ctx->channels; + u64 channel_layout = codec_ctx->channel_layout; +#else + int sample_rate = audio_input_data->aframe->sample_rate; + int num_channels = audio_input_data->aframe->channels; + u64 channel_layout = audio_input_data->aframe->channel_layout; +#endif + enum AVSampleFormat sample_format = (enum AVSampleFormat)audio_input_data->aframe->format; + Bool resample = (sample_rate != DC_AUDIO_SAMPLE_RATE + || num_channels != DC_AUDIO_NUM_CHANNELS + || channel_layout != DC_AUDIO_CHANNEL_LAYOUT + || sample_format != DC_AUDIO_SAMPLE_FORMAT); + + /* Resample if needed */ + if (resample) { +#ifndef DC_AUDIO_RESAMPLER + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Audio resampling is needed at the decoding stage, but not supported by your version of DashCast. Aborting.\n")); + exit(1); +#else + uint8_t **output; + if (ensure_resampler(audio_input_file, sample_rate, num_channels, channel_layout, sample_format)) { + return -1; + } + + if (resample_audio(audio_input_file, audio_input_data, codec_ctx, &output, &num_planes_out, num_channels, sample_format)) { + return -1; + } else { + data = output; + av_samples_get_buffer_size(&data_size, num_channels, audio_input_data->aframe->nb_samples, sample_format, 0); + } +#endif + } else { + /*no resampling needed: read data from the AVFrame*/ + data = audio_input_data->aframe->extended_data; + data_size = audio_input_data->aframe->linesize[0]; + } + + assert(!av_sample_fmt_is_planar(DC_AUDIO_SAMPLE_FORMAT)); + av_fifo_generic_write(audio_input_file->fifo, data[0], data_size, NULL); if (/*audio_input_file->circular_buf.mode == OFFLINE*/audio_input_file->mode == ON_DEMAND || audio_input_file->mode == LIVE_MEDIA) { dc_producer_lock(&audio_input_data->producer, &audio_input_data->circular_buf); @@ -212,18 +316,12 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi /* Get the pointer of the current node in circular buffer. */ audio_data_node = (AudioDataNode *) dc_producer_produce(&audio_input_data->producer, &audio_input_data->circular_buf); -#ifdef GPAC_USE_LIBAV - audio_data_node->channels = codec_ctx->channels; - audio_data_node->channel_layout = codec_ctx->request_channel_layout; - audio_data_node->sample_rate = codec_ctx->sample_rate; -#else - audio_data_node->channels = audio_input_data->aframe->channels; - audio_data_node->channel_layout = audio_input_data->aframe->channel_layout; - audio_data_node->sample_rate = audio_input_data->aframe->sample_rate; -#endif - audio_data_node->format = audio_input_data->aframe->format; - audio_data_node->abuf_size = audio_input_data->aframe->linesize[0]; - av_fifo_generic_read(audio_input_file->fifo, audio_data_node->abuf, audio_data_node->abuf_size , NULL); + audio_data_node->channels = DC_AUDIO_NUM_CHANNELS; + audio_data_node->channel_layout = DC_AUDIO_CHANNEL_LAYOUT; + audio_data_node->sample_rate = DC_AUDIO_SAMPLE_RATE; + audio_data_node->format = DC_AUDIO_SAMPLE_FORMAT; + audio_data_node->abuf_size = data_size; + av_fifo_generic_read(audio_input_file->fifo, audio_data_node->abuf, audio_data_node->abuf_size, NULL); dc_producer_advance(&audio_input_data->producer, &audio_input_data->circular_buf); } else { @@ -238,7 +336,7 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi dc_producer_unlock_previous(&audio_input_data->producer, &audio_input_data->circular_buf); /* Get the pointer of the current node in circular buffer. */ - audio_data_node = (AudioDataNode *) dc_producer_produce( &audio_input_data->producer, &audio_input_data->circular_buf); + audio_data_node = (AudioDataNode *) dc_producer_produce(&audio_input_data->producer, &audio_input_data->circular_buf); audio_data_node->abuf_size = LIVE_FRAME_SIZE; av_fifo_generic_read(audio_input_file->fifo, audio_data_node->abuf, audio_data_node->abuf_size, NULL); @@ -246,6 +344,16 @@ int dc_audio_decoder_read(AudioInputFile *audio_input_file, AudioInputData *audi dc_producer_advance(&audio_input_data->producer, &audio_input_data->circular_buf); } } + +#ifdef DC_AUDIO_RESAMPLER + if (resample) { + int i; + for (i=0; iav_pkt_list); } + gf_list_del(audio_input_file->av_pkt_list); gf_mx_v(audio_input_file->av_pkt_list_mutex); gf_mx_del(audio_input_file->av_pkt_list_mutex); } av_fifo_free(audio_input_file->fifo); + +#ifdef DC_AUDIO_RESAMPLER + avresample_free(&audio_input_file->aresampler); +#endif } diff --git a/applications/dashcast/audio_decoder.h b/applications/dashcast/audio_decoder.h index a6fc08d..db094fb 100644 --- a/applications/dashcast/audio_decoder.h +++ b/applications/dashcast/audio_decoder.h @@ -30,6 +30,10 @@ #include "libavformat/avformat.h" #include "libavutil/fifo.h" +#ifdef DC_AUDIO_RESAMPLER +#include "libavutil/opt.h" +#include "libavresample/avresample.h" +#endif /* @@ -48,9 +52,15 @@ typedef struct { /* The index of the audio stream in the file. */ int astream_idx; + /* This is the output FIFO linking the decoder to the other encoder: only conveys + * stereo 44100 (and resample if needed) */ AVFifoBuffer *fifo; +#ifdef DC_AUDIO_RESAMPLER + /* Optional audio resampling between the decoder and the encoder */ + AVAudioResampleContext *aresampler; +#endif - int mode; + LockMode mode; int no_loop; } AudioInputFile; diff --git a/applications/dashcast/audio_encoder.c b/applications/dashcast/audio_encoder.c index 3cd7b11..f277d73 100644 --- a/applications/dashcast/audio_encoder.c +++ b/applications/dashcast/audio_encoder.c @@ -31,15 +31,17 @@ extern void build_dict(void *priv_data, const char *options); int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *audio_data_conf) { - int osize; + AVDictionary *opts = NULL; audio_output_file->fifo = av_fifo_alloc(2 * MAX_AUDIO_PACKET_SIZE); audio_output_file->aframe = FF_ALLOC_FRAME(); audio_output_file->adata_buf = (uint8_t*) av_malloc(2 * MAX_AUDIO_PACKET_SIZE); #ifndef GPAC_USE_LIBAV + audio_output_file->aframe->channels = -1; +#endif +#ifndef LIBAV_FRAME_OLD audio_output_file->aframe->channel_layout = 0; audio_output_file->aframe->sample_rate = -1; - audio_output_file->aframe->channels = -1; #endif audio_output_file->aframe->format = -1; audio_output_file->codec = avcodec_find_encoder_by_name(audio_data_conf->codec); @@ -48,7 +50,7 @@ int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *aud return -1; } - audio_output_file->codec_ctx = avcodec_alloc_context3(audio_output_file->codec); + audio_output_file->codec_ctx = avcodec_alloc_context3(audio_output_file->codec); audio_output_file->codec_ctx->codec_id = audio_output_file->codec->id; audio_output_file->codec_ctx->codec_type = AVMEDIA_TYPE_AUDIO; audio_output_file->codec_ctx->bit_rate = audio_data_conf->bitrate; @@ -61,7 +63,7 @@ int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *aud } audio_output_file->codec_ctx->channels = audio_data_conf->channels; audio_output_file->codec_ctx->channel_layout = AV_CH_LAYOUT_STEREO; /*FIXME: depends on channels -> http://ffmpeg.org/doxygen/trunk/channel__layout_8c_source.html#l00074*/ - audio_output_file->codec_ctx->sample_fmt = AV_SAMPLE_FMT_S16; + audio_output_file->codec_ctx->sample_fmt = audio_output_file->codec->sample_fmts[0]; #ifdef DC_AUDIO_RESAMPLER audio_output_file->aresampler = NULL; #endif @@ -73,27 +75,33 @@ int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *aud audio_output_file->astream_idx = 0; /* open the audio codec */ - if (avcodec_open2(audio_output_file->codec_ctx, audio_output_file->codec, NULL) < 0) { + av_dict_set(&opts, "strict", "experimental", 0); + if (avcodec_open2(audio_output_file->codec_ctx, audio_output_file->codec, &opts) < 0) { /*FIXME: if we enter here (set "mp2" as a codec and "200000" as a bitrate -> deadlock*/ GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output audio codec\n")); + av_dict_free(&opts); return -1; } + av_dict_free(&opts); + + audio_output_file->frame_bytes = audio_output_file->codec_ctx->frame_size * av_get_bytes_per_sample(DC_AUDIO_SAMPLE_FORMAT) * DC_AUDIO_NUM_CHANNELS; - osize = av_get_bytes_per_sample(audio_output_file->codec_ctx->sample_fmt); - audio_output_file->frame_bytes = audio_output_file->codec_ctx->frame_size * osize * audio_output_file->codec_ctx->channels; +#ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(audio_output_file->aframe); - audio_output_file->aframe->nb_samples = audio_output_file->frame_bytes - / (audio_output_file->codec_ctx->channels * av_get_bytes_per_sample(audio_output_file->codec_ctx->sample_fmt)); +#else + av_frame_unref(audio_output_file->aframe); +#endif + + + audio_output_file->aframe->nb_samples = audio_output_file->codec_ctx->frame_size; - if (avcodec_fill_audio_frame(audio_output_file->aframe, - audio_output_file->codec_ctx->channels, audio_output_file->codec_ctx->sample_fmt, - audio_output_file->adata_buf, audio_output_file->frame_bytes, 1) < 0) { + if (avcodec_fill_audio_frame(audio_output_file->aframe, audio_output_file->codec_ctx->channels, audio_output_file->codec_ctx->sample_fmt, + audio_output_file->adata_buf, audio_output_file->codec_ctx->frame_size * av_get_bytes_per_sample(audio_output_file->codec_ctx->sample_fmt) * audio_output_file->codec_ctx->channels, 1) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Fill audio frame failed\n")); return -1; } //audio_output_file->acc_samples = 0; - audio_output_file->frame_size = audio_output_file->codec_ctx->frame_size; return 0; } @@ -113,15 +121,15 @@ int dc_audio_encoder_read(AudioOutputFile *audio_output_file, AudioInputData *au audio_data_node = (AudioDataNode *) dc_consumer_consume(&audio_output_file->consumer, &audio_input_data->circular_buf); #ifndef GPAC_USE_LIBAV - audio_output_file->aframe->channels = audio_data_node->channels; - audio_output_file->aframe->channel_layout = audio_data_node->channel_layout; - audio_output_file->aframe->sample_rate = audio_data_node->sample_rate; + audio_output_file->aframe->channels = audio_output_file->codec_ctx->channels; #endif - audio_output_file->aframe->format = audio_data_node->format; +#ifndef LIBAV_FRAME_OLD + audio_output_file->aframe->channel_layout = audio_output_file->codec_ctx->channel_layout; + audio_output_file->aframe->sample_rate = audio_output_file->codec_ctx->sample_rate; +#endif + audio_output_file->aframe->format = audio_output_file->codec_ctx->sample_fmt; /* Write audio sample on fifo */ -// av_fifo_generic_write(audio_output_file->fifo, audio_data_node->aframe->data[0], -// audio_data_node->aframe->linesize[0], NULL); av_fifo_generic_write(audio_output_file->fifo, audio_data_node->abuf, audio_data_node->abuf_size, NULL); dc_consumer_advance(&audio_output_file->consumer); @@ -160,27 +168,88 @@ int dc_audio_encoder_flush(AudioOutputFile *audio_output_file, AudioInputData *a } #endif +#ifdef DC_AUDIO_RESAMPLER +static int ensure_resampler(AudioOutputFile *audio_output_file, AVCodecContext *audio_codec_ctx) +{ + if (!audio_output_file->aresampler) { + audio_output_file->aresampler = avresample_alloc_context(); + if (!audio_output_file->aresampler) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot allocate the audio resampler. Aborting.\n")); + return -1; + } + av_opt_set_int(audio_output_file->aresampler, "in_channel_layout", DC_AUDIO_CHANNEL_LAYOUT, 0); + av_opt_set_int(audio_output_file->aresampler, "out_channel_layout", audio_codec_ctx->channel_layout, 0); + av_opt_set_int(audio_output_file->aresampler, "in_sample_fmt", DC_AUDIO_SAMPLE_FORMAT, 0); + av_opt_set_int(audio_output_file->aresampler, "out_sample_fmt", audio_codec_ctx->sample_fmt, 0); + av_opt_set_int(audio_output_file->aresampler, "in_sample_rate", DC_AUDIO_SAMPLE_RATE, 0); + av_opt_set_int(audio_output_file->aresampler, "out_sample_rate", audio_codec_ctx->sample_rate, 0); + av_opt_set_int(audio_output_file->aresampler, "in_channels", DC_AUDIO_NUM_CHANNELS, 0); + av_opt_set_int(audio_output_file->aresampler, "out_channels", audio_codec_ctx->channels, 0); + + if (avresample_open(audio_output_file->aresampler)) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not open the audio resampler. Aborting.\n")); + return -1; + } + } + + return 0; +} + +//resample - see http://ffmpeg.org/pipermail/libav-user/2012-June/002164.html +static int resample_audio(AudioOutputFile *audio_output_file, AVCodecContext *audio_codec_ctx, int *num_planes_out) +{ + int i, linesize; + uint8_t **output; + *num_planes_out = av_sample_fmt_is_planar(audio_output_file->codec->sample_fmts[0]) ? audio_output_file->codec_ctx->channels : 1; + linesize = audio_output_file->codec_ctx->frame_size * av_get_bytes_per_sample(audio_output_file->codec->sample_fmts[0]) * audio_output_file->codec_ctx->channels / *num_planes_out; + output = (uint8_t**)av_malloc(*num_planes_out*sizeof(uint8_t*)); + for (i=0; i<*num_planes_out; i++) { + output[i] = (uint8_t*)av_malloc(linesize); + } + + if (avresample_convert(audio_output_file->aresampler, output, linesize, audio_output_file->aframe->nb_samples, audio_output_file->aframe->extended_data, audio_output_file->aframe->linesize[0], audio_output_file->aframe->nb_samples) < 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not resample audio frame. Aborting.\n")); + return -1; + } + + audio_output_file->aframe->extended_data = output; + for (i=0; i<*num_planes_out; i++) { + audio_output_file->aframe->linesize[i] = linesize; + } + audio_codec_ctx->channel_layout = audio_output_file->aframe->channel_layout; + audio_codec_ctx->sample_fmt = audio_output_file->aframe->format; + audio_codec_ctx->sample_rate = audio_output_file->aframe->sample_rate; +#ifndef GPAC_USE_LIBAV + audio_codec_ctx->channels = audio_output_file->aframe->channels; +#endif + + return 0; +} +#endif + int dc_audio_encoder_encode(AudioOutputFile *audio_output_file, AudioInputData *audio_input_data) { int got_pkt; -#ifdef DC_AUDIO_RESAMPLER - int i; -#endif - //AVStream *audio_stream = audio_output_file->av_fmt_ctx->streams[audio_output_file->astream_idx]; - //AVCodecContext *audio_codec_ctx = audio_stream->codec; AVCodecContext *audio_codec_ctx = audio_output_file->codec_ctx; while (av_fifo_size(audio_output_file->fifo) >= audio_output_file->frame_bytes) { +#ifdef DC_AUDIO_RESAMPLER + uint8_t **data; //mirror AVFrame::data + int num_planes_out; +#endif + Bool resample; + av_fifo_generic_read(audio_output_file->fifo, audio_output_file->adata_buf, audio_output_file->frame_bytes, NULL); audio_output_file->aframe->data[0] = audio_output_file->adata_buf; audio_output_file->aframe->linesize[0] = audio_output_file->frame_bytes; + audio_output_file->aframe->linesize[1] = 0; av_init_packet(&audio_output_file->packet); audio_output_file->packet.data = NULL; audio_output_file->packet.size = 0; - /* + /* * Set PTS (method 1) */ //audio_output_file->aframe->pts = audio_input_data->next_pts; @@ -196,59 +265,23 @@ int dc_audio_encoder_encode(AudioOutputFile *audio_output_file, AudioInputData * // audio_output_file->aframe->pts = av_rescale_q(now, avr, audio_codec_ctx->time_base); //} + resample = (DC_AUDIO_SAMPLE_FORMAT != audio_codec_ctx->sample_fmt + || DC_AUDIO_SAMPLE_RATE != audio_codec_ctx->sample_rate + || DC_AUDIO_NUM_CHANNELS != audio_codec_ctx->channels + || DC_AUDIO_CHANNEL_LAYOUT != audio_codec_ctx->channel_layout); /* Resample if needed */ - if ( audio_output_file->aframe->format != audio_codec_ctx->sample_fmt -#ifndef GPAC_USE_LIBAV - || audio_output_file->aframe->sample_rate != audio_codec_ctx->sample_rate - || audio_output_file->aframe->channel_layout != audio_codec_ctx->channel_layout -#endif - ) { -#ifndef DC_AUDIO_RESAMPLER - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Audio resampling is needed, but not supported by your version of DashCast. Aborting.\n")); + if (resample) { +#ifndef DC_AUDIO_RESAMPLER + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Audio resampling is needed at the encoding stage, but not supported by your version of DashCast. Aborting.\n")); exit(1); #else - if (!audio_output_file->aresampler) { - audio_output_file->aresampler = avresample_alloc_context(); - if (!audio_output_file->aresampler) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot allocate the audio resampler. Aborting.\n")); - return -1; - } - av_opt_set_int(audio_output_file->aresampler, "in_channel_layout", audio_output_file->aframe->channel_layout, 0); - av_opt_set_int(audio_output_file->aresampler, "out_channel_layout", audio_codec_ctx->channel_layout, 0); - av_opt_set_int(audio_output_file->aresampler, "in_sample_fmt", audio_output_file->aframe->format, 0); - av_opt_set_int(audio_output_file->aresampler, "out_sample_fmt", audio_codec_ctx->sample_fmt, 0); - av_opt_set_int(audio_output_file->aresampler, "in_sample_rate", audio_output_file->aframe->sample_rate, 0); - av_opt_set_int(audio_output_file->aresampler, "out_sample_rate", audio_codec_ctx->sample_rate, 0); - av_opt_set_int(audio_output_file->aresampler, "in_channels", audio_output_file->aframe->channels, 0); - av_opt_set_int(audio_output_file->aresampler, "out_channels", audio_codec_ctx->channels, 0); - - if (avresample_open(audio_output_file->aresampler)) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not open the audio resampler. Aborting.\n")); - return -1; - } + if (ensure_resampler(audio_output_file, audio_codec_ctx)) { + return -1; } - //resample - see http://ffmpeg.org/pipermail/libav-user/2012-June/002164.html - { - int num_planes = av_sample_fmt_is_planar(audio_codec_ctx->sample_fmt) ? 1 : audio_codec_ctx->channels; - uint8_t **output = (uint8_t**)av_malloc(num_planes*sizeof(uint8_t*)); - for (i=0; iaresampler, output, 192000, audio_output_file->aframe->nb_samples, audio_output_file->aframe->extended_data, audio_output_file->aframe->linesize[0], audio_output_file->aframe->nb_samples) < 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Could not resample audio frame. Aborting.\n")); - return -1; - } - num_planes = av_sample_fmt_is_planar(audio_codec_ctx->sample_fmt) ? audio_codec_ctx->channels : 1; - for (i=0; iaframe->extended_data[i]); - } - av_free(audio_output_file->aframe->extended_data); - audio_output_file->aframe->extended_data = output; - audio_codec_ctx->channel_layout = audio_output_file->aframe->channel_layout; - audio_codec_ctx->sample_fmt = audio_output_file->aframe->format; - audio_codec_ctx->sample_rate = audio_output_file->aframe->sample_rate; - audio_codec_ctx->channels = audio_output_file->aframe->channels; + data = audio_output_file->aframe->extended_data; + if (resample_audio(audio_output_file, audio_codec_ctx, &num_planes_out)) { + return -1; } #endif } @@ -256,8 +289,29 @@ int dc_audio_encoder_encode(AudioOutputFile *audio_output_file, AudioInputData * /* Encode audio */ if (avcodec_encode_audio2(audio_codec_ctx, &audio_output_file->packet, audio_output_file->aframe, &got_pkt) != 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Error while encoding audio.\n")); +#ifdef DC_AUDIO_RESAMPLER + if (resample) { + int i; + for (i=0; iaframe->extended_data[i]); + } + av_free(audio_output_file->aframe->extended_data); + audio_output_file->aframe->extended_data = data; + } +#endif return -1; } + +#ifdef DC_AUDIO_RESAMPLER + if (resample) { + int i; + for (i=0; iaframe->extended_data[i]); + } + av_free(audio_output_file->aframe->extended_data); + audio_output_file->aframe->extended_data = data; + } +#endif if (got_pkt) { //audio_output_file->acc_samples += audio_output_file->aframe->nb_samples; @@ -287,4 +341,8 @@ void dc_audio_encoder_close(AudioOutputFile *audio_output_file) avcodec_close(audio_output_file->codec_ctx); av_free(audio_output_file->codec_ctx); + +#ifdef DC_AUDIO_RESAMPLER + avresample_free(&audio_output_file->aresampler); +#endif } diff --git a/applications/dashcast/audio_encoder.h b/applications/dashcast/audio_encoder.h index c30499a..b8fbd3d 100644 --- a/applications/dashcast/audio_encoder.h +++ b/applications/dashcast/audio_encoder.h @@ -33,8 +33,8 @@ * * @param audio_output_file [in] add an audio stream to the file * with the parameters already passed to open_audio_output - * - * @return 0 on success, -1 on failure + * + * @return 0 on success, -1 on failure */ int dc_audio_encoder_open(AudioOutputFile *audio_output_file, AudioDataConf *audio_data_conf); @@ -43,20 +43,20 @@ int dc_audio_encoder_read(AudioOutputFile *audio_output_file, AudioInputData *au //int dc_audio_encoder_flush(AudioOutputFile *audio_output_file, AudioInputData *audio_input_data); /* - * Read the decoded audio sample from circular buffer (which is in audio_input_data) + * Read the decoded audio sample from circular buffer (which is in audio_input_data) * and encode and write them on the output file - * + * * @param audio_output_file [in] audio output file * @param audio_input_data [in] audio input data structure which contains a circular buffer with audio samples - * + * * @return 0 on success, -1 on failure, -2 on finishing; - * when there is no more data on circular buffer to encode - */ + * when there is no more data on circular buffer to encode + */ int dc_audio_encoder_encode(AudioOutputFile *audio_output_file, AudioInputData *audio_input_data); /* * Close the output audio file - * + * * @param audio_output_file [in] audio output file */ void dc_audio_encoder_close(AudioOutputFile *audio_output_file); diff --git a/applications/dashcast/audio_muxer.c b/applications/dashcast/audio_muxer.c index 0e41e34..8ca4eae 100644 --- a/applications/dashcast/audio_muxer.c +++ b/applications/dashcast/audio_muxer.c @@ -53,23 +53,47 @@ int dc_gpac_audio_moov_create(AudioOutputFile *audio_output_file, char *filename esd->decoderConfig = (GF_DecoderConfig *) gf_odf_desc_new(GF_ODF_DCD_TAG); esd->slConfig = (GF_SLConfig *) gf_odf_desc_new(GF_ODF_SLC_TAG); esd->decoderConfig->streamType = GF_STREAM_AUDIO; - esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1; - esd->decoderConfig->bufferSizeDB = 20; - esd->slConfig->timestampResolution = audio_codec_ctx->sample_rate; - esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); - esd->ESID = 1; + if (!strcmp(audio_output_file->codec_ctx->codec->name, "aac")) { //TODO: find an automatic table + esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_LCP; + esd->decoderConfig->bufferSizeDB = 20; + esd->slConfig->timestampResolution = audio_codec_ctx->sample_rate; + esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); + esd->ESID = 1; #ifndef GPAC_DISABLE_AV_PARSERS - memset(&acfg, 0, sizeof(GF_M4ADecSpecInfo)); - acfg.base_object_type = GF_M4A_LAYER2; - acfg.base_sr = audio_codec_ctx->sample_rate; - acfg.nb_chan = audio_codec_ctx->channels; - acfg.sbr_object_type = 0; - acfg.audioPL = gf_m4a_get_profile(&acfg); - - ret = gf_m4a_write_config(&acfg, &esd->decoderConfig->decoderSpecificInfo->data, &esd->decoderConfig->decoderSpecificInfo->dataLength); - assert(ret == GF_OK); + memset(&acfg, 0, sizeof(GF_M4ADecSpecInfo)); + acfg.base_object_type = GF_M4A_AAC_LC; + acfg.base_sr = audio_codec_ctx->sample_rate; + acfg.nb_chan = audio_codec_ctx->channels; + acfg.sbr_object_type = 0; + acfg.audioPL = gf_m4a_get_profile(&acfg); + + ret = gf_m4a_write_config(&acfg, &esd->decoderConfig->decoderSpecificInfo->data, &esd->decoderConfig->decoderSpecificInfo->dataLength); + assert(ret == GF_OK); #endif + } else { + if (strcmp(audio_output_file->codec_ctx->codec->name, "mp2")) { + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("Unlisted codec, setting GPAC_OTI_AUDIO_MPEG1 descriptor.\n")); + } + esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1; + esd->decoderConfig->bufferSizeDB = 20; + esd->slConfig->timestampResolution = audio_codec_ctx->sample_rate; + esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); + esd->ESID = 1; + +#ifndef GPAC_DISABLE_AV_PARSERS + memset(&acfg, 0, sizeof(GF_M4ADecSpecInfo)); + acfg.base_object_type = GF_M4A_LAYER2; + acfg.base_sr = audio_codec_ctx->sample_rate; + acfg.nb_chan = audio_codec_ctx->channels; + acfg.sbr_object_type = 0; + acfg.audioPL = gf_m4a_get_profile(&acfg); + + ret = gf_m4a_write_config(&acfg, &esd->decoderConfig->decoderSpecificInfo->data, &esd->decoderConfig->decoderSpecificInfo->dataLength); + assert(ret == GF_OK); +#endif + } + //gf_isom_store_movie_config(video_output_file->isof, 0); track = gf_isom_new_track(audio_output_file->isof, esd->ESID, GF_ISOM_MEDIA_AUDIO, audio_codec_ctx->sample_rate); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("TimeScale: %d \n", audio_codec_ctx->time_base.den)); @@ -98,7 +122,7 @@ int dc_gpac_audio_moov_create(AudioOutputFile *audio_output_file, char *filename bpsample = av_get_bytes_per_sample(audio_output_file->codec_ctx->sample_fmt) * 8; ret = gf_isom_set_audio_info(audio_output_file->isof, track, di, - audio_codec_ctx->sample_rate, audio_output_file->codec_ctx->channels, bpsample); + audio_codec_ctx->sample_rate, audio_output_file->codec_ctx->channels, bpsample); if (ret != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_set_audio_info\n", gf_error_to_string(ret))); return -1; @@ -106,11 +130,11 @@ int dc_gpac_audio_moov_create(AudioOutputFile *audio_output_file, char *filename #ifndef GPAC_DISABLE_AV_PARSERS ret = gf_isom_set_pl_indication(audio_output_file->isof, GF_ISOM_PL_AUDIO, acfg.audioPL); -#endif if (ret != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_set_pl_indication\n", gf_error_to_string(ret))); return -1; } +#endif GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("time scale: %d sample dur: %d \n", audio_codec_ctx->time_base.den, audio_output_file->codec_ctx->frame_size)); @@ -148,10 +172,6 @@ int dc_gpac_audio_isom_open_seg(AudioOutputFile *audio_output_file, char *filena int dc_gpac_audio_isom_write(AudioOutputFile *audio_output_file) { GF_Err ret; - //AVStream *video_stream = video_output_file->av_fmt_ctx->streams[video_output_file->vstream_idx]; - //AVCodecContext *video_codec_ctx = video_stream->codec; - //AVCodecContext *audio_codec_ctx = audio_output_file->codec_ctx; - audio_output_file->sample->data = (char *) audio_output_file->packet.data; audio_output_file->sample->dataLength = audio_output_file->packet.size; @@ -207,6 +227,7 @@ int dc_ffmpeg_audio_muxer_open(AudioOutputFile *audio_output_file, char *filenam { AVStream *audio_stream; AVOutputFormat *output_fmt; + AVDictionary *opts = NULL; AVCodecContext *audio_codec_ctx = audio_output_file->codec_ctx; audio_output_file->av_fmt_ctx = NULL; @@ -252,7 +273,8 @@ int dc_ffmpeg_audio_muxer_open(AudioOutputFile *audio_output_file, char *filenam audio_stream->codec->bit_rate = audio_codec_ctx->bit_rate;//audio_output_file->audio_data_conf->bitrate; audio_stream->codec->sample_rate = audio_codec_ctx->sample_rate;//audio_output_file->audio_data_conf->samplerate; audio_stream->codec->channels = audio_codec_ctx->channels;//audio_output_file->audio_data_conf->channels; - audio_stream->codec->sample_fmt = AV_SAMPLE_FMT_S16; + assert(audio_codec_ctx->codec->sample_fmts); + audio_stream->codec->sample_fmt = audio_codec_ctx->codec->sample_fmts[0]; // if (audio_output_file->av_fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) // audio_output_file->codec_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; @@ -260,10 +282,13 @@ int dc_ffmpeg_audio_muxer_open(AudioOutputFile *audio_output_file, char *filenam //video_stream->codec = video_output_file->codec_ctx; /* open the video codec */ - if (avcodec_open2(audio_stream->codec, audio_output_file->codec, NULL) < 0) { + av_dict_set(&opts, "strict", "experimental", 0); + if (avcodec_open2(audio_stream->codec, audio_output_file->codec, &opts) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video codec\n")); + av_dict_free(&opts); return -1; } + av_dict_free(&opts); avformat_write_header(audio_output_file->av_fmt_ctx, NULL); @@ -387,7 +412,7 @@ int dc_audio_muxer_write(AudioOutputFile *audio_output_file, int frame_nb) case GPAC_INIT_AUDIO_MUXER: if (frame_nb % audio_output_file->frame_per_frag == 0) { gf_isom_start_fragment(audio_output_file->isof, 1); - gf_isom_set_traf_base_media_decode_time(audio_output_file->isof, 1, audio_output_file->first_dts * audio_output_file->frame_size); + gf_isom_set_traf_base_media_decode_time(audio_output_file->isof, 1, audio_output_file->first_dts * audio_output_file->codec_ctx->frame_size); audio_output_file->first_dts += audio_output_file->frame_per_frag; } dc_gpac_audio_isom_write(audio_output_file); diff --git a/applications/dashcast/audio_muxer.h b/applications/dashcast/audio_muxer.h index 67c4adb..148d8c1 100644 --- a/applications/dashcast/audio_muxer.h +++ b/applications/dashcast/audio_muxer.h @@ -104,9 +104,6 @@ typedef struct { int first_dts; u32 seg_marker; - - int frame_size; - } AudioOutputFile; int dc_audio_muxer_init(AudioOutputFile *audio_output_file, AudioDataConf *audio_data_conf, AudioMuxerType muxer_type, int frame_per_seg, int frame_per_frag, u32 seg_marker); diff --git a/applications/dashcast/circular_buffer.c b/applications/dashcast/circular_buffer.c index 6fae808..4f1e6f4 100644 --- a/applications/dashcast/circular_buffer.c +++ b/applications/dashcast/circular_buffer.c @@ -200,7 +200,7 @@ int dc_producer_lock(Producer *producer, CircularBuffer *circular_buf) GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("producer %s exits lock %d \n", producer->name, producer->idx)); gf_mx_v(node->mutex); - + return 0; } diff --git a/applications/dashcast/circular_buffer.h b/applications/dashcast/circular_buffer.h index 4e90a5e..e660440 100644 --- a/applications/dashcast/circular_buffer.h +++ b/applications/dashcast/circular_buffer.h @@ -47,7 +47,7 @@ typedef enum { /* * Every node of the circular buffer has a data, plus - * all the variables needed for multithread management. + * all the variables needed for multithread management. */ typedef struct { /* Pointer to the data on the node */ @@ -80,18 +80,18 @@ typedef struct { */ typedef struct { /* The size of circular buffer */ - u32 size; + u32 size; /* A list of all the nodes */ - Node *list; + Node *list; /* The mode for multithread management. */ - LockMode mode; + LockMode mode; /* The maximum number of the consumers using the circular buffer */ u32 max_num_consumers; } CircularBuffer; /* * Producer has an index to the circular buffer. - */ + */ typedef struct { /* The index where the producer is using */ int idx; @@ -115,7 +115,7 @@ typedef struct { /* * Create a circular buffer - * + * * @param circular_buf [out] circular buffer to be created * @param size [in] size of circular buffer * @param mode [in] mode of multithread management (LIVE or OFFLINE) @@ -130,9 +130,9 @@ void dc_circular_buffer_create(CircularBuffer *circular_buf, u32 size, LockMode */ void dc_circular_buffer_destroy(CircularBuffer *circular_buf); -/* +/* * Initialize a consumer - * + * * @param consumer [out] the consumer to be initialize * @param num_consumers [in] maximum number of the consumers */ @@ -148,12 +148,12 @@ void * dc_consumer_consume(Consumer *consumer, CircularBuffer *circular_buf); /* * Consumer lock on circular buffer - * + * * @param consumer [in] consumer * @param circular_buf [in] circular buffer * - * @return 0 on success, -1 if the node in question is the last node and not usable. - */ + * @return 0 on success, -1 if the node in question is the last node and not usable. + */ int dc_consumer_lock(Consumer *consumer, CircularBuffer *circular_buf); /* @@ -178,14 +178,14 @@ int dc_consumer_unlock_previous(Consumer *consumer, CircularBuffer *circular_buf /* * Consumer leads its index - * + * * @param consumer [in] consumer */ void dc_consumer_advance(Consumer *consumer); -/* +/* * Initialize a producer - * + * * @param producer [out] the producer to be initialize * @param maxpro [in] maximum number of the producers */ @@ -201,12 +201,12 @@ void * dc_producer_produce(Producer *producer, CircularBuffer *circular_buf); /* * Producer lock on circular buffer - * + * * @param producer [in] producer * @param circular_buf [in] circular buffer * * @return 0 on success, -1 if the mode is live and cannot wait. - */ + */ int dc_producer_lock(Producer *producer, CircularBuffer *circular_buf); /* @@ -227,7 +227,7 @@ void dc_producer_unlock_previous(Producer *, CircularBuffer *); /* * Producer leads its index - * + * * @param producer [in] producer * @param circular_buf [in] circular buffer */ @@ -235,7 +235,7 @@ void dc_producer_advance(Producer *producer, CircularBuffer *); /* * Producer signal that the current node is the last node - * + * * @param producer [in] producer * @param circular_buf [in] circular buffer */ diff --git a/applications/dashcast/cmd_data.c b/applications/dashcast/cmd_data.c index 9f64326..1d35e11 100644 --- a/applications/dashcast/cmd_data.c +++ b/applications/dashcast/cmd_data.c @@ -61,13 +61,13 @@ int dc_str_to_resolution(char *str, int *width, int *height) #define DEFAULT_VIDEO_HEIGHT 480 #define DEFAULT_VIDEO_CODEC "libx264" #define DEFAULT_AUDIO_BITRATE 192000 -#define DEFAULT_AUDIO_SAMPLERATE 48000 +#define DEFAULT_AUDIO_SAMPLERATE 44100 #define DEFAULT_AUDIO_CHANNELS 2 -#define DEFAULT_AUDIO_CODEC "mp2" +#define DEFAULT_AUDIO_CODEC "aac" static void dc_create_configuration(CmdData *cmd_data) -{ +{ u32 i; GF_Config *conf = cmd_data->conf; u32 sec_count = gf_cfg_get_section_count(conf); @@ -77,7 +77,7 @@ static void dc_create_configuration(CmdData *cmd_data) sec_count = gf_cfg_get_section_count(conf); } for (i=0; ivideo_data_conf.bitrate); gf_cfg_set_key(conf, section_name, "bitrate", value); } - + if (!gf_cfg_get_key(conf, section_name, "framerate")) { if (cmd_data->video_data_conf.framerate == -1) cmd_data->video_data_conf.framerate = DEFAULT_VIDEO_FRAMERATE; snprintf(value, sizeof(value), "%d", cmd_data->video_data_conf.framerate); gf_cfg_set_key(conf, section_name, "framerate", value); } - + if (!gf_cfg_get_key(conf, section_name, "width")) { if (cmd_data->video_data_conf.width == -1) cmd_data->video_data_conf.width = DEFAULT_VIDEO_WIDTH; snprintf(value, sizeof(value), "%d", cmd_data->video_data_conf.width); gf_cfg_set_key(conf, section_name, "width", value); } - + if (!gf_cfg_get_key(conf, section_name, "height")) { if (cmd_data->video_data_conf.height == -1) cmd_data->video_data_conf.height = DEFAULT_VIDEO_HEIGHT; snprintf(value, sizeof(value), "%d", cmd_data->video_data_conf.height); gf_cfg_set_key(conf, section_name, "height", value); } - + if (!gf_cfg_get_key(conf, section_name, "crop_x")) { if (cmd_data->video_data_conf.crop_x == -1) cmd_data->video_data_conf.crop_x = 0; snprintf(value, sizeof(value), "%d", cmd_data->video_data_conf.crop_x); gf_cfg_set_key(conf, section_name, "crop_x", value); } - + if (!gf_cfg_get_key(conf, section_name, "crop_y")) { if (cmd_data->video_data_conf.crop_y == -1) cmd_data->video_data_conf.crop_y = 0; snprintf(value, sizeof(value), "%d", cmd_data->video_data_conf.crop_y); gf_cfg_set_key(conf, section_name, "crop_y", value); } - + if (!gf_cfg_get_key(conf, section_name, "codec")) gf_cfg_set_key(conf, section_name, "codec", DEFAULT_VIDEO_CODEC); } - + if (strcmp(section_type, "audio") == 0) { if (!gf_cfg_get_key(conf, section_name, "bitrate")) { if (cmd_data->audio_data_conf.bitrate == -1) @@ -135,21 +135,21 @@ static void dc_create_configuration(CmdData *cmd_data) snprintf(value, sizeof(value), "%d", cmd_data->audio_data_conf.bitrate); gf_cfg_set_key(conf, section_name, "bitrate", value); } - + if (!gf_cfg_get_key(conf, section_name, "samplerate")) { if (cmd_data->audio_data_conf.samplerate == -1) cmd_data->audio_data_conf.samplerate = DEFAULT_AUDIO_SAMPLERATE; snprintf(value, sizeof(value), "%d", cmd_data->audio_data_conf.samplerate); gf_cfg_set_key(conf, section_name, "samplerate", value); } - + if (!gf_cfg_get_key(conf, section_name, "channels")) { if (cmd_data->audio_data_conf.channels == -1) cmd_data->audio_data_conf.channels = DEFAULT_AUDIO_CHANNELS; snprintf(value, sizeof(value), "%d", cmd_data->audio_data_conf.channels); gf_cfg_set_key(conf, section_name, "channels", value); } - + if (!gf_cfg_get_key(conf, section_name, "codec")) gf_cfg_set_key(conf, section_name, "codec", DEFAULT_AUDIO_CODEC); } @@ -217,8 +217,9 @@ int dc_read_configuration(CmdData *cmd_data) for (i=0; ivideo_lst); i++) { VideoDataConf *video_data_conf = gf_list_get(cmd_data->video_lst, i); fprintf(stdout, " id:%s\tres:%dx%d\tvbr:%d\n", video_data_conf->filename, - video_data_conf->width, video_data_conf->height, - video_data_conf->bitrate/*, video_data_conf->framerate, video_data_conf->codec*/); } + video_data_conf->width, video_data_conf->height, + video_data_conf->bitrate/*, video_data_conf->framerate, video_data_conf->codec*/); + } for (i=0; iaudio_lst); i++) { AudioDataConf *audio_data_conf = gf_list_get(cmd_data->audio_lst, i); @@ -393,99 +394,99 @@ int dc_parse_command(int argc, char **argv, CmdData *cmd_data) int i; const char *command_usage = - "Usage: DashCast [options]\n" - "\n" - "General options:\n" - " -log-file filename set output log file. Also works with -lf\n" - " -logs LOGS set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" + "Usage: DashCast [options]\n" + "\n" + "General options:\n" + " -log-file filename set output log file. Also works with -lf\n" + " -logs LOGS set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" #ifdef GPAC_MEMORY_TRACKING - " -mem-track enable the memory tracker\n" + " -mem-track enable the memory tracker\n" #endif - " -conf filename set the configuration file name (default: dashcast.conf)\n" - " -switch-source filename set the configuration file name for source switching\n" - "\n" - "Live options:\n" - " -live system is live and input is a camera\n" - " -live-media system is live and input is a media file\n" - " -no-loop system does not loop on the input media file when live\n" - " -dynamic-ast changes segment availability start time at each MPD generation (old behaviour but not allowed in most profiles)\n" - " -insert-utc inserts UTC clock at the start of each segment\n" - "\n" - "Source options:\n" - " -npts use frame counting for timestamps (not error-free) instead of source timing (default)\n" - " -av string set the source name for a multiplexed audio and video input\n" - " - if this option is present, neither '-a' nor '-v' shall be present\n" - "* Video options:\n" - " -v string set the source name for a video input\n" - " - if input is from a webcam, use \"/dev/video[x]\" \n" - " where x is the video device number\n" - " - if input is the screen video, use \":0.0+[x],[y]\" \n" - " which captures from upper-left at x,y\n" - " - if input is from stdin, use \"pipe:\"\n" - " -vf string set the input video format\n" + " -conf filename set the configuration file name (default: dashcast.conf)\n" + " -switch-source filename set the configuration file name for source switching\n" + "\n" + "Live options:\n" + " -live system is live and input is a camera\n" + " -live-media system is live and input is a media file\n" + " -no-loop system does not loop on the input media file when live\n" + " -dynamic-ast changes segment availability start time at each MPD generation (old behaviour but not allowed in most profiles)\n" + " -insert-utc inserts UTC clock at the start of each segment\n" + "\n" + "Source options:\n" + " -npts use frame counting for timestamps (not error-free) instead of source timing (default)\n" + " -av string set the source name for a multiplexed audio and video input\n" + " - if this option is present, neither '-a' nor '-v' shall be present\n" + "* Video options:\n" + " -v string set the source name for a video input\n" + " - if input is from a webcam, use \"/dev/video[x]\" \n" + " where x is the video device number\n" + " - if input is the screen video, use \":0.0+[x],[y]\" \n" + " which captures from upper-left at x,y\n" + " - if input is from stdin, use \"pipe:\"\n" + " -vf string set the input video format\n" #ifdef WIN32 - " - to capture from a VfW webcam, set vfwcap\n" - " - to capture from a directshow device, set dshow\n" + " - to capture from a VfW webcam, set vfwcap\n" + " - to capture from a directshow device, set dshow\n" #else - " - to capture from a webcam, set video4linux2\n" - " - to capture the screen, set x11grab\n" - " -v4l2f inv4l2f inv4l2f is the input format for webcam acquisition\n" - " - it can be mjpeg, yuyv422, etc.\n" + " - to capture from a webcam, set video4linux2\n" + " - to capture the screen, set x11grab\n" + " -v4l2f inv4l2f inv4l2f is the input format for webcam acquisition\n" + " - it can be mjpeg, yuyv422, etc.\n" #endif - " -pixf FMT set the input pixel format\n" - " -vfr N force the input video framerate\n" - " -vres WxH force the video resolution (e.g. 640x480)\n" - " -vcrop XxY crop the source video from X pixels left and Y pixels top. Must be used with -vres.\n" - " -gdr use Gradual Decoder Refresh feature for video encoding (h264 codec only)\n" - "* Audio options:\n" - " -a string set the source name for an audio input\n" - " - if input is from microphone, use \"plughw:[x],[y]\"\n" - " where x is the card number and y is the device number\n" - " -af string set the input audio format\n" - "\n" - "Output options:\n" - "* Video encoding options:\n" - " -vcodec string set the output video codec (default: h264)\n" + " -pixf FMT set the input pixel format\n" + " -vfr N force the input video framerate\n" + " -vres WxH force the video resolution (e.g. 640x480)\n" + " -vcrop XxY crop the source video from X pixels left and Y pixels top. Must be used with -vres.\n" + " -gdr use Gradual Decoder Refresh feature for video encoding (h264 codec only)\n" + "* Audio options:\n" + " -a string set the source name for an audio input\n" + " - if input is from microphone, use \"plughw:[x],[y]\"\n" + " where x is the card number and y is the device number\n" + " -af string set the input audio format\n" + "\n" + "Output options:\n" + "* Video encoding options:\n" + " -vcodec string set the output video codec (default: h264)\n" #if 0 //TODO: bind to option and params - test first how it binds to current input parameters - " -vb int set the output video bitrate (in bits)\n" + " -vb int set the output video bitrate (in bits)\n" #endif - " -vcustom string send custom parameters directly to the audio encoder\n" - "* Audio encoding options:\n" - " -acodec string set the output audio codec (default: mp2)\n" + " -vcustom string send custom parameters directly to the audio encoder\n" + "* Audio encoding options:\n" + " -acodec string set the output audio codec (default: aac)\n" #if 0 //TODO: bind to option and params - test first how it binds to current input parameters - " -ab int set the output audio bitrate in bits (default: 192000)\n" - " -as int set the sample rate (default: 48000)\n" - " -ach int set the number of output audio channels (default: 2)\n" + " -ab int set the output audio bitrate in bits (default: 192000)\n" + " -as int set the sample rate (default: 44100)\n" + " -ach int set the number of output audio channels (default: 2)\n" #endif - " -acustom string send custom parameters directly to the audio encoder\n" - "\n" - "DASH options:\n" - " -seg-dur dur:int set the segment duration in millisecond (default value: 1000)\n" - " -frag-dur dur:int set the fragment duration in millisecond (default value: 1000)\n" - " -seg-marker marker:str add a marker box named marker at the end of DASH segment\n" - " -out outdir:str outdir is the output data directory (default: output)\n" - " -mpd mpdname:str mpdname is the MPD file name (default: dashcast.mpd)\n" - " -ast-offset dur:int dur is the MPD availabilityStartTime shift in milliseconds (default value: 1000)\n" - " -mpd-refresh dur:int dur is the MPD minimumUpdatePeriod in seconds\n" - " -time-shift dur:int dur is the MPD TimeShiftBufferDepth in seconds\n" - " - the default value is 10. Specify -1 to keep all files.\n" - " -min-buffer dur:float dur is the MPD minBufferTime in seconds (default value: 1.0)\n" - " -base-url baseurl:str baseurl is the MPD BaseURL\n" - "\n" - "\n" - "Examples:\n" - "\n" - " DashCast -av test.avi -live-media\n" - " DashCast -a test_audio.mp3 -v test_audio.mp4 -live-media\n" + " -acustom string send custom parameters directly to the audio encoder\n" + "\n" + "DASH options:\n" + " -seg-dur dur:int set the segment duration in millisecond (default value: 1000)\n" + " -frag-dur dur:int set the fragment duration in millisecond (default value: 1000)\n" + " -seg-marker marker:str add a marker box named marker at the end of DASH segment\n" + " -out outdir:str outdir is the output data directory (default: output)\n" + " -mpd mpdname:str mpdname is the MPD file name (default: dashcast.mpd)\n" + " -ast-offset dur:int dur is the MPD availabilityStartTime shift in milliseconds (default value: 1000)\n" + " -mpd-refresh dur:int dur is the MPD minimumUpdatePeriod in seconds\n" + " -time-shift dur:int dur is the MPD TimeShiftBufferDepth in seconds\n" + " - the default value is 10. Specify -1 to keep all files.\n" + " -min-buffer dur:float dur is the MPD minBufferTime in seconds (default value: 1.0)\n" + " -base-url baseurl:str baseurl is the MPD BaseURL\n" + "\n" + "\n" + "Examples:\n" + "\n" + " DashCast -av test.avi -live-media\n" + " DashCast -a test_audio.mp3 -v test_audio.mp4 -live-media\n" #ifdef WIN32 - " DashCast -vf vfwcap -vres 1280x720 -vfr 24 -v 0 -live\n" - " DashCast -vf dshow -vres 1280x720 -vfr 24 -v video=\"screen-capture-recorder\" -live (please install http://screencapturer.sf.net/)\n" - " DashCast -vf dshow -vres 1280x720 -vfr 24 -v video=\"YOUR-WEBCAM\" -pixf yuv420p -live\n" + " DashCast -vf vfwcap -vres 1280x720 -vfr 24 -v 0 -live\n" + " DashCast -vf dshow -vres 1280x720 -vfr 24 -v video=\"screen-capture-recorder\" -live (please install http://screencapturer.sf.net/)\n" + " DashCast -vf dshow -vres 1280x720 -vfr 24 -v video=\"YOUR-WEBCAM\" -pixf yuv420p -live\n" #else - " DashCast -vf video4linux2 -vres 1280x720 -vfr 24 -v4l2f mjpeg -v /dev/video0 -af alsa -a plughw:1,0 -live\n" - " DashCast -vf x11grab -vres 800x600 -vfr 25 -v :0.0 -live\n" + " DashCast -vf video4linux2 -vres 1280x720 -vfr 24 -v4l2f mjpeg -v /dev/video0 -af alsa -a plughw:1,0 -live\n" + " DashCast -vf x11grab -vres 800x600 -vfr 25 -v :0.0 -live\n" #endif - "\n"; + "\n"; const char *command_error = "\33[31mUnknown option or missing mandatory argument.\33[0m\n"; @@ -871,8 +872,8 @@ int dc_parse_command(int argc, char **argv, CmdData *cmd_data) fprintf(stdout, " audio format: %s\n", cmd_data->audio_data_conf.format); } fprintf(stdout, "\33[0m"); -// fflush(stdout); - + fflush(stdout); + if (!cmd_data->conf) { cmd_data->conf = gf_cfg_force_new(NULL, "dashcast.conf"); dc_create_configuration(cmd_data); diff --git a/applications/dashcast/cmd_data.h b/applications/dashcast/cmd_data.h index e572c63..4c706d6 100644 --- a/applications/dashcast/cmd_data.h +++ b/applications/dashcast/cmd_data.h @@ -112,7 +112,7 @@ typedef struct { /* * Initilize the command data structure - * + * * @param cmd_data [out] structure to be initialize */ void dc_cmd_data_init(CmdData *cmd_data); diff --git a/applications/dashcast/controler.c b/applications/dashcast/controler.c index 189dc62..cc6487a 100644 --- a/applications/dashcast/controler.c +++ b/applications/dashcast/controler.c @@ -27,30 +27,20 @@ #if (!defined(__DARWIN__) && !defined(__APPLE__)) -#include +# include #endif #include -//FIXME: use GPAC utility functions + #if defined(__GNUC__) -#include -#include +# include +# include #elif defined(WIN32) -#include -#include -#define suseconds_t long - -s32 gettimeofday(struct timeval *tp, void *tz) -{ - struct _timeb timebuffer; - - _ftime( &timebuffer ); - tp->tv_sec = (long) (timebuffer.time); - tp->tv_usec = timebuffer.millitm * 1000; - return 0; -} +# include +# include +# define suseconds_t long #else -#error +# error #endif @@ -159,7 +149,7 @@ static void dc_write_mpd(CmdData *cmddata, const AudioDataConf *audio_data_conf, video_frag_dur = (int)(video_data_conf->framerate * (cmddata->frag_dur / 1000.0)); optimize_seg_frag_dur(&video_seg_dur, &video_frag_dur); } - + f = fopen(name, "w"); //TODO: if (!f) ... @@ -173,21 +163,21 @@ static void dc_write_mpd(CmdData *cmddata, const AudioDataConf *audio_data_conf, fprintf(f, "\n"); fprintf(f, "mode == ON_DEMAND) ? "mediaPresentationDuration" : "availabilityStartTime", - (cmddata->mode == ON_DEMAND) ? presentation_duration : availability_start_time, - cmddata->min_buffer_time, time_shift, - (cmddata->mode == ON_DEMAND) ? "static" : "dynamic"); + "%s=\"%s\" " + "minBufferTime=\"PT%fS\" %s type=\"%s\" " + "profiles=\"urn:mpeg:dash:profile:full:2011\"", + (cmddata->mode == ON_DEMAND) ? "mediaPresentationDuration" : "availabilityStartTime", + (cmddata->mode == ON_DEMAND) ? presentation_duration : availability_start_time, + cmddata->min_buffer_time, time_shift, + (cmddata->mode == ON_DEMAND) ? "static" : "dynamic"); if (cmddata->minimum_update_period > 0 ) { fprintf(f, " minimumUpdatePeriod=\"PT%dS\"", cmddata->minimum_update_period); } fprintf(f, ">\n"); fprintf(f, - " \n" - " %s\n" - " \n", cmddata->mpd_filename); + " \n" + " %s\n" + " \n", cmddata->mpd_filename); if (strcmp(cmddata->base_url, "") != 0) { fprintf(f, " %s\n", cmddata->base_url); @@ -199,16 +189,16 @@ static void dc_write_mpd(CmdData *cmddata, const AudioDataConf *audio_data_conf, fprintf(f, " \n"); fprintf(f, - " \n"); + " \n"); fprintf(f, - " samplerate, audio_seg_dur * audio_frame_size, segnum); + " samplerate, audio_seg_dur * audio_frame_size, segnum); if (ast_offset<0) { - fprintf(f, " availabilityTimeOffset=\"%g\"", -ast_offset/1000.0); + fprintf(f, " availabilityTimeOffset=\"%g\"", -ast_offset/1000.0); } fprintf(f, "/>\n"); @@ -217,9 +207,9 @@ static void dc_write_mpd(CmdData *cmddata, const AudioDataConf *audio_data_conf, for (i = 0; i < gf_list_count(cmddata->audio_lst); i++) { audio_data_conf = gf_list_get(cmddata->audio_lst, i); fprintf(f, - " \n" - " \n", audio_data_conf->filename, audio_data_conf->samplerate, audio_data_conf->bitrate); + " \n" + " \n", audio_data_conf->filename, audio_data_conf->samplerate, audio_data_conf->bitrate); } fprintf(f, " \n"); @@ -229,24 +219,24 @@ static void dc_write_mpd(CmdData *cmddata, const AudioDataConf *audio_data_conf, fprintf(f, " \n"); fprintf(f, - " framerate, video_seg_dur, segnum); + " framerate, video_seg_dur, segnum); if (ast_offset<0) { - fprintf(f, " availabilityTimeOffset=\"%g\"", -ast_offset/1000.0); + fprintf(f, " availabilityTimeOffset=\"%g\"", -ast_offset/1000.0); } fprintf(f, "/>\n"); for (i = 0; i < gf_list_count(cmddata->video_lst); i++) { video_data_conf = gf_list_get(cmddata->video_lst, i); fprintf(f, " \n" - " \n", video_data_conf->filename, - VIDEO_MUXER == GPAC_INIT_VIDEO_MUXER_AVC1 ? "avc1.42e01e" : "avc3", //FIXME: hardcoded. We would need acces to the ISOFile to call gf_media_get_rfc_6381_codec_name() - video_data_conf->width, video_data_conf->height, video_data_conf->framerate, - video_data_conf->bitrate); + "width=\"%d\" height=\"%d\" frameRate=\"%d\" sar=\"1:1\" startWithSAP=\"1\" bandwidth=\"%d\">\n" + " \n", video_data_conf->filename, + VIDEO_MUXER == GPAC_INIT_VIDEO_MUXER_AVC1 ? video_data_conf->codec6381 : "avc3", + video_data_conf->width, video_data_conf->height, video_data_conf->framerate, + video_data_conf->bitrate); } fprintf(f, " \n"); @@ -308,7 +298,7 @@ static u32 mpd_thread(void *params) if (cmddata->use_dynamic_ast) { main_seg_time = seg_time; } else { - //get the last notification of AST + //get the last notification of AST if (first) { if (seg_time.segnum) { first = GF_FALSE; @@ -333,7 +323,7 @@ static u32 mpd_thread(void *params) ast_time = *gmtime(&t); sprintf(availability_start_time, "%d-%02d-%02dT%02d:%02d:%02d.%d", 1900 + ast_time.tm_year, ast_time.tm_mon+1, ast_time.tm_mday, ast_time.tm_hour, ast_time.tm_min, ast_time.tm_sec, msecs); fprintf(stdout, "StartTime: %s - startNumber %d - last number %d\n", availability_start_time, main_seg_time.segnum, seg_time.segnum); - + if (cmddata->time_shift != -1) { int ts, h, m, s; ts = cmddata->time_shift; @@ -381,7 +371,8 @@ static u32 mpd_thread(void *params) u32 delete_seg_thread(void *params) { int ret; - ThreadParam *th_param = (ThreadParam*)params;CmdData *cmd_data = th_param->in_data; + ThreadParam *th_param = (ThreadParam*)params; + CmdData *cmd_data = th_param->in_data; MessageQueue *mq = th_param->mq; char buff[GF_MAX_PATH]; @@ -598,7 +589,7 @@ u32 video_decoder_thread(void *params) VideoInputData *video_input_data = thread_params->video_input_data; VideoInputFile **video_input_file = thread_params->video_input_file; - suseconds_t total_wait_time = 1000000 / in_data->video_data_conf.framerate; + suseconds_t total_wait_time = (int) (1000000.0 / (double) in_data->video_data_conf.framerate); suseconds_t pick_packet_delay, select_delay = 0, real_wait, other_delays = 2; Task t; @@ -614,7 +605,7 @@ u32 video_decoder_thread(void *params) //fprintf(stdout, "sourcenumber: %d\n", source_number); if (video_input_file[source_number]->mode == LIVE_MEDIA) { - gettimeofday(&time_start, NULL); + gf_gettimeofday(&time_start, NULL); } ret = dc_video_decoder_read(video_input_file[source_number], video_input_data, source_number, in_data->use_source_timing, (in_data->mode == LIVE_CAMERA) ? 1 : 0, (const int *) &in_data->exit_signal); @@ -637,16 +628,16 @@ u32 video_decoder_thread(void *params) } if (video_input_file[source_number]->mode == LIVE_MEDIA) { - gettimeofday(&time_end, NULL); + gf_gettimeofday(&time_end, NULL); pick_packet_delay = ((time_end.tv_sec - time_start.tv_sec) * 1000000) + time_end.tv_usec - time_start.tv_usec; time_wait.tv_sec = 0; real_wait = total_wait_time - pick_packet_delay - select_delay - other_delays; time_wait.tv_usec = real_wait; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("delay: %ld = %ld - %ld\n", time_wait.tv_usec, total_wait_time, pick_packet_delay)); - gettimeofday(&time_start, NULL); + gf_gettimeofday(&time_start, NULL); select(0, NULL, NULL, NULL, &time_wait); - gettimeofday(&time_end, NULL); + gf_gettimeofday(&time_end, NULL); select_delay = (((time_end.tv_sec - time_start.tv_sec) * 1000000) + time_end.tv_usec - time_start.tv_usec) - real_wait; } @@ -669,7 +660,7 @@ u32 audio_decoder_thread(void *params) CmdData *in_data = thread_params->in_data; AudioInputData *audio_input_data = thread_params->audio_input_data; AudioInputFile *audio_input_file = thread_params->audio_input_file; - + suseconds_t pick_packet_delay, select_delay = 0, real_wait, other_delays = 1; suseconds_t total_wait_time; if (in_data->audio_data_conf.samplerate < 1024) { @@ -678,7 +669,7 @@ u32 audio_decoder_thread(void *params) //FIXME: deadlock on the mpd thread. Reproduce with big_buck_bunny.mp4. return 1; } - total_wait_time = 1000000 / (in_data->audio_data_conf.samplerate / 1024); + total_wait_time = (int) (1000000.0 / (in_data->audio_data_conf.samplerate / (double) AUDIO_FRAME_SIZE)); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("wait time : %ld\n", total_wait_time)); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("sample-rate : %ld\n", in_data->audio_data_conf.samplerate)); @@ -687,7 +678,7 @@ u32 audio_decoder_thread(void *params) while (1) { if (audio_input_file->mode == LIVE_MEDIA) { - gettimeofday(&time_start, NULL); + gf_gettimeofday(&time_start, NULL); } ret = dc_audio_decoder_read(audio_input_file, audio_input_data); @@ -700,7 +691,7 @@ u32 audio_decoder_thread(void *params) break; } if (ret == -1) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("An error occurred while reading video frame.\n")); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("An error occurred while reading audio frame.\n")); break; } @@ -710,15 +701,15 @@ u32 audio_decoder_thread(void *params) } if (audio_input_file->mode == LIVE_MEDIA) { - gettimeofday(&time_end, NULL); + gf_gettimeofday(&time_end, NULL); pick_packet_delay = ((time_end.tv_sec - time_start.tv_sec) * 1000000) + time_end.tv_usec - time_start.tv_usec; time_wait.tv_sec = 0; real_wait = total_wait_time - pick_packet_delay - select_delay - other_delays; time_wait.tv_usec = real_wait; - gettimeofday(&time_start, NULL); + gf_gettimeofday(&time_start, NULL); select(0, NULL, NULL, NULL, &time_wait); - gettimeofday(&time_end, NULL); + gf_gettimeofday(&time_end, NULL); select_delay = (((time_end.tv_sec - time_start.tv_sec) * 1000000) + time_end.tv_usec - time_start.tv_usec) - real_wait; } @@ -755,7 +746,7 @@ u32 video_scaler_thread(void *params) u32 video_encoder_thread(void *params) { - int ret, shift, frame_nb, seg_frame_max, frag_frame_max, seg_nb = 0, loss_state = 0, quit = 0; + int ret, shift, frame_nb, seg_frame_max, frag_frame_max, seg_nb = 0, loss_state = 0, quit = 0, real_video_seg_dur; char name_to_delete[GF_MAX_PATH], name_to_send[GF_MAX_PATH]; u64 start_utc, seg_utc; segtime time_at_segment_start; @@ -784,6 +775,10 @@ u32 video_encoder_thread(void *params) frag_frame_max = (int)(video_data_conf->framerate * (float) (in_data->frag_dur / 1000.0)); optimize_seg_frag_dur(&seg_frame_max, &frag_frame_max); + real_video_seg_dur = (int) (seg_frame_max * 1000.0 / (float) video_data_conf->framerate); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[video_encoder] seg_frame_max=%d, frag_frame_max=%d, real_video_seg_dur=%d ms\n", seg_frame_max, frag_frame_max, real_video_seg_dur)); + + if (seg_frame_max <= 0) seg_frame_max = -1; @@ -817,7 +812,7 @@ u32 video_encoder_thread(void *params) //logging at the end of the segment production will induce one segment delay time_at_segment_start.segnum = seg_nb; time_at_segment_start.time = gf_net_get_utc(); - + if (dc_video_muxer_open(&out_file, in_data->out_dir, video_data_conf->filename, seg_nb) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video file.\n")); in_data->exit_signal = 1; @@ -838,7 +833,7 @@ u32 video_encoder_thread(void *params) } if (ret == -2) { - GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("Audio encoder has no more data to encode.\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("Video encoder has no more data to encode.\n")); quit = 1; break; } @@ -889,17 +884,18 @@ u32 video_encoder_thread(void *params) int seg_diff; seg_utc = gf_net_get_utc(); diff = (int) (seg_utc - start_utc); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[video_encoder] UTC diff %d - cumulated segment duration %d -> %d\n", diff, (seg_nb+1) * real_video_seg_dur, diff - (seg_nb+1) * real_video_seg_dur)); //if seg UTC is after next segment UTC (current ends at seg_nb+1, next at seg_nb+2), adjust numbers - if (diff > (seg_nb+2) * in_data->seg_dur) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Rep %s UTC diff %d bigger than segment duration %d - some frame where probably lost. Adjusting\n", out_file.rep_id, diff, seg_nb)); + if (diff > (seg_nb+2) * real_video_seg_dur) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[video_encoder] Rep %s UTC diff %d bigger than segment duration %d - some frame where probably lost. Adjusting\n", out_file.rep_id, diff, seg_nb)); - while (diff > (seg_nb+2) * in_data->seg_dur) { + while (diff > (seg_nb+2) * real_video_seg_dur) { seg_nb++; //do a rough estimate of losses to adjust timing... if (! in_data->use_source_timing) { - out_file.first_dts += out_file.codec_ctx->time_base.den; + out_file.first_dts += out_file.codec_ctx->time_base.den; } } //wait for RAP to cut next segment @@ -908,21 +904,21 @@ u32 video_encoder_thread(void *params) #define SYNC_SAFE 800 seg_diff = diff; - seg_diff -= (seg_nb+1) * in_data->seg_dur; + seg_diff -= (seg_nb+1) * real_video_seg_dur; if (seg_diff > SYNC_SAFE) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Rep %s UTC diff at segment close: %d is higher than cumulated segment duration %d (diff %d) - frame rate is probably not correct !!\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[video_encoder] Rep %s UTC diff at segment close: %d is higher than cumulated segment duration %d (diff %d) - frame rate is probably not correct!\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); } else if (seg_diff < -SYNC_SAFE) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Rep %s UTC diff at segment close: %d is lower than cumulated segment duration %d (diff %d) - frame rate is probably not correct or frames were lost !!\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[video_encoder] Rep %s UTC diff at segment close: %d is lower than cumulated segment duration %d (diff %d) - frame rate is probably not correct or frames were lost!\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("Rep %s UTC diff at segment close: %d - cumulated segment duration %d (diff %d)\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[video_encoder] Rep %s UTC diff at segment close: %d - cumulated segment duration %d (diff %d)\n", out_file.rep_id, diff, (seg_nb+1) * in_data->seg_dur, seg_diff)); } } //time_t t = time(NULL); dc_message_queue_put(mq, &time_at_segment_start, sizeof(time_at_segment_start)); } - + if ((in_data->time_shift != -1)) { shift = 1000 * in_data->time_shift / in_data->seg_dur; if (seg_nb - shift>=0) { @@ -943,7 +939,7 @@ u32 video_encoder_thread(void *params) if (thread_params->video_conf_idx == 0) { int dur = (seg_nb * seg_frame_max * 1000) / video_data_conf->framerate; int dur_tot = (out_file.codec_ctx->frame_number * 1000) - / video_data_conf->framerate; + / video_data_conf->framerate; if (dur > dur_tot) dur = dur_tot; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("Duration: %d \n", dur)); @@ -962,7 +958,7 @@ u32 video_encoder_thread(void *params) u32 audio_encoder_thread(void *params) { - int ret, exit_loop = 0, quit = 0, seg_nb = 0, frame_per_seg, frame_per_frag, frame_nb, shift; + int ret, exit_loop = 0, quit = 0, seg_nb = 0, frame_per_seg, frame_per_frag, frame_nb, shift, real_audio_seg_dur; //int seg_frame_max; //int frag_frame_max; //int audio_frame_size = AUDIO_FRAME_SIZE; @@ -1001,9 +997,12 @@ u32 audio_encoder_thread(void *params) return -1; } - frame_per_seg = (int)((audio_data_conf->samplerate / (double) audio_output_file.frame_size) * (in_data->seg_dur / 1000.0)); - frame_per_frag = (int)((audio_data_conf->samplerate / (double) audio_output_file.frame_size) * (in_data->frag_dur / 1000.0)); + frame_per_seg = (int)((audio_data_conf->samplerate / (double) audio_output_file.codec_ctx->frame_size) * (in_data->seg_dur / 1000.0)); + frame_per_frag = (int)((audio_data_conf->samplerate / (double) audio_output_file.codec_ctx->frame_size) * (in_data->frag_dur / 1000.0)); optimize_seg_frag_dur(&frame_per_seg, &frame_per_frag); + + real_audio_seg_dur = (int) (frame_per_seg * (double) audio_output_file.codec_ctx->frame_size * 1000.0 / (double) audio_data_conf->samplerate); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH,("[audio_encoder] frame_per_seg=%d, frame_per_frag=%d, real_audio_seg_dur=%d ms\n", frame_per_seg, frame_per_frag, real_audio_seg_dur) ); if (dc_audio_muxer_init(&audio_output_file, audio_data_conf, muxer_type, frame_per_seg, frame_per_frag, in_data->seg_marker) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot init output audio.\n")); @@ -1012,6 +1011,7 @@ u32 audio_encoder_thread(void *params) } start_utc = gf_net_get_utc(); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[audio_encoder] start_utc="LLU"\n", start_utc)); seg_utc = 0; while (1) { frame_nb = 0; @@ -1088,19 +1088,19 @@ u32 audio_encoder_thread(void *params) if (in_data->mode == LIVE_CAMERA || in_data->mode == LIVE_MEDIA) { if (thread_params->audio_conf_idx == 0) { segtime t; - + //check we don't loose sync int diff; seg_utc = gf_net_get_utc(); diff = (int) (seg_utc - start_utc); //if seg UTC is after next segment UTC (current ends at seg_nb+1, next at seg_nb+2), adjust numbers - if (diff > (seg_nb+2) * in_data->seg_dur) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("UTC diff %d bigger than segment duration %d - some frame where probably lost. Adjusting\n", diff, seg_nb)); - while (diff > (seg_nb+2) * in_data->seg_dur) { + if (diff > (seg_nb+2) * real_audio_seg_dur) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[audio_encoder] UTC diff %d bigger than segment duration %d - some frame where probably lost. Adjusting\n", diff, seg_nb)); + while (diff > (seg_nb+2) * real_audio_seg_dur) { seg_nb++; } } - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("UTC diff %d - cumulated segment duration %d\n", diff, (seg_nb+1) * in_data->seg_dur)); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[audio_encoder] UTC diff %d - cumulated segment duration %d -> %d\n", diff, (seg_nb+1) * real_audio_seg_dur, diff - (seg_nb+1) * real_audio_seg_dur)); t.segnum = seg_nb; t.time = gf_net_get_utc(); //time_t t = time(NULL); @@ -1124,8 +1124,8 @@ u32 audio_encoder_thread(void *params) // Send the duration of the video if (in_data->mode == ON_DEMAND) { if (thread_params->audio_conf_idx == 0) { - int dur = (seg_nb * audio_output_file.frame_size * frame_per_seg * 1000) / audio_data_conf->samplerate; - int dur_tot = (audio_output_file.codec_ctx->frame_number * audio_output_file.frame_size * 1000) / audio_data_conf->samplerate; + int dur = (seg_nb * audio_output_file.codec_ctx->frame_size * frame_per_seg * 1000) / audio_data_conf->samplerate; + int dur_tot = (audio_output_file.codec_ctx->frame_number * audio_output_file.codec_ctx->frame_size * 1000) / audio_data_conf->samplerate; if (dur > dur_tot) dur = dur_tot; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("Duration: %d \n", dur)); @@ -1147,7 +1147,7 @@ int dc_run_controler(CmdData *in_data) int ret = 0; u32 video_cb_size = VIDEO_CB_DEFAULT_SIZE; u32 i, j; - + ThreadParam keyboard_th_params; ThreadParam mpd_th_params; ThreadParam delete_seg_th_params; @@ -1282,7 +1282,7 @@ int dc_run_controler(CmdData *in_data) /* Initialize keyboard controller thread */ keyboard_th_params.thread = gf_th_new("keyboard_thread"); - + /* Create keyboard controller thread */ keyboard_th_params.in_data = in_data; if (gf_th_run(keyboard_th_params.thread, keyboard_thread, (void *)&keyboard_th_params) != GF_OK) { @@ -1306,12 +1306,12 @@ int dc_run_controler(CmdData *in_data) tmvdata->time_base = in_data->video_data_conf.time_base; } } - + /******** MPD Thread ********/ /* Initialize MPD generator thread */ mpd_th_params.thread = gf_th_new("mpd_thread"); - + /* Create MPD generator thread */ mpd_th_params.in_data = in_data; mpd_th_params.mq = &mq; @@ -1522,7 +1522,7 @@ int dc_run_controler(CmdData *in_data) dasher_thread((void*) &dasher_th_params); } #endif - + exit: if (strcmp(in_data->audio_data_conf.filename, "") != 0) { /* Destroy audio input data */ @@ -1557,7 +1557,7 @@ exit: dc_message_queue_free(&mq); dc_message_queue_free(&delete_seg_mq); dc_message_queue_free(&send_frag_mq); - + dc_unregister_libav(); return ret; diff --git a/applications/dashcast/controler.h b/applications/dashcast/controler.h index 5a43cd1..ab12f3d 100644 --- a/applications/dashcast/controler.h +++ b/applications/dashcast/controler.h @@ -87,12 +87,12 @@ typedef struct { MessageQueue *send_seg_mq; } AudioThreadParam; -/* +/* * Run controler runs all decoder, scalers, and encoders * of audio and video - * - * @param cmd_data [in] command data - * + * + * @param cmd_data [in] command data + * * @return 0 on success, -1 on failure */ int dc_run_controler(CmdData *); diff --git a/applications/dashcast/libav_compat.h b/applications/dashcast/libav_compat.h index ef691c9..9d8cb57 100644 --- a/applications/dashcast/libav_compat.h +++ b/applications/dashcast/libav_compat.h @@ -30,12 +30,13 @@ #define URL_WRONLY AVIO_FLAG_WRITE #endif -#ifndef CODEC_ID_RAWVIDEO - -#if (LIBAVCODEC_VERSION_MAJOR <= 53) && (LIBAVCODEC_VERSION_MINOR < 30) +#if (LIBAVCODEC_VERSION_MAJOR>54) #define CODEC_ID_RAWVIDEO AV_CODEC_ID_RAWVIDEO #define CODEC_ID_H264 AV_CODEC_ID_H264 #endif + +#if (LIBAVCODEC_VERSION_MAJOR<54) +#define LIBAV_ENCODE_OLD #endif #ifndef AV_CH_LAYOUT_STEREO @@ -44,8 +45,9 @@ #define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) #endif -#if (LIBAVCODEC_VERSION_MAJOR<=55) && (LIBAVCODEC_VERSION_MINOR<=40) +#if (LIBAVCODEC_VERSION_MAJOR<55) || ((LIBAVCODEC_VERSION_MAJOR==55) && (LIBAVCODEC_VERSION_MINOR<=40)) #define FF_ALLOC_FRAME avcodec_alloc_frame +#define LIBAV_FRAME_OLD #else #define FF_ALLOC_FRAME av_frame_alloc #endif diff --git a/applications/dashcast/register.c b/applications/dashcast/register.c index c8ad3d9..b62bb3f 100644 --- a/applications/dashcast/register.c +++ b/applications/dashcast/register.c @@ -32,14 +32,14 @@ int lock_call_back(void ** mutex, enum AVLockOp op) { switch (op) { case AV_LOCK_CREATE: - { - static int i = 0; - char mxName[64]; - snprintf(mxName, 64, "AVLIB callback mutex %d", i++); - *mutex = gf_mx_new(mxName); - gf_list_add(av_mutex, *mutex); - break; - } + { + static int i = 0; + char mxName[64]; + snprintf(mxName, 64, "AVLIB callback mutex %d", i++); + *mutex = gf_mx_new(mxName); + gf_list_add(av_mutex, *mutex); + break; + } case AV_LOCK_OBTAIN: gf_mx_p(*mutex); break; @@ -68,7 +68,7 @@ void dc_register_libav() av_lockmgr_register(&lock_call_back); } -void dc_unregister_libav() +void dc_unregister_libav() { av_lockmgr_register(NULL); diff --git a/applications/dashcast/register.h b/applications/dashcast/register.h index a885a65..cbf3e32 100644 --- a/applications/dashcast/register.h +++ b/applications/dashcast/register.h @@ -35,14 +35,14 @@ #include -/* +/* * Register all codecs and define * the lock manager on top of avlib */ void dc_register_libav(); void dc_unregister_libav(); -/* +/* * performs libav* cleanup */ void dc_unregister_libav(); diff --git a/applications/dashcast/video_data.h b/applications/dashcast/video_data.h index a4a28de..26f3f6f 100644 --- a/applications/dashcast/video_data.h +++ b/applications/dashcast/video_data.h @@ -67,6 +67,8 @@ typedef struct { int framerate; /* video codec */ char codec[GF_MAX_PATH]; + /* RFC6381 codec name, only valid when VIDEO_MUXER == GPAC_INIT_VIDEO_MUXER_AVC1 */ + char codec6381[GF_MAX_PATH]; /* custom parameter to be passed directly to the encoder - free it once you're done */ char *custom; diff --git a/applications/dashcast/video_decoder.c b/applications/dashcast/video_decoder.c index d2f878b..d0c6298 100644 --- a/applications/dashcast/video_decoder.c +++ b/applications/dashcast/video_decoder.c @@ -80,7 +80,7 @@ int dc_video_decoder_open(VideoInputFile *video_input_file, VideoDataConf *video } } #endif - + if (video_data_conf->format && strcmp(video_data_conf->format, "") != 0) { in_fmt = av_find_input_format(video_data_conf->format); if (in_fmt == NULL) { @@ -154,8 +154,8 @@ int dc_video_decoder_open(VideoInputFile *video_input_file, VideoDataConf *video video_input_file->width = codec_ctx->width; video_input_file->height = codec_ctx->height; video_input_file->pix_fmt = codec_ctx->pix_fmt; - if (video_data_conf->framerate >= 0) { - video_data_conf->framerate = codec_ctx->time_base.den / codec_ctx->time_base.num; + if (video_data_conf->framerate >= 0 && codec_ctx->time_base.num) { + video_data_conf->framerate = codec_ctx->time_base.den / codec_ctx->time_base.num; } if (video_data_conf->framerate <= 1 || video_data_conf->framerate > 1000) { const int num = video_input_file->av_fmt_ctx->streams[video_input_file->vstream_idx]->avg_frame_rate.num; @@ -203,16 +203,16 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide /* Read frames */ while (1) { #ifdef DASHCAST_DEBUG_TIME_ - gettimeofday(&start, NULL); + gf_gettimeofday(&start, NULL); #endif memset(&packet, 0, sizeof(AVPacket)); ret = av_read_frame(video_input_file->av_fmt_ctx, &packet); #ifdef DASHCAST_DEBUG_TIME_ - gettimeofday(&end, NULL); + gf_gettimeofday(&end, NULL); elapsed_time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec); fprintf(stdout, "fps: %f\n", 1000000.0/elapsed_time); #endif - + /* If we demux for the audio thread, send the packet to the audio */ if (video_input_file->av_fmt_ctx_ref_cnt && ((packet.stream_index != video_input_file->vstream_idx) || (ret == AVERROR_EOF))) { AVPacket *packet_copy = NULL; @@ -225,7 +225,7 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide gf_mx_p(video_input_file->av_pkt_list_mutex); gf_list_add(video_input_file->av_pkt_list, packet_copy); gf_mx_v(video_input_file->av_pkt_list_mutex); - + if (ret != AVERROR_EOF) { continue; } @@ -244,7 +244,12 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide video_data_node->source_number = source_number; /* Flush decoder */ memset(&packet, 0, sizeof(AVPacket)); +#ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(video_data_node->vframe); +#else + av_frame_unref(video_data_node->vframe); +#endif + avcodec_decode_video2(codec_ctx, video_data_node->vframe, &got_frame, &packet); if (got_frame) { dc_producer_advance(&video_input_data->producer, &video_input_data->circular_buf); @@ -278,7 +283,11 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide video_data_node->source_number = source_number; /* Set video frame to default */ +#ifndef FF_API_AVFRAME_LAVC avcodec_get_frame_defaults(video_data_node->vframe); +#else + av_frame_unref(video_data_node->vframe); +#endif /* Decode video frame */ if (avcodec_decode_video2(codec_ctx, video_data_node->vframe, &got_frame, &packet) < 0) { @@ -300,10 +309,10 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide video_input_file->computed_pts = 0; video_input_data->frame_duration = codec_ctx->time_base.num; video_input_file->sync_tolerance = 9*video_input_data->frame_duration/5; - //TODO - check with audio if sync is OK - } - //perform FPS re-linearisation - pts = packet.pts - video_input_file->first_pts; + //TODO - check with audio if sync is OK + } + //perform FPS re-linearisation + pts = packet.pts - video_input_file->first_pts; if (pts - video_input_file->prev_pts > video_input_file->sync_tolerance) { u32 nb_lost=0; while (pts > video_input_file->computed_pts) { @@ -324,7 +333,7 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide } if (video_data_node->vframe->pts==AV_NOPTS_VALUE) { - if (!use_source_timing ) { + if (!use_source_timing) { video_data_node->vframe->pts = video_input_file->frame_decoded; } else { video_data_node->vframe->pts = video_data_node->vframe->pkt_pts; @@ -342,9 +351,6 @@ int dc_video_decoder_read(VideoInputFile *video_input_file, VideoInputData *vide video_data_node->nb_raw_frames_ref = video_input_file->nb_consumers; video_data_node->raw_packet = packet; -#ifndef GPAC_USE_LIBAV - video_data_node->vframe = av_frame_clone(video_data_node->vframe); -#endif dc_producer_advance(&video_input_data->producer, &video_input_data->circular_buf); while (video_data_node->nb_raw_frames_ref && ! *exit_signal_addr) { @@ -372,7 +378,7 @@ void dc_video_decoder_close(VideoInputFile *video_input_file) /* Close the video format context */ if (!video_input_file->av_fmt_ctx_ref_cnt) avformat_close_input(&video_input_file->av_fmt_ctx); - + video_input_file->av_pkt_list = NULL; video_input_file->av_pkt_list_mutex = NULL; } diff --git a/applications/dashcast/video_encoder.c b/applications/dashcast/video_encoder.c index e174ed6..784e4a4 100644 --- a/applications/dashcast/video_encoder.c +++ b/applications/dashcast/video_encoder.c @@ -33,12 +33,6 @@ #define _TOSTR(_val) #_val #define TOSTR(_val) _TOSTR(_val) -#pragma comment(lib, "avcodec-"TOSTR(LIBAVCODEC_VERSION_MAJOR) ) -#pragma comment(lib, "avdevice-"TOSTR(LIBAVDEVICE_VERSION_MAJOR) ) -#pragma comment(lib, "avformat-"TOSTR(LIBAVFORMAT_VERSION_MAJOR) ) -#pragma comment(lib, "avutil-"TOSTR(LIBAVUTIL_VERSION_MAJOR) ) -#pragma comment(lib, "swscale-"TOSTR(LIBSWSCALE_VERSION_MAJOR) ) - #endif @@ -66,35 +60,30 @@ int dc_video_encoder_open(VideoOutputFile *video_output_file, VideoDataConf *vid { video_output_file->vbuf_size = 9 * video_data_conf->width * video_data_conf->height + 10000; video_output_file->vbuf = (uint8_t *) av_malloc(video_output_file->vbuf_size); + video_output_file->video_data_conf = video_data_conf; -// video_output_file->codec = avcodec_find_encoder_by_name("libx264"/*video_data_conf->codec*/); - video_output_file->codec = avcodec_find_encoder(CODEC_ID_H264); + video_output_file->codec = avcodec_find_encoder_by_name(video_data_conf->codec); if (video_output_file->codec == NULL) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Output video codec %d not found\n", CODEC_ID_H264)); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Output video codec %s not found\n", video_data_conf->codec)); return -1; } video_output_file->codec_ctx = avcodec_alloc_context3(video_output_file->codec); - //Create new video stream -// video_stream = avformat_new_stream(video_output_file->av_fmt_ctx, video_codec); -// if (!video_stream) { -// GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create output video stream\n")); -// return -1; -// } - video_output_file->codec_ctx->codec_id = video_output_file->codec->id; video_output_file->codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; video_output_file->codec_ctx->bit_rate = video_data_conf->bitrate; video_output_file->codec_ctx->width = video_data_conf->width; video_output_file->codec_ctx->height = video_data_conf->height; + video_output_file->codec_ctx->sample_aspect_ratio.num = video_data_conf->width; + video_output_file->codec_ctx->sample_aspect_ratio.den = video_data_conf->height; video_output_file->codec_ctx->time_base.num = 1; video_output_file->codec_ctx->time_base.den = video_output_file->gop_size ? video_output_file->gop_size : video_data_conf->framerate; - + video_output_file->use_source_timing = use_source_timing; if (use_source_timing) { - //for avcodec to do rate allcoation, we need to have ctx->timebase == 1/framerate + //for avcodec to do rate allocation, we need to have ctx->timebase == 1/framerate video_output_file->codec_ctx->time_base.den = video_data_conf->time_base.den; video_output_file->codec_ctx->time_base.num = video_data_conf->time_base.num * video_data_conf->time_base.den / video_data_conf->framerate; } @@ -153,40 +142,26 @@ int dc_video_encoder_open(VideoOutputFile *video_output_file, VideoDataConf *vid av_opt_set_int(video_output_file->codec_ctx->priv_data, "key-int", video_output_file->gdr, 0); } -// if (video_output_file->av_fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) //the global header gives access to the extradata (SPS/PPS) video_output_file->codec_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; -// if (video_output_file->av_fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) -// video_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; - video_output_file->vstream_idx = 0;//video_stream->index; - + /* open the video codec - options are passed thru video_output_file->codec_ctx->priv_data */ if (avcodec_open2(video_output_file->codec_ctx, video_output_file->codec, NULL) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video codec\n")); return -1; } -// /* open the video codec */ -// if (avcodec_open2(video_stream->codec, video_codec, NULL) < 0) { -// GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output video codec\n")); -// return -1; -// } - video_output_file->rep_id = video_data_conf->filename; return 0; } int dc_video_encoder_encode(VideoOutputFile *video_output_file, VideoScaledData *video_scaled_data) { - //AVPacket pkt; VideoDataNode *video_data_node; int ret; - //int out_size; -// AVStream *video_stream = video_output_file->av_fmt_ctx->streams[video_output_file->vstream_idx]; -// AVCodecContext *video_codec_ctx = video_stream->codec; AVCodecContext *video_codec_ctx = video_output_file->codec_ctx; //FIXME: deadlock when pressing 'q' with BigBuckBunny_640x360.m4v @@ -206,8 +181,8 @@ int dc_video_encoder_encode(VideoOutputFile *video_output_file, VideoScaledData */ if (!video_output_file->use_source_timing) { video_data_node->vframe->pts = video_codec_ctx->frame_number; - } - + } + /* Encoding video */ { int got_packet = 0; @@ -216,14 +191,20 @@ int dc_video_encoder_encode(VideoOutputFile *video_output_file, VideoScaledData pkt.data = video_output_file->vbuf; pkt.size = video_output_file->vbuf_size; pkt.pts = pkt.dts = video_data_node->vframe->pkt_dts = video_data_node->vframe->pkt_pts = video_data_node->vframe->pts; -#ifdef GPAC_USE_LIBAV +#ifdef LIBAV_ENCODE_OLD video_output_file->encoded_frame_size = avcodec_encode_video(video_codec_ctx, video_output_file->vbuf, video_output_file->vbuf_size, video_data_node->vframe); got_packet = video_output_file->encoded_frame_size>=0 ? 1 : 0; #else video_output_file->encoded_frame_size = avcodec_encode_video2(video_codec_ctx, &pkt, video_data_node->vframe, &got_packet); +#endif + //this is not true with libav ! +#ifndef GPAC_USE_LIBAV if (video_output_file->encoded_frame_size >= 0) video_output_file->encoded_frame_size = pkt.size; +#else + if (got_packet) + video_output_file->encoded_frame_size = pkt.size; #endif if (video_output_file->encoded_frame_size >= 0) { if (got_packet) { @@ -248,7 +229,6 @@ int dc_video_encoder_encode(VideoOutputFile *video_output_file, VideoScaledData /* if zero size, it means the image was buffered */ // if (out_size > 0) { -// // av_init_packet(&pkt); // pkt.data = NULL; // pkt.size = 0; diff --git a/applications/dashcast/video_muxer.c b/applications/dashcast/video_muxer.c index 5a8de38..19facd7 100644 --- a/applications/dashcast/video_muxer.c +++ b/applications/dashcast/video_muxer.c @@ -42,7 +42,7 @@ static GF_Err avc_import_ffextradata(const u8 *extradata, const u64 extradata_si u8 nal_size; AVCState avc; GF_BitStream *bs; - if (!extradata || !extradata_size) + if (!extradata || (extradata_size < sizeof(u32))) return GF_BAD_PARAM; bs = gf_bs_new(extradata, extradata_size, GF_BITSTREAM_READ); if (!bs) @@ -114,7 +114,7 @@ static GF_Err avc_import_ffextradata(const u8 *extradata, const u64 extradata_si gf_free(buffer); return GF_BAD_PARAM; } - + idx = gf_media_avc_read_pps(buffer, nal_size, &avc); if (idx < 0) { gf_bs_del(bs); @@ -136,37 +136,273 @@ static GF_Err avc_import_ffextradata(const u8 *extradata, const u64 extradata_si #endif } -int dc_gpac_video_moov_create(VideoOutputFile *video_output_file, char *filename) +/** + * A function which takes FFmpeg H265 extradata (SPS/PPS) and bring them ready to be pushed to the MP4 muxer. + * @param extradata + * @param extradata_size + * @param dstcfg + * @returns GF_OK is the extradata was parsed and is valid, other values otherwise. + */ +static GF_Err hevc_import_ffextradata(const u8 *extradata, const u64 extradata_size, GF_HEVCConfig *dst_cfg) { - GF_Err ret; - //AVStream *video_stream = video_output_file->av_fmt_ctx->streams[video_output_file->vstream_idx]; - //AVCodecContext *video_codec_ctx = video_stream->codec; +#ifdef GPAC_DISABLE_AV_PARSERS + return GF_OK; +#else + HEVCState hevc; + GF_HEVCParamArray *vpss = NULL, *spss = NULL, *ppss = NULL; + GF_BitStream *bs; + char *buffer = NULL; + u32 buffer_size = 0; + if (!extradata || (extradata_size < sizeof(u32))) + return GF_BAD_PARAM; + bs = gf_bs_new(extradata, extradata_size, GF_BITSTREAM_READ); + if (!bs) + return GF_BAD_PARAM; + + memset(&hevc, 0, sizeof(HEVCState)); + hevc.sps_active_idx = -1; - AVCodecContext *video_codec_ctx = video_output_file->codec_ctx; - GF_AVCConfig *avccfg; - u32 di, track; + while (gf_bs_available(bs)) { + s32 idx; + GF_AVCConfigSlot *slc; + u8 nal_unit_type, temporal_id, layer_id; + u64 nal_start; + u32 nal_size; + + if (gf_bs_read_u32(bs) != 0x00000001) { + gf_bs_del(bs); + return GF_BAD_PARAM; + } + nal_start = gf_bs_get_position(bs); + nal_size = gf_media_nalu_next_start_code_bs(bs); + if (nal_start + nal_size > extradata_size) { + gf_bs_del(bs); + return GF_BAD_PARAM; + } - // T0D0: For the moment it is fixed - //u32 sample_dur = video_output_file->codec_ctx->time_base.den; + if (nal_size > buffer_size) { + buffer = (char*)gf_realloc(buffer, nal_size); + buffer_size = nal_size; + } + gf_bs_read_data(bs, buffer, nal_size); + gf_bs_seek(bs, nal_start); - avccfg = gf_odf_avc_cfg_new(); - if (!avccfg) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create AVCConfig\n")); - return -1; + gf_media_hevc_parse_nalu(bs, &hevc, &nal_unit_type, &temporal_id, &layer_id); + if (layer_id) { + gf_bs_del(bs); + gf_free(buffer); + return GF_BAD_PARAM; + } + + switch (nal_unit_type) { + case GF_HEVC_NALU_VID_PARAM: + idx = gf_media_hevc_read_vps(buffer, nal_size , &hevc); + if (idx < 0) { + gf_bs_del(bs); + gf_free(buffer); + return GF_BAD_PARAM; + } + + assert(hevc.vps[idx].state == 1); //we don't expect multiple VPS + if (hevc.vps[idx].state == 1) { + hevc.vps[idx].state = 2; + hevc.vps[idx].crc = gf_crc_32(buffer, nal_size); + + dst_cfg->avgFrameRate = hevc.vps[idx].rates[0].avg_pic_rate; + dst_cfg->constantFrameRate = hevc.vps[idx].rates[0].constand_pic_rate_idc; + dst_cfg->numTemporalLayers = hevc.vps[idx].max_sub_layers; + dst_cfg->temporalIdNested = hevc.vps[idx].temporal_id_nesting; + + if (!vpss) { + GF_SAFEALLOC(vpss, GF_HEVCParamArray); + vpss->nalus = gf_list_new(); + gf_list_add(dst_cfg->param_array, vpss); + vpss->array_completeness = 1; + vpss->type = GF_HEVC_NALU_VID_PARAM; + } + + slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); + slc->size = nal_size; + slc->id = idx; + slc->data = (char*)gf_malloc(sizeof(char)*slc->size); + memcpy(slc->data, buffer, sizeof(char)*slc->size); + + gf_list_add(vpss->nalus, slc); + } + break; + case GF_HEVC_NALU_SEQ_PARAM: + idx = gf_media_hevc_read_sps(buffer, nal_size, &hevc); + if (idx < 0) { + gf_bs_del(bs); + gf_free(buffer); + return GF_BAD_PARAM; + } + + assert(!(hevc.sps[idx].state & AVC_SPS_DECLARED)); //we don't expect multiple SPS + if ((hevc.sps[idx].state & AVC_SPS_PARSED) && !(hevc.sps[idx].state & AVC_SPS_DECLARED)) { + hevc.sps[idx].state |= AVC_SPS_DECLARED; + hevc.sps[idx].crc = gf_crc_32(buffer, nal_size); + } + + dst_cfg->configurationVersion = 1; + dst_cfg->profile_space = hevc.sps[idx].ptl.profile_space; + dst_cfg->tier_flag = hevc.sps[idx].ptl.tier_flag; + dst_cfg->profile_idc = hevc.sps[idx].ptl.profile_idc; + dst_cfg->general_profile_compatibility_flags = hevc.sps[idx].ptl.profile_compatibility_flag; + dst_cfg->progressive_source_flag = hevc.sps[idx].ptl.general_progressive_source_flag; + dst_cfg->interlaced_source_flag = hevc.sps[idx].ptl.general_interlaced_source_flag; + dst_cfg->non_packed_constraint_flag = hevc.sps[idx].ptl.general_non_packed_constraint_flag; + dst_cfg->frame_only_constraint_flag = hevc.sps[idx].ptl.general_frame_only_constraint_flag; + + dst_cfg->constraint_indicator_flags = hevc.sps[idx].ptl.general_reserved_44bits; + dst_cfg->level_idc = hevc.sps[idx].ptl.level_idc; + + dst_cfg->chromaFormat = hevc.sps[idx].chroma_format_idc; + dst_cfg->luma_bit_depth = hevc.sps[idx].bit_depth_luma; + dst_cfg->chroma_bit_depth = hevc.sps[idx].bit_depth_chroma; + + if (!spss) { + GF_SAFEALLOC(spss, GF_HEVCParamArray); + spss->nalus = gf_list_new(); + gf_list_add(dst_cfg->param_array, spss); + spss->array_completeness = 1; + spss->type = GF_HEVC_NALU_SEQ_PARAM; + } + + slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); + slc->size = nal_size; + slc->id = idx; + slc->data = (char*)gf_malloc(sizeof(char)*slc->size); + memcpy(slc->data, buffer, sizeof(char)*slc->size); + gf_list_add(spss->nalus, slc); + break; + case GF_HEVC_NALU_PIC_PARAM: + idx = gf_media_hevc_read_pps(buffer, nal_size, &hevc); + if (idx < 0) { + gf_bs_del(bs); + gf_free(buffer); + return GF_BAD_PARAM; + } + + assert(hevc.pps[idx].state == 1); //we don't expect multiple PPS + if (hevc.pps[idx].state == 1) { + hevc.pps[idx].state = 2; + hevc.pps[idx].crc = gf_crc_32(buffer, nal_size); + + if (!ppss) { + GF_SAFEALLOC(ppss, GF_HEVCParamArray); + ppss->nalus = gf_list_new(); + gf_list_add(dst_cfg->param_array, ppss); + ppss->array_completeness = 1; + ppss->type = GF_HEVC_NALU_PIC_PARAM; + } + + slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); + slc->size = nal_size; + slc->id = idx; + slc->data = (char*)gf_malloc(sizeof(char)*slc->size); + memcpy(slc->data, buffer, sizeof(char)*slc->size); + + gf_list_add(ppss->nalus, slc); + } + break; + default: + break; + } + + if (gf_bs_seek(bs, nal_start+nal_size)) { + assert(nal_start+nal_size <= gf_bs_get_size(bs)); + break; + } } - //int64_t profile = 0; - //av_opt_get_int(video_output_file->codec_ctx->priv_data, "level", AV_OPT_SEARCH_CHILDREN, &profile); + gf_bs_del(bs); + gf_free(buffer); - { - GF_Err e = avc_import_ffextradata(video_codec_ctx->extradata, video_codec_ctx->extradata_size, avccfg); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot parse H264 SPS/PPS\n")); + return GF_OK; +#endif +} + +static GF_Err dc_gpac_video_write_config(VideoOutputFile *video_output_file, u32 *di, u32 track) { + GF_Err ret; + if (video_output_file->codec_ctx->codec_id == CODEC_ID_H264) { + GF_AVCConfig *avccfg; + avccfg = gf_odf_avc_cfg_new(); + if (!avccfg) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create AVCConfig\n")); + return GF_OUT_OF_MEM; + } + + ret = avc_import_ffextradata(video_output_file->codec_ctx->extradata, video_output_file->codec_ctx->extradata_size, avccfg); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot parse AVC/H264 SPS/PPS\n")); gf_odf_avc_cfg_del(avccfg); - return -1; + return ret; + } + + ret = gf_isom_avc_config_new(video_output_file->isof, track, avccfg, NULL, NULL, di); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_avc_config_new\n", gf_error_to_string(ret))); + return ret; + } + + gf_odf_avc_cfg_del(avccfg); + + //inband SPS/PPS + if (video_output_file->muxer_type == GPAC_INIT_VIDEO_MUXER_AVC3) { + ret = gf_isom_avc_set_inband_config(video_output_file->isof, track, 1); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_avc_set_inband_config\n", gf_error_to_string(ret))); + return ret; + } + } + } else if (!strcmp(video_output_file->codec_ctx->codec->name, "libx265")) { //FIXME CODEC_ID_HEVC would break on old releases + GF_HEVCConfig *hevccfg = gf_odf_hevc_cfg_new(); + if (!hevccfg) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create HEVCConfig\n")); + return GF_OUT_OF_MEM; + } + + ret = hevc_import_ffextradata(video_output_file->codec_ctx->extradata, video_output_file->codec_ctx->extradata_size, hevccfg); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot parse HEVC/H265 SPS/PPS\n")); + gf_odf_hevc_cfg_del(hevccfg); + return ret; + } + + ret = gf_isom_hevc_config_new(video_output_file->isof, track, hevccfg, NULL, NULL, di); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_hevc_config_new\n", gf_error_to_string(ret))); + return ret; + } + + gf_odf_hevc_cfg_del(hevccfg); + + //inband SPS/PPS + if (video_output_file->muxer_type == GPAC_INIT_VIDEO_MUXER_AVC3) { + ret = gf_isom_hevc_set_inband_config(video_output_file->isof, track, 1); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_hevc_set_inband_config\n", gf_error_to_string(ret))); + return ret; + } } } + return GF_OK; +} + +int dc_gpac_video_moov_create(VideoOutputFile *video_output_file, char *filename) +{ + GF_Err ret; + AVCodecContext *video_codec_ctx = video_output_file->codec_ctx; + u32 di, track; + + //TODO: For the moment it is fixed + //u32 sample_dur = video_output_file->codec_ctx->time_base.den; + + //int64_t profile = 0; + //av_opt_get_int(video_output_file->codec_ctx->priv_data, "level", AV_OPT_SEARCH_CHILDREN, &profile); + video_output_file->isof = gf_isom_open(filename, GF_ISOM_OPEN_WRITE, NULL); if (!video_output_file->isof) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open iso file %s\n", filename)); @@ -177,7 +413,7 @@ int dc_gpac_video_moov_create(VideoOutputFile *video_output_file, char *filename video_output_file->trackID = gf_isom_get_track_id(video_output_file->isof, track); video_output_file->timescale = video_codec_ctx->time_base.den; - if (!video_output_file->frame_dur) + if (!video_output_file->frame_dur) video_output_file->frame_dur = video_codec_ctx->time_base.num; if (!track) { @@ -191,30 +427,18 @@ int dc_gpac_video_moov_create(VideoOutputFile *video_output_file, char *filename return -1; } - ret = gf_isom_avc_config_new(video_output_file->isof, track, avccfg, NULL, NULL, &di); + ret = dc_gpac_video_write_config(video_output_file, &di, track); if (ret != GF_OK) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_avc_config_new\n", gf_error_to_string(ret))); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: dc_gpac_video_write_config\n", gf_error_to_string(ret))); return -1; } - gf_odf_avc_cfg_del(avccfg); - //fprintf(stdout, "time scale: %d \n", video_codec_ctx->time_base.den); - gf_isom_set_visual_info(video_output_file->isof, track, di, video_codec_ctx->width, video_codec_ctx->height); gf_isom_set_sync_table(video_output_file->isof, track); - //inband SPS/PPS - if (video_output_file->muxer_type == GPAC_INIT_VIDEO_MUXER_AVC3) { - ret = gf_isom_avc_set_inband_config(video_output_file->isof, track, 1); - if (ret != GF_OK) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_avc_set_inband_config\n", gf_error_to_string(ret))); - return -1; - } - } - ret = gf_isom_setup_track_fragment(video_output_file->isof, track, 1, video_output_file->use_source_timing ? (u32) video_output_file->frame_dur : 1, 0, 0, 0, 0); if (ret != GF_OK) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_setutrack_fragment\n", gf_error_to_string(ret))); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_setup_track_fragment\n", gf_error_to_string(ret))); return -1; } @@ -226,6 +450,12 @@ int dc_gpac_video_moov_create(VideoOutputFile *video_output_file, char *filename return -1; } + ret = gf_media_get_rfc_6381_codec_name(video_output_file->isof, track, video_output_file->video_data_conf->codec6381); + if (ret != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_finalize_for_fragment\n", gf_error_to_string(ret))); + return -1; + } + return 0; } @@ -254,8 +484,6 @@ int dc_gpac_video_isom_open_seg(VideoOutputFile *video_output_file, char *filena int dc_gpac_video_isom_write(VideoOutputFile *video_output_file) { GF_Err ret; - //AVStream *video_stream = video_output_file->av_fmt_ctx->streams[video_output_file->vstream_idx]; - //AVCodecContext *video_codec_ctx = video_stream->codec; AVCodecContext *video_codec_ctx = video_output_file->codec_ctx; u32 sc_size = 0; @@ -398,7 +626,7 @@ int dc_ffmpeg_video_muxer_open(VideoOutputFile *video_output_file, char *filenam } video_stream = avformat_new_stream(video_output_file->av_fmt_ctx, - video_output_file->codec); + video_output_file->codec); if (!video_stream) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot create output video stream\n")); return -1; @@ -413,7 +641,7 @@ int dc_ffmpeg_video_muxer_open(VideoOutputFile *video_output_file, char *filenam video_stream->codec->height = video_codec_ctx->height; //video_output_file->video_data_conf->height; video_stream->codec->time_base = video_codec_ctx->time_base; - + video_stream->codec->pix_fmt = PIX_FMT_YUV420P; video_stream->codec->gop_size = video_codec_ctx->time_base.den; //video_output_file->video_data_conf->framerate; @@ -586,7 +814,9 @@ int dc_video_muxer_write(VideoOutputFile *video_output_file, int frame_nb, Bool if (insert_utc) { gf_net_get_ntp(&sec, &frac); - ntpts = sec; ntpts <<= 32; ntpts |= frac; + ntpts = sec; + ntpts <<= 32; + ntpts |= frac; gf_isom_set_fragment_reference_time(video_output_file->isof, video_output_file->trackID, ntpts, video_output_file->pts_at_segment_start); } } @@ -626,7 +856,7 @@ int dc_video_muxer_write(VideoOutputFile *video_output_file, int frame_nb, Bool if (!video_output_file->segment_started) { u32 sec, frac; u64 ntpts; - + video_output_file->pts_at_segment_start = video_output_file->codec_ctx->coded_frame->pts; video_output_file->segment_started = 1; @@ -634,7 +864,9 @@ int dc_video_muxer_write(VideoOutputFile *video_output_file, int frame_nb, Bool time_t secs; struct tm t; gf_net_get_ntp(&sec, &frac); - ntpts = sec; ntpts <<= 32; ntpts |= frac; + ntpts = sec; + ntpts <<= 32; + ntpts |= frac; gf_isom_set_fragment_reference_time(video_output_file->isof, video_output_file->trackID, ntpts, video_output_file->pts_at_segment_start); secs = sec - GF_NTP_SEC_1900_TO_1970; diff --git a/applications/dashcast/video_muxer.h b/applications/dashcast/video_muxer.h index 3f9c03e..f869589 100644 --- a/applications/dashcast/video_muxer.h +++ b/applications/dashcast/video_muxer.h @@ -51,7 +51,7 @@ typedef enum { * available in Consumer data structure. */ typedef struct { - //VideoDataConf *video_data_conf; + VideoDataConf *video_data_conf; VideoMuxerType muxer_type; /* file format context structure */ diff --git a/applications/dashcast/video_scaler.c b/applications/dashcast/video_scaler.c index 7c64f3e..277d95f 100644 --- a/applications/dashcast/video_scaler.c +++ b/applications/dashcast/video_scaler.c @@ -60,7 +60,9 @@ VideoScaledDataNode * dc_video_scaler_node_create(int width, int height, int cro void dc_video_scaler_node_destroy(VideoScaledDataNode *video_scaled_data_node) { +#ifndef GPAC_USE_LIBAV av_frame_free(&video_scaled_data_node->v_frame); +#endif gf_free(video_scaled_data_node); } @@ -77,7 +79,7 @@ void dc_video_scaler_list_init(VideoScaledDataList *video_scaled_data_list, GF_L found = 0; for (j=0; jsize; j++) { if ( video_scaled_data_list->video_scaled_data[j]->out_height == video_data_conf->height - && video_scaled_data_list->video_scaled_data[j]->out_width == video_data_conf->width) { + && video_scaled_data_list->video_scaled_data[j]->out_width == video_data_conf->width) { found = 1; video_scaled_data_list->video_scaled_data[j]->num_consumers++; break; @@ -142,11 +144,11 @@ int dc_video_scaler_data_set_prop(VideoInputData *video_input_data, VideoScaledD video_scaled_data->vsprop[index].in_pix_fmt = video_input_data->vprop[index].pix_fmt; video_scaled_data->vsprop[index].sws_ctx = sws_getContext( - video_scaled_data->vsprop[index].in_width, - video_scaled_data->vsprop[index].in_height, - video_scaled_data->vsprop[index].in_pix_fmt, - video_scaled_data->out_width, video_scaled_data->out_height, - video_scaled_data->out_pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL); + video_scaled_data->vsprop[index].in_width, + video_scaled_data->vsprop[index].in_height, + video_scaled_data->vsprop[index].in_pix_fmt, + video_scaled_data->out_width, video_scaled_data->out_height, + video_scaled_data->out_pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL); if (video_scaled_data->vsprop[index].sws_ctx == NULL) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot initialize the conversion context!\n")); return -1; @@ -168,7 +170,7 @@ int dc_video_scaler_scale(VideoInputData *video_input_data, VideoScaledData *vid return -2; } - if (video_input_data->circular_buf.size > 1) + if (video_input_data->circular_buf.size > 1) dc_consumer_unlock_previous(&video_scaled_data->consumer, &video_input_data->circular_buf); dc_producer_lock(&video_scaled_data->producer, &video_scaled_data->circular_buf); @@ -201,9 +203,9 @@ int dc_video_scaler_scale(VideoInputData *video_input_data, VideoScaledData *vid //rescale the cropped frame sws_scale(video_scaled_data->vsprop[index].sws_ctx, - (const uint8_t * const *)src_vframe->data, src_vframe->linesize, 0, src_height, - video_scaled_data_node->v_frame->data, video_scaled_data_node->v_frame->linesize); - + (const uint8_t * const *)src_vframe->data, src_vframe->linesize, 0, src_height, + video_scaled_data_node->v_frame->data, video_scaled_data_node->v_frame->linesize); + video_scaled_data_node->v_frame->pts = video_data_node->vframe->pts; if (video_data_node->nb_raw_frames_ref) { @@ -219,7 +221,7 @@ int dc_video_scaler_scale(VideoInputData *video_input_data, VideoScaledData *vid dc_consumer_advance(&video_scaled_data->consumer); dc_producer_advance(&video_scaled_data->producer, &video_scaled_data->circular_buf); - if (video_input_data->circular_buf.size == 1) + if (video_input_data->circular_buf.size == 1) dc_consumer_unlock_previous(&video_scaled_data->consumer, &video_input_data->circular_buf); return 0; } diff --git a/applications/generators/MPEG4/main.c b/applications/generators/MPEG4/main.c index d797fb7..1715182 100644 --- a/applications/generators/MPEG4/main.c +++ b/applications/generators/MPEG4/main.c @@ -1,8 +1,8 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre - * Copyright (c) Telecom ParisTech 2004-2012 + * Authors: Jean Le Feuvre + * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * * This file is part of GPAC / MPEG4 Scene Graph Generator sub-project @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,13 +44,13 @@ static char *CurrentLine; void PrintUsage() { printf("MPEG4Gen [-p file] [template_file_v1 (template_file_v2 ...) ]\n" - "\nGPAC MPEG4 Scene Graph generator. Usage:\n" - "-p: listing file of nodes to exclude from tables\n" - "Template files MUST be fed in order\n" - "\n" - "Generated Files are directly updated in the GPAC distribution - do NOT try to change this\n\n" - "Written by Jean Le Feuvre - Copyright (c) Telecom ParisTech 2000-2012\n" - ); + "\nGPAC MPEG4 Scene Graph generator. Usage:\n" + "-p: listing file of nodes to exclude from tables\n" + "Template files MUST be fed in order\n" + "\n" + "Generated Files are directly updated in the GPAC distribution - do NOT try to change this\n\n" + "Written by Jean Le Feuvre - Copyright (c) Telecom ParisTech 2000-2012\n" + ); } //a node field @@ -119,7 +119,7 @@ u32 GetNextToken(char *token, char *sep) u32 i , j = 0; strcpy(token, ""); - + //skip separaors while (*CurrentLine && strchr(sep, *CurrentLine)) { CurrentLine = CurrentLine + 1; @@ -228,7 +228,7 @@ FILE *BeginFile(char *name, u32 type) sprintf(sPath, "..%c..%c..%csrc%cscenegraph%c%s.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, name); } } - + f = fopen(sPath, "wt"); fprintf(f, "%s\n", cprt); @@ -290,7 +290,7 @@ void WriteNodesFile(GF_List *BNodes, GF_List *NDTs, u32 NumVersions) //write all tags fprintf(f, "\n\nenum {\n"); - + for (i=0; iFields); j++) { bf = gf_list_get(n->Fields, j); - + if (!strcmp(bf->name, "addChildren") || !strcmp(bf->name, "removeChildren")) continue; if (!strcmp(bf->name, "children") && stricmp(n->name, "audioBuffer")) continue; @@ -337,8 +337,8 @@ void WriteNodesFile(GF_List *BNodes, GF_List *NDTs, u32 NumVersions) //we will likely need a function such as: // void SignalRoute(route_stack, node, par) fprintf(f, "\t%s %s;\t/*eventOut*/\n", bf->familly, bf->name); - } else if (strstr(bf->familly, "Node")) { - //this is a POINTER to a node + } else if (strstr(bf->familly, "Node")) { + //this is a POINTER to a node if (strstr(bf->familly, "SF")) { fprintf(f, "\tGF_Node *%s;\t/*%s*/\n", bf->name, bf->type); } else { @@ -350,18 +350,18 @@ void WriteNodesFile(GF_List *BNodes, GF_List *NDTs, u32 NumVersions) } } if (!strcmp(n->name, "CacheTexture")) { - fprintf(f, "\t/*GPAC private*/\n"); - fprintf(f, "\tu8 *data;\n"); - fprintf(f, "\tu32 data_len;\n"); + fprintf(f, "\t/*GPAC private*/\n"); + fprintf(f, "\tu8 *data;\n"); + fprintf(f, "\tu32 data_len;\n"); } if (!strcmp(n->name, "BitWrapper")) { - fprintf(f, "\t/*GPAC private*/\n"); - fprintf(f, "\tu32 buffer_len;\n"); + fprintf(f, "\t/*GPAC private*/\n"); + fprintf(f, "\tu32 buffer_len;\n"); } fprintf(f, "} M_%s;\n\n\n", n->name); } - + hasViewport = 0; //all NDTs are defined in v1 fprintf(f, "/*NodeDataType tags*/\nenum {\n"); @@ -465,11 +465,11 @@ void WriteNDT_H(FILE *f, GF_List *BNodes, GF_List *NDTs, u32 Version) count -= 1; } if (!count) continue; - + //numBits fprintf(f, "#define %s_V%d_NUMBITS\t\t%d\n", NDTName, Version, GetBitsCount(count + ( (Version == 2) ? 1 : 0) ) ); fprintf(f, "#define %s_V%d_Count\t%d\n\n", NDTName, Version, count); - + fprintf(f, "static const u32 %s_V%d_TypeToTag[%d] = {\n", NDTName, Version, count); first = 1; //browse each node. @@ -477,7 +477,7 @@ void WriteNDT_H(FILE *f, GF_List *BNodes, GF_List *NDTs, u32 Version) n = gf_list_get(BNodes, j); if (n->version != Version) continue; if (!IsNodeInTable(n, NDTName)) continue; - + if (first) { fprintf(f, " TAG_MPEG4_%s", n->name); first = 0; @@ -492,7 +492,7 @@ void WriteNDT_H(FILE *f, GF_List *BNodes, GF_List *NDTs, u32 Version) fprintf(f, "\nu32 NDT_V%d_GetNumBits(u32 NDT_Tag);\n", Version); fprintf(f, "u32 NDT_V%d_GetNodeTag(u32 Context_NDT_Tag, u32 NodeType);\n", Version); fprintf(f, "u32 NDT_V%d_GetNodeType(u32 NDT_Tag, u32 NodeTag);\n", Version); - + fprintf(f, "\n\n"); } @@ -532,7 +532,7 @@ void WriteNDT_Dec(FILE *f, GF_List *BNodes, GF_List *NDTs, u32 Version) count -= 1; } if (!count) continue; - + fprintf(f, "\tcase NDT_%s:\n\t\tif (NodeType >= %s_V%d_Count) return 0;\n", NDTName, NDTName, Version); fprintf(f, "\t\treturn %s_V%d_TypeToTag[NodeType];\n", NDTName, Version); } @@ -551,7 +551,7 @@ void WriteNDT_Dec(FILE *f, GF_List *BNodes, GF_List *NDTs, u32 Version) count -= 1; } if (!count) continue; - + fprintf(f, "\tcase NDT_%s:\n\t\treturn %s_V%d_NUMBITS;\n", NDTName, NDTName, Version); } /*all tables have 1 node in v2 for proto coding*/ @@ -588,7 +588,7 @@ void WriteNodeFields(FILE *f, BNode *n) u32 NbDef, NbIn, NbOut, NbDyn, hasAQ; NbDef = NbIn = NbOut = NbDyn = hasAQ = 0; - for (i=0;iFields); i++) { + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); if (!strcmp(bf->type, "field") || !strcmp(bf->type, "exposedField")) { NbDef += 1; @@ -719,11 +719,11 @@ void WriteNodeFields(FILE *f, BNode *n) fprintf(f, "static GF_Err %s_get_field(GF_Node *node, GF_FieldInfo *info)\n{\n\tswitch (info->fieldIndex) {\n", n->name); - for (i=0;iFields); i++) { + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); fprintf(f, "\tcase %d:\n", i); - + fprintf(f, "\t\tinfo->name = \"%s\";\n", (bf->name[0]=='_') ? bf->name+1 : bf->name); //skip all eventIn @@ -763,7 +763,7 @@ void WriteNodeFields(FILE *f, BNode *n) fprintf(f, "\tdefault:\n\t\treturn GF_BAD_PARAM;\n\t}\n}\n\n"); fprintf(f, "\nstatic s32 %s_get_field_index_by_name(char *name)\n{\n", n->name); - for (i=0;iFields); i++) { + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); fprintf(f, "\tif (!strcmp(\"%s\", name)) return %d;\n", (bf->name[0]=='_') ? bf->name+1 : bf->name, i); } @@ -777,7 +777,7 @@ void WriteNodeQuant(FILE *f, BNode *n) u32 i; BField *bf; fprintf(f, "static Bool %s_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits)\n{\n\tswitch (FieldIndex) {\n", n->name); - + for (i=0; iFields) ; i++ ) { bf = gf_list_get(n->Fields, i); if (!bf->hasAnim && !bf->hasQuant) continue; @@ -787,7 +787,7 @@ void WriteNodeQuant(FILE *f, BNode *n) fprintf(f, "\t\t*AType = %d;\n", bf->AnimType); //Quant Type fprintf(f, "\t\t*QType = %s;\n", bf->quant_type); - if (!strcmp(bf->quant_type, "13")) + if (!strcmp(bf->quant_type, "13")) fprintf(f, "\t\t*QT13_bits = %s;\n", bf->qt13_bits); //Bounds @@ -841,35 +841,35 @@ void WriteNodeCode(GF_List *BNodes) //nothing on child events if (!strcmp(bf->name, "addChildren")) continue; if (!strcmp(bf->name, "removeChildren")) continue; - + //delete all children node if (!strcmp(bf->name, "children") && stricmp(n->name, "audioBuffer")) { is_parent = 1; continue; } - //delete ALL fields that must be deleted: this includes eventIn and out since + //delete ALL fields that must be deleted: this includes eventIn and out since //all fields are defined in the node if (!strcmp(bf->familly, "MFInt") - || !strcmp(bf->familly, "MFFloat") - || !strcmp(bf->familly, "MFDouble") - || !strcmp(bf->familly, "MFBool") - || !strcmp(bf->familly, "MFInt32") - || !strcmp(bf->familly, "MFColor") - || !strcmp(bf->familly, "MFRotation") - || !strcmp(bf->familly, "MFString") - || !strcmp(bf->familly, "MFTime") - || !strcmp(bf->familly, "MFVec2f") - || !strcmp(bf->familly, "MFVec3f") - || !strcmp(bf->familly, "MFVec4f") - || !strcmp(bf->familly, "MFVec2d") - || !strcmp(bf->familly, "MFVec3d") - || !strcmp(bf->familly, "MFURL") - || !strcmp(bf->familly, "MFScript") - || !strcmp(bf->familly, "SFString") - || !strcmp(bf->familly, "SFURL") - || !strcmp(bf->familly, "SFImage") - ) { + || !strcmp(bf->familly, "MFFloat") + || !strcmp(bf->familly, "MFDouble") + || !strcmp(bf->familly, "MFBool") + || !strcmp(bf->familly, "MFInt32") + || !strcmp(bf->familly, "MFColor") + || !strcmp(bf->familly, "MFRotation") + || !strcmp(bf->familly, "MFString") + || !strcmp(bf->familly, "MFTime") + || !strcmp(bf->familly, "MFVec2f") + || !strcmp(bf->familly, "MFVec3f") + || !strcmp(bf->familly, "MFVec4f") + || !strcmp(bf->familly, "MFVec2d") + || !strcmp(bf->familly, "MFVec3d") + || !strcmp(bf->familly, "MFURL") + || !strcmp(bf->familly, "MFScript") + || !strcmp(bf->familly, "SFString") + || !strcmp(bf->familly, "SFURL") + || !strcmp(bf->familly, "SFImage") + ) { char szName[500]; strcpy(szName, bf->familly); strlwr(szName); @@ -878,8 +878,8 @@ void WriteNodeCode(GF_List *BNodes) else if (!strcmp(bf->familly, "SFCommandBuffer")) { fprintf(f, "\tgf_sg_sfcommand_del(p->%s);\n", bf->name); } - else if (strstr(bf->familly, "Node")) { - //this is a POINTER to a node + else if (strstr(bf->familly, "Node")) { + //this is a POINTER to a node if (strstr(bf->familly, "SF")) { fprintf(f, "\tgf_node_unregister((GF_Node *) p->%s, (GF_Node *) p);\t\n", bf->name); } else { @@ -913,9 +913,9 @@ void WriteNodeCode(GF_List *BNodes) fprintf(f, "\tgf_sg_vrml_parent_setup((GF_Node *) p);\n"); break; } - else if ( strstr(bf->familly, "Node") && strncmp(bf->type, "event", 5) ) { + else if ( strstr(bf->familly, "Node") && strncmp(bf->type, "event", 5) ) { #if 0 - //this is a POINTER to a node + //this is a POINTER to a node if (strstr(bf->familly, "MF")) { //this is a POINTER to a chain fprintf(f, "\tp->%s = gf_list_new();\t\n", bf->name); @@ -931,15 +931,15 @@ void WriteNodeCode(GF_List *BNodes) //check if we have a child node for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); - if ( !strcmp(bf->name, "children") || - ( !strstr(bf->type, "event") && strstr(bf->familly, "MF") && strstr(bf->familly, "Node")) ) { + if ( !strcmp(bf->name, "children") || + ( !strstr(bf->type, "event") && strstr(bf->familly, "MF") && strstr(bf->familly, "Node")) ) { sprintf(n->Child_NDT_Name, "NDT_SF%s", bf->familly+2); break; } } fprintf(f, "\n\t/*default field values*/\n"); - + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); @@ -952,14 +952,14 @@ void WriteNodeCode(GF_List *BNodes) //no default on nodes if (strstr(bf->familly, "Node")) continue; //extract default falue - + // // SF Fields // - + //SFBool if (!strcmp(bf->familly, "SFBool")) { - if (!strcmp(bf->def, "1") || !strcmp(bf->def, "TRUE")) + if (!strcmp(bf->def, "1") || !strcmp(bf->def, "TRUE")) fprintf(f, "\tp->%s = 1;\n", bf->name); } //SFFloat @@ -1040,7 +1040,7 @@ void WriteNodeCode(GF_List *BNodes) fprintf(f, "\tp->%s.buffer = (char*)gf_malloc(sizeof(char) * %d);\n", bf->name, strlen(bf->def)+1); fprintf(f, "\tstrcpy(p->%s.buffer, \"%s\");\n", bf->name, bf->def); } - + // // MF Fields // @@ -1365,7 +1365,7 @@ void ParseTemplateFile(FILE *nodes, GF_List *BNodes, GF_List *NDTs, u32 version) if (sLine[0] == '\n') continue; CurrentLine = sLine; - + //parse the line till end of line while (GetNextToken(token, " \t")) { @@ -1424,7 +1424,7 @@ void ParseTemplateFile(FILE *nodes, GF_List *BNodes, GF_List *NDTs, u32 version) } f = BlankField(); gf_list_add(n->Fields, f); - + //get the field type strcpy(f->type, token); GetNextToken(f->familly, " \t"); @@ -1553,7 +1553,7 @@ void parse_profile(GF_List *nodes, FILE *prof) //skip comment and empty lines if (sLine[0] == '#') continue; if (sLine[0] == '\n') continue; - if (strstr(sLine, "Proximity")) + if (strstr(sLine, "Proximity")) found = 0; found = 1; while (found) { @@ -1620,25 +1620,25 @@ void generate_ndts(GF_List *NDTs, GF_List *nodes, u32 nbVersion) char szStr[100]; nb_ndt = gf_list_count(NDTs); nb_nodes = gf_list_count(nodes); - for (i=0; i\n"\ -"\n"\ -"\n"\ -"NdtListV%d.html\n"\ -"\n"\ -"\n"\ -"Node Coding Tables for BIFS Version %d group\n" - ,GPAC_FULL_VERSION, i+1, i+1); + "\n"\ + "\n"\ + "NdtListV%d.html\n"\ + "\n"\ + "\n"\ + "Node Coding Tables for BIFS Version %d group\n" + ,GPAC_FULL_VERSION, i+1, i+1); for (j=0; jversion != i+1) continue; if (!IsNodeInTable(n, ndt)) continue; @@ -1648,22 +1648,22 @@ void generate_ndts(GF_List *NDTs, GF_List *nodes, u32 nbVersion) if (!nb_in_ndt) continue; fprintf(f, "
\n"\ -"\n"\ -"\n"\ -"\n", ndt, ndt, nb_in_ndt); + "
%s%u nodes
\n"\ + "\n"\ + "\n", ndt, ndt, nb_in_ndt); nb_bits = GetBitsCount(nb_in_ndt); fprintf(f, "\n", format_bit_string(szStr, 0, nb_bits)); idx = 1; - for (k=0;kversion != i+1) continue; if (!IsNodeInTable(n, ndt)) continue; n->hasDef = n->hasIn = n->hasOut = n->hasDyn = 0; - for (l=0;lFields); l++) { + for (l=0; lFields); l++) { BField *bf = gf_list_get(n->Fields, l); if (!strcmp(bf->type, "field") || !strcmp(bf->type, "exposedField")) { n->hasDef += 1; @@ -1735,7 +1735,7 @@ int main (int argc, char **argv) //all nodes are in the same list but we keep version info ParseTemplateFile(nodes, BNodes, NDTs, nbVersion); - + //special case for viewport: it is present in V1 but empty if (nbVersion==1) CheckInTable("SFViewportNode", NDTs); @@ -1769,7 +1769,7 @@ int main (int argc, char **argv) fprintf(ndt_c, "\n\n#include \n"); fprintf(ndt_c, "\n\n#ifndef GPAC_DISABLE_BIFS\n"); - + //prepare the encoding file fprintf(ndt_h, "\n\nu32 ALL_GetNodeType(const u32 *table, const u32 count, u32 NodeTag, u32 Version);\n\n"); fprintf(ndt_c, "\n\nu32 ALL_GetNodeType(const u32 *table, const u32 count, u32 NodeTag, u32 Version)\n{\n\tu32 i = 0;"); @@ -1803,11 +1803,11 @@ int main (int argc, char **argv) for (i=0; i\n"); fprintf(f, "\n"); - fprintf(f, "

Status of the SVG implementation in GPAC

\n"); + fprintf(f, "

Status of the SVG implementation in GPAC

\n"); return f; } @@ -66,7 +66,7 @@ void generate_table(GF_List *elements) FILE *f; f = BeginHtml(); - + fprintf(f, "

Legend

\n"); fprintf(f, "
%s%u nodes
reserved

%s

 

 

 

 

\n"); fprintf(f, "\n"); @@ -111,7 +111,7 @@ void generate_table(GF_List *elements) fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); - fprintf(f, "\n"); + fprintf(f, "\n"); } fprintf(f, "\n"); fprintf(f, "
   
\n"); @@ -140,7 +140,7 @@ void generate_table(GF_List *elements) fprintf(f, "%d -  \n",++nbExamples); fprintf(f, " \n"); fprintf(f, "\n"); - } + } fprintf(f, "\n"); fprintf(f, "\n"); } diff --git a/applications/generators/SVG/laser.c b/applications/generators/SVG/laser.c index 2986d9a..376bef3 100644 --- a/applications/generators/SVG/laser.c +++ b/applications/generators/SVG/laser.c @@ -2,7 +2,7 @@ * GPAC - Multimedia Framework C SDK * * Authors: Cyril Concolato - * Copyright (c) Telecom ParisTech 2004-2012 + * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * * This file is part of GPAC / SVG Scene Graph Generator sub-project @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,17 +32,17 @@ static char *laser_attribute_name_type_list[] = { static char *laser_attribute_rare_type_list[] = { - "_class", "audio_level", "color", "color_rendering", "display", "display_align", "fill_opacity", - "fill_rule", "image_rendering", "line_increment", "pointer_events", "shape_rendering", "solid_color", - "solid_opacity", "stop_color", "stop_opacity", "stroke_dasharray", "stroke_dashoffset", "stroke_linecap", - "stroke_linejoin", "stroke_miterlimit", "stroke_opacity", "stroke_width", "text_anchor", "text_rendering", - "viewport_fill", "viewport_fill_opacity", "vector_effect", "visibility", "requiredExtensions", - "requiredFeatures", "requiredFormats", "systemLanguage", "xml_base", "xml_lang", "xml_space", - "nav_next", "nav_up", "nav_up_left", "nav_up_right", "nav_prev", "nav_down", "nav_down_left", - "nav_down_right", "nav_left", "focusable", "nav_right", "transform","text_decoration", + "_class", "audio_level", "color", "color_rendering", "display", "display_align", "fill_opacity", + "fill_rule", "image_rendering", "line_increment", "pointer_events", "shape_rendering", "solid_color", + "solid_opacity", "stop_color", "stop_opacity", "stroke_dasharray", "stroke_dashoffset", "stroke_linecap", + "stroke_linejoin", "stroke_miterlimit", "stroke_opacity", "stroke_width", "text_anchor", "text_rendering", + "viewport_fill", "viewport_fill_opacity", "vector_effect", "visibility", "requiredExtensions", + "requiredFeatures", "requiredFormats", "systemLanguage", "xml_base", "xml_lang", "xml_space", + "nav_next", "nav_up", "nav_up_left", "nav_up_right", "nav_prev", "nav_down", "nav_down_left", + "nav_down_right", "nav_left", "focusable", "nav_right", "transform","text_decoration", "extension", /*LASER EXTENSIONS SVG*/ - "font_variant", "font_family", "font_size", "font_style", "font_weight", "xlink_title", "xlink_type", + "font_variant", "font_family", "font_size", "font_style", "font_weight", "xlink_title", "xlink_type", "xlink_role", "xlink_arcrole", "xlink_actuate", "xlink_show", "end", "max", "min", NULL }; @@ -99,7 +99,7 @@ void generate_laser_tables(GF_List *svg_elements) if (elt->has_media_properties) generateGenericAttrib(output, elt, 2); if (elt->has_properties) generateGenericAttrib(output, elt, 1); if (elt->has_opacity_properties) generateGenericAttrib(output, elt, 3); - if (elt->has_focus) generateGenericAttrib(output, elt, 4); + if (elt->has_focus) generateGenericAttrib(output, elt, 4); if (elt->has_xlink) generateGenericAttrib(output, elt, 5); if (elt->has_timing) generateGenericAttrib(output, elt, 6); if (elt->has_sync) generateGenericAttrib(output, elt, 7); @@ -119,12 +119,12 @@ void generate_laser_tables(GF_List *svg_elements) SVGGenAttribute *att = gf_list_get(elt->attributes, j); s32 type = get_lsr_att_name_type(att->svg_name); if (special_cases==1) { - if (!strcmp(att->svg_name, "width")) + if (!strcmp(att->svg_name, "width")) type = 95; - else if (!strcmp(att->svg_name, "height")) + else if (!strcmp(att->svg_name, "height")) type = 94; } - if ((special_cases==2) && !strcmp(att->svg_name, "target")) + if ((special_cases==2) && !strcmp(att->svg_name, "target")) type = 0; fprintf(output, ", %d", type); } @@ -149,7 +149,7 @@ void generate_laser_tables_da(GF_List *atts) u32 i, count, j, count2; output = BeginFile(2); - + fprintf(output, "\n#include \n\n"); fprintf(output, "\n\ns32 gf_lsr_anim_type_from_attribute(u32 tag) {\n\tswitch(tag) {\n"); @@ -247,7 +247,7 @@ void generate_laser_tables_da(GF_List *atts) } for (i=0; iimplementation_name, laser_attribute_rare_type_list[j])) + if (!strcmp(att->implementation_name, laser_attribute_rare_type_list[j])) break; att = NULL; } @@ -262,6 +262,6 @@ void generate_laser_tables_da(GF_List *atts) j++; } fprintf(output, "\treturn 1;\n}\n\n"); - + fclose(output); } \ No newline at end of file diff --git a/applications/generators/SVG/main.c b/applications/generators/SVG/main.c index 7de0a23..668c701 100644 --- a/applications/generators/SVG/main.c +++ b/applications/generators/SVG/main.c @@ -2,7 +2,7 @@ * GPAC - Multimedia Framework C SDK * * Authors: Cyril Concolato - * Copyright (c) Telecom ParisTech 2004-2012 + * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * * This file is part of GPAC / SVG Scene Graph Generator sub-project @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -49,7 +49,7 @@ SVGGenAttrGrp *NewSVGGenAttrGrp() return tmp; } -SVGGenElement *NewSVGGenElement() +SVGGenElement *NewSVGGenElement() { SVGGenElement *elt; GF_SAFEALLOC(elt, SVGGenElement); @@ -146,56 +146,65 @@ void svgNameToImplementationName(xmlChar *svg_name, char implementation_name[50] char *tmp; strcpy(implementation_name, svg_name); tmp = implementation_name; - while ( (tmp = strchr(tmp, '.')) ) { *tmp='_'; tmp++; } + while ( (tmp = strchr(tmp, '.')) ) { + *tmp='_'; + tmp++; + } tmp = implementation_name; - while ( (tmp = strchr(tmp, '-')) ) { *tmp='_'; tmp++; } + while ( (tmp = strchr(tmp, '-')) ) { + *tmp='_'; + tmp++; + } tmp = implementation_name; - while ( (tmp = strchr(tmp, ':')) ) { *tmp='_'; tmp++; } + while ( (tmp = strchr(tmp, ':')) ) { + *tmp='_'; + tmp++; + } } -static Bool isGenericAttributesGroup(char *name) +static Bool isGenericAttributesGroup(char *name) { if (!strcmp(name, "svg.Core.attr") || - !strcmp(name, "svg.CorePreserve.attr") || - !strcmp(name, "svg.External.attr") || - !strcmp(name, "svg.Properties.attr") || - !strcmp(name, "svg.Media.attr") || - !strcmp(name, "svg.MediaClip.attr") || - !strcmp(name, "svg.Opacity.attr") || - !strcmp(name, "svg.FocusHighlight.attr") || - !strcmp(name, "svg.Focus.attr") || - !strcmp(name, "svg.AnimateCommon.attr") || - !strcmp(name, "svg.XLinkEmbed.attr") || - !strcmp(name, "svg.XLinkRequired.attr") || - !strcmp(name, "svg.XLinkReplace.attr") || + !strcmp(name, "svg.CorePreserve.attr") || + !strcmp(name, "svg.External.attr") || + !strcmp(name, "svg.Properties.attr") || + !strcmp(name, "svg.Media.attr") || + !strcmp(name, "svg.MediaClip.attr") || + !strcmp(name, "svg.Opacity.attr") || + !strcmp(name, "svg.FocusHighlight.attr") || + !strcmp(name, "svg.Focus.attr") || + !strcmp(name, "svg.AnimateCommon.attr") || + !strcmp(name, "svg.XLinkEmbed.attr") || + !strcmp(name, "svg.XLinkRequired.attr") || + !strcmp(name, "svg.XLinkReplace.attr") || // !strcmp(name, "svg.ContentType.attr") || - !strcmp(name, "svg.AnimateTiming.attr") || - !strcmp(name, "svg.AnimateTimingNoMinMax.attr") || - !strcmp(name, "svg.AnimateBegin.attr") || - !strcmp(name, "svg.AnimateTimingNoFillNoMinMax.attr") || - !strcmp(name, "svg.AnimateSync.attr") || - !strcmp(name, "svg.AnimateSyncDefault.attr") || - !strcmp(name, "svg.AnimateAttributeCommon.attr") || - !strcmp(name, "svg.AnimateToCommon.attr") || - !strcmp(name, "svg.AnimateValueCommon.attr") || - !strcmp(name, "svg.AnimateAdditionCommon.attr") || - !strcmp(name, "svg.AnimateTypeCommon.attr") || - !strcmp(name, "svg.Conditional.attr") || + !strcmp(name, "svg.AnimateTiming.attr") || + !strcmp(name, "svg.AnimateTimingNoMinMax.attr") || + !strcmp(name, "svg.AnimateBegin.attr") || + !strcmp(name, "svg.AnimateTimingNoFillNoMinMax.attr") || + !strcmp(name, "svg.AnimateSync.attr") || + !strcmp(name, "svg.AnimateSyncDefault.attr") || + !strcmp(name, "svg.AnimateAttributeCommon.attr") || + !strcmp(name, "svg.AnimateToCommon.attr") || + !strcmp(name, "svg.AnimateValueCommon.attr") || + !strcmp(name, "svg.AnimateAdditionCommon.attr") || + !strcmp(name, "svg.AnimateTypeCommon.attr") || + !strcmp(name, "svg.Conditional.attr") || // !strcmp(name, "svg.XY.attr") || - !strcmp(name, "svg.Transform.attr")) { + !strcmp(name, "svg.Transform.attr")) { return 1; } else { return 0; } } -static Bool setGenericAttributesFlags(char *name, SVGGenElement *e) +static Bool setGenericAttributesFlags(char *name, SVGGenElement *e) { Bool ret = 1; if (!strcmp(name, "svg.Core.attr") || - !strcmp(name, "svg.CorePreserve.attr") || - !strcmp(name, "svg.External.attr")) { - e->has_svg_generic = 1; + !strcmp(name, "svg.CorePreserve.attr") || + !strcmp(name, "svg.External.attr")) { + e->has_svg_generic = 1; e->has_xml_generic = 1; } else if (!strcmp(name, "svg.Properties.attr")) { e->has_properties = 1; @@ -204,28 +213,28 @@ static Bool setGenericAttributesFlags(char *name, SVGGenElement *e) e->has_media_properties = 1; } else if (!strcmp(name, "svg.Opacity.attr")) { e->has_opacity_properties = 1; - } else if (!strcmp(name, "svg.FocusHighlight.attr") || - !strcmp(name, "svg.Focus.attr")) { + } else if (!strcmp(name, "svg.FocusHighlight.attr") || + !strcmp(name, "svg.Focus.attr")) { e->has_focus = 1; } else if (!strcmp(name, "svg.AnimateCommon.attr") || - !strcmp(name, "svg.XLinkEmbed.attr") || - !strcmp(name, "svg.XLinkRequired.attr") || - !strcmp(name, "svg.XLinkReplace.attr")) { //|| + !strcmp(name, "svg.XLinkEmbed.attr") || + !strcmp(name, "svg.XLinkRequired.attr") || + !strcmp(name, "svg.XLinkReplace.attr")) { //|| // !strcmp(name, "svg.ContentType.attr")) { e->has_xlink = 1; } else if (!strcmp(name, "svg.AnimateTiming.attr") || - !strcmp(name, "svg.AnimateTimingNoMinMax.attr") || - !strcmp(name, "svg.AnimateBegin.attr") || - !strcmp(name, "svg.AnimateTimingNoFillNoMinMax.attr")) { + !strcmp(name, "svg.AnimateTimingNoMinMax.attr") || + !strcmp(name, "svg.AnimateBegin.attr") || + !strcmp(name, "svg.AnimateTimingNoFillNoMinMax.attr")) { e->has_timing = 1; } else if (!strcmp(name, "svg.AnimateSync.attr") || - !strcmp(name, "svg.AnimateSyncDefault.attr")) { + !strcmp(name, "svg.AnimateSyncDefault.attr")) { e->has_sync= 1; } else if (!strcmp(name, "svg.AnimateAttributeCommon.attr") || - !strcmp(name, "svg.AnimateToCommon.attr") || - !strcmp(name, "svg.AnimateValueCommon.attr") || - !strcmp(name, "svg.AnimateAdditionCommon.attr") || - !strcmp(name, "svg.AnimateTypeCommon.attr")) { + !strcmp(name, "svg.AnimateToCommon.attr") || + !strcmp(name, "svg.AnimateValueCommon.attr") || + !strcmp(name, "svg.AnimateAdditionCommon.attr") || + !strcmp(name, "svg.AnimateTypeCommon.attr")) { e->has_animation = 1; } else if (!strcmp(name, "svg.Conditional.attr")) { e->has_conditional = 1; @@ -241,16 +250,16 @@ static Bool setGenericAttributesFlags(char *name, SVGGenElement *e) static void flattenAttributeGroup(SVGGenAttrGrp attgrp, SVGGenElement *e, Bool all); -static void flattenAttributeGroups(GF_List *attrgrps, SVGGenElement *e, Bool all) +static void flattenAttributeGroups(GF_List *attrgrps, SVGGenElement *e, Bool all) { u32 i; for (i = 0; i < gf_list_count(attrgrps); i ++) { SVGGenAttrGrp *ag = gf_list_get(attrgrps, i); flattenAttributeGroup(*ag, e, all); - } + } } -static void flattenAttributeGroup(SVGGenAttrGrp attgrp, SVGGenElement *e, Bool all) +static void flattenAttributeGroup(SVGGenAttrGrp attgrp, SVGGenElement *e, Bool all) { u32 i; @@ -263,15 +272,15 @@ static void flattenAttributeGroup(SVGGenAttrGrp attgrp, SVGGenElement *e, Bool a } else { flattenAttributeGroups(attgrp.attrgrps, e, all); for (i = 0; i < gf_list_count(attgrp.attrs); i++) { - if (all) + if (all) gf_list_add(e->generic_attributes, gf_list_get(attgrp.attrs, i)); - else + else gf_list_add(e->attributes, gf_list_get(attgrp.attrs, i)); } } } -SVGGenAttribute *findAttribute(SVGGenElement *e, char *name) +SVGGenAttribute *findAttribute(SVGGenElement *e, char *name) { u32 i; for (i = 0; i < gf_list_count(e->attributes); i++) { @@ -291,74 +300,74 @@ static u32 countAttributesAllInGroup(SVGGenAttrGrp *ag) for (i = 0; i < gf_list_count(ag->attrgrps); i ++) { SVGGenAttrGrp *agtmp = gf_list_get(ag->attrgrps, i); ret += countAttributesAllInGroup(agtmp); - } + } ret += gf_list_count(ag->attrs); return ret; } /* XML related functions */ -xmlNodeSetPtr findNodes( xmlXPathContextPtr ctxt, xmlChar * path ) +xmlNodeSetPtr findNodes( xmlXPathContextPtr ctxt, xmlChar * path ) { - xmlXPathObjectPtr res = NULL; - - if ( ctxt->node != NULL && path != NULL ) { - xmlXPathCompExprPtr comp; - - xmlDocPtr tdoc = NULL; - xmlNodePtr froot = ctxt->node; - - comp = xmlXPathCompile( path ); - if ( comp == NULL ) { - return NULL; - } - - if ( ctxt->node->doc == NULL ) { - /* if one XPaths a node from a fragment, libxml2 will - refuse the lookup. this is not very usefull for XML - scripters. thus we need to create a temporary document - to make libxml2 do it's job correctly. - */ - tdoc = xmlNewDoc( NULL ); - - /* find refnode's root node */ - while ( froot != NULL ) { - if ( froot->parent == NULL ) { - break; - } - froot = froot->parent; - } - xmlAddChild((xmlNodePtr)tdoc, froot); - - ctxt->node->doc = tdoc; - } - - res = xmlXPathCompiledEval(comp, ctxt); - - xmlXPathFreeCompExpr(comp); - - if ( tdoc != NULL ) { - /* after looking through a fragment, we need to drop the - fake document again */ - xmlSetTreeDoc(froot,NULL); - froot->doc = NULL; - tdoc->children = NULL; - tdoc->last = NULL; - froot->parent = NULL; - ctxt->node->doc = NULL; - - xmlFreeDoc( tdoc ); - } - } + xmlXPathObjectPtr res = NULL; + + if ( ctxt->node != NULL && path != NULL ) { + xmlXPathCompExprPtr comp; + + xmlDocPtr tdoc = NULL; + xmlNodePtr froot = ctxt->node; + + comp = xmlXPathCompile( path ); + if ( comp == NULL ) { + return NULL; + } + + if ( ctxt->node->doc == NULL ) { + /* if one XPaths a node from a fragment, libxml2 will + refuse the lookup. this is not very usefull for XML + scripters. thus we need to create a temporary document + to make libxml2 do it's job correctly. + */ + tdoc = xmlNewDoc( NULL ); + + /* find refnode's root node */ + while ( froot != NULL ) { + if ( froot->parent == NULL ) { + break; + } + froot = froot->parent; + } + xmlAddChild((xmlNodePtr)tdoc, froot); + + ctxt->node->doc = tdoc; + } + + res = xmlXPathCompiledEval(comp, ctxt); + + xmlXPathFreeCompExpr(comp); + + if ( tdoc != NULL ) { + /* after looking through a fragment, we need to drop the + fake document again */ + xmlSetTreeDoc(froot,NULL); + froot->doc = NULL; + tdoc->children = NULL; + tdoc->last = NULL; + froot->parent = NULL; + ctxt->node->doc = NULL; + + xmlFreeDoc( tdoc ); + } + } if (res && res->type == XPATH_NODESET) return res->nodesetval; - else + else return NULL; } /* definition of GPAC groups of SVG attributes */ -void setAttributeType(SVGGenAttribute *att) +void setAttributeType(SVGGenAttribute *att) { if (!att->svg_type) { /* if the type is not given in the RNG, we explicitely set it */ if (!strcmp(att->svg_name, "textContent")) { @@ -398,27 +407,27 @@ void setAttributeType(SVGGenAttribute *att) strcpy(att->impl_type, "SMIL_KeySplines"); } else if (!strcmp(att->svg_name, "keyPoints")) { strcpy(att->impl_type, "SMIL_KeyPoints"); - } else if (!strcmp(att->svg_name, "from") || - !strcmp(att->svg_name, "to") || - !strcmp(att->svg_name, "by")) { + } else if (!strcmp(att->svg_name, "from") || + !strcmp(att->svg_name, "to") || + !strcmp(att->svg_name, "by")) { strcpy(att->impl_type, "SMIL_AnimateValue"); } else if (!strcmp(att->svg_name, "additive")) { strcpy(att->impl_type, "SMIL_Additive"); } else if (!strcmp(att->svg_name, "accumulate")) { strcpy(att->impl_type, "SMIL_Accumulate"); } else if (!strcmp(att->svg_name, "begin") || - !strcmp(att->svg_name, "end") - ) { + !strcmp(att->svg_name, "end") + ) { strcpy(att->impl_type, "SMIL_Times"); } else if (!strcmp(att->svg_name, "clipBegin") || - !strcmp(att->svg_name, "clipEnd") - ) { + !strcmp(att->svg_name, "clipEnd") + ) { strcpy(att->impl_type, "SVG_Clock"); } else if (!strcmp(att->svg_name, "min") || - !strcmp(att->svg_name, "max") || - !strcmp(att->svg_name, "dur") || - !strcmp(att->svg_name, "repeatDur") - ) { + !strcmp(att->svg_name, "max") || + !strcmp(att->svg_name, "dur") || + !strcmp(att->svg_name, "repeatDur") + ) { strcpy(att->impl_type, "SMIL_Duration"); } else if (!strcmp(att->svg_name, "repeat")) { strcpy(att->impl_type, "SMIL_Repeat"); @@ -506,8 +515,8 @@ void setAttributeType(SVGGenAttribute *att) strcpy(att->impl_type, "SVG_Boolean"); } else if (!strcmp(att->svg_name, "choice")) { strcpy(att->impl_type, "LASeR_Choice"); - } else if (!strcmp(att->svg_name, "size") || - !strcmp(att->svg_name, "delta")) { + } else if (!strcmp(att->svg_name, "size") || + !strcmp(att->svg_name, "delta")) { strcpy(att->impl_type, "LASeR_Size"); } else if (!strcmp(att->svg_name, "syncReference")) { strcpy(att->impl_type, "XMLRI"); @@ -541,20 +550,26 @@ void setAttributeType(SVGGenAttribute *att) char *tmp; sprintf(att->impl_type, "SVG_%s", att->svg_type); tmp = att->impl_type; - while ( (tmp = strstr(tmp, "-")) ) { *tmp='_'; tmp++; } + while ( (tmp = strstr(tmp, "-")) ) { + *tmp='_'; + tmp++; + } tmp = att->impl_type; - while ( (tmp = strstr(tmp, ".")) ) { *tmp='_'; tmp++; } + while ( (tmp = strstr(tmp, ".")) ) { + *tmp='_'; + tmp++; + } tmp = att->impl_type;; if ( (tmp = strstr(tmp, "datatype")) ) { tmp--; *tmp = 0; - } + } } } } -void getAttributeType(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, - xmlNodePtr attributeNode, SVGGenAttribute *a) +void getAttributeType(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, + xmlNodePtr attributeNode, SVGGenAttribute *a) { xmlNodeSetPtr refNodes; @@ -570,8 +585,8 @@ void getAttributeType(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, } } -void getRealAttributes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr newCtxNode, - GF_List *attributes) +void getRealAttributes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr newCtxNode, + GF_List *attributes) { xmlNodeSetPtr attributeNodes; int k; @@ -589,7 +604,7 @@ void getRealAttributes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr ne svgNameToImplementationName(a->svg_name, a->implementation_name); getAttributeType(doc, xpathCtx, attributeNode, a); setAttributeType(a); - for (j=0;jsvg_name, a->svg_name)) { already_exists = 1; @@ -606,7 +621,7 @@ void getRealAttributes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlNodePtr ne } } -SVGGenAttrGrp *getOneGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlChar *name) +SVGGenAttrGrp *getOneGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, xmlChar *name) { SVGGenAttrGrp *attgrp = NULL; xmlNodeSetPtr attrGrpDefNodes; @@ -631,7 +646,7 @@ SVGGenAttrGrp *getOneGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, x fprintf(stdout, "Warning: found 0 non-empty or allowed definition for the Group of Attributes: %s\n", name); return NULL; } - attgrp = NewSVGGenAttrGrp(); + attgrp = NewSVGGenAttrGrp(); attgrp->name = gf_strdup(name); svgNameToImplementationName(attgrp->name, attgrp->imp_name); gf_list_add(globalAttrGrp, attgrp); @@ -659,7 +674,7 @@ SVGGenAttrGrp *getOneGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx, x return attgrp; } -void getAllGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) +void getAllGlobalAttrGrp(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) { xmlNodeSetPtr elementNodes = findNodes(xpathCtx, "//rng:define"); int k; @@ -690,9 +705,9 @@ GF_List *getElements(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) SVGGenElement *e = NewSVGGenElement(); e->svg_name = xmlStrdup(xmlGetProp(elementNode, "name")); //fprintf(stdout, "\n\tElement %s\n", e->svg_name); - + svgNameToImplementationName(e->svg_name, e->implementation_name); - + /* getting the */ expr = xmlStrdup("//rng:define[@name=\""); if (!xmlStrcmp(e->svg_name, "polygon") || !xmlStrcmp(e->svg_name, "polyline")) { @@ -710,7 +725,7 @@ GF_List *getElements(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) for (j = 0; j nodeNr; j++) { xmlNodePtr refNode = refNodes->nodeTab[j]; char *name = xmlGetProp(refNode, "name"); - for (i = 0; i < gf_list_count(globalAttrGrp); i++) { + for (i = 0; i < gf_list_count(globalAttrGrp); i++) { SVGGenAttrGrp *a = gf_list_get(globalAttrGrp, i); if (!strcmp(a->name, name)) { if (isGenericAttributesGroup(a->name)) { @@ -728,11 +743,11 @@ GF_List *getElements(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) getRealAttributes(doc, xpathCtx, ATNodes->nodeTab[0], e->attributes); } - /* checking if this element is already present in the list of possible elements + /* checking if this element is already present in the list of possible elements and if not, adding it */ { Bool found = 0; - for (i=0;isvg_name, e->svg_name)) { found = 1; @@ -757,21 +772,21 @@ FILE *BeginFile(u32 type) #ifdef LOCAL_SVG_NODES sprintf(sPath, "nodes_svg.h", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); #else - if (generation_mode == 1) + if (generation_mode == 1) sprintf(sPath, "..%c..%c..%c..%cinclude%cgpac%cnodes_svg_sa.h", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); - else if (generation_mode == 2) + else if (generation_mode == 2) sprintf(sPath, "..%c..%c..%c..%cinclude%cgpac%cnodes_svg_sani.h", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); else if (generation_mode == 3) sprintf(sPath, "..%c..%c..%c..%cinclude%cgpac%cnodes_svg_da.h", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); - + #endif } else if (type==1) { #ifdef LOCAL_SVG_NODES sprintf(sPath, "svg_nodes.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); #else - if (generation_mode == 1) + if (generation_mode == 1) sprintf(sPath, "..%c..%c..%c..%csrc%cscenegraph%csvg_nodes_sa.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); - else if (generation_mode == 2) + else if (generation_mode == 2) sprintf(sPath, "..%c..%c..%c..%csrc%cscenegraph%csvg_nodes_sani.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); else if (generation_mode == 3) sprintf(sPath, "..%c..%c..%c..%csrc%cscenegraph%csvg_nodes_da.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); @@ -780,16 +795,16 @@ FILE *BeginFile(u32 type) #ifdef LOCAL_SVG_NODES sprintf(sPath, "lsr_tables.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); #else - if (generation_mode == 1) + if (generation_mode == 1) sprintf(sPath, "..%c..%c..%c..%csrc%claser%clsr_tables_sa.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); - else if (generation_mode == 2) + else if (generation_mode == 2) sprintf(sPath, "..%c..%c..%c..%csrc%claser%clsr_tables_sani.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); - else if (generation_mode == 3) + else if (generation_mode == 3) sprintf(sPath, "..%c..%c..%c..%csrc%claser%clsr_tables.c", GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR); #endif } - + f = fopen(sPath, "wt"); fprintf(f, "%s\n", COPYRIGHT); @@ -828,17 +843,17 @@ void EndFile(FILE *f, u32 type) fclose(f); } -void generateAttributes(FILE *output, GF_List *attributes, Bool inDefine) +void generateAttributes(FILE *output, GF_List *attributes, Bool inDefine) { u32 i; for (i = 0; iimpl_type, att->implementation_name); - else + else fprintf(output, "\t%s %s; \\\n", att->impl_type, att->implementation_name); - else + else fprintf(output, "\t%s %s;\n", att->impl_type, att->implementation_name); } } @@ -864,14 +879,14 @@ void replaceIncludes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) { int k; xmlNodeSetPtr nodes; - xmlXPathObjectPtr xpathObj; - - /* Get all the RNG elements */ - xpathObj = xmlXPathEvalExpression("//rng:include", xpathCtx); - if(xpathObj == NULL || xpathObj->type != XPATH_NODESET) return; - - nodes = xpathObj->nodesetval; - + xmlXPathObjectPtr xpathObj; + + /* Get all the RNG elements */ + xpathObj = xmlXPathEvalExpression("//rng:include", xpathCtx); + if(xpathObj == NULL || xpathObj->type != XPATH_NODESET) return; + + nodes = xpathObj->nodesetval; + for (k = 0; k < nodes->nodeNr; k++) { xmlNodePtr node = nodes->nodeTab[k]; if (node->type == XML_ELEMENT_NODE) { @@ -889,31 +904,31 @@ void replaceIncludes(xmlDocPtr doc, xmlXPathContextPtr xpathCtx) int main(int argc, char **argv) { xmlDocPtr doc = NULL; - xmlXPathContextPtr xpathCtx = NULL; + xmlXPathContextPtr xpathCtx = NULL; GF_List *svg_elements = NULL; - xmlInitParser(); + xmlInitParser(); LIBXML_TEST_VERSION doc = xmlParseFile(argv[1]); - if (!doc) { - printf("error: could not parse file %s\n", argv[1]); + if (!doc) { + printf("error: could not parse file %s\n", argv[1]); return -1; - } + } xpathCtx = xmlXPathNewContext(doc); - if(xpathCtx == NULL) { - fprintf(stderr,"Error: unable to create new XPath context\n"); - xmlFreeDoc(doc); - return(-1); - } + if(xpathCtx == NULL) { + fprintf(stderr,"Error: unable to create new XPath context\n"); + xmlFreeDoc(doc); + return(-1); + } xmlXPathRegisterNs(xpathCtx, RNG_PREFIX, RNG_NS); xmlXPathRegisterNs(xpathCtx, RNGA_PREFIX, RNGA_NS); xmlXPathRegisterNs(xpathCtx, SVGA_PREFIX, SVGA_NS); replaceIncludes(doc, xpathCtx); xmlSaveFile("completerng_props.xml", doc); - + globalAttrGrp = gf_list_new(); getAllGlobalAttrGrp(doc, xpathCtx); @@ -928,9 +943,9 @@ int main(int argc, char **argv) if (generation_mode == 3) generateSVGCode_V3(svg_elements); } - xmlXPathFreeContext(xpathCtx); - //xmlFreeDoc(doc); - + xmlXPathFreeContext(xpathCtx); + //xmlFreeDoc(doc); + xmlCleanupParser(); return 0; } diff --git a/applications/generators/SVG/svggen.h b/applications/generators/SVG/svggen.h index fd74a60..a2c97e3 100644 --- a/applications/generators/SVG/svggen.h +++ b/applications/generators/SVG/svggen.h @@ -2,7 +2,7 @@ * GPAC - Multimedia Framework C SDK * * Authors: Cyril Concolato - * Copyright (c) Telecom ParisTech 2004-2012 + * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * * This file is part of GPAC / SVG Scene Graph Generator sub-project @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _SVGGEN_H_ @@ -39,9 +39,9 @@ /* if defined generates .c/.h directly in the appropriate GPAC source folders */ #undef LOCAL_SVG_NODES -/* +/* Modes for generating SVG code - - 1 means static allocation of attributes (including properties, use Tiny-1.2-NG) + - 1 means static allocation of attributes (including properties, use Tiny-1.2-NG) - 2 means static allocation of attributes (only useful properties on nodes, use Tiny-1.2-NG-noproperties) - 3 means dynamic allocation of attributes (including properties) */ @@ -58,8 +58,8 @@ static u32 generation_mode = 3; #define COPYRIGHT "/*\n * GPAC - Multimedia Framework C SDK\n *\n * Authors: Cyril Concolato - Jean Le Feuvre\n * Copyright (c) Telecom ParisTech 2000-2012 - All rights reserved\n *\n * This file is part of GPAC / SVG Scene Graph sub-project\n *\n * GPAC is free software; you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation; either version 2, or (at your option)\n * any later version.\n *\n * GPAC is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details. \n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; see the file COPYING. If not, write to\n * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n *\n */\n" -/* - type declarations +/* + type declarations */ typedef struct @@ -88,12 +88,12 @@ typedef struct } SVGGenElement; typedef struct { - xmlChar *svg_name; + xmlChar *svg_name; char implementation_name[50]; - xmlChar *svg_type; - char impl_type[50]; - u8 animatable; - u8 inheritable; + xmlChar *svg_type; + char impl_type[50]; + u8 animatable; + u8 inheritable; Bool optional; xmlChar *default_value; u32 index; @@ -120,28 +120,28 @@ static char *core[] = { "id", "class", "xml:id", "xml:base", "xml:lang", "xml:sp /* Media Properties */ static char *media_properties[] = { - "audio-level", "display", "image-rendering", "pointer-events", "shape-rendering", "text-rendering", - "viewport-fill", "viewport-fill-opacity", "visibility" + "audio-level", "display", "image-rendering", "pointer-events", "shape-rendering", "text-rendering", + "viewport-fill", "viewport-fill-opacity", "visibility" }; /* others */ static char *other_properties[] = { - "color", "color-rendering", "display-align", "fill", "fill-opacity", "fill-rule", - "font-family", "font-size", "font-style", "font-weight", "line-increment", - "solid-color", "solid-opacity", "stop-color", "stop-opacity", - "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", - "stroke-opacity", "stroke-width", "text-align", "text-anchor", "vector-effect" + "color", "color-rendering", "display-align", "fill", "fill-opacity", "fill-rule", + "font-family", "font-size", "font-style", "font-weight", "line-increment", + "solid-color", "solid-opacity", "stop-color", "stop-opacity", + "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", + "stroke-opacity", "stroke-width", "text-align", "text-anchor", "vector-effect" }; /* only opacity on image */ static char *opacity_properties[] = { - "opacity" + "opacity" }; /* Focus */ -static char *focus[] = { - "focusHighlight", "focusable", "nav-down", "nav-down-left", "nav-down-right", - "nav-left", "nav-next", "nav-prev", "nav-right", "nav-up", "nav-up-left", "nav-up-right" +static char *focus[] = { + "focusHighlight", "focusable", "nav-down", "nav-down-left", "nav-down-right", + "nav-left", "nav-next", "nav-prev", "nav-right", "nav-up", "nav-up-left", "nav-up-right" }; /* Xlink */ diff --git a/applications/generators/SVG/v1.c b/applications/generators/SVG/v1.c index 792a20d..a48bbbd 100644 --- a/applications/generators/SVG/v1.c +++ b/applications/generators/SVG/v1.c @@ -2,7 +2,7 @@ * GPAC - Multimedia Framework C SDK * * Authors: Cyril Concolato - * Copyright (c) Telecom ParisTech 2004-2012 + * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * * This file is part of GPAC / SVG Scene Graph Generator sub-project @@ -11,21 +11,21 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "svggen.h" -void generateNode(FILE *output, SVGGenElement* svg_elt) +void generateNode(FILE *output, SVGGenElement* svg_elt) { fprintf(output, "typedef struct _tagSVG_SA_%sElement\n{\n", svg_elt->implementation_name); @@ -37,7 +37,7 @@ void generateNode(FILE *output, SVGGenElement* svg_elt) if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tSVGCommandBuffer updates;\n"); - } + } generateAttributes(output, svg_elt->attributes, 0); @@ -202,64 +202,64 @@ u32 generateIndexInfo(FILE *output, SVGGenElement *elt, u32 index, u32 start) char *att_name = generic_attributes[index].array[k]; SVGGenAttribute *a = findAttribute(elt, att_name); if (a) { - fprintf(output, "\tif(!strcmp(\"%s\", name)) return %d;\n", att_name, i); + fprintf(output, "\tif(!strcmp(\"%s\", name)) return %d;\n", att_name, i); i++; } } return i; } -void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) +void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) { - u32 i; + u32 i; - /***************************************************/ + /***************************************************/ /* Constructor */ - /***************************************************/ + /***************************************************/ fprintf(output, "void *gf_svg_new_%s()\n{\n\tSVG_SA_%sElement *p;\n", svg_elt->implementation_name,svg_elt->implementation_name); fprintf(output, "\tGF_SAFEALLOC(p, SVG_SA_%sElement);\n\tif (!p) return NULL;\n\tgf_node_setup((GF_Node *)p, TAG_SVG_%s);\n\tgf_sg_parent_setup((GF_Node *) p);\n",svg_elt->implementation_name,svg_elt->implementation_name); - fprintf(output, "\tgf_svg_sa_init_core((SVG_SA_Element *)p);\n"); - if (svg_elt->has_properties || - svg_elt->has_media_properties || - svg_elt->has_opacity_properties) { - fprintf(output, "\tgf_svg_sa_init_properties((SVG_SA_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sa_init_core((SVG_SA_Element *)p);\n"); + if (svg_elt->has_properties || + svg_elt->has_media_properties || + svg_elt->has_opacity_properties) { + fprintf(output, "\tgf_svg_sa_init_properties((SVG_SA_Element *)p);\n"); + } if (svg_elt->has_focus) { - fprintf(output, "\tgf_svg_sa_init_focus((SVG_SA_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sa_init_focus((SVG_SA_Element *)p);\n"); + } if (svg_elt->has_xlink) { - fprintf(output, "\tgf_svg_sa_init_xlink((SVG_SA_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sa_init_xlink((SVG_SA_Element *)p);\n"); + } if (svg_elt->has_timing) { - fprintf(output, "\tgf_svg_sa_init_timing((SVG_SA_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sa_init_timing((SVG_SA_Element *)p);\n"); + } if (svg_elt->has_sync) { - fprintf(output, "\tgf_svg_sa_init_sync((SVG_SA_Element *)p);\n"); + fprintf(output, "\tgf_svg_sa_init_sync((SVG_SA_Element *)p);\n"); + } + if (svg_elt->has_animation) { + fprintf(output, "\tgf_svg_sa_init_anim((SVG_SA_Element *)p);\n"); } - if (svg_elt->has_animation){ - fprintf(output, "\tgf_svg_sa_init_anim((SVG_SA_Element *)p);\n"); - } if (svg_elt->has_conditional) { - fprintf(output, "\tgf_svg_sa_init_conditional((SVG_SA_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sa_init_conditional((SVG_SA_Element *)p);\n"); + } if (svg_elt->has_transform) { fprintf(output, "\tgf_mx2d_init(p->transform.mat);\n"); - } + } if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tgf_svg_sa_init_lsr_conditional(&p->updates);\n"); - fprintf(output, "\tgf_svg_sa_init_timing((SVG_SA_Element *)p);\n"); + fprintf(output, "\tgf_svg_sa_init_timing((SVG_SA_Element *)p);\n"); - } + } for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { SVGGenAttribute *att = gf_list_get(svg_elt->attributes, i); /* Initialization of complex types */ - if ( !strcmp("SVG_Points", att->impl_type) || - !strcmp("SVG_Coordinates", att->impl_type) || - !strcmp("SMIL_KeyPoints", att->impl_type)) { + if ( !strcmp("SVG_Points", att->impl_type) || + !strcmp("SVG_Coordinates", att->impl_type) || + !strcmp("SMIL_KeyPoints", att->impl_type)) { fprintf(output, "\tp->%s = gf_list_new();\n", att->implementation_name); } else if (!strcmp("SVG_PathData", att->impl_type) && !strcmp(svg_elt->svg_name, "animateMotion")) { fprintf(output, "#ifdef USE_GF_PATH\n"); @@ -277,7 +277,7 @@ void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) fprintf(output, "#endif\n"); } else if (!strcmp(att->svg_name, "lsr:enabled")) { fprintf(output, "\tp->lsr_enabled = 1;\n"); - } + } } /*some default values*/ if (!strcmp(svg_elt->svg_name, "svg")) { @@ -309,9 +309,9 @@ void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) } fprintf(output, "\treturn p;\n}\n\n"); - /***************************************************/ + /***************************************************/ /* Destructor */ - /***************************************************/ + /***************************************************/ fprintf(output, "static void gf_svg_sa_%s_del(GF_Node *node)\n{\n", svg_elt->implementation_name); fprintf(output, "\tSVG_SA_%sElement *p = (SVG_SA_%sElement *)node;\n", svg_elt->implementation_name, svg_elt->implementation_name); @@ -319,10 +319,10 @@ void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tgf_svg_sa_reset_lsr_conditional(&p->updates);\n"); - } + } else if (!strcmp(svg_elt->implementation_name, "a")) { fprintf(output, "\tif (p->target) free(p->target);\n"); - } + } for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { SVGGenAttribute *att = gf_list_get(svg_elt->attributes, i); @@ -348,43 +348,43 @@ void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) } if (svg_elt->has_transform) { fprintf(output, "\tif (p->motionTransform) free(p->motionTransform);\n"); - } + } fprintf(output, "\tgf_sg_parent_reset((GF_Node *) p);\n"); fprintf(output, "\tgf_node_free((GF_Node *)p);\n"); fprintf(output, "}\n\n"); - - /***************************************************/ + + /***************************************************/ /* Attribute Access */ - /***************************************************/ + /***************************************************/ fprintf(output, "static GF_Err gf_svg_sa_%s_get_attribute(GF_Node *node, GF_FieldInfo *info)\n{\n", svg_elt->implementation_name); fprintf(output, "\tswitch (info->fieldIndex) {\n"); svg_elt->nb_atts = 0; svg_elt->nb_atts = generateCoreInfo(output, svg_elt, svg_elt->nb_atts); - if (svg_elt->has_media_properties) + if (svg_elt->has_media_properties) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 2, "((SVG_SA_Element *)node)->properties->", svg_elt->nb_atts); - if (svg_elt->has_properties) + if (svg_elt->has_properties) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 1, "((SVG_SA_Element *)node)->properties->", svg_elt->nb_atts); - if (svg_elt->has_opacity_properties) + if (svg_elt->has_opacity_properties) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 3, "((SVG_SA_Element *)node)->properties->", svg_elt->nb_atts); - if (svg_elt->has_focus) + if (svg_elt->has_focus) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 4, "((SVG_SA_Element *)node)->focus->", svg_elt->nb_atts); - if (svg_elt->has_xlink) + if (svg_elt->has_xlink) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 5, "((SVG_SA_Element *)node)->xlink->", svg_elt->nb_atts); - if (svg_elt->has_timing) + if (svg_elt->has_timing) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 6, "((SVG_SA_Element *)node)->timing->", svg_elt->nb_atts); - if (svg_elt->has_sync) + if (svg_elt->has_sync) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 7, "((SVG_SA_Element *)node)->sync->", svg_elt->nb_atts); - if (svg_elt->has_animation) + if (svg_elt->has_animation) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 8, "((SVG_SA_Element *)node)->anim->", svg_elt->nb_atts); - if (svg_elt->has_conditional) + if (svg_elt->has_conditional) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 9, "((SVG_SA_Element *)node)->conditional->", svg_elt->nb_atts); if (svg_elt->has_transform) { svg_elt->nb_atts = generateTransformInfo(output, svg_elt, svg_elt->nb_atts); svg_elt->nb_atts = generateMotionTransformInfo(output, svg_elt, svg_elt->nb_atts); } - if (svg_elt->has_xy) + if (svg_elt->has_xy) svg_elt->nb_atts = generateXYInfo(output, svg_elt, svg_elt->nb_atts); for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { @@ -393,77 +393,77 @@ void generateNodeImpl(FILE *output, SVGGenElement* svg_elt) } fprintf(output, "\t\tdefault: return GF_BAD_PARAM;\n\t}\n}\n\n"); - /***************************************************/ + /***************************************************/ /* gf_svg_sa_%s_get_attribute_index_from_name */ - /***************************************************/ + /***************************************************/ fprintf(output, "s32 gf_svg_sa_%s_get_attribute_index_from_name(char *name)\n{\n", svg_elt->implementation_name); { u32 att_index = 0; - fprintf(output, "\tif(!strcmp(\"id\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"id\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"xml:id\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"xml:id\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"class\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"class\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"xml:lang\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"xml:lang\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"xml:base\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"xml:base\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"xml:space\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"xml:space\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"externalResourcesRequired\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"externalResourcesRequired\", name)) return %d;\n", att_index); att_index++; - if (svg_elt->has_media_properties) + if (svg_elt->has_media_properties) att_index = generateIndexInfo(output, svg_elt, 2, att_index); - if (svg_elt->has_properties) + if (svg_elt->has_properties) att_index = generateIndexInfo(output, svg_elt, 1, att_index); - if (svg_elt->has_opacity_properties) + if (svg_elt->has_opacity_properties) att_index = generateIndexInfo(output, svg_elt, 3, att_index); - if (svg_elt->has_focus) + if (svg_elt->has_focus) att_index = generateIndexInfo(output, svg_elt, 4, att_index); - if (svg_elt->has_xlink) + if (svg_elt->has_xlink) att_index = generateIndexInfo(output, svg_elt, 5, att_index); - if (svg_elt->has_timing) + if (svg_elt->has_timing) att_index = generateIndexInfo(output, svg_elt, 6, att_index); - if (svg_elt->has_sync) + if (svg_elt->has_sync) att_index = generateIndexInfo(output, svg_elt, 7, att_index); - if (svg_elt->has_animation) + if (svg_elt->has_animation) att_index = generateIndexInfo(output, svg_elt, 8, att_index); - if (svg_elt->has_conditional) + if (svg_elt->has_conditional) att_index = generateIndexInfo(output, svg_elt, 9, att_index); if (svg_elt->has_transform) { - fprintf(output, "\tif(!strcmp(\"transform\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"transform\", name)) return %d;\n", att_index); att_index++; /*motionTransform*/ - fprintf(output, "\tif(!strcmp(\"motionTransform\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"motionTransform\", name)) return %d;\n", att_index); att_index++; } if (svg_elt->has_xy) { - fprintf(output, "\tif(!strcmp(\"x\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"x\", name)) return %d;\n", att_index); att_index++; - fprintf(output, "\tif(!strcmp(\"y\", name)) return %d;\n", att_index); + fprintf(output, "\tif(!strcmp(\"y\", name)) return %d;\n", att_index); att_index++; } for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { SVGGenAttribute *att = gf_list_get(svg_elt->attributes, i); - fprintf(output, "\tif(!strcmp(\"%s\", name)) return %d;\n", att->svg_name, att_index); + fprintf(output, "\tif(!strcmp(\"%s\", name)) return %d;\n", att->svg_name, att_index); att_index++; } } fprintf(output, "\treturn -1;\n}\n\n"); } -void generateSVGCode_V1(GF_List *svg_elements) +void generateSVGCode_V1(GF_List *svg_elements) { FILE *output; u32 i; - /***************************************************/ - /***************************************************/ - /*************** Creating .h file ******************/ - /***************************************************/ - /***************************************************/ + /***************************************************/ + /***************************************************/ + /*************** Creating .h file ******************/ + /***************************************************/ + /***************************************************/ output = BeginFile(0); fprintf(output, "#include \n\n\n"); fprintf(output, "/* Definition of SVG element internal tags */\n"); @@ -479,29 +479,29 @@ void generateSVGCode_V1(GF_List *svg_elements) fprintf(output, ",\n\tTAG_SVG_%s", elt->implementation_name); } } - + fprintf(output, ",\n\t/*undefined elements (when parsing) use this tag*/\n\tTAG_SVG_UndefinedElement\n};\n\n"); - + fprintf(output, "/******************************************\n"); - fprintf(output, "* SVG Elements structure definitions *\n"); - fprintf(output, "*******************************************/\n"); + fprintf(output, "* SVG Elements structure definitions *\n"); + fprintf(output, "*******************************************/\n"); for (i=0; i\n\n"); - + fprintf(output, "#ifndef GPAC_DISABLE_SVG\n\n"); fprintf(output, "#include \n\n"); fprintf(output, "#ifdef GPAC_ENABLE_SVG_SA\n\n"); @@ -510,9 +510,9 @@ void generateSVGCode_V1(GF_List *svg_elements) generateNodeImpl(output, elt); } - /***************************************************/ + /***************************************************/ /* SVG_SA_Element *gf_svg_sa_create_node(u32 ElementTag) */ - /***************************************************/ + /***************************************************/ fprintf(output, "SVG_SA_Element *gf_svg_sa_create_node(u32 ElementTag)\n"); fprintf(output, "{\n"); fprintf(output, "\tswitch (ElementTag) {\n"); @@ -521,10 +521,10 @@ void generateSVGCode_V1(GF_List *svg_elements) fprintf(output, "\t\tcase TAG_SVG_%s: return (SVG_SA_Element*) gf_svg_new_%s();\n",elt->implementation_name,elt->implementation_name); } fprintf(output, "\t\tdefault: return NULL;\n\t}\n}\n\n"); - - /***************************************************/ + + /***************************************************/ /* void gf_svg_sa_element_del(SVG_SA_Element *elt) */ - /***************************************************/ + /***************************************************/ fprintf(output, "void gf_svg_sa_element_del(SVG_SA_Element *elt)\n{\n"); fprintf(output, "\tGF_Node *node = (GF_Node *)elt;\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); @@ -534,9 +534,9 @@ void generateSVGCode_V1(GF_List *svg_elements) } fprintf(output, "\t\tdefault: return;\n\t}\n}\n\n"); - /***************************************************/ + /***************************************************/ /* u32 gf_svg_sa_get_attribute_count(SVG_SA_Element *elt) */ - /***************************************************/ + /***************************************************/ fprintf(output, "u32 gf_svg_sa_get_attribute_count(GF_Node *node)\n{\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; iimplementation_name, elt->nb_atts); } fprintf(output, "\t\tdefault: return 0;\n\t}\n}\n\n"); - - /***********************************************************************/ + + /***********************************************************************/ /* GF_Err gf_svg_sa_get_attribute_info(GF_Node *node, GF_FieldInfo *info) */ - /***********************************************************************/ + /***********************************************************************/ fprintf(output, "GF_Err gf_svg_sa_get_attribute_info(GF_Node *node, GF_FieldInfo *info)\n{\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; isgprivate->tag) {\n"); for (i=0; iimplementation_name); @@ -47,7 +47,7 @@ void generateNode2(FILE *output, SVGGenElement* svg_elt) if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tSVGCommandBuffer updates;\n"); - } + } generateAttributes2(output, svg_elt->attributes); @@ -113,47 +113,47 @@ u32 generateXYInfo2(FILE *output, SVGGenElement *elt, u32 start) return i; } -void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) +void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) { - u32 i; + u32 i; /* Constructor */ fprintf(output, "void *gf_svg_sani_new_%s()\n{\n\tSVG_SANI_%sElement *p;\n", svg_elt->implementation_name,svg_elt->implementation_name); fprintf(output, "\tGF_SAFEALLOC(p, SVG_SANI_%sElement);\n\tif (!p) return NULL;\n\tgf_node_setup((GF_Node *)p, TAG_SVG_SANI_%s);\n\tgf_sg_parent_setup((GF_Node *) p);\n",svg_elt->implementation_name,svg_elt->implementation_name); - fprintf(output, "\tgf_svg_sani_init_core((SVG_SANI_Element *)p);\n"); + fprintf(output, "\tgf_svg_sani_init_core((SVG_SANI_Element *)p);\n"); if (svg_elt->has_focus) { - fprintf(output, "\tgf_svg_sani_init_focus((SVG_SANI_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sani_init_focus((SVG_SANI_Element *)p);\n"); + } if (svg_elt->has_xlink) { - fprintf(output, "\tgf_svg_sani_init_xlink((SVG_SANI_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sani_init_xlink((SVG_SANI_Element *)p);\n"); + } if (svg_elt->has_timing) { - fprintf(output, "\tgf_svg_sani_init_timing((SVG_SANI_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sani_init_timing((SVG_SANI_Element *)p);\n"); + } if (svg_elt->has_sync) { - fprintf(output, "\tgf_svg_sani_init_sync((SVG_SANI_Element *)p);\n"); + fprintf(output, "\tgf_svg_sani_init_sync((SVG_SANI_Element *)p);\n"); + } + if (svg_elt->has_animation) { + fprintf(output, "\tgf_svg_sani_init_anim((SVG_SANI_Element *)p);\n"); } - if (svg_elt->has_animation){ - fprintf(output, "\tgf_svg_sani_init_anim((SVG_SANI_Element *)p);\n"); - } if (svg_elt->has_conditional) { - fprintf(output, "\tgf_svg_sani_init_conditional((SVG_SANI_Element *)p);\n"); - } + fprintf(output, "\tgf_svg_sani_init_conditional((SVG_SANI_Element *)p);\n"); + } if (svg_elt->has_transform) { fprintf(output, "\tgf_mx2d_init(p->transform.mat);\n"); - } + } if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tgf_svg_sa_init_lsr_conditional(&p->updates);\n"); - fprintf(output, "\tgf_svg_sani_init_timing((SVG_SANI_Element *)p);\n"); + fprintf(output, "\tgf_svg_sani_init_timing((SVG_SANI_Element *)p);\n"); - } + } for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { SVGGenAttribute *att = gf_list_get(svg_elt->attributes, i); - + /* forcing initialization of old-properties */ if (!strcmp("audio-level", att->svg_name)) { fprintf(output, "\tp->audio_level.type = SVG_NUMBER_VALUE;\n"); @@ -236,9 +236,9 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) } /* Initialization of complex types */ - if ( !strcmp("SVG_Points", att->impl_type) || - !strcmp("SVG_Coordinates", att->impl_type) || - !strcmp("SMIL_KeyPoints", att->impl_type)) { + if ( !strcmp("SVG_Points", att->impl_type) || + !strcmp("SVG_Coordinates", att->impl_type) || + !strcmp("SMIL_KeyPoints", att->impl_type)) { fprintf(output, "\tp->%s = gf_list_new();\n", att->implementation_name); } else if (!strcmp("SVG_PathData", att->impl_type) && !strcmp(svg_elt->svg_name, "animateMotion")) { fprintf(output, "#ifdef USE_GF_PATH\n"); @@ -256,7 +256,7 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) fprintf(output, "#endif\n"); } else if (!strcmp(att->svg_name, "lsr:enabled")) { fprintf(output, "\tp->lsr_enabled = 1;\n"); - } + } } /*some default values*/ if (!strcmp(svg_elt->svg_name, "svg")) { @@ -289,10 +289,10 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) if (!strcmp(svg_elt->implementation_name, "conditional")) { fprintf(output, "\tgf_svg_sa_reset_lsr_conditional(&p->updates);\n"); - } + } else if (!strcmp(svg_elt->implementation_name, "a")) { fprintf(output, "\tif (p->target) free(p->target);\n"); - } + } for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { SVGGenAttribute *att = gf_list_get(svg_elt->attributes, i); @@ -318,7 +318,7 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) } if (svg_elt->has_transform) { fprintf(output, "\tif (p->motionTransform) free(p->motionTransform);\n"); - } + } fprintf(output, "\tgf_sg_parent_reset((GF_Node *) p);\n"); fprintf(output, "\tgf_node_free((GF_Node *)p);\n"); @@ -330,23 +330,23 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) svg_elt->nb_atts = 0; svg_elt->nb_atts = generateCoreInfo(output, svg_elt, svg_elt->nb_atts); - if (svg_elt->has_focus) + if (svg_elt->has_focus) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 4, "((SVG_SANI_Element *)node)->focus->", svg_elt->nb_atts); - if (svg_elt->has_xlink) + if (svg_elt->has_xlink) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 5, "((SVG_SANI_Element *)node)->xlink->", svg_elt->nb_atts); - if (svg_elt->has_timing) + if (svg_elt->has_timing) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 6, "((SVG_SANI_Element *)node)->timing->", svg_elt->nb_atts); - if (svg_elt->has_sync) + if (svg_elt->has_sync) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 7, "((SVG_SANI_Element *)node)->sync->", svg_elt->nb_atts); - if (svg_elt->has_animation) + if (svg_elt->has_animation) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 8, "((SVG_SANI_Element *)node)->anim->", svg_elt->nb_atts); - if (svg_elt->has_conditional) + if (svg_elt->has_conditional) svg_elt->nb_atts = generateGenericInfo(output, svg_elt, 9, "((SVG_SANI_Element *)node)->conditional->", svg_elt->nb_atts); if (svg_elt->has_transform) { svg_elt->nb_atts = generateTransformInfo2(output, svg_elt, svg_elt->nb_atts); svg_elt->nb_atts = generateMotionTransformInfo2(output, svg_elt, svg_elt->nb_atts); } - if (svg_elt->has_xy) + if (svg_elt->has_xy) svg_elt->nb_atts = generateXYInfo2(output, svg_elt, svg_elt->nb_atts); for (i = 0; i < gf_list_count(svg_elt->attributes); i++) { @@ -357,7 +357,7 @@ void generateNodeImpl2(FILE *output, SVGGenElement* svg_elt) } -void generateSVGCode_V2(GF_List *svg_elements) +void generateSVGCode_V2(GF_List *svg_elements) { FILE *output; u32 i; @@ -377,12 +377,12 @@ void generateSVGCode_V2(GF_List *svg_elements) fprintf(output, ",\n\tTAG_SVG_SANI_%s", elt->implementation_name); } } - + fprintf(output, ",\n\t/*undefined elements (when parsing) use this tag*/\n\tTAG_SVG_SANI_UndefinedElement\n};\n\n"); fprintf(output, "/******************************************\n"); - fprintf(output, "* SVG_SANI_ Elements structure definitions *\n"); - fprintf(output, "*******************************************/\n"); + fprintf(output, "* SVG_SANI_ Elements structure definitions *\n"); + fprintf(output, "*******************************************/\n"); for (i=0; iimplementation_name,elt->implementation_name); } fprintf(output, "\t\tdefault: return NULL;\n\t}\n}\n\n"); - + fprintf(output, "void gf_svg_sani_element_del(SVG_SANI_Element *elt)\n{\n"); fprintf(output, "\tGF_Node *node = (GF_Node *)elt;\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); @@ -424,7 +424,7 @@ void generateSVGCode_V2(GF_List *svg_elements) fprintf(output, "\t\tcase TAG_SVG_SANI_%s: return %i;\n", elt->implementation_name, elt->nb_atts); } fprintf(output, "\t\tdefault: return 0;\n\t}\n}\n\n"); - + fprintf(output, "GF_Err gf_svg_sani_get_attribute_info(GF_Node *node, GF_FieldInfo *info)\n{\n"); fprintf(output, "\tswitch (node->sgprivate->tag) {\n"); for (i=0; iimplementation_name, "smil_fill"); } else if (!strcmp(att->impl_type, "SVG_TransformType")) { strcpy(att->implementation_name, "transform_type"); - } + } for (k = 0; k < gf_list_count(all_atts); k++) { SVGGenAttribute *a = gf_list_get(all_atts, k); if (!strcmp(a->implementation_name, att->implementation_name) - && !strcmp(a->impl_type, att->impl_type)) { + && !strcmp(a->impl_type, att->impl_type)) { added = 1; break; } @@ -78,7 +78,7 @@ void buildGlobalAttributeList(GF_List *svg_elements, GF_List *all_atts) for (k = 0; k < gf_list_count(all_atts); k++) { SVGGenAttribute *a = gf_list_get(all_atts, k); if (!strcmp(a->implementation_name, att->implementation_name) - && !strcmp(a->impl_type, att->impl_type)) { + && !strcmp(a->impl_type, att->impl_type)) { added = 1; break; } @@ -86,7 +86,7 @@ void buildGlobalAttributeList(GF_List *svg_elements, GF_List *all_atts) if (!added) { gf_list_add(all_atts, att); } - } + } } /*motionTransform is not parsed in rng*/ { @@ -107,11 +107,11 @@ void generateSVGCode_V3(GF_List *svg_elements) buildGlobalAttributeList(svg_elements, all_atts); - /***************************************************/ - /***************************************************/ - /*************** Creating .h file ******************/ - /***************************************************/ - /***************************************************/ + /***************************************************/ + /***************************************************/ + /*************** Creating .h file ******************/ + /***************************************************/ + /***************************************************/ output = BeginFile(0); fprintf(output, "#include \n\n\n"); @@ -133,7 +133,7 @@ void generateSVGCode_V3(GF_List *svg_elements) fprintf(output, "/* Definition of SVG 3 attribute internal tags - %d defined */\n", gf_list_count(all_atts)); fprintf(output, "/* TAG names are made of \"TAG_SVG_ATT_\" + SVG attribute name (with - replaced by _) */\n"); fprintf(output, "enum {\n"); - + for (i=0; iimplementation_name); @@ -151,33 +151,33 @@ void generateSVGCode_V3(GF_List *svg_elements) EndFile(output, 0); - /***************************************************/ - /***************************************************/ - /*************** Creating .c file ******************/ - /***************************************************/ - /***************************************************/ - output = BeginFile(1); + /***************************************************/ + /***************************************************/ + /*************** Creating .c file ******************/ + /***************************************************/ + /***************************************************/ + output = BeginFile(1); fprintf(output, "#ifndef GPAC_DISABLE_SVG\n\n"); fprintf(output, "#include \n\n"); fprintf(output, "#include \n\n"); - - /****************************************************************/ + + /****************************************************************/ /* u32 gf_svg_get_attribute_tag(u32 element_tag, const char *attribute_name) */ - /****************************************************************/ + /****************************************************************/ fprintf(output, "u32 gf_svg_get_attribute_tag(u32 element_tag, const char *attribute_name)\n{\n\tif (!attribute_name) return TAG_SVG_ATT_Unknown;\n"); for (i=0; iimpl_type, "SMIL_Fill")) continue; - if (!strcmp(att->impl_type, "SVG_ContentType")) continue; - if (!strcmp(att->implementation_name, "text_x")) continue; - if (!strcmp(att->implementation_name, "text_y")) continue; - if (!strcmp(att->implementation_name, "text_rotate")) continue; - if (!strcmp(att->implementation_name, "cursorManager_x")) continue; - if (!strcmp(att->implementation_name, "cursorManager_y")) continue; - + if (!strcmp(att->impl_type, "SMIL_Fill")) continue; + if (!strcmp(att->impl_type, "SVG_ContentType")) continue; + if (!strcmp(att->implementation_name, "text_x")) continue; + if (!strcmp(att->implementation_name, "text_y")) continue; + if (!strcmp(att->implementation_name, "text_rotate")) continue; + if (!strcmp(att->implementation_name, "cursorManager_x")) continue; + if (!strcmp(att->implementation_name, "cursorManager_y")) continue; + if (!strcmp(att->svg_name, "x") || !strcmp(att->svg_name, "y")) { fprintf(output, "\tif (!stricmp(attribute_name, \"%s\")) {\n", att->svg_name); fprintf(output, "\t\tif (element_tag == TAG_SVG_text) return TAG_SVG_ATT_text_%s;\n", att->implementation_name); @@ -205,9 +205,9 @@ void generateSVGCode_V3(GF_List *svg_elements) } fprintf(output, "\treturn TAG_SVG_ATT_Unknown;\n}\n\n"); - /****************************************************************/ + /****************************************************************/ /* u32 gf_svg_get_attribute_type(u32 tag) */ - /****************************************************************/ + /****************************************************************/ fprintf(output, "u32 gf_svg_get_attribute_type(u32 tag)\n{\n"); fprintf(output, "\tswitch(tag) {\n"); for (i=0; iFields); j++) { bf = gf_list_get(n->Fields, j); - + if (!strcmp(bf->name, "addChildren") || !strcmp(bf->name, "removeChildren")) continue; if (strcmp(bf->type, "eventOut") && !strcmp(bf->name, "children")) continue; - if (strstr(bf->familly, "Node")) { - //this is a POINTER to a node + if (strstr(bf->familly, "Node")) { + //this is a POINTER to a node if (strstr(bf->familly, "SF")) { fprintf(f, "\tGF_Node *%s;\t/*%s*/\n", bf->name, bf->type); } else { @@ -273,7 +273,7 @@ void WriteNodesFile(GF_List *BNodes, GF_List *NDTs) } else { fprintf(f, "\t%s %s;\t/*%s*/\n", bf->familly, bf->name, bf->type); } - if (!strcmp(bf->type, "eventIn")) + if (!strcmp(bf->type, "eventIn")) fprintf(f, "\tvoid (*on_%s)(GF_Node *pThis, struct _route *route);\t/*eventInHandler*/\n", bf->name); } fprintf(f, "} X_%s;\n\n\n", n->name); @@ -291,11 +291,11 @@ void WriteNodeFields(FILE *f, X3DNode *n) fprintf(f, "\nstatic u32 %s_get_field_count(GF_Node *node, u8 dummy)\n{\n\treturn %d;\n}\n\n", n->name, gf_list_count(n->Fields)); fprintf(f, "static GF_Err %s_get_field(GF_Node *node, GF_FieldInfo *info)\n{\n\tswitch (info->fieldIndex) {\n", n->name); - for (i=0;iFields); i++) { + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); fprintf(f, "\tcase %d:\n", i); - + fprintf(f, "\t\tinfo->name = \"%s\";\n", bf->name); //skip all eventIn @@ -335,7 +335,7 @@ void WriteNodeFields(FILE *f, X3DNode *n) fprintf(f, "\tdefault:\n\t\treturn GF_BAD_PARAM;\n\t}\n}\n\n"); fprintf(f, "\nstatic s32 %s_get_field_index_by_name(char *name)\n{\n", n->name); - for (i=0;iFields); i++) { + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); fprintf(f, "\tif (!strcmp(\"%s\", name)) return %d;\n", bf->name, i); } @@ -367,42 +367,42 @@ void WriteNodeCode(GF_List *BNodes, FILE *vrml_code) //nothing on child events if (!strcmp(bf->name, "addChildren")) continue; if (!strcmp(bf->name, "removeChildren")) continue; - + //delete all children node if (strcmp(bf->type, "eventOut") && !strcmp(bf->name, "children")) { is_parent = 1; continue; } - //delete ALL fields that must be deleted: this includes eventIn and out since + //delete ALL fields that must be deleted: this includes eventIn and out since //all fields are defined in the node if (!strcmp(bf->familly, "MFInt") - || !strcmp(bf->familly, "MFFloat") - || !strcmp(bf->familly, "MFDouble") - || !strcmp(bf->familly, "MFBool") - || !strcmp(bf->familly, "MFInt32") - || !strcmp(bf->familly, "MFColor") - || !strcmp(bf->familly, "MFRotation") - || !strcmp(bf->familly, "MFString") - || !strcmp(bf->familly, "MFTime") - || !strcmp(bf->familly, "MFVec2f") - || !strcmp(bf->familly, "MFVec3f") - || !strcmp(bf->familly, "MFVec4f") - || !strcmp(bf->familly, "MFVec2d") - || !strcmp(bf->familly, "MFVec3d") - || !strcmp(bf->familly, "MFURL") - || !strcmp(bf->familly, "MFScript") - || !strcmp(bf->familly, "SFString") - || !strcmp(bf->familly, "SFURL") - || !strcmp(bf->familly, "SFImage") - - ) { + || !strcmp(bf->familly, "MFFloat") + || !strcmp(bf->familly, "MFDouble") + || !strcmp(bf->familly, "MFBool") + || !strcmp(bf->familly, "MFInt32") + || !strcmp(bf->familly, "MFColor") + || !strcmp(bf->familly, "MFRotation") + || !strcmp(bf->familly, "MFString") + || !strcmp(bf->familly, "MFTime") + || !strcmp(bf->familly, "MFVec2f") + || !strcmp(bf->familly, "MFVec3f") + || !strcmp(bf->familly, "MFVec4f") + || !strcmp(bf->familly, "MFVec2d") + || !strcmp(bf->familly, "MFVec3d") + || !strcmp(bf->familly, "MFURL") + || !strcmp(bf->familly, "MFScript") + || !strcmp(bf->familly, "SFString") + || !strcmp(bf->familly, "SFURL") + || !strcmp(bf->familly, "SFImage") + + ) { char szName[500]; strcpy(szName, bf->familly); strlwr(szName); fprintf(vrml_code, "\tgf_sg_%s_del(p->%s);\n", szName, bf->name); - } else if (strstr(bf->familly, "Node")) { - //this is a POINTER to a node + } else if (strstr(bf->familly, "Node")) { + //this is a POINTER to a node if (strstr(bf->familly, "SF")) { fprintf(vrml_code, "\tgf_node_unregister((GF_Node *) p->%s, node);\t\n", bf->name); } else { @@ -434,8 +434,8 @@ void WriteNodeCode(GF_List *BNodes, FILE *vrml_code) fprintf(vrml_code, "\tgf_sg_vrml_parent_setup((GF_Node *) p);\n"); break; } - else if ( strstr(bf->familly, "Node") && strncmp(bf->type, "event", 5) ) { - //this is a POINTER to a node + else if ( strstr(bf->familly, "Node") && strncmp(bf->type, "event", 5) ) { + //this is a POINTER to a node if (strstr(bf->familly, "MF")) { //this is a POINTER to a chain //fprintf(vrml_code, "\tp->%s = gf_list_new();\t\n", bf->name); @@ -448,7 +448,7 @@ void WriteNodeCode(GF_List *BNodes, FILE *vrml_code) } fprintf(vrml_code, "\n\t/*default field values*/\n"); - + for (i=0; iFields); i++) { bf = gf_list_get(n->Fields, i); @@ -461,14 +461,14 @@ void WriteNodeCode(GF_List *BNodes, FILE *vrml_code) //no default on nodes if (strstr(bf->familly, "Node")) continue; //extract default falue - + // // SF Fields // - + //SFBool if (!strcmp(bf->familly, "SFBool")) { - if (!strcmp(bf->def, "1") || !strcmp(bf->def, "TRUE")) + if (!strcmp(bf->def, "1") || !strcmp(bf->def, "TRUE")) fprintf(vrml_code, "\tp->%s = 1;\n", bf->name); } //SFFloat @@ -569,7 +569,7 @@ void WriteNodeCode(GF_List *BNodes, FILE *vrml_code) fprintf(vrml_code, "\tp->%s.buffer = (char*) gf_malloc(sizeof(char) * %d);\n", bf->name, strlen(bf->def)+1); fprintf(vrml_code, "\tstrcpy(p->%s.buffer, \"%s\");\n", bf->name, bf->def); } - + // // MF Fields // @@ -947,7 +947,7 @@ void WriteNDT(FILE *f, GF_List *XNodes, GF_List *NDTs) NDTName = gf_list_get(NDTs, i); count = GetNDTCount(NDTName, XNodes); if (!count) continue; - + fprintf(f, "#define %s_X3D_Count\t%d\n", NDTName, count); fprintf(f, "static const u32 %s_X3D_TypeToTag[%d] = {\n", NDTName, count); first = 1; @@ -955,7 +955,7 @@ void WriteNDT(FILE *f, GF_List *XNodes, GF_List *NDTs) for (j=0; jname); first = 0; @@ -1000,7 +1000,7 @@ void ParseTemplateFile(FILE *nodes, GF_List *BNodes, GF_List *NDTs) if (sLine[0] == '\n') continue; CurrentLine = sLine; - + //parse the line till end of line while (GetNextToken(token, " \t")) { @@ -1042,7 +1042,7 @@ void ParseTemplateFile(FILE *nodes, GF_List *BNodes, GF_List *NDTs) } f = BlankField(); gf_list_add(n->Fields, f); - + //get the field type strcpy(f->type, token); GetNextToken(f->familly, " \t"); @@ -1167,7 +1167,7 @@ void parse_profile(GF_List *nodes, FILE *prof) //skip comment and empty lines if (sLine[0] == '#') continue; if (sLine[0] == '\n') continue; - if (strstr(sLine, "Proximity")) + if (strstr(sLine, "Proximity")) found = 0; found = 1; while (found) { @@ -1228,12 +1228,12 @@ int main (int argc, char **argv) fclose(pf); } } - + //write the nodes def WriteNodesFile(XNodes, NDTs); nodes = BeginFile(1); - + //write all nodes init stuff WriteNodeCode(XNodes, nodes); diff --git a/applications/m3u82mpd/main.c b/applications/m3u82mpd/main.c index b64442f..5621030 100644 --- a/applications/m3u82mpd/main.c +++ b/applications/m3u82mpd/main.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Copyright (c) Telecom ParisTech 2010 - + * Copyright (c) Telecom ParisTech 2010 - * All rights reserved * * This file is part of GPAC / m3u82mpd application @@ -10,15 +10,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -57,16 +57,16 @@ int main(int argc, char **argv) e = parse_root_playlist(m3u8_local_name, &pl, "."); if (e != GF_OK) return -1; - + fmpd = fopen(argv[2], "wt"); - + fprintf(fmpd, "\n"); fprintf(fmpd, " \n"); fprintf(fmpd, " Media Presentation Description for file %s\n", url); fprintf(fmpd, " Generated by GPAC %s\n", GPAC_FULL_VERSION); fprintf(fmpd, " \n"); - fprintf(fmpd, " \n"); + fprintf(fmpd, " \n"); count = gf_list_count(pl->programs); for (i=0; i\n"); - fprintf(fmpd, " durationInfo); - if (baseURL[0]) fprintf(fmpd, "baseURL=\"%s\"", baseURL); - fprintf(fmpd, ">\n"); + fprintf(fmpd, " \n"); + fprintf(fmpd, " durationInfo); + if (baseURL[0]) fprintf(fmpd, "baseURL=\"%s\"", baseURL); + fprintf(fmpd, ">\n"); count3 = gf_list_count(pe->element.playlist.elements); update_interval = (count3 - 1) * pe->durationInfo * 1000; for (k=0; kelement.playlist.elements, k); - if (k) fprintf(fmpd, " \n", elt->url); - else fprintf(fmpd, " \n", elt->url); + if (k) fprintf(fmpd, " \n", elt->url); + else fprintf(fmpd, " \n", elt->url); } fprintf(fmpd, " \n"); fprintf(fmpd, " \n"); diff --git a/applications/mp42avi/main.c b/applications/mp42avi/main.c index 0089f0f..06403bf 100644 --- a/applications/mp42avi/main.c +++ b/applications/mp42avi/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,16 +34,16 @@ #define GPAC_CFG_FILE "GPAC.cfg" #else #include -typedef struct tagBITMAPFILEHEADER +typedef struct tagBITMAPFILEHEADER { - u16 bfType; - u32 bfSize; - u16 bfReserved1; - u16 bfReserved2; - u32 bfOffBits; + u16 bfType; + u32 bfSize; + u16 bfReserved1; + u16 bfReserved2; + u32 bfOffBits; } BITMAPFILEHEADER; -typedef struct tagBITMAPINFOHEADER{ +typedef struct tagBITMAPINFOHEADER { u32 biSize; s32 biWidth; s32 biHeight; @@ -73,26 +73,26 @@ void PrintVersion() void PrintUsage() { printf ("MP42AVI [option] input\n" - "Dumps BIFS media frames as AVI, BMP or raw\n\n" - "Options\n" - "-fps Framerate: specifies extraction framerate - if not set computed from track length\n" - "-size WxH: forces output BIFS to the given resolution\n" - "-raw [frame]: uses raw format for output - only dumps one frame if specified\n" - "-bmp [frame]: uses BMP format for output - only dumps one frame if specified\n" - "-outpath path: specifies where to dump frames/movie\n" - "\n" - "Note: when dumping a frame, either the frame number can be specified or the frame time\n" - "in the format hh:mm:ss:xFz where hh, mm, ss are hours, minutes, seconds, x the number\n" - "of the frame in the seconds and z the frame rate used to express the time\n" - "\n" - "-cfg: specifies path to GPAC config file (GPAC.cfg)\n" - "-v: prints version\n" - "-h: prints this message\n" - "\nWritten by Jean Le Feuvre - (c) 2000-2005\n"); + "Dumps BIFS media frames as AVI, BMP or raw\n\n" + "Options\n" + "-fps Framerate: specifies extraction framerate - if not set computed from track length\n" + "-size WxH: forces output BIFS to the given resolution\n" + "-raw [frame]: uses raw format for output - only dumps one frame if specified\n" + "-bmp [frame]: uses BMP format for output - only dumps one frame if specified\n" + "-outpath path: specifies where to dump frames/movie\n" + "\n" + "Note: when dumping a frame, either the frame number can be specified or the frame time\n" + "in the format hh:mm:ss:xFz where hh, mm, ss are hours, minutes, seconds, x the number\n" + "of the frame in the seconds and z the frame rate used to express the time\n" + "\n" + "-cfg: specifies path to GPAC config file (GPAC.cfg)\n" + "-v: prints version\n" + "-h: prints this message\n" + "\nWritten by Jean Le Feuvre - (c) 2000-2005\n"); } -typedef struct +typedef struct { GF_Compositor *sr; GF_SceneGraph *sg; @@ -165,18 +165,18 @@ void write_bmp(GF_VideoSurface *fb, char *rad_name, u32 img_num) fi.biSizeImage = fb->pitch * fb->height; /*NOT ALIGNED!!*/ - gf_fwrite(&fh.bfType, 2, 1, fout); - gf_fwrite(&fh.bfSize, 4, 1, fout); - gf_fwrite(&fh.bfReserved1, 2, 1, fout); - gf_fwrite(&fh.bfReserved2, 2, 1, fout); - gf_fwrite(&fh.bfOffBits, 4, 1, fout); + gf_fwrite(&fh.bfType, 2, 1, fout); + gf_fwrite(&fh.bfSize, 4, 1, fout); + gf_fwrite(&fh.bfReserved1, 2, 1, fout); + gf_fwrite(&fh.bfReserved2, 2, 1, fout); + gf_fwrite(&fh.bfOffBits, 4, 1, fout); gf_fwrite(&fi, 1, 40, fout); for (j=fb->height; j>0; j--) { ptr = fb->video_buffer + (j-1)*fb->pitch; //gf_fwrite(ptr, 1, fb->width * 3, fout); - for (i=0;iwidth; i++) { + for (i=0; iwidth; i++) { fputc(ptr[2], fout); fputc(ptr[1], fout); fputc(ptr[0], fout); @@ -295,7 +295,7 @@ void bifs3d_viewpoints_merger(GF_ISOFile *file, char *szConfigFile, u32 width, u b2v.sr = gf_sc_new(&user, 0, NULL); gf_sc_set_option(b2v.sr, GF_OPT_VISIBLE, 0); - /* Initialization of the scene graph */ + /* Initialization of the scene graph */ b2v.sg = gf_sg_new(); gf_sg_set_scene_time_callback(b2v.sg, get_scene_time, &b2v); gf_sg_set_init_callback(b2v.sg, node_init, &b2v); @@ -343,7 +343,7 @@ void bifs3d_viewpoints_merger(GF_ISOFile *file, char *szConfigFile, u32 width, u b2v.duration = gf_isom_get_media_duration(file, track_number+1); gf_odf_desc_del((GF_Descriptor *) esd); - + } gf_sc_set_scene(b2v.sr, b2v.sg); @@ -398,7 +398,7 @@ void bifs3d_viewpoints_merger(GF_ISOFile *file, char *szConfigFile, u32 width, u for (y=0; y [options]\n" - "\n" - "Inputs:\n" - "-prog filename specifies an input file used for a TS service\n" - " * currently only supports ISO files and SDP files\n" - " * can be used several times, once for each program\n" - "\n" - "Destinations:\n" - "Several destinations may be specified as follows, at least one is mandatory\n" - "-dst-udp UDP_address:port (multicast or unicast)\n" - "-dst-rtp RTP_address:port\n" - "-dst-file filename\n" - "The following parameters may be specified when -dst-file is used\n" - "-segment-dir dir server local directory to store segments (ends with a '/')\n" - "-segment-duration dur segment duration in seconds\n" - "-segment-manifest file m3u8 file basename\n" - "-segment-http-prefix p client address for accessing server segments\n" - "-segment-number n number of segments to list in the manifest\n" - "\n" - "Basic options:\n" - "-rate R specifies target rate in kbps of the multiplex (optional)\n" - "-real-time specifies the muxer will work in real-time mode\n" - " * if not specified, the muxer will generate the TS as quickly as possible\n" - " * automatically set for SDP or BT input\n" - "-pcr-init V sets initial value V for PCR - if not set, random value is used\n" - "-pcr-offset V offsets all timestamps from PCR by V, in 90kHz. Default value: %d\n" - "-psi-rate V sets PSI refresh rate V in ms (default 100ms).\n" - " * If 0, PSI data is only send once at the begining or before each IDR when -rap option is set.\n" - " * This should be set to 0 for DASH streams.\n" - "-time n request the muxer to stop after n ms\n" - "-single-au forces 1 PES = 1 AU (disabled by default)\n" - "-rap forces RAP/IDR to be aligned with PES start for video streams (disabled by default)\n" - " in this mode, PAT, PMT and PCR will be inserted before the first TS packet of the RAP PES\n" - "-flush-rap same as -rap but flushes all other streams (sends remaining PES packets) before inserting PAT/PMT\n" - "-nb-pack N specifies to pack N TS packets together before sending on network or writing to file\n" - "-ttl N specifies Time-To-Live for multicast. Default is 1.\n" - "-ifce IPIFCE specifies default IP interface to use. Default is IF_ANY.\n" - "-temi [URL] Inserts TEMI time codes in adaptation field. URL is optionnal\n" - "-temi-delay DelayMS Specifies delay between two TEMI url descriptors\n" - "\n" - "MPEG-4/T-DMB options:\n" - "-src filename update file: must be either an .sdp or a .bt file\n" - "-audio url may be mp3/udp or aac/http (shoutcast/icecast)\n" - "-video url shall be a raw h264 frame\n" - "-mpeg4-carousel n carousel period in ms\n" - "-mpeg4 or -4on2 forces usage of MPEG-4 signaling (IOD and SL Config)\n" - "-4over2 same as -4on2 and uses PMT to carry OD Updates\n" - "-bifs-pes carries BIFS over PES instead of sections\n" - "-bifs-pes-ex carries BIFS over PES without writing timestamps in SL\n" - "\n" - "Misc options\n" + "\n" + "Inputs:\n" + "-src filename[:OPTS] specifies an input file used for a TS service\n" + " * currently only supports ISO files and SDP files\n" + " * can be used several times, once for each program\n" + "By default each source is a program in a TS. \n" + "Source options are colon-separated list of options, as follows:\n" + "ID=N specifies the program ID for this source.\n" + " All sources with the same ID will be added to the same program\n" + "name=STR program name, as used in DVB service description table\n" + "provider=STR provider name, as used in DVB service description table\n" + + "\n" + "-prog filename same as -src filename\n" + "\n" + "Destinations:\n" + "Several destinations may be specified as follows, at least one is mandatory\n" + "-dst-udp UDP_address:port (multicast or unicast)\n" + "-dst-rtp RTP_address:port\n" + "-dst-file filename\n" + "The following parameters may be specified when -dst-file is used\n" + "-segment-dir dir server local directory to store segments (ends with a '/')\n" + "-segment-duration dur segment duration in seconds\n" + "-segment-manifest file m3u8 file basename\n" + "-segment-http-prefix p client address for accessing server segments\n" + "-segment-number n number of segments to list in the manifest\n" + "\n" + "Basic options:\n" + "-rate R specifies target rate in kbps of the multiplex (optional)\n" + "-real-time specifies the muxer will work in real-time mode\n" + " * if not specified, the muxer will generate the TS as quickly as possible\n" + " * automatically set for SDP or BT input\n" + "-pcr-init V sets initial value V for PCR - if not set, random value is used\n" + "-pcr-offset V offsets all timestamps from PCR by V, in 90kHz. Default value is computed based on input media.\n" + "-psi-rate V sets PSI refresh rate V in ms (default 100ms).\n" + " * If 0, PSI data is only send once at the begining or before each IDR when -rap option is set.\n" + " * This should be set to 0 for DASH streams.\n" + "-time n request the muxer to stop after n ms\n" + "-single-au forces 1 PES = 1 AU (disabled by default)\n" + "-rap forces RAP/IDR to be aligned with PES start for video streams (disabled by default)\n" + " in this mode, PAT, PMT and PCR will be inserted before the first TS packet of the RAP PES\n" + "-flush-rap same as -rap but flushes all other streams (sends remaining PES packets) before inserting PAT/PMT\n" + "-nb-pack N specifies to pack N TS packets together before sending on network or writing to file\n" + "-pcr-ms N sets max interval in ms between 2 PCR. Default is 100 ms\n" + "-ttl N specifies Time-To-Live for multicast. Default is 1.\n" + "-ifce IPIFCE specifies default IP interface to use. Default is IF_ANY.\n" + "-temi [URL] Inserts TEMI time codes in adaptation field. URL is optionnal\n" + "-temi-delay DelayMS Specifies delay between two TEMI url descriptors\n" + "-sdt-rate MS Gives the SDT carrousel rate in milliseconds. If 0 (default), SDT is not sent\n" + "\n" + "MPEG-4/T-DMB options:\n" + "-bifs-src filename update file: must be either an .sdp or a .bt file\n" + "-audio url may be mp3/udp or aac/http (shoutcast/icecast)\n" + "-video url shall be a raw h264 frame\n" + "-mpeg4-carousel n carousel period in ms\n" + "-mpeg4 or -4on2 forces usage of MPEG-4 signaling (IOD and SL Config)\n" + "-4over2 same as -4on2 and uses PMT to carry OD Updates\n" + "-bifs-pes carries BIFS over PES instead of sections\n" + "-bifs-pes-ex carries BIFS over PES without writing timestamps in SL\n" + "\n" + "Misc options\n" #ifdef GPAC_MEMORY_TRACKING - "-mem-track enables memory tracker\n" + "-mem-track enables memory tracker\n" #endif - "-logs set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" - "-h or -help print this screen\n" - "\n", DEFAULT_PCR_OFFSET - ); + "-logs set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" + "-h or -help print this screen\n" + "\n" + ); } @@ -148,7 +157,7 @@ typedef struct GF_SceneEngine *seng; #endif GF_Thread *th; - char *src_name; + char *bifs_src_name; u32 rate; Bool repeat; u32 mpeg4_signaling; @@ -158,8 +167,15 @@ typedef struct Bool real_time; GF_List *od_updates; + u32 max_sample_size; + + char program_name[20]; + char provider_name[20]; + u32 ID; + Bool is_not_program_declaration; + Double last_ntp; -} M2TSProgram; +} M2TSSource; typedef struct { @@ -176,7 +192,7 @@ typedef struct Bool loop; Bool is_repeat; s64 ts_offset; - M2TSProgram *prog; + M2TSSource *source; const char *temi_url; u32 last_temi_url; @@ -243,7 +259,7 @@ static u32 format_af_descriptor(char *af_data, u64 timecode, u32 timescale, u64 gf_bs_write_int(bs, 0, 1); //is_announcement gf_bs_write_int(bs, 0, 1); //splicing_flag gf_bs_write_int(bs, strlen(temi_url) ? 0 : 1, 1); //external_url - gf_bs_write_int(bs, 0, 1); //use_base_temi_url + gf_bs_write_int(bs, 0, 1); //use_base_temi_url gf_bs_write_int(bs, 0xFF, 3); //reserved gf_bs_write_int(bs, 0, 8); //timeline_id @@ -288,7 +304,7 @@ static u32 format_af_descriptor(char *af_data, u64 timecode, u32 timescale, u64 gf_bs_write_int(bs, 0, 8); //timeline_id if (timescale) { gf_bs_write_u32(bs, timescale); //timescale - if (timecode > 0xFFFFFFUL) + if (timecode > 0xFFFFFFUL) gf_bs_write_u64(bs, timecode); //timestamp else gf_bs_write_u32(bs, (u32) timecode); //timestamp @@ -315,7 +331,7 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) #ifndef GPAC_DISABLE_TTXT GF_List *cues = NULL; #endif - if (!priv->sample) + if (!priv->sample) priv->sample = gf_isom_get_sample(priv->mp4, priv->track, priv->sample_number+1, NULL); if (!priv->sample) { @@ -338,8 +354,8 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) pck.cts += priv->nb_repeat_last*ifce->timescale * priv->image_repeat_ms / 1000; } + pck.dts = pck.cts; if (priv->sample->CTS_Offset) { - pck.dts = pck.cts; pck.cts += priv->sample->CTS_Offset; pck.flags |= GF_ESI_DATA_HAS_DTS; } @@ -363,7 +379,7 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) start = (priv->sample->DTS * 1000) / ifce->timescale; cues = gf_webvtt_parse_iso_cues(priv->sample, start); if (gf_list_count(cues)>1) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] More than one cue in sample\n")); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] More than one cue in sample\n")); } cue = (GF_WebVTTCue *)gf_list_get(cues, 0); if (cue) { @@ -373,7 +389,7 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) pck.data = NULL; pck.data_len = 0; } - } + } #endif ifce->output_ctrl(ifce, GF_ESI_OUTPUT_DATA_DISPATCH, &pck); GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] Track %d: sample %d CTS %d\n", priv->track, priv->sample_number+1, pck.cts)); @@ -392,9 +408,9 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) gf_isom_sample_del(&priv->sample); priv->sample_number++; - if (!priv->prog->real_time && !priv->is_repeat) { - priv->prog->samples_done++; - gf_set_progress("Converting to MPEG-2 TS", priv->prog->samples_done, priv->prog->samples_count); + if (!priv->source->real_time && !priv->is_repeat) { + priv->source->samples_done++; + gf_set_progress("Converting to MPEG-2 TS", priv->source->samples_done, priv->source->samples_count); } if (priv->sample_number==priv->sample_count) { @@ -409,7 +425,7 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) priv->sample_number = 0; priv->is_repeat = (priv->sample_count==1) ? 1 : 0; } - else if (priv->image_repeat_ms && priv->prog->nb_real_streams) { + else if (priv->image_repeat_ms && priv->source->nb_real_streams) { priv->nb_repeat_last++; priv->sample_number--; priv->is_repeat = 1; @@ -417,14 +433,14 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) if (!(ifce->caps & GF_ESI_STREAM_IS_OVER)) { ifce->caps |= GF_ESI_STREAM_IS_OVER; if (priv->sample_count>1) { - assert(priv->prog->nb_real_streams); - priv->prog->nb_real_streams--; + assert(priv->source->nb_real_streams); + priv->source->nb_real_streams--; } } } } } - return GF_OK; + return GF_OK; case GF_ESI_INPUT_DESTROY: if (priv->dsi) gf_free(priv->dsi); @@ -440,7 +456,7 @@ static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) } } -static void fill_isom_es_ifce(M2TSProgram *prog, GF_ESInterface *ifce, GF_ISOFile *mp4, u32 track_num, u32 bifs_use_pes) +static void fill_isom_es_ifce(M2TSSource *source, GF_ESInterface *ifce, GF_ISOFile *mp4, u32 track_num, u32 bifs_use_pes, Bool compute_max_size) { GF_ESIMP4 *priv; char _lan[4]; @@ -455,13 +471,13 @@ static void fill_isom_es_ifce(M2TSProgram *prog, GF_ESInterface *ifce, GF_ISOFil priv->track = track_num; priv->mtype = gf_isom_get_media_type(priv->mp4, priv->track); priv->mstype = gf_isom_get_media_subtype(priv->mp4, priv->track, 1); - priv->loop = prog->real_time ? 1 : 0; + priv->loop = source->real_time ? 1 : 0; priv->sample_count = gf_isom_get_sample_count(mp4, track_num); - prog->samples_count += priv->sample_count; + source->samples_count += priv->sample_count; if (priv->sample_count>1) - prog->nb_real_streams++; + source->nb_real_streams++; - priv->prog = prog; + priv->source = source; memset(ifce, 0, sizeof(GF_ESInterface)); ifce->stream_id = gf_isom_get_track_id(mp4, track_num); @@ -530,7 +546,7 @@ static void fill_isom_es_ifce(M2TSProgram *prog, GF_ESInterface *ifce, GF_ISOFil ifce->sl_config->timestampLength = 0; ifce->sl_config->timestampResolution = 90000; } - + #ifdef GPAC_DISABLE_ISOM_WRITE fprintf(stderr, "Warning: GPAC was compiled without ISOM Write support, can't set SL Config!\n"); #else @@ -538,10 +554,10 @@ static void fill_isom_es_ifce(M2TSProgram *prog, GF_ESInterface *ifce, GF_ISOFil #endif ifce->input_ctrl = mp4_input_ctrl; - if (priv != ifce->input_udta){ - if (ifce->input_udta) - gf_free(ifce->input_udta); - ifce->input_udta = priv; + if (priv != ifce->input_udta) { + if (ifce->input_udta) + gf_free(ifce->input_udta); + ifce->input_udta = priv; } @@ -556,6 +572,16 @@ static void fill_isom_es_ifce(M2TSProgram *prog, GF_ESInterface *ifce, GF_ISOFil else { ifce->depends_on_stream = 0; } + + source->max_sample_size = 0; + if (compute_max_size) { + u32 i; + for (i=0; i < priv->sample_count; i++) { + u32 s = gf_isom_get_sample_size(mp4, track_num, i+1); + if (s>source->max_sample_size) source->max_sample_size = s; + } + } + } @@ -565,7 +591,7 @@ static GF_Err seng_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) if (act_type==GF_ESI_INPUT_DESTROY) { //TODO: free my data if (ifce->input_udta) - gf_free(ifce->input_udta); + gf_free(ifce->input_udta); ifce->input_udta = NULL; return GF_OK; } @@ -597,7 +623,7 @@ typedef struct s64 ts_offset; Bool rtcp_init; - M2TSProgram *prog; + M2TSSource *source; u32 min_dts_inc; u64 prev_cts; @@ -628,11 +654,11 @@ static GF_Err rtp_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) if (has_sr && !rtp->rtcp_init) { Double time = rtp->rtp_ch->last_SR_NTP_sec; time += ((Double)rtp->rtp_ch->last_SR_NTP_frac)/0xFFFFFFFF; - if (!rtp->prog->last_ntp) { - rtp->prog->last_ntp = time; + if (!rtp->source->last_ntp) { + rtp->source->last_ntp = time; } - if (time >= rtp->prog->last_ntp) { - time -= rtp->prog->last_ntp; + if (time >= rtp->source->last_ntp) { + time -= rtp->source->last_ntp; } else { time = 0; } @@ -753,7 +779,7 @@ static void rtp_sl_packet_cbk(void *udta, char *payload, u32 size, GF_SLHeader * } } -static void fill_rtp_es_ifce(GF_ESInterface *ifce, GF_SDPMedia *media, GF_SDPInfo *sdp, M2TSProgram *prog) +static void fill_rtp_es_ifce(GF_ESInterface *ifce, GF_SDPMedia *media, GF_SDPInfo *sdp, M2TSSource *source) { u32 i; GF_Err e; @@ -808,7 +834,7 @@ static void fill_rtp_es_ifce(GF_ESInterface *ifce, GF_SDPMedia *media, GF_SDPInf ifce->input_udta = rtp; ifce->input_ctrl = rtp_input_ctrl; rtp->ifce = ifce; - rtp->prog = prog; + rtp->source = source; ifce->object_type_indication = rtp->depacketizer->sl_map.ObjectTypeIndication; ifce->stream_type = rtp->depacketizer->sl_map.StreamType; @@ -822,31 +848,31 @@ static void fill_rtp_es_ifce(GF_ESInterface *ifce, GF_SDPMedia *media, GF_SDPInf case GPAC_OTI_VIDEO_SVC: rtp->is_264 = 1; rtp->depacketizer->flags |= GF_RTP_AVC_USE_ANNEX_B; - { + { #ifndef GPAC_DISABLE_AV_PARSERS - GF_AVCConfig *avccfg = gf_odf_avc_cfg_read(rtp->depacketizer->sl_map.config, rtp->depacketizer->sl_map.configSize); - if (avccfg) { - GF_AVCConfigSlot *slc; - u32 i; - GF_BitStream *bs; - - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - for (i=0; isequenceParameterSets);i++) { - slc = gf_list_get(avccfg->sequenceParameterSets, i); - gf_bs_write_u32(bs, 1); - gf_bs_write_data(bs, slc->data, slc->size); - } - for (i=0; ipictureParameterSets);i++) { - slc = gf_list_get(avccfg->pictureParameterSets, i); - gf_bs_write_u32(bs, 1); - gf_bs_write_data(bs, slc->data, slc->size); + GF_AVCConfig *avccfg = gf_odf_avc_cfg_read(rtp->depacketizer->sl_map.config, rtp->depacketizer->sl_map.configSize); + if (avccfg) { + GF_AVCConfigSlot *slc; + u32 i; + GF_BitStream *bs; + + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + for (i=0; isequenceParameterSets); i++) { + slc = gf_list_get(avccfg->sequenceParameterSets, i); + gf_bs_write_u32(bs, 1); + gf_bs_write_data(bs, slc->data, slc->size); + } + for (i=0; ipictureParameterSets); i++) { + slc = gf_list_get(avccfg->pictureParameterSets, i); + gf_bs_write_u32(bs, 1); + gf_bs_write_data(bs, slc->data, slc->size); + } + gf_bs_get_content(bs, (char **) &rtp->dsi_and_rap, &rtp->avc_dsi_size); + gf_bs_del(bs); } - gf_bs_get_content(bs, (char **) &rtp->dsi_and_rap, &rtp->avc_dsi_size); - gf_bs_del(bs); - } - gf_odf_avc_cfg_del(avccfg); + gf_odf_avc_cfg_del(avccfg); #endif - } + } break; case GPAC_OTI_AUDIO_AAC_MPEG4: ifce->decoder_config = gf_malloc(sizeof(char) * rtp->depacketizer->sl_map.configSize); @@ -885,12 +911,12 @@ static GF_Err void_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) void *audio_prog = NULL; static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, u64 ts); #define DONT_USE_TERMINAL_MODULE_API -#include "../../modules/aac_in/aac_in.c" +#include "../../modules/aac_in/aac_in.c" AACReader *aac_reader = NULL; u64 audio_discontinuity_offset = 0; /*create an OD codec and encode the descriptor*/ -static GF_Err encode_audio_desc(GF_ESD *esd, GF_SimpleDataDescriptor *audio_desc) +static GF_Err encode_audio_desc(GF_ESD *esd, GF_SimpleDataDescriptor *audio_desc) { GF_Err e; GF_ODCodec *odc = gf_odf_codec_new(); @@ -931,12 +957,12 @@ static GF_Err encode_audio_desc(GF_ESD *esd, GF_SimpleDataDescriptor *audio_desc static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, u64 ts) -{ +{ u32 i; //fprintf(stderr, "update: ESID=%d - size=%d - ts="LLD"\n", ESID, size, ts); if (calling_object) { - M2TSProgram *prog = (M2TSProgram *)calling_object; + M2TSSource *source = (M2TSSource *)calling_object; #ifndef GPAC_DISABLE_PLAYER if (ESID == AUDIO_DATA_ESID) { @@ -944,7 +970,7 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, /*this is the first time we get some audio data. Therefore we are sure we can retrieve the audio descriptor. Then we'll send it by calling this callback recursively so that a player gets the audio descriptor before audio data. Hack: the descriptor is carried thru the input_udta, you shall delete it*/ - GF_SimpleDataDescriptor *audio_desc = prog->streams[audio_OD_stream_id].input_udta; + GF_SimpleDataDescriptor *audio_desc = source->streams[audio_OD_stream_id].input_udta; if (audio_desc && !audio_desc->data) /*intended for HTTP/AAC: an empty descriptor was set (vs already filled for RTP/UDP MP3)*/ { /*get the audio descriptor and encode it*/ @@ -957,14 +983,14 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, /*audio stream, all samples are RAPs*/ esd->slConfig->useRandomAccessPointFlag = 0; esd->slConfig->hasRandomAccessUnitsOnlyFlag = 1; - for (i=0; inb_streams; i++) { - if (prog->streams[i].stream_id == AUDIO_DATA_ESID) { + for (i=0; inb_streams; i++) { + if (source->streams[i].stream_id == AUDIO_DATA_ESID) { GF_Err e; - prog->streams[i].timescale = esd->slConfig->timestampResolution; - e = gf_m2ts_program_stream_update_ts_scale(&prog->streams[i], esd->slConfig->timestampResolution); + source->streams[i].timescale = esd->slConfig->timestampResolution; + e = gf_m2ts_program_stream_update_ts_scale(&source->streams[i], esd->slConfig->timestampResolution); assert(!e); - if (!prog->streams[i].sl_config) prog->streams[i].sl_config = (GF_SLConfig *)gf_odf_desc_new(GF_ODF_SLC_TAG); - memcpy(prog->streams[i].sl_config, esd->slConfig, sizeof(GF_SLConfig)); + if (!source->streams[i].sl_config) source->streams[i].sl_config = (GF_SLConfig *)gf_odf_desc_new(GF_ODF_SLC_TAG); + memcpy(source->streams[i].sl_config, esd->slConfig, sizeof(GF_SLConfig)); break; } } @@ -975,37 +1001,37 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, /*build the ESI*/ { /*audio OD descriptor: rap=1 and vers_inc=0*/ - GF_SAFEALLOC(prog->streams[audio_OD_stream_id].input_udta, GF_ESIStream); - ((GF_ESIStream*)prog->streams[audio_OD_stream_id].input_udta)->rap = 1; + GF_SAFEALLOC(source->streams[audio_OD_stream_id].input_udta, GF_ESIStream); + ((GF_ESIStream*)source->streams[audio_OD_stream_id].input_udta)->rap = 1; /*we have the descriptor; now call this callback recursively so that a player gets the audio descriptor before audio data.*/ - prog->repeat = 1; - SampleCallBack(prog, AUDIO_OD_ESID, audio_desc->data, audio_desc->size, 0/*gf_m2ts_get_sys_clock(muxer)*/); - prog->repeat = 0; + source->repeat = 1; + SampleCallBack(source, AUDIO_OD_ESID, audio_desc->data, audio_desc->size, 0/*gf_m2ts_get_sys_clock(muxer)*/); + source->repeat = 0; /*clean*/ gf_free(audio_desc->data); gf_free(audio_desc); - gf_free(prog->streams[audio_OD_stream_id].input_udta); - prog->streams[audio_OD_stream_id].input_udta = NULL; + gf_free(source->streams[audio_OD_stream_id].input_udta); + source->streams[audio_OD_stream_id].input_udta = NULL; } } } /*update the timescale if needed*/ - else if (!prog->audio_configured) { + else if (!source->audio_configured) { GF_ESD *esd = AAC_GetESD(aac_reader); assert(esd->slConfig->timestampResolution); - for (i=0; inb_streams; i++) { - if (prog->streams[i].stream_id == AUDIO_DATA_ESID) { + for (i=0; inb_streams; i++) { + if (source->streams[i].stream_id == AUDIO_DATA_ESID) { GF_Err e; - prog->streams[i].timescale = esd->slConfig->timestampResolution; - prog->streams[i].decoder_config = esd->decoderConfig->decoderSpecificInfo->data; - prog->streams[i].decoder_config_size = esd->decoderConfig->decoderSpecificInfo->dataLength; + source->streams[i].timescale = esd->slConfig->timestampResolution; + source->streams[i].decoder_config = esd->decoderConfig->decoderSpecificInfo->data; + source->streams[i].decoder_config_size = esd->decoderConfig->decoderSpecificInfo->dataLength; esd->decoderConfig->decoderSpecificInfo->data = NULL; esd->decoderConfig->decoderSpecificInfo->dataLength = 0; - e = gf_m2ts_program_stream_update_ts_scale(&prog->streams[i], esd->slConfig->timestampResolution); + e = gf_m2ts_program_stream_update_ts_scale(&source->streams[i], esd->slConfig->timestampResolution); if (!e) - prog->audio_configured = 1; + source->audio_configured = 1; break; } } @@ -1017,13 +1043,13 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, } #endif i=0; - while (inb_streams){ - if (prog->streams[i].output_ctrl==NULL) { + while (inb_streams) { + if (source->streams[i].output_ctrl==NULL) { fprintf(stderr, "MULTIPLEX NOT YET CREATED\n"); return; } - if (prog->streams[i].stream_id == ESID) { - GF_ESIStream *priv = (GF_ESIStream *)prog->streams[i].input_udta; + if (source->streams[i].stream_id == ESID) { + GF_ESIStream *priv = (GF_ESIStream *)source->streams[i].input_udta; GF_ESIPacket pck; memset(&pck, 0, sizeof(GF_ESIPacket)); pck.data = data; @@ -1036,19 +1062,19 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, if (priv->rap) pck.flags |= GF_ESI_DATA_AU_RAP; - if (prog->repeat || !priv->vers_inc) { + if (source->repeat || !priv->vers_inc) { pck.flags |= GF_ESI_DATA_REPEAT; fprintf(stderr, "RAP carousel from scene engine sent: ESID=%d - size=%d - ts="LLD"\n", ESID, size, ts); } else { if (ESID != AUDIO_DATA_ESID && ESID != VIDEO_DATA_ESID) /*don't log A/V inputs*/ - fprintf(stderr, "Update from scene engine sent: ESID=%d - size=%d - ts="LLD"\n", ESID, size, ts); + fprintf(stderr, "Update from scene engine sent: ESID=%d - size=%d - ts="LLD"\n", ESID, size, ts); } - prog->streams[i].output_ctrl(&prog->streams[i], GF_ESI_OUTPUT_DATA_DISPATCH, &pck); + source->streams[i].output_ctrl(&source->streams[i], GF_ESI_OUTPUT_DATA_DISPATCH, &pck); return; } - i++; + i++; } - } + } return; } @@ -1058,7 +1084,7 @@ static void SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, static volatile Bool run = 1; #ifndef GPAC_DISABLE_SENG -static GF_ESIStream * set_broadcast_params(M2TSProgram *prog, u16 esid, u32 period, u32 ts_delta, u16 aggregate_on_stream, Bool adjust_carousel_time, Bool force_rap, Bool aggregate_au, Bool discard_pending, Bool signal_rap, Bool signal_critical, Bool version_inc) +static GF_ESIStream * set_broadcast_params(M2TSSource *source, u16 esid, u32 period, u32 ts_delta, u16 aggregate_on_stream, Bool adjust_carousel_time, Bool force_rap, Bool aggregate_au, Bool discard_pending, Bool signal_rap, Bool signal_critical, Bool version_inc) { u32 i=0; GF_ESIStream *priv=NULL; @@ -1066,13 +1092,13 @@ static GF_ESIStream * set_broadcast_params(M2TSProgram *prog, u16 esid, u32 peri /*locate our stream*/ if (esid) { - while (inb_streams) { - if (prog->streams[i].stream_id == esid){ - priv = (GF_ESIStream *)prog->streams[i].input_udta; - esi = &prog->streams[i]; + while (inb_streams) { + if (source->streams[i].stream_id == esid) { + priv = (GF_ESIStream *)source->streams[i].input_udta; + esi = &source->streams[i]; break; } - else{ + else { i++; } } @@ -1087,7 +1113,7 @@ static GF_ESIStream * set_broadcast_params(M2TSProgram *prog, u16 esid, u32 peri } /*remember RAP flag*/ - priv->rap = signal_rap; + priv->rap = signal_rap; priv->critical = signal_critical; priv->vers_inc = version_inc; @@ -1096,7 +1122,7 @@ static GF_ESIStream * set_broadcast_params(M2TSProgram *prog, u16 esid, u32 peri /*change stream aggregation mode*/ if ((aggregate_on_stream != (u16)-1) && (priv->aggregate_on_stream != aggregate_on_stream)) { - gf_seng_enable_aggregation(prog->seng, esid, aggregate_on_stream); + gf_seng_enable_aggregation(source->seng, esid, aggregate_on_stream); priv->aggregate_on_stream = aggregate_on_stream; } /*change stream aggregation mode*/ @@ -1117,8 +1143,8 @@ static u32 seng_output(void *param) { GF_Err e; u64 last_src_modif, mod_time; - M2TSProgram *prog = (M2TSProgram *)param; - GF_SceneEngine *seng = prog->seng; + M2TSSource *source = (M2TSSource *)param; + GF_SceneEngine *seng = source->seng; GF_SimpleDataDescriptor *audio_desc; Bool update_context=0; Bool force_rap, adjust_carousel_time, discard_pending, signal_rap, signal_critical, version_inc, aggregate_au; @@ -1127,41 +1153,41 @@ static u32 seng_output(void *param) e = GF_OK; gf_sleep(2000); /*TODO: events instead? What are we waiting for?*/ gf_seng_encode_context(seng, SampleCallBack); - - last_src_modif = prog->src_name ? gf_file_modification_time(prog->src_name) : 0; + + last_src_modif = source->bifs_src_name ? gf_file_modification_time(source->bifs_src_name) : 0; /*send the audio descriptor*/ - if (prog->mpeg4_signaling==GF_M2TS_MPEG4_SIGNALING_FULL && audio_OD_stream_id!=(u32)-1) { - audio_desc = prog->streams[audio_OD_stream_id].input_udta; + if (source->mpeg4_signaling==GF_M2TS_MPEG4_SIGNALING_FULL && audio_OD_stream_id!=(u32)-1) { + audio_desc = source->streams[audio_OD_stream_id].input_udta; if (audio_desc && audio_desc->data) /*RTP/UDP + MP3 case*/ { assert(audio_OD_stream_id != (u32)-1); assert(!aac_reader); /*incompatible with AAC*/ - prog->repeat = 1; - SampleCallBack(prog, AUDIO_OD_ESID, audio_desc->data, audio_desc->size, 0/*gf_m2ts_get_sys_clock(muxer)*/); - prog->repeat = 0; + source->repeat = 1; + SampleCallBack(source, AUDIO_OD_ESID, audio_desc->data, audio_desc->size, 0/*gf_m2ts_get_sys_clock(muxer)*/); + source->repeat = 0; gf_free(audio_desc->data); gf_free(audio_desc); - prog->streams[audio_OD_stream_id].input_udta = NULL; + source->streams[audio_OD_stream_id].input_udta = NULL; } } while (run) { if (!gf_prompt_has_input()) { - if (prog->src_name) { - mod_time = gf_file_modification_time(prog->src_name); + if (source->bifs_src_name) { + mod_time = gf_file_modification_time(source->bifs_src_name); if (mod_time != last_src_modif) { FILE *srcf; char flag_buf[201], *flag; fprintf(stderr, "Update file modified - processing\n"); last_src_modif = mod_time; - srcf = gf_f64_open(prog->src_name, "rt"); + srcf = gf_f64_open(source->bifs_src_name, "rt"); if (!srcf) continue; /*checks if we have a broadcast config*/ if (!fgets(flag_buf, 200, srcf)) - flag_buf[0] = '\0'; + flag_buf[0] = '\0'; fclose(srcf); aggregate_au = force_rap = adjust_carousel_time = discard_pending = signal_rap = signal_critical = 0; @@ -1223,25 +1249,25 @@ static u32 seng_output(void *param) } } - set_broadcast_params(prog, es_id, period, ts_delta, aggregate_on_stream, adjust_carousel_time, force_rap, aggregate_au, discard_pending, signal_rap, signal_critical, version_inc); + set_broadcast_params(source, es_id, period, ts_delta, aggregate_on_stream, adjust_carousel_time, force_rap, aggregate_au, discard_pending, signal_rap, signal_critical, version_inc); } - e = gf_seng_encode_from_file(seng, es_id, aggregate_au ? 0 : 1, prog->src_name, SampleCallBack); - if (e){ + e = gf_seng_encode_from_file(seng, es_id, aggregate_au ? 0 : 1, source->bifs_src_name, SampleCallBack); + if (e) { fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e)); } else gf_seng_aggregate_context(seng, 0); update_context=1; - + } } if (update_context) { - prog->repeat = 1; + source->repeat = 1; e = gf_seng_encode_context(seng, SampleCallBack); - prog->repeat = 0; + source->repeat = 0; update_context = 0; } @@ -1249,46 +1275,46 @@ static u32 seng_output(void *param) } else { /*gf_prompt_has_input()*/ char c = gf_prompt_get_char(); switch (c) { - case 'u': - { - GF_Err e; - char szCom[8192]; - fprintf(stderr, "Enter command to send:\n"); - fflush(stdin); - szCom[0] = 0; - if (1 > scanf("%[^\t\n]", szCom)){ - fprintf(stderr, "No command has been properly entered, aborting.\n"); - break; - } - e = gf_seng_encode_from_string(seng, 0, 0, szCom, SampleCallBack); - if (e) { - fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e)); - } - update_context=1; - } + case 'u': + { + GF_Err e; + char szCom[8192]; + fprintf(stderr, "Enter command to send:\n"); + fflush(stdin); + szCom[0] = 0; + if (1 > scanf("%[^\t\n]", szCom)) { + fprintf(stderr, "No command has been properly entered, aborting.\n"); break; - case 'p': - { - char rad[GF_MAX_PATH]; - fprintf(stderr, "Enter output file name - \"std\" for stderr: "); - if (1 > scanf("%s", rad)){ - fprintf(stderr, "No outfile name has been entered, aborting.\n"); - break; - } - e = gf_seng_save_context(seng, !strcmp(rad, "std") ? NULL : rad); - fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e)); } + e = gf_seng_encode_from_string(seng, 0, 0, szCom, SampleCallBack); + if (e) { + fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e)); + } + update_context=1; + } + break; + case 'p': + { + char rad[GF_MAX_PATH]; + fprintf(stderr, "Enter output file name - \"std\" for stderr: "); + if (1 > scanf("%s", rad)) { + fprintf(stderr, "No outfile name has been entered, aborting.\n"); break; - case 'q': - { - run = 0; } + e = gf_seng_save_context(seng, !strcmp(rad, "std") ? NULL : rad); + fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e)); + } + break; + case 'q': + { + run = 0; + } } e = GF_OK; } } - - + + return e ? 1 : 0; } @@ -1300,7 +1326,7 @@ void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 pe char *config_buffer = NULL; memset(ifce, 0, sizeof(GF_ESInterface)); - e = gf_seng_get_stream_config(seng, i, (u16*) &(ifce->stream_id), &config_buffer, &len, (u32*) &(ifce->stream_type), (u32*) &(ifce->object_type_indication), &(ifce->timescale)); + e = gf_seng_get_stream_config(seng, i, (u16*) &(ifce->stream_id), &config_buffer, &len, (u32*) &(ifce->stream_type), (u32*) &(ifce->object_type_indication), &(ifce->timescale)); if (e) { fprintf(stderr, "Cannot set the stream config for stream %d to %d: %s\n", ifce->stream_id, period, gf_error_to_string(e)); } @@ -1310,9 +1336,9 @@ void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 pe memset(stream, 0, sizeof(GF_ESIStream)); stream->rap = 1; if (ifce->input_udta) - gf_free(ifce->input_udta); + gf_free(ifce->input_udta); ifce->input_udta = stream; - + //fprintf(stderr, "Caroussel period: %d\n", period); // e = gf_seng_set_carousel_time(seng, ifce->stream_id, period); if (e) { @@ -1323,16 +1349,16 @@ void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 pe } #endif -static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mpeg4_signaling, char *update, char *audio_input_ip, u16 audio_input_port, char *video_buffer, Bool force_real_time, u32 bifs_use_pes, const char *temi_url) +static Bool open_source(M2TSSource *source, char *src, u32 carousel_rate, u32 mpeg4_signaling, char *update, char *audio_input_ip, u16 audio_input_port, char *video_buffer, Bool force_real_time, u32 bifs_use_pes, const char *temi_url, Bool compute_max_size) { #ifndef GPAC_DISABLE_STREAMING GF_SDPInfo *sdp; #endif u32 i; s64 min_offset = 0; - - memset(prog, 0, sizeof(M2TSProgram)); - prog->mpeg4_signaling = mpeg4_signaling; + + memset(source, 0, sizeof(M2TSSource)); + source->mpeg4_signaling = mpeg4_signaling; /*open ISO file*/ if (gf_isom_probe_file(src)) { @@ -1340,45 +1366,45 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp Bool has_bifs_od = 0; u32 first_audio = 0; u32 first_other = 0; - prog->mp4 = gf_isom_open(src, GF_ISOM_OPEN_READ, 0); - prog->nb_streams = 0; - prog->real_time = force_real_time; + source->mp4 = gf_isom_open(src, GF_ISOM_OPEN_READ, 0); + source->nb_streams = 0; + source->real_time = force_real_time; /*on MPEG-2 TS, carry 3GPP timed text as MPEG-4 Part17*/ - gf_isom_text_set_streaming_mode(prog->mp4, 1); - nb_tracks = gf_isom_get_track_count(prog->mp4); + gf_isom_text_set_streaming_mode(source->mp4, 1); + nb_tracks = gf_isom_get_track_count(source->mp4); for (i=0; imp4, i+1) == GF_ISOM_MEDIA_HINT) - continue; + if (gf_isom_get_media_type(source->mp4, i+1) == GF_ISOM_MEDIA_HINT) + continue; - fill_isom_es_ifce(prog, &prog->streams[i], prog->mp4, i+1, bifs_use_pes); - if (min_offset > ((GF_ESIMP4 *)prog->streams[i].input_udta)->ts_offset) - min_offset = ((GF_ESIMP4 *)prog->streams[i].input_udta)->ts_offset; + fill_isom_es_ifce(source, &source->streams[i], source->mp4, i+1, bifs_use_pes, compute_max_size); + if (min_offset > ((GF_ESIMP4 *)source->streams[i].input_udta)->ts_offset) + min_offset = ((GF_ESIMP4 *)source->streams[i].input_udta)->ts_offset; - switch(prog->streams[i].stream_type) { + switch(source->streams[i].stream_type) { case GF_STREAM_OD: has_bifs_od = 1; - prog->streams[i].repeat_rate = carousel_rate; + source->streams[i].repeat_rate = carousel_rate; break; case GF_STREAM_SCENE: has_bifs_od = 1; - prog->streams[i].repeat_rate = carousel_rate; + source->streams[i].repeat_rate = carousel_rate; break; case GF_STREAM_VISUAL: /*turn on image repeat*/ - switch (prog->streams[i].object_type_indication) { + switch (source->streams[i].object_type_indication) { case GPAC_OTI_IMAGE_JPEG: case GPAC_OTI_IMAGE_PNG: - ((GF_ESIMP4 *)prog->streams[i].input_udta)->image_repeat_ms = carousel_rate; + ((GF_ESIMP4 *)source->streams[i].input_udta)->image_repeat_ms = carousel_rate; break; default: check_deps = 1; - if (gf_isom_get_sample_count(prog->mp4, i+1)>1) { + if (gf_isom_get_sample_count(source->mp4, i+1)>1) { /*get first visual stream as PCR*/ - if (!prog->pcr_idx) { - prog->pcr_idx = i+1; - ((GF_ESIMP4 *)prog->streams[i].input_udta)->temi_url = temi_url; + if (!source->pcr_idx) { + source->pcr_idx = i+1; + ((GF_ESIMP4 *)source->streams[i].input_udta)->temi_url = temi_url; } } break; @@ -1392,66 +1418,66 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp /*log not supported stream type: %s*/ break; } - prog->nb_streams++; - if (gf_isom_get_sample_count(prog->mp4, i+1)>1) first_other = i+1; + source->nb_streams++; + if (gf_isom_get_sample_count(source->mp4, i+1)>1) first_other = i+1; if (check_deps) { u32 k; Bool found_dep = 0; for (k=0; kmp4, k+1) != GF_ISOM_MEDIA_OD) - continue; + if (gf_isom_get_media_type(source->mp4, k+1) != GF_ISOM_MEDIA_OD) + continue; /*this stream is not refered to by any OD, send as regular PES*/ - if (gf_isom_has_track_reference(prog->mp4, k+1, GF_ISOM_REF_OD, gf_isom_get_track_id(prog->mp4, i+1) )==1) { + if (gf_isom_has_track_reference(source->mp4, k+1, GF_ISOM_REF_OD, gf_isom_get_track_id(source->mp4, i+1) )==1) { found_dep = 1; break; } } if (!found_dep) { - prog->streams[i].caps |= GF_ESI_STREAM_WITHOUT_MPEG4_SYSTEMS; + source->streams[i].caps |= GF_ESI_STREAM_WITHOUT_MPEG4_SYSTEMS; } } } - if (has_bifs_od && !prog->mpeg4_signaling) prog->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; + if (has_bifs_od && !source->mpeg4_signaling) source->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; /*if no visual PCR found, use first audio*/ - if (!prog->pcr_idx) prog->pcr_idx = first_audio; - if (!prog->pcr_idx) prog->pcr_idx = first_other; - if (prog->pcr_idx) { + if (!source->pcr_idx) source->pcr_idx = first_audio; + if (!source->pcr_idx) source->pcr_idx = first_other; + if (source->pcr_idx) { GF_ESIMP4 *priv; - prog->pcr_idx-=1; - priv = prog->streams[prog->pcr_idx].input_udta; - gf_isom_set_default_sync_track(prog->mp4, priv->track); + source->pcr_idx-=1; + priv = source->streams[source->pcr_idx].input_udta; + gf_isom_set_default_sync_track(source->mp4, priv->track); } if (min_offset < 0) { - for (i=0; inb_streams; i++) { - ((GF_ESIMP4 *)prog->streams[i].input_udta)->ts_offset += -min_offset; + for (i=0; inb_streams; i++) { + ((GF_ESIMP4 *)source->streams[i].input_udta)->ts_offset += -min_offset; } } - prog->iod = gf_isom_get_root_od(prog->mp4); - if (prog->iod) { - GF_ObjectDescriptor*iod = (GF_ObjectDescriptor*)prog->iod; - if (gf_list_count( ((GF_ObjectDescriptor*)prog->iod)->ESDescriptors) == 0) { - gf_odf_desc_del(prog->iod); - prog->iod = NULL; + source->iod = gf_isom_get_root_od(source->mp4); + if (source->iod) { + GF_ObjectDescriptor*iod = (GF_ObjectDescriptor*)source->iod; + if (gf_list_count( ((GF_ObjectDescriptor*)source->iod)->ESDescriptors) == 0) { + gf_odf_desc_del(source->iod); + source->iod = NULL; } else { fprintf(stderr, "IOD found for program %s\n", src); /*if using 4over2, get rid of OD tracks*/ - if (prog->mpeg4_signaling==GF_M2TS_MPEG4_SIGNALING_SCENE) { + if (source->mpeg4_signaling==GF_M2TS_MPEG4_SIGNALING_SCENE) { for (i=0; iESDescriptors); i++) { u32 track_num, k; GF_M2TSDescriptor *oddesc; GF_ISOSample *sample; GF_ESD *esd = gf_list_get(iod->ESDescriptors, i); if (esd->decoderConfig->streamType!=GF_STREAM_OD) continue; - track_num = gf_isom_get_track_by_id(prog->mp4, esd->ESID); - if (gf_isom_get_sample_count(prog->mp4, track_num)>1) continue; + track_num = gf_isom_get_track_by_id(source->mp4, esd->ESID); + if (gf_isom_get_sample_count(source->mp4, track_num)>1) continue; - sample = gf_isom_get_sample(prog->mp4, track_num, 1, NULL); + sample = gf_isom_get_sample(source->mp4, track_num, 1, NULL); if (sample->dataLength >= 255-2) { gf_isom_sample_del(&sample); continue; @@ -1462,26 +1488,26 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp if (dep_esd->dependsOnESID==esd->ESID) dep_esd->dependsOnESID = esd->dependsOnESID; } - for (k=0; knb_streams; k++) { - if (prog->streams[k].stream_id==esd->ESID) { - prog->streams[k].stream_type = 0; + for (k=0; knb_streams; k++) { + if (source->streams[k].stream_id==esd->ESID) { + source->streams[k].stream_type = 0; break; } } - if (!prog->od_updates) prog->od_updates = gf_list_new(); - GF_SAFEALLOC(oddesc, GF_M2TSDescriptor); + if (!source->od_updates) source->od_updates = gf_list_new(); + GF_SAFEALLOC(oddesc, GF_M2TSDescriptor); oddesc->data_len = sample->dataLength; oddesc->data = sample->data; oddesc->tag = GF_M2TS_MPEG4_ODUPDATE_DESCRIPTOR; sample->data = NULL; gf_isom_sample_del(&sample); - gf_list_add(prog->od_updates, oddesc); + gf_list_add(source->od_updates, oddesc); gf_list_rem(iod->ESDescriptors, i); i--; gf_odf_desc_del((GF_Descriptor *) esd); - prog->samples_count--; + source->samples_count--; } } @@ -1536,186 +1562,186 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp size64 = (u32) strlen(buf64) - 1; size = gf_base64_decode(buf64, size64, buf, 2000); - gf_odf_desc_read(buf, size, &prog->iod); + gf_odf_desc_read(buf, size, &source->iod); break; } - prog->nb_streams = gf_list_count(sdp->media_desc); - for (i=0; inb_streams; i++) { + source->nb_streams = gf_list_count(sdp->media_desc); + for (i=0; inb_streams; i++) { GF_SDPMedia *media = gf_list_get(sdp->media_desc, i); - fill_rtp_es_ifce(&prog->streams[i], media, sdp, prog); - switch(prog->streams[i].stream_type) { + fill_rtp_es_ifce(&source->streams[i], media, sdp, source); + switch(source->streams[i].stream_type) { case GF_STREAM_OD: case GF_STREAM_SCENE: - prog->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; - prog->streams[i].repeat_rate = carousel_rate; + source->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; + source->streams[i].repeat_rate = carousel_rate; break; } - if (!prog->pcr_idx && (prog->streams[i].stream_type == GF_STREAM_VISUAL)) { - prog->pcr_idx = i+1; + if (!source->pcr_idx && (source->streams[i].stream_type == GF_STREAM_VISUAL)) { + source->pcr_idx = i+1; } } - if (prog->pcr_idx) prog->pcr_idx-=1; + if (source->pcr_idx) source->pcr_idx-=1; gf_sdp_info_del(sdp); return 2; - } else + } else #endif /*GPAC_DISABLE_STREAMING*/ #ifndef GPAC_DISABLE_SENG - if (strstr(src, ".bt")) //open .bt file - { - u32 load_type=0; - prog->seng = gf_seng_init(prog, src, load_type, NULL, (load_type == GF_SM_LOAD_DIMS) ? 1 : 0); - if (!prog->seng) { - fprintf(stderr, "Cannot create scene engine\n"); - exit(1); - } - else{ - fprintf(stderr, "Scene engine created.\n"); - } - assert( prog ); - assert( prog->seng); - prog->iod = gf_seng_get_iod(prog->seng); - if (! prog->iod){ - fprintf(stderr, __FILE__": No IOD\n"); - } - - prog->nb_streams = gf_seng_get_stream_count(prog->seng); - prog->rate = carousel_rate; - prog->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; - - for (i=0; inb_streams; i++) { - fill_seng_es_ifce(&prog->streams[i], i, prog->seng, prog->rate); - //fprintf(stderr, "Fill interface\n"); - if (!prog->pcr_idx && (prog->streams[i].stream_type == GF_STREAM_AUDIO)) { - prog->pcr_idx = i+1; + if (strstr(src, ".bt")) //open .bt file + { + u32 load_type=0; + source->seng = gf_seng_init(source, src, load_type, NULL, (load_type == GF_SM_LOAD_DIMS) ? 1 : 0); + if (!source->seng) { + fprintf(stderr, "Cannot create scene engine\n"); + exit(1); + } + else { + fprintf(stderr, "Scene engine created.\n"); + } + assert( source ); + assert( source->seng); + source->iod = gf_seng_get_iod(source->seng); + if (! source->iod) { + fprintf(stderr, __FILE__": No IOD\n"); + } + + source->nb_streams = gf_seng_get_stream_count(source->seng); + source->rate = carousel_rate; + source->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_FULL; + + for (i=0; inb_streams; i++) { + fill_seng_es_ifce(&source->streams[i], i, source->seng, source->rate); + //fprintf(stderr, "Fill interface\n"); + if (!source->pcr_idx && (source->streams[i].stream_type == GF_STREAM_AUDIO)) { + source->pcr_idx = i+1; + } } - } - /*when an audio input is present, declare it and store OD + ESD_U*/ - if (audio_input_ip) { - /*add the audio program*/ - prog->pcr_idx = prog->nb_streams; - prog->streams[prog->nb_streams].stream_type = GF_STREAM_AUDIO; - /*hack: http urls are not decomposed therefore audio_input_port remains null*/ - if (audio_input_port) { /*UDP/RTP*/ - prog->streams[prog->nb_streams].object_type_indication = GPAC_OTI_AUDIO_MPEG1; - } else { /*HTTP*/ - aac_reader->oti = prog->streams[prog->nb_streams].object_type_indication = GPAC_OTI_AUDIO_AAC_MPEG4; - } - prog->streams[prog->nb_streams].input_ctrl = void_input_ctrl; - prog->streams[prog->nb_streams].stream_id = AUDIO_DATA_ESID; - prog->streams[prog->nb_streams].timescale = 1000; - - GF_SAFEALLOC(prog->streams[prog->nb_streams].input_udta, GF_ESIStream); - ((GF_ESIStream*)prog->streams[prog->nb_streams].input_udta)->vers_inc = 1; /*increment version number at every audio update*/ - assert( prog ); - //assert( prog->iod); - if (prog->iod && ((prog->iod->tag!=GF_ODF_IOD_TAG) || (mpeg4_signaling != GF_M2TS_MPEG4_SIGNALING_SCENE))) { - /*create the descriptor*/ - GF_ESD *esd; - GF_SimpleDataDescriptor *audio_desc; - GF_SAFEALLOC(audio_desc, GF_SimpleDataDescriptor); + /*when an audio input is present, declare it and store OD + ESD_U*/ + if (audio_input_ip) { + /*add the audio program*/ + source->pcr_idx = source->nb_streams; + source->streams[source->nb_streams].stream_type = GF_STREAM_AUDIO; + /*hack: http urls are not decomposed therefore audio_input_port remains null*/ if (audio_input_port) { /*UDP/RTP*/ - esd = gf_odf_desc_esd_new(0); - esd->decoderConfig->streamType = prog->streams[prog->nb_streams].stream_type; - esd->decoderConfig->objectTypeIndication = prog->streams[prog->nb_streams].object_type_indication; - } else { /*HTTP*/ - esd = AAC_GetESD(aac_reader); /*in case of AAC, we have to wait the first ADTS chunk*/ + source->streams[source->nb_streams].object_type_indication = GPAC_OTI_AUDIO_MPEG1; + } else { /*HTTP*/ + aac_reader->oti = source->streams[source->nb_streams].object_type_indication = GPAC_OTI_AUDIO_AAC_MPEG4; } - assert( esd ); - esd->ESID = prog->streams[prog->nb_streams].stream_id; - if (esd->slConfig->timestampResolution) /*in case of AAC, we have to wait the first ADTS chunk*/ - encode_audio_desc(esd, audio_desc); - else - gf_odf_desc_del((GF_Descriptor *)esd); + source->streams[source->nb_streams].input_ctrl = void_input_ctrl; + source->streams[source->nb_streams].stream_id = AUDIO_DATA_ESID; + source->streams[source->nb_streams].timescale = 1000; + + GF_SAFEALLOC(source->streams[source->nb_streams].input_udta, GF_ESIStream); + ((GF_ESIStream*)source->streams[source->nb_streams].input_udta)->vers_inc = 1; /*increment version number at every audio update*/ + assert( source ); + //assert( source->iod); + if (source->iod && ((source->iod->tag!=GF_ODF_IOD_TAG) || (mpeg4_signaling != GF_M2TS_MPEG4_SIGNALING_SCENE))) { + /*create the descriptor*/ + GF_ESD *esd; + GF_SimpleDataDescriptor *audio_desc; + GF_SAFEALLOC(audio_desc, GF_SimpleDataDescriptor); + if (audio_input_port) { /*UDP/RTP*/ + esd = gf_odf_desc_esd_new(0); + esd->decoderConfig->streamType = source->streams[source->nb_streams].stream_type; + esd->decoderConfig->objectTypeIndication = source->streams[source->nb_streams].object_type_indication; + } else { /*HTTP*/ + esd = AAC_GetESD(aac_reader); /*in case of AAC, we have to wait the first ADTS chunk*/ + } + assert( esd ); + esd->ESID = source->streams[source->nb_streams].stream_id; + if (esd->slConfig->timestampResolution) /*in case of AAC, we have to wait the first ADTS chunk*/ + encode_audio_desc(esd, audio_desc); + else + gf_odf_desc_del((GF_Descriptor *)esd); - /*find the audio OD stream and attach its descriptor*/ - for (i=0; inb_streams; i++) { - if (prog->streams[i].stream_id == AUDIO_OD_ESID) { - if (prog->streams[i].input_udta) - gf_free(prog->streams[i].input_udta); - prog->streams[i].input_udta = (void*)audio_desc; /*Hack: the real input_udta type (for our SampleCallBack function) is GF_ESIStream*/ - audio_OD_stream_id = i; - break; + /*find the audio OD stream and attach its descriptor*/ + for (i=0; inb_streams; i++) { + if (source->streams[i].stream_id == AUDIO_OD_ESID) { + if (source->streams[i].input_udta) + gf_free(source->streams[i].input_udta); + source->streams[i].input_udta = (void*)audio_desc; /*Hack: the real input_udta type (for our SampleCallBack function) is GF_ESIStream*/ + audio_OD_stream_id = i; + break; + } } + if (audio_OD_stream_id == (u32)-1) { + fprintf(stderr, "Error: could not find an audio OD stream with ESID=100 in '%s'\n", src); + return 0; + } + } else { + source->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_SCENE; } - if (audio_OD_stream_id == (u32)-1) { - fprintf(stderr, "Error: could not find an audio OD stream with ESID=100 in '%s'\n", src); - return 0; - } - } else { - prog->mpeg4_signaling = GF_M2TS_MPEG4_SIGNALING_SCENE; + source->nb_streams++; } - prog->nb_streams++; - } - /*when an audio input is present, declare it and store OD + ESD_U*/ - if (video_buffer) { - /*add the video program*/ - prog->streams[prog->nb_streams].stream_type = GF_STREAM_VISUAL; - prog->streams[prog->nb_streams].object_type_indication = GPAC_OTI_VIDEO_AVC; - prog->streams[prog->nb_streams].input_ctrl = void_input_ctrl; - prog->streams[prog->nb_streams].stream_id = VIDEO_DATA_ESID; - prog->streams[prog->nb_streams].timescale = 1000; + /*when an audio input is present, declare it and store OD + ESD_U*/ + if (video_buffer) { + /*add the video program*/ + source->streams[source->nb_streams].stream_type = GF_STREAM_VISUAL; + source->streams[source->nb_streams].object_type_indication = GPAC_OTI_VIDEO_AVC; + source->streams[source->nb_streams].input_ctrl = void_input_ctrl; + source->streams[source->nb_streams].stream_id = VIDEO_DATA_ESID; + source->streams[source->nb_streams].timescale = 1000; - GF_SAFEALLOC(prog->streams[prog->nb_streams].input_udta, GF_ESIStream); - ((GF_ESIStream*)prog->streams[prog->nb_streams].input_udta)->vers_inc = 1; /*increment version number at every video update*/ - assert(prog); + GF_SAFEALLOC(source->streams[source->nb_streams].input_udta, GF_ESIStream); + ((GF_ESIStream*)source->streams[source->nb_streams].input_udta)->vers_inc = 1; /*increment version number at every video update*/ + assert(source); - if (prog->iod && ((prog->iod->tag!=GF_ODF_IOD_TAG) || (mpeg4_signaling != GF_M2TS_MPEG4_SIGNALING_SCENE))) { - assert(0); /*TODO*/ + if (source->iod && ((source->iod->tag!=GF_ODF_IOD_TAG) || (mpeg4_signaling != GF_M2TS_MPEG4_SIGNALING_SCENE))) { + assert(0); /*TODO*/ #if 0 - /*create the descriptor*/ - GF_ESD *esd; - GF_SimpleDataDescriptor *video_desc; - GF_SAFEALLOC(video_desc, GF_SimpleDataDescriptor); - esd = gf_odf_desc_esd_new(0); - esd->decoderConfig->streamType = prog->streams[prog->nb_streams].stream_type; - esd->decoderConfig->objectTypeIndication = prog->streams[prog->nb_streams].object_type_indication; - esd->ESID = prog->streams[prog->nb_streams].stream_id; - - /*find the audio OD stream and attach its descriptor*/ - for (i=0; inb_streams; i++) { - if (prog->streams[i].stream_id == 103/*TODO: VIDEO_OD_ESID*/) { - if (prog->streams[i].input_udta) - gf_free(prog->streams[i].input_udta); - prog->streams[i].input_udta = (void*)video_desc; - audio_OD_stream_id = i; - break; + /*create the descriptor*/ + GF_ESD *esd; + GF_SimpleDataDescriptor *video_desc; + GF_SAFEALLOC(video_desc, GF_SimpleDataDescriptor); + esd = gf_odf_desc_esd_new(0); + esd->decoderConfig->streamType = source->streams[source->nb_streams].stream_type; + esd->decoderConfig->objectTypeIndication = source->streams[source->nb_streams].object_type_indication; + esd->ESID = source->streams[source->nb_streams].stream_id; + + /*find the audio OD stream and attach its descriptor*/ + for (i=0; inb_streams; i++) { + if (source->streams[i].stream_id == 103/*TODO: VIDEO_OD_ESID*/) { + if (source->streams[i].input_udta) + gf_free(source->streams[i].input_udta); + source->streams[i].input_udta = (void*)video_desc; + audio_OD_stream_id = i; + break; + } + } + if (audio_OD_stream_id == (u32)-1) { + fprintf(stderr, "Error: could not find an audio OD stream with ESID=100 in '%s'\n", src); + return 0; } - } - if (audio_OD_stream_id == (u32)-1) { - fprintf(stderr, "Error: could not find an audio OD stream with ESID=100 in '%s'\n", src); - return 0; - } #endif - } else { - assert (prog->mpeg4_signaling == GF_M2TS_MPEG4_SIGNALING_SCENE); - } + } else { + assert (source->mpeg4_signaling == GF_M2TS_MPEG4_SIGNALING_SCENE); + } - prog->nb_streams++; - } + source->nb_streams++; + } - if (!prog->pcr_idx) prog->pcr_idx=1; - prog->th = gf_th_new("Carousel"); - prog->src_name = update; - gf_th_run(prog->th, seng_output, prog); - return 1; - } else + if (!source->pcr_idx) source->pcr_idx=1; + source->th = gf_th_new("Carousel"); + source->bifs_src_name = update; + gf_th_run(source->th, seng_output, source); + return 1; + } else #endif - { - FILE *f = fopen(src, "rt"); - if (f) { - fclose(f); - fprintf(stderr, "Error opening %s - not a supported input media, skipping.\n", src); - } else { - fprintf(stderr, "Error opening %s - no such file.\n", src); + { + FILE *f = fopen(src, "rt"); + if (f) { + fclose(f); + fprintf(stderr, "Error opening %s - not a supported input media, skipping.\n", src); + } else { + fprintf(stderr, "Error opening %s - no such file.\n", src); + } + return 0; } - return 0; - } } /*macro to keep retro compatibility with '=' and spaces in parse_args*/ @@ -1724,20 +1750,20 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp || ((strlen(arg) == strlen(param)) && ++i && (i 150) { fprintf(stderr, "URLs longer than 150 bytes are not currently supported\n"); return GF_NOT_SUPPORTED; @@ -1968,7 +1999,10 @@ static GFINLINE GF_Err parse_args(int argc, char **argv, u32 *mux_rate, u32 *car } else { *rtp_out = gf_strdup(next_arg); } - } else if (strnicmp(arg, "-prog", 5)) { //second pass arguments + } else if (CHECK_PARAM("-src")) { //second pass arguments + } else if (CHECK_PARAM("-prog")) { //second pass arguments + } + else { error_msg = "unknown option"; goto error; } @@ -1977,59 +2011,72 @@ static GFINLINE GF_Err parse_args(int argc, char **argv, u32 *mux_rate, u32 *car rate_found = 1; /*second pass: other*/ - for (i=1; i=0) gf_m2ts_mux_set_initial_pcr(muxer, (u64) pcr_init_val); + gf_m2ts_mux_set_pcr_max_interval(muxer, pcr_ms); if (ts_out != NULL) { if (segment_duration) { @@ -2213,12 +2263,12 @@ int main(int argc, char **argv) sprintf(segment_name, "%s_%d.ts", segment_prefix, segment_index); } ts_out = gf_strdup(segment_name); - if (!segment_manifest) { + if (!segment_manifest) { sprintf(segment_manifest_default, "%s.m3u8", segment_prefix); segment_manifest = segment_manifest_default; } //write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, segment_index, 0, 0); - } + } if (!strcmp(ts_out, "stdout") || !strcmp(ts_out, "-") ) { ts_output_file = stdout; is_stdout = GF_TRUE; @@ -2286,7 +2336,7 @@ int main(int argc, char **argv) /* create streaming audio input */ /************************************/ if (audio_input_ip) - switch(audio_input_type) { + switch(audio_input_type) { case GF_MP42TS_UDP: audio_input_udp_sk = gf_sk_new(GF_SOCK_TYPE_UDP); if (gf_sk_is_multicast_address((char *)audio_input_ip)) { @@ -2311,7 +2361,7 @@ int main(int argc, char **argv) break; #ifndef GPAC_DISABLE_PLAYER case GF_MP42TS_HTTP: - audio_prog = (void*)&progs[nb_progs-1]; + audio_prog = (void*)&sources[nb_sources-1]; aac_download_file(aac_reader, audio_input_ip); break; #endif @@ -2320,44 +2370,80 @@ int main(int argc, char **argv) break; default: assert(0); - } + } - if (!nb_progs) { + if (!nb_sources) { fprintf(stderr, "No program to mux, quitting.\n"); } + for (i=0; iiod = progs[i].iod; - if (progs[i].od_updates) { - program->loop_descriptors = progs[i].od_updates; - progs[i].od_updates = NULL; + for (i=0; iiod = sources[i].iod; + if (sources[i].od_updates) { + program->loop_descriptors = sources[i].od_updates; + sources[i].od_updates = NULL; + } + } else { + program = gf_m2ts_mux_program_find(muxer, sources[i].ID); } + if (!program) continue; - for (j=0; jstart_pes_at_rap = 1; + stream = gf_m2ts_program_stream_add(program, &sources[i].streams[j], cur_pid+j+1, (sources[i].pcr_idx==j) ? 1 : 0, force_pes_mode); + if (split_rap && (sources[i].streams[j].stream_type==GF_STREAM_VISUAL)) stream->start_pes_at_rap = 1; } - cur_pid += progs[i].nb_streams; + cur_pid += sources[i].nb_streams; while (cur_pid % 10) cur_pid ++; + + if (sources[i].program_name[0] || sources[i].provider_name[0] ) gf_m2ts_mux_program_set_name(program, sources[i].program_name, sources[i].provider_name); } muxer->flush_pes_at_rap = (split_rap == 2) ? GF_TRUE : GF_FALSE; + if (sdt_refresh_rate) { + gf_m2ts_mux_enable_sdt(muxer, sdt_refresh_rate); + } gf_m2ts_mux_update_config(muxer, 1); - + if (nb_pck_pack>1) { ts_pack_buffer = gf_malloc(sizeof(char) * 188 * nb_pck_pack); } @@ -2373,32 +2459,33 @@ int main(int argc, char **argv) if (audio_input_ip) { u32 read; switch (audio_input_type) { - case GF_MP42TS_UDP: - case GF_MP42TS_RTP: - /*e =*/gf_sk_receive(audio_input_udp_sk, audio_input_buffer, audio_input_buffer_length, 0, &read); - if (read) { - SampleCallBack((void*)&progs[nb_progs-1], AUDIO_DATA_ESID, audio_input_buffer, read, gf_m2ts_get_sys_clock(muxer)); - } - break; + case GF_MP42TS_UDP: + case GF_MP42TS_RTP: + /*e =*/ + gf_sk_receive(audio_input_udp_sk, audio_input_buffer, audio_input_buffer_length, 0, &read); + if (read) { + SampleCallBack((void*)&sources[nb_sources-1], AUDIO_DATA_ESID, audio_input_buffer, read, gf_m2ts_get_sys_clock(muxer)); + } + break; #ifndef GPAC_DISABLE_PLAYER - case GF_MP42TS_HTTP: - /*nothing to do: AAC_OnLiveData is called automatically*/ - /*check we're still alive*/ - if (gf_dm_is_thread_dead(aac_reader->dnload)) { - GF_ESD *esd; - aac_download_file(aac_reader, audio_input_ip); - esd = AAC_GetESD(aac_reader); - if (!esd) - break; - assert(esd->slConfig->timestampResolution); /*if we don't have this value we won't be able to adjust the timestamps within the MPEG2-TS*/ - if (esd->slConfig->timestampResolution) - audio_discontinuity_offset = gf_m2ts_get_sys_clock(muxer) * (u64)esd->slConfig->timestampResolution / 1000; - gf_odf_desc_del((GF_Descriptor *)esd); - } - break; + case GF_MP42TS_HTTP: + /*nothing to do: AAC_OnLiveData is called automatically*/ + /*check we're still alive*/ + if (gf_dm_is_thread_dead(aac_reader->dnload)) { + GF_ESD *esd; + aac_download_file(aac_reader, audio_input_ip); + esd = AAC_GetESD(aac_reader); + if (!esd) + break; + assert(esd->slConfig->timestampResolution); /*if we don't have this value we won't be able to adjust the timestamps within the MPEG2-TS*/ + if (esd->slConfig->timestampResolution) + audio_discontinuity_offset = gf_m2ts_get_sys_clock(muxer) * (u64)esd->slConfig->timestampResolution / 1000; + gf_odf_desc_del((GF_Descriptor *)esd); + } + break; #endif - default: - assert(0); + default: + assert(0); } } @@ -2420,7 +2507,7 @@ int main(int argc, char **argv) call_flush: if (ts_output_file != NULL) { - gf_fwrite(ts_pck, 1, 188 * nb_pck_in_pack, ts_output_file); + gf_fwrite(ts_pck, 1, 188 * nb_pck_in_pack, ts_output_file); if (segment_duration && (muxer->time.sec > prev_seg_time.sec + segment_duration)) { prev_seg_time = muxer->time; fclose(ts_output_file); @@ -2440,7 +2527,7 @@ call_flush: goto exit; } /* delete the oldest segment */ - if (segment_number && ((s32) (segment_index - segment_number - 1) >= 0)){ + if (segment_number && ((s32) (segment_index - segment_number - 1) >= 0)) { char old_segment_name[GF_MAX_PATH]; if (segment_dir) { if (strchr("\\/", segment_name[strlen(segment_name)-1])) { @@ -2453,14 +2540,14 @@ call_flush: } gf_delete_file(old_segment_name); } - write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, + write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, // (segment_index >= segment_number/2 ? segment_index - segment_number/2 : 0), segment_index >1 ? segment_index-1 : 0, 0); - ( (segment_index > segment_number ) ? segment_index - segment_number : 0), segment_index >1 ? segment_index-1 : 0, 0); - } + ( (segment_index > segment_number ) ? segment_index - segment_number : 0), segment_index >1 ? segment_index-1 : 0, 0); + } } if (ts_output_udp_sk != NULL) { - e = gf_sk_send(ts_output_udp_sk, (char*)ts_pck, 188 * nb_pck_in_pack); + e = gf_sk_send(ts_output_udp_sk, (char*)ts_pck, 188 * nb_pck_in_pack); if (e) { fprintf(stderr, "Error %s sending UDP packet\n", gf_error_to_string(e)); } @@ -2498,7 +2585,7 @@ call_flush: if (now/MP42TS_VIDEO_FREQ != last_video_time/MP42TS_VIDEO_FREQ) { /*should use carrousel behaviour instead of being pushed manually*/ if (video_buffer) - SampleCallBack((void*)&progs[nb_progs-1], VIDEO_DATA_ESID, video_buffer, video_buffer_size, gf_m2ts_get_sys_clock(muxer)+1000/*try buffering due to VLC msg*/); + SampleCallBack((void*)&sources[nb_sources-1], VIDEO_DATA_ESID, video_buffer, video_buffer_size, gf_m2ts_get_sys_clock(muxer)+1000/*try buffering due to VLC msg*/); last_video_time = now; } } @@ -2545,6 +2632,7 @@ call_flush: { u64 bits = muxer->tot_pck_sent*8*188; u32 dur_sec = gf_m2ts_get_ts_clock(muxer) / 1000; + if (!dur_sec) dur_sec = 1; fprintf(stderr, "Done muxing - %d sec - average rate %d kbps "LLD" packets written\n", dur_sec, (u32) (bits/dur_sec/1000), muxer->tot_pck_sent); fprintf(stderr, "\tPadding: "LLD" packets - "LLD" PES padded bytes (%g kbps)\n", muxer->tot_pad_sent, muxer->tot_pes_pad_bytes, (Double) (muxer->tot_pes_pad_bytes*8.0/dur_sec/1000) ); } @@ -2569,29 +2657,29 @@ exit: if (rtp_out) gf_free(rtp_out); #endif if (muxer) gf_m2ts_mux_del(muxer); - - for (i=0; i @@ -80,7 +80,7 @@ typedef struct __m2ts_mux_stream { /*average stream bit-rate in bit/sec*/ u32 bit_rate; - + /*multiplexer time - NOT THE PCR*/ M2TS_Time time; @@ -161,12 +161,12 @@ struct __m2ts_mux { Bool needs_reconfig; - /* used to indicate that the input data is pushed to the muxer (i.e. not read from a file) - or that the output data is sent on sockets (not written to a file) */ + /* used to indicate that the input data is pushed to the muxer (i.e. not read from a file) + or that the output data is sent on sockets (not written to a file) */ Bool real_time; /* indicates if the multiplexer shall target a fix bit rate (monitoring timing and produce padding packets) - or if the output stream will contain only input data*/ + or if the output stream will contain only input data*/ Bool fixed_rate; /*output bit-rate in bit/sec*/ @@ -175,14 +175,14 @@ struct __m2ts_mux { char dst_pck[188], null_pck[188]; /*multiplexer time, incremented each time a packet is sent - used to monitor the sending of muxer related data (PAT, ...) */ - M2TS_Time time; - - /* Time of the muxer when the first call to process is made (first packet sent?) */ - M2TS_Time init_ts_time; - - /* System time when the muxer is started */ - u32 init_sys_time; + used to monitor the sending of muxer related data (PAT, ...) */ + M2TS_Time time; + + /* Time of the muxer when the first call to process is made (first packet sent?) */ + M2TS_Time init_ts_time; + + /* System time when the muxer is started */ + u32 init_sys_time; Bool eos_found; u32 pck_sent_over_br_window, last_br_time, avg_br; diff --git a/applications/mp4box/filedump.c b/applications/mp4box/filedump.c index db9764b..feea5e1 100644 --- a/applications/mp4box/filedump.c +++ b/applications/mp4box/filedump.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -127,7 +127,7 @@ GF_Err dump_cover_art(GF_ISOFile *file, char *inName) sprintf(szName, "%s.%s", inName, (tag_len>>31) ? "png" : "jpg"); t = gf_f64_open(szName, "wb"); gf_fwrite(tag, tag_len & 0x7FFFFFFF, 1, t); - + fclose(t); return GF_OK; } @@ -147,7 +147,7 @@ GF_Err set_cover_art(GF_ISOFile *file, char *inName) tag = gf_malloc(sizeof(char) * tag_len); tag_len = (u32) fread(tag, sizeof(char), tag_len, t); fclose(t); - + ext = strrchr(inName, '.'); if (!stricmp(ext, ".png")) tag_len |= 0x80000000; e = gf_isom_apple_set_tag(file, GF_ISOM_ITUNE_COVER_ART, tag, tag_len); @@ -176,9 +176,9 @@ GF_Err dump_file_text(char *file, char *inName, u32 dump_mode, Bool do_log) load.fileName = file; load.ctx = ctx; load.swf_import_flags = swf_flags; - if (dump_mode == GF_SM_DUMP_SVG) { - load.swf_import_flags |= GF_SM_SWF_USE_SVG; - } + if (dump_mode == GF_SM_DUMP_SVG) { + load.swf_import_flags |= GF_SM_SWF_USE_SVG; + } load.swf_flatten_limit = swf_flatten_angle; ftype = get_file_type_by_ext(file); @@ -260,7 +260,7 @@ static void dump_stats(FILE *dump, GF_SceneStatistics *stats) for (i=0; inode_stats); i++) { GF_NodeStats *ptr = gf_list_get(stats->node_stats, i); fprintf(dump, "\n", ptr->name); - + switch (ptr->tag) { #ifndef GPAC_DISABLE_VRML case TAG_MPEG4_Bitmap: @@ -359,10 +359,10 @@ static void ReorderAU(GF_List *sample_list, GF_AUContext *au) for (i=0; itiming_sec > au->timing_sec) - /*set bifs first*/ - || ((ptr->timing_sec == au->timing_sec) && (ptr->owner->streamType < au->owner->streamType)) + /*time ordered*/ + (ptr->timing_sec > au->timing_sec) + /*set bifs first*/ + || ((ptr->timing_sec == au->timing_sec) && (ptr->owner->streamType < au->owner->streamType)) ) { gf_list_insert(sample_list, au, i); return; @@ -380,14 +380,14 @@ void dump_scene_stats(char *file, char *inName, u32 stat_level) char szBuf[1024]; GF_SceneManager *ctx; GF_SceneLoader load; - GF_StatManager *sm; + GF_StatManager *sm; GF_List *sample_list; GF_SceneGraph *scene_graph; dump = NULL; sm = NULL; sample_list = NULL; - + close = 0; scene_graph = gf_sg_new(); @@ -450,7 +450,7 @@ void dump_scene_stats(char *file, char *inName, u32 stat_level) count = gf_list_count(sample_list); for (i=0; icommands); j++) { GF_Command *com = gf_list_get(au->commands, j); /*stat level 2 - get command stats*/ @@ -485,7 +485,7 @@ void dump_scene_stats(char *file, char *inName, u32 stat_level) } -exit: +exit: if (sample_list) gf_list_del(sample_list); if (sm) gf_sm_stats_del(sm); gf_sm_del(ctx); @@ -593,8 +593,8 @@ void PrintNode(const char *name, u32 graph_type) tag = gf_node_x3d_type_by_class_name(name); std_name = "X3D"; #else - fprintf(stderr, "X3D node printing is not supported (X3D support disabled)\n"); - return; + fprintf(stderr, "X3D node printing is not supported (X3D support disabled)\n"); + return; #endif } else { tag = gf_node_mpeg4_type_by_class_name(name); @@ -629,13 +629,13 @@ void PrintNode(const char *name, u32 graph_type) tfirst = GF_NODE_RANGE_FIRST_MPEG4; tlast = GF_NODE_RANGE_LAST_MPEG4; } - for (i=tfirst; iDTS; cts = dts + (s32) samp->CTS_Offset; - fprintf(dump, "Sample %d\tDTS "LLD"\tCTS "LLD"\t%d\t%d", j+1, LLD_CAST dts, LLD_CAST cts, samp->dataLength, samp->IsRAP); - if (ctsdataLength, samp->IsRAP, offset); + if (ctsDTS; acts = adts + (s32) samp->CTS_Offset; - if (adts==dts) { fprintf(dump, " #SAME DTS USED!!!"); has_error = 1; } - if (acts==cts) { fprintf(dump, " #SAME CTS USED!!! "); has_error = 1; } + if (adts==dts) { + fprintf(dump, " #SAME DTS USED!!!"); + has_error = 1; + } + if (acts==cts) { + fprintf(dump, " #SAME CTS USED!!! "); + has_error = 1; + } gf_isom_sample_del(&samp); } @@ -875,108 +885,203 @@ void dump_file_timestamps(GF_ISOFile *file, char *inName) #ifndef GPAC_DISABLE_AV_PARSERS -static void dump_nalu(FILE *dump, char *ptr, u32 ptr_size, Bool is_svc, Bool is_hevc, AVCState *avc) + +static u32 read_nal_size_hdr(char *ptr, u32 nalh_size) +{ + u32 nal_size=0; + u32 v = nalh_size; + while (v) { + nal_size |= (u8) *ptr; + ptr++; + v-=1; + if (v) nal_size <<= 8; + } + return nal_size; +} + +static void dump_nalu(FILE *dump, char *ptr, u32 ptr_size, Bool is_svc, Bool is_hevc, AVCState *avc, u32 nalh_size) { + s32 res; u8 type; u8 dependency_id, quality_id, temporal_id; u8 track_ref_index; - u32 data_offset, idx; + s8 sample_offset; + u32 data_offset, idx, data_size; GF_BitStream *bs; - + if (is_hevc) { #ifndef GPAC_DISABLE_HEVC type = (ptr[0] & 0x7E) >> 1; fprintf(dump, "code=\"%d\" type=\"", type); switch (type) { - case GF_HEVC_NALU_SLICE_TRAIL_N: fputs("TRAIL_N slice segment", dump); break; - case GF_HEVC_NALU_SLICE_TRAIL_R: fputs("TRAIL_R slice segment", dump); break; - case GF_HEVC_NALU_SLICE_TSA_N: fputs("TSA_N slice segment", dump); break; - case GF_HEVC_NALU_SLICE_TSA_R: fputs("TSA_R slice segment", dump); break; - case GF_HEVC_NALU_SLICE_STSA_N: fputs("STSA_N slice segment", dump); break; - case GF_HEVC_NALU_SLICE_STSA_R: fputs("STSA_R slice segment", dump); break; - case GF_HEVC_NALU_SLICE_RADL_N: fputs("RADL_N slice segment", dump); break; - case GF_HEVC_NALU_SLICE_RADL_R: fputs("RADL_R slice segment", dump); break; - case GF_HEVC_NALU_SLICE_RASL_N: fputs("RASL_N slice segment", dump); break; - case GF_HEVC_NALU_SLICE_RASL_R: fputs("RASL_R slice segment", dump); break; - case GF_HEVC_NALU_SLICE_BLA_W_LP: fputs("Broken link access slice (W LP)", dump); break; - case GF_HEVC_NALU_SLICE_BLA_W_DLP: fputs("Broken link access slice (W DLP)", dump); break; - case GF_HEVC_NALU_SLICE_BLA_N_LP: fputs("Broken link access slice (N LP)", dump); break; - case GF_HEVC_NALU_SLICE_IDR_W_DLP: fputs("IDR slice (W DLP)", dump); break; - case GF_HEVC_NALU_SLICE_IDR_N_LP: fputs("IDR slice (N LP)", dump); break; - case GF_HEVC_NALU_SLICE_CRA: fputs("CRA slice", dump); break; - - case GF_HEVC_NALU_VID_PARAM: fputs("Video Parameter Set", dump); break; - case GF_HEVC_NALU_SEQ_PARAM: fputs("Sequence Parameter Set", dump); break; - case GF_HEVC_NALU_PIC_PARAM: fputs("Picture Parameter Set", dump); break; - case GF_HEVC_NALU_ACCESS_UNIT: fputs("AU Delimiter", dump); break; - case GF_HEVC_NALU_END_OF_SEQ: fputs("End of Sequence", dump); break; - case GF_HEVC_NALU_END_OF_STREAM: fputs("End of Stream", dump); break; - case GF_HEVC_NALU_FILLER_DATA: fputs("Filler Data", dump); break; - case GF_HEVC_NALU_SEI_PREFIX: fputs("SEI Prefix", dump); break; - case GF_HEVC_NALU_SEI_SUFFIX: fputs("SEI Suffix", dump); break; + case GF_HEVC_NALU_SLICE_TRAIL_N: + fputs("TRAIL_N slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_TRAIL_R: + fputs("TRAIL_R slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_TSA_N: + fputs("TSA_N slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_TSA_R: + fputs("TSA_R slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_STSA_N: + fputs("STSA_N slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_STSA_R: + fputs("STSA_R slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_RADL_N: + fputs("RADL_N slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_RADL_R: + fputs("RADL_R slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_RASL_N: + fputs("RASL_N slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_RASL_R: + fputs("RASL_R slice segment", dump); + break; + case GF_HEVC_NALU_SLICE_BLA_W_LP: + fputs("Broken link access slice (W LP)", dump); + break; + case GF_HEVC_NALU_SLICE_BLA_W_DLP: + fputs("Broken link access slice (W DLP)", dump); + break; + case GF_HEVC_NALU_SLICE_BLA_N_LP: + fputs("Broken link access slice (N LP)", dump); + break; + case GF_HEVC_NALU_SLICE_IDR_W_DLP: + fputs("IDR slice (W DLP)", dump); + break; + case GF_HEVC_NALU_SLICE_IDR_N_LP: + fputs("IDR slice (N LP)", dump); + break; + case GF_HEVC_NALU_SLICE_CRA: + fputs("CRA slice", dump); + break; + + case GF_HEVC_NALU_VID_PARAM: + fputs("Video Parameter Set", dump); + break; + case GF_HEVC_NALU_SEQ_PARAM: + fputs("Sequence Parameter Set", dump); + break; + case GF_HEVC_NALU_PIC_PARAM: + fputs("Picture Parameter Set", dump); + break; + case GF_HEVC_NALU_ACCESS_UNIT: + fputs("AU Delimiter", dump); + break; + case GF_HEVC_NALU_END_OF_SEQ: + fputs("End of Sequence", dump); + break; + case GF_HEVC_NALU_END_OF_STREAM: + fputs("End of Stream", dump); + break; + case GF_HEVC_NALU_FILLER_DATA: + fputs("Filler Data", dump); + break; + case GF_HEVC_NALU_SEI_PREFIX: + fputs("SEI Prefix", dump); + break; + case GF_HEVC_NALU_SEI_SUFFIX: + fputs("SEI Suffix", dump); + break; case 48: - fputs("HEVCAggregator", dump); + fputs("HEVCAggregator", dump); break; case 49: - fputs("HEVCExtractor", dump); - track_ref_index = (u8) ptr[4]; - data_offset = (ptr[6] << 12) + (ptr[7] << 8) + (ptr[8] << 4) + ptr[9]; - fprintf(dump, "\" track_ref_index=\"%d\" data_offset=\"%d", track_ref_index, data_offset); + fputs("HEVCExtractor", dump); + track_ref_index = (u8) ptr[2]; + sample_offset = (s8) ptr[3]; + data_offset = read_nal_size_hdr(&ptr[4], nalh_size); + data_size = read_nal_size_hdr(&ptr[4+nalh_size], nalh_size); + fprintf(dump, "\" track_ref_index=\"%d\" sample_offset=\"%d\" data_offset=\"%d\" data_size=\"%d", track_ref_index, sample_offset, data_offset, data_size); break; default: - fputs("UNKNOWN", dump); break; + fputs("UNKNOWN", dump); + break; } fputs("\"", dump); fprintf(dump, " layer_id=\"%d\" temporal_id=\"%d\"", ((ptr[0] & 0x1) << 5) | (ptr[1]>>3), (ptr[1] & 0x7) ); #endif //GPAC_DISABLE_HEVC return; - } - + } + bs = gf_bs_new(ptr, ptr_size, GF_BITSTREAM_READ); type = ptr[0] & 0x1F; fprintf(dump, "code=\"%d\" type=\"", type); + res = 0; switch (type) { - case GF_AVC_NALU_NON_IDR_SLICE: - gf_media_avc_parse_nalu(bs, ptr[0], avc); + case GF_AVC_NALU_NON_IDR_SLICE: + res = gf_media_avc_parse_nalu(bs, ptr[0], avc); fputs("Non IDR slice", dump); - fprintf(dump, "\" poc=\"%d", avc->s_info.poc); + + if (res>=0) + fprintf(dump, "\" poc=\"%d", avc->s_info.poc); break; - case GF_AVC_NALU_DP_A_SLICE: fputs("DP Type A slice", dump); break; - case GF_AVC_NALU_DP_B_SLICE: fputs("DP Type B slice", dump); break; - case GF_AVC_NALU_DP_C_SLICE: fputs("DP Type C slice", dump); break; - case GF_AVC_NALU_IDR_SLICE: - gf_media_avc_parse_nalu(bs, ptr[0], avc); + case GF_AVC_NALU_DP_A_SLICE: + fputs("DP Type A slice", dump); + break; + case GF_AVC_NALU_DP_B_SLICE: + fputs("DP Type B slice", dump); + break; + case GF_AVC_NALU_DP_C_SLICE: + fputs("DP Type C slice", dump); + break; + case GF_AVC_NALU_IDR_SLICE: + res = gf_media_avc_parse_nalu(bs, ptr[0], avc); fputs("IDR slice", dump); - fprintf(dump, "\" poc=\"%d", avc->s_info.poc); + if (res>=0) + fprintf(dump, "\" poc=\"%d", avc->s_info.poc); break; - case GF_AVC_NALU_SEI: fputs("SEI Message", dump); break; - case GF_AVC_NALU_SEQ_PARAM: + case GF_AVC_NALU_SEI: + fputs("SEI Message", dump); + break; + case GF_AVC_NALU_SEQ_PARAM: fputs("SequenceParameterSet", dump); idx = gf_media_avc_read_sps(ptr, ptr_size, avc, 0, NULL); assert (idx >= 0); fprintf(dump, "\" sps_id=\"%d", idx); break; - case GF_AVC_NALU_PIC_PARAM: + case GF_AVC_NALU_PIC_PARAM: fputs("PictureParameterSet", dump); idx = gf_media_avc_read_pps(ptr, ptr_size, avc); assert (idx >= 0); fprintf(dump, "\" pps_id=\"%d\" sps_id=\"%d", idx, avc->pps[idx].sps_id); break; - case GF_AVC_NALU_ACCESS_UNIT: fputs("AccessUnit delimiter", dump); break; - case GF_AVC_NALU_END_OF_SEQ: fputs("EndOfSequence", dump); break; - case GF_AVC_NALU_END_OF_STREAM: fputs("EndOfStream", dump); break; - case GF_AVC_NALU_FILLER_DATA: fputs("Filler data", dump); break; - case GF_AVC_NALU_SEQ_PARAM_EXT: fputs("SequenceParameterSetExtension", dump); break; - case GF_AVC_NALU_SVC_PREFIX_NALU: fputs("SVCPrefix", dump); break; - case GF_AVC_NALU_SVC_SUBSEQ_PARAM: - fputs("SVCSubsequenceParameterSet", dump); + case GF_AVC_NALU_ACCESS_UNIT: + fputs("AccessUnit delimiter", dump); + break; + case GF_AVC_NALU_END_OF_SEQ: + fputs("EndOfSequence", dump); + break; + case GF_AVC_NALU_END_OF_STREAM: + fputs("EndOfStream", dump); + break; + case GF_AVC_NALU_FILLER_DATA: + fputs("Filler data", dump); + break; + case GF_AVC_NALU_SEQ_PARAM_EXT: + fputs("SequenceParameterSetExtension", dump); + break; + case GF_AVC_NALU_SVC_PREFIX_NALU: + fputs("SVCPrefix", dump); + break; + case GF_AVC_NALU_SVC_SUBSEQ_PARAM: + fputs("SVCSubsequenceParameterSet", dump); idx = gf_media_avc_read_sps(ptr, ptr_size, avc, 1, NULL); assert (idx >= 0); fprintf(dump, "\" sps_id=\"%d", idx - GF_SVC_SSPS_ID_SHIFT); break; - case GF_AVC_NALU_SLICE_AUX: fputs("Auxiliary Slice", dump); break; + case GF_AVC_NALU_SLICE_AUX: + fputs("Auxiliary Slice", dump); + break; - case GF_AVC_NALU_SVC_SLICE: + case GF_AVC_NALU_SVC_SLICE: gf_media_avc_parse_nalu(bs, ptr[0], avc); fputs(is_svc ? "SVCSlice" : "CodedSliceExtension", dump); dependency_id = (ptr[2] & 0x70) >> 4; @@ -985,18 +1090,26 @@ static void dump_nalu(FILE *dump, char *ptr, u32 ptr_size, Bool is_svc, Bool is_ fprintf(dump, "\" dependency_id=\"%d\" quality_id=\"%d\" temporal_id=\"%d", dependency_id, quality_id, temporal_id); fprintf(dump, "\" poc=\"%d", avc->s_info.poc); break; - case 30: fputs("SVCAggregator", dump); break; + case 30: + fputs("SVCAggregator", dump); + break; case 31: - fputs("SVCExtractor", dump); + fputs("SVCExtractor", dump); track_ref_index = (u8) ptr[4]; - data_offset = (ptr[6] << 12) + (ptr[7] << 8) + (ptr[8] << 4) + ptr[9]; - fprintf(dump, "\" track_ref_index=\"%d\" data_offset=\"%d", track_ref_index, data_offset); + sample_offset = (s8) ptr[5]; + data_offset = read_nal_size_hdr(&ptr[6], nalh_size); + data_size = read_nal_size_hdr(&ptr[6+nalh_size], nalh_size); + fprintf(dump, "\" track_ref_index=\"%d\" sample_offset=\"%d\" data_offset=\"%d\" data_size=\"%d\"", track_ref_index, sample_offset, data_offset, data_size); break; default: - fputs("UNKNOWN", dump); break; + fputs("UNKNOWN", dump); + break; } fputs("\"", dump); + if (res<0) + fprintf(dump, " status=\"error decoding slice\""); + if (bs) gf_bs_del(bs); } #endif @@ -1040,6 +1153,12 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) svccfg = gf_isom_svc_config_get(file, track, 1); hevccfg = gf_isom_hevc_config_get(file, track, 1); shvccfg = gf_isom_shvc_config_get(file, track, 1); + //for tile tracks the hvcC is stored in the 'tbas' track + if (!hevccfg && gf_isom_get_reference_count(file, track, GF_4CC('t','b','a','s'))) { + u32 tk = 0; + gf_isom_get_reference(file, track, GF_4CC('t','b','a','s'), 1, &tk); + hevccfg = gf_isom_hevc_config_get(file, tk, 1); + } fprintf(dump, " \n"); #define DUMP_ARRAY(arr, name)\ @@ -1047,11 +1166,11 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) for (i=0; isize);\ - dump_nalu(dump, slc->data, slc->size, svccfg ? 1 : 0, is_hevc, &avc);\ + dump_nalu(dump, slc->data, slc->size, svccfg ? 1 : 0, is_hevc, &avc, nalh_size);\ fprintf(dump, "/>\n");\ }\ }\ - + nalh_size = 0; if (avccfg) { @@ -1079,7 +1198,7 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) DUMP_ARRAY(ar->nalus, "HEVCPPSArray") } else if (ar->type==GF_HEVC_NALU_VID_PARAM) { DUMP_ARRAY(ar->nalus, "HEVCVPSArray") - } else { + } else { DUMP_ARRAY(ar->nalus, "HEVCUnknownPSArray") } } @@ -1098,7 +1217,7 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) DUMP_ARRAY(ar->nalus, "HEVCPPSArray") } else if (ar->type==GF_HEVC_NALU_VID_PARAM) { DUMP_ARRAY(ar->nalus, "HEVCVPSArray") - } else { + } else { DUMP_ARRAY(ar->nalus, "HEVCUnknownPSArray") } } @@ -1121,7 +1240,7 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) gf_isom_get_reference_ID(file, track, GF_ISOM_REF_SCAL, i, &refTrackID); fprintf(dump, " \n", i, refTrackID); } - + fprintf(dump, " \n"); } @@ -1137,8 +1256,8 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) cts = dts + (s32) samp->CTS_Offset; fprintf(dump, " \n", i+1, dts, cts, samp->dataLength, samp->IsRAP); - if (cts\n"); - + if (cts\n"); + idx = 1; ptr = samp->data; size = samp->dataLength; @@ -1155,21 +1274,16 @@ void dump_file_nal(GF_ISOFile *file, u32 trackID, char *inName) } } while (size) { - u32 v = nalh_size; - nal_size = 0; - while (v) { - nal_size |= (u8) *ptr; - ptr++; - v-=1; - if (v) nal_size<<=8; - } + nal_size = read_nal_size_hdr(ptr, nalh_size); + ptr += nalh_size; + if (nalh_size + nal_size > size) { fprintf(dump, " \n", idx, nal_size, size); break; } else { fprintf(dump, " \n"); } @@ -1259,7 +1373,7 @@ void dump_timed_text_track(GF_ISOFile *file, u32 trackID, char *inName, Bool is_ } if (inName) { - if (is_convert) + if (is_convert) sprintf(szBuf, "%s.%s", inName, (dump_type==2) ? "svg" : ((dump_type==1) ? "srt" : "ttxt") ) ; else sprintf(szBuf, "%s_%d_text.%s", inName, trackID, (dump_type==2) ? "svg" : ((dump_type==1) ? "srt" : "ttxt") ); @@ -1380,15 +1494,15 @@ GF_Err dump_chapters(GF_ISOFile *file, char *inName, Bool dump_ogg) t = gf_f64_open(szName, "wt"); if (!t) return GF_IO_ERR; - - for (i=0; i0))); switch (gf_isom_has_meta_xml(file, root_meta, tk_num)) { - case 1: fprintf(stderr, "Meta has XML resource\n"); break; - case 2: fprintf(stderr, "Meta has BinaryXML resource\n"); break; + case 1: + fprintf(stderr, "Meta has XML resource\n"); + break; + case 2: + fprintf(stderr, "Meta has BinaryXML resource\n"); + break; } if (primary_id) { - fprintf(stderr, "Primary Item - ID %d\n", primary_id); - } + fprintf(stderr, "Primary Item - ID %d\n", primary_id); + } for (i=0; idecoderConfig->streamType); if (st) { fprintf(stderr, "MPEG-4 Config%s%s Stream - ObjectTypeIndication 0x%02x\n", - full_dump ? "\n\t" : ": ", st, esd->decoderConfig->objectTypeIndication); + full_dump ? "\n\t" : ": ", st, esd->decoderConfig->objectTypeIndication); } else { fprintf(stderr, "MPEG-4 Config%sStream Type 0x%02x - ObjectTypeIndication 0x%02x\n", - full_dump ? "\n\t" : ": ", esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication); + full_dump ? "\n\t" : ": ", esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication); } - if (esd->decoderConfig->streamType==GF_STREAM_OD) + if (esd->decoderConfig->streamType==GF_STREAM_OD) is_od_track=1; if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) { @@ -1581,8 +1700,8 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) #ifndef GPAC_DISABLE_AV_PARSERS if (!esd->decoderConfig->decoderSpecificInfo) { #else - gf_isom_get_visual_info(file, trackNum, 1, &w, &h); - fprintf(stderr, "MPEG-4 Visual Size %d x %d\n", w, h); + gf_isom_get_visual_info(file, trackNum, 1, &w, &h); + fprintf(stderr, "MPEG-4 Visual Size %d x %d\n", w, h); #endif fprintf(stderr, "\tNon-compliant MPEG-4 Visual track: video_object_layer infos not found in sample description\n"); #ifndef GPAC_DISABLE_AV_PARSERS @@ -1654,8 +1773,8 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) #endif /*GPAC_DISABLE_AV_PARSERS*/ } else if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_HEVC) - || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SHVC) - ) { + || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SHVC) + ) { #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_HEVC) HEVCState hevc_state; GF_HEVCConfig *hevccfg, *shvccfg; @@ -1669,9 +1788,22 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_HEVC) hevccfg = gf_isom_hevc_config_get(file, trackNum, 1); shvccfg = gf_isom_shvc_config_get(file, trackNum, 1); - if (!hevccfg && !shvccfg) { + + if (msub_type==GF_ISOM_SUBTYPE_HVT1) { + const char *data; + u32 size; + u32 is_default, x,y,w,h, id, independent; + Bool full_frame; + if (gf_isom_get_tile_info(file, trackNum, 1, &is_default, &id, &independent, &full_frame, &x, &y, &w, &h)) { + fprintf(stderr, "\tHEVC Tile - ID %d independent %d (x,y,w,h)=%d,%d,%d,%d \n", id, independent, x, y, w, h); + } else if (gf_isom_get_sample_group_info(file, trackNum, 1, GF_4CC('t','r','i','f'), &is_default, &data, &size)) { + fprintf(stderr, "\tHEVC Tile track containing a tile set\n"); + } else { + fprintf(stderr, "\tHEVC Tile track without tiling info\n"); + } + } else if (!hevccfg && !shvccfg) { fprintf(stderr, "\n\n\tNon-compliant HEVC track: No hvcC or shcC found in sample description\n"); - } + } if (hevccfg) { dump_hevc_track_info(file, trackNum, hevccfg, &hevc_state); gf_odf_hevc_cfg_del(hevccfg); @@ -1682,7 +1814,7 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) gf_odf_hevc_cfg_del(shvccfg); } #endif /*GPAC_DISABLE_AV_PARSERS && defined(GPAC_DISABLE_HEVC)*/ - } + } /*OGG media*/ else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_MEDIA_OGG) { @@ -1736,7 +1868,7 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) if (e) fprintf(stderr, "Corrupted AAC Config\n"); else { fprintf(stderr, "%s - %d Channel(s) - SampleRate %d", gf_m4a_object_type_name(a_cfg.base_object_type), a_cfg.nb_chan, a_cfg.base_sr); - if (is_mp2) fprintf(stderr, " (MPEG-2 Signaling)"); + if (is_mp2) fprintf(stderr, " (MPEG-2 Signaling)"); if (a_cfg.has_sbr) fprintf(stderr, " - SBR SampleRate %d", a_cfg.sbr_sr); if (a_cfg.has_ps) fprintf(stderr, " - PS"); fprintf(stderr, "\n"); @@ -1756,11 +1888,11 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) oti = GF_4CC((u8)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]); if (full_dump) fprintf(stderr, "\t"); fprintf(stderr, "%s Audio - %d Channel(s) - SampleRate %d - Layer %d\n", - gf_mp3_version_name(oti), - gf_mp3_num_channels(oti), - gf_mp3_sampling_rate(oti), - gf_mp3_layer(oti) - ); + gf_mp3_version_name(oti), + gf_mp3_num_channels(oti), + gf_mp3_sampling_rate(oti), + gf_mp3_layer(oti) + ); gf_isom_sample_del(&samp); } else { fprintf(stderr, "\n\tError fetching sample: %s\n", gf_error_to_string(gf_isom_last_error(file)) ); @@ -1781,16 +1913,22 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) else szName = "Unknown"; fprintf(stderr, "Ogg/%s audio / GPAC Mux - Sample Rate %d - %d channel(s)\n", szName, sr, nb_ch); } + break; + case GPAC_OTI_AUDIO_EVRC_VOICE: + fprintf(stderr, "EVRC Audio - Sample Rate 8000 - 1 channel\n"); + break; + case GPAC_OTI_AUDIO_SMV_VOICE: + fprintf(stderr, "SMV Audio - Sample Rate 8000 - 1 channel\n"); + break; + case GPAC_OTI_AUDIO_13K_VOICE: + fprintf(stderr, "QCELP Audio - Sample Rate 8000 - 1 channel\n"); break; - case GPAC_OTI_AUDIO_EVRC_VOICE: fprintf(stderr, "EVRC Audio - Sample Rate 8000 - 1 channel\n"); break; - case GPAC_OTI_AUDIO_SMV_VOICE: fprintf(stderr, "SMV Audio - Sample Rate 8000 - 1 channel\n"); break; - case GPAC_OTI_AUDIO_13K_VOICE: fprintf(stderr, "QCELP Audio - Sample Rate 8000 - 1 channel\n"); break; /*packetVideo hack for EVRC...*/ - case 0xD1: + case 0xD1: if (esd->decoderConfig->decoderSpecificInfo && (esd->decoderConfig->decoderSpecificInfo->dataLength==8) - && !strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "pvmm", 4)) { + && !strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "pvmm", 4)) { if (full_dump) fprintf(stderr, "\t"); - fprintf(stderr, "EVRC Audio (PacketVideo Mux) - Sample Rate 8000 - 1 channel\n"); + fprintf(stderr, "EVRC Audio (PacketVideo Mux) - Sample Rate 8000 - 1 channel\n"); } break; } @@ -1798,27 +1936,27 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) else if (esd->decoderConfig->streamType==GF_STREAM_SCENE) { if (esd->decoderConfig->objectTypeIndication<=4) { GF_BIFSConfig *b_cfg = gf_odf_get_bifs_config(esd->decoderConfig->decoderSpecificInfo, esd->decoderConfig->objectTypeIndication); - fprintf(stderr, "BIFS Scene description - %s stream\n", b_cfg->elementaryMasks ? "Animation" : "Command"); + fprintf(stderr, "BIFS Scene description - %s stream\n", b_cfg->elementaryMasks ? "Animation" : "Command"); if (full_dump && !b_cfg->elementaryMasks) { - fprintf(stderr, "\tWidth %d Height %d Pixel Metrics %s\n", b_cfg->pixelWidth, b_cfg->pixelHeight, b_cfg->pixelMetrics ? "yes" : "no"); + fprintf(stderr, "\tWidth %d Height %d Pixel Metrics %s\n", b_cfg->pixelWidth, b_cfg->pixelHeight, b_cfg->pixelMetrics ? "yes" : "no"); } gf_odf_desc_del((GF_Descriptor *)b_cfg); } else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_AFX) { u8 tag = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data[0] : 0xFF; const char *afxtype = gf_afx_get_type_description(tag); - fprintf(stderr, "AFX Stream - type %s (%d)\n", afxtype, tag); + fprintf(stderr, "AFX Stream - type %s (%d)\n", afxtype, tag); } else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_FONT) { - fprintf(stderr, "Font Data stream\n"); + fprintf(stderr, "Font Data stream\n"); } else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_LASER) { GF_LASERConfig l_cfg; gf_odf_get_laser_config(esd->decoderConfig->decoderSpecificInfo, &l_cfg); - fprintf(stderr, "LASER Stream - %s\n", l_cfg.newSceneIndicator ? "Full Scene" : "Scene Segment"); + fprintf(stderr, "LASER Stream - %s\n", l_cfg.newSceneIndicator ? "Full Scene" : "Scene Segment"); } else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_TEXT_MPEG4) { - fprintf(stderr, "MPEG-4 Streaming Text stream\n"); + fprintf(stderr, "MPEG-4 Streaming Text stream\n"); } else if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) { - fprintf(stderr, "Synthetized Texture stream stream\n"); + fprintf(stderr, "Synthetized Texture stream stream\n"); } else { - fprintf(stderr, "Unknown Systems stream OTI %d\n", esd->decoderConfig->objectTypeIndication); + fprintf(stderr, "Unknown Systems stream OTI %d\n", esd->decoderConfig->objectTypeIndication); } } @@ -1957,7 +2095,7 @@ void DumpTrackInfo(GF_ISOFile *file, u32 trackID, Bool full_dump) } #ifndef GPAC_DISABLE_ISOM_HINTING refCount = gf_isom_get_payt_count(file, trackNum); - for (i=0;i0) && (tag <= (sizeof(ID3v1Genres)/sizeof(const char *)) )) { @@ -2122,6 +2260,7 @@ static const char *id3_get_genre(u32 tag) u32 id3_get_genre_tag(const char *name) { u32 i, count = sizeof(ID3v1Genres)/sizeof(const char *); + if (!name) return 0; for (i=0; ihas_seen_pat = 1; if (dumper->timestamps_info_file) { @@ -2349,7 +2488,7 @@ static void on_m2ts_dump_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) prog = (GF_M2TS_Program*)par; if (gf_list_count(ts->programs)>1 && prog->number!=dumper->prog_number) break; - + count = gf_list_count(prog->streams); GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Program number %d found - %d streams:\n", prog->number, count)); @@ -2363,7 +2502,7 @@ static void on_m2ts_dump_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("\tPID %d: %s ", pes->pid, gf_m2ts_get_stream_name(pes->stream_type) )); if (pes->mpeg4_es_id) GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (" - MPEG-4 ES ID %d", pes->mpeg4_es_id)); GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("\n")); - } + } } if (dumper->timestamps_info_file) { fprintf(dumper->timestamps_info_file, "%u\t%d\n", ts->pck_number, prog->pmt_pid); @@ -2423,16 +2562,16 @@ static void on_m2ts_dump_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) if (pes->last_pcr_value && pes->before_last_pcr_value_pck_number && pes->last_pcr_value > pes->before_last_pcr_value) { u32 delta_pcr_pck_num = pes->last_pcr_value_pck_number - pes->before_last_pcr_value_pck_number; u32 delta_pts_pcr_pck_num = pes->pes_start_packet_number - pes->last_pcr_value_pck_number; - u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; + u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; if ((pes->pes_start_packet_number > pes->last_pcr_value_pck_number) - && (pes->last_pcr_value > pes->before_last_pcr_value)) { - - pes->last_pcr_value = pes->before_last_pcr_value; + && (pes->last_pcr_value > pes->before_last_pcr_value)) { + + pes->last_pcr_value = pes->before_last_pcr_value; } /* we can compute the interpolated pcr value for the packet containing the PES header */ interpolated_pcr_value = pes->last_pcr_value + (u64)((delta_pcr_value*delta_pts_pcr_pck_num*1.0)/delta_pcr_pck_num); } - + if (dumper->timestamps_info_file) { Double diff; fprintf(dumper->timestamps_info_file, "%u\t%d\t", pck->stream->pes_start_packet_number, pck->stream->pid); @@ -2465,32 +2604,32 @@ static void on_m2ts_dump_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) break; case GF_M2TS_EVT_SL_PCK: #if 0 - { - GF_M2TS_SL_PCK *sl_pck = par; - if (dumper->pes_out && (dumper->dump_pid == sl_pck->stream->pid)) { - GF_SLHeader header; - u32 header_len; - if (sl_pck->stream->mpeg4_es_id) { - GF_ESD *esd = ((GF_M2TS_PES*)sl_pck->stream)->esd; - if (!dumper->is_info_dumped) { - if (esd->decoderConfig->decoderSpecificInfo) gf_fwrite(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 1, dumper->pes_out_info); - dumper->is_info_dumped = 1; - fprintf(dumper->pes_out_nhml, "pes_out_nhml, "timeScale=\"%d\" ", esd->slConfig->timestampResolution); - fprintf(dumper->pes_out_nhml, "streamType=\"%d\" ", esd->decoderConfig->streamType); - fprintf(dumper->pes_out_nhml, "objectTypeIndication=\"%d\" ", esd->decoderConfig->objectTypeIndication); - if (esd->decoderConfig->decoderSpecificInfo) fprintf(dumper->pes_out_nhml, "specificInfoFile=\"%s\" ", dumper->info); - fprintf(dumper->pes_out_nhml, "baseMediaFile=\"%s\" ", dumper->dump); - fprintf(dumper->pes_out_nhml, "inRootOD=\"yes\">\n"); - } - gf_sl_depacketize(esd->slConfig, &header, sl_pck->data, sl_pck->data_len, &header_len); - gf_fwrite(sl_pck->data+header_len, sl_pck->data_len-header_len, 1, dumper->pes_out); - fprintf(dumper->pes_out_nhml, "\n", LLD_CAST header.decodingTimeStamp, sl_pck->data_len-header_len, (header.randomAccessPointFlag?"yes":"no")); + { + GF_M2TS_SL_PCK *sl_pck = par; + if (dumper->pes_out && (dumper->dump_pid == sl_pck->stream->pid)) { + GF_SLHeader header; + u32 header_len; + if (sl_pck->stream->mpeg4_es_id) { + GF_ESD *esd = ((GF_M2TS_PES*)sl_pck->stream)->esd; + if (!dumper->is_info_dumped) { + if (esd->decoderConfig->decoderSpecificInfo) gf_fwrite(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 1, dumper->pes_out_info); + dumper->is_info_dumped = 1; + fprintf(dumper->pes_out_nhml, "pes_out_nhml, "timeScale=\"%d\" ", esd->slConfig->timestampResolution); + fprintf(dumper->pes_out_nhml, "streamType=\"%d\" ", esd->decoderConfig->streamType); + fprintf(dumper->pes_out_nhml, "objectTypeIndication=\"%d\" ", esd->decoderConfig->objectTypeIndication); + if (esd->decoderConfig->decoderSpecificInfo) fprintf(dumper->pes_out_nhml, "specificInfoFile=\"%s\" ", dumper->info); + fprintf(dumper->pes_out_nhml, "baseMediaFile=\"%s\" ", dumper->dump); + fprintf(dumper->pes_out_nhml, "inRootOD=\"yes\">\n"); } + gf_sl_depacketize(esd->slConfig, &header, sl_pck->data, sl_pck->data_len, &header_len); + gf_fwrite(sl_pck->data+header_len, sl_pck->data_len-header_len, 1, dumper->pes_out); + fprintf(dumper->pes_out_nhml, "\n", LLD_CAST header.decodingTimeStamp, sl_pck->data_len-header_len, (header.randomAccessPointFlag?"yes":"no")); } } + } #endif - break; + break; } } diff --git a/applications/mp4box/fileimport.c b/applications/mp4box/fileimport.c index 9099ddc..b97bdf7 100644 --- a/applications/mp4box/fileimport.c +++ b/applications/mp4box/fileimport.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,7 +47,7 @@ #include -typedef struct +typedef struct { const char *root_file; const char *dir; @@ -98,13 +98,27 @@ void convert_file_info(char *inName, u32 trackID) else fprintf(stderr, "Track type: "); switch (import.tk_info[i].type) { - case GF_ISOM_MEDIA_VISUAL: fprintf(stderr, "Video (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - case GF_ISOM_MEDIA_AUDIO: fprintf(stderr, "Audio (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - case GF_ISOM_MEDIA_TEXT: fprintf(stderr, "Text (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - case GF_ISOM_MEDIA_SCENE: fprintf(stderr, "Scene (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - case GF_ISOM_MEDIA_OD: fprintf(stderr, "OD (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - case GF_ISOM_MEDIA_META: fprintf(stderr, "Metadata (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); break; - default: fprintf(stderr, "Other (4CC: %s)", gf_4cc_to_str(import.tk_info[i].type)); break; + case GF_ISOM_MEDIA_VISUAL: + fprintf(stderr, "Video (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + case GF_ISOM_MEDIA_AUDIO: + fprintf(stderr, "Audio (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + case GF_ISOM_MEDIA_TEXT: + fprintf(stderr, "Text (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + case GF_ISOM_MEDIA_SCENE: + fprintf(stderr, "Scene (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + case GF_ISOM_MEDIA_OD: + fprintf(stderr, "OD (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + case GF_ISOM_MEDIA_META: + fprintf(stderr, "Metadata (%s)", gf_4cc_to_str(import.tk_info[i].media_type)); + break; + default: + fprintf(stderr, "Other (4CC: %s)", gf_4cc_to_str(import.tk_info[i].type)); + break; } if (import.tk_info[i].lang) fprintf(stderr, " - lang %s", gf_4cc_to_str(import.tk_info[i].lang)); @@ -126,10 +140,10 @@ void convert_file_info(char *inName, u32 trackID) fprintf(stderr, "\n"); if (!trackID) continue; - if ((import.tk_info[i].type==GF_ISOM_MEDIA_VISUAL) - && import.tk_info[i].video_info.width - && import.tk_info[i].video_info.height - ) { + if ((import.tk_info[i].type==GF_ISOM_MEDIA_VISUAL) + && import.tk_info[i].video_info.width + && import.tk_info[i].video_info.height + ) { fprintf(stderr, "Source: %s %dx%d", gf_4cc_to_str(import.tk_info[i].media_type), import.tk_info[i].video_info.width, import.tk_info[i].video_info.height); if (import.tk_info[i].video_info.FPS) fprintf(stderr, " @ %g FPS", import.tk_info[i].video_info.FPS); if (import.tk_info[i].video_info.par) fprintf(stderr, " PAR: %d:%d", import.tk_info[i].video_info.par >> 16, import.tk_info[i].video_info.par & 0xFFFF); @@ -140,7 +154,7 @@ void convert_file_info(char *inName, u32 trackID) } else { fprintf(stderr, "Source: %s\n", gf_4cc_to_str(import.tk_info[i].media_type)); } - + fprintf(stderr, "\nImport Capabilities:\n"); if (import.tk_info[i].flags & GF_IMPORT_USE_DATAREF) fprintf(stderr, "\tCan use data referencing\n"); @@ -197,7 +211,7 @@ GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double forc new_timescale = 1; rescale = 0; text_layout = 0; - /*0: merge all + /*0: merge all 1: split base and all SVC in two tracks 2: split all base and SVC layers in dedicated tracks */ @@ -320,7 +334,7 @@ GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double forc } else if (!strnicmp(ext+1, "hdlr=", 5)) handler = GF_4CC(ext[6], ext[7], ext[8], ext[9]); - + else if (!strnicmp(ext+1, "layout=", 7)) { if ( sscanf(ext+8, "%dx%dx%dx%d", &tw, &th, &tx, &ty)==4) { track_layout = 1; @@ -368,8 +382,8 @@ GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double forc } /*unrecognized, assume name has colon in it*/ else { - ext = ext2; - continue; + ext = ext2; + continue; } if (ext2) ext2[0] = ':'; @@ -384,7 +398,7 @@ GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double forc import.duration = (u32) (atof(ext+1) * 1000); ext[0] = 0; } - + /*select switches for av containers import*/ do_audio = do_video = 0; track_id = prog_id = 0; @@ -405,7 +419,7 @@ GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double forc else if (!strnicmp(ext, "video", 5)) do_video = 1; else if (!strnicmp(ext, "trackID=", 8)) track_id = atoi(&ext[8]); else if (!strnicmp(ext, "PID=", 4)) track_id = atoi(&ext[4]); - else if (!strnicmp(ext, "program=", 8)) { + else if (!strnicmp(ext, "program=", 8)) { for (i=0; istop_state) + + if (tki->stop_state) continue; - if (tki->last_sample==tki->sample_count) + if (tki->last_sample==tki->sample_count) continue; - + /*get sample info, see if we need to check it (basic de-interleaver)*/ dts = gf_isom_get_sample_dts(mp4, tki->tk, tki->last_sample+1); @@ -1070,7 +1086,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, if (e==GF_EOS) is_last = 1; if (next_rap) { - if (!next_rap->IsRAP) + if (!next_rap->IsRAP) is_last = 1; gf_isom_sample_del(&next_rap); } @@ -1085,7 +1101,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, fprintf(stderr, "Error cloning track %d sample %d\n", tki->tk, tki->last_sample); goto err_exit; } - + tki->next_sample_is_rap = 0; if (rap_split && tki->has_non_raps) { if ( gf_isom_get_sample_sync(mp4, tki->tk, tki->last_sample+1)) @@ -1100,7 +1116,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, if (split_size_kb) { u64 est_size = gf_isom_estimate_size(dest); /*while below desired size keep importing*/ - if (est_sizelastDTS; time /= tki->time_scale; - if (size_exceeded - || (tki->last_sample==tki->sample_count) - || (!tki->can_duplicate && (time>file_split_dur)) - || (rap_split && tki->has_non_raps && tki->next_sample_is_rap) - ) { + if (size_exceeded + || (tki->last_sample==tki->sample_count) + || (!tki->can_duplicate && (time>file_split_dur)) + || (rap_split && tki->has_non_raps && tki->next_sample_is_rap) + ) { nb_over++; tki->stop_state = 1; if (tki->last_samplesample_count) @@ -1140,7 +1156,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, tki->stop_state = 1; } } - if (!nb_add && (!max_dts || (tki->lastDTS <= 1 + (u64) (tki->time_scale*max_dts) ))) + if (!nb_add && (!max_dts || (tki->lastDTS <= 1 + (u64) (tki->time_scale*max_dts) ))) tki->first_sample_done = 0; } if (nb_over==nb_tk) do_add = 0; @@ -1160,7 +1176,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, continue; } - //if (tki->lastDTS) + //if (tki->lastDTS) { //time = (Double) (s64) tki->lastDTS; time = (Double) (s64) ( gf_isom_get_sample_dts(mp4, tki->tk, tki->last_sample+1) - tki->firstDTS); @@ -1289,7 +1305,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, for (j=0; jtk, j+1, &editTime, &segDur, &MediaTime, &mode); if (!j && (mode!=GF_ISOM_EDIT_EMPTY) ) { fprintf(stderr, "Warning: Edit list doesn't look like a track delay scheme - ignoring\n"); @@ -1297,7 +1313,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, } if (mode==GF_ISOM_EDIT_NORMAL) { segDur = new_track_dur; - } + } gf_isom_set_edit_segment(dest, tki->dst_tk, editTime, segDur, MediaTime, mode); } } @@ -1371,10 +1387,10 @@ static u32 merge_avc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 s { GF_AVCConfig *avc_src, *avc_dst; u32 dst_tk = gf_isom_get_track_by_id(dest, tk_id); - + avc_src = gf_isom_avc_config_get(orig, src_track, 1); avc_dst = gf_isom_avc_config_get(dest, dst_tk, 1); - + if (avc_src->AVCLevelIndication!=avc_dst->AVCLevelIndication) { dst_tk = 0; } else if (avc_src->AVCProfileIndication!=avc_dst->AVCProfileIndication) { @@ -1383,10 +1399,10 @@ static u32 merge_avc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 s else { /*rewrite all samples if using different NALU size*/ if (avc_src->nal_unit_size > avc_dst->nal_unit_size) { - gf_media_avc_rewrite_samples(dest, dst_tk, 8*avc_dst->nal_unit_size, 8*avc_src->nal_unit_size); + gf_media_avc_rewrite_samples(dest, dst_tk, 8*avc_dst->nal_unit_size, 8*avc_src->nal_unit_size); avc_dst->nal_unit_size = avc_src->nal_unit_size; } else if (avc_src->nal_unit_size < avc_dst->nal_unit_size) { - gf_media_avc_rewrite_samples(orig, src_track, 8*avc_src->nal_unit_size, 8*avc_dst->nal_unit_size); + gf_media_avc_rewrite_samples(orig, src_track, 8*avc_src->nal_unit_size, 8*avc_dst->nal_unit_size); } /*merge PS*/ @@ -1394,7 +1410,7 @@ static u32 merge_avc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 s dst_tk = 0; if (!merge_parameter_set(avc_src->pictureParameterSets, avc_dst->pictureParameterSets, "PPS")) dst_tk = 0; - + gf_isom_avc_config_update(dest, dst_tk, 1, avc_dst); } @@ -1418,7 +1434,7 @@ static u32 merge_hevc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 u32 i; GF_HEVCConfig *hevc_src, *hevc_dst; u32 dst_tk = gf_isom_get_track_by_id(dest, tk_id); - + hevc_src = gf_isom_hevc_config_get(orig, src_track, 1); hevc_dst = gf_isom_hevc_config_get(dest, dst_tk, 1); @@ -1428,10 +1444,10 @@ static u32 merge_hevc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 else { /*rewrite all samples if using different NALU size*/ if (hevc_src->nal_unit_size > hevc_dst->nal_unit_size) { - gf_media_avc_rewrite_samples(dest, dst_tk, 8*hevc_dst->nal_unit_size, 8*hevc_src->nal_unit_size); + gf_media_avc_rewrite_samples(dest, dst_tk, 8*hevc_dst->nal_unit_size, 8*hevc_src->nal_unit_size); hevc_dst->nal_unit_size = hevc_src->nal_unit_size; } else if (hevc_src->nal_unit_size < hevc_dst->nal_unit_size) { - gf_media_avc_rewrite_samples(orig, src_track, 8*hevc_src->nal_unit_size, 8*hevc_dst->nal_unit_size); + gf_media_avc_rewrite_samples(orig, src_track, 8*hevc_src->nal_unit_size, 8*hevc_dst->nal_unit_size); } /*merge PS*/ @@ -1447,7 +1463,7 @@ static u32 merge_hevc_config(GF_ISOFile *dest, u32 tk_id, GF_ISOFile *orig, u32 } } } - + gf_isom_hevc_config_update(dest, dst_tk, 1, hevc_dst); } @@ -1481,14 +1497,14 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou Double aligned_to_DTS = 0; if (strchr(fileName, '*')) return cat_multiple_files(dest, fileName, import_flags, force_fps, frames_per_sample, tmp_dir, force_cat, align_timelines, allow_add_in_command); - + multi_cat = allow_add_in_command ? strchr(fileName, '+') : NULL; if (multi_cat) { multi_cat[0] = 0; multi_cat = &multi_cat[1]; } opts = strchr(fileName, ':'); - if (opts && (opts[1]=='\\')) + if (opts && (opts[1]=='\\')) opts = strchr(fileName, ':'); e = GF_OK; @@ -1508,7 +1524,7 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou while (multi_cat) { char *sep = strchr(multi_cat, '+'); if (sep) sep[0] = 0; - + e = import_file(orig, multi_cat, import_flags, force_fps, frames_per_sample); if (e) { gf_isom_delete(orig); @@ -1553,7 +1569,7 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou fprintf(stderr, "No suitable media tracks to cat in %s - skipping\n", fileName); goto err_exit; } - + dest_orig_dur = (Double) (s64) gf_isom_get_duration(dest); if (!gf_isom_get_timescale(dest)) { gf_isom_set_timescale(dest, gf_isom_get_timescale(orig)); @@ -1661,7 +1677,7 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou /*if not forcing cat, check the media codec config is the same*/ if (!gf_isom_is_same_sample_description(orig, i+1, 0, dest, dst_tk, 0)) { dst_tk = 0; - } + } /*we force the same visual resolution*/ else if (mtype==GF_ISOM_MEDIA_VISUAL) { u32 w, h, ow, oh; @@ -1674,17 +1690,17 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou if (!dst_tk) { /*merge AVC config if possible*/ - if ((stype == GF_ISOM_SUBTYPE_AVC_H264) - || (stype == GF_ISOM_SUBTYPE_AVC2_H264) - || (stype == GF_ISOM_SUBTYPE_AVC3_H264) - || (stype == GF_ISOM_SUBTYPE_AVC4_H264) ) { + if ((stype == GF_ISOM_SUBTYPE_AVC_H264) + || (stype == GF_ISOM_SUBTYPE_AVC2_H264) + || (stype == GF_ISOM_SUBTYPE_AVC3_H264) + || (stype == GF_ISOM_SUBTYPE_AVC4_H264) ) { dst_tk = merge_avc_config(dest, tk_id, orig, i+1, force_cat); } /*merge HEVC config if possible*/ - else if ((stype == GF_ISOM_SUBTYPE_HVC1) - || (stype == GF_ISOM_SUBTYPE_HEV1) - || (stype == GF_ISOM_SUBTYPE_HVC2) - || (stype == GF_ISOM_SUBTYPE_HEV2)) { + else if ((stype == GF_ISOM_SUBTYPE_HVC1) + || (stype == GF_ISOM_SUBTYPE_HEV1) + || (stype == GF_ISOM_SUBTYPE_HVC2) + || (stype == GF_ISOM_SUBTYPE_HEV2)) { dst_tk = merge_hevc_config(dest, tk_id, orig, i+1, force_cat); } } @@ -1703,11 +1719,11 @@ GF_Err cat_isomedia_file(GF_ISOFile *dest, char *fileName, u32 import_flags, Dou u32 dst_timescale = 0; u32 idx; for (idx=0; idx 0)) { editMode = GF_ISOM_EDIT_NORMAL; } @@ -1977,7 +2001,7 @@ GF_Err cat_multiple_files(GF_ISOFile *dest, char *fileName, u32 import_flags, Do MPEG-4 encoding */ -GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *logs) +GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *logs) { #ifdef GPAC_DISABLE_SMGR return GF_NOT_SUPPORTED; @@ -1989,7 +2013,7 @@ GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *log #ifndef GPAC_DISABLE_SCENE_STATS GF_StatManager *statsman = NULL; #endif - + sg = gf_sg_new(); ctx = gf_sm_new(sg); memset(&load, 0, sizeof(GF_SceneLoader)); @@ -2023,7 +2047,7 @@ GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *log } else if (stats->int_res_2d + opts->resolution <= 0) { fprintf(stderr, " Given resolution %d is too low, using %d instead.\n", opts->resolution, stats->int_res_2d - 1); opts->resolution = 1 - stats->int_res_2d; - } + } opts->coord_bits = stats->int_res_2d + opts->resolution; fprintf(stderr, " Coordinates & Lengths encoded using "); if (opts->resolution < 0) fprintf(stderr, "only the %d most significant bits (of %d).\n", opts->coord_bits, stats->int_res_2d); @@ -2037,7 +2061,7 @@ GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *log opts->scale_bits = 0; fprintf(stderr, "encoded using a %d.8 representation\n", opts->coord_bits - 8); } - } + } #ifndef GPAC_DISABLE_VRML /*BIFS*/ else if (stats->base_layer) { @@ -2046,7 +2070,7 @@ GF_Err EncodeFile(char *in, GF_ISOFile *mp4, GF_SMEncodeOptions *opts, FILE *log M_QuantizationParameter *qp; GF_Command *com = gf_sg_command_new(ctx->scene_graph, GF_SG_GLOBAL_QUANTIZER); qp = (M_QuantizationParameter *) gf_node_new(ctx->scene_graph, TAG_MPEG4_QuantizationParameter); - + inf = gf_sg_command_field_new(com); inf->new_node = (GF_Node *)qp; inf->field_ptr = &inf->new_node; @@ -2244,7 +2268,7 @@ GF_Err EncodeBIFSChunk(GF_SceneManager *ctx, char *bifsOutputFile, GF_Err (*AUCa esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); esd->decoderConfig->decoderSpecificInfo->data = data; esd->decoderConfig->decoderSpecificInfo->dataLength = data_len; - esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(bifsenc, sc->ESID); + esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(bifsenc, sc->ESID); for (j=1; jAUs); j++) { char *data; @@ -2272,11 +2296,11 @@ GF_Err EncodeBIFSChunk(GF_SceneManager *ctx, char *bifsOutputFile, GF_Err (*AUCa * \param chunkFile BT chunk to be encoded * \param bifs output file name for the BIFS data * \param inputContext initial BT upon which the chunk is based (shall not be NULL) - * \param outputContext: file name to dump the context after applying the new chunk to the input context + * \param outputContext: file name to dump the context after applying the new chunk to the input context can be NULL, without .bt * \param tmpdir can be NULL */ -GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *outputContext, const char *tmpdir) +GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *outputContext, const char *tmpdir) { #if defined(GPAC_DISABLE_SMGR) || defined(GPAC_DISABLE_BIFS_ENC) || defined(GPAC_DISABLE_SCENE_ENCODER) || defined (GPAC_DISABLE_SCENE_DUMP) fprintf(stderr, "BIFS encoding is not supported in this build of GPAC\n"); @@ -2306,7 +2330,7 @@ GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *ou /* Step 2: make sure we have only ONE RAP for each stream*/ e = gf_sm_aggregate(ctx, 0); if (e) goto exit; - + /*Step 3: loading the chunk into the context*/ memset(&load, 0, sizeof(GF_SceneLoader)); load.fileName = chunkFile; @@ -2321,11 +2345,11 @@ GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *ou } fprintf(stderr, "Context and chunks loaded\n"); - /* Assumes that the first AU contains only one command a SceneReplace and + /* Assumes that the first AU contains only one command a SceneReplace and that is not part of the current chunk */ - /* Last argument is a callback to pass the encoded AUs: not needed here + /* Last argument is a callback to pass the encoded AUs: not needed here Saving is not handled correctly */ - e = EncodeBIFSChunk(ctx, bifs, NULL); + e = EncodeBIFSChunk(ctx, bifs, NULL); if (e) goto exit; @@ -2336,7 +2360,7 @@ GF_Err EncodeFileChunk(char *chunkFile, char *bifs, char *inputContext, char *ou /*make random access for storage*/ e = gf_sm_aggregate(ctx, 0); if (e) goto exit; - + /*check if we dump to BT, XMT or encode to MP4*/ strcpy(szF, outputContext); ext = strrchr(szF, '.'); @@ -2385,8 +2409,8 @@ void sax_node_start(void *sax_cbck, const char *node_name, const char *name_spac /*do not process hyperlinks*/ if (!strcmp(node_name, "a") || !strcmp(node_name, "Anchor")) return; - - for (i=0; iname, "xlink:href") && stricmp(att->name, "url")) continue; if (att->value[0]=='#') continue; @@ -2555,15 +2579,26 @@ GF_ISOFile *package_file(char *file_name, char *fcc, const char *tmpdir, Bool ma ext = strrchr(item, '.'); if (!stricmp(ext, ".gz")) ext = strrchr(ext-1, '.'); - if (!stricmp(ext, ".jpg") || !stricmp(ext, ".jpeg")) mime = "image/jpeg"; - else if (!stricmp(ext, ".png")) mime = "image/png"; - else if (!stricmp(ext, ".svg")) mime = "image/svg+xml"; - else if (!stricmp(ext, ".x3d")) mime = "model/x3d+xml"; - else if (!stricmp(ext, ".xmt")) mime = "application/x-xmt"; - else if (!stricmp(ext, ".js")) { mime = "application/javascript"; } - else if (!stricmp(ext, ".svgz") || !stricmp(ext, ".svg.gz")) { mime = "image/svg+xml"; encoding = "binary-gzip"; } - else if (!stricmp(ext, ".x3dz") || !stricmp(ext, ".x3d.gz")) { mime = "model/x3d+xml"; encoding = "binary-gzip"; } - else if (!stricmp(ext, ".xmtz") || !stricmp(ext, ".xmt.gz")) { mime = "application/x-xmt"; encoding = "binary-gzip"; } + if (!stricmp(ext, ".jpg") || !stricmp(ext, ".jpeg")) mime = "image/jpeg"; + else if (!stricmp(ext, ".png")) mime = "image/png"; + else if (!stricmp(ext, ".svg")) mime = "image/svg+xml"; + else if (!stricmp(ext, ".x3d")) mime = "model/x3d+xml"; + else if (!stricmp(ext, ".xmt")) mime = "application/x-xmt"; + else if (!stricmp(ext, ".js")) { + mime = "application/javascript"; + } + else if (!stricmp(ext, ".svgz") || !stricmp(ext, ".svg.gz")) { + mime = "image/svg+xml"; + encoding = "binary-gzip"; + } + else if (!stricmp(ext, ".x3dz") || !stricmp(ext, ".x3d.gz")) { + mime = "model/x3d+xml"; + encoding = "binary-gzip"; + } + else if (!stricmp(ext, ".xmtz") || !stricmp(ext, ".xmt.gz")) { + mime = "application/x-xmt"; + encoding = "binary-gzip"; + } e = gf_isom_add_meta_item(file, 1, 0, 0, item, name, 0, mime, NULL, NULL, NULL); gf_free(name); diff --git a/applications/mp4box/live.c b/applications/mp4box/live.c index c58fc70..180c219 100644 --- a/applications/mp4box/live.c +++ b/applications/mp4box/live.c @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,21 +54,21 @@ void PrintStreamerUsage() { fprintf(stderr, "File Streamer Options\n" - "\n" - "MP4Box can stream ISO files to RTP. The streamer currently doesn't support\n" - "data carrouselling and will therefore not handle BIFS and OD streams properly.\n" - "\n" - "-rtp enables streamer\n" - "-noloop disables looping when streaming\n" - "-mpeg4 forces MPEG-4 ES Generic for all RTP streams\n" - "-dst=IP IP destination (uni/multi-cast). Default: 127.0.0.1\n" - "-port=PORT output port of the first stream. Default: 7000\n" - "-mtu=MTU path MTU for RTP packets. Default is 1450 bytes\n" - "-ifce=IFCE IP address of the physical interface to use. Default: NULL (ANY)\n" - "-ttl=TTL time to live for multicast packets. Default: 1\n" - "-sdp=Name file name of the generated SDP. Default: \"session.sdp\"\n" - "\n" - ); + "\n" + "MP4Box can stream ISO files to RTP. The streamer currently doesn't support\n" + "data carrouselling and will therefore not handle BIFS and OD streams properly.\n" + "\n" + "-rtp enables streamer\n" + "-noloop disables looping when streaming\n" + "-mpeg4 forces MPEG-4 ES Generic for all RTP streams\n" + "-dst=IP IP destination (uni/multi-cast). Default: 127.0.0.1\n" + "-port=PORT output port of the first stream. Default: 7000\n" + "-mtu=MTU path MTU for RTP packets. Default is 1450 bytes\n" + "-ifce=IFCE IP address of the physical interface to use. Default: NULL (ANY)\n" + "-ttl=TTL time to live for multicast packets. Default: 1\n" + "-sdp=Name file name of the generated SDP. Default: \"session.sdp\"\n" + "\n" + ); } static void on_logs(void *cbk, u32 ll, u32 lm, const char *fmt, va_list list) @@ -78,14 +78,14 @@ static void on_logs(void *cbk, u32 ll, u32 lm, const char *fmt, va_list list) fflush(logs); } -int stream_file_rtp(int argc, char **argv) +int stream_file_rtp(int argc, char **argv) { GF_ISOMRTPStreamer *file_streamer; char *sdp_file = "session.sdp"; char *ip_dest = "127.0.0.1"; char *ifce_addr = NULL; char *inName = NULL; - char *logs=NULL; + char *logs=NULL; FILE *logfile=NULL; u16 port = 7000; u32 ttl = 1; @@ -99,7 +99,10 @@ int stream_file_rtp(int argc, char **argv) char *arg = argv[i]; if (arg[0] != '-') { - if (inName) { fprintf(stderr, "Error - 2 input names specified, please check usage\n"); return 1; } + if (inName) { + fprintf(stderr, "Error - 2 input names specified, please check usage\n"); + return 1; + } inName = arg; } else if (!stricmp(arg, "-noloop")) loop = 0; @@ -116,9 +119,9 @@ int stream_file_rtp(int argc, char **argv) } gf_sys_init(mem_track); - if (logs) + if (logs) gf_log_set_tools_levels(logs); - else + else gf_log_set_tool_level(GF_LOG_RTP, GF_LOG_INFO); //set to debug to have packet list if (logfile) { gf_log_set_callback(logfile, on_logs); @@ -144,7 +147,7 @@ int stream_file_rtp(int argc, char **argv) check--; if (!check) { if (gf_prompt_has_input()) { - char c = (char) gf_prompt_get_char(); + char c = (char) gf_prompt_get_char(); if (c=='q') break; } check = 50; @@ -160,37 +163,37 @@ int stream_file_rtp(int argc, char **argv) void PrintLiveUsage() { - fprintf(stderr, - - "Live scene encoder options:\n" - "-dst=IP destination IP - default: NULL\n" - "-port=PORT destination port - default: 7000\n" - "-mtu=MTU path MTU for RTP packets. Default is 1450 bytes\n" - "-ifce=IFCE IP address of the physical interface to use. Default: NULL(ANY)\n" - "-ttl=TTL time to live for multicast packets. Default: 1\n" - "-sdp=Name ouput SDP file - default: session.sdp\n" - "\n" - "-dims turns on DIMS mode for SVG input - default: off\n" - "-no-rap disabled RAP sending - this also disables carousel generation. Default: off\n" - "-src=file source of updates - default: null\n" - "-rap=time duration in ms of base carousel - default: 0 (off)\n" - " you can specify the RAP period of a single ESID (not in DIMS):\n" - " -rap=ESID=X:time\n" - "\n" - "Runtime options:\n" - "q: quits\n" - "u: inputs some commands to be sent\n" - "U: same as u but signals the updates as critical\n" - "e: inputs some commands to be sent without being aggregated\n" - "E: same as e but signals the updates as critical\n" - "f: forces RAP sending\n" - "F: forces RAP regeneration and sending\n" - "p: dumps current scene\n" - "\n" - "GPAC version: " GPAC_FULL_VERSION "\n" - ""); + fprintf(stderr, + + "Live scene encoder options:\n" + "-dst=IP destination IP - default: NULL\n" + "-port=PORT destination port - default: 7000\n" + "-mtu=MTU path MTU for RTP packets. Default is 1450 bytes\n" + "-ifce=IFCE IP address of the physical interface to use. Default: NULL(ANY)\n" + "-ttl=TTL time to live for multicast packets. Default: 1\n" + "-sdp=Name ouput SDP file - default: session.sdp\n" + "\n" + "-dims turns on DIMS mode for SVG input - default: off\n" + "-no-rap disabled RAP sending - this also disables carousel generation. Default: off\n" + "-src=file source of updates - default: null\n" + "-rap=time duration in ms of base carousel - default: 0 (off)\n" + " you can specify the RAP period of a single ESID (not in DIMS):\n" + " -rap=ESID=X:time\n" + "\n" + "Runtime options:\n" + "q: quits\n" + "u: inputs some commands to be sent\n" + "U: same as u but signals the updates as critical\n" + "e: inputs some commands to be sent without being aggregated\n" + "E: same as e but signals the updates as critical\n" + "f: forces RAP sending\n" + "F: forces RAP regeneration and sending\n" + "p: dumps current scene\n" + "\n" + "GPAC version: " GPAC_FULL_VERSION "\n" + ""); } -typedef struct +typedef struct { GF_RTPStreamer *rtp; Bool manual_rtcp; @@ -208,7 +211,7 @@ typedef struct u32 critical; } RTPChannel; -typedef struct +typedef struct { GF_SceneEngine *seng; Bool force_carousel, carousel_generation; @@ -261,7 +264,7 @@ static void live_session_callback(void *calling_object, u16 ESID, char *data, u3 while ( (rtpch = gf_list_enum(livesess->streams, &i))) { if (rtpch->ESID == ESID) { - + /*store carousel data*/ if (livesess->carousel_generation && rtpch->carousel_period) { if (rtpch->carousel_alloc < size) { @@ -357,9 +360,9 @@ static void live_session_setup(LiveSession *livesess, char *ip, u16 port, u32 pa switch (st) { case GF_STREAM_OD: case GF_STREAM_SCENE: - rtpch->rtp = gf_rtp_streamer_new_extended(st, oti, ts, ip, port, path_mtu, ttl, ifce_addr, - GP_RTP_PCK_SYSTEMS_CAROUSEL, (char *) config, config_len, - 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); + rtpch->rtp = gf_rtp_streamer_new_extended(st, oti, ts, ip, port, path_mtu, ttl, ifce_addr, + GP_RTP_PCK_SYSTEMS_CAROUSEL, (char *) config, config_len, + 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4); if (rtpch->rtp) { gf_rtp_streamer_disable_auto_rtcp(rtpch->rtp); @@ -381,12 +384,12 @@ static void live_session_setup(LiveSession *livesess, char *ip, u16 port, u32 pa port += 2; } - if (sdp) { + if (sdp) { FILE *out = gf_f64_open(sdp_name, "wt"); - fprintf(out, "%s", sdp); + fprintf(out, "%s", sdp); fclose(out); - gf_free(sdp); - } + gf_free(sdp); + } } void live_session_shutdown(LiveSession *livesess) @@ -470,9 +473,9 @@ int live_session(int argc, char **argv) u64 last_src_modif, mod_time; char *src_name = NULL; Bool run, has_carousel, no_rap; - Bool udp = 0; + Bool udp = 0; u16 sk_port=0; - GF_Socket *sk = NULL; + GF_Socket *sk = NULL; LiveSession livesess; RTPChannel *ch; char *update_buffer = NULL; @@ -489,10 +492,10 @@ int live_session(int argc, char **argv) gf_sys_init(GF_FALSE); memset(&livesess, 0, sizeof(LiveSession)); - + gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_INFO); - for (i=1; i scanf("%[^\t\n]", szCom)){ - fprintf(stderr, "No command entered properly, aborting.\n"); - break; + if (1 > scanf("%[^\t\n]", szCom)) { + fprintf(stderr, "No command entered properly, aborting.\n"); + break; } /*stdin flush bug*/ while (getchar()!='\n') {} @@ -614,7 +623,7 @@ int live_session(int argc, char **argv) livesess.critical = 0; update_context = 1; } - break; + break; case 'E': livesess.critical = 1; case 'e': @@ -623,32 +632,32 @@ int live_session(int argc, char **argv) char szCom[8192]; fprintf(stderr, "Enter command to send:\n"); szCom[0] = 0; - if (1 > scanf("%[^\t\n]", szCom)){ - printf("No command entered properly, aborting.\n"); - break; + if (1 > scanf("%[^\t\n]", szCom)) { + printf("No command entered properly, aborting.\n"); + break; } /*stdin flush bug*/ while (getchar()!='\n') {} e = gf_seng_encode_from_string(livesess.seng, 0, 1, szCom, live_session_callback); if (e) fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e)); - livesess.critical = 0; + livesess.critical = 0; e = gf_seng_aggregate_context(livesess.seng, 0); } - break; + break; case 'p': { char rad[GF_MAX_PATH]; fprintf(stderr, "Enter output file name - \"std\" for stderr: "); - if (1 > scanf("%s", rad)){ - fprintf(stderr, "No ouput file name entered, aborting.\n"); - break; + if (1 > scanf("%s", rad)) { + fprintf(stderr, "No ouput file name entered, aborting.\n"); + break; } e = gf_seng_save_context(livesess.seng, !strcmp(rad, "std") ? NULL : rad); fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e)); } - break; + break; case 'F': update_context = 1; case 'f': @@ -673,7 +682,7 @@ int live_session(int argc, char **argv) /*checks if we have a broadcast config*/ if (!fgets(flag_buf, 200, srcf)) - flag_buf[0] = '\0'; + flag_buf[0] = '\0'; fclose(srcf); aggregate_on_stream = (u16) -1; @@ -726,10 +735,10 @@ int live_session(int argc, char **argv) /*process updates from socket source*/ if (sk) { - char buffer[2049]; - u32 bytes_read; - u32 update_length; - u32 bytes_received; + char buffer[2049]; + u32 bytes_read; + u32 update_length; + u32 bytes_received; e = gf_sk_receive(sk, buffer, 2048, 0, &bytes_read); @@ -761,8 +770,8 @@ int live_session(int argc, char **argv) gf_bs_del(bs); } - set_broadcast_params(&livesess, es_id, period, ts_delta, aggregate_on_stream, adjust_carousel_time, force_rap, aggregate_au, discard_pending, signal_rap, signal_critical, version_inc); - break; + set_broadcast_params(&livesess, es_id, period, ts_delta, aggregate_on_stream, adjust_carousel_time, force_rap, aggregate_au, discard_pending, signal_rap, signal_critical, version_inc); + break; default: update_length = 0; break; @@ -819,7 +828,7 @@ int live_session(int argc, char **argv) gf_sleep(10); continue; } - ch = next_carousel(&livesess, (u32 *) &next_time); + ch = next_carousel(&livesess, (u32 *) &next_time); if ((ch==NULL) || (next_time > 20)) { gf_sleep(20); continue; @@ -865,7 +874,7 @@ u32 grab_live_m2ts(const char *grab_m2ts, const char *outName) gf_sk_del(sock); return 1; } - + fprintf(stderr, "Dumping %s stream to %s - press q to abort\n", grab_m2ts, outName); first_run = 1; @@ -876,7 +885,7 @@ u32 grab_live_m2ts(const char *grab_m2ts, const char *outName) check--; if (!check) { if (gf_prompt_has_input()) { - char c = (char) gf_prompt_get_char(); + char c = (char) gf_prompt_get_char(); if (c=='q') break; } check = 50; @@ -901,8 +910,8 @@ u32 grab_live_m2ts(const char *grab_m2ts, const char *outName) /*process chunk*/ if (is_rtp) { #ifndef GPAC_DISABLE_STREAMING - char *pck; - seq_num = ((data[2] << 8) & 0xFF00) | (data[3] & 0xFF); + char *pck; + seq_num = ((data[2] << 8) & 0xFF00) | (data[3] & 0xFF); gf_rtp_reorderer_add(ch, (void *) data, size, seq_num); pck = (char *) gf_rtp_reorderer_get(ch, &size); @@ -911,7 +920,7 @@ u32 grab_live_m2ts(const char *grab_m2ts, const char *outName) gf_free(pck); } #else - fwrite(data+12, size-12, 1, output); + fwrite(data+12, size-12, 1, output); #endif } else { fwrite(data, size, 1, output); diff --git a/applications/mp4box/main.c b/applications/mp4box/main.c index 58fbcee..2ab062b 100644 --- a/applications/mp4box/main.c +++ b/applications/mp4box/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -125,7 +125,7 @@ const char *GetLanguageCode(char *lang); #ifndef GPAC_DISABLE_MPEG2TS void dump_mpeg2_ts(char *mpeg2ts_file, char *pes_out_name, Bool prog_num); -#endif +#endif #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG) @@ -152,7 +152,11 @@ Float swf_flatten_angle = 0; s32 laser_resolution = 0; -typedef struct { u32 code; const char *name; const char *comment; } itunes_tag; +typedef struct { + u32 code; + const char *name; + const char *comment; +} itunes_tag; static const itunes_tag itags[] = { {GF_ISOM_ITUNE_ALBUM_ARTIST, "album_artist", "usage: album_artist=album artist"}, {GF_ISOM_ITUNE_ALBUM, "album", "usage: album=name" }, @@ -181,576 +185,576 @@ u32 nb_itunes_tags = sizeof(itags) / sizeof(itunes_tag); void PrintVersion() { fprintf(stderr, "MP4Box - GPAC version " GPAC_FULL_VERSION "\n" - "GPAC Copyright (c) Telecom ParisTech 2000-2012\n" - "GPAC Configuration: " GPAC_CONFIGURATION "\n" - "Features: %s\n", gpac_features()); + "GPAC Copyright (c) Telecom ParisTech 2000-2012\n" + "GPAC Configuration: " GPAC_CONFIGURATION "\n" + "Features: %s\n", gpac_features()); } void PrintGeneralUsage() { fprintf(stderr, "General Options:\n" #ifdef GPAC_MEMORY_TRACKING - " -mem-track: enables memory tracker\n" -#endif - " -strict-error exits after the first error is reported\n" - " -inter time_in_ms interleaves file data (track chunks of time_in_ms)\n" - " * Note 1: Interleaving is 0.5s by default\n" - " * Note 2: Performs drift checking accross tracks\n" - " * Note 3: a value of 0 disables interleaving\n" - " -old-inter time same as -inter but doesn't perform drift checking\n" - " -tight performs tight interleaving (sample based) of the file\n" - " * Note: reduces disk seek but increases file size\n" - " -flat stores file with all media data first, non-interleaved\n" - " -frag time_in_ms fragments file (track fragments of time_in_ms)\n" - " * Note: Always disables interleaving\n" - " -ffspace size inserts free space before moof in fragmented files\n" - " -out filename specifies output file name\n" - " * Note: By default input (MP4,3GP) file is overwritten\n" - " -tmp dirname specifies directory for temporary file creation\n" - " * Note: Default temp dir is OS-dependent\n" - " -write-buffer SIZE specifies write buffer in bytes for ISOBMF files\n" - " -no-sys removes all MPEG-4 Systems info except IOD (profiles)\n" - " * Note: Set by default whith '-add' and '-cat'\n" - " -no-iod removes InitialObjectDescriptor from file\n" - " -isma rewrites the file as an ISMA 1.0 AV file\n" - " -ismax same as \'-isma\' and removes all clock references\n" - " -3gp rewrites as 3GPP(2) file (no more MPEG-4 Systems Info)\n" - " * Note 1: some tracks may be removed in the process\n" - " * Note 2: always on for *.3gp *.3g2 *.3gpp\n" - " -ipod rewrites the file for iPod\n" - " -psp rewrites the file for PSP devices\n" - " -brand ABCD[:v] sets major brand of file, with optional version\n" - " -ab ABCD adds given brand to file's alternate brand list\n" - " -rb ABCD removes given brand from file's alternate brand list\n" - " -cprt string adds copyright string to movie\n" - " -chap file adds chapter information contained in file\n" - " -rem trackID removes track from file\n" - " -rap trackID removes all non-RAP samples from track\n" - " -enable trackID enables track\n" - " -disable trackID disables track\n" - " -new forces creation of a new destination file\n" - " -lang [tkID=]LAN sets track language. LAN is the ISO 639-2 code (eng, und)\n" - " -delay tkID=TIME sets track start delay in ms.\n" - " -par tkID=PAR sets visual track pixel aspect ratio (PAR=N:D or \"none\")\n" - " -name tkID=NAME sets track handler name\n" - " * NAME can indicate a UTF-8 file (\"file://file name\"\n" - " -itags tag1[:tag2] sets iTunes tags to file - more info: MP4Box -tag-list.\n" - " -split time_sec splits in files of time_sec max duration\n" - " * Note: this removes all MPEG-4 Systems media\n" - " -split-size size splits in files of max filesize kB. same as -splits.\n" - " * Note: this removes all MPEG-4 Systems media\n" - " -split-rap splits in files begining at each RAP. same as -splitr.\n" - " * Note: this removes all MPEG-4 Systems media\n" - " -split-chunk S:E extracts a new file from Start to End (in seconds). same as -splitx\n" - " * Note: this removes all MPEG-4 Systems media\n" - " -splitz S:E same as -split-chunk, but adjust the end time to be before the last RAP sample\n" - " * Note: this removes all MPEG-4 Systems media\n" - " -group-add fmt creates a new grouping information in the file. Format is\n" - " a colon-separated list of following options:\n" - " refTrack=ID: ID of the track used as a group reference.\n" - " If not set, the track will belong to the same group as the previous trackID specified.\n" - " If 0 or no previous track specified, a new alternate group will be created\n" - " switchID=ID: ID of the switch group to create.\n" - " If 0, a new ID will be computed for you\n" - " If <0, disables SwitchGroup\n" - " criteria=string: list of space-separated 4CCs.\n" - " trackID=ID: ID of the track to add to this group.\n" - "\n" - " *WARNING* Options modify state as they are parsed:\n" - " trackID=1:criteria=lang:trackID=2\n" - " is different from:\n" - " criteria=lang:trackID=1:trackID=2\n" - "\n" - " -group-rem-track ID removes track from its group\n" - " -group-rem ID removes the track's group\n" - " -group-clean removes all group information from all tracks\n" - " -group-single puts all tracks in a single group\n" - " -ref id:XXXX:refID adds a reference of type 4CC from track ID to track refID\n" - " -keep-utc keeps UTC timing in the file after edit\n" - "\n"); + " -mem-track: enables memory tracker\n" +#endif + " -strict-error exits after the first error is reported\n" + " -inter time_in_ms interleaves file data (track chunks of time_in_ms)\n" + " * Note 1: Interleaving is 0.5s by default\n" + " * Note 2: Performs drift checking accross tracks\n" + " * Note 3: a value of 0 disables interleaving\n" + " -old-inter time same as -inter but doesn't perform drift checking\n" + " -tight performs tight interleaving (sample based) of the file\n" + " * Note: reduces disk seek but increases file size\n" + " -flat stores file with all media data first, non-interleaved\n" + " -frag time_in_ms fragments file (track fragments of time_in_ms)\n" + " * Note: Always disables interleaving\n" + " -ffspace size inserts free space before moof in fragmented files\n" + " -out filename specifies output file name\n" + " * Note: By default input (MP4,3GP) file is overwritten\n" + " -tmp dirname specifies directory for temporary file creation\n" + " * Note: Default temp dir is OS-dependent\n" + " -write-buffer SIZE specifies write buffer in bytes for ISOBMF files\n" + " -no-sys removes all MPEG-4 Systems info except IOD (profiles)\n" + " * Note: Set by default whith '-add' and '-cat'\n" + " -no-iod removes InitialObjectDescriptor from file\n" + " -isma rewrites the file as an ISMA 1.0 AV file\n" + " -ismax same as \'-isma\' and removes all clock references\n" + " -3gp rewrites as 3GPP(2) file (no more MPEG-4 Systems Info)\n" + " * Note 1: some tracks may be removed in the process\n" + " * Note 2: always on for *.3gp *.3g2 *.3gpp\n" + " -ipod rewrites the file for iPod\n" + " -psp rewrites the file for PSP devices\n" + " -brand ABCD[:v] sets major brand of file, with optional version\n" + " -ab ABCD adds given brand to file's alternate brand list\n" + " -rb ABCD removes given brand from file's alternate brand list\n" + " -cprt string adds copyright string to movie\n" + " -chap file adds chapter information contained in file\n" + " -rem trackID removes track from file\n" + " -rap trackID removes all non-RAP samples from track\n" + " -enable trackID enables track\n" + " -disable trackID disables track\n" + " -new forces creation of a new destination file\n" + " -lang [tkID=]LAN sets track language. LAN is the ISO 639-2 code (eng, und)\n" + " -delay tkID=TIME sets track start delay in ms.\n" + " -par tkID=PAR sets visual track pixel aspect ratio (PAR=N:D or \"none\")\n" + " -name tkID=NAME sets track handler name\n" + " * NAME can indicate a UTF-8 file (\"file://file name\"\n" + " -itags tag1[:tag2] sets iTunes tags to file - more info: MP4Box -tag-list.\n" + " -split time_sec splits in files of time_sec max duration\n" + " * Note: this removes all MPEG-4 Systems media\n" + " -split-size size splits in files of max filesize kB. same as -splits.\n" + " * Note: this removes all MPEG-4 Systems media\n" + " -split-rap splits in files begining at each RAP. same as -splitr.\n" + " * Note: this removes all MPEG-4 Systems media\n" + " -split-chunk S:E extracts a new file from Start to End (in seconds). same as -splitx\n" + " * Note: this removes all MPEG-4 Systems media\n" + " -splitz S:E same as -split-chunk, but adjust the end time to be before the last RAP sample\n" + " * Note: this removes all MPEG-4 Systems media\n" + " -group-add fmt creates a new grouping information in the file. Format is\n" + " a colon-separated list of following options:\n" + " refTrack=ID: ID of the track used as a group reference.\n" + " If not set, the track will belong to the same group as the previous trackID specified.\n" + " If 0 or no previous track specified, a new alternate group will be created\n" + " switchID=ID: ID of the switch group to create.\n" + " If 0, a new ID will be computed for you\n" + " If <0, disables SwitchGroup\n" + " criteria=string: list of space-separated 4CCs.\n" + " trackID=ID: ID of the track to add to this group.\n" + "\n" + " *WARNING* Options modify state as they are parsed:\n" + " trackID=1:criteria=lang:trackID=2\n" + " is different from:\n" + " criteria=lang:trackID=1:trackID=2\n" + "\n" + " -group-rem-track ID removes track from its group\n" + " -group-rem ID removes the track's group\n" + " -group-clean removes all group information from all tracks\n" + " -group-single puts all tracks in a single group\n" + " -ref id:XXXX:refID adds a reference of type 4CC from track ID to track refID\n" + " -keep-utc keeps UTC timing in the file after edit\n" + "\n"); } void PrintDASHUsage() { fprintf(stderr, "DASH Options:\n" - " -dash dur enables DASH-ing of the file(s) with a segment duration of DUR ms\n" - " Note: the duration of a fragment (subsegment) is set\n" - " using the -frag switch.\n" - " Note: for onDemand profile, sets duration of a subsegment\n" - " -frag time_in_ms Specifies a fragment duration of time_in_ms.\n" - " * Note: By default, this is the DASH duration\n" - " -out filename specifies output MPD file name.\n" - " -tmp dirname specifies directory for temporary file creation\n" - " * Note: Default temp dir is OS-dependent\n" - " -profile NAME specifies the target DASH profile: \"onDemand\", \"live\", \"main\", \"simple\", \"full\"\n" - " * This will set default option values to ensure conformance to the desired profile\n" - " * Default profile is \"full\" in static mode, \"live\" in dynamic mode\n" - "\n" - "Input media files to dash can use the following modifiers\n" - " \"#trackID=N\" only uses the track ID N from the source file\n" - " \"#video\" only uses the first video track from the source file\n" - " \"#audio\" only uses the first video track from the source file\n" - " \":id=NAME\" sets the representation ID to NAME\n" - " \":period=NAME\" sets the representation's period to NAME. Multiple periods may be used\n" - " period appear in the MPD in the same order as specified with this option\n" - " \":bandwidth=VALUE\" sets the representation's bandwidth to a given value\n" - " \":xlink=VALUE\" sets the xlink value for the period containing this element\n" - " only the xlink declared on the first rep of a period will be used\n" - " \":role=VALUE\" sets the role of this representation (cf DASH spec).\n" - " media with different roles belong to different adaptation sets.\n" - "\n" - " -rap segments begin with random access points\n" - " Note: segment duration may not be exactly what asked by\n" - " \"-dash\" since encoded video data is not modified\n" - " -frag-rap All fragments begin with random access points\n" - " Note: fragment duration may not be exactly what is asked by\n" - " \"-frag\" since encoded video data is not modified\n" - " -segment-name name sets the segment name for generated segments\n" - " If not set (default), segments are concatenated in output file\n" - " except in \"live\" profile where dash_%%s is used\n" - " -segment-ext name sets the segment extension. Default is m4s, \"null\" means no extension\n" - " -segment-timeline Uses SegmentTimeline when generating segments. NOT SUPPORTED BY LIVE/CTX MODE YET.\n" - " -segment-marker MARK Adds a box of type \'MARK\' at the end of each DASH segment. MARK shall be a 4CC identifier\n" - " -base-url string sets Base url at MPD level. Can be used several times.\n" - " -mpd-title string sets MPD title.\n" - " -mpd-source string sets MPD source.\n" - " -mpd-info-url string sets MPD info url.\n" - " -cprt string adds copyright string to MPD\n" - " -dash-live[=F] dur generates a live DASH session using dur segment duration, optionnally writing live context to F\n" - " MP4Box will run the live session until \'q\' is pressed or a fatal error occurs.\n" - " -ddbg-live[=F] dur same as -dash-live without time regulation for debug purposes.\n" - " -dash-ctx FILE stores/restore DASH timing from FILE.\n" - " -dynamic uses dynamic MPD type instead of static.\n" - " -mpd-refresh TIME specifies MPD update time in seconds.\n" - " -time-shift TIME specifies MPD time shift buffer depth in seconds (default 0). Specify -1 to keep all files\n" - " -subdur DUR specifies maximum duration in ms of the input file to be dashed in LIVE or context mode.\n" - " NOTE: This does not change the segment duration: dashing stops once segments produced exceeded the duration.\n" - " -min-buffer TIME specifies MPD min buffer time in milliseconds\n" - " -ast-offset TIME specifies MPD AvailabilityStartTime offset in seconds. Default is 1 sec delay\n" - " -dash-scale SCALE specifies that timing for -dash and -frag are expressed in SCALE units per seconds\n" - " -mem-frags fragments will be produced in memory rather than on disk before flushing to disk\n" - " -pssh-moof stores PSSH boxes in first moof of each segments. By default PSSH are stored in movie box.\n" - " -sample-groups-traf stores sample group descriptions in traf (duplicated for each traf) rather than in moof. By default sample group descriptions are stored in movie box.\n" - - "\n" - "Advanced Options, should not be needed when using -dash-profile:\n" - " -subsegs-per-sidx N sets the number of subsegments to be written in each SIDX box\n" - " If 0, a single SIDX box is used per segment\n" - " If -1, no SIDX box is used\n" - " -url-template uses SegmentTemplate instead of explicit sources in segments.\n" - " Ignored if segments are stored in the output file.\n" - " -daisy-chain uses daisy-chain SIDX instead of hierarchical. Ignored if frags/sidx is 0.\n" - " -single-segment uses a single segment for the whole file (OnDemand profile). \n" - " -single-file uses a single file for the whole file (default). \n" - " -bs-switching MODE sets bitstream switching to \"inband\" (default), \"merge\", \"no\" or \"single\" to test with single input.\n" - " -moof-sn N sets sequence number of first moof to N\n" - " -tfdt N sets TFDT of first traf to N in SCALE units (cf -dash-scale)\n" - " -no-frags-default disables default flags in fragments\n" - " -dash-ts-prog N program_number to be considered in case of an MPTS input file.\n" - "\n"); + " -dash dur enables DASH-ing of the file(s) with a segment duration of DUR ms\n" + " Note: the duration of a fragment (subsegment) is set\n" + " using the -frag switch.\n" + " Note: for onDemand profile, sets duration of a subsegment\n" + " -frag time_in_ms Specifies a fragment duration of time_in_ms.\n" + " * Note: By default, this is the DASH duration\n" + " -out filename specifies output MPD file name.\n" + " -tmp dirname specifies directory for temporary file creation\n" + " * Note: Default temp dir is OS-dependent\n" + " -profile NAME specifies the target DASH profile: \"onDemand\", \"live\", \"main\", \"simple\", \"full\"\n" + " * This will set default option values to ensure conformance to the desired profile\n" + " * Default profile is \"full\" in static mode, \"live\" in dynamic mode\n" + "\n" + "Input media files to dash can use the following modifiers\n" + " \"#trackID=N\" only uses the track ID N from the source file\n" + " \"#video\" only uses the first video track from the source file\n" + " \"#audio\" only uses the first video track from the source file\n" + " \":id=NAME\" sets the representation ID to NAME\n" + " \":period=NAME\" sets the representation's period to NAME. Multiple periods may be used\n" + " period appear in the MPD in the same order as specified with this option\n" + " \":bandwidth=VALUE\" sets the representation's bandwidth to a given value\n" + " \":xlink=VALUE\" sets the xlink value for the period containing this element\n" + " only the xlink declared on the first rep of a period will be used\n" + " \":role=VALUE\" sets the role of this representation (cf DASH spec).\n" + " media with different roles belong to different adaptation sets.\n" + "\n" + " -rap segments begin with random access points\n" + " Note: segment duration may not be exactly what asked by\n" + " \"-dash\" since encoded video data is not modified\n" + " -frag-rap All fragments begin with random access points\n" + " Note: fragment duration may not be exactly what is asked by\n" + " \"-frag\" since encoded video data is not modified\n" + " -segment-name name sets the segment name for generated segments\n" + " If not set (default), segments are concatenated in output file\n" + " except in \"live\" profile where dash_%%s is used\n" + " -segment-ext name sets the segment extension. Default is m4s, \"null\" means no extension\n" + " -segment-timeline Uses SegmentTimeline when generating segments. NOT SUPPORTED BY LIVE/CTX MODE YET.\n" + " -segment-marker MARK Adds a box of type \'MARK\' at the end of each DASH segment. MARK shall be a 4CC identifier\n" + " -base-url string sets Base url at MPD level. Can be used several times.\n" + " -mpd-title string sets MPD title.\n" + " -mpd-source string sets MPD source.\n" + " -mpd-info-url string sets MPD info url.\n" + " -cprt string adds copyright string to MPD\n" + " -dash-live[=F] dur generates a live DASH session using dur segment duration, optionnally writing live context to F\n" + " MP4Box will run the live session until \'q\' is pressed or a fatal error occurs.\n" + " -ddbg-live[=F] dur same as -dash-live without time regulation for debug purposes.\n" + " -dash-ctx FILE stores/restore DASH timing from FILE.\n" + " -dynamic uses dynamic MPD type instead of static.\n" + " -mpd-refresh TIME specifies MPD update time in seconds.\n" + " -time-shift TIME specifies MPD time shift buffer depth in seconds (default 0). Specify -1 to keep all files\n" + " -subdur DUR specifies maximum duration in ms of the input file to be dashed in LIVE or context mode.\n" + " NOTE: This does not change the segment duration: dashing stops once segments produced exceeded the duration.\n" + " -min-buffer TIME specifies MPD min buffer time in milliseconds\n" + " -ast-offset TIME specifies MPD AvailabilityStartTime offset in seconds. Default is 1 sec delay\n" + " -dash-scale SCALE specifies that timing for -dash and -frag are expressed in SCALE units per seconds\n" + " -mem-frags fragments will be produced in memory rather than on disk before flushing to disk\n" + " -pssh-moof stores PSSH boxes in first moof of each segments. By default PSSH are stored in movie box.\n" + " -sample-groups-traf stores sample group descriptions in traf (duplicated for each traf) rather than in moof. By default sample group descriptions are stored in movie box.\n" + + "\n" + "Advanced Options, should not be needed when using -dash-profile:\n" + " -subsegs-per-sidx N sets the number of subsegments to be written in each SIDX box\n" + " If 0, a single SIDX box is used per segment\n" + " If -1, no SIDX box is used\n" + " -url-template uses SegmentTemplate instead of explicit sources in segments.\n" + " Ignored if segments are stored in the output file.\n" + " -daisy-chain uses daisy-chain SIDX instead of hierarchical. Ignored if frags/sidx is 0.\n" + " -single-segment uses a single segment for the whole file (OnDemand profile). \n" + " -single-file uses a single file for the whole file (default). \n" + " -bs-switching MODE sets bitstream switching to \"inband\" (default), \"merge\", \"no\" or \"single\" to test with single input.\n" + " -moof-sn N sets sequence number of first moof to N\n" + " -tfdt N sets TFDT of first traf to N in SCALE units (cf -dash-scale)\n" + " -no-frags-default disables default flags in fragments\n" + " -dash-ts-prog N program_number to be considered in case of an MPTS input file.\n" + "\n"); } void PrintFormats() { fprintf(stderr, "Suppported raw formats and file extensions:\n" - " NHNT .media .nhnt .info\n" - " NHML .nhml (opt: .media .info)\n" - " MPEG-1-2 Video .m1v .m2v\n" - " MPEG-4 Video .cmp .m4v\n" - " H263 Video .263 .h263\n" - " AVC/H264 Video .h264 .h26L .264 .26L\n" - " JPEG Images .jpg .jpeg\n" - " PNG Images .png\n" - " MPEG 1-2 Audio .mp3, .m1a, .m2a\n" - " ADTS-AAC Audio .aac\n" - " AMR(WB) Audio .amr .awb\n" - " EVRC Audio .evc\n" - " SMV Audio .smv\n" - "\n" - "Supported containers and file extensions:\n" - " AVI .avi\n" - " MPEG-2 PS .mpg .mpeg .vob .vcd .svcd\n" - " MPEG-2 TS .ts .m2t\n" - " QCP .qcp\n" - " OGG .ogg\n" - " ISO-Media files no extension checking\n" - "\n" - "Supported text formats:\n" - " SRT Subtitles .srt\n" - " SUB Subtitles .sub\n" - " GPAC Timed Text .ttxt\n" - " QuickTime TeXML Text .xml (cf QT documentation)\n" - "\n" - "Supported Scene formats:\n" - " MPEG-4 XMT-A .xmt .xmta .xmt.gz .xmta.gz\n" - " MPEG-4 BT .bt .bt.gz\n" - " VRML .wrl .wrl.gz\n" - " X3D-XML .x3d .x3d.gz\n" - " X3D-VRML .x3dv .x3dv.gz\n" - " MacroMedia Flash .swf (very limited import support only)\n" - "\n" - ); + " NHNT .media .nhnt .info\n" + " NHML .nhml (opt: .media .info)\n" + " MPEG-1-2 Video .m1v .m2v\n" + " MPEG-4 Video .cmp .m4v\n" + " H263 Video .263 .h263\n" + " AVC/H264 Video .h264 .h26L .264 .26L\n" + " JPEG Images .jpg .jpeg\n" + " PNG Images .png\n" + " MPEG 1-2 Audio .mp3, .m1a, .m2a\n" + " ADTS-AAC Audio .aac\n" + " AMR(WB) Audio .amr .awb\n" + " EVRC Audio .evc\n" + " SMV Audio .smv\n" + "\n" + "Supported containers and file extensions:\n" + " AVI .avi\n" + " MPEG-2 PS .mpg .mpeg .vob .vcd .svcd\n" + " MPEG-2 TS .ts .m2t\n" + " QCP .qcp\n" + " OGG .ogg\n" + " ISO-Media files no extension checking\n" + "\n" + "Supported text formats:\n" + " SRT Subtitles .srt\n" + " SUB Subtitles .sub\n" + " GPAC Timed Text .ttxt\n" + " QuickTime TeXML Text .xml (cf QT documentation)\n" + "\n" + "Supported Scene formats:\n" + " MPEG-4 XMT-A .xmt .xmta .xmt.gz .xmta.gz\n" + " MPEG-4 BT .bt .bt.gz\n" + " VRML .wrl .wrl.gz\n" + " X3D-XML .x3d .x3d.gz\n" + " X3D-VRML .x3dv .x3dv.gz\n" + " MacroMedia Flash .swf (very limited import support only)\n" + "\n" + ); } void PrintImportUsage() { fprintf(stderr, "Importing Options\n" - "\nFile importing syntax:\n" - " \"#video\" \"#audio\" base import for most AV files\n" - " \"#trackID=ID\" track import for IsoMedia and other files\n" - " \"#pid=ID\" stream import from MPEG-2 TS\n" - " \":dur=D\" imports only the first D seconds\n" - " \":lang=LAN\" sets imported media language code\n" - " \":delay=delay_ms\" sets imported media initial delay in ms\n" - " \":par=PAR\" sets visual pixel aspect ratio (PAR=Num:Den)\n" - " \":name=NAME\" sets track handler name\n" - " \":ext=EXT\" overrides file extension when importing\n" - " \":hdlr=code\" sets track handler type to the given code point (4CC)\n" - " \":disable\" imported track(s) will be disabled\n" - " \":group=G\" adds the track as part of the G alternate group.\n" - " If G is 0, the first available GroupID will be picked.\n" - " \":fps=VAL\" same as -fps option\n" - " \":agg=VAL\" same as -agg option\n" - " \":par=VAL\" same as -par option\n" - " \":dref\" same as -dref option\n" - " \":nodrop\" same as -nodrop option\n" - " \":packed\" same as -packed option\n" - " \":sbr\" same as -sbr option\n" - " \":sbrx\" same as -sbrx option\n" - " \":ps\" same as -ps option\n" - " \":psx\" same as -psx option\n" - " \":ovsbr\" same as -ovsbr option\n" - " \":mpeg4\" same as -mpeg4 option\n" - " \":svc\" import SVC with explicit signaling (no AVC base compatibility)\n" - " \":nosvc\" discard SVC data when importing\n" - " \":svcmode=MODE\" sets SVC import mode:\n" - " \" split : each AVC/SVC layer is in its own track\n" - " \" merge : all AVC/SVC layers are merged in a single track\n" - " \" splitbase : all SVC layers are merged in a track, and the AVC base in another\n" - " \":subsamples\" adds SubSample information for AVC+SVC\n" - " \":forcesync\" forces non IDR samples with I slices to be marked as sync points (AVC GDR)\n" - " !! RESULTING FILE IS NOT COMPLIANT WITH THE SPEC but will fix seeking in most players\n" - " \":font=name\" specifies font name for text import (default \"Serif\")\n" - " \":size=s\" specifies font size for text import (default 18)\n" - " \":stype=4CC\" forces the sample description type to a different value\n" - " !! THIS MAY BREAK THE FILE WRITING !!\n" - " \":chap\" specifies the track is a chapter track\n" - " \":chapter=NAME\" adds a single chapter (old nero format) with given name lasting the entire file\n" - " This command can be used in -cat as well\n" - " \":chapfile=file\" adds a chapter file (old nero format)\n" - " This command can be used in -cat as well\n" - " \":layout=WxHxXxY\" specifies the track layout\n" - " - if W (resp H) = 0, the max width (resp height) of\n" - " the tracks in the file are used.\n" - " - if Y=-1, the layout is moved to the bottom of the\n" - " track area\n" - " - X and Y can be omitted (:layout=WxH)\n" - " \":rescale=TS\" forces media timescale to TS !! changes the media duration\n" - " \":timescale=TS\" sets import timescale to TS\n" - " \":swf-global\" all SWF defines are placed in first scene replace\n" - " * Note: By default SWF defines are sent when needed\n" - " \":swf-no-ctrl\" uses a single stream for movie control and dictionary\n" - " * Note: this will disable ActionScript\n" - " \":swf-no-text\" removes all SWF text\n" - " \":swf-no-font\" removes all embedded SWF Fonts (terminal fonts used)\n" - " \":swf-no-line\" removes all lines from SWF shapes\n" - " \":swf-no-grad\" removes all gradients from swf shapes\n" - " \":swf-quad\" uses quadratic bezier curves instead of cubic ones\n" - " \":swf-xlp\" support for lines transparency and scalability\n" - " \":swf-flatten=ang\" complementary angle below which 2 lines are merged\n" - " * Note: angle \'0\' means no flattening\n" - "\n" - " \":negctts\" uses negative CTS-DTS offsets (ISO4 brand)\n" - " -add file add file tracks to (new) output file\n" - " -cat file concatenates file samples to (new) output file\n" - " * Note: creates tracks if needed\n" - " * Note: aligns initial timestamp of the file to be concatenated.\n" - " -catx file same as cat but new tracks can be imported before concatenation by specifying '+ADD_COMMAND'\n" - " where ADD_COMMAND is a regular -add syntax\n" - " -unalign-cat does not attempt to align timestamps of samples inbetween tracks\n" - " -force-cat skips media configuration check when concatenating file\n" - " !!! THIS MAY BREAK THE CONCATENATED TRACK(S) !!!\n" - " -keep-sys keeps all MPEG-4 Systems info when using '-add' / 'cat'\n" - " -keep-all keeps all existing tracks when using '-add'\n" - " * Note: only used when adding IsoMedia files\n" - "\n" - "All the following options can be specified as default or for each track.\n" - "When specified by track the syntax is \":opt\" or \":opt=val\".\n\n" - " -dref keeps media data in original file\n" - " -no-drop forces constant FPS when importing AVI video\n" - " -packed forces packed bitstream when importing raw ASP\n" - " -sbr backward compatible signaling of AAC-SBR\n" - " -sbrx non-backward compatible signaling of AAC-SBR\n" - " -ps backward compatible signaling of AAC-PS\n" - " -psx non-backward compatible signaling of AAC-PS\n" - " -ovsbr oversample SBR\n" - " * Note: SBR AAC, PS AAC and oversampled SBR cannot be detected at import time\n" - " -fps FPS forces frame rate for video and SUB subtitles import\n" - " FPS is either a number or expressed as timescale-increment\n" - " * For raw H263 import, default FPS is 15\n" - " * For all other imports, default FPS is 25\n" - " !! THIS IS IGNORED FOR IsoMedia IMPORT !!\n" - " -mpeg4 forces MPEG-4 sample descriptions when possible (3GPP2)\n" - " For AAC, forces MPEG-4 AAC signaling even if MPEG-2\n" - " -agg N aggregates N audio frames in 1 sample (3GP media only)\n" - " * Note: Maximum value is 15 - Disabled by default\n" - "\n" - ); + "\nFile importing syntax:\n" + " \"#video\" \"#audio\" base import for most AV files\n" + " \"#trackID=ID\" track import for IsoMedia and other files\n" + " \"#pid=ID\" stream import from MPEG-2 TS\n" + " \":dur=D\" imports only the first D seconds\n" + " \":lang=LAN\" sets imported media language code\n" + " \":delay=delay_ms\" sets imported media initial delay in ms\n" + " \":par=PAR\" sets visual pixel aspect ratio (PAR=Num:Den)\n" + " \":name=NAME\" sets track handler name\n" + " \":ext=EXT\" overrides file extension when importing\n" + " \":hdlr=code\" sets track handler type to the given code point (4CC)\n" + " \":disable\" imported track(s) will be disabled\n" + " \":group=G\" adds the track as part of the G alternate group.\n" + " If G is 0, the first available GroupID will be picked.\n" + " \":fps=VAL\" same as -fps option\n" + " \":agg=VAL\" same as -agg option\n" + " \":par=VAL\" same as -par option\n" + " \":dref\" same as -dref option\n" + " \":nodrop\" same as -nodrop option\n" + " \":packed\" same as -packed option\n" + " \":sbr\" same as -sbr option\n" + " \":sbrx\" same as -sbrx option\n" + " \":ps\" same as -ps option\n" + " \":psx\" same as -psx option\n" + " \":ovsbr\" same as -ovsbr option\n" + " \":mpeg4\" same as -mpeg4 option\n" + " \":svc\" import SVC with explicit signaling (no AVC base compatibility)\n" + " \":nosvc\" discard SVC data when importing\n" + " \":svcmode=MODE\" sets SVC import mode:\n" + " \" split : each AVC/SVC layer is in its own track\n" + " \" merge : all AVC/SVC layers are merged in a single track\n" + " \" splitbase : all SVC layers are merged in a track, and the AVC base in another\n" + " \":subsamples\" adds SubSample information for AVC+SVC\n" + " \":forcesync\" forces non IDR samples with I slices to be marked as sync points (AVC GDR)\n" + " !! RESULTING FILE IS NOT COMPLIANT WITH THE SPEC but will fix seeking in most players\n" + " \":font=name\" specifies font name for text import (default \"Serif\")\n" + " \":size=s\" specifies font size for text import (default 18)\n" + " \":stype=4CC\" forces the sample description type to a different value\n" + " !! THIS MAY BREAK THE FILE WRITING !!\n" + " \":chap\" specifies the track is a chapter track\n" + " \":chapter=NAME\" adds a single chapter (old nero format) with given name lasting the entire file\n" + " This command can be used in -cat as well\n" + " \":chapfile=file\" adds a chapter file (old nero format)\n" + " This command can be used in -cat as well\n" + " \":layout=WxHxXxY\" specifies the track layout\n" + " - if W (resp H) = 0, the max width (resp height) of\n" + " the tracks in the file are used.\n" + " - if Y=-1, the layout is moved to the bottom of the\n" + " track area\n" + " - X and Y can be omitted (:layout=WxH)\n" + " \":rescale=TS\" forces media timescale to TS !! changes the media duration\n" + " \":timescale=TS\" sets import timescale to TS\n" + " \":swf-global\" all SWF defines are placed in first scene replace\n" + " * Note: By default SWF defines are sent when needed\n" + " \":swf-no-ctrl\" uses a single stream for movie control and dictionary\n" + " * Note: this will disable ActionScript\n" + " \":swf-no-text\" removes all SWF text\n" + " \":swf-no-font\" removes all embedded SWF Fonts (terminal fonts used)\n" + " \":swf-no-line\" removes all lines from SWF shapes\n" + " \":swf-no-grad\" removes all gradients from swf shapes\n" + " \":swf-quad\" uses quadratic bezier curves instead of cubic ones\n" + " \":swf-xlp\" support for lines transparency and scalability\n" + " \":swf-flatten=ang\" complementary angle below which 2 lines are merged\n" + " * Note: angle \'0\' means no flattening\n" + "\n" + " \":negctts\" uses negative CTS-DTS offsets (ISO4 brand)\n" + " -add file add file tracks to (new) output file\n" + " -cat file concatenates file samples to (new) output file\n" + " * Note: creates tracks if needed\n" + " * Note: aligns initial timestamp of the file to be concatenated.\n" + " -catx file same as cat but new tracks can be imported before concatenation by specifying '+ADD_COMMAND'\n" + " where ADD_COMMAND is a regular -add syntax\n" + " -unalign-cat does not attempt to align timestamps of samples inbetween tracks\n" + " -force-cat skips media configuration check when concatenating file\n" + " !!! THIS MAY BREAK THE CONCATENATED TRACK(S) !!!\n" + " -keep-sys keeps all MPEG-4 Systems info when using '-add' / 'cat'\n" + " -keep-all keeps all existing tracks when using '-add'\n" + " * Note: only used when adding IsoMedia files\n" + "\n" + "All the following options can be specified as default or for each track.\n" + "When specified by track the syntax is \":opt\" or \":opt=val\".\n\n" + " -dref keeps media data in original file\n" + " -no-drop forces constant FPS when importing AVI video\n" + " -packed forces packed bitstream when importing raw ASP\n" + " -sbr backward compatible signaling of AAC-SBR\n" + " -sbrx non-backward compatible signaling of AAC-SBR\n" + " -ps backward compatible signaling of AAC-PS\n" + " -psx non-backward compatible signaling of AAC-PS\n" + " -ovsbr oversample SBR\n" + " * Note: SBR AAC, PS AAC and oversampled SBR cannot be detected at import time\n" + " -fps FPS forces frame rate for video and SUB subtitles import\n" + " FPS is either a number or expressed as timescale-increment\n" + " * For raw H263 import, default FPS is 15\n" + " * For all other imports, default FPS is 25\n" + " !! THIS IS IGNORED FOR IsoMedia IMPORT !!\n" + " -mpeg4 forces MPEG-4 sample descriptions when possible (3GPP2)\n" + " For AAC, forces MPEG-4 AAC signaling even if MPEG-2\n" + " -agg N aggregates N audio frames in 1 sample (3GP media only)\n" + " * Note: Maximum value is 15 - Disabled by default\n" + "\n" + ); } void PrintEncodeUsage() { fprintf(stderr, "MPEG-4 Scene Encoding Options\n" - " -mp4 specify input file is for encoding.\n" - " -def encode DEF names\n" - " -sync time_in_ms forces BIFS sync sample generation every time_in_ms\n" - " * Note: cannot be used with -shadow\n" - " -shadow time_ms forces BIFS sync shadow sample generation every time_ms.\n" - " * Note: cannot be used with -sync\n" - " -log generates scene codec log file if available\n" - " -ms file specifies file for track importing\n" - "\nChunk Processing\n" - " -ctx-in file specifies initial context (MP4/BT/XMT)\n" - " * Note: input file must be a commands-only file\n" - " -ctx-out file specifies storage of updated context (MP4/BT/XMT)\n" - "\n" - "LASeR Encoding options\n" - " -resolution res resolution factor (-8 to 7, default 0)\n" - " all coords are multiplied by 2^res before truncation\n" - " -coord-bits bits bits used for encoding truncated coordinates\n" - " (0 to 31, default 12)\n" - " -scale-bits bits extra bits used for encoding truncated scales\n" - " (0 to 4, default 0)\n" - " -auto-quant res resolution is given as if using -resolution\n" - " but coord-bits and scale-bits are infered\n" - ); + " -mp4 specify input file is for encoding.\n" + " -def encode DEF names\n" + " -sync time_in_ms forces BIFS sync sample generation every time_in_ms\n" + " * Note: cannot be used with -shadow\n" + " -shadow time_ms forces BIFS sync shadow sample generation every time_ms.\n" + " * Note: cannot be used with -sync\n" + " -log generates scene codec log file if available\n" + " -ms file specifies file for track importing\n" + "\nChunk Processing\n" + " -ctx-in file specifies initial context (MP4/BT/XMT)\n" + " * Note: input file must be a commands-only file\n" + " -ctx-out file specifies storage of updated context (MP4/BT/XMT)\n" + "\n" + "LASeR Encoding options\n" + " -resolution res resolution factor (-8 to 7, default 0)\n" + " all coords are multiplied by 2^res before truncation\n" + " -coord-bits bits bits used for encoding truncated coordinates\n" + " (0 to 31, default 12)\n" + " -scale-bits bits extra bits used for encoding truncated scales\n" + " (0 to 4, default 0)\n" + " -auto-quant res resolution is given as if using -resolution\n" + " but coord-bits and scale-bits are infered\n" + ); } void PrintEncryptUsage() { fprintf(stderr, "ISMA Encryption/Decryption Options\n" - " -crypt drm_file crypts a specific track using ISMA AES CTR 128\n" - " -decrypt [drm_file] decrypts a specific track using ISMA AES CTR 128\n" - " * Note: drm_file can be omitted if keys are in file\n" - " -set-kms kms_uri changes KMS location for all tracks or a given one.\n" - " * to adress a track, use \'tkID=kms_uri\'\n" - "\n" - "DRM file syntax for GPAC ISMACryp:\n" - " File is XML and shall start with xml header\n" - " File root is an \"ISMACryp\" element\n" - " File is a list of \"cryptrack\" elements\n" - "\n" - "cryptrack attributes are\n" - " TrackID ID of track to en/decrypt\n" - " key AES-128 key formatted (hex string \'0x\'+32 chars)\n" - " salt CTR IV salt key (64 bits) (hex string \'0x\'+16 chars)\n" - "\nEncryption only attributes:\n" - " Scheme_URI URI of scheme used\n" - " KMS_URI URI of key management system\n" - " * Note: \'self\' writes key and salt in the file\n" - " selectiveType selective encryption type - understood values are:\n" - " \"None\" all samples encrypted (default)\n" - " \"RAP\" only encrypts random access units\n" - " \"Non-RAP\" only encrypts non-random access units\n" - " \"Rand\" random selection is performed\n" - " \"X\" Encrypts every first sample out of X (uint)\n" - " \"RandX\" Encrypts one random sample out of X (uint)\n" - "\n" - " ipmpType IPMP Signaling Type: None, IPMP, IPMPX\n" - " ipmpDescriptorID IPMP_Descriptor ID to use if IPMP(X) is used\n" - " * If not set MP4Box will generate one for you\n" - "\n" - ); + " -crypt drm_file crypts a specific track using ISMA AES CTR 128\n" + " -decrypt [drm_file] decrypts a specific track using ISMA AES CTR 128\n" + " * Note: drm_file can be omitted if keys are in file\n" + " -set-kms kms_uri changes KMS location for all tracks or a given one.\n" + " * to adress a track, use \'tkID=kms_uri\'\n" + "\n" + "DRM file syntax for GPAC ISMACryp:\n" + " File is XML and shall start with xml header\n" + " File root is an \"ISMACryp\" element\n" + " File is a list of \"cryptrack\" elements\n" + "\n" + "cryptrack attributes are\n" + " TrackID ID of track to en/decrypt\n" + " key AES-128 key formatted (hex string \'0x\'+32 chars)\n" + " salt CTR IV salt key (64 bits) (hex string \'0x\'+16 chars)\n" + "\nEncryption only attributes:\n" + " Scheme_URI URI of scheme used\n" + " KMS_URI URI of key management system\n" + " * Note: \'self\' writes key and salt in the file\n" + " selectiveType selective encryption type - understood values are:\n" + " \"None\" all samples encrypted (default)\n" + " \"RAP\" only encrypts random access units\n" + " \"Non-RAP\" only encrypts non-random access units\n" + " \"Rand\" random selection is performed\n" + " \"X\" Encrypts every first sample out of X (uint)\n" + " \"RandX\" Encrypts one random sample out of X (uint)\n" + "\n" + " ipmpType IPMP Signaling Type: None, IPMP, IPMPX\n" + " ipmpDescriptorID IPMP_Descriptor ID to use if IPMP(X) is used\n" + " * If not set MP4Box will generate one for you\n" + "\n" + ); } void PrintHintUsage() { fprintf(stderr, "Hinting Options\n" - " -hint hints the file for RTP/RTSP\n" - " -mtu size specifies RTP MTU (max size) in bytes. Default size is 1450\n" - " * Note: this includes the RTP header (12 bytes)\n" - " -copy copies media data to hint track rather than reference\n" - " * Note: speeds up server but takes much more space\n" - " -multi [maxptime] enables frame concatenation in RTP packets if possible\n" - " maxptime max packet duration in ms (optional, default 100ms)\n" - " -rate ck_rate specifies rtp rate in Hz when no default for payload\n" - " * Note: default value is 90000 (MPEG rtp rates)\n" - " -mpeg4 forces MPEG-4 generic payload whenever possible\n" - " -latm forces MPG4-LATM transport for AAC streams\n" - " -static enables static RTP payload IDs whenever possible\n" - " * By default, dynamic payloads are always used\n" - "\n" - "MPEG-4 Generic Payload Options\n" - " -ocr forces all streams to be synchronized\n" - " * Most RTSP servers only support synchronized streams\n" - " -rap signals random access points in RTP packets\n" - " -ts signals AU Time Stamps in RTP packets\n" - " -size signals AU size in RTP packets\n" - " -idx signals AU sequence numbers in RTP packets\n" - " -iod prevents systems tracks embedding in IOD\n" - " * Note: shouldn't be used with -isma option\n" - "\n" - " -add-sdp string adds sdp string to (hint) track (\"-add-sdp tkID:string\")\n" - " or movie. This will take care of SDP lines ordering\n" - " -unhint removes all hinting information.\n" - "\n"); + " -hint hints the file for RTP/RTSP\n" + " -mtu size specifies RTP MTU (max size) in bytes. Default size is 1450\n" + " * Note: this includes the RTP header (12 bytes)\n" + " -copy copies media data to hint track rather than reference\n" + " * Note: speeds up server but takes much more space\n" + " -multi [maxptime] enables frame concatenation in RTP packets if possible\n" + " maxptime max packet duration in ms (optional, default 100ms)\n" + " -rate ck_rate specifies rtp rate in Hz when no default for payload\n" + " * Note: default value is 90000 (MPEG rtp rates)\n" + " -mpeg4 forces MPEG-4 generic payload whenever possible\n" + " -latm forces MPG4-LATM transport for AAC streams\n" + " -static enables static RTP payload IDs whenever possible\n" + " * By default, dynamic payloads are always used\n" + "\n" + "MPEG-4 Generic Payload Options\n" + " -ocr forces all streams to be synchronized\n" + " * Most RTSP servers only support synchronized streams\n" + " -rap signals random access points in RTP packets\n" + " -ts signals AU Time Stamps in RTP packets\n" + " -size signals AU size in RTP packets\n" + " -idx signals AU sequence numbers in RTP packets\n" + " -iod prevents systems tracks embedding in IOD\n" + " * Note: shouldn't be used with -isma option\n" + "\n" + " -add-sdp string adds sdp string to (hint) track (\"-add-sdp tkID:string\")\n" + " or movie. This will take care of SDP lines ordering\n" + " -unhint removes all hinting information.\n" + "\n"); } void PrintExtractUsage() { fprintf(stderr, "Extracting Options:\n" - " -raw TrackID extracts track in raw format when supported\n" - " :output=FileName sets the output filename for this extraction \n" - " -raws TrackID extract each track sample to a file\n" - " * Note: \"TrackID:N\" extracts Nth sample\n" - " -nhnt TrackID extracts track in nhnt format\n" - " -nhml TrackID extracts track in nhml format (XML nhnt).\n" - " * Note: \"-nhml TrackID:full\" for full dump\n" - " -webvtt-raw TrackID extracts raw media track in WebVTT as metadata.\n" - " * Note: \"-webvtt-raw TrackID:embedded\" to include media data in the WebVTT file\n" - " -six TrackID extracts raw media track in experimental XML streaming instructions.\n" - " -single TrackID extracts track to a new mp4 file\n" - " -avi TrackID extracts visual track to an avi file\n" - " -qcp TrackID same as \'-raw\' but defaults to QCP file for EVRC/SMV\n" - " -aviraw TK extracts AVI track in raw format\n" - " $TK can be one of \"video\" \"audio\" \"audioN\"\n" - " -saf remux file to SAF multiplex\n" - " -dvbhdemux demux DVB-H file into IP Datagrams\n" - " * Note: can be used when encoding scene descriptions\n" - " -raw-layer ID same as -raw but skips SVC/MVC extractors when extracting\n" - " -diod extracts file IOD in raw format when supported\n" - "\n" + " -raw TrackID extracts track in raw format when supported\n" + " :output=FileName sets the output filename for this extraction \n" + " -raws TrackID extract each track sample to a file\n" + " * Note: \"TrackID:N\" extracts Nth sample\n" + " -nhnt TrackID extracts track in nhnt format\n" + " -nhml TrackID extracts track in nhml format (XML nhnt).\n" + " * Note: \"-nhml TrackID:full\" for full dump\n" + " -webvtt-raw TrackID extracts raw media track in WebVTT as metadata.\n" + " * Note: \"-webvtt-raw TrackID:embedded\" to include media data in the WebVTT file\n" + " -six TrackID extracts raw media track in experimental XML streaming instructions.\n" + " -single TrackID extracts track to a new mp4 file\n" + " -avi TrackID extracts visual track to an avi file\n" + " -qcp TrackID same as \'-raw\' but defaults to QCP file for EVRC/SMV\n" + " -aviraw TK extracts AVI track in raw format\n" + " $TK can be one of \"video\" \"audio\" \"audioN\"\n" + " -saf remux file to SAF multiplex\n" + " -dvbhdemux demux DVB-H file into IP Datagrams\n" + " * Note: can be used when encoding scene descriptions\n" + " -raw-layer ID same as -raw but skips SVC/MVC extractors when extracting\n" + " -diod extracts file IOD in raw format when supported\n" + "\n" #if !defined(GPAC_DISABLE_STREAMING) - " -grab-ts IP:port grabs TS over UDP or RTP at IP:port location to output TS file\n" + " -grab-ts IP:port grabs TS over UDP or RTP at IP:port location to output TS file\n" #endif - "\n"); + "\n"); } void PrintDumpUsage() { fprintf(stderr, "Dumping Options\n" - " -stdb dumps/write to stdout and assumes stdout is opened in binary mode\n" - " -std dumps/write to stdout and try to reopen stdout in binary mode.\n" - " -info [trackID] prints movie info / track info if trackID specified\n" - " * Note: for non IsoMedia files, gets import options\n" - " -bt scene to bt format - removes unknown MPEG4 nodes\n" - " -xmt scene to XMT-A format - removes unknown MPEG4 nodes\n" - " -wrl scene VRML format - removes unknown VRML nodes\n" - " -x3d scene to X3D/XML format - removes unknown X3D nodes\n" - " -x3dv scene to X3D/VRML format - removes unknown X3D nodes\n" - " -lsr scene to LASeR format\n" - " -diso scene IsoMedia file boxes in XML output\n" - " -drtp rtp hint samples structure to XML output\n" - " -dts prints sample timing to text output\n" - " -dnal trackID prints NAL sample info of given track\n" - " -sdp dumps SDP description of hinted file\n" - " -dcr ISMACryp samples structure to XML output\n" - " -dump-cover Extracts cover art\n" - " -dump-chap Extracts chapter file\n" - "\n" + " -stdb dumps/write to stdout and assumes stdout is opened in binary mode\n" + " -std dumps/write to stdout and try to reopen stdout in binary mode.\n" + " -info [trackID] prints movie info / track info if trackID specified\n" + " * Note: for non IsoMedia files, gets import options\n" + " -bt scene to bt format - removes unknown MPEG4 nodes\n" + " -xmt scene to XMT-A format - removes unknown MPEG4 nodes\n" + " -wrl scene VRML format - removes unknown VRML nodes\n" + " -x3d scene to X3D/XML format - removes unknown X3D nodes\n" + " -x3dv scene to X3D/VRML format - removes unknown X3D nodes\n" + " -lsr scene to LASeR format\n" + " -diso scene IsoMedia file boxes in XML output\n" + " -drtp rtp hint samples structure to XML output\n" + " -dts prints sample timing to text output\n" + " -dnal trackID prints NAL sample info of given track\n" + " -sdp dumps SDP description of hinted file\n" + " -dcr ISMACryp samples structure to XML output\n" + " -dump-cover Extracts cover art\n" + " -dump-chap Extracts chapter file\n" + "\n" #ifndef GPAC_DISABLE_ISOM_WRITE - " -ttxt Converts input subtitle to GPAC TTXT format\n" + " -ttxt Converts input subtitle to GPAC TTXT format\n" #endif - " -ttxt TrackID Dumps Text track to GPAC TTXT format\n" + " -ttxt TrackID Dumps Text track to GPAC TTXT format\n" #ifndef GPAC_DISABLE_ISOM_WRITE - " -srt Converts input subtitle to SRT format\n" -#endif - " -srt TrackID Dumps Text track to SRT format\n" - "\n" - " -stat generates node/field statistics for scene\n" - " -stats generates node/field statistics per MPEG-4 Access Unit\n" - " -statx generates node/field statistics for scene after each AU\n" - "\n" - " -hash generates SHA-1 Hash of the input file\n" - "\n"); + " -srt Converts input subtitle to SRT format\n" +#endif + " -srt TrackID Dumps Text track to SRT format\n" + "\n" + " -stat generates node/field statistics for scene\n" + " -stats generates node/field statistics per MPEG-4 Access Unit\n" + " -statx generates node/field statistics for scene after each AU\n" + "\n" + " -hash generates SHA-1 Hash of the input file\n" + "\n"); } void PrintMetaUsage() { fprintf(stderr, "Meta handling Options\n" - " -set-meta args sets given meta type - syntax: \"ABCD[:tk=ID]\"\n" - " * ABCD: four char meta type (NULL or 0 to remove meta)\n" - " * [:tk=ID]: if not set use root (file) meta\n" - " if ID is 0 use moov meta\n" - " if ID is not 0 use track meta\n" - " -add-item args adds resource to meta\n" - " * syntax: file_path + options (\':\' separated):\n" - " tk=ID: meta adressing (file, moov, track)\n" - " name=str: item name\n" - " mime=mtype: item mime type\n" - " encoding=enctype: item content-encoding type\n" - " id=id: item ID\n" - " * file_path \"this\" or \"self\": item is the file itself\n" - " -rem-item args removes resource from meta - syntax: item_ID[:tk=ID]\n" - " -set-primary args sets item as primary for meta - syntax: item_ID[:tk=ID]\n" - " -set-xml args sets meta XML data\n" - " * syntax: xml_file_path[:tk=ID][:binary]\n" - " -rem-xml [tk=ID] removes meta XML data\n" - " -dump-xml args dumps meta XML to file - syntax file_path[:tk=ID]\n" - " -dump-item args dumps item to file - syntax item_ID[:tk=ID][:path=fileName]\n" - " -package packages input XML file into an ISO container\n" - " * all media referenced except hyperlinks are added to file\n" - " -mgt packages input XML file into an MPEG-U widget with ISO container.\n" - " * all files contained in the current folder are added to the widget package\n" - "\n"); + " -set-meta args sets given meta type - syntax: \"ABCD[:tk=ID]\"\n" + " * ABCD: four char meta type (NULL or 0 to remove meta)\n" + " * [:tk=ID]: if not set use root (file) meta\n" + " if ID is 0 use moov meta\n" + " if ID is not 0 use track meta\n" + " -add-item args adds resource to meta\n" + " * syntax: file_path + options (\':\' separated):\n" + " tk=ID: meta adressing (file, moov, track)\n" + " name=str: item name\n" + " mime=mtype: item mime type\n" + " encoding=enctype: item content-encoding type\n" + " id=id: item ID\n" + " * file_path \"this\" or \"self\": item is the file itself\n" + " -rem-item args removes resource from meta - syntax: item_ID[:tk=ID]\n" + " -set-primary args sets item as primary for meta - syntax: item_ID[:tk=ID]\n" + " -set-xml args sets meta XML data\n" + " * syntax: xml_file_path[:tk=ID][:binary]\n" + " -rem-xml [tk=ID] removes meta XML data\n" + " -dump-xml args dumps meta XML to file - syntax file_path[:tk=ID]\n" + " -dump-item args dumps item to file - syntax item_ID[:tk=ID][:path=fileName]\n" + " -package packages input XML file into an ISO container\n" + " * all media referenced except hyperlinks are added to file\n" + " -mgt packages input XML file into an MPEG-U widget with ISO container.\n" + " * all files contained in the current folder are added to the widget package\n" + "\n"); } void PrintSWFUsage() { - fprintf(stderr, - "SWF Importer Options\n" - "\n" - "MP4Box can import simple Macromedia Flash files (\".SWF\")\n" - "You can specify a SWF input file with \'-bt\', \'-xmt\' and \'-mp4\' options\n" - "\n" - " -global all SWF defines are placed in first scene replace\n" - " * Note: By default SWF defines are sent when needed\n" - " -no-ctrl uses a single stream for movie control and dictionary\n" - " * Note: this will disable ActionScript\n" - " -no-text removes all SWF text\n" - " -no-font removes all embedded SWF Fonts (terminal fonts used)\n" - " -no-line removes all lines from SWF shapes\n" - " -no-grad removes all gradients from swf shapes\n" - " -quad uses quadratic bezier curves instead of cubic ones\n" - " -xlp support for lines transparency and scalability\n" - " -flatten ang complementary angle below which 2 lines are merged\n" - " * Note: angle \'0\' means no flattening\n" - "\n" - ); + fprintf(stderr, + "SWF Importer Options\n" + "\n" + "MP4Box can import simple Macromedia Flash files (\".SWF\")\n" + "You can specify a SWF input file with \'-bt\', \'-xmt\' and \'-mp4\' options\n" + "\n" + " -global all SWF defines are placed in first scene replace\n" + " * Note: By default SWF defines are sent when needed\n" + " -no-ctrl uses a single stream for movie control and dictionary\n" + " * Note: this will disable ActionScript\n" + " -no-text removes all SWF text\n" + " -no-font removes all embedded SWF Fonts (terminal fonts used)\n" + " -no-line removes all lines from SWF shapes\n" + " -no-grad removes all gradients from swf shapes\n" + " -quad uses quadratic bezier curves instead of cubic ones\n" + " -xlp support for lines transparency and scalability\n" + " -flatten ang complementary angle below which 2 lines are merged\n" + " * Note: angle \'0\' means no flattening\n" + "\n" + ); } void PrintUsage() { fprintf (stderr, "MP4Box [option] input [option]\n" - " -h general general options help\n" - " -h hint hinting options help\n" - " -h dash DASH segmenter help\n" - " -h import import options help\n" - " -h encode encode options help\n" - " -h meta meta handling options help\n" - " -h extract extraction options help\n" - " -h dump dump options help\n" - " -h swf Flash (SWF) options help\n" - " -h crypt ISMA E&A options help\n" - " -h format supported formats help\n" - " -h rtp file streamer help\n" - " -h live BIFS streamer help\n" - " -h all all options are printed\n" - "\n" - " -nodes lists supported MPEG4 nodes\n" - " -node NodeName gets MPEG4 node syntax and QP info\n" - " -xnodes lists supported X3D nodes\n" - " -xnode NodeName gets X3D node syntax\n" - " -snodes lists supported SVG nodes\n" - " -snode NodeName gets SVG node syntax\n" - " -languages lists supported ISO 639 languages\n" - "\n" - " -quiet quiet mode\n" - " -noprog disables progress\n" - " -v verbose mode\n" - " -logs set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" - " -version gets build version\n" - " -- INPUT escape option if INPUT starts with - character\n" - "\n" - ); + " -h general general options help\n" + " -h hint hinting options help\n" + " -h dash DASH segmenter help\n" + " -h import import options help\n" + " -h encode encode options help\n" + " -h meta meta handling options help\n" + " -h extract extraction options help\n" + " -h dump dump options help\n" + " -h swf Flash (SWF) options help\n" + " -h crypt ISMA E&A options help\n" + " -h format supported formats help\n" + " -h rtp file streamer help\n" + " -h live BIFS streamer help\n" + " -h all all options are printed\n" + "\n" + " -nodes lists supported MPEG4 nodes\n" + " -node NodeName gets MPEG4 node syntax and QP info\n" + " -xnodes lists supported X3D nodes\n" + " -xnode NodeName gets X3D node syntax\n" + " -snodes lists supported SVG nodes\n" + " -snode NodeName gets SVG node syntax\n" + " -languages lists supported ISO 639 languages\n" + "\n" + " -quiet quiet mode\n" + " -noprog disables progress\n" + " -v verbose mode\n" + " -logs set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" + " -version gets build version\n" + " -- INPUT escape option if INPUT starts with - character\n" + "\n" + ); } @@ -758,7 +762,7 @@ void scene_coding_log(void *cbk, u32 log_level, u32 log_tool, const char *fmt, v { FILE *logs = cbk; if (log_tool != GF_LOG_CODING) return; - vfprintf(logs, fmt, vlist); + vfprintf(logs, fmt, vlist); fflush(logs); } @@ -812,7 +816,7 @@ GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 tot_bw = 0; prev_ocr = 0; single_ocr = 1; - + has_iod = 1; iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file); if (!iod) has_iod = 0; @@ -914,26 +918,26 @@ GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 if (!nb_done) return e; } continue; - } + } bw = gf_hinter_track_get_bandwidth(hinter); tot_bw += bw; flags = gf_hinter_track_get_flags(hinter); - + //set extraction mode for AVC/SVC gf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY); gf_hinter_track_get_payload_name(hinter, szPayload); fprintf(stderr, "Hinting track ID %d - Type \"%s:%s\" (%s) - BW %d kbps\n", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw); if (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) fprintf(stderr, "\tMPEG-4 Systems stream carousel enabled\n"); -/* - if (flags & GP_RTP_PCK_FORCE_MPEG4) fprintf(stderr, "\tMPEG4 transport forced\n"); - if (flags & GP_RTP_PCK_USE_MULTI) fprintf(stderr, "\tRTP aggregation enabled\n"); -*/ + /* + if (flags & GP_RTP_PCK_FORCE_MPEG4) fprintf(stderr, "\tMPEG4 transport forced\n"); + if (flags & GP_RTP_PCK_USE_MULTI) fprintf(stderr, "\tRTP aggregation enabled\n"); + */ e = gf_hinter_track_process(hinter); if (!e) e = gf_hinter_track_finalize(hinter, has_iod); gf_hinter_track_del(hinter); - + if (e) { fprintf(stderr, "Error while hinting (%s)\n", gf_error_to_string(e)); if (!nb_done) return e; @@ -983,9 +987,9 @@ static void check_media_profile(GF_ISOFile *file, u32 track) case 0x05: PL = gf_isom_get_pl_indication(file, GF_ISOM_PL_AUDIO); switch (esd->decoderConfig->objectTypeIndication) { - case GPAC_OTI_AUDIO_AAC_MPEG2_MP: - case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: - case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: + case GPAC_OTI_AUDIO_AAC_MPEG2_MP: + case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: + case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: case GPAC_OTI_AUDIO_AAC_MPEG4: gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi); if (dsi.audioPL > PL) gf_isom_set_pl_indication(file, GF_ISOM_PL_AUDIO, dsi.audioPL); @@ -1051,8 +1055,8 @@ void remove_systems_tracks(GF_ISOFile *file) #endif /*!defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_AV_PARSERS)*/ /*return value: - 0: not supported - 1: ISO media + 0: not supported + 1: ISO media 2: input bt file (.bt, .wrl) 3: input XML file (.xmt) 4: input SVG file (.svg) @@ -1157,18 +1161,36 @@ static Bool parse_meta_args(MetaAction *meta, u32 act_type, char *opts) /*use ':' as separator, but beware DOS paths...*/ if (next && next[1]=='\\') next = strchr(szSlot+2, ':'); if (next) next[0] = 0; - + if (!strnicmp(szSlot, "tk=", 3)) { sscanf(szSlot, "tk=%u", &meta->trackID); meta->root_meta = 0; ret = 1; } - else if (!strnicmp(szSlot, "id=", 3)) { meta->item_id = atoi(szSlot+3); ret = 1; } - else if (!strnicmp(szSlot, "name=", 5)) { strcpy(meta->szName, szSlot+5); ret = 1; } - else if (!strnicmp(szSlot, "path=", 5)) { strcpy(meta->szPath, szSlot+5); ret = 1; } - else if (!strnicmp(szSlot, "mime=", 5)) { strcpy(meta->mime_type, szSlot+5); ret = 1; } - else if (!strnicmp(szSlot, "encoding=", 9)) { strcpy(meta->enc_type, szSlot+9); ret = 1; } - else if (!strnicmp(szSlot, "dref", 4)) { meta->use_dref = 1; ret = 1; } + else if (!strnicmp(szSlot, "id=", 3)) { + meta->item_id = atoi(szSlot+3); + ret = 1; + } + else if (!strnicmp(szSlot, "name=", 5)) { + strcpy(meta->szName, szSlot+5); + ret = 1; + } + else if (!strnicmp(szSlot, "path=", 5)) { + strcpy(meta->szPath, szSlot+5); + ret = 1; + } + else if (!strnicmp(szSlot, "mime=", 5)) { + strcpy(meta->mime_type, szSlot+5); + ret = 1; + } + else if (!strnicmp(szSlot, "encoding=", 9)) { + strcpy(meta->enc_type, szSlot+9); + ret = 1; + } + else if (!strnicmp(szSlot, "dref", 4)) { + meta->use_dref = 1; + ret = 1; + } else if (!stricmp(szSlot, "binary")) { if (meta->act_type==4) meta->act_type=5; ret = 1; @@ -1180,16 +1202,16 @@ static Bool parse_meta_args(MetaAction *meta, u32 act_type, char *opts) else meta->meta_4cc = GF_4CC(szSlot[0], szSlot[1], szSlot[2], szSlot[3]); ret = 1; break; - case 1: - case 4: - case 7: - strcpy(meta->szPath, szSlot); + case 1: + case 4: + case 7: + strcpy(meta->szPath, szSlot); ret = 1; break; - case 2: - case 3: - case 8: - meta->item_id = atoi(szSlot); + case 2: + case 3: + case 8: + meta->item_id = atoi(szSlot); ret = 1; break; } @@ -1204,7 +1226,7 @@ static Bool parse_meta_args(MetaAction *meta, u32 act_type, char *opts) typedef struct -{ +{ /*0: set tsel param - 1 remove tsel - 2 remove all tsel info in alternate group - 3 remove all tsel info in file*/ u32 act_type; u32 trackID; @@ -1230,7 +1252,7 @@ static Bool parse_tsel_args(TSELAction **__tsel_list, char *opts, u32 *nb_tsel_a has_switch_id = 0; act = tsel_list[*nb_tsel_act].act_type; - + if (!opts) return 0; while (1) { @@ -1243,19 +1265,19 @@ static Bool parse_tsel_args(TSELAction **__tsel_list, char *opts, u32 *nb_tsel_a if (next) next[0] = 0; - if (!strnicmp(szSlot, "ref=", 4)) refTrackID = atoi(szSlot+4); + if (!strnicmp(szSlot, "ref=", 4)) refTrackID = atoi(szSlot+4); else if (!strnicmp(szSlot, "switchID=", 9)) { if (atoi(szSlot+9)<0) { - switch_id = 0; + switch_id = 0; has_switch_id = 0; } else { - switch_id = atoi(szSlot+9); + switch_id = atoi(szSlot+9); has_switch_id = 1; } } else if (!strnicmp(szSlot, "switchID", 8)) { - switch_id = 0; - has_switch_id = 1; + switch_id = 0; + has_switch_id = 1; } else if (!strnicmp(szSlot, "criteria=", 9)) { u32 j=9; @@ -1284,7 +1306,7 @@ static Bool parse_tsel_args(TSELAction **__tsel_list, char *opts, u32 *nb_tsel_a refTrackID = tsel_act->trackID; (*nb_tsel_act) ++; - } + } opts += strlen(szSlot); } return 1; @@ -1306,7 +1328,7 @@ typedef struct 7: disables track 8: referenceTrack 9: raw extraction - 10: remove non-rap + 10: remove non-rap */ u32 act_type; /*track ID*/ @@ -1346,7 +1368,7 @@ enum if (dash_inputs) gf_free(dash_inputs); \ gf_sys_close(); \ return __ret_code; \ - + GF_DashSegmenterInput *set_dash_input(GF_DashSegmenterInput *dash_inputs, char *name, u32 *nb_dash_inputs) { @@ -1371,7 +1393,7 @@ GF_DashSegmenterInput *set_dash_input(GF_DashSegmenterInput *dash_inputs, char * u32 i; strncpy(di->representationID, opts+3, 99); /* check to see if this representation Id has already been assigned */ - for (i=0; i<(*nb_dash_inputs)-1;i++) { + for (i=0; i<(*nb_dash_inputs)-1; i++) { GF_DashSegmenterInput *other_di; other_di = &dash_inputs[i]; if (!strcmp(other_di->representationID, di->representationID)) { @@ -1383,7 +1405,7 @@ GF_DashSegmenterInput *set_dash_input(GF_DashSegmenterInput *dash_inputs, char * GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] PeriodID cannot exceed 99 characters in MP4Box, truncating ...\n")); } strncpy(di->periodID, opts+7, 99); - } + } else if (!strnicmp(opts, "bandwidth=", 10)) di->bandwidth = atoi(opts+10); else if (!strnicmp(opts, "role=", 5)) strncpy(di->role, opts+5, 99); else if (!strnicmp(opts, "xlink=", 6)) { @@ -1392,7 +1414,7 @@ GF_DashSegmenterInput *set_dash_input(GF_DashSegmenterInput *dash_inputs, char * } strncpy(di->xlink, opts+6, 199); } - + if (!sep) break; sep[0] = ':'; opts = sep+1; @@ -1427,12 +1449,12 @@ static GF_Err parse_track_action_params(char *string, TrackAction *action) action->sample_num = atoi(param); } #endif - } + } } if (!strcmp(string, "*")) { action->trackID = (u32) -1; } else { - action->trackID = atoi(string); + action->trackID = atoi(string); } return GF_OK; } @@ -1527,7 +1549,7 @@ int mp4boxMain(int argc, char **argv) const char *grab_m2ts = NULL; #endif FILE *logfile = NULL; - + nb_tsel_acts = nb_add = nb_cat = nb_track_act = nb_sdp_ex = max_ptime = raw_sample_num = nb_meta_act = rtp_rate = major_brand = nb_alt_brand_add = nb_alt_brand_rem = car_dur = minor_version = 0; e = GF_OK; split_duration = 0.0; @@ -1579,7 +1601,7 @@ int mp4boxMain(int argc, char **argv) #ifdef GPAC_MEMORY_TRACKING enable_mem_tracker = 1; #else - fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); + fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); #endif break; } @@ -1604,9 +1626,9 @@ int mp4boxMain(int argc, char **argv) i++; } if (argc < 3) { - fprintf(stderr, "Error - only one input file found as argument, please check usage\n"); - MP4BOX_EXIT_WITH_CODE(1); - } else if (inName) { + fprintf(stderr, "Error - only one input file found as argument, please check usage\n"); + MP4BOX_EXIT_WITH_CODE(1); + } else if (inName) { if (dash_duration) { if (!nb_dash_inputs) { dash_inputs = set_dash_input(dash_inputs, inName, &nb_dash_inputs); @@ -1614,18 +1636,24 @@ int mp4boxMain(int argc, char **argv) dash_inputs = set_dash_input(dash_inputs, arg_val, &nb_dash_inputs); } else { fprintf(stderr, "Error - 2 input names specified, please check usage\n"); - MP4BOX_EXIT_WITH_CODE(1); + MP4BOX_EXIT_WITH_CODE(1); } } else { inName = arg_val; } } - else if (!stricmp(arg, "-?")) { PrintUsage(); MP4BOX_EXIT_WITH_CODE(0); } - else if (!stricmp(arg, "-version")) { PrintVersion(); MP4BOX_EXIT_WITH_CODE(0); } + else if (!stricmp(arg, "-?")) { + PrintUsage(); + MP4BOX_EXIT_WITH_CODE(0); + } + else if (!stricmp(arg, "-version")) { + PrintVersion(); + MP4BOX_EXIT_WITH_CODE(0); + } else if (!stricmp(arg, "-sdp")) print_sdp = 1; else if (!stricmp(arg, "-quiet")) quiet = 2; else if (!strcmp(argv[i], "-mem-track")) continue; - + else if (!stricmp(arg, "-logs")) { CHECK_NEXT_ARG gf_logs = argv[i+1]; @@ -1637,7 +1665,7 @@ int mp4boxMain(int argc, char **argv) logfile = gf_f64_open(argv[i+1], "wt"); gf_log_set_callback(logfile, on_gpac_log); i++; - } + } else if (!stricmp(arg, "-noprog")) quiet = 1; else if (!stricmp(arg, "-info")) { print_info = 1; @@ -1655,14 +1683,14 @@ int mp4boxMain(int argc, char **argv) CHECK_NEXT_ARG grab_m2ts = argv[i+1]; i++; - } + } #endif #if !defined(GPAC_DISABLE_CORE_TOOLS) else if (!stricmp(arg, "-wget")) { CHECK_NEXT_ARG do_wget = argv[i+1]; i++; - } + } #endif /*******************************************************************************/ else if (!stricmp(arg, "-dvbhdemux")) { @@ -1692,7 +1720,10 @@ int mp4boxMain(int argc, char **argv) if (strlen(argv[i+1])==5) trackID = 2; else trackID = 1 + atoi(argv[i+1] + 5); } - else { fprintf(stderr, "Usage: \"-aviraw video\" or \"-aviraw audio\"\n"); MP4BOX_EXIT_WITH_CODE(1); } + else { + fprintf(stderr, "Usage: \"-aviraw video\" or \"-aviraw audio\"\n"); + MP4BOX_EXIT_WITH_CODE(1); + } track_dump_type = GF_EXPORT_AVI_NATIVE; i++; } @@ -1739,14 +1770,32 @@ int mp4boxMain(int argc, char **argv) dump_iod = 1; } #ifndef GPAC_DISABLE_VRML - else if (!stricmp(arg, "-node")) { CHECK_NEXT_ARG PrintNode(argv[i+1], 0); MP4BOX_EXIT_WITH_CODE(0); } - else if (!stricmp(arg, "-xnode")) { CHECK_NEXT_ARG PrintNode(argv[i+1], 1); MP4BOX_EXIT_WITH_CODE(0); } - else if (!stricmp(arg, "-nodes")) { PrintBuiltInNodes(0); MP4BOX_EXIT_WITH_CODE(0); } - else if (!stricmp(arg, "-xnodes")) { PrintBuiltInNodes(1); MP4BOX_EXIT_WITH_CODE(0); } + else if (!stricmp(arg, "-node")) { + CHECK_NEXT_ARG PrintNode(argv[i+1], 0); + MP4BOX_EXIT_WITH_CODE(0); + } + else if (!stricmp(arg, "-xnode")) { + CHECK_NEXT_ARG PrintNode(argv[i+1], 1); + MP4BOX_EXIT_WITH_CODE(0); + } + else if (!stricmp(arg, "-nodes")) { + PrintBuiltInNodes(0); + MP4BOX_EXIT_WITH_CODE(0); + } + else if (!stricmp(arg, "-xnodes")) { + PrintBuiltInNodes(1); + MP4BOX_EXIT_WITH_CODE(0); + } #endif #ifndef GPAC_DISABLE_SVG - else if (!stricmp(arg, "-snode")) { CHECK_NEXT_ARG PrintNode(argv[i+1], 2); MP4BOX_EXIT_WITH_CODE(0); } - else if (!stricmp(arg, "-snodes")) { PrintBuiltInNodes(2); MP4BOX_EXIT_WITH_CODE(0); } + else if (!stricmp(arg, "-snode")) { + CHECK_NEXT_ARG PrintNode(argv[i+1], 2); + MP4BOX_EXIT_WITH_CODE(0); + } + else if (!stricmp(arg, "-snodes")) { + PrintBuiltInNodes(2); + MP4BOX_EXIT_WITH_CODE(0); + } #endif else if (!stricmp(arg, "-std")) dump_std = 2; else if (!stricmp(arg, "-stdb")) dump_std = 1; @@ -1772,8 +1821,11 @@ int mp4boxMain(int argc, char **argv) #if 0 else if (!stricmp(arg, "-conf")) { - if (i+1==(u32)argc) { fprintf(stderr, "Missing arg - please check usage\n"); MP4BOX_EXIT_WITH_CODE(1); } - if (i+2==(u32)argc) { + if (i+1==(u32)argc) { + fprintf(stderr, "Missing arg - please check usage\n"); + MP4BOX_EXIT_WITH_CODE(1); + } + if (i+2==(u32)argc) { gf_check_isom_files(NULL, argv[i+1]); } else { gf_check_isom_files(argv[i+1], argv[i+2]); @@ -1794,7 +1846,7 @@ int mp4boxMain(int argc, char **argv) } } else if (!stricmp(arg, "-dnal")) { CHECK_NEXT_ARG - dump_nal = atoi(argv[i+1]); + dump_nal = atoi(argv[i+1]); i++; } else if (!stricmp(arg, "-dcr")) dump_cr = 1; @@ -1808,7 +1860,10 @@ int mp4boxMain(int argc, char **argv) trackID = 0; } #ifdef GPAC_DISABLE_ISOM_WRITE - if (trackID) { fprintf(stderr, "Error: Read-Only version - subtitle conversion not available\n"); MP4BOX_EXIT_WITH_CODE(1); } + if (trackID) { + fprintf(stderr, "Error: Read-Only version - subtitle conversion not available\n"); + MP4BOX_EXIT_WITH_CODE(1); + } #endif if (!stricmp(arg, "-ttxt")) dump_ttxt = 1; else dump_srt = 1; @@ -1840,25 +1895,58 @@ int mp4boxMain(int argc, char **argv) } #endif #ifndef GPAC_DISABLE_ISOM_WRITE - else if (!stricmp(arg, "-isma")) { conv_type = GF_ISOM_CONV_TYPE_ISMA; open_edit = 1; } - else if (!stricmp(arg, "-3gp")) { conv_type = GF_ISOM_CONV_TYPE_3GPP; open_edit = 1; } - else if (!stricmp(arg, "-ipod")) { conv_type = GF_ISOM_CONV_TYPE_IPOD; open_edit = 1; } - else if (!stricmp(arg, "-psp")) { conv_type = GF_ISOM_CONV_TYPE_PSP; open_edit = 1; } - else if (!stricmp(arg, "-ismax")) { conv_type = GF_ISOM_CONV_TYPE_ISMA_EX; open_edit = 1; } - - else if (!stricmp(arg, "-no-sys") || !stricmp(arg, "-nosys")) { remove_sys_tracks = 1; open_edit = 1; } - else if (!stricmp(arg, "-no-iod")) { remove_root_od = 1; open_edit = 1; } - else if (!stricmp(arg, "-out")) { CHECK_NEXT_ARG outName = argv[i+1]; i++; } + else if (!stricmp(arg, "-isma")) { + conv_type = GF_ISOM_CONV_TYPE_ISMA; + open_edit = 1; + } + else if (!stricmp(arg, "-3gp")) { + conv_type = GF_ISOM_CONV_TYPE_3GPP; + open_edit = 1; + } + else if (!stricmp(arg, "-ipod")) { + conv_type = GF_ISOM_CONV_TYPE_IPOD; + open_edit = 1; + } + else if (!stricmp(arg, "-psp")) { + conv_type = GF_ISOM_CONV_TYPE_PSP; + open_edit = 1; + } + else if (!stricmp(arg, "-ismax")) { + conv_type = GF_ISOM_CONV_TYPE_ISMA_EX; + open_edit = 1; + } + + else if (!stricmp(arg, "-no-sys") || !stricmp(arg, "-nosys")) { + remove_sys_tracks = 1; + open_edit = 1; + } + else if (!stricmp(arg, "-no-iod")) { + remove_root_od = 1; + open_edit = 1; + } + else if (!stricmp(arg, "-out")) { + CHECK_NEXT_ARG outName = argv[i+1]; + i++; + } else if (!stricmp(arg, "-tmp")) { - CHECK_NEXT_ARG tmpdir = argv[i+1]; i++; + CHECK_NEXT_ARG tmpdir = argv[i+1]; + i++; } else if (!stricmp(arg, "-write-buffer")) { - CHECK_NEXT_ARG + CHECK_NEXT_ARG gf_isom_set_output_buffering(NULL, atoi(argv[i+1])); - i++; + i++; + } + else if (!stricmp(arg, "-cprt")) { + CHECK_NEXT_ARG cprt = argv[i+1]; + i++; + if (!dash_duration) open_edit = 1; + } + else if (!stricmp(arg, "-chap")) { + CHECK_NEXT_ARG chap_file = argv[i+1]; + i++; + open_edit = 1; } - else if (!stricmp(arg, "-cprt")) { CHECK_NEXT_ARG cprt = argv[i+1]; i++; if (!dash_duration) open_edit = 1; } - else if (!stricmp(arg, "-chap")) { CHECK_NEXT_ARG chap_file = argv[i+1]; i++; open_edit = 1; } else if (!strcmp(arg, "-strict-error")) { gf_log_set_strict_error(1); } else if (!stricmp(arg, "-inter") || !stricmp(arg, "-old-inter")) { @@ -1919,7 +2007,9 @@ int mp4boxMain(int argc, char **argv) else bitstream_switching_mode = GF_DASH_BSMODE_INBAND; i++; } - else if (!stricmp(arg, "-dynamic")) { dash_dynamic = 1; } + else if (!stricmp(arg, "-dynamic")) { + dash_dynamic = 1; + } else if (!strnicmp(arg, "-dash-live", 10) || !strnicmp(arg, "-ddbg-live", 10)) { dash_dynamic = !strnicmp(arg, "-ddbg-live", 10) ? 2 : 1; dash_live = 1; @@ -1930,46 +2020,60 @@ int mp4boxMain(int argc, char **argv) dash_duration = atof(argv[i+1]) / 1000; i++; } - else if (!stricmp(arg, "-mpd-refresh")) { CHECK_NEXT_ARG mpd_update_time = atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-time-shift")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-mpd-refresh")) { + CHECK_NEXT_ARG mpd_update_time = atoi(argv[i+1]); + i++; + } + else if (!stricmp(arg, "-time-shift")) { + CHECK_NEXT_ARG time_shift_depth = (u32) atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-min-buffer")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-min-buffer")) { + CHECK_NEXT_ARG min_buffer = atoi(argv[i+1]); min_buffer /= 1000; i++; } - else if (!stricmp(arg, "-ast-offset")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-ast-offset")) { + CHECK_NEXT_ARG ast_shift_sec = (u32) atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-moof-sn")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-moof-sn")) { + CHECK_NEXT_ARG initial_moof_sn = (u32) atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-tfdt")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-tfdt")) { + CHECK_NEXT_ARG sscanf(argv[i+1], LLU, &initial_tfdt); i++; } - else if (!stricmp(arg, "-no-frags-default")) { no_fragments_defaults = 1; } - else if (!stricmp(arg, "-mpd-title")) { CHECK_NEXT_ARG dash_title = argv[i+1]; i++; } - else if (!stricmp(arg, "-mpd-source")) { CHECK_NEXT_ARG dash_source = argv[i+1]; i++; } - else if (!stricmp(arg, "-mpd-info-url")) { CHECK_NEXT_ARG dash_more_info = argv[i+1]; i++; } - else if (!stricmp(arg, "-base-url")) { - CHECK_NEXT_ARG - dash_more_info = argv[i+1]; + else if (!stricmp(arg, "-no-frags-default")) { + no_fragments_defaults = 1; + } + else if (!stricmp(arg, "-mpd-title")) { + CHECK_NEXT_ARG dash_title = argv[i+1]; + i++; + } + else if (!stricmp(arg, "-mpd-source")) { + CHECK_NEXT_ARG dash_source = argv[i+1]; + i++; + } + else if (!stricmp(arg, "-mpd-info-url")) { + CHECK_NEXT_ARG dash_more_info = argv[i+1]; + i++; + } + else if (!stricmp(arg, "-base-url")) { + CHECK_NEXT_ARG + dash_more_info = argv[i+1]; mpd_base_urls = gf_realloc(mpd_base_urls, (nb_mpd_base_urls+1)*sizeof(char**)); mpd_base_urls[nb_mpd_base_urls] = argv[i+1]; nb_mpd_base_urls++; - i++; + i++; } - + else if (!stricmp(arg, "-dash-ctx")) { CHECK_NEXT_ARG dash_ctx_file = argv[i+1]; @@ -2011,10 +2115,20 @@ int mp4boxMain(int argc, char **argv) CHECK_NEXT_ARG m = argv[i+1]; segment_marker = GF_4CC(m[0], m[1], m[2], m[3]); - } else if (!stricmp(arg, "-itags")) { CHECK_NEXT_ARG itunes_tags = argv[i+1]; i++; open_edit = 1; } + } else if (!stricmp(arg, "-itags")) { + CHECK_NEXT_ARG itunes_tags = argv[i+1]; + i++; + open_edit = 1; + } #ifndef GPAC_DISABLE_ISOM_HINTING - else if (!stricmp(arg, "-hint")) { open_edit = 1; HintIt = 1; } - else if (!stricmp(arg, "-unhint")) { open_edit = 1; remove_hint = 1; } + else if (!stricmp(arg, "-hint")) { + open_edit = 1; + HintIt = 1; + } + else if (!stricmp(arg, "-unhint")) { + open_edit = 1; + remove_hint = 1; + } else if (!stricmp(arg, "-copy")) HintCopy = 1; else if (!stricmp(arg, "-tight")) { FullInter = 1; @@ -2063,9 +2177,18 @@ int mp4boxMain(int argc, char **argv) #endif } #ifndef GPAC_DISABLE_ISOM_HINTING - else if (!stricmp(arg, "-mtu")) { CHECK_NEXT_ARG MTUSize = atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-cardur")) { CHECK_NEXT_ARG car_dur = atoi(argv[i+1]); i++; } - else if (!stricmp(arg, "-rate")) { CHECK_NEXT_ARG rtp_rate = atoi(argv[i+1]); i++; } + else if (!stricmp(arg, "-mtu")) { + CHECK_NEXT_ARG MTUSize = atoi(argv[i+1]); + i++; + } + else if (!stricmp(arg, "-cardur")) { + CHECK_NEXT_ARG car_dur = atoi(argv[i+1]); + i++; + } + else if (!stricmp(arg, "-rate")) { + CHECK_NEXT_ARG rtp_rate = atoi(argv[i+1]); + i++; + } #ifndef GPAC_DISABLE_SENG else if (!stricmp(arg, "-add-sdp") || !stricmp(arg, "-sdp_ex")) { char *id; @@ -2246,7 +2369,10 @@ int mp4boxMain(int argc, char **argv) MP4BOX_EXIT_WITH_CODE(1); } tracks[nb_track_act].act_type = 8; - ext[0] = 0; tracks[nb_track_act].trackID = atoi(szTK); ext[0] = ':'; szTK = ext+1; + ext[0] = 0; + tracks[nb_track_act].trackID = atoi(szTK); + ext[0] = ':'; + szTK = ext+1; ext = strchr(szTK, ':'); if (!ext) { fprintf(stderr, "Bad format for track reference - expecting ID:XXXX:refID got %s\n", argv[i+1]); @@ -2290,8 +2416,8 @@ int mp4boxMain(int argc, char **argv) else if (!stricmp(arg, "-ps")) import_flags |= GF_IMPORT_PS_IMPLICIT; else if (!stricmp(arg, "-psx")) import_flags |= GF_IMPORT_PS_EXPLICIT; else if (!stricmp(arg, "-ovsbr")) import_flags |= GF_IMPORT_OVSBR; - else if (!stricmp(arg, "-fps")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-fps")) { + CHECK_NEXT_ARG if (!strcmp(argv[i+1], "auto")) import_fps = GF_IMPORT_AUTO_FPS; else if (strchr(argv[i+1], '-')) { u32 ticks, dts_inc; @@ -2300,25 +2426,38 @@ int mp4boxMain(int argc, char **argv) import_fps = ticks; import_fps /= dts_inc; } else import_fps = atof(argv[i+1]); - i++; + i++; + } + else if (!stricmp(arg, "-agg")) { + CHECK_NEXT_ARG agg_samples = atoi(argv[i+1]); + i++; } - else if (!stricmp(arg, "-agg")) { CHECK_NEXT_ARG agg_samples = atoi(argv[i+1]); i++; } else if (!stricmp(arg, "-keep-all") || !stricmp(arg, "-keepall")) import_flags |= GF_IMPORT_KEEP_ALL_TRACKS; #endif /*!defined(GPAC_DISABLE_MEDIA_EXPORT) && !defined(GPAC_DISABLE_MEDIA_IMPORT*/ else if (!stricmp(arg, "-keep-sys") || !stricmp(arg, "-keepsys")) keep_sys_tracks = 1; - else if (!stricmp(arg, "-ms")) { CHECK_NEXT_ARG mediaSource = argv[i+1]; i++; } - else if (!stricmp(arg, "-mp4")) { encode = 1; open_edit = 1; } - else if (!stricmp(arg, "-saf")) { do_saf = 1; } - else if (!stricmp(arg, "-log")) { do_log = 1; } + else if (!stricmp(arg, "-ms")) { + CHECK_NEXT_ARG mediaSource = argv[i+1]; + i++; + } + else if (!stricmp(arg, "-mp4")) { + encode = 1; + open_edit = 1; + } + else if (!stricmp(arg, "-saf")) { + do_saf = 1; + } + else if (!stricmp(arg, "-log")) { + do_log = 1; + } #ifndef GPAC_DISABLE_MPD - else if (!stricmp(arg, "-mpd")) { - do_mpd = 1; - CHECK_NEXT_ARG - outName = argv[i+1]; - i++; + else if (!stricmp(arg, "-mpd")) { + do_mpd = 1; + CHECK_NEXT_ARG + outName = argv[i+1]; + i++; } #endif - + #ifndef GPAC_DISABLE_SCENE_ENCODER else if (!stricmp(arg, "-def")) opts.flags |= GF_SM_ENCODE_USE_NAMES; else if (!stricmp(arg, "-sync")) { @@ -2337,7 +2476,7 @@ int mp4boxMain(int argc, char **argv) opts.flags &= ~(GF_SM_ENCODE_RAP_INBAND | GF_SM_ENCODE_RAP_SHADOW); opts.rap_freq = atoi(argv[i+1]); i++; - } + } /*LASeR options*/ else if (!stricmp(arg, "-resolution")) { CHECK_NEXT_ARG @@ -2369,7 +2508,10 @@ int mp4boxMain(int argc, char **argv) i++; } /*chunk encoding*/ - else if (!stricmp(arg, "-ctx-out") || !stricmp(arg, "-outctx")) { CHECK_NEXT_ARG output_ctx = argv[i+1]; i++; } + else if (!stricmp(arg, "-ctx-out") || !stricmp(arg, "-outctx")) { + CHECK_NEXT_ARG output_ctx = argv[i+1]; + i++; + } else if (!stricmp(arg, "-ctx-in") || !stricmp(arg, "-inctx")) { CHECK_NEXT_ARG chunk_mode = 1; @@ -2417,96 +2559,96 @@ int mp4boxMain(int argc, char **argv) nb_track_act++; i++; } - else if (!stricmp(arg, "-split")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-split")) { + CHECK_NEXT_ARG split_duration = atof(argv[i+1]); if (split_duration<0) split_duration=0;; i++; split_size = 0; } - else if (!stricmp(arg, "-split-rap") || !stricmp(arg, "-splitr")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-split-rap") || !stricmp(arg, "-splitr")) { + CHECK_NEXT_ARG split_duration = -1; split_size = -1; } - else if (!stricmp(arg, "-split-size") || !stricmp(arg, "-splits")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-split-size") || !stricmp(arg, "-splits")) { + CHECK_NEXT_ARG split_size = (u32) atoi(argv[i+1]); - i++; + i++; split_duration = 0; } - else if (!stricmp(arg, "-split-chunk") || !stricmp(arg, "-splitx") || !stricmp(arg, "-splitz")) { - CHECK_NEXT_ARG + else if (!stricmp(arg, "-split-chunk") || !stricmp(arg, "-splitx") || !stricmp(arg, "-splitz")) { + CHECK_NEXT_ARG if (!strstr(argv[i+1], ":")) { fprintf(stderr, "Chunk extraction usage: \"-splitx start:end\" expressed in seconds\n"); MP4BOX_EXIT_WITH_CODE(1); } if (strstr(argv[i+1], "end")) { sscanf(argv[i+1], "%lf:end", &split_start); - split_duration = -2; + split_duration = -2; } else { sscanf(argv[i+1], "%lf:%lf", &split_start, &split_duration); - split_duration -= split_start; + split_duration -= split_start; } split_size = 0; if (!stricmp(arg, "-splitz")) adjust_split_end = 1; i++; } /*meta*/ - else if (!stricmp(arg, "-set-meta")) { + else if (!stricmp(arg, "-set-meta")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 0, argv[i+1]); nb_meta_act++; open_edit = 1; i++; } - else if (!stricmp(arg, "-add-item")) { + else if (!stricmp(arg, "-add-item")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 1, argv[i+1]); nb_meta_act++; open_edit = 1; i++; } - else if (!stricmp(arg, "-rem-item")) { + else if (!stricmp(arg, "-rem-item")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 2, argv[i+1]); nb_meta_act++; open_edit = 1; i++; } - else if (!stricmp(arg, "-set-primary")) { + else if (!stricmp(arg, "-set-primary")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 3, argv[i+1]); nb_meta_act++; open_edit = 1; i++; } - else if (!stricmp(arg, "-set-xml")) { + else if (!stricmp(arg, "-set-xml")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 4, argv[i+1]); nb_meta_act++; open_edit = 1; i++; } - else if (!stricmp(arg, "-rem-xml")) { + else if (!stricmp(arg, "-rem-xml")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); if (parse_meta_args(&metas[nb_meta_act], 6, argv[i+1])) i++; nb_meta_act++; open_edit = 1; } - else if (!stricmp(arg, "-dump-xml")) { + else if (!stricmp(arg, "-dump-xml")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 7, argv[i+1]); nb_meta_act++; i++; } - else if (!stricmp(arg, "-dump-item")) { + else if (!stricmp(arg, "-dump-item")) { metas = gf_realloc(metas, sizeof(MetaAction) * (nb_meta_act+1)); parse_meta_args(&metas[nb_meta_act], 8, argv[i+1]); nb_meta_act++; i++; } - else if (!stricmp(arg, "-group-add") || !stricmp(arg, "-group-rem-track") || !stricmp(arg, "-group-rem")) { + else if (!stricmp(arg, "-group-add") || !stricmp(arg, "-group-rem-track") || !stricmp(arg, "-group-rem")) { tsel_acts[nb_tsel_acts].act_type = !stricmp(arg, "-group-rem") ? 2 : ( !stricmp(arg, "-group-rem-track") ? 1 : 0 ); if (parse_tsel_args(&tsel_acts, argv[i+1], &nb_tsel_acts)==0) { fprintf(stderr, "Invalid group syntax - check usage\n"); @@ -2515,37 +2657,37 @@ int mp4boxMain(int argc, char **argv) open_edit=1; i++; } - else if (!stricmp(arg, "-group-clean")) { + else if (!stricmp(arg, "-group-clean")) { tsel_acts[nb_tsel_acts].act_type = 3; nb_tsel_acts++; open_edit=1; } - else if (!stricmp(arg, "-group-single")) { - single_group = 1; - } + else if (!stricmp(arg, "-group-single")) { + single_group = 1; + } else if (!stricmp(arg, "-package")) { - CHECK_NEXT_ARG + CHECK_NEXT_ARG pack_file = argv[i+1]; i++; } else if (!stricmp(arg, "-mgt")) { - CHECK_NEXT_ARG + CHECK_NEXT_ARG pack_file = argv[i+1]; pack_wgt = 1; i++; } - - else if (!stricmp(arg, "-brand")) { + + else if (!stricmp(arg, "-brand")) { char *b = argv[i+1]; - CHECK_NEXT_ARG + CHECK_NEXT_ARG major_brand = GF_4CC(b[0], b[1], b[2], b[3]); open_edit = 1; if (b[4]==':') minor_version = atoi(b+5); i++; } - else if (!stricmp(arg, "-ab")) { + else if (!stricmp(arg, "-ab")) { char *b = argv[i+1]; - CHECK_NEXT_ARG + CHECK_NEXT_ARG brand_add = gf_realloc(brand_add, sizeof(u32) * (nb_alt_brand_add+1)); brand_add[nb_alt_brand_add] = GF_4CC(b[0], b[1], b[2], b[3]); @@ -2553,9 +2695,9 @@ int mp4boxMain(int argc, char **argv) open_edit = 1; i++; } - else if (!stricmp(arg, "-rb")) { + else if (!stricmp(arg, "-rb")) { char *b = argv[i+1]; - CHECK_NEXT_ARG + CHECK_NEXT_ARG brand_rem = gf_realloc(brand_rem, sizeof(u32) * (nb_alt_brand_rem+1)); brand_rem[nb_alt_brand_rem] = GF_4CC(b[0], b[1], b[2], b[3]); @@ -2564,7 +2706,7 @@ int mp4boxMain(int argc, char **argv) i++; } #endif - else if (!stricmp(arg, "-languages")) { + else if (!stricmp(arg, "-languages")) { PrintLanguages(); MP4BOX_EXIT_WITH_CODE(0); } @@ -2618,7 +2760,7 @@ int mp4boxMain(int argc, char **argv) } } - if (!inName && dump_std) + if (!inName && dump_std) inName = "std"; if (!inName) { @@ -2633,20 +2775,20 @@ int mp4boxMain(int argc, char **argv) if (!interleaving_time) { /*by default use single fragment per dash segment*/ - if (dash_duration) + if (dash_duration) interleaving_time = dash_duration; else interleaving_time = 0.5; } - if (dump_std) + if (dump_std) outName = "std"; if (dump_std==2) { #ifdef WIN32 - if ( _setmode(_fileno(stdout), _O_BINARY) == -1 ) + if ( _setmode(_fileno(stdout), _O_BINARY) == -1 ) #else - if ( freopen(NULL, "wb", stdout) == NULL) + if ( freopen(NULL, "wb", stdout) == NULL) #endif { fprintf(stderr, "Fatal error: cannot reopen stdout in binary mode.\n"); @@ -2691,7 +2833,7 @@ int mp4boxMain(int argc, char **argv) fclose(fout); MP4BOX_EXIT_WITH_CODE(0); } -#if !defined(GPAC_DISABLE_STREAMING) +#if !defined(GPAC_DISABLE_STREAMING) if (grab_m2ts) { return grab_live_m2ts(grab_m2ts, inName); } @@ -2731,7 +2873,7 @@ int mp4boxMain(int argc, char **argv) MP4BOX_EXIT_WITH_CODE(1); } #endif - + #ifndef GPAC_DISABLE_MPD if (do_mpd) { Bool remote = 0; @@ -2748,12 +2890,12 @@ int mp4boxMain(int argc, char **argv) remote = 1; #else fprintf(stderr, "HTTP Downloader disabled in this build\n"); - MP4BOX_EXIT_WITH_CODE(1); + MP4BOX_EXIT_WITH_CODE(1); #endif } - e = gf_m3u8_to_mpd(inName, mpd_base_url, (outName ? outName : inName), 0, "video/mp2t", 1, use_url_template, NULL); + e = gf_m3u8_to_mpd(inName, mpd_base_url, (outName ? outName : inName), 0, "video/mp2t", 1, use_url_template, NULL); gf_free(mpd_base_url); - + if (remote) { //gf_delete_file("tmp_main.m3u8"); } @@ -2773,7 +2915,9 @@ int mp4boxMain(int argc, char **argv) if (do_saf && !encode) { switch (get_file_type_by_ext(inName)) { - case 2: case 3: case 4: + case 2: + case 3: + case 4: encode = 1; break; } @@ -2965,7 +3109,7 @@ int mp4boxMain(int argc, char **argv) open_edit = 0; } #endif - } + } #ifndef GPAC_DISABLE_ISOM_WRITE else if (pack_file) { @@ -2980,7 +3124,7 @@ int mp4boxMain(int argc, char **argv) if (!outName) outName = inName; needSave = 1; open_edit = 1; - } + } #endif if (dash_duration) { @@ -3002,7 +3146,7 @@ int mp4boxMain(int argc, char **argv) if (!dash_ctx_file && dash_live) { dash_ctx = gf_cfg_new(NULL, NULL); } else if (dash_ctx_file) { - if (force_new) + if (force_new) gf_delete_file(dash_ctx_file); dash_ctx = gf_cfg_force_new(NULL, dash_ctx_file); @@ -3028,12 +3172,12 @@ int mp4boxMain(int argc, char **argv) while (!do_abort) { e = gf_dasher_segment_files(szMPD, dash_inputs, nb_dash_inputs, dash_profile, dash_title, dash_source, cprt, dash_more_info, - (const char **) mpd_base_urls, nb_mpd_base_urls, - use_url_template, segment_timeline, single_segment, single_file, bitstream_switching_mode, - seg_at_rap, dash_duration, seg_name, seg_ext, segment_marker, - interleaving_time, subsegs_per_sidx, daisy_chain_sidx, frag_at_rap, tmpdir, - dash_ctx, dash_dynamic, mpd_update_time, time_shift_depth, dash_subduration, min_buffer, - ast_shift_sec, dash_scale, memory_frags, initial_moof_sn, initial_tfdt, no_fragments_defaults, pssh_in_moof, samplegroups_in_traf); + (const char **) mpd_base_urls, nb_mpd_base_urls, + use_url_template, segment_timeline, single_segment, single_file, bitstream_switching_mode, + seg_at_rap, dash_duration, seg_name, seg_ext, segment_marker, + interleaving_time, subsegs_per_sidx, daisy_chain_sidx, frag_at_rap, tmpdir, + dash_ctx, dash_dynamic, mpd_update_time, time_shift_depth, dash_subduration, min_buffer, + ast_shift_sec, dash_scale, memory_frags, initial_moof_sn, initial_tfdt, no_fragments_defaults, pssh_in_moof, samplegroups_in_traf); if (e) break; if (dash_live) { @@ -3041,15 +3185,21 @@ int mp4boxMain(int argc, char **argv) fprintf(stderr, "sleep for %d ms\n", sleep_for); while (1) { if (gf_prompt_has_input()) { - char c = (char) gf_prompt_get_char(); - if (c=='q') { do_abort = 1; break; } - if (c=='s') { do_abort = 2; break; } + char c = (char) gf_prompt_get_char(); + if (c=='q') { + do_abort = 1; + break; + } + if (c=='s') { + do_abort = 2; + break; + } } if (dash_dynamic == 2) { break; } - if (sleep_for<100) + if (sleep_for<100) break; gf_sleep(100); @@ -3059,7 +3209,7 @@ int mp4boxMain(int argc, char **argv) break; } } - + if (dash_ctx) { if (do_abort==2) { char szName[1024]; @@ -3073,17 +3223,17 @@ int mp4boxMain(int argc, char **argv) } if (e) fprintf(stderr, "Error DASHing file: %s\n", gf_error_to_string(e)); if (file) gf_isom_delete(file); - if (del_file) + if (del_file) gf_delete_file(inName); - + MP4BOX_EXIT_WITH_CODE( (e!=GF_OK) ? 1 : 0 ); } else if (!file #ifndef GPAC_DISABLE_MEDIA_EXPORT - && !(track_dump_type & GF_EXPORT_AVI_NATIVE) + && !(track_dump_type & GF_EXPORT_AVI_NATIVE) #endif - ) { + ) { FILE *st = gf_f64_open(inName, "rb"); Bool file_exists = 0; if (st) { @@ -3129,10 +3279,10 @@ int mp4boxMain(int argc, char **argv) default: if (!open_edit && file_exists && !gf_isom_probe_file(inName) && track_dump_type) { - } + } #ifndef GPAC_DISABLE_ISOM_WRITE else if (!open_edit && file_exists /* && !gf_isom_probe_file(inName) */ && !dump_mode) { - /*************************************************************************************************/ + /*************************************************************************************************/ #ifndef GPAC_DISABLE_MEDIA_IMPORT if(dvbhdemux) { @@ -3190,13 +3340,13 @@ int mp4boxMain(int argc, char **argv) char *szExt = strrchr(outfile, '.'); /*turn on 3GP saving*/ - if (!stricmp(szExt, ".3gp") || !stricmp(szExt, ".3gpp") || !stricmp(szExt, ".3g2")) + if (!stricmp(szExt, ".3gp") || !stricmp(szExt, ".3gpp") || !stricmp(szExt, ".3g2")) conv_type = GF_ISOM_CONV_TYPE_3GPP; else if (!stricmp(szExt, ".m4a") || !stricmp(szExt, ".m4v")) conv_type = GF_ISOM_CONV_TYPE_IPOD; else if (!stricmp(szExt, ".psp")) conv_type = GF_ISOM_CONV_TYPE_PSP; - + while (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0; outfile[strlen(outfile)-1] = 0; } @@ -3249,7 +3399,7 @@ int mp4boxMain(int argc, char **argv) if (e) goto err_exit; } MP4BOX_EXIT_WITH_CODE(0); - } + } #endif /*GPAC_DISABLE_MEDIA_EXPORT*/ @@ -3286,7 +3436,7 @@ int mp4boxMain(int argc, char **argv) if (dump_timestamps) dump_file_timestamps(file, dump_std ? NULL : outfile); if (dump_nal) dump_file_nal(file, dump_nal, dump_std ? NULL : outfile); - + if (do_hash) { u8 hash[20]; e = gf_media_get_file_hash(inName, hash); @@ -3323,7 +3473,7 @@ int mp4boxMain(int argc, char **argv) } fclose(iodf); } - gf_free(bs); + gf_free(bs); } } @@ -3399,12 +3549,12 @@ int mp4boxMain(int argc, char **argv) break; case 1: self_ref = !stricmp(meta->szPath, "NULL") || !stricmp(meta->szPath, "this") || !stricmp(meta->szPath, "self"); - e = gf_isom_add_meta_item(file, meta->root_meta, tk, self_ref, self_ref ? NULL : meta->szPath, - strlen(meta->szName) ? meta->szName : NULL, - meta->item_id, - strlen(meta->mime_type) ? meta->mime_type : NULL, - strlen(meta->enc_type) ? meta->enc_type : NULL, - meta->use_dref ? meta->szPath : NULL, NULL); + e = gf_isom_add_meta_item(file, meta->root_meta, tk, self_ref, self_ref ? NULL : meta->szPath, + strlen(meta->szName) ? meta->szName : NULL, + meta->item_id, + strlen(meta->mime_type) ? meta->mime_type : NULL, + strlen(meta->enc_type) ? meta->enc_type : NULL, + meta->use_dref ? meta->szPath : NULL, NULL); needSave = 1; break; case 2: @@ -3455,12 +3605,12 @@ int mp4boxMain(int argc, char **argv) for (i=0; i>8; _t[5]=t; _t[4]=t>>8; } - else if (sscanf(val, "%u", &n) == 1) { _t[3]=n; _t[2]=n>>8;} + if (sscanf(val, "%u/%u", &n, &t) == 2) { + _t[3]=n; + _t[2]=n>>8; + _t[5]=t; + _t[4]=t>>8; + } + else if (sscanf(val, "%u", &n) == 1) { + _t[3]=n; + _t[2]=n>>8; + } else tlen = 0; if (tlen) gf_isom_apple_set_tag(file, itag, _t, tlen); } - break; + break; case GF_ISOM_ITUNE_GAPLESS: case GF_ISOM_ITUNE_COMPILATION: { @@ -3824,7 +3983,7 @@ int mp4boxMain(int argc, char **argv) else _t[0] = 0; gf_isom_apple_set_tag(file, itag, _t, 1); } - break; + break; default: gf_isom_apple_set_tag(file, itag, val, tlen); break; @@ -3868,7 +4027,7 @@ int mp4boxMain(int argc, char **argv) if (HintIt) { if (force_ocr) SetupClockReferences(file); fprintf(stderr, "Hinting file with Path-MTU %d Bytes\n", MTUSize); - MTUSize -= 12; + MTUSize -= 12; e = HintFile(file, MTUSize, max_ptime, rtp_rate, hint_flags, HintCopy, HintInter, regular_iod, single_group); if (e) goto err_exit; needSave = 1; @@ -3986,7 +4145,7 @@ int mp4boxMain(int argc, char **argv) #endif err_exit: /*close libgpac*/ - if (file) gf_isom_delete(file); + if (file) gf_isom_delete(file); fprintf(stderr, "\n\tError: %s\n", gf_error_to_string(e)); MP4BOX_EXIT_WITH_CODE(1); } diff --git a/applications/mp4box/wrapper.c b/applications/mp4box/wrapper.c index 8a8bc58..f26fe93 100644 --- a/applications/mp4box/wrapper.c +++ b/applications/mp4box/wrapper.c @@ -24,41 +24,41 @@ extern "C" { }\ jlong h = env->GetLongField(obj, fid); //CNativeWrapper* wr = (CNativeWrapper*) h;*/ - + char ** ConvertCommandLine( const char* sCommand, int* iNbArg ); - + JNIEXPORT void JNICALL Java_com_enst_mp4box_mp4terminal_run(JNIEnv * env, jobject obj, jstring sCommand) { //CAST_HANDLE(wr); - jniLOGV("mp4terminal::start"); - /*if (!wr) - { + jniLOGV("mp4terminal::start"); + /*if (!wr) + { jniLOGV("mp4terminal::end : aborted"); - return; - }*/ - jboolean isCopy; - const char * sOriginalCommand = (*env)->GetStringUTFChars(env, sCommand, &isCopy); - - jniLOGV("mp4terminal::command get back ok"); - jniLOGV(sOriginalCommand); + return; + }*/ + jboolean isCopy; + const char * sOriginalCommand = (*env)->GetStringUTFChars(env, sCommand, &isCopy); + + jniLOGV("mp4terminal::command get back ok"); + jniLOGV(sOriginalCommand); int iNbArg = 0; - + int i = 0; char** sConvertedCommandLine; sConvertedCommandLine = ConvertCommandLine( sOriginalCommand, &i ); - - jniLOGV("Convert command line done"); + + jniLOGV("Convert command line done"); FILE* ferr = freopen( "/mnt/sdcard/stderrout.txt", "w", stderr ); FILE* fout = freopen( "/mnt/sdcard/stdout.txt", "w", stdout ); - mp4boxMain(i, sConvertedCommandLine); + mp4boxMain(i, sConvertedCommandLine); - (*env)->ReleaseStringUTFChars(env, sCommand, sOriginalCommand); - jniLOGV("mp4terminal::end"); - fclose(ferr); - fclose(fout); + (*env)->ReleaseStringUTFChars(env, sCommand, sOriginalCommand); + jniLOGV("mp4terminal::end"); + fclose(ferr); + fclose(fout); } char ** ConvertCommandLine( const char* sCommand, int* iNbArg ) @@ -83,7 +83,7 @@ char ** ConvertCommandLine( const char* sCommand, int* iNbArg ) pReturn[0] = (char*)malloc(sizeof( char) * ( 7 )); strcpy( pReturn[0], "MP4Box" );//just a place holder , will never be read. pReturn[0][6] = '\0'; - + for ( l = 0; l <= iLength ; l++ ) { if( sCommand[l] == ' ' || l == ( iLength ) ) diff --git a/applications/mp4client/extract.c b/applications/mp4client/extract.c index 9556a9d..d82b2fb 100644 --- a/applications/mp4client/extract.c +++ b/applications/mp4client/extract.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,16 +31,16 @@ #ifdef WIN32 #include #else -typedef struct tagBITMAPFILEHEADER +typedef struct tagBITMAPFILEHEADER { - u16 bfType; - u32 bfSize; - u16 bfReserved1; - u16 bfReserved2; - u32 bfOffBits; + u16 bfType; + u32 bfSize; + u16 bfReserved1; + u16 bfReserved2; + u32 bfOffBits; } BITMAPFILEHEADER; -typedef struct tagBITMAPINFOHEADER{ +typedef struct tagBITMAPINFOHEADER { u32 biSize; s32 biWidth; s32 biHeight; @@ -70,8 +70,8 @@ extern GF_Err last_error; static GFINLINE u8 colmask(s32 a, s32 n) { - s32 mask = (1 << n) - 1; - return (u8) (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); + s32 mask = (1 << n) - 1; + return (u8) (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); } static u32 put_pixel(FILE *fout, u32 type, u32 pf, char *ptr) @@ -87,7 +87,7 @@ static u32 put_pixel(FILE *fout, u32 type, u32 pf, char *ptr) case GF_PIXEL_BGR_32: case GF_PIXEL_RGBA: - //probably due to tinygl bug - verify + //probably due to tinygl bug - verify #ifndef GPAC_USE_TINYGL fputc(ptr[3], fout); fputc(ptr[2], fout); @@ -123,12 +123,12 @@ static u32 put_pixel(FILE *fout, u32 type, u32 pf, char *ptr) fputc(colmask(col >> (5 - 3), 3), fout); fputc(colmask(col >> (10 - 3), 3), fout); return 2; - /* this is used to write the byte depthbuffer in greyscale when dumping depth*/ + /* this is used to write the byte depthbuffer in greyscale when dumping depth*/ case GF_PIXEL_GREYSCALE: /* bmp always needs 3 pixels */ fputc(ptr[0], fout); fputc(ptr[0], fout); - fputc(ptr[0], fout); + fputc(ptr[0], fout); /* if printing the characters corresponding to the float depth buffer: */ /* { @@ -180,17 +180,17 @@ void write_bmp(GF_VideoSurface *fb, char *rad_name, u32 img_num) fi.biSizeImage = fb->pitch_y * fb->height; /*NOT ALIGNED!!*/ - gf_fwrite(&fh.bfType, 2, 1, fout); - gf_fwrite(&fh.bfSize, 4, 1, fout); - gf_fwrite(&fh.bfReserved1, 2, 1, fout); - gf_fwrite(&fh.bfReserved2, 2, 1, fout); - gf_fwrite(&fh.bfOffBits, 4, 1, fout); + gf_fwrite(&fh.bfType, 2, 1, fout); + gf_fwrite(&fh.bfSize, 4, 1, fout); + gf_fwrite(&fh.bfReserved1, 2, 1, fout); + gf_fwrite(&fh.bfReserved2, 2, 1, fout); + gf_fwrite(&fh.bfOffBits, 4, 1, fout); gf_fwrite(&fi, 1, 40, fout); //#ifndef GPAC_USE_TINYGL for (j=fb->height; j>0; j--) { ptr = fb->video_buffer + (j-1)*fb->pitch_y; - for (i=0;iwidth; i++) { + for (i=0; iwidth; i++) { u32 res = put_pixel(fout, 0, fb->pixel_format, ptr); assert(res); ptr += res; @@ -200,7 +200,7 @@ void write_bmp(GF_VideoSurface *fb, char *rad_name, u32 img_num) #if 0 for (j=0; jheight; j++) { ptr = fb->video_buffer + j*fb->pitch; - for (i=0;iwidth; i++) { + for (i=0; iwidth; i++) { u32 res = put_pixel(fout, 0, fb->pixel_format, ptr); assert(res); ptr += res; @@ -221,9 +221,9 @@ void write_png(GF_VideoSurface *fb, char *rad_name, u32 img_num) u32 dst_size; char *dst; char *prev = strrchr(rad_name, '.'); - if (prev) prev[0] = '\0'; + if (prev) prev[0] = '\0'; sprintf(str, "%s_%d.png", rad_name, img_num); - if (prev) prev[0] = '.'; + if (prev) prev[0] = '.'; switch (fb->pixel_format) { case GF_PIXEL_ARGB: @@ -257,15 +257,15 @@ void write_png(GF_VideoSurface *fb, char *rad_name, u32 img_num) void write_depthfile(GF_VideoSurface *fb, char *rad_name, u32 img_num) { FILE *fout; - u32 i, j; + u32 i, j; unsigned char *depth; depth = (unsigned char *) fb->video_buffer; - + fout = gf_f64_open("dump_depth", "wb"); if (!fout) return; for (j=0; jheight; j++) { - for (i=0;iwidth; i++) { + for (i=0; iwidth; i++) { #ifdef GPAC_USE_TINYGL fputc(depth[2*i+j*fb->width*sizeof(unsigned short)], fout); @@ -282,18 +282,18 @@ void write_texture_file(GF_VideoSurface *fb, char *rad_name, u32 img_num, u32 du { FILE *fout; - u32 i, j; + u32 i, j; unsigned char *buf; buf = (unsigned char *) fb->video_buffer; - + if (dump_mode==6) fout = gf_f64_open("dump_rgbds", "wb"); else if (dump_mode==9) fout = gf_f64_open("dump_rgbd", "wb"); else return; - + if (!fout) return; for (j=0; jheight; j++) { - for (i=0;iwidth*4; i++) { + for (i=0; iwidth*4; i++) { fputc(buf[i+j*fb->pitch_y], fout); } } @@ -308,7 +308,7 @@ void write_raw(GF_VideoSurface *fb, char *rad_name, u32 img_num) char str[GF_MAX_PATH]; FILE *fout; prev = strrchr(rad_name, '.'); - if (prev) prev[0] = '\0'; + if (prev) prev[0] = '\0'; if (img_num<10) { sprintf(str, "%s_00%d.raw", rad_name, img_num); } else if (img_num<100) { @@ -320,10 +320,10 @@ void write_raw(GF_VideoSurface *fb, char *rad_name, u32 img_num) fout = gf_f64_open(str, "wb"); if (!fout) return; - - for (j=0;jheight; j++) { + + for (j=0; jheight; j++) { ptr = fb->video_buffer + j*fb->pitch_y; - for (i=0;iwidth; i++) { + for (i=0; iwidth; i++) { u32 res = put_pixel(fout, 0, fb->pixel_format, ptr); assert(res); ptr += res; @@ -354,8 +354,8 @@ void dump_depth (GF_Terminal *term, char *rad_name, u32 dump_type, u32 frameNum, u16 src_16; dst = conv_buf + k*fb.width*3; src = fb.video_buffer + (fb.height-k-1) * fb.pitch_y; - - for (i=0;i> 8/*(11 - 3)*/, 3); dst[1] = colmask(src_16 >> 3/*(5 - 2)*/, 2); @@ -532,7 +540,7 @@ void dump_frame(GF_Terminal *term, char *rad_name, u32 dump_type, u32 frameNum, } break; case GF_PIXEL_RGB_555: - for (i=0;i> 7/*(10 - 3)*/, 3); dst[1] = colmask(src_16 >> 2/*(5 - 3)*/, 3); @@ -543,18 +551,18 @@ void dump_frame(GF_Terminal *term, char *rad_name, u32 dump_type, u32 frameNum, break; } } - if (dump_type!=5 && dump_type!= 10 && dump_type!= 11) { + if (dump_type!=5 && dump_type!= 10 && dump_type!= 11) { out_size = fb.height*fb.width*3; } else { out_size = fb.height*fb.width*4; } #ifndef GPAC_DISABLE_AVILIB - if (dump_type!=5 && dump_type!= 10) { + if (dump_type!=5 && dump_type!= 10) { if (AVI_write_frame(avi_out, conv_buf, out_size, 1) <0) - fprintf(stderr, "Error writing frame\n"); + fprintf(stderr, "Error writing frame\n"); } else { if (AVI_write_frame(avi_out, conv_buf, out_size, 1) <0) - fprintf(stderr, "Error writing frame\n"); + fprintf(stderr, "Error writing frame\n"); } #endif break; @@ -568,7 +576,7 @@ void dump_frame(GF_Terminal *term, char *rad_name, u32 dump_type, u32 frameNum, case 9: write_texture_file(&fb, rad_name, frameNum, dump_type); break; - + case 3: write_raw(&fb, rad_name, frameNum); break; @@ -577,13 +585,14 @@ void dump_frame(GF_Terminal *term, char *rad_name, u32 dump_type, u32 frameNum, gf_sc_release_screen_buffer(term->compositor, &fb); } -Bool dump_file(char *url, u32 dump_mode, Double fps, u32 width, u32 height, Float scale, u32 *times, u32 nb_times) +Bool dump_file(char *url, char *out_url, u32 dump_mode, Double fps, u32 width, u32 height, Float scale, u32 *times, u32 nb_times) { GF_Err e; u32 i = 0; GF_VideoSurface fb; char szPath[GF_MAX_PATH]; - char *prev=NULL; + char szOutPath[GF_MAX_PATH]; + char *prev=NULL; prev = strstr(url, "://"); if (prev) { @@ -591,33 +600,42 @@ Bool dump_file(char *url, u32 dump_mode, Double fps, u32 width, u32 height, Floa if (prev) prev++; } - if (!prev) prev = url; + if (!prev) prev = url; strcpy(szPath, prev); prev = strrchr(szPath, '.'); if (prev) prev[0] = 0; + if (out_url) { + strcpy(szOutPath, out_url); + } else { + strcpy(szOutPath, szPath); + } + prev = strrchr(szOutPath, '.'); + if (prev) prev[0] = 0; + + fprintf(stderr, "Opening URL %s\n", url); /*connect in pause mode*/ gf_term_connect_from_time(term, url, 0, 1); - while (!term->compositor->scene - || term->compositor->msg_type - || (gf_term_get_option(term, GF_OPT_PLAY_STATE) == GF_STATE_STEP_PAUSE) - ) { + while (!term->compositor->scene + || term->compositor->msg_type + || (gf_term_get_option(term, GF_OPT_PLAY_STATE) == GF_STATE_STEP_PAUSE) + ) { if (last_error) return 1; gf_term_process_flush(term); gf_sleep(10); } - + if (width && height) { gf_term_set_size(term, width, height); gf_term_process_flush(term); - } + } #ifndef GPAC_USE_TINYGL - fprintf(stderr, "not tinygl\n"); + fprintf(stderr, "not tinygl\n"); e = gf_sc_get_screen_buffer(term->compositor, &fb, 0); #else - fprintf(stderr, "tinygl\n"); + fprintf(stderr, "tinygl\n"); e = gf_sc_get_screen_buffer(term->compositor, &fb, 1); #endif if (e != GF_OK) { @@ -657,26 +675,26 @@ Bool dump_file(char *url, u32 dump_mode, Double fps, u32 width, u32 height, Floa u32 time, prev_time, nb_frames; u64 dump_dur; char *conv_buf; - avi_t *avi_out = NULL; - avi_t *depth_avi_out = NULL; + avi_t *avi_out = NULL; + avi_t *depth_avi_out = NULL; char szPath_depth[GF_MAX_PATH]; char comp[5]; - strcpy(szPath_depth, szPath); - strcat(szPath, ".avi"); - avi_out = AVI_open_output_file(szPath); + strcpy(szPath_depth, szOutPath); + strcat(szOutPath, ".avi"); + avi_out = AVI_open_output_file(szOutPath); if (!avi_out) { - fprintf(stderr, "Error creating AVI file %s\n", szPath); + fprintf(stderr, "Error creating AVI file %s\n", szOutPath); return 1; } if (dump_mode==8) { strcat(szPath_depth, "_depth.avi"); depth_avi_out = AVI_open_output_file(szPath_depth); if (!depth_avi_out) { - fprintf(stderr, "Error creating AVI file %s\n", szPath); + fprintf(stderr, "Error creating AVI file %s\n", szPath_depth); return 1; - } + } } - + if (!fps) fps = GF_IMPORT_DEFAULT_FPS; time = prev_time = 0; nb_frames = 0; @@ -710,12 +728,12 @@ Bool dump_file(char *url, u32 dump_mode, Double fps, u32 width, u32 height, Floa /*we'll dump both buffers at once*/ gf_mx_p(term->compositor->mx); dump_depth(term, szPath_depth, dump_mode, i+1, conv_buf, depth_avi_out); - dump_frame(term, szPath, dump_mode, i+1, conv_buf, avi_out); + dump_frame(term, szOutPath, dump_mode, i+1, conv_buf, avi_out); gf_mx_v(term->compositor->mx); } - else dump_frame(term, szPath, dump_mode, i+1, conv_buf, avi_out); - + else dump_frame(term, szOutPath, dump_mode, i+1, conv_buf, avi_out); + nb_frames++; time = (u32) (nb_frames*1000/fps); gf_term_step_clocks(term, time - prev_time); @@ -739,12 +757,12 @@ Bool dump_file(char *url, u32 dump_mode, Double fps, u32 width, u32 height, Floa gf_term_process_flush(term); } - if (dump_mode==4 || dump_mode==7) { - dump_depth(term, szPath, dump_mode, i+1, NULL, NULL); + if (dump_mode==4 || dump_mode==7 || dump_mode==12) { + dump_depth(term, szOutPath, dump_mode, i+1, NULL, NULL); } else { - dump_frame(term, url, dump_mode, i+1, NULL, NULL); + dump_frame(term, out_url, dump_mode, i+1, NULL, NULL); } - + if (i+1 -//FIXME we need a plugin for playlists +//FIXME we need a plugin for playlists #include @@ -78,6 +78,7 @@ static u32 bench_mode = 0; static u32 bench_mode_start = 0; static u32 bench_buffer = 0; static Bool eos_seen = GF_FALSE; +static Bool addon_visible = GF_TRUE; Bool is_connected = GF_FALSE; Bool startup_file = GF_FALSE; GF_User user; @@ -85,8 +86,9 @@ GF_Terminal *term; u64 Duration; GF_Err last_error = GF_OK; static Bool enable_add_ons = GF_TRUE; +static Fixed playback_speed = 1.0; -static Bool request_next_playlist_item = GF_FALSE; +static s32 request_next_playlist_item = GF_FALSE; FILE *playlist = NULL; static Bool readonly_playlist = GF_FALSE; @@ -112,7 +114,7 @@ u32 last_x, last_y; Bool right_down = GF_FALSE; void dump_frame(GF_Terminal *term, char *rad_path, u32 dump_type, u32 frameNum); -Bool dump_file(char *the_url, u32 dump_mode, Double fps, u32 width, u32 height, Float scale, u32 *times, u32 nb_times); +Bool dump_file(char *the_url, char *out_url, u32 dump_mode, Double fps, u32 width, u32 height, Float scale, u32 *times, u32 nb_times); void hide_shell(u32 cmd_type) @@ -133,178 +135,181 @@ void hide_shell(u32 cmd_type) void PrintUsage() { fprintf(stderr, "Usage MP4Client [options] [filename]\n" - "\t-c fileName: user-defined configuration file. Also works with -cfg\n" + "\t-c fileName: user-defined configuration file. Also works with -cfg\n" #ifdef GPAC_MEMORY_TRACKING - "\t-mem-track: enables memory tracker\n" + "\t-mem-track: enables memory tracker\n" #endif - "\t-rti fileName: logs run-time info (FPS, CPU, Mem usage) to file\n" - "\t-rtix fileName: same as -rti but driven by GPAC logs\n" - "\t-quiet: removes script message, buffering and downloading status\n" - "\t-strict-error: exit when the player reports its first error\n" - "\t-opt option: Overrides an option in the configuration file. String format is section:key=value\n" - "\t-log-file file: sets output log file. Also works with -lf\n" - "\t-logs log_args: sets log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" - "\t levelX can be one of:\n" - "\t \"quiet\" : skip logs\n" - "\t \"error\" : logs only error messages\n" - "\t \"warning\" : logs error+warning messages\n" - "\t \"info\" : logs error+warning+info messages\n" - "\t \"debug\" : logs all messages\n" - "\t toolX can be one of:\n" - "\t \"core\" : libgpac core\n" - "\t \"coding\" : bitstream formats (audio, video, scene)\n" - "\t \"container\" : container formats (ISO File, MPEG-2 TS, AVI, ...)\n" - "\t \"network\" : network data exept RTP trafic\n" - "\t \"rtp\" : rtp trafic\n" - "\t \"author\" : authoring tools (hint, import, export)\n" - "\t \"sync\" : terminal sync layer\n" - "\t \"codec\" : terminal codec messages\n" - "\t \"parser\" : scene parsers (svg, xmt, bt) and other\n" - "\t \"media\" : terminal media object management\n" - "\t \"scene\" : scene graph and scene manager\n" - "\t \"script\" : scripting engine messages\n" - "\t \"interact\" : interaction engine (events, scripts, etc)\n" - "\t \"smil\" : SMIL timing engine\n" - "\t \"compose\" : composition engine (2D, 3D, etc)\n" - "\t \"mmio\" : Audio/Video HW I/O management\n" - "\t \"rti\" : various run-time stats\n" - "\t \"cache\" : HTTP cache subsystem\n" - "\t \"audio\" : Audio renderer and mixers\n" + "\t-rti fileName: logs run-time info (FPS, CPU, Mem usage) to file\n" + "\t-rtix fileName: same as -rti but driven by GPAC logs\n" + "\t-quiet: removes script message, buffering and downloading status\n" + "\t-strict-error: exit when the player reports its first error\n" + "\t-opt option: Overrides an option in the configuration file. String format is section:key=value\n" + "\t-log-file file: sets output log file. Also works with -lf\n" + "\t-logs log_args: sets log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX\n" + "\t levelX can be one of:\n" + "\t \"quiet\" : skip logs\n" + "\t \"error\" : logs only error messages\n" + "\t \"warning\" : logs error+warning messages\n" + "\t \"info\" : logs error+warning+info messages\n" + "\t \"debug\" : logs all messages\n" + "\t toolX can be one of:\n" + "\t \"core\" : libgpac core\n" + "\t \"coding\" : bitstream formats (audio, video, scene)\n" + "\t \"container\" : container formats (ISO File, MPEG-2 TS, AVI, ...)\n" + "\t \"network\" : network data exept RTP trafic\n" + "\t \"rtp\" : rtp trafic\n" + "\t \"author\" : authoring tools (hint, import, export)\n" + "\t \"sync\" : terminal sync layer\n" + "\t \"codec\" : terminal codec messages\n" + "\t \"parser\" : scene parsers (svg, xmt, bt) and other\n" + "\t \"media\" : terminal media object management\n" + "\t \"scene\" : scene graph and scene manager\n" + "\t \"script\" : scripting engine messages\n" + "\t \"interact\" : interaction engine (events, scripts, etc)\n" + "\t \"smil\" : SMIL timing engine\n" + "\t \"compose\" : composition engine (2D, 3D, etc)\n" + "\t \"mmio\" : Audio/Video HW I/O management\n" + "\t \"rti\" : various run-time stats\n" + "\t \"cache\" : HTTP cache subsystem\n" + "\t \"audio\" : Audio renderer and mixers\n" #ifdef GPAC_MEMORY_TRACKING - "\t \"mem\" : GPAC memory tracker\n" + "\t \"mem\" : GPAC memory tracker\n" #endif #ifndef GPAC_DISABLE_DASH_CLIENT - "\t \"dash\" : HTTP streaming logs\n" + "\t \"dash\" : HTTP streaming logs\n" #endif - "\t \"module\" : GPAC modules debugging\n" - "\t \"mutex\" : mutex\n" - "\t \"all\" : all tools logged - other tools can be specified afterwards.\n" - "\n" - "\t-log-clock or -lc : logs time in ms since start time of GPAC before each log line.\n" - "\t-log-utc or -lu : logs UTC time in ms before each log line.\n" - "\t-ifce IPIFCE : Sets default Multicast interface\n" - "\t-size WxH: specifies visual size (default: scene size)\n" + "\t \"module\" : GPAC modules debugging\n" + "\t \"mutex\" : mutex\n" + "\t \"all\" : all tools logged - other tools can be specified afterwards.\n" + "\n" + "\t-log-clock or -lc : logs time in ms since start time of GPAC before each log line.\n" + "\t-log-utc or -lu : logs UTC time in ms before each log line.\n" + "\t-ifce IPIFCE : Sets default Multicast interface\n" + "\t-size WxH: specifies visual size (default: scene size)\n" #if defined(__DARWIN__) || defined(__APPLE__) - "\t-thread: enables thread usage for terminal and compositor \n" + "\t-thread: enables thread usage for terminal and compositor \n" #else - "\t-no-thread: disables thread usage (except for audio)\n" + "\t-no-thread: disables thread usage (except for audio)\n" #endif - "\t-no-audio: disables audio \n" - "\t-no-wnd: uses windowless mode (Win32 only)\n" - "\t-no-back: uses transparent background for output window when no background is specified (Win32 only)\n" - "\t-align vh: specifies v and h alignment for windowless mode\n" - " possible v values: t(op), m(iddle), b(ottom)\n" - " possible h values: l(eft), m(iddle), r(ight)\n" - " default alignment is top-left\n" - " default alignment is top-left\n" - "\t-pause: pauses at first frame\n" - "\t-loop: loops presentation\n" - "\t-no-regulation: disables framerate regulation\n" - "\t-bench: disable a/v output and bench source decoding (as fast as possible)\n" - "\t-vbench: disable audio output, video sync bench source decoding/display (as fast as possible)\n" - "\t-sbench: disable all decoders and bench systems layer (as fast as possible)\n" - "\t-fs: starts in fullscreen mode\n" - "\t-views v1:.:vN: creates an auto-stereo scene of N views. vN can be any type of URL supported by GPAC. \n" - " in this mode, URL argument of GPAC is ignored, GUI as well.\n" - " this is equivalent as using views://v1:.:N as an URL.\n" - "\n" - "\t-exit: automatically exits when presentation is over\n" - "\t-run-for TIME: runs for TIME seconds and exits\n" - "\t-no-addon: disable automatic loading of media addons declared in source URL\n" - "\t-gui: starts in GUI mode. The GUI is indicated in GPAC config, section General, by the key [StartupFile]\n" - "\n" - "Dumper Options:\n" - "\t-bmp [times]: dumps given frames to bmp\n" - "\t-png [times]: dumps given frames to png\n" - "\t-raw [times]: dumps given frames to raw\n" - "\t-avi [times]: dumps given file to raw avi\n" - "\t-rgbds: dumps the RGBDS pixel format texture\n" - " with -avi [times]: dumps an rgbds-format .avi\n" - "\t-rgbd: dumps the RGBD pixel format texture\n" - " with -avi [times]: dumps an rgbd-format .avi\n" - "\t-depth: dumps depthmap (z-buffer) frames\n" - " with -avi [times]: dumps depthmap in grayscale .avi\n" - " with -bmp: dumps depthmap in grayscale .bmp\n" - "\t-fps FPS: specifies frame rate for AVI dumping (default: %f)\n" - "\t-scale s: scales the visual size (default: 1)\n" - "\t-fill: uses fill aspect ratio for dumping (default: none)\n" - "\t-show: show window while dumping (default: no)\n" - "\n" - "\t-help: show this screen\n" - "\n" - "MP4Client - GPAC command line player and dumper - version "GPAC_FULL_VERSION"\n" - "GPAC Written by Jean Le Feuvre (c) 2001-2005 - ENST (c) 2005-200X\n" - "GPAC Configuration: " GPAC_CONFIGURATION "\n" - "Features: %s\n", - GF_IMPORT_DEFAULT_FPS, - gpac_features() - ); + "\t-no-audio: disables audio \n" + "\t-no-wnd: uses windowless mode (Win32 only)\n" + "\t-no-back: uses transparent background for output window when no background is specified (Win32 only)\n" + "\t-align vh: specifies v and h alignment for windowless mode\n" + " possible v values: t(op), m(iddle), b(ottom)\n" + " possible h values: l(eft), m(iddle), r(ight)\n" + " default alignment is top-left\n" + " default alignment is top-left\n" + "\t-pause: pauses at first frame\n" + "\t-loop: loops presentation\n" + "\t-no-regulation: disables framerate regulation\n" + "\t-bench: disable a/v output and bench source decoding (as fast as possible)\n" + "\t-vbench: disable audio output, video sync bench source decoding/display (as fast as possible)\n" + "\t-sbench: disable all decoders and bench systems layer (as fast as possible)\n" + "\t-fs: starts in fullscreen mode\n" + "\t-views v1:.:vN: creates an auto-stereo scene of N views. vN can be any type of URL supported by GPAC. \n" + " in this mode, URL argument of GPAC is ignored, GUI as well.\n" + " this is equivalent as using views://v1:.:N as an URL.\n" + "\n" + "\t-exit: automatically exits when presentation is over\n" + "\t-run-for TIME: runs for TIME seconds and exits\n" + "\t-service ID: auto-tune to given service ID in a multiplex\n" + "\t-no-addon: disable automatic loading of media addons declared in source URL\n" + "\t-gui: starts in GUI mode. The GUI is indicated in GPAC config, section General, by the key [StartupFile]\n" + "\n" + "Dumper Options (times is a formated as start-end, with start being sec, h:m:s:f/fps or h:m:s:ms):\n" + "\t-bmp [times]: dumps given frames to bmp\n" + "\t-png [times]: dumps given frames to png\n" + "\t-raw [times]: dumps given frames to raw\n" + "\t-avi [times]: dumps given file to raw avi\n" + "\r-out filename: name of the output file\n" + "\t-rgbds: dumps the RGBDS pixel format texture\n" + " with -avi [times]: dumps an rgbds-format .avi\n" + "\t-rgbd: dumps the RGBD pixel format texture\n" + " with -avi [times]: dumps an rgbd-format .avi\n" + "\t-depth: dumps depthmap (z-buffer) frames\n" + " with -avi [times]: dumps depthmap in grayscale .avi\n" + " with -bmp: dumps depthmap in grayscale .bmp\n" + " with -png: dumps depthmap in grayscale .png\n" + "\t-fps FPS: specifies frame rate for AVI dumping (default: %f)\n" + "\t-scale s: scales the visual size (default: 1)\n" + "\t-fill: uses fill aspect ratio for dumping (default: none)\n" + "\t-show: show window while dumping (default: no)\n" + "\n" + "\t-help: show this screen\n" + "\n" + "MP4Client - GPAC command line player and dumper - version "GPAC_FULL_VERSION"\n" + "GPAC Written by Jean Le Feuvre (c) 2001-2005 - ENST (c) 2005-200X\n" + "GPAC Configuration: " GPAC_CONFIGURATION "\n" + "Features: %s\n", + GF_IMPORT_DEFAULT_FPS, + gpac_features() + ); } void PrintHelp() { fprintf(stderr, "MP4Client command keys:\n" - "\tq: quit\n" - "\tX: kill\n" - "\to: connect to the specified URL\n" - "\tO: connect to the specified playlist\n" - "\tN: switch to the next URL in the playlist. Also works with \\n\n" - "\tP: jumps to a given number ahead in the playlist\n" - "\tr: reload current presentation\n" - "\tD: disconnects the current presentation\n" - "\n" - "\tp: play/pause the presentation\n" - "\ts: step one frame ahead\n" - "\tz: seek into presentation by percentage\n" - "\tT: seek into presentation by time\n" - "\tt: print current timing\n" - "\n" - "\tu: sends a command (BIFS or LASeR) to the main scene\n" - "\te: evaluates JavaScript code\n" - "\tZ: dumps output video to PNG\n" - "\n" - "\tw: view world info\n" - "\tv: view Object Descriptor list\n" - "\ti: view Object Descriptor info (by ID)\n" - "\tj: view Object Descriptor info (by number)\n" - "\tb: view media objects timing and buffering info\n" - "\tm: view media objects buffering and memory info\n" - "\td: dumps scene graph\n" - "\n" - "\tk: turns stress mode on/off\n" - "\tn: changes navigation mode\n" - "\tx: reset to last active viewpoint\n" - "\n" - "\t3: switch OpenGL on or off for 2D scenes\n" - "\n" - "\t4: forces 4/3 Aspect Ratio\n" - "\t5: forces 16/9 Aspect Ratio\n" - "\t6: forces no Aspect Ratio (always fill screen)\n" - "\t7: forces original Aspect Ratio (default)\n" - "\n" - "\tL: changes to new log level. CF MP4Client usage for possible values\n" - "\tT: select new tools to log. CF MP4Client usage for possible values\n" - "\n" - "\tl: list available modules\n" - "\tc: prints some GPAC configuration info\n" - "\tE: forces reload of GPAC configuration\n" - "\n" - "\tR: toggles run-time info display in window title bar on/off\n" - "\tF: toggle displaying of FPS in stderr on/off\n" - "\tg: print GPAC allocated memory\n" - "\th: print this message\n" - "\n" - "\tEXPERIMENTAL/UNSTABLE OPTIONS\n" - "\tC: Enable Streaming Cache\n" - "\tS: Stops Streaming Cache and save to file\n" - "\tA: Aborts Streaming Cache\n" - "\tM: specifies video cache memory for 2D objects\n" - "\n" - "MP4Client - GPAC command line player - version %s\n" - "GPAC Written by Jean Le Feuvre (c) 2001-2005 - ENST (c) 2005-200X\n", - - GPAC_FULL_VERSION - ); + "\tq: quit\n" + "\tX: kill\n" + "\to: connect to the specified URL\n" + "\tO: connect to the specified playlist\n" + "\tN: switch to the next URL in the playlist. Also works with \\n\n" + "\tP: jumps to a given number ahead in the playlist\n" + "\tr: reload current presentation\n" + "\tD: disconnects the current presentation\n" + "\n" + "\tp: play/pause the presentation\n" + "\ts: step one frame ahead\n" + "\tz: seek into presentation by percentage\n" + "\tT: seek into presentation by time\n" + "\tt: print current timing\n" + "\n" + "\tu: sends a command (BIFS or LASeR) to the main scene\n" + "\te: evaluates JavaScript code\n" + "\tZ: dumps output video to PNG\n" + "\n" + "\tw: view world info\n" + "\tv: view Object Descriptor list\n" + "\ti: view Object Descriptor info (by ID)\n" + "\tj: view Object Descriptor info (by number)\n" + "\tb: view media objects timing and buffering info\n" + "\tm: view media objects buffering and memory info\n" + "\td: dumps scene graph\n" + "\n" + "\tk: turns stress mode on/off\n" + "\tn: changes navigation mode\n" + "\tx: reset to last active viewpoint\n" + "\n" + "\t3: switch OpenGL on or off for 2D scenes\n" + "\n" + "\t4: forces 4/3 Aspect Ratio\n" + "\t5: forces 16/9 Aspect Ratio\n" + "\t6: forces no Aspect Ratio (always fill screen)\n" + "\t7: forces original Aspect Ratio (default)\n" + "\n" + "\tL: changes to new log level. CF MP4Client usage for possible values\n" + "\tT: select new tools to log. CF MP4Client usage for possible values\n" + "\n" + "\tl: list available modules\n" + "\tc: prints some GPAC configuration info\n" + "\tE: forces reload of GPAC configuration\n" + "\n" + "\tR: toggles run-time info display in window title bar on/off\n" + "\tF: toggle displaying of FPS in stderr on/off\n" + "\tg: print GPAC allocated memory\n" + "\th: print this message\n" + "\n" + "\tEXPERIMENTAL/UNSTABLE OPTIONS\n" + "\tC: Enable Streaming Cache\n" + "\tS: Stops Streaming Cache and save to file\n" + "\tA: Aborts Streaming Cache\n" + "\tM: specifies video cache memory for 2D objects\n" + "\n" + "MP4Client - GPAC command line player - version %s\n" + "GPAC Written by Jean Le Feuvre (c) 2001-2005 - ENST (c) 2005-200X\n", + + GPAC_FULL_VERSION + ); } @@ -330,25 +335,25 @@ static void UpdateRTInfo(const char *legend) /*refresh every second*/ if (!display_rti && !rti_logs) return; - if (!gf_sys_get_rti(rti_update_time_ms, &rti, 0) && !legend) + if (!gf_sys_get_rti(rti_update_time_ms, &rti, 0) && !legend) return; if (display_rti) { char szMsg[1024]; if (rti.total_cpu_usage && (bench_mode<2) ) { - sprintf(szMsg, "FPS %d CPU %2d (%02d) Mem %d kB", - (u32) gf_term_get_framerate(term, 0), rti.total_cpu_usage, rti.process_cpu_usage, (u32) (rti.gpac_memory / 1024)); + sprintf(szMsg, "FPS %d CPU %2d (%02d) Mem %d kB", + (u32) gf_term_get_framerate(term, 0), rti.total_cpu_usage, rti.process_cpu_usage, (u32) (rti.gpac_memory / 1024)); } else { - sprintf(szMsg, "FPS %d CPU %02d Mem %d kB", - (u32) gf_term_get_framerate(term, 0), rti.process_cpu_usage, (u32) (rti.gpac_memory / 1024) ); + sprintf(szMsg, "FPS %d CPU %02d Mem %d kB", + (u32) gf_term_get_framerate(term, 0), rti.process_cpu_usage, (u32) (rti.gpac_memory / 1024) ); } if (display_rti==2) { if (bench_mode>=2) { PrintAVInfo(GF_FALSE); } - fprintf(stderr, "%s\r", szMsg); + fprintf(stderr, "%s\r", szMsg); } else { GF_Event evt; evt.type = GF_EVENT_SET_CAPTION; @@ -357,14 +362,14 @@ static void UpdateRTInfo(const char *legend) } } if (rti_logs) { - fprintf(rti_logs, "% 8d\t% 8d\t% 8d\t% 4d\t% 8d\t%s", - gf_sys_clock(), - gf_term_get_time_in_ms(term), - rti.total_cpu_usage, - (u32) gf_term_get_framerate(term, 0), - (u32) (rti.gpac_memory / 1024), - legend ? legend : "" - ); + fprintf(rti_logs, "% 8d\t% 8d\t% 8d\t% 4d\t% 8d\t%s", + gf_sys_clock(), + gf_term_get_time_in_ms(term), + rti.total_cpu_usage, + (u32) gf_term_get_framerate(term, 0), + (u32) (rti.gpac_memory / 1024), + legend ? legend : "" + ); if (!legend) fprintf(rti_logs, "\n"); } } @@ -382,15 +387,30 @@ static void ResetCaption() /*get any service info*/ if (!startup_file && gf_term_get_service_info(term, gf_term_get_root_object(term), &com) == GF_OK) { strcpy(szName, ""); - if (com.track_info) { + if (com.track_info) { char szBuf[10]; sprintf(szBuf, "%02d ", (u32) (com.track_info>>16) ); strcat(szName, szBuf); } - if (com.artist) { strcat(szName, com.artist); strcat(szName, " "); } - if (com.name) { strcat(szName, com.name); strcat(szName, " "); } - if (com.album) { strcat(szName, "("); strcat(szName, com.album); strcat(szName, ")"); } - + if (com.artist) { + strcat(szName, com.artist); + strcat(szName, " "); + } + if (com.name) { + strcat(szName, com.name); + strcat(szName, " "); + } + if (com.album) { + strcat(szName, "("); + strcat(szName, com.album); + strcat(szName, ")"); + } + if (com.provider) { + strcat(szName, "("); + strcat(szName, com.provider); + strcat(szName, ")"); + } + if (strlen(szName)) event.caption.caption = szName; } if (!event.caption.caption) { @@ -409,8 +429,10 @@ u32 get_sys_col(int idx) { u32 res; DWORD val = GetSysColor(idx); - res = (val)&0xFF; res<<=8; - res |= (val>>8)&0xFF; res<<=8; + res = (val)&0xFF; + res<<=8; + res |= (val>>8)&0xFF; + res<<=8; res |= (val>>16)&0xFF; return res; } @@ -427,26 +449,26 @@ void switch_bench(u32 is_on) #ifndef WIN32 #include int getch() { - struct termios old; - struct termios new; - int rc; - if (tcgetattr(0, &old) == -1) { - return -1; - } - new = old; - new.c_lflag &= ~(ICANON | ECHO); - new.c_cc[VMIN] = 1; - new.c_cc[VTIME] = 0; - if (tcsetattr(0, TCSANOW, &new) == -1) { - return -1; - } - rc = getchar(); - (void) tcsetattr(0, TCSANOW, &old); - return rc; + struct termios old; + struct termios new; + int rc; + if (tcgetattr(0, &old) == -1) { + return -1; + } + new = old; + new.c_lflag &= ~(ICANON | ECHO); + new.c_cc[VMIN] = 1; + new.c_cc[VTIME] = 0; + if (tcsetattr(0, TCSANOW, &new) == -1) { + return -1; + } + rc = getchar(); + (void) tcsetattr(0, TCSANOW, &old); + return rc; } #else -int getch(){ - return getchar(); +int getch() { + return getchar(); } #endif @@ -454,38 +476,38 @@ int getch(){ * Reads a line of input from stdin * @param line the buffer to fill * @param maxSize the maximum size of the line to read - * @param showContent boolean indicating if the line read should be printed on stderr or not + * @param showContent boolean indicating if the line read should be printed on stderr or not */ -static const char * read_line_input(char * line, int maxSize, Bool showContent){ - char read; - int i = 0; - if (fflush( stderr )) - perror("Failed to flush buffer %s"); - do { - line[i] = '\0'; - if (i >= maxSize - 1) +static const char * read_line_input(char * line, int maxSize, Bool showContent) { + char read; + int i = 0; + if (fflush( stderr )) + perror("Failed to flush buffer %s"); + do { + line[i] = '\0'; + if (i >= maxSize - 1) + return line; + read = getch(); + if (read == 8 || read == 127) { + if (i > 0) { + fprintf(stderr, "\b \b"); + i--; + } + } else if (read > 32) { + fputc(showContent ? read : '*', stderr); + line[i++] = read; + } + fflush(stderr); + } while (read != '\n'); + if (!read) + return 0; return line; - read = getch(); - if (read == 8 || read == 127){ - if (i > 0){ - fprintf(stderr, "\b \b"); - i--; - } - } else if (read > 32){ - fputc(showContent ? read : '*', stderr); - line[i++] = read; - } - fflush(stderr); - } while (read != '\n'); - if (!read) - return 0; - return line; } Bool GPAC_EventProc(void *ptr, GF_Event *evt) { if (!term) return 0; - + if (gui_mode==1) { if (evt->type==GF_EVENT_QUIT) { Run = 0; @@ -520,30 +542,30 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CONSOLE, ("%s %s: %s\n", servName, evt->message.message, gf_error_to_string(evt->message.error))); } - } else if (!be_quiet) + } else if (!be_quiet) GF_LOG(GF_LOG_INFO, GF_LOG_CONSOLE, ("%s %s\n", servName, evt->message.message)); } - break; + break; case GF_EVENT_PROGRESS: - { - char *szTitle = ""; - if (evt->progress.progress_type==0) { - szTitle = "Buffer "; - if (bench_mode) { - if (evt->progress.done >= evt->progress.total) bench_buffer = 0; - else bench_buffer = 1 + 100*evt->progress.done / evt->progress.total; - break; - } - } - else if (evt->progress.progress_type==1) { - if (bench_mode) break; - szTitle = "Download "; + { + char *szTitle = ""; + if (evt->progress.progress_type==0) { + szTitle = "Buffer "; + if (bench_mode && (bench_mode!=3) ) { + if (evt->progress.done >= evt->progress.total) bench_buffer = 0; + else bench_buffer = 1 + 100*evt->progress.done / evt->progress.total; + break; } - else if (evt->progress.progress_type==2) szTitle = "Import "; - gf_set_progress(szTitle, evt->progress.done, evt->progress.total); } - break; - + else if (evt->progress.progress_type==1) { + if (bench_mode) break; + szTitle = "Download "; + } + else if (evt->progress.progress_type==2) szTitle = "Import "; + gf_set_progress(szTitle, evt->progress.done, evt->progress.total); + } + break; + case GF_EVENT_DBLCLICK: gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN)); @@ -608,21 +630,21 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) case GF_KEY_D: if (evt->key.flags & GF_KEY_MOD_CTRL) gf_term_set_option(term, GF_OPT_DRAW_MODE, (gf_term_get_option(term, GF_OPT_DRAW_MODE)==GF_DRAW_MODE_DEFER) ? GF_DRAW_MODE_IMMEDIATE : GF_DRAW_MODE_DEFER ); break; - case GF_KEY_4: + case GF_KEY_4: if (evt->key.flags & GF_KEY_MOD_CTRL) - gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break; - case GF_KEY_5: + case GF_KEY_5: if (evt->key.flags & GF_KEY_MOD_CTRL) - gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break; - case GF_KEY_6: + case GF_KEY_6: if (evt->key.flags & GF_KEY_MOD_CTRL) - gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break; - case GF_KEY_7: + case GF_KEY_7: if (evt->key.flags & GF_KEY_MOD_CTRL) - gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; case GF_KEY_P: if (evt->key.flags & GF_KEY_MOD_CTRL && is_connected) { @@ -659,6 +681,32 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) if (is_connected) reload = 1; break; + case GF_KEY_A: + addon_visible = !addon_visible; + gf_term_toggle_addons(term, addon_visible); + break; + case GF_KEY_UP: + if (evt->key.flags & GF_KEY_MOD_CTRL && is_connected) { + playback_speed *= 2; + fprintf(stderr, "Playing at %g speed\n", FIX2FLT(playback_speed)); + gf_term_set_speed(term, playback_speed); + } + break; + case GF_KEY_DOWN: + if (evt->key.flags & GF_KEY_MOD_CTRL && is_connected) { + playback_speed /= 2; + fprintf(stderr, "Playing at %g speed\n", FIX2FLT(playback_speed)); + gf_term_set_speed(term, playback_speed); + } + break; + case GF_KEY_LEFT: + if (evt->key.flags & GF_KEY_MOD_CTRL && is_connected) { + playback_speed = -playback_speed; + fprintf(stderr, "Playing at %g speed\n", FIX2FLT(playback_speed)); + gf_term_set_speed(term, playback_speed); + } + break; + } break; @@ -689,7 +737,7 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) move.move.align_y = (align_mode>>8) & 0xFF; move.move.relative = 2; gf_term_user_event(term, &move); - } + } break; case GF_EVENT_SCENE_SIZE: if (forced_width && forced_height) { @@ -722,14 +770,14 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) i=0; while (iopen_file.nb_files) { if (evt->open_file.files[i] != NULL) { - fprintf(playlist, "%s\n", evt->open_file.files[i]); + fprintf(playlist, "%s\n", evt->open_file.files[i]); } i++; } fseek(playlist, pos, SEEK_SET); request_next_playlist_item = 1; } - return 1; + return 1; case GF_EVENT_QUIT: if (evt->message.error) { @@ -743,7 +791,7 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) case GF_EVENT_MIGRATE: { } - break; + break; case GF_EVENT_NAVIGATE_INFO: if (evt->navigate.to_url) fprintf(stderr, "Go to URL: \"%s\"\r", evt->navigate.to_url); break; @@ -767,7 +815,7 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) assert( evt->auth.user); assert( evt->auth.password); assert( evt->auth.site_url); - while ((!strlen(evt->auth.user) || !strlen(evt->auth.password)) && (maxTries--) >= 0){ + while ((!strlen(evt->auth.user) || !strlen(evt->auth.password)) && (maxTries--) >= 0) { fprintf(stderr, "**** Authorization required for site %s ****\n", evt->auth.site_url); fprintf(stderr, "login : "); read_line_input(evt->auth.user, 50, 1); @@ -775,15 +823,17 @@ Bool GPAC_EventProc(void *ptr, GF_Event *evt) read_line_input(evt->auth.password, 50, 0); fprintf(stderr, "*********\n"); } - if (maxTries < 0){ - fprintf(stderr, "**** No User or password has been filled, aborting ***\n"); - return 0; + if (maxTries < 0) { + fprintf(stderr, "**** No User or password has been filled, aborting ***\n"); + return 0; } return 1; } case GF_EVENT_ADDON_DETECTED: - if (enable_add_ons) + if (enable_add_ons) { fprintf(stderr, "Media Addon %s detected - enabling it\n", evt->addon_connect.addon_url); + addon_visible = 1; + } return enable_add_ons; } return 0; @@ -931,7 +981,8 @@ void set_cfg_option(char *opt_string) } sep[0] = 0; strcpy(szSec, opt_string); - sep[0] = ':'; sep ++; + sep[0] = ':'; + sep ++; sep2 = strchr(sep, '='); if (!sep2) { fprintf(stderr, "Badly formatted option %s - expected Section:Name=Value\n", opt_string); @@ -940,7 +991,7 @@ void set_cfg_option(char *opt_string) sep2[0] = 0; strcpy(szKey, sep); strcpy(szVal, sep2+1); - sep2[0] = '='; + sep2[0] = '='; if (!stricmp(szVal, "null")) szVal[0]=0; gf_cfg_set_key(cfg_file, szSec, szKey, szVal[0] ? szVal : NULL); } @@ -955,6 +1006,7 @@ int main (int argc, char **argv) const char *str; u32 i, times[100], nb_times, dump_mode; u32 simulation_time_in_ms = 0; + u32 initial_service_id = 0; Bool auto_exit = GF_FALSE; Bool logs_set = GF_FALSE; Bool start_fs = GF_FALSE; @@ -969,7 +1021,7 @@ int main (int argc, char **argv) #endif Double fps = GF_IMPORT_DEFAULT_FPS; Bool fill_ar, visible; - char *url_arg, *the_cfg, *rti_file, *views; + char *url_arg, *out_arg, *the_cfg, *rti_file, *views, *default_com; FILE *logfile = NULL; Float scale = 1; #ifndef WIN32 @@ -983,7 +1035,7 @@ int main (int argc, char **argv) dump_mode = 0; fill_ar = visible = GF_FALSE; - url_arg = the_cfg = rti_file = views = NULL; + url_arg = out_arg = the_cfg = rti_file = views = default_com = NULL; nb_times = 0; times[0] = 0; @@ -998,7 +1050,7 @@ int main (int argc, char **argv) #ifdef GPAC_MEMORY_TRACKING enable_mem_tracker = GF_TRUE; #else - fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); + fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); #endif } else if (!strcmp(arg, "-h") || !strcmp(arg, "-help")) { @@ -1023,7 +1075,7 @@ int main (int argc, char **argv) return 1; } - if( gf_cfg_get_key(cfg_file, "General", "Logs") != NULL ){ + if( gf_cfg_get_key(cfg_file, "General", "Logs") != NULL ) { logs_set = GF_TRUE; } @@ -1065,9 +1117,10 @@ int main (int argc, char **argv) dump_mode=9; /* rgbd texture directly*/ if (dump_mode==1) dump_mode = 10; /* .avi rgbds dump*/ } else if (!strcmp(arg, "-depth")) { - depth_dump = 1; + depth_dump = 1; if (dump_mode==2) dump_mode=7; /* grayscale .bmp depth dump*/ else if (dump_mode==1) dump_mode=8; /* .avi depth dump*/ + else if (dump_mode==11)dump_mode=12; else dump_mode=4; /*depth dump*/ } else if (!strcmp(arg, "-bmp")) { if(depth_dump) dump_mode=7; /*grayscale depth .bmp dump*/ @@ -1137,9 +1190,12 @@ int main (int argc, char **argv) #ifdef GPAC_MEMORY_TRACKING enable_mem_tracker = 1; #else - fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); + fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); #endif } + else if (!strcmp(arg, "-out")) { + out_arg = gf_strdup(argv[i+1]); + } else if (!strcmp(arg, "-loop")) loop_at_end = 1; else if (!strcmp(arg, "-bench")) bench_mode = 1; else if (!strcmp(arg, "-vbench")) bench_mode = 2; @@ -1164,10 +1220,18 @@ int main (int argc, char **argv) simulation_time_in_ms = 1; /*1ms*/ i++; } + else if (!stricmp(arg, "-com")) { + default_com = argv[i+1]; + i++; + } + else if (!stricmp(arg, "-service")) { + initial_service_id = atoi(argv[i+1]); + i++; + } else if (!stricmp(arg, "-help")) { PrintUsage(); return 1; - } else { + } else { fprintf(stderr, "Unrecognized option %s - skipping\n", arg); } } @@ -1206,7 +1270,7 @@ int main (int argc, char **argv) GF_SystemRTInfo rti; if (gf_sys_get_rti(0, &rti, 0)) fprintf(stderr, "System info: %d MB RAM - %d cores\n", (u32) (rti.physical_memory/1024/1024), rti.nb_cores); - } + } /*setup dumping options*/ @@ -1254,7 +1318,7 @@ int main (int argc, char **argv) } } - fprintf(stderr, "Loading GPAC Terminal\n"); + fprintf(stderr, "Loading GPAC Terminal\n"); i = gf_sys_clock(); term = gf_term_new(&user); if (!term) { @@ -1313,63 +1377,63 @@ int main (int argc, char **argv) times[0] = 0; nb_times++; } - dump_file(url_arg, dump_mode, fps, forced_width, forced_height, scale, times, nb_times); + dump_file(url_arg, out_arg, dump_mode, fps, forced_width, forced_height, scale, times, nb_times); Run = 0; } else - /*connect if requested*/ - if (views) { - } else if (!gui_mode && url_arg) { - char *ext; - - strcpy(the_url, url_arg); - ext = strrchr(the_url, '.'); - if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls"))) { - GF_Err e = GF_OK; - fprintf(stderr, "Opening Playlist %s\n", the_url); - - strcpy(pl_path, the_url); - /*this is not clean, we need to have a plugin handle playlist for ourselves*/ - if (!strncmp("http:", the_url, 5)) { - GF_DownloadSession *sess = gf_dm_sess_new(term->downloader, the_url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL, &e); - if (sess) { - e = gf_dm_sess_process(sess); - if (!e) strcpy(the_url, gf_dm_sess_get_cache_name(sess)); - gf_dm_sess_del(sess); + /*connect if requested*/ + if (views) { + } else if (!gui_mode && url_arg) { + char *ext; + + strcpy(the_url, url_arg); + ext = strrchr(the_url, '.'); + if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls"))) { + GF_Err e = GF_OK; + fprintf(stderr, "Opening Playlist %s\n", the_url); + + strcpy(pl_path, the_url); + /*this is not clean, we need to have a plugin handle playlist for ourselves*/ + if (!strncmp("http:", the_url, 5)) { + GF_DownloadSession *sess = gf_dm_sess_new(term->downloader, the_url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL, &e); + if (sess) { + e = gf_dm_sess_process(sess); + if (!e) strcpy(the_url, gf_dm_sess_get_cache_name(sess)); + gf_dm_sess_del(sess); + } } - } - - playlist = e ? NULL : gf_f64_open(the_url, "rt"); - readonly_playlist = 1; - if (playlist) { - if (1 > fscanf(playlist, "%s", the_url)) - fprintf(stderr, "Cannot read any URL from playlist\n"); - else { - fprintf(stderr, "Opening URL %s\n", the_url); - gf_term_connect_with_path(term, the_url, pl_path); + + playlist = e ? NULL : gf_f64_open(the_url, "rt"); + readonly_playlist = 1; + if (playlist) { + if (1 > fscanf(playlist, "%s", the_url)) + fprintf(stderr, "Cannot read any URL from playlist\n"); + else { + fprintf(stderr, "Opening URL %s\n", the_url); + gf_term_connect_with_path(term, the_url, pl_path); + } + } else { + if (e) + fprintf(stderr, "Failed to open playlist %s: %s\n", the_url, gf_error_to_string(e) ); + fprintf(stderr, "Hit 'h' for help\n\n"); } } else { - if (e) - fprintf(stderr, "Failed to open playlist %s: %s\n", the_url, gf_error_to_string(e) ); - fprintf(stderr, "Hit 'h' for help\n\n"); + fprintf(stderr, "Opening URL %s\n", the_url); + if (pause_at_first) fprintf(stderr, "[Status: Paused]\n"); + gf_term_connect_from_time(term, the_url, (u64) (play_from*1000), pause_at_first); } } else { - fprintf(stderr, "Opening URL %s\n", the_url); - if (pause_at_first) fprintf(stderr, "[Status: Paused]\n"); - gf_term_connect_from_time(term, the_url, (u64) (play_from*1000), pause_at_first); - } - } else { - fprintf(stderr, "Hit 'h' for help\n\n"); - str = gf_cfg_get_key(cfg_file, "General", "StartupFile"); - if (str) { - strcpy(the_url, "MP4Client "GPAC_FULL_VERSION); - gf_term_connect(term, str); - startup_file = 1; - } - if (url_arg) { - gf_cfg_set_key(cfg_file, "Temp", "GUIStartupFile", url_arg); + fprintf(stderr, "Hit 'h' for help\n\n"); + str = gf_cfg_get_key(cfg_file, "General", "StartupFile"); + if (str) { + strcpy(the_url, "MP4Client "GPAC_FULL_VERSION); + gf_term_connect(term, str); + startup_file = 1; + } + if (url_arg) { + gf_cfg_set_key(cfg_file, "Temp", "GUIStartupFile", url_arg); + } } - } if (gui_mode==2) gui_mode=0; if (start_fs) gf_term_set_option(term, GF_OPT_FULLSCREEN, 1); @@ -1384,7 +1448,8 @@ int main (int argc, char **argv) bench_mode_start = gf_sys_clock(); } - while (Run) { + + while (Run) { /*we don't want getchar to block*/ if (gui_mode || !gf_prompt_has_input()) { if (reload) { @@ -1392,7 +1457,7 @@ int main (int argc, char **argv) gf_term_disconnect(term); gf_term_connect(term, startup_file ? gf_cfg_get_key(cfg_file, "General", "StartupFile") : the_url); } - if (restart) { + if (restart && gf_term_get_option(term, GF_OPT_IS_OVER)) { restart = 0; gf_term_play_from_time(term, 0, 0); } @@ -1401,6 +1466,19 @@ int main (int argc, char **argv) request_next_playlist_item = 0; goto force_input; } + + if (default_com && is_connected) { + gf_term_scene_update(term, NULL, default_com); + default_com = NULL; + } + if (initial_service_id && is_connected) { + GF_ObjectManager *root_od = gf_term_get_root_object(term); + if (root_od) { + gf_term_select_service(term, root_od, initial_service_id); + initial_service_id = 0; + } + } + if (!use_rtix || display_rti) UpdateRTInfo(NULL); if (term_step) { gf_term_process_step(term); @@ -1409,12 +1487,12 @@ int main (int argc, char **argv) } if (auto_exit && eos_seen && gf_term_get_option(term, GF_OPT_IS_OVER)) { Run = 0; - } + } /*sim time*/ - if (simulation_time_in_ms - && ( (gf_term_get_time_in_ms(term)>simulation_time_in_ms) || (!url_arg && gf_sys_clock()>simulation_time_in_ms)) - ) { + if (simulation_time_in_ms + && ( (gf_term_get_time_in_ms(term)>simulation_time_in_ms) || (!url_arg && gf_sys_clock()>simulation_time_in_ms)) + ) { Run = 0; } continue; @@ -1435,9 +1513,9 @@ force_input: startup_file = 0; gf_term_disconnect(term); fprintf(stderr, "Enter the absolute URL\n"); - if (1 > scanf("%s", the_url)){ - fprintf(stderr, "Cannot read absolute URL, aborting\n"); - break; + if (1 > scanf("%s", the_url)) { + fprintf(stderr, "Cannot read absolute URL, aborting\n"); + break; } if (rti_file) init_rti_logs(rti_file, the_url, use_rtix); gf_term_connect(term, the_url); @@ -1445,16 +1523,16 @@ force_input: case 'O': gf_term_disconnect(term); fprintf(stderr, "Enter the absolute URL to the playlist\n"); - if (1 > scanf("%s", the_url)){ - fprintf(stderr, "Cannot read the absolute URL, aborting.\n"); - break; + if (1 > scanf("%s", the_url)) { + fprintf(stderr, "Cannot read the absolute URL, aborting.\n"); + break; } playlist = gf_f64_open(the_url, "rt"); if (playlist) { - if (1 > fscanf(playlist, "%s", the_url)){ - fprintf(stderr, "Cannot read any URL from playlist, aborting.\n"); - fclose( playlist); - break; + if (1 > fscanf(playlist, "%s", the_url)) { + fprintf(stderr, "Cannot read any URL from playlist, aborting.\n"); + fclose( playlist); + break; } fprintf(stderr, "Opening URL %s\n", the_url); gf_term_connect(term, the_url); @@ -1484,14 +1562,14 @@ force_input: if (playlist) { u32 count; gf_term_disconnect(term); - if (1 > scanf("%u", &count)){ - fprintf(stderr, "Cannot read number, aborting.\n"); - break; + if (1 > scanf("%u", &count)) { + fprintf(stderr, "Cannot read number, aborting.\n"); + break; } while (count) { - if (fscanf(playlist, "%s", the_url)){ - fprintf(stderr, "Failed to read line, aborting\n"); - break; + if (fscanf(playlist, "%s", the_url)) { + fprintf(stderr, "Failed to read line, aborting\n"); + break; } count--; } @@ -1500,10 +1578,10 @@ force_input: } break; case 'r': - if (is_connected) + if (is_connected) reload = 1; break; - + case 'D': if (is_connected) gf_term_disconnect(term); break; @@ -1535,11 +1613,14 @@ force_input: PrintTime(Duration); res = gf_term_get_time_in_ms(term); if (c=='z') { - res *= 100; res /= (s64)Duration; + res *= 100; + res /= (s64)Duration; fprintf(stderr, " (current %.2f %%)\nEnter Seek percentage:\n", res); - if (scanf("%d", &seekTo) == 1) { + if (scanf("%d", &seekTo) == 1) { if (seekTo > 100) seekTo = 100; - res = (Double)(s64)Duration; res /= 100; res *= seekTo; + res = (Double)(s64)Duration; + res /= 100; + res *= seekTo; gf_term_play_from_time(term, (u64) (s64) res, 0); } } else { @@ -1549,8 +1630,15 @@ force_input: fprintf(stderr, "\nEnter seek time (Format: s, m:s or h:m:s):\n"); h = m = s = 0; r =scanf("%d:%d:%d", &h, &m, &s); - if (r==2) { s = m; m = h; h = 0; } - else if (r==1) { s = h; m = h = 0; } + if (r==2) { + s = m; + m = h; + h = 0; + } + else if (r==1) { + s = h; + m = h = 0; + } if (r && (r<=3)) { u64 time = h*3600 + m*60 + s; @@ -1570,7 +1658,7 @@ force_input: fprintf(stderr, "\n"); } } - break; + break; case 'w': if (is_connected) PrintWorldInfo(term); break; @@ -1581,8 +1669,8 @@ force_input: if (is_connected) { u32 ID; do { - fprintf(stderr, "Enter OD ID (0 for main OD): "); - fflush(stderr); + fprintf(stderr, "Enter OD ID (0 for main OD): "); + fflush(stderr); } while( 1 > scanf("%ud", &ID)); ViewOD(term, ID, (u32)-1); } @@ -1591,8 +1679,8 @@ force_input: if (is_connected) { u32 num; do { - fprintf(stderr, "Enter OD number (0 for main OD): "); - fflush(stderr); + fprintf(stderr, "Enter OD number (0 for main OD): "); + fflush(stderr); } while( 1 > scanf("%ud", &num)); ViewOD(term, (u32)-1, num); } @@ -1625,8 +1713,8 @@ force_input: Bool xml_dump, std_out; radname[0] = 0; do { - fprintf(stderr, "Enter Inline OD ID if any or 0 : "); - fflush(stderr); + fprintf(stderr, "Enter Inline OD ID if any or 0 : "); + fflush(stderr); } while( 1 > scanf("%ud", &odid)); if (odid) { GF_ObjectManager *root_odm = gf_term_get_root_object(term); @@ -1641,9 +1729,9 @@ force_input: odm = NULL; } } - do{ - fprintf(stderr, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stderr: "); - fflush(stderr); + do { + fprintf(stderr, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stderr: "); + fflush(stderr); } while( 1 > scanf("%s", radname)); sExt = strrchr(radname, '.'); xml_dump = 0; @@ -1667,7 +1755,7 @@ force_input: fprintf(stderr, "Using %s for 2D drawing\n", use_3d ? "OpenGL" : "2D rasterizer"); } } - break; + break; case 'k': { Bool opt = gf_term_get_option(term, GF_OPT_STRESS_MODE); @@ -1675,22 +1763,42 @@ force_input: fprintf(stderr, "Turning stress mode %s\n", opt ? "on" : "off"); gf_term_set_option(term, GF_OPT_STRESS_MODE, opt); } + break; + case '4': + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); + break; + case '5': + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); + break; + case '6': + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); + break; + case '7': + gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; - case '4': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break; - case '5': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break; - case '6': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break; - case '7': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; case 'C': switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) { - case GF_MEDIA_CACHE_DISABLED: gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED); break; - case GF_MEDIA_CACHE_ENABLED: gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED); break; - case GF_MEDIA_CACHE_RUNNING: fprintf(stderr, "Streaming Cache is running - please stop it first\n"); continue; + case GF_MEDIA_CACHE_DISABLED: + gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED); + break; + case GF_MEDIA_CACHE_ENABLED: + gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED); + break; + case GF_MEDIA_CACHE_RUNNING: + fprintf(stderr, "Streaming Cache is running - please stop it first\n"); + continue; } switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) { - case GF_MEDIA_CACHE_ENABLED: fprintf(stderr, "Streaming Cache Enabled\n"); break; - case GF_MEDIA_CACHE_DISABLED: fprintf(stderr, "Streaming Cache Disabled\n"); break; - case GF_MEDIA_CACHE_RUNNING: fprintf(stderr, "Streaming Cache Running\n"); break; + case GF_MEDIA_CACHE_ENABLED: + fprintf(stderr, "Streaming Cache Enabled\n"); + break; + case GF_MEDIA_CACHE_DISABLED: + fprintf(stderr, "Streaming Cache Disabled\n"); + break; + case GF_MEDIA_CACHE_RUNNING: + fprintf(stderr, "Streaming Cache Running\n"); + break; } break; case 'S': @@ -1719,9 +1827,9 @@ force_input: fprintf(stderr, "Enter command to send:\n"); fflush(stdin); szCom[0] = 0; - if (1 > scanf("%[^\t\n]", szCom)){ - fprintf(stderr, "Cannot read command to send, aborting.\n"); - break; + if (1 > scanf("%[^\t\n]", szCom)) { + fprintf(stderr, "Cannot read command to send, aborting.\n"); + break; } e = gf_term_scene_update(term, NULL, szCom); if (e) fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e)); @@ -1734,9 +1842,9 @@ force_input: fprintf(stderr, "Enter JavaScript code to evaluate:\n"); fflush(stdin); jsCode[0] = 0; - if (1 > scanf("%[^\t\n]", jsCode)){ - fprintf(stderr, "Cannot read code to evaluate, aborting.\n"); - break; + if (1 > scanf("%[^\t\n]", jsCode)) { + fprintf(stderr, "Cannot read code to evaluate, aborting.\n"); + break; } e = gf_term_scene_update(term, "application/ecmascript", jsCode); if (e) fprintf(stderr, "Processing JS code failed: %s\n", gf_error_to_string(e)); @@ -1750,8 +1858,8 @@ force_input: fprintf(stderr, "Enter new log level (current tools %s):\n", cur_logs); gf_free(cur_logs); if (scanf("%s", szLog) < 1) { - fprintf(stderr, "Cannot read new log level, aborting.\n"); - break; + fprintf(stderr, "Cannot read new log level, aborting.\n"); + break; } gf_log_modify_tools_levels(szLog); } @@ -1776,7 +1884,7 @@ force_input: case 'H': { - u32 http_bitrate = gf_term_get_option(term, GF_OPT_HTTP_MAX_RATE); + u32 http_bitrate = gf_term_get_option(term, GF_OPT_HTTP_MAX_RATE); do { fprintf(stderr, "Enter new http bitrate in bps (0 for none) - current limit: %d\n", http_bitrate); } while (1 > scanf("%ud", &http_bitrate)); @@ -1786,7 +1894,7 @@ force_input: break; case 'E': - gf_term_set_option(term, GF_OPT_RELOAD_CONFIG, 1); + gf_term_set_option(term, GF_OPT_RELOAD_CONFIG, 1); break; case 'B': @@ -1799,9 +1907,9 @@ force_input: fprintf(stderr, "Enter option to set (Section:Name=Value):\n"); fflush(stdin); szOpt[0] = 0; - if (1 > scanf("%[^\t\n]", szOpt)){ - fprintf(stderr, "Cannot read option\n"); - break; + if (1 > scanf("%[^\t\n]", szOpt)) { + fprintf(stderr, "Cannot read option\n"); + break; } set_cfg_option(szOpt); } @@ -1869,6 +1977,33 @@ force_input: } } fprintf(stderr, "Done: %s\n", szFileName); + } + break; + + case 'G': + { + GF_ObjectManager *root_od, *odm; + u32 index; + char szOpt[8192]; + fprintf(stderr, "Enter 0-based index of object to select or service ID:\n"); + fflush(stdin); + szOpt[0] = 0; + if (1 > scanf("%[^\t\n]", szOpt)) { + fprintf(stderr, "Cannot read OD ID\n"); + break; + } + index = atoi(szOpt); + odm = NULL; + root_od = gf_term_get_root_object(term); + if (root_od) { + odm = gf_term_get_object(term, root_od, index); + if (odm) { + gf_term_select_object(term, odm); + } else { + fprintf(stderr, "Cannot find object at index %d - trying with serviceID\n", index); + gf_term_select_service(term, root_od, index); + } + } } break; @@ -1880,7 +2015,7 @@ force_input: } } - if (bench_mode) { + if (bench_mode) { PrintAVInfo(GF_TRUE); } @@ -1955,7 +2090,7 @@ void PrintAVInfo(Bool final) } } - if (bench_buffer) { + if (0 && bench_buffer) { fprintf(stderr, "Buffering %d %% ", bench_buffer-1); return; } @@ -1966,9 +2101,9 @@ void PrintAVInfo(Bool final) return; } avg_dec_time = 0; - if (v_odi.nb_dec_frames && v_odi.total_dec_time) { - avg_dec_time = (Float) 1000000 * v_odi.nb_dec_frames; - avg_dec_time /= v_odi.total_dec_time; + if (v_odi.nb_dec_frames && v_odi.total_dec_time) { + avg_dec_time = (Float) 1000000 * v_odi.nb_dec_frames; + avg_dec_time /= v_odi.total_dec_time; } } if (print_codecs && audio_odm) { @@ -1987,9 +2122,9 @@ void PrintAVInfo(Bool final) if (!video_odm) { u32 nb_frames_drawn; Double FPS = gf_term_get_simulation_frame_rate(term, &nb_frames_drawn); - fprintf(stderr, "Drawn %d frames FPS %.2f (simulation FPS %.2f) - duration %d ms\n", nb_frames_drawn, ((Float)nb_frames_drawn*1000)/tot_time, FPS, gf_term_get_time_in_ms(term) ); + fprintf(stderr, "Drawn %d frames FPS %.2f (simulation FPS %.2f) - duration %d ms\n", nb_frames_drawn, ((Float)nb_frames_drawn*1000)/tot_time,(Float) FPS, gf_term_get_time_in_ms(term) ); } - } + } if (print_codecs) { if (video_odm) { fprintf(stderr, "%s %dx%d sar=%d:%d duration %.2fs\n", v_odi.codec_name, v_odi.width, v_odi.height, v_odi.par ? (v_odi.par>>16)&0xFF : 1, v_odi.par ? (v_odi.par)&0xFF : 1, v_odi.duration); @@ -2015,14 +2150,14 @@ void PrintAVInfo(Bool final) fprintf(stderr, " (Error during bench: %d frames drop)", a_odi.nb_droped); } fprintf(stderr, "\n"); - } + } } if (scene_odm) { u32 w, h; gf_term_get_visual_output_size(term, &w, &h); fprintf(stderr, "%s scene size %dx%d rastered to %dx%d duration %.2fs\n", s_odi.codec_name, s_odi.width, s_odi.height, w, h, s_odi.duration); if (final) { - if (s_odi.nb_dec_frames>2 && s_odi.total_dec_time) { + if (s_odi.nb_dec_frames>2 && s_odi.total_dec_time) { u32 dec_run_time = s_odi.last_frame_time - s_odi.first_frame_time; if (!dec_run_time) dec_run_time = 1; fprintf(stderr, "%d frames FPS %.2f (max "LLD" us/f) rate avg %d max %d", s_odi.nb_dec_frames, ((Float)s_odi.nb_dec_frames*1000) / dec_run_time, s_odi.max_dec_time, (u32) s_odi.avg_bitrate/1000, (u32) s_odi.max_bitrate/1000); @@ -2051,9 +2186,9 @@ void PrintAVInfo(Bool final) else if (scene_odm) { avg_dec_time = 0; - if (s_odi.nb_dec_frames>2 && s_odi.total_dec_time) { - avg_dec_time = (Float) 1000000 * s_odi.nb_dec_frames; - avg_dec_time /= s_odi.total_dec_time; + if (s_odi.nb_dec_frames>2 && s_odi.total_dec_time) { + avg_dec_time = (Float) 1000000 * s_odi.nb_dec_frames; + avg_dec_time /= s_odi.total_dec_time; if (s_odi.duration) fprintf(stderr, "%d%% ", (u32) (100*s_odi.current_time / s_odi.duration ) ); fprintf(stderr, "%d f %.2f ("LLU" us max) - rate %d ", s_odi.nb_dec_frames, avg_dec_time, s_odi.max_dec_time, (u32) s_odi.instant_bitrate/1000); } else { @@ -2064,6 +2199,15 @@ void PrintAVInfo(Bool final) fprintf(stderr, "%d f FPS %.2f (abs %.2f) ", nb_frames_drawn, (1000.0*nb_frames_drawn / tot_time), FPS); } } + else if (audio_odm) { + if (!print_codecs) { + gf_term_get_object_info(term, audio_odm, &a_odi); + } + tot_time = a_odi.last_frame_time - a_odi.first_frame_time; + if (!tot_time) tot_time=1; + if (a_odi.duration) fprintf(stderr, "%d%% ", (u32) (100*a_odi.current_time / a_odi.duration ) ); + fprintf(stderr, "%d frames (ms/f %.2f avg %.2f max)", a_odi.nb_dec_frames, ((Float)tot_time)/a_odi.nb_dec_frames, a_odi.max_dec_time/1000.0); + } } void PrintWorldInfo(GF_Terminal *term) @@ -2099,7 +2243,7 @@ void PrintODList(GF_Terminal *term, GF_ObjectManager *root_odm, u32 num, u32 ind if (!root_odm) return; count = gf_term_get_current_service_id(term); - if (count) + if (count) fprintf(stderr, "Current service ID %d\n", count); if (gf_term_get_object_info(term, root_odm, &odi) != GF_OK) return; @@ -2108,9 +2252,9 @@ void PrintODList(GF_Terminal *term, GF_ObjectManager *root_odm, u32 num, u32 ind return; } - for (i=0;iServiceID) fprintf(stderr, "Service ID %d ", odi.od->ServiceID); @@ -2168,7 +2312,7 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) odm = NULL; if ((!OD_ID && (number == (u32)(-1))) || - ((OD_ID == (u32)(-1)) && !number)) { + ((OD_ID == (u32)(-1)) && !number)) { odm = root_odm; if ((gf_term_get_object_info(term, odm, &odi) != GF_OK)) odm=NULL; } else { @@ -2190,7 +2334,7 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) } if (!odi.od) { if (number == (u32)-1) fprintf(stderr, "Object %d not attached yet\n", OD_ID); - else fprintf(stderr, "Object #%d not attached yet\n", number); + else fprintf(stderr, "Object #%d not attached yet\n", number); return; } @@ -2201,8 +2345,8 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) if (odi.od->tag==GF_ODF_IOD_TAG) { fprintf(stderr, "InitialObjectDescriptor %d\n", odi.od->objectDescriptorID); - fprintf(stderr, "Profiles and Levels: Scene %x - Graphics %x - Visual %x - Audio %x - OD %x\n", - odi.scene_pl, odi.graphics_pl, odi.visual_pl, odi.audio_pl, odi.OD_pl); + fprintf(stderr, "Profiles and Levels: Scene %x - Graphics %x - Visual %x - Audio %x - OD %x\n", + odi.scene_pl, odi.graphics_pl, odi.visual_pl, odi.audio_pl, odi.OD_pl); fprintf(stderr, "Inline Profile Flag %d\n", odi.inline_pl); } else { fprintf(stderr, "ObjectDescriptor %d\n", odi.od->objectDescriptorID); @@ -2210,16 +2354,16 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) fprintf(stderr, "Object Duration: "); if (odi.duration) { - PrintTime((u32) (odi.duration*1000)); + PrintTime((u32) (odi.duration*1000)); } else { - fprintf(stderr, "unknown"); + fprintf(stderr, "unknown"); } fprintf(stderr, "\n"); if (odi.owns_service) { fprintf(stderr, "Service Handler: %s\n", odi.service_handler); fprintf(stderr, "Service URL: %s\n", odi.service_url); - } + } if (odi.codec_name) { Float avg_dec_time; switch (odi.od_type) { @@ -2250,14 +2394,14 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) fprintf(stderr, "Text Codec %s\n", odi.codec_name); break; } - + avg_dec_time = 0; - if (odi.nb_dec_frames) { - avg_dec_time = (Float) odi.total_dec_time; - avg_dec_time /= odi.nb_dec_frames; + if (odi.nb_dec_frames) { + avg_dec_time = (Float) odi.total_dec_time; + avg_dec_time /= odi.nb_dec_frames; } - fprintf(stderr, "\tBitrate over last second: %d kbps\n\tMax bitrate over one second: %d kbps\n\tAverage Decoding Time %.2f ms ("LLU" max)\n\tTotal decoded frames %d\n", - (u32) odi.avg_bitrate/1024, odi.max_bitrate/1024, avg_dec_time, odi.max_dec_time, odi.nb_dec_frames); + fprintf(stderr, "\tBitrate over last second: %d kbps\n\tMax bitrate over one second: %d kbps\n\tAverage Decoding Time %.2f ms ("LLU" max)\n\tTotal decoded frames %d\n", + (u32) odi.avg_bitrate/1024, odi.max_bitrate/1024, avg_dec_time, odi.max_dec_time, odi.nb_dec_frames); } if (odi.protection) fprintf(stderr, "Encrypted Media%s\n", (odi.protection==2) ? " NOT UNLOCKED" : ""); @@ -2352,7 +2496,7 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) GF_Segment *sd = (GF_Segment *) desc; fprintf(stderr, "Segment Descriptor: Name: %s - start time %g sec - duration %g sec\n", sd->SegmentName, sd->startTime, sd->Duration); } - break; + break; case GF_ODF_CC_NAME_TAG: { GF_CC_Name *ccn = (GF_CC_Name *)desc; @@ -2363,14 +2507,14 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) fprintf(stderr, "\t%s\n", ci->contentCreatorName); } } - break; + break; case GF_ODF_SHORT_TEXT_TAG: - { - GF_ShortTextual *std = (GF_ShortTextual *)desc; - fprintf(stderr, "Description:\n\tEvent: %s\n\t%s\n", std->eventName, std->eventText); - } - break; + { + GF_ShortTextual *std = (GF_ShortTextual *)desc; + fprintf(stderr, "Description:\n\tEvent: %s\n\t%s\n", std->eventName, std->eventText); + } + break; default: break; } @@ -2379,11 +2523,21 @@ void ViewOD(GF_Terminal *term, u32 OD_ID, u32 number) } switch (odi.status) { - case 0: fprintf(stderr, "Stopped - "); break; - case 1: fprintf(stderr, "Playing - "); break; - case 2: fprintf(stderr, "Paused - "); break; - case 3: fprintf(stderr, "Not setup yet\n"); return; - default: fprintf(stderr, "Setup Failed\n"); return; + case 0: + fprintf(stderr, "Stopped - "); + break; + case 1: + fprintf(stderr, "Playing - "); + break; + case 2: + fprintf(stderr, "Paused - "); + break; + case 3: + fprintf(stderr, "Not setup yet\n"); + return; + default: + fprintf(stderr, "Setup Failed\n"); + return; } if (odi.buffer>=0) fprintf(stderr, "Buffer: %d ms - ", odi.buffer); else fprintf(stderr, "Not buffering - "); @@ -2447,9 +2601,15 @@ void PrintODTiming(GF_Terminal *term, GF_ObjectManager *odm) fprintf(stderr, "OD %d: ", odi.od->objectDescriptorID); switch (odi.status) { - case 1: fprintf(stderr, "Playing - "); break; - case 2: fprintf(stderr, "Paused - "); break; - default: fprintf(stderr, "Stopped - "); break; + case 1: + fprintf(stderr, "Playing - "); + break; + case 2: + fprintf(stderr, "Paused - "); + break; + default: + fprintf(stderr, "Stopped - "); + break; } if (odi.buffer>=0) fprintf(stderr, "Buffer: %d ms - ", odi.buffer); else fprintf(stderr, "Not buffering - "); @@ -2473,19 +2633,28 @@ void PrintODBuffer(GF_Terminal *term, GF_ObjectManager *odm) fprintf(stderr, "OD %d: ", odi.od->objectDescriptorID); switch (odi.status) { - case 1: fprintf(stderr, "Playing"); break; - case 2: fprintf(stderr, "Paused"); break; - default: fprintf(stderr, "Stopped"); break; + case 1: + fprintf(stderr, "Playing"); + break; + case 2: + fprintf(stderr, "Paused"); + break; + default: + fprintf(stderr, "Stopped"); + break; } if (odi.buffer>=0) fprintf(stderr, " - Buffer: %d ms", odi.buffer); if (odi.db_unit_count) fprintf(stderr, " - DB: %d AU", odi.db_unit_count); if (odi.cb_max_count) fprintf(stderr, " - CB: %d/%d CUs", odi.cb_unit_count, odi.cb_max_count); - + fprintf(stderr, "\n * %d decoded frames - %d dropped frames\n", odi.nb_dec_frames, odi.nb_droped); avg_dec_time = 0; - if (odi.nb_dec_frames) { avg_dec_time = (Float) odi.total_dec_time; avg_dec_time /= odi.nb_dec_frames; } + if (odi.nb_dec_frames) { + avg_dec_time = (Float) odi.total_dec_time; + avg_dec_time /= odi.nb_dec_frames; + } fprintf(stderr, " * Avg Bitrate %d kbps (%d max) - Avg Decoding Time %.2f ms ("LLU" max)\n", - (u32) odi.avg_bitrate/1024, odi.max_bitrate/1024, avg_dec_time, odi.max_dec_time); + (u32) odi.avg_bitrate/1024, odi.max_bitrate/1024, avg_dec_time, odi.max_dec_time); } void ViewODs(GF_Terminal *term, Bool show_timing) @@ -2519,9 +2688,9 @@ void PrintGPACConfig() char *secName = NULL; fprintf(stderr, "Enter section name (\"*\" for complete dump):\n"); - if (1 > scanf("%s", szName)){ - fprintf(stderr, "No section name, aborting.\n"); - return; + if (1 > scanf("%s", szName)) { + fprintf(stderr, "No section name, aborting.\n"); + return; } if (strcmp(szName, "*")) secName = szName; diff --git a/applications/mp4client/resource.h b/applications/mp4client/resource.h index deb8163..0e3f382 100644 --- a/applications/mp4client/resource.h +++ b/applications/mp4client/resource.h @@ -7,7 +7,7 @@ #define IDI_ICON3 105 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 106 diff --git a/applications/testapps/bmp4demux/bmp4demux.vcxproj b/applications/testapps/bmp4demux/bmp4demux.vcxproj index 0cdd147..e570064 100644 --- a/applications/testapps/bmp4demux/bmp4demux.vcxproj +++ b/applications/testapps/bmp4demux/bmp4demux.vcxproj @@ -35,6 +35,7 @@ + @@ -61,13 +62,13 @@ Application - v100 + v110 false MultiByte Application - v100 + v110 false MultiByte diff --git a/applications/testapps/bmp4demux/bmp4demux.vcxproj.filters b/applications/testapps/bmp4demux/bmp4demux.vcxproj.filters index 5aa4a72..3f80c02 100644 --- a/applications/testapps/bmp4demux/bmp4demux.vcxproj.filters +++ b/applications/testapps/bmp4demux/bmp4demux.vcxproj.filters @@ -119,6 +119,9 @@ others + + isoff + diff --git a/applications/testapps/bmp4demux/main.c b/applications/testapps/bmp4demux/main.c index fc3efeb..cbe7cac 100644 --- a/applications/testapps/bmp4demux/main.c +++ b/applications/testapps/bmp4demux/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -73,7 +73,7 @@ int main(int argc, char **argv) if (iso_sample) { fprintf(stdout, "Found sample #%5d/%5d of length %8d, RAP: %d, DTS: "LLD", CTS: "LLD"\n", sample_index, sample_count, iso_sample->dataLength, iso_sample->IsRAP, iso_sample->DTS, iso_sample->DTS+iso_sample->CTS_Offset); sample_index++; - + /*release the sample data, once you're done with it*/ gf_isom_sample_del(&iso_sample); } else { diff --git a/applications/testapps/broadcaster/RTP_serv_generator.c b/applications/testapps/broadcaster/RTP_serv_generator.c index a10292f..027aa3a 100644 --- a/applications/testapps/broadcaster/RTP_serv_generator.c +++ b/applications/testapps/broadcaster/RTP_serv_generator.c @@ -10,14 +10,14 @@ GF_Err SampleCallBack(void *calling_object, u16 ESID, char *au, u32 size, u64 ts { PNC_CallbackData *data = (PNC_CallbackData *)calling_object; /* call the packetizer to create RTP packets */ - PNC_ProcessData(data, au, size, ts); + PNC_ProcessData(data, au, size, ts); return GF_OK; } GF_Err (*MySampleCallBack)(void *, u16, char *data, u32 size, u64 ts) = &SampleCallBack; PNC_CallbackData *PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p_hdr, char *default_scene, - u32 socketType, u16 socketPort, int debug) + u32 socketType, u16 socketPort, int debug) { GF_Err e; PNC_CallbackData *data = gf_malloc(sizeof(PNC_CallbackData)); @@ -36,7 +36,7 @@ PNC_CallbackData *PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p } data->server_socket = NULL; data->socket = NULL; - + if (socketType == GF_SOCK_TYPE_TCP) { data->server_socket = gf_sk_new(socketType); @@ -62,7 +62,7 @@ PNC_CallbackData *PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p u32 socket_type = 0; e |= gf_sk_get_local_ip(data->socket, buffIp); e |= gf_sk_get_local_info(data->socket, &port, &socket_type); - dprintf(DEBUG_RTP_serv_generator, "RTS_serv_generator %s:%d %s\n", + dprintf(DEBUG_RTP_serv_generator, "RTS_serv_generator %s:%d %s\n", buffIp, port, socket_type==GF_SOCK_TYPE_UDP?"UDP":"TCP", e==GF_OK?"OK":"ERROR"); */ if (e) { @@ -83,7 +83,7 @@ PNC_CallbackData *PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p void PNC_SendInitScene(PNC_CallbackData * data) { - data->RAP = 1; + data->RAP = 1; data->SAUN_inc = 1; gf_seng_encode_context(data->codec, MySampleCallBack); } @@ -107,13 +107,13 @@ static int findCommand(const char * buffer, int searchFrom) assert( buffer ); assert( searchFrom >= 0); /** We may have received #RTP_STREAM_ directive before the last update */ - if (searchFrom < 30){ + if (searchFrom < 30) { searchFrom = 0; } else { searchFrom-= 30; } sstr = strstr(&(buffer[searchFrom]), "#_RTP_STREAM_"); - if (sstr){ + if (sstr) { return (sstr - buffer); } return -1; @@ -138,7 +138,7 @@ static GF_Err processRapReset(PNC_CallbackData * data, char * bsBuffer) GF_Err error; dprintf(DEBUG_RTP_serv_generator, "RTP STREAM RAP RESET\n"); gf_mx_p(data->carrousel_mutex); - data->RAP = 1; + data->RAP = 1; data->RAPsent++; data->SAUN_inc = 1; error = gf_seng_aggregate_context(data->codec, 0); @@ -218,7 +218,7 @@ GF_Err PNC_processBIFSGenerator(PNC_CallbackData * data) { data->socket = NULL; e = gf_sk_accept(data->server_socket, &(data->socket)); - if (e){ + if (e) { return GF_OK; } else { dprintf(DEBUG_RTP_serv_generator, "New TCP client connected !\n"); @@ -231,53 +231,53 @@ GF_Err PNC_processBIFSGenerator(PNC_CallbackData * data) return GF_OK; e = gf_sk_receive(data->socket, tmpBuffer, tmpBufferSize, 0, & byteRead); switch (e) { - case GF_IP_NETWORK_EMPTY: - e = GF_OK; - break; - case GF_OK: - if (byteRead > 0){ - dprintf(DEBUG_RTP_serv_generator, "Received %d bytes\n", byteRead); - /* We copy data in buffer */ - memcpy( &(data->buffer[data->bufferPosition]), tmpBuffer, byteRead ); - data->buffer[data->bufferPosition + byteRead] = '\0'; - retour = findCommand( data->buffer, data->bufferPosition); - data->bufferPosition += byteRead; - if (retour >= 0){ - /** OK, it means we found a command ! */ - if (strncmp(&(data->buffer[retour+13]), - "SEND_CRITICAL", 13)==0){ - bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 26, RECV_BUFFER_SIZE_FOR_COMMANDS); - data->bufferPosition = 0; - return processSendCritical(data, bsBuffer); - } - if (strncmp(&(data->buffer[retour+13]), "SEND", 4)==0){ - bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 17, RECV_BUFFER_SIZE_FOR_COMMANDS); - data->bufferPosition = 0; - return processSend(data, bsBuffer); - } - if (strncmp(&(data->buffer[retour+13]), "RAP", 3)==0){ - bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 16, RECV_BUFFER_SIZE_FOR_COMMANDS); - data->bufferPosition = 0; - return processRap(data, bsBuffer); - } - if (strncmp(&(data->buffer[retour+13]), "RAP_RESET", 9)==0){ - bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 22, RECV_BUFFER_SIZE_FOR_COMMANDS); - data->bufferPosition = 0; - return processRapReset(data, bsBuffer); - } - /** If we are here, it means probably we did not received fully the command */ - break; + case GF_IP_NETWORK_EMPTY: + e = GF_OK; + break; + case GF_OK: + if (byteRead > 0) { + dprintf(DEBUG_RTP_serv_generator, "Received %d bytes\n", byteRead); + /* We copy data in buffer */ + memcpy( &(data->buffer[data->bufferPosition]), tmpBuffer, byteRead ); + data->buffer[data->bufferPosition + byteRead] = '\0'; + retour = findCommand( data->buffer, data->bufferPosition); + data->bufferPosition += byteRead; + if (retour >= 0) { + /** OK, it means we found a command ! */ + if (strncmp(&(data->buffer[retour+13]), + "SEND_CRITICAL", 13)==0) { + bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 26, RECV_BUFFER_SIZE_FOR_COMMANDS); + data->bufferPosition = 0; + return processSendCritical(data, bsBuffer); } + if (strncmp(&(data->buffer[retour+13]), "SEND", 4)==0) { + bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 17, RECV_BUFFER_SIZE_FOR_COMMANDS); + data->bufferPosition = 0; + return processSend(data, bsBuffer); + } + if (strncmp(&(data->buffer[retour+13]), "RAP", 3)==0) { + bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 16, RECV_BUFFER_SIZE_FOR_COMMANDS); + data->bufferPosition = 0; + return processRap(data, bsBuffer); + } + if (strncmp(&(data->buffer[retour+13]), "RAP_RESET", 9)==0) { + bsBuffer = eat_buffer_to_bs( data->buffer, retour, retour + 22, RECV_BUFFER_SIZE_FOR_COMMANDS); + data->bufferPosition = 0; + return processRapReset(data, bsBuffer); + } + /** If we are here, it means probably we did not received fully the command */ + break; } - /* No bytes were received */ - break; - default: - fprintf(stderr, "Socket error while receiving BIFS data %s\n", gf_error_to_string(e)); - if (data->socket != NULL){ - gf_sk_del(data->socket); - data->socket = NULL; - } - return e; + } + /* No bytes were received */ + break; + default: + fprintf(stderr, "Socket error while receiving BIFS data %s\n", gf_error_to_string(e)); + if (data->socket != NULL) { + gf_sk_del(data->socket); + data->socket = NULL; + } + return e; } } while (e == GF_OK); diff --git a/applications/testapps/broadcaster/RTP_serv_generator.h b/applications/testapps/broadcaster/RTP_serv_generator.h index 42dd43f..7a99a79 100644 --- a/applications/testapps/broadcaster/RTP_serv_generator.h +++ b/applications/testapps/broadcaster/RTP_serv_generator.h @@ -25,7 +25,7 @@ typedef struct tmp_PNC_CallbackData { GF_Socket *socket; GF_Socket *server_socket; /* socket on which bitrate feedback is sent */ - GF_Socket *feedback_socket; + GF_Socket *feedback_socket; void *extension; @@ -34,7 +34,7 @@ typedef struct tmp_PNC_CallbackData { /* RAP counter */ int RAPsent; /* indication that the Access Unit Sequence Number should be increased */ - int SAUN_inc; + int SAUN_inc; GF_Mutex *carrousel_mutex; char buffer[RECV_BUFFER_SIZE_FOR_COMMANDS]; @@ -54,8 +54,8 @@ typedef struct tmp_PNC_CallbackExt { /*exports*/ extern GF_Err PNC_RAP(PNC_CallbackData *data); -extern PNC_CallbackData* PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p_hdr, char *default_scene, - u32 socketType, u16 socketPort, int debug); +extern PNC_CallbackData* PNC_Init_SceneGenerator(GF_RTPChannel *p_chan, GF_RTPHeader *p_hdr, char *default_scene, + u32 socketType, u16 socketPort, int debug); extern GF_Err PNC_processBIFSGenerator(PNC_CallbackData*); extern void PNC_Close_SceneGenerator(PNC_CallbackData*); diff --git a/applications/testapps/broadcaster/RTP_serv_packetizer.c b/applications/testapps/broadcaster/RTP_serv_packetizer.c index 1e7f84b..6021644 100644 --- a/applications/testapps/broadcaster/RTP_serv_packetizer.c +++ b/applications/testapps/broadcaster/RTP_serv_packetizer.c @@ -13,7 +13,7 @@ void OnNewPacket(void *cbk, GF_RTPHeader *header) { - ((PNC_CallbackData *)cbk)->formatedPacketLength = 0; + ((PNC_CallbackData *)cbk)->formatedPacketLength = 0; } void OnPacketDone(void *cbk, GF_RTPHeader *header) @@ -21,7 +21,7 @@ void OnPacketDone(void *cbk, GF_RTPHeader *header) PNC_CallbackData *data = (PNC_CallbackData *)cbk; dprintf(DEBUG_RTP_serv_packetizer, "RTP Packet done\n"); PNC_SendRTP(data, ((PNC_CallbackData *)cbk)->formatedPacket, ((PNC_CallbackData *)cbk)->formatedPacketLength); - ((PNC_CallbackData *)cbk)->formatedPacketLength = 0; + ((PNC_CallbackData *)cbk)->formatedPacketLength = 0; } void OnData(void *cbk, char *data, u32 data_size, Bool is_head) @@ -38,16 +38,16 @@ void PNC_InitPacketiser(PNC_CallbackData * data, char *sdp_fmt, unsigned short m sl.useTimestampsFlag = 1; sl.useRandomAccessPointFlag = 1; sl.timestampResolution = 1000; - sl.AUSeqNumLength = 16; + sl.AUSeqNumLength = 16; p = gf_rtp_builder_new(GF_RTP_PAYT_MPEG4, - &sl, - GP_RTP_PCK_SIGNAL_RAP | GP_RTP_PCK_SIGNAL_AU_IDX, - data, - OnNewPacket, - OnPacketDone, - NULL, - OnData); + &sl, + GP_RTP_PCK_SIGNAL_RAP | GP_RTP_PCK_SIGNAL_AU_IDX, + data, + OnNewPacket, + OnPacketDone, + NULL, + OnData); if (!p) { fprintf(stderr, "Cannot create RTP builder \n"); return; @@ -58,7 +58,7 @@ void PNC_InitPacketiser(PNC_CallbackData * data, char *sdp_fmt, unsigned short m gf_rtp_builder_init(p, 96, mtu_size, 0, 3, 1, 1, 0, 0, 0, 0, 0, 0, NULL); gf_rtp_builder_format_sdp(p, "mpeg4-generic", sdp_fmt, NULL, 0); p->rtp_header.Version=2; - p->rtp_header.SSRC=rand(); + p->rtp_header.SSRC=rand(); data->hdr=& p->rtp_header; data->rtpBuilder=p; data->formatedPacket = gf_malloc(MAX_PACKET_SIZE); @@ -71,12 +71,12 @@ void PNC_ClosePacketizer(PNC_CallbackData *data) gf_rtp_builder_del(data->rtpBuilder); } -GF_Err PNC_ProcessData(PNC_CallbackData * data, char *au, u32 size, u64 ts) +GF_Err PNC_ProcessData(PNC_CallbackData * data, char *au, u32 size, u64 ts) { assert( data ); assert( au ); /* We need to set a TS different every time */ - data->hdr->TimeStamp = (u32) gf_sys_clock(); + data->hdr->TimeStamp = (u32) gf_sys_clock(); data->rtpBuilder->sl_header.compositionTimeStamp = (u32) gf_sys_clock(); data->rtpBuilder->sl_header.randomAccessPointFlag = data->RAP; if (data->SAUN_inc) data->rtpBuilder->sl_header.AU_sequenceNumber++; @@ -84,9 +84,9 @@ GF_Err PNC_ProcessData(PNC_CallbackData * data, char *au, u32 size, u64 ts) /* reset input data config */ data->RAP=0; data->SAUN_inc=0; - + data->rtpBuilder->sl_header.paddingBits = 0; gf_rtp_builder_process(data->rtpBuilder, au, size, 1, size, 0, 0); - + return GF_OK; } diff --git a/applications/testapps/broadcaster/RTP_serv_sender.c b/applications/testapps/broadcaster/RTP_serv_sender.c index bd379b9..7dd8ddf 100644 --- a/applications/testapps/broadcaster/RTP_serv_sender.c +++ b/applications/testapps/broadcaster/RTP_serv_sender.c @@ -13,7 +13,7 @@ GF_Err PNC_InitRTP(GF_RTPChannel **chan, char *dest, int port, unsigned short mt res = gf_rtp_set_ports(*chan, 0); if (res) { fprintf(stderr, "Cannot set RTP ports: %s\n", gf_error_to_string(res)); - gf_rtp_del(*chan); + gf_rtp_del(*chan); return res; } @@ -56,16 +56,16 @@ GF_Err PNC_InitRTP(GF_RTPChannel **chan, char *dest, int port, unsigned short mt GF_Err PNC_SendRTP(PNC_CallbackData *data, char *payload, int payloadSize) { GF_Err e; - unsigned char feedback_buffer[250]; - - if (!data->hdr->TimeStamp) + unsigned char feedback_buffer[250]; + + if (!data->hdr->TimeStamp) data->hdr->TimeStamp = ((PNC_CallbackExt * )data->extension)->lastTS; ((PNC_CallbackExt * )data->extension)->lastTS = data->hdr->TimeStamp; - + e = gf_rtp_send_packet(data->chan, data->hdr, payload, payloadSize, 0); dprintf(DEBUG_RTP_serv_sender, "SendPacket : %d, TimeStamp RTP = %d, sz= %d\n", - e, data->hdr->TimeStamp, payloadSize); + e, data->hdr->TimeStamp, payloadSize); // sending feedback bytes memset(feedback_buffer, 0, sizeof(feedback_buffer)); @@ -77,7 +77,7 @@ GF_Err PNC_SendRTP(PNC_CallbackData *data, char *payload, int payloadSize) } GF_Err PNC_CloseRTP(GF_RTPChannel *chan) -{ +{ gf_rtp_del(chan); return GF_OK; } diff --git a/applications/testapps/broadcaster/RTP_serv_sender.h b/applications/testapps/broadcaster/RTP_serv_sender.h index f564c17..99562f7 100644 --- a/applications/testapps/broadcaster/RTP_serv_sender.h +++ b/applications/testapps/broadcaster/RTP_serv_sender.h @@ -6,9 +6,9 @@ extern void test_RTP_serv_send(); -extern GF_Err PNC_InitRTP(GF_RTPChannel **chan, char *dest, int port, unsigned short mtu_size); +extern GF_Err PNC_InitRTP(GF_RTPChannel **chan, char *dest, int port, unsigned short mtu_size); extern GF_Err PNC_SendRTP(PNC_CallbackData *data, char *payload, int payloadSize); -extern GF_Err PNC_CloseRTP(GF_RTPChannel *chan); +extern GF_Err PNC_CloseRTP(GF_RTPChannel *chan); #endif diff --git a/applications/testapps/broadcaster/broadcaster.c b/applications/testapps/broadcaster/broadcaster.c index e3a00f0..58485dc 100644 --- a/applications/testapps/broadcaster/broadcaster.c +++ b/applications/testapps/broadcaster/broadcaster.c @@ -16,12 +16,12 @@ static unsigned short port_from_string(const char * port_to_parse) unsigned long int v; char * endptr = '\0'; const char * value = port_to_parse; - if (value == NULL || value[0] == '\0'){ + if (value == NULL || value[0] == '\0') { fprintf(stderr, "Value for port cannot be empty"); return 0; } v = strtoul(value, &endptr, 10); - if (*endptr != '\0' || v < 1 || v > 65535){ + if (*endptr != '\0' || v < 1 || v > 65535) { fprintf(stderr, "Value %s is not a valid port, port must be between 1 and 65535 !\n", value); return 0; } @@ -29,8 +29,8 @@ static unsigned short port_from_string(const char * port_to_parse) } static int command_line_parsing(int argc, const char** argv, unsigned short * tcp_port, - char *config_file, int *config_flag, unsigned short * mtu_size, - int * debug, u32 * socketType_for_updates) + char *config_file, int *config_flag, unsigned short * mtu_size, + int * debug, u32 * socketType_for_updates) { int counter = 1; if (argc < 2 || argc%2 != 1) { @@ -39,7 +39,7 @@ static int command_line_parsing(int argc, const char** argv, unsigned short * tc } for(counter = 1; counter < (argc - 1); counter+=2) - { + { const char * a = argv[counter]; if (!strcmp("-p", a) || !strcmp("--port", a)) { @@ -57,7 +57,7 @@ static int command_line_parsing(int argc, const char** argv, unsigned short * tc printIncompatibleOptions(); return -2; } - strcpy(config_file, argv[counter+1]); + strcpy(config_file, argv[counter+1]); (*config_flag) = 1; } else if (!strcmp("-m", a) || !strcmp("--mtu", a)) @@ -103,7 +103,7 @@ u32 RAP_send(void *par) RAP_Input *input = par; PNC_CallbackData *data = input->data; u32 *timer; - + input->status = 1; while (input->status==1) { gf_mx_p(input->carrousel_mutex); @@ -111,7 +111,7 @@ u32 RAP_send(void *par) timer = input->RAPtimer; data->RAPsent++; dprintf(DEBUG_broadcaster, "Sending RAP, will sleep for %d seconds\n", *timer); - data->RAP = 1; + data->RAP = 1; gf_seng_aggregate_context(data->codec, 0); gf_seng_encode_context(data->codec, SampleCallBack); @@ -122,7 +122,7 @@ u32 RAP_send(void *par) return GF_OK; } -GF_Err parse_config(GF_Config *gf_config_file, CONF_Data *conf, int debug) +GF_Err parse_config(GF_Config *gf_config_file, CONF_Data *conf, int debug) { conf->scene_init_file = gf_cfg_get_key(gf_config_file, MAIN_SECTION, SCENE_INIT); if (!conf->scene_init_file) { @@ -147,14 +147,14 @@ GF_Err parse_config(GF_Config *gf_config_file, CONF_Data *conf, int debug) conf->dest_ip = gf_cfg_get_key(gf_config_file, DEST_SECTION, DEST_ADDRESS); if (!conf->dest_ip) - conf->dest_ip = "127.0.0.1"; + conf->dest_ip = "127.0.0.1"; conf->dest_port = gf_cfg_get_key(gf_config_file, DEST_SECTION, PORT_OUTPUT); if (!conf->dest_port) conf->dest_port = "7000"; dprintf(DEBUG_broadcaster, "Destination: %s:%s\n", conf->dest_ip, conf->dest_port); conf->feedback_ip = gf_cfg_get_key(gf_config_file, FEEDBACK_SECTION, IP_FEEDBACK); - if (!conf->feedback_ip) conf->feedback_ip = "127.0.0.1"; + if (!conf->feedback_ip) conf->feedback_ip = "127.0.0.1"; conf->feedback_port = gf_cfg_get_key(gf_config_file, FEEDBACK_SECTION, PORT_FEEDBACK); if (!conf->feedback_port) conf->feedback_port = "5757"; dprintf(DEBUG_broadcaster, "Feedback host: %s:%s\n", conf->feedback_ip, conf->feedback_port); @@ -174,7 +174,7 @@ u32 tcp_server(void *par) GF_Socket *TCP_socket; GF_Socket *conn_socket; GF_Err e; - + int debug = input->debug; input->status = 1; @@ -183,10 +183,10 @@ u32 tcp_server(void *par) e = gf_sk_listen(TCP_socket, 1); e = gf_sk_set_block_mode(TCP_socket, 1); e = gf_sk_server_mode(TCP_socket, 0); - + while(input->status == 1) - { - memset(buffer, 0, sizeof(buffer)); + { + memset(buffer, 0, sizeof(buffer)); e = gf_sk_accept(TCP_socket, &conn_socket); if (e == GF_OK) { memset(buffer, 0, sizeof(buffer)); @@ -194,15 +194,15 @@ u32 tcp_server(void *par) } switch (e) { - case GF_IP_NETWORK_EMPTY: - gf_sleep(33); - continue; - case GF_OK: - break; - default: - fprintf(stderr, "Error with TCP socket : %s\n", gf_error_to_string(e)); - exit(1); - break; + case GF_IP_NETWORK_EMPTY: + gf_sleep(33); + continue; + case GF_OK: + break; + default: + fprintf(stderr, "Error with TCP socket : %s\n", gf_error_to_string(e)); + exit(1); + break; } if((*(input->config_flag)) == 0) @@ -215,7 +215,7 @@ u32 tcp_server(void *par) } ret = gf_fwrite(buffer, 1, byte_read, fp); fclose(fp); - + /* parsing config info */ gf_config_file = gf_cfg_new(".", "temp.cfg"); if (!gf_config_file) { @@ -224,7 +224,7 @@ u32 tcp_server(void *par) } parse_config(gf_config_file, input->config, debug); - /* Acknowledging the configuration */ + /* Acknowledging the configuration */ gf_sk_send(conn_socket, "OK\n", 3); memset(temp, 0, sizeof(temp)); @@ -256,7 +256,7 @@ u32 tcp_server(void *par) } /* we only wait now for the config updates */ if ( (*(input->config_flag)) == 1) { - ret = sscanf(buffer, "DelaiMax=%d\n", timer); + ret = sscanf(buffer, "DelaiMax=%d\n", timer); fprintf(stdout, "RAP timer changed, now : %d\n", *timer); } gf_sk_del(conn_socket); @@ -265,7 +265,7 @@ u32 tcp_server(void *par) input->status = 2; return GF_OK; } - + u8 get_a_char(); Bool has_input(); @@ -275,7 +275,7 @@ int main (const int argc, const char** argv) Bool run; /* location of the configuration file: 0 wait for config on a socket, 1 use the given file */ - u32 config_flag; + u32 config_flag; char config_file_name[MAX_BUF]; int dest_port; @@ -291,30 +291,30 @@ int main (const int argc, const char** argv) RAP_Input *rap_conf; GF_Thread *rap_thread; - CONF_Data *conf; + CONF_Data *conf; GF_Config *gf_config_file; GF_Err res; - + GF_Socket *UDP_feedback_socket; u32 socketType_for_updates; - + PNC_CallbackData * data; GF_RTPChannel * chan; GF_RTPHeader hdr; u32 timer = -1; - - GF_Mutex *carrousel_mutex; + + GF_Mutex *carrousel_mutex; char sdp_fmt[5000]; tcp_thread = NULL; - + /* init gpac lib */ gf_sys_init(); - + GF_SAFEALLOC(conf, CONF_Data); - + tcp_port = config_flag = 0; socketType_for_updates = GF_SOCK_TYPE_UDP; - if (command_line_parsing(argc, argv, &tcp_port, config_file_name, (int *) &config_flag, &mtu_size, &debug, &socketType_for_updates)){ + if (command_line_parsing(argc, argv, &tcp_port, config_file_name, (int *) &config_flag, &mtu_size, &debug, &socketType_for_updates)) { print_usage(); return -1; } @@ -325,7 +325,7 @@ int main (const int argc, const char** argv) char *cfg_path; char *cfg_fname; char *tmp; - + cfg_fname = config_file_name; cfg_path = config_file_name; tmp = strrchr(cfg_fname, GF_PATH_SEPARATOR); @@ -335,7 +335,7 @@ int main (const int argc, const char** argv) } else { cfg_path = "."; } - gf_config_file = gf_cfg_new(cfg_path, cfg_fname); + gf_config_file = gf_cfg_new(cfg_path, cfg_fname); if (!gf_config_file) { fprintf(stderr, "Cannot open config file %s\n", config_file_name); return -1; @@ -356,33 +356,33 @@ int main (const int argc, const char** argv) /* Starting the thread which will write the received config in a temporary file */ th_err_tcp = gf_th_run(tcp_thread, tcp_server, tcp_conf); - + fprintf(stdout, "Waiting for configuration on port %d...\n", tcp_conf->port); - while(config_flag == 0) { - gf_sleep(1000); + while(config_flag == 0) { + gf_sleep(1000); } fprintf(stdout, "Configuration File received. Starting Streaming ...\n"); } - + timer = atoi(conf->rap_timer); dest_port = atoi(conf->dest_port); res = PNC_InitRTP(&chan, (char *)conf->dest_ip, dest_port, mtu_size); - if (res != 0) { - fprintf(stderr, "Cannot initialize RTP output (error: %d)\n", res); + if (res != 0) { + fprintf(stderr, "Cannot initialize RTP output (error: %d)\n", res); exit(1); - } + } carrousel_mutex = gf_mx_new("Carrousel"); data = PNC_Init_SceneGenerator(chan, &hdr, (char *) conf->scene_init_file, - socketType_for_updates, (u16) atoi(conf->modif_input_port), debug); + socketType_for_updates, (u16) atoi(conf->modif_input_port), debug); if (!data) { - fprintf(stderr, "Cannot initialize Scene Generator\n"); + fprintf(stderr, "Cannot initialize Scene Generator\n"); exit(1); } data->carrousel_mutex = carrousel_mutex; data->RAPsent = 1; - + UDP_feedback_socket = gf_sk_new(GF_SOCK_TYPE_UDP); e = gf_sk_bind(UDP_feedback_socket, NULL, (u16)atoi(conf->feedback_port), (char*)conf->feedback_ip, (u16)atoi(conf->feedback_port), 0); if (e) { @@ -395,7 +395,7 @@ int main (const int argc, const char** argv) } data->feedback_socket = UDP_feedback_socket; - PNC_InitPacketiser(data, sdp_fmt, mtu_size); + PNC_InitPacketiser(data, sdp_fmt, mtu_size); PNC_SendInitScene(data); GF_SAFEALLOC(rap_conf, RAP_Input); @@ -406,11 +406,11 @@ int main (const int argc, const char** argv) th_err_rap = gf_th_run(rap_thread, RAP_send, rap_conf); sdp_generator(data, (char *)conf->dest_ip, sdp_fmt); - + run = 1; while (run) { - GF_Err e = PNC_processBIFSGenerator(data); + GF_Err e = PNC_processBIFSGenerator(data); if (e) { fprintf(stderr, "Cannot Process BIFS data (%s)\n", gf_error_to_string(e)); break; @@ -444,9 +444,9 @@ int main (const int argc, const char** argv) } PNC_Close_SceneGenerator(data); - + gf_free(conf); - + if (gf_config_file) gf_cfg_del(gf_config_file); @@ -466,7 +466,7 @@ u8 get_a_char() { return getchar(); } -void set_echo_off(Bool echo_off) +void set_echo_off(Bool echo_off) { DWORD flags; HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -499,8 +499,8 @@ void close_keyboard(Bool new_line) if (new_line) fprintf(stdout, "\n"); } -void set_echo_off(Bool echo_off) -{ +void set_echo_off(Bool echo_off) +{ init_keyboard(); if (echo_off) t_orig.c_lflag &= ~ECHO; else t_orig.c_lflag |= ECHO; diff --git a/applications/testapps/broadcaster/broadcaster.h b/applications/testapps/broadcaster/broadcaster.h index 8bb17d4..fbcb0d7 100644 --- a/applications/testapps/broadcaster/broadcaster.h +++ b/applications/testapps/broadcaster/broadcaster.h @@ -77,7 +77,7 @@ typedef struct rap_input PNC_CallbackData *data; u32 status; } RAP_Input; - + /*void command_line_parsing(int* argc, const char** argv, int *tcp_port, const char *config_file, int *config_flag); int server_command_line(char *arg_a, char *arg_b, char *value, int argument);*/ u32 tcp_server(void *par); diff --git a/applications/testapps/broadcaster/sdp_generator.c b/applications/testapps/broadcaster/sdp_generator.c index 02a1b6b..63b00df 100644 --- a/applications/testapps/broadcaster/sdp_generator.c +++ b/applications/testapps/broadcaster/sdp_generator.c @@ -13,7 +13,7 @@ int sdp_generator(PNC_CallbackData *data, char *ip_dest, char *sdp_fmt) char temp[5000]; u16 port; u32 socket_type; - + gf_sk_get_local_info(data->chan->rtp, &port, &socket_type); fp = fopen("broadcaster.sdp", "w+"); @@ -27,19 +27,19 @@ int sdp_generator(PNC_CallbackData *data, char *ip_dest, char *sdp_fmt) ret = gf_fwrite(temp, 1, strlen(temp), fp); ret = gf_fwrite("s=MPEG4Broadcaster\n", 1, 19, fp); - + sprintf(temp, "c=IN IP%d %s\n", gf_net_is_ipv6(ip_dest) ? 6 : 4, ip_dest); ret = gf_fwrite(temp, 1, strlen(temp), fp); - + ret = gf_fwrite("t=0 0\n", 1, 6, fp); - + codec = (GF_SceneEngine *) data->codec; if (codec) { buffer = NULL; size = 0; gf_odf_desc_write((GF_Descriptor *) codec->ctx->root_od, &buffer, &size); esd = gf_list_get(codec->ctx->root_od->ESDescriptors, 0); - + size64 = gf_base64_encode((unsigned char *) buffer, size, (unsigned char *) buf64, 2000); buf64[size64] = 0; free(buffer); @@ -47,17 +47,17 @@ int sdp_generator(PNC_CallbackData *data, char *ip_dest, char *sdp_fmt) sprintf(temp, "a=mpeg4-iod:\"data:application/mpeg4-iod;base64,%s\"\n", buf64); ret = gf_fwrite(temp, 1, strlen(temp), fp); } - + sprintf(temp, "m=application %d RTP/AVP 96\n", port); ret = gf_fwrite(temp, 1, strlen(temp), fp); - + ret = gf_fwrite("a=rtpmap:96 mpeg4-generic/1000\n", 1, 31, fp); if (esd) { sprintf(temp, "a=mpeg4-esid:%d\n", esd->ESID); ret = gf_fwrite(temp, 1, strlen(temp), fp); } - + sprintf(temp, "%s\n", sdp_fmt); ret = gf_fwrite(temp, 1, strlen(temp), fp); fflush(fp); diff --git a/applications/testapps/broadcaster/sdp_generator.h b/applications/testapps/broadcaster/sdp_generator.h index 7742591..9e5d155 100644 --- a/applications/testapps/broadcaster/sdp_generator.h +++ b/applications/testapps/broadcaster/sdp_generator.h @@ -15,10 +15,10 @@ struct __tag_bifs_engine GF_SceneLoader load; void *calling_object; GF_StreamContext *sc; - + GF_BifsEncoder *bifsenc; u32 stream_ts_res; - /* TODO: maybe the currentAUCount should be a GF_List of u32 + /* TODO: maybe the currentAUCount should be a GF_List of u32 to capture the number of AU per input BIFS stream */ u32 currentAUCount; diff --git a/applications/testapps/dmbrs/main.c b/applications/testapps/dmbrs/main.c index 7a95d5f..6cecfef 100644 --- a/applications/testapps/dmbrs/main.c +++ b/applications/testapps/dmbrs/main.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -72,7 +72,7 @@ void RS_Interleaver(GF_BitStream *bs, char *out_name) k = 11; bs_data = gf_bs_available(bs); - while (bs_data > 188 || k > 0){ + while (bs_data > 188 || k > 0) { gf_bs_read_data(bs, ts[11], 188); if (bs_data == 0) { @@ -81,11 +81,11 @@ void RS_Interleaver(GF_BitStream *bs, char *out_name) k--; } bs_data = gf_bs_available(bs); - - for (i=0; i<(17*12); i+=12){ // 1 paquet RS - + + for (i=0; i<(17*12); i+=12) { // 1 paquet RS + rs[i] = ts[11][i]; - if (rs[0] != 0x47){ + if (rs[0] != 0x47) { printf ("error ts sync byte"); } rs[i+1] = ts[10][i+1]; @@ -100,10 +100,10 @@ void RS_Interleaver(GF_BitStream *bs, char *out_name) rs[i+10] = ts[1][i+10]; rs[i+11] = ts[0][i+11]; } - + if (rs[0] != 0x47) { printf("error in output TS\n"); - }else{ + } else { save_rs_0(out_name, rs); } @@ -147,17 +147,17 @@ void RS_Deinterleaver(GF_BitStream *bs, char *out_name) memset(rs[11], 0, 204); bs_data = gf_bs_available(bs); - while (bs_data > 204){ + while (bs_data > 204) { u64 pos; k++; // printf("TS Packet Number: %d\r", k); - + pos = gf_bs_get_position(bs); gf_bs_read_data(bs, buf, 204); bs_data = gf_bs_available(bs); - while ((buf[0] != 0x47) && (bs_data > 0)) { - printf("error in input TS %d\n", k); + while ((buf[0] != 0x47) && (bs_data > 0)) { + printf("error in input TS %d\n", k); //return; pos++; gf_bs_seek(bs, pos); @@ -165,8 +165,8 @@ void RS_Deinterleaver(GF_BitStream *bs, char *out_name) bs_data = gf_bs_available(bs); } - for (i=0; i<(17*12); i+=12){ // 1 paquet - rs[0][i] = buf[i]; + for (i=0; i<(17*12); i+=12) { // 1 paquet + rs[0][i] = buf[i]; rs[1][i+1] = buf[i+1]; rs[2][i+2] = buf[i+2]; rs[3][i+3] = buf[i+3]; @@ -179,10 +179,10 @@ void RS_Deinterleaver(GF_BitStream *bs, char *out_name) rs[10][i+10] = buf[i+10]; rs[11][i+11] = buf[i+11]; } - if (k >= 12){ + if (k >= 12) { if (rs[11][0] != 0x47) { printf("error in output TS\n"); - }else{ + } else { save_ts(out_name, rs[11]); } } @@ -208,39 +208,39 @@ void main(int argc, char **argv) GF_BitStream *bs; /* generation d'un TS aléatoire */ -/* - if ((in=fopen(argv[1], "wb")) == NULL) { - printf( "Impossible d'ouvrir %s en lecture.\n", argv[1]); - } - { - char buffer[188]; - u32 j, i, nb_packets = 300; - for (i = 0; i < nb_packets; i++) { - buffer[0] = 0x47; - for (j = 1; j <188; j++) { - buffer[j] = rand();//j; + /* + if ((in=fopen(argv[1], "wb")) == NULL) { + printf( "Impossible d'ouvrir %s en lecture.\n", argv[1]); + } + { + char buffer[188]; + u32 j, i, nb_packets = 300; + for (i = 0; i < nb_packets; i++) { + buffer[0] = 0x47; + for (j = 1; j <188; j++) { + buffer[j] = rand();//j; + } + gf_fwrite(buffer, 1, 188, in); } - gf_fwrite(buffer, 1, 188, in); - } - } - fclose(in); - if ((in=fopen(argv[1], "rb")) == NULL) { - printf( "Impossible d'ouvrir %s en lecture.\n", argv[1]); - } - - bs = gf_bs_from_file(in, GF_BITSTREAM_READ); - if (bs == NULL) return; + } + fclose(in); + if ((in=fopen(argv[1], "rb")) == NULL) { + printf( "Impossible d'ouvrir %s en lecture.\n", argv[1]); + } - RS_Interleaver(bs, argv[2]); - fclose(in); - gf_bs_del(bs); -*/ + bs = gf_bs_from_file(in, GF_BITSTREAM_READ); + if (bs == NULL) return; + + RS_Interleaver(bs, argv[2]); + fclose(in); + gf_bs_del(bs); + */ if ((in=fopen(argv[1], "rb")) == NULL) { printf( "Impossible d'ouvrir %s en lecture.\n", argv[1]); } - + bs = gf_bs_from_file(in, GF_BITSTREAM_READ); if (bs == NULL) return; diff --git a/applications/testapps/fmp4demux/fmp4demux.vcxproj b/applications/testapps/fmp4demux/fmp4demux.vcxproj index 2593ef0..371d252 100644 --- a/applications/testapps/fmp4demux/fmp4demux.vcxproj +++ b/applications/testapps/fmp4demux/fmp4demux.vcxproj @@ -35,6 +35,7 @@ + @@ -62,13 +63,13 @@ Application - v100 + v110 false MultiByte Application - v100 + v110 false MultiByte @@ -111,7 +112,7 @@ Disabled ../../../include;%(AdditionalIncludeDirectories) - GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_CORE_TOOLS;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZILB;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZLIB;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -153,7 +154,7 @@ MaxSpeed OnlyExplicitInline ../../../include;%(AdditionalIncludeDirectories) - GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_CORE_TOOLS;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZILB;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZLIB;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) true MultiThreadedDLL true diff --git a/applications/testapps/fmp4demux/fmp4demux.vcxproj.filters b/applications/testapps/fmp4demux/fmp4demux.vcxproj.filters index d7e2dc7..b819529 100644 --- a/applications/testapps/fmp4demux/fmp4demux.vcxproj.filters +++ b/applications/testapps/fmp4demux/fmp4demux.vcxproj.filters @@ -122,6 +122,9 @@ others + + isoff + diff --git a/applications/testapps/fmp4demux/main.c b/applications/testapps/fmp4demux/main.c index 3135128..482684a 100644 --- a/applications/testapps/fmp4demux/main.c +++ b/applications/testapps/fmp4demux/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ //#define GPAC_HAVE_CONFIG_H @@ -86,7 +86,7 @@ static u32 iso_progressive_read_thread(void *param) /* get the track number we want */ if (track_number == 0) { track_number = gf_isom_get_track_by_id(reader->movie, reader->track_id); - } + } /* only if we have the track number can we try to get the sample data */ if (track_number != 0) { @@ -109,7 +109,7 @@ static u32 iso_progressive_read_thread(void *param) gf_mx_v(reader->mutex); //gf_sleep(1000); } else { - /* we have some samples, lets keep things stable in the parser for now and + /* we have some samples, lets keep things stable in the parser for now and don't let the data input force a reparsing of the data */ reader->refresh_boxes = GF_FALSE; @@ -119,15 +119,15 @@ static u32 iso_progressive_read_thread(void *param) /* if you want the sample description data, you can call: GF_Descriptor *desc = gf_isom_get_decoder_config(reader->movie, reader->track_handle, di); */ - + samples_processed++; /*here we dump some sample info: samp->data, samp->dataLength, samp->isRAP, samp->DTS, samp->CTS_Offset */ fprintf(stdout, "Found sample #%5d (#%5d) of length %8d, RAP: %d, DTS: "LLD", CTS: "LLD"\r", sample_index, samples_processed, iso_sample->dataLength, iso_sample->IsRAP, iso_sample->DTS, iso_sample->DTS+iso_sample->CTS_Offset); sample_index++; - + /*release the sample data, once you're done with it*/ gf_isom_sample_del(&iso_sample); - + /* once we have read all the samples, we can release some data and force a reparse of the input buffer */ if (sample_index > sample_count) { u64 new_buffer_start; @@ -144,7 +144,7 @@ static u32 iso_progressive_read_thread(void *param) u32 offset = (u32)new_buffer_start; memmove(reader->data, reader->data+offset, reader->data_size-offset); reader->valid_data_size -= offset; - } + } sprintf(reader->data_url, "gmem://%d@%p", reader->valid_data_size, reader->data); gf_isom_refresh_fragmented(reader->movie, &missing_bytes, reader->data_url); #endif @@ -237,7 +237,7 @@ int main(int argc, char **argv) while (1) { /* block the parser until we are done manipulating the data buffer */ gf_mx_p(reader.mutex); - + if (reader.valid_data_size + BUFFER_BLOC_SIZE > MAX_BUFFER_SIZE) { /* regulate the reader to limit the max buffer size and let some time to the parser to release buffer data */ fprintf(stdout, "Buffer full (%d/%d)- waiting to read next data \r", reader.valid_data_size, reader.data_size); @@ -248,7 +248,7 @@ int main(int argc, char **argv) if (reader.valid_data_size + BUFFER_BLOC_SIZE > reader.data_size) { reader.data = (u8 *)gf_realloc(reader.data, reader.data_size + BUFFER_BLOC_SIZE); reader.data_size += BUFFER_BLOC_SIZE; - } + } /* read the next bloc of data and update the data buffer url */ read_bytes = fread(reader.data+reader.valid_data_size, 1, BUFFER_BLOC_SIZE, input); @@ -279,7 +279,7 @@ int main(int argc, char **argv) fprintf(stdout, "Error opening fragmented mp4 in progressive mode: %s (missing "LLD" bytes)\n", gf_error_to_string(e), missing_bytes); ret = 1; goto exit; - } + } } else { /* let inform the parser that the buffer has been updated with new data */ e = gf_isom_refresh_fragmented(reader.movie, &missing_bytes, reader.data_url); @@ -293,7 +293,7 @@ int main(int argc, char **argv) goto exit; } } - + //gf_sleep(1); } } diff --git a/applications/testapps/hevcbench/defbench.h b/applications/testapps/hevcbench/defbench.h index 9dd8ea7..cc54aab 100644 --- a/applications/testapps/hevcbench/defbench.h +++ b/applications/testapps/hevcbench/defbench.h @@ -42,7 +42,7 @@ #define GLDECL(ret, funname, args) \ typedef ret (GLAPICAST proc_ ## funname)args; \ extern proc_ ## funname funname; \ - + #define GLDECL_STATIC(funname) proc_ ## funname funname = NULL #if defined GPAC_USE_TINYGL @@ -51,14 +51,14 @@ extern proc_ ## funname funname; \ //no extensions with OpenGL ES #elif defined(WIN32) || defined (GPAC_CONFIG_WIN32) #define LOAD_GL_FUNCS -#define GET_GLFUN(funname) funname = (proc_ ## funname) wglGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) wglGetProcAddress(#funname) #elif defined(CONFIG_DARWIN_GL) extern void (*glutGetProcAddress(const GLubyte *procname))( void ); -#define GET_GLFUN(funname) funname = (proc_ ## funname) glutGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) glutGetProcAddress(#funname) #else #define LOAD_GL_FUNCS extern void (*glXGetProcAddress(const GLubyte *procname))( void ); -#define GET_GLFUN(funname) funname = (proc_ ## funname) glXGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) glXGetProcAddress(#funname) #endif diff --git a/applications/testapps/hevcbench/main.c b/applications/testapps/hevcbench/main.c index 04491aa..96cb43d 100644 --- a/applications/testapps/hevcbench/main.c +++ b/applications/testapps/hevcbench/main.c @@ -130,15 +130,15 @@ static char *default_glsl_vertex = "\ Bool sdl_compile_shader(u32 shader_id, const char *name, const char *source) { - GLint blen = 0; + GLint blen = 0; GLsizei slen = 0; u32 len; if (!source || !shader_id) return 0; len = (u32) strlen(source); glShaderSource(shader_id, 1, &source, &len); glCompileShader(shader_id); - - glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH , &blen); + + glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH , &blen); if (blen > 1) { char* compiler_log = (char*) gf_malloc(blen); #ifdef CONFIG_DARWIN_GL @@ -180,7 +180,7 @@ void sdl_init(u32 _width, u32 _height, u32 _bpp, u32 stride, Bool use_pbo) render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); -#if (COPY_TYPE==5) +#if (COPY_TYPE==5) size = stride*height; #else size = width*height; @@ -261,7 +261,7 @@ void sdl_init(u32 _width, u32 _height, u32 _bpp, u32 stride, Bool use_pbo) glAttachShader(glsl_program, vertex_shader); glAttachShader(glsl_program, fragment_shader); - glLinkProgram(glsl_program); + glLinkProgram(glsl_program); glGenTextures(3, txid); for (i=0; i<3; i++) { @@ -277,9 +277,9 @@ void sdl_init(u32 _width, u32 _height, u32 _bpp, u32 stride, Bool use_pbo) glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - + if (bpp>8) { - glPixelStorei(GL_UNPACK_ALIGNMENT, 2); + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } @@ -287,7 +287,7 @@ void sdl_init(u32 _width, u32 _height, u32 _bpp, u32 stride, Bool use_pbo) } //sets uniforms: y, u, v textures point to texture slots 0, 1 and 2 - glUseProgram(glsl_program); + glUseProgram(glsl_program); for (i=0; i<3; i++) { const char *txname = (i==0) ? "y_plane" : (i==1) ? "u_plane" : "v_plane"; loc = glGetUniformLocation(glsl_program, txname); @@ -308,7 +308,7 @@ void sdl_init(u32 _width, u32 _height, u32 _bpp, u32 stride, Bool use_pbo) glUniform1f(loc, h); } - glUseProgram(0); + glUseProgram(0); if (glMapBuffer==NULL) use_pbo = GF_FALSE; @@ -524,10 +524,10 @@ void sdl_draw_frame(u8 *pY, u8 *pU, u8 *pV, u32 w, u32 h, u32 bit_depth, u32 str #endif glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB); -#if (COPY_TYPE!=5) +#if (COPY_TYPE!=5) needs_stride=0; #endif - + #if (NO_TEX==0) glBindTexture(texture_type, txid[0] ); @@ -587,7 +587,7 @@ void sdl_draw_frame(u8 *pY, u8 *pU, u8 *pV, u32 w, u32 h, u32 bit_depth, u32 str glActiveTexture(GL_TEXTURE0 ); glBindTexture(texture_type, txid[0]); - + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glClientActiveTexture(GL_TEXTURE0); @@ -616,26 +616,27 @@ void sdl_bench() for (i=0; idecoderConfig && esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data) { libOpenHevcCopyExtraData(ohevc, esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength+8); } - libOpenHevcStartDecoder(ohevc); + libOpenHevcStartDecoder(ohevc); gf_odf_desc_del((GF_Descriptor *)esd); gf_isom_set_sample_padding(isom, track, 8); @@ -764,7 +765,7 @@ int main(int argc, char **argv) start = gf_sys_clock(); nb_frames_at_start = i+1; } - + if (no_display) { OpenHevc_Frame HVCFrame_ptr; libOpenHevcGetOutput(ohevc, 1, &HVCFrame_ptr); @@ -786,7 +787,7 @@ int main(int argc, char **argv) gf_isom_sample_del(&sample); now = gf_sys_clock(); - fprintf(stderr, "%d %% %d frames in %d ms - FPS %02.2g - push time %d ms - draw %d ms\r", 100*(i+1-nb_frames_at_start)/count, i+1-nb_frames_at_start, now-start, 1000.0 * (i+1-nb_frames_at_start) / (now-start), gl_upload_time / gl_nb_frames , (gl_draw_time - gl_upload_time) / gl_nb_frames ); + fprintf(stderr, "%d %% %d frames in %d ms - FPS %02.2g - push time %d ms - draw %d ms\r", 100*(i+1-nb_frames_at_start)/count, i+1-nb_frames_at_start, now-start, 1000.0 * (i+1-nb_frames_at_start) / (now-start), gl_upload_time / gl_nb_frames , (gl_draw_time - gl_upload_time) / gl_nb_frames ); } else { gf_sleep(10); i--; @@ -823,14 +824,14 @@ int main(int argc, char **argv) } } now = gf_sys_clock(); - fprintf(stderr, "Decoded %d frames in %d ms - FPS %g\n", i+1, now-start, 1000.0 * (i+1) / (now-start) ); + fprintf(stderr, "Decoded %d frames in %d ms - FPS %g\n", i+1, now-start, 1000.0 * (i+1) / (now-start) ); libOpenHevcClose(ohevc); gf_isom_close(isom); - if (!no_display) + if (!no_display) sdl_close(); - + gf_sys_close(); return 1; } diff --git a/applications/testapps/largefile/main.c b/applications/testapps/largefile/main.c index 80ed26b..289d878 100644 --- a/applications/testapps/largefile/main.c +++ b/applications/testapps/largefile/main.c @@ -2,14 +2,14 @@ void PrintUsage() { - fprintf(stdout, - "Usage: largefile [options]\n" - "Option is one of:\n" - "-flat test file writing in flat mode (moov at end)\n" - "-inter test file writing in interleaved mode (moov at begin)\n" - "-size size specifies target media size in GB. Default is 5.0 GB\n" - "" - ); + fprintf(stdout, + "Usage: largefile [options]\n" + "Option is one of:\n" + "-flat test file writing in flat mode (moov at end)\n" + "-inter test file writing in interleaved mode (moov at begin)\n" + "-size size specifies target media size in GB. Default is 5.0 GB\n" + "" + ); } #define TEST_FILE_NAME "largefile.mp4" @@ -39,7 +39,7 @@ int main(int argc, char **argv) nb_samp = (u32) (gb_size*1024); fprintf(stdout, "Creating test file %s - %g GBytes - %d samples - %s mode\n", TEST_FILE_NAME, gb_size, nb_samp, (store_mode == GF_ISOM_OPEN_WRITE) ? "Flat" : "Interleaved"); - + movie = gf_isom_open(TEST_FILE_NAME, store_mode, NULL); if (!movie) { fprintf(stdout, "Error creating file: %s\n", gf_error_to_string(gf_isom_last_error(NULL))); @@ -54,8 +54,8 @@ int main(int argc, char **argv) samp = gf_isom_sample_new(); samp->dataLength = 1024*1024; samp->data = gf_malloc(sizeof(char)*samp->dataLength); - memset(samp->data, 0, sizeof(char)*samp->dataLength); - + memset(samp->data, 0, sizeof(char)*samp->dataLength); + for (i=0; iDTS % 25) samp->IsRAP = 0; else samp->IsRAP = 1; @@ -72,7 +72,7 @@ int main(int argc, char **argv) gf_isom_delete(movie); return 1; } - + fprintf(stdout, "\nDone writing samples\n"); e = gf_isom_close(movie); if (e) { diff --git a/applications/testapps/loadcompare/loadcompare.c b/applications/testapps/loadcompare/loadcompare.c index f57f2dc..828dc5b 100644 --- a/applications/testapps/loadcompare/loadcompare.c +++ b/applications/testapps/loadcompare/loadcompare.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -64,7 +64,7 @@ GF_Err load_mp4(GF_LoadCompare *lc, GF_ISOFile *mp4, u32 *loadtime) u32 nb; if (lc->spread_repeat) nb = 1; else nb = lc->nbloads ; - + *loadtime = 0; for (i = 0; i< nb; i++) { memset(&load, 0, sizeof(GF_SceneLoader)); @@ -86,7 +86,7 @@ GF_Err load_mp4(GF_LoadCompare *lc, GF_ISOFile *mp4, u32 *loadtime) *loadtime += endtime-starttime; } gf_sm_load_done(&load); - } + } gf_sm_del(load.ctx); gf_sg_del(sg); } @@ -103,7 +103,7 @@ GF_Err gpacctx_load_file(GF_LoadCompare *lc, char *item_path, u32 *loadtime) GF_SceneLoader load; GF_SceneGraph *sg; u32 i, starttime, endtime; - + u32 nb; if (lc->spread_repeat) nb = 1; else nb = lc->nbloads ; @@ -131,7 +131,7 @@ GF_Err gpacctx_load_file(GF_LoadCompare *lc, char *item_path, u32 *loadtime) *loadtime += endtime-starttime; } gf_sm_load_done(&load); - } + } gf_sm_del(load.ctx); gf_sg_del(sg); } @@ -143,7 +143,7 @@ GF_Err get_laser_track_size(GF_ISOFile *mp4, u32 *size) GF_Err e = GF_OK; u32 j; u32 track_id, trackNum; - + *size = 0; track_id = gf_isom_get_track_id(mp4, 1); trackNum = gf_isom_get_track_by_id(mp4, track_id); @@ -155,7 +155,7 @@ GF_Err get_laser_track_size(GF_ISOFile *mp4, u32 *size) return e; } -GF_Err encode_laser(GF_LoadCompare *lc, char *item_path, GF_ISOFile *mp4, GF_SMEncodeOptions *opts) +GF_Err encode_laser(GF_LoadCompare *lc, char *item_path, GF_ISOFile *mp4, GF_SMEncodeOptions *opts) { GF_Err e = GF_OK; GF_SceneLoader load; @@ -189,7 +189,7 @@ GF_Err encode_laser(GF_LoadCompare *lc, char *item_path, GF_ISOFile *mp4, GF_SME } else if (stats->int_res_2d + opts->resolution <= 0) { if (lc->verbose) fprintf(stdout, " Given resolution %d is too low, using %d instead.\n", opts->resolution, stats->int_res_2d - 1); opts->resolution = 1 - stats->int_res_2d; - } + } opts->coord_bits = stats->int_res_2d + opts->resolution; if (lc->verbose) fprintf(stdout, " Coordinates & Lengths encoded using "); if (opts->resolution < 0) { @@ -209,7 +209,7 @@ GF_Err encode_laser(GF_LoadCompare *lc, char *item_path, GF_ISOFile *mp4, GF_SME } gf_sm_stats_del(statsman); } - + e = gf_sm_encode_to_file(ctx, mp4, opts); if (e) { fprintf(stderr, "Error while encoding mp4 file\n"); @@ -219,7 +219,7 @@ GF_Err encode_laser(GF_LoadCompare *lc, char *item_path, GF_ISOFile *mp4, GF_SME } gf_sm_load_done(&load); - } + } } gf_sm_del(ctx); gf_sg_del(sg); @@ -262,7 +262,7 @@ GF_Err create_laser_mp4(GF_LoadCompare *lc, char *item_name, char *item_path, u3 e = get_laser_track_size(mp4, size); if (e) { if (lc->verbose) fprintf(stdout, "Could not get MP4 file size\n"); - } + } gf_isom_close(mp4); } } @@ -290,7 +290,7 @@ GF_Err get_mp4_loadtime(GF_LoadCompare *lc, char *item_name, char *item_path, u3 e = load_mp4(lc, mp4, loadtime); if (e) { if (lc->verbose) fprintf(stdout, "Could not get MP4 file load time\n"); - } + } } gf_isom_close(mp4); return e; @@ -322,7 +322,7 @@ GF_Err decode_svg(GF_LoadCompare *lc, char *item_name, char *item_path, char *sv e = gf_sm_load_init(&load); if (e) { fprintf(stderr, "Error loading MP4 file\n"); - } else { + } else { e = gf_sm_load_run(&load); if (e) { fprintf(stderr, "Error loading MP4 file\n"); @@ -350,7 +350,7 @@ GF_Err libxml_load_svg(GF_LoadCompare *lc, char *item_path, u32 *loadtime) GF_SceneGraph *sg; u32 i, starttime, endtime; void *p; - + u32 nb; if (lc->spread_repeat) nb = 1; else nb = lc->nbloads ; @@ -393,7 +393,7 @@ GF_Err get_size(GF_LoadCompare *lc, char *item_name, char *item_path, u32 *size) if (*size == 0) { if (lc->verbose) fprintf(stdout, "File %s has a size of 0\n", item_path); e = GF_IO_ERR; - } + } } return e; } @@ -452,7 +452,7 @@ GF_Err create_gz_file(GF_LoadCompare *lc, char *item_name, char *item_path, u32 if (*size == 0) { if (lc->verbose) fprintf(stdout, "File %s has a size of 0\n", gz_path); e = GF_IO_ERR; - } + } } return e; } @@ -573,9 +573,9 @@ Bool loadcompare_one(void *cbck, char *item_name, char *item_path) if (e) return 1; ld->track_loadtime += loadtime; -/* e = get_decoded_svg_loadtime_and_size(lc, item_name, item_path, &loadtime, &ld->decoded_size); - if (e) return 1; - ld->decoded_loadtime += loadtime;*/ + /* e = get_decoded_svg_loadtime_and_size(lc, item_name, item_path, &loadtime, &ld->decoded_size); + if (e) return 1; + ld->decoded_loadtime += loadtime;*/ } else if (lc->type == XMT) { e = gpacctx_load_file(lc, item_path, &loadtime); @@ -590,7 +590,7 @@ Bool loadcompare_one(void *cbck, char *item_name, char *item_path) return 0; } -void usage() +void usage() { fprintf(stdout, "Compare LASeR and SVG encoding size and loading time\n"); fprintf(stdout, "usage: (-out output_result) (-single input.svg | -dir dir) (-nloads X) (-verbose X)\n"); @@ -611,7 +611,7 @@ int main(int argc, char **argv) memset(&lc, 0, sizeof(GF_LoadCompare)); lc.nbloads = 1; lc.out = stdout; - + for (i = 1; i < (u32) argc ; i++) { arg = argv[i]; if (!stricmp(arg, "-out")) { @@ -641,7 +641,7 @@ int main(int argc, char **argv) } else { usage(); return -1; - } + } } gf_sys_init(); @@ -690,7 +690,7 @@ int main(int argc, char **argv) } } gf_list_del(lc.data); - + if (lc.out) fclose(lc.out); gf_sys_close(); return 0; diff --git a/applications/testapps/mpedemux/main.c b/applications/testapps/mpedemux/main.c index f8ac67c..f10076e 100644 --- a/applications/testapps/mpedemux/main.c +++ b/applications/testapps/mpedemux/main.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2007-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -60,15 +60,15 @@ static void mpedemux_on_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) /* called when an MPEG-4 SL-packet is parsed */ break; case GF_M2TS_EVT_IP_DATAGRAM: - /* called when an IP packet is parsed - TODO: send this packet on the right socket */ + /* called when an IP packet is parsed + TODO: send this packet on the right socket */ break; } } -static void usage() +static void usage() { - fprintf(stdout, "mpedemux input.ts\n"); + fprintf(stdout, "mpedemux input.ts\n"); } int main(int argc, char **argv) diff --git a/applications/testapps/mpeg2ts/main.c b/applications/testapps/mpeg2ts/main.c index 3e948a5..0d27634 100644 --- a/applications/testapps/mpeg2ts/main.c +++ b/applications/testapps/mpeg2ts/main.c @@ -4,7 +4,7 @@ u32 dump_pid = 130; FILE *dest = NULL; Bool has_seen_pat = 0; -void on_m2ts_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +void on_m2ts_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { GF_M2TS_PES_PCK *pck; switch (evt_type) { diff --git a/applications/testapps/segmp4demux/main.c b/applications/testapps/segmp4demux/main.c index 7adae49..dd220fb 100644 --- a/applications/testapps/segmp4demux/main.c +++ b/applications/testapps/segmp4demux/main.c @@ -12,15 +12,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/applications/testapps/segmp4demux/segmp4demux.vcxproj b/applications/testapps/segmp4demux/segmp4demux.vcxproj index 1470614..aba1919 100644 --- a/applications/testapps/segmp4demux/segmp4demux.vcxproj +++ b/applications/testapps/segmp4demux/segmp4demux.vcxproj @@ -35,6 +35,7 @@ + @@ -61,13 +62,13 @@ Application - v100 + v110 false MultiByte Application - v100 + v110 false MultiByte @@ -110,7 +111,7 @@ Disabled ../../../include;%(AdditionalIncludeDirectories) - GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_CORE_TOOLS;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZILB;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) + GPAC_DISABLE_MEDIA_IMPORT;GPAC_DISABLE_ISOM_HINTING;GPAC_MINIMAL_ODF;GPAC_DISABLE_AV_PARSERS;GPAC_DISABLE_ISOM_DUMP;GPAC_DISABLE_ZLIB;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL diff --git a/applications/testapps/segmp4demux/segmp4demux.vcxproj.filters b/applications/testapps/segmp4demux/segmp4demux.vcxproj.filters index 5aa4a72..3f80c02 100644 --- a/applications/testapps/segmp4demux/segmp4demux.vcxproj.filters +++ b/applications/testapps/segmp4demux/segmp4demux.vcxproj.filters @@ -119,6 +119,9 @@ others + + isoff + diff --git a/applications/testapps/svg2bifs/main.c b/applications/testapps/svg2bifs/main.c index e824368..f5a462d 100644 --- a/applications/testapps/svg2bifs/main.c +++ b/applications/testapps/svg2bifs/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,7 +31,7 @@ typedef struct { GF_SAXParser *sax_parser; - + GF_SceneGraph *svg_sg; GF_Node *svg_parent; SVGAllAttributes all_atts; @@ -79,13 +79,13 @@ static GF_Node *create_appearance(SVGPropertiesPointers *svg_props, GF_SceneGrap M_LinearGradient *lg; app = (M_Appearance *)gf_node_new(sg, TAG_MPEG4_Appearance); - + app->material = gf_node_new(sg, TAG_MPEG4_Material2D); mat = (M_Material2D *)app->material; gf_node_register((GF_Node*)mat, (GF_Node*)app); - + if (svg_props->fill->type == SVG_PAINT_NONE) { - mat->filled = 0; + mat->filled = 0; } else { mat->filled = 1; if (svg_props->fill->type == SVG_PAINT_COLOR) { @@ -110,12 +110,12 @@ static GF_Node *create_appearance(SVGPropertiesPointers *svg_props, GF_SceneGrap mat->transparency = FIX_ONE - svg_props->fill_opacity->value; - if (svg_props->stroke->type != SVG_PAINT_NONE && - svg_props->stroke_width->value != 0) { + if (svg_props->stroke->type != SVG_PAINT_NONE && + svg_props->stroke_width->value != 0) { mat->lineProps = gf_node_new(sg, TAG_MPEG4_XLineProperties); - xlp = (M_XLineProperties *)mat->lineProps; + xlp = (M_XLineProperties *)mat->lineProps; gf_node_register((GF_Node*)xlp, (GF_Node*)mat); - + xlp->width = svg_props->stroke_width->value; if (svg_props->stroke->type == SVG_PAINT_COLOR) { @@ -149,7 +149,7 @@ static GF_Node *create_appearance(SVGPropertiesPointers *svg_props, GF_SceneGrap } xlp->miterLimit = svg_props->stroke_miterlimit->value; } - + return (GF_Node*)app; } @@ -168,7 +168,7 @@ static GF_Node *add_transform_matrix(SVG2BIFS_Converter *converter, GF_Node *nod tr->myx = svg_tr->mat.m[3]; tr->myy = svg_tr->mat.m[4]; tr->ty = svg_tr->mat.m[5]; - } + } return (GF_Node *)tr; } @@ -188,15 +188,15 @@ static void svg_parse_animation(GF_SceneGraph *sg, SVG_DeferedAnimation *anim) u8 anim_value_type = 0; if (anim->resolve_stage==0) { - /* Stage 0: parsing the animation attribute values + /* Stage 0: parsing the animation attribute values for that we need to resolve the target first */ - if (!anim->target) + if (!anim->target) anim->target = (SVG_Element *) gf_sg_find_node_by_name(sg, anim->target_id + 1); if (!anim->target) { /* the target is still not known stay in stage 0 */ return; - } else { + } else { XMLRI *iri; gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_XLINK_ATT_href, 1, 0, &info); iri = (XMLRI *)info.far_ptr; @@ -254,15 +254,15 @@ static void svg_parse_animation(GF_SceneGraph *sg, SVG_DeferedAnimation *anim) if (anim->to) { gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_to, 1, 0, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->to, anim_value_type); - } + } if (anim->from) { gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_from, 1, 0, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->from, anim_value_type); - } + } if (anim->by) { gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_by, 1, 0, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->by, anim_value_type); - } + } if (anim->values) { gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_values, 1, 0, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->values, anim_value_type); @@ -288,10 +288,10 @@ static void svg2bifs_node_start(void *sax_cbck, const char *name, const char *na gf_node_register((GF_Node *)elt, NULL); gf_sg_set_root_node(converter->svg_sg, (GF_Node *)elt); } else { - gf_node_register((GF_Node *)elt, converter->svg_parent); + gf_node_register((GF_Node *)elt, converter->svg_parent); //gf_node_list_add_child(&((GF_ParentNode*)converter->svg_parent)->children, (GF_Node *)elt); } - + // fprintf(stdout, "Converting %s\n", gf_node_get_class_name((GF_Node *)elt)); // if (converter->bifs_parent) fprintf(stdout, "%s\n", gf_node_get_class_name(converter->bifs_parent)); @@ -339,7 +339,7 @@ static void svg2bifs_node_start(void *sax_cbck, const char *name, const char *na memset(&converter->all_atts, 0, sizeof(SVGAllAttributes)); gf_svg_flatten_attributes(elt, &converter->all_atts); - + backup_props = gf_malloc(sizeof(SVGPropertiesPointers)); memcpy(backup_props, &converter->svg_props, sizeof(SVGPropertiesPointers)); gf_node_set_private((GF_Node *)elt, backup_props); @@ -401,7 +401,7 @@ static void svg2bifs_node_start(void *sax_cbck, const char *name, const char *na { M_Background2D *b = (M_Background2D *)child; b->backColor.red = FIX_ONE; - b->backColor.green = FIX_ONE; + b->backColor.green = FIX_ONE; b->backColor.blue = FIX_ONE; } @@ -418,261 +418,321 @@ static void svg2bifs_node_start(void *sax_cbck, const char *name, const char *na } } else { GF_Node *node, *child; - + node = converter->bifs_parent; switch(tag) { case TAG_SVG_g: - { - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); - converter->bifs_parent = node; - } else { - M_Group *g = (M_Group*)gf_node_new(converter->bifs_sg, TAG_MPEG4_Group); - gf_node_register((GF_Node *)g, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, (GF_Node *)g); - node = (GF_Node *)g; - converter->bifs_parent = node; - } + { + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + } else { + M_Group *g = (M_Group*)gf_node_new(converter->bifs_sg, TAG_MPEG4_Group); + gf_node_register((GF_Node *)g, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, (GF_Node *)g); + node = (GF_Node *)g; + converter->bifs_parent = node; } - break; + } + break; case TAG_SVG_rect: - { - Bool is_parent_set = 0; - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); + { + Bool is_parent_set = 0; + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + is_parent_set = 1; + } + if (converter->force_transform) { + node = add_transform2d(converter, node); + if (!is_parent_set) { converter->bifs_parent = node; is_parent_set = 1; - } - if (converter->force_transform) { - node = add_transform2d(converter, node); - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } } - if (converter->all_atts.x || converter->all_atts.y) { - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } - { - M_Transform2D *tr = (M_Transform2D *)node; - if (converter->all_atts.x) tr->translation.x = converter->all_atts.x->value + (converter->all_atts.width?converter->all_atts.width->value/2:0); - if (converter->all_atts.y) tr->translation.y = converter->all_atts.y->value + (converter->all_atts.height?converter->all_atts.height->value/2:0); - } - } - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + } + if (converter->all_atts.x || converter->all_atts.y) { + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); gf_node_register(child, node); gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); node = child; child = NULL; - if (!is_parent_set) converter->bifs_parent = node; + if (!is_parent_set) { + converter->bifs_parent = node; + is_parent_set = 1; + } { - M_Shape *shape = (M_Shape *)node; - shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_Rectangle); - gf_node_register(shape->geometry, (GF_Node *)shape); - { - M_Rectangle *rect = (M_Rectangle *)shape->geometry; - if (converter->all_atts.width) rect->size.x = converter->all_atts.width->value; - if (converter->all_atts.height) rect->size.y = converter->all_atts.height->value; - } - - shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); - gf_node_register(shape->appearance, (GF_Node *)shape); + M_Transform2D *tr = (M_Transform2D *)node; + if (converter->all_atts.x) tr->translation.x = converter->all_atts.x->value + (converter->all_atts.width?converter->all_atts.width->value/2:0); + if (converter->all_atts.y) tr->translation.y = converter->all_atts.y->value + (converter->all_atts.height?converter->all_atts.height->value/2:0); } } - break; - case TAG_SVG_path: + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + if (!is_parent_set) converter->bifs_parent = node; { - Bool is_parent_set = 0; - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); + M_Shape *shape = (M_Shape *)node; + shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_Rectangle); + gf_node_register(shape->geometry, (GF_Node *)shape); + { + M_Rectangle *rect = (M_Rectangle *)shape->geometry; + if (converter->all_atts.width) rect->size.x = converter->all_atts.width->value; + if (converter->all_atts.height) rect->size.y = converter->all_atts.height->value; + } + + shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); + gf_node_register(shape->appearance, (GF_Node *)shape); + } + } + break; + case TAG_SVG_path: + { + Bool is_parent_set = 0; + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + is_parent_set = 1; + } + if (converter->force_transform) { + node = add_transform2d(converter, node); + if (!is_parent_set) { converter->bifs_parent = node; is_parent_set = 1; - } - if (converter->force_transform) { - node = add_transform2d(converter, node); - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } } - if (converter->all_atts.x || converter->all_atts.y) { - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } - { - M_Transform2D *tr = (M_Transform2D *)node; - if (converter->all_atts.x) tr->translation.x = converter->all_atts.x->value; - if (converter->all_atts.y) tr->translation.y = converter->all_atts.y->value; - } - } - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + } + if (converter->all_atts.x || converter->all_atts.y) { + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); gf_node_register(child, node); gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); node = child; child = NULL; - if (!is_parent_set) converter->bifs_parent = node; + if (!is_parent_set) { + converter->bifs_parent = node; + is_parent_set = 1; + } { - M_Shape *shape = (M_Shape *)node; - shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_XCurve2D); - gf_node_register(shape->geometry, (GF_Node *)shape); - if (converter->all_atts.d) { - M_Coordinate2D *c2d; - M_XCurve2D *xc = (M_XCurve2D *)shape->geometry; - u32 i, j, c, k; - - xc->point = gf_node_new(converter->bifs_sg, TAG_MPEG4_Coordinate2D); - c2d = (M_Coordinate2D *)xc->point; - gf_node_register(xc->point, (GF_Node *)xc); - - gf_sg_vrml_mf_alloc(&c2d->point, GF_SG_VRML_MFVEC2F, converter->all_atts.d->n_points); - gf_sg_vrml_mf_alloc(&xc->type, GF_SG_VRML_MFINT32, converter->all_atts.d->n_points); - - c = 0; - k = 0; - j = 0; - c2d->point.vals[k] = converter->all_atts.d->points[0]; - k++; - xc->type.vals[0] = 0; - for (i = 1; i < converter->all_atts.d->n_points; ) { - switch(converter->all_atts.d->tags[i]) { - case GF_PATH_CURVE_ON: - c2d->point.vals[k] = converter->all_atts.d->points[i]; - k++; - - if (i-1 == converter->all_atts.d->contours[c]) { - xc->type.vals[j] = 0; - c++; - } else { - xc->type.vals[j] = 1; - } - i++; - break; - case GF_PATH_CURVE_CUBIC: - c2d->point.vals[k] = converter->all_atts.d->points[i]; - c2d->point.vals[k+1] = converter->all_atts.d->points[i+1]; - c2d->point.vals[k+2] = converter->all_atts.d->points[i+2]; - k+=3; - - xc->type.vals[j] = 2; - if (converter->all_atts.d->tags[i+2]==GF_PATH_CLOSE) { - j++; - xc->type.vals[j] = 6; - } - i+=3; - break; - case GF_PATH_CLOSE: + M_Transform2D *tr = (M_Transform2D *)node; + if (converter->all_atts.x) tr->translation.x = converter->all_atts.x->value; + if (converter->all_atts.y) tr->translation.y = converter->all_atts.y->value; + } + } + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + if (!is_parent_set) converter->bifs_parent = node; + { + M_Shape *shape = (M_Shape *)node; + shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_XCurve2D); + gf_node_register(shape->geometry, (GF_Node *)shape); + if (converter->all_atts.d) { + M_Coordinate2D *c2d; + M_XCurve2D *xc = (M_XCurve2D *)shape->geometry; + u32 i, j, c, k; + + xc->point = gf_node_new(converter->bifs_sg, TAG_MPEG4_Coordinate2D); + c2d = (M_Coordinate2D *)xc->point; + gf_node_register(xc->point, (GF_Node *)xc); + + gf_sg_vrml_mf_alloc(&c2d->point, GF_SG_VRML_MFVEC2F, converter->all_atts.d->n_points); + gf_sg_vrml_mf_alloc(&xc->type, GF_SG_VRML_MFINT32, converter->all_atts.d->n_points); + + c = 0; + k = 0; + j = 0; + c2d->point.vals[k] = converter->all_atts.d->points[0]; + k++; + xc->type.vals[0] = 0; + for (i = 1; i < converter->all_atts.d->n_points; ) { + switch(converter->all_atts.d->tags[i]) { + case GF_PATH_CURVE_ON: + c2d->point.vals[k] = converter->all_atts.d->points[i]; + k++; + + if (i-1 == converter->all_atts.d->contours[c]) { + xc->type.vals[j] = 0; + c++; + } else { + xc->type.vals[j] = 1; + } + i++; + break; + case GF_PATH_CURVE_CUBIC: + c2d->point.vals[k] = converter->all_atts.d->points[i]; + c2d->point.vals[k+1] = converter->all_atts.d->points[i+1]; + c2d->point.vals[k+2] = converter->all_atts.d->points[i+2]; + k+=3; + + xc->type.vals[j] = 2; + if (converter->all_atts.d->tags[i+2]==GF_PATH_CLOSE) { + j++; + xc->type.vals[j] = 6; + } + i+=3; + break; + case GF_PATH_CLOSE: + xc->type.vals[j] = 6; + i++; + break; + case GF_PATH_CURVE_CONIC: + c2d->point.vals[k] = converter->all_atts.d->points[i]; + c2d->point.vals[k+1] = converter->all_atts.d->points[i+1]; + k+=2; + + xc->type.vals[j] = 7; + if (converter->all_atts.d->tags[i+1]==GF_PATH_CLOSE) { + j++; xc->type.vals[j] = 6; - i++; - break; - case GF_PATH_CURVE_CONIC: - c2d->point.vals[k] = converter->all_atts.d->points[i]; - c2d->point.vals[k+1] = converter->all_atts.d->points[i+1]; - k+=2; - - xc->type.vals[j] = 7; - if (converter->all_atts.d->tags[i+1]==GF_PATH_CLOSE) { - j++; - xc->type.vals[j] = 6; - } - i+=2; - break; } - j++; + i+=2; + break; } - xc->type.count = j; - c2d->point.count = k; - } - - shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); - gf_node_register(shape->appearance, (GF_Node *)shape); + j++; + } + xc->type.count = j; + c2d->point.count = k; } + + shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); + gf_node_register(shape->appearance, (GF_Node *)shape); } - break; + } + break; case TAG_SVG_polyline: - { - Bool is_parent_set = 0; - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); + { + Bool is_parent_set = 0; + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + is_parent_set = 1; + } + if (converter->force_transform) { + node = add_transform2d(converter, node); + if (!is_parent_set) { converter->bifs_parent = node; is_parent_set = 1; - } - if (converter->force_transform) { - node = add_transform2d(converter, node); - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } } - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - if (!is_parent_set) converter->bifs_parent = node; - { - M_Shape *shape = (M_Shape *)node; - shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_IndexedFaceSet2D); - gf_node_register(shape->geometry, (GF_Node *)shape); - if (converter->all_atts.points) { - M_Coordinate2D *c2d; - M_IndexedFaceSet2D *ifs = (M_IndexedFaceSet2D *)shape->geometry; - u32 i; - - ifs->coord = gf_node_new(converter->bifs_sg, TAG_MPEG4_Coordinate2D); - c2d = (M_Coordinate2D *)ifs->coord; - gf_node_register(ifs->coord, (GF_Node *)ifs); - - gf_sg_vrml_mf_alloc(&c2d->point, GF_SG_VRML_MFVEC2F, gf_list_count(*converter->all_atts.points)); - for (i = 0; i < gf_list_count(*converter->all_atts.points); i++) { - SVG_Point *p = (SVG_Point *)gf_list_get(*converter->all_atts.points, i); - c2d->point.vals[i].x = p->x; - c2d->point.vals[i].y = p->y; - } - } - - shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); - gf_node_register(shape->appearance, (GF_Node *)shape); + } + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + if (!is_parent_set) converter->bifs_parent = node; + { + M_Shape *shape = (M_Shape *)node; + shape->geometry = gf_node_new(converter->bifs_sg, TAG_MPEG4_IndexedFaceSet2D); + gf_node_register(shape->geometry, (GF_Node *)shape); + if (converter->all_atts.points) { + M_Coordinate2D *c2d; + M_IndexedFaceSet2D *ifs = (M_IndexedFaceSet2D *)shape->geometry; + u32 i; + + ifs->coord = gf_node_new(converter->bifs_sg, TAG_MPEG4_Coordinate2D); + c2d = (M_Coordinate2D *)ifs->coord; + gf_node_register(ifs->coord, (GF_Node *)ifs); + + gf_sg_vrml_mf_alloc(&c2d->point, GF_SG_VRML_MFVEC2F, gf_list_count(*converter->all_atts.points)); + for (i = 0; i < gf_list_count(*converter->all_atts.points); i++) { + SVG_Point *p = (SVG_Point *)gf_list_get(*converter->all_atts.points, i); + c2d->point.vals[i].x = p->x; + c2d->point.vals[i].y = p->y; + } } + + shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); + gf_node_register(shape->appearance, (GF_Node *)shape); } - break; + } + break; case TAG_SVG_text: - { - Bool is_parent_set = 0; - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); + { + Bool is_parent_set = 0; + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + is_parent_set = 1; + } + if (converter->force_transform) { + node = add_transform2d(converter, node); + if (!is_parent_set) { converter->bifs_parent = node; is_parent_set = 1; } - if (converter->force_transform) { - node = add_transform2d(converter, node); - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } - } + } + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + { + M_Transform2D *tr = (M_Transform2D *)child; + if (converter->all_atts.text_x) tr->translation.x = ((SVG_Coordinate *)gf_list_get(*converter->all_atts.text_x, 0))->value; + if (converter->all_atts.text_y) tr->translation.y = ((SVG_Coordinate *)gf_list_get(*converter->all_atts.text_y, 0))->value; + tr->scale.y = -FIX_ONE; + } + node = child; + child = NULL; + if (!is_parent_set) { + converter->bifs_parent = node; + is_parent_set = 1; + } + + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + if (!is_parent_set) converter->bifs_parent = node; + { + M_FontStyle *fs; + M_Text *text; + M_Shape *shape = (M_Shape *)node; + text = (M_Text *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Text); + shape->geometry = (GF_Node *)text; + converter->bifs_text_node = shape->geometry; + gf_node_register(shape->geometry, (GF_Node *)shape); + + fs = (M_FontStyle *)gf_node_new(converter->bifs_sg, TAG_MPEG4_XFontStyle); + gf_node_register((GF_Node *)fs, (GF_Node*)text); + text->fontStyle = (GF_Node *)fs; + + gf_sg_vrml_mf_alloc(&fs->family, GF_SG_VRML_MFSTRING, 1); + fs->family.vals[0] = gf_strdup(converter->svg_props.font_family->value); + fs->size = converter->svg_props.font_size->value; + + shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); + gf_node_register(shape->appearance, (GF_Node *)shape); + } + } + break; + case TAG_SVG_ellipse: + case TAG_SVG_circle: + { + Bool is_parent_set = 0; + if (converter->all_atts.transform) { + node = add_transform_matrix(converter, node); + converter->bifs_parent = node; + is_parent_set = 1; + } + if (converter->force_transform) { + node = add_transform2d(converter, node); + if (!is_parent_set) { + converter->bifs_parent = node; + is_parent_set = 1; + } + } + if (converter->all_atts.cx || converter->all_atts.cy) { child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); gf_node_register(child, node); gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); { M_Transform2D *tr = (M_Transform2D *)child; - if (converter->all_atts.text_x) tr->translation.x = ((SVG_Coordinate *)gf_list_get(*converter->all_atts.text_x, 0))->value; - if (converter->all_atts.text_y) tr->translation.y = ((SVG_Coordinate *)gf_list_get(*converter->all_atts.text_y, 0))->value; - tr->scale.y = -FIX_ONE; + if (converter->all_atts.cx) tr->translation.x = converter->all_atts.cx->value; + if (converter->all_atts.cy) tr->translation.y = converter->all_atts.cy->value; } node = child; child = NULL; @@ -680,295 +740,235 @@ static void svg2bifs_node_start(void *sax_cbck, const char *name, const char *na converter->bifs_parent = node; is_parent_set = 1; } - - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - if (!is_parent_set) converter->bifs_parent = node; - { - M_FontStyle *fs; - M_Text *text; - M_Shape *shape = (M_Shape *)node; - text = (M_Text *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Text); - shape->geometry = (GF_Node *)text; - converter->bifs_text_node = shape->geometry; - gf_node_register(shape->geometry, (GF_Node *)shape); - - fs = (M_FontStyle *)gf_node_new(converter->bifs_sg, TAG_MPEG4_XFontStyle); - gf_node_register((GF_Node *)fs, (GF_Node*)text); - text->fontStyle = (GF_Node *)fs; - - gf_sg_vrml_mf_alloc(&fs->family, GF_SG_VRML_MFSTRING, 1); - fs->family.vals[0] = gf_strdup(converter->svg_props.font_family->value); - fs->size = converter->svg_props.font_size->value; - - shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); - gf_node_register(shape->appearance, (GF_Node *)shape); - } } - break; - case TAG_SVG_ellipse: - case TAG_SVG_circle: + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + if (!is_parent_set) converter->bifs_parent = node; { - Bool is_parent_set = 0; - if (converter->all_atts.transform) { - node = add_transform_matrix(converter, node); - converter->bifs_parent = node; - is_parent_set = 1; - } - if (converter->force_transform) { - node = add_transform2d(converter, node); - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } - } - if (converter->all_atts.cx || converter->all_atts.cy) { - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - { - M_Transform2D *tr = (M_Transform2D *)child; - if (converter->all_atts.cx) tr->translation.x = converter->all_atts.cx->value; - if (converter->all_atts.cy) tr->translation.y = converter->all_atts.cy->value; - } - node = child; - child = NULL; - if (!is_parent_set) { - converter->bifs_parent = node; - is_parent_set = 1; - } - } - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - if (!is_parent_set) converter->bifs_parent = node; - { - M_Shape *shape = (M_Shape *)node; - if (tag == TAG_SVG_ellipse) { - M_Ellipse *e = (M_Ellipse *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Ellipse); - shape->geometry = (GF_Node *)e; - e->radius.x = converter->all_atts.rx->value; - e->radius.y = converter->all_atts.ry->value; - } else { - M_Circle *c = (M_Circle *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Circle); - shape->geometry = (GF_Node *)c; - c->radius = converter->all_atts.r->value; - } - gf_node_register(shape->geometry, (GF_Node *)shape); - - shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); - gf_node_register(shape->appearance, (GF_Node *)shape); + M_Shape *shape = (M_Shape *)node; + if (tag == TAG_SVG_ellipse) { + M_Ellipse *e = (M_Ellipse *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Ellipse); + shape->geometry = (GF_Node *)e; + e->radius.x = converter->all_atts.rx->value; + e->radius.y = converter->all_atts.ry->value; + } else { + M_Circle *c = (M_Circle *)gf_node_new(converter->bifs_sg, TAG_MPEG4_Circle); + shape->geometry = (GF_Node *)c; + c->radius = converter->all_atts.r->value; } + gf_node_register(shape->geometry, (GF_Node *)shape); + + shape->appearance = create_appearance(&converter->svg_props, converter->bifs_sg); + gf_node_register(shape->appearance, (GF_Node *)shape); } - break; + } + break; case TAG_SVG_defs: + { + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Switch); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; { - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Switch); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - { - M_Switch *sw = (M_Switch *)node; - sw->whichChoice = -1; - } - converter->bifs_parent = node; + M_Switch *sw = (M_Switch *)node; + sw->whichChoice = -1; } - break; + converter->bifs_parent = node; + } + break; case TAG_SVG_solidColor: - { - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - converter->bifs_parent = node; - } - break; + { + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Shape); + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + converter->bifs_parent = node; + } + break; case TAG_SVG_animateTransform: + { + GF_Node *child_ts; + if (!gf_node_get_id(node)) { + gf_node_set_id(node, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + } + + child_ts = gf_node_new(converter->bifs_sg, TAG_MPEG4_TimeSensor); + if (!gf_node_get_id(child_ts)) { + gf_node_set_id(child_ts, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + } + gf_node_register(child_ts, node); + gf_node_list_add_child(&((GF_ParentNode *)node)->children, child_ts); { - GF_Node *child_ts; - if (!gf_node_get_id(node)) { - gf_node_set_id(node, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + M_TimeSensor *ts = (M_TimeSensor *)child_ts; + if (converter->all_atts.dur) { + ts->cycleInterval = converter->all_atts.dur->clock_value; } - - child_ts = gf_node_new(converter->bifs_sg, TAG_MPEG4_TimeSensor); - if (!gf_node_get_id(child_ts)) { - gf_node_set_id(child_ts, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + if (converter->all_atts.repeatCount && converter->all_atts.repeatCount->type == SMIL_REPEATCOUNT_INDEFINITE) { + ts->loop = 1; } - gf_node_register(child_ts, node); - gf_node_list_add_child(&((GF_ParentNode *)node)->children, child_ts); - { - M_TimeSensor *ts = (M_TimeSensor *)child_ts; - if (converter->all_atts.dur) { - ts->cycleInterval = converter->all_atts.dur->clock_value; - } - if (converter->all_atts.repeatCount && converter->all_atts.repeatCount->type == SMIL_REPEATCOUNT_INDEFINITE) { - ts->loop = 1; + } + + if (converter->all_atts.transform_type) { + GF_FieldInfo fromField, toField; + + switch (*converter->all_atts.transform_type) { + case SVG_TRANSFORM_ROTATE: + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_PositionInterpolator2D); + if (!gf_node_get_id(child)) { + gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); } - } - - if (converter->all_atts.transform_type) { - GF_FieldInfo fromField, toField; - - switch (*converter->all_atts.transform_type) { - case SVG_TRANSFORM_ROTATE: - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_PositionInterpolator2D); - if (!gf_node_get_id(child)) { - gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); - } - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); - - gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); - gf_node_get_field_by_name(child, "set_fraction", &toField); - gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); - - gf_node_get_field_by_name(child, "value_changed", &fromField); - gf_node_get_field_by_name(node, "rotationAngle", &toField); - gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); - { - M_PositionInterpolator2D *pi2d = (M_PositionInterpolator2D *)child; - if (converter->all_atts.keyTimes) { - SFFloat *g; - u32 count, i; - count = gf_list_count(*converter->all_atts.keyTimes); - for (i = 0; i < count; i++) { - Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); - gf_sg_vrml_mf_append(&pi2d->key, GF_SG_VRML_MFFLOAT, &g); - *g = *f; - } + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); + + gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); + gf_node_get_field_by_name(child, "set_fraction", &toField); + gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); + + gf_node_get_field_by_name(child, "value_changed", &fromField); + gf_node_get_field_by_name(node, "rotationAngle", &toField); + gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); + { + M_PositionInterpolator2D *pi2d = (M_PositionInterpolator2D *)child; + if (converter->all_atts.keyTimes) { + SFFloat *g; + u32 count, i; + count = gf_list_count(*converter->all_atts.keyTimes); + for (i = 0; i < count; i++) { + Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); + gf_sg_vrml_mf_append(&pi2d->key, GF_SG_VRML_MFFLOAT, &g); + *g = *f; } - if (converter->all_atts.values) { - SFVec2f *g; - u32 count, i; - count = gf_list_count(converter->all_atts.values->values); - for (i = 0; i < count; i++) { - SVG_Point_Angle *p; - p = gf_list_get(converter->all_atts.values->values, i); - gf_sg_vrml_mf_append(&pi2d->keyValue, GF_SG_VRML_MFVEC2F, &g); - g->x = p->x; - g->y = p->y; - } + } + if (converter->all_atts.values) { + SFVec2f *g; + u32 count, i; + count = gf_list_count(converter->all_atts.values->values); + for (i = 0; i < count; i++) { + SVG_Point_Angle *p; + p = gf_list_get(converter->all_atts.values->values, i); + gf_sg_vrml_mf_append(&pi2d->keyValue, GF_SG_VRML_MFVEC2F, &g); + g->x = p->x; + g->y = p->y; } } + } - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_ScalarInterpolator); - if (!gf_node_get_id(child)) { - gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); - } - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); - - gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); - gf_node_get_field_by_name(child, "set_fraction", &toField); - gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); - - gf_node_get_field_by_name(child, "value_changed", &fromField); - gf_node_get_field_by_name(node, "center", &toField); - gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); - - { - M_ScalarInterpolator *si = (M_ScalarInterpolator *)child; - if (converter->all_atts.keyTimes) { - SFFloat *g; - u32 count, i; - count = gf_list_count(*converter->all_atts.keyTimes); - for (i = 0; i < count; i++) { - Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); - gf_sg_vrml_mf_append(&si->key, GF_SG_VRML_MFFLOAT, &g); - *g = *f; - } + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_ScalarInterpolator); + if (!gf_node_get_id(child)) { + gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + } + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); + + gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); + gf_node_get_field_by_name(child, "set_fraction", &toField); + gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); + + gf_node_get_field_by_name(child, "value_changed", &fromField); + gf_node_get_field_by_name(node, "center", &toField); + gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); + + { + M_ScalarInterpolator *si = (M_ScalarInterpolator *)child; + if (converter->all_atts.keyTimes) { + SFFloat *g; + u32 count, i; + count = gf_list_count(*converter->all_atts.keyTimes); + for (i = 0; i < count; i++) { + Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); + gf_sg_vrml_mf_append(&si->key, GF_SG_VRML_MFFLOAT, &g); + *g = *f; } - if (converter->all_atts.values) { - SFFloat *g; - u32 count, i; - count = gf_list_count(converter->all_atts.values->values); - for (i = 0; i < count; i++) { - SVG_Point_Angle *p; - p = gf_list_get(converter->all_atts.values->values, i); - gf_sg_vrml_mf_append(&si->keyValue, GF_SG_VRML_MFFLOAT, &g); - *g = p->angle; - } + } + if (converter->all_atts.values) { + SFFloat *g; + u32 count, i; + count = gf_list_count(converter->all_atts.values->values); + for (i = 0; i < count; i++) { + SVG_Point_Angle *p; + p = gf_list_get(converter->all_atts.values->values, i); + gf_sg_vrml_mf_append(&si->keyValue, GF_SG_VRML_MFFLOAT, &g); + *g = p->angle; } } + } - break; + break; - case SVG_TRANSFORM_SCALE: - case SVG_TRANSFORM_TRANSLATE: - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_PositionInterpolator2D); - if (!gf_node_get_id(child)) { - gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); - } - gf_node_register(child, node); - gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); - - gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); - gf_node_get_field_by_name(child, "set_fraction", &toField); - gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); - - gf_node_get_field_by_name(child, "value_changed", &fromField); - if (*converter->all_atts.transform_type == SVG_TRANSFORM_SCALE) - gf_node_get_field_by_name(node, "scale", &toField); - else - gf_node_get_field_by_name(node, "translation", &toField); - - gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); - { - M_PositionInterpolator2D *pi2d = (M_PositionInterpolator2D *)child; - if (converter->all_atts.keyTimes) { - SFFloat *g; - u32 count, i; - count = gf_list_count(*converter->all_atts.keyTimes); - for (i = 0; i < count; i++) { - Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); - gf_sg_vrml_mf_append(&pi2d->key, GF_SG_VRML_MFFLOAT, &g); - *g = *f; - } + case SVG_TRANSFORM_SCALE: + case SVG_TRANSFORM_TRANSLATE: + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_PositionInterpolator2D); + if (!gf_node_get_id(child)) { + gf_node_set_id(child, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL); + } + gf_node_register(child, node); + gf_node_list_add_child(&((GF_ParentNode *)node)->children, child); + + gf_node_get_field_by_name(child_ts, "fraction_changed", &fromField); + gf_node_get_field_by_name(child, "set_fraction", &toField); + gf_sg_route_new(converter->bifs_sg, child_ts, fromField.fieldIndex, child, toField.fieldIndex); + + gf_node_get_field_by_name(child, "value_changed", &fromField); + if (*converter->all_atts.transform_type == SVG_TRANSFORM_SCALE) + gf_node_get_field_by_name(node, "scale", &toField); + else + gf_node_get_field_by_name(node, "translation", &toField); + + gf_sg_route_new(converter->bifs_sg, child, fromField.fieldIndex, node, toField.fieldIndex); + { + M_PositionInterpolator2D *pi2d = (M_PositionInterpolator2D *)child; + if (converter->all_atts.keyTimes) { + SFFloat *g; + u32 count, i; + count = gf_list_count(*converter->all_atts.keyTimes); + for (i = 0; i < count; i++) { + Fixed *f = gf_list_get(*converter->all_atts.keyTimes, i); + gf_sg_vrml_mf_append(&pi2d->key, GF_SG_VRML_MFFLOAT, &g); + *g = *f; } - if (converter->all_atts.values) { - SFVec2f *g; - u32 count, i; - count = gf_list_count(converter->all_atts.values->values); - for (i = 0; i < count; i++) { - SVG_Point *p; - p = gf_list_get(converter->all_atts.values->values, i); - gf_sg_vrml_mf_append(&pi2d->keyValue, GF_SG_VRML_MFVEC2F, &g); - g->x = p->x; - g->y = p->y; - } + } + if (converter->all_atts.values) { + SFVec2f *g; + u32 count, i; + count = gf_list_count(converter->all_atts.values->values); + for (i = 0; i < count; i++) { + SVG_Point *p; + p = gf_list_get(converter->all_atts.values->values, i); + gf_sg_vrml_mf_append(&pi2d->keyValue, GF_SG_VRML_MFVEC2F, &g); + g->x = p->x; + g->y = p->y; } } - break; - default: - fprintf(stdout, "Warning: transformation type not supported \n"); } - } - //converter->bifs_parent = node; + break; + default: + fprintf(stdout, "Warning: transformation type not supported \n"); + } } - break; + //converter->bifs_parent = node; + } + break; default: - { - fprintf(stdout, "Warning: element %s not supported \n", gf_node_get_class_name((GF_Node *)elt)); - child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); - gf_node_register(child, node); - //gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); - node = child; - child = NULL; - converter->bifs_parent = node; - } - break; + { + fprintf(stdout, "Warning: element %s not supported \n", gf_node_get_class_name((GF_Node *)elt)); + child = gf_node_new(converter->bifs_sg, TAG_MPEG4_Transform2D); + gf_node_register(child, node); + //gf_node_list_add_child(&((GF_ParentNode*)node)->children, child); + node = child; + child = NULL; + converter->bifs_parent = node; + } + break; } - if (id_string) + if (id_string) gf_node_set_id(converter->bifs_parent, gf_sg_get_next_available_node_id(converter->bifs_sg), NULL);//gf_node_get_name((GF_Node *)elt)); } @@ -988,7 +988,7 @@ static void svg2bifs_node_end(void *sax_cbck, const char *name, const char *name if (!(gf_node_get_tag(converter->svg_parent) == TAG_SVG_animateTransform)) converter->bifs_parent = gf_node_get_parent(converter->bifs_parent, 0); parent = gf_node_get_parent(converter->svg_parent, 0); - gf_node_unregister(converter->svg_parent, parent); + gf_node_unregister(converter->svg_parent, parent); if (!parent) gf_sg_set_root_node(converter->svg_sg, NULL); converter->svg_parent = parent; converter->bifs_text_node = NULL; @@ -1042,6 +1042,6 @@ int main(int argc, char **argv) // gf_sg_del(converter->bifs_sg); gf_xml_sax_del(converter->sax_parser); - + gf_free(converter); } diff --git a/applications/ts2hds/f4m.c b/applications/ts2hds/f4m.c index ab52259..74f9603 100644 --- a/applications/ts2hds/f4m.c +++ b/applications/ts2hds/f4m.c @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,18 +47,18 @@ struct __tag_adobe_multirate GF_List *streams; }; -static GF_Err adobe_gen_stream_manifest(AdobeStream *as) -{ - fprintf(as->f, "\n"); - fprintf(as->f, "\n"); - fprintf(as->f, "%s\n", as->id); - if (as->base_url) - fprintf(as->f, "%s\n", as->base_url); - fprintf(as->f, "\n", as->id, as->bitrate, as->id, as->bitrate); - fprintf(as->f, "\n", as->id, as->bitrate, as->bitrate, as->id, as->bitrate); - fprintf(as->f, "\n"); - - return GF_OK; +static GF_Err adobe_gen_stream_manifest(AdobeStream *as) +{ + fprintf(as->f, "\n"); + fprintf(as->f, "\n"); + fprintf(as->f, "%s\n", as->id); + if (as->base_url) + fprintf(as->f, "%s\n", as->base_url); + fprintf(as->f, "\n", as->id, as->bitrate, as->id, as->bitrate); + fprintf(as->f, "\n", as->id, as->bitrate, as->bitrate, as->id, as->bitrate); + fprintf(as->f, "\n"); + + return GF_OK; } AdobeMultirate *adobe_alloc_multirate_manifest(char *id) @@ -84,16 +84,16 @@ AdobeMultirate *adobe_alloc_multirate_manifest(char *id) AdobeStream *as = gf_calloc(1, sizeof(AdobeStream)); as->id = "HD"; as->bitrate = 100; - sprintf(filename, "%s_%s_%d.f4m", am->id, as->id, as->bitrate); - as->f = fopen(filename, "wt"); - if (!as->f) { - fprintf(stderr, "Couldn't create Adobe stream manifest file: %s\n", filename); - assert(0); - gf_list_del(am->streams); - gf_free(as); - gf_free(am); - return NULL; - } + sprintf(filename, "%s_%s_%d.f4m", am->id, as->id, as->bitrate); + as->f = fopen(filename, "wt"); + if (!as->f) { + fprintf(stderr, "Couldn't create Adobe stream manifest file: %s\n", filename); + assert(0); + gf_list_del(am->streams); + gf_free(as); + gf_free(am); + return NULL; + } gf_list_add(am->streams, as); } @@ -110,8 +110,8 @@ void adobe_free_multirate_manifest(AdobeMultirate *am) for (i=0; istreams); i++) { AdobeStream *as = gf_list_get(am->streams, i); assert(as); - if (as->f) - fclose(as->f); + if (as->f) + fclose(as->f); //TODO: base_url and id may be stored as gf_strdup in the future gf_list_rem(am->streams, i); gf_free(as); @@ -134,7 +134,7 @@ GF_Err adobe_gen_multirate_manifest(AdobeMultirate* am, char *bootstrap, size_t fprintf(am->f, "\n"); fprintf(am->f, "%s\n", am->id); fprintf(am->f, "%s\n", am->base_url); - fprintf(am->f, "live\n"); + fprintf(am->f, "live\n"); assert(am->streams); for (i=0; istreams); i++) { @@ -159,12 +159,12 @@ GF_Err adobe_gen_multirate_manifest(AdobeMultirate* am, char *bootstrap, size_t fclose(bstfile); } #endif - e = adobe_gen_stream_manifest(as); - if (!e) { - if (!am->base_url && !as->base_url) - fprintf(stderr, "Warning: no base_url specified\n"); + e = adobe_gen_stream_manifest(as); + if (!e) { + if (!am->base_url && !as->base_url) + fprintf(stderr, "Warning: no base_url specified\n"); - fprintf(am->f, "\n", am->id, as->id, as->bitrate, as->bitrate); + fprintf(am->f, "\n", am->id, as->id, as->bitrate, as->bitrate); } } fprintf(am->f, "\n"); diff --git a/applications/ts2hds/f4v.c b/applications/ts2hds/f4v.c index c65f166..c507f48 100644 --- a/applications/ts2hds/f4v.c +++ b/applications/ts2hds/f4v.c @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/applications/ts2hds/main.c b/applications/ts2hds/main.c index 9f677a6..0932fb3 100644 --- a/applications/ts2hds/main.c +++ b/applications/ts2hds/main.c @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,14 +44,14 @@ #endif -static GFINLINE void usage(const char * progname) +static GFINLINE void usage(const char * progname) { fprintf(stderr, "USAGE: %s -i input -o output\n" - "\n" + "\n" #ifdef GPAC_MEMORY_TRACKING - "\t-mem-track: enables memory tracker\n" + "\t-mem-track: enables memory tracker\n" #endif - ); + ); } @@ -84,7 +84,7 @@ static GFINLINE GF_Err parse_args(int argc, char **argv, char **input, char **ou gf_sys_init(1); gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO); #else - fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); + fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"-mem-track\"\n"); #endif } else { error_msg = "unknown option \"%s\""; @@ -103,7 +103,7 @@ static GFINLINE GF_Err parse_args(int argc, char **argv, char **input, char **ou return GF_BAD_PARAM; } -error: +error: if (!arg) { fprintf(stderr, "Error: %s\n\n", error_msg); } else { @@ -123,13 +123,13 @@ int main(int argc, char **argv) AdobeHDSCtx ctx; GF_Err e; u32 i; - + /*****************/ /* gpac init */ /*****************/ gf_sys_init(0); gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING); - + /***********************/ /* initialisations */ /***********************/ @@ -140,7 +140,7 @@ int main(int argc, char **argv) memset(&import, 0, sizeof(GF_MediaImporter)); e = GF_OK; memset(&ctx, 0, sizeof(ctx)); - + ctx.curr_time = 0; ctx.segnum = 1; @@ -265,7 +265,7 @@ int main(int argc, char **argv) } //interleave data and remove imported file - //FIXME: set multiple fragments: + //FIXME: set multiple fragments: sprintf(tmpstr, "%s_HD_100_Seg%u-Frag1", output, ctx.segnum); //FIXME: "HD", "100" and fragnum: pass as arg //e = gf_media_fragment_file(isom_file_in, tmpstr, 1.0); e = gf_media_fragment_file(isom_file_in, tmpstr, 1.0+gf_isom_get_duration(isom_file_in)/gf_isom_get_timescale(isom_file_in)); @@ -299,7 +299,7 @@ exit: } gf_sys_close(); - + return !e ? 0 : 1; } diff --git a/applications/ts2hds/ts2hds.h b/applications/ts2hds/ts2hds.h index a5495ee..556d444 100644 --- a/applications/ts2hds/ts2hds.h +++ b/applications/ts2hds/ts2hds.h @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/applications/udptsseg/main.c b/applications/udptsseg/main.c index 9825bff..3163737 100644 --- a/applications/udptsseg/main.c +++ b/applications/udptsseg/main.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. -* +* * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. -* +* * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -31,65 +31,65 @@ #define UDP_BUFFER_SIZE 64484 /* adapted from http://svn.assembla.com/svn/legend/segmenter/segmenter.c */ -static GF_Err write_manifest(char *manifest, char *segment_dir, u32 segment_duration, char *segment_prefix, char *http_prefix, - u32 first_segment, u32 last_segment, Bool end) { - FILE *manifest_fp; - u32 i; - char manifest_tmp_name[GF_MAX_PATH]; - char manifest_name[GF_MAX_PATH]; - char *tmp_manifest = manifest_tmp_name; +static GF_Err write_manifest(char *manifest, char *segment_dir, u32 segment_duration, char *segment_prefix, char *http_prefix, + u32 first_segment, u32 last_segment, Bool end) { + FILE *manifest_fp; + u32 i; + char manifest_tmp_name[GF_MAX_PATH]; + char manifest_name[GF_MAX_PATH]; + char *tmp_manifest = manifest_tmp_name; - if (segment_dir) { - sprintf(manifest_tmp_name, "%stmp.m3u8", segment_dir); - sprintf(manifest_name, "%s%s", segment_dir, manifest); - } else { - sprintf(manifest_tmp_name, "tmp.m3u8"); - sprintf(manifest_name, "%s", manifest); - } + if (segment_dir) { + sprintf(manifest_tmp_name, "%stmp.m3u8", segment_dir); + sprintf(manifest_name, "%s%s", segment_dir, manifest); + } else { + sprintf(manifest_tmp_name, "tmp.m3u8"); + sprintf(manifest_name, "%s", manifest); + } - manifest_fp = fopen(tmp_manifest, "w"); - if (!manifest_fp) { - fprintf(stderr, "Could not create m3u8 manifest file (%s)\n", tmp_manifest); - return GF_BAD_PARAM; - } + manifest_fp = fopen(tmp_manifest, "w"); + if (!manifest_fp) { + fprintf(stderr, "Could not create m3u8 manifest file (%s)\n", tmp_manifest); + return GF_BAD_PARAM; + } - fprintf(manifest_fp, "#EXTM3U\n#EXT-X-TARGETDURATION:%u\n#EXT-X-MEDIA-SEQUENCE:%u\n", segment_duration, first_segment); + fprintf(manifest_fp, "#EXTM3U\n#EXT-X-TARGETDURATION:%u\n#EXT-X-MEDIA-SEQUENCE:%u\n", segment_duration, first_segment); - for (i = first_segment; i <= last_segment; i++) { - fprintf(manifest_fp, "#EXTINF:%u,\n%s%s_%u.ts\n", segment_duration, http_prefix, segment_prefix, i); - } + for (i = first_segment; i <= last_segment; i++) { + fprintf(manifest_fp, "#EXTINF:%u,\n%s%s_%u.ts\n", segment_duration, http_prefix, segment_prefix, i); + } - if (end) { - fprintf(manifest_fp, "#EXT-X-ENDLIST\n"); - } - fclose(manifest_fp); + if (end) { + fprintf(manifest_fp, "#EXT-X-ENDLIST\n"); + } + fclose(manifest_fp); - if (!rename(tmp_manifest, manifest_name)) { - return GF_OK; - } else { - if (remove(manifest_name)) { - fprintf(stdout, "Error removing file %s\n", manifest_name); - return GF_IO_ERR; - } else if (rename(tmp_manifest, manifest_name)) { - fprintf(stderr, "Could not rename temporary m3u8 manifest file (%s) into %s\n", tmp_manifest, manifest_name); - return GF_IO_ERR; - } else { - return GF_OK; - } - } + if (!rename(tmp_manifest, manifest_name)) { + return GF_OK; + } else { + if (remove(manifest_name)) { + fprintf(stdout, "Error removing file %s\n", manifest_name); + return GF_IO_ERR; + } else if (rename(tmp_manifest, manifest_name)) { + fprintf(stderr, "Could not rename temporary m3u8 manifest file (%s) into %s\n", tmp_manifest, manifest_name); + return GF_IO_ERR; + } else { + return GF_OK; + } + } } -void usage() +void usage() { fprintf(stderr, "usage: udptsseg -src=UDP -dst-file=FILE -segment-duration=DUR -segment-dir=DIR -segment-manifest=M3U8 -segment-http-prefix=P -segment-number=N\n" - "-src=UDP udp://address:port providing the input transport stream\n" - "-dst-file=FILE e.g. out.ts, radical name of all segments\n" - "-segment-dir=DIR server local directory to store segments (with the trailing path separator)\n" - "-segment-duration=DUR segment duration in seconds\n" - "-segment-manifest=M3U8 m3u8 file basename\n" - "-segment-http-prefix=P client address for accessing server segments\n" - "-segment-number=N only n segments are used using a cyclic pattern\n" - "\n"); + "-src=UDP udp://address:port providing the input transport stream\n" + "-dst-file=FILE e.g. out.ts, radical name of all segments\n" + "-segment-dir=DIR server local directory to store segments (with the trailing path separator)\n" + "-segment-duration=DUR segment duration in seconds\n" + "-segment-manifest=M3U8 m3u8 file basename\n" + "-segment-http-prefix=P client address for accessing server segments\n" + "-segment-number=N only n segments are used using a cyclic pattern\n" + "\n"); } int main(int argc, char **argv) @@ -120,7 +120,7 @@ int main(int argc, char **argv) u32 last_segment_size = 0; u32 read = 0; u32 towrite = 0; - u32 leftinbuffer = 0; + u32 leftinbuffer = 0; fprintf(stdout, "UDP Transport Stream Segmenter\n"); @@ -138,7 +138,7 @@ int main(int argc, char **argv) /*****************/ for (i = 1; i < (u32) argc ; i++) { arg = argv[i]; - if (!strnicmp(arg, "-src=udp://",11)) { + if (!strnicmp(arg, "-src=udp://",11)) { char *sep; arg+=11; sep = strchr(arg+6, ':'); @@ -165,7 +165,7 @@ int main(int argc, char **argv) segment_http_prefix = gf_strdup(arg+21); } else if (!strnicmp(arg, "-segment-number=", 16)) { segment_number = atoi(arg+16); - } + } } fprintf(stdout, "Listening to TS input on %s:%d\n", input_ip, input_port); fprintf(stdout, "Creating %d sec. segments in directory %s\n", segment_duration, segment_dir); @@ -207,12 +207,12 @@ int main(int argc, char **argv) } fprintf(stderr, "Processing %s segment\r", segment_name); ts_out = gf_strdup(segment_name); - if (!segment_manifest) { + if (!segment_manifest) { sprintf(segment_manifest_default, "%s.m3u8", segment_prefix); segment_manifest = segment_manifest_default; } //write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, segment_index, 0, 0); - } + } ts_output_file = fopen(ts_out, "wb"); if (!ts_output_file) { fprintf(stderr, "Error opening %s\n", ts_out); @@ -240,7 +240,7 @@ int main(int argc, char **argv) while (input_buffer[i] != 0x47 && i < leftinbuffer) i++; fprintf(stderr, "Warning: data in buffer not starting with the MPEG-2 TS sync byte, skipping %d bytes of %d\n", i, leftinbuffer); if (i < leftinbuffer) memmove(input_buffer, input_buffer+i, leftinbuffer-i); - leftinbuffer -=i; + leftinbuffer -=i; } if ((leftinbuffer % 188) != 0) { fprintf(stderr, "Warning: data in buffer with a size (%d bytes) not multiple of 188 bytes\n", leftinbuffer); @@ -255,7 +255,7 @@ int main(int argc, char **argv) if (ts_output_file != NULL) { u32 now = gf_sys_clock(); if (towrite) { - gf_fwrite(input_buffer, 1, towrite, ts_output_file); + gf_fwrite(input_buffer, 1, towrite, ts_output_file); if (towrite < leftinbuffer) { fprintf(stderr, "Warning: wrote %d bytes, keeping %d bytes\n", towrite, (leftinbuffer-towrite)); memmove(input_buffer, input_buffer+towrite, leftinbuffer-towrite); @@ -263,7 +263,7 @@ int main(int argc, char **argv) leftinbuffer -= towrite; last_segment_size += towrite; } - if ((now - last_segment_time) > segment_duration*1000) { + if ((now - last_segment_time) > segment_duration*1000) { last_segment_time = now; fclose(ts_output_file); fprintf(stderr, "Closing segment %s (%d bytes)\n", segment_name, last_segment_size); @@ -284,7 +284,7 @@ int main(int argc, char **argv) goto exit; } /* delete the oldest segment */ - if (segment_number && ((s32) (segment_index - segment_number - 1) >= 0)){ + if (segment_number && ((s32) (segment_index - segment_number - 1) >= 0)) { char old_segment_name[GF_MAX_PATH]; if (segment_dir) { if (strchr("\\/", segment_name[strlen(segment_name)-1])) { @@ -298,10 +298,10 @@ int main(int argc, char **argv) gf_delete_file(old_segment_name); fprintf(stderr, "Deleting segment %s\n", old_segment_name); } - write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, - // (segment_index >= segment_number/2 ? segment_index - segment_number/2 : 0), segment_index >1 ? segment_index-1 : 0, 0); - ( (segment_index > segment_number ) ? segment_index - segment_number : 0), segment_index >1 ? segment_index-1 : 0, 0); - } + write_manifest(segment_manifest, segment_dir, segment_duration, segment_prefix, segment_http_prefix, + // (segment_index >= segment_number/2 ? segment_index - segment_number/2 : 0), segment_index >1 ? segment_index-1 : 0, 0); + ( (segment_index > segment_number ) ? segment_index - segment_number : 0), segment_index >1 ? segment_index-1 : 0, 0); + } } //} diff --git a/configure b/configure index fcd621e..446acd6 100755 --- a/configure +++ b/configure @@ -152,6 +152,7 @@ disable_scenegraph="no" disable_dvbx="yes" disable_vobsub="no" disable_ttxt="no" +disable_ttml="no" disable_hevc="no" enable_depth_compositor="no" enable_renoir="no" @@ -838,7 +839,7 @@ EOF mozjs_pkgcfg="mozjs185" fi - if test mozjs_pkgcfg != "no" ; then + if test $mozjs_pkgcfg != "no" ; then js_flags=`$pkg_config --cflags $mozjs_pkgcfg` js_lib_pkg=`$pkg_config --libs $mozjs_pkgcfg` if $cc -o $TMPO $TMPC $js_flags $js_lib_pkg $LDFLAGS -lpthread 2> /dev/null ; then @@ -1014,13 +1015,13 @@ fi if test "$darwin" = "yes" ; then ohevc_cflags="-I/usr/include -I/usr/local/include" -ohevc_ldflags="-L/usr/lib -L/usr/local/lib -lLibOpenHevcWrapper -lpthread" +ohevc_ldflags="-L/usr/lib -L/usr/local/lib -lLibOpenHevcWrapper -lm -lpthread " elif test "$cross_prefix" = "" ; then ohevc_cflags="" -ohevc_ldflags="-lLibOpenHevcWrapper -lpthread -lm" +ohevc_ldflags="-lLibOpenHevcWrapper -lm -lpthread" else ohevc_cflags="-I${prefix}include" -ohevc_ldflags="-lLibOpenHevcWrapper -lpthread" +ohevc_ldflags="-lLibOpenHevcWrapper -lm -lpthread" fi cat > $TMPC << EOF @@ -1028,12 +1029,12 @@ cat > $TMPC << EOF #include int main( void ) { libOpenHevcInit(1, 1); return 0; } EOF -if $cc -o $TMPO $TMPC $ohevc_cflags $LDFLAGS $ohevc_ldflags 2> /dev/null ; then +if $cc -o $TMPO $TMPC $ohevc_cflags $ohevc_ldflags $LDFLAGS 2> /dev/null ; then has_openhevc="yes" else ohevc_cflags="-I$local_inc" - ohevc_ldflags="-lLibOpenHevcWrapper -lpthread -lm" - if $cc -o $TMPO $TMPC $ohevc_cflags $LDFLAGS -L$local_lib $ohevc_ldflags 2> /dev/null ; then + ohevc_ldflags="-lLibOpenHevcWrapper -lm -lpthread" + if $cc -o $TMPO $TMPC $ohevc_cflags $ohevc_ldflags $LDFLAGS -L$local_lib 2> /dev/null ; then has_openhevc="yes" ohevc_ldflags="-L../../$local_lib $ohevc_ldflags" fi @@ -1298,7 +1299,9 @@ fi cat > $TMPC << EOF #include -int main(void) {return 0;} +int main(void) { + return 0; +} EOF if $cc -o $TMPO $TMPC $ffmpeg_cflags $ffmpeg_lflags $LDFLAGS 2> /dev/null ; then @@ -1306,7 +1309,7 @@ if $cc -o $TMPO $TMPC $ffmpeg_cflags $ffmpeg_lflags $LDFLAGS 2> /dev/null ; the else old_ffmpeg_inc="yes" - cat > $TMPC << EOF +cat > $TMPC << EOF #include int main(void) { AVFrame *f1, *f2; @@ -1318,6 +1321,14 @@ EOF fi +cat > $TMPC << EOF +#include +int main(void) { + CODEC_ID_H264; + return 0; +} +EOF + if test "$cross_prefix" = "" ; then if $cc -o $TMPO $TMPC -I$prefix/include -L$prefix/lib $ffmpeg_lflags $LDFLAGS 2> /dev/null ; then has_ffmpeg="system" @@ -1343,14 +1354,45 @@ fi cat > $TMPC << EOF #include -int main(void) {return 0;} +#include +int main(void) { + CODEC_ID_H264; + return 0; +} EOF if $cc -o $TMPO $TMPC $ffmpeg_cflags $ffmpeg_lflags 2> /dev/null ; then - is_libav="no" + is_libav="no" else - is_libav="yes" + +cat > $TMPC << EOF +#include +int main(void) { + CODEC_ID_H264; + return 0; +} +EOF + + if $cc -o $TMPO $TMPC $ffmpeg_cflags $ffmpeg_lflags 2> /dev/null ; then + is_libav="yes" + else + is_libav="new" + fi fi +#detect libavresample (libav only, but ffmpeg backported with '--enable-avresample') for dashcast only +cat > $TMPC << EOF +#include "libavresample/avresample.h" +int main(void) { + AVAudioResampleContext *aresampler = avresample_alloc_context(); + return 0; +} +EOF + +if $cc -o $TMPO $TMPC $ffmpeg_cflags $ffmpeg_lflags -lavresample 2> /dev/null ; then + has_libavresample="yes" +else + has_libavresample="no" +fi #look for FREENECT support @@ -1814,7 +1856,7 @@ for opt do ;; --enable-pulseaudio=*) has_pulseaudio="yes" ;; - --disable-all) has_pulseaudio="no"; has_alsa="no"; disable_core_tools="yes"; disable_3d="yes"; disable_svg="yes"; disable_vrml="yes"; disable_od="yes"; disable_bifs="yes"; disable_bifs_enc="yes"; disable_laser="yes"; disable_seng="yes"; disable_qtvr="yes"; disable_avi="yes"; disable_ogg="yes"; disable_m2ps="yes"; disable_m2ts="yes"; disable_m2ts_mux="yes"; disable_parsers="yes"; disable_import="yes"; disable_export="yes"; disable_swf="yes"; disable_scene_stats="yes"; disable_scene_dump="yes"; disable_scene_encode="yes"; disable_loader_isoff="yes"; disable_od_dump="yes"; disable_od_parse="yes"; disable_isom_dump="yes"; disable_mcrypt="yes"; disable_isoff="yes"; disable_isoff_write="yes"; disable_isoff_hint="yes"; disable_isoff_frag="yes"; disable_streaming="yes"; disable_x3d="yes"; disable_loader_bt="yes"; disable_loader_xmt="yes"; has_dvb4linux="no"; disable_player="yes"; disable_vobsub="yes"; disable_scenegraph="yes"; disable_dvbx="yes"; disable_ttxt="yes"; disable_saf="yes"; disable_smgr="yes"; disable_mpd="yes"; disable_dash="yes"; disable_isoff_hds="yes"; disable_hevc="yes" + --disable-all) has_pulseaudio="no"; has_alsa="no"; disable_core_tools="yes"; disable_3d="yes"; disable_svg="yes"; disable_vrml="yes"; disable_od="yes"; disable_bifs="yes"; disable_bifs_enc="yes"; disable_laser="yes"; disable_seng="yes"; disable_qtvr="yes"; disable_avi="yes"; disable_ogg="yes"; disable_m2ps="yes"; disable_m2ts="yes"; disable_m2ts_mux="yes"; disable_parsers="yes"; disable_import="yes"; disable_export="yes"; disable_swf="yes"; disable_scene_stats="yes"; disable_scene_dump="yes"; disable_scene_encode="yes"; disable_loader_isoff="yes"; disable_od_dump="yes"; disable_od_parse="yes"; disable_isom_dump="yes"; disable_mcrypt="yes"; disable_isoff="yes"; disable_isoff_write="yes"; disable_isoff_hint="yes"; disable_isoff_frag="yes"; disable_streaming="yes"; disable_x3d="yes"; disable_loader_bt="yes"; disable_loader_xmt="yes"; has_dvb4linux="no"; disable_player="yes"; disable_vobsub="yes"; disable_scenegraph="yes"; disable_dvbx="yes"; disable_ttxt="yes"; disable_ttml="yes"; disable_saf="yes"; disable_smgr="yes"; disable_mpd="yes"; disable_dash="yes"; disable_isoff_hds="yes"; disable_hevc="yes" ;; --isomedia-only) has_pulseaudio="no"; has_alsa="no"; disable_core_tools="yes"; disable_3d="yes"; disable_svg="yes"; disable_vrml="yes"; disable_od="yes"; disable_bifs="yes"; disable_bifs_enc="yes"; disable_laser="yes"; disable_seng="yes"; disable_qtvr="yes"; disable_avi="yes"; disable_ogg="yes"; disable_m2ps="yes"; disable_m2ts="yes"; disable_m2ts_mux="yes"; disable_parsers="yes"; disable_import="yes"; disable_export="yes"; disable_swf="yes"; disable_scene_stats="yes"; disable_scene_dump="yes"; disable_scene_encode="yes"; disable_loader_isoff="yes"; disable_od_dump="yes"; disable_od_parse="yes"; disable_isom_dump="yes"; disable_mcrypt="yes"; disable_streaming="yes"; disable_x3d="yes"; disable_loader_bt="yes"; disable_loader_xmt="yes"; has_dvb4linux="no"; disable_player="yes"; disable_vobsub="yes"; disable_scenegraph="yes"; disable_dvbx="yes"; disable_ttxt="yes"; disable_saf="yes"; disable_smgr="yes"; disable_mpd="yes"; disable_dash="yes"; disable_hevc="no"; disable_isoff="no"; disable_isoff_hds="no"; disable_isoff_write="no"; disable_isoff_hint="no"; disable_isoff_frag="no" ;; @@ -1980,6 +2022,10 @@ for opt do ;; --enable-ttxt) disable_ttxt="no" ;; + --disable-ttml) disable_ttml="yes" + ;; + --enable-ttml) disable_ttml="no" + ;; --disable-saf) disable_saf="yes" ;; --enable-saf) disable_saf="no" @@ -2486,6 +2532,10 @@ if test "$disable_swf" = "yes" ; then echo "SWF import disabled" echo "#define GPAC_DISABLE_SWF_IMPORT" >> $TMPH fi +if test "$disable_scenegraph" = "yes" ; then + echo "Scene Graph disabled" + echo "#define GPAC_DISABLE_SCENEGRAPH" >> $TMPH +fi if test "$disable_scene_stats" = "yes" ; then echo "Scene statistics disabled" echo "#define GPAC_DISABLE_SCENE_STATS" >> $TMPH @@ -2557,10 +2607,15 @@ if test "$disable_vobsub" = "yes" ; then echo "#define GPAC_DISABLE_VOBSUB" >> $TMPH fi if test "$disable_ttxt" = "yes" ; then - echo "TimedText disabled" + echo "3GPP/Apple TimedText disabled" echo "#define GPAC_DISABLE_TTXT" >> $TMPH fi +if test "$disable_ttml" = "yes" ; then + echo "TTML TimedText disabled" + echo "#define GPAC_DISABLE_TTML" >> $TMPH +fi + if test "$enable_depth_compositor" = "yes" ; then echo "Depth Compositor enabled" echo "#define GF_SR_USE_DEPTH" >> $TMPH @@ -2877,8 +2932,8 @@ echo "DISABLE_DASHCAST=yes" >> config.mak else echo "ffmpeg_cflags=$ffmpeg_cflags" >> config.mak echo "ffmpeg_lflags=$ffmpeg_lflags" >> config.mak -# echo "DISABLE_DASHCAST=$is_libav" >> config.mak echo "CONFIG_LIBAV=$is_libav" >> config.mak + echo "CONFIG_LIBAVRESAMPLE=$has_libavresample" >> config.mak fi echo "CONFIG_FFMPEG_OLD=$old_ffmpeg_inc" >> config.mak @@ -2918,6 +2973,7 @@ echo "DISABLE_OGG=$disable_ogg" >> config.mak echo "DISABLE_ISOFF_HINT=$disable_isoff_hint" >> config.mak echo "DISABLE_VOBSUB=$disable_vobsub" >> config.mak echo "DISABLE_TTXT=$disable_ttxt" >> config.mak +echo "DISABLE_TTML=$disable_ttml" >> config.mak echo "DISABLE_SMGR=$disable_smgr" >> config.mak echo "DISABLE_AV_PARSERS=$disable_parsers" >> config.mak echo "DISABLE_MEDIA_IMPORT=$disable_import" >> config.mak @@ -3107,7 +3163,7 @@ if test "$source_path_used" = "yes" ; then echo "Creating compilation tree image" SRC_DIRS="src src/utils src/isomedia src/ietf src/odf src/bifs src/scenegraph src/terminal src/mcrypt src/media_tools src/scene_manager src/compositor src/laser" - APP_DIRS="applications/mp4box applications/mp4client applications/osmozilla applications/osmo4_wx applications/mp42ts" + APP_DIRS="applications/mp4box applications/mp4client applications/osmozilla applications/osmo4_wx applications/mp42ts applications/dashcast" for dir in $SRC_DIRS ; do mkdir -p "$dir" diff --git a/doc/CODING_STYLE b/doc/CODING_STYLE index 58f944b..9440327 100644 --- a/doc/CODING_STYLE +++ b/doc/CODING_STYLE @@ -1,14 +1,11 @@ -GPAC coding styles as of 0.4.0 +GPAC coding style -Foreword: - As of 0.4.0, GPAC is being licensed under the LGPL. This brought the concern of refining coding conventions inside the framework so as - to extract the core functionlaities of GPAC to third-party developers. - The number of modules present in GPAC having been developed for many years without any specific coding styles, the entire GPAC framework - has been rewrote in a NON-BACKWARD COMPATIBLE WAY. - Introduction coding styles only concern the GPAC library (M4Systems in GPAC<=0.3.0, libgpac now), and, although recommended, are not mandatory for plugins or applications development. + + AStyle is a code beautifier tool. Code should be compliant with the following pattern provided by AStyle : + AStyle -r --indent=tab '*.c' '*.h' '*.cpp' '*.hpp' 1 Exported symbols diff --git a/doc/configuration.html b/doc/configuration.html index ab6423d..8c8bdbd 100644 --- a/doc/configuration.html +++ b/doc/configuration.html @@ -10,7 +10,7 @@
GPAC Configuration file documentation
Version 0.5.0

-Last Modified $LastChangedDate: 2014-03-27 06:31:20 -0400 (Do, 27. Mär 2014) $ +Last Modified $LastChangedDate: 2014-06-10 15:08:09 +0100 (Tue, 10 Jun 2014) $



@@ -366,11 +366,6 @@ Enables power of 2 emulation. Ignored if openGL rectangular texture extension is DisableGLUScale [value: "yes" "no"]

Disables usage of gluScaleImage, which may be slower but nicer than GPAC's software stretch routines.

-BitmapCopyPixels [value: "yes" "no"] -

-Specifies whether the bitmap node should be drawn with regular openGL texturing ("no") or through pixel copy routines ("yes"). This greatly impacts video rendering through -bitmap depending on the graphics card. Some cards will have faster pixel copy routines that texture transfer ones, some won't. -

TextureTextMode (value: "Default", "Never", "Always"]

Specifies whether text shall be drawn to a texture and then rendered or directly rendered. Using textured text can improve text rendering in 3D and also improve text-on-video like content. Default value will use texturing for OpenGL rendering.

@@ -751,9 +746,11 @@ Disables all resolutions that are higher than the screen resolution. Default is StartRepresentation [value: minBandwidth, maxBandwidth, minQuality, maxQuality]

Instructs the DASH client to start playing the indicated representation before doing any switching. Default is minBandwidth.

-InitialTimeshift [value: positive integer between 0 and 100 ] +InitialTimeshift [value: positive integer ]

-Uses the given percentage of the timeshift buffer when starting playback. Default is 0 to tune to the live point.

+If between 0 and 100, indicates the percentage of the timeshift buffer when starting playback.
+If more than 100, indicates the number of milliseconds to rewind in the timeshift buffer when starting playback.
+Default is 0 to tune to the live point.

LowLatency [value: always, chunk, no]

Sets low-latency mode enabled. In low-latency mode, media data is parsed as soon as possible while segment is being downloaded. Default is no. @@ -843,6 +840,12 @@ Specifies the number of threads to allocate to the OpenHEVC decoder. Default is ThreadingType [value: frame , wpp , frame+wpp ]

Specifies the threading type for the openHEVC decoder. Default is frame (wpp disabled).

+CBUnits [value: unsigned integer ] +

+Specifies the number of decoded frames in memory before display. Default value is 4.

+PackHFR [value: yes, no ] +

+Packs 4 consecutive frames in a single 4x frame.



diff --git a/extra_lib/include/libavdevice/avdevice.h b/extra_lib/include/libavdevice/avdevice.h index 93a044f..28344ca 100644 --- a/extra_lib/include/libavdevice/avdevice.h +++ b/extra_lib/include/libavdevice/avdevice.h @@ -66,4 +66,168 @@ const char *avdevice_license(void); */ void avdevice_register_all(void); +typedef struct AVDeviceRect { + int x; /**< x coordinate of top left corner */ + int y; /**< y coordinate of top left corner */ + int width; /**< width */ + int height; /**< height */ +} AVDeviceRect; + +/** + * Message types used by avdevice_app_to_dev_control_message(). + */ +enum AVAppToDevMessageType { + /** + * Dummy message. + */ + AV_APP_TO_DEV_NONE = MKBETAG('N','O','N','E'), + + /** + * Window size change message. + * + * Message is sent to the device every time the application changes the size + * of the window device renders to. + * Message should also be sent right after window is created. + * + * data: AVDeviceRect: new window size. + */ + AV_APP_TO_DEV_WINDOW_SIZE = MKBETAG('G','E','O','M'), + + /** + * Repaint request message. + * + * Message is sent to the device when window have to be rapainted. + * + * data: AVDeviceRect: area required to be repainted. + * NULL: whole area is required to be repainted. + */ + AV_APP_TO_DEV_WINDOW_REPAINT = MKBETAG('R','E','P','A') +}; + +/** + * Message types used by avdevice_dev_to_app_control_message(). + */ +enum AVDevToAppMessageType { + /** + * Dummy message. + */ + AV_DEV_TO_APP_NONE = MKBETAG('N','O','N','E'), + + /** + * Create window buffer message. + * + * Device requests to create a window buffer. Exact meaning is device- + * and application-dependent. Message is sent before rendering first + * frame and all one-shot initializations should be done here. + * Application is allowed to ignore preferred window buffer size. + * + * @note: Application is obligated to inform about window buffer size + * with AV_APP_TO_DEV_WINDOW_SIZE message. + * + * data: AVDeviceRect: preferred size of the window buffer. + * NULL: no preferred size of the window buffer. + */ + AV_DEV_TO_APP_CREATE_WINDOW_BUFFER = MKBETAG('B','C','R','E'), + + /** + * Prepare window buffer message. + * + * Device requests to prepare a window buffer for rendering. + * Exact meaning is device- and application-dependent. + * Message is sent before rendering of each frame. + * + * data: NULL. + */ + AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER = MKBETAG('B','P','R','E'), + + /** + * Display window buffer message. + * + * Device requests to display a window buffer. + * Message is sent when new frame is ready to be displyed. + * Usually buffers need to be swapped in handler of this message. + * + * data: NULL. + */ + AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER = MKBETAG('B','D','I','S'), + + /** + * Destroy window buffer message. + * + * Device requests to destroy a window buffer. + * Message is sent when device is about to be destroyed and window + * buffer is not required anymore. + * + * data: NULL. + */ + AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER = MKBETAG('B','D','E','S') +}; + +/** + * Send control message from application to device. + * + * @param s device context. + * @param type message type. + * @param data message data. Exact type depends on message type. + * @param data_size size of message data. + * @return >= 0 on success, negative on error. + * AVERROR(ENOSYS) when device doesn't implement handler of the message. + */ +int avdevice_app_to_dev_control_message(struct AVFormatContext *s, + enum AVAppToDevMessageType type, + void *data, size_t data_size); + +/** + * Send control message from device to application. + * + * @param s device context. + * @param type message type. + * @param data message data. Can be NULL. + * @param data_size size of message data. + * @return >= 0 on success, negative on error. + * AVERROR(ENOSYS) when application doesn't implement handler of the message. + */ +int avdevice_dev_to_app_control_message(struct AVFormatContext *s, + enum AVDevToAppMessageType type, + void *data, size_t data_size); + +/** + * Structure describes basic parameters of the device. + */ +typedef struct AVDeviceInfo { + char *device_name; /**< device name, format depends on device */ + char *device_description; /**< human friendly name */ +} AVDeviceInfo; + +/** + * List of devices. + */ +typedef struct AVDeviceInfoList { + AVDeviceInfo **devices; /**< list of autodetected devices */ + int nb_devices; /**< number of autodetected devices */ + int default_device; /**< index of default device or -1 if no default */ +} AVDeviceInfoList; + +/** + * List devices. + * + * Returns available device names and their parameters. + * + * @note: Some devices may accept system-dependent device names that cannot be + * autodetected. The list returned by this function cannot be assumed to + * be always completed. + * + * @param s device context. + * @param[out] device_list list of autodetected devices. + * @return count of autodetected devices, negative on error. + */ +int avdevice_list_devices(struct AVFormatContext *s, AVDeviceInfoList **device_list); + +/** + * Convinient function to free result of avdevice_list_devices(). + * + * @param devices device list to be freed. + */ +void avdevice_free_list_devices(AVDeviceInfoList **device_list); + #endif /* AVDEVICE_AVDEVICE_H */ diff --git a/extra_lib/include/libavdevice/version.h b/extra_lib/include/libavdevice/version.h index 1e18f51..85b3b37 100644 --- a/extra_lib/include/libavdevice/version.h +++ b/extra_lib/include/libavdevice/version.h @@ -25,10 +25,10 @@ * Libavdevice version macros */ -#include "libavutil/avutil.h" +#include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 55 -#define LIBAVDEVICE_VERSION_MINOR 3 +#define LIBAVDEVICE_VERSION_MINOR 10 #define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ diff --git a/extra_lib/include/libavfilter/asrc_abuffer.h b/extra_lib/include/libavfilter/asrc_abuffer.h new file mode 100644 index 0000000..aa34461 --- /dev/null +++ b/extra_lib/include/libavfilter/asrc_abuffer.h @@ -0,0 +1,91 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_ASRC_ABUFFER_H +#define AVFILTER_ASRC_ABUFFER_H + +#include "avfilter.h" + +/** + * @file + * memory buffer source for audio + * + * @deprecated use buffersrc.h instead. + */ + +/** + * Queue an audio buffer to the audio buffer source. + * + * @param abuffersrc audio source buffer context + * @param data pointers to the samples planes + * @param linesize linesizes of each audio buffer plane + * @param nb_samples number of samples per channel + * @param sample_fmt sample format of the audio data + * @param ch_layout channel layout of the audio data + * @param planar flag to indicate if audio data is planar or packed + * @param pts presentation timestamp of the audio buffer + * @param flags unused + * + * @deprecated use av_buffersrc_add_ref() instead. + */ +attribute_deprecated +int av_asrc_buffer_add_samples(AVFilterContext *abuffersrc, + uint8_t *data[8], int linesize[8], + int nb_samples, int sample_rate, + int sample_fmt, int64_t ch_layout, int planar, + int64_t pts, int av_unused flags); + +/** + * Queue an audio buffer to the audio buffer source. + * + * This is similar to av_asrc_buffer_add_samples(), but the samples + * are stored in a buffer with known size. + * + * @param abuffersrc audio source buffer context + * @param buf pointer to the samples data, packed is assumed + * @param size the size in bytes of the buffer, it must contain an + * integer number of samples + * @param sample_fmt sample format of the audio data + * @param ch_layout channel layout of the audio data + * @param pts presentation timestamp of the audio buffer + * @param flags unused + * + * @deprecated use av_buffersrc_add_ref() instead. + */ +attribute_deprecated +int av_asrc_buffer_add_buffer(AVFilterContext *abuffersrc, + uint8_t *buf, int buf_size, + int sample_rate, + int sample_fmt, int64_t ch_layout, int planar, + int64_t pts, int av_unused flags); + +/** + * Queue an audio buffer to the audio buffer source. + * + * @param abuffersrc audio source buffer context + * @param samplesref buffer ref to queue + * @param flags unused + * + * @deprecated use av_buffersrc_add_ref() instead. + */ +attribute_deprecated +int av_asrc_buffer_add_audio_buffer_ref(AVFilterContext *abuffersrc, + AVFilterBufferRef *samplesref, + int av_unused flags); + +#endif /* AVFILTER_ASRC_ABUFFER_H */ diff --git a/extra_lib/include/libavfilter/avcodec.h b/extra_lib/include/libavfilter/avcodec.h new file mode 100644 index 0000000..8bbdad2 --- /dev/null +++ b/extra_lib/include/libavfilter/avcodec.h @@ -0,0 +1,110 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_AVCODEC_H +#define AVFILTER_AVCODEC_H + +/** + * @file + * libavcodec/libavfilter gluing utilities + * + * This should be included in an application ONLY if the installed + * libavfilter has been compiled with libavcodec support, otherwise + * symbols defined below will not be available. + */ + +#include "avfilter.h" + +#if FF_API_AVFILTERBUFFER +/** + * Create and return a picref reference from the data and properties + * contained in frame. + * + * @param perms permissions to assign to the new buffer reference + * @deprecated avfilter APIs work natively with AVFrame instead. + */ +attribute_deprecated +AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms); + + +/** + * Create and return a picref reference from the data and properties + * contained in frame. + * + * @param perms permissions to assign to the new buffer reference + * @deprecated avfilter APIs work natively with AVFrame instead. + */ +attribute_deprecated +AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame, + int perms); + +/** + * Create and return a buffer reference from the data and properties + * contained in frame. + * + * @param perms permissions to assign to the new buffer reference + * @deprecated avfilter APIs work natively with AVFrame instead. + */ +attribute_deprecated +AVFilterBufferRef *avfilter_get_buffer_ref_from_frame(enum AVMediaType type, + const AVFrame *frame, + int perms); +#endif + +#if FF_API_FILL_FRAME +/** + * Fill an AVFrame with the information stored in samplesref. + * + * @param frame an already allocated AVFrame + * @param samplesref an audio buffer reference + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + * @deprecated Use avfilter_copy_buf_props() instead. + */ +attribute_deprecated +int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame, + const AVFilterBufferRef *samplesref); + +/** + * Fill an AVFrame with the information stored in picref. + * + * @param frame an already allocated AVFrame + * @param picref a video buffer reference + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + * @deprecated Use avfilter_copy_buf_props() instead. + */ +attribute_deprecated +int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame, + const AVFilterBufferRef *picref); + +/** + * Fill an AVFrame with information stored in ref. + * + * @param frame an already allocated AVFrame + * @param ref a video or audio buffer reference + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + * @deprecated Use avfilter_copy_buf_props() instead. + */ +attribute_deprecated +int avfilter_fill_frame_from_buffer_ref(AVFrame *frame, + const AVFilterBufferRef *ref); +#endif + +#endif /* AVFILTER_AVCODEC_H */ diff --git a/extra_lib/include/libavfilter/avfilter.h b/extra_lib/include/libavfilter/avfilter.h new file mode 100644 index 0000000..ef7e8ca --- /dev/null +++ b/extra_lib/include/libavfilter/avfilter.h @@ -0,0 +1,1529 @@ +/* + * filter layer + * Copyright (c) 2007 Bobby Bingham + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_AVFILTER_H +#define AVFILTER_AVFILTER_H + +/** + * @file + * @ingroup lavfi + * Main libavfilter public API header + */ + +/** + * @defgroup lavfi Libavfilter - graph-based frame editing library + * @{ + */ + +#include + +#include "libavutil/attributes.h" +#include "libavutil/avutil.h" +#include "libavutil/dict.h" +#include "libavutil/frame.h" +#include "libavutil/log.h" +#include "libavutil/samplefmt.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" + +#include "libavfilter/version.h" + +/** + * Return the LIBAVFILTER_VERSION_INT constant. + */ +unsigned avfilter_version(void); + +/** + * Return the libavfilter build-time configuration. + */ +const char *avfilter_configuration(void); + +/** + * Return the libavfilter license. + */ +const char *avfilter_license(void); + +typedef struct AVFilterContext AVFilterContext; +typedef struct AVFilterLink AVFilterLink; +typedef struct AVFilterPad AVFilterPad; +typedef struct AVFilterFormats AVFilterFormats; + +#if FF_API_AVFILTERBUFFER +/** + * A reference-counted buffer data type used by the filter system. Filters + * should not store pointers to this structure directly, but instead use the + * AVFilterBufferRef structure below. + */ +typedef struct AVFilterBuffer { + uint8_t *data[8]; ///< buffer data for each plane/channel + + /** + * pointers to the data planes/channels. + * + * For video, this should simply point to data[]. + * + * For planar audio, each channel has a separate data pointer, and + * linesize[0] contains the size of each channel buffer. + * For packed audio, there is just one data pointer, and linesize[0] + * contains the total size of the buffer for all channels. + * + * Note: Both data and extended_data will always be set, but for planar + * audio with more channels that can fit in data, extended_data must be used + * in order to access all channels. + */ + uint8_t **extended_data; + int linesize[8]; ///< number of bytes per line + + /** private data to be used by a custom free function */ + void *priv; + /** + * A pointer to the function to deallocate this buffer if the default + * function is not sufficient. This could, for example, add the memory + * back into a memory pool to be reused later without the overhead of + * reallocating it from scratch. + */ + void (*free)(struct AVFilterBuffer *buf); + + int format; ///< media format + int w, h; ///< width and height of the allocated buffer + unsigned refcount; ///< number of references to this buffer +} AVFilterBuffer; + +#define AV_PERM_READ 0x01 ///< can read from the buffer +#define AV_PERM_WRITE 0x02 ///< can write to the buffer +#define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer +#define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time +#define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time +#define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes +#define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned + +#define AVFILTER_ALIGN 16 //not part of ABI + +/** + * Audio specific properties in a reference to an AVFilterBuffer. Since + * AVFilterBufferRef is common to different media formats, audio specific + * per reference properties must be separated out. + */ +typedef struct AVFilterBufferRefAudioProps { + uint64_t channel_layout; ///< channel layout of audio buffer + int nb_samples; ///< number of audio samples per channel + int sample_rate; ///< audio buffer sample rate + int channels; ///< number of channels (do not access directly) +} AVFilterBufferRefAudioProps; + +/** + * Video specific properties in a reference to an AVFilterBuffer. Since + * AVFilterBufferRef is common to different media formats, video specific + * per reference properties must be separated out. + */ +typedef struct AVFilterBufferRefVideoProps { + int w; ///< image width + int h; ///< image height + AVRational sample_aspect_ratio; ///< sample aspect ratio + int interlaced; ///< is frame interlaced + int top_field_first; ///< field order + enum AVPictureType pict_type; ///< picture type of the frame + int key_frame; ///< 1 -> keyframe, 0-> not + int qp_table_linesize; ///< qp_table stride + int qp_table_size; ///< qp_table size + int8_t *qp_table; ///< array of Quantization Parameters +} AVFilterBufferRefVideoProps; + +/** + * A reference to an AVFilterBuffer. Since filters can manipulate the origin of + * a buffer to, for example, crop image without any memcpy, the buffer origin + * and dimensions are per-reference properties. Linesize is also useful for + * image flipping, frame to field filters, etc, and so is also per-reference. + * + * TODO: add anything necessary for frame reordering + */ +typedef struct AVFilterBufferRef { + AVFilterBuffer *buf; ///< the buffer that this is a reference to + uint8_t *data[8]; ///< picture/audio data for each plane + /** + * pointers to the data planes/channels. + * + * For video, this should simply point to data[]. + * + * For planar audio, each channel has a separate data pointer, and + * linesize[0] contains the size of each channel buffer. + * For packed audio, there is just one data pointer, and linesize[0] + * contains the total size of the buffer for all channels. + * + * Note: Both data and extended_data will always be set, but for planar + * audio with more channels that can fit in data, extended_data must be used + * in order to access all channels. + */ + uint8_t **extended_data; + int linesize[8]; ///< number of bytes per line + + AVFilterBufferRefVideoProps *video; ///< video buffer specific properties + AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties + + /** + * presentation timestamp. The time unit may change during + * filtering, as it is specified in the link and the filter code + * may need to rescale the PTS accordingly. + */ + int64_t pts; + int64_t pos; ///< byte position in stream, -1 if unknown + + int format; ///< media format + + int perms; ///< permissions, see the AV_PERM_* flags + + enum AVMediaType type; ///< media type of buffer data + + AVDictionary *metadata; ///< dictionary containing metadata key=value tags +} AVFilterBufferRef; + +/** + * Copy properties of src to dst, without copying the actual data + */ +attribute_deprecated +void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src); + +/** + * Add a new reference to a buffer. + * + * @param ref an existing reference to the buffer + * @param pmask a bitmask containing the allowable permissions in the new + * reference + * @return a new reference to the buffer with the same properties as the + * old, excluding any permissions denied by pmask + */ +attribute_deprecated +AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); + +/** + * Remove a reference to a buffer. If this is the last reference to the + * buffer, the buffer itself is also automatically freed. + * + * @param ref reference to the buffer, may be NULL + * + * @note it is recommended to use avfilter_unref_bufferp() instead of this + * function + */ +attribute_deprecated +void avfilter_unref_buffer(AVFilterBufferRef *ref); + +/** + * Remove a reference to a buffer and set the pointer to NULL. + * If this is the last reference to the buffer, the buffer itself + * is also automatically freed. + * + * @param ref pointer to the buffer reference + */ +attribute_deprecated +void avfilter_unref_bufferp(AVFilterBufferRef **ref); +#endif + +/** + * Get the number of channels of a buffer reference. + */ +attribute_deprecated +int avfilter_ref_get_channels(AVFilterBufferRef *ref); + +#if FF_API_AVFILTERPAD_PUBLIC +/** + * A filter pad used for either input or output. + * + * See doc/filter_design.txt for details on how to implement the methods. + * + * @warning this struct might be removed from public API. + * users should call avfilter_pad_get_name() and avfilter_pad_get_type() + * to access the name and type fields; there should be no need to access + * any other fields from outside of libavfilter. + */ +struct AVFilterPad { + /** + * Pad name. The name is unique among inputs and among outputs, but an + * input may have the same name as an output. This may be NULL if this + * pad has no need to ever be referenced by name. + */ + const char *name; + + /** + * AVFilterPad type. + */ + enum AVMediaType type; + + /** + * Input pads: + * Minimum required permissions on incoming buffers. Any buffer with + * insufficient permissions will be automatically copied by the filter + * system to a new buffer which provides the needed access permissions. + * + * Output pads: + * Guaranteed permissions on outgoing buffers. Any buffer pushed on the + * link must have at least these permissions; this fact is checked by + * asserts. It can be used to optimize buffer allocation. + */ + attribute_deprecated int min_perms; + + /** + * Input pads: + * Permissions which are not accepted on incoming buffers. Any buffer + * which has any of these permissions set will be automatically copied + * by the filter system to a new buffer which does not have those + * permissions. This can be used to easily disallow buffers with + * AV_PERM_REUSE. + * + * Output pads: + * Permissions which are automatically removed on outgoing buffers. It + * can be used to optimize buffer allocation. + */ + attribute_deprecated int rej_perms; + + /** + * @deprecated unused + */ + int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref); + + /** + * Callback function to get a video buffer. If NULL, the filter system will + * use ff_default_get_video_buffer(). + * + * Input video pads only. + */ + AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h); + + /** + * Callback function to get an audio buffer. If NULL, the filter system will + * use ff_default_get_audio_buffer(). + * + * Input audio pads only. + */ + AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples); + + /** + * @deprecated unused + */ + int (*end_frame)(AVFilterLink *link); + + /** + * @deprecated unused + */ + int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir); + + /** + * Filtering callback. This is where a filter receives a frame with + * audio/video data and should do its processing. + * + * Input pads only. + * + * @return >= 0 on success, a negative AVERROR on error. This function + * must ensure that frame is properly unreferenced on error if it + * hasn't been passed on to another filter. + */ + int (*filter_frame)(AVFilterLink *link, AVFrame *frame); + + /** + * Frame poll callback. This returns the number of immediately available + * samples. It should return a positive value if the next request_frame() + * is guaranteed to return one frame (with no delay). + * + * Defaults to just calling the source poll_frame() method. + * + * Output pads only. + */ + int (*poll_frame)(AVFilterLink *link); + + /** + * Frame request callback. A call to this should result in at least one + * frame being output over the given link. This should return zero on + * success, and another value on error. + * See ff_request_frame() for the error codes with a specific + * meaning. + * + * Output pads only. + */ + int (*request_frame)(AVFilterLink *link); + + /** + * Link configuration callback. + * + * For output pads, this should set the following link properties: + * video: width, height, sample_aspect_ratio, time_base + * audio: sample_rate. + * + * This should NOT set properties such as format, channel_layout, etc which + * are negotiated between filters by the filter system using the + * query_formats() callback before this function is called. + * + * For input pads, this should check the properties of the link, and update + * the filter's internal state as necessary. + * + * For both input and output pads, this should return zero on success, + * and another value on error. + */ + int (*config_props)(AVFilterLink *link); + + /** + * The filter expects a fifo to be inserted on its input link, + * typically because it has a delay. + * + * input pads only. + */ + int needs_fifo; + + /** + * The filter expects writable frames from its input link, + * duplicating data buffers if needed. + * + * input pads only. + */ + int needs_writable; +}; +#endif + +/** + * Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. + * AVFilter.inputs/outputs). + */ +int avfilter_pad_count(const AVFilterPad *pads); + +/** + * Get the name of an AVFilterPad. + * + * @param pads an array of AVFilterPads + * @param pad_idx index of the pad in the array it; is the caller's + * responsibility to ensure the index is valid + * + * @return name of the pad_idx'th pad in pads + */ +const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx); + +/** + * Get the type of an AVFilterPad. + * + * @param pads an array of AVFilterPads + * @param pad_idx index of the pad in the array; it is the caller's + * responsibility to ensure the index is valid + * + * @return type of the pad_idx'th pad in pads + */ +enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx); + +/** + * The number of the filter inputs is not determined just by AVFilter.inputs. + * The filter might add additional inputs during initialization depending on the + * options supplied to it. + */ +#define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0) +/** + * The number of the filter outputs is not determined just by AVFilter.outputs. + * The filter might add additional outputs during initialization depending on + * the options supplied to it. + */ +#define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1) +/** + * The filter supports multithreading by splitting frames into multiple parts + * and processing them concurrently. + */ +#define AVFILTER_FLAG_SLICE_THREADS (1 << 2) +/** + * Some filters support a generic "enable" expression option that can be used + * to enable or disable a filter in the timeline. Filters supporting this + * option have this flag set. When the enable expression is false, the default + * no-op filter_frame() function is called in place of the filter_frame() + * callback defined on each input pad, thus the frame is passed unchanged to + * the next filters. + */ +#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC (1 << 16) +/** + * Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will + * have its filter_frame() callback(s) called as usual even when the enable + * expression is false. The filter will disable filtering within the + * filter_frame() callback(s) itself, for example executing code depending on + * the AVFilterContext->is_disabled value. + */ +#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL (1 << 17) +/** + * Handy mask to test whether the filter supports or no the timeline feature + * (internally or generically). + */ +#define AVFILTER_FLAG_SUPPORT_TIMELINE (AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL) + +/** + * Filter definition. This defines the pads a filter contains, and all the + * callback functions used to interact with the filter. + */ +typedef struct AVFilter { + /** + * Filter name. Must be non-NULL and unique among filters. + */ + const char *name; + + /** + * A description of the filter. May be NULL. + * + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *description; + + /** + * List of inputs, terminated by a zeroed element. + * + * NULL if there are no (static) inputs. Instances of filters with + * AVFILTER_FLAG_DYNAMIC_INPUTS set may have more inputs than present in + * this list. + */ + const AVFilterPad *inputs; + /** + * List of outputs, terminated by a zeroed element. + * + * NULL if there are no (static) outputs. Instances of filters with + * AVFILTER_FLAG_DYNAMIC_OUTPUTS set may have more outputs than present in + * this list. + */ + const AVFilterPad *outputs; + + /** + * A class for the private data, used to declare filter private AVOptions. + * This field is NULL for filters that do not declare any options. + * + * If this field is non-NULL, the first member of the filter private data + * must be a pointer to AVClass, which will be set by libavfilter generic + * code to this class. + */ + const AVClass *priv_class; + + /** + * A combination of AVFILTER_FLAG_* + */ + int flags; + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavfilter and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + /** + * Filter initialization function. + * + * This callback will be called only once during the filter lifetime, after + * all the options have been set, but before links between filters are + * established and format negotiation is done. + * + * Basic filter initialization should be done here. Filters with dynamic + * inputs and/or outputs should create those inputs/outputs here based on + * provided options. No more changes to this filter's inputs/outputs can be + * done after this callback. + * + * This callback must not assume that the filter links exist or frame + * parameters are known. + * + * @ref AVFilter.uninit "uninit" is guaranteed to be called even if + * initialization fails, so this callback does not have to clean up on + * failure. + * + * @return 0 on success, a negative AVERROR on failure + */ + int (*init)(AVFilterContext *ctx); + + /** + * Should be set instead of @ref AVFilter.init "init" by the filters that + * want to pass a dictionary of AVOptions to nested contexts that are + * allocated during init. + * + * On return, the options dict should be freed and replaced with one that + * contains all the options which could not be processed by this filter (or + * with NULL if all the options were processed). + * + * Otherwise the semantics is the same as for @ref AVFilter.init "init". + */ + int (*init_dict)(AVFilterContext *ctx, AVDictionary **options); + + /** + * Filter uninitialization function. + * + * Called only once right before the filter is freed. Should deallocate any + * memory held by the filter, release any buffer references, etc. It does + * not need to deallocate the AVFilterContext.priv memory itself. + * + * This callback may be called even if @ref AVFilter.init "init" was not + * called or failed, so it must be prepared to handle such a situation. + */ + void (*uninit)(AVFilterContext *ctx); + + /** + * Query formats supported by the filter on its inputs and outputs. + * + * This callback is called after the filter is initialized (so the inputs + * and outputs are fixed), shortly before the format negotiation. This + * callback may be called more than once. + * + * This callback must set AVFilterLink.out_formats on every input link and + * AVFilterLink.in_formats on every output link to a list of pixel/sample + * formats that the filter supports on that link. For audio links, this + * filter must also set @ref AVFilterLink.in_samplerates "in_samplerates" / + * @ref AVFilterLink.out_samplerates "out_samplerates" and + * @ref AVFilterLink.in_channel_layouts "in_channel_layouts" / + * @ref AVFilterLink.out_channel_layouts "out_channel_layouts" analogously. + * + * This callback may be NULL for filters with one input, in which case + * libavfilter assumes that it supports all input formats and preserves + * them on output. + * + * @return zero on success, a negative value corresponding to an + * AVERROR code otherwise + */ + int (*query_formats)(AVFilterContext *); + + int priv_size; ///< size of private data to allocate for the filter + + /** + * Used by the filter registration system. Must not be touched by any other + * code. + */ + struct AVFilter *next; + + /** + * Make the filter instance process a command. + * + * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only + * @param arg the argument for the command + * @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported. + * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be + * time consuming then a filter should treat it like an unsupported command + * + * @returns >=0 on success otherwise an error code. + * AVERROR(ENOSYS) on unsupported commands + */ + int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags); + + /** + * Filter initialization function, alternative to the init() + * callback. Args contains the user-supplied parameters, opaque is + * used for providing binary data. + */ + int (*init_opaque)(AVFilterContext *ctx, void *opaque); +} AVFilter; + +/** + * Process multiple parts of the frame concurrently. + */ +#define AVFILTER_THREAD_SLICE (1 << 0) + +typedef struct AVFilterInternal AVFilterInternal; + +/** An instance of a filter */ +struct AVFilterContext { + const AVClass *av_class; ///< needed for av_log() and filters common options + + const AVFilter *filter; ///< the AVFilter of which this is an instance + + char *name; ///< name of this filter instance + + AVFilterPad *input_pads; ///< array of input pads + AVFilterLink **inputs; ///< array of pointers to input links +#if FF_API_FOO_COUNT + attribute_deprecated unsigned input_count; ///< @deprecated use nb_inputs +#endif + unsigned nb_inputs; ///< number of input pads + + AVFilterPad *output_pads; ///< array of output pads + AVFilterLink **outputs; ///< array of pointers to output links +#if FF_API_FOO_COUNT + attribute_deprecated unsigned output_count; ///< @deprecated use nb_outputs +#endif + unsigned nb_outputs; ///< number of output pads + + void *priv; ///< private data for use by the filter + + struct AVFilterGraph *graph; ///< filtergraph this filter belongs to + + /** + * Type of multithreading being allowed/used. A combination of + * AVFILTER_THREAD_* flags. + * + * May be set by the caller before initializing the filter to forbid some + * or all kinds of multithreading for this filter. The default is allowing + * everything. + * + * When the filter is initialized, this field is combined using bit AND with + * AVFilterGraph.thread_type to get the final mask used for determining + * allowed threading types. I.e. a threading type needs to be set in both + * to be allowed. + * + * After the filter is initialzed, libavfilter sets this field to the + * threading type that is actually used (0 for no multithreading). + */ + int thread_type; + + /** + * An opaque struct for libavfilter internal use. + */ + AVFilterInternal *internal; + + struct AVFilterCommand *command_queue; + + char *enable_str; ///< enable expression string + void *enable; ///< parsed expression (AVExpr*) + double *var_values; ///< variable values for the enable expression + int is_disabled; ///< the enabled state from the last expression evaluation +}; + +/** + * A link between two filters. This contains pointers to the source and + * destination filters between which this link exists, and the indexes of + * the pads involved. In addition, this link also contains the parameters + * which have been negotiated and agreed upon between the filter, such as + * image dimensions, format, etc. + */ +struct AVFilterLink { + AVFilterContext *src; ///< source filter + AVFilterPad *srcpad; ///< output pad on the source filter + + AVFilterContext *dst; ///< dest filter + AVFilterPad *dstpad; ///< input pad on the dest filter + + enum AVMediaType type; ///< filter media type + + /* These parameters apply only to video */ + int w; ///< agreed upon image width + int h; ///< agreed upon image height + AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio + /* These parameters apply only to audio */ + uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h) + int sample_rate; ///< samples per second + + int format; ///< agreed upon media format + + /** + * Define the time base used by the PTS of the frames/samples + * which will pass through this link. + * During the configuration stage, each filter is supposed to + * change only the output timebase, while the timebase of the + * input link is assumed to be an unchangeable property. + */ + AVRational time_base; + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavfilter and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + /** + * Lists of formats and channel layouts supported by the input and output + * filters respectively. These lists are used for negotiating the format + * to actually be used, which will be loaded into the format and + * channel_layout members, above, when chosen. + * + */ + AVFilterFormats *in_formats; + AVFilterFormats *out_formats; + + /** + * Lists of channel layouts and sample rates used for automatic + * negotiation. + */ + AVFilterFormats *in_samplerates; + AVFilterFormats *out_samplerates; + struct AVFilterChannelLayouts *in_channel_layouts; + struct AVFilterChannelLayouts *out_channel_layouts; + + /** + * Audio only, the destination filter sets this to a non-zero value to + * request that buffers with the given number of samples should be sent to + * it. AVFilterPad.needs_fifo must also be set on the corresponding input + * pad. + * Last buffer before EOF will be padded with silence. + */ + int request_samples; + + /** stage of the initialization of the link properties (dimensions, etc) */ + enum { + AVLINK_UNINIT = 0, ///< not started + AVLINK_STARTINIT, ///< started, but incomplete + AVLINK_INIT ///< complete + } init_state; + + struct AVFilterPool *pool; + + /** + * Graph the filter belongs to. + */ + struct AVFilterGraph *graph; + + /** + * Current timestamp of the link, as defined by the most recent + * frame(s), in AV_TIME_BASE units. + */ + int64_t current_pts; + + /** + * Index in the age array. + */ + int age_index; + + /** + * Frame rate of the stream on the link, or 1/0 if unknown; + * if left to 0/0, will be automatically be copied from the first input + * of the source filter if it exists. + * + * Sources should set it to the best estimation of the real frame rate. + * Filters should update it if necessary depending on their function. + * Sinks can use it to set a default output frame rate. + * It is similar to the r_frame_rate field in AVStream. + */ + AVRational frame_rate; + + /** + * Buffer partially filled with samples to achieve a fixed/minimum size. + */ + AVFrame *partial_buf; + + /** + * Size of the partial buffer to allocate. + * Must be between min_samples and max_samples. + */ + int partial_buf_size; + + /** + * Minimum number of samples to filter at once. If filter_frame() is + * called with fewer samples, it will accumulate them in partial_buf. + * This field and the related ones must not be changed after filtering + * has started. + * If 0, all related fields are ignored. + */ + int min_samples; + + /** + * Maximum number of samples to filter at once. If filter_frame() is + * called with more samples, it will split them. + */ + int max_samples; + + /** + * The buffer reference currently being received across the link by the + * destination filter. This is used internally by the filter system to + * allow automatic copying of buffers which do not have sufficient + * permissions for the destination. This should not be accessed directly + * by the filters. + */ + AVFilterBufferRef *cur_buf_copy; + + /** + * True if the link is closed. + * If set, all attemps of start_frame, filter_frame or request_frame + * will fail with AVERROR_EOF, and if necessary the reference will be + * destroyed. + * If request_frame returns AVERROR_EOF, this flag is set on the + * corresponding link. + * It can be set also be set by either the source or the destination + * filter. + */ + int closed; + + /** + * Number of channels. + */ + int channels; + + /** + * True if a frame is being requested on the link. + * Used internally by the framework. + */ + unsigned frame_requested; + + /** + * Link processing flags. + */ + unsigned flags; + + /** + * Number of past frames sent through the link. + */ + int64_t frame_count; +}; + +/** + * Link two filters together. + * + * @param src the source filter + * @param srcpad index of the output pad on the source filter + * @param dst the destination filter + * @param dstpad index of the input pad on the destination filter + * @return zero on success + */ +int avfilter_link(AVFilterContext *src, unsigned srcpad, + AVFilterContext *dst, unsigned dstpad); + +/** + * Free the link in *link, and set its pointer to NULL. + */ +void avfilter_link_free(AVFilterLink **link); + +/** + * Get the number of channels of a link. + */ +int avfilter_link_get_channels(AVFilterLink *link); + +/** + * Set the closed field of a link. + */ +void avfilter_link_set_closed(AVFilterLink *link, int closed); + +/** + * Negotiate the media format, dimensions, etc of all inputs to a filter. + * + * @param filter the filter to negotiate the properties for its inputs + * @return zero on successful negotiation + */ +int avfilter_config_links(AVFilterContext *filter); + +#if FF_API_AVFILTERBUFFER +/** + * Create a buffer reference wrapped around an already allocated image + * buffer. + * + * @param data pointers to the planes of the image to reference + * @param linesize linesizes for the planes of the image to reference + * @param perms the required access permissions + * @param w the width of the image specified by the data and linesize arrays + * @param h the height of the image specified by the data and linesize arrays + * @param format the pixel format of the image specified by the data and linesize arrays + */ +attribute_deprecated +AVFilterBufferRef * +avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms, + int w, int h, enum AVPixelFormat format); + +/** + * Create an audio buffer reference wrapped around an already + * allocated samples buffer. + * + * See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version + * that can handle unknown channel layouts. + * + * @param data pointers to the samples plane buffers + * @param linesize linesize for the samples plane buffers + * @param perms the required access permissions + * @param nb_samples number of samples per channel + * @param sample_fmt the format of each sample in the buffer to allocate + * @param channel_layout the channel layout of the buffer + */ +attribute_deprecated +AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, + int linesize, + int perms, + int nb_samples, + enum AVSampleFormat sample_fmt, + uint64_t channel_layout); +/** + * Create an audio buffer reference wrapped around an already + * allocated samples buffer. + * + * @param data pointers to the samples plane buffers + * @param linesize linesize for the samples plane buffers + * @param perms the required access permissions + * @param nb_samples number of samples per channel + * @param sample_fmt the format of each sample in the buffer to allocate + * @param channels the number of channels of the buffer + * @param channel_layout the channel layout of the buffer, + * must be either 0 or consistent with channels + */ +attribute_deprecated +AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data, + int linesize, + int perms, + int nb_samples, + enum AVSampleFormat sample_fmt, + int channels, + uint64_t channel_layout); + +#endif + + +#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically +#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw) + +/** + * Make the filter instance process a command. + * It is recommended to use avfilter_graph_send_command(). + */ +int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); + +/** Initialize the filter system. Register all builtin filters. */ +void avfilter_register_all(void); + +#if FF_API_OLD_FILTER_REGISTER +/** Uninitialize the filter system. Unregister all filters. */ +attribute_deprecated +void avfilter_uninit(void); +#endif + +/** + * Register a filter. This is only needed if you plan to use + * avfilter_get_by_name later to lookup the AVFilter structure by name. A + * filter can still by instantiated with avfilter_graph_alloc_filter even if it + * is not registered. + * + * @param filter the filter to register + * @return 0 if the registration was successful, a negative value + * otherwise + */ +int avfilter_register(AVFilter *filter); + +/** + * Get a filter definition matching the given name. + * + * @param name the filter name to find + * @return the filter definition, if any matching one is registered. + * NULL if none found. + */ +#if !FF_API_NOCONST_GET_NAME +const +#endif +AVFilter *avfilter_get_by_name(const char *name); + +/** + * Iterate over all registered filters. + * @return If prev is non-NULL, next registered filter after prev or NULL if + * prev is the last filter. If prev is NULL, return the first registered filter. + */ +const AVFilter *avfilter_next(const AVFilter *prev); + +#if FF_API_OLD_FILTER_REGISTER +/** + * If filter is NULL, returns a pointer to the first registered filter pointer, + * if filter is non-NULL, returns the next pointer after filter. + * If the returned pointer points to NULL, the last registered filter + * was already reached. + * @deprecated use avfilter_next() + */ +attribute_deprecated +AVFilter **av_filter_next(AVFilter **filter); +#endif + +#if FF_API_AVFILTER_OPEN +/** + * Create a filter instance. + * + * @param filter_ctx put here a pointer to the created filter context + * on success, NULL on failure + * @param filter the filter to create an instance of + * @param inst_name Name to give to the new instance. Can be NULL for none. + * @return >= 0 in case of success, a negative error code otherwise + * @deprecated use avfilter_graph_alloc_filter() instead + */ +attribute_deprecated +int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name); +#endif + + +#if FF_API_AVFILTER_INIT_FILTER +/** + * Initialize a filter. + * + * @param filter the filter to initialize + * @param args A string of parameters to use when initializing the filter. + * The format and meaning of this string varies by filter. + * @param opaque Any extra non-string data needed by the filter. The meaning + * of this parameter varies by filter. + * @return zero on success + */ +attribute_deprecated +int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque); +#endif + +/** + * Initialize a filter with the supplied parameters. + * + * @param ctx uninitialized filter context to initialize + * @param args Options to initialize the filter with. This must be a + * ':'-separated list of options in the 'key=value' form. + * May be NULL if the options have been set directly using the + * AVOptions API or there are no options that need to be set. + * @return 0 on success, a negative AVERROR on failure + */ +int avfilter_init_str(AVFilterContext *ctx, const char *args); + +/** + * Initialize a filter with the supplied dictionary of options. + * + * @param ctx uninitialized filter context to initialize + * @param options An AVDictionary filled with options for this filter. On + * return this parameter will be destroyed and replaced with + * a dict containing options that were not found. This dictionary + * must be freed by the caller. + * May be NULL, then this function is equivalent to + * avfilter_init_str() with the second parameter set to NULL. + * @return 0 on success, a negative AVERROR on failure + * + * @note This function and avfilter_init_str() do essentially the same thing, + * the difference is in manner in which the options are passed. It is up to the + * calling code to choose whichever is more preferable. The two functions also + * behave differently when some of the provided options are not declared as + * supported by the filter. In such a case, avfilter_init_str() will fail, but + * this function will leave those extra options in the options AVDictionary and + * continue as usual. + */ +int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options); + +/** + * Free a filter context. This will also remove the filter from its + * filtergraph's list of filters. + * + * @param filter the filter to free + */ +void avfilter_free(AVFilterContext *filter); + +/** + * Insert a filter in the middle of an existing link. + * + * @param link the link into which the filter should be inserted + * @param filt the filter to be inserted + * @param filt_srcpad_idx the input pad on the filter to connect + * @param filt_dstpad_idx the output pad on the filter to connect + * @return zero on success + */ +int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, + unsigned filt_srcpad_idx, unsigned filt_dstpad_idx); + +#if FF_API_AVFILTERBUFFER +/** + * Copy the frame properties of src to dst, without copying the actual + * image data. + * + * @return 0 on success, a negative number on error. + */ +attribute_deprecated +int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src); + +/** + * Copy the frame properties and data pointers of src to dst, without copying + * the actual data. + * + * @return 0 on success, a negative number on error. + */ +attribute_deprecated +int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src); +#endif + +/** + * @return AVClass for AVFilterContext. + * + * @see av_opt_find(). + */ +const AVClass *avfilter_get_class(void); + +typedef struct AVFilterGraphInternal AVFilterGraphInternal; + +/** + * A function pointer passed to the @ref AVFilterGraph.execute callback to be + * executed multiple times, possibly in parallel. + * + * @param ctx the filter context the job belongs to + * @param arg an opaque parameter passed through from @ref + * AVFilterGraph.execute + * @param jobnr the index of the job being executed + * @param nb_jobs the total number of jobs + * + * @return 0 on success, a negative AVERROR on error + */ +typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); + +/** + * A function executing multiple jobs, possibly in parallel. + * + * @param ctx the filter context to which the jobs belong + * @param func the function to be called multiple times + * @param arg the argument to be passed to func + * @param ret a nb_jobs-sized array to be filled with return values from each + * invocation of func + * @param nb_jobs the number of jobs to execute + * + * @return 0 on success, a negative AVERROR on error + */ +typedef int (avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *func, + void *arg, int *ret, int nb_jobs); + +typedef struct AVFilterGraph { + const AVClass *av_class; +#if FF_API_FOO_COUNT + attribute_deprecated + unsigned filter_count_unused; +#endif + AVFilterContext **filters; +#if !FF_API_FOO_COUNT + unsigned nb_filters; +#endif + + char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters + char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters +#if FF_API_FOO_COUNT + unsigned nb_filters; +#endif + + /** + * Type of multithreading allowed for filters in this graph. A combination + * of AVFILTER_THREAD_* flags. + * + * May be set by the caller at any point, the setting will apply to all + * filters initialized after that. The default is allowing everything. + * + * When a filter in this graph is initialized, this field is combined using + * bit AND with AVFilterContext.thread_type to get the final mask used for + * determining allowed threading types. I.e. a threading type needs to be + * set in both to be allowed. + */ + int thread_type; + + /** + * Maximum number of threads used by filters in this graph. May be set by + * the caller before adding any filters to the filtergraph. Zero (the + * default) means that the number of threads is determined automatically. + */ + int nb_threads; + + /** + * Opaque object for libavfilter internal use. + */ + AVFilterGraphInternal *internal; + + /** + * Opaque user data. May be set by the caller to an arbitrary value, e.g. to + * be used from callbacks like @ref AVFilterGraph.execute. + * Libavfilter will not touch this field in any way. + */ + void *opaque; + + /** + * This callback may be set by the caller immediately after allocating the + * graph and before adding any filters to it, to provide a custom + * multithreading implementation. + * + * If set, filters with slice threading capability will call this callback + * to execute multiple jobs in parallel. + * + * If this field is left unset, libavfilter will use its internal + * implementation, which may or may not be multithreaded depending on the + * platform and build options. + */ + avfilter_execute_func *execute; + + char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions + + /** + * Private fields + * + * The following fields are for internal use only. + * Their type, offset, number and semantic can change without notice. + */ + + AVFilterLink **sink_links; + int sink_links_count; + + unsigned disable_auto_convert; +} AVFilterGraph; + +/** + * Allocate a filter graph. + */ +AVFilterGraph *avfilter_graph_alloc(void); + +/** + * Create a new filter instance in a filter graph. + * + * @param graph graph in which the new filter will be used + * @param filter the filter to create an instance of + * @param name Name to give to the new instance (will be copied to + * AVFilterContext.name). This may be used by the caller to identify + * different filters, libavfilter itself assigns no semantics to + * this parameter. May be NULL. + * + * @return the context of the newly created filter instance (note that it is + * also retrievable directly through AVFilterGraph.filters or with + * avfilter_graph_get_filter()) on success or NULL or failure. + */ +AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, + const AVFilter *filter, + const char *name); + +/** + * Get a filter instance with name name from graph. + * + * @return the pointer to the found filter instance or NULL if it + * cannot be found. + */ +AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name); + +#if FF_API_AVFILTER_OPEN +/** + * Add an existing filter instance to a filter graph. + * + * @param graphctx the filter graph + * @param filter the filter to be added + * + * @deprecated use avfilter_graph_alloc_filter() to allocate a filter in a + * filter graph + */ +attribute_deprecated +int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter); +#endif + +/** + * Create and add a filter instance into an existing graph. + * The filter instance is created from the filter filt and inited + * with the parameters args and opaque. + * + * In case of success put in *filt_ctx the pointer to the created + * filter instance, otherwise set *filt_ctx to NULL. + * + * @param name the instance name to give to the created filter instance + * @param graph_ctx the filter graph + * @return a negative AVERROR error code in case of failure, a non + * negative value otherwise + */ +int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, + const char *name, const char *args, void *opaque, + AVFilterGraph *graph_ctx); + +/** + * Enable or disable automatic format conversion inside the graph. + * + * Note that format conversion can still happen inside explicitly inserted + * scale and aresample filters. + * + * @param flags any of the AVFILTER_AUTO_CONVERT_* constants + */ +void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags); + +enum { + AVFILTER_AUTO_CONVERT_ALL = 0, /**< all automatic conversions enabled */ + AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */ +}; + +/** + * Check validity and configure all the links and formats in the graph. + * + * @param graphctx the filter graph + * @param log_ctx context used for logging + * @return >= 0 in case of success, a negative AVERROR code otherwise + */ +int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx); + +/** + * Free a graph, destroy its links, and set *graph to NULL. + * If *graph is NULL, do nothing. + */ +void avfilter_graph_free(AVFilterGraph **graph); + +/** + * A linked-list of the inputs/outputs of the filter chain. + * + * This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(), + * where it is used to communicate open (unlinked) inputs and outputs from and + * to the caller. + * This struct specifies, per each not connected pad contained in the graph, the + * filter context and the pad index required for establishing a link. + */ +typedef struct AVFilterInOut { + /** unique name for this input/output in the list */ + char *name; + + /** filter context associated to this input/output */ + AVFilterContext *filter_ctx; + + /** index of the filt_ctx pad to use for linking */ + int pad_idx; + + /** next input/input in the list, NULL if this is the last */ + struct AVFilterInOut *next; +} AVFilterInOut; + +/** + * Allocate a single AVFilterInOut entry. + * Must be freed with avfilter_inout_free(). + * @return allocated AVFilterInOut on success, NULL on failure. + */ +AVFilterInOut *avfilter_inout_alloc(void); + +/** + * Free the supplied list of AVFilterInOut and set *inout to NULL. + * If *inout is NULL, do nothing. + */ +void avfilter_inout_free(AVFilterInOut **inout); + +#if AV_HAVE_INCOMPATIBLE_LIBAV_ABI || !FF_API_OLD_GRAPH_PARSE +/** + * Add a graph described by a string to a graph. + * + * @note The caller must provide the lists of inputs and outputs, + * which therefore must be known before calling the function. + * + * @note The inputs parameter describes inputs of the already existing + * part of the graph; i.e. from the point of view of the newly created + * part, they are outputs. Similarly the outputs parameter describes + * outputs of the already existing filters, which are provided as + * inputs to the parsed filters. + * + * @param graph the filter graph where to link the parsed grap context + * @param filters string to be parsed + * @param inputs linked list to the inputs of the graph + * @param outputs linked list to the outputs of the graph + * @return zero on success, a negative AVERROR code on error + */ +int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, + AVFilterInOut *inputs, AVFilterInOut *outputs, + void *log_ctx); +#else +/** + * Add a graph described by a string to a graph. + * + * @param graph the filter graph where to link the parsed graph context + * @param filters string to be parsed + * @param inputs pointer to a linked list to the inputs of the graph, may be NULL. + * If non-NULL, *inputs is updated to contain the list of open inputs + * after the parsing, should be freed with avfilter_inout_free(). + * @param outputs pointer to a linked list to the outputs of the graph, may be NULL. + * If non-NULL, *outputs is updated to contain the list of open outputs + * after the parsing, should be freed with avfilter_inout_free(). + * @return non negative on success, a negative AVERROR code on error + * @deprecated Use avfilter_graph_parse_ptr() instead. + */ +attribute_deprecated +int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, + AVFilterInOut **inputs, AVFilterInOut **outputs, + void *log_ctx); +#endif + +/** + * Add a graph described by a string to a graph. + * + * @param graph the filter graph where to link the parsed graph context + * @param filters string to be parsed + * @param inputs pointer to a linked list to the inputs of the graph, may be NULL. + * If non-NULL, *inputs is updated to contain the list of open inputs + * after the parsing, should be freed with avfilter_inout_free(). + * @param outputs pointer to a linked list to the outputs of the graph, may be NULL. + * If non-NULL, *outputs is updated to contain the list of open outputs + * after the parsing, should be freed with avfilter_inout_free(). + * @return non negative on success, a negative AVERROR code on error + */ +int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, + AVFilterInOut **inputs, AVFilterInOut **outputs, + void *log_ctx); + +/** + * Add a graph described by a string to a graph. + * + * @param[in] graph the filter graph where to link the parsed graph context + * @param[in] filters string to be parsed + * @param[out] inputs a linked list of all free (unlinked) inputs of the + * parsed graph will be returned here. It is to be freed + * by the caller using avfilter_inout_free(). + * @param[out] outputs a linked list of all free (unlinked) outputs of the + * parsed graph will be returned here. It is to be freed by the + * caller using avfilter_inout_free(). + * @return zero on success, a negative AVERROR code on error + * + * @note This function returns the inputs and outputs that are left + * unlinked after parsing the graph and the caller then deals with + * them. + * @note This function makes no reference whatsoever to already + * existing parts of the graph and the inputs parameter will on return + * contain inputs of the newly parsed part of the graph. Analogously + * the outputs parameter will contain outputs of the newly created + * filters. + */ +int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, + AVFilterInOut **inputs, + AVFilterInOut **outputs); + +/** + * Send a command to one or more filter instances. + * + * @param graph the filter graph + * @param target the filter(s) to which the command should be sent + * "all" sends to all filters + * otherwise it can be a filter or filter instance name + * which will send the command to all matching filters. + * @param cmd the command to send, for handling simplicity all commands must be alphanumeric only + * @param arg the argument for the command + * @param res a buffer with size res_size where the filter(s) can return a response. + * + * @returns >=0 on success otherwise an error code. + * AVERROR(ENOSYS) on unsupported commands + */ +int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags); + +/** + * Queue a command for one or more filter instances. + * + * @param graph the filter graph + * @param target the filter(s) to which the command should be sent + * "all" sends to all filters + * otherwise it can be a filter or filter instance name + * which will send the command to all matching filters. + * @param cmd the command to sent, for handling simplicity all commands must be alphanummeric only + * @param arg the argument for the command + * @param ts time at which the command should be sent to the filter + * + * @note As this executes commands after this function returns, no return code + * from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported. + */ +int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts); + + +/** + * Dump a graph into a human-readable string representation. + * + * @param graph the graph to dump + * @param options formatting options; currently ignored + * @return a string, or NULL in case of memory allocation failure; + * the string must be freed using av_free + */ +char *avfilter_graph_dump(AVFilterGraph *graph, const char *options); + +/** + * Request a frame on the oldest sink link. + * + * If the request returns AVERROR_EOF, try the next. + * + * Note that this function is not meant to be the sole scheduling mechanism + * of a filtergraph, only a convenience function to help drain a filtergraph + * in a balanced way under normal circumstances. + * + * Also note that AVERROR_EOF does not mean that frames did not arrive on + * some of the sinks during the process. + * When there are multiple sink links, in case the requested link + * returns an EOF, this may cause a filter to flush pending frames + * which are sent to another sink link, although unrequested. + * + * @return the return value of ff_request_frame(), + * or AVERROR_EOF if all links returned AVERROR_EOF + */ +int avfilter_graph_request_oldest(AVFilterGraph *graph); + +/** + * @} + */ + +#endif /* AVFILTER_AVFILTER_H */ diff --git a/extra_lib/include/libavfilter/avfiltergraph.h b/extra_lib/include/libavfilter/avfiltergraph.h new file mode 100644 index 0000000..b31d581 --- /dev/null +++ b/extra_lib/include/libavfilter/avfiltergraph.h @@ -0,0 +1,28 @@ +/* + * Filter graphs + * copyright (c) 2007 Bobby Bingham + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_AVFILTERGRAPH_H +#define AVFILTER_AVFILTERGRAPH_H + +#include "avfilter.h" +#include "libavutil/log.h" + +#endif /* AVFILTER_AVFILTERGRAPH_H */ diff --git a/extra_lib/include/libavfilter/buffersink.h b/extra_lib/include/libavfilter/buffersink.h new file mode 100644 index 0000000..24cd2fe --- /dev/null +++ b/extra_lib/include/libavfilter/buffersink.h @@ -0,0 +1,204 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_BUFFERSINK_H +#define AVFILTER_BUFFERSINK_H + +/** + * @file + * @ingroup lavfi_buffersink + * memory buffer sink API for audio and video + */ + +#include "avfilter.h" + +/** + * @defgroup lavfi_buffersink Buffer sink API + * @ingroup lavfi + * @{ + */ + +#if FF_API_AVFILTERBUFFER +/** + * Get an audio/video buffer data from buffer_sink and put it in bufref. + * + * This function works with both audio and video buffer sinks. + * + * @param buffer_sink pointer to a buffersink or abuffersink context + * @param flags a combination of AV_BUFFERSINK_FLAG_* flags + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + */ +attribute_deprecated +int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, + AVFilterBufferRef **bufref, int flags); + +/** + * Get the number of immediately available frames. + */ +attribute_deprecated +int av_buffersink_poll_frame(AVFilterContext *ctx); + +/** + * Get a buffer with filtered data from sink and put it in buf. + * + * @param ctx pointer to a context of a buffersink or abuffersink AVFilter. + * @param buf pointer to the buffer will be written here if buf is non-NULL. buf + * must be freed by the caller using avfilter_unref_buffer(). + * Buf may also be NULL to query whether a buffer is ready to be + * output. + * + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure. + */ +attribute_deprecated +int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf); + +/** + * Same as av_buffersink_read, but with the ability to specify the number of + * samples read. This function is less efficient than av_buffersink_read(), + * because it copies the data around. + * + * @param ctx pointer to a context of the abuffersink AVFilter. + * @param buf pointer to the buffer will be written here if buf is non-NULL. buf + * must be freed by the caller using avfilter_unref_buffer(). buf + * will contain exactly nb_samples audio samples, except at the end + * of stream, when it can contain less than nb_samples. + * Buf may also be NULL to query whether a buffer is ready to be + * output. + * + * @warning do not mix this function with av_buffersink_read(). Use only one or + * the other with a single sink, not both. + */ +attribute_deprecated +int av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf, + int nb_samples); +#endif + +/** + * Get a frame with filtered data from sink and put it in frame. + * + * @param ctx pointer to a buffersink or abuffersink filter context. + * @param frame pointer to an allocated frame that will be filled with data. + * The data must be freed using av_frame_unref() / av_frame_free() + * @param flags a combination of AV_BUFFERSINK_FLAG_* flags + * + * @return >= 0 in for success, a negative AVERROR code for failure. + */ +int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags); + +/** + * Tell av_buffersink_get_buffer_ref() to read video/samples buffer + * reference, but not remove it from the buffer. This is useful if you + * need only to read a video/samples buffer, without to fetch it. + */ +#define AV_BUFFERSINK_FLAG_PEEK 1 + +/** + * Tell av_buffersink_get_buffer_ref() not to request a frame from its input. + * If a frame is already buffered, it is read (and removed from the buffer), + * but if no frame is present, return AVERROR(EAGAIN). + */ +#define AV_BUFFERSINK_FLAG_NO_REQUEST 2 + +/** + * Struct to use for initializing a buffersink context. + */ +typedef struct { + const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE +} AVBufferSinkParams; + +/** + * Create an AVBufferSinkParams structure. + * + * Must be freed with av_free(). + */ +AVBufferSinkParams *av_buffersink_params_alloc(void); + +/** + * Struct to use for initializing an abuffersink context. + */ +typedef struct { + const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE + const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 + const int *channel_counts; ///< list of allowed channel counts, terminated by -1 + int all_channel_counts; ///< if not 0, accept any channel count or layout + int *sample_rates; ///< list of allowed sample rates, terminated by -1 +} AVABufferSinkParams; + +/** + * Create an AVABufferSinkParams structure. + * + * Must be freed with av_free(). + */ +AVABufferSinkParams *av_abuffersink_params_alloc(void); + +/** + * Set the frame size for an audio buffer sink. + * + * All calls to av_buffersink_get_buffer_ref will return a buffer with + * exactly the specified number of samples, or AVERROR(EAGAIN) if there is + * not enough. The last buffer at EOF will be padded with 0. + */ +void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size); + +/** + * Get the frame rate of the input. + */ +AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx); + +/** + * Get a frame with filtered data from sink and put it in frame. + * + * @param ctx pointer to a context of a buffersink or abuffersink AVFilter. + * @param frame pointer to an allocated frame that will be filled with data. + * The data must be freed using av_frame_unref() / av_frame_free() + * + * @return + * - >= 0 if a frame was successfully returned. + * - AVERROR(EAGAIN) if no frames are available at this point; more + * input frames must be added to the filtergraph to get more output. + * - AVERROR_EOF if there will be no more output frames on this sink. + * - A different negative AVERROR code in other failure cases. + */ +int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame); + +/** + * Same as av_buffersink_get_frame(), but with the ability to specify the number + * of samples read. This function is less efficient than + * av_buffersink_get_frame(), because it copies the data around. + * + * @param ctx pointer to a context of the abuffersink AVFilter. + * @param frame pointer to an allocated frame that will be filled with data. + * The data must be freed using av_frame_unref() / av_frame_free() + * frame will contain exactly nb_samples audio samples, except at + * the end of stream, when it can contain less than nb_samples. + * + * @return The return codes have the same meaning as for + * av_buffersink_get_samples(). + * + * @warning do not mix this function with av_buffersink_get_frame(). Use only one or + * the other with a single sink, not both. + */ +int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples); + +/** + * @} + */ + +#endif /* AVFILTER_BUFFERSINK_H */ diff --git a/extra_lib/include/libavfilter/buffersrc.h b/extra_lib/include/libavfilter/buffersrc.h new file mode 100644 index 0000000..5d12433 --- /dev/null +++ b/extra_lib/include/libavfilter/buffersrc.h @@ -0,0 +1,160 @@ +/* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_BUFFERSRC_H +#define AVFILTER_BUFFERSRC_H + +/** + * @file + * @ingroup lavfi_buffersrc + * Memory buffer source API. + */ + +#include "libavcodec/avcodec.h" +#include "avfilter.h" + +/** + * @defgroup lavfi_buffersrc Buffer source API + * @ingroup lavfi + * @{ + */ + +enum { + + /** + * Do not check for format changes. + */ + AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = 1, + +#if FF_API_AVFILTERBUFFER + /** + * Ignored + */ + AV_BUFFERSRC_FLAG_NO_COPY = 2, +#endif + + /** + * Immediately push the frame to the output. + */ + AV_BUFFERSRC_FLAG_PUSH = 4, + + /** + * Keep a reference to the frame. + * If the frame if reference-counted, create a new reference; otherwise + * copy the frame data. + */ + AV_BUFFERSRC_FLAG_KEEP_REF = 8, + +}; + +/** + * Add buffer data in picref to buffer_src. + * + * @param buffer_src pointer to a buffer source context + * @param picref a buffer reference, or NULL to mark EOF + * @param flags a combination of AV_BUFFERSRC_FLAG_* + * @return >= 0 in case of success, a negative AVERROR code + * in case of failure + */ +int av_buffersrc_add_ref(AVFilterContext *buffer_src, + AVFilterBufferRef *picref, int flags); + +/** + * Get the number of failed requests. + * + * A failed request is when the request_frame method is called while no + * frame is present in the buffer. + * The number is reset when a frame is added. + */ +unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src); + +#if FF_API_AVFILTERBUFFER +/** + * Add a buffer to a filtergraph. + * + * @param ctx an instance of the buffersrc filter + * @param buf buffer containing frame data to be passed down the filtergraph. + * This function will take ownership of buf, the user must not free it. + * A NULL buf signals EOF -- i.e. no more frames will be sent to this filter. + * + * @deprecated use av_buffersrc_write_frame() or av_buffersrc_add_frame() + */ +attribute_deprecated +int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf); +#endif + +/** + * Add a frame to the buffer source. + * + * @param ctx an instance of the buffersrc filter + * @param frame frame to be added. If the frame is reference counted, this + * function will make a new reference to it. Otherwise the frame data will be + * copied. + * + * @return 0 on success, a negative AVERROR on error + * + * This function is equivalent to av_buffersrc_add_frame_flags() with the + * AV_BUFFERSRC_FLAG_KEEP_REF flag. + */ +int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame); + +/** + * Add a frame to the buffer source. + * + * @param ctx an instance of the buffersrc filter + * @param frame frame to be added. If the frame is reference counted, this + * function will take ownership of the reference(s) and reset the frame. + * Otherwise the frame data will be copied. If this function returns an error, + * the input frame is not touched. + * + * @return 0 on success, a negative AVERROR on error. + * + * @note the difference between this function and av_buffersrc_write_frame() is + * that av_buffersrc_write_frame() creates a new reference to the input frame, + * while this function takes ownership of the reference passed to it. + * + * This function is equivalent to av_buffersrc_add_frame_flags() without the + * AV_BUFFERSRC_FLAG_KEEP_REF flag. + */ +int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame); + +/** + * Add a frame to the buffer source. + * + * By default, if the frame is reference-counted, this function will take + * ownership of the reference(s) and reset the frame. This can be controled + * using the flags. + * + * If this function returns an error, the input frame is not touched. + * + * @param buffer_src pointer to a buffer source context + * @param frame a frame, or NULL to mark EOF + * @param flags a combination of AV_BUFFERSRC_FLAG_* + * @return >= 0 in case of success, a negative AVERROR code + * in case of failure + */ +int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, + AVFrame *frame, int flags); + + +/** + * @} + */ + +#endif /* AVFILTER_BUFFERSRC_H */ diff --git a/extra_lib/include/libavfilter/version.h b/extra_lib/include/libavfilter/version.h new file mode 100644 index 0000000..a33ab49 --- /dev/null +++ b/extra_lib/include/libavfilter/version.h @@ -0,0 +1,95 @@ +/* + * Version macros. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_VERSION_H +#define AVFILTER_VERSION_H + +/** + * @file + * @ingroup lavfi + * Libavfilter version macros + */ + +#include "libavutil/version.h" + +#define LIBAVFILTER_VERSION_MAJOR 4 +#define LIBAVFILTER_VERSION_MINOR 2 +#define LIBAVFILTER_VERSION_MICRO 100 + +#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ + LIBAVFILTER_VERSION_MINOR, \ + LIBAVFILTER_VERSION_MICRO) +#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \ + LIBAVFILTER_VERSION_MINOR, \ + LIBAVFILTER_VERSION_MICRO) +#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT + +#define LIBAVFILTER_IDENT "Lavfi" AV_STRINGIFY(LIBAVFILTER_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_AVFILTERPAD_PUBLIC +#define FF_API_AVFILTERPAD_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_FOO_COUNT +#define FF_API_FOO_COUNT (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_FILL_FRAME +#define FF_API_FILL_FRAME (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_BUFFERSRC_BUFFER +#define FF_API_BUFFERSRC_BUFFER (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_AVFILTERBUFFER +#define FF_API_AVFILTERBUFFER (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_OLD_FILTER_OPTS +#define FF_API_OLD_FILTER_OPTS (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_ACONVERT_FILTER +#define FF_API_ACONVERT_FILTER (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_AVFILTER_OPEN +#define FF_API_AVFILTER_OPEN (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_AVFILTER_INIT_FILTER +#define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_OLD_FILTER_REGISTER +#define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_OLD_GRAPH_PARSE +#define FF_API_OLD_GRAPH_PARSE (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_DRAWTEXT_OLD_TIMELINE +#define FF_API_DRAWTEXT_OLD_TIMELINE (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_NOCONST_GET_NAME +#define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 5) +#endif +#ifndef FF_API_INTERLACE_LOWPASS_SET +#define FF_API_INTERLACE_LOWPASS_SET (LIBAVFILTER_VERSION_MAJOR < 5) +#endif + +#endif /* AVFILTER_VERSION_H */ diff --git a/extra_lib/include/libavresample/avresample.h b/extra_lib/include/libavresample/avresample.h new file mode 100644 index 0000000..dc392ad --- /dev/null +++ b/extra_lib/include/libavresample/avresample.h @@ -0,0 +1,417 @@ +/* + * Copyright (c) 2012 Justin Ruggles + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVRESAMPLE_AVRESAMPLE_H +#define AVRESAMPLE_AVRESAMPLE_H + +/** + * @file + * @ingroup lavr + * external API header + */ + +/** + * @defgroup lavr Libavresample + * @{ + * + * Libavresample (lavr) is a library that handles audio resampling, sample + * format conversion and mixing. + * + * Interaction with lavr is done through AVAudioResampleContext, which is + * allocated with avresample_alloc_context(). It is opaque, so all parameters + * must be set with the @ref avoptions API. + * + * For example the following code will setup conversion from planar float sample + * format to interleaved signed 16-bit integer, downsampling from 48kHz to + * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing + * matrix): + * @code + * AVAudioResampleContext *avr = avresample_alloc_context(); + * av_opt_set_int(avr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_int(avr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_int(avr, "in_sample_rate", 48000, 0); + * av_opt_set_int(avr, "out_sample_rate", 44100, 0); + * av_opt_set_int(avr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); + * av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + * @endcode + * + * Once the context is initialized, it must be opened with avresample_open(). If + * you need to change the conversion parameters, you must close the context with + * avresample_close(), change the parameters as described above, then reopen it + * again. + * + * The conversion itself is done by repeatedly calling avresample_convert(). + * Note that the samples may get buffered in two places in lavr. The first one + * is the output FIFO, where the samples end up if the output buffer is not + * large enough. The data stored in there may be retrieved at any time with + * avresample_read(). The second place is the resampling delay buffer, + * applicable only when resampling is done. The samples in it require more input + * before they can be processed. Their current amount is returned by + * avresample_get_delay(). At the end of conversion the resampling buffer can be + * flushed by calling avresample_convert() with NULL input. + * + * The following code demonstrates the conversion loop assuming the parameters + * from above and caller-defined functions get_input() and handle_output(): + * @code + * uint8_t **input; + * int in_linesize, in_samples; + * + * while (get_input(&input, &in_linesize, &in_samples)) { + * uint8_t *output + * int out_linesize; + * int out_samples = avresample_available(avr) + + * av_rescale_rnd(avresample_get_delay(avr) + + * in_samples, 44100, 48000, AV_ROUND_UP); + * av_samples_alloc(&output, &out_linesize, 2, out_samples, + * AV_SAMPLE_FMT_S16, 0); + * out_samples = avresample_convert(avr, &output, out_linesize, out_samples, + * input, in_linesize, in_samples); + * handle_output(output, out_linesize, out_samples); + * av_freep(&output); + * } + * @endcode + * + * When the conversion is finished and the FIFOs are flushed if required, the + * conversion context and everything associated with it must be freed with + * avresample_free(). + */ + +#include "libavutil/avutil.h" +#include "libavutil/channel_layout.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "libavresample/version.h" + +#define AVRESAMPLE_MAX_CHANNELS 32 + +typedef struct AVAudioResampleContext AVAudioResampleContext; + +/** Mixing Coefficient Types */ +enum AVMixCoeffType { + AV_MIX_COEFF_TYPE_Q8, /** 16-bit 8.8 fixed-point */ + AV_MIX_COEFF_TYPE_Q15, /** 32-bit 17.15 fixed-point */ + AV_MIX_COEFF_TYPE_FLT, /** floating-point */ + AV_MIX_COEFF_TYPE_NB, /** Number of coeff types. Not part of ABI */ +}; + +/** Resampling Filter Types */ +enum AVResampleFilterType { + AV_RESAMPLE_FILTER_TYPE_CUBIC, /**< Cubic */ + AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */ + AV_RESAMPLE_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */ +}; + +enum AVResampleDitherMethod { + AV_RESAMPLE_DITHER_NONE, /**< Do not use dithering */ + AV_RESAMPLE_DITHER_RECTANGULAR, /**< Rectangular Dither */ + AV_RESAMPLE_DITHER_TRIANGULAR, /**< Triangular Dither*/ + AV_RESAMPLE_DITHER_TRIANGULAR_HP, /**< Triangular Dither with High Pass */ + AV_RESAMPLE_DITHER_TRIANGULAR_NS, /**< Triangular Dither with Noise Shaping */ + AV_RESAMPLE_DITHER_NB, /**< Number of dither types. Not part of ABI. */ +}; + +/** + * Return the LIBAVRESAMPLE_VERSION_INT constant. + */ +unsigned avresample_version(void); + +/** + * Return the libavresample build-time configuration. + * @return configure string + */ +const char *avresample_configuration(void); + +/** + * Return the libavresample license. + */ +const char *avresample_license(void); + +/** + * Get the AVClass for AVAudioResampleContext. + * + * Can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options + * without allocating a context. + * + * @see av_opt_find(). + * + * @return AVClass for AVAudioResampleContext + */ +const AVClass *avresample_get_class(void); + +/** + * Allocate AVAudioResampleContext and set options. + * + * @return allocated audio resample context, or NULL on failure + */ +AVAudioResampleContext *avresample_alloc_context(void); + +/** + * Initialize AVAudioResampleContext. + * + * @param avr audio resample context + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_open(AVAudioResampleContext *avr); + +/** + * Check whether an AVAudioResampleContext is open or closed. + * + * @param avr AVAudioResampleContext to check + * @return 1 if avr is open, 0 if avr is closed. + */ +int avresample_is_open(AVAudioResampleContext *avr); + +/** + * Close AVAudioResampleContext. + * + * This closes the context, but it does not change the parameters. The context + * can be reopened with avresample_open(). It does, however, clear the output + * FIFO and any remaining leftover samples in the resampling delay buffer. If + * there was a custom matrix being used, that is also cleared. + * + * @see avresample_convert() + * @see avresample_set_matrix() + * + * @param avr audio resample context + */ +void avresample_close(AVAudioResampleContext *avr); + +/** + * Free AVAudioResampleContext and associated AVOption values. + * + * This also calls avresample_close() before freeing. + * + * @param avr audio resample context + */ +void avresample_free(AVAudioResampleContext **avr); + +/** + * Generate a channel mixing matrix. + * + * This function is the one used internally by libavresample for building the + * default mixing matrix. It is made public just as a utility function for + * building custom matrices. + * + * @param in_layout input channel layout + * @param out_layout output channel layout + * @param center_mix_level mix level for the center channel + * @param surround_mix_level mix level for the surround channel(s) + * @param lfe_mix_level mix level for the low-frequency effects channel + * @param normalize if 1, coefficients will be normalized to prevent + * overflow. if 0, coefficients will not be + * normalized. + * @param[out] matrix mixing coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o. + * @param stride distance between adjacent input channels in the + * matrix array + * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii) + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout, + double center_mix_level, double surround_mix_level, + double lfe_mix_level, int normalize, double *matrix, + int stride, enum AVMatrixEncoding matrix_encoding); + +/** + * Get the current channel mixing matrix. + * + * If no custom matrix has been previously set or the AVAudioResampleContext is + * not open, an error is returned. + * + * @param avr audio resample context + * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of + * input channel i in output channel o. + * @param stride distance between adjacent input channels in the matrix array + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, + int stride); + +/** + * Set channel mixing matrix. + * + * Allows for setting a custom mixing matrix, overriding the default matrix + * generated internally during avresample_open(). This function can be called + * anytime on an allocated context, either before or after calling + * avresample_open(), as long as the channel layouts have been set. + * avresample_convert() always uses the current matrix. + * Calling avresample_close() on the context will clear the current matrix. + * + * @see avresample_close() + * + * @param avr audio resample context + * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of + * input channel i in output channel o. + * @param stride distance between adjacent input channels in the matrix array + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix, + int stride); + +/** + * Set a customized input channel mapping. + * + * This function can only be called when the allocated context is not open. + * Also, the input channel layout must have already been set. + * + * Calling avresample_close() on the context will clear the channel mapping. + * + * The map for each input channel specifies the channel index in the source to + * use for that particular channel, or -1 to mute the channel. Source channels + * can be duplicated by using the same index for multiple input channels. + * + * Examples: + * + * Reordering 5.1 AAC order (C,L,R,Ls,Rs,LFE) to FFmpeg order (L,R,C,LFE,Ls,Rs): + * { 1, 2, 0, 5, 3, 4 } + * + * Muting the 3rd channel in 4-channel input: + * { 0, 1, -1, 3 } + * + * Duplicating the left channel of stereo input: + * { 0, 0 } + * + * @param avr audio resample context + * @param channel_map customized input channel mapping + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_channel_mapping(AVAudioResampleContext *avr, + const int *channel_map); + +/** + * Set compensation for resampling. + * + * This can be called anytime after avresample_open(). If resampling is not + * automatically enabled because of a sample rate conversion, the + * "force_resampling" option must have been set to 1 when opening the context + * in order to use resampling compensation. + * + * @param avr audio resample context + * @param sample_delta compensation delta, in samples + * @param compensation_distance compensation distance, in samples + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, + int compensation_distance); + +/** + * Convert input samples and write them to the output FIFO. + * + * The upper bound on the number of output samples is given by + * avresample_available() + (avresample_get_delay() + number of input samples) * + * output sample rate / input sample rate. + * + * The output data can be NULL or have fewer allocated samples than required. + * In this case, any remaining samples not written to the output will be added + * to an internal FIFO buffer, to be returned at the next call to this function + * or to avresample_read(). + * + * If converting sample rate, there may be data remaining in the internal + * resampling delay buffer. avresample_get_delay() tells the number of remaining + * samples. To get this data as output, call avresample_convert() with NULL + * input. + * + * At the end of the conversion process, there may be data remaining in the + * internal FIFO buffer. avresample_available() tells the number of remaining + * samples. To get this data as output, either call avresample_convert() with + * NULL input or call avresample_read(). + * + * @see avresample_available() + * @see avresample_read() + * @see avresample_get_delay() + * + * @param avr audio resample context + * @param output output data pointers + * @param out_plane_size output plane size, in bytes. + * This can be 0 if unknown, but that will lead to + * optimized functions not being used directly on the + * output, which could slow down some conversions. + * @param out_samples maximum number of samples that the output buffer can hold + * @param input input data pointers + * @param in_plane_size input plane size, in bytes + * This can be 0 if unknown, but that will lead to + * optimized functions not being used directly on the + * input, which could slow down some conversions. + * @param in_samples number of input samples to convert + * @return number of samples written to the output buffer, + * not including converted samples added to the internal + * output FIFO + */ +int avresample_convert(AVAudioResampleContext *avr, uint8_t **output, + int out_plane_size, int out_samples, uint8_t **input, + int in_plane_size, int in_samples); + +/** + * Return the number of samples currently in the resampling delay buffer. + * + * When resampling, there may be a delay between the input and output. Any + * unconverted samples in each call are stored internally in a delay buffer. + * This function allows the user to determine the current number of samples in + * the delay buffer, which can be useful for synchronization. + * + * @see avresample_convert() + * + * @param avr audio resample context + * @return number of samples currently in the resampling delay buffer + */ +int avresample_get_delay(AVAudioResampleContext *avr); + +/** + * Return the number of available samples in the output FIFO. + * + * During conversion, if the user does not specify an output buffer or + * specifies an output buffer that is smaller than what is needed, remaining + * samples that are not written to the output are stored to an internal FIFO + * buffer. The samples in the FIFO can be read with avresample_read() or + * avresample_convert(). + * + * @see avresample_read() + * @see avresample_convert() + * + * @param avr audio resample context + * @return number of samples available for reading + */ +int avresample_available(AVAudioResampleContext *avr); + +/** + * Read samples from the output FIFO. + * + * During conversion, if the user does not specify an output buffer or + * specifies an output buffer that is smaller than what is needed, remaining + * samples that are not written to the output are stored to an internal FIFO + * buffer. This function can be used to read samples from that internal FIFO. + * + * @see avresample_available() + * @see avresample_convert() + * + * @param avr audio resample context + * @param output output data pointers. May be NULL, in which case + * nb_samples of data is discarded from output FIFO. + * @param nb_samples number of samples to read from the FIFO + * @return the number of samples written to output + */ +int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples); + +/** + * @} + */ + +#endif /* AVRESAMPLE_AVRESAMPLE_H */ diff --git a/extra_lib/include/libavresample/version.h b/extra_lib/include/libavresample/version.h new file mode 100644 index 0000000..d865ad2 --- /dev/null +++ b/extra_lib/include/libavresample/version.h @@ -0,0 +1,54 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVRESAMPLE_VERSION_H +#define AVRESAMPLE_VERSION_H + +/** + * @file + * @ingroup lavr + * Libavresample version macros. + */ + +#include "libavutil/version.h" + +#define LIBAVRESAMPLE_VERSION_MAJOR 1 +#define LIBAVRESAMPLE_VERSION_MINOR 2 +#define LIBAVRESAMPLE_VERSION_MICRO 0 + +#define LIBAVRESAMPLE_VERSION_INT AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR, \ + LIBAVRESAMPLE_VERSION_MINOR, \ + LIBAVRESAMPLE_VERSION_MICRO) +#define LIBAVRESAMPLE_VERSION AV_VERSION(LIBAVRESAMPLE_VERSION_MAJOR, \ + LIBAVRESAMPLE_VERSION_MINOR, \ + LIBAVRESAMPLE_VERSION_MICRO) +#define LIBAVRESAMPLE_BUILD LIBAVRESAMPLE_VERSION_INT + +#define LIBAVRESAMPLE_IDENT "Lavr" AV_STRINGIFY(LIBAVRESAMPLE_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_RESAMPLE_CLOSE_OPEN +#define FF_API_RESAMPLE_CLOSE_OPEN (LIBAVRESAMPLE_VERSION_MAJOR < 2) +#endif + +#endif /* AVRESAMPLE_VERSION_H */ diff --git a/extra_lib/include/libswresample/swresample.h b/extra_lib/include/libswresample/swresample.h new file mode 100644 index 0000000..4ba008e --- /dev/null +++ b/extra_lib/include/libswresample/swresample.h @@ -0,0 +1,318 @@ +/* + * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at) + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWRESAMPLE_SWRESAMPLE_H +#define SWRESAMPLE_SWRESAMPLE_H + +/** + * @file + * @ingroup lswr + * libswresample public header + */ + +/** + * @defgroup lswr Libswresample + * @{ + * + * Libswresample (lswr) is a library that handles audio resampling, sample + * format conversion and mixing. + * + * Interaction with lswr is done through SwrContext, which is + * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters + * must be set with the @ref avoptions API. + * + * For example the following code will setup conversion from planar float sample + * format to interleaved signed 16-bit integer, downsampling from 48kHz to + * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing + * matrix): + * @code + * SwrContext *swr = swr_alloc(); + * av_opt_set_channel_layout(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_channel_layout(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_int(swr, "in_sample_rate", 48000, 0); + * av_opt_set_int(swr, "out_sample_rate", 44100, 0); + * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); + * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + * @endcode + * + * Once all values have been set, it must be initialized with swr_init(). If + * you need to change the conversion parameters, you can change the parameters + * as described above, or by using swr_alloc_set_opts(), then call swr_init() + * again. + * + * The conversion itself is done by repeatedly calling swr_convert(). + * Note that the samples may get buffered in swr if you provide insufficient + * output space or if sample rate conversion is done, which requires "future" + * samples. Samples that do not require future input can be retrieved at any + * time by using swr_convert() (in_count can be set to 0). + * At the end of conversion the resampling buffer can be flushed by calling + * swr_convert() with NULL in and 0 in_count. + * + * The delay between input and output, can at any time be found by using + * swr_get_delay(). + * + * The following code demonstrates the conversion loop assuming the parameters + * from above and caller-defined functions get_input() and handle_output(): + * @code + * uint8_t **input; + * int in_samples; + * + * while (get_input(&input, &in_samples)) { + * uint8_t *output; + * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) + + * in_samples, 44100, 48000, AV_ROUND_UP); + * av_samples_alloc(&output, NULL, 2, out_samples, + * AV_SAMPLE_FMT_S16, 0); + * out_samples = swr_convert(swr, &output, out_samples, + * input, in_samples); + * handle_output(output, out_samples); + * av_freep(&output); + * } + * @endcode + * + * When the conversion is finished, the conversion + * context and everything associated with it must be freed with swr_free(). + * There will be no memory leak if the data is not completely flushed before + * swr_free(). + */ + +#include +#include "libavutil/samplefmt.h" + +#include "libswresample/version.h" + +#if LIBSWRESAMPLE_VERSION_MAJOR < 1 +#define SWR_CH_MAX 32 ///< Maximum number of channels +#endif + +#define SWR_FLAG_RESAMPLE 1 ///< Force resampling even if equal sample rate +//TODO use int resample ? +//long term TODO can we enable this dynamically? + +enum SwrDitherType { + SWR_DITHER_NONE = 0, + SWR_DITHER_RECTANGULAR, + SWR_DITHER_TRIANGULAR, + SWR_DITHER_TRIANGULAR_HIGHPASS, + + SWR_DITHER_NS = 64, ///< not part of API/ABI + SWR_DITHER_NS_LIPSHITZ, + SWR_DITHER_NS_F_WEIGHTED, + SWR_DITHER_NS_MODIFIED_E_WEIGHTED, + SWR_DITHER_NS_IMPROVED_E_WEIGHTED, + SWR_DITHER_NS_SHIBATA, + SWR_DITHER_NS_LOW_SHIBATA, + SWR_DITHER_NS_HIGH_SHIBATA, + SWR_DITHER_NB, ///< not part of API/ABI +}; + +/** Resampling Engines */ +enum SwrEngine { + SWR_ENGINE_SWR, /**< SW Resampler */ + SWR_ENGINE_SOXR, /**< SoX Resampler */ + SWR_ENGINE_NB, ///< not part of API/ABI +}; + +/** Resampling Filter Types */ +enum SwrFilterType { + SWR_FILTER_TYPE_CUBIC, /**< Cubic */ + SWR_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */ + SWR_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */ +}; + +typedef struct SwrContext SwrContext; + +/** + * Get the AVClass for swrContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *swr_get_class(void); + +/** + * Allocate SwrContext. + * + * If you use this function you will need to set the parameters (manually or + * with swr_alloc_set_opts()) before calling swr_init(). + * + * @see swr_alloc_set_opts(), swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc(void); + +/** + * Initialize context after user parameters have been set. + * + * @return AVERROR error code in case of failure. + */ +int swr_init(struct SwrContext *s); + +/** + * Check whether an swr context has been initialized or not. + * + * @return positive if it has been initialized, 0 if not initialized + */ +int swr_is_initialized(struct SwrContext *s); + +/** + * Allocate SwrContext if needed and set/reset common parameters. + * + * This function does not require s to be allocated with swr_alloc(). On the + * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters + * on the allocated context. + * + * @param s Swr context, can be NULL + * @param out_ch_layout output channel layout (AV_CH_LAYOUT_*) + * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*). + * @param out_sample_rate output sample rate (frequency in Hz) + * @param in_ch_layout input channel layout (AV_CH_LAYOUT_*) + * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*). + * @param in_sample_rate input sample rate (frequency in Hz) + * @param log_offset logging level offset + * @param log_ctx parent logging context, can be NULL + * + * @see swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, + int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + int log_offset, void *log_ctx); + +/** + * Free the given SwrContext and set the pointer to NULL. + */ +void swr_free(struct SwrContext **s); + +/** + * Convert audio. + * + * in and in_count can be set to 0 to flush the last few samples out at the + * end. + * + * If more input is provided than output space then the input will be buffered. + * You can avoid this buffering by providing more output space than input. + * Convertion will run directly without copying whenever possible. + * + * @param s allocated Swr context, with parameters set + * @param out output buffers, only the first one need be set in case of packed audio + * @param out_count amount of space available for output in samples per channel + * @param in input buffers, only the first one need to be set in case of packed audio + * @param in_count number of input samples available in one channel + * + * @return number of samples output per channel, negative value on error + */ +int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, + const uint8_t **in , int in_count); + +/** + * Convert the next timestamp from input to output + * timestamps are in 1/(in_sample_rate * out_sample_rate) units. + * + * @note There are 2 slightly differently behaving modes. + * First is when automatic timestamp compensation is not used, (min_compensation >= FLT_MAX) + * in this case timestamps will be passed through with delays compensated + * Second is when automatic timestamp compensation is used, (min_compensation < FLT_MAX) + * in this case the output timestamps will match output sample numbers + * + * @param pts timestamp for the next input sample, INT64_MIN if unknown + * @return the output timestamp for the next output sample + */ +int64_t swr_next_pts(struct SwrContext *s, int64_t pts); + +/** + * Activate resampling compensation. + */ +int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance); + +/** + * Set a customized input channel mapping. + * + * @param s allocated Swr context, not yet initialized + * @param channel_map customized input channel mapping (array of channel + * indexes, -1 for a muted channel) + * @return AVERROR error code in case of failure. + */ +int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); + +/** + * Set a customized remix matrix. + * + * @param s allocated Swr context, not yet initialized + * @param matrix remix coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o + * @param stride offset between lines of the matrix + * @return AVERROR error code in case of failure. + */ +int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride); + +/** + * Drops the specified number of output samples. + */ +int swr_drop_output(struct SwrContext *s, int count); + +/** + * Injects the specified number of silence samples. + */ +int swr_inject_silence(struct SwrContext *s, int count); + +/** + * Gets the delay the next input sample will experience relative to the next output sample. + * + * Swresample can buffer data if more input has been provided than available + * output space, also converting between sample rates needs a delay. + * This function returns the sum of all such delays. + * The exact delay is not necessarily an integer value in either input or + * output sample rate. Especially when downsampling by a large value, the + * output sample rate may be a poor choice to represent the delay, similarly + * for upsampling and the input sample rate. + * + * @param s swr context + * @param base timebase in which the returned delay will be + * if its set to 1 the returned delay is in seconds + * if its set to 1000 the returned delay is in milli seconds + * if its set to the input sample rate then the returned delay is in input samples + * if its set to the output sample rate then the returned delay is in output samples + * an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate) + * @returns the delay in 1/base units. + */ +int64_t swr_get_delay(struct SwrContext *s, int64_t base); + +/** + * Return the LIBSWRESAMPLE_VERSION_INT constant. + */ +unsigned swresample_version(void); + +/** + * Return the swr build-time configuration. + */ +const char *swresample_configuration(void); + +/** + * Return the swr license. + */ +const char *swresample_license(void); + +/** + * @} + */ + +#endif /* SWRESAMPLE_SWRESAMPLE_H */ diff --git a/extra_lib/include/libswresample/version.h b/extra_lib/include/libswresample/version.h new file mode 100644 index 0000000..3a92875 --- /dev/null +++ b/extra_lib/include/libswresample/version.h @@ -0,0 +1,45 @@ +/* + * Version macros. + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWR_VERSION_H +#define SWR_VERSION_H + +/** + * @file + * Libswresample version macros + */ + +#include "libavutil/avutil.h" + +#define LIBSWRESAMPLE_VERSION_MAJOR 0 +#define LIBSWRESAMPLE_VERSION_MINOR 18 +#define LIBSWRESAMPLE_VERSION_MICRO 100 + +#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_VERSION AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_BUILD LIBSWRESAMPLE_VERSION_INT + +#define LIBSWRESAMPLE_IDENT "SwR" AV_STRINGIFY(LIBSWRESAMPLE_VERSION) + +#endif /* SWR_VERSION_H */ diff --git a/extra_lib/include/openHevcWrapper.h b/extra_lib/include/openHevcWrapper.h index 1d49ebf..349c0ee 100644 --- a/extra_lib/include/openHevcWrapper.h +++ b/extra_lib/include/openHevcWrapper.h @@ -1,7 +1,28 @@ +/* + * openhevc.h wrapper to openhevc or ffmpeg + * Copyright (c) 2012-2013 Micka�l Raulet, Wassim Hamidouche, Gildas Cocherel, Pierre Edouard Lepere + * + * This file is part of openhevc. + * + * openHevc is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * openhevc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with openhevc; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef OPEN_HEVC_WRAPPER_H #define OPEN_HEVC_WRAPPER_H -#define NV_VERSION "1.2" ///< Current software version +#define NV_VERSION "2.0" ///< Current software version #ifdef __cplusplus extern "C" { @@ -53,20 +74,20 @@ int libOpenHevcDecode(OpenHevc_Handle openHevcHandle, const unsigned char *buff void libOpenHevcGetPictureInfo(OpenHevc_Handle openHevcHandle, OpenHevc_FrameInfo *openHevcFrameInfo); void libOpenHevcCopyExtraData(OpenHevc_Handle openHevcHandle, unsigned char *extra_data, int extra_size_alloc); -void libOpenHevcGetPictureSize2(OpenHevc_Handle openHevcHandle, OpenHevc_FrameInfo *openHevcFrameInfo); +void libOpenHevcGetPictureInfoCpy(OpenHevc_Handle openHevcHandle, OpenHevc_FrameInfo *openHevcFrameInfo); int libOpenHevcGetOutput(OpenHevc_Handle openHevcHandle, int got_picture, OpenHevc_Frame *openHevcFrame); int libOpenHevcGetOutputCpy(OpenHevc_Handle openHevcHandle, int got_picture, OpenHevc_Frame_cpy *openHevcFrame); void libOpenHevcSetCheckMD5(OpenHevc_Handle openHevcHandle, int val); void libOpenHevcSetDebugMode(OpenHevc_Handle openHevcHandle, int val); void libOpenHevcSetTemporalLayer_id(OpenHevc_Handle openHevcHandle, int val); void libOpenHevcSetNoCropping(OpenHevc_Handle openHevcHandle, int val); - +void libOpenHevcSetActiveDecoders(OpenHevc_Handle openHevcHandle, int val); +void libOpenHevcSetViewLayers(OpenHevc_Handle openHevcHandle, int val); void libOpenHevcClose(OpenHevc_Handle openHevcHandle); void libOpenHevcFlush(OpenHevc_Handle openHevcHandle); -const char *libOpenHevcVersion(OpenHevc_Handle openHevcHandle); +void libOpenHevcFlushSVC(OpenHevc_Handle openHevcHandle, int decoderId); -void libOpenHevcSetActiveDecoders(OpenHevc_Handle openHevcHandle, int val); -void libOpenHevcSetViewLayers(OpenHevc_Handle openHevcHandle, int val); +const char *libOpenHevcVersion(OpenHevc_Handle openHevcHandle); #ifdef __cplusplus } diff --git a/include/gpac/ait.h b/include/gpac/ait.h index 876fb74..1247411 100644 --- a/include/gpac/ait.h +++ b/include/gpac/ait.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) TELECOM ParisTech 2011 */ @@ -32,9 +32,9 @@ typedef enum { } DESCRIPTOR_TAG; enum ApplicationControlCode { - AUTOSTART = 0x01, - PRESENT = 0x02, - DESTROY = 0x03, + AUTOSTART = 0x01, + PRESENT = 0x02, + DESTROY = 0x03, KILL = 0x04, PREFETCH = 0x05, REMOTE = 0x06, @@ -72,7 +72,7 @@ typedef struct typedef struct { ABSTRACT_ES - GF_M2TS_SectionFilter *sec; + GF_M2TS_SectionFilter *sec; } GF_M2TS_AIT_CARRY; @@ -87,7 +87,7 @@ typedef struct u8 application_descriptors_id[50]; u8 index_app_desc_id; -}GF_M2TS_AIT_APPLICATION_DECODE; +} GF_M2TS_AIT_APPLICATION_DECODE; typedef enum { @@ -129,7 +129,7 @@ typedef struct u8 descriptor_length; char* initial_path_bytes; -}GF_M2TS_SIMPLE_APPLICATION_LOCATION; +} GF_M2TS_SIMPLE_APPLICATION_LOCATION; typedef struct { @@ -141,19 +141,19 @@ typedef struct } GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE; -typedef struct{ +typedef struct { u8 URL_extension_length; char* URL_extension_byte; -}GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION; +} GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION; typedef struct { u8 URL_base_length; char* URL_base_byte; u8 URL_extension_count; - GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION* URL_extentions; + GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION* URL_extentions; } GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE; @@ -194,7 +194,7 @@ typedef struct } GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR; typedef struct -{ +{ u32 application_id; u8 application_control_code; @@ -211,7 +211,7 @@ typedef struct /* Carousel */ u32 carousel_pid; u32 component_tag; - + char* appli_name; @@ -223,7 +223,7 @@ typedef struct u32 version_number; u32 ait_pid; u32 nb_application; - GF_List *Application; + GF_List *Application; } GF_M2TS_CHANNEL_APPLICATION_INFO; diff --git a/include/gpac/avparse.h b/include/gpac/avparse.h index c5b2260..05d87b4 100644 --- a/include/gpac/avparse.h +++ b/include/gpac/avparse.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -133,44 +133,44 @@ u32 gf_vorbis_check_frame(GF_VorbisParser *vp, char *data, u32 data_length); enum { - GF_M4A_AAC_MAIN = 1, - GF_M4A_AAC_LC = 2, - GF_M4A_AAC_SSR = 3, - GF_M4A_AAC_LTP = 4, - GF_M4A_AAC_SBR = 5, - GF_M4A_AAC_SCALABLE = 6, - GF_M4A_TWINVQ = 7, - GF_M4A_CELP = 8, - GF_M4A_HVXC = 9, - GF_M4A_TTSI = 12, - GF_M4A_MAIN_SYNTHETIC = 13, - GF_M4A_WAVETABLE_SYNTHESIS = 14, - GF_M4A_GENERAL_MIDI = 15, - GF_M4A_ALGO_SYNTH_AUDIO_FX = 16, - GF_M4A_ER_AAC_LC = 17, - GF_M4A_ER_AAC_LTP = 19, - GF_M4A_ER_AAC_SCALABLE = 20, - GF_M4A_ER_TWINVQ = 21, - GF_M4A_ER_BSAC = 22, - GF_M4A_ER_AAC_LD = 23, - GF_M4A_ER_CELP = 24, - GF_M4A_ER_HVXC = 25, - GF_M4A_ER_HILN = 26, - GF_M4A_ER_PARAMETRIC = 27, - GF_M4A_SSC = 28, - GF_M4A_AAC_PS = 29, - GF_M4A_LAYER1 = 32, - GF_M4A_LAYER2 = 33, - GF_M4A_LAYER3 = 34, - GF_M4A_DST = 35, - GF_M4A_ALS = 36 + GF_M4A_AAC_MAIN = 1, + GF_M4A_AAC_LC = 2, + GF_M4A_AAC_SSR = 3, + GF_M4A_AAC_LTP = 4, + GF_M4A_AAC_SBR = 5, + GF_M4A_AAC_SCALABLE = 6, + GF_M4A_TWINVQ = 7, + GF_M4A_CELP = 8, + GF_M4A_HVXC = 9, + GF_M4A_TTSI = 12, + GF_M4A_MAIN_SYNTHETIC = 13, + GF_M4A_WAVETABLE_SYNTHESIS = 14, + GF_M4A_GENERAL_MIDI = 15, + GF_M4A_ALGO_SYNTH_AUDIO_FX = 16, + GF_M4A_ER_AAC_LC = 17, + GF_M4A_ER_AAC_LTP = 19, + GF_M4A_ER_AAC_SCALABLE = 20, + GF_M4A_ER_TWINVQ = 21, + GF_M4A_ER_BSAC = 22, + GF_M4A_ER_AAC_LD = 23, + GF_M4A_ER_CELP = 24, + GF_M4A_ER_HVXC = 25, + GF_M4A_ER_HILN = 26, + GF_M4A_ER_PARAMETRIC = 27, + GF_M4A_SSC = 28, + GF_M4A_AAC_PS = 29, + GF_M4A_LAYER1 = 32, + GF_M4A_LAYER2 = 33, + GF_M4A_LAYER3 = 34, + GF_M4A_DST = 35, + GF_M4A_ALS = 36 }; #ifndef GPAC_DISABLE_AV_PARSERS static const u32 GF_M4ASampleRates[] = { - 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 }; @@ -230,7 +230,7 @@ const char *gf_hevc_get_profile_name(u8 video_prof); -/*gets image size (bs must contain the whole image) +/*gets image size (bs must contain the whole image) @OTI: image type (JPEG=0x6C, PNG=0x6D) @width, height: image resolution - for jpeg max size if thumbnail included*/ void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height, char **dsi, u32 *dsi_len); diff --git a/include/gpac/base_coding.h b/include/gpac/base_coding.h index 7db5141..e6a751d 100644 --- a/include/gpac/base_coding.h +++ b/include/gpac/base_coding.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/bifs.h b/include/gpac/bifs.h index 7f2b7cb..0db9540 100644 --- a/include/gpac/bifs.h +++ b/include/gpac/bifs.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ extern "C" { typedef struct __tag_bifs_dec GF_BifsDecoder; -/*BIFS decoder constructor - +/*BIFS decoder constructor - @command_dec: if set, the decoder will only work in memory mode (creating commands for the graph) otherwise the decoder will always apply commands while decoding them*/ GF_BifsDecoder *gf_bifs_decoder_new(GF_SceneGraph *scenegraph, Bool command_dec); diff --git a/include/gpac/bitstream.h b/include/gpac/bitstream.h index 4620d74..f35cfbd 100644 --- a/include/gpac/bitstream.h +++ b/include/gpac/bitstream.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -61,17 +61,17 @@ typedef struct __tag_bitstream GF_BitStream; * * Constructs a bitstream from a buffer (read or write mode) * \param buffer buffer to read or write. In WRITE mode, this can be NULL to let the bitstream object dynamically allocate memory, in which case the size param is ignored. - * \param size size of the buffer given. + * \param size size of the buffer given. * \param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write. * \return new bitstream object - * \note In write mode on an existing data buffer, data overflow is never signaled but simply ignored, it is the caller responsability to ensure it + * \note In write mode on an existing data buffer, data overflow is never signaled but simply ignored, it is the caller responsability to ensure it * does not write more than possible. */ GF_BitStream *gf_bs_new(const char *buffer, u64 size, u32 mode); /*! * \brief bitstream constructor from file handle * - * Creates a bitstream from a file handle. + * Creates a bitstream from a file handle. * \param f handle of the file to use. This handle must be created with binary mode. * \param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write. * \return new bitstream object @@ -92,8 +92,8 @@ void gf_bs_del(GF_BitStream *bs); /*! * \brief sets bitstream write cache size * - * Sets the write cache size for file-based bitstreams. - * \param bs the target bitstream + * Sets the write cache size for file-based bitstreams. + * \param bs the target bitstream * \param size size of the write cache in bytes * \return error if any. */ @@ -103,8 +103,8 @@ GF_Err gf_bs_set_output_buffering(GF_BitStream *bs, u32 size); /*! * \brief gets bitstream write cache size * - * Gets the write cache size for file-based bitstreams. - * \param bs the target bitstream + * Gets the write cache size for file-based bitstreams. + * \param bs the target bitstream * \return size of the write cache in bytes, 0 if no cache */ u32 gf_bs_get_output_buffering(GF_BitStream *bs); @@ -113,7 +113,7 @@ u32 gf_bs_get_output_buffering(GF_BitStream *bs); * \brief integer reading * * Reads an integer coded on a number of bit. - * \param bs the target bitstream + * \param bs the target bitstream * \param nBits the number of bits to read * \return the integer value read. */ @@ -122,7 +122,7 @@ u32 gf_bs_read_int(GF_BitStream *bs, u32 nBits); * \brief large integer reading * * Reads a large integer coded on a number of bit bigger than 32. - * \param bs the target bitstream + * \param bs the target bitstream * \param nBits the number of bits to read * \return the large integer value read. */ @@ -131,7 +131,7 @@ u64 gf_bs_read_long_int(GF_BitStream *bs, u32 nBits); * \brief float reading * * Reads a float coded as IEEE 32 bit format. - * \param bs the target bitstream + * \param bs the target bitstream * \return the float value read. */ Float gf_bs_read_float(GF_BitStream *bs); @@ -139,7 +139,7 @@ Float gf_bs_read_float(GF_BitStream *bs); * \brief double reading * * Reads a double coded as IEEE 64 bit format. - * \param bs the target bitstream + * \param bs the target bitstream * \return the double value read. */ Double gf_bs_read_double(GF_BitStream *bs); @@ -147,7 +147,7 @@ Double gf_bs_read_double(GF_BitStream *bs); * \brief data reading * * Reads a data buffer - * \param bs the target bitstream + * \param bs the target bitstream * \param data the data buffer to be filled * \param nbBytes the amount of bytes to read * \return the number of bytes actually read. @@ -160,7 +160,7 @@ u32 gf_bs_read_data(GF_BitStream *bs, char *data, u32 nbBytes); * * Reads an integer coded on 8 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \return the char value read. */ u32 gf_bs_read_u8(GF_BitStream *bs); @@ -171,7 +171,7 @@ u32 gf_bs_read_u8(GF_BitStream *bs); * Reads an integer coded on 8 bits starting at a byte boundary in the bitstream until * the given appears on the bitstream. * \note the bytes read in the bitstream will only be update if the delimiter is found - * \param bs the target bitstream + * \param bs the target bitstream * \param delimiter the stop condition * \param out the resulting value * \param max_length the maximum length of the output @@ -184,7 +184,7 @@ u32 gf_bs_read_u8_until_delimiter(GF_BitStream *bs, u8 delimiter, u8* out, u32 m * * Reads an integer coded on 16 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \return the short value read. */ u32 gf_bs_read_u16(GF_BitStream *bs); @@ -193,7 +193,7 @@ u32 gf_bs_read_u16(GF_BitStream *bs); * * Reads an integer coded on 24 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_read_u24(GF_BitStream *bs); @@ -202,7 +202,7 @@ u32 gf_bs_read_u24(GF_BitStream *bs); * * Reads an integer coded on 32 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_read_u32(GF_BitStream *bs); @@ -211,7 +211,7 @@ u32 gf_bs_read_u32(GF_BitStream *bs); * * Reads an integer coded on 64 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \return the large integer value read. */ u64 gf_bs_read_u64(GF_BitStream *bs); @@ -219,7 +219,7 @@ u64 gf_bs_read_u64(GF_BitStream *bs); * \brief little endian integer reading * * Reads an integer coded on 32 bits in little-endian order. - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_read_u32_le(GF_BitStream *bs); @@ -227,7 +227,7 @@ u32 gf_bs_read_u32_le(GF_BitStream *bs); * \brief little endian integer reading * * Reads an integer coded on 16 bits in little-endian order. - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u16 gf_bs_read_u16_le(GF_BitStream *bs); @@ -237,7 +237,7 @@ u16 gf_bs_read_u16_le(GF_BitStream *bs); * \brief variable length integer reading * * Reads an integer coded on a variable number of 4-bits chunks. The number of chunks is given by the number of non-0 bits at the begining. - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_read_vluimsbf5(GF_BitStream *bs); @@ -246,7 +246,7 @@ u32 gf_bs_read_vluimsbf5(GF_BitStream *bs); * \brief bit position * * Returns current bit position in the bitstream - only works in memory mode. - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_get_bit_offset(GF_BitStream *bs); @@ -255,7 +255,7 @@ u32 gf_bs_get_bit_offset(GF_BitStream *bs); * \brief current bit position * * Returns bit position in the current byte of the bitstream - only works in memory mode. - * \param bs the target bitstream + * \param bs the target bitstream * \return the integer value read. */ u32 gf_bs_get_bit_position(GF_BitStream *bs); @@ -265,7 +265,7 @@ u32 gf_bs_get_bit_position(GF_BitStream *bs); * \brief integer writing * * Writes an integer on a given number of bits. - * \param bs the target bitstream + * \param bs the target bitstream * \param value the integer to write * \param nBits number of bits used to code the integer */ @@ -274,7 +274,7 @@ void gf_bs_write_int(GF_BitStream *bs, s32 value, s32 nBits); * \brief large integer writing * * Writes an integer on a given number of bits greater than 32. - * \param bs the target bitstream + * \param bs the target bitstream * \param value the large integer to write * \param nBits number of bits used to code the integer */ @@ -283,7 +283,7 @@ void gf_bs_write_long_int(GF_BitStream *bs, s64 value, s32 nBits); * \brief float writing * * Writes a float in IEEE 32 bits format. - * \param bs the target bitstream + * \param bs the target bitstream * \param value the float to write */ void gf_bs_write_float(GF_BitStream *bs, Float value); @@ -291,7 +291,7 @@ void gf_bs_write_float(GF_BitStream *bs, Float value); * \brief double writing * * Writes a double in IEEE 64 bits format. - * \param bs the target bitstream + * \param bs the target bitstream * \param value the double to write */ void gf_bs_write_double(GF_BitStream *bs, Double value); @@ -299,7 +299,7 @@ void gf_bs_write_double(GF_BitStream *bs, Double value); * \brief data writing * * Writes a data buffer. - * \param bs the target bitstream + * \param bs the target bitstream * \param data the data to write * \param nbBytes number of data bytes to write */ @@ -310,7 +310,7 @@ u32 gf_bs_write_data(GF_BitStream *bs, const char *data, u32 nbBytes); * * Writes an integer on 8 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \param value the char value to write */ void gf_bs_write_u8(GF_BitStream *bs, u32 value); @@ -319,7 +319,7 @@ void gf_bs_write_u8(GF_BitStream *bs, u32 value); * * Writes an integer on 16 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \param value the short value to write */ void gf_bs_write_u16(GF_BitStream *bs, u32 value); @@ -328,7 +328,7 @@ void gf_bs_write_u16(GF_BitStream *bs, u32 value); * * Writes an integer on 24 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \param value the integer value to write */ void gf_bs_write_u24(GF_BitStream *bs, u32 value); @@ -337,7 +337,7 @@ void gf_bs_write_u24(GF_BitStream *bs, u32 value); * * Writes an integer on 32 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \param value the integer value to write */ void gf_bs_write_u32(GF_BitStream *bs, u32 value); @@ -347,7 +347,7 @@ void gf_bs_write_u32(GF_BitStream *bs, u32 value); * * Writes an integer on 64 bits starting at a byte boundary in the bitstream. * \warning you must not use this function if the bitstream is not aligned - * \param bs the target bitstream + * \param bs the target bitstream * \param value the large integer value to write */ void gf_bs_write_u64(GF_BitStream *bs, u64 value); @@ -415,7 +415,7 @@ u64 gf_bs_available(GF_BitStream *bs); * \param bs the target bitstream * \param output address of a memory block to be allocated for bitstream data. * \param outSize set to the size of the allocated memory block. - * \note + * \note * It is the user responsability to destroy the allocated buffer * Once this function has been called, the internal bitstream buffer is reseted. */ @@ -449,7 +449,7 @@ GF_Err gf_bs_seek(GF_BitStream *bs, u64 offset); void gf_bs_truncate(GF_BitStream *bs); /*! - *\brief bit peeking + *\brief bit peeking * *Peeks a given number of bits (read without moving the position indicator) for read modes only. *\param bs the target bitstream diff --git a/include/gpac/cache.h b/include/gpac/cache.h index 1ac20f5..a0378d4 100644 --- a/include/gpac/cache.h +++ b/include/gpac/cache.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre, Pierre Souchay + * Authors: Jean Le Feuvre, Pierre Souchay * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -48,191 +48,191 @@ extern "C" { #include - /** - * Handle for Cache Entries. - * You can use the gf_cache_get_* functions to get the cache properties - */ - typedef struct __DownloadedCacheEntryStruct * DownloadedCacheEntry; - - - typedef struct __CacheReaderStruct * GF_CacheReader; - - /** - * Free The DownloadedCacheEntry handle - * \param entry The entry to delete - * \return GF_OK - */ - GF_Err gf_cache_delete_entry( const DownloadedCacheEntry entry ); - - /** - * Get the ETag associated with this cache entry if any - * \param entry The entry - * \return The ETag if any was defined, NULL otherwise - */ - const char * gf_cache_get_etag_on_server( const DownloadedCacheEntry entry ); - - /** - * Set the eTag in the cache. Data is duplicated, so original string can be freed by caller. - * \param entry The entry - * \param eTag The eTag to set - * \return GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise - */ - GF_Err gf_cache_set_etag_on_disk(const DownloadedCacheEntry entry, const char * eTag ); - - /** - * Get the ETag associated with this cache entry if any - * \param entry The entry - * \return The ETag if any was defined, NULL otherwise - */ - const char * gf_cache_get_etag_on_disk( const DownloadedCacheEntry entry ); - - /** - * Set the eTag in the cache. Data is duplicated, so original string can be freed by caller. - * \param entry The entry - * \param eTag The eTag to set - * \return GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise - */ - GF_Err gf_cache_set_etag_on_server(const DownloadedCacheEntry entry, const char * eTag ); - - - /** - * Get the Mime-Type associated with this cache entry. - * \param entry The entry - * \return The Mime-Type (never NULL if entry is valid) - */ - const char * gf_cache_get_mime_type( const DownloadedCacheEntry entry ); - - /** - * Set the Mime-Type in the cache. Data is duplicated, so original string can be freed by caller. - * \param entry The entry - * \param mime_type The mime-type to set - * \return GF_OK if entry and mime-type are valid, GF_BAD_PARAM otherwise - */ - GF_Err gf_cache_set_mime_type(const DownloadedCacheEntry entry, const char * mime_type ); - - /** - * Get the URL associated with this cache entry. - * \param entry The entry - * \return The Hash key (never NULL if entry is valid) - */ - const char * gf_cache_get_url( const DownloadedCacheEntry entry ); - - /** - * Get the Hash Key associated with this cache entry. - * \param entry The entry - * \return The Hash key (never NULL if entry is valid) - */ - const char * gf_cache_get_hash( const DownloadedCacheEntry entry ); - - /** - * Tells whether a cache entry should be cached safely (no - * \param entry The entry - * \return 1 if entry should be cached - */ - Bool gf_cache_can_be_cached( const DownloadedCacheEntry entry ); - - /** - * Get the Last-Modified information associated with this cache entry. - * \param entry The entry - * \return The Last-Modified header (can be NULL) - */ - const char * gf_cache_get_last_modified_on_disk ( const DownloadedCacheEntry entry ); - - /** - * Get the Last-Modified information associated with this cache entry. - * \param entry The entry - * \return The Last-Modified header (can be NULL) - */ - const char * gf_cache_get_last_modified_on_server ( const DownloadedCacheEntry entry ); - - /** - * Set the Last-Modified header for this cache entry - * \param entry The entry - * \param newLastModified The new value to set, will be duplicated - * \return GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL - */ - GF_Err gf_cache_set_last_modified_on_disk ( const DownloadedCacheEntry entry, const char * newLastModified ); - - /** - * Set the Last-Modified header for this cache entry - * \param entry The entry - * \param newLastModified The new value to set, will be duplicated - * \return GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL - */ - GF_Err gf_cache_set_last_modified_on_server ( const DownloadedCacheEntry entry, const char * newLastModified ); - - /** - * Get the file name of cache associated with this cache entry. - * \param entry The entry - * \return The Cache file (never NULL if entry is valid) - */ - const char * gf_cache_get_cache_filename( const DownloadedCacheEntry entry ); - - /** - * Get the real file size of the cache entry - * \param entry The entry - * \return the file size - */ - u32 gf_cache_get_cache_filesize( const DownloadedCacheEntry entry ); - - /** - * Flushes The disk cache for this entry (by persisting the property file - * \param entry The entry - */ - GF_Err gf_cache_flush_disk_cache( const DownloadedCacheEntry entry ); - - GF_Err gf_cache_set_content_length( const DownloadedCacheEntry entry, u32 length ); - - u32 gf_cache_get_content_length( const DownloadedCacheEntry entry); - - /** - * \brief append cache directives to an HTTP GET request - * \param entry The entry of cache to use - * \param httpRequest The HTTP GET request to populate. The request must have been allocated enough to handle the cache arguments - * \return GF_OK if everything went fine, GF_BAD_PARAM if parameters are wrong - */ - GF_Err appendHttpCacheHeaders(const DownloadedCacheEntry entry, char * httpRequest); - - /* - * Cache Management functions - */ - - /*! - * Delete all cached files in given directory starting with startpattern - * \param directory to clean up - * \return GF_OK if everything went fine - */ - GF_Err gf_cache_delete_all_cached_files(const char * directory); - - - /* - * Cache Reader functions - */ - - GF_CacheReader gf_cache_reader_new(const DownloadedCacheEntry entry); - - GF_Err gf_cache_reader_del( GF_CacheReader handle ); - - s64 gf_cache_reader_seek_at( GF_CacheReader reader, u64 seekPosition); - - s64 gf_cache_reader_get_position( const GF_CacheReader reader); - - s64 gf_cache_reader_get_currentSize( GF_CacheReader reader ); - - s64 gf_cache_reader_get_full_size( GF_CacheReader reader ); - - s32 gf_cache_reader_read( GF_CacheReader reader, char * buff, s32 length); +/** + * Handle for Cache Entries. + * You can use the gf_cache_get_* functions to get the cache properties + */ +typedef struct __DownloadedCacheEntryStruct * DownloadedCacheEntry; + + +typedef struct __CacheReaderStruct * GF_CacheReader; + +/** + * Free The DownloadedCacheEntry handle + * \param entry The entry to delete + * \return GF_OK + */ +GF_Err gf_cache_delete_entry( const DownloadedCacheEntry entry ); + +/** + * Get the ETag associated with this cache entry if any + * \param entry The entry + * \return The ETag if any was defined, NULL otherwise + */ +const char * gf_cache_get_etag_on_server( const DownloadedCacheEntry entry ); + +/** + * Set the eTag in the cache. Data is duplicated, so original string can be freed by caller. + * \param entry The entry + * \param eTag The eTag to set + * \return GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise + */ +GF_Err gf_cache_set_etag_on_disk(const DownloadedCacheEntry entry, const char * eTag ); + +/** + * Get the ETag associated with this cache entry if any + * \param entry The entry + * \return The ETag if any was defined, NULL otherwise + */ +const char * gf_cache_get_etag_on_disk( const DownloadedCacheEntry entry ); + +/** + * Set the eTag in the cache. Data is duplicated, so original string can be freed by caller. + * \param entry The entry + * \param eTag The eTag to set + * \return GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise + */ +GF_Err gf_cache_set_etag_on_server(const DownloadedCacheEntry entry, const char * eTag ); + + +/** + * Get the Mime-Type associated with this cache entry. + * \param entry The entry + * \return The Mime-Type (never NULL if entry is valid) + */ +const char * gf_cache_get_mime_type( const DownloadedCacheEntry entry ); + +/** + * Set the Mime-Type in the cache. Data is duplicated, so original string can be freed by caller. + * \param entry The entry + * \param mime_type The mime-type to set + * \return GF_OK if entry and mime-type are valid, GF_BAD_PARAM otherwise + */ +GF_Err gf_cache_set_mime_type(const DownloadedCacheEntry entry, const char * mime_type ); + +/** + * Get the URL associated with this cache entry. + * \param entry The entry + * \return The Hash key (never NULL if entry is valid) + */ +const char * gf_cache_get_url( const DownloadedCacheEntry entry ); + +/** + * Get the Hash Key associated with this cache entry. + * \param entry The entry + * \return The Hash key (never NULL if entry is valid) + */ +const char * gf_cache_get_hash( const DownloadedCacheEntry entry ); + +/** + * Tells whether a cache entry should be cached safely (no + * \param entry The entry + * \return 1 if entry should be cached + */ +Bool gf_cache_can_be_cached( const DownloadedCacheEntry entry ); + +/** + * Get the Last-Modified information associated with this cache entry. + * \param entry The entry + * \return The Last-Modified header (can be NULL) + */ +const char * gf_cache_get_last_modified_on_disk ( const DownloadedCacheEntry entry ); + +/** + * Get the Last-Modified information associated with this cache entry. + * \param entry The entry + * \return The Last-Modified header (can be NULL) + */ +const char * gf_cache_get_last_modified_on_server ( const DownloadedCacheEntry entry ); + +/** + * Set the Last-Modified header for this cache entry + * \param entry The entry + * \param newLastModified The new value to set, will be duplicated + * \return GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL + */ +GF_Err gf_cache_set_last_modified_on_disk ( const DownloadedCacheEntry entry, const char * newLastModified ); + +/** + * Set the Last-Modified header for this cache entry + * \param entry The entry + * \param newLastModified The new value to set, will be duplicated + * \return GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL + */ +GF_Err gf_cache_set_last_modified_on_server ( const DownloadedCacheEntry entry, const char * newLastModified ); + +/** + * Get the file name of cache associated with this cache entry. + * \param entry The entry + * \return The Cache file (never NULL if entry is valid) + */ +const char * gf_cache_get_cache_filename( const DownloadedCacheEntry entry ); + +/** + * Get the real file size of the cache entry + * \param entry The entry + * \return the file size + */ +u32 gf_cache_get_cache_filesize( const DownloadedCacheEntry entry ); + +/** + * Flushes The disk cache for this entry (by persisting the property file + * \param entry The entry + */ +GF_Err gf_cache_flush_disk_cache( const DownloadedCacheEntry entry ); + +GF_Err gf_cache_set_content_length( const DownloadedCacheEntry entry, u32 length ); + +u32 gf_cache_get_content_length( const DownloadedCacheEntry entry); + +/** + * \brief append cache directives to an HTTP GET request + * \param entry The entry of cache to use + * \param httpRequest The HTTP GET request to populate. The request must have been allocated enough to handle the cache arguments + * \return GF_OK if everything went fine, GF_BAD_PARAM if parameters are wrong + */ +GF_Err appendHttpCacheHeaders(const DownloadedCacheEntry entry, char * httpRequest); + +/* + * Cache Management functions + */ + +/*! + * Delete all cached files in given directory starting with startpattern + * \param directory to clean up + * \return GF_OK if everything went fine + */ +GF_Err gf_cache_delete_all_cached_files(const char * directory); + + +/* + * Cache Reader functions + */ + +GF_CacheReader gf_cache_reader_new(const DownloadedCacheEntry entry); + +GF_Err gf_cache_reader_del( GF_CacheReader handle ); + +s64 gf_cache_reader_seek_at( GF_CacheReader reader, u64 seekPosition); + +s64 gf_cache_reader_get_position( const GF_CacheReader reader); + +s64 gf_cache_reader_get_currentSize( GF_CacheReader reader ); + +s64 gf_cache_reader_get_full_size( GF_CacheReader reader ); + +s32 gf_cache_reader_read( GF_CacheReader reader, char * buff, s32 length); + +Bool gf_cache_check_if_cache_file_is_corrupted(const DownloadedCacheEntry entry); - Bool gf_cache_check_if_cache_file_is_corrupted(const DownloadedCacheEntry entry); - - void gf_cache_entry_set_delete_files_when_deleted(const DownloadedCacheEntry entry); +void gf_cache_entry_set_delete_files_when_deleted(const DownloadedCacheEntry entry); - Bool gf_cache_entry_is_delete_files_when_deleted(const DownloadedCacheEntry entry); +Bool gf_cache_entry_is_delete_files_when_deleted(const DownloadedCacheEntry entry); - u32 gf_cache_get_sessions_count_for_cache_entry(const DownloadedCacheEntry entry); +u32 gf_cache_get_sessions_count_for_cache_entry(const DownloadedCacheEntry entry); - u64 gf_cache_get_start_range( const DownloadedCacheEntry entry ); - u64 gf_cache_get_end_range( const DownloadedCacheEntry entry ); +u64 gf_cache_get_start_range( const DownloadedCacheEntry entry ); +u64 gf_cache_get_end_range( const DownloadedCacheEntry entry ); /*! @} */ diff --git a/include/gpac/color.h b/include/gpac/color.h index 5356ac7..d254019 100644 --- a/include/gpac/color.h +++ b/include/gpac/color.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,10 +56,10 @@ typedef struct u32 width; /*!Height of the video framebuffer */ u32 height; - /*!Horizontal pitch of the video framebuffer (number of bytes to skip to go to next (right) pixel in the buffer). May be + /*!Horizontal pitch of the video framebuffer (number of bytes to skip to go to next (right) pixel in the buffer). May be negative for some framebuffers (embedded devices). 0 means linear frame buffer (pitch_x==bytes per pixel)*/ s32 pitch_x; - /*!Vertical pitch of the video framebuffer (number of bytes to skip to go down one line in the buffer). May be + /*!Vertical pitch of the video framebuffer (number of bytes to skip to go down one line in the buffer). May be negative for some framebuffers (embedded devices)*/ s32 pitch_y; /*!Pixel format of the video framebuffer*/ @@ -146,12 +146,12 @@ typedef u32 GF_Color; /*!Inits a color matrix to identity*/ void gf_cmx_init(GF_ColorMatrix *_this); -/*!Inits all coefficients of a color matrix +/*!Inits all coefficients of a color matrix *\param _this color matrix to initialize *\param coefs list of the 20 fixed numbers to copy */ void gf_cmx_set_all(GF_ColorMatrix *_this, Fixed *coefs); -/*!Inits all coefficients of a color matrix +/*!Inits all coefficients of a color matrix *\param _this color matrix to initialize *\param mrr red-to-red multiplication factor *\param mrg red-to-green multiplication factor @@ -174,11 +174,11 @@ void gf_cmx_set_all(GF_ColorMatrix *_this, Fixed *coefs); *\param maa alpha-to-alpha multiplication factor *\param ta alpha translation factor */ -void gf_cmx_set(GF_ColorMatrix *_this, - Fixed mrr, Fixed mrg, Fixed mrb, Fixed mra, Fixed tr, - Fixed mgr, Fixed mgg, Fixed mgb, Fixed mga, Fixed tg, - Fixed mbr, Fixed mbg, Fixed mbb, Fixed mba, Fixed tb, - Fixed mar, Fixed mag, Fixed mab, Fixed maa, Fixed ta); +void gf_cmx_set(GF_ColorMatrix *_this, + Fixed mrr, Fixed mrg, Fixed mrb, Fixed mra, Fixed tr, + Fixed mgr, Fixed mgg, Fixed mgb, Fixed mga, Fixed tg, + Fixed mbr, Fixed mbg, Fixed mbb, Fixed mba, Fixed tb, + Fixed mar, Fixed mag, Fixed mab, Fixed maa, Fixed ta); /*!Inits a matrix from another matrix *\param _this color matrix to initialize *\param from color matrix to copy from @@ -249,8 +249,8 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds * Software stretch of source surface ont destination surface. *\param vs_dst destination surface *\param pY source Y plane - *\param pU source U plane. if NULL, the U plane is located after the Y plane - *\param pV source V plane. if NULL, the V plane is located after the U plane + *\param pU source U plane. if NULL, the U plane is located after the Y plane + *\param pV source V plane. if NULL, the V plane is located after the U plane *\param src_stride source stride in bytes *\param src_width source width in pixels *\param src_height source height in pixels diff --git a/include/gpac/compositor.h b/include/gpac/compositor.h index 9487a46..e0fb3cd 100644 --- a/include/gpac/compositor.h +++ b/include/gpac/compositor.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ extern "C" { typedef struct __tag_compositor GF_Compositor; -/*creates default compositor +/*creates default compositor if self_threaded, video compositor uses a dedicated thread, otherwise visual rendering is done by the user audio compositor always runs in its own thread if enabled term may be NULL, in which case InputSensors won't be enabled @@ -60,7 +60,7 @@ Bool gf_sc_draw_frame(GF_Compositor *sr, u32 *ms_till_next); /*inits rendering info for the node - shall be called for all nodes the parent system doesn't handle*/ void gf_sc_on_node_init(GF_Compositor *sr, GF_Node *node); -/*notify the given node has been modified. The compositor filters object to decide whether the scene graph has to be +/*notify the given node has been modified. The compositor filters object to decide whether the scene graph has to be traversed or not- if object is NULL, this means complete traversing of the graph is requested (use carefully since it can be a time consuming operation)*/ void gf_sc_invalidate(GF_Compositor *sr, GF_Node *byObj); @@ -80,7 +80,7 @@ void gf_sc_lock_audio(GF_Compositor *sr, Bool doLock); Bool gf_sc_user_event(GF_Compositor *sr, GF_Event *event); /*maps screen coordinates to bifs 2D coordinates for the current zoom/pan settings -X and Y are point coordinates in the display expressed in BIFS-like fashion (0,0) at center of +X and Y are point coordinates in the display expressed in BIFS-like fashion (0,0) at center of display and Y increasing from bottom to top*/ void gf_sc_map_point(GF_Compositor *sr, s32 X, s32 Y, Fixed *bifsX, Fixed *bifsY); @@ -104,7 +104,7 @@ const char *gf_sc_get_selected_text(GF_Compositor *compositor); GF_Err gf_sc_paste_text(GF_Compositor *compositor, const char *text); -/*user-define management: this is used for instant visual rendering of the scene graph, +/*user-define management: this is used for instant visual rendering of the scene graph, for exporting or authoring tools preview. User is responsible for calling render when desired and shall also maintain scene timing*/ diff --git a/include/gpac/config_file.h b/include/gpac/config_file.h index 2befc15..2a0b86e 100644 --- a/include/gpac/config_file.h +++ b/include/gpac/config_file.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,16 +35,16 @@ extern "C" { * \brief configuration file functions. */ - /*! - * \addtogroup cfg_grp configuration - * \ingroup utils_grp - * \brief Configuration File object - * - * This section documents the configuration file object of the GPAC framework. - * This file is formatted as the INI file mode of WIN32 in sections and keys.\n - *\note For more information on the GPAC configuration file itself, please refer to the GPAC configuration help provided with GPAC. - * @{ - */ +/*! +* \addtogroup cfg_grp configuration +* \ingroup utils_grp +* \brief Configuration File object +* +* This section documents the configuration file object of the GPAC framework. +* This file is formatted as the INI file mode of WIN32 in sections and keys.\n +*\note For more information on the GPAC configuration file itself, please refer to the GPAC configuration help provided with GPAC. +* @{ +*/ #include @@ -55,7 +55,7 @@ typedef struct __tag_config GF_Config; * \brief configuration file initialization * * Constructs a configuration file from fileName. if fileName is NULL, the default GPAC configuration file is loaded. - * If no configuration file is found, a default configuration file is created with the proper module directory, font directory + * If no configuration file is found, a default configuration file is created with the proper module directory, font directory * and other default options. *\param file name of the configuration file, or NULL for default file *\param new_cfg Boolean set to true if a new configuration file has been created @@ -173,7 +173,7 @@ const char *gf_cfg_get_key_name(GF_Config *cfgFile, const char *secName, u32 key /*! * \brief key insertion * - *Inserts a new key in a given section. Returns an error if a key with the given name + *Inserts a new key in a given section. Returns an error if a key with the given name *already exists in the section *\param cfgFile the target configuration file *\param secName the target section diff --git a/include/gpac/configuration.h b/include/gpac/configuration.h index d36dc4c..209751a 100644 --- a/include/gpac/configuration.h +++ b/include/gpac/configuration.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2008-2012 * All rights reserved * - * This file is part of GPAC + * This file is part of GPAC * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ /*visual studio and xcode*/ -#if defined(WIN32) || defined(_WIN32_WCE) || defined(GPAC_CONFIG_DARWIN) +#if defined(WIN32) || defined(_WIN32_WCE) || defined(GPAC_CONFIG_DARWIN) || defined(GPAC_CONFIG_ANDROID) /*enables GPAC memory tracking in debug mode only*/ #if defined(DEBUG) || defined(_DEBUG) @@ -90,6 +90,21 @@ #endif //end OSX flags +//Android test compilation without any extra lib +#if defined(GPAC_CONFIG_ANDROID) +#define GPAC_ANDROID + +#define GPAC_HAS_IPV6 +#define GPAC_USE_OGL_ES +#define GPAC_FIXED_POINT + +#undef GPAC_HAS_SPIDERMONKEY +#undef GPAC_HAS_PNG +#undef GPAC_HAS_JPEG + +#endif //end OSX flags + + //WinCE flags #if defined(_WIN32_WCE) @@ -137,6 +152,18 @@ #define GPAC_X64 #endif +/*disables player */ +//#define GPAC_DISABLE_PLAYER + +/*disables scene manager */ +//#define GPAC_DISABLE_SMGR + +/*disables core tools */ +//#define GPAC_DISABLE_CORE_TOOLS + +/*disables core tools */ +//#define GPAC_DISABLE_ZLIB + /*disables SVG scene graph*/ //#define GPAC_DISABLE_SVG @@ -154,6 +181,7 @@ /*disables LASeR coder*/ //#define GPAC_DISABLE_LASER +//#define GPAC_DISABLE_SAF /*disables BIFS Engine support - TODO - merge DIMS and LASeR into BENG and rename it*/ //#define GPAC_DISABLE_SENG @@ -218,6 +246,9 @@ /*disables ISO FF fragments*/ //#define GPAC_DISABLE_ISOM_FRAGMENTS +/*disables scene graph */ +//GPAC_DISABLE_SCENEGRAPH + /*disables scene graph textual dump*/ //#define GPAC_DISABLE_SCENE_DUMP @@ -236,5 +267,17 @@ /*disables Timed Text support */ //#define GPAC_DISABLE_TTXT +/*disables TTML */ +//#define GPAC_DISABLE_TTML + +/*disables DASH MPD */ +//#define GPAC_DISABLE_MPD + +/*disables HEVC */ +//#define GPAC_DISABLE_HEVC + +/*disables VOBSUB */ +//#define GPAC_DISABLE_VOBSUB + #endif /*_GF_CONFIG_H_*/ diff --git a/include/gpac/constants.h b/include/gpac/constants.h index 8a648f0..5bcca2c 100644 --- a/include/gpac/constants.h +++ b/include/gpac/constants.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -106,7 +106,7 @@ enum /*!GPAC Private Media streams\n *\n\note *this stream type (MPEG-4 user-private) is reserved for media streams bypassing GPAC for decoding - and composition. The media decoder is only in charge of repositioning the video output, and the compositor will + and composition. The media decoder is only in charge of repositioning the video output, and the compositor will draw an empty rectangle if using alpha composition *The decoderSpecificInfo carried only contains an opaque pointer in the data field, which depends on the underlying InputServce provider @@ -183,13 +183,13 @@ typedef enum /*!32 bit RGBA (openGL like). Component ordering in bytes is R-G-B-A.*/ GF_PIXEL_RGBA = GF_4CC('R','G','B', 'A'), /*!RGB24 + depth plane. Component ordering in bytes is R-G-B-D.*/ - GF_PIXEL_RGBD = GF_4CC('R', 'G', 'B', 'D'), + GF_PIXEL_RGBD = GF_4CC('R', 'G', 'B', 'D'), /*!RGB24 + depth plane (7 lower bits) + shape mask. Component ordering in bytes is R-G-B-(S+D).*/ - GF_PIXEL_RGBDS = GF_4CC('3', 'C', 'D', 'S'), + GF_PIXEL_RGBDS = GF_4CC('3', 'C', 'D', 'S'), /*!Stereo RGB24 */ - GF_PIXEL_RGBS = GF_4CC('R', 'G', 'B', 'S'), + GF_PIXEL_RGBS = GF_4CC('R', 'G', 'B', 'S'), /*!Stereo RGBA. Component ordering in bytes is R-G-B-A. */ - GF_PIXEL_RGBAS = GF_4CC('R', 'G', 'A', 'S'), + GF_PIXEL_RGBAS = GF_4CC('R', 'G', 'A', 'S'), /*internal format for OpenGL using pachek RGB 24 bit plus planaer depth plane at the end of the image*/ GF_PIXEL_RGB_24_DEPTH = GF_4CC('R', 'G', 'B', 'd'), @@ -255,11 +255,11 @@ enum GPAC_OTI_SCENE_BIFS_EXTENDED = 0x04, /*!OTI for AFX streams with AFXConfig*/ GPAC_OTI_SCENE_AFX = 0x05, - /*!OTI for Font data streams */ + /*!OTI for Font data streams */ GPAC_OTI_FONT = 0x06, - /*!OTI for synthesized texture streams */ + /*!OTI for synthesized texture streams */ GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE = 0x07, - /*!OTI for streaming text streams */ + /*!OTI for streaming text streams */ GPAC_OTI_TEXT_MPEG4 = 0x08, /*!OTI for LASeR streams*/ GPAC_OTI_SCENE_LASER = 0x09, @@ -279,105 +279,105 @@ enum /*!OTI for HEVC layered streams*/ GPAC_OTI_VIDEO_SHVC = 0x25, /*!OTI for MPEG-4 AAC streams*/ - GPAC_OTI_AUDIO_AAC_MPEG4 = 0x40, + GPAC_OTI_AUDIO_AAC_MPEG4 = 0x40, /*!OTI for MPEG-2 Visual Simple Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_SIMPLE = 0x60, + GPAC_OTI_VIDEO_MPEG2_SIMPLE = 0x60, /*!OTI for MPEG-2 Visual Main Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_MAIN = 0x61, + GPAC_OTI_VIDEO_MPEG2_MAIN = 0x61, /*!OTI for MPEG-2 Visual SNR Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_SNR = 0x62, + GPAC_OTI_VIDEO_MPEG2_SNR = 0x62, /*!OTI for MPEG-2 Visual SNR Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_SPATIAL = 0x63, + GPAC_OTI_VIDEO_MPEG2_SPATIAL = 0x63, /*!OTI for MPEG-2 Visual SNR Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_HIGH = 0x64, + GPAC_OTI_VIDEO_MPEG2_HIGH = 0x64, /*!OTI for MPEG-2 Visual SNR Profile streams*/ - GPAC_OTI_VIDEO_MPEG2_422 = 0x65, + GPAC_OTI_VIDEO_MPEG2_422 = 0x65, /*!OTI for MPEG-2 AAC Main Profile streams*/ - GPAC_OTI_AUDIO_AAC_MPEG2_MP = 0x66, + GPAC_OTI_AUDIO_AAC_MPEG2_MP = 0x66, /*!OTI for MPEG-2 AAC Low Complexity Profile streams*/ - GPAC_OTI_AUDIO_AAC_MPEG2_LCP = 0x67, - /*!OTI for MPEG-2 AAC Scaleable Sampling Rate Profile streams*/ - GPAC_OTI_AUDIO_AAC_MPEG2_SSRP = 0x68, + GPAC_OTI_AUDIO_AAC_MPEG2_LCP = 0x67, + /*!OTI for MPEG-2 AAC Scalable Sampling Rate Profile streams*/ + GPAC_OTI_AUDIO_AAC_MPEG2_SSRP = 0x68, /*!OTI for MPEG-2 Audio Part 3 streams*/ - GPAC_OTI_AUDIO_MPEG2_PART3 = 0x69, + GPAC_OTI_AUDIO_MPEG2_PART3 = 0x69, /*!OTI for MPEG-1 Video streams*/ - GPAC_OTI_VIDEO_MPEG1 = 0x6A, + GPAC_OTI_VIDEO_MPEG1 = 0x6A, /*!OTI for MPEG-1 Audio streams*/ - GPAC_OTI_AUDIO_MPEG1 = 0x6B, + GPAC_OTI_AUDIO_MPEG1 = 0x6B, /*!OTI for JPEG streams*/ - GPAC_OTI_IMAGE_JPEG = 0x6C, + GPAC_OTI_IMAGE_JPEG = 0x6C, /*!OTI for PNG streams*/ - GPAC_OTI_IMAGE_PNG = 0x6D, + GPAC_OTI_IMAGE_PNG = 0x6D, /*!OTI for JPEG-2000 streams*/ - GPAC_OTI_IMAGE_JPEG_2000 = 0x6E, - -/*! - * \brief Extra ObjectTypeIndication - * - * ObjectTypeIndication for media (audio/video) codecs not defined in MPEG-4. Since GPAC signals streams through MPEG-4 Descriptions, - * it needs extensions for non-MPEG-4 streams such as AMR, H263 , etc.\n - *\note The decoder specific info for such streams is always carried encoded, with the following syntax:\n - * DSI Syntax for audio streams - \code - * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg - * u32 sample_rate: sampling rate or 0 if unknown - * u16 nb_channels: num channels or 0 if unknown - * u16 frame_size: num audio samples per frame or 0 if unknown - * u8 nb_bits_per_sample: nb bits or 0 if unknown - * u8 num_frames_per_au: num audio frames per AU (used in 3GPP, max 15), 0 if unknown - * char *data: per-codec extensions till end of DSI bitstream - \endcode - \n - * DSI Syntax for video streams - \code - * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg - * u16 width: video width or 0 if unknown - * u16 height: video height or 0 if unknown - * char *data: per-codec extensions till end of DSI bitstream - \endcode -*/ - GPAC_OTI_MEDIA_GENERIC = 0x80, -/*! - * \brief FFMPEG ObjectTypeIndication - * - * ObjectTypeIndication for FFMPEG codecs not defined in MPEG-4. FFMPEG uses the base GPAC_OTI_MEDIA_GENERIC specific info formats, and extends it as follows: - \code - * u32 bit_rate: the stream rate or 0 if unknown - * u32 codec_tag: FFMPEG codec tag as defined in libavcodec - * char *data: codec extensions till end of DSI bitstream - \endcode - */ - GPAC_OTI_MEDIA_FFMPEG = 0x81, + GPAC_OTI_IMAGE_JPEG_2000 = 0x6E, + + /*! + * \brief Extra ObjectTypeIndication + * + * ObjectTypeIndication for media (audio/video) codecs not defined in MPEG-4. Since GPAC signals streams through MPEG-4 Descriptions, + * it needs extensions for non-MPEG-4 streams such as AMR, H263 , etc.\n + *\note The decoder specific info for such streams is always carried encoded, with the following syntax:\n + * DSI Syntax for audio streams + \code + * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg + * u32 sample_rate: sampling rate or 0 if unknown + * u16 nb_channels: num channels or 0 if unknown + * u16 frame_size: num audio samples per frame or 0 if unknown + * u8 nb_bits_per_sample: nb bits or 0 if unknown + * u8 num_frames_per_au: num audio frames per AU (used in 3GPP, max 15), 0 if unknown + * char *data: per-codec extensions till end of DSI bitstream + \endcode + \n + * DSI Syntax for video streams + \code + * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg + * u16 width: video width or 0 if unknown + * u16 height: video height or 0 if unknown + * char *data: per-codec extensions till end of DSI bitstream + \endcode + */ + GPAC_OTI_MEDIA_GENERIC = 0x80, + /*! + * \brief FFMPEG ObjectTypeIndication + * + * ObjectTypeIndication for FFMPEG codecs not defined in MPEG-4. FFMPEG uses the base GPAC_OTI_MEDIA_GENERIC specific info formats, and extends it as follows: + \code + * u32 bit_rate: the stream rate or 0 if unknown + * u32 codec_tag: FFMPEG codec tag as defined in libavcodec + * char *data: codec extensions till end of DSI bitstream + \endcode + */ + GPAC_OTI_MEDIA_FFMPEG = 0x81, - /*!OTI for EVRC Voice streams*/ - GPAC_OTI_AUDIO_EVRC_VOICE = 0xA0, + /*!OTI for EVRC Voice streams*/ + GPAC_OTI_AUDIO_EVRC_VOICE = 0xA0, /*!OTI for SMV Voice streams*/ - GPAC_OTI_AUDIO_SMV_VOICE = 0xA1, + GPAC_OTI_AUDIO_SMV_VOICE = 0xA1, /*!OTI for 3GPP2 CMF streams*/ - GPAC_OTI_3GPP2_CMF = 0xA2, + GPAC_OTI_3GPP2_CMF = 0xA2, /*!OTI for SMPTE VC-1 Video streams*/ - GPAC_OTI_VIDEO_SMPTE_VC1 = 0xA3, + GPAC_OTI_VIDEO_SMPTE_VC1 = 0xA3, /*!OTI for Dirac Video streams*/ - GPAC_OTI_VIDEO_DIRAC = 0xA4, + GPAC_OTI_VIDEO_DIRAC = 0xA4, /*!OTI for AC-3 audio streams*/ - GPAC_OTI_AUDIO_AC3 = 0xA5, + GPAC_OTI_AUDIO_AC3 = 0xA5, /*!OTI for enhanced AC-3 audio streams*/ - GPAC_OTI_AUDIO_AC3_ENHANCED = 0xA6, + GPAC_OTI_AUDIO_EAC3 = 0xA6, /*!OTI for DRA audio streams*/ - GPAC_OTI_AUDIO_DRA = 0xA7, + GPAC_OTI_AUDIO_DRA = 0xA7, /*!OTI for ITU G719 audio streams*/ - GPAC_OTI_AUDIO_ITU_G719 = 0xA8, + GPAC_OTI_AUDIO_ITU_G719 = 0xA8, /*!OTI for DTS Coherent Acoustics audio streams*/ - GPAC_OTI_AUDIO_DTS_CA = 0xA9, + GPAC_OTI_AUDIO_DTS_CA = 0xA9, /*!OTI for DTS-HD High Resolution audio streams*/ - GPAC_OTI_AUDIO_DTS_HD_HR = 0xAA, + GPAC_OTI_AUDIO_DTS_HD_HR = 0xAA, /*!OTI for DTS-HD Master audio streams*/ - GPAC_OTI_AUDIO_DTS_HD_MASTER = 0xAB, + GPAC_OTI_AUDIO_DTS_HD_MASTER = 0xAB, - /*!OTI for dummy streams (dsi = file name) using the generic context loader (BIFS/VRML/SWF/...) - GPAC internal*/ + /*!OTI for dummy streams (dsi = file name) using the generic context loader (BIFS/VRML/SWF/...) - GPAC internal*/ GPAC_OTI_PRIVATE_SCENE_GENERIC = 0xC0, /*!OTI for SVG dummy stream (dsi = file name) - GPAC internal*/ GPAC_OTI_PRIVATE_SCENE_SVG = 0xC1, @@ -405,49 +405,49 @@ enum /*!OTI for streaming simple text from MP4- GPAC internal*/ GPAC_OTI_SCENE_SIMPLE_TEXT_MP4 = 0xD5, -/*! - * \brief OGG ObjectTypeIndication - * - * Object type indication for all OGG media. The DSI contains all intitialization ogg packets for the codec - * and is formated as follows:\n - *\code - while (dsi_size) { - bit(16) packet_size; - char packet[packet_size]; - dsi_size -= packet_size; - }\endcode -*/ - GPAC_OTI_MEDIA_OGG = 0xDD, - GPAC_OTI_MEDIA_THEORA = 0xDF, + /*! + * \brief OGG ObjectTypeIndication + * + * Object type indication for all OGG media. The DSI contains all intitialization ogg packets for the codec + * and is formated as follows:\n + *\code + while (dsi_size) { + bit(16) packet_size; + char packet[packet_size]; + dsi_size -= packet_size; + }\endcode + */ + GPAC_OTI_MEDIA_OGG = 0xDD, + GPAC_OTI_MEDIA_THEORA = 0xDF, - GPAC_OTI_MEDIA_SUBPIC = 0xE0, + GPAC_OTI_MEDIA_SUBPIC = 0xE0, - /*!OTI for 13K Voice / QCELP audio streams*/ - GPAC_OTI_AUDIO_13K_VOICE = 0xE1, + /*!OTI for 13K Voice / QCELP audio streams*/ + GPAC_OTI_AUDIO_13K_VOICE = 0xE1, /*!OTI for RAW media streams. Input data is directly dispatched to the composition memory. The DSI contains is formated (MSBF) as follows:\n - * DSI Syntax for audio streams - \code - * u32 sample_rate: sampling rate - * u16 nb_channels: num channels - * u16 nb_bits_per_sample: num of bits per audio sample - * u32 frame_size: max size of audio frame in byte - * u32 channel_config: GPAC mask of GF_AUDIO_CH_ constants, or 0 if unknown - \endcode - \n - * DSI Syntax for video streams - \code - * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg - * u16 width: video width or 0 if unknown - * u16 height: video height or 0 if unknown - * u32 frame_size: size of the video frame - * u32 stride: horizontal stride of the video frame - \endcode + * DSI Syntax for audio streams + \code + * u32 sample_rate: sampling rate + * u16 nb_channels: num channels + * u16 nb_bits_per_sample: num of bits per audio sample + * u32 frame_size: max size of audio frame in byte + * u32 channel_config: GPAC mask of GF_AUDIO_CH_ constants, or 0 if unknown + \endcode + \n + * DSI Syntax for video streams + \code + * u32 codec_four_cc: the codec 4CC reg code / codec id for ffmpeg + * u16 width: video width or 0 if unknown + * u16 height: video height or 0 if unknown + * u32 frame_size: size of the video frame + * u32 stride: horizontal stride of the video frame + \endcode */ GPAC_OTI_RAW_MEDIA_STREAM = 0x101, /*!OTI for LIBPLAYER private streams. The data pointer in the DSI is the libplayer handle object*/ - GPAC_OTI_PRIVATE_MEDIA_LIBPLAYER = 0xF1 + GPAC_OTI_PRIVATE_MEDIA_LIBPLAYER = 0xF1 }; diff --git a/include/gpac/crypt.h b/include/gpac/crypt.h index 54ba9b2..b990f4f 100644 --- a/include/gpac/crypt.h +++ b/include/gpac/crypt.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,10 +31,10 @@ /* * Copyright (C) 1998,1999,2000 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -67,7 +67,7 @@ extern "C" { typedef struct _tag_crypt_stream GF_Crypt; /*supported modes (case insensitive): "CBC", "CFB", "CTR", "ECB", "nCFB", "nOFB", "OFB", "STREAM"*/ -/*supported algos (case insensitive): +/*supported algos (case insensitive): "AES-128" == "Rijndael-128" "AES-192" == "Rijndael-192" "AES-256" == "Rijndael-256" @@ -80,11 +80,11 @@ GF_Crypt *gf_crypt_open(const char *algorithm, const char *mode); /*close crypto context*/ void gf_crypt_close(GF_Crypt *gfc); -/* sets the state of the algorithm. Can be used only with block algorithms and certain modes like CBC, CFB etc. -It is usefully if you want to restart or start a different encryption quickly. +/* sets the state of the algorithm. Can be used only with block algorithms and certain modes like CBC, CFB etc. +It is usefully if you want to restart or start a different encryption quickly. */ GF_Err gf_crypt_set_state(GF_Crypt *gfc, const void *iv, int size); -/*gets the state of the algorithm. Can be used only certain modes and algorithms. +/*gets the state of the algorithm. Can be used only certain modes and algorithms. The size will hold the size of the state and the state must have enough bytes to hold it. */ GF_Err gf_crypt_get_state(GF_Crypt *gfc, void *iv, int *size); @@ -101,12 +101,12 @@ u32 gf_crypt_get_key_size(GF_Crypt *gfc); /*Returns the number of supported key sizes. @keys: array of at least MAX_KEY_SIZES size - will hold the supported sizes*/ u32 gf_crypt_get_supported_key_sizes(GF_Crypt *gfc, u32 *key_sizes); -/*Returns size (in bytes) of the IV of the algorithm specified for the context. -If it is '0' then the IV is ignored in that algorithm. +/*Returns size (in bytes) of the IV of the algorithm specified for the context. +If it is '0' then the IV is ignored in that algorithm. IV is used in CBC, CFB, OFB modes, and in some algorithms in STREAM mode. */ u32 gf_crypt_get_iv_size(GF_Crypt *gfc); -/*Returns 1 if the mode needs an IV, 0 otherwise. +/*Returns 1 if the mode needs an IV, 0 otherwise. Some 'stream' algorithms may need an IV even if the mode itself does not need an IV. */ Bool gf_crypt_mode_has_iv(GF_Crypt *gfc); @@ -120,13 +120,13 @@ u32 gf_crypt_get_mode_version(GF_Crypt *gfc); /* This function initializes all buffers for the specified context -@Lenofkey: key size in BYTES - maximum value of lenofkey should be the one obtained by +@Lenofkey: key size in BYTES - maximum value of lenofkey should be the one obtained by calling gf_crypt_get_key_size() and every value smaller than this is legal. @IV: usually size of the algorithms block size - get it by calling gf_crypt_get_iv_size(). IV is ignored in ECB. IV MUST exist in CFB, CBC, STREAM, nOFB and OFB modes. It needs to be random and unique (but not secret). The same IV must be used - for encryption/decryption. -After calling this function you can use the descriptor for encryption or decryption (not both). + for encryption/decryption. +After calling this function you can use the descriptor for encryption or decryption (not both). */ GF_Err gf_crypt_init(GF_Crypt *gfc, void *key, u32 lenofkey, const void *IV); /*releases context buffers - you may call gf_crypt_init after that, or gf_crypt_close*/ @@ -135,10 +135,10 @@ void gf_crypt_deinit(GF_Crypt *gfc); GF_Err gf_crypt_set_key(GF_Crypt *gfc, void *key, u32 keysize, const void *iv); /* -main encryption function. +main encryption function. @Plaintext, @len: plaintext to encrypt - len should be k*algorithms_block_size if used in a mode which operated in blocks (cbc, ecb, nofb), or whatever when used in cfb or ofb which operate in streams. -The plaintext is replaced by the ciphertext. +The plaintext is replaced by the ciphertext. */ GF_Err gf_crypt_encrypt(GF_Crypt *gfc, void *plaintext, int len); /*decryption function. It is almost the same with gf_crypt_generic.*/ diff --git a/include/gpac/dash.h b/include/gpac/dash.h index 7a6f555..fbc698f 100644 --- a/include/gpac/dash.h +++ b/include/gpac/dash.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -45,7 +45,7 @@ static const char * GF_DASH_MPD_MIME_TYPES[] = { "application/dash+xml", "video/ */ static const char * GF_DASH_M3U8_MIME_TYPES[] = { "video/x-mpegurl", "audio/x-mpegurl", "application/x-mpegurl", "application/vnd.apple.mpegurl", NULL}; -typedef enum +typedef enum { /*event sent if an error occurs when setting up manifest*/ GF_DASH_EVENT_MANIFEST_INIT_ERROR, @@ -72,7 +72,7 @@ struct _gf_dash_io { /*user private data*/ void *udta; - + /*signals errors or specific actions to perform*/ GF_Err (*on_dash_event)(GF_DASHFileIO *dashio, GF_DASHEventType evt, s32 group_idx, GF_Err setup_error); @@ -96,7 +96,7 @@ struct _gf_dash_io /*get URL of the file - i tmay be different from the original one if resource relocation happened*/ const char *(*get_url)(GF_DASHFileIO *dashio, GF_DASHFileIOSession session); - /*get the name of the cache file. If NULL is returned, the file cannot be cached and its associated UTL will be used when + /*get the name of the cache file. If NULL is returned, the file cannot be cached and its associated UTL will be used when the client request file to play*/ const char *(*get_cache_name)(GF_DASHFileIO *dashio, GF_DASHFileIOSession session); /*get the MIME type of the file*/ @@ -130,14 +130,16 @@ typedef enum @keep_files: do not delete files from the cache @disable_switching: turn off bandwidth switching algorithm @first_select_mode: indicates which representation to select upon startup + @enable_buffering: forces buffering of segments for the duration indicated in the MPD before calling back the user + @initial_time_shift_percent: sets initial buffering: if between 0 and 100, this is a percentage of the time shift window of the session. If greater than 100, this is a time shift in milliseconds. */ -GF_DashClient *gf_dash_new(GF_DASHFileIO *dash_io, - u32 max_cache_duration, - u32 auto_switch_count, - Bool keep_files, - Bool disable_switching, - GF_DASHInitialSelectionMode first_select_mode, - Bool enable_buffering, u32 initial_time_shift_percent); +GF_DashClient *gf_dash_new(GF_DASHFileIO *dash_io, + u32 max_cache_duration, + u32 auto_switch_count, + Bool keep_files, + Bool disable_switching, + GF_DASHInitialSelectionMode first_select_mode, + Bool enable_buffering, u32 initial_time_shift_percent); /*delete the DASH client*/ void gf_dash_del(GF_DashClient *dash); @@ -188,15 +190,15 @@ const char *gf_dash_group_get_segment_mime(GF_DashClient *dash, u32 idx); /*returns the URL of tyhe first media resource to play (init segment or first media segment depending on format). start_range and end_range are optional*/ const char *gf_dash_group_get_segment_init_url(GF_DashClient *dash, u32 idx, u64 *start_range, u64 *end_range); -/*returns the URL and byte range of the next media resource to play in this group. +/*returns the URL and byte range of the next media resource to play in this group. If switching occured, sets switching_index to the new representation index. -If no bitstream switching is possible, also set the url and byte range of the media file required to intialize +If no bitstream switching is possible, also set the url and byte range of the media file required to intialize the playback of the next segment original_url is optional and may be used to het the URI of the segment */ -GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 dependent_representation_index, const char **url, u64 *start_range, u64 *end_range, - s32 *switching_index, const char **switching_url, u64 *switching_start_range, u64 *switching_end_range, - const char **original_url, Bool *has_next_segment); +GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 dependent_representation_index, const char **url, u64 *start_range, u64 *end_range, + s32 *switching_index, const char **switching_url, u64 *switching_start_range, u64 *switching_end_range, + const char **original_url, Bool *has_next_segment); /*same as gf_dash_group_get_next_segment_location but query the current downloaded segment*/ GF_EXPORT @@ -221,8 +223,8 @@ GF_Err gf_dash_group_get_presentation_time_offset(GF_DashClient *dash, u32 idx, /*returns 1 if the playback position is in the last period of the presentation*/ Bool gf_dash_in_last_period(GF_DashClient *dash); -/*return value: - 1 if the period switching has been requested (due to seeking), +/*return value: + 1 if the period switching has been requested (due to seeking), 2 if the switching is in progress (all groups will soon be destroyed and plyback will be stoped and restarted) 0 if no switching is requested */ @@ -273,17 +275,17 @@ u32 gf_dash_get_min_buffer_time(GF_DashClient *dash); //shifts UTC clock of server by shift_utc_ms so that new UTC in MPD is old + shift_utc_ms void gf_dash_set_utc_shift(GF_DashClient *dash, s32 shift_utc_ms); -//sets max resolution@bpp for all video +//sets max resolution@bpp for all video GF_Err gf_dash_set_max_resolution(GF_DashClient *dash, u32 width, u32 height, u8 max_display_bpp); -//sets min time in ms between a 404 and the next request on the same group. The default value is 500 ms. +//sets min time in ms between a 404 and the next request on the same group. The default value is 500 ms. GF_Err gf_dash_set_min_timeout_between_404(GF_DashClient *dash, u32 min_timeout_between_404); -//sets time in ms after which 404 request for a segment will indicate segment lost. The default value is 100 ms. +//sets time in ms after which 404 request for a segment will indicate segment lost. The default value is 100 ms. GF_Err gf_dash_set_segment_expiration_threshold(GF_DashClient *dash, u32 expire_after_ms); -//only enables the given group - this shall be set before calling @gf_dash_open. If group_index is <0 (default) no groups will be disabled. +//only enables the given group - this shall be set before calling @gf_dash_open. If group_index is <0 (default) no groups will be disabled. void gf_dash_debug_group(GF_DashClient *dash, s32 group_index); //indicates typical buffering used by the user app . This allows fetching data earlier in live mode, if the timeshiftbuffer allows for it diff --git a/include/gpac/download.h b/include/gpac/download.h index 9078934..70f7eeb 100644 --- a/include/gpac/download.h +++ b/include/gpac/download.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -52,494 +52,494 @@ extern "C" { #include - /*!the download manager object. This is usually not used by GPAC modules*/ - typedef struct __gf_download_manager GF_DownloadManager; - /*!the download manager session.*/ - typedef struct __gf_download_session GF_DownloadSession; - - typedef struct GF_URL_Info_Struct { - const char * protocol; - char * server_name; - char * remotePath; - char * canonicalRepresentation; - char * userName; - char * password; - u16 port; - } GF_URL_Info; - - /*! - * Extracts the information from an URL. A call to gf_dm_url_info_init() must have been issue before calling this method. - * \param url The URL to fill - * \param info This structure will be initialized properly and filled with the data - * \param baseURL The baseURL to use if any (can be null) - * \return GF_OK if URL is well formed and supported by GPAC - */ - GF_Err gf_dm_get_url_info(const char * url, GF_URL_Info * info, const char * baseURL); - - /** - * Init the GF_URL_Info structure before it can be used - * \param info The structure to initialize - */ - void gf_dm_url_info_init(GF_URL_Info * info); - - /*! - * Frees the inner structures of a GF_URL_Info_Struct - * \param info The info to free - */ - void gf_dm_url_info_del(GF_URL_Info * info); - - /*! - *\brief download manager constructor - * - *Creates a new download manager object. - *\param cfg optional configuration file. Currently the download manager needs a configuration file for cache location and - *other options. The cache directory must be indicated in the section "General", key "CacheDirectory" of the configuration - *file. If the cache directory is not found, the cache will be disabled but the downloader will still work. - *\return the download manager object - */ - GF_DownloadManager *gf_dm_new(GF_Config *cfg); - /* - *\brief download manager destructor - * - *Deletes the download manager. All running sessions are aborted - *\param dm the download manager object - */ - void gf_dm_del(GF_DownloadManager *dm); - - /*! - *\brief callback function for authentication - * - * The gf_dm_get_usr_pass type is the type for the callback of the \ref gf_dm_set_auth_callback function used for password retrieval - *\param usr_cbk opaque user data - *\param site_url url of the site the user and password are requested for - *\param usr_name the user name for this site. The allocated space for this buffer is 50 bytes. \note this varaibale may already be formatted. - *\param password the password for this site and user. The allocated space for this buffer is 50 bytes. - *\return 0 if user didn't fill in the information which will result in an authentication failure, 1 otherwise. - */ - typedef Bool (*gf_dm_get_usr_pass)(void *usr_cbk, const char *site_url, char *usr_name, char *password); - - /*! - *\brief password retrieval assignment - * - *Assigns the callback function used for user password retrieval. If no such function is assigned to the download manager, - *all downloads requiring authentication will fail. - *\param dm the download manager object - *\param get_pass \ref gf_dm_get_usr_pass callback function for user and password retrieval. - *\param usr_cbk opaque user data passed to callback function - */ - void gf_dm_set_auth_callback(GF_DownloadManager *dm, gf_dm_get_usr_pass get_pass, void *usr_cbk); - - /*!downloader session message types*/ - typedef enum - { - /*!signal that session is setup and waiting for connection request*/ - GF_NETIO_SETUP = 0, - /*!signal that session connection is done*/ - GF_NETIO_CONNECTED, - /*!request a protocol method from the user. Default value is "GET" for HTTP*/ - GF_NETIO_GET_METHOD, - /*!request a header from the user. */ - GF_NETIO_GET_HEADER, - /*!requesting content from the user, if any. Content is appended to the request*/ - GF_NETIO_GET_CONTENT, - /*!signal that request is sent and waiting for server reply*/ - GF_NETIO_WAIT_FOR_REPLY, - /*!signal a header to user. */ - GF_NETIO_PARSE_HEADER, - /*!signal request reply to user. The reply is always sent after the headers*/ - GF_NETIO_PARSE_REPLY, - /*!send data to the user*/ - GF_NETIO_DATA_EXCHANGE, - /*!all data has been transfered*/ - GF_NETIO_DATA_TRANSFERED, - /*!signal that the session has been deconnected*/ - GF_NETIO_DISCONNECTED, - /*!downloader session failed (error code set) or done/destroyed (no error code)*/ - GF_NETIO_STATE_ERROR - } GF_NetIOStatus; - - /*!session download flags*/ - enum - { - /*!session is not threaded, the user must explicitely fetch the data , either with the function gf_dm_sess_fetch_data - or the function gf_dm_sess_process- if the session is threaded, the user must call gf_dm_sess_process to start the session*/ - GF_NETIO_SESSION_NOT_THREADED = 1, - /*! session data is live, e.g. data will be sent to the user if threaded mode (live streams like radios & co) - Whether the data is cached or not to disk cannot be controlled by the user at the current time. - */ - GF_NETIO_SESSION_NOT_CACHED = 1<<1, - /*indicates that the connection to the server should be kept once the download is successfully completed*/ - GF_NETIO_SESSION_PERSISTENT = 1<<2, - /*file is stored in memory, and the cache name is set to gpac://%u@%p, where %d is the size in bytes and %d is the the pointer to the memory. - Memory cached files are destroyed upon downloader destruction*/ - GF_NETIO_SESSION_MEMORY_CACHE = 1<<3, - }; - - - /*!protocol I/O parameter*/ - typedef struct - { - /*!parameter message type*/ - u32 msg_type; - /*error code if any. Valid for all message types.*/ - GF_Err error; - /*!data received or data to send. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE (when no cache is setup) messages*/ - const char *data; - /*!size of associated data. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE messages*/ - u32 size; - /*protocol header. Only valid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_GET_METHOD*/ - const char *name; - /*protocol header value or server response. Only alid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_PARSE_REPLY*/ - char *value; - /*message-dependend - for GF_NETIO_PARSE_REPLY, response code - for GF_NETIO_DATA_EXCHANGE - Set to 1 in to indicate end of chunk transfer - Set to 2 in GF_NETIO_DATA_EXCHANGE to indicate complete file is already received (replay of events from cache) - for all other, usage is reserved - */ - u32 reply; - /*download session for which the message is being sent*/ - GF_DownloadSession *sess; - } GF_NETIO_Parameter; - - /*! - *\brief callback function for data reception and state signaling - * - * The gf_dm_user_io type is the type for the data callback function of a download session - *\param usr_cbk opaque user data - *\param parameter the input/output parameter structure - */ - typedef void (*gf_dm_user_io)(void *usr_cbk, GF_NETIO_Parameter *parameter); - - - - /*! - *\brief download session constructor - * - *Creates a new download session - *\param dm the download manager object - *\param url file to retrieve (no PUT/POST yet, only downloading is supported) - *\param dl_flags combination of session download flags - *\param user_io \ref gf_dm_user_io callback function for data reception and service messages - *\param usr_cbk opaque user data passed to callback function - *\param error error for failure cases - *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local - */ - GF_DownloadSession * gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 dl_flags, - gf_dm_user_io user_io, - void *usr_cbk, - GF_Err *error); - - /*! - *\brief download session simple constructor - * - *Creates a new download session - *\param dm The download manager used to create the download session - *\param url file to retrieve (no PUT/POST yet, only downloading is supported) - *\param dl_flags combination of session download flags - *\param user_io \ref gf_dm_user_io callback function for data reception and service messages - *\param usr_cbk opaque user data passed to callback function - *\param e error for failure cases - *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local - */ - GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags, - gf_dm_user_io user_io, - void *usr_cbk, - GF_Err *e); - - /*! - *brief downloader session destructor - * - *Deletes the download session, cleaning the cache if indicated in the configuration file of the download manager (section "Downloader", key "CleanCache") - *\param sess the download session - */ - void gf_dm_sess_del(GF_DownloadSession * sess); - - /*! - *\brief aborts downloading - * - *Aborts all operations in the session, regardless of its state. The session cannot be reused once this is called. - *\param sess the download session - */ - void gf_dm_sess_abort(GF_DownloadSession * sess); - - /*! - *\brief sets private data - * - *associate private data with the session. - *\param sess the download session - *\param private_data the private data - *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal. - */ - void gf_dm_sess_set_private(GF_DownloadSession * sess, void *private_data); - - /*! - *\brief gets private data - * - *Gets private data associated with the session. - *\param sess the download session - *\return the private data - *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal. - */ - void *gf_dm_sess_get_private(GF_DownloadSession * sess); - - /*! - *\brief gets last session error - * - *Gets the last error that occured in the session - *\param sess the download session - *\return the last error - */ - GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess); - - /*! - *\brief is download manager thread dead? - * - *Indicates whether the thread has ended - *\param sess the download session - */ - Bool gf_dm_is_thread_dead(GF_DownloadSession *sess); - - /*! - *\brief fetches data on session - * - *Fetches data from the server. This will also performs connections and all needed exchange with server. - *\param sess the download session - *\param buffer destination buffer - *\param buffer_size destination buffer allocated size - *\param read_size amount of data actually fetched - *\note this can only be used when the session is not threaded - */ - GF_Err gf_dm_sess_fetch_data(GF_DownloadSession * sess, char *buffer, u32 buffer_size, u32 *read_size); - - /*! - *\brief get mime type as lower case - * - *Fetches the mime type of the URL this session is fetching, value will be returned lower case, so application/x-mpegURL will be returned as application/x-mpegurl - *\param sess the download session - *\return the mime type of the URL, or NULL if error. You should get the error with \ref gf_dm_sess_last_error - */ - const char *gf_dm_sess_mime_type(GF_DownloadSession * sess); - - /*! - *\brief sets session range - * - *Sets the session byte range. This shll be called before processing the session. - *\param sess the download session - *\param start_range HTTP download start range in byte - *\param end_range HTTP download end range in byte - *\param discontinue_cache If set, forces a new cache entry if byte range are not continuous. Otherwise a single cache entry is used to reconstruct the file - *\note this can only be used when the session is not threaded - */ - GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range, Bool discontinue_cache); - /*! - *\brief get cache file name - * - * Gets the cache file name for the session. - *\param sess the download session - *\return the absolute path of the cache file, or NULL if the session is not cached*/ - const char *gf_dm_sess_get_cache_name(GF_DownloadSession * sess); - - /*! - * \brief Marks the cache file to be deleted once the file is not used anymore by any session - * \param dm the download manager - * \param url The URL associate to the cache entry to be deleted - */ - void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * url); - - /*! - * Convenience function - * \see gf_dm_delete_cached_file_entry - *\param sess the download session - * \param url The URL associate to the cache entry to be deleted - */ - void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url); - - /*! - * Get a range of a cache entry file - * \param sess The session - * \param startOffset The first byte of the request to get - * \param endOffset The last byte of request to get - * \return The temporary name for the file created to have a range of the file - */ - const char * gf_cache_get_cache_filename_range( const GF_DownloadSession * sess, u64 startOffset, u64 endOffset ); - - /*! - *\brief get statistics - * - *Gets download statistics for the session. All output parameters are optional and may be set to NULL. - *\param sess the download session - *\param server the remote server address - *\param path the path on the remote server - *\param total_size the total size in bytes the file fetched, 0 if unknown. - *\param bytes_done the amount of bytes received from the server - *\param bytes_per_sec the average data rate in bytes per seconds - *\param net_status the session status - */ - GF_Err gf_dm_sess_get_stats(GF_DownloadSession * sess, const char **server, const char **path, u32 *total_size, u32 *bytes_done, u32 *bytes_per_sec, GF_NetIOStatus *net_status); - - /*! - *\brief get start time - * - *Gets session start time in UTC. If chunk-transfer is used, the start time is reset at each chunk start - *\param sess the download session - *\return UTC start time - */ - u64 gf_dm_sess_get_utc_start(GF_DownloadSession *sess); - - - /*! - *\brief fetch session object - * - *Fetch the session object (process all headers and data transfer). This is only usable if the session is not threaded - *\param sess the download session - *\return the last error in the session or 0 if none*/ - GF_Err gf_dm_sess_process(GF_DownloadSession * sess); - - /*! - *\brief fetch session object headers - * - *Fetch the session object headers and stops after that. This is only usable if the session is not threaded - *\param sess the download session - *\return the last error in the session or 0 if none*/ - GF_Err gf_dm_sess_process_headers(GF_DownloadSession * sess); - - /*! - *\brief fetch session status - * - *Fetch the session current status - *\param sess the download session - *\return the session status*/ - u32 gf_dm_sess_get_status(GF_DownloadSession * sess); - /*! - *\brief Get session resource url - * - *Returns the original resource URL associated with the session - *\param sess the download session - *\return the associated URL - */ - const char *gf_dm_sess_get_resource_name(GF_DownloadSession *sess); - /*! - *\brief Get session original resource url - * - *Returns the original resource URL before any redirection associated with the session - *\param sess the download session - *\return the associated URL - */ - const char *gf_dm_sess_get_original_resource_name(GF_DownloadSession *sess); - - - /*! - * \brief Download a file over the network using a download manager - * \param dm The downlaod manager to use, function will use all associated cache ressources - * \param url The url to download - * \param filename The filename to download - * \param start_range start position of a byte range - * \param end_range end position of a byte range - * \return GF_OK if everything went fine, an error otherwise - */ - GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, - const char *url, const char *filename, u64 start_range, u64 end_range); - - /*! - * \brief Same as gf_dm_wget_with_cache, but initializes the GF_DownloadManager by itself. - * This function is deprecated, please use gf_dm_wget_with_cache instead - * \param url The url to download - * \param filename The filename to download - * \param start_range start position of a byte range - * \param end_range end position of a byte range - * \return GF_OK if everything went fine, an error otherwise - */ - GF_Err gf_dm_wget(const char *url, const char *filename, u64 start_range, u64 end_range); - - /*! - *\brief Reset session - * - *Resets the session for new processing of the same url - *\param sess the download session - *\return error code if any - */ - GF_Err gf_dm_sess_reset(GF_DownloadSession *sess); - - /*! - * \brief forces the refresh of a cache entry - * The entry is still allocated in the session. - * \param sess The session - * \return a pointer to the entry of session refreshed - */ - DownloadedCacheEntry gf_dm_refresh_cache_entry(GF_DownloadSession *sess); - - /*! - * Tells whether session can be cached on disk. - * Typically, when request has no content length, it deserves being streamed an cannot be cached - * (ICY or MPEG-streamed content - * \param sess The session - * \return True if a cache can be created - */ - Bool gf_dm_sess_can_be_cached_on_disk(const GF_DownloadSession *sess); - - - /*! - * Reassigns session flags and callbacks. This is only possible if the session is not threaded. - * \param sess The session - * \param flags The new flags for the session - if flags is 0xFFFFFFFF, existing flags are not modified - * \param user_io The new callback function - * \param cbk The new user data to ba used in the callback function - * \return GF_OK or error - */ - GF_Err gf_dm_sess_reassign(GF_DownloadSession *sess, u32 flags, gf_dm_user_io user_io, void *cbk); - - /*! - * Re-setup an existing, completed session to download a new URL. If same server/port/protocol is used, the same socket will be reused if the session - * has the GF_NETIO_SESSION_PERSISTENT flag set. This is only possible if the session is not threaded. - * \param sess The session - * \param url The new url for the session - * \return GF_OK or error - */ - GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url); - - /* - *\retrieves the HTTP header value for the given name - * - *Retrieves the HTTP header value for the given header name. - *\param sess the current session - *\param name the target header name - * \return header value or NULL if not found - */ - const char *gf_dm_sess_get_header(GF_DownloadSession *sess, const char *name); - - /* - *\brief sets download manager max rate per session - * - *Sets the maximum rate (per session only at the current time). - *\param dm the download manager object - *\param rate_in_bits_per_sec the new rate in bits per sec. If 0, HTTP rate will not be limited - */ - void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_bits_per_sec); - - /* - *\brief gets download manager max rate per session - * - *Sets the maximum rate (per session only at the current time). - *\param dm the download manager object - *\return the rate in bits per sec. If 0, HTTP rate is not limited - */ - u32 gf_dm_get_data_rate(GF_DownloadManager *dm); - - - /* - *\brief fetches remote file in memory - * - *Fetches remote file in memory . - *\param url the data to fetch - *\param out_data output data (allocated by function) - *\param out_size output data size - *\param out_mime if not NULL, pointer will contain the mime type (allocated by function) - *\return error code if any - */ - GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, char **out_mime); - /*! @} */ +/*!the download manager object. This is usually not used by GPAC modules*/ +typedef struct __gf_download_manager GF_DownloadManager; +/*!the download manager session.*/ +typedef struct __gf_download_session GF_DownloadSession; + +typedef struct GF_URL_Info_Struct { + const char * protocol; + char * server_name; + char * remotePath; + char * canonicalRepresentation; + char * userName; + char * password; + u16 port; +} GF_URL_Info; + +/*! + * Extracts the information from an URL. A call to gf_dm_url_info_init() must have been issue before calling this method. + * \param url The URL to fill + * \param info This structure will be initialized properly and filled with the data + * \param baseURL The baseURL to use if any (can be null) + * \return GF_OK if URL is well formed and supported by GPAC + */ +GF_Err gf_dm_get_url_info(const char * url, GF_URL_Info * info, const char * baseURL); + +/** + * Init the GF_URL_Info structure before it can be used + * \param info The structure to initialize + */ +void gf_dm_url_info_init(GF_URL_Info * info); + +/*! + * Frees the inner structures of a GF_URL_Info_Struct + * \param info The info to free + */ +void gf_dm_url_info_del(GF_URL_Info * info); + +/*! + *\brief download manager constructor + * + *Creates a new download manager object. + *\param cfg optional configuration file. Currently the download manager needs a configuration file for cache location and + *other options. The cache directory must be indicated in the section "General", key "CacheDirectory" of the configuration + *file. If the cache directory is not found, the cache will be disabled but the downloader will still work. + *\return the download manager object +*/ +GF_DownloadManager *gf_dm_new(GF_Config *cfg); +/* + *\brief download manager destructor + * + *Deletes the download manager. All running sessions are aborted + *\param dm the download manager object + */ +void gf_dm_del(GF_DownloadManager *dm); + +/*! + *\brief callback function for authentication + * + * The gf_dm_get_usr_pass type is the type for the callback of the \ref gf_dm_set_auth_callback function used for password retrieval + *\param usr_cbk opaque user data + *\param site_url url of the site the user and password are requested for + *\param usr_name the user name for this site. The allocated space for this buffer is 50 bytes. \note this varaibale may already be formatted. + *\param password the password for this site and user. The allocated space for this buffer is 50 bytes. + *\return 0 if user didn't fill in the information which will result in an authentication failure, 1 otherwise. +*/ +typedef Bool (*gf_dm_get_usr_pass)(void *usr_cbk, const char *site_url, char *usr_name, char *password); + +/*! + *\brief password retrieval assignment + * + *Assigns the callback function used for user password retrieval. If no such function is assigned to the download manager, + *all downloads requiring authentication will fail. + *\param dm the download manager object + *\param get_pass \ref gf_dm_get_usr_pass callback function for user and password retrieval. + *\param usr_cbk opaque user data passed to callback function + */ +void gf_dm_set_auth_callback(GF_DownloadManager *dm, gf_dm_get_usr_pass get_pass, void *usr_cbk); + +/*!downloader session message types*/ +typedef enum +{ + /*!signal that session is setup and waiting for connection request*/ + GF_NETIO_SETUP = 0, + /*!signal that session connection is done*/ + GF_NETIO_CONNECTED, + /*!request a protocol method from the user. Default value is "GET" for HTTP*/ + GF_NETIO_GET_METHOD, + /*!request a header from the user. */ + GF_NETIO_GET_HEADER, + /*!requesting content from the user, if any. Content is appended to the request*/ + GF_NETIO_GET_CONTENT, + /*!signal that request is sent and waiting for server reply*/ + GF_NETIO_WAIT_FOR_REPLY, + /*!signal a header to user. */ + GF_NETIO_PARSE_HEADER, + /*!signal request reply to user. The reply is always sent after the headers*/ + GF_NETIO_PARSE_REPLY, + /*!send data to the user*/ + GF_NETIO_DATA_EXCHANGE, + /*!all data has been transfered*/ + GF_NETIO_DATA_TRANSFERED, + /*!signal that the session has been deconnected*/ + GF_NETIO_DISCONNECTED, + /*!downloader session failed (error code set) or done/destroyed (no error code)*/ + GF_NETIO_STATE_ERROR +} GF_NetIOStatus; + +/*!session download flags*/ +enum +{ + /*!session is not threaded, the user must explicitely fetch the data , either with the function gf_dm_sess_fetch_data + or the function gf_dm_sess_process- if the session is threaded, the user must call gf_dm_sess_process to start the session*/ + GF_NETIO_SESSION_NOT_THREADED = 1, + /*! session data is live, e.g. data will be sent to the user if threaded mode (live streams like radios & co) + Whether the data is cached or not to disk cannot be controlled by the user at the current time. + */ + GF_NETIO_SESSION_NOT_CACHED = 1<<1, + /*indicates that the connection to the server should be kept once the download is successfully completed*/ + GF_NETIO_SESSION_PERSISTENT = 1<<2, + /*file is stored in memory, and the cache name is set to gpac://%u@%p, where %d is the size in bytes and %d is the the pointer to the memory. + Memory cached files are destroyed upon downloader destruction*/ + GF_NETIO_SESSION_MEMORY_CACHE = 1<<3, +}; + + +/*!protocol I/O parameter*/ +typedef struct +{ + /*!parameter message type*/ + u32 msg_type; + /*error code if any. Valid for all message types.*/ + GF_Err error; + /*!data received or data to send. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE (when no cache is setup) messages*/ + const char *data; + /*!size of associated data. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE messages*/ + u32 size; + /*protocol header. Only valid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_GET_METHOD*/ + const char *name; + /*protocol header value or server response. Only alid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_PARSE_REPLY*/ + char *value; + /*message-dependend + for GF_NETIO_PARSE_REPLY, response code + for GF_NETIO_DATA_EXCHANGE + Set to 1 in to indicate end of chunk transfer + Set to 2 in GF_NETIO_DATA_EXCHANGE to indicate complete file is already received (replay of events from cache) + for all other, usage is reserved + */ + u32 reply; + /*download session for which the message is being sent*/ + GF_DownloadSession *sess; +} GF_NETIO_Parameter; + +/*! + *\brief callback function for data reception and state signaling + * + * The gf_dm_user_io type is the type for the data callback function of a download session + *\param usr_cbk opaque user data + *\param parameter the input/output parameter structure +*/ +typedef void (*gf_dm_user_io)(void *usr_cbk, GF_NETIO_Parameter *parameter); + + + +/*! + *\brief download session constructor + * + *Creates a new download session + *\param dm the download manager object + *\param url file to retrieve (no PUT/POST yet, only downloading is supported) + *\param dl_flags combination of session download flags + *\param user_io \ref gf_dm_user_io callback function for data reception and service messages + *\param usr_cbk opaque user data passed to callback function + *\param error error for failure cases + *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local + */ +GF_DownloadSession * gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 dl_flags, + gf_dm_user_io user_io, + void *usr_cbk, + GF_Err *error); + +/*! + *\brief download session simple constructor + * + *Creates a new download session + *\param dm The download manager used to create the download session + *\param url file to retrieve (no PUT/POST yet, only downloading is supported) + *\param dl_flags combination of session download flags + *\param user_io \ref gf_dm_user_io callback function for data reception and service messages + *\param usr_cbk opaque user data passed to callback function + *\param e error for failure cases + *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local + */ +GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags, + gf_dm_user_io user_io, + void *usr_cbk, + GF_Err *e); + +/*! + *brief downloader session destructor + * + *Deletes the download session, cleaning the cache if indicated in the configuration file of the download manager (section "Downloader", key "CleanCache") + *\param sess the download session +*/ +void gf_dm_sess_del(GF_DownloadSession * sess); + +/*! + *\brief aborts downloading + * + *Aborts all operations in the session, regardless of its state. The session cannot be reused once this is called. + *\param sess the download session + */ +void gf_dm_sess_abort(GF_DownloadSession * sess); + +/*! + *\brief sets private data + * + *associate private data with the session. + *\param sess the download session + *\param private_data the private data + *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal. + */ +void gf_dm_sess_set_private(GF_DownloadSession * sess, void *private_data); + +/*! + *\brief gets private data + * + *Gets private data associated with the session. + *\param sess the download session + *\return the private data + *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal. + */ +void *gf_dm_sess_get_private(GF_DownloadSession * sess); + +/*! + *\brief gets last session error + * + *Gets the last error that occured in the session + *\param sess the download session + *\return the last error + */ +GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess); + +/*! + *\brief is download manager thread dead? + * + *Indicates whether the thread has ended + *\param sess the download session + */ +Bool gf_dm_is_thread_dead(GF_DownloadSession *sess); + +/*! + *\brief fetches data on session + * + *Fetches data from the server. This will also performs connections and all needed exchange with server. + *\param sess the download session + *\param buffer destination buffer + *\param buffer_size destination buffer allocated size + *\param read_size amount of data actually fetched + *\note this can only be used when the session is not threaded + */ +GF_Err gf_dm_sess_fetch_data(GF_DownloadSession * sess, char *buffer, u32 buffer_size, u32 *read_size); + +/*! + *\brief get mime type as lower case + * + *Fetches the mime type of the URL this session is fetching, value will be returned lower case, so application/x-mpegURL will be returned as application/x-mpegurl + *\param sess the download session + *\return the mime type of the URL, or NULL if error. You should get the error with \ref gf_dm_sess_last_error + */ +const char *gf_dm_sess_mime_type(GF_DownloadSession * sess); + +/*! + *\brief sets session range + * + *Sets the session byte range. This shll be called before processing the session. + *\param sess the download session + *\param start_range HTTP download start range in byte + *\param end_range HTTP download end range in byte + *\param discontinue_cache If set, forces a new cache entry if byte range are not continuous. Otherwise a single cache entry is used to reconstruct the file + *\note this can only be used when the session is not threaded + */ +GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range, Bool discontinue_cache); +/*! + *\brief get cache file name + * + * Gets the cache file name for the session. + *\param sess the download session + *\return the absolute path of the cache file, or NULL if the session is not cached*/ +const char *gf_dm_sess_get_cache_name(GF_DownloadSession * sess); + +/*! + * \brief Marks the cache file to be deleted once the file is not used anymore by any session + * \param dm the download manager + * \param url The URL associate to the cache entry to be deleted + */ +void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * url); + +/*! + * Convenience function + * \see gf_dm_delete_cached_file_entry + *\param sess the download session + * \param url The URL associate to the cache entry to be deleted + */ +void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url); + +/*! + * Get a range of a cache entry file + * \param sess The session + * \param startOffset The first byte of the request to get + * \param endOffset The last byte of request to get + * \return The temporary name for the file created to have a range of the file + */ +const char * gf_cache_get_cache_filename_range( const GF_DownloadSession * sess, u64 startOffset, u64 endOffset ); + +/*! + *\brief get statistics + * + *Gets download statistics for the session. All output parameters are optional and may be set to NULL. + *\param sess the download session + *\param server the remote server address + *\param path the path on the remote server + *\param total_size the total size in bytes the file fetched, 0 if unknown. + *\param bytes_done the amount of bytes received from the server + *\param bytes_per_sec the average data rate in bytes per seconds + *\param net_status the session status + */ +GF_Err gf_dm_sess_get_stats(GF_DownloadSession * sess, const char **server, const char **path, u32 *total_size, u32 *bytes_done, u32 *bytes_per_sec, GF_NetIOStatus *net_status); + +/*! + *\brief get start time + * + *Gets session start time in UTC. If chunk-transfer is used, the start time is reset at each chunk start + *\param sess the download session + *\return UTC start time + */ +u64 gf_dm_sess_get_utc_start(GF_DownloadSession *sess); + + +/*! + *\brief fetch session object + * + *Fetch the session object (process all headers and data transfer). This is only usable if the session is not threaded + *\param sess the download session + *\return the last error in the session or 0 if none*/ +GF_Err gf_dm_sess_process(GF_DownloadSession * sess); + +/*! + *\brief fetch session object headers + * + *Fetch the session object headers and stops after that. This is only usable if the session is not threaded + *\param sess the download session + *\return the last error in the session or 0 if none*/ +GF_Err gf_dm_sess_process_headers(GF_DownloadSession * sess); + +/*! + *\brief fetch session status + * + *Fetch the session current status + *\param sess the download session + *\return the session status*/ +u32 gf_dm_sess_get_status(GF_DownloadSession * sess); +/*! + *\brief Get session resource url + * + *Returns the original resource URL associated with the session + *\param sess the download session + *\return the associated URL + */ +const char *gf_dm_sess_get_resource_name(GF_DownloadSession *sess); +/*! + *\brief Get session original resource url + * + *Returns the original resource URL before any redirection associated with the session + *\param sess the download session + *\return the associated URL + */ +const char *gf_dm_sess_get_original_resource_name(GF_DownloadSession *sess); + + +/*! + * \brief Download a file over the network using a download manager + * \param dm The downlaod manager to use, function will use all associated cache ressources + * \param url The url to download + * \param filename The filename to download + * \param start_range start position of a byte range + * \param end_range end position of a byte range + * \return GF_OK if everything went fine, an error otherwise + */ +GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, + const char *url, const char *filename, u64 start_range, u64 end_range); + +/*! + * \brief Same as gf_dm_wget_with_cache, but initializes the GF_DownloadManager by itself. + * This function is deprecated, please use gf_dm_wget_with_cache instead + * \param url The url to download + * \param filename The filename to download + * \param start_range start position of a byte range + * \param end_range end position of a byte range + * \return GF_OK if everything went fine, an error otherwise + */ +GF_Err gf_dm_wget(const char *url, const char *filename, u64 start_range, u64 end_range); + +/*! + *\brief Reset session + * + *Resets the session for new processing of the same url + *\param sess the download session + *\return error code if any + */ +GF_Err gf_dm_sess_reset(GF_DownloadSession *sess); + +/*! + * \brief forces the refresh of a cache entry + * The entry is still allocated in the session. + * \param sess The session + * \return a pointer to the entry of session refreshed + */ +DownloadedCacheEntry gf_dm_refresh_cache_entry(GF_DownloadSession *sess); + +/*! + * Tells whether session can be cached on disk. + * Typically, when request has no content length, it deserves being streamed an cannot be cached + * (ICY or MPEG-streamed content + * \param sess The session + * \return True if a cache can be created + */ +Bool gf_dm_sess_can_be_cached_on_disk(const GF_DownloadSession *sess); + + +/*! + * Reassigns session flags and callbacks. This is only possible if the session is not threaded. + * \param sess The session + * \param flags The new flags for the session - if flags is 0xFFFFFFFF, existing flags are not modified + * \param user_io The new callback function + * \param cbk The new user data to ba used in the callback function + * \return GF_OK or error + */ +GF_Err gf_dm_sess_reassign(GF_DownloadSession *sess, u32 flags, gf_dm_user_io user_io, void *cbk); + +/*! + * Re-setup an existing, completed session to download a new URL. If same server/port/protocol is used, the same socket will be reused if the session + * has the GF_NETIO_SESSION_PERSISTENT flag set. This is only possible if the session is not threaded. + * \param sess The session + * \param url The new url for the session + * \return GF_OK or error + */ +GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url); + +/* + *\retrieves the HTTP header value for the given name + * + *Retrieves the HTTP header value for the given header name. + *\param sess the current session + *\param name the target header name + * \return header value or NULL if not found + */ +const char *gf_dm_sess_get_header(GF_DownloadSession *sess, const char *name); + +/* + *\brief sets download manager max rate per session + * + *Sets the maximum rate (per session only at the current time). + *\param dm the download manager object + *\param rate_in_bits_per_sec the new rate in bits per sec. If 0, HTTP rate will not be limited + */ +void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_bits_per_sec); + +/* + *\brief gets download manager max rate per session + * + *Sets the maximum rate (per session only at the current time). + *\param dm the download manager object + *\return the rate in bits per sec. If 0, HTTP rate is not limited + */ +u32 gf_dm_get_data_rate(GF_DownloadManager *dm); + + +/* + *\brief fetches remote file in memory + * + *Fetches remote file in memory . + *\param url the data to fetch + *\param out_data output data (allocated by function) + *\param out_size output data size + *\param out_mime if not NULL, pointer will contain the mime type (allocated by function) + *\return error code if any + */ +GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, char **out_mime); +/*! @} */ #ifdef __cplusplus } diff --git a/include/gpac/dsmcc.h b/include/gpac/dsmcc.h index 8cb0f3f..444db69 100644 --- a/include/gpac/dsmcc.h +++ b/include/gpac/dsmcc.h @@ -41,27 +41,27 @@ extern "C" { #define DSMCC_SECTION_LENGTH_MAX 4093 -typedef enum{ +typedef enum { DOWNLOAD_INFO_REQUEST = 0x1001, DOWNLOAD_INFO_REPONSE_INDICATION = 0x1002, DOWNLOAD_DATA_BLOCK = 0x1003, DOWNLOAD_DATA_REQUEST = 0x1004, DOWNLOAD_DATA_CANCEL = 0x1005, DOWNLOAD_SERVER_INITIATE = 0x1006 -}DSMCC_DOWNLOAD_MESSAGE_ID; +} DSMCC_DOWNLOAD_MESSAGE_ID; -typedef enum{ +typedef enum { TAG_BIOP = 0x49534F06, TAG_LITE_OPTIONS = 0x49534F05 -}DSMCC_DOWNLOAD_PROFILE_ID_TAG; +} DSMCC_DOWNLOAD_PROFILE_ID_TAG; -typedef enum{ +typedef enum { CACHING_PRIORITY_DESCRIPTOR = 0x71, CONTENT_TYPE_DESCRIPTOR = 0x72, COMPRESSED_MODULE_DESCRIPTOR = 0x09 -}DSMCC_BIOP_DESCRIPTOR; +} DSMCC_BIOP_DESCRIPTOR; -typedef struct{ +typedef struct { u8 descriptor_tag; u8 descriptor_length; u32 carousel_id; @@ -76,7 +76,7 @@ typedef struct{ u8 TimeOut; u8 ObjectKeyLength; char* ObjectKeyData; -}GF_M2TS_CAROUSEL_INDENTIFIER_DESCRIPTOR; +} GF_M2TS_CAROUSEL_INDENTIFIER_DESCRIPTOR; typedef struct { @@ -84,7 +84,7 @@ typedef struct u32 downloadId; u32 version_number; Bool done; -}GF_M2TS_DSMCC_PROCESSED; +} GF_M2TS_DSMCC_PROCESSED; typedef struct { @@ -116,7 +116,7 @@ typedef struct Bool Gzip; /* Size of the module's data after uncompression */ u32 original_size; -}GF_M2TS_DSMCC_MODULE; +} GF_M2TS_DSMCC_MODULE; typedef struct { @@ -135,11 +135,11 @@ typedef struct /* section number of the data block if carried by the section */ u8 section_number; /* last section number of the data block if carried by the section */ - u8 last_section_number; + u8 last_section_number; void* DSMCC_Extension; u32 checksum; u32 CRC_32; -}GF_M2TS_DSMCC_SECTION; +} GF_M2TS_DSMCC_SECTION; typedef struct { @@ -164,7 +164,7 @@ typedef struct u8 header_length; GF_M2TS_DSMCC_ADAPTATION_HEADER* DsmccAdaptationHeader; -}GF_M2TS_DSMCC_MESSAGE_DATA_HEADER; +} GF_M2TS_DSMCC_MESSAGE_DATA_HEADER; /* DOWNLOAD_DATA_MESSAGE */ typedef struct @@ -178,15 +178,15 @@ typedef struct u16 messageLength; GF_M2TS_DSMCC_ADAPTATION_HEADER* DsmccAdaptationHeader; -}GF_M2TS_DSMCC_DOWNLOAD_DATA_HEADER; +} GF_M2TS_DSMCC_DOWNLOAD_DATA_HEADER; typedef struct -{ +{ u8 subDescriptorType; - u8 subDescriptorLength; + u8 subDescriptorLength; char *additionalInformation; -}GF_M2TS_DSMCC_SUBDESCRIPTOR; +} GF_M2TS_DSMCC_SUBDESCRIPTOR; typedef struct { @@ -199,23 +199,23 @@ typedef struct u8 subDescriptorCount; GF_M2TS_DSMCC_SUBDESCRIPTOR* SubDescriptor; -}GF_M2TS_DSMCC_DESCRIPTOR; +} GF_M2TS_DSMCC_DESCRIPTOR; typedef struct { u16 compatibilityDescriptorLength; u16 descriptorCount; GF_M2TS_DSMCC_DESCRIPTOR* Descriptor; -}GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR; +} GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR; typedef struct -{ +{ u32 bufferSize; u16 maximumBlockSize; GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR CompatibilityDescr; u16 privateDataLength; char* privateDataByte; -}GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST; +} GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST; typedef struct { @@ -224,10 +224,10 @@ typedef struct u8 moduleVersion; u8 moduleInfoLength; char* moduleInfoByte; -}GF_M2TS_DSMCC_INFO_MODULES; +} GF_M2TS_DSMCC_INFO_MODULES; typedef struct -{ +{ u32 downloadId; u16 blockSize; u8 windowSize; @@ -237,12 +237,12 @@ typedef struct GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR CompatibilityDescr; u16 numberOfModules; GF_M2TS_DSMCC_INFO_MODULES Modules; - u16 privateDataLength; + u16 privateDataLength; char* privateDataByte; -}GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC; +} GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC; typedef struct -{ +{ u8 moduleId; u8 moduleVersion; u8 reserved; @@ -250,17 +250,17 @@ typedef struct char* blockDataByte; /*added not in the spec */ u32 dataBlocksize; -}GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK; +} GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK; typedef struct -{ +{ u16 moduleId; u16 blockNumber; u8 downloadReason; -}GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE; +} GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE; typedef struct -{ +{ u32 downloadId; u16 moduleId; u16 blockNumber; @@ -268,40 +268,40 @@ typedef struct u8 reserved; u16 privateDataLength; char* privateDataByte; -}GF_M2TS_DSMCC_DOWNLOAD_CANCEL; +} GF_M2TS_DSMCC_DOWNLOAD_CANCEL; typedef struct -{ +{ u32 GroupId; u32 GroupSize; GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR CompatibilityDescr; u16 GroupInfoLength; char* groupInfoByte; -}GF_M2TS_DSMCC_INFO_GROUP; +} GF_M2TS_DSMCC_INFO_GROUP; typedef struct { u16 NumberOfGroups; - GF_M2TS_DSMCC_INFO_GROUP* InfoGroup; + GF_M2TS_DSMCC_INFO_GROUP* InfoGroup; u16 PrivateDataLength; char* privateDataByte; -}GF_M2TS_DSMCC_GROUP_INFO_INDICATION; +} GF_M2TS_DSMCC_GROUP_INFO_INDICATION; typedef struct -{ +{ u8 serverId[20]; GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR CompatibilityDescr; u16 privateDataLength; char* privateDataByte; GF_M2TS_DSMCC_GROUP_INFO_INDICATION* GroupInfoIndic; -}GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT; +} GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT; typedef struct { GF_M2TS_DSMCC_MESSAGE_DATA_HEADER DownloadDataHeader; void* dataMessagePayload; -}GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE; +} GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE; /* DESCRIPTOR LIST */ @@ -315,7 +315,7 @@ typedef struct u8 NPT_Reference[5]; u16 scaleNumerator; u16 scaleDenominator; -}GF_M2TS_DSMCC_NPT_REFERENCE_DESCRIPTOR; +} GF_M2TS_DSMCC_NPT_REFERENCE_DESCRIPTOR; typedef struct @@ -323,10 +323,10 @@ typedef struct u8 descriptorTag; u8 descriptorLength; void* descriptor; -}GF_M2TS_DSMCC_STREAM_DESCRIPTOR; +} GF_M2TS_DSMCC_STREAM_DESCRIPTOR; /* OBJECT CAROUSEL */ -typedef struct{ +typedef struct { u16 id; u16 use; u16 assocTag; @@ -335,21 +335,21 @@ typedef struct{ u16 selector_type; u32 transactionId; u32 timeout; -}GF_M2TS_DSMCC_BIOP_TAPS; +} GF_M2TS_DSMCC_BIOP_TAPS; -typedef struct{ +typedef struct { u8 AFI; u8 type; u32 carouselId; u8 specifierType; u32 specifierData; - u16 transport_stream_id; + u16 transport_stream_id; u16 original_network_id; u16 service_id; u32 reserved; -}GF_M2TS_DSMCC_SERVICE_DOMAIN; +} GF_M2TS_DSMCC_SERVICE_DOMAIN; -typedef struct{ +typedef struct { u32 componentId_tag; u8 component_data_length; u32 carouselId; @@ -358,29 +358,29 @@ typedef struct{ u8 version_minor; u8 objectKey_length; u32 objectKey_data; -}GF_M2TS_DSMCC_BIOP_OBJECT_LOCATION; +} GF_M2TS_DSMCC_BIOP_OBJECT_LOCATION; -typedef struct{ +typedef struct { u32 componentId_tag; u8 component_data_length; u8 taps_count; GF_M2TS_DSMCC_BIOP_TAPS* Taps; char* additional_tap_byte; -}GF_M2TS_DSMCC_BIOP_CONN_BINDER; +} GF_M2TS_DSMCC_BIOP_CONN_BINDER; -typedef struct{ +typedef struct { GF_M2TS_DSMCC_BIOP_OBJECT_LOCATION ObjectLocation; GF_M2TS_DSMCC_BIOP_CONN_BINDER ConnBinder; -}GF_M2TS_DSMCC_BIOP_PROFILE_BODY; +} GF_M2TS_DSMCC_BIOP_PROFILE_BODY; -typedef struct{ +typedef struct { u32 id_length; char* id_data; u32 kind_length; char* kind_data; -}GF_M2TS_DSMCC_BIOP_NAME_COMPONENT; +} GF_M2TS_DSMCC_BIOP_NAME_COMPONENT; -typedef struct{ +typedef struct { u32 componentId_tag; u8 component_data_length; u8 serviceDomain_length; @@ -389,15 +389,15 @@ typedef struct{ GF_M2TS_DSMCC_BIOP_NAME_COMPONENT* NameComponent; u32 initialContext_length; char* InitialContext_data_byte; -}GF_M2TS_DSMCC_BIOP_SERVICE_LOCATION; +} GF_M2TS_DSMCC_BIOP_SERVICE_LOCATION; -typedef struct{ +typedef struct { u32 componentId_tag; u8 component_data_length; char* component_data_byte; -}GF_M2TS_DSMCC_BIOP_LITE_COMPONENT; +} GF_M2TS_DSMCC_BIOP_LITE_COMPONENT; -typedef struct{ +typedef struct { u32 profileId_tag; u32 profile_data_length; u8 profile_data_byte_order; @@ -407,16 +407,16 @@ typedef struct{ GF_M2TS_DSMCC_BIOP_SERVICE_LOCATION* ServiceLocation; GF_M2TS_DSMCC_BIOP_LITE_COMPONENT* LiteComponent; -}GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE; +} GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE; -typedef struct{ +typedef struct { u32 type_id_length; char* type_id_byte; u32 taggedProfiles_count; GF_List* taggedProfile; -}GF_M2TS_DSMCC_IOR; +} GF_M2TS_DSMCC_IOR; -typedef struct{ +typedef struct { u32 moduleTimeOut; u32 blockTimeOut; u32 minBlockTime; @@ -426,17 +426,17 @@ typedef struct{ u8* userInfo_data; GF_List* descriptor; - u8 compression_method; - u8 transparency_level; -}GF_M2TS_DSMCC_BIOP_MODULE_INFO; + u8 compression_method; + u8 transparency_level; +} GF_M2TS_DSMCC_BIOP_MODULE_INFO; -typedef struct{ +typedef struct { u32 context_id; u16 context_data_length; char* context_data_byte; -}GF_M2TS_DSMCC_SERVICE_CONTEXT; +} GF_M2TS_DSMCC_SERVICE_CONTEXT; -typedef struct{ +typedef struct { GF_M2TS_DSMCC_IOR IOR; u8 downloadTaps_count; GF_M2TS_DSMCC_BIOP_TAPS* Taps; @@ -444,32 +444,32 @@ typedef struct{ GF_M2TS_DSMCC_SERVICE_CONTEXT* ServiceContext; u16 userInfoLength; char* userInfo_data; -}GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO; +} GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO; /* DESCRIPTORS */ -typedef struct{ +typedef struct { u8 descriptor_tag; u8 descriptor_length; u8 priority_value; u8 transparency_level; -}GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR; +} GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR; -typedef struct{ +typedef struct { u8 descriptor_tag; u8 descriptor_length; u8 compression_method; u32 original_size; -}GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR; +} GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR; -typedef struct{ +typedef struct { u8 descriptor_tag; - u8 descriptor_length; + u8 descriptor_length; char* content_type_data_byte; -}GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR; +} GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR; -typedef struct{ +typedef struct { /* "BIOP" */ u32 magic; u8 biop_version_major; @@ -490,9 +490,9 @@ typedef struct{ /* The number that identifies the object in the module */ char* objectKind_data; u16 objectInfo_length; -}GF_M2TS_DSMCC_BIOP_HEADER; +} GF_M2TS_DSMCC_BIOP_HEADER; -typedef struct{ +typedef struct { GF_M2TS_DSMCC_BIOP_HEADER* Header; u64 ContentSize; GF_List* descriptor; @@ -503,9 +503,9 @@ typedef struct{ u32 content_length; /* data a the file */ char* content_byte; -}GF_M2TS_DSMCC_BIOP_FILE; +} GF_M2TS_DSMCC_BIOP_FILE; -typedef struct{ +typedef struct { /* Name */ u8 nameComponents_count; /* There is must be only one nameComponent */ @@ -527,9 +527,9 @@ typedef struct{ u16 objectInfo_length; u64 ContentSize; GF_List* descriptor; -}GF_M2TS_DSMCC_BIOP_NAME; +} GF_M2TS_DSMCC_BIOP_NAME; -typedef struct{ +typedef struct { GF_M2TS_DSMCC_BIOP_HEADER* Header; char* objectInfo_data; u8 serviceContextList_count; @@ -539,49 +539,49 @@ typedef struct{ /* Number of the item */ u16 bindings_count; /* List of the item in the directory */ - GF_M2TS_DSMCC_BIOP_NAME* Name; -}GF_M2TS_DSMCC_BIOP_DIRECTORY; + GF_M2TS_DSMCC_BIOP_NAME* Name; +} GF_M2TS_DSMCC_BIOP_DIRECTORY; -typedef struct{ - u8 aDescription_length; +typedef struct { + u8 aDescription_length; char* aDescription_bytes; u32 duration_aSeconds; u32 duration_aMicroseconds; - u8 audio; - u8 video; + u8 audio; + u8 video; u8 data; -}GF_M2TS_DSMCC_STREAM_INFO; +} GF_M2TS_DSMCC_STREAM_INFO; -typedef struct{ - GF_M2TS_DSMCC_BIOP_HEADER* Header; +typedef struct { + GF_M2TS_DSMCC_BIOP_HEADER* Header; GF_M2TS_DSMCC_STREAM_INFO Info; char* objectInfo_byte; - u8 serviceContextList_count; + u8 serviceContextList_count; GF_M2TS_DSMCC_SERVICE_CONTEXT* ServiceContext; - u32 messageBody_length; + u32 messageBody_length; u8 taps_count; - GF_M2TS_DSMCC_BIOP_TAPS* Taps; -}GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE; + GF_M2TS_DSMCC_BIOP_TAPS* Taps; +} GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE; -typedef struct{ - u8 eventName_length; +typedef struct { + u8 eventName_length; char* eventName_data_byte; -}GF_M2TS_DSMCC_BIOP_EVENT_LIST; +} GF_M2TS_DSMCC_BIOP_EVENT_LIST; -typedef struct{ - GF_M2TS_DSMCC_BIOP_HEADER* Header; - GF_M2TS_DSMCC_STREAM_INFO Info; +typedef struct { + GF_M2TS_DSMCC_BIOP_HEADER* Header; + GF_M2TS_DSMCC_STREAM_INFO Info; u16 eventNames_count; GF_M2TS_DSMCC_BIOP_EVENT_LIST* EventList; char* objectInfo_byte; - u8 serviceContextList_count; + u8 serviceContextList_count; GF_M2TS_DSMCC_SERVICE_CONTEXT* ServiceContext; - u32 messageBody_length; + u32 messageBody_length; u8 taps_count; - GF_M2TS_DSMCC_BIOP_TAPS* Taps; - u8 eventIds_count; + GF_M2TS_DSMCC_BIOP_TAPS* Taps; + u8 eventIds_count; u16* eventId; -}GF_M2TS_DSMCC_BIOP_STREAM_EVENT; +} GF_M2TS_DSMCC_BIOP_STREAM_EVENT; /*Define the base element for extracted dsmcc element*/ #define GF_M2TS_DSMCC_ELEMENT \ @@ -593,11 +593,11 @@ typedef struct{ void* parent; typedef struct -{ +{ GF_M2TS_DSMCC_ELEMENT /*Path to the file */ char* Path; -}GF_M2TS_DSMCC_FILE; +} GF_M2TS_DSMCC_FILE; typedef struct { GF_M2TS_DSMCC_ELEMENT @@ -607,7 +607,7 @@ typedef struct GF_List* Dir; /*Path to the directory */ char* Path; -}GF_M2TS_DSMCC_DIR; +} GF_M2TS_DSMCC_DIR; typedef struct { GF_M2TS_DSMCC_ELEMENT @@ -619,14 +619,14 @@ typedef struct GF_List* File; /* List of directories of the root of the file system*/ GF_List* Dir; -}GF_M2TS_DSMCC_SERVICE_GATEWAY; +} GF_M2TS_DSMCC_SERVICE_GATEWAY; typedef struct -{ +{ /* List that carries the modules to process */ GF_List* dsmcc_modules; /* List of processed module */ - GF_M2TS_DSMCC_PROCESSED processed[512]; + GF_M2TS_DSMCC_PROCESSED processed[512]; /*Check if the ServiceGateway has been recovered*/ /* 1 ServiceGateway received */ /* 0 otherwise */ diff --git a/include/gpac/dvb_mpe.h b/include/gpac/dvb_mpe.h index 2151836..55f749b 100644 --- a/include/gpac/dvb_mpe.h +++ b/include/gpac/dvb_mpe.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the gf_free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the gf_free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the gf_free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/esi.h b/include/gpac/esi.h index f92e840..cc0ae0f 100644 --- a/include/gpac/esi.h +++ b/include/gpac/esi.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -60,7 +60,7 @@ enum */ GF_ESI_OUTPUT_DATA_DISPATCH }; - + /* data packet flags */ @@ -116,7 +116,7 @@ enum GF_ESI_STREAM_WITHOUT_MPEG4_SYSTEMS = 1<<3, }; -typedef struct __elementary_stream_ifce +typedef struct __elementary_stream_ifce { /*misc caps of the stream*/ u32 caps; @@ -139,10 +139,10 @@ typedef struct __elementary_stream_ifce u32 bit_rate; /*repeat rate in ms for carrouseling - 0 if no repeat*/ u32 repeat_rate; - + char *decoder_config; u32 decoder_config_size; - + /* MPEG-4 SL Config if any*/ GF_SLConfig *sl_config; diff --git a/include/gpac/events.h b/include/gpac/events.h index a8e17aa..ecf06d6 100644 --- a/include/gpac/events.h +++ b/include/gpac/events.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -281,15 +281,15 @@ typedef struct { } GF_EventOpenFile; typedef struct { - /* GF_EVENT_FORWARDED*/ + /*GF_EVENT_FROM_SERVICE*/ u8 type; - /*one of te above event*/ + //cf GF_EVT_FORWARDED_ * u8 forward_type; /*original type of event as forwarded by the service*/ u32 service_event_type; /*parameter of event as forwarded by the service - creation/deletion is handled by the service*/ void *param; -} GF_EventForwarded; +} GF_EventFromService; typedef union { @@ -311,9 +311,9 @@ typedef union GF_EventMove move; GF_EventVideoSetup setup; GF_EventMutation mutation; - GF_EventForwarded forwarded_event; GF_EventOpenFile open_file; GF_EventAddonConnect addon_connect; + GF_EventFromService from_service; } GF_Event; diff --git a/include/gpac/events_constants.h b/include/gpac/events_constants.h index ec644a9..a8eeb64 100644 --- a/include/gpac/events_constants.h +++ b/include/gpac/events_constants.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -121,23 +121,23 @@ typedef enum { GF_EVENT_MEDIA_SETUP_DONE, /*not HTML5 but should be :)*/ GF_EVENT_MEDIA_LOAD_START, GF_EVENT_MEDIA_LOAD_DONE, /*not HTML5 but should be :)*/ - GF_EVENT_MEDIA_PROGRESS, - GF_EVENT_MEDIA_SUSPEND, - GF_EVENT_MEDIA_EMPTIED, - GF_EVENT_MEDIA_STALLED, - GF_EVENT_MEDIA_LOADED_METADATA, - GF_EVENT_MEDIA_LODADED_DATA, - GF_EVENT_MEDIA_CANPLAY, - GF_EVENT_MEDIA_CANPLAYTHROUGH, - GF_EVENT_MEDIA_PLAYING, - GF_EVENT_MEDIA_WAITING, - GF_EVENT_MEDIA_SEEKING, - GF_EVENT_MEDIA_SEEKED, - GF_EVENT_MEDIA_ENDED, - GF_EVENT_MEDIA_DURATION_CHANGED, - GF_EVENT_MEDIA_TIME_UPDATE, - GF_EVENT_MEDIA_RATECHANGE, - GF_EVENT_MEDIA_VOLUME_CHANGED, + GF_EVENT_MEDIA_PROGRESS, + GF_EVENT_MEDIA_SUSPEND, + GF_EVENT_MEDIA_EMPTIED, + GF_EVENT_MEDIA_STALLED, + GF_EVENT_MEDIA_LOADED_METADATA, + GF_EVENT_MEDIA_LODADED_DATA, + GF_EVENT_MEDIA_CANPLAY, + GF_EVENT_MEDIA_CANPLAYTHROUGH, + GF_EVENT_MEDIA_PLAYING, + GF_EVENT_MEDIA_WAITING, + GF_EVENT_MEDIA_SEEKING, + GF_EVENT_MEDIA_SEEKED, + GF_EVENT_MEDIA_ENDED, + GF_EVENT_MEDIA_DURATION_CHANGED, + GF_EVENT_MEDIA_TIME_UPDATE, + GF_EVENT_MEDIA_RATECHANGE, + GF_EVENT_MEDIA_VOLUME_CHANGED, GF_EVENT_HTML_MSE_SOURCE_OPEN, GF_EVENT_HTML_MSE_SOURCE_ENDED, @@ -196,7 +196,7 @@ typedef enum { * for 3D output, this means re-setup of OpenGL context (depending on HW constraints). Depending on windowing systems and implementations, it could be possible to resize a window without destroying the GL context. - - when sent from plugin to gpac, indicates that hardware has been setup. + - when sent from plugin to gpac, indicates that hardware has been setup. - when sent from gpac to user, indicate aspect ratio has been modified and video output is ready */ GF_EVENT_VIDEO_SETUP, @@ -225,9 +225,11 @@ typedef enum { GF_EVENT_DISCONNECT, /*indicates the current url should be disconnected*/ GF_EVENT_RESOLUTION, /*indicates the screen resolution has changed*/ GF_EVENT_OPENFILE, - /* Events for Keyboad */ - GF_EVENT_TEXT_EDITING_START, - GF_EVENT_TEXT_EDITING_END, + /* Events for Keyboad */ + GF_EVENT_TEXT_EDITING_START, + GF_EVENT_TEXT_EDITING_END, + + GF_EVENT_FROM_SERVICE, GF_EVENT_ADDON_DETECTED, } GF_EventType; @@ -440,7 +442,7 @@ typedef enum { GF_KEY_EPG, /*EPG*/ GF_KEY_RECORD, /*Record*/ GF_KEY_BEGINPAGE, /*BeginPage*/ - /* end STB */ + /* end STB */ /*non-dom keys, used in LASeR*/ GF_KEY_CELL_SOFT1, /*soft1 key of cell phones*/ @@ -490,10 +492,10 @@ enum enum { + //regular even codes + GF_EVT_REGULAR = 0, /*events forwarded from MPEG-2 stack*/ - GF_EVT_FORWARDED_MPEG2 = 0, - /*events forwarded from RTP/RTSP/IP stack (not used yet)*/ - GF_EVT_FORWARDED_RTP_RTSP + GF_EVT_MPEG2 = 1, }; #endif diff --git a/include/gpac/filestreamer.h b/include/gpac/filestreamer.h index 66e0d54..8d1daa1 100644 --- a/include/gpac/filestreamer.h +++ b/include/gpac/filestreamer.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2008-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -97,7 +97,7 @@ GF_Err gf_isom_streamer_get_sdp(GF_ISOMRTPStreamer *streamer, char **out_sdp_buf * Sends the next RTP packet in the current file, potentially waiting for the TS to be mature. If the last packet is sent and looping is disabled, this will return GF_EOS. * \param streamer RTP streamer object * \param send_ahead_delay delay in milliseconds for packet sending. A packet is sent if (packet.timestamp + send_ahead_delay) is greate than the current time. - * \param max_sleep_time indicates that if the streamer has to wait more than max_sleep_time before sending the packet, it should return and send it later. + * \param max_sleep_time indicates that if the streamer has to wait more than max_sleep_time before sending the packet, it should return and send it later. */ GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ahead_delay, s32 max_sleep_time); diff --git a/include/gpac/html5_media.h b/include/gpac/html5_media.h index 7ed55fe..f069224 100644 --- a/include/gpac/html5_media.h +++ b/include/gpac/html5_media.h @@ -46,46 +46,48 @@ extern "C" { #include #include +#ifdef GPAC_HAS_SPIDERMONKEY #include +#endif typedef struct { - u32 nb_inst; - /* Basic classes */ - GF_JSClass arrayBufferClass; - - /*HTML Media classes*/ - GF_JSClass htmlVideoElementClass; - GF_JSClass htmlAudioElementClass; - GF_JSClass htmlSourceElementClass; - GF_JSClass htmlTrackElementClass; - GF_JSClass htmlMediaElementClass; - GF_JSClass mediaControllerClass; - GF_JSClass audioTrackListClass; - GF_JSClass audioTrackClass; - GF_JSClass videoTrackListClass; - GF_JSClass videoTrackClass; - GF_JSClass textTrackListClass; - GF_JSClass textTrackClass; - GF_JSClass textTrackCueListClass; - GF_JSClass textTrackCueClass; - GF_JSClass timeRangesClass; - GF_JSClass trackEventClass; - GF_JSClass mediaErrorClass; - - /* Media Source Extensions */ - GF_JSClass mediaSourceClass; - GF_JSClass sourceBufferClass; - GF_JSClass sourceBufferListClass; - GF_JSClass URLClass; - - /* Media Capture */ - GF_JSClass mediaStreamClass; - GF_JSClass localMediaStreamClass; - GF_JSClass mediaStreamTrackClass; - GF_JSClass mediaStreamTrackListClass; - GF_JSClass navigatorUserMediaClass; - GF_JSClass navigatorUserMediaErrorClass; + u32 nb_inst; + /* Basic classes */ + GF_JSClass arrayBufferClass; + + /*HTML Media classes*/ + GF_JSClass htmlVideoElementClass; + GF_JSClass htmlAudioElementClass; + GF_JSClass htmlSourceElementClass; + GF_JSClass htmlTrackElementClass; + GF_JSClass htmlMediaElementClass; + GF_JSClass mediaControllerClass; + GF_JSClass audioTrackListClass; + GF_JSClass audioTrackClass; + GF_JSClass videoTrackListClass; + GF_JSClass videoTrackClass; + GF_JSClass textTrackListClass; + GF_JSClass textTrackClass; + GF_JSClass textTrackCueListClass; + GF_JSClass textTrackCueClass; + GF_JSClass timeRangesClass; + GF_JSClass trackEventClass; + GF_JSClass mediaErrorClass; + + /* Media Source Extensions */ + GF_JSClass mediaSourceClass; + GF_JSClass sourceBufferClass; + GF_JSClass sourceBufferListClass; + GF_JSClass URLClass; + + /* Media Capture */ + GF_JSClass mediaStreamClass; + GF_JSClass localMediaStreamClass; + GF_JSClass mediaStreamTrackClass; + GF_JSClass mediaStreamTrackListClass; + GF_JSClass navigatorUserMediaClass; + GF_JSClass navigatorUserMediaErrorClass; } GF_HTML_MediaRuntime; /************************************************************ @@ -97,55 +99,55 @@ typedef struct typedef enum { - MEDIA_ERR_ABORTED = 1, - MEDIA_ERR_NETWORK = 2, - MEDIA_ERR_DECODE = 3, - MEDIA_ERR_SRC_NOT_SUPPORTED = 4 + MEDIA_ERR_ABORTED = 1, + MEDIA_ERR_NETWORK = 2, + MEDIA_ERR_DECODE = 3, + MEDIA_ERR_SRC_NOT_SUPPORTED = 4 } GF_HTML_MediaErrorCode; typedef enum { - NETWORK_EMPTY = 0, - NETWORK_IDLE = 1, - NETWORK_LOADING = 2, - NETWORK_NO_SOURCE = 3 + NETWORK_EMPTY = 0, + NETWORK_IDLE = 1, + NETWORK_LOADING = 2, + NETWORK_NO_SOURCE = 3 } GF_HTML_NetworkState; typedef enum { - HAVE_NOTHING = 0, - HAVE_METADATA = 1, - HAVE_CURRENT_DATA = 2, - HAVE_FUTURE_DATA = 3, - HAVE_ENOUGH_DATA = 4 + HAVE_NOTHING = 0, + HAVE_METADATA = 1, + HAVE_CURRENT_DATA = 2, + HAVE_FUTURE_DATA = 3, + HAVE_ENOUGH_DATA = 4 } GF_HTML_MediaReadyState; typedef struct { - /* JavaScript context associated to this object */ - JSContext *c; - /* JavaScript counterpart */ - JSObject *_this; + /* JavaScript context associated to this object */ + JSContext *c; + /* JavaScript counterpart */ + JSObject *_this; - GF_HTML_MediaErrorCode code; + GF_HTML_MediaErrorCode code; } GF_HTML_MediaError; typedef struct _timerange { - /* JavaScript context associated to this object */ - JSContext *c; - /* JavaScript counterpart */ - JSObject *_this; + /* JavaScript context associated to this object */ + JSContext *c; + /* JavaScript counterpart */ + JSObject *_this; - GF_List *times; + GF_List *times; u32 timescale; } GF_HTML_MediaTimeRanges; typedef enum { - HTML_MEDIA_TRACK_TYPE_UNKNOWN = 0, - HTML_MEDIA_TRACK_TYPE_AUDIO = 1, - HTML_MEDIA_TRACK_TYPE_VIDEO = 2, - HTML_MEDIA_TRACK_TYPE_TEXT = 3 + HTML_MEDIA_TRACK_TYPE_UNKNOWN = 0, + HTML_MEDIA_TRACK_TYPE_AUDIO = 1, + HTML_MEDIA_TRACK_TYPE_VIDEO = 2, + HTML_MEDIA_TRACK_TYPE_TEXT = 3 } GF_HTML_TrackType; #define BASE_HTML_TRACK \ @@ -175,21 +177,21 @@ typedef enum { char *label;\ char *language;\ char *mime; \ - Bool enabled_or_selected; + Bool enabled_or_selected; typedef struct { - BASE_HTML_TRACK + BASE_HTML_TRACK } GF_HTML_Track; typedef struct { - BASE_HTML_TRACK + BASE_HTML_TRACK JSFunction *oncuechange; - char *inBandMetadataTrackDispatchType; - //GF_HTMLTextTrackMode mode; - //GF_HTMLTextTrackCueList cues; - //GF_HTMLTextTrackCueList activeCues; + char *inBandMetadataTrackDispatchType; + //GF_HTMLTextTrackMode mode; + //GF_HTMLTextTrackCueList cues; + //GF_HTMLTextTrackCueList activeCues; } GF_HTML_TextTrack; #define BASE_HTML_TRACK_LIST \ @@ -205,108 +207,108 @@ typedef struct typedef struct { - BASE_HTML_TRACK_LIST + BASE_HTML_TRACK_LIST } GF_HTML_TrackList; typedef enum { - MEDIA_CONTROLLER_WAITING = 0, - MEDIA_CONTROLLER_PLAYING = 1, - MEDIA_CONTROLLER_ENDED = 2 + MEDIA_CONTROLLER_WAITING = 0, + MEDIA_CONTROLLER_PLAYING = 1, + MEDIA_CONTROLLER_ENDED = 2 } GF_HTML_MediaControllerPlaybackState; typedef struct { - /* JavaScript context associated to this object */ - JSContext *c; - /* JavaScript counterpart */ - JSObject *_this; - - GF_HTML_MediaTimeRanges *buffered; - GF_HTML_MediaTimeRanges *seekable; - GF_HTML_MediaTimeRanges *played; - Bool paused; - GF_HTML_MediaControllerPlaybackState playbackState; - double defaultPlaybackRate; - - /* list of media elements using this media controller */ - GF_List *media_elements; + /* JavaScript context associated to this object */ + JSContext *c; + /* JavaScript counterpart */ + JSObject *_this; + + GF_HTML_MediaTimeRanges *buffered; + GF_HTML_MediaTimeRanges *seekable; + GF_HTML_MediaTimeRanges *played; + Bool paused; + GF_HTML_MediaControllerPlaybackState playbackState; + double defaultPlaybackRate; + + /* list of media elements using this media controller */ + GF_List *media_elements; } GF_HTML_MediaController; typedef struct { - /* JavaScript context associated to this object */ - JSContext *c; - /* JavaScript counterpart */ - JSObject *_this; - - /* The audio or video node */ - GF_Node *node; - - /* error state */ - GF_HTML_MediaError error; - - /* src: not stored in this structure, - using the value stored in the node ( see HTML 5 "must reflect the content of the attribute")*/ - /* currentSrc: the actual source used for the video (src attribute on video, audio or source elements) */ - char *currentSrc; - /* crossOrigin: "must reflect the content of the attribute of the same name", use the node */ - /* networkState: retrieved dynamically from GPAC Service */ - /* preload: "must reflect the content of the attribute of the same name", use the node */ - GF_HTML_MediaTimeRanges *buffered; - /* ready state */ - /* readyState: retrieved from GPAC Media Object dynamically */ - Bool seeking; - - /* playback state */ - /* currentTime: retrieved from GPAC Media Object */ - /* duration: retrieved from GPAC Media Object */ - char *startDate; - Bool paused; - double defaultPlaybackRate; - GF_HTML_MediaTimeRanges *played; - GF_HTML_MediaTimeRanges *seekable; - /* ended: retrieved from the state of GPAC Media Object */ - /* autoplay: "must reflect the content of the attribute of the same name", use the node */ - /* loop: "must reflect the content of the attribute of the same name", use the node */ - - /* media controller*/ - /* mediaGroup: "must reflect the content of the attribute of the same name", use the node */ - GF_HTML_MediaController *controller; - - /* controls*/ - /* controls: "must reflect the content of the attribute of the same name", use the node */ - /* volume: retrieved from GPAC Audio Input in GPAC Media Object */ - /* muted: retrieved from GPAC media object */ - /* defaultMuted: "must reflect the content of the attribute of with the name" muted */ - - /* tracks*/ - GF_HTML_TrackList audioTracks; - GF_HTML_TrackList videoTracks; - GF_HTML_TrackList textTracks; + /* JavaScript context associated to this object */ + JSContext *c; + /* JavaScript counterpart */ + JSObject *_this; + + /* The audio or video node */ + GF_Node *node; + + /* error state */ + GF_HTML_MediaError error; + + /* src: not stored in this structure, + using the value stored in the node ( see HTML 5 "must reflect the content of the attribute")*/ + /* currentSrc: the actual source used for the video (src attribute on video, audio or source elements) */ + char *currentSrc; + /* crossOrigin: "must reflect the content of the attribute of the same name", use the node */ + /* networkState: retrieved dynamically from GPAC Service */ + /* preload: "must reflect the content of the attribute of the same name", use the node */ + GF_HTML_MediaTimeRanges *buffered; + /* ready state */ + /* readyState: retrieved from GPAC Media Object dynamically */ + Bool seeking; + + /* playback state */ + /* currentTime: retrieved from GPAC Media Object */ + /* duration: retrieved from GPAC Media Object */ + char *startDate; + Bool paused; + double defaultPlaybackRate; + GF_HTML_MediaTimeRanges *played; + GF_HTML_MediaTimeRanges *seekable; + /* ended: retrieved from the state of GPAC Media Object */ + /* autoplay: "must reflect the content of the attribute of the same name", use the node */ + /* loop: "must reflect the content of the attribute of the same name", use the node */ + + /* media controller*/ + /* mediaGroup: "must reflect the content of the attribute of the same name", use the node */ + GF_HTML_MediaController *controller; + + /* controls*/ + /* controls: "must reflect the content of the attribute of the same name", use the node */ + /* volume: retrieved from GPAC Audio Input in GPAC Media Object */ + /* muted: retrieved from GPAC media object */ + /* defaultMuted: "must reflect the content of the attribute of with the name" muted */ + + /* tracks*/ + GF_HTML_TrackList audioTracks; + GF_HTML_TrackList videoTracks; + GF_HTML_TrackList textTracks; GF_DOMEventTarget *evt_target; } GF_HTML_MediaElement; -typedef struct +typedef struct { - /* JavaScript context used to create the JavaScript object below */ - JSContext *c; + /* JavaScript context used to create the JavaScript object below */ + JSContext *c; - /* JavaScript counterpart for this object*/ - JSObject *_this; + /* JavaScript counterpart for this object*/ + JSObject *_this; char *data; - u32 length; - char *url; + u32 length; + char *url; Bool is_init; /* used to do proper garbage collection between JS and Terminal */ - u32 reference_count; + u32 reference_count; } GF_HTML_ArrayBuffer; -/* - * TimeRanges +/* + * TimeRanges */ GF_HTML_MediaTimeRanges *gf_html_timeranges_new(u32 timescale); GF_Err gf_html_timeranges_add_start(GF_HTML_MediaTimeRanges *timeranges, u64 start); @@ -320,8 +322,8 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_union(GF_HTML_MediaTimeRanges *a, GF * HTML5 TrackList */ GF_HTML_Track *html_media_add_new_track_to_list(GF_HTML_TrackList *tracklist, - GF_HTML_TrackType type, const char *mime, Bool enable_or_selected, - const char *id, const char *kind, const char *label, const char *lang); + GF_HTML_TrackType type, const char *mime, Bool enable_or_selected, + const char *id, const char *kind, const char *label, const char *lang); Bool html_media_tracklist_has_track(GF_HTML_TrackList *tracklist, const char *id); GF_HTML_Track *html_media_tracklist_get_track(GF_HTML_TrackList *tracklist, const char *id); void gf_html_tracklist_del(GF_HTML_TrackList *tlist); @@ -333,7 +335,7 @@ GF_HTML_Track *gf_html_media_track_new(GF_HTML_TrackType type, const char *mime, const char *id, const char *kind, const char *label, const char *lang); void gf_html_track_del(GF_HTML_Track *track); -/* +/* * HTML5 Media Element */ GF_HTML_MediaElement *gf_html_media_element_new(GF_Node *media_node, GF_HTML_MediaController *mc); @@ -341,13 +343,13 @@ void gf_html_media_element_del(GF_HTML_MediaElement *me); void html_media_element_js_init(JSContext *c, JSObject *new_obj, GF_Node *n); -/* +/* * HTML5 Media Controller */ GF_HTML_MediaController *gf_html_media_controller_new(); void gf_html_media_controller_del(GF_HTML_MediaController *mc); -/* +/* * HTML5 Array Buffer */ GF_HTML_ArrayBuffer *gf_arraybuffer_new(char *data, u32 length); diff --git a/include/gpac/html5_mse.h b/include/gpac/html5_mse.h index c739882..dccc2a6 100644 --- a/include/gpac/html5_mse.h +++ b/include/gpac/html5_mse.h @@ -36,88 +36,88 @@ extern "C" { #include #include -typedef enum +typedef enum { - MEDIA_SOURCE_READYSTATE_CLOSED = 0, - MEDIA_SOURCE_READYSTATE_OPEN = 1, - MEDIA_SOURCE_READYSTATE_ENDED = 2, + MEDIA_SOURCE_READYSTATE_CLOSED = 0, + MEDIA_SOURCE_READYSTATE_OPEN = 1, + MEDIA_SOURCE_READYSTATE_ENDED = 2, } GF_HTML_MediaSource_ReadyState; -typedef enum +typedef enum { - MEDIA_SOURCE_APPEND_MODE_SEGMENTS = 0, - MEDIA_SOURCE_APPEND_MODE_SEQUENCE = 1 + MEDIA_SOURCE_APPEND_MODE_SEGMENTS = 0, + MEDIA_SOURCE_APPEND_MODE_SEQUENCE = 1 } GF_HTML_MediaSource_AppendMode; -typedef enum +typedef enum { - MEDIA_SOURCE_APPEND_STATE_WAITING_FOR_SEGMENT = 0, - MEDIA_SOURCE_APPEND_STATE_PARSING_INIT_SEGMENT = 1, - MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT = 2 + MEDIA_SOURCE_APPEND_STATE_WAITING_FOR_SEGMENT = 0, + MEDIA_SOURCE_APPEND_STATE_PARSING_INIT_SEGMENT = 1, + MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT = 2 } GF_HTML_MediaSource_AppendState; typedef struct { - /* Pointer back to the MediaSource object to which this source buffer is attached */ - struct _html_mediasource *mediasource; - - /* JavaScript counterpart for this object*/ - JSObject *_this; - - /* MSE defined properties */ - Bool updating; - GF_HTML_MediaTimeRanges *buffered; - s64 timestampOffset; - double appendWindowStart; - double appendWindowEnd; - u32 timescale; - - GF_HTML_MediaSource_AppendState append_state; - Bool buffer_full_flag; - /* Mode used to append media data: - - "segments" uses the timestamps in the media, + /* Pointer back to the MediaSource object to which this source buffer is attached */ + struct _html_mediasource *mediasource; + + /* JavaScript counterpart for this object*/ + JSObject *_this; + + /* MSE defined properties */ + Bool updating; + GF_HTML_MediaTimeRanges *buffered; + s64 timestampOffset; + double appendWindowStart; + double appendWindowEnd; + u32 timescale; + + GF_HTML_MediaSource_AppendState append_state; + Bool buffer_full_flag; + /* Mode used to append media data: + - "segments" uses the timestamps in the media, - "sequence" ignores them and appends just after the previous data */ - GF_HTML_MediaSource_AppendMode append_mode; + GF_HTML_MediaSource_AppendMode append_mode; /* time (in timescale units) of the first frame in the group */ - u64 group_start_timestamp; - Bool group_start_timestamp_flag; + u64 group_start_timestamp; + Bool group_start_timestamp_flag; /* time (in timescale units) of the frame end time (start + duration) in the group */ - u64 group_end_timestamp; - Bool group_end_timestamp_set; + u64 group_end_timestamp; + Bool group_end_timestamp_set; - Bool first_init_segment; + Bool first_init_segment; /* times (in timescale units) of the frames to be removed */ - u64 remove_start; - u64 remove_end; + u64 remove_start; + u64 remove_end; - /* - * GPAC internal objects + /* + * GPAC internal objects */ /* Media tracks (GF_HTML_Track) associated to this source buffer */ - GF_List *tracks; + GF_List *tracks; /* Buffers to parse */ GF_List *input_buffer; - /* We can only delete a buffer when we know it has been parsed, - i.e. when the next buffer is asked for, + /* We can only delete a buffer when we know it has been parsed, + i.e. when the next buffer is asked for, so we need to keep the buffer in the meantime */ - void *prev_buffer; + void *prev_buffer; /* Media parser */ - GF_InputService *parser; + GF_InputService *parser; /* MPEG-4 Object descriptor as returned by the media parser */ - GF_ObjectDescriptor *service_desc; + GF_ObjectDescriptor *service_desc; - /* Boolean indicating that the parser has parsed the initialisation segment */ + /* Boolean indicating that the parser has parsed the initialisation segment */ Bool parser_connected; /* Threads used to asynchronously parse the buffer and remove media data */ GF_List *threads; - GF_Thread *parser_thread; - GF_Thread *remove_thread; + GF_Thread *parser_thread; + GF_Thread *remove_thread; /* Object used to fire JavaScript events to */ GF_DOMEventTarget *evt_target; @@ -125,10 +125,10 @@ typedef struct typedef struct { - /* JavaScript counterpart for this object */ - JSObject *_this; + /* JavaScript counterpart for this object */ + JSObject *_this; - GF_List *list; + GF_List *list; struct _html_mediasource *parent; @@ -138,48 +138,48 @@ typedef struct typedef enum { - DURATION_NAN = 0, - DURATION_INFINITY = 1, - DURATION_VALUE = 2 + DURATION_NAN = 0, + DURATION_INFINITY = 1, + DURATION_VALUE = 2 } GF_HTML_MediaSource_DurationType; typedef struct _html_mediasource { - /* JavaScript context associated to all the objects */ - JSContext *c; + /* JavaScript context associated to all the objects */ + JSContext *c; - /* JavaScript counterpart for this object*/ - JSObject *_this; + /* JavaScript counterpart for this object*/ + JSObject *_this; /* Used to determine if the object can be safely deleted (not used by JS, not used by the service) */ u32 reference_count; - GF_HTML_SourceBufferList sourceBuffers; - GF_HTML_SourceBufferList activeSourceBuffers; + GF_HTML_SourceBufferList sourceBuffers; + GF_HTML_SourceBufferList activeSourceBuffers; - double duration; - GF_HTML_MediaSource_DurationType durationType; + double duration; + GF_HTML_MediaSource_DurationType durationType; - u32 readyState; + u32 readyState; - /* URL created by the call to createObjectURL on this MediaSource*/ - char *blobURI; + /* URL created by the call to createObjectURL on this MediaSource*/ + char *blobURI; - /* GPAC Terminal Service object - it is associated to this MediaSource when the Media element uses the blobURI of this MediaSource - should be NULL when the MediaSource is not open - we use only one service object for all sourceBuffers - */ - GF_ClientService *service; + /* GPAC Terminal Service object + it is associated to this MediaSource when the Media element uses the blobURI of this MediaSource + should be NULL when the MediaSource is not open + we use only one service object for all sourceBuffers + */ + GF_ClientService *service; /* SceneGraph to be used before the node is actually attached */ - GF_SceneGraph *sg; + GF_SceneGraph *sg; - /* Node the MediaSource is attached to */ - GF_Node *node; + /* Node the MediaSource is attached to */ + GF_Node *node; - /* object implementing Event Target Interface */ - GF_DOMEventTarget *evt_target; + /* object implementing Event Target Interface */ + GF_DOMEventTarget *evt_target; } GF_HTML_MediaSource; GF_HTML_MediaSource *gf_mse_media_source_new(); @@ -199,29 +199,29 @@ GF_Err gf_mse_source_buffer_abort(GF_HTML_SourceBuffer *sb); void gf_mse_source_buffer_append_arraybuffer(GF_HTML_SourceBuffer *sb, GF_HTML_ArrayBuffer *buffer); void gf_mse_source_buffer_update_buffered(GF_HTML_SourceBuffer *sb); void gf_mse_remove(GF_HTML_SourceBuffer *sb, double start, double end); - + typedef struct { - char *data; - u32 size; - GF_SLHeader sl_header; - Bool is_compressed; - Bool is_new_data; - GF_Err status; + char *data; + u32 size; + GF_SLHeader sl_header; + Bool is_compressed; + Bool is_new_data; + GF_Err status; } GF_MSE_Packet; GF_Err gf_mse_proxy(GF_InputService *parser, GF_NetworkCommand *command); void gf_mse_packet_del(GF_MSE_Packet *packet); GF_Err gf_mse_track_buffer_get_next_packet(GF_HTML_Track *track, - char **out_data_ptr, u32 *out_data_size, - GF_SLHeader *out_sl_hdr, Bool *sl_compressed, - GF_Err *out_reception_status, Bool *is_new_data); + char **out_data_ptr, u32 *out_data_size, + GF_SLHeader *out_sl_hdr, Bool *sl_compressed, + GF_Err *out_reception_status, Bool *is_new_data); GF_Err gf_mse_track_buffer_release_packet(GF_HTML_Track *track); #ifdef __cplusplus } #endif -#endif +#endif diff --git a/include/gpac/ietf.h b/include/gpac/ietf.h index 67afcf7..ad94531 100644 --- a/include/gpac/ietf.h +++ b/include/gpac/ietf.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -94,7 +94,7 @@ enum NC_RTSP_Only_Aggregate_Operation_Allowed = 460, NC_RTSP_Unsupported_Transport = 461, NC_RTSP_Destination_Unreachable = 462, - + NC_RTSP_Internal_Server_Error = 500, NC_RTSP_Not_Implemented = 501, NC_RTSP_Bad_Gateway = 502, @@ -135,7 +135,7 @@ GF_RTSPRange *gf_rtsp_range_new(); void gf_rtsp_range_del(GF_RTSPRange *range); /* - Transport structure + Transport structure contains all network info for RTSP sessions (ports, uni/multi-cast, ...) */ @@ -174,7 +174,7 @@ typedef struct u16 client_port_first, client_port_last; u32 SSRC; - /*Transport protocol. In this version we only support RTP/AVP, the following flag tells + /*Transport protocol. In this version we only support RTP/AVP, the following flag tells us if this is RTP/AVP/TCP or RTP/AVP (default)*/ char *Profile; } GF_RTSPTransport; @@ -228,18 +228,18 @@ typedef struct Double Scale; char *Session; Double Speed; - /*nota : RTSP allows several configurations for a single channel (multicast and + /*nota : RTSP allows several configurations for a single channel (multicast and unicast , ...). Usually only 1*/ GF_List *Transports; char *User_Agent; /*type of the command, one of the described above*/ char *method; - + /*Header extensions*/ GF_List *Xtensions; - /*body of the command, size is Content-Length (auto computed when sent). It is not + /*body of the command, size is Content-Length (auto computed when sent). It is not terminated by a NULL char*/ char *body; @@ -247,7 +247,7 @@ typedef struct Specify ControlString if your request targets a specific media stream in the service. If null, the service name only will be used for control (for ex, both A and V streams in a single file) - If the request is GF_RTSP_OPTIONS, you must provide a control string containing the options + If the request is GF_RTSP_OPTIONS, you must provide a control string containing the options you want to query */ char *ControlString; @@ -262,7 +262,7 @@ typedef struct */ /*full URL of the command. Not used at client side, as the URL is ALWAYS relative - to the server / service of the RTSP session + to the server / service of the RTSP session On the server side however redirections are up to the server, so we cannot decide for it */ char *service_name; /*RTSP status code of the command as parsed. One of the above RTSP StatusCode*/ @@ -312,7 +312,7 @@ typedef struct u32 ResponseCode; /* comment from the server */ char *ResponseInfo; - + /* Header Fields */ char *Accept; char *Accept_Encoding; @@ -353,7 +353,7 @@ typedef struct u32 SessionTimeOut; Double Speed; char *Timestamp; - /*nota : RTSP allows several configurations for a single channel (multicast and + /*nota : RTSP allows several configurations for a single channel (multicast and unicast , ...). Usually only 1*/ GF_List *Transports; char *Unsupported; @@ -365,8 +365,8 @@ typedef struct /*Header extensions*/ GF_List *Xtensions; - /*body of the response, size is Content-Length (auto computed when sent). It is not - terminated by a NULL char when response is parsed but must be null-terminated when + /*body of the response, size is Content-Length (auto computed when sent). It is not + terminated by a NULL char when response is parsed but must be null-terminated when response is being sent*/ char *body; } GF_RTSPResponse; @@ -419,7 +419,7 @@ enum /*Waiting*/ GF_RTSP_STATE_WAITING, /*PLAY, PAUSE, RECORD. Aggregation is allowed for the same type, you can send several command - in a row. However the session will return GF_SERVICE_ERROR if you do not have + in a row. However the session will return GF_SERVICE_ERROR if you do not have a valid SessionID in the command You cannot issue a SETUP / DESCRIBE while in this state*/ GF_RTSP_STATE_WAIT_FOR_CONTROL, @@ -429,7 +429,7 @@ enum }; u32 gf_rtsp_get_session_state(GF_RTSPSession *sess); -/*aggregate command state-machine: the PLAY/PAUSE can be aggregated +/*aggregate command state-machine: the PLAY/PAUSE can be aggregated (sent before the reply is received). This function gets the last command sent*/ char *gf_rtsp_get_last_request(GF_RTSPSession *sess); /*foce a reset in case of pbs*/ @@ -442,8 +442,8 @@ GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com); GF_Err gf_rtsp_set_interleave_callback(GF_RTSPSession *sess, - GF_Err (*SignalData)(GF_RTSPSession *sess, void *cbk_ptr, char *buffer, u32 bufferSize, Bool IsRTCP) - ); + GF_Err (*SignalData)(GF_RTSPSession *sess, void *cbk_ptr, char *buffer, u32 bufferSize, Bool IsRTCP) + ); GF_Err gf_rtsp_session_read(GF_RTSPSession *sess); @@ -463,7 +463,7 @@ GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener); /*fetch an RTSP request. The GF_RTSPCommand will be reseted before fetch*/ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com); -/*unpack the URL, check the service name / server. Typically used when a client sends a +/*unpack the URL, check the service name / server. Typically used when a client sends a DESCRIBE || SETUP url RTSP/1.0. Server / service name check must be performed by your app as redirection or services available are unknown here.*/ GF_Err gf_rtsp_load_service_name(GF_RTSPSession *sess, char *URL); @@ -478,7 +478,7 @@ GF_Err gf_rtsp_send_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp); buffer shall be GF_MAX_IP_NAME_LEN long*/ GF_Err gf_rtsp_get_session_ip(GF_RTSPSession *sess, char *buffer); -/*returns the next available ID for interleaving. It is recommended that you use 2 +/*returns the next available ID for interleaving. It is recommended that you use 2 consecutive IDs for RTP/RTCP interleaving*/ u8 gf_rtsp_get_next_interleave_id(GF_RTSPSession *sess); @@ -539,12 +539,12 @@ typedef struct __tag_rtp_channel GF_RTPChannel; GF_RTPChannel *gf_rtp_new(); void gf_rtp_del(GF_RTPChannel *ch); -/*you configure a server channel through the transport structure, with the same info as a +/*you configure a server channel through the transport structure, with the same info as a client channel, the client_port_* info designing the REMOTE client and port_* designing your server channel*/ GF_Err gf_rtp_setup_transport(GF_RTPChannel *ch, GF_RTSPTransport *trans_info, const char *remote_address); -/*auto-setup of rtp/rtcp transport ports - only effective in unicast, non interleaved cases. +/*auto-setup of rtp/rtcp transport ports - only effective in unicast, non interleaved cases. for multicast port setup MUST be done through the above gf_rtp_setup_transport function this will take care of port reuse*/ GF_Err gf_rtp_set_ports(GF_RTPChannel *ch, u16 first_port); @@ -554,8 +554,8 @@ version of the library (a sender cannot switch payload types on a single media)* GF_Err gf_rtp_setup_payload(GF_RTPChannel *ch, GF_RTPMap *map); /*enables sending of NAT keep-alive packets for NAT traversal - @nat_timeout: specifies the inactivity period in ms after which NAT keepalive packets are sent. - If 0, disables NAT keep-alive packets + @nat_timeout: specifies the inactivity period in ms after which NAT keepalive packets are sent. + If 0, disables NAT keep-alive packets */ void gf_rtp_enable_nat_keepalive(GF_RTPChannel *ch, u32 nat_timeout); @@ -585,7 +585,7 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 GF_Err gf_rtp_stop(GF_RTPChannel *ch); /*init the RTP info after a PLAY or PAUSE, rtp_time is the rtp TimeStamp of the RTP packet -with seq_num sequence number. This info is needed to compute the CurrentTime of the RTP channel +with seq_num sequence number. This info is needed to compute the CurrentTime of the RTP channel ssrc may not be known if sender hasn't indicated it (use 0 then)*/ GF_Err gf_rtp_set_info_rtp(GF_RTPChannel *ch, u32 seq_num, u32 rtp_time, u32 ssrc); @@ -612,17 +612,17 @@ GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size, Bool *has_ the callback function. NOTE: many RTP implementation do NOT process RTCP info received on TCP... the lib will decide whether the report shall be sent or not, therefore you should call this function at regular times*/ -GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, - GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), - void *rtsp_cbk); +GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, + GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), + void *rtsp_cbk); /*send a BYE info (leaving the session)*/ GF_Err gf_rtp_send_bye(GF_RTPChannel *ch, - GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), - void *rtsp_cbk); + GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), + void *rtsp_cbk); -/*send RTP packet. In fast_send mode, user passes a pck pointer with 12 bytes available BEFORE pck to +/*send RTP packet. In fast_send mode, user passes a pck pointer with 12 bytes available BEFORE pck to write the header in place*/ GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *pck, u32 pck_size, Bool fast_send); @@ -656,31 +656,31 @@ void gf_rtp_get_ports(GF_RTPChannel *ch, u16 *rtp_port, u16 *rtcp_port); - + /**************************************************************************** SDP LIBRARY EXPORTS - - Note: SDP is mainly a text protocol with + + Note: SDP is mainly a text protocol with well defined containers. The following structures are used to write / read SDP informations, and the library also provides consistency checking When reading SDP, all text items/structures are allocated by the lib, and you must call gf_sdp_info_reset(GF_SDPInfo *sdp) or gf_sdp_info_del(GF_SDPInfo *sdp) to release the memory - When writing the SDP from a GF_SDPInfo, the output buffer is allocated by the library, + When writing the SDP from a GF_SDPInfo, the output buffer is allocated by the library, and you must release it yourself Some quick constructors are available for GF_SDPConnection and GF_SDPMedia in order to set up some specific parameters to their default value - An extra function gf_sdp_info_check(GF_SDPInfo *sdp) is provided for compliency check + An extra function gf_sdp_info_check(GF_SDPInfo *sdp) is provided for compliency check with RFC2327: all requested fields are checked as well as conflicting information forbidden in RFC 2327 ****************************************************************************/ /* - All attributes x-ZZZZ are considered as extensions attributes. If no "x-" is found + All attributes x-ZZZZ are considered as extensions attributes. If no "x-" is found the attributes in the RTSP response is SKIPPED. The "x-" radical is removed in the structure when parsing commands / responses */ @@ -737,13 +737,13 @@ typedef struct /*timezone adjustments, to cope with #timezones, daylight saving countries and co ... Ex: adjTime = [2882844526 2898848070] adjOffset=[-1h 0] - [0]: at 2882844526 the time base by which the session's repeat times are calculated + [0]: at 2882844526 the time base by which the session's repeat times are calculated is shifted back by 1 hour [1]: at time 2898848070 the session's original time base is restored */ - /*Adjustment time at which the corresponding time offset is to be applied to the - session time line (time used to compute the "repeat session"). + /*Adjustment time at which the corresponding time offset is to be applied to the + session time line (time used to compute the "repeat session"). All Expressed in NPT*/ u32 AdjustmentTime[GF_SDP_MAX_TIMEOFFSET]; /* Offset with the session time line, ALWAYS ABSOLUTE OFFSET TO the specified StartTime*/ @@ -788,12 +788,12 @@ typedef struct /*m= 0: application - 1:video - 2: audio - 3: text - 4:data - 5: control*/ u32 Type; - /*Port Number - For transports based on UDP, the value should be in the range 1024 + /*Port Number - For transports based on UDP, the value should be in the range 1024 to 65535 inclusive. For RTP compliance it should be an even number*/ u32 PortNumber; /*number of ports described. If >= 2, the next media(s) in the SDP will be configured to use the next tuple (for RTP). If 0 or 1, ignored - Note: this is used for scalable media: PortNumber indicates the port of the base + Note: this is used for scalable media: PortNumber indicates the port of the base media and NumPorts the ports||total number of the upper layers*/ u32 NumPorts; /*currently ony "RTP/AVP" and "udp" defined*/ @@ -807,7 +807,7 @@ typedef struct /*FMTP contains a list of FMTP structures*/ GF_List *FMTP; - + /*for RTP this is PayloadType, but can be opaque (string) depending on the app. Formated as XX WW QQ FF When reading the SDP, the payloads defined in RTPMap are removed from this list @@ -821,7 +821,7 @@ typedef struct /*Other SDP attributes for media desc*/ /*k= - method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) + method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) or 'prompt' (key not included)*/ char *k_method, *k_key; @@ -858,13 +858,13 @@ typedef struct /*p=*/ char *p_phone; /*c= either 1 or 0 GF_SDPConnection */ - GF_SDPConnection *c_connection; + GF_SDPConnection *c_connection; /*b=*/ GF_List *b_bandwidth; /*All time info (t, r, z)*/ GF_List *Timing; /*k= - method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) + method is 'clear' (key follows), 'base64' (key in base64), 'uri' (key is the URI) or 'prompt' (key not included)*/ char *k_method, *k_key; /*all possible attributes (a=), session level*/ @@ -878,15 +878,15 @@ typedef struct /*all attributes not defined in RFC 2327 for the presentation*/ GF_List *Attributes; - + /*list of media in the SDP*/ GF_List *media_desc; } GF_SDPInfo; /* - Memory Consideration: the destructors free all non-NULL string. You should therefore - be carefull while (de-)assigning the strings. The function gf_sdp_info_parse() performs a complete + Memory Consideration: the destructors free all non-NULL string. You should therefore + be carefull while (de-)assigning the strings. The function gf_sdp_info_parse() performs a complete reset of the GF_SDPInfo */ /*constructor*/ @@ -929,13 +929,13 @@ void gf_sdp_fmtp_del(GF_SDP_FMTP *fmtp); /*RTP<->SL mapping*/ -typedef struct +typedef struct { /*1 - required options*/ /*mode, or "" if no mode ("generic" should be used instead)*/ char mode[30]; - + /*config of the stream if carried in SDP*/ char *config; u32 configSize; @@ -950,7 +950,7 @@ typedef struct u32 rvc_config_size; /*2 - optional options*/ - + /*size of AUs if constant*/ u32 ConstantSize; /*duration of AUs if constant, in RTP timescale*/ @@ -962,7 +962,7 @@ typedef struct u32 maxDisplacement; /*de-interleaveBufferSize if not recomputable from maxDisplacement*/ u32 deinterleaveBufferSize; - + /*The number of bits on which the AU-size field is encoded in the AU-header*/ u32 SizeLength; /*The number of bits on which the AU-Index is encoded in the first AU-header*/ @@ -976,10 +976,10 @@ typedef struct u32 CTSDeltaLength; /*random access point flag present*/ Bool RandomAccessIndication; - + /*The number of bits on which the Stream-state field is encoded in the AU-header (systems only)*/ u32 StreamStateIndication; - /*The number of bits that is used to encode the auxiliary-data-size field + /*The number of bits that is used to encode the auxiliary-data-size field (no normative usage of this section)*/ u32 AuxiliaryDataSizeLength; @@ -992,7 +992,7 @@ typedef struct u32 auh_first_min_len; u32 auh_min_len; } GP_RTPSLMap; - + /*packetizer config flags - some flags are dynamically re-assigned when detecting multiSL / B-Frames / ...*/ enum @@ -1024,7 +1024,7 @@ enum GP_RTP_PCK_USE_LATM_AAC = (1<<9), /*ISMACryp options*/ - /*signals that input data is selectively encrypted (eg not all input frames are encrypted) + /*signals that input data is selectively encrypted (eg not all input frames are encrypted) - this is usually automatically set by hinter*/ GP_RTP_PCK_SELECTIVE_ENCRYPTION = (1<<10), /*signals that each sample will have its own key indicator - ignored in non-multi modes @@ -1042,7 +1042,7 @@ enum */ /*currently supported payload types*/ -enum +enum { /*not defined*/ GF_RTP_PAYT_UNKNOWN, @@ -1094,7 +1094,7 @@ enum Also note that AU start/end is automatically updated, therefore you should only set CTS-DTS-OCR-sequenceNumber (which is automatically incremented when spliting a payload) -padding-idle infos - SL flags are computed on the fly, but you may wish to modify them in case of + SL flags are computed on the fly, but you may wish to modify them in case of packet drop/... at the encoder side */ @@ -1104,10 +1104,10 @@ struct __tag_rtp_packetizer GF_SLHeader sl_header; /* - + PRIVATE _ DO NOT TOUCH */ - + /*RTP payload type (RFC type, NOT the RTP hdr payT)*/ u32 rtp_payt; /*packetization flags*/ @@ -1129,10 +1129,10 @@ struct __tag_rtp_packetizer void (*OnDataReference)(void *cbk_obj, u32 payload_size, u32 offset_from_orig); void (*OnData)(void *cbk_obj, char *data, u32 data_size, Bool is_header); void *cbk_obj; - - /********************************* - MPEG-4 Generic hinting - *********************************/ + + /********************************* + MPEG-4 Generic hinting + *********************************/ /*SL to RTP map*/ GP_RTPSLMap slMap; @@ -1151,28 +1151,28 @@ struct __tag_rtp_packetizer /*info for the current packet*/ u32 auh_size, bytesInPacket; - /********************************* - ISMACryp info - *********************************/ + /********************************* + ISMACryp info + *********************************/ Bool force_flush, is_encrypted; u64 IV, first_AU_IV; char *key_indicator; - /********************************* - AVC-H264 info - *********************************/ + /********************************* + AVC-H264 info + *********************************/ /*AVC non-IDR flag: set if all NAL in current packet are non-IDR (disposable)*/ Bool avc_non_idr; - /********************************* - AC3 info - *********************************/ + /********************************* + AC3 info + *********************************/ /*ac3 ft flags*/ u8 ac3_ft; - /********************************* - HEVC-H265 info - *********************************/ + /********************************* + HEVC-H265 info + *********************************/ /*HEVC Payload Header. It will be use in case of Aggreation Packet where we must add payload header for packet after having added of NALU to AP*/ char hevc_payload_hdr[2]; }; @@ -1189,7 +1189,7 @@ typedef struct __tag_rtp_packetizer GP_RTPPacketizer; @header: rtp header for new packet - note that RTP header flags are not used until PacketDone is called @OnPacketDone: callback function closing current RTP packet @header: final rtp header for packet - @OnDataReference: optional, to call each time data from input buffer is added to current RTP packet. + @OnDataReference: optional, to call each time data from input buffer is added to current RTP packet. If not set, data must be added through OnData @payload_size: size of reference data @offset_from_orig: start offset in input buffer @@ -1198,15 +1198,15 @@ typedef struct __tag_rtp_packetizer GP_RTPPacketizer; @is_head: signal the data added MUST be inserted at the begining of the payload. Otherwise data is concatenated as received */ -GP_RTPPacketizer *gf_rtp_builder_new(u32 rtp_payt, - GF_SLConfig *slc, - u32 flags, - void *cbk_obj, - void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), - void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), - void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), - void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head) - ); +GP_RTPPacketizer *gf_rtp_builder_new(u32 rtp_payt, + GF_SLConfig *slc, + u32 flags, + void *cbk_obj, + void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), + void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), + void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), + void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head) + ); /*destroy builder*/ void gf_rtp_builder_del(GP_RTPPacketizer *builder); @@ -1215,37 +1215,37 @@ void gf_rtp_builder_del(GP_RTPPacketizer *builder); init the builder @MaxPayloadSize: maximum payload size of RTP packets (eg MTU minus IP/UDP/RTP headers) @max_ptime: maximum packet duration IN RTP TIMESCALE - @StreamType: MPEG-4 system stream type - MUST always be provided for payloads format specifying + @StreamType: MPEG-4 system stream type - MUST always be provided for payloads format specifying audio or video streams @OTI : MPEG-4 system objectTypeIndication - may be 0 if stream is not mpeg4 systems *** all other params are for MultiSL draft *** - - @avgSize: average size of an AU. This is not always known (real-time encoding). -In this case you should specify a rough compute indicating how many packets could be + + @avgSize: average size of an AU. This is not always known (real-time encoding). +In this case you should specify a rough compute indicating how many packets could be stored per RTP packet. for ex AAC stereo at 44100 k / 64kbps , one AU ~= 380 bytes so 3 AUs for 1500 MTU is ok - BE CAREFULL: MultiSL adds some SL info on top of the 12 byte RTP header so you should specify a smaller size -The packetizer will ALWAYS make sure there's no pb storing the packets so specifying -more will result in a slight overhead in the SL mapping but the gain to singleSL +The packetizer will ALWAYS make sure there's no pb storing the packets so specifying +more will result in a slight overhead in the SL mapping but the gain to singleSL will still be worth it. - -Nota: at init, the packetizer can decide to switch to SingleSL if the average size + -Nota: at init, the packetizer can decide to switch to SingleSL if the average size specified is too close to the PathMTU @maxSize: max size of an AU. If unknown (real-time) set to 0 @avgTS: average CTS progression (1000/FPS for video) - @maxDTS: maximum DTS offset in case of bidirectional coding. + @maxDTS: maximum DTS offset in case of bidirectional coding. @IV_length: size (in bytes) of IV when ISMACrypted @KI_length: size (in bytes) of key indicator when ISMACrypted @pref_mode: MPEG-4 generic only, specifies the payload mode - can be NULL (mode generic) */ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 MaxPayloadSize, u32 max_ptime, - u32 StreamType, u32 OTI, u32 PL_ID, - u32 avgSize, u32 maxSize, - u32 avgTS, u32 maxDTS, - u32 IV_length, u32 KI_length, - char *pref_mode); + u32 StreamType, u32 OTI, u32 PL_ID, + u32 avgSize, u32 maxSize, + u32 avgTS, u32 maxDTS, + u32 IV_length, u32 KI_length, + char *pref_mode); /*set frame crypto info*/ void gp_rtp_builder_set_cryp_info(GP_RTPPacketizer *builder, u64 IV, char *key_indicator, Bool is_encrypted); @@ -1285,7 +1285,7 @@ enum GF_RTP_HAS_ISMACRYP = (1<<5), GF_RTP_ISMA_SEL_ENC = (1<<6), GF_RTP_ISMA_HAS_KEY_IDX = (1<<7), - + GF_RTP_AVC_USE_ANNEX_B = (1<<8) }; @@ -1319,7 +1319,7 @@ struct __tag_rtp_depacketizer /*H264/AVC config*/ u32 h264_pck_mode; - + /*3GP text reassembler state*/ u8 nb_txt_frag, cur_txt_frag, sidx, txt_len, nb_mod_frag; diff --git a/include/gpac/internal/avilib.h b/include/gpac/internal/avilib.h index 7697cc3..cc030c8 100644 --- a/include/gpac/internal/avilib.h +++ b/include/gpac/internal/avilib.h @@ -5,23 +5,23 @@ * multiple audio track support Copyright (C) 2002 Thomas Östreich * * Original code: - * Copyright (C) 1999 Rainer Johanni + * Copyright (C) 1999 Rainer Johanni * * This file is part of transcode, a linux video stream processing tool - * + * * transcode is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * transcode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,16 +36,16 @@ typedef struct { - u64 key; - u64 pos; - u64 len; + u64 key; + u64 pos; + u64 len; } video_index_entry; typedef struct { - u64 pos; - u64 len; - u64 tot; + u64 pos; + u64 len; + u64 tot; } audio_index_entry; @@ -53,187 +53,187 @@ typedef struct #define AVI_INDEX_OF_INDEXES 0x00 // when each entry in aIndex - // array points to an index chunk +// array points to an index chunk #define AVI_INDEX_OF_CHUNKS 0x01 // when each entry in aIndex - // array points to a chunk in the file +// array points to a chunk in the file #define AVI_INDEX_IS_DATA 0x80 // when each entry is aIndex is - // really the data +// really the data // bIndexSubtype codes for INDEX_OF_CHUNKS // #define AVI_INDEX_2FIELD 0x01 // when fields within frames - // are also indexed +// are also indexed typedef struct _avisuperindex_entry { - u64 qwOffset; // absolute file offset - u32 dwSize; // size of index chunk at this offset - u32 dwDuration; // time span in stream ticks + u64 qwOffset; // absolute file offset + u32 dwSize; // size of index chunk at this offset + u32 dwDuration; // time span in stream ticks } avisuperindex_entry; typedef struct _avistdindex_entry { - u32 dwOffset; // qwBaseOffset + this is absolute file offset - u32 dwSize; // bit 31 is set if this is NOT a keyframe + u32 dwOffset; // qwBaseOffset + this is absolute file offset + u32 dwSize; // bit 31 is set if this is NOT a keyframe } avistdindex_entry; -// Standard index +// Standard index typedef struct _avistdindex_chunk { - char fcc[4]; // ix## - u32 dwSize; // size of this chunk - u16 wLongsPerEntry; // must be sizeof(aIndex[0])/sizeof(DWORD) - u8 bIndexSubType; // must be 0 - u8 bIndexType; // must be AVI_INDEX_OF_CHUNKS - u32 nEntriesInUse; // - char dwChunkId[4]; // '##dc' or '##db' or '##wb' etc.. - u64 qwBaseOffset; // all dwOffsets in aIndex array are relative to this - u32 dwReserved3; // must be 0 - avistdindex_entry *aIndex; + char fcc[4]; // ix## + u32 dwSize; // size of this chunk + u16 wLongsPerEntry; // must be sizeof(aIndex[0])/sizeof(DWORD) + u8 bIndexSubType; // must be 0 + u8 bIndexType; // must be AVI_INDEX_OF_CHUNKS + u32 nEntriesInUse; // + char dwChunkId[4]; // '##dc' or '##db' or '##wb' etc.. + u64 qwBaseOffset; // all dwOffsets in aIndex array are relative to this + u32 dwReserved3; // must be 0 + avistdindex_entry *aIndex; } avistdindex_chunk; - + // Base Index Form 'indx' typedef struct _avisuperindex_chunk { - char fcc[4]; - u32 dwSize; // size of this chunk - u16 wLongsPerEntry; // size of each entry in aIndex array (must be 8 for us) - u8 bIndexSubType; // future use. must be 0 - u8 bIndexType; // one of AVI_INDEX_* codes - u32 nEntriesInUse; // index of first unused member in aIndex array - char dwChunkId[4]; // fcc of what is indexed - u32 dwReserved[3]; // meaning differs for each index type/subtype. - // 0 if unused - avisuperindex_entry *aIndex; // where are the ix## chunks - avistdindex_chunk **stdindex; // the ix## chunks itself (array) + char fcc[4]; + u32 dwSize; // size of this chunk + u16 wLongsPerEntry; // size of each entry in aIndex array (must be 8 for us) + u8 bIndexSubType; // future use. must be 0 + u8 bIndexType; // one of AVI_INDEX_* codes + u32 nEntriesInUse; // index of first unused member in aIndex array + char dwChunkId[4]; // fcc of what is indexed + u32 dwReserved[3]; // meaning differs for each index type/subtype. + // 0 if unused + avisuperindex_entry *aIndex; // where are the ix## chunks + avistdindex_chunk **stdindex; // the ix## chunks itself (array) } avisuperindex_chunk; - + typedef struct track_s { - long a_fmt; /* Audio format, see #defines below */ - long a_chans; /* Audio channels, 0 for no audio */ - long a_rate; /* Rate in Hz */ - long a_bits; /* bits per audio sample */ - long mp3rate; /* mp3 bitrate kbs*/ - long a_vbr; /* 0 == no Variable BitRate */ - long padrate; /* byte rate used for zero padding */ + long a_fmt; /* Audio format, see #defines below */ + long a_chans; /* Audio channels, 0 for no audio */ + long a_rate; /* Rate in Hz */ + long a_bits; /* bits per audio sample */ + long mp3rate; /* mp3 bitrate kbs*/ + long a_vbr; /* 0 == no Variable BitRate */ + long padrate; /* byte rate used for zero padding */ - long audio_strn; /* Audio stream number */ - u64 audio_bytes; /* Total number of bytes of audio data */ - long audio_chunks; /* Chunks of audio data in the file */ + long audio_strn; /* Audio stream number */ + u64 audio_bytes; /* Total number of bytes of audio data */ + long audio_chunks; /* Chunks of audio data in the file */ - char audio_tag[4]; /* Tag of audio data */ - long audio_posc; /* Audio position: chunk */ - long audio_posb; /* Audio position: byte within chunk */ - - u64 a_codech_off; /* absolut offset of audio codec information */ - u64 a_codecf_off; /* absolut offset of audio codec information */ + char audio_tag[4]; /* Tag of audio data */ + long audio_posc; /* Audio position: chunk */ + long audio_posb; /* Audio position: byte within chunk */ - audio_index_entry *audio_index; - avisuperindex_chunk *audio_superindex; + u64 a_codech_off; /* absolut offset of audio codec information */ + u64 a_codecf_off; /* absolut offset of audio codec information */ + + audio_index_entry *audio_index; + avisuperindex_chunk *audio_superindex; } track_t; typedef struct { - u32 bi_size; - u32 bi_width; - u32 bi_height; - u16 bi_planes; - u16 bi_bit_count; - u32 bi_compression; - u32 bi_size_image; - u32 bi_x_pels_per_meter; - u32 bi_y_pels_per_meter; - u32 bi_clr_used; - u32 bi_clr_important; + u32 bi_size; + u32 bi_width; + u32 bi_height; + u16 bi_planes; + u16 bi_bit_count; + u32 bi_compression; + u32 bi_size_image; + u32 bi_x_pels_per_meter; + u32 bi_y_pels_per_meter; + u32 bi_clr_used; + u32 bi_clr_important; } alBITMAPINFOHEADER; typedef struct { - u16 w_format_tag; - u16 n_channels; - u32 n_samples_per_sec; - u32 n_avg_bytes_per_sec; - u16 n_block_align; - u16 w_bits_per_sample; - u16 cb_size; + u16 w_format_tag; + u16 n_channels; + u32 n_samples_per_sec; + u32 n_avg_bytes_per_sec; + u16 n_block_align; + u16 w_bits_per_sample; + u16 cb_size; } alWAVEFORMATEX; typedef struct { - u32 fcc_type; - u32 fcc_handler; - u32 dw_flags; - u32 dw_caps; - u16 w_priority; - u16 w_language; - u32 dw_scale; - u32 dw_rate; - u32 dw_start; - u32 dw_length; - u32 dw_initial_frames; - u32 dw_suggested_buffer_size; - u32 dw_quality; - u32 dw_sample_size; - u16 dw_left; - u16 dw_top; - u16 dw_right; - u16 dw_bottom; + u32 fcc_type; + u32 fcc_handler; + u32 dw_flags; + u32 dw_caps; + u16 w_priority; + u16 w_language; + u32 dw_scale; + u32 dw_rate; + u32 dw_start; + u32 dw_length; + u32 dw_initial_frames; + u32 dw_suggested_buffer_size; + u32 dw_quality; + u32 dw_sample_size; + u16 dw_left; + u16 dw_top; + u16 dw_right; + u16 dw_bottom; } alAVISTREAMHEADER; typedef struct { - - FILE *fdes; /* File descriptor of AVI file */ - long mode; /* 0 for reading, 1 for writing */ - - long width; /* Width of a video frame */ - long height; /* Height of a video frame */ - double fps; /* Frames per second */ - char compressor[8]; /* Type of compressor, 4 bytes + padding for 0 byte */ - char compressor2[8]; /* Type of compressor, 4 bytes + padding for 0 byte */ - u32 video_strn; /* Video stream number */ - long video_frames; /* Number of video frames */ - char video_tag[4]; /* Tag of video data */ - long video_pos; /* Number of next frame to be read + + FILE *fdes; /* File descriptor of AVI file */ + long mode; /* 0 for reading, 1 for writing */ + + long width; /* Width of a video frame */ + long height; /* Height of a video frame */ + double fps; /* Frames per second */ + char compressor[8]; /* Type of compressor, 4 bytes + padding for 0 byte */ + char compressor2[8]; /* Type of compressor, 4 bytes + padding for 0 byte */ + u32 video_strn; /* Video stream number */ + long video_frames; /* Number of video frames */ + char video_tag[4]; /* Tag of video data */ + long video_pos; /* Number of next frame to be read (if index present) */ - alAVISTREAMHEADER video_stream_header; - - u32 max_len; /* maximum video chunk present */ - - track_t track[AVI_MAX_TRACKS]; // up to AVI_MAX_TRACKS audio tracks supported - - s64 pos; /* position in file */ - long n_idx; /* number of index entries actually filled */ - long max_idx; /* number of index entries actually allocated */ - - s64 v_codech_off; /* absolut offset of video codec (strh) info */ - s64 v_codecf_off; /* absolut offset of video codec (strf) info */ - - u8 (*idx)[16]; /* index entries (AVI idx1 tag) */ - - video_index_entry *video_index; - avisuperindex_chunk *video_superindex; /* index of indices */ - int is_opendml; /* set to 1 if this is an odml file with multiple index chunks */ - - s64 last_pos; /* Position of last frame written */ - u32 last_len; /* Length of last frame written */ - int must_use_index; /* Flag if frames are duplicated */ - s64 movi_start; - int total_frames; /* total number of frames if dmlh is present */ - - u32 anum; // total number of audio tracks - u32 aptr; // current audio working track - char *index_file; // read the avi index from this file - - alBITMAPINFOHEADER *bitmap_info_header; - alWAVEFORMATEX *wave_format_ex[AVI_MAX_TRACKS]; - alAVISTREAMHEADER stream_headers[AVI_MAX_TRACKS]; - - void* extradata; - unsigned long extradata_size; + alAVISTREAMHEADER video_stream_header; + + u32 max_len; /* maximum video chunk present */ + + track_t track[AVI_MAX_TRACKS]; // up to AVI_MAX_TRACKS audio tracks supported + + s64 pos; /* position in file */ + long n_idx; /* number of index entries actually filled */ + long max_idx; /* number of index entries actually allocated */ + + s64 v_codech_off; /* absolut offset of video codec (strh) info */ + s64 v_codecf_off; /* absolut offset of video codec (strf) info */ + + u8 (*idx)[16]; /* index entries (AVI idx1 tag) */ + + video_index_entry *video_index; + avisuperindex_chunk *video_superindex; /* index of indices */ + int is_opendml; /* set to 1 if this is an odml file with multiple index chunks */ + + s64 last_pos; /* Position of last frame written */ + u32 last_len; /* Length of last frame written */ + int must_use_index; /* Flag if frames are duplicated */ + s64 movi_start; + int total_frames; /* total number of frames if dmlh is present */ + + u32 anum; // total number of audio tracks + u32 aptr; // current audio working track + char *index_file; // read the avi index from this file + + alBITMAPINFOHEADER *bitmap_info_header; + alWAVEFORMATEX *wave_format_ex[AVI_MAX_TRACKS]; + alAVISTREAMHEADER stream_headers[AVI_MAX_TRACKS]; + + void* extradata; + unsigned long extradata_size; } avi_t; #define AVI_MODE_WRITE 0 @@ -356,8 +356,8 @@ int AVI_set_audio_position_index(avi_t *AVI, long indexpos); long AVI_read_audio(avi_t *AVI, char *audbuf, long bytes, int *continuous); int AVI_read_data(avi_t *AVI, char *vidbuf, long max_vidbuf, - char *audbuf, long max_audbuf, - long *len); + char *audbuf, long max_audbuf, + long *len); int AVI_scan(char *name); int AVI_dump(char *name, int mode); @@ -379,21 +379,21 @@ long AVI_get_audio_vbr(avi_t *AVI); void AVI_set_comment_fd(avi_t *AVI, int fd); int AVI_get_comment_fd(avi_t *AVI); -struct riff_struct +struct riff_struct { - u8 id[4]; /* RIFF */ - u32 len; - u8 wave_id[4]; /* WAVE */ + u8 id[4]; /* RIFF */ + u32 len; + u8 wave_id[4]; /* WAVE */ }; -struct chunk_struct +struct chunk_struct { u8 id[4]; u32 len; }; -struct common_struct +struct common_struct { u16 wFormatTag; u16 wChannels; @@ -403,7 +403,7 @@ struct common_struct u16 wBitsPerSample; /* Only for PCM */ }; -struct wave_header +struct wave_header { struct riff_struct riff; struct chunk_struct format; @@ -419,18 +419,18 @@ size_t AVI_write_wave_pcm_data( int fd, const void * buffer, size_t buflen ); struct AVIStreamHeader { - long fccType; - long fccHandler; - long dwFlags; - long dwPriority; - long dwInitialFrames; - long dwScale; - long dwRate; - long dwStart; - long dwLength; - long dwSuggestedBufferSize; - long dwQuality; - long dwSampleSize; + long fccType; + long fccHandler; + long dwFlags; + long dwPriority; + long dwInitialFrames; + long dwScale; + long dwRate; + long dwStart; + long dwLength; + long dwSuggestedBufferSize; + long dwQuality; + long dwSampleSize; }; #endif /*GPAC_DISABLE_AVILIB*/ diff --git a/include/gpac/internal/bifs_dev.h b/include/gpac/internal/bifs_dev.h index 7dc3324..3fefc56 100644 --- a/include/gpac/internal/bifs_dev.h +++ b/include/gpac/internal/bifs_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -74,14 +74,14 @@ typedef struct /*per_stream config support*/ -typedef struct +typedef struct { BIFSConfig config; u16 ESID; } BIFSStreamInfo; /*per_stream config support*/ -typedef struct +typedef struct { GF_Node *node; SFCommandBuffer *cb; @@ -109,7 +109,7 @@ struct __tag_bifs_dec M_QuantizationParameter *ActiveQP; /*QP 14 stuff: we need to store the last numb of fields in the last received Coord //field (!!!)*/ - + /*number of iten in the Coord field*/ u32 NumCoord; Bool coord_stored, storing_coord; @@ -195,7 +195,7 @@ struct __tag_bifs_enc GF_Err gf_bifs_enc_commands(GF_BifsEncoder *codec, GF_List *comList, GF_BitStream *bs); -GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_BitStream *bs); +GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_BitStream *bs, GF_Node *parent_node); GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *node, GF_FieldInfo *field); GF_Err gf_bifs_enc_field(GF_BifsEncoder * codec, GF_BitStream *bs, GF_Node *node, GF_FieldInfo *field); GF_Err gf_bifs_enc_mf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *node, GF_FieldInfo *field); @@ -207,7 +207,7 @@ GF_Node *gf_bifs_enc_find_node(GF_BifsEncoder *codec, u32 nodeID); gf_bs_write_int(bs, val, nbBits); \ GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] %s\t\t%d\t\t%d\t\t%s\n", str, nbBits, val, com ? com : "") ); \ } \ - + GF_Route *gf_bifs_enc_is_field_ised(GF_BifsEncoder *codec, GF_Node *node, u32 fieldIndex); #endif /*GPAC_DISABLE_BIFS_ENC*/ diff --git a/include/gpac/internal/bifs_tables.h b/include/gpac/internal/bifs_tables.h index 748cdac..4265a8a 100644 --- a/include/gpac/internal/bifs_tables.h +++ b/include/gpac/internal/bifs_tables.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -50,217 +50,217 @@ u32 ALL_GetNodeType(const u32 *table, const u32 count, u32 NodeTag, u32 Version) #define SFWorldNode_V1_Count 100 static const u32 SFWorldNode_V1_TypeToTag[100] = { - TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Appearance, TAG_MPEG4_AudioBuffer, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioDelay, TAG_MPEG4_AudioFX, TAG_MPEG4_AudioMix, TAG_MPEG4_AudioSource, TAG_MPEG4_AudioSwitch, TAG_MPEG4_Background, TAG_MPEG4_Background2D, TAG_MPEG4_Billboard, TAG_MPEG4_Bitmap, TAG_MPEG4_Box, TAG_MPEG4_Circle, TAG_MPEG4_Collision, TAG_MPEG4_Color, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_CompositeTexture2D, TAG_MPEG4_CompositeTexture3D, TAG_MPEG4_Conditional, TAG_MPEG4_Cone, TAG_MPEG4_Coordinate, TAG_MPEG4_Coordinate2D, TAG_MPEG4_CoordinateInterpolator, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_Curve2D, TAG_MPEG4_Cylinder, TAG_MPEG4_CylinderSensor, TAG_MPEG4_DirectionalLight, TAG_MPEG4_DiscSensor, TAG_MPEG4_ElevationGrid, TAG_MPEG4_Expression, TAG_MPEG4_Extrusion, TAG_MPEG4_Face, TAG_MPEG4_FaceDefMesh, TAG_MPEG4_FaceDefTables, TAG_MPEG4_FaceDefTransform, TAG_MPEG4_FAP, TAG_MPEG4_FDP, TAG_MPEG4_FIT, TAG_MPEG4_Fog, TAG_MPEG4_FontStyle, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_ImageTexture, TAG_MPEG4_IndexedFaceSet, TAG_MPEG4_IndexedFaceSet2D, TAG_MPEG4_IndexedLineSet, TAG_MPEG4_IndexedLineSet2D, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_LineProperties, TAG_MPEG4_ListeningPoint, TAG_MPEG4_Material, TAG_MPEG4_Material2D, TAG_MPEG4_MovieTexture, TAG_MPEG4_NavigationInfo, TAG_MPEG4_Normal, TAG_MPEG4_NormalInterpolator, TAG_MPEG4_OrderedGroup, TAG_MPEG4_OrientationInterpolator, TAG_MPEG4_PixelTexture, TAG_MPEG4_PlaneSensor, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PointLight, TAG_MPEG4_PointSet, TAG_MPEG4_PointSet2D, TAG_MPEG4_PositionInterpolator, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_ProximitySensor, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_Rectangle, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound, TAG_MPEG4_Sound2D, TAG_MPEG4_Sphere, TAG_MPEG4_SphereSensor, TAG_MPEG4_SpotLight, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_Text, TAG_MPEG4_TextureCoordinate, TAG_MPEG4_TextureTransform, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_Viewpoint, TAG_MPEG4_VisibilitySensor, TAG_MPEG4_Viseme, TAG_MPEG4_WorldInfo + TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Appearance, TAG_MPEG4_AudioBuffer, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioDelay, TAG_MPEG4_AudioFX, TAG_MPEG4_AudioMix, TAG_MPEG4_AudioSource, TAG_MPEG4_AudioSwitch, TAG_MPEG4_Background, TAG_MPEG4_Background2D, TAG_MPEG4_Billboard, TAG_MPEG4_Bitmap, TAG_MPEG4_Box, TAG_MPEG4_Circle, TAG_MPEG4_Collision, TAG_MPEG4_Color, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_CompositeTexture2D, TAG_MPEG4_CompositeTexture3D, TAG_MPEG4_Conditional, TAG_MPEG4_Cone, TAG_MPEG4_Coordinate, TAG_MPEG4_Coordinate2D, TAG_MPEG4_CoordinateInterpolator, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_Curve2D, TAG_MPEG4_Cylinder, TAG_MPEG4_CylinderSensor, TAG_MPEG4_DirectionalLight, TAG_MPEG4_DiscSensor, TAG_MPEG4_ElevationGrid, TAG_MPEG4_Expression, TAG_MPEG4_Extrusion, TAG_MPEG4_Face, TAG_MPEG4_FaceDefMesh, TAG_MPEG4_FaceDefTables, TAG_MPEG4_FaceDefTransform, TAG_MPEG4_FAP, TAG_MPEG4_FDP, TAG_MPEG4_FIT, TAG_MPEG4_Fog, TAG_MPEG4_FontStyle, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_ImageTexture, TAG_MPEG4_IndexedFaceSet, TAG_MPEG4_IndexedFaceSet2D, TAG_MPEG4_IndexedLineSet, TAG_MPEG4_IndexedLineSet2D, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_LineProperties, TAG_MPEG4_ListeningPoint, TAG_MPEG4_Material, TAG_MPEG4_Material2D, TAG_MPEG4_MovieTexture, TAG_MPEG4_NavigationInfo, TAG_MPEG4_Normal, TAG_MPEG4_NormalInterpolator, TAG_MPEG4_OrderedGroup, TAG_MPEG4_OrientationInterpolator, TAG_MPEG4_PixelTexture, TAG_MPEG4_PlaneSensor, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PointLight, TAG_MPEG4_PointSet, TAG_MPEG4_PointSet2D, TAG_MPEG4_PositionInterpolator, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_ProximitySensor, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_Rectangle, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound, TAG_MPEG4_Sound2D, TAG_MPEG4_Sphere, TAG_MPEG4_SphereSensor, TAG_MPEG4_SpotLight, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_Text, TAG_MPEG4_TextureCoordinate, TAG_MPEG4_TextureTransform, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_Viewpoint, TAG_MPEG4_VisibilitySensor, TAG_MPEG4_Viseme, TAG_MPEG4_WorldInfo }; #define SF3DNode_V1_NUMBITS 6 #define SF3DNode_V1_Count 52 static const u32 SF3DNode_V1_TypeToTag[52] = { - TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Background, TAG_MPEG4_Background2D, TAG_MPEG4_Billboard, TAG_MPEG4_Collision, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_Conditional, TAG_MPEG4_CoordinateInterpolator, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_CylinderSensor, TAG_MPEG4_DirectionalLight, TAG_MPEG4_DiscSensor, TAG_MPEG4_Face, TAG_MPEG4_Fog, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_ListeningPoint, TAG_MPEG4_NavigationInfo, TAG_MPEG4_NormalInterpolator, TAG_MPEG4_OrderedGroup, TAG_MPEG4_OrientationInterpolator, TAG_MPEG4_PlaneSensor, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PointLight, TAG_MPEG4_PositionInterpolator, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_ProximitySensor, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound, TAG_MPEG4_Sound2D, TAG_MPEG4_SphereSensor, TAG_MPEG4_SpotLight, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_Viewpoint, TAG_MPEG4_VisibilitySensor, TAG_MPEG4_WorldInfo + TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Background, TAG_MPEG4_Background2D, TAG_MPEG4_Billboard, TAG_MPEG4_Collision, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_Conditional, TAG_MPEG4_CoordinateInterpolator, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_CylinderSensor, TAG_MPEG4_DirectionalLight, TAG_MPEG4_DiscSensor, TAG_MPEG4_Face, TAG_MPEG4_Fog, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_ListeningPoint, TAG_MPEG4_NavigationInfo, TAG_MPEG4_NormalInterpolator, TAG_MPEG4_OrderedGroup, TAG_MPEG4_OrientationInterpolator, TAG_MPEG4_PlaneSensor, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PointLight, TAG_MPEG4_PositionInterpolator, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_ProximitySensor, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound, TAG_MPEG4_Sound2D, TAG_MPEG4_SphereSensor, TAG_MPEG4_SpotLight, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_Viewpoint, TAG_MPEG4_VisibilitySensor, TAG_MPEG4_WorldInfo }; #define SF2DNode_V1_NUMBITS 5 #define SF2DNode_V1_Count 31 static const u32 SF2DNode_V1_TypeToTag[31] = { - TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Background2D, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_Conditional, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_DiscSensor, TAG_MPEG4_Face, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_OrderedGroup, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound2D, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_WorldInfo + TAG_MPEG4_Anchor, TAG_MPEG4_AnimationStream, TAG_MPEG4_Background2D, TAG_MPEG4_ColorInterpolator, TAG_MPEG4_Conditional, TAG_MPEG4_CoordinateInterpolator2D, TAG_MPEG4_DiscSensor, TAG_MPEG4_Face, TAG_MPEG4_Form, TAG_MPEG4_Group, TAG_MPEG4_Inline, TAG_MPEG4_LOD, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_Layout, TAG_MPEG4_OrderedGroup, TAG_MPEG4_PlaneSensor2D, TAG_MPEG4_PositionInterpolator2D, TAG_MPEG4_ProximitySensor2D, TAG_MPEG4_QuantizationParameter, TAG_MPEG4_ScalarInterpolator, TAG_MPEG4_Script, TAG_MPEG4_Shape, TAG_MPEG4_Sound2D, TAG_MPEG4_Switch, TAG_MPEG4_TermCap, TAG_MPEG4_TimeSensor, TAG_MPEG4_TouchSensor, TAG_MPEG4_Transform2D, TAG_MPEG4_Valuator, TAG_MPEG4_WorldInfo }; #define SFStreamingNode_V1_NUMBITS 3 #define SFStreamingNode_V1_Count 5 static const u32 SFStreamingNode_V1_TypeToTag[5] = { - TAG_MPEG4_AnimationStream, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioSource, TAG_MPEG4_Inline, TAG_MPEG4_MovieTexture + TAG_MPEG4_AnimationStream, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioSource, TAG_MPEG4_Inline, TAG_MPEG4_MovieTexture }; #define SFAppearanceNode_V1_NUMBITS 1 #define SFAppearanceNode_V1_Count 1 static const u32 SFAppearanceNode_V1_TypeToTag[1] = { - TAG_MPEG4_Appearance + TAG_MPEG4_Appearance }; #define SFAudioNode_V1_NUMBITS 3 #define SFAudioNode_V1_Count 7 static const u32 SFAudioNode_V1_TypeToTag[7] = { - TAG_MPEG4_AudioBuffer, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioDelay, TAG_MPEG4_AudioFX, TAG_MPEG4_AudioMix, TAG_MPEG4_AudioSource, TAG_MPEG4_AudioSwitch + TAG_MPEG4_AudioBuffer, TAG_MPEG4_AudioClip, TAG_MPEG4_AudioDelay, TAG_MPEG4_AudioFX, TAG_MPEG4_AudioMix, TAG_MPEG4_AudioSource, TAG_MPEG4_AudioSwitch }; #define SFBackground3DNode_V1_NUMBITS 1 #define SFBackground3DNode_V1_Count 1 static const u32 SFBackground3DNode_V1_TypeToTag[1] = { - TAG_MPEG4_Background + TAG_MPEG4_Background }; #define SFBackground2DNode_V1_NUMBITS 1 #define SFBackground2DNode_V1_Count 1 static const u32 SFBackground2DNode_V1_TypeToTag[1] = { - TAG_MPEG4_Background2D + TAG_MPEG4_Background2D }; #define SFGeometryNode_V1_NUMBITS 5 #define SFGeometryNode_V1_Count 17 static const u32 SFGeometryNode_V1_TypeToTag[17] = { - TAG_MPEG4_Bitmap, TAG_MPEG4_Box, TAG_MPEG4_Circle, TAG_MPEG4_Cone, TAG_MPEG4_Curve2D, TAG_MPEG4_Cylinder, TAG_MPEG4_ElevationGrid, TAG_MPEG4_Extrusion, TAG_MPEG4_IndexedFaceSet, TAG_MPEG4_IndexedFaceSet2D, TAG_MPEG4_IndexedLineSet, TAG_MPEG4_IndexedLineSet2D, TAG_MPEG4_PointSet, TAG_MPEG4_PointSet2D, TAG_MPEG4_Rectangle, TAG_MPEG4_Sphere, TAG_MPEG4_Text + TAG_MPEG4_Bitmap, TAG_MPEG4_Box, TAG_MPEG4_Circle, TAG_MPEG4_Cone, TAG_MPEG4_Curve2D, TAG_MPEG4_Cylinder, TAG_MPEG4_ElevationGrid, TAG_MPEG4_Extrusion, TAG_MPEG4_IndexedFaceSet, TAG_MPEG4_IndexedFaceSet2D, TAG_MPEG4_IndexedLineSet, TAG_MPEG4_IndexedLineSet2D, TAG_MPEG4_PointSet, TAG_MPEG4_PointSet2D, TAG_MPEG4_Rectangle, TAG_MPEG4_Sphere, TAG_MPEG4_Text }; #define SFColorNode_V1_NUMBITS 1 #define SFColorNode_V1_Count 1 static const u32 SFColorNode_V1_TypeToTag[1] = { - TAG_MPEG4_Color + TAG_MPEG4_Color }; #define SFTextureNode_V1_NUMBITS 3 #define SFTextureNode_V1_Count 5 static const u32 SFTextureNode_V1_TypeToTag[5] = { - TAG_MPEG4_CompositeTexture2D, TAG_MPEG4_CompositeTexture3D, TAG_MPEG4_ImageTexture, TAG_MPEG4_MovieTexture, TAG_MPEG4_PixelTexture + TAG_MPEG4_CompositeTexture2D, TAG_MPEG4_CompositeTexture3D, TAG_MPEG4_ImageTexture, TAG_MPEG4_MovieTexture, TAG_MPEG4_PixelTexture }; #define SFCoordinateNode_V1_NUMBITS 1 #define SFCoordinateNode_V1_Count 1 static const u32 SFCoordinateNode_V1_TypeToTag[1] = { - TAG_MPEG4_Coordinate + TAG_MPEG4_Coordinate }; #define SFCoordinate2DNode_V1_NUMBITS 1 #define SFCoordinate2DNode_V1_Count 1 static const u32 SFCoordinate2DNode_V1_TypeToTag[1] = { - TAG_MPEG4_Coordinate2D + TAG_MPEG4_Coordinate2D }; #define SFExpressionNode_V1_NUMBITS 1 #define SFExpressionNode_V1_Count 1 static const u32 SFExpressionNode_V1_TypeToTag[1] = { - TAG_MPEG4_Expression + TAG_MPEG4_Expression }; #define SFFaceDefMeshNode_V1_NUMBITS 1 #define SFFaceDefMeshNode_V1_Count 1 static const u32 SFFaceDefMeshNode_V1_TypeToTag[1] = { - TAG_MPEG4_FaceDefMesh + TAG_MPEG4_FaceDefMesh }; #define SFFaceDefTablesNode_V1_NUMBITS 1 #define SFFaceDefTablesNode_V1_Count 1 static const u32 SFFaceDefTablesNode_V1_TypeToTag[1] = { - TAG_MPEG4_FaceDefTables + TAG_MPEG4_FaceDefTables }; #define SFFaceDefTransformNode_V1_NUMBITS 1 #define SFFaceDefTransformNode_V1_Count 1 static const u32 SFFaceDefTransformNode_V1_TypeToTag[1] = { - TAG_MPEG4_FaceDefTransform + TAG_MPEG4_FaceDefTransform }; #define SFFAPNode_V1_NUMBITS 1 #define SFFAPNode_V1_Count 1 static const u32 SFFAPNode_V1_TypeToTag[1] = { - TAG_MPEG4_FAP + TAG_MPEG4_FAP }; #define SFFDPNode_V1_NUMBITS 1 #define SFFDPNode_V1_Count 1 static const u32 SFFDPNode_V1_TypeToTag[1] = { - TAG_MPEG4_FDP + TAG_MPEG4_FDP }; #define SFFITNode_V1_NUMBITS 1 #define SFFITNode_V1_Count 1 static const u32 SFFITNode_V1_TypeToTag[1] = { - TAG_MPEG4_FIT + TAG_MPEG4_FIT }; #define SFFogNode_V1_NUMBITS 1 #define SFFogNode_V1_Count 1 static const u32 SFFogNode_V1_TypeToTag[1] = { - TAG_MPEG4_Fog + TAG_MPEG4_Fog }; #define SFFontStyleNode_V1_NUMBITS 1 #define SFFontStyleNode_V1_Count 1 static const u32 SFFontStyleNode_V1_TypeToTag[1] = { - TAG_MPEG4_FontStyle + TAG_MPEG4_FontStyle }; #define SFTopNode_V1_NUMBITS 3 #define SFTopNode_V1_Count 4 static const u32 SFTopNode_V1_TypeToTag[4] = { - TAG_MPEG4_Group, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_OrderedGroup + TAG_MPEG4_Group, TAG_MPEG4_Layer2D, TAG_MPEG4_Layer3D, TAG_MPEG4_OrderedGroup }; #define SFLinePropertiesNode_V1_NUMBITS 1 #define SFLinePropertiesNode_V1_Count 1 static const u32 SFLinePropertiesNode_V1_TypeToTag[1] = { - TAG_MPEG4_LineProperties + TAG_MPEG4_LineProperties }; #define SFMaterialNode_V1_NUMBITS 2 #define SFMaterialNode_V1_Count 2 static const u32 SFMaterialNode_V1_TypeToTag[2] = { - TAG_MPEG4_Material, TAG_MPEG4_Material2D + TAG_MPEG4_Material, TAG_MPEG4_Material2D }; #define SFNavigationInfoNode_V1_NUMBITS 1 #define SFNavigationInfoNode_V1_Count 1 static const u32 SFNavigationInfoNode_V1_TypeToTag[1] = { - TAG_MPEG4_NavigationInfo + TAG_MPEG4_NavigationInfo }; #define SFNormalNode_V1_NUMBITS 1 #define SFNormalNode_V1_Count 1 static const u32 SFNormalNode_V1_TypeToTag[1] = { - TAG_MPEG4_Normal + TAG_MPEG4_Normal }; #define SFTextureCoordinateNode_V1_NUMBITS 1 #define SFTextureCoordinateNode_V1_Count 1 static const u32 SFTextureCoordinateNode_V1_TypeToTag[1] = { - TAG_MPEG4_TextureCoordinate + TAG_MPEG4_TextureCoordinate }; #define SFTextureTransformNode_V1_NUMBITS 1 #define SFTextureTransformNode_V1_Count 1 static const u32 SFTextureTransformNode_V1_TypeToTag[1] = { - TAG_MPEG4_TextureTransform + TAG_MPEG4_TextureTransform }; #define SFViewpointNode_V1_NUMBITS 1 #define SFViewpointNode_V1_Count 1 static const u32 SFViewpointNode_V1_TypeToTag[1] = { - TAG_MPEG4_Viewpoint + TAG_MPEG4_Viewpoint }; #define SFVisemeNode_V1_NUMBITS 1 #define SFVisemeNode_V1_Count 1 static const u32 SFVisemeNode_V1_TypeToTag[1] = { - TAG_MPEG4_Viseme + TAG_MPEG4_Viseme }; @@ -277,70 +277,70 @@ u32 NDT_V1_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V2_Count 12 static const u32 SFWorldNode_V2_TypeToTag[12] = { - TAG_MPEG4_AcousticMaterial, TAG_MPEG4_AcousticScene, TAG_MPEG4_ApplicationWindow, TAG_MPEG4_BAP, TAG_MPEG4_BDP, TAG_MPEG4_Body, TAG_MPEG4_BodyDefTable, TAG_MPEG4_BodySegmentConnectionHint, TAG_MPEG4_DirectiveSound, TAG_MPEG4_Hierarchical3DMesh, TAG_MPEG4_MaterialKey, TAG_MPEG4_PerceptualParameters + TAG_MPEG4_AcousticMaterial, TAG_MPEG4_AcousticScene, TAG_MPEG4_ApplicationWindow, TAG_MPEG4_BAP, TAG_MPEG4_BDP, TAG_MPEG4_Body, TAG_MPEG4_BodyDefTable, TAG_MPEG4_BodySegmentConnectionHint, TAG_MPEG4_DirectiveSound, TAG_MPEG4_Hierarchical3DMesh, TAG_MPEG4_MaterialKey, TAG_MPEG4_PerceptualParameters }; #define SF3DNode_V2_NUMBITS 3 #define SF3DNode_V2_Count 3 static const u32 SF3DNode_V2_TypeToTag[3] = { - TAG_MPEG4_AcousticScene, TAG_MPEG4_Body, TAG_MPEG4_DirectiveSound + TAG_MPEG4_AcousticScene, TAG_MPEG4_Body, TAG_MPEG4_DirectiveSound }; #define SF2DNode_V2_NUMBITS 2 #define SF2DNode_V2_Count 2 static const u32 SF2DNode_V2_TypeToTag[2] = { - TAG_MPEG4_ApplicationWindow, TAG_MPEG4_Body + TAG_MPEG4_ApplicationWindow, TAG_MPEG4_Body }; #define SFGeometryNode_V2_NUMBITS 2 #define SFGeometryNode_V2_Count 1 static const u32 SFGeometryNode_V2_TypeToTag[1] = { - TAG_MPEG4_Hierarchical3DMesh + TAG_MPEG4_Hierarchical3DMesh }; #define SFMaterialNode_V2_NUMBITS 2 #define SFMaterialNode_V2_Count 2 static const u32 SFMaterialNode_V2_TypeToTag[2] = { - TAG_MPEG4_AcousticMaterial, TAG_MPEG4_MaterialKey + TAG_MPEG4_AcousticMaterial, TAG_MPEG4_MaterialKey }; #define SFBAPNode_V2_NUMBITS 2 #define SFBAPNode_V2_Count 1 static const u32 SFBAPNode_V2_TypeToTag[1] = { - TAG_MPEG4_BAP + TAG_MPEG4_BAP }; #define SFBDPNode_V2_NUMBITS 2 #define SFBDPNode_V2_Count 1 static const u32 SFBDPNode_V2_TypeToTag[1] = { - TAG_MPEG4_BDP + TAG_MPEG4_BDP }; #define SFBodyDefTableNode_V2_NUMBITS 2 #define SFBodyDefTableNode_V2_Count 1 static const u32 SFBodyDefTableNode_V2_TypeToTag[1] = { - TAG_MPEG4_BodyDefTable + TAG_MPEG4_BodyDefTable }; #define SFBodySegmentConnectionHintNode_V2_NUMBITS 2 #define SFBodySegmentConnectionHintNode_V2_Count 1 static const u32 SFBodySegmentConnectionHintNode_V2_TypeToTag[1] = { - TAG_MPEG4_BodySegmentConnectionHint + TAG_MPEG4_BodySegmentConnectionHint }; #define SFPerceptualParameterNode_V2_NUMBITS 2 #define SFPerceptualParameterNode_V2_Count 1 static const u32 SFPerceptualParameterNode_V2_TypeToTag[1] = { - TAG_MPEG4_PerceptualParameters + TAG_MPEG4_PerceptualParameters }; @@ -357,28 +357,28 @@ u32 NDT_V2_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V3_Count 3 static const u32 SFWorldNode_V3_TypeToTag[3] = { - TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand + TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand }; #define SF3DNode_V3_NUMBITS 2 #define SF3DNode_V3_Count 3 static const u32 SF3DNode_V3_TypeToTag[3] = { - TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand + TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand }; #define SF2DNode_V3_NUMBITS 2 #define SF2DNode_V3_Count 3 static const u32 SF2DNode_V3_TypeToTag[3] = { - TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand + TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup, TAG_MPEG4_ServerCommand }; #define SFTemporalNode_V3_NUMBITS 2 #define SFTemporalNode_V3_Count 2 static const u32 SFTemporalNode_V3_TypeToTag[2] = { - TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup + TAG_MPEG4_TemporalTransform, TAG_MPEG4_TemporalGroup }; @@ -395,28 +395,28 @@ u32 NDT_V3_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V4_Count 5 static const u32 SFWorldNode_V4_TypeToTag[5] = { - TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor + TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor }; #define SF3DNode_V4_NUMBITS 3 #define SF3DNode_V4_Count 5 static const u32 SF3DNode_V4_TypeToTag[5] = { - TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor + TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor }; #define SF2DNode_V4_NUMBITS 3 #define SF2DNode_V4_Count 5 static const u32 SF2DNode_V4_TypeToTag[5] = { - TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor + TAG_MPEG4_InputSensor, TAG_MPEG4_MatteTexture, TAG_MPEG4_MediaBuffer, TAG_MPEG4_MediaControl, TAG_MPEG4_MediaSensor }; #define SFTextureNode_V4_NUMBITS 1 #define SFTextureNode_V4_Count 1 static const u32 SFTextureNode_V4_TypeToTag[1] = { - TAG_MPEG4_MatteTexture + TAG_MPEG4_MatteTexture }; @@ -433,147 +433,147 @@ u32 NDT_V4_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V5_Count 39 static const u32 SFWorldNode_V5_TypeToTag[39] = { - TAG_MPEG4_BitWrapper, TAG_MPEG4_CoordinateInterpolator4D, TAG_MPEG4_DepthImage, TAG_MPEG4_FFD, TAG_MPEG4_Implicit, TAG_MPEG4_XXLFM_Appearance, TAG_MPEG4_XXLFM_BlendList, TAG_MPEG4_XXLFM_FrameList, TAG_MPEG4_XXLFM_LightMap, TAG_MPEG4_XXLFM_SurfaceMapList, TAG_MPEG4_XXLFM_ViewMapList, TAG_MPEG4_MeshGrid, TAG_MPEG4_NonLinearDeformer, TAG_MPEG4_NurbsCurve, TAG_MPEG4_NurbsCurve2D, TAG_MPEG4_NurbsSurface, TAG_MPEG4_OctreeImage, TAG_MPEG4_XXParticles, TAG_MPEG4_XXParticleInitBox, TAG_MPEG4_XXPlanarObstacle, TAG_MPEG4_XXPointAttractor, TAG_MPEG4_PointTexture, TAG_MPEG4_PositionAnimator, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_PositionInterpolator4D, TAG_MPEG4_ProceduralTexture, TAG_MPEG4_Quadric, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator, TAG_MPEG4_SimpleTexture, TAG_MPEG4_SolidRep, TAG_MPEG4_SubdivisionSurface, TAG_MPEG4_SubdivSurfaceSector, TAG_MPEG4_WaveletSubdivisionSurface + TAG_MPEG4_BitWrapper, TAG_MPEG4_CoordinateInterpolator4D, TAG_MPEG4_DepthImage, TAG_MPEG4_FFD, TAG_MPEG4_Implicit, TAG_MPEG4_XXLFM_Appearance, TAG_MPEG4_XXLFM_BlendList, TAG_MPEG4_XXLFM_FrameList, TAG_MPEG4_XXLFM_LightMap, TAG_MPEG4_XXLFM_SurfaceMapList, TAG_MPEG4_XXLFM_ViewMapList, TAG_MPEG4_MeshGrid, TAG_MPEG4_NonLinearDeformer, TAG_MPEG4_NurbsCurve, TAG_MPEG4_NurbsCurve2D, TAG_MPEG4_NurbsSurface, TAG_MPEG4_OctreeImage, TAG_MPEG4_XXParticles, TAG_MPEG4_XXParticleInitBox, TAG_MPEG4_XXPlanarObstacle, TAG_MPEG4_XXPointAttractor, TAG_MPEG4_PointTexture, TAG_MPEG4_PositionAnimator, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_PositionInterpolator4D, TAG_MPEG4_ProceduralTexture, TAG_MPEG4_Quadric, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator, TAG_MPEG4_SimpleTexture, TAG_MPEG4_SolidRep, TAG_MPEG4_SubdivisionSurface, TAG_MPEG4_SubdivSurfaceSector, TAG_MPEG4_WaveletSubdivisionSurface }; #define SF3DNode_V5_NUMBITS 5 #define SF3DNode_V5_Count 17 static const u32 SF3DNode_V5_TypeToTag[17] = { - TAG_MPEG4_BitWrapper, TAG_MPEG4_CoordinateInterpolator4D, TAG_MPEG4_DepthImage, TAG_MPEG4_FFD, TAG_MPEG4_OctreeImage, TAG_MPEG4_XXParticles, TAG_MPEG4_PositionAnimator, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_PositionInterpolator4D, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator, TAG_MPEG4_WaveletSubdivisionSurface + TAG_MPEG4_BitWrapper, TAG_MPEG4_CoordinateInterpolator4D, TAG_MPEG4_DepthImage, TAG_MPEG4_FFD, TAG_MPEG4_OctreeImage, TAG_MPEG4_XXParticles, TAG_MPEG4_PositionAnimator, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_PositionInterpolator4D, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator, TAG_MPEG4_WaveletSubdivisionSurface }; #define SF2DNode_V5_NUMBITS 4 #define SF2DNode_V5_Count 9 static const u32 SF2DNode_V5_TypeToTag[9] = { - TAG_MPEG4_BitWrapper, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator + TAG_MPEG4_BitWrapper, TAG_MPEG4_PositionAnimator2D, TAG_MPEG4_SBBone, TAG_MPEG4_SBMuscle, TAG_MPEG4_SBSegment, TAG_MPEG4_SBSite, TAG_MPEG4_SBSkinnedModel, TAG_MPEG4_SBVCAnimation, TAG_MPEG4_ScalarAnimator }; #define SFAppearanceNode_V5_NUMBITS 1 #define SFAppearanceNode_V5_Count 1 static const u32 SFAppearanceNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_Appearance + TAG_MPEG4_XXLFM_Appearance }; #define SFGeometryNode_V5_NUMBITS 4 #define SFGeometryNode_V5_Count 10 static const u32 SFGeometryNode_V5_TypeToTag[10] = { - TAG_MPEG4_BitWrapper, TAG_MPEG4_Implicit, TAG_MPEG4_MeshGrid, TAG_MPEG4_NonLinearDeformer, TAG_MPEG4_NurbsCurve, TAG_MPEG4_NurbsCurve2D, TAG_MPEG4_NurbsSurface, TAG_MPEG4_Quadric, TAG_MPEG4_SolidRep, TAG_MPEG4_SubdivisionSurface + TAG_MPEG4_BitWrapper, TAG_MPEG4_Implicit, TAG_MPEG4_MeshGrid, TAG_MPEG4_NonLinearDeformer, TAG_MPEG4_NurbsCurve, TAG_MPEG4_NurbsCurve2D, TAG_MPEG4_NurbsSurface, TAG_MPEG4_Quadric, TAG_MPEG4_SolidRep, TAG_MPEG4_SubdivisionSurface }; #define SFTextureNode_V5_NUMBITS 1 #define SFTextureNode_V5_Count 1 static const u32 SFTextureNode_V5_TypeToTag[1] = { - TAG_MPEG4_ProceduralTexture + TAG_MPEG4_ProceduralTexture }; #define SFDepthImageNode_V5_NUMBITS 1 #define SFDepthImageNode_V5_Count 1 static const u32 SFDepthImageNode_V5_TypeToTag[1] = { - TAG_MPEG4_DepthImage + TAG_MPEG4_DepthImage }; #define SFBlendListNode_V5_NUMBITS 1 #define SFBlendListNode_V5_Count 1 static const u32 SFBlendListNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_BlendList + TAG_MPEG4_XXLFM_BlendList }; #define SFFrameListNode_V5_NUMBITS 1 #define SFFrameListNode_V5_Count 1 static const u32 SFFrameListNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_FrameList + TAG_MPEG4_XXLFM_FrameList }; #define SFLightMapNode_V5_NUMBITS 1 #define SFLightMapNode_V5_Count 1 static const u32 SFLightMapNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_LightMap + TAG_MPEG4_XXLFM_LightMap }; #define SFSurfaceMapNode_V5_NUMBITS 1 #define SFSurfaceMapNode_V5_Count 1 static const u32 SFSurfaceMapNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_SurfaceMapList + TAG_MPEG4_XXLFM_SurfaceMapList }; #define SFViewMapNode_V5_NUMBITS 1 #define SFViewMapNode_V5_Count 1 static const u32 SFViewMapNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXLFM_ViewMapList + TAG_MPEG4_XXLFM_ViewMapList }; #define SFParticleInitializerNode_V5_NUMBITS 1 #define SFParticleInitializerNode_V5_Count 1 static const u32 SFParticleInitializerNode_V5_TypeToTag[1] = { - TAG_MPEG4_XXParticleInitBox + TAG_MPEG4_XXParticleInitBox }; #define SFInfluenceNode_V5_NUMBITS 2 #define SFInfluenceNode_V5_Count 2 static const u32 SFInfluenceNode_V5_TypeToTag[2] = { - TAG_MPEG4_XXPlanarObstacle, TAG_MPEG4_XXPointAttractor + TAG_MPEG4_XXPlanarObstacle, TAG_MPEG4_XXPointAttractor }; #define SFDepthTextureNode_V5_NUMBITS 2 #define SFDepthTextureNode_V5_Count 2 static const u32 SFDepthTextureNode_V5_TypeToTag[2] = { - TAG_MPEG4_PointTexture, TAG_MPEG4_SimpleTexture + TAG_MPEG4_PointTexture, TAG_MPEG4_SimpleTexture }; #define SFSBBoneNode_V5_NUMBITS 1 #define SFSBBoneNode_V5_Count 1 static const u32 SFSBBoneNode_V5_TypeToTag[1] = { - TAG_MPEG4_SBBone + TAG_MPEG4_SBBone }; #define SFSBMuscleNode_V5_NUMBITS 1 #define SFSBMuscleNode_V5_Count 1 static const u32 SFSBMuscleNode_V5_TypeToTag[1] = { - TAG_MPEG4_SBMuscle + TAG_MPEG4_SBMuscle }; #define SFSBSegmentNode_V5_NUMBITS 1 #define SFSBSegmentNode_V5_Count 1 static const u32 SFSBSegmentNode_V5_TypeToTag[1] = { - TAG_MPEG4_SBSegment + TAG_MPEG4_SBSegment }; #define SFSBSiteNode_V5_NUMBITS 1 #define SFSBSiteNode_V5_Count 1 static const u32 SFSBSiteNode_V5_TypeToTag[1] = { - TAG_MPEG4_SBSite + TAG_MPEG4_SBSite }; #define SFBaseMeshNode_V5_NUMBITS 1 #define SFBaseMeshNode_V5_Count 1 static const u32 SFBaseMeshNode_V5_TypeToTag[1] = { - TAG_MPEG4_SubdivisionSurface + TAG_MPEG4_SubdivisionSurface }; #define SFSubdivSurfaceSectorNode_V5_NUMBITS 1 #define SFSubdivSurfaceSectorNode_V5_Count 1 static const u32 SFSubdivSurfaceSectorNode_V5_TypeToTag[1] = { - TAG_MPEG4_SubdivSurfaceSector + TAG_MPEG4_SubdivSurfaceSector }; @@ -590,63 +590,63 @@ u32 NDT_V5_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V6_Count 12 static const u32 SFWorldNode_V6_TypeToTag[12] = { - TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_Ellipse, TAG_MPEG4_LinearGradient, TAG_MPEG4_PathLayout, TAG_MPEG4_RadialGradient, TAG_MPEG4_SynthesizedTexture, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport, TAG_MPEG4_XCurve2D, TAG_MPEG4_XFontStyle, TAG_MPEG4_XLineProperties + TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_Ellipse, TAG_MPEG4_LinearGradient, TAG_MPEG4_PathLayout, TAG_MPEG4_RadialGradient, TAG_MPEG4_SynthesizedTexture, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport, TAG_MPEG4_XCurve2D, TAG_MPEG4_XFontStyle, TAG_MPEG4_XLineProperties }; #define SF3DNode_V6_NUMBITS 3 #define SF3DNode_V6_Count 5 static const u32 SF3DNode_V6_TypeToTag[5] = { - TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_PathLayout, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport + TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_PathLayout, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport }; #define SF2DNode_V6_NUMBITS 3 #define SF2DNode_V6_Count 5 static const u32 SF2DNode_V6_TypeToTag[5] = { - TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_PathLayout, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport + TAG_MPEG4_Clipper2D, TAG_MPEG4_ColorTransform, TAG_MPEG4_PathLayout, TAG_MPEG4_TransformMatrix2D, TAG_MPEG4_Viewport }; #define SFGeometryNode_V6_NUMBITS 2 #define SFGeometryNode_V6_Count 2 static const u32 SFGeometryNode_V6_TypeToTag[2] = { - TAG_MPEG4_Ellipse, TAG_MPEG4_XCurve2D + TAG_MPEG4_Ellipse, TAG_MPEG4_XCurve2D }; #define SFTextureNode_V6_NUMBITS 2 #define SFTextureNode_V6_Count 3 static const u32 SFTextureNode_V6_TypeToTag[3] = { - TAG_MPEG4_LinearGradient, TAG_MPEG4_RadialGradient, TAG_MPEG4_SynthesizedTexture + TAG_MPEG4_LinearGradient, TAG_MPEG4_RadialGradient, TAG_MPEG4_SynthesizedTexture }; #define SFFontStyleNode_V6_NUMBITS 1 #define SFFontStyleNode_V6_Count 1 static const u32 SFFontStyleNode_V6_TypeToTag[1] = { - TAG_MPEG4_XFontStyle + TAG_MPEG4_XFontStyle }; #define SFLinePropertiesNode_V6_NUMBITS 1 #define SFLinePropertiesNode_V6_Count 1 static const u32 SFLinePropertiesNode_V6_TypeToTag[1] = { - TAG_MPEG4_XLineProperties + TAG_MPEG4_XLineProperties }; #define SFTextureTransformNode_V6_NUMBITS 1 #define SFTextureTransformNode_V6_Count 1 static const u32 SFTextureTransformNode_V6_TypeToTag[1] = { - TAG_MPEG4_TransformMatrix2D + TAG_MPEG4_TransformMatrix2D }; #define SFViewportNode_V6_NUMBITS 1 #define SFViewportNode_V6_Count 1 static const u32 SFViewportNode_V6_TypeToTag[1] = { - TAG_MPEG4_Viewport + TAG_MPEG4_Viewport }; @@ -663,49 +663,49 @@ u32 NDT_V6_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V7_Count 11 static const u32 SFWorldNode_V7_TypeToTag[11] = { - TAG_MPEG4_AdvancedAudioBuffer, TAG_MPEG4_AudioChannelConfig, TAG_MPEG4_DepthImageV2, TAG_MPEG4_MorphShape, TAG_MPEG4_MultiTexture, TAG_MPEG4_PointTextureV2, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_SimpleTextureV2, TAG_MPEG4_SurroundingSound, TAG_MPEG4_Transform3DAudio, TAG_MPEG4_WideSound + TAG_MPEG4_AdvancedAudioBuffer, TAG_MPEG4_AudioChannelConfig, TAG_MPEG4_DepthImageV2, TAG_MPEG4_MorphShape, TAG_MPEG4_MultiTexture, TAG_MPEG4_PointTextureV2, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_SimpleTextureV2, TAG_MPEG4_SurroundingSound, TAG_MPEG4_Transform3DAudio, TAG_MPEG4_WideSound }; #define SF3DNode_V7_NUMBITS 3 #define SF3DNode_V7_Count 6 static const u32 SF3DNode_V7_TypeToTag[6] = { - TAG_MPEG4_DepthImageV2, TAG_MPEG4_MorphShape, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_SurroundingSound, TAG_MPEG4_Transform3DAudio, TAG_MPEG4_WideSound + TAG_MPEG4_DepthImageV2, TAG_MPEG4_MorphShape, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_SurroundingSound, TAG_MPEG4_Transform3DAudio, TAG_MPEG4_WideSound }; #define SF2DNode_V7_NUMBITS 2 #define SF2DNode_V7_Count 3 static const u32 SF2DNode_V7_TypeToTag[3] = { - TAG_MPEG4_MorphShape, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_Transform3DAudio + TAG_MPEG4_MorphShape, TAG_MPEG4_SBVCAnimationV2, TAG_MPEG4_Transform3DAudio }; #define SFAudioNode_V7_NUMBITS 2 #define SFAudioNode_V7_Count 2 static const u32 SFAudioNode_V7_TypeToTag[2] = { - TAG_MPEG4_AdvancedAudioBuffer, TAG_MPEG4_AudioChannelConfig + TAG_MPEG4_AdvancedAudioBuffer, TAG_MPEG4_AudioChannelConfig }; #define SFTextureNode_V7_NUMBITS 1 #define SFTextureNode_V7_Count 1 static const u32 SFTextureNode_V7_TypeToTag[1] = { - TAG_MPEG4_MultiTexture + TAG_MPEG4_MultiTexture }; #define SFDepthImageNode_V7_NUMBITS 1 #define SFDepthImageNode_V7_Count 1 static const u32 SFDepthImageNode_V7_TypeToTag[1] = { - TAG_MPEG4_DepthImageV2 + TAG_MPEG4_DepthImageV2 }; #define SFDepthTextureNode_V7_NUMBITS 2 #define SFDepthTextureNode_V7_Count 2 static const u32 SFDepthTextureNode_V7_TypeToTag[2] = { - TAG_MPEG4_PointTextureV2, TAG_MPEG4_SimpleTextureV2 + TAG_MPEG4_PointTextureV2, TAG_MPEG4_SimpleTextureV2 }; @@ -722,28 +722,28 @@ u32 NDT_V7_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V8_Count 2 static const u32 SFWorldNode_V8_TypeToTag[2] = { - TAG_MPEG4_ScoreShape, TAG_MPEG4_MusicScore + TAG_MPEG4_ScoreShape, TAG_MPEG4_MusicScore }; #define SF3DNode_V8_NUMBITS 1 #define SF3DNode_V8_Count 1 static const u32 SF3DNode_V8_TypeToTag[1] = { - TAG_MPEG4_ScoreShape + TAG_MPEG4_ScoreShape }; #define SF2DNode_V8_NUMBITS 1 #define SF2DNode_V8_Count 1 static const u32 SF2DNode_V8_TypeToTag[1] = { - TAG_MPEG4_ScoreShape + TAG_MPEG4_ScoreShape }; #define SFMusicScoreNode_V8_NUMBITS 1 #define SFMusicScoreNode_V8_Count 1 static const u32 SFMusicScoreNode_V8_TypeToTag[1] = { - TAG_MPEG4_MusicScore + TAG_MPEG4_MusicScore }; @@ -760,21 +760,21 @@ u32 NDT_V8_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V9_Count 6 static const u32 SFWorldNode_V9_TypeToTag[6] = { - TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow + TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow }; #define SF3DNode_V9_NUMBITS 3 #define SF3DNode_V9_Count 6 static const u32 SF3DNode_V9_TypeToTag[6] = { - TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow + TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow }; #define SFGeometryNode_V9_NUMBITS 3 #define SFGeometryNode_V9_Count 6 static const u32 SFGeometryNode_V9_TypeToTag[6] = { - TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow + TAG_MPEG4_FootPrintSetNode, TAG_MPEG4_FootPrintNode, TAG_MPEG4_BuildingPartNode, TAG_MPEG4_RoofNode, TAG_MPEG4_FacadeNode, TAG_MPEG4_Shadow }; @@ -791,28 +791,28 @@ u32 NDT_V9_GetNodeType(u32 NDT_Tag, u32 NodeTag); #define SFWorldNode_V10_Count 5 static const u32 SFWorldNode_V10_TypeToTag[5] = { - TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_SpacePartition, TAG_MPEG4_Storage + TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_SpacePartition, TAG_MPEG4_Storage }; #define SF3DNode_V10_NUMBITS 3 #define SF3DNode_V10_Count 5 static const u32 SF3DNode_V10_TypeToTag[5] = { - TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_SpacePartition, TAG_MPEG4_Storage + TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_SpacePartition, TAG_MPEG4_Storage }; #define SF2DNode_V10_NUMBITS 3 #define SF2DNode_V10_Count 4 static const u32 SF2DNode_V10_TypeToTag[4] = { - TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_Storage + TAG_MPEG4_CacheTexture, TAG_MPEG4_EnvironmentTest, TAG_MPEG4_KeyNavigator, TAG_MPEG4_Storage }; #define SFTextureNode_V10_NUMBITS 1 #define SFTextureNode_V10_Count 1 static const u32 SFTextureNode_V10_TypeToTag[1] = { - TAG_MPEG4_CacheTexture + TAG_MPEG4_CacheTexture }; diff --git a/include/gpac/internal/camera.h b/include/gpac/internal/camera.h index 2f68a84..5780b8e 100644 --- a/include/gpac/internal/camera.h +++ b/include/gpac/internal/camera.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/internal/compositor_dev.h b/include/gpac/internal/compositor_dev.h index eae690d..61580bc 100644 --- a/include/gpac/internal/compositor_dev.h +++ b/include/gpac/internal/compositor_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,7 +50,7 @@ extern "C" { /*if defined, events are queued before being processed, otherwise they are handled whenever triggered*/ -//#define GF_SR_EVENT_QUEUE +//#define GF_SR_EVENT_QUEUE /*use 2D caching for groups*/ @@ -91,7 +91,7 @@ typedef struct _gf_ft_mgr GF_FontManager; #include #include -typedef struct +typedef struct { Bool multisample; Bool bgra_texture; @@ -182,7 +182,7 @@ struct __tag_compositor GF_List *extra_scenes; u32 inherit_type_3d; - + /*all time nodes registered*/ GF_List *time_nodes; /*all textures (texture handlers)*/ @@ -220,7 +220,7 @@ struct __tag_compositor /*display size*/ u32 display_width, display_height; - /*visual output location on window (we may draw background color outside of it) + /*visual output location on window (we may draw background color outside of it) vp_x & vp_y: horizontal & vertical offset of the drawing area in the video output vp_width & vp_height: width & height of the drawing area * in scalable mode, this is the display size @@ -268,7 +268,7 @@ struct __tag_compositor Bool opengl_raster; #endif - //in this mode all 2D raster is done through and RGBA canvas except background IO and textures which are done by the GPU. The canvas is then flushed to GPU. + //in this mode all 2D raster is done through and RGBA canvas except background IO and textures which are done by the GPU. The canvas is then flushed to GPU. //the mode supports defer and immediate rendering Bool hybrid_opengl; @@ -305,7 +305,7 @@ struct __tag_compositor GF_VisualManager *visual; /*set to false whenever a new scene is attached to compositor*/ Bool root_visual_setup; - + /*indicates whether the aspect ratio shall be recomputed: 1: AR changed 2: AR changed and root visual type changed between 2D and 3D @@ -430,8 +430,8 @@ struct __tag_compositor /*the active parent text node under selection*/ GF_Node *text_selection; /*text selection start/end in world coord system*/ - SFVec2f start_sel, end_sel; - /*text selection state*/ + SFVec2f start_sel, end_sel; + /*text selection state*/ u32 store_text_state; /*parent text node when a text is hit (to handle tspan selection)*/ GF_Node *hit_text; @@ -461,8 +461,6 @@ struct __tag_compositor /*disable RECT extensions (except for Bitmap...)*/ Bool disable_rect_ext; /*disable RECT extensions (except for Bitmap...)*/ - Bool bitmap_use_pixels; - /*disable RECT extensions (except for Bitmap...)*/ u32 draw_normals; /*backface cull type: 0 off, 1: on, 2: on with transparency*/ u32 backcull; @@ -513,7 +511,7 @@ struct __tag_compositor #endif Bool texture_from_decoder_memory; - + u32 networks_time; u32 decoders_time; @@ -579,7 +577,7 @@ enum GF_SR_TEXTURE_MATTE = (1<<2), /*texture doesn't need vertical flip for OpenGL*/ GF_SR_TEXTURE_NO_GL_FLIP = (1<<3), - /*Set durin a composition cycle. If not set at the end of the cycle, + /*Set durin a composition cycle. If not set at the end of the cycle, the hardware binding is released*/ GF_SR_TEXTURE_USED = (1<<4), @@ -614,12 +612,12 @@ typedef struct _gf_sc_texture_handler u32 last_frame_time; /*active display in the texture (0, 0 == top, left)*/ //GF_Rect active_window; - /*texture is transparent*/ + /*texture is transparent*/ Bool transparent; /*flags for user - the repeatS and repeatT are set upon creation, the rest is NEVER touched by compositor*/ u32 flags; /*gradients are relative to the object bounds, therefore a gradient is not the same if used on 2 different - objects - since we don't want to build an offscreen texture for the gradient, gradients have to be updated + objects - since we don't want to build an offscreen texture for the gradient, gradients have to be updated at each draw - the matrix shall be updated to the gradient transformation in the local system MUST be set for gradient textures*/ void (*compute_gradient_matrix)(struct _gf_sc_texture_handler *txh, GF_Rect *bounds, GF_Matrix2D *mat, Bool for_3d); @@ -627,7 +625,7 @@ typedef struct _gf_sc_texture_handler /*image data for natural media*/ char *data; u32 width, height, stride, pixelformat, pixel_ar; - Bool is_flipped; + Bool is_flipped; Bool raw_memory; u8 *pU, *pV; @@ -674,7 +672,7 @@ void gf_sc_texture_release_stream(GF_TextureHandler *txh); void gf_sc_texture_cleanup_hw(GF_Compositor *compositor); -/*sensor node handler - this is not defined as a stack because Anchor is both a grouping node and a +/*sensor node handler - this is not defined as a stack because Anchor is both a grouping node and a sensor node, and we DO need the groupingnode stack...*/ typedef struct _sensor_handler { @@ -699,6 +697,7 @@ Bool compositor_mpeg4_is_sensor_node(GF_Node *node); /*returns associated sensor handler from traversable stack (the node handler is always responsible for creation/deletion) returns NULL if not a sensor or sensor is not activated*/ GF_SensorHandler *compositor_mpeg4_get_sensor_handler(GF_Node *n); +GF_SensorHandler *compositor_mpeg4_get_sensor_handler_ex(GF_Node *n, Bool skip_anchors); /*rendering modes*/ enum @@ -727,7 +726,7 @@ enum #ifndef GPAC_DISABLE_3D /*explicit draw routine used when flushing 3D display list*/ TRAVERSE_DRAW_3D, - /*set global lights on. Since the model_matrix is not pushed to the target in this + /*set global lights on. Since the model_matrix is not pushed to the target in this pass, global lights shall not forget to do it (cf lighting.c)*/ TRAVERSE_LIGHTING, /*collision routine*/ @@ -743,7 +742,7 @@ typedef struct _group_cache_candidate GF_CacheCandidate; #define MAX_USER_CLIP_PLANES 4 -/*the traversing context: set_up at top-level and passed through SFNode_Render. Each node is responsible for +/*the traversing context: set_up at top-level and passed through SFNode_Render. Each node is responsible for restoring the context state before returning*/ struct _traversing_state { @@ -779,7 +778,7 @@ struct _traversing_state /*the one and only visual manager currently being traversed*/ GF_VisualManager *visual; - + #ifndef GPAC_DISABLE_VRML /*current background and viewport stacks*/ GF_List *backgrounds; @@ -818,7 +817,7 @@ struct _traversing_state Bool abort_bounds_traverse; GF_Matrix2D mx_at_node; Bool ignore_strike; - + GF_List *use_stack; /* Styling Property and others for SVG context */ @@ -845,7 +844,7 @@ struct _traversing_state Fixed base_x, base_y; Fixed line_spacing; Fixed base_shift; - /*quick and dirty hack to try to solve xml:space across text and tspans without + /*quick and dirty hack to try to solve xml:space across text and tspans without flattening the DOMText nodes 0: first block of text 1: previous block of text ended with a space @@ -873,7 +872,7 @@ struct _traversing_state /*current object (model) transformation at the given layer*/ GF_Matrix layer_matrix; - + /*set when traversing a cached group during offscreen bitmap construction.*/ Bool in_group_cache; @@ -890,7 +889,7 @@ struct _traversing_state #ifndef GPAC_DISABLE_VRML /*fog bind stack*/ - GF_List *fogs; + GF_List *fogs; /*navigation bind stack*/ GF_List *navigations; #endif @@ -919,20 +918,20 @@ struct _traversing_state /*layer traversal state: set to the first traversed layer3D when picking - set to the current layer3D traversed when rendering 3D to an offscreen bitmap. This alows other - nodes (typically bindables) seting the layer dirty flags to force a redraw + set to the current layer3D traversed when rendering 3D to an offscreen bitmap. This alows other + nodes (typically bindables) seting the layer dirty flags to force a redraw */ GF_Node *layer3d; #endif - + #ifdef GF_SR_USE_DEPTH - Fixed depth_gain, depth_offset; + Fixed depth_gain, depth_offset; #endif #ifdef GF_SR_USE_VIDEO_CACHE - /*set to 1 if cache evaluation can be skipped - this is only set when there is not enough memory + /*set to 1 if cache evaluation can be skipped - this is only set when there is not enough memory to cache a sub-group, in which case the group cannot be cached (we're caching in display coordinates)*/ Bool cache_too_small; #endif @@ -945,7 +944,7 @@ struct _traversing_state /*the audio object as used by the mixer. All audio nodes need to implement this interface*/ typedef struct _audiointerface { - /*fetch audio data for a given audio delay (~soundcard drift) - if delay is 0 sync should not be performed + /*fetch audio data for a given audio delay (~soundcard drift) - if delay is 0 sync should not be performed (eg intermediate mix) */ char *(*FetchFrame) (void *callback, u32 *size, u32 audio_delay_ms); /*release a number of bytes in the indicated frame (ts)*/ @@ -958,7 +957,7 @@ typedef struct _audiointerface Bool (*IsMuted)(void *callback); /*user callback*/ void *callback; - /*returns 0 if config is not known yet or changed, + /*returns 0 if config is not known yet or changed, otherwise AND IF @for_reconf is set, updates member var below and return TRUE You may return 0 to force parent user invalidation*/ Bool (*GetConfig)(struct _audiointerface *ai, Bool for_reconf); @@ -1034,7 +1033,7 @@ typedef struct _audio_render /*frozen time counter if set*/ Bool Frozen; u32 FreezeTime; - + /*final output*/ GF_AudioMixer *mixer; Bool need_reconfig; @@ -1050,7 +1049,7 @@ typedef struct _audio_render u32 audio_delay, volume, pan, mute; GF_AudioFilterChain filter_chain; - u32 nb_filled, nb_used; + u32 nb_filled, nb_used; } GF_AudioRenderer; /*creates audio renderer*/ @@ -1133,7 +1132,7 @@ Bool gf_sc_audio_check_url(GF_AudioInput *ai, MFURL *url); #define AUDIO_GROUP_NODE \ GF_AudioInput output; \ void (*add_source)(struct _audio_group *_this, GF_AudioInput *src); \ - + typedef struct _audio_group { AUDIO_GROUP_NODE @@ -1162,6 +1161,7 @@ GF_Rect compositor_2d_update_clipper(GF_TraverseState *tr_state, GF_Rect this_cl #ifndef GPAC_DISABLE_3D void compositor_2d_reset_gl_auto(GF_Compositor *compositor); void compositor_2d_hybgl_flush_video(GF_Compositor *compositor, GF_IRect *area); +void compositor_2d_hybgl_clear_surface_ex(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor, Bool is_offscreen_clear); #endif Bool compositor_texture_rectangles(GF_VisualManager *visual, GF_TextureHandler *txh, GF_IRect *clip, GF_Rect *unclip, GF_Window *src, GF_Window *dst, Bool *disable_blit, Bool *has_scale); @@ -1255,7 +1255,7 @@ GF_SceneGraph *gf_sc_animation_get_scenegraph(GF_Node *node); typedef struct _gf_font GF_Font; -struct _gf_font +struct _gf_font { /*fonts are linked within the font manager*/ GF_Font *next; @@ -1282,7 +1282,7 @@ struct _gf_font GF_List *spans; }; -enum +enum { /*span direction is horizontal*/ GF_TEXT_SPAN_HORIZONTAL = 1, @@ -1299,7 +1299,7 @@ enum typedef struct __text_span { GF_Font *font; - + GF_Glyph **glyphs; u32 nb_glyphs; @@ -1386,10 +1386,10 @@ GF_Err gf_sc_remove_video_listener(GF_Compositor *compositor, GF_VideoListener * typedef struct { void *udta; - /*called when audio frame is ready to be sent to the sound card. + /*called when audio frame is ready to be sent to the sound card. @buffer, @buffer_size: audio buffer @time: the terminal global clock in ms - @delay: Due to sound card latencies, audio is sent to the sound card delay milliseconds earlier than + @delay: Due to sound card latencies, audio is sent to the sound card delay milliseconds earlier than its associated video. */ void (*on_audio_frame)(void *udta, char *buffer, u32 buffer_size, u32 time, u32 delay); @@ -1408,7 +1408,7 @@ GF_Err gf_sc_set_scene_size(GF_Compositor *compositor, u32 Width, u32 Height, Bo Bool gf_sc_use_raw_texture(GF_Compositor *compositor); void gf_sc_get_av_caps(GF_Compositor *compositor, u32 *width, u32 *height, u32 *display_bit_depth, u32 *audio_bpp, u32 *channels, u32 *sample_rate); -//signals the compositor a system frame is pending on a future frame +//signals the compositor a system frame is pending on a future frame void gf_sc_set_system_pending_frame(GF_Compositor *compositor, Bool frame_pending); //indicates a video frame is pending - this is used fo decoders dispatching their internal memory in order to wake up the compositor asap diff --git a/include/gpac/internal/crypt_dev.h b/include/gpac/internal/crypt_dev.h index 70d6f3a..a9d6a84 100644 --- a/include/gpac/internal/crypt_dev.h +++ b/include/gpac/internal/crypt_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/internal/dvb_mpe_dev.h b/include/gpac/internal/dvb_mpe_dev.h index 4e32c98..3d55bac 100644 --- a/include/gpac/internal/dvb_mpe_dev.h +++ b/include/gpac/internal/dvb_mpe_dev.h @@ -54,18 +54,18 @@ typedef struct u32 service_id; u32 component_tag; -}GF_M2TS_LOC_DSCPTR_IP_STREAM; +} GF_M2TS_LOC_DSCPTR_IP_STREAM; typedef struct descriptor_TimeSliceFec { Bool time_slicing; u8 mpe_fec; u8 frame_size; - u8 max_burst_duration; + u8 max_burst_duration; u8 max_average_rate; u8 time_slice_fec_id; u8 * id_selector; -}GF_M2TS_DesTimeSliceFec; +} GF_M2TS_DesTimeSliceFec; typedef struct { @@ -74,7 +74,7 @@ typedef struct u16 transport_stream_id; u16 service_id; u8 component_tag; -}GF_M2TS_DesLocation; +} GF_M2TS_DesLocation; typedef struct { u8 type; /* 0 = target_IP_descriptor, 1 = target_IP_address_descriptor */ @@ -100,7 +100,7 @@ typedef struct /*IP_Platform object*/ typedef struct __gf_dvb_mpe_ip_platform { -/* remaining from INT, to be delete */ + /* remaining from INT, to be delete */ u32 id; u32 processing_order; u32 number_of_descriptor; @@ -142,7 +142,7 @@ typedef struct u32 u32_rx_udp_port; /* destination port */ u32 u32_udp_data_size; u32 u32_udp_chksm; -}GF_M2TS_IP_Packet; +} GF_M2TS_IP_Packet; @@ -155,7 +155,7 @@ typedef struct mpe_error_holes u32 offset; u32 length; -}MPE_Error_Holes; +} MPE_Error_Holes; typedef struct mpe_fec_frame { @@ -164,13 +164,13 @@ typedef struct mpe_fec_frame u32 col_rs ; u8 *p_adt; /* pointer to the application data table*/ u8 *p_rs; /* pointer to the RS data table*/ - u32 *p_error_adt; + u32 *p_error_adt; u32 *p_error_rs ; u32 capacity_total; u32 current_offset_adt ; u32 current_offset_rs; - u32 initialized ; + u32 initialized ; u8 ADT_done; u32 PID; GF_List *mpe_holes; @@ -228,7 +228,7 @@ void gf_m2ts_gather_ipdatagram_information(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *t void socket_simu(GF_M2TS_IP_Packet *ip_packet, GF_M2TS_Demuxer *ts, Bool yield); -void gf_m2ts_mpe_send_datagram(GF_M2TS_Demuxer *ts, u32 pid, unsigned char *data, u32 data_size); +void gf_m2ts_mpe_send_datagram(GF_M2TS_Demuxer *ts, u32 pid, unsigned char *data, u32 data_size); /* allocate the necessary memory space*/ u32 init_frame(MPE_FEC_FRAME * mff, u32 rows); diff --git a/include/gpac/internal/ietf_dev.h b/include/gpac/internal/ietf_dev.h index 9b7741d..b24e4c8 100644 --- a/include/gpac/internal/ietf_dev.h +++ b/include/gpac/internal/ietf_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,7 +50,7 @@ typedef struct u16 Length; /*sync source identifier*/ u32 SSRC; -} GF_RTCPHeader; +} GF_RTCPHeader; typedef struct __PRO_item @@ -94,12 +94,12 @@ struct __tag_rtp_channel { /*global transport info for the session*/ GF_RTSPTransport net_info; - + /*RTP CHANNEL*/ GF_Socket *rtp; /*RTCP CHANNEL*/ GF_Socket *rtcp; - + /*RTP Packet reordering. Turned on/off during initialization. The library forces a 200 ms max latency at the reordering queue*/ GF_RTPReorder *po; @@ -111,7 +111,7 @@ struct __tag_rtp_channel /*NAT keep-alive*/ u32 last_nat_keepalive_time, nat_keepalive_time_period; - + /*the seq number of the first packet as signaled by the server if any, or first RTP SN received (RTP multicast)*/ u32 rtp_first_SN; @@ -156,7 +156,7 @@ struct __tag_rtp_channel u32 last_num_pck_rcv, last_num_pck_expected, last_num_pck_loss; /*jitter compute*/ u32 Jitter, ntp_init; - s32 last_deviance; + s32 last_deviance; /*NTP of last SR*/ u32 last_SR_NTP_sec, last_SR_NTP_frac; /*RTP time at last SR as indicated in SR*/ @@ -190,12 +190,12 @@ void gf_rtp_get_next_report_time(GF_RTPChannel *ch); } \ strcpy(buf+pos, (const char *) str); \ pos += (u32) strlen((const char *) str); \ - + #define RTSP_WRITE_ALLOC_STR(buf, buf_size, pos, str) \ if (str){ \ RTSP_WRITE_ALLOC_STR_WITHOUT_CHECK(buf, buf_size, pos, str); \ } \ - + #define RTSP_WRITE_HEADER(buf, buf_size, pos, type, str) \ if( str ) { \ RTSP_WRITE_ALLOC_STR(buf, buf_size, pos, type); \ @@ -203,7 +203,7 @@ void gf_rtp_get_next_report_time(GF_RTPChannel *ch); RTSP_WRITE_ALLOC_STR(buf, buf_size, pos, str); \ RTSP_WRITE_ALLOC_STR(buf, buf_size, pos, "\r\n"); \ } \ - + #define RTSP_WRITE_INT(buf, buf_size, pos, d, sig) \ if (sig < 0) { \ sprintf(temp, "%d", d); \ @@ -238,7 +238,7 @@ typedef struct struct _tag_rtsp_session { /*service name (extracted from URL) ex: news/latenight.mp4, vod.mp4 ...*/ - char *Service; + char *Service; /*server name (extracted from URL)*/ char *Server; /*server port (extracted from URL)*/ @@ -278,7 +278,7 @@ struct _tag_rtsp_session /*RTSP interleaving*/ GF_Err (*RTSP_SignalData)(GF_RTSPSession *sess, void *chan, char *buffer, u32 bufferSize, Bool IsRTCP); - + /*buffer for pck reconstruction*/ char *rtsp_pck_buf; u32 rtsp_pck_size; @@ -289,7 +289,7 @@ struct _tag_rtsp_session /*thread-safe, full duplex library for PLAY and RECORD*/ GF_Mutex *mx; - char *MobileIP; + char *MobileIP; }; GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort); @@ -299,7 +299,7 @@ GF_Err gf_rtsp_check_connection(GF_RTSPSession *sess); /*send data on RTSP*/ GF_Err gf_rtsp_send_data(GF_RTSPSession *sess, char *buffer, u32 Size); -/* +/* Common RTSP tools */ @@ -335,7 +335,7 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si GF_Err gp_rtp_builder_do_avc(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize); GF_Err gp_rtp_builder_do_qcelp(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize); GF_Err gp_rtp_builder_do_smv(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize); -GF_Err gp_rtp_builder_do_latm(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration); +GF_Err gp_rtp_builder_do_latm(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration); GF_Err gp_rtp_builder_do_dims(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration); GF_Err gp_rtp_builder_do_ac3(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize); GF_Err gp_rtp_builder_do_hevc(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize); diff --git a/include/gpac/internal/isomedia_dev.h b/include/gpac/internal/isomedia_dev.h index 06a2b0c..5d37786 100644 --- a/include/gpac/internal/isomedia_dev.h +++ b/include/gpac/internal/isomedia_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,7 +37,7 @@ extern "C" { /*the default size is 64, cause we need to handle large boxes... -the other_boxes container is by default NOT created. When parsing a box and adding +the other_boxes container is by default NOT created. When parsing a box and adding a sub-box with gf_isom_box_add_default, the list is created. This list is destroyed befaore calling the final box destructor This list is automatically taken into account during size() and write() functions @@ -46,17 +46,17 @@ This list is automatically taken into account during size() and write() function u32 type; \ u64 size; \ GF_List *other_boxes; \ - + #define GF_ISOM_FULL_BOX \ GF_ISOM_BOX \ u8 version; \ u32 flags; \ - + #define GF_ISOM_UUID_BOX \ GF_ISOM_BOX \ u8 uuid[16]; \ u32 internal_4cc; \ - + typedef struct { GF_ISOM_BOX @@ -215,6 +215,7 @@ enum GF_ISOM_BOX_TYPE_HVCC = GF_4CC( 'h', 'v', 'c', 'C' ), GF_ISOM_BOX_TYPE_HVC1 = GF_4CC( 'h', 'v', 'c', '1' ), GF_ISOM_BOX_TYPE_HEV1 = GF_4CC( 'h', 'e', 'v', '1' ), + GF_ISOM_BOX_TYPE_HVT1 = GF_4CC( 'h', 'v', 't', '1' ), GF_ISOM_BOX_TYPE_HVC2 = GF_4CC( 'h', 'v', 'c', '2' ), GF_ISOM_BOX_TYPE_HEV2 = GF_4CC( 'h', 'e', 'v', '2' ), @@ -234,7 +235,7 @@ enum GF_ISOM_BOX_TYPE_DSMV = GF_4CC( 'd', 's', 'm', 'v' ), GF_ISOM_BOX_TYPE_TSEL = GF_4CC( 't', 's', 'e', 'l' ), - /* 3GPP Adaptive Streaming extensions */ + /* 3GPP Adaptive Streaming extensions */ GF_ISOM_BOX_TYPE_STYP = GF_4CC( 's', 't', 'y', 'p' ), GF_ISOM_BOX_TYPE_TFDT = GF_4CC( 't', 'f', 'd', 't' ), GF_ISOM_BOX_TYPE_SIDX = GF_4CC( 's', 'i', 'd', 'x' ), @@ -305,7 +306,7 @@ enum GF_ISOM_BOX_TYPE_TSRO = GF_4CC( 't', 's', 'r', 'o' ), GF_ISOM_BOX_TYPE_SNRO = GF_4CC( 's', 'n', 'r', 'o' ), GF_ISOM_BOX_TYPE_RTPO = GF_4CC( 'r', 't', 'p', 'o' ), - + /*internal type for track references*/ GF_ISOM_BOX_TYPE_REFT = GF_4CC( 'R', 'E', 'F', 'T' ), @@ -348,7 +349,7 @@ enum GF_ISOM_HANDLER_TYPE_MDIR = GF_4CC( 'm', 'd', 'i', 'r' ), GF_ISOM_BOX_TYPE_CHAP = GF_4CC( 'c', 'h', 'a', 'p' ), GF_ISOM_BOX_TYPE_TEXT = GF_4CC( 't', 'e', 'x', 't' ), - + /*OMA (P)DCF boxes*/ GF_ISOM_BOX_TYPE_OHDR = GF_4CC( 'o', 'h', 'd', 'r' ), GF_ISOM_BOX_TYPE_GRPI = GF_4CC( 'g', 'r', 'p', 'i' ), @@ -372,7 +373,7 @@ enum GF_ISOM_BOX_TYPE_SUBS = GF_4CC( 's', 'u', 'b', 's' ), GF_ISOM_BOX_TYPE_RVCC = GF_4CC( 'r', 'v', 'c', 'c' ), - + GF_ISOM_BOX_TYPE_VTTC = GF_4CC( 'v', 't', 't', 'C' ), GF_ISOM_BOX_TYPE_VTCU = GF_4CC( 'v', 't', 't', 'c' ), GF_ISOM_BOX_TYPE_VTTE = GF_4CC( 'v', 't', 't', 'e' ), @@ -389,7 +390,7 @@ enum GF_ISOM_BOX_TYPE_STTC = GF_4CC( 's', 't', 't', 'C' ), GF_ISOM_BOX_TYPE_PRFT = GF_4CC( 'p', 'r', 'f', 't' ), - + /*ALL INTERNAL BOXES - NEVER WRITTEN TO FILE!!*/ /*generic handlers*/ @@ -575,7 +576,7 @@ typedef struct u32 sample_count_at_seg_start; Bool first_traf_merged; Bool present_in_scalable_segment; -#endif +#endif } GF_TrackBox; typedef struct @@ -868,7 +869,7 @@ typedef struct s16 color_table_index; \ GF_PixelAspectRatioBox *pasp; \ GF_RVCConfigurationBox *rvcc; \ - + typedef struct { GF_ISOM_VISUAL_SAMPLE_ENTRY @@ -946,9 +947,9 @@ typedef struct u16 samplerate_hi; \ u16 samplerate_lo; \ u8 extensions[36]; \ + - -typedef struct +typedef struct { GF_ISOM_AUDIO_SAMPLE_ENTRY } GF_AudioSampleEntryBox; @@ -1061,7 +1062,7 @@ typedef struct /*if this is the compact version, sample size is actually fieldSize*/ u32 sampleSize; u32 sampleCount; - u32 alloc_size; + u32 alloc_size; u32 *sizes; } GF_SampleSizeBox; @@ -1073,7 +1074,7 @@ typedef struct u32 *offsets; } GF_ChunkOffsetBox; -typedef struct +typedef struct { GF_ISOM_FULL_BOX u32 nb_entries; @@ -1172,7 +1173,7 @@ typedef struct GF_ISOM_FULL_BOX GF_List *Samples; } GF_SubSampleInformationBox; - + u32 gf_isom_sample_get_subsample_entry(GF_ISOFile *movie, u32 track, u32 sampleNumber, GF_SubSampleInfoEntry **sub_sample); #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err gf_isom_add_subsample_info(GF_SubSampleInformationBox *sub_samples, u32 sampleNumber, u32 subSampleSize, u8 priority, u32 reserved, Bool discardable); @@ -1183,10 +1184,10 @@ typedef struct { GF_ISOM_FULL_BOX - s32 compositionToDTSShift; - s32 leastDecodeToDisplayDelta; + s32 compositionToDTSShift; + s32 leastDecodeToDisplayDelta; s32 greatestDecodeToDisplayDelta; - s32 compositionStartTime; + s32 compositionStartTime; s32 compositionEndTime; } GF_CompositionToDecodeBox; @@ -1197,8 +1198,8 @@ typedef struct u32 aux_info_type; u32 aux_info_type_parameter; - u8 default_sample_info_size; - u32 sample_count; + u8 default_sample_info_size; + u32 sample_count; u8 *sample_info_size; } GF_SampleAuxiliaryInfoSizeBox; @@ -1209,7 +1210,7 @@ typedef struct u32 aux_info_type; u32 aux_info_type_parameter; - u8 default_sample_info_size; + u8 default_sample_info_size; u32 entry_count; //1 or stco / trun count u32 *offsets; u64 *offsets_large; @@ -1339,7 +1340,7 @@ typedef struct s8 vertical_justification; /*ARGB*/ u32 back_color; - GF_BoxRecord default_box; + GF_BoxRecord default_box; GF_StyleRecord default_style; GF_FontTableBox *font_table; } GF_Tx3gSampleEntryBox; @@ -1351,7 +1352,7 @@ typedef struct u32 displayFlags; u32 textJustification; char background_color[6], foreground_color[6]; - GF_BoxRecord default_box; + GF_BoxRecord default_box; u16 fontNumber; u16 fontFace; char reserved1[8]; @@ -1371,7 +1372,7 @@ typedef struct { GF_ISOM_BOX u16 startcharoffset; - u16 endcharoffset; + u16 endcharoffset; } GF_TextHighlightBox; typedef struct @@ -1465,7 +1466,7 @@ typedef struct #endif } GF_ItemExtentEntry; -typedef struct +typedef struct { u16 item_ID; u16 data_reference_index; @@ -1481,12 +1482,12 @@ typedef struct { GF_ISOM_FULL_BOX u8 offset_size; - u8 length_size; + u8 length_size; u8 base_offset_size; GF_List *location_entries; } GF_ItemLocationBox; -typedef struct +typedef struct { GF_ISOM_FULL_BOX u16 item_ID; @@ -1498,7 +1499,7 @@ typedef struct GF_List *protection_information; } GF_ItemProtectionBox; -typedef struct +typedef struct { GF_ISOM_FULL_BOX u16 item_ID; @@ -1586,7 +1587,7 @@ typedef struct typedef struct __tag_meta_box { GF_ISOM_FULL_BOX - GF_HandlerBox *handler; + GF_HandlerBox *handler; GF_PrimaryItemBox *primary_resource; GF_DataInformationBox *file_locations; GF_ItemLocationBox *item_locations; @@ -1708,7 +1709,7 @@ typedef struct /*when data caching is on*/ u32 DataCache; - GF_TFBaseMediaDecodeTimeBox *tfdt; + GF_TFBaseMediaDecodeTimeBox *tfdt; u64 moof_start_in_bs; } GF_TrackFragmentBox; @@ -1822,7 +1823,7 @@ typedef struct typedef struct { GF_ISOM_BOX - u32 TimeOffset; + u32 TimeOffset; } GF_TimeOffHintEntryBox; typedef struct @@ -2166,7 +2167,7 @@ typedef struct GF_ISOM_FULL_BOX u32 grouping_type; u32 grouping_type_parameter; - + u32 entry_count; GF_SampleGroupEntry *sample_entries; @@ -2178,32 +2179,33 @@ typedef struct u32 grouping_type; u32 default_length; + u32 default_description_index; GF_List *group_descriptions; } GF_SampleGroupDescriptionBox; /*default entry */ typedef struct { - u32 length; - u8 *data; + u32 length; + u8 *data; } GF_DefaultSampleGroupDescriptionEntry; /*VisualRandomAccessEntry - 'rap ' type*/ typedef struct { - u8 num_leading_samples_known; - u8 num_leading_samples; + u8 num_leading_samples_known; + u8 num_leading_samples; } GF_VisualRandomAccessEntry; /*RollRecoveryEntry - 'roll' type*/ typedef struct { - s16 roll_distance; + s16 roll_distance; } GF_RollRecoveryEntry; -/* +/* CENC stuff */ @@ -2211,7 +2213,7 @@ typedef struct typedef struct { u32 IsEncrypted; - u8 IV_size; + u8 IV_size; bin128 KID; } GF_CENCSampleEncryptionGroupEntry; @@ -2231,7 +2233,7 @@ typedef struct __cenc_tenc_box GF_ISOM_FULL_BOX u32 IsEncrypted; - u8 IV_size; + u8 IV_size; bin128 KID; } GF_TrackEncryptionBox; @@ -2239,10 +2241,10 @@ typedef struct __piff_tenc_box { GF_ISOM_UUID_BOX u8 version; - u32 flags; + u32 flags; u32 AlgorithmID; - u8 IV_size; + u8 IV_size; bin128 KID; } GF_PIFFTrackEncryptionBox; @@ -2250,7 +2252,7 @@ typedef struct { GF_ISOM_UUID_BOX u8 version; - u32 flags; + u32 flags; bin128 SystemID; u32 private_data_size; @@ -2262,7 +2264,7 @@ typedef struct __piff_sample_enc_box { GF_ISOM_UUID_BOX u8 version; - u32 flags; + u32 flags; GF_List *samp_aux_info; u64 bs_offset; @@ -2288,7 +2290,7 @@ typedef struct __sample_encryption_box { GF_ISOM_UUID_BOX u8 version; - u32 flags; + u32 flags; GF_List *samp_aux_info; u64 bs_offset; @@ -2363,7 +2365,7 @@ typedef struct __adobe_drm_key_management_system_box } GF_AdobeDRMKeyManagementSystemBox; -typedef struct +typedef struct { GF_ISOM_FULL_BOX u32 refTrackID; @@ -2412,7 +2414,7 @@ typedef struct __tag_data_map GF_ISOM_BASE_DATA_HANDLER } GF_DataMap; -typedef struct +typedef struct { GF_ISOM_BASE_DATA_HANDLER FILE *stream; @@ -2424,7 +2426,7 @@ typedef struct } GF_FileDataMap; /*file mapping handler. used if supported, only on read mode for complete files (not in file download)*/ -typedef struct +typedef struct { GF_ISOM_BASE_DATA_HANDLER char *name; @@ -2456,7 +2458,7 @@ u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, char *buffer, u32 bufferLen #ifndef GPAC_DISABLE_ISOM_WRITE u64 gf_isom_datamap_get_offset(GF_DataMap *map); GF_Err gf_isom_datamap_add_data(GF_DataMap *ptr, char *data, u32 dataSize); -#endif +#endif void gf_isom_datamap_flush(GF_DataMap *map); @@ -2587,7 +2589,7 @@ GF_Err GetESD(GF_MovieBox *moov, u32 trackID, u32 StreamDescIndex, GF_ESD **outE GF_Err GetESDForTime(GF_MovieBox *moov, u32 trackID, u64 CTS, GF_ESD **outESD); GF_Err Media_GetSampleDesc(GF_MediaBox *mdia, u32 SampleDescIndex, GF_SampleEntryBox **out_entry, u32 *dataRefIndex); GF_Err Media_GetSampleDescIndex(GF_MediaBox *mdia, u64 DTS, u32 *sampleDescIndex); -/*get esd for given sample desc - +/*get esd for given sample desc - @true_desc_only: if true doesn't emulate desc and returns native ESD, otherwise emulates if needed/possible (TimedText) and return a hard copy of the desc */ @@ -2752,6 +2754,8 @@ void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox void gf_isom_cenc_merge_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, u32 offset, u32 len); Bool gf_isom_cenc_has_saiz_saio(GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf); +void gf_isom_parse_trif_info(const char *data, u32 size, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h); + #ifndef GPAC_DISABLE_ISOM_HINTING /* @@ -2877,8 +2881,8 @@ u32 gf_isom_hint_pck_length(u8 HintType, GF_HintPacket *ptr); /*the RTP packet*/ typedef struct { - GF_ISOM_BASE_PACKET - + GF_ISOM_BASE_PACKET + /*RTP Header*/ u8 P_bit; u8 X_bit; @@ -2907,11 +2911,11 @@ u32 gf_isom_hint_rtp_length(GF_RTPPacket *ptr); #endif -struct _3gpp_text_sample +struct _3gpp_text_sample { char *text; u32 len; - + GF_TextStyleBox *styles; /*at most one of these*/ GF_TextHighlightColorBox *highlight_color; @@ -3418,7 +3422,7 @@ GF_Err mehd_Read(GF_Box *s, GF_BitStream *bs); GF_Err mehd_Write(GF_Box *s, GF_BitStream *bs); GF_Err mehd_Size(GF_Box *s); -#endif +#endif /*avc ext*/ GF_Box *avcc_New(); @@ -3547,21 +3551,21 @@ GF_Err wvtt_dump(GF_Box *a, FILE * trace); GF_Err gf_isom_update_webvtt_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, const char *config); GF_ISOSample *gf_isom_webvtt_to_sample(void *samp); -typedef struct +typedef struct { - GF_ISOM_BOX - char *string; + GF_ISOM_BOX + char *string; } GF_StringBox; typedef struct { - GF_ISOM_SAMPLE_ENTRY_FIELDS - GF_StringBox *config; + GF_ISOM_SAMPLE_ENTRY_FIELDS + GF_StringBox *config; } GF_WebVTTSampleEntryBox; typedef struct { - GF_ISOM_SAMPLE_ENTRY_FIELDS + GF_ISOM_SAMPLE_ENTRY_FIELDS char *xmlnamespace; // not optional char *schema_location; // optional char *auxiliary_mime_types; // optional @@ -3570,11 +3574,11 @@ typedef struct typedef struct { - GF_ISOM_SAMPLE_ENTRY_FIELDS + GF_ISOM_SAMPLE_ENTRY_FIELDS char *content_encoding; //optional char *mime_type; //not optional GF_MPEG4BitRateBox *bitrate; // optional - GF_StringBox *config; + GF_StringBox *config; } GF_SimpleTextSampleEntryBox; GF_List *gf_webvtt_parse_cues_from_data(const char *data, u32 dataLength, u64 start); @@ -3600,6 +3604,7 @@ GF_Box *encs_New(); void meta_del(GF_Box *s); void xml_del(GF_Box *s); void bxml_del(GF_Box *s); +void iloc_entry_del(GF_ItemLocationEntry *location); void iloc_del(GF_Box *s); void pitm_del(GF_Box *s); void ipro_del(GF_Box *s); diff --git a/include/gpac/internal/laser_dev.h b/include/gpac/internal/laser_dev.h index c8094ea..86d3aab 100644 --- a/include/gpac/internal/laser_dev.h +++ b/include/gpac/internal/laser_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ #ifndef GPAC_DISABLE_LASER /*per_stream config support*/ -typedef struct +typedef struct { GF_LASERConfig cfg; u16 ESID; @@ -142,7 +142,7 @@ enum LSR_EVT_textinput = 30, LSR_EVT_unload = 31, LSR_EVT_zoom = 32 -}; +}; u32 dom_to_lsr_key(u32 dom_k); @@ -179,18 +179,18 @@ enum LSR_PATH_COM_C = 0, LSR_PATH_COM_H, LSR_PATH_COM_L, - LSR_PATH_COM_M, - LSR_PATH_COM_Q, - LSR_PATH_COM_S, - LSR_PATH_COM_T, - LSR_PATH_COM_V, - LSR_PATH_COM_Z, - LSR_PATH_COM_c, - LSR_PATH_COM_h, - LSR_PATH_COM_l, - LSR_PATH_COM_m, - LSR_PATH_COM_q, - LSR_PATH_COM_s, + LSR_PATH_COM_M, + LSR_PATH_COM_Q, + LSR_PATH_COM_S, + LSR_PATH_COM_T, + LSR_PATH_COM_V, + LSR_PATH_COM_Z, + LSR_PATH_COM_c, + LSR_PATH_COM_h, + LSR_PATH_COM_l, + LSR_PATH_COM_m, + LSR_PATH_COM_q, + LSR_PATH_COM_s, LSR_PATH_COM_t, LSR_PATH_COM_v, LSR_PATH_COM_z diff --git a/include/gpac/internal/m3u8.h b/include/gpac/internal/m3u8.h index e1cce16..5fbb103 100644 --- a/include/gpac/internal/m3u8.h +++ b/include/gpac/internal/m3u8.h @@ -62,20 +62,20 @@ * Basic Stream structure */ typedef struct s_stream { - u8 i; + u8 i; } Stream; /** * The playlist contains a list of elements to play */ typedef struct s_playList { - int currentMediaSequence; - int target_duration; - int mediaSequenceMin; - int mediaSequenceMax; - int computed_duration; - char is_ended; - GF_List * elements; + int currentMediaSequence; + int target_duration; + int mediaSequenceMin; + int mediaSequenceMax; + int computed_duration; + char is_ended; + GF_List * elements; } Playlist; typedef enum e_playlistElementType { TYPE_PLAYLIST, TYPE_STREAM, TYPE_UNKNOWN} PlaylistElementType; @@ -84,23 +84,24 @@ typedef enum e_playlistElementType { TYPE_PLAYLIST, TYPE_STREAM, TYPE_UNKNOWN} * The Structure containing the playlist element */ typedef struct s_playlistElement { - int durationInfo; - u64 byteRangeStart, byteRangeEnd; - int bandwidth, width, height; - char * title; + int durationInfo; + u64 byteRangeStart, byteRangeEnd; + int bandwidth, width, height; + char * title; char * codecs; - char * url; - PlaylistElementType elementType; - union { Playlist playlist; - Stream stream; - } element; + char * url; + PlaylistElementType elementType; + union { + Playlist playlist; + Stream stream; + } element; } PlaylistElement; typedef struct s_program { - int programId; - GF_List * bitrates; - int currentBitrateIndex; + int programId; + GF_List * bitrates; + int currentBitrateIndex; int computed_duration; } Program; @@ -109,9 +110,9 @@ typedef struct s_program { * The root playlist, can contains several PlaylistElements structures */ typedef struct s_variantPlaylist { - GF_List * programs; - int currentProgram; - Bool playlistNeedsRefresh; + GF_List * programs; + int currentProgram; + Bool playlistNeedsRefresh; } VariantPlaylist; /** @@ -144,7 +145,7 @@ GF_Err program_del(Program * program); /** * Creates an Playlist element. * This element can be either a playlist of a stream according to first parameter. - * \return NULL if element could not be created. Elements will be deleted recusively + * \return NULL if element could not be created. Elements will be deleted recusively */ PlaylistElement * playlist_element_new(PlaylistElementType elementType, const char * url, const char * title, const char *codecs, int durationInfo, u64 byteRangeStart, u64 byteRangeEnd); diff --git a/include/gpac/internal/media_dev.h b/include/gpac/internal/media_dev.h index a472411..2f2a6e3 100644 --- a/include/gpac/internal/media_dev.h +++ b/include/gpac/internal/media_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -46,7 +46,7 @@ GF_Err gf_import_message(GF_MediaImporter *import, GF_Err e, char *format, ...); u32 gf_latm_get_value(GF_BitStream *bs); -#define GF_SVC_SSPS_ID_SHIFT 16 +#define GF_SVC_SSPS_ID_SHIFT 16 /*returns 0 if not a start code, or size of start code (3 or 4 bytes). If start code, bitstream is positionned AFTER start code*/ @@ -78,7 +78,7 @@ enum AVC_SPS_EXT_DECLARED = 1<<4, }; -typedef struct +typedef struct { u8 cpb_removal_delay_length_minus1; u8 dpb_output_delay_length_minus1; @@ -86,7 +86,7 @@ typedef struct /*to be eventually completed by other hrd members*/ } AVC_HRD; -typedef struct +typedef struct { s32 timing_info_present_flag; u32 num_units_in_tick; @@ -123,7 +123,7 @@ typedef struct u32 width, height; AVC_VUI vui; - + /*used to discard repeated SPSs - 0: not parsed, 1 parsed, 2 sent*/ u32 state; @@ -131,7 +131,7 @@ typedef struct u32 nb_ei, nb_ep, nb_eb; } AVC_SPS; -typedef struct +typedef struct { s32 id; /* used to compare pps when storing SVC PSS */ s32 sps_id; @@ -143,7 +143,7 @@ typedef struct } AVC_PPS; -typedef struct +typedef struct { s32 idr_pic_flag; u8 temporal_id, priority_id, dependency_id, quality_id; @@ -167,7 +167,7 @@ typedef struct } AVCSliceInfo; -typedef struct +typedef struct { u32 frame_cnt; u8 exact_match_flag; @@ -176,13 +176,13 @@ typedef struct u8 valid; } AVCSeiRecoveryPoint; -typedef struct +typedef struct { u8 pic_struct; /*to be eventually completed by other pic_timing members*/ } AVCSeiPicTiming; -typedef struct +typedef struct { AVCSeiRecoveryPoint recovery_point; AVCSeiPicTiming pic_timing; @@ -257,7 +257,7 @@ typedef struct Bool general_non_packed_constraint_flag; Bool general_frame_only_constraint_flag; u64 general_reserved_44bits; - + HEVC_SublayerPTL sub_ptl[8]; } HEVC_ProfileTierLevel; @@ -270,7 +270,7 @@ typedef struct typedef struct { - s32 id, vps_id; + s32 id, vps_id; /*used to discard repeated SPSs - 0: not parsed, 1 parsed, 2 stored*/ u32 state; u32 crc; @@ -306,8 +306,8 @@ typedef struct typedef struct { - s32 id; - u32 sps_id; + s32 id; + u32 sps_id; /*used to discard repeated SPSs - 0: not parsed, 1 parsed, 2 stored*/ u32 state; u32 crc; @@ -324,11 +324,11 @@ typedef struct typedef struct RepFormat { - u32 chroma_format_idc; - u32 pic_width_luma_samples; - u32 pic_height_luma_samples; - u32 bit_depth_luma; - u32 bit_depth_chroma; + u32 chroma_format_idc; + u32 pic_width_luma_samples; + u32 pic_height_luma_samples; + u32 bit_depth_luma; + u32 bit_depth_chroma; u8 separate_colour_plane_flag; } HEVC_RepFormat; @@ -342,7 +342,7 @@ typedef struct #define MAX_SHVC_LAYERS 4 typedef struct { - s32 id; + s32 id; /*used to discard repeated SPSs - 0: not parsed, 1 parsed, 2 stored*/ u32 state; u32 crc; @@ -355,9 +355,9 @@ typedef struct u32 scalability_mask[16]; - u32 dimension_id[MAX_SHVC_LAYERS][16]; - u32 layer_id_in_nuh[MAX_SHVC_LAYERS]; - u32 layer_id_in_vps[MAX_SHVC_LAYERS]; + u32 dimension_id[MAX_SHVC_LAYERS][16]; + u32 layer_id_in_nuh[MAX_SHVC_LAYERS]; + u32 layer_id_in_vps[MAX_SHVC_LAYERS]; u32 profile_level_tier_idx[MAX_SHVC_LAYERS]; @@ -365,7 +365,7 @@ typedef struct u32 num_rep_formats; HEVC_RepFormat rep_formats[16]; - u32 rep_format_idx[16]; + u32 rep_format_idx[16]; } HEVC_VPS; typedef struct @@ -437,21 +437,21 @@ typedef struct #if !defined(GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_STREAMING) -GP_RTPPacketizer *gf_rtp_packetizer_create_and_init_from_file(GF_ISOFile *file, - u32 TrackNum, - void *cbk_obj, - void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), - void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), - void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), - void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head), - u32 Path_MTU, - u32 max_ptime, - u32 default_rtp_rate, - u32 flags, - u8 PayloadID, - Bool copy_media, - u32 InterleaveGroupID, - u8 InterleaveGroupPriority); +GP_RTPPacketizer *gf_rtp_packetizer_create_and_init_from_file(GF_ISOFile *file, + u32 TrackNum, + void *cbk_obj, + void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), + void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), + void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), + void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head), + u32 Path_MTU, + u32 max_ptime, + u32 default_rtp_rate, + u32 flags, + u8 PayloadID, + Bool copy_media, + u32 InterleaveGroupID, + u8 InterleaveGroupPriority); void gf_media_format_ttxt_sdp(GP_RTPPacketizer *builder, char *payload_name, char *sdpLine, GF_ISOFile *file, u32 track); @@ -475,10 +475,10 @@ typedef struct _webvtt_parser GF_WebVTTParser; typedef struct _webvtt_sample GF_WebVTTSample; GF_WebVTTParser *gf_webvtt_parser_new(); -GF_Err gf_webvtt_parser_init(GF_WebVTTParser *parser, const char *input_file, - void *user, GF_Err (*report_message)(void *, GF_Err, char *, const char *), - void (*on_sample_parsed)(void *, GF_WebVTTSample *), - void (*on_header_parsed)(void *, const char *)); +GF_Err gf_webvtt_parser_init(GF_WebVTTParser *parser, const char *input_file, + void *user, GF_Err (*report_message)(void *, GF_Err, char *, const char *), + void (*on_sample_parsed)(void *, GF_WebVTTSample *), + void (*on_header_parsed)(void *, const char *)); GF_Err gf_webvtt_parser_parse(GF_WebVTTParser *parser, u32 duration); u64 gf_webvtt_parser_last_duration(GF_WebVTTParser *parser); void gf_webvtt_parser_del(GF_WebVTTParser *parser); diff --git a/include/gpac/internal/mesh.h b/include/gpac/internal/mesh.h index 7c35e03..6212b4c 100644 --- a/include/gpac/internal/mesh.h +++ b/include/gpac/internal/mesh.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -73,7 +73,7 @@ typedef struct typedef struct { /*position*/ - SFVec3f pos; + SFVec3f pos; /*texture coordinates*/ SFVec2f texcoords; /*normal*/ @@ -118,19 +118,19 @@ enum enum { /*vertex.color is used*/ - MESH_HAS_COLOR = 1, + MESH_HAS_COLOR = 1, /*mesh is 2D: normal should be ignored and a global normal set to 0 0 1*/ - MESH_IS_2D = 1<<1, + MESH_IS_2D = 1<<1, /*mesh has no texture coords - disable texturing*/ - MESH_NO_TEXTURE = 1<<2, + MESH_NO_TEXTURE = 1<<2, /*mesh faces are clockwise*/ - MESH_IS_CW = 1<<3, + MESH_IS_CW = 1<<3, /*mesh is solid (back face culling + 2 side lighting)*/ - MESH_IS_SOLID = 1<<4, + MESH_IS_SOLID = 1<<4, /*mesh has smoothed normals*/ - MESH_IS_SMOOTHED = 1<<5, + MESH_IS_SMOOTHED = 1<<5, /*vertex.color is used with alpha channel*/ - MESH_HAS_ALPHA = 1<<6, + MESH_HAS_ALPHA = 1<<6, }; /*indexes as used in glDrawElements - note that integer type is not allowed with oglES*/ @@ -224,7 +224,7 @@ void mesh_get_outline(GF_Mesh *mesh, GF_Path *path); begin_cap, end_cap: indicates whether start/end faces shall be added @spine_ori: orientation at spine points @spine_scale: scale at spine points -@tx_along_spine: if set, texture coords are generated so that the texture is mapped on the side, +@tx_along_spine: if set, texture coords are generated so that the texture is mapped on the side, otherwise the same txcoords are used all along the extrusion spine */ void mesh_extrude_path(GF_Mesh *mesh, GF_Path *path, MFVec3f *thespine, Fixed creaseAngle, Bool begin_cap, Bool end_cap, MFRotation *spine_ori, MFVec2f *spine_scale, Bool tx_along_spine); @@ -256,13 +256,13 @@ typedef struct __AABBNode enum { /*AABB tree is not used*/ - AABB_NONE, + AABB_NONE, /*longest box axis is used to divide an AABB node*/ - AABB_LONGEST, + AABB_LONGEST, /*keep tree well-balanced*/ AABB_BALANCED, /*best axis is use: test largest, then middle, then smallest axis*/ - AABB_BEST_AXIS, + AABB_BEST_AXIS, /*use variance to pick axis*/ AABB_SPLATTER, /*fifty/fifty point split*/ @@ -277,7 +277,7 @@ void gf_mesh_build_aabbtree(GF_Mesh *mesh); */ /*appends given face (and tesselate if needed) to the mesh. Only vertices are used in the face -indices are ignored. +indices are ignored. partially implemented on ogl-ES*/ void TesselateFaceMesh(GF_Mesh *mesh, GF_Mesh *face); @@ -291,7 +291,7 @@ for_outline: void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style); /*appends given face (and tesselate if needed) to the mesh. Only vertices are used in the face -indices are ignored. +indices are ignored. Same as TesselateFaceMesh + faces info to determine where are the polygons in the face - used by extruder only */ void TesselateFaceMeshComplex(GF_Mesh *dest, GF_Mesh *orig, u32 nbFaces, u32 *ptsPerFaces); diff --git a/include/gpac/internal/mpd.h b/include/gpac/internal/mpd.h index 3eb9848..1f6403e 100644 --- a/include/gpac/internal/mpd.h +++ b/include/gpac/internal/mpd.h @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #ifndef _MPD_H_ #define _MPD_H_ @@ -30,64 +30,66 @@ #include /*TODO*/ -typedef struct +typedef struct { u32 dummy; } GF_MPD_Metrics; /*TODO*/ -typedef struct +typedef struct { u32 dummy; } GF_MPD_ContentComponent; /*TODO*/ -typedef struct +typedef struct { char *scheme_id_uri; /*MANDATORY*/ char *value; + char *id; } GF_MPD_Descriptor; /*TODO*/ -typedef struct +typedef struct { u32 dummy; } GF_MPD_Subset; -typedef struct +typedef struct { u64 start_time; u32 duration; /*MANDATORY*/ + //may be -1 (FIXME this needs further testing) u32 repeat_count; } GF_MPD_SegmentTimelineEntry; -typedef struct +typedef struct { GF_List *entries; } GF_MPD_SegmentTimeline; -typedef struct +typedef struct { u64 start_range, end_range; } GF_MPD_ByteRange; -typedef struct +typedef struct { - char *URL; - char *service_location; - GF_MPD_ByteRange *byte_range; + char *URL; + char *service_location; + GF_MPD_ByteRange *byte_range; } GF_MPD_BaseURL; -typedef struct +typedef struct { - char *sourceURL; - GF_MPD_ByteRange *byte_range; + char *sourceURL; + GF_MPD_ByteRange *byte_range; } GF_MPD_URL; -typedef struct +typedef struct { - u32 num, den; + u32 num, den; } GF_MPD_Fractional; @@ -100,9 +102,9 @@ typedef struct Double availability_time_offset; \ GF_MPD_URL *initialization_segment; \ GF_MPD_URL *representation_index; \ + - -typedef struct +typedef struct { GF_MPD_SEGMENT_BASE } GF_MPD_SegmentBase; @@ -114,13 +116,13 @@ typedef struct u32 start_number; \ GF_MPD_SegmentTimeline *segment_timeline; \ GF_MPD_URL *bitstream_switching_url; \ - -typedef struct + +typedef struct { GF_MPD_MULTIPLE_SEGMENT_BASE } GF_MPD_MultipleSegmentBase; -typedef struct +typedef struct { char *media; GF_MPD_ByteRange *media_range; @@ -129,9 +131,9 @@ typedef struct u64 duration; } GF_MPD_SegmentURL; -typedef struct +typedef struct { - GF_MPD_MULTIPLE_SEGMENT_BASE + GF_MPD_MULTIPLE_SEGMENT_BASE /*list of segments - can be NULL if no segment*/ GF_List *segment_URLs; @@ -139,9 +141,9 @@ typedef struct Bool xlink_actuate_on_load; } GF_MPD_SegmentList; -typedef struct +typedef struct { - GF_MPD_MULTIPLE_SEGMENT_BASE + GF_MPD_MULTIPLE_SEGMENT_BASE char *media; char *index; char *initialization; @@ -177,7 +179,8 @@ typedef enum GF_List *frame_packing; \ GF_List *audio_channels; \ GF_List *content_protection; \ - + GF_List *essential_properties; \ + GF_List *supplemental_properties; \ typedef struct { GF_MPD_COMMON_ATTRIBUTES_ELEMENTS @@ -185,7 +188,7 @@ typedef struct { typedef struct { GF_MPD_COMMON_ATTRIBUTES_ELEMENTS - + u32 level; char *dependecy_level; u32 bandwidth; /*MANDATORY if level set*/ @@ -203,11 +206,11 @@ typedef struct { GF_MPD_COMMON_ATTRIBUTES_ELEMENTS char *id; /*MANDATORY*/ - u32 bandwidth; /*MANDATORY*/ + u32 bandwidth; /*MANDATORY*/ u32 quality_ranking; char *dependency_id; char *media_stream_structure_id; - + GF_List *base_URLs; GF_MPD_SegmentBase *segment_base; GF_MPD_SegmentList *segment_list; @@ -223,8 +226,8 @@ typedef struct { } GF_MPD_Representation; -typedef struct -{ +typedef struct +{ GF_MPD_COMMON_ATTRIBUTES_ELEMENTS u32 id; @@ -265,10 +268,10 @@ typedef struct } GF_MPD_AdaptationSet; -typedef struct +typedef struct { char *ID; - u32 start; /* expressed in ms, relative to the start of the MPD */ + u32 start; /* expressed in ms, relative to the start of the MPD */ u32 duration; /* expressed in ms*/ Bool bitstream_switching; @@ -283,31 +286,31 @@ typedef struct Bool xlink_actuate_on_load; } GF_MPD_Period; -typedef struct +typedef struct { - char *lang; - char *title; - char *source; - char *copyright; - char *more_info_url; + char *lang; + char *title; + char *source; + char *copyright; + char *more_info_url; } GF_MPD_ProgramInfo; typedef enum { - GF_MPD_TYPE_STATIC, - GF_MPD_TYPE_DYNAMIC, + GF_MPD_TYPE_STATIC, + GF_MPD_TYPE_DYNAMIC, } GF_MPD_Type; typedef struct { - char *ID; - char *profiles; /*MANDATORY*/ - GF_MPD_Type type; + char *ID; + char *profiles; /*MANDATORY*/ + GF_MPD_Type type; u64 availabilityStartTime; /* expressed in milliseconds */ /*MANDATORY if type=dynamic*/ - u64 availabilityEndTime;/* expressed in milliseconds */ - u64 publishTime;/* expressed in milliseconds */ - u32 media_presentation_duration; /* expressed in milliseconds */ /*MANDATORY if type=static*/ - u32 minimum_update_period; /* expressed in milliseconds */ - u32 min_buffer_time; /* expressed in milliseconds */ /*MANDATORY*/ + u64 availabilityEndTime;/* expressed in milliseconds */ + u64 publishTime;/* expressed in milliseconds */ + u32 media_presentation_duration; /* expressed in milliseconds */ /*MANDATORY if type=static*/ + u32 minimum_update_period; /* expressed in milliseconds */ + u32 min_buffer_time; /* expressed in milliseconds */ /*MANDATORY*/ u32 time_shift_buffer_depth; /* expressed in milliseconds */ u32 suggested_presentaton_delay; /* expressed in milliseconds */ @@ -324,7 +327,7 @@ typedef struct { /*list of Metrics */ GF_List *metrics; /*list of GF_MPD_Period */ - GF_List *periods; + GF_List *periods; /*set during parsing*/ const char *xml_namespace; diff --git a/include/gpac/internal/odf_dev.h b/include/gpac/internal/odf_dev.h index 15c7f0e..e3455b4 100644 --- a/include/gpac/internal/odf_dev.h +++ b/include/gpac/internal/odf_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/internal/odf_parse_common.h b/include/gpac/internal/odf_parse_common.h index 80c0f8c..73eb0ad 100644 --- a/include/gpac/internal/odf_parse_common.h +++ b/include/gpac/internal/odf_parse_common.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -28,11 +28,11 @@ #define _GF_OD_PARSE_COMMON_H_ #include -#define GET_U8(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = (u8) d; } else { ret += sscanf(val, "%u", &d); if (ret) field = (u8) d; } } +#define GET_U8(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = (u8) d; } else { ret += sscanf(val, "%u", &d); if (ret) field = (u8) d; } } #define GET_U16(field) { u16 d; if (strstr(val, "0x")) { ret += sscanf(val, "%hx", &d); if (ret) field = d; } else { ret += sscanf(val, "%hu", &d); if (ret) field = d; } } -#define GET_S16(field) { s16 d; if (strstr(val, "0x")) { ret += sscanf(val, "%hx", (u16*)&d); if (ret) field = d; } else { ret += sscanf(val, "%hd", &d); if (ret) field = d; } } -#define GET_U32(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = d; } else { ret += sscanf(val, "%ud", &d); if (ret) field = d; } } -#define GET_S32(field) { s32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", (u32*)&d); if (ret) field = d; } else { ret += sscanf(val, "%d", &d); if (ret) field = d; } } +#define GET_S16(field) { s16 d; if (strstr(val, "0x")) { ret += sscanf(val, "%hx", (u16*)&d); if (ret) field = d; } else { ret += sscanf(val, "%hd", &d); if (ret) field = d; } } +#define GET_U32(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = d; } else { ret += sscanf(val, "%ud", &d); if (ret) field = d; } } +#define GET_S32(field) { s32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", (u32*)&d); if (ret) field = d; } else { ret += sscanf(val, "%d", &d); if (ret) field = d; } } #define GET_BOOL(field) { ret = 1; field = (!stricmp(val, "true") || !stricmp(val, "1")) ? 1 : 0; } #define GET_U64(field) { u64 d; if (strstr(val, "0x")) { ret += sscanf(val, LLX, &d); if (ret) field = d; } else { ret += sscanf(val, LLU, &d); if (ret) field = d; } } diff --git a/include/gpac/internal/ogg.h b/include/gpac/internal/ogg.h index 36aa3b8..c87e1cd 100644 --- a/include/gpac/internal/ogg.h +++ b/include/gpac/internal/ogg.h @@ -35,57 +35,57 @@ extern "C" { #endif typedef struct { - s32 endbyte; - s32 endbit; + s32 endbyte; + s32 endbit; - unsigned char *buffer; - unsigned char *ptr; - s32 storage; + unsigned char *buffer; + unsigned char *ptr; + s32 storage; } oggpack_buffer; /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ typedef struct { - unsigned char *header; - s32 header_len; - unsigned char *body; - s32 body_len; + unsigned char *header; + s32 header_len; + unsigned char *body; + s32 body_len; } ogg_page; /* ogg_stream_state contains the current encode/decode state of a logical Ogg bitstream **********************************************************/ typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - s32 body_storage; /* storage elements allocated */ - s32 body_fill; /* elements stored; fill mark */ - s32 body_returned; /* elements of fill returned */ + unsigned char *body_data; /* bytes from packet bodies */ + s32 body_storage; /* storage elements allocated */ + s32 body_fill; /* elements stored; fill mark */ + s32 body_returned; /* elements of fill returned */ - s32 *lacing_vals; /* The values that will go to the segment table */ - s64 *granule_vals; /* granulepos values for headers. Not compact + s32 *lacing_vals; /* The values that will go to the segment table */ + s64 *granule_vals; /* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */ - s32 lacing_storage; - s32 lacing_fill; - s32 lacing_packet; - s32 lacing_returned; + s32 lacing_storage; + s32 lacing_fill; + s32 lacing_packet; + s32 lacing_returned; - unsigned char header[282]; /* working space for header encode */ - s32 header_fill; + unsigned char header[282]; /* working space for header encode */ + s32 header_fill; - s32 e_o_s; /* set when we have buffered the last packet in the + s32 e_o_s; /* set when we have buffered the last packet in the logical bitstream */ - s32 b_o_s; /* set after we've written the initial page + s32 b_o_s; /* set after we've written the initial page of a logical bitstream */ - s32 serialno; - s32 pageno; - s64 packetno; /* sequence number for decode; the framing + s32 serialno; + s32 pageno; + s64 packetno; /* sequence number for decode; the framing knows where there's a hole in the data, but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */ - s64 granulepos; + s64 granulepos; } ogg_stream_state; @@ -93,14 +93,14 @@ typedef struct { to a single raw Ogg/Vorbis packet *************************************/ typedef struct { - unsigned char *packet; - s32 bytes; - s32 b_o_s; - s32 e_o_s; - - s64 granulepos; - - s64 packetno; /* sequence number for decode; the framing + unsigned char *packet; + s32 bytes; + s32 b_o_s; + s32 e_o_s; + + s64 granulepos; + + s64 packetno; /* sequence number for decode; the framing knows where there's a hole in the data, but we need coupling so that the codec (which is in a seperate abstraction @@ -108,14 +108,14 @@ typedef struct { } ogg_packet; typedef struct { - unsigned char *data; - s32 storage; - s32 fill; - s32 returned; - - s32 unsynced; - s32 headerbytes; - s32 bodybytes; + unsigned char *data; + s32 storage; + s32 fill; + s32 returned; + + s32 unsynced; + s32 headerbytes; + s32 bodybytes; } ogg_sync_state; diff --git a/include/gpac/internal/reedsolomon.h b/include/gpac/internal/reedsolomon.h index 891450c..5d6f2ab 100644 --- a/include/gpac/internal/reedsolomon.h +++ b/include/gpac/internal/reedsolomon.h @@ -1,15 +1,15 @@ /* Reed Solomon Coding for glyphs - * + * * (c) Henry Minsky (hqm@ua.com), Universal Access Inc. (1991-1996) - * + * * */ /**************************************************************** - + Below is NPAR, the only compile-time parameter you should have to modify. - + It is the number of parity bytes which will be appended to your data to create a codeword. @@ -61,7 +61,7 @@ extern int gexp[]; extern int glog[]; void init_galois_tables (void); -int ginv(int elt); +int ginv(int elt); int gmult(int a, int b); diff --git a/include/gpac/internal/scenegraph_dev.h b/include/gpac/internal/scenegraph_dev.h index ae9f6d5..9d380c8 100644 --- a/include/gpac/internal/scenegraph_dev.h +++ b/include/gpac/internal/scenegraph_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -130,7 +130,7 @@ typedef struct _nodepriv /*list of all parent nodes (needed to invalidate parent tree)*/ GF_ParentList *parents; - + /*holder for all interactive stuff - THIS IS DYNAMICALLY CREATED*/ struct _node_interactive_ext *interact; } NodePriv; @@ -154,7 +154,7 @@ typedef struct u32 xmlns_id; } GF_XMLNS; -struct __tag_scene_graph +struct __tag_scene_graph { /*used to discriminate between node and scenegraph*/ u64 __reserved_null; @@ -215,7 +215,7 @@ struct __tag_scene_graph /*all routes available*/ GF_List *Routes; - /*when a proto is instanciated it creates its own scene graph. BIFS/VRML specify that the namespace is the same + /*when a proto is instanciated it creates its own scene graph. BIFS/VRML specify that the namespace is the same (eg cannot reuse a NodeID or route name/ID), but this could be done differently by some other stds if NULL this is the main scenegraph*/ struct _proto_instance *pOwningProto; @@ -226,7 +226,7 @@ struct __tag_scene_graph GF_List *unregistered_protos; /*routes to be activated (cascade model). This is used at the top-level graph only (eg - proto routes use that too, ecept ISed fields). It is the app responsability to + proto routes use that too, ecept ISed fields). It is the app responsability to correctly connect or browse scene graphs connected through Inline*/ GF_List *routes_to_activate; @@ -284,10 +284,10 @@ struct __tag_scene_graph /* Note about reference counter - A DOM document (<=> scenegraph) may be created through javascript, and the JS object having created the + A DOM document (<=> scenegraph) may be created through javascript, and the JS object having created the document may be destroyed while the document is still in use. Moreover with XMLHttpRequest, the "associated" doc is re-created at each request, but the script may still refer to the original document. - Since the document doesn't have a fixed owner, a reference counter is use and the scenegraph is kept alive + Since the document doesn't have a fixed owner, a reference counter is use and the scenegraph is kept alive until the last object using it is destroyed. If this counter is set to 0 when creating DOM Elements/..., this means the scenegraph is hold by an external @@ -436,7 +436,7 @@ struct _protofield /*default field value*/ void *def_value; - + GF_Node *def_sfnode_value; GF_ChildNodeItem *def_mfnode_value; @@ -463,7 +463,7 @@ GF_Err gf_bifs_proto_field_set_aq_info(GF_ProtoFieldInterface *field, u32 QP_Typ /*proto field instance. since it is useless to duplicate all coding info, names and the like we seperate proto declaration and proto instanciation*/ -typedef struct +typedef struct { u8 EventType; u8 FieldType; @@ -549,7 +549,7 @@ void gf_sg_proto_instanciate(GF_ProtoInstance *proto_node); u32 gf_sg_proto_get_root_tag(GF_Proto *proto); -/*to call when a proto field has been modified (at creation or through commands, modifications through events +/*to call when a proto field has been modified (at creation or through commands, modifications through events are handled internally). node can be the proto instance or a node from the proto code this will call NodeChanged if needed, forward to proto/node or trigger any route if needed*/ @@ -590,7 +590,7 @@ typedef struct __xlink_attrip_ptrs { XMLRI *href; SVG_ContentType *type; SVG_String *title; - XMLRI *arcrole; + XMLRI *arcrole; XMLRI *role; SVG_String *show; SVG_String *actuate; @@ -617,7 +617,7 @@ typedef struct __smil_sync_attrip_ptrs { } SMILSyncAttributesPointers; typedef struct __smil_anim_attrip_ptrs { - SMIL_AttributeName *attributeName; + SMIL_AttributeName *attributeName; SMIL_AttributeType *attributeType; SMIL_AnimateValue *to, *by, *from; SMIL_AnimateValues *values; @@ -663,7 +663,7 @@ Bool gf_svg_resolve_smil_times(GF_Node *anim, void *event_base_element, GF_List /* SMIL Timing structures */ -/* status of an SMIL timed element */ +/* status of an SMIL timed element */ enum { SMIL_STATUS_WAITING_TO_BEGIN = 0, SMIL_STATUS_ACTIVE, @@ -680,11 +680,11 @@ typedef struct { Bool min_active; /* negative values mean indefinite */ - Double begin, - end, - simple_duration, - active_duration, - repeat_duration; + Double begin, + end, + simple_duration, + active_duration, + repeat_duration; } SMIL_Interval; @@ -745,15 +745,15 @@ s32 gf_smil_timing_notify_time(SMIL_Timing_RTI *rti, Double scene_time); /* This structure is used per animated attribute, it contains: - all the animations applying to the same attribute, - - the specified value before any inheritance has been applied nor any animation started + - the specified value before any inheritance has been applied nor any animation started (as specified in the SVG document), - the presentation value passed from one animation to the next one, at the same level in the tree - a boolean indicating if the animated attribute is in fact a property - + and if the attribute is a property: - a pointer to presentation value passed from the previous level in the tree - a pointer to the value of the color property (for handling of 'currentColor'), from previous level in the tree - - the location of the attribute in the elt structure when it was created + - the location of the attribute in the elt structure when it was created (used for fast comparison of SVG properties when animating from/to/by/values/... inherited values) */ typedef struct { @@ -771,8 +771,8 @@ typedef struct { Bool dirty_parents; } SMIL_AttributeAnimations; -/* This structure is per animation element, - it holds the result of the animation and +/* This structure is per animation element, + it holds the result of the animation and some info to make animation computation faster */ typedef struct _smil_anim_rti { SMIL_AttributeAnimations *owner; @@ -794,16 +794,16 @@ typedef struct _smil_anim_rti { /* last value of the animation, used in accumulation phase */ /* normally the far pointer in the last specified value is a pointer to a real attribute value, - and there's no need to allocate a new value. Except if the last specified value is the last + and there's no need to allocate a new value. Except if the last specified value is the last point in a path (animateMotion) in which case we allocate a matrix as last spec value, which we need to delete (see animate-elem-202-t.svg). This is signaled if rai->path is not NULL*/ GF_FieldInfo last_specified_value; - /* temporary value needed when the type of + /* temporary value needed when the type of the key values is different from the target attribute type */ GF_FieldInfo tmp_value; - /* the number of values in animations should be constant (unless updated with LASeR commands) + /* the number of values in animations should be constant (unless updated with LASeR commands) we can store them to avoid computing them at each cycle */ u32 values_count; u32 key_times_count; @@ -811,8 +811,8 @@ typedef struct _smil_anim_rti { u32 key_splines_count; - /* In change detection mode, we test previous animation parameters to determine - if a new evaluation of the animation will produce a different result. + /* In change detection mode, we test previous animation parameters to determine + if a new evaluation of the animation will produce a different result. The result of these test is stored in interpolated_value_changed */ Bool change_detection_mode; Bool interpolated_value_changed; @@ -854,7 +854,7 @@ void gf_smil_timing_resume(GF_Node *node); Script node */ -typedef struct +typedef struct { //extra script fields GF_List *fields; @@ -942,7 +942,7 @@ void gf_sg_js_call_gc(struct JSContext *c); #endif /* GPAC_HAS_SPIDERMONKEY */ -typedef struct +typedef struct { GF_FieldInfo field; GF_Node *owner; @@ -957,7 +957,7 @@ typedef struct GF_ChildNodeItem *temp_list; /*when not owned by a node*/ void *field_ptr; - + /*cpontext in which the field was created*/ struct JSContext *js_ctx; Bool is_rooted; @@ -973,7 +973,7 @@ struct _node_js_binding #ifndef GPAC_DISABLE_SVG -typedef struct __tag_svg_script_ctx +typedef struct __tag_svg_script_ctx { Bool (*script_execute)(struct __tag_scene_graph *sg, char *utf8_script, GF_DOM_Event *event); Bool (*handler_execute)(GF_Node *n, GF_DOM_Event *event, GF_Node *observer, char *utf8_script); @@ -989,7 +989,7 @@ typedef struct __tag_svg_script_ctx Bool force_gc; } GF_SVGJS; -typedef struct __tag_html_media_script_ctx +typedef struct __tag_html_media_script_ctx { /*global script context for the scene*/ struct JSContext *js_ctx; @@ -1047,13 +1047,13 @@ enum GF_DOM_EXC_VALIDATION_ERR = 16, GF_DOM_EXC_TYPE_MISMATCH_ERR = 17, GF_DOM_EXC_SECURITY_ERR = 18, - GF_DOM_EXC_NETWORK_ERR = 19, - GF_DOM_EXC_ABORT_ERR = 20, - GF_DOM_EXC_URL_MISMATCH_ERR = 21, - GF_DOM_EXC_QUOTA_EXCEEDED_ERR = 22, - GF_DOM_EXC_TIMEOUT_ERR = 23, - GF_DOM_EXC_INVALID_NODE_TYPE_ERR = 24, - GF_DOM_EXC_DATA_CLONE_ERR = 25, + GF_DOM_EXC_NETWORK_ERR = 19, + GF_DOM_EXC_ABORT_ERR = 20, + GF_DOM_EXC_URL_MISMATCH_ERR = 21, + GF_DOM_EXC_QUOTA_EXCEEDED_ERR = 22, + GF_DOM_EXC_TIMEOUT_ERR = 23, + GF_DOM_EXC_INVALID_NODE_TYPE_ERR = 24, + GF_DOM_EXC_DATA_CLONE_ERR = 25, }; @@ -1079,7 +1079,7 @@ SVGAttribute *gf_node_create_attribute_from_datatype(u32 data_type, u32 attribut GF_Err gf_node_get_attribute_by_name(GF_Node *node, char *name, u32 xmlns_code, Bool create_if_not_found, Bool set_default, GF_FieldInfo *field); void *gf_svg_get_property_pointer_from_tag(SVGPropertiesPointers *output_property_context, u32 prop_tag); void *gf_svg_get_property_pointer(SVG_Element *elt, void *input_attribute, - SVGPropertiesPointers *output_property_context); + SVGPropertiesPointers *output_property_context); Bool gf_svg_is_property(GF_Node *node, GF_FieldInfo *target_attribute); @@ -1093,7 +1093,7 @@ GF_Err gf_node_activate(GF_Node *node); through DOM*/ GF_Err gf_node_deactivate(GF_Node *node); -/*post a listener to be added - this is only used by LASeR:activate and DOM.addEventListener. This +/*post a listener to be added - this is only used by LASeR:activate and DOM.addEventListener. This is to ensure that when a node is processing an event creating a new listener on this node, this listener will not be triggered*/ void gf_sg_listener_post_add(GF_Node *obs, GF_Node *listener); diff --git a/include/gpac/internal/smjs_api.h b/include/gpac/internal/smjs_api.h index 9e29f28..bf9c649 100644 --- a/include/gpac/internal/smjs_api.h +++ b/include/gpac/internal/smjs_api.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -99,7 +99,7 @@ typedef double jsdouble; #if defined(USE_FFDEV_17) -#define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSHandleObject __hobj, JSHandleId __hid, JSBool strict, JSMutableHandleValue __vp) +#define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSHandleObject __hobj, JSHandleId __hid, JSBool strict, JSMutableHandleValue __vp) #define SMJS_FUNC_PROP_SET(func_name) SMJS_DECL_FUNC_PROP_SET(func_name) { JSObject *obj = *(__hobj._); jsid id = *(__hid._); jsval *vp = __vp._; #define SMJS_FUNC_PROP_SET_NOVP(func_name) SMJS_DECL_FUNC_PROP_SET(func_name) { JSObject *obj = *(__hobj._); jsid id = *(__hid._); @@ -117,7 +117,7 @@ typedef double jsdouble; #ifdef USE_FFDEV_15 -#define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSHandleObject __hobj, JSHandleId __hid, JSBool strict, jsval *vp) +#define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSHandleObject __hobj, JSHandleId __hid, JSBool strict, jsval *vp) #define SMJS_FUNC_PROP_SET(func_name) SMJS_DECL_FUNC_PROP_SET(func_name) { JSObject *obj = *(__hobj._); jsid id = *(__hid._); #define SMJS_DECL_FUNC_PROP_GET(func_name) JSBool func_name(JSContext *c, JSHandleObject __hobj, JSHandleId __hid, jsval *vp) #define SMJS_FUNC_PROP_GET(func_name) SMJS_DECL_FUNC_PROP_GET( func_name ) { JSObject *obj = *(__hobj._); jsid id = *(__hid._); @@ -128,8 +128,8 @@ typedef double jsdouble; #define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsid id, JSBool strict, jsval *vp) #define SMJS_FUNC_PROP_SET(func_name) SMJS_DECL_FUNC_PROP_SET( func_name) { -#define SMJS_DECL_FUNC_PROP_GET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsid id, jsval *vp) -#define SMJS_FUNC_PROP_GET(func_name) SMJS_DECL_FUNC_PROP_GET(func_name) { +#define SMJS_DECL_FUNC_PROP_GET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsid id, jsval *vp) +#define SMJS_FUNC_PROP_GET(func_name) SMJS_DECL_FUNC_PROP_GET(func_name) { #define SMJS_CALL_PROP_STUB() JS_PropertyStub(c, obj, id, vp) #define DECL_FINALIZE(func_name) void func_name(JSContext *c, JSObject *obj) { @@ -160,7 +160,7 @@ typedef double jsdouble; #define SMJS_OBJ_CONSTRUCTOR(__classp) \ JSObject *obj = JS_NEW_OBJ_FOR_CONS(c, __classp, argsvp); \ SMJS_SET_RVAL(OBJECT_TO_JSVAL(obj));\ - + #define JS_GetFunctionName(_v) (JS_GetFunctionId(_v)!=NULL) ? SMJS_CHARS_FROM_STRING(c, JS_GetFunctionId(_v)) : NULL #define SMJS_ID_IS_STRING JSID_IS_STRING @@ -217,8 +217,8 @@ typedef double jsdouble; #define SMJS_DECL_FUNC_PROP_SET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsval id, jsval *vp) #define SMJS_FUNC_PROP_SET(func_name) SMJS_DECL_FUNC_PROP_SET(func_name) { #define SMJS_FUNC_PROP_SET_NOVP SMJS_FUNC_PROP_SET -#define SMJS_DECL_FUNC_PROP_GET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsval id, jsval *vp) -#define SMJS_FUNC_PROP_GET(func_name) SMJS_DECL_FUNC_PROP_GET( func_name) { +#define SMJS_DECL_FUNC_PROP_GET(func_name) JSBool func_name(JSContext *c, JSObject *obj, jsval id, jsval *vp) +#define SMJS_FUNC_PROP_GET(func_name) SMJS_DECL_FUNC_PROP_GET( func_name) { #define DECL_FINALIZE(func_name) void func_name(JSContext *c, JSObject *obj) { #define SMJS_CALL_PROP_STUB() JS_PropertyStub(c, obj, id, vp) @@ -230,7 +230,7 @@ typedef double jsdouble; #define SMJS_FUNCTION(__name) __name(JSContext *c, JSObject *obj, uintN argc, jsval *argv, jsval *rval) #define SMJS_FUNCTION_EXT(__name, __ext) __name(JSContext *c, JSObject *obj, uintN argc, jsval *argv, jsval *rval, __ext) #define SMJS_ARGS -#define SMJS_OBJ +#define SMJS_OBJ #define SMJS_OBJ_CONSTRUCTOR(__classp) #define SMJS_GET_RVAL rval #define SMJS_SET_RVAL(__rval) *rval = __rval @@ -285,7 +285,7 @@ JSBool gf_sg_js_has_instance(JSContext *c, JSObject *obj, jsval val, JSBool *vp) the_class._class.hasInstance = gf_sg_js_has_instance; -#define JS_MAKE_DOUBLE(__c, __double) DOUBLE_TO_JSVAL(JS_NewDouble(__c, __double) ) +#define JS_MAKE_DOUBLE(__c, __double) DOUBLE_TO_JSVAL(JS_NewDouble(__c, __double) ) #define GF_JS_InstanceOf(_a, _b, __class, _d) JS_InstanceOf(_a, _b, & (__class)->_class, NULL) diff --git a/include/gpac/internal/swf_dev.h b/include/gpac/internal/swf_dev.h index 9976bd6..cbd4e20 100644 --- a/include/gpac/internal/swf_dev.h +++ b/include/gpac/internal/swf_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -79,13 +79,13 @@ struct SWFReader Bool has_interact, no_as; Bool empty_frame; - /*copy of the swf import flags*/ + /*copy of the swf import flags*/ u32 flags; /*bit reader*/ GF_BitStream *bs; - GF_Err ioerr; - + GF_Err ioerr; + u32 current_frame; /*current tag*/ @@ -103,7 +103,7 @@ struct SWFReader /*the one and only sound stream for current timeline*/ SWFSound *sound_stream; - /*when creating sprites: + /*when creating sprites: 1- all BIFS AUs in sprites are random access 2- depth is ignored in Sprites */ @@ -124,7 +124,7 @@ struct SWFReader GF_Err (*show_frame)(SWFReader *read); /*checks if display list is large enough - returns 1 if yes, 0 otherwise (and allocate space)*/ - Bool (*allocate_depth)(SWFReader *read, u32 depth); + Bool (*allocate_depth)(SWFReader *read, u32 depth); GF_Err (*place_obj)(SWFReader *read, u32 depth, u32 ID, u32 prev_id, u32 type, GF_Matrix2D *mat, GF_ColorMatrix *cmat, GF_Matrix2D *prev_mat, GF_ColorMatrix *prev_cmat); GF_Err (*remove_obj)(SWFReader *read, u32 depth, u32 ID); @@ -132,12 +132,12 @@ struct SWFReader GF_Err (*define_sprite)(SWFReader *read, u32 nb_frames); GF_Err (*define_text)(SWFReader *read, SWFText *text); GF_Err (*define_edit_text)(SWFReader *read, SWFEditText *text); - /*@button is NULL to signal end of button declaration, non-null otherwise. "action" callback will be + /*@button is NULL to signal end of button declaration, non-null otherwise. "action" callback will be called inbetween*/ GF_Err (*define_button)(SWFReader *read, SWF_Button *button); GF_Err (*setup_image)(SWFReader *read, u32 ID, char *fileName); - /*called whenever a sound is found. For soundstreams, called twice, once on the header (declaration), + /*called whenever a sound is found. For soundstreams, called twice, once on the header (declaration), and one on the first soundstream block for offset signaling*/ GF_Err (*setup_sound)(SWFReader *read, SWFSound *snd, Bool soundstream_first_block); GF_Err (*start_sound)(SWFReader *read, SWFSound *snd, Bool stop); @@ -177,14 +177,14 @@ struct SWFReader /* */ - /* SVG conversion state */ + /* SVG conversion state */ Bool print_stream_header; Bool print_frame_header; u32 frame_header_offset; char *svg_data; u32 svg_data_size; Bool svg_shape_started; - /* end of SVG conversion state */ + /* end of SVG conversion state */ /* MP4 user */ void *user; @@ -205,9 +205,9 @@ SWFReader *gf_swf_reader_new(const char *path, const char *filename); GF_Err gf_swf_read_header(SWFReader *read); void gf_swf_reader_del(SWFReader *read); -GF_Err gf_swf_reader_set_user_mode(SWFReader *read, void *user, - GF_Err (*add_sample)(void *user, const char *data, u32 length, u64 timestamp, Bool isRap), - GF_Err (*add_header)(void *user, const char *data, u32 length)); +GF_Err gf_swf_reader_set_user_mode(SWFReader *read, void *user, + GF_Err (*add_sample)(void *user, const char *data, u32 length, u64 timestamp, Bool isRap), + GF_Err (*add_header)(void *user, const char *data, u32 length)); typedef struct { @@ -241,7 +241,7 @@ typedef struct SWFPath *path; } SWFShapeRec; -struct SWFShape +struct SWFShape { GF_List *fill_left, *fill_right, *lines; u32 ID; @@ -295,7 +295,7 @@ struct SWFText GF_List *text; }; -struct SWFEditText +struct SWFEditText { u32 ID; char *init_value; @@ -336,7 +336,7 @@ struct SWFSound Bool is_setup; }; -typedef struct +typedef struct { /*interaction states*/ Bool hitTest, down, over, up; @@ -348,7 +348,7 @@ typedef struct } SWF_ButtonRecord; -struct SWF_Button +struct SWF_Button { u32 count; SWF_ButtonRecord buttons[40]; diff --git a/include/gpac/internal/terminal_dev.h b/include/gpac/internal/terminal_dev.h index 34f080d..abf0dcd 100644 --- a/include/gpac/internal/terminal_dev.h +++ b/include/gpac/internal/terminal_dev.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -55,6 +55,15 @@ struct _net_service /*the module handling this service - must be declared first to typecast with GF_DownlaodSession upon deletion*/ GF_InputService *ifce; + //function table of service + void (*fn_connect_ack) (GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); + void (*fn_disconnect_ack) (GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); + void (*fn_command) (GF_ClientService *service, GF_NetworkCommand *com, GF_Err response); + void (*fn_data_packet) (GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status); + void (*fn_add_media) (GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_check); + + + /*the terminal*/ struct _tag_terminal *term; /*service url*/ @@ -67,7 +76,7 @@ struct _net_service u32 nb_ch_users; /*number of attached remote ODM (OD URLs)*/ u32 nb_odm_users; - + /*clock objects. Kept at service level since ESID namespace is the service one*/ GF_List *Clocks; /*all downloaders objects used in this service*/ @@ -136,7 +145,7 @@ struct _scene GF_List *resources; /*list of GF_MediaObject - these are the links betwwen scene nodes (URL, xlink:href) and media resources. - We need this link because of MPEG-4 Systems, where an OD (media resource) can be removed or replaced by the server + We need this link because of MPEG-4 Systems, where an OD (media resource) can be removed or replaced by the server without the scene being modified*/ GF_List *scene_objects; @@ -163,7 +172,7 @@ struct _scene /*callback to call to dispatch SVG MediaEvent - this is a pointer to function only because of linking issues with static libgpac (avoids depending on SpiderMonkey and OpenGL32 if not needed)*/ - void (*on_media_event)(GF_Scene *scene, u32 type); + void (*on_media_event)(GF_Scene *scene, u32 type); /*duration of inline scene*/ u64 duration; @@ -309,7 +318,7 @@ enum }; /*URI relocators are used for containers like zip or ISO FF with file items. The relocator -is in charge of translating the URI, potentially extracting the associated resource and sending +is in charge of translating the URI, potentially extracting the associated resource and sending back the new (local or not) URI. Only the interface is defined, URI translators are free to derive from them relocate a URI - if NULL is returned, this relocator is not concerned with the URI @@ -318,17 +327,17 @@ otherwise returns the translated URI #define GF_TERM_URI_RELOCATOR \ Bool (*relocate_uri)(void *__self, const char *parent_uri, const char *uri, char *out_relocated_uri, char *out_localized_uri); \ - + typedef struct __gf_uri_relocator GF_URIRelocator; -struct __gf_uri_relocator -{ - GF_TERM_URI_RELOCATOR +struct __gf_uri_relocator +{ + GF_TERM_URI_RELOCATOR }; -typedef struct -{ - GF_TERM_URI_RELOCATOR +typedef struct +{ + GF_TERM_URI_RELOCATOR GF_Terminal *term; char *szAbsRelocatedPath; } GF_TermLocales; @@ -347,7 +356,7 @@ struct _tag_terminal { u32 flags; - /*callback to user application*/ + /*callback to user application*/ GF_User *user; /*scene compositor*/ struct __tag_compositor *compositor; @@ -388,7 +397,7 @@ struct _tag_terminal GF_List *x3d_sensors; /*all input stream decoders*/ GF_List *input_streams; - + /*options (cf config doc)*/ Bool enable_cache; /*data timeout for network buffering in ms - if no data is received within this timeout @@ -400,7 +409,7 @@ struct _tag_terminal u32 reload_state; char *reload_url; - /*special list used by nodes needing a call to RenderNode but not in the traverese scene graph (VRML/MPEG-4 protos only). + /*special list used by nodes needing a call to RenderNode but not in the traverese scene graph (VRML/MPEG-4 protos only). For these nodes, the traverse effect passed will be NULL. This is only used by InputSensor node at the moment*/ GF_List *nodes_pending; @@ -426,6 +435,8 @@ struct _tag_terminal /*bench mode type: 0-none 1: regular 2- systems layers only: all decoders inputs are discarded*/ u32 bench_mode; + + u32 prefered_audio_codec_oti; }; @@ -476,7 +487,7 @@ void gf_term_invalidate_compositor(GF_Terminal *term); /*callbacks for scene graph library so that all related ESM nodes are properly instanciated*/ void gf_term_node_callback(void *_is, u32 type, GF_Node *node, void *param); -/*add/rem node requiring a call to render without being present in traversed graph (VRML/MPEG-4 protos). +/*add/rem node requiring a call to render without being present in traversed graph (VRML/MPEG-4 protos). For these nodes, the traverse effect passed will be NULL.*/ void gf_term_queue_node_traverse(GF_Terminal *term, GF_Node *node); void gf_term_unqueue_node_traverse(GF_Terminal *term, GF_Node *node); @@ -496,9 +507,9 @@ GF_Err gf_term_remove_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef /*clock*/ -struct _object_clock +struct _object_clock { - u16 clockID; + u16 clockID; GF_Terminal *term; GF_Mutex *mx; /*no_time_ctrl : set if ANY stream running on this clock has no time control capabilities - this avoids applying @@ -516,6 +527,7 @@ struct _object_clock u32 data_timeout; Bool probe_ocr; u32 last_TS_rendered; + u32 service_id; }; /*destroys clock*/ @@ -579,7 +591,7 @@ enum }; /*data channel (elementary stream)*/ -struct _es_channel +struct _es_channel { /*service this channel belongs to*/ GF_ClientService *service; @@ -597,6 +609,7 @@ struct _es_channel struct _decoding_buffer * AU_buffer_first, * AU_buffer_last; /*static decoding buffer for pull mode*/ struct _decoding_buffer * AU_buffer_pull; + char *pull_reaggregated_buffer; /*channel buffer flag*/ Bool BufferOn; /*min level to trigger buffering on, max to trigger it off. */ @@ -636,13 +649,13 @@ struct _es_channel buffering - note this doesn't affect the clock, it is still paused if buffering*/ Bool first_au_fetched; - /* used in Carousel, to skip packets until the end of AU */ + /* used in Carousel, to skip packets until the end of AU */ u8 carousel_type; Bool skip_carousel_au; /*discard clock initialization when dispatching pending AU - this is used when TS discontinuities / MPA_TIME happen*/ Bool skip_time_check_for_pending; - + /* TimeStamp to Media Time mapping*/ /*TS (in TSResolution) corresponding to the SeedTime of the decoder. Delivered by net, otherwise 0*/ u64 seed_ts; @@ -661,14 +674,14 @@ struct _es_channel /*duration of last received AU if any, 0 if not known (most of the time)*/ u32 au_duration; - /*A channel with this flag set considers each incoming packet as a complete AU and assigns timestamps + /*A channel with this flag set considers each incoming packet as a complete AU and assigns timestamps upon reception matching the reception time, then dispatching it into the decoding buffer (only tested with audi video). This flag is turned on by setting esd->slconfig->predefined to 'SLPredef_SkipSL' */ Bool skip_sl; /*indicates that decoding can be called directly when receiving a complete AU on this channel - This is used by systems streams in non-seekable (eg broadcast/multicast, MPEG-2 TS multiplexes) to - make sure resources are setup as fast as possible. If the AU is too early, it will be kept in the + This is used by systems streams in non-seekable (eg broadcast/multicast, MPEG-2 TS multiplexes) to + make sure resources are setup as fast as possible. If the AU is too early, it will be kept in the decoding buffer*/ Bool dispatch_after_db; @@ -749,11 +762,11 @@ enum /*stop: the decoder is playing*/ GF_ESM_CODEC_PLAY = 1, /*End Of Stream: when the base layer signals it's done, this triggers media-specific - handling of the CB. + handling of the CB. For video, the output is kept alive, For audio, the output is reseted (don't want audio loop ;)*/ GF_ESM_CODEC_EOS = 2, /*pause: the decoder is stopped but the CB is kept intact - THIS IS NOT USED AS A CODEC STATUS, but only for signaling that the CB shouldn't + THIS IS NOT USED AS A CODEC STATUS, but only for signaling that the CB shouldn't be reseted - the real status of a "paused" decoder is STOP*/ GF_ESM_CODEC_PAUSE = 3, /*Buffer: transition state: the decoder runs (fetch data/decode) but the clock @@ -774,14 +787,14 @@ enum GF_ESM_CODEC_IS_RAW_MEDIA = 1<<3, }; -struct _generic_codec +struct _generic_codec { - /*codec type (streamType from base layer)*/ - u32 type; + /*codec type (streamType and OTI from base layer)*/ + u32 type, oti; u32 flags; /*decoder module interface */ GF_BaseDecoder *decio; - + /*base process routine*/ GF_Err (*process)(GF_Codec *codec, u32 TimeAvailable); @@ -829,8 +842,10 @@ struct _generic_codec u32 nb_droped; /*we detect if the same image is sent again and again to the decoder (using last_unit_signature)*/ u32 nb_repeted_frames; + /*we detect if the same image is sent again and again to the decoder (using last_unit_signature)*/ + u32 min_frame_dur; - /*for CTS reconstruction (channels not using SL): we cannot just update timing at each frame, not precise enough + /*for CTS reconstruction (channels not using SL): we cannot just update timing at each frame, not precise enough since we use ms and not microsec TSs*/ u32 cur_audio_bytes, cur_video_frames; @@ -847,7 +862,7 @@ GF_Err gf_codec_process(GF_Codec *codec, u32 TimeAvailable); GF_Err gf_codec_get_capability(GF_Codec *codec, GF_CodecCapability *cap); GF_Err gf_codec_set_capability(GF_Codec *codec, GF_CodecCapability cap); void gf_codec_set_status(GF_Codec *codec, u32 Status); -/*returns a new codec using an existing loaded decoder - only used by private scene to handle != timelines, for +/*returns a new codec using an existing loaded decoder - only used by private scene to handle != timelines, for instance when loading a BT with an animation stream*/ GF_Codec *gf_codec_use_codec(GF_Codec *codec, GF_ObjectManager *odm); @@ -878,7 +893,7 @@ enum /*flag set if object has been deleted*/ GF_ODM_DESTROYED = (1<<9), /*dynamic flags*/ - + /*flag set if associated subscene must be regenerated*/ GF_ODM_REGENERATE_SCENE = (1<<10), @@ -935,10 +950,10 @@ struct _od_manager /*PLs*/ u8 Audio_PL, Graphics_PL, OD_PL, Scene_PL, Visual_PL; - + /*interface with scene rendering*/ struct _mediaobj *mo; - + /*number of channels with connection not yet acknowledge*/ u32 pending_channels; u32 state; @@ -995,14 +1010,14 @@ void gf_odm_set_duration(GF_ObjectManager *odm, GF_Channel *, u64 stream_duratio /*signals end of stream on channels*/ void gf_odm_on_eos(GF_ObjectManager *odm, GF_Channel *); /*start Object streams and queue object for network PLAY -media_queue_state: 0: object was not in media queue and must be queued - 1: object is already in media queue +media_queue_state: 0: object was not in media queue and must be queued + 1: object is already in media queue 2: object shall not be queued bu started directly */ void gf_odm_start(GF_ObjectManager *odm, u32 media_queue_state); /*stop OD streams*/ void gf_odm_stop(GF_ObjectManager *odm, Bool force_close); -/*send PLAY request to network - needed to properly handle multiplexed inputs +/*send PLAY request to network - needed to properly handle multiplexed inputs ONLY called by service handler (media manager thread)*/ void gf_odm_play(GF_ObjectManager *odm); @@ -1025,7 +1040,9 @@ Bool gf_odm_lock_mo(struct _mediaobj *mo); void gf_odm_signal_eos(GF_ObjectManager *odm); -/*GF_MediaObject: link between real object manager and scene. although there is a one-to-one mapping between a +void gf_odm_reset_media_control(GF_ObjectManager *odm, Bool signal_reset); + +/*GF_MediaObject: link between real object manager and scene. although there is a one-to-one mapping between a MediaObject and an ObjectManager, we have to keep them seperated in order to handle OD remove commands which destroy ObjectManagers. */ struct _mediaobj @@ -1065,7 +1082,7 @@ struct _mediaobj used to dispatch HTML5 Media and Media Source Events */ GF_List *evt_targets; /*pointer to the node responsible for the creation of this media object - ONLY used for scene media type (animationStreams) + ONLY used for scene media type (animationStreams) Reset upon creation of the decoder. */ void *node_ptr; @@ -1075,10 +1092,10 @@ GF_MediaObject *gf_mo_new(); /*used for delayed channel setup*/ -typedef struct +typedef struct { struct _generic_codec *dec; - struct _es_channel *ch; + struct _es_channel *ch; } GF_ChannelSetup; /*post-poned channel connect*/ @@ -1103,9 +1120,11 @@ void gf_scene_generate_views(GF_Scene *scene, char *url, char *parent_url); void gf_scene_register_associated_media(GF_Scene *scene, GF_AssociatedContentLocation *addon_info); void gf_scene_notify_associated_media_timeline(GF_Scene *scene, GF_AssociatedContentTiming *addon_time); -u32 gf_scene_adjust_time_for_addon(GF_Scene *scene, u32 clock_time, GF_AddonMedia *addon); +//returns media time in sec for the addon - timestamp_based is set to 1 if no timeline has been found (eg sync is based on direct timestamp comp) +Double gf_scene_adjust_time_for_addon(GF_Scene *scene, u32 clock_time, GF_AddonMedia *addon, Bool *timestamp_based); u64 gf_scene_adjust_timestamp_for_addon(GF_Scene *scene, u64 orig_ts, GF_AddonMedia *addon); void gf_scene_select_scalable_addon(GF_Scene *scene, GF_ObjectManager *odm); +void gf_scene_check_addon_restart(GF_AddonMedia *addon, u64 cts, u64 dts); struct _gf_addon_media { @@ -1117,12 +1136,19 @@ struct _gf_addon_media Double activation_time; Bool enabled; + Bool started; Bool timeline_ready; u32 media_timescale; u64 media_timestamp; u64 media_pts; + //in case we detect a loop, we store the value of the mediatime in the loop until we actually loop the content + u32 past_media_timescale; + u64 past_media_timestamp; + u64 past_media_pts, past_media_pts_scaled; + Bool loop_detected; + //0: not scalable //1: layered coding scalable enhancement (reassembly before the decoder) //2: view enhancement (reassembly after the decoder) @@ -1134,6 +1160,9 @@ GF_Err gf_codec_process_private_media(GF_Codec *codec, u32 TimeAvailable); Bool gf_codec_is_scene_or_image(GF_Codec *codec); +void gf_scene_set_service_id(GF_Scene *scene, u32 service_id); +void gf_scene_toggle_addons(GF_Scene *scene, Bool show_addons); + #ifdef __cplusplus } #endif diff --git a/include/gpac/internal/vobsub.h b/include/gpac/internal/vobsub.h index a723b14..4c3be6e 100644 --- a/include/gpac/internal/vobsub.h +++ b/include/gpac/internal/vobsub.h @@ -10,15 +10,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/ismacryp.h b/include/gpac/ismacryp.h index 4140d2c..b919356 100644 --- a/include/gpac/ismacryp.h +++ b/include/gpac/ismacryp.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -38,7 +38,7 @@ GF_Err gf_ismacryp_gpac_get_info(u32 stream_id, char *drm_file, char *key, char /*loads key and salt for MPEG4IP protected files*/ Bool gf_ismacryp_mpeg4ip_get_info(char *kms_uri, char *key, char *salt); - + enum { /*no selective encryption*/ @@ -89,7 +89,7 @@ typedef struct /*CENC extensions*/ u32 IsEncrypted; - u8 IV_size; + u8 IV_size; bin128 default_KID; u32 KID_count; bin128 *KIDs; @@ -127,13 +127,13 @@ GF_Err gf_adobe_decrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pr GF_Err (*gf_encrypt_track)(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*progress)(void *cbk, u64 done, u64 total), void *cbk); GF_Err (*gf_decrypt_track)(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*progress)(void *cbk, u64 done, u64 total), void *cbk); -/*decrypt a file +/*decrypt a file @drm_file: location of DRM data (cf MP4Box doc). @LogMsg: redirection for message or NULL for default */ GF_Err gf_decrypt_file(GF_ISOFile *mp4file, const char *drm_file); -/*Crypt a the file +/*Crypt a the file @drm_file: location of DRM data. @LogMsg: redirection for message or NULL for default */ diff --git a/include/gpac/iso639.h b/include/gpac/iso639.h index e9301f7..8c1177c 100644 --- a/include/gpac/iso639.h +++ b/include/gpac/iso639.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * - * This file is part of GPAC + * This file is part of GPAC * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -27,12 +27,12 @@ #define _GF_ISO_639_H -/*ISO 639 code names +/*ISO 639 code names - first string is readable english name of the language - second string is 3-char code of language as per ISO/IEC 639-2/T - - third string is 2-char code of language as per ISO/IEC 639-1, and may be empty + - third string is 2-char code of language as per ISO/IEC 639-1, and may be empty */ -static const char *GF_ISO639_Lang[] = +static const char *GF_ISO639_Lang[] = { "Abkhazian","abk","ab", "Achinese","ace","", diff --git a/include/gpac/isomedia.h b/include/gpac/isomedia.h index 33925af..5f8f6a5 100644 --- a/include/gpac/isomedia.h +++ b/include/gpac/isomedia.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -41,24 +41,24 @@ extern "C" { ********************************************************************/ /*Modes for file opening - NOTE 1: All the READ function in this API can be used in EDIT/WRITE mode. + NOTE 1: All the READ function in this API can be used in EDIT/WRITE mode. However, some unexpected errors or values may happen in that case, depending on how much modifications you made (timing, track with 0 samples, ...) - On the other hand, none of the EDIT/WRITE functions will work in + On the other hand, none of the EDIT/WRITE functions will work in READ mode. - NOTE 2: The output structure of a edited file will sometimes be different + NOTE 2: The output structure of a edited file will sometimes be different from the original file, but the media-data and meta-data will be identical. The only change happens in the file media-data container(s) during edition NOTE 3: when editing the file, you MUST set the final name of the modified file to something different. This API doesn't allow file overwriting. */ -enum +enum { /*Opens file for dumping: same as read-only but keeps all movie fragments info untouched*/ GF_ISOM_OPEN_READ_DUMP = 0, /*Opens a file in READ ONLY mode*/ GF_ISOM_OPEN_READ, - /*Opens a file in WRITE ONLY mode. Media Data is captured on the fly. In this mode, + /*Opens a file in WRITE ONLY mode. Media Data is captured on the fly. In this mode, the editing functions are disabled.*/ GF_ISOM_OPEN_WRITE, /*Opens an existing file in EDIT mode*/ @@ -74,7 +74,7 @@ enum { /*FLAT: the MediaData (MPEG4 ESs) is stored at the begining of the file*/ GF_ISOM_STORE_FLAT = 1, - /*STREAMABLE: the MetaData (File Info) is stored at the begining of the file + /*STREAMABLE: the MetaData (File Info) is stored at the begining of the file for fast access during download*/ GF_ISOM_STORE_STREAMABLE, /*INTERLEAVED: Same as STREAMABLE, plus the media data is mixed by chunk of fixed duration*/ @@ -87,7 +87,7 @@ enum }; -/*Some track may depend on other tracks for several reasons. They reference these tracks +/*Some track may depend on other tracks for several reasons. They reference these tracks through the following Reference Types*/ enum { @@ -107,7 +107,8 @@ enum GF_ISOM_REF_CHAP = GF_4CC( 'c', 'h', 'a', 'p' ), /*ref type for the SVC tracks*/ GF_ISOM_REF_BASE = GF_4CC( 's', 'b', 'a', 's' ), - GF_ISOM_REF_SCAL = GF_4CC( 's', 'c', 'a', 'l' ) + GF_ISOM_REF_SCAL = GF_4CC( 's', 'c', 'a', 'l' ), + GF_ISOM_REF_TBAS = GF_4CC( 't', 'b', 'a', 's' ) }; /*Track Edition flag*/ @@ -165,7 +166,7 @@ enum /* Encryption Scheme Type in the SchemeTypeInfoBox */ GF_ISOM_CENC_SCHEME = GF_4CC('c','e','n','c'), - + /* Encryption Scheme Type in the SchemeTypeInfoBox */ GF_ISOM_CBC_SCHEME = GF_4CC('c','b','c','1'), @@ -180,7 +181,7 @@ enum /*reserved, internal use in the lib. Indicates the track complies to MPEG-4 system specification, and the usual OD framework tools may be used*/ GF_ISOM_SUBTYPE_MPEG4 = GF_4CC( 'M', 'P', 'E', 'G' ), - + /*reserved, internal use in the lib. Indicates the track is of GF_ISOM_SUBTYPE_MPEG4 but it is encrypted.*/ GF_ISOM_SUBTYPE_MPEG4_CRYP = GF_4CC( 'E', 'N', 'C', 'M' ), @@ -198,6 +199,7 @@ enum GF_ISOM_SUBTYPE_HEV2 = GF_4CC( 'h', 'e', 'v', '2' ), GF_ISOM_SUBTYPE_SHC1 = GF_4CC( 's', 'h', 'c', '1' ), GF_ISOM_SUBTYPE_SHV1 = GF_4CC( 's', 'h', 'v', '1' ), + GF_ISOM_SUBTYPE_HVT1 = GF_4CC( 'h', 'v', 't', '1' ), /*3GPP(2) extension subtypes*/ GF_ISOM_SUBTYPE_3GP_H263 = GF_4CC( 's', '2', '6', '3' ), @@ -313,9 +315,9 @@ typedef struct s32 CTS_Offset; /*Random Access Point flag: 0: not random access - 1: regular RAP, + 1: regular RAP, 2: sample is a redundant RAP. If set when adding the sample, this will create a sample dependency entry - 3: specific RAP (CRA/BLA in HEVC) + 3: specific RAP (CRA/BLA in HEVC) */ u8 IsRAP; } GF_ISOSample; @@ -325,7 +327,7 @@ typedef struct GF_ISOSample *gf_isom_sample_new(); /*delete a sample. NOTE:the buffer content will be destroyed by default. -if you wish to keep the buffer, set dataLength to 0 in the sample +if you wish to keep the buffer, set dataLength to 0 in the sample before deleting it the pointer is set to NULL after deletion*/ void gf_isom_sample_del(GF_ISOSample **samp); @@ -337,12 +339,12 @@ void gf_isom_sample_del(GF_ISOSample **samp); /*get the last fatal error that occured in the file ANY FUNCTION OF THIS API WON'T BE PROCESSED IF THE FILE HAS AN ERROR Note: some function may return an error while the movie has no error -the last error is a FatalError, and is not always set if a bad +the last error is a FatalError, and is not always set if a bad param is specified...*/ GF_Err gf_isom_last_error(GF_ISOFile *the_file); /*indicates if target file is an IsoMedia file - returns 1 if it is a non-special file, 2 if an init segment, 3 if a media segment, + returns 1 if it is a non-special file, 2 if an init segment, 3 if a media segment, returns 0 otherwise*/ u32 gf_isom_probe_file(const char *fileName); @@ -377,7 +379,7 @@ GF_Err gf_isom_set_output_buffering(GF_ISOFile *movie, u32 size); /*open a movie that can be uncomplete in READ_ONLY mode to use for http streaming & co -NOTE: you must buffer the data to a local file, this mode DOES NOT handle +NOTE: you must buffer the data to a local file, this mode DOES NOT handle http/ftp/... streaming start_range and end_range restricts the media byte range in the URL (used by DASH) @@ -401,9 +403,9 @@ u32 gf_isom_is_fragmented(GF_ISOFile *the_file); /*return 0 if track isn't fragmented, 1 otherwise*/ u32 gf_isom_is_track_fragmented(GF_ISOFile *the_file, u32 TrackID); -/*a file being downloaded may be a fragmented file. In this case only partial info -is available once the file is successfully open (gf_isom_open_progressive), and since there is -no information wrt number fragments (which could actually be generated on the fly +/*a file being downloaded may be a fragmented file. In this case only partial info +is available once the file is successfully open (gf_isom_open_progressive), and since there is +no information wrt number fragments (which could actually be generated on the fly at the sender side), you must call this function on regular bases in order to load newly downloaded fragments. Note this may result in Track/Movie duration changes and SampleCount change too ... @@ -426,7 +428,7 @@ u32 gf_isom_segment_get_track_fragment_count(GF_ISOFile *file, u32 moof_index); /*returns the track ID and get the tfdt of the given track fragment (1-based index) in the indicated movie fragment (1-based index)*/ u32 gf_isom_segment_get_track_fragment_decode_time(GF_ISOFile *file, u32 moof_index, u32 traf_index, u64 *decode_time); -/* Indicates that we want to parse only one moof/mdat at a time +/* Indicates that we want to parse only one moof/mdat at a time in order to proceed to next moof, call gf_isom_reset_data_offset */ void gf_isom_set_single_moof_mode(GF_ISOFile *file, Bool mode); @@ -532,8 +534,8 @@ GF_ISOSample *gf_isom_get_sample(GF_ISOFile *the_file, u32 trackNumber, u32 samp /*same as gf_isom_get_sample but doesn't fetch media data @StreamDescriptionIndex (optional): set to stream description index @data_offset (optional): set to sample start offset in file. - - NOTE: when both StreamDescriptionIndex and data_offset are NULL, only DTS, CTS_Offset and RAP indications are + + NOTE: when both StreamDescriptionIndex and data_offset are NULL, only DTS, CTS_Offset and RAP indications are retrieved (faster) */ GF_ISOSample *gf_isom_get_sample_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 *StreamDescriptionIndex, u64 *data_offset); @@ -569,7 +571,7 @@ u64 gf_isom_get_current_tfdt(GF_ISOFile *the_file, u32 trackNumber); /*return a sample given a desired time in the movie. MovieTime is IN MEDIA TIME SCALE , handles edit list. and set the StreamDescIndex of this sample this index allows to retrieve the stream description if needed (2 media in 1 track) -sample must be set to NULL before calling. +sample must be set to NULL before calling. result Sample is NULL if an error occured if no sample is playing, an empty sample is returned with no data and a DTS set to MovieTime when serching in sync modes @@ -577,8 +579,8 @@ if no sample is playing, the closest sample in the edit time-line is returned wh WARNING: the sample may not be sync even though the sync was requested (depends on the media and the editList) -Note: this function will handle re-timestamping the sample according to the mapping of the media time-line -on the track time-line. The sample TSs (DTS / CTS offset) are expressed in MEDIA TIME SCALE +Note: this function will handle re-timestamping the sample according to the mapping of the media time-line +on the track time-line. The sample TSs (DTS / CTS offset) are expressed in MEDIA TIME SCALE (to match the media stream TS resolution as indicated in media header / SLConfig) sampleNumber is optional and gives the number of the sample in the media @@ -612,7 +614,7 @@ GF_Err gf_isom_get_chapter(GF_ISOFile *the_file, u32 trackNumber, u32 Index, u64 /* return 0 if the media has no sync point info (eg, all samples are RAPs) return 1 if the media has sync points (eg some samples are RAPs) -return 2 if the media has empty sync point info (eg no samples are RAPs). This will likely only happen +return 2 if the media has empty sync point info (eg no samples are RAPs). This will likely only happen in scalable context */ u8 gf_isom_has_sync_points(GF_ISOFile *the_file, u32 trackNumber); @@ -622,8 +624,8 @@ u32 gf_isom_get_sync_point_count(GF_ISOFile *the_file, u32 trackNumber); /* returns 1 if the track uses unsigned compositionTime offsets (B-frames or similar) -returns 2 if the track uses signed compositionTime offsets (B-frames or similar) -returns 0 if the track does not use compositionTime offsets (CTS == DTS) +returns 2 if the track uses signed compositionTime offsets (B-frames or similar) +returns 0 if the track does not use compositionTime offsets (CTS == DTS) */ u32 gf_isom_has_time_offset(GF_ISOFile *the_file, u32 trackNumber); @@ -697,10 +699,10 @@ const char *gf_isom_get_filename(GF_ISOFile *the_file); MP4, MJPEG2000 and QT while indicating compatibilities the brand is one of the above defined code, or any other registered brand -minorVersion is an optional parameter (can be set to NULL) , +minorVersion is an optional parameter (can be set to NULL) , "informative integer for the minor version of the major brand" -AlternateBrandsCount is an optional parameter (can be set to NULL) , - giving the number of compatible brands. +AlternateBrandsCount is an optional parameter (can be set to NULL) , + giving the number of compatible brands. The function will set brand to 0 if no brand indication is found in the file */ @@ -737,7 +739,7 @@ GF_Err gf_isom_get_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptio User Data Manipulation (cf write API too) */ -/* Gets the number of UserDataItems with the same ID / UUID in the desired track or +/* Gets the number of UserDataItems with the same ID / UUID in the desired track or in the movie if trackNumber is set to 0*/ u32 gf_isom_get_user_data_count(GF_ISOFile *the_file, u32 trackNumber, u32 UserDataType, bin128 UUID); /* Gets the UserData for the specified item from the track or the movie if trackNumber is set to 0 @@ -783,14 +785,14 @@ typedef struct /*returns wrapper for unknown entries - you must delete it yourself*/ GF_GenericSampleDescription *gf_isom_get_generic_sample_description(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex); -/*retrieves default values for a track fragment. Each variable is optional and +/*retrieves default values for a track fragment. Each variable is optional and if set will contain the default value for this track samples*/ -GF_Err gf_isom_get_fragment_defaults(GF_ISOFile *the_file, u32 trackNumber, - u32 *defaultDuration, u32 *defaultSize, u32 *defaultDescriptionIndex, - u32 *defaultRandomAccess, u8 *defaultPadding, u16 *defaultDegradationPriority); +GF_Err gf_isom_get_fragment_defaults(GF_ISOFile *the_file, u32 trackNumber, + u32 *defaultDuration, u32 *defaultSize, u32 *defaultDescriptionIndex, + u32 *defaultRandomAccess, u8 *defaultPadding, u16 *defaultDegradationPriority); -/*non standard extensions used for video packets in order to keep AU structure in the file format +/*non standard extensions used for video packets in order to keep AU structure in the file format (no normative tables for that). Info is NOT written to disk. */ /*get number of fragments for a sample */ @@ -858,8 +860,8 @@ GF_Err gf_isom_rewrite_track_dependencies(GF_ISOFile *movie, u32 trackNumber); /*Add samples to a track. Use streamDescriptionIndex to specify the desired stream (if several)*/ GF_Err gf_isom_add_sample(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_ISOSample *sample); -/*Add sync shadow sample to a track. -- There must be a regular sample with the same DTS. +/*Add sync shadow sample to a track. +- There must be a regular sample with the same DTS. - Sync Shadow samples MUST be RAP - Currently, adding sync shadow must be done in order (no sample insertion) */ @@ -888,7 +890,7 @@ GF_Err gf_isom_set_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 re /*removes a track reference*/ GF_Err gf_isom_remove_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferenceIndex); -/*sets track handler name. name is either NULL (reset), a UTF-8 formatted string or a UTF8 file +/*sets track handler name. name is either NULL (reset), a UTF-8 formatted string or a UTF8 file resource in the form "file://path/to/file_utf8" */ GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const char *nameUTF8); @@ -912,7 +914,7 @@ GF_Err gf_isom_remove_sample(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNu /*changes media time scale - if force_rescale is 1, only the media timescale is changed but media times are not updated */ GF_Err gf_isom_set_media_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 new_timescale, Bool force_rescale); -/*set the save file name of the (edited) movie. +/*set the save file name of the (edited) movie. If the movie is edited, the default fileName is avp_#openName) NOTE: you cannot save an edited file under the same name (overwrite not allowed) If the movie is created (WRITE mode), the default filename is #openName*/ @@ -1011,9 +1013,9 @@ GF_Err gf_isom_add_uuid(GF_ISOFile *movie, u32 trackNumber, bin128 UUID, char *d /* Update of the Writing API for IsoMedia Version 2 -*/ +*/ -/*use a compact track version for sample size. This is not usually recommended +/*use a compact track version for sample size. This is not usually recommended except for speech codecs where the track has a lot of small samples compaction is done automatically while writing based on the track's sample sizes*/ GF_Err gf_isom_use_compact_size(GF_ISOFile *the_file, u32 trackNumber, u8 CompactionOn); @@ -1036,7 +1038,7 @@ GF_Err gf_isom_set_sample_padding_bits(GF_ISOFile *the_file, u32 trackNumber, u3 /*since v2 you must specify w/h of video tracks for authoring tools (no decode the video cfg / first sample)*/ GF_Err gf_isom_set_visual_info(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, u32 Width, u32 Height); -/*mainly used for 3GPP text since most ISO-based formats ignore these (except MJ2K) +/*mainly used for 3GPP text since most ISO-based formats ignore these (except MJ2K) all coord values are expressed as 16.16 fixed point floats*/ GF_Err gf_isom_set_track_layout_info(GF_ISOFile *the_file, u32 trackNumber, u32 width, u32 height, s32 translation_x, s32 translation_y, s16 layer); @@ -1094,7 +1096,7 @@ GF_Err gf_isom_set_pl_indication(GF_ISOFile *the_file, u8 PL_Code, u8 ProfileLev /*set the rootOD ID of the movie if you need it. By default, movies are created without root ODs*/ GF_Err gf_isom_set_root_od_id(GF_ISOFile *the_file, u32 OD_ID); -/*set the rootOD URL of the movie if you need it (only needed to create empty file pointing +/*set the rootOD URL of the movie if you need it (only needed to create empty file pointing to external ressource)*/ GF_Err gf_isom_set_root_od_url(GF_ISOFile *the_file, char *url_string); @@ -1110,7 +1112,7 @@ GF_Err gf_isom_add_track_to_root_od(GF_ISOFile *the_file, u32 trackNumber); /*remove a track to the root OD*/ GF_Err gf_isom_remove_track_from_root_od(GF_ISOFile *the_file, u32 trackNumber); -/*Create a new StreamDescription (GF_ESD) in the file. The URL and URN are used to +/*Create a new StreamDescription (GF_ESD) in the file. The URL and URN are used to describe external media, this will creat a data reference for the media*/ GF_Err gf_isom_new_mpeg4_description(GF_ISOFile *the_file, u32 trackNumber, GF_ESD *esd, char *URLname, char *URNname, u32 *outDescriptionIndex); @@ -1124,7 +1126,7 @@ GF_Err gf_isom_add_desc_to_description(GF_ISOFile *the_file, u32 trackNumber, u3 /*Default extensions*/ -/*Create a new unknown StreamDescription in the file. The URL and URN are used to +/*Create a new unknown StreamDescription in the file. The URL and URN are used to describe external media, this will creat a data reference for the media use this to store media not currently supported by the ISO media format */ @@ -1144,7 +1146,7 @@ GF_Err gf_isom_clone_sample_description(GF_ISOFile *the_file, u32 trackNumber, G /*clones all sampleDescription entries in new track, after an optional reset of existing entries*/ GF_Err gf_isom_clone_sample_descriptions(GF_ISOFile *the_file, u32 trackNumber, GF_ISOFile *orig_file, u32 orig_track, Bool reset_existing); -/*special shortcut: clones a track (everything except media data and sample info (DTS? CTS, RAPs, etc...) +/*special shortcut: clones a track (everything except media data and sample info (DTS? CTS, RAPs, etc...) also clones sampleDescriptions @keep_data_ref: if set, external data references are kept, otherwise they are removed (track media data will be self-contained) @dest_track: track number of cloned track*/ @@ -1201,10 +1203,10 @@ u32 gf_isom_get_highest_track_in_scalable_segment(GF_ISOFile *movie, u32 for_bas 2- possibly add some samples in the regular fashion 3- setup track fragments for all track that will be written in a fragmented way (note that you can create/write a track that has no fragmentation at all) - 4- finalize the movie for fragmentation (this will flush all meta-data and + 4- finalize the movie for fragmentation (this will flush all meta-data and any media-data added to disk, ensuring all vital information for the presentation is stored on file and not lost in case of crash/poweroff) - + then 5-6 as often as desired 5- start a new movie fragment 6- add samples to each setup track @@ -1213,11 +1215,11 @@ u32 gf_isom_get_highest_track_in_scalable_segment(GF_ISOFile *movie, u32 for_bas IMPORTANT NOTES: * Movie Fragments can only be used in GF_ISOM_OPEN_WRITE mode (capturing) and no editing functionalities can be used - * the fragmented movie API uses TrackID and not TrackNumber + * the fragmented movie API uses TrackID and not TrackNumber */ /* -setup a track for fragmentation by specifying some default values for +setup a track for fragmentation by specifying some default values for storage efficiency *TrackID: track identifier *DefaultStreamDescriptionIndex: the default description used by samples in this track @@ -1228,23 +1230,23 @@ storage efficiency *DefaultDegradationPriority: default degradation priority for samples in this track */ -GF_Err gf_isom_setup_track_fragment(GF_ISOFile *the_file, u32 TrackID, - u32 DefaultStreamDescriptionIndex, - u32 DefaultSampleDuration, - u32 DefaultSampleSize, - u8 DefaultSampleIsSync, - u8 DefaultSamplePadding, - u16 DefaultDegradationPriority); - -/*change the default parameters of an existing trak fragment - should not be used if samples have +GF_Err gf_isom_setup_track_fragment(GF_ISOFile *the_file, u32 TrackID, + u32 DefaultStreamDescriptionIndex, + u32 DefaultSampleDuration, + u32 DefaultSampleSize, + u8 DefaultSampleIsSync, + u8 DefaultSamplePadding, + u16 DefaultDegradationPriority); + +/*change the default parameters of an existing trak fragment - should not be used if samples have already been added - semantics are the same as in gf_isom_setup_track_fragment*/ -GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID, - u32 DefaultSampleDescriptionIndex, - u32 DefaultSampleDuration, - u32 DefaultSampleSize, - u8 DefaultSampleIsSync, - u8 DefaultSamplePadding, - u16 DefaultDegradationPriority); +GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID, + u32 DefaultSampleDescriptionIndex, + u32 DefaultSampleDuration, + u32 DefaultSampleSize, + u8 DefaultSampleIsSync, + u8 DefaultSamplePadding, + u16 DefaultDegradationPriority); /*flushes data to disk and prepare movie fragmentation @media_segment_type: 0 if no segments, 1 if regular segment, 2 if single segment*/ @@ -1274,7 +1276,7 @@ GF_Err gf_isom_flush_fragments(GF_ISOFile *movie, Bool last_segment); GF_Err gf_isom_set_fragment_reference_time(GF_ISOFile *movie, u32 reference_track_ID, u64 ntp, u64 timestamp); /*writes an empty sidx in the current movie. The SIDX will be forced to have nb_segs entries - nb_segs shall match the number of calls to -gf_isom_close_segment that will follow. This avoids wasting time and disk space moving data around. Once gf_isom_close_segment has then been called nb_segs times, +gf_isom_close_segment that will follow. This avoids wasting time and disk space moving data around. Once gf_isom_close_segment has then been called nb_segs times, the pre-allocated SIDX is destroyed and sucessive calls to gf_isom_close_segment will create their own sidx (unless gf_isom_allocate_sidx is called again). frags_per_sidx, daisy_chain_sidx and frags_per_segment are currently ignored and reserved for future usages where multiple SIDX could be written if not NULL, start_range and end_range will contain the byte range of the SIDX box in the movie*/ @@ -1283,7 +1285,7 @@ GF_Err gf_isom_allocate_sidx(GF_ISOFile *movie, s32 subsegs_per_sidx, Bool daisy enum { /*indicates that the track fragment has no samples but still has a duration - (silence-detection in audio codecs, ...). + (silence-detection in audio codecs, ...). param: indicates duration*/ GF_ISOM_TRAF_EMPTY, /*I-Frame detection: this can reduce file size by detecting I-frames and @@ -1292,7 +1294,7 @@ enum GF_ISOM_TRAF_RANDOM_ACCESS, /*activate data cache on track fragment. This is usefull when writing interleaved media from a live source (typically audio-video), and greatly reduces file size - param: Number of samples (> 1) to cache before disk flushing. You shouldn't try + param: Number of samples (> 1) to cache before disk flushing. You shouldn't try to cache too many samples since this will load your memory. base that on FPS/SR*/ GF_ISOM_TRAF_DATA_CACHE }; @@ -1306,7 +1308,7 @@ GF_Err gf_isom_set_fragment_option(GF_ISOFile *the_file, u32 TrackID, u32 Code, *TrackID: destination track *sample: sample to add -*StreamDescriptionIndex: stream description for this sample. If 0, the default one +*StreamDescriptionIndex: stream description for this sample. If 0, the default one is used *Duration: sample duration. Note: because of the interleaved nature of the meta/media data, the sample duration @@ -1317,9 +1319,9 @@ MUST be provided (in case of regular tracks, this was computed internally by the */ -GF_Err gf_isom_fragment_add_sample(GF_ISOFile *the_file, u32 TrackID, GF_ISOSample *sample, - u32 StreamDescriptionIndex, - u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redundantCoding); +GF_Err gf_isom_fragment_add_sample(GF_ISOFile *the_file, u32 TrackID, GF_ISOSample *sample, + u32 StreamDescriptionIndex, + u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redundantCoding); /*appends data into last sample of track for video fragments/other media CANNOT be used with OD tracks*/ @@ -1360,10 +1362,10 @@ you can specify the storage order for media data of a group of streams. This is for BIFS presentation so that static resources of the scene can be downloaded before BIFS*/ GF_Err gf_isom_set_track_group(GF_ISOFile *the_file, u32 trackNumber, u32 GroupID); -/*set the priority of a track within a Group (used for optimized interleaving and hinting). -This allows tracks to be stored before other within a same group, for instance the +/*set the priority of a track within a Group (used for optimized interleaving and hinting). +This allows tracks to be stored before other within a same group, for instance the hint track data can be stored just before the media data, reducing disk seeking -for a same time, within a group of tracks, the track with the lowest inversePriority will +for a same time, within a group of tracks, the track with the lowest inversePriority will be written first*/ GF_Err gf_isom_set_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber, u32 InversePriority); @@ -1426,7 +1428,7 @@ the transmissionTime is indicated in the media timeScale of the hint track*/ GF_Err gf_isom_begin_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TransmissionTime); /*stores the hint sample in the file once all your packets for this sample are done -set IsRandomAccessPoint if you want to indicate that this is a random access point +set IsRandomAccessPoint if you want to indicate that this is a random access point in the stream*/ GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint); @@ -1457,7 +1459,7 @@ extra_data: only used when the sample is actually the sample that will contain t In this case, set SourceTrackID to the HintTrack ID and SampleNumber to 0 In this case, the DataOffset MUST BE NULL and length will indicate the extra_data size -Note that if you want to reference a previous HintSample in the hintTrack, you will +Note that if you want to reference a previous HintSample in the hintTrack, you will have to parse the sample yourself ... */ GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, char *extra_data, u8 AtBegin); @@ -1469,7 +1471,7 @@ StreamDescriptionIndex: the index of the stream description in the desired track DataLength: the length of bytes to copy in the packet offsetInDescription: the offset in bytes in the description at which to begin copying data -Since it is far from being obvious what this offset is, we recommend not using this +Since it is far from being obvious what this offset is, we recommend not using this function. The ISO Media Format specification is currently being updated to solve this issue*/ GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 StreamDescriptionIndex, u16 DataLength, u32 offsetInDescription, u8 AtBegin); @@ -1479,9 +1481,9 @@ GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumbe RTP SPECIFIC WRITING API ******************************************************************/ -/*Creates a new RTP packet in the HintSample. If a previous packet was created, +/*Creates a new RTP packet in the HintSample. If a previous packet was created, it is stored in the hint sample and a new packet is created. -- relativeTime: RTP time offset of this packet in the HintSample if any - in hint track +- relativeTime: RTP time offset of this packet in the HintSample if any - in hint track time scale. Used for data smoothing by servers. - PackingBit: the 'P' bit of the RTP packet header - eXtensionBit: the'X' bit of the RTP packet header @@ -1497,13 +1499,13 @@ GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, s32 relat /*set the flags of the RTP packet*/ GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 disposable_packet, u8 IsRepeatedPacket); -/*set the time offset of this packet. This enables packets to be placed in the hint track -in decoding order, but have their presentation time-stamp in the transmitted +/*set the time offset of this packet. This enables packets to be placed in the hint track +in decoding order, but have their presentation time-stamp in the transmitted packet in a different order. Typically used for MPEG video with B-frames */ GF_Err gf_isom_rtp_packet_set_offset(GF_ISOFile *the_file, u32 trackNumber, s32 timeOffset); - + /*set some specific info in the HintDescription for RTP*/ /*sets the RTP TimeScale that the server use to send packets @@ -1584,7 +1586,7 @@ GF_Err gf_isom_reset_hint_reader(GF_ISOFile *the_file, u32 trackNumber, u32 samp /*reads next hint packet. ALl packets are read in transmission (decoding) order returns an error if not supported, or GF_EOS when no more packets are available currently only RTP reader is supported -@pck_data, @pck_size: output packet data (must be freed by caller) - contains all info to be sent +@pck_data, @pck_size: output packet data (must be freed by caller) - contains all info to be sent on the wire, eg for RTP contains the RTP header and the data @disposable (optional): indicates that the packet can be droped when late (B-frames & co) @repeated (optional): indicates this is a repeated packet (same one has already been sent) @@ -1606,7 +1608,7 @@ GF_Err gf_isom_next_hint_packet(GF_ISOFile *the_file, u32 trackNumber, char **pc */ /*Generic 3GP/3GP2 config record*/ -typedef struct +typedef struct { /*GF_4CC record type, one fo the above GF_ISOM_SUBTYPE_3GP_ * subtypes*/ u32 type; @@ -1709,6 +1711,9 @@ GF_Err gf_isom_avc_set_inband_config(GF_ISOFile *the_file, u32 trackNumber, u32 /*sets hev1 entry type (inband SPS/PPS) instead of of hvc1 (SPS/PPS in avcC box)*/ GF_Err gf_isom_hevc_set_inband_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex); +/*sets hvt1 entry type (tile track) - cfg may be set to indicate sub-profile of the tile. It is the use responsability to set the tbas track reference to the base hevc track*/ +GF_Err gf_isom_hevc_set_tile_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg); + /*creates new HEVC config*/ GF_Err gf_isom_hevc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_HEVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex); @@ -1742,9 +1747,9 @@ GF_Err gf_isom_text_dump(GF_ISOFile *the_file, u32 track, FILE *dump, u32 dump_t /*returns encoded TX3G box (text sample description for 3GPP text streams) as needed by RTP or other standards: @sidx: 1-based stream description index - @sidx_offset: + @sidx_offset: if 0, the sidx will NOT be written before the encoded TX3G - if not 0, the sidx will be written before the encoded TX3G, with the given offset. Offset sshould be at + if not 0, the sidx will be written before the encoded TX3G, with the given offset. Offset sshould be at least 128 for most commmon usage of TX3G (RTP, MPEG-4 timed text, etc) */ @@ -1775,7 +1780,7 @@ GF_Err gf_isom_update_webvtt_description(GF_ISOFile *movie, u32 trackNumber, u32 #ifndef GPAC_DISABLE_ISOM_WRITE -/*Create a new TextSampleDescription in the file. +/*Create a new TextSampleDescription in the file. The URL and URN are used to describe external media, this will create a data reference for the media GF_TextSampleDescriptor is defined in mpeg4_odf.h */ @@ -1788,17 +1793,17 @@ GF_Err gf_isom_text_reset(GF_TextSample * tx_samp); /*reset text sample styles but keep text*/ GF_Err gf_isom_text_reset_styles(GF_TextSample * samp); -/*sets UTF16 marker for text data. This MUST be called on an empty sample. If text data added later -on (cf below) is not formatted as UTF16 data(2 bytes char) the resulting text sample won't be compliant, +/*sets UTF16 marker for text data. This MUST be called on an empty sample. If text data added later +on (cf below) is not formatted as UTF16 data(2 bytes char) the resulting text sample won't be compliant, but this library WON'T WARN*/ GF_Err gf_isom_text_set_utf16_marker(GF_TextSample * samp); -/*append text to sample - text_len is the number of bytes to be written from text_data. This allows +/*append text to sample - text_len is the number of bytes to be written from text_data. This allows handling UTF8 and UTF16 strings in a transparent manner*/ GF_Err gf_isom_text_add_text(GF_TextSample * tx_samp, char *text_data, u32 text_len); /*append style modifyer to sample*/ GF_Err gf_isom_text_add_style(GF_TextSample * tx_samp, GF_StyleRecord *rec); -/*appends highlight modifier for the sample - @start_char: first char highlighted, +/*appends highlight modifier for the sample + @start_char: first char highlighted, @end_char: first char not highlighted*/ GF_Err gf_isom_text_add_highlight(GF_TextSample * samp, u16 start_char, u16 end_char); /*sets highlight color for the whole sample*/ @@ -1810,7 +1815,7 @@ GF_Err gf_isom_text_set_highlight_color_argb(GF_TextSample * samp, u32 argb); GF_Err gf_isom_text_add_karaoke(GF_TextSample * samp, u32 start_time); /*appends a new segment in the current karaoke sequence - you must build sequences in order to be compliant @end_time: segment end time expressed in text stream timescale, but relative to the sample media time - @start_char: first char highlighted, + @start_char: first char highlighted, @end_char: first char not highlighted */ GF_Err gf_isom_text_set_karaoke_segment(GF_TextSample * samp, u32 end_time, u16 start_char, u16 end_char); @@ -1821,14 +1826,14 @@ GF_Err gf_isom_text_set_scroll_delay(GF_TextSample * samp, u32 scroll_delay); /*appends hyperlinking for the sample @URL: ASCII url @altString: ASCII hint (tooltip, ...) for end user - @start_char: first char hyperlinked, + @start_char: first char hyperlinked, @end_char: first char not hyperlinked */ GF_Err gf_isom_text_add_hyperlink(GF_TextSample * samp, char *URL, char *altString, u16 start_char, u16 end_char); /*sets current text box (display pos&size within the text track window) for the sample*/ GF_Err gf_isom_text_set_box(GF_TextSample * samp, s16 top, s16 left, s16 bottom, s16 right); /*appends blinking for the sample - @start_char: first char blinking, + @start_char: first char blinking, @end_char: first char not blinking */ GF_Err gf_isom_text_add_blink(GF_TextSample * samp, u16 start_char, u16 end_char); @@ -1855,7 +1860,7 @@ GF_Err gf_isom_xml_subtitle_sample_add_text(GF_GenericSubtitleSample *samp, char ISMACryp Samples *****************************************************/ /*flags for GF_ISMASample*/ -enum +enum { /*signals the stream the sample belongs to uses selective encryption*/ GF_ISOM_ISMA_USE_SEL_ENC = 1, @@ -1888,7 +1893,7 @@ GF_ISMASample *gf_isom_ismacryp_sample_from_data(char *data, u32 dataLength, Boo /*rewrites samp content from s content*/ GF_Err gf_isom_ismacryp_sample_to_sample(GF_ISMASample *s, GF_ISOSample *dest); -/*decodes ISMACryp sample based on sample and its descrition index - returns NULL if not an ISMA sample +/*decodes ISMACryp sample based on sample and its descrition index - returns NULL if not an ISMA sample Note: input sample is NOT destroyed*/ GF_ISMASample *gf_isom_get_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, GF_ISOSample *samp, u32 sampleDescriptionIndex); @@ -1902,19 +1907,19 @@ Bool gf_isom_is_ismacryp_media(GF_ISOFile *the_file, u32 trackNumber, u32 sample Bool gf_isom_is_omadrm_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex); GF_Err gf_isom_get_omadrm_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, - u32 *outSchemeType, u32 *outSchemeVersion, - const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength); + u32 *outSchemeType, u32 *outSchemeVersion, + const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength); /*retrieves ISMACryp info for the given track & SDI - all output parameters are optional - URIs SHALL NOT BE MODIFIED BY USER @outOriginalFormat: retrieves orginal protected media format - usually GF_ISOM_SUBTYPE_MPEG4 @outSchemeType: retrieves 4CC of protection scheme (GF_ISOM_ISMACRYP_SCHEME = iAEC in ISMACryp 1.0) outSchemeVersion: retrieves version of protection scheme (1 in ISMACryp 1.0) - outSchemeURI: retrieves URI location of scheme + outSchemeURI: retrieves URI location of scheme outKMS_URI: retrieves URI location of key management system - only valid with ISMACryp 1.0 outSelectiveEncryption: specifies whether sample-based encryption is used in media - only valid with ISMACryp 1.0 outIVLength: specifies length of Initial Vector - only valid with ISMACryp 1.0 outKeyIndicationLength: specifies length of key indicator - only valid with ISMACryp 1.0 - outSelectiveEncryption, outIVLength and outKeyIndicationLength are usually not needed to decode an + outSelectiveEncryption, outIVLength and outKeyIndicationLength are usually not needed to decode an ISMA sample when using gf_isom_get_ismacryp_sample fct above */ GF_Err gf_isom_get_ismacryp_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, u32 *outSchemeType, u32 *outSchemeVersion, const char **outSchemeURI, const char **outKMS_URI, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength); @@ -1922,15 +1927,28 @@ GF_Err gf_isom_get_ismacryp_info(GF_ISOFile *the_file, u32 trackNumber, u32 samp /*returns original format type of a protected media file*/ GF_Err gf_isom_get_original_format_type(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat); +typedef struct +{ + u16 bytes_clear_data; + u32 bytes_encrypted_data; +} GF_CENCSubSampleEntry; + +typedef struct __cenc_sample_aux_info +{ + u8 IV_size; //0, 8 or 16; it MUST NOT be written to file + bin128 IV; /*can be 0, 64 or 128 bits - if 64, bytes 0-7 are used and 8-15 are 0-padded*/ + u16 subsample_count; + GF_CENCSubSampleEntry *subsamples; +} GF_CENCSampleAuxInfo; #ifndef GPAC_DISABLE_ISOM_WRITE /*removes protection info (does not perform decryption :), for ISMA, OMA and CENC*/ GF_Err gf_isom_remove_track_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex); /*creates ISMACryp protection info (does not perform encryption :)*/ -GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, - u32 scheme_version, char *scheme_uri, char *kms_URI, - Bool selective_encryption, u32 KI_length, u32 IV_length); +GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, + u32 scheme_version, char *scheme_uri, char *kms_URI, + Bool selective_encryption, u32 KI_length, u32 IV_length); /*change scheme URI and/or KMS URI for crypted files. Other params cannot be changed once the media is crypted @scheme_uri: new scheme URI, or NULL to keep previous @@ -1940,31 +1958,17 @@ GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, GF_Err gf_isom_set_oma_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, - char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len, - Bool selective_encryption, u32 KI_length, u32 IV_length); + char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len, + Bool selective_encryption, u32 KI_length, u32 IV_length); GF_Err gf_isom_cenc_allocate_storage(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u32 AlgorithmID, u8 IV_size, bin128 KID); GF_Err gf_isom_track_cenc_add_sample_info(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u8 IV_size, char *buf, u32 len); -typedef struct -{ - u16 bytes_clear_data; - u32 bytes_encrypted_data; -} GF_CENCSubSampleEntry; -typedef struct __cenc_sample_aux_info -{ - u8 IV_size; //0, 8 or 16; it MUST NOT be written to file - bin128 IV; /*can be 0, 64 or 128 bits - if 64, bytes 0-7 are used and 8-15 are 0-padded*/ - u16 subsample_count; - GF_CENCSubSampleEntry *subsamples; -} GF_CENCSampleAuxInfo; - - -GF_Err gf_isom_set_cenc_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, - u32 scheme_version, u32 default_IsEncrypted, u8 default_IV_size, bin128 default_KID); +GF_Err gf_isom_set_cenc_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, + u32 scheme_version, u32 default_IsEncrypted, u8 default_IV_size, bin128 default_KID); GF_Err gf_cenc_set_pssh(GF_ISOFile *mp4, bin128 systemID, u32 version, u32 KID_count, bin128 *KID, char *data, u32 len); @@ -2008,13 +2012,13 @@ GF_Err gf_isom_dump_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, u32 S /******************************************************************** GENERAL META API FUNCTIONS - + Meta can be stored at several places in the file layout: * root level (like moov, ftyp and co) * moov level * track level Meta API uses the following parameters for all functions: - + gf_isom_*_meta_*(GF_ISOFile *file, Bool root_meta, u32 track_num, ....) with: @root_meta: if set, accesses file root meta @track_num: if root_meta not set, specifies whether the target meta is at the @@ -2025,7 +2029,7 @@ GF_Err gf_isom_dump_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, u32 S /*gets meta type. Returned value: 0 if no meta found, or four char code of meta (eg, "mp21", "smil", ...)*/ u32 gf_isom_get_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num); -/*indicates if the meta has an XML container (note that XML data can also be included as items). +/*indicates if the meta has an XML container (note that XML data can also be included as items). return value: 0 (no XML or error), 1 (XML text), 2 (BinaryXML, eg BiM) */ u32 gf_isom_has_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num); @@ -2045,14 +2049,14 @@ u32 gf_isom_get_meta_item_count(GF_ISOFile *file, Bool root_meta, u32 track_num) @item_name (optional): item name @item_mime_type (optional): item mime type @item_encoding (optional): item content encoding type - @item_url, @item_urn (optional): url/urn of external resource containing this item data if any. + @item_url, @item_urn (optional): url/urn of external resource containing this item data if any. When item is fully contained in file, these are set to NULL */ -GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num, - u32 *itemID, u32 *protection_idx, Bool *is_self_reference, - const char **item_name, const char **item_mime_type, const char **item_encoding, - const char **item_url, const char **item_urn); +GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num, + u32 *itemID, u32 *protection_idx, Bool *is_self_reference, + const char **item_name, const char **item_mime_type, const char **item_encoding, + const char **item_url, const char **item_urn); /*gets item idx from item ID*/ @@ -2074,9 +2078,9 @@ u32 gf_isom_get_meta_primary_item_id(GF_ISOFile *file, Bool root_meta, u32 track #ifndef GPAC_DISABLE_ISOM_WRITE -/*sets meta type (four char int, eg "mp21", ... +/*sets meta type (four char int, eg "mp21", ... Creates a meta box if none found - if metaType is 0, REMOVES META + if metaType is 0, REMOVES META */ GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 metaType); @@ -2092,7 +2096,7 @@ GF_Err gf_isom_set_meta_xml_memory(GF_ISOFile *file, Bool root_meta, u32 track_n @self_reference: indicates this item is the file itself @resource_path: file to add - can be NULL when URL/URN is used @item_name: item name - if NULL, use file name. CANNOT BE NULL if resource_path is not set - @item_id: item id - if 0, use the last item id + 1. + @item_id: item id - if 0, use the last item id + 1. @mime_type: item mime type - if NULL, use "application/octet-stream" @content_encoding: content encoding type - if NULL, none specified @URL, @URN: if set, resource will be remote (same as stream descriptions) @@ -2150,8 +2154,8 @@ enum GF_ISOM_ITUNE_ALBUM_ARTIST = GF_4CC( 'a', 'A', 'R', 'T' ), GF_ISOM_ITUNE_GAPLESS = GF_4CC( 'p', 'g', 'a', 'p' ), }; -/*get the given tag info. -!! 'genre' may be coded by ID, the libisomedia doesn't translate the ID. In such a case, the result data is set to NULL +/*get the given tag info. +!! 'genre' may be coded by ID, the libisomedia doesn't translate the ID. In such a case, the result data is set to NULL and the data_len to the genre ID returns GF_URL_ERROR if no tag is present in the file */ @@ -2216,8 +2220,8 @@ typedef struct const char *textEncoding; const char *contentEncoding; const char *content_script_types; - const char *mime_type; - const char *xml_schema_loc; + const char *mime_type; + const char *xml_schema_loc; } GF_DIMSDescription; GF_Err gf_isom_get_dims_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_DIMSDescription *desc); @@ -2241,7 +2245,7 @@ struct __ec3_stream }; /*AC3 config record*/ -typedef struct +typedef struct { u8 is_ec3; u8 nb_streams; //1 for AC3, max 8 for EC3 @@ -2281,6 +2285,12 @@ void gf_isom_set_next_moof_number(GF_ISOFile *movie, u32 value); /*returns 'rap ' and 'roll' group info for the given sample*/ GF_Err gf_isom_get_sample_rap_roll_info(GF_ISOFile *the_file, u32 trackNumber, u32 sample_number, Bool *is_rap, Bool *has_roll, s32 *roll_distance); +/*returns opaque data of sample group*/ +Bool gf_isom_get_sample_group_info(GF_ISOFile *the_file, u32 trackNumber, u32 sample_description_index, u32 grouping_type, u32 *default_index, const char **data, u32 *size); + +/*returns tile info */ +Bool gf_isom_get_tile_info(GF_ISOFile *file, u32 trackNumber, u32 sample_description_index, u32 *default_sample_group_index, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h); + /*sample groups information*/ #ifndef GPAC_DISABLE_ISOM_WRITE /*sets rap flag for sample_number - this is used by non-IDR RAPs in AVC (also in USAC) were SYNC flag (stss table) cannot be used @@ -2291,11 +2301,18 @@ GF_Err gf_isom_set_sample_rap_group(GF_ISOFile *movie, u32 track, u32 sample_num - currently sample group info MUST be added in order (no insertion in the tables)*/ GF_Err gf_isom_set_sample_roll_group(GF_ISOFile *movie, u32 track, u32 sample_number, s16 roll_distance); -/*set encryption group for a sample_number; buf specifies the parameters for this group: IsEncrypted, IV_size, KID*/ +/*set encryption group for a sample_number; buf specifies the parameters for this group: IsEncrypted, IV_size, KID*/ GF_Err gf_isom_set_sample_cenc_group(GF_ISOFile *movie, u32 track, u32 sample_number, Bool isEncrypted, u8 IV_size, bin128 KeyID); GF_Err gf_isom_set_composition_offset_mode(GF_ISOFile *file, u32 track, Bool use_negative_offsets); +//adds the given blob as a sample group description of the given grouping type. If default is set, the sample grouping will be marked as default. +//sampleGroupDescriptionIndex is optional, used to retrieve the index +GF_Err gf_isom_add_sample_group_info(GF_ISOFile *movie, u32 track, u32 grouping_type, void *data, u32 data_size, Bool is_default, u32 *sampleGroupDescriptionIndex); + +//tags the sample in the grouping adds the given blob as a sample group description of the given grouping type. If default is set, the sample grouping will be marked as default +GF_Err gf_isom_add_sample_info(GF_ISOFile *movie, u32 track, u32 sample_number, u32 grouping_type, u32 sampleGroupDescriptionIndex); + #endif GF_Err gf_isom_get_sample_cenc_info(GF_ISOFile *movie, u32 track, u32 sample_number, u32 *IsEncrypted, u8 *IV_size, bin128 *KID); diff --git a/include/gpac/laser.h b/include/gpac/laser.h index 76eb9f2..658a688 100644 --- a/include/gpac/laser.h +++ b/include/gpac/laser.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/list.h b/include/gpac/list.h index fdef52b..e1fc76a 100644 --- a/include/gpac/list.h +++ b/include/gpac/list.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -144,7 +144,7 @@ void gf_list_reset(GF_List *ptr); /*! * \brief gets last item * - * Gets last item o fthe list + * Gets last item o fthe list * \param ptr target list object */ void *gf_list_last(GF_List *ptr); @@ -217,7 +217,7 @@ GF_List* gf_list_clone(GF_List *ptr); /*! * \brief Pop the first element in the list * - * Removes the first element in the list container, effectively reducing its size by one + * Removes the first element in the list container, effectively reducing its size by one * and returns the popped element. * \param ptr the list to pop * \return the popped element diff --git a/include/gpac/map.h b/include/gpac/map.h index 5893f94..89c5642 100644 --- a/include/gpac/map.h +++ b/include/gpac/map.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,7 +37,7 @@ extern "C" { /*! * \addtogroup map_grp map * \ingroup utils_grp - * \brief + * \brief * * This section documents the map object of the GPAC framework * \note The map use a random function for hashing. Collisions are resolved by using a GF_List on each slot. @@ -76,7 +76,7 @@ typedef struct { * * Allows to go through each pair key/value in the map. */ -typedef struct _it_map{ +typedef struct _it_map { /* The current map*/ GF_Map* map; @@ -88,8 +88,8 @@ typedef struct _it_map{ /* The current index in the hasmap*/ u32 hash; - -}GF_It_Map; + +} GF_It_Map; /*! * \brief map constructor diff --git a/include/gpac/math.h b/include/gpac/math.h index 43e0a7d..29dd00a 100644 --- a/include/gpac/math.h +++ b/include/gpac/math.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,7 +36,7 @@ extern "C" { */ #include - + #include @@ -46,7 +46,7 @@ extern "C" { *\brief Mathematics and Trigonometric functions * *This section documents the math and trigo functions used in the GPAC framework. GPAC can be compiled with - *fixed-point support, representing float values on a 16.16 signed integer, which implies a developer + *fixed-point support, representing float values on a 16.16 signed integer, which implies a developer *must take care of float computations when using GPAC.\n *A developper should not need to know in which mode the framework has been compiled as long as he uses *the math functions of GPAC which work in both float and fixed-point mode.\n @@ -206,7 +206,7 @@ typedef Float Fixed; Fixed gf_angle_diff(Fixed a, Fixed b); /*! - * \brief Field bit-size + * \brief Field bit-size * * Gets the number of bits needed to represent the value. * \param MaxVal Maximum value to be represented. @@ -273,7 +273,7 @@ typedef struct { /*!the left coordinate of the rectangle*/ Fixed x; - /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the + /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the greatest coordinate value, even if the rectangle is presented bottom-up. This insures proper rectangles testing*/ Fixed y; /*!the width of the rectangle. Width must be greater than or equal to 0*/ @@ -327,7 +327,7 @@ typedef struct { /*!the left coordinate of the rectangle*/ s32 x; - /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the + /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the greatest coordinate value, even if the rectangle is presented bottom-up. This insures proper rectangles operations*/ s32 y; /*!the width of the rectangle. Width must be greater than or equal to 0*/ @@ -454,7 +454,7 @@ void gf_mx2d_add_skew_x(GF_Matrix2D *_this, Fixed angle); void gf_mx2d_add_skew_y(GF_Matrix2D *_this, Fixed angle); /*!\brief matrix inversing * - *Inverses a 2D matrix + *Inverses a 2D matrix *\param _this matrix being transformed. Once the function is called, _this contains the result matrix */ void gf_mx2d_inverse(GF_Matrix2D *_this); @@ -587,7 +587,7 @@ typedef struct __vec4f /*!\brief 3D matrix * - *The 3D matrix object used in GPAC. The matrix is oriented like OpenGL matrices (column-major ordering), with + *The 3D matrix object used in GPAC. The matrix is oriented like OpenGL matrices (column-major ordering), with the translation part at the end of the coefficients list. \note Unless specified otherwise, the matrix object is always expected to represent an affine transformation. */ @@ -604,7 +604,7 @@ typedef struct Fixed __mag = gf_quat_len(v); \ (v).x = gf_divfix((v).x, __mag); (v).y = gf_divfix((v).y, __mag); (v).z = gf_divfix((v).z, __mag); (v).q = gf_divfix((v).q, __mag); \ } \ - + /*!\brief quaternion to rotation * *Transforms a quaternion to a Rotation, expressed as a 4 dimension vector with x,y,z for axis and q for rotation angle @@ -631,7 +631,7 @@ GF_Vec4 gf_quat_get_inv(GF_Vec4 *quat); GF_Vec4 gf_quat_multiply(GF_Vec4 *q1, GF_Vec4 *q2); /*!\brief quaternion vector rotating * - *Rotates a vector with a quaternion + *Rotates a vector with a quaternion *\param quat the quaternion modelizing the rotation *\param vec the vector to rotate *\return the resulting vector @@ -657,7 +657,7 @@ GF_Vec4 gf_quat_slerp(GF_Vec4 q1, GF_Vec4 q2, Fixed frac); /*!\brief 3D Bounding Box * - *The 3D Bounding Box is a 3D Axis-Aligned Bounding Box used to in various tools of the GPAC framework for bounds + *The 3D Bounding Box is a 3D Axis-Aligned Bounding Box used to in various tools of the GPAC framework for bounds estimation of a 3D object. It features an axis-aligned box and a sphere bounding volume for fast intersection tests. */ typedef struct @@ -695,8 +695,8 @@ Bool gf_bbox_equal(GF_BBox *b1, GF_BBox *b2); Bool gf_bbox_point_inside(GF_BBox *box, GF_Vec *p); /*!\brief get box vertices * - *Returns the 8 bounding box vertices given the minimum and maximum edge. Vertices are ordered to respect - "p-vertex indexes", (vertex from a box closest to plane) and so that n-vertex (vertex from a box farthest from plane) + *Returns the 8 bounding box vertices given the minimum and maximum edge. Vertices are ordered to respect + "p-vertex indexes", (vertex from a box closest to plane) and so that n-vertex (vertex from a box farthest from plane) is 7-p_vx_idx *\param bmin minimum edge of the box *\param bmax maximum edge of the box @@ -730,7 +730,7 @@ void gf_mx_from_mx2d(GF_Matrix *mx, GF_Matrix2D *mat2D); Bool gf_mx_equal(GF_Matrix *mx1, GF_Matrix *mx2); /*!\brief matrix translation * - *Translates a matrix + *Translates a matrix *\param mx the matrix being transformed. Once the function is called, contains the result matrix *\param tx horizontal translation *\param ty vertical translation @@ -739,7 +739,7 @@ Bool gf_mx_equal(GF_Matrix *mx1, GF_Matrix *mx2); void gf_mx_add_translation(GF_Matrix *mx, Fixed tx, Fixed ty, Fixed tz); /*!\brief matrix scaling * - *Scales a matrix + *Scales a matrix *\param mx the matrix being transformed. Once the function is called, contains the result matrix *\param sx horizontal translation scaling *\param sy vertical translation scaling @@ -748,7 +748,7 @@ void gf_mx_add_translation(GF_Matrix *mx, Fixed tx, Fixed ty, Fixed tz); void gf_mx_add_scale(GF_Matrix *mx, Fixed sx, Fixed sy, Fixed sz); /*!\brief matrix rotating * - *Rotates a matrix + *Rotates a matrix *\param mx the matrix being transformed. Once the function is called, contains the result matrix *\param angle rotation angle in radians *\param x horizontal coordinate of rotation axis @@ -756,7 +756,7 @@ void gf_mx_add_scale(GF_Matrix *mx, Fixed sx, Fixed sy, Fixed sz); *\param z depth coordinate of rotation axis */ void gf_mx_add_rotation(GF_Matrix *mx, Fixed angle, Fixed x, Fixed y, Fixed z); -/*!\brief matrices multiplication +/*!\brief matrices multiplication * *Multiplies a matrix with another one mx = mx*mul *\param mx the matrix being transformed. Once the function is called, contains the result matrix @@ -766,7 +766,7 @@ void gf_mx_add_matrix(GF_Matrix *mx, GF_Matrix *mul); /*!\brief 2D matrix multiplication * *Adds a 2D affine matrix to a matrix - *\param mx the matrix + *\param mx the matrix *\param mat2D the matrix to premultiply */ void gf_mx_add_matrix_2d(GF_Matrix *mx, GF_Matrix2D *mat2D); @@ -880,7 +880,7 @@ void gf_mx_rotate_vector(GF_Matrix *mx, GF_Vec *pt); \param z_axis target normalized Z axis */ void gf_mx_rotation_matrix_from_vectors(GF_Matrix *mx, GF_Vec x_axis, GF_Vec y_axis, GF_Vec z_axis); -/*!\brief matrix to 2D matrix +/*!\brief matrix to 2D matrix * *Inits a 2D matrix by removing all depth info from a 3D matrix *\param mx2d 2D matrix to initialize @@ -922,7 +922,7 @@ Fixed gf_plane_get_distance(GF_Plane *plane, GF_Vec *p); GF_Vec gf_closest_point_to_line(GF_Vec line_pt, GF_Vec line_vec, GF_Vec pt); /*!\brief box p-vertex index * - *Gets the p-vertex index for a given plane. The p-vertex index is the index of the closest vertex of a bounding box to the plane. The vertices of a box are always + *Gets the p-vertex index for a given plane. The p-vertex index is the index of the closest vertex of a bounding box to the plane. The vertices of a box are always *ordered in GPAC? cf \ref gf_bbox_get_vertices *\param p the plane to check *\return the p-vertex index value, ranging from 0 to 7 @@ -940,8 +940,8 @@ u32 gf_plane_get_p_vertex_idx(GF_Plane *p); Bool gf_plane_intersect_line(GF_Plane *plane, GF_Vec *linepoint, GF_Vec *linevec, GF_Vec *outPoint); /*!Classification types for box/plane position used in \ref gf_bbox_plane_relation*/ -enum -{ +enum +{ /*!box is in front of the plane*/ GF_BBOX_FRONT, /*!box intersects the plane*/ diff --git a/include/gpac/media_tools.h b/include/gpac/media_tools.h index 6ba223d..d65557a 100644 --- a/include/gpac/media_tools.h +++ b/include/gpac/media_tools.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,6 +42,12 @@ GF_Err gf_media_get_file_hash(const char *file, u8 hash[20]); /*creates (if needed) a GF_ESD for the given track - THIS IS RESERVED for local playback only, since the OTI used when emulated is not standard...*/ GF_ESD *gf_media_map_esd(GF_ISOFile *mp4, u32 track); + +/*! + * \brief Get RFC 6381 description for @track from @movie. + * \parama szCodec a pointer to an already allocated string. + */ +GF_Err gf_media_get_rfc_6381_codec_name(GF_ISOFile *movie, u32 track, char *szCodec); #endif #ifndef GPAC_DISABLE_ISOM_WRITE @@ -55,10 +61,10 @@ GF_Err gf_media_remove_non_rap(GF_ISOFile *file, u32 track); #ifndef GPAC_DISABLE_MEDIA_IMPORT -/* +/* track importers - All these can import a file into a dedicated track. If esd is NULL the track is blindly added + All these can import a file into a dedicated track. If esd is NULL the track is blindly added otherwise it is added with the requested ESID if non-0, otherwise the new trackID is stored in ESID if use_data_ref is set, data is only referenced in the file if duration is not 0, only the first duration seconds are imported @@ -75,7 +81,7 @@ enum GF_IMPORT_FORCE_PACKED = 1<<2, /*for AAC audio: forces SBR mode with implicit signaling (backward compatible)*/ GF_IMPORT_SBR_IMPLICIT = 1<<3, - /*for AAC audio: forces SBR mode with explicit signaling (non-backward compatible). + /*for AAC audio: forces SBR mode with explicit signaling (non-backward compatible). Will override GF_IMPORT_SBR_IMPLICIT flag when set*/ GF_IMPORT_SBR_EXPLICIT = 1<<4, /*forces MPEG-4 import - some 3GP2 streams have both native IsoMedia sample description and MPEG-4 one possible*/ @@ -96,17 +102,17 @@ enum /*for AAC audio: forces PS mode with implicit signaling (backward compatible)*/ GF_IMPORT_PS_IMPLICIT = 1<<12, - /*for AAC audio: forces PS mode with explicit signaling (non-backward compatible). + /*for AAC audio: forces PS mode with explicit signaling (non-backward compatible). Will override GF_IMPORT_PS_IMPLICIT flag when set*/ GF_IMPORT_PS_EXPLICIT = 1<<13, - + /* oversampled SBR */ GF_IMPORT_OVSBR = 1<<14, /* set subsample information with SVC*/ GF_IMPORT_SET_SUBSAMPLES = 1<<15, - /* force to mark non-IDR frmaes with sync data (I slices,) to be marked as sync points points + /* force to mark non-IDR frmaes with sync data (I slices,) to be marked as sync points points THE RESULTING FILE IS NOT COMPLIANT*/ GF_IMPORT_FORCE_SYNC = 1<<16, @@ -173,11 +179,11 @@ typedef struct __track_import GF_ISOFile *dest; /*media to import: MP4/ISO media: trackID - AVI files: + AVI files: 0: first video and first audio, 1: video track 2->any: audio track(s) - MPEG-PS files with N video streams: + MPEG-PS files with N video streams: 0: first video and first audio 1->N: video track N+1->any: audio track @@ -205,7 +211,7 @@ typedef struct __track_import u32 final_trackID; /*optional format indication for media source (used in IM1)*/ char *force_ext; - + /*for MP4 import only*/ GF_ISOFile *orig; @@ -218,7 +224,7 @@ typedef struct __track_import /*Initial offset of the first AU to import*/ Double initial_time_offset; - /*number of tracks after probing - may be set to 0, in which case no track + /*number of tracks after probing - may be set to 0, in which case no track selection can be performed. It may also be inaccurate if probing doesn't detect all available tracks (cf ogg import)*/ u32 nb_tracks; @@ -273,7 +279,7 @@ GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file); #endif /*GPAC_DISABLE_MEDIA_IMPORT*/ -typedef struct +typedef struct { char *file_name; char representationID[100]; @@ -307,14 +313,14 @@ typedef enum GF_DASH_BSMODE_SINGLE } GF_DashSwitchingMode; -GF_Err gf_dasher_segment_files(const char *mpd_name, GF_DashSegmenterInput *inputs, u32 nb_inputs, GF_DashProfile profile, - const char *mpd_title, const char *mpd_source, const char *mpd_copyright, - const char *mpd_moreInfoURL, const char **mpd_base_urls, u32 nb_mpd_base_urls, - u32 use_url_template, Bool use_segment_timeline, Bool single_segment, Bool single_file, GF_DashSwitchingMode bitstream_switching_mode, - Bool segments_start_with_rap, Double dash_duration_sec, char *seg_rad_name, char *seg_ext, u32 segment_marker_4cc, - Double frag_duration_sec, s32 subsegs_per_sidx, Bool daisy_chain_sidx, Bool fragments_start_with_rap, const char *tmp_dir, - GF_Config *dash_ctx, u32 dash_dynamic, u32 mpd_update_time, u32 time_shift_depth, Double subduration, Double min_buffer, - u32 ast_shift_sec, u32 dash_scale, Bool fragments_in_memory, u32 initial_moof_sn, u64 initial_tfdt, Bool no_fragments_defaults, Bool pssh_moof, Bool samplegroups_in_traf); +GF_Err gf_dasher_segment_files(const char *mpd_name, GF_DashSegmenterInput *inputs, u32 nb_inputs, GF_DashProfile profile, + const char *mpd_title, const char *mpd_source, const char *mpd_copyright, + const char *mpd_moreInfoURL, const char **mpd_base_urls, u32 nb_mpd_base_urls, + u32 use_url_template, Bool use_segment_timeline, Bool single_segment, Bool single_file, GF_DashSwitchingMode bitstream_switching_mode, + Bool segments_start_with_rap, Double dash_duration_sec, char *seg_rad_name, char *seg_ext, u32 segment_marker_4cc, + Double frag_duration_sec, s32 subsegs_per_sidx, Bool daisy_chain_sidx, Bool fragments_start_with_rap, const char *tmp_dir, + GF_Config *dash_ctx, u32 dash_dynamic, u32 mpd_update_time, u32 time_shift_depth, Double subduration, Double min_buffer, + u32 ast_shift_sec, u32 dash_scale, Bool fragments_in_memory, u32 initial_moof_sn, u64 initial_tfdt, Bool no_fragments_defaults, Bool pssh_moof, Bool samplegroups_in_traf); /*returns time to wait until end of currently generated segments*/ u32 gf_dasher_next_update_time(GF_Config *dash_ctx, u32 mpd_update_time); @@ -335,7 +341,7 @@ GF_Err gf_media_fragment_file(GF_ISOFile *input, const char *output_file, Double enum { - /*track dumper types are formatted as flags for conveniency for + /*track dumper types are formatted as flags for conveniency for authoring tools, but never used as a OR'ed set*/ /*native format (JPG, PNG, MP3, etc) if supported*/ GF_EXPORT_NATIVE = GF_TRUE, @@ -407,9 +413,9 @@ GF_Err gf_media_export(GF_MediaExporter *dump); */ typedef struct __tag_isom_hinter GF_RTPHinter; -GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, - u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 hint_flags, u8 PayloadID, - Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e); +GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, + u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 hint_flags, u8 PayloadID, + Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e); /*delete the track hinter*/ void gf_hinter_track_del(GF_RTPHinter *tkHinter); /*hints all samples in the media track*/ @@ -418,7 +424,7 @@ GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint); u32 gf_hinter_track_get_bandwidth(GF_RTPHinter *tkHinter); /*retrieves hinter flags*/ u32 gf_hinter_track_get_flags(GF_RTPHinter *tkHinter); -/*retrieves rtp payload name +/*retrieves rtp payload name @payloadName: static buffer for retrieval, minimum 30 bytes */ void gf_hinter_track_get_payload_name(GF_RTPHinter *tkHint, char *payloadName); @@ -467,7 +473,7 @@ void gf_saf_mux_del(GF_SAFMuxer *mux); GF_Err gf_saf_mux_stream_add(GF_SAFMuxer *mux, u32 stream_id, u32 ts_res, u32 buffersize_db, u8 stream_type, u8 object_type, char *mime_type, char *dsi, u32 dsi_len, char *remote_url); /*removes a stream from the SAF multiplex*/ GF_Err gf_saf_mux_stream_rem(GF_SAFMuxer *mux, u32 stream_id); -/*adds an AU to the given stream. !!AU data will be freed by the multiplexer!! +/*adds an AU to the given stream. !!AU data will be freed by the multiplexer!! AUs are not reinterleaved based on their CTS, in order to enable audio interleaving */ GF_Err gf_saf_mux_add_au(GF_SAFMuxer *mux, u32 stream_id, u32 CTS, char *data, u32 data_len, Bool is_rap); diff --git a/include/gpac/mediaobject.h b/include/gpac/mediaobject.h index a6b8e27..7405f80 100644 --- a/include/gpac/mediaobject.h +++ b/include/gpac/mediaobject.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,7 +39,7 @@ extern "C" { Media Object opaque handler for all natural media objects (audio, video, image) so that compositor and systems engine -are not too tied up. +are not too tied up. NOTE: the media object location relies on the node parent graph (this is to deal with namespaces in OD framework) therefore it is the task of the media management app to setup clear links between the scene graph and its ressources (but this is not mandatory, cf URLs in VRML ) @@ -76,15 +76,15 @@ you must use the gf_mo_get_speed and gf_mo_get_loop in order to know whether the /*set speed of media - speed is not always applied, depending on media control settings. NOTE: audio pitching is the responsability of the rendering app*/ void gf_mo_set_speed(GF_MediaObject *mo, Fixed speed); -/*returns current speed of media - in_speed is the speed of the media as set in the node (MovieTexture, +/*returns current speed of media - in_speed is the speed of the media as set in the node (MovieTexture, AudioClip and AudioSource) - the return value is the real speed of the media as overloaded by mediaControl if any*/ Fixed gf_mo_get_speed(GF_MediaObject *mo, Fixed in_speed); -/*returns looping flag of media - in_loop is the looping flag of the media as set in the node (MovieTexture, +/*returns looping flag of media - in_loop is the looping flag of the media as set in the node (MovieTexture, AudioClip) - the return value is the real loop flag of the media as overloaded by mediaControl if any*/ Bool gf_mo_get_loop(GF_MediaObject *mo, Bool in_loop); /*returns media object duration*/ Double gf_mo_get_duration(GF_MediaObject *mo); -/*returns whether the object should be deactivated (stop) or not - this checks object status as well as +/*returns whether the object should be deactivated (stop) or not - this checks object status as well as mediaControl status */ Bool gf_mo_should_deactivate(GF_MediaObject *mo); /*checks whether the target object is changed - you MUST use this in order to detect url changes*/ @@ -94,7 +94,11 @@ Bool gf_mo_url_changed(GF_MediaObject *mo, MFURL *url); Bool gf_mo_is_raw_memory(GF_MediaObject *mo); GF_Err gf_mo_get_raw_image_planes(GF_MediaObject *mo, u8 **pY_or_RGB, u8 **pU, u8 **pV); -/*fetch media data + +/*returns min frame duration for his object or 0 if unknown*/ +u32 gf_mo_get_min_frame_dur(GF_MediaObject *mo); + +/*fetch media data */ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestamp, u32 *size, s32 *ms_until_pres, s32 *ms_until_next); @@ -102,7 +106,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam /*release given amount of media data - nb_bytes is used for audio - drop_mode can take the following values: -1: do not drop 0: do not force drop: the unlocked frame it will be droped based on object time (typically video) -1: force drop : the unlocked frame will be droped if all bytes are consumed (typically audio) +1: force drop : the unlocked frame will be droped if all bytes are consumed (typically audio) 2: the frame will be stated as a discraded frame */ void gf_mo_release_data(GF_MediaObject *mo, u32 nb_bytes, s32 drop_mode); @@ -137,7 +141,7 @@ Bool gf_mo_set_position(GF_MediaObject *mo, GF_Window *src, GF_Window *dst); enum { - /*this is set to 0 by the OD manager whenever a change occur in the media (w/h change, SR change, etc) + /*this is set to 0 by the OD manager whenever a change occur in the media (w/h change, SR change, etc) as a hint for the compositor*/ GF_MO_IS_INIT = (1<<1), /*used by animation stream to remove TEXT from display upon delete and URL change*/ diff --git a/include/gpac/module.h b/include/gpac/module.h index 49c0a7b..500800f 100644 --- a/include/gpac/module.h +++ b/include/gpac/module.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -80,12 +80,12 @@ typedef struct __tag_mod_man GF_ModuleManager; const char *module_name; \ const char *author_name; \ void *HPLUG; \ - + /*! *\brief Base Interface * *This structure represent a base interface, e.g. the minimal interface declaration without functionalities. Each interface is - *type-casted to this structure and shall always be checked against its interface type. API Versioning is taken care of in the + *type-casted to this structure and shall always be checked against its interface type. API Versioning is taken care of in the *interface type itsel, changing at each modification of the interface API */ typedef struct @@ -160,7 +160,7 @@ typedef struct reg->ShutdownInterface = ShutdownInterface; \ return reg;\ } \ - + #else #define GPAC_MODULE_STATIC_DELARATION(__name) #endif @@ -168,7 +168,7 @@ typedef struct *\brief module manager construtcor * *Constructs a module manager object. - *\param directory absolute path to the directory where the manager shall look for modules + *\param directory absolute path to the directory where the manager shall look for modules *\param cfgFile GPAC configuration file handle. If this is NULL, the modules won't be able to share the configuration *file with the rest of the GPAC framework. *\return the module manager object @@ -262,7 +262,7 @@ GF_Err gf_modules_close_interface(GF_BaseInterface *interface_obj); /*! *\brief interface option query * - *Gets an option from the config file associated with the module manager + *Gets an option from the config file associated with the module manager *\param interface_obj the interface object used *\param secName the desired key parent section name *\param keyName the desired key name @@ -272,7 +272,7 @@ const char *gf_modules_get_option(GF_BaseInterface *interface_obj, const char *s /*! *\brief interface option update * - *Sets an option in the config file associated with the module manager + *Sets an option in the config file associated with the module manager *\param interface_obj the interface object used *\param secName the desired key parent section name *\param keyName the desired key name diff --git a/include/gpac/modules/audio_out.h b/include/gpac/modules/audio_out.h index 7153b77..a282659 100644 --- a/include/gpac/modules/audio_out.h +++ b/include/gpac/modules/audio_out.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,7 +56,7 @@ typedef struct _audiooutput /* interface declaration*/ GF_DECL_MODULE_INTERFACE - /*setup system + /*setup system Win32: os_handle is HWND if num_buffer is set, the audio driver should work with num_buffers with a total amount of audio data @@ -68,14 +68,14 @@ typedef struct _audiooutput /*shutdown system */ void (*Shutdown) (struct _audiooutput *aout); - /*query output frequency available - if the requested sampleRate is not available, the driver shall return the best + /*query output frequency available - if the requested sampleRate is not available, the driver shall return the best possible sampleRate able to handle NbChannels and NbBitsPerSample - if it doesn't handle the NbChannels the internal mixer will do it */ GF_Err (*QueryOutputSampleRate)(struct _audiooutput *aout, u32 *io_desired_samplerate, u32 *io_NbChannels, u32 *io_nbBitsPerSample); /*set output config - if audio is not running, driver must start it - *SampleRate, *NbChannels, *nbBitsPerSample: + *SampleRate, *NbChannels, *nbBitsPerSample: input: desired value output: final values channel_cfg is the channels output cfg, eg set of flags as specified in constants.h @@ -86,7 +86,7 @@ typedef struct _audiooutput u32 (*GetTotalBufferTime)(struct _audiooutput *aout); /*returns audio delay in ms, eg time delay until written audio data is outputed by the sound card - This function is only called after ConfigureOuput*/ + This function is only called after ConfigureOuput*/ u32 (*GetAudioDelay)(struct _audiooutput *aout); /*set output volume(between 0 and 100) */ @@ -114,9 +114,9 @@ typedef struct _audiooutput /*your private data handler - should be allocated when creating the interface object*/ void *opaque; - + /*these are assigned by the audio renderer once module is loaded*/ - + /*fills the buffer with audio data, returns effective bytes written - the rest is filled with 0*/ u32 (*FillBuffer) (void *audio_renderer, char *buffer, u32 buffer_size); void *audio_renderer; @@ -134,13 +134,13 @@ typedef struct _audiooutput /*interface returned on query interface*/ typedef struct _tag_audio_filter GF_AudioFilter; -struct _tag_audio_filter +struct _tag_audio_filter { /* interface declaration*/ GF_DECL_MODULE_INTERFACE - /*sets the current filter. The filterstring is opaque to libgpac and is taken as given - in the GPAC configuration file, where filters are listed as a ';;' seperated list in the "Filter" key of + /*sets the current filter. The filterstring is opaque to libgpac and is taken as given + in the GPAC configuration file, where filters are listed as a ';;' seperated list in the "Filter" key of the [Audio] section. @returns: 1 is this module can handle the filterstring, 0 otherwise. */ @@ -148,32 +148,32 @@ struct _tag_audio_filter /*configures the filter: @samplerate: samplerate of data - this cannot be modified by a filter @bits_per_sample: sample format (8 or 16 bit signed PCM data) of data - this cannot be modified by a filter - @input_channel_number: number of input channels + @input_channel_number: number of input channels @input_channel_layout: channel layout of input data - cf - @output_channel_number: number of ouput channels + @output_channel_number: number of ouput channels @output_channel_layout: channel layout of output data - cf - &output_block_size_in_samples: size in blocks of the data to be sent to this filter. + &output_block_size_in_samples: size in blocks of the data to be sent to this filter. If 0, data will not be reframed and blocks of any number of samples will be processed @delay_ms: delay in ms introduced by this filter @inplace_processing_capable: if set to 1, this filter is capable of processing data inplace, in which case the same buffer is passed for in_data and out_data in the process call */ GF_Err (*Configure)(GF_AudioFilter *af, u32 samplerate, u32 bits_per_sample, u32 input_channel_number, u32 input_channel_layout, u32 *output_channel_number, u32 *output_channel_layout, u32 *output_block_size_in_samples, u32 *delay_ms, Bool *inplace_processing_capable); - /*process a chunk of audio data. + /*process a chunk of audio data. @in_data: input sample buffer @in_data_size: input sample buffer size. If block len was set in the configure stage, there will be block len sample - @out_data: output sample buffer - if inplace was set in the configure stage, same as in_data. - NOTE: Outputing more samples that input ones may crash the system, the buffer only contains space for + @out_data: output sample buffer - if inplace was set in the configure stage, same as in_data. + NOTE: Outputing more samples that input ones may crash the system, the buffer only contains space for the same amount of samples (including channels added/removed by the filter) - @out_data_size: data size written to output. Usually 0 or in_data_size. + @out_data_size: data size written to output. Usually 0 or in_data_size. */ GF_Err (*Process)(GF_AudioFilter *af, void *in_data, u32 in_data_size, void *out_data, u32 *out_data_size); - + /*gets an option from the filter - currently not implemented */ const char *(*GetOption)(GF_AudioFilter *af, char *option); /*sets an option to the filter - currently not implemented */ Bool (*SetOption)(GF_AudioFilter *af, char *option, char *value); - + /*Indicates the filter should be reset (audio stop or seek )*/ void (*Reset)(GF_AudioFilter *af); diff --git a/include/gpac/modules/codec.h b/include/gpac/modules/codec.h index 6edf8b2..47204ff 100644 --- a/include/gpac/modules/codec.h +++ b/include/gpac/modules/codec.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,7 +64,7 @@ enum /*the structure for capabilities*/ -typedef struct +typedef struct { /*cap code cf below*/ u16 CapCode; @@ -109,7 +109,7 @@ enum GF_CODEC_HEIGHT, GF_CODEC_STRIDE, GF_CODEC_FPS, - GF_CODEC_FLIP, + GF_CODEC_FLIP, /*Pixel Aspect Ratio, expressed as (par.num<<16) | par.den*/ GF_CODEC_PAR, /*video color mode - color modes are defined in constants.h*/ @@ -139,7 +139,7 @@ enum /*queries or set support for usage of decoded frame from decoder memory - used for video codecs only*/ GF_CODEC_DIRECT_OUTPUT, - /*This is only called on scene decoders to signal that potential overlay scene should be + /*This is only called on scene decoders to signal that potential overlay scene should be showed (cap.valueINT=1) or hidden (cap.valueINT=0). Currently only used with SetCap*/ GF_CODEC_SHOW_SCENE, /*This is only called on scene decoders, GetCap only. If the decoder may continue modifying the scene once the last AU is received, @@ -167,28 +167,28 @@ enum GF_CODEC_SUPPORTED = 255, }; - /* Generic interface used by both media decoders and scene decoders +/* Generic interface used by both media decoders and scene decoders @AttachStream: - Add a Stream to the codec. If DependsOnESID is NULL, the stream is a base layer - UpStream means that the decoder should send feedback on this channel. - WARNING: Feedback format is not standardized by MPEG - the same API is used for both encoder and decoder (decSpecInfo is ignored - for an encoder) +Add a Stream to the codec. If DependsOnESID is NULL, the stream is a base layer +UpStream means that the decoder should send feedback on this channel. +WARNING: Feedback format is not standardized by MPEG +the same API is used for both encoder and decoder (decSpecInfo is ignored +for an encoder) @DetachStream: - Remove stream +Remove stream @GetCapabilities: - Get the desired capability given its code +Get the desired capability given its code @SetCapabilities - Set the desired capability given its code if possible - if the codec does not support the request capability, return GF_NOT_SUPPORTED +Set the desired capability given its code if possible +if the codec does not support the request capability, return GF_NOT_SUPPORTED @CanHandleStream - Can module handle this codec? Return one of GF_CODEC_NOT_SUPPORTED, GF_CODEC_MAYBE_SUPPORTED or GF_CODEC_SUPPORTED - esd is provided for more advanced inspection ( eg MPEG4 audio/visual where a bunch of codecs are defined with same objectType). If esd is NULL, only - decoder type is checked (audio or video), not codec type +Can module handle this codec? Return one of GF_CODEC_NOT_SUPPORTED, GF_CODEC_MAYBE_SUPPORTED or GF_CODEC_SUPPORTED +esd is provided for more advanced inspection ( eg MPEG4 audio/visual where a bunch of codecs are defined with same objectType). If esd is NULL, only +decoder type is checked (audio or video), not codec type @GetDecoderName - returns codec name - only called once the stream is successfully attached +returns codec name - only called once the stream is successfully attached @privateStack - user defined. +user defined. */ #define GF_CODEC_BASE_INTERFACE(IFCE_NAME) \ @@ -200,7 +200,7 @@ enum u32 (*CanHandleStream)(IFCE_NAME, u32 StreamType, GF_ESD *esd, u8 ProfileLevelIndication);\ const char *(*GetName)(IFCE_NAME);\ void *privateStack; \ - + typedef struct _basedecoder { @@ -210,25 +210,25 @@ typedef struct _basedecoder /*interface name and version for media decoder */ #define GF_MEDIA_DECODER_INTERFACE GF_4CC('G', 'M', 'D', '3') -/*the media module interface. A media module MUST be implemented in synchronous mode as time +/*the media module interface. A media module MUST be implemented in synchronous mode as time and resources management is done by the terminal*/ typedef struct _mediadecoder { GF_CODEC_BASE_INTERFACE(struct _basedecoder *) - /*Process the media data in inAU. + /*Process the media data in inAU. @inBuffer, inBufferLength: encoded input data (complete framing of encoded data) @ES_ID: stream this data belongs too (scalable object) @outBuffer, outBufferLength: allocated data for decoding - if outBufferLength is not enough - you must set the size in outBufferLength and GF_BUFFER_TOO_SMALL + you must set the size in outBufferLength and GF_BUFFER_TOO_SMALL @PaddingBits is the padding at the end of the buffer (some codecs need this info) @mmlevel: speed indicator for the decoding - cf above for values*/ - GF_Err (*ProcessData)(struct _mediadecoder *, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel); + GF_Err (*ProcessData)(struct _mediadecoder *, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel); /*optionnal (may be null), retrievs internal output frame of decoder. this function is called only if the decoder returns GF_OK on a SetCapabilities GF_CODEC_DIRECT_OUTPUT*/ @@ -248,8 +248,8 @@ typedef struct _scene *LPSCENE; typedef struct _scenedecoder { GF_CODEC_BASE_INTERFACE(struct _basedecoder *) - - /*Process the scene data in inAU. + + /*Process the scene data in inAU. @inBuffer, inBufferLength: encoded input data (complete framing of encoded data) @ES_ID: stream this data belongs too (scalable object) @AU_Time: specifies the current AU time. This is usually unused, however is needed for decoder @@ -257,11 +257,11 @@ typedef struct _scenedecoder time caries the time of the scene (or of the stream object attached to the scene decoder, cf below) @mmlevel: speed indicator for the decoding - cf above for values*/ GF_Err (*ProcessData)(struct _scenedecoder *, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_Time, u32 mmlevel); + u16 ES_ID, u32 AU_Time, u32 mmlevel); /*attaches scene to the decoder - a scene may be attached to several decoders of several types - (BIFS or others scene dec, ressource decoders (OD), etc. + (BIFS or others scene dec, ressource decoders (OD), etc. is: inline scene owning graph (and not just graph), defined in intern/terminal_dev.h. With inline scene the complete terminal is exposed so there's pretty much everything doable in a scene decoder @is_scene_root: set to true if this decoder is the root of the scene, false otherwise (either another decoder @@ -269,7 +269,7 @@ typedef struct _scenedecoder This is called once upon creation of the decoder (several times if re-entrant) */ GF_Err (*AttachScene)(struct _scenedecoder *, LPSCENE scene, Bool is_scene_root); - /*releases scene. If the decoder manages nodes / resources in the scene, + /*releases scene. If the decoder manages nodes / resources in the scene, THESE MUST BE DESTROYED. May be NULL if decoder doesn't manage nodes but only create them (like BIFS, OD) and doesn't have to be instructed the scene is about to be resumed This is called each time the scene is about to be reseted (eg, seek and destroy) @@ -286,8 +286,8 @@ typedef struct _base_node *LPNODE; typedef struct _nodedecoder { GF_CODEC_BASE_INTERFACE(struct _basedecoder *) - - /*Process the node data in inAU. + + /*Process the node data in inAU. @inBuffer, inBufferLength: encoded input data (complete framing of encoded data) @ES_ID: stream this data belongs too (scalable object) @AU_Time: specifies the current AU time. This is usually unused, however is needed for decoder @@ -295,7 +295,7 @@ typedef struct _nodedecoder time caries the time of the scene (or of the stream object attached to the scene decoder, cf below) @mmlevel: speed indicator for the decoding - cf above for values*/ GF_Err (*ProcessData)(struct _nodedecoder *, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_Time, u32 mmlevel); + u16 ES_ID, u32 AU_Time, u32 mmlevel); /*attaches node to the decoder - currently only one node is only attached to a single decoder*/ GF_Err (*AttachNode)(struct _nodedecoder *, LPNODE node); @@ -328,13 +328,13 @@ typedef struct __input_device /*interface name and version for media decoder */ #define GF_PRIVATE_MEDIA_DECODER_INTERFACE GF_4CC('G', 'P', 'M', '2') -/*the media module interface. A media module MUST be implemented in synchronous mode as time +/*the media module interface. A media module MUST be implemented in synchronous mode as time and resources management is done by the terminal*/ typedef struct _private_mediadecoder { GF_CODEC_BASE_INTERFACE(struct _basedecoder *) - /*Control media decoder. + /*Control media decoder. @mute: set mute or not @x, y, w, h: video output position in screen coordinate */ diff --git a/include/gpac/modules/font.h b/include/gpac/modules/font.h index a996047..4078e62 100644 --- a/include/gpac/modules/font.h +++ b/include/gpac/modules/font.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -100,7 +100,7 @@ typedef struct _font_reader /*shutdown font engine*/ GF_Err (*shutdown_font_engine)(struct _font_reader *dr); - /*set active font . @styles indicates font styles (PLAIN, BOLD, ITALIC, + /*set active font . @styles indicates font styles (PLAIN, BOLD, ITALIC, BOLDITALIC and UNDERLINED, STRIKEOUT)*/ GF_Err (*set_font)(struct _font_reader *dr, const char *fontName, u32 styles); /*gets font info*/ @@ -112,7 +112,7 @@ typedef struct _font_reader /*loads glyph by name - returns NULL if glyph cannot be found*/ GF_Glyph *(*load_glyph)(struct _font_reader *dr, u32 glyph_name); -/*module private*/ + /*module private*/ void *udta; } GF_FontReader; diff --git a/include/gpac/modules/hardcoded_proto.h b/include/gpac/modules/hardcoded_proto.h index e01941d..b0d08b7 100644 --- a/include/gpac/modules/hardcoded_proto.h +++ b/include/gpac/modules/hardcoded_proto.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/modules/ipmp.h b/include/gpac/modules/ipmp.h index 753402b..d584b2f 100644 --- a/include/gpac/modules/ipmp.h +++ b/include/gpac/modules/ipmp.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/include/gpac/modules/js_usr.h b/include/gpac/modules/js_usr.h index a84e08e..1b2031b 100644 --- a/include/gpac/modules/js_usr.h +++ b/include/gpac/modules/js_usr.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -49,7 +49,7 @@ struct _js_usr_ext /*load JS extension doc: scene graph in which the extension is loaded - jsctx: JavaScript context in which the extension is loaded. + jsctx: JavaScript context in which the extension is loaded. For BIFS/VRML/X3D, one context is created per script node For other graphs, one context is created per scene/document global: JavaScript global object for the context diff --git a/include/gpac/modules/raster2d.h b/include/gpac/modules/raster2d.h index 750d19d..af96e83 100644 --- a/include/gpac/modules/raster2d.h +++ b/include/gpac/modules/raster2d.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -103,7 +103,7 @@ typedef enum @cbk: user defined callback @x, y: first pixel position of the run, in device memory (top-left) coordinates @run_h_len: number of pixels to fill on line - @color: color to fill pixel with. USER MUST IGNORE THE ALPHA COMPONENT OF THIS COLOR, the final + @color: color to fill pixel with. USER MUST IGNORE THE ALPHA COMPONENT OF THIS COLOR, the final alpha is computed by the lib @alpha: blending amount (0->0xFF) for the pixels */ @@ -155,7 +155,7 @@ typedef struct _raster2d_interface GF_Err (*stencil_set_linear_gradient) (GF_STENCIL _this, Fixed start_x, Fixed start_y, Fixed end_x, Fixed end_y); /*radial gradient brush center point, focal point and radius - colors can only be set through set_interpolation */ GF_Err (*stencil_set_radial_gradient) (GF_STENCIL _this, Fixed cx, Fixed cy, Fixed fx, Fixed fy, Fixed x_radius, Fixed y_radius); - /*radial and linear gradient (not used with vertex) - set color interpolation at given points, + /*radial and linear gradient (not used with vertex) - set color interpolation at given points, @pos[i]: distance from (center for radial, start for linear) expressed between 0 and 1 (1 being the gradient bounds) @col[i]: associated color NOTE 1: the colors at 0 and 1.0 MUST be provided @@ -170,11 +170,11 @@ typedef struct _raster2d_interface GF_Err (*stencil_set_vertex_center) (GF_STENCIL _this, Fixed cx, Fixed cy, u32 color); /*set the center of the gradient*/ GF_Err (*stencil_set_vertex_colors) (GF_STENCIL _this, u32 *colors, u32 nbCol); - + /*sets global alpha blending level for stencil (texture and gradients) the alpha channel shall be combined with the color matrix if any*/ GF_Err (*stencil_set_alpha) (GF_STENCIL _this, u8 alpha); - + /*set stencil texture @pixels: texture data, from top to bottom @width, @height: texture size @@ -188,9 +188,9 @@ typedef struct _raster2d_interface data is not required to be available for texturing until the stencil is used in a draw operation */ GF_Err (*stencil_set_texture) (GF_STENCIL _this, char *pixels, u32 width, u32 height, u32 stride, GF_PixelFormat pixelFormat, GF_PixelFormat destination_format_hint, Bool no_copy); - /*creates internal texture - pixel data is owned by texture brush - set to NULL if not supported - this is used to - cope with engines that don't support random strides (ex: Gdiplus needs stride to be a multiple of 4) - if not set the compositor will create its own mem texture and pass it through set_texture - pixel format shall + /*creates internal texture - pixel data is owned by texture brush - set to NULL if not supported - this is used to + cope with engines that don't support random strides (ex: Gdiplus needs stride to be a multiple of 4) + if not set the compositor will create its own mem texture and pass it through set_texture - pixel format shall be respected as far as Alpha is concerned (eg alpha info shall be kept and used in blit) */ GF_Err (*stencil_create_texture) (GF_STENCIL _this, u32 width, u32 height, GF_PixelFormat pixelFormat); /*signals the texture has been modified (internal texture only)*/ @@ -204,7 +204,7 @@ typedef struct _raster2d_interface GF_Err (*stencil_set_color_matrix) (GF_STENCIL _this, GF_ColorMatrix *cmat); /*creates surface object*/ - /* @center_coords: true indicates mathematical-like coord system, + /* @center_coords: true indicates mathematical-like coord system, false indicates computer-like coord system */ GF_SURFACE (*surface_new) (struct _raster2d_interface *, Bool center_coords); /* delete surface object */ @@ -252,7 +252,7 @@ typedef struct _raster2d_interface the given rect is formatted as a clipper - CF ABOVE NOTE ON CLIPPERS*/ GF_Err (*surface_clear)(GF_SURFACE _this, GF_IRect *rc, GF_Color col); -/*private:*/ + /*private:*/ void *internal; } GF_Raster2D; diff --git a/include/gpac/modules/service.h b/include/gpac/modules/service.h index 5bacc8e..e4c38a0 100644 --- a/include/gpac/modules/service.h +++ b/include/gpac/modules/service.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -63,16 +63,16 @@ typedef enum GF_NET_CHAN_BUFFER_QUERY, /*retrieves DSI from channel (DSI may be caried by net with a != value than OD), app->module*/ GF_NET_CHAN_GET_DSI, - /*set media padding for all AUs fetched (pull mode only). + /*set media padding for all AUs fetched (pull mode only). If not supported the channel will have to run in push mode. app->module*/ GF_NET_CHAN_SET_PADDING, /*sets input channel to pull mode if possible, app->module*/ GF_NET_CHAN_SET_PULL, /*query channel capability to pause/resume and seek(play from an arbitrary range) - a non-interactive channel doesn't have to handle SET_SPEED, PAUSE and RESUME commands but can + a non-interactive channel doesn't have to handle SET_SPEED, PAUSE and RESUME commands but can still work in pull mode*/ GF_NET_CHAN_INTERACTIVE, - /*map net time (OTB) to media time (up only) - this is needed by some signaling protocols when the + /*map net time (OTB) to media time (up only) - this is needed by some signaling protocols when the real play range is not the requested one */ GF_NET_CHAN_MAP_TIME, /*reconfiguration of channel comming from network (up only) - this is used to override the SL config @@ -83,12 +83,12 @@ typedef enum /*reset channel - this is need when we turn off this channel in rtp/mpeg2ts*/ GF_NET_CHAN_RESET, - + /*retrieves ESD for channel - net->term only, for cache configuration*/ GF_NET_CHAN_GET_ESD, /*retrieves visual PAR as indicated in container if any*/ GF_NET_CHAN_GET_PIXEL_AR, - + /*service buffer query (for all channels running in service), app<-module*/ GF_NET_BUFFER_QUERY, /*retrieves network stats for service/channel; app->module*/ @@ -113,7 +113,7 @@ typedef enum /*When using DASH or playlists, query the next file to concatenate to thecurrent one net->proxy only*/ GF_NET_SERVICE_QUERY_NEXT, - /*When using DASH, query the media range of the url passed in ConnectService - this is only used for local + /*When using DASH, query the media range of the url passed in ConnectService - this is only used for local playback/validation of DASH sequences*/ GF_NET_SERVICE_QUERY_INIT_RANGE, /* When using proxy between an input module and the terminal, exchange status using this command: input -> proxy */ @@ -131,6 +131,8 @@ typedef enum /*signal associated content timeline (from service to term)*/ GF_NET_ASSOCIATED_CONTENT_TIMING, + /*event send from service*/ + GF_NET_SERVICE_EVENT, //sets nalu mode GF_NET_CHAN_NALU_MODE, } GF_NET_CHAN_CMD; @@ -157,8 +159,10 @@ typedef struct /*params for GF_NET_CHAN_PLAY and GF_NET_CHAN_SPEED*/ Double speed; Bool dash_segment_switch; - /*indicates theis is the first PLAY on an elemnt inserted from bcast*/ + /*indicates this is the first PLAY on an elemnt inserted from bcast*/ Bool initial_broadcast_play; + /*indicates the range is given in timestamps, no media time */ + Bool is_timestamp_based; } GF_NetComPlay; @@ -172,10 +176,10 @@ typedef struct LPNETCHANNEL on_channel; /*SL config of the stream as delivered in OD (app->channel) or by network (channel->app)*/ - GF_SLConfig sl_config; + GF_SLConfig sl_config; /*stream priority packet drops are more tolerable if low priority - app->channel only*/ u32 priority; - /*sync ID: all channels with the same sync ID run on the same timeline, thus the module should + /*sync ID: all channels with the same sync ID run on the same timeline, thus the module should try to match this - note this may not be possible (typically RTP/RTSP)*/ u32 sync_id; /*audio frame duration and sample rate if any - this is needed by some RTP payload*/ @@ -189,7 +193,7 @@ typedef struct { u32 command_type; LPNETCHANNEL on_channel; - /*the recommended buffering limits in ms - this depends on the modules preferences and on the service + /*the recommended buffering limits in ms - this depends on the modules preferences and on the service type (multicast, vod, ...) - below buffer_min the stream will pause if possible until buffer_max is reached note the app will fill in default values before querying*/ u32 min, max; @@ -295,7 +299,7 @@ typedef struct /*GF_NET_GET_STATS Notes -1: only channels using network must reply. All channels fetching data through a +1: only channels using network must reply. All channels fetching data through a file downloader (cf below) shall NOT answer, the app manages downloader bandwidth internally. 2: BANDWIDTH USED BY SIGNALING PROTOCOL IS IGNORED IN GPAC */ @@ -312,8 +316,8 @@ typedef struct __netstatcom u16 port, ctrl_port; /*bandwidth used by channel & its control channel if any (both up and down) - expressed in bits per second*/ u32 bw_up, bw_down, ctrl_bw_down, ctrl_bw_up; - /*set to 0 if channel is not part of a multiplex. Otherwise set to the multiplex port, and - above port info shall be identifiers in the multiplex - note that multiplexing overhead is ignored + /*set to 0 if channel is not part of a multiplex. Otherwise set to the multiplex port, and + above port info shall be identifiers in the multiplex - note that multiplexing overhead is ignored in GPAC for the current time*/ u16 multiplex_port; } GF_NetComStats; @@ -342,6 +346,7 @@ typedef struct __netinfocom const char *composer; const char *name; const char *writer; + const char *provider; } GF_NetComInfo; /*GF_NET_CHAN_GET_PIXEL_AR*/ @@ -361,11 +366,21 @@ typedef struct u32 data_len; } GF_NetComMigration; +/*GF_NET_SERVICE_EVENT*/ +typedef struct +{ + u32 command_type; + + /*type of the event being sent*/ + GF_Event evt; + Bool res; +} GF_NetComSendEvent; + /*GF_NET_SERVICE_QUERY_NEXT*/ typedef struct { u32 command_type; - //input + //input /*drops first segment */ Bool drop_first_segment; @@ -391,12 +406,14 @@ typedef struct Bool has_next; - /*module->proxy: indicates that currently downloaded segment should be checked. - proxy->module: indicates that the return URL is the currently downloaded one, not yet completed (progressive mode only). + /*module->proxy: indicates that currently downloaded segment should be checked. + proxy->module: indicates that the return URL is the currently downloaded one, not yet completed (progressive mode only). */ Bool current_download; /*indicates that there is new data in the cache for the current URL (progressive mode only) - only valid if is_current_download is set.*/ Bool has_new_data; + /*indicates that end of period is being reached (no new segements returned until period activates)*/ + Bool in_end_of_period; } GF_NetURLQuery; @@ -445,7 +462,7 @@ typedef struct { u32 command_type; LPNETCHANNEL channel; - + //negative values mean "timeline is ready no need for timing message" s32 timeline_id; const char *external_URL; Bool is_announce, is_splicing; @@ -506,6 +523,7 @@ typedef union __netcommand GF_AssociatedContentLocation addon_info; GF_AssociatedContentTiming addon_time; GF_NALUExtractMode nalu_mode; + GF_NetComSendEvent send_event; } GF_NetworkCommand; /* @@ -521,36 +539,36 @@ typedef struct _netinterface GF_DECL_MODULE_INTERFACE /*returns 1 if module can process this URL, 0 otherwise. This is only called when the file extension/mimeType cannot be - retrieved in the cfg file, otherwise the mime type/file ext is used to load service. Typically a module would - register its mime types in this function (cf gf_term_register_mime_type below) + retrieved in the cfg file, otherwise the mime type/file ext is used to load service. Typically a module would + register its mime types in this function (cf gf_service_register_mime below) */ Bool (*CanHandleURL)(struct _netinterface *, const char *url); - /*connects the service to the desired URL - the service handle is used for callbacks. + /*connects the service to the desired URL - the service handle is used for callbacks. Only one service can be connected to a loaded interface. */ GF_Err (*ConnectService) (struct _netinterface *, GF_ClientService *serv, const char *url); /*disconnects service - the module is no longer used after this call - if immediate_shutdown is set the module shall not attempt to get confirmation from remote side, it will be deleted right away - + NOTE: depending on how the client/server exchange is happening, it may happen that the CloseService is called - in the same context as a reply from your module. This can result into deadlocks if you're using threads. + in the same context as a reply from your module. This can result into deadlocks if you're using threads. You should therefore only try to destroy threads used in the interface shutdown process, which is guarantee to be in a different context call. */ GF_Err (*CloseService) (struct _netinterface *); - /*retrieves service decsriptor (expressed as an MPEG4 OD/IOD) for accessing this service + /*retrieves service decsriptor (expressed as an MPEG4 OD/IOD) for accessing this service descriptor is allocated by plugin and destroyed by user the IOD shall refer to the service attached to the module - @expect_type is a hint in case the service regenerates an IOD. It indicates whether the entry point expected is + @expect_type is a hint in case the service regenerates an IOD. It indicates whether the entry point expected is INLINE, BIFS animation stream, video, audio or input sensor. @sub_url: indicates fetching of an IOD for a given object in the service. Only used for services handling the optional CanHandleURLInService below NULL for main service service extension for sub-service (cf CanHandleURLInService below). For ex, - "rtsp://myserver/file.mp4/ES_ID=3" and "rtsp://myserver/file.mp4/ES_ID=4" + "rtsp://myserver/file.mp4/ES_ID=3" and "rtsp://myserver/file.mp4/ES_ID=4" or "file.avi#audio" and "file.avi#video".In this case a partial IOD for the desired object is expected Note: once a service is acknowledged as connected, this function must be executed synchronously The service can return NULL for a descriptor: @@ -558,14 +576,14 @@ typedef struct _netinterface * if the expected media type is a scene, this means the terminalk shall create and manage the scene */ GF_Descriptor *(*GetServiceDescriptor) (struct _netinterface *, u32 expect_type, const char *sub_url); - + /*sends command to the service / channel - cf command structure*/ GF_Err (*ServiceCommand) (struct _netinterface *, GF_NetworkCommand *com); /*data channel setup - url is either "ES_ID=ID" where ID is the stream ID in this service - or a control string depending on the service/stream. The URL is first used to load a module able to handle it, + or a control string depending on the service/stream. The URL is first used to load a module able to handle it, so the module has no redirection to handle */ GF_Err (*ConnectChannel) (struct _netinterface *, LPNETCHANNEL channel, const char *url, Bool upstream); @@ -573,7 +591,7 @@ typedef struct _netinterface GF_Err (*DisconnectChannel) (struct _netinterface *, LPNETCHANNEL channel); /*optional - fetch MPEG4 data from channel - data shall not be duplicated and must be released at ReleaseData - SL info shall be written to provided header - if the data is a real SL packet the flag sl_compressed shall be + SL info shall be written to provided header - if the data is a real SL packet the flag sl_compressed shall be set to signal the app this is a full SL pdu (@out_sl_hdr is then ignored) set to NULL if not supported */ @@ -583,77 +601,74 @@ typedef struct _netinterface set to NULL if not supported*/ GF_Err (*ChannelReleaseSLP) (struct _netinterface *, LPNETCHANNEL channel); - /*this is needed for modules to query other modules, the typical case being 2 ESD URLs pointing to the - same media (audio and video streams in an RTSP session). This is always used on loaded modules but + /*this is needed for modules to query other modules, the typical case being 2 ESD URLs pointing to the + same media (audio and video streams in an RTSP session). This is always used on loaded modules but doesn't have to be declared*/ Bool (*CanHandleURLInService)(struct _netinterface *, const char *url); -/*private*/ + /*private*/ void *priv; -/*proxy stuff*/ + /*proxy stuff*/ GF_Err (*query_proxy)(struct _netinterface *, GF_NetworkCommand *param); void *proxy_udta; Bool proxy_type; /* 0 corresponds to a proxy without full command support */ /*! * This is needed for modules supporting mime types, when this method is called, - * the module has to call gf_term_register_mime_type() for all the mime-types + * the module has to call gf_service_register_mime() for all the mime-types * its supports. * \return The number of declared mime types - * \see gf_term_register_mime_type(GF_InputService *, const char *, const char *, const char *) + * \see gf_service_register_mime(GF_InputService *, const char *, const char *, const char *) */ u32 (*RegisterMimeTypes) (const struct _netinterface *); } GF_InputService; /*callback functions - these can be linked with non-LGPL modules*/ -/*message from service - error is set if error*/ -void gf_term_on_message(GF_ClientService *service, GF_Err error, const char *message); + /*to call on service (if channel is NULL) or channel connect completed*/ -void gf_term_on_connect(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); +void gf_service_connect_ack(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); /*to call on service (if channel is NULL) or channel disconnect completed*/ -void gf_term_on_disconnect(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); +void gf_service_disconnect_ack(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); /* acknowledgement of service command - service commands handle both services and channels Most of the time commands are NOT acknowledged, typical acknowledgement are needed for setup and control -with remote servers. +with remote servers. command can also be triggered from the service (QoS, broadcast announcements) cf above for command usage */ -void gf_term_on_command(GF_ClientService *service, GF_NetworkCommand *com, GF_Err response); -/*to call when data packet is received. +void gf_service_command(GF_ClientService *service, GF_NetworkCommand *com, GF_Err response); +/*to call when data packet is received. @data, data_size: data received -@hdr: uncompressed SL header passed with data for stream sync - if not present then data shall be a valid SL packet +@hdr: uncompressed SL header passed with data for stream sync - if not present then data shall be a valid SL packet (header + PDU). Note that using an SLConfig resulting in an empty GF_SLHeader allows sending raw data directly @reception_status: data reception status. To signal end of stream, set this to GF_EOS */ -void gf_term_on_sl_packet(GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status); +void gf_service_send_packet(GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status); /*returns URL associated with service (so that you don't need to store it)*/ -const char *gf_term_get_service_url(GF_ClientService *service); +const char *gf_service_get_url(GF_ClientService *service); /*adds a new media from network. !! The media descriptor is then owned/destroyed by the term!! media_desc: object descriptor for the new media. May be NULL to force scene rebuilt. no_scene_check: specifies if the scene description shall be rebuilt or not. */ -void gf_term_add_media(GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_update); - -Bool gf_term_on_service_event(GF_ClientService *service, GF_Event *service_event); +void gf_service_declare_media(GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_update); +//returns module interface of the service +GF_InputService *gf_service_get_interface(GF_ClientService *service); /*check if @fileExt extension is supported for given mimeType, and if associated with module. If mimeType not registered, register it for given module*/ -Bool gf_term_check_extension(GF_InputService *ifce, const char *mimeType, const char *extList, const char *description, const char *fileExt); +Bool gf_service_check_mime_register(GF_InputService *ifce, const char *mimeType, const char *extList, const char *description, const char *fileExt); /*register mime types & file extensions - most modules should only need the check version above*/ -void gf_term_register_mime_type(const GF_InputService *ifce, const char *mimeType, const char *extList, const char *description); - -GF_InputService *gf_term_get_service_interface(GF_ClientService *service); +void gf_service_register_mime(const GF_InputService *ifce, const char *mimeType, const char *extList, const char *description); -/*file downloading - can and MUST be used by any module (regardless of license) in order not to interfere +/*file downloading - can and MUST be used by any module (regardless of license) in order not to interfere with net management*/ /*creates a new downloading session in the given service - if url is relative, it will be interpreted through the service URL*/ -GF_DownloadSession * gf_term_download_new(GF_ClientService *service, const char *url, u32 flags, gf_dm_user_io user_io, void *cbk); +GF_DownloadSession * gf_service_download_new(GF_ClientService *service, const char *url, u32 flags, gf_dm_user_io user_io, void *cbk); /*closes the downloading session*/ -void gf_term_download_del(GF_DownloadSession * dnload); +void gf_service_download_del(GF_DownloadSession * dnload); /*send progress and connection messages to user...*/ -void gf_term_download_update_stats(GF_DownloadSession * sess); +void gf_service_download_update_stats(GF_DownloadSession * sess); /*MPEG-4 media cache interface name*/ diff --git a/include/gpac/modules/term_ext.h b/include/gpac/modules/term_ext.h index 3a18fbf..b017b28 100644 --- a/include/gpac/modules/term_ext.h +++ b/include/gpac/modules/term_ext.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,7 +64,7 @@ enum @return: ignored */ GF_TERM_EXT_PROCESS, - + /*load/unload js bindings of this extension associated param: GF_TermExtJS *jsext @return: ignored diff --git a/include/gpac/modules/video_out.h b/include/gpac/modules/video_out.h index 96eefc9..d832897 100644 --- a/include/gpac/modules/video_out.h +++ b/include/gpac/modules/video_out.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -84,7 +84,7 @@ enum }; typedef struct -{ +{ GF_IRect *list; u32 count; } GF_DirtyRectangles; @@ -92,19 +92,19 @@ typedef struct typedef struct _gf_sc_texture_handler GF_TextureH; /*interface name and version for video output*/ -#define GF_VIDEO_OUTPUT_INTERFACE GF_4CC('G','V','O','1') +#define GF_VIDEO_OUTPUT_INTERFACE GF_4CC('G','V','O','1') /* video output interface the video output may run in 2 modes: 2D and 3D. - ** the 2D video output works by accessing a backbuffer surface on the video mem board - - the app accesses to the surface through the GF_VideoSurface handler. + ** the 2D video output works by accessing a backbuffer surface on the video mem board - + the app accesses to the surface through the GF_VideoSurface handler. The module may support HW blitting of RGB or YUV data to backbuffer. ** the 3D video output only handles window management and openGL contexts setup. - The context shall be setup in Resize and SetFullScreen calls which are always happening in the main + The context shall be setup in Resize and SetFullScreen calls which are always happening in the main rendering thread. This will take care of openGL context issues with multithreading By default all modules are required to be setup in 2D. If 3D is needed, a GF_EVENT_VIDEO_SETUP will @@ -125,7 +125,7 @@ typedef struct _video_out /*shutdown system */ void (*Shutdown) (struct _video_out *vout); - /*flush video: the video shall be presented to screen + /*flush video: the video shall be presented to screen the destination area to update is in client display coordinates (0,0) being top-left, (w,h) bottom-right Note: dest is always NULL in 3D mode (buffer flip only)*/ GF_Err (*Flush) (struct _video_out *vout, GF_Window *dest); @@ -143,16 +143,16 @@ typedef struct _video_out * This can be a request for an offscreen rendering surface. If supported, this surface SHALL be readable through glReadPixels. If not supported, just return an error. Note that GPAC never uses more than one GL context (offscreen or main video) - * Depending on windowing systems and implementations, it could be possible to resize a window + * Depending on windowing systems and implementations, it could be possible to resize a window without destroying the GL context. If the GL context is destroyed, the module should send an event of the same type to the player. - - This function is also called with a NULL event at the begining of each rendering cycle, in order to allow event + + This function is also called with a NULL event at the begining of each rendering cycle, in order to allow event handling for modules uncapable of safe multithreading (eg X11) */ GF_Err (*ProcessEvent)(struct _video_out *vout, GF_Event *event); - /*pass events to user (assigned before setup) - return 1 if the event has been processed by GPAC + /*pass events to user (assigned before setup) - return 1 if the event has been processed by GPAC (eiher scene or navigation), 0 otherwise*/ void *evt_cbk_hdl; Bool (*on_event)(void *hdl, GF_Event *event); @@ -180,7 +180,7 @@ typedef struct _video_out GF_Err (*Blit)(struct _video_out *vout, GF_VideoSurface *video_src, GF_Window *src_wnd, GF_Window *dst_wnd, u32 overlay_type); /*optional - blits the texture as a bitmap with the specified transform cliped with the given cliper, with alpha and + blits the texture as a bitmap with the specified transform cliped with the given cliper, with alpha and color keying (NULL if no keying) */ Bool (*BlitTexture)(struct _video_out *vout, GF_TextureH *texture, GF_Matrix2D *transform, GF_IRect *clip, u8 alpha, GF_ColorKey *col_key, Fixed depth_offset, Fixed depth_gain); @@ -194,7 +194,7 @@ typedef struct _video_out flushes only the listed rectangles */ void (*FlushRectangles)(struct _video_out *vout, GF_DirtyRectangles *rectangles); - + /*ignored if GF_VIDEO_HW_HAS_LINE_BLIT is not set*/ void (*DrawHLine)(struct _video_out *vout, u32 x, u32 y, u32 length, GF_Color color); void (*DrawHLineAlpha)(struct _video_out *vout, u32 x, u32 y, u32 length, GF_Color color, u8 alpha); @@ -219,10 +219,10 @@ typedef struct _video_out u32 overlay_color_key; /*for auto-stereoscopic output*/ - /*maximum pixel disparity*/ - u32 disparity; - /*nominal display viewing distance in cm*/ - Fixed view_distance; + /*maximum pixel disparity*/ + u32 disparity; + /*nominal display viewing distance in cm*/ + Fixed view_distance; /*driver private*/ void *opaque; diff --git a/include/gpac/mpeg4_odf.h b/include/gpac/mpeg4_odf.h index 245cc80..8700e7c 100644 --- a/include/gpac/mpeg4_odf.h +++ b/include/gpac/mpeg4_odf.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -60,10 +60,10 @@ enum GF_ODF_ISOM_OD_TAG = 0x11, GF_ODF_ISOM_IPI_PTR_TAG = 0x12, /*END FILE FORMAT RESERVED*/ - + GF_ODF_EXT_PL_TAG = 0x13, GF_ODF_PL_IDX_TAG = 0x14, - + GF_ODF_ISO_BEGIN_TAG = 0x15, GF_ODF_ISO_END_TAG = 0x3F, @@ -87,7 +87,7 @@ enum GF_ODF_ISO_RES_BEGIN_TAG = 0x62, GF_ODF_ISO_RES_END_TAG = 0xBF, - + GF_ODF_USER_BEGIN_TAG = 0xC0, /*internal descriptor for mux input description*/ @@ -132,7 +132,7 @@ typedef struct } GF_Descriptor; -/* default descriptor. +/* default descriptor. NOTE: The decoderSpecificInfo is used as a default desc with tag 0x05 */ typedef struct { @@ -161,7 +161,7 @@ typedef struct GF_List *extensionDescriptors; /*MPEG-2 (or other service mux formats) service ID*/ u16 ServiceID; - /*pointer to the service interface (GF_InputService) of the service having declared the object + /*pointer to the service interface (GF_InputService) of the service having declared the object only used for DASH*/ void *service_ifce; } GF_ObjectDescriptor; @@ -181,7 +181,7 @@ typedef struct GF_List *extensionDescriptors; /*MPEG-2 (or other service mux formats) service ID*/ u16 ServiceID; - /*pointer to the service interface (GF_InputService) of the service having declared the object + /*pointer to the service interface (GF_InputService) of the service having declared the object only used for DASH*/ void *service_ifce; @@ -256,7 +256,7 @@ typedef struct u32 maxBitrate; u32 avgBitrate; GF_DefaultDescriptor *decoderSpecificInfo; - + /*placeholder for RVC decoder config if any*/ u16 predefined_rvc_config; GF_DefaultDescriptor *rvc_config; @@ -277,7 +277,7 @@ typedef struct { u8 contentType; u8 contentIdentifierType; /*international code string*/ - char *contentIdentifier; + char *contentIdentifier; } GF_CIDesc; /*Supplementary Content Identification Descriptor)*/ @@ -299,7 +299,7 @@ typedef struct { BASE_DESCRIPTOR u8 IPMP_DescriptorID; u16 IPMP_DescriptorIDEx; - u16 IPMP_ES_ID; + u16 IPMP_ES_ID; } GF_IPMPPtr; /*IPMPX control points*/ @@ -315,7 +315,7 @@ enum IPMP_CP_CM = 3, /*control point in BIFS tree (???)*/ IPMP_CP_BIFS = 4 - /*the rest is reserved or forbidden(0xFF)*/ + /*the rest is reserved or forbidden(0xFF)*/ }; /*IPMPX base classe*/ @@ -323,8 +323,8 @@ enum u8 tag; \ u8 version; \ u32 dataID; \ - -typedef struct + +typedef struct { GF_IPMPX_BASE } GF_GF_IPMPX_Base; @@ -693,7 +693,7 @@ typedef struct GF_Registration *RegDescriptor; /*0 or 1 lang desc*/ GF_Language *langDesc; - + GF_List *IPIDataSet; GF_List *IPMPDescriptorPointers; GF_List *extensionDescriptors; @@ -856,18 +856,18 @@ typedef struct { u16 size; char *data; - /* used of AVC/SVC detection */ - s32 id; + /* used of AVC/SVC detection */ + s32 id; } GF_AVCConfigSlot; -typedef struct +typedef struct { u8 configurationVersion; u8 AVCProfileIndication; u8 profile_compatibility; - u8 AVCLevelIndication; + u8 AVCLevelIndication; u8 nal_unit_size; - + GF_List *sequenceParameterSets; GF_List *pictureParameterSets; @@ -893,7 +893,7 @@ typedef struct } GF_HEVCParamArray; -typedef struct +typedef struct { u8 configurationVersion; u8 profile_space; @@ -919,7 +919,7 @@ typedef struct u8 temporalIdNested; u8 nal_unit_size; - + GF_List *param_array; //set by libisomedia at import/export time @@ -974,7 +974,7 @@ enum GF_ODF_COM_ISO_BEGIN_TAG = 0x0D, GF_ODF_COM_ISO_END_TAG = 0xBF, - + GF_ODF_COM_USER_BEGIN_TAG = 0xC0, GF_ODF_COM_USER_END_TAG = 0xFE }; @@ -1065,7 +1065,7 @@ GF_ODCodec *gf_odf_codec_new(); void gf_odf_codec_del(GF_ODCodec *codec); /* add a command to the codec command list. */ GF_Err gf_odf_codec_add_com(GF_ODCodec *codec, GF_ODCom *command); -/*encode the current command list - once called the commands are removed or destroyed depending on @cleanup_type: +/*encode the current command list - once called the commands are removed or destroyed depending on @cleanup_type: 0: commands are removed from the list but not destroyed 1: commands are removed from the list and destroyed 2: commands are kept in the list and not destroyed @@ -1077,7 +1077,7 @@ GF_Err gf_odf_codec_get_au(GF_ODCodec *codec, char **outAU, u32 *au_length); GF_Err gf_odf_codec_set_au(GF_ODCodec *codec, const char *au, u32 au_length); /*decode the previously set-up AU*/ GF_Err gf_odf_codec_decode(GF_ODCodec *codec); -/*get the first OD command in the list. Once called, the command is removed +/*get the first OD command in the list. Once called, the command is removed from the command list. Return NULL when commandList is empty*/ GF_ODCom *gf_odf_codec_get_com(GF_ODCodec *codec); @@ -1102,7 +1102,7 @@ GF_Err gf_odf_com_del(GF_ODCom **com); GF_Descriptor *gf_odf_desc_new(u8 tag); void gf_odf_desc_del(GF_Descriptor *desc); -/*this is a helper for building a preformatted GF_ESD with decoderConfig, decoderSpecificInfo with no data and +/*this is a helper for building a preformatted GF_ESD with decoderConfig, decoderSpecificInfo with no data and SLConfig descriptor with predefined*/ GF_ESD *gf_odf_desc_esd_new(u32 sl_predefined); @@ -1139,7 +1139,7 @@ GF_Err gf_odf_desc_list_del(GF_List *descList); /*use this function to decode a standalone descriptor the raw descriptor MUST be formatted with tag and size field!!! a new desc is created and you must delete it when done*/ -GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor * *outDesc); +GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor **outDesc); /*use this function to encode a standalone descriptor the desc will be formatted with tag and size field @@ -1155,7 +1155,7 @@ GF_Err gf_odf_desc_copy(GF_Descriptor *inDesc, GF_Descriptor **outDesc); /*This functions handles internally what desc can be added to another desc and adds it. NO DUPLICATION of the descriptor, so -once a desc is added to its parent, destroying the parent WILL DESTROY +once a desc is added to its parent, destroying the parent WILL DESTROY this descriptor*/ GF_Err gf_odf_desc_add_desc(GF_Descriptor *parentDesc, GF_Descriptor *newDesc); @@ -1236,12 +1236,12 @@ OCICodec *gf_oci_codec_new(u8 IsEncoder, u8 Version); void gf_oci_codec_del(OCICodec *codec); /* ENCODER FUNCTIONS -add a command to the codec event list. +add a command to the codec event list. The event WILL BE DESTROYED BY THE CODEC after encoding*/ GF_Err gf_oci_codec_add_event(OCICodec *codec, OCIEvent *event); /*encode AU. The memory allocation is done in place -WARNING: once this function called, the codec event List is empty +WARNING: once this function called, the codec event List is empty and events destroyed you must set *outAU = NULL*/ GF_Err gf_oci_codec_encode(OCICodec *codec, char **outAU, u32 *au_length); @@ -1252,7 +1252,7 @@ GF_Err gf_oci_codec_encode(OCICodec *codec, char **outAU, u32 *au_length); the input buffer is cleared once decoded*/ GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length); -/*get the first OCI Event in the list. Once called, the event is removed +/*get the first OCI Event in the list. Once called, the event is removed from the event list. Return NULL when the event List is empty you MUST delete events */ OCIEvent *gf_oci_codec_get_event(OCICodec *codec); @@ -1319,7 +1319,7 @@ typedef struct /*IPMPX authentication descriptors*/ #define GF_IPMPX_AUTH_DESC \ u8 tag; \ - + typedef struct { GF_IPMPX_AUTH_DESC @@ -1350,7 +1350,7 @@ typedef struct /*IPMP data messages*/ -enum +enum { GF_IPMPX_OPAQUE_DATA_TAG = 0x01, GF_IPMPX_AUDIO_WM_INIT_TAG = 0x02, @@ -1383,7 +1383,7 @@ enum GF_IPMPX_TOOL_API_CONFIG_TAG = 0x1C, /*ISMA*/ - GF_IPMPX_ISMACRYP_TAG = 0xD0, + GF_IPMPX_ISMACRYP_TAG = 0xD0, /*intern ones for parsing (not real datas)*/ GF_IPMPX_TRUSTED_TOOL_TAG = 0xA1, @@ -1403,7 +1403,7 @@ typedef char GF_IPMPX_Date[5]; u8 tag; \ u8 Version; \ u8 dataID; \ - + typedef struct { GF_IPMPX_DATA_BASE @@ -1430,7 +1430,7 @@ typedef struct typedef struct { GF_IPMPX_DATA_BASE - bin128 toolID; + bin128 toolID; GF_IPMPX_Date AuditDate; GF_List *trustSpecifications; } GF_IPMPX_TrustedTool; @@ -1609,7 +1609,7 @@ typedef struct typedef struct { GF_IPMPX_DATA_BASE - GF_IPMPX_ByteArray *rightsInfo; + GF_IPMPX_ByteArray *rightsInfo; } GF_IPMPX_RightsData; @@ -1617,22 +1617,22 @@ typedef struct typedef struct { GF_IPMPX_DATA_BASE - bin128 cipher_Id; + bin128 cipher_Id; u8 syncBoundary; /*block mode if stream cypher info is NULL*/ - u8 mode; + u8 mode; u16 blockSize; u16 keySize; - GF_IPMPX_ByteArray *Stream_Cipher_Specific_Init_Info; + GF_IPMPX_ByteArray *Stream_Cipher_Specific_Init_Info; } GF_IPMPX_SelEncBuffer; /*not a real GF_IPMPX_Data in spec, but emulated as if for parsing*/ typedef struct { GF_IPMPX_DATA_BASE - u8 field_Id; + u8 field_Id; u8 field_Scope; - u8 buf; + u8 buf; u16 mappingTableSize; u16 *mappingTable; @@ -1645,7 +1645,7 @@ enum { GF_IPMPX_SE_MT_ISO_IEC = 0x00, GF_IPMPX_SE_MT_ITU = 0x01 - /*the rest is reserved or forbidden*/ + /*the rest is reserved or forbidden*/ }; /*compliance*/ @@ -1659,12 +1659,12 @@ enum /*0x05-2F ISO Reserved for video*/ GF_IPMPX_SE_COMP_AAC_DF = 0x30, GF_IPMPX_SE_COMP_AAC_NONE = 0x31 - /* - 0x32 - 0x5F ISO Reserved for audio - 0x60 - 0xCF ISO Reserved - 0xD0 - 0xFE User Defined - 0xFF Forbidden - */ + /* + 0x32 - 0x5F ISO Reserved for audio + 0x60 - 0xCF ISO Reserved + 0xD0 - 0xFE User Defined + 0xFF Forbidden + */ }; /*syncBoundary*/ @@ -1675,11 +1675,11 @@ enum GF_IPMPX_SE_SYNC_VIDEO_GOV = 0x02, /*0x03-2F ISO Reserved for video,*/ GF_IPMPX_SE_SYNC_AAC_DF = 0x30 - /*0x31 - 0x5F ISO Reserved for audio - 0x60 - 0xCF ISO Reserved - 0xD0 - 0xFE User Defined - 0xFF Forbidden - */ + /*0x31 - 0x5F ISO Reserved for audio + 0x60 - 0xCF ISO Reserved + 0xD0 - 0xFE User Defined + 0xFF Forbidden + */ }; /*field_Id*/ @@ -1695,19 +1695,19 @@ enum GF_IPMPX_SE_FID_AAC_SIGN = 0x30, GF_IPMPX_SE_FID_AAC_CODEWORDS = 0x31, GF_IPMPX_SE_FID_AAC_SCALE = 0x32 - /*0x32 - 0x5F ISO Reserved for audio - 0x60 - 0xCF ISO Reserved - 0xD0 - 0xFE User Defined - 0xFF Forbidden*/ + /*0x32 - 0x5F ISO Reserved for audio + 0x60 - 0xCF ISO Reserved + 0xD0 - 0xFE User Defined + 0xFF Forbidden*/ }; typedef struct { GF_IPMPX_DATA_BASE - u8 mediaTypeExtension; + u8 mediaTypeExtension; u8 mediaTypeIndication; - u8 profileLevelIndication; + u8 profileLevelIndication; u8 compliance; GF_List *SelEncBuffer; @@ -1753,7 +1753,7 @@ typedef struct char *wmPayload; u16 wmRecipientId; - + u32 opaqueDataSize; char *opaqueData; } GF_IPMPX_WatermarkingInit; diff --git a/include/gpac/mpegts.h b/include/gpac/mpegts.h index b97c7cc..c1cb34e 100644 --- a/include/gpac/mpegts.h +++ b/include/gpac/mpegts.h @@ -10,15 +10,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,7 +64,7 @@ enum GF_M2TS_METADATA_DESCRIPTOR = 0x26, /* ... */ GF_M2TS_AVC_VIDEO_DESCRIPTOR = 0x28, - /* ... */ + /* ... */ GF_M2TS_AVC_TIMING_HRD_DESCRIPTOR = 0x2A, /* ... */ GF_M2TS_SVC_EXTENSION_DESCRIPTOR = 0x30, @@ -110,7 +110,7 @@ enum GF_M2TS_DVB_TIME_SLICE_FEC_DESCRIPTOR = 0x77, /* ... */ GF_M2TS_DVB_EAC3_DESCRIPTOR = 0x7A, - GF_M2TS_DVB_LOGICAL_CHANNEL_DESCRIPTOR = 0x83, + GF_M2TS_DVB_LOGICAL_CHANNEL_DESCRIPTOR = 0x83, }; /* Reserved PID values */ @@ -118,7 +118,7 @@ enum { GF_M2TS_PID_PAT = 0x0000, GF_M2TS_PID_CAT = 0x0001, GF_M2TS_PID_TSDT = 0x0002, - /* reserved 0x0003 to 0x000F */ + /* reserved 0x0003 to 0x000F */ GF_M2TS_PID_NIT_ST = 0x0010, GF_M2TS_PID_SDT_BAT_ST = 0x0011, GF_M2TS_PID_EIT_ST_CIT = 0x0012, @@ -126,7 +126,7 @@ enum { GF_M2TS_PID_TDT_TOT_ST = 0x0014, GF_M2TS_PID_NET_SYNC = 0x0015, GF_M2TS_PID_RNT = 0x0016, - /* reserved 0x0017 to 0x001B */ + /* reserved 0x0017 to 0x001B */ GF_M2TS_PID_IN_SIG = 0x001C, GF_M2TS_PID_MEAS = 0x001D, GF_M2TS_PID_DIT = 0x001E, @@ -136,16 +136,16 @@ enum { /* max size includes first header, second header, payload and CRC */ enum { GF_M2TS_TABLE_ID_PAT = 0x00, - GF_M2TS_TABLE_ID_CAT = 0x01, - GF_M2TS_TABLE_ID_PMT = 0x02, + GF_M2TS_TABLE_ID_CAT = 0x01, + GF_M2TS_TABLE_ID_PMT = 0x02, GF_M2TS_TABLE_ID_TSDT = 0x03, /* max size for section 1024 */ GF_M2TS_TABLE_ID_MPEG4_BIFS = 0x04, /* max size for section 4096 */ GF_M2TS_TABLE_ID_MPEG4_OD = 0x05, /* max size for section 4096 */ - GF_M2TS_TABLE_ID_METADATA = 0x06, - GF_M2TS_TABLE_ID_IPMP_CONTROL = 0x07, + GF_M2TS_TABLE_ID_METADATA = 0x06, + GF_M2TS_TABLE_ID_IPMP_CONTROL = 0x07, /* 0x08 - 0x37 reserved */ /* 0x38 - 0x3D DSM-CC defined */ - GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA = 0x3A, + GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA = 0x3A, GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE = 0x3B, /* used for MPE (only, not MPE-FEC) */ GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE = 0x3C, /* used for MPE (only, not MPE-FEC) */ GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION = 0x3D, /* used for MPE (only, not MPE-FEC) */ @@ -161,7 +161,7 @@ enum { /* 0x4b reserved */ GF_M2TS_TABLE_ID_INT = 0x4c, /* max size for section 4096 */ /* 0x4d reserved */ - + GF_M2TS_TABLE_ID_EIT_ACTUAL_PF = 0x4E, /* max size for section 4096 */ GF_M2TS_TABLE_ID_EIT_OTHER_PF = 0x4F, /* 0x50 - 0x6f EIT SCHEDULE */ @@ -192,7 +192,7 @@ enum GF_M2TS_VIDEO_MPEG1 = 0x01, GF_M2TS_VIDEO_MPEG2 = 0x02, GF_M2TS_AUDIO_MPEG1 = 0x03, - GF_M2TS_AUDIO_MPEG2 = 0x04, + GF_M2TS_AUDIO_MPEG2 = 0x04, GF_M2TS_PRIVATE_SECTION = 0x05, GF_M2TS_PRIVATE_DATA = 0x06, GF_M2TS_MHEG = 0x07, @@ -223,8 +223,8 @@ enum GF_M2TS_AUDIO_DTS = 0x8A, GF_M2TS_MPE_SECTIONS = 0x90, GF_M2TS_SUBTITLE_DVB = 0x100, - - /*internal use*/ + + /*internal use*/ GF_M2TS_AUDIO_EC3 = 0x150, GF_M2TS_VIDEO_VC1 = 0x151, GF_M2TS_DVB_TELETEXT = 0x152, @@ -276,7 +276,7 @@ const char *gf_m2ts_get_stream_name(u32 streamType); /*returns 1 if file is an MPEG-2 TS */ Bool gf_m2ts_probe_file(const char *fileName); -/*shifts all timing by the given value +/*shifts all timing by the given value @is_pes: array of GF_M2TS_MAX_STREAMS u8 set to 1 for PES PIDs to be restamped */ GF_Err gf_m2ts_restamp(char *buffer, u32 size, s64 ts_shift, u8 *is_pes); @@ -284,14 +284,15 @@ GF_Err gf_m2ts_restamp(char *buffer, u32 size, s64 ts_shift, u8 *is_pes); /*PES data framing modes*/ enum { - /*use data framing: recompute start of AUs (data frames)*/ - GF_M2TS_PES_FRAMING_DEFAULT, - /*don't use data framing: all packets are raw PES packets*/ - GF_M2TS_PES_FRAMING_RAW, /*skip pes processing: all transport packets related to this stream are discarded*/ GF_M2TS_PES_FRAMING_SKIP, /*same as GF_M2TS_PES_FRAMING_SKIP but keeps internal PES buffer alive*/ GF_M2TS_PES_FRAMING_SKIP_NO_RESET, + /*don't use data framing: all packets are raw PES packets*/ + GF_M2TS_PES_FRAMING_RAW, + + /*use data framing: recompute start of AUs (data frames)*/ + GF_M2TS_PES_FRAMING_DEFAULT, /*same as defualt PES framing but forces nal-per-nal dispatch for AVC/HEVC (default mode may dispatch complete frames)*/ GF_M2TS_PES_FRAMING_DEFAULT_NAL, }; @@ -383,12 +384,12 @@ enum GF_M2TS_EVT_AIT_FOUND, /*DSCM-CC has been found (carousel) */ GF_M2TS_EVT_DSMCC_FOUND, - + /*a TEMI locator has been found or repeated*/ GF_M2TS_EVT_TEMI_LOCATION, /*a TEMI timecode has been found*/ GF_M2TS_EVT_TEMI_TIMECODE, - + GF_M2TS_EVT_EOS, }; @@ -401,7 +402,7 @@ enum GF_M2TS_TABLE_REPEAT = 1<<4, }; -typedef void (*gf_m2ts_section_callback)(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status); +typedef void (*gf_m2ts_section_callback)(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status); typedef struct __m2ts_demux_section { @@ -447,7 +448,7 @@ typedef struct GF_M2TS_SectionFilter /*section->table aggregator*/ GF_M2TS_Table *table; - + /* indicates that the section and last_section_number do not need to be checked */ Bool process_individual; @@ -458,7 +459,7 @@ typedef struct GF_M2TS_SectionFilter /* this field is used for AIT sections, to link the AIT with the program */ u32 service_id; - gf_m2ts_section_callback process_section; + gf_m2ts_section_callback process_section; } GF_M2TS_SectionFilter; enum metadata_carriage { @@ -508,16 +509,16 @@ typedef struct /*MPEG-2 TS program object*/ -typedef struct +typedef struct { GF_List *streams; - u32 pmt_pid; + u32 pmt_pid; u32 pcr_pid; u32 number; GF_InitialObjectDescriptor *pmt_iod; - /*list of additional ODs found per program !! used by media importer only , refine this !! + /*list of additional ODs found per program !! used by media importer only , refine this !! this list is only created when MPEG-4 over MPEG-2 is detected the list AND the ODs contained in it are destroyed when destroying the demuxer */ @@ -528,7 +529,7 @@ typedef struct /* Last PCR value received for this program and associated packet number */ u64 last_pcr_value; u32 last_pcr_value_pck_number; - /* PCR value before the last received one for this program and associated packet number + /* PCR value before the last received one for this program and associated packet number used to compute PCR interpolation value*/ u64 before_last_pcr_value; u32 before_last_pcr_value_pck_number; @@ -559,7 +560,7 @@ enum GF_M2TS_ES_IS_MPE = 1<<5, /*stream is used to send PCR to upper layer*/ GF_M2TS_INHERIT_PCR = 1<<6, - + /*all flags above this mask are used by importers & co*/ GF_M2TS_ES_STATIC_FLAGS_MASK = 0x0000FFFF, @@ -583,15 +584,15 @@ enum s16 component_tag; \ void *user; \ u64 first_dts; \ - u32 service_id; + u32 service_id; struct tag_m2ts_es { - ABSTRACT_ES + ABSTRACT_ES }; -typedef struct +typedef struct { u8 id; u16 pck_len; @@ -604,7 +605,7 @@ struct tag_m2ts_section_es { ABSTRACT_ES GF_M2TS_SectionFilter *sec; -}; +}; /*******************************************************************************/ @@ -679,7 +680,7 @@ typedef struct tag_m2ts_pes /* Last PCR value received for this program and associated packet number */ u64 last_pcr_value; u32 last_pcr_value_pck_number; - /* PCR value before the last received one for this program and associated packet number + /* PCR value before the last received one for this program and associated packet number used to compute PCR interpolation value*/ u64 before_last_pcr_value; u32 before_last_pcr_value_pck_number; @@ -803,7 +804,7 @@ typedef struct GF_List *extended_events; GF_List *components; GF_List *contents; - GF_List *ratings; + GF_List *ratings; } GF_M2TS_EIT_Event; typedef struct @@ -839,7 +840,7 @@ typedef struct /*MPEG-2 TS demuxer*/ struct tag_m2ts_demux { - /* From M2TSIn */ + /* From M2TSIn */ GF_List *requested_progs; GF_List *requested_pids; @@ -848,7 +849,7 @@ struct tag_m2ts_demux u32 run_state; Bool force_file_refresh; - /*net playing*/ + /*net playing*/ GF_Socket *sock; #ifdef GPAC_HAS_LINUX_DVB @@ -907,12 +908,12 @@ struct tag_m2ts_demux Bool dvb_h_demux; Bool notify_pes_timing; - + /*user callback - MUST NOT BE NULL*/ void (*on_mpe_event)(struct tag_m2ts_demux *ts, u32 evt_type, void *par); /* Structure to hold all the INT tables if the TS contains IP streams */ struct __gf_dvb_mpe_ip_platform *ip_platform; - + u32 pck_number; /*remote file handling - created and destroyed by user*/ @@ -923,7 +924,7 @@ struct tag_m2ts_demux /*AIT*/ GF_List* ChannelAppList; - /*Carousel*/ + /*Carousel*/ Bool process_dmscc; char* dsmcc_root_dir; GF_List* dsmcc_controler; @@ -941,12 +942,14 @@ void gf_m2ts_demux_del(GF_M2TS_Demuxer *ts); void gf_m2ts_reset_parsers(GF_M2TS_Demuxer *ts); GF_ESD *gf_m2ts_get_esd(GF_M2TS_ES *es); GF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode); +u32 gf_m2ts_pes_get_framing_mode(GF_M2TS_PES *pes); void gf_m2ts_es_del(GF_M2TS_ES *es, GF_M2TS_Demuxer *ts); GF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, char *data, u32 data_size); u32 gf_dvb_get_freq_from_url(const char *channels_config_path, const char *url); void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts); +GF_M2TS_SDT *gf_m2ts_get_sdt_info(GF_M2TS_Demuxer *ts, u32 program_id); Bool gf_m2ts_crc32_check(char *data, u32 len); @@ -979,19 +982,19 @@ typedef struct u32 splicing_point_flag; u32 transport_private_data_flag; u32 adaptation_field_extension_flag; -/* - u32 splice_countdown; - u32 transport_private_data_length; - u32 adaptation_field_extension_length; - u32 ltw_flag; - u32 piecewise_rate_flag; - u32 seamless_splice_flag; - u32 ltw_valid_flag; - u32 ltw_offset; - u32 piecewise_rate; - u32 splice_type; - u32 DTS_next_AU; -*/ + /* + u32 splice_countdown; + u32 transport_private_data_length; + u32 adaptation_field_extension_length; + u32 ltw_flag; + u32 piecewise_rate_flag; + u32 seamless_splice_flag; + u32 ltw_valid_flag; + u32 ltw_offset; + u32 piecewise_rate; + u32 splice_type; + u32 DTS_next_AU; + */ } GF_M2TS_AdaptationField; @@ -1071,11 +1074,9 @@ typedef struct __m2ts_mux_stream { /*average stream bit-rate in bit/sec*/ u32 bit_rate; - + /*multiplexer time - NOT THE PCR*/ GF_M2TS_Time time; - /*for PCR strreams, set to 1 when PCR has to be sent, 0 otherwise*/ - u32 pcr_priority; /*table tools*/ GF_M2TS_Mux_Table *tables; @@ -1089,7 +1090,7 @@ typedef struct __m2ts_mux_stream { Bool table_needs_update; Bool table_needs_send; - /*minimal amount of bytes we are allowed to copy frome next AU in the current PES. If no more than this + /*minimal amount of bytes we are allowed to copy frome next AU in the current PES. If no more than this is available in PES, don't copy from next*/ u32 min_bytes_copy_from_next; /*process PES or table update/framing @@ -1108,7 +1109,7 @@ typedef struct __m2ts_mux_stream { u32 pes_data_len, pes_data_remain; Bool force_new; Bool discard_data; - + u32 next_pck_flags; u64 next_pck_cts, next_pck_dts; @@ -1145,7 +1146,7 @@ enum { GF_M2TS_MPEG4_SIGNALING_SCENE }; -typedef struct __m2ts_base_descriptor +typedef struct __m2ts_base_descriptor { u8 tag; u8 data_len; @@ -1169,7 +1170,9 @@ struct __m2ts_mux_program { u64 pcr_init_time, num_pck_at_pcr_init; u64 last_pcr; u64 last_dts; - u32 last_sys_clock; + //high res clock at last PCR + u64 sys_clock_at_last_pcr; + u64 nb_pck_last_pcr; u64 initial_ts; Bool initial_ts_set; Bool pcr_init_time_set; @@ -1181,6 +1184,7 @@ struct __m2ts_mux_program { u32 mpeg4_signaling; Bool mpeg4_signaling_for_scene_only; + char *name, *provider; }; enum @@ -1196,17 +1200,18 @@ enum struct __m2ts_mux { GF_M2TS_Mux_Program *programs; GF_M2TS_Mux_Stream *pat; + GF_M2TS_Mux_Stream *sdt; u16 ts_id; Bool needs_reconfig; - /* used to indicate that the input data is pushed to the muxer (i.e. not read from a file) - or that the output data is sent on sockets (not written to a file) */ + /* used to indicate that the input data is pushed to the muxer (i.e. not read from a file) + or that the output data is sent on sockets (not written to a file) */ Bool real_time; /* indicates if the multiplexer shall target a fix bit rate (monitoring timing and produce padding packets) - or if the output stream will contain only input data*/ + or if the output stream will contain only input data*/ Bool fixed_rate; /*output bit-rate in bit/sec*/ @@ -1215,24 +1220,27 @@ struct __m2ts_mux { /*init value for PCRs on all streams if 0, random value is used*/ u64 init_pcr_value; + u32 pcr_update_ms; + char dst_pck[188], null_pck[188]; /*multiplexer time, incremented each time a packet is sent - used to monitor the sending of muxer related data (PAT, ...) */ - GF_M2TS_Time time; - - /* Time of the muxer when the first call to process is made (first packet sent?) */ - GF_M2TS_Time init_ts_time; - - /* System time when the muxer is started */ - u32 init_sys_time; + used to monitor the sending of muxer related data (PAT, ...) */ + GF_M2TS_Time time; + + /* Time of the muxer when the first call to process is made (first packet sent?) */ + GF_M2TS_Time init_ts_time; + + /* System time high res when the muxer is started */ + u64 init_sys_time; Bool force_pat; Bool one_au_per_pes; Bool eos_found; - u32 pck_sent_over_br_window, last_br_time; + u64 last_br_time_us; + u32 pck_sent_over_br_window; u64 tot_pck_sent, tot_pad_sent, tot_pes_pad_bytes; @@ -1260,10 +1268,13 @@ enum */ GF_M2TS_Mux *gf_m2ts_mux_new(u32 mux_rate, u32 pat_refresh_rate, Bool real_time); void gf_m2ts_mux_del(GF_M2TS_Mux *mux); +//sets max interval between two PCR. Default/max interval is 100 ms +void gf_m2ts_mux_set_pcr_max_interval(GF_M2TS_Mux *muxer, u32 pcr_update_ms); GF_M2TS_Mux_Program *gf_m2ts_mux_program_add(GF_M2TS_Mux *muxer, u32 program_number, u32 pmt_pid, u32 pmt_refresh_rate, u32 pcr_offset, Bool mpeg4_signaling); GF_M2TS_Mux_Stream *gf_m2ts_program_stream_add(GF_M2TS_Mux_Program *program, GF_ESInterface *ifce, u32 pid, Bool is_pcr, Bool force_pes_mode); -void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time); -void gf_m2ts_mux_update_bitrate(GF_M2TS_Mux *mux); +void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time); + +GF_M2TS_Mux_Program *gf_m2ts_mux_program_find(GF_M2TS_Mux *muxer, u32 program_number); const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_next); u32 gf_m2ts_get_sys_clock(GF_M2TS_Mux *muxer); @@ -1276,6 +1287,9 @@ GF_Err gf_m2ts_mux_set_initial_pcr(GF_M2TS_Mux *muxer, u64 init_pcr_value); /*user inteface functions*/ GF_Err gf_m2ts_program_stream_update_ts_scale(GF_ESInterface *_self, u32 time_scale); +void gf_m2ts_mux_program_set_name(GF_M2TS_Mux_Program *program, const char *program_name, const char *mux_provider_name); +void gf_m2ts_mux_enable_sdt(GF_M2TS_Mux *mux, u32 refresh_rate_ms); + #endif /*GPAC_DISABLE_MPEG2TS_MUX*/ @@ -1310,7 +1324,7 @@ struct __gf_dvb_tuner { // DVB buffer size 188x20 -#define DVB_BUFFER_SIZE 3760 +#define DVB_BUFFER_SIZE 3760 #endif //GPAC_HAS_LINUX_DVB diff --git a/include/gpac/network.h b/include/gpac/network.h index f25ea26..a10660f 100644 --- a/include/gpac/network.h +++ b/include/gpac/network.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,14 +35,14 @@ extern "C" { * \brief IP network functions. */ - /*! - * \addtogroup net_grp network - * \ingroup utils_grp - * \brief IP Network Functions - * - *This section documents the IP network functions of the GPAC framework. - * @{ - */ +/*! +* \addtogroup net_grp network +* \ingroup utils_grp +* \brief IP Network Functions +* +*This section documents the IP network functions of the GPAC framework. +* @{ +*/ #include @@ -61,7 +61,7 @@ Bool gf_url_is_local(const char *url); * *Gets the absolute file path from a relative path and its parent absolute one. This can only be used with file paths. *\param pathName the relative path name of a file - *\param parentPath the absolute parent path name + *\param parentPath the absolute parent path name *\return absolute path name of the file, or NULL if bad paths are provided. \note the returned string must be freed by user */ @@ -102,7 +102,7 @@ void gf_url_to_fs_path(char *url); *\brief Extract resource name from URL * * Extracts the resource name from the URL - *\param url input url + *\param url input url *\return resource name. */ const char *gf_url_get_resource_name(const char *url); @@ -111,7 +111,7 @@ const char *gf_url_get_resource_name(const char *url); *\brief Extract resource path from URL * *Extracts the reource path from the URL - *\param url input url + *\param url input url *\param res_path buffer for resulting path storage *\return 1 if path was extracted, 0 if url is a single file name. */ @@ -121,7 +121,7 @@ Bool gf_url_get_resource_path(const char *url, char *res_path); *\brief Remove last delimenter from URL * * Remove last delimenter from URL - *\param sURL input url + *\param sURL input url *\param res_path buffer for resulting path storage *\return GF_TRUE if delimiter was extracted, otherwise GF_FALSE. */ @@ -131,13 +131,19 @@ Bool gf_url_remove_last_delimiter(const char *sURL, char *res_path); *\brief Extract extension from a resource path in URL * * Extract a resource path of URL and analyze its extension - *\param sURL input url + *\param sURL input url *\return The corresponding extension if exists, otherwise NULL. */ const char* gf_url_get_ressource_extension(const char *sURL); /*! - *\brief gets UTC time + *\brief Portable version of UNIX gettimeofday() + */ +struct timeval; +s32 gf_gettimeofday(struct timeval *tp, void *tz); + +/*! + *\brief gets UTC time * *Gets UTC time since midnight Jan 1970 *\param sec number of seconds @@ -155,7 +161,7 @@ void gf_utc_time_since_1970(u32 *sec, u32 *msec); #define GF_NTP_SEC_1900_TO_1970 2208988800ul /*! - *\brief gets NTP time + *\brief gets NTP time * *Gets NTP (Network Time Protocol) in seconds and fractional side \param sec NTP time in seconds @@ -228,7 +234,7 @@ GF_Err gf_sk_set_buffer_size(GF_Socket *sock, Bool send_buffer, u32 new_size); /*! *\brief blocking mode control * - *Sets the blocking mode of a socket on or off. A blocking socket will wait for the net operation to be possible + *Sets the blocking mode of a socket on or off. A blocking socket will wait for the net operation to be possible *while a non-blocking one would return an error. By default, sockets are created in blocking mode *\param sock the socket object *\param NonBlockingOn set to 1 to use on-blocking sockets, 0 otherwise @@ -247,9 +253,9 @@ GF_Err gf_sk_set_block_mode(GF_Socket *sock, Bool NonBlockingOn); */ GF_Err gf_sk_bind(GF_Socket *sock, const char *local_ip, u16 port, const char *peer_name, u16 peer_port, u32 options); /*! - *\brief connects a socket + *\brief connects a socket * - *Connects a socket to a remote peer on a given port + *Connects a socket to a remote peer on a given port *\param sock the socket object *\param peer_name the remote server address (IP or DNS) *\param port remote port number to connect the socket to @@ -267,7 +273,7 @@ GF_Err gf_sk_connect(GF_Socket *sock, const char *peer_name, u16 port, const cha GF_Err gf_sk_send(GF_Socket *sock, const char *buffer, u32 length); /*! *\brief data reception - * + * *Fetches data on a socket. The socket must be in a bound or connected state *\param sock the socket object *\param buffer the recpetion buffer where data is written @@ -279,7 +285,7 @@ GF_Err gf_sk_receive(GF_Socket *sock, char *buffer, u32 length, u32 start_from, /*! *\brief socket listening * - *Sets the socket in a listening state. This socket must have been bound to a port before + *Sets the socket in a listening state. This socket must have been bound to a port before *\param sock the socket object *\param max_conn the maximum number of simultaneous connection this socket will accept */ @@ -294,9 +300,9 @@ GF_Err gf_sk_listen(GF_Socket *sock, u32 max_conn); GF_Err gf_sk_accept(GF_Socket *sock, GF_Socket **new_conn); /*! - *\brief server socket mode + *\brief server socket mode * - *Disable the Nable algo (e.g. set TCP_NODELAY) and set the KEEPALIVE on + *Disable the Nable algo (e.g. set TCP_NODELAY) and set the KEEPALIVE on *\param sock the socket object *\param server_on sets server mode on or off */ diff --git a/include/gpac/nodes_mpeg4.h b/include/gpac/nodes_mpeg4.h index f2371cb..5a7d8f2 100644 --- a/include/gpac/nodes_mpeg4.h +++ b/include/gpac/nodes_mpeg4.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to diff --git a/include/gpac/nodes_svg.h b/include/gpac/nodes_svg.h index 26175bf..f2769fd 100644 --- a/include/gpac/nodes_svg.h +++ b/include/gpac/nodes_svg.h @@ -14,7 +14,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -104,7 +104,7 @@ enum { TAG_SVG_feSpecularLighting, TAG_SVG_feTile, TAG_SVG_feTurbulence, - + TAG_LSR_conditional, TAG_LSR_cursorManager, TAG_LSR_rectClip, @@ -120,7 +120,7 @@ enum { /* TAG names are made of "TAG_SVG_ATT_" + SVG attribute name (with - replaced by _) */ enum { TAG_SVG_ATT_id = TAG_SVG_ATT_RANGE_FIRST, - TAG_SVG_ATT__class, + TAG_SVG_ATT__class, TAG_SVG_ATT_requiredFeatures, TAG_SVG_ATT_requiredExtensions, @@ -518,9 +518,9 @@ struct _all_atts { SVG_Boolean *fullscreen; SVG_Motion *motionTransform; - SVG_Boolean *gpac_useAsPrimary; - SVG_Number *gpac_depthOffset; - SVG_Number *gpac_depthGain; + SVG_Boolean *gpac_useAsPrimary; + SVG_Number *gpac_depthOffset; + SVG_Number *gpac_depthGain; }; #ifdef __cplusplus } diff --git a/include/gpac/nodes_x3d.h b/include/gpac/nodes_x3d.h index 096b345..080954b 100644 --- a/include/gpac/nodes_x3d.h +++ b/include/gpac/nodes_x3d.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to diff --git a/include/gpac/nodes_xbl.h b/include/gpac/nodes_xbl.h index cfcd057..4e0bdff 100644 --- a/include/gpac/nodes_xbl.h +++ b/include/gpac/nodes_xbl.h @@ -4,7 +4,7 @@ * Authors: Cyril Concolato * Copyright (c)2004-2012 Telecom ParisTech - All rights reserved * - * This file is part of GPAC / XBL Elements + * This file is part of GPAC / XBL Elements * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -14,7 +14,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -33,7 +33,7 @@ extern "C" { #include #include -#define XBL_String_datatype SVG_String_datatype +#define XBL_String_datatype SVG_String_datatype struct _all_atts { DOM_String *id; diff --git a/include/gpac/options.h b/include/gpac/options.h index 0c667fc..685962c 100644 --- a/include/gpac/options.h +++ b/include/gpac/options.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -76,7 +76,7 @@ enum /*interaction level settings*/ enum -{ +{ /*regular interactions enabled (touch sensors)*/ GF_INTERACT_NORMAL = 1, /*InputSensor interactions enabled (mouse and keyboard)*/ @@ -106,7 +106,7 @@ enum /*navigation type*/ -enum +enum { /*navigation is disabled by content and cannot be forced by user*/ GF_NAVIGATE_TYPE_NONE, @@ -207,31 +207,31 @@ enum GF_OPT_AUDIO_MUTE, /*get javascript flag (no set, depends on compil) - value: boolean, true if JS enabled in build*/ GF_OPT_HAS_JAVASCRIPT, - /*get selectable stream flag (no set) - value: boolean, true if audio/video/subtitle stream selection is + /*get selectable stream flag (no set) - value: boolean, true if audio/video/subtitle stream selection is possible with content (if an MPEG-4 scene description is not present). Use regular OD browsing to get streams*/ GF_OPT_CAN_SELECT_STREAMS, /*set/get control interaction, OR'ed combination of interaction flags*/ GF_OPT_INTERACTION_LEVEL, /*set display window visible / get show/hide state*/ GF_OPT_VISIBLE, - /*set freeze display on/off / get freeze state freeze_display prevents any screen updates + /*set freeze display on/off / get freeze state freeze_display prevents any screen updates needed when output driver uses direct video memory access*/ GF_OPT_FREEZE_DISPLAY, - /*Returns 1 if file playback is considered as done (all streams finished, no active time sensors + /*Returns 1 if file playback is considered as done (all streams finished, no active time sensors and no user interactions in the scene)*/ GF_OPT_IS_FINISHED, /*Returns 1 if file timeline is considered as done (all streams finished, no active time sensors)*/ GF_OPT_IS_OVER, /*set/get aspect ratio (value: one of AspectRatio enum) */ GF_OPT_ASPECT_RATIO, - /*send a redraw message (SetOption only): all graphics info (display list, vectorial path) is + /*send a redraw message (SetOption only): all graphics info (display list, vectorial path) is recomputed, and textures are reloaded in HW*/ GF_OPT_REFRESH, /*set/get stress mode (value: boolean) - in stress mode a GF_OPT_FORCE_REDRAW is emulated at each frame*/ GF_OPT_STRESS_MODE, /*get/set bounding volume drawing (value: one of the above option)*/ GF_OPT_DRAW_BOUNDS, - /*get/set texture text option - when enabled and usable (that depends on content), text is first rendered + /*get/set texture text option - when enabled and usable (that depends on content), text is first rendered to a texture and only the texture is drawn, rather than drawing all the text each time (CPU intensive)*/ GF_OPT_TEXTURE_TEXT, /*fake option, reload config file (set only), including drivers. Plugins configs are not reloaded*/ @@ -251,7 +251,7 @@ enum /*get/set OpenGL force mode - returns error if OpenGL is not supported*/ GF_OPT_USE_OPENGL, - /*set/get draw mode. + /*set/get draw mode. In immediate mode, the screen is entirely redrawn at each frame In defer mode, only the changed ares are redrawn In defer-debug mode, unchanged areas are erased and changed ares are redrawn @@ -271,9 +271,9 @@ enum /*max HTTP download rate in bits per second, 0 if no limit*/ GF_OPT_HTTP_MAX_RATE, - + /* 3D ONLY OPTIONS */ - /*set/get raster outline flag (value: boolean) - when set, no vectorial outlining is done, only + /*set/get raster outline flag (value: boolean) - when set, no vectorial outlining is done, only openGL raster outline*/ GF_OPT_RASTER_OUTLINES, /*set/get pow2 emulation flag (value: boolean) - when set, video textures with non power of 2 dimensions @@ -288,11 +288,9 @@ enum GF_OPT_NORMALS, /*disable backface culling*/ GF_OPT_BACK_CULL, - /*get/set RECT Ext flag (value: boolean) - when set, GL rectangular texture extension is not used + /*get/set RECT Ext flag (value: boolean) - when set, GL rectangular texture extension is not used (but NPO2 texturing is if available)*/ GF_OPT_NO_RECT_TEXTURE, - /*get/set bitmap draw mode. If set, bitmap doesn't use texturing but direct video copy*/ - GF_OPT_BITMAP_COPY, /*set/get headlight (value: boolean)*/ GF_OPT_HEADLIGHT, /*set/get collision (value: cf above)*/ diff --git a/include/gpac/path2d.h b/include/gpac/path2d.h index 4f86a35..7ed62c8 100644 --- a/include/gpac/path2d.h +++ b/include/gpac/path2d.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,11 +47,11 @@ extern "C" { *\ingroup utils_grp *\brief Vectorial 2D Path manipulation functions * - *This section documents the 2D path object used in the GPAC framework. + *This section documents the 2D path object used in the GPAC framework. * @{ */ - + /*!\brief 2D Path Object * *The 2D path object is used to construct complex 2D shapes for later drawing @@ -217,7 +217,7 @@ GF_Err gf_path_add_rect_center(GF_Path *gp, Fixed cx, Fixed cy, Fixed w, Fixed h * * Adds a rectangle contour to the path * \param gp the target path - * \param ox left-most coordinate of the rectangle + * \param ox left-most coordinate of the rectangle * \param oy top-most coordinate of the rectangle * \param w width of the rectangle * \param h height of the rectangle @@ -270,7 +270,7 @@ GF_Err gf_path_add_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed fa_x, Fix * \param end_x x-coordinate of the arc end point * \param end_y y-coordinate of the arc end point * \param r_x x-axis radius - * \param r_y y-axis radius + * \param r_y y-axis radius * \param x_axis_rotation angle for the x-axis * \param large_arc_flag large or short arc selection * \param sweep_flag if 1, the arc will be clockwise, otherwise counter-clockwise. @@ -282,7 +282,7 @@ GF_Err gf_path_add_svg_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, * * Adds an arc contour to the path. * \param gp the target path - * \param radius radius of the arc + * \param radius radius of the arc * \param start_angle start angle of the arc in radians * \param end_angle end angle of the arc in radians * \param close_type closing type: 0 for open arc, 1 for close arc, 2 for pie @@ -296,7 +296,7 @@ GF_Err gf_path_add_arc(GF_Path *gp, Fixed radius, Fixed start_angle, Fixed end_a * Adds a sub-path to the path with a given transform. * \param gp the target path * \param subpath the path to add - * \param mx Matrix for subpath + * \param mx Matrix for subpath * \return error code if any error, \ref GF_OK otherwise */ GF_Err gf_path_add_subpath(GF_Path *gp, GF_Path *subpath, GF_Matrix2D *mx); @@ -319,14 +319,14 @@ GF_Err gf_path_get_control_bounds(GF_Path *gp, GF_Rect *rc); */ GF_Err gf_path_get_bounds(GF_Path *gp, GF_Rect *rc); /*! - * \brief flattens path + * \brief flattens path * * Flattens the path, i.e. transform all bezier curves to lines according to the path flatness. * \param gp the target path */ void gf_path_flatten(GF_Path *gp); /*! - * \brief gets flatten copy of path + * \brief gets flatten copy of path * * Gets a flatten copy of the path. * \param gp the target path @@ -354,7 +354,7 @@ Bool gf_path_point_over(GF_Path *gp, Fixed x, Fixed y); Bool gf_path_is_empty(GF_Path *gp); /*! - * \brief path iterator + * \brief path iterator * * The path iterator object is used to compute the length of a given path as well * as transformation matrices along this path. @@ -388,8 +388,8 @@ Fixed gf_path_iterator_get_length(GF_PathIterator *it); /*! *\brief gets transformation matrix at given point on path * - * Gets the transformation of a given point on the path, given by offset from origin. - *The transform is so that a local system is translated to the given point, its x-axis tangent + * Gets the transformation of a given point on the path, given by offset from origin. + *The transform is so that a local system is translated to the given point, its x-axis tangent *to the path and in the same direction. The path direction is from first point to last point *of the path. * \param it the target path iterator @@ -397,7 +397,7 @@ Fixed gf_path_iterator_get_length(GF_PathIterator *it); * \param follow_tangent indicates if transformation shall be computed if offset indicates a point outside the path (<0 or >path_length). In which case the path shall be virtually extended by the tangent at origin (offset <0) or at end (offset>path_length). Otherwise the transformation is not computed and 0 is returned. * \param mat matrix to be transformed (transformation shall be appended) - the matrix shall not be initialized * \param smooth_edges indicates if discontinuities shall be smoothed. If not set, the rotation angle THETA is the slope (DX/DY) of the current segment found. - * \param length_after_point if set and smooth_edges is set, the amount of the object that lies on next segment shall be computed according to length_after_point. + * \param length_after_point if set and smooth_edges is set, the amount of the object that lies on next segment shall be computed according to length_after_point. \code Let: len_last: length of current checked segment @@ -405,7 +405,7 @@ Fixed gf_path_iterator_get_length(GF_PathIterator *it); ratio = (len1 + len_last - offset) / length_after_point; then THETA = ratio * slope(L1) + (1-ratio) * slope(L2) - Of course care must be taken for PI/2 angles and similar situations + Of course care must be taken for PI/2 angles and similar situations \endcode * \return 1 if matrix has been updated, 0 otherwise, if failure or if point is out of path without tangent extension. @@ -451,7 +451,7 @@ enum { /*! Path is filled using the zero-nonzero rule. If not set, filling uses odd/even rule*/ GF_PATH_FILL_ZERO_NONZERO = 1, - /*! When set bbox must be recomputed. + /*! When set bbox must be recomputed. \note Read only, used to avoid wasting time on bounds calculation*/ GF_PATH_BBOX_DIRTY = 2, /*! Indicates the path is flattened flattened @@ -484,7 +484,7 @@ enum * \hideinitializer */ enum -{ +{ /*! outline is centered on the path (default)*/ GF_PATH_LINE_CENTER = 0, /*! outline is inside the path*/ @@ -563,11 +563,11 @@ typedef struct u32 num_dash; /*! Value of the pattern dashes. Unit depends on the dash type*/ Fixed *dashes; - /*! SVG/CSS unit for the dashes */ - u8 *dash_units; + /*! SVG/CSS unit for the dashes */ + u8 *dash_units; } GF_DashSettings; -/*!\brief Pen properties +/*!\brief Pen properties * *The pen properties object is used to specify several parameters used when building *the vectorial outline of a path. @@ -586,7 +586,7 @@ typedef struct u8 dash; /*! The miter limit of the line joins*/ Fixed miterLimit; - /*! The initial dash offset in the outline. All points before this offset will be + /*! The initial dash offset in the outline. All points before this offset will be * ignored when building the outline*/ Fixed dash_offset; /*! The dash pattern used for curstom dashing*/ @@ -600,7 +600,7 @@ typedef struct * Builds the vectorial outline of a path for the given settings. The outline of a path is a path. * \param path the desired path to outline * \param pen the properties of the virtual pen used for outlining - * \return the outline of the path + * \return the outline of the path */ GF_Path *gf_path_get_outline(GF_Path *path, GF_PenSettings pen); diff --git a/include/gpac/ringbuffer.h b/include/gpac/ringbuffer.h index c7d4c2f..bec75ca 100644 --- a/include/gpac/ringbuffer.h +++ b/include/gpac/ringbuffer.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,12 +35,12 @@ extern "C" { typedef struct { - u8 *buf; - volatile u32 write_ptr; - volatile u32 read_ptr; - u32 size; - u32 size_mask; - GF_Mutex * mx; + u8 *buf; + volatile u32 write_ptr; + volatile u32 read_ptr; + u32 size; + u32 size_mask; + GF_Mutex * mx; } GF_Ringbuffer ; @@ -54,7 +54,7 @@ GF_Ringbuffer ; * \return a pointer to a new ringbuffer if successful, NULL otherwise. */ GF_Ringbuffer * gf_ringbuffer_new(u32 sz); - + /*! * Frees a previously allocated ringbuffer * \param ringbuffer The ringbuffer to free @@ -87,7 +87,7 @@ u32 gf_ringbuffer_available_for_read (GF_Ringbuffer * rb); * \return Returns the actual number of bytes copied, may be lower than sz if ringbuffer is already full */ u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u8 * src, u32 sz); - + #ifdef __cplusplus } #endif diff --git a/include/gpac/rtp_streamer.h b/include/gpac/rtp_streamer.h index f7d3b60..a607025 100644 --- a/include/gpac/rtp_streamer.h +++ b/include/gpac/rtp_streamer.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,7 +47,7 @@ extern "C" { #include #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_ISOM) - + typedef struct __rtp_streamer GF_RTPStreamer; /*! @@ -60,17 +60,17 @@ typedef struct __rtp_streamer GF_RTPStreamer; *\param ip_dest IP address of the destination *\param port port number of the destination *\param MTU Maximum Transmission Unit size to use - *\param TTL Time To Leave + *\param TTL Time To Leave *\param ifce_addr IP of the local interface to use (may be NULL) - *\param flags + *\param flags *\param dsi MPEG-4 Decoder Specific Info for the stream *\param dsi_len length of the dsi parameter *\return new object */ -GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, - const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, - u32 flags, char *dsi, u32 dsi_len); +GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, + const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, + u32 flags, char *dsi, u32 dsi_len); /*! * \brief RTP Streamer constructor with extended parameters @@ -82,9 +82,9 @@ GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, *\param ip_dest IP address of the destination *\param port port number of the destination *\param MTU Maximum Transmission Unit size to use - *\param TTL Time To Leave + *\param TTL Time To Leave *\param ifce_addr IP of the local interface to use (may be NULL) - *\param flags + *\param flags *\param dsi MPEG-4 Decoder Specific Info for the stream *\param dsi_len length of the dsi parameter *\param PayloadType RTP payload type @@ -92,24 +92,24 @@ GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, *\param nb_ch number of channels in audio streams *\param is_crypted Boolean indicating if the stream is crypted *\param IV_length lenght of the Initialisation Vector used for encryption - *\param KI_length length of the key index - *\param MinSize - *\param MaxSize - *\param avgTS - *\param maxDTSDelta - *\param const_dur - *\param bandwidth - *\param max_ptime + *\param KI_length length of the key index + *\param MinSize + *\param MaxSize + *\param avgTS + *\param maxDTSDelta + *\param const_dur + *\param bandwidth + *\param max_ptime *\param au_sn_len length of the MPEG-4 SL descriptor AU sequence number field *\return new object */ -GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale, - const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, - u32 flags, char *dsi, u32 dsi_len, - u32 PayloadType, u32 sample_rate, u32 nb_ch, - Bool is_crypted, u32 IV_length, u32 KI_length, - u32 MinSize, u32 MaxSize, u32 avgTS, u32 maxDTSDelta, u32 const_dur, u32 bandwidth, u32 max_ptime, - u32 au_sn_len); +GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale, + const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, + u32 flags, char *dsi, u32 dsi_len, + u32 PayloadType, u32 sample_rate, u32 nb_ch, + Bool is_crypted, u32 IV_length, u32 KI_length, + u32 MinSize, u32 MaxSize, u32 avgTS, u32 maxDTSDelta, u32 const_dur, u32 bandwidth, u32 max_ptime, + u32 au_sn_len); /*! * \brief RTP file streamer destructor diff --git a/include/gpac/scene_engine.h b/include/gpac/scene_engine.h index 4a90e59..560257e 100644 --- a/include/gpac/scene_engine.h +++ b/include/gpac/scene_engine.h @@ -5,21 +5,21 @@ * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * - * This file is part of GPAC + * This file is part of GPAC * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,7 +44,7 @@ typedef void (*gf_seng_callback)(void *udta, u16 ESID, char *data, u32 size, u64 * \param calling_object is the calling object on which call back will be called * \param inputContext is the name of a scene file (bt, xmt or mp4) to initialize the coding context * \param load_type is the prefered loader type for the content (e.g. SVG vs DIMS) - * \param dump_path is the path where scenes are dumped + * \param dump_path is the path where scenes are dumped * \param embed_resources indicates if images and scripts should be encoded inlined with the content * * must be called only one time (by process calling the DLL) before other calls @@ -58,7 +58,7 @@ GF_SceneEngine *gf_seng_init(void *calling_object, char *inputContext, u32 load_ * \param width width of scene if no IOD is given in the context. * \param height height of scene if no IOD is given in the context. * \param usePixelMetrics metrics system used in the scene, if no IOD is given in the context. - * \param dump_path the path where scenes are dumped + * \param dump_path the path where scenes are dumped * * must be called only one time (by process calling the DLL) before other calls */ @@ -68,7 +68,7 @@ GF_SceneEngine *gf_seng_init_from_string(void *calling_object, char *inputContex /** * \param calling_object the calling object on which call back will be called * \param ctx an already loaded scene manager - * \param dump_path the path where scenes are dumped + * \param dump_path the path where scenes are dumped * * must be called only one time (by process calling the DLL) before other calls */ @@ -84,7 +84,7 @@ u32 gf_seng_get_stream_count(GF_SceneEngine *seng); /** * \param seng pointer to the GF_SceneEngine returned by gf_seng_init() * \param ESID ID of the stream - * \param carousel_period pointer to store the carousel_period + * \param carousel_period pointer to store the carousel_period * \param aggregate_on_es_id pointer to store the target carousel stream ID * * must be called after gf_seng_init() @@ -103,7 +103,7 @@ GF_Err gf_seng_get_stream_carousel_info(GF_SceneEngine *seng, u16 ESID, u32 *car * * must be called after gf_seng_init() */ -GF_Err gf_seng_get_stream_config(GF_SceneEngine *seng, u32 idx, u16 *ESID, char * * const config, u32 *config_len, u32 *streamType, u32 *objectType, u32 *timeScale); +GF_Err gf_seng_get_stream_config(GF_SceneEngine *seng, u32 idx, u16 *ESID, char ** const config, u32 *config_len, u32 *streamType, u32 *objectType, u32 *timeScale); /** * Encodes the AU context which is not encoded when calling BENC_EncodeAUFromString/File @@ -118,7 +118,7 @@ GF_Err gf_seng_encode_context(GF_SceneEngine *seng, gf_seng_callback callback); /** * \param seng pointer to the GF_SceneEngine returned by gf_seng_init() * \param ESID target streams when no indication is present in the file (eg, no atES_ID ) - * \param disable_aggregation + * \param disable_aggregation * \param auFile name of a file containing a description for an access unit (BT or XMT) * \param callback pointer on a callback function to get the result of the coding the AU using the current context * @@ -128,7 +128,7 @@ GF_Err gf_seng_encode_from_file(GF_SceneEngine *seng, u16 ESID, Bool disable_agg /** * \param seng pointer to the GF_SceneEngine returned by gf_seng_init() * \param ESID target streams when no indication is present in the file (eg, no atES_ID ) - * \param disable_aggregation + * \param disable_aggregation * \param auString a char string to encode (must one or several complete nodes in BT * \param callback pointer on a callback function to get the result of the coding the AU using the current context * @@ -138,7 +138,7 @@ GF_Err gf_seng_encode_from_string(GF_SceneEngine *seng, u16 ESID, Bool disable_a /** * \param seng pointer to the GF_SceneEngine returned by gf_seng_init() * \param ESID indicates the stream to which these commands apply (0 if first scene stream) - * \param disable_aggregation + * \param disable_aggregation * \param time * \param commands the list of commands to encode * \param callback pointer on a callback function to get the result of the coding the AU using the current context @@ -161,7 +161,7 @@ GF_Err gf_seng_save_context(GF_SceneEngine *seng, char *ctxFileName); * \param ESID stream ID * \param onESID set stream aggragation on to the specified stream, or off if onESID is 0 * - * marks the stream as carrying its own "rap" in the first AU of the stream + * marks the stream as carrying its own "rap" in the first AU of the stream */ GF_Err gf_seng_enable_aggregation(GF_SceneEngine *seng, u16 ESID, u16 onESID); diff --git a/include/gpac/scene_manager.h b/include/gpac/scene_manager.h index e7db68d..348e1a1 100644 --- a/include/gpac/scene_manager.h +++ b/include/gpac/scene_manager.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,7 +58,7 @@ enum /*generic systems access unit context*/ typedef struct -{ +{ /*AU timing in TimeStampResolution*/ u64 timing; /*timing in sec - used if timing isn't set*/ @@ -104,7 +104,7 @@ typedef struct _stream_context } GF_StreamContext; /*generic presentation context*/ -typedef struct +typedef struct { /*the one and only scene graph used by the scene manager.*/ GF_SceneGraph *scene_graph; @@ -131,7 +131,7 @@ GF_SceneManager *gf_sm_new(GF_SceneGraph *scene_graph); /*scene manager destructor - does not destroy the attached scene graph*/ void gf_sm_del(GF_SceneManager *ctx); /*retrive or create a stream context in the presentation context -WARNING: if a stream with the same streamType and no ESID already exists in the context, +WARNING: if a stream with the same streamType and no ESID already exists in the context, it is assigned the requested ES_ID - this is needed to solve base layer*/ GF_StreamContext *gf_sm_stream_new(GF_SceneManager *ctx, u16 ES_ID, u8 streamType, u8 objectType); /*removes and destroy stream context from presentation context*/ @@ -143,8 +143,8 @@ GF_AUContext *gf_sm_stream_au_new(GF_StreamContext *stream, u64 timing, Double t GF_MuxInfo *gf_sm_get_mux_info(GF_ESD *src); -/*reset the context: -- purge all access units on all streams +/*reset the context: +- purge all access units on all streams - destroy root OD */ void gf_sm_reset(GF_SceneManager *ctx); @@ -194,7 +194,7 @@ enum { /*if set, always load MPEG-4 nodes, otherwise X3D versions are used for vrml/x3d*/ GF_SM_LOAD_MPEG4_STRICT = 1, - /*signal loading is done for playback: + /*signal loading is done for playback: scrips will be queued in their parent command for later loading SFTime (MPEG-4 only) fields will be handled correctly when inserting/creating nodes based on AU timing */ @@ -213,7 +213,7 @@ enum /*loader type, usually detected based on file ext*/ enum -{ +{ GF_SM_LOAD_BT = 1, /*BT loader*/ GF_SM_LOAD_VRML, /*VRML97 loader*/ GF_SM_LOAD_X3DV, /*X3D VRML loader*/ @@ -230,7 +230,7 @@ enum typedef struct __scene_loader GF_SceneLoader; -struct __scene_loader +struct __scene_loader { /*loader type, one of the above value. If not set, detected based on file extension*/ u32 type; @@ -240,7 +240,7 @@ struct __scene_loader struct _scene *is; - /*context manager to load (MUST BE RESETED BEFORE if needed) - may be NULL for loaders not using commands, + /*context manager to load (MUST BE RESETED BEFORE if needed) - may be NULL for loaders not using commands, in which case the graph will be directly updated*/ GF_SceneManager *ctx; /*file to import except IsoMedia files*/ @@ -251,7 +251,7 @@ struct __scene_loader #endif /*swf import flags*/ u32 swf_import_flags; - /*swf flatten limit: angle limit below which 2 lines are considered as aligned, + /*swf flatten limit: angle limit below which 2 lines are considered as aligned, in which case the lines are merged as one. If 0, no flattening happens*/ Float swf_flatten_limit; /*swf extraction path: if set, swf media (mp3, jpeg) are extracted to this path. If not set @@ -282,9 +282,9 @@ GF_Err gf_sm_load_suspend(GF_SceneLoader *load, Bool suspend); /*parses memory scene (any textural format) into the context !! THE LOADER TYPE MUST BE ASSIGNED (BT/WRL/XMT/X3D/SVG only) !! -The string MUST be at least 4 bytes long in order to detect BOM (unicode encoding). +The string MUST be at least 4 bytes long in order to detect BOM (unicode encoding). The string can ba either UTF-8 or UTF-16 data -if clean_at_end is set, associated parser is destroyed. Otherwise, a call to gf_sm_load_done must be done +if clean_at_end is set, associated parser is destroyed. Otherwise, a call to gf_sm_load_done must be done to clean ressources (needed for SAX progressive loading) */ GF_Err gf_sm_load_string(GF_SceneLoader *load, const char *str, Bool clean_at_end); @@ -367,7 +367,7 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode); typedef struct _scenedump GF_SceneDumper; -/*create a scene dumper +/*create a scene dumper @graph: scene graph being dumped @rad_name: file radical (NULL for stdout) - if not NULL MUST BE GF_MAX_PATH length @indent_char: indent format @@ -389,7 +389,7 @@ char *gf_sm_dump_get_name(GF_SceneDumper *bd); */ GF_Err gf_sm_dump_command_list(GF_SceneDumper *sdump, GF_List *comList, u32 indent, Bool skip_first_replace); -/*dumps complete graph - +/*dumps complete graph - @skip_proto: proto declarations are skipped @skip_routes: routes are not dumped */ @@ -420,7 +420,7 @@ typedef struct _scenestat GF_List *node_stats; GF_List *proto_stats; - + /*ranges of all SFVec2fs for points only (MFVec2fs)*/ SFVec2f max_2d, min_2d; /* resolution of 2D points (nb bits for integer part and decimal part)*/ diff --git a/include/gpac/scenegraph.h b/include/gpac/scenegraph.h index 05322e8..4213f02 100644 --- a/include/gpac/scenegraph.h +++ b/include/gpac/scenegraph.h @@ -2,7 +2,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -12,15 +12,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -53,7 +53,7 @@ enum { GF_NODE_RANGE_LAST_MPEG4 = GF_NODE_RANGE_FIRST_MPEG4+512, /*range for X3D*/ - GF_NODE_RANGE_FIRST_X3D, + GF_NODE_RANGE_FIRST_X3D, GF_NODE_RANGE_LAST_X3D = GF_NODE_RANGE_FIRST_X3D+512, /*all nodes after this are always parent nodes*/ @@ -69,16 +69,16 @@ enum { TAG_DOMText, /*all nodes below MUST use the base DOM structure (with dyn attribute list)*/ GF_NODE_FIRST_DOM_NODE_TAG, - + /*full node*/ TAG_DOMFullNode = GF_NODE_FIRST_DOM_NODE_TAG, /*range for SVG*/ - GF_NODE_RANGE_FIRST_SVG, + GF_NODE_RANGE_FIRST_SVG, GF_NODE_RANGE_LAST_SVG = GF_NODE_RANGE_FIRST_SVG+100, /*range for XBL*/ - GF_NODE_RANGE_FIRST_XBL, + GF_NODE_RANGE_FIRST_XBL, TAG_XBL_bindings = GF_NODE_RANGE_FIRST_XBL, TAG_XBL_binding, TAG_XBL_content, @@ -156,7 +156,7 @@ GF_Node *gf_node_list_del_child_idx(GF_ChildNodeItem **list, u32 pos); /*tag is set upon creation and cannot be modified*/ u32 gf_node_get_tag(GF_Node*); /*set node def - @ID: node ID, !=0 set def node - if a different node with the same ID exists, returns error. + @ID: node ID, !=0 set def node - if a different node with the same ID exists, returns error. You may change the node ID by recalling the function with a different ID value. You may get a node ID by calling the gf_sg_get_next_available_node_id function @defName: optional readable name (script, MPEGJ). To change the name, recall the function with a different name and the same ID @@ -180,7 +180,7 @@ GF_Err gf_node_remove_id(GF_Node *p); void *gf_node_get_private(GF_Node*); void gf_node_set_private(GF_Node*, void *); -/*set traversal callback function. If a node has no associated callback, the traversing of the +/*set traversal callback function. If a node has no associated callback, the traversing of the graph won't propagate below it. It is the app responsability to setup traversing functions as needed VRML/MPEG4: Instanciated Protos are handled internally as well as interpolators, valuators and scripts @is_destroy: set when the node is about to be destroyed @@ -188,7 +188,7 @@ VRML/MPEG4: Instanciated Protos are handled internally as well as interpolators GF_Err gf_node_set_callback_function(GF_Node *, void (*NodeFunction)(GF_Node *node, void *traverse_state, Bool is_destroy) ); /*register a node (DEFed or not), specifying parent if any. -A node must be registered whenever used by something (a parent node, a command, whatever) to prevent its +A node must be registered whenever used by something (a parent node, a command, whatever) to prevent its destruction (think of it as a reference counting). NOTE: NODES ARE CREATED WITHOUT BEING REGISTERED */ @@ -197,7 +197,7 @@ GF_Err gf_node_register(GF_Node *node, GF_Node *parent_node); /*unregister a node from parent (node may or not be DEF'ed). Parent may be NULL (DEF root node, commands). This MUST be called whenever a node is destroyed (removed from a parent node) If this is the last instance of the node, the node is destroyed -NOTE: NODES ARE CREATED WITHOUT BEING REGISTERED, hence they MUST be registered at least once before +NOTE: NODES ARE CREATED WITHOUT BEING REGISTERED, hence they MUST be registered at least once before being destroyed */ GF_Err gf_node_unregister(GF_Node *node, GF_Node *parent_node); @@ -214,7 +214,7 @@ u32 gf_node_get_num_instances(GF_Node *node); /*calls node traverse callback routine on this node*/ void gf_node_traverse(GF_Node *node, void *udta); -/*allows a node to be re-rendered - by default a node in its render phase will never be retraversed a second time. +/*allows a node to be re-rendered - by default a node in its render phase will never be retraversed a second time. Use this function to enable a second traverse for this node while traversing the node*/ void gf_node_allow_cyclic_traverse(GF_Node *node); @@ -242,7 +242,7 @@ enum if relying on this flag for sub-tree discarding (eg, culling or similar)*/ GF_SG_CHILD_DIRTY = 1<<1, - /*flag set by bindable nodes to indicate a modification of the bindable stack. This is + /*flag set by bindable nodes to indicate a modification of the bindable stack. This is only used for offscreen rendering of Layer3D*/ GF_SG_VRML_BINDABLE_DIRTY = 1<<2, @@ -310,7 +310,7 @@ void gf_node_dirty_reset(GF_Node *node, Bool reset_children); u32 gf_node_dirty_get(GF_Node *node); /*Notes on GF_FieldInfo -all scene graph implementations should answer node field query with this interface. +all scene graph implementations should answer node field query with this interface. In case an implementation does not use this: - the implementation shall handle the parent node dirty flag itself most of the time - the implementation shall NOT allow referencing of a graph node in a parent graph node (when inlining @@ -322,7 +322,7 @@ typedef struct _route GF_Route; /*other fieldTypes may be ignored by implmentation not using VRML/MPEG4 native types*/ typedef struct -{ +{ /*0-based index of the field in the node*/ u32 fieldIndex; /*field type - VRML/MPEG4 types are listed in scenegraph_vrml.h*/ @@ -353,10 +353,10 @@ typedef struct __tag_scene_graph GF_SceneGraph; /*scene graph constructor*/ GF_SceneGraph *gf_sg_new(); -/*creates a sub scene graph (typically used with Inline node): independent graph with same private stack, -and user callbacks as parent. All routes triggered in this subgraph are executed in the parent graph (this +/*creates a sub scene graph (typically used with Inline node): independent graph with same private stack, +and user callbacks as parent. All routes triggered in this subgraph are executed in the parent graph (this means you only have to activate routes on the main graph) -NOTE: the resulting graph is not destroyed when the parent graph is +NOTE: the resulting graph is not destroyed when the parent graph is */ GF_SceneGraph *gf_sg_new_subscene(GF_SceneGraph *scene); @@ -377,7 +377,7 @@ void gf_sg_set_scene_time_callback(GF_SceneGraph *scene, Double (*GetSceneTime)( enum { - /*function called upon node creation. + /*function called upon node creation. ctxdata is not used*/ GF_SG_CALLBACK_INIT = 0, /*function called upon node modification. You typically will set some of the dirty flags here. @@ -390,7 +390,7 @@ enum GF_SG_CALLBACK_NODE_DESTROY, }; -/*set node callback: function called upon node creation. +/*set node callback: function called upon node creation. Application should instanciate the node rendering stack and any desired callback*/ void gf_sg_set_node_callback(GF_SceneGraph *sg, void (*NodeCallback)(void *user_priv, u32 type, GF_Node *node, void *ctxdata) ); @@ -403,7 +403,7 @@ GF_Node *gf_sg_find_node(GF_SceneGraph *sg, u32 nodeID); /*finds a registered node by DEF name*/ GF_Node *gf_sg_find_node_by_name(GF_SceneGraph *sg, char *name); -/*used to signal modification of a node, indicating which field is modified - exposed for BIFS codec, +/*used to signal modification of a node, indicating which field is modified - exposed for BIFS codec, should not be needed by other apps*/ void gf_node_changed(GF_Node *node, GF_FieldInfo *fieldChanged); @@ -430,7 +430,7 @@ void gf_node_init(GF_Node *node); /*clones a node in the given graph and register with parent cloned. The cloning handles ID based on id_suffix: id_suffix = NULL: all IDs are removed from the cloned subtree, (each node instance will become a hard copy) - id_suffix = "": ID will be kept exactly as they where in the original subtree - this may lead to errors due to + id_suffix = "": ID will be kept exactly as they where in the original subtree - this may lead to errors due to the presence of the same ID depending on the standard (DOM, ...). id_suffix = anything: all IDs are translated ($(name) -> $(name)id_suffix) and bynary IDs are generated on the fly */ @@ -464,8 +464,8 @@ enum typedef struct { - /*for GF_JSAPI_OP_RESOLVE_URI, - set by caller to the URI to resolve. + /*for GF_JSAPI_OP_RESOLVE_URI, + set by caller to the URI to resolve. If NULL, the return URI is the unresolved parent scene one. Otherwise, the input URL will be reolved to its local name (eg for ZIP/... packages) upon return, ALLOCATED by the callee and must be freed by the caller @@ -482,7 +482,7 @@ typedef struct const char *key_val; } GF_JSAPIOPT; - /*for script message option*/ +/*for script message option*/ typedef struct { GF_Err e; @@ -604,8 +604,8 @@ char *gf_node_dump_attribute(GF_Node *elt, GF_FieldInfo *info); /* scene graph command tools used for BIFS and LASeR - These are used to store updates in memory without applying changes to the graph, - for dumpers, encoders ... + These are used to store updates in memory without applying changes to the graph, + for dumpers, encoders ... The commands can then be applied through this lib */ @@ -621,7 +621,7 @@ enum /*BIFS commands*/ GF_SG_SCENE_REPLACE, GF_SG_NODE_REPLACE, - GF_SG_FIELD_REPLACE, + GF_SG_FIELD_REPLACE, GF_SG_INDEXED_REPLACE, GF_SG_ROUTE_REPLACE, GF_SG_NODE_DELETE, @@ -641,7 +641,7 @@ enum GF_SG_NODE_DELETE_EX, /*BIFS*/ - GF_SG_XREPLACE, + GF_SG_XREPLACE, #endif GF_SG_LAST_BIFS_COMMAND, @@ -668,8 +668,8 @@ enum /* single command wrapper - NOTE: In order to maintain node registry, the nodes replaced/inserted MUST be registered with - their parents even when the command is never applied. Registering shall be performed + NOTE: In order to maintain node registry, the nodes replaced/inserted MUST be registered with + their parents even when the command is never applied. Registering shall be performed with gf_node_register (see below). If you fail to do so, a node may be destroyed when destroying a command while still used in another command or in the graph - this will just crash. @@ -700,7 +700,7 @@ typedef struct /*node the command applies to - may be NULL*/ GF_Node *node; - /*list of GF_CommandField for all field commands replace/ index insert / index replace / index delete / MultipleReplace / MultipleIndexedreplace + /*list of GF_CommandField for all field commands replace/ index insert / index replace / index delete / MultipleReplace / MultipleIndexedreplace the content is destroyed when deleting the command*/ GF_List *command_fields; @@ -712,7 +712,7 @@ typedef struct union { - /*scene replace command: + /*scene replace command: root node is stored in com->node protos are stored in com->new_proto_list routes are stored as RouteInsert in the same frame diff --git a/include/gpac/scenegraph_svg.h b/include/gpac/scenegraph_svg.h index 0e295d3..22dd7e7 100644 --- a/include/gpac/scenegraph_svg.h +++ b/include/gpac/scenegraph_svg.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,7 +35,7 @@ extern "C" { /******************************************************************************* - * + * * DOM base scene graph * *******************************************************************************/ @@ -116,9 +116,9 @@ enum TAG_XBL_ATT_preventdefault, TAG_XBL_ATT_src, - TAG_GSVG_ATT_useAsPrimary, - TAG_GSVG_ATT_depthOffset, - TAG_GSVG_ATT_depthGain, + TAG_GSVG_ATT_useAsPrimary, + TAG_GSVG_ATT_depthOffset, + TAG_GSVG_ATT_depthGain, }; @@ -130,7 +130,7 @@ enum #define GF_DOM_FULL_ATTRIBUTE \ GF_DOM_ATTRIBUTE \ - + typedef struct __dom_base_attribute { GF_DOM_BASE_ATTRIBUTE @@ -172,7 +172,7 @@ typedef enum GF_XMLNS_SVG, GF_XMLNS_XBL, - GF_XMLNS_SVG_GPAC_EXTENSION, + GF_XMLNS_SVG_GPAC_EXTENSION, /*any other namespace uses the CRC32 of the namespace as an identifier*/ } GF_NamespaceType; @@ -235,7 +235,7 @@ typedef struct /*creates a new updates node and register node with parent*/ GF_DOMUpdates *gf_dom_add_updates_node(GF_Node *parent); -/* +/* DOM event handling */ typedef enum @@ -266,7 +266,7 @@ typedef enum /* Structure representing the DOM EventTarget Interface */ -typedef struct +typedef struct { GF_List *listeners; // list of SVG Listener nodes attached to this Event Target void *ptr; // pointer to the object implementing the DOM Event Target Interface @@ -299,15 +299,15 @@ typedef struct u8 cancelable; /*output only - indicates UI events (mouse) have been detected*/ u8 has_ui_events; - + /*we don't use a GF_DOMEventTarget here since the structure is only created when events are attached */ void *target; GF_DOMEventTargetType target_type; GF_DOMEventTarget *currentTarget; Double timestamp; - /*UIEvent extension. - For mouse extensions: number of clicks + /*UIEvent extension. + For mouse extensions: number of clicks For key event: the key code For SMIL event: number of iteration (repeat) */ @@ -368,7 +368,7 @@ const char *gf_dom_get_key_name(GF_KeyCode key_identifier); GF_KeyCode gf_dom_get_key_type(char *key_name); -/*listener is simply a node added to the node events list. +/*listener is simply a node added to the node events list. Only one observer can be attached to a listener. The listener will remove itself from the observer event list when destructed.*/ #define GF_DOM_BASE_LISTENER \ @@ -382,9 +382,9 @@ event list when destructed.*/ /*compiled function for the case were CallFunction is needed*/\ void *js_fun; \ /* text content of the callback */ \ - char *callback; + char *callback; -typedef struct __xml_ev_handler +typedef struct __xml_ev_handler { GF_DOM_BASE_NODE void (*handle_event)(GF_Node *hdl, GF_DOM_Event *event, GF_Node *observer); @@ -437,7 +437,7 @@ GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener); u32 gf_dom_listener_count(GF_Node *node); GF_Node *gf_dom_listener_get(GF_Node *node, u32 i); -/*creates a default listener/handler for the given event on the given node, and return the +/*creates a default listener/handler for the given event on the given node, and return the handler element to allow for handler function override Listener/handler are stored at the node level*/ GF_DOMHandler *gf_dom_listener_build(GF_Node *observer, GF_EventType event_type, u32 event_param); @@ -457,7 +457,7 @@ GF_Err gf_node_store_embedded_data(XMLRI *iri, const char *cache_dir, const char typedef struct { /* Tiny 1.2 properties*/ SVG_Paint *color; - SVG_Paint *fill; + SVG_Paint *fill; SVG_Paint *stroke; SVG_Paint *solid_color; SVG_Paint *stop_color; @@ -478,67 +478,67 @@ typedef struct { SVG_RenderingHint *shape_rendering; SVG_RenderingHint *text_rendering; - SVG_Display *display; + SVG_Display *display; SVG_Visibility *visibility; SVG_Overflow *overflow; /* Restricted property in Tiny 1.2 */ - + SVG_FontFamily *font_family; SVG_FontSize *font_size; - SVG_FontStyle *font_style; - SVG_FontWeight *font_weight; - SVG_FontVariant *font_variant; - SVG_Number *line_increment; + SVG_FontStyle *font_style; + SVG_FontWeight *font_weight; + SVG_FontVariant *font_variant; + SVG_Number *line_increment; SVG_TextAnchor *text_anchor; SVG_DisplayAlign *display_align; SVG_TextAlign *text_align; SVG_PointerEvents *pointer_events; - - SVG_FillRule *fill_rule; - + + SVG_FillRule *fill_rule; + SVG_StrokeDashArray *stroke_dasharray; SVG_Length *stroke_dashoffset; - SVG_StrokeLineCap *stroke_linecap; - SVG_StrokeLineJoin *stroke_linejoin; - SVG_Number *stroke_miterlimit; + SVG_StrokeLineCap *stroke_linecap; + SVG_StrokeLineJoin *stroke_linejoin; + SVG_Number *stroke_miterlimit; SVG_Length *stroke_width; SVG_VectorEffect *vector_effect; - + /* Full 1.1 props, i.e. not implemented */ -/* - SVG_String *font; - SVG_String *font_size_adjust; - SVG_String *font_stretch; - SVG_String *direction; - SVG_String *letter_spacing; - SVG_String *text_decoration; - SVG_String *unicode_bidi; - SVG_String *word_spacing; - SVG_String *clip; - SVG_String *cursor; - SVG_String *clip_path; - SVG_String *clip_rule; - SVG_String *mask; - SVG_String *enable_background; - SVG_String *filter; - SVG_String *flood_color; - SVG_String *flood_opacity; - SVG_String *lighting_color; - SVG_String *color_interpolation; - SVG_String *color_interpolation_filters; - SVG_String *color_profile; - SVG_String *marker; - SVG_String *marker_end; - SVG_String *marker_mid; - SVG_String *marker_start; - SVG_String *alignment_baseline; - SVG_String *baseline_shift; - SVG_String *dominant_baseline; - SVG_String *glyph_orientation_horizontal; - SVG_String *glyph_orientation_vertical; - SVG_String *kerning; - SVG_String *writing_mode; -*/ + /* + SVG_String *font; + SVG_String *font_size_adjust; + SVG_String *font_stretch; + SVG_String *direction; + SVG_String *letter_spacing; + SVG_String *text_decoration; + SVG_String *unicode_bidi; + SVG_String *word_spacing; + SVG_String *clip; + SVG_String *cursor; + SVG_String *clip_path; + SVG_String *clip_rule; + SVG_String *mask; + SVG_String *enable_background; + SVG_String *filter; + SVG_String *flood_color; + SVG_String *flood_opacity; + SVG_String *lighting_color; + SVG_String *color_interpolation; + SVG_String *color_interpolation_filters; + SVG_String *color_profile; + SVG_String *marker; + SVG_String *marker_end; + SVG_String *marker_mid; + SVG_String *marker_start; + SVG_String *alignment_baseline; + SVG_String *baseline_shift; + SVG_String *dominant_baseline; + SVG_String *glyph_orientation_horizontal; + SVG_String *glyph_orientation_vertical; + SVG_String *kerning; + SVG_String *writing_mode; + */ } SVGPropertiesPointers; /************************************* @@ -606,8 +606,8 @@ enum SMIL_TIMING_EVAL_DEACTIVATE, }; -void gf_smil_set_evaluation_callback(GF_Node *smil_time, - void (*smil_evaluate)(struct _smil_timing_rti *rti, Fixed normalized_simple_time, u32 state)); +void gf_smil_set_evaluation_callback(GF_Node *smil_time, + void (*smil_evaluate)(struct _smil_timing_rti *rti, Fixed normalized_simple_time, u32 state)); void gf_smil_set_media_duration(SMIL_Timing_RTI *rti, Double media_duration); Double gf_smil_get_media_duration(SMIL_Timing_RTI *rti); @@ -617,7 +617,7 @@ Bool gf_smil_timing_is_active(GF_Node *node); void gf_smil_timing_modified(GF_Node *node, GF_FieldInfo *field); /******************************************************************************* - * + * * SVG Scene Graph for dynamic allocation of attributes * * *******************************************************************************/ diff --git a/include/gpac/scenegraph_vrml.h b/include/gpac/scenegraph_vrml.h index 4db6b9b..0db0a28 100644 --- a/include/gpac/scenegraph_vrml.h +++ b/include/gpac/scenegraph_vrml.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,7 +35,7 @@ extern "C" { #include /* - All extensions for VRML/MPEG-4/X3D graph structure + All extensions for VRML/MPEG-4/X3D graph structure */ /*reserved NDT for MPEG4 (match binary coding)*/ @@ -60,7 +60,7 @@ enum */ /* - event types, as defined in the specs + event types, as defined in the specs this should not be needed by non binary codecs */ enum @@ -311,8 +311,8 @@ enum GF_SG_VRML_MFVEC2D, GF_SG_VRML_MFVEC3D, - /*special event only used in routes for binding eventOut/exposedFields to script functions. - A route with ToField.FieldType set to this value holds a pointer to a function object. + /*special event only used in routes for binding eventOut/exposedFields to script functions. + A route with ToField.FieldType set to this value holds a pointer to a function object. */ GF_SG_VRML_SCRIPT_FUNCTION, @@ -367,17 +367,17 @@ hardcoded protos (extensions of MPEG-4 scene graph used for module deveopment) -/*VRML grouping nodes macro - note we have inverted the children field to be +/*VRML grouping nodes macro - note we have inverted the children field to be compatible with the base GF_ParentNode node -All grouping nodes (with "children" field) implement the following: +All grouping nodes (with "children" field) implement the following: addChildren: chain containing nodes to add passed as eventIn - handled internally through ROUTE -void (*on_addChildren)(GF_Node *pNode): add eventIn signaler - this is handled internally by the scene_graph and SHALL +void (*on_addChildren)(GF_Node *pNode): add eventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE OVERRIDEN since it takes care of node(s) routing removeChildren: chain containing nodes to remove passed as eventIn - handled internally through ROUTE -void (*on_removeChildren)(GF_Node *pNode): remove eventIn signaler - this is handled internally by the scene_graph and SHALL +void (*on_removeChildren)(GF_Node *pNode): remove eventIn signaler - this is handled internally by the scene_graph and SHALL NOT BE OVERRIDEN since it takes care of node(s) routing children: list of children SFNodes @@ -389,7 +389,7 @@ children: list of children SFNodes void (*on_addChildren)(GF_Node *pNode, struct _route *route); \ GF_ChildNodeItem *removeChildren; \ void (*on_removeChildren)(GF_Node *pNode, struct _route *route); \ - + typedef struct { BASE_NODE @@ -407,7 +407,7 @@ const char *gf_sg_vrml_get_field_type_by_name(u32 FieldType); /* -allocates a new field and gets it back. +allocates a new field and gets it back. NOTE: GF_SG_VRML_MFNODE will return a pointer to a GF_List structure (eg GF_List *) GF_SG_VRML_SFNODE will return NULL @@ -482,10 +482,10 @@ void gf_sg_set_max_defined_route_id(GF_SceneGraph *sg, u32 ID); - routes are collected during eventOut generation - routes are activated. If eventOuts are generated during activation the cycle goes on. - A route cannot be activated twice in the same simulation tick, hence this function shall be called + A route cannot be activated twice in the same simulation tick, hence this function shall be called ONCE AND ONLY ONCE per simulation tick -Note that children scene graphs register their routes with the top-level graph, so only the main +Note that children scene graphs register their routes with the top-level graph, so only the main scene graph needs to be activated*/ void gf_sg_activate_routes(GF_SceneGraph *sg); @@ -493,7 +493,7 @@ void gf_sg_activate_routes(GF_SceneGraph *sg); /* proto handling - The lib allows you to construct prototype nodes as defined in VRML/MPEG4 by constructing + The lib allows you to construct prototype nodes as defined in VRML/MPEG4 by constructing proto interfaces and instanciating them. An instanciated proto is handled as a single node for rendering, thus an application will never handle proto instances for rendering */ @@ -556,11 +556,11 @@ GF_Err gf_sg_proto_field_get_field(GF_ProtoFieldInterface *field, GF_FieldInfo * /* NOTE on proto instances: - The proto instance is handled as an GF_Node outside the scenegraph lib, and is manipulated with the same functions - as an GF_Node - The proto instance may or may not be loaded. - An unloaded instance only contains the proto instance fields - A loaded instance contains the proto instance fields plus all the proto code (Nodes, routes) and + The proto instance is handled as an GF_Node outside the scenegraph lib, and is manipulated with the same functions + as an GF_Node + The proto instance may or may not be loaded. + An unloaded instance only contains the proto instance fields + A loaded instance contains the proto instance fields plus all the proto code (Nodes, routes) and will load any scripts present in it. This allows keeping the memory usage of proto very low, especially when nested protos (protos used as building blocks of their parent proto) are used. */ diff --git a/include/gpac/setup.h b/include/gpac/setup.h index aef139b..e255d85 100644 --- a/include/gpac/setup.h +++ b/include/gpac/setup.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -429,7 +429,7 @@ void gf_memory_print(void); /*prints the state of current allocations*/ #define GPAC_STATIC_MODULES #endif - + /*safety checks on macros*/ #ifdef GPAC_DISABLE_ZLIB diff --git a/include/gpac/svg_types.h b/include/gpac/svg_types.h index 1a10d22..17616d9 100644 --- a/include/gpac/svg_types.h +++ b/include/gpac/svg_types.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,21 +35,21 @@ extern "C" { -/* Attributes in SVG can be accessed using a GF_FieldInfo structure +/* Attributes in SVG can be accessed using a GF_FieldInfo structure like it is done in the BIFS part of the implementation: fieldIndex: attribute tag to identify the attribute in the element in the case of dynamic alloc (default) or index of the attribute in the element in the case of static allocation of attributes fieldType: attribute data type as in the enumeration below - + name: attribute name (WARNING: this may be NULL) far_ptr: pointer to the actual data with one of the type given in this file NDTType: unused in SVG eventType: unused in SVG - on_event_in: unused in SVG + on_event_in: unused in SVG */ /* SVG attribute types */ @@ -68,8 +68,8 @@ enum { SVG_FontWeight_datatype, SVG_FontVariant_datatype, SVG_TextAnchor_datatype, - SVG_TransformType_datatype, - SVG_Display_datatype, + SVG_TransformType_datatype, + SVG_Display_datatype, SVG_Visibility_datatype, SVG_Overflow_datatype, SVG_ZoomAndPan_datatype, @@ -95,7 +95,7 @@ enum { SMIL_Additive_datatype, SMIL_Accumulate_datatype, SMIL_Restart_datatype, - SMIL_Fill_datatype, + SMIL_Fill_datatype, SVG_LAST_U8_PROPERTY, @@ -234,15 +234,15 @@ typedef struct { /* Type of timing value*/ u8 type; /* in case of syncbase, event, repeat value: this is the pointer to the source of the event */ - GF_Node *element; + GF_Node *element; /* id of the element before resolution of the pointer to the element */ - char *element_id; + char *element_id; /* listener associated with event */ - GF_Node *listener; + GF_Node *listener; /* event type and parameter */ - XMLEV_Event event; - /*set if event is + XMLEV_Event event; + /*set if event is begin rather than beginEvent, end rather than endEvent, repeat rather than repeatEvent */ @@ -274,7 +274,7 @@ typedef u8 SMIL_Restart; enum { SMIL_FILL_FREEZE=0, SMIL_FILL_REMOVE, - + }; typedef u8 SMIL_Fill; @@ -302,13 +302,13 @@ typedef struct { enum { SMIL_ADDITIVE_REPLACE = 0, SMIL_ADDITIVE_SUM -}; +}; typedef u8 SMIL_Additive; enum { SMIL_ACCUMULATE_NONE = 0, SMIL_ACCUMULATE_SUM -}; +}; typedef u8 SMIL_Accumulate; enum { @@ -338,9 +338,9 @@ typedef struct __xml_ri XML_IDREF; enum { - SVG_FOCUS_AUTO = 0, - SVG_FOCUS_SELF, - SVG_FOCUS_IRI, + SVG_FOCUS_AUTO = 0, + SVG_FOCUS_SELF, + SVG_FOCUS_IRI, }; typedef struct @@ -361,10 +361,10 @@ typedef struct { enum { SVG_FONTSTYLE_INHERIT = 0, - SVG_FONTSTYLE_ITALIC = 1, + SVG_FONTSTYLE_ITALIC = 1, SVG_FONTSTYLE_NORMAL = 2, SVG_FONTSTYLE_OBLIQUE = 3 -}; +}; typedef u8 SVG_FontStyle; /*the values are chosen to match LASeR code points*/ @@ -412,7 +412,7 @@ enum { SVG_FILLRULE_INHERIT }; typedef u8 SVG_FillRule; - + enum { SVG_STROKELINEJOIN_MITER = GF_LINE_JOIN_MITER_SVG, SVG_STROKELINEJOIN_ROUND = GF_LINE_JOIN_ROUND, @@ -510,11 +510,11 @@ enum { typedef struct { u8 type; Fixed value; -} SVG_Number, - SVG_FontSize, - SVG_Length, - SVG_Coordinate, - SVG_Rotate; +} SVG_Number, +SVG_FontSize, +SVG_Length, +SVG_Coordinate, +SVG_Rotate; typedef struct { u8 is_ref; @@ -530,22 +530,22 @@ enum { SVG_TRANSFORM_SKEWY = 5 }; -typedef u8 SVG_TransformType; +typedef u8 SVG_TransformType; enum { - SVG_FONTWEIGHT_100 = 0, + SVG_FONTWEIGHT_100 = 0, SVG_FONTWEIGHT_200, - SVG_FONTWEIGHT_300, + SVG_FONTWEIGHT_300, SVG_FONTWEIGHT_400, SVG_FONTWEIGHT_500, SVG_FONTWEIGHT_600, SVG_FONTWEIGHT_700, SVG_FONTWEIGHT_800, SVG_FONTWEIGHT_900, - SVG_FONTWEIGHT_BOLD, - SVG_FONTWEIGHT_BOLDER, + SVG_FONTWEIGHT_BOLD, + SVG_FONTWEIGHT_BOLDER, SVG_FONTWEIGHT_INHERIT, - SVG_FONTWEIGHT_LIGHTER, + SVG_FONTWEIGHT_LIGHTER, SVG_FONTWEIGHT_NORMAL }; typedef u8 SVG_FontWeight; @@ -613,7 +613,7 @@ enum { typedef struct { u32 count; Fixed* vals; - u8 *units; + u8 *units; } UnitArray; typedef struct { @@ -667,7 +667,7 @@ typedef struct { Bool defer; u8 align; u8 meetOrSlice; -} SVG_PreserveAspectRatio; +} SVG_PreserveAspectRatio; enum { SVG_ZOOMANDPAN_DISABLE = 0, @@ -683,33 +683,33 @@ enum { }; enum { - // textPath Method Types + // textPath Method Types TEXTPATH_METHODTYPE_UNKNOWN = 0, TEXTPATH_METHODTYPE_ALIGN = 1, TEXTPATH_METHODTYPE_STRETCH = 2 }; enum { - // textPath Spacing Types + // textPath Spacing Types TEXTPATH_SPACINGTYPE_UNKNOWN = 0, TEXTPATH_SPACINGTYPE_AUTO = 1, TEXTPATH_SPACINGTYPE_EXACT = 2 }; enum { - // Marker Unit Types + // Marker Unit Types SVG_MARKERUNITS_UNKNOWN = 0, SVG_MARKERUNITS_USERSPACEONUSE = 1, SVG_MARKERUNITS_STROKEWIDTH = 2 }; enum { - // Marker Orientation Types + // Marker Orientation Types SVG_MARKER_ORIENT_UNKNOWN = 0, SVG_MARKER_ORIENT_AUTO = 1, SVG_MARKER_ORIENT_ANGLE = 2 }; enum { - // Spread Method Types + // Spread Method Types SVG_SPREADMETHOD_UNKNOWN = 0, SVG_SPREADMETHOD_PAD = 1, SVG_SPREADMETHOD_REFLECT = 2, @@ -759,7 +759,7 @@ typedef u8 XMLEV_Propagate; enum { XMLEVENT_DEFAULTACTION_CANCEL = 0, XMLEVENT_DEFAULTACTION_PERFORM, - + }; typedef u8 XMLEV_DefaultAction; diff --git a/include/gpac/sync_layer.h b/include/gpac/sync_layer.h index 3035666..10de1ff 100644 --- a/include/gpac/sync_layer.h +++ b/include/gpac/sync_layer.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -30,7 +30,7 @@ extern "C" { #endif - + /*the Sync Layer config descriptor*/ typedef struct { diff --git a/include/gpac/term_info.h b/include/gpac/term_info.h index 689c632..f32fdeb 100644 --- a/include/gpac/term_info.h +++ b/include/gpac/term_info.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ extern "C" { #endif /* - OD Browsing API - YOU MUST INCLUDE before + OD Browsing API - YOU MUST INCLUDE before (this has been separated from terminal.h to limit dependency of core to mpeg4_odf.h header) ALL ITEMS ARE READ-ONLY AND SHALL NOT BE MODIFIED */ @@ -57,6 +57,12 @@ u32 gf_term_object_subscene_type(GF_Terminal *term, GF_ObjectManager *odm); /*select given object when stream selection is available*/ void gf_term_select_object(GF_Terminal *term, GF_ObjectManager *odm); +/*select service by given ID for multiplexed services (MPEG-2 TS)*/ +void gf_term_select_service(GF_Terminal *term, GF_ObjectManager *odm, u32 service_id); + +/*sets addon on or off (only one addon possible for now). When OFF , the associated service is shut down*/ +void gf_term_toggle_addons(GF_Terminal *term, Bool show_addons); + typedef struct { GF_ObjectDescriptor *od; @@ -67,7 +73,7 @@ typedef struct /*if set, the PL flags are valid*/ Bool has_profiles; Bool inline_pl; - u8 OD_pl; + u8 OD_pl; u8 scene_pl; u8 audio_pl; u8 visual_pl; @@ -124,7 +130,7 @@ typedef struct /*fills the GF_MediaInfo structure describing the OD manager*/ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_MediaInfo *info); /*gets current downloads info for the service - only use if ODM owns thesrevice, returns 0 otherwise. - @d_enum: in/out current enum - shall start to 0, incremented at each call. fct returns 0 if no more + @d_enum: in/out current enum - shall start to 0, incremented at each call. fct returns 0 if no more downloads @server: server name @path: file/data location on server @@ -141,11 +147,11 @@ Bool gf_term_get_channel_net_info(GF_Terminal *term, GF_ObjectManager *odm, u32 typedef struct __netinfocom NetInfoCommand; GF_Err gf_term_get_service_info(GF_Terminal *term, GF_ObjectManager *odm, NetInfoCommand *netcom); -/*retrieves world info of the scene @od belongs to. +/*retrieves world info of the scene @od belongs to. If @odm is or points to an inlined OD the world info of the inlined content is retrieved If @odm is NULL the world info of the main scene is retrieved returns NULL if no WorldInfo available -returns world title if available +returns world title if available @descriptions: any textual descriptions is stored here strings are not allocated */ diff --git a/include/gpac/terminal.h b/include/gpac/terminal.h index 5df7eff..52d046f 100644 --- a/include/gpac/terminal.h +++ b/include/gpac/terminal.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,12 +47,12 @@ void gf_term_connect(GF_Terminal *term, const char *URL); /*disconnects the url*/ void gf_term_disconnect(GF_Terminal *term); /*navigates to a given destination or shutdown/restart the current one if any. -This is the only safe way of restarting/jumping a presentation from inside the EventProc +This is the only safe way of restarting/jumping a presentation from inside the EventProc where doing a disconnect/connect could deadlock if toURL is NULL, uses the current URL*/ void gf_term_navigate_to(GF_Terminal *term, const char *toURL); -/*restarts url from given time (in ms). +/*restarts url from given time (in ms). @pause_at_first_frame: if 1, pauses at the first frame. If 2, pauses at the first frame only if the terminal is in paused state. -Return value: +Return value: 0: service is not connected yet 1: service has no seeking capabilities 2: service has been seeked @@ -67,9 +67,9 @@ void gf_term_connect_with_path(GF_Terminal *term, const char *URL, const char *p /*returns current framerate if @absoluteFPS is set, the return value is the absolute framerate, eg NbFrameCount/NbTimeSpent regardless of -whether a frame has been drawn or not, which means the FPS returned can be much greater than the target rendering +whether a frame has been drawn or not, which means the FPS returned can be much greater than the target rendering framerate - if @absoluteFPS is not set, the return value is the FPS taking into account not drawn frames (eg, less than + if @absoluteFPS is not set, the return value is the FPS taking into account not drawn frames (eg, less than or equal to compositor FPS) */ Double gf_term_get_framerate(GF_Terminal *term, Bool absoluteFPS); @@ -114,7 +114,7 @@ void gf_term_process_shortcut(GF_Terminal *term, GF_Event *ev); void gf_term_set_speed(GF_Terminal *term, Fixed speed); /*sends a set of scene commands (BT, XMT, X3D, LASeR+XML) to the scene -type indicates the language used - accepted values are +type indicates the language used - accepted values are "model/x3d+xml" or "x3d": commands is an X3D+XML scene "model/x3d+vrml" or "xrdv": commands is an X3D+VRML scene "model/vrml" or "vrml": commands is an VRML scene @@ -133,7 +133,7 @@ GF_Err gf_term_scene_update(GF_Terminal *term, char *type, char *com); */ GF_Err gf_term_set_size(GF_Terminal *term, u32 NewWidth, u32 NewHeight); -/*returns current text selection if any, or NULL otherwise. If probe mode is set, returns a non-NULL string ("") +/*returns current text selection if any, or NULL otherwise. If probe mode is set, returns a non-NULL string ("") if some text is selected*/ const char *gf_term_get_text_selection(GF_Terminal *term, Bool probe_only); /*pastes text into current selection if any. If probe mode is set, only check if text is currently edited @@ -141,7 +141,7 @@ if some text is selected*/ GF_Err gf_term_paste_text(GF_Terminal *term, const char *txt, Bool probe_only); -/*decodes pending media and render frame. +/*decodes pending media and render frame. NOTE: This can only be used when the terminal runs without visual thread (GF_TERM_NO_VISUAL_THREAD flag set) returns estimated time left until next frame should be drawn. If GF_TERM_NO_REGULATION is not set, the function will sleep for until next frame should be drawn before returning. @@ -157,7 +157,7 @@ GF_Err gf_term_process_flush(GF_Terminal *term); /*NOT NEEDED WHEN THE TERMINAL IS HANDLING THE DISPLAY WINDOW (cf user.h)*/ Bool gf_term_user_event(GF_Terminal *term, GF_Event *event); -/*post extended user mouse interaction to terminal +/*post extended user mouse interaction to terminal X and Y are point coordinates in the display expressed in 2D coord system top-left (0,0), Y increasing towards bottom @xxx_but_down: specifiy whether the mouse button is down(2) or up (1), 0 if unchanged @wheel: specifiy current wheel inc (0: unchanged , +1 for one wheel delta forward, -1 for one wheel delta backward) @@ -165,7 +165,7 @@ Bool gf_term_user_event(GF_Terminal *term, GF_Event *event); /*NOT NEEDED WHEN THE TERMINAL IS HANDLING THE DISPLAY WINDOW (cf user.h)*/ void gf_term_mouse_input(GF_Terminal *term, GF_EventMouse *event); -/*post extended user key interaction to terminal +/*post extended user key interaction to terminal @key_code: GPAC DOM code of input key @hw_code: hardware code of input key @isKeyUp: set if key is released @@ -173,7 +173,7 @@ void gf_term_mouse_input(GF_Terminal *term, GF_EventMouse *event); /*NOT NEEDED WHEN THE TERMINAL IS HANDLING THE DISPLAY WINDOW (cf user.h)*/ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool isKeyUp); -/*post extended user character interaction to terminal +/*post extended user character interaction to terminal @character: unicode character input */ /*NOT NEEDED WHEN THE TERMINAL IS HANDLING THE DISPLAY WINDOW (cf user.h)*/ diff --git a/include/gpac/thread.h b/include/gpac/thread.h index 591ad84..2b14617 100644 --- a/include/gpac/thread.h +++ b/include/gpac/thread.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -35,15 +35,15 @@ extern "C" { * \brief threading functions. */ - /*! - * \addtogroup thr_grp threading - * \ingroup utils_grp - * \brief Threading and Mutual Exclusion Functions - * - *This section documents the threading of the GPAC framework. These provide an easy way to implement - *safe multithreaded tools. - * @{ - */ +/*! +* \addtogroup thr_grp threading +* \ingroup utils_grp +* \brief Threading and Mutual Exclusion Functions +* +*This section documents the threading of the GPAC framework. These provide an easy way to implement +*safe multithreaded tools. +* @{ +*/ #include @@ -220,7 +220,7 @@ Bool gf_mx_try_lock(GF_Mutex *mx); /* *\brief get mutex number of locks * - *Returns the number of locks on the mutex if the caller thread is holding the mutex. + *Returns the number of locks on the mutex if the caller thread is holding the mutex. *\param mx the mutex object *\return -1 if the mutex is not hold by the calling thread, or the number of locks (possibly 0) otherwise. */ diff --git a/include/gpac/token.h b/include/gpac/token.h index 7fb5d50..2d427f1 100644 --- a/include/gpac/token.h +++ b/include/gpac/token.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,19 +35,19 @@ extern "C" { * \brief tokenizer functions. */ - /*! - * \addtogroup tok_grp tokenizer - * \ingroup utils_grp - * \brief String Tokenizer Functions - * - *This section documents the basic string tokenizer of the GPAC framework. - * @{ - */ +/*! +* \addtogroup tok_grp tokenizer +* \ingroup utils_grp +* \brief String Tokenizer Functions +* +*This section documents the basic string tokenizer of the GPAC framework. +* @{ +*/ #include /*! - *\brief get string component + *\brief get string component * *Gets the next string component comprised in a given set of characters *\param Buffer source string to scan diff --git a/include/gpac/tools.h b/include/gpac/tools.h index d0a39e1..8802ec7 100644 --- a/include/gpac/tools.h +++ b/include/gpac/tools.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -454,7 +454,7 @@ Bool gf_log_tool_level_on(u32 log_tool, u32 log_level); * \brief Set log tools and levels * * Set log tools and levels according to the log_tools_levels string. All previous log settings are discarded. - * \param log_tools_levels string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:... + * \param log_tools_levels string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:... * \return GF_OK or GF_BAD_PARAM */ GF_Err gf_log_set_tools_levels(const char *log_tools_levels); @@ -463,7 +463,7 @@ GF_Err gf_log_set_tools_levels(const char *log_tools_levels); * \brief Modify log tools and levels * * Modify log tools and levels according to the log_tools_levels string. Previous log settings are kept. - * \param val string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:... + * \param val string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:... * \return GF_OK or GF_BAD_PARAM */ GF_Err gf_log_modify_tools_levels(const char *val); @@ -732,7 +732,7 @@ u32 gf_crc_32(const char *data, u32 size); #endif /*! - *\brief gets UTC time in milliseconds + *\brief gets UTC time in milliseconds * * Gets UTC clock in milliseconds * \return UTC time in milliseconds @@ -740,10 +740,10 @@ u32 gf_crc_32(const char *data, u32 size); u64 gf_net_get_utc(); /*! - *\brief parses date and returns UTC value for this date. Date format is an XSD dateTime format or any of the supported formats from HTTP 1.1: - Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 + *\brief parses date and returns UTC value for this date. Date format is an XSD dateTime format or any of the supported formats from HTTP 1.1: + Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 - Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() formatgets UTC time in milliseconds + Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() formatgets UTC time in milliseconds * * \param date string containing the date to parse * \return UTC time in milliseconds @@ -751,7 +751,7 @@ u64 gf_net_get_utc(); u64 gf_net_parse_date(const char *date); /*! - *\brief gets timezone adjustment in seconds + *\brief gets timezone adjustment in seconds * * Gets timezone adjustment in seconds, with localtime - timezone = UTC time * \return timezone shift in seconds @@ -759,9 +759,9 @@ u64 gf_net_parse_date(const char *date); s32 gf_net_get_timezone(); /*! - *\brief parses 128 bit from string + *\brief parses 128 bit from string * - * Parses 128 bit from string + * Parses 128 bit from string * * \param string the string containing the value in hexa. Non alphanum characters are skipped * \param value the value parsed @@ -879,7 +879,7 @@ char * gf_get_default_cache_directory(); GF_Err gf_gz_compress_payload(char **data, u32 data_len, u32 *out_size); /** - * Decompresses a data buffer using zlib. + * Decompresses a data buffer using zlib. * \param data data buffer to be decompressed * \param data_len length of the data buffer to be decompressed * \param uncompressed_data pointer to the uncompressed data buffer. It is the responsibility of the caller to free this buffer. diff --git a/include/gpac/unicode.h b/include/gpac/unicode.h index c94bfca..b93959d 100644 --- a/include/gpac/unicode.h +++ b/include/gpac/unicode.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -45,7 +45,7 @@ extern "C" { * \return the length of the ucs4_buf. Note that the ucs4_buf should be allocated by parent and should be at least utf8_len * 4 */ u32 utf8_to_ucs4 (u32 *ucs4_buf, u32 utf8_len, unsigned char *utf8_buf); - + #ifdef __cplusplus } #endif diff --git a/include/gpac/user.h b/include/gpac/user.h index 571a23a..fc44065 100644 --- a/include/gpac/user.h +++ b/include/gpac/user.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,7 +39,7 @@ extern "C" { /*GPAC client terminal*/ typedef struct _tag_terminal GF_Terminal; typedef struct _tag_user GF_User; - + enum { @@ -47,14 +47,14 @@ enum GF_TERM_INIT_HIDE = 1, /*no audio renderer will be created*/ GF_TERM_NO_AUDIO = 1<<1, - /*terminal is used without visual threading: + /*terminal is used without visual threading: * media codecs are not threaded * all composition memories are filled before rendering * rendering is done after media decoding * the user is responsible for updating the terminal */ GF_TERM_NO_DECODER_THREAD = 1<<2, - + /*works with no visual thread for the composition - compositor is driven by the media manager if GF_TERM_NO_DECODER_THREAD, equivalent to GF_TERM_NO_COMPOSITOR_THREAD */ @@ -91,7 +91,7 @@ struct _tag_user GF_Config *config; /*modules manager - cannot be NULL - owned by the user (to allow selection of module directory)*/ GF_ModuleManager *modules; - /*optional os window handler (HWND on win32/winCE, XWindow for X11) + /*optional os window handler (HWND on win32/winCE, XWindow for X11) if not set the video outut will create and manage the display window.*/ void *os_window_handler; /*for now, only used by X11 (indicates display the window is on)*/ diff --git a/include/gpac/utf.h b/include/gpac/utf.h index 3008d7b..6940e10 100644 --- a/include/gpac/utf.h +++ b/include/gpac/utf.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -63,7 +63,7 @@ converted if not enough space*/ /*! *\brief multibyte to wide-char conversion * - *Converts a multibyte string to a wide-char string + *Converts a multibyte string to a wide-char string *\param dst wide-char destination buffer *\param dst_len wide-char destination buffer size *\param srcp address of the multibyte character buffer. This will be set to the next char to be converted in the input buffer if not enough space in the destination, or NULL if conversion was completed. diff --git a/include/gpac/version.h b/include/gpac/version.h index fcd5dfb..d006622 100644 --- a/include/gpac/version.h +++ b/include/gpac/version.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2012 * All rights reserved * diff --git a/include/gpac/webvtt.h b/include/gpac/webvtt.h index 0e8d265..e36b2b1 100644 --- a/include/gpac/webvtt.h +++ b/include/gpac/webvtt.h @@ -5,7 +5,7 @@ * Copyright (c) Telecom ParisTech 2013- * All rights reserved * - * This file is part of GPAC / WebVTT header + * This file is part of GPAC / WebVTT header * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -32,14 +32,14 @@ extern "C" { /* WebVTT types */ typedef enum { - WEBVTT_ID, - WEBVTT_SETTINGS, - WEBVTT_PAYLOAD, - WEBVTT_TIME + WEBVTT_ID, + WEBVTT_SETTINGS, + WEBVTT_PAYLOAD, + WEBVTT_TIME } GF_WebVTTCuePropertyType; typedef struct _webvtt_timestamp { - u32 hour, min, sec, ms; + u32 hour, min, sec, ms; } GF_WebVTTTimestamp; u64 gf_webvtt_timestamp_get(GF_WebVTTTimestamp *ts); void gf_webvtt_timestamp_set(GF_WebVTTTimestamp *ts, u64 value); @@ -47,17 +47,17 @@ void gf_webvtt_timestamp_dump(GF_WebVTTTimestamp *ts, FILE *dump, Bool dump_hour typedef struct _webvtt_cue { - GF_WebVTTTimestamp start; - GF_WebVTTTimestamp end; - char *id; - char *settings; - char *text; - char *time; + GF_WebVTTTimestamp start; + GF_WebVTTTimestamp end; + char *id; + char *settings; + char *text; + char *time; - Bool split; - /* original times before split, if applicable */ - GF_WebVTTTimestamp orig_start; - GF_WebVTTTimestamp orig_end; + Bool split; + /* original times before split, if applicable */ + GF_WebVTTTimestamp orig_start; + GF_WebVTTTimestamp orig_end; } GF_WebVTTCue; void gf_webvtt_cue_del(GF_WebVTTCue * cue); @@ -67,10 +67,10 @@ GF_Err gf_webvtt_dump_header_boxed(FILE *dump, const char *data, u32 dataLength, #ifdef GPAC_HAS_SPIDERMONKEY #include -GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, - const char *start, const char *end, - const char *settings, - const char *payload); +GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, + const char *start, const char *end, + const char *settings, + const char *payload); GF_Err gf_webvtt_js_removeCues(GF_Node *node); #endif diff --git a/include/gpac/xml.h b/include/gpac/xml.h index 666f820..ac1290c 100644 --- a/include/gpac/xml.h +++ b/include/gpac/xml.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -94,10 +94,10 @@ typedef void (*gf_xml_sax_text_content)(void *sax_cbck, const char *content, Boo typedef void (*gf_xml_sax_progress)(void *cbck, u64 done, u64 tot); /*creates new sax parser - all callbacks are optionals*/ -GF_SAXParser *gf_xml_sax_new(gf_xml_sax_node_start on_node_start, - gf_xml_sax_node_end on_node_end, - gf_xml_sax_text_content on_text_content, - void *cbck); +GF_SAXParser *gf_xml_sax_new(gf_xml_sax_node_start on_node_start, + gf_xml_sax_node_end on_node_end, + gf_xml_sax_text_content on_text_content, + void *cbck); /*destroys sax parser */ void gf_xml_sax_del(GF_SAXParser *parser); @@ -106,7 +106,7 @@ assume UTF-8 compatible coding*/ GF_Err gf_xml_sax_init(GF_SAXParser *parser, unsigned char *BOM); /*parses input string data. string data MUST be terminated by the 0 character (eg 2 0s for UTF-16)*/ GF_Err gf_xml_sax_parse(GF_SAXParser *parser, const void *string_bytes); -/*suspends/resume sax parsing. +/*suspends/resume sax parsing. When resuming on file, the function will run until suspended/end of file/error When resuming on steram, the function will simply return */ @@ -155,7 +155,7 @@ char *gf_xml_dom_serialize(GF_XMLNode *node, Bool content_only); /* *\brief Create the root element of the DOM * - * Create the root element -- the only top level element -- of the document. + * Create the root element -- the only top level element -- of the document. * *\param parser the DOM structure *\return The created node if creation occurs properly, otherwise NULL; @@ -165,7 +165,7 @@ GF_XMLNode *gf_xml_dom_create_root(GF_DOMParser *parser, const char* name); /* *\brief Get the root element of the DOM * - * Get the root element -- the only top level element -- of the document. + * Get the root element -- the only top level element -- of the document. * *\param parser the DOM structure *\return The corresponding node if exists, otherwise NULL; @@ -240,8 +240,8 @@ void gf_xml_dom_node_del(GF_XMLNode *node); *\brief bitsequence parser. * * inspects all child elements of the node and converts children into bits. BS take the following attributes:. - *bits: value gives the number of bits used to code a value or a length - *value: value is a 32 bit signed value + *bits: value gives the number of bits used to code a value or a length + *value: value is a 32 bit signed value *dataOffset: value gives an offset into a file *dataLength: value gives the number of bits bytes to copy in a file *dataFile: value gives the name of the source file @@ -249,8 +249,8 @@ void gf_xml_dom_node_del(GF_XMLNode *node); *text: or string: value gives a string (length is first coded on number of bits in bits attribute) *fcc: value gives a four character code, coded on 32 bits *ID128: value gives a 128 bit vlue in hexadecimal - *data64: value gives data coded as base64 - *data: value gives data coded in hexa + *data64: value gives data coded as base64 + *data: value gives data coded in hexa * * * diff --git a/include/win32/inttypes.h b/include/win32/inttypes.h index 4db18db..f8139a2 100644 --- a/include/win32/inttypes.h +++ b/include/win32/inttypes.h @@ -1,9 +1,9 @@ -/* 7.8 Format conversion of integer types */ - -#ifndef _INTTYPES_H_ -#define _INTTYPES_H_ - - +/* 7.8 Format conversion of integer types */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + + typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; @@ -12,6 +12,6 @@ typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; - - -#endif /* ndef _INTTYPES_H */ + + +#endif /* ndef _INTTYPES_H */ diff --git a/modules/Makefile b/modules/Makefile index 0386349..8cd8fb2 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -100,10 +100,12 @@ endif ifneq ($(CONFIG_FFMPEG), no) +ifneq ($(CONFIG_LIBAV), new) #we don't support libav newest APIs ifeq ($(CONFIG_OPENHEVC),no) PLUGDIRS+=ffmpeg_in endif endif +endif ifeq ($(CONFIG_OPENHEVC), yes) ifeq ($(CONFIG_FFMPEG), no) diff --git a/modules/aac_in/aac_in.c b/modules/aac_in/aac_in.c index 9837acf..0c84d5c 100644 --- a/modules/aac_in/aac_in.c +++ b/modules/aac_in/aac_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -92,28 +92,28 @@ static const char * AAC_EXTENSIONS = "aac mp4a"; static const char * AAC_DESC = "MPEG-4 AAC Music"; -static u32 AAC_RegisterMimeTypes(const GF_InputService *plug){ - int i; - if (!plug) - return 0; - for (i = 0 ; AAC_MIMES[i] ; i++) - gf_term_register_mime_type( plug, AAC_MIMES[i], AAC_EXTENSIONS, AAC_DESC); - return i; +static u32 AAC_RegisterMimeTypes(const GF_InputService *plug) { + int i; + if (!plug) + return 0; + for (i = 0 ; AAC_MIMES[i] ; i++) + gf_service_register_mime( plug, AAC_MIMES[i], AAC_EXTENSIONS, AAC_DESC); + return i; } static Bool AAC_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; - if (!plug || !url) - return 0; + if (!plug || !url) + return 0; sExt = strrchr(url, '.'); if (!strnicmp(url, "rtsp://", 7)) return 0; { - int i; - for (i = 0 ; AAC_MIMES[i] ; i++) - if (gf_term_check_extension(plug, AAC_MIMES[i], AAC_EXTENSIONS, AAC_DESC, sExt)) - return 1; + int i; + for (i = 0 ; AAC_MIMES[i] ; i++) + if (gf_service_check_mime_register(plug, AAC_MIMES[i], AAC_EXTENSIONS, AAC_DESC, sExt)) + return 1; } return 0; } @@ -127,7 +127,7 @@ static GF_ESD *AAC_GetESD(AACReader *read) esd = gf_odf_desc_esd_new(0); if (!esd) - return NULL; + return NULL; esd->decoderConfig->streamType = GF_STREAM_AUDIO; esd->decoderConfig->objectTypeIndication = read->oti; esd->ESID = 1; @@ -176,7 +176,7 @@ static void AAC_SetupObject(AACReader *read) esd->OCRESID = 0; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } #endif @@ -244,7 +244,7 @@ static Bool AAC_ConfigureFromFile(AACReader *read) Bool sync; GF_BitStream *bs; ADTSHeader hdr; - if (!read || !read->stream) return 0; + if (!read || !read->stream) return 0; bs = gf_bs_from_file(read->stream, GF_BITSTREAM_READ); sync = ADTS_SyncFrame(bs, !read->is_remote, &hdr); @@ -277,13 +277,13 @@ static Bool AAC_ConfigureFromFile(AACReader *read) static void AAC_RegulateDataRate(AACReader *read) { GF_NetworkCommand com; - if (!read) - return; + if (!read) + return; memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = GF_NET_CHAN_BUFFER_QUERY; com.base.on_channel = read->ch; while (read->ch) { - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if (com.buffer.occupancy < com.buffer.max) break; gf_sleep(2); } @@ -315,7 +315,7 @@ static void AAC_OnLiveData(AACReader *read, const char *data, u32 data_size) read->is_live = 1; memset(&read->sl_hdr, 0, sizeof(GF_SLHeader)); #ifndef DONT_USE_TERMINAL_MODULE_API - gf_term_on_connect(read->service, NULL, GF_OK); + gf_service_connect_ack(read->service, NULL, GF_OK); AAC_SetupObject(read); #endif } @@ -336,7 +336,7 @@ static void AAC_OnLiveData(AACReader *read, const char *data, u32 data_size) read->sl_hdr.compositionTimeStampFlag = 1; read->sl_hdr.compositionTimeStamp += 1024; #ifndef DONT_USE_TERMINAL_MODULE_API - gf_term_on_sl_packet(read->service, read->ch, read->data + pos, hdr.frame_size, &read->sl_hdr, GF_OK); + gf_service_send_packet(read->service, read->ch, read->data + pos, hdr.frame_size, &read->sl_hdr, GF_OK); #else SampleCallBack(audio_prog, AUDIO_DATA_ESID, read->data + pos, hdr.frame_size, read->sl_hdr.compositionTimeStamp); #endif @@ -350,12 +350,12 @@ static void AAC_OnLiveData(AACReader *read, const char *data, u32 data_size) time_t now; struct tm *now_tm; const char *opt; - + opt = gf_modules_get_option((GF_BaseInterface *)read->input, "HybRadio", "AudioDelay"); if (opt) { hybrid_delay = atof(opt); } - time(&now); + time(&now); now += (s32)hybrid_delay; now_tm = gmtime(&now); { @@ -364,12 +364,12 @@ static void AAC_OnLiveData(AACReader *read, const char *data, u32 data_size) com.command_type = GF_NET_CHAN_MAP_TIME; com.map_time.media_time = now_tm->tm_hour*3600+now_tm->tm_min*60+now_tm->tm_sec + hybrid_delay; com.map_time.timestamp = read->sl_hdr.compositionTimeStamp; - com.map_time.reset_buffers = 0; + com.map_time.reset_buffers = 0; com.base.on_channel = read->ch; - gf_term_on_command(read->service, &com, GF_OK); - GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[AAC In] Mapping WC Time %04d/%02d/%02d %02d:%02d:%02d and AAC time "LLD" (audio delay %f)\n", - (now_tm->tm_year + 1900), (now_tm->tm_mon + 1), now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, - com.map_time.timestamp, hybrid_delay)); + gf_service_command(read->service, &com, GF_OK); + GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[AAC In] Mapping WC Time %04d/%02d/%02d %02d:%02d:%02d and AAC time "LLD" (audio delay %f)\n", + (now_tm->tm_year + 1900), (now_tm->tm_mon + 1), now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, + com.map_time.timestamp, hybrid_delay)); } read->prev_map_time = read->sl_hdr.compositionTimeStamp; @@ -399,17 +399,17 @@ static void AAC_OnLiveData(AACReader *read, const char *data, u32 data_size) static void AAC_disconnect_from_http_and_free(AACReader * read) { - if (!read) - return; - if (read->dnload){ - gf_dm_sess_abort(read->dnload); + if (!read) + return; + if (read->dnload) { + gf_dm_sess_abort(read->dnload); #ifdef DONT_USE_TERMINAL_MODULE_API - gf_dm_sess_del( read->dnload); + gf_dm_sess_del( read->dnload); #else - gf_term_download_del(read->dnload); + gf_service_download_del(read->dnload); #endif /* DONT_USE_TERMINAL_MODULE_API */ - } - read->dnload = NULL; + } + read->dnload = NULL; } void AAC_NetIO(void *cbk, GF_NETIO_Parameter *param) @@ -451,10 +451,10 @@ void AAC_NetIO(void *cbk, GF_NETIO_Parameter *param) if (!strnicmp(meta, "StreamTitle=", 12)) { read->icy_track_name = gf_strdup(meta+12); - if (!strcmp(read->icy_track_name, "''")){ - /* On some servers, '' means not track name */ - gf_free(read->icy_track_name); - read->icy_track_name = NULL; + if (!strcmp(read->icy_track_name, "''")) { + /* On some servers, '' means not track name */ + gf_free(read->icy_track_name); + read->icy_track_name = NULL; } } if (!sep) break; @@ -463,14 +463,14 @@ void AAC_NetIO(void *cbk, GF_NETIO_Parameter *param) } #ifndef DONT_USE_TERMINAL_MODULE_API com.base.command_type = GF_NET_SERVICE_INFO; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); #endif } return; } else { /*handle service message*/ #ifndef DONT_USE_TERMINAL_MODULE_API - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); #endif if (param->msg_type!=GF_NETIO_DATA_EXCHANGE) return; } @@ -516,7 +516,7 @@ void AAC_NetIO(void *cbk, GF_NETIO_Parameter *param) if (read->needs_connection) { read->needs_connection = 0; #ifndef DONT_USE_TERMINAL_MODULE_API - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); if (!e) AAC_SetupObject(read); #endif } @@ -527,21 +527,21 @@ void aac_download_file(AACReader *read, char *url) read->needs_connection = 1; AAC_disconnect_from_http_and_free(read); #ifndef DONT_USE_TERMINAL_MODULE_API - read->dnload = gf_term_download_new(read->service, url, 0, AAC_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, AAC_NetIO, read); #else { - GF_Err e; - if (!read->dm) - read->dm = gf_dm_new(NULL); - assert( read->dm ); - read->dnload = gf_dm_sess_new_simple(read->dm, url, 0, AAC_NetIO, read, &e); + GF_Err e; + if (!read->dm) + read->dm = gf_dm_new(NULL); + assert( read->dm ); + read->dnload = gf_dm_sess_new_simple(read->dm, url, 0, AAC_NetIO, read, &e); } #endif if (!read->dnload ) { read->needs_connection = 0; #ifndef DONT_USE_TERMINAL_MODULE_API - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); #endif } @@ -555,33 +555,33 @@ void aac_download_file(AACReader *read, char *url) static void AAC_Reader_del(AACReader * read) { - if (!read) - return; - AAC_disconnect_from_http_and_free(read); + if (!read) + return; + AAC_disconnect_from_http_and_free(read); #ifdef DONT_USE_TERMINAL_MODULE_API - if (read->dm) - gf_dm_del(read->dm); - read->dm = NULL; + if (read->dm) + gf_dm_del(read->dm); + read->dm = NULL; #endif - if (read->icy_name) - gf_free(read->icy_name); - if (read->icy_genre) - gf_free(read->icy_genre); - if (read->icy_track_name) - gf_free(read->icy_track_name); - read->icy_name = read->icy_genre = read->icy_track_name = NULL; - if (read->stream) - fclose(read->stream); - if (read->data) - gf_free(read->data); - read->data = NULL; - read->stream = NULL; + if (read->icy_name) + gf_free(read->icy_name); + if (read->icy_genre) + gf_free(read->icy_genre); + if (read->icy_track_name) + gf_free(read->icy_track_name); + read->icy_name = read->icy_genre = read->icy_track_name = NULL; + if (read->stream) + fclose(read->stream); + if (read->data) + gf_free(read->data); + read->data = NULL; + read->stream = NULL; #ifndef DONT_USE_TERMINAL_MODULE_API - gf_free( read ); + gf_free( read ); #endif } -static AACReader * AAC_Reader_new(){ +static AACReader * AAC_Reader_new() { AACReader *reader = gf_malloc(sizeof(AACReader)); memset(reader, 0, sizeof(AACReader)); return reader; @@ -633,7 +633,7 @@ static GF_Err AAC_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->stream = NULL; reply = GF_NOT_SUPPORTED; } - gf_term_on_connect(serv, NULL, reply); + gf_service_connect_ack(serv, NULL, reply); if (!reply && read->is_inline ) AAC_SetupObject(read); return GF_OK; } @@ -641,12 +641,12 @@ static GF_Err AAC_ConnectService(GF_InputService *plug, GF_ClientService *serv, static GF_Err AAC_CloseService(GF_InputService *plug) { AACReader *read; - if (!plug) - return GF_BAD_PARAM; - read = plug->priv; - if (!read) - return GF_BAD_PARAM; - gf_term_on_disconnect(read->service, NULL, GF_OK); + if (!plug) + return GF_BAD_PARAM; + read = plug->priv; + if (!read) + return GF_BAD_PARAM; + gf_service_disconnect_ack(read->service, NULL, GF_OK); AAC_Reader_del( read ); plug->priv = NULL; return GF_OK; @@ -683,9 +683,9 @@ static GF_Err AAC_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co e = GF_SERVICE_ERROR; if (read->ch==channel) { - GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[AAC_IN] read->ch==channel = %p, GF_SERVICE_ERROR\n", channel)); - goto exit; - } + GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[AAC_IN] read->ch==channel = %p, GF_SERVICE_ERROR\n", channel)); + goto exit; + } e = GF_STREAM_NOT_FOUND; if (strstr(url, "ES_ID")) { @@ -700,7 +700,7 @@ static GF_Err AAC_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -713,11 +713,11 @@ static GF_Err AAC_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) AAC_disconnect_from_http_and_free(read); read->ch = NULL; if (read->data) - gf_free(read->data); + gf_free(read->data); read->data = NULL; e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -774,7 +774,7 @@ static GF_Err AAC_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) rcfg.base.command_type = GF_NET_CHAN_DURATION; rcfg.duration.duration = read->duration; rcfg.duration.duration /= read->sample_rate; - gf_term_on_command(read->service, &rcfg, GF_OK); + gf_service_command(read->service, &rcfg, GF_OK); } } } @@ -830,9 +830,9 @@ fetch_next: if (read->input->query_proxy) { GF_NetworkCommand param; param.command_type = GF_NET_SERVICE_QUERY_NEXT; - if ((read->input->query_proxy(read->input, ¶m)==GF_OK) - && param.url_query.next_url - ) { + if ((read->input->query_proxy(read->input, ¶m)==GF_OK) + && param.url_query.next_url + ) { fclose(read->stream); read->stream = gf_f64_open(param.url_query.next_url, "rb"); *out_reception_status = GF_OK; @@ -919,15 +919,15 @@ GF_InputService *AAC_Load() void AAC_Delete(void *ifce) { - AACReader *read; + AACReader *read; GF_InputService *plug = (GF_InputService *) ifce; - if (!plug) - return; + if (!plug) + return; read = plug->priv; - if (read){ - AAC_Reader_del(read); - plug->priv = NULL; - } + if (read) { + AAC_Reader_del(read); + plug->priv = NULL; + } gf_free(plug); } @@ -940,12 +940,12 @@ GPAC_MODULE_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { - #ifndef GPAC_DISABLE_AV_PARSERS +#ifndef GPAC_DISABLE_AV_PARSERS GF_NET_CLIENT_INTERFACE, - #endif - #ifdef GPAC_HAS_FAAD +#endif +#ifdef GPAC_HAS_FAAD GF_MEDIA_DECODER_INTERFACE, - #endif +#endif 0 }; diff --git a/modules/aac_in/faad_dec.c b/modules/aac_in/faad_dec.c index b37ff1e..43241ee 100644 --- a/modules/aac_in/faad_dec.c +++ b/modules/aac_in/faad_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,8 +54,9 @@ typedef struct u16 ES_ID; Bool signal_mc; Bool is_sbr; - + char ch_reorder[16]; + GF_ESD *esd; } FAADDec; @@ -68,11 +69,14 @@ static GF_Err FAAD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) GF_M4ADecSpecInfo a_cfg; #endif FAADCTX(); - + if (ctx->ES_ID && ctx->ES_ID!=esd->ESID) return GF_NOT_SUPPORTED; if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->dataLength) return GF_NON_COMPLIANT_BITSTREAM; - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[FAAD] Attaching stream %d\n", esd->ESID)); + if (!ctx->esd) { + ctx->esd = esd; + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[FAAD] Attaching stream %d\n", esd->ESID)); + } if (ctx->codec) faacDecClose(ctx->codec); ctx->codec = faacDecOpen(); @@ -85,34 +89,34 @@ static GF_Err FAAD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) e = gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg); if (e) return e; #endif - if (faacDecInit2(ctx->codec, (unsigned char *)esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, (unsigned long*)&ctx->sample_rate, (u8*)&ctx->num_channels) < 0) + if (faacDecInit2(ctx->codec, (unsigned char *)esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, (unsigned long*)&ctx->sample_rate, (u8*)&ctx->num_channels) < 0) { #ifndef GPAC_DISABLE_AV_PARSERS s8 res; char *dsi, *s_base_object_type; u32 dsi_len; switch (a_cfg.base_object_type) { - case GF_M4A_AAC_MAIN: - s_base_object_type = gf_stringizer(GF_M4A_AAC_MAIN); - goto base_object_type_error; - case GF_M4A_AAC_LC: - s_base_object_type = gf_stringizer(GF_M4A_AAC_LC); - goto base_object_type_error; - case GF_M4A_AAC_SSR: - s_base_object_type = gf_stringizer(GF_M4A_AAC_SSR); - goto base_object_type_error; - case GF_M4A_AAC_LTP: - s_base_object_type = gf_stringizer(GF_M4A_AAC_LTP); - goto base_object_type_error; - case GF_M4A_AAC_SBR: - s_base_object_type = gf_stringizer(GF_M4A_AAC_SBR); - goto base_object_type_error; - case GF_M4A_AAC_PS: - s_base_object_type = gf_stringizer(GF_M4A_AAC_PS); - base_object_type_error: /*error case*/ - GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[FAAD] Error: unsupported %s format for stream %d - defaulting to AAC LC\n", s_base_object_type, esd->ESID)); - default: - break; + case GF_M4A_AAC_MAIN: + s_base_object_type = gf_stringizer(GF_M4A_AAC_MAIN); + goto base_object_type_error; + case GF_M4A_AAC_LC: + s_base_object_type = gf_stringizer(GF_M4A_AAC_LC); + goto base_object_type_error; + case GF_M4A_AAC_SSR: + s_base_object_type = gf_stringizer(GF_M4A_AAC_SSR); + goto base_object_type_error; + case GF_M4A_AAC_LTP: + s_base_object_type = gf_stringizer(GF_M4A_AAC_LTP); + goto base_object_type_error; + case GF_M4A_AAC_SBR: + s_base_object_type = gf_stringizer(GF_M4A_AAC_SBR); + goto base_object_type_error; + case GF_M4A_AAC_PS: + s_base_object_type = gf_stringizer(GF_M4A_AAC_PS); +base_object_type_error: /*error case*/ + GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[FAAD] Error: unsupported %s format for stream %d - defaulting to AAC LC\n", s_base_object_type, esd->ESID)); + default: + break; } a_cfg.base_object_type = GF_M4A_AAC_LC; a_cfg.has_sbr = 0; @@ -121,7 +125,7 @@ static GF_Err FAAD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) gf_m4a_write_config(&a_cfg, &dsi, &dsi_len); res = faacDecInit2(ctx->codec, (unsigned char *) dsi, dsi_len, (unsigned long *) &ctx->sample_rate, (u8 *) &ctx->num_channels); gf_free(dsi); - if (res < 0) + if (res < 0) #endif { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[FAAD] Error when initializing AAC decoder for stream %d\n", esd->ESID)); @@ -189,16 +193,35 @@ static GF_Err FAAD_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap capability->cap.valueInt = 0; for (i=0; inum_channels; i++) { switch (ctx->info.channel_position[i]) { - case FRONT_CHANNEL_CENTER: capability->cap.valueInt |= GF_AUDIO_CH_FRONT_CENTER; break; - case FRONT_CHANNEL_LEFT: capability->cap.valueInt |= GF_AUDIO_CH_FRONT_LEFT; break; - case FRONT_CHANNEL_RIGHT: capability->cap.valueInt |= GF_AUDIO_CH_FRONT_RIGHT; break; - case SIDE_CHANNEL_LEFT: capability->cap.valueInt |= GF_AUDIO_CH_SIDE_LEFT; break; - case SIDE_CHANNEL_RIGHT: capability->cap.valueInt |= GF_AUDIO_CH_SIDE_RIGHT; break; - case BACK_CHANNEL_LEFT: capability->cap.valueInt |= GF_AUDIO_CH_BACK_LEFT; break; - case BACK_CHANNEL_RIGHT: capability->cap.valueInt |= GF_AUDIO_CH_BACK_RIGHT; break; - case BACK_CHANNEL_CENTER: capability->cap.valueInt |= GF_AUDIO_CH_BACK_CENTER; break; - case LFE_CHANNEL: capability->cap.valueInt |= GF_AUDIO_CH_LFE; break; - default: break; + case FRONT_CHANNEL_CENTER: + capability->cap.valueInt |= GF_AUDIO_CH_FRONT_CENTER; + break; + case FRONT_CHANNEL_LEFT: + capability->cap.valueInt |= GF_AUDIO_CH_FRONT_LEFT; + break; + case FRONT_CHANNEL_RIGHT: + capability->cap.valueInt |= GF_AUDIO_CH_FRONT_RIGHT; + break; + case SIDE_CHANNEL_LEFT: + capability->cap.valueInt |= GF_AUDIO_CH_SIDE_LEFT; + break; + case SIDE_CHANNEL_RIGHT: + capability->cap.valueInt |= GF_AUDIO_CH_SIDE_RIGHT; + break; + case BACK_CHANNEL_LEFT: + capability->cap.valueInt |= GF_AUDIO_CH_BACK_LEFT; + break; + case BACK_CHANNEL_RIGHT: + capability->cap.valueInt |= GF_AUDIO_CH_BACK_RIGHT; + break; + case BACK_CHANNEL_CENTER: + capability->cap.valueInt |= GF_AUDIO_CH_BACK_CENTER; + break; + case LFE_CHANNEL: + capability->cap.valueInt |= GF_AUDIO_CH_LFE; + break; + default: + break; } } break; @@ -219,25 +242,43 @@ static s8 FAAD_GetChannelPos(FAADDec *ffd, u32 ch_cfg) u32 i; for (i=0; iinfo.channels; i++) { switch (ffd->info.channel_position[i]) { - case FRONT_CHANNEL_CENTER: if (ch_cfg==GF_AUDIO_CH_FRONT_CENTER) return i; break; - case FRONT_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_FRONT_LEFT) return i; break; - case FRONT_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_FRONT_RIGHT) return i; break; - case SIDE_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_SIDE_LEFT) return i; break; - case SIDE_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_SIDE_RIGHT) return i; break; - case BACK_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_BACK_LEFT) return i; break; - case BACK_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_BACK_RIGHT) return i; break; - case BACK_CHANNEL_CENTER: if (ch_cfg==GF_AUDIO_CH_BACK_CENTER) return i; break; - case LFE_CHANNEL: if (ch_cfg==GF_AUDIO_CH_LFE) return i; break; + case FRONT_CHANNEL_CENTER: + if (ch_cfg==GF_AUDIO_CH_FRONT_CENTER) return i; + break; + case FRONT_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_FRONT_LEFT) return i; + break; + case FRONT_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_FRONT_RIGHT) return i; + break; + case SIDE_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_SIDE_LEFT) return i; + break; + case SIDE_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_SIDE_RIGHT) return i; + break; + case BACK_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_BACK_LEFT) return i; + break; + case BACK_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_BACK_RIGHT) return i; + break; + case BACK_CHANNEL_CENTER: + if (ch_cfg==GF_AUDIO_CH_BACK_CENTER) return i; + break; + case LFE_CHANNEL: + if (ch_cfg==GF_AUDIO_CH_LFE) return i; + break; } } return -1; } -static GF_Err FAAD_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err FAAD_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { void *buffer; unsigned short *conv_in, *conv_out; @@ -267,6 +308,8 @@ static GF_Err FAAD_ProcessData(GF_MediaDecoder *ifcg, if (ctx->info.error>0) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[FAAD] Error decoding AU %s\n", faacDecGetErrorMessage(ctx->info.error) )); *outBufferLength = 0; + //reinit if error + FAAD_AttachStream((GF_BaseDecoder *)ifcg, ctx->esd); return GF_NON_COMPLIANT_BITSTREAM; } if (!ctx->info.samples || !buffer || !ctx->info.bytesconsumed) { @@ -286,34 +329,61 @@ static GF_Err FAAD_ProcessData(GF_MediaDecoder *ifcg, /*get cfg*/ ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_FRONT_LEFT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_FRONT_RIGHT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_FRONT_CENTER); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_LFE); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_BACK_LEFT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_BACK_RIGHT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_BACK_CENTER); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_SIDE_LEFT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } ch = FAAD_GetChannelPos(ctx, GF_AUDIO_CH_SIDE_RIGHT); - if (ch>=0) { ctx->ch_reorder[idx] = ch; idx++; } + if (ch>=0) { + ctx->ch_reorder[idx] = ch; + idx++; + } *outBufferLength = ctx->out_size; if (sizeof(short) * ctx->info.samples > *outBufferLength) { - *outBufferLength = ctx->out_size = sizeof(short)*ctx->info.samples; + *outBufferLength = ctx->out_size = sizeof(short)*ctx->info.samples; } return GF_BUFFER_TOO_SMALL; } if (sizeof(short) * ctx->info.samples > *outBufferLength) { - *outBufferLength = sizeof(short)*ctx->info.samples; + *outBufferLength = sizeof(short)*ctx->info.samples; return GF_BUFFER_TOO_SMALL; - } + } /*we assume left/right order*/ if (ctx->num_channels<=2) { @@ -345,7 +415,7 @@ static u32 FAAD_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd GF_M4ADecSpecInfo a_cfg; #endif - /*audio decs*/ + /*audio decs*/ if (StreamType != GF_STREAM_AUDIO) return GF_CODEC_NOT_SUPPORTED; /*media type query*/ if (!esd) return GF_CODEC_STREAM_TYPE_SUPPORTED; @@ -356,7 +426,7 @@ static u32 FAAD_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: /*MPEG4 aac*/ - case GPAC_OTI_AUDIO_AAC_MPEG4: + case GPAC_OTI_AUDIO_AAC_MPEG4: break; default: return GF_CODEC_NOT_SUPPORTED; @@ -398,7 +468,7 @@ GF_BaseDecoder *NewFAADDec() ifce->privateStack = dec; - /*setup our own interface*/ + /*setup our own interface*/ ifce->AttachStream = FAAD_AttachStream; ifce->DetachStream = FAAD_DetachStream; ifce->GetCapabilities = FAAD_GetCapabilities; diff --git a/modules/ac3_in/ac3_in.c b/modules/ac3_in/ac3_in.c index 1fc81af..47ca89f 100644 --- a/modules/ac3_in/ac3_in.c +++ b/modules/ac3_in/ac3_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include @@ -35,7 +35,7 @@ typedef struct GF_ClientService *service; Bool is_remote; - + FILE *stream; u32 duration; @@ -72,10 +72,10 @@ static const char * AC3_DESC = "AC3 Music"; static u32 AC3_RegisterMimeTypes(const GF_InputService *plug) { - u32 i; - for (i = 0 ; AC3_MIMES[i]; i++) - gf_term_register_mime_type(plug, AC3_MIMES[i], AC3_EXTS, AC3_DESC); - return i; + u32 i; + for (i = 0 ; AC3_MIMES[i]; i++) + gf_service_register_mime(plug, AC3_MIMES[i], AC3_EXTS, AC3_DESC); + return i; } static Bool AC3_CanHandleURL(GF_InputService *plug, const char *url) @@ -83,8 +83,8 @@ static Bool AC3_CanHandleURL(GF_InputService *plug, const char *url) char *sExt; u32 i; sExt = strrchr(url, '.'); - for (i = 0 ; AC3_MIMES[i]; i++){ - if (gf_term_check_extension(plug, AC3_MIMES[i], AC3_EXTS, AC3_DESC, sExt)) return 1; + for (i = 0 ; AC3_MIMES[i]; i++) { + if (gf_service_check_mime_register(plug, AC3_MIMES[i], AC3_EXTS, AC3_DESC, sExt)) return 1; } return 0; } @@ -117,7 +117,7 @@ static void AC3_SetupObject(AC3Reader *read) esd = AC3_GetESD(read); esd->OCRESID = 0; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } @@ -129,7 +129,7 @@ static Bool AC3_ConfigureFromFile(AC3Reader *read) if (!read->stream) return 0; bs = gf_bs_from_file(read->stream, GF_BITSTREAM_READ); - + sync = gf_ac3_parser_bs(bs, &hdr, 1); if (!sync) { gf_bs_del(bs); @@ -138,7 +138,7 @@ static Bool AC3_ConfigureFromFile(AC3Reader *read) read->nb_ch = hdr.channels; read->sample_rate = hdr.sample_rate; read->duration = 0; - + if (!read->is_remote) { read->duration = 1536; gf_bs_skip_bytes(bs, hdr.framesize); @@ -160,7 +160,7 @@ static void AC3_RegulateDataRate(AC3Reader *read) com.command_type = GF_NET_CHAN_BUFFER_QUERY; com.base.on_channel = read->ch; while (read->ch) { - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if (com.buffer.occupancy < com.buffer.max) break; gf_sleep(2); } @@ -172,7 +172,7 @@ static void AC3_OnLiveData(AC3Reader *read, const char *data, u32 data_size) Bool sync; GF_BitStream *bs; GF_AC3Header hdr; - + read->data = gf_realloc(read->data, sizeof(char)*(read->data_size+data_size) ); memcpy(read->data + read->data_size, data, sizeof(char)*data_size); read->data_size += data_size; @@ -187,7 +187,7 @@ static void AC3_OnLiveData(AC3Reader *read, const char *data, u32 data_size) read->sample_rate = hdr.sample_rate; read->is_live = 1; memset(&read->sl_hdr, 0, sizeof(GF_SLHeader)); - gf_term_on_connect(read->service, NULL, GF_OK); + gf_service_connect_ack(read->service, NULL, GF_OK); AC3_SetupObject(read); } if (!read->ch) return; @@ -205,7 +205,7 @@ static void AC3_OnLiveData(AC3Reader *read, const char *data, u32 data_size) read->sl_hdr.AU_sequenceNumber++; read->sl_hdr.compositionTimeStampFlag = 1; read->sl_hdr.compositionTimeStamp += 1536; - gf_term_on_sl_packet(read->service, read->ch, (char *) read->data + pos, hdr.framesize, &read->sl_hdr, GF_OK); + gf_service_send_packet(read->service, read->ch, (char *) read->data + pos, hdr.framesize, &read->sl_hdr, GF_OK); gf_bs_skip_bytes(bs, hdr.framesize); } @@ -257,7 +257,7 @@ void AC3_NetIO(void *cbk, GF_NETIO_Parameter *param) while (meta && meta[0]) { char *sep = strchr(meta, ';'); if (sep) sep[0] = 0; - + if (!strnicmp(meta, "StreamTitle=", 12)) { read->icy_track_name = gf_strdup(meta+12); } @@ -267,12 +267,12 @@ void AC3_NetIO(void *cbk, GF_NETIO_Parameter *param) } com.base.command_type = GF_NET_SERVICE_INFO; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); } return; } else { /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); if (param->msg_type!=GF_NETIO_DATA_EXCHANGE) return; } @@ -316,7 +316,7 @@ void AC3_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (read->needs_connection) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); if (!e) AC3_SetupObject(read); } } @@ -327,10 +327,10 @@ void ac3_download_file(GF_InputService *plug, char *url) read->needs_connection = 1; - read->dnload = gf_term_download_new(read->service, url, 0, AC3_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, AC3_NetIO, read); if (!read->dnload ) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -347,7 +347,7 @@ static GF_Err AC3_ConnectService(GF_InputService *plug, GF_ClientService *serv, AC3Reader *read = plug->priv; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; strcpy(szURL, url); @@ -370,7 +370,7 @@ static GF_Err AC3_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->stream = NULL; reply = GF_NOT_SUPPORTED; } - gf_term_on_connect(serv, NULL, reply); + gf_service_connect_ack(serv, NULL, reply); if (!reply && read->is_inline ) AC3_SetupObject(read); return GF_OK; } @@ -380,12 +380,12 @@ static GF_Err AC3_CloseService(GF_InputService *plug) AC3Reader *read = plug->priv; if (read->stream) fclose(read->stream); read->stream = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; if (read->data) gf_free(read->data); read->data = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -434,7 +434,7 @@ static GF_Err AC3_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -449,7 +449,7 @@ static GF_Err AC3_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) read->data = NULL; e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -495,8 +495,8 @@ static GF_Err AC3_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) read->current_time = 0; if (read->stream) gf_f64_seek(read->stream, 0, SEEK_SET); - if (read->ch == com->base.on_channel) { - read->done = 0; + if (read->ch == com->base.on_channel) { + read->done = 0; /*PLAY after complete download, estimate duration*/ if (!read->is_remote && !read->duration) { AC3_ConfigureFromFile(read); @@ -506,7 +506,7 @@ static GF_Err AC3_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) rcfg.base.command_type = GF_NET_CHAN_DURATION; rcfg.duration.duration = read->duration; rcfg.duration.duration /= read->sample_rate; - gf_term_on_command(read->service, &rcfg, GF_OK); + gf_service_command(read->service, &rcfg, GF_OK); } } } @@ -585,7 +585,7 @@ fetch_next: read->start_range = 0; } } - + read->sl_hdr.compositionTimeStamp = read->current_time; read->data = gf_malloc(sizeof(char) * (read->data_size+read->pad_bytes)); @@ -654,23 +654,23 @@ void DeleteAC3Dec(GF_BaseDecoder *ifcg); #endif GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { -static u32 si [] = { + static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS - GF_NET_CLIENT_INTERFACE, + GF_NET_CLIENT_INTERFACE, #endif #ifdef GPAC_HAS_LIBA52 - GF_MEDIA_DECODER_INTERFACE, + GF_MEDIA_DECODER_INTERFACE, #endif - 0 -}; + 0 + }; return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS if (InterfaceType == GF_NET_CLIENT_INTERFACE) return (GF_BaseInterface *)AC3_Load(); diff --git a/modules/ac3_in/liba52_dec.c b/modules/ac3_in/liba52_dec.c index 11db2f2..9e4704e 100644 --- a/modules/ac3_in/liba52_dec.c +++ b/modules/ac3_in/liba52_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -49,7 +49,7 @@ typedef struct { a52_state_t *codec; - sample_t* samples; + sample_t* samples; u32 sample_rate, num_samples, out_size, flags; u8 num_channels; @@ -76,7 +76,7 @@ static GF_Err AC3_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[A52] Error initializing decoder\n")); return GF_IO_ERR; } - ctx->samples = a52_samples(ctx->codec); + ctx->samples = a52_samples(ctx->codec); if (!ctx->samples) { a52_free(ctx->codec); GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[A52] Error initializing decoder\n")); @@ -187,15 +187,33 @@ static s8 AC3_GetChannelPos(AC3Dec *ffd, u32 ch_cfg) u32 i; for (i=0; iinfo.channels; i++) { switch (ffd->info.channel_position[i]) { - case FRONT_CHANNEL_CENTER: if (ch_cfg==GF_AUDIO_CH_FRONT_CENTER) return i; break; - case FRONT_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_FRONT_LEFT) return i; break; - case FRONT_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_FRONT_RIGHT) return i; break; - case SIDE_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_SIDE_LEFT) return i; break; - case SIDE_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_SIDE_RIGHT) return i; break; - case BACK_CHANNEL_LEFT: if (ch_cfg==GF_AUDIO_CH_BACK_LEFT) return i; break; - case BACK_CHANNEL_RIGHT: if (ch_cfg==GF_AUDIO_CH_BACK_RIGHT) return i; break; - case BACK_CHANNEL_CENTER: if (ch_cfg==GF_AUDIO_CH_BACK_CENTER) return i; break; - case LFE_CHANNEL: if (ch_cfg==GF_AUDIO_CH_LFE) return i; break; + case FRONT_CHANNEL_CENTER: + if (ch_cfg==GF_AUDIO_CH_FRONT_CENTER) return i; + break; + case FRONT_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_FRONT_LEFT) return i; + break; + case FRONT_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_FRONT_RIGHT) return i; + break; + case SIDE_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_SIDE_LEFT) return i; + break; + case SIDE_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_SIDE_RIGHT) return i; + break; + case BACK_CHANNEL_LEFT: + if (ch_cfg==GF_AUDIO_CH_BACK_LEFT) return i; + break; + case BACK_CHANNEL_RIGHT: + if (ch_cfg==GF_AUDIO_CH_BACK_RIGHT) return i; + break; + case BACK_CHANNEL_CENTER: + if (ch_cfg==GF_AUDIO_CH_BACK_CENTER) return i; + break; + case LFE_CHANNEL: + if (ch_cfg==GF_AUDIO_CH_LFE) return i; + break; } } return -1; @@ -205,39 +223,39 @@ static s8 AC3_GetChannelPos(AC3Dec *ffd, u32 ch_cfg) /**** the following two functions comes from a52dec */ static GFINLINE s32 blah (s32 i) { - if (i > 0x43c07fff) - return 32767; - else if (i < 0x43bf8000) - return -32768; - return i - 0x43c00000; + if (i > 0x43c07fff) + return 32767; + else if (i < 0x43bf8000) + return -32768; + return i - 0x43c00000; } static GFINLINE void float_to_int (float * _f, s16 *samps, int nchannels) { - int i, j, c; - s32 * f = (s32 *) _f; // XXX assumes IEEE float format - - j = 0; - nchannels *= 256; - for (i = 0; i < 256; i++) { - for (c = 0; c < nchannels; c += 256) - samps[j++] = blah (f[i + c]); - } + int i, j, c; + s32 * f = (s32 *) _f; // XXX assumes IEEE float format + + j = 0; + nchannels *= 256; + for (i = 0; i < 256; i++) { + for (c = 0; c < nchannels; c += 256) + samps[j++] = blah (f[i + c]); + } } /**** end */ static const int ac3_channels[8] = { - 2, 1, 2, 3, 3, 4, 4, 5 + 2, 1, 2, 3, 3, 4, 4, 5 }; static GF_Err AC3_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { - short *out_samples; + short *out_samples; int i, len, bit_rate; sample_t level; A52CTX(); @@ -339,16 +357,16 @@ GF_BaseDecoder *NewAC3Dec() void DeleteAC3Dec(GF_BaseDecoder *ifcg) { AC3Dec *ctx; - if (!ifcg) - return; - ctx = (AC3Dec *) ifcg->privateStack; - if (ctx){ - if (ctx->codec) - a52_free(ctx->codec); - ctx->codec = NULL; - gf_free(ctx); - ifcg->privateStack = NULL; - } + if (!ifcg) + return; + ctx = (AC3Dec *) ifcg->privateStack; + if (ctx) { + if (ctx->codec) + a52_free(ctx->codec); + ctx->codec = NULL; + gf_free(ctx); + ifcg->privateStack = NULL; + } gf_free(ifcg); } diff --git a/modules/alsa/alsa.c b/modules/alsa/alsa.c index df68767..ff1748f 100644 --- a/modules/alsa/alsa.c +++ b/modules/alsa/alsa.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -28,11 +28,11 @@ #include #include #include -#include +#include #include -typedef struct +typedef struct { snd_pcm_t *playback_handle; u32 nb_ch, buf_size, delay, num_buffers, total_duration, block_align; @@ -47,7 +47,7 @@ static GF_Err ALSA_Setup(GF_AudioOutput*dr, void *os_handle, u32 num_buffers, u3 int err; const char *opt; ALSAContext *ctx = (ALSAContext*)dr->opaque; - + opt = gf_modules_get_option((GF_BaseInterface *)dr, "ALSA", "ForceSampleRate"); if (opt) ctx->force_sr = atoi(opt); @@ -180,7 +180,7 @@ static GF_Err ALSA_ConfigureOutput(GF_AudioOutput*dr, u32 *SampleRate, u32 *NbCh ctx->buf_size *= ctx->block_align; /*get period time*/ snd_pcm_hw_params_get_period_time(hw_params, &period_time, 0); - + err = snd_pcm_hw_params(ctx->playback_handle, hw_params); if (err < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[ALSA] Cannot set parameters: %s\n", snd_strerror (err)) ); @@ -196,7 +196,7 @@ static GF_Err ALSA_ConfigureOutput(GF_AudioOutput*dr, u32 *SampleRate, u32 *NbCh if(!ctx->wav_buf) return GF_OUT_OF_MEM; memset(ctx->wav_buf, 0, ctx->buf_size*sizeof(char)); GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[ALSA] Setup %d ch @ %d hz - %d periods of %d us - total buffer size %d - overall delay %d ms\n", ctx->nb_ch, sr, nb_bufs, period_time, ctx->buf_size, ctx->delay)); - + return GF_OK; err_exit: @@ -239,7 +239,7 @@ static void ALSA_WriteAudio(GF_AudioOutput*dr) GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[ALSA] no frame to write\n" )); return; } - + //assert(nb_frames*ctx->block_align<=ctx->buf_size); written = dr->FillBuffer(dr->audio_renderer, ctx->wav_buf, (u32) (ctx->block_align*nb_frames) ); if (!written) return; @@ -260,11 +260,11 @@ static void ALSA_SetVolume(GF_AudioOutput*dr, u32 Volume) { } -static void ALSA_SetPan(GF_AudioOutput*dr, u32 Pan) +static void ALSA_SetPan(GF_AudioOutput*dr, u32 Pan) { } -static void ALSA_SetPriority(GF_AudioOutput*dr, u32 Priority) +static void ALSA_SetPriority(GF_AudioOutput*dr, u32 Priority) { } @@ -352,19 +352,19 @@ void DeleteALSAOutput(void *ifce) * interface */ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_AUDIO_OUTPUT_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewALSAOutput(); return NULL; } diff --git a/modules/amr_dec/amr_dec.c b/modules/amr_dec/amr_dec.c index 7da0c59..ed7ade6 100644 --- a/modules/amr_dec/amr_dec.c +++ b/modules/amr_dec/amr_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,7 +42,7 @@ #define DEFAULT_AUDIO_CM_TRIGGER 4 /*our own headers for AMR NB*/ -#if (defined(WIN32) || defined(_WIN32_WCE)) +#if (defined(WIN32) || defined(_WIN32_WCE)) #include "amr_nb_api.h" #if !defined(__GNUC__) #pragma comment(lib, "libamrnb") @@ -57,9 +57,9 @@ typedef struct u32 out_size; /*AMR NB state vars*/ __Speech_Decode_FrameState * speech_decoder_state; - enum RXFrameType rx_type; - enum Mode mode; - + enum RXFrameType rx_type; + enum Mode mode; + s16 reset_flag, reset_flag_old; } AMRDec; @@ -72,9 +72,9 @@ static GF_Err AMR_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) u32 packed_size; AMRCTX(); if (esd->dependsOnESID || !esd->decoderConfig->decoderSpecificInfo) return GF_NOT_SUPPORTED; - - if (strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "samr", 4) - && strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "amr ", 4)) return GF_NOT_SUPPORTED; + + if (strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "samr", 4) + && strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "amr ", 4)) return GF_NOT_SUPPORTED; ctx->reset_flag = 0; ctx->reset_flag_old = 1; @@ -86,7 +86,7 @@ static GF_Err AMR_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) packed_size = (u32) (esd->decoderConfig->decoderSpecificInfo->dataLength>14) ? esd->decoderConfig->decoderSpecificInfo->data[13] : 0; /*max possible frames in a sample are seen in MP4, that's 15*/ if (!packed_size) packed_size = 15; - + ctx->out_size = packed_size * 2 * 160; return GF_OK; } @@ -150,18 +150,18 @@ static GF_Err AMR_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab /* frame size in serial bitstream file (frame type + serial stream + flags) */ #define SERIAL_FRAMESIZE (270) -static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { - u32 offset = 0; - u8 toc, q, ft; - s16 *synth; - u8 *packed_bits; - s16 serial[SERIAL_FRAMESIZE]; - s32 i; + u32 offset = 0; + u8 toc, q, ft; + s16 *synth; + u8 *packed_bits; + s16 serial[SERIAL_FRAMESIZE]; + s32 i; AMRCTX(); /*if late or seeking don't decode (each frame is a RAP)*/ @@ -178,15 +178,15 @@ static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, *outBufferLength = ctx->out_size; return GF_BUFFER_TOO_SMALL; } - - synth = (s16 *) outBuffer; + + synth = (s16 *) outBuffer; *outBufferLength = 0; - while (inBufferLength) { - toc = inBuffer[0]; - /* read rest of the frame based on ToC byte */ - q = (toc >> 2) & 0x01; - ft = (toc >> 3) & 0x0F; + while (inBufferLength) { + toc = inBuffer[0]; + /* read rest of the frame based on ToC byte */ + q = (toc >> 2) & 0x01; + ft = (toc >> 3) & 0x0F; packed_bits = inBuffer + 1; offset = 1 + GF_AMR_FRAME_SIZE[ft]; @@ -199,7 +199,7 @@ static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, } else { ctx->speech_decoder_state->prev_mode = ctx->mode; } - + /* if homed: check if this frame is another homing frame */ if (ctx->reset_flag_old == 1) { /* only check until end of first subframe */ @@ -210,14 +210,14 @@ static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, for (i = 0; i < L_FRAME; i++) { synth[i] = EHF_MASK; } - } else { + } else { /* decode frame */ Speech_Decode_Frame(ctx->speech_decoder_state, ctx->mode, &serial[1], ctx->rx_type, synth); } *outBufferLength += 160*2; synth += 160; - + /* if not homed: check whether current frame is a homing frame */ if (ctx->reset_flag_old == 0) { ctx->reset_flag = decoder_homing_frame_test(&serial[1], ctx->mode); @@ -233,7 +233,7 @@ static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, inBuffer += offset; if (*outBufferLength > ctx->out_size) return GF_NON_COMPLIANT_BITSTREAM; - } + } return GF_OK; } @@ -250,7 +250,7 @@ static u32 AMR_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, dsi = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data : NULL; if (!dsi) return GF_CODEC_NOT_SUPPORTED; if (esd->decoderConfig->decoderSpecificInfo->dataLength < 4) return GF_CODEC_NOT_SUPPORTED; - + if (!strnicmp(dsi, "samr", 4) || !strnicmp(dsi, "amr ", 4)) return GF_CODEC_SUPPORTED; return GF_CODEC_NOT_SUPPORTED; } @@ -271,7 +271,7 @@ GF_MediaDecoder *NewAMRDecoder() ifce->privateStack = dec; ifce->CanHandleStream = AMR_CanHandleStream; - /*setup our own interface*/ + /*setup our own interface*/ ifce->AttachStream = AMR_AttachStream; ifce->DetachStream = AMR_DetachStream; ifce->GetCapabilities = AMR_GetCapabilities; @@ -292,7 +292,7 @@ void DeleteAMRDecoder(GF_BaseDecoder *ifcg) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_NET_CLIENT_INTERFACE, @@ -309,9 +309,12 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_MEDIA_DECODER_INTERFACE: return (GF_BaseInterface *) NewAMRDecoder(); - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *) NewAESReader(); - default: return NULL; + case GF_MEDIA_DECODER_INTERFACE: + return (GF_BaseInterface *) NewAMRDecoder(); + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *) NewAESReader(); + default: + return NULL; } } @@ -319,8 +322,12 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_MEDIA_DECODER_INTERFACE: DeleteAMRDecoder((GF_BaseDecoder *)ifce); break; - case GF_NET_CLIENT_INTERFACE: DeleteAESReader(ifce); break; + case GF_MEDIA_DECODER_INTERFACE: + DeleteAMRDecoder((GF_BaseDecoder *)ifce); + break; + case GF_NET_CLIENT_INTERFACE: + DeleteAESReader(ifce); + break; } } diff --git a/modules/amr_dec/amr_in.c b/modules/amr_dec/amr_in.c index 08c172b..8581ae5 100644 --- a/modules/amr_dec/amr_in.c +++ b/modules/amr_dec/amr_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include @@ -71,9 +71,9 @@ static const char * AMR_MIMES[] = { "audio/ac3", "audio/x-ac3", NULL }; static u32 AMR_RegisterMimeTypes(const GF_InputService *plug) { - gf_term_register_mime_type(plug, "audio/amr", "amr awb", "AMR Speech Data"); - gf_term_register_mime_type(plug, "audio/evrc", "evc", "EVRC Speech Data"); - gf_term_register_mime_type(plug, "audio/smv", "smv", "SMV Speech Data"); + gf_service_register_mime(plug, "audio/amr", "amr awb", "AMR Speech Data"); + gf_service_register_mime(plug, "audio/evrc", "evc", "EVRC Speech Data"); + gf_service_register_mime(plug, "audio/smv", "smv", "SMV Speech Data"); return 3; } @@ -101,7 +101,7 @@ static GF_ESD *AMR_GetESD(AMR_Reader *read) gf_bs_write_u8(dsi, 1); gf_bs_get_content(dsi, & esd->decoderConfig->decoderSpecificInfo->data, & esd->decoderConfig->decoderSpecificInfo->dataLength); gf_bs_del(dsi); - } + } else if (read->mtype==TYPE_EVRC) esd->decoderConfig->objectTypeIndication = 0xA0; else if (read->mtype==TYPE_SMV) esd->decoderConfig->objectTypeIndication = 0xA1; return esd; @@ -115,7 +115,7 @@ static void AMR_SetupObject(AMR_Reader *read) esd = AMR_GetESD(read); esd->OCRESID = 0; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } static Bool AMR_CanHandleURL(GF_InputService *plug, const char *url) @@ -123,9 +123,9 @@ static Bool AMR_CanHandleURL(GF_InputService *plug, const char *url) char *sExt; sExt = strrchr(url, '.'); if (!sExt) return 0; - if (gf_term_check_extension(plug, "audio/amr", "amr awb", "AMR Speech Data", sExt)) return 1; - if (gf_term_check_extension(plug, "audio/evrc", "evc", "EVRC Speech Data", sExt)) return 1; - if (gf_term_check_extension(plug, "audio/smv", "smv", "SMV Speech Data", sExt)) return 1; + if (gf_service_check_mime_register(plug, "audio/amr", "amr awb", "AMR Speech Data", sExt)) return 1; + if (gf_service_check_mime_register(plug, "audio/evrc", "evc", "EVRC Speech Data", sExt)) return 1; + if (gf_service_check_mime_register(plug, "audio/smv", "smv", "SMV Speech Data", sExt)) return 1; return 0; } @@ -175,7 +175,7 @@ static Bool AMR_ConfigureFromFile(AMR_Reader *read) read->duration = 0; - + if (!read->is_remote) { u32 size; while (!feof(read->stream)) { @@ -223,7 +223,7 @@ static void AMR_NetIO(void *cbk, GF_NETIO_Parameter *param) } } else { /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); if (param->msg_type!=GF_NETIO_DATA_EXCHANGE) return; } @@ -259,7 +259,7 @@ static void AMR_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (read->needs_connection) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); if (!e) AMR_SetupObject(read); } } @@ -270,10 +270,10 @@ static void AMR_DownloadFile(GF_InputService *plug, char *url) read->needs_connection = 1; - read->dnload = gf_term_download_new(read->service, url, 0, AMR_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, AMR_NetIO, read); if (!read->dnload) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -290,7 +290,7 @@ static GF_Err AMR_ConnectService(GF_InputService *plug, GF_ClientService *serv, AMR_Reader *read = plug->priv; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; strcpy(szURL, url); @@ -313,7 +313,7 @@ static GF_Err AMR_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->stream = NULL; reply = GF_NOT_SUPPORTED; } - gf_term_on_connect(serv, NULL, reply); + gf_service_connect_ack(serv, NULL, reply); if (!reply && read->is_inline) AMR_SetupObject(read); return GF_OK; } @@ -323,12 +323,12 @@ static GF_Err AMR_CloseService(GF_InputService *plug) AMR_Reader *read = plug->priv; if (read->stream) fclose(read->stream); read->stream = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; if (read->data) gf_free(read->data); read->data = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -375,7 +375,7 @@ static GF_Err AMR_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -390,7 +390,7 @@ static GF_Err AMR_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) read->data = NULL; e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -419,8 +419,8 @@ static GF_Err AMR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) read->current_time = 0; if (read->stream) fseek(read->stream, read->start_offset, SEEK_SET); - if (read->ch == com->base.on_channel) { - read->done = 0; + if (read->ch == com->base.on_channel) { + read->done = 0; /*PLAY after complete download, estimate duration*/ if (!read->is_remote && !read->duration) { AMR_ConfigureFromFile(read); @@ -430,7 +430,7 @@ static GF_Err AMR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) rcfg.base.command_type = GF_NET_CHAN_DURATION; rcfg.duration.duration = read->duration; rcfg.duration.duration /= read->sample_rate; - gf_term_on_command(read->service, &rcfg, GF_OK); + gf_service_command(read->service, &rcfg, GF_OK); } } } @@ -506,7 +506,7 @@ fetch_next: read->start_range = 0; } } - + read->data_size++; read->sl_hdr.compositionTimeStamp = read->current_time; read->data = gf_malloc(sizeof(char) * (read->data_size+read->pad_bytes)); @@ -570,7 +570,7 @@ void DeleteAESReader(void *ifce) #ifdef GPAC_AMR_IN_STANDALONE GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_NET_CLIENT_INTERFACE, @@ -583,8 +583,10 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *) NewAESReader(); - default: return NULL; + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *) NewAESReader(); + default: + return NULL; } } @@ -592,7 +594,9 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_NET_CLIENT_INTERFACE: DeleteAESReader(ifce); break; + case GF_NET_CLIENT_INTERFACE: + DeleteAESReader(ifce); + break; } } diff --git a/modules/amr_dec/amr_nb/typedefs.h b/modules/amr_dec/amr_nb/typedefs.h index 0777505..2e42acb 100644 --- a/modules/amr_dec/amr_nb/typedefs.h +++ b/modules/amr_dec/amr_nb/typedefs.h @@ -2,8 +2,8 @@ ******************************************************************************** * * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 -* R99 Version 3.3.0 -* REL-4 Version 4.1.0 +* R99 Version 3.3.0 +* REL-4 Version 4.1.0 * ******************************************************************************** * @@ -36,7 +36,7 @@ * OSF only defined if the current platform is an Alpha * PC only defined if the current platform is a PC * SUN only defined if the current platform is a Sun -* +* * LSBFIRST is defined if the byte order on this platform is * "least significant byte first" -> defined on DEC Alpha * and PC, undefined on Sun @@ -58,7 +58,7 @@ /* ******************************************************************************** -* DEFINITION OF CONSTANTS +* DEFINITION OF CONSTANTS ******************************************************************************** */ /* @@ -147,8 +147,8 @@ typedef unsigned long UWord32; ********* define complex type */ typedef struct { - Float r; /* real part */ - Float i; /* imaginary part */ + Float r; /* real part */ + Float i; /* imaginary part */ } CPX; /* @@ -185,9 +185,9 @@ typedef struct { #error "can't determine architecture; adapt typedefs.h to your platform" #endif -#if defined(_WIN32_WCE) +#if defined(_WIN32_WCE) # ifndef abort -# define abort() +# define abort() # endif #endif diff --git a/modules/amr_dec/amr_nb_api.h b/modules/amr_dec/amr_nb_api.h index ae5fbbd..fcdfa37 100644 --- a/modules/amr_dec/amr_nb_api.h +++ b/modules/amr_dec/amr_nb_api.h @@ -1,21 +1,21 @@ -#ifndef _AMR_NB_API_H -#define _AMR_NB_API_H - +#ifndef _AMR_NB_API_H +#define _AMR_NB_API_H + enum Mode { MR475 = 0, - MR515, + MR515, MR59, MR67, MR74, MR795, MR102, - MR122, + MR122, + + MRDTX, - MRDTX, - N_MODES /* number of (SPC) modes */ }; - + enum RXFrameType { RX_SPEECH_GOOD = 0, RX_SPEECH_DEGRADED, RX_ONSET, @@ -25,36 +25,36 @@ enum RXFrameType { RX_SPEECH_GOOD = 0, RX_SID_BAD, RX_NO_DATA, RX_N_FRAMETYPES /* number of frame types */ -}; - -typedef struct{ - void* decoder_amrState; - void* post_state; - void* postHP_state; - enum Mode prev_mode; - - int complexityCounter; /* Only for complexity computation */ + }; + +typedef struct { + void* decoder_amrState; + void* post_state; + void* postHP_state; + enum Mode prev_mode; + + int complexityCounter; /* Only for complexity computation */ } __Speech_Decode_FrameState; - + int Speech_Decode_Frame_init (__Speech_Decode_FrameState **st, char *id); void Speech_Decode_Frame_exit (__Speech_Decode_FrameState **st); -void Speech_Decode_Frame (__Speech_Decode_FrameState *st, enum Mode mode, short *serial, enum RXFrameType frame_type, short *synth); -int Speech_Decode_Frame_reset (__Speech_Decode_FrameState **st); +void Speech_Decode_Frame (__Speech_Decode_FrameState *st, enum Mode mode, short *serial, enum RXFrameType frame_type, short *synth); +int Speech_Decode_Frame_reset (__Speech_Decode_FrameState **st); s16 decoder_homing_frame_test_first (s16 input_frame[], enum Mode mode); s16 decoder_homing_frame_test (s16 input_frame[], enum Mode mode); - -#ifdef MMS_IO - -enum RXFrameType UnpackBits ( - s8 q, /* i : Q-bit (i.e. BFI) */ - s16 ft, /* i : frame type (i.e. mode) */ - u8 packed_bits[], /* i : sorted & packed bits */ - enum Mode *mode, /* o : mode information */ - s16 bits[] /* o : serial bits */ -); -#endif - + +#ifdef MMS_IO + +enum RXFrameType UnpackBits ( + s8 q, /* i : Q-bit (i.e. BFI) */ + s16 ft, /* i : frame type (i.e. mode) */ + u8 packed_bits[], /* i : sorted & packed bits */ + enum Mode *mode, /* o : mode information */ + s16 bits[] /* o : serial bits */ +); +#endif + #define EHF_MASK 0x0008 /* encoder homing frame pattern */ #define L_FRAME 160 /* Frame size */ diff --git a/modules/amr_float_dec/amr_api.h b/modules/amr_float_dec/amr_api.h index dd6082f..a761c26 100644 --- a/modules/amr_float_dec/amr_api.h +++ b/modules/amr_float_dec/amr_api.h @@ -4,21 +4,21 @@ /*AMR*/ void Decoder_Interface_Decode( void *st, #ifndef ETSI - unsigned char *bits, + unsigned char *bits, #else - short *bits, + short *bits, #endif - short *synth, int bfi ); + short *synth, int bfi ); void *Decoder_Interface_init( void ); void Decoder_Interface_exit( void *state ); - - - -/*AMR WB*/ - + + + +/*AMR WB*/ + #define NB_SERIAL_MAX 61 /* max serial size */ #define L_FRAME16k 320 /* Frame size at 16kHz */ @@ -31,5 +31,5 @@ void Decoder_Interface_exit( void *state ); void D_IF_decode(void *st, unsigned char *bits, short *synth, long bfi); void * D_IF_init(void); void D_IF_exit(void *state); - + #endif //_AMR_API_H \ No newline at end of file diff --git a/modules/amr_float_dec/amr_float_dec.c b/modules/amr_float_dec/amr_float_dec.c index 176cafe..98dad50 100644 --- a/modules/amr_float_dec/amr_float_dec.c +++ b/modules/amr_float_dec/amr_float_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -69,7 +69,7 @@ typedef struct /*AMR NB state vars*/ int *nb_destate; - void *wb_destate; + void *wb_destate; } AMRFTDec; #define AMRFTCTX() AMRFTDec *ctx = (AMRFTDec *) ifcg->privateStack @@ -80,7 +80,7 @@ static GF_Err AMR_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) GF_BitStream *bs; u32 packed; AMRFTCTX(); - if (esd->dependsOnESID || !esd->decoderConfig->decoderSpecificInfo) return GF_NOT_SUPPORTED; + if (esd->dependsOnESID || !esd->decoderConfig->decoderSpecificInfo) return GF_NOT_SUPPORTED; /*AMRWB dec is another module*/ if (!strnicmp(esd->decoderConfig->decoderSpecificInfo->data, "sawb", 4)) ctx->is_amr_wb = 1; @@ -193,14 +193,14 @@ static GF_Err AMR_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab } -static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { - u32 offset; - u8 toc, ft; + u32 offset; + u8 toc, ft; AMRFTCTX(); /*if late or seeking don't decode (each frame is a RAP)*/ @@ -217,10 +217,10 @@ static GF_Err AMR_ProcessData(GF_MediaDecoder *ifcg, *outBufferLength = ctx->out_size; return GF_BUFFER_TOO_SMALL; } - + *outBufferLength = 0; - while (inBufferLength) { + while (inBufferLength) { toc = inBuffer[0]; ft = (toc >> 3) & 0x0F; @@ -289,7 +289,7 @@ GF_MediaDecoder *NewAMRFTDecoder() ifce->privateStack = dec; ifce->CanHandleStream = AMR_CanHandleStream; - /*setup our own interface*/ + /*setup our own interface*/ ifce->AttachStream = AMR_AttachStream; ifce->DetachStream = AMR_DetachStream; ifce->GetCapabilities = AMR_GetCapabilities; @@ -314,7 +314,7 @@ GF_InputService *NewAESReader(); void DeleteAESReader(void *ifce); GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_NET_CLIENT_INTERFACE, @@ -328,9 +328,12 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_MEDIA_DECODER_INTERFACE: return (GF_BaseInterface *)NewAMRFTDecoder(); - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *)NewAESReader(); - default: return NULL; + case GF_MEDIA_DECODER_INTERFACE: + return (GF_BaseInterface *)NewAMRFTDecoder(); + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *)NewAESReader(); + default: + return NULL; } } @@ -338,8 +341,12 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_MEDIA_DECODER_INTERFACE: DeleteAMRFTDecoder((GF_BaseDecoder *)ifce); break; - case GF_NET_CLIENT_INTERFACE: DeleteAESReader(ifce); break; + case GF_MEDIA_DECODER_INTERFACE: + DeleteAMRFTDecoder((GF_BaseDecoder *)ifce); + break; + case GF_NET_CLIENT_INTERFACE: + DeleteAESReader(ifce); + break; } } diff --git a/modules/audio_filter/audio_filter.c b/modules/audio_filter/audio_filter.c index 3837020..ee46e48 100644 --- a/modules/audio_filter/audio_filter.c +++ b/modules/audio_filter/audio_filter.c @@ -12,16 +12,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -32,7 +32,7 @@ #define PI GF_PI #endif -typedef struct +typedef struct { u32 type; Bool inplace; @@ -140,7 +140,7 @@ static GF_Err Configure(GF_AudioFilter *af, u32 in_sr, u32 in_bps, u32 in_nb_ch, if (ctx->delai_buffer) gf_free(ctx->delai_buffer); ctx->delai_buffer = gf_malloc(sizeof(char)*ctx->delai_buffer_size); memset(ctx->delai_buffer, 0, sizeof(char)*ctx->delai_buffer_size); - + if (ctx->block_buffer) gf_free(ctx->block_buffer); ctx->block_buffer = gf_malloc(sizeof(char)*ctx->block_size); memset(ctx->block_buffer, 0, sizeof(char)*ctx->block_size); @@ -261,19 +261,19 @@ void DeleteAudioFilter(void *ifce) * interface */ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_AUDIO_FILTER_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - if (InterfaceType == GF_AUDIO_FILTER_INTERFACE) + if (InterfaceType == GF_AUDIO_FILTER_INTERFACE) return NewAudioFilter(); return NULL; } diff --git a/modules/avcap/avcap.cpp b/modules/avcap/avcap.cpp index d781af5..19cbe16 100644 --- a/modules/avcap/avcap.cpp +++ b/modules/avcap/avcap.cpp @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -60,7 +60,7 @@ using namespace avcap; class GPACCaptureHandler : public CaptureHandler { public: - GPACCaptureHandler(GF_ClientService *service, LPNETCHANNEL channel) + GPACCaptureHandler(GF_ClientService *service, LPNETCHANNEL channel) : m_pService(service), m_pChannel(channel), m_data(NULL) { memset(&m_pSLHeader, 0, sizeof(GF_SLHeader)); @@ -103,9 +103,9 @@ void GPACCaptureHandler::handleCaptureEvent(IOBuffer* io_buf) for (u32 i=0; igetValidBytes(), &m_pSLHeader, GF_OK); + gf_service_send_packet(m_pService, m_pChannel, m_data, (u32)io_buf->getValidBytes(), &m_pSLHeader, GF_OK); } else { - gf_term_on_sl_packet(m_pService, m_pChannel, (char *) io_buf->getPtr(), (u32)io_buf->getValidBytes(), &m_pSLHeader, GF_OK); + gf_service_send_packet(m_pService, m_pChannel, (char *) io_buf->getPtr(), (u32)io_buf->getValidBytes(), &m_pSLHeader, GF_OK); } io_buf->release(); } @@ -120,7 +120,7 @@ DeviceDescriptor* get_device_descriptor(char *name) for(DeviceCollector::DeviceList::const_iterator i = dl.begin(); i != dl.end(); i++, index++) { dd = *i; - if (!name || !stricmp(name, "default") ) + if (!name || !stricmp(name, "default") ) return dd; if (strstr((char *) dd->getName().c_str(), name) != NULL) return dd; @@ -193,26 +193,26 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const if (!vcap->device_desc) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[VideoCapture] Failed to instanciate AVCap\n")); - gf_term_on_connect(serv, NULL, GF_REMOTE_SERVICE_ERROR); + gf_service_connect_ack(serv, NULL, GF_REMOTE_SERVICE_ERROR); return GF_OK; } - + vcap->device_desc->open(); if ( (!strnicmp(url, "camera://", 9) || !strnicmp(url, "video://", 8)) && !vcap->device_desc->isVideoCaptureDev()) { vcap->device_desc->close(); - gf_term_on_connect(serv, NULL, GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } else if (!strnicmp(url, "audio://", 8) && !vcap->device_desc->isAudioDev()) { vcap->device_desc->close(); - gf_term_on_connect(serv, NULL, GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } vcap->device = vcap->device_desc->getDevice(); if (!vcap->device) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[VideoCapture] Failed to initialize capture device\n")); vcap->device_desc->close(); - gf_term_on_connect(serv, NULL, GF_SERVICE_ERROR); + gf_service_connect_ack(serv, NULL, GF_SERVICE_ERROR); return GF_OK; } vcap->device->getFormatMgr()->setFramerate(30); @@ -228,7 +228,7 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const while (params) { char *sep = (char *) strchr(params, '&'); if (sep) sep[0] = 0; - + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[VideoCapture] Set camera option %s\n", params)); if (!strnicmp(params, "resolution=", 11)) { @@ -272,7 +272,7 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const if (default_4cc ) vcap->device->getFormatMgr()->setFormat(default_4cc ); - + format = vcap->device->getFormatMgr()->getFormat(); switch (format->getFourcc()) { case GF_4CC('V', 'Y', 'U', 'Y'): @@ -294,19 +294,19 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const default: GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[VideoCapture] Unsupported 4CC %s (%08x) from capture device\n", gf_4cc_to_str(format->getFourcc()), format->getFourcc())); vcap->device_desc->close(); - gf_term_on_connect(serv, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(serv, NULL, GF_NOT_SUPPORTED); return GF_OK; } GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[VideoCapture] Device configured - resolution %dx%d - Frame Rate %d - Pixel Format %s (Device 4CC %08x) \n", vcap->width, vcap->height, vcap->fps, gf_4cc_to_str(vcap->pixel_format), format->getFourcc())); } /*ACK connection is OK*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); /*setup object descriptor*/ od = (GF_ObjectDescriptor *) gf_odf_desc_new(GF_ODF_OD_TAG); - + esd = gf_odf_desc_esd_new(0); esd->slConfig->timestampResolution = 1000; if (!strnicmp(url, "camera://", 9) || !strnicmp(url, "video://", 8)) { @@ -319,7 +319,7 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const esd->decoderConfig->streamType = GF_STREAM_AUDIO; } esd->decoderConfig->objectTypeIndication = GPAC_OTI_RAW_MEDIA_STREAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); gf_bs_write_u32(bs, vcap->pixel_format); gf_bs_write_u16(bs, vcap->width); @@ -330,7 +330,7 @@ GF_Err AVCap_ConnectService(GF_InputService *plug, GF_ClientService *serv, const gf_bs_del(bs); gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(vcap->service, (GF_Descriptor*)od, GF_FALSE); + gf_service_declare_media(vcap->service, (GF_Descriptor*)od, GF_FALSE); return GF_OK; } @@ -344,7 +344,7 @@ GF_Err AVCap_CloseService(GF_InputService *plug) } vcap->state = 0; - gf_term_on_disconnect(vcap->service, NULL, GF_OK); + gf_service_disconnect_ack(vcap->service, NULL, GF_OK); return GF_OK; } @@ -362,10 +362,13 @@ GF_Err AVCap_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (!com->base.on_channel) return GF_NOT_SUPPORTED; switch (com->command_type) { - case GF_NET_CHAN_SET_PULL: return GF_NOT_SUPPORTED; - case GF_NET_CHAN_INTERACTIVE: return GF_OK; + case GF_NET_CHAN_SET_PULL: + return GF_NOT_SUPPORTED; + case GF_NET_CHAN_INTERACTIVE: + return GF_OK; /*since data is file-based, no padding is needed (decoder plugin will handle it itself)*/ - case GF_NET_CHAN_SET_PADDING: return GF_OK; + case GF_NET_CHAN_SET_PADDING: + return GF_OK; case GF_NET_CHAN_BUFFER: com->buffer.max = com->buffer.min = 500; return GF_OK; @@ -379,7 +382,7 @@ GF_Err AVCap_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (vcap->video_handler) vcap->device->getVidCapMgr()->registerCaptureHandler(vcap->video_handler); - if (vcap->device->getVidCapMgr()->startCapture() != -1) + if (vcap->device->getVidCapMgr()->startCapture() != -1) vcap->state = 1; else vcap->device->getVidCapMgr()->removeCaptureHandler(); @@ -389,11 +392,12 @@ GF_Err AVCap_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (vcap->state==1) { /*stop capture*/ vcap->device->getVidCapMgr()->removeCaptureHandler(); - vcap->device->getVidCapMgr()->stopCapture(); + vcap->device->getVidCapMgr()->stopCapture(); vcap->state = 0; } return GF_OK; - case GF_NET_CHAN_CONFIG: return GF_OK; + case GF_NET_CHAN_CONFIG: + return GF_OK; case GF_NET_CHAN_GET_DSI: com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; @@ -408,7 +412,7 @@ GF_Err AVCap_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const c { u32 ESID; AVCapIn *vcap = (AVCapIn *) plug->priv; - + sscanf(url, "ES_ID=%u", &ESID); if (ESID == 1) { /*video connect*/ @@ -417,13 +421,13 @@ GF_Err AVCap_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const c if (vcap->flip_video) vcap->video_handler->AllocData(vcap->height, vcap->stride); - gf_term_on_connect(vcap->service, channel, GF_OK); + gf_service_connect_ack(vcap->service, channel, GF_OK); } else if (ESID == 2) { /*audio connect*/ vcap->audio_handler = new GPACCaptureHandler(vcap->service, channel); - gf_term_on_connect(vcap->service, channel, GF_OK); + gf_service_connect_ack(vcap->service, channel, GF_OK); } else { - gf_term_on_connect(vcap->service, channel, GF_STREAM_NOT_FOUND); + gf_service_connect_ack(vcap->service, channel, GF_STREAM_NOT_FOUND); } return GF_OK; } @@ -439,7 +443,7 @@ GF_Err AVCap_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) delete vcap->audio_handler; vcap->audio_handler = NULL; } - gf_term_on_disconnect(vcap->service, channel, GF_OK); + gf_service_disconnect_ack(vcap->service, channel, GF_OK); return GF_OK; } @@ -450,7 +454,7 @@ Bool AVCap_CanHandleURLInService(GF_InputService *plug, const char *url) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_NET_CLIENT_INTERFACE, @@ -482,7 +486,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) GF_SAFEALLOC(vcap, AVCapIn); plug->priv = vcap; return (GF_BaseInterface *)plug; - } + } return NULL; } diff --git a/modules/bifs_dec/bifs_dec.c b/modules/bifs_dec/bifs_dec.c index 1c19c8e..6d11351 100644 --- a/modules/bifs_dec/bifs_dec.c +++ b/modules/bifs_dec/bifs_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -95,7 +95,7 @@ static GF_Err BIFS_DetachStream(GF_BaseDecoder *plug, u16 ES_ID) } static GF_Err BIFS_ProcessData(GF_SceneDecoder*plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_time, u32 mmlevel) + u16 ES_ID, u32 AU_time, u32 mmlevel) { Double ts_offset; s32 time; @@ -137,16 +137,16 @@ static u32 BIFS_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *es void DeleteBIFSDec(GF_BaseDecoder *plug) { BIFSPriv *priv; - if (!plug) - return; - priv = (BIFSPriv *)plug->privateStack; - if (priv){ - /*in case something went wrong*/ - if (priv->codec) gf_bifs_decoder_del(priv->codec); - priv->codec = NULL; - gf_free(priv); - plug->privateStack = NULL; - } + if (!plug) + return; + priv = (BIFSPriv *)plug->privateStack; + if (priv) { + /*in case something went wrong*/ + if (priv->codec) gf_bifs_decoder_del(priv->codec); + priv->codec = NULL; + gf_free(priv); + plug->privateStack = NULL; + } gf_free(plug); } diff --git a/modules/ctx_load/ctx_load.c b/modules/ctx_load/ctx_load.c index 5a13ff7..9afe8ba 100644 --- a/modules/ctx_load/ctx_load.c +++ b/modules/ctx_load/ctx_load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -231,8 +231,8 @@ static GF_Err CTXLoad_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) ext++; if (!stricmp(ext, "xmt") || !stricmp(ext, "xmtz") || !stricmp(ext, "xmta") - || !stricmp(ext, "x3d") || !stricmp(ext, "x3dz") - ) { + || !stricmp(ext, "x3d") || !stricmp(ext, "x3dz") + ) { ext = gf_modules_get_option((GF_BaseInterface *)plug, "SAXLoader", "Progressive"); priv->progressive_support = (ext && !stricmp(ext, "yes")) ? 1 : 0; } @@ -320,7 +320,7 @@ static void CTXLoad_CheckStreams(CTXLoadPriv *priv ) } static GF_Err CTXLoad_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 stream_time, u32 mmlevel) + u16 ES_ID, u32 stream_time, u32 mmlevel) { GF_Err e = GF_OK; u32 i, j, k, nb_updates, last_rap=0; @@ -633,7 +633,7 @@ static GF_Err CTXLoad_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u } if (keep_com) break; } - break; + break; case GF_ODF_OD_REMOVE_TAG: { GF_ODRemove *odR = (GF_ODRemove*)com; @@ -642,7 +642,7 @@ static GF_Err CTXLoad_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u if (odm) gf_odm_disconnect(odm, 1); } } - break; + break; default: break; } @@ -681,17 +681,27 @@ const char *CTXLoad_GetName(struct _basedecoder *plug) CTXLoadPriv *priv = (CTXLoadPriv *)plug->privateStack; switch (priv->load.type) { - case GF_SM_LOAD_BT: return "MPEG-4 BT Parser"; - case GF_SM_LOAD_VRML: return "VRML 97 Parser"; - case GF_SM_LOAD_X3DV: return "X3D (VRML Syntax) Parser"; - case GF_SM_LOAD_XMTA: return "XMT-A Parser"; - case GF_SM_LOAD_X3D: return "X3D (XML Syntax) Parser"; - case GF_SM_LOAD_SWF: return "Flash (SWF) Emulator"; - case GF_SM_LOAD_XSR: return "LASeRML Loader"; - case GF_SM_LOAD_MP4: return "MP4 Memory Loader"; - case GF_SM_LOAD_XBL: return "XBL Parser"; - - default: return "Undetermined"; + case GF_SM_LOAD_BT: + return "MPEG-4 BT Parser"; + case GF_SM_LOAD_VRML: + return "VRML 97 Parser"; + case GF_SM_LOAD_X3DV: + return "X3D (VRML Syntax) Parser"; + case GF_SM_LOAD_XMTA: + return "XMT-A Parser"; + case GF_SM_LOAD_X3D: + return "X3D (XML Syntax) Parser"; + case GF_SM_LOAD_SWF: + return "Flash (SWF) Emulator"; + case GF_SM_LOAD_XSR: + return "LASeRML Loader"; + case GF_SM_LOAD_MP4: + return "MP4 Memory Loader"; + case GF_SM_LOAD_XBL: + return "XBL Parser"; + + default: + return "Undetermined"; } } @@ -721,7 +731,7 @@ static u32 CTXLoad_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD case GPAC_OTI_SCENE_SVG_GZ: case GPAC_OTI_SCENE_DIMS: return GF_CODEC_MAYBE_SUPPORTED; - default: + default: break; } } @@ -731,20 +741,20 @@ static u32 CTXLoad_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD void DeleteContextLoader(GF_BaseDecoder *plug) { CTXLoadPriv *priv; - if (!plug) - return; - priv = (CTXLoadPriv *)plug->privateStack; - if (priv){ - if (priv->file_name) - gf_free(priv->file_name); - priv->file_name = NULL; - assert(!priv->ctx); - if (priv->files_to_delete) - gf_list_del(priv->files_to_delete); - priv->files_to_delete = NULL; - gf_free(priv); - plug->privateStack = NULL; - } + if (!plug) + return; + priv = (CTXLoadPriv *)plug->privateStack; + if (priv) { + if (priv->file_name) + gf_free(priv->file_name); + priv->file_name = NULL; + assert(!priv->ctx); + if (priv->files_to_delete) + gf_list_del(priv->files_to_delete); + priv->files_to_delete = NULL; + gf_free(priv); + plug->privateStack = NULL; + } gf_free(plug); } @@ -777,11 +787,12 @@ GF_BaseDecoder *NewContextLoader() GPAC_MODULE_EXPORT const u32 *QueryInterfaces() { -static u32 si [] = { + static u32 si [] = { #ifndef GPAC_DISABLE_VRML - GF_SCENE_DECODER_INTERFACE, + GF_SCENE_DECODER_INTERFACE, #endif - 0}; + 0 + }; return si; } @@ -790,7 +801,8 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { #ifndef GPAC_DISABLE_VRML - case GF_SCENE_DECODER_INTERFACE: return (GF_BaseInterface *)NewContextLoader(); + case GF_SCENE_DECODER_INTERFACE: + return (GF_BaseInterface *)NewContextLoader(); #endif default: return NULL; diff --git a/modules/demo_is/demo_is.c b/modules/demo_is/demo_is.c index a4654eb..fcd5d84 100644 --- a/modules/demo_is/demo_is.c +++ b/modules/demo_is/demo_is.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -46,7 +46,7 @@ static void DEV_Start(struct __input_device *ifce) bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); /*HTK sensor buffer format: SFString - SFInt32 - SFFloat*/ - gf_bs_write_int(bs, 1, 1); + gf_bs_write_int(bs, 1, 1); len = strlen(szWord); val = gf_get_bit_size(len); gf_bs_write_int(bs, val, 5); @@ -67,7 +67,7 @@ static void DEV_Stop(struct __input_device *ifce) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_INPUT_DEVICE_INTERFACE, diff --git a/modules/directfb_out/directfb_out.c b/modules/directfb_out/directfb_out.c index 5227203..8d03864 100755 --- a/modules/directfb_out/directfb_out.c +++ b/modules/directfb_out/directfb_out.c @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Romain Bouqueau - Jean Le Feuvre + * Authors: Romain Bouqueau - Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details.0 - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ /** * function DirectFBVid_DrawHLine - * - using hardware accelerator to a draw horizontal line + * - using hardware accelerator to a draw horizontal line **/ static void DirectFBVid_DrawHLine(GF_VideoOutput *driv, u32 x, u32 y, u32 length, GF_Color color) { @@ -49,7 +49,7 @@ static void DirectFBVid_DrawHLine(GF_VideoOutput *driv, u32 x, u32 y, u32 length /** * function DirectFBVid_DrawHLineAlpha - * - using hardware accelerator to draw a horizontal line with alpha + * - using hardware accelerator to draw a horizontal line with alpha **/ static void DirectFBVid_DrawHLineAlpha(GF_VideoOutput *driv, u32 x, u32 y, u32 length, GF_Color color, u8 alpha) { @@ -64,7 +64,7 @@ static void DirectFBVid_DrawHLineAlpha(GF_VideoOutput *driv, u32 x, u32 y, u32 l /** * function DirectFBVid_DrawRectangle - * - using hardware accelerator to fill a rectangle + * - using hardware accelerator to fill a rectangle **/ static void DirectFBVid_DrawRectangle(GF_VideoOutput *driv, u32 x, u32 y, u32 width, u32 height, GF_Color color) { @@ -79,15 +79,15 @@ static void DirectFBVid_DrawRectangle(GF_VideoOutput *driv, u32 x, u32 y, u32 wi /** * function DirectFBVid_Setup - * - DirectFB setup + * - DirectFB setup **/ GF_Err DirectFBVid_Setup(GF_VideoOutput *driv, void *os_handle, void *os_display, u32 init_flags) { const char* opt; - + DirectFBVID(); DirectFBVid_CtxSetIsInit(ctx, 0); - + // initialisation and surface creation GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DirectFB] Initialization\n")); // check window mode used - SDL or X11 @@ -99,7 +99,7 @@ GF_Err DirectFBVid_Setup(GF_VideoOutput *driv, void *os_handle, void *os_display else if (opt && !strcmp(opt, "SDL")) window_mode = WINDOW_SDL; DirectFBVid_InitAndCreateSurface(ctx, window_mode); } - + // check hardware accelerator configuration DirectFBVid_CtxSetDisableAcceleration(ctx, 0); opt = gf_modules_get_option((GF_BaseInterface *)driv, "DirectFB", "DisableAcceleration"); @@ -121,7 +121,7 @@ GF_Err DirectFBVid_Setup(GF_VideoOutput *driv, void *os_handle, void *os_display else if (opt && !strcmp(opt, "wait")) flip_mode |= FLIP_WAIT; else if (opt && !strcmp(opt, "sync")) flip_mode |= FLIP_ONSYNC; else if (opt && !strcmp(opt, "swap")) flip_mode |= FLIP_SWAP; - + DirectFBVid_CtxSetFlipMode(ctx, flip_mode); } @@ -173,7 +173,7 @@ static void DirectFBVid_Shutdown(GF_VideoOutput *driv) /** * function DirectFBVid_Flush - * - flushing buffer + * - flushing buffer **/ static GF_Err DirectFBVid_Flush(GF_VideoOutput *driv, GF_Window *dest) { @@ -188,7 +188,7 @@ static GF_Err DirectFBVid_Flush(GF_VideoOutput *driv, GF_Window *dest) /** * function DirectFBVid_SetFullScreen - * - set fullscreen mode + * - set fullscreen mode **/ GF_Err DirectFBVid_SetFullScreen(GF_VideoOutput *driv, u32 bFullScreenOn, u32 *screen_width, u32 *screen_height) { @@ -203,7 +203,7 @@ GF_Err DirectFBVid_SetFullScreen(GF_VideoOutput *driv, u32 bFullScreenOn, u32 *s /** * function DirectFBVid_ProcessMessageQueue - * - handle DirectFB events + * - handle DirectFB events **/ Bool DirectFBVid_ProcessMessageQueue(DirectFBVidCtx *ctx, GF_VideoOutput *driv) { @@ -221,7 +221,7 @@ Bool DirectFBVid_ProcessMessageQueue(DirectFBVidCtx *ctx, GF_VideoOutput *driv) /** * function DirectFBVid_ProcessEvent - * - process events + * - process events **/ static GF_Err DirectFBVid_ProcessEvent(GF_VideoOutput *driv, GF_Event *evt) { @@ -294,14 +294,14 @@ static GF_Err DirectFBVid_LockBackBuffer(GF_VideoOutput *driv, GF_VideoSurface * DirectFBVid_CtxPrimaryUnlock(ctx); GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DirectFB] backbuffer unlocked\n")); } - + return GF_OK; } /** * function DirectFBVid_Blit - * - blit a surface + * - blit a surface **/ static GF_Err DirectFBVid_Blit(GF_VideoOutput *driv, GF_VideoSurface *video_src, GF_Window *src_wnd, GF_Window *dst_wnd, u32 overlay_type) { @@ -322,7 +322,7 @@ static GF_Err DirectFBVid_Blit(GF_VideoOutput *driv, GF_VideoSurface *video_src, /** * function DirectFBNewVideo - * - creates a DirectFb module + * - creates a DirectFb module **/ void *DirectFBNewVideo() { @@ -353,7 +353,7 @@ void *DirectFBNewVideo() /** - * function DirectFBDeleteVideo + * function DirectFBDeleteVideo * - delete video **/ void DirectFBDeleteVideo(void *ifce) diff --git a/modules/directfb_out/directfb_out.h b/modules/directfb_out/directfb_out.h index 2dfa1fa..f7b948d 100755 --- a/modules/directfb_out/directfb_out.h +++ b/modules/directfb_out/directfb_out.h @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Romain Bouqueau - Jean Le Feuvre + * Authors: Romain Bouqueau - Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/directfb_out/directfb_wrapper.c b/modules/directfb_out/directfb_wrapper.c index e87906c..15d423a 100644 --- a/modules/directfb_out/directfb_wrapper.c +++ b/modules/directfb_out/directfb_wrapper.c @@ -1,8 +1,8 @@ /* * GPAC Multimedia Framework * - * Authors: Romain Bouqueau - Jean Le Feuvre - * Copyright (c) Telecom ParisTech 2010-2012 + * Authors: Romain Bouqueau - Jean Le Feuvre + * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * * This file is part of GPAC / DirectFB video output module @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -53,7 +53,7 @@ static int do_xor = 0; DirectFBErrorFatal( #x, err ); \ } \ } while (0) - + #define SET_DRAWING_FLAGS( flags ) \ ctx->primary->SetDrawingFlags( ctx->primary, (flags) | (do_xor ? DSDRAW_XOR : 0) ) @@ -62,39 +62,39 @@ static int do_xor = 0; struct __DirectFBVidCtx { - /* the super interface */ - IDirectFB *dfb; - /* the primary surface */ - IDirectFBSurface *primary; - - /* for keyboard input */ - //~ IDirectFBInputDevice *keyboard; - - /* screen width, height */ - u32 width, height, pixel_format; - Bool use_systems_memory, disable_acceleration, disable_aa, is_init, disable_display; - - /* acceleration */ - int accel_drawline, accel_fillrect; - DFBSurfaceFlipFlags flip_mode; - - /*===== for key events =====*/ - - /* Input interfaces: devices and its buffer */ - IDirectFBEventBuffer *events; - - /* mouse events */ - IDirectFBInputDevice *mouse; - - /*============================= + /* the super interface */ + IDirectFB *dfb; + /* the primary surface */ + IDirectFBSurface *primary; + + /* for keyboard input */ + //~ IDirectFBInputDevice *keyboard; + + /* screen width, height */ + u32 width, height, pixel_format; + Bool use_systems_memory, disable_acceleration, disable_aa, is_init, disable_display; + + /* acceleration */ + int accel_drawline, accel_fillrect; + DFBSurfaceFlipFlags flip_mode; + + /*===== for key events =====*/ + + /* Input interfaces: devices and its buffer */ + IDirectFBEventBuffer *events; + + /* mouse events */ + IDirectFBInputDevice *mouse; + + /*============================= if using window - ============================= */ - - /* DirectFB window */ - IDirectFBWindow *window; - - /* display layer */ - IDirectFBDisplayLayer *layer; + ============================= */ + + /* DirectFB window */ + IDirectFBWindow *window; + + /* display layer */ + IDirectFBDisplayLayer *layer; }; @@ -107,9 +107,9 @@ size_t DirectFBVid_GetCtxSizeOf(void) typedef struct _DeviceInfo DeviceInfo; struct _DeviceInfo { - DFBInputDeviceID device_id; - DFBInputDeviceDescription desc; - DeviceInfo *next; + DFBInputDeviceID device_id; + DFBInputDeviceDescription desc; + DeviceInfo *next; }; @@ -118,18 +118,18 @@ struct _DeviceInfo { /** * function DirectFBVid_DrawHLineWrapper - * - using hardware accelerator to draw horizontal line + * - using hardware accelerator to draw horizontal line **/ void DirectFBVid_DrawHLineWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 length, u8 r, u8 g, u8 b) { //GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DirectFB] in DirectFBVid_DrawHLine(). Drawing line x %d y %d length %d color %08X\n", x, y, length, color)); - - // DSDRAW_NOFX: flag controlling drawing command, drawing without using any effects + + // DSDRAW_NOFX: flag controlling drawing command, drawing without using any effects SET_DRAWING_FLAGS( DSDRAW_NOFX ); - // set the color used without alpha - ctx->primary->SetColor(ctx->primary, r, g, b, 0xFF); - + // set the color used without alpha + ctx->primary->SetColor(ctx->primary, r, g, b, 0xFF); + // to draw a line using hardware accelerators, we can use either DrawLine (in our STB, DrawLine() function is not accelerated) or FillRectangle function with height equals to 1 //ctx->primary->DrawLine(ctx->primary, x, y, x+length, y); // no acceleration ctx->primary->FillRectangle(ctx->primary, x, y,length, 1); @@ -138,7 +138,7 @@ void DirectFBVid_DrawHLineWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 length, /** * function DirectFBVid_DrawHLineWrapper - * - using hardware accelerator to draw horizontal line with alpha + * - using hardware accelerator to draw horizontal line with alpha **/ void DirectFBVid_DrawHLineAlphaWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 length, u8 r, u8 g, u8 b, u8 alpha) { @@ -155,7 +155,7 @@ void DirectFBVid_DrawHLineAlphaWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 le /** * function DirectFBVid_DrawRectangleWrapper - * - using hardware accelerator to fill a rectangle with the given color + * - using hardware accelerator to fill a rectangle with the given color **/ void DirectFBVid_DrawRectangleWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 width, u32 height, u8 r, u8 g, u8 b, u8 a) { @@ -171,7 +171,7 @@ void DirectFBVid_DrawRectangleWrapper(DirectFBVidCtx *ctx, u32 x, u32 y, u32 wid /** * function DirectFBVid_CtxPrimaryLock - * - lock the surface (in order to access certain data) + * - lock the surface (in order to access certain data) **/ u32 DirectFBVid_CtxPrimaryLock(DirectFBVidCtx *ctx, void **buf, u32 *pitch) { @@ -186,7 +186,7 @@ static DFBEnumerationResult enum_input_device(DFBInputDeviceID device_id, DFBInp DeviceInfo **devices = data; DeviceInfo *device = malloc(sizeof(DeviceInfo) ); - + device->device_id = device_id; device->desc = desc; device->next = *devices; @@ -199,7 +199,7 @@ static DFBEnumerationResult enum_input_device(DFBInputDeviceID device_id, DFBInp /** * function DirectFBVid_InitAndCreateSurface - * - initialize and create DirectFB surface + * - initialize and create DirectFB surface **/ u32 DirectFBVid_TranslatePixelFormatToGPAC(u32 dfbpf); void DirectFBVid_InitAndCreateSurface(DirectFBVidCtx *ctx, u32 window_mode) @@ -208,7 +208,7 @@ void DirectFBVid_InitAndCreateSurface(DirectFBVidCtx *ctx, u32 window_mode) DFBSurfaceDescription dsc; DFBSurfacePixelFormat dfbpf; DeviceInfo *devices = NULL; - + //fake arguments and DirectFBInit() { int i, argc=2, argc_ro=2; @@ -222,14 +222,14 @@ void DirectFBVid_InitAndCreateSurface(DirectFBVidCtx *ctx, u32 window_mode) } else { argv_ro[1]=argv[1]=strdup("--dfb:system=x11"); } - + // screen resolution 640x480 //~ argv_ro[2]=argv[2]=strdup("--dfb:mode=640x480"); //~ argv_ro[2]=argv[2]=strdup(""); /* create the super interface */ DFBCHECK(DirectFBInit(&argc, &argv)); - + for (i=0; idfb->GetInputDevice(ctx->dfb, devices->device_id, &(ctx->mouse))); } - + /* create an event buffer for all devices */ DFBCHECK(ctx->dfb->CreateInputEventBuffer(ctx->dfb, DICAPS_KEYS, DFB_FALSE, &(ctx->events) )); @@ -289,7 +289,7 @@ void DirectFBVid_CtxPrimaryUnlock(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxGetWidth - * - returns screen width + * - returns screen width **/ u32 DirectFBVid_CtxGetWidth(DirectFBVidCtx *ctx) { @@ -299,7 +299,7 @@ u32 DirectFBVid_CtxGetWidth(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxGetHeight - * - returns screen height + * - returns screen height **/ u32 DirectFBVid_CtxGetHeight(DirectFBVidCtx *ctx) { @@ -309,7 +309,7 @@ u32 DirectFBVid_CtxGetHeight(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxGetPrimary - * - return the primary surface + * - return the primary surface **/ void *DirectFBVid_CtxGetPrimary(DirectFBVidCtx *ctx) { @@ -319,7 +319,7 @@ void *DirectFBVid_CtxGetPrimary(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxGetPixelFormat - * - get pixel format + * - get pixel format **/ u32 DirectFBVid_CtxGetPixelFormat(DirectFBVidCtx *ctx) { @@ -329,7 +329,7 @@ u32 DirectFBVid_CtxGetPixelFormat(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxIsHwMemory - * - return value whether system memory is used or not + * - return value whether system memory is used or not **/ Bool DirectFBVid_CtxIsHwMemory(DirectFBVidCtx *ctx) { @@ -339,7 +339,7 @@ Bool DirectFBVid_CtxIsHwMemory(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxPrimaryFlip - * - flipping buffers + * - flipping buffers **/ u32 DirectFBVid_CtxPrimaryFlip(DirectFBVidCtx *ctx) { @@ -349,7 +349,7 @@ u32 DirectFBVid_CtxPrimaryFlip(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxSetDisableDisplay - * - set disable display value + * - set disable display value **/ void DirectFBVid_CtxSetDisableDisplay(DirectFBVidCtx *ctx, Bool val) { @@ -359,7 +359,7 @@ void DirectFBVid_CtxSetDisableDisplay(DirectFBVidCtx *ctx, Bool val) /** * function DirectFBVid_CtxGetDisableDisplay - * - boolean showing whether display is enabled/disabled + * - boolean showing whether display is enabled/disabled **/ Bool DirectFBVid_CtxGetDisableDisplay(DirectFBVidCtx *ctx) { @@ -369,7 +369,7 @@ Bool DirectFBVid_CtxGetDisableDisplay(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxSetDisableAcceleration - * - boolean showing whether hardware accelerator is enabled/disabled + * - boolean showing whether hardware accelerator is enabled/disabled **/ void DirectFBVid_CtxSetDisableAcceleration(DirectFBVidCtx *ctx, Bool val) { @@ -379,7 +379,7 @@ void DirectFBVid_CtxSetDisableAcceleration(DirectFBVidCtx *ctx, Bool val) /** * function DirectFBVid_CtxGetDisableAcceleration - * - return disable_acceleration value + * - return disable_acceleration value **/ Bool DirectFBVid_CtxGetDisableAcceleration(DirectFBVidCtx *ctx) { @@ -389,7 +389,7 @@ Bool DirectFBVid_CtxGetDisableAcceleration(DirectFBVidCtx *ctx) /** * function DirectFBVid_CtxSetIsInit - * - boolean showing whether DirectFB is initialized + * - boolean showing whether DirectFB is initialized **/ void DirectFBVid_CtxSetIsInit(DirectFBVidCtx *ctx, Bool val) { @@ -399,24 +399,24 @@ void DirectFBVid_CtxSetIsInit(DirectFBVidCtx *ctx, Bool val) /** * function DirectFBVid_CtxSetFlipMode - * - set flip mode + * - set flip mode **/ void DirectFBVid_CtxSetFlipMode(DirectFBVidCtx *ctx, u32 flip_mode) { ctx->flip_mode = DSFLIP_BLIT; switch(flip_mode) { - case FLIP_WAITFORSYNC: - ctx->flip_mode |= DSFLIP_WAITFORSYNC; - break; - case FLIP_WAIT: - ctx->flip_mode |= DSFLIP_WAIT; - break; - case FLIP_ONSYNC: - ctx->flip_mode |= DSFLIP_ONSYNC; - break; - case FLIP_SWAP: - ctx->flip_mode &= ~DSFLIP_BLIT; - break; + case FLIP_WAITFORSYNC: + ctx->flip_mode |= DSFLIP_WAITFORSYNC; + break; + case FLIP_WAIT: + ctx->flip_mode |= DSFLIP_WAIT; + break; + case FLIP_ONSYNC: + ctx->flip_mode |= DSFLIP_ONSYNC; + break; + case FLIP_SWAP: + ctx->flip_mode &= ~DSFLIP_BLIT; + break; } } @@ -439,7 +439,7 @@ void DirectFBVid_CtxPrimaryProcessGetAccelerationMask(DirectFBVidCtx *ctx) /** * function DirectFBVid_ShutdownWrapper - * - shutdown DirectFB module + * - shutdown DirectFB module **/ u32 DirectFBVid_ShutdownWrapper(DirectFBVidCtx *ctx) { @@ -458,7 +458,7 @@ u32 DirectFBVid_ShutdownWrapper(DirectFBVidCtx *ctx) /** - * Blit a surface + * Blit a surface **/ u32 DirectFBVid_TranslatePixelFormatFromGPAC(u32 gpacpf); u32 DirectFBVid_BlitWrapper(DirectFBVidCtx *ctx, u32 video_src_width, u32 video_src_height, u32 video_src_pixel_format, char *video_src_buffer, s32 video_src_pitch_y, u32 src_wnd_x, u32 src_wnd_y, u32 src_wnd_w, u32 src_wnd_h, u32 dst_wnd_x, u32 dst_wnd_y, u32 dst_wnd_w, u32 dst_wnd_h, u32 overlay_type) @@ -482,12 +482,12 @@ u32 DirectFBVid_BlitWrapper(DirectFBVidCtx *ctx, u32 video_src_width, u32 video_ switch (video_src_pixel_format) { - case GF_PIXEL_ARGB: //return DSPF_ARGB; - case GF_PIXEL_RGBA: //return DSPF_ARGB; - ctx->primary->SetBlittingFlags(ctx->primary, DSBLIT_BLEND_ALPHACHANNEL); - break; - default: - ctx->primary->SetBlittingFlags(ctx->primary, DSBLIT_NOFX); + case GF_PIXEL_ARGB: //return DSPF_ARGB; + case GF_PIXEL_RGBA: //return DSPF_ARGB; + ctx->primary->SetBlittingFlags(ctx->primary, DSBLIT_BLEND_ALPHACHANNEL); + break; + default: + ctx->primary->SetBlittingFlags(ctx->primary, DSBLIT_NOFX); } // create a surface with the new surface description @@ -505,8 +505,8 @@ u32 DirectFBVid_BlitWrapper(DirectFBVidCtx *ctx, u32 video_src_width, u32 video_ // blit on the surface if (!src_wnd_x && !src_wnd_y && (dst_wnd_w==src_wnd_w) && (dst_wnd_h==src_wnd_h)) { - ctx->primary->Blit(ctx->primary, src, &dfbsrc, dst_wnd_x, dst_wnd_y); - // blit an area scaled from the source to the destination rectangle + ctx->primary->Blit(ctx->primary, src, &dfbsrc, dst_wnd_x, dst_wnd_y); + // blit an area scaled from the source to the destination rectangle } else { dfbdst.x = dst_wnd_x; dfbdst.y = dst_wnd_y; @@ -516,13 +516,13 @@ u32 DirectFBVid_BlitWrapper(DirectFBVidCtx *ctx, u32 video_src_width, u32 video_ } src->Release(src); - + return 0; } /** - * function DirectFBVid_ProcessMessageQueueWrapper + * function DirectFBVid_ProcessMessageQueueWrapper * - handle DirectFB events * - key events **/ @@ -534,36 +534,36 @@ u32 DirectFBVid_ProcessMessageQueueWrapper(DirectFBVidCtx *ctx, u8 *type, u32 *f if (ctx->events->GetEvent( ctx->events, DFB_EVENT(&directfb_evt) ) == DFB_OK) { switch (directfb_evt.type) { - case DIET_KEYPRESS: - case DIET_KEYRELEASE: - directfb_translate_key(directfb_evt.key_id, flags, key_code); - *type = (directfb_evt.type == DIET_KEYPRESS) ? GF_EVENT_KEYDOWN : GF_EVENT_KEYUP; + case DIET_KEYPRESS: + case DIET_KEYRELEASE: + directfb_translate_key(directfb_evt.key_id, flags, key_code); + *type = (directfb_evt.type == DIET_KEYPRESS) ? GF_EVENT_KEYDOWN : GF_EVENT_KEYUP; + break; + case DIET_BUTTONPRESS: + case DIET_BUTTONRELEASE: + *type = (directfb_evt.type == DIET_BUTTONPRESS) ? GF_EVENT_MOUSEUP : GF_EVENT_MOUSEDOWN; + switch(directfb_evt.button) { + case DIBI_LEFT: + *button = GF_MOUSE_LEFT; break; - case DIET_BUTTONPRESS: - case DIET_BUTTONRELEASE: - *type = (directfb_evt.type == DIET_BUTTONPRESS) ? GF_EVENT_MOUSEUP : GF_EVENT_MOUSEDOWN; - switch(directfb_evt.button) { - case DIBI_LEFT: - *button = GF_MOUSE_LEFT; - break; - case DIBI_RIGHT: - *button = GF_MOUSE_RIGHT; - break; - case DIBI_MIDDLE: - *button = GF_MOUSE_MIDDLE; - break; - default: - //fprintf(stderr, "in here for others\n"); - break; - } + case DIBI_RIGHT: + *button = GF_MOUSE_RIGHT; + break; + case DIBI_MIDDLE: + *button = GF_MOUSE_MIDDLE; break; - case DIET_AXISMOTION: - *type = GF_EVENT_MOUSEMOVE; - ctx->mouse->GetXY(ctx->mouse, x, y); default: + //fprintf(stderr, "in here for others\n"); break; + } + break; + case DIET_AXISMOTION: + *type = GF_EVENT_MOUSEMOVE; + ctx->mouse->GetXY(ctx->mouse, x, y); + default: + break; } - + return 0; } @@ -574,38 +574,53 @@ u32 DirectFBVid_ProcessMessageQueueWrapper(DirectFBVidCtx *ctx, u8 *type, u32 *f /* Events translation */ /** * function DirectFBVid_TranslatePixelFormatToGPAC - * - translate pixel from DirectFb to GPAC + * - translate pixel from DirectFb to GPAC **/ u32 DirectFBVid_TranslatePixelFormatToGPAC(u32 dfbpf) { switch (dfbpf) { - case DSPF_RGB16: return GF_PIXEL_RGB_565; - case DSPF_RGB555: return GF_PIXEL_RGB_555; - case DSPF_RGB24: return GF_PIXEL_RGB_24; - case DSPF_RGB32: return GF_PIXEL_RGB_32; - case DSPF_ARGB: return GF_PIXEL_ARGB; - default: return 0; + case DSPF_RGB16: + return GF_PIXEL_RGB_565; + case DSPF_RGB555: + return GF_PIXEL_RGB_555; + case DSPF_RGB24: + return GF_PIXEL_RGB_24; + case DSPF_RGB32: + return GF_PIXEL_RGB_32; + case DSPF_ARGB: + return GF_PIXEL_ARGB; + default: + return 0; } } /** * function DirectFBVid_TranslatePixelFormatToGPAC - * - translate pixel from GPAC to DirectFB + * - translate pixel from GPAC to DirectFB **/ u32 DirectFBVid_TranslatePixelFormatFromGPAC(u32 gpacpf) { switch (gpacpf) { - case GF_PIXEL_RGB_565: return DSPF_RGB16; - case GF_PIXEL_RGB_555 : return DSPF_RGB555; - case GF_PIXEL_BGR_24 : return DSPF_RGB24; - case GF_PIXEL_RGB_24 : return DSPF_RGB24; - case GF_PIXEL_RGB_32 : return DSPF_RGB32; - case GF_PIXEL_ARGB: return DSPF_ARGB; - case GF_PIXEL_RGBA: return DSPF_ARGB; - case GF_PIXEL_YUY2 : return DSPF_YUY2; - case GF_PIXEL_YV12 : return DSPF_YV12; - default: - ;//GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectFB] pixel format %s not supported\n", gf_4cc_to_str(gpacpf))); + case GF_PIXEL_RGB_565: + return DSPF_RGB16; + case GF_PIXEL_RGB_555 : + return DSPF_RGB555; + case GF_PIXEL_BGR_24 : + return DSPF_RGB24; + case GF_PIXEL_RGB_24 : + return DSPF_RGB24; + case GF_PIXEL_RGB_32 : + return DSPF_RGB32; + case GF_PIXEL_ARGB: + return DSPF_ARGB; + case GF_PIXEL_RGBA: + return DSPF_ARGB; + case GF_PIXEL_YUY2 : + return DSPF_YUY2; + case GF_PIXEL_YV12 : + return DSPF_YV12; + default: + ;//GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectFB] pixel format %s not supported\n", gf_4cc_to_str(gpacpf))); } return 0; @@ -614,218 +629,302 @@ u32 DirectFBVid_TranslatePixelFormatFromGPAC(u32 gpacpf) /** * function directfb_translate_key - * - translate key from DirectFB to GPAC + * - translate key from DirectFB to GPAC **/ void directfb_translate_key(DFBInputDeviceKeyIdentifier DirectFBkey, u32 *flags, u32 *key_code) { //~ fprintf(stderr, "DirectFBkey=%d\n", DirectFBkey); switch (DirectFBkey) { - case DIKI_BACKSPACE: - *key_code = GF_KEY_BACKSPACE; - //~ fprintf(stderr, "DIKI_BACKSPACE\n"); - break; - case DIKI_TAB: - *key_code = GF_KEY_TAB; - //~ fprintf(stderr, "DIKI_TAB\n"); - break; - case DIKI_ENTER: - *key_code = GF_KEY_ENTER; - //~ fprintf(stderr, "DIKI_ENTER\n"); - break; - case DIKI_ESCAPE: - *key_code = GF_KEY_ESCAPE; - //~ fprintf(stderr, "DIKI_ESCAPE\n"); - break; - case DIKI_SPACE: - *key_code = GF_KEY_SPACE; - //~ fprintf(stderr, "DIKI_SPACE\n"); - break; - case DIKI_SHIFT_L: - case DIKI_SHIFT_R: - *key_code = GF_KEY_SHIFT; - //~ fprintf(stderr, "DIKI_SHIFT_R/DIKI_SHIFT_L\n"); - break; - case DIKI_CONTROL_L: - case DIKI_CONTROL_R: - *key_code = GF_KEY_CONTROL; - //~ fprintf(stderr, "DIKI_CONTROL_L/DIKI_CONTROL_R\n"); - break; - case DIKI_ALT_L: - case DIKI_ALT_R: - *key_code = GF_KEY_ALT; - //~ fprintf(stderr, "DIKI_ALT_L/DIKI_ALT_R\n"); - break; - case DIKI_CAPS_LOCK: - *key_code = GF_KEY_CAPSLOCK; - //~ fprintf(stderr, "DIKI_CAPS_LOCK\n"); - break; - case DIKI_META_L: - case DIKI_META_R: - *key_code = GF_KEY_META; break; - case DIKI_KP_EQUAL: - *key_code = GF_KEY_EQUALS; break; - case DIKI_SUPER_L: - case DIKI_SUPER_R: - *key_code = GF_KEY_WIN; break; - - /* alphabets */ - case DIKI_A: - *key_code = GF_KEY_A; - //~ fprintf(stderr, "DIKI_A\n"); - break; - case DIKI_B: - *key_code = GF_KEY_B; - //~ fprintf(stderr, "DIKI_B\n"); - break; - case DIKI_C: - *key_code = GF_KEY_C; - //~ fprintf(stderr, "DIKI_C\n"); - break; - case DIKI_D: - *key_code = GF_KEY_D; - //~ fprintf(stderr, "DIKI_D\n"); - break; - case DIKI_E: - *key_code = GF_KEY_E; - //~ fprintf(stderr, "DIKI_E\n"); - break; - case DIKI_F: - *key_code = GF_KEY_F; break; - case DIKI_G: - *key_code = GF_KEY_G; break; - case DIKI_H: - *key_code = GF_KEY_H; break; - case DIKI_I: - *key_code = GF_KEY_I; break; - case DIKI_J: - *key_code = GF_KEY_J; break; - case DIKI_K: - *key_code = GF_KEY_K; break; - case DIKI_L: - *key_code = GF_KEY_L; break; - case DIKI_M: - *key_code = GF_KEY_M; break; - case DIKI_N: - *key_code = GF_KEY_N; break; - case DIKI_O: - *key_code = GF_KEY_O; break; - case DIKI_P: - *key_code = GF_KEY_P; break; - case DIKI_Q: - *key_code = GF_KEY_Q; break; - case DIKI_R: - *key_code = GF_KEY_R; break; - case DIKI_S: - *key_code = GF_KEY_S; break; - case DIKI_T: - *key_code = GF_KEY_T; break; - case DIKI_U: - *key_code = GF_KEY_U; break; - case DIKI_V: - *key_code = GF_KEY_V; break; - case DIKI_W: - *key_code = GF_KEY_W; break; - case DIKI_X: - *key_code = GF_KEY_X; break; - case DIKI_Y: - *key_code = GF_KEY_Y; break; - case DIKI_Z: - *key_code = GF_KEY_Z; break; - - case DIKI_PRINT: - *key_code = GF_KEY_PRINTSCREEN; break; - case DIKI_SCROLL_LOCK: - *key_code = GF_KEY_SCROLL; break; - case DIKI_PAUSE: - *key_code = GF_KEY_PAUSE; break; - case DIKI_INSERT: - *key_code = GF_KEY_INSERT; break; - case DIKI_DELETE: - *key_code = GF_KEY_DEL; break; - case DIKI_HOME: - *key_code = GF_KEY_HOME; break; - case DIKI_END: - *key_code = GF_KEY_END; break; - case DIKI_PAGE_UP: - *key_code = GF_KEY_PAGEUP; break; - case DIKI_PAGE_DOWN: - *key_code = GF_KEY_PAGEDOWN; break; - - /* arrows */ - case DIKI_UP: - *key_code = GF_KEY_UP; break; - case DIKI_DOWN: - *key_code = GF_KEY_DOWN; break; - case DIKI_RIGHT: - *key_code = GF_KEY_RIGHT; break; - case DIKI_LEFT: - *key_code = GF_KEY_LEFT; break; - - /* extended numerical pad */ - case DIKI_NUM_LOCK: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_NUMLOCK; break; - case DIKI_KP_DIV: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_SLASH; break; - case DIKI_KP_MULT: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_STAR; break; - case DIKI_KP_MINUS: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_HYPHEN; break; - case DIKI_KP_PLUS: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_PLUS; break; - case DIKI_KP_ENTER: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_ENTER; break; - case DIKI_KP_DECIMAL: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_FULLSTOP; break; - case DIKI_KP_0: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_0; break; - case DIKI_KP_1: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_1; break; - case DIKI_KP_2: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_2; break; - case DIKI_KP_3: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_3; break; - case DIKI_KP_4: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_4; break; - case DIKI_KP_5: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_5; break; - case DIKI_KP_6: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_6; break; - case DIKI_KP_7: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_7; break; - case DIKI_KP_8: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_8; break; - case DIKI_KP_9: - *flags = GF_KEY_EXT_NUMPAD; *key_code = GF_KEY_9; break; - - /* Fn functions */ - case DIKI_F1: - *key_code = GF_KEY_F1; break; - case DIKI_F2: - *key_code = GF_KEY_F2; break; - case DIKI_F3: - *key_code = GF_KEY_F3; break; - case DIKI_F4: - *key_code = GF_KEY_F4; break; - case DIKI_F5: - *key_code = GF_KEY_F5; break; - case DIKI_F6: - *key_code = GF_KEY_F6; break; - case DIKI_F7: - *key_code = GF_KEY_F7; break; - case DIKI_F8: - *key_code = GF_KEY_F8; break; - case DIKI_F9: - *key_code = GF_KEY_F9; break; - case DIKI_F10: - *key_code = GF_KEY_F10; break; - case DIKI_F11: - *key_code = GF_KEY_F11; break; - case DIKI_F12: - *key_code = GF_KEY_F12; break; - - default: - *key_code = GF_KEY_UNIDENTIFIED; break; + case DIKI_BACKSPACE: + *key_code = GF_KEY_BACKSPACE; + //~ fprintf(stderr, "DIKI_BACKSPACE\n"); + break; + case DIKI_TAB: + *key_code = GF_KEY_TAB; + //~ fprintf(stderr, "DIKI_TAB\n"); + break; + case DIKI_ENTER: + *key_code = GF_KEY_ENTER; + //~ fprintf(stderr, "DIKI_ENTER\n"); + break; + case DIKI_ESCAPE: + *key_code = GF_KEY_ESCAPE; + //~ fprintf(stderr, "DIKI_ESCAPE\n"); + break; + case DIKI_SPACE: + *key_code = GF_KEY_SPACE; + //~ fprintf(stderr, "DIKI_SPACE\n"); + break; + case DIKI_SHIFT_L: + case DIKI_SHIFT_R: + *key_code = GF_KEY_SHIFT; + //~ fprintf(stderr, "DIKI_SHIFT_R/DIKI_SHIFT_L\n"); + break; + case DIKI_CONTROL_L: + case DIKI_CONTROL_R: + *key_code = GF_KEY_CONTROL; + //~ fprintf(stderr, "DIKI_CONTROL_L/DIKI_CONTROL_R\n"); + break; + case DIKI_ALT_L: + case DIKI_ALT_R: + *key_code = GF_KEY_ALT; + //~ fprintf(stderr, "DIKI_ALT_L/DIKI_ALT_R\n"); + break; + case DIKI_CAPS_LOCK: + *key_code = GF_KEY_CAPSLOCK; + //~ fprintf(stderr, "DIKI_CAPS_LOCK\n"); + break; + case DIKI_META_L: + case DIKI_META_R: + *key_code = GF_KEY_META; + break; + case DIKI_KP_EQUAL: + *key_code = GF_KEY_EQUALS; + break; + case DIKI_SUPER_L: + case DIKI_SUPER_R: + *key_code = GF_KEY_WIN; + break; + + /* alphabets */ + case DIKI_A: + *key_code = GF_KEY_A; + //~ fprintf(stderr, "DIKI_A\n"); + break; + case DIKI_B: + *key_code = GF_KEY_B; + //~ fprintf(stderr, "DIKI_B\n"); + break; + case DIKI_C: + *key_code = GF_KEY_C; + //~ fprintf(stderr, "DIKI_C\n"); + break; + case DIKI_D: + *key_code = GF_KEY_D; + //~ fprintf(stderr, "DIKI_D\n"); + break; + case DIKI_E: + *key_code = GF_KEY_E; + //~ fprintf(stderr, "DIKI_E\n"); + break; + case DIKI_F: + *key_code = GF_KEY_F; + break; + case DIKI_G: + *key_code = GF_KEY_G; + break; + case DIKI_H: + *key_code = GF_KEY_H; + break; + case DIKI_I: + *key_code = GF_KEY_I; + break; + case DIKI_J: + *key_code = GF_KEY_J; + break; + case DIKI_K: + *key_code = GF_KEY_K; + break; + case DIKI_L: + *key_code = GF_KEY_L; + break; + case DIKI_M: + *key_code = GF_KEY_M; + break; + case DIKI_N: + *key_code = GF_KEY_N; + break; + case DIKI_O: + *key_code = GF_KEY_O; + break; + case DIKI_P: + *key_code = GF_KEY_P; + break; + case DIKI_Q: + *key_code = GF_KEY_Q; + break; + case DIKI_R: + *key_code = GF_KEY_R; + break; + case DIKI_S: + *key_code = GF_KEY_S; + break; + case DIKI_T: + *key_code = GF_KEY_T; + break; + case DIKI_U: + *key_code = GF_KEY_U; + break; + case DIKI_V: + *key_code = GF_KEY_V; + break; + case DIKI_W: + *key_code = GF_KEY_W; + break; + case DIKI_X: + *key_code = GF_KEY_X; + break; + case DIKI_Y: + *key_code = GF_KEY_Y; + break; + case DIKI_Z: + *key_code = GF_KEY_Z; + break; + + case DIKI_PRINT: + *key_code = GF_KEY_PRINTSCREEN; + break; + case DIKI_SCROLL_LOCK: + *key_code = GF_KEY_SCROLL; + break; + case DIKI_PAUSE: + *key_code = GF_KEY_PAUSE; + break; + case DIKI_INSERT: + *key_code = GF_KEY_INSERT; + break; + case DIKI_DELETE: + *key_code = GF_KEY_DEL; + break; + case DIKI_HOME: + *key_code = GF_KEY_HOME; + break; + case DIKI_END: + *key_code = GF_KEY_END; + break; + case DIKI_PAGE_UP: + *key_code = GF_KEY_PAGEUP; + break; + case DIKI_PAGE_DOWN: + *key_code = GF_KEY_PAGEDOWN; + break; + + /* arrows */ + case DIKI_UP: + *key_code = GF_KEY_UP; + break; + case DIKI_DOWN: + *key_code = GF_KEY_DOWN; + break; + case DIKI_RIGHT: + *key_code = GF_KEY_RIGHT; + break; + case DIKI_LEFT: + *key_code = GF_KEY_LEFT; + break; + + /* extended numerical pad */ + case DIKI_NUM_LOCK: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_NUMLOCK; + break; + case DIKI_KP_DIV: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_SLASH; + break; + case DIKI_KP_MULT: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_STAR; + break; + case DIKI_KP_MINUS: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_HYPHEN; + break; + case DIKI_KP_PLUS: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_PLUS; + break; + case DIKI_KP_ENTER: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_ENTER; + break; + case DIKI_KP_DECIMAL: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_FULLSTOP; + break; + case DIKI_KP_0: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_0; + break; + case DIKI_KP_1: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_1; + break; + case DIKI_KP_2: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_2; + break; + case DIKI_KP_3: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_3; + break; + case DIKI_KP_4: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_4; + break; + case DIKI_KP_5: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_5; + break; + case DIKI_KP_6: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_6; + break; + case DIKI_KP_7: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_7; + break; + case DIKI_KP_8: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_8; + break; + case DIKI_KP_9: + *flags = GF_KEY_EXT_NUMPAD; + *key_code = GF_KEY_9; + break; + + /* Fn functions */ + case DIKI_F1: + *key_code = GF_KEY_F1; + break; + case DIKI_F2: + *key_code = GF_KEY_F2; + break; + case DIKI_F3: + *key_code = GF_KEY_F3; + break; + case DIKI_F4: + *key_code = GF_KEY_F4; + break; + case DIKI_F5: + *key_code = GF_KEY_F5; + break; + case DIKI_F6: + *key_code = GF_KEY_F6; + break; + case DIKI_F7: + *key_code = GF_KEY_F7; + break; + case DIKI_F8: + *key_code = GF_KEY_F8; + break; + case DIKI_F9: + *key_code = GF_KEY_F9; + break; + case DIKI_F10: + *key_code = GF_KEY_F10; + break; + case DIKI_F11: + *key_code = GF_KEY_F11; + break; + case DIKI_F12: + *key_code = GF_KEY_F12; + break; + + default: + *key_code = GF_KEY_UNIDENTIFIED; + break; } } diff --git a/modules/droid_audio/droidaudio.c b/modules/droid_audio/droidaudio.c index 869ad98..15331cd 100644 --- a/modules/droid_audio/droidaudio.c +++ b/modules/droid_audio/droidaudio.c @@ -44,6 +44,15 @@ /*for channel codes*/ #include +#ifdef GPAC_STATIC_MODULES + +JavaVM* GetJavaVM(); +JNIEnv* GetEnv(); + +#endif + + + static const char android_device[] = "Android Default"; static jclass cAudioTrack = NULL; @@ -91,8 +100,8 @@ typedef struct u32 channelConfig; //AudioFormat.CHANNEL_OUT_MONO u32 audioFormat; //AudioFormat.ENCODING_PCM_16BIT s32 mbufferSizeInBytes; - u32 volume; - u32 pan; + u32 volume; + u32 pan; jarray buff; } DroidContext; @@ -112,13 +121,13 @@ static GF_Err WAV_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, u3 if (ctx->cfg_num_buffers <= 1) ctx->cfg_num_buffers = 2; ctx->cfg_duration = total_duration; if (!ctx->force_config) ctx->num_buffers = 1; - ctx->volume = 100; - ctx->pan = 50; + ctx->volume = 100; + ctx->pan = 50; - if (!cAudioTrack){ + if (!cAudioTrack) { cAudioTrack = (*env)->FindClass(env, "android/media/AudioTrack"); if (!cAudioTrack) { - return GF_NOT_SUPPORTED; + return GF_NOT_SUPPORTED; } cAudioTrack = (*env)->NewGlobalRef(env, cAudioTrack); @@ -161,7 +170,7 @@ static void WAV_Shutdown(GF_AudioOutput *dr) (*env)->DeleteGlobalRef(env, cAudioTrack); //if ( res == JNI_EDETACHED ) { - (*GetJavaVM())->DetachCurrentThread(GetJavaVM()); + (*GetJavaVM())->DetachCurrentThread(GetJavaVM()); //} LOGV("[Android Audio] Shutdown DONE.", 0); @@ -194,7 +203,7 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh ctx->num_buffers = 1; ctx->mbufferSizeInBytes = (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - ctx->sampleRateInHz, ctx->channelConfig, ctx->audioFormat); + ctx->sampleRateInHz, ctx->channelConfig, ctx->audioFormat); //ctx->mbufferSizeInBytes *= 3; @@ -214,11 +223,11 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh ctx->delay = ctx->total_length_ms; mtrack = (*env)->NewObject(env, cAudioTrack, mAudioTrack, STREAM_MUSIC, ctx->sampleRateInHz, - ctx->channelConfig, ctx->audioFormat, ctx->mbufferSizeInBytes, MODE_STREAM); //AudioTrack.MODE_STREAM - if (mtrack){ - mtrack = (*env)->NewGlobalRef(env, mtrack); - ctx->mtrack = mtrack; - (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mPlay); + ctx->channelConfig, ctx->audioFormat, ctx->mbufferSizeInBytes, MODE_STREAM); //AudioTrack.MODE_STREAM + if (mtrack) { + mtrack = (*env)->NewGlobalRef(env, mtrack); + ctx->mtrack = mtrack; + (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mPlay); // (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mStop); } else { LOGV("[Android Audio] mtrack = %p", mtrack); @@ -229,7 +238,7 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh ctx->buff = (*env)->NewByteArray(env, ctx->mbufferSizeInBytes); else ctx->buff = (*env)->NewShortArray(env, ctx->mbufferSizeInBytes/2); - if ( ctx->buff ){ + if ( ctx->buff ) { ctx->buff = (*env)->NewGlobalRef(env, ctx->buff); } else { LOGV("[Android Audio] ctx->buff = %p", ctx->buff ); @@ -244,15 +253,15 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh static void WAV_WriteAudio(GF_AudioOutput *dr) { DroidContext *ctx = (DroidContext *)dr->opaque; - if (!ctx) - return; + if (!ctx) + return; JNIEnv* env = ctx->env; u32 written; void* pBuffer; - if (!env) - return; + if (!env) + return; #ifdef DROID_EXTREME_LOGS - LOGV("[Android Audio] WAV_WriteAudio() : entering",ctx->sampleRateInHz); + LOGV("[Android Audio] WAV_WriteAudio() : entering",ctx->sampleRateInHz); #endif /* DROID_EXTREME_LOGS */ pBuffer = (*env)->GetPrimitiveArrayCritical(env, ctx->buff, NULL); if (pBuffer) @@ -286,45 +295,45 @@ static void WAV_Play(GF_AudioOutput *dr, u32 PlayType) switch ( PlayType ) { - case 0: - // Stop playing - (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mStop); - // Clear the internal buffers - (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mFlush); - break; - case 2: - (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mFlush); - case 1: - (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mPlay); - break; - default: - LOGW("[Android Audio] Unknown Play method=%d.\n", PlayType); + case 0: + // Stop playing + (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mStop); + // Clear the internal buffers + (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mFlush); + break; + case 2: + (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mFlush); + case 1: + (*env)->CallNonvirtualVoidMethod(env, mtrack, cAudioTrack, mPlay); + break; + default: + LOGW("[Android Audio] Unknown Play method=%d.\n", PlayType); } LOGV("[Android Audio] Play DONE (%d).\n", PlayType); } -static void WAV_UpdateVolume(DroidContext *ctx){ - float lV, rV; - JNIEnv* env = GetEnv(); - if (!ctx) - return; - if (ctx->pan > 100) - ctx->pan = 100; - lV =rV = ctx->volume / 100.0; - if (ctx->pan > 50){ - float m = (100 - ctx->pan) / 50.0; - lV*=m; - } else if (ctx->pan < 50){ - float m = ctx->pan / 50.0; - rV*=m; - } - if (env && setStereoVolume && mtrack && cAudioTrack){ - int success; - if (0!= (success=((*env)->CallNonvirtualIntMethod(env, mtrack, cAudioTrack, setStereoVolume, lV, rV)))) - LOGE3("SetVolume(%f,%f) returned Error code %d", lV, rV, success ); - } else { - LOGD2("SetVolume(%f,%f)", lV, rV ); - } +static void WAV_UpdateVolume(DroidContext *ctx) { + float lV, rV; + JNIEnv* env = GetEnv(); + if (!ctx) + return; + if (ctx->pan > 100) + ctx->pan = 100; + lV =rV = ctx->volume / 100.0; + if (ctx->pan > 50) { + float m = (100 - ctx->pan) / 50.0; + lV*=m; + } else if (ctx->pan < 50) { + float m = ctx->pan / 50.0; + rV*=m; + } + if (env && setStereoVolume && mtrack && cAudioTrack) { + int success; + if (0!= (success=((*env)->CallNonvirtualIntMethod(env, mtrack, cAudioTrack, setStereoVolume, lV, rV)))) + LOGE3("SetVolume(%f,%f) returned Error code %d", lV, rV, success ); + } else { + LOGD2("SetVolume(%f,%f)", lV, rV ); + } } static void WAV_SetVolume(GF_AudioOutput *dr, u32 Volume) { @@ -354,53 +363,53 @@ static GF_Err WAV_QueryOutputSampleRate(GF_AudioOutput *dr, u32 *desired_sampler audioFormat = (*nbBitsPerSample == 8)? ENCODING_PCM_8BIT : ENCODING_PCM_16BIT; LOGV3("[Android Audio] Query: SampleRate ChannelConfig AudioFormat: %d %d %d \n", - sampleRateInHz, - (channelConfig == CHANNEL_CONFIGURATION_MONO)? 1 : 2, - (ctx->audioFormat == ENCODING_PCM_8BIT)? 8 : 16); + sampleRateInHz, + (channelConfig == CHANNEL_CONFIGURATION_MONO)? 1 : 2, + (ctx->audioFormat == ENCODING_PCM_8BIT)? 8 : 16); switch (*desired_samplerate) { case 11025: *desired_samplerate = 11025; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; case 22050: *desired_samplerate = 22050; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; break; case 8000: *desired_samplerate = 8000; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; case 16000: *desired_samplerate = 16000; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; case 32000: *desired_samplerate = 32000; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; break; case 24000: *desired_samplerate = 24000; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; case 48000: *desired_samplerate = 48000; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; break; case 44100: *desired_samplerate = 44100; if ( (*env)->CallStaticIntMethod(env, cAudioTrack, mGetMinBufferSize, - *desired_samplerate, channelConfig, audioFormat) > 0 ) + *desired_samplerate, channelConfig, audioFormat) > 0 ) return GF_OK; break; default: diff --git a/modules/droid_audio/javaenv.c b/modules/droid_audio/javaenv.c index 291f108..ab81805 100644 --- a/modules/droid_audio/javaenv.c +++ b/modules/droid_audio/javaenv.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -30,20 +30,20 @@ static JavaVM* javaVM = 0; //---------------------------------------------------------------------- jint JNI_OnLoad(JavaVM* vm, void* reserved) { - javaVM = vm; - return JNI_VERSION_1_2; + javaVM = vm; + return JNI_VERSION_1_2; } //---------------------------------------------------------------------- JNIEnv* GetEnv() { - JNIEnv* env = 0; - //if (javaVM) javaVM->GetEnv((void**)&env, JNI_VERSION_1_2); + JNIEnv* env = 0; + //if (javaVM) javaVM->GetEnv((void**)&env, JNI_VERSION_1_2); if (javaVM) (*javaVM)->GetEnv(javaVM, (void**)&env, JNI_VERSION_1_2); - return env; + return env; } //---------------------------------------------------------------------- JavaVM* GetJavaVM() { - return javaVM; + return javaVM; } //---------------------------------------------------------------------- diff --git a/modules/droid_audio/javaenv.h b/modules/droid_audio/javaenv.h index dc80f31..4091018 100644 --- a/modules/droid_audio/javaenv.h +++ b/modules/droid_audio/javaenv.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/droid_cam/droid_cam.c b/modules/droid_cam/droid_cam.c index cae0837..a62a658 100644 --- a/modules/droid_cam/droid_cam.c +++ b/modules/droid_cam/droid_cam.c @@ -57,10 +57,14 @@ static jmethodID getImageFormat; static jmethodID getImageHeight; static jmethodID getImageWidth; +#ifndef GPAC_STATIC_MODULES jint JNI_OnLoad(JavaVM* vm, void* reserved) +#else +jint static_JNI_OnLoad(JavaVM* vm, void* reserved) +#endif { JNIEnv* env = 0; - javaVM = vm; + javaVM = vm; if ( (*javaVM)->GetEnv(javaVM, (void**)&env, JNI_VERSION_1_2) != JNI_OK ) return -1; @@ -144,10 +148,12 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) return JNI_VERSION_1_2; } + +#ifndef GPAC_STATIC_MODULES //---------------------------------------------------------------------- JavaVM* GetJavaVM() { - return javaVM; + return javaVM; } JNIEnv* GetEnv() @@ -158,14 +164,19 @@ JNIEnv* GetEnv() return env; } +#else +JavaVM* GetJavaVM(); +JNIEnv* GetEnv(); + +#endif void JNI_OnUnload(JavaVM *vm, void *reserved) { JNIEnv* env = 0; - + if ( (*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_2) != JNI_OK ) return; - + (*env)->DeleteGlobalRef(env, camCtrlClass); } //---------------------------------------------------------------------- @@ -268,12 +279,11 @@ void loadCameraControler(ISOMReader *read) read->isAttached = 1; //(*rc->env)->PushLocalFrame(rc->env, 2); } - else - if ( res == JNI_EVERSION ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] The specified version is not supported\n")); - return; - } + else if ( res == JNI_EVERSION ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] The specified version is not supported\n")); + return; + } read->env = env; read->camCtrlClass = camCtrlClass; @@ -313,7 +323,7 @@ GF_Err CAM_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c loadCameraControler(read); /*reply to user*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); //if (read->no_service_desc) isor_declare_objects(read); return GF_OK; @@ -330,12 +340,12 @@ GF_Err CAM_CloseService(GF_InputService *plug) reply = GF_OK; - (*GetEnv())->DeleteLocalRef( GetEnv(), read->camCtrlObj ); + (*GetEnv())->DeleteLocalRef( GetEnv(), read->camCtrlObj ); read->camCtrlObj = NULL; //unloadCameraControler(read); - gf_term_on_disconnect(read->service, NULL, reply); + gf_service_disconnect_ack(read->service, NULL, reply); return GF_OK; } @@ -367,7 +377,7 @@ static GF_Descriptor *CAM_GetServiceDesc(GF_InputService *plug, u32 expect_type, esd->decoderConfig->streamType = GF_STREAM_VISUAL; esd->ESID = 1; esd->decoderConfig->objectTypeIndication = GPAC_OTI_RAW_MEDIA_STREAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); read->width = getWidth(read); @@ -414,7 +424,7 @@ GF_Err CAM_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const cha camStartCamera(read); - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -431,7 +441,7 @@ GF_Err CAM_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) camStopCamera(read); - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return e; } @@ -474,7 +484,7 @@ int* decodeYUV420SP( char* yuv420sp, int width, int height) b = 262143; rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) - | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); + | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); // rgb[ti+tj] = 0xff000000 | ((r << 6) & 0xff0000) // | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); } @@ -512,8 +522,8 @@ void Java_com_gpac_Osmo4_Preview_processFrameBuf( JNIEnv* env, jobject thiz, jby memset(&hdr, 0, sizeof(hdr)); hdr.compositionTimeStampFlag = 1; hdr.compositionTimeStamp = cts; - gf_term_on_sl_packet(ctx->service, ctx->channel, (void*)data, datasize, &hdr, GF_OK); - + gf_service_send_packet(ctx->service, ctx->channel, (void*)data, datasize, &hdr, GF_OK); + //gf_free(data); (*env)->ReleaseByteArrayElements(env,arr,jdata,JNI_ABORT); @@ -545,7 +555,7 @@ void CallCamMethod(ISOMReader *read, jmethodID methodID) (*env)->CallNonvirtualVoidMethod(env, read->camCtrlObj, read->camCtrlClass, methodID); if (isAttached) - { + { (*GetJavaVM())->DetachCurrentThread(GetJavaVM()); } } @@ -645,28 +655,28 @@ GF_Err CAM_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) case GF_NET_CHAN_GET_PIXEL_AR: return 1<<16;//gf_isom_get_pixel_aspect_ratio(read->mov, ch->track, 1, &com->par.hSpacing, &com->par.vSpacing); case GF_NET_CHAN_GET_DSI: - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cam get DSI\n")); - /*it may happen that there are conflicting config when using ESD URLs...*/ - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - - read->width = getWidth(read); - read->height = getHeight(read); - - gf_bs_write_u32(bs, CAM_PIXEL_FORMAT); // fourcc - gf_bs_write_u16(bs, read->width); // width - gf_bs_write_u16(bs, read->height); // height - gf_bs_write_u32(bs, read->width * read->height * CAM_PIXEL_SIZE); // framesize - gf_bs_write_u32(bs, read->width * CAM_PIXEL_SIZE); // stride - - gf_bs_align(bs); - gf_bs_get_content(bs, &buf, &buf_size); - gf_bs_del(bs); - - com->get_dsi.dsi = buf; - com->get_dsi.dsi_len = buf_size; - return GF_OK; - } + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cam get DSI\n")); + /*it may happen that there are conflicting config when using ESD URLs...*/ + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + + read->width = getWidth(read); + read->height = getHeight(read); + + gf_bs_write_u32(bs, CAM_PIXEL_FORMAT); // fourcc + gf_bs_write_u16(bs, read->width); // width + gf_bs_write_u16(bs, read->height); // height + gf_bs_write_u32(bs, read->width * read->height * CAM_PIXEL_SIZE); // framesize + gf_bs_write_u32(bs, read->width * CAM_PIXEL_SIZE); // stride + + gf_bs_align(bs); + gf_bs_get_content(bs, &buf, &buf_size); + gf_bs_del(bs); + + com->get_dsi.dsi = buf; + com->get_dsi.dsi_len = buf_size; + return GF_OK; + } } return GF_NOT_SUPPORTED; } @@ -688,6 +698,12 @@ GF_InputService *CAM_client_load() GF_SAFEALLOC(reader, ISOMReader); plug->priv = reader; globReader = reader; + + +#ifdef GPAC_STATIC_MODULES + static_JNI_OnLoad(GetJavaVM(), NULL); +#endif + return plug; } @@ -722,7 +738,9 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_NET_CLIENT_INTERFACE: CAM_client_del(ifce); break; + case GF_NET_CLIENT_INTERFACE: + CAM_client_del(ifce); + break; } } diff --git a/modules/droid_mpegv/droid_mpegv.c b/modules/droid_mpegv/droid_mpegv.c index 36d2573..0444a9f 100644 --- a/modules/droid_mpegv/droid_mpegv.c +++ b/modules/droid_mpegv/droid_mpegv.c @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include @@ -57,11 +57,13 @@ static jmethodID cid; static jmethodID startSensor; static jmethodID stopSensor; +#ifndef GPAC_STATIC_MODULES + //---------------------------------------------------------------------- jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv* env = 0; - javaVM = vm; + javaVM = vm; if ( (*javaVM)->GetEnv(javaVM, (void**)&env, JNI_VERSION_1_2) != JNI_OK ) return -1; @@ -114,18 +116,24 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) void JNI_OnUnload(JavaVM *vm, void *reserved) { JNIEnv* env = 0; - + if ( (*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_2) != JNI_OK ) return; - + (*env)->DeleteGlobalRef(env, sensCtrlClass); } + //---------------------------------------------------------------------- JavaVM* GetJavaVM() { return javaVM; } //---------------------------------------------------------------------- +#else +JavaVM* GetJavaVM(); +JNIEnv* GetEnv(); + +#endif typedef struct { @@ -177,18 +185,17 @@ void loadSensorControler(MPEGVSensorContext *rc) rc->isAttached = 1; (*env)->PushLocalFrame(env, 2); } - else - if ( res == JNI_EVERSION ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] The specified version is not supported\n")); - return; - } - + else if ( res == JNI_EVERSION ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] The specified version is not supported\n")); + return; + } + rc->env = env; rc->sensCtrlClass = sensCtrlClass; rc->cid = cid; rc->startSensor = startSensor; - rc->stopSensor = stopSensor; + rc->stopSensor = stopSensor; // Create the sensor object in the thread rc->sensCtrlObj = (*rc->env)->NewObject(rc->env, rc->sensCtrlClass, rc->cid); @@ -202,7 +209,7 @@ void loadSensorControler(MPEGVSensorContext *rc) Bool MPEGVS_RegisterDevice(struct __input_device *dr, const char *urn, GF_BitStream *dsi, void (*AddField)(struct __input_device *_this, u32 fieldType, const char *name)) { MPEGVSCTX; - + //"MPEG-V:siv:OrientationSensorType" if ( strnicmp(urn, "MPEG-V", 6) ) @@ -213,7 +220,7 @@ Bool MPEGVS_RegisterDevice(struct __input_device *dr, const char *urn, GF_BitStr GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[MPEG-V] No sensor type specified\n")); return 0; } - + if ( strnicmp(urn+6, ":siv:", 5) ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[MPEG-V] Not valid sensor type specified\n")); @@ -302,13 +309,13 @@ u32 MPEGVS_OnData(struct __input_device * dr, const char* data) u32 buf_size; float x, y, z, q, a, b; MPEGVSCTX; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - if ( rc->sensorAndroidType == 1 - || rc->sensorAndroidType == 2 - || rc->sensorAndroidType == 3 - || rc->sensorAndroidType == 4 ) + if ( rc->sensorAndroidType == 1 + || rc->sensorAndroidType == 2 + || rc->sensorAndroidType == 3 + || rc->sensorAndroidType == 4 ) { sscanf(data, "%f;%f;%f;", &x, &y, &z); gf_bs_write_int(bs, 1, 1); @@ -316,17 +323,15 @@ u32 MPEGVS_OnData(struct __input_device * dr, const char* data) gf_bs_write_float(bs, y); gf_bs_write_float(bs, z); } - else - if ( rc->sensorAndroidType == 5 - || rc->sensorAndroidType == 6 ) + else if ( rc->sensorAndroidType == 5 + || rc->sensorAndroidType == 6 ) { sscanf(data, "%f;", &x); - + gf_bs_write_int(bs, 1, 1); gf_bs_write_float(bs, x); } - else - if ( rc->sensorAndroidType == 11 ) + else if ( rc->sensorAndroidType == 11 ) { sscanf(data, "%f;%f;%f;", &x, &y, &z); @@ -336,8 +341,7 @@ u32 MPEGVS_OnData(struct __input_device * dr, const char* data) gf_bs_write_float(bs, z); /*gf_bs_write_float(bs, q);*/ } - else - if ( rc->sensorAndroidType == 100 ) + else if ( rc->sensorAndroidType == 100 ) { sscanf(data, "%f;%f;%f;%f;%f;", &x, &y, &z, &a, &b); @@ -388,14 +392,14 @@ u32 ThreadRun(void* param) while (!rc->stop) gf_sleep(10); - + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] Stop: %d\n", gf_th_id())); if (!rc->env) return; if ( rc->sensCtrlObj ) - { + { (*rc->env)->CallNonvirtualVoidMethod(rc->env, rc->sensCtrlObj, rc->sensCtrlClass, rc->stopSensor); (*rc->env)->DeleteLocalRef( rc->env, rc->sensCtrlObj ); @@ -407,7 +411,7 @@ u32 ThreadRun(void* param) void MPEGVS_Start(struct __input_device * dr) { MPEGVSCTX; - + rc->trd = gf_th_new("MPEG-V_IN"); gf_th_run(rc->trd, ThreadRun, dr); } @@ -432,7 +436,7 @@ GF_InputSensorDevice* NewMPEGVSInputSesor() { MPEGVSensorContext* ctx = NULL; GF_InputSensorDevice* driv = NULL; - + driv = (GF_InputSensorDevice *) gf_malloc(sizeof(GF_InputSensorDevice)); memset(driv, 0, sizeof(GF_InputSensorDevice)); GF_REGISTER_MODULE_INTERFACE(driv, GF_INPUT_DEVICE_INTERFACE, "MPEG-V Sensors Input Module", "gpac distribution"); @@ -443,7 +447,7 @@ GF_InputSensorDevice* NewMPEGVSInputSesor() ctx = (MPEGVSensorContext*) gf_malloc (sizeof(MPEGVSensorContext)); memset(ctx, 0, sizeof(MPEGVSensorContext)); - + driv->udta = (void*)ctx; return driv; @@ -458,13 +462,13 @@ void DeleteMPEGVSInputSensor(GF_InputSensorDevice* dev) /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_INPUT_DEVICE_INTERFACE, 0 }; - return si; + return si; } /*interface create*/ diff --git a/modules/droid_out/droid_vout-bitmap.c b/modules/droid_out/droid_vout-bitmap.c index ac7762a..75f8302 100644 --- a/modules/droid_out/droid_vout-bitmap.c +++ b/modules/droid_out/droid_vout-bitmap.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -59,14 +59,14 @@ GF_Err RAW_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 init RAWCTX; void * pixels; int ret; - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout RAW_Setup\n")); - + if (!rc->width) { rc->env = (JNIEnv *)os_handle; rc->bitmap = (jobject *)os_display; - + AndroidBitmap_getInfo(rc->env, *(rc->bitmap), &info); rc->width = info.width; rc->height = info.height; @@ -77,9 +77,9 @@ GF_Err RAW_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 init rc->env = (JNIEnv *)os_handle; rc->bitmap = (jobject *)os_display; } - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout rc dims: %d:%d\n", rc->height, rc->width)); - + return GF_OK; } @@ -103,7 +103,7 @@ static GF_Err RAW_LockBackBuffer(GF_VideoOutput *dr, GF_VideoSurface *vi, Bool d RAWCTX; int ret; void * pixels; - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout RAW_LockBackBuffer: %d\n", do_lock)); if (do_lock) { if (!vi) return GF_BAD_PARAM; @@ -168,9 +168,9 @@ GF_VideoOutput *NewRawVideoOutput() driv->Setup = RAW_Setup; driv->Shutdown = RAW_Shutdown; driv->ProcessEvent = RAW_ProcessEvent; - + driv->hw_caps = GF_VIDEO_HW_OPENGL; - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout init\n")); return (void *)driv; } @@ -184,19 +184,19 @@ void DeleteVideoOutput(void *ifce) rc = (AndroidContext *)driv->opaque; gf_free(rc); gf_free(driv); - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout deinit\n")); } /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, 0 }; - return si; + return si; } /*interface create*/ GPAC_MODULE_EXPORT diff --git a/modules/droid_out/droid_vout.c b/modules/droid_out/droid_vout.c index 8e98158..53e0453 100644 --- a/modules/droid_out/droid_vout.c +++ b/modules/droid_out/droid_vout.c @@ -107,78 +107,78 @@ void initGL(AndroidContext *rc) LOG( ANDROID_LOG_INFO, TAG, "Using GL_ARB_texture_non_power_of_two"); } - /* Enable smooth shading */ - glShadeModel(GL_SMOOTH); + /* Enable smooth shading */ + glShadeModel(GL_SMOOTH); - /* Set the background black */ - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + /* Set the background black */ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - /* Depth buffer setup */ - glClearDepthf(1.0f); + /* Depth buffer setup */ + glClearDepthf(1.0f); - /* Enables Depth Testing */ - glEnable(GL_DEPTH_TEST); + /* Enables Depth Testing */ + glEnable(GL_DEPTH_TEST); - /* The Type Of Depth Test To Do */ - glDepthFunc(GL_LEQUAL); + /* The Type Of Depth Test To Do */ + glDepthFunc(GL_LEQUAL); - /* Really Nice Perspective Calculations */ - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + /* Really Nice Perspective Calculations */ + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - glDisable(GL_CULL_FACE | GL_NORMALIZE | GL_LIGHTING | GL_BLEND | GL_FOG | GL_COLOR_MATERIAL | GL_TEXTURE_2D); + glDisable(GL_CULL_FACE | GL_NORMALIZE | GL_LIGHTING | GL_BLEND | GL_FOG | GL_COLOR_MATERIAL | GL_TEXTURE_2D); } void gluPerspective(GLfloat fovy, GLfloat aspect, - GLfloat zNear, GLfloat zFar) + GLfloat zNear, GLfloat zFar) { - GLfloat xmin, xmax, ymin, ymax; + GLfloat xmin, xmax, ymin, ymax; - ymax = zNear * (GLfloat)tan(fovy * PI / 360); - ymin = -ymax; - xmin = ymin * aspect; - xmax = ymax * aspect; + ymax = zNear * (GLfloat)tan(fovy * PI / 360); + ymin = -ymax; + xmin = ymin * aspect; + xmax = ymax * aspect; - glFrustumx((GLfixed)(xmin * 65536), (GLfixed)(xmax * 65536), - (GLfixed)(ymin * 65536), (GLfixed)(ymax * 65536), - (GLfixed)(zNear * 65536), (GLfixed)(zFar * 65536)); + glFrustumx((GLfixed)(xmin * 65536), (GLfixed)(xmax * 65536), + (GLfixed)(ymin * 65536), (GLfixed)(ymax * 65536), + (GLfixed)(zNear * 65536), (GLfixed)(zFar * 65536)); } void resizeWindow(AndroidContext *rc) { - LOG( ANDROID_LOG_VERBOSE, TAG, "resizeWindow : start"); - /* Height / width ration */ - GLfloat ratio; + LOG( ANDROID_LOG_VERBOSE, TAG, "resizeWindow : start"); + /* Height / width ration */ + GLfloat ratio; - /* Protect against a divide by zero */ - if (rc->height==0) - { - rc->height=1; - } + /* Protect against a divide by zero */ + if (rc->height==0) + { + rc->height=1; + } - ratio=(GLfloat)rc->width/(GLfloat)rc->height; + ratio=(GLfloat)rc->width/(GLfloat)rc->height; - /* Setup our viewport. */ - glViewport(0, 0, (GLsizei)rc->width, (GLsizei)rc->height); + /* Setup our viewport. */ + glViewport(0, 0, (GLsizei)rc->width, (GLsizei)rc->height); - /* change to the projection matrix and set our viewing volume. */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + /* change to the projection matrix and set our viewing volume. */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); - /* Set our perspective */ - glOrthox(0, INT2FIX(rc->width), 0, INT2FIX(rc->height), INT2FIX(-1), INT2FIX(1)); + /* Set our perspective */ + glOrthox(0, INT2FIX(rc->width), 0, INT2FIX(rc->height), INT2FIX(-1), INT2FIX(1)); - /* Make sure we're chaning the model view and not the projection */ - glMatrixMode(GL_MODELVIEW); + /* Make sure we're chaning the model view and not the projection */ + glMatrixMode(GL_MODELVIEW); - /* Reset The View */ - glLoadIdentity(); - LOG( ANDROID_LOG_VERBOSE, TAG, "resizeWindow : end"); + /* Reset The View */ + glLoadIdentity(); + LOG( ANDROID_LOG_VERBOSE, TAG, "resizeWindow : end"); } void drawGLScene(AndroidContext *rc) { #ifdef DROID_EXTREME_LOGS - LOG( ANDROID_LOG_VERBOSE, TAG, "drawGLScene : start"); + LOG( ANDROID_LOG_VERBOSE, TAG, "drawGLScene : start"); #endif /* DROID_EXTREME_LOGS */ GLfloat vertices[4][3]; GLfloat texcoord[4][2]; @@ -199,14 +199,14 @@ void drawGLScene(AndroidContext *rc) glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, rgba); glDisable(GL_CULL_FACE | GL_NORMALIZE | GL_LIGHTING | GL_BLEND | GL_FOG | GL_COLOR_MATERIAL | GL_TEXTURE_2D); - /* Clear The Screen And The Depth Buffer */ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + /* Clear The Screen And The Depth Buffer */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //glEnable(GL_BLEND); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //glEnable(GL_BLEND); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, rc->texID); + glEnable(GL_TEXTURE_2D); + glBindTexture( GL_TEXTURE_2D, rc->texID); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -219,8 +219,8 @@ void drawGLScene(AndroidContext *rc) // memset(rc->texData, 255, 4 * rc->width * rc->height ); #ifndef GLES_FRAMEBUFFER_TEST - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, rc->tex_width, rc->tex_height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, rc->texData ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, rc->tex_width, rc->tex_height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, rc->texData ); #endif if ( rc->draw_texture ) @@ -246,17 +246,29 @@ void drawGLScene(AndroidContext *rc) //glTranslatef(0.0f, 0.0f, -2.3f); /* Top Right Of The Quad */ - vertices[0][0]=rc->tex_width; vertices[0][1]=rc->tex_height; vertices[0][2]=0.0f; - texcoord[0][0]=1.f; texcoord[0][1]=0.f; + vertices[0][0]=rc->tex_width; + vertices[0][1]=rc->tex_height; + vertices[0][2]=0.0f; + texcoord[0][0]=1.f; + texcoord[0][1]=0.f; /* Top Left Of The Quad */ - vertices[1][0]=0.f; vertices[1][1]=rc->tex_height; vertices[1][2]=0.0f; - texcoord[1][0]=0.f; texcoord[1][1]=0.f; + vertices[1][0]=0.f; + vertices[1][1]=rc->tex_height; + vertices[1][2]=0.0f; + texcoord[1][0]=0.f; + texcoord[1][1]=0.f; /* Bottom Left Of The Quad */ - vertices[2][0]=rc->tex_width; vertices[2][1]=0.f; vertices[2][2]=0.0f; - texcoord[2][0]=1.f; texcoord[2][1]=1.f; + vertices[2][0]=rc->tex_width; + vertices[2][1]=0.f; + vertices[2][2]=0.0f; + texcoord[2][0]=1.f; + texcoord[2][1]=1.f; /* Bottom Right Of The Quad */ - vertices[3][0]=0.f; vertices[3][1]=0.f; vertices[3][2]=0.0f; - texcoord[3][0]=0.f; texcoord[3][1]=1.f; + vertices[3][0]=0.f; + vertices[3][1]=0.f; + vertices[3][2]=0.0f; + texcoord[3][0]=0.f; + texcoord[3][1]=1.f; /* Drawing using triangle strips, draw triangles using 4 vertices */ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -266,22 +278,22 @@ void drawGLScene(AndroidContext *rc) glDisableClientState(GL_TEXTURE_COORD_ARRAY); } - glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); - /* Flush all drawings */ - glFinish(); + /* Flush all drawings */ + glFinish(); #ifdef GLES_FRAMEBUFFER_TEST glBindFramebufferOES(GL_FRAMEBUFFER_OES, rc->framebuff); #endif #ifdef DROID_EXTREME_LOGS - LOG( ANDROID_LOG_VERBOSE, TAG, "drawGLScene : end"); + LOG( ANDROID_LOG_VERBOSE, TAG, "drawGLScene : end"); #endif /* DROID_EXTREME_LOGS */ } int releaseTexture(AndroidContext *rc) { - if (!rc) - return 0; + if (!rc) + return 0; LOG( ANDROID_LOG_DEBUG, TAG, "Android Delete Texture"); if ( rc->texID >= 0 ) @@ -300,13 +312,13 @@ int releaseTexture(AndroidContext *rc) int createTexture(AndroidContext *rc) { - if (!rc) - return 0; + if (!rc) + return 0; if ( rc->texID >= 0 ) releaseTexture(rc); LOG( ANDROID_LOG_INFO, TAG, "Android Create Texture Size: WxH: %dx%d", - rc->tex_width, rc->tex_height); + rc->tex_width, rc->tex_height); glGenTextures( 1, &(rc->texID) ); @@ -322,10 +334,10 @@ int createTexture(AndroidContext *rc) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, rc->tex_width, rc->tex_height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL/*rc->texData*/ ); + GL_RGBA, GL_UNSIGNED_BYTE, NULL/*rc->texData*/ ); glBindTexture( GL_TEXTURE_2D, 0); - LOG( ANDROID_LOG_VERBOSE, TAG, "Android Create Texture DONE"); + LOG( ANDROID_LOG_VERBOSE, TAG, "Android Create Texture DONE"); return 0; } @@ -361,7 +373,7 @@ int createFrameBuffer(AndroidContext *rc) LOG( ANDROID_LOG_DEBUG, TAG, "Android Create FrameBuffer")); glGenFramebuffersOES(1, &(rc->framebuff)); - glBindFramebufferOES(GL_FRAMEBUFFER_OES, rc->framebuff); + glBindFramebufferOES(GL_FRAMEBUFFER_OES, rc->framebuff); // glGenRenderbuffersOES(1, &(rc->depthbuff)); // glBindRenderbufferOES(GL_RENDERBUFFER_OES, rc->depthbuff); @@ -377,37 +389,37 @@ int createFrameBuffer(AndroidContext *rc) // GL_RENDERBUFFER_OES, rc->depthbuff); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, - GL_TEXTURE_2D, rc->texID, 0); + GL_TEXTURE_2D, rc->texID, 0); if ( (res=(int)glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)) != GL_FRAMEBUFFER_COMPLETE_OES ) { LOG( ANDROID_LOG_ERROR, TAG, "Android failed to make complete framebuffer object:"); switch (res) { - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES: - LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"); - break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES: - LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"); - break; - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES: - LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES"); - break; - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES: - LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES"); - break; - case GL_FRAMEBUFFER_UNSUPPORTED_OES: - LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_UNSUPPORTED_OES"); - break; - default : - LOG( ANDROID_LOG_ERROR, TAG, "Unknown error: %d", res); - break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES: + LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES: + LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES: + LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES: + LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES"); + break; + case GL_FRAMEBUFFER_UNSUPPORTED_OES: + LOG( ANDROID_LOG_ERROR, TAG, "GL_FRAMEBUFFER_UNSUPPORTED_OES"); + break; + default : + LOG( ANDROID_LOG_ERROR, TAG, "Unknown error: %d", res); + break; } - return 1; - } + return 1; + } - //glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); + //glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); return 0; } @@ -450,7 +462,7 @@ static GF_Err droid_Resize(GF_VideoOutput *dr, u32 w, u32 h) createFrameBuffer(rc); #endif } - LOG( ANDROID_LOG_VERBOSE, TAG, "Android Resize DONE", w, h); + LOG( ANDROID_LOG_VERBOSE, TAG, "Android Resize DONE", w, h); return GF_OK; } @@ -466,7 +478,7 @@ GF_Err droid_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 in if ( rc->out_3d_type == 0 ) #endif initGL(rc); - LOG( ANDROID_LOG_VERBOSE, TAG, "Android Setup DONE"); + LOG( ANDROID_LOG_VERBOSE, TAG, "Android Setup DONE"); return GF_OK; } @@ -480,7 +492,7 @@ static void droid_Shutdown(GF_VideoOutput *dr) #ifdef GLES_FRAMEBUFFER_TEST releaseFrameBuffer(rc); #endif - LOG( ANDROID_LOG_VERBOSE, TAG, "Android Shutdown DONE"); + LOG( ANDROID_LOG_VERBOSE, TAG, "Android Shutdown DONE"); } @@ -496,7 +508,7 @@ static GF_Err droid_Flush(GF_VideoOutput *dr, GF_Window *dest) #endif drawGLScene(rc); #ifdef DROID_EXTREME_LOGS - LOG( ANDROID_LOG_VERBOSE, TAG, "Android Flush DONE"); + LOG( ANDROID_LOG_VERBOSE, TAG, "Android Flush DONE"); #endif /* DROID_EXTREME_LOGS */ return GF_OK; } @@ -550,39 +562,39 @@ static GF_Err droid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) if (evt) { switch (evt->type) { case GF_EVENT_SIZE: - LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SIZE( %d x %d)", - evt->setup.width, evt->setup.height); + LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SIZE( %d x %d)", + evt->setup.width, evt->setup.height); //if (evt->setup.opengl_mode) return GF_OK; return droid_Resize(dr, evt->setup.width, evt->setup.height); case GF_EVENT_VIDEO_SETUP: LOG( ANDROID_LOG_DEBUG, TAG, "Android OpenGL mode: %d", evt->setup.opengl_mode); switch (evt->setup.opengl_mode) { - case 0: - rc->out_3d_type = 0; + case 0: + rc->out_3d_type = 0; // initGL(rc); - droid_Resize(dr, evt->setup.width, evt->setup.height); - return GF_OK; - case 1: - rc->out_3d_type = 1; - droid_Resize(dr, evt->setup.width, evt->setup.height); - return GF_OK; - case 2: - rc->out_3d_type = 2; - droid_Resize(dr, evt->setup.width, evt->setup.height); - return GF_OK; - case GF_EVENT_SET_CURSOR: - LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SET_CURSOR"); - return GF_OK; - case GF_EVENT_SET_CAPTION: - LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SET_CAPTION"); - return GF_OK; - case GF_EVENT_SHOWHIDE: - LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SHOWHIDE"); - return GF_OK; - default: - LOG( ANDROID_LOG_DEBUG, TAG, "Process Unknown Event: %d", evt->type); - return GF_OK; + droid_Resize(dr, evt->setup.width, evt->setup.height); + return GF_OK; + case 1: + rc->out_3d_type = 1; + droid_Resize(dr, evt->setup.width, evt->setup.height); + return GF_OK; + case 2: + rc->out_3d_type = 2; + droid_Resize(dr, evt->setup.width, evt->setup.height); + return GF_OK; + case GF_EVENT_SET_CURSOR: + LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SET_CURSOR"); + return GF_OK; + case GF_EVENT_SET_CAPTION: + LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SET_CAPTION"); + return GF_OK; + case GF_EVENT_SHOWHIDE: + LOG( ANDROID_LOG_VERBOSE, TAG, "GF_EVENT_SHOWHIDE"); + return GF_OK; + default: + LOG( ANDROID_LOG_DEBUG, TAG, "Process Unknown Event: %d", evt->type); + return GF_OK; } break; } @@ -590,11 +602,11 @@ static GF_Err droid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) return GF_OK; } -GF_VideoOutput *NewRawVideoOutput() +GF_VideoOutput *NewAndroidVideoOutput() { AndroidContext *pCtx; GF_VideoOutput *driv = (GF_VideoOutput *) gf_malloc(sizeof(GF_VideoOutput)); - LOG( ANDROID_LOG_INFO, TAG, "Android Video Initialization in progress..."); + LOG( ANDROID_LOG_INFO, TAG, "Android Video Initialization in progress..."); memset(driv, 0, sizeof(GF_VideoOutput)); GF_REGISTER_MODULE_INTERFACE(driv, GF_VIDEO_OUTPUT_INTERFACE, "Android Video Output", "gpac distribution") @@ -621,17 +633,17 @@ GF_VideoOutput *NewRawVideoOutput() return (void *)driv; } -void DeleteVideoOutput(void *ifce) +void DeleteAndroidVideoOutput(void *ifce) { AndroidContext *rc; GF_VideoOutput *driv = (GF_VideoOutput *) ifce; - if (!ifce) - return; + if (!ifce) + return; droid_Shutdown(driv); rc = (AndroidContext *)driv->opaque; - if (rc) - gf_free(rc); - driv->opaque = NULL; + if (rc) + gf_free(rc); + driv->opaque = NULL; gf_free(driv); LOG( ANDROID_LOG_DEBUG, TAG, "Android vout deinit\n"); } @@ -650,7 +662,7 @@ const u32 *QueryInterfaces() GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput(); + if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewAndroidVideoOutput(); return NULL; } /*interface destroy*/ @@ -659,7 +671,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { case GF_VIDEO_OUTPUT_INTERFACE: - DeleteVideoOutput((GF_VideoOutput *)ifce); + DeleteAndroidVideoOutput((GF_VideoOutput *)ifce); break; } } diff --git a/modules/dummy_in/dummy_in.c b/modules/dummy_in/dummy_in.c index 7c9e7f0..ee2e193 100644 --- a/modules/dummy_in/dummy_in.c +++ b/modules/dummy_in/dummy_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -76,38 +76,38 @@ Bool DC_RemoveChannel(DCReader *read, LPNETCHANNEL ch) } static const char * DC_MIME_TYPES[] = { -/* "application/x-xmta", "xmta xmta.gz xmtaz", "MPEG-4 Text (XMT)" */ - "application/x-bt", "bt bt.gz btz", "MPEG-4 Text (BT)", - "application/x-xmt", "xmt xmt.gz xmtz", "MPEG-4 Text (XMT)", - "model/vrml", "wrl wrl.gz", "VRML World", - "x-model/x-vrml", "wrl wrl.gz", "VRML World", - "model/x3d+vrml", "x3dv x3dv.gz x3dvz", "X3D/VRML World", - "model/x3d+xml", "x3d x3d.gz x3dz", "X3D/XML World", - "application/x-shockwave-flash", "swf", "Macromedia Flash Movie", - "image/svg+xml", "svg svg.gz svgz", "SVG Document", - "image/x-svgm", "svgm", "SVGM Document", - "application/x-LASeR+xml", "xsr", "LASeR Document", - "application/widget", "wgt", "W3C Widget Package", - "application/x-mpegu-widget", "mgt", "MPEG-U Widget Package", - NULL + /* "application/x-xmta", "xmta xmta.gz xmtaz", "MPEG-4 Text (XMT)" */ + "application/x-bt", "bt bt.gz btz", "MPEG-4 Text (BT)", + "application/x-xmt", "xmt xmt.gz xmtz", "MPEG-4 Text (XMT)", + "model/vrml", "wrl wrl.gz", "VRML World", + "x-model/x-vrml", "wrl wrl.gz", "VRML World", + "model/x3d+vrml", "x3dv x3dv.gz x3dvz", "X3D/VRML World", + "model/x3d+xml", "x3d x3d.gz x3dz", "X3D/XML World", + "application/x-shockwave-flash", "swf", "Macromedia Flash Movie", + "image/svg+xml", "svg svg.gz svgz", "SVG Document", + "image/x-svgm", "svgm", "SVGM Document", + "application/x-LASeR+xml", "xsr", "LASeR Document", + "application/widget", "wgt", "W3C Widget Package", + "application/x-mpegu-widget", "mgt", "MPEG-U Widget Package", + NULL }; -static u32 DC_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - if (!plug) - return 0; - for (i = 0 ; DC_MIME_TYPES[i] ; i+=3) - gf_term_register_mime_type(plug, DC_MIME_TYPES[i], DC_MIME_TYPES[i+1], DC_MIME_TYPES[i+2]); - return i / 3; +static u32 DC_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + if (!plug) + return 0; + for (i = 0 ; DC_MIME_TYPES[i] ; i+=3) + gf_service_register_mime(plug, DC_MIME_TYPES[i], DC_MIME_TYPES[i+1], DC_MIME_TYPES[i+2]); + return i / 3; } Bool DC_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; - if (!plug || !url) - return 0; - sExt = strrchr(url, '.'); + if (!plug || !url) + return 0; + sExt = strrchr(url, '.'); if (sExt) { Bool ok = 0; char *cgi_par; @@ -117,16 +117,16 @@ Bool DC_CanHandleURL(GF_InputService *plug, const char *url) cgi_par = strchr(sExt, '?'); if (cgi_par) cgi_par[0] = 0; { - u32 i; - for (i = 0 ; DC_MIME_TYPES[i] ; i+=3) - if (0 != (ok = gf_term_check_extension(plug, DC_MIME_TYPES[i], DC_MIME_TYPES[i+1], DC_MIME_TYPES[i+2], sExt))) - break; + u32 i; + for (i = 0 ; DC_MIME_TYPES[i] ; i+=3) + if (0 != (ok = gf_service_check_mime_register(plug, DC_MIME_TYPES[i], DC_MIME_TYPES[i+1], DC_MIME_TYPES[i+2], sExt))) + break; } if (cgi_par) cgi_par[0] = '?'; if (ok) return 1; } /*views:// internal URI*/ - if (!strnicmp(url, "views://", 8)) + if (!strnicmp(url, "views://", 8)) return 1; if (!strncmp(url, "\\\\", 2)) return 0; @@ -154,7 +154,7 @@ void DC_NetIO(void *cbk, GF_NETIO_Parameter *param) DCReader *read = (DCReader *) cbk; /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); e = param->error; @@ -181,7 +181,7 @@ void DC_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (!read->is_service_connected) { if (!gf_dm_sess_get_cache_name(read->dnload)) e = GF_IO_ERR; - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); read->is_service_connected = 1; } } @@ -190,9 +190,9 @@ void DC_DownloadFile(GF_InputService *plug, char *url) { DCReader *read = (DCReader *) plug->priv; - read->dnload = gf_term_download_new(read->service, url, 0, DC_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, DC_NetIO, read); if (!read->dnload) { - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -208,7 +208,7 @@ GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const ch if (!read || !serv || !url) return GF_BAD_PARAM; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; read->url = gf_strdup(url); @@ -233,7 +233,7 @@ GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const ch if (!strnicmp(url, "views://", 8)) { read->is_views_url = 1; - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); read->is_service_connected = 1; return GF_OK; } @@ -242,19 +242,21 @@ GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const ch char *cgi_par = NULL; ext += 1; if (ext) { - tmp = strchr(ext, '#'); if (tmp) tmp[0] = 0; + tmp = strchr(ext, '#'); + if (tmp) tmp[0] = 0; /* Warning the '?' sign should not be present in local files but it is convenient to have it to test web content locally */ - cgi_par = strchr(ext, '?'); if (cgi_par) cgi_par[0] = 0; + cgi_par = strchr(ext, '?'); + if (cgi_par) cgi_par[0] = 0; } if (!stricmp(ext, "bt") || !stricmp(ext, "btz") || !stricmp(ext, "bt.gz") - || !stricmp(ext, "xmta") - || !stricmp(ext, "xmt") || !stricmp(ext, "xmt.gz") || !stricmp(ext, "xmtz") - || !stricmp(ext, "wrl") || !stricmp(ext, "wrl.gz") - || !stricmp(ext, "x3d") || !stricmp(ext, "x3d.gz") || !stricmp(ext, "x3dz") - || !stricmp(ext, "x3dv") || !stricmp(ext, "x3dv.gz") || !stricmp(ext, "x3dvz") - || !stricmp(ext, "swf") - ) + || !stricmp(ext, "xmta") + || !stricmp(ext, "xmt") || !stricmp(ext, "xmt.gz") || !stricmp(ext, "xmtz") + || !stricmp(ext, "wrl") || !stricmp(ext, "wrl.gz") + || !stricmp(ext, "x3d") || !stricmp(ext, "x3d.gz") || !stricmp(ext, "x3dz") + || !stricmp(ext, "x3dv") || !stricmp(ext, "x3dv.gz") || !stricmp(ext, "x3dvz") + || !stricmp(ext, "swf") + ) read->oti = GPAC_OTI_PRIVATE_SCENE_GENERIC; else if (!stricmp(ext, "svg") || !stricmp(ext, "svgz") || !stricmp(ext, "svg.gz")) { @@ -295,12 +297,12 @@ GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const ch test = gf_f64_open(read->url, "rt"); if (!test) { - gf_term_on_connect(serv, NULL, GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } fclose(test); if (!read->is_service_connected) { - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); read->is_service_connected = 1; } return GF_OK; @@ -309,9 +311,9 @@ GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const ch GF_Err DC_CloseService(GF_InputService *plug) { DCReader *read = (DCReader *) plug->priv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -374,10 +376,13 @@ GF_Err DC_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (!dc) return GF_STREAM_NOT_FOUND; switch (com->command_type) { - case GF_NET_CHAN_SET_PULL: return GF_OK; - case GF_NET_CHAN_INTERACTIVE: return GF_OK; + case GF_NET_CHAN_SET_PULL: + return GF_OK; + case GF_NET_CHAN_INTERACTIVE: + return GF_OK; /*since data is file-based, no padding is needed (decoder plugin will handle it itself)*/ - case GF_NET_CHAN_SET_PADDING: return GF_OK; + case GF_NET_CHAN_SET_PADDING: + return GF_OK; case GF_NET_CHAN_BUFFER: com->buffer.max = com->buffer.min = 0; return GF_OK; @@ -391,7 +396,8 @@ GF_Err DC_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) return GF_OK; case GF_NET_CHAN_STOP: return GF_OK; - case GF_NET_CHAN_CONFIG: return GF_OK; + case GF_NET_CHAN_CONFIG: + return GF_OK; case GF_NET_CHAN_GET_DSI: com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; @@ -409,14 +415,14 @@ GF_Err DC_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const char sscanf(url, "ES_ID=%ud", &ESID); if (!ESID) { - gf_term_on_connect(read->service, channel, GF_STREAM_NOT_FOUND); + gf_service_connect_ack(read->service, channel, GF_STREAM_NOT_FOUND); } else { DummyChannel *dc; GF_SAFEALLOC(dc, DummyChannel); dc->ch = channel; dc->ESID = ESID; gf_list_add(read->channels, dc); - gf_term_on_connect(read->service, channel, GF_OK); + gf_service_connect_ack(read->service, channel, GF_OK); } return GF_OK; } @@ -427,7 +433,7 @@ GF_Err DC_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) DCReader *read = (DCReader *) plug->priv; had_ch = DC_RemoveChannel(read, channel); - gf_term_on_disconnect(read->service, channel, had_ch ? GF_OK : GF_STREAM_NOT_FOUND); + gf_service_disconnect_ack(read->service, channel, had_ch ? GF_OK : GF_STREAM_NOT_FOUND); return GF_OK; } diff --git a/modules/dx_hw/copy_pixels.c b/modules/dx_hw/copy_pixels.c index a0ec2d2..328ce63 100644 --- a/modules/dx_hw/copy_pixels.c +++ b/modules/dx_hw/copy_pixels.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,22 +11,22 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "dx_hw.h" -static u32 get_yuv_base(u32 in_pf) +static u32 get_yuv_base(u32 in_pf) { switch (in_pf) { case GF_PIXEL_I420: @@ -85,7 +85,7 @@ static Bool is_planar_yuv(u32 pf) static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_stride, u32 src_pf, - u32 src_width, u32 src_height, const GF_Window *src_wnd, u8 *pU, u8 *pV) + u32 src_width, u32 src_height, const GF_Window *src_wnd, u8 *pU, u8 *pV) { if (!pU) { @@ -120,7 +120,7 @@ static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_s src = pY; dst = vs->video_buffer; - + src2 = (vs->pixel_format != GF_PIXEL_YV12) ? pU : pV; dst2 = vs->video_buffer + vs->pitch_y * vs->height; src3 = (vs->pixel_format != GF_PIXEL_YV12) ? pV : pU; @@ -148,7 +148,7 @@ static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_s v = pV + (i/2) * src_stride/2; dst = vs->video_buffer + i*vs->pitch_y; - for (j=0; jw/2;j++) { + for (j=0; jw/2; j++) { *dst = *u; dst++; u++; @@ -172,7 +172,7 @@ static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_s v = pV + (i/2) * src_stride/2; dst = vs->video_buffer + i*vs->pitch_y; - for (j=0; jw/2;j++) { + for (j=0; jw/2; j++) { *dst = *y; dst++; y++; @@ -196,7 +196,7 @@ static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_s v = pV + (i/2) * src_stride/2; dst = vs->video_buffer + i*vs->pitch_y; - for (j=0; jw/2;j++) { + for (j=0; jw/2; j++) { *dst = *y; dst++; y++; @@ -215,7 +215,7 @@ static void write_yv12_to_yuv(GF_VideoSurface *vs, unsigned char *pY, u32 src_s } static void write_yvyu_to_yuv(GF_VideoSurface *vs, unsigned char *src, u32 src_stride, u32 src_pf, - u32 src_width, u32 src_height, const GF_Window *src_wnd) + u32 src_width, u32 src_height, const GF_Window *src_wnd) { u32 i, j, base_pf; unsigned char *pY, *pU, *pV; @@ -274,7 +274,7 @@ static void write_yvyu_to_yuv(GF_VideoSurface *vs, unsigned char *src, u32 src_ } return; } - + if (get_yuv_base(src_pf) == get_yuv_base(vs->pixel_format)) { u32 i; for (i=0; ih; i++) { @@ -404,7 +404,7 @@ void rgb_to_555(GF_VideoSurface *vs, unsigned char *src, u32 src_stride, u32 src } } break; - } + } } void rgb_to_565(GF_VideoSurface *vs, unsigned char *src, u32 src_stride, u32 src_w, u32 src_h, u32 src_pf, const GF_Window *src_wnd) @@ -589,7 +589,7 @@ void dx_copy_pixels(GF_VideoSurface *dst_s, const GF_VideoSurface *src_s, const return; } } - + gf_stretch_bits(dst_s, (GF_VideoSurface*) src_s, NULL, (GF_Window *)src_wnd, 0xFF, 0, NULL, NULL); } diff --git a/modules/dx_hw/dx_2d.c b/modules/dx_hw/dx_2d.c index 1081508..923b4fa 100644 --- a/modules/dx_hw/dx_2d.c +++ b/modules/dx_hw/dx_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -90,21 +90,21 @@ static GF_Err DD_ClearBackBuffer(GF_VideoOutput *dr, u32 color) { HRESULT hr; RECT rc; - DDBLTFX ddbltfx; + DDBLTFX ddbltfx; DDCONTEXT; // Erase the background - ZeroMemory( &ddbltfx, sizeof(ddbltfx) ); - ddbltfx.dwSize = sizeof(ddbltfx); + ZeroMemory( &ddbltfx, sizeof(ddbltfx) ); + ddbltfx.dwSize = sizeof(ddbltfx); switch (dd->pixelFormat) { case GF_PIXEL_RGB_565: - ddbltfx.dwFillColor = GF_COL_TO_565(color); + ddbltfx.dwFillColor = GF_COL_TO_565(color); break; case GF_PIXEL_RGB_555: - ddbltfx.dwFillColor = GF_COL_TO_555(color); + ddbltfx.dwFillColor = GF_COL_TO_555(color); break; default: - ddbltfx.dwFillColor = color; + ddbltfx.dwFillColor = color; break; } rc.left = rc.top = 0; @@ -120,8 +120,8 @@ GF_Err CreateBackBuffer(GF_VideoOutput *dr, u32 Width, u32 Height, Bool use_syst { Bool force_reinit; HRESULT hr; - const char *opt; - DDSURFDESC ddsd; + const char *opt; + DDSURFDESC ddsd; DDCONTEXT; @@ -147,7 +147,7 @@ GF_Err CreateBackBuffer(GF_VideoOutput *dr, u32 Width, u32 Height, Bool use_syst /*create backbuffer*/ ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; if (dd->systems_memory==2) { @@ -203,9 +203,9 @@ GF_Err InitDirectDraw(GF_VideoOutput *dr, u32 Width, u32 Height) HRESULT hr; DWORD cooplev; LPDIRECTDRAW ddraw; - DDSURFDESC ddsd; + DDSURFDESC ddsd; DDPIXELFORMAT pixelFmt; - LPDIRECTDRAWCLIPPER pcClipper; + LPDIRECTDRAWCLIPPER pcClipper; DDCONTEXT; if (!dd->cur_hwnd || !Width || !Height || !dd->DirectDrawCreate) return GF_BAD_PARAM; DestroyObjects(dd); @@ -240,15 +240,15 @@ GF_Err InitDirectDraw(GF_VideoOutput *dr, u32 Width, u32 Height) if( FAILED(hr) ) return GF_IO_ERR; /*create primary*/ - ZeroMemory( &ddsd, sizeof( ddsd ) ); - ddsd.dwSize = sizeof( ddsd ); - ddsd.dwFlags = DDSD_CAPS; + ZeroMemory( &ddsd, sizeof( ddsd ) ); + ddsd.dwSize = sizeof( ddsd ); + ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - hr = dd->pDD->lpVtbl->CreateSurface(dd->pDD, &ddsd, &dd->pPrimary, NULL); + hr = dd->pDD->lpVtbl->CreateSurface(dd->pDD, &ddsd, &dd->pPrimary, NULL); if( FAILED(hr) ) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DX Out] Failed creating primary surface: error %08x\n", hr)); - return GF_IO_ERR; + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DX Out] Failed creating primary surface: error %08x\n", hr)); + return GF_IO_ERR; } /*get pixel format of video board*/ @@ -264,7 +264,7 @@ GF_Err InitDirectDraw(GF_VideoOutput *dr, u32 Width, u32 Height) dd->pixelFormat = GF_PIXEL_RGB_565; else if ((pixelFmt.dwRBitMask == 0x7c00) && (pixelFmt.dwGBitMask == 0x03e0) && (pixelFmt.dwBBitMask == 0x001f)) dd->pixelFormat = GF_PIXEL_RGB_555; - else + else return GF_NOT_SUPPORTED; dd->video_bpp = 16; break; @@ -288,19 +288,19 @@ GF_Err InitDirectDraw(GF_VideoOutput *dr, u32 Width, u32 Height) } hr = dd->pDD->lpVtbl->CreateClipper(dd->pDD, 0, &pcClipper, NULL); - if( FAILED(hr)) + if( FAILED(hr)) return GF_IO_ERR; hr = pcClipper->lpVtbl->SetHWnd(pcClipper, 0, dd->cur_hwnd); if( FAILED(hr) ) { - pcClipper->lpVtbl->Release(pcClipper); - return GF_IO_ERR; - } - hr = dd->pPrimary->lpVtbl->SetClipper(dd->pPrimary, pcClipper); + pcClipper->lpVtbl->Release(pcClipper); + return GF_IO_ERR; + } + hr = dd->pPrimary->lpVtbl->SetClipper(dd->pPrimary, pcClipper); if( FAILED(hr)) { pcClipper->lpVtbl->Release(pcClipper); - return GF_IO_ERR; - } + return GF_IO_ERR; + } pcClipper->lpVtbl->Release(pcClipper); @@ -311,16 +311,16 @@ GF_Err InitDirectDraw(GF_VideoOutput *dr, u32 Width, u32 Height) static GF_Err DD_LockSurface(DDContext *dd, GF_VideoSurface *vi, LPDDRAWSURFACE surface) { - HRESULT hr; + HRESULT hr; DDSURFDESC desc; - + if (!dd || !vi || !surface) return GF_BAD_PARAM; ZeroMemory(&desc, sizeof(desc)); desc.dwSize = sizeof(DDSURFACEDESC); hr = surface->lpVtbl->Lock(surface, NULL, &desc, DDLOCK_SURFACEMEMORYPTR | /*DDLOCK_WRITEONLY | */ DDLOCK_WAIT, NULL); - if (FAILED(hr)) + if (FAILED(hr)) return GF_IO_ERR; vi->video_buffer = desc.lpSurface; @@ -334,7 +334,7 @@ static GF_Err DD_LockSurface(DDContext *dd, GF_VideoSurface *vi, LPDDRAWSURFACE static GF_Err DD_UnlockSurface(DDContext *dd, LPDDRAWSURFACE surface) { - HRESULT hr; + HRESULT hr; if (!dd || !dd->ddraw_init) return GF_IO_ERR; hr = surface->lpVtbl->Unlock(surface, NULL); return FAILED(hr) ? GF_IO_ERR : GF_OK; @@ -361,9 +361,9 @@ static void *LockOSContext(GF_VideoOutput *dr, Bool do_lock) if (do_lock) { if (!dd->lock_hdc && ! dd->pBack->lpVtbl->IsLost(dd->pBack)) { - if (FAILED(dd->pBack->lpVtbl->GetDC(dd->pBack, &dd->lock_hdc)) ) + if (FAILED(dd->pBack->lpVtbl->GetDC(dd->pBack, &dd->lock_hdc)) ) dd->lock_hdc = NULL; - } + } } else if (dd->lock_hdc) { dd->pBack->lpVtbl->ReleaseDC(dd->pBack, dd->lock_hdc); dd->lock_hdc = NULL; @@ -392,14 +392,18 @@ static GF_Err DD_BlitSurface(DDContext *dd, DDSurface *src, GF_Window *src_wnd, col = GF_COL_ARGB(0xFF, key->r, key->g, key->b); ck.dwColorSpaceHighValue = ck.dwColorSpaceLowValue = col; hr = src->pSurface->lpVtbl->SetColorKey(src->pSurface, DDCKEY_SRCBLT, &ck); - if (FAILED(hr)) + if (FAILED(hr)) return GF_IO_ERR; } if ((dst_w==src_w) && (dst_h==src_h)) { flags = DDBLTFAST_WAIT; if (key) flags |= DDBLTFAST_SRCCOLORKEY; - if (dst_wnd) { left = r_dst.left; top = r_dst.top; } else left = top = 0; + if (dst_wnd) { + left = r_dst.left; + top = r_dst.top; + } + else left = top = 0; hr = dd->pBack->lpVtbl->BltFast(dd->pBack, left, top, src->pSurface, src_wnd ? &r_src : NULL, flags); } else { flags = DDBLT_WAIT; @@ -434,7 +438,7 @@ static DDSurface *DD_GetSurface(GF_VideoOutput *dr, u32 width, u32 height, u32 p while (height%2) height++; if (dr->yuv_pixel_format) { - DDSurface *yuvp = &dd->yuv_pool; + DDSurface *yuvp = &dd->yuv_pool; /*don't recreate a surface if not needed*/ if (yuvp->pSurface && (yuvp->width >= width) && (yuvp->height >= height) ) return yuvp; @@ -537,7 +541,7 @@ static GF_Err DD_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window DDCONTEXT; if (!video_src) { - if (overlay_type && dd->yuv_pool.pSurface) + if (overlay_type && dd->yuv_pool.pSurface) dd->yuv_pool.pSurface->lpVtbl->UpdateOverlay(dd->yuv_pool.pSurface, NULL, dd->pPrimary, NULL, DDOVER_HIDE, NULL); return GF_OK; } @@ -552,7 +556,7 @@ static GF_Err DD_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window //if (video_src->pixel_format==GF_PIXEL_YUVD) return GF_NOT_SUPPORTED; if (video_src->pixel_format==GF_PIXEL_YUVD) video_src->pixel_format=GF_PIXEL_YV12; pool = DD_GetSurface(dr, w, h, video_src->pixel_format, 0); - if (!pool) + if (!pool) return GF_IO_ERR; memset(&temp_surf, 0, sizeof(GF_VideoSurface)); @@ -583,8 +587,8 @@ static GF_Err DD_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window MAKERECT(dst_rc, (&dst)); GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DX] Blit surface to dest %d x %d - overlay type %s\n", dst.w, dst.h, - (overlay_type==0)? "none" : ((overlay_type==1) ? "Top-Level" : "ColorKey") - )); + (overlay_type==0)? "none" : ((overlay_type==1) ? "Top-Level" : "ColorKey") + )); #if 1 if (overlay_type==1) { @@ -685,7 +689,7 @@ void DD_InitYUV(GF_VideoOutput *dr) dr->yuv_pixel_format = GF_4CC(a, b, c, d); dr->hw_caps |= GF_VIDEO_HW_HAS_YUV; opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "HasOverlay"); - if (opt && !strcmp(opt, "yes")) + if (opt && !strcmp(opt, "yes")) dr->hw_caps |= GF_VIDEO_HW_HAS_YUV_OVERLAY; dd->yuv_init = 1; num_yuv = 1; @@ -693,7 +697,7 @@ void DD_InitYUV(GF_VideoOutput *dr) } /*first run on this machine, to some benchmark*/ - if (! dd->yuv_init) { + if (! dd->yuv_init) { char szOpt[100]; dd->yuv_init = 1; @@ -703,14 +707,14 @@ void DD_InitYUV(GF_VideoOutput *dr) if (!numCodes) return; codes = (DWORD *)gf_malloc(numCodes*sizeof(DWORD)); dd->pDD->lpVtbl->GetFourCCCodes(dd->pDD, &numCodes, codes); - + num_yuv = 0; for (i=0; ihw_caps &= ~(GF_VIDEO_HW_HAS_YUV | GF_VIDEO_HW_HAS_YUV_OVERLAY); @@ -741,7 +745,7 @@ void DD_InitYUV(GF_VideoOutput *dr) goto rem_fmt; } now = gf_sys_clock() - now; - if (formats[i]== GF_PIXEL_YV12) + if (formats[i]== GF_PIXEL_YV12) force_yv12=1; if (!checkPacked) { @@ -782,7 +786,7 @@ rem_fmt: } else { min_planar = min_packed; dr->yuv_pixel_format = best_packed; - } + } if (force_yv12) dr->yuv_pixel_format = GF_PIXEL_YV12; @@ -824,10 +828,10 @@ rem_fmt: } sscanf(opt, "%06x", &dr->overlay_color_key); if (dr->overlay_color_key) dr->overlay_color_key |= 0xFF000000; - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[DX Out] YUV->RGB enabled: %s - ColorKey enabled: %s (key %x)\n", - (dr->hw_caps & GF_VIDEO_HW_HAS_YUV) ? "Yes" : "No", - dr->overlay_color_key ? "Yes" : "No", dr->overlay_color_key - )); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[DX Out] YUV->RGB enabled: %s - ColorKey enabled: %s (key %x)\n", + (dr->hw_caps & GF_VIDEO_HW_HAS_YUV) ? "Yes" : "No", + dr->overlay_color_key ? "Yes" : "No", dr->overlay_color_key + )); } GF_Err DD_SetBackBufferSize(GF_VideoOutput *dr, u32 width, u32 height, Bool use_system_memory) diff --git a/modules/dx_hw/dx_audio.c b/modules/dx_hw/dx_audio.c index a6d48c4..0cfa57b 100644 --- a/modules/dx_hw/dx_audio.c +++ b/modules/dx_hw/dx_audio.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -34,7 +34,8 @@ #include #include const static GUID GPAC_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001,0x0000,0x0010, -{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}}; + {0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71} +}; #endif @@ -45,7 +46,7 @@ typedef HRESULT (WINAPI *DIRECTSOUNDCREATEPROC)(LPCGUID pcGuidDevice, LPDIRECTSO */ #define MAX_NUM_BUFFERS 20 -typedef struct +typedef struct { Bool force_config; u32 cfg_num_buffers, cfg_duration; @@ -56,12 +57,12 @@ typedef struct IDirectSoundBuffer *pOutput; u32 buffer_size, num_audio_buffer, total_audio_buffer_ms; - + /*notifs*/ Bool use_notif; - u32 frame_state[MAX_NUM_BUFFERS]; - DSBPOSITIONNOTIFY notif_events[MAX_NUM_BUFFERS]; - HANDLE events[MAX_NUM_BUFFERS]; + u32 frame_state[MAX_NUM_BUFFERS]; + DSBPOSITIONNOTIFY notif_events[MAX_NUM_BUFFERS]; + HANDLE events[MAX_NUM_BUFFERS]; HMODULE hDSoundLib; DIRECTSOUNDCREATEPROC DirectSoundCreate; @@ -75,7 +76,7 @@ void DS_WriteAudio_Notifs(GF_AudioOutput *dr); static GF_Err DS_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, u32 total_duration) { DWORD flags; - HRESULT hr; + HRESULT hr; DSCONTEXT(); ctx->hWnd = (HWND) os_handle; @@ -92,7 +93,7 @@ static GF_Err DS_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, u32 if ( FAILED( hr = ctx->DirectSoundCreate( NULL, &ctx->pDS, NULL ) ) ) return GF_IO_ERR; flags = DSSCL_EXCLUSIVE; if( FAILED( hr = ctx->pDS->lpVtbl->SetCooperativeLevel(ctx->pDS, ctx->hWnd, DSSCL_EXCLUSIVE) ) ) { - SAFE_DS_RELEASE( ctx->pDS ); + SAFE_DS_RELEASE( ctx->pDS ); return GF_IO_ERR; } return GF_OK; @@ -101,13 +102,13 @@ static GF_Err DS_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, u32 void DS_ResetBuffer(DSContext *ctx) { - VOID *pLock = NULL; - DWORD size; + VOID *pLock = NULL; + DWORD size; - if( FAILED(ctx->pOutput->lpVtbl->Lock(ctx->pOutput, 0, ctx->buffer_size*ctx->num_audio_buffer, &pLock, &size, NULL, NULL, 0 ) ) ) - return; + if( FAILED(ctx->pOutput->lpVtbl->Lock(ctx->pOutput, 0, ctx->buffer_size*ctx->num_audio_buffer, &pLock, &size, NULL, NULL, 0 ) ) ) + return; memset(pLock, 0, (size_t) size); - ctx->pOutput->lpVtbl->Unlock(ctx->pOutput, pLock, size, NULL, 0L); + ctx->pOutput->lpVtbl->Unlock(ctx->pOutput, pLock, size, NULL, 0L); } void DS_ReleaseBuffer(GF_AudioOutput *dr) @@ -118,7 +119,7 @@ void DS_ReleaseBuffer(GF_AudioOutput *dr) /*stop playing and notif proc*/ if (ctx->pOutput) ctx->pOutput->lpVtbl->Stop(ctx->pOutput); SAFE_DS_RELEASE(ctx->pOutput); - + /*use notif, shutdown notifier and event watcher*/ if (ctx->use_notif) { for (i=0; inum_audio_buffer; i++) CloseHandle(ctx->events[i]); @@ -130,14 +131,14 @@ static void DS_Shutdown(GF_AudioOutput *dr) { DSCONTEXT(); DS_ReleaseBuffer(dr); - SAFE_DS_RELEASE(ctx->pDS ); + SAFE_DS_RELEASE(ctx->pDS ); } /*we assume what was asked is what we got*/ static GF_Err DS_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbChannels, u32 *nbBitsPerSample, u32 channel_cfg) { - u32 i; - HRESULT hr; + u32 i; + HRESULT hr; const char *sOpt; DSBUFFERDESC dsbBufferDesc; IDirectSoundNotify *pNotify; @@ -207,7 +208,14 @@ retry: ctx->use_notif = 0; dsbBufferDesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS; hr = ctx->pDS->lpVtbl->CreateSoundBuffer(ctx->pDS, &dsbBufferDesc, &ctx->pOutput, NULL ); - if (FAILED(hr)) return GF_IO_ERR; + if (FAILED(hr)) { + if (ctx->format.nChannels>2) { + GF_LOG(GF_LOG_ERROR, GF_LOG_AUDIO, ("[DirectSound] failed to configure output for %d channels (error %08x) - falling back to stereo\n", *NbChannels, hr)); + *NbChannels = 2; + return DS_ConfigureOutput(dr, SampleRate, NbChannels, nbBitsPerSample, 0); + } + return GF_IO_ERR; + } } for (i=0; inum_audio_buffer; i++) ctx->frame_state[i] = 0; @@ -248,46 +256,46 @@ retry: /*reset*/ DS_ResetBuffer(ctx); /*play*/ - ctx->pOutput->lpVtbl->Play(ctx->pOutput, 0, 0, DSBPLAY_LOOPING); + ctx->pOutput->lpVtbl->Play(ctx->pOutput, 0, 0, DSBPLAY_LOOPING); return GF_OK; } static Bool DS_RestoreBuffer(LPDIRECTSOUNDBUFFER pDSBuffer) { DWORD dwStatus; - pDSBuffer->lpVtbl->GetStatus(pDSBuffer, &dwStatus ); - if( dwStatus & DSBSTATUS_BUFFERLOST ) { + pDSBuffer->lpVtbl->GetStatus(pDSBuffer, &dwStatus ); + if( dwStatus & DSBSTATUS_BUFFERLOST ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectSound] buffer lost\n")); pDSBuffer->lpVtbl->Restore(pDSBuffer); - pDSBuffer->lpVtbl->GetStatus(pDSBuffer, &dwStatus); + pDSBuffer->lpVtbl->GetStatus(pDSBuffer, &dwStatus); if( dwStatus & DSBSTATUS_BUFFERLOST ) return 1; - } + } return 0; } -void DS_FillBuffer(GF_AudioOutput *dr, u32 buffer) +void DS_FillBuffer(GF_AudioOutput *dr, u32 buffer) { HRESULT hr; - VOID *pLock; + VOID *pLock; u32 pos; - DWORD size; + DWORD size; DSCONTEXT(); /*restoring*/ - if (DS_RestoreBuffer(ctx->pOutput)) { + if (DS_RestoreBuffer(ctx->pOutput)) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectSound] restoring sound buffer\n")); return; } - + /*lock and fill from current pos*/ pos = buffer * ctx->buffer_size; pLock = NULL; - if( FAILED( hr = ctx->pOutput->lpVtbl->Lock(ctx->pOutput, pos, ctx->buffer_size, - &pLock, &size, NULL, NULL, 0L ) ) ) { + if( FAILED( hr = ctx->pOutput->lpVtbl->Lock(ctx->pOutput, pos, ctx->buffer_size, + &pLock, &size, NULL, NULL, 0L ) ) ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectSound] Error locking sound buffer\n")); - return; + return; } assert(size == ctx->buffer_size); @@ -295,7 +303,7 @@ void DS_FillBuffer(GF_AudioOutput *dr, u32 buffer) dr->FillBuffer(dr->audio_renderer, pLock, size); /*update current pos*/ - if( FAILED( hr = ctx->pOutput->lpVtbl->Unlock(ctx->pOutput, pLock, size, NULL, 0)) ) { + if( FAILED( hr = ctx->pOutput->lpVtbl->Unlock(ctx->pOutput, pLock, size, NULL, 0)) ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DirectSound] Error unlocking sound buffer\n")); } ctx->frame_state[buffer] = 1; @@ -324,7 +332,7 @@ void DS_WriteAudio_Notifs(GF_AudioOutput *dr) void DS_WriteAudio(GF_AudioOutput *dr) { u32 retry; - DWORD in_play, cur_play; + DWORD in_play, cur_play; DSCONTEXT(); /*wait for end of current play buffer*/ @@ -424,7 +432,7 @@ void *NewAudioOutput() if( FAILED( hr = CoInitialize(NULL) ) ) return NULL; - + ctx = gf_malloc(sizeof(DSContext)); memset(ctx, 0, sizeof(DSContext)); ctx->hDSoundLib = LoadLibrary("dsound.dll"); @@ -433,7 +441,8 @@ void *NewAudioOutput() } if (!ctx->DirectSoundCreate) { if (ctx->hDSoundLib) FreeLibrary(ctx->hDSoundLib); - gf_free(ctx);return NULL; + gf_free(ctx); + return NULL; } @@ -464,7 +473,7 @@ void DeleteAudioOutput(void *ifce) GF_AudioOutput *dr = (GF_AudioOutput *)ifce; DSCONTEXT(); - if (ctx->hDSoundLib) + if (ctx->hDSoundLib) FreeLibrary(ctx->hDSoundLib); gf_free(ctx); gf_free(ifce); diff --git a/modules/dx_hw/dx_hw.h b/modules/dx_hw/dx_hw.h index 53a6260..5486846 100644 --- a/modules/dx_hw/dx_hw.h +++ b/modules/dx_hw/dx_hw.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -90,7 +90,7 @@ typedef HRESULT(WINAPI * DIRECTDRAWCREATEPROC) (GUID *, LPDIRECTDRAW *, IUnknown typedef struct { - LPDDRAWSURFACE pSurface; + LPDDRAWSURFACE pSurface; u32 width, height, format, pitch; Bool is_yuv; } DDSurface; @@ -113,13 +113,13 @@ typedef struct Bool switch_res; #ifdef USE_DX_3 - LPDIRECTDRAW pDD; - LPDIRECTDRAWSURFACE pPrimary; - LPDIRECTDRAWSURFACE pBack; + LPDIRECTDRAW pDD; + LPDIRECTDRAWSURFACE pPrimary; + LPDIRECTDRAWSURFACE pBack; #else - LPDIRECTDRAW7 pDD; - LPDIRECTDRAWSURFACE7 pPrimary; - LPDIRECTDRAWSURFACE7 pBack; + LPDIRECTDRAW7 pDD; + LPDIRECTDRAWSURFACE7 pPrimary; + LPDIRECTDRAWSURFACE7 pBack; #endif Bool ddraw_init; Bool yuv_init; @@ -161,10 +161,10 @@ typedef struct #ifdef GPAC_USE_OGL_ES NativeDisplayType gl_HDC; - EGLDisplay egldpy; - EGLSurface surface; - EGLConfig eglconfig; - EGLContext eglctx; + EGLDisplay egldpy; + EGLSurface surface; + EGLConfig eglconfig; + EGLContext eglctx; #else HDC gl_HDC, pb_HDC; HGLRC gl_HRC, pb_HRC; @@ -190,7 +190,7 @@ typedef struct Bool force_video_mem_for_yuv; HMODULE hDDrawLib; - DIRECTDRAWCREATEPROC DirectDrawCreate; + DIRECTDRAWCREATEPROC DirectDrawCreate; } DDContext; void DD_SetupWindow(GF_VideoOutput *dr, Bool hide); diff --git a/modules/dx_hw/dx_video.c b/modules/dx_hw/dx_video.c index 8636088..5c07ae1 100644 --- a/modules/dx_hw/dx_video.c +++ b/modules/dx_hw/dx_video.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -111,7 +111,7 @@ static void dd_init_gl_offscreen(GF_VideoOutput *driv) driv->hw_caps |= GF_VIDEO_HW_OPENGL_OFFSCREEN | GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA; if (!opt) gf_modules_set_option((GF_BaseInterface *)driv, "Video", "GLOffscreenMode", "PBuffer"); - } else + } else #endif { u32 gl_type = 1; @@ -144,7 +144,7 @@ static void dd_init_gl_offscreen(GF_VideoOutput *driv) #endif -static void RestoreWindow(DDContext *dd) +static void RestoreWindow(DDContext *dd) { if (!dd->NeedRestore) return; dd->NeedRestore = 0; @@ -154,10 +154,10 @@ static void RestoreWindow(DDContext *dd) #ifndef _WIN32_WCE ChangeDisplaySettings(NULL,0); #endif - } else + } else #endif - dd->pDD->lpVtbl->SetCooperativeLevel(dd->pDD, dd->cur_hwnd, DDSCL_NORMAL); + dd->pDD->lpVtbl->SetCooperativeLevel(dd->pDD, dd->cur_hwnd, DDSCL_NORMAL); dd->NeedRestore = 0; // SetForegroundWindow(dd->cur_hwnd); @@ -200,7 +200,7 @@ void DestroyObjectsEx(DDContext *dd, Bool only_3d) dd->gl_HDC = 0L; dd->egldpy = NULL; } -#elif !defined(_WIN32_WCE) +#elif !defined(_WIN32_WCE) if (dd->pb_HRC) { wglMakeCurrent(dd->pb_HDC, NULL); @@ -216,7 +216,7 @@ void DestroyObjectsEx(DDContext *dd, Bool only_3d) wglDestroyPbufferARB(dd->pbuffer); dd->pbuffer = NULL; } - + if (dd->gl_HRC) { //wglMakeCurrent(NULL, NULL); wglDeleteContext(dd->gl_HRC); @@ -239,7 +239,7 @@ void DestroyObjects(DDContext *dd) #ifndef GPAC_DISABLE_3D -GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_height) +GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_height) { const char *sOpt; GF_Event evt; @@ -257,15 +257,21 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsPerComponent"); nb_bits = sOpt ? atoi(sOpt) : 5; - egl_atts[i++] = EGL_RED_SIZE; egl_atts[i++] = nb_bits; - egl_atts[i++] = EGL_GREEN_SIZE; egl_atts[i++] = nb_bits; - egl_atts[i++] = EGL_BLUE_SIZE; egl_atts[i++] = nb_bits; + egl_atts[i++] = EGL_RED_SIZE; + egl_atts[i++] = nb_bits; + egl_atts[i++] = EGL_GREEN_SIZE; + egl_atts[i++] = nb_bits; + egl_atts[i++] = EGL_BLUE_SIZE; + egl_atts[i++] = nb_bits; /*alpha for compositeTexture*/ - egl_atts[i++] = EGL_ALPHA_SIZE; egl_atts[i++] = 1; + egl_atts[i++] = EGL_ALPHA_SIZE; + egl_atts[i++] = 1; sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsDepth"); nb_bits = sOpt ? atoi(sOpt) : 5; - egl_atts[i++] = EGL_DEPTH_SIZE; egl_atts[i++] = nb_bits; - egl_atts[i++] = EGL_STENCIL_SIZE; egl_atts[i++] = EGL_DONT_CARE; + egl_atts[i++] = EGL_DEPTH_SIZE; + egl_atts[i++] = nb_bits; + egl_atts[i++] = EGL_STENCIL_SIZE; + egl_atts[i++] = EGL_DONT_CARE; egl_atts[i++] = EGL_NONE; /*already setup*/ @@ -276,14 +282,14 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei if (!eglChooseConfig(dd->egldpy, egl_atts, configs, 1, &n)) return GF_IO_ERR; dd->eglconfig = configs[0]; dd->surface = eglCreateWindowSurface(dd->egldpy, dd->eglconfig, dd->cur_hwnd, 0); - if (!dd->surface) return GF_IO_ERR; + if (!dd->surface) return GF_IO_ERR; dd->eglctx = eglCreateContext(dd->egldpy, dd->eglconfig, NULL, NULL); if (!dd->eglctx) { eglDestroySurface(dd->egldpy, dd->surface); dd->surface = 0L; - return GF_IO_ERR; + return GF_IO_ERR; } - if (!eglMakeCurrent(dd->egldpy, dd->surface, dd->surface, dd->eglctx)) { + if (!eglMakeCurrent(dd->egldpy, dd->surface, dd->surface, dd->eglctx)) { eglDestroyContext(dd->egldpy, dd->eglctx); dd->eglctx = 0L; eglDestroySurface(dd->egldpy, dd->surface); @@ -291,17 +297,17 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei return GF_IO_ERR; } #elif !defined(_WIN32_WCE) - PIXELFORMATDESCRIPTOR pfd; - s32 pixelformat; + PIXELFORMATDESCRIPTOR pfd; + s32 pixelformat; HWND highbpp_hwnd = NULL; HWND target_hwnd = NULL; - int bits_depth = 24; + int bits_depth = 16; u32 i; Bool use_double_buffer; /*already setup*/ target_hwnd = (dd->gl_hwnd && (dd->output_3d_type==2)) ? dd->gl_hwnd : dd->cur_hwnd; - if ((dd->bound_hwnd == target_hwnd) && dd->gl_HRC) + if ((dd->bound_hwnd == target_hwnd) && dd->gl_HRC) goto exit; hw_reset = GF_TRUE; @@ -310,9 +316,9 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei /*cleanup*/ DestroyObjectsEx(dd, (dd->output_3d_type==1) ? 0 : 1); - //first time we init GL: create a dummy window to select pixel format for high bpp - we must do this because + //first time we init GL: create a dummy window to select pixel format for high bpp - we must do this because //- we must get a valid GL context to query the extensions for bpp > 8 (regular choosePixelFormat does not work for them) - //- we must call SetPixelFormat to create the GL context + //- we must call SetPixelFormat to create the GL context //- it is not possible to call several time SetPixelFormat on the same window with different PF properties ... if (!dd->mode_high_bpp) { sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsPerComponent"); @@ -330,11 +336,11 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_SUPPORT_OPENGL; - if ( (pixelformat = ChoosePixelFormat(dd->gl_HDC, &pfd)) == FALSE ) return GF_IO_ERR; - + if ( (pixelformat = ChoosePixelFormat(dd->gl_HDC, &pfd)) == FALSE ) return GF_IO_ERR; + if (SetPixelFormat(dd->gl_HDC, pixelformat, &pfd) == FALSE) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DX GL] Cannot select pixel format: error %d- disabling GL\n", GetLastError() )); - return GF_IO_ERR; + return GF_IO_ERR; } dd->gl_HRC = wglCreateContext(dd->gl_HDC); if (!dd->gl_HRC) return GF_IO_ERR; @@ -349,7 +355,7 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei ReleaseDC(highbpp_hwnd, dd->gl_HDC); DestroyWindow(highbpp_hwnd); - + dd->mode_high_bpp = wglChoosePixelFormatARB ? 1 : 2; } else { dd->mode_high_bpp = 2; @@ -378,23 +384,23 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei int pformats[200]; u32 nbformats=0; Bool found = GF_FALSE; - float fattribs[1] = { 0.0f }; - + float fattribs[1] = { 0.0f }; + int hdcAttributes[] = { WGL_SUPPORT_OPENGL_ARB, TRUE, WGL_DRAW_TO_WINDOW_ARB, (dd->bound_hwnd != dd->fs_hwnd) ? TRUE : FALSE, WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, - WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, + WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, WGL_RED_BITS_ARB, dd->bpp, WGL_GREEN_BITS_ARB, dd->bpp, - WGL_BLUE_BITS_ARB, dd->bpp, - WGL_ALPHA_BITS_ARB, (dd->bpp==10) ? 2 : 0, + WGL_BLUE_BITS_ARB, dd->bpp, + WGL_ALPHA_BITS_ARB, (dd->bpp==10) ? 2 : 0, WGL_DEPTH_BITS_ARB, bits_depth, - WGL_DOUBLE_BUFFER_ARB, use_double_buffer ? TRUE : FALSE, + WGL_DOUBLE_BUFFER_ARB, use_double_buffer ? TRUE : FALSE, 0,0 - }; + }; - wglChoosePixelFormatARB(dd->gl_HDC, hdcAttributes, NULL, 200, pformats, &nbformats); + wglChoosePixelFormatARB(dd->gl_HDC, hdcAttributes, NULL, 200, pformats, &nbformats); for (i=0; igl_HDC, pformats[i], &pfd) != FALSE) { @@ -439,11 +445,11 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei /*we need alpha support for composite textures...*/ pfd.cAlphaBits = 8; - if ( (pixelformat = ChoosePixelFormat(dd->gl_HDC, &pfd)) == FALSE ) return GF_IO_ERR; + if ( (pixelformat = ChoosePixelFormat(dd->gl_HDC, &pfd)) == FALSE ) return GF_IO_ERR; if (SetPixelFormat(dd->gl_HDC, pixelformat, &pfd) == FALSE) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[DX GL] Cannot select pixel format: error %d- disabling GL\n", GetLastError() )); - return GF_IO_ERR; + return GF_IO_ERR; } } @@ -480,14 +486,14 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei WGL_DRAW_TO_PBUFFER_ARB, TRUE, WGL_RED_BITS_ARB, 8, WGL_GREEN_BITS_ARB, 8, - WGL_BLUE_BITS_ARB, 8, + WGL_BLUE_BITS_ARB, 8, WGL_DEPTH_BITS_ARB, bits_depth, 0 - }; - wglChoosePixelFormatARB(dd->gl_HDC, hdcAttributes, NULL, 20, pformats, &nbformats); + }; + wglChoosePixelFormatARB(dd->gl_HDC, hdcAttributes, NULL, 20, pformats, &nbformats); // Create the PBuffer for (i=0; ipbuffer = wglCreatePbufferARB(dd->gl_HDC, pformats[i], offscreen_width, offscreen_height, pbufferAttributes); + dd->pbuffer = wglCreatePbufferARB(dd->gl_HDC, pformats[i], offscreen_width, offscreen_height, pbufferAttributes); if (dd->pbuffer) break; } if (!dd->pbuffer) return GF_IO_ERR; @@ -496,7 +502,7 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei dd->pb_HRC = wglCreateContext(dd->pb_HDC); if (!wglMakeCurrent(dd->pb_HDC, dd->pb_HRC)) return GF_IO_ERR; - + } #endif @@ -504,7 +510,7 @@ GF_Err DD_SetupOpenGL(GF_VideoOutput *dr, u32 offscreen_width, u32 offscreen_hei for our plugin window - avoid this by overriding the WindowProc once OpenGL is setup!!*/ if ((dd->bound_hwnd==dd->os_hwnd) && dd->orig_wnd_proc) #ifdef _WIN64 - SetWindowLongPtr(dd->os_hwnd, GWLP_WNDPROC, (DWORD) DD_WindowProc); + SetWindowLongPtr(dd->os_hwnd, GWLP_WNDPROC, (DWORD) DD_WindowProc); #else SetWindowLong(dd->os_hwnd, GWL_WNDPROC, (DWORD) DD_WindowProc); #endif @@ -514,7 +520,7 @@ exit: memset(&evt, 0, sizeof(GF_Event)); evt.type = GF_EVENT_VIDEO_SETUP; evt.setup.hw_reset = hw_reset; - dr->on_event(dr->evt_cbk_hdl, &evt); + dr->on_event(dr->evt_cbk_hdl, &evt); } return GF_OK; } @@ -529,7 +535,7 @@ GF_Err DD_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 init_ DDCONTEXT const char *opt; dd->os_hwnd = (HWND) os_handle; - + DD_SetupWindow(dr, init_flags); /*fatal error*/ if (!dd->os_hwnd) return GF_IO_ERR; @@ -580,7 +586,7 @@ static GF_Err DD_SetFullScreen(GF_VideoOutput *dr, Bool bOn, u32 *outWidth, u32 dd->fullscreen = bOn; if (!dd->width ||!dd->height) return GF_OK; - + /*whenever changing card display mode relocate fastest YUV format for blit (since it depends on the dest pixel format)*/ dd->yuv_init = 0; @@ -651,8 +657,8 @@ static GF_Err DD_SetFullScreen(GF_VideoOutput *dr, Bool bOn, u32 *outWidth, u32 } if (!e) e = DD_SetupOpenGL(dr, 0, 0); - - } else + + } else #endif { @@ -719,7 +725,7 @@ GF_Err DD_Flush(GF_VideoOutput *dr, GF_Window *dest) dr->LockOSContext(dr, 0); return GF_OK; } - + if (!dd->disable_vsync) hr = dd->pDD->lpVtbl->WaitForVerticalBlank(dd->pDD, DDWAITVB_BLOCKBEGIN, NULL); @@ -747,15 +753,15 @@ GF_Err DD_Flush(GF_VideoOutput *dr, GF_Window *dest) HRESULT WINAPI EnumDisplayModes( LPDDSURFDESC lpDDDesc, LPVOID lpContext) { DDContext *dd = (DDContext *) lpContext; - + //check W and H if (dd->width <= lpDDDesc->dwWidth && dd->height <= lpDDDesc->dwHeight - //check FSW and FSH - && dd->fs_width > lpDDDesc->dwWidth && dd->fs_height > lpDDDesc->dwHeight) { + //check FSW and FSH + && dd->fs_width > lpDDDesc->dwWidth && dd->fs_height > lpDDDesc->dwHeight) { if (lpDDDesc->dwHeight == 200) return DDENUMRET_OK; - + dd->fs_width = lpDDDesc->dwWidth; dd->fs_height = lpDDDesc->dwHeight; @@ -812,8 +818,8 @@ static void *NewDXVideoOutput() pCtx->DirectDrawCreate = (DIRECTDRAWCREATEPROC) GetProcAddress(pCtx->hDDrawLib, "DirectDrawCreate"); } - driv->max_screen_width = GetSystemMetrics(SM_CXSCREEN); - driv->max_screen_height = GetSystemMetrics(SM_CYSCREEN); + driv->max_screen_width = GetSystemMetrics(SM_CXSCREEN); + driv->max_screen_height = GetSystemMetrics(SM_CYSCREEN); driv->max_screen_bpp = 8; driv->hw_caps = GF_VIDEO_HW_OPENGL | GF_VIDEO_HW_OPENGL_OFFSCREEN | GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA | GF_VIDEO_HW_HAS_HWND_HDC; diff --git a/modules/dx_hw/dx_window.c b/modules/dx_hw/dx_window.c index e788034..a2ff70e 100644 --- a/modules/dx_hw/dx_window.c +++ b/modules/dx_hw/dx_window.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -63,88 +63,157 @@ static void w32_translate_key(WPARAM wParam, LPARAM lParam, GF_EventKey *evt) evt->flags = 0; evt->hw_code = (u32) wParam; switch (wParam) { - case VK_BACK: evt->key_code = GF_KEY_BACKSPACE; break; - case VK_TAB: evt->key_code = GF_KEY_TAB; break; - case VK_CLEAR: evt->key_code = GF_KEY_CLEAR; break; - case VK_RETURN: evt->key_code = GF_KEY_ENTER; break; - case VK_SHIFT: evt->key_code = GF_KEY_SHIFT; break; - case VK_CONTROL: evt->key_code = GF_KEY_CONTROL; break; - case VK_MENU: evt->key_code = GF_KEY_ALT; break; - case VK_PAUSE: evt->key_code = GF_KEY_PAUSE; break; - case VK_CAPITAL: evt->key_code = GF_KEY_CAPSLOCK; break; - case VK_KANA: evt->key_code = GF_KEY_KANAMODE; break; - case VK_JUNJA: evt->key_code = GF_KEY_JUNJAMODE; break; - case VK_FINAL: evt->key_code = GF_KEY_FINALMODE; break; - case VK_KANJI: evt->key_code = GF_KEY_KANJIMODE; break; - case VK_ESCAPE: evt->key_code = GF_KEY_ESCAPE; break; - case VK_CONVERT: evt->key_code = GF_KEY_CONVERT; break; - case VK_SPACE: evt->key_code = GF_KEY_SPACE; break; - case VK_PRIOR: evt->key_code = GF_KEY_PAGEUP; break; - case VK_NEXT: evt->key_code = GF_KEY_PAGEDOWN; break; - case VK_END: evt->key_code = GF_KEY_END; break; - case VK_HOME: evt->key_code = GF_KEY_HOME; break; - case VK_LEFT: evt->key_code = GF_KEY_LEFT; break; - case VK_UP: evt->key_code = GF_KEY_UP; break; - case VK_RIGHT: evt->key_code = GF_KEY_RIGHT; break; - case VK_DOWN: evt->key_code = GF_KEY_DOWN; break; - case VK_SELECT: evt->key_code = GF_KEY_SELECT; break; - case VK_PRINT: + case VK_BACK: + evt->key_code = GF_KEY_BACKSPACE; + break; + case VK_TAB: + evt->key_code = GF_KEY_TAB; + break; + case VK_CLEAR: + evt->key_code = GF_KEY_CLEAR; + break; + case VK_RETURN: + evt->key_code = GF_KEY_ENTER; + break; + case VK_SHIFT: + evt->key_code = GF_KEY_SHIFT; + break; + case VK_CONTROL: + evt->key_code = GF_KEY_CONTROL; + break; + case VK_MENU: + evt->key_code = GF_KEY_ALT; + break; + case VK_PAUSE: + evt->key_code = GF_KEY_PAUSE; + break; + case VK_CAPITAL: + evt->key_code = GF_KEY_CAPSLOCK; + break; + case VK_KANA: + evt->key_code = GF_KEY_KANAMODE; + break; + case VK_JUNJA: + evt->key_code = GF_KEY_JUNJAMODE; + break; + case VK_FINAL: + evt->key_code = GF_KEY_FINALMODE; + break; + case VK_KANJI: + evt->key_code = GF_KEY_KANJIMODE; + break; + case VK_ESCAPE: + evt->key_code = GF_KEY_ESCAPE; + break; + case VK_CONVERT: + evt->key_code = GF_KEY_CONVERT; + break; + case VK_SPACE: + evt->key_code = GF_KEY_SPACE; + break; + case VK_PRIOR: + evt->key_code = GF_KEY_PAGEUP; + break; + case VK_NEXT: + evt->key_code = GF_KEY_PAGEDOWN; + break; + case VK_END: + evt->key_code = GF_KEY_END; + break; + case VK_HOME: + evt->key_code = GF_KEY_HOME; + break; + case VK_LEFT: + evt->key_code = GF_KEY_LEFT; + break; + case VK_UP: + evt->key_code = GF_KEY_UP; + break; + case VK_RIGHT: + evt->key_code = GF_KEY_RIGHT; + break; + case VK_DOWN: + evt->key_code = GF_KEY_DOWN; + break; + case VK_SELECT: + evt->key_code = GF_KEY_SELECT; + break; + case VK_PRINT: case VK_SNAPSHOT: - evt->key_code = GF_KEY_PRINTSCREEN; break; - case VK_EXECUTE: evt->key_code = GF_KEY_EXECUTE; break; - case VK_INSERT: evt->key_code = GF_KEY_INSERT; break; - case VK_DELETE: evt->key_code = GF_KEY_DEL; break; - case VK_HELP: evt->key_code = GF_KEY_HELP; break; + evt->key_code = GF_KEY_PRINTSCREEN; + break; + case VK_EXECUTE: + evt->key_code = GF_KEY_EXECUTE; + break; + case VK_INSERT: + evt->key_code = GF_KEY_INSERT; + break; + case VK_DELETE: + evt->key_code = GF_KEY_DEL; + break; + case VK_HELP: + evt->key_code = GF_KEY_HELP; + break; #if !defined(_WIN32_WCE) && !defined(__GNUC__) - case VK_OEM_PLUS: evt->key_code = GF_KEY_PLUS; break; - case VK_OEM_MINUS: evt->key_code = GF_KEY_PLUS; break; -#endif + case VK_OEM_PLUS: + evt->key_code = GF_KEY_PLUS; + break; + case VK_OEM_MINUS: + evt->key_code = GF_KEY_PLUS; + break; +#endif #ifndef _WIN32_WCE - case VK_NONCONVERT: evt->key_code = GF_KEY_NONCONVERT; break; - case VK_ACCEPT: evt->key_code = GF_KEY_ACCEPT; break; - case VK_MODECHANGE: evt->key_code = GF_KEY_MODECHANGE; break; + case VK_NONCONVERT: + evt->key_code = GF_KEY_NONCONVERT; + break; + case VK_ACCEPT: + evt->key_code = GF_KEY_ACCEPT; + break; + case VK_MODECHANGE: + evt->key_code = GF_KEY_MODECHANGE; + break; #endif -/* case '!': evt->key_code = GF_KEY_EXCLAMATION; break; - case '"': evt->key_code = GF_KEY_QUOTATION; break; - case '#': evt->key_code = GF_KEY_NUMBER; break; - case '$': evt->key_code = GF_KEY_DOLLAR; break; - case '&': evt->key_code = GF_KEY_AMPERSAND; break; - case '\'': evt->key_code = GF_KEY_APOSTROPHE; break; - case '(': evt->key_code = GF_KEY_LEFTPARENTHESIS; break; - case ')': evt->key_code = GF_KEY_RIGHTPARENTHESIS; break; - case ',': evt->key_code = GF_KEY_COMMA; break; - case ':': evt->key_code = GF_KEY_COLON; break; - case ';': evt->key_code = GF_KEY_SEMICOLON; break; - case '<': evt->key_code = GF_KEY_LESSTHAN; break; - case '>': evt->key_code = GF_KEY_GREATERTHAN; break; - case '?': evt->key_code = GF_KEY_QUESTION; break; - case '@': evt->key_code = GF_KEY_AT; break; - case '[': evt->key_code = GF_KEY_LEFTSQUAREBRACKET; break; - case ']': evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; break; - case '\\': evt->key_code = GF_KEY_BACKSLASH; break; - case '_': evt->key_code = GF_KEY_UNDERSCORE; break; - case '`': evt->key_code = GF_KEY_GRAVEACCENT; break; - case ' ': evt->key_code = GF_KEY_SPACE; break; - case '/': evt->key_code = GF_KEY_SLASH; break; - case '*': evt->key_code = GF_KEY_STAR; break; - case '-': evt->key_code = GF_KEY_HIPHEN; break; - case '+': evt->key_code = GF_KEY_PLUS; break; - case '=': evt->key_code = GF_KEY_EQUALS; break; - case '^': evt->key_code = GF_KEY_CIRCUM; break; - case '{': evt->key_code = GF_KEY_LEFTCURLYBRACKET; break; - case '}': evt->key_code = GF_KEY_RIGHTCURLYBRACKET; break; - case '|': evt->key_code = GF_KEY_PIPE; break; -*/ - - -/* case VK_LWIN: return ; - case VK_RWIN: return ; - case VK_APPS: return ; -*/ - case VK_NUMPAD0: + /* case '!': evt->key_code = GF_KEY_EXCLAMATION; break; + case '"': evt->key_code = GF_KEY_QUOTATION; break; + case '#': evt->key_code = GF_KEY_NUMBER; break; + case '$': evt->key_code = GF_KEY_DOLLAR; break; + case '&': evt->key_code = GF_KEY_AMPERSAND; break; + case '\'': evt->key_code = GF_KEY_APOSTROPHE; break; + case '(': evt->key_code = GF_KEY_LEFTPARENTHESIS; break; + case ')': evt->key_code = GF_KEY_RIGHTPARENTHESIS; break; + case ',': evt->key_code = GF_KEY_COMMA; break; + case ':': evt->key_code = GF_KEY_COLON; break; + case ';': evt->key_code = GF_KEY_SEMICOLON; break; + case '<': evt->key_code = GF_KEY_LESSTHAN; break; + case '>': evt->key_code = GF_KEY_GREATERTHAN; break; + case '?': evt->key_code = GF_KEY_QUESTION; break; + case '@': evt->key_code = GF_KEY_AT; break; + case '[': evt->key_code = GF_KEY_LEFTSQUAREBRACKET; break; + case ']': evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; break; + case '\\': evt->key_code = GF_KEY_BACKSLASH; break; + case '_': evt->key_code = GF_KEY_UNDERSCORE; break; + case '`': evt->key_code = GF_KEY_GRAVEACCENT; break; + case ' ': evt->key_code = GF_KEY_SPACE; break; + case '/': evt->key_code = GF_KEY_SLASH; break; + case '*': evt->key_code = GF_KEY_STAR; break; + case '-': evt->key_code = GF_KEY_HIPHEN; break; + case '+': evt->key_code = GF_KEY_PLUS; break; + case '=': evt->key_code = GF_KEY_EQUALS; break; + case '^': evt->key_code = GF_KEY_CIRCUM; break; + case '{': evt->key_code = GF_KEY_LEFTCURLYBRACKET; break; + case '}': evt->key_code = GF_KEY_RIGHTCURLYBRACKET; break; + case '|': evt->key_code = GF_KEY_PIPE; break; + */ + + + /* case VK_LWIN: return ; + case VK_RWIN: return ; + case VK_APPS: return ; + */ + case VK_NUMPAD0: evt->key_code = GF_KEY_0; evt->flags = GF_KEY_EXT_NUMPAD; break; @@ -184,11 +253,11 @@ static void w32_translate_key(WPARAM wParam, LPARAM lParam, GF_EventKey *evt) evt->key_code = GF_KEY_9; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_MULTIPLY: + case VK_MULTIPLY: evt->key_code = GF_KEY_STAR; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_ADD: + case VK_ADD: evt->key_code = GF_KEY_PLUS; evt->flags = GF_KEY_EXT_NUMPAD; break; @@ -208,40 +277,92 @@ static void w32_translate_key(WPARAM wParam, LPARAM lParam, GF_EventKey *evt) evt->key_code = GF_KEY_SLASH; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_F1: evt->key_code = GF_KEY_F1; break; - case VK_F2: evt->key_code = GF_KEY_F2; break; - case VK_F3: evt->key_code = GF_KEY_F3; break; - case VK_F4: evt->key_code = GF_KEY_F4; break; - case VK_F5: evt->key_code = GF_KEY_F5; break; - case VK_F6: evt->key_code = GF_KEY_F6; break; - case VK_F7: evt->key_code = GF_KEY_F7; break; - case VK_F8: evt->key_code = GF_KEY_F8; break; - case VK_F9: evt->key_code = GF_KEY_F9; break; - case VK_F10: evt->key_code = GF_KEY_F10; break; - case VK_F11: evt->key_code = GF_KEY_F11; break; - case VK_F12: evt->key_code = GF_KEY_F12; break; - case VK_F13: evt->key_code = GF_KEY_F13; break; - case VK_F14: evt->key_code = GF_KEY_F14; break; - case VK_F15: evt->key_code = GF_KEY_F15; break; - case VK_F16: evt->key_code = GF_KEY_F16; break; - case VK_F17: evt->key_code = GF_KEY_F17; break; - case VK_F18: evt->key_code = GF_KEY_F18; break; - case VK_F19: evt->key_code = GF_KEY_F19; break; - case VK_F20: evt->key_code = GF_KEY_F20; break; - case VK_F21: evt->key_code = GF_KEY_F21; break; - case VK_F22: evt->key_code = GF_KEY_F22; break; - case VK_F23: evt->key_code = GF_KEY_F23; break; - case VK_F24: evt->key_code = GF_KEY_F24; break; - - case VK_NUMLOCK: evt->key_code = GF_KEY_NUMLOCK; break; - case VK_SCROLL: evt->key_code = GF_KEY_SCROLL; break; + case VK_F1: + evt->key_code = GF_KEY_F1; + break; + case VK_F2: + evt->key_code = GF_KEY_F2; + break; + case VK_F3: + evt->key_code = GF_KEY_F3; + break; + case VK_F4: + evt->key_code = GF_KEY_F4; + break; + case VK_F5: + evt->key_code = GF_KEY_F5; + break; + case VK_F6: + evt->key_code = GF_KEY_F6; + break; + case VK_F7: + evt->key_code = GF_KEY_F7; + break; + case VK_F8: + evt->key_code = GF_KEY_F8; + break; + case VK_F9: + evt->key_code = GF_KEY_F9; + break; + case VK_F10: + evt->key_code = GF_KEY_F10; + break; + case VK_F11: + evt->key_code = GF_KEY_F11; + break; + case VK_F12: + evt->key_code = GF_KEY_F12; + break; + case VK_F13: + evt->key_code = GF_KEY_F13; + break; + case VK_F14: + evt->key_code = GF_KEY_F14; + break; + case VK_F15: + evt->key_code = GF_KEY_F15; + break; + case VK_F16: + evt->key_code = GF_KEY_F16; + break; + case VK_F17: + evt->key_code = GF_KEY_F17; + break; + case VK_F18: + evt->key_code = GF_KEY_F18; + break; + case VK_F19: + evt->key_code = GF_KEY_F19; + break; + case VK_F20: + evt->key_code = GF_KEY_F20; + break; + case VK_F21: + evt->key_code = GF_KEY_F21; + break; + case VK_F22: + evt->key_code = GF_KEY_F22; + break; + case VK_F23: + evt->key_code = GF_KEY_F23; + break; + case VK_F24: + evt->key_code = GF_KEY_F24; + break; -/* - * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. - * Used only as parameters to GetAsyncKeyState() and GetKeyState(). - * No other API or message will distinguish left and right keys in this way. - */ - case VK_LSHIFT: + case VK_NUMLOCK: + evt->key_code = GF_KEY_NUMLOCK; + break; + case VK_SCROLL: + evt->key_code = GF_KEY_SCROLL; + break; + + /* + * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. + * Used only as parameters to GetAsyncKeyState() and GetKeyState(). + * No other API or message will distinguish left and right keys in this way. + */ + case VK_LSHIFT: evt->key_code = GF_KEY_SHIFT; evt->flags = GF_KEY_EXT_LEFT; break; @@ -267,22 +388,38 @@ static void w32_translate_key(WPARAM wParam, LPARAM lParam, GF_EventKey *evt) break; #if(WINVER >= 0x0400) - case VK_PROCESSKEY: evt->key_code = GF_KEY_PROCESS; break; + case VK_PROCESSKEY: + evt->key_code = GF_KEY_PROCESS; + break; #endif /* WINVER >= 0x0400 */ - case VK_ATTN: evt->key_code = GF_KEY_ATTN; break; - case VK_CRSEL: evt->key_code = GF_KEY_CRSEL; break; - case VK_EXSEL: evt->key_code = GF_KEY_EXSEL; break; - case VK_EREOF: evt->key_code = GF_KEY_ERASEEOF; break; - case VK_PLAY: evt->key_code = GF_KEY_PLAY; break; - case VK_ZOOM: evt->key_code = GF_KEY_ZOOM; break; + case VK_ATTN: + evt->key_code = GF_KEY_ATTN; + break; + case VK_CRSEL: + evt->key_code = GF_KEY_CRSEL; + break; + case VK_EXSEL: + evt->key_code = GF_KEY_EXSEL; + break; + case VK_EREOF: + evt->key_code = GF_KEY_ERASEEOF; + break; + case VK_PLAY: + evt->key_code = GF_KEY_PLAY; + break; + case VK_ZOOM: + evt->key_code = GF_KEY_ZOOM; + break; //case VK_NONAME: evt->key_code = GF_KEY_NONAME; break; //case VK_PA1: evt->key_code = GF_KEY_PA1; break; - case VK_OEM_CLEAR: evt->key_code = GF_KEY_CLEAR; break; + case VK_OEM_CLEAR: + evt->key_code = GF_KEY_CLEAR; + break; /*thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ - default: + default: if ((wParam>=0x30) && (wParam<=0x39)) evt->key_code = GF_KEY_0 + (u32) (wParam-0x30); else if ((wParam>=0x41) && (wParam<=0x5A)) evt->key_code = GF_KEY_A + (u32) (wParam-0x41); /*DOM 3 Events: Implementations that are unable to identify a key must use the key identifier "Unidentified".*/ @@ -327,7 +464,7 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam GF_Event evt; DDContext *ctx; #ifdef _WIN64 - GF_VideoOutput *vout = (GF_VideoOutput *) GetWindowLongPtr(hWnd, GWLP_USERDATA); + GF_VideoOutput *vout = (GF_VideoOutput *) GetWindowLongPtr(hWnd, GWLP_USERDATA); #else GF_VideoOutput *vout = (GF_VideoOutput *) GetWindowLong(hWnd, GWL_USERDATA); #endif @@ -374,7 +511,7 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam } else if (ctx->orig_wnd_proc) { /*restore window proc*/ #ifdef _WIN64 - SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, ctx->orig_wnd_proc); + SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, ctx->orig_wnd_proc); #else SetWindowLong(ctx->os_hwnd, GWL_WNDPROC, ctx->orig_wnd_proc); #endif @@ -390,12 +527,12 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam break; case WM_ACTIVATE: - if (!ctx->on_secondary_screen && ctx->fullscreen && (LOWORD(wParam)==WA_INACTIVE) - && (hWnd==ctx->fs_hwnd) + if (!ctx->on_secondary_screen && ctx->fullscreen && (LOWORD(wParam)==WA_INACTIVE) + && (hWnd==ctx->fs_hwnd) #ifndef GPAC_DISABLE_3D - && (ctx->output_3d_type!=2) + && (ctx->output_3d_type!=2) #endif - ) { + ) { evt.type = GF_EVENT_SHOWHIDE; vout->on_event(vout->evt_cbk_hdl, &evt); } @@ -430,34 +567,34 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam } /*this avoids 100% cpu usage in Firefox*/ return DefWindowProc (hWnd, msg, wParam, lParam); - + case WM_SETCURSOR: if (ctx->cur_hwnd==hWnd) DD_SetCursor(vout, ctx->cursor_type); break; case WM_DROPFILES: - { - char szFile[GF_MAX_PATH]; - GF_Event evt; - u32 i; - - HDROP hDrop = (HDROP) wParam; - evt.type = GF_EVENT_OPENFILE; - evt.open_file.nb_files = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); - evt.open_file.files = gf_malloc(sizeof(char *)*evt.open_file.nb_files); - for (i=0; ion_event(vout->evt_cbk_hdl, &evt); - for (i=0; ion_event(vout->evt_cbk_hdl, &evt); + for (i=0; icur_hwnd!=hWnd) break; @@ -543,7 +680,7 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ret = vout->on_event(vout->evt_cbk_hdl, &evt); mouse_start_timer(ctx, hWnd, vout); break; - case WM_MOUSEWHEEL: + case WM_MOUSEWHEEL: if (ctx->cur_hwnd==hWnd) { DD_SetCursor(vout, (ctx->cursor_type==GF_CURSOR_HIDE) ? ctx->cursor_type_backup : ctx->cursor_type); evt.type = GF_EVENT_MOUSEWHEEL; @@ -559,12 +696,24 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam evt.type = GF_EVENT_MOUSEWHEEL; evt.mouse.button = 1; switch (LOWORD(wParam)) { - case SB_LEFT: evt.mouse.wheel_pos = -1; break; - case SB_RIGHT: evt.mouse.wheel_pos = +1; break; - case SB_LINELEFT: evt.mouse.wheel_pos = -5; break; - case SB_LINERIGHT: evt.mouse.wheel_pos = +5; break; - case SB_PAGELEFT: evt.mouse.wheel_pos = -10; break; - case SB_PAGERIGHT: evt.mouse.wheel_pos = +10; break; + case SB_LEFT: + evt.mouse.wheel_pos = -1; + break; + case SB_RIGHT: + evt.mouse.wheel_pos = +1; + break; + case SB_LINELEFT: + evt.mouse.wheel_pos = -5; + break; + case SB_LINERIGHT: + evt.mouse.wheel_pos = +5; + break; + case SB_PAGELEFT: + evt.mouse.wheel_pos = -10; + break; + case SB_PAGERIGHT: + evt.mouse.wheel_pos = +10; + break; default: break; } @@ -597,9 +746,9 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam evt.type = GF_EVENT_PASTE_TEXT; evt.message.message = lptstrCopy; ret = vout->on_event(vout->evt_cbk_hdl, &evt); - GlobalUnlock(hglbCopy); + GlobalUnlock(hglbCopy); } - CloseClipboard(); + CloseClipboard(); break; } else if (ctx->ctrl_down && (evt.type==GF_EVENT_KEYUP) && (evt.key.key_code==GF_KEY_C)) { @@ -611,54 +760,54 @@ LRESULT APIENTRY DD_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam if (!IsClipboardFormatAvailable(CF_TEXT)) break; if (!OpenClipboard(ctx->cur_hwnd)) break; EmptyClipboard(); - + len = strlen(evt.message.message); if (!len) break; - hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(char)); + hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(char)); lptstrCopy = (char *) GlobalLock(hglbCopy); - memcpy(lptstrCopy, evt.message.message, len * sizeof(char)); + memcpy(lptstrCopy, evt.message.message, len * sizeof(char)); lptstrCopy[len] = 0; - GlobalUnlock(hglbCopy); + GlobalUnlock(hglbCopy); SetClipboardData(CF_TEXT, hglbCopy); - CloseClipboard(); + CloseClipboard(); break; } } ret = vout->on_event(vout->evt_cbk_hdl, &evt); - + if ( !ctx->ctrl_down && !ctx->alt_down - && evt.key.key_code != GF_KEY_CONTROL && evt.key.key_code != GF_KEY_ALT ) + && evt.key.key_code != GF_KEY_CONTROL && evt.key.key_code != GF_KEY_ALT ) ret = 1; break; case WM_UNICHAR: case WM_CHAR: /*no reason to filter out things*/ -// if (wParam>=32) - { - evt.type = GF_EVENT_TEXTINPUT; - evt.character.unicode_char = (u32) wParam; - ret = vout->on_event(vout->evt_cbk_hdl, &evt); - } - break; -/* - case WM_CANCELMODE: - case WM_CAPTURECHANGED: - case WM_NCHITTEST: - return 0; -*/ +// if (wParam>=32) + { + evt.type = GF_EVENT_TEXTINPUT; + evt.character.unicode_char = (u32) wParam; + ret = vout->on_event(vout->evt_cbk_hdl, &evt); + } + break; + /* + case WM_CANCELMODE: + case WM_CAPTURECHANGED: + case WM_NCHITTEST: + return 0; + */ default: return DefWindowProc (hWnd, msg, wParam, lParam); } - if (!ret &&(ctx->os_hwnd==hWnd) && ctx->orig_wnd_proc) + if (!ret &&(ctx->os_hwnd==hWnd) && ctx->orig_wnd_proc) return CallWindowProc((WNDPROC) ctx->orig_wnd_proc, hWnd, msg, wParam, lParam); return 0; } #ifndef WS_EX_LAYERED -#define WS_EX_LAYERED 0x80000 +#define WS_EX_LAYERED 0x80000 #endif #ifndef LWA_COLORKEY #define LWA_COLORKEY 0x00000001 @@ -683,9 +832,9 @@ static void SetWindowless(GF_VideoOutput *vout, HWND hWnd) u32 isWin2K; OSVERSIONINFO Version = {sizeof(OSVERSIONINFO)}; GetVersionEx(&Version); - isWin2K = (Version.dwPlatformId == VER_PLATFORM_WIN32_NT && Version.dwMajorVersion >= 5); + isWin2K = (Version.dwPlatformId == VER_PLATFORM_WIN32_NT && Version.dwMajorVersion >= 5); if (!isWin2K) return; - + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[DX Out] Enabling windowless mode\n")); hUser32 = GetModuleHandle("USER32.DLL"); if (hUser32 == NULL) return; @@ -810,20 +959,20 @@ Bool DD_InitWindows(GF_VideoOutput *vout, DDContext *ctx) } ShowWindow(ctx->fs_hwnd, SW_HIDE); #ifdef _WIN64 - SetWindowLongPtr(ctx->fs_hwnd, GWLP_USERDATA, (LONG) vout); + SetWindowLongPtr(ctx->fs_hwnd, GWLP_USERDATA, (LONG) vout); #else SetWindowLong(ctx->fs_hwnd, GWL_USERDATA, (LONG) vout); #endif } else { ctx->fs_hwnd = ctx->os_hwnd; } - + /*if visible set focus*/ if (!ctx->switch_res) SetFocus(ctx->os_hwnd); ctx->switch_res = 0; #ifdef _WIN64 - SetWindowLongPtr(ctx->os_hwnd, GWLP_USERDATA, (LONG) vout); + SetWindowLongPtr(ctx->os_hwnd, GWLP_USERDATA, (LONG) vout); #else SetWindowLong(ctx->os_hwnd, GWL_USERDATA, (LONG) vout); #endif @@ -850,7 +999,7 @@ u32 DD_WindowThread(void *par) ctx->th_state = 1; while (msg_ok) { msg_ok = GetMessage (&(msg), NULL, 0, 0); - if (msg_ok == -1) msg_ok = 0; + if (msg_ok == -1) msg_ok = 0; if (msg.message == WM_DESTROY) PostQuitMessage(0); //WM_DESTROY: exit TranslateMessage (&(msg)); DispatchMessage (&(msg)); @@ -869,8 +1018,8 @@ void DD_SetupWindow(GF_VideoOutput *dr, u32 flags) /*override window proc*/ if (!(flags & GF_TERM_NO_WINDOWPROC_OVERRIDE) ) { #ifdef _WIN64 - ctx->orig_wnd_proc = GetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC); - SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, (DWORD) DD_WindowProc); + ctx->orig_wnd_proc = GetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC); + SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, (DWORD) DD_WindowProc); #else ctx->orig_wnd_proc = GetWindowLong(ctx->os_hwnd, GWL_WNDPROC); SetWindowLong(ctx->os_hwnd, GWL_WNDPROC, (DWORD) DD_WindowProc); @@ -906,7 +1055,7 @@ void DD_ShutdownWindow(GF_VideoOutput *dr) } else if (ctx->orig_wnd_proc) { /*restore window proc*/ #ifdef _WIN64 - SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, ctx->orig_wnd_proc); + SetWindowLongPtr(ctx->os_hwnd, GWLP_WNDPROC, ctx->orig_wnd_proc); #else SetWindowLong(ctx->os_hwnd, GWL_WNDPROC, ctx->orig_wnd_proc); #endif @@ -916,8 +1065,8 @@ void DD_ShutdownWindow(GF_VideoOutput *dr) if (ctx->fs_hwnd != ctx->os_hwnd) { dd_closewindow(ctx->fs_hwnd); #ifdef _WIN64 - SetWindowLongPtr(ctx->fs_hwnd, GWLP_USERDATA, (LONG) NULL); - SetWindowLongPtr(ctx->fs_hwnd, GWLP_WNDPROC, (DWORD) DefWindowProc); + SetWindowLongPtr(ctx->fs_hwnd, GWLP_USERDATA, (LONG) NULL); + SetWindowLongPtr(ctx->fs_hwnd, GWLP_WNDPROC, (DWORD) DefWindowProc); #else SetWindowLong(ctx->fs_hwnd, GWL_USERDATA, (LONG) NULL); SetWindowLong(ctx->fs_hwnd, GWL_WNDPROC, (DWORD) DefWindowProc); @@ -929,7 +1078,7 @@ void DD_ShutdownWindow(GF_VideoOutput *dr) #endif if (ctx->th) { - while (ctx->th_state!=2) + while (ctx->th_state!=2) gf_sleep(10); gf_th_del(ctx->th); @@ -939,7 +1088,7 @@ void DD_ShutdownWindow(GF_VideoOutput *dr) /*special care for Firefox: the windows created by our NP plugin may still be called after the shutdown of the plugin !!*/ #ifdef _WIN64 - SetWindowLongPtr(ctx->os_hwnd, GWLP_USERDATA, (LONG) NULL); + SetWindowLongPtr(ctx->os_hwnd, GWLP_USERDATA, (LONG) NULL); #else SetWindowLong(ctx->os_hwnd, GWL_USERDATA, (LONG) NULL); #endif @@ -997,15 +1146,17 @@ static u32 get_sys_col(int idx) { u32 res; DWORD val = GetSysColor(idx); - res = (val)&0xFF; res<<=8; - res |= (val>>8)&0xFF; res<<=8; + res = (val)&0xFF; + res<<=8; + res |= (val>>8)&0xFF; + res<<=8; res |= (val>>16)&0xFF; return res; } /*Note: all calls to SetWindowPos are made in a non-blocking way using SWP_ASYNCWINDOWPOS. This avoids deadlocks -when the compositor request a size change and the DX window thread has grabbed the main compositor mutex. +when the compositor request a size change and the DX window thread has grabbed the main compositor mutex. This typically happens when switching playlist items as fast as possible*/ GF_Err DD_ProcessEvent(GF_VideoOutput*dr, GF_Event *evt) { @@ -1067,7 +1218,7 @@ GF_Err DD_ProcessEvent(GF_VideoOutput*dr, GF_Event *evt) } else { if (ctx->windowless) SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width, evt->size.height, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS); - else + else SetWindowPos(ctx->os_hwnd, NULL, 0, 0, evt->size.width + ctx->off_w, evt->size.height + ctx->off_h, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS); } } @@ -1095,7 +1246,7 @@ GF_Err DD_ProcessEvent(GF_VideoOutput*dr, GF_Event *evt) case 2: ctx->output_3d_type = 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DX Out] Attempting to resize Offscreen OpenGL window to %d x %d\n", evt->size.width, evt->size.height)); - if (ctx->gl_hwnd) + if (ctx->gl_hwnd) SetWindowPos(ctx->gl_hwnd, NULL, 0, 0, evt->size.width, evt->size.height, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS); GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[DX Out] Resizing Offscreen OpenGL window to %d x %d\n", evt->size.width, evt->size.height)); SetForegroundWindow(ctx->cur_hwnd); diff --git a/modules/dx_hw/resource.h b/modules/dx_hw/resource.h index 64f8f8c..0c5b2f3 100644 --- a/modules/dx_hw/resource.h +++ b/modules/dx_hw/resource.h @@ -12,7 +12,7 @@ #define IDC_ZOOM_OUT 151 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 106 diff --git a/modules/epoc_hw/epoc_aout.cpp b/modules/epoc_hw/epoc_aout.cpp index 42adc86..ced5ede 100644 --- a/modules/epoc_hw/epoc_aout.cpp +++ b/modules/epoc_hw/epoc_aout.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -90,21 +90,39 @@ GF_Err EPOCAudio::Open(u32 sample_rate, Bool stereo) u32 count; TMdaAudioDataSettings::TAudioCaps epoc_sr; - + switch (sample_rate) { - case 8000: epoc_sr = TMdaAudioDataSettings::ESampleRate8000Hz; break; - case 11025: epoc_sr = TMdaAudioDataSettings::ESampleRate11025Hz; break; - case 12000: epoc_sr = TMdaAudioDataSettings::ESampleRate12000Hz; break; - case 16000: epoc_sr = TMdaAudioDataSettings::ESampleRate16000Hz; break; - case 22050: epoc_sr = TMdaAudioDataSettings::ESampleRate22050Hz; break; - case 24000: epoc_sr = TMdaAudioDataSettings::ESampleRate24000Hz; break; - case 32000: epoc_sr = TMdaAudioDataSettings::ESampleRate32000Hz; break; - case 44100: epoc_sr = TMdaAudioDataSettings::ESampleRate44100Hz; break; - case 48000: epoc_sr = TMdaAudioDataSettings::ESampleRate48000Hz; break; + case 8000: + epoc_sr = TMdaAudioDataSettings::ESampleRate8000Hz; + break; + case 11025: + epoc_sr = TMdaAudioDataSettings::ESampleRate11025Hz; + break; + case 12000: + epoc_sr = TMdaAudioDataSettings::ESampleRate12000Hz; + break; + case 16000: + epoc_sr = TMdaAudioDataSettings::ESampleRate16000Hz; + break; + case 22050: + epoc_sr = TMdaAudioDataSettings::ESampleRate22050Hz; + break; + case 24000: + epoc_sr = TMdaAudioDataSettings::ESampleRate24000Hz; + break; + case 32000: + epoc_sr = TMdaAudioDataSettings::ESampleRate32000Hz; + break; + case 44100: + epoc_sr = TMdaAudioDataSettings::ESampleRate44100Hz; + break; + case 48000: + epoc_sr = TMdaAudioDataSettings::ESampleRate48000Hz; + break; default: return GF_NOT_SUPPORTED; } - + state = EPOC_AUDIO_INIT; gf_sleep(10); @@ -231,10 +249,10 @@ static GF_Err EAUD_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbC e = ctx->Open(*SampleRate, (*NbChannels ==2) ? 1 : 0); if (e) return e; - + snd_align = *NbChannels * 2; - bps = snd_align * *SampleRate; - + bps = snd_align **SampleRate; + if (ctx->cfg_total_duration) { ctx->num_buffers = ctx->cfg_num_buffers; ctx->buffer_size = (bps*ctx->cfg_total_duration/1000) / ctx->num_buffers; diff --git a/modules/epoc_hw/epoc_codec.cpp b/modules/epoc_hw/epoc_codec.cpp index d2d6bb3..16ee08a 100644 --- a/modules/epoc_hw/epoc_codec.cpp +++ b/modules/epoc_hw/epoc_codec.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -93,7 +93,7 @@ static void EDEC_LoadCaps(GF_BaseDecoder *ifcg) ctx->caps |= GF_EPOC_HAS_HEAAC; delete codec; } - + /*MP3*/ TRAP(err, codec = CMMFCodec::NewL(KMMFFourCCCodeMP3, KMMFFourCCCodePCM16)); if (err==KErrNone) { @@ -115,17 +115,17 @@ static GF_Err EDEC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) if (ctx->dec) return GF_BAD_PARAM; - /*audio decs*/ + /*audio decs*/ switch (esd->decoderConfig->objectTypeIndication) { /*MPEG2 aac*/ case GPAC_OTI_AUDIO_AAC_MPEG2_MP: case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: /*MPEG4 aac*/ - case GPAC_OTI_AUDIO_AAC_MPEG4: + case GPAC_OTI_AUDIO_AAC_MPEG4: if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return GF_NON_COMPLIANT_BITSTREAM; if (gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg) != GF_OK) return GF_NON_COMPLIANT_BITSTREAM; - + aac_sbr_upsample = 0; #if !defined(__SYMBIAN32__) || defined(__SERIES60_3X__) if (a_cfg.has_sbr && (ctx->caps & GF_EPOC_HAS_HEAAC)) { @@ -147,7 +147,7 @@ static GF_Err EDEC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) configParams.Append(16); // 8: Sample resolution, 8Khz (8-bit PCM) or 16Khz (16-bit) configParams.Append(a_cfg.sbr_sr); // 9: Output Sample Frequency configParams.Append(5); // 10: Extension Object Type - + TRAP(err, ctx->dec->ConfigureL(TUid::Uid(KUidMmfCodecAudioSettings), (TDesC8&) configParams)); if (err != KErrNone) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[EPOC Decoder] Failed to configure HE-AAC decoder (error %d) - retrying with AAC\n", err)); @@ -158,7 +158,7 @@ static GF_Err EDEC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) ctx->num_channels = a_cfg.nb_chan; ctx->num_samples = aac_sbr_upsample ? 2048 : 1024; ctx->sample_rate = a_cfg.sbr_sr; - } else + } else #endif { retry_no_sbr: @@ -176,7 +176,7 @@ retry_no_sbr: configParams.Append(0); // Aac decimation factor {0 - none, 2 - decimation by 2, 4 - decimation by 4} configParams.Append(0); // Aac concealment - It can be {0 - none, 1 - basic} configParams.Append(16); // Sample resolution - It can be {16 - 16-bit resolution} - configParams.Append(0); // Sample Rate Conversion 0 : none + configParams.Append(0); // Sample Rate Conversion 0 : none TRAP(err, ctx->dec->ConfigureL(TUid::Uid(KUidMmfCodecAudioSettings), (TDesC8&) configParams)); if (err != KErrNone) { @@ -298,11 +298,11 @@ static GF_Err EDEC_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa } -static GF_Err EDEC_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err EDEC_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { TCodecProcessResult res; EPOCCodec *ctx = (EPOCCodec *)ifcg->privateStack; @@ -339,7 +339,7 @@ static u32 EDEC_CanHandleStream(GF_BaseDecoder *ifcg, u32 StreamType, GF_ESD *es GF_M4ADecSpecInfo a_cfg; EPOCCodec *ctx = (EPOCCodec *)ifcg->privateStack; - /*audio decs*/ + /*audio decs*/ if (StreamType == GF_STREAM_AUDIO) { /*media type query*/ if (!esd) return GF_CODEC_STREAM_TYPE_SUPPORTED; @@ -350,7 +350,7 @@ static u32 EDEC_CanHandleStream(GF_BaseDecoder *ifcg, u32 StreamType, GF_ESD *es case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: /*MPEG4 aac*/ - case GPAC_OTI_AUDIO_AAC_MPEG4: + case GPAC_OTI_AUDIO_AAC_MPEG4: if (!dsi) return GF_CODEC_NOT_SUPPORTED; if (gf_m4a_get_config(dsi, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg) != GF_OK) return GF_CODEC_MAYBE_SUPPORTED; switch (a_cfg.base_object_type) { @@ -401,7 +401,7 @@ GF_BaseDecoder *EPOC_codec_new() GF_SAFEALLOC(ctx, EPOCCodec); ifce->privateStack = ctx; - /*setup our own interface*/ + /*setup our own interface*/ ifce->AttachStream = EDEC_AttachStream; ifce->DetachStream = EDEC_DetachStream; ifce->GetCapabilities = EDEC_GetCapabilities; diff --git a/modules/epoc_hw/epoc_vout.cpp b/modules/epoc_hw/epoc_vout.cpp index cfa3451..f958035 100644 --- a/modules/epoc_hw/epoc_vout.cpp +++ b/modules/epoc_hw/epoc_vout.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ /*driver interface*/ @@ -65,8 +65,8 @@ static void EVID_ResetSurface(GF_VideoOutput *dr, Bool gl_only) eglMakeCurrent(ctx->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (ctx->egl_context) eglDestroyContext(ctx->egl_display, ctx->egl_context); ctx->egl_context = NULL; - if (ctx->egl_surface) eglDestroySurface(ctx->egl_display, ctx->egl_surface); - ctx->egl_surface = NULL; + if (ctx->egl_surface) eglDestroySurface(ctx->egl_display, ctx->egl_surface); + ctx->egl_surface = NULL; eglTerminate(ctx->egl_display); ctx->egl_display = NULL; } @@ -100,12 +100,12 @@ static GF_Err EVID_InitSurface(GF_VideoOutput *dr) GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[EPOC Video] Cannot create screen device for session\n")); return GF_IO_ERR; } - e = ctx->screen->Construct(); + e = ctx->screen->Construct(); if (e != KErrNone) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[EPOC Video] Cannot construct screen device for session - error %d\n", e)); return GF_IO_ERR; } - e = ctx->screen->CreateContext(ctx->gc); + e = ctx->screen->CreateContext(ctx->gc); if (e != KErrNone) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[EPOC Video] Cannot create graphical context - error %d\n", e)); return GF_IO_ERR; @@ -127,36 +127,36 @@ static GF_Err EVID_InitSurface(GF_VideoOutput *dr) gl_buffer_size = 0; switch (disp_mode) { - case EGray256: - ctx->pixel_format = GF_PIXEL_GREYSCALE; + case EGray256: + ctx->pixel_format = GF_PIXEL_GREYSCALE; ctx->bpp = 1; break; - case EColor64K: - ctx->pixel_format = GF_PIXEL_RGB_565; + case EColor64K: + ctx->pixel_format = GF_PIXEL_RGB_565; ctx->bpp = 2; gl_buffer_size = 16; break; - case EColor16M: - ctx->pixel_format = GF_PIXEL_RGB_24; + case EColor16M: + ctx->pixel_format = GF_PIXEL_RGB_24; ctx->bpp = 3; gl_buffer_size = 24; break; /** 4096 colour display (12 bpp). */ - case EColor4K: - ctx->pixel_format = GF_PIXEL_RGB_444; + case EColor4K: + ctx->pixel_format = GF_PIXEL_RGB_444; ctx->bpp = 2; gl_buffer_size = 12; break; /** True colour display mode (32 bpp, but top byte is unused and unspecified) */ - case EColor16MU: - ctx->pixel_format = GF_PIXEL_RGB_32; + case EColor16MU: + ctx->pixel_format = GF_PIXEL_RGB_32; ctx->bpp = 4; gl_buffer_size = 32; break; #if defined(__SERIES60_3X__) /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ - case EColor16MA: - ctx->pixel_format = GF_PIXEL_ARGB; + case EColor16MA: + ctx->pixel_format = GF_PIXEL_ARGB; ctx->bpp = 4; gl_buffer_size = 32; break; @@ -185,22 +185,25 @@ static GF_Err EVID_InitSurface(GF_VideoOutput *dr) return GF_IO_ERR; } EGLConfig *configList = NULL; - EGLint numOfConfigs = 0; + EGLint numOfConfigs = 0; EGLint configSize = 0; if (eglGetConfigs(ctx->egl_display, configList, configSize, &numOfConfigs) == EGL_FALSE) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[EPOC Video] Cannot retrieve OpenGL configurations\n")); return GF_IO_ERR; } - configSize = numOfConfigs; - configList = (EGLConfig*) gf_malloc(sizeof(EGLConfig)*configSize); + configSize = numOfConfigs; + configList = (EGLConfig*) gf_malloc(sizeof(EGLConfig)*configSize); - // Define properties for the wanted EGLSurface + // Define properties for the wanted EGLSurface EGLint atts[7]; const char *opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsDepth"); - atts[0] = EGL_BUFFER_SIZE; atts[1] = gl_buffer_size; - atts[2] = EGL_DEPTH_SIZE; atts[3] = opt ? atoi(opt) : 16; - atts[4] = EGL_SURFACE_TYPE; atts[5] = EGL_PIXMAP_BIT; + atts[0] = EGL_BUFFER_SIZE; + atts[1] = gl_buffer_size; + atts[2] = EGL_DEPTH_SIZE; + atts[3] = opt ? atoi(opt) : 16; + atts[4] = EGL_SURFACE_TYPE; + atts[5] = EGL_PIXMAP_BIT; atts[6] = EGL_NONE; if (eglChooseConfig(ctx->egl_display, atts, configList, configSize, &numOfConfigs) == EGL_FALSE) { @@ -245,15 +248,25 @@ static GF_Err EVID_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 heig TDisplayMode disp_mode = ctx->screen->DisplayMode(); TInt gl_buffer_size = 0; switch (disp_mode) { - case EColor64K: gl_buffer_size = 16; break; - case EColor16M: gl_buffer_size = 24; break; + case EColor64K: + gl_buffer_size = 16; + break; + case EColor16M: + gl_buffer_size = 24; + break; /** 4096 colour display (12 bpp). */ - case EColor4K: gl_buffer_size = 12; break; + case EColor4K: + gl_buffer_size = 12; + break; /** True colour display mode (32 bpp, but top byte is unused and unspecified) */ - case EColor16MU: gl_buffer_size = 32; break; + case EColor16MU: + gl_buffer_size = 32; + break; #if defined(__SERIES60_3X__) /** Display mode with alpha (24bpp colour plus 8bpp alpha) */ - case EColor16MA: gl_buffer_size = 32; break; + case EColor16MA: + gl_buffer_size = 32; + break; #endif case EGray256: default: @@ -273,7 +286,7 @@ static GF_Err EVID_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 heig } EGLConfig *configList = NULL; - EGLint numOfConfigs = 0; + EGLint numOfConfigs = 0; EGLint configSize = 0; if (eglGetConfigs(ctx->egl_display, configList, configSize, &numOfConfigs) == EGL_FALSE) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[EPOC Video] Cannot retrieve OpenGL configurations\n")); @@ -282,15 +295,21 @@ static GF_Err EVID_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 heig configSize = numOfConfigs; configList = (EGLConfig*) gf_malloc(sizeof(EGLConfig)*configSize); - // Define properties for the wanted EGLSurface + // Define properties for the wanted EGLSurface EGLint atts[13]; const char *opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsDepth"); - atts[0] = EGL_RED_SIZE; atts[1] = 8; - atts[2] = EGL_GREEN_SIZE; atts[3] = 8; - atts[4] = EGL_BLUE_SIZE; atts[5] = 8; - atts[6] = EGL_ALPHA_SIZE; atts[7] = (dr->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA) ? 8 : EGL_DONT_CARE; - atts[8] = EGL_SURFACE_TYPE; atts[9] = EGL_PBUFFER_BIT; - atts[10] = EGL_DEPTH_SIZE; atts[11] = opt ? atoi(opt) : 16; + atts[0] = EGL_RED_SIZE; + atts[1] = 8; + atts[2] = EGL_GREEN_SIZE; + atts[3] = 8; + atts[4] = EGL_BLUE_SIZE; + atts[5] = 8; + atts[6] = EGL_ALPHA_SIZE; + atts[7] = (dr->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA) ? 8 : EGL_DONT_CARE; + atts[8] = EGL_SURFACE_TYPE; + atts[9] = EGL_PBUFFER_BIT; + atts[10] = EGL_DEPTH_SIZE; + atts[11] = opt ? atoi(opt) : 16; atts[12] = EGL_NONE; if (eglChooseConfig(ctx->egl_display, atts, configList, configSize, &numOfConfigs) == EGL_FALSE) { @@ -300,8 +319,10 @@ static GF_Err EVID_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 heig EGLConfig gl_cfg = configList[0]; gf_free(configList); - atts[0] = EGL_WIDTH; atts[1] = width; - atts[2] = EGL_HEIGHT; atts[3] = height; + atts[0] = EGL_WIDTH; + atts[1] = width; + atts[2] = EGL_HEIGHT; + atts[3] = height; atts[4] = EGL_NONE; ctx->egl_surface = eglCreatePbufferSurface(ctx->egl_display, gl_cfg, atts); @@ -484,10 +505,10 @@ void EPOC_aout_del(void *ifce); void EPOC_codec_del(void *ifcg); void *EPOC_codec_new(); - + /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, diff --git a/modules/ffmpeg_in/ffmpeg_decode.c b/modules/ffmpeg_in/ffmpeg_decode.c index e1ca2e1..80a278b 100644 --- a/modules/ffmpeg_in/ffmpeg_decode.c +++ b/modules/ffmpeg_in/ffmpeg_decode.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -25,6 +25,7 @@ #include "ffmpeg_in.h" #include +#include #if (LIBAVCODEC_VERSION_MAJOR >= 55) && (LIBAVCODEC_VERSION_MINOR >= 38) @@ -44,7 +45,7 @@ * \param size Size to allocate (will use extra padding for real size) * \return The newly allocated buffer */ -static uint8_t * ffmpeg_realloc_buffer(uint8_t * oldBuffer, u32 size){ +static uint8_t * ffmpeg_realloc_buffer(uint8_t * oldBuffer, u32 size) { uint8_t * buffer; /* Size of buffer must be larger, see avcodec_decode_video2 documentation */ u32 allocatedSz = sizeof( char ) * (FF_INPUT_BUFFER_PADDING_SIZE + size); @@ -116,7 +117,7 @@ static void FFDEC_LoadDSI(FFDec *ffd, GF_BitStream *bs, AVCodec *codec, AVCodecC gf_bs_read_data(bs, (char *)ctx->extradata + 0x5a, size); } } - break; + break; default: if (ctx->extradata) gf_free(ctx->extradata); @@ -168,12 +169,12 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) codec = &ffd->base_codec; frame = &ffd->base_frame; } - if (!(*ctx)){ + if (!(*ctx)) { #ifdef USE_AVCTX3 - *ctx = avcodec_alloc_context3(NULL); + *ctx = avcodec_alloc_context3(NULL); #else - *ctx = avcodec_alloc_context(); + *ctx = avcodec_alloc_context(); #endif } @@ -219,9 +220,9 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) /*num_frames_per_au*/ gf_bs_read_u8(bs); /*just in case...*/ if (codec_id == GF_4CC('a', 'm', 'r', ' ')) { - (*ctx)->sample_rate = 8000; - (*ctx)->channels = 1; - (*ctx)->frame_size = 160; + (*ctx)->sample_rate = 8000; + (*ctx)->channels = 1; + (*ctx)->frame_size = 160; } } else if (ffd->st==GF_STREAM_VISUAL) { (*ctx)->codec_type = AVMEDIA_TYPE_VIDEO; @@ -245,11 +246,11 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) codec_id = CODEC_ID_H264; break; #ifdef HAS_HEVC - case GPAC_OTI_VIDEO_HEVC: - codec_id = AV_CODEC_ID_HEVC; - break; + case GPAC_OTI_VIDEO_HEVC: + codec_id = AV_CODEC_ID_HEVC; + break; #endif - case GPAC_OTI_VIDEO_MPEG1: + case GPAC_OTI_VIDEO_MPEG1: case GPAC_OTI_VIDEO_MPEG2_SIMPLE: case GPAC_OTI_VIDEO_MPEG2_MAIN: case GPAC_OTI_VIDEO_MPEG2_SNR: @@ -274,6 +275,12 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) (*ctx)->frame_size = 1152; codec_id = CODEC_ID_MP2; break; + case GPAC_OTI_AUDIO_AC3: + codec_id = CODEC_ID_AC3; + break; + case GPAC_OTI_AUDIO_EAC3: + codec_id = CODEC_ID_EAC3; + break; } } else if ((ffd->st==GF_STREAM_ND_SUBPIC) && (ffd->oti==0xe0)) { @@ -311,7 +318,7 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) /*setup dsi for FFMPEG context BEFORE attaching decoder (otherwise not proper init)*/ (*ctx)->extradata = ffmpeg_realloc_buffer((*ctx)->extradata, esd->decoderConfig->decoderSpecificInfo->dataLength + 8); - if ((*ctx)->extradata){ + if ((*ctx)->extradata) { memcpy((*ctx)->extradata, esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength); (*ctx)->extradata_size = esd->decoderConfig->decoderSpecificInfo->dataLength; } else { @@ -320,7 +327,12 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) } } } +#ifndef FF_API_AVFRAME_LAVC *frame = avcodec_alloc_frame(); +#else + *frame = av_frame_alloc(); +#endif + } #ifdef HAS_HEVC if (ffd->oti == GPAC_OTI_VIDEO_HEVC) { @@ -351,9 +363,9 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) GF_LOG(GF_LOG_CODEC, GF_LOG_INFO, ("[HEVC@ffmpeg] Initializing with %d threads\n", nb_threads)); } fprintf(stderr, "[HEVC@ffmpeg] Initializing with %d threads\n", nb_threads); - av_opt_set_int(*ctx, "threads", nb_threads, 0); + av_opt_set_int(*ctx, "threads", nb_threads, 0); - /* Set the decoder id */ + /* Set the decoder id */ //av_opt_set_int(openHevcContext->c->priv_data, "decoder-id", i, 0); sOpt = gf_modules_get_option((GF_BaseInterface *)plug, "OpenHEVC", "CBUnits"); @@ -385,7 +397,13 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) if (!(*ctx)->channels) (*ctx)->channels = 2; #if defined(USE_AVCTX3) + +#ifndef FF_API_AVFRAME_LAVC ffd->audio_frame = avcodec_alloc_frame(); +#else + ffd->audio_frame = av_frame_alloc(); +#endif + #endif } else { @@ -401,14 +419,19 @@ static GF_Err FFDEC_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) break; case CODEC_ID_DVD_SUBTITLE: +#ifndef FF_API_AVFRAME_LAVC *frame = avcodec_alloc_frame(); +#else + *frame = av_frame_alloc(); +#endif + #ifdef USE_AVCODEC2 { - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = (uint8_t *) esd->decoderConfig->decoderSpecificInfo->data; - pkt.size = esd->decoderConfig->decoderSpecificInfo->dataLength; - avcodec_decode_video2((*ctx), *frame, &gotpic, &pkt); + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = (uint8_t *) esd->decoderConfig->decoderSpecificInfo->data; + pkt.size = esd->decoderConfig->decoderSpecificInfo->dataLength; + avcodec_decode_video2((*ctx), *frame, &gotpic, &pkt); } #else avcodec_decode_video((*ctx), *frame, &gotpic, esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength); @@ -551,7 +574,7 @@ static GF_Err FFDEC_GetCapabilities(GF_BaseDecoder *plug, GF_CodecCapability *ca capability->cap.valueInt = (ffd->st==GF_STREAM_AUDIO) ? 4 : 1; break; case GF_CODEC_BUFFER_MAX: - /*for audio let the systems engine decide since we may have very large block size (1 sec with some QT movies)*/ + /*for audio let the systems engine decide since we may have very large block size (1 sec with some QT movies)*/ capability->cap.valueInt = (ffd->st==GF_STREAM_AUDIO) ? 0 : (ffd->is_image ? 1 : ffd->output_cb_size); break; /*by default AAC access unit lasts num_samples (timescale being sampleRate)*/ @@ -565,11 +588,11 @@ static GF_Err FFDEC_GetCapabilities(GF_BaseDecoder *plug, GF_CodecCapability *ca capability->cap.valueInt = ffd->base_ctx->height; break; case GF_CODEC_STRIDE: - if (ffd->out_pix_fmt==GF_PIXEL_RGB_24) + if (ffd->out_pix_fmt==GF_PIXEL_RGB_24) capability->cap.valueInt = ffd->stride*3; - else if (ffd->conv_buffer) + else if (ffd->conv_buffer) capability->cap.valueInt = ffd->base_ctx->width; - else + else capability->cap.valueInt = ffd->stride; break; case GF_CODEC_FPS: @@ -634,10 +657,10 @@ static GF_Err FFDEC_SetCapabilities(GF_BaseDecoder *plug, GF_CodecCapability cap } static GF_Err FFDEC_ProcessData(GF_MediaDecoder *plug, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { #ifdef USE_AVCODEC2 AVPacket pkt; @@ -710,7 +733,11 @@ static GF_Err FFDEC_ProcessData(GF_MediaDecoder *plug, return GF_OK; } if (ffd->frame_start>inBufferLength) ffd->frame_start = 0; - + //seek to last byte consumed by the previous decode4() + else if (ffd->frame_start) { + pkt.data += ffd->frame_start; + pkt.size -= ffd->frame_start; + } redecode: #if defined(USE_AVCTX3) @@ -723,8 +750,14 @@ redecode: gotpic = AVCODEC_MAX_AUDIO_FRAME_SIZE; len = avcodec_decode_audio2(ctx, (short *)ffd->audio_buf, &gotpic, inBuffer + ffd->frame_start, inBufferLength - ffd->frame_start); #endif - if (len<0) { ffd->frame_start = 0; return GF_NON_COMPLIANT_BITSTREAM; } - if (gotpic<0) { ffd->frame_start = 0; return GF_OK; } + if (len<0) { + ffd->frame_start = 0; + return GF_NON_COMPLIANT_BITSTREAM; + } + if (gotpic<0) { + ffd->frame_start = 0; + return GF_OK; + } /*first config*/ if (!ffd->out_size) { @@ -755,7 +788,7 @@ redecode: Float sample = inputChannel[i]; if (sample<-1.0f) sample=-1.0f; else if (sample>1.0f) sample=1.0f; - + output[i*ctx->channels + j] = (int16_t) (sample * GF_SHORT_MAX ); } } @@ -864,11 +897,11 @@ redecode: } } - #ifdef USE_AVCODEC2 +#ifdef USE_AVCODEC2 if (avcodec_decode_video2(ctx, frame, &gotpic, &pkt) < 0) { - #else +#else if (avcodec_decode_video(ctx, frame, &gotpic, inBuffer, inBufferLength) < 0) { - #endif +#endif if (!ffd->check_short_header) { return GF_NON_COMPLIANT_BITSTREAM; } @@ -888,11 +921,11 @@ redecode: if (! (*codec) || (avcodec_open(ctx, *codec)<0)) return GF_NON_COMPLIANT_BITSTREAM; #endif - #if USE_AVCODEC2 +#if USE_AVCODEC2 if (avcodec_decode_video2(ctx, frame, &gotpic, &pkt) < 0) { - #else +#else if (avcodec_decode_video(ctx, frame, &gotpic, inBuffer, inBufferLength) < 0) { - #endif +#endif /*nope, stay in MPEG-4*/ avcodec_close(ctx); *codec = avcodec_find_decoder(old_codec); @@ -907,13 +940,13 @@ redecode: } } - /* - if (!gotpic && (!ctx->width || !ctx->height) ) { - ctx->width = w; - ctx->height = h; - return GF_OK; - } - */ + /* + if (!gotpic && (!ctx->width || !ctx->height) ) { + ctx->width = w; + ctx->height = h; + return GF_OK; + } + */ /*some streams use odd width/height frame values*/ if (ffd->out_pix_fmt == GF_PIXEL_YV12) { if (ctx->width%2) ctx->width++; @@ -931,19 +964,19 @@ redecode: stride = frame->linesize[0]; #ifndef NO_10bit - if ((ctx->pix_fmt == PIX_FMT_YUV420P10LE) && ffd->output_as_8bit && (frame->linesize[0] >= 2*w) ) { + if ((ctx->pix_fmt == PIX_FMT_YUV420P10LE) && ffd->output_as_8bit && (frame->linesize[0] >= 2*w) ) { ffd->conv_to_8bit = 1; stride=w; } #endif - + /*recompute outsize in case on-the-fly change*/ if ((w != ctx->width) || (h != ctx->height) - || (ffd->direct_output && (stride != ffd->stride)) - || ((ffd->out_pix_fmt==GF_PIXEL_YV12) && (ctx->pix_fmt != PIX_FMT_YUV420P) && !ffd->output_as_8bit ) - //need to realloc the conversion buffer - || (ffd->conv_to_8bit && !ffd->conv_buffer && ffd->direct_output) - ) { + || (ffd->direct_output && (stride != ffd->stride)) + || ((ffd->out_pix_fmt==GF_PIXEL_YV12) && (ctx->pix_fmt != PIX_FMT_YUV420P) && !ffd->output_as_8bit ) + //need to realloc the conversion buffer + || (ffd->conv_to_8bit && !ffd->conv_buffer && ffd->direct_output) + ) { ffd->stride = (!ffd->conv_to_8bit && ffd->direct_output) ? frame->linesize[0] : ctx->width; if (ffd->out_pix_fmt == GF_PIXEL_RGB_24) { @@ -973,7 +1006,7 @@ redecode: ffd->previous_par = (ctx->sample_aspect_ratio.num<<16) | ctx->sample_aspect_ratio.den; } - /*we didn't get any picture: wait for a picture before resizing output buffer, otherwise we will have no + /*we didn't get any picture: wait for a picture before resizing output buffer, otherwise we will have no video in the output buffer*/ if (!gotpic) { ffd->needs_output_resize = 1; @@ -1019,7 +1052,7 @@ redecode: if (!gotpic) return GF_OK; #if (LIBAVCODEC_VERSION_MAJOR>52) - //fixme - investigate this, happens in some dash cases + //fixme - investigate this, happens in some dash cases if ((frame->width!=ctx->width) || (frame->height!=ctx->height)) { *outBufferLength = 0; return GF_OK; @@ -1041,7 +1074,7 @@ redecode: dst.pixel_format = GF_PIXEL_YV12; gf_color_write_yv12_10_to_yuv(&dst, (u8 *) frame->data[0], frame->data[1], frame->data[2], frame->linesize[0], ctx->width, ctx->height, NULL); - *outBufferLength = ffd->out_size; + *outBufferLength = ffd->out_size; return GF_OK; } @@ -1121,9 +1154,9 @@ redecode: img_convert(&pict, pix_out, (AVPicture *) frame, ctx->pix_fmt, ctx->width, ctx->height); #else *cached_sws = sws_getCachedContext(*cached_sws, - ctx->width, ctx->height, ctx->pix_fmt, - ctx->width, ctx->height, pix_out, - SWS_BICUBIC, NULL, NULL, NULL); + ctx->width, ctx->height, ctx->pix_fmt, + ctx->width, ctx->height, pix_out, + SWS_BICUBIC, NULL, NULL, NULL); if ((*cached_sws)) { #if LIBSWSCALE_VERSION_INT < AV_VERSION_INT(0, 9, 0) int sz = sws_scale((*cached_sws), frame->data, frame->linesize, 0, ctx->height, pict.data, pict.linesize); @@ -1144,7 +1177,7 @@ static GF_Err FFDEC_GetOutputBuffer(GF_MediaDecoder *ifcg, u16 ES_ID, u8 **pY_or { FFDec *ffd = ifcg->privateStack; AVFrame *frame; - + if (ffd->conv_buffer) { *pY_or_RGB = (u8 *) ffd->conv_buffer; @@ -1161,7 +1194,7 @@ static GF_Err FFDEC_GetOutputBuffer(GF_MediaDecoder *ifcg, u16 ES_ID, u8 **pY_or *pY_or_RGB = frame->data[0]; *pU = frame->data[1]; *pV = frame->data[2]; - } + } return GF_OK; } @@ -1200,16 +1233,25 @@ static u32 FFDEC_CanHandleStream(GF_BaseDecoder *plug, u32 StreamType, GF_ESD *e } else if (StreamType==GF_STREAM_AUDIO) { /*std MPEG-2 audio*/ - if ((ffd->oti==GPAC_OTI_AUDIO_MPEG2_PART3) || (ffd->oti==GPAC_OTI_AUDIO_MPEG1)) codec_id = CODEC_ID_MP2; - /*std AC3 audio*/ - //if (ffd->oti==0xA5) codec_id = CODEC_ID_AC3; + switch (ffd->oti) { + case GPAC_OTI_AUDIO_MPEG2_PART3: + case GPAC_OTI_AUDIO_MPEG1: + codec_id = CODEC_ID_MP2; + break; + case GPAC_OTI_AUDIO_AC3: + codec_id = CODEC_ID_AC3; + break; + case GPAC_OTI_AUDIO_EAC3: + codec_id = CODEC_ID_EAC3; + break; + } } /*std MPEG-4 visual*/ else if (StreamType==GF_STREAM_VISUAL) { /*fixme - we should use some priority rather than declare ffmpeg can't handle svc*/ - if (esd->decoderConfig->objectTypeIndication == GPAC_OTI_VIDEO_AVC){ + if (esd->decoderConfig->objectTypeIndication == GPAC_OTI_VIDEO_AVC) { if (esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data) { Bool is_svc = 0; u32 i, count; @@ -1239,15 +1281,19 @@ static u32 FFDEC_CanHandleStream(GF_BaseDecoder *plug, u32 StreamType, GF_ESD *e switch (ffd->oti) { /*MPEG-4 v1 simple profile*/ - case GPAC_OTI_VIDEO_MPEG4_PART2: codec_id = CODEC_ID_MPEG4; break; + case GPAC_OTI_VIDEO_MPEG4_PART2: + codec_id = CODEC_ID_MPEG4; + break; /*H264 (not std OTI, just the way we use it internally)*/ case GPAC_OTI_VIDEO_AVC: - codec_id = CODEC_ID_H264; break; + codec_id = CODEC_ID_H264; + break; #ifdef HAS_HEVC - case GPAC_OTI_VIDEO_HEVC: - codec_id = AV_CODEC_ID_HEVC; break; + case GPAC_OTI_VIDEO_HEVC: + codec_id = AV_CODEC_ID_HEVC; + break; #endif - /*MPEG1 video*/ + /*MPEG1 video*/ case GPAC_OTI_VIDEO_MPEG1: /*MPEG2 video*/ case GPAC_OTI_VIDEO_MPEG2_SIMPLE: @@ -1256,15 +1302,16 @@ static u32 FFDEC_CanHandleStream(GF_BaseDecoder *plug, u32 StreamType, GF_ESD *e case GPAC_OTI_VIDEO_MPEG2_SPATIAL: case GPAC_OTI_VIDEO_MPEG2_HIGH: case GPAC_OTI_VIDEO_MPEG2_422: - codec_id = CODEC_ID_MPEG2VIDEO; break; + codec_id = CODEC_ID_MPEG2VIDEO; + break; /*JPEG*/ case GPAC_OTI_IMAGE_JPEG: codec_id = CODEC_ID_MJPEG; /*return maybe supported as FFMPEG JPEG decoder has some issues with many files, so let's use it only if no other dec is available*/ - if (avcodec_find_decoder(codec_id) != NULL) + if (avcodec_find_decoder(codec_id) != NULL) return GF_CODEC_MAYBE_SUPPORTED; - + return GF_CODEC_NOT_SUPPORTED; default: return GF_CODEC_NOT_SUPPORTED; @@ -1283,8 +1330,16 @@ static u32 FFDEC_CanHandleStream(GF_BaseDecoder *plug, u32 StreamType, GF_ESD *e if (avcodec_find_decoder(codec_id) != NULL) { if (esd->decoderConfig->rvc_config || esd->decoderConfig->predefined_rvc_config) return GF_CODEC_MAYBE_SUPPORTED; + + //for HEVC return MAYBE supported to fallback to openHEVC if present (more optimized for now) +#ifdef HAS_HEVC + if (codec_id == AV_CODEC_ID_HEVC) + return GF_CODEC_MAYBE_SUPPORTED; +#endif + return GF_CODEC_SUPPORTED; } + return GF_CODEC_NOT_SUPPORTED; } @@ -1341,7 +1396,7 @@ void FFDEC_Delete(void *ifce) return; ffd = dec->privateStack; dec->privateStack = NULL; - if (ffd){ + if (ffd) { if (ffd->base_ctx && ffd->base_ctx->codec) avcodec_close(ffd->base_ctx); ffd->base_ctx = NULL; if (ffd->depth_ctx && ffd->depth_ctx->codec) avcodec_close(ffd->depth_ctx); diff --git a/modules/ffmpeg_in/ffmpeg_demux.c b/modules/ffmpeg_in/ffmpeg_demux.c index ed818a1..e365910 100644 --- a/modules/ffmpeg_in/ffmpeg_demux.c +++ b/modules/ffmpeg_in/ffmpeg_demux.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -81,7 +81,7 @@ static u32 FFDemux_Run(void *par) com.command_type = GF_NET_BUFFER_QUERY; memset(&slh, 0, sizeof(GF_SLHeader)); - + slh.compositionTimeStampFlag = slh.decodingTimeStampFlag = 1; while (ffd->is_running) { @@ -116,7 +116,7 @@ static u32 FFDemux_Run(void *par) slh.decodingTimeStamp = slh.compositionTimeStamp = seek_audio; } #endif - gf_term_on_sl_packet(ffd->service, ffd->audio_ch, (char *) pkt.data, pkt.size, &slh, GF_OK); + gf_service_send_packet(ffd->service, ffd->audio_ch, (char *) pkt.data, pkt.size, &slh, GF_OK); } else if (ffd->video_ch && (pkt.stream_index == ffd->video_st)) { // u64 seek_video = ffd->seek_time ? (u64) (s64) (ffd->seek_time*ffd->video_tscale.den) : 0; @@ -128,7 +128,7 @@ static u32 FFDemux_Run(void *par) slh.decodingTimeStamp = slh.compositionTimeStamp = seek_video; } #endif - gf_term_on_sl_packet(ffd->service, ffd->video_ch, (char *) pkt.data, pkt.size, &slh, GF_OK); + gf_service_send_packet(ffd->service, ffd->video_ch, (char *) pkt.data, pkt.size, &slh, GF_OK); } gf_mx_v(ffd->mx); av_free_packet(&pkt); @@ -136,8 +136,8 @@ static u32 FFDemux_Run(void *par) /*sleep untill the buffer occupancy is too low - note that this work because all streams in this demuxer are synchronized*/ while (ffd->audio_run || ffd->video_run) { - gf_term_on_command(ffd->service, &com, GF_OK); - if (com.buffer.occupancy < com.buffer.max) + gf_service_command(ffd->service, &com, GF_OK); + if (com.buffer.occupancy < com.buffer.max) break; gf_sleep(10); @@ -145,49 +145,49 @@ static u32 FFDemux_Run(void *par) if (!ffd->audio_run && !ffd->video_run) break; } /*signal EOS*/ - if (ffd->audio_ch) gf_term_on_sl_packet(ffd->service, ffd->audio_ch, NULL, 0, NULL, GF_EOS); - if (ffd->video_ch) gf_term_on_sl_packet(ffd->service, ffd->video_ch, NULL, 0, NULL, GF_EOS); + if (ffd->audio_ch) gf_service_send_packet(ffd->service, ffd->audio_ch, NULL, 0, NULL, GF_EOS); + if (ffd->video_ch) gf_service_send_packet(ffd->service, ffd->video_ch, NULL, 0, NULL, GF_EOS); ffd->is_running = 2; return 0; } static const char * FFD_MIME_TYPES[] = { - "video/x-mpeg", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", - "video/x-mpeg-systems", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", - "audio/basic", "snd au", "Basic Audio", - "audio/x-wav", "wav", "WAV Audio", - "audio/vnd.wave", "wav", "WAV Audio", - "video/x-ms-asf", "asf wma wmv asx asr", "WindowsMedia Movies", - "video/x-ms-wmv", "asf wma wmv asx asr", "WindowsMedia Movies", - "video/x-msvideo", "avi", "AVI Movies", - "video/x-ms-video", "avi", "AVI Movies", - "video/avi", "avi", "AVI Movies", - "video/vnd.avi", "avi", "AVI Movies", - "video/H263", "h263 263", "H263 Video", - "video/H264", "h264 264", "H264 Video", - "video/MPEG4", "cmp", "MPEG-4 Video", -/* We let ffmpeg handle mov because some QT files with uncompressed or adpcm audio use 1 audio sample - per MP4 sample which is a killer for our MP4 lib, whereas ffmpeg handles these as complete audio chunks - moreover ffmpeg handles cmov, we don't */ - "video/quicktime", "mov qt", "QuickTime Movies", -/* Supported by latest versions of FFMPEG */ - "video/webm", "webm", "Google WebM Movies", - "audio/webm", "webm", "Google WebM Music", + "video/x-mpeg", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", + "video/x-mpeg-systems", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", + "audio/basic", "snd au", "Basic Audio", + "audio/x-wav", "wav", "WAV Audio", + "audio/vnd.wave", "wav", "WAV Audio", + "video/x-ms-asf", "asf wma wmv asx asr", "WindowsMedia Movies", + "video/x-ms-wmv", "asf wma wmv asx asr", "WindowsMedia Movies", + "video/x-msvideo", "avi", "AVI Movies", + "video/x-ms-video", "avi", "AVI Movies", + "video/avi", "avi", "AVI Movies", + "video/vnd.avi", "avi", "AVI Movies", + "video/H263", "h263 263", "H263 Video", + "video/H264", "h264 264", "H264 Video", + "video/MPEG4", "cmp", "MPEG-4 Video", + /* We let ffmpeg handle mov because some QT files with uncompressed or adpcm audio use 1 audio sample + per MP4 sample which is a killer for our MP4 lib, whereas ffmpeg handles these as complete audio chunks + moreover ffmpeg handles cmov, we don't */ + "video/quicktime", "mov qt", "QuickTime Movies", + /* Supported by latest versions of FFMPEG */ + "video/webm", "webm", "Google WebM Movies", + "audio/webm", "webm", "Google WebM Music", #ifdef FFMPEG_DEMUX_ENABLE_MPEG2TS - "video/mp2t", "ts", "MPEG 2 TS", + "video/mp2t", "ts", "MPEG 2 TS", #endif - NULL + NULL }; -static u32 FFD_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - for (i = 0 ; FFD_MIME_TYPES[i]; i+=3) - gf_term_register_mime_type(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2]); - return i/3; +static u32 FFD_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + for (i = 0 ; FFD_MIME_TYPES[i]; i+=3) + gf_service_register_mime(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2]); + return i/3; } -static int open_file(AVFormatContext ** ic_ptr, const char * filename, AVInputFormat * fmt){ +static int open_file(AVFormatContext ** ic_ptr, const char * filename, AVInputFormat * fmt) { #ifdef USE_PRE_0_7 return av_open_input_file(ic_ptr, filename, fmt, 0, NULL); #else @@ -234,30 +234,30 @@ static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url) /*note we forbid ffmpeg to handle files we support*/ if (!strcmp(szExt, "mp4") || !strcmp(szExt, "mpg4") || !strcmp(szExt, "m4a") || !strcmp(szExt, "m21") - || !strcmp(szExt, "m4v") || !strcmp(szExt, "m4a") - || !strcmp(szExt, "m4s") || !strcmp(szExt, "3gs") - || !strcmp(szExt, "3gp") || !strcmp(szExt, "3gpp") || !strcmp(szExt, "3gp2") || !strcmp(szExt, "3g2") - || !strcmp(szExt, "mp3") - || !strcmp(szExt, "ac3") - || !strcmp(szExt, "amr") - || !strcmp(szExt, "bt") || !strcmp(szExt, "wrl") || !strcmp(szExt, "x3dv") - || !strcmp(szExt, "xmt") || !strcmp(szExt, "xmta") || !strcmp(szExt, "x3d") - - || !strcmp(szExt, "jpg") || !strcmp(szExt, "jpeg") || !strcmp(szExt, "png") - ) return 0; + || !strcmp(szExt, "m4v") || !strcmp(szExt, "m4a") + || !strcmp(szExt, "m4s") || !strcmp(szExt, "3gs") + || !strcmp(szExt, "3gp") || !strcmp(szExt, "3gpp") || !strcmp(szExt, "3gp2") || !strcmp(szExt, "3g2") + || !strcmp(szExt, "mp3") + || !strcmp(szExt, "ac3") + || !strcmp(szExt, "amr") + || !strcmp(szExt, "bt") || !strcmp(szExt, "wrl") || !strcmp(szExt, "x3dv") + || !strcmp(szExt, "xmt") || !strcmp(szExt, "xmta") || !strcmp(szExt, "x3d") + + || !strcmp(szExt, "jpg") || !strcmp(szExt, "jpeg") || !strcmp(szExt, "png") + ) return 0; /*check any default stuff that should work with ffmpeg*/ { - u32 i; - for (i = 0 ; FFD_MIME_TYPES[i]; i+=3){ - if (gf_term_check_extension(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2], ext)) - return 1; - } + u32 i; + for (i = 0 ; FFD_MIME_TYPES[i]; i+=3) { + if (gf_service_check_mime_register(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2], ext)) + return 1; + } } } ctx = NULL; - if (open_file(&ctx, szName, NULL)<0) { + if (open_file(&ctx, szName, NULL)<0) { AVInputFormat *av_in = NULL;; /*some extensions not supported by ffmpeg*/ if (ext && !strcmp(szExt, "cmp")) av_in = av_find_input_format("m4v"); @@ -266,7 +266,7 @@ static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url) return 0; } } - if (!ctx || av_find_stream_info(ctx) <0) goto exit; + if (!ctx || av_find_stream_info(ctx) <0) goto exit; /*figure out if we can use codecs or not*/ has_video = has_audio = 0; @@ -290,7 +290,7 @@ static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url) #else fmt_out = av_guess_format(NULL, url, NULL); #endif - if (fmt_out) gf_term_register_mime_type(plug, fmt_out->mime_type, fmt_out->extensions, fmt_out->name); + if (fmt_out) gf_service_register_mime(plug, fmt_out->mime_type, fmt_out->extensions, fmt_out->name); else { ext = strrchr(szName, '.'); if (ext) { @@ -299,7 +299,7 @@ static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url) szExtList = gf_modules_get_option((GF_BaseInterface *)plug, "MimeTypes", "application/x-ffmpeg"); if (!szExtList) { - gf_term_register_mime_type(plug, "application/x-ffmpeg", szExt, "Other Movies (FFMPEG)"); + gf_service_register_mime(plug, "application/x-ffmpeg", szExt, "Other Movies (FFMPEG)"); } else if (!strstr(szExtList, szExt)) { u32 len; char *buf; @@ -314,7 +314,11 @@ static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url) } exit: - if (ctx) av_close_input_file(ctx); +#ifndef FF_API_CLOSE_INPUT_FILE + if (ctx) av_close_input_file(ctx); +#else + if (ctx) avformat_close_input(&ctx); +#endif return ret; } @@ -330,7 +334,7 @@ static GF_ESD *FFD_GetESDescriptor(FFDemux *ffd, Bool for_audio) /*remap std object types - depending on input formats, FFMPEG may not have separate DSI from initial frame. In this case we have no choice but using FFMPEG decoders*/ if (for_audio) { - AVCodecContext *dec = ffd->ctx->streams[ffd->audio_st]->codec; + AVCodecContext *dec = ffd->ctx->streams[ffd->audio_st]->codec; esd->slConfig->timestampResolution = ffd->audio_tscale.den; switch (dec->codec_id) { case CODEC_ID_MP2: @@ -345,8 +349,8 @@ static GF_ESD *FFD_GetESDescriptor(FFDemux *ffd, Bool for_audio) esd->decoderConfig->decoderSpecificInfo->dataLength = dec->extradata_size; esd->decoderConfig->decoderSpecificInfo->data = gf_malloc(sizeof(char)*dec->extradata_size); memcpy(esd->decoderConfig->decoderSpecificInfo->data, - dec->extradata, - sizeof(char)*dec->extradata_size); + dec->extradata, + sizeof(char)*dec->extradata_size); break; default: opaque_audio: @@ -375,9 +379,9 @@ opaque_audio: esd->slConfig->timestampResolution = ffd->video_tscale.den; switch (dec->codec_id) { case CODEC_ID_MPEG4: - /*there is a bug in fragmentation of raw H264 in ffmpeg, the NALU startcode (0x00000001) is split across - two frames - we therefore force internal ffmpeg codec ID to avoid NALU size recompute - at the decoder level*/ + /*there is a bug in fragmentation of raw H264 in ffmpeg, the NALU startcode (0x00000001) is split across + two frames - we therefore force internal ffmpeg codec ID to avoid NALU size recompute + at the decoder level*/ // case CODEC_ID_H264: /*if dsi not detected force use ffmpeg*/ if (!dec->extradata_size) goto opaque_video; @@ -386,8 +390,8 @@ opaque_audio: esd->decoderConfig->decoderSpecificInfo->dataLength = dec->extradata_size; esd->decoderConfig->decoderSpecificInfo->data = gf_malloc(sizeof(char)*dec->extradata_size); memcpy(esd->decoderConfig->decoderSpecificInfo->data, - dec->extradata, - sizeof(char)*dec->extradata_size); + dec->extradata, + sizeof(char)*dec->extradata_size); break; case CODEC_ID_MPEG1VIDEO: esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_MPEG1; @@ -442,7 +446,7 @@ static void FFD_SetupObjects(FFDemux *ffd) od->objectDescriptorID = esd->ESID; audio_esid = esd->ESID; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(ffd->service, (GF_Descriptor*)od, (ffd->video_st>=0) ? 1 : 0); + gf_service_declare_media(ffd->service, (GF_Descriptor*)od, (ffd->video_st>=0) ? 1 : 0); } if ((ffd->video_st>=0) && (ffd->service_type != 2)) { od = (GF_ObjectDescriptor *) gf_odf_desc_new(GF_ODF_OD_TAG); @@ -450,7 +454,7 @@ static void FFD_SetupObjects(FFDemux *ffd) od->objectDescriptorID = esd->ESID; esd->OCRESID = audio_esid; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(ffd->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(ffd->service, (GF_Descriptor*)od, 0); } } @@ -564,7 +568,7 @@ static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, ffd->io.seekable = 1; #endif - ffd->dnload = gf_term_download_new(ffd->service, url, GF_NETIO_SESSION_NOT_THREADED | GF_NETIO_SESSION_NOT_CACHED, NULL, ffd); + ffd->dnload = gf_service_download_new(ffd->service, url, GF_NETIO_SESSION_NOT_THREADED | GF_NETIO_SESSION_NOT_CACHED, NULL, ffd); if (!ffd->dnload) return GF_URL_ERROR; while (1) { u32 read; @@ -602,13 +606,25 @@ static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, switch (res) { #ifndef _WIN32_WCE - case 0: e = GF_OK; break; - case AVERROR_IO: e = GF_URL_ERROR; goto err_exit; - case AVERROR_INVALIDDATA: e = GF_NON_COMPLIANT_BITSTREAM; goto err_exit; - case AVERROR_NOMEM: e = GF_OUT_OF_MEM; goto err_exit; - case AVERROR_NOFMT: e = GF_NOT_SUPPORTED; goto err_exit; + case 0: + e = GF_OK; + break; + case AVERROR_IO: + e = GF_URL_ERROR; + goto err_exit; + case AVERROR_INVALIDDATA: + e = GF_NON_COMPLIANT_BITSTREAM; + goto err_exit; + case AVERROR_NOMEM: + e = GF_OUT_OF_MEM; + goto err_exit; + case AVERROR_NOFMT: + e = GF_NOT_SUPPORTED; + goto err_exit; #endif - default: e = GF_SERVICE_ERROR; goto err_exit; + default: + e = GF_SERVICE_ERROR; + goto err_exit; } GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[FFMPEG] looking for streams in %s - %d streams - type %s\n", ffd->ctx->filename, ffd->ctx->nb_streams, ffd->ctx->iformat->name)); @@ -673,7 +689,11 @@ static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, ffd->seekable = (av_seek_frame(ffd->ctx, -1, 0, AVSEEK_FLAG_BACKWARD)<0) ? 0 : 1; if (!ffd->seekable) { +#ifndef FF_API_CLOSE_INPUT_FILE av_close_input_file(ffd->ctx); +#else + avformat_close_input(&ffd->ctx); +#endif ffd->ctx = NULL; open_file(&ffd->ctx, szName, av_in); av_find_stream_info(ffd->ctx); @@ -681,16 +701,20 @@ static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, } /*let's go*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); /*if (!ffd->service_type)*/ FFD_SetupObjects(ffd); ffd->service_type = 0; return GF_OK; err_exit: GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[FFMPEG] Error opening file %s: %s\n", url, gf_error_to_string(e))); - if (ffd->ctx) av_close_input_file(ffd->ctx); +#ifndef FF_API_CLOSE_INPUT_FILE + if (ffd->ctx) av_close_input_file(ffd->ctx); +#else + if (ffd->ctx) avformat_close_input(&ffd->ctx); +#endif ffd->ctx = NULL; - gf_term_on_connect(serv, NULL, e); + gf_service_connect_ack(serv, NULL, e); return GF_OK; } @@ -742,7 +766,12 @@ static GF_Err FFD_CloseService(GF_InputService *plug) ffd->is_running = 0; +#ifndef FF_API_CLOSE_INPUT_FILE if (ffd->ctx) av_close_input_file(ffd->ctx); +#else + if (ffd->ctx) avformat_close_input(&ffd->ctx); +#endif + ffd->ctx = NULL; ffd->audio_ch = ffd->video_ch = NULL; ffd->audio_run = ffd->video_run = 0; @@ -752,13 +781,13 @@ static GF_Err FFD_CloseService(GF_InputService *plug) while (!ffd->is_running) gf_sleep(1); ffd->is_running = 0; } - gf_term_download_del(ffd->dnload); + gf_service_download_del(ffd->dnload); ffd->dnload = NULL; } if (ffd->buffer) gf_free(ffd->buffer); ffd->buffer = NULL; - gf_term_on_disconnect(ffd->service, NULL, GF_OK); + gf_service_disconnect_ack(ffd->service, NULL, GF_OK); #ifdef FFMPEG_DUMP_REMOTE if (ffd->outdbg) fclose(ffd->outdbg); #endif @@ -800,7 +829,7 @@ static GF_Err FFD_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(ffd->service, channel, e); + gf_service_connect_ack(ffd->service, channel, e); return GF_OK; } @@ -820,7 +849,7 @@ static GF_Err FFD_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) ffd->video_ch = NULL; ffd->video_run = 0; } - gf_term_on_disconnect(ffd->service, channel, e); + gf_service_disconnect_ack(ffd->service, channel, e); return GF_OK; } @@ -892,7 +921,7 @@ static Bool FFD_CanHandleURLInService(GF_InputService *plug, const char *url) if (!plug || !url) return GF_FALSE; ffd = (FFDemux *)plug->priv; - this_url = gf_term_get_service_url(ffd->service); + this_url = gf_service_get_url(ffd->service); if (!this_url) return GF_FALSE; @@ -915,13 +944,13 @@ void *New_FFMPEG_Demux() GF_SAFEALLOC(priv, FFDemux); - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[FFMPEG Demuxer] Registering all ffmpeg plugins...\n") ); - /* register all codecs, demux and protocols */ - av_register_all(); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[FFMPEG Demuxer] Registering all ffmpeg plugins DONE.\n") ); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[FFMPEG Demuxer] Registering all ffmpeg plugins...\n") ); + /* register all codecs, demux and protocols */ + av_register_all(); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[FFMPEG Demuxer] Registering all ffmpeg plugins DONE.\n") ); ffd->RegisterMimeTypes = FFD_RegisterMimeTypes; - ffd->CanHandleURL = FFD_CanHandleURL; + ffd->CanHandleURL = FFD_CanHandleURL; ffd->CloseService = FFD_CloseService; ffd->ConnectChannel = FFD_ConnectChannel; ffd->ConnectService = FFD_ConnectService; diff --git a/modules/ffmpeg_in/ffmpeg_in.h b/modules/ffmpeg_in/ffmpeg_in.h index 8845c6d..a9aa0b7 100644 --- a/modules/ffmpeg_in/ffmpeg_in.h +++ b/modules/ffmpeg_in/ffmpeg_in.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -109,7 +109,7 @@ void gf_av_vlog(void* avcl, int level, const char *fmt, va_list vl); #undef USE_AVCODEC2 #endif -#if (LIBAVCODEC_VERSION_MAJOR >= 55) +#if (LIBAVCODEC_VERSION_MAJOR >= 55) #define USE_AVCTX3 #elif (LIBAVCODEC_VERSION_MAJOR >= 54) && (LIBAVCODEC_VERSION_MINOR >= 35) #define USE_AVCTX3 @@ -117,7 +117,7 @@ void gf_av_vlog(void* avcl, int level, const char *fmt, va_list vl); /*FFMPEG decoder module */ -typedef struct +typedef struct { char szCodec[100]; u32 out_size; @@ -196,7 +196,7 @@ typedef struct /*input file*/ AVFormatContext *ctx; - + Bool seekable; Double seek_time; @@ -244,14 +244,14 @@ void Delete_FFMPEG_Demux(void *ifce); u32 codec_id -- for audio - +- for audio - u32 sample_rate: sampling rate or 0 if unknown u16 nb_channels: num channels or 0 if unknown u16 nb_bits_per_sample: nb bits or 0 if unknown u16 num_samples: num audio samples per frame or 0 if unknown u16 block_align: audio block align -- for video - +- for video - u32 width: video width or 0 if unknown; u32 height: video height or 0 if unknown; diff --git a/modules/ffmpeg_in/ffmpeg_load.c b/modules/ffmpeg_in/ffmpeg_load.c index 6237330..0e82811 100644 --- a/modules/ffmpeg_in/ffmpeg_load.c +++ b/modules/ffmpeg_in/ffmpeg_load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -28,7 +28,7 @@ #if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(__GNUC__) -#if defined(_WIN32_WCE) +#if defined(_WIN32_WCE) #pragma comment(lib, "toolhelp") #pragma comment(lib, "winsock") #endif @@ -36,11 +36,6 @@ #define _TOSTR(_val) #_val #define TOSTR(_val) _TOSTR(_val) -#pragma comment(lib, "avcodec-"TOSTR(LIBAVCODEC_VERSION_MAJOR) ) -#pragma comment(lib, "avformat-"TOSTR(LIBAVFORMAT_VERSION_MAJOR) ) -#pragma comment(lib, "avutil-"TOSTR(LIBAVUTIL_VERSION_MAJOR) ) -#pragma comment(lib, "swscale-"TOSTR(LIBSWSCALE_VERSION_MAJOR) ) - #endif @@ -52,7 +47,7 @@ const u32 *QueryInterfaces() #ifndef DISABLE_FFMPEG_DEMUX GF_NET_CLIENT_INTERFACE, #endif - 0 + 0 }; return si; } diff --git a/modules/freenect/freenect.c b/modules/freenect/freenect.c index 9a28895..ca8925c 100644 --- a/modules/freenect/freenect.c +++ b/modules/freenect/freenect.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -89,7 +89,7 @@ void Freenect_DepthCallback_RGBD(freenect_device *dev, void *v_depth, uint32_t t } } vcap->depth_sl_header.compositionTimeStamp = timestamp; - gf_term_on_sl_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); + gf_service_send_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); } } @@ -101,7 +101,7 @@ void Freenect_DepthCallback_GREY16(freenect_device *dev, void *v_depth, uint32_t memcpy(vcap->depth_buf, v_depth, vcap->out_depth_size); vcap->depth_sl_header.compositionTimeStamp = timestamp; - gf_term_on_sl_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); + gf_service_send_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); } } @@ -121,7 +121,7 @@ void Freenect_DepthCallback_GREY8(freenect_device *dev, void *v_depth, uint32_t } // vcap->depth_sl_header.compositionTimeStamp = timestamp; vcap->depth_sl_header.compositionTimeStamp ++; - gf_term_on_sl_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); + gf_service_send_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); } } @@ -136,45 +136,45 @@ void Freenect_DepthCallback_ColorGradient(freenect_device *dev, void *v_depth, u int pval = vcap->gamma[depth[i]]; int lb = pval & 0xff; switch (pval>>8) { - case 0: - vcap->depth_buf[3*i+0] = 255; - vcap->depth_buf[3*i+1] = 255-lb; - vcap->depth_buf[3*i+2] = 255-lb; - break; - case 1: - vcap->depth_buf[3*i+0] = 255; - vcap->depth_buf[3*i+1] = lb; - vcap->depth_buf[3*i+2] = 0; - break; - case 2: - vcap->depth_buf[3*i+0] = 255-lb; - vcap->depth_buf[3*i+1] = 255; - vcap->depth_buf[3*i+2] = 0; - break; - case 3: - vcap->depth_buf[3*i+0] = 0; - vcap->depth_buf[3*i+1] = 255; - vcap->depth_buf[3*i+2] = lb; - break; - case 4: - vcap->depth_buf[3*i+0] = 0; - vcap->depth_buf[3*i+1] = 255-lb; - vcap->depth_buf[3*i+2] = 255; - break; - case 5: - vcap->depth_buf[3*i+0] = 0; - vcap->depth_buf[3*i+1] = 0; - vcap->depth_buf[3*i+2] = 255-lb; - break; - default: - vcap->depth_buf[3*i+0] = 0; - vcap->depth_buf[3*i+1] = 0; - vcap->depth_buf[3*i+2] = 0; - break; + case 0: + vcap->depth_buf[3*i+0] = 255; + vcap->depth_buf[3*i+1] = 255-lb; + vcap->depth_buf[3*i+2] = 255-lb; + break; + case 1: + vcap->depth_buf[3*i+0] = 255; + vcap->depth_buf[3*i+1] = lb; + vcap->depth_buf[3*i+2] = 0; + break; + case 2: + vcap->depth_buf[3*i+0] = 255-lb; + vcap->depth_buf[3*i+1] = 255; + vcap->depth_buf[3*i+2] = 0; + break; + case 3: + vcap->depth_buf[3*i+0] = 0; + vcap->depth_buf[3*i+1] = 255; + vcap->depth_buf[3*i+2] = lb; + break; + case 4: + vcap->depth_buf[3*i+0] = 0; + vcap->depth_buf[3*i+1] = 255-lb; + vcap->depth_buf[3*i+2] = 255; + break; + case 5: + vcap->depth_buf[3*i+0] = 0; + vcap->depth_buf[3*i+1] = 0; + vcap->depth_buf[3*i+2] = 255-lb; + break; + default: + vcap->depth_buf[3*i+0] = 0; + vcap->depth_buf[3*i+1] = 0; + vcap->depth_buf[3*i+2] = 0; + break; } } vcap->depth_sl_header.compositionTimeStamp = timestamp; - gf_term_on_sl_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); + gf_service_send_packet(vcap->service, vcap->depth_channel, (char *) vcap->depth_buf, vcap->out_depth_size, &vcap->depth_sl_header, GF_OK); } } @@ -183,7 +183,7 @@ void Freenect_RGBCallback(freenect_device *dev, void *rgb, uint32_t timestamp) FreenectIn *vcap = freenect_get_user(dev); if (vcap->color_channel) { vcap->color_sl_header.compositionTimeStamp = timestamp; - gf_term_on_sl_packet(vcap->service, vcap->color_channel, (char *) rgb, vcap->out_color_size, &vcap->color_sl_header, GF_OK); + gf_service_send_packet(vcap->service, vcap->color_channel, (char *) rgb, vcap->out_color_size, &vcap->color_sl_header, GF_OK); } } @@ -294,7 +294,7 @@ GF_Err Freenect_ConnectService(GF_InputService *plug, GF_ClientService *serv, co while (params) { char *sep = (char *) strchr(params, '&'); if (sep) sep[0] = 0; - + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[VideoCapture] Set camera option %s\n", params)); if (!strnicmp(params, "resolution=", 11)) { @@ -388,12 +388,12 @@ GF_Err Freenect_ConnectService(GF_InputService *plug, GF_ClientService *serv, co } /*ACK connection is OK*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); /*setup object descriptor*/ od = (GF_ObjectDescriptor *) gf_odf_desc_new(GF_ODF_OD_TAG); - + esd = gf_odf_desc_esd_new(0); esd->slConfig->timestampResolution = 1000; if (!strnicmp(url, "camera://", 9) || !strnicmp(url, "video://", 8) || !strnicmp(url, "kinect://", 8)) { @@ -412,7 +412,7 @@ GF_Err Freenect_ConnectService(GF_InputService *plug, GF_ClientService *serv, co esd->decoderConfig->streamType = GF_STREAM_AUDIO; } esd->decoderConfig->objectTypeIndication = GPAC_OTI_RAW_MEDIA_STREAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); gf_bs_write_u32(bs, (esd->ESID==2) ? vcap->color_pixel_format : vcap->depth_pixel_format); gf_bs_write_u16(bs, vcap->width); @@ -423,7 +423,7 @@ GF_Err Freenect_ConnectService(GF_InputService *plug, GF_ClientService *serv, co gf_bs_del(bs); gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(vcap->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(vcap->service, (GF_Descriptor*)od, 0); return GF_OK; } @@ -435,7 +435,7 @@ GF_Err Freenect_CloseService(GF_InputService *plug) if (vcap->f_ctx) freenect_shutdown(vcap->f_ctx); vcap->f_ctx = NULL; vcap->f_dev = NULL; - gf_term_on_disconnect(vcap->service, NULL, GF_OK); + gf_service_disconnect_ack(vcap->service, NULL, GF_OK); return GF_OK; } @@ -453,10 +453,13 @@ GF_Err Freenect_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (!com->base.on_channel) return GF_NOT_SUPPORTED; switch (com->command_type) { - case GF_NET_CHAN_SET_PULL: return GF_NOT_SUPPORTED; - case GF_NET_CHAN_INTERACTIVE: return GF_OK; + case GF_NET_CHAN_SET_PULL: + return GF_NOT_SUPPORTED; + case GF_NET_CHAN_INTERACTIVE: + return GF_OK; /*since data is file-based, no padding is needed (decoder plugin will handle it itself)*/ - case GF_NET_CHAN_SET_PADDING: return GF_OK; + case GF_NET_CHAN_SET_PADDING: + return GF_OK; case GF_NET_CHAN_BUFFER: com->buffer.max = com->buffer.min = 500; return GF_OK; @@ -480,7 +483,8 @@ GF_Err Freenect_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } } return GF_OK; - case GF_NET_CHAN_CONFIG: return GF_OK; + case GF_NET_CHAN_CONFIG: + return GF_OK; case GF_NET_CHAN_GET_DSI: com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; @@ -495,21 +499,21 @@ GF_Err Freenect_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, cons { u32 ESID; FreenectIn *vcap = (FreenectIn *) plug->priv; - + sscanf(url, "ES_ID=%u", &ESID); if (ESID == 1) { vcap->depth_channel = channel; memset(&vcap->depth_sl_header, 0, sizeof(GF_SLHeader)); vcap->depth_sl_header.compositionTimeStampFlag = 1; - gf_term_on_connect(vcap->service, channel, GF_OK); + gf_service_connect_ack(vcap->service, channel, GF_OK); } else if (ESID == 2) { vcap->color_channel = channel; memset(&vcap->color_sl_header, 0, sizeof(GF_SLHeader)); vcap->color_sl_header.compositionTimeStampFlag = 1; - gf_term_on_connect(vcap->service, channel, GF_OK); + gf_service_connect_ack(vcap->service, channel, GF_OK); } else { /*TODO*/ - gf_term_on_connect(vcap->service, channel, GF_STREAM_NOT_FOUND); + gf_service_connect_ack(vcap->service, channel, GF_STREAM_NOT_FOUND); } return GF_OK; } @@ -523,7 +527,7 @@ GF_Err Freenect_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) else if (vcap->color_channel == channel) { vcap->color_channel = NULL; } - gf_term_on_disconnect(vcap->service, channel, GF_OK); + gf_service_disconnect_ack(vcap->service, channel, GF_OK); return GF_OK; } @@ -534,7 +538,7 @@ Bool Freenect_CanHandleURLInService(GF_InputService *plug, const char *url) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_NET_CLIENT_INTERFACE, @@ -566,7 +570,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) GF_SAFEALLOC(vcap, FreenectIn); plug->priv = vcap; return (GF_BaseInterface *)plug; - } + } return NULL; } diff --git a/modules/ft_font/ft_font.c b/modules/ft_font/ft_font.c index 54777a1..dbaa2c4 100644 --- a/modules/ft_font/ft_font.c +++ b/modules/ft_font/ft_font.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -43,7 +43,7 @@ #include FT_GLYPH_H #include FT_OUTLINE_H /*TrueType tables*/ -#include FT_TRUETYPE_TABLES_H +#include FT_TRUETYPE_TABLES_H typedef struct { @@ -92,7 +92,7 @@ static Bool isBestFontFor(const char * listOfFonts[], const char * currentBestFo u32 i; assert( fontName ); assert( listOfFonts ); - for (i = 0 ; listOfFonts[i]; i++){ + for (i = 0 ; listOfFonts[i]; i++) { const char * best = listOfFonts[i]; if (!stricmp(best, fontName)) return GF_TRUE; @@ -103,13 +103,13 @@ static Bool isBestFontFor(const char * listOfFonts[], const char * currentBestFo return currentBestFont == NULL; } -void setBestFont(const char * listOfFonts[], char ** currentBestFont, const char * fontName){ - if (isBestFontFor(listOfFonts, *currentBestFont, fontName)){ +void setBestFont(const char * listOfFonts[], char ** currentBestFont, const char * fontName) { + if (isBestFontFor(listOfFonts, *currentBestFont, fontName)) { if (*currentBestFont) gf_free(*currentBestFont); *currentBestFont = NULL; } - if (! (*currentBestFont)){ + if (! (*currentBestFont)) { *currentBestFont = gf_strdup(fontName); } } @@ -176,7 +176,7 @@ static Bool ft_enum_fonts(void *cbck, char *file_name, char *file_path) strcpy(szfont, face->family_name); strlwr(szfont); - if (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH){ + if (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) { setBestFont(BEST_FIXED_FONTS, &(ftpriv->font_fixed), face->family_name); } setBestFont(BEST_SERIF_FONTS, &(ftpriv->font_serif), face->family_name); @@ -257,8 +257,8 @@ static void ft_rescan_fonts(GF_FontReader *dr) if (!strchr(opt, '/') && !strchr(opt, '\\')) continue; if (!strcmp(key, "FontDirectory")) continue; - if (strstr(key, "Bold")) continue; - if (strstr(key, "Italic")) continue; + if (strstr(key, "Bold")) continue; + if (strstr(key, "Italic")) continue; strcpy(fkey, key); strcat(fkey, " Italic"); @@ -277,18 +277,18 @@ static void ft_rescan_fonts(GF_FontReader *dr) strcpy(fkey, key); strlwr(fkey); - + /*this font is suited for our case*/ if (isBestFontFor(BEST_FIXED_FONTS, ftpriv->font_fixed, key) || (!ftpriv->font_fixed && (strstr(fkey, "fixed") || strstr(fkey, "mono")) ) ) { if (ftpriv->font_fixed) gf_free(ftpriv->font_fixed); ftpriv->font_fixed = gf_strdup(key); } - + if (isBestFontFor(BEST_SANS_FONTS, ftpriv->font_sans, key) || (!ftpriv->font_sans && strstr(fkey, "sans")) ) { if (ftpriv->font_sans) gf_free(ftpriv->font_sans); ftpriv->font_sans = gf_strdup(key); } - + if (isBestFontFor(BEST_SERIF_FONTS, ftpriv->font_serif, key) || (!ftpriv->font_serif && strstr(fkey, "serif")) ) { if (ftpriv->font_serif) gf_free(ftpriv->font_serif); ftpriv->font_serif = gf_strdup(key); @@ -324,7 +324,7 @@ static GF_Err ft_init_font_engine(GF_FontReader *dr) } /*remove the final delimiter*/ - ftpriv->font_dir = gf_strdup(sOpt); + ftpriv->font_dir = gf_strdup(sOpt); while ( (ftpriv->font_dir[strlen(ftpriv->font_dir)-1] == '\n') || (ftpriv->font_dir[strlen(ftpriv->font_dir)-1] == '\r') ) ftpriv->font_dir[strlen(ftpriv->font_dir)-1] = 0; @@ -341,7 +341,7 @@ static GF_Err ft_init_font_engine(GF_FontReader *dr) } sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "FontEngine", "RescanFonts"); - if (!sOpt || !strcmp(sOpt, "yes") ) + if (!sOpt || !strcmp(sOpt, "yes") ) ft_rescan_fonts(dr); sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "FontEngine", "FontSerif"); @@ -349,12 +349,12 @@ static GF_Err ft_init_font_engine(GF_FontReader *dr) sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "FontEngine", "FontSans"); ftpriv->font_sans = gf_strdup(sOpt ? sOpt : ""); - + sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "FontEngine", "FontFixed"); ftpriv->font_fixed = gf_strdup(sOpt ? sOpt : ""); GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[FreeType] Init OK - font directory %s\n", ftpriv->font_dir)); - + return GF_OK; } @@ -403,10 +403,10 @@ static Bool ft_check_face(FT_Face font, const char *fontName, u32 styles) loc_styles = styles & GF_FONT_WEIGHT_MASK; if (loc_styles>=GF_FONT_WEIGHT_BOLD) styles = (styles & 0x00000007) | GF_FONT_WEIGHT_BOLD; - else + else styles = (styles & 0x00000007); - if (ft_style==styles) + if (ft_style==styles) return 1; return 0; } @@ -455,7 +455,7 @@ static GF_Err ft_set_font(GF_FontReader *dr, const char *OrigFontName, u32 style { int checkStyles = (styles & GF_FONT_WEIGHT_BOLD) | (styles & GF_FONT_ITALIC); - checkFont: +checkFont: strcpy(fname, fontName); if (styles & GF_FONT_WEIGHT_BOLD & checkStyles) strcat(fname, " Bold"); if (styles & GF_FONT_ITALIC & checkStyles) strcat(fname, " Italic"); @@ -471,10 +471,10 @@ static GF_Err ft_set_font(GF_FontReader *dr, const char *OrigFontName, u32 style ftpriv->active_face = face; return GF_OK; } - if (checkStyles){ + if (checkStyles) { /* If we tried font + bold + italic -> we will try font + [bold | italic] If we tried font + [bold | italic] -> we try font - */ + */ if (checkStyles == (GF_FONT_WEIGHT_BOLD | GF_FONT_ITALIC)) checkStyles = GF_FONT_WEIGHT_BOLD; else if (checkStyles == GF_FONT_WEIGHT_BOLD && (styles & GF_FONT_ITALIC)) @@ -635,7 +635,7 @@ static GF_Glyph *ft_load_glyph(GF_FontReader *dr, u32 glyph_name) ft_outl_funcs.cubic_to = ft_cubic_to; outl.path = glyph->path; outl.ftpriv = ftpriv; - + /*FreeType is marvelous and gives back the right advance on space char !!!*/ FT_Outline_Decompose(&outline->outline, &ft_outl_funcs, &outl); @@ -645,10 +645,10 @@ static GF_Glyph *ft_load_glyph(GF_FontReader *dr, u32 glyph_name) glyph->utf_name = glyph_name; glyph->horiz_advance = ftpriv->active_face->glyph->metrics.horiAdvance; glyph->vert_advance = ftpriv->active_face->glyph->metrics.vertAdvance; -/* - glyph->x = bbox.xMin; - glyph->y = bbox.yMax; -*/ + /* + glyph->x = bbox.xMin; + glyph->y = bbox.yMax; + */ glyph->width = ftpriv->active_face->glyph->metrics.width; glyph->height = ftpriv->active_face->glyph->metrics.height; FT_Done_Glyph((FT_Glyph) outline); @@ -671,7 +671,7 @@ GF_FontReader *ft_load() dr->udta = ftpriv; - + dr->init_font_engine = ft_init_font_engine; dr->shutdown_font_engine = ft_shutdown_font_engine; dr->set_font = ft_set_font; @@ -703,7 +703,7 @@ void ft_delete(GF_BaseInterface *ifce) #ifndef GPAC_STANDALONE_RENDER_2D GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_FONT_READER_INTERFACE, @@ -713,7 +713,7 @@ const u32 *QueryInterfaces() } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_FONT_READER_INTERFACE) return (GF_BaseInterface *)ft_load(); return NULL; diff --git a/modules/ft_font/ft_font.h b/modules/ft_font/ft_font.h index 4fc6531..68ef27f 100644 --- a/modules/ft_font/ft_font.h +++ b/modules/ft_font/ft_font.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/gapi/gapi.cpp b/modules/gapi/gapi.cpp index 03ac8e8..b2f8a57 100644 --- a/modules/gapi/gapi.cpp +++ b/modules/gapi/gapi.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -98,44 +98,103 @@ static void w32_translate_key(u32 wParam, u32 lParam, GF_EventKey *evt) evt->flags = 0; evt->hw_code = wParam; switch (wParam) { - case VK_BACK: evt->key_code = GF_KEY_BACKSPACE; break; - case VK_TAB: evt->key_code = GF_KEY_TAB; break; - case VK_CLEAR: evt->key_code = GF_KEY_CLEAR; break; - case VK_RETURN: evt->key_code = GF_KEY_ENTER; break; - case VK_SHIFT: evt->key_code = GF_KEY_SHIFT; break; - case VK_CONTROL: evt->key_code = GF_KEY_CONTROL; break; - case VK_MENU: evt->key_code = GF_KEY_ALT; break; - case VK_PAUSE: evt->key_code = GF_KEY_PAUSE; break; - case VK_CAPITAL: evt->key_code = GF_KEY_CAPSLOCK; break; - case VK_KANA: evt->key_code = GF_KEY_KANAMODE; break; - case VK_JUNJA: evt->key_code = GF_KEY_JUNJAMODE; break; - case VK_FINAL: evt->key_code = GF_KEY_FINALMODE; break; - case VK_KANJI: evt->key_code = GF_KEY_KANJIMODE; break; - case VK_ESCAPE: evt->key_code = GF_KEY_ESCAPE; break; - case VK_CONVERT: evt->key_code = GF_KEY_CONVERT; break; - case VK_SPACE: evt->key_code = GF_KEY_SPACE; break; - case VK_PRIOR: evt->key_code = GF_KEY_PAGEUP; break; - case VK_NEXT: evt->key_code = GF_KEY_PAGEDOWN; break; - case VK_END: evt->key_code = GF_KEY_END; break; - case VK_HOME: evt->key_code = GF_KEY_HOME; break; - case VK_LEFT: evt->key_code = GF_KEY_LEFT; break; - case VK_UP: evt->key_code = GF_KEY_UP; break; - case VK_RIGHT: evt->key_code = GF_KEY_RIGHT; break; - case VK_DOWN: evt->key_code = GF_KEY_DOWN; break; - case VK_SELECT: evt->key_code = GF_KEY_SELECT; break; - case VK_PRINT: + case VK_BACK: + evt->key_code = GF_KEY_BACKSPACE; + break; + case VK_TAB: + evt->key_code = GF_KEY_TAB; + break; + case VK_CLEAR: + evt->key_code = GF_KEY_CLEAR; + break; + case VK_RETURN: + evt->key_code = GF_KEY_ENTER; + break; + case VK_SHIFT: + evt->key_code = GF_KEY_SHIFT; + break; + case VK_CONTROL: + evt->key_code = GF_KEY_CONTROL; + break; + case VK_MENU: + evt->key_code = GF_KEY_ALT; + break; + case VK_PAUSE: + evt->key_code = GF_KEY_PAUSE; + break; + case VK_CAPITAL: + evt->key_code = GF_KEY_CAPSLOCK; + break; + case VK_KANA: + evt->key_code = GF_KEY_KANAMODE; + break; + case VK_JUNJA: + evt->key_code = GF_KEY_JUNJAMODE; + break; + case VK_FINAL: + evt->key_code = GF_KEY_FINALMODE; + break; + case VK_KANJI: + evt->key_code = GF_KEY_KANJIMODE; + break; + case VK_ESCAPE: + evt->key_code = GF_KEY_ESCAPE; + break; + case VK_CONVERT: + evt->key_code = GF_KEY_CONVERT; + break; + case VK_SPACE: + evt->key_code = GF_KEY_SPACE; + break; + case VK_PRIOR: + evt->key_code = GF_KEY_PAGEUP; + break; + case VK_NEXT: + evt->key_code = GF_KEY_PAGEDOWN; + break; + case VK_END: + evt->key_code = GF_KEY_END; + break; + case VK_HOME: + evt->key_code = GF_KEY_HOME; + break; + case VK_LEFT: + evt->key_code = GF_KEY_LEFT; + break; + case VK_UP: + evt->key_code = GF_KEY_UP; + break; + case VK_RIGHT: + evt->key_code = GF_KEY_RIGHT; + break; + case VK_DOWN: + evt->key_code = GF_KEY_DOWN; + break; + case VK_SELECT: + evt->key_code = GF_KEY_SELECT; + break; + case VK_PRINT: case VK_SNAPSHOT: - evt->key_code = GF_KEY_PRINTSCREEN; break; - case VK_EXECUTE: evt->key_code = GF_KEY_EXECUTE; break; - case VK_INSERT: evt->key_code = GF_KEY_INSERT; break; - case VK_DELETE: evt->key_code = GF_KEY_DEL; break; - case VK_HELP: evt->key_code = GF_KEY_HELP; break; - -/* case VK_LWIN: return ; - case VK_RWIN: return ; - case VK_APPS: return ; -*/ - case VK_NUMPAD0: + evt->key_code = GF_KEY_PRINTSCREEN; + break; + case VK_EXECUTE: + evt->key_code = GF_KEY_EXECUTE; + break; + case VK_INSERT: + evt->key_code = GF_KEY_INSERT; + break; + case VK_DELETE: + evt->key_code = GF_KEY_DEL; + break; + case VK_HELP: + evt->key_code = GF_KEY_HELP; + break; + + /* case VK_LWIN: return ; + case VK_RWIN: return ; + case VK_APPS: return ; + */ + case VK_NUMPAD0: evt->key_code = GF_KEY_0; evt->flags = GF_KEY_EXT_NUMPAD; break; @@ -175,11 +234,11 @@ static void w32_translate_key(u32 wParam, u32 lParam, GF_EventKey *evt) evt->key_code = GF_KEY_9; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_MULTIPLY: + case VK_MULTIPLY: evt->key_code = GF_KEY_STAR; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_ADD: + case VK_ADD: evt->key_code = GF_KEY_PLUS; evt->flags = GF_KEY_EXT_NUMPAD; break; @@ -199,43 +258,95 @@ static void w32_translate_key(u32 wParam, u32 lParam, GF_EventKey *evt) evt->key_code = GF_KEY_SLASH; evt->flags = GF_KEY_EXT_NUMPAD; break; - case VK_F1: evt->key_code = GF_KEY_F1; break; - case VK_F2: evt->key_code = GF_KEY_F2; break; - case VK_F3: evt->key_code = GF_KEY_F3; break; - case VK_F4: evt->key_code = GF_KEY_F4; break; - case VK_F5: evt->key_code = GF_KEY_F5; break; + case VK_F1: + evt->key_code = GF_KEY_F1; + break; + case VK_F2: + evt->key_code = GF_KEY_F2; + break; + case VK_F3: + evt->key_code = GF_KEY_F3; + break; + case VK_F4: + evt->key_code = GF_KEY_F4; + break; + case VK_F5: + evt->key_code = GF_KEY_F5; + break; // case VK_F6: evt->key_code = GF_KEY_F6; break; // case VK_F7: evt->key_code = GF_KEY_F7; break; - case VK_F6: evt->key_code = GF_KEY_VOLUMEUP; break; - case VK_F7: evt->key_code = GF_KEY_VOLUMEDOWN; break; - case VK_F8: evt->key_code = GF_KEY_F8; break; - - case VK_F9: evt->key_code = GF_KEY_F9; break; - case VK_F10: evt->key_code = GF_KEY_F10; break; - case VK_F11: evt->key_code = GF_KEY_F11; break; - case VK_F12: evt->key_code = GF_KEY_F12; break; - case VK_F13: evt->key_code = GF_KEY_F13; break; - case VK_F14: evt->key_code = GF_KEY_F14; break; - case VK_F15: evt->key_code = GF_KEY_F15; break; - case VK_F16: evt->key_code = GF_KEY_F16; break; - case VK_F17: evt->key_code = GF_KEY_F17; break; - case VK_F18: evt->key_code = GF_KEY_F18; break; - case VK_F19: evt->key_code = GF_KEY_F19; break; - case VK_F20: evt->key_code = GF_KEY_F20; break; - case VK_F21: evt->key_code = GF_KEY_F21; break; - case VK_F22: evt->key_code = GF_KEY_F22; break; - case VK_F23: evt->key_code = GF_KEY_F23; break; - case VK_F24: evt->key_code = GF_KEY_F24; break; - - case VK_NUMLOCK: evt->key_code = GF_KEY_NUMLOCK; break; - case VK_SCROLL: evt->key_code = GF_KEY_SCROLL; break; + case VK_F6: + evt->key_code = GF_KEY_VOLUMEUP; + break; + case VK_F7: + evt->key_code = GF_KEY_VOLUMEDOWN; + break; + case VK_F8: + evt->key_code = GF_KEY_F8; + break; -/* - * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. - * Used only as parameters to GetAsyncKeyState() and GetKeyState(). - * No other API or message will distinguish left and right keys in this way. - */ - case VK_LSHIFT: + case VK_F9: + evt->key_code = GF_KEY_F9; + break; + case VK_F10: + evt->key_code = GF_KEY_F10; + break; + case VK_F11: + evt->key_code = GF_KEY_F11; + break; + case VK_F12: + evt->key_code = GF_KEY_F12; + break; + case VK_F13: + evt->key_code = GF_KEY_F13; + break; + case VK_F14: + evt->key_code = GF_KEY_F14; + break; + case VK_F15: + evt->key_code = GF_KEY_F15; + break; + case VK_F16: + evt->key_code = GF_KEY_F16; + break; + case VK_F17: + evt->key_code = GF_KEY_F17; + break; + case VK_F18: + evt->key_code = GF_KEY_F18; + break; + case VK_F19: + evt->key_code = GF_KEY_F19; + break; + case VK_F20: + evt->key_code = GF_KEY_F20; + break; + case VK_F21: + evt->key_code = GF_KEY_F21; + break; + case VK_F22: + evt->key_code = GF_KEY_F22; + break; + case VK_F23: + evt->key_code = GF_KEY_F23; + break; + case VK_F24: + evt->key_code = GF_KEY_F24; + break; + + case VK_NUMLOCK: + evt->key_code = GF_KEY_NUMLOCK; + break; + case VK_SCROLL: + evt->key_code = GF_KEY_SCROLL; + break; + + /* + * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. + * Used only as parameters to GetAsyncKeyState() and GetKeyState(). + * No other API or message will distinguish left and right keys in this way. + */ + case VK_LSHIFT: evt->key_code = GF_KEY_SHIFT; evt->flags = GF_KEY_EXT_LEFT; break; @@ -261,22 +372,38 @@ static void w32_translate_key(u32 wParam, u32 lParam, GF_EventKey *evt) break; #if(WINVER >= 0x0400) - case VK_PROCESSKEY: evt->key_code = GF_KEY_PROCESS; break; + case VK_PROCESSKEY: + evt->key_code = GF_KEY_PROCESS; + break; #endif /* WINVER >= 0x0400 */ - case VK_ATTN: evt->key_code = GF_KEY_ATTN; break; - case VK_CRSEL: evt->key_code = GF_KEY_CRSEL; break; - case VK_EXSEL: evt->key_code = GF_KEY_EXSEL; break; - case VK_EREOF: evt->key_code = GF_KEY_ERASEEOF; break; - case VK_PLAY: evt->key_code = GF_KEY_PLAY; break; - case VK_ZOOM: evt->key_code = GF_KEY_ZOOM; break; + case VK_ATTN: + evt->key_code = GF_KEY_ATTN; + break; + case VK_CRSEL: + evt->key_code = GF_KEY_CRSEL; + break; + case VK_EXSEL: + evt->key_code = GF_KEY_EXSEL; + break; + case VK_EREOF: + evt->key_code = GF_KEY_ERASEEOF; + break; + case VK_PLAY: + evt->key_code = GF_KEY_PLAY; + break; + case VK_ZOOM: + evt->key_code = GF_KEY_ZOOM; + break; //case VK_NONAME: evt->key_code = GF_KEY_NONAME; break; //case VK_PA1: evt->key_code = GF_KEY_PA1; break; - case VK_OEM_CLEAR: evt->key_code = GF_KEY_CLEAR; break; + case VK_OEM_CLEAR: + evt->key_code = GF_KEY_CLEAR; + break; /*thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ - default: + default: if ((wParam>=0x30) && (wParam<=0x39)) evt->key_code = GF_KEY_0 + wParam-0x30; else if ((wParam>=0x41) && (wParam<=0x5A)) evt->key_code = GF_KEY_A + wParam-0x41; else { @@ -288,17 +415,17 @@ static void w32_translate_key(u32 wParam, u32 lParam, GF_EventKey *evt) else if (res==ctx->keys.vkDown) evt->key_code = landscape ? GF_KEY_LEFT : GF_KEY_DOWN; else if (res==ctx->keys.vkUp) evt->key_code = landscape ? GF_KEY_RIGHT : GF_KEY_UP; else if (res==ctx->keys.vkStart) evt->key_code = GF_KEY_ENTER; - else if (res==ctx->keys.vkA) + else if (res==ctx->keys.vkA) evt->key_code = GF_KEY_MEDIAPREVIOUSTRACK; - else if (res==ctx->keys.vkB) + else if (res==ctx->keys.vkB) evt->key_code = GF_KEY_MEDIANEXTTRACK; - else if (res==ctx->keys.vkC) + else if (res==ctx->keys.vkC) evt->key_code = GF_KEY_SHIFT; - else if (res==0xc1) + else if (res==0xc1) evt->key_code = GF_KEY_ALT; - else if (res==0xc2) + else if (res==0xc2) evt->key_code = GF_KEY_CONTROL; - else if (res==0xc5) + else if (res==0xc5) evt->key_code = GF_KEY_VOLUMEDOWN; else { evt->key_code = GF_KEY_UNIDENTIFIED; @@ -322,7 +449,7 @@ LRESULT APIENTRY GAPI_WindowProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) evt.size.height = HIWORD(lParam); the_video_driver->on_event(the_video_driver->evt_cbk_hdl, &evt); } - break; + break; case WM_CLOSE: memset(&evt, 0, sizeof(GF_Event)); evt.type = GF_EVENT_QUIT; @@ -339,7 +466,7 @@ LRESULT APIENTRY GAPI_WindowProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) ctx->orig_wnd_proc = 0L; } } - break; + break; case WM_ERASEBKGND: evt.type = GF_EVENT_REFRESH; @@ -347,15 +474,15 @@ LRESULT APIENTRY GAPI_WindowProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) break; case WM_PAINT: #ifndef DIRECT_BITBLT - { + { GAPIPriv *gctx = (GAPIPriv *)the_video_driver->opaque; if (gctx->gx_mode || !gctx->bitmap) break; HDC dc = GetDC(gctx->hWnd); BitBlt(dc, gctx->dst_blt.x, gctx->dst_blt.y, gctx->bb_width, gctx->bb_height, gctx->hdcBitmap, 0, 0, SRCCOPY); ReleaseDC(gctx->hWnd, dc); - } + } #endif - break; + break; case WM_MOUSEMOVE: GAPI_GetCoordinates(lParam, &evt); @@ -406,7 +533,7 @@ void GAPI_WindowThread(void *par) wc.hbrBackground = (HBRUSH)GetStockObject (BLACK_BRUSH); wc.lpszClassName = _T("GPAC GAPI Output"); RegisterClass (&wc); - + ctx->hWnd = CreateWindow(_T("GPAC GAPI Output"), NULL, WS_POPUP, 0, 0, 120, 100, NULL, NULL, wc.hInstance, NULL); if (ctx->hWnd == NULL) { ctx->ThreadID = 0; @@ -529,41 +656,47 @@ GF_Err GAPI_Clear(GF_VideoOutput *dr, u32 color) static void createPixmap(GAPIPriv *ctx, u32 pix_type) { - const size_t bmiSize = sizeof(BITMAPINFO) + 256U*sizeof(RGBQUAD); - BITMAPINFO* bmi; - DWORD* p; + const size_t bmiSize = sizeof(BITMAPINFO) + 256U*sizeof(RGBQUAD); + BITMAPINFO* bmi; + DWORD* p; u32 bpel = 0; if (ctx->bmi) gf_free(ctx->bmi); - bmi = (BITMAPINFO*)gf_malloc(bmiSize); - memset(bmi, 0, bmiSize); + bmi = (BITMAPINFO*)gf_malloc(bmiSize); + memset(bmi, 0, bmiSize); - bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi->bmiHeader.biWidth = ctx->bb_width; - bmi->bmiHeader.biHeight = -1 * (s32) ctx->bb_height; /*top-down image*/ - bmi->bmiHeader.biPlanes = (short)1; - bmi->bmiHeader.biBitCount = (unsigned int) ctx->bits_per_pixel; - bmi->bmiHeader.biCompression = BI_BITFIELDS; - bmi->bmiHeader.biClrUsed = 3; + bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi->bmiHeader.biWidth = ctx->bb_width; + bmi->bmiHeader.biHeight = -1 * (s32) ctx->bb_height; /*top-down image*/ + bmi->bmiHeader.biPlanes = (short)1; + bmi->bmiHeader.biBitCount = (unsigned int) ctx->bits_per_pixel; + bmi->bmiHeader.biCompression = BI_BITFIELDS; + bmi->bmiHeader.biClrUsed = 3; - p = (DWORD*)bmi->bmiColors; + p = (DWORD*)bmi->bmiColors; switch (ctx->pixel_format) { case GF_PIXEL_RGB_555: - p[0] = 0x00007c00; p[1] = 0x000003e0; p[2] = 0x0000001f; + p[0] = 0x00007c00; + p[1] = 0x000003e0; + p[2] = 0x0000001f; bpel = 16; break; case GF_PIXEL_RGB_565: - p[0] = 0x0000f800; p[1] = 0x000007e0; p[2] = 0x0000001f; + p[0] = 0x0000f800; + p[1] = 0x000007e0; + p[2] = 0x0000001f; bpel = 16; break; case GF_PIXEL_RGB_24: - p[0] = 0x00ff0000; p[1] = 0x0000ff00; p[2] = 0x000000ff; + p[0] = 0x00ff0000; + p[1] = 0x0000ff00; + p[2] = 0x000000ff; bpel = 24; break; } ctx->hdc = GetDC(NULL/*ctx->hWnd*/); - + if (pix_type==2) { #ifdef GPAC_USE_OGL_ES ctx->gl_bitmap = CreateDIBSection(ctx->hdc, bmi, DIB_RGB_COLORS, (void **) &ctx->gl_bits, NULL, 0); @@ -576,7 +709,7 @@ static void createPixmap(GAPIPriv *ctx, u32 pix_type) ctx->hdcBitmap = CreateCompatibleDC(ctx->hdc); ctx->bitmap = CreateDIBSection(ctx->hdc, bmi, DIB_RGB_COLORS, (void **) &ctx->backbuffer, NULL, 0); ctx->old_bitmap = (HBITMAP) SelectObject(ctx->hdcBitmap, ctx->bitmap); - + /*watchout - win32 always create DWORD align memory, so align our pitch*/ while ((ctx->bb_pitch % 4) != 0) ctx->bb_pitch ++; } @@ -601,16 +734,16 @@ void GAPI_ReleaseOGL_ES(GAPIPriv *ctx, Bool offscreen_only) if (ctx->egldpy) eglTerminate(ctx->egldpy); ctx->egldpy = 0; } - if (ctx->gl_bitmap) DeleteObject(ctx->gl_bitmap); + if (ctx->gl_bitmap) DeleteObject(ctx->gl_bitmap); ctx->gl_bitmap = NULL; if (offscreen_only) return; - if (ctx->bitmap) DeleteObject(ctx->bitmap); + if (ctx->bitmap) DeleteObject(ctx->bitmap); ctx->bitmap = NULL; } -GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) +GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) { EGLint n, maj, min; u32 i; @@ -620,12 +753,16 @@ GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) const char *opt; i=0; - atts[i++] = EGL_RED_SIZE; atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : 5; - atts[i++] = EGL_GREEN_SIZE; atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : (gctx->pixel_format==GF_PIXEL_RGB_565) ? 6 : 5; - atts[i++] = EGL_BLUE_SIZE; atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : 5; + atts[i++] = EGL_RED_SIZE; + atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : 5; + atts[i++] = EGL_GREEN_SIZE; + atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : (gctx->pixel_format==GF_PIXEL_RGB_565) ? 6 : 5; + atts[i++] = EGL_BLUE_SIZE; + atts[i++] = (gctx->pixel_format==GF_PIXEL_RGB_24) ? 8 : 5; opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsDepth"); - atts[i++] = EGL_DEPTH_SIZE; atts[i++] = opt ? atoi(opt) : 16; - atts[i++] = EGL_SURFACE_TYPE; + atts[i++] = EGL_DEPTH_SIZE; + atts[i++] = opt ? atoi(opt) : 16; + atts[i++] = EGL_SURFACE_TYPE; #ifdef GLES_NO_PIXMAP atts[i++] = EGL_WINDOW_BIT; @@ -633,8 +770,10 @@ GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) atts[i++] = EGL_PIXMAP_BIT; // atts[i++] = gctx->fullscreen ? EGL_WINDOW_BIT : EGL_PIXMAP_BIT; #endif - atts[i++] = EGL_ALPHA_SIZE; atts[i++] = EGL_DONT_CARE; - atts[i++] = EGL_STENCIL_SIZE; atts[i++] = EGL_DONT_CARE; + atts[i++] = EGL_ALPHA_SIZE; + atts[i++] = EGL_DONT_CARE; + atts[i++] = EGL_STENCIL_SIZE; + atts[i++] = EGL_DONT_CARE; atts[i++] = EGL_NONE; /*whenever window is resized we must reinit OGL-ES*/ @@ -669,9 +808,9 @@ GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) if (gctx->fullscreen #ifdef GLES_NO_PIXMAP - || 1 + || 1 #endif - ) { + ) { gctx->surface = eglCreateWindowSurface(gctx->egldpy, gctx->eglconfig, gctx->hWnd, 0); } else { gctx->surface = eglCreatePixmapSurface(gctx->egldpy, gctx->eglconfig, gctx->bitmap, 0); @@ -679,16 +818,16 @@ GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) if (!gctx->surface) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[GAPI] Cannot create OpenGL surface - error %d\n", eglGetError())); - return GF_IO_ERR; + return GF_IO_ERR; } gctx->eglctx = eglCreateContext(gctx->egldpy, gctx->eglconfig, NULL, NULL); if (!gctx->eglctx) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[GAPI] Cannot create OpenGL context\n")); eglDestroySurface(gctx->egldpy, gctx->surface); gctx->surface = 0L; - return GF_IO_ERR; + return GF_IO_ERR; } - if (!eglMakeCurrent(gctx->egldpy, gctx->surface, gctx->surface, gctx->eglctx)) { + if (!eglMakeCurrent(gctx->egldpy, gctx->surface, gctx->surface, gctx->eglctx)) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[GAPI] Cannot bind OpenGL context\n")); eglDestroyContext(gctx->egldpy, gctx->eglctx); gctx->eglctx = 0L; @@ -700,13 +839,13 @@ GF_Err GAPI_SetupOGL_ES(GF_VideoOutput *dr) memset(&evt, 0, sizeof(GF_Event)); evt.type = GF_EVENT_VIDEO_SETUP; evt.hw_reset = 1; - dr->on_event(dr->evt_cbk_hdl, &evt); + dr->on_event(dr->evt_cbk_hdl, &evt); return GF_OK; } -GF_Err GAPI_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 height) +GF_Err GAPI_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 height) { int atts[15]; const char *opt; @@ -726,15 +865,22 @@ GF_Err GAPI_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 height) gctx->egldpy = NULL; return GF_IO_ERR; } - atts[0] = EGL_RED_SIZE; atts[1] = 8; - atts[2] = EGL_GREEN_SIZE; atts[3] = 8; - atts[4] = EGL_BLUE_SIZE; atts[5] = 8; - atts[6] = EGL_ALPHA_SIZE; atts[7] = (dr->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA) ? 8 : EGL_DONT_CARE; + atts[0] = EGL_RED_SIZE; + atts[1] = 8; + atts[2] = EGL_GREEN_SIZE; + atts[3] = 8; + atts[4] = EGL_BLUE_SIZE; + atts[5] = 8; + atts[6] = EGL_ALPHA_SIZE; + atts[7] = (dr->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA) ? 8 : EGL_DONT_CARE; opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "GLNbBitsDepth"); - atts[8] = EGL_DEPTH_SIZE; atts[9] = opt ? atoi(opt) : 16; + atts[8] = EGL_DEPTH_SIZE; + atts[9] = opt ? atoi(opt) : 16; - atts[10] = EGL_STENCIL_SIZE; atts[11] = EGL_DONT_CARE; - atts[12] = EGL_SURFACE_TYPE; atts[13] = gctx->use_pbuffer ? EGL_PBUFFER_BIT : EGL_PIXMAP_BIT; + atts[10] = EGL_STENCIL_SIZE; + atts[11] = EGL_DONT_CARE; + atts[12] = EGL_SURFACE_TYPE; + atts[13] = gctx->use_pbuffer ? EGL_PBUFFER_BIT : EGL_PIXMAP_BIT; atts[14] = EGL_NONE; eglGetConfigs(gctx->egldpy, NULL, 0, &n); @@ -745,23 +891,25 @@ GF_Err GAPI_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 height) if (!gctx->use_pbuffer) { gctx->surface = eglCreatePixmapSurface(gctx->egldpy, gctx->eglconfig, gctx->gl_bitmap, 0); } else { - atts[0] = EGL_WIDTH; atts[1] = width; - atts[2] = EGL_HEIGHT; atts[3] = height; + atts[0] = EGL_WIDTH; + atts[1] = width; + atts[2] = EGL_HEIGHT; + atts[3] = height; atts[4] = EGL_NONE; gctx->surface = eglCreatePbufferSurface(gctx->egldpy, gctx->eglconfig, atts); } if (!gctx->surface) { - return GF_IO_ERR; + return GF_IO_ERR; } gctx->eglctx = eglCreateContext(gctx->egldpy, gctx->eglconfig, NULL, NULL); if (!gctx->eglctx) { eglDestroySurface(gctx->egldpy, gctx->surface); gctx->surface = 0L; - return GF_IO_ERR; + return GF_IO_ERR; } - if (!eglMakeCurrent(gctx->egldpy, gctx->surface, gctx->surface, gctx->eglctx)) { + if (!eglMakeCurrent(gctx->egldpy, gctx->surface, gctx->surface, gctx->eglctx)) { eglDestroyContext(gctx->egldpy, gctx->eglctx); gctx->eglctx = 0L; eglDestroySurface(gctx->egldpy, gctx->surface); @@ -782,8 +930,8 @@ void GAPI_ReleaseObjects(GAPIPriv *ctx) if (ctx->output_3d_type) GAPI_ReleaseOGL_ES(ctx, GF_FALSE); else #endif - if (ctx->bitmap) DeleteObject(ctx->bitmap); - else if (ctx->backbuffer) gf_free(ctx->backbuffer); + if (ctx->bitmap) DeleteObject(ctx->bitmap); + else if (ctx->backbuffer) gf_free(ctx->backbuffer); ctx->backbuffer = NULL; ctx->bitmap = NULL; @@ -803,36 +951,36 @@ GF_Err GAPI_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 noo RECT rc; GAPICTX(dr); gctx->hWnd = (HWND) os_handle; - + /*get keys in both 2D and 3D modes*/ gctx->keys = GXGetDefaultKeys(GX_NORMALKEYS); #if 0 /*FIXME - not supported in rasterizer*/ - if (gx.ffFormat & kfDirect444) { + if (gx.ffFormat & kfDirect444) { gctx->pixel_format = GF_PIXEL_RGB_444; gctx->BPP = 2; gctx->bitsPP = 12; - } - else -#endif - if (gx.ffFormat & kfDirect555) { - gctx->pixel_format = GF_PIXEL_RGB_555; - gctx->BPP = 2; - gctx->bits_per_pixel = 15; - } - else if (gx.ffFormat & kfDirect565) { - gctx->pixel_format = GF_PIXEL_RGB_565; - gctx->BPP = 2; - gctx->bits_per_pixel = 16; - } - else if (gx.ffFormat & kfDirect888) { - gctx->pixel_format = GF_PIXEL_RGB_24; - gctx->BPP = 3; - gctx->bits_per_pixel = 24; - } else { - return GF_NOT_SUPPORTED; } + else +#endif + if (gx.ffFormat & kfDirect555) { + gctx->pixel_format = GF_PIXEL_RGB_555; + gctx->BPP = 2; + gctx->bits_per_pixel = 15; + } + else if (gx.ffFormat & kfDirect565) { + gctx->pixel_format = GF_PIXEL_RGB_565; + gctx->BPP = 2; + gctx->bits_per_pixel = 16; + } + else if (gx.ffFormat & kfDirect888) { + gctx->pixel_format = GF_PIXEL_RGB_24; + gctx->BPP = 3; + gctx->bits_per_pixel = 24; + } else { + return GF_NOT_SUPPORTED; + } GAPI_SetupWindow(dr); if (!gctx->hWnd) return GF_IO_ERR; @@ -842,7 +990,7 @@ GF_Err GAPI_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 noo MessageBox(NULL, _T("Cannot open display"), _T("GAPI Error"), MB_OK); return GF_IO_ERR; } - GetClientRect(gctx->hWnd, &rc); + GetClientRect(gctx->hWnd, &rc); gctx->backup_w = rc.right - rc.left; gctx->backup_h = rc.bottom - rc.top; @@ -948,7 +1096,7 @@ static GF_Err GAPI_FlipBackBuffer(GF_VideoOutput *dr) ptr = (unsigned char *) gctx->raw_ptr; } if (!ptr) return GF_IO_ERR; - + src.video_buffer = gctx->backbuffer; src.width = gctx->bb_width; src.height = gctx->bb_height; @@ -977,7 +1125,7 @@ static GF_Err GAPI_FlipBackBuffer(GF_VideoOutput *dr) } /*apply x/y offset*/ - if (!gctx->fullscreen) + if (!gctx->fullscreen) dst.video_buffer += gctx->dst_blt.x * gctx->x_pitch + gctx->y_pitch * gctx->dst_blt.y; if (gctx->contiguous_mem) { @@ -1012,7 +1160,7 @@ static GF_Err GAPI_Flush(GF_VideoOutput *dr, GF_Window *dest) if (!gctx) return GF_BAD_PARAM; gf_mx_p(gctx->mx); - + #ifdef GPAC_USE_OGL_ES if (gctx->output_3d_type==1) { #ifndef GLES_NO_PIXMAP @@ -1025,7 +1173,7 @@ static GF_Err GAPI_Flush(GF_VideoOutput *dr, GF_Window *dest) eglSwapBuffers(gctx->egldpy, gctx->surface); #ifndef GLES_NO_PIXMAP } else { - InvalidateRect(gctx->hWnd, NULL, gctx->erase_dest); + InvalidateRect(gctx->hWnd, NULL, gctx->erase_dest); gctx->erase_dest = GF_FALSE; } #endif @@ -1069,8 +1217,10 @@ u32 get_sys_col(int idx) { u32 res; DWORD val = GetSysColor(idx); - res = (val)&0xFF; res<<=8; - res |= (val>>8)&0xFF; res<<=8; + res = (val)&0xFF; + res<<=8; + res |= (val>>8)&0xFF; + res<<=8; res |= (val>>16)&0xFF; return res; } @@ -1146,7 +1296,7 @@ static GF_Err GAPI_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) #define ESC_QUERYESCSUPPORT 8 #define GETGXINFO 0x00020000 -typedef struct GXDeviceInfo +typedef struct GXDeviceInfo { long Version; //00 void * pvFrameBuffer; //04 @@ -1195,21 +1345,21 @@ static Bool check_resolution_switch(GF_VideoOutput *dr, u32 width, u32 height) } #ifndef GETRAWFRAMEBUFFER - #define GETRAWFRAMEBUFFER 0x00020001 - typedef struct _RawFrameBufferInfo - { - WORD wFormat; - WORD wBPP; - VOID *pFramePointer; - int cxStride; - int cyStride; - int cxPixels; - int cyPixels; - } RawFrameBufferInfo; - - #define FORMAT_565 1 - #define FORMAT_555 2 - #define FORMAT_OTHER 3 +#define GETRAWFRAMEBUFFER 0x00020001 +typedef struct _RawFrameBufferInfo +{ + WORD wFormat; + WORD wBPP; + VOID *pFramePointer; + int cxStride; + int cyStride; + int cxPixels; + int cyPixels; +} RawFrameBufferInfo; + +#define FORMAT_565 1 +#define FORMAT_555 2 +#define FORMAT_OTHER 3 #endif static GF_Err gapi_get_raw_fb(GF_VideoOutput *dr) @@ -1236,8 +1386,8 @@ static GF_Err gapi_get_raw_fb(GF_VideoOutput *dr) // avoid VGA devices (or QVGA smartphones emulating 176x220) if (GXInfo.cbStride>0 && !(GXInfo.ffFormat & kfLandscape) && - ((DCWidth == GXInfo.cxWidth && DCHeight == GXInfo.cyHeight) || - (DCWidth == GXInfo.cyHeight && DCHeight == GXInfo.cxWidth))) + ((DCWidth == GXInfo.cxWidth && DCHeight == GXInfo.cyHeight) || + (DCWidth == GXInfo.cyHeight && DCHeight == GXInfo.cxWidth))) { Bool Detect = GF_FALSE; int* p = (int*)GXInfo.pvFrameBuffer; @@ -1270,7 +1420,7 @@ static GF_Err gapi_get_raw_fb(GF_VideoOutput *dr) if (abs(Info.cyStride) < abs(Info.cxStride)) { if (abs(Info.cxStride)*8 < Info.cyPixels*Info.wBPP && - abs(Info.cxStride)*8 >= Info.cxPixels*Info.wBPP) { //swapped resolution + abs(Info.cxStride)*8 >= Info.cxPixels*Info.wBPP) { //swapped resolution tmp = Info.cxPixels; Info.cxPixels = Info.cyPixels; Info.cyPixels = tmp; @@ -1279,7 +1429,7 @@ static GF_Err gapi_get_raw_fb(GF_VideoOutput *dr) else { if (abs(Info.cyStride)*8 < Info.cxPixels*Info.wBPP && - abs(Info.cyStride)*8 >= Info.cyPixels*Info.wBPP) {//swapped resolution + abs(Info.cyStride)*8 >= Info.cyPixels*Info.wBPP) {//swapped resolution tmp = Info.cxPixels; Info.cxPixels = Info.cyPixels; Info.cyPixels = tmp; @@ -1288,12 +1438,12 @@ static GF_Err gapi_get_raw_fb(GF_VideoOutput *dr) gctx->raw_ptr = (unsigned char *)Info.pFramePointer; - if (Info.cxStride<0) + if (Info.cxStride<0) gctx->raw_ptr += (Info.cxStride * (Info.cxPixels-1)); - if (Info.cyStride<0) + if (Info.cyStride<0) gctx->raw_ptr += (Info.cyStride * (Info.cyPixels-1)); - if (check_resolution_switch(dr, Info.cxPixels, Info.cyPixels)) + if (check_resolution_switch(dr, Info.cxPixels, Info.cyPixels)) return GF_EOS; return GF_OK; @@ -1386,7 +1536,7 @@ static void GAPI_AdjustLandscape(GAPIPriv *gctx, GF_VideoSurface *dst, s32 x_pit if (x_pitch>0) { dst->video_buffer += dst->height * y_pitch; dst->pitch_y = x_pitch; - } + } /*start of frame-buffer is top-right corner*/ else { dst->video_buffer += dst->height * y_pitch + dst->width * x_pitch; @@ -1398,7 +1548,7 @@ static void GAPI_AdjustLandscape(GAPIPriv *gctx, GF_VideoSurface *dst, s32 x_pit if (x_pitch>0) { dst->video_buffer += y_pitch - x_pitch; dst->pitch_y = -x_pitch; - } + } /*start of frame-buffer is top-right corner*/ else { dst->video_buffer += dst->height * y_pitch + dst->width * x_pitch; @@ -1410,7 +1560,7 @@ static void GAPI_AdjustLandscape(GAPIPriv *gctx, GF_VideoSurface *dst, s32 x_pit /*start of frame-buffer is bottom-left corner*/ if (x_pitch>0) { dst->pitch_y = x_pitch; - } + } /*start of frame-buffer is bottom-right corner*/ else { dst->video_buffer += dst->width * x_pitch; @@ -1437,7 +1587,7 @@ static GF_Err GAPI_LockBackBuffer(GF_VideoOutput *dr, GF_VideoSurface *vi, Bool vi->pitch_x = gctx->x_pitch; vi->pitch_y = gctx->y_pitch; - if (landscape) + if (landscape) GAPI_AdjustLandscape(gctx, vi, gctx->x_pitch, gctx->y_pitch); } return GF_OK; @@ -1488,7 +1638,7 @@ extern "C" { /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, diff --git a/modules/gapi/gapi.h b/modules/gapi/gapi.h index 565ccac..2934a20 100644 --- a/modules/gapi/gapi.h +++ b/modules/gapi/gapi.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -79,19 +79,19 @@ typedef struct u32 off_x, off_y; HBITMAP bitmap, old_bitmap; - DWORD * bits; + DWORD * bits; HDC hdcBitmap, hdc; BITMAPINFO* bmi; #ifdef GPAC_USE_OGL_ES u32 output_3d_type; - EGLDisplay egldpy; - EGLSurface surface; - EGLConfig eglconfig; - EGLContext eglctx; + EGLDisplay egldpy; + EGLSurface surface; + EGLConfig eglconfig; + EGLContext eglctx; HBITMAP gl_bitmap; - DWORD *gl_bits; + DWORD *gl_bits; HWND gl_hwnd; Bool use_pbuffer; #endif @@ -105,4 +105,4 @@ GF_Err GAPI_SetupOGL_ES_Offscreen(GF_VideoOutput *dr, u32 width, u32 height) ; } #endif -#endif +#endif diff --git a/modules/gdip_raster/gdip_font.cpp b/modules/gdip_raster/gdip_font.cpp index 6b71612..7437342 100644 --- a/modules/gdip_raster/gdip_font.cpp +++ b/modules/gdip_raster/gdip_font.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -53,7 +53,7 @@ GF_Err gdip_shutdown_font_engine(GF_FontReader *dr) if (ctx->font) GdipDeleteFontFamily(ctx->font); ctx->font = NULL; - + /*nothing to do*/ return GF_OK; } @@ -136,7 +136,7 @@ static GF_Err gdip_get_text_size(GF_FontReader *dr, const unsigned short *string GdipDeleteStringFormat(fmt); GdipDeletePath(path_tmp); - + return GF_OK; } @@ -155,8 +155,8 @@ static GF_Err gdip_set_font(GF_FontReader *dr, const char *fontName, u32 styles) else if (!stricmp(fontName, "SERIF")) fontName = ctx->font_serif; else if (!stricmp(fontName, "TYPEWRITER") || !stricmp(fontName, "monospace")) fontName = ctx->font_fixed; - MultiByteToWideChar(CP_ACP, 0, fontName, (u32)strlen(fontName)+1, - wcFontName, sizeof(wcFontName)/sizeof(wcFontName[0]) ); + MultiByteToWideChar(CP_ACP, 0, fontName, (u32)strlen(fontName)+1, + wcFontName, sizeof(wcFontName)/sizeof(wcFontName[0]) ); GdipCreateFontFamilyFromName(wcFontName, NULL, &ctx->font); @@ -187,7 +187,8 @@ static GF_Err gdip_get_font_info(GF_FontReader *dr, char **font_name, u32 *em_si ctx->ascent = (Float) val; *ascent = (s32) val; GdipGetCellDescent(ctx->font, ctx->font_style, &val); - *descent = (s32) val; *descent *= -1; + *descent = (s32) val; + *descent *= -1; ctx->descent = -1 * (Float) val; *underline = *descent / 2; GdipGetLineSpacing(ctx->font, ctx->font_style, &val); @@ -242,7 +243,7 @@ static GF_Glyph *gdip_load_glyph(GF_FontReader *dr, u32 glyph_name) est_advance_h = ctx->whitespace_width; } else { /*to compute first glyph alignment (say 'x', we figure out its bounding full box by using the '_' char as wrapper (eg, "_x_") - then the bounding box starting from xMin of the glyph ('x_'). The difference between both will give us a good approx + then the bounding box starting from xMin of the glyph ('x_'). The difference between both will give us a good approx of the glyph alignment*/ str[0] = glyph_name; str[1] = (unsigned short) '_'; @@ -251,7 +252,7 @@ static GF_Glyph *gdip_load_glyph(GF_FontReader *dr, u32 glyph_name) GdipGetPathWorldBounds(path_tmp, &rc, NULL, NULL); est_advance_h = rc.Width - ctx->underscore_width; } - + GdipResetPath(path_tmp); str[0] = glyph_name; @@ -284,7 +285,7 @@ static GF_Glyph *gdip_load_glyph(GF_FontReader *dr, u32 glyph_name) for (i=0; ipath, FLT2FIX(pts[i].X), FLT2FIX(pts[i].Y)); - + if (types[i] & PathPointTypeCloseSubpath) gf_path_close(glyph->path); i++; @@ -310,7 +311,7 @@ static GF_Glyph *gdip_load_glyph(GF_FontReader *dr, u32 glyph_name) break; } } - + delete [] pts; delete [] types; GdipDeleteStringFormat(fmt); @@ -368,7 +369,7 @@ extern "C" { #endif GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_FONT_READER_INTERFACE, diff --git a/modules/gdip_raster/gdip_grad.cpp b/modules/gdip_raster/gdip_grad.cpp index 14a059a..1dec02c 100644 --- a/modules/gdip_raster/gdip_grad.cpp +++ b/modules/gdip_raster/gdip_grad.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -29,7 +29,7 @@ GF_STENCIL gdip_new_stencil(GF_Raster2D *, GF_StencilType type) { struct _stencil *sten; - + switch (type) { case GF_STENCIL_SOLID: case GF_STENCIL_LINEAR_GRADIENT: @@ -80,7 +80,7 @@ GF_Err gdip_set_brush_color(GF_STENCIL _this, GF_Color c) { GPSTEN(); CHECK_RET(GF_STENCIL_SOLID); - if (!_sten->pSolid) + if (!_sten->pSolid) GdipCreateSolidFill(c, &_sten->pSolid); else GdipSetSolidFillColor(_sten->pSolid, c); @@ -99,7 +99,7 @@ GF_Err gdip_set_gradient_mode(GF_STENCIL _this, GF_GradientMode mode) return GF_OK; } -static +static GF_Err gdip_set_linear_gradient (GF_STENCIL _this, Fixed start_x, Fixed start_y, Fixed end_x, Fixed end_y) { GPSTEN(); @@ -142,7 +142,7 @@ void gdip_recompute_line_gradient(GF_STENCIL _this) GdipSetLinePresetBlend(_sten->pLinear, (ARGB *) _sten->cols, _sten->pos, _sten->num_pos); return; } - /*currently gdiplus doesn't support padded mode on gradients, so update the line gradient by + /*currently gdiplus doesn't support padded mode on gradients, so update the line gradient by using a line 3 times longer*/ w = _sten->end.X - _sten->start.X; h = _sten->end.Y - _sten->start.Y; @@ -173,7 +173,7 @@ void gdip_recompute_line_gradient(GF_STENCIL _this) cases the x3 dilatation is enough*/ GdipSetLineWrapMode(_sten->pLinear, WrapModeTileFlipXY); GdipSetLinePresetBlend(_sten->pLinear, cols, pos, 2+_sten->num_pos); - + delete [] cols; delete [] pos; } @@ -212,22 +212,22 @@ void gdip_recompute_radial_gradient(GF_STENCIL _this) if (_sten->spread == GF_GRADIENT_MODE_PAD) { - GdipAddPathEllipse(_sten->circle, - _sten->radius.X, -_sten->radius.Y, - 2*_sten->radius.X, 2*_sten->radius.Y); - + GdipAddPathEllipse(_sten->circle, - _sten->radius.X, -_sten->radius.Y, + 2*_sten->radius.X, 2*_sten->radius.Y); + GdipCreatePathGradientFromPath(_sten->circle, &_sten->pRadial); ARGB *blends = new ARGB[_sten->num_pos + 1]; /*radial blend pos are from bounds to center in gdiplus*/ blends[0] = _sten->cols[_sten->num_pos - 1]; - for (i=0; i<_sten->num_pos;i++) { + for (i=0; i<_sten->num_pos; i++) { blends[i+1] = _sten->cols[_sten->num_pos - i - 1]; } - + REAL *pos = new REAL[_sten->num_pos + 1]; pos[0] = 0; - for (i=0; i<_sten->num_pos;i++) { + for (i=0; i<_sten->num_pos; i++) { pos[i+1] = _sten->pos[i]; } @@ -239,7 +239,7 @@ void gdip_recompute_radial_gradient(GF_STENCIL _this) pt = _sten->focal; pt.X -= _sten->center.X; pt.Y -= _sten->center.Y; - GdipSetPathGradientCenterPoint(_sten->pRadial, &pt); + GdipSetPathGradientCenterPoint(_sten->pRadial, &pt); /*set transform*/ GdipCreateMatrix(&mat); @@ -251,14 +251,14 @@ void gdip_recompute_radial_gradient(GF_STENCIL _this) /*create back brush*/ GdipCreateSolidFill(_sten->cols[_sten->num_pos - 1], &_sten->pSolid); GdipResetPath(_sten->circle); - GdipAddPathEllipse(_sten->circle, - _sten->radius.X + _sten->center.X, -_sten->radius.Y + _sten->center.Y, - 2*_sten->radius.X, 2*_sten->radius.Y); + GdipAddPathEllipse(_sten->circle, - _sten->radius.X + _sten->center.X, -_sten->radius.Y + _sten->center.Y, + 2*_sten->radius.X, 2*_sten->radius.Y); } else { repeat = 10; - GdipAddPathEllipse(_sten->circle, - repeat * _sten->radius.X, - repeat*_sten->radius.Y, - 2*repeat*_sten->radius.X, 2*repeat*_sten->radius.Y); + GdipAddPathEllipse(_sten->circle, - repeat * _sten->radius.X, - repeat*_sten->radius.Y, + 2*repeat*_sten->radius.X, 2*repeat*_sten->radius.Y); GdipCreatePathGradientFromPath(_sten->circle, &_sten->pRadial); GdipDeletePath(_sten->circle); @@ -296,13 +296,13 @@ void gdip_recompute_radial_gradient(GF_STENCIL _this) pt = _sten->focal; pt.X -= (1 - repeat) * (_sten->focal.X - _sten->center.X) + _sten->center.X; pt.Y -= (1 - repeat) * (_sten->focal.Y - _sten->center.Y) + _sten->center.Y; - GdipSetPathGradientCenterPoint(_sten->pRadial, &pt); + GdipSetPathGradientCenterPoint(_sten->pRadial, &pt); /*set transform*/ GdipCreateMatrix(&mat); GdipTranslateMatrix(mat, (1 - repeat) * (_sten->focal.X - _sten->center.X) + _sten->center.X, - (1 - repeat) * (_sten->focal.Y - _sten->center.Y) + _sten->center.Y, - MatrixOrderAppend); + (1 - repeat) * (_sten->focal.Y - _sten->center.Y) + _sten->center.Y, + MatrixOrderAppend); if (_sten->pMat) GdipMultiplyMatrix(mat, _sten->pMat, MatrixOrderAppend); GdipSetTextureTransform((GpTexture*)_sten->pRadial, mat); GdipDeleteMatrix(mat); @@ -311,7 +311,7 @@ void gdip_recompute_radial_gradient(GF_STENCIL _this) } } -static +static GF_Err gdip_set_radial_gradient(GF_STENCIL _this, Fixed cx, Fixed cy, Fixed fx, Fixed fy, Fixed x_radius, Fixed y_radius) { GPSTEN(); @@ -348,7 +348,7 @@ GF_Err gdip_set_gradient_interpolation(GF_STENCIL _this, Fixed *pos, GF_Color *c } -static +static GF_Err gdip_set_vertex_path(GF_STENCIL _this, GF_Path *path) { GPSTEN(); @@ -361,7 +361,7 @@ GF_Err gdip_set_vertex_path(GF_STENCIL _this, GF_Path *path) return GF_OK; } -static +static GF_Err gdip_set_vertex_center (GF_STENCIL _this, Fixed cx, Fixed cy, u32 color) { GpStatus ret; diff --git a/modules/gdip_raster/gdip_priv.h b/modules/gdip_raster/gdip_priv.h index 7b89b05..e3a72d8 100644 --- a/modules/gdip_raster/gdip_priv.h +++ b/modules/gdip_raster/gdip_priv.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/gdip_raster/gdip_rend.cpp b/modules/gdip_raster/gdip_rend.cpp index e6a5e9c..4c6b88b 100644 --- a/modules/gdip_raster/gdip_rend.cpp +++ b/modules/gdip_raster/gdip_rend.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -63,7 +63,7 @@ GpPath *gdip_create_path(GF_Path *_this) u32 j, i, nb_pts, cur; if (!_this || !_this->n_points) return NULL; GdipCreatePath(FillModeAlternate, &p); - + GdipSetPathFillMode(p, (_this->flags & GF_PATH_FILL_ZERO_NONZERO) ? FillModeWinding : FillModeAlternate); cur = 0; @@ -82,11 +82,11 @@ GpPath *gdip_create_path(GF_Path *_this) break; case GF_PATH_CURVE_CUBIC: GdipAddPathBezier(p, - FIX2FLT(_this->points[j-1].x), FIX2FLT(_this->points[j-1].y), - FIX2FLT(_this->points[j].x), FIX2FLT(_this->points[j].y), - FIX2FLT(_this->points[j+1].x), FIX2FLT(_this->points[j+1].y), - FIX2FLT(_this->points[j+2].x), FIX2FLT(_this->points[j+2].y) - ); + FIX2FLT(_this->points[j-1].x), FIX2FLT(_this->points[j-1].y), + FIX2FLT(_this->points[j].x), FIX2FLT(_this->points[j].y), + FIX2FLT(_this->points[j+1].x), FIX2FLT(_this->points[j+1].y), + FIX2FLT(_this->points[j+2].x), FIX2FLT(_this->points[j+2].y) + ); j+=3; break; case GF_PATH_CURVE_CONIC: @@ -99,15 +99,15 @@ GpPath *gdip_create_path(GF_Path *_this) c1.y = start.y + 2*(ctl.y - start.y) / 3; c2.x = c1.x + (end.x - start.x) / 3; c2.y = c1.y + (end.y - start.y) / 3; - GdipAddPathBezier(p, - FIX2FLT(start.x), FIX2FLT(start.y), - FIX2FLT(c1.x), FIX2FLT(c1.y), - FIX2FLT(c2.x), FIX2FLT(c2.y), - FIX2FLT(end.x), FIX2FLT(end.y) - ); + GdipAddPathBezier(p, + FIX2FLT(start.x), FIX2FLT(start.y), + FIX2FLT(c1.x), FIX2FLT(c1.y), + FIX2FLT(c2.x), FIX2FLT(c2.y), + FIX2FLT(end.x), FIX2FLT(end.y) + ); j+=2; } - break; + break; } } GdipClosePathFigure(p); @@ -220,7 +220,7 @@ GF_Err gdip_attach_surface_to_buffer(GF_SURFACE _this, char *pixels, u32 width, } GdipCreateBitmapFromScan0(width, height, pitch_y, pFormat, (unsigned char*)pixels, &_graph->pBitmap); GdipGetImageGraphicsContext(_graph->pBitmap, &_graph->graph); - + _graph->w = width; _graph->h = height; if (_graph->center_coords) { @@ -276,7 +276,7 @@ GF_Err gdip_surface_set_matrix(GF_SURFACE _this, GF_Matrix2D * mat) { GPGRAPH(); if (_graph->mat) GdipDeleteMatrix(_graph->mat); - + _graph->mat = mat_gpac_to_gdip(mat); return GF_OK; } @@ -320,7 +320,7 @@ GF_Err gdip_surface_set_path(GF_SURFACE _this, GF_Path *path) if (_graph->current) GdipDeletePath(_graph->current); _graph->current = NULL; if (!path) return GF_OK; - + _path = (struct _storepath *)path; _graph->current = gdip_setup_path(_graph, path); return GF_OK; @@ -337,7 +337,8 @@ GF_Err gdip_surface_fill(GF_SURFACE _this, GF_STENCIL stencil) GPGRAPH(); if (!_this) return GF_BAD_PARAM; if (!_graph->current) return GF_OK; - _sten = (struct _stencil *)stencil; assert(_sten); + _sten = (struct _stencil *)stencil; + assert(_sten); #ifdef NODRAW return GF_OK; @@ -375,7 +376,7 @@ GF_Err gdip_surface_fill(GF_SURFACE _this, GF_STENCIL stencil) GdipSetCompositingQuality(_graph->graph, CompositingQualityHighSpeed); GdipSetInterpolationMode(_graph->graph, InterpolationModeLowQuality); GdipSetSmoothingMode(_graph->graph, SmoothingModeHighSpeed); - + /*check if we need to draw solid background (GDIplus doesn't implement padded mode on path gradients)*/ if (_sten->pSolid) { GpPath *tr; @@ -405,10 +406,10 @@ GF_Err gdip_surface_fill(GF_SURFACE _this, GF_STENCIL stencil) GdipCreateMatrix(&newmat); } /*gdip flip*/ - if (_graph->center_coords && !(_sten->tiling&GF_TEXTURE_FLIP) ) - GdipScaleMatrix(newmat, 1, -1, MatrixOrderPrepend); - else if (!_graph->center_coords && (_sten->tiling&GF_TEXTURE_FLIP) ) - GdipScaleMatrix(newmat, 1, -1, MatrixOrderPrepend); + if (_graph->center_coords && !(_sten->tiling&GF_TEXTURE_FLIP) ) + GdipScaleMatrix(newmat, 1, -1, MatrixOrderPrepend); + else if (!_graph->center_coords && (_sten->tiling&GF_TEXTURE_FLIP) ) + GdipScaleMatrix(newmat, 1, -1, MatrixOrderPrepend); GdipSetTextureTransform((GpTexture*)_sten->pTexture, newmat); GdipDeleteMatrix(newmat); @@ -441,10 +442,10 @@ GF_Err gdip_surface_clear(GF_SURFACE _this, GF_IRect *rc, u32 color) /*luckily enough this maps well for both flipped and unflipped coords*/ GdipAddPathRectangleI(path, rc->x, rc->y - rc->height, rc->width, rc->height); } else { -/* if (_graph->center_coords) { - GdipAddPathRectangleI(path, -1 * (s32)_graph->w / 2, -1 * (s32)_graph->h / 2, _graph->w, _graph->h); - } else { -*/ GdipAddPathRectangleI(path, 0, 0, _graph->w, _graph->h); + /* if (_graph->center_coords) { + GdipAddPathRectangleI(path, -1 * (s32)_graph->w / 2, -1 * (s32)_graph->h / 2, _graph->w, _graph->h); + } else { + */ GdipAddPathRectangleI(path, 0, 0, _graph->w, _graph->h); // } } /*we MUST use clear otherwise ARGB surfaces are not cleared correctly*/ diff --git a/modules/gdip_raster/gdip_texture.cpp b/modules/gdip_raster/gdip_texture.cpp index ebaeb01..eb55065 100644 --- a/modules/gdip_raster/gdip_texture.cpp +++ b/modules/gdip_raster/gdip_texture.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -135,62 +135,63 @@ GF_Err gdip_set_texture(GF_STENCIL _this, char *pixels, u32 width, u32 height, u GdipCreateBitmapFromScan0(_sten->width, _sten->height, 0, pFormat, NULL, &_sten->pBitmap); ptr = pixels; for (j=0; j<_sten->height; j++) { - for (i=0; i<_sten->width; i++) { - switch (pixelFormat) { - case GF_PIXEL_GREYSCALE: - r = *ptr++; - col = GF_COL_ARGB(255, r, r, r); - break; - case GF_PIXEL_ALPHAGREY: - r = *ptr++; - a = *ptr++; - col = GF_COL_ARGB(a, r, r, r); - break; - case GF_PIXEL_RGB_555: - val = * (unsigned short *) (ptr); - ptr+= 2; - col = COL_555(val); - break; - case GF_PIXEL_RGB_565: - val = * (unsigned short *) (ptr); - ptr+= 2; - col = COL_565(val); - break; - /*scan0 uses bgr...*/ - case GF_PIXEL_BGR_24: - case GF_PIXEL_RGB_24: - r = *ptr++; - g = *ptr++; - b = *ptr++; - if (!isBGR) { - col = GF_COL_ARGB(255, b, g, r); - } else { - col = GF_COL_ARGB(255, r, g, b); + for (i=0; i<_sten->width; i++) { + switch (pixelFormat) { + case GF_PIXEL_GREYSCALE: + r = *ptr++; + col = GF_COL_ARGB(255, r, r, r); + break; + case GF_PIXEL_ALPHAGREY: + r = *ptr++; + a = *ptr++; + col = GF_COL_ARGB(a, r, r, r); + break; + case GF_PIXEL_RGB_555: + val = * (unsigned short *) (ptr); + ptr+= 2; + col = COL_555(val); + break; + case GF_PIXEL_RGB_565: + val = * (unsigned short *) (ptr); + ptr+= 2; + col = COL_565(val); + break; + /*scan0 uses bgr...*/ + case GF_PIXEL_BGR_24: + case GF_PIXEL_RGB_24: + r = *ptr++; + g = *ptr++; + b = *ptr++; + if (!isBGR) { + col = GF_COL_ARGB(255, b, g, r); + } else { + col = GF_COL_ARGB(255, r, g, b); + } + break; + /*NOTE: we assume little-endian only for GDIplus platforms, so BGRA/BGRX*/ + case GF_PIXEL_RGB_32: + case GF_PIXEL_ARGB: + b = *ptr++; + g = *ptr++; + r = *ptr++; + a = *ptr++; + if (pixelFormat==GF_PIXEL_RGB_32) a = 0xFF; + col = GF_COL_ARGB(a, r, g, b); + break; + case GF_PIXEL_RGBA: + r = *ptr++; + g = *ptr++; + b = *ptr++; + a = *ptr++; + col = GF_COL_ARGB(a, r, g, b); + break; + default: + col = GF_COL_ARGB(255, 255, 255, 255); + break; } - break; - /*NOTE: we assume little-endian only for GDIplus platforms, so BGRA/BGRX*/ - case GF_PIXEL_RGB_32: - case GF_PIXEL_ARGB: - b = *ptr++; - g = *ptr++; - r = *ptr++; - a = *ptr++; - if (pixelFormat==GF_PIXEL_RGB_32) a = 0xFF; - col = GF_COL_ARGB(a, r, g, b); - break; - case GF_PIXEL_RGBA: - r = *ptr++; - g = *ptr++; - b = *ptr++; - a = *ptr++; - col = GF_COL_ARGB(a, r, g, b); - break; - default: - col = GF_COL_ARGB(255, 255, 255, 255); - break; + GdipBitmapSetPixel(_sten->pBitmap, i, j, col); } - GdipBitmapSetPixel(_sten->pBitmap, i, j, col); - }} + } } return GF_OK; diff --git a/modules/gpac_js/gpac_js.c b/modules/gpac_js/gpac_js.c index 965c456..9ba3a8a 100644 --- a/modules/gpac_js/gpac_js.c +++ b/modules/gpac_js/gpac_js.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2007-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,7 +56,7 @@ #endif #include -#include +#include #include #include @@ -94,204 +94,204 @@ static GF_Terminal *gpac_get_term(JSContext *c, JSObject *obj) static SMJS_FUNC_PROP_GET( gpac_getProperty) - const char *res; - char *prop_name; - GF_Terminal *term = gpac_get_term(c, obj); - if (!term) return JS_FALSE; +const char *res; +char *prop_name; +GF_Terminal *term = gpac_get_term(c, obj); +if (!term) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!prop_name) return JS_FALSE; +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!prop_name) return JS_FALSE; - if (!strcmp(prop_name, "last_working_directory")) { - res = gf_cfg_get_key(term->user->config, "General", "LastWorkingDir"); - if (!res) res = gf_cfg_get_key(term->user->config, "General", "ModulesDirectory"); - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, res)); - } - else if (!strcmp(prop_name, "scale_x")) { - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->scale_x)) ); - } - else if (!strcmp(prop_name, "scale_y")) { - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->scale_y)) ); - } - else if (!strcmp(prop_name, "translation_x")) { - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->trans_x)) ); - } - else if (!strcmp(prop_name, "translation_y")) { - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->trans_y)) ); - } - else if (!strcmp(prop_name, "rectangular_textures")) { - Bool any_size = GF_FALSE; +if (!strcmp(prop_name, "last_working_directory")) { + res = gf_cfg_get_key(term->user->config, "General", "LastWorkingDir"); + if (!res) res = gf_cfg_get_key(term->user->config, "General", "ModulesDirectory"); + *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, res)); +} +else if (!strcmp(prop_name, "scale_x")) { + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->scale_x)) ); +} +else if (!strcmp(prop_name, "scale_y")) { + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->scale_y)) ); +} +else if (!strcmp(prop_name, "translation_x")) { + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->trans_x)) ); +} +else if (!strcmp(prop_name, "translation_y")) { + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(term->compositor->trans_y)) ); +} +else if (!strcmp(prop_name, "rectangular_textures")) { + Bool any_size = GF_FALSE; #ifndef GPAC_DISABLE_3D - if (term->compositor->gl_caps.npot_texture || term->compositor->gl_caps.rect_texture) - any_size = GF_TRUE; + if (term->compositor->gl_caps.npot_texture || term->compositor->gl_caps.rect_texture) + any_size = GF_TRUE; #endif - *vp = BOOLEAN_TO_JSVAL( any_size ? JS_TRUE : JS_FALSE ); - } - else if (!strcmp(prop_name, "batteryOn")) { - Bool on_battery = GF_FALSE; - gf_sys_get_battery_state(&on_battery, NULL, NULL, NULL, NULL); - *vp = BOOLEAN_TO_JSVAL( on_battery ? JS_TRUE : JS_FALSE ); - } - else if (!strcmp(prop_name, "batteryCharging")) { - u32 on_charge = 0; - gf_sys_get_battery_state(NULL, &on_charge, NULL, NULL, NULL); - *vp = BOOLEAN_TO_JSVAL( on_charge ? JS_TRUE : JS_FALSE ); - } - else if (!strcmp(prop_name, "batteryPercent")) { - u32 level = 0; - gf_sys_get_battery_state(NULL, NULL, &level, NULL, NULL); - *vp = INT_TO_JSVAL( level ); - } - else if (!strcmp(prop_name, "batteryLifeTime")) { - u32 level = 0; - gf_sys_get_battery_state(NULL, NULL, NULL, &level, NULL); - *vp = INT_TO_JSVAL( level ); - } - else if (!strcmp(prop_name, "batteryFullLifeTime")) { - u32 level = 0; - gf_sys_get_battery_state(NULL, NULL, NULL, NULL, &level); - *vp = INT_TO_JSVAL( level ); - } - else if (!strcmp(prop_name, "hostname")) { - char hostname[100]; - gf_sk_get_host_name((char*)hostname); - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, hostname)); - } - else if (!strcmp(prop_name, "fullscreen")) { - *vp = BOOLEAN_TO_JSVAL( term->compositor->fullscreen ? JS_TRUE : JS_FALSE); - } - else if (!strcmp(prop_name, "current_path")) { - char *url = gf_url_concatenate(term->root_scene->root_od->net_service->url, ""); - if (!url) url = gf_strdup(""); - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, url)); - gf_free(url); - } - else if (!strcmp(prop_name, "volume")) { - *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_AUDIO_VOLUME)); - } - else if (!strcmp(prop_name, "navigation")) { - *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_NAVIGATION)); - } - else if (!strcmp(prop_name, "navigation_type")) { - *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_NAVIGATION_TYPE) ); - } - else if (!strcmp(prop_name, "hardware_yuv")) { - *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_YUV) ? 1 : 0 ); - } - else if (!strcmp(prop_name, "hardware_rgb")) { - *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_RGB) ? 1 : 0 ); - } - else if (!strcmp(prop_name, "hardware_rgba")) { - u32 has_rgba = (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_RGBA) ? 1 : 0; + *vp = BOOLEAN_TO_JSVAL( any_size ? JS_TRUE : JS_FALSE ); +} +else if (!strcmp(prop_name, "batteryOn")) { + Bool on_battery = GF_FALSE; + gf_sys_get_battery_state(&on_battery, NULL, NULL, NULL, NULL); + *vp = BOOLEAN_TO_JSVAL( on_battery ? JS_TRUE : JS_FALSE ); +} +else if (!strcmp(prop_name, "batteryCharging")) { + u32 on_charge = 0; + gf_sys_get_battery_state(NULL, &on_charge, NULL, NULL, NULL); + *vp = BOOLEAN_TO_JSVAL( on_charge ? JS_TRUE : JS_FALSE ); +} +else if (!strcmp(prop_name, "batteryPercent")) { + u32 level = 0; + gf_sys_get_battery_state(NULL, NULL, &level, NULL, NULL); + *vp = INT_TO_JSVAL( level ); +} +else if (!strcmp(prop_name, "batteryLifeTime")) { + u32 level = 0; + gf_sys_get_battery_state(NULL, NULL, NULL, &level, NULL); + *vp = INT_TO_JSVAL( level ); +} +else if (!strcmp(prop_name, "batteryFullLifeTime")) { + u32 level = 0; + gf_sys_get_battery_state(NULL, NULL, NULL, NULL, &level); + *vp = INT_TO_JSVAL( level ); +} +else if (!strcmp(prop_name, "hostname")) { + char hostname[100]; + gf_sk_get_host_name((char*)hostname); + *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, hostname)); +} +else if (!strcmp(prop_name, "fullscreen")) { + *vp = BOOLEAN_TO_JSVAL( term->compositor->fullscreen ? JS_TRUE : JS_FALSE); +} +else if (!strcmp(prop_name, "current_path")) { + char *url = gf_url_concatenate(term->root_scene->root_od->net_service->url, ""); + if (!url) url = gf_strdup(""); + *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, url)); + gf_free(url); +} +else if (!strcmp(prop_name, "volume")) { + *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_AUDIO_VOLUME)); +} +else if (!strcmp(prop_name, "navigation")) { + *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_NAVIGATION)); +} +else if (!strcmp(prop_name, "navigation_type")) { + *vp = INT_TO_JSVAL( gf_term_get_option(term, GF_OPT_NAVIGATION_TYPE) ); +} +else if (!strcmp(prop_name, "hardware_yuv")) { + *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_YUV) ? 1 : 0 ); +} +else if (!strcmp(prop_name, "hardware_rgb")) { + *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_RGB) ? 1 : 0 ); +} +else if (!strcmp(prop_name, "hardware_rgba")) { + u32 has_rgba = (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_RGBA) ? 1 : 0; #ifndef GPAC_DISABLE_3D - if (term->compositor->hybrid_opengl || term->compositor->is_opengl) has_rgba = 1; + if (term->compositor->hybrid_opengl || term->compositor->is_opengl) has_rgba = 1; #endif - *vp = INT_TO_JSVAL( has_rgba ); - } - else if (!strcmp(prop_name, "hardware_stretch")) { - *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_STRETCH) ? 1 : 0 ); - } - else if (!strcmp(prop_name, "screen_width")) { - *vp = INT_TO_JSVAL( term->compositor->video_out->max_screen_width); - } - else if (!strcmp(prop_name, "screen_height")) { - *vp = INT_TO_JSVAL( term->compositor->video_out->max_screen_height); - } - else if (!strcmp(prop_name, "http_bitrate")) { - *vp = INT_TO_JSVAL( gf_dm_get_data_rate(term->downloader)*8/1024); - } - else if (!strcmp(prop_name, "fps")) { - Double fps = gf_sc_get_fps(term->compositor, 0); - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, fps) ); - } - else if (!strcmp(prop_name, "cpu_load")) { - GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); - gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); - *vp = INT_TO_JSVAL(ext->rti.process_cpu_usage); - } - else if (!strcmp(prop_name, "memory")) { - GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); - gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); - *vp = INT_TO_JSVAL(ext->rti.process_memory); - } + *vp = INT_TO_JSVAL( has_rgba ); +} +else if (!strcmp(prop_name, "hardware_stretch")) { + *vp = INT_TO_JSVAL( (term->compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_STRETCH) ? 1 : 0 ); +} +else if (!strcmp(prop_name, "screen_width")) { + *vp = INT_TO_JSVAL( term->compositor->video_out->max_screen_width); +} +else if (!strcmp(prop_name, "screen_height")) { + *vp = INT_TO_JSVAL( term->compositor->video_out->max_screen_height); +} +else if (!strcmp(prop_name, "http_bitrate")) { + *vp = INT_TO_JSVAL( gf_dm_get_data_rate(term->downloader)*8/1024); +} +else if (!strcmp(prop_name, "fps")) { + Double fps = gf_sc_get_fps(term->compositor, 0); + *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, fps) ); +} +else if (!strcmp(prop_name, "cpu_load")) { + GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); + gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); + *vp = INT_TO_JSVAL(ext->rti.process_cpu_usage); +} +else if (!strcmp(prop_name, "memory")) { + GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); + gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); + *vp = INT_TO_JSVAL(ext->rti.process_memory); +} - SMJS_FREE(c, prop_name); - return JS_TRUE; +SMJS_FREE(c, prop_name); +return JS_TRUE; } static SMJS_FUNC_PROP_SET( gpac_setProperty) - char *prop_name, *prop_val; - GF_Terminal *term = gpac_get_term(c, obj); - if (!term) return JS_FALSE; +char *prop_name, *prop_val; +GF_Terminal *term = gpac_get_term(c, obj); +if (!term) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!strcmp(prop_name, "last_working_directory")) { - if (!JSVAL_IS_STRING(*vp)) { - SMJS_FREE(c, prop_name); - return JS_FALSE; - } - prop_val = SMJS_CHARS(c, *vp); - gf_cfg_set_key(term->user->config, "General", "LastWorkingDir", prop_val); - SMJS_FREE(c, prop_val); +if (!strcmp(prop_name, "last_working_directory")) { + if (!JSVAL_IS_STRING(*vp)) { + SMJS_FREE(c, prop_name); + return JS_FALSE; } - else if (!strcmp(prop_name, "caption")) { - GF_Event evt; - if (!JSVAL_IS_STRING(*vp)) { - SMJS_FREE(c, prop_name); - return JS_FALSE; - } - evt.type = GF_EVENT_SET_CAPTION; - evt.caption.caption = SMJS_CHARS(c, *vp); - gf_term_user_event(term, &evt); - SMJS_FREE(c, (char*)evt.caption.caption); + prop_val = SMJS_CHARS(c, *vp); + gf_cfg_set_key(term->user->config, "General", "LastWorkingDir", prop_val); + SMJS_FREE(c, prop_val); +} +else if (!strcmp(prop_name, "caption")) { + GF_Event evt; + if (!JSVAL_IS_STRING(*vp)) { + SMJS_FREE(c, prop_name); + return JS_FALSE; } - else if (!strcmp(prop_name, "fullscreen")) { - /*no fullscreen for iOS (always on)*/ + evt.type = GF_EVENT_SET_CAPTION; + evt.caption.caption = SMJS_CHARS(c, *vp); + gf_term_user_event(term, &evt); + SMJS_FREE(c, (char*)evt.caption.caption); +} +else if (!strcmp(prop_name, "fullscreen")) { + /*no fullscreen for iOS (always on)*/ #ifndef GPAC_IPHONE - Bool res = (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? 1 : 0; - if (term->compositor->fullscreen != res) { - gf_term_set_option(term, GF_OPT_FULLSCREEN, res); - } -#endif - } - else if (!strcmp(prop_name, "volume")) { - if (JSVAL_IS_NUMBER(*vp)) { - jsdouble d; - JS_ValueToNumber(c, *vp, &d); - gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, (u32) d); - } else if (JSVAL_IS_INT(*vp)) { - gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, JSVAL_TO_INT(*vp)); - } - } - else if (!strcmp(prop_name, "navigation")) { - gf_term_set_option(term, GF_OPT_NAVIGATION, JSVAL_TO_INT(*vp) ); + Bool res = (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? 1 : 0; + if (term->compositor->fullscreen != res) { + gf_term_set_option(term, GF_OPT_FULLSCREEN, res); } - else if (!strcmp(prop_name, "navigation_type")) { - gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0); +#endif +} +else if (!strcmp(prop_name, "volume")) { + if (JSVAL_IS_NUMBER(*vp)) { + jsdouble d; + JS_ValueToNumber(c, *vp, &d); + gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, (u32) d); + } else if (JSVAL_IS_INT(*vp)) { + gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, JSVAL_TO_INT(*vp)); } - else if (!strcmp(prop_name, "disable_hardware_blit")) { - term->compositor->disable_hardware_blit = JSVAL_TO_INT(*vp) ? 1 : 0; +} +else if (!strcmp(prop_name, "navigation")) { + gf_term_set_option(term, GF_OPT_NAVIGATION, JSVAL_TO_INT(*vp) ); +} +else if (!strcmp(prop_name, "navigation_type")) { + gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0); +} +else if (!strcmp(prop_name, "disable_hardware_blit")) { + term->compositor->disable_hardware_blit = JSVAL_TO_INT(*vp) ? 1 : 0; + gf_sc_set_option(term->compositor, GF_OPT_REFRESH, 0); +} +else if (!strcmp(prop_name, "disable_composite_blit")) { + Bool new_val = JSVAL_TO_INT(*vp) ? 1 : 0; + if (new_val != term->compositor->disable_composite_blit) { + term->compositor->disable_composite_blit = new_val; + term->compositor->rebuild_offscreen_textures = 1; gf_sc_set_option(term->compositor, GF_OPT_REFRESH, 0); } - else if (!strcmp(prop_name, "disable_composite_blit")) { - Bool new_val = JSVAL_TO_INT(*vp) ? 1 : 0; - if (new_val != term->compositor->disable_composite_blit) { - term->compositor->disable_composite_blit = new_val; - term->compositor->rebuild_offscreen_textures = 1; - gf_sc_set_option(term->compositor, GF_OPT_REFRESH, 0); - } - } - else if (!strcmp(prop_name, "http_bitrate")) { - u32 new_rate = JSVAL_TO_INT(*vp); - gf_dm_set_data_rate(term->downloader, new_rate); - } +} +else if (!strcmp(prop_name, "http_bitrate")) { + u32 new_rate = JSVAL_TO_INT(*vp); + gf_dm_set_data_rate(term->downloader, new_rate); +} - SMJS_FREE(c, prop_name); - return JS_TRUE; +SMJS_FREE(c, prop_name); +return JS_TRUE; } static JSBool SMJS_FUNCTION(gpac_getOption) @@ -305,7 +305,7 @@ static JSBool SMJS_FUNCTION(gpac_getOption) if (!term) return JS_FALSE; if (argc < 2) return JS_FALSE; - + if (!JSVAL_IS_STRING(argv[0])) return JS_FALSE; if (!JSVAL_IS_STRING(argv[1])) return JS_FALSE; @@ -313,11 +313,11 @@ static JSBool SMJS_FUNCTION(gpac_getOption) key_name = SMJS_CHARS(c, argv[1]); if (!stricmp(sec_name, "audiofilters")) { - if (!term->compositor->audio_renderer->filter_chain.enable_filters - || !term->compositor->audio_renderer->filter_chain.filters->filter->GetOption) { - SMJS_FREE(c, key_name); - SMJS_FREE(c, sec_name); - return JS_TRUE; + if (!term->compositor->audio_renderer->filter_chain.enable_filters + || !term->compositor->audio_renderer->filter_chain.filters->filter->GetOption) { + SMJS_FREE(c, key_name); + SMJS_FREE(c, sec_name); + return JS_TRUE; } opt = term->compositor->audio_renderer->filter_chain.filters->filter->GetOption(term->compositor->audio_renderer->filter_chain.filters->filter, key_name); } else { @@ -328,8 +328,8 @@ static JSBool SMJS_FUNCTION(gpac_getOption) s = JS_NewStringCopyZ(c, opt ? opt : ""); if (!s) return JS_FALSE; - SMJS_SET_RVAL( STRING_TO_JSVAL(s) ); - return JS_TRUE; + SMJS_SET_RVAL( STRING_TO_JSVAL(s) ); + return JS_TRUE; } static JSBool SMJS_FUNCTION(gpac_setOption) @@ -340,7 +340,7 @@ static JSBool SMJS_FUNCTION(gpac_setOption) GF_Terminal *term = gpac_get_term(c, obj); if (!term) return JS_FALSE; if (argc < 3) return JS_FALSE; - + if (!JSVAL_IS_STRING(argv[0])) return JS_FALSE; if (!JSVAL_IS_STRING(argv[1])) return JS_FALSE; if (!JSVAL_IS_STRING(argv[2])) return JS_FALSE; @@ -351,7 +351,7 @@ static JSBool SMJS_FUNCTION(gpac_setOption) if (!stricmp(sec_name, "audiofilters")) { if (term->compositor->audio_renderer->filter_chain.enable_filters - && term->compositor->audio_renderer->filter_chain.filters->filter->SetOption) { + && term->compositor->audio_renderer->filter_chain.filters->filter->SetOption) { term->compositor->audio_renderer->filter_chain.filters->filter->SetOption(term->compositor->audio_renderer->filter_chain.filters->filter, key_name, key_val); } } else { @@ -366,7 +366,7 @@ static JSBool SMJS_FUNCTION(gpac_setOption) return JS_TRUE; } -typedef struct +typedef struct { JSContext *c; JSObject *array; @@ -519,7 +519,7 @@ static JSBool SMJS_FUNCTION(gpac_set_size) JS_ValueToNumber(c, argv[1], &d); h = (u32) d; } - if ((argc >= 3) && JSVAL_IS_BOOLEAN(argv[2]) && (JSVAL_TO_BOOLEAN(argv[2])==JS_TRUE) ) + if ((argc >= 3) && JSVAL_IS_BOOLEAN(argv[2]) && (JSVAL_TO_BOOLEAN(argv[2])==JS_TRUE) ) override_size_info = 1; if (w && h) { @@ -557,7 +557,7 @@ static JSBool SMJS_FUNCTION(gpac_get_vertical_dpi) { SMJS_OBJ GF_Terminal *term = gpac_get_term(c, obj); - if (term) SMJS_SET_RVAL( INT_TO_JSVAL(term->compositor->video_out->dpi_y) ); + if (term) SMJS_SET_RVAL( INT_TO_JSVAL(term->compositor->video_out->dpi_y) ); return JS_TRUE; } @@ -611,13 +611,13 @@ static JSBool SMJS_FUNCTION(gpac_move_window) GF_Terminal *term = gpac_get_term(c, obj); if (argc < 2) return JS_TRUE; if (!JSVAL_IS_INT(argv[0]) || !JSVAL_IS_INT(argv[1])) return JS_TRUE; - + evt.type = GF_EVENT_MOVE; evt.move.relative = 1; evt.move.x = JSVAL_TO_INT(argv[0]); evt.move.y = JSVAL_TO_INT(argv[1]); term->compositor->video_out->ProcessEvent(term->compositor->video_out, &evt); - + return JS_TRUE; } @@ -630,7 +630,7 @@ static JSBool SMJS_FUNCTION(gpac_error_string) if (argc < 1) return JS_TRUE; if (!JSVAL_IS_INT(argv[0]) ) return JS_TRUE; str = gf_error_to_string(JSVAL_TO_INT(argv[0])); - + SMJS_SET_RVAL( STRING_TO_JSVAL(JS_NewStringCopyZ(c, str)) ); return JS_TRUE; } @@ -661,10 +661,10 @@ static JSBool SMJS_FUNCTION(gpac_migrate_url) SMJS_ARGS GF_Terminal *term = gpac_get_term(c, obj); if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_FALSE; - + url = SMJS_CHARS(c, argv[0]); if (!url) return JS_FALSE; - + count = gf_list_count(term->root_scene->resources); for (i=0; iroot_scene->resources, i); @@ -679,7 +679,7 @@ static JSBool SMJS_FUNCTION(gpac_migrate_url) } else { SMJS_SET_RVAL( STRING_TO_JSVAL(JS_NewStringCopyZ(c, odm->net_service->url)) ); } - break; + break; } SMJS_FREE(c, url); return JS_TRUE; @@ -687,61 +687,61 @@ static JSBool SMJS_FUNCTION(gpac_migrate_url) static SMJS_FUNC_PROP_GET( gpacevt_getProperty) - GF_GPACJSExt *gjs = SMJS_GET_PRIVATE(c, obj); - GF_Event *evt = gjs->evt; - if (!evt) return 0; +GF_GPACJSExt *gjs = SMJS_GET_PRIVATE(c, obj); +GF_Event *evt = gjs->evt; +if (!evt) return 0; - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case -1: +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case -1: #ifndef GPAC_DISABLE_SVG - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, gf_dom_get_key_name(evt->key.key_code) )); + *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, gf_dom_get_key_name(evt->key.key_code) )); #endif - break; - case -2: - *vp = INT_TO_JSVAL(evt->mouse.x); - break; - case -3: - *vp = INT_TO_JSVAL(evt->mouse.y); - break; - case -4: - if (gjs->term->compositor->hit_appear) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); - else if (gf_list_count(gjs->term->compositor->previous_sensors) ) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); - else if (gjs->term->compositor->text_selection) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); - else *vp = BOOLEAN_TO_JSVAL(JS_FALSE); - break; - case -5: - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(evt->mouse.wheel_pos)) ); - break; - case -6: - *vp = INT_TO_JSVAL( evt->mouse.button); - break; - case -7: - *vp = INT_TO_JSVAL(evt->type); - break; - } - } else if (SMJS_ID_IS_STRING(id)) { - char *name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!strcmp(name, "target_url")) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, evt->navigate.to_url) ); - } - else if (!strcmp(name, "files")) { - u32 i, idx; - jsval v; - JSObject *files_array = JS_NewArrayObject(c, 0, NULL); - for (i=0; iopen_file.nb_files; i++) { - if (evt->open_file.files[i]) { - JS_GetArrayLength(c, files_array, &idx); - v = STRING_TO_JSVAL( JS_NewStringCopyZ(c, evt->open_file.files[i]) ); - JS_SetElement(c, files_array, idx, &v); - } + break; + case -2: + *vp = INT_TO_JSVAL(evt->mouse.x); + break; + case -3: + *vp = INT_TO_JSVAL(evt->mouse.y); + break; + case -4: + if (gjs->term->compositor->hit_appear) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); + else if (gf_list_count(gjs->term->compositor->previous_sensors) ) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); + else if (gjs->term->compositor->text_selection) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); + else *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + break; + case -5: + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, FIX2FLT(evt->mouse.wheel_pos)) ); + break; + case -6: + *vp = INT_TO_JSVAL( evt->mouse.button); + break; + case -7: + *vp = INT_TO_JSVAL(evt->type); + break; + } +} else if (SMJS_ID_IS_STRING(id)) { + char *name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); + if (!strcmp(name, "target_url")) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, evt->navigate.to_url) ); + } + else if (!strcmp(name, "files")) { + u32 i, idx; + jsval v; + JSObject *files_array = JS_NewArrayObject(c, 0, NULL); + for (i=0; iopen_file.nb_files; i++) { + if (evt->open_file.files[i]) { + JS_GetArrayLength(c, files_array, &idx); + v = STRING_TO_JSVAL( JS_NewStringCopyZ(c, evt->open_file.files[i]) ); + JS_SetElement(c, files_array, idx, &v); } - *vp = OBJECT_TO_JSVAL(files_array); } - SMJS_FREE(c, name); + *vp = OBJECT_TO_JSVAL(files_array); } + SMJS_FREE(c, name); +} - return JS_TRUE; +return JS_TRUE; } static Bool gjs_event_filter(void *udta, GF_Event *evt, Bool consumed_by_compositor) @@ -809,7 +809,7 @@ static JSBool SMJS_FUNCTION(gpac_set_focus) char *focus_type = SMJS_CHARS(c, argv[0]); if (!stricmp(focus_type, "previous")) { gf_sc_focus_switch_ring(term->compositor, 1, NULL, 0); - } + } else if (!stricmp(focus_type, "next")) { gf_sc_focus_switch_ring(term->compositor, 0, NULL, 0); } @@ -861,8 +861,8 @@ static JSBool SMJS_FUNCTION(gpac_get_scene) SMJS_SET_PRIVATE(c, scene_obj, scene); gf_sg_get_scene_size_info(scene->graph, &w, &h); JS_DefineProperty(c, scene_obj, "width", INT_TO_JSVAL(w), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, scene_obj, "height", INT_TO_JSVAL(h), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, scene_obj, "connected", BOOLEAN_TO_JSVAL(scene->graph ? JS_TRUE : JS_FALSE), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, scene_obj, "height", INT_TO_JSVAL(h), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, scene_obj, "connected", BOOLEAN_TO_JSVAL(scene->graph ? JS_TRUE : JS_FALSE), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); SMJS_SET_RVAL( OBJECT_TO_JSVAL(scene_obj) ); return JS_TRUE; } @@ -877,10 +877,10 @@ static JSBool SMJS_FUNCTION(gpac_show_keyboard) if (JSVAL_IS_BOOLEAN(argv[0])) { Bool show = JSVAL_TO_BOOLEAN(argv[0])==JS_TRUE; GF_Event evt; - memset(&evt, 0, sizeof(GF_Event)); - evt.type = show ? GF_EVENT_TEXT_EDITING_START : GF_EVENT_TEXT_EDITING_END; - gf_term_user_event(term, &evt); - } + memset(&evt, 0, sizeof(GF_Event)); + evt.type = show ? GF_EVENT_TEXT_EDITING_START : GF_EVENT_TEXT_EDITING_END; + gf_term_user_event(term, &evt); + } return JS_TRUE; } @@ -927,7 +927,7 @@ static void gjs_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, JSContext SMJS_FUNCTION_SPEC("get_scene", gpac_get_scene, 1), SMJS_FUNCTION_SPEC("error_string", gpac_error_string, 1), SMJS_FUNCTION_SPEC("show_keyboard", gpac_show_keyboard, 1), - + SMJS_FUNCTION_SPEC(0, 0, 0) }; @@ -998,12 +998,12 @@ static void gjs_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, JSContext DECLARE_GPAC_CONST(GF_NAVIGATE_TYPE_NONE); DECLARE_GPAC_CONST(GF_NAVIGATE_TYPE_2D); DECLARE_GPAC_CONST(GF_NAVIGATE_TYPE_3D); - + JS_SETUP_CLASS(gjs->anyClass, "GPACOBJECT", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); GF_JS_InitClass(c, global, 0, &gjs->anyClass, 0, 0, 0, 0, 0, 0); gjs->evt_fun = JSVAL_NULL; - } + } } @@ -1020,6 +1020,7 @@ GF_JSUserExtension *gjs_new() GF_SAFEALLOC(gjs, GF_GPACJSExt); gjs->rti_refresh_rate = GPAC_JS_RTI_REFRESH_RATE; + gjs->evt_fun = JSVAL_NULL; dr->load = gjs_load; dr->udta = gjs; return dr; @@ -1038,7 +1039,7 @@ void gjs_delete(GF_BaseInterface *ifce) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifdef GPAC_HAS_SPIDERMONKEY @@ -1050,7 +1051,7 @@ const u32 *QueryInterfaces() } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifdef GPAC_HAS_SPIDERMONKEY if (InterfaceType == GF_JS_USER_EXT_INTERFACE) return (GF_BaseInterface *)gjs_new(); diff --git a/modules/hyb_in/fm_fake_pull.c b/modules/hyb_in/fm_fake_pull.c index 8ffdeb3..8b46d89 100644 --- a/modules/hyb_in/fm_fake_pull.c +++ b/modules/hyb_in/fm_fake_pull.c @@ -132,7 +132,7 @@ static u32 ext_media_load_th(void *par) { od->URLString = gf_strdup("http://gpac.sourceforge.net/screenshots/lion.jpg"); od->objectDescriptorID = 0; gf_sleep(2000); //TODO: remove the sleep - gf_term_add_media(self->owner, (GF_Descriptor*)od, 0); + gf_service_declare_media(self->owner, (GF_Descriptor*)od, 0); return 0; } diff --git a/modules/hyb_in/fm_fake_push.c b/modules/hyb_in/fm_fake_push.c index b463f68..7ebd90c 100644 --- a/modules/hyb_in/fm_fake_push.c +++ b/modules/hyb_in/fm_fake_push.c @@ -159,11 +159,11 @@ u32 ext_media_load_th(void *par) { od->URLString = gf_strdup("http://gpac.sourceforge.net/screenshots/lion.jpg"); od->objectDescriptorID = 0; gf_sleep(2000); //TODO: remove the sleep - gf_term_add_media(self->owner, (GF_Descriptor*)od, 0); + gf_service_declare_media(self->owner, (GF_Descriptor*)od, 0); return 0; } -static u32 audio_gen_th(void *par) +static u32 audio_gen_th(void *par) { GF_Err e; char *data; @@ -202,10 +202,10 @@ static u32 audio_gen_th(void *par) com.map_time.timestamp = slh.compositionTimeStamp; com.map_time.reset_buffers = 0; com.base.on_channel = self->channel; - gf_term_on_command(self->owner, &com, GF_OK); + gf_service_command(self->owner, &com, GF_OK); GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[HYB In] Mapping WC Time %04d/%02d/%02d %02d:%02d:%02d and Hyb time "LLD"\n", - (now_tm->tm_year + 1900), (now_tm->tm_mon + 1), now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, - com.map_time.timestamp)); + (now_tm->tm_year + 1900), (now_tm->tm_mon + 1), now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, + com.map_time.timestamp)); } } @@ -232,7 +232,7 @@ static u32 audio_gen_th(void *par) #endif e = GetData(self, &data, &data_size, &slh); - gf_term_on_sl_packet(self->owner, self->channel, data, data_size, &slh, e); + gf_service_send_packet(self->owner, self->channel, data, data_size, &slh, e); } self->state = HYB_STATE_STOPPED; @@ -307,20 +307,20 @@ static GF_Err FM_FAKE_PUSH_Disconnect(GF_HYBMEDIA *self) static GF_Err FM_FAKE_PUSH_SetState(GF_HYBMEDIA *self, const GF_NET_CHAN_CMD state) { switch(state) { - case GF_NET_CHAN_PLAY: - self->state = HYB_STATE_PLAYING; - break; - case GF_NET_CHAN_STOP: - audio_gen_stop(self); - break; - case GF_NET_CHAN_PAUSE: - self->state = HYB_STATE_PAUSE; - break; - case GF_NET_CHAN_RESUME: - self->state = HYB_STATE_PLAYING; - break; - default: - return GF_BAD_PARAM; + case GF_NET_CHAN_PLAY: + self->state = HYB_STATE_PLAYING; + break; + case GF_NET_CHAN_STOP: + audio_gen_stop(self); + break; + case GF_NET_CHAN_PAUSE: + self->state = HYB_STATE_PAUSE; + break; + case GF_NET_CHAN_RESUME: + self->state = HYB_STATE_PLAYING; + break; + default: + return GF_BAD_PARAM; } return GF_OK; diff --git a/modules/hyb_in/hyb_in.c b/modules/hyb_in/hyb_in.c index 6fe41bd..8b1d70a 100644 --- a/modules/hyb_in/hyb_in.c +++ b/modules/hyb_in/hyb_in.c @@ -122,7 +122,7 @@ static GF_Err HYB_ConnectService(GF_InputService *plug, GF_ClientService *serv, e = hybmedia_sanity_check(hyb_in->master); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[HYB_IN] Error - object \"%s\" failed the sanity checks\n", hyb_in->master->name)); - gf_term_on_connect(hyb_in->service, NULL, e); + gf_service_connect_ack(hyb_in->service, NULL, e); return e; } GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[HYB_IN] Selected master object \"%s\" for URL: %s\n", hyb_in->master->name, url)); @@ -131,11 +131,11 @@ static GF_Err HYB_ConnectService(GF_InputService *plug, GF_ClientService *serv, e = hyb_in->master->Connect(hyb_in->master, hyb_in->service, url); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[HYB_IN] Error - cannot connect service, wrong URL %s\n", url)); - gf_term_on_connect(hyb_in->service, NULL, GF_BAD_PARAM); + gf_service_connect_ack(hyb_in->service, NULL, GF_BAD_PARAM); return e; } - gf_term_on_connect(hyb_in->service, NULL, GF_OK); - gf_term_add_media(hyb_in->service, (GF_Descriptor*)hyb_in->master->GetOD(), 0); + gf_service_connect_ack(hyb_in->service, NULL, GF_OK); + gf_service_declare_media(hyb_in->service, (GF_Descriptor*)hyb_in->master->GetOD(), 0); return GF_OK; } @@ -152,11 +152,11 @@ static GF_Err HYB_CloseService(GF_InputService *plug) e = hyb_in->master->Disconnect(hyb_in->master); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[HYB_IN] Error - cannot disconnect service %p\n", hyb_in->service)); - gf_term_on_connect(hyb_in->service, NULL, GF_BAD_PARAM); + gf_service_connect_ack(hyb_in->service, NULL, GF_BAD_PARAM); return e; } - gf_term_on_disconnect(hyb_in->service, NULL, GF_OK); + gf_service_disconnect_ack(hyb_in->service, NULL, GF_OK); return GF_OK; } @@ -175,14 +175,14 @@ static GF_Err HYB_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co if (!plug || !plug->priv) return GF_SERVICE_ERROR; - + hyb_in = (GF_HYB_In*)plug->priv; master = (GF_HYBMEDIA*)hyb_in->master; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[HYB_IN] Received Channel Connection request from service %p for %s\n", channel, url)); - + master->channel = channel; - gf_term_on_connect(hyb_in->service, channel, GF_OK); + gf_service_connect_ack(hyb_in->service, channel, GF_OK); return GF_OK; } @@ -193,7 +193,7 @@ static GF_Err HYB_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[HYB_IN] Received Channel Disconnect Service (%p) request from terminal\n", hyb_in->service)); - gf_term_on_disconnect(hyb_in->service, channel, GF_OK); + gf_service_disconnect_ack(hyb_in->service, channel, GF_OK); hyb_in->master->channel = NULL; return GF_OK; @@ -271,7 +271,7 @@ const u32 *QueryInterfaces() GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - GF_HYB_In *hyb_in; + GF_HYB_In *hyb_in; GF_InputService *plug; if (InterfaceType != GF_NET_CLIENT_INTERFACE) return NULL; diff --git a/modules/hyb_in/hyb_in.h b/modules/hyb_in/hyb_in.h index daf5df1..d93d760 100644 --- a/modules/hyb_in/hyb_in.h +++ b/modules/hyb_in/hyb_in.h @@ -51,23 +51,23 @@ typedef struct s_GF_HYBMEDIA { const char* name; /* *** static methods *** */ - + /*is url handled by this service?*/ Bool (*CanHandleURL)(const char *url); - + /*retrieve object descriptor*/ GF_ObjectDescriptor* (*GetOD)(void); /* *** other methods *** */ - + /*create/destroy the object and all its data*/ GF_Err (*Connect) (struct s_GF_HYBMEDIA *self, GF_ClientService *service, const char *url); GF_Err (*Disconnect)(struct s_GF_HYBMEDIA *self); /*request state from */ GF_Err (*SetState)(struct s_GF_HYBMEDIA *self, const GF_NET_CHAN_CMD state); - + /*in case data retrieval paradigm is pull these two functions shall not be NULL*/ GF_Err (*GetData) (struct s_GF_HYBMEDIA *self, char **out_data_ptr, u32 *out_data_size, GF_SLHeader *out_sl_hdr); /*only available when data_mode is pull*/ GF_Err (*ReleaseData)(struct s_GF_HYBMEDIA *self); /*only available when data_mode is pull*/ diff --git a/modules/img_in/bmp_dec.c b/modules/img_in/bmp_dec.c index 1665103..30c5ab8 100644 --- a/modules/img_in/bmp_dec.c +++ b/modules/img_in/bmp_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,7 +36,7 @@ typedef struct u16 ES_ID; u32 width, height, out_size, pixel_format; } BMPDec; - + #define BMPCTX() BMPDec *ctx = (BMPDec *) ((IMGDec *)ifcg->privateStack)->opaque @@ -104,11 +104,11 @@ static GF_Err BMP_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab return GF_NOT_SUPPORTED; } -static GF_Err BMP_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err BMP_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { char *pix; u32 i, j, irow, in_stride, out_stride, BPP; @@ -193,7 +193,7 @@ Bool NewBMPDec(GF_BaseDecoder *ifcd) wrap->opaque = dec; wrap->type = DEC_BMP; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = BMP_AttachStream; ifcd->DetachStream = BMP_DetachStream; ifcd->GetCapabilities = BMP_GetCapabilities; diff --git a/modules/img_in/img_dec.c b/modules/img_in/img_dec.c index 64dee92..dd08701 100644 --- a/modules/img_in/img_dec.c +++ b/modules/img_in/img_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -55,15 +55,15 @@ static u32 DEC_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, default: #ifdef GPAC_HAS_JP2 - { - char *dsi = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data : NULL; - if (dsi && (dsi[0]=='m') && (dsi[1]=='j') && (dsi[2]=='p') && (dsi[3]=='2')) - if (NewJP2Dec(dec)) return GF_CODEC_SUPPORTED; - return GF_CODEC_NOT_SUPPORTED; - } -#endif + { + char *dsi = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data : NULL; + if (dsi && (dsi[0]=='m') && (dsi[1]=='j') && (dsi[2]=='p') && (dsi[3]=='2')) + if (NewJP2Dec(dec)) return GF_CODEC_SUPPORTED; return GF_CODEC_NOT_SUPPORTED; } +#endif + return GF_CODEC_NOT_SUPPORTED; + } return GF_CODEC_NOT_SUPPORTED; } @@ -91,11 +91,11 @@ GF_BaseDecoder *NewBaseDecoder() void DeleteBaseDecoder(GF_BaseDecoder *ifcd) { IMGDec *wrap; - if (!ifcd) - return; - wrap = (IMGDec *)ifcd->privateStack; - if (!wrap) - return; + if (!ifcd) + return; + wrap = (IMGDec *)ifcd->privateStack; + if (!wrap) + return; switch (wrap->type) { case DEC_PNG: DeletePNGDec(ifcd); @@ -115,7 +115,7 @@ void DeleteBaseDecoder(GF_BaseDecoder *ifcd) break; } gf_free(wrap); - ifcd->privateStack = NULL; + ifcd->privateStack = NULL; gf_free(ifcd); } diff --git a/modules/img_in/img_in.c b/modules/img_in/img_in.c index a3f0682..8514202 100644 --- a/modules/img_in/img_in.c +++ b/modules/img_in/img_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -105,24 +105,24 @@ GF_ESD *IMG_GetESD(IMGLoader *read) } const char * IMG_MIME_TYPES[] = { - "image/jpeg", "jpeg jpg", "JPEG Images", - "image/jp2", "jp2", "JPEG2000 Images", - "image/png", "png", "PNG Images", - "image/bmp", "bmp", "MS Bitmap Images", - "image/x-png+depth", "pngd", "PNG+Depth Images", - "image/x-png+depth+mask", "pngds", "PNG+Depth+Mask Images", - "image/x-png+stereo", "pngs", "Stereo PNG Images", - NULL + "image/jpeg", "jpeg jpg", "JPEG Images", + "image/jp2", "jp2", "JPEG2000 Images", + "image/png", "png", "PNG Images", + "image/bmp", "bmp", "MS Bitmap Images", + "image/x-png+depth", "pngd", "PNG+Depth Images", + "image/x-png+depth+mask", "pngds", "PNG+Depth+Mask Images", + "image/x-png+stereo", "pngs", "Stereo PNG Images", + NULL }; -static u32 IMG_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - if (!plug){ - GF_LOG(GF_LOG_MEDIA, GF_LOG_ERROR, ("IMG_RegisterMimeTypes : plug is NULL !!\n")); - } - for (i = 0 ; IMG_MIME_TYPES[i]; i+=3) - gf_term_register_mime_type(plug, IMG_MIME_TYPES[i], IMG_MIME_TYPES[i+1], IMG_MIME_TYPES[i+2]); - return i/3; +static u32 IMG_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + if (!plug) { + GF_LOG(GF_LOG_MEDIA, GF_LOG_ERROR, ("IMG_RegisterMimeTypes : plug is NULL !!\n")); + } + for (i = 0 ; IMG_MIME_TYPES[i]; i+=3) + gf_service_register_mime(plug, IMG_MIME_TYPES[i], IMG_MIME_TYPES[i+1], IMG_MIME_TYPES[i+2]); + return i/3; } @@ -130,13 +130,13 @@ static Bool IMG_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; u32 i; - GF_LOG(GF_LOG_MEDIA, GF_LOG_INFO, ("IMG_CanHandleURL(%s)\n", url)); - if (!plug || !url) - return 0; + GF_LOG(GF_LOG_MEDIA, GF_LOG_INFO, ("IMG_CanHandleURL(%s)\n", url)); + if (!plug || !url) + return 0; sExt = strrchr(url, '.'); - for (i = 0 ; IMG_MIME_TYPES[i]; i+=3){ - if (gf_term_check_extension(plug, IMG_MIME_TYPES[i], IMG_MIME_TYPES[i+1], IMG_MIME_TYPES[i+2], sExt)) - return 1; + for (i = 0 ; IMG_MIME_TYPES[i]; i+=3) { + if (gf_service_check_mime_register(plug, IMG_MIME_TYPES[i], IMG_MIME_TYPES[i+1], IMG_MIME_TYPES[i+2], sExt)) + return 1; } return 0; } @@ -156,7 +156,7 @@ static void IMG_SetupObject(IMGLoader *read) GF_ESD *esd = IMG_GetESD(read); od->objectDescriptorID = 1; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor *)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor *)od, 0); } } @@ -169,7 +169,7 @@ void IMG_NetIO(void *cbk, GF_NETIO_Parameter *param) if (!read->dnload) return; /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); e = param->error; /*wait to get the whole file*/ @@ -190,7 +190,7 @@ void IMG_NetIO(void *cbk, GF_NETIO_Parameter *param) } } /*OK confirm*/ - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); if (!e) IMG_SetupObject(read); } @@ -198,9 +198,9 @@ void jp_download_file(GF_InputService *plug, const char *url) { IMGLoader *read = (IMGLoader *) plug->priv; - read->dnload = gf_term_download_new(read->service, url, 0, IMG_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, IMG_NetIO, read); if (!read->dnload) { - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -214,8 +214,8 @@ static GF_Err IMG_ConnectService(GF_InputService *plug, GF_ClientService *serv, IMGLoader *read = (IMGLoader *)plug->priv; read->service = serv; - if (!url) - return GF_BAD_PARAM; + if (!url) + return GF_BAD_PARAM; sExt = strrchr(url, '.'); if (!stricmp(sExt, ".jpeg") || !stricmp(sExt, ".jpg")) read->img_type = IMG_JPEG; else if (!stricmp(sExt, ".png")) read->img_type = IMG_PNG; @@ -224,7 +224,7 @@ static GF_Err IMG_ConnectService(GF_InputService *plug, GF_ClientService *serv, else if (!stricmp(sExt, ".pngs")) read->img_type = IMG_PNGS; else if (!stricmp(sExt, ".bmp")) read->img_type = IMG_BMP; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; /*remote fetch*/ @@ -239,7 +239,7 @@ static GF_Err IMG_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->data_size = (u32) gf_f64_tell(read->stream); gf_f64_seek(read->stream, 0, SEEK_SET); } - gf_term_on_connect(serv, NULL, read->stream ? GF_OK : GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, read->stream ? GF_OK : GF_URL_ERROR); if (read->stream && read->is_inline) IMG_SetupObject(read); return GF_OK; } @@ -254,10 +254,10 @@ static GF_Err IMG_CloseService(GF_InputService *plug) return GF_BAD_PARAM; if (read->stream) fclose(read->stream); read->stream = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; if (read->service) - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -287,14 +287,14 @@ static GF_Err IMG_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co u32 ES_ID=0; GF_Err e; IMGLoader *read; - if (!plug) - return 0; - read = (IMGLoader *)plug->priv; + if (!plug) + return 0; + read = (IMGLoader *)plug->priv; e = GF_SERVICE_ERROR; if (read->ch==channel) goto exit; - if (!url) - goto exit; + if (!url) + goto exit; e = GF_STREAM_NOT_FOUND; if (strstr(url, "ES_ID")) { sscanf(url, "ES_ID=%ud", &ES_ID); @@ -308,7 +308,7 @@ static GF_Err IMG_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -321,7 +321,7 @@ static GF_Err IMG_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) read->ch = NULL; e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -341,7 +341,9 @@ static GF_Err IMG_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) return GF_OK; case GF_NET_CHAN_PLAY: /*note we don't handle range since we're only dealing with images*/ - if (read->ch == com->base.on_channel) { read->done = 0; } + if (read->ch == com->base.on_channel) { + read->done = 0; + } return GF_OK; case GF_NET_CHAN_STOP: return GF_OK; diff --git a/modules/img_in/img_in.h b/modules/img_in/img_in.h index 3374235..fcc4b1b 100644 --- a/modules/img_in/img_in.h +++ b/modules/img_in/img_in.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -66,16 +66,16 @@ void DeleteJP2Dec(GF_BaseDecoder *dec); #if defined(WIN32) || defined(_WIN32_WCE) #include #else -typedef struct tagBITMAPFILEHEADER +typedef struct tagBITMAPFILEHEADER { - u16 bfType; - u32 bfSize; - u16 bfReserved1; - u16 bfReserved2; - u32 bfOffBits; + u16 bfType; + u32 bfSize; + u16 bfReserved1; + u16 bfReserved2; + u32 bfOffBits; } BITMAPFILEHEADER; -typedef struct tagBITMAPINFOHEADER{ +typedef struct tagBITMAPINFOHEADER { u32 biSize; s32 biWidth; s32 biHeight; diff --git a/modules/img_in/jp2_dec.c b/modules/img_in/jp2_dec.c index 46b87ec..02f65cd 100644 --- a/modules/img_in/jp2_dec.c +++ b/modules/img_in/jp2_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. -* +* * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. -* +* * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -69,11 +69,20 @@ static GF_Err JP2_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) gf_bs_del(bs); switch (ctx->nb_comp) { - case 1: ctx->pixel_format = GF_PIXEL_GREYSCALE; break; - case 2: ctx->pixel_format = GF_PIXEL_ALPHAGREY; break; - case 3: ctx->pixel_format = GF_PIXEL_RGB_24; break; - case 4: ctx->pixel_format = GF_PIXEL_RGBA; break; - default: return GF_NOT_SUPPORTED; + case 1: + ctx->pixel_format = GF_PIXEL_GREYSCALE; + break; + case 2: + ctx->pixel_format = GF_PIXEL_ALPHAGREY; + break; + case 3: + ctx->pixel_format = GF_PIXEL_RGB_24; + break; + case 4: + ctx->pixel_format = GF_PIXEL_RGBA; + break; + default: + return GF_NOT_SUPPORTED; } } else { bs = gf_bs_new(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, GF_BITSTREAM_READ); @@ -98,7 +107,7 @@ static GF_Err JP2_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) ctx->nb_comp = 3; ctx->out_size = 3*ctx->width*ctx->height/2; - ctx->pixel_format = GF_PIXEL_YV12; + ctx->pixel_format = GF_PIXEL_YV12; } return GF_OK; @@ -165,21 +174,21 @@ static GF_Err JP2_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab /** sample error callback expecting a FILE* client object */ -void error_callback(const char *msg, void *client_data) +void error_callback(const char *msg, void *client_data) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[OpenJPEG] Error %s", msg)); } /** sample warning callback expecting a FILE* client object */ -void warning_callback(const char *msg, void *client_data) +void warning_callback(const char *msg, void *client_data) { GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[OpenJPEG] Warning %s", msg)); } /** sample debug callback expecting no client object */ -void info_callback(const char *msg, void *client_data) +void info_callback(const char *msg, void *client_data) { GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("[OpenJPEG] Info %s", msg)); } @@ -193,11 +202,11 @@ static int int_ceildivpow2(int a, int b) { return (a + (1 << b) - 1) >> b; } -static GF_Err JP2_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err JP2_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { u32 i, w, wr, h, hr, wh; opj_dparameters_t parameters; /* decompression parameters */ @@ -263,11 +272,20 @@ static GF_Err JP2_ProcessData(GF_MediaDecoder *ifcg, ctx->out_size = ctx->width * ctx->height * ctx->nb_comp /* * ctx->bpp / 8 */; switch (ctx->nb_comp) { - case 1: ctx->pixel_format = GF_PIXEL_GREYSCALE; break; - case 2: ctx->pixel_format = GF_PIXEL_ALPHAGREY; break; - case 3: ctx->pixel_format = GF_PIXEL_RGB_24; break; - case 4: ctx->pixel_format = GF_PIXEL_RGBA; break; - default: return GF_NOT_SUPPORTED; + case 1: + ctx->pixel_format = GF_PIXEL_GREYSCALE; + break; + case 2: + ctx->pixel_format = GF_PIXEL_ALPHAGREY; + break; + case 3: + ctx->pixel_format = GF_PIXEL_RGB_24; + break; + case 4: + ctx->pixel_format = GF_PIXEL_RGBA; + break; + default: + return GF_NOT_SUPPORTED; } if ( *outBufferLength < ctx->out_size ) { @@ -315,94 +333,94 @@ static GF_Err JP2_ProcessData(GF_MediaDecoder *ifcg, else if (ctx->nb_comp==3) { if ((ctx->image->comps[0].w==2*ctx->image->comps[1].w) && (ctx->image->comps[1].w==ctx->image->comps[2].w) - && (ctx->image->comps[0].h==2*ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h)) { + && (ctx->image->comps[0].h==2*ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h)) { - if (ctx->pixel_format != GF_PIXEL_YV12) { - ctx->pixel_format = GF_PIXEL_YV12; - ctx->out_size = 3*ctx->width*ctx->height/2; - *outBufferLength = ctx->out_size; - return GF_BUFFER_TOO_SMALL; - } + if (ctx->pixel_format != GF_PIXEL_YV12) { + ctx->pixel_format = GF_PIXEL_YV12; + ctx->out_size = 3*ctx->width*ctx->height/2; + *outBufferLength = ctx->out_size; + return GF_BUFFER_TOO_SMALL; + } - if ((w==wr) && (h==hr)) { - for (i=0; iimage->comps[0].data[i]; - outBuffer++; - } - w = ctx->image->comps[1].w; - wr = int_ceildivpow2(ctx->image->comps[1].w, ctx->image->comps[1].factor); - h = ctx->image->comps[1].h; - hr = int_ceildivpow2(ctx->image->comps[1].h, ctx->image->comps[1].factor); - wh = wr*hr; - for (i=0; iimage->comps[1].data[i]; - outBuffer++; - } - for (i=0; iimage->comps[2].data[i]; - outBuffer++; - } - } else { - for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - } - w = ctx->image->comps[1].w; - wr = int_ceildivpow2(ctx->image->comps[1].w, ctx->image->comps[1].factor); - h = ctx->image->comps[1].h; - hr = int_ceildivpow2(ctx->image->comps[1].h, ctx->image->comps[1].factor); - wh = wr*hr; - for (i=0; iimage->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - } - for (i=0; iimage->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - } + if ((w==wr) && (h==hr)) { + for (i=0; iimage->comps[0].data[i]; + outBuffer++; + } + w = ctx->image->comps[1].w; + wr = int_ceildivpow2(ctx->image->comps[1].w, ctx->image->comps[1].factor); + h = ctx->image->comps[1].h; + hr = int_ceildivpow2(ctx->image->comps[1].h, ctx->image->comps[1].factor); + wh = wr*hr; + for (i=0; iimage->comps[1].data[i]; + outBuffer++; + } + for (i=0; iimage->comps[2].data[i]; + outBuffer++; + } + } else { + for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; } + w = ctx->image->comps[1].w; + wr = int_ceildivpow2(ctx->image->comps[1].w, ctx->image->comps[1].factor); + h = ctx->image->comps[1].h; + hr = int_ceildivpow2(ctx->image->comps[1].h, ctx->image->comps[1].factor); + wh = wr*hr; + for (i=0; iimage->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + } + for (i=0; iimage->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + } + } } else if ((ctx->image->comps[0].w==ctx->image->comps[1].w) && (ctx->image->comps[1].w==ctx->image->comps[2].w) - && (ctx->image->comps[0].h==ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h)) { - - if ((w==wr) && (h==hr)) { - for (i=0; iimage->comps[0].data[i]; - outBuffer[idx+1] = ctx->image->comps[1].data[i]; - outBuffer[idx+2] = ctx->image->comps[2].data[i]; - } - } else { - for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - outBuffer[idx+1] = ctx->image->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - outBuffer[idx+2] = ctx->image->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - } + && (ctx->image->comps[0].h==ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h)) { + + if ((w==wr) && (h==hr)) { + for (i=0; iimage->comps[0].data[i]; + outBuffer[idx+1] = ctx->image->comps[1].data[i]; + outBuffer[idx+2] = ctx->image->comps[2].data[i]; + } + } else { + for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + outBuffer[idx+1] = ctx->image->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + outBuffer[idx+2] = ctx->image->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; } + } } } else if (ctx->nb_comp==4) { if ((ctx->image->comps[0].w==ctx->image->comps[1].w) && (ctx->image->comps[1].w==ctx->image->comps[2].w) && (ctx->image->comps[2].w==ctx->image->comps[3].w) - && (ctx->image->comps[0].h==ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h) && (ctx->image->comps[2].h==ctx->image->comps[3].h)) { - - if ((w==wr) && (h==hr)) { - for (i=0; iimage->comps[0].data[i]; - outBuffer[idx+1] = ctx->image->comps[1].data[i]; - outBuffer[idx+2] = ctx->image->comps[2].data[i]; - outBuffer[idx+3] = ctx->image->comps[3].data[i]; - } - } else { - for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - outBuffer[idx+1] = ctx->image->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - outBuffer[idx+2] = ctx->image->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - outBuffer[idx+3] = ctx->image->comps[3].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - } + && (ctx->image->comps[0].h==ctx->image->comps[1].h) && (ctx->image->comps[1].h==ctx->image->comps[2].h) && (ctx->image->comps[2].h==ctx->image->comps[3].h)) { + + if ((w==wr) && (h==hr)) { + for (i=0; iimage->comps[0].data[i]; + outBuffer[idx+1] = ctx->image->comps[1].data[i]; + outBuffer[idx+2] = ctx->image->comps[2].data[i]; + outBuffer[idx+3] = ctx->image->comps[3].data[i]; + } + } else { + for (i=0; iimage->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + outBuffer[idx+1] = ctx->image->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + outBuffer[idx+2] = ctx->image->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; + outBuffer[idx+3] = ctx->image->comps[3].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; } + } } - } + } /* gf_free( image data structure */ if (ctx->image) { @@ -432,7 +450,7 @@ Bool NewJP2Dec(GF_BaseDecoder *ifcd) wrap->opaque = dec; wrap->type = DEC_JPEG; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = JP2_AttachStream; ifcd->DetachStream = JP2_DetachStream; ifcd->GetCapabilities = JP2_GetCapabilities; diff --git a/modules/img_in/jpeg_dec.c b/modules/img_in/jpeg_dec.c index d5542c3..db9b768 100644 --- a/modules/img_in/jpeg_dec.c +++ b/modules/img_in/jpeg_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -99,11 +99,11 @@ static GF_Err JPEG_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa return GF_NOT_SUPPORTED; } -static GF_Err JPEG_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err JPEG_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { #ifndef GPAC_DISABLE_AV_PARSERS GF_Err e; @@ -111,8 +111,12 @@ static GF_Err JPEG_ProcessData(GF_MediaDecoder *ifcg, e = gf_img_jpeg_dec(inBuffer, inBufferLength, &ctx->width, &ctx->height, &ctx->pixel_format, outBuffer, outBufferLength, ctx->BPP); switch (ctx->pixel_format) { - case GF_PIXEL_GREYSCALE: ctx->BPP = 1; break; - case GF_PIXEL_RGB_24: ctx->BPP = 3; break; + case GF_PIXEL_GREYSCALE: + ctx->BPP = 1; + break; + case GF_PIXEL_RGB_24: + ctx->BPP = 3; + break; } ctx->out_size = *outBufferLength; return e; @@ -135,7 +139,7 @@ Bool NewJPEGDec(GF_BaseDecoder *ifcd) wrap->opaque = dec; wrap->type = DEC_JPEG; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = JPEG_AttachStream; ifcd->DetachStream = JPEG_DetachStream; ifcd->GetCapabilities = JPEG_GetCapabilities; diff --git a/modules/img_in/png_dec.c b/modules/img_in/png_dec.c index f42ce62..cc9727c 100644 --- a/modules/img_in/png_dec.c +++ b/modules/img_in/png_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -33,7 +33,7 @@ typedef struct u32 BPP, width, height, out_size, pixel_format; u32 aux_type; } PNGDec; - + #define PNGCTX() PNGDec *ctx = (PNGDec *) ((IMGDec *)ifcg->privateStack)->opaque @@ -113,11 +113,11 @@ static GF_Err PNG_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab } -static GF_Err PNG_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err PNG_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { #ifndef GPAC_DISABLE_AV_PARSERS GF_Err e; @@ -126,15 +126,19 @@ static GF_Err PNG_ProcessData(GF_MediaDecoder *ifcg, e = gf_img_png_dec(inBuffer, inBufferLength, &ctx->width, &ctx->height, &ctx->pixel_format, outBuffer, outBufferLength); switch (ctx->pixel_format) { - case GF_PIXEL_GREYSCALE: ctx->BPP = 1; break; - case GF_PIXEL_ALPHAGREY: ctx->BPP = 2; break; - case GF_PIXEL_RGB_24: + case GF_PIXEL_GREYSCALE: + ctx->BPP = 1; + break; + case GF_PIXEL_ALPHAGREY: + ctx->BPP = 2; + break; + case GF_PIXEL_RGB_24: ctx->BPP = 3; if (ctx->aux_type==3) ctx->pixel_format = GF_PIXEL_RGBS; break; case GF_PIXEL_RGBA: case GF_PIXEL_RGBD: - ctx->BPP = 4; + ctx->BPP = 4; if (ctx->aux_type==1) ctx->pixel_format = GF_PIXEL_RGBD; else if (ctx->aux_type==2) ctx->pixel_format = GF_PIXEL_RGBDS; else if (ctx->aux_type==3) ctx->pixel_format = GF_PIXEL_RGBAS; @@ -160,7 +164,7 @@ Bool NewPNGDec(GF_BaseDecoder *ifcd) wrap->opaque = dec; wrap->type = DEC_PNG; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = PNG_AttachStream; ifcd->DetachStream = PNG_DetachStream; ifcd->GetCapabilities = PNG_GetCapabilities; diff --git a/modules/ios_cam/CameraObject.h b/modules/ios_cam/CameraObject.h index 166b914..e3470f7 100644 --- a/modules/ios_cam/CameraObject.h +++ b/modules/ios_cam/CameraObject.h @@ -29,23 +29,23 @@ #include "cam_wrap.h" @interface CameraObject : NSObject - + { - // AVCaptureSession *session; - // AVCaptureDevice *device; - AVCaptureDeviceInput *input; - AVCaptureVideoDataOutput *output; - - int desiredWidth; - int desiredHeight; - int desiredColor; - - int m_width; - int m_height; - int m_color; - int m_stride; - - GetPixelsCallback *callback; + // AVCaptureSession *session; + // AVCaptureDevice *device; + AVCaptureDeviceInput *input; + AVCaptureVideoDataOutput *output; + + int desiredWidth; + int desiredHeight; + int desiredColor; + + int m_width; + int m_height; + int m_color; + int m_stride; + + GetPixelsCallback *callback; } @property (retain) AVCaptureSession *captureSession; @@ -58,7 +58,7 @@ - (int) setCallback:(GetPixelsCallback*) func; - (void)captureOutput:(AVCaptureOutput *)captureOutput -didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer - fromConnection:(AVCaptureConnection *)connection; + didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer + fromConnection:(AVCaptureConnection *)connection; @end diff --git a/modules/ios_cam/cam_wrap.h b/modules/ios_cam/cam_wrap.h index 8604330..0321ef6 100644 --- a/modules/ios_cam/cam_wrap.h +++ b/modules/ios_cam/cam_wrap.h @@ -47,7 +47,7 @@ int CAM_Stop(void* inst); int CAM_IsStarted(void* inst); int CAM_SetCallback(void* inst, GetPixelsCallback *callback); - + #ifdef __cplusplus } #endif diff --git a/modules/ios_cam/ios_cam.c b/modules/ios_cam/ios_cam.c index cec372b..08b5ef9 100644 --- a/modules/ios_cam/ios_cam.c +++ b/modules/ios_cam/ios_cam.c @@ -50,23 +50,23 @@ typedef struct /*the service we're responsible for*/ GF_ClientService *service; LPNETCHANNEL channel; - + /*input file*/ u32 time_scale; - + u32 base_track_id; - + struct _tag_terminal *term; - + u32 cntr; - + u32 width; u32 height; - + Bool started; - - void* camInst; - + + void* camInst; + } IOSCamCtx; IOSCamCtx* globReader = NULL; @@ -78,7 +78,7 @@ void processFrameBuf( unsigned char* data, unsigned int dataSize); Bool CAM_CanHandleURL(GF_InputService *plug, const char *url) { if (!strnicmp(url, "hw://camera", 11)) return 1; - + return 0; } @@ -87,25 +87,25 @@ GF_Err CAM_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c IOSCamCtx *read; if (!plug || !plug->priv || !serv) return GF_SERVICE_ERROR; read = (IOSCamCtx *) plug->priv; - + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] CAM_ConnectService: %d\n", gf_th_id())); - - globReader = read; - + + globReader = read; + read->input = plug; read->service = serv; read->base_track_id = 1; read->time_scale = 1000; - + read->term = serv->term; - + read->camInst = CAM_CreateInstance(); - CAM_SetCallback(read->camInst, processFrameBuf); - + CAM_SetCallback(read->camInst, processFrameBuf); + /*reply to user*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); //if (read->no_service_desc) isor_declare_objects(read); - + return GF_OK; } @@ -115,14 +115,14 @@ GF_Err CAM_CloseService(GF_InputService *plug) IOSCamCtx *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (IOSCamCtx *) plug->priv; - + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] CAM_CloseService: %d\n", gf_th_id())); - + reply = GF_OK; - + CAM_DestroyInstance(&read->camInst); - - gf_term_on_disconnect(read->service, NULL, reply); + + gf_service_disconnect_ack(read->service, NULL, reply); return GF_OK; } @@ -138,46 +138,46 @@ static GF_Descriptor *CAM_GetServiceDesc(GF_InputService *plug, u32 expect_type, GF_BitStream *bs; char *buf; u32 buf_size; - s32 color; - s32 stride; + s32 color; + s32 stride; if (!plug || !plug->priv) return NULL; read = (IOSCamCtx *) plug->priv; - + trackID = read->base_track_id; read->base_track_id = 0; - + if (trackID && (expect_type==GF_MEDIA_OBJECT_VIDEO) ) { od = (GF_ObjectDescriptor *) gf_odf_desc_new(GF_ODF_OD_TAG); od->objectDescriptorID = 1; - + esd = gf_odf_desc_esd_new(0); esd->slConfig->timestampResolution = 1000; esd->decoderConfig->streamType = GF_STREAM_VISUAL; esd->ESID = 1; esd->decoderConfig->objectTypeIndication = GPAC_OTI_RAW_MEDIA_STREAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - - CAM_GetCurrentFormat(read->camInst, &read->width, &read->height, &color, &stride); - + + CAM_GetCurrentFormat(read->camInst, &read->width, &read->height, &color, &stride); + gf_bs_write_u32(bs, CAM_PIXEL_FORMAT); // fourcc gf_bs_write_u16(bs, read->width); // width gf_bs_write_u16(bs, read->height); // height gf_bs_write_u32(bs, read->height * stride); // framesize gf_bs_write_u32(bs, stride); // stride - gf_bs_write_u8(bs, 1); // is_flipped - + gf_bs_write_u8(bs, 1); // is_flipped + gf_bs_align(bs); gf_bs_get_content(bs, &buf, &buf_size); gf_bs_del(bs); - + esd->decoderConfig->decoderSpecificInfo->data = buf; esd->decoderConfig->decoderSpecificInfo->dataLength = buf_size; - + gf_list_add(od->ESDescriptors, esd); return (GF_Descriptor *) od; } - + return NULL; } @@ -187,19 +187,19 @@ GF_Err CAM_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const cha IOSCamCtx *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (IOSCamCtx *) plug->priv; - + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] CAM_ConnectChannel: %d\n", gf_th_id())); - + e = GF_OK; if (upstream) { e = GF_ISOM_INVALID_FILE; } - + read->channel = channel; - + camStartCamera(read); - - gf_term_on_connect(read->service, channel, e); + + gf_service_connect_ack(read->service, channel, e); return e; } @@ -209,14 +209,14 @@ GF_Err CAM_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) IOSCamCtx *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (IOSCamCtx *) plug->priv; - + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] CAM_DisconnectChannel: %d\n", gf_th_id())); - + e = GF_OK; - + camStopCamera(read); - - gf_term_on_disconnect(read->service, channel, e); + + gf_service_disconnect_ack(read->service, channel, e); return e; } @@ -225,7 +225,7 @@ int* decodeYUV420SP( char* yuv420sp, int width, int height) int frameSize = width * height; int j, yp, uvp, i, y, y1192, r, g, b, u, v; int ti, tj; - + int* rgb = (int*)gf_malloc(width*height*4); for (j = 0, yp = 0, tj=height-1; j < height; j++, tj--) { @@ -239,12 +239,12 @@ int* decodeYUV420SP( char* yuv420sp, int width, int height) v = (0xff & yuv420sp[uvp++]) - 128; u = (0xff & yuv420sp[uvp++]) - 128; } - + y1192 = 1192 * y; r = (y1192 + 1634 * v); g = (y1192 - 833 * v - 400 * u); b = (y1192 + 2066 * u); - + if (r < 0) r = 0; else if (r > 262143) @@ -257,11 +257,11 @@ int* decodeYUV420SP( char* yuv420sp, int width, int height) b = 0; else if (b > 262143) b = 262143; - + rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) - | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); - // rgb[ti+tj] = 0xff000000 | ((r << 6) & 0xff0000) - // | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); + | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); + // rgb[ti+tj] = 0xff000000 | ((r << 6) & 0xff0000) + // | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); } } return rgb; @@ -272,34 +272,34 @@ void processFrameBuf( unsigned char* data, unsigned int dataSize) IOSCamCtx* ctx = globReader; GF_SLHeader hdr; u32 cts = 0; - + cts = gf_term_get_time(ctx->term); - + memset(&hdr, 0, sizeof(hdr)); hdr.compositionTimeStampFlag = 1; hdr.compositionTimeStamp = cts; - gf_term_on_sl_packet(ctx->service, ctx->channel, (void*)data, dataSize, &hdr, GF_OK); + gf_service_send_packet(ctx->service, ctx->channel, (void*)data, dataSize, &hdr, GF_OK); } void camStartCamera(IOSCamCtx *read) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] startCamera: %d\n", gf_th_id())); - + //CAM_Start(read->camInst); } void camStopCamera(IOSCamCtx *read) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] stopCamera: %d\n", gf_th_id())); - - //CAM_Stop(read->camInst); + + //CAM_Stop(read->camInst); } void pauseCamera(IOSCamCtx *read) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] pauseCamera: %d\n", gf_th_id())); - + read->started = 0; CAM_Stop(read->camInst); } @@ -307,7 +307,7 @@ void pauseCamera(IOSCamCtx *read) void resumeCamera(IOSCamCtx *read) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[ANDROID_CAMERA] resumeCamera: %d\n", gf_th_id())); - + read->started = 1; CAM_Start(read->camInst); } @@ -320,7 +320,7 @@ GF_Err CAM_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) u32 buf_size; if (!plug || !plug->priv || !com) return GF_SERVICE_ERROR; read = (IOSCamCtx *) plug->priv; - + if (com->command_type==GF_NET_SERVICE_INFO) { return GF_OK; } @@ -328,48 +328,48 @@ GF_Err CAM_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) return GF_NOT_SUPPORTED; } if (!com->base.on_channel) return GF_NOT_SUPPORTED; - + switch (com->command_type) { - case GF_NET_CHAN_INTERACTIVE: - return GF_OK; - case GF_NET_CHAN_BUFFER: - com->buffer.max = com->buffer.min = 0; - return GF_OK; - case GF_NET_CHAN_PLAY: - resumeCamera(read); - return GF_OK; - case GF_NET_CHAN_STOP: - pauseCamera(read); - return GF_OK; - /*nothing to do on MP4 for channel config*/ - case GF_NET_CHAN_CONFIG: - return GF_OK; - case GF_NET_CHAN_GET_PIXEL_AR: - return 1<<16;//gf_isom_get_pixel_aspect_ratio(read->mov, ch->track, 1, &com->par.hSpacing, &com->par.vSpacing); - case GF_NET_CHAN_GET_DSI: - { - s32 color; - s32 stride; - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cam get DSI\n")); - /*it may happen that there are conflicting config when using ESD URLs...*/ - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - - CAM_GetCurrentFormat(read->camInst, &read->width, &read->height, &color, &stride); - - gf_bs_write_u32(bs, CAM_PIXEL_FORMAT); // fourcc - gf_bs_write_u16(bs, read->width); // width - gf_bs_write_u16(bs, read->height); // height - gf_bs_write_u32(bs, read->height * stride); // framesize - gf_bs_write_u32(bs, stride); // stride - - gf_bs_align(bs); - gf_bs_get_content(bs, &buf, &buf_size); - gf_bs_del(bs); - - com->get_dsi.dsi = buf; - com->get_dsi.dsi_len = buf_size; - return GF_OK; - } + case GF_NET_CHAN_INTERACTIVE: + return GF_OK; + case GF_NET_CHAN_BUFFER: + com->buffer.max = com->buffer.min = 0; + return GF_OK; + case GF_NET_CHAN_PLAY: + resumeCamera(read); + return GF_OK; + case GF_NET_CHAN_STOP: + pauseCamera(read); + return GF_OK; + /*nothing to do on MP4 for channel config*/ + case GF_NET_CHAN_CONFIG: + return GF_OK; + case GF_NET_CHAN_GET_PIXEL_AR: + return 1<<16;//gf_isom_get_pixel_aspect_ratio(read->mov, ch->track, 1, &com->par.hSpacing, &com->par.vSpacing); + case GF_NET_CHAN_GET_DSI: + { + s32 color; + s32 stride; + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cam get DSI\n")); + /*it may happen that there are conflicting config when using ESD URLs...*/ + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + + CAM_GetCurrentFormat(read->camInst, &read->width, &read->height, &color, &stride); + + gf_bs_write_u32(bs, CAM_PIXEL_FORMAT); // fourcc + gf_bs_write_u16(bs, read->width); // width + gf_bs_write_u16(bs, read->height); // height + gf_bs_write_u32(bs, read->height * stride); // framesize + gf_bs_write_u32(bs, stride); // stride + + gf_bs_align(bs); + gf_bs_get_content(bs, &buf, &buf_size); + gf_bs_del(bs); + + com->get_dsi.dsi = buf; + com->get_dsi.dsi_len = buf_size; + return GF_OK; + } } return GF_NOT_SUPPORTED; } @@ -387,7 +387,7 @@ GF_InputService *CAM_client_load() plug->ConnectChannel = CAM_ConnectChannel; plug->DisconnectChannel = CAM_DisconnectChannel; plug->ServiceCommand = CAM_ServiceCommand; - + GF_SAFEALLOC(reader, IOSCamCtx); plug->priv = reader; return plug; @@ -397,7 +397,7 @@ void CAM_client_del(GF_BaseInterface *bi) { GF_InputService *plug = (GF_InputService *) bi; IOSCamCtx *read = (IOSCamCtx *)plug->priv; - + gf_free(read); gf_free(bi); } @@ -424,7 +424,9 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_NET_CLIENT_INTERFACE: CAM_client_del(ifce); break; + case GF_NET_CLIENT_INTERFACE: + CAM_client_del(ifce); + break; } } diff --git a/modules/ios_mpegv/SensorAccess.h b/modules/ios_mpegv/SensorAccess.h index 045c540..bff9957 100644 --- a/modules/ios_mpegv/SensorAccess.h +++ b/modules/ios_mpegv/SensorAccess.h @@ -14,10 +14,10 @@ @interface SensorAccess : NSObject { - SensorDataCallback* sensorCallbak; - void* userData; - int sensorType; - int gpsActive; + SensorDataCallback* sensorCallbak; + void* userData; + int sensorType; + int gpsActive; } @property (nonatomic, retain) CMMotionManager *motionManager; diff --git a/modules/ios_mpegv/ios_mpegv.c b/modules/ios_mpegv/ios_mpegv.c index d2a5643..a64c35e 100644 --- a/modules/ios_mpegv/ios_mpegv.c +++ b/modules/ios_mpegv/ios_mpegv.c @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ /*driver interfaces*/ @@ -42,8 +42,8 @@ typedef struct char sensor[50]; u16 sensorIOSType; u8 isAttached; - - GF_Mutex* mx; + + GF_Mutex* mx; void* inst; @@ -54,7 +54,7 @@ typedef struct Bool MPEGVS_RegisterDevice(struct __input_device *dr, const char *urn, GF_BitStream *dsi, void (*AddField)(struct __input_device *_this, u32 fieldType, const char *name)) { MPEGVSCTX; - + //"MPEG-V:siv:OrientationSensorType" if ( strnicmp(urn, "MPEG-V", 6) ) @@ -65,7 +65,7 @@ Bool MPEGVS_RegisterDevice(struct __input_device *dr, const char *urn, GF_BitStr GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[MPEG-V] No sensor type specified\n")); return 0; } - + if ( strnicmp(urn+6, ":siv:", 5) ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[MPEG-V] Not valid sensor type specified\n")); @@ -153,18 +153,18 @@ void MPEGVSensorCallback( void* ptr, const char* data) char *buf; u32 buf_size; float x, y, z, a, b; - struct __input_device * dr = (struct __input_device *)ptr; + struct __input_device * dr = (struct __input_device *)ptr; MPEGVSCTX; - - if (!gf_mx_try_lock(rc->mx)) - return; - + + if (!gf_mx_try_lock(rc->mx)) + return; + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - if ( rc->sensorIOSType == SENSOR_ACCELEROMETER - || rc->sensorIOSType == SENSOR_GYROSCOPE - //|| rc->sensorIOSType == 3 - || rc->sensorIOSType == SENSOR_MAGNETOMETER ) + if ( rc->sensorIOSType == SENSOR_ACCELEROMETER + || rc->sensorIOSType == SENSOR_GYROSCOPE + //|| rc->sensorIOSType == 3 + || rc->sensorIOSType == SENSOR_MAGNETOMETER ) { sscanf(data, "%f;%f;%f;", &x, &y, &z); gf_bs_write_int(bs, 1, 1); @@ -172,17 +172,15 @@ void MPEGVSensorCallback( void* ptr, const char* data) gf_bs_write_float(bs, y); gf_bs_write_float(bs, z); } - else - if ( rc->sensorIOSType == 5 - || rc->sensorIOSType == 6 ) + else if ( rc->sensorIOSType == 5 + || rc->sensorIOSType == 6 ) { sscanf(data, "%f;", &x); - + gf_bs_write_int(bs, 1, 1); gf_bs_write_float(bs, x); } - else - if ( rc->sensorIOSType == 11 ) + else if ( rc->sensorIOSType == 11 ) { sscanf(data, "%f;%f;%f;", &x, &y, &z); @@ -192,8 +190,7 @@ void MPEGVSensorCallback( void* ptr, const char* data) gf_bs_write_float(bs, z); /*gf_bs_write_float(bs, q);*/ } - else - if ( rc->sensorIOSType == SENSOR_GPS ) + else if ( rc->sensorIOSType == SENSOR_GPS ) { sscanf(data, "%f;%f;%f;%f;%f;", &x, &y, &z, &a, &b); @@ -214,42 +211,42 @@ void MPEGVSensorCallback( void* ptr, const char* data) dr->DispatchFrame(dr, (u8*)buf, buf_size); gf_free(buf); - - gf_mx_v(rc->mx); + + gf_mx_v(rc->mx); } void MPEGVS_Start(struct __input_device * dr) { MPEGVSCTX; - - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] Start: %d\n", gf_th_id())); - - if ( rc->inst ) { - SENS_Stop(rc->inst); - SENS_DestroyInstance(&rc->inst); - } - - rc->inst = SENS_CreateInstance(); - SENS_SetSensorType(rc->inst, rc->sensorIOSType); - SENS_SetCallback(rc->inst, MPEGVSensorCallback, dr); - SENS_Start(rc->inst); + + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] Start: %d\n", gf_th_id())); + + if ( rc->inst ) { + SENS_Stop(rc->inst); + SENS_DestroyInstance(&rc->inst); + } + + rc->inst = SENS_CreateInstance(); + SENS_SetSensorType(rc->inst, rc->sensorIOSType); + SENS_SetCallback(rc->inst, MPEGVSensorCallback, dr); + SENS_Start(rc->inst); } void MPEGVS_Stop(struct __input_device * dr) { MPEGVSCTX; - - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] Stop: %d\n", gf_th_id())); - SENS_Stop(rc->inst); - SENS_DestroyInstance(&rc->inst); + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[MPEG-V_IN] Stop: %d\n", gf_th_id())); + + SENS_Stop(rc->inst); + SENS_DestroyInstance(&rc->inst); } GF_InputSensorDevice* NewMPEGVSInputSesor() { MPEGVSensorContext* ctx = NULL; GF_InputSensorDevice* driv = NULL; - + driv = (GF_InputSensorDevice *) gf_malloc(sizeof(GF_InputSensorDevice)); memset(driv, 0, sizeof(GF_InputSensorDevice)); GF_REGISTER_MODULE_INTERFACE(driv, GF_INPUT_DEVICE_INTERFACE, "MPEG-V Sensors Input Module", "gpac distribution"); @@ -260,8 +257,8 @@ GF_InputSensorDevice* NewMPEGVSInputSesor() ctx = (MPEGVSensorContext*) gf_malloc (sizeof(MPEGVSensorContext)); memset(ctx, 0, sizeof(MPEGVSensorContext)); - ctx->mx = gf_mx_new(NULL); - + ctx->mx = gf_mx_new(NULL); + driv->udta = (void*)ctx; return driv; @@ -270,21 +267,21 @@ GF_InputSensorDevice* NewMPEGVSInputSesor() void DeleteMPEGVSInputSensor(GF_InputSensorDevice* dev) { MPEGVS_Stop(dev); - MPEGVSensorContext* ctx = (MPEGVSensorContext*)dev->udta; - gf_mx_del(ctx->mx); + MPEGVSensorContext* ctx = (MPEGVSensorContext*)dev->udta; + gf_mx_del(ctx->mx); gf_free(dev->udta); gf_free(dev); } /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_INPUT_DEVICE_INTERFACE, 0 }; - return si; + return si; } /*interface create*/ diff --git a/modules/ios_mpegv/sensor_wrap.h b/modules/ios_mpegv/sensor_wrap.h index 5dd1d5c..9666d40 100644 --- a/modules/ios_mpegv/sensor_wrap.h +++ b/modules/ios_mpegv/sensor_wrap.h @@ -12,30 +12,30 @@ #ifdef __cplusplus extern "C" { #endif - - #define SENSOR_ACCELEROMETER 0 - #define SENSOR_GYROSCOPE 1 - #define SENSOR_MAGNETOMETER 2 - #define SENSOR_GPS 3 - - typedef void (SensorDataCallback)(void* user, const char* data); - - void* SENS_CreateInstance(); - - int SENS_DestroyInstance(void** inst); - - int SENS_SetSensorType(void* inst, int type); - - int SENS_GetCurrentSensorType(void* inst); - - int SENS_Start(void* inst); - - int SENS_Stop(void* inst); - - int SENS_IsStarted(void* inst); - - int SENS_SetCallback(void* inst, SensorDataCallback *callback, void* user); - + +#define SENSOR_ACCELEROMETER 0 +#define SENSOR_GYROSCOPE 1 +#define SENSOR_MAGNETOMETER 2 +#define SENSOR_GPS 3 + +typedef void (SensorDataCallback)(void* user, const char* data); + +void* SENS_CreateInstance(); + +int SENS_DestroyInstance(void** inst); + +int SENS_SetSensorType(void* inst, int type); + +int SENS_GetCurrentSensorType(void* inst); + +int SENS_Start(void* inst); + +int SENS_Stop(void* inst); + +int SENS_IsStarted(void* inst); + +int SENS_SetCallback(void* inst, SensorDataCallback *callback, void* user); + #ifdef __cplusplus } #endif diff --git a/modules/ismacryp/isma_ea.c b/modules/ismacryp/isma_ea.c index cc9c4a0..5eb282e 100644 --- a/modules/ismacryp/isma_ea.c +++ b/modules/ismacryp/isma_ea.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,7 +42,7 @@ enum ISMAEA_STATE_PLAY, }; -typedef struct +typedef struct { GF_Crypt *crypt; char key[16], salt[8]; @@ -85,7 +85,7 @@ static GF_Err ISMA_GetGPAC_KMS(ISMAEAPriv *priv, GF_Channel *ch, const char *kms is supported as a proof of concept, crypto and IPMP being the last priority on gpac...*/ GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[CENC/ISMA] Fetching ISMACryp key for channel %d\n", ch->esd->ESID) ); - sess = gf_term_download_new(ch->service, kms_url, 0, ISMA_KMS_NetIO, ch); + sess = gf_service_download_new(ch->service, kms_url, 0, ISMA_KMS_NetIO, ch); if (!sess) return GF_IO_ERR; /*start our download (threaded)*/ gf_dm_sess_process(sess); @@ -97,7 +97,7 @@ static GF_Err ISMA_GetGPAC_KMS(ISMAEAPriv *priv, GF_Channel *ch, const char *kms if (e==GF_EOS) { e = gf_ismacryp_gpac_get_info(ch->esd->ESID, (char *) gf_dm_sess_get_cache_name(sess), priv->key, priv->salt); } - gf_term_download_del(sess); + gf_service_download_del(sess); return e; } @@ -131,16 +131,18 @@ static GF_Err ISMA_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) if (strlen(cfg->kms_uri) < 10+32+16) return GF_NON_COMPLIANT_BITSTREAM; k = (char *)cfg->kms_uri + 10; - for (i=0; i<16; i++) { - szT[0] = k[2*i]; szT[1] = k[2*i + 1]; - sscanf(szT, "%X", &v); + for (i=0; i<16; i++) { + szT[0] = k[2*i]; + szT[1] = k[2*i + 1]; + sscanf(szT, "%X", &v); priv->key[i] = v; } k = (char *)cfg->kms_uri + 10 + 32; - for (i=0; i<8; i++) { - szT[0] = k[2*i]; szT[1] = k[2*i + 1]; - sscanf(szT, "%X", &v); + for (i=0; i<8; i++) { + szT[0] = k[2*i]; + szT[1] = k[2*i + 1]; + sscanf(szT, "%X", &v); priv->salt[i] = v; } } @@ -159,8 +161,10 @@ static GF_Err ISMA_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) else { static u8 mysalt[] = { 8,7,6,5,4,3,2,1, 0,0,0,0,0,0,0,0 }; static u8 mykey[][16] = { - { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 } }; + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 + } + }; memcpy(priv->salt, mysalt, sizeof(char)*8); memcpy(priv->key, mykey, sizeof(char)*16); } @@ -173,14 +177,14 @@ static GF_Err ISMA_Access(ISMAEAPriv *priv, GF_IPMPEvent *evt) { GF_Err e; char IV[16]; - + if (evt->event_type==GF_IPMP_TOOL_GRANT_ACCESS) { if (priv->state != ISMAEA_STATE_SETUP) return GF_SERVICE_ERROR; assert(!priv->crypt); //if (!priv->nb_allow_play) return GF_AUTHENTICATION_FAILURE; //priv->nb_allow_play--; - + /*init decrypter*/ priv->crypt = gf_crypt_open("AES-128", "CTR"); if (!priv->crypt) return GF_IO_ERR; @@ -206,7 +210,7 @@ static GF_Err ISMA_Access(ISMAEAPriv *priv, GF_IPMPEvent *evt) static GF_Err ISMA_ProcessData(ISMAEAPriv *priv, GF_IPMPEvent *evt) { if (!priv->crypt) return GF_SERVICE_ERROR; - + if (!evt->is_encrypted) return GF_OK; /*resync IV*/ @@ -268,14 +272,14 @@ static GF_Err OMA_DRM_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) if (!cfg->kms_uri) return GF_NON_COMPLIANT_BITSTREAM; priv->state = ISMAEA_STATE_SETUP; //priv->nb_allow_play = 1; - + /*we have preview*/ if (priv->preview_range) return GF_OK; return GF_NOT_SUPPORTED; } #endif -static GF_Err CENC_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) +static GF_Err CENC_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) { GF_CENCConfig *cfg = (GF_CENCConfig*)evt->config_data; u32 i; @@ -353,14 +357,14 @@ static GF_Err CENC_Setup(ISMAEAPriv *priv, GF_IPMPEvent *evt) } static GF_Err CENC_Access(ISMAEAPriv *priv, GF_IPMPEvent *evt) -{ +{ if (evt->event_type==GF_IPMP_TOOL_GRANT_ACCESS) { if (priv->state != ISMAEA_STATE_SETUP) return GF_SERVICE_ERROR; assert(!priv->crypt); //if (!priv->nb_allow_play) return GF_AUTHENTICATION_FAILURE; //priv->nb_allow_play--; - + /*open decrypter - we do NOT initialize decrypter; it wil be done when we decrypt the first crypted sample*/ if (priv->is_cenc) priv->crypt = gf_crypt_open("AES-128", "CTR"); @@ -400,8 +404,8 @@ static GF_Err CENC_ProcessData(ISMAEAPriv *priv, GF_IPMPEvent *evt) max_size = 4096; if (!priv->crypt) return GF_SERVICE_ERROR; - - if (!evt->is_encrypted || !evt->IV_size) return GF_OK; + + if (!evt->is_encrypted || !evt->IV_size || !evt->saiz) return GF_OK; cyphertext_bs = gf_bs_new(evt->data, evt->data_size, GF_BITSTREAM_READ); sai_bs = gf_bs_new(evt->sai, evt->saiz, GF_BITSTREAM_READ); @@ -465,70 +469,82 @@ static GF_Err CENC_ProcessData(ISMAEAPriv *priv, GF_IPMPEvent *evt) } } - subsample_count = 0; - BSO = 0; - while (gf_bs_available(cyphertext_bs)) { - assert(subsample_count < sai->subsample_count); - - /*read clear data and write it to pleintext bitstream*/ - if (max_size < sai->subsamples[subsample_count].bytes_clear_data) { - buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_clear_data); - max_size = sai->subsamples[subsample_count].bytes_clear_data; - } - gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); - gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); - - /*now read encrypted data, decrypted it and write to pleintext bitstream*/ - if (max_size < sai->subsamples[subsample_count].bytes_encrypted_data) { - buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_encrypted_data); - max_size = sai->subsamples[subsample_count].bytes_encrypted_data; - } - gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); - gf_crypt_decrypt(priv->crypt, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); - gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + //sub-sample encryption + if (sai->subsample_count) { + subsample_count = 0; + BSO = 0; + while (gf_bs_available(cyphertext_bs)) { + if (subsample_count >= sai->subsample_count) + break; + + /*read clear data and write it to pleintext bitstream*/ + if (max_size < sai->subsamples[subsample_count].bytes_clear_data) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_clear_data); + max_size = sai->subsamples[subsample_count].bytes_clear_data; + } + gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); + gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); - /*update IV for next subsample*/ - if (priv->is_cenc) { - BSO += sai->subsamples[subsample_count].bytes_encrypted_data; - if (gf_bs_available(cyphertext_bs)) { - char next_IV[17]; - u64 prev_block_count, salt_portion, block_count_portion; - u32 remain; - GF_BitStream *bs, *tmp; - - prev_block_count = BSO / 16; - remain = BSO % 16; - tmp = gf_bs_new((const char *)sai->IV, 16, GF_BITSTREAM_READ); - bs = gf_bs_new(next_IV, 17, GF_BITSTREAM_WRITE); - gf_bs_write_u8(bs, 0); /*begin of counter*/ - - salt_portion = gf_bs_read_u64(tmp); - block_count_portion = gf_bs_read_u64(tmp); - /*reset the block counter to zero without affecting the other 64 bits of the IV*/ - if (prev_block_count > 0xFFFFFFFFFFFFFFFFULL - block_count_portion) - block_count_portion = prev_block_count - (0xFFFFFFFFFFFFFFFFULL - block_count_portion) - 1; - else - block_count_portion += prev_block_count; - gf_bs_write_u64(bs, salt_portion); - gf_bs_write_u64(bs, block_count_portion); - - gf_crypt_set_state(priv->crypt, next_IV, 17); - /*decrypt remain bytes*/ - if (remain) { - char dummy[20]; - gf_crypt_decrypt(priv->crypt, dummy, remain); + /*now read encrypted data, decrypted it and write to pleintext bitstream*/ + if (max_size < sai->subsamples[subsample_count].bytes_encrypted_data) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_encrypted_data); + max_size = sai->subsamples[subsample_count].bytes_encrypted_data; + } + gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + gf_crypt_decrypt(priv->crypt, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + + /*update IV for next subsample*/ + if (priv->is_cenc) { + BSO += sai->subsamples[subsample_count].bytes_encrypted_data; + if (gf_bs_available(cyphertext_bs)) { + char next_IV[17]; + u64 prev_block_count, salt_portion, block_count_portion; + u32 remain; + GF_BitStream *bs, *tmp; + + prev_block_count = BSO / 16; + remain = BSO % 16; + tmp = gf_bs_new((const char *)sai->IV, 16, GF_BITSTREAM_READ); + bs = gf_bs_new(next_IV, 17, GF_BITSTREAM_WRITE); + gf_bs_write_u8(bs, 0); /*begin of counter*/ + + salt_portion = gf_bs_read_u64(tmp); + block_count_portion = gf_bs_read_u64(tmp); + /*reset the block counter to zero without affecting the other 64 bits of the IV*/ + if (prev_block_count > 0xFFFFFFFFFFFFFFFFULL - block_count_portion) + block_count_portion = prev_block_count - (0xFFFFFFFFFFFFFFFFULL - block_count_portion) - 1; + else + block_count_portion += prev_block_count; + gf_bs_write_u64(bs, salt_portion); + gf_bs_write_u64(bs, block_count_portion); + + gf_crypt_set_state(priv->crypt, next_IV, 17); + /*decrypt remain bytes*/ + if (remain) { + char dummy[20]; + gf_crypt_decrypt(priv->crypt, dummy, remain); + } + + gf_bs_del(bs); + gf_bs_del(tmp); } - - gf_bs_del(bs); - gf_bs_del(tmp); } - } - subsample_count++; + subsample_count++; + } + if (buffer) gf_free(buffer); + gf_bs_get_content(pleintext_bs, &buffer, &evt->data_size); + } + //full sample encryption + else { + if (max_size < evt->data_size) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*evt->data_size); + max_size = evt->data_size; + } + gf_bs_read_data(cyphertext_bs, buffer, evt->data_size); + gf_crypt_decrypt(priv->crypt, buffer, evt->data_size); } - - if (buffer) gf_free(buffer); - gf_bs_get_content(pleintext_bs, &buffer, &evt->data_size); memmove(evt->data, buffer, evt->data_size); exit: @@ -541,6 +557,7 @@ exit: return e; } + static GF_Err IPMP_Process(GF_IPMPTool *plug, GF_IPMPEvent *evt) { ISMAEAPriv *priv = (ISMAEAPriv *)plug->udta; @@ -553,7 +570,7 @@ static GF_Err IPMP_Process(GF_IPMPTool *plug, GF_IPMPEvent *evt) #endif if((evt->config_data_code != GF_4CC('c', 'e', 'n', 'c')) || (evt->config_data_code != GF_4CC('c','b','c','1'))) return CENC_Setup(priv, evt); return GF_NOT_SUPPORTED; - + case GF_IPMP_TOOL_GRANT_ACCESS: case GF_IPMP_TOOL_RELEASE_ACCESS: if (priv->is_cenc || priv->is_cbc) { @@ -593,7 +610,7 @@ GF_IPMPTool *NewIPMPTool() { ISMAEAPriv *priv; GF_IPMPTool *tmp; - + GF_SAFEALLOC(tmp, GF_IPMPTool); if (!tmp) return NULL; GF_SAFEALLOC(priv, ISMAEAPriv); @@ -606,7 +623,7 @@ GF_IPMPTool *NewIPMPTool() #endif /*GPAC_DISABLE_MCRYPT*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_MCRYPT diff --git a/modules/isom_in/isom_cache.c b/modules/isom_in/isom_cache.c index b334cf4..447e924 100644 --- a/modules/isom_in/isom_cache.c +++ b/modules/isom_in/isom_cache.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "isom_in.h" @@ -52,7 +52,7 @@ static GF_Err ISOW_Open(GF_StreamingCache *mc, GF_ClientService *serv, const cha } } } - + /*create a new movie in write mode (eg no editing)*/ cache->mov = gf_isom_open(szPath, GF_ISOM_OPEN_WRITE, NULL); if (!cache->mov) return gf_isom_last_error(NULL); @@ -100,21 +100,40 @@ static GF_Err ISOW_Write(GF_StreamingCache *mc, LPNETCHANNEL ch, char *data, u32 GF_NetworkCommand com; com.base.on_channel = ch; com.base.command_type = GF_NET_CHAN_GET_ESD; - gf_term_on_command(cache->service, &com, GF_OK); + gf_service_command(cache->service, &com, GF_OK); if (!com.cache_esd.esd) return GF_SERVICE_ERROR; esd = (GF_ESD *)com.cache_esd.esd; switch (esd->decoderConfig->streamType) { - case GF_STREAM_OD: mtype = GF_ISOM_MEDIA_OD; break; - case GF_STREAM_SCENE: mtype = GF_ISOM_MEDIA_SCENE; break; - case GF_STREAM_VISUAL: mtype = GF_ISOM_MEDIA_VISUAL; break; - case GF_STREAM_AUDIO: mtype = GF_ISOM_MEDIA_AUDIO; break; - case GF_STREAM_MPEG7: mtype = GF_ISOM_MEDIA_MPEG7; break; - case GF_STREAM_OCI: mtype = GF_ISOM_MEDIA_OCI; break; - case GF_STREAM_IPMP: mtype = GF_ISOM_MEDIA_IPMP; break; - case GF_STREAM_MPEGJ: mtype = GF_ISOM_MEDIA_MPEGJ; break; - case GF_STREAM_TEXT: mtype = GF_ISOM_MEDIA_TEXT; break; - default: return GF_NOT_SUPPORTED; + case GF_STREAM_OD: + mtype = GF_ISOM_MEDIA_OD; + break; + case GF_STREAM_SCENE: + mtype = GF_ISOM_MEDIA_SCENE; + break; + case GF_STREAM_VISUAL: + mtype = GF_ISOM_MEDIA_VISUAL; + break; + case GF_STREAM_AUDIO: + mtype = GF_ISOM_MEDIA_AUDIO; + break; + case GF_STREAM_MPEG7: + mtype = GF_ISOM_MEDIA_MPEG7; + break; + case GF_STREAM_OCI: + mtype = GF_ISOM_MEDIA_OCI; + break; + case GF_STREAM_IPMP: + mtype = GF_ISOM_MEDIA_IPMP; + break; + case GF_STREAM_MPEGJ: + mtype = GF_ISOM_MEDIA_MPEGJ; + break; + case GF_STREAM_TEXT: + mtype = GF_ISOM_MEDIA_TEXT; + break; + default: + return GF_NOT_SUPPORTED; } GF_SAFEALLOC(mch, ISOMChannel); mch->time_scale = esd->slConfig->timestampResolution; @@ -147,7 +166,7 @@ static GF_Err ISOW_Write(GF_StreamingCache *mc, LPNETCHANNEL ch, char *data, u32 gf_isom_3gp_config_new(cache->mov, mch->track, &h263c, NULL, NULL, &di); mapped = 1; } - } + } if (!mapped) gf_isom_new_mpeg4_description(cache->mov, mch->track, esd, NULL, NULL, &di); if (com.cache_esd.is_iod_stream) gf_isom_add_track_to_root_od(cache->mov, mch->track); gf_list_add(cache->channels, mch); @@ -184,7 +203,7 @@ static GF_Err ISOW_Write(GF_StreamingCache *mc, LPNETCHANNEL ch, char *data, u32 mch->cache_sample->DTS = mch->prev_dts + mch->frame_cts_offset; mch->cache_sample->CTS_Offset += (u32) (CTS-mch->cache_sample->DTS); } - /*deal with reference picture insertion: if no CTS offset and biggest CTS until now, this is + /*deal with reference picture insertion: if no CTS offset and biggest CTS until now, this is a reference insertion - we must check that in order to make sure we have strictly increasing DTSs*/ if (mch->max_cts && !mch->cache_sample->CTS_Offset && (mch->cache_sample->DTS+mch->cache_sample->CTS_Offset > mch->max_cts)) { assert(mch->cache_sample->DTS > mch->prev_dts + mch->frame_cts_offset); @@ -192,7 +211,7 @@ static GF_Err ISOW_Write(GF_StreamingCache *mc, LPNETCHANNEL ch, char *data, u32 mch->cache_sample->DTS = mch->prev_dts + mch->frame_cts_offset; mch->cache_sample->CTS_Offset = (u32) (CTS-mch->cache_sample->DTS); } - if (mch->cache_sample->CTS_Offset) + if (mch->cache_sample->CTS_Offset) mch->max_cts = mch->cache_sample->DTS+mch->cache_sample->CTS_Offset; /*add cache*/ diff --git a/modules/isom_in/isom_in.h b/modules/isom_in/isom_in.h index 75fd3fa..470999b 100644 --- a/modules/isom_in/isom_in.h +++ b/modules/isom_in/isom_in.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -106,7 +106,7 @@ typedef struct u32 time_scale; Bool to_init, is_playing, has_rap; u8 streamType; - + Bool is_encrypted, is_cenc; /*cache stuff*/ @@ -118,7 +118,7 @@ typedef struct Bool buffering; u32 buffer_min, buffer_max; - + Bool disable_seek; u32 nalu_extract_mode; } ISOMChannel; void isor_reset_reader(ISOMChannel *ch); diff --git a/modules/isom_in/load.c b/modules/isom_in/load.c index 0d437ed..303c80c 100644 --- a/modules/isom_in/load.c +++ b/modules/isom_in/load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "isom_in.h" @@ -88,22 +88,14 @@ void isor_declare_objects(ISOMReader *read) const char *tag; u32 i, count, ocr_es_id, tlen, base_track, j, track_id; Bool highest_stream; - char *opt; - Bool add_ps_lower = GF_TRUE; ocr_es_id = 0; - opt = (char*) gf_modules_get_option((GF_BaseInterface *)read->input, "ISOReader", "DeclareScalableXPS"); - if (!opt) { - gf_modules_set_option((GF_BaseInterface *)read->input, "ISOReader", "DeclareScalableXPS", "yes"); - } else if (!strcmp(opt, "no")) { - add_ps_lower = GF_FALSE; - } /*TODO check for alternate tracks*/ count = gf_isom_get_track_count(read->mov); for (i=0; imov, i+1)) continue; - + switch (gf_isom_get_media_type(read->mov, i+1)) { case GF_ISOM_MEDIA_AUDIO: case GF_ISOM_MEDIA_VISUAL: @@ -115,7 +107,13 @@ void isor_declare_objects(ISOMReader *read) default: continue; } - + //some subtypes are not declared as readable objects + switch (gf_isom_get_media_subtype(read->mov, i+1, 1)) { + case GF_ISOM_SUBTYPE_HVT1: + continue; + default: + break; + } /*we declare only the highest video track (i.e the track we play)*/ highest_stream = GF_TRUE; track_id = gf_isom_get_track_id(read->mov, i+1); @@ -141,13 +139,13 @@ void isor_declare_objects(ISOMReader *read) if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { send_proxy_command(read, GF_FALSE, GF_TRUE, GF_OK, (GF_Descriptor*)od, NULL); } else { - gf_term_add_media(read->service, (GF_Descriptor*)od, GF_TRUE); + gf_service_declare_media(read->service, (GF_Descriptor*)od, GF_TRUE); } } } /*if cover art, extract it in cache*/ if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COVER_ART, &tag, &tlen)==GF_OK) { - const char *cdir = gf_modules_get_option((GF_BaseInterface *)gf_term_get_service_interface(read->service), "General", "CacheDirectory"); + const char *cdir = gf_modules_get_option((GF_BaseInterface *)gf_service_get_interface(read->service), "General", "CacheDirectory"); if (cdir) { char szName[GF_MAX_PATH]; const char *sep; @@ -190,7 +188,7 @@ void isor_declare_objects(ISOMReader *read) if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { send_proxy_command(read, GF_FALSE, GF_TRUE, GF_OK, (GF_Descriptor*)od, NULL); } else { - gf_term_add_media(read->service, (GF_Descriptor*)od, GF_TRUE); + gf_service_declare_media(read->service, (GF_Descriptor*)od, GF_TRUE); } } } @@ -199,22 +197,22 @@ void isor_declare_objects(ISOMReader *read) if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { send_proxy_command(read, GF_FALSE, GF_TRUE, GF_OK, NULL, NULL); } else { - gf_term_add_media(read->service, NULL, GF_FALSE); - } + gf_service_declare_media(read->service, NULL, GF_FALSE); + } } #endif /*GPAC_DISABLE_ISOM*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_ISOM - GF_NET_CLIENT_INTERFACE, + GF_NET_CLIENT_INTERFACE, #endif #ifndef GPAC_DISABLE_ISOM_WRITE - GF_STREAMING_MEDIA_CACHE, + GF_STREAMING_MEDIA_CACHE, #endif 0 }; @@ -222,14 +220,14 @@ const u32 *QueryInterfaces() } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_ISOM - if (InterfaceType == GF_NET_CLIENT_INTERFACE) + if (InterfaceType == GF_NET_CLIENT_INTERFACE) return (GF_BaseInterface *)isor_client_load(); #endif #ifndef GPAC_DISABLE_ISOM_WRITE - if (InterfaceType == GF_STREAMING_MEDIA_CACHE) + if (InterfaceType == GF_STREAMING_MEDIA_CACHE) return (GF_BaseInterface *)isow_load_cache(); #endif return NULL; @@ -240,10 +238,14 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_ISOM - case GF_NET_CLIENT_INTERFACE: isor_client_del(ifce); break; + case GF_NET_CLIENT_INTERFACE: + isor_client_del(ifce); + break; #endif #ifndef GPAC_DISABLE_ISOM_WRITE - case GF_STREAMING_MEDIA_CACHE: isow_delete_cache(ifce); break; + case GF_STREAMING_MEDIA_CACHE: + isow_delete_cache(ifce); + break; #endif } } diff --git a/modules/isom_in/read.c b/modules/isom_in/read.c index ede0144..3e8b411 100644 --- a/modules/isom_in/read.c +++ b/modules/isom_in/read.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "isom_in.h" @@ -63,23 +63,23 @@ static GFINLINE Bool isor_is_local(const char *url) } static const char * ISOR_MIME_TYPES[] = { - /* First one is specific because we probe */ - "application/x-isomedia", "*", "IsoMedia Files", - "video/mp4", "mp4 mpg4", "MPEG-4 Movies", - "audio/mp4", "m4a mp4 mpg4", "MPEG-4 Music", - "application/mp4", "mp4 mpg4", "MPEG-4 Applications", - "video/3gpp", "3gp 3gpp", "3GPP/MMS Movies", - "audio/3gpp", "3gp 3gpp", "3GPP/MMS Music", - "video/3gpp2", "3g2 3gp2", "3GPP2/MMS Movies", - "audio/3gpp2", "3g2 3gp2", "3GPP2/MMS Music", - NULL + /* First one is specific because we probe */ + "application/x-isomedia", "*", "IsoMedia Files", + "video/mp4", "mp4 mpg4", "MPEG-4 Movies", + "audio/mp4", "m4a mp4 mpg4", "MPEG-4 Music", + "application/mp4", "mp4 mpg4", "MPEG-4 Applications", + "video/3gpp", "3gp 3gpp", "3GPP/MMS Movies", + "audio/3gpp", "3gp 3gpp", "3GPP/MMS Music", + "video/3gpp2", "3g2 3gp2", "3GPP2/MMS Movies", + "audio/3gpp2", "3g2 3gp2", "3GPP2/MMS Music", + NULL }; - -u32 ISOR_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - for (i = 0 ; ISOR_MIME_TYPES[i]; i+=3) - gf_term_register_mime_type(plug, ISOR_MIME_TYPES[i], ISOR_MIME_TYPES[i+1], ISOR_MIME_TYPES[i+2]); - return i/3; + +u32 ISOR_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + for (i = 0 ; ISOR_MIME_TYPES[i]; i+=3) + gf_service_register_mime(plug, ISOR_MIME_TYPES[i], ISOR_MIME_TYPES[i+1], ISOR_MIME_TYPES[i+2]); + return i/3; } Bool ISOR_CanHandleURL(GF_InputService *plug, const char *url) @@ -88,15 +88,15 @@ Bool ISOR_CanHandleURL(GF_InputService *plug, const char *url) if (!strnicmp(url, "rtsp://", 7)) return GF_FALSE; ext = (char *)strrchr(url, '.'); { - u32 i; - /* We don't start at 0 since first one is specific */ - for (i = 3 ; ISOR_MIME_TYPES[i]; i+=3) - if (gf_term_check_extension(plug, ISOR_MIME_TYPES[i], ISOR_MIME_TYPES[i+1], ISOR_MIME_TYPES[i+2], ext)) - return GF_TRUE; + u32 i; + /* We don't start at 0 since first one is specific */ + for (i = 3 ; ISOR_MIME_TYPES[i]; i+=3) + if (gf_service_check_mime_register(plug, ISOR_MIME_TYPES[i], ISOR_MIME_TYPES[i+1], ISOR_MIME_TYPES[i+2], ext)) + return GF_TRUE; } if (ext && gf_isom_probe_file(url)) { - gf_term_check_extension(plug, ISOR_MIME_TYPES[0], ext+1, ISOR_MIME_TYPES[2], ext); + gf_service_check_mime_register(plug, ISOR_MIME_TYPES[0], ext+1, ISOR_MIME_TYPES[2], ext); return GF_TRUE; } return GF_FALSE; @@ -164,7 +164,7 @@ void isor_check_buffer_level(ISOMReader *read) //we have enough buffer else if ((data_offset + ch->buffer_max * mov_rate/1000 <= done)) { do_buffer = GF_FALSE; - } + } #endif time_remain_ch -= (samp->DTS + samp->CTS_Offset); if (time_remain_ch<0) time_remain_ch=0; @@ -187,7 +187,7 @@ void isor_check_buffer_level(ISOMReader *read) memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = do_buffer ? GF_NET_CHAN_PAUSE : GF_NET_CHAN_RESUME; com.buffer.on_channel = ch->channel; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); ch->buffering = do_buffer; } else if (ch->buffering) { memset(&com, 0, sizeof(GF_NetworkCommand)); @@ -196,7 +196,7 @@ void isor_check_buffer_level(ISOMReader *read) com.buffer.min = ch->buffer_min; com.buffer.max = ch->buffer_max; com.buffer.occupancy = buffer_level; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); } } } @@ -207,9 +207,9 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) u32 size = 0; char *local_name; ISOMReader *read = (ISOMReader *) cbk; - + /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); if (param->msg_type==GF_NETIO_DATA_TRANSFERED) { e = GF_EOS; @@ -223,13 +223,13 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) if (emov) { - /* if there is an intermediate between this module and the terminal, report to it */ - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, e); - } - } + /* if there is an intermediate between this module and the terminal, report to it */ + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, e); + } + } return; } @@ -239,25 +239,25 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) if (read->mov) return; local_name = gf_dm_sess_get_cache_name(read->dnload); if (!local_name) { - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_SERVICE_ERROR, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_SERVICE_ERROR); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_SERVICE_ERROR, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_SERVICE_ERROR); + } return; } e = GF_OK; read->mov = gf_isom_open(local_name, GF_ISOM_OPEN_READ, NULL); if (!read->mov) e = gf_isom_last_error(NULL); else read->time_scale = gf_isom_get_timescale(read->mov); - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_OK); + } if (read->no_service_desc) isor_declare_objects(read); } - + if (!size) return; /*service is opened, nothing to do*/ @@ -277,11 +277,11 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) /*try to open the service*/ local_name = (char *)gf_dm_sess_get_cache_name(read->dnload); if (!local_name) { - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_SERVICE_ERROR, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_SERVICE_ERROR); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_SERVICE_ERROR, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_SERVICE_ERROR); + } return; } @@ -290,7 +290,7 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) read->missing_bytes -= size; return; } - + e = gf_isom_open_progressive(local_name, 0, 0, &read->mov, &read->missing_bytes); switch (e) { case GF_ISOM_INCOMPLETE_FILE: @@ -298,22 +298,22 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) case GF_OK: break; default: - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, e); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, e); + } return; } read->frag_type = gf_isom_is_fragmented(read->mov) ? 1 : 0; - + /*ok let's go, we can setup the decoders */ read->time_scale = gf_isom_get_timescale(read->mov); - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_OK); + } if (read->no_service_desc) isor_declare_objects(read); } @@ -322,13 +322,13 @@ void isor_net_io(void *cbk, GF_NETIO_Parameter *param) void isor_setup_download(GF_InputService *plug, const char *url) { ISOMReader *read = (ISOMReader *) plug->priv; - read->dnload = gf_term_download_new(read->service, url, 0, isor_net_io, read); + read->dnload = gf_service_download_new(read->service, url, 0, isor_net_io, read); if (!read->dnload) { - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_NOT_SUPPORTED, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_NOT_SUPPORTED, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); + } } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -347,7 +347,7 @@ GF_Err ISOR_ConnectService(GF_InputService *plug, GF_ClientService *serv, const read->input = plug; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; read->base_track_id = 0; @@ -380,13 +380,13 @@ GF_Err ISOR_ConnectService(GF_InputService *plug, GF_ClientService *serv, const } } e = gf_isom_open_progressive(szURL, start_range, end_range, &read->mov, &read->missing_bytes); - if (e != GF_OK){ - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[IsoMedia] : error while opening %s, error=%s\n", szURL, gf_error_to_string(e))); - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, 0, 0, e, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, e); - } + if (e != GF_OK) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[IsoMedia] : error while opening %s, error=%s\n", szURL, gf_error_to_string(e))); + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, 0, 0, e, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, e); + } return GF_OK; } read->frag_type = gf_isom_is_fragmented(read->mov) ? 1 : 0; @@ -394,11 +394,11 @@ GF_Err ISOR_ConnectService(GF_InputService *plug, GF_ClientService *serv, const read->time_scale = gf_isom_get_timescale(read->mov); /*reply to user*/ - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); - } else { - gf_term_on_connect(read->service, NULL, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL); + } else { + gf_service_connect_ack(read->service, NULL, GF_OK); + } if (read->no_service_desc) isor_declare_objects(read); @@ -427,14 +427,14 @@ GF_Err ISOR_CloseService(GF_InputService *plug) isor_delete_channel(read, ch); } - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_TRUE, GF_FALSE, reply, NULL, NULL); - } else { - gf_term_on_disconnect(read->service, NULL, reply); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_TRUE, GF_FALSE, reply, NULL, NULL); + } else { + gf_service_disconnect_ack(read->service, NULL, reply); + } return GF_OK; } @@ -559,8 +559,8 @@ static GF_Descriptor *ISOR_GetServiceDesc(GF_InputService *plug, u32 expect_type for (i=0; imov); i++) { u32 type = gf_isom_get_media_type(read->mov, i+1); if ( - ((type==GF_ISOM_MEDIA_VISUAL) && (expect_type==GF_MEDIA_OBJECT_VIDEO)) - || ((type==GF_ISOM_MEDIA_AUDIO) && (expect_type==GF_MEDIA_OBJECT_AUDIO)) ) { + ((type==GF_ISOM_MEDIA_VISUAL) && (expect_type==GF_MEDIA_OBJECT_VIDEO)) + || ((type==GF_ISOM_MEDIA_AUDIO) && (expect_type==GF_MEDIA_OBJECT_AUDIO)) ) { trackID = gf_isom_get_track_id(read->mov, i+1); break; } @@ -638,9 +638,15 @@ static GF_Descriptor *ISOR_GetServiceDesc(GF_InputService *plug, u32 expect_type for (i=0; iESDescriptors, i); switch (esd->decoderConfig->streamType) { - case GF_STREAM_VISUAL: nb_st |= 1; break; - case GF_STREAM_AUDIO: nb_st |= 2; break; - case GF_STREAM_TEXT: nb_st |= 4; break; + case GF_STREAM_VISUAL: + nb_st |= 1; + break; + case GF_STREAM_AUDIO: + nb_st |= 2; + break; + case GF_STREAM_TEXT: + nb_st |= 4; + break; } } if ( (nb_st & 1) + (nb_st & 2) + (nb_st & 4) > 1) { @@ -657,12 +663,12 @@ void isor_send_cenc_config(ISOMChannel *ch) { GF_NetworkCommand com; u32 i; - + memset(&com, 0, sizeof(GF_NetworkCommand)); com.base.on_channel = ch->channel; com.command_type = GF_NET_CHAN_DRM_CFG; ch->is_encrypted = GF_TRUE; - + gf_isom_get_cenc_info(ch->owner->mov, ch->track, 1, NULL, &com.drm_cfg.scheme_type, &com.drm_cfg.scheme_version, NULL); com.drm_cfg.PSSH_count = gf_isom_get_pssh_count(ch->owner->mov); @@ -676,10 +682,10 @@ void isor_send_cenc_config(ISOMChannel *ch) //fixme - check MSE and EME #if 0 if (read->input->query_proxy && read->input->proxy_udta) { - read->input->query_proxy(read->input, &com); - } else + read->input->query_proxy(read->input, &com); + } else #endif - gf_term_on_command(ch->owner->service, &com, GF_OK); + gf_service_command(ch->owner->service, &com, GF_OK); //free our PSSH if (com.drm_cfg.PSSHs) gf_free(com.drm_cfg.PSSHs); } @@ -774,11 +780,11 @@ GF_Err ISOR_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const ch ch->time_scale = gf_isom_get_media_timescale(ch->owner->mov, ch->track); exit: - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, channel); - } else { - gf_term_on_connect(read->service, channel, e); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, GF_FALSE, GF_FALSE, e, NULL, channel); + } else { + gf_service_connect_ack(read->service, channel, e); + } /*if esd url reconfig SL layer*/ if (!e && is_esd_url) { GF_ESD *esd; @@ -795,11 +801,11 @@ exit: com.cfg.sl_config.timestampResolution = ch->time_scale; com.cfg.sl_config.useRandomAccessPointFlag = 1; } - if (read->input->query_proxy && read->input->proxy_udta) { - read->input->query_proxy(read->input, &com); - } else { - gf_term_on_command(read->service, &com, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta) { + read->input->query_proxy(read->input, &com); + } else { + gf_service_command(read->service, &com, GF_OK); + } } if (!e && track && gf_isom_is_track_encrypted(read->mov, track)) { memset(&com, 0, sizeof(GF_NetworkCommand)); @@ -808,20 +814,20 @@ exit: ch->is_encrypted = GF_TRUE; if (gf_isom_is_ismacryp_media(read->mov, track, 1)) { gf_isom_get_ismacryp_info(read->mov, track, 1, NULL, &com.drm_cfg.scheme_type, &com.drm_cfg.scheme_version, &com.drm_cfg.scheme_uri, &com.drm_cfg.kms_uri, NULL, NULL, NULL); - if (read->input->query_proxy && read->input->proxy_udta) { - read->input->query_proxy(read->input, &com); - } else { - gf_term_on_command(read->service, &com, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta) { + read->input->query_proxy(read->input, &com); + } else { + gf_service_command(read->service, &com, GF_OK); + } } else if (gf_isom_is_omadrm_media(read->mov, track, 1)) { gf_isom_get_omadrm_info(read->mov, track, 1, NULL, &com.drm_cfg.scheme_type, &com.drm_cfg.scheme_version, &com.drm_cfg.contentID, &com.drm_cfg.kms_uri, &com.drm_cfg.oma_drm_textual_headers, &com.drm_cfg.oma_drm_textual_headers_len, NULL, &com.drm_cfg.oma_drm_crypt_type, NULL, NULL, NULL); gf_media_get_file_hash(gf_isom_get_filename(read->mov), com.drm_cfg.hash); - if (read->input->query_proxy && read->input->proxy_udta) { - read->input->query_proxy(read->input, &com); - } else { - gf_term_on_command(read->service, &com, GF_OK); - } + if (read->input->query_proxy && read->input->proxy_udta) { + read->input->query_proxy(read->input, &com); + } else { + gf_service_command(read->service, &com, GF_OK); + } } else if (gf_isom_is_cenc_media(read->mov, track, 1)) { ch->is_cenc = GF_TRUE; isor_send_cenc_config(ch); @@ -851,11 +857,11 @@ GF_Err ISOR_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) assert(!isor_get_channel(read, channel)); exit: - if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { - send_proxy_command(read, 1, 0, e, NULL, channel); - } else { - gf_term_on_disconnect(read->service, channel, e); - } + if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { + send_proxy_command(read, 1, 0, e, NULL, channel); + } else { + gf_service_disconnect_ack(read->service, channel, e); + } return e; } @@ -895,7 +901,7 @@ GF_Err ISOR_ChannelGetSLP(GF_InputService *plug, LPNETCHANNEL channel, char **ou *out_reception_status = ch->last_state; if (read->waiting_for_data) *out_reception_status = GF_BUFFER_TOO_SMALL; - + return GF_OK; } @@ -953,7 +959,7 @@ u32 gf_channel_switch_quality(ISOMChannel *ch, GF_ISOFile *the_file, Bool switch break; } } - /*this is the highest quality*/ + /*this is the highest quality*/ if (!next_track) return cur_track; } @@ -1052,7 +1058,7 @@ GF_Err ISOR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) case GF_NET_CHAN_SET_PULL: //we don't pull in DASH base services, we flush as soon as we have a complete segment #ifndef DASH_USE_PULL - if (read->input->proxy_udta && !read->input->proxy_type) + if (read->input->proxy_udta && !read->input->proxy_type) return GF_NOT_SUPPORTED; #endif @@ -1104,8 +1110,11 @@ GF_Err ISOR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) ch->end = check_round(ch, ch->end, com->play.end_range, 0); } } else if (com->play.speed<0) { - if (com->play.end_range>=com->play.start_range) ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); - if (com->play.end_range >= 0) ch->end = (u64) (s64) (com->play.end_range*ch->time_scale); + Double end = com->play.end_range; + if (end==-1) end = 0; + ch->start = (u64) (s64) (com->play.start_range * ch->time_scale); + if (end <= com->play.start_range) + ch->end = (u64) (s64) (end * ch->time_scale); } ch->is_playing = 1; if (com->play.dash_segment_switch) ch->wait_for_segment_switch = 1; @@ -1141,9 +1150,12 @@ GF_Err ISOR_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } case GF_NET_CHAN_NALU_MODE: ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG; + ch->disable_seek = 1; //when this is set, we work in real scalable (eg N streams reassembled by the player) so only extract the layer. This wll need refinements if we plan to support //several scalable layers ... - if (com->nalu_mode.extract_mode==1) ch->nalu_extract_mode |= GF_ISOM_NALU_EXTRACT_ANNEXB_FLAG | GF_ISOM_NALU_EXTRACT_VDRD_FLAG | GF_ISOM_NALU_EXTRACT_LAYER_ONLY; + if (com->nalu_mode.extract_mode==1) { + ch->nalu_extract_mode |= GF_ISOM_NALU_EXTRACT_ANNEXB_FLAG | GF_ISOM_NALU_EXTRACT_VDRD_FLAG | GF_ISOM_NALU_EXTRACT_LAYER_ONLY; + } gf_isom_set_nalu_extract_mode(ch->owner->mov, ch->track, ch->nalu_extract_mode); break; default: @@ -1156,7 +1168,7 @@ static Bool ISOR_CanHandleURLInService(GF_InputService *plug, const char *url) { char szURL[2048], *sep; ISOMReader *read = (ISOMReader *)plug->priv; - const char *this_url = gf_term_get_service_url(read->service); + const char *this_url = gf_service_get_url(read->service); if (!this_url || !url) return GF_FALSE; if (!strcmp(this_url, url)) return GF_TRUE; @@ -1193,7 +1205,7 @@ GF_InputService *isor_client_load() GF_SAFEALLOC(reader, ISOMReader); reader->channels = gf_list_new(); reader->segment_mutex = gf_mx_new("ISO Segment"); - + plug->priv = reader; return plug; } diff --git a/modules/isom_in/read_ch.c b/modules/isom_in/read_ch.c index f325e71..5e948c8 100644 --- a/modules/isom_in/read_ch.c +++ b/modules/isom_in/read_ch.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -46,7 +46,7 @@ void isor_reset_reader(ISOMChannel *ch) } /* - refresh type: + refresh type: 0: not progressive 1: progressive 2: not progressive and don't check current download @@ -69,9 +69,9 @@ void isor_segment_switch_or_refresh(ISOMReader *read, u32 refresh_type) memset(¶m, 0, sizeof(GF_NetworkCommand)); param.command_type = GF_NET_SERVICE_QUERY_NEXT; param.url_query.current_download = (refresh_type==2) ? 0 : 1; - if (refresh_type==2) + if (refresh_type==2) refresh_type = 0; - + count = gf_list_count(read->channels); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[IsoMedia] Refresh seg: refresh_type %d - seg opened %d\n", refresh_type , read->seg_opened)); @@ -117,7 +117,7 @@ next_segment: if (e == GF_OK) { u64 timestamp, ntp; u32 trackID = 0; - if (param.url_query.next_url){ + if (param.url_query.next_url) { //previously loaded file has been aborted, reload segment ! if (refresh_type && param.url_query.discontinuity_type) { @@ -184,7 +184,8 @@ next_segment: gf_isom_reset_fragment_info(read->mov, 0); for (i=0; ichannels, i); - ch->sample_num = 0; + if (ch) + ch->sample_num = 0; } //cannot open file, don't change our state @@ -271,7 +272,7 @@ next_segment: gf_isom_set_nalu_extract_mode(read->mov, ch->track, ch->nalu_extract_mode); ch->last_state = GF_OK; - + if (ch->is_cenc) { isor_send_cenc_config(ch); } @@ -292,7 +293,7 @@ next_segment: /*consider we are done*/ read->frag_type = 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[IsoMedia] No more segments - done playing file\n")); - } else if (e==GF_BUFFER_TOO_SMALL){ + } else if (e==GF_BUFFER_TOO_SMALL) { if (refresh_type==0) { GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[IsoMedia] Next segment is not yet available\n")); read->waiting_for_data = GF_TRUE; @@ -312,7 +313,7 @@ static void init_reader(ISOMChannel *ch) u32 ivar; if (ch->is_pulling && ch->wait_for_segment_switch) { isor_segment_switch_or_refresh(ch->owner, 0); - if (ch->wait_for_segment_switch) + if (ch->wait_for_segment_switch) return; } @@ -333,14 +334,17 @@ static void init_reader(ISOMChannel *ch) ch->sample->DTS = ch->start; ch->last_state=GF_OK; } else { + //if seek is disabled, get the next closest sample for this time; otherwose, get the previous RAP sample for this time + u32 mode = ch->disable_seek ? GF_ISOM_SEARCH_BACKWARD : GF_ISOM_SEARCH_SYNC_BACKWARD; + /*take care of seeking out of the track range*/ if (!ch->owner->frag_type && (ch->durationstart)) { - ch->last_state = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->duration, &ivar, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->sample, &ch->sample_num); + ch->last_state = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->duration, &ivar, mode, &ch->sample, &ch->sample_num); } else { - ch->last_state = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->start, &ivar, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->sample, &ch->sample_num); + ch->last_state = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->start, &ivar, mode, &ch->sample, &ch->sample_num); } ch->last_state = GF_OK; - + if (ch->has_rap && ch->has_edit_list) { ch->edit_sync_frame = ch->sample_num; } @@ -361,14 +365,21 @@ static void init_reader(ISOMChannel *ch) ch->last_state = (ch->owner->frag_type==1) ? GF_OK : GF_EOS; ch->to_init = 0; } + return; + } + + ch->sample_time = ch->sample->DTS; + ch->to_init = 0; + + if (ch->disable_seek) { + ch->current_slh.decodingTimeStamp = ch->sample->DTS; + ch->current_slh.compositionTimeStamp = ch->sample->DTS + ch->sample->CTS_Offset; + ch->start = 0; } else { - ch->sample_time = ch->sample->DTS; - ch->to_init = 0; + ch->current_slh.decodingTimeStamp = ch->start; + ch->current_slh.compositionTimeStamp = ch->start; } - ch->current_slh.decodingTimeStamp = ch->start; - ch->current_slh.compositionTimeStamp = ch->start; ch->current_slh.randomAccessPointFlag = ch->sample ? ch->sample->IsRAP : 0; - } @@ -390,6 +401,10 @@ void isor_reader_get_sample(ISOMChannel *ch) if (ch->to_init) { init_reader(ch); + } else if (ch->speed < 0) { + gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time - 1, &ivar, GF_ISOM_SEARCH_SYNC_BACKWARD, &ch->sample, &ch->sample_num); + if (ch->sample) ch->sample_time = ch->sample->DTS; + } else if (ch->has_edit_list) { u32 prev_sample = ch->sample_num; e = gf_isom_get_sample_for_movie_time(ch->owner->mov, ch->track, ch->sample_time + 1, &ivar, GF_ISOM_SEARCH_FORWARD, &ch->sample, &ch->sample_num); @@ -412,7 +427,7 @@ void isor_reader_get_sample(ISOMChannel *ch) /*if we get the same sample, figure out next interesting time (current sample + DTS gap to next sample should be a good bet)*/ if (prev_sample == ch->sample_num) { if (ch->owner->frag_type && (ch->sample_num==gf_isom_get_sample_count(ch->owner->mov, ch->track))) { - if (ch->sample) + if (ch->sample) gf_isom_sample_del(&ch->sample); } else { u32 time_diff = 2; @@ -462,28 +477,33 @@ void isor_reader_get_sample(ISOMChannel *ch) } } else { ch->sample_num++; -fetch_next: + ch->sample = gf_isom_get_sample(ch->owner->mov, ch->track, ch->sample_num, &ivar); /*if sync shadow / carousel RAP skip*/ if (ch->sample && (ch->sample->IsRAP==2)) { gf_isom_sample_del(&ch->sample); ch->sample_num++; - goto fetch_next; - } - if (ch->sample && ch->sample->IsRAP && ch->next_track) { - ch->track = ch->next_track; - ch->next_track = 0; - gf_isom_sample_del(&ch->sample); - goto fetch_next; - } - if (ch->sample && ch->dts_offset) { - if ( (ch->dts_offset<0) && (ch->sample->DTS < (u64) -ch->dts_offset)) { - ch->sample->DTS = 0; - } else { - ch->sample->DTS += ch->dts_offset; - } + isor_reader_get_sample(ch); + return; + } + } + + //check scalable track change + if (ch->sample && ch->sample->IsRAP && ch->next_track) { + ch->track = ch->next_track; + ch->next_track = 0; + gf_isom_sample_del(&ch->sample); + isor_reader_get_sample(ch); + return; + } + if (ch->sample && ch->dts_offset) { + if ( (ch->dts_offset<0) && (ch->sample->DTS < (u64) -ch->dts_offset)) { + ch->sample->DTS = 0; + } else { + ch->sample->DTS += ch->dts_offset; } } + if (!ch->sample) { /*incomplete file - check if we're still downloading or not*/ if (gf_isom_get_missing_bytes(ch->owner->mov, ch->track)) { @@ -493,7 +513,7 @@ fetch_next: gf_dm_sess_get_stats(ch->owner->dnload, NULL, NULL, NULL, NULL, NULL, &net_status); if (net_status == GF_NETIO_DATA_EXCHANGE) { ch->last_state = GF_OK; - if (!ch->has_edit_list) + if (!ch->has_edit_list) ch->sample_num--; } } @@ -530,8 +550,12 @@ fetch_next: ch->current_slh.accessUnitEndFlag = ch->current_slh.accessUnitStartFlag = 1; ch->current_slh.accessUnitLength = ch->sample->dataLength; ch->current_slh.au_duration = gf_isom_get_sample_duration(ch->owner->mov, ch->track, ch->sample_num); - /*still seeking or not ?*/ - if (ch->start <= ch->sample->DTS + ch->sample->CTS_Offset) { + + /*still seeking or not ? + 1- when speed is negative, the RAP found is "after" the seek point in playback order since we used backward RAP search: nothing to do + 2- otherwise set DTS+CTS to start value - !! FIXME we should not change the TS but rather signal the frame is a seek frame + */ + if ((ch->speed < 0) || (ch->start <= ch->sample->DTS + ch->sample->CTS_Offset)) { ch->current_slh.decodingTimeStamp = ch->sample->DTS; ch->current_slh.compositionTimeStamp = ch->sample->DTS + ch->sample->CTS_Offset; } else { @@ -645,7 +669,7 @@ void isor_flush_data(ISOMReader *read, Bool check_buffer_level, Bool is_chunk_fl } //otherwise this is new chunk or end of chunk, process } - //this is a new file, check buffer level + //this is a new file, check buffer level else if (!is_chunk_flush && check_buffer_level) { Bool buffer_full = 1; for (i=0; ichannel; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if ((com.buffer.occupancy < MAX(com.buffer.max, 1000) )) { buffer_full = 0; break; @@ -680,9 +704,9 @@ void isor_flush_data(ISOMReader *read, Bool check_buffer_level, Bool is_chunk_fl #endif //if this is a request from terminal to flush pending segments, do not attempt to open the current download one, only open the first available in the cache - if (!check_buffer_level && !in_progressive_mode) + if (!check_buffer_level && !in_progressive_mode) in_progressive_mode = 2; - + //update data isor_segment_switch_or_refresh(read, in_progressive_mode); @@ -690,19 +714,19 @@ void isor_flush_data(ISOMReader *read, Bool check_buffer_level, Bool is_chunk_fl count = gf_list_count(read->channels); for (i=0; ichannels, i); - + while (!ch->sample) { isor_reader_get_sample(ch); if (!ch->sample) break; - gf_term_on_sl_packet(read->service, ch->channel, ch->sample->data, ch->sample->dataLength, &ch->current_slh, GF_OK); + gf_service_send_packet(read->service, ch->channel, ch->sample->data, ch->sample->dataLength, &ch->current_slh, GF_OK); isor_reader_release_sample(ch); } - if (!ch->sample && (ch->last_state==GF_EOS)) { - gf_term_on_sl_packet(read->service, ch->channel, NULL, 0, NULL, GF_EOS); + if (!ch->sample && (ch->last_state==GF_EOS)) { + gf_service_send_packet(read->service, ch->channel, NULL, 0, NULL, GF_EOS); } } - //done playing the file after notification from DASH client: + //done playing the file after notification from DASH client: if (read->seg_opened==2) { GF_NetworkCommand param; //drop this segment @@ -715,14 +739,20 @@ void isor_flush_data(ISOMReader *read, Bool check_buffer_level, Bool is_chunk_fl if (read->has_pending_segments) { read->has_pending_segments--; - } + } if (e==GF_EOS) { for (i=0; ichannels, i); - gf_term_on_sl_packet(read->service, ch->channel, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(read->service, ch->channel, NULL, 0, NULL, GF_EOS); } } + //not enough data + else if (param.url_query.in_end_of_period) { + //act as if we have a pending segment to process at next call until we get to the next period + if (!read->has_pending_segments) + read->has_pending_segments++; + } /*close current segment*/ gf_isom_release_segment(read->mov, 1); diff --git a/modules/jack/jack.c b/modules/jack/jack.c index a8ee027..5fb2774 100644 --- a/modules/jack/jack.c +++ b/modules/jack/jack.c @@ -21,18 +21,17 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include #include #include -#include #include #include #include @@ -44,14 +43,14 @@ int getPid () { - return getpid (); + return getpid (); } #else - // FIXME : get handle under WIN32 ? +#include int getPid () { - return 1979; + return GetCurrentProcessId(); } #endif @@ -61,19 +60,19 @@ getPid () */ typedef struct { - char jackClientName[MAX_JACK_CLIENT_NAME_SZ]; - jack_client_t *jack; - jack_port_t **jackPorts; - jack_nframes_t currentBlockSize; - u32 numChannels; - char *buffer; - u32 bufferSz; - u32 bytesPerSample; - char isActive; - char autoConnect; - char autoStartJackd; - jack_default_audio_sample_t **channels; - float volume; + char jackClientName[MAX_JACK_CLIENT_NAME_SZ]; + jack_client_t *jack; + jack_port_t **jackPorts; + jack_nframes_t currentBlockSize; + u32 numChannels; + char *buffer; + u32 bufferSz; + u32 bytesPerSample; + char isActive; + char autoConnect; + char autoStartJackd; + jack_default_audio_sample_t **channels; + float volume; } JackContext; #ifndef TRUE @@ -86,45 +85,45 @@ typedef struct static void Jack_cleanup (JackContext * ctx) { - u32 channels = 0; - if (ctx == NULL) - return; - ctx->isActive = 0; - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[Jack] Jack_cleanup\n")); - if (ctx->jack != NULL && ctx->isActive) - { - jack_deactivate (ctx->jack); - } - if (ctx->buffer != NULL) - { - gf_free(ctx->buffer); - ctx->bufferSz = 0; - ctx->buffer = NULL; - } - if (ctx->jackPorts != NULL) - { - for (channels = 0; channels < ctx->numChannels; channels++) + u32 channels = 0; + if (ctx == NULL) + return; + ctx->isActive = 0; + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[Jack] Jack_cleanup\n")); + if (ctx->jack != NULL && ctx->isActive) { - if (ctx->jackPorts[channels] != NULL) - jack_port_unregister (ctx->jack, ctx->jackPorts[channels]); - ctx->jackPorts[channels] = NULL; + jack_deactivate (ctx->jack); } - gf_free(ctx->jackPorts); - ctx->jackPorts = NULL; - } - if (ctx->jack != NULL) - { - jack_client_close (ctx->jack); - } - if (ctx->channels != NULL) - { - gf_free(ctx->channels); - ctx->channels = NULL; - } - ctx->numChannels = 0; - ctx->currentBlockSize = 0; - bzero (ctx->jackClientName, MAX_JACK_CLIENT_NAME_SZ); - ctx->jack = NULL; + if (ctx->buffer != NULL) + { + gf_free(ctx->buffer); + ctx->bufferSz = 0; + ctx->buffer = NULL; + } + if (ctx->jackPorts != NULL) + { + for (channels = 0; channels < ctx->numChannels; channels++) + { + if (ctx->jackPorts[channels] != NULL) + jack_port_unregister (ctx->jack, ctx->jackPorts[channels]); + ctx->jackPorts[channels] = NULL; + } + gf_free(ctx->jackPorts); + ctx->jackPorts = NULL; + } + if (ctx->jack != NULL) + { + jack_client_close (ctx->jack); + } + if (ctx->channels != NULL) + { + gf_free(ctx->channels); + ctx->channels = NULL; + } + ctx->numChannels = 0; + ctx->currentBlockSize = 0; + memset (ctx->jackClientName, 0, MAX_JACK_CLIENT_NAME_SZ); + ctx->jack = NULL; } /** @@ -133,46 +132,46 @@ Jack_cleanup (JackContext * ctx) static int process_callback (jack_nframes_t nframes, void *arg) { - uint channel, i; - short *tmpBuffer; - size_t toRead; - size_t bytesToRead; - size_t readen; - GF_AudioOutput *dr = (GF_AudioOutput *) arg; - JackContext *ctx; - if (dr == NULL) - { - // Should not happen - return 1; - } - ctx = dr->opaque; - toRead = nframes * ctx->numChannels; - bytesToRead = toRead * ctx->bytesPerSample; - readen = dr->FillBuffer (dr->audio_renderer, (void *) ctx->buffer, - bytesToRead); - toRead = readen / ctx->bytesPerSample; - if (ctx->bytesPerSample == 2) - { - tmpBuffer = (short *) ctx->buffer; - for (channel = 0; channel < nframes; channel += ctx->numChannels) + unsigned int channel, i; + short *tmpBuffer; + size_t toRead; + size_t bytesToRead; + size_t readen; + GF_AudioOutput *dr = (GF_AudioOutput *) arg; + JackContext *ctx; + if (dr == NULL) { - for (i = 0; i < ctx->numChannels; i++) - ctx->channels[i][channel] = - (float) (ctx->volume / 32768.0 * - (tmpBuffer[channel * ctx->numChannels + i])); + // Should not happen + return 1; } - } - else - { - for (channel = 0; channel < nframes; channel += ctx->numChannels) + ctx = dr->opaque; + toRead = nframes * ctx->numChannels; + bytesToRead = toRead * ctx->bytesPerSample; + readen = dr->FillBuffer (dr->audio_renderer, (void *) ctx->buffer, + bytesToRead); + toRead = readen / ctx->bytesPerSample; + if (ctx->bytesPerSample == 2) { - for (i = 0; i < ctx->numChannels; i++) - ctx->channels[i][channel] = - (float) (ctx->volume / 255.0 * - (ctx->buffer[channel * ctx->numChannels + i])); + tmpBuffer = (short *) ctx->buffer; + for (channel = 0; channel < nframes; channel += ctx->numChannels) + { + for (i = 0; i < ctx->numChannels; i++) + ctx->channels[i][channel] = + (float) (ctx->volume / 32768.0 * + (tmpBuffer[channel * ctx->numChannels + i])); + } } - } - return 0; + else + { + for (channel = 0; channel < nframes; channel += ctx->numChannels) + { + for (i = 0; i < ctx->numChannels; i++) + ctx->channels[i][channel] = + (float) (ctx->volume / 255.0 * + (ctx->buffer[channel * ctx->numChannels + i])); + } + } + return 0; } /** @@ -181,57 +180,57 @@ process_callback (jack_nframes_t nframes, void *arg) static int onBufferSizeChanged (jack_nframes_t nframes, void *arg) { - GF_AudioOutput *dr = (GF_AudioOutput *) arg; - JackContext *ctx; - size_t realBuffSize; - u32 channel; - if (dr == NULL) - { - // Should not happen - return 1; - } - ctx = dr->opaque; - realBuffSize = nframes * ctx->numChannels * sizeof (short); - if (ctx->buffer != NULL && ctx->bufferSz == realBuffSize) - return 0; - if (ctx->channels != NULL) - gf_free(ctx->channels); - ctx->channels = NULL; - ctx->channels = gf_calloc (ctx->numChannels, sizeof (jack_default_audio_sample_t *)); - if (ctx->channels == NULL) - { - Jack_cleanup (ctx); - return 2; - } - for (channel = 0; channel < ctx->numChannels; channel++) - { - ctx->channels[channel] = - jack_port_get_buffer (ctx->jackPorts[channel], nframes); - if (ctx->channels[channel] == NULL) + GF_AudioOutput *dr = (GF_AudioOutput *) arg; + JackContext *ctx; + size_t realBuffSize; + u32 channel; + if (dr == NULL) + { + // Should not happen + return 1; + } + ctx = dr->opaque; + realBuffSize = nframes * ctx->numChannels * sizeof (short); + if (ctx->buffer != NULL && ctx->bufferSz == realBuffSize) + return 0; + if (ctx->channels != NULL) + gf_free(ctx->channels); + ctx->channels = NULL; + ctx->channels = gf_calloc (ctx->numChannels, sizeof (jack_default_audio_sample_t *)); + if (ctx->channels == NULL) + { + Jack_cleanup (ctx); + return 2; + } + for (channel = 0; channel < ctx->numChannels; channel++) + { + ctx->channels[channel] = + jack_port_get_buffer (ctx->jackPorts[channel], nframes); + if (ctx->channels[channel] == NULL) + { + Jack_cleanup (ctx); + return 3; + } + } + + if (ctx->buffer != NULL) + gf_free(ctx->buffer); + ctx->buffer = gf_calloc (realBuffSize, sizeof (char)); + if (ctx->buffer == NULL) + { + Jack_cleanup (ctx); + return 4; + } + ctx->bufferSz = realBuffSize; + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[Jack] onBufferSizeChanged : resized to %d.\n", realBuffSize)); + if (ctx->buffer == NULL) { - Jack_cleanup (ctx); - return 3; + ctx->bufferSz = 0; + Jack_cleanup (ctx); + return 5; } - } - - if (ctx->buffer != NULL) - gf_free(ctx->buffer); - ctx->buffer = gf_calloc (realBuffSize, sizeof (char)); - if (ctx->buffer == NULL) - { - Jack_cleanup (ctx); - return 4; - } - ctx->bufferSz = realBuffSize; - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[Jack] onBufferSizeChanged : resized to %d.\n", realBuffSize)); - if (ctx->buffer == NULL) - { - ctx->bufferSz = 0; - Jack_cleanup (ctx); - return 5; - } - return 0; + return 0; } static const char *MODULE_NAME = "Jack"; @@ -247,295 +246,295 @@ static const char *YES_OPTION = "yes"; static char optionIsTrue (const char *optionValue) { - return (0 == strcasecmp (TRUE_OPTION, optionValue) || - 0 == strcasecmp (YES_OPTION, optionValue) - || 0 == strcmp ("1", optionValue)); + return (0 == strcasecmp (TRUE_OPTION, optionValue) || + 0 == strcasecmp (YES_OPTION, optionValue) + || 0 == strcmp ("1", optionValue)); } static GF_Err Jack_Setup (GF_AudioOutput * dr, void *os_handle, u32 num_buffers, - u32 total_duration) + u32 total_duration) { - const char *opt; - JackContext *ctx = (JackContext *) dr->opaque; - jack_status_t status; - jack_options_t options = JackNullOption; - - memset (ctx->jackClientName, 0, MAX_JACK_CLIENT_NAME_SZ); - snprintf (ctx->jackClientName, MAX_JACK_CLIENT_NAME_SZ, "gpac-%d", - getPid ()); - - opt = - gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, - AUTO_CONNECT_OPTION); - if (opt != NULL) - { - if (optionIsTrue (opt)) - ctx->autoConnect = TRUE; - else - ctx->autoConnect = FALSE; - } - else - { - ctx->autoConnect = TRUE; - gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, - AUTO_CONNECT_OPTION, YES_OPTION); - } - opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, - AUTO_START_JACKD_OPTION); - if (opt != NULL) - { - if (optionIsTrue (opt)) - ctx->autoStartJackd = TRUE; - else - ctx->autoStartJackd = FALSE; - } - else - { - ctx->autoStartJackd = TRUE; - gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, - AUTO_START_JACKD_OPTION, YES_OPTION); - } - if (!ctx->autoStartJackd) - { - options |= JackNoStartServer; - } - ctx->jack = jack_client_open (ctx->jackClientName, options, &status, NULL); - if (status & JackNameNotUnique) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[Jack] Cannot open connection to jackd as %s since name was not unique.\n", - ctx->jackClientName)); - Jack_cleanup (ctx); - return GF_IO_ERR; - } - - if (ctx->jack == NULL) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[Jack] Cannot open connection to jackd as %s.\n", - ctx->jackClientName)); - return GF_IO_ERR; - } - return GF_OK; + const char *opt; + JackContext *ctx = (JackContext *) dr->opaque; + jack_status_t status; + jack_options_t options = JackNullOption; + + memset (ctx->jackClientName, 0, MAX_JACK_CLIENT_NAME_SZ); + snprintf (ctx->jackClientName, MAX_JACK_CLIENT_NAME_SZ, "gpac-%d", + getPid ()); + + opt = + gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, + AUTO_CONNECT_OPTION); + if (opt != NULL) + { + if (optionIsTrue (opt)) + ctx->autoConnect = TRUE; + else + ctx->autoConnect = FALSE; + } + else + { + ctx->autoConnect = TRUE; + gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, + AUTO_CONNECT_OPTION, YES_OPTION); + } + opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, + AUTO_START_JACKD_OPTION); + if (opt != NULL) + { + if (optionIsTrue (opt)) + ctx->autoStartJackd = TRUE; + else + ctx->autoStartJackd = FALSE; + } + else + { + ctx->autoStartJackd = TRUE; + gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, + AUTO_START_JACKD_OPTION, YES_OPTION); + } + if (!ctx->autoStartJackd) + { + options |= JackNoStartServer; + } + ctx->jack = jack_client_open (ctx->jackClientName, options, &status, NULL); + if (status & JackNameNotUnique) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[Jack] Cannot open connection to jackd as %s since name was not unique.\n", + ctx->jackClientName)); + Jack_cleanup (ctx); + return GF_IO_ERR; + } + + if (ctx->jack == NULL) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[Jack] Cannot open connection to jackd as %s.\n", + ctx->jackClientName)); + return GF_IO_ERR; + } + return GF_OK; } static void Jack_Shutdown (GF_AudioOutput * dr) { - JackContext *ctx = (JackContext *) dr->opaque; - Jack_cleanup (ctx); + JackContext *ctx = (JackContext *) dr->opaque; + Jack_cleanup (ctx); } #define JACK_PORT_NAME_MAX_SZ 128 static GF_Err Jack_ConfigureOutput (GF_AudioOutput * dr, u32 * SampleRate, u32 * NbChannels, - u32 * nbBitsPerSample, u32 channel_cfg) + u32 * nbBitsPerSample, u32 channel_cfg) { - u32 channels; - u32 i; - char port_name[JACK_PORT_NAME_MAX_SZ]; - JackContext *ctx = (JackContext *) dr->opaque; - if (!ctx) - return GF_BAD_PARAM; - ctx->bytesPerSample = *nbBitsPerSample / 8; - if (ctx->bytesPerSample > 2 || ctx->bytesPerSample < 1) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[Jack] Jack-ConfigureOutput : unable to use %d bits/sample.\n")); - return GF_BAD_PARAM; - } - ctx->numChannels = *NbChannels; - *SampleRate = jack_get_sample_rate (ctx->jack); - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[Jack] Jack_ConfigureOutput channels=%d, srate=%d bits/sample=%d\n", - *NbChannels, *SampleRate, *nbBitsPerSample)); - if (ctx->jackPorts == NULL) - ctx->jackPorts = gf_calloc (ctx->numChannels, sizeof (jack_port_t *)); - if (ctx->jackPorts == NULL) - { - goto exit_cleanup; - } - if (!ctx->isActive) - { - for (channels = 0; channels < ctx->numChannels; channels++) + u32 channels; + u32 i; + char port_name[JACK_PORT_NAME_MAX_SZ]; + JackContext *ctx = (JackContext *) dr->opaque; + if (!ctx) + return GF_BAD_PARAM; + ctx->bytesPerSample = *nbBitsPerSample / 8; + if (ctx->bytesPerSample > 2 || ctx->bytesPerSample < 1) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[Jack] Jack-ConfigureOutput : unable to use %d bits/sample.\n")); + return GF_BAD_PARAM; + } + ctx->numChannels = *NbChannels; + *SampleRate = jack_get_sample_rate (ctx->jack); + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[Jack] Jack_ConfigureOutput channels=%d, srate=%d bits/sample=%d\n", + *NbChannels, *SampleRate, *nbBitsPerSample)); + if (ctx->jackPorts == NULL) + ctx->jackPorts = gf_calloc (ctx->numChannels, sizeof (jack_port_t *)); + if (ctx->jackPorts == NULL) + { + goto exit_cleanup; + } + if (!ctx->isActive) { - snprintf (port_name, JACK_PORT_NAME_MAX_SZ, "playback_%d", - channels + 1); - ctx->jackPorts[channels] = - jack_port_register (ctx->jack, port_name, JACK_DEFAULT_AUDIO_TYPE, - JackPortIsOutput, 0); - if (ctx->jackPorts[channels] == NULL) - goto exit_cleanup; + for (channels = 0; channels < ctx->numChannels; channels++) + { + snprintf (port_name, JACK_PORT_NAME_MAX_SZ, "playback_%d", + channels + 1); + ctx->jackPorts[channels] = + jack_port_register (ctx->jack, port_name, JACK_DEFAULT_AUDIO_TYPE, + JackPortIsOutput, 0); + if (ctx->jackPorts[channels] == NULL) + goto exit_cleanup; + } + onBufferSizeChanged (jack_get_buffer_size (ctx->jack), dr); + jack_set_buffer_size_callback (ctx->jack, onBufferSizeChanged, dr); + jack_set_process_callback (ctx->jack, process_callback, dr); } - onBufferSizeChanged (jack_get_buffer_size (ctx->jack), dr); - jack_set_buffer_size_callback (ctx->jack, onBufferSizeChanged, dr); - jack_set_process_callback (ctx->jack, process_callback, dr); - } - ctx->currentBlockSize = jack_get_buffer_size (ctx->jack); - if (!ctx->isActive) - { - jack_activate (ctx->jack); - if (ctx->autoConnect) + ctx->currentBlockSize = jack_get_buffer_size (ctx->jack); + if (!ctx->isActive) { - const char **matching_outputs = - jack_get_ports (ctx->jack, NULL, NULL, - JackPortIsInput | JackPortIsPhysical | - JackPortIsTerminal); - if (matching_outputs != NULL) - { - channels = 0; - i = 0; - while (matching_outputs[i] != NULL - && channels < ctx->numChannels) + jack_activate (ctx->jack); + if (ctx->autoConnect) { - if (!jack_connect (ctx->jack, - jack_port_name (ctx-> - jackPorts[channels++]), - matching_outputs[i])) - { - GF_LOG (GF_LOG_INFO, GF_LOG_MMIO, - ("[Jack] Jack_ConfigureOutput: Failed to connect port[%d] to %s.\n", - channels - 1, matching_outputs[i])); - } - i++; + const char **matching_outputs = + jack_get_ports (ctx->jack, NULL, NULL, + JackPortIsInput | JackPortIsPhysical | + JackPortIsTerminal); + if (matching_outputs != NULL) + { + channels = 0; + i = 0; + while (matching_outputs[i] != NULL + && channels < ctx->numChannels) + { + if (!jack_connect (ctx->jack, + jack_port_name (ctx-> + jackPorts[channels++]), + matching_outputs[i])) + { + GF_LOG (GF_LOG_INFO, GF_LOG_MMIO, + ("[Jack] Jack_ConfigureOutput: Failed to connect port[%d] to %s.\n", + channels - 1, matching_outputs[i])); + } + i++; + } + } } - } + ctx->isActive = TRUE; } - ctx->isActive = TRUE; - } - return GF_OK; + return GF_OK; exit_cleanup: - Jack_cleanup (ctx); - return GF_IO_ERR; + Jack_cleanup (ctx); + return GF_IO_ERR; } static void Jack_SetVolume (GF_AudioOutput * dr, u32 Volume) { - JackContext *ctx = (JackContext *) dr->opaque; - if (ctx == NULL) - { - return; - } - /* We support ajust the volume to more than 100, up to +6dB even - * if frontends don't support it, it may be useful */ - if (Volume > 400) - Volume = 400; - ctx->volume = (float) Volume / 100.0; - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[Jack] Jack_SetVolume: Volume set to %d%%.\n", Volume)); + JackContext *ctx = (JackContext *) dr->opaque; + if (ctx == NULL) + { + return; + } + /* We support ajust the volume to more than 100, up to +6dB even + * if frontends don't support it, it may be useful */ + if (Volume > 400) + Volume = 400; + ctx->volume = (float) Volume / 100.0; + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[Jack] Jack_SetVolume: Volume set to %d%%.\n", Volume)); } static void Jack_SetPan (GF_AudioOutput * dr, u32 Pan) { - GF_LOG (GF_LOG_INFO, GF_LOG_MMIO, ("[Jack] Jack_SetPan: Not supported.\n")); + GF_LOG (GF_LOG_INFO, GF_LOG_MMIO, ("[Jack] Jack_SetPan: Not supported.\n")); } static void Jack_SetPriority (GF_AudioOutput * dr, u32 Priority) { - /** - * Jack manages the priority itself, we don't need - * to interfere here... - */ + /** + * Jack manages the priority itself, we don't need + * to interfere here... + */ } static u32 Jack_GetAudioDelay (GF_AudioOutput * dr) { - jack_nframes_t max = 0; - jack_nframes_t latency; - u32 channel; - JackContext *ctx = (JackContext *) dr->opaque; - if (ctx == NULL) - { - return 0; - } - jack_recompute_total_latencies (ctx->jack); - for (channel = 0; channel < ctx->numChannels; channel++) - { - latency = - jack_port_get_total_latency (ctx->jack, ctx->jackPorts[channel]); - if (latency > max) - max = latency; - } - channel = max * 1000 / jack_get_sample_rate (ctx->jack); - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[Jack] Jack_GetAudioDelay latency = %d ms.\n", channel)); - return channel; + jack_nframes_t max = 0; + jack_nframes_t latency; + u32 channel; + JackContext *ctx = (JackContext *) dr->opaque; + if (ctx == NULL) + { + return 0; + } + jack_recompute_total_latencies (ctx->jack); + for (channel = 0; channel < ctx->numChannels; channel++) + { + latency = + jack_port_get_total_latency (ctx->jack, ctx->jackPorts[channel]); + if (latency > max) + max = latency; + } + channel = max * 1000 / jack_get_sample_rate (ctx->jack); + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[Jack] Jack_GetAudioDelay latency = %d ms.\n", channel)); + return channel; } static GF_Err Jack_QueryOutputSampleRate (GF_AudioOutput * dr, u32 * desired_sr, - u32 * NbChannels, u32 * nbBitsPerSample) + u32 * NbChannels, u32 * nbBitsPerSample) { - JackContext *ctx = (JackContext *) dr->opaque; - if (!ctx) - return GF_IO_ERR; - *desired_sr = jack_get_sample_rate (ctx->jack); - *NbChannels = 2; - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[Jack] Jack output sample rate %d\n", *desired_sr)); - return GF_OK; + JackContext *ctx = (JackContext *) dr->opaque; + if (!ctx) + return GF_IO_ERR; + *desired_sr = jack_get_sample_rate (ctx->jack); + *NbChannels = 2; + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[Jack] Jack output sample rate %d\n", *desired_sr)); + return GF_OK; } void * NewJackOutput () { - JackContext *ctx; - GF_AudioOutput *driv; - GF_SAFEALLOC (ctx, JackContext); - if (!ctx) - return NULL; - GF_SAFEALLOC (driv, GF_AudioOutput); - if (!driv) - { - gf_free(ctx); - return NULL; - } - driv->opaque = ctx; - driv->SelfThreaded = 1; - driv->Setup = Jack_Setup; - driv->Shutdown = Jack_Shutdown; - driv->ConfigureOutput = Jack_ConfigureOutput; - driv->GetAudioDelay = Jack_GetAudioDelay; - driv->SetVolume = Jack_SetVolume; - driv->SetPan = Jack_SetPan; - driv->SetPriority = Jack_SetPriority; - driv->QueryOutputSampleRate = Jack_QueryOutputSampleRate; - - ctx->jack = NULL; - ctx->numChannels = 0; - ctx->jackPorts = NULL; - ctx->currentBlockSize = 0; - ctx->numChannels = 0; - ctx->buffer = NULL; - ctx->bufferSz = 0; - ctx->bytesPerSample = 0; - ctx->isActive = FALSE; - ctx->autoConnect = FALSE; - ctx->autoStartJackd = FALSE; - ctx->volume = 1.0; - - GF_REGISTER_MODULE_INTERFACE (driv, GF_AUDIO_OUTPUT_INTERFACE, - "Jack Audio Output", "gpac distribution"); - return driv; + JackContext *ctx; + GF_AudioOutput *driv; + GF_SAFEALLOC (ctx, JackContext); + if (!ctx) + return NULL; + GF_SAFEALLOC (driv, GF_AudioOutput); + if (!driv) + { + gf_free(ctx); + return NULL; + } + driv->opaque = ctx; + driv->SelfThreaded = 1; + driv->Setup = Jack_Setup; + driv->Shutdown = Jack_Shutdown; + driv->ConfigureOutput = Jack_ConfigureOutput; + driv->GetAudioDelay = Jack_GetAudioDelay; + driv->SetVolume = Jack_SetVolume; + driv->SetPan = Jack_SetPan; + driv->SetPriority = Jack_SetPriority; + driv->QueryOutputSampleRate = Jack_QueryOutputSampleRate; + + ctx->jack = NULL; + ctx->numChannels = 0; + ctx->jackPorts = NULL; + ctx->currentBlockSize = 0; + ctx->numChannels = 0; + ctx->buffer = NULL; + ctx->bufferSz = 0; + ctx->bytesPerSample = 0; + ctx->isActive = FALSE; + ctx->autoConnect = FALSE; + ctx->autoStartJackd = FALSE; + ctx->volume = 1.0; + + GF_REGISTER_MODULE_INTERFACE (driv, GF_AUDIO_OUTPUT_INTERFACE, + "Jack Audio Output", "gpac distribution"); + return driv; } void DeleteJackOutput (void *ifce) { - GF_AudioOutput *dr = (GF_AudioOutput *) ifce; - JackContext *ctx = (JackContext *) dr->opaque; - Jack_cleanup (ctx); - gf_free(ctx); - dr->opaque = NULL; - gf_free(dr); + GF_AudioOutput *dr = (GF_AudioOutput *) ifce; + JackContext *ctx = (JackContext *) dr->opaque; + Jack_cleanup (ctx); + gf_free(ctx); + dr->opaque = NULL; + gf_free(dr); } /* @@ -556,18 +555,18 @@ const u32 *QueryInterfaces() GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface (u32 InterfaceType) { - if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) - { - return NewJackOutput (); - } - return NULL; + if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + { + return NewJackOutput (); + } + return NULL; } GPAC_MODULE_EXPORT void ShutdownInterface (GF_BaseInterface * ifce) { - if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) - DeleteJackOutput ((GF_AudioOutput *) ifce); + if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + DeleteJackOutput ((GF_AudioOutput *) ifce); } GPAC_MODULE_STATIC_DELARATION( jack ) diff --git a/modules/laser_dec/laser_dec.c b/modules/laser_dec/laser_dec.c index 6805f96..9df3408 100644 --- a/modules/laser_dec/laser_dec.c +++ b/modules/laser_dec/laser_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -93,7 +93,7 @@ static GF_Err LSR_DetachStream(GF_BaseDecoder *plug, u16 ES_ID) } static GF_Err LSR_ProcessData(GF_SceneDecoder*plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_time, u32 mmlevel) + u16 ES_ID, u32 AU_time, u32 mmlevel) { GF_Err e = GF_OK; LSRPriv *priv = (LSRPriv *)plug->privateStack; @@ -118,17 +118,17 @@ static u32 LSR_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *esd void DeleteLSRDec(GF_BaseDecoder *plug) { LSRPriv *priv; - if (!plug) - return; - priv = (LSRPriv *)plug->privateStack; - if (priv){ - /*in case something went wrong*/ - if (priv->codec) - gf_laser_decoder_del(priv->codec); - priv->codec = NULL; - gf_free(priv); - plug->privateStack = NULL; - } + if (!plug) + return; + priv = (LSRPriv *)plug->privateStack; + if (priv) { + /*in case something went wrong*/ + if (priv->codec) + gf_laser_decoder_del(priv->codec); + priv->codec = NULL; + gf_free(priv); + plug->privateStack = NULL; + } gf_free(plug); } diff --git a/modules/libplayer/libplayer.c b/modules/libplayer/libplayer.c index 2dc6714..5738900 100644 --- a/modules/libplayer/libplayer.c +++ b/modules/libplayer/libplayer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -45,12 +45,12 @@ typedef s32 off_t; #endif -// variable used to detect the number of libplayer instances created - up to 2 instances +// variable used to detect the number of libplayer instances created - up to 2 instances static int libplayer_id = 0; -//! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user +//! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user //! uses the navigation button -// value for input output windows, when save_data_instance1 equals to 1 <=> the second instance is already created with the correct size, -// save these values in in_instance1 and out_instance1 so that we do not need to recalculate every time +// value for input output windows, when save_data_instance1 equals to 1 <=> the second instance is already created with the correct size, +// save these values in in_instance1 and out_instance1 so that we do not need to recalculate every time //~ static video_rect_t in_instance1, out_instance1; //~ static save_data_instance1 = 0; @@ -74,7 +74,7 @@ typedef struct u32 player_type; u32 width; u32 height; - char *url; + char *url; #ifndef TEST_LIBPLAYER player_t *player; #endif @@ -83,35 +83,35 @@ typedef struct static const char * LIBPLAYER_MIME_TYPES[] = { - "video/x-mpeg", "mpg mpeg mp2 mpa mpe mpv2 ts", "MPEG 1/2 Movies", - "video/x-mpeg-systems", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", - "audio/basic", "snd au", "Basic Audio", - "audio/x-wav", "wav", "WAV Audio", - "audio/vnd.wave", "wav", "WAV Audio", - "video/x-ms-asf", "asf wma wmv asx asr", "WindowsMedia Movies", - "video/x-ms-wmv", "asf wma wmv asx asr", "WindowsMedia Movies", - "video/x-msvideo", "avi", "AVI Movies", - "video/x-ms-video", "avi", "AVI Movies", - "video/avi", "avi", "AVI Movies", - "video/vnd.avi", "avi", "AVI Movies", - "video/H263", "h263 263", "H263 Video", - "video/H264", "h264 264", "H264 Video", - "video/MPEG4", "cmp", "MPEG-4 Video", - "video/mp4", "mp4", "MPEG-4 Movie", - "video/quicktime", "mov qt", "QuickTime Movies", - "video/webm", "webm", "Google WebM Movies", - "audio/webm", "webm", "Google WebM Music", - NULL + "video/x-mpeg", "mpg mpeg mp2 mpa mpe mpv2 ts", "MPEG 1/2 Movies", + "video/x-mpeg-systems", "mpg mpeg mp2 mpa mpe mpv2", "MPEG 1/2 Movies", + "audio/basic", "snd au", "Basic Audio", + "audio/x-wav", "wav", "WAV Audio", + "audio/vnd.wave", "wav", "WAV Audio", + "video/x-ms-asf", "asf wma wmv asx asr", "WindowsMedia Movies", + "video/x-ms-wmv", "asf wma wmv asx asr", "WindowsMedia Movies", + "video/x-msvideo", "avi", "AVI Movies", + "video/x-ms-video", "avi", "AVI Movies", + "video/avi", "avi", "AVI Movies", + "video/vnd.avi", "avi", "AVI Movies", + "video/H263", "h263 263", "H263 Video", + "video/H264", "h264 264", "H264 Video", + "video/MPEG4", "cmp", "MPEG-4 Video", + "video/mp4", "mp4", "MPEG-4 Movie", + "video/quicktime", "mov qt", "QuickTime Movies", + "video/webm", "webm", "Google WebM Movies", + "audio/webm", "webm", "Google WebM Music", + NULL }; -static u32 LIBPLAYER_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - if (!plug) - return 0; - for (i = 0 ; LIBPLAYER_MIME_TYPES[i] ; i+=3) - gf_term_register_mime_type(plug, LIBPLAYER_MIME_TYPES[i], LIBPLAYER_MIME_TYPES[i+1], LIBPLAYER_MIME_TYPES[i+2]); - return i / 3; +static u32 LIBPLAYER_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + if (!plug) + return 0; + for (i = 0 ; LIBPLAYER_MIME_TYPES[i] ; i+=3) + gf_service_register_mime(plug, LIBPLAYER_MIME_TYPES[i], LIBPLAYER_MIME_TYPES[i+1], LIBPLAYER_MIME_TYPES[i+2]); + return i / 3; } Bool LIBPLAYER_CanHandleURL(GF_InputService *plug, const char *url) @@ -139,7 +139,7 @@ Bool LIBPLAYER_CanHandleURL(GF_InputService *plug, const char *url) if (cgi_par) cgi_par[0] = '?'; if (ok) return 1; } - + return 0; } @@ -153,18 +153,18 @@ static int on_libplayer_event(player_event_t e, void *data) case PLAYER_EVENT_PLAYBACK_FINISHED: player_playback_stop(data); player_playback_start(data); - break; - case PLAYER_EVENT_FE_HAS_LOCK: - break; - case PLAYER_EVENT_FE_TIMEDOUT: - break; - case PLAYER_EVENT_VIDEO_PICTURE: - break; - default: - break; - } - - return 0; + break; + case PLAYER_EVENT_FE_HAS_LOCK: + break; + case PLAYER_EVENT_FE_TIMEDOUT: + break; + case PLAYER_EVENT_VIDEO_PICTURE: + break; + default: + break; + } + + return 0; } @@ -179,11 +179,11 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c #endif GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Connecting\n")); - + if (!read || !serv || !url) return GF_BAD_PARAM; if (!strnicmp(url, "libplayer://", 12)) url+=12; - + if (!read->init) { read->init=1; /* libplayer init with default width/height */ @@ -192,30 +192,30 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c read->url = url; read->player_id = libplayer_id; read->player_type = PLAYER_FILE; - + #ifndef TEST_LIBPLAYER read->player = player_init(PLAYER_TYPE_DUMMY, PLAYER_AO_AUTO, PLAYER_VO_AUTO, PLAYER_MSG_INFO, read->player_id, on_libplayer_event); - + if (!read->player) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Failed to instanciate libplayer instance %d\n", read->player_id)); - gf_term_on_connect(serv, NULL, GF_REMOTE_SERVICE_ERROR); + gf_service_connect_ack(serv, NULL, GF_REMOTE_SERVICE_ERROR); return GF_OK; } #endif libplayer_id++; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Opening URL %s for Player instance %d\n", url, read->player_id)); } - + #ifndef TEST_LIBPLAYER mrl = NULL; - - // dvb + + // dvb if (!strnicmp(url, "dvb://", 6)) { read->player_type = PLAYER_DVB; mrl_resource_dvb_args_t *mrl_dvb_args; mrl_dvb_args = calloc(1, sizeof(mrl_resource_dvb_args_t)); char *frequency; - + // fetch frequency if (frequency = strchr(url+6, '@')) { char *enc, *pid; @@ -235,15 +235,15 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Unknown video encoding\n")); mrl_dvb_args->video_enc = PLAYER_VIDEO_UNKNOWN; } - + // video PID if (mrl_dvb_args->video_enc != PLAYER_VIDEO_UNKNOWN) { pid = strchr(enc, ':'); mrl_dvb_args->video_pid = atoi(pid+1); } - + /* - * audio + * audio */ // audio codec if (enc = strstr(url+6, "mp2")) { @@ -256,13 +256,13 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Unknown audio encoding\n")); mrl_dvb_args->audio_enc = PLAYER_AUDIO_UNKNOWN; } - + // audio PID if (mrl_dvb_args->audio_enc != PLAYER_AUDIO_UNKNOWN) { pid = strchr(enc, ':'); mrl_dvb_args->audio_pid = atoi(pid+1); } - + if (mrl_dvb_args->video_enc == PLAYER_VIDEO_UNKNOWN && mrl_dvb_args->audio_enc == PLAYER_AUDIO_UNKNOWN) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Unknown video and audio encoding\n")); free(mrl_dvb_args); @@ -275,12 +275,12 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c return GF_BAD_PARAM; } - // player instance 1 has not starter yet in dvb case <=> player instance 1 is not created yet + // player instance 1 has not starter yet in dvb case <=> player instance 1 is not created yet if (start_dvb == 0) { mrl = mrl_new(read->player, MRL_RESOURCE_DVB, mrl_dvb_args); GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] MRL created for DVB\n")); - - // player has already started, zapping case, make sure the player is not recreated + + // player has already started, zapping case, make sure the player is not recreated } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Starting DVB PES filtering\n")); player_dvb_pes_filter_start(read->player, mrl_dvb_args->video_enc, mrl_dvb_args->video_pid, mrl_dvb_args->audio_enc, mrl_dvb_args->audio_pid); @@ -296,17 +296,17 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c mrl_args->location = strdup(url); } mrl = mrl_new (read->player, MRL_RESOURCE_FILE, mrl_args); - + } // only for DVB case to make sure player is only set once if (start_dvb == 0) { if (!mrl) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[LibPlayerIN] Failed to create MRL for url %s\n", url)); - gf_term_on_connect(serv, NULL, GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } - + player_mrl_set(read->player, mrl); } @@ -315,7 +315,7 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c read->service = serv; /*ACK connection is OK*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); /*setup LIBPLAYER object descriptor*/ @@ -334,7 +334,7 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c #endif gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } return GF_OK; @@ -343,9 +343,9 @@ GF_Err LIBPLAYER_ConnectService(GF_InputService *plug, GF_ClientService *serv, c GF_Err LIBPLAYER_CloseService(GF_InputService *plug) { LibPlayerIn *read = (LibPlayerIn *) plug->priv; - + #ifndef TEST_LIBPLAYER - // only disconnect if + // only disconnect if if (read->player_type == PLAYER_FILE) { player_playback_stop(read->player); fprintf(stderr, "[LibPlayerIN]player_playback_stop for instance %d\n", read->player_id); @@ -353,15 +353,15 @@ GF_Err LIBPLAYER_CloseService(GF_InputService *plug) fprintf(stderr, "[LibPlayerIN]player_uninit for instance %d\n", read->player_id); read->player = NULL; libplayer_id--; - + read->state = 0; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Closing libplayer instance %d\n", read->player_id)); - - - - // channel zapping dvb case, don't disconnect service + + + + // channel zapping dvb case, don't disconnect service } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Don't close service libplayer instance %d, use this instance for channel zapping\n", read->player_id)); } @@ -387,12 +387,15 @@ GF_Err LIBPLAYER_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (com->command_type==GF_NET_SERVICE_HAS_AUDIO) return GF_NOT_SUPPORTED; switch (com->command_type) { - case GF_NET_CHAN_SET_PULL: return GF_NOT_SUPPORTED; - case GF_NET_CHAN_INTERACTIVE: return GF_OK; + case GF_NET_CHAN_SET_PULL: + return GF_NOT_SUPPORTED; + case GF_NET_CHAN_INTERACTIVE: + return GF_OK; /*since data is file-based, no padding is needed (decoder plugin will handle it itself)*/ - case GF_NET_CHAN_SET_PADDING: return GF_OK; + case GF_NET_CHAN_SET_PADDING: + return GF_OK; case GF_NET_CHAN_BUFFER: - return GF_OK; + return GF_OK; com->buffer.max = com->buffer.min = 0; return GF_OK; case GF_NET_CHAN_DURATION: @@ -404,25 +407,25 @@ GF_Err LIBPLAYER_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) #ifndef TEST_LIBPLAYER if ((read->player_id == 0) && (read->player_type == PLAYER_DVB) && (start_dvb == 1)) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Instance %d has already started, zapping mode\n", read->player_id)); - + } else { player_playback_start(read->player); if ((read->player_id == 0) && (read->player_type == PLAYER_DVB)) { start_dvb = 1; } - + read->state = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Starting playback for instance %d\n", read->player_id)); } #endif } - + return GF_OK; case GF_NET_CHAN_STOP: if (read->state==1) { #ifndef TEST_LIBPLAYER // channel zapping, don't stop channel - if ((read->player_id == 0) && (read->player_type == PLAYER_DVB) && (start_dvb = 1)) { + if ((read->player_id == 0) && (read->player_type == PLAYER_DVB) && (start_dvb = 1)) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] Instance %d is in zapping mode, don't stop channel\n", read->player_id)); } else { player_playback_stop(read->player); @@ -432,7 +435,8 @@ GF_Err LIBPLAYER_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) #endif } return GF_OK; - case GF_NET_CHAN_CONFIG: return GF_OK; + case GF_NET_CHAN_CONFIG: + return GF_OK; case GF_NET_CHAN_GET_DSI: com->get_dsi.dsi = NULL; com->get_dsi.dsi_len = 0; @@ -448,9 +452,9 @@ GF_Err LIBPLAYER_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, con sscanf(url, "ES_ID=%ud", &ESID); GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] instance %d connect channel %d\n", read->player_id, ESID)); if (ESID != 1+read->player_id) { - gf_term_on_connect(read->service, channel, GF_STREAM_NOT_FOUND); + gf_service_connect_ack(read->service, channel, GF_STREAM_NOT_FOUND); } else { - gf_term_on_connect(read->service, channel, GF_OK); + gf_service_connect_ack(read->service, channel, GF_OK); } return GF_OK; } @@ -459,7 +463,7 @@ GF_Err LIBPLAYER_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { LibPlayerIn *read = (LibPlayerIn *) plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] instance %d disconnect channel\n", read->player_id)); - gf_term_on_disconnect(read->service, channel, GF_OK); + gf_service_disconnect_ack(read->service, channel, GF_OK); return GF_OK; } @@ -533,23 +537,23 @@ static GF_Err LIBPLAYER_Control(GF_PrivateMediaDecoder *dec, Bool mute, GF_Windo video_rect_t in, out; LibPlayerIn *read = dec->privateStack; u32 width, height; - + if (!read) return GF_OK; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerDEC] Control instance %d\n",read->player_id)); - //! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user + //! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user //! uses the navigation button //~ if (read->player_id == 1 && save_data_instance1 == 1) { - //~ fprintf(stderr, "in here for save data instance\n"); - //~ player_video_io_windows_set(read->player, &in_instance1, &out_instance1); - //~ - //~ return GF_OK; - //~ + //~ fprintf(stderr, "in here for save data instance\n"); + //~ player_video_io_windows_set(read->player, &in_instance1, &out_instance1); + //~ + //~ return GF_OK; + //~ //~ } else { width = mrl_get_property(read->player, NULL, MRL_PROPERTY_VIDEO_WIDTH); height = mrl_get_property(read->player, NULL, MRL_PROPERTY_VIDEO_HEIGHT); //~ } - + if((width != read->width) || (height != read->height)) { fprintf(stderr, "in here for video size changed\t"); @@ -561,7 +565,7 @@ static GF_Err LIBPLAYER_Control(GF_PrivateMediaDecoder *dec, Bool mute, GF_Windo } return GF_BUFFER_TOO_SMALL; } - + in.x = src->x; in.y = src->y; in.w = src->w; @@ -571,20 +575,20 @@ static GF_Err LIBPLAYER_Control(GF_PrivateMediaDecoder *dec, Bool mute, GF_Windo out.w = dst->w; out.h = dst->h; player_video_io_windows_set(read->player, &in, &out); - - //! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user + + //! unfortunately, saving data would not be a good solution for Mosaic Mode in ESG Application since the position changes everytime user //! uses the navigation button //~ if (read->player_id == 1) { - //~ in_instance1 = in; + //~ in_instance1 = in; //~ // //~ out_instance1.w = out.w; //~ // //~ out_instance1.h = out.h; - //~ out_instance1 = out; - //~ save_data_instance1 = 1; + //~ out_instance1 = out; + //~ save_data_instance1 = 1; //~ } - //~ - + //~ + #endif - + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerDEC] Repositioning video src %d %d %d %d - dest %d %d %d %d\n", src->x, src->y, src->w, src->h, dst->x, dst->y, dst->w, dst->h) ); return GF_OK; } diff --git a/modules/modules_export.cpp b/modules/modules_export.cpp index afed8da..6e25fe2 100644 --- a/modules/modules_export.cpp +++ b/modules/modules_export.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * - * This file is part of GPAC + * This file is part of GPAC * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/mp3_in/mad_dec.c b/modules/mp3_in/mad_dec.c index 1efe787..b86bfb0 100644 --- a/modules/mp3_in/mad_dec.c +++ b/modules/mp3_in/mad_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -199,12 +199,12 @@ static GF_Err MAD_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capab else if (chan < -MAD_F_ONE) \ chan = -MAD_F_ONE; \ ret = chan >> (MAD_F_FRACBITS + 1 - 16); \ - + static GF_Err MAD_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { mad_fixed_t *left_ch, *right_ch, chan; char *ptr; @@ -267,7 +267,7 @@ static GF_Err MAD_ProcessData(GF_MediaDecoder *ifcg, if (ctx->stream.next_frame) { ctx->len = (u32) (&ctx->buffer[ctx->len] - ctx->stream.next_frame); - memmove(ctx->buffer, ctx->stream.next_frame, ctx->len); + memmove(ctx->buffer, ctx->stream.next_frame, ctx->len); } @@ -304,7 +304,7 @@ static GF_Err MAD_ProcessData(GF_MediaDecoder *ifcg, static const char *MAD_GetCodecName(GF_BaseDecoder *dec) { return "MAD " \ - MAD_VERSION; + MAD_VERSION; } static u32 MAD_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, u8 PL) @@ -351,22 +351,22 @@ GF_BaseDecoder *NewMADDec() void DeleteMADDec(GF_MediaDecoder *ifcg) { MADDec *ctx; - if (!ifcg) - return; - ctx = (MADDec *) ifcg->privateStack; - ifcg->privateStack = NULL; - if (ctx){ - if (ctx->configured) { - mad_stream_finish(&ctx->stream); - mad_frame_finish(&ctx->frame); - mad_synth_finish(&ctx->synth); - } - ctx->configured = 0; - ctx->sample_rate = ctx->out_size = ctx->num_samples = 0; - ctx->num_channels = 0; - gf_free(ctx); + if (!ifcg) + return; + ctx = (MADDec *) ifcg->privateStack; + ifcg->privateStack = NULL; + if (ctx) { + if (ctx->configured) { + mad_stream_finish(&ctx->stream); + mad_frame_finish(&ctx->frame); + mad_synth_finish(&ctx->synth); + } + ctx->configured = 0; + ctx->sample_rate = ctx->out_size = ctx->num_samples = 0; + ctx->num_channels = 0; + gf_free(ctx); } - gf_free(ifcg); + gf_free(ifcg); } #endif diff --git a/modules/mp3_in/mp3_in.c b/modules/mp3_in/mp3_in.c index ac71067..a79ba7b 100644 --- a/modules/mp3_in/mp3_in.c +++ b/modules/mp3_in/mp3_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -79,24 +79,24 @@ static const char * MP3_DESC = "MP3 Music"; static u32 MP3_RegisterMimeTypes(const GF_InputService *plug) { - u32 i; - for (i =0 ; MP3_MIME_TYPES[i] ; i++) - gf_term_register_mime_type(plug, MP3_MIME_TYPES[i], MP3_EXTENSIONS, MP3_DESC); - return i; + u32 i; + for (i =0 ; MP3_MIME_TYPES[i] ; i++) + gf_service_register_mime(plug, MP3_MIME_TYPES[i], MP3_EXTENSIONS, MP3_DESC); + return i; } static Bool MP3_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; - if (!plug || !url) - return 0; + if (!plug || !url) + return 0; sExt = strrchr(url, '.'); if (!strnicmp(url, "rtsp://", 7)) return 0; { - u32 i; - for (i =0 ; MP3_MIME_TYPES[i] ; i++) - if (gf_term_check_extension(plug, MP3_MIME_TYPES[i], MP3_EXTENSIONS, MP3_DESC, sExt)) - return 1; + u32 i; + for (i =0 ; MP3_MIME_TYPES[i] ; i++) + if (gf_service_check_mime_register(plug, MP3_MIME_TYPES[i], MP3_EXTENSIONS, MP3_DESC, sExt)) + return 1; } return 0; } @@ -127,7 +127,7 @@ static void mp3_setup_object(MP3Reader *read) od->objectDescriptorID = 1; esd = MP3_GetESD(read); gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } } @@ -143,17 +143,17 @@ static Bool MP3_ConfigureFromFile(MP3Reader *read, u32 *minSizeToRead) u64 pos; if (!read->stream) return 0; /* ID3VVFFFFSIZE = 13bytes - * ID3 string + * ID3 string * VV = Version - * F = Flags - * SIZE = 32bits size with first Most Significant bit set to 0 -> 28 bits + * F = Flags + * SIZE = 32bits size with first Most Significant bit set to 0 -> 28 bits * Size starts AFTER this header, meaning we have to add 10 bytes */ pos = fread(id3v2, sizeof(unsigned char), 10, read->stream); *minSizeToRead = 0; - if (pos == 10){ + if (pos == 10) { /* Did we read an ID3v2 ? */ - if (id3v2[0] == 'I' && id3v2[1] == 'D' && id3v2[2] == '3'){ + if (id3v2[0] == 'I' && id3v2[1] == 'D' && id3v2[2] == '3') { int sz = 10 + ((id3v2[9] & 0x7f) + ((id3v2[8] & 0x7f) << 7) + ((id3v2[7] & 0x7f) << 14) + ((id3v2[6] & 0x7f) << 21)); //printf("Size of id3v2 header = %d\n", sz); *minSizeToRead = sz; @@ -194,7 +194,7 @@ static void MP3_RegulateDataRate(MP3Reader *read) com.command_type = GF_NET_CHAN_BUFFER_QUERY; com.base.on_channel = read->ch; while (read->ch) { - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if (com.buffer.occupancy < com.buffer.max) break; gf_sleep(2); } @@ -214,7 +214,7 @@ static void MP3_OnLiveData(MP3Reader *read, char *data, u32 data_size) memset(&read->sl_hdr, 0, sizeof(GF_SLHeader)); read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_OK); + gf_service_connect_ack(read->service, NULL, GF_OK); mp3_setup_object(read); } if (!data_size) return; @@ -250,7 +250,7 @@ static void MP3_OnLiveData(MP3Reader *read, char *data, u32 data_size) read->sl_hdr.AU_sequenceNumber++; read->sl_hdr.compositionTimeStampFlag = 1; read->sl_hdr.compositionTimeStamp += gf_mp3_window_size(hdr); - gf_term_on_sl_packet(read->service, read->ch, data + pos, size, &read->sl_hdr, GF_OK); + gf_service_send_packet(read->service, read->ch, data + pos, size, &read->sl_hdr, GF_OK); data += pos + size; assert(data_size>=pos+size); data_size -= pos+size; @@ -292,13 +292,13 @@ void MP3_NetIO(void *cbk, GF_NETIO_Parameter *param) if (sep) sep[0] = 0; if (!strnicmp(meta, "StreamTitle=", 12)) { - if (read->icy_track_name) gf_free(read->icy_track_name); - read->icy_track_name = NULL; + if (read->icy_track_name) gf_free(read->icy_track_name); + read->icy_track_name = NULL; read->icy_track_name = gf_strdup(meta+12); - if (!strcmp(read->icy_track_name, "''")){ - /* On some servers, '' means not track name */ - gf_free(read->icy_track_name); - read->icy_track_name = NULL; + if (!strcmp(read->icy_track_name, "''")) { + /* On some servers, '' means not track name */ + gf_free(read->icy_track_name); + read->icy_track_name = NULL; } } if (!sep) break; @@ -307,12 +307,12 @@ void MP3_NetIO(void *cbk, GF_NETIO_Parameter *param) } com.base.command_type = GF_NET_SERVICE_INFO; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); } return; } else { /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); if (param->msg_type!=GF_NETIO_DATA_EXCHANGE) return; } @@ -323,12 +323,12 @@ void MP3_NetIO(void *cbk, GF_NETIO_Parameter *param) } /*looks like a live stream*/ if (read->is_live) { - if (read->liveDataCopySize < param->size){ - read->liveDataCopy = gf_realloc(read->liveDataCopy, param->size); - } - memcpy(read->liveDataCopy, param->data, param->size); - if (!e) MP3_OnLiveData(read, read->liveDataCopy, param->size); - return; + if (read->liveDataCopySize < param->size) { + read->liveDataCopy = gf_realloc(read->liveDataCopy, param->size); + } + memcpy(read->liveDataCopy, param->data, param->size); + if (!e) MP3_OnLiveData(read, read->liveDataCopy, param->size); + return; } if (read->stream) return; @@ -363,7 +363,7 @@ void MP3_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (read->needs_connection) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); if (!e) mp3_setup_object(read); } } @@ -374,10 +374,10 @@ void mp3_download_file(GF_InputService *plug, char *url) read->needs_connection = 1; - read->dnload = gf_term_download_new(read->service, url, 0, MP3_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, MP3_NetIO, read); if (!read->dnload) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -395,7 +395,7 @@ static GF_Err MP3_ConnectService(GF_InputService *plug, GF_ClientService *serv, MP3Reader *read = plug->priv; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; strcpy(szURL, url); @@ -418,7 +418,7 @@ static GF_Err MP3_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->stream = NULL; reply = GF_NOT_SUPPORTED; } - gf_term_on_connect(serv, NULL, reply); + gf_service_connect_ack(serv, NULL, reply); if (!reply) mp3_setup_object(read); return GF_OK; } @@ -429,26 +429,26 @@ static GF_Err MP3_CloseService(GF_InputService *plug) if (read->stream) fclose(read->stream); read->stream = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; if (read->data) gf_free(read->data); read->data = NULL; - if (read->liveDataCopy){ - gf_free(read->liveDataCopy); - read->liveDataCopy = NULL; - read->liveDataCopySize = 0; + if (read->liveDataCopy) { + gf_free(read->liveDataCopy); + read->liveDataCopy = NULL; + read->liveDataCopySize = 0; } if (read->icy_name) - gf_free(read->icy_name); + gf_free(read->icy_name); read->icy_name = NULL; if (read->icy_genre) - gf_free(read->icy_genre); + gf_free(read->icy_genre); read->icy_genre = NULL; if (read->icy_track_name) - gf_free(read->icy_track_name); + gf_free(read->icy_track_name); read->icy_track_name = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -493,7 +493,7 @@ static GF_Err MP3_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -507,7 +507,7 @@ static GF_Err MP3_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) read->data = NULL; e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -564,7 +564,7 @@ static GF_Err MP3_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) rcfg.base.command_type = GF_NET_CHAN_DURATION; rcfg.duration.duration = read->duration; rcfg.duration.duration /= read->sample_rate; - gf_term_on_command(read->service, &rcfg, GF_OK); + gf_service_command(read->service, &rcfg, GF_OK); } } } diff --git a/modules/mpd_in/mpd_in.c b/modules/mpd_in/mpd_in.c index d4ecb24..55e7469 100644 --- a/modules/mpd_in/mpd_in.c +++ b/modules/mpd_in/mpd_in.c @@ -37,14 +37,14 @@ typedef enum MPDIN_BUFFER_SEGMENTS=2 } MpdInBuffer; -typedef struct __mpd_module +typedef struct __mpd_module { - /* GPAC Service object (i.e. how this module is seen by the terminal)*/ - GF_ClientService *service; + /* GPAC Service object (i.e. how this module is seen by the terminal)*/ + GF_ClientService *service; GF_InputService *plug; - - GF_DashClient *dash; + GF_DashClient *dash; + Bool closed; /*interface to mpd parser*/ GF_DASHFileIO dash_io; @@ -57,9 +57,14 @@ typedef struct __mpd_module Double previous_start_range; /*max width & height in all active representations*/ u32 width, height; + + + //we store here all callbacks to the parent services we need to intercept, and we will override our own ones + void (*fn_connect_ack) (GF_ClientService *service, LPNETCHANNEL ns, GF_Err response); + void (*fn_data_packet) (GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status); } GF_MPD_In; -typedef struct +typedef struct { GF_MPD_In *mpdin; GF_InputService *segment_ifce; @@ -69,6 +74,7 @@ typedef struct Bool has_new_data; u32 idx; GF_DownloadSession *sess; + Bool in_seek, is_timestamp_based; } GF_MPDGroup; const char * MPD_MPD_DESC = "MPEG-DASH Streaming"; @@ -78,35 +84,85 @@ const char * MPD_M3U8_EXT = "m3u8 m3u"; static u32 MPD_RegisterMimeTypes(const GF_InputService *plug) { - u32 i, c; - for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i]; i++) - gf_term_register_mime_type (plug, GF_DASH_MPD_MIME_TYPES[i], MPD_MPD_EXT, MPD_MPD_DESC); - c = i; - for (i = 0 ; GF_DASH_M3U8_MIME_TYPES[i]; i++) - gf_term_register_mime_type(plug, GF_DASH_M3U8_MIME_TYPES[i], MPD_M3U8_EXT, MPD_M3U8_DESC); - return c+i; + u32 i, c; + for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i]; i++) + gf_service_register_mime (plug, GF_DASH_MPD_MIME_TYPES[i], MPD_MPD_EXT, MPD_MPD_DESC); + c = i; + for (i = 0 ; GF_DASH_M3U8_MIME_TYPES[i]; i++) + gf_service_register_mime(plug, GF_DASH_M3U8_MIME_TYPES[i], MPD_M3U8_EXT, MPD_M3U8_DESC); + return c+i; } Bool MPD_CanHandleURL(GF_InputService *plug, const char *url) { - u32 i; + u32 i; char *sExt; - if (!plug || !url) - return 0; - sExt = strrchr(url, '.'); - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Can Handle URL request from terminal for %s\n", url)); - for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i]; i++) { - if (gf_term_check_extension(plug, GF_DASH_MPD_MIME_TYPES[i], MPD_MPD_EXT, MPD_MPD_DESC, sExt)) - return 1; - } - for (i = 0 ; GF_DASH_M3U8_MIME_TYPES[i]; i++) { - if (gf_term_check_extension(plug, GF_DASH_M3U8_MIME_TYPES[i], MPD_M3U8_EXT, MPD_M3U8_DESC, sExt)) - return 1; - } + if (!plug || !url) + return 0; + sExt = strrchr(url, '.'); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Can Handle URL request from terminal for %s\n", url)); + for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i]; i++) { + if (gf_service_check_mime_register(plug, GF_DASH_MPD_MIME_TYPES[i], MPD_MPD_EXT, MPD_MPD_DESC, sExt)) + return 1; + } + for (i = 0 ; GF_DASH_M3U8_MIME_TYPES[i]; i++) { + if (gf_service_check_mime_register(plug, GF_DASH_M3U8_MIME_TYPES[i], MPD_M3U8_EXT, MPD_M3U8_DESC, sExt)) + return 1; + } return gf_dash_check_mpd_root_type(url); } + +static void mpdin_connect_ack(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response) +{ + GF_MPD_In *mpdin = (GF_MPD_In*) service->ifce->priv; + //do not send connect error, we may have other running services - this has to be clean up + if (response==GF_OK) + mpdin->fn_connect_ack(mpdin->service, ns, response); +} + +void mpdin_data_packet(GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status) +{ + u32 i; + GF_InputService *ifce; + GF_MPD_In *mpdin = (GF_MPD_In*) service->ifce->priv; + GF_Channel *ch; + + if (!ns || !hdr) { + mpdin->fn_data_packet(service, ns, data, data_size, hdr, reception_status); + return; + } + + ch = (GF_Channel *) ns; + assert(ch->odm && ch->odm->OD); + ifce = (GF_InputService *) ch->odm->OD->service_ifce; + + for (i=0; idash); i++) { + GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); + if (!group) continue; + if (group->segment_ifce == ifce) { + //if sync is based on timestamps do not adjust the timestamps back + if (! group->is_timestamp_based) { + u32 idx, timescale; + u64 pto=0; + gf_dash_group_get_presentation_time_offset(mpdin->dash, i, &pto, ×cale); + if (timescale && (timescale != ch->esd->slConfig->timestampResolution)) { + pto *= ch->esd->slConfig->timestampResolution; + pto /= timescale; + } + if (hdr->decodingTimeStamp > pto) hdr->decodingTimeStamp -= pto; + else hdr->decodingTimeStamp = 0; + if (hdr->compositionTimeStamp> pto) hdr->compositionTimeStamp -= pto; + else hdr->compositionTimeStamp = 0; + } + + mpdin->fn_data_packet(service, ns, data, data_size, hdr, reception_status); + return; + } + } +} + static void MPD_NotifyData(GF_MPDGroup *group, Bool chunk_flush) { GF_NetworkCommand com; @@ -122,14 +178,14 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) u32 i; GF_Err e; GF_MPD_In *mpdin = (GF_MPD_In *) ifce->proxy_udta; - if (!param || !ifce || !ifce->proxy_udta) return GF_BAD_PARAM; + if (!param || !ifce || !ifce->proxy_udta) return GF_BAD_PARAM; /*gets byte range of init segment (for local validation)*/ if (param->command_type==GF_NET_SERVICE_QUERY_INIT_RANGE) { param->url_query.next_url = NULL; param->url_query.start_range = 0; param->url_query.end_range = 0; - + mpdin->in_seek = 0; for (i=0; idash); i++) { @@ -141,7 +197,7 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) param->url_query.current_download = 0; return GF_OK; } - } + } return GF_SERVICE_ERROR; } @@ -154,17 +210,12 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) const char *src_url; Bool discard_first_cache_entry = param->url_query.drop_first_segment; Bool check_current_download = param->url_query.current_download; - u32 timer = gf_sys_clock(); + u32 timer = gf_sys_clock(); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Service Query Next request from input service %s\n", ifce->module_name)); param->url_query.current_download = 0; param->url_query.discontinuity_type = 0; - if (mpdin->in_seek) { - mpdin->in_seek = 0; - param->url_query.discontinuity_type = 2; - discard_first_cache_entry = 0; - } for (i=0; idash); i++) { if (!gf_dash_is_group_selected(mpdin->dash, i)) continue; @@ -174,11 +225,18 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) break; } group=NULL; - } - + } + if (!group) { return GF_SERVICE_ERROR; } + + if (group->in_seek) { + group->in_seek = 0; + param->url_query.discontinuity_type = 2; + discard_first_cache_entry = 0; + } + //update group idx if (group->idx != group_idx) { group->idx = group_idx; @@ -193,24 +251,28 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) while (gf_dash_is_running(mpdin->dash) ) { group_done=0; nb_segments_cached = gf_dash_group_get_num_segments_ready(mpdin->dash, group_idx, &group_done); - if (nb_segments_cached>=1) + if (nb_segments_cached>=1) break; if (group_done) { if (!gf_dash_get_period_switch_status(mpdin->dash) && !gf_dash_in_last_period(mpdin->dash) ) { GF_NetworkCommand com; + param->url_query.in_end_of_period = 1; memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = GF_NET_BUFFER_QUERY; - while (gf_dash_get_period_switch_status(mpdin->dash) != 1) { - gf_term_on_command(mpdin->service, &com, GF_OK); + if (gf_dash_get_period_switch_status(mpdin->dash) != 1) { + gf_service_command(mpdin->service, &com, GF_OK); + //we only switch period once no more data is in our buffers if (!com.buffer.occupancy) { + param->url_query.in_end_of_period = 0; gf_dash_request_period_switch(mpdin->dash); - break; } - gf_sleep(30); } - } - return GF_EOS; + if (param->url_query.in_end_of_period) + return GF_BUFFER_TOO_SMALL; + } else { + return GF_EOS; + } } if (check_current_download && mpdin->use_low_latency) { @@ -226,48 +288,48 @@ static GF_Err MPD_ClientQuery(GF_InputService *ifce, GF_NetworkCommand *param) group->has_new_data = 0; return GF_OK; } - return GF_BUFFER_TOO_SMALL; + return GF_BUFFER_TOO_SMALL; } - return GF_BUFFER_TOO_SMALL; - } - + return GF_BUFFER_TOO_SMALL; + } + param->url_query.current_download = 0; nb_segments_cached = gf_dash_group_get_num_segments_ready(mpdin->dash, group_idx, &group_done); - if (nb_segments_cached < 1) { - GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] No more file in cache, EOS\n")); - return GF_EOS; - } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Had to wait for %u ms for the only cache file to be downloaded\n", (gf_sys_clock() - timer))); - } - - e = gf_dash_group_get_next_segment_location(mpdin->dash, group_idx, param->url_query.dependent_representation_index, ¶m->url_query.next_url, ¶m->url_query.start_range, ¶m->url_query.end_range, - NULL, ¶m->url_query.next_url_init_or_switch_segment, ¶m->url_query.switch_start_range , ¶m->url_query.switch_end_range, - &src_url, ¶m->url_query.has_next); + if (nb_segments_cached < 1) { + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] No more file in cache, EOS\n")); + return GF_EOS; + } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Had to wait for %u ms for the only cache file to be downloaded\n", (gf_sys_clock() - timer))); + } + + e = gf_dash_group_get_next_segment_location(mpdin->dash, group_idx, param->url_query.dependent_representation_index, ¶m->url_query.next_url, ¶m->url_query.start_range, ¶m->url_query.end_range, + NULL, ¶m->url_query.next_url_init_or_switch_segment, ¶m->url_query.switch_start_range , ¶m->url_query.switch_end_range, + &src_url, ¶m->url_query.has_next); if (e) return e; if (gf_dash_group_loop_detected(mpdin->dash, group_idx)) param->url_query.discontinuity_type = 2; - -#ifndef GPAC_DISABLE_LOG + +#ifndef GPAC_DISABLE_LOG { - u32 timer2 = gf_sys_clock() - timer ; - if (timer2 > 1000) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Waiting for download to end took a long time : %u ms\n", timer2)); - } + u32 timer2 = gf_sys_clock() - timer ; + if (timer2 > 1000) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Waiting for download to end took a long time : %u ms\n", timer2)); + } if (param->url_query.end_range) { - GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] Next Segment is %s bytes "LLD"-"LLD"\n", src_url, param->url_query.start_range, param->url_query.end_range)); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] Next Segment is %s bytes "LLD"-"LLD"\n", src_url, param->url_query.start_range, param->url_query.end_range)); } else { - GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] Next Segment is %s\n", src_url)); + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[MPD_IN] Next Segment is %s\n", src_url)); } GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Waited %d ms - Elements in cache: %u/%u\n\tCache file name %s\n\tsegment start time %g sec\n", timer2, gf_dash_group_get_num_segments_ready(mpdin->dash, group_idx, &group_done), gf_dash_group_get_max_segments_in_cache(mpdin->dash, group_idx), param->url_query.next_url, gf_dash_group_current_segment_start_time(mpdin->dash, group_idx) )); - } + } #endif - } + } - return GF_OK; + return GF_OK; } /*locates input service (demuxer) based on mime type or segment name*/ @@ -275,7 +337,7 @@ static GF_Err MPD_LoadMediaService(GF_MPD_In *mpdin, u32 group_index, const char { GF_InputService *segment_ifce; u32 i; - const char *sPlug; + const char *sPlug; if (mime) { /* Check MIME type to start the right InputService */ sPlug = gf_cfg_get_key(mpdin->service->term->user->config, "MimeTypes", mime); @@ -300,7 +362,7 @@ static GF_Err MPD_LoadMediaService(GF_MPD_In *mpdin, u32 group_index, const char for (i=0; i< gf_modules_get_count(mpdin->service->term->user->modules); i++) { GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(mpdin->service->term->user->modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; - + if (ifce->CanHandleURL && ifce->CanHandleURL(ifce, init_segment_name)) { GF_MPDGroup *group; GF_SAFEALLOC(group, GF_MPDGroup); @@ -316,7 +378,7 @@ static GF_Err MPD_LoadMediaService(GF_MPD_In *mpdin, u32 group_index, const char } } GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD_IN] Error locating plugin for segment - mime type %s - name %s\n", mime, init_segment_name)); - return GF_CODEC_NOT_FOUND; + return GF_CODEC_NOT_FOUND; } @@ -356,19 +418,19 @@ s32 MPD_GetGroupIndexForChannel(GF_MPD_In *mpdin, LPNETCHANNEL channel) GF_Err MPD_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const char *url, Bool upstream) { - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; GF_InputService *segment_ifce = MPD_GetInputServiceForChannel(mpdin, channel); - if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Channel Connection (%p) request from terminal for %s\n", channel, url)); + if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Channel Connection (%p) request from terminal for %s\n", channel, url)); return segment_ifce->ConnectChannel(segment_ifce, channel, url, upstream); } GF_Err MPD_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; GF_InputService *segment_ifce = MPD_GetInputServiceForChannel(mpdin, channel); - if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Disconnect channel (%p) request from terminal \n", channel)); + if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Disconnect channel (%p) request from terminal \n", channel)); return segment_ifce->DisconnectChannel(segment_ifce, channel); } @@ -393,12 +455,12 @@ static void mpdin_dash_segment_netio(void *cbk, GF_NETIO_Parameter *param) gf_dm_sess_get_stats(group->sess, NULL, &url, NULL, NULL, &bytes_per_sec, NULL); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] End of chunk received for %s at UTC "LLU" ms - estimated bandwidth %d kbps - chunk start at UTC "LLU"\n", url, gf_net_get_utc(), 8*bytes_per_sec/1000, gf_dm_sess_get_utc_start(group->sess))); - if (group->mpdin->use_low_latency) + if (group->mpdin->use_low_latency) MPD_NotifyData(group, 1); } else if (group->mpdin->use_low_latency==2) { MPD_NotifyData(group, 1); } - + if (group->mpdin->allow_http_abort) gf_dash_group_check_bandwidth(group->mpdin->dash, group->idx); } @@ -431,19 +493,19 @@ GF_DASHFileIOSession mpdin_dash_io_create(GF_DASHFileIO *dashio, Bool persistent } if (group) { group->netio_assigned = GF_TRUE; - group->sess = sess = gf_term_download_new(mpdin->service, url, flags, mpdin_dash_segment_netio, group); + group->sess = sess = gf_service_download_new(mpdin->service, url, flags, mpdin_dash_segment_netio, group); } else { - sess = gf_term_download_new(mpdin->service, url, flags, NULL, NULL); + sess = gf_service_download_new(mpdin->service, url, flags, NULL, NULL); } return (GF_DASHFileIOSession ) sess; } void mpdin_dash_io_del(GF_DASHFileIO *dashio, GF_DASHFileIOSession session) { - gf_term_download_del((GF_DownloadSession *)session); + gf_service_download_del((GF_DownloadSession *)session); } void mpdin_dash_io_abort(GF_DASHFileIO *dashio, GF_DASHFileIOSession session) { - gf_dm_sess_abort((GF_DownloadSession *)session); + gf_dm_sess_abort((GF_DownloadSession *)session); } GF_Err mpdin_dash_io_setup_from_url(GF_DASHFileIO *dashio, GF_DASHFileIOSession session, const char *url, s32 group_idx) { @@ -499,21 +561,21 @@ u32 mpdin_dash_io_get_bytes_per_sec(GF_DASHFileIO *dashio, GF_DASHFileIOSession { u32 bps=0; // GF_DownloadSession *sess = (GF_DownloadSession *)session; - gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, NULL, NULL, &bps, NULL); + gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, NULL, NULL, &bps, NULL); return bps; } u32 mpdin_dash_io_get_total_size(GF_DASHFileIO *dashio, GF_DASHFileIOSession session) { u32 size=0; // GF_DownloadSession *sess = (GF_DownloadSession *)session; - gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, &size, NULL, NULL, NULL); + gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, &size, NULL, NULL, NULL); return size; } u32 mpdin_dash_io_get_bytes_done(GF_DASHFileIO *dashio, GF_DASHFileIOSession session) { u32 size=0; // GF_DownloadSession *sess = (GF_DownloadSession *)session; - gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, NULL, &size, NULL, NULL); + gf_dm_sess_get_stats((GF_DownloadSession *)session, NULL, NULL, NULL, &size, NULL, NULL); return size; } @@ -526,7 +588,7 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ if (dash_evt==GF_DASH_EVENT_PERIOD_SETUP_ERROR) { if (!mpdin->connection_ack_sent) { - gf_term_on_connect(mpdin->service, NULL, error_code); + mpdin->fn_connect_ack(mpdin->service, NULL, error_code); mpdin->connection_ack_sent= GF_TRUE; } return GF_OK; @@ -544,7 +606,7 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ u32 mpd_buffer_ms = gf_dash_get_min_buffer_time(mpdin->dash); if (mpd_buffer_ms > buffer_ms) buffer_ms = mpd_buffer_ms; - } + } if (buffer_ms) { gf_dash_set_user_buffer(mpdin->dash, buffer_ms); @@ -559,7 +621,7 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ /*select input services if possible*/ for (i=0; idash); i++) { - const char *mime, *init_segment; + const char *mime, *init_segment; //let the player decide which group to play if (!gf_dash_is_group_selectable(mpdin->dash, i)) continue; @@ -586,11 +648,12 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ } else { group->service_connected = 1; } + if (mpdin->closed) return GF_OK; } } if (!mpdin->connection_ack_sent) { - gf_term_on_connect(mpdin->service, NULL, GF_OK); + mpdin->fn_connect_ack(mpdin->service, NULL, GF_OK); mpdin->connection_ack_sent=1; } return GF_OK; @@ -600,7 +663,7 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ if (dash_evt==GF_DASH_EVENT_DESTROY_PLAYBACK) { mpdin->service->subservice_disconnect = 1; - gf_term_on_disconnect(mpdin->service, NULL, GF_OK); + gf_service_disconnect_ack(mpdin->service, NULL, GF_OK); mpdin->service->subservice_disconnect = 2; for (i=0; idash); i++) { @@ -613,7 +676,7 @@ GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_ } gf_modules_close_interface((GF_BaseInterface *) group->segment_ifce); } - gf_free(group); + gf_free(group); gf_dash_set_group_udta(mpdin->dash, i, NULL); } mpdin->service->subservice_disconnect = 0; @@ -675,21 +738,21 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c max_cache_duration = 0; opt = gf_modules_get_option((GF_BaseInterface *)plug, "Network", "BufferLength"); - if (opt) max_cache_duration = atoi(opt); + if (opt) max_cache_duration = atoi(opt); - auto_switch_count = 0; - opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "AutoSwitchCount"); - if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "AutoSwitchCount", "0"); - if (opt) auto_switch_count = atoi(opt); + auto_switch_count = 0; + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "AutoSwitchCount"); + if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "AutoSwitchCount", "0"); + if (opt) auto_switch_count = atoi(opt); keep_files = 0; - opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "KeepFiles"); - if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "KeepFiles", "no"); - if (opt && !strcmp(opt, "yes")) keep_files = 1; + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "KeepFiles"); + if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "KeepFiles", "no"); + if (opt && !strcmp(opt, "yes")) keep_files = 1; disable_switching = 0; opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "DisableSwitching"); - if (opt && !strcmp(opt, "yes")) disable_switching = 1; + if (opt && !strcmp(opt, "yes")) disable_switching = 1; first_select_mode = 0; opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "StartRepresentation"); @@ -698,9 +761,9 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c opt = "minBandwidth"; } if (opt && !strcmp(opt, "maxBandwidth")) first_select_mode = GF_DASH_SELECT_BANDWIDTH_HIGHEST; - else if (opt && !strcmp(opt, "minQuality")) first_select_mode = GF_DASH_SELECT_QUALITY_LOWEST; - else if (opt && !strcmp(opt, "maxQuality")) first_select_mode = GF_DASH_SELECT_QUALITY_HIGHEST; - else first_select_mode = GF_DASH_SELECT_BANDWIDTH_LOWEST; + else if (opt && !strcmp(opt, "minQuality")) first_select_mode = GF_DASH_SELECT_QUALITY_LOWEST; + else if (opt && !strcmp(opt, "maxQuality")) first_select_mode = GF_DASH_SELECT_QUALITY_HIGHEST; + else first_select_mode = GF_DASH_SELECT_BANDWIDTH_LOWEST; opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "MemoryStorage"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "MemoryStorage", "yes"); @@ -708,7 +771,7 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "UseMaxResolution"); if (!opt) { -#if defined(_WIN32_WCE) || defined(GPAC_ANDROID) || defined(GPAC_IPHONE) +#if defined(_WIN32_WCE) || defined(GPAC_ANDROID) || defined(GPAC_IPHONE) opt = "yes"; #else opt = "no"; @@ -720,7 +783,7 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "ImmediateSwitching"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "ImmediateSwitching", "no"); mpdin->immediate_switch = (opt && !strcmp(opt, "yes")) ? 1 : 0; - + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "BufferingMode"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "BufferingMode", "minBuffer"); @@ -739,11 +802,11 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "AllowAbort"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "AllowAbort", "no"); mpdin->allow_http_abort = (opt && !strcmp(opt, "yes")) ? GF_TRUE : GF_FALSE; - + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "ShiftClock"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "ShiftClock", "0"); shift_utc_ms = opt ? atoi(opt) : 0; - + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "UseServerUTC"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "UseServerUTC", "yes"); use_server_utc = (opt && !strcmp(opt, "yes")) ? 1 : 0; @@ -755,12 +818,18 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "InitialTimeshift"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "InitialTimeshift", "0"); if (opt) init_timeshift = atoi(opt); - + + //override all service callbacks + mpdin->fn_connect_ack = serv->fn_connect_ack; + serv->fn_connect_ack = mpdin_connect_ack; + mpdin->fn_data_packet = serv->fn_data_packet; + serv->fn_data_packet = mpdin_data_packet; + mpdin->dash = gf_dash_new(&mpdin->dash_io, max_cache_duration, auto_switch_count, keep_files, disable_switching, first_select_mode, (mpdin->buffer_mode == MPDIN_BUFFER_SEGMENTS) ? 1 : 0, init_timeshift); if (!mpdin->dash) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD_IN] Error - cannot create DASH Client for %s\n", url)); - gf_term_on_connect(mpdin->service, NULL, GF_IO_ERR); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD_IN] Error - cannot create DASH Client for %s\n", url)); + mpdin->fn_connect_ack(mpdin->service, NULL, GF_IO_ERR); return GF_OK; } @@ -774,7 +843,7 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c GF_NetworkCommand com; memset(&com, 0, sizeof(GF_NetworkCommand)); com.base.command_type = GF_NET_SERVICE_MEDIA_CAP_QUERY; - gf_term_on_command(serv, &com, GF_OK); + gf_service_command(serv, &com, GF_OK); com.mcaps.width = 1920; com.mcaps.height = 1080; @@ -804,7 +873,7 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c e = gf_dash_open(mpdin->dash, url); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD_IN] Error - cannot initialize DASH Client for %s: %s\n", url, gf_error_to_string(e) )); - gf_term_on_connect(mpdin->service, NULL, e); + mpdin->fn_connect_ack(mpdin->service, NULL, e); return GF_OK; } return GF_OK; @@ -814,7 +883,7 @@ static GF_Descriptor *MPD_GetServiceDesc(GF_InputService *plug, u32 expect_type, { u32 i; GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Service Description request from terminal for %s\n", sub_url)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Service Description request from terminal for %s\n", sub_url)); for (i=0; idash); i++) { GF_Descriptor *desc; GF_MPDGroup *mudta; @@ -836,14 +905,16 @@ static GF_Descriptor *MPD_GetServiceDesc(GF_InputService *plug, u32 expect_type, GF_Err MPD_CloseService(GF_InputService *plug) { - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; - assert( mpdin ); - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Close Service (%p) request from terminal\n", mpdin->service)); - + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + assert( mpdin ); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Close Service (%p) request from terminal\n", mpdin->service)); + + mpdin->closed = 1; + if (mpdin->dash) gf_dash_close(mpdin->dash); - gf_term_on_disconnect(mpdin->service, NULL, GF_OK); + gf_service_disconnect_ack(mpdin->service, NULL, GF_OK); return GF_OK; } @@ -851,8 +922,8 @@ GF_Err MPD_CloseService(GF_InputService *plug) GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { s32 idx; - GF_Err e; - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + GF_Err e; + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; GF_InputService *segment_ifce = NULL; if (!plug || !plug->priv || !com ) return GF_SERVICE_ERROR; @@ -860,9 +931,9 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) segment_ifce = MPD_GetInputServiceForChannel(mpdin, com->base.on_channel); switch (com->command_type) { - case GF_NET_SERVICE_INFO: - { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Info command from terminal on Service (%p)\n", mpdin->service)); + case GF_NET_SERVICE_INFO: + { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Info command from terminal on Service (%p)\n", mpdin->service)); e = GF_OK; if (segment_ifce) { @@ -872,40 +943,40 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (e!= GF_OK || !com->info.name || 2 > strlen(com->info.name)) { gf_dash_get_info(mpdin->dash, &com->info.name, &com->info.comment); - } - return GF_OK; - } + } + return GF_OK; + } /*we could get it from MPD*/ - case GF_NET_SERVICE_HAS_AUDIO: + case GF_NET_SERVICE_HAS_AUDIO: case GF_NET_SERVICE_FLUSH_DATA: if (segment_ifce) { - /* defer to the real input service */ - return segment_ifce->ServiceCommand(segment_ifce, com); + /* defer to the real input service */ + return segment_ifce->ServiceCommand(segment_ifce, com); } - return GF_NOT_SUPPORTED; + return GF_NOT_SUPPORTED; case GF_NET_SERVICE_HAS_FORCED_VIDEO_SIZE: com->par.width = mpdin->use_max_res ? mpdin->width : 0; com->par.height = mpdin->use_max_res ? mpdin->height : 0; - return GF_OK; + return GF_OK; case GF_NET_SERVICE_QUALITY_SWITCH: gf_dash_switch_quality(mpdin->dash, com->switch_quality.up, mpdin->immediate_switch); - return GF_OK; + return GF_OK; default: break; } /*not supported*/ if (!com->base.on_channel) return GF_NOT_SUPPORTED; - + segment_ifce = MPD_GetInputServiceForChannel(mpdin, com->base.on_channel); if (!segment_ifce) return GF_NOT_SUPPORTED; switch (com->command_type) { - case GF_NET_CHAN_INTERACTIVE: - /* we are interactive (that's the whole point of MPD) */ - return GF_OK; + case GF_NET_CHAN_INTERACTIVE: + /* we are interactive (that's the whole point of MPD) */ + return GF_OK; case GF_NET_CHAN_BUFFER: /*get it from MPD minBufferTime - if not in low latency mode, indicate the value given in MPD (not possible to fetch segments earlier) - to be more precise we should get the min segment duration for this group*/ @@ -914,11 +985,11 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (max>com->buffer.max) com->buffer.max = max; - if (! gf_dash_is_dynamic_mpd(mpdin->dash)) { + if (! gf_dash_is_dynamic_mpd(mpdin->dash)) { com->buffer.min = 1; } } - return GF_OK; + return GF_OK; case GF_NET_CHAN_DURATION: /* Ignore the duration given by the input service and use the one given in the MPD @@ -927,34 +998,57 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) return GF_OK; case GF_NET_CHAN_PLAY: - /*don't seek if this command is the first PLAY request of objects declared by the subservice*/ - if (!com->play.initial_broadcast_play) { + /*don't seek if this command is the first PLAY request of objects declared by the subservice + not long ago*/ + if (!com->play.initial_broadcast_play || (com->play.start_range>2.0) ) { GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Play command from terminal on channel %p on Service (%p)\n", com->base.on_channel, mpdin->service)); + idx = MPD_GetGroupIndexForChannel(mpdin, com->play.on_channel); + if (!gf_dash_in_period_setup(mpdin->dash) && !com->play.dash_segment_switch && ! mpdin->in_seek) { //Bool skip_seek; - + mpdin->in_seek = 1; - + /*if start range request is the same as previous one, don't process it - this happens at period switch when new objects are declared*/ //skip_seek = (mpdin->previous_start_range==com->play.start_range) ? 1 : 0; mpdin->previous_start_range = com->play.start_range; gf_dash_seek(mpdin->dash, com->play.start_range); - } + } /*For MPEG-2 TS or formats not using Init Seg: since objects are declared and started once the first segment is playing, we will stay in playback_start_range!=-1 until next segment (because we won't have a query_next), which will prevent seeking until then ... we force a reset of playback_start_range to allow seeking asap*/ else if (mpdin->in_seek && (com->play.start_range==0)) { // mpdin->in_seek = 0; } - else if (gf_dash_in_period_setup(mpdin->dash) && (com->play.start_range==0)) { + else if (gf_dash_in_period_setup(mpdin->dash)) { + if (idx>=0) { + GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, idx); + group->is_timestamp_based = com->play.is_timestamp_based; + + if (com->play.is_timestamp_based) { + u32 timescale; + u64 pto; + Double offset; + gf_dash_group_get_presentation_time_offset(mpdin->dash, idx, &pto, ×cale); + offset = pto; + offset /= timescale; + com->play.start_range -= offset; + if (com->play.start_range < 0) com->play.start_range = 0; + } + } + gf_dash_seek(mpdin->dash, com->play.start_range); + com->play.start_range = gf_dash_get_playback_start_range(mpdin->dash); } - idx = MPD_GetGroupIndexForChannel(mpdin, com->play.on_channel); if (idx>=0) { + if (mpdin->in_seek) { + GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, idx); + group->in_seek = 1; + } gf_dash_group_select(mpdin->dash, idx, GF_TRUE); gf_dash_set_group_done(mpdin->dash, idx, 0); com->play.dash_segment_switch = gf_dash_group_segment_switch_forced(mpdin->dash, idx); @@ -966,7 +1060,7 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) idx = MPD_GetGroupIndexForChannel(mpdin, com->play.on_channel); if (idx>=0) gf_dash_group_select(mpdin->dash, idx, GF_TRUE); - com->play.start_range = gf_dash_group_get_start_range(mpdin->dash, idx); + com->play.start_range = gf_dash_group_get_start_range(mpdin->dash, idx); } return segment_ifce->ServiceCommand(segment_ifce, com); @@ -978,35 +1072,35 @@ GF_Err MPD_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) gf_dash_set_group_done(mpdin->dash, (u32) idx, 1); } } - return segment_ifce->ServiceCommand(segment_ifce, com); + return segment_ifce->ServiceCommand(segment_ifce, com); /*we could get it from MPD*/ case GF_NET_CHAN_GET_PIXEL_AR: - /* defer to the real input service */ - return segment_ifce->ServiceCommand(segment_ifce, com); + /* defer to the real input service */ + return segment_ifce->ServiceCommand(segment_ifce, com); case GF_NET_CHAN_SET_SPEED: - return segment_ifce->ServiceCommand(segment_ifce, com); + return segment_ifce->ServiceCommand(segment_ifce, com); - default: - return segment_ifce->ServiceCommand(segment_ifce, com); - } + default: + return segment_ifce->ServiceCommand(segment_ifce, com); + } } GF_Err MPD_ChannelGetSLP(GF_InputService *plug, LPNETCHANNEL channel, char **out_data_ptr, u32 *out_data_size, GF_SLHeader *out_sl_hdr, Bool *sl_compressed, GF_Err *out_reception_status, Bool *is_new_data) { - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; GF_InputService *segment_ifce = MPD_GetInputServiceForChannel(mpdin, channel); - if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; - return segment_ifce->ChannelGetSLP(segment_ifce, channel, out_data_ptr, out_data_size, out_sl_hdr, sl_compressed, out_reception_status, is_new_data); + if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; + return segment_ifce->ChannelGetSLP(segment_ifce, channel, out_data_ptr, out_data_size, out_sl_hdr, sl_compressed, out_reception_status, is_new_data); } GF_Err MPD_ChannelReleaseSLP(GF_InputService *plug, LPNETCHANNEL channel) { - GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; + GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; GF_InputService *segment_ifce = MPD_GetInputServiceForChannel(mpdin, channel); - if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; - return segment_ifce->ChannelReleaseSLP(segment_ifce, channel); + if (!plug || !plug->priv || !segment_ifce) return GF_SERVICE_ERROR; + return segment_ifce->ChannelReleaseSLP(segment_ifce, channel); } Bool MPD_CanHandleURLInService(GF_InputService *plug, const char *url) @@ -1022,9 +1116,9 @@ Bool MPD_CanHandleURLInService(GF_InputService *plug, const char *url) } else { GF_MPDGroup *mudta; u32 i; - for (i=0;idash); i++) { + for (i=0; idash); i++) { if (!gf_dash_is_group_selected(mpdin->dash, i)) continue; - + mudta = gf_dash_get_group_udta(mpdin->dash, i); if (mudta && mudta->segment_ifce && mudta->segment_ifce->CanHandleURLInService) { return mudta->segment_ifce->CanHandleURLInService(plug, url); @@ -1037,37 +1131,37 @@ Bool MPD_CanHandleURLInService(GF_InputService *plug, const char *url) GPAC_MODULE_EXPORT const u32 *QueryInterfaces() { - static u32 si [] = { - GF_NET_CLIENT_INTERFACE, - 0 - }; - return si; + static u32 si [] = { + GF_NET_CLIENT_INTERFACE, + 0 + }; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - GF_MPD_In *mpdin; - GF_InputService *plug; - if (InterfaceType != GF_NET_CLIENT_INTERFACE) return NULL; - - GF_SAFEALLOC(plug, GF_InputService); - GF_REGISTER_MODULE_INTERFACE(plug, GF_NET_CLIENT_INTERFACE, "GPAC MPD Loader", "gpac distribution") - plug->RegisterMimeTypes = MPD_RegisterMimeTypes; - plug->CanHandleURL = MPD_CanHandleURL; - plug->ConnectService = MPD_ConnectService; - plug->CloseService = MPD_CloseService; - plug->GetServiceDescriptor = MPD_GetServiceDesc; - plug->ConnectChannel = MPD_ConnectChannel; - plug->DisconnectChannel = MPD_DisconnectChannel; - plug->ServiceCommand = MPD_ServiceCommand; - plug->CanHandleURLInService = MPD_CanHandleURLInService; - plug->ChannelGetSLP = MPD_ChannelGetSLP; - plug->ChannelReleaseSLP = MPD_ChannelReleaseSLP; - GF_SAFEALLOC(mpdin, GF_MPD_In); - plug->priv = mpdin; + GF_MPD_In *mpdin; + GF_InputService *plug; + if (InterfaceType != GF_NET_CLIENT_INTERFACE) return NULL; + + GF_SAFEALLOC(plug, GF_InputService); + GF_REGISTER_MODULE_INTERFACE(plug, GF_NET_CLIENT_INTERFACE, "GPAC MPD Loader", "gpac distribution") + plug->RegisterMimeTypes = MPD_RegisterMimeTypes; + plug->CanHandleURL = MPD_CanHandleURL; + plug->ConnectService = MPD_ConnectService; + plug->CloseService = MPD_CloseService; + plug->GetServiceDescriptor = MPD_GetServiceDesc; + plug->ConnectChannel = MPD_ConnectChannel; + plug->DisconnectChannel = MPD_DisconnectChannel; + plug->ServiceCommand = MPD_ServiceCommand; + plug->CanHandleURLInService = MPD_CanHandleURLInService; + plug->ChannelGetSLP = MPD_ChannelGetSLP; + plug->ChannelReleaseSLP = MPD_ChannelReleaseSLP; + GF_SAFEALLOC(mpdin, GF_MPD_In); + plug->priv = mpdin; mpdin->plug = plug; - return (GF_BaseInterface *)plug; + return (GF_BaseInterface *)plug; } GPAC_MODULE_EXPORT diff --git a/modules/mpegts_in/mpegts_in.c b/modules/mpegts_in/mpegts_in.c index 2c9f98d..6966932 100644 --- a/modules/mpegts_in/mpegts_in.c +++ b/modules/mpegts_in/mpegts_in.c @@ -44,7 +44,7 @@ typedef struct { u32 pid; } M2TSIn_Prog; -typedef struct +typedef struct { GF_M2TS_Demuxer *ts; @@ -78,7 +78,10 @@ typedef struct Bool in_data_flush; Bool hybrid_on; -}M2TSIn; + + Bool flush_sdt; + +} M2TSIn; static void M2TS_GetNetworkType(GF_InputService *plug,M2TSIn *reader); @@ -86,23 +89,23 @@ static void M2TS_GetNetworkType(GF_InputService *plug,M2TSIn *reader); static Bool M2TS_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; - if (!plug || !url) - return 0; + if (!plug || !url) + return 0; if (!strnicmp(url, "udp://", 6) - || !strnicmp(url, "mpegts-udp://", 13) - || !strnicmp(url, "mpegts-tcp://", 13) + || !strnicmp(url, "mpegts-udp://", 13) + || !strnicmp(url, "mpegts-tcp://", 13) #ifdef GPAC_HAS_LINUX_DVB - || !strnicmp(url, "dvb://", 6) + || !strnicmp(url, "dvb://", 6) #endif - ) { - return 1; + ) { + return 1; } sExt = strrchr(url, '.'); { int i=0; for (i = 0 ; NULL != MIMES[i]; i++) - if (gf_term_check_extension(plug, MIMES[i], "ts m2t dmb", "MPEG-2 TS", sExt)) + if (gf_service_check_mime_register(plug, MIMES[i], "ts m2t dmb trp", "MPEG-2 TS", sExt)) return 1; } return 0; @@ -148,21 +151,21 @@ static Bool M2TS_CanHandleURLInService(GF_InputService *plug, const char *url) } } else #endif - if (!strnicmp(url, "udp://", 6) - || !strnicmp(url, "mpegts-udp://", 13) - || !strnicmp(url, "mpegts-tcp://", 13)) - { - /* TODO: check IP address ...*/ - ret = 0; - } else { - char *frag = strchr(url, '#'); - if (frag) frag[0] = 0; - if (!strlen(url) || !strcmp(url, m2ts->ts->filename)) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[DVBIn] Reusing the same input file for %s\n", url)); - ret = 1; + if (!strnicmp(url, "udp://", 6) + || !strnicmp(url, "mpegts-udp://", 13) + || !strnicmp(url, "mpegts-tcp://", 13)) + { + /* TODO: check IP address ...*/ + ret = 0; + } else { + char *frag = strchr(url, '#'); + if (frag) frag[0] = 0; + if (!strlen(url) || !strcmp(url, m2ts->ts->filename)) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[DVBIn] Reusing the same input file for %s\n", url)); + ret = 1; + } + if (frag) frag[0] = '#'; } - if (frag) frag[0] = '#'; - } return ret; } @@ -235,6 +238,10 @@ static GF_ESD *MP2TS_GetESD(M2TSIn *m2ts, GF_M2TS_PES *stream, char *dsi, u32 ds esd->decoderConfig->streamType = GF_STREAM_AUDIO; esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_AC3; break; + case GF_M2TS_AUDIO_EC3: + esd->decoderConfig->streamType = GF_STREAM_AUDIO; + esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_EAC3; + break; case GF_M2TS_SYSTEMS_MPEG4_SECTIONS: default: gf_odf_desc_del((GF_Descriptor *)esd); @@ -311,7 +318,7 @@ static void MP2TS_DeclareStream(M2TSIn *m2ts, GF_M2TS_PES *stream, char *dsi, u3 GF_ObjectDescriptor *od = MP2TS_GetOD(m2ts, stream, dsi, dsi_size, NULL); if (!od) return; /*declare but don't regenerate scene*/ - gf_term_add_media(m2ts->service, (GF_Descriptor*)od, 1); + gf_service_declare_media(m2ts->service, (GF_Descriptor*)od, 1); } static void MP2TS_SetupProgram(M2TSIn *m2ts, GF_M2TS_Program *prog, Bool regenerate_scene, Bool no_declare) @@ -332,9 +339,9 @@ static void MP2TS_SetupProgram(M2TSIn *m2ts, GF_M2TS_Program *prog, Bool regener #endif /*TS is a file, start regulation regardless of how the TS is access (with or without fragment URI)*/ - if (m2ts->ts->file || m2ts->ts->dnload) + if (m2ts->ts->file || m2ts->ts->dnload) m2ts->ts->file_regulate = 1; - + for (i=0; istreams, i); if (es->pid==prog->pmt_pid) continue; @@ -347,23 +354,23 @@ static void MP2TS_SetupProgram(M2TSIn *m2ts, GF_M2TS_Program *prog, Bool regener for (i=0; istreams, i); if (es->pid==prog->pmt_pid) continue; - if ((es->flags & GF_M2TS_ES_IS_PES) && ((GF_M2TS_PES *)es)->depends_on_pid ) + if ((es->flags & GF_M2TS_ES_IS_PES) && ((GF_M2TS_PES *)es)->depends_on_pid ) continue; /*move to skip mode for all ES until asked for playback*/ if (!es->user) gf_m2ts_set_pes_framing((GF_M2TS_PES *)es, GF_M2TS_PES_FRAMING_SKIP); - if (!prog->pmt_iod && !no_declare) { + if (!prog->pmt_iod && !no_declare) { MP2TS_DeclareStream(m2ts, (GF_M2TS_PES *)es, NULL, 0); - } + } /*if IOD, streams not declared through OD framework are refered to by pid:// scheme, and will be declared upon request by the terminal through GetServiceDesc*/ } - + /*force scene regeneration*/ if (!prog->pmt_iod && regenerate_scene) - gf_term_add_media(m2ts->service, NULL, 0); + gf_service_declare_media(m2ts->service, NULL, 0); } static void MP2TS_SendPacket(M2TSIn *m2ts, GF_M2TS_PES_PCK *pck) @@ -392,7 +399,7 @@ static void MP2TS_SendPacket(M2TSIn *m2ts, GF_M2TS_PES_PCK *pck) } slh.randomAccessPointFlag = (pck->flags & GF_M2TS_PES_PCK_RAP) ? 1 : 0; } - gf_term_on_sl_packet(m2ts->service, pck->stream->user, pck->data, pck->data_len, &slh, GF_OK); + gf_service_send_packet(m2ts->service, pck->stream->user, pck->data, pck->data_len, &slh, GF_OK); } static GFINLINE void MP2TS_SendSLPacket(M2TSIn *m2ts, GF_M2TS_SL_PCK *pck) @@ -406,7 +413,7 @@ static GFINLINE void MP2TS_SendSLPacket(M2TSIn *m2ts, GF_M2TS_SL_PCK *pck) SLHeader.m2ts_version_number_plus_one = pck->version_number + 1; slh = &SLHeader; } - gf_term_on_sl_packet(m2ts->service, pck->stream->user, pck->data+SLHdrLen, pck->data_len-SLHdrLen, slh, GF_OK); + gf_service_send_packet(m2ts->service, pck->stream->user, pck->data+SLHdrLen, pck->data_len-SLHdrLen, slh, GF_OK); } static GF_ObjectDescriptor *M2TS_GenerateEPG_OD(M2TSIn *m2ts) @@ -442,6 +449,18 @@ static void M2TS_FlushRequested(M2TSIn *m2ts) gf_mx_p(m2ts->mx); + count = gf_list_count(m2ts->ts->programs); + for (j=0; jts->programs, j); + //PMT not yet received, do not allow playback regulation + if (!ts_prog->pcr_pid) { + m2ts->ts->file_regulate = 0; + gf_mx_v(m2ts->mx); + return; + } + } + + found = 0; count = gf_list_count(m2ts->ts->requested_pids); for (i=0; its->requested_progs); for (i = 0; i < req_prog_count; i++) { M2TSIn_Prog *req_prog = gf_list_get(m2ts->ts->requested_progs, i); + prog_id = atoi(req_prog->fragment); count = gf_list_count(m2ts->ts->SDTs); for (j=0; jnumber) { req_prog->id = prog_id; break; - } + } } } if (req_prog->id) { @@ -502,93 +522,89 @@ static void M2TS_FlushRequested(M2TSIn *m2ts) if (!m2ts->has_eit) { GF_ObjectDescriptor *od = M2TS_GenerateEPG_OD(m2ts); /*declare but don't regenerate scene*/ - gf_term_add_media(m2ts->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(m2ts->service, (GF_Descriptor*)od, 0); m2ts->has_eit = 1; } } else { /*force scene regeneration only when EPG is not requested*/ if (found) - gf_term_add_media(m2ts->service, NULL, 0); + gf_service_declare_media(m2ts->service, NULL, 0); } gf_mx_v(m2ts->mx); } +static void forward_m2ts_event(M2TSIn *m2ts, u32 evt_type, void *param) +{ + GF_NetworkCommand com; + memset(&com, 0, sizeof(com)); + + com.command_type = GF_NET_SERVICE_EVENT; + com.send_event.evt.type = GF_EVENT_FROM_SERVICE; + com.send_event.evt.from_service.forward_type = GF_EVT_MPEG2; + com.send_event.evt.from_service.service_event_type = evt_type; + com.send_event.evt.from_service.param = param; + gf_service_command(m2ts->service, &com, GF_OK); +} + static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) { - GF_Event evt; M2TSIn *m2ts = (M2TSIn *) ts->user; switch (evt_type) { case GF_M2TS_EVT_PAT_UPDATE: -/* example code showing how to forward an event from MPEG-2 TS input service to GPAC user*/ + /* example code showing how to forward an event from MPEG-2 TS input service to GPAC user*/ #if 0 - { - GF_Event evt; - evt.type = GF_EVENT_FORWARDED; - evt.forwarded_event.forward_type = GF_EVT_FORWARDED_MPEG2; - evt.forwarded_event.forward_type = GF_EVT_FORWARDED_MPEG2; - evt.forwarded_event.service_event_type = evt_type; - evt.forwarded_event.param = param; - gf_term_on_service_event(m2ts->service, &evt); - } + send_m2ts_event(m2ts, evt_type, param); #endif - break; + break; case GF_M2TS_EVT_AIT_FOUND: - evt.type = GF_EVENT_FORWARDED; - evt.forwarded_event.forward_type = GF_EVT_FORWARDED_MPEG2; - evt.forwarded_event.service_event_type = evt_type; - evt.forwarded_event.param = param; - gf_term_on_service_event(m2ts->service, &evt); + forward_m2ts_event(m2ts, evt_type, param); break; case GF_M2TS_EVT_PAT_FOUND: - /* In case the TS has one program, wait for the PMT to send connect, in case of IOD in PMT */ + /* In case the TS has one program, wait for the PMT to send connect, in case of IOD in PMT */ if (gf_list_count(m2ts->ts->programs) != 1) { - gf_term_on_connect(m2ts->service, NULL, GF_OK); + gf_service_connect_ack(m2ts->service, NULL, GF_OK); m2ts->is_connected = 1; } /* Send the TS to the a user if needed. Useful to check the number of received programs*/ - evt.type = GF_EVENT_FORWARDED; - evt.forwarded_event.forward_type = GF_M2TS_EVT_PAT_FOUND; - evt.forwarded_event.service_event_type = evt_type; - evt.forwarded_event.param = ts; - gf_term_on_service_event(m2ts->service, &evt); + forward_m2ts_event(m2ts, evt_type, param); break; case GF_M2TS_EVT_DSMCC_FOUND: - evt.type = GF_EVENT_FORWARDED; - evt.forwarded_event.forward_type = GF_EVT_FORWARDED_MPEG2; - evt.forwarded_event.service_event_type = evt_type; - evt.forwarded_event.param = param; - gf_term_on_service_event(m2ts->service, &evt); + forward_m2ts_event(m2ts, evt_type, param); break; case GF_M2TS_EVT_PMT_FOUND: if (gf_list_count(m2ts->ts->programs) == 1) { - gf_term_on_connect(m2ts->service, NULL, GF_OK); + gf_service_connect_ack(m2ts->service, NULL, GF_OK); m2ts->is_connected = 1; - } + } /*do not declare if single program was requested for playback*/ MP2TS_SetupProgram(m2ts, param, m2ts->request_all_pids, m2ts->request_all_pids ? 0 : 1); - M2TS_FlushRequested(m2ts); + M2TS_FlushRequested(m2ts); /* Send the TS to the a user if needed. Useful to check the number of received programs*/ - evt.type = GF_EVENT_FORWARDED; - evt.forwarded_event.forward_type = GF_M2TS_EVT_PMT_FOUND; - evt.forwarded_event.service_event_type = evt_type; - evt.forwarded_event.param = param; - gf_term_on_service_event(m2ts->service, &evt); + forward_m2ts_event(m2ts, evt_type, param); break; case GF_M2TS_EVT_PMT_REPEAT: // case GF_M2TS_EVT_PMT_UPDATE: M2TS_FlushRequested(m2ts); break; - case GF_M2TS_EVT_SDT_REPEAT: - case GF_M2TS_EVT_SDT_UPDATE: case GF_M2TS_EVT_SDT_FOUND: + case GF_M2TS_EVT_SDT_UPDATE: + m2ts->flush_sdt = 1; + case GF_M2TS_EVT_SDT_REPEAT: M2TS_FlushRequested(m2ts); + if (m2ts->flush_sdt) { + GF_NetworkCommand com; + m2ts->flush_sdt = 0; + memset(&com, 0, sizeof(GF_NetworkCommand)); + com.base.command_type = GF_NET_SERVICE_INFO; + gf_service_command(m2ts->service, &com, GF_OK); + } break; case GF_M2TS_EVT_DVB_GENERAL: if (m2ts->eit_channel) { GF_M2TS_SL_PCK *pck = (GF_M2TS_SL_PCK *)param; - gf_term_on_sl_packet(m2ts->service, m2ts->eit_channel, pck->data, pck->data_len, NULL, GF_OK); + gf_service_send_packet(m2ts->service, m2ts->eit_channel, pck->data, pck->data_len, NULL, GF_OK); } break; case GF_M2TS_EVT_PES_PCK: @@ -598,7 +614,7 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) MP2TS_SendSLPacket(m2ts, param); break; case GF_M2TS_EVT_EOS: - gf_term_on_sl_packet(m2ts->service, ((GF_M2TS_PES *)param)->user, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(m2ts->service, ((GF_M2TS_PES *)param)->user, NULL, 0, NULL, GF_EOS); break; case GF_M2TS_EVT_AAC_CFG: { @@ -606,14 +622,14 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) if (!pck->stream->first_dts) { gf_m2ts_set_pes_framing(pck->stream, GF_M2TS_PES_FRAMING_SKIP_NO_RESET); MP2TS_DeclareStream(m2ts, pck->stream, pck->data, pck->data_len); - if (ts->file || ts->dnload) + if (ts->file || ts->dnload) ts->file_regulate = 1; pck->stream->first_dts=1; /*force scene regeneration*/ - gf_term_add_media(m2ts->service, NULL, 0); + gf_service_declare_media(m2ts->service, NULL, 0); } } - break; + break; case GF_M2TS_EVT_PES_PCR: /*send pcr*/ if (((GF_M2TS_PES_PCK *) param)->stream && ((GF_M2TS_PES_PCK *) param)->stream->user) { @@ -622,7 +638,7 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) slh.OCRflag = 1; slh.m2ts_pcr = ( ((GF_M2TS_PES_PCK *) param)->flags & GF_M2TS_PES_PCK_DISCONTINUITY) ? 2 : 1; slh.objectClockReference = ((GF_M2TS_PES_PCK *) param)->PTS; - gf_term_on_sl_packet(m2ts->service, ((GF_M2TS_PES_PCK *) param)->stream->user, NULL, 0, &slh, GF_OK); + gf_service_send_packet(m2ts->service, ((GF_M2TS_PES_PCK *) param)->stream->user, NULL, 0, &slh, GF_OK); } ((GF_M2TS_PES_PCK *) param)->stream->program->first_dts = 1; @@ -634,7 +650,7 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) } #endif GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[M2TS In] PCR discontinuity - switching from old STB "LLD" to new one "LLD"\n", ts->pcr_last, ((GF_M2TS_PES_PCK *) param)->PTS)); - /*FIXME - we need to find a way to treat PCR discontinuities correctly while ignoring broken PCR discontinuities + /*FIXME - we need to find a way to treat PCR discontinuities correctly while ignoring broken PCR discontinuities seen in many HLS solutions*/ return; } @@ -642,7 +658,7 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) if (ts->file_regulate) { u64 pcr = ((GF_M2TS_PES_PCK *) param)->PTS; u32 stb = gf_sys_clock(); - + if (m2ts->regulation_pcr_pid==0) { /*we pick the first PCR PID for file regulation - we don't need to make sure this is the PCR of a program being played as we only check buffer levels, not DTS/PTS of the streams in the regulation step*/ @@ -681,7 +697,7 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) com.command_type = GF_NET_BUFFER_QUERY; com.base.on_channel = NULL; while (ts->run_state) { - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); if (!com.buffer.occupancy || (com.buffer.occupancy < com.buffer.max)) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TS In] Demux not going to sleep: buffer occupancy %d ms\n", com.buffer.occupancy)); break; @@ -736,11 +752,11 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) GF_M2TS_ES * stream = gf_list_get(prog->streams, j); if (stream->user) { com.base.on_channel = stream->user; - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); } } - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TS In] Mapping TDT Time %04d/%02d/%02d %02d:%02d:%02d and PCR time "LLD" on program %d\n", - tdt->year, tdt->month, tdt->day, tdt->hour, tdt->minute, tdt->second, com.map_time.timestamp, prog->number)); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TS In] Mapping TDT Time %04d/%02d/%02d %02d:%02d:%02d and PCR time "LLD" on program %d\n", + tdt->year, tdt->month, tdt->day, tdt->hour, tdt->minute, tdt->second, com.map_time.timestamp, prog->number)); } } break; @@ -764,12 +780,12 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) GF_M2TS_ES * stream = gf_list_get(prog->streams, j); if (stream->user) { com.base.on_channel = stream->user; - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); } } } } - break; + break; case GF_M2TS_EVT_TEMI_LOCATION: { @@ -782,9 +798,9 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) com.addon_info.activation_countdown = ((GF_M2TS_TemiLocationDescriptor*)param)->activation_countdown; com.addon_info.reload_external = ((GF_M2TS_TemiLocationDescriptor*)param)->reload_external; com.addon_info.timeline_id = ((GF_M2TS_TemiLocationDescriptor*)param)->timeline_id; - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); } - break; + break; case GF_M2TS_EVT_TEMI_TIMECODE: { GF_NetworkCommand com; @@ -796,9 +812,9 @@ static void M2TS_OnEvent(GF_M2TS_Demuxer *ts, u32 evt_type, void *param) com.addon_time.media_timestamp = ((GF_M2TS_TemiTimecodeDescriptor*)param)->media_timestamp; com.addon_time.force_reload = ((GF_M2TS_TemiTimecodeDescriptor*)param)->force_reload; com.addon_time.is_paused = ((GF_M2TS_TemiTimecodeDescriptor*)param)->is_paused; - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); } - break; + break; } } @@ -808,17 +824,17 @@ void m2ts_net_io(void *cbk, GF_NETIO_Parameter *param) M2TSIn *m2ts = (M2TSIn *) cbk; assert( m2ts ); /*handle service message*/ - gf_term_download_update_stats(m2ts->ts->dnload); + gf_service_download_update_stats(m2ts->ts->dnload); if (param->msg_type==GF_NETIO_DATA_TRANSFERED) { e = GF_EOS; } else if (param->msg_type==GF_NETIO_DATA_EXCHANGE) { e = GF_OK; assert( m2ts->ts); - if (param->size > 0){ + if (param->size > 0) { /*process chunk*/ assert(param->data); - if (m2ts->network_buffer_size < param->size){ + if (m2ts->network_buffer_size < param->size) { m2ts->network_buffer = gf_realloc(m2ts->network_buffer, sizeof(char) * param->size); m2ts->network_buffer_size = param->size; } @@ -838,8 +854,8 @@ void m2ts_net_io(void *cbk, GF_NETIO_Parameter *param) } #if 1 //see commit 3642: crashes when reload quickly with http if (!m2ts->ts->run_state) { - if (m2ts->ts->dnload) - gf_term_download_del( m2ts->ts->dnload ); + if (m2ts->ts->dnload) + gf_service_download_del( m2ts->ts->dnload ); m2ts->ts->dnload = NULL; } #endif @@ -848,20 +864,20 @@ void m2ts_net_io(void *cbk, GF_NETIO_Parameter *param) e = param->error; } - switch (e){ - case GF_EOS: - if (!m2ts->is_connected) { - gf_term_on_connect(m2ts->service, NULL, GF_OK); - } - return; - case GF_OK: - return; - default: - if (!m2ts->ts_setup) { - m2ts->ts_setup = 1; - } - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER,("[MPEGTSIn] : Error while getting data : %s\n", gf_error_to_string(e))); - gf_term_on_connect(m2ts->service, NULL, e); + switch (e) { + case GF_EOS: + if (!m2ts->is_connected) { + gf_service_connect_ack(m2ts->service, NULL, GF_OK); + } + return; + case GF_OK: + return; + default: + if (!m2ts->ts_setup) { + m2ts->ts_setup = 1; + } + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER,("[MPEGTSIn] : Error while getting data : %s\n", gf_error_to_string(e))); + gf_service_connect_ack(m2ts->service, NULL, e); } } @@ -894,9 +910,9 @@ static GF_Err M2TS_QueryNextFile(void *udta, u32 query_type, const char **out_ur query_ret = m2ts->owner->query_proxy(m2ts->owner, ¶m); - if ((query_ret==GF_BUFFER_TOO_SMALL) && query_type && !param.url_query.next_url){ + if ((query_ret==GF_BUFFER_TOO_SMALL) && query_type && !param.url_query.next_url) { GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[M2TS In] Cannot query next file: not yet downloaded\n")); - } else if ((query_ret==GF_OK) && query_type && !param.url_query.next_url){ + } else if ((query_ret==GF_OK) && query_type && !param.url_query.next_url) { GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[M2TS In] Cannot query next file: no file provided but no error raised\n")); } else if (query_ret) { GF_LOG((query_ret<0) ? GF_LOG_ERROR : GF_LOG_INFO, GF_LOG_DASH, ("[M2TS In] Cannot query next file: error: %s\n", gf_error_to_string(query_ret))); @@ -945,7 +961,7 @@ void m2ts_flush_data(M2TSIn *m2ts, u32 flush_type) const char *url; if (m2ts->in_data_flush) { - if (flush_type==GF_M2TS_PUSH_SEGMENT) + if (flush_type==GF_M2TS_PUSH_SEGMENT) m2ts->has_pending_segments++; return; } @@ -958,12 +974,12 @@ void m2ts_flush_data(M2TSIn *m2ts, u32 flush_type) /*query buffer level on each channel, don't sleep if too low*/ memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = GF_NET_BUFFER_QUERY; - gf_term_on_command(m2ts->service, &com, GF_OK); + gf_service_command(m2ts->service, &com, GF_OK); if (com.buffer.occupancy && (com.buffer.occupancy >= com.buffer.max)) { //count completed segment that were not dispatched if (flush_type==GF_M2TS_PUSH_SEGMENT) m2ts->has_pending_segments++; - + m2ts->in_data_flush = 0; gf_mx_v(m2ts->mx); return; @@ -985,7 +1001,7 @@ void m2ts_flush_data(M2TSIn *m2ts, u32 flush_type) } gf_m2ts_demux_file(m2ts->ts, url, start_byterange, end_byterange, refresh_type, 0); - //done, drop segment + //done, drop segment if (!m2ts->in_segment_download) { e = M2TS_QueryNextFile(m2ts, 3, &url, &start_byterange, &end_byterange, &refresh_type); @@ -1003,7 +1019,7 @@ void m2ts_flush_data(M2TSIn *m2ts, u32 flush_type) static GF_Err M2TS_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url) { - GF_Err e; + GF_Err e; const char *opt; M2TSIn *m2ts = plug->priv; @@ -1014,7 +1030,7 @@ static GF_Err M2TS_ConnectService(GF_InputService *plug, GF_ClientService *serv, opt = gf_modules_get_option((GF_BaseInterface *)m2ts->owner, "HybRadio", "Activated"); if (opt && !strcmp(opt, "true")) { m2ts->hybrid_on = 1; - } + } m2ts->ts->record_to = gf_modules_get_option((GF_BaseInterface *)m2ts->owner, "M2TS", "RecordTo"); @@ -1026,15 +1042,15 @@ static GF_Err M2TS_ConnectService(GF_InputService *plug, GF_ClientService *serv, } if (url && !strnicmp(url, "http://", 7)) { - m2ts->ts->dnload = gf_term_download_new(m2ts->service, url, GF_NETIO_SESSION_NOT_THREADED | GF_NETIO_SESSION_NOT_CACHED, m2ts_net_io, m2ts); - if (!m2ts->ts->dnload){ - gf_term_on_connect(m2ts->service, NULL, GF_NOT_SUPPORTED); + m2ts->ts->dnload = gf_service_download_new(m2ts->service, url, GF_NETIO_SESSION_NOT_THREADED | GF_NETIO_SESSION_NOT_CACHED, m2ts_net_io, m2ts); + if (!m2ts->ts->dnload) { + gf_service_connect_ack(m2ts->service, NULL, GF_NOT_SUPPORTED); return GF_OK; } else { e = gf_m2ts_demuxer_play(m2ts->ts); } } else { - //dash & HLS - run in non-threaded mode + //dash & HLS - run in non-threaded mode if (plug->query_proxy) { //get byte range if any (local playback) if (url) { @@ -1056,7 +1072,7 @@ static GF_Err M2TS_ConnectService(GF_InputService *plug, GF_ClientService *serv, } if (e) { - gf_term_on_connect(m2ts->service, NULL, e); + gf_service_connect_ack(m2ts->service, NULL, e); } return e; } @@ -1067,14 +1083,14 @@ static GF_Err M2TS_CloseService(GF_InputService *plug) GF_M2TS_Demuxer* ts = m2ts->ts; if (!plug->query_proxy) - gf_m2ts_demuxer_close(ts); - + gf_m2ts_demuxer_close(ts); + m2ts->ts->run_state = 0; - if (ts->dnload) gf_term_download_del(ts->dnload); + if (ts->dnload) gf_service_download_del(ts->dnload); ts->dnload = NULL; - gf_term_on_disconnect(m2ts->service, NULL, GF_OK); + gf_service_disconnect_ack(m2ts->service, NULL, GF_OK); return GF_OK; } @@ -1143,7 +1159,7 @@ static GF_Descriptor *M2TS_GetServiceDesc(GF_InputService *plug, u32 expect_type } } /*if we expect scene, return NULL and repost a connection ack when we get the PMT*/ - if (expect_type==GF_MEDIA_OBJECT_SCENE) + if (expect_type==GF_MEDIA_OBJECT_SCENE) return NULL; if (m2ts->epg_requested) { GF_ObjectDescriptor *od = M2TS_GenerateEPG_OD(m2ts); @@ -1187,17 +1203,17 @@ static GF_Err M2TS_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, c GF_M2TS_PES *pes = (GF_M2TS_PES *)m2ts->ts->ess[i]; if (!pes || (pes->pid==pes->program->pmt_pid)) continue; if ((pes->mpeg4_es_id == ES_ID) - /*for pid:// url*/ - || (!pes->mpeg4_es_id && (pes->pid == ES_ID)) - ) { + /*for pid:// url*/ + || (!pes->mpeg4_es_id && (pes->pid == ES_ID)) + ) { if (pes->user) { e = GF_SERVICE_ERROR; - gf_term_on_connect(m2ts->service, channel, e); + gf_service_connect_ack(m2ts->service, channel, e); return e; } else { pes->user = channel; e = GF_OK; - gf_term_on_connect(m2ts->service, channel, e); + gf_service_connect_ack(m2ts->service, channel, e); return e; } } @@ -1224,7 +1240,7 @@ static GF_Err M2TS_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, c pes->program->pid_playing = pes->pid; } } - gf_term_on_connect(m2ts->service, channel, e); + gf_service_connect_ack(m2ts->service, channel, e); return e; } @@ -1238,6 +1254,21 @@ static GF_M2TS_PES *M2TS_GetChannel(M2TSIn *m2ts, LPNETCHANNEL channel) } return NULL; } + +static GF_M2TS_PES *M2TS_GetFirstRunningChannel(M2TSIn *m2ts) +{ + u32 i; + for (i=0; its->ess[i]; + if (!pes || (pes->pid==pes->program->pmt_pid)) continue; + if (!pes->user) continue; + + if (gf_m2ts_pes_get_framing_mode(pes) >= GF_M2TS_PES_FRAMING_DEFAULT) + return pes; + } + return NULL; +} + static GF_Err M2TS_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { M2TSIn *m2ts = plug->priv; @@ -1247,7 +1278,7 @@ static GF_Err M2TS_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel pes->user = NULL; e = GF_OK; } - gf_term_on_disconnect(m2ts->service, channel, e); + gf_service_disconnect_ack(m2ts->service, channel, e); return GF_OK; } @@ -1281,7 +1312,7 @@ static void gf_m2ts_switch_quality(GF_M2TS_Program *prog, GF_M2TS_Demuxer *ts, B memset(&com, 0, sizeof(com)); com.command_type = GF_NET_CHAN_RESET; com.base.on_channel = ((GF_M2TS_PES *)es)->user; - gf_term_on_command(((M2TSIn *)ts->user)->service, &com, GF_OK); + gf_service_command(((M2TSIn *)ts->user)->service, &com, GF_OK); prog->pid_playing = ((GF_M2TS_PES *)es)->depends_on_pid; return; } @@ -1293,7 +1324,7 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { GF_M2TS_PES *pes; M2TSIn *m2ts = plug->priv; - GF_M2TS_Demuxer *ts = m2ts->ts; + GF_M2TS_Demuxer *ts = m2ts->ts; if (com->command_type==GF_NET_SERVICE_HAS_AUDIO) { char *frag = strchr(com->audio.base_url, '#'); @@ -1318,6 +1349,20 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) m2ts_flush_data(m2ts, GF_M2TS_FLUSH_DATA); return GF_OK; } + //get info on the first running program + if (com->command_type==GF_NET_SERVICE_INFO) { + pes = M2TS_GetFirstRunningChannel(m2ts); + if (pes) { + GF_M2TS_SDT *sdt = gf_m2ts_get_sdt_info(ts, pes->program->number); + if (sdt) { + com->info.name = sdt->service; + com->info.provider = sdt->provider; + } + } else { + m2ts->flush_sdt = 1; + } + return GF_OK; + } if (!com->base.on_channel) return GF_NOT_SUPPORTED; @@ -1330,7 +1375,7 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) if (m2ts->ts->file) return GF_OK; return GF_NOT_SUPPORTED; case GF_NET_CHAN_BUFFER: - //do not override config + //do not override config if (ts->dnload || plug->query_proxy) { if (!com->buffer.max) com->buffer.max = 1000; } @@ -1352,10 +1397,12 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSIn] Setting default reframing for PID %d\n", pes->pid)); /*this is a multplex, only trigger the play command for the first stream activated*/ if (!ts->nb_playing) { - ts->start_range = (u32) (com->play.start_range*1000); - ts->end_range = (com->play.end_range>0) ? (u32) (com->play.end_range*1000) : 0; + if (ts->file) { + ts->start_range = (u32) (com->play.start_range*1000); + ts->end_range = (com->play.end_range>0) ? (u32) (com->play.end_range*1000) : 0; + } - if (plug->query_proxy && ts->file) + if (plug->query_proxy && ts->file) ts->segment_switch = 1; /*start demuxer*/ @@ -1377,7 +1424,7 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } /* In case of EOS, we may receive a stop command after no one is playing */ if (ts->nb_playing) - ts->nb_playing--; + ts->nb_playing--; /*stop demuxer*/ if (!plug->query_proxy) { if (!ts->nb_playing && (ts->run_state==1)) { @@ -1408,13 +1455,13 @@ static GF_Err M2TS_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } } -static u32 M2TS_RegisterMimeTypes(const GF_InputService * service){ - int i; - if (service == NULL) - return 0; - for (i = 0 ; MIMES[i]; i++) - gf_term_register_mime_type( service, MIMES[i], "ts m2t dmb", "MPEG-2 TS"); - return i; +static u32 M2TS_RegisterMimeTypes(const GF_InputService * service) { + int i; + if (service == NULL) + return 0; + for (i = 0 ; MIMES[i]; i++) + gf_service_register_mime( service, MIMES[i], "ts m2t dmb", "MPEG-2 TS"); + return i; } static void M2TS_GetNetworkType(GF_InputService *plug,M2TSIn *reader) @@ -1423,12 +1470,12 @@ static void M2TS_GetNetworkType(GF_InputService *plug,M2TSIn *reader) const char *mcast_ifce; mob_on = gf_modules_get_option((GF_BaseInterface*)plug, "Network", "MobileIPEnabled"); - if(mob_on && !strcmp(mob_on, "yes")){ + if(mob_on && !strcmp(mob_on, "yes")) { reader->ts->MobileIPEnabled = 1; reader->ts->network_type = gf_modules_get_option((GF_BaseInterface*)plug, "Network", "MobileIP"); } - mcast_ifce = gf_modules_get_option((GF_BaseInterface*)plug, "Network", "DefaultMCastInterface"); + mcast_ifce = gf_modules_get_option((GF_BaseInterface*)plug, "Network", "DefaultMCastInterface"); if(mcast_ifce) reader->ts->network_type = gf_strdup(mcast_ifce); } @@ -1459,7 +1506,7 @@ GF_InputService *NewM2TSReader() reader->ts->th = gf_th_new("MPEG-2 TS Demux"); reader->mx = gf_mx_new("MPEG2 Demux"); - + return plug; } @@ -1469,11 +1516,11 @@ void DeleteM2TSReader(void *ifce) M2TSIn *m2ts; GF_InputService *plug = (GF_InputService *) ifce; if (!ifce) - return; + return; m2ts = plug->priv; if (!m2ts) - return; - if( m2ts->ts->requested_progs ){ + return; + if( m2ts->ts->requested_progs ) { count = gf_list_count(m2ts->ts->requested_progs); for (i = 0; i < count; i++) { M2TSIn_Prog *prog = gf_list_get(m2ts->ts->requested_progs, i); @@ -1483,7 +1530,7 @@ void DeleteM2TSReader(void *ifce) gf_list_del(m2ts->ts->requested_progs); m2ts->ts->requested_progs = NULL; } - if( m2ts->ts->requested_pids ){ + if( m2ts->ts->requested_pids ) { count = gf_list_count(m2ts->ts->requested_pids); for (i = 0; i < count; i++) { M2TSIn_Prog *prog = gf_list_get(m2ts->ts->requested_pids, i); @@ -1526,9 +1573,11 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { #ifndef GPAC_DISABLE_MPEG2TS - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *) NewM2TSReader(); + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *) NewM2TSReader(); #endif - default: return NULL; + default: + return NULL; } } @@ -1537,7 +1586,9 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_MPEG2TS - case GF_NET_CLIENT_INTERFACE: DeleteM2TSReader(ifce); break; + case GF_NET_CLIENT_INTERFACE: + DeleteM2TSReader(ifce); + break; #endif } } diff --git a/modules/mse_in/mse_in.c b/modules/mse_in/mse_in.c index 8527fe6..c60f644 100644 --- a/modules/mse_in/mse_in.c +++ b/modules/mse_in/mse_in.c @@ -27,10 +27,10 @@ #include #include -typedef struct __mse_module +typedef struct __mse_module { - GF_HTML_MediaSource *mediasource; - GF_InputService *plug; + GF_HTML_MediaSource *mediasource; + GF_InputService *plug; } GF_MSE_In; /* The MSE plugin has no MIME type associated, it cannot handle basic media resources (it needs a blob)*/ @@ -42,14 +42,14 @@ static u32 MSE_RegisterMimeTypes(const GF_InputService *plug) /* Only Blob URL are supported */ static Bool MSE_CanHandleURL(GF_InputService *plug, const char *url) { - if (!plug || !url) - return GF_FALSE; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received CanHandleURL request from terminal for URL '%s'\n", url)); - if (!strncmp(url, "blob:", 5)) { - return GF_TRUE; - } else { - return GF_FALSE; - } + if (!plug || !url) + return GF_FALSE; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received CanHandleURL request from terminal for URL '%s'\n", url)); + if (!strncmp(url, "blob:", 5)) { + return GF_TRUE; + } else { + return GF_FALSE; + } } /* Returns the source buffer associated with the terminal channel */ @@ -73,79 +73,79 @@ static GF_HTML_SourceBuffer *MSE_GetSourceBufferForChannel(GF_HTML_MediaSource * } } -/* For a given source buffer, returns the media track associated with the terminal channel object +/* For a given source buffer, returns the media track associated with the terminal channel object Association is saved during the ConnectChannel operation */ static GF_HTML_Track *MSE_GetTrackForChannel(GF_HTML_SourceBuffer *sb, LPNETCHANNEL channel) { - u32 i; - u32 count; - count = gf_list_count(sb->tracks); - for (i = 0; i < count; i++) - { - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); - if (track->channel == channel) - { - return track; - } - } - return NULL; + u32 i; + u32 count; + count = gf_list_count(sb->tracks); + for (i = 0; i < count; i++) + { + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); + if (track->channel == channel) + { + return track; + } + } + return NULL; } /* For a given source buffer, returns the media track associated with the given ESID Association is saved when the initialisation segment has been parsed */ static GF_HTML_Track *gf_mse_get_track_by_esid(GF_HTML_SourceBuffer *sb, u32 ESID) { - GF_HTML_Track *track; - u32 i; - u32 count; - count = gf_list_count(sb->tracks); - for (i=0; itracks, i); - if (track->bin_id == ESID) - { - return track; - } - } - return NULL; + GF_HTML_Track *track; + u32 i; + u32 count; + count = gf_list_count(sb->tracks); + for (i=0; itracks, i); + if (track->bin_id == ESID) + { + return track; + } + } + return NULL; } /* We connect the channel only if the sourcebuffer has been created, and a track with the right ESID has been found in the init segment */ static GF_Err MSE_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const char *url, Bool upstream) { - u32 ESID; - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); - if (!plug || !plug->priv || !sb || !sb->parser) return GF_SERVICE_ERROR; - if (strstr(url, "ES_ID")) { - GF_HTML_Track *track; - sscanf(url, "ES_ID=%u", &ESID); - track = gf_mse_get_track_by_esid(sb, ESID); - if (!track) { - return GF_BAD_PARAM; - } else { - track->channel = channel; + u32 ESID; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); + if (!plug || !plug->priv || !sb || !sb->parser) return GF_SERVICE_ERROR; + if (strstr(url, "ES_ID")) { + GF_HTML_Track *track; + sscanf(url, "ES_ID=%u", &ESID); + track = gf_mse_get_track_by_esid(sb, ESID); + if (!track) { + return GF_BAD_PARAM; + } else { + track->channel = channel; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Channel Connection request on Service %p from terminal for URL '%s#%s'\n", channel, msein->mediasource->blobURI, url)); - return sb->parser->ConnectChannel(sb->parser, channel, url, upstream); - } - } else { - return GF_BAD_PARAM; - } + return sb->parser->ConnectChannel(sb->parser, channel, url, upstream); + } + } else { + return GF_BAD_PARAM; + } } static GF_Err MSE_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_HTML_Track *track; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_HTML_Track *track; GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); - if (!plug || !plug->priv || !sb || !sb->parser) return GF_SERVICE_ERROR; + if (!plug || !plug->priv || !sb || !sb->parser) return GF_SERVICE_ERROR; track = MSE_GetTrackForChannel(sb, channel); if (track) { track->channel = NULL; } - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Disconnect channel request on Service %p from terminal for channel %p\n", msein->mediasource->service, channel)); - return sb->parser->DisconnectChannel(sb->parser, channel); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Disconnect channel request on Service %p from terminal for channel %p\n", msein->mediasource->service, channel)); + return sb->parser->DisconnectChannel(sb->parser, channel); } /* Upon service connection, if the URL is a blobURL, we do the following: @@ -153,161 +153,161 @@ static GF_Err MSE_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) - trigger a source event to the media node associated with the service */ static GF_Err MSE_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Service Connection request on Service %p from terminal for URL '%s'\n", serv, url)); - if (!msein|| !serv || !url) { + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Service Connection request on Service %p from terminal for URL '%s'\n", serv, url)); + if (!msein|| !serv || !url) { return GF_BAD_PARAM; } else { - GF_HTML_MediaSource *ms = NULL; + GF_HTML_MediaSource *ms = NULL; - sscanf(url, "blob:%p", &ms); - msein->mediasource = ms; + sscanf(url, "blob:%p", &ms); + msein->mediasource = ms; ms->reference_count++; - ms->service = serv; + ms->service = serv; gf_mse_mediasource_open(ms, serv->owner->mo); - return GF_OK; - } + return GF_OK; + } } /* There is no service description (no MPEG-4 IOD) for this module, the associated scene will be generated dynamically */ static GF_Descriptor *MSE_GetServiceDesc(GF_InputService *plug, u32 expect_type, const char *sub_url) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Service Description request on Service %p from terminal for URL '%s'\n", msein->mediasource->service, sub_url)); - return NULL; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Service Description request on Service %p from terminal for URL '%s'\n", msein->mediasource->service, sub_url)); + return NULL; } /* Indicate that the media source object is unused anymore */ static GF_Err MSE_CloseService(GF_InputService *plug) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - assert( msein ); - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Close Service request on Service %p from terminal for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + assert( msein ); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Close Service request on Service %p from terminal for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); if (msein->mediasource) { - gf_term_on_disconnect(msein->mediasource->service, NULL, GF_OK); + gf_service_disconnect_ack(msein->mediasource->service, NULL, GF_OK); gf_mse_mediasource_del(msein->mediasource, GF_FALSE); msein->mediasource = NULL; } - return GF_OK; + return GF_OK; } -/* Forward all the commands received from the the terminal +/* Forward all the commands received from the the terminal to the parser associated with the channel on which the command is received */ static GF_Err MSE_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_HTML_SourceBuffer *sb = NULL; - - if (!plug || !plug->priv || !com ) return GF_SERVICE_ERROR; - - /* channel independant commands */ - switch (com->command_type) { - case GF_NET_SERVICE_INFO: - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Info command from terminal on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); - return GF_NOT_SUPPORTED; - case GF_NET_SERVICE_HAS_AUDIO: - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received HasAudio command from terminal on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); - return GF_OK; - case GF_NET_SERVICE_QUALITY_SWITCH: - return GF_NOT_SUPPORTED; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_HTML_SourceBuffer *sb = NULL; + + if (!plug || !plug->priv || !com ) return GF_SERVICE_ERROR; + + /* channel independant commands */ + switch (com->command_type) { + case GF_NET_SERVICE_INFO: + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Info command from terminal on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); + return GF_NOT_SUPPORTED; + case GF_NET_SERVICE_HAS_AUDIO: + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received HasAudio command from terminal on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); + return GF_OK; + case GF_NET_SERVICE_QUALITY_SWITCH: + return GF_NOT_SUPPORTED; case GF_NET_SERVICE_FLUSH_DATA: return GF_NOT_SUPPORTED; - default: - break; - } + default: + break; + } - if (!com->base.on_channel) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received unknown command %d from terminal on Service %p for URL '%s'\n", com->command_type, msein->mediasource->service, msein->mediasource->blobURI)); + if (!com->base.on_channel) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received unknown command %d from terminal on Service %p for URL '%s'\n", com->command_type, msein->mediasource->service, msein->mediasource->blobURI)); return GF_NOT_SUPPORTED; } - sb = MSE_GetSourceBufferForChannel(msein->mediasource, com->base.on_channel); - if (!sb || !sb->parser) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] SourceBuffer not ready on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); + sb = MSE_GetSourceBufferForChannel(msein->mediasource, com->base.on_channel); + if (!sb || !sb->parser) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] SourceBuffer not ready on Service %p for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); return GF_NOT_SUPPORTED; } - switch (com->command_type) { - case GF_NET_CHAN_PLAY: - return sb->parser->ServiceCommand(sb->parser, com); + switch (com->command_type) { + case GF_NET_CHAN_PLAY: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_STOP: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_STOP: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_PAUSE: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_PAUSE: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_RESUME: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_RESUME: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_SET_SPEED: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_SET_SPEED: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_CONFIG: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_CONFIG: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_DURATION: - /* Ignore the duration given by the input service and - Note: the duration of the initial segment will be 0 anyway (in MP4).*/ - com->duration.duration = 0; - return GF_OK; + case GF_NET_CHAN_DURATION: + /* Ignore the duration given by the input service and + Note: the duration of the initial segment will be 0 anyway (in MP4).*/ + com->duration.duration = 0; + return GF_OK; - case GF_NET_CHAN_BUFFER: - com->buffer.max = com->buffer.min = 0; - return GF_OK; + case GF_NET_CHAN_BUFFER: + com->buffer.max = com->buffer.min = 0; + return GF_OK; - case GF_NET_CHAN_BUFFER_QUERY: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_BUFFER_QUERY: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_GET_DSI: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_GET_DSI: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_SET_PADDING: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_SET_PADDING: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_SET_PULL: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_SET_PULL: + return sb->parser->ServiceCommand(sb->parser, com); - case GF_NET_CHAN_INTERACTIVE: - /* we are interactive */ - return GF_OK; + case GF_NET_CHAN_INTERACTIVE: + /* we are interactive */ + return GF_OK; - case GF_NET_CHAN_GET_PIXEL_AR: - return sb->parser->ServiceCommand(sb->parser, com); + case GF_NET_CHAN_GET_PIXEL_AR: + return sb->parser->ServiceCommand(sb->parser, com); - default: - return sb->parser->ServiceCommand(sb->parser, com); - } + default: + return sb->parser->ServiceCommand(sb->parser, com); + } } /* Forward the request for a new packet to the track (ask the parser to parse a new buffer or use already parsed AU) */ -static GF_Err MSE_ChannelGetSLP(GF_InputService *plug, LPNETCHANNEL channel, char **out_data_ptr, u32 *out_data_size, - GF_SLHeader *out_sl_hdr, Bool *sl_compressed, GF_Err *out_reception_status, Bool *is_new_data) +static GF_Err MSE_ChannelGetSLP(GF_InputService *plug, LPNETCHANNEL channel, char **out_data_ptr, u32 *out_data_size, + GF_SLHeader *out_sl_hdr, Bool *sl_compressed, GF_Err *out_reception_status, Bool *is_new_data) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); - GF_HTML_Track *track = MSE_GetTrackForChannel(sb, channel); - if (!plug || !plug->priv || !sb || !sb->parser || !track) return GF_SERVICE_ERROR; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); + GF_HTML_Track *track = MSE_GetTrackForChannel(sb, channel); + if (!plug || !plug->priv || !sb || !sb->parser || !track) return GF_SERVICE_ERROR; gf_mse_track_buffer_get_next_packet(track, out_data_ptr, out_data_size, out_sl_hdr, sl_compressed, out_reception_status, is_new_data); - return GF_OK; + return GF_OK; } /* Indicate to the track that a packet can be released (and potentially deleted) */ static GF_Err MSE_ChannelReleaseSLP(GF_InputService *plug, LPNETCHANNEL channel) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); - GF_HTML_Track *track = MSE_GetTrackForChannel(sb, channel); - if (!plug || !plug->priv || !sb || !sb->parser || !track) return GF_SERVICE_ERROR; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_HTML_SourceBuffer *sb = MSE_GetSourceBufferForChannel(msein->mediasource, channel); + GF_HTML_Track *track = MSE_GetTrackForChannel(sb, channel); + if (!plug || !plug->priv || !sb || !sb->parser || !track) return GF_SERVICE_ERROR; gf_mse_track_buffer_release_packet(track); - return GF_OK; + return GF_OK; } /* This module can only handle one blobURL at a time */ static Bool MSE_CanHandleURLInService(GF_InputService *plug, const char *url) { - GF_MSE_In *msein = (GF_MSE_In*) plug->priv; - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received CanHandleURLInService request on service %p from terminal for URL '%s'\n", msein->mediasource->service, url)); - if (!plug || !plug->priv) return GF_FALSE; + GF_MSE_In *msein = (GF_MSE_In*) plug->priv; + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received CanHandleURLInService request on service %p from terminal for URL '%s'\n", msein->mediasource->service, url)); + if (!plug || !plug->priv) return GF_FALSE; if (!strcmp(url, msein->mediasource->blobURI)) { return GF_TRUE; } else { @@ -318,49 +318,49 @@ static Bool MSE_CanHandleURLInService(GF_InputService *plug, const char *url) GPAC_MODULE_EXPORT const u32 *QueryInterfaces() { - static u32 si [] = { - GF_NET_CLIENT_INTERFACE, - 0 - }; - return si; + static u32 si [] = { + GF_NET_CLIENT_INTERFACE, + 0 + }; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - GF_MSE_In *msein; - GF_InputService *plug; - if (InterfaceType != GF_NET_CLIENT_INTERFACE) return NULL; - - GF_SAFEALLOC(plug, GF_InputService); - GF_REGISTER_MODULE_INTERFACE(plug, GF_NET_CLIENT_INTERFACE, "GPAC MSE Loader", "gpac distribution") - plug->RegisterMimeTypes = MSE_RegisterMimeTypes; - plug->CanHandleURL = MSE_CanHandleURL; - plug->ConnectService = MSE_ConnectService; - plug->CloseService = MSE_CloseService; - plug->GetServiceDescriptor = MSE_GetServiceDesc; - plug->ConnectChannel = MSE_ConnectChannel; - plug->DisconnectChannel = MSE_DisconnectChannel; - plug->ServiceCommand = MSE_ServiceCommand; - plug->CanHandleURLInService = MSE_CanHandleURLInService; - plug->ChannelGetSLP = MSE_ChannelGetSLP; - plug->ChannelReleaseSLP = MSE_ChannelReleaseSLP; - GF_SAFEALLOC(msein, GF_MSE_In); - plug->priv = msein; - msein->plug = plug; - return (GF_BaseInterface *)plug; + GF_MSE_In *msein; + GF_InputService *plug; + if (InterfaceType != GF_NET_CLIENT_INTERFACE) return NULL; + + GF_SAFEALLOC(plug, GF_InputService); + GF_REGISTER_MODULE_INTERFACE(plug, GF_NET_CLIENT_INTERFACE, "GPAC MSE Loader", "gpac distribution") + plug->RegisterMimeTypes = MSE_RegisterMimeTypes; + plug->CanHandleURL = MSE_CanHandleURL; + plug->ConnectService = MSE_ConnectService; + plug->CloseService = MSE_CloseService; + plug->GetServiceDescriptor = MSE_GetServiceDesc; + plug->ConnectChannel = MSE_ConnectChannel; + plug->DisconnectChannel = MSE_DisconnectChannel; + plug->ServiceCommand = MSE_ServiceCommand; + plug->CanHandleURLInService = MSE_CanHandleURLInService; + plug->ChannelGetSLP = MSE_ChannelGetSLP; + plug->ChannelReleaseSLP = MSE_ChannelReleaseSLP; + GF_SAFEALLOC(msein, GF_MSE_In); + plug->priv = msein; + msein->plug = plug; + return (GF_BaseInterface *)plug; } GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *bi) { - GF_MSE_In *msein; + GF_MSE_In *msein; - if (bi->InterfaceType!=GF_NET_CLIENT_INTERFACE) return; + if (bi->InterfaceType!=GF_NET_CLIENT_INTERFACE) return; - msein = (GF_MSE_In*) ((GF_InputService*)bi)->priv; - assert(msein); - gf_free(msein); - gf_free(bi); + msein = (GF_MSE_In*) ((GF_InputService*)bi)->priv; + assert(msein); + gf_free(msein); + gf_free(bi); } GPAC_MODULE_STATIC_DELARATION( mse_in ) diff --git a/modules/odf_dec/odf_dec.c b/modules/odf_dec/odf_dec.c index 5d9c265..9558807 100644 --- a/modules/odf_dec/odf_dec.c +++ b/modules/odf_dec/odf_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -164,7 +164,7 @@ static GF_Err ODF_DetachStream(GF_BaseDecoder *plug, u16 ES_ID) static GF_Err ODF_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_time, u32 mmlevel) + u16 ES_ID, u32 AU_time, u32 mmlevel) { GF_Err e; GF_ODCom *com; @@ -208,9 +208,9 @@ static GF_Err ODF_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 i e = GF_OK; } #else - e = GF_OK; + e = GF_OK; #endif - break; + break; case GF_ODF_IPMP_REMOVE_TAG: e = GF_NOT_SUPPORTED; break; @@ -251,13 +251,13 @@ static u32 ODF_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *esd void DeleteODDec(GF_BaseDecoder *plug) { ODPriv *priv; - if (!plug) - return; - priv = (ODPriv *)plug->privateStack; - if (priv){ - gf_free(priv); - plug->privateStack = NULL; - } + if (!plug) + return; + priv = (ODPriv *)plug->privateStack; + if (priv) { + gf_free(priv); + plug->privateStack = NULL; + } gf_free(plug); } @@ -308,8 +308,8 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { - if (!ifce) - return; + if (!ifce) + return; switch (ifce->InterfaceType) { case GF_SCENE_DECODER_INTERFACE: DeleteODDec((GF_BaseDecoder *)ifce); diff --git a/modules/ogg/ogg_in.c b/modules/ogg/ogg_in.c index f35b6f9..50383b6 100644 --- a/modules/ogg/ogg_in.c +++ b/modules/ogg/ogg_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "ogg_in.h" @@ -28,7 +28,7 @@ #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_OGG) -typedef struct +typedef struct { u32 streamType; /*MPEG-4 streamType*/ u32 num_init_headers; @@ -77,8 +77,8 @@ typedef struct u32 nb_playing, kill_demux, do_seek, service_type, init_remain, bos_done; /*ogg ogfile state*/ - ogg_sync_state oy; - + ogg_sync_state oy; + OGGStream *resync_stream; Bool has_video, has_audio, is_single_media; @@ -100,7 +100,7 @@ void OGG_EndOfFile(OGGReader *read) OGGStream *st; u32 i=0; while ((st = gf_list_enum(read->streams, &i))) { - gf_term_on_sl_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); } } @@ -132,10 +132,10 @@ static Bool OGG_ReadPage(OGGReader *read, ogg_page *oggpage) } } - while (ogg_sync_pageout(&read->oy, oggpage ) != 1 ) { - char *buffer; + while (ogg_sync_pageout(&read->oy, oggpage ) != 1 ) { + char *buffer; u32 bytes; - + if (read->ogfile) { if (feof(read->ogfile)) { OGG_EndOfFile(read); @@ -149,9 +149,9 @@ static Bool OGG_ReadPage(OGGReader *read, ogg_page *oggpage) if (!bytes) return 0; buffer = ogg_sync_buffer(&read->oy, bytes); memcpy(buffer, buf, bytes); - ogg_sync_wrote(&read->oy, bytes); - } - return 1; + ogg_sync_wrote(&read->oy, bytes); + } + return 1; } static OGGStream *OGG_FindStreamForPage(OGGReader *read, ogg_page *oggpage) @@ -160,7 +160,7 @@ static OGGStream *OGG_FindStreamForPage(OGGReader *read, ogg_page *oggpage) count = gf_list_count(read->streams); for (i=0; istreams, i); - if (ogg_stream_pagein(&st->os, oggpage) == 0) return st; + if (ogg_stream_pagein(&st->os, oggpage) == 0) return st; } return NULL; } @@ -217,7 +217,7 @@ Double OGG_GranuleToMediaTime(OGGInfo *cfg, s64 granule) } -static void OGG_GetStreamInfo(ogg_packet *oggpacket, OGGInfo *info) +static void OGG_GetStreamInfo(ogg_packet *oggpacket, OGGInfo *info) { oggpack_buffer opb; @@ -285,7 +285,7 @@ static void OGG_GetStreamInfo(ogg_packet *oggpacket, OGGInfo *info) info->theora_kgs ++; keyframe_freq_force >>= 1; } - info->frame_rate = ((Float)fps_numerator) / fps_denominator; + info->frame_rate = ((Float)fps_numerator) / fps_denominator; info->num_init_headers = 3; gf_bs_del(bs); info->frame_rate_base = fps_denominator; @@ -298,7 +298,7 @@ static void OGG_ResetupStream(OGGReader *read, OGGStream *st, ogg_page *oggpage) ogg_stream_init(&st->os, st->serial_no); ogg_stream_pagein(&st->os, oggpage); st->parse_headers = st->info.num_init_headers; - + if (st->info.sample_rate) { st->seek_granule = (s64) (read->start_range * st->info.sample_rate); } else if (st->info.frame_rate) { @@ -341,23 +341,23 @@ static void OGG_NewStream(OGGReader *read, ogg_page *oggpage) } ogg_stream_clear(&os); /*nope streams are different, signal eos on this one*/ - gf_term_on_sl_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); } } GF_SAFEALLOC(st, OGGStream); - st->serial_no = serial_no; - ogg_stream_init(&st->os, st->serial_no); + st->serial_no = serial_no; + ogg_stream_init(&st->os, st->serial_no); ogg_stream_pagein(&st->os, oggpage); - + ogg_stream_packetpeek(&st->os, &oggpacket); OGG_GetStreamInfo(&oggpacket, &st->info); /*check we don't discard audio or visual streams*/ if ( ((read->service_type==1) && (st->info.streamType==GF_STREAM_AUDIO)) - || ((read->service_type==2) && (st->info.streamType==GF_STREAM_VISUAL)) ) + || ((read->service_type==2) && (st->info.streamType==GF_STREAM_VISUAL)) ) { - ogg_stream_clear(&st->os); + ogg_stream_clear(&st->os); gf_free(st); return; } @@ -366,7 +366,7 @@ static void OGG_NewStream(OGGReader *read, ogg_page *oggpage) st->ESID = 2 + gf_list_count(read->streams); st->parse_headers = st->info.num_init_headers; if (st->parse_headers) read->init_remain++; - + if (st->info.sample_rate) { st->seek_granule = (s64) (read->start_range * st->info.sample_rate); } else if (st->info.frame_rate) { @@ -381,13 +381,13 @@ static void OGG_NewStream(OGGReader *read, ogg_page *oggpage) } else { read->has_audio = 1; } - if (st->got_headers && read->is_inline) gf_term_add_media(read->service, (GF_Descriptor*) OGG_GetOD(st), 0); + if (st->got_headers && read->is_inline) gf_service_declare_media(read->service, (GF_Descriptor*) OGG_GetOD(st), 0); } void OGG_SignalEndOfStream(OGGReader *read, OGGStream *st) { if (st->eos_detected) { - gf_term_on_sl_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(read->service, st->ch, NULL, 0, NULL, GF_EOS); ogg_stream_clear(&st->os); } } @@ -402,7 +402,7 @@ void OGG_SendPackets(OGGReader *read, OGGStream *st, ogg_packet *oggpacket) slh.randomAccessPointFlag = 1; slh.compositionTimeStampFlag = 1; slh.compositionTimeStamp = st->ogg_ts; - gf_term_on_sl_packet(read->service, st->ch, (char *) oggpacket->packet, oggpacket->bytes, &slh, GF_OK); + gf_service_send_packet(read->service, st->ch, (char *) oggpacket->packet, oggpacket->bytes, &slh, GF_OK); st->ogg_ts += gf_vorbis_check_frame(&st->vp, (char *) oggpacket->packet, oggpacket->bytes); } else if (st->info.type==OGG_THEORA) { @@ -415,7 +415,7 @@ void OGG_SendPackets(OGGReader *read, OGGStream *st, ogg_packet *oggpacket) slh.randomAccessPointFlag = oggpackB_read(&opb, 1) ? 0 : 1; slh.compositionTimeStampFlag = 1; slh.compositionTimeStamp = st->ogg_ts; - gf_term_on_sl_packet(read->service, st->ch, (char *) oggpacket->packet, oggpacket->bytes, &slh, GF_OK); + gf_service_send_packet(read->service, st->ch, (char *) oggpacket->packet, oggpacket->bytes, &slh, GF_OK); st->ogg_ts += 1000; } } @@ -424,7 +424,7 @@ void OGG_SendPackets(OGGReader *read, OGGStream *st, ogg_packet *oggpacket) void OGG_Process(OGGReader *read) { OGGStream *st; - ogg_packet oggpacket; + ogg_packet oggpacket; ogg_page oggpage; if (read->resync_stream) { @@ -447,14 +447,14 @@ void OGG_Process(OGGReader *read) if (!read->bos_done && read->is_live) { u32 now = gf_sys_clock(); if (now-read->tune_in_time > 1000) { - gf_term_on_message(read->service, GF_OK, "Waiting for tune in..."); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[OGG]: Waiting for tune in...\n")); read->tune_in_time = now; } } return; } - if (ogg_page_eos(&oggpage)) + if (ogg_page_eos(&oggpage)) st->eos_detected = 1; if (st->parse_headers && !st->got_headers) { @@ -477,8 +477,8 @@ void OGG_Process(OGGReader *read) st->parse_headers--; if (!st->parse_headers) { st->got_headers = 1; - if (read->is_inline) - gf_term_add_media(read->service, (GF_Descriptor*) OGG_GetOD(st), 0); + if (read->is_inline) + gf_service_declare_media(read->service, (GF_Descriptor*) OGG_GetOD(st), 0); break; } } @@ -515,7 +515,7 @@ process_stream: map.map_time.reset_buffers = (read->start_range>0.2) ? 1 : 0; map.map_time.timestamp = st->ogg_ts = 0; map.map_time.media_time = t; - gf_term_on_command(read->service, &map, GF_OK); + gf_service_command(read->service, &map, GF_OK); st->map_time = 0; OGG_SendPackets(read, st, &oggpacket); } @@ -540,17 +540,17 @@ static u32 OggDemux(void *par) if (read->needs_connection) { read->needs_connection=0; - gf_term_on_connect(read->service, NULL, GF_OK); + gf_service_connect_ack(read->service, NULL, GF_OK); } - ogg_sync_init(&read->oy); + ogg_sync_init(&read->oy); while (!read->kill_demux) { OGG_Process(read); if (!read->bos_done) continue; - + /*wait for stream connection*/ while (!read->kill_demux && !read->nb_playing) { gf_sleep(20); @@ -585,7 +585,7 @@ static u32 OggDemux(void *par) st = gf_list_get(read->streams, i); if (!st->ch) continue; com.base.on_channel = st->ch; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if (com.buffer.occupancy < read->data_buffer_ms) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[OGG] channel %d needs fill (%d ms data, %d max buffer)\n", st->ESID, com.buffer.occupancy, read->data_buffer_ms)); go = 0; @@ -596,7 +596,7 @@ static u32 OggDemux(void *par) gf_sleep(0); } } - ogg_sync_clear(&read->oy); + ogg_sync_clear(&read->oy); read->kill_demux=2; return 0; } @@ -613,7 +613,7 @@ Bool OGG_CheckFile(OGGReader *read) gf_f64_seek(read->ogfile, 0, SEEK_SET); ogg_sync_init(&read->oy); - memset(&the_info, 0, sizeof(OGGInfo)); + memset(&the_info, 0, sizeof(OGGInfo)); max_gran = 0; while (1) { if (!OGG_ReadPage(read, &oggpage)) break; @@ -624,7 +624,7 @@ Bool OGG_CheckFile(OGGReader *read) ogg_stream_packetpeek(&os, &oggpacket); if (ogg_stream_pagein(&os, &oggpage) >= 0 ) { ogg_stream_packetpeek(&os, &oggpacket); - OGG_GetStreamInfo(&oggpacket, &info); + OGG_GetStreamInfo(&oggpacket, &info); } if (!has_stream) { has_stream = 1; @@ -643,7 +643,7 @@ Bool OGG_CheckFile(OGGReader *read) } } } - ogg_sync_clear(&read->oy); + ogg_sync_clear(&read->oy); read->file_size = gf_f64_tell(read->ogfile); gf_f64_seek(read->ogfile, 0, SEEK_SET); read->dur = 0; @@ -657,7 +657,7 @@ Bool OGG_CheckFile(OGGReader *read) } static const char * OGG_MIMES_AUDIO[] = { - "audio/ogg", "audio/x-ogg", "audio/x-vorbis+ogg", NULL + "audio/ogg", "audio/x-ogg", "audio/x-vorbis+ogg", NULL }; static const char * OGG_MIMES_AUDIO_EXT = "oga spx"; @@ -665,21 +665,21 @@ static const char * OGG_MIMES_AUDIO_EXT = "oga spx"; static const char * OGG_MIMES_AUDIO_DESC = "Xiph.org OGG Music"; static const char * OGG_MIMES_VIDEO[] = { - "application/ogg", "application/x-ogg", "video/ogg", "video/x-ogg", "video/x-ogm+ogg", NULL + "application/ogg", "application/x-ogg", "video/ogg", "video/x-ogg", "video/x-ogm+ogg", NULL }; static const char * OGG_MIMES_VIDEO_DESC = "Xiph.org OGG Movie"; static const char * OGG_MIMES_VIDEO_EXT = "ogg ogv oggm"; -static u32 OGG_RegisterMimeTypes(const GF_InputService *plug){ - u32 i, c; - for (i = 0 ; OGG_MIMES_AUDIO[i]; i++) - gf_term_register_mime_type(plug, OGG_MIMES_AUDIO[i], OGG_MIMES_AUDIO_EXT, OGG_MIMES_AUDIO_DESC); - c = i; - for (i = 0 ; OGG_MIMES_VIDEO[i]; i++) - gf_term_register_mime_type(plug, OGG_MIMES_VIDEO[i], OGG_MIMES_VIDEO_EXT, OGG_MIMES_VIDEO_DESC); - return c+i; +static u32 OGG_RegisterMimeTypes(const GF_InputService *plug) { + u32 i, c; + for (i = 0 ; OGG_MIMES_AUDIO[i]; i++) + gf_service_register_mime(plug, OGG_MIMES_AUDIO[i], OGG_MIMES_AUDIO_EXT, OGG_MIMES_AUDIO_DESC); + c = i; + for (i = 0 ; OGG_MIMES_VIDEO[i]; i++) + gf_service_register_mime(plug, OGG_MIMES_VIDEO[i], OGG_MIMES_VIDEO_EXT, OGG_MIMES_VIDEO_DESC); + return c+i; } static Bool OGG_CanHandleURL(GF_InputService *plug, const char *url) @@ -687,13 +687,13 @@ static Bool OGG_CanHandleURL(GF_InputService *plug, const char *url) char *sExt; u32 i; sExt = strrchr(url, '.'); - for (i = 0 ; OGG_MIMES_AUDIO[i]; i++){ - if (gf_term_check_extension(plug, OGG_MIMES_AUDIO[i], OGG_MIMES_AUDIO_EXT, OGG_MIMES_AUDIO_DESC, sExt)) - return 1; + for (i = 0 ; OGG_MIMES_AUDIO[i]; i++) { + if (gf_service_check_mime_register(plug, OGG_MIMES_AUDIO[i], OGG_MIMES_AUDIO_EXT, OGG_MIMES_AUDIO_DESC, sExt)) + return 1; } - for (i = 0 ; OGG_MIMES_VIDEO[i]; i++){ - if (gf_term_check_extension(plug, OGG_MIMES_VIDEO[i], OGG_MIMES_VIDEO_EXT, OGG_MIMES_VIDEO_DESC, sExt)) - return 1; + for (i = 0 ; OGG_MIMES_VIDEO[i]; i++) { + if (gf_service_check_mime_register(plug, OGG_MIMES_VIDEO[i], OGG_MIMES_VIDEO_EXT, OGG_MIMES_VIDEO_DESC, sExt)) + return 1; } return 0; } @@ -709,8 +709,8 @@ void OGG_NetIO(void *cbk, GF_NETIO_Parameter *param) { OGGReader *read = (OGGReader *) cbk; - gf_term_download_update_stats(read->dnload); - + gf_service_download_update_stats(read->dnload); + /*done*/ if ((param->msg_type==GF_NETIO_DATA_TRANSFERED) && read->ogfile) { read->is_remote = 0; @@ -721,7 +721,7 @@ void OGG_NetIO(void *cbk, GF_NETIO_Parameter *param) if (param->error && read->needs_connection) { read->needs_connection = 0; read->kill_demux = 2; - gf_term_on_connect(read->service, NULL, param->error); + gf_service_connect_ack(read->service, NULL, param->error); } /*we never receive data from here since the downloader is not threaded*/ } @@ -730,11 +730,11 @@ void OGG_DownloadFile(GF_InputService *plug, char *url) { OGGReader *read = (OGGReader*) plug->priv; - read->dnload = gf_term_download_new(read->service, url, GF_NETIO_SESSION_NOT_THREADED, OGG_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, GF_NETIO_SESSION_NOT_THREADED, OGG_NetIO, read); if (!read->dnload) { read->kill_demux=2; read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } /*service confirm is done once fetched, but start the demuxer thread*/ gf_th_run(read->demuxer, OggDemux, read); @@ -749,7 +749,7 @@ static GF_Err OGG_ConnectService(GF_InputService *plug, GF_ClientService *serv, OGGReader *read = plug->priv; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; read->service_type = 0; @@ -787,7 +787,7 @@ static GF_Err OGG_ConnectService(GF_InputService *plug, GF_ClientService *serv, } /*error*/ read->kill_demux=2; - gf_term_on_connect(serv, NULL, reply); + gf_service_connect_ack(serv, NULL, reply); return GF_OK; } @@ -801,9 +801,9 @@ static GF_Err OGG_CloseService(GF_InputService *plug) if (read->ogfile) fclose(read->ogfile); read->ogfile = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -823,7 +823,7 @@ static GF_Descriptor *OGG_GetServiceDesc(GF_InputService *plug, u32 expect_type, while ((st = gf_list_enum(read->streams, &i))) { if ((expect_type==GF_MEDIA_OBJECT_AUDIO) && (st->info.streamType!=GF_STREAM_AUDIO)) continue; if ((expect_type==GF_MEDIA_OBJECT_VIDEO) && (st->info.streamType!=GF_STREAM_VISUAL)) continue; - + od = OGG_GetOD(st); read->is_single_media = 1; return (GF_Descriptor *) od; @@ -856,7 +856,7 @@ static GF_Err OGG_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co break; } } - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -875,7 +875,7 @@ static GF_Err OGG_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) break; } } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -902,7 +902,8 @@ static GF_Err OGG_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) com->buffer.min = com->buffer.max = 0; if (read->is_live) com->buffer.max = read->data_buffer_ms; return GF_OK; - case GF_NET_CHAN_SET_PADDING: return GF_NOT_SUPPORTED; + case GF_NET_CHAN_SET_PADDING: + return GF_NOT_SUPPORTED; case GF_NET_CHAN_DURATION: com->duration.duration = read->dur; @@ -921,12 +922,12 @@ static GF_Err OGG_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } } /*recfg duration in case*/ - if (!read->is_remote && read->dur) { + if (!read->is_remote && read->dur) { GF_NetworkCommand rcfg; rcfg.base.on_channel = NULL; rcfg.base.command_type = GF_NET_CHAN_DURATION; rcfg.duration.duration = read->dur; - gf_term_on_command(read->service, &rcfg, GF_OK); + gf_service_command(read->service, &rcfg, GF_OK); } return GF_OK; case GF_NET_CHAN_STOP: @@ -948,7 +949,7 @@ static Bool OGG_CanHandleURLInService(GF_InputService *plug, const char *url) { char szURL[2048], *sep; OGGReader *read = (OGGReader *)plug->priv; - const char *this_url = gf_term_get_service_url(read->service); + const char *this_url = gf_service_get_url(read->service); if (!this_url || !url) return 0; strcpy(szURL, this_url); diff --git a/modules/ogg/ogg_in.h b/modules/ogg/ogg_in.h index 82145a6..824f474 100644 --- a/modules/ogg/ogg_in.h +++ b/modules/ogg/ogg_in.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/modules/ogg/ogg_load.c b/modules/ogg/ogg_load.c index 94ef77e..78bac81 100644 --- a/modules/ogg/ogg_load.c +++ b/modules/ogg/ogg_load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -27,7 +27,7 @@ #if !defined(__GNUC__) -# if (defined(_WIN32_WCE) || defined (WIN32)) +# if (defined(_WIN32_WCE) || defined (WIN32)) # pragma comment(lib, "libogg_static") # pragma comment(lib, "libvorbis_static") # pragma comment(lib, "libtheora_static") @@ -43,7 +43,7 @@ static u32 OGG_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, /*media type query*/ if (!esd) return GF_CODEC_STREAM_TYPE_SUPPORTED; dsi = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data : NULL; - + switch (esd->decoderConfig->objectTypeIndication) { #ifdef GPAC_HAS_THEORA case GPAC_OTI_MEDIA_OGG: @@ -52,7 +52,7 @@ static u32 OGG_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, } return GF_CODEC_NOT_SUPPORTED; #endif - default: + default: return GF_CODEC_NOT_SUPPORTED; } } @@ -71,7 +71,7 @@ static u32 OGG_CanHandleStream(GF_BaseDecoder *dec, u32 StreamType, GF_ESD *esd, } return GF_CODEC_NOT_SUPPORTED; #endif - default: + default: return GF_CODEC_NOT_SUPPORTED; } } @@ -96,23 +96,27 @@ GF_BaseDecoder *OGG_LoadDecoder() void DeleteOGGDecoder(GF_BaseDecoder *ifcd) { OGGWraper *wrap; - if (!ifcd) - return; - wrap = (OGGWraper *)ifcd->privateStack; - if (wrap){ - switch (wrap->type) { + if (!ifcd) + return; + wrap = (OGGWraper *)ifcd->privateStack; + if (wrap) { + switch (wrap->type) { #ifdef GPAC_HAS_VORBIS - case OGG_VORBIS: DeleteVorbisDecoder(ifcd); break; + case OGG_VORBIS: + DeleteVorbisDecoder(ifcd); + break; #endif #ifdef GPAC_HAS_THEORA - case OGG_THEORA: DeleteTheoraDecoder(ifcd); break; + case OGG_THEORA: + DeleteTheoraDecoder(ifcd); + break; #endif - default: - break; - } - gf_free(wrap); - ifcd->privateStack = NULL; - } + default: + break; + } + gf_free(wrap); + ifcd->privateStack = NULL; + } gf_free(ifcd); } diff --git a/modules/ogg/theora_dec.c b/modules/ogg/theora_dec.c index acfa4dd..d3d6a7b 100644 --- a/modules/ogg/theora_dec.c +++ b/modules/ogg/theora_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,11 +32,11 @@ typedef struct { - theora_info ti; + theora_info ti; theora_state td; - theora_comment tc; - ogg_packet op; - + theora_comment tc; + ogg_packet op; + u16 ES_ID; Bool has_reconfigured; } TheoraDec; @@ -45,12 +45,12 @@ typedef struct static GF_Err THEO_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) { - ogg_packet oggpacket; + ogg_packet oggpacket; GF_BitStream *bs; THEORACTX(); if (ctx->ES_ID) return GF_BAD_PARAM; - + if (!esd->decoderConfig->decoderSpecificInfo) return GF_NON_COMPLIANT_BITSTREAM; if (esd->decoderConfig->objectTypeIndication != GPAC_OTI_MEDIA_OGG) return GF_NON_COMPLIANT_BITSTREAM; @@ -63,8 +63,8 @@ static GF_Err THEO_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) ctx->ES_ID = esd->ESID; - theora_info_init(&ctx->ti); - theora_comment_init(&ctx->tc); + theora_info_init(&ctx->ti); + theora_comment_init(&ctx->tc); bs = gf_bs_new(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, GF_BITSTREAM_READ); @@ -79,7 +79,7 @@ static GF_Err THEO_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) } gf_free(oggpacket.packet); } - theora_decode_init(&ctx->td, &ctx->ti); + theora_decode_init(&ctx->td, &ctx->ti); gf_bs_del(bs); return GF_OK; } @@ -89,9 +89,9 @@ static GF_Err THEO_DetachStream(GF_BaseDecoder *ifcg, u16 ES_ID) THEORACTX(); if (ctx->ES_ID != ES_ID) return GF_BAD_PARAM; - theora_clear(&ctx->td); - theora_info_clear(&ctx->ti); - theora_comment_clear(&ctx->tc); + theora_clear(&ctx->td); + theora_info_clear(&ctx->ti); + theora_comment_clear(&ctx->tc); ctx->ES_ID = 0; return GF_OK; @@ -148,11 +148,11 @@ static GF_Err THEO_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa } -static GF_Err THEO_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err THEO_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { ogg_packet op; yuv_buffer yuv; @@ -168,15 +168,15 @@ static GF_Err THEO_ProcessData(GF_MediaDecoder *ifcg, op.b_o_s = 0; op.e_o_s = 0; op.packetno = 0; - op.packet = inBuffer; - op.bytes = inBufferLength; + op.packet = inBuffer; + op.bytes = inBufferLength; *outBufferLength = 0; - if (theora_decode_packetin(&ctx->td, &op)<0) return GF_NON_COMPLIANT_BITSTREAM; + if (theora_decode_packetin(&ctx->td, &op)<0) return GF_NON_COMPLIANT_BITSTREAM; if (mmlevel == GF_CODEC_LEVEL_SEEK) return GF_OK; - if (theora_decode_YUVout(&ctx->td, &yuv)<0) return GF_OK; + if (theora_decode_YUVout(&ctx->td, &yuv)<0) return GF_OK; pYO = yuv.y; pUO = yuv.u; @@ -184,7 +184,7 @@ static GF_Err THEO_ProcessData(GF_MediaDecoder *ifcg, pYD = outBuffer; pUD = outBuffer + ctx->ti.width * ctx->ti.height; pVD = outBuffer + 5 * ctx->ti.width * ctx->ti.height / 4; - + for (i=0; i<(u32)yuv.y_height; i++) { memcpy(pYD, pYO, sizeof(char) * yuv.y_width); pYD += ctx->ti.width; @@ -215,7 +215,7 @@ u32 NewTheoraDecoder(GF_BaseDecoder *ifcd) GF_SAFEALLOC(dec, TheoraDec); ((OGGWraper *)ifcd->privateStack)->opaque = dec; ((OGGWraper *)ifcd->privateStack)->type = OGG_THEORA; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = THEO_AttachStream; ifcd->DetachStream = THEO_DetachStream; ifcd->GetCapabilities = THEO_GetCapabilities; diff --git a/modules/ogg/vorbis_dec.c b/modules/ogg/vorbis_dec.c index d4c7173..49692f3 100644 --- a/modules/ogg/vorbis_dec.c +++ b/modules/ogg/vorbis_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -32,11 +32,11 @@ typedef struct { - vorbis_info vi; + vorbis_info vi; vorbis_dsp_state vd; vorbis_block vb; - vorbis_comment vc; - ogg_packet op; + vorbis_comment vc; + ogg_packet op; u16 ES_ID; Bool has_reconfigured; @@ -46,7 +46,7 @@ typedef struct static GF_Err VORB_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) { - ogg_packet oggpacket; + ogg_packet oggpacket; GF_BitStream *bs; VORBISCTX(); @@ -58,8 +58,8 @@ static GF_Err VORB_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) ctx->ES_ID = esd->ESID; - vorbis_info_init(&ctx->vi); - vorbis_comment_init(&ctx->vc); + vorbis_info_init(&ctx->vi); + vorbis_comment_init(&ctx->vc); oggpacket.granulepos = -1; oggpacket.b_o_s = 1; @@ -92,8 +92,8 @@ static GF_Err VORB_DetachStream(GF_BaseDecoder *ifcg, u16 ES_ID) vorbis_block_clear(&ctx->vb); vorbis_dsp_clear(&ctx->vd); - vorbis_info_clear(&ctx->vi); - vorbis_comment_clear(&ctx->vc); + vorbis_info_clear(&ctx->vi); + vorbis_comment_clear(&ctx->vc); ctx->ES_ID = 0; return GF_OK; @@ -134,7 +134,9 @@ static GF_Err VORB_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap break; case GF_CODEC_CHANNEL_CONFIG: switch (ctx->vi.channels) { - case 1: capability->cap.valueInt = GF_AUDIO_CH_FRONT_CENTER; break; + case 1: + capability->cap.valueInt = GF_AUDIO_CH_FRONT_CENTER; + break; case 2: capability->cap.valueInt = GF_AUDIO_CH_FRONT_LEFT | GF_AUDIO_CH_FRONT_RIGHT; break; @@ -173,7 +175,7 @@ static GFINLINE void vorbis_to_intern(u32 samples, Float **pcm, char *buf, u32 c ogg_int16_t *ptr, *data = (ogg_int16_t*)buf ; Float *mono; - for (i=0 ; i2) { /*center is third in gpac*/ @@ -195,18 +197,18 @@ static GFINLINE void vorbis_to_intern(u32 samples, Float **pcm, char *buf, u32 c *ptr = val; ptr += channels; } - } + } } static GF_Err VORB_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { ogg_packet op; - Float **pcm; - u32 samples, total_samples, total_bytes; + Float **pcm; + u32 samples, total_samples, total_bytes; VORBISCTX(); /*not using scalabilty*/ @@ -216,8 +218,8 @@ static GF_Err VORB_ProcessData(GF_MediaDecoder *ifcg, op.b_o_s = 0; op.e_o_s = 0; op.packetno = 0; - op.packet = inBuffer; - op.bytes = inBufferLength; + op.packet = inBuffer; + op.bytes = inBufferLength; *outBufferLength = 0; @@ -263,13 +265,13 @@ u32 NewVorbisDecoder(GF_BaseDecoder *ifcd) void DeleteVorbisDecoder(GF_BaseDecoder *ifcg) { VorbDec *ctx; - if (!ifcg || !ifcg->privateStack) - return; - ctx = (VorbDec *) ((OGGWraper *)ifcg->privateStack)->opaque; - if (ctx){ - gf_free(ctx); - ((OGGWraper *)ifcg->privateStack)->opaque = NULL; - } + if (!ifcg || !ifcg->privateStack) + return; + ctx = (VorbDec *) ((OGGWraper *)ifcg->privateStack)->opaque; + if (ctx) { + gf_free(ctx); + ((OGGWraper *)ifcg->privateStack)->opaque = NULL; + } } #endif diff --git a/modules/opencv_is/opencv_is.c b/modules/opencv_is/opencv_is.c index 1bbfa8a..30b2e7d 100644 --- a/modules/opencv_is/opencv_is.c +++ b/modules/opencv_is/opencv_is.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,55 +54,55 @@ static Bool OCV_RegisterDevice(struct __input_device *ifce, const char *urn, GF_ CvHaarClassifierCascade* load_object_detector( const char* cascade_path ) { - return (CvHaarClassifierCascade*)cvLoad( cascade_path, NULL, NULL, NULL ); + return (CvHaarClassifierCascade*)cvLoad( cascade_path, NULL, NULL, NULL ); } int prev_x0=0, prev_y0=0; void detect_and_draw_objects(GF_InputSensorDevice *ifce, IplImage* image, - CvHaarClassifierCascade* cascade, - int do_pyramids ) + CvHaarClassifierCascade* cascade, + int do_pyramids ) { - IplImage* small_image = image; - CvMemStorage* storage = cvCreateMemStorage(0); - CvSeq* faces; - int i, scale = 1; - //CvRect* theRealFace; - int theRealX=0, theRealY=0, theRealHeight=0 , theRealWidth=0; - - int tmpMaxSurface=0; - - - if( do_pyramids ) - { - small_image = cvCreateImage( cvSize(image->width/2,image->height/2), IPL_DEPTH_8U, 3 ); - cvPyrDown( image, small_image, CV_GAUSSIAN_5x5 ); - scale = 2; - } - - faces = cvHaarDetectObjects( small_image, cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(0,0) ); - - for( i = 0; i < faces->total; i++ ) - { - - CvRect face_rect = *(CvRect*)cvGetSeqElem( faces, i ); - /* cvRectangle( image, cvPoint(face_rect.x*scale,face_rect.y*scale), - cvPoint((face_rect.x+face_rect.width)*scale, - (face_rect.y+face_rect.height)*scale), - CV_RGB(0,255,0), 3 );*/ - if(face_rect.width*face_rect.height>tmpMaxSurface){ - theRealX=face_rect.x; - theRealY=face_rect.y; - theRealHeight=face_rect.height; - theRealWidth=face_rect.width; - tmpMaxSurface=face_rect.width*face_rect.height; - } - - } - cvRectangle( image, cvPoint(theRealX*scale,theRealY*scale), - cvPoint((theRealX+theRealWidth)*scale, - (theRealY+theRealHeight)*scale), - CV_RGB(0,255,0), 3, 8, 0 ); + IplImage* small_image = image; + CvMemStorage* storage = cvCreateMemStorage(0); + CvSeq* faces; + int i, scale = 1; + //CvRect* theRealFace; + int theRealX=0, theRealY=0, theRealHeight=0 , theRealWidth=0; + + int tmpMaxSurface=0; + + + if( do_pyramids ) + { + small_image = cvCreateImage( cvSize(image->width/2,image->height/2), IPL_DEPTH_8U, 3 ); + cvPyrDown( image, small_image, CV_GAUSSIAN_5x5 ); + scale = 2; + } + + faces = cvHaarDetectObjects( small_image, cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(0,0) ); + + for( i = 0; i < faces->total; i++ ) + { + + CvRect face_rect = *(CvRect*)cvGetSeqElem( faces, i ); + /* cvRectangle( image, cvPoint(face_rect.x*scale,face_rect.y*scale), + cvPoint((face_rect.x+face_rect.width)*scale, + (face_rect.y+face_rect.height)*scale), + CV_RGB(0,255,0), 3 );*/ + if(face_rect.width*face_rect.height>tmpMaxSurface) { + theRealX=face_rect.x; + theRealY=face_rect.y; + theRealHeight=face_rect.height; + theRealWidth=face_rect.width; + tmpMaxSurface=face_rect.width*face_rect.height; + } + + } + cvRectangle( image, cvPoint(theRealX*scale,theRealY*scale), + cvPoint((theRealX+theRealWidth)*scale, + (theRealY+theRealHeight)*scale), + CV_RGB(0,255,0), 3, 8, 0 ); GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[OpenCV] translation selon X : %d - translation selon Y : %d\n", (theRealX - prev_x0), (theRealY -prev_y0) )); @@ -111,7 +111,7 @@ void detect_and_draw_objects(GF_InputSensorDevice *ifce, IplImage* image, char *buf; u32 buf_size; GF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - gf_bs_write_int(bs, 1, 1); + gf_bs_write_int(bs, 1, 1); gf_bs_write_float(bs, (Float) (theRealX - 640/2) ); gf_bs_write_float(bs, (Float) (480/2 - theRealY) ); @@ -125,42 +125,42 @@ void detect_and_draw_objects(GF_InputSensorDevice *ifce, IplImage* image, prev_x0=theRealX; prev_y0=theRealY; - + if( small_image != image ) - cvReleaseImage( &small_image ); - + cvReleaseImage( &small_image ); + cvReleaseMemStorage( &storage ); } static u32 OCV_Run(void *par) { - IplImage* image; - CvCapture *capture; + IplImage* image; + CvCapture *capture; GF_InputSensorDevice *ifce = (GF_InputSensorDevice *)par; GF_OpenCV *ocv = (GF_OpenCV *)ifce->udta; - capture= cvCaptureFromCAM(0); - cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,640 ); - cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 ); + capture= cvCaptureFromCAM(0); + cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,640 ); + cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 ); - cvNamedWindow( "test", 0 ); + cvNamedWindow( "test", 0 ); - image = NULL; - while (ocv->running) { + image = NULL; + while (ocv->running) { if (cvGrabFrame(capture)) { - CvHaarClassifierCascade* cascade; - + CvHaarClassifierCascade* cascade; + image = cvRetrieveFrame(capture); - + cascade = load_object_detector("haarcascade_frontalface_default.xml"); detect_and_draw_objects(ifce, image, cascade, 1 ); - + cvShowImage( "test", image ); cvWaitKey(40); } } - if (image) cvReleaseImage( &image); + if (image) cvReleaseImage( &image); return 0; } @@ -179,7 +179,7 @@ static void OCV_Stop(struct __input_device *ifce) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_INPUT_DEVICE_INTERFACE, diff --git a/modules/openhevc_dec/openhevc_dec.c b/modules/openhevc_dec/openhevc_dec.c index 1b73018..bf9f2f1 100644 --- a/modules/openhevc_dec/openhevc_dec.c +++ b/modules/openhevc_dec/openhevc_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,13 +58,16 @@ typedef struct GF_ESD *esd; OpenHevc_Handle openHevcHandle; - u32 nb_layers; + u32 nb_layers; u32 output_cb_size; u32 display_bpp; Bool conv_to_8bit; char *conv_buffer; + u32 frame_idx; + Bool pack_mode; + } HEVCDec; static GF_Err HEVC_ConfigurationScalableStream(HEVCDec *ctx, GF_ESD *esd) @@ -78,13 +81,13 @@ static GF_Err HEVC_ConfigurationScalableStream(HEVCDec *ctx, GF_ESD *esd) if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return GF_OK; cfg = gf_odf_hevc_cfg_read(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 0); - if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; - if (ctx->nalu_size_length != cfg->nal_unit_size) + if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; + if (ctx->nalu_size_length != cfg->nal_unit_size) return GF_NON_COMPLIANT_BITSTREAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - for (i=0; i< gf_list_count(cfg->param_array); i++) { - GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(cfg->param_array, i); + for (i=0; i< gf_list_count(cfg->param_array); i++) { + GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(cfg->param_array, i); for (j=0; j< gf_list_count(ar->nalus); j++) { GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(ar->nalus, j); gf_bs_write_int(bs, sl->size, 8*ctx->nalu_size_length); @@ -99,33 +102,34 @@ static GF_Err HEVC_ConfigurationScalableStream(HEVCDec *ctx, GF_ESD *esd) libOpenHevcSetActiveDecoders(ctx->openHevcHandle, 2); libOpenHevcSetViewLayers(ctx->openHevcHandle, 1); + return GF_OK; } static GF_Err HEVC_ConfigureStream(HEVCDec *ctx, GF_ESD *esd) { u32 i, j; - GF_HEVCConfig *cfg = NULL; + GF_HEVCConfig *cfg = NULL; ctx->ES_ID = esd->ESID; ctx->width = ctx->height = ctx->out_size = ctx->luma_bpp = ctx->chroma_bpp = 0; - - ctx->nb_layers = 1; - + + ctx->nb_layers = 1; + if (esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data) { HEVCState hevc; - memset(&hevc, 0, sizeof(HEVCState)); + memset(&hevc, 0, sizeof(HEVCState)); cfg = gf_odf_hevc_cfg_read(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 0); - if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; - ctx->nalu_size_length = cfg->nal_unit_size; + if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; + ctx->nalu_size_length = cfg->nal_unit_size; - for (i=0; i< gf_list_count(cfg->param_array); i++) { - GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(cfg->param_array, i); + for (i=0; i< gf_list_count(cfg->param_array); i++) { + GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(cfg->param_array, i); for (j=0; j< gf_list_count(ar->nalus); j++) { GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(ar->nalus, j); s32 idx; - u16 hdr = sl->data[0] << 8 | sl->data[1]; - + u16 hdr = sl->data[0] << 8 | sl->data[1]; + if (ar->type==GF_HEVC_NALU_SEQ_PARAM) { idx = gf_media_hevc_read_sps(sl->data, sl->size, &hevc); ctx->width = MAX(hevc.sps[idx].width, ctx->width); @@ -150,10 +154,10 @@ static GF_Err HEVC_ConfigureStream(HEVCDec *ctx, GF_ESD *esd) ctx->nalu_size_length = 0; } - ctx->openHevcHandle = libOpenHevcInit(ctx->nb_threads, ctx->threading_type); + ctx->openHevcHandle = libOpenHevcInit(ctx->nb_threads, ctx->threading_type); #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_CODEC, GF_LOG_DEBUG) ) { + if (gf_log_tool_level_on(GF_LOG_CODEC, GF_LOG_DEBUG) ) { libOpenHevcSetDebugMode(ctx->openHevcHandle, 1); } #endif @@ -170,9 +174,9 @@ static GF_Err HEVC_ConfigureStream(HEVCDec *ctx, GF_ESD *esd) libOpenHevcSetViewLayers(ctx->openHevcHandle, 0/*ctx->nb_layers-1*/); } - libOpenHevcStartDecoder(ctx->openHevcHandle); + libOpenHevcStartDecoder(ctx->openHevcHandle); + - ctx->stride = ((ctx->luma_bpp==8) && (ctx->chroma_bpp==8)) ? ctx->width : ctx->width * 2; ctx->out_size = ctx->stride * ctx->height * 3 / 2; @@ -181,7 +185,9 @@ static GF_Err HEVC_ConfigureStream(HEVCDec *ctx, GF_ESD *esd) ctx->out_size /= 2; ctx->chroma_bpp = ctx->luma_bpp = 8; ctx->conv_to_8bit = 1; + ctx->pack_mode = 0; } + return GF_OK; } @@ -226,6 +232,9 @@ static GF_Err HEVC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) if (sOpt) ctx->output_cb_size = atoi(sOpt); if (!ctx->output_cb_size) ctx->output_cb_size = 4; + sOpt = gf_modules_get_option((GF_BaseInterface *)ifcg, "OpenHEVC", "PackHFR"); + if (sOpt && !strcmp(sOpt, "yes") ) ctx->pack_mode = 1; + else if (!sOpt) gf_modules_set_option((GF_BaseInterface *)ifcg, "OpenHEVC", "PackHFR", "no"); /*RTP case: configure enhancement now*/ @@ -264,18 +273,21 @@ static GF_Err HEVC_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap break; case GF_CODEC_WIDTH: capability->cap.valueInt = ctx->width; + if (ctx->pack_mode) { + capability->cap.valueInt *= 2; + } break; case GF_CODEC_HEIGHT: capability->cap.valueInt = ctx->height; + if (ctx->pack_mode) { + capability->cap.valueInt *= 2; + } break; case GF_CODEC_STRIDE: capability->cap.valueInt = ctx->stride; - if (ctx->direct_output && !ctx->conv_buffer) { - //to fix soon - currently hardcoded to 32 pixels - if ((ctx->luma_bpp==8) && (ctx->chroma_bpp==8)) - capability->cap.valueInt += 32; - else - capability->cap.valueInt += 64; + + if (ctx->pack_mode) { + capability->cap.valueInt *= 2; } break; case GF_CODEC_PAR: @@ -283,6 +295,9 @@ static GF_Err HEVC_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap break; case GF_CODEC_OUTPUT_SIZE: capability->cap.valueInt = ctx->out_size; + if (ctx->pack_mode) { + capability->cap.valueInt *= 4; + } break; case GF_CODEC_PIXEL_FORMAT: capability->cap.valueInt = (ctx->luma_bpp==10) ? GF_PIXEL_YV12_10 : GF_PIXEL_YV12; @@ -323,23 +338,26 @@ static GF_Err HEVC_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa case GF_CODEC_DISPLAY_BPP: ctx->display_bpp = capability.cap.valueInt; return GF_OK; - case GF_CODEC_WAIT_RAP: + case GF_CODEC_WAIT_RAP: if (ctx->openHevcHandle) - libOpenHevcFlush(ctx->openHevcHandle); - return GF_OK; + libOpenHevcFlush(ctx->openHevcHandle); + return GF_OK; case GF_CODEC_MEDIA_SWITCH_QUALITY: /*switch up*/ - if (capability.cap.valueInt > 0) { - libOpenHevcSetViewLayers(ctx->openHevcHandle, 1); + if (capability.cap.valueInt > 0) { + libOpenHevcSetViewLayers(ctx->openHevcHandle, 1); + libOpenHevcSetActiveDecoders(ctx->openHevcHandle, 1); } else { - libOpenHevcSetViewLayers(ctx->openHevcHandle, 0); + libOpenHevcSetViewLayers(ctx->openHevcHandle, 0); + libOpenHevcSetActiveDecoders(ctx->openHevcHandle, 0); } return GF_OK; case GF_CODEC_DIRECT_OUTPUT: ctx->direct_output = GF_TRUE; + ctx->pack_mode = 0; if (ctx->conv_to_8bit && ctx->out_size) ctx->conv_buffer = gf_realloc(ctx->conv_buffer, sizeof(char)*ctx->out_size); - + return GF_OK; } /*return unsupported to avoid confusion by the player (like color space changing ...) */ @@ -350,29 +368,34 @@ static GF_Err HEVC_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa static GF_Err HEVC_flush_picture(HEVCDec *ctx, char *outBuffer, u32 *outBufferLength, u32 *CTS) { unsigned int a_w, a_h, a_stride, bit_depth; - OpenHevc_Frame_cpy openHevcFrame; - - libOpenHevcGetPictureInfo(ctx->openHevcHandle, &openHevcFrame.frameInfo); + OpenHevc_Frame_cpy openHevcFrame; + if (ctx->direct_output) + libOpenHevcGetPictureInfo(ctx->openHevcHandle, &openHevcFrame.frameInfo); + else + libOpenHevcGetPictureInfoCpy(ctx->openHevcHandle, &openHevcFrame.frameInfo); a_w = openHevcFrame.frameInfo.nWidth; - a_h = openHevcFrame.frameInfo.nHeight; - a_stride = openHevcFrame.frameInfo.nYPitch; + a_h = openHevcFrame.frameInfo.nHeight; + a_stride = openHevcFrame.frameInfo.nYPitch; bit_depth = openHevcFrame.frameInfo.nBitDepth; - + *CTS = (u32) openHevcFrame.frameInfo.nTimeStamp; if (!ctx->output_as_8bit) { - if ((ctx->luma_bpp>8) || (ctx->chroma_bpp>8)) a_stride *= 2; + if ((ctx->luma_bpp>8) || (ctx->chroma_bpp>8)) { + ctx->pack_mode = 0; + } } else { if (bit_depth>8) { bit_depth=8; - ctx->conv_to_8bit = 1; + a_stride /= 2; + ctx->pack_mode = 0; } } - if ((ctx->width != a_w) || (ctx->height!=a_h) || (ctx->stride != a_stride) || (ctx->luma_bpp!= bit_depth) || (ctx->chroma_bpp != bit_depth) ){ + if ((ctx->width != a_w) || (ctx->height!=a_h) || (ctx->stride != a_stride) || (ctx->luma_bpp!= bit_depth) || (ctx->chroma_bpp != bit_depth) ) { ctx->width = a_w; ctx->stride = a_stride; ctx->height = a_h; @@ -402,12 +425,55 @@ static GF_Err HEVC_flush_picture(HEVCDec *ctx, char *outBuffer, u32 *outBufferLe dst.video_buffer = ctx->direct_output ? ctx->conv_buffer : outBuffer; dst.pixel_format = GF_PIXEL_YV12; - gf_color_write_yv12_10_to_yuv(&dst, (u8 *) openHevcFramePtr.pvY, (u8 *) openHevcFramePtr.pvU, (u8 *) openHevcFramePtr.pvV, (openHevcFramePtr.frameInfo.nYPitch + 32)*2, ctx->width, ctx->height, NULL); - *outBufferLength = ctx->out_size; - - if (ctx->direct_output ) + gf_color_write_yv12_10_to_yuv(&dst, (u8 *) openHevcFramePtr.pvY, (u8 *) openHevcFramePtr.pvU, (u8 *) openHevcFramePtr.pvV, openHevcFramePtr.frameInfo.nYPitch, ctx->width, ctx->height, NULL); + *outBufferLength = ctx->out_size; + + if (ctx->direct_output ) ctx->has_pic = GF_TRUE; } + } else if (ctx->pack_mode) { + OpenHevc_Frame openHFrame; + u8 *pY, *pU, *pV; + + u32 idx_w, idx_h; + idx_w = ((ctx->frame_idx==0) || (ctx->frame_idx==2)) ? 0 : ctx->width; + idx_h = ((ctx->frame_idx==0) || (ctx->frame_idx==1)) ? 0 : ctx->height*2*ctx->stride; + + pY = (void*) ( outBuffer + idx_h + idx_w ); + pU = (void*) (outBuffer + 2*ctx->stride*2*ctx->height + idx_w/2 + idx_h/4); + pV = (void*) (outBuffer + 2*ctx->stride*2*ctx->height + ctx->stride*ctx->height + idx_w/2 + idx_h/4); + + + *outBufferLength = 0; + if (libOpenHevcGetOutput(ctx->openHevcHandle, 1, &openHFrame)) { + u32 i, s_stride, qs_stride, d_stride, dd_stride, hd_stride; + + s_stride = openHFrame.frameInfo.nYPitch; + qs_stride = s_stride / 4; + + d_stride = ctx->stride; + dd_stride = 2*ctx->stride; + hd_stride = ctx->stride/2; + + for (i=0; iheight; i++) { + memcpy(pY, (u8 *) openHFrame.pvY + i*s_stride, d_stride); + pY += dd_stride; + + if (! (i%2) ) { + memcpy(pU, (u8 *) openHFrame.pvU + i*qs_stride, hd_stride); + pU += d_stride; + + memcpy(pV, (u8 *) openHFrame.pvV + i*qs_stride, hd_stride); + pV += d_stride; + } + } + + ctx->frame_idx++; + if (ctx->frame_idx==4) { + *outBufferLength = 4 * ctx->out_size; + ctx->frame_idx = 0; + } + } } else { openHevcFrame.pvY = (void*) outBuffer; openHevcFrame.pvU = (void*) (outBuffer + ctx->stride * ctx->height); @@ -418,15 +484,15 @@ static GF_Err HEVC_flush_picture(HEVCDec *ctx, char *outBuffer, u32 *outBufferLe } } } - return GF_OK; + return GF_OK; } -static GF_Err HEVC_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err HEVC_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { GF_Err e; int got_pic; @@ -436,7 +502,14 @@ static GF_Err HEVC_ProcessData(GF_MediaDecoder *ifcg, if ( libOpenHevcDecode(ctx->openHevcHandle, NULL, 0, 0) ) { return HEVC_flush_picture(ctx, outBuffer, outBufferLength, CTS); } - return GF_OK; + //quick hack, we have an issue with openHEVC resuming after being flushed ... + ctx->had_pic = 0; + libOpenHevcClose(ctx->openHevcHandle); + ctx->openHevcHandle = NULL; + ctx->is_init = GF_FALSE; + HEVC_ConfigureStream(ctx, ctx->esd); + + return GF_OK; } if (!ES_ID) { @@ -470,7 +543,7 @@ static GF_Err HEVC_ProcessData(GF_MediaDecoder *ifcg, static GF_Err HEVC_GetOutputBuffer(GF_MediaDecoder *ifcg, u16 ESID, u8 **pY_or_RGB, u8 **pU, u8 **pV) { s32 res; - OpenHevc_Frame openHevcFrame; + OpenHevc_Frame openHevcFrame; HEVCDec *ctx = (HEVCDec*) ifcg->privateStack; if (!ctx->has_pic) return GF_BAD_PARAM; ctx->has_pic = GF_FALSE; @@ -519,14 +592,14 @@ GF_BaseDecoder *NewHEVCDec() { GF_MediaDecoder *ifcd; HEVCDec *dec; - + GF_SAFEALLOC(ifcd, GF_MediaDecoder); GF_SAFEALLOC(dec, HEVCDec); GF_REGISTER_MODULE_INTERFACE(ifcd, GF_MEDIA_DECODER_INTERFACE, "HEVC Decoder", "gpac distribution") ifcd->privateStack = dec; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = HEVC_AttachStream; ifcd->DetachStream = HEVC_DetachStream; ifcd->GetCapabilities = HEVC_GetCapabilities; @@ -546,7 +619,7 @@ void DeleteHEVCDec(GF_BaseDecoder *ifcg) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS @@ -554,11 +627,11 @@ const u32 *QueryInterfaces() #endif 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *)NewHEVCDec(); @@ -571,7 +644,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS - case GF_MEDIA_DECODER_INTERFACE: + case GF_MEDIA_DECODER_INTERFACE: DeleteHEVCDec((GF_BaseDecoder*)ifce); break; #endif diff --git a/modules/opensvc_dec/opensvc_dec.c b/modules/opensvc_dec/opensvc_dec.c index 742b0a0..95e545c 100644 --- a/modules/opensvc_dec/opensvc_dec.c +++ b/modules/opensvc_dec/opensvc_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -51,8 +51,8 @@ typedef struct int CurrentDqId; int MaxDqId; int DqIdTable[8]; - int TemporalId; - int TemporalCom; + int TemporalId; + int TemporalCom; } OSVCDec; static GF_Err OSVC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) @@ -63,10 +63,10 @@ static GF_Err OSVC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) int Layer[4]; OSVCDec *ctx = (OSVCDec*) ifcg->privateStack; - /*todo: we should check base layer of this stream is indeed our base layer*/ + /*todo: we should check base layer of this stream is indeed our base layer*/ if (!ctx->ES_ID) { ctx->ES_ID = esd->ESID; - ctx->width = ctx->height = ctx->out_size = 0; + ctx->width = ctx->height = ctx->out_size = 0; if (!esd->dependsOnESID) ctx->baseES_ID = esd->ESID; } @@ -80,10 +80,10 @@ static GF_Err OSVC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) /*decode all NALUs*/ count = gf_list_count(cfg->sequenceParameterSets); - SetCommandLayer(Layer, 255, 0, &res, 0);//bufindex can be reset without pb + SetCommandLayer(Layer, 255, 0, &res, 0);//bufindex can be reset without pb for (i=0; isequenceParameterSets, i); #ifndef GPAC_DISABLE_AV_PARSERS @@ -210,16 +210,16 @@ static GF_Err OSVC_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa } -static GF_Err OSVC_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err OSVC_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { s32 got_pic; OPENSVCFRAME pic; - int Layer[4]; + int Layer[4]; u32 i, nalu_size, sc_size; u8 *ptr; OSVCDec *ctx = (OSVCDec*) ifcg->privateStack; @@ -236,10 +236,10 @@ static GF_Err OSVC_ProcessData(GF_MediaDecoder *ifcg, ctx->MaxDqId = GetDqIdMax((unsigned char *) inBuffer, inBufferLength, ctx->nalu_size_length, ctx->DqIdTable, ctx->nalu_size_length ? 1 : 0); if (!ctx->init_layer_set) { - //AVC stream in a h264 file - if (ctx->MaxDqId == -1) + //AVC stream in a h264 file + if (ctx->MaxDqId == -1) ctx->MaxDqId = 0; - + ctx->CurrentDqId = ctx->MaxDqId; ctx->init_layer_set = 1; } @@ -279,23 +279,23 @@ static GF_Err OSVC_ProcessData(GF_MediaDecoder *ifcg, } #ifndef GPAC_DISABLE_LOG switch (ptr[0] & 0x1F) { - case GF_AVC_NALU_SEQ_PARAM: - case GF_AVC_NALU_SVC_SUBSEQ_PARAM: - { - u32 sps_id; - gf_avc_get_sps_info((char *)ptr, nalu_size, &sps_id, NULL, NULL, NULL, NULL); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: SPS id=\"%d\" code=\"%d\" size=\"%d\"\n", ES_ID, sps_id, ptr[0] & 0x1F, nalu_size)); - } - break; - case GF_AVC_NALU_PIC_PARAM: - { - u32 sps_id, pps_id; - gf_avc_get_pps_info((char *)ptr, nalu_size, &pps_id, &sps_id); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: PPS id=\"%d\" code=\"%d\" size=\"%d\" sps_id=\"%d\"\n", ES_ID, pps_id, ptr[0] & 0x1F, nalu_size, sps_id)); - } - break; - default: - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: NALU code=\"%d\" size=\"%d\"\n", ES_ID, ptr[0] & 0x1F, nalu_size)); + case GF_AVC_NALU_SEQ_PARAM: + case GF_AVC_NALU_SVC_SUBSEQ_PARAM: + { + u32 sps_id; + gf_avc_get_sps_info((char *)ptr, nalu_size, &sps_id, NULL, NULL, NULL, NULL); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: SPS id=\"%d\" code=\"%d\" size=\"%d\"\n", ES_ID, sps_id, ptr[0] & 0x1F, nalu_size)); + } + break; + case GF_AVC_NALU_PIC_PARAM: + { + u32 sps_id, pps_id; + gf_avc_get_pps_info((char *)ptr, nalu_size, &pps_id, &sps_id); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: PPS id=\"%d\" code=\"%d\" size=\"%d\" sps_id=\"%d\"\n", ES_ID, pps_id, ptr[0] & 0x1F, nalu_size, sps_id)); + } + break; + default: + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[SVC Decoder] ES%d: NALU code=\"%d\" size=\"%d\"\n", ES_ID, ptr[0] & 0x1F, nalu_size)); } #endif if (!ctx->state_found) { @@ -310,7 +310,7 @@ static GF_Err OSVC_ProcessData(GF_MediaDecoder *ifcg, } if (ctx->state_found) { - if (!got_pic) + if (!got_pic) got_pic = decodeNAL(ctx->codec, ptr, nalu_size, &pic, Layer); else decodeNAL(ctx->codec, ptr, nalu_size, &pic, Layer); @@ -397,14 +397,14 @@ GF_BaseDecoder *NewOSVCDec() { GF_MediaDecoder *ifcd; OSVCDec *dec; - + GF_SAFEALLOC(ifcd, GF_MediaDecoder); GF_SAFEALLOC(dec, OSVCDec); GF_REGISTER_MODULE_INTERFACE(ifcd, GF_MEDIA_DECODER_INTERFACE, "OpenSVC Decoder", "gpac distribution") ifcd->privateStack = dec; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = OSVC_AttachStream; ifcd->DetachStream = OSVC_DetachStream; ifcd->GetCapabilities = OSVC_GetCapabilities; @@ -423,7 +423,7 @@ void DeleteOSVCDec(GF_BaseDecoder *ifcg) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS @@ -431,11 +431,11 @@ const u32 *QueryInterfaces() #endif 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *)NewOSVCDec(); @@ -448,7 +448,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS - case GF_MEDIA_DECODER_INTERFACE: + case GF_MEDIA_DECODER_INTERFACE: DeleteOSVCDec((GF_BaseDecoder*)ifce); break; #endif diff --git a/modules/osd/osd.c b/modules/osd/osd.c index a2fcffa..619b620 100644 --- a/modules/osd/osd.c +++ b/modules/osd/osd.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2011-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -152,7 +152,7 @@ Bool osd_load_scene(GF_OSD *osd) gf_list_del(nodes); if (!n) return 0; - + gf_sg_set_root_node(osd->odm->subscene->graph, n); gf_sg_set_scene_size_info(osd->odm->subscene->graph, 0, 0, 1); @@ -274,17 +274,17 @@ void osd_delete(GF_BaseInterface *ifce) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_TERM_EXT_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_TERM_EXT_INTERFACE) return (GF_BaseInterface *)osd_new(); return NULL; diff --git a/modules/oss_audio/oss.c b/modules/oss_audio/oss.c index b57962a..2f68b62 100644 --- a/modules/oss_audio/oss.c +++ b/modules/oss_audio/oss.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -51,7 +51,7 @@ #define OSS_AUDIO_DEVICE "/dev/dsp" -typedef struct +typedef struct { int audio_dev, sr, nb_ch; u32 buf_size, delay, num_buffers, total_duration; @@ -75,8 +75,8 @@ static GF_Err OSS_Setup(GF_AudioOutput*dr, void *os_handle, u32 num_buffers, u32 /*open OSS in non-blocking mode*/ audio = open(OSS_AUDIO_DEVICE, 0); if (audio < 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[OSS] Cannot open audio device\n")); - return GF_NOT_SUPPORTED; + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[OSS] Cannot open audio device\n")); + return GF_NOT_SUPPORTED; } /*set blocking mode back*/ @@ -112,7 +112,7 @@ static GF_Err OSS_ConfigureOutput(GF_AudioOutput*dr, u32 *SampleRate, u32 *NbCha ctx->audio_dev=open(OSS_AUDIO_DEVICE,O_WRONLY|O_NONBLOCK); if (!ctx->audio_dev) return GF_IO_ERR; - /* Make the file descriptor use blocking writes with fcntl() so that + /* Make the file descriptor use blocking writes with fcntl() so that we don't have to handle sleep() ourselves*/ flags = fcntl(ctx->audio_dev, F_GETFL); flags &= ~O_NONBLOCK; @@ -123,26 +123,26 @@ static GF_Err OSS_ConfigureOutput(GF_AudioOutput*dr, u32 *SampleRate, u32 *NbCha blockalign = ctx->nb_ch; if ((*nbBitsPerSample) == 16) { - blockalign *= 2; - format = AFMT_S16_LE; + blockalign *= 2; + format = AFMT_S16_LE; } else { - format = AFMT_S8; + format = AFMT_S8; } if(ioctl(ctx->audio_dev, SNDCTL_DSP_SETFMT,&format)==-1) return GF_IO_ERR; - ctx->sr = (*SampleRate); + ctx->sr = (*SampleRate); if(ioctl(ctx->audio_dev, SNDCTL_DSP_SPEED,&ctx->sr)==-1) return GF_IO_ERR; nb_bufs = ctx->num_buffers ? ctx->num_buffers : 8; ctx->buf_size = (*SampleRate * blockalign * ctx->total_duration) / (1000 * nb_bufs); frag_spec = 4; - while (ctx->buf_size > (1<<(frag_spec+1))) + while (ctx->buf_size > (1<<(frag_spec+1))) frag_spec++; ctx->buf_size = 1<delay = (1000*ctx->buf_size) / (*SampleRate * blockalign); frag_spec = ((nb_bufs<<16) & 0xFFFF0000) | frag_spec; - + ctx->delay = (1000*ctx->buf_size*nb_bufs) / (*SampleRate * blockalign); if ( ioctl(ctx->audio_dev, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0 ) return GF_IO_ERR; @@ -159,10 +159,10 @@ static void OSS_WriteAudio(GF_AudioOutput*dr) OSSCTX(); written = dr->FillBuffer(dr->audio_renderer, ctx->wav_buf, ctx->buf_size); /*this will also perform sleep*/ - if (written){ + if (written) { u32 reallyWritten = write(ctx->audio_dev, ctx->wav_buf, written); - if (reallyWritten != written){ - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[OSS] Failed to write all audio to device, has written %u, should have %u", reallyWritten, written)); + if (reallyWritten != written) { + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[OSS] Failed to write all audio to device, has written %u, should have %u", reallyWritten, written)); } } } @@ -172,8 +172,8 @@ static void OSS_SetPan(GF_AudioOutput*dr, u32 Pan) {} static void OSS_SetPriority(GF_AudioOutput*dr, u32 Priority) {} static u32 OSS_GetAudioDelay(GF_AudioOutput*dr) { - OSSCTX() - return ctx->delay; + OSSCTX() + return ctx->delay; } /* @@ -186,18 +186,18 @@ static u32 OSS_GetAudioDelay(GF_AudioOutput*dr) static GF_Err OSS_QueryOutputSampleRate(GF_AudioOutput*dr, u32 *desired_sr, u32 *NbChannels, u32 *nbBitsPerSample) { #ifdef FORCE_SR_LIMIT - *NbChannels = 2; - if (!( *desired_sr % 11025)) return GF_OK; - if (*desired_sr<22050) *desired_sr = 22050; - else *desired_sr = 44100; - return GF_OK; + *NbChannels = 2; + if (!( *desired_sr % 11025)) return GF_OK; + if (*desired_sr<22050) *desired_sr = 22050; + else *desired_sr = 44100; + return GF_OK; #else /* reset and reopen audio-device */ int i; OSSCTX(); if (ctx->force_sr) { - *desired_sr = ctx->force_sr; - return GF_OK; + *desired_sr = ctx->force_sr; + return GF_OK; } i=*desired_sr; if(ioctl(ctx->audio_dev, SNDCTL_DSP_SPEED,&i)==-1) return GF_IO_ERR; @@ -259,7 +259,7 @@ void DeleteOSSRender(void *ifce) * interface */ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_AUDIO_OUTPUT_INTERFACE, @@ -271,7 +271,7 @@ const u32 *QueryInterfaces() GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { - if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewOSSRender(); return NULL; } diff --git a/modules/platinum/GPACFileMediaServer.cpp b/modules/platinum/GPACFileMediaServer.cpp index 97816e2..5b81ba9 100644 --- a/modules/platinum/GPACFileMediaServer.cpp +++ b/modules/platinum/GPACFileMediaServer.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -43,9 +43,9 @@ NPT_SET_LOCAL_LOGGER("gpac.media.server.file") GPAC_FileMediaServer::GPAC_FileMediaServer(const char* friendly_name, - bool show_ip, - const char* uuid, - NPT_UInt16 port) : PLT_FileMediaServer("", friendly_name, show_ip, uuid, port) + bool show_ip, + const char* uuid, + NPT_UInt16 port) : PLT_FileMediaServer("", friendly_name, show_ip, uuid, port) { } @@ -53,8 +53,8 @@ void GPAC_FileMediaServer::AddSharedDirectory(const char *path, const char *alia { u8 buf[10]; if (!alias) { - sprintf((char*)buf, "%08X", gf_crc_32((char*) path, (u32) strlen(path))); - alias = (const char *)buf; + sprintf((char*)buf, "%08X", gf_crc_32((char*) path, (u32) strlen(path))); + alias = (const char *)buf; } m_Directories.Add(GPAC_MediaDirectory(alias, path, is_hidden)); } @@ -62,13 +62,13 @@ void GPAC_FileMediaServer::AddSharedDirectory(const char *path, const char *alia NPT_Result -GPAC_FileMediaServer::OnBrowseDirectChildren(PLT_ActionReference& action, - const char* object_id, - const char* filter, - NPT_UInt32 start_index, - NPT_UInt32 req_count, - const char* sort_criteria, - const PLT_HttpRequestContext& context) +GPAC_FileMediaServer::OnBrowseDirectChildren(PLT_ActionReference& action, + const char* object_id, + const char* filter, + NPT_UInt32 start_index, + NPT_UInt32 req_count, + const char* sort_criteria, + const PLT_HttpRequestContext& context) { /*not the root of our server*/ if (strcmp(object_id, "/") && strcmp(object_id, "\\") && strcmp(object_id, "0")) { @@ -76,61 +76,61 @@ GPAC_FileMediaServer::OnBrowseDirectChildren(PLT_ActionReference& actio } unsigned long cur_index = 0; - unsigned long num_returned = 0; - unsigned long total_matches = 0; - NPT_String didl = didl_header; + unsigned long num_returned = 0; + unsigned long total_matches = 0; + NPT_String didl = didl_header; - PLT_MediaObjectReference item; + PLT_MediaObjectReference item; for (u32 i=0; im_Hide) continue; - item = BuildFromFilePath(alias->m_Path, context, true, false); + item = BuildFromFilePath(alias->m_Path, context, true, false); - if (!item.IsNull()) { - if ((cur_index >= start_index) && ((num_returned < req_count) || (req_count == 0))) { - NPT_String tmp; - NPT_CHECK_SEVERE(PLT_Didl::ToDidl(*item.AsPointer(), filter, tmp)); + if (!item.IsNull()) { + if ((cur_index >= start_index) && ((num_returned < req_count) || (req_count == 0))) { + NPT_String tmp; + NPT_CHECK_SEVERE(PLT_Didl::ToDidl(*item.AsPointer(), filter, tmp)); - didl += tmp; - num_returned++; - } - cur_index++; - total_matches++; - } - }; + didl += tmp; + num_returned++; + } + cur_index++; + total_matches++; + } + }; - didl += didl_footer; + didl += didl_footer; - NPT_CHECK_SEVERE(action->SetArgumentValue("Result", didl)); - NPT_CHECK_SEVERE(action->SetArgumentValue("NumberReturned", NPT_String::FromInteger(num_returned))); - NPT_CHECK_SEVERE(action->SetArgumentValue("TotalMatches", NPT_String::FromInteger(total_matches))); // 0 means we don't know how many we have but most browsers don't like that!! - NPT_CHECK_SEVERE(action->SetArgumentValue("UpdateId", "1")); + NPT_CHECK_SEVERE(action->SetArgumentValue("Result", didl)); + NPT_CHECK_SEVERE(action->SetArgumentValue("NumberReturned", NPT_String::FromInteger(num_returned))); + NPT_CHECK_SEVERE(action->SetArgumentValue("TotalMatches", NPT_String::FromInteger(total_matches))); // 0 means we don't know how many we have but most browsers don't like that!! + NPT_CHECK_SEVERE(action->SetArgumentValue("UpdateId", "1")); - return NPT_SUCCESS; + return NPT_SUCCESS; } -NPT_Result -GPAC_FileMediaServer::ServeFile(NPT_HttpRequest& request, - const NPT_HttpRequestContext& context, - NPT_HttpResponse& response, - const NPT_String& _file_path) +NPT_Result +GPAC_FileMediaServer::ServeFile(NPT_HttpRequest& request, + const NPT_HttpRequestContext& context, + NPT_HttpResponse& response, + const NPT_String& _file_path) { - NPT_COMPILER_UNUSED(context); + NPT_COMPILER_UNUSED(context); NPT_String file_path = _file_path; - NPT_String uri_path = NPT_Uri::PercentDecode(request.GetUrl().GetPath()); + NPT_String uri_path = NPT_Uri::PercentDecode(request.GetUrl().GetPath()); NPT_String query = request.GetUrl().GetQuery(); if (! query.IsEmpty()) { uri_path += "?"; uri_path += query; } - // prevent hackers from accessing files outside of our root - if ((file_path.Find("/..") >= 0) || (file_path.Find("\\..") >= 0)) { - return NPT_FAILURE; - } + // prevent hackers from accessing files outside of our root + if ((file_path.Find("/..") >= 0) || (file_path.Find("\\..") >= 0)) { + return NPT_FAILURE; + } NPT_String file_id = (const char *) file_path + ((file_path[0]=='0') ? 2:1); for (u32 i=0; i 2 || object_id[0]!='0') { - filepath += (const char*)object_id + (object_id[0]=='0'?1:0); - } + if (NPT_StringLength(object_id) > 2 || object_id[0]!='0') { + filepath += (const char*)object_id + (object_id[0]=='0'?1:0); + } - return NPT_SUCCESS; + return NPT_SUCCESS; } PLT_MediaObject* -GPAC_FileMediaServer::BuildFromFilePath(const NPT_String& filepath, - const PLT_HttpRequestContext &context, - bool with_count, - bool keep_extension_in_title) +GPAC_FileMediaServer::BuildFromFilePath(const NPT_String& filepath, + const PLT_HttpRequestContext &context, + bool with_count, + bool keep_extension_in_title) { return BuildFromFilePathAndHost(filepath, &context, with_count, keep_extension_in_title, NULL); } PLT_MediaObject* -GPAC_FileMediaServer::BuildFromFilePathAndHost(const NPT_String& __filepath, - const PLT_HttpRequestContext *context, - bool with_count /* = true */, - bool keep_extension_in_title /* = false */, - const char *host) +GPAC_FileMediaServer::BuildFromFilePathAndHost(const NPT_String& __filepath, + const PLT_HttpRequestContext *context, + bool with_count /* = true */, + bool keep_extension_in_title /* = false */, + const char *host) { - PLT_MediaItemResource resource; - PLT_MediaObject* object = NULL; + PLT_MediaItemResource resource; + PLT_MediaObject* object = NULL; NPT_String filepath = __filepath; unsigned int len; - /* retrieve the entry type (directory or file) */ - NPT_FileInfo info; - NPT_CHECK_LABEL_FATAL(NPT_File::GetInfo(__filepath, &info), failure); + /* retrieve the entry type (directory or file) */ + NPT_FileInfo info; + NPT_CHECK_LABEL_FATAL(NPT_File::GetInfo(__filepath, &info), failure); len = 0; for (u32 i=0; im_Title = NPT_FilePath::BaseName(filepath, keep_extension_in_title); - if (object->m_Title.GetLength() == 0) goto failure; + /* Set the title using the filename for now */ + object->m_Title = NPT_FilePath::BaseName(filepath, keep_extension_in_title); + if (object->m_Title.GetLength() == 0) goto failure; - /* Set the protocol Info from the extension */ - resource.m_ProtocolInfo = PLT_ProtocolInfo(PLT_ProtocolInfo::GetProtocolInfo(filepath, true, context)); - if (!resource.m_ProtocolInfo.IsValid()) goto failure; + /* Set the protocol Info from the extension */ + resource.m_ProtocolInfo = PLT_ProtocolInfo(PLT_ProtocolInfo::GetProtocolInfo(filepath, true, context)); + if (!resource.m_ProtocolInfo.IsValid()) goto failure; - /* Set the resource file size */ - resource.m_Size = info.m_Size; - - /* format the resource URI */ - NPT_String url = "0" + filepath; + /* Set the resource file size */ + resource.m_Size = info.m_Size; + + /* format the resource URI */ + NPT_String url = "0" + filepath; if (host) { @@ -306,37 +306,37 @@ GPAC_FileMediaServer::BuildFromFilePathAndHost(const NPT_String& __filepa #if 0 /* Look to see if a metadatahandler exists for this extension */ - PLT_MetadataHandler* handler = NULL; - NPT_Result res = NPT_ContainerFind( - m_MetadataHandlers, - PLT_MetadataHandlerFinder(NPT_FilePath::FileExtension(filepath)), - handler); - if (NPT_SUCCEEDED(res) && handler) { - /* if it failed loading data, reset the metadatahandler so we don't use it */ - if (NPT_SUCCEEDED(handler->Load(filepath))) { - /* replace the title with the one from the Metadata */ - NPT_String newTitle; - if (handler->GetTitle(newTitle) != NULL) { - object->m_Title = newTitle; - } - - /* assign description */ - handler->GetDescription(object->m_Description.long_description); - - /* assign album art uri if we haven't yet */ - /* prepend the album art base URI and url encode it */ - if (object->m_ExtraInfo.album_art_uri.GetLength() == 0) { - object->m_ExtraInfo.album_art_uri = - NPT_Uri::PercentEncode(BuildResourceUri(m_AlbumArtBaseUri, ip.ToString(), url), - NPT_Uri::UnsafeCharsToEncode); - } - - /* duration */ - handler->GetDuration(resource.m_Duration); - - /* protection */ - handler->GetProtection(resource.m_Protection); - } + PLT_MetadataHandler* handler = NULL; + NPT_Result res = NPT_ContainerFind( + m_MetadataHandlers, + PLT_MetadataHandlerFinder(NPT_FilePath::FileExtension(filepath)), + handler); + if (NPT_SUCCEEDED(res) && handler) { + /* if it failed loading data, reset the metadatahandler so we don't use it */ + if (NPT_SUCCEEDED(handler->Load(filepath))) { + /* replace the title with the one from the Metadata */ + NPT_String newTitle; + if (handler->GetTitle(newTitle) != NULL) { + object->m_Title = newTitle; + } + + /* assign description */ + handler->GetDescription(object->m_Description.long_description); + + /* assign album art uri if we haven't yet */ + /* prepend the album art base URI and url encode it */ + if (object->m_ExtraInfo.album_art_uri.GetLength() == 0) { + object->m_ExtraInfo.album_art_uri = + NPT_Uri::PercentEncode(BuildResourceUri(m_AlbumArtBaseUri, ip.ToString(), url), + NPT_Uri::UnsafeCharsToEncode); + } + + /* duration */ + handler->GetDuration(resource.m_Duration); + + /* protection */ + handler->GetProtection(resource.m_Protection); + } } #endif object->m_ObjectClass.type = PLT_MediaItem::GetUPnPClass(filepath, context); @@ -346,53 +346,53 @@ GPAC_FileMediaServer::BuildFromFilePathAndHost(const NPT_String& __filepa object->m_Resources.Add(resource); } else { - object = new PLT_MediaContainer; + object = new PLT_MediaContainer; - /* Assign a title for this container */ - if ((filepath.Compare("/", true) == 0) || (filepath.Compare("\\", true) == 0)) { - object->m_Title = "Root"; - } else { + /* Assign a title for this container */ + if ((filepath.Compare("/", true) == 0) || (filepath.Compare("\\", true) == 0)) { + object->m_Title = "Root"; + } else { filepath.TrimRight("/\\"); - object->m_Title = NPT_FilePath::BaseName(filepath, keep_extension_in_title); - if (object->m_Title.GetLength() == 0) goto failure; - } + object->m_Title = NPT_FilePath::BaseName(filepath, keep_extension_in_title); + if (object->m_Title.GetLength() == 0) goto failure; + } #ifndef _WIN32_WCE /* Get the number of children for this container */ - NPT_Cardinal count = 0; + NPT_Cardinal count = 0; // reset output params count = 0; - if (with_count ) { + if (with_count ) { NPT_List entries; - NPT_File::ListDir(__filepath, entries); + NPT_File::ListDir(__filepath, entries); count = entries.GetItemCount(); - ((PLT_MediaContainer*)object)->m_ChildrenCount = count; - } + ((PLT_MediaContainer*)object)->m_ChildrenCount = count; + } #endif //_WIN32_WCE - object->m_ObjectClass.type = "object.container"; - } + object->m_ObjectClass.type = "object.container"; + } - /* is it the root? */ - if ((filepath.Compare("/", true) == 0) || (filepath.Compare("\\", true) == 0)) { - object->m_ParentID = "-1"; - object->m_ObjectID = "0"; - } else { - NPT_String directory = NPT_FilePath::DirName(filepath); - /* is the parent path the root? */ + /* is it the root? */ + if ((filepath.Compare("/", true) == 0) || (filepath.Compare("\\", true) == 0)) { + object->m_ParentID = "-1"; + object->m_ObjectID = "0"; + } else { + NPT_String directory = NPT_FilePath::DirName(filepath); + /* is the parent path the root? */ if ((directory.Compare("/", true) == 0) || (directory.Compare("\\", true) == 0)) { - object->m_ParentID = "0"; - } else { - object->m_ParentID = "0" + directory; - } - object->m_ObjectID = "0" + filepath; - } - return object; + object->m_ParentID = "0"; + } else { + object->m_ParentID = "0" + directory; + } + object->m_ObjectID = "0" + filepath; + } + return object; failure: - delete object; - return NULL; + delete object; + return NULL; } @@ -435,7 +435,7 @@ NPT_String GPAC_FileMediaServer::GetResourceURI(const char *url, const char *for } /*if no parent directory, we don't allow sharing of the resource*/ if (nb_sep!=2) return ""; - + char sep = abs_url[len-i]; abs_url[len-i] = 0; newdir = abs_url; @@ -493,7 +493,7 @@ void GPAC_FileMediaServer::ShareVirtualResource(const char *res_uri, const char the_uri += "?"; else if (!strnicmp(sep, "%5c", 3)) the_uri += "/"; - else + else the_uri += " "; uri= sep+3; continue; @@ -511,22 +511,22 @@ void GPAC_FileMediaServer::ShareVirtualResource(const char *res_uri, const char GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[UPnP] sharing virtual file %s as %s\n", res_uri, (const char *)the_uri)); } -NPT_Result +NPT_Result GPAC_FileMediaServer::ServeVirtualFile(NPT_HttpResponse& response, - GPAC_VirtualFile *vfile, - NPT_Position start, - NPT_Position end, - bool request_is_head) + GPAC_VirtualFile *vfile, + NPT_Position start, + NPT_Position end, + bool request_is_head) { - NPT_LargeSize total_len; - NPT_Result result; + NPT_LargeSize total_len; + NPT_Result result; NPT_MemoryStream* memory_stream = new NPT_MemoryStream(vfile->m_Content.GetChars(), vfile->m_Content.GetLength() ); - NPT_InputStreamReference stream(memory_stream); + NPT_InputStreamReference stream(memory_stream); if (NPT_FAILED(result = stream->GetSize(total_len)) ) { - response.SetStatus(404, "File Not Found"); - return NPT_SUCCESS; + response.SetStatus(404, "File Not Found"); + return NPT_SUCCESS; } GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[UPnP] Serving virtual file %s\n", vfile->m_Content.GetChars())); @@ -536,44 +536,44 @@ GPAC_FileMediaServer::ServeVirtualFile(NPT_HttpResponse& response, response.SetEntity(entity); entity->SetContentType(vfile->m_MIME); - // request is HEAD, returns without setting a body - if (request_is_head) return NPT_SUCCESS; - - // see if it was a byte range request - if (start != (NPT_Position)-1 || end != (NPT_Position)-1) { - // we can only support a range from an offset to the end of the resource for now - // due to the fact we can't limit how much to read from a stream yet - NPT_Position start_offset = (NPT_Position)-1, end_offset = total_len - 1, len; - if (start == (NPT_Position)-1 && end != (NPT_Position)-1) { - // we are asked for the last N=end bytes - // adjust according to total length - if (end >= total_len) { - start_offset = 0; - } else { - start_offset = total_len-end; - } - } else if (start != (NPT_Position)-1) { - start_offset = start; - // if the end is specified but incorrect - // set the end_offset in order to generate a bad response - if (end != (NPT_Position)-1 && end < start) { - end_offset = (NPT_Position)-1; - } - } - - // in case the range request was invalid or we can't seek then respond appropriately - if (start_offset == (NPT_Position)-1 || end_offset == (NPT_Position)-1 || - start_offset > end_offset || NPT_FAILED(stream->Seek(start_offset))) { - response.SetStatus(416, "Requested range not satisfiable"); - } else { - len = end_offset - start_offset + 1; - response.SetStatus(206, "Partial Content"); - entity->SetInputStream(stream); - entity->SetContentLength(len); - } - } else { - entity->SetInputStream(stream); - } - return NPT_SUCCESS; + // request is HEAD, returns without setting a body + if (request_is_head) return NPT_SUCCESS; + + // see if it was a byte range request + if (start != (NPT_Position)-1 || end != (NPT_Position)-1) { + // we can only support a range from an offset to the end of the resource for now + // due to the fact we can't limit how much to read from a stream yet + NPT_Position start_offset = (NPT_Position)-1, end_offset = total_len - 1, len; + if (start == (NPT_Position)-1 && end != (NPT_Position)-1) { + // we are asked for the last N=end bytes + // adjust according to total length + if (end >= total_len) { + start_offset = 0; + } else { + start_offset = total_len-end; + } + } else if (start != (NPT_Position)-1) { + start_offset = start; + // if the end is specified but incorrect + // set the end_offset in order to generate a bad response + if (end != (NPT_Position)-1 && end < start) { + end_offset = (NPT_Position)-1; + } + } + + // in case the range request was invalid or we can't seek then respond appropriately + if (start_offset == (NPT_Position)-1 || end_offset == (NPT_Position)-1 || + start_offset > end_offset || NPT_FAILED(stream->Seek(start_offset))) { + response.SetStatus(416, "Requested range not satisfiable"); + } else { + len = end_offset - start_offset + 1; + response.SetStatus(206, "Partial Content"); + entity->SetInputStream(stream); + entity->SetContentLength(len); + } + } else { + entity->SetInputStream(stream); + } + return NPT_SUCCESS; } diff --git a/modules/platinum/GPACFileMediaServer.h b/modules/platinum/GPACFileMediaServer.h index 5b2ded8..2ececfb 100644 --- a/modules/platinum/GPACFileMediaServer.h +++ b/modules/platinum/GPACFileMediaServer.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ public: m_MIME = mime; m_temporary = temporary; } - bool operator==(const GPAC_VirtualFile & v1) { + bool operator==(const GPAC_VirtualFile & v1) { return m_URI==v1.m_URI; } @@ -86,49 +86,49 @@ public: class GPAC_FileMediaServer : public PLT_FileMediaServer { public: - GPAC_FileMediaServer(const char* friendly_name, - bool show_ip = false, - const char* uuid = NULL, - NPT_UInt16 port = 0); + GPAC_FileMediaServer(const char* friendly_name, + bool show_ip = false, + const char* uuid = NULL, + NPT_UInt16 port = 0); void AddSharedDirectory(const char *path, const char *alias, Bool is_hidden = GF_FALSE); - NPT_String GetResourceURI(const char *file_path, const char *for_host); - void ShareVirtualResource(const char *res_uri, const char *res_val, const char *res_mime, Bool temporary = GF_FALSE); + NPT_String GetResourceURI(const char *file_path, const char *for_host); + void ShareVirtualResource(const char *res_uri, const char *res_val, const char *res_mime, Bool temporary = GF_FALSE); protected: - virtual NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action, - const char* object_id, - const char* filter, - NPT_UInt32 starting_index, - NPT_UInt32 requested_count, - const char * sort_criteria, - const PLT_HttpRequestContext& context); + virtual NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action, + const char* object_id, + const char* filter, + NPT_UInt32 starting_index, + NPT_UInt32 requested_count, + const char * sort_criteria, + const PLT_HttpRequestContext& context); virtual NPT_Result GetFilePath(const char* object_id, NPT_String& filepath); - virtual NPT_Result ServeFile(NPT_HttpRequest& request, - const NPT_HttpRequestContext& context, - NPT_HttpResponse& response, - const NPT_String& file_path); + virtual NPT_Result ServeFile(NPT_HttpRequest& request, + const NPT_HttpRequestContext& context, + NPT_HttpResponse& response, + const NPT_String& file_path); - virtual PLT_MediaObject* BuildFromFilePath(const NPT_String& filepath, - const PLT_HttpRequestContext& context, - bool with_count = true, - bool keep_extension_in_title = false); + virtual PLT_MediaObject* BuildFromFilePath(const NPT_String& filepath, + const PLT_HttpRequestContext& context, + bool with_count = true, + bool keep_extension_in_title = false); - PLT_MediaObject* BuildFromFilePathAndHost(const NPT_String& filepath, - const PLT_HttpRequestContext *context = NULL, - bool with_count = true, - bool keep_extension_in_title = false, - const char *for_host = NULL); + PLT_MediaObject* BuildFromFilePathAndHost(const NPT_String& filepath, + const PLT_HttpRequestContext *context = NULL, + bool with_count = true, + bool keep_extension_in_title = false, + const char *for_host = NULL); NPT_Result ServeVirtualFile(NPT_HttpResponse& response, - GPAC_VirtualFile *vfile, - NPT_Position start, - NPT_Position end, - bool request_is_head); + GPAC_VirtualFile *vfile, + NPT_Position start, + NPT_Position end, + bool request_is_head); private: NPT_List m_Directories; diff --git a/modules/platinum/GPACMediaController.cpp b/modules/platinum/GPACMediaController.cpp index 77b2aa8..fb4a12b 100644 --- a/modules/platinum/GPACMediaController.cpp +++ b/modules/platinum/GPACMediaController.cpp @@ -2,25 +2,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -34,8 +34,8 @@ GPAC_MediaController::GPAC_MediaController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp) { - m_MediaController = new PLT_MediaController(ctrlPoint, this); - m_MediaBrowser = new PLT_MediaBrowser(ctrlPoint, this); + m_MediaController = new PLT_MediaController(ctrlPoint, this); + m_MediaBrowser = new PLT_MediaBrowser(ctrlPoint, this); m_MediaServers = gf_list_new(); m_MediaRenderers = gf_list_new(); @@ -48,7 +48,7 @@ GPAC_MediaController::~GPAC_MediaController() { delete m_MediaController; m_MediaController=NULL; - delete m_MediaBrowser; + delete m_MediaBrowser; m_MediaBrowser=NULL; while (gf_list_count(m_MediaServers)) { @@ -71,28 +71,28 @@ GPAC_MediaController::~GPAC_MediaController() -bool +bool GPAC_MediaController::OnMRAdded(PLT_DeviceDataReference& device) { - NPT_String uuid = device->GetUUID(); + NPT_String uuid = device->GetUUID(); gf_mx_p(m_ControlPointLock); - // test if it's a media renderer - PLT_Service* service; - if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service))) { - gf_list_add(m_MediaRenderers, new GPAC_MediaRendererItem(device, uuid) ); - } + // test if it's a media renderer + PLT_Service* service; + if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service))) { + gf_list_add(m_MediaRenderers, new GPAC_MediaRendererItem(device, uuid) ); + } m_pUPnP->OnMediaRendererAdd(device, 1); gf_mx_v(m_ControlPointLock); return true; } -void +void GPAC_MediaController::OnMRRemoved(PLT_DeviceDataReference& device) { - NPT_String uuid = device->GetUUID(); + NPT_String uuid = device->GetUUID(); gf_mx_p(m_ControlPointLock); @@ -111,19 +111,19 @@ GPAC_MediaController::OnMRRemoved(PLT_DeviceDataReference& device) gf_mx_v(m_ControlPointLock); } -bool +bool GPAC_MediaController::OnMSAdded(PLT_DeviceDataReference& device) { - NPT_String uuid = device->GetUUID(); + NPT_String uuid = device->GetUUID(); - gf_mx_p(m_ControlPointLock); - // test if it's a media server - PLT_Service* service; - if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:ContentDirectory:1", service))) { + gf_mx_p(m_ControlPointLock); + // test if it's a media server + PLT_Service* service; + if (NPT_SUCCEEDED(device->FindServiceByType("urn:schemas-upnp-org:service:ContentDirectory:1", service))) { gf_list_add(m_MediaServers, new GPAC_MediaServerItem(device, uuid) ); - } + } m_pUPnP->OnMediaServerAdd(device, 1); - gf_mx_v(m_ControlPointLock); + gf_mx_v(m_ControlPointLock); return true; } @@ -131,9 +131,9 @@ GPAC_MediaController::OnMSAdded(PLT_DeviceDataReference& device) void GPAC_MediaController::OnMSRemoved(PLT_DeviceDataReference& device) { - NPT_String uuid = device->GetUUID(); + NPT_String uuid = device->GetUUID(); - gf_mx_p(m_ControlPointLock); + gf_mx_p(m_ControlPointLock); u32 i, count; count = gf_list_count(m_MediaServers); for (i=0; iOnMediaServerAdd(device, 0); - gf_mx_v(m_ControlPointLock); + gf_mx_v(m_ControlPointLock); } NPT_Result -GPAC_MediaController::OnActionResponse(NPT_Result res, - PLT_ActionReference& action, - void* userdata) +GPAC_MediaController::OnActionResponse(NPT_Result res, + PLT_ActionReference& action, + void* userdata) { return NPT_SUCCESS; } @@ -178,7 +178,7 @@ void GPAC_MediaController::OnMRStateVariablesChanged(PLT_Service* service, NPT_L } } if (render_idx < 0) return; - + count = vars->GetItemCount(); for (i=0; ires = res; - if (NPT_SUCCEEDED(res) && info) { - (*data)->info = *info; - } - (*data)->shared_var.SetValue(1); - delete data; + GPAC_BrowseDataReference* data = (GPAC_BrowseDataReference*) userdata; + (*data)->res = res; + if (NPT_SUCCEEDED(res) && info) { + (*data)->info = *info; + } + (*data)->shared_var.SetValue(1); + delete data; } -void +void GPAC_MediaController::OnMSStateVariablesChanged(PLT_Service* service, NPT_List* vars) { GPAC_MediaServerItem *ms = NULL; @@ -234,129 +234,129 @@ GPAC_MediaController::OnMSStateVariablesChanged(PLT_Service* service, NPT_List

GetValue(); - NPT_String item_id, update_id; - int index; - - while (value.GetLength()) { - // look for container id - index = value.Find(','); - if (index < 0) break; - item_id = value.Left(index); - value = value.SubString(index+1); - - // look for update id - if (value.GetLength()) { - index = value.Find(','); - update_id = (index<0)?value:value.Left(index); - value = (index<0)?"":value.SubString(index+1); + PLT_StateVariable* var = PLT_StateVariable::Find(*vars, "ContainerUpdateIDs"); + if (var) { + // variable found, parse value + NPT_String value = var->GetValue(); + NPT_String item_id, update_id; + int index; + + while (value.GetLength()) { + // look for container id + index = value.Find(','); + if (index < 0) break; + item_id = value.Left(index); + value = value.SubString(index+1); + + // look for update id + if (value.GetLength()) { + index = value.Find(','); + update_id = (index<0)?value:value.Left(index); + value = (index<0)?"":value.SubString(index+1); m_pUPnP->ContainerChanged(ms->m_device, item_id, update_id); - } - } - } + } + } + } gf_mx_v(m_ControlPointLock); } NPT_Result GPAC_MediaController::WaitForResponse(NPT_SharedVariable& shared_var) { - return shared_var.WaitUntilEquals(1, 30000); + return shared_var.WaitUntilEquals(1, 30000); } -NPT_Result +NPT_Result GPAC_MediaController::Browse(GPAC_BrowseDataReference& browse_data, - PLT_DeviceDataReference& device, - const char* object_id, - NPT_Int32 index, + PLT_DeviceDataReference& device, + const char* object_id, + NPT_Int32 index, NPT_Int32 count, bool browse_metadata, - const char* filter, + const char* filter, const char* sort) { - NPT_Result res; - - browse_data->shared_var.SetValue(0); - - // send off the browse packet. Note that this will - // not block. There is a call to WaitForResponse in order - // to block until the response comes back. - res = m_MediaBrowser->Browse(device, - (const char*)object_id, - index, - count, - browse_metadata, - filter, - sort, - new GPAC_BrowseDataReference(browse_data)); - NPT_CHECK_SEVERE(res); - - return WaitForResponse(browse_data->shared_var); + NPT_Result res; + + browse_data->shared_var.SetValue(0); + + // send off the browse packet. Note that this will + // not block. There is a call to WaitForResponse in order + // to block until the response comes back. + res = m_MediaBrowser->Browse(device, + (const char*)object_id, + index, + count, + browse_metadata, + filter, + sort, + new GPAC_BrowseDataReference(browse_data)); + NPT_CHECK_SEVERE(res); + + return WaitForResponse(browse_data->shared_var); } -NPT_Result +NPT_Result GPAC_MediaController::Browse(GPAC_MediaServerItem *server, const char *object_id, const char *filter) { - NPT_Result res = NPT_FAILURE; - NPT_Int32 index = 0; + NPT_Result res = NPT_FAILURE; + NPT_Int32 index = 0; - // reset output params + // reset output params server->m_BrowseResults = NULL; - do { - GPAC_BrowseDataReference browse_data(new GPAC_BrowseData()); - - // send off the browse packet. Note that this will - // not block. There is a call to WaitForResponse in order - // to block until the response comes back. - res = Browse(browse_data, - server->m_device, - (const char*)object_id, - index, - 1024, - false, - filter, - ""); - NPT_CHECK_LABEL_WARNING(res, done); - - if (NPT_FAILED(browse_data->res)) { - res = browse_data->res; - NPT_CHECK_LABEL_WARNING(res, done); - } - - if (browse_data->info.items->GetItemCount() == 0) - break; - - if (server->m_BrowseResults.IsNull()) { - server->m_BrowseResults = browse_data->info.items; - } else { - server->m_BrowseResults->Add(*browse_data->info.items); - // clear the list items so that the data inside is not - // cleaned up by PLT_MediaItemList dtor since we copied - // each pointer into the new list. - browse_data->info.items->Clear(); - } - - // stop now if our list contains exactly what the server said it had - if (browse_data->info.tm && browse_data->info.tm == server->m_BrowseResults->GetItemCount()) - break; - - // ask for the next chunk of entries - index = server->m_BrowseResults->GetItemCount(); - } while(1); + do { + GPAC_BrowseDataReference browse_data(new GPAC_BrowseData()); + + // send off the browse packet. Note that this will + // not block. There is a call to WaitForResponse in order + // to block until the response comes back. + res = Browse(browse_data, + server->m_device, + (const char*)object_id, + index, + 1024, + false, + filter, + ""); + NPT_CHECK_LABEL_WARNING(res, done); + + if (NPT_FAILED(browse_data->res)) { + res = browse_data->res; + NPT_CHECK_LABEL_WARNING(res, done); + } + + if (browse_data->info.items->GetItemCount() == 0) + break; + + if (server->m_BrowseResults.IsNull()) { + server->m_BrowseResults = browse_data->info.items; + } else { + server->m_BrowseResults->Add(*browse_data->info.items); + // clear the list items so that the data inside is not + // cleaned up by PLT_MediaItemList dtor since we copied + // each pointer into the new list. + browse_data->info.items->Clear(); + } + + // stop now if our list contains exactly what the server said it had + if (browse_data->info.tm && browse_data->info.tm == server->m_BrowseResults->GetItemCount()) + break; + + // ask for the next chunk of entries + index = server->m_BrowseResults->GetItemCount(); + } while(1); done: - return res; + return res; } diff --git a/modules/platinum/GPACMediaController.h b/modules/platinum/GPACMediaController.h index c22f767..5a56700 100644 --- a/modules/platinum/GPACMediaController.h +++ b/modules/platinum/GPACMediaController.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -40,9 +40,9 @@ #include typedef struct { - NPT_SharedVariable shared_var; - NPT_Result res; - PLT_BrowseInfo info; + NPT_SharedVariable shared_var; + NPT_Result res; + PLT_BrowseInfo info; } GPAC_BrowseData; /*basic class to hold each media renderer*/ @@ -71,40 +71,40 @@ typedef NPT_Reference GPAC_BrowseDataReference; class GF_UPnP; -class GPAC_MediaController : public PLT_CtrlPointListener, - public PLT_MediaControllerDelegate, - public PLT_MediaBrowserDelegate +class GPAC_MediaController : public PLT_CtrlPointListener, + public PLT_MediaControllerDelegate, + public PLT_MediaBrowserDelegate { public: - GPAC_MediaController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp); - ~GPAC_MediaController(); + GPAC_MediaController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp); + ~GPAC_MediaController(); - virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device) + virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device) { return NPT_SUCCESS; } - virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device) + virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device) { return NPT_SUCCESS; } - virtual NPT_Result OnActionResponse(NPT_Result res, - PLT_ActionReference& action, - void* userdata); - virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List* vars); + virtual NPT_Result OnActionResponse(NPT_Result res, + PLT_ActionReference& action, + void* userdata); + virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List* vars); - // PLT_MediaControllerDelegate + // PLT_MediaControllerDelegate virtual bool OnMRAdded(PLT_DeviceDataReference& device); virtual void OnMRRemoved(PLT_DeviceDataReference& device); - virtual void OnMRStateVariablesChanged(PLT_Service* /* service */, NPT_List* /* vars */); + virtual void OnMRStateVariablesChanged(PLT_Service* /* service */, NPT_List* /* vars */); //PLT_MediaBrowserDelegate - virtual bool OnMSAdded(PLT_DeviceDataReference& device); - virtual void OnMSRemoved(PLT_DeviceDataReference& device); - virtual void OnMSStateVariablesChanged(PLT_Service *service, NPT_List* vars); - virtual void OnBrowseResult(NPT_Result res, - PLT_DeviceDataReference& device, - PLT_BrowseInfo* info, - void* userdata); + virtual bool OnMSAdded(PLT_DeviceDataReference& device); + virtual void OnMSRemoved(PLT_DeviceDataReference& device); + virtual void OnMSStateVariablesChanged(PLT_Service *service, NPT_List* vars); + virtual void OnBrowseResult(NPT_Result res, + PLT_DeviceDataReference& device, + PLT_BrowseInfo* info, + void* userdata); NPT_Result Browse(GPAC_MediaServerItem *server, const char *id, const char *filter); @@ -112,23 +112,23 @@ public: GF_List *m_MediaRenderers; GF_List *m_MediaServers; - /* The UPnP MediaRenderer control point. */ - PLT_MediaController* m_MediaController; - /* The UPnP MediaServer control point. */ - PLT_MediaBrowser *m_MediaBrowser; + /* The UPnP MediaRenderer control point. */ + PLT_MediaController* m_MediaController; + /* The UPnP MediaServer control point. */ + PLT_MediaBrowser *m_MediaBrowser; protected: - NPT_Result Browse(GPAC_BrowseDataReference& browse_data, - PLT_DeviceDataReference& device, - const char* object_id, - NPT_Int32 index, - NPT_Int32 count, - bool browse_metadata = false, - const char* filter = "*", - const char* sort = ""); + NPT_Result Browse(GPAC_BrowseDataReference& browse_data, + PLT_DeviceDataReference& device, + const char* object_id, + NPT_Int32 index, + NPT_Int32 count, + bool browse_metadata = false, + const char* filter = "*", + const char* sort = ""); private: - NPT_Result WaitForResponse(NPT_SharedVariable& shared_var); + NPT_Result WaitForResponse(NPT_SharedVariable& shared_var); GF_UPnP *m_pUPnP; GF_Mutex *m_ControlPointLock; diff --git a/modules/platinum/GPACMediaRenderer.cpp b/modules/platinum/GPACMediaRenderer.cpp index 5da5c38..6c9ab2a 100644 --- a/modules/platinum/GPACMediaRenderer.cpp +++ b/modules/platinum/GPACMediaRenderer.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -46,11 +46,11 @@ void format_time_string(char *str, Double dur) sprintf(str, "%02d:%02d:%02d", h, m, s); } -GPAC_MediaRenderer::GPAC_MediaRenderer(GF_UPnP *upnp, const char* friendly_name, - bool show_ip, - const char* uuid, - unsigned int port) : - PLT_DeviceHost("/", uuid, "urn:schemas-upnp-org:device:MediaRenderer:1", friendly_name, show_ip, port) +GPAC_MediaRenderer::GPAC_MediaRenderer(GF_UPnP *upnp, const char* friendly_name, + bool show_ip, + const char* uuid, + unsigned int port) : + PLT_DeviceHost("/", uuid, "urn:schemas-upnp-org:device:MediaRenderer:1", friendly_name, show_ip, port) { m_mediaHistoryList = gf_list_new(); m_pUPnP = upnp; @@ -74,113 +74,113 @@ GPAC_MediaRenderer::~GPAC_MediaRenderer() NPT_Result GPAC_MediaRenderer::SetupServices() { - PLT_Service* service; - - { - /* AVTransport */ - m_pAVService = new PLT_Service( - this, - "urn:schemas-upnp-org:service:AVTransport:1", - "urn:upnp-org:serviceId:AVTransport", - "AVTransport", - "urn:schemas-upnp-org:metadata-1-0/AVT/"); - - NPT_CHECK_FATAL(m_pAVService->SetSCPDXML((const char*) RDR_AVTransportSCPD)); - NPT_CHECK_FATAL(AddService(m_pAVService)); - - m_pAVService->SetStateVariableRate("LastChange", NPT_TimeInterval(0.2f)); - m_pAVService->SetStateVariable("A_ARG_TYPE_InstanceID", "0"); - - // GetCurrentTransportActions - m_pAVService->SetStateVariable("CurrentTransportActions", "Play,Pause,Stop,Seek,Next,Previous"); - - // GetDeviceCapabilities - m_pAVService->SetStateVariable("PossiblePlaybackStorageMedia", "NONE,NETWORK"); - m_pAVService->SetStateVariable("PossibleRecordStorageMedia", "NOT_IMPLEMENTED"); - m_pAVService->SetStateVariable("PossibleRecordQualityModes", "NOT_IMPLEMENTED"); - - // GetMediaInfo - m_pAVService->SetStateVariable("NumberOfTracks", "0"); - m_pAVService->SetStateVariable("CurrentMediaDuration", "00:00:00");; - m_pAVService->SetStateVariable("AVTransportURI", ""); - m_pAVService->SetStateVariable("AVTransportURIMetadata", "");; - m_pAVService->SetStateVariable("NextAVTransportURI", "NOT_IMPLEMENTED"); - m_pAVService->SetStateVariable("NextAVTransportURIMetadata", "NOT_IMPLEMENTED"); - m_pAVService->SetStateVariable("PlaybackStorageMedium", "NONE"); - m_pAVService->SetStateVariable("RecordStorageMedium", "NOT_IMPLEMENTED"); - m_pAVService->SetStateVariable("RecordMediumWriteStatus", "NOT_IMPLEMENTED"); - - // GetPositionInfo - m_pAVService->SetStateVariable("CurrentTrack", "0"); - m_pAVService->SetStateVariable("CurrentTrackDuration", "00:00:00"); - m_pAVService->SetStateVariable("CurrentTrackMetadata", ""); - m_pAVService->SetStateVariable("CurrentTrackURI", ""); - m_pAVService->SetStateVariable("RelativeTimePosition", "00:00:00"); - m_pAVService->SetStateVariable("AbsoluteTimePosition", "00:00:00"); - m_pAVService->SetStateVariable("RelativeCounterPosition", "2147483647"); // means NOT_IMPLEMENTED - m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED - - // disable indirect eventing for certain state variables - //PLT_StateVariable* var; - //var = - m_pAVService->FindStateVariable("RelativeTimePosition"); - //if (var) var->DisableIndirectEventing(); - //var = - m_pAVService->FindStateVariable("AbsoluteTimePosition"); - //if (var) var->DisableIndirectEventing(); - //var = - m_pAVService->FindStateVariable("RelativeCounterPosition"); - //if (var) var->DisableIndirectEventing(); - //var = - m_pAVService->FindStateVariable("AbsoluteCounterPosition"); - //if (var) var->DisableIndirectEventing(); - - // GetTransportInfo - m_pAVService->SetStateVariable("TransportState", "NO_MEDIA_PRESENT"); - m_pAVService->SetStateVariable("TransportStatus", "OK"); - m_pAVService->SetStateVariable("TransportPlaySpeed", "1"); - - // GetTransportSettings - m_pAVService->SetStateVariable("CurrentPlayMode", "NORMAL"); - m_pAVService->SetStateVariable("CurrentRecordQualityMode", "NOT_IMPLEMENTED"); - } - - { - /* ConnectionManager */ - service = new PLT_Service( - this, - "urn:schemas-upnp-org:service:ConnectionManager:1", - "urn:upnp-org:serviceId:ConnectionManager", - "ConnectionManager"); - NPT_CHECK_FATAL(service->SetSCPDXML((const char*) RDR_ConnectionManagerSCPD)); - NPT_CHECK_FATAL(AddService(service)); - - service->SetStateVariable("CurrentConnectionIDs", "0"); - - // put all supported mime types here instead - service->SetStateVariable("SinkProtocolInfo", "http-get:*:*:*, rtsp-rtp-udp:*:*:*"); - service->SetStateVariable("SourceProtocolInfo", ""); - } - - { - /* RenderingControl */ - service = new PLT_Service( - this, - "urn:schemas-upnp-org:service:RenderingControl:1", - "urn:upnp-org:serviceId:RenderingControl", - "RenderingControl", - "urn:schemas-upnp-org:metadata-1-0/RCS/"); - NPT_CHECK_FATAL(service->SetSCPDXML((const char*) RDR_RenderingControlSCPD)); - NPT_CHECK_FATAL(AddService(service)); - - service->SetStateVariableRate("LastChange", NPT_TimeInterval(0.2f)); - - service->SetStateVariable("Mute", "0"); - service->SetStateVariable("Volume", "100"); - } - - { -static NPT_UInt8 MIGRATION_SCPDXML[] = "\ + PLT_Service* service; + + { + /* AVTransport */ + m_pAVService = new PLT_Service( + this, + "urn:schemas-upnp-org:service:AVTransport:1", + "urn:upnp-org:serviceId:AVTransport", + "AVTransport", + "urn:schemas-upnp-org:metadata-1-0/AVT/"); + + NPT_CHECK_FATAL(m_pAVService->SetSCPDXML((const char*) RDR_AVTransportSCPD)); + NPT_CHECK_FATAL(AddService(m_pAVService)); + + m_pAVService->SetStateVariableRate("LastChange", NPT_TimeInterval(0.2f)); + m_pAVService->SetStateVariable("A_ARG_TYPE_InstanceID", "0"); + + // GetCurrentTransportActions + m_pAVService->SetStateVariable("CurrentTransportActions", "Play,Pause,Stop,Seek,Next,Previous"); + + // GetDeviceCapabilities + m_pAVService->SetStateVariable("PossiblePlaybackStorageMedia", "NONE,NETWORK"); + m_pAVService->SetStateVariable("PossibleRecordStorageMedia", "NOT_IMPLEMENTED"); + m_pAVService->SetStateVariable("PossibleRecordQualityModes", "NOT_IMPLEMENTED"); + + // GetMediaInfo + m_pAVService->SetStateVariable("NumberOfTracks", "0"); + m_pAVService->SetStateVariable("CurrentMediaDuration", "00:00:00");; + m_pAVService->SetStateVariable("AVTransportURI", ""); + m_pAVService->SetStateVariable("AVTransportURIMetadata", "");; + m_pAVService->SetStateVariable("NextAVTransportURI", "NOT_IMPLEMENTED"); + m_pAVService->SetStateVariable("NextAVTransportURIMetadata", "NOT_IMPLEMENTED"); + m_pAVService->SetStateVariable("PlaybackStorageMedium", "NONE"); + m_pAVService->SetStateVariable("RecordStorageMedium", "NOT_IMPLEMENTED"); + m_pAVService->SetStateVariable("RecordMediumWriteStatus", "NOT_IMPLEMENTED"); + + // GetPositionInfo + m_pAVService->SetStateVariable("CurrentTrack", "0"); + m_pAVService->SetStateVariable("CurrentTrackDuration", "00:00:00"); + m_pAVService->SetStateVariable("CurrentTrackMetadata", ""); + m_pAVService->SetStateVariable("CurrentTrackURI", ""); + m_pAVService->SetStateVariable("RelativeTimePosition", "00:00:00"); + m_pAVService->SetStateVariable("AbsoluteTimePosition", "00:00:00"); + m_pAVService->SetStateVariable("RelativeCounterPosition", "2147483647"); // means NOT_IMPLEMENTED + m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED + + // disable indirect eventing for certain state variables + //PLT_StateVariable* var; + //var = + m_pAVService->FindStateVariable("RelativeTimePosition"); + //if (var) var->DisableIndirectEventing(); + //var = + m_pAVService->FindStateVariable("AbsoluteTimePosition"); + //if (var) var->DisableIndirectEventing(); + //var = + m_pAVService->FindStateVariable("RelativeCounterPosition"); + //if (var) var->DisableIndirectEventing(); + //var = + m_pAVService->FindStateVariable("AbsoluteCounterPosition"); + //if (var) var->DisableIndirectEventing(); + + // GetTransportInfo + m_pAVService->SetStateVariable("TransportState", "NO_MEDIA_PRESENT"); + m_pAVService->SetStateVariable("TransportStatus", "OK"); + m_pAVService->SetStateVariable("TransportPlaySpeed", "1"); + + // GetTransportSettings + m_pAVService->SetStateVariable("CurrentPlayMode", "NORMAL"); + m_pAVService->SetStateVariable("CurrentRecordQualityMode", "NOT_IMPLEMENTED"); + } + + { + /* ConnectionManager */ + service = new PLT_Service( + this, + "urn:schemas-upnp-org:service:ConnectionManager:1", + "urn:upnp-org:serviceId:ConnectionManager", + "ConnectionManager"); + NPT_CHECK_FATAL(service->SetSCPDXML((const char*) RDR_ConnectionManagerSCPD)); + NPT_CHECK_FATAL(AddService(service)); + + service->SetStateVariable("CurrentConnectionIDs", "0"); + + // put all supported mime types here instead + service->SetStateVariable("SinkProtocolInfo", "http-get:*:*:*, rtsp-rtp-udp:*:*:*"); + service->SetStateVariable("SourceProtocolInfo", ""); + } + + { + /* RenderingControl */ + service = new PLT_Service( + this, + "urn:schemas-upnp-org:service:RenderingControl:1", + "urn:upnp-org:serviceId:RenderingControl", + "RenderingControl", + "urn:schemas-upnp-org:metadata-1-0/RCS/"); + NPT_CHECK_FATAL(service->SetSCPDXML((const char*) RDR_RenderingControlSCPD)); + NPT_CHECK_FATAL(AddService(service)); + + service->SetStateVariableRate("LastChange", NPT_TimeInterval(0.2f)); + + service->SetStateVariable("Mute", "0"); + service->SetStateVariable("Volume", "100"); + } + + { + static NPT_UInt8 MIGRATION_SCPDXML[] = "\ \ \ MigrationStatus\ @@ -226,88 +226,88 @@ static NPT_UInt8 MIGRATION_SCPDXML[] = "\ "; - /* MigrationService */ - m_pMigrationService = new PLT_Service(this, "urn:intermedia:service:migration:1", "urn:intermedia:service:migration.001", "SessionMigration"); - + /* MigrationService */ + m_pMigrationService = new PLT_Service(this, "urn:intermedia:service:migration:1", "urn:intermedia:service:migration.001", "SessionMigration"); + NPT_CHECK_FATAL(m_pMigrationService->SetSCPDXML((const char*) MIGRATION_SCPDXML)); - NPT_CHECK_FATAL(AddService(m_pMigrationService)); + NPT_CHECK_FATAL(AddService(m_pMigrationService)); - m_pMigrationService->SetStateVariable("MigrationStatus", "OK"); - m_pMigrationService->SetStateVariable("MigrationMetaData", ""); - } + m_pMigrationService->SetStateVariable("MigrationStatus", "OK"); + m_pMigrationService->SetStateVariable("MigrationMetaData", ""); + } - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result -GPAC_MediaRenderer::OnAction(PLT_ActionReference& action, - const PLT_HttpRequestContext& context) +GPAC_MediaRenderer::OnAction(PLT_ActionReference& action, + const PLT_HttpRequestContext& context) { - NPT_COMPILER_UNUSED(context); + NPT_COMPILER_UNUSED(context); - /* parse the action name */ - NPT_String name = action->GetActionDesc().GetName(); + /* parse the action name */ + NPT_String name = action->GetActionDesc().GetName(); m_ip_src = context.GetRemoteAddress().GetIpAddress().ToString(); /* Is it a ConnectionManager Service Action ? */ - if (name.Compare("GetCurrentConnectionIDs", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetProtocolInfo", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetCurrentConnectionInfo", true) == 0) { - return OnGetCurrentConnectionInfo(action); - } - if (name.Compare("StopForMigration", true) == 0) { + if (name.Compare("GetCurrentConnectionIDs", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetProtocolInfo", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetCurrentConnectionInfo", true) == 0) { + return OnGetCurrentConnectionInfo(action); + } + if (name.Compare("StopForMigration", true) == 0) { NPT_String res = m_pUPnP->OnMigrate(); - m_pMigrationService->SetStateVariable("MigrationStatus", "OK"); - m_pMigrationService->SetStateVariable("MigrationMetaData", res); + m_pMigrationService->SetStateVariable("MigrationStatus", "OK"); + m_pMigrationService->SetStateVariable("MigrationMetaData", res); if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - - /* Is it a AVTransport Service Action ? */ - - // since all actions take an instance ID and we only support 1 instance - // verify that the Instance ID is 0 and return an error here now if not - NPT_String serviceType = action->GetActionDesc().GetService()->GetServiceType(); - if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) { - if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) { - action->SetError(802,"Not valid InstanceID."); - return NPT_FAILURE; - } - } - - if (name.Compare("GetCurrentTransportActions", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetDeviceCapabilities", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetMediaInfo", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetPositionInfo", true) == 0) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + + /* Is it a AVTransport Service Action ? */ + + // since all actions take an instance ID and we only support 1 instance + // verify that the Instance ID is 0 and return an error here now if not + NPT_String serviceType = action->GetActionDesc().GetService()->GetServiceType(); + if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) { + if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) { + action->SetError(802,"Not valid InstanceID."); + return NPT_FAILURE; + } + } + + if (name.Compare("GetCurrentTransportActions", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetDeviceCapabilities", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetMediaInfo", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetPositionInfo", true) == 0) { if (m_pUPnP->m_pTerm->root_scene) { char szVal[100]; @@ -318,7 +318,7 @@ GPAC_MediaRenderer::OnAction(PLT_ActionReference& action, m_pAVService->SetStateVariable("CurrentTrackMetadata", ""); m_pAVService->SetStateVariable("CurrentTrackURI", ""); format_time_string(szVal, m_Time); - m_pAVService->SetStateVariable("RelativeTimePosition", szVal); + m_pAVService->SetStateVariable("RelativeTimePosition", szVal); m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal); m_pAVService->SetStateVariable("RelativeCounterPosition", "2147483647"); // means NOT_IMPLEMENTED m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED @@ -327,119 +327,119 @@ GPAC_MediaRenderer::OnAction(PLT_ActionReference& action, return NPT_FAILURE; } } - return NPT_SUCCESS; - } - if (name.Compare("GetTransportInfo", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("GetTransportSettings", true) == 0) { - if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { - return NPT_FAILURE; - } - return NPT_SUCCESS; - } - if (name.Compare("Next", true) == 0) { - return OnNext(action); - } - if (name.Compare("Pause", true) == 0) { - return OnPause(action); - } - if (name.Compare("Play", true) == 0) { - return OnPlay(action); - } - if (name.Compare("Previous", true) == 0) { - return OnPrevious(action); - } - if (name.Compare("Seek", true) == 0) { - return OnSeek(action); - } - if (name.Compare("Stop", true) == 0) { - return OnStop(action); - } - if (name.Compare("SetAVTransportURI", true) == 0) { - return OnSetAVTransportURI(action); - } - if (name.Compare("SetPlayMode", true) == 0) { - return OnSetPlayMode(action); - } - - /* Is it a RendererControl Service Action ? */ - if (serviceType.Compare("urn:schemas-upnp-org:service:RenderingControl:1", true) == 0) { - /* we only support master channel */ - if (NPT_FAILED(action->VerifyArgumentValue("Channel", "Master"))) { - action->SetError(402,"Invalid Args."); - return NPT_FAILURE; - } - } - - if ((name.Compare("GetVolume", true) == 0) || (name.Compare("GetVolumeRangeDB", true) == 0) ) { - NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); - return NPT_SUCCESS; - } - - if (name.Compare("GetMute", true) == 0) { - NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); - return NPT_SUCCESS; - } - - if (name.Compare("SetVolume", true) == 0) { - return OnSetVolume(action); - } - if (name.Compare("SetVolumeDB", true) == 0) { - return OnSetVolumeDB(action); - } - - if (name.Compare("SetMute", true) == 0) { - return OnSetMute(action); - } - - action->SetError(401,"No Such Action."); - return NPT_FAILURE; + return NPT_SUCCESS; + } + if (name.Compare("GetTransportInfo", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("GetTransportSettings", true) == 0) { + if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) { + return NPT_FAILURE; + } + return NPT_SUCCESS; + } + if (name.Compare("Next", true) == 0) { + return OnNext(action); + } + if (name.Compare("Pause", true) == 0) { + return OnPause(action); + } + if (name.Compare("Play", true) == 0) { + return OnPlay(action); + } + if (name.Compare("Previous", true) == 0) { + return OnPrevious(action); + } + if (name.Compare("Seek", true) == 0) { + return OnSeek(action); + } + if (name.Compare("Stop", true) == 0) { + return OnStop(action); + } + if (name.Compare("SetAVTransportURI", true) == 0) { + return OnSetAVTransportURI(action); + } + if (name.Compare("SetPlayMode", true) == 0) { + return OnSetPlayMode(action); + } + + /* Is it a RendererControl Service Action ? */ + if (serviceType.Compare("urn:schemas-upnp-org:service:RenderingControl:1", true) == 0) { + /* we only support master channel */ + if (NPT_FAILED(action->VerifyArgumentValue("Channel", "Master"))) { + action->SetError(402,"Invalid Args."); + return NPT_FAILURE; + } + } + + if ((name.Compare("GetVolume", true) == 0) || (name.Compare("GetVolumeRangeDB", true) == 0) ) { + NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); + return NPT_SUCCESS; + } + + if (name.Compare("GetMute", true) == 0) { + NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); + return NPT_SUCCESS; + } + + if (name.Compare("SetVolume", true) == 0) { + return OnSetVolume(action); + } + if (name.Compare("SetVolumeDB", true) == 0) { + return OnSetVolumeDB(action); + } + + if (name.Compare("SetMute", true) == 0) { + return OnSetMute(action); + } + + action->SetError(401,"No Such Action."); + return NPT_FAILURE; } NPT_Result GPAC_MediaRenderer::OnGetCurrentConnectionInfo(PLT_ActionReference& action) { - if (NPT_FAILED(action->VerifyArgumentValue("ConnectionID", "0"))) { - action->SetError(706,"No Such Connection."); - return NPT_FAILURE; - } - - if (NPT_FAILED(action->SetArgumentValue("RcsID", "0"))){ - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("AVTransportID", "0"))) { - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("ProtocolInfo", "http-get:*:*:*"))) { - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("PeerConnectionManager", "/"))) { - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("PeerConnectionID", "-1"))) { - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("Direction", "Input"))) { - return NPT_FAILURE; - } - if (NPT_FAILED(action->SetArgumentValue("Status", "Unknown"))) { - return NPT_FAILURE; - } - - return NPT_SUCCESS; + if (NPT_FAILED(action->VerifyArgumentValue("ConnectionID", "0"))) { + action->SetError(706,"No Such Connection."); + return NPT_FAILURE; + } + + if (NPT_FAILED(action->SetArgumentValue("RcsID", "0"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("AVTransportID", "0"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("ProtocolInfo", "http-get:*:*:*"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("PeerConnectionManager", "/"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("PeerConnectionID", "-1"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("Direction", "Input"))) { + return NPT_FAILURE; + } + if (NPT_FAILED(action->SetArgumentValue("Status", "Unknown"))) { + return NPT_FAILURE; + } + + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSetAVTransportURI(PLT_ActionReference& action) { char the_url[4096], szVal[100]; - NPT_String url_id; + NPT_String url_id; const char *MediaUri; - if (NPT_FAILED(action->GetArgumentValue("CurrentURI", url_id))) { - return NPT_FAILURE; + if (NPT_FAILED(action->GetArgumentValue("CurrentURI", url_id))) { + return NPT_FAILURE; } MediaUri = url_id; if (!MediaUri) return NPT_FAILURE; @@ -466,22 +466,22 @@ NPT_Result GPAC_MediaRenderer::OnSetAVTransportURI(PLT_ActionReference& action) m_connected = GF_TRUE; m_pUPnP->OnConnect(the_url, m_ip_src); /* Set UPnP datas */ - m_pAVService->SetStateVariable("TransportState", "PLAYING"); - m_pAVService->SetStateVariable("AVTransportURI", the_url); + m_pAVService->SetStateVariable("TransportState", "PLAYING"); + m_pAVService->SetStateVariable("AVTransportURI", the_url); sprintf(szVal, "%d", gf_list_count(m_mediaHistoryList)); - m_pAVService->SetStateVariable("NumberOfTracks", szVal); + m_pAVService->SetStateVariable("NumberOfTracks", szVal); sprintf(szVal, "%d", m_track_pos); - m_pAVService->SetStateVariable("CurrentTrack", szVal); + m_pAVService->SetStateVariable("CurrentTrack", szVal); return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnPause(PLT_ActionReference& action) { GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Request: change state : PAUSE\n")); - m_pAVService->SetStateVariable("TransportState", "PAUSED_PLAYBACK"); + m_pAVService->SetStateVariable("TransportState", "PAUSED_PLAYBACK"); m_pUPnP->OnPause(GF_FALSE, m_ip_src); - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnPlay(PLT_ActionReference& action) @@ -490,19 +490,19 @@ NPT_Result GPAC_MediaRenderer::OnPlay(PLT_ActionReference& action) /* if nothing playing, connect to first media of mediaHistoryList */ if (m_connected) { - m_pAVService->SetStateVariable("TransportState", "PLAYING"); + m_pAVService->SetStateVariable("TransportState", "PLAYING"); m_pUPnP->OnPause(GF_TRUE, m_ip_src); } else if (gf_list_count(m_mediaHistoryList) >= 1) { char *track = (char *) gf_list_get(m_mediaHistoryList, 0); m_track_pos = 1; GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Reading first media : %s\n", track)); - m_pAVService->SetStateVariable("TransportState", "PLAYING"); + m_pAVService->SetStateVariable("TransportState", "PLAYING"); m_connected = GF_TRUE; m_pUPnP->OnConnect(track, m_ip_src); //MRSetTrack(track, upnph->TrackPosition); } - return NPT_SUCCESS; + return NPT_SUCCESS; } @@ -510,7 +510,7 @@ NPT_Result GPAC_MediaRenderer::OnStop(PLT_ActionReference& action) { GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Request: change state : STOP\n")); if (m_pUPnP->m_pTerm->root_scene) { - m_pAVService->SetStateVariable("TransportState", "STOPPED"); + m_pAVService->SetStateVariable("TransportState", "STOPPED"); m_pUPnP->OnStop(m_ip_src); } return NPT_SUCCESS; @@ -518,60 +518,60 @@ NPT_Result GPAC_MediaRenderer::OnStop(PLT_ActionReference& action) NPT_Result GPAC_MediaRenderer::OnPrevious(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnNext(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSeek(PLT_ActionReference& action) { u32 h, m, s; Double time; - NPT_String unit, target; - if (NPT_FAILED(action->GetArgumentValue("Unit", unit))) { - return NPT_FAILURE; + NPT_String unit, target; + if (NPT_FAILED(action->GetArgumentValue("Unit", unit))) { + return NPT_FAILURE; } - if (NPT_FAILED(action->GetArgumentValue("Target", target))) { - return NPT_FAILURE; + if (NPT_FAILED(action->GetArgumentValue("Target", target))) { + return NPT_FAILURE; } if ((unit!="ABS_TIME") && (unit!="REL_TIME")) { action->SetError(710,"Seek mode not supported"); - return NPT_FAILURE; + return NPT_FAILURE; } sscanf(target, "%d:%d:%d", &h, &m, &s); time = h*3600.0 + m*60.0 + s; m_pUPnP->OnSeek(time); - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSetPlayMode(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSetVolume(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSetVolumeDB(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnSetMute(PLT_ActionReference& action) { - return NPT_SUCCESS; + return NPT_SUCCESS; } NPT_Result GPAC_MediaRenderer::OnGetVolumeDBRange(PLT_ActionReference& action ) { - return NPT_SUCCESS; + return NPT_SUCCESS; } void GPAC_MediaRenderer::SetDuration(Double duration, Bool can_seek) @@ -579,7 +579,7 @@ void GPAC_MediaRenderer::SetDuration(Double duration, Bool can_seek) char szVal[100]; format_time_string(szVal, duration); m_Duration = duration; - m_pAVService->SetStateVariable("CurrentTrackDuration", szVal); + m_pAVService->SetStateVariable("CurrentTrackDuration", szVal); } void GPAC_MediaRenderer::SetTime(Double time) @@ -587,14 +587,14 @@ void GPAC_MediaRenderer::SetTime(Double time) char szVal[100]; format_time_string(szVal, time); m_Time = time; - m_pAVService->SetStateVariable("RelativeTimePosition", szVal); - m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal); + m_pAVService->SetStateVariable("RelativeTimePosition", szVal); + m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal); } void GPAC_MediaRenderer::SetConnected(const char *url) { - m_pAVService->SetStateVariable("AVTransportURI", url); - m_pAVService->SetStateVariable("CurrentTrackURI", url); - m_pAVService->SetStateVariable("TransportState", "PLAYING"); + m_pAVService->SetStateVariable("AVTransportURI", url); + m_pAVService->SetStateVariable("CurrentTrackURI", url); + m_pAVService->SetStateVariable("TransportState", "PLAYING"); m_connected = url ? GF_TRUE : GF_FALSE; } diff --git a/modules/platinum/GPACMediaRenderer.h b/modules/platinum/GPACMediaRenderer.h index c9778cf..b60c26b 100644 --- a/modules/platinum/GPACMediaRenderer.h +++ b/modules/platinum/GPACMediaRenderer.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -40,17 +40,17 @@ class GF_UPnP; class GPAC_MediaRenderer : public PLT_DeviceHost, - public PLT_MediaRendererDelegate + public PLT_MediaRendererDelegate { public: - GPAC_MediaRenderer (GF_UPnP *upnp, const char* friendly_name, - bool show_ip = false, - const char* uuid = NULL, - unsigned int port = 0); + GPAC_MediaRenderer (GF_UPnP *upnp, const char* friendly_name, + bool show_ip = false, + const char* uuid = NULL, + unsigned int port = 0); - // PLT_DeviceHost methods - virtual NPT_Result SetupServices(); - virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext& context); + // PLT_DeviceHost methods + virtual NPT_Result SetupServices(); + virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext& context); /*these are called when event filtering is used (no JS)*/ void SetDuration(Double duration, Bool can_seek); @@ -58,28 +58,28 @@ public: void SetConnected(const char *url); protected: - virtual ~GPAC_MediaRenderer(); - - // PLT_MediaRendererInterface methods - // ConnectionManager - virtual NPT_Result OnGetCurrentConnectionInfo(PLT_ActionReference& action); - - // AVTransport - virtual NPT_Result OnNext(PLT_ActionReference& action); - virtual NPT_Result OnPause(PLT_ActionReference& action); - virtual NPT_Result OnPlay(PLT_ActionReference& action); - virtual NPT_Result OnPrevious(PLT_ActionReference& action); - virtual NPT_Result OnSeek(PLT_ActionReference& action); - virtual NPT_Result OnStop(PLT_ActionReference& action); - virtual NPT_Result OnSetAVTransportURI(PLT_ActionReference& action); - virtual NPT_Result OnSetPlayMode(PLT_ActionReference& action); - - // RenderingControl - //virtual NPT_Result OnGetVolume(PLT_ActionReference& action); - virtual NPT_Result OnSetVolume(PLT_ActionReference& action); - virtual NPT_Result OnSetVolumeDB(PLT_ActionReference& action); - virtual NPT_Result OnSetMute(PLT_ActionReference& action); - virtual NPT_Result OnGetVolumeDBRange(PLT_ActionReference &action); + virtual ~GPAC_MediaRenderer(); + + // PLT_MediaRendererInterface methods + // ConnectionManager + virtual NPT_Result OnGetCurrentConnectionInfo(PLT_ActionReference& action); + + // AVTransport + virtual NPT_Result OnNext(PLT_ActionReference& action); + virtual NPT_Result OnPause(PLT_ActionReference& action); + virtual NPT_Result OnPlay(PLT_ActionReference& action); + virtual NPT_Result OnPrevious(PLT_ActionReference& action); + virtual NPT_Result OnSeek(PLT_ActionReference& action); + virtual NPT_Result OnStop(PLT_ActionReference& action); + virtual NPT_Result OnSetAVTransportURI(PLT_ActionReference& action); + virtual NPT_Result OnSetPlayMode(PLT_ActionReference& action); + + // RenderingControl + //virtual NPT_Result OnGetVolume(PLT_ActionReference& action); + virtual NPT_Result OnSetVolume(PLT_ActionReference& action); + virtual NPT_Result OnSetVolumeDB(PLT_ActionReference& action); + virtual NPT_Result OnSetMute(PLT_ActionReference& action); + virtual NPT_Result OnGetVolumeDBRange(PLT_ActionReference &action); private: @@ -88,8 +88,8 @@ private: Bool m_connected; /*pointer to the AV service for further StateVariable modifications*/ - PLT_Service *m_pAVService; - PLT_Service *m_pMigrationService; + PLT_Service *m_pAVService; + PLT_Service *m_pMigrationService; GF_List *m_mediaHistoryList; u32 m_track_pos; diff --git a/modules/platinum/GPACPlatinum.cpp b/modules/platinum/GPACPlatinum.cpp index b6f9799..4f3c297 100644 --- a/modules/platinum/GPACPlatinum.cpp +++ b/modules/platinum/GPACPlatinum.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -37,37 +37,37 @@ void upnp_delete(GF_BaseInterface *ifce); #ifdef __cplusplus extern "C" { #endif - - - GPAC_MODULE_EXPORT - const u32 *QueryInterfaces() - { - static u32 si [] = { - GF_TERM_EXT_INTERFACE, - 0 - }; - return si; - } - - GPAC_MODULE_EXPORT - GF_BaseInterface *LoadInterface(u32 InterfaceType) - { - if (InterfaceType == GF_TERM_EXT_INTERFACE) return (GF_BaseInterface *)upnp_new(); - return NULL; - } - - GPAC_MODULE_EXPORT - void ShutdownInterface(GF_BaseInterface *ifce) - { - switch (ifce->InterfaceType) { - case GF_TERM_EXT_INTERFACE: - upnp_delete(ifce); - break; - } - } - - GPAC_MODULE_STATIC_DELARATION( platinum ) - + + +GPAC_MODULE_EXPORT +const u32 *QueryInterfaces() +{ + static u32 si [] = { + GF_TERM_EXT_INTERFACE, + 0 + }; + return si; +} + +GPAC_MODULE_EXPORT +GF_BaseInterface *LoadInterface(u32 InterfaceType) +{ + if (InterfaceType == GF_TERM_EXT_INTERFACE) return (GF_BaseInterface *)upnp_new(); + return NULL; +} + +GPAC_MODULE_EXPORT +void ShutdownInterface(GF_BaseInterface *ifce) +{ + switch (ifce->InterfaceType) { + case GF_TERM_EXT_INTERFACE: + upnp_delete(ifce); + break; + } +} + +GPAC_MODULE_STATIC_DELARATION( platinum ) + #ifdef __cplusplus } #endif @@ -92,12 +92,12 @@ extern "C" { GF_UPnP::GF_UPnP() { m_pTerm = NULL; - m_pPlatinum = NULL; + m_pPlatinum = NULL; m_pMediaRenderer = NULL; m_pMediaServer = NULL; m_pAVCtrlPoint = NULL; m_renderer_bound = GF_FALSE; - m_pGenericController = NULL; + m_pGenericController = NULL; #ifdef GPAC_HAS_SPIDERMONKEY m_Devices = NULL; @@ -177,7 +177,7 @@ NPT_String GF_UPnP::OnMigrate() } #ifdef GPAC_HAS_SPIDERMONKEY -jsval GF_UPnP::GetUPnPDevice(const char *src_url) +jsval GF_UPnP::GetUPnPDevice(const char *src_url) { return src_url ? STRING_TO_JSVAL( JS_NewStringCopyZ(m_pJSCtx, src_url ) ) : JSVAL_NULL; } @@ -242,8 +242,8 @@ void GF_UPnP::OnSeek(Double time) } else { /* CanSeek and Duration set for each media by event_proc */ if (!m_pTerm->root_scene || (m_pTerm->root_scene->root_od->flags & GF_ODM_NO_TIME_CTRL) - || (m_pTerm->root_scene->duration<2000) - ) { + || (m_pTerm->root_scene->duration<2000) + ) { GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[UPnP] Scene not seekable\n")); } else { gf_term_play_from_time(m_pTerm, (u64) (time * 1000), 0); @@ -308,7 +308,7 @@ Bool GF_UPnP::ProcessEvent(GF_Event *evt) break; case GF_EVENT_DURATION: - m_pMediaRenderer->SetDuration(evt->duration.duration, evt->duration.can_seek); + m_pMediaRenderer->SetDuration(evt->duration.duration, evt->duration.can_seek); case GF_EVENT_METADATA: if (m_pTerm->root_scene) { char szName[1024]; @@ -318,8 +318,15 @@ Bool GF_UPnP::ProcessEvent(GF_Event *evt) /*get any service info*/ if (gf_term_get_service_info(m_pTerm, m_pTerm->root_scene->root_od, &com) == GF_OK) { strcpy(szName, ""); - if (com.name) { strcat(szName, com.name); strcat(szName, " "); } - if (com.album) { strcat(szName, "("); strcat(szName, com.album); strcat(szName, ")"); } + if (com.name) { + strcat(szName, com.name); + strcat(szName, " "); + } + if (com.album) { + strcat(szName, "("); + strcat(szName, com.album); + strcat(szName, ")"); + } /*const char *artist = "Unknown"; if (com.artist) artist = com.artist; @@ -382,7 +389,7 @@ void GF_UPnP::Load(GF_Terminal *term) opt = gf_cfg_get_key(m_pTerm->user->config, "UPnP", "SaveUUIDs"); if (opt && !strcmp(opt, "yes")) save_uuids = GF_TRUE; - + opt = gf_cfg_get_key(m_pTerm->user->config, "UPnP", "MediaRendererEnabled"); if (!opt || !strcmp(opt, "yes")) { if (!opt) gf_cfg_set_key(m_pTerm->user->config, "UPnP", "MediaRendererEnabled", "yes"); @@ -392,7 +399,7 @@ void GF_UPnP::Load(GF_Terminal *term) sprintf(friendly_name, "GPAC @ %s", hostname); name = friendly_name; } - + port = 0; opt = gf_cfg_get_key(m_pTerm->user->config, "UPnP", "MediaRendererPort"); if (opt) port = atoi(opt); @@ -428,7 +435,7 @@ void GF_UPnP::Load(GF_Terminal *term) sprintf(friendly_name, "GPAC @ %s", hostname); name = friendly_name; } - + port = 0; opt = gf_cfg_get_key(m_pTerm->user->config, "UPnP", "MediaServerPort"); if (opt) port = atoi(opt); @@ -467,7 +474,7 @@ void GF_UPnP::Load(GF_Terminal *term) media_root = sep2+1; } } - PLT_DeviceHostReference device(m_pMediaServer); + PLT_DeviceHostReference device(m_pMediaServer); device->m_ModelDescription = "GPAC Media Server"; device->m_ModelURL = "http://gpac.sourceforge.net"; device->m_ModelNumber = GPAC_FULL_VERSION; @@ -499,7 +506,7 @@ void GF_UPnP::Load(GF_Terminal *term) m_pAVCtrlPoint = new GPAC_MediaController(m_ctrlPtRef, this); } - // add control point to upnp engine + // add control point to upnp engine if (m_pCtrlPoint) { if (ignore_local_devices) { if (m_pMediaServer) m_pCtrlPoint->IgnoreUUID(m_pMediaServer->GetUUID()); @@ -514,7 +521,7 @@ void GF_UPnP::Load(GF_Terminal *term) //start UPnP engine m_pPlatinum->Start(); - + /*if we have a control point, force a rescan of the network servcies*/ if (m_pCtrlPoint) { m_pCtrlPoint->Search(); @@ -530,7 +537,7 @@ void GF_UPnP::Unload() delete m_pPlatinum; /*final cleanup of UPnP lib*/ - NPT_AutomaticCleaner::Shutdown(); + NPT_AutomaticCleaner::Shutdown(); } @@ -551,7 +558,7 @@ void GF_UPnP::OnMediaRendererAdd(PLT_DeviceDataReference& device, int added) argv[0] = STRING_TO_JSVAL( JS_NewStringCopyZ(m_pJSCtx, device->GetFriendlyName() ) ); argv[1] = STRING_TO_JSVAL( JS_NewStringCopyZ(m_pJSCtx, device->GetUUID() ) ); argv[2] = BOOLEAN_TO_JSVAL( added ? JS_TRUE : JS_FALSE); - + JS_CallFunctionValue(m_pJSCtx, m_pObj, funval, 3, argv, &rval); } LockJavascript(GF_FALSE); @@ -572,7 +579,7 @@ void GF_UPnP::OnMediaServerAdd(PLT_DeviceDataReference& device, int added) argv[0] = STRING_TO_JSVAL( JS_NewStringCopyZ(m_pJSCtx, device->GetFriendlyName() ) ); argv[1] = STRING_TO_JSVAL( JS_NewStringCopyZ(m_pJSCtx, device->GetUUID() ) ); argv[2] = BOOLEAN_TO_JSVAL( added ? JS_TRUE : JS_FALSE); - + JS_CallFunctionValue(m_pJSCtx, m_pObj, funval, 3, argv, &rval); } LockJavascript(GF_FALSE); @@ -610,14 +617,14 @@ static SMJS_DECL_FUNC_PROP_GET( upnpdevice_getProperty) } VPASSIGN( INT_TO_JSVAL(count) ); } - SMJS_FREE(c, prop_name); + SMJS_FREE(c, prop_name); return JS_TRUE; } #ifdef GPAC_UNUSED_FUNC static JSBool upnp_device_subscribe(JSContext *c, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { - PLT_Service* service; + PLT_Service* service; char *service_uuid; GPAC_DeviceItem *item = (GPAC_DeviceItem *)SMJS_GET_PRIVATE(c, obj); if (!item || (argc!=2) ) return JS_FALSE; @@ -911,7 +918,7 @@ static JSBool SMJS_FUNCTION(upnp_renderer_open) if (!JS_LookupProperty(c, fobj, "ObjectID", &val) || JSVAL_IS_NULL(val) || !JSVAL_IS_STRING(val)) return JS_TRUE; item = SMJS_CHARS(c, val); } - else if (JSVAL_IS_STRING(argv[0])) + else if (JSVAL_IS_STRING(argv[0])) resource_url = SMJS_CHARS(c, argv[0]); if (!item && !resource_url) { @@ -925,10 +932,10 @@ static JSBool SMJS_FUNCTION(upnp_renderer_open) return JS_TRUE; } - if (NPT_SUCCEEDED(render->m_device->FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service))) { + if (NPT_SUCCEEDED(render->m_device->FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service))) { if (resource_url) { upnp->m_pAVCtrlPoint->m_MediaController->SetAVTransportURI(render->m_device, 0, resource_url, NULL, NULL); - upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, "1", NULL); + upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, "1", NULL); } else { NPT_String objID = item; @@ -938,7 +945,7 @@ static JSBool SMJS_FUNCTION(upnp_renderer_open) if ((*item)->m_ObjectID == objID) { if ((*item)->m_Resources.GetItemCount()) { upnp->m_pAVCtrlPoint->m_MediaController->SetAVTransportURI(render->m_device, 0, (*item)->m_Resources[0].m_Uri, (*item)->m_Didl, NULL); - upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, "1", NULL); + upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, "1", NULL); } break; } @@ -972,15 +979,15 @@ static JSBool SMJS_FUNCTION_EXT(upnp_renderer_playback, u32 act_type) JS_ValueToNumber(c, argv[0], &d); sprintf(szSpeed, "%2.2f", d); } - upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, szSpeed, NULL); + upnp->m_pAVCtrlPoint->m_MediaController->Play(render->m_device, 0, szSpeed, NULL); break; /*pause*/ case 1: - upnp->m_pAVCtrlPoint->m_MediaController->Pause(render->m_device, 0, NULL); + upnp->m_pAVCtrlPoint->m_MediaController->Pause(render->m_device, 0, NULL); break; /*stop*/ case 2: - upnp->m_pAVCtrlPoint->m_MediaController->Stop(render->m_device, 0, NULL); + upnp->m_pAVCtrlPoint->m_MediaController->Stop(render->m_device, 0, NULL); break; /*seek*/ case 3: @@ -1082,11 +1089,11 @@ static JSBool SMJS_FUNCTION(upnp_server_browse) SMJS_FREE(c, _filter); return JS_FALSE; } - server->m_ParentDirectories.Pop(parent); - server->m_ParentDirectories.Peek(parent); + server->m_ParentDirectories.Pop(parent); + server->m_ParentDirectories.Peek(parent); dir=parent; - if (server->m_ParentDirectories.GetItemCount()==1) + if (server->m_ParentDirectories.GetItemCount()==1) server->m_ParentDirectories.Clear(); } else { @@ -1165,7 +1172,7 @@ static JSBool SMJS_FUNCTION(upnp_server_get_file) if (!mo->IsContainer()) { JS_DefineProperty(c, f_obj, "ResourceCount", INT_TO_JSVAL(mo->m_Resources.GetItemCount()), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(c, f_obj, "GetResourceURI", upnp_server_get_resource_uri, 1, 0); - } + } SMJS_SET_RVAL( OBJECT_TO_JSVAL(f_obj)); return JS_TRUE; } @@ -1512,12 +1519,12 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) SMJS_FUNCTION_SPEC("BindRenderer", upnp_bind_renderer, 0), SMJS_FUNCTION_SPEC("GetMediaServer", upnp_get_server, 1), SMJS_FUNCTION_SPEC("GetMediaRenderer", upnp_get_renderer, 1), - SMJS_FUNCTION_SPEC("ShareResource", upnp_share_resource, 1), - SMJS_FUNCTION_SPEC("ShareVirtualResource", upnp_share_virtual_resource, 2), - SMJS_FUNCTION_SPEC("GetDevice", upnp_get_device, 1), - SMJS_FUNCTION_SPEC("FindService", upnp_find_service, 1), - SMJS_FUNCTION_SPEC("CreateDevice", upnp_create_device, 2), - SMJS_FUNCTION_SPEC("DeleteDevice", upnp_delete_device, 1), + SMJS_FUNCTION_SPEC("ShareResource", upnp_share_resource, 1), + SMJS_FUNCTION_SPEC("ShareVirtualResource", upnp_share_virtual_resource, 2), + SMJS_FUNCTION_SPEC("GetDevice", upnp_get_device, 1), + SMJS_FUNCTION_SPEC("FindService", upnp_find_service, 1), + SMJS_FUNCTION_SPEC("CreateDevice", upnp_create_device, 2), + SMJS_FUNCTION_SPEC("DeleteDevice", upnp_delete_device, 1), SMJS_FUNCTION_SPEC(0, 0, 0) }; @@ -1571,7 +1578,7 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) SMJS_SET_PRIVATE(m_pJSCtx, m_pObj, this); JS_SETUP_CLASS(upnpDeviceClass, "UPNPAVDEVICE", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - + /*setup JS bindings*/ JSPropertySpec upnpDeviceClassProps[] = { SMJS_PROPERTY_SPEC(0, 0, 0, 0, 0) @@ -1583,12 +1590,12 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) }; JS_SETUP_CLASS(upnpGenericDeviceClass, "UPNPDEVICE", JSCLASS_HAS_PRIVATE, upnpdevice_getProperty, JS_PropertyStub_forSetter, JS_FinalizeStub); GF_JS_InitClass(m_pJSCtx, (JSObject*)param->global, 0, &upnpGenericDeviceClass, 0, 0, upnpDeviceClassProps, upnpDeviceClassFuncs, 0, 0); - + JS_SETUP_CLASS(upnpServiceClass, "UPNPSERVICEDEVICE", JSCLASS_HAS_PRIVATE, upnpservice_getProperty, JS_PropertyStub_forSetter, JS_FinalizeStub); GF_JS_InitClass(m_pJSCtx, (JSObject*)param->global, 0, &upnpServiceClass, 0, 0, 0, 0, 0, 0); m_nbJSInstances=1; - + upnp_init_time = gf_sys_clock(); count = gf_cfg_get_key_count(m_pTerm->user->config, "UPnPDevices"); @@ -1598,7 +1605,7 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) const char *dev = gf_cfg_get_key(m_pTerm->user->config, "UPnPDevices", device_id); if (!strncmp(dev, "off;", 4)) continue; - + if (!strncmp(dev, "on;", 3)) dev += 3; sep = (char*)strchr(dev, ';'); @@ -1606,7 +1613,7 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) sep[0] = 0; strcpy(szFile, dev); sep[0] = ';'; - + if (!sep[1]) continue; strcpy(szFriendlyName, sep+1); @@ -1675,7 +1682,7 @@ static Bool upnp_process(GF_TermExt *termext, u32 action, void *param) u32 now; now = gf_sys_clock() - upnp->upnp_init_time; if (now - upnp->last_time > 200) { - u32 i, count, arg_set; + u32 i, count, arg_set; jsval argv[1], rval; upnp->LockJavascript(GF_TRUE); arg_set = 0; diff --git a/modules/platinum/GPACPlatinum.h b/modules/platinum/GPACPlatinum.h index 1264017..c9ef06f 100644 --- a/modules/platinum/GPACPlatinum.h +++ b/modules/platinum/GPACPlatinum.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -75,8 +75,8 @@ public: GF_Terminal *m_pTerm; /*Platinum's UPnP stack*/ - PLT_UPnP *m_pPlatinum; - + PLT_UPnP *m_pPlatinum; + /*GPAC UPnP/DLNA media renderer if loaded*/ GPAC_MediaRenderer *m_pMediaRenderer; /*is renderer bound to the script ? If so, events are dispatched to the script's "UPnP" object*/ @@ -143,11 +143,11 @@ public: SMJS_DECL_FUNC_PROP_GET( upnpservice_getProperty); #ifdef USE_FFDEV_17 - #define VPASSIGN(__b) __vp.set( __b ) - #define VPGET() (jsval) __vp +#define VPASSIGN(__b) __vp.set( __b ) +#define VPGET() (jsval) __vp #else - #define VPASSIGN(__b) *vp = __b - #define VPGET() *vp +#define VPASSIGN(__b) *vp = __b +#define VPGET() *vp #endif #endif diff --git a/modules/platinum/GenericDevice.cpp b/modules/platinum/GenericDevice.cpp index f8ebe7a..3b2e002 100644 --- a/modules/platinum/GenericDevice.cpp +++ b/modules/platinum/GenericDevice.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -35,7 +35,7 @@ NPT_SET_LOCAL_LOGGER("gpac.genericdevice") -GPAC_ServiceItem::GPAC_ServiceItem(GPAC_DeviceItem *device, PLT_Service *service) : m_device(device), m_service(service) +GPAC_ServiceItem::GPAC_ServiceItem(GPAC_DeviceItem *device, PLT_Service *service) : m_device(device), m_service(service) { #ifdef GPAC_HAS_SPIDERMONKEY obj = NULL; @@ -47,7 +47,7 @@ GPAC_ServiceItem::GPAC_ServiceItem(GPAC_DeviceItem *device, PLT_Service *service #endif } -GPAC_ServiceItem::~GPAC_ServiceItem() +GPAC_ServiceItem::~GPAC_ServiceItem() { #ifdef GPAC_HAS_SPIDERMONKEY DetachJS(); @@ -57,7 +57,7 @@ GPAC_ServiceItem::~GPAC_ServiceItem() } #ifdef GPAC_HAS_SPIDERMONKEY -void GPAC_ServiceItem::DetachJS() +void GPAC_ServiceItem::DetachJS() { if (obj) { gf_js_remove_root(js_ctx, &obj, GF_JSGC_OBJECT); @@ -84,9 +84,9 @@ void GPAC_ServiceItem::DetachJS() #endif -GPAC_DeviceItem::GPAC_DeviceItem(PLT_DeviceDataReference device, NPT_String uuid) - : m_device(device), m_UUID(uuid) -{ +GPAC_DeviceItem::GPAC_DeviceItem(PLT_DeviceDataReference device, NPT_String uuid) + : m_device(device), m_UUID(uuid) +{ #ifdef GPAC_HAS_SPIDERMONKEY obj = NULL; js_ctx = NULL; @@ -94,7 +94,7 @@ GPAC_DeviceItem::GPAC_DeviceItem(PLT_DeviceDataReference device, NPT_String uuid #endif } -GPAC_DeviceItem::~GPAC_DeviceItem() +GPAC_DeviceItem::~GPAC_DeviceItem() { #ifdef GPAC_HAS_SPIDERMONKEY DetachJS(); @@ -185,7 +185,7 @@ static JSBool SMJS_FUNCTION(upnp_service_set_action_listener) SMJS_ARGS GPAC_ServiceItem *service = (GPAC_ServiceItem *)SMJS_GET_PRIVATE(c, obj); if (!service || (argc<2) || !JSVAL_IS_STRING(argv[0]) || !JSVAL_IS_OBJECT(argv[1])) return JS_FALSE; - + name = SMJS_CHARS(c, argv[0]); if (!name) return JS_FALSE; @@ -238,7 +238,7 @@ static JSBool SMJS_FUNCTION(upnp_service_get_scpd) NPT_String name; SMJS_OBJ GPAC_ServiceItem *service = (GPAC_ServiceItem *)SMJS_GET_PRIVATE(c, obj); - if (!service ) + if (!service ) return JS_FALSE; service->m_service->GetSCPDXML(name); @@ -278,7 +278,7 @@ static JSBool SMJS_FUNCTION(upnp_service_has_var) SMJS_OBJ SMJS_ARGS GPAC_ServiceItem *service = (GPAC_ServiceItem *)SMJS_GET_PRIVATE(c, obj); - if (!service || !argc || !JSVAL_IS_STRING(argv[0]) ) + if (!service || !argc || !JSVAL_IS_STRING(argv[0]) ) return JS_FALSE; name = SMJS_CHARS(c, argv[0]); @@ -329,11 +329,11 @@ static JSBool SMJS_FUNCTION(upnp_service_call_action) PLT_ActionReference action; NPT_CHECK_SEVERE( - service->m_device->m_pUPnP->m_pGenericController->m_CtrlPoint->CreateAction( - service->m_device->m_device, - service->m_service->GetServiceType(), - action_name, - action) + service->m_device->m_pUPnP->m_pGenericController->m_CtrlPoint->CreateAction( + service->m_device->m_device, + service->m_service->GetServiceType(), + action_name, + action) ); @@ -380,11 +380,11 @@ static JSBool SMJS_FUNCTION(upnp_service_call_action) SMJS_FREE(c, _param_val); if (res != NPT_SUCCESS) return JS_FALSE; - + i+=2; } GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, (" )\n")); - } + } if ((argc==3) && JSVAL_IS_OBJECT(argv[2])) { act_udta = new GPAC_ActionUDTA(); @@ -416,7 +416,7 @@ GPAC_ServiceItem *GPAC_DeviceItem::FindService(const char *type) count = gf_list_count(m_Services); for (i=0; im_service->GetServiceType() == type) + if (serv->m_service->GetServiceType() == type) return serv; } @@ -424,7 +424,7 @@ GPAC_ServiceItem *GPAC_DeviceItem::FindService(const char *type) if (m_device->FindServiceByType(type, service) != NPT_SUCCESS) return NULL; serv = new GPAC_ServiceItem(this, service); - + #ifdef GPAC_HAS_SPIDERMONKEY serv->js_ctx = js_ctx; serv->obj = JS_NewObject(serv->js_ctx, &m_pUPnP->upnpServiceClass._class, 0, obj); @@ -439,7 +439,7 @@ GPAC_ServiceItem *GPAC_DeviceItem::FindService(const char *type) JS_DefineFunction(serv->js_ctx, serv->obj, "CallAction", upnp_service_call_action, 2, 0); JS_DefineFunction(serv->js_ctx, serv->obj, "SetActionListener", upnp_service_set_action_listener, 2, 0); JS_DefineFunction(serv->js_ctx, serv->obj, "GetSCPD", upnp_service_get_scpd, 1, 0); - + #endif gf_list_add(m_Services, serv); @@ -451,14 +451,14 @@ GPAC_GenericController::GPAC_GenericController(PLT_CtrlPointReference& ctrlPoint { m_pUPnP = upnp; m_CtrlPoint = ctrlPoint; - m_CtrlPoint->AddListener(this); + m_CtrlPoint->AddListener(this); m_ControlPointLock = gf_mx_new("GenericController"); m_Devices = gf_list_new(); } GPAC_GenericController::~GPAC_GenericController() { - m_CtrlPoint->RemoveListener(this); + m_CtrlPoint->RemoveListener(this); gf_mx_del(m_ControlPointLock); while (gf_list_count(m_Devices)) { GPAC_DeviceItem*ms = (GPAC_DeviceItem*)gf_list_get(m_Devices, 0); @@ -567,14 +567,14 @@ NPT_Result GPAC_GenericController::OnActionResponse(NPT_Result res, PLT_ActionRe PLT_Service* service = action->GetActionDesc().GetService(); NPT_String uuid; GPAC_ActionUDTA *act_udta = (GPAC_ActionUDTA *)userdata; - + /*this is NOT an actionResponse to an action triggered on a generic device*/ if (act_udta && act_udta->m_Reserved) act_udta = NULL; GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Receive %s Response - error code %d\n", (char *) action->GetActionDesc().GetName(), res)); gf_mx_p(m_ControlPointLock); - + /*get our device*/ uuid = service->GetDevice()->GetUUID(); count = gf_list_count(m_Devices); @@ -614,7 +614,7 @@ NPT_Result GPAC_GenericController::OnActionResponse(NPT_Result res, PLT_ActionRe if (argl->arg==NULL) { act_l = argl; continue; - } + } /*if error don't trigger listeners*/ if (res != NPT_SUCCESS) { GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[UPnP] Receive %s Response: error on remote device %d\n", (char *) action->GetActionDesc().GetName(), res)); @@ -692,7 +692,7 @@ NPT_Result GPAC_GenericController::OnEventNotify(PLT_Service* service, NPT_List< GPAC_StateVariableListener *svl; gf_mx_p(m_ControlPointLock); - + NPT_String uuid = service->GetDevice()->GetUUID(); count = gf_list_count(m_Devices); for (i=0; im_Services); for (i=0; im_Services, i); @@ -852,9 +852,9 @@ GPAC_GenericDevice::SetupServices() count = gf_list_count(m_pServices); for (i=0; iGetActionDesc(); - NPT_String name = act_desc.GetName(); + NPT_String name = act_desc.GetName(); #ifdef GPAC_HAS_SPIDERMONKEY assert(!m_pSema); #endif GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Action %s called (thread %d)\n", (char *) name, gf_th_id() )); - + #ifdef GPAC_HAS_SPIDERMONKEY if (JSVAL_IS_NULL(act_proc)) { gf_mx_v(m_pMutex); @@ -969,7 +969,7 @@ GPAC_GenericDevice::OnAction(PLT_ActionReference& action, JSObject *js_action = JS_NewObject(m_pUPnP->m_pJSCtx, &m_pUPnP->upnpDeviceClass._class, 0, 0); argv[0] = OBJECT_TO_JSVAL(js_action); SMJS_SET_PRIVATE(m_pUPnP->m_pJSCtx, js_action, this); - + act_ref = action; JS_DefineProperty(m_pUPnP->m_pJSCtx, js_action, "Name", STRING_TO_JSVAL( JS_NewStringCopyZ(m_pUPnP->m_pJSCtx, name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -987,7 +987,7 @@ GPAC_GenericDevice::OnAction(PLT_ActionReference& action, m_pUPnP->LockJavascript(GF_FALSE); if (JSVAL_IS_INT(rval) && (JSVAL_TO_INT(rval) != 0)) { - action->SetError(JSVAL_TO_INT(rval), "Action Failed"); + action->SetError(JSVAL_TO_INT(rval), "Action Failed"); } /*wait on the semaphore*/ if (!gf_sema_wait_for(m_pSema, 10000)) { diff --git a/modules/platinum/GenericDevice.h b/modules/platinum/GenericDevice.h index 410baa9..0b324e2 100644 --- a/modules/platinum/GenericDevice.h +++ b/modules/platinum/GenericDevice.h @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * - * This file is part of GPAC / Platinum UPnP module + * This file is part of GPAC / Platinum UPnP module * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * ---------------------------------------------------------------------------------- @@ -98,10 +98,13 @@ public: Bool is_script; }; -class GPAC_ActionUDTA +class GPAC_ActionUDTA { public: - GPAC_ActionUDTA() { m_Reserved = NULL; udta = JSVAL_NULL;} + GPAC_ActionUDTA() { + m_Reserved = NULL; + udta = JSVAL_NULL; + } /*members*/ /*this is used to differentiate browse request from JS (using BrowseDataReference) @@ -141,14 +144,14 @@ public: class GPAC_GenericController : public PLT_CtrlPointListener { public: - GPAC_GenericController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp); - ~GPAC_GenericController(); + GPAC_GenericController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp); + ~GPAC_GenericController(); /*any device control point*/ - virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device); - virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device); - virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata); - virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List* vars); + virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device); + virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device); + virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata); + virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List* vars); GF_List *m_Devices; GF_UPnP *m_pUPnP; @@ -161,13 +164,13 @@ class GPAC_GenericDevice : public PLT_DeviceHost { public: GPAC_GenericDevice(const char* FriendlyName, const char *device_id); - virtual ~GPAC_GenericDevice(); + virtual ~GPAC_GenericDevice(); protected: - // PLT_DeviceHost methods - virtual NPT_Result SetupServices(); - virtual NPT_Result OnAction(PLT_ActionReference& action, - const PLT_HttpRequestContext& context); + // PLT_DeviceHost methods + virtual NPT_Result SetupServices(); + virtual NPT_Result OnAction(PLT_ActionReference& action, + const PLT_HttpRequestContext& context); public: GF_UPnP *m_pUPnP; GF_List *m_pServices; diff --git a/modules/pulseaudio/pulseaudio.c b/modules/pulseaudio/pulseaudio.c index 900c824..d40ba40 100644 --- a/modules/pulseaudio/pulseaudio.c +++ b/modules/pulseaudio/pulseaudio.c @@ -37,28 +37,28 @@ typedef struct { - pa_simple *playback_handle; - pa_sample_spec sample_spec; - const char *output_name; - const char *output_description; - u32 errors; - u32 consecutive_zero_reads; + pa_simple *playback_handle; + pa_sample_spec sample_spec; + const char *output_name; + const char *output_description; + u32 errors; + u32 consecutive_zero_reads; } PulseAudioContext; static void free_pulseaudio_resources (GF_AudioOutput * dr) { - PulseAudioContext *ctx; - if (dr == NULL) - return; - ctx = (PulseAudioContext *) dr->opaque; - if (ctx == NULL) - return; - if (ctx->playback_handle != NULL) - { - pa_simple_free (ctx->playback_handle); - } - ctx->playback_handle = NULL; + PulseAudioContext *ctx; + if (dr == NULL) + return; + ctx = (PulseAudioContext *) dr->opaque; + if (ctx == NULL) + return; + if (ctx->playback_handle != NULL) + { + pa_simple_free (ctx->playback_handle); + } + ctx->playback_handle = NULL; } static const char *MODULE_NAME = "PulseAudio"; @@ -75,57 +75,57 @@ static GF_Err PulseAudio_Setup (GF_AudioOutput * dr, void *os_handle, u32 num_buffers, u32 total_duration) { - const char *opt; - PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; - if (ctx == NULL) - return GF_BAD_PARAM; - opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, - OUTPUT_NAME); - ctx->output_name = DEFAULT_OUTPUT_NAME; - if (opt != NULL) - { - ctx->output_name = opt; - } - else - { - gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, - OUTPUT_NAME, DEFAULT_OUTPUT_NAME); - } - opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, - OUTPUT_DESCRIPTION); - ctx->output_description = DEFAULT_OUTPUT_DESCRIPTION; - if (opt != NULL) - { - ctx->output_description = opt; - } - else - { - gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, - OUTPUT_DESCRIPTION, DEFAULT_OUTPUT_DESCRIPTION); - } - return GF_OK; + const char *opt; + PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; + if (ctx == NULL) + return GF_BAD_PARAM; + opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, + OUTPUT_NAME); + ctx->output_name = DEFAULT_OUTPUT_NAME; + if (opt != NULL) + { + ctx->output_name = opt; + } + else + { + gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, + OUTPUT_NAME, DEFAULT_OUTPUT_NAME); + } + opt = gf_modules_get_option ((GF_BaseInterface *) dr, MODULE_NAME, + OUTPUT_DESCRIPTION); + ctx->output_description = DEFAULT_OUTPUT_DESCRIPTION; + if (opt != NULL) + { + ctx->output_description = opt; + } + else + { + gf_modules_set_option ((GF_BaseInterface *) dr, MODULE_NAME, + OUTPUT_DESCRIPTION, DEFAULT_OUTPUT_DESCRIPTION); + } + return GF_OK; } static void PulseAudio_Shutdown (GF_AudioOutput * dr) { - int pa_error = 0; - PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; - if (ctx == NULL) - return; - if (ctx->playback_handle) - { - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[PulseAudio] Closing PulseAudio output\n")); - pa_simple_drain (ctx->playback_handle, &pa_error); - if (pa_error) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] Error while closing PulseAudio output: %s\n", - pa_strerror (pa_error))); + int pa_error = 0; + PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; + if (ctx == NULL) + return; + if (ctx->playback_handle) + { + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[PulseAudio] Closing PulseAudio output\n")); + pa_simple_drain (ctx->playback_handle, &pa_error); + if (pa_error) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] Error while closing PulseAudio output: %s\n", + pa_strerror (pa_error))); - } - } + } + } } static GF_Err @@ -133,37 +133,37 @@ PulseAudio_ConfigureOutput (GF_AudioOutput * dr, u32 * SampleRate, u32 * NbChannels, u32 * nbBitsPerSample, u32 channel_cfg) { - int pa_error = 0; - PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; - if (ctx->playback_handle != NULL) - { - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, - ("[PulseAudio] PulseAudio output already configured !\n")); - /* Should not happen */ - pa_simple_flush (ctx->playback_handle, &pa_error); - pa_simple_free (ctx->playback_handle); - ctx->playback_handle = NULL; - } - ctx->consecutive_zero_reads = 0; - ctx->sample_spec.format = PA_SAMPLE_S16NE; - ctx->sample_spec.channels = *NbChannels; - ctx->sample_spec.rate = *SampleRate; - ctx->playback_handle = pa_simple_new (NULL, - ctx->output_name, - PA_STREAM_PLAYBACK, - NULL, - ctx->output_description, - &(ctx->sample_spec), - NULL, NULL, &pa_error); - if (ctx->playback_handle == NULL || pa_error != 0) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] Error while allocating PulseAudio output: %s.\n", - pa_strerror (pa_error))); - return GF_IO_ERR; - } - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[PulseAudio] Initialized - sampling rate %d - %d channels\n", ctx->sample_spec.rate, ctx->sample_spec.channels)); - return GF_OK; + int pa_error = 0; + PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; + if (ctx->playback_handle != NULL) + { + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, + ("[PulseAudio] PulseAudio output already configured !\n")); + /* Should not happen */ + pa_simple_flush (ctx->playback_handle, &pa_error); + pa_simple_free (ctx->playback_handle); + ctx->playback_handle = NULL; + } + ctx->consecutive_zero_reads = 0; + ctx->sample_spec.format = PA_SAMPLE_S16NE; + ctx->sample_spec.channels = *NbChannels; + ctx->sample_spec.rate = *SampleRate; + ctx->playback_handle = pa_simple_new (NULL, + ctx->output_name, + PA_STREAM_PLAYBACK, + NULL, + ctx->output_description, + &(ctx->sample_spec), + NULL, NULL, &pa_error); + if (ctx->playback_handle == NULL || pa_error != 0) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] Error while allocating PulseAudio output: %s.\n", + pa_strerror (pa_error))); + return GF_IO_ERR; + } + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[PulseAudio] Initialized - sampling rate %d - %d channels\n", ctx->sample_spec.rate, ctx->sample_spec.channels)); + return GF_OK; } #define BUFF_SIZE 8192 @@ -171,54 +171,54 @@ PulseAudio_ConfigureOutput (GF_AudioOutput * dr, u32 * SampleRate, static void PulseAudio_WriteAudio (GF_AudioOutput * dr) { - char data[BUFF_SIZE]; - int written = 0; - int pa_error = 0; - PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; - if (ctx == NULL || ctx->playback_handle == NULL) - { - if (ctx == NULL || ctx->errors == 0) - { - if (ctx != NULL) - ctx->errors++; - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] unable to connect to a PulseAudio daemon!\n")) - } - return; - } - written = dr->FillBuffer (dr->audio_renderer, data, BUFF_SIZE / 4); - if (written <= 0) - { - ctx->consecutive_zero_reads++; - if (ctx->consecutive_zero_reads > 5){ - gf_sleep(5); - } else if (ctx->consecutive_zero_reads < 25) { - gf_sleep(10); - } else { - gf_sleep(33); + char data[BUFF_SIZE]; + int written = 0; + int pa_error = 0; + PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; + if (ctx == NULL || ctx->playback_handle == NULL) + { + if (ctx == NULL || ctx->errors == 0) + { + if (ctx != NULL) + ctx->errors++; + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] unable to connect to a PulseAudio daemon!\n")) + } + return; + } + written = dr->FillBuffer (dr->audio_renderer, data, BUFF_SIZE / 4); + if (written <= 0) + { + ctx->consecutive_zero_reads++; + if (ctx->consecutive_zero_reads > 5) { + gf_sleep(5); + } else if (ctx->consecutive_zero_reads < 25) { + gf_sleep(10); + } else { + gf_sleep(33); + } + return; + } + ctx->consecutive_zero_reads = 0; + written = pa_simple_write (ctx->playback_handle, data, written, &pa_error); + if (pa_error != 0) + { + if (ctx->errors < 1) + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] Write failure: %s\n", pa_strerror (pa_error))); + ctx->errors++; + } + else + { + ctx->errors = 0; } - return; - } - ctx->consecutive_zero_reads = 0; - written = pa_simple_write (ctx->playback_handle, data, written, &pa_error); - if (pa_error != 0) - { - if (ctx->errors < 1) - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] Write failure: %s\n", pa_strerror (pa_error))); - ctx->errors++; - } - else - { - ctx->errors = 0; - } } static void PulseAudio_SetVolume (GF_AudioOutput * dr, u32 Volume) { - GF_LOG (GF_LOG_WARNING, GF_LOG_MMIO, - ("[PulseAudio] Set volume to %lu: not yet implemented.\n", Volume)); + GF_LOG (GF_LOG_WARNING, GF_LOG_MMIO, + ("[PulseAudio] Set volume to %lu: not yet implemented.\n", Volume)); } static void @@ -234,83 +234,83 @@ PulseAudio_SetPriority (GF_AudioOutput * dr, u32 Priority) static u32 PulseAudio_GetAudioDelay (GF_AudioOutput * dr) { - pa_usec_t delay = 0; - int pa_error = 0; - u32 ms_delay = 0; - PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; - if (ctx == NULL || ctx->playback_handle == NULL) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] missing connection to pulseaudio daemon!\n")) - return 0; - } - delay = pa_simple_get_latency (ctx->playback_handle, &pa_error); - if (pa_error) - { - GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, - ("[PulseAudio] Error while retrieving pulseaudio delay: %s.\n", - pa_strerror (pa_error))); - return 0; - } - ms_delay = (u32) (delay / 1000); - GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[PulseAudio] Audio delay: %llu us.\n", - delay)); - return ms_delay; + pa_usec_t delay = 0; + int pa_error = 0; + u32 ms_delay = 0; + PulseAudioContext *ctx = (PulseAudioContext *) dr->opaque; + if (ctx == NULL || ctx->playback_handle == NULL) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] missing connection to pulseaudio daemon!\n")) + return 0; + } + delay = pa_simple_get_latency (ctx->playback_handle, &pa_error); + if (pa_error) + { + GF_LOG (GF_LOG_ERROR, GF_LOG_MMIO, + ("[PulseAudio] Error while retrieving pulseaudio delay: %s.\n", + pa_strerror (pa_error))); + return 0; + } + ms_delay = (u32) (delay / 1000); + GF_LOG (GF_LOG_DEBUG, GF_LOG_MMIO, ("[PulseAudio] Audio delay: %llu us.\n", + delay)); + return ms_delay; } static GF_Err PulseAudio_QueryOutputSampleRate (GF_AudioOutput * dr, u32 * desired_sr, u32 * NbChannels, u32 * nbBitsPerSample) { - /** - * PulseAudio can do the resampling by itself and play any number of channels - */ - return GF_OK; + /** + * PulseAudio can do the resampling by itself and play any number of channels + */ + return GF_OK; } void * NewPulseAudioOutput () { - PulseAudioContext *ctx; - GF_AudioOutput *driv; - GF_SAFEALLOC (ctx, PulseAudioContext); - if (!ctx) - return NULL; + PulseAudioContext *ctx; + GF_AudioOutput *driv; + GF_SAFEALLOC (ctx, PulseAudioContext); + if (!ctx) + return NULL; - GF_SAFEALLOC (driv, GF_AudioOutput); - if (!driv) - { - gf_free(ctx); - return NULL; - } - driv->opaque = ctx; - ctx->playback_handle = NULL; - ctx->errors = 0; - driv->SelfThreaded = 0; - driv->Setup = PulseAudio_Setup; - driv->Shutdown = PulseAudio_Shutdown; - driv->ConfigureOutput = PulseAudio_ConfigureOutput; - driv->GetAudioDelay = PulseAudio_GetAudioDelay; - driv->SetVolume = PulseAudio_SetVolume; - driv->SetPan = PulseAudio_SetPan; - driv->SetPriority = PulseAudio_SetPriority; - driv->QueryOutputSampleRate = PulseAudio_QueryOutputSampleRate; - driv->WriteAudio = PulseAudio_WriteAudio; - GF_REGISTER_MODULE_INTERFACE (driv, GF_AUDIO_OUTPUT_INTERFACE, MODULE_NAME, "gpac distribution"); - return driv; + GF_SAFEALLOC (driv, GF_AudioOutput); + if (!driv) + { + gf_free(ctx); + return NULL; + } + driv->opaque = ctx; + ctx->playback_handle = NULL; + ctx->errors = 0; + driv->SelfThreaded = 0; + driv->Setup = PulseAudio_Setup; + driv->Shutdown = PulseAudio_Shutdown; + driv->ConfigureOutput = PulseAudio_ConfigureOutput; + driv->GetAudioDelay = PulseAudio_GetAudioDelay; + driv->SetVolume = PulseAudio_SetVolume; + driv->SetPan = PulseAudio_SetPan; + driv->SetPriority = PulseAudio_SetPriority; + driv->QueryOutputSampleRate = PulseAudio_QueryOutputSampleRate; + driv->WriteAudio = PulseAudio_WriteAudio; + GF_REGISTER_MODULE_INTERFACE (driv, GF_AUDIO_OUTPUT_INTERFACE, MODULE_NAME, "gpac distribution"); + return driv; } void DeletePulseAudioOutput (void *ifce) { - GF_AudioOutput *dr = (GF_AudioOutput *) ifce; - free_pulseaudio_resources (dr); - if (dr != NULL) { - if (dr->opaque) - gf_free(dr->opaque); - dr->opaque = NULL; - gf_free(dr); - } + GF_AudioOutput *dr = (GF_AudioOutput *) ifce; + free_pulseaudio_resources (dr); + if (dr != NULL) { + if (dr->opaque) + gf_free(dr->opaque); + dr->opaque = NULL; + gf_free(dr); + } } @@ -321,26 +321,26 @@ DeletePulseAudioOutput (void *ifce) GPAC_MODULE_EXPORT const u32 *QueryInterfaces(u32 InterfaceType) { - static u32 si [] = { - GF_AUDIO_OUTPUT_INTERFACE, - 0 - }; - return si; + static u32 si [] = { + GF_AUDIO_OUTPUT_INTERFACE, + 0 + }; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface (u32 InterfaceType) { - if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) - return NewPulseAudioOutput (); - return NULL; + if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + return NewPulseAudioOutput (); + return NULL; } GPAC_MODULE_EXPORT void ShutdownInterface (GF_BaseInterface * ifce) { - if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) - DeletePulseAudioOutput ((GF_AudioOutput *) ifce); + if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) + DeletePulseAudioOutput ((GF_AudioOutput *) ifce); } GPAC_MODULE_STATIC_DELARATION( pulseaudio ) diff --git a/modules/raw_out/raw_video.c b/modules/raw_out/raw_video.c index 0997ab3..896fdb5 100644 --- a/modules/raw_out/raw_video.c +++ b/modules/raw_out/raw_video.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -153,7 +153,7 @@ GF_VideoOutput *NewRawVideoOutput() return (void *)driv; } -void DeleteVideoOutput(void *ifce) +void DeleteRawVideoOutput(void *ifce) { RawContext *rc; GF_VideoOutput *driv = (GF_VideoOutput *) ifce; @@ -254,14 +254,14 @@ void DeleteAudioOutput(void *ifce) /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, GF_AUDIO_OUTPUT_INTERFACE, 0 }; - return si; + return si; } /*interface create*/ @@ -279,7 +279,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { case GF_VIDEO_OUTPUT_INTERFACE: - DeleteVideoOutput((GF_VideoOutput *)ifce); + DeleteRawVideoOutput((GF_VideoOutput *)ifce); break; case GF_AUDIO_OUTPUT_INTERFACE: DeleteAudioOutput((GF_AudioOutput *)ifce); diff --git a/modules/redirect_av/ffmpeg_ts_muxer.c b/modules/redirect_av/ffmpeg_ts_muxer.c index 6283440..d265f5b 100644 --- a/modules/redirect_av/ffmpeg_ts_muxer.c +++ b/modules/redirect_av/ffmpeg_ts_muxer.c @@ -21,22 +21,22 @@ #define PACKETS_BUFFER_LEN 1024 struct avr_ts_muxer { - AVFormatContext *oc; - AVStream *audio_st, *video_st; - AVPacketList * videoPackets; - AVPacketList * audioPackets; - volatile Bool encode; - GF_Mutex *videoMx, *audioMx; - GF_Thread * tsEncodingThread; - const char * destination; + AVFormatContext *oc; + AVStream *audio_st, *video_st; + AVPacketList * videoPackets; + AVPacketList * audioPackets; + volatile Bool encode; + GF_Mutex *videoMx, *audioMx; + GF_Thread * tsEncodingThread; + const char * destination; }; static Bool has_packet_ready(GF_AbstractTSMuxer* ts, GF_Mutex * mx, AVPacketList ** pkts) { - Bool ret; - gf_mx_p(mx); - ret = (*pkts) != NULL; - gf_mx_v(mx); - return ret; + Bool ret; + gf_mx_p(mx); + ret = (*pkts) != NULL; + gf_mx_v(mx); + return ret; } @@ -49,118 +49,118 @@ static Bool has_packet_ready(GF_AbstractTSMuxer* ts, GF_Mutex * mx, AVPacketList * \return NULL if encoding is ended, the first packet available otherwise */ static AVPacketList * wait_for_packet(GF_AbstractTSMuxer* ts, GF_Mutex * mx, AVPacketList ** pkts) { - AVPacketList * p; - gf_mx_p(mx); - while (ts->encode && !(*pkts)) { - gf_mx_v(mx); - gf_mx_p(mx); + AVPacketList * p; + gf_mx_p(mx); + while (ts->encode && !(*pkts)) { + gf_mx_v(mx); + gf_mx_p(mx); gf_sleep(1); - } - if (!ts->encode) { - gf_mx_v(mx); - return NULL; - } - p = *pkts; - *pkts = p->next; - gf_mx_v(mx); - return p; + } + if (!ts->encode) { + gf_mx_v(mx); + return NULL; + } + p = *pkts; + *pkts = p->next; + gf_mx_v(mx); + return p; } static u32 ts_interleave_thread_run(void *param) { - GF_AbstractTSMuxer * mux = (GF_AbstractTSMuxer *) param; - AVStream * video_st = mux->video_st; - AVStream * audio_st = mux->audio_st; - u64 audio_pts, video_pts; - u64 audioSize, videoSize, videoKbps, audioKbps; - u32 pass; - u32 now, start; - /* open the output file, if needed */ - if (!(mux->oc->oformat->flags & AVFMT_NOFILE)) { - if (url_fopen(&mux->oc->pb, mux->destination, URL_WRONLY) < 0) { - fprintf(stderr, "Could not open '%s'\n", mux->destination); - return 0; - } - } - /* write the stream header, if any */ - av_write_header(mux->oc); - audio_pts = video_pts = 0; - // Buffering... - gf_sleep(1000); - now = start = gf_sys_clock(); - audioSize = videoSize = 0; - audioKbps = videoKbps = 0; - pass = 0; - while ( mux->encode) { - pass++; - if (0== (pass%16)) { - now = gf_sys_clock(); - if (now - start > 1000) { - videoKbps = videoSize * 8000 / (now-start) / 1024; - audioKbps = audioSize * 8000 / (now-start) / 1024; - audioSize = videoSize = 0; - start = now; - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("\rPTS audio="LLU" ("LLU"kbps), video="LLU" ("LLU"kbps)", audio_pts, audioKbps, video_pts, videoKbps)); - } - } - /* write interleaved audio and video frames */ - if (!video_st || - (audio_pts == AV_NOPTS_VALUE && has_packet_ready(mux, mux->audioMx, &mux->audioPackets)) || - ((audio_st && audio_pts < video_pts && audio_pts!= AV_NOPTS_VALUE))) { - AVPacketList * pl = wait_for_packet(mux, mux->audioMx, &mux->audioPackets); - if (!pl) - goto exit; - audio_pts = pl->pkt.pts ; - audioSize+=pl->pkt.size; - if (pl->pkt.pts == AV_NOPTS_VALUE) { - pl->pkt.pts = 0; - } - if (av_interleaved_write_frame(mux->oc, &(pl->pkt)) < 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] : failed to write audio interleaved frame audio_pts="LLU", video_pts="LLU"\n", audio_pts, video_pts)); - } - gf_free(pl); - } else { - AVPacketList * pl = wait_for_packet(mux, mux->videoMx, &mux->videoPackets); - if (!pl) - goto exit; - video_pts = pl->pkt.pts; - /* write the compressed frame in the media file */ - if (0 && audio_pts != AV_NOPTS_VALUE && audio_pts > video_pts && pl->next) { - u32 skipped = 0; - u64 first = video_pts; - /* We may be too slow... */ - gf_mx_p(mux->videoMx); - while (video_pts < audio_pts && pl->next) { - AVPacketList * old = pl; - // We skip frames... - pl = pl->next; - video_pts = pl->pkt.pts; - skipped++; - gf_free(old); - } - mux->videoPackets = pl->next; - gf_mx_v(mux->videoMx); - if (skipped > 0) - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Skipped %u video frames, frame was "LLU", but is now "LLU"\n", skipped, first, video_pts)); - } - videoSize+=pl->pkt.size; - video_pts = pl->pkt.pts; // * video_st->time_base.num / video_st->time_base.den; - assert( video_pts); - if (av_interleaved_write_frame(mux->oc, &(pl->pkt)) < 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] : failed to write video interleaved frame audio_pts="LLU", video_pts="LLU"\n", audio_pts, video_pts)); - } - gf_free(pl); - } + GF_AbstractTSMuxer * mux = (GF_AbstractTSMuxer *) param; + AVStream * video_st = mux->video_st; + AVStream * audio_st = mux->audio_st; + u64 audio_pts, video_pts; + u64 audioSize, videoSize, videoKbps, audioKbps; + u32 pass; + u32 now, start; + /* open the output file, if needed */ + if (!(mux->oc->oformat->flags & AVFMT_NOFILE)) { + if (url_fopen(&mux->oc->pb, mux->destination, URL_WRONLY) < 0) { + fprintf(stderr, "Could not open '%s'\n", mux->destination); + return 0; + } + } + /* write the stream header, if any */ + av_write_header(mux->oc); + audio_pts = video_pts = 0; + // Buffering... + gf_sleep(1000); + now = start = gf_sys_clock(); + audioSize = videoSize = 0; + audioKbps = videoKbps = 0; + pass = 0; + while ( mux->encode) { + pass++; + if (0== (pass%16)) { + now = gf_sys_clock(); + if (now - start > 1000) { + videoKbps = videoSize * 8000 / (now-start) / 1024; + audioKbps = audioSize * 8000 / (now-start) / 1024; + audioSize = videoSize = 0; + start = now; + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("\rPTS audio="LLU" ("LLU"kbps), video="LLU" ("LLU"kbps)", audio_pts, audioKbps, video_pts, videoKbps)); + } + } + /* write interleaved audio and video frames */ + if (!video_st || + (audio_pts == AV_NOPTS_VALUE && has_packet_ready(mux, mux->audioMx, &mux->audioPackets)) || + ((audio_st && audio_pts < video_pts && audio_pts!= AV_NOPTS_VALUE))) { + AVPacketList * pl = wait_for_packet(mux, mux->audioMx, &mux->audioPackets); + if (!pl) + goto exit; + audio_pts = pl->pkt.pts ; + audioSize+=pl->pkt.size; + if (pl->pkt.pts == AV_NOPTS_VALUE) { + pl->pkt.pts = 0; + } + if (av_interleaved_write_frame(mux->oc, &(pl->pkt)) < 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] : failed to write audio interleaved frame audio_pts="LLU", video_pts="LLU"\n", audio_pts, video_pts)); + } + gf_free(pl); + } else { + AVPacketList * pl = wait_for_packet(mux, mux->videoMx, &mux->videoPackets); + if (!pl) + goto exit; + video_pts = pl->pkt.pts; + /* write the compressed frame in the media file */ + if (0 && audio_pts != AV_NOPTS_VALUE && audio_pts > video_pts && pl->next) { + u32 skipped = 0; + u64 first = video_pts; + /* We may be too slow... */ + gf_mx_p(mux->videoMx); + while (video_pts < audio_pts && pl->next) { + AVPacketList * old = pl; + // We skip frames... + pl = pl->next; + video_pts = pl->pkt.pts; + skipped++; + gf_free(old); + } + mux->videoPackets = pl->next; + gf_mx_v(mux->videoMx); + if (skipped > 0) + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Skipped %u video frames, frame was "LLU", but is now "LLU"\n", skipped, first, video_pts)); + } + videoSize+=pl->pkt.size; + video_pts = pl->pkt.pts; // * video_st->time_base.num / video_st->time_base.den; + assert( video_pts); + if (av_interleaved_write_frame(mux->oc, &(pl->pkt)) < 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] : failed to write video interleaved frame audio_pts="LLU", video_pts="LLU"\n", audio_pts, video_pts)); + } + gf_free(pl); + } gf_sleep(1); - } + } exit: - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending TS thread...\n")); - av_write_trailer(mux->oc); - if (!(mux->oc->oformat->flags & AVFMT_NOFILE)) { - /* close the output file */ - url_fclose(mux->oc->pb); - } - return 0; + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending TS thread...\n")); + av_write_trailer(mux->oc); + if (!(mux->oc->oformat->flags & AVFMT_NOFILE)) { + /* close the output file */ + url_fclose(mux->oc->pb); + } + return 0; } @@ -171,237 +171,237 @@ exit: #endif /* LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 */ GF_AbstractTSMuxer * ts_amux_new(GF_AVRedirect * avr, u32 videoBitrateInBitsPerSec, u32 width, u32 height, u32 audioBitRateInBitsPerSec) { - GF_AbstractTSMuxer * ts = gf_malloc( sizeof(GF_AbstractTSMuxer)); - memset( ts, 0, sizeof( GF_AbstractTSMuxer)); - ts->oc = avformat_alloc_context(); - ts->destination = avr->destination; - av_register_all(); - ts->oc->oformat = GUESS_FORMAT(NULL, avr->destination, NULL); - if (!ts->oc->oformat) - ts->oc->oformat = GUESS_FORMAT("mpegts", NULL, NULL); - assert( ts->oc->oformat); + GF_AbstractTSMuxer * ts = gf_malloc( sizeof(GF_AbstractTSMuxer)); + memset( ts, 0, sizeof( GF_AbstractTSMuxer)); + ts->oc = avformat_alloc_context(); + ts->destination = avr->destination; + av_register_all(); + ts->oc->oformat = GUESS_FORMAT(NULL, avr->destination, NULL); + if (!ts->oc->oformat) + ts->oc->oformat = GUESS_FORMAT("mpegts", NULL, NULL); + assert( ts->oc->oformat); #if REDIRECT_AV_AUDIO_ENABLED - ts->audio_st = av_new_stream(ts->oc, avr->audioCodec->id); - { - AVCodecContext * c = ts->audio_st->codec; - c->codec_id = avr->audioCodec->id; - c->codec_type = AVMEDIA_TYPE_AUDIO; - /* put sample parameters */ - c->sample_fmt = SAMPLE_FMT_S16; - c->bit_rate = audioBitRateInBitsPerSec; - c->sample_rate = avr->audioSampleRate; - c->channels = 2; - c->time_base.num = 1; - c->time_base.den = 1000; - // some formats want stream headers to be separate - if (ts->oc->oformat->flags & AVFMT_GLOBALHEADER) - c->flags |= CODEC_FLAG_GLOBAL_HEADER; - } + ts->audio_st = av_new_stream(ts->oc, avr->audioCodec->id); + { + AVCodecContext * c = ts->audio_st->codec; + c->codec_id = avr->audioCodec->id; + c->codec_type = AVMEDIA_TYPE_AUDIO; + /* put sample parameters */ + c->sample_fmt = SAMPLE_FMT_S16; + c->bit_rate = audioBitRateInBitsPerSec; + c->sample_rate = avr->audioSampleRate; + c->channels = 2; + c->time_base.num = 1; + c->time_base.den = 1000; + // some formats want stream headers to be separate + if (ts->oc->oformat->flags & AVFMT_GLOBALHEADER) + c->flags |= CODEC_FLAG_GLOBAL_HEADER; + } #endif - ts->video_st = av_new_stream(ts->oc, avr->videoCodec->id); - { - AVCodecContext * c = ts->video_st->codec; - c->codec_id = avr->videoCodec->id; - c->codec_type = AVMEDIA_TYPE_VIDEO; + ts->video_st = av_new_stream(ts->oc, avr->videoCodec->id); + { + AVCodecContext * c = ts->video_st->codec; + c->codec_id = avr->videoCodec->id; + c->codec_type = AVMEDIA_TYPE_VIDEO; - /* put sample parameters */ - c->bit_rate = videoBitrateInBitsPerSec; - /* resolution must be a multiple of two */ - c->width = width; - c->height = height; - /* time base: this is the fundamental unit of time (in seconds) in terms - of which frame timestamps are represented. for fixed-fps content, - timebase should be 1/framerate and timestamp increments should be - identically 1. */ - c->time_base.den = STREAM_FRAME_RATE; - c->time_base.num = 1; - c->gop_size = 12; /* emit one intra frame every twelve frames at most */ - c->pix_fmt = STREAM_PIX_FMT; - if (c->codec_id == CODEC_ID_MPEG2VIDEO) { - /* just for testing, we also add B frames */ - c->max_b_frames = 2; - } - if (c->codec_id == CODEC_ID_MPEG1VIDEO) { - /* Needed to avoid using macroblocks in which some coeffs overflow. - This does not happen with normal video, it just happens here as - the motion of the chroma plane does not match the luma plane. */ - c->mb_decision=2; - } - // some formats want stream headers to be separate - if (ts->oc->oformat->flags & AVFMT_GLOBALHEADER) - c->flags |= CODEC_FLAG_GLOBAL_HEADER; + /* put sample parameters */ + c->bit_rate = videoBitrateInBitsPerSec; + /* resolution must be a multiple of two */ + c->width = width; + c->height = height; + /* time base: this is the fundamental unit of time (in seconds) in terms + of which frame timestamps are represented. for fixed-fps content, + timebase should be 1/framerate and timestamp increments should be + identically 1. */ + c->time_base.den = STREAM_FRAME_RATE; + c->time_base.num = 1; + c->gop_size = 12; /* emit one intra frame every twelve frames at most */ + c->pix_fmt = STREAM_PIX_FMT; + if (c->codec_id == CODEC_ID_MPEG2VIDEO) { + /* just for testing, we also add B frames */ + c->max_b_frames = 2; + } + if (c->codec_id == CODEC_ID_MPEG1VIDEO) { + /* Needed to avoid using macroblocks in which some coeffs overflow. + This does not happen with normal video, it just happens here as + the motion of the chroma plane does not match the luma plane. */ + c->mb_decision=2; + } + // some formats want stream headers to be separate + if (ts->oc->oformat->flags & AVFMT_GLOBALHEADER) + c->flags |= CODEC_FLAG_GLOBAL_HEADER; - } - //av_set_pts_info(ts->audio_st, 33, 1, audioBitRateInBitsPerSec); + } + //av_set_pts_info(ts->audio_st, 33, 1, audioBitRateInBitsPerSec); #ifndef AVIO_FLAG_WRITE /* set the output parameters (must be done even if no - parameters). */ - if (av_set_parameters(ts->oc, NULL) < 0) { - fprintf(stderr, "Invalid output format parameters\n"); - return NULL; - } + parameters). */ + if (av_set_parameters(ts->oc, NULL) < 0) { + fprintf(stderr, "Invalid output format parameters\n"); + return NULL; + } #endif - + dump_format(ts->oc, 0, avr->destination, 1); - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] DUMPING to %s...\n", ts->destination)); + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] DUMPING to %s...\n", ts->destination)); #if (LIBAVCODEC_VERSION_MAJOR<55) - if (avcodec_open(ts->video_st->codec, avr->videoCodec) < 0) { + if (avcodec_open(ts->video_st->codec, avr->videoCodec) < 0) { #else if (avcodec_open2(ts->video_st->codec, avr->videoCodec, NULL) < 0) { #endif GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] failed to open video codec\n")); - return NULL; - } + return NULL; + } #if REDIRECT_AV_AUDIO_ENABLED #if (LIBAVCODEC_VERSION_MAJOR<55) - if (avcodec_open(ts->audio_st->codec, avr->audioCodec) < 0) { + if (avcodec_open(ts->audio_st->codec, avr->audioCodec) < 0) { #else if (avcodec_open2(ts->audio_st->codec, avr->audioCodec, NULL) < 0) { #endif GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] failed to open audio codec\n")); - return NULL; - } - ts->audioMx = gf_mx_new("TS_AudioMx"); + return NULL; + } + ts->audioMx = gf_mx_new("TS_AudioMx"); #endif - ts->videoMx = gf_mx_new("TS_VideoMx"); - ts->tsEncodingThread = gf_th_new("ts_interleave_thread_run"); - ts->encode = 1; - ts->audioPackets = NULL; - ts->videoPackets = NULL; - gf_th_run(ts->tsEncodingThread, ts_interleave_thread_run, ts); - return ts; + ts->videoMx = gf_mx_new("TS_VideoMx"); + ts->tsEncodingThread = gf_th_new("ts_interleave_thread_run"); + ts->encode = 1; + ts->audioPackets = NULL; + ts->videoPackets = NULL; + gf_th_run(ts->tsEncodingThread, ts_interleave_thread_run, ts); + return ts; } void ts_amux_del(GF_AbstractTSMuxer * muxerToDelete) { - if (!muxerToDelete) - return; - muxerToDelete->encode = 0; - gf_sleep(100); - gf_th_stop(muxerToDelete->tsEncodingThread); - muxerToDelete->tsEncodingThread = NULL; + if (!muxerToDelete) + return; + muxerToDelete->encode = 0; + gf_sleep(100); + gf_th_stop(muxerToDelete->tsEncodingThread); + muxerToDelete->tsEncodingThread = NULL; #if REDIRECT_AV_AUDIO_ENABLED - gf_mx_del(muxerToDelete->audioMx); - muxerToDelete->audioMx = NULL; + gf_mx_del(muxerToDelete->audioMx); + muxerToDelete->audioMx = NULL; #endif - gf_mx_del(muxerToDelete->videoMx); - muxerToDelete->videoMx = NULL; - if (muxerToDelete->video_st) { - avcodec_close(muxerToDelete->video_st->codec); - muxerToDelete->video_st = NULL; - } + gf_mx_del(muxerToDelete->videoMx); + muxerToDelete->videoMx = NULL; + if (muxerToDelete->video_st) { + avcodec_close(muxerToDelete->video_st->codec); + muxerToDelete->video_st = NULL; + } #if REDIRECT_AV_AUDIO_ENABLED - if (muxerToDelete->audio_st) { - avcodec_close(muxerToDelete->audio_st->codec); - muxerToDelete->audio_st = NULL; - } + if (muxerToDelete->audio_st) { + avcodec_close(muxerToDelete->audio_st->codec); + muxerToDelete->audio_st = NULL; + } #endif - /* write the trailer, if any. the trailer must be written - * before you close the CodecContexts open when you wrote the - * header; otherwise write_trailer may try to use memory that - * was freed on av_codec_close() */ - if (muxerToDelete->oc) { - u32 i; - /* free the streams */ - for (i = 0; i < muxerToDelete->oc->nb_streams; i++) { - av_freep(&muxerToDelete->oc->streams[i]->codec); - av_freep(&muxerToDelete->oc->streams[i]); - } + /* write the trailer, if any. the trailer must be written + * before you close the CodecContexts open when you wrote the + * header; otherwise write_trailer may try to use memory that + * was freed on av_codec_close() */ + if (muxerToDelete->oc) { + u32 i; + /* free the streams */ + for (i = 0; i < muxerToDelete->oc->nb_streams; i++) { + av_freep(&muxerToDelete->oc->streams[i]->codec); + av_freep(&muxerToDelete->oc->streams[i]); + } - /* free the stream */ - av_free(muxerToDelete->oc); - muxerToDelete->oc = NULL; - } + /* free the stream */ + av_free(muxerToDelete->oc); + muxerToDelete->oc = NULL; + } } Bool ts_encode_audio_frame(GF_AbstractTSMuxer * ts, uint8_t * data, int encoded, u64 pts) { - AVPacketList *pl; - AVPacket * pkt; - if (!ts->encode) - return 1; - pl = gf_malloc(sizeof(AVPacketList)); - pl->next = NULL; - pkt = &(pl->pkt); - av_init_packet(pkt); - assert( ts->audio_st); - assert( ts->audio_st->codec); - pkt->flags = 0; - if (ts->audio_st->codec->coded_frame) { - if (ts->audio_st->codec->coded_frame->key_frame) - pkt->flags = AV_PKT_FLAG_KEY; - if (ts->audio_st->codec->coded_frame->pts != AV_NOPTS_VALUE) { - pkt->pts = av_rescale_q(ts->audio_st->codec->coded_frame->pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); - } else { - if (pts == AV_NOPTS_VALUE) - pkt->pts = AV_NOPTS_VALUE; - else { - pkt->pts = av_rescale_q(pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); - } - } - } else { - if (pts == AV_NOPTS_VALUE) - pkt->pts = AV_NOPTS_VALUE; - else - pkt->pts = av_rescale_q(pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); - } - pkt->stream_index= ts->audio_st->index; - pkt->data = data; - pkt->size = encoded; - //fprintf(stderr, "AUDIO PTS="LLU" was: "LLU" (%p)\n", pkt->pts, pts, pl); - gf_mx_p(ts->audioMx); - if (!ts->audioPackets) - ts->audioPackets = pl; - else { - AVPacketList * px = ts->audioPackets; - while (px->next) - px = px->next; - px->next = pl; - } - gf_mx_v(ts->audioMx); - return 0; + AVPacketList *pl; + AVPacket * pkt; + if (!ts->encode) + return 1; + pl = gf_malloc(sizeof(AVPacketList)); + pl->next = NULL; + pkt = &(pl->pkt); + av_init_packet(pkt); + assert( ts->audio_st); + assert( ts->audio_st->codec); + pkt->flags = 0; + if (ts->audio_st->codec->coded_frame) { + if (ts->audio_st->codec->coded_frame->key_frame) + pkt->flags = AV_PKT_FLAG_KEY; + if (ts->audio_st->codec->coded_frame->pts != AV_NOPTS_VALUE) { + pkt->pts = av_rescale_q(ts->audio_st->codec->coded_frame->pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); + } else { + if (pts == AV_NOPTS_VALUE) + pkt->pts = AV_NOPTS_VALUE; + else { + pkt->pts = av_rescale_q(pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); + } + } + } else { + if (pts == AV_NOPTS_VALUE) + pkt->pts = AV_NOPTS_VALUE; + else + pkt->pts = av_rescale_q(pts, ts->audio_st->codec->time_base, ts->audio_st->time_base); + } + pkt->stream_index= ts->audio_st->index; + pkt->data = data; + pkt->size = encoded; + //fprintf(stderr, "AUDIO PTS="LLU" was: "LLU" (%p)\n", pkt->pts, pts, pl); + gf_mx_p(ts->audioMx); + if (!ts->audioPackets) + ts->audioPackets = pl; + else { + AVPacketList * px = ts->audioPackets; + while (px->next) + px = px->next; + px->next = pl; + } + gf_mx_v(ts->audioMx); + return 0; } Bool ts_encode_video_frame(GF_AbstractTSMuxer* ts, uint8_t* data, int encoded) { - AVPacketList *pl; - AVPacket * pkt; - if (!ts->encode) - return 1; - pl = gf_malloc(sizeof(AVPacketList)); - pl->next = NULL; - pkt = &(pl->pkt); + AVPacketList *pl; + AVPacket * pkt; + if (!ts->encode) + return 1; + pl = gf_malloc(sizeof(AVPacketList)); + pl->next = NULL; + pkt = &(pl->pkt); - av_init_packet(pkt); + av_init_packet(pkt); - if (ts->video_st->codec->coded_frame->pts != AV_NOPTS_VALUE) { - //pkt->pts= av_rescale_q(ts->video_st->codec->coded_frame->pts, ts->video_st->codec->time_base, ts->video_st->time_base); - pkt->pts = ts->video_st->codec->coded_frame->pts * ts->video_st->time_base.den / ts->video_st->time_base.num / 1000; - //pkt->pts = ts->video_st->codec->coded_frame->pts; - } - if (ts->video_st->codec->coded_frame->key_frame) - pkt->flags |= AV_PKT_FLAG_KEY; - pkt->stream_index= ts->video_st->index; - pkt->data= data; - pkt->size= encoded; - //fprintf(stderr, "VIDEO PTS="LLU" was: "LLU" (%p)\n", pkt->pts, ts->video_st->codec->coded_frame->pts, pl); - gf_mx_p(ts->videoMx); - if (!ts->videoPackets) - ts->videoPackets = pl; - else { - AVPacketList * px = ts->videoPackets; - while (px->next) - px = px->next; - px->next = pl; - } - gf_mx_v(ts->videoMx); - return 0; + if (ts->video_st->codec->coded_frame->pts != AV_NOPTS_VALUE) { + //pkt->pts= av_rescale_q(ts->video_st->codec->coded_frame->pts, ts->video_st->codec->time_base, ts->video_st->time_base); + pkt->pts = ts->video_st->codec->coded_frame->pts * ts->video_st->time_base.den / ts->video_st->time_base.num / 1000; + //pkt->pts = ts->video_st->codec->coded_frame->pts; + } + if (ts->video_st->codec->coded_frame->key_frame) + pkt->flags |= AV_PKT_FLAG_KEY; + pkt->stream_index= ts->video_st->index; + pkt->data= data; + pkt->size= encoded; + //fprintf(stderr, "VIDEO PTS="LLU" was: "LLU" (%p)\n", pkt->pts, ts->video_st->codec->coded_frame->pts, pl); + gf_mx_p(ts->videoMx); + if (!ts->videoPackets) + ts->videoPackets = pl; + else { + AVPacketList * px = ts->videoPackets; + while (px->next) + px = px->next; + px->next = pl; + } + gf_mx_v(ts->videoMx); + return 0; } AVCodecContext * ts_get_video_codec_context(GF_AbstractTSMuxer * ts) { - return !ts ? NULL : ts->video_st->codec; + return !ts ? NULL : ts->video_st->codec; } AVCodecContext * ts_get_audio_codec_context(GF_AbstractTSMuxer * ts) { - return !ts ? NULL : ts->audio_st->codec; + return !ts ? NULL : ts->audio_st->codec; } diff --git a/modules/redirect_av/gpac_ts_muxer.c b/modules/redirect_av/gpac_ts_muxer.c index 9dbd789..c79638a 100644 --- a/modules/redirect_av/gpac_ts_muxer.c +++ b/modules/redirect_av/gpac_ts_muxer.c @@ -2,12 +2,12 @@ #include struct avr_ts_muxer { - GF_M2TS_Mux *muxer; - GF_ESIPacket videoCurrentTSPacket; - GF_ESIPacket audioCurrentTSPacket; - GF_ESInterface * video, * audio; - u64 frameTimeSentOverTS; - GF_Socket * ts_output_udp_sk; + GF_M2TS_Mux *muxer; + GF_ESIPacket videoCurrentTSPacket; + GF_ESIPacket audioCurrentTSPacket; + GF_ESInterface * video, * audio; + u64 frameTimeSentOverTS; + GF_Socket * ts_output_udp_sk; }; /*! @@ -16,163 +16,163 @@ struct avr_ts_muxer { */ static GF_Err sendTSMux(GF_AbstractTSMuxer * ts) { - u32 status; - const char * pkt; - GF_Err e; - u32 padding, data; - padding = data = 0; - while ( (NULL!= ( pkt = gf_m2ts_mux_process ( ts->muxer, &status )))) - { - switch (status) { - case GF_M2TS_STATE_IDLE: - break; - case GF_M2TS_STATE_DATA: - data+=188; - break; - case GF_M2TS_STATE_PADDING: - padding+=188; - break; - default: - break; - } - if (ts->ts_output_udp_sk) { - e = gf_sk_send ( ts->ts_output_udp_sk, pkt, 188); - if ( e ) - { - GF_LOG ( GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Unable to send TS data : %s\n", gf_error_to_string(e)) ); - return e; - } - } - } - if (data || padding) - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[AVRedirect] : Sent TS data=%u/padding=%u\n", data, padding)); - return GF_OK; + u32 status; + const char * pkt; + GF_Err e; + u32 padding, data; + padding = data = 0; + while ( (NULL!= ( pkt = gf_m2ts_mux_process ( ts->muxer, &status )))) + { + switch (status) { + case GF_M2TS_STATE_IDLE: + break; + case GF_M2TS_STATE_DATA: + data+=188; + break; + case GF_M2TS_STATE_PADDING: + padding+=188; + break; + default: + break; + } + if (ts->ts_output_udp_sk) { + e = gf_sk_send ( ts->ts_output_udp_sk, pkt, 188); + if ( e ) + { + GF_LOG ( GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Unable to send TS data : %s\n", gf_error_to_string(e)) ); + return e; + } + } + } + if (data || padding) + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[AVRedirect] : Sent TS data=%u/padding=%u\n", data, padding)); + return GF_OK; } //Bool *add_video_stream(GF_AbstractTSMuxer * ts, int codec_id) Bool ts_encode_audio_frame(GF_AbstractTSMuxer * ts, AVFrame * encodedFrame, uint8_t * data, int encoded) { - ts->audioCurrentTSPacket.data = data; - ts->audioCurrentTSPacket.data_len = encoded; - ts->audioCurrentTSPacket.flags = GF_ESI_DATA_AU_START|GF_ESI_DATA_AU_END | GF_ESI_DATA_HAS_CTS | GF_ESI_DATA_HAS_DTS; - //avr->audioCurrentTSPacket.cts = avr->audioCurrentTSPacket.dts = myTime; - ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = gf_m2ts_get_sys_clock(ts->muxer); - ts->audio->output_ctrl(ts->audio, GF_ESI_OUTPUT_DATA_DISPATCH, &(ts->audioCurrentTSPacket)); - return 0; + ts->audioCurrentTSPacket.data = data; + ts->audioCurrentTSPacket.data_len = encoded; + ts->audioCurrentTSPacket.flags = GF_ESI_DATA_AU_START|GF_ESI_DATA_AU_END | GF_ESI_DATA_HAS_CTS | GF_ESI_DATA_HAS_DTS; + //avr->audioCurrentTSPacket.cts = avr->audioCurrentTSPacket.dts = myTime; + ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = gf_m2ts_get_sys_clock(ts->muxer); + ts->audio->output_ctrl(ts->audio, GF_ESI_OUTPUT_DATA_DISPATCH, &(ts->audioCurrentTSPacket)); + return 0; } static GF_Err void_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) { - GF_AbstractTSMuxer * ts = (GF_AbstractTSMuxer *) ifce->input_udta; - if (!ts) - return GF_BAD_PARAM; - switch (act_type) { - case GF_ESI_INPUT_DATA_FLUSH: - break; - case GF_ESI_INPUT_DESTROY: - break; - /* case GF_ESI_INPUT_DATA_PULL: - gf_mx_p(ts->encodingMutex); - if (ts->frameTimeEncoded > ts->frameTimeSentOverTS) { - //fprintf(stderr, "Data PULL, avr=%p, avr->video=%p, encoded="LLU", sent over TS="LLU"\n", avr, &avr->video, avr->frameTimeEncoded, avr->frameTimeSentOverTS); - ts->video->output_ctrl( ts->video, GF_ESI_OUTPUT_DATA_DISPATCH, &(ts->videoCurrentTSPacket)); - ts->frameTimeSentOverTS = ts->frameTime; - } else { - //fprintf(stderr, "Data PULL IGNORED : encoded = "LLU", sent on TS="LLU"\n", avr->frameTimeEncoded, avr->frameTimeSentOverTS); - } - gf_mx_v(avr->encodingMutex); - break;*/ - case GF_ESI_INPUT_DATA_RELEASE: - break; - default: - fprintf(stderr, "Asking unknown : %u\n", act_type); - } - return GF_OK; + GF_AbstractTSMuxer * ts = (GF_AbstractTSMuxer *) ifce->input_udta; + if (!ts) + return GF_BAD_PARAM; + switch (act_type) { + case GF_ESI_INPUT_DATA_FLUSH: + break; + case GF_ESI_INPUT_DESTROY: + break; + /* case GF_ESI_INPUT_DATA_PULL: + gf_mx_p(ts->encodingMutex); + if (ts->frameTimeEncoded > ts->frameTimeSentOverTS) { + //fprintf(stderr, "Data PULL, avr=%p, avr->video=%p, encoded="LLU", sent over TS="LLU"\n", avr, &avr->video, avr->frameTimeEncoded, avr->frameTimeSentOverTS); + ts->video->output_ctrl( ts->video, GF_ESI_OUTPUT_DATA_DISPATCH, &(ts->videoCurrentTSPacket)); + ts->frameTimeSentOverTS = ts->frameTime; + } else { + //fprintf(stderr, "Data PULL IGNORED : encoded = "LLU", sent on TS="LLU"\n", avr->frameTimeEncoded, avr->frameTimeSentOverTS); + } + gf_mx_v(avr->encodingMutex); + break;*/ + case GF_ESI_INPUT_DATA_RELEASE: + break; + default: + fprintf(stderr, "Asking unknown : %u\n", act_type); + } + return GF_OK; } Bool ts_encode_video_frame(GF_AbstractTSMuxer * ts, AVFrame * encodedFrame, uint8_t * data, int encoded, AVCodecContext * videoCodecContext) { - if ( ts->muxer ) - { // currentFrameTimeProcessed / 1000; // - ts->videoCurrentTSPacket.dts = videoCodecContext->coded_frame->coded_picture_number; - ts->videoCurrentTSPacket.cts = videoCodecContext->coded_frame->display_picture_number; - //avr->videoCurrentTSPacket.dts = avr->videoCurrentTSPacket.cts = sysclock; - //ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = currentFrameTimeProcessed; - ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = gf_m2ts_get_sys_clock(ts->muxer); - ts->videoCurrentTSPacket.data = data; - ts->videoCurrentTSPacket.data_len = encoded; - ts->videoCurrentTSPacket.flags = GF_ESI_DATA_HAS_CTS | GF_ESI_DATA_HAS_DTS; - //if (ts_packets_sent == 0) { - ts->videoCurrentTSPacket.flags|=GF_ESI_DATA_AU_START|GF_ESI_DATA_AU_END ; - //} - void_input_ctrl(ts->video, GF_ESI_INPUT_DATA_PULL, NULL); - sendTSMux(ts); - } - return 0; + if ( ts->muxer ) + { // currentFrameTimeProcessed / 1000; // + ts->videoCurrentTSPacket.dts = videoCodecContext->coded_frame->coded_picture_number; + ts->videoCurrentTSPacket.cts = videoCodecContext->coded_frame->display_picture_number; + //avr->videoCurrentTSPacket.dts = avr->videoCurrentTSPacket.cts = sysclock; + //ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = currentFrameTimeProcessed; + ts->videoCurrentTSPacket.dts = ts->videoCurrentTSPacket.cts = gf_m2ts_get_sys_clock(ts->muxer); + ts->videoCurrentTSPacket.data = data; + ts->videoCurrentTSPacket.data_len = encoded; + ts->videoCurrentTSPacket.flags = GF_ESI_DATA_HAS_CTS | GF_ESI_DATA_HAS_DTS; + //if (ts_packets_sent == 0) { + ts->videoCurrentTSPacket.flags|=GF_ESI_DATA_AU_START|GF_ESI_DATA_AU_END ; + //} + void_input_ctrl(ts->video, GF_ESI_INPUT_DATA_PULL, NULL); + sendTSMux(ts); + } + return 0; } GF_AbstractTSMuxer * ts_amux_new(GF_AVRedirect * avr, u32 videoBitrateInBitsPerSec, u32 audioBitRateInBitsPerSec, GF_Socket * ts_output_udp_sk) { - GF_AbstractTSMuxer * ts = malloc(sizeof(GF_AbstractTSMuxer)); - ts->muxer = gf_m2ts_mux_new ( videoBitrateInBitsPerSec * audioBitRateInBitsPerSec + 1000000, 0, 1 ); - ts->ts_output_udp_sk = ts_output_udp_sk; - { - //u32 cur_pid = 100; /*PIDs start from 100*/ - GF_M2TS_Mux_Program *program = gf_m2ts_mux_program_add ( ts->muxer, 1, 100, 0, 0 ); - - ts->video = gf_malloc( sizeof( GF_ESInterface)); - memset( ts->video, 0, sizeof( GF_ESInterface)); - //audio.stream_id = 101; - //gf_m2ts_program_stream_add ( program, &audifero, 101, 1 ); - ts->video->stream_id = 101; - ts->video->stream_type = GF_STREAM_VISUAL; - ts->video->bit_rate = 410000; - /* ms resolution */ - ts->video->timescale = 1000; - - ts->video->object_type_indication = GPAC_OTI_VIDEO_MPEG2_SIMPLE; - ts->video->input_udta = ts; + GF_AbstractTSMuxer * ts = malloc(sizeof(GF_AbstractTSMuxer)); + ts->muxer = gf_m2ts_mux_new ( videoBitrateInBitsPerSec * audioBitRateInBitsPerSec + 1000000, 0, 1 ); + ts->ts_output_udp_sk = ts_output_udp_sk; + { + //u32 cur_pid = 100; /*PIDs start from 100*/ + GF_M2TS_Mux_Program *program = gf_m2ts_mux_program_add ( ts->muxer, 1, 100, 0, 0 ); + + ts->video = gf_malloc( sizeof( GF_ESInterface)); + memset( ts->video, 0, sizeof( GF_ESInterface)); + //audio.stream_id = 101; + //gf_m2ts_program_stream_add ( program, &audifero, 101, 1 ); + ts->video->stream_id = 101; + ts->video->stream_type = GF_STREAM_VISUAL; + ts->video->bit_rate = 410000; + /* ms resolution */ + ts->video->timescale = 1000; + + ts->video->object_type_indication = GPAC_OTI_VIDEO_MPEG2_SIMPLE; + ts->video->input_udta = ts; #ifdef TS_MUX_MODE_PUT - ts->video->caps = GF_ESI_SIGNAL_DTS; + ts->video->caps = GF_ESI_SIGNAL_DTS; #else - avr->video->input_ctrl = void_input_ctrl; - avr->video->caps = GF_ESI_AU_PULL_CAP | GF_ESI_SIGNAL_DTS; + avr->video->input_ctrl = void_input_ctrl; + avr->video->caps = GF_ESI_AU_PULL_CAP | GF_ESI_SIGNAL_DTS; #endif /* TS_MUX_MODE_PUT */ - ts->audio = gf_malloc( sizeof( GF_ESInterface)); - memset( ts->audio, 0, sizeof( GF_ESInterface)); - ts->audio->stream_id = 102; - ts->audio->stream_type = GF_STREAM_AUDIO; - ts->audio->bit_rate = audioBitRateInBitsPerSec; - /* ms resolution */ - ts->audio->timescale = 1000; + ts->audio = gf_malloc( sizeof( GF_ESInterface)); + memset( ts->audio, 0, sizeof( GF_ESInterface)); + ts->audio->stream_id = 102; + ts->audio->stream_type = GF_STREAM_AUDIO; + ts->audio->bit_rate = audioBitRateInBitsPerSec; + /* ms resolution */ + ts->audio->timescale = 1000; - ts->audio->object_type_indication = GPAC_OTI_AUDIO_MPEG2_PART3; - ts->audio->input_udta = ts; + ts->audio->object_type_indication = GPAC_OTI_AUDIO_MPEG2_PART3; + ts->audio->input_udta = ts; #ifdef TS_MUX_MODE_PUT - ts->audio->caps = 0; + ts->audio->caps = 0; #else - ts->audio->input_ctrl = void_input_ctrl; - ts->audio->caps = GF_ESI_AU_PULL_CAP; + ts->audio->input_ctrl = void_input_ctrl; + ts->audio->caps = GF_ESI_AU_PULL_CAP; #endif /* TS_MUX_MODE_PUT */ - gf_m2ts_program_stream_add ( program, ts->video, 101, 0 ); - gf_m2ts_program_stream_add ( program, ts->audio, 102, 1 ); + gf_m2ts_program_stream_add ( program, ts->video, 101, 0 ); + gf_m2ts_program_stream_add ( program, ts->audio, 102, 1 ); - assert(program->streams->mpeg2_stream_type == GF_M2TS_VIDEO_MPEG2 || - program->streams->mpeg2_stream_type == GF_M2TS_VIDEO_DCII); - } - gf_m2ts_mux_update_config ( ts->muxer, 1 ); - return ts; + assert(program->streams->mpeg2_stream_type == GF_M2TS_VIDEO_MPEG2 || + program->streams->mpeg2_stream_type == GF_M2TS_VIDEO_DCII); + } + gf_m2ts_mux_update_config ( ts->muxer, 1 ); + return ts; } void ts_amux_del(GF_AbstractTSMuxer * ts) { - if (!ts) - return; - if ( ts->ts_output_udp_sk ) - { - gf_sk_del ( ts->ts_output_udp_sk ); - ts->ts_output_udp_sk = NULL; - } + if (!ts) + return; + if ( ts->ts_output_udp_sk ) + { + gf_sk_del ( ts->ts_output_udp_sk ); + ts->ts_output_udp_sk = NULL; + } } diff --git a/modules/redirect_av/redirect_av.c b/modules/redirect_av/redirect_av.c index e0a8d1d..3fb5874 100644 --- a/modules/redirect_av/redirect_av.c +++ b/modules/redirect_av/redirect_av.c @@ -76,7 +76,7 @@ #if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(__GNUC__) -#if defined(_WIN32_WCE) +#if defined(_WIN32_WCE) #pragma comment(lib, "toolhelp") #pragma comment(lib, "winsock") #endif @@ -84,11 +84,6 @@ #define _TOSTR(_val) #_val #define TOSTR(_val) _TOSTR(_val) -#pragma comment(lib, "avcodec-"TOSTR(LIBAVCODEC_VERSION_MAJOR) ) -#pragma comment(lib, "avformat-"TOSTR(LIBAVFORMAT_VERSION_MAJOR) ) -#pragma comment(lib, "avutil-"TOSTR(LIBAVUTIL_VERSION_MAJOR) ) -#pragma comment(lib, "swscale-"TOSTR(LIBSWSCALE_VERSION_MAJOR) ) - #endif @@ -122,106 +117,106 @@ static const char * AVR_VIDEO_CODEC_OPTION = "VideoCodec"; */ static u32 audio_encoding_thread_run(void *param) { - u8 * inBuff; - u8 * outBuff; - u32 inBuffSize, outBuffSize, samplesReaden, toRead; - u64 myTime = 0; - u32 frameCountSinceReset = 0; - u32 lastCurrentTime; - Bool sendPts = 1; - GF_AVRedirect * avr = (GF_AVRedirect*) param; - AVCodecContext * ctx = NULL; - assert( avr ); - - outBuffSize = FF_MIN_BUFFER_SIZE; - - outBuff = gf_malloc(outBuffSize* sizeof(u8)); - inBuff = NULL; + u8 * inBuff; + u8 * outBuff; + u32 inBuffSize, outBuffSize, samplesReaden, toRead; + u64 myTime = 0; + u32 frameCountSinceReset = 0; + u32 lastCurrentTime; + Bool sendPts = 1; + GF_AVRedirect * avr = (GF_AVRedirect*) param; + AVCodecContext * ctx = NULL; + assert( avr ); + + outBuffSize = FF_MIN_BUFFER_SIZE; + + outBuff = gf_malloc(outBuffSize* sizeof(u8)); + inBuff = NULL; #ifdef DUMP_MP3 - FILE * mp3 = fopen("/tmp/dump.mp3", "w"); + FILE * mp3 = fopen("/tmp/dump.mp3", "w"); #endif /* DUMP_MP3 */ - sendPts = 1; - gf_sc_add_audio_listener ( avr->term->compositor, &avr->audio_listen ); - while (avr->is_running && !ctx) { - ctx = ts_get_audio_codec_context(avr->ts_implementation); - gf_sleep(16); - } - if (!ctx) { - goto exit; - } - - fprintf(stderr, "******* Audio Codec Context = %d/%d, start="LLU", frame_size=%u\n", ctx->time_base.num, ctx->time_base.den, ctx->timecode_frame_start, ctx->frame_size); - samplesReaden = ctx->frame_size * ctx->channels; - - //fprintf(stderr, "SETUP input sample size=%u, output samplesize=%u, buffsize=%u, samplesReaden=%u\n", ctx->input_sample_size, ctx->frame_size, sizeof(outbuf), samplesReaden); - // 2 chars are needed for each short - toRead = samplesReaden * 2; - inBuffSize = toRead; - inBuff = gf_malloc(inBuffSize * sizeof(u8)); - while (avr->is_running && !avr->audioCurrentTime) { - gf_sleep(16); - } - myTime = lastCurrentTime = avr->audioCurrentTime; - frameCountSinceReset = 0; - while (avr->is_running) { - u32 readen; - if (U32_ABS(avr->audioCurrentTime, myTime) > 25000) { - //GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] Drift in audio : audioCurrentTime = %u, myTime=%u, resync...\n", avr->audioCurrentTime, myTime)); - //myTime = lastCurrentTime = avr->audioCurrentTime; - //frameCountSinceReset = 0; - sendPts = 1; - } - while (toRead <= gf_ringbuffer_available_for_read(avr->pcmAudio) ) { - memset( inBuff, 0, inBuffSize); - memset( outBuff, 0, outBuffSize); - readen = gf_ringbuffer_read(avr->pcmAudio, inBuff, toRead); - assert( readen == toRead ); - if (avr->encode) - { - //u32 oldFrameSize = ctx->frame_size; - //ctx->frame_size = readable / (2 * ctx->channels); - //assert( oldFrameSize <= ctx->frame_size ); - /* buf_size * input_sample_size / output_sample_size */ - int encoded = avcodec_encode_audio(ctx, outBuff, outBuffSize, (const short *) inBuff); - if (encoded < 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[RedirectAV]: failed to encode audio, buffer size=%u, readen=%u, frame_size=%u\n", outBuffSize, readen, ctx->frame_size)); - } else if (encoded > 0) { - ts_encode_audio_frame(avr->ts_implementation, outBuff, encoded, sendPts ? myTime : AV_NOPTS_VALUE ); - frameCountSinceReset++; + sendPts = 1; + gf_sc_add_audio_listener ( avr->term->compositor, &avr->audio_listen ); + while (avr->is_running && !ctx) { + ctx = ts_get_audio_codec_context(avr->ts_implementation); + gf_sleep(16); + } + if (!ctx) { + goto exit; + } + + fprintf(stderr, "******* Audio Codec Context = %d/%d, start="LLU", frame_size=%u\n", ctx->time_base.num, ctx->time_base.den, ctx->timecode_frame_start, ctx->frame_size); + samplesReaden = ctx->frame_size * ctx->channels; + + //fprintf(stderr, "SETUP input sample size=%u, output samplesize=%u, buffsize=%u, samplesReaden=%u\n", ctx->input_sample_size, ctx->frame_size, sizeof(outbuf), samplesReaden); + // 2 chars are needed for each short + toRead = samplesReaden * 2; + inBuffSize = toRead; + inBuff = gf_malloc(inBuffSize * sizeof(u8)); + while (avr->is_running && !avr->audioCurrentTime) { + gf_sleep(16); + } + myTime = lastCurrentTime = avr->audioCurrentTime; + frameCountSinceReset = 0; + while (avr->is_running) { + u32 readen; + if (U32_ABS(avr->audioCurrentTime, myTime) > 25000) { + //GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[AVRedirect] Drift in audio : audioCurrentTime = %u, myTime=%u, resync...\n", avr->audioCurrentTime, myTime)); + //myTime = lastCurrentTime = avr->audioCurrentTime; + //frameCountSinceReset = 0; + sendPts = 1; + } + while (toRead <= gf_ringbuffer_available_for_read(avr->pcmAudio) ) { + memset( inBuff, 0, inBuffSize); + memset( outBuff, 0, outBuffSize); + readen = gf_ringbuffer_read(avr->pcmAudio, inBuff, toRead); + assert( readen == toRead ); + if (avr->encode) + { + //u32 oldFrameSize = ctx->frame_size; + //ctx->frame_size = readable / (2 * ctx->channels); + //assert( oldFrameSize <= ctx->frame_size ); + /* buf_size * input_sample_size / output_sample_size */ + int encoded = avcodec_encode_audio(ctx, outBuff, outBuffSize, (const short *) inBuff); + if (encoded < 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[RedirectAV]: failed to encode audio, buffer size=%u, readen=%u, frame_size=%u\n", outBuffSize, readen, ctx->frame_size)); + } else if (encoded > 0) { + ts_encode_audio_frame(avr->ts_implementation, outBuff, encoded, sendPts ? myTime : AV_NOPTS_VALUE ); + frameCountSinceReset++; #ifdef DUMP_MP3 - gf_fwrite( outBuff, sizeof(char), encoded, mp3); + gf_fwrite( outBuff, sizeof(char), encoded, mp3); #endif /* DUMP_MP3 */ - //if (ctx->codec->id == CODEC_ID_MP3) { - /* It seems the MP3 codec only fetches 50% of data... */ - // myTime= lastCurrentTime + (frameCountSinceReset * ctx->frame_size * 500 / ctx->sample_rate); - //} else - //myTime = lastCurrentTime + (frameCountSinceReset * toRead * 1000 / ctx->sample_rate/ ctx->channels / 4); - /* Avoid overflow , multiply by 10 and divide sample rate by 100 instead of *1000 / sampleRate */ - myTime = lastCurrentTime + (frameCountSinceReset * toRead * 10 / (ctx->sample_rate / 100) / ctx->channels / 4); - //sendPts = 0; - sendPts = 1; - } else { - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[RedirectAV]: no encoded frame.\n")); - //frameCountSinceReset++; - } - //ctx->frame_size = oldFrameSize; - } - } + //if (ctx->codec->id == CODEC_ID_MP3) { + /* It seems the MP3 codec only fetches 50% of data... */ + // myTime= lastCurrentTime + (frameCountSinceReset * ctx->frame_size * 500 / ctx->sample_rate); + //} else + //myTime = lastCurrentTime + (frameCountSinceReset * toRead * 1000 / ctx->sample_rate/ ctx->channels / 4); + /* Avoid overflow , multiply by 10 and divide sample rate by 100 instead of *1000 / sampleRate */ + myTime = lastCurrentTime + (frameCountSinceReset * toRead * 10 / (ctx->sample_rate / 100) / ctx->channels / 4); + //sendPts = 0; + sendPts = 1; + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[RedirectAV]: no encoded frame.\n")); + //frameCountSinceReset++; + } + //ctx->frame_size = oldFrameSize; + } + } gf_sleep(1); - } + } exit: - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending audio encoding thread...\n")); - if (inBuff) - gf_free( inBuff ); - if (outBuff) - gf_free( outBuff ); + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending audio encoding thread...\n")); + if (inBuff) + gf_free( inBuff ); + if (outBuff) + gf_free( outBuff ); #ifdef DUMP_MP3 - if (mp3) - fclose(mp3); + if (mp3) + fclose(mp3); #endif /* DUMP_MP3 */ - if (avr->term) - gf_sc_remove_audio_listener ( avr->term->compositor, &avr->audio_listen ); - return GF_OK; + if (avr->term) + gf_sc_remove_audio_listener ( avr->term->compositor, &avr->audio_listen ); + return GF_OK; } #endif @@ -231,261 +226,261 @@ exit: */ static u32 video_encoding_thread_run(void *param) { - GF_AVRedirect * avr = (GF_AVRedirect*) param; - u64 currentFrameTimeProcessed = 0, lastEncodedFrameTime = 0; - AVCodecContext * ctx = NULL; - assert( avr ); - gf_sc_add_video_listener ( avr->term->compositor, &avr->video_listen ); - while (avr->is_running && (!ctx || !avr->swsContext)) { - ctx = ts_get_video_codec_context(avr->ts_implementation); - gf_sleep(16); - } - if (!ctx) { - goto exit; - } - fprintf(stderr, "******* Video Codec Context = %d/%d, start="LLU"\n", ctx->time_base.num, ctx->time_base.den, ctx->timecode_frame_start); - while (avr->is_running) { - { - gf_mx_p(avr->frameMutex); - while (!avr->frameTime || currentFrameTimeProcessed == avr->frameTime) { - gf_mx_v(avr->frameMutex); - if (!avr->is_running) { - goto exit; - } - gf_mx_p(avr->frameMutex); + GF_AVRedirect * avr = (GF_AVRedirect*) param; + u64 currentFrameTimeProcessed = 0, lastEncodedFrameTime = 0; + AVCodecContext * ctx = NULL; + assert( avr ); + gf_sc_add_video_listener ( avr->term->compositor, &avr->video_listen ); + while (avr->is_running && (!ctx || !avr->swsContext)) { + ctx = ts_get_video_codec_context(avr->ts_implementation); + gf_sleep(16); + } + if (!ctx) { + goto exit; + } + fprintf(stderr, "******* Video Codec Context = %d/%d, start="LLU"\n", ctx->time_base.num, ctx->time_base.den, ctx->timecode_frame_start); + while (avr->is_running) { + { + gf_mx_p(avr->frameMutex); + while (!avr->frameTime || currentFrameTimeProcessed == avr->frameTime) { + gf_mx_v(avr->frameMutex); + if (!avr->is_running) { + goto exit; + } + gf_mx_p(avr->frameMutex); gf_sleep(1); - } - assert( currentFrameTimeProcessed != avr->frameTime); - currentFrameTimeProcessed = avr->frameTime; - { + } + assert( currentFrameTimeProcessed != avr->frameTime); + currentFrameTimeProcessed = avr->frameTime; + { avpicture_fill ( ( AVPicture * ) avr->RGBpicture, avr->frame, PIX_FMT_RGB24, avr->srcWidth, avr->srcHeight ); - assert( avr->swsContext ); - sws_scale ( avr->swsContext, + assert( avr->swsContext ); + sws_scale ( avr->swsContext, #ifdef USE_AVCODEC2 - ( const uint8_t * const * ) + ( const uint8_t * const * ) #else - ( uint8_t ** ) + ( uint8_t ** ) #endif /* USE_AVCODEC2 */ - avr->RGBpicture->data, avr->RGBpicture->linesize, - 0, avr->srcHeight, - avr->YUVpicture->data, avr->YUVpicture->linesize ); + avr->RGBpicture->data, avr->RGBpicture->linesize, + 0, avr->srcHeight, + avr->YUVpicture->data, avr->YUVpicture->linesize ); #ifdef AVR_DUMP_RAW_AVI - if ( AVI_write_frame ( avr->avi_out, avr->frame, avr->size, 1 ) <0 ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error writing video frame\n" ) ); - } + if ( AVI_write_frame ( avr->avi_out, avr->frame, avr->size, 1 ) <0 ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error writing video frame\n" ) ); + } #endif /* AVR_DUMP_RAW_AVI */ - gf_mx_v(avr->frameMutex); - if (avr->encode) - { - int written; - u32 sysclock_begin = gf_sys_clock(), sysclock_end=0; - avr->YUVpicture->pts = currentFrameTimeProcessed; - { - int got_packet = 0; - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = avr->videoOutbuf; - pkt.size = avr->videoOutbufSize; - written = avcodec_encode_video2(ctx, &pkt, avr->YUVpicture, &got_packet); - if (written >= 0) { - written = pkt.size; - if (got_packet) { - ctx->coded_frame->pts = pkt.pts; - ctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); - } - } - } - sysclock_end = gf_sys_clock(); - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("Encoding frame PTS="LLD", frameNum=%u, time="LLU", size=%d\t in %ums\n", avr->YUVpicture->pts, avr->YUVpicture->coded_picture_number, currentFrameTimeProcessed, written, sysclock_end-sysclock_begin)); - ctx->coded_frame->pts = currentFrameTimeProcessed; - - if (written<0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error while encoding video frame =%d\n", written ) ); - } else { - if (written>0) - ts_encode_video_frame(avr->ts_implementation, avr->videoOutbuf, written); - lastEncodedFrameTime = currentFrameTimeProcessed; - } - } - } - } - avr->frameTimeEncoded = currentFrameTimeProcessed; - gf_sleep(1); - } /* End of main loop */ + gf_mx_v(avr->frameMutex); + if (avr->encode) + { + int written; + u32 sysclock_begin = gf_sys_clock(), sysclock_end=0; + avr->YUVpicture->pts = currentFrameTimeProcessed; + { + int got_packet = 0; + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = avr->videoOutbuf; + pkt.size = avr->videoOutbufSize; + written = avcodec_encode_video2(ctx, &pkt, avr->YUVpicture, &got_packet); + if (written >= 0) { + written = pkt.size; + if (got_packet) { + ctx->coded_frame->pts = pkt.pts; + ctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); + } + } + } + sysclock_end = gf_sys_clock(); + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("Encoding frame PTS="LLD", frameNum=%u, time="LLU", size=%d\t in %ums\n", avr->YUVpicture->pts, avr->YUVpicture->coded_picture_number, currentFrameTimeProcessed, written, sysclock_end-sysclock_begin)); + ctx->coded_frame->pts = currentFrameTimeProcessed; + + if (written<0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error while encoding video frame =%d\n", written ) ); + } else { + if (written>0) + ts_encode_video_frame(avr->ts_implementation, avr->videoOutbuf, written); + lastEncodedFrameTime = currentFrameTimeProcessed; + } + } + } + } + avr->frameTimeEncoded = currentFrameTimeProcessed; + gf_sleep(1); + } /* End of main loop */ exit: - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending video encoding thread...\n")); - if (avr->term) - gf_sc_remove_video_listener ( avr->term->compositor, &avr->video_listen ); - return 0; + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Ending video encoding thread...\n")); + if (avr->term) + gf_sc_remove_video_listener ( avr->term->compositor, &avr->video_listen ); + return 0; } #define VIDEO_RATE 400000 static Bool start_if_needed(GF_AVRedirect *avr) { - enum PixelFormat pxlFormatForCodec = PIX_FMT_YUV420P; - if (avr->is_open) - return 0; - gf_mx_p(avr->frameMutex); - if (avr->is_open) { - gf_mx_v(avr->frameMutex); - return 0; - } + enum PixelFormat pxlFormatForCodec = PIX_FMT_YUV420P; + if (avr->is_open) + return 0; + gf_mx_p(avr->frameMutex); + if (avr->is_open) { + gf_mx_v(avr->frameMutex); + return 0; + } if (!avr->srcWidth || !avr->srcHeight #if REDIRECT_AV_AUDIO_ENABLED - || !avr->audioSampleRate || !avr->audioChannels + || !avr->audioSampleRate || !avr->audioChannels #endif - ) { - gf_mx_v(avr->frameMutex); - return 3; - } + ) { + gf_mx_v(avr->frameMutex); + return 3; + } #ifdef AVR_DUMP_RAW_AVI - avr->avi_out = AVI_open_output_file ( "dump.avi" ); - if ( !avr->avi_out ) - { - gf_mx_v(avr->frameMutex); - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error opening output AVI file\n" ) ); - return 4; - } + avr->avi_out = AVI_open_output_file ( "dump.avi" ); + if ( !avr->avi_out ) + { + gf_mx_v(avr->frameMutex); + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error opening output AVI file\n" ) ); + return 4; + } #endif /* AVR_DUMP_RAW_AVI */ - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Initializing...\n")); - if (!avr->pcmAudio) - avr->pcmAudio = gf_ringbuffer_new(48000*2*2); //1s of 16b stereo 48000Hz - - /* Setting up the video encoding ... */ - { - avr->YUVpicture = avr->RGBpicture = NULL; - avr->videoOutbuf = NULL; + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Initializing...\n")); + if (!avr->pcmAudio) + avr->pcmAudio = gf_ringbuffer_new(48000*2*2); //1s of 16b stereo 48000Hz + + /* Setting up the video encoding ... */ + { + avr->YUVpicture = avr->RGBpicture = NULL; + avr->videoOutbuf = NULL; #if REDIRECT_AV_AUDIO_ENABLED - if ( !avr->audioCodec) - { - gf_mx_v(avr->frameMutex); - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Cannot find audio codec.\n" ) ); - return 1; - } + if ( !avr->audioCodec) + { + gf_mx_v(avr->frameMutex); + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Cannot find audio codec.\n" ) ); + return 1; + } #endif - if ( !avr->videoCodec ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Cannot find video codec.\n" ) ); - return 2; - } - - if (avr->videoCodec->id == CODEC_ID_MJPEG) { - pxlFormatForCodec = PIX_FMT_YUVJ420P; - } - - avr->RGBpicture = avcodec_alloc_frame(); - assert ( avr->RGBpicture ); - avr->RGBpicture->data[0] = NULL; - avr->YUVpicture = avcodec_alloc_frame(); - assert ( avr->YUVpicture ); - { - u32 sz = sizeof ( uint8_t ) * avpicture_get_size ( pxlFormatForCodec, avr->srcWidth, avr->srcHeight ); - avr->yuv_data = av_malloc ( sz ); /* size for YUV 420 */ - assert ( avr->yuv_data ); - memset ( avr->yuv_data, 0, sz ); - avpicture_fill ( ( AVPicture* ) avr->YUVpicture, avr->yuv_data, pxlFormatForCodec, avr->srcWidth, avr->srcHeight ); - avr->YUVpicture->coded_picture_number = 0; - } - avr->videoOutbufSize = avr->srcHeight * avr->srcWidth * 4; - avr->videoOutbuf = gf_malloc ( avr->videoOutbufSize ); - memset ( avr->videoOutbuf, 0, avr->videoOutbufSize ); - } + if ( !avr->videoCodec ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Cannot find video codec.\n" ) ); + return 2; + } + + if (avr->videoCodec->id == CODEC_ID_MJPEG) { + pxlFormatForCodec = PIX_FMT_YUVJ420P; + } + + avr->RGBpicture = avcodec_alloc_frame(); + assert ( avr->RGBpicture ); + avr->RGBpicture->data[0] = NULL; + avr->YUVpicture = avcodec_alloc_frame(); + assert ( avr->YUVpicture ); + { + u32 sz = sizeof ( uint8_t ) * avpicture_get_size ( pxlFormatForCodec, avr->srcWidth, avr->srcHeight ); + avr->yuv_data = av_malloc ( sz ); /* size for YUV 420 */ + assert ( avr->yuv_data ); + memset ( avr->yuv_data, 0, sz ); + avpicture_fill ( ( AVPicture* ) avr->YUVpicture, avr->yuv_data, pxlFormatForCodec, avr->srcWidth, avr->srcHeight ); + avr->YUVpicture->coded_picture_number = 0; + } + avr->videoOutbufSize = avr->srcHeight * avr->srcWidth * 4; + avr->videoOutbuf = gf_malloc ( avr->videoOutbufSize ); + memset ( avr->videoOutbuf, 0, avr->videoOutbufSize ); + } #ifdef AVR_DUMP_RAW_AVI - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Open output AVI file %s\n", "dump.avi" ) ); + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Open output AVI file %s\n", "dump.avi" ) ); #endif /* AVR_DUMP_RAW_AVI */ - /* Setting up the TS mux */ - { - /* - GF_Socket * ts_output_udp_sk = gf_sk_new ( GF_SOCK_TYPE_UDP ); - if ( gf_sk_is_multicast_address ( avr->udp_address ) ) - { - e = gf_sk_setup_multicast ( ts_output_udp_sk, avr->udp_address, avr->udp_port, 0, 0, NULL ); - } - else - { - e = gf_sk_bind ( ts_output_udp_sk, NULL, avr->udp_port, avr->udp_address, avr->udp_port, GF_SOCK_REUSE_PORT ); - } - gf_sk_set_buffer_size(ts_output_udp_sk, 0, 188 * TS_PACKETS_PER_UDP_PACKET); - gf_sk_set_block_mode(ts_output_udp_sk, 0);*/ - assert( avr->destination ); - avr->ts_implementation = ts_amux_new(avr, VIDEO_RATE, avr->srcWidth, avr->srcHeight, audioCodecBitrate); - } - /* - if ( e ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error while initializing UDP address %s\n", gf_error_to_string ( e ) ) ); - return e; - } - */ - avr->is_open = avr->ts_implementation != NULL; - gf_mx_v(avr->frameMutex); - return avr->is_open ? 1 : 0; + /* Setting up the TS mux */ + { + /* + GF_Socket * ts_output_udp_sk = gf_sk_new ( GF_SOCK_TYPE_UDP ); + if ( gf_sk_is_multicast_address ( avr->udp_address ) ) + { + e = gf_sk_setup_multicast ( ts_output_udp_sk, avr->udp_address, avr->udp_port, 0, 0, NULL ); + } + else + { + e = gf_sk_bind ( ts_output_udp_sk, NULL, avr->udp_port, avr->udp_address, avr->udp_port, GF_SOCK_REUSE_PORT ); + } + gf_sk_set_buffer_size(ts_output_udp_sk, 0, 188 * TS_PACKETS_PER_UDP_PACKET); + gf_sk_set_block_mode(ts_output_udp_sk, 0);*/ + assert( avr->destination ); + avr->ts_implementation = ts_amux_new(avr, VIDEO_RATE, avr->srcWidth, avr->srcHeight, audioCodecBitrate); + } + /* + if ( e ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error while initializing UDP address %s\n", gf_error_to_string ( e ) ) ); + return e; + } + */ + avr->is_open = avr->ts_implementation != NULL; + gf_mx_v(avr->frameMutex); + return avr->is_open ? 1 : 0; } static GF_Err avr_open ( GF_AVRedirect *avr ) { - assert( avr ); - if ( avr->is_open) - return GF_OK; - if (!avr->is_running) { - avr->is_running = 1; - gf_th_run(avr->encodingThread, video_encoding_thread_run, avr); + assert( avr ); + if ( avr->is_open) + return GF_OK; + if (!avr->is_running) { + avr->is_running = 1; + gf_th_run(avr->encodingThread, video_encoding_thread_run, avr); #if REDIRECT_AV_AUDIO_ENABLED - gf_th_run(avr->audioEncodingThread, audio_encoding_thread_run, avr); + gf_th_run(avr->audioEncodingThread, audio_encoding_thread_run, avr); #endif - } - return GF_OK; + } + return GF_OK; } static void avr_on_audio_frame ( void *udta, char *buffer, u32 buffer_size, u32 time, u32 delay_ms ) { - GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; - if (start_if_needed(avr)) - return; + GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; + if (start_if_needed(avr)) + return; #ifdef AVR_DUMP_RAW_AVI - AVI_write_audio ( avr->avi_out, buffer, buffer_size ); + AVI_write_audio ( avr->avi_out, buffer, buffer_size ); #endif /* AVR_DUMP_RAW_AVI */ - { - gf_ringbuffer_write(avr->pcmAudio, buffer, buffer_size); - avr->audioCurrentTime = time - delay_ms; - } + { + gf_ringbuffer_write(avr->pcmAudio, buffer, buffer_size); + avr->audioCurrentTime = time - delay_ms; + } } static void avr_on_audio_reconfig ( void *udta, u32 samplerate, u32 bits_per_sample, u32 nb_channel, u32 channel_cfg ) { - GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; - if (avr->audioSampleRate != samplerate || avr->audioChannels != nb_channel) { - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Audio %u Hz, bitsPerSample=%u, nbchannels=%u\n", samplerate, bits_per_sample, nb_channel)); + GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; + if (avr->audioSampleRate != samplerate || avr->audioChannels != nb_channel) { + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[AVRedirect] Audio %u Hz, bitsPerSample=%u, nbchannels=%u\n", samplerate, bits_per_sample, nb_channel)); #ifdef AVR_DUMP_RAW_AVI - AVI_set_audio ( avr->avi_out, nb_channel, samplerate, bits_per_sample, WAVE_FORMAT_PCM, 0 ); + AVI_set_audio ( avr->avi_out, nb_channel, samplerate, bits_per_sample, WAVE_FORMAT_PCM, 0 ); #endif /* AVR_DUMP_RAW_AVI */ - avr->audioChannels = nb_channel; - avr->audioSampleRate = samplerate; - } + avr->audioChannels = nb_channel; + avr->audioSampleRate = samplerate; + } } static void avr_on_video_frame ( void *udta, u32 time ) { - u32 i, j; - GF_Err e; - GF_VideoSurface fb; - GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; - - if (start_if_needed(avr)) - return; - gf_mx_p(avr->frameMutex); - e = gf_sc_get_screen_buffer ( avr->term->compositor, &fb, 0 ); - if ( e ) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error grabing frame buffer %s\n", gf_error_to_string ( e ) ) ); - return; - } - /*convert colorspace for input frame*/ + u32 i, j; + GF_Err e; + GF_VideoSurface fb; + GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; + + if (start_if_needed(avr)) + return; + gf_mx_p(avr->frameMutex); + e = gf_sc_get_screen_buffer ( avr->term->compositor, &fb, 0 ); + if ( e ) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Error grabing frame buffer %s\n", gf_error_to_string ( e ) ) ); + return; + } + /*convert colorspace for input frame*/ if (fb.pixel_format == GF_PIXEL_ARGB) { /*ARGB -> RGB24*/ for (i=0; iframe+i*fb.width*3, fb.video_buffer+i*fb.pitch_y, fb.width*3); } - avr->frameTime = time; - gf_mx_v(avr->frameMutex); - gf_sc_release_screen_buffer ( avr->term->compositor, &fb ); - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ( "[AVRedirect] Writing video frame\n" ) ); + avr->frameTime = time; + gf_mx_v(avr->frameMutex); + gf_sc_release_screen_buffer ( avr->term->compositor, &fb ); + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ( "[AVRedirect] Writing video frame\n" ) ); } static void avr_on_video_reconfig ( void *udta, u32 width, u32 height, u8 bpp ) { - GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; + GF_AVRedirect *avr = ( GF_AVRedirect * ) udta; - if ((avr->srcHeight != height || avr->srcWidth != width)) - { + if ((avr->srcHeight != height || avr->srcWidth != width)) + { #ifdef AVR_DUMP_RAW_AVI - char comp[5]; - comp[0] = comp[1] = comp[2] = comp[3] = comp[4] = 0; - AVI_set_video ( avr->avi_out, width, height, 30, comp ); + char comp[5]; + comp[0] = comp[1] = comp[2] = comp[3] = comp[4] = 0; + AVI_set_video ( avr->avi_out, width, height, 30, comp ); #endif /* AVR_DUMP_RAW_AVI */ - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Video reconfig width %d height %d\n", width, height ) ); - gf_mx_p(avr->frameMutex); - if ( avr->frame ) gf_free ( avr->frame ); - avr->size = 3*width*height; - avr->frame = gf_malloc ( sizeof ( char ) *avr->size ); - avr->srcWidth = width; - avr->srcHeight = height; - avr->swsContext = sws_getCachedContext ( avr->swsContext, avr->srcWidth, avr->srcHeight, PIX_FMT_RGB24, avr->srcWidth, avr->srcHeight, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL ); - gf_mx_v(avr->frameMutex); - } + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Video reconfig width %d height %d\n", width, height ) ); + gf_mx_p(avr->frameMutex); + if ( avr->frame ) gf_free ( avr->frame ); + avr->size = 3*width*height; + avr->frame = gf_malloc ( sizeof ( char ) *avr->size ); + avr->srcWidth = width; + avr->srcHeight = height; + avr->swsContext = sws_getCachedContext ( avr->swsContext, avr->srcWidth, avr->srcHeight, PIX_FMT_RGB24, avr->srcWidth, avr->srcHeight, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL ); + gf_mx_v(avr->frameMutex); + } } @@ -542,24 +537,24 @@ static void avr_on_video_reconfig ( void *udta, u32 width, u32 height, u8 bpp ) */ static Bool ts_thread_run(void *param) { - GF_Err e; - GF_AVRedirect * avr = (GF_AVRedirect*) param; - assert( avr ); - gf_mx_p(avr->tsMutex); - while (!avr->frameTimeEncoded && avr->is_running) { - gf_mx_v(avr->tsMutex); - gf_sleep(1); - gf_mx_p(avr->tsMutex); - } - fprintf(stderr, "avr->frameTimeEncoded="LLU"\n", avr->frameTimeEncoded); - - while (avr->is_running) { - e = sendTSMux(avr); - gf_mx_v(avr->tsMutex); - gf_mx_p(avr->tsMutex); - } - gf_mx_v(avr->tsMutex); - return 0; + GF_Err e; + GF_AVRedirect * avr = (GF_AVRedirect*) param; + assert( avr ); + gf_mx_p(avr->tsMutex); + while (!avr->frameTimeEncoded && avr->is_running) { + gf_mx_v(avr->tsMutex); + gf_sleep(1); + gf_mx_p(avr->tsMutex); + } + fprintf(stderr, "avr->frameTimeEncoded="LLU"\n", avr->frameTimeEncoded); + + while (avr->is_running) { + e = sendTSMux(avr); + gf_mx_v(avr->tsMutex); + gf_mx_p(avr->tsMutex); + } + gf_mx_v(avr->tsMutex); + return 0; } #endif /* MULTITHREAD_REDIRECT_AV */ @@ -576,32 +571,32 @@ static const char * possibleCodecs = "supported codecs : MPEG-1, MPEG-2, MPEG-4, static void avr_close ( GF_AVRedirect *avr ) { - if ( !avr->is_open ) return; - avr->is_open = 0; + if ( !avr->is_open ) return; + avr->is_open = 0; #ifdef AVR_DUMP_RAW_AVI - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Closing output AVI file\n" ) ); - AVI_close ( avr->avi_out ); - avr->avi_out = NULL; + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ( "[AVRedirect] Closing output AVI file\n" ) ); + AVI_close ( avr->avi_out ); + avr->avi_out = NULL; #endif /* AVR_DUMP_RAW_AVI */ } static Bool avr_on_event ( void *udta, GF_Event *evt, Bool consumed_by_compositor ) { - GF_AVRedirect *avr = udta; - switch ( evt->type ) - { - case GF_EVENT_CONNECT: - if ( evt->connect.is_connected ) - { - avr_open ( avr ); - } - else - { - avr_close ( avr ); - } - break; - } - return 0; + GF_AVRedirect *avr = udta; + switch ( evt->type ) + { + case GF_EVENT_CONNECT: + if ( evt->connect.is_connected ) + { + avr_open ( avr ); + } + else + { + avr_close ( avr ); + } + break; + } + return 0; } static const char * AVR_ENABLED_OPTION = "Enabled"; @@ -614,242 +609,242 @@ static const char * AVR_DESTINATION = "destination"; static Bool avr_process ( GF_TermExt *termext, u32 action, void *param ) { - const char *opt; - GF_AVRedirect *avr = termext->udta; - - switch ( action ) - { - case GF_TERM_EXT_START: - avr->term = ( GF_Terminal * ) param; - opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_ENABLED_OPTION ); - if ( !opt ) - gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_ENABLED_OPTION, "no" ); - if ( !opt || strcmp ( opt, "yes" ) ) return 0; - opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_VIDEO_CODEC_OPTION ); - avr->globalLock = gf_global_resource_lock("AVRedirect:output"); - if (!avr->globalLock) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("Failed to lock global resource 'AVRedirect:output', another GPAC instance must be running, disabling AVRedirect\n")); - return 0; - } + const char *opt; + GF_AVRedirect *avr = termext->udta; + + switch ( action ) + { + case GF_TERM_EXT_START: + avr->term = ( GF_Terminal * ) param; + opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_ENABLED_OPTION ); + if ( !opt ) + gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_ENABLED_OPTION, "no" ); + if ( !opt || strcmp ( opt, "yes" ) ) return 0; + opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_VIDEO_CODEC_OPTION ); + avr->globalLock = gf_global_resource_lock("AVRedirect:output"); + if (!avr->globalLock) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("Failed to lock global resource 'AVRedirect:output', another GPAC instance must be running, disabling AVRedirect\n")); + return 0; + } #ifndef AVIO_FLAG_WRITE - /* must be called before using avcodec lib */ - avcodec_init(); + /* must be called before using avcodec lib */ + avcodec_init(); #endif - /* register all the codecs */ - avcodec_register_all(); - if ( !opt ) - gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_VIDEO_CODEC_OPTION, possibleCodecs ); - { - if ( !opt ) - { - avr->videoCodec = avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); - } - else if ( !strcmp ( "MPEG-1", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG1VIDEO ); - } - else if ( !strcmp ( "MPEG-2", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); - } - else if ( !strcmp ( "MPEG-4", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG4 ); - } - else if ( !strcmp ( "MSMPEG-4", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MSMPEG4V3 ); - } - else if ( !strcmp ( "H263", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263 ); - } - else if ( !strcmp ( "RV10", opt ) ) - { - avr->videoCodec = avcodec_find_encoder ( CODEC_ID_RV10 ); - } - else if ( !strcmp ( "H263P", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263P ); - } - else if ( !strcmp ( "H263I", opt ) ) - { - avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263I ); - } - else if ( !strcmp( "MJPEG", opt)) - { - avr->videoCodec=avcodec_find_encoder( CODEC_ID_MJPEG); - } - else - { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Not a known Video codec : %s, using MPEG-2 video instead, %s\n", opt, possibleCodecs ) ); - avr->videoCodec = avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); - } - } + /* register all the codecs */ + avcodec_register_all(); + if ( !opt ) + gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_VIDEO_CODEC_OPTION, possibleCodecs ); + { + if ( !opt ) + { + avr->videoCodec = avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); + } + else if ( !strcmp ( "MPEG-1", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG1VIDEO ); + } + else if ( !strcmp ( "MPEG-2", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); + } + else if ( !strcmp ( "MPEG-4", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MPEG4 ); + } + else if ( !strcmp ( "MSMPEG-4", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_MSMPEG4V3 ); + } + else if ( !strcmp ( "H263", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263 ); + } + else if ( !strcmp ( "RV10", opt ) ) + { + avr->videoCodec = avcodec_find_encoder ( CODEC_ID_RV10 ); + } + else if ( !strcmp ( "H263P", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263P ); + } + else if ( !strcmp ( "H263I", opt ) ) + { + avr->videoCodec=avcodec_find_encoder ( CODEC_ID_H263I ); + } + else if ( !strcmp( "MJPEG", opt)) + { + avr->videoCodec=avcodec_find_encoder( CODEC_ID_MJPEG); + } + else + { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] Not a known Video codec : %s, using MPEG-2 video instead, %s\n", opt, possibleCodecs ) ); + avr->videoCodec = avcodec_find_encoder ( CODEC_ID_MPEG2VIDEO ); + } + } #if REDIRECT_AV_AUDIO_ENABLED - avr->audioCodec = avcodec_find_encoder(CODEC_ID_MP2); + avr->audioCodec = avcodec_find_encoder(CODEC_ID_MP2); #endif - /* - opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_ADDRESS_OPTION); - if (!opt) { - gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_ADDRESS_OPTION, DEFAULT_UDP_OUT_ADDRESS); - avr->udp_address = DEFAULT_UDP_OUT_ADDRESS; - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s not set, using %s\n", AVR_UDP_ADDRESS_OPTION, DEFAULT_UDP_OUT_ADDRESS ) ); - } else - avr->udp_address = opt; - opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_PORT_OPTION); - if (opt) { - char *endPtr = NULL; - unsigned int x = strtoul(opt, &endPtr, 10); - if (endPtr == opt || x > 65536) { - fprintf(stderr, "Failed to parse : %s\n", opt); - opt = NULL; - } else - avr->udp_port = (u16) x; - } - if (!opt) { - gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_PORT_OPTION, DEFAULT_UDP_OUT_PORT_STR); - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s is not set or valid, using %s\n", AVR_UDP_PORT_OPTION, DEFAULT_UDP_OUT_PORT_STR ) ); - avr->udp_port = DEFAULT_UDP_OUT_PORT; - } - */ - opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_DESTINATION); - if (!opt) { - gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_DESTINATION, AVR_DEFAULT_DESTINATION); - avr->destination = AVR_DEFAULT_DESTINATION; - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s not set, using %s\n", AVR_DESTINATION, AVR_DEFAULT_DESTINATION ) ); - } else - avr->destination = opt; - avr->audio_listen.udta = avr; - avr->audio_listen.on_audio_frame = avr_on_audio_frame; - avr->audio_listen.on_audio_reconfig = avr_on_audio_reconfig; - avr->video_listen.udta = avr; - avr->video_listen.on_video_frame = avr_on_video_frame; - avr->video_listen.on_video_reconfig = avr_on_video_reconfig; - - avr->term_listen.udta = avr; - avr->term_listen.on_event = avr_on_event; - gf_term_add_event_filter ( avr->term, &avr->term_listen ); - return 1; - - case GF_TERM_EXT_STOP: - gf_term_remove_event_filter ( avr->term, &avr->term_listen ); - avr->term = NULL; - break; - - /*if not threaded, perform our tasks here*/ - case GF_TERM_EXT_PROCESS: - break; - } - return 0; + /* + opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_ADDRESS_OPTION); + if (!opt) { + gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_ADDRESS_OPTION, DEFAULT_UDP_OUT_ADDRESS); + avr->udp_address = DEFAULT_UDP_OUT_ADDRESS; + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s not set, using %s\n", AVR_UDP_ADDRESS_OPTION, DEFAULT_UDP_OUT_ADDRESS ) ); + } else + avr->udp_address = opt; + opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_PORT_OPTION); + if (opt) { + char *endPtr = NULL; + unsigned int x = strtoul(opt, &endPtr, 10); + if (endPtr == opt || x > 65536) { + fprintf(stderr, "Failed to parse : %s\n", opt); + opt = NULL; + } else + avr->udp_port = (u16) x; + } + if (!opt) { + gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_UDP_PORT_OPTION, DEFAULT_UDP_OUT_PORT_STR); + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s is not set or valid, using %s\n", AVR_UDP_PORT_OPTION, DEFAULT_UDP_OUT_PORT_STR ) ); + avr->udp_port = DEFAULT_UDP_OUT_PORT; + } + */ + opt = gf_modules_get_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_DESTINATION); + if (!opt) { + gf_modules_set_option ( ( GF_BaseInterface* ) termext, moduleName, AVR_DESTINATION, AVR_DEFAULT_DESTINATION); + avr->destination = AVR_DEFAULT_DESTINATION; + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ( "[AVRedirect] %s not set, using %s\n", AVR_DESTINATION, AVR_DEFAULT_DESTINATION ) ); + } else + avr->destination = opt; + avr->audio_listen.udta = avr; + avr->audio_listen.on_audio_frame = avr_on_audio_frame; + avr->audio_listen.on_audio_reconfig = avr_on_audio_reconfig; + avr->video_listen.udta = avr; + avr->video_listen.on_video_frame = avr_on_video_frame; + avr->video_listen.on_video_reconfig = avr_on_video_reconfig; + + avr->term_listen.udta = avr; + avr->term_listen.on_event = avr_on_event; + gf_term_add_event_filter ( avr->term, &avr->term_listen ); + return 1; + + case GF_TERM_EXT_STOP: + gf_term_remove_event_filter ( avr->term, &avr->term_listen ); + avr->term = NULL; + break; + + /*if not threaded, perform our tasks here*/ + case GF_TERM_EXT_PROCESS: + break; + } + return 0; } GF_TermExt *avr_new() { - GF_TermExt *dr; - GF_AVRedirect *uir; - GF_SAFEALLOC ( dr, GF_TermExt ); - GF_REGISTER_MODULE_INTERFACE ( dr, GF_TERM_EXT_INTERFACE, "GPAC Output Recorder", "gpac distribution" ); - - GF_SAFEALLOC ( uir, GF_AVRedirect ); - dr->process = avr_process; - dr->udta = uir; - uir->encodingMutex = gf_mx_new("RedirectAV_encodingMutex"); - assert( uir->encodingMutex); - uir->frameMutex = gf_mx_new("RedirectAV_frameMutex"); - uir->encodingThread = gf_th_new("RedirectAV_EncodingThread"); - uir->audioEncodingThread = gf_th_new("RedirectAV_AudioEncodingThread"); - uir->encode = 1; - uir->is_open = 0; - uir->is_running = 0; - return dr; + GF_TermExt *dr; + GF_AVRedirect *uir; + GF_SAFEALLOC ( dr, GF_TermExt ); + GF_REGISTER_MODULE_INTERFACE ( dr, GF_TERM_EXT_INTERFACE, "GPAC Output Recorder", "gpac distribution" ); + + GF_SAFEALLOC ( uir, GF_AVRedirect ); + dr->process = avr_process; + dr->udta = uir; + uir->encodingMutex = gf_mx_new("RedirectAV_encodingMutex"); + assert( uir->encodingMutex); + uir->frameMutex = gf_mx_new("RedirectAV_frameMutex"); + uir->encodingThread = gf_th_new("RedirectAV_EncodingThread"); + uir->audioEncodingThread = gf_th_new("RedirectAV_AudioEncodingThread"); + uir->encode = 1; + uir->is_open = 0; + uir->is_running = 0; + return dr; } void avr_delete ( GF_BaseInterface *ifce ) { - GF_TermExt *dr = ( GF_TermExt * ) ifce; - GF_AVRedirect *avr = dr->udta; - avr->is_running = 0; - /* Ensure encoding is finished */ - gf_mx_p(avr->frameMutex); - gf_mx_v(avr->frameMutex); - gf_sleep(200); - gf_th_stop(avr->encodingThread); - gf_mx_del(avr->frameMutex); - avr->frameMutex = NULL; - gf_th_del(avr->encodingThread); - avr->encodingThread = NULL; - gf_mx_del(avr->encodingMutex); - avr->encodingMutex = NULL; - if ( avr->ts_implementation ) - { - ts_amux_del(avr->ts_implementation); - avr->ts_implementation = NULL; - } - avr->videoCodec = NULL; - if ( avr->YUVpicture ) - { - av_free ( avr->YUVpicture ); - } - if ( avr->yuv_data ) - av_free ( avr->yuv_data ); - avr->yuv_data = NULL; - avr->YUVpicture = NULL; - if ( avr->RGBpicture ) - { - av_free ( avr->RGBpicture ); - } - avr->RGBpicture = NULL; - if ( avr->swsContext ) - sws_freeContext ( avr->swsContext ); - avr->swsContext = NULL; - if ( avr->videoOutbuf ) - gf_free ( avr->videoOutbuf ); - avr->videoOutbuf = NULL; - if ( avr->pcmAudio ) - gf_ringbuffer_del(avr->pcmAudio); - avr->pcmAudio = NULL; - gf_global_resource_unlock(avr->globalLock); - avr->globalLock = NULL; - if (avr->audioEncodingThread){ - gf_th_stop(avr->audioEncodingThread); - gf_th_del(avr->audioEncodingThread); - } - avr->audioEncodingThread = NULL; - gf_free ( avr ); - gf_free ( dr ); + GF_TermExt *dr = ( GF_TermExt * ) ifce; + GF_AVRedirect *avr = dr->udta; + avr->is_running = 0; + /* Ensure encoding is finished */ + gf_mx_p(avr->frameMutex); + gf_mx_v(avr->frameMutex); + gf_sleep(200); + gf_th_stop(avr->encodingThread); + gf_mx_del(avr->frameMutex); + avr->frameMutex = NULL; + gf_th_del(avr->encodingThread); + avr->encodingThread = NULL; + gf_mx_del(avr->encodingMutex); + avr->encodingMutex = NULL; + if ( avr->ts_implementation ) + { + ts_amux_del(avr->ts_implementation); + avr->ts_implementation = NULL; + } + avr->videoCodec = NULL; + if ( avr->YUVpicture ) + { + av_free ( avr->YUVpicture ); + } + if ( avr->yuv_data ) + av_free ( avr->yuv_data ); + avr->yuv_data = NULL; + avr->YUVpicture = NULL; + if ( avr->RGBpicture ) + { + av_free ( avr->RGBpicture ); + } + avr->RGBpicture = NULL; + if ( avr->swsContext ) + sws_freeContext ( avr->swsContext ); + avr->swsContext = NULL; + if ( avr->videoOutbuf ) + gf_free ( avr->videoOutbuf ); + avr->videoOutbuf = NULL; + if ( avr->pcmAudio ) + gf_ringbuffer_del(avr->pcmAudio); + avr->pcmAudio = NULL; + gf_global_resource_unlock(avr->globalLock); + avr->globalLock = NULL; + if (avr->audioEncodingThread) { + gf_th_stop(avr->audioEncodingThread); + gf_th_del(avr->audioEncodingThread); + } + avr->audioEncodingThread = NULL; + gf_free ( avr ); + gf_free ( dr ); } GPAC_MODULE_EXPORT const u32 *QueryInterfaces() { - static u32 si [] = - { - GF_TERM_EXT_INTERFACE, - 0 - }; - return si; + static u32 si [] = + { + GF_TERM_EXT_INTERFACE, + 0 + }; + return si; } GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface ( u32 InterfaceType ) { - if ( InterfaceType == GF_TERM_EXT_INTERFACE ) return ( GF_BaseInterface * ) avr_new(); - return NULL; + if ( InterfaceType == GF_TERM_EXT_INTERFACE ) return ( GF_BaseInterface * ) avr_new(); + return NULL; } GPAC_MODULE_EXPORT void ShutdownInterface ( GF_BaseInterface *ifce ) { - switch ( ifce->InterfaceType ) - { - case GF_TERM_EXT_INTERFACE: - avr_delete ( ifce ); - break; - } + switch ( ifce->InterfaceType ) + { + case GF_TERM_EXT_INTERFACE: + avr_delete ( ifce ); + break; + } } diff --git a/modules/redirect_av/ts_muxer.h b/modules/redirect_av/ts_muxer.h index 086c15f..4430e54 100644 --- a/modules/redirect_av/ts_muxer.h +++ b/modules/redirect_av/ts_muxer.h @@ -60,48 +60,48 @@ typedef struct avr_ts_muxer GF_AbstractTSMuxer; typedef struct { - GF_Terminal *term; + GF_Terminal *term; - Bool is_open; - GF_AudioListener audio_listen; - GF_VideoListener video_listen; - GF_TermEventFilter term_listen; + Bool is_open; + GF_AudioListener audio_listen; + GF_VideoListener video_listen; + GF_TermEventFilter term_listen; #ifdef AVR_DUMP_RAW_AVI - avi_t *avi_out; + avi_t *avi_out; #endif - char *frame; - u32 size; - GF_AbstractTSMuxer * ts_implementation; - Bool encode; - AVCodec *audioCodec; - AVCodec *videoCodec; - AVFrame *YUVpicture, *RGBpicture; - struct SwsContext * swsContext; - uint8_t * yuv_data; - uint8_t * videoOutbuf; - u32 videoOutbufSize; - GF_Ringbuffer * pcmAudio; - u32 audioCurrentTime; - GF_Thread * encodingThread; - GF_Thread * audioEncodingThread; - GF_Mutex * frameMutex; - GF_Mutex * encodingMutex; - volatile Bool is_running; - u64 frameTime; - u64 frameTimeEncoded; - /** - * Audio parameters for encoding - */ - u32 audioSampleRate; - u16 audioChannels; - /** - * Video parameters for encoding - */ - u32 srcWidth; - u32 srcHeight; - const char * destination; - GF_GlobalLock * globalLock; - Bool started; + char *frame; + u32 size; + GF_AbstractTSMuxer * ts_implementation; + Bool encode; + AVCodec *audioCodec; + AVCodec *videoCodec; + AVFrame *YUVpicture, *RGBpicture; + struct SwsContext * swsContext; + uint8_t * yuv_data; + uint8_t * videoOutbuf; + u32 videoOutbufSize; + GF_Ringbuffer * pcmAudio; + u32 audioCurrentTime; + GF_Thread * encodingThread; + GF_Thread * audioEncodingThread; + GF_Mutex * frameMutex; + GF_Mutex * encodingMutex; + volatile Bool is_running; + u64 frameTime; + u64 frameTimeEncoded; + /** + * Audio parameters for encoding + */ + u32 audioSampleRate; + u16 audioChannels; + /** + * Video parameters for encoding + */ + u32 srcWidth; + u32 srcHeight; + const char * destination; + GF_GlobalLock * globalLock; + Bool started; } GF_AVRedirect; GF_AbstractTSMuxer * ts_amux_new(GF_AVRedirect * avr, u32 videoBitrateInBitsPerSec, u32 width, u32 height, u32 audioBitRateInBitsPerSec); diff --git a/modules/rtp_in/rtp_in.c b/modules/rtp_in/rtp_in.c index cc2fff2..a93c55b 100644 --- a/modules/rtp_in/rtp_in.c +++ b/modules/rtp_in/rtp_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -141,7 +141,7 @@ u32 RP_Thread(void *param) /*for interleaved channels don't read too fast, query the buffer occupancy*/ if (ch->flags & RTP_INTERLEAVED) { com.base.on_channel = ch->channel; - gf_term_on_command(rtp->service, &com, GF_OK); + gf_service_command(rtp->service, &com, GF_OK); /*if no buffering, use a default value (3 sec of data should do it)*/ if (!com.buffer.max) com.buffer.max = 3000; if (com.buffer.occupancy <= com.buffer.max) ch->rtsp->flags |= RTSP_TCP_FLUSH; @@ -156,7 +156,7 @@ u32 RP_Thread(void *param) RP_ProcessCommands(sess); if (sess->connect_error) { - gf_term_on_connect(sess->owner->service, NULL, sess->connect_error); + gf_service_connect_ack(sess->owner->service, NULL, sess->connect_error); sess->connect_error = 0; } @@ -167,7 +167,7 @@ u32 RP_Thread(void *param) gf_sleep(1); } - if (rtp->dnload) gf_term_download_del(rtp->dnload); + if (rtp->dnload) gf_service_download_del(rtp->dnload); rtp->dnload = NULL; rtp->th_state = 2; @@ -180,11 +180,11 @@ static const char * sdp_exts = "sdp"; static const char * sdp_desc = "OnDemand Media/Multicast Session"; -static u32 RP_RegisterMimeTypes(const GF_InputService *plug){ - if (!plug) - return 0; - gf_term_register_mime_type(plug, sdp_mime, sdp_exts, sdp_desc); - return 1; +static u32 RP_RegisterMimeTypes(const GF_InputService *plug) { + if (!plug) + return 0; + gf_service_register_mime(plug, sdp_mime, sdp_exts, sdp_desc); + return 1; } static Bool RP_CanHandleURL(GF_InputService *plug, const char *url) @@ -194,14 +194,14 @@ static Bool RP_CanHandleURL(GF_InputService *plug, const char *url) return 0; sExt = strrchr(url, '.'); - if (sExt && gf_term_check_extension(plug, sdp_mime, sdp_exts, sdp_desc, sExt)) return 1; + if (sExt && gf_service_check_mime_register(plug, sdp_mime, sdp_exts, sdp_desc, sExt)) return 1; /*local */ if (strstr(url, "data:application/sdp")) return 1; /*embedded data*/ if (strstr(url, "data:application/mpeg4-od-au;base64") || - strstr(url, "data:application/mpeg4-bifs-au;base64") || - strstr(url, "data:application/mpeg4-es-au;base64")) return 1; + strstr(url, "data:application/mpeg4-bifs-au;base64") || + strstr(url, "data:application/mpeg4-es-au;base64")) return 1; /*we need rtsp/tcp , rtsp/udp or direct RTP sender (no control)*/ if (!strnicmp(url, "rtsp://", 7) || !strnicmp(url, "rtspu://", 8) || !strnicmp(url, "rtp://", 6)) return 1; @@ -218,7 +218,7 @@ GF_Err RP_ConnectServiceEx(GF_InputService *plug, GF_ClientService *serv, const /*store user address*/ priv->service = serv; - if (priv->dnload) gf_term_download_del(priv->dnload); + if (priv->dnload) gf_service_download_del(priv->dnload); priv->dnload = NULL; GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] Opening service %s\n", url)); @@ -266,7 +266,7 @@ GF_Err RP_ConnectServiceEx(GF_InputService *plug, GF_ClientService *serv, const sess = RP_NewSession(priv, (char *) the_url); gf_free(the_url); if (!sess) { - gf_term_on_connect(serv, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(serv, NULL, GF_NOT_SUPPORTED); } else { RP_Describe(sess, 0, NULL); } @@ -275,7 +275,7 @@ GF_Err RP_ConnectServiceEx(GF_InputService *plug, GF_ClientService *serv, const /*direct RTP (no control) or embedded data - this means the service is attached to a single channel (no IOD) reply right away*/ - gf_term_on_connect(serv, NULL, GF_OK); + gf_service_connect_ack(serv, NULL, GF_OK); RP_SetupObjects(priv); return GF_OK; } @@ -344,7 +344,7 @@ static GF_Err RP_CloseService(GF_InputService *plug) if (rtp->th_state==1) rtp->th_state = 0; /*confirm close*/ - gf_term_on_disconnect(rtp->service, NULL, GF_OK); + gf_service_disconnect_ack(rtp->service, NULL, GF_OK); return GF_OK; } @@ -414,9 +414,9 @@ static GF_Err RP_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, con } /*data: url*/ else if (strstr(url, "data:application/mpeg4-od-au;base64") - || strstr(url, "data:application/mpeg4-bifs-au;base64") - || strstr(url, "data:application/mpeg4-es-au;base64") - ) { + || strstr(url, "data:application/mpeg4-bifs-au;base64") + || strstr(url, "data:application/mpeg4-es-au;base64") + ) { GF_SAFEALLOC(ch, RTPStream); ch->control = gf_strdup(url); @@ -460,7 +460,7 @@ static GF_Err RP_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) ch->flags &= ~RTP_CONNECTED; ch->channel = NULL; gf_mx_v(priv->mx); - gf_term_on_disconnect(priv->service, channel, GF_OK); + gf_service_disconnect_ack(priv->service, channel, GF_OK); return GF_OK; } @@ -469,7 +469,7 @@ static void gf_rtp_switch_quality(RTPClient *rtp, Bool switch_up) u32 i,count; RTPStream *ch, *cur_ch; GF_NetworkCommand com; - + count = gf_list_count(rtp->channels); /*find the current stream*/ ch = cur_ch = NULL; @@ -505,9 +505,9 @@ static void gf_rtp_switch_quality(RTPClient *rtp, Bool switch_up) rtp->cur_mid = ch->mid; break; } - + } - } + } } else { @@ -528,12 +528,12 @@ static void gf_rtp_switch_quality(RTPClient *rtp, Bool switch_up) cur_ch->status = RTP_Connected; com.command_type = GF_NET_CHAN_RESET; com.base.on_channel = cur_ch; - gf_term_on_command(rtp->service, &com, GF_OK); + gf_service_command(rtp->service, &com, GF_OK); rtp->cur_mid = ch->mid; break; - } + } } - } + } } GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("Switch from ES%d to ES %d\n", cur_ch->mid, ch->mid)); return; @@ -709,9 +709,18 @@ static GF_Err RP_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) } else { time = gf_sys_clock() - ch->stat_start_time; } - bps = 8.0f * ch->rtp_bytes; bps *= 1000; bps /= time; com->net_stats.bw_down = (u32) bps; - bps = 8.0f * ch->rtcp_bytes; bps *= 1000; bps /= time; com->net_stats.ctrl_bw_down = (u32) bps; - bps = 8.0f * gf_rtp_get_tcp_bytes_sent(ch->rtp_ch); bps *= 1000; bps /= time; com->net_stats.ctrl_bw_up = (u32) bps; + bps = 8.0f * ch->rtp_bytes; + bps *= 1000; + bps /= time; + com->net_stats.bw_down = (u32) bps; + bps = 8.0f * ch->rtcp_bytes; + bps *= 1000; + bps /= time; + com->net_stats.ctrl_bw_down = (u32) bps; + bps = 8.0f * gf_rtp_get_tcp_bytes_sent(ch->rtp_ch); + bps *= 1000; + bps /= time; + com->net_stats.ctrl_bw_up = (u32) bps; } return GF_OK; default: @@ -781,9 +790,9 @@ static Bool RP_CanHandleURLInService(GF_InputService *plug, const char *url) RTPClient *priv = (RTPClient *)plug->priv; if (strstr(url, "data:application/mpeg4-od-au;base64") - || strstr(url, "data:application/mpeg4-bifs-au;base64") - || strstr(url, "data:application/mpeg4-es-au;base64") - ) return 1; + || strstr(url, "data:application/mpeg4-bifs-au;base64") + || strstr(url, "data:application/mpeg4-es-au;base64") + ) return 1; if (url[0]=='#') { Bool st_type = 0; diff --git a/modules/rtp_in/rtp_in.h b/modules/rtp_in/rtp_in.h index 16ebb1a..6e05923 100644 --- a/modules/rtp_in/rtp_in.h +++ b/modules/rtp_in/rtp_in.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #ifndef RTP_IN_H @@ -91,7 +91,7 @@ typedef struct // Bool handle_announce; Double last_ntp; - + Bool session_migration; Bool is_scalable; @@ -121,7 +121,7 @@ typedef struct _rtp_session GF_RTSPSession *session; /*session ID for aggregated stream control*/ char *session_id; - + /*session control string*/ char *control; @@ -145,6 +145,8 @@ void RP_SetupObjects(RTPClient *rtp); void RP_ProcessCommands(RTSPSession *sess); +void RP_SendMessage(GF_ClientService *service, GF_Err e, const char *message); + /*RTP channel state*/ enum { @@ -179,7 +181,7 @@ enum RTP_INTERLEAVED = (1<<2), /*broadcast emultaion is on (no time control for stream)*/ RTP_FORCE_BROADCAST = (1<<3), - + /*RTP channel runtime flags*/ /*set if next command (PLAY/PAUSE) is to be skipped (aggregation control)*/ @@ -200,14 +202,14 @@ enum RTP_SET_TIME_NONE = 0, RTP_SET_TIME_RTP, RTP_SET_TIME_RTP_SEEK, - }; +}; /*rtp channel*/ typedef struct { /*module*/ RTPClient *owner; - + /*channel flags*/ u32 flags; @@ -225,7 +227,7 @@ typedef struct /*logical app channel*/ LPNETCHANNEL channel; u32 status; - + u32 ES_ID, OD_ID; char *control; @@ -250,7 +252,7 @@ typedef struct /*stream id*/ u32 mid; - + u32 prev_stream; u32 next_stream; u32 base_stream; diff --git a/modules/rtp_in/rtp_session.c b/modules/rtp_in/rtp_session.c index 388228e..114a7db 100644 --- a/modules/rtp_in/rtp_session.c +++ b/modules/rtp_in/rtp_session.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rtp_in.h" @@ -32,24 +32,24 @@ void RP_SendFailure(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) { char sMsg[1000]; sprintf(sMsg, "Cannot send %s", com->method); - gf_term_on_message(sess->owner->service, e, sMsg); + RP_SendMessage(sess->owner->service, e, sMsg); } GF_Err RP_ProcessResponse(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) { - if (!strcmp(com->method, GF_RTSP_DESCRIBE)) + if (!strcmp(com->method, GF_RTSP_DESCRIBE)) return RP_ProcessDescribe(sess, com, e); - else if (!strcmp(com->method, GF_RTSP_SETUP)) + else if (!strcmp(com->method, GF_RTSP_SETUP)) RP_ProcessSetup(sess, com, e); - else if (!strcmp(com->method, GF_RTSP_TEARDOWN)) + else if (!strcmp(com->method, GF_RTSP_TEARDOWN)) RP_ProcessTeardown(sess, com, e); - else if (!strcmp(com->method, GF_RTSP_PLAY) || !strcmp(com->method, GF_RTSP_PAUSE)) + else if (!strcmp(com->method, GF_RTSP_PLAY) || !strcmp(com->method, GF_RTSP_PAUSE)) RP_ProcessUserCommand(sess, com, e); return GF_OK; } /*access to command list is protected bymutex, BUT ONLY ACCESS - this way we're sure that command queueing -from app will not deadlock if we're waiting for the app to release any mutex (don't forget play request may +from app will not deadlock if we're waiting for the app to release any mutex (don't forget play request may come on stream N while we're processing stream P setup)*/ static GF_RTSPCommand *RP_GetCommand(RTSPSession *sess) { @@ -93,7 +93,7 @@ void RP_ProcessCommands(RTSPSession *sess) if (e!=GF_OK) { RP_RemoveCommand(sess); gf_rtsp_command_del(com); - gf_term_on_connect(sess->owner->service, NULL, e); + gf_service_connect_ack(sess->owner->service, NULL, e); return; } @@ -108,10 +108,10 @@ void RP_ProcessCommands(RTSPSession *sess) if (!strcmp(com->method, GF_RTSP_DESCRIBE) && (time_out < 10000) ) time_out = 10000; /*don't waste time waiting for teardown ACK, half a sec is enough. If server is not replying - in time it is likely to never reply (happens with RTP over RTSP) -> kill session + in time it is likely to never reply (happens with RTP over RTSP) -> kill session and create new one*/ else if (!strcmp(com->method, GF_RTSP_TEARDOWN) && (time>=500) ) time = time_out; - + //signal what's going on if (time >= time_out) { if (!strcmp(com->method, GF_RTSP_TEARDOWN)) { @@ -147,7 +147,7 @@ void RP_ProcessCommands(RTSPSession *sess) return; } /*process*/ - com->User_Agent = (char*)gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(sess->owner->service), "Downloader", "UserAgent"); + com->User_Agent = (char*)gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(sess->owner->service), "Downloader", "UserAgent"); if (!com->User_Agent) com->User_Agent = "GPAC " GPAC_VERSION " RTSP Client"; com->Accept_Language = RTSP_LANGUAGE; /*if no session assigned and a session ID is valid, use it*/ @@ -164,9 +164,9 @@ void RP_ProcessCommands(RTSPSession *sess) } } /*preprocess play/stop/pause before sending (aggregation)*/ - if (!strcmp(com->method, GF_RTSP_PLAY) - || !strcmp(com->method, GF_RTSP_PAUSE) - || !strcmp(com->method, GF_RTSP_TEARDOWN)) { + if (!strcmp(com->method, GF_RTSP_PLAY) + || !strcmp(com->method, GF_RTSP_PAUSE) + || !strcmp(com->method, GF_RTSP_TEARDOWN)) { //command is skipped if (!RP_PreprocessUserCom(sess, com)) { e = GF_BAD_PARAM; @@ -225,7 +225,7 @@ RTSPSession *RP_CheckSession(RTPClient *rtp, char *control) RTSPSession *sess; if (!control) return NULL; - if (!strcmp(control, "*")) control = (char *) gf_term_get_service_url(rtp->service); + if (!strcmp(control, "*")) control = (char *) gf_service_get_url(rtp->service); i=0; while ( (sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i)) ) { @@ -262,9 +262,9 @@ RTSPSession *RP_NewSession(RTPClient *rtp, char *session_control) tmp->session = rtsp; - szCtrl = (char *)gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Network", "MobileIPEnabled"); + szCtrl = (char *)gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Network", "MobileIPEnabled"); if (szCtrl && !strcmp(szCtrl, "yes")) { - char *ip = (char *)gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Network", "MobileIP"); + char *ip = (char *)gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Network", "MobileIP"); gf_rtsp_set_mobile_ip(rtsp, ip); } @@ -274,7 +274,7 @@ RTSPSession *RP_NewSession(RTPClient *rtp, char *session_control) gf_rtsp_set_buffer_size(rtsp, RTSP_BUFFER_SIZE); } tmp->rtsp_commands = gf_list_new(); - tmp->rtsp_rsp = gf_rtsp_response_new(); + tmp->rtsp_rsp = gf_rtsp_response_new(); gf_list_add(rtp->sessions, tmp); @@ -381,7 +381,7 @@ void RP_ResetSession(RTSPSession *sess, GF_Err e) gf_rtsp_command_del(com); //first = 0; } - /*reset session state*/ + /*reset session state*/ gf_rtsp_session_reset(sess->session, 1); sess->flags &= ~RTSP_WAIT_REPLY; } @@ -398,5 +398,15 @@ void RP_DelSession(RTSPSession *sess) gf_free(sess); } +void RP_SendMessage(GF_ClientService *service, GF_Err e, const char *message) +{ + GF_NetworkCommand com; + memset(&com, 0, sizeof(com)); + com.command_type = GF_NET_SERVICE_EVENT; + com.send_event.evt.type = GF_EVENT_MESSAGE; + com.send_event.evt.message.message = message; + com.send_event.evt.message.error = e; + gf_service_command(service, &com, GF_OK); +} #endif /*GPAC_DISABLE_STREAMING*/ diff --git a/modules/rtp_in/rtp_signaling.c b/modules/rtp_in/rtp_signaling.c index e43981d..6be53b9 100644 --- a/modules/rtp_in/rtp_signaling.c +++ b/modules/rtp_in/rtp_signaling.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rtp_in.h" @@ -90,14 +90,14 @@ void RP_Setup(RTPStream *ch) GF_RTSPCommand *com; GF_RTSPTransport *trans; - com = gf_rtsp_command_new(); + com = gf_rtsp_command_new(); com->method = gf_strdup(GF_RTSP_SETUP); def_first_port = 0; - opt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ForceFirstPort"); + opt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ForceFirstPort"); if (opt) def_first_port = atoi(opt); - opt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ForceMulticastIP"); + opt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ForceMulticastIP"); //setup ports if unicast non interleaved or multicast if (gf_rtp_is_unicast(ch->rtp_ch) && (ch->owner->transport_mode != 1) && !gf_rtp_is_interleaved(ch->rtp_ch) ) { @@ -113,25 +113,25 @@ void RP_Setup(RTPStream *ch) trans->SSRC = 0; /*override transport: */ - /*1: multicast forced*/ - opt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ForceMulticastIP"); + /*1: multicast forced*/ + opt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ForceMulticastIP"); if (opt) { trans->IsUnicast = 0; trans->destination = gf_strdup(opt); - opt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ForceMulticastTTL"); + opt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ForceMulticastTTL"); trans->TTL = opt ? atoi(opt) : 127; if (trans->Profile) gf_free(trans->Profile); trans->Profile = gf_strdup(GF_RTSP_PROFILE_RTP_AVP); if (!(ch->rtsp->flags & RTSP_DSS_SERVER) ) { trans->port_first = trans->client_port_first; trans->port_last = trans->client_port_last; - /*this is correct but doesn't work with DSS: the server expects "client_port" to indicate + /*this is correct but doesn't work with DSS: the server expects "client_port" to indicate the multicast port, not "port" - this will send both*/ //trans->client_port_first = trans->client_port_last = 0; } gf_rtp_setup_transport(ch->rtp_ch, trans, NULL); } - /*2: RTP over RTSP forced*/ + /*2: RTP over RTSP forced*/ else if (ch->rtsp->flags & RTSP_FORCE_INTER) { if (trans->Profile) gf_free(trans->Profile); trans->Profile = gf_strdup(GF_RTSP_PROFILE_RTP_AVP_TCP); @@ -196,7 +196,7 @@ void RP_ProcessSetup(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) RTPStream *ch; u32 i; GF_RTSPTransport *trans; - + ch = (RTPStream *)com->user_data; if (e) goto exit; @@ -225,8 +225,8 @@ void RP_ProcessSetup(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) i=0; while ((trans = (GF_RTSPTransport *)gf_list_enum(sess->rtsp_rsp->Transports, &i))) { /*copy over previous ports (hack for some servers overriding client ports)*/ - const char *opt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ForceClientPorts"); - if (opt && !stricmp(opt, "yes")) + const char *opt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ForceClientPorts"); + if (opt && !stricmp(opt, "yes")) gf_rtp_get_ports(ch->rtp_ch, &trans->client_port_first, &trans->client_port_last); if (gf_rtp_is_interleaved(ch->rtp_ch) && !trans->IsInterleaved) { @@ -251,9 +251,9 @@ void RP_ProcessSetup(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) } exit: - /*confirm only on first connect, otherwise this is a re-SETUP of the rtsp session, not the channel*/ + /*confirm only on first connect, otherwise this is a re-SETUP of the rtsp session, not the channel*/ if (! (ch->flags & RTP_CONNECTED) ) { - if (!e) + if (!e) ch->flags |= RTP_CONNECTED; RP_ConfirmChannelConnect(ch, e); } @@ -272,7 +272,7 @@ Bool RP_PreprocessDescribe(RTSPSession *sess, GF_RTSPCommand *com) ChannelDescribe *ch_desc; /*not a channel describe*/ if (!com->user_data) { - gf_term_on_message(sess->owner->service, GF_OK, "Connecting..."); + RP_SendMessage(sess->owner->service, GF_OK, "Connecting..."); return 1; } @@ -282,7 +282,7 @@ Bool RP_PreprocessDescribe(RTSPSession *sess, GF_RTSPCommand *com) /*channel has been described already, skip describe and send setup directly*/ RP_SetupChannel(ch, ch_desc); - + if (ch_desc->esd_url) gf_free(ch_desc->esd_url); gf_free(ch_desc); return 0; @@ -318,7 +318,7 @@ GF_Err RP_ProcessDescribe(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) if (ch_desc) { ch = RP_FindChannel(sess->owner, ch_desc->channel, ch_desc->ES_ID, ch_desc->esd_url, 0); } else { - gf_term_on_message(sess->owner->service, GF_OK, "Connected"); + RP_SendMessage(sess->owner->service, GF_OK, "Connected"); } /*error on loading SDP is done internally*/ @@ -340,7 +340,7 @@ exit: } else if (ch) { RP_ConfirmChannelConnect(ch, e); } else { - gf_term_on_connect(sess->owner->service, ch_desc->channel, e); + gf_service_connect_ack(sess->owner->service, ch_desc->channel, e); } } if (ch_desc) gf_free(ch_desc); @@ -373,7 +373,7 @@ void RP_Describe(RTSPSession *sess, char *esd_url, LPNETCHANNEL channel) ch_desc->esd_url = esd_url ? gf_strdup(esd_url) : NULL; ch_desc->channel = channel; RP_SetupChannel(ch, ch_desc); - + if (esd_url) gf_free(ch_desc->esd_url); gf_free(ch_desc); return; @@ -392,7 +392,7 @@ void RP_Describe(RTSPSession *sess, char *esd_url, LPNETCHANNEL channel) ch_desc = (ChannelDescribe *)gf_malloc(sizeof(ChannelDescribe)); ch_desc->esd_url = esd_url ? gf_strdup(esd_url) : NULL; ch_desc->channel = channel; - + com->user_data = ch_desc; } else { //always accept both SDP and IOD @@ -401,7 +401,7 @@ void RP_Describe(RTSPSession *sess, char *esd_url, LPNETCHANNEL channel) } /*need better tuning ...*/ - opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(sess->owner->service), "Network", "Bandwidth"); + opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(sess->owner->service), "Network", "Bandwidth"); if (opt && !stricmp(opt, "yes")) com->Bandwidth = atoi(opt); RP_QueueCommand(sess, NULL, com, 0); @@ -437,7 +437,7 @@ Bool RP_PreprocessUserCom(RTSPSession *sess, GF_RTSPCommand *com) if (strcmp(com->method, GF_RTSP_TEARDOWN)) ch_ctrl = (ChannelControl *)com->user_data; if (!ch_ctrl || !ch_ctrl->ch) return 1; ch = ch_ctrl->ch; - + if (!ch->channel || !channel_is_valid(sess->owner, ch)) { gf_free(ch_ctrl); com->user_data = NULL; @@ -463,7 +463,7 @@ Bool RP_PreprocessUserCom(RTSPSession *sess, GF_RTSPCommand *com) /*check if aggregation discards this command*/ if (skip_it || ( (sess->flags & RTSP_AGG_CONTROL) && (ch->flags & RTP_SKIP_NEXT_COM) )) { ch->flags &= ~RTP_SKIP_NEXT_COM; - gf_term_on_command(sess->owner->service, &ch_ctrl->com, GF_OK); + gf_service_command(sess->owner->service, &ch_ctrl->com, GF_OK); gf_free(ch_ctrl); com->user_data = NULL; return 0; @@ -474,7 +474,7 @@ err_exit: gf_rtsp_reset_aggregation(ch->rtsp->session); ch->status = RTP_Disconnected; ch->check_rtp_time = RTP_SET_TIME_NONE; - gf_term_on_command(sess->owner->service, &ch_ctrl->com, e); + gf_service_command(sess->owner->service, &ch_ctrl->com, e); gf_free(ch_ctrl); com->user_data = NULL; return 0; @@ -500,14 +500,14 @@ void RP_ProcessUserCommand(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) assert(ch->channel==ch_ctrl->com.base.on_channel); } - /*some consistency checking: on interleaved sessions, some servers do NOT reply to the + /*some consistency checking: on interleaved sessions, some servers do NOT reply to the teardown. If our command is STOP just skip the error notif*/ if (e) { if (!strcmp(com->method, GF_RTSP_TEARDOWN)) { goto process_reply; } else { - /*spec is not really clear about what happens if the server doesn't support - non aggregated operations. Since this happen only on pause/play, we consider + /*spec is not really clear about what happens if the server doesn't support + non aggregated operations. Since this happen only on pause/play, we consider that no error occured and wait for next play*/ if (sess->rtsp_rsp->ResponseCode == NC_RTSP_Only_Aggregate_Operation_Allowed) { sess->flags |= RTSP_AGG_ONLY; @@ -533,11 +533,11 @@ void RP_ProcessUserCommand(RTSPSession *sess, GF_RTSPCommand *com, GF_Err e) process_reply: - gf_term_on_command(sess->owner->service, &ch_ctrl->com, GF_OK); + gf_service_command(sess->owner->service, &ch_ctrl->com, GF_OK); - if ( (ch_ctrl->com.command_type==GF_NET_CHAN_PLAY) - || (ch_ctrl->com.command_type==GF_NET_CHAN_SET_SPEED) - || (ch_ctrl->com.command_type==GF_NET_CHAN_RESUME) ) { + if ( (ch_ctrl->com.command_type==GF_NET_CHAN_PLAY) + || (ch_ctrl->com.command_type==GF_NET_CHAN_SET_SPEED) + || (ch_ctrl->com.command_type==GF_NET_CHAN_RESUME) ) { //auto-detect any aggregated control if not done yet if (gf_list_count(sess->rtsp_rsp->RTP_Infos) > 1) { @@ -546,7 +546,7 @@ process_reply: //process all RTP infos count = gf_list_count(sess->rtsp_rsp->RTP_Infos); - for (i=0;irtsp_rsp->RTP_Infos, i); agg_ch = RP_FindChannel(sess->owner, NULL, 0, info->url, 0); @@ -557,7 +557,7 @@ process_reply: agg_ch->check_rtp_time = RTP_SET_TIME_RTP; continue; } - + /*if play/seeking we must send update RTP/NPT link*/ if (ch_ctrl->com.command_type != GF_NET_CHAN_RESUME) { agg_ch->check_rtp_time = RTP_SET_TIME_RTP; @@ -577,10 +577,10 @@ process_reply: if (gf_rtp_is_interleaved(agg_ch->rtp_ch)) { - gf_rtsp_register_interleave(sess->session, - agg_ch, - gf_rtp_get_low_interleave_id(agg_ch->rtp_ch), - gf_rtp_get_hight_interleave_id(agg_ch->rtp_ch)); + gf_rtsp_register_interleave(sess->session, + agg_ch, + gf_rtp_get_low_interleave_id(agg_ch->rtp_ch), + gf_rtp_get_hight_interleave_id(agg_ch->rtp_ch)); } } /*no rtp info (just in case), no time mapped - set to 0 and specify we're not interactive*/ @@ -590,8 +590,8 @@ process_reply: RP_InitStream(ch, 1); ch->status = RTP_Running; if (gf_rtp_is_interleaved(ch->rtp_ch)) { - gf_rtsp_register_interleave(sess->session, - ch, gf_rtp_get_low_interleave_id(ch->rtp_ch), gf_rtp_get_hight_interleave_id(ch->rtp_ch)); + gf_rtsp_register_interleave(sess->session, + ch, gf_rtp_get_low_interleave_id(ch->rtp_ch), gf_rtp_get_hight_interleave_id(ch->rtp_ch)); } } ch->flags &= ~RTP_SKIP_NEXT_COM; @@ -609,7 +609,7 @@ process_reply: err_exit: - gf_term_on_command(sess->owner->service, &ch_ctrl->com, e); + gf_service_command(sess->owner->service, &ch_ctrl->com, e); if (ch) { ch->status = RTP_Disconnected; gf_rtsp_reset_aggregation(ch->rtsp->session); @@ -667,11 +667,11 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command case GF_NET_CHAN_STOP: break; default: - gf_term_on_command(sess->owner->service, command, GF_NOT_SUPPORTED); + gf_service_command(sess->owner->service, command, GF_NOT_SUPPORTED); return; } - + /*we may need to re-setup stream/session*/ if (needs_setup) { if (ch->status == RTP_Disconnected) { @@ -679,7 +679,7 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command i=0; while ((a_ch = (RTPStream *)gf_list_enum(sess->owner->channels, &i))) { if (a_ch->rtsp != sess) continue; - if (a_ch->status == RTP_Disconnected) + if (a_ch->status == RTP_Disconnected) RP_Setup(a_ch); } } else { @@ -687,7 +687,7 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command } } } - + com = gf_rtsp_command_new(); range = NULL; @@ -696,11 +696,11 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command range = gf_rtsp_range_new(); range->start = ch->range_start; range->end = ch->range_end; - + com->method = gf_strdup(GF_RTSP_PLAY); ch->paused=0; - + /*specify pause range on resume - this is not mandatory but most servers need it*/ if (command->command_type==GF_NET_CHAN_RESUME) { range->start = ch->current_start; @@ -738,9 +738,9 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command com->Range = range; } - if (sess->flags & RTSP_AGG_CONTROL) + if (sess->flags & RTSP_AGG_CONTROL) SkipCommandOnSession(ch); - else if (strlen(ch->control)) + else if (strlen(ch->control)) com->ControlString = gf_strdup(ch->control); if (RP_SessionActive(ch)) { @@ -763,13 +763,13 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command range->end = -1.0; com->Range = range; - if (sess->flags & RTSP_AGG_CONTROL) + if (sess->flags & RTSP_AGG_CONTROL) SkipCommandOnSession(ch); - else if (strlen(ch->control)) + else if (strlen(ch->control)) com->ControlString = gf_strdup(ch->control); ch->paused=1; - } + } } else if (command->command_type==GF_NET_CHAN_STOP) { ch->current_start = 0; @@ -786,7 +786,7 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command if (!RP_SessionActive(ch)) RP_Teardown(sess, ch); return; - } + } /* otherwise send a PAUSE on the stream */ else { if (ch->paused) { @@ -802,7 +802,7 @@ void RP_UserCommand(RTSPSession *sess, RTPStream *ch, GF_NetworkCommand *command if (ch->control) com->ControlString = gf_strdup(ch->control); } } else { - gf_term_on_command(sess->owner->service, command, GF_NOT_SUPPORTED); + gf_service_command(sess->owner->service, command, GF_NOT_SUPPORTED); gf_rtsp_command_del(com); return; } diff --git a/modules/rtp_in/rtp_stream.c b/modules/rtp_in/rtp_stream.c index 020ba87..f9fca87 100644 --- a/modules/rtp_in/rtp_stream.c +++ b/modules/rtp_in/rtp_stream.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rtp_in.h" @@ -31,12 +31,12 @@ void RP_ConfirmChannelConnect(RTPStream *ch, GF_Err e) { GF_NetworkCommand com; - + /*in case the channel has been disconnected while SETUP was issued&processed. We also could clean up the command stack*/ if (!ch->channel) return; - gf_term_on_connect(ch->owner->service, ch->channel, e); + gf_service_connect_ack(ch->owner->service, ch->channel, e); if (e != GF_OK || !ch->rtp_ch) return; /*success, overwrite SL config*/ @@ -46,7 +46,7 @@ void RP_ConfirmChannelConnect(RTPStream *ch, GF_Err e) gf_rtp_depacketizer_get_slconfig(ch->depacketizer, &com.cfg.sl_config); /*reconfig*/ - gf_term_on_command(ch->owner->service, &com, GF_OK); + gf_service_command(ch->owner->service, &com, GF_OK); /*ISMACryp config*/ if (ch->depacketizer->flags & GF_RTP_HAS_ISMACRYP) { @@ -58,7 +58,7 @@ void RP_ConfirmChannelConnect(RTPStream *ch, GF_Err e) /*not transported in SDP!!!*/ com.drm_cfg.scheme_uri = NULL; com.drm_cfg.kms_uri = ch->depacketizer->key; - gf_term_on_command(ch->owner->service, &com, GF_OK); + gf_service_command(ch->owner->service, &com, GF_OK); } } @@ -70,16 +70,16 @@ GF_Err RP_InitStream(RTPStream *ch, Bool ResetOnly) const char *ip_ifce = NULL; u32 reorder_size = 0; if (!ch->owner->transport_mode) { - const char *sOpt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ReorderSize"); + const char *sOpt = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Streaming", "ReorderSize"); if (sOpt) reorder_size = atoi(sOpt); else reorder_size = 10; - - ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "DefaultMCastInterface"); + + ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Network", "DefaultMCastInterface"); if (!ip_ifce) { - const char *mob_on = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "MobileIPEnabled"); + const char *mob_on = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Network", "MobileIPEnabled"); if (mob_on && !strcmp(mob_on, "yes")) { - ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "MobileIP"); + ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(ch->owner->service), "Network", "MobileIP"); ch->flags |= RTP_MOBILEIP; } @@ -120,16 +120,16 @@ static void rtp_sl_packet_cbk(void *udta, char *payload, u32 size, GF_SLHeader * if (!ch->rtcp_init) return; cts = hdr->compositionTimeStamp; dts = hdr->decodingTimeStamp; - hdr->compositionTimeStamp += ch->ts_offset; - hdr->decodingTimeStamp += ch->ts_offset; + hdr->compositionTimeStamp -= ch->ts_offset; + hdr->decodingTimeStamp -= ch->ts_offset; if (ch->rtp_ch->packet_loss) e = GF_REMOTE_SERVICE_ERROR; if (ch->owner->first_packet_drop && (hdr->packetSequenceNumber >= ch->owner->first_packet_drop) ) { if ( (hdr->packetSequenceNumber - ch->owner->first_packet_drop) % ch->owner->frequency_drop) - gf_term_on_sl_packet(ch->owner->service, ch->channel, payload, size, hdr, e); + gf_service_send_packet(ch->owner->service, ch->channel, payload, size, hdr, e); } else { - gf_term_on_sl_packet(ch->owner->service, ch->channel, payload, size, hdr, e); + gf_service_send_packet(ch->owner->service, ch->channel, payload, size, hdr, e); } hdr->compositionTimeStamp = cts; hdr->decodingTimeStamp = dts; @@ -174,15 +174,15 @@ RTPStream *RP_NewStream(RTPClient *rtp, GF_SDPMedia *media, GF_SDPInfo *sdp, RTP else if (!stricmp(att->Name, "mpeg4-odid") && att->Value) ODID = atoi(att->Value); else if (!stricmp(att->Name, "range") && !range) range = gf_rtsp_range_parse(att->Value); else if (!stricmp(att->Name, "x-stream-state") ) { - sscanf(att->Value, "server-port=%u-%u;ssrc=%X;npt=%g;seq=%u;rtptime=%u", - &s_port_first, &s_port_last, &ssrc, &CurrentTime, &rtp_seq, &rtp_time); + sscanf(att->Value, "server-port=%u-%u;ssrc=%X;npt=%g;seq=%u;rtptime=%u", + &s_port_first, &s_port_last, &ssrc, &CurrentTime, &rtp_seq, &rtp_time); is_migration = 1; } else if (!stricmp(att->Name, "x-server-port") ) { sscanf(att->Value, "%u-%u", &s_port_first, &s_port_last); - } else if (!stricmp(att->Name, "rvc-config-predef")) { + } else if (!stricmp(att->Name, "rvc-config-predef")) { rvc_predef = atoi(att->Value); - } else if (!stricmp(att->Name, "rvc-config")) { + } else if (!stricmp(att->Name, "rvc-config")) { rvc_config_att = att->Value; } else if (!stricmp(att->Name, "mid")) { sscanf(att->Value, "L%d", &mid); @@ -219,8 +219,8 @@ RTPStream *RP_NewStream(RTPClient *rtp, GF_SDPMedia *media, GF_SDPInfo *sdp, RTP } /*do we support transport*/ if (strcmp(media->Profile, "RTP/AVP") && strcmp(media->Profile, "RTP/AVP/TCP") - && strcmp(media->Profile, "RTP/SAVP") && strcmp(media->Profile, "RTP/SAVP/TCP") - ) return NULL; + && strcmp(media->Profile, "RTP/SAVP") && strcmp(media->Profile, "RTP/SAVP/TCP") + ) return NULL; /*check RTP map. For now we only support 1 RTPMap*/ if (media->fmt_list || (gf_list_count(media->RTPMaps) > 1)) return NULL; @@ -281,11 +281,11 @@ RTPStream *RP_NewStream(RTPClient *rtp, GF_SDPMedia *media, GF_SDPInfo *sdp, RTP // tmp->status = NM_Disconnected; - ctrl = (char *) gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Streaming", "DisableRTCP"); + ctrl = (char *) gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Streaming", "DisableRTCP"); if (!ctrl || stricmp(ctrl, "yes")) tmp->flags |= RTP_ENABLE_RTCP; /*setup NAT keep-alive*/ - ctrl = (char *) gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Streaming", "NATKeepAlive"); + ctrl = (char *) gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Streaming", "NATKeepAlive"); if (ctrl) gf_rtp_enable_nat_keepalive(tmp->rtp_ch, atoi(ctrl)); tmp->range_start = Start; @@ -357,7 +357,7 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) /*corrupted or NULL data*/ if (e || (PayloadStart >= size)) { - //gf_term_on_sl_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_CORRUPTED_DATA); + //gf_service_send_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_CORRUPTED_DATA); return; } @@ -367,12 +367,12 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) /*it may happen that we still receive packets from a previous "play" request. If this is the case, filter until we reach the indicated rtptime*/ - if (ch->rtp_ch->rtp_time - && (ch->rtp_ch->rtp_first_SN > hdr.SequenceNumber) - && (ch->rtp_ch->rtp_time < hdr.TimeStamp) - ) { + if (ch->rtp_ch->rtp_time + && (ch->rtp_ch->rtp_first_SN > hdr.SequenceNumber) + && (ch->rtp_ch->rtp_time < hdr.TimeStamp) + ) { GF_LOG(GF_LOG_WARNING, GF_LOG_RTP, ("[RTP] Rejecting too early packet (TS %d vs signaled rtp time %d - diff %d ms)\n", - hdr.TimeStamp, ch->rtp_ch->rtp_time, ((hdr.TimeStamp - ch->rtp_ch->rtp_time)*1000) / ch->rtp_ch->TimeScale)); + hdr.TimeStamp, ch->rtp_ch->rtp_time, ((hdr.TimeStamp - ch->rtp_ch->rtp_time)*1000) / ch->rtp_ch->TimeScale)); return; } @@ -380,11 +380,11 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) /*this is the first packet on the channel (no PAUSE)*/ if (ch->check_rtp_time == RTP_SET_TIME_RTP) { - /*Note: in a SEEK with RTSP, the rtp-info time given by the server is + /*Note: in a SEEK with RTSP, the rtp-info time given by the server is the rtp time of the desired range. But the server may (and should) send from the previous I frame on video, so the time of the first rtp packet after a SEEK can actually be less than CurrentStart. We don't drop these - packets in order to see the maximum video. We could drop it, this would mean + packets in order to see the maximum video. We could drop it, this would mean wait for next RAP...*/ memset(&com, 0, sizeof(com)); @@ -398,11 +398,11 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) com.map_time.timestamp = hdr.TimeStamp; com.map_time.reset_buffers = 0; - gf_term_on_command(ch->owner->service, &com, GF_OK); + gf_service_command(ch->owner->service, &com, GF_OK); GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] Mapping RTP Time seq %d TS %d Media Time %g - rtp info seq %d TS %d\n", - hdr.SequenceNumber, hdr.TimeStamp, com.map_time.media_time, ch->rtp_ch->rtp_first_SN, ch->rtp_ch->rtp_time - )); + hdr.SequenceNumber, hdr.TimeStamp, com.map_time.media_time, ch->rtp_ch->rtp_first_SN, ch->rtp_ch->rtp_time + )); /*skip RTCP clock init when RTSP is used*/ if (ch->rtsp) ch->rtcp_init = 1; @@ -418,7 +418,7 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) } ch->check_rtp_time = RTP_SET_TIME_NONE; } - + gf_rtp_depacketizer_process(ch->depacketizer, &hdr, pck + PayloadStart, size - PayloadStart); /*last check: signal EOS if we're close to end range in case the server do not send RTCP BYE*/ @@ -429,7 +429,7 @@ void RP_ProcessRTP(RTPStream *ch, char *pck, u32 size) if (ABSDIFF(ch->range_end, (ts + ch->current_start + gf_rtp_get_current_time(ch->rtp_ch)) ) < 0.2) { ch->flags |= RTP_EOS; ch->stat_stop_time = gf_sys_clock(); - gf_term_on_sl_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_EOS); } } } @@ -452,14 +452,14 @@ void RP_ProcessRTCP(RTPStream *ch, char *pck, u32 size) ntp_clock = ch->rtp_ch->last_SR_NTP_sec; ntp_clock += ((Double)ch->rtp_ch->last_SR_NTP_frac)/0xFFFFFFFF; - + if (!ch->owner->last_ntp) { - //add safety in case this RTCP report is received before another report + //add safety in case this RTCP report is received before another report //that was supposed to come in earlier (with earlier NTP) - Double safety_offset, time = ch->rtp_ch->last_SR_rtp_time; - time /= ch->rtp_ch->TimeScale; - safety_offset = time/2; - ch->owner->last_ntp = ntp_clock - safety_offset; + //Double safety_offset, time = ch->rtp_ch->last_SR_rtp_time; + //time /= ch->rtp_ch->TimeScale; + //safety_offset = time/2; + ch->owner->last_ntp = ntp_clock; } if (ntp_clock >= ch->owner->last_ntp) { @@ -468,7 +468,7 @@ void RP_ProcessRTCP(RTPStream *ch, char *pck, u32 size) ntp_clock = 0; } - assert(ch->rtp_ch->last_SR_rtp_time >= (u64) (ntp_clock * ch->rtp_ch->TimeScale)); + //assert(ch->rtp_ch->last_SR_rtp_time >= (u64) (ntp_clock * ch->rtp_ch->TimeScale)); ch->ts_offset = ch->rtp_ch->last_SR_rtp_time; ch->ts_offset -= (s64) (ntp_clock * ch->rtp_ch->TimeScale); @@ -478,7 +478,7 @@ void RP_ProcessRTCP(RTPStream *ch, char *pck, u32 size) com.command_type = GF_NET_CHAN_MAP_TIME; com.base.on_channel = ch->channel; com.map_time.media_time = ntp; - + if (com.map_time.media_time >= ch->owner->last_ntp) { com.map_time.media_time -= ch->owner->last_ntp; } else { @@ -486,12 +486,12 @@ void RP_ProcessRTCP(RTPStream *ch, char *pck, u32 size) } com.map_time.timestamp = ch->rtp_ch->last_SR_rtp_time; com.map_time.reset_buffers = 1; - gf_term_on_command(ch->owner->service, &com, GF_OK); + gf_service_command(ch->owner->service, &com, GF_OK); #endif GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTCP] At %d Using Sender Report to map RTP TS %d to NTP clock %g - new TS offset "LLD" \n", - gf_sys_clock(), ch->rtp_ch->last_SR_rtp_time, ntp_clock, ch->ts_offset - )); + gf_sys_clock(), ch->rtp_ch->last_SR_rtp_time, ntp_clock, ch->ts_offset + )); ch->rtcp_init = 1; ch->check_rtp_time = RTP_SET_TIME_NONE; @@ -500,7 +500,7 @@ void RP_ProcessRTCP(RTPStream *ch, char *pck, u32 size) if (e == GF_EOS) { ch->flags |= RTP_EOS; ch->stat_stop_time = gf_sys_clock(); - gf_term_on_sl_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(ch->owner->service, ch->channel, NULL, 0, NULL, GF_EOS); } } @@ -552,20 +552,20 @@ void RP_ReadStream(RTPStream *ch) } /*and send the report*/ if (ch->flags & RTP_ENABLE_RTCP) gf_rtp_send_rtcp_report(ch->rtp_ch, SendTCPData, ch); - + if (tot_size) ch->owner->udp_time_out = 0; /*detect timeout*/ if (ch->owner->udp_time_out) { if (!ch->last_udp_time) { ch->last_udp_time = gf_sys_clock(); - } else if (ch->rtp_ch->net_info.IsUnicast && !(ch->flags & RTP_MOBILEIP) ){ + } else if (ch->rtp_ch->net_info.IsUnicast && !(ch->flags & RTP_MOBILEIP) ) { u32 diff = gf_sys_clock() - ch->last_udp_time; if (diff >= ch->owner->udp_time_out) { char szMessage[1024]; GF_LOG(GF_LOG_WARNING, GF_LOG_RTP, ("[RTP] UDP Timeout after %d ms\n", diff)); sprintf(szMessage, "No data received in %d ms", diff); - gf_term_on_message(ch->owner->service, GF_IP_UDP_TIMEOUT, szMessage); + RP_SendMessage(ch->owner->service, GF_IP_UDP_TIMEOUT, szMessage); ch->status = RTP_Unavailable; } } diff --git a/modules/rtp_in/sdp_fetch.c b/modules/rtp_in/sdp_fetch.c index b18ff35..062e4e8 100644 --- a/modules/rtp_in/sdp_fetch.c +++ b/modules/rtp_in/sdp_fetch.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rtp_in.h" @@ -36,7 +36,7 @@ void RP_SDPFromData(RTPClient *rtp, char *s_url, RTPStream *stream) url = strstr(s_url, ","); if (!url) { - gf_term_on_connect(rtp->service, NULL, GF_URL_ERROR); + gf_service_connect_ack(rtp->service, NULL, GF_URL_ERROR); return; } url += 1; @@ -59,7 +59,7 @@ void RP_SDPFromFile(RTPClient *rtp, char *file_name, RTPStream *stream) if (file_name && strstr(file_name, "file://")) file_name += strlen("file://"); if (!file_name || !(_sdp = gf_f64_open(file_name, "rt")) ) { - gf_term_on_connect(rtp->service, NULL, GF_URL_ERROR); + gf_service_connect_ack(rtp->service, NULL, GF_URL_ERROR); return; } @@ -67,10 +67,10 @@ void RP_SDPFromFile(RTPClient *rtp, char *file_name, RTPStream *stream) sdp_size = (u32) gf_f64_tell(_sdp); gf_f64_seek(_sdp, 0, SEEK_SET); sdp_buf = (char*)gf_malloc(sdp_size); - if (1 > fread(sdp_buf, 1, sdp_size, _sdp)){ - gf_term_on_connect(rtp->service, NULL, GF_URL_ERROR); + if (1 > fread(sdp_buf, 1, sdp_size, _sdp)) { + gf_service_connect_ack(rtp->service, NULL, GF_URL_ERROR); } else { - RP_LoadSDP(rtp, sdp_buf, sdp_size, stream); + RP_LoadSDP(rtp, sdp_buf, sdp_size, stream); } fclose(_sdp); gf_free(sdp_buf); @@ -82,7 +82,7 @@ void SDP_NetIO(void *cbk, GF_NETIO_Parameter *param) RTPClient *rtp = (RTPClient *)cbk; SDPFetch *sdp = rtp->sdp_temp; - gf_term_download_update_stats(rtp->dnload); + gf_service_download_update_stats(rtp->dnload); e = param->error; switch (param->msg_type) { @@ -93,7 +93,7 @@ void SDP_NetIO(void *cbk, GF_NETIO_Parameter *param) case GF_NETIO_GET_CONTENT: if (sdp->original_url) { char szBody[4096], *opt; - opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Network", "MobileIP"); + opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Network", "MobileIP"); sprintf(szBody, "ipadd\n%s\n\nurl\n%s\n\n", opt, sdp->original_url); param->data = szBody; param->size = (u32) strlen(szBody); @@ -103,7 +103,7 @@ void SDP_NetIO(void *cbk, GF_NETIO_Parameter *param) if (sdp->original_url) { u32 sdp_size; e = gf_dm_sess_get_stats(rtp->dnload, NULL, NULL, &sdp_size, NULL, NULL, NULL); - if (sdp_size) { + if (sdp_size) { const char *szFile = gf_dm_sess_get_cache_name(rtp->dnload); if (!szFile) { e = GF_SERVICE_ERROR; @@ -128,17 +128,17 @@ void SDP_NetIO(void *cbk, GF_NETIO_Parameter *param) gf_free(sdp->remote_url); gf_free(sdp); rtp->sdp_temp = NULL; - gf_term_on_message(rtp->service, e, "Error fetching session state - restarting"); - RP_ConnectServiceEx(gf_term_get_service_interface(rtp->service), rtp->service, url, 1); + RP_SendMessage(rtp->service, e, "Error fetching session state - restarting"); + RP_ConnectServiceEx(gf_service_get_interface(rtp->service), rtp->service, url, 1); gf_free(url); - return; + return; } /*error*/ if (sdp->chan) { - gf_term_on_connect(rtp->service, sdp->chan->channel, e); + gf_service_connect_ack(rtp->service, sdp->chan->channel, e); } else { - gf_term_on_connect(rtp->service, NULL, e); + gf_service_connect_ack(rtp->service, NULL, e); rtp->sdp_temp = NULL; } gf_free(sdp->remote_url); @@ -159,7 +159,7 @@ void RP_FetchSDP(RTPClient *rtp, char *url, RTPStream *stream, char *original_ur RP_SDPFromFile(rtp, url, stream); return; } - + sdp = (SDPFetch*)gf_malloc(sizeof(SDPFetch)); memset(sdp, 0, sizeof(SDPFetch)); sdp->client = rtp; @@ -170,13 +170,13 @@ void RP_FetchSDP(RTPClient *rtp, char *url, RTPStream *stream, char *original_ur } /*otherwise setup download*/ - if (rtp->dnload) gf_term_download_del(rtp->dnload); + if (rtp->dnload) gf_service_download_del(rtp->dnload); rtp->dnload = NULL; rtp->sdp_temp = sdp; - rtp->dnload = gf_term_download_new(rtp->service, url, 0, SDP_NetIO, rtp); + rtp->dnload = gf_service_download_new(rtp->service, url, 0, SDP_NetIO, rtp); if (!rtp->dnload) { - gf_term_on_connect(rtp->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(rtp->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(rtp->dnload); diff --git a/modules/rtp_in/sdp_load.c b/modules/rtp_in/sdp_load.c index 52c9124..46b2482 100644 --- a/modules/rtp_in/sdp_load.c +++ b/modules/rtp_in/sdp_load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rtp_in.h" @@ -94,7 +94,7 @@ GF_Err RP_SetupSDP(RTPClient *rtp, GF_SDPInfo *sdp, RTPStream *stream) if (End > 0) ch->flags |= RTP_HAS_RANGE; } - /*force interleaving whenever needed*/ + /*force interleaving whenever needed*/ if (ch->rtsp) { switch (ch->depacketizer->sl_map.StreamType) { case GF_STREAM_VISUAL: @@ -112,7 +112,7 @@ GF_Err RP_SetupSDP(RTPClient *rtp, GF_SDPInfo *sdp, RTPStream *stream) break; } } - + } return GF_OK; } @@ -160,10 +160,14 @@ GF_Err RP_SDPLoadIOD(RTPClient *rtp, char *iod_str) static u32 get_stream_type_from_hint(u32 ht) { switch (ht) { - case GF_MEDIA_OBJECT_VIDEO: return GF_STREAM_VISUAL; - case GF_MEDIA_OBJECT_AUDIO: return GF_STREAM_AUDIO; - case GF_MEDIA_OBJECT_TEXT: return GF_STREAM_TEXT; - default: return 0; + case GF_MEDIA_OBJECT_VIDEO: + return GF_STREAM_VISUAL; + case GF_MEDIA_OBJECT_AUDIO: + return GF_STREAM_AUDIO; + case GF_MEDIA_OBJECT_TEXT: + return GF_STREAM_TEXT; + default: + return 0; } } @@ -226,7 +230,7 @@ static GF_ObjectDescriptor *RP_GetChannelOD(RTPStream *ch, u32 ch_idx) GF_ESD *the_esd; the_channel = (RTPStream *)gf_list_get(ch->owner->channels, i); - if (the_channel->base_stream == ch->mid) + if (the_channel->base_stream == ch->mid) { the_esd = RP_GetChannelESD(the_channel, i); the_esd->dependsOnESID = the_channel->prev_stream; @@ -234,7 +238,7 @@ static GF_ObjectDescriptor *RP_GetChannelOD(RTPStream *ch, u32 ch_idx) } } } - + return od; } @@ -286,16 +290,16 @@ void RP_SetupObjects(RTPClient *rtp) if (!rtp->media_type) { od = RP_GetChannelOD(ch, i); if (!od) continue; - gf_term_add_media(rtp->service, (GF_Descriptor*)od, 1); + gf_service_declare_media(rtp->service, (GF_Descriptor*)od, 1); } else if (rtp->media_type==ch->depacketizer->sl_map.StreamType) { od = RP_GetChannelOD(ch, i); if (!od) continue; - gf_term_add_media(rtp->service, (GF_Descriptor*)od, 1); + gf_service_declare_media(rtp->service, (GF_Descriptor*)od, 1); rtp->media_type = 0; break; } } - gf_term_add_media(rtp->service, NULL, 0); + gf_service_declare_media(rtp->service, NULL, 0); } void RP_LoadSDP(RTPClient *rtp, char *sdp_text, u32 sdp_len, RTPStream *stream) @@ -329,7 +333,7 @@ void RP_LoadSDP(RTPClient *rtp, char *sdp_text, u32 sdp_len, RTPStream *stream) /*force iod reconstruction with ISMA to use proper clock dependencies*/ if (is_isma_1) iod_str = NULL; - /*some folks have weird notions of MPEG-4 systems, they use hardcoded IOD + /*some folks have weird notions of MPEG-4 systems, they use hardcoded IOD with AAC ESD even when streaming AMR...*/ if (iod_str) { RTPStream *ch; @@ -340,15 +344,15 @@ void RP_LoadSDP(RTPClient *rtp, char *sdp_text, u32 sdp_len, RTPStream *stream) break; } } - } + } if (!iod_str) { RTPStream *ch; Bool needs_iod = 0; i=0; while ((ch = (RTPStream *)gf_list_enum(rtp->channels, &i))) { - if ((ch->depacketizer->payt==GF_RTP_PAYT_MPEG4) && (ch->depacketizer->sl_map.StreamType==GF_STREAM_SCENE) + if ((ch->depacketizer->payt==GF_RTP_PAYT_MPEG4) && (ch->depacketizer->sl_map.StreamType==GF_STREAM_SCENE) // || ((ch->depacketizer->payt==GF_RTP_PAYT_3GPP_DIMS) && (ch->depacketizer->sl_map.StreamType==GF_STREAM_SCENE)) - ) { + ) { needs_iod = 1; break; } @@ -357,19 +361,19 @@ void RP_LoadSDP(RTPClient *rtp, char *sdp_text, u32 sdp_len, RTPStream *stream) rtp->session_desc = (GF_Descriptor *)RP_GetChannelOD(ch, 0); } } - + if (iod_str) e = RP_SDPLoadIOD(rtp, iod_str); } /*attach service*/ has_iod = rtp->session_desc ? 1 : 0; - gf_term_on_connect(rtp->service, NULL, e); + gf_service_connect_ack(rtp->service, NULL, e); if (!e && !has_iod && !rtp->media_type) RP_SetupObjects(rtp); rtp->media_type = 0; } /*channel SDP */ else { if (e) { - gf_term_on_connect(rtp->service, stream->channel, e); + gf_service_connect_ack(rtp->service, stream->channel, e); stream->status = RTP_Unavailable; } else { /*connect*/ @@ -472,14 +476,14 @@ void RP_SaveSessionState(RTPClient *rtp) porta = ch->rtp_ch->net_info.port_first ? ch->rtp_ch->net_info.port_first : ch->rtp_ch->net_info.client_port_first; portb = ch->rtp_ch->net_info.port_last ? ch->rtp_ch->net_info.port_last : ch->rtp_ch->net_info.client_port_last; - sprintf(szPorts, "server-port=%d-%d;ssrc=%X;npt=%g;seq=%d;rtptime=%d", - porta, - portb, - ch->rtp_ch->SenderSSRC, - ch->current_start, - ch->rtp_ch->rtp_first_SN, - ch->rtp_ch->rtp_time - ); + sprintf(szPorts, "server-port=%d-%d;ssrc=%X;npt=%g;seq=%d;rtptime=%d", + porta, + portb, + ch->rtp_ch->SenderSSRC, + ch->current_start, + ch->rtp_ch->rtp_first_SN, + ch->rtp_ch->rtp_time + ); att->Value = gf_strdup(szPorts); gf_list_add(media->Attributes, att); @@ -494,7 +498,7 @@ void RP_SaveSessionState(RTPClient *rtp) for (j=0; jAttributes); j++) { att = (GF_X_Attribute*)gf_list_get(sdp->Attributes, j); if (!stricmp(att->Name, "x-session-id") || !stricmp(att->Name, "x-session-name") - ) { + ) { gf_free(att->Name); gf_free(att->Value); gf_free(att); @@ -532,20 +536,20 @@ void RP_SaveSessionState(RTPClient *rtp) gf_sdp_info_del(sdp); - opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(rtp->service), "Streaming", "SessionMigrationServer"); + opt = (char *) gf_modules_get_option((GF_BaseInterface *) gf_service_get_interface(rtp->service), "Streaming", "SessionMigrationServer"); if (opt) { - if (rtp->dnload) gf_term_download_del(rtp->dnload); + if (rtp->dnload) gf_service_download_del(rtp->dnload); rtp->dnload = NULL; if (strnicmp(opt, "http://", 7)) { - rtp->dnload = gf_term_download_new(rtp->service, opt, GF_NETIO_SESSION_NOT_THREADED, MigrateSDP_NetIO, rtp); + rtp->dnload = gf_service_download_new(rtp->service, opt, GF_NETIO_SESSION_NOT_THREADED, MigrateSDP_NetIO, rtp); while (1) { char buffer[100]; u32 read; e = gf_dm_sess_fetch_data(rtp->dnload, buffer, 100, &read); if (e && (e!=GF_IP_NETWORK_EMPTY)) break; } - gf_term_download_del(rtp->dnload); + gf_service_download_del(rtp->dnload); rtp->dnload = NULL; } else { FILE *f = gf_f64_open(opt, "wt"); @@ -558,7 +562,7 @@ void RP_SaveSessionState(RTPClient *rtp) } } if (e<0) { - gf_term_on_message(sess->owner->service, e, "Error saving session state"); + RP_SendMessage(sess->owner->service, e, "Error saving session state"); } } } diff --git a/modules/rvc_dec/rvc_dec.c b/modules/rvc_dec/rvc_dec.c index 654126c..bbbcd70 100644 --- a/modules/rvc_dec/rvc_dec.c +++ b/modules/rvc_dec/rvc_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2010-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,11 +42,11 @@ -typedef struct{ +typedef struct { int Width; int Height; unsigned char* pY[1]; - unsigned char* pU[1]; + unsigned char* pU[1]; unsigned char* pV[1]; } RVCFRAME; @@ -74,13 +74,13 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) s32 res; char Picture; RVCDec *ctx = (RVCDec*) ifcg->privateStack; - char* VTLFolder; - char *XDF_doc = NULL; + char* VTLFolder; + char *XDF_doc = NULL; int isNALUFile; /*not supported in this version*/ if (esd->dependsOnESID) return GF_NOT_SUPPORTED; - + ctx->ES_ID = esd->ESID; ctx->width = ctx->height = ctx->out_size = 0; @@ -114,7 +114,7 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) fclose(f); XDF_doc[size]=0; } else { - if (!esd->decoderConfig->rvc_config) + if (!esd->decoderConfig->rvc_config) return GF_NOT_SUPPORTED; XDF_doc = esd->decoderConfig->rvc_config->data; } @@ -140,9 +140,9 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) esd->decoderConfig->rvc_config->data = NULL; esd->decoderConfig->rvc_config->dataLength = 0; } - + /*decoder config not known, output buffers will be reconfigured at run-time*/ - if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) + if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return GF_OK; /*initialize the decoder */ @@ -150,7 +150,7 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) GF_AVCConfig *cfg = gf_odf_avc_cfg_read(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength); if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; ctx->nalu_size_length = cfg->nal_unit_size; - + /*decode all NALUs*/ count = gf_list_count(cfg->sequenceParameterSets); for (i=0; ipixel_ar = (par_n<<16) || par_d; } } - - /* call decode*/ + + /* call decode*/ res = rvc_decode(slc->data, slc->size, &Picture, 1); if (res<0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[RVC Decoder] Error decoding SPS %d\n", res)); @@ -182,16 +182,16 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) if (res<0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[RVC Decoder] Error decoding PPS %d\n", res)); } - + } gf_odf_avc_cfg_del(cfg); - /*initialize the decoder */ + /*initialize the decoder */ } else if ( (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_HEVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SHVC)) { GF_HEVCConfig *cfg = gf_odf_hevc_cfg_read(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 0); if (!cfg) return GF_NON_COMPLIANT_BITSTREAM; ctx->nalu_size_length = cfg->nal_unit_size; - + /*decode all NALUs*/ count = gf_list_count(cfg->param_array); for (i=0; idata, slc->size, &Picture, 1); if (res<0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[RVC Decoder] Error decoding parameter set: %d\n", res)); @@ -234,22 +234,22 @@ static GF_Err RVCD_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) ctx->width = dsi.width; ctx->height = dsi.height; ctx->pixel_ar = (dsi.par_num<<16) | dsi.par_den; - - + + res = rvc_decode(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &Picture, 1); if (res<0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[RVC Decoder] Error decoding PPS %d\n", res)); } - + } else { /*unknown type, do what you want*/ - + res = rvc_decode(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &Picture, 1); if (res<0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[RVC Decoder] Error decoding PPS %d\n", res)); } - + } /*adjust stride to what you decoder uses*/ ctx->stride = ctx->width; @@ -321,11 +321,11 @@ static GF_Err RVCD_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa int bookmark = 0; -static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { s32 got_pic; RVCDec *ctx = (RVCDec*) ifcg->privateStack; @@ -342,12 +342,12 @@ static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, //if your decoder outputs directly in the memory passed, setup pointers for your decoder output picture got_pic = 0; - + if (ctx->nalu_size_length) { u32 i, nalu_size = 0; u8 *ptr = inBuffer; int nalNumber = 1; - + while (inBufferLength) { for (i=0; inalu_size_length; i++) { nalu_size = (nalu_size<<8) + ptr[i]; @@ -355,23 +355,23 @@ static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, ptr += ctx->nalu_size_length; //same remark as above regardin start codes - - if(nalNumber > bookmark){ + + if(nalNumber > bookmark) { got_pic = rvc_decode(ptr, nalu_size, outBuffer, !got_pic); bookmark ++; - if(got_pic>1){ + if(got_pic>1) { return GF_PACKED_FRAMES; } - }else if(nalNumber == bookmark){ + } else if(nalNumber == bookmark) { got_pic = rvc_decode(NULL, 0, outBuffer, !got_pic); - if(got_pic>1){ + if(got_pic>1) { return GF_PACKED_FRAMES; } } nalNumber ++; ptr += nalu_size; - if (inBufferLength < nalu_size + ctx->nalu_size_length) + if (inBufferLength < nalu_size + ctx->nalu_size_length) break; inBufferLength -= nalu_size + ctx->nalu_size_length; @@ -381,7 +381,7 @@ static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, } else { u32 nalu_size = 0; u8 *ptr = inBuffer; - + got_pic = rvc_decode(ptr, inBufferLength, outBuffer, 1); } @@ -389,7 +389,7 @@ static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, //if (got_pic!=1) return GF_OK; /*if size changed during the decoding, resize the composition buffer*/ - /*if ((pic.Width != ctx->width) || (pic.Height!=ctx->height)) + /*if ((pic.Width != ctx->width) || (pic.Height!=ctx->height)) { ctx->width = pic.Width; ctx->stride = pic.Width; @@ -398,14 +398,14 @@ static GF_Err RVCD_ProcessData(GF_MediaDecoder *ifcg, *outBufferLength = ctx->out_size; return GF_BUFFER_TOO_SMALL; } - + *outBufferLength = ctx->out_size;*/ /*if your decoder does not output directly in the memory passed, copy over the data*/ - - /*memcpy(outBuffer, pic.pY[0], ctx->stride*ctx->height); + + /*memcpy(outBuffer, pic.pY[0], ctx->stride*ctx->height); memcpy(outBuffer + ctx->stride * ctx->height, pic.pU[0], ctx->stride*ctx->height/4); - memcpy(outBuffer + 5*ctx->stride * ctx->height/4, pic.pV[0], ctx->stride*ctx->height/4);*/ + memcpy(outBuffer + 5*ctx->stride * ctx->height/4, pic.pV[0], ctx->stride*ctx->height/4);*/ if(got_pic>1) return GF_PACKED_FRAMES; return GF_OK; @@ -437,14 +437,14 @@ GF_BaseDecoder *NewRVCDec() { GF_MediaDecoder *ifcd; RVCDec *dec; - + GF_SAFEALLOC(ifcd, GF_MediaDecoder); GF_SAFEALLOC(dec, RVCDec); GF_REGISTER_MODULE_INTERFACE(ifcd, GF_MEDIA_DECODER_INTERFACE, "RVC Decoder", "gpac distribution") ifcd->privateStack = dec; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = RVCD_AttachStream; ifcd->DetachStream = RVCD_DetachStream; ifcd->GetCapabilities = RVCD_GetCapabilities; @@ -463,7 +463,7 @@ void DeleteRVCDec(GF_BaseDecoder *ifcg) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS @@ -471,11 +471,11 @@ const u32 *QueryInterfaces() #endif 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *)NewRVCDec(); @@ -488,7 +488,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS - case GF_MEDIA_DECODER_INTERFACE: + case GF_MEDIA_DECODER_INTERFACE: DeleteRVCDec((GF_BaseDecoder*)ifce); break; #endif diff --git a/modules/saf_in/saf_in.c b/modules/saf_in/saf_in.c index cc2da7c..ad0e5db 100644 --- a/modules/saf_in/saf_in.c +++ b/modules/saf_in/saf_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -86,18 +86,18 @@ static const char * SAF_MIME_DESC = "SAF Rich Media"; static u32 SAF_RegisterMimeTypes(const GF_InputService *plug) { if (!plug) - return 0; - gf_term_register_mime_type(plug, SAF_MIME, SAF_MIME_EXT, SAF_MIME_DESC); + return 0; + gf_service_register_mime(plug, SAF_MIME, SAF_MIME_EXT, SAF_MIME_DESC); return 1; } static Bool SAF_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; - if (!plug || !url) - return 0; + if (!plug || !url) + return 0; sExt = strrchr(url, '.'); - if (gf_term_check_extension(plug, SAF_MIME, SAF_MIME_EXT, SAF_MIME_DESC, sExt)) return 1; + if (gf_service_check_mime_register(plug, SAF_MIME, SAF_MIME_EXT, SAF_MIME_DESC, sExt)) return 1; return 0; } @@ -114,7 +114,7 @@ static void SAF_Regulate(SAFIn *read) u32 i=0; while ( (ch = (SAFChannel *)gf_list_enum(read->channels, &i))) { com.base.on_channel = ch->ch; - gf_term_on_command(read->service, &com, GF_OK); + gf_service_command(read->service, &com, GF_OK); if (com.buffer.occupancy < ch->buffer_min) return; if (com.buffer.occupancy) min_occ = MIN(min_occ, com.buffer.occupancy - ch->buffer_min); } @@ -143,12 +143,12 @@ static void SAF_NetIO(void *cbk, GF_NETIO_Parameter *param) return; } else { /*handle service message*/ - gf_term_download_update_stats(read->dnload); + gf_service_download_update_stats(read->dnload); if (param->msg_type!=GF_NETIO_DATA_EXCHANGE) { if (e<0) { if (read->needs_connection) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, e); + gf_service_connect_ack(read->service, NULL, e); } return; } @@ -245,7 +245,7 @@ static void SAF_NetIO(void *cbk, GF_NETIO_Parameter *param) if (read->needs_connection && (ch->esd->decoderConfig->streamType==GF_STREAM_SCENE)) { gf_list_add(read->channels, ch); read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_OK); + gf_service_connect_ack(read->service, NULL, GF_OK); } else if (read->needs_connection) { gf_odf_desc_del((GF_Descriptor *) ch->esd); gf_free(ch); @@ -258,7 +258,7 @@ static void SAF_NetIO(void *cbk, GF_NETIO_Parameter *param) gf_list_add(od->ESDescriptors, ch->esd); ch->esd = NULL; od->objectDescriptorID = ch->stream_id; - gf_term_add_media(read->service, (GF_Descriptor*)od, 0); + gf_service_declare_media(read->service, (GF_Descriptor*)od, 0); } } @@ -275,19 +275,19 @@ static void SAF_NetIO(void *cbk, GF_NETIO_Parameter *param) if (read->start_range && (read->start_range*ch->ts_res>cts*1000)) { sl_hdr.compositionTimeStamp = read->start_range*ch->ts_res/1000; } - gf_term_on_sl_packet(read->service, ch->ch, read->saf_data+bs_pos, au_size, &sl_hdr, GF_OK); + gf_service_send_packet(read->service, ch->ch, read->saf_data+bs_pos, au_size, &sl_hdr, GF_OK); } gf_bs_skip_bytes(bs, au_size); break; case 3: - if (ch) gf_term_on_sl_packet(read->service, ch->ch, NULL, 0, NULL, GF_EOS); + if (ch) gf_service_send_packet(read->service, ch->ch, NULL, 0, NULL, GF_EOS); break; case 5: go = 0; read->run_state = 0; i=0; while ((ch = (SAFChannel *)gf_list_enum(read->channels, &i))) { - gf_term_on_sl_packet(read->service, ch->ch, NULL, 0, NULL, GF_EOS); + gf_service_send_packet(read->service, ch->ch, NULL, 0, NULL, GF_EOS); } break; } @@ -328,10 +328,10 @@ static void SAF_DownloadFile(GF_InputService *plug, char *url) { SAFIn *read = (SAFIn*) plug->priv; - read->dnload = gf_term_download_new(read->service, url, 0, SAF_NetIO, read); + read->dnload = gf_service_download_new(read->service, url, 0, SAF_NetIO, read); if (!read->dnload) { read->needs_connection = 0; - gf_term_on_connect(read->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(read->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(read->dnload); @@ -363,7 +363,9 @@ static void SAF_CheckFile(SAFIn *read) stream_id = gf_bs_read_int(bs, 12); au_size-=2; ts_res = 0; - for (i=0; ipriv; read->service = serv; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; strcpy(szURL, url); @@ -412,7 +414,7 @@ static GF_Err SAF_ConnectService(GF_InputService *plug, GF_ClientService *serv, read->stream = gf_f64_open(szURL, "rb"); if (!read->stream) { - gf_term_on_connect(serv, NULL, GF_URL_ERROR); + gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } SAF_CheckFile(read); @@ -437,9 +439,9 @@ static GF_Err SAF_CloseService(GF_InputService *plug) if (read->stream) fclose(read->stream); read->stream = NULL; - if (read->dnload) gf_term_download_del(read->dnload); + if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; - gf_term_on_disconnect(read->service, NULL, GF_OK); + gf_service_disconnect_ack(read->service, NULL, GF_OK); return GF_OK; } @@ -484,7 +486,7 @@ static GF_Err SAF_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } } - gf_term_on_connect(read->service, channel, e); + gf_service_connect_ack(read->service, channel, e); return e; } @@ -501,7 +503,7 @@ static GF_Err SAF_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) gf_free(ch); e = GF_OK; } - gf_term_on_disconnect(read->service, channel, e); + gf_service_disconnect_ack(read->service, channel, e); return GF_OK; } @@ -571,8 +573,8 @@ void DeleteSAFReader(void *ifce) { GF_InputService *plug = (GF_InputService *) ifce; SAFIn *read = (SAFIn *)plug->priv; - if (!ifce) - return; + if (!ifce) + return; while (gf_list_count(read->channels)) { SAFChannel *ch = (SAFChannel *)gf_list_last(read->channels); gf_list_rem_last(read->channels); @@ -581,10 +583,10 @@ void DeleteSAFReader(void *ifce) } gf_list_del(read->channels); if (read->saf_data) - gf_free(read->saf_data); - read->saf_data = NULL; + gf_free(read->saf_data); + read->saf_data = NULL; gf_free(read); - plug->priv = NULL; + plug->priv = NULL; gf_free(plug); } @@ -603,8 +605,10 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *) NewSAFReader(); - default: return NULL; + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *) NewSAFReader(); + default: + return NULL; } } @@ -612,7 +616,9 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_NET_CLIENT_INTERFACE: DeleteSAFReader(ifce); break; + case GF_NET_CLIENT_INTERFACE: + DeleteSAFReader(ifce); + break; } } diff --git a/modules/sdl_out/audio.c b/modules/sdl_out/audio.c index 3d12b8a..e74cdf7 100644 --- a/modules/sdl_out/audio.c +++ b/modules/sdl_out/audio.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,24 +11,24 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "sdl_out.h" - + #define SDLAUD() SDLAudCtx *ctx = (SDLAudCtx *)dr->opaque -static void sdl_close_audio(){ - SDL_CloseAudio(); +static void sdl_close_audio() { + SDL_CloseAudio(); } @@ -36,18 +36,18 @@ void sdl_fill_audio(void *udata, Uint8 *stream, int len) { GF_AudioOutput *dr = (GF_AudioOutput *)udata; SDLAUD(); - if (ctx->volume != SDL_MIX_MAXVOLUME){ + if (ctx->volume != SDL_MIX_MAXVOLUME) { u32 written; if (ctx->alloc_size < (u32) len) { ctx->audioBuff = gf_realloc( ctx->audioBuff, sizeof(Uint8) * len); ctx->alloc_size = len; } memset(stream, 0, len); - written = dr->FillBuffer(dr->audio_renderer, (char *) ctx->audioBuff, (u32) len); + written = dr->FillBuffer(dr->audio_renderer, (char *) ctx->audioBuff, (u32) len); if (written) SDL_MixAudio(stream, ctx->audioBuff, len, ctx->volume); } else { - dr->FillBuffer(dr->audio_renderer, (char *) stream, (u32) len); + dr->FillBuffer(dr->audio_renderer, (char *) stream, (u32) len); } } @@ -64,7 +64,7 @@ static GF_Err SDLAud_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, flags = SDL_WasInit(SDL_INIT_AUDIO); if (!(flags & SDL_INIT_AUDIO)) { if (SDL_InitSubSystem(SDL_INIT_AUDIO)<0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Audio output initialization error\n")); + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Audio output initialization error\n")); SDLOUT_CloseSDL(); return GF_IO_ERR; } @@ -81,14 +81,14 @@ static GF_Err SDLAud_Setup(GF_AudioOutput *dr, void *os_handle, u32 num_buffers, sdl_close_audio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); SDLOUT_CloseSDL(); - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Audio output format not supported\n")); + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Audio output format not supported\n")); return GF_IO_ERR; } sdl_close_audio(); ctx->is_init = GF_TRUE; ctx->num_buffers = num_buffers; ctx->total_duration = total_duration; - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Audio output setup\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Audio output setup\n")); return GF_OK; } @@ -103,7 +103,7 @@ static void SDLAud_Shutdown(GF_AudioOutput *dr) } } -void SDL_DeleteAudio(void *ifce){ +void SDL_DeleteAudio(void *ifce) { SDLAudCtx *ctx; GF_AudioOutput * dr; if (!ifce) @@ -166,7 +166,7 @@ static GF_Err SDLAud_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *N } /*and play*/ SDL_PauseAudio(0); - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Audio output setup - SampleRate %d Nb Channels %d - %d ms delay\n", got_format.freq, got_format.channels, ctx->delay_ms)); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Audio output setup - SampleRate %d Nb Channels %d - %d ms delay\n", got_format.freq, got_format.channels, ctx->delay_ms)); return GF_OK; } diff --git a/modules/sdl_out/cursors.c b/modules/sdl_out/cursors.c index a83335c..819c0e6 100644 --- a/modules/sdl_out/cursors.c +++ b/modules/sdl_out/cursors.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,23 +11,23 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #if 0 -static char hand_data[] = +static char hand_data[] = { - 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/modules/sdl_out/sdl_out.c b/modules/sdl_out/sdl_out.c index 3547ba1..4a518b5 100644 --- a/modules/sdl_out/sdl_out.c +++ b/modules/sdl_out/sdl_out.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "sdl_out.h" @@ -60,14 +60,14 @@ void SDLOUT_CloseSDL() /*interface query*/ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, GF_AUDIO_OUTPUT_INTERFACE, 0 }; - return si; + return si; } /*interface create*/ diff --git a/modules/sdl_out/sdl_out.h b/modules/sdl_out/sdl_out.h index c5f6b69..744446c 100644 --- a/modules/sdl_out/sdl_out.h +++ b/modules/sdl_out/sdl_out.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #ifndef _GF_SDL_OUT_H_ @@ -66,7 +66,7 @@ typedef struct SDL_Cursor *curs_def, *curs_hand, *curs_collide; Bool use_systems_memory; - + #if SDL_VERSION_ATLEAST(2,0,0) SDL_GLContext gl_context; SDL_Renderer *renderer; diff --git a/modules/sdl_out/video.c b/modules/sdl_out/video.c index 8dad54d..e6cde15 100644 --- a/modules/sdl_out/video.c +++ b/modules/sdl_out/video.c @@ -1,27 +1,27 @@ - /* - * GPAC - Multimedia Framework C SDK - * - * Authors: Jean Le Feuvre - Romain Bouqueau - * Copyright (c) Telecom ParisTech 2000-2012 - * All rights reserved - * - * This file is part of GPAC / SDL audio and video module - * - * GPAC is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * GPAC is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ +/* +* GPAC - Multimedia Framework C SDK +* +* Authors: Jean Le Feuvre - Romain Bouqueau +* Copyright (c) Telecom ParisTech 2000-2012 +* All rights reserved +* +* This file is part of GPAC / SDL audio and video module +* +* GPAC is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* GPAC is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; see the file COPYING. If not, write to +* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +* +*/ #include "sdl_out.h" #include @@ -38,9 +38,9 @@ #endif /*cursors data*/ -static char hand_data[] = +static char hand_data[] = { - 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -77,8 +77,8 @@ static char hand_data[] = static char collide_data[] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -91,8 +91,8 @@ static char collide_data[] = 0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -117,7 +117,7 @@ static char collide_data[] = #define SDLVID() SDLVidCtx *ctx = (SDLVidCtx *)dr->opaque - + #if SDL_VERSION_ATLEAST(2,0,0) void SDLVid_SetCaption(SDL_Window* window) { @@ -147,7 +147,7 @@ void SDLVid_SetCaption(SDL_Window* window) #define SDLK_PRINTSCREEN SDLK_PRINT #define SDL_WINDOW_RESIZABLE SDL_RESIZABLE -static u32 video_modes[] = +static u32 video_modes[] = { 320, 200, 320, 240, @@ -172,7 +172,7 @@ void SDLVid_SetCaption() } } #endif - + SDL_Cursor *SDLVid_LoadCursor(char *maskdata) @@ -206,191 +206,326 @@ SDL_Cursor *SDLVid_LoadCursor(char *maskdata) } -static void sdl_translate_key(u32 SDLkey, GF_EventKey *evt) +static void sdl_translate_key(u32 SDLkey, GF_EventKey *evt) { evt->flags = 0; evt->hw_code = SDLkey; switch (SDLkey) { - case SDLK_BACKSPACE: evt->key_code = GF_KEY_BACKSPACE; break; - case SDLK_TAB: evt->key_code = GF_KEY_TAB; break; - case SDLK_CLEAR: evt->key_code = GF_KEY_CLEAR; break; - case SDLK_PAUSE: evt->key_code = GF_KEY_PAUSE; break; - case SDLK_ESCAPE: evt->key_code = GF_KEY_ESCAPE; break; - case SDLK_SPACE: evt->key_code = GF_KEY_SPACE; break; + case SDLK_BACKSPACE: + evt->key_code = GF_KEY_BACKSPACE; + break; + case SDLK_TAB: + evt->key_code = GF_KEY_TAB; + break; + case SDLK_CLEAR: + evt->key_code = GF_KEY_CLEAR; + break; + case SDLK_PAUSE: + evt->key_code = GF_KEY_PAUSE; + break; + case SDLK_ESCAPE: + evt->key_code = GF_KEY_ESCAPE; + break; + case SDLK_SPACE: + evt->key_code = GF_KEY_SPACE; + break; - case SDLK_KP_ENTER: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_RETURN: - evt->key_code = GF_KEY_ENTER; + case SDLK_KP_ENTER: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_RETURN: + evt->key_code = GF_KEY_ENTER; break; - case SDLK_KP_MULTIPLY: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_ASTERISK: - evt->key_code = GF_KEY_STAR; + case SDLK_KP_MULTIPLY: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_ASTERISK: + evt->key_code = GF_KEY_STAR; break; - case SDLK_KP_PLUS: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_PLUS: - evt->key_code = GF_KEY_PLUS; + case SDLK_KP_PLUS: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_PLUS: + evt->key_code = GF_KEY_PLUS; break; - case SDLK_KP_MINUS: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_MINUS: - evt->key_code = GF_KEY_HYPHEN; + case SDLK_KP_MINUS: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_MINUS: + evt->key_code = GF_KEY_HYPHEN; break; - case SDLK_KP_DIVIDE: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_SLASH: - evt->key_code = GF_KEY_SLASH; + case SDLK_KP_DIVIDE: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_SLASH: + evt->key_code = GF_KEY_SLASH; break; - case SDLK_KP_0: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_0: - evt->key_code = GF_KEY_0; + case SDLK_KP_0: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_0: + evt->key_code = GF_KEY_0; break; - case SDLK_KP_1: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_1: - evt->key_code = GF_KEY_1; + case SDLK_KP_1: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_1: + evt->key_code = GF_KEY_1; break; - case SDLK_KP_2: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_2: - evt->key_code = GF_KEY_2; + case SDLK_KP_2: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_2: + evt->key_code = GF_KEY_2; break; - case SDLK_KP_3: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_3: - evt->key_code = GF_KEY_3; + case SDLK_KP_3: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_3: + evt->key_code = GF_KEY_3; break; - case SDLK_KP_4: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_4: - evt->key_code = GF_KEY_4; + case SDLK_KP_4: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_4: + evt->key_code = GF_KEY_4; break; - case SDLK_KP_5: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_5: - evt->key_code = GF_KEY_5; + case SDLK_KP_5: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_5: + evt->key_code = GF_KEY_5; break; - case SDLK_KP_6: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_6: - evt->key_code = GF_KEY_6; + case SDLK_KP_6: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_6: + evt->key_code = GF_KEY_6; break; - case SDLK_KP_7: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_7: - evt->key_code = GF_KEY_7; + case SDLK_KP_7: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_7: + evt->key_code = GF_KEY_7; break; - case SDLK_KP_8: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_8: - evt->key_code = GF_KEY_8; + case SDLK_KP_8: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_8: + evt->key_code = GF_KEY_8; break; - case SDLK_KP_9: evt->flags = GF_KEY_EXT_NUMPAD; - case SDLK_9: - evt->key_code = GF_KEY_9; + case SDLK_KP_9: + evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_9: + evt->key_code = GF_KEY_9; break; - case SDLK_KP_PERIOD: evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_KP_PERIOD: + evt->flags = GF_KEY_EXT_NUMPAD; case SDLK_PERIOD: - evt->key_code = GF_KEY_FULLSTOP; + evt->key_code = GF_KEY_FULLSTOP; break; - case SDLK_KP_EQUALS: evt->flags = GF_KEY_EXT_NUMPAD; + case SDLK_KP_EQUALS: + evt->flags = GF_KEY_EXT_NUMPAD; case SDLK_EQUALS: - evt->key_code = GF_KEY_EQUALS; - break; - - case SDLK_EXCLAIM: evt->key_code = GF_KEY_EXCLAMATION; break; - case SDLK_QUOTEDBL: evt->key_code = GF_KEY_QUOTATION; break; - case SDLK_HASH: evt->key_code = GF_KEY_NUMBER; break; - case SDLK_DOLLAR: evt->key_code = GF_KEY_DOLLAR; break; - case SDLK_AMPERSAND: evt->key_code = GF_KEY_AMPERSAND; break; - case SDLK_QUOTE: evt->key_code = GF_KEY_APOSTROPHE; break; - case SDLK_LEFTPAREN: evt->key_code = GF_KEY_LEFTPARENTHESIS; break; - case SDLK_RIGHTPAREN: evt->key_code = GF_KEY_RIGHTPARENTHESIS; break; - case SDLK_COMMA: evt->key_code = GF_KEY_COMMA; break; - case SDLK_COLON: evt->key_code = GF_KEY_COLON; break; - case SDLK_SEMICOLON: evt->key_code = GF_KEY_SEMICOLON; break; - case SDLK_LESS: evt->key_code = GF_KEY_LESSTHAN; break; - case SDLK_GREATER: evt->key_code = GF_KEY_GREATERTHAN; break; - case SDLK_QUESTION: evt->key_code = GF_KEY_QUESTION; break; - case SDLK_AT: evt->key_code = GF_KEY_AT; break; - case SDLK_LEFTBRACKET: evt->key_code = GF_KEY_LEFTSQUAREBRACKET; break; - case SDLK_RIGHTBRACKET: evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; break; - case SDLK_BACKSLASH: evt->key_code = GF_KEY_BACKSLASH; break; - case SDLK_UNDERSCORE: evt->key_code = GF_KEY_UNDERSCORE; break; - case SDLK_BACKQUOTE: evt->key_code = GF_KEY_GRAVEACCENT; break; - case SDLK_DELETE: evt->key_code = GF_KEY_DEL; break; - case SDLK_UNDO: evt->key_code = GF_KEY_UNDO; break; - - case SDLK_UP: evt->key_code = GF_KEY_UP; break; - case SDLK_DOWN: evt->key_code = GF_KEY_DOWN; break; - case SDLK_RIGHT: evt->key_code = GF_KEY_RIGHT; break; - case SDLK_LEFT: evt->key_code = GF_KEY_LEFT; break; - case SDLK_INSERT: evt->key_code = GF_KEY_INSERT; break; - case SDLK_HOME: evt->key_code = GF_KEY_HOME; break; - case SDLK_END: evt->key_code = GF_KEY_END; break; - case SDLK_PAGEUP: evt->key_code = GF_KEY_PAGEUP; break; - case SDLK_PAGEDOWN: evt->key_code = GF_KEY_PAGEDOWN; break; - case SDLK_F1: evt->key_code = GF_KEY_F1; break; - case SDLK_F2: evt->key_code = GF_KEY_F2; break; - case SDLK_F3: evt->key_code = GF_KEY_F3; break; - case SDLK_F4: evt->key_code = GF_KEY_F4; break; - case SDLK_F5: evt->key_code = GF_KEY_F5; break; - case SDLK_F6: evt->key_code = GF_KEY_F6; break; - case SDLK_F7: evt->key_code = GF_KEY_F7; break; - case SDLK_F8: evt->key_code = GF_KEY_F8; break; - case SDLK_F9: evt->key_code = GF_KEY_F9; break; - case SDLK_F10: evt->key_code = GF_KEY_F10; break; - case SDLK_F11: evt->key_code = GF_KEY_F11; break; - case SDLK_F12: evt->key_code = GF_KEY_F12; break; - case SDLK_F13: evt->key_code = GF_KEY_F13; break; - case SDLK_F14: evt->key_code = GF_KEY_F14; break; - case SDLK_F15: evt->key_code = GF_KEY_F15; break; - case SDLK_NUMLOCKCLEAR: evt->key_code = GF_KEY_NUMLOCK; break; - case SDLK_CAPSLOCK: evt->key_code = GF_KEY_CAPSLOCK; break; - case SDLK_SCROLLLOCK: evt->key_code = GF_KEY_SCROLL; break; - - case SDLK_RSHIFT: + evt->key_code = GF_KEY_EQUALS; + break; + + case SDLK_EXCLAIM: + evt->key_code = GF_KEY_EXCLAMATION; + break; + case SDLK_QUOTEDBL: + evt->key_code = GF_KEY_QUOTATION; + break; + case SDLK_HASH: + evt->key_code = GF_KEY_NUMBER; + break; + case SDLK_DOLLAR: + evt->key_code = GF_KEY_DOLLAR; + break; + case SDLK_AMPERSAND: + evt->key_code = GF_KEY_AMPERSAND; + break; + case SDLK_QUOTE: + evt->key_code = GF_KEY_APOSTROPHE; + break; + case SDLK_LEFTPAREN: + evt->key_code = GF_KEY_LEFTPARENTHESIS; + break; + case SDLK_RIGHTPAREN: + evt->key_code = GF_KEY_RIGHTPARENTHESIS; + break; + case SDLK_COMMA: + evt->key_code = GF_KEY_COMMA; + break; + case SDLK_COLON: + evt->key_code = GF_KEY_COLON; + break; + case SDLK_SEMICOLON: + evt->key_code = GF_KEY_SEMICOLON; + break; + case SDLK_LESS: + evt->key_code = GF_KEY_LESSTHAN; + break; + case SDLK_GREATER: + evt->key_code = GF_KEY_GREATERTHAN; + break; + case SDLK_QUESTION: + evt->key_code = GF_KEY_QUESTION; + break; + case SDLK_AT: + evt->key_code = GF_KEY_AT; + break; + case SDLK_LEFTBRACKET: + evt->key_code = GF_KEY_LEFTSQUAREBRACKET; + break; + case SDLK_RIGHTBRACKET: + evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; + break; + case SDLK_BACKSLASH: + evt->key_code = GF_KEY_BACKSLASH; + break; + case SDLK_UNDERSCORE: + evt->key_code = GF_KEY_UNDERSCORE; + break; + case SDLK_BACKQUOTE: + evt->key_code = GF_KEY_GRAVEACCENT; + break; + case SDLK_DELETE: + evt->key_code = GF_KEY_DEL; + break; + case SDLK_UNDO: + evt->key_code = GF_KEY_UNDO; + break; + + case SDLK_UP: + evt->key_code = GF_KEY_UP; + break; + case SDLK_DOWN: + evt->key_code = GF_KEY_DOWN; + break; + case SDLK_RIGHT: + evt->key_code = GF_KEY_RIGHT; + break; + case SDLK_LEFT: + evt->key_code = GF_KEY_LEFT; + break; + case SDLK_INSERT: + evt->key_code = GF_KEY_INSERT; + break; + case SDLK_HOME: + evt->key_code = GF_KEY_HOME; + break; + case SDLK_END: + evt->key_code = GF_KEY_END; + break; + case SDLK_PAGEUP: + evt->key_code = GF_KEY_PAGEUP; + break; + case SDLK_PAGEDOWN: + evt->key_code = GF_KEY_PAGEDOWN; + break; + case SDLK_F1: + evt->key_code = GF_KEY_F1; + break; + case SDLK_F2: + evt->key_code = GF_KEY_F2; + break; + case SDLK_F3: + evt->key_code = GF_KEY_F3; + break; + case SDLK_F4: + evt->key_code = GF_KEY_F4; + break; + case SDLK_F5: + evt->key_code = GF_KEY_F5; + break; + case SDLK_F6: + evt->key_code = GF_KEY_F6; + break; + case SDLK_F7: + evt->key_code = GF_KEY_F7; + break; + case SDLK_F8: + evt->key_code = GF_KEY_F8; + break; + case SDLK_F9: + evt->key_code = GF_KEY_F9; + break; + case SDLK_F10: + evt->key_code = GF_KEY_F10; + break; + case SDLK_F11: + evt->key_code = GF_KEY_F11; + break; + case SDLK_F12: + evt->key_code = GF_KEY_F12; + break; + case SDLK_F13: + evt->key_code = GF_KEY_F13; + break; + case SDLK_F14: + evt->key_code = GF_KEY_F14; + break; + case SDLK_F15: + evt->key_code = GF_KEY_F15; + break; + case SDLK_NUMLOCKCLEAR: + evt->key_code = GF_KEY_NUMLOCK; + break; + case SDLK_CAPSLOCK: + evt->key_code = GF_KEY_CAPSLOCK; + break; + case SDLK_SCROLLLOCK: + evt->key_code = GF_KEY_SCROLL; + break; + + case SDLK_RSHIFT: evt->key_code = GF_KEY_SHIFT; evt->flags = GF_KEY_EXT_RIGHT; break; - case SDLK_LSHIFT: + case SDLK_LSHIFT: evt->key_code = GF_KEY_SHIFT; evt->flags = GF_KEY_EXT_LEFT; break; - case SDLK_LCTRL: + case SDLK_LCTRL: evt->key_code = GF_KEY_CONTROL; evt->flags = GF_KEY_EXT_LEFT; break; - case SDLK_RCTRL: + case SDLK_RCTRL: evt->key_code = GF_KEY_CONTROL; evt->flags = GF_KEY_EXT_RIGHT; break; - case SDLK_LALT: + case SDLK_LALT: evt->key_code = GF_KEY_ALT; evt->flags = GF_KEY_EXT_LEFT; break; - case SDLK_RALT: + case SDLK_RALT: evt->key_code = GF_KEY_ALT; evt->flags = GF_KEY_EXT_RIGHT; break; #if (SDL_MAJOR_VERSION<=1) && (SDL_MINOR_VERSION<3) - case SDLK_LMETA: - case SDLK_LSUPER: + case SDLK_LMETA: + case SDLK_LSUPER: #else - case SDLK_LGUI: + case SDLK_LGUI: #endif evt->key_code = GF_KEY_META; evt->flags = GF_KEY_EXT_LEFT; break; #if (SDL_MAJOR_VERSION<=1) && (SDL_MINOR_VERSION<3) - case SDLK_RMETA: - case SDLK_RSUPER: + case SDLK_RMETA: + case SDLK_RSUPER: #else - case SDLK_RGUI: + case SDLK_RGUI: #endif evt->key_code = GF_KEY_META; evt->flags = GF_KEY_EXT_RIGHT; break; - case SDLK_MODE: evt->key_code = GF_KEY_MODECHANGE; break; - case SDLK_APPLICATION: evt->key_code = GF_KEY_COMPOSE; break; - case SDLK_HELP: evt->key_code = GF_KEY_HELP; break; - case SDLK_PRINTSCREEN: evt->key_code = GF_KEY_PRINTSCREEN; break; + case SDLK_MODE: + evt->key_code = GF_KEY_MODECHANGE; + break; + case SDLK_APPLICATION: + evt->key_code = GF_KEY_COMPOSE; + break; + case SDLK_HELP: + evt->key_code = GF_KEY_HELP; + break; + case SDLK_PRINTSCREEN: + evt->key_code = GF_KEY_PRINTSCREEN; + break; #if (SDL_MAJOR_VERSION>=1) && (SDL_MINOR_VERSION>=3) -/* - SDLK_CARET = 94, - */ + /* + SDLK_CARET = 94, + */ case SDLK_a: case SDLK_b: case SDLK_c: @@ -419,20 +554,20 @@ static void sdl_translate_key(u32 SDLkey, GF_EventKey *evt) case SDLK_z: evt->key_code = GF_KEY_A + SDLkey - SDLK_a; break; - /* - SDLK_DELETE = 127, + /* + SDLK_DELETE = 127, - SDLK_SYSREQ = 317, - SDLK_POWER = 320, + SDLK_SYSREQ = 317, + SDLK_POWER = 320, -*/ + */ #endif - + default: if ((SDLkey>=0x30) && (SDLkey<=0x39)) evt->key_code = GF_KEY_0 + SDLkey-0x30; else if ((SDLkey>=0x41) && (SDLkey<=0x5A)) evt->key_code = GF_KEY_A + SDLkey-0x41; else if ((SDLkey>=0x61) && (SDLkey<=0x7A)) evt->key_code = GF_KEY_A + SDLkey-0x61; - else + else { evt->key_code = GF_KEY_UNIDENTIFIED; } @@ -513,12 +648,12 @@ GF_Err SDLVid_ResizeWindow(GF_VideoOutput *dr, u32 width, u32 height) Bool hw_reset = GF_FALSE; SDLVID(); GF_Event evt; - + /*lock X mutex to make sure the event queue is not being processed*/ gf_mx_p(ctx->evt_mx); - - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Resizing window %dx%d\n", width, height)); - + + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Resizing window %dx%d\n", width, height)); + if (ctx->output_3d_type) { u32 flags, nb_bits; const char *opt; @@ -527,7 +662,7 @@ GF_Err SDLVid_ResizeWindow(GF_VideoOutput *dr, u32 width, u32 height) gf_mx_v(ctx->evt_mx); return GF_OK; } - + #if SDL_VERSION_ATLEAST(2,0,0) flags = SDL_GL_WINDOW_FLAGS; if (ctx->os_handle) flags &= ~SDL_WINDOW_RESIZABLE; @@ -552,14 +687,14 @@ GF_Err SDLVid_ResizeWindow(GF_VideoOutput *dr, u32 width, u32 height) assert(width); assert(height); -#if SDL_VERSION_ATLEAST(2,0,0) +#if SDL_VERSION_ATLEAST(2,0,0) if (!ctx->screen) { if (!(ctx->screen = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags))) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Cannot create window: %s\n", SDL_GetError())); gf_mx_v(ctx->evt_mx); return GF_IO_ERR; } - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Window created\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Window created\n")); } if ( !ctx->gl_context ) { @@ -575,8 +710,8 @@ GF_Err SDLVid_ResizeWindow(GF_VideoOutput *dr, u32 width, u32 height) } hw_reset = GF_TRUE; } - SDL_SetWindowSize(ctx->screen, width, height); - + SDL_SetWindowSize(ctx->screen, width, height); + #else hw_reset = GF_TRUE; ctx->screen = SDL_SetVideoMode(width, height, 0, flags); @@ -609,22 +744,22 @@ GF_Err SDLVid_ResizeWindow(GF_VideoOutput *dr, u32 width, u32 height) gf_mx_v(ctx->evt_mx); return GF_IO_ERR; } - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Window created\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Window created\n")); } if ( !ctx->renderer ) { u32 flags = SDL_RENDERER_ACCELERATED; const char *opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "DisableVSync"); - if (!opt || strcmp(opt, "yes")) + if (!opt || strcmp(opt, "yes")) flags |= SDL_RENDERER_PRESENTVSYNC; - + if (!(ctx->renderer = SDL_CreateRenderer(ctx->screen, -1, flags))) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Cannot create renderer: %s\n", SDL_GetError())); + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Cannot create renderer: %s\n", SDL_GetError())); gf_mx_v(ctx->evt_mx); return GF_IO_ERR; } - } - SDL_SetWindowSize(ctx->screen, width, height); + } + SDL_SetWindowSize(ctx->screen, width, height); #else ctx->screen = SDL_SetVideoMode(width, height, 0, flags); #endif @@ -647,14 +782,14 @@ static Bool SDLVid_InitializeWindow(SDLVidCtx *ctx, GF_VideoOutput *dr) #ifdef WIN32 putenv("directx"); #endif - - flags = SDL_WasInit(SDL_INIT_VIDEO); + + flags = SDL_WasInit(SDL_INIT_VIDEO); if (!(flags & SDL_INIT_VIDEO)) { if (SDL_InitSubSystem(SDL_INIT_VIDEO)) { return 0; } } - + ctx->curs_def = SDL_GetCursor(); ctx->curs_hand = SDLVid_LoadCursor(hand_data); ctx->curs_collide = SDLVid_LoadCursor(collide_data); @@ -686,16 +821,16 @@ static Bool SDLVid_InitializeWindow(SDLVidCtx *ctx, GF_VideoOutput *dr) SDL_Rect** modes; modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); assert( (modes != (SDL_Rect**)0)); - if ( modes == (SDL_Rect**)-1 ){ + if ( modes == (SDL_Rect**)-1 ) { fprintf(stderr, "SDL : DONT KNOW WHICH MODE TO USE, using 640x480\n"); dr->max_screen_width = 640; dr->max_screen_height = 480; } else { int i; dr->max_screen_width = 0; - for (i=0; modes[i]; ++i){ + for (i=0; modes[i]; ++i) { int w = modes[i]->w; - if (w > dr->max_screen_width){ + if (w > dr->max_screen_width) { dr->max_screen_width = w; dr->max_screen_height = modes[i]->h; } @@ -706,13 +841,13 @@ static Bool SDLVid_InitializeWindow(SDLVidCtx *ctx, GF_VideoOutput *dr) #endif /* versions prior to 1.2.10 do not have the size of screen */ #endif - if (!ctx->os_handle) + if (!ctx->os_handle) #if SDL_VERSION_ATLEAST(2,0,0) SDLVid_SetCaption(ctx->screen); #else SDLVid_SetCaption(); #endif - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Video output initialized - screen resolution %d %d\n", dr->max_screen_width, dr->max_screen_height)); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Video output initialized - screen resolution %d %d\n", dr->max_screen_width, dr->max_screen_height)); return 1; } @@ -722,14 +857,14 @@ static void SDLVid_ResetWindow(SDLVidCtx *ctx) #if SDL_VERSION_ATLEAST(2,0,0) if ( ctx->gl_context ) { SDL_GL_DeleteContext(ctx->gl_context); - ctx->gl_context = NULL; - } + ctx->gl_context = NULL; + } if ( ctx->renderer ) { SDL_DestroyRenderer(ctx->renderer); - ctx->renderer = NULL; - } - - /*iOS SDL2 has a nasty bug that breaks switching between 2D and GL context if we don't re-init the video subsystem*/ + ctx->renderer = NULL; + } + + /*iOS SDL2 has a nasty bug that breaks switching between 2D and GL context if we don't re-init the video subsystem*/ #ifdef GPAC_IPHONE if ( ctx->screen ) { SDL_DestroyWindow(ctx->screen); @@ -738,7 +873,7 @@ static void SDLVid_ResetWindow(SDLVidCtx *ctx) SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); #endif - + #endif } @@ -765,7 +900,7 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) case SDL_WINDOWEVENT: switch (sdl_evt.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: - gpac_evt.type = GF_EVENT_SIZE; + gpac_evt.type = GF_EVENT_SIZE; gpac_evt.size.width = sdl_evt.window.data1; gpac_evt.size.height = sdl_evt.window.data2; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); @@ -780,7 +915,7 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) break; #else case SDL_VIDEORESIZE: - gpac_evt.type = GF_EVENT_SIZE; + gpac_evt.type = GF_EVENT_SIZE; gpac_evt.size.width = sdl_evt.resize.w; gpac_evt.size.height = sdl_evt.resize.h; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); @@ -790,13 +925,13 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) dr->on_event(dr->evt_cbk_hdl, &gpac_evt); break; #endif - + case SDL_QUIT: memset(&gpac_evt, 0, sizeof(GF_Event)); gpac_evt.type = GF_EVENT_QUIT; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); return 0; - + #ifdef SDL_TEXTINPUTEVENT_TEXT_SIZE /*keyboard*/ case SDL_TEXTINPUT: /* Since SDL 1.3, text-input is handled in a specific event */ @@ -806,7 +941,7 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) assert( len < 5 ); ucs4_len = utf8_to_ucs4 (&(gpac_evt.character.unicode_char), len, (unsigned char*)(sdl_evt.text.text)); gpac_evt.type = GF_EVENT_TEXTINPUT; - dr->on_event(dr->evt_cbk_hdl, &gpac_evt); + dr->on_event(dr->evt_cbk_hdl, &gpac_evt); break; } #endif /* SDL_TEXTINPUTEVENT_TEXT_SIZE */ @@ -818,16 +953,16 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) if (gpac_evt.key.key_code==GF_KEY_CONTROL) ctx->ctrl_down = (sdl_evt.key.type==SDL_KEYDOWN) ? 1 : 0; else if (gpac_evt.key.key_code==GF_KEY_ALT) ctx->alt_down = (sdl_evt.key.type==SDL_KEYDOWN) ? 1 : 0; else if (gpac_evt.key.key_code==GF_KEY_META) ctx->meta_down = (sdl_evt.key.type==SDL_KEYDOWN) ? 1 : 0; - + #if (SDL_MAJOR_VERSION>=1) && (SDL_MINOR_VERSION>=3) - if ((gpac_evt.type==GF_EVENT_KEYUP) && (gpac_evt.key.key_code==GF_KEY_V) + if ((gpac_evt.type==GF_EVENT_KEYUP) && (gpac_evt.key.key_code==GF_KEY_V) #if defined(__DARWIN__) || defined(__APPLE__) - && ctx->meta_down + && ctx->meta_down #else - && ctx->ctrl_down + && ctx->ctrl_down #endif - ) { + ) { #if defined(__DARWIN__) || defined(__APPLE__) #else gpac_evt.type = GF_EVENT_PASTE_TEXT; @@ -836,33 +971,33 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) SDL_free((char *) gpac_evt.message.message); #endif } - else if ((gpac_evt.type==GF_EVENT_KEYUP) && (gpac_evt.key.key_code==GF_KEY_C) + else if ((gpac_evt.type==GF_EVENT_KEYUP) && (gpac_evt.key.key_code==GF_KEY_C) #if defined(__DARWIN__) || defined(__APPLE__) - && ctx->meta_down + && ctx->meta_down #else - && ctx->ctrl_down + && ctx->ctrl_down #endif - ) { - gpac_evt.type = GF_EVENT_COPY_TEXT; + ) { + gpac_evt.type = GF_EVENT_COPY_TEXT; #if defined(__DARWIN__) || defined(__APPLE__) #else - if (dr->on_event(dr->evt_cbk_hdl, &gpac_evt)==GF_TRUE) - SDL_SetClipboardText((char *)gpac_evt.message.message ); + if (dr->on_event(dr->evt_cbk_hdl, &gpac_evt)==GF_TRUE) + SDL_SetClipboardText((char *)gpac_evt.message.message ); #endif } #endif #ifndef SDL_TEXTINPUTEVENT_TEXT_SIZE if ((sdl_evt.key.type==SDL_KEYDOWN) - && sdl_evt.key.keysym.unicode - && ((sdl_evt.key.keysym.unicode=='\r') || (sdl_evt.key.keysym.unicode=='\n') || (sdl_evt.key.keysym.unicode=='\b') || (sdl_evt.key.keysym.unicode=='\t') ) - ) { + && sdl_evt.key.keysym.unicode + && ((sdl_evt.key.keysym.unicode=='\r') || (sdl_evt.key.keysym.unicode=='\n') || (sdl_evt.key.keysym.unicode=='\b') || (sdl_evt.key.keysym.unicode=='\t') ) + ) { gpac_evt.character.unicode_char = sdl_evt.key.keysym.unicode; gpac_evt.type = GF_EVENT_TEXTINPUT; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); } #endif - break; + break; /*mouse*/ case SDL_MOUSEMOTION: @@ -879,15 +1014,15 @@ Bool SDLVid_ProcessMessageQueue(SDLVidCtx *ctx, GF_VideoOutput *dr) gpac_evt.mouse.y = sdl_evt.motion.y; gpac_evt.type = (sdl_evt.type==SDL_MOUSEBUTTONUP) ? GF_EVENT_MOUSEUP : GF_EVENT_MOUSEDOWN; switch (sdl_evt.button.button) { - case SDL_BUTTON_LEFT: + case SDL_BUTTON_LEFT: gpac_evt.mouse.button = GF_MOUSE_LEFT; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); break; - case SDL_BUTTON_MIDDLE: + case SDL_BUTTON_MIDDLE: gpac_evt.mouse.button = GF_MOUSE_MIDDLE; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); break; - case SDL_BUTTON_RIGHT: + case SDL_BUTTON_RIGHT: gpac_evt.mouse.button = GF_MOUSE_RIGHT; dr->on_event(dr->evt_cbk_hdl, &gpac_evt); break; @@ -959,7 +1094,7 @@ u32 SDLVid_EventProc(void *par) cursor_on = 1; } #endif - + /*QUIT message has been processed*/ if (!ret) { ctx->sdl_th_state = SDL_STATE_STOP_REQ; @@ -992,7 +1127,7 @@ GF_Err SDLVid_Setup(struct _video_out *dr, void *os_handle, void *os_display, u3 ctx->force_alpha = (init_flags & GF_TERM_WINDOW_TRANSPARENT) ? 1 : 0; if (!SDLOUT_InitSDL()) - return GF_IO_ERR; + return GF_IO_ERR; #ifdef SDL_WINDOW_THREAD ctx->sdl_th_state = SDL_STATE_STOPPED; @@ -1009,7 +1144,7 @@ GF_Err SDLVid_Setup(struct _video_out *dr, void *os_handle, void *os_display, u3 } #else if (!SDLVid_InitializeWindow(ctx, dr)) { - SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_QuitSubSystem(SDL_INIT_VIDEO); SDLOUT_CloseSDL(); return GF_IO_ERR; } @@ -1057,7 +1192,7 @@ GF_Err SDLVid_SetFullScreen(GF_VideoOutput *dr, Bool bFullScreenOn, u32 *screen_ #endif if (ctx->fullscreen==bFullScreenOn) return GF_OK; - + /*lock to get sure the event queue is not processed under X*/ gf_mx_p(ctx->evt_mx); ctx->fullscreen = bFullScreenOn; @@ -1158,7 +1293,7 @@ GF_Err SDLVid_SetBackbufferSize(GF_VideoOutput *dr, u32 newWidth, u32 newHeight, #else u32 col; #endif - + if (ctx->output_3d_type==1) return GF_BAD_PARAM; opt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "HardwareMemory"); @@ -1249,9 +1384,9 @@ static GF_Err SDLVid_Flush(GF_VideoOutput *dr, GF_Window *dest) /*if resizing don't process otherwise we may deadlock*/ if (!ctx->screen) return GF_OK; - //GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Flush\n")); - - if (ctx->output_3d_type==1) { + //GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Flush\n")); + + if (ctx->output_3d_type==1) { #if SDL_VERSION_ATLEAST(2,0,0) SDL_GL_SwapWindow(ctx->screen); #else @@ -1303,12 +1438,15 @@ static GF_Err SDLVid_Flush(GF_VideoOutput *dr, GF_Window *dest) SDL_UnlockSurface(ctx->screen); #endif SDL_UnlockSurface(ctx->back_buffer); - + } else { #if SDL_VERSION_ATLEAST(2,0,0) SDL_Texture* tx; #endif - rc.x = dest->x; rc.y = dest->y; rc.w = dest->w; rc.h = dest->h; + rc.x = dest->x; + rc.y = dest->y; + rc.w = dest->w; + rc.h = dest->h; #if SDL_VERSION_ATLEAST(2,0,0) SDL_ClearError(); if (!(tx = SDL_CreateTextureFromSurface(ctx->renderer, ctx->back_buffer))) { @@ -1355,8 +1493,10 @@ static u32 get_sys_col(int idx) { u32 res; DWORD val = GetSysColor(idx); - res = (val)&0xFF; res<<=8; - res |= (val>>8)&0xFF; res<<=8; + res = (val)&0xFF; + res<<=8; + res |= (val>>8)&0xFF; + res<<=8; res |= (val>>16)&0xFF; return res; } @@ -1368,7 +1508,7 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) #ifndef SDL_WINDOW_THREAD SDLVID(); SDLVid_ProcessMessageQueue(ctx, dr); -#endif +#endif #if SDL_VERSION_ATLEAST(2,0,0) { SDLVID(); @@ -1400,9 +1540,9 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) ctx->szCaption[99]=0; } #else - SDL_WM_SetCaption(evt->caption.caption, NULL); + SDL_WM_SetCaption(evt->caption.caption, NULL); #endif - break; + break; case GF_EVENT_SHOWHIDE: /*the only way to have proper show/hide with SDL is to shutdown the video system and reset it up which we don't want to do since the setup MUST occur in the rendering thread for some configs (openGL)*/ @@ -1422,7 +1562,7 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) #endif } } - break; + break; case GF_EVENT_MOVE: break; case GF_EVENT_VIDEO_SETUP: @@ -1435,7 +1575,7 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) ctx->width = ctx->height = 0; ctx->output_3d_type = 0; SDLVid_ResetWindow(ctx); - SDLVid_ResizeWindow(dr, evt->setup.width, evt->setup.height); + SDLVid_ResizeWindow(dr, evt->setup.width, evt->setup.height); } else { #if SDL_VERSION_ATLEAST(2,0,0) SDLVid_ResizeWindow(dr, evt->setup.width, evt->setup.height); @@ -1450,7 +1590,7 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) SDLVid_ResetWindow(ctx); } ctx->output_3d_type = 1; - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Setting up 3D in SDL.\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Setting up 3D in SDL.\n")); #ifdef GPAC_IPHONE // return SDLVid_ResizeWindow(dr, dr->max_screen_width, dr->max_screen_height); return SDLVid_ResizeWindow(dr, evt->setup.width, evt->setup.height); @@ -1466,7 +1606,7 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) default: GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Trying to set an Unknown Mode %d !\n", evt->setup.opengl_mode)); return GF_NOT_SUPPORTED; - } + } break; case GF_EVENT_SYS_COLORS: #ifdef WIN32 @@ -1533,7 +1673,7 @@ static void copy_yuv(u8 *pYD, u8 *pVD, u8 *pUD, u32 pixel_format, u32 pitch_y, u memcpy(pYD, pY, sizeof(unsigned char)*src_width*src_height); memcpy(pVD, pV, sizeof(unsigned char)*src_width*src_height/4); memcpy(pUD, pU, sizeof(unsigned char)*src_width*src_height/4); - } else if (src_pf==GF_PIXEL_YUY2){ + } else if (src_pf==GF_PIXEL_YUY2) { u32 i, j; unsigned char *dst_y, *dst_u, *dst_v; @@ -1565,7 +1705,7 @@ static void copy_yuv(u8 *pYD, u8 *pVD, u8 *pUD, u32 pixel_format, u32 pitch_y, u pV += src_stride; } } - } else if (src_pf==GF_PIXEL_YV12_10){ + } else if (src_pf==GF_PIXEL_YV12_10) { u32 i, j; for (i=0; ih; i++) { u16 *py = (u16 *) (pY + i*src_stride); @@ -1598,7 +1738,7 @@ static void copy_yuv(u8 *pYD, u8 *pVD, u8 *pUD, u32 pixel_format, u32 pitch_y, u src = pY; dst = pYD; - + src2 = (pixel_format != GF_PIXEL_YV12) ? pU : pV; dst2 = pVD; src3 = (pixel_format != GF_PIXEL_YV12) ? pV : pU; @@ -1632,7 +1772,7 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window SDL_Rect dstrc; SDL_Surface **pool; - GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[SDL] Bliting surface (overlay type %d)\n", overlay_type)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[SDL] Bliting surface (overlay type %d)\n", overlay_type)); if (overlay_type) { #if SDL_VERSION_ATLEAST(2,0,0) @@ -1701,9 +1841,9 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window /*copy pixels*/ SDL_LockYUVOverlay(ctx->yuv_overlay); - copy_yuv(ctx->yuv_overlay->pixels[0], ctx->yuv_overlay->pixels[1], ctx->yuv_overlay->pixels[2], GF_PIXEL_YV12, ctx->yuv_overlay->pitches[0], - (unsigned char *) video_src->video_buffer, (unsigned char *) video_src->u_ptr, (unsigned char *) video_src->v_ptr, video_src->pitch_y, video_src->pixel_format, - video_src->width, video_src->height, src_wnd); + copy_yuv(ctx->yuv_overlay->pixels[0], ctx->yuv_overlay->pixels[1], ctx->yuv_overlay->pixels[2], GF_PIXEL_YV12, ctx->yuv_overlay->pitches[0], + (unsigned char *) video_src->video_buffer, (unsigned char *) video_src->u_ptr, (unsigned char *) video_src->v_ptr, video_src->pitch_y, video_src->pixel_format, + video_src->width, video_src->height, src_wnd); SDL_UnlockYUVOverlay(ctx->yuv_overlay); @@ -1717,7 +1857,7 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window } /*SDL doesn't support stretching ...*/ - if ((src_wnd->w != dst_wnd->w) || (src_wnd->h!=dst_wnd->h)) + if ((src_wnd->w != dst_wnd->w) || (src_wnd->h!=dst_wnd->h)) return GF_NOT_SUPPORTED; switch (video_src->pixel_format) { @@ -1730,7 +1870,7 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window #if SDL_BYTEORDER == SDL_BIG_ENDIAN amask = 0x000000FF; #else - amask = 0xFF000000; + amask = 0xFF000000; #endif bpp = 4; break; @@ -1738,33 +1878,33 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window return GF_NOT_SUPPORTED; } #if SDL_VERSION_ATLEAST(2,0,0) - if ((*pool)) SDL_FreeSurface((*pool)); - (*pool) = SDL_CreateRGBSurfaceFrom(video_src->video_buffer + video_src->pitch_y*src_wnd->y + src_wnd->x*bpp, - src_wnd->w, src_wnd->h, 8*bpp, video_src->pitch_y, + if ((*pool)) SDL_FreeSurface((*pool)); + (*pool) = SDL_CreateRGBSurfaceFrom(video_src->video_buffer + video_src->pitch_y*src_wnd->y + src_wnd->x*bpp, + src_wnd->w, src_wnd->h, 8*bpp, video_src->pitch_y, #if SDL_BYTEORDER == SDL_BIG_ENDIAN - 0xFF000000, 0x00FF0000, 0x0000FF00, amask); + 0xFF000000, 0x00FF0000, 0x0000FF00, amask); #else - 0x000000FF, 0x0000FF00, 0x00FF0000, amask); + 0x000000FF, 0x0000FF00, 0x00FF0000, amask); #endif - dstrc.w = dst_wnd->w; + dstrc.w = dst_wnd->w; dstrc.h = dst_wnd->h; dstrc.x = dst_wnd->x; dstrc.y = dst_wnd->y; - + if (SDL_BlitSurface(*pool, NULL, ctx->back_buffer, &dstrc)) - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Blit error: %s\n", SDL_GetError())); + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Blit error: %s\n", SDL_GetError())); + - SDL_FreeSurface((*pool)); - *pool = NULL; + *pool = NULL; #else if (! *pool || ((*pool)->w < (int) src_wnd->w) || ((*pool)->h < (int) src_wnd->h) ) { if ((*pool)) SDL_FreeSurface((*pool)); - (*pool) = SDL_CreateRGBSurface(ctx->use_systems_memory ? SDL_SWSURFACE : SDL_HWSURFACE, - src_wnd->w, src_wnd->h, 8*bpp, - 0x000000FF, 0x0000FF00, 0x00FF0000, amask); + (*pool) = SDL_CreateRGBSurface(ctx->use_systems_memory ? SDL_SWSURFACE : SDL_HWSURFACE, + src_wnd->w, src_wnd->h, 8*bpp, + 0x000000FF, 0x0000FF00, 0x00FF0000, amask); if (! (*pool) ) return GF_IO_ERR; } @@ -1786,10 +1926,10 @@ static GF_Err SDL_Blit(GF_VideoOutput *dr, GF_VideoSurface *video_src, GF_Window dstrc.y = dst_wnd->y; if (SDL_BlitSurface(*pool, NULL, ctx->back_buffer, &dstrc)) - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Blit error: %s\n", SDL_GetError())); + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[SDL] Blit error: %s\n", SDL_GetError())); #endif - - + + return GF_OK; } @@ -1799,7 +1939,7 @@ void *SDL_NewVideo() { SDLVidCtx *ctx; GF_VideoOutput *driv; - + driv = (GF_VideoOutput*)gf_malloc(sizeof(GF_VideoOutput)); memset(driv, 0, sizeof(GF_VideoOutput)); GF_REGISTER_MODULE_INTERFACE(driv, GF_VIDEO_OUTPUT_INTERFACE, "SDL Video Output", "gpac distribution"); @@ -1810,7 +1950,7 @@ void *SDL_NewVideo() ctx->sdl_th = gf_th_new("SDLVideo"); #endif ctx->evt_mx = gf_mx_new("SDLEvents"); - + driv->opaque = ctx; driv->Setup = SDLVid_Setup; driv->Shutdown = SDLVid_Shutdown; @@ -1838,9 +1978,9 @@ void *SDL_NewVideo() } sscanf(opt, "%06x", &driv->overlay_color_key); if (driv->overlay_color_key) driv->overlay_color_key |= 0xFF000000; - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL Out] YUV Overlays enabled - ColorKey enabled: %s (key %x)\n", - driv->overlay_color_key ? "Yes" : "No", driv->overlay_color_key - )); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL Out] YUV Overlays enabled - ColorKey enabled: %s (key %x)\n", + driv->overlay_color_key ? "Yes" : "No", driv->overlay_color_key + )); #endif #ifndef SDL_TEXTINPUTEVENT_TEXT_SIZE SDL_EnableUNICODE(1); diff --git a/modules/sdl_out/video2d.c b/modules/sdl_out/video2d.c index b41481d..9ed42fb 100644 --- a/modules/sdl_out/video2d.c +++ b/modules/sdl_out/video2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "sdl_out.h" diff --git a/modules/soft_raster/ftgrays.c b/modules/soft_raster/ftgrays.c index 5e769f0..e68846c 100644 --- a/modules/soft_raster/ftgrays.c +++ b/modules/soft_raster/ftgrays.c @@ -15,45 +15,45 @@ /* */ /***************************************************************************/ - /*************************************************************************/ - /* */ - /* This is a new anti-aliasing scan-converter for FreeType 2. The */ - /* algorithm used here is _very_ different from the one in the standard */ - /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ - /* coverage of the outline on each pixel cell. */ - /* */ - /* It is based on ideas that I initially found in Raph Levien's */ - /* excellent LibArt graphics library (see http://www.levien.com/libart */ - /* for more information, though the web pages do not tell anything */ - /* about the renderer; you'll have to dive into the source code to */ - /* understand how it works). */ - /* */ - /* Note, however, that this is a _very_ different implementation */ - /* compared to Raph's. Coverage information is stored in a very */ - /* different way, and I don't use sorted vector paths. Also, it doesn't */ - /* use floating point values. */ - /* */ - /* This renderer has the following advantages: */ - /* */ - /* - It doesn't need an intermediate bitmap. Instead, one can supply a */ - /* callback function that will be called by the renderer to draw gray */ - /* spans on any target surface. You can thus do direct composition on */ - /* any kind of bitmap, provided that you give the renderer the right */ - /* callback. */ - /* */ - /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ - /* each pixel cell. */ - /* */ - /* - It performs a single pass on the outline (the `standard' FT2 */ - /* renderer makes two passes). */ - /* */ - /* - It can easily be modified to render to _any_ number of gray levels */ - /* cheaply. */ - /* */ - /* - For small (< 20) pixel sizes, it is faster than the standard */ - /* renderer. */ - /* */ - /*************************************************************************/ +/*************************************************************************/ +/* */ +/* This is a new anti-aliasing scan-converter for FreeType 2. The */ +/* algorithm used here is _very_ different from the one in the standard */ +/* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ +/* coverage of the outline on each pixel cell. */ +/* */ +/* It is based on ideas that I initially found in Raph Levien's */ +/* excellent LibArt graphics library (see http://www.levien.com/libart */ +/* for more information, though the web pages do not tell anything */ +/* about the renderer; you'll have to dive into the source code to */ +/* understand how it works). */ +/* */ +/* Note, however, that this is a _very_ different implementation */ +/* compared to Raph's. Coverage information is stored in a very */ +/* different way, and I don't use sorted vector paths. Also, it doesn't */ +/* use floating point values. */ +/* */ +/* This renderer has the following advantages: */ +/* */ +/* - It doesn't need an intermediate bitmap. Instead, one can supply a */ +/* callback function that will be called by the renderer to draw gray */ +/* spans on any target surface. You can thus do direct composition on */ +/* any kind of bitmap, provided that you give the renderer the right */ +/* callback. */ +/* */ +/* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ +/* each pixel cell. */ +/* */ +/* - It performs a single pass on the outline (the `standard' FT2 */ +/* renderer makes two passes). */ +/* */ +/* - It can easily be modified to render to _any_ number of gray levels */ +/* cheaply. */ +/* */ +/* - For small (< 20) pixel sizes, it is faster than the standard */ +/* renderer. */ +/* */ +/*************************************************************************/ /* @@ -112,7 +112,7 @@ typedef int TArea; #endif - /* maximal number of gray spans in a call to the span callback */ +/* maximal number of gray spans in a call to the span callback */ #define FT_MAX_GRAY_SPANS 64 typedef struct TCell_ @@ -151,7 +151,7 @@ typedef struct TRaster_ #define AA_CELL_STEP_ALLOC 8 -static GFINLINE void gray_record_cell( TRaster *raster ) +static GFINLINE void gray_record_cell( TRaster *raster ) { if (( raster->area | raster->cover) && (raster->eymax_ey)) { AACell *cell; @@ -190,16 +190,16 @@ static GFINLINE void gray_set_cell( TRaster *raster, TCoord ex, TCoord ey ) static GFINLINE void evg_translate_point(GF_Matrix2D *mx, EVG_Vector *pt, TPos *x, TPos *y) { - Fixed _x, _y; - _x = pt->x; - _y = pt->y; - gf_mx2d_apply_coords(mx, &_x, &_y); + Fixed _x, _y; + _x = pt->x; + _y = pt->y; + gf_mx2d_apply_coords(mx, &_x, &_y); #ifdef GPAC_FIXED_POINT - *x = UPSCALE(_x); - *y = UPSCALE(_y); + *x = UPSCALE(_x); + *y = UPSCALE(_y); #else - *x = (s32) (_x * ONE_PIXEL); - *y = (s32) (_y * ONE_PIXEL); + *x = (s32) (_x * ONE_PIXEL); + *y = (s32) (_y * ONE_PIXEL); #endif } #endif @@ -241,7 +241,7 @@ static void gray_render_scanline( TRaster *raster, TCoord ey, TPos x1, TCoord long p, first; long dx; int incr, lift, mod, rem; - + dx = x2 - x1; ex1 = TRUNC( x1 ); /* if (ex1 >= raster->max_ex) ex1 = raster->max_ex-1; */ ex2 = TRUNC( x2 ); /* if (ex2 >= raster->max_ex) ex2 = raster->max_ex-1; */ @@ -261,13 +261,13 @@ static void gray_render_scanline( TRaster *raster, TCoord ey, TPos x1, TCoord raster->cover += delta; return; } - + /* ok, we'll have to render a run of adjacent cells on the same */ /* scanline... */ p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 ); first = ONE_PIXEL; incr = 1; - + if ( dx < 0 ) { p = fx1 * ( y2 - y1 ); first = 0; @@ -302,7 +302,7 @@ static void gray_render_scanline( TRaster *raster, TCoord ey, TPos x1, TCoord mod += rem; if ( mod >= 0 ) { mod -= (TCoord)dx; - delta++; + delta++; } raster->area += (TArea)ONE_PIXEL * delta; @@ -455,7 +455,7 @@ End: } - + static int EVG_Outline_Decompose(EVG_Outline *outline, TRaster *user) { EVG_Vector v_start; @@ -508,14 +508,14 @@ static int EVG_Outline_Decompose(EVG_Outline *outline, TRaster *user) } - /* This is a non-recursive quicksort that directly process our cells */ - /* array. It should be faster than calling the stdlib qsort(), and we */ - /* can even tailor our insertion threshold... */ +/* This is a non-recursive quicksort that directly process our cells */ +/* array. It should be faster than calling the stdlib qsort(), and we */ +/* can even tailor our insertion threshold... */ #define QSORT_THRESHOLD 9 /* below this size, a sub-array will be sorted */ - /* through a normal insertion sort */ +/* through a normal insertion sort */ -static void gray_quick_sort( AACell *cells, int count ) +static void gray_quick_sort( AACell *cells, int count ) { AACell *stack[80]; /* should be enough ;-) */ AACell **top; /* top of stack */ @@ -549,8 +549,10 @@ static void gray_quick_sort( AACell *cells, int count ) for (;;) { int x = base->x; - do i++; while( i->x < x ); - do j--; while( x < j->x ); + do i++; + while( i->x < x ); + do j--; + while( x < j->x ); if ( i > j ) break; @@ -579,7 +581,7 @@ static void gray_quick_sort( AACell *cells, int count ) for ( ; i < limit; j = i, i++ ) { for ( ; j[1].x < j->x; j-- ) { SWAP_CELLS( j + 1, j, temp ); - if ( j == base ) + if ( j == base ) break; } } @@ -610,9 +612,9 @@ static void gray_hline( TRaster *raster, TCoord x, TCoord y, TPos area, int /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ /* */ coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); - /* use range 0..256 */ + /* use range 0..256 */ if ( coverage < 0 ) - coverage = -coverage; + coverage = -coverage; if (zero_non_zero_rule) { /* normal non-zero winding rule */ @@ -632,8 +634,8 @@ static void gray_hline( TRaster *raster, TCoord x, TCoord y, TPos area, int count = raster->num_gray_spans; span = raster->gray_spans + count - 1; if ( count > 0 && - (int)span->x + span->len == (int)x && - span->coverage == coverage ) + (int)span->x + span->len == (int)x && + span->coverage == coverage ) { span->len = (unsigned short)( span->len + acount ); return; @@ -680,7 +682,7 @@ static void gray_sweep_line( TRaster *raster, AAScanline *sl, int y, Bool zero_n area += cur->area; cover += cur->cover; } - + /* if the start cell has a non-null area, we must draw an */ /* individual gray pixel there */ if ( area && x >= 0 ) { @@ -719,19 +721,19 @@ int evg_raster_render(EVG_Raster raster, EVG_Raster_Params* params) #endif size_y = raster->max_ey - raster->min_ey; - if (raster->max_lines < size_y) { + if (raster->max_lines < size_y) { raster->scanlines = (AAScanline*)gf_realloc(raster->scanlines, sizeof(AAScanline)*size_y); memset(&raster->scanlines[raster->max_lines], 0, sizeof(AAScanline)*(size_y-raster->max_lines) ); raster->max_lines = size_y; } - + raster->ex = raster->max_ex+1; raster->ey = raster->max_ey+1; raster->cover = 0; raster->area = 0; EVG_Outline_Decompose(outline, raster); - gray_record_cell( raster ); - + gray_record_cell( raster ); + /*store odd/even rule*/ zero_non_zero_rule = (outline->flags & GF_PATH_FILL_ZERO_NONZERO) ? 1 : 0; @@ -771,7 +773,7 @@ void evg_raster_del(EVG_Raster raster) gf_free(raster->scanlines[i].cells); } gf_free(raster->scanlines); - gf_free(raster); + gf_free(raster); } /* END */ diff --git a/modules/soft_raster/rast_soft.h b/modules/soft_raster/rast_soft.h index 430d382..67aeb24 100644 --- a/modules/soft_raster/rast_soft.h +++ b/modules/soft_raster/rast_soft.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,17 +11,17 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * * - * */ @@ -54,7 +54,7 @@ typedef struct _evg_surface EVGSurface; GF_Matrix2D smat; \ GF_Rect frame; \ GF_ColorMatrix cmat; \ - + typedef struct _evg_base_stencil { EVGBASESTENCIL @@ -197,7 +197,7 @@ typedef struct u32 col[EVGGRADIENTSLOTS]; \ Fixed pos[EVGGRADIENTSLOTS]; \ u8 alpha; \ - + typedef struct { EVGBASESTENCIL @@ -209,7 +209,7 @@ typedef struct { EVGBASESTENCIL EVGGRADIENT - + GF_Point2D start, end; GF_Matrix2D vecmat; s32 curp; @@ -221,7 +221,7 @@ typedef struct { EVGBASESTENCIL EVGGRADIENT - + GF_Point2D center, focus, radius; /*drawing state vars*/ GF_Point2D cur_p, d_f, d_i; @@ -363,5 +363,5 @@ GF_Err evg_surface_clear_user(GF_SURFACE surf, GF_IRect rc, GF_Color col); } #endif -#endif +#endif diff --git a/modules/soft_raster/raster_565.c b/modules/soft_raster/raster_565.c index 77d5535..c927327 100644 --- a/modules/soft_raster/raster_565.c +++ b/modules/soft_raster/raster_565.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,17 +11,17 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * */ @@ -30,7 +30,7 @@ /* FIXME / WARNING - this code only works for little endian platfoms - not seen any big endian platform using RGB565/RGB555 output + not seen any big endian platform using RGB565/RGB555 output */ @@ -385,7 +385,7 @@ static void overmask_444_const_run(u32 src, u16 *dst, s32 dst_pitch_x, u32 count resg = mul255(srca, srcg - dstg) + dstg; resb = mul255(srca, srcb - dstb) + dstb; *dst = GF_COL_444(resr, resg, resb); - dst = (u16*) (((u8*)dst)+dst_pitch_x); + dst = (u16*) (((u8*)dst)+dst_pitch_x); count--; } } diff --git a/modules/soft_raster/raster_argb.c b/modules/soft_raster/raster_argb.c index 34834a5..115d7d9 100644 --- a/modules/soft_raster/raster_argb.c +++ b/modules/soft_raster/raster_argb.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,17 +11,17 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * * - * */ #include "rast_soft.h" @@ -109,7 +109,7 @@ void evg_bgra_fill_const(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) for (i=0; ipitch_x; len = spans[i].len; - + if (spans[i].coverage != 0xFF) { a = mul255(0xFF, spans[i].coverage); fin = (a<<24) | col_no_a; @@ -195,7 +195,7 @@ GF_Err evg_surface_clear_bgra(GF_SURFACE surf, GF_IRect rc, GF_Color col) w = rc.width; sx = rc.x; sy = rc.y; - + use_memset = 0; if (_this->pitch_x !=4) use_memset = 0; else if (!col_a) use_memset = 1; @@ -355,7 +355,7 @@ static void overmask_rgbx(u32 src, u8 *dst, u32 alpha) s32 srcr = (src >> 16) & 0xff; s32 srcg = (src >> 8) & 0xff; s32 srcb = (src >> 0) & 0xff; - + s32 dstr = dst[0]; s32 dstg = dst[1]; s32 dstb = dst[2]; @@ -514,7 +514,7 @@ GFINLINE static void overmask_rgba(u32 src, u8 *dst, u32 alpha) u8 dsta = dst[3]; srca = mul255(srca, alpha); - /*special case for RGBA: + /*special case for RGBA: if dst alpha is 0, consider the surface is empty and copy pixel if source alpha is 0xFF erase the entire pixel */ @@ -553,7 +553,7 @@ GFINLINE static void overmask_rgba_const_run(u32 src, u8 *dst, s32 dst_pitch_x, while (count) { u8 dsta = dst[3]; - /*special case for RGBA: + /*special case for RGBA: if dst alpha is 0, consider the surface is empty and copy pixel if source alpha is 0xFF erase the entire pixel */ @@ -601,7 +601,7 @@ void evg_rgba_fill_const(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) for (i=0; ipitch_x; len = spans[i].len; - + new_a = spans[i].coverage; fin = (new_a<<24) | col_no_a; //we must blend in all cases since we have to merge with the dst alpha @@ -660,13 +660,14 @@ void evg_rgba_fill_erase(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) for (i=0; ipitch_x; len = spans[i].len; - + if (spans[i].coverage != 0xFF) { -/* while (len--) { - *p = 0xFF-spans[i].coverage; - p += surf->pitch_x; - } -*/ } else { + /* while (len--) { + *p = 0xFF-spans[i].coverage; + p += surf->pitch_x; + } + */ + } else { while (len--) { *(u32 *)p = 0; p += surf->pitch_x; diff --git a/modules/soft_raster/raster_load.c b/modules/soft_raster/raster_load.c index 5dfdbd8..da73b94 100644 --- a/modules/soft_raster/raster_load.c +++ b/modules/soft_raster/raster_load.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,17 +11,17 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * * - * */ #include "rast_soft.h" @@ -75,13 +75,13 @@ void EVG_ShutdownRenderer(GF_Raster2D *dr) #ifndef GPAC_STANDALONE_RENDER_2D GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_RASTER_2D_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT diff --git a/modules/soft_raster/raster_rgb.c b/modules/soft_raster/raster_rgb.c index 9f2d404..4a76dc1 100644 --- a/modules/soft_raster/raster_rgb.c +++ b/modules/soft_raster/raster_rgb.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,18 +11,18 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * * * - * */ #include "rast_soft.h" @@ -91,7 +91,7 @@ void evg_rgb_fill_const(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) for (i=0; ipitch_x; - + if (spans[i].coverage != 0xFF) { a = mul255(0xFF, spans[i].coverage); fin = (a<<24) | col_no_a; @@ -243,7 +243,7 @@ void evg_bgr_fill_const(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) for (i=0; ipitch_x; - + if (spans[i].coverage != 0xFF) { a = mul255(0xFF, spans[i].coverage); fin = (a<<24) | col_no_a; @@ -349,7 +349,7 @@ void evg_user_fill_const(s32 y, s32 count, EVG_Span *spans, EVGSurface *surf) s32 i; col_no_a = surf->fill_col; - for (i=0; iraster_fill_run_alpha(surf->raster_cbk, spans[i].x, y, spans[i].len, col_no_a, a); diff --git a/modules/soft_raster/stencil.c b/modules/soft_raster/stencil.c index c629c24..abc430d 100644 --- a/modules/soft_raster/stencil.c +++ b/modules/soft_raster/stencil.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include "rast_soft.h" @@ -32,16 +32,16 @@ EVGStencil *evg_radial_gradient_brush(); -GF_Color color_interpolate(u32 a, u32 b, u8 pos) -{ +GF_Color color_interpolate(u32 a, u32 b, u8 pos) +{ u32 ca = ((a>>24) )*(u32)(0xFF-pos)+((b>>24) )*(u32)pos; u32 cr = ((a>>16)&0xFF)*(u32)(0xFF-pos)+((b>>16)&0xFF)*(u32)pos; u32 cg = ((a>> 8)&0xFF)*(u32)(0xFF-pos)+((b>> 8)&0xFF)*(u32)pos; u32 cb = ((a )&0xFF)*(u32)(0xFF-pos)+((b )&0xFF)*(u32)pos; return (((ca+(ca>>8)+1)>>8)<<24)| - (((cr+(cr>>8)+1)>>8)<<16)| - (((cg+(cg>>8)+1)>>8)<< 8)| - (((cb+(cb>>8)+1)>>8) ); + (((cr+(cr>>8)+1)>>8)<<16)| + (((cg+(cg>>8)+1)>>8)<< 8)| + (((cb+(cb>>8)+1)>>8) ); } @@ -63,11 +63,11 @@ static void gradient_update(EVG_BaseGradient *_this) if (_this->pos[0]>=0) { if(_this->pos[0]>0) { end = FIX2INT(gf_mulfix(_this->pos[0], maxPos)); - for (i=0; i<= end;i++) { + for (i=0; i<= end; i++) { _this->pre[i] = _this->col[0]; } } - for (c=0; cpos[c]<0) break; if (_this->pos[c+1]>=0) { start = FIX2INT(gf_mulfix(_this->pos[c], maxPos)); @@ -75,14 +75,14 @@ static void gradient_update(EVG_BaseGradient *_this) diff = end-start; if (diff) { - for (i=start;i<=end;i++) { + for (i=start; i<=end; i++) { _this->pre[i] = color_interpolate(_this->col[c], _this->col[c+1], - (u8) ( ( (i-start) * 255) / diff) ); + (u8) ( ( (i-start) * 255) / diff) ); } } } else { start = FIX2INT(gf_mulfix(_this->pos[c+0], maxPos)); - for(i=start;i<=EVGGRADIENTMAXINTPOS;i++) { + for(i=start; i<=EVGGRADIENTMAXINTPOS; i++) { _this->pre[i] = _this->col[c]; } } @@ -90,7 +90,7 @@ static void gradient_update(EVG_BaseGradient *_this) } } -static u32 gradient_get_color(EVG_BaseGradient *_this, s32 pos) +static u32 gradient_get_color(EVG_BaseGradient *_this, s32 pos) { s32 max_pos = 1 << EVGGRADIENTBITS; @@ -179,7 +179,7 @@ void evg_stencil_delete(GF_STENCIL st) if (tx->owns_texture && tx->pixels) gf_free(tx->pixels); gf_free(_this); } - return; + return; } } @@ -224,7 +224,7 @@ GF_Err evg_stencil_set_brush_color(GF_STENCIL st, GF_Color c) linear gradient stencil */ -static void lgb_fill_run(EVGStencil *p, EVGSurface *surf, s32 x, s32 y, u32 count) +static void lgb_fill_run(EVGStencil *p, EVGSurface *surf, s32 x, s32 y, u32 count) { Bool has_cmat, has_a; Fixed _res; @@ -246,7 +246,7 @@ static void lgb_fill_run(EVGStencil *p, EVGSurface *surf, s32 x, s32 y, u32 coun if (has_a) { ca = ((GF_COL_A(col) + 1) * _this->alpha) >> 8; col = ( ((ca<<24) & 0xFF000000) ) | (col & 0x00FFFFFF); - } + } if (has_cmat) col = gf_cmx_apply(&p->cmat, col); *data++ = col; count--; @@ -306,7 +306,7 @@ EVGStencil *evg_linear_gradient_brush() radial gradient stencil */ -static void rg_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) +static void rg_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) { Fixed x, y, dx, dy, b, val; Bool has_cmat, has_a; @@ -334,8 +334,8 @@ static void rg_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 cou if (has_a) { ca = ((GF_COL_A(col) + 1) * _this->alpha) >> 8; col = ( ((ca<<24) & 0xFF000000) ) | (col & 0x00FFFFFF); - } - if (has_cmat) col = gf_cmx_apply(&p->cmat, col); + } + if (has_cmat) col = gf_cmx_apply(&p->cmat, col); *data++ = col; dx += _this->d_i.x; @@ -344,7 +344,7 @@ static void rg_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 cou } } -void evg_radial_init(EVG_RadialGradient *_this) +void evg_radial_init(EVG_RadialGradient *_this) { GF_Point2D p0, p1; p0.x = p0.y = p1.y = 0; @@ -499,7 +499,7 @@ static void bmp_untransform_coord(EVG_Texture *_this, s32 _x, s32 _y, Fixed *out *outy=y; } -static void bmp_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) +static void bmp_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) { s32 cx, x0, y0; u32 pix, replace_col; @@ -518,12 +518,12 @@ static void bmp_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 co incy = (_this->inc_y>0) ? 1 : -1; #endif - _fd = INT2FIX(_this->width); + _fd = INT2FIX(_this->width); repeat_s = _this->mod & GF_TEXTURE_REPEAT_S; if (!repeat_s && (x < - _fd)) x = 0; while (x<0) x += _fd; - _fd = INT2FIX(_this->height); + _fd = INT2FIX(_this->height); repeat_t = _this->mod & GF_TEXTURE_REPEAT_T; if (!repeat_t && (y < - _fd)) y = 0; while (y<0) y += _fd; @@ -542,7 +542,7 @@ static void bmp_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 co } else { x0 = MIN(x0, (s32) _this->width - 1); } - + y0 = FIX2INT(y); assert((s32)y0 >=0); if (repeat_t) { @@ -624,7 +624,7 @@ static void bmp_fill_run(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 co /*just a little faster...*/ -static void bmp_fill_run_straight(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) +static void bmp_fill_run_straight(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _y, u32 count) { s32 x0, y0; u32 pix; @@ -683,7 +683,7 @@ static void bmp_fill_run_straight(EVGStencil *p, EVGSurface *surf, s32 _x, s32 _ } } -void evg_bmp_init(EVGStencil *p) +void evg_bmp_init(EVGStencil *p) { GF_Point2D p0, p1; EVG_Texture *_this = (EVG_Texture *) p; @@ -698,10 +698,10 @@ void evg_bmp_init(EVGStencil *p) _this->replace_col = 0; _this->cmat_is_replace = 0; if (!_this->cmat.identity - && !_this->cmat.m[0] && !_this->cmat.m[1] && !_this->cmat.m[2] && !_this->cmat.m[3] - && !_this->cmat.m[5] && !_this->cmat.m[6] && !_this->cmat.m[7] && !_this->cmat.m[8] - && !_this->cmat.m[10] && !_this->cmat.m[11] && !_this->cmat.m[12] && !_this->cmat.m[13] - && !_this->cmat.m[15] && !_this->cmat.m[16] && !_this->cmat.m[17] && !_this->cmat.m[19]) { + && !_this->cmat.m[0] && !_this->cmat.m[1] && !_this->cmat.m[2] && !_this->cmat.m[3] + && !_this->cmat.m[5] && !_this->cmat.m[6] && !_this->cmat.m[7] && !_this->cmat.m[8] + && !_this->cmat.m[10] && !_this->cmat.m[11] && !_this->cmat.m[12] && !_this->cmat.m[13] + && !_this->cmat.m[15] && !_this->cmat.m[16] && !_this->cmat.m[17] && !_this->cmat.m[19]) { _this->cmat_is_replace = 1; _this->replace_col = GF_COL_ARGB(FIX2INT(_this->cmat.m[18]*255), FIX2INT(_this->cmat.m[4]*255), FIX2INT(_this->cmat.m[9]*255), FIX2INT(_this->cmat.m[14]*255)); } @@ -731,16 +731,40 @@ EVGStencil *evg_texture_brush() } -u32 get_pix_argb(char *pix) { return GF_COL_ARGB(*(pix+3) & 0xFF, *(pix+2) & 0xFF, *(pix+1) & 0xFF, *pix & 0xFF); } -u32 get_pix_rgba(char *pix) { return GF_COL_ARGB(*(pix+3) & 0xFF, *pix & 0xFF, *(pix+1) & 0xFF, *(pix+2) & 0xFF); } -u32 get_pix_rgb_32(char *pix) { return GF_COL_ARGB(0xFF, *(pix+2) & 0xFF, *(pix+1) & 0xFF, *pix & 0xFF); } -u32 get_pix_rgb_24(char *pix) { return GF_COL_ARGB(0xFF, *pix & 0xFF, *(pix+1) & 0xFF, *(pix+2) & 0xFF); } -u32 get_pix_bgr_24(char *pix) { return GF_COL_ARGB(0xFF, *(pix+2) & 0xFF, * (pix+1) & 0xFF, *pix & 0xFF); } -u32 get_pix_444(char *pix) { u16 val = *(u16*)pix; return GF_COL_ARGB(0xFF, (u8) ( (val >> 4) & 0xf0), (u8) ( (val) & 0xf0), (u8) ( (val << 4) & 0xf0) ); } -u32 get_pix_555(char *pix) { u16 val = *(u16*)pix; return GF_COL_ARGB(0xFF, (u8) ( (val >> 7) & 0xf8), (u8) ( (val >> 2) & 0xf8), (u8) ( (val << 3) & 0xf8) ); } -u32 get_pix_565(char *pix) { u16 val = *(u16*)pix; return GF_COL_ARGB(0xFF, (u8) ( (val >> 8) & 0xf8), (u8) ( (val >> 3) & 0xfc), (u8) ( (val << 3) & 0xf8) ); } -u32 get_pix_grey(char *pix) { u8 val = *pix; return GF_COL_ARGB(0xFF, val, val, val); } -u32 get_pix_alphagrey(char *pix) { return GF_COL_ARGB((u8) *(pix+1), (u8) *pix, (u8) *pix, (u8) *pix); } +u32 get_pix_argb(char *pix) { + return GF_COL_ARGB(*(pix+3) & 0xFF, *(pix+2) & 0xFF, *(pix+1) & 0xFF, *pix & 0xFF); +} +u32 get_pix_rgba(char *pix) { + return GF_COL_ARGB(*(pix+3) & 0xFF, *pix & 0xFF, *(pix+1) & 0xFF, *(pix+2) & 0xFF); +} +u32 get_pix_rgb_32(char *pix) { + return GF_COL_ARGB(0xFF, *(pix+2) & 0xFF, *(pix+1) & 0xFF, *pix & 0xFF); +} +u32 get_pix_rgb_24(char *pix) { + return GF_COL_ARGB(0xFF, *pix & 0xFF, *(pix+1) & 0xFF, *(pix+2) & 0xFF); +} +u32 get_pix_bgr_24(char *pix) { + return GF_COL_ARGB(0xFF, *(pix+2) & 0xFF, * (pix+1) & 0xFF, *pix & 0xFF); +} +u32 get_pix_444(char *pix) { + u16 val = *(u16*)pix; + return GF_COL_ARGB(0xFF, (u8) ( (val >> 4) & 0xf0), (u8) ( (val) & 0xf0), (u8) ( (val << 4) & 0xf0) ); +} +u32 get_pix_555(char *pix) { + u16 val = *(u16*)pix; + return GF_COL_ARGB(0xFF, (u8) ( (val >> 7) & 0xf8), (u8) ( (val >> 2) & 0xf8), (u8) ( (val << 3) & 0xf8) ); +} +u32 get_pix_565(char *pix) { + u16 val = *(u16*)pix; + return GF_COL_ARGB(0xFF, (u8) ( (val >> 8) & 0xf8), (u8) ( (val >> 3) & 0xfc), (u8) ( (val << 3) & 0xf8) ); +} +u32 get_pix_grey(char *pix) { + u8 val = *pix; + return GF_COL_ARGB(0xFF, val, val, val); +} +u32 get_pix_alphagrey(char *pix) { + return GF_COL_ARGB((u8) *(pix+1), (u8) *pix, (u8) *pix, (u8) *pix); +} static void texture_set_callback(EVG_Texture *_this) { diff --git a/modules/soft_raster/surface.c b/modules/soft_raster/surface.c index 55be661..ed1e57b 100644 --- a/modules/soft_raster/surface.c +++ b/modules/soft_raster/surface.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * */ @@ -54,7 +54,7 @@ void evg_surface_delete(GF_SURFACE _this) { EVGSurface *surf = (EVGSurface *)_this; if (!surf) - return; + return; #ifndef INLINE_POINT_CONVERSION if (surf->points) gf_free(surf->points); surf->points = NULL; @@ -216,7 +216,7 @@ GF_Err evg_surface_clear(GF_SURFACE _this, GF_IRect *rc, u32 color) EVGSurface *surf = (EVGSurface *)_this; if (!surf) return GF_BAD_PARAM; - if (rc) { + if (rc) { s32 _x, _y; if (surf->center_coords) { _x = rc->x + surf->width / 2; @@ -247,7 +247,7 @@ GF_Err evg_surface_clear(GF_SURFACE _this, GF_IRect *rc, u32 color) clear.width = surf->width; clear.height = surf->height; } - + if (surf->raster_cbk) { surf->raster_fill_rectangle(surf->raster_cbk, clear.x, clear.y, clear.width, clear.height, color); return GF_OK; @@ -350,7 +350,7 @@ static Bool setup_grey_callback(EVGSurface *surf) col = a = 0; use_const = 0; } - + if (surf->raster_cbk) { if (use_const) { if (!a) return 0; @@ -534,7 +534,7 @@ GF_Err evg_surface_set_path(GF_SURFACE _this, GF_Path *gp) surf->pointlen = gp->n_points; } surf->ftoutline.points = surf->points; - + for (i=0; in_points; i++) { pt = gp->points[i]; gf_mx2d_apply_point(&surf->mat, &pt); @@ -567,7 +567,7 @@ GF_Err evg_surface_fill(GF_SURFACE _this, GF_STENCIL stencil) /*setup ft raster calllbacks*/ if (!setup_grey_callback(surf)) return GF_OK; -/* surf->ftparams.gray_spans = gray_spans_stub; */ + /* surf->ftparams.gray_spans = gray_spans_stub; */ get_surface_world_matrix(surf, &mat); @@ -615,7 +615,7 @@ GF_Err evg_surface_fill(GF_SURFACE _this, GF_STENCIL stencil) gf_mx2d_add_scale(&sten->smat, INT2FIX(1<privateStack; @@ -188,43 +188,43 @@ static GF_Err SVG_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 i /*!OTI for DIMS (dsi = 3GPP DIMS configuration) - GPAC internal*/ case GPAC_OTI_SCENE_DIMS: - { - u8 prev, dims_hdr; - u32 nb_bytes, size; - u64 pos; - char * buf2 = gf_malloc(inBufferLength); - GF_BitStream *bs = gf_bs_new(inBuffer, inBufferLength, GF_BITSTREAM_READ); - memcpy(buf2, inBuffer, inBufferLength); + { + u8 prev, dims_hdr; + u32 nb_bytes, size; + u64 pos; + char * buf2 = gf_malloc(inBufferLength); + GF_BitStream *bs = gf_bs_new(inBuffer, inBufferLength, GF_BITSTREAM_READ); + memcpy(buf2, inBuffer, inBufferLength); // FILE *f = gf_f64_open("dump.svg", "wb"); // - while (gf_bs_available(bs)) { - pos = gf_bs_get_position(bs); - size = gf_bs_read_u16(bs); - nb_bytes = 2; - /*GPAC internal hack*/ - if (!size) { - size = gf_bs_read_u32(bs); - nb_bytes = 6; - } + while (gf_bs_available(bs)) { + pos = gf_bs_get_position(bs); + size = gf_bs_read_u16(bs); + nb_bytes = 2; + /*GPAC internal hack*/ + if (!size) { + size = gf_bs_read_u32(bs); + nb_bytes = 6; + } // gf_fwrite( inBuffer + pos + nb_bytes + 1, 1, size - 1, f ); - dims_hdr = gf_bs_read_u8(bs); - prev = buf2[pos + nb_bytes + size]; - - buf2[pos + nb_bytes + size] = 0; - if (dims_hdr & GF_DIMS_UNIT_C) { - e = svgin_deflate(svgin, buf2 + pos + nb_bytes + 1, size - 1); - } else { - e = gf_sm_load_string(&svgin->loader, buf2 + pos + nb_bytes + 1, 0); - } - buf2[pos + nb_bytes + size] = prev; - gf_bs_skip_bytes(bs, size-1); + dims_hdr = gf_bs_read_u8(bs); + prev = buf2[pos + nb_bytes + size]; + buf2[pos + nb_bytes + size] = 0; + if (dims_hdr & GF_DIMS_UNIT_C) { + e = svgin_deflate(svgin, buf2 + pos + nb_bytes + 1, size - 1); + } else { + e = gf_sm_load_string(&svgin->loader, buf2 + pos + nb_bytes + 1, 0); } -// fclose(f); - gf_bs_del(bs); + buf2[pos + nb_bytes + size] = prev; + gf_bs_skip_bytes(bs, size-1); + } - break; +// fclose(f); + gf_bs_del(bs); + } + break; default: return GF_BAD_PARAM; @@ -344,7 +344,7 @@ static u32 SVG_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *esd if (StreamType==GF_STREAM_PRIVATE_SCENE) { /*media type query*/ if (!esd) return GF_CODEC_STREAM_TYPE_SUPPORTED; - + if (esd->decoderConfig->objectTypeIndication == GPAC_OTI_PRIVATE_SCENE_SVG) return GF_CODEC_SUPPORTED; return GF_CODEC_NOT_SUPPORTED; } else if (StreamType==GF_STREAM_SCENE) { @@ -356,7 +356,7 @@ static u32 SVG_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *esd case GPAC_OTI_SCENE_SVG_GZ: case GPAC_OTI_SCENE_DIMS: return GF_CODEC_SUPPORTED; - default: + default: return GF_CODEC_NOT_SUPPORTED; } } @@ -415,14 +415,14 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { SVGIn *svgin; - GF_SceneDecoder *sdec = (GF_SceneDecoder *)ifce; - if (!sdec) - return; + GF_SceneDecoder *sdec = (GF_SceneDecoder *)ifce; + if (!sdec) + return; if (sdec->InterfaceType != GF_SCENE_DECODER_INTERFACE) return; - svgin = (SVGIn *) sdec->privateStack; - if (svgin) - gf_free(svgin); - sdec->privateStack = NULL; + svgin = (SVGIn *) sdec->privateStack; + if (svgin) + gf_free(svgin); + sdec->privateStack = NULL; gf_free(sdec); } diff --git a/modules/timedtext/timedtext_dec.c b/modules/timedtext/timedtext_dec.c index dc1e592..54f83fe 100644 --- a/modules/timedtext/timedtext_dec.c +++ b/modules/timedtext/timedtext_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -124,8 +124,10 @@ static void TTD_UpdateSizeInfo(TTDPriv *priv) if offsets are negative: since MPEG-4 uses centered coord system, we must assume video is aligned to top-left*/ if (priv->cfg->has_vid_info) { Bool set_size = 0; - vw = priv->cfg->horiz_offset; if (vw<0) vw = 0; - vh = priv->cfg->vert_offset; if (vh<0) vh = 0; + vw = priv->cfg->horiz_offset; + if (vw<0) vw = 0; + vh = priv->cfg->vert_offset; + if (vh<0) vh = 0; if (priv->cfg->text_width + (u32) vw > w) { w = priv->cfg->text_width+vw; set_size = 1; @@ -412,7 +414,7 @@ static void ttd_set_scroll_fraction(GF_Node *node, GF_Route *route) priv->tr_scroll->translation.y = gf_muldiv(priv->dlist->size.y, frac, priv->scroll_time); } } - if (priv->scroll_type - 1 == GF_TXT_SCROLL_DOWN) priv->tr_scroll->translation.y *= -1; + if (priv->scroll_type - 1 == GF_TXT_SCROLL_DOWN) priv->tr_scroll->translation.y *= -1; break; case GF_TXT_SCROLL_MARQUEE: case GF_TXT_SCROLL_RIGHT: @@ -960,19 +962,26 @@ static void TTD_ApplySample(TTDPriv *priv, GF_TextSample *txt, u32 sdi, Bool is_ /*only one item in line, no need for alignment, but still add a group (we could use the item as a group but that would complicate the alignment generation)*/ if (start_idx==i-1) { - gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = idx.vals[start_idx]; - gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = idx.vals[start_idx]; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; } else { /*spread horizontal 0 pixels (eg align) all items in line*/ - gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); s->buffer = gf_strdup(vertical ? "SV 0" : "SH 0"); + gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); + s->buffer = gf_strdup(vertical ? "SV 0" : "SH 0"); for (j=start_idx; jgroupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = idx.vals[j]; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = idx.vals[j]; /*also add a group for the line, for final justif*/ - gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = idx.vals[j]; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = idx.vals[j]; } - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; /*mark end of group*/ - gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; } start_idx = i+1; nb_lines ++; @@ -986,56 +995,92 @@ static void TTD_ApplySample(TTDPriv *priv, GF_TextSample *txt, u32 sdi, Bool is_ gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); if (vertical) { switch (td->vert_justif) { - case 1: s->buffer = gf_strdup("AV"); break;/*center*/ - case -1: s->buffer = gf_strdup("AB"); break;/*bottom*/ - default: s->buffer = gf_strdup("AT"); break;/*top*/ + case 1: + s->buffer = gf_strdup("AV"); + break;/*center*/ + case -1: + s->buffer = gf_strdup("AB"); + break;/*bottom*/ + default: + s->buffer = gf_strdup("AT"); + break;/*top*/ } } else { switch (td->horiz_justif) { - case 1: s->buffer = gf_strdup("AH"); break;/*center*/ - case -1: s->buffer = gf_strdup("AR"); break;/*right*/ - default: s->buffer = gf_strdup("AL"); break;/*left*/ + case 1: + s->buffer = gf_strdup("AH"); + break;/*center*/ + case -1: + s->buffer = gf_strdup("AR"); + break;/*right*/ + default: + s->buffer = gf_strdup("AL"); + break;/*left*/ } } - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = 0; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = 0; for (i=0; igroupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = i+start_idx; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = i+start_idx; } - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; /*vertical alignment: first align all items vertically, 0 pixel */ - gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); s->buffer = gf_strdup(vertical ? "SH 0" : "SV 0"); - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = 0; + gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); + s->buffer = gf_strdup(vertical ? "SH 0" : "SV 0"); + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = 0; for (i=0; igroupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = i+start_idx; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = i+start_idx; } - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; /*define a group with every item drawn*/ count = gf_node_list_get_count(form->children); for (i=0; igroups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = i+1; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = i+1; } - gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groups, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; gf_sg_vrml_mf_append(&form->constraints, GF_SG_VRML_MFSTRING, (void **) &s); if (vertical) { switch (td->horiz_justif) { - case 1: s->buffer = gf_strdup("AH"); break;/*center*/ - case -1: s->buffer = gf_strdup("AR"); break;/*right*/ - default: s->buffer = gf_strdup("AL"); break;/*left*/ + case 1: + s->buffer = gf_strdup("AH"); + break;/*center*/ + case -1: + s->buffer = gf_strdup("AR"); + break;/*right*/ + default: + s->buffer = gf_strdup("AL"); + break;/*left*/ } } else { switch (td->vert_justif) { - case 1: s->buffer = gf_strdup("AV"); break;/*center*/ - case -1: s->buffer = gf_strdup("AB"); break;/*bottom*/ - default: s->buffer = gf_strdup("AT"); break;/*top*/ + case 1: + s->buffer = gf_strdup("AV"); + break;/*center*/ + case -1: + s->buffer = gf_strdup("AB"); + break;/*bottom*/ + default: + s->buffer = gf_strdup("AT"); + break;/*top*/ } } - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = 0; - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = start_idx + nb_lines; - gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); (*id) = -1; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = 0; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = start_idx + nb_lines; + gf_sg_vrml_mf_append(&form->groupsIndex, GF_SG_VRML_MFINT32, (void **) &id); + (*id) = -1; gf_node_dirty_set((GF_Node *)form, 0, 1); @@ -1059,7 +1104,7 @@ static void TTD_ApplySample(TTDPriv *priv, GF_TextSample *txt, u32 sdi, Bool is_ } static GF_Err TTD_ProcessData(GF_SceneDecoder*plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_time, u32 mmlevel) + u16 ES_ID, u32 AU_time, u32 mmlevel) { GF_BitStream *bs; GF_Err e = GF_OK; @@ -1148,11 +1193,14 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_SCENE_DECODER_INTERFACE: return (GF_BaseInterface *)NewTimedTextDec(); + case GF_SCENE_DECODER_INTERFACE: + return (GF_BaseInterface *)NewTimedTextDec(); #if !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_MEDIA_IMPORT) - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *)NewTTReader(); + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *)NewTTReader(); #endif - default: return NULL; + default: + return NULL; } } @@ -1174,7 +1222,9 @@ void ShutdownInterface(GF_BaseInterface *ifce) #else GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) { return NULL; } +GF_BaseInterface *LoadInterface(u32 InterfaceType) { + return NULL; +} GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) {} diff --git a/modules/timedtext/timedtext_in.c b/modules/timedtext/timedtext_in.c index ca32829..cfc1067 100644 --- a/modules/timedtext/timedtext_in.c +++ b/modules/timedtext/timedtext_in.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -54,40 +54,40 @@ typedef struct const char * TTIN_MIME_TYPES[] = { - "x-subtitle/srt", "srt", "SRT SubTitles", - "x-subtitle/sub", "sub", "SUB SubTitles", - "x-subtitle/ttxt", "ttxt", "3GPP TimedText", - NULL + "x-subtitle/srt", "srt", "SRT SubTitles", + "x-subtitle/sub", "sub", "SUB SubTitles", + "x-subtitle/ttxt", "ttxt", "3GPP TimedText", + NULL }; -static u32 TTIN_RegisterMimeTypes(const GF_InputService *plug){ - u32 i; - if (!plug) - return 0; - for (i = 0 ; TTIN_MIME_TYPES[i]; i+=3){ - gf_term_register_mime_type(plug, TTIN_MIME_TYPES[i], TTIN_MIME_TYPES[i+1], TTIN_MIME_TYPES[i+2]); - } - return i/3; +static u32 TTIN_RegisterMimeTypes(const GF_InputService *plug) { + u32 i; + if (!plug) + return 0; + for (i = 0 ; TTIN_MIME_TYPES[i]; i+=3) { + gf_service_register_mime(plug, TTIN_MIME_TYPES[i], TTIN_MIME_TYPES[i+1], TTIN_MIME_TYPES[i+2]); + } + return i/3; } static Bool TTIn_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; u32 i; - if (!plug || !url) - return 0; + if (!plug || !url) + return 0; sExt = strrchr(url, '.'); if (!sExt) return 0; - for (i = 0 ; TTIN_MIME_TYPES[i]; i+=3){ - if (gf_term_check_extension(plug, TTIN_MIME_TYPES[i], TTIN_MIME_TYPES[i+1], TTIN_MIME_TYPES[i+2], sExt)) return 1; + for (i = 0 ; TTIN_MIME_TYPES[i]; i+=3) { + if (gf_service_check_mime_register(plug, TTIN_MIME_TYPES[i], TTIN_MIME_TYPES[i+1], TTIN_MIME_TYPES[i+2], sExt)) return 1; } return 0; } static Bool TTIn_is_local(const char *url) { - if (!url) - return 0; + if (!url) + return 0; if (!strnicmp(url, "file://", 7)) return 1; if (strstr(url, "://")) return 0; return 1; @@ -104,7 +104,7 @@ static void tti_setup_object(TTIn *tti) GF_ESD *esd = tti_get_esd(tti); od->objectDescriptorID = esd->ESID; gf_list_add(od->ESDescriptors, esd); - gf_term_add_media(tti->service, (GF_Descriptor *)od, 0); + gf_service_declare_media(tti->service, (GF_Descriptor *)od, 0); } @@ -115,9 +115,9 @@ GF_Err TTIn_LoadFile(GF_InputService *plug, const char *url, Bool is_cache) char szFILE[GF_MAX_PATH]; TTIn *tti = (TTIn *)plug->priv; const char *cache_dir; - if (!tti || !url) - return GF_BAD_PARAM; - cache_dir = gf_modules_get_option((GF_BaseInterface *)plug, "General", "CacheDirectory"); + if (!tti || !url) + return GF_BAD_PARAM; + cache_dir = gf_modules_get_option((GF_BaseInterface *)plug, "General", "CacheDirectory"); if (cache_dir && strlen(cache_dir)) { if (cache_dir[strlen(cache_dir)-1] != GF_PATH_SEPARATOR) { sprintf(szFILE, "%s%csrt_%p_mp4", cache_dir, GF_PATH_SEPARATOR, tti); @@ -129,8 +129,8 @@ GF_Err TTIn_LoadFile(GF_InputService *plug, const char *url, Bool is_cache) } tti->mp4 = gf_isom_open(szFILE, GF_ISOM_OPEN_WRITE, NULL); if (!tti->mp4) return gf_isom_last_error(NULL); - if (tti->szFile) - gf_free(tti->szFile); + if (tti->szFile) + gf_free(tti->szFile); tti->szFile = gf_strdup(szFILE); memset(&import, 0, sizeof(GF_MediaImporter)); @@ -145,7 +145,7 @@ GF_Err TTIn_LoadFile(GF_InputService *plug, const char *url, Bool is_cache) gf_isom_text_set_streaming_mode(tti->mp4, 1); } if (import.in_name) - gf_free(import.in_name); + gf_free(import.in_name); return e; } @@ -155,9 +155,9 @@ void TTIn_NetIO(void *cbk, GF_NETIO_Parameter *param) const char *szCache; GF_InputService *plug = (GF_InputService *)cbk; TTIn *tti = (TTIn *) plug->priv; - if (!tti) - return; - gf_term_download_update_stats(tti->dnload); + if (!tti) + return; + gf_service_download_update_stats(tti->dnload); e = param->error; /*done*/ @@ -174,7 +174,7 @@ void TTIn_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (tti->needs_connection) { tti->needs_connection = 0; - gf_term_on_connect(tti->service, NULL, e); + gf_service_connect_ack(tti->service, NULL, e); if (!e && !tti->od_done) tti_setup_object(tti); } } @@ -182,13 +182,13 @@ void TTIn_NetIO(void *cbk, GF_NETIO_Parameter *param) void TTIn_download_file(GF_InputService *plug, const char *url) { TTIn *tti = (TTIn *) plug->priv; - if (!plug || !url) - return; + if (!plug || !url) + return; tti->needs_connection = 1; - tti->dnload = gf_term_download_new(tti->service, url, 0, TTIn_NetIO, plug); + tti->dnload = gf_service_download_new(tti->service, url, 0, TTIn_NetIO, plug); if (!tti->dnload) { tti->needs_connection = 0; - gf_term_on_connect(tti->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(tti->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(tti->dnload); @@ -200,11 +200,11 @@ static GF_Err TTIn_ConnectService(GF_InputService *plug, GF_ClientService *serv, { GF_Err e; TTIn *tti = (TTIn *)plug->priv; - if (!plug || !url) - return GF_BAD_PARAM; + if (!plug || !url) + return GF_BAD_PARAM; tti->service = serv; - if (tti->dnload) gf_term_download_del(tti->dnload); + if (tti->dnload) gf_service_download_del(tti->dnload); tti->dnload = NULL; /*remote fetch*/ @@ -213,7 +213,7 @@ static GF_Err TTIn_ConnectService(GF_InputService *plug, GF_ClientService *serv, return GF_OK; } e = TTIn_LoadFile(plug, url, 0); - gf_term_on_connect(serv, NULL, e); + gf_service_connect_ack(serv, NULL, e); if (!e && !tti->od_done) tti_setup_object(tti); return GF_OK; } @@ -221,16 +221,16 @@ static GF_Err TTIn_ConnectService(GF_InputService *plug, GF_ClientService *serv, static GF_Err TTIn_CloseService(GF_InputService *plug) { TTIn *tti; - if (!plug) - return GF_BAD_PARAM; - tti = (TTIn *)plug->priv; - if (!tti) - return GF_BAD_PARAM; + if (!plug) + return GF_BAD_PARAM; + tti = (TTIn *)plug->priv; + if (!tti) + return GF_BAD_PARAM; if (tti->samp) - gf_isom_sample_del(&tti->samp); - tti->samp = NULL; + gf_isom_sample_del(&tti->samp); + tti->samp = NULL; if (tti->mp4) - gf_isom_delete(tti->mp4); + gf_isom_delete(tti->mp4); tti->mp4 = NULL; if (tti->szFile) { gf_delete_file(tti->szFile); @@ -238,22 +238,22 @@ static GF_Err TTIn_CloseService(GF_InputService *plug) tti->szFile = NULL; } if (tti->dnload) - gf_term_download_del(tti->dnload); + gf_service_download_del(tti->dnload); tti->dnload = NULL; - if (tti->service) - gf_term_on_disconnect(tti->service, NULL, GF_OK); - tti->service = NULL; + if (tti->service) + gf_service_disconnect_ack(tti->service, NULL, GF_OK); + tti->service = NULL; return GF_OK; } static GF_Descriptor *TTIn_GetServiceDesc(GF_InputService *plug, u32 expect_type, const char *sub_url) { TTIn *tti; - if (!plug) - return NULL; - tti = (TTIn *)plug->priv; - if (!tti) - return NULL; + if (!plug) + return NULL; + tti = (TTIn *)plug->priv; + if (!tti) + return NULL; /*visual object*/ switch (expect_type) { case GF_MEDIA_OBJECT_UNDEF: @@ -278,8 +278,8 @@ static GF_Err TTIn_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, c u32 ES_ID; GF_Err e; TTIn *tti = (TTIn *)plug->priv; - if (!tti) - return GF_BAD_PARAM; + if (!tti) + return GF_BAD_PARAM; e = GF_SERVICE_ERROR; if (!tti || tti->ch==channel) goto exit; @@ -293,7 +293,7 @@ static GF_Err TTIn_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, c } exit: - gf_term_on_connect(tti->service, channel, e); + gf_service_connect_ack(tti->service, channel, e); return e; } @@ -306,15 +306,15 @@ static GF_Err TTIn_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel tti->ch = NULL; e = GF_OK; } - gf_term_on_disconnect(tti->service, channel, e); + gf_service_disconnect_ack(tti->service, channel, e); return GF_OK; } static GF_Err TTIn_ServiceCommand(GF_InputService *plug, GF_NetworkCommand *com) { TTIn *tti = (TTIn *)plug->priv; - if (!tti) - return GF_BAD_PARAM; + if (!tti) + return GF_BAD_PARAM; if (!com->base.on_channel) return GF_NOT_SUPPORTED; switch (com->command_type) { case GF_NET_CHAN_SET_PADDING: @@ -425,15 +425,15 @@ void *NewTTReader() void DeleteTTReader(void *ifce) { TTIn *tti; - GF_InputService *plug = (GF_InputService *) ifce; - if (!plug) - return; - tti = (TTIn *)plug->priv; - if (tti){ - TTIn_CloseService(plug); - gf_free(tti); - } - plug->priv = NULL; + GF_InputService *plug = (GF_InputService *) ifce; + if (!plug) + return; + tti = (TTIn *)plug->priv; + if (tti) { + TTIn_CloseService(plug); + gf_free(tti); + } + plug->priv = NULL; gf_free(plug); } diff --git a/modules/ui_rec/ui_rec.c b/modules/ui_rec/ui_rec.c index 3ab5237..8df04bd 100644 --- a/modules/ui_rec/ui_rec.c +++ b/modules/ui_rec/ui_rec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2007-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -63,10 +63,10 @@ Bool uir_on_event_record(GF_UIRecord *uir , GF_Event *event, Bool consumed_by_co uir->ck = uir->term->root_scene->scene_codec ? uir->term->root_scene->scene_codec->ck : uir->term->root_scene->dyn_ck; } break; - case GF_EVENT_CLICK: + case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: + case GF_EVENT_MOUSEDOWN: + case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: /*!! ALL MOUSE EVENTS SHALL BE DECLARED BEFORE MOUSEMOVE !! */ case GF_EVENT_MOUSEMOVE: @@ -110,10 +110,10 @@ void uir_load_event(GF_UIRecord *uir) uir->next_time = gf_bs_read_u32(uir->bs); uir->next_event.type = gf_bs_read_u8(uir->bs); switch (uir->next_event.type) { - case GF_EVENT_CLICK: + case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: + case GF_EVENT_MOUSEDOWN: + case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: /*!! ALL MOUSE EVENTS SHALL BE DECLARED BEFORE MOUSEMOVE !! */ case GF_EVENT_MOUSEMOVE: @@ -223,17 +223,17 @@ void uir_delete(GF_BaseInterface *ifce) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_TERM_EXT_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_TERM_EXT_INTERFACE) return (GF_BaseInterface *)uir_new(); return NULL; diff --git a/modules/validator/validator.c b/modules/validator/validator.c index 51c706b..9dab44c 100644 --- a/modules/validator/validator.c +++ b/modules/validator/validator.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,45 +32,45 @@ typedef struct __validation_module { - GF_Terminal *term; + GF_Terminal *term; - Bool is_recording; - char *prev_fps; - char *prev_alias; + Bool is_recording; + char *prev_fps; + char *prev_alias; - /* Clock used to synchronize events in recording and playback*/ + /* Clock used to synchronize events in recording and playback*/ GF_Clock *ck; - /* Next event to process */ - Bool next_event_snapshot; + /* Next event to process */ + Bool next_event_snapshot; GF_Event next_event; - u32 xvs_event_index; + u32 xvs_event_index; u32 next_time; Bool evt_loaded; - GF_VideoListener video_listener; - - /* XML Validation List (the list of files to be tested) */ - char *xvl_filename; - GF_DOMParser *xvl_parser; - GF_XMLNode *xvl_node; - GF_XMLNode *xvs_node_in_xvl; - u32 xvl_node_index; - - /* Pointer to the current validation script file being tested */ - char *xvs_filename; - GF_DOMParser *xvs_parser; - GF_XMLNode *xvs_node; - Bool xvs_result; - - /* test sequence */ - char *test_base; - char *test_filename; - - Bool snapshot_next_frame; - u32 snapshot_number; - - GF_TermEventFilter evt_filter; + GF_VideoListener video_listener; + + /* XML Validation List (the list of files to be tested) */ + char *xvl_filename; + GF_DOMParser *xvl_parser; + GF_XMLNode *xvl_node; + GF_XMLNode *xvs_node_in_xvl; + u32 xvl_node_index; + + /* Pointer to the current validation script file being tested */ + char *xvs_filename; + GF_DOMParser *xvs_parser; + GF_XMLNode *xvs_node; + Bool xvs_result; + + /* test sequence */ + char *test_base; + char *test_filename; + + Bool snapshot_next_frame; + u32 snapshot_number; + + GF_TermEventFilter evt_filter; } GF_Validator; static void validator_xvs_close(GF_Validator *validator); @@ -78,137 +78,137 @@ static Bool validator_xvs_next(GF_Validator *validator, Bool reverse); static void validator_xvs_add_snapshot_node(GF_Validator *validator, const char *filename, u32 scene_time) { - GF_XMLNode *snap_node; - GF_XMLAttribute *att; - GF_SAFEALLOC(snap_node, GF_XMLNode); - snap_node->name = gf_strdup("snapshot"); - snap_node->attributes = gf_list_new(); - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("time"); - att->value = gf_malloc(100); - sprintf(att->value, "%d", scene_time); - gf_list_add(snap_node->attributes, att); - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("image"); - att->value = gf_strdup(filename); - gf_list_add(snap_node->attributes, att); - gf_list_add(validator->xvs_node->content, snap_node); - - /* adding an extra text node for line break in serialization */ - GF_SAFEALLOC(snap_node, GF_XMLNode); - snap_node->type = GF_XML_TEXT_TYPE; - snap_node->name = gf_strdup("\n"); - gf_list_add(validator->xvs_node->content, snap_node); + GF_XMLNode *snap_node; + GF_XMLAttribute *att; + GF_SAFEALLOC(snap_node, GF_XMLNode); + snap_node->name = gf_strdup("snapshot"); + snap_node->attributes = gf_list_new(); + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("time"); + att->value = gf_malloc(100); + sprintf(att->value, "%d", scene_time); + gf_list_add(snap_node->attributes, att); + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("image"); + att->value = gf_strdup(filename); + gf_list_add(snap_node->attributes, att); + gf_list_add(validator->xvs_node->content, snap_node); + + /* adding an extra text node for line break in serialization */ + GF_SAFEALLOC(snap_node, GF_XMLNode); + snap_node->type = GF_XML_TEXT_TYPE; + snap_node->name = gf_strdup("\n"); + gf_list_add(validator->xvs_node->content, snap_node); } static char *validator_get_snapshot_name(char *test_filename, Bool is_reference, u32 number) { - char *dot; - char dumpname[GF_MAX_PATH]; - dot = strrchr(test_filename, '.'); - dot[0] = 0; - sprintf(dumpname, "%s-%s-%03d.png", test_filename, (is_reference?"reference":"newest"), number); - dot[0] = '.'; - return gf_strdup(dumpname); + char *dot; + char dumpname[GF_MAX_PATH]; + dot = strrchr(test_filename, '.'); + dot[0] = 0; + sprintf(dumpname, "%s-%s-%03d.png", test_filename, (is_reference?"reference":"newest"), number); + dot[0] = '.'; + return gf_strdup(dumpname); } -static char *validator_create_snapshot(GF_Validator *validator) +static char *validator_create_snapshot(GF_Validator *validator) { - GF_Err e; + GF_Err e; GF_VideoSurface fb; - GF_Terminal *term = validator->term; - char *dumpname; - - dumpname = validator_get_snapshot_name(validator->test_filename, validator->is_recording, validator->snapshot_number); - - e = gf_term_get_screen_buffer(term, &fb); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error dumping screen buffer %s\n", gf_error_to_string(e))); - } else { - u32 dst_size = fb.width*fb.height*3; - char *dst=gf_malloc(sizeof(char)*dst_size); - - e = gf_img_png_enc(fb.video_buffer, fb.width, fb.height, fb.pitch_y, fb.pixel_format, dst, &dst_size); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error encoding PNG %s\n", gf_error_to_string(e))); - } else { - FILE *png = gf_f64_open(dumpname, "wb"); - if (!png) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error writing file %s\n", dumpname)); - } else { - gf_fwrite(dst, dst_size, 1, png); - fclose(png); - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[Validator] Writing file %s\n", dumpname)); - } - } - if (dst) gf_free(dst); - gf_term_release_screen_buffer(term, &fb); - } - validator->snapshot_number++; - return dumpname; + GF_Terminal *term = validator->term; + char *dumpname; + + dumpname = validator_get_snapshot_name(validator->test_filename, validator->is_recording, validator->snapshot_number); + + e = gf_term_get_screen_buffer(term, &fb); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error dumping screen buffer %s\n", gf_error_to_string(e))); + } else { + u32 dst_size = fb.width*fb.height*3; + char *dst=gf_malloc(sizeof(char)*dst_size); + + e = gf_img_png_enc(fb.video_buffer, fb.width, fb.height, fb.pitch_y, fb.pixel_format, dst, &dst_size); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error encoding PNG %s\n", gf_error_to_string(e))); + } else { + FILE *png = gf_f64_open(dumpname, "wb"); + if (!png) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Error writing file %s\n", dumpname)); + } else { + gf_fwrite(dst, dst_size, 1, png); + fclose(png); + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[Validator] Writing file %s\n", dumpname)); + } + } + if (dst) gf_free(dst); + gf_term_release_screen_buffer(term, &fb); + } + validator->snapshot_number++; + return dumpname; } static Bool validator_compare_snapshots(GF_Validator *validator) { - char *ref_name, *new_name; - u32 ref_width, ref_height, ref_pixel_format, ref_data_size; - u32 new_width, new_height, new_pixel_format, new_data_size; - char *ref_data, *new_data; - Bool result = 0; - GF_Err e; - u32 i; - - u32 snap_number = validator->snapshot_number - 1; - ref_name = validator_get_snapshot_name(validator->test_filename, 1, snap_number); - new_name = validator_get_snapshot_name(validator->test_filename, 0, snap_number); - - e = gf_img_file_dec(ref_name, NULL, &ref_width, &ref_height, &ref_pixel_format, &ref_data, &ref_data_size); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Cannot decode PNG file %s\n", ref_name)); - goto end; - } - e = gf_img_file_dec(new_name, NULL, &new_width, &new_height, &new_pixel_format, &new_data, &new_data_size); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Cannot decode PNG file %s\n", new_name)); - goto end; - } - if (ref_width != new_width) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different widths: %d vs %d\n", ref_width, new_width)); - goto end; - } - if (ref_height != new_height) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different heights: %d vs %d\n", ref_height, new_height)); - goto end; - } - if (ref_pixel_format != new_pixel_format) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different pixel formats: %d vs %d\n", ref_pixel_format, new_pixel_format)); - goto end; - } - - for (i = 0; isnapshot_number - 1; + ref_name = validator_get_snapshot_name(validator->test_filename, 1, snap_number); + new_name = validator_get_snapshot_name(validator->test_filename, 0, snap_number); + + e = gf_img_file_dec(ref_name, NULL, &ref_width, &ref_height, &ref_pixel_format, &ref_data, &ref_data_size); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Cannot decode PNG file %s\n", ref_name)); + goto end; + } + e = gf_img_file_dec(new_name, NULL, &new_width, &new_height, &new_pixel_format, &new_data, &new_data_size); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Cannot decode PNG file %s\n", new_name)); + goto end; + } + if (ref_width != new_width) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different widths: %d vs %d\n", ref_width, new_width)); + goto end; + } + if (ref_height != new_height) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different heights: %d vs %d\n", ref_height, new_height)); + goto end; + } + if (ref_pixel_format != new_pixel_format) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Snapshots have different pixel formats: %d vs %d\n", ref_pixel_format, new_pixel_format)); + goto end; + } + + for (i = 0; isnapshot_next_frame) { - char *snap_name = validator_create_snapshot(validator); - validator_xvs_add_snapshot_node(validator, snap_name, gf_clock_time(validator->ck)); - gf_free(snap_name); - validator->snapshot_next_frame = 0; - } + if (validator->snapshot_next_frame) { + char *snap_name = validator_create_snapshot(validator); + validator_xvs_add_snapshot_node(validator, snap_name, gf_clock_time(validator->ck)); + gf_free(snap_name); + validator->snapshot_next_frame = 0; + } } static void validator_on_video_reconfig(void *udta, u32 width, u32 height, u8 bpp) @@ -221,171 +221,171 @@ Bool validator_on_event_play(void *udta, GF_Event *event, Bool consumed_by_compo switch (event->type) { case GF_EVENT_CONNECT: if (event->connect.is_connected) { - gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); - validator->ck = validator->term->root_scene->scene_codec ? - validator->term->root_scene->scene_codec->ck : - validator->term->root_scene->dyn_ck; + gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); + validator->ck = validator->term->root_scene->scene_codec ? + validator->term->root_scene->scene_codec->ck : + validator->term->root_scene->dyn_ck; } break; - case GF_EVENT_CLICK: + case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: + case GF_EVENT_MOUSEDOWN: + case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: case GF_EVENT_MOUSEMOVE: case GF_EVENT_MOUSEWHEEL: case GF_EVENT_KEYDOWN: case GF_EVENT_TEXTINPUT: - return 1; + return 1; case GF_EVENT_KEYUP: - if ((event->key.key_code == GF_KEY_END)&&(event->key.flags & GF_KEY_MOD_CTRL)) { - GF_Event evt; + if ((event->key.key_code == GF_KEY_END)&&(event->key.flags & GF_KEY_MOD_CTRL)) { + GF_Event evt; memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_QUIT; - validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); - } - return 1; + evt.type = GF_EVENT_QUIT; + validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); + } + return 1; } return 0; } -static void validator_xvs_add_event_dom(GF_Validator *validator, GF_Event *event) +static void validator_xvs_add_event_dom(GF_Validator *validator, GF_Event *event) { - GF_XMLNode *evt_node; - GF_XMLAttribute *att; - - GF_SAFEALLOC(evt_node, GF_XMLNode); + GF_XMLNode *evt_node; + GF_XMLAttribute *att; - switch (event->type) { - case GF_EVENT_CLICK: + GF_SAFEALLOC(evt_node, GF_XMLNode); + + switch (event->type) { + case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: + case GF_EVENT_MOUSEDOWN: + case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: case GF_EVENT_MOUSEMOVE: case GF_EVENT_MOUSEWHEEL: case GF_EVENT_KEYUP: case GF_EVENT_KEYDOWN: case GF_EVENT_TEXTINPUT: - evt_node->name = gf_strdup(gf_dom_event_get_name(event->type)); - break; - } - - if (!evt_node->name) { - gf_free(evt_node); - return; - } - - evt_node->attributes = gf_list_new(); - - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("time"); - att->value = gf_malloc(100); - sprintf(att->value, "%f", gf_scene_get_time(validator->term->root_scene)*1000); - gf_list_add(evt_node->attributes, att); - - switch (event->type) { - case GF_EVENT_CLICK: + evt_node->name = gf_strdup(gf_dom_event_get_name(event->type)); + break; + } + + if (!evt_node->name) { + gf_free(evt_node); + return; + } + + evt_node->attributes = gf_list_new(); + + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("time"); + att->value = gf_malloc(100); + sprintf(att->value, "%f", gf_scene_get_time(validator->term->root_scene)*1000); + gf_list_add(evt_node->attributes, att); + + switch (event->type) { + case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: + case GF_EVENT_MOUSEDOWN: + case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: case GF_EVENT_MOUSEMOVE: case GF_EVENT_MOUSEWHEEL: - if (event->type == GF_EVENT_MOUSEDOWN || event->type == GF_EVENT_MOUSEUP) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("button"); - switch (event->mouse.button) { - case 0: - att->value = gf_strdup("Left"); - break; - case 1: - att->value = gf_strdup("Middle"); - break; - case 2: - att->value = gf_strdup("Right"); - break; - } - gf_list_add(evt_node->attributes, att); - } - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("x"); - att->value = gf_malloc(100); - sprintf(att->value, "%d", event->mouse.x); - gf_list_add(evt_node->attributes, att); - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("y"); - att->value = gf_malloc(100); - sprintf(att->value, "%d", event->mouse.y); - gf_list_add(evt_node->attributes, att); - if (event->type == GF_EVENT_MOUSEWHEEL) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("wheel_pos"); - att->value = gf_malloc(100); - sprintf(att->value, "%f", event->mouse.wheel_pos); - gf_list_add(evt_node->attributes, att); - } - if (event->mouse.key_states & GF_KEY_MOD_SHIFT) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("shift"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } - if (event->mouse.key_states & GF_KEY_MOD_CTRL) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("ctrl"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } - if (event->mouse.key_states & GF_KEY_MOD_ALT) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("alt"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } - break; + if (event->type == GF_EVENT_MOUSEDOWN || event->type == GF_EVENT_MOUSEUP) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("button"); + switch (event->mouse.button) { + case 0: + att->value = gf_strdup("Left"); + break; + case 1: + att->value = gf_strdup("Middle"); + break; + case 2: + att->value = gf_strdup("Right"); + break; + } + gf_list_add(evt_node->attributes, att); + } + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("x"); + att->value = gf_malloc(100); + sprintf(att->value, "%d", event->mouse.x); + gf_list_add(evt_node->attributes, att); + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("y"); + att->value = gf_malloc(100); + sprintf(att->value, "%d", event->mouse.y); + gf_list_add(evt_node->attributes, att); + if (event->type == GF_EVENT_MOUSEWHEEL) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("wheel_pos"); + att->value = gf_malloc(100); + sprintf(att->value, "%f", event->mouse.wheel_pos); + gf_list_add(evt_node->attributes, att); + } + if (event->mouse.key_states & GF_KEY_MOD_SHIFT) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("shift"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } + if (event->mouse.key_states & GF_KEY_MOD_CTRL) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("ctrl"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } + if (event->mouse.key_states & GF_KEY_MOD_ALT) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("alt"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } + break; /*Key Events*/ case GF_EVENT_KEYUP: case GF_EVENT_KEYDOWN: case GF_EVENT_LONGKEYPRESS: - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("key_identifier"); - att->value = gf_strdup(gf_dom_get_key_name(event->key.key_code)); - gf_list_add(evt_node->attributes, att); - if (event->key.flags & GF_KEY_MOD_SHIFT) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("shift"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } - if (event->key.flags & GF_KEY_MOD_CTRL) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("ctrl"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } - if (event->key.flags & GF_KEY_MOD_ALT) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("alt"); - att->value = gf_strdup("true"); - gf_list_add(evt_node->attributes, att); - } + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("key_identifier"); + att->value = gf_strdup(gf_dom_get_key_name(event->key.key_code)); + gf_list_add(evt_node->attributes, att); + if (event->key.flags & GF_KEY_MOD_SHIFT) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("shift"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } + if (event->key.flags & GF_KEY_MOD_CTRL) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("ctrl"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } + if (event->key.flags & GF_KEY_MOD_ALT) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("alt"); + att->value = gf_strdup("true"); + gf_list_add(evt_node->attributes, att); + } break; case GF_EVENT_TEXTINPUT: - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("unicode-char"); - att->value = gf_malloc(100); - sprintf(att->value, "%d", event->character.unicode_char); - gf_list_add(evt_node->attributes, att); - break; - } - gf_list_add(validator->xvs_node->content, evt_node); - /* adding an extra text node for line break in serialization */ - GF_SAFEALLOC(evt_node, GF_XMLNode); - evt_node->type = GF_XML_TEXT_TYPE; - evt_node->name = gf_strdup("\n"); - gf_list_add(validator->xvs_node->content, evt_node); -} + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("unicode-char"); + att->value = gf_malloc(100); + sprintf(att->value, "%d", event->character.unicode_char); + gf_list_add(evt_node->attributes, att); + break; + } + gf_list_add(validator->xvs_node->content, evt_node); + /* adding an extra text node for line break in serialization */ + GF_SAFEALLOC(evt_node, GF_XMLNode); + evt_node->type = GF_XML_TEXT_TYPE; + evt_node->name = gf_strdup("\n"); + gf_list_add(validator->xvs_node->content, evt_node); +} Bool validator_on_event_record(void *udta, GF_Event *event, Bool consumed_by_compositor) { @@ -394,402 +394,402 @@ Bool validator_on_event_record(void *udta, GF_Event *event, Bool consumed_by_com switch (event->type) { case GF_EVENT_CONNECT: if (event->connect.is_connected) { - gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); + gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); validator->ck = validator->term->root_scene->scene_codec ? validator->term->root_scene->scene_codec->ck : validator->term->root_scene->dyn_ck; } break; case GF_EVENT_KEYDOWN: - if (event->key.key_code == GF_KEY_INSERT) { - rec_event = 0; - } else if (event->key.key_code == GF_KEY_PAGEDOWN) { - rec_event = 0; - } else if (event->key.key_code == GF_KEY_PAGEUP) { - rec_event = 0; - } else if (event->key.key_code == GF_KEY_END) { - rec_event = 0; - } else if (event->key.key_code == GF_KEY_CONTROL) { - rec_event = 0; - } else if (event->key.flags & GF_KEY_MOD_CTRL) { - rec_event = 0; - } - break; + if (event->key.key_code == GF_KEY_INSERT) { + rec_event = 0; + } else if (event->key.key_code == GF_KEY_PAGEDOWN) { + rec_event = 0; + } else if (event->key.key_code == GF_KEY_PAGEUP) { + rec_event = 0; + } else if (event->key.key_code == GF_KEY_END) { + rec_event = 0; + } else if (event->key.key_code == GF_KEY_CONTROL) { + rec_event = 0; + } else if (event->key.flags & GF_KEY_MOD_CTRL) { + rec_event = 0; + } + break; case GF_EVENT_KEYUP: - if (event->key.flags & GF_KEY_MOD_CTRL) { - rec_event = 0; - if (event->key.key_code == GF_KEY_INSERT) { - char *snap_name = validator_create_snapshot(validator); - validator_xvs_add_snapshot_node(validator, snap_name, gf_clock_time(validator->ck)); - gf_free(snap_name); - } else if (event->key.key_code == GF_KEY_END) { - GF_Event evt; + if (event->key.flags & GF_KEY_MOD_CTRL) { + rec_event = 0; + if (event->key.key_code == GF_KEY_INSERT) { + char *snap_name = validator_create_snapshot(validator); + validator_xvs_add_snapshot_node(validator, snap_name, gf_clock_time(validator->ck)); + gf_free(snap_name); + } else if (event->key.key_code == GF_KEY_END) { + GF_Event evt; memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_QUIT; - validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); - } else if (event->key.key_code == GF_KEY_F1) { - validator->snapshot_next_frame = 1; - } - } else if (event->key.key_code == GF_KEY_PAGEDOWN) { - rec_event = 0; - validator_xvs_close(validator); - gf_term_disconnect(validator->term); - gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); - validator_xvs_next(validator, 0); - } else if (event->key.key_code == GF_KEY_PAGEUP) { - rec_event = 0; - validator_xvs_close(validator); - gf_term_disconnect(validator->term); - gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); - validator_xvs_next(validator, 1); - } else if (event->key.key_code == GF_KEY_CONTROL) { - rec_event = 0; - } - break; + evt.type = GF_EVENT_QUIT; + validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); + } else if (event->key.key_code == GF_KEY_F1) { + validator->snapshot_next_frame = 1; + } + } else if (event->key.key_code == GF_KEY_PAGEDOWN) { + rec_event = 0; + validator_xvs_close(validator); + gf_term_disconnect(validator->term); + gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); + validator_xvs_next(validator, 0); + } else if (event->key.key_code == GF_KEY_PAGEUP) { + rec_event = 0; + validator_xvs_close(validator); + gf_term_disconnect(validator->term); + gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); + validator_xvs_next(validator, 1); + } else if (event->key.key_code == GF_KEY_CONTROL) { + rec_event = 0; + } + break; + } + if (rec_event) { + validator_xvs_add_event_dom(validator, event); } - if (rec_event) { - validator_xvs_add_event_dom(validator, event); - } return 0; } -static void validator_xvl_open(GF_Validator *validator) +static void validator_xvl_open(GF_Validator *validator) { - GF_Err e; - u32 att_index; - GF_XMLAttribute *att; - validator->xvl_parser = gf_xml_dom_new(); - e = gf_xml_dom_parse(validator->xvl_parser, validator->xvl_filename, NULL, NULL); - if (e != GF_OK) { - gf_xml_dom_del(validator->xvl_parser); - validator->xvl_parser = NULL; - return; - } - validator->xvl_node = gf_xml_dom_get_root(validator->xvl_parser); - if (!validator->xvl_node) { - gf_xml_dom_del(validator->xvl_parser); - validator->xvl_parser = NULL; - return; - } - att_index = 0; - while (1) { - att = gf_list_get(validator->xvl_node->attributes, att_index); - if (!att) break; - if (!strcmp(att->name, "content-base")) { - validator->test_base = gf_strdup(att->value); - } - att_index++; - } + GF_Err e; + u32 att_index; + GF_XMLAttribute *att; + validator->xvl_parser = gf_xml_dom_new(); + e = gf_xml_dom_parse(validator->xvl_parser, validator->xvl_filename, NULL, NULL); + if (e != GF_OK) { + gf_xml_dom_del(validator->xvl_parser); + validator->xvl_parser = NULL; + return; + } + validator->xvl_node = gf_xml_dom_get_root(validator->xvl_parser); + if (!validator->xvl_node) { + gf_xml_dom_del(validator->xvl_parser); + validator->xvl_parser = NULL; + return; + } + att_index = 0; + while (1) { + att = gf_list_get(validator->xvl_node->attributes, att_index); + if (!att) break; + if (!strcmp(att->name, "content-base")) { + validator->test_base = gf_strdup(att->value); + } + att_index++; + } } -static void validator_xvl_close(GF_Validator *validator) +static void validator_xvl_close(GF_Validator *validator) { - if (validator->xvl_parser) { - /* writing the validation results */ - if (!validator->is_recording) { - FILE *xvl_fp; - char *xvl_content; - char result_filename[GF_MAX_PATH]; - char *dot; - xvl_content = gf_xml_dom_serialize(validator->xvl_node, 0); - dot = strrchr(validator->xvl_filename, '.'); - dot[0] = 0; - sprintf(result_filename, "%s-result.xml", validator->xvl_filename); - dot[0] = '.'; - xvl_fp = gf_f64_open(result_filename, "wt"); - gf_fwrite(xvl_content, strlen(xvl_content), 1, xvl_fp); - fclose(xvl_fp); - gf_free(xvl_content); - } - gf_xml_dom_del(validator->xvl_parser); - validator->xvl_parser = NULL; - validator->xvl_filename = NULL; - } + if (validator->xvl_parser) { + /* writing the validation results */ + if (!validator->is_recording) { + FILE *xvl_fp; + char *xvl_content; + char result_filename[GF_MAX_PATH]; + char *dot; + xvl_content = gf_xml_dom_serialize(validator->xvl_node, 0); + dot = strrchr(validator->xvl_filename, '.'); + dot[0] = 0; + sprintf(result_filename, "%s-result.xml", validator->xvl_filename); + dot[0] = '.'; + xvl_fp = gf_f64_open(result_filename, "wt"); + gf_fwrite(xvl_content, strlen(xvl_content), 1, xvl_fp); + fclose(xvl_fp); + gf_free(xvl_content); + } + gf_xml_dom_del(validator->xvl_parser); + validator->xvl_parser = NULL; + validator->xvl_filename = NULL; + } } static void validator_xvl_get_next_xvs(GF_Validator *validator, Bool reverse) -{ - u32 xvl_att_index; - validator->xvs_node = NULL; - validator->xvs_filename = NULL; - validator->test_filename = NULL; - while (1) { - validator->xvs_node_in_xvl = gf_list_get(validator->xvl_node->content, validator->xvl_node_index); - if (!validator->xvs_node_in_xvl) { - return; - } - if (validator->xvs_node_in_xvl->type != GF_XML_NODE_TYPE) { - if (!reverse) validator->xvl_node_index++; - else validator->xvl_node_index--; - continue; - } - xvl_att_index = 0; - while(1) { - GF_XMLAttribute *att = gf_list_get(validator->xvs_node_in_xvl->attributes, xvl_att_index); - if (!att) break; - if (!strcmp(att->name, "scenario")) { - validator->xvs_filename = att->value; - } else if (!strcmp(att->name, "content")) { - validator->test_filename = att->value; - } - xvl_att_index++; - } - if (!reverse) validator->xvl_node_index++; - else validator->xvl_node_index--; - break; - } +{ + u32 xvl_att_index; + validator->xvs_node = NULL; + validator->xvs_filename = NULL; + validator->test_filename = NULL; + while (1) { + validator->xvs_node_in_xvl = gf_list_get(validator->xvl_node->content, validator->xvl_node_index); + if (!validator->xvs_node_in_xvl) { + return; + } + if (validator->xvs_node_in_xvl->type != GF_XML_NODE_TYPE) { + if (!reverse) validator->xvl_node_index++; + else validator->xvl_node_index--; + continue; + } + xvl_att_index = 0; + while(1) { + GF_XMLAttribute *att = gf_list_get(validator->xvs_node_in_xvl->attributes, xvl_att_index); + if (!att) break; + if (!strcmp(att->name, "scenario")) { + validator->xvs_filename = att->value; + } else if (!strcmp(att->name, "content")) { + validator->test_filename = att->value; + } + xvl_att_index++; + } + if (!reverse) validator->xvl_node_index++; + else validator->xvl_node_index--; + break; + } } -static Bool validator_xvs_open(GF_Validator *validator) +static Bool validator_xvs_open(GF_Validator *validator) { - GF_Err e; - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Validator] Opening Validation Script: %s\n", validator->xvs_filename)); - validator->snapshot_number = 0; - validator->xvs_parser = gf_xml_dom_new(); - e = gf_xml_dom_parse(validator->xvs_parser, validator->xvs_filename, NULL, NULL); - if (e != GF_OK) { - if (validator->is_recording) { - GF_SAFEALLOC(validator->xvs_node, GF_XMLNode); - validator->xvs_node->name = gf_strdup("TestValidationScript"); - validator->xvs_node->attributes = gf_list_new(); - validator->xvs_node->content = gf_list_new(); - } else { - gf_xml_dom_del(validator->xvs_parser); - validator->xvs_parser = NULL; - return 0; - } - } else { - validator->xvs_node = gf_xml_dom_get_root(validator->xvs_parser); - } - /* Get the file name from the XVS if not found in the XVL */ - if (!validator->test_filename) { - GF_XMLAttribute *att; - GF_XMLAttribute *att_file; - u32 att_index = 0; - att_file = NULL; - while (1) { - att = gf_list_get(validator->xvs_node->attributes, att_index); - if (!att) { - break; - } else if (!strcmp(att->name, "file")) { - att_file = att; - } - att_index++; - } - if (!att_file) { - gf_xml_dom_del(validator->xvs_parser); - validator->xvs_parser = NULL; - validator->xvs_node = NULL; - return 0; - } else { - char *sep; - sep = strrchr(att_file->value, GF_PATH_SEPARATOR); - if (!sep) { - validator->test_filename = att_file->value; - } else { - sep[0] = 0; - validator->test_base = gf_strdup(att_file->value); - sep[0] = GF_PATH_SEPARATOR; - validator->test_filename = sep+1; - } - } - } - if (validator->is_recording) { - GF_XMLNode *node; - /* Removing prerecorded interactions */ + GF_Err e; + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Validator] Opening Validation Script: %s\n", validator->xvs_filename)); + validator->snapshot_number = 0; + validator->xvs_parser = gf_xml_dom_new(); + e = gf_xml_dom_parse(validator->xvs_parser, validator->xvs_filename, NULL, NULL); + if (e != GF_OK) { + if (validator->is_recording) { + GF_SAFEALLOC(validator->xvs_node, GF_XMLNode); + validator->xvs_node->name = gf_strdup("TestValidationScript"); + validator->xvs_node->attributes = gf_list_new(); + validator->xvs_node->content = gf_list_new(); + } else { + gf_xml_dom_del(validator->xvs_parser); + validator->xvs_parser = NULL; + return 0; + } + } else { + validator->xvs_node = gf_xml_dom_get_root(validator->xvs_parser); + } + /* Get the file name from the XVS if not found in the XVL */ + if (!validator->test_filename) { + GF_XMLAttribute *att; + GF_XMLAttribute *att_file; + u32 att_index = 0; + att_file = NULL; + while (1) { + att = gf_list_get(validator->xvs_node->attributes, att_index); + if (!att) { + break; + } else if (!strcmp(att->name, "file")) { + att_file = att; + } + att_index++; + } + if (!att_file) { + gf_xml_dom_del(validator->xvs_parser); + validator->xvs_parser = NULL; + validator->xvs_node = NULL; + return 0; + } else { + char *sep; + sep = strrchr(att_file->value, GF_PATH_SEPARATOR); + if (!sep) { + validator->test_filename = att_file->value; + } else { + sep[0] = 0; + validator->test_base = gf_strdup(att_file->value); + sep[0] = GF_PATH_SEPARATOR; + validator->test_filename = sep+1; + } + } + } + if (validator->is_recording) { + GF_XMLNode *node; + /* Removing prerecorded interactions */ while (gf_list_count(validator->xvs_node->content)) { GF_XMLNode *child = (GF_XMLNode *)gf_list_last(validator->xvs_node->content); gf_list_rem_last(validator->xvs_node->content); gf_xml_dom_node_del(child); } - /* adding an extra text node for line break in serialization */ - GF_SAFEALLOC(node, GF_XMLNode); - node->type = GF_XML_TEXT_TYPE; - node->name = gf_strdup("\n"); - gf_list_add(validator->xvs_node->content, node); - } else { - validator->xvs_result = 1; - } - return 1; + /* adding an extra text node for line break in serialization */ + GF_SAFEALLOC(node, GF_XMLNode); + node->type = GF_XML_TEXT_TYPE; + node->name = gf_strdup("\n"); + gf_list_add(validator->xvs_node->content, node); + } else { + validator->xvs_result = 1; + } + return 1; } static void validator_xvs_close(GF_Validator *validator) { - if (validator->xvs_parser) { - if (validator->is_recording) { - FILE *xvs_fp; - char *xvs_content; - char filename[100]; - GF_XMLAttribute *att; - GF_XMLAttribute *att_file = NULL; - u32 att_index = 0; - while (1) { - att = gf_list_get(validator->xvs_node->attributes, att_index); - if (!att) { - break; - } else if (!strcmp(att->name, "file")) { - att_file = att; - } - att_index++; - } - - if (!att_file) { - GF_SAFEALLOC(att, GF_XMLAttribute); - att->name = gf_strdup("file"); - gf_list_add(validator->xvs_node->attributes, att); - } else { - att = att_file; - if (att->value) gf_free(att->value); - } - sprintf(filename, "%s%c%s", validator->test_base, GF_PATH_SEPARATOR, validator->test_filename); - att->value = gf_strdup(filename); - xvs_content = gf_xml_dom_serialize(validator->xvs_node, 0); - xvs_fp = gf_f64_open(validator->xvs_filename, "wt"); - gf_fwrite(xvs_content, strlen(xvs_content), 1, xvs_fp); - fclose(xvs_fp); - gf_free(xvs_content); - } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Validator] XVS Result : %s\n", (validator->xvs_result?"Success":"Failure"))); - if (validator->xvs_node_in_xvl) { - GF_XMLAttribute *att; - GF_XMLAttribute *att_result = NULL; - u32 att_index = 0; - while (1) { - att = gf_list_get(validator->xvs_node_in_xvl->attributes, att_index); - if (!att) { - break; - } else if (!strcmp(att->name, "result")) { - att_result = att; - } - att_index++; - } - if (!att_result) { - GF_SAFEALLOC(att_result, GF_XMLAttribute); - att_result->name = gf_strdup("result"); - gf_list_add(validator->xvs_node_in_xvl->attributes, att_result); - } - if (att_result->value) gf_free(att_result->value); - att_result->value = gf_strdup(validator->xvs_result ? "pass" : "fail"); - } - } - gf_xml_dom_del(validator->xvs_parser); - validator->xvs_parser = NULL; - } - validator->xvs_node = NULL; - validator->xvs_node_in_xvl = NULL; - validator->xvs_filename = NULL; - validator->test_filename = NULL; - validator->ck = NULL; - validator->xvs_event_index = 0; - validator->snapshot_number = 0; + if (validator->xvs_parser) { + if (validator->is_recording) { + FILE *xvs_fp; + char *xvs_content; + char filename[100]; + GF_XMLAttribute *att; + GF_XMLAttribute *att_file = NULL; + u32 att_index = 0; + while (1) { + att = gf_list_get(validator->xvs_node->attributes, att_index); + if (!att) { + break; + } else if (!strcmp(att->name, "file")) { + att_file = att; + } + att_index++; + } + + if (!att_file) { + GF_SAFEALLOC(att, GF_XMLAttribute); + att->name = gf_strdup("file"); + gf_list_add(validator->xvs_node->attributes, att); + } else { + att = att_file; + if (att->value) gf_free(att->value); + } + sprintf(filename, "%s%c%s", validator->test_base, GF_PATH_SEPARATOR, validator->test_filename); + att->value = gf_strdup(filename); + xvs_content = gf_xml_dom_serialize(validator->xvs_node, 0); + xvs_fp = gf_f64_open(validator->xvs_filename, "wt"); + gf_fwrite(xvs_content, strlen(xvs_content), 1, xvs_fp); + fclose(xvs_fp); + gf_free(xvs_content); + } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Validator] XVS Result : %s\n", (validator->xvs_result?"Success":"Failure"))); + if (validator->xvs_node_in_xvl) { + GF_XMLAttribute *att; + GF_XMLAttribute *att_result = NULL; + u32 att_index = 0; + while (1) { + att = gf_list_get(validator->xvs_node_in_xvl->attributes, att_index); + if (!att) { + break; + } else if (!strcmp(att->name, "result")) { + att_result = att; + } + att_index++; + } + if (!att_result) { + GF_SAFEALLOC(att_result, GF_XMLAttribute); + att_result->name = gf_strdup("result"); + gf_list_add(validator->xvs_node_in_xvl->attributes, att_result); + } + if (att_result->value) gf_free(att_result->value); + att_result->value = gf_strdup(validator->xvs_result ? "pass" : "fail"); + } + } + gf_xml_dom_del(validator->xvs_parser); + validator->xvs_parser = NULL; + } + validator->xvs_node = NULL; + validator->xvs_node_in_xvl = NULL; + validator->xvs_filename = NULL; + validator->test_filename = NULL; + validator->ck = NULL; + validator->xvs_event_index = 0; + validator->snapshot_number = 0; } static void validator_test_open(GF_Validator *validator) { - char filename[100]; - if (validator->test_base) - sprintf(filename, "%s%c%s", validator->test_base, GF_PATH_SEPARATOR, validator->test_filename); - else - sprintf(filename, "%s", validator->test_filename); - gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); - if (validator->is_recording) - validator->snapshot_next_frame = 1; - gf_term_connect(validator->term, filename); - validator->ck = validator->term->root_scene->scene_codec ? - validator->term->root_scene->scene_codec->ck : - validator->term->root_scene->dyn_ck; + char filename[100]; + if (validator->test_base) + sprintf(filename, "%s%c%s", validator->test_base, GF_PATH_SEPARATOR, validator->test_filename); + else + sprintf(filename, "%s", validator->test_filename); + gf_sc_add_video_listener(validator->term->compositor, &validator->video_listener); + if (validator->is_recording) + validator->snapshot_next_frame = 1; + gf_term_connect(validator->term, filename); + validator->ck = validator->term->root_scene->scene_codec ? + validator->term->root_scene->scene_codec->ck : + validator->term->root_scene->dyn_ck; } static Bool validator_xvs_next(GF_Validator *validator, Bool reverse) { - if (validator->xvl_node) { - validator_xvl_get_next_xvs(validator, reverse); - if (validator->xvs_filename) { - validator_xvs_open(validator); - if (!validator->xvs_node) { - return 0; - } - if (validator->test_filename) { - validator_test_open(validator); - } else { - validator_xvs_close(validator); - return 0; - } - } else { - return 0; - } - return 1; - } else { - return 0; - } + if (validator->xvl_node) { + validator_xvl_get_next_xvs(validator, reverse); + if (validator->xvs_filename) { + validator_xvs_open(validator); + if (!validator->xvs_node) { + return 0; + } + if (validator->test_filename) { + validator_test_open(validator); + } else { + validator_xvs_close(validator); + return 0; + } + } else { + return 0; + } + return 1; + } else { + return 0; + } } -static Bool validator_load_event(GF_Validator *validator) +static Bool validator_load_event(GF_Validator *validator) { - GF_XMLNode *event_node; - GF_XMLAttribute *att; - u32 att_index; + GF_XMLNode *event_node; + GF_XMLAttribute *att; + u32 att_index; memset(&validator->next_event, 0, sizeof(GF_Event)); validator->evt_loaded = 0; - validator->next_event_snapshot = 0; - - if (!validator->xvs_node) return 0; - - while (1) { - event_node = gf_list_get(validator->xvs_node->content, validator->xvs_event_index); - if (!event_node) { - return 0; - } else if (event_node->type == GF_XML_NODE_TYPE) { - validator->xvs_event_index++; - break; - } else { - validator->xvs_event_index++; - } - } - - if (!strcmp(event_node->name, "snapshot")) { - validator->next_event_snapshot = 1; - } else { - validator->next_event.type = gf_dom_event_type_by_name(event_node->name); - if (validator->next_event.type == GF_EVENT_UNKNOWN) { - return 1; - } - } - - att_index = 0; - while (1) { - att = gf_list_get(event_node->attributes, att_index); - if (!att) break; - if (!strcmp(att->name, "time")) { - validator->next_time = atoi(att->value); - } else if (!strcmp(att->name, "button")) { - if (!strcmp(att->value, "Left")) { - validator->next_event.mouse.button = 0; - } else if (!strcmp(att->value, "Middle")) { - validator->next_event.mouse.button = 1; - } else if (!strcmp(att->value, "Right")) { - validator->next_event.mouse.button = 2; - } - } else if (!strcmp(att->name, "x")) { - validator->next_event.mouse.x = atoi(att->value); - } else if (!strcmp(att->name, "y")) { - validator->next_event.mouse.y = atoi(att->value); - } else if (!strcmp(att->name, "wheel_pos")) { - validator->next_event.mouse.wheel_pos = FLT2FIX(atof(att->value)); - } else if (!strcmp(att->name, "shift") && !strcmp(att->value, "true")) { - validator->next_event.mouse.key_states |= GF_KEY_MOD_SHIFT; - } else if (!strcmp(att->name, "alt") && !strcmp(att->value, "true")) { - validator->next_event.mouse.key_states |= GF_KEY_MOD_ALT; - } else if (!strcmp(att->name, "ctrl") && !strcmp(att->value, "true")) { - validator->next_event.mouse.key_states |= GF_KEY_MOD_CTRL; - } else if (!strcmp(att->name, "key_identifier")) { - validator->next_event.key.key_code = gf_dom_get_key_type(att->value); - } else if (!strcmp(att->name, "unicode-char")) { - validator->next_event.character.unicode_char = atoi(att->value); - } - att_index++; - } + validator->next_event_snapshot = 0; + + if (!validator->xvs_node) return 0; + + while (1) { + event_node = gf_list_get(validator->xvs_node->content, validator->xvs_event_index); + if (!event_node) { + return 0; + } else if (event_node->type == GF_XML_NODE_TYPE) { + validator->xvs_event_index++; + break; + } else { + validator->xvs_event_index++; + } + } + + if (!strcmp(event_node->name, "snapshot")) { + validator->next_event_snapshot = 1; + } else { + validator->next_event.type = gf_dom_event_type_by_name(event_node->name); + if (validator->next_event.type == GF_EVENT_UNKNOWN) { + return 1; + } + } + + att_index = 0; + while (1) { + att = gf_list_get(event_node->attributes, att_index); + if (!att) break; + if (!strcmp(att->name, "time")) { + validator->next_time = atoi(att->value); + } else if (!strcmp(att->name, "button")) { + if (!strcmp(att->value, "Left")) { + validator->next_event.mouse.button = 0; + } else if (!strcmp(att->value, "Middle")) { + validator->next_event.mouse.button = 1; + } else if (!strcmp(att->value, "Right")) { + validator->next_event.mouse.button = 2; + } + } else if (!strcmp(att->name, "x")) { + validator->next_event.mouse.x = atoi(att->value); + } else if (!strcmp(att->name, "y")) { + validator->next_event.mouse.y = atoi(att->value); + } else if (!strcmp(att->name, "wheel_pos")) { + validator->next_event.mouse.wheel_pos = FLT2FIX(atof(att->value)); + } else if (!strcmp(att->name, "shift") && !strcmp(att->value, "true")) { + validator->next_event.mouse.key_states |= GF_KEY_MOD_SHIFT; + } else if (!strcmp(att->name, "alt") && !strcmp(att->value, "true")) { + validator->next_event.mouse.key_states |= GF_KEY_MOD_ALT; + } else if (!strcmp(att->name, "ctrl") && !strcmp(att->value, "true")) { + validator->next_event.mouse.key_states |= GF_KEY_MOD_CTRL; + } else if (!strcmp(att->name, "key_identifier")) { + validator->next_event.key.key_code = gf_dom_get_key_type(att->value); + } else if (!strcmp(att->name, "unicode-char")) { + validator->next_event.character.unicode_char = atoi(att->value); + } + att_index++; + } validator->evt_loaded = 1; - return 1; + return 1; } static Bool validator_process(GF_TermExt *termext, u32 action, void *param) @@ -799,41 +799,41 @@ static Bool validator_process(GF_TermExt *termext, u32 action, void *param) switch (action) { - /* Upon starting of the terminal, we parse (possibly an XVL file), an XVS file, and start the first test sequence */ - case GF_TERM_EXT_START: + /* Upon starting of the terminal, we parse (possibly an XVL file), an XVS file, and start the first test sequence */ + case GF_TERM_EXT_START: validator->term = (GF_Terminal *) param; - /* if the validator is loaded, we switch off anti-aliasing for image comparison and we put a low framerate, + /* if the validator is loaded, we switch off anti-aliasing for image comparison and we put a low framerate, but we store the previous value to restore it upon termination of the validator */ - opt = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Compositor", "FrameRate"); - if (opt) validator->prev_fps = gf_strdup(opt); - opt = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias"); - if (opt) validator->prev_alias = gf_strdup(opt); + opt = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Compositor", "FrameRate"); + if (opt) validator->prev_fps = gf_strdup(opt); + opt = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias"); + if (opt) validator->prev_alias = gf_strdup(opt); /* Check if the validator should be loaded and in which mode */ - opt = gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "Mode"); + opt = gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "Mode"); if (!opt) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("Validator missing configuration, stopping.\n")); return 0; } else if (!strcmp(opt, "Play")) { GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Validator starting in playback mode.\n")); - validator->is_recording = 0; - } else if (!strcmp(opt, "Record")) { + validator->is_recording = 0; + } else if (!strcmp(opt, "Record")) { GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Validator starting in recording mode.\n")); - validator->is_recording = 1; - } else if (!strcmp(opt, "Disable")) { + validator->is_recording = 1; + } else if (!strcmp(opt, "Disable")) { GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Validator is disabled.\n")); - return 0; - } else { + return 0; + } else { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("Validator configuration using wrong mode, stopping.\n")); - return 0; - } + return 0; + } /* initializes the validator and starts */ - validator->xvs_filename = NULL; - validator->xvl_filename = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "XVL"); - if (!validator->xvl_filename) { - validator->xvs_filename = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "XVS"); + validator->xvs_filename = NULL; + validator->xvl_filename = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "XVL"); + if (!validator->xvl_filename) { + validator->xvs_filename = (char *)gf_modules_get_option((GF_BaseInterface*)termext, "Validator", "XVS"); if (!validator->xvs_filename) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("Validator configuration without input, stopping.\n")); return 0; @@ -845,64 +845,64 @@ static Bool validator_process(GF_TermExt *termext, u32 action, void *param) } /* since we changed parameters of the compositor, we need to trigger a reconfiguration */ - gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "FrameRate", "5.0"); - gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias", "None"); - gf_term_set_option(validator->term, GF_OPT_RELOAD_CONFIG, 1); + gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "FrameRate", "5.0"); + gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias", "None"); + gf_term_set_option(validator->term, GF_OPT_RELOAD_CONFIG, 1); validator->evt_filter.udta = validator; if (!validator->is_recording) { validator->evt_filter.on_event = validator_on_event_play; - termext->caps |= GF_TERM_EXTENSION_NOT_THREADED; - } else { - validator->evt_filter.on_event = validator_on_event_record; - } - gf_term_add_event_filter(validator->term, &validator->evt_filter); - validator->video_listener.udta = validator; - validator->video_listener.on_video_frame = validator_on_video_frame; - validator->video_listener.on_video_reconfig = validator_on_video_reconfig; + termext->caps |= GF_TERM_EXTENSION_NOT_THREADED; + } else { + validator->evt_filter.on_event = validator_on_event_record; + } + gf_term_add_event_filter(validator->term, &validator->evt_filter); + validator->video_listener.udta = validator; + validator->video_listener.on_video_frame = validator_on_video_frame; + validator->video_listener.on_video_reconfig = validator_on_video_reconfig; /* TODO: if start returns 0, the module is not loaded, so the above init (filter registration) is not removed, should probably return 1 all the time, to make sure stop is called */ - if (validator->xvl_filename) { - validator_xvl_open(validator); - if (!validator->xvl_node) { - return 0; - } - validator_xvs_next(validator, 0); - if (!validator->xvs_node) { - return 0; - } - } else if (validator->xvs_filename) { - validator_xvs_open(validator); - if (!validator->xvs_node) { - return 0; - } - if (validator->test_filename) { - validator_test_open(validator); - } else { - validator_xvs_close(validator); - return 0; - } - } else { - return 0; - } - if (!validator->is_recording) { - validator_load_event(validator); - } + if (validator->xvl_filename) { + validator_xvl_open(validator); + if (!validator->xvl_node) { + return 0; + } + validator_xvs_next(validator, 0); + if (!validator->xvs_node) { + return 0; + } + } else if (validator->xvs_filename) { + validator_xvs_open(validator); + if (!validator->xvs_node) { + return 0; + } + if (validator->test_filename) { + validator_test_open(validator); + } else { + validator_xvs_close(validator); + return 0; + } + } else { + return 0; + } + if (!validator->is_recording) { + validator_load_event(validator); + } return 1; - /* when the terminal stops, we close the XVS parser and XVL parser if any, restore the config, - and free all validator data (the validator will be destroyed when the module is unloaded) - Note: we don't need to disconnect the terminal since it's already stopping */ + /* when the terminal stops, we close the XVS parser and XVL parser if any, restore the config, + and free all validator data (the validator will be destroyed when the module is unloaded) + Note: we don't need to disconnect the terminal since it's already stopping */ case GF_TERM_EXT_STOP: - gf_term_remove_event_filter(validator->term, &validator->evt_filter); + gf_term_remove_event_filter(validator->term, &validator->evt_filter); validator_xvs_close(validator); - validator_xvl_close(validator); + validator_xvl_close(validator); validator->term = NULL; - if (validator->test_base) { - gf_free(validator->test_base); - validator->test_base = NULL; - } + if (validator->test_base) { + gf_free(validator->test_base); + validator->test_base = NULL; + } /*auto-disable the recording by default*/ if (validator->is_recording) { gf_modules_set_option((GF_BaseInterface*)termext, "Validator", "Mode", "Play"); @@ -912,52 +912,52 @@ static Bool validator_process(GF_TermExt *termext, u32 action, void *param) GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Stopping validator\n")); if (validator->prev_fps) { gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "FrameRate", validator->prev_fps); - gf_free(validator->prev_fps); - validator->prev_fps = NULL; - } - if (validator->prev_alias) { - gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias", validator->prev_alias); - gf_free(validator->prev_alias); - validator->prev_alias = NULL; - } + gf_free(validator->prev_fps); + validator->prev_fps = NULL; + } + if (validator->prev_alias) { + gf_modules_set_option((GF_BaseInterface*)termext, "Compositor", "AntiAlias", validator->prev_alias); + gf_free(validator->prev_alias); + validator->prev_alias = NULL; + } break; - /* When called in the main loop of the terminal, we don't do anything in the recording mode. - In the playing/validating mode, we need to check if an event needs to be dispatched or if snapshots need to be made, - until there is no more event, in which case we trigger either the load of the next XVS or the quit */ + /* When called in the main loop of the terminal, we don't do anything in the recording mode. + In the playing/validating mode, we need to check if an event needs to be dispatched or if snapshots need to be made, + until there is no more event, in which case we trigger either the load of the next XVS or the quit */ case GF_TERM_EXT_PROCESS: - /* if the time is right, dispatch the event and load the next one */ + /* if the time is right, dispatch the event and load the next one */ while (!validator->is_recording && validator->evt_loaded && validator->ck && (validator->next_time <= gf_clock_time(validator->ck) )) { - Bool has_more_events; - //u32 diff = gf_clock_time(validator->ck) - validator->next_time; - //GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Time diff: evt_time=%d clock_time = %d, diff=%d\n", validator->next_time, gf_clock_time(validator->ck), diff)); - if (validator->next_event_snapshot) { - Bool res; - char *snap_name = validator_create_snapshot(validator); - gf_free(snap_name); - res = validator_compare_snapshots(validator); - validator->xvs_result &= res; - validator->next_event_snapshot = 0; - } else { - validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &validator->next_event); - } - has_more_events = validator_load_event(validator); - if (!has_more_events) { - validator_xvs_close(validator); - gf_term_disconnect(validator->term); - gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); - validator_xvs_next(validator, 0); - if (!validator->xvs_node) { - GF_Event evt; + Bool has_more_events; + //u32 diff = gf_clock_time(validator->ck) - validator->next_time; + //GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[Validator] Time diff: evt_time=%d clock_time = %d, diff=%d\n", validator->next_time, gf_clock_time(validator->ck), diff)); + if (validator->next_event_snapshot) { + Bool res; + char *snap_name = validator_create_snapshot(validator); + gf_free(snap_name); + res = validator_compare_snapshots(validator); + validator->xvs_result &= res; + validator->next_event_snapshot = 0; + } else { + validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &validator->next_event); + } + has_more_events = validator_load_event(validator); + if (!has_more_events) { + validator_xvs_close(validator); + gf_term_disconnect(validator->term); + gf_sc_remove_video_listener(validator->term->compositor, &validator->video_listener); + validator_xvs_next(validator, 0); + if (!validator->xvs_node) { + GF_Event evt; memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_QUIT; - validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); - } else { - if (!validator->is_recording) { - validator_load_event(validator); - } - } - } + evt.type = GF_EVENT_QUIT; + validator->term->compositor->video_out->on_event(validator->term->compositor->video_out->evt_cbk_hdl, &evt); + } else { + if (!validator->is_recording) { + validator_load_event(validator); + } + } + } } break; } @@ -986,22 +986,22 @@ void validator_delete(GF_BaseInterface *ifce) GF_Validator *validator = dr->udta; if (validator->prev_fps) gf_free(validator->prev_fps); if (validator->prev_alias) gf_free(validator->prev_alias); - gf_free(validator); + gf_free(validator); gf_free(dr); } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_TERM_EXT_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_TERM_EXT_INTERFACE) return (GF_BaseInterface *)validator_new(); return NULL; diff --git a/modules/vtt_in/vtt_dec.c b/modules/vtt_in/vtt_dec.c index 661e7c1..03ea6d4 100644 --- a/modules/vtt_in/vtt_dec.c +++ b/modules/vtt_in/vtt_dec.c @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Cyril Concolato + * Authors: Cyril Concolato * Copyright (c) Telecom ParisTech 2013- * All rights reserved * @@ -51,13 +51,13 @@ typedef struct { 0 if no dependency */ u32 base_es_id; - /* file_name of the VTT file when parsing a input text file + /* file_name of the VTT file when parsing a input text file not used when parsing from MP4 or from a stream */ char *file_name; u64 file_size; u64 file_pos; - /* config of the VTT file when parsing an MP4 file + /* config of the VTT file when parsing an MP4 file not used when parsing from text file or from a stream */ char *config; @@ -96,7 +96,7 @@ static Bool vtt_check_download(VTTDec *vttdec) static GF_Err VTT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 stream_time, u32 mmlevel) + u16 ES_ID, u32 stream_time, u32 mmlevel) { GF_Err e = GF_OK; VTTDec *vttdec = (VTTDec *)plug->privateStack; @@ -127,23 +127,23 @@ static GF_Err VTT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 i break; case GPAC_OTI_SCENE_VTT_MP4: - { - char start[100], end[100]; - GF_List *cues; - cues = gf_webvtt_parse_cues_from_data(inBuffer, inBufferLength, 0); - gf_webvtt_js_removeCues(vttdec->sg->RootNode); - if (gf_list_count(cues)) { - while (gf_list_count(cues)) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, 0); - gf_list_rem(cues, 0); - sprintf(start, "%02d:%02d:%02d.%03d", cue->start.hour, cue->start.min, cue->start.sec, cue->start.ms); - sprintf(end, "%02d:%02d:%02d.%03d", cue->end.hour, cue->end.min, cue->end.sec, cue->end.ms); - gf_webvtt_js_addCue(vttdec->sg->RootNode, cue->id, start, end, cue->settings, cue->text); - } - } - gf_list_del(cues); + { + char start[100], end[100]; + GF_List *cues; + cues = gf_webvtt_parse_cues_from_data(inBuffer, inBufferLength, 0); + gf_webvtt_js_removeCues(vttdec->sg->RootNode); + if (gf_list_count(cues)) { + while (gf_list_count(cues)) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, 0); + gf_list_rem(cues, 0); + sprintf(start, "%02d:%02d:%02d.%03d", cue->start.hour, cue->start.min, cue->start.sec, cue->start.ms); + sprintf(end, "%02d:%02d:%02d.%03d", cue->end.hour, cue->end.min, cue->end.sec, cue->end.ms); + gf_webvtt_js_addCue(vttdec->sg->RootNode, cue->id, start, end, cue->settings, cue->text); + } } - break; + gf_list_del(cues); + } + break; default: return GF_BAD_PARAM; @@ -266,7 +266,7 @@ static void VTT_ReadConfigFromDSI(VTTDec *vttdec, GF_DefaultDescriptor *dsi) vttdec->config = ((GF_StringBox *)b)->string; ((GF_StringBox *)b)->string = NULL; gf_isom_box_del(b); - } + } gf_bs_del(bs); } @@ -331,7 +331,7 @@ static u32 VTT_CanHandleStream(GF_BaseDecoder *ifce, u32 StreamType, GF_ESD *esd case GPAC_OTI_SCENE_VTT: case GPAC_OTI_SCENE_VTT_MP4: return GF_CODEC_SUPPORTED; - default: + default: return GF_CODEC_NOT_SUPPORTED; } } diff --git a/modules/vtt_in/vtt_in.c b/modules/vtt_in/vtt_in.c index 9cc8c75..72b76f5 100644 --- a/modules/vtt_in/vtt_in.c +++ b/modules/vtt_in/vtt_in.c @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Cyril Concolato + * Authors: Cyril Concolato * Copyright (c) Telecom ParisTech 2013- * All rights reserved * @@ -48,15 +48,15 @@ typedef struct } VTTIn; const char * VTT_MIME_TYPES[] = { - "text/vtt", "vtt", "VTT SubTitles", - NULL + "text/vtt", "vtt", "VTT SubTitles", + NULL }; -static u32 VTT_RegisterMimeTypes(const GF_InputService *plug){ +static u32 VTT_RegisterMimeTypes(const GF_InputService *plug) { u32 i; if (!plug) return 0; - for (i = 0 ; VTT_MIME_TYPES[i]; i+=3){ - gf_term_register_mime_type(plug, VTT_MIME_TYPES[i], VTT_MIME_TYPES[i+1], VTT_MIME_TYPES[i+2]); + for (i = 0 ; VTT_MIME_TYPES[i]; i+=3) { + gf_service_register_mime(plug, VTT_MIME_TYPES[i], VTT_MIME_TYPES[i+1], VTT_MIME_TYPES[i+2]); } return i/3; } @@ -68,8 +68,8 @@ static Bool VTT_CanHandleURL(GF_InputService *plug, const char *url) if (!plug || !url) return GF_FALSE; sExt = strrchr(url, '.'); if (!sExt) return GF_FALSE; - for (i = 0 ; VTT_MIME_TYPES[i]; i+=3){ - if (gf_term_check_extension(plug, VTT_MIME_TYPES[i], VTT_MIME_TYPES[i+1], VTT_MIME_TYPES[i+2], sExt)) return GF_TRUE; + for (i = 0 ; VTT_MIME_TYPES[i]; i+=3) { + if (gf_service_check_mime_register(plug, VTT_MIME_TYPES[i], VTT_MIME_TYPES[i+1], VTT_MIME_TYPES[i+2], sExt)) return GF_TRUE; } return GF_FALSE; } @@ -90,7 +90,7 @@ void VTT_NetIO(void *cbk, GF_NETIO_Parameter *param) VTTIn *vttin = (VTTIn *) plug->priv; if (!vttin) return; - gf_term_download_update_stats(vttin->dnload); + gf_service_download_update_stats(vttin->dnload); e = param->error; /*done*/ @@ -108,7 +108,7 @@ void VTT_NetIO(void *cbk, GF_NETIO_Parameter *param) /*OK confirm*/ if (vttin->needs_connection) { vttin->needs_connection = GF_FALSE; - gf_term_on_connect(vttin->service, NULL, e); + gf_service_connect_ack(vttin->service, NULL, e); //if (!e && !vttin->od_done) tti_setup_object(vttin); } } @@ -116,13 +116,13 @@ void VTT_NetIO(void *cbk, GF_NETIO_Parameter *param) void VTT_download_file(GF_InputService *plug, const char *url) { VTTIn *vttin = (VTTIn *) plug->priv; - if (!plug || !url) - return; + if (!plug || !url) + return; vttin->needs_connection = GF_TRUE; - vttin->dnload = gf_term_download_new(vttin->service, url, 0, VTT_NetIO, plug); + vttin->dnload = gf_service_download_new(vttin->service, url, 0, VTT_NetIO, plug); if (!vttin->dnload) { vttin->needs_connection = GF_FALSE; - gf_term_on_connect(vttin->service, NULL, GF_NOT_SUPPORTED); + gf_service_connect_ack(vttin->service, NULL, GF_NOT_SUPPORTED); } else { /*start our download (threaded)*/ gf_dm_sess_process(vttin->dnload); @@ -134,11 +134,11 @@ static GF_Err VTT_ConnectService(GF_InputService *plug, GF_ClientService *serv, { GF_Err e; VTTIn *vttin = (VTTIn *)plug->priv; - if (!plug || !url) - return GF_BAD_PARAM; + if (!plug || !url) + return GF_BAD_PARAM; vttin->service = serv; - if (vttin->dnload) gf_term_download_del(vttin->dnload); + if (vttin->dnload) gf_service_download_del(vttin->dnload); vttin->dnload = NULL; /*remote fetch*/ @@ -148,7 +148,7 @@ static GF_Err VTT_ConnectService(GF_InputService *plug, GF_ClientService *serv, } else { e = GF_OK; //e = TTIn_LoadFile(plug, url, 0); - gf_term_on_connect(serv, NULL, e); + gf_service_connect_ack(serv, NULL, e); //if (!e && !vttin->od_done) tti_setup_object(vttin); } return GF_OK; @@ -158,7 +158,7 @@ static GF_Err VTT_CloseService(GF_InputService *plug) { VTTIn *vttin; if (!plug) return GF_BAD_PARAM; - + vttin = (VTTIn *)plug->priv; if (!vttin) return GF_BAD_PARAM; @@ -169,15 +169,15 @@ static GF_Err VTT_CloseService(GF_InputService *plug) //vttin->szFile = NULL; if (vttin->dnload) { - gf_term_download_del(vttin->dnload); + gf_service_download_del(vttin->dnload); } vttin->dnload = NULL; if (vttin->service) { - gf_term_on_disconnect(vttin->service, NULL, GF_OK); + gf_service_disconnect_ack(vttin->service, NULL, GF_OK); } vttin->service = NULL; - + return GF_OK; } @@ -225,7 +225,7 @@ static GF_Err VTT_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, co } exit: - gf_term_on_connect(vttin->service, channel, e); + gf_service_connect_ack(vttin->service, channel, e); return e; } @@ -240,7 +240,7 @@ static GF_Err VTT_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) vttin->channel = NULL; e = GF_OK; } - gf_term_on_disconnect(vttin->service, channel, e); + gf_service_disconnect_ack(vttin->service, channel, e); return GF_OK; } @@ -361,7 +361,7 @@ void DeleteVTTInput(void *ifce) if (!plug) return; vttin = (VTTIn *)plug->priv; - if (vttin){ + if (vttin) { VTT_CloseService(plug); gf_free(vttin); } @@ -379,10 +379,13 @@ GPAC_MODULE_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { - case GF_SCENE_DECODER_INTERFACE: return (GF_BaseInterface *)NewVTTDec(); - case GF_NET_CLIENT_INTERFACE: return (GF_BaseInterface *)NewVTTInput(); + case GF_SCENE_DECODER_INTERFACE: + return (GF_BaseInterface *)NewVTTDec(); + case GF_NET_CLIENT_INTERFACE: + return (GF_BaseInterface *)NewVTTInput(); // case GF_JS_USER_EXT_INTERFACE: return (GF_BaseInterface *)NewVTTJS(); - default: return NULL; + default: + return NULL; } } @@ -398,9 +401,9 @@ void ShutdownInterface(GF_BaseInterface *ifce) case GF_NET_CLIENT_INTERFACE: DeleteVTTInput(ifce); break; - //case GF_JS_USER_EXT_INTERFACE: - // DeleteVTTJS(ifce); - // break; + //case GF_JS_USER_EXT_INTERFACE: + // DeleteVTTJS(ifce); + // break; } } diff --git a/modules/wav_out/wav_out.c b/modules/wav_out/wav_out.c index 45c8d12..c0dbca8 100644 --- a/modules/wav_out/wav_out.c +++ b/modules/wav_out/wav_out.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ @@ -29,7 +29,7 @@ #define MAX_AUDIO_BUFFER 30 -typedef struct +typedef struct { HWAVEOUT hwo; WAVEHDR wav_hdr[MAX_AUDIO_BUFFER]; @@ -91,15 +91,15 @@ typedef struct #ifndef _WAVEFORMATEXTENSIBLE_ typedef struct { - WAVEFORMATEX Format; - union { - WORD wValidBitsPerSample; /* bits of precision */ - WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */ - WORD wReserved; /* If neither applies, set to zero. */ - } Samples; - DWORD dwChannelMask; /* which channels are */ - /* present in stream */ - GUID SubFormat; + WAVEFORMATEX Format; + union { + WORD wValidBitsPerSample; /* bits of precision */ + WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */ + WORD wReserved; /* If neither applies, set to zero. */ + } Samples; + DWORD dwChannelMask; /* which channels are */ + /* present in stream */ + GUID SubFormat; } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; #endif @@ -134,14 +134,14 @@ static void CALLBACK WaveProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD d if (uMsg != WOM_DONE) return; if (ctx->exit_request) return; SetEvent(ctx->event); -} +} static void close_waveform(GF_AudioOutput *dr) { WAVCTX(); - if (!ctx->event) return; + if (!ctx->event) return; /*brute-force version, actually much safer on winCE*/ #ifdef _WIN32_WCE @@ -151,7 +151,7 @@ static void close_waveform(GF_AudioOutput *dr) waveOutClose(ctx->hwo); if (ctx->wav_buf) gf_free(ctx->wav_buf); ctx->wav_buf = NULL; - CloseHandle(ctx->event); + CloseHandle(ctx->event); ctx->event = NULL; ctx->exit_request = 0; #else @@ -182,7 +182,7 @@ static void close_waveform(GF_AudioOutput *dr) } if (ctx->wav_buf) gf_free(ctx->wav_buf); ctx->wav_buf = NULL; - CloseHandle(ctx->event); + CloseHandle(ctx->event); ctx->event = NULL; ctx->exit_request = 0; #endif @@ -222,7 +222,7 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh ctx->fmt.wBitsPerSample = *nbBitsPerSample; ctx->fmt.nSamplesPerSec = *SampleRate; ctx->fmt.nBlockAlign = ctx->fmt.wBitsPerSample * ctx->fmt.nChannels / 8; - ctx->fmt.nAvgBytesPerSec = *SampleRate * ctx->fmt.nBlockAlign; + ctx->fmt.nAvgBytesPerSec = *SampleRate * ctx->fmt.nBlockAlign; fmt = &ctx->fmt; #ifdef USE_WAVE_EXT @@ -247,12 +247,12 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh } #endif - /* Open a waveform device for output using window callback. */ + /* Open a waveform device for output using window callback. */ retry = 10; - while (retry) { - hr = waveOutOpen((LPHWAVEOUT)&ctx->hwo, WAVE_MAPPER, &ctx->fmt, (DWORD) WaveProc, (DWORD) dr, - CALLBACK_FUNCTION | WAVE_ALLOWSYNC | WAVE_FORMAT_DIRECT - ); + while (retry) { + hr = waveOutOpen((LPHWAVEOUT)&ctx->hwo, WAVE_MAPPER, &ctx->fmt, (DWORD) WaveProc, (DWORD) dr, + CALLBACK_FUNCTION | WAVE_ALLOWSYNC | WAVE_FORMAT_DIRECT + ); if (hr == MMSYSERR_NOERROR) break; /*couldn't open audio*/ @@ -270,7 +270,7 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh ctx->buffer_size = (ctx->fmt.nAvgBytesPerSec * ctx->cfg_duration) / (1000 * ctx->cfg_num_buffers); } - ctx->event = CreateEvent( NULL, FALSE, FALSE, NULL); + ctx->event = CreateEvent( NULL, FALSE, FALSE, NULL); /*make sure we're aligned*/ while (ctx->buffer_size % ctx->fmt.nBlockAlign) ctx->buffer_size++; @@ -281,7 +281,7 @@ static GF_Err WAV_ConfigureOutput(GF_AudioOutput *dr, u32 *SampleRate, u32 *NbCh /*setup wave headers*/ for (i=0 ; i < ctx->num_buffers; i++) { memset(& ctx->wav_hdr[i], 0, sizeof(WAVEHDR)); - ctx->wav_hdr[i].dwBufferLength = ctx->buffer_size; + ctx->wav_hdr[i].dwBufferLength = ctx->buffer_size; ctx->wav_hdr[i].lpData = & ctx->wav_buf[i*ctx->buffer_size]; ctx->wav_hdr[i].dwFlags = WHDR_DONE; waveOutPrepareHeader(ctx->hwo, &ctx->wav_hdr[i], sizeof(WAVEHDR)); @@ -320,7 +320,7 @@ static void WAV_WriteAudio(GF_AudioOutput *dr) /*fill it*/ hdr->dwBufferLength = dr->FillBuffer(dr->audio_renderer, hdr->lpData, ctx->buffer_size); hdr->dwFlags = 0; - hr = waveOutPrepareHeader(ctx->hwo, hdr, sizeof(WAVEHDR)); + hr = waveOutPrepareHeader(ctx->hwo, hdr, sizeof(WAVEHDR)); /*write it*/ waveOutWrite(ctx->hwo, hdr, sizeof(WAVEHDR)); } @@ -466,13 +466,13 @@ void DeleteWAVRender(void *ifce) } GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_AUDIO_OUTPUT_INTERFACE, 0 }; - return si; + return si; } GPAC_MODULE_EXPORT diff --git a/modules/widgetman/unzip.c b/modules/widgetman/unzip.c index e01826d..4043a92 100644 --- a/modules/widgetman/unzip.c +++ b/modules/widgetman/unzip.c @@ -48,282 +48,281 @@ #endif voidpf ZCALLBACK fopen_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); + voidpf opaque, + const char* filename, + int mode)); uLong ZCALLBACK fread_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); uLong ZCALLBACK fwrite_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); long ZCALLBACK ftell_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); long ZCALLBACK fseek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); int ZCALLBACK fclose_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); int ZCALLBACK ferror_file_func OF(( - voidpf opaque, - voidpf stream)); + voidpf opaque, + voidpf stream)); voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; +voidpf opaque; +const char* filename; +int mode; { - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); - return file; + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen(filename, mode_fopen); + return file; } uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; +voidpf opaque; +voidpf stream; +void* buf; +uLong size; { - uLong ret; - ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; + uLong ret; + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; } uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; +voidpf opaque; +voidpf stream; +const void* buf; +uLong size; { - uLong ret; - ret = (uLong)gf_fwrite(buf, 1, (size_t)size, (FILE *)stream); - return ret; + uLong ret; + ret = (uLong)gf_fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; } long ZCALLBACK ftell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +voidpf opaque; +voidpf stream; { - long ret; - ret = ftell((FILE *)stream); - return ret; + long ret; + ret = ftell((FILE *)stream); + return ret; } long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; +voidpf opaque; +voidpf stream; +uLong offset; +int origin; { - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - fseek((FILE *)stream, offset, fseek_origin); - return ret; + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: + return -1; + } + ret = 0; + fseek((FILE *)stream, offset, fseek_origin); + return ret; } int ZCALLBACK fclose_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +voidpf opaque; +voidpf stream; { - int ret; - ret = fclose((FILE *)stream); - return ret; + int ret; + ret = fclose((FILE *)stream); + return ret; } int ZCALLBACK ferror_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +voidpf opaque; +voidpf stream; { - int ret; - ret = ferror((FILE *)stream); - return ret; + int ret; + ret = ferror((FILE *)stream); + return ret; } void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +zlib_filefunc_def* pzlib_filefunc_def; { - pzlib_filefunc_def->zopen_file = fopen_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell_file = ftell_file_func; - pzlib_filefunc_def->zseek_file = fseek_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; } static int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; +const zlib_filefunc_def* pzlib_filefunc_def; +voidpf filestream; +int *pi; { - unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ZERROR(*pzlib_filefunc_def,filestream)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } + unsigned char c; + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ZERROR(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } } static int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +const zlib_filefunc_def* pzlib_filefunc_def; +voidpf filestream; +uLong *pX; { - uLong x ; - int err; - int i = 0; - - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; + uLong x ; + int err; + int i = 0; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; } static int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +const zlib_filefunc_def* pzlib_filefunc_def; +voidpf filestream; +uLong *pX; { - uLong x ; - int err; - int i = 0; - - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; + uLong x ; + int err; + int i = 0; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; } static uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; +const zlib_filefunc_def* pzlib_filefunc_def; +voidpf filestream; { - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; } @@ -331,191 +330,191 @@ static uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) Translate date/time from Dos format to tm_unz (readable more easilty) */ void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; +uLong ulDosDate; +tm_unz* ptm; { - uLong uDate; - uDate = (uLong)(ulDosDate>>16); - ptm->tm_mday = (uInt)(uDate&0x1f) ; - ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; - - ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } static int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; + pfile_info, + pfile_info_internal, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) +unzFile file; +unz_file_info *pfile_info; +unz_file_info_internal *pfile_info_internal; +char *szFileName; +uLong fileNameBufferSize; +void *extraField; +uLong extraFieldBufferSize; +char *szComment; +uLong commentBufferSize; { - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (ZSEEK(s->z_filefunc, s->filestream, - s->pos_in_central_dir+s->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK){ - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - } - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (ZSEEK(s->z_filefunc, s->filestream, + s->pos_in_central_dir+s->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) { + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + } + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek -= uSizeRead; } - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; } - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; - return err; + return err; } int unzGetCurrentFileInfo(unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize) + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) { return unzlocal_GetCurrentFileInfoInternal(file, pfile_info, NULL, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize); } @@ -526,28 +525,28 @@ int unzGetCurrentFileInfo(unzFile file, return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ int unzGoToNextFile (file) - unzFile file; +unzFile file; { - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } /* @@ -555,32 +554,32 @@ int unzGoToNextFile (file) return UNZ_OK if there is no problem */ int unzGoToFirstFile (file) - unzFile file; +unzFile file; { - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; } int unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; +unzFile file; +unz_global_info *pglobal_info; { - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; } /* @@ -588,40 +587,40 @@ int unzGetGlobalInfo (file,pglobal_info) Return UNZ_CRCERROR if all the file was read but the CRC is not good */ int unzCloseCurrentFile (file) - unzFile file; +unzFile file; { - int err=UNZ_OK; + int err=UNZ_OK; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; - if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && - (!pfile_in_zip_read_info->raw)) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && + (!pfile_in_zip_read_info->raw)) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); - s->pfile_in_zip_read=NULL; + s->pfile_in_zip_read=NULL; - return err; + return err; } @@ -635,102 +634,102 @@ int unzCloseCurrentFile (file) of this unzip package. */ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) - const char *path; - zlib_filefunc_def* pzlib_filefunc_def; +const char *path; +zlib_filefunc_def* pzlib_filefunc_def; { - unz_s us; - unz_s *s; - uLong central_pos,uL; + unz_s us; + unz_s *s; + uLong central_pos,uL; - uLong number_disk; /* number of the current dist, used for + uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used + uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in + uLong number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ - int err=UNZ_OK; - - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&us.z_filefunc); - else - us.z_filefunc = *pzlib_filefunc_def; - - us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, - path, - ZLIB_FILEFUNC_MODE_READ | - ZLIB_FILEFUNC_MODE_EXISTING); - if (us.filestream==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); - if (central_pos==0) - err=UNZ_ERRNO; - - if (ZSEEK(us.z_filefunc, us.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pospfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if (pfile_in_zip_read_info->read_buffer == NULL) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && - (!(pfile_in_zip_read_info->raw))) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - if ((len>pfile_in_zip_read_info->rest_read_compressed+ - pfile_in_zip_read_info->stream.avail_in) && - (pfile_in_zip_read_info->raw)) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_compressed+ - pfile_in_zip_read_info->stream.avail_in; - - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && - (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (ZSEEK(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - if (ZREAD(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->read_buffer, - uReadThis)!=uReadThis) - return UNZ_ERRNO; - - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = - (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } - - if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) - { - uInt uDoCopy,i ; - - if ((pfile_in_zip_read_info->stream.avail_in == 0) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - return (iRead==0) ? UNZ_EOF : iRead; - - if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; - pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) - err = Z_DATA_ERROR; - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); - - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; - - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return iRead; - return err; + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->read_buffer == NULL) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && + (!(pfile_in_zip_read_info->raw))) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + if ((len>pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in) && + (pfile_in_zip_read_info->raw)) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + if (ZREAD(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->read_buffer, + uReadThis)!=uReadThis) + return UNZ_ERRNO; + + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) + { + uInt uDoCopy,i ; + + if ((pfile_in_zip_read_info->stream.avail_in == 0) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + return (iRead==0) ? UNZ_EOF : iRead; + + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0; istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) + err = Z_DATA_ERROR; + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; } /* @@ -896,90 +895,90 @@ int unzReadCurrentFile (file, buf, len) (filename and size of extra field data) */ int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; + poffset_local_extrafield, + psize_local_extrafield) +unz_s* s; +uInt* piSizeVar; +uLong *poffset_local_extrafield; +uInt *psize_local_extrafield; { - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; - if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK){ - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - } - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; + if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; - if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; - - *piSizeVar += (uInt)size_filename; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; - - *piSizeVar += (uInt)size_extra_field; + if (err==UNZ_OK) { + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + } - return err; + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + /* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; + */ + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; } /* @@ -987,122 +986,128 @@ int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, If there is no error and the file is opened, the return value is UNZ_OK. */ int unzOpenCurrentFile3 (file, method, level, raw, password) - unzFile file; - int* method; - int* level; - int raw; - const char* password; +unzFile file; +int* method; +int* level; +int raw; +const char* password; { - int err=UNZ_OK; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ + int err=UNZ_OK; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ if (password != NULL) - return UNZ_PARAMERROR; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - pfile_in_zip_read_info->raw=raw; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if (method!=NULL) - *method = (int)s->cur_file_info.compression_method; - - if (level!=NULL) - { - *level = 6; - switch (s->cur_file_info.flag & 0x06) - { - case 6 : *level = 1; break; - case 4 : *level = 2; break; - case 2 : *level = 9; break; - } - } - - if ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; - pfile_in_zip_read_info->filestream=s->filestream; - pfile_in_zip_read_info->z_filefunc=s->z_filefunc; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if ((s->cur_file_info.compression_method==Z_DEFLATED) && - (!raw)) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - pfile_in_zip_read_info->stream.next_in = (voidpf)0; - pfile_in_zip_read_info->stream.avail_in = 0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - else - { - TRYFREE(pfile_in_zip_read_info); - return err; - } - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the - * size of both compressed and uncompressed data - */ - } - pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; - - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - s->pfile_in_zip_read = pfile_in_zip_read_info; - - return UNZ_OK; + return UNZ_PARAMERROR; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + pfile_in_zip_read_info->raw=raw; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if (method!=NULL) + *method = (int)s->cur_file_info.compression_method; + + if (level!=NULL) + { + *level = 6; + switch (s->cur_file_info.flag & 0x06) + { + case 6 : + *level = 1; + break; + case 4 : + *level = 2; + break; + case 2 : + *level = 9; + break; + } + } + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->filestream=s->filestream; + pfile_in_zip_read_info->z_filefunc=s->z_filefunc; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if ((s->cur_file_info.compression_method==Z_DEFLATED) && + (!raw)) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = (voidpf)0; + pfile_in_zip_read_info->stream.avail_in = 0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + else + { + TRYFREE(pfile_in_zip_read_info); + return err; + } + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + s->pfile_in_zip_read = pfile_in_zip_read_info; + + return UNZ_OK; } /* @@ -1111,19 +1116,19 @@ int unzOpenCurrentFile3 (file, method, level, raw, password) these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzClose (file) - unzFile file; +unzFile file; { - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; - if (s->pfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); + if (s->pfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); - ZCLOSE(s->z_filefunc, s->filestream); - TRYFREE(s); - return UNZ_OK; + ZCLOSE(s->z_filefunc, s->filestream); + TRYFREE(s); + return UNZ_OK; } #ifndef _WIN32_WCE @@ -1132,60 +1137,60 @@ extern int ZEXPORT unzClose (file) As I don't know well Unix, I wait feedback for the unix portion */ int mymkdir(dirname) - const char* dirname; +const char* dirname; { - int ret=0; + int ret=0; #if defined(WIN32) || defined(_WIN32_WCE) - return mkdir(dirname); + return mkdir(dirname); #else - return mkdir (dirname, 700); + return mkdir (dirname, 700); #endif - return ret; + return ret; } int makedir (newdir) - const char *newdir; +const char *newdir; { - char *buffer ; - char *p; - int len = (int)strlen(newdir); - - if (len <= 0) - return 0; - - buffer = (char*)gf_malloc(len+1); - strcpy(buffer,newdir); - - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mymkdir(buffer) == 0) - { - gf_free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mymkdir(buffer) == -1) && (errno == ENOENT)) - { - fprintf(stderr, "couldn't create directory %s\n",buffer); - gf_free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - gf_free(buffer); - return 1; + char *buffer ; + char *p; + int len = (int)strlen(newdir); + + if (len <= 0) + return 0; + + buffer = (char*)gf_malloc(len+1); + strcpy(buffer,newdir); + + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mymkdir(buffer) == 0) + { + gf_free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mymkdir(buffer) == -1) && (errno == ENOENT)) + { + fprintf(stderr, "couldn't create directory %s\n",buffer); + gf_free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + gf_free(buffer); + return 1; } #else int makedir (newdir) @@ -1196,167 +1201,167 @@ int makedir (newdir) int do_extract_currentfile(uf) - unzFile uf; +unzFile uf; { - char filename_inzip[256]; - char* filename_withoutpath; - char* p; - int err=UNZ_OK; - FILE *fout=NULL; - void* buf; - uInt size_buf; - - unz_file_info file_info; - err = unzlocal_GetCurrentFileInfoInternal(uf,&file_info,NULL,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); - - if (err!=UNZ_OK) - { - fprintf(stderr, "error %d with zipfile in unzGetCurrentFileInfo\n",err); - return err; - } - - size_buf = WRITEBUFFERSIZE; - buf = (void*)gf_malloc(size_buf); - if (buf==NULL) - { - fprintf(stderr, "Error allocating memory\n"); - return UNZ_INTERNALERROR; - } - - p = filename_withoutpath = filename_inzip; - while ((*p) != '\0') - { - if (((*p)=='/') || ((*p)=='\\')) - filename_withoutpath = p+1; - p++; - } - - if ((*filename_withoutpath)=='\0') - { + char filename_inzip[256]; + char* filename_withoutpath; + char* p; + int err=UNZ_OK; + FILE *fout=NULL; + void* buf; + uInt size_buf; + + unz_file_info file_info; + err = unzlocal_GetCurrentFileInfoInternal(uf,&file_info,NULL,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); + + if (err!=UNZ_OK) + { + fprintf(stderr, "error %d with zipfile in unzGetCurrentFileInfo\n",err); + return err; + } + + size_buf = WRITEBUFFERSIZE; + buf = (void*)gf_malloc(size_buf); + if (buf==NULL) + { + fprintf(stderr, "Error allocating memory\n"); + return UNZ_INTERNALERROR; + } + + p = filename_withoutpath = filename_inzip; + while ((*p) != '\0') + { + if (((*p)=='/') || ((*p)=='\\')) + filename_withoutpath = p+1; + p++; + } + + if ((*filename_withoutpath)=='\0') + { #ifndef _WIN32_WCE fprintf(stderr, "creating directory: %s\n",filename_inzip); - mymkdir(filename_inzip); + mymkdir(filename_inzip); #endif } - else - { - const char* write_filename; - int skip=0; + else + { + const char* write_filename; + int skip=0; - write_filename = filename_inzip; + write_filename = filename_inzip; err = unzOpenCurrentFile3(uf, NULL, NULL, 0, NULL/*password*/); - if (err!=UNZ_OK) - { - fprintf(stderr, "error %d with zipfile in unzOpenCurrentFilePassword\n",err); - } - - if ((skip==0) && (err==UNZ_OK)) - { - fout=fopen(write_filename,"wb"); - - /* some zipfile don't contain directory alone before file */ - if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip)) - { - char c=*(filename_withoutpath-1); - *(filename_withoutpath-1)='\0'; - makedir(write_filename); - *(filename_withoutpath-1)=c; - fout=fopen(write_filename,"wb"); - } - - if (fout==NULL) - { - fprintf(stderr, "error opening %s\n",write_filename); - } - } - - if (fout!=NULL) - { - fprintf(stderr, " extracting: %s\n",write_filename); - - do - { - err = unzReadCurrentFile(uf,buf,size_buf); - if (err<0) - { - fprintf(stderr, "error %d with zipfile in unzReadCurrentFile\n",err); - break; - } - if (err>0) - if (gf_fwrite(buf,err,1,fout)!=1) - { - fprintf(stderr, "error in writing extracted file\n"); - err=UNZ_ERRNO; - break; - } - } - while (err>0); - if (fout) - fclose(fout); - } - - if (err==UNZ_OK) - { - err = unzCloseCurrentFile (uf); - if (err!=UNZ_OK) - { - fprintf(stderr, "error %d with zipfile in unzCloseCurrentFile\n",err); - } - } - else - unzCloseCurrentFile(uf); /* don't lose the error */ - } - - gf_free(buf); - return err; + if (err!=UNZ_OK) + { + fprintf(stderr, "error %d with zipfile in unzOpenCurrentFilePassword\n",err); + } + + if ((skip==0) && (err==UNZ_OK)) + { + fout=fopen(write_filename,"wb"); + + /* some zipfile don't contain directory alone before file */ + if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip)) + { + char c=*(filename_withoutpath-1); + *(filename_withoutpath-1)='\0'; + makedir(write_filename); + *(filename_withoutpath-1)=c; + fout=fopen(write_filename,"wb"); + } + + if (fout==NULL) + { + fprintf(stderr, "error opening %s\n",write_filename); + } + } + + if (fout!=NULL) + { + fprintf(stderr, " extracting: %s\n",write_filename); + + do + { + err = unzReadCurrentFile(uf,buf,size_buf); + if (err<0) + { + fprintf(stderr, "error %d with zipfile in unzReadCurrentFile\n",err); + break; + } + if (err>0) + if (gf_fwrite(buf,err,1,fout)!=1) + { + fprintf(stderr, "error in writing extracted file\n"); + err=UNZ_ERRNO; + break; + } + } + while (err>0); + if (fout) + fclose(fout); + } + + if (err==UNZ_OK) + { + err = unzCloseCurrentFile (uf); + if (err!=UNZ_OK) + { + fprintf(stderr, "error %d with zipfile in unzCloseCurrentFile\n",err); + } + } + else + unzCloseCurrentFile(uf); /* don't lose the error */ + } + + gf_free(buf); + return err; } int gf_unzip_archive(const char *zipfilename, const char *dirname) { - uLong i; - unz_global_info gi; - int err; - - unzFile uf=NULL; - - uf = unzOpen2(zipfilename, NULL); - if (uf==NULL) - { - fprintf(stderr, "Cannot open %s\n", zipfilename); - return 1; - } + uLong i; + unz_global_info gi; + int err; + + unzFile uf=NULL; + + uf = unzOpen2(zipfilename, NULL); + if (uf==NULL) + { + fprintf(stderr, "Cannot open %s\n", zipfilename); + return 1; + } #ifndef _WIN32_WCE - if (chdir(dirname)) - { - fprintf(stderr, "Error changing into %s, aborting\n", dirname); - exit(-1); - } + if (chdir(dirname)) + { + fprintf(stderr, "Error changing into %s, aborting\n", dirname); + exit(-1); + } #endif - err = unzGetGlobalInfo (uf,&gi); - if (err!=UNZ_OK) - fprintf(stderr, "error %d with zipfile in unzGetGlobalInfo \n",err); - - for (i=0;i0 for sfx)*/ - int raw; + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for gf_f64_seek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + int raw; } file_in_zip_read_info_s; @@ -227,35 +229,35 @@ typedef struct */ typedef struct { - zlib_filefunc_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ - int encrypted; + int encrypted; # ifndef NOUNCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const unsigned long* pcrc_32_tab; # endif } unz_s; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); + const char* fileName2, + int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) @@ -300,8 +302,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); + char *szComment, + uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. @@ -326,8 +328,8 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); */ extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); + const char *szFileName, + int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare @@ -343,8 +345,8 @@ extern int ZEXPORT unzLocateFile OF((unzFile file, /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_pos_s { - uLong pos_in_zip_directory; /* offset in zip file directory */ - uLong num_of_file; /* # of file */ + uLong pos_in_zip_directory; /* offset in zip file directory */ + uLong num_of_file; /* # of file */ } unz_file_pos; extern int ZEXPORT unzGetFilePos( @@ -358,13 +360,13 @@ extern int ZEXPORT unzGoToFilePos( /* ****************************************** */ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about @@ -390,7 +392,7 @@ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); */ extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, - const char* password)); + const char* password)); /* Open for reading data the current file in the zipfile. password is a crypting password @@ -398,9 +400,9 @@ extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, */ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, - int* method, - int* level, - int raw)); + int* method, + int* level, + int raw)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 @@ -411,10 +413,10 @@ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, */ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, - int* method, - int* level, - int raw, - const char* password)); + int* method, + int* level, + int raw, + const char* password)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 @@ -432,8 +434,8 @@ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); */ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); + voidp buf, + unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied @@ -456,8 +458,8 @@ extern int ZEXPORT unzeof OF((unzFile file)); */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); + voidp buf, + unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is diff --git a/modules/widgetman/wgt_load.c b/modules/widgetman/wgt_load.c index 72c1c60..db1e24b 100644 --- a/modules/widgetman/wgt_load.c +++ b/modules/widgetman/wgt_load.c @@ -55,7 +55,7 @@ typedef struct } WgtLoad; static GF_Err WGT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 stream_time, u32 mmlevel) + u16 ES_ID, u32 stream_time, u32 mmlevel) { GF_Err e = GF_OK; WgtLoad *wgtload = (WgtLoad *)plug->privateStack; @@ -90,13 +90,13 @@ static GF_Err WGT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 i gf_svg_parse_attribute(n, &info, "0 0 320 240", 0); gf_node_get_attribute_by_name(n, "xmlns", 0, 1, 0, &info); gf_svg_parse_attribute(n, &info, "http://www.w3.org/2000/svg", 0); -/* - gf_sg_set_scene_size_info(wgtload->scene->graph, 800, 600, 1); - gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_width, 1, 0, &info); - gf_svg_parse_attribute(n, &info, "800", 0); - gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_height, 1, 0, &info); - gf_svg_parse_attribute(n, &info, "600", 0); -*/ + /* + gf_sg_set_scene_size_info(wgtload->scene->graph, 800, 600, 1); + gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_width, 1, 0, &info); + gf_svg_parse_attribute(n, &info, "800", 0); + gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_height, 1, 0, &info); + gf_svg_parse_attribute(n, &info, "600", 0); + */ gf_node_init(n); n = gf_node_new(wgtload->scene->graph, TAG_SVG_animation); @@ -126,15 +126,15 @@ static GF_Err WGT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 i gf_svg_parse_attribute(n, &info, (char *) path, 0); } else { const char *load_fun = "function load_widget(wid_url) {\n" - " var wid = WidgetManager.load(wid_url);\n" - " var anim = document.getElementById('w_anim');\n" - " if (wid != null) {\n" - " wid.activate(anim);" - " anim.setAttributeNS('http://www.w3.org/1999/xlink', 'href', wid.main);\n" - " } else {\n" - " alert('Widget ' + wid_url + ' is not valid');\n" - " }\n" - "}\n"; + " var wid = WidgetManager.load(wid_url);\n" + " var anim = document.getElementById('w_anim');\n" + " if (wid != null) {\n" + " wid.activate(anim);" + " anim.setAttributeNS('http://www.w3.org/1999/xlink', 'href', wid.main);\n" + " } else {\n" + " alert('Widget ' + wid_url + ' is not valid');\n" + " }\n" + "}\n"; gf_dom_add_text_node(n, gf_strdup(load_fun) ); } @@ -290,12 +290,12 @@ void ShutdownWidgetReader(GF_BaseInterface *ifce) { GF_SceneDecoder *sdec = (GF_SceneDecoder *)ifce; WgtLoad *wgtload; - if (!ifce) - return; - wgtload = (WgtLoad *) sdec->privateStack; - if (wgtload) - gf_free(wgtload); - sdec->privateStack = NULL; + if (!ifce) + return; + wgtload = (WgtLoad *) sdec->privateStack; + if (wgtload) + gf_free(wgtload); + sdec->privateStack = NULL; gf_free(sdec); } diff --git a/modules/widgetman/widget.c b/modules/widgetman/widget.c index 0bd8c5b..395c98e 100644 --- a/modules/widgetman/widget.c +++ b/modules/widgetman/widget.c @@ -1,7 +1,7 @@ //This software module was originally developed by TelecomParisTech in the //course of the development of MPEG-U Widgets (ISO/IEC 23007-1) standard. // -//This software module is an implementation of a part of one or +//This software module is an implementation of a part of one or //more MPEG-U Widgets (ISO/IEC 23007-1) tools as specified by the MPEG-U Widgets //(ISO/IEC 23007-1) standard. ISO/IEC gives users of the MPEG-U Widgets //(ISO/IEC 23007-1) free license to this software module or modifications @@ -10,13 +10,13 @@ //module in hardware or software products are advised that its use may //infringe existing patents. //The original developer of this software module and his/her company, the -//subsequent editors and their companies, and ISO/IEC have no liability -//for use of this software module or modifications thereof in an implementation. -//Copyright is not released for non MPEG-U Widgets (ISO/IEC 23007-1) conforming -//products. -//Telecom ParisTech retains full right to use the code for his/her own purpose, -//assign or donate the code to a third party and to inhibit third parties from -//using the code for non MPEG-U Widgets (ISO/IEC 23007-1) conforming products. +//subsequent editors and their companies, and ISO/IEC have no liability +//for use of this software module or modifications thereof in an implementation. +//Copyright is not released for non MPEG-U Widgets (ISO/IEC 23007-1) conforming +//products. +//Telecom ParisTech retains full right to use the code for his/her own purpose, +//assign or donate the code to a third party and to inhibit third parties from +//using the code for non MPEG-U Widgets (ISO/IEC 23007-1) conforming products. // //This copyright notice must be included in all copies or derivative works. // @@ -32,7 +32,7 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Authors: +// Authors: // Jean Le Feuvre, Telecom ParisTech // ///////////////////////////////////////////////////////////////////////////////// @@ -105,7 +105,7 @@ JSBool SMJS_FUNCTION(widget_show_notification) u32 i; vars = gf_malloc(sizeof(jsval)*(argc+1)); vars[0] = OBJECT_TO_JSVAL(wid->obj); - for (i=0; iwidget->wm->obj, fval, argc+1, vars, SMJS_GET_RVAL); @@ -166,7 +166,7 @@ static JSBool SMJS_FUNCTION(widget_message_handler_factory) if ((argc==2) && JSVAL_IS_OBJECT(argv[1]) && !JSVAL_IS_NULL(argv[1])) JS_DefineProperty(c, an_obj, "replyCallback", argv[1], 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - + SMJS_SET_RVAL( OBJECT_TO_JSVAL(an_obj) ); } } @@ -287,7 +287,7 @@ static JSBool SMJS_FUNCTION_EXT(widget_activate_component, Bool is_deactivate) for (i=0; iwidget->main->components, i); if (!comp->id || strcmp(comp->id, comp_id)) continue; - + if (is_deactivate) { wm_deactivate_component(c, wid, comp, NULL); } else { @@ -317,7 +317,7 @@ void widget_on_interface_bind(GF_WidgetInterfaceInstance *ifce, Bool unbind) if (!ifce || !ifce->wid || !ifce->wid->scene_context) return; /*look for JS Callback "invoke" in the widget manager script*/ - if (JS_LookupProperty(ifce->wid->scene_context, ifce->wid->scene_obj, fun_name, &funval)!=JS_TRUE) + if (JS_LookupProperty(ifce->wid->scene_context, ifce->wid->scene_obj, fun_name, &funval)!=JS_TRUE) return; if (!JSVAL_IS_OBJECT(funval)) return; @@ -329,67 +329,67 @@ void widget_on_interface_bind(GF_WidgetInterfaceInstance *ifce, Bool unbind) SMJS_FUNC_PROP_GET(widget_getProperty) - const char *opt; - char *prop_name; - GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); - if (!wid) return JS_FALSE; +const char *opt; +char *prop_name; +GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); +if (!wid) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!prop_name) return JS_FALSE; +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!prop_name) return JS_FALSE; - if (!strcmp(prop_name, "viewMode")) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "floating") ); - } - else if (!strcmp(prop_name, "locale")) { - opt = gf_cfg_get_key(wid->widget->wm->term->user->config, "Systems", "Language2CC"); - if (!opt) opt = "und"; - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, opt) ); - } - else if (!strcmp(prop_name, "identifier")) { - if (wid->widget->identifier) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->identifier) ); - } - else if (!strcmp(prop_name, "authorName")) { - if (wid->widget->authorName) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorName) ); - } - else if (!strcmp(prop_name, "authorEmail")) { - if (wid->widget->authorEmail) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorEmail) ); - } - else if (!strcmp(prop_name, "authorHref")) { - if (wid->widget->authorHref) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorHref) ); - } - else if (!strcmp(prop_name, "name")) { - if (wid->widget->name) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->name) ); - } - else if (!strcmp(prop_name, "version")) { - if (wid->widget->version) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->version) ); - } - else if (!strcmp(prop_name, "description")) { - if (wid->widget->description) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->description) ); - } - else if (!strcmp(prop_name, "width")) { - opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, "width"); - *vp = INT_TO_JSVAL( (opt ? atoi(opt) : 0) ); - } - else if (!strcmp(prop_name, "height")) { - opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, "height"); - *vp = INT_TO_JSVAL( (opt ? atoi(opt) : 0) ); - } - else if (!strcmp(prop_name, "preferences")) { - } - SMJS_FREE(c, prop_name); - return JS_TRUE; +if (!strcmp(prop_name, "viewMode")) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "floating") ); +} +else if (!strcmp(prop_name, "locale")) { + opt = gf_cfg_get_key(wid->widget->wm->term->user->config, "Systems", "Language2CC"); + if (!opt) opt = "und"; + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, opt) ); +} +else if (!strcmp(prop_name, "identifier")) { + if (wid->widget->identifier) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->identifier) ); +} +else if (!strcmp(prop_name, "authorName")) { + if (wid->widget->authorName) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorName) ); +} +else if (!strcmp(prop_name, "authorEmail")) { + if (wid->widget->authorEmail) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorEmail) ); +} +else if (!strcmp(prop_name, "authorHref")) { + if (wid->widget->authorHref) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->authorHref) ); +} +else if (!strcmp(prop_name, "name")) { + if (wid->widget->name) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->name) ); +} +else if (!strcmp(prop_name, "version")) { + if (wid->widget->version) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->version) ); +} +else if (!strcmp(prop_name, "description")) { + if (wid->widget->description) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, wid->widget->description) ); +} +else if (!strcmp(prop_name, "width")) { + opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, "width"); + *vp = INT_TO_JSVAL( (opt ? atoi(opt) : 0) ); +} +else if (!strcmp(prop_name, "height")) { + opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, "height"); + *vp = INT_TO_JSVAL( (opt ? atoi(opt) : 0) ); +} +else if (!strcmp(prop_name, "preferences")) { +} +SMJS_FREE(c, prop_name); +return JS_TRUE; } -SMJS_FUNC_PROP_SET( widget_setProperty) +SMJS_FUNC_PROP_SET( widget_setProperty) - /*avoids GCC warning*/ - if (!obj) obj = NULL; +/*avoids GCC warning*/ +if (!obj) obj = NULL; #ifndef GPAC_CONFIG_DARWIN - if (!id) id=0; +if (!id) id=0; #endif - if (!vp) vp=0; - return JS_TRUE; +if (!vp) vp=0; +return JS_TRUE; } void widget_load(GF_WidgetManager *wm, GF_SceneGraph *scene, JSContext *c, JSObject *global, Bool unload) @@ -439,7 +439,7 @@ void widget_load(GF_WidgetManager *wm, GF_SceneGraph *scene, JSContext *c, JSObj GF_JS_InitClass(c, global, 0, &wm->widgetClass, 0, 0,widgetClassProps, widgetClassFuncs, 0, 0); - + wi->scene_obj = JS_DefineObject(c, global, "widget", &wm->widgetClass._class, 0, 0); //JS_AliasProperty(c, global, "widget", "MPEGWidget"); SMJS_SET_PRIVATE(c, wi->scene_obj, wi); diff --git a/modules/widgetman/widgetman.c b/modules/widgetman/widgetman.c index a9dc711..c74a2f8 100644 --- a/modules/widgetman/widgetman.c +++ b/modules/widgetman/widgetman.c @@ -151,7 +151,7 @@ static Bool package_find_res(GF_WidgetPackage *wpack, char *res_path, char *relo { u32 count, i; count = gf_list_count(wpack->resources); - for (i=0;iresources, i); if (is_same_path(res_path, pack_res->inner_path, 0)) { strcpy(localized_rel_path, res_path); @@ -409,7 +409,7 @@ static GF_WidgetPackage *widget_zip_new(GF_WidgetManager *wm, const char *path) } if ((i+1)interfaces)) { - GF_WidgetInterface*ifce = gf_list_last(content->interfaces); - gf_list_rem_last(content->interfaces); + GF_WidgetInterface*ifce = gf_list_last(content->interfaces); + gf_list_rem_last(content->interfaces); - while (gf_list_count(ifce->messages)) { + while (gf_list_count(ifce->messages)) { GF_WidgetMessage *msg = gf_list_last(ifce->messages); gf_list_rem_last(ifce->messages); @@ -502,32 +502,32 @@ static void wm_delete_widget_content(GF_WidgetContent *content) gf_list_del(content->interfaces); while (gf_list_count(content->components)) { - GF_WidgetComponent *comp = gf_list_last(content->components); - gf_list_rem_last(content->components); + GF_WidgetComponent *comp = gf_list_last(content->components); + gf_list_rem_last(content->components); - wm_delete_message_param(comp->activateTrigger); - wm_delete_message_param(comp->deactivateTrigger); + wm_delete_message_param(comp->activateTrigger); + wm_delete_message_param(comp->deactivateTrigger); - while (gf_list_count(comp->required_interfaces)) { + while (gf_list_count(comp->required_interfaces)) { char *type = gf_list_last(comp->required_interfaces); gf_list_rem_last(comp->required_interfaces); if (type) gf_free(type); - } - gf_list_del(comp->required_interfaces); - if (comp->id) gf_free(comp->id); - if (comp->src) gf_free(comp->src); - gf_free(comp); + } + gf_list_del(comp->required_interfaces); + if (comp->id) gf_free(comp->id); + if (comp->src) gf_free(comp->src); + gf_free(comp); } gf_list_del(content->components); while (gf_list_count(content->preferences)) { - GF_WidgetPreference *pref = gf_list_last(content->preferences); - gf_list_rem_last(content->preferences); + GF_WidgetPreference *pref = gf_list_last(content->preferences); + gf_list_rem_last(content->preferences); - wm_delete_message_param(pref->connectTo); - if (pref->value) gf_free(pref->value); - gf_free(pref->name); - gf_free(pref); + wm_delete_message_param(pref->connectTo); + if (pref->value) gf_free(pref->value); + gf_free(pref->name); + gf_free(pref); } gf_list_del(content->preferences); @@ -858,9 +858,9 @@ static JSBool wm_widget_set_scene_input_value(JSContext *c, JSObject *obj, uintN //if this is a script eventIn call directly script if ((n->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (n->sgprivate->tag==TAG_X3D_Script) + || (n->sgprivate->tag==TAG_X3D_Script) #endif - ) + ) gf_sg_script_event_in(n, &info); gf_node_changed(n, &info); @@ -952,7 +952,7 @@ static SVG_handlerElement *wm_create_scene_listener(GF_WidgetInstance *wid, GF_W evt_type = GF_EVENT_ATTR_MODIFIED; n = gf_sg_find_node_by_name(wid->scene, param->node); - if (!n) + if (!n) return NULL; att_name = 0; @@ -1465,7 +1465,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_component) comp_id = SMJS_CHARS(c, argv[0]); count = gf_list_count(wid->components); - for (i=0; icomponents, i); if (comp_inst->comp->id && !strcmp(comp_inst->comp->id, comp_id)) { SMJS_SET_RVAL( OBJECT_TO_JSVAL(comp_inst->wid->obj) ); @@ -1582,7 +1582,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_context) count = gf_list_count(wid->widget->main->preferences); for (i=0; iwidget->main->preferences, i); + GF_WidgetPreference *pref = gf_list_get(wid->widget->main->preferences, i); /*preference is read only, do not include in context*/ if (pref->flags & GF_WM_PREF_READONLY) continue; @@ -1609,13 +1609,13 @@ static JSBool SMJS_FUNCTION(wm_widget_get_context) gf_bs_write_data(bs, (const char *) txt, (u32) strlen(txt) ); } else #endif - if (gf_node_get_field_by_name(n, pref->connectTo->attribute, &info)==GF_OK) { - att = gf_node_dump_attribute(n, &info); - if (att) { - gf_bs_write_data(bs, (const char *) att, (u32) strlen(att) ); - gf_free(att); + if (gf_node_get_field_by_name(n, pref->connectTo->attribute, &info)==GF_OK) { + att = gf_node_dump_attribute(n, &info); + if (att) { + gf_bs_write_data(bs, (const char *) att, (u32) strlen(att) ); + gf_free(att); + } } - } } } /*read from config*/ @@ -1646,304 +1646,304 @@ static JSBool SMJS_FUNCTION(wm_widget_get_context) static SMJS_FUNC_PROP_GET( wm_widget_getProperty) - JSString *s; - char *prop_name; - const char *opt; - GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); - if (!wid) return JS_FALSE; +JSString *s; +char *prop_name; +const char *opt; +GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); +if (!wid) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!prop_name) return JS_FALSE; +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!prop_name) return JS_FALSE; - /* - Manifest properties - */ - if (!strcmp(prop_name, "manifest")) { - s = JS_NewStringCopyZ(c, wid->widget->manifest_path); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "url")) { - s = JS_NewStringCopyZ(c, wid->widget->local_path ? wid->widget->local_path : wid->widget->url); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "main")) { - s = JS_NewStringCopyZ(c, wid->widget->main->relocated_src); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "localizedSrc")) { - s = JS_NewStringCopyZ(c, wid->widget->main->src); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "mainEncoding")) { - s = JS_NewStringCopyZ(c, wid->widget->main->encoding); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "mainMimeType")) { - s = JS_NewStringCopyZ(c, wid->widget->main->mimetype); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "defaultWidth")) { - *vp = INT_TO_JSVAL(wid->widget->width); - } - else if (!strcmp(prop_name, "defaultHeight")) { - *vp = INT_TO_JSVAL(wid->widget->height); - } - else if (!strcmp(prop_name, "icons")) { - u32 i, count; - JSObject *arr; - count = gf_list_count(wid->widget->icons); - arr = JS_NewArrayObject(c, count, NULL); - for (i = 0; iwidget->icons, i); - if (icon) { - char *abs_reloc_url; - jsval icon_obj_val; - JSObject *icon_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); - SMJS_SET_PRIVATE(c, icon_obj, icon); - JS_DefineProperty(c, icon_obj, "src", STRING_TO_JSVAL( JS_NewStringCopyZ(c, icon->src) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - if (strlen(icon->relocated_src)) abs_reloc_url = gf_url_concatenate(wid->widget->url, icon->relocated_src); - else abs_reloc_url = gf_strdup(""); - JS_DefineProperty(c, icon_obj, "relocated_src", STRING_TO_JSVAL( JS_NewStringCopyZ(c, abs_reloc_url) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, icon_obj, "width", INT_TO_JSVAL( icon->width ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, icon_obj, "height", INT_TO_JSVAL( icon->height ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - icon_obj_val = OBJECT_TO_JSVAL(icon_obj); - JS_SetElement(c, arr, i, &icon_obj_val); - gf_free(abs_reloc_url); - } - } - *vp = OBJECT_TO_JSVAL(arr); - } - else if (!strcmp(prop_name, "preferences")) { - u32 i, count; - JSObject *arr; - count = gf_list_count(wid->widget->main->preferences); - arr = JS_NewArrayObject(c, count, NULL); - for (i = 0; iwidget->main->preferences, i); - if (pref) { - jsval pref_obj_val; - JSObject *pref_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); - SMJS_SET_PRIVATE(c, pref_obj, pref); - JS_DefineProperty(c, pref_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, pref_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, pref_obj, "readonly", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ((pref->flags & GF_WM_PREF_READONLY)?"true":"false")) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - pref_obj_val = OBJECT_TO_JSVAL(pref_obj); - JS_SetElement(c, arr, i, &pref_obj_val); - } +/* + Manifest properties +*/ +if (!strcmp(prop_name, "manifest")) { + s = JS_NewStringCopyZ(c, wid->widget->manifest_path); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "url")) { + s = JS_NewStringCopyZ(c, wid->widget->local_path ? wid->widget->local_path : wid->widget->url); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "main")) { + s = JS_NewStringCopyZ(c, wid->widget->main->relocated_src); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "localizedSrc")) { + s = JS_NewStringCopyZ(c, wid->widget->main->src); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "mainEncoding")) { + s = JS_NewStringCopyZ(c, wid->widget->main->encoding); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "mainMimeType")) { + s = JS_NewStringCopyZ(c, wid->widget->main->mimetype); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "defaultWidth")) { + *vp = INT_TO_JSVAL(wid->widget->width); +} +else if (!strcmp(prop_name, "defaultHeight")) { + *vp = INT_TO_JSVAL(wid->widget->height); +} +else if (!strcmp(prop_name, "icons")) { + u32 i, count; + JSObject *arr; + count = gf_list_count(wid->widget->icons); + arr = JS_NewArrayObject(c, count, NULL); + for (i = 0; iwidget->icons, i); + if (icon) { + char *abs_reloc_url; + jsval icon_obj_val; + JSObject *icon_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); + SMJS_SET_PRIVATE(c, icon_obj, icon); + JS_DefineProperty(c, icon_obj, "src", STRING_TO_JSVAL( JS_NewStringCopyZ(c, icon->src) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + if (strlen(icon->relocated_src)) abs_reloc_url = gf_url_concatenate(wid->widget->url, icon->relocated_src); + else abs_reloc_url = gf_strdup(""); + JS_DefineProperty(c, icon_obj, "relocated_src", STRING_TO_JSVAL( JS_NewStringCopyZ(c, abs_reloc_url) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, icon_obj, "width", INT_TO_JSVAL( icon->width ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, icon_obj, "height", INT_TO_JSVAL( icon->height ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + icon_obj_val = OBJECT_TO_JSVAL(icon_obj); + JS_SetElement(c, arr, i, &icon_obj_val); + gf_free(abs_reloc_url); + } + } + *vp = OBJECT_TO_JSVAL(arr); +} +else if (!strcmp(prop_name, "preferences")) { + u32 i, count; + JSObject *arr; + count = gf_list_count(wid->widget->main->preferences); + arr = JS_NewArrayObject(c, count, NULL); + for (i = 0; iwidget->main->preferences, i); + if (pref) { + jsval pref_obj_val; + JSObject *pref_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); + SMJS_SET_PRIVATE(c, pref_obj, pref); + JS_DefineProperty(c, pref_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, pref_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, pref_obj, "readonly", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ((pref->flags & GF_WM_PREF_READONLY)?"true":"false")) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + pref_obj_val = OBJECT_TO_JSVAL(pref_obj); + JS_SetElement(c, arr, i, &pref_obj_val); } - *vp = OBJECT_TO_JSVAL(arr); } - else if (!strcmp(prop_name, "features")) { - u32 i, count; - JSObject *arr; - count = gf_list_count(wid->widget->features); - arr = JS_NewArrayObject(c, count, NULL); - for (i = 0; iwidget->features, i); - if (feat) { - jsval feat_obj_val; - JSObject *feat_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); - SMJS_SET_PRIVATE(c, feat_obj, feat); - JS_DefineProperty(c, feat_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, feat->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, feat_obj, "required", BOOLEAN_TO_JSVAL( (feat->required? JS_TRUE : JS_FALSE) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - { - u32 j, pcount; - JSObject *params_arr; - pcount = gf_list_count(feat->params); - params_arr = JS_NewArrayObject(c, pcount, NULL); - for (j=0; j < pcount; j++) { - GF_WidgetFeatureParam *param = gf_list_get(feat->params, j); - JSObject *param_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); - jsval param_obj_val; - SMJS_SET_PRIVATE(c, param_obj, param); - JS_DefineProperty(c, param_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineProperty(c, param_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - param_obj_val = OBJECT_TO_JSVAL(param_obj); - JS_SetElement(c, params_arr, j, ¶m_obj_val); - } - JS_DefineProperty(c, feat_obj, "params", OBJECT_TO_JSVAL(params_arr), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + *vp = OBJECT_TO_JSVAL(arr); +} +else if (!strcmp(prop_name, "features")) { + u32 i, count; + JSObject *arr; + count = gf_list_count(wid->widget->features); + arr = JS_NewArrayObject(c, count, NULL); + for (i = 0; iwidget->features, i); + if (feat) { + jsval feat_obj_val; + JSObject *feat_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); + SMJS_SET_PRIVATE(c, feat_obj, feat); + JS_DefineProperty(c, feat_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, feat->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, feat_obj, "required", BOOLEAN_TO_JSVAL( (feat->required? JS_TRUE : JS_FALSE) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + { + u32 j, pcount; + JSObject *params_arr; + pcount = gf_list_count(feat->params); + params_arr = JS_NewArrayObject(c, pcount, NULL); + for (j=0; j < pcount; j++) { + GF_WidgetFeatureParam *param = gf_list_get(feat->params, j); + JSObject *param_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass._class, 0, 0); + jsval param_obj_val; + SMJS_SET_PRIVATE(c, param_obj, param); + JS_DefineProperty(c, param_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineProperty(c, param_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + param_obj_val = OBJECT_TO_JSVAL(param_obj); + JS_SetElement(c, params_arr, j, ¶m_obj_val); } - feat_obj_val = OBJECT_TO_JSVAL(feat_obj); - JS_SetElement(c, arr, i, &feat_obj_val); + JS_DefineProperty(c, feat_obj, "params", OBJECT_TO_JSVAL(params_arr), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); } + feat_obj_val = OBJECT_TO_JSVAL(feat_obj); + JS_SetElement(c, arr, i, &feat_obj_val); } - *vp = OBJECT_TO_JSVAL(arr); } + *vp = OBJECT_TO_JSVAL(arr); +} - else if (!strcmp(prop_name, "components")) { - u32 i, count; - jsval val; - JSObject *arr; - count = gf_list_count(wid->components); - arr = JS_NewArrayObject(c, count, NULL); - for (i = 0; icomponents, i); - val = OBJECT_TO_JSVAL(comp->wid->obj); - JS_SetElement(c, arr, i, &val); - } - *vp = OBJECT_TO_JSVAL(arr); - } - else if (!strcmp(prop_name, "identifier")) { - s = JS_NewStringCopyZ(c, wid->widget->identifier); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "name")) { - s = JS_NewStringCopyZ(c, wid->widget->name); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "shortName")) { - s = JS_NewStringCopyZ(c, wid->widget->shortname); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "authorName")) { - s = JS_NewStringCopyZ(c, wid->widget->authorName); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "authorEmail")) { - s = JS_NewStringCopyZ(c, wid->widget->authorEmail); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "authorHref")) { - s = JS_NewStringCopyZ(c, wid->widget->authorHref); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "description")) { - s = JS_NewStringCopyZ(c, wid->widget->description); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "viewmodes")) { - if (wid->widget->viewmodes) s = JS_NewStringCopyZ(c, wid->widget->viewmodes); - else s = JS_NewStringCopyZ(c, ""); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "license")) { - s = JS_NewStringCopyZ(c, wid->widget->license); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "licenseHref")) { - s = JS_NewStringCopyZ(c, wid->widget->licenseHref); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "version")) { - s = JS_NewStringCopyZ(c, wid->widget->version); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "uuid")) { - s = JS_NewStringCopyZ(c, wid->widget->uuid); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "discardable")) { - *vp = BOOLEAN_TO_JSVAL( wid->widget->discardable ? JS_TRUE : JS_FALSE); - } - else if (!strcmp(prop_name, "multipleInstances")) { - *vp = BOOLEAN_TO_JSVAL( wid->widget->multipleInstance ? JS_TRUE : JS_FALSE); +else if (!strcmp(prop_name, "components")) { + u32 i, count; + jsval val; + JSObject *arr; + count = gf_list_count(wid->components); + arr = JS_NewArrayObject(c, count, NULL); + for (i = 0; icomponents, i); + val = OBJECT_TO_JSVAL(comp->wid->obj); + JS_SetElement(c, arr, i, &val); } + *vp = OBJECT_TO_JSVAL(arr); +} +else if (!strcmp(prop_name, "identifier")) { + s = JS_NewStringCopyZ(c, wid->widget->identifier); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "name")) { + s = JS_NewStringCopyZ(c, wid->widget->name); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "shortName")) { + s = JS_NewStringCopyZ(c, wid->widget->shortname); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "authorName")) { + s = JS_NewStringCopyZ(c, wid->widget->authorName); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "authorEmail")) { + s = JS_NewStringCopyZ(c, wid->widget->authorEmail); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "authorHref")) { + s = JS_NewStringCopyZ(c, wid->widget->authorHref); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "description")) { + s = JS_NewStringCopyZ(c, wid->widget->description); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "viewmodes")) { + if (wid->widget->viewmodes) s = JS_NewStringCopyZ(c, wid->widget->viewmodes); + else s = JS_NewStringCopyZ(c, ""); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "license")) { + s = JS_NewStringCopyZ(c, wid->widget->license); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "licenseHref")) { + s = JS_NewStringCopyZ(c, wid->widget->licenseHref); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "version")) { + s = JS_NewStringCopyZ(c, wid->widget->version); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "uuid")) { + s = JS_NewStringCopyZ(c, wid->widget->uuid); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "discardable")) { + *vp = BOOLEAN_TO_JSVAL( wid->widget->discardable ? JS_TRUE : JS_FALSE); +} +else if (!strcmp(prop_name, "multipleInstances")) { + *vp = BOOLEAN_TO_JSVAL( wid->widget->multipleInstance ? JS_TRUE : JS_FALSE); +} - /* - Widget Manager special properties (common to all implementations) - */ - else if (!strcmp(prop_name, "permanent")) { - *vp = BOOLEAN_TO_JSVAL( wid->permanent ? JS_TRUE : JS_FALSE); - } - else if (!strcmp(prop_name, "is_component")) { - *vp = BOOLEAN_TO_JSVAL( wid->parent ? JS_TRUE : JS_FALSE); - } - else if (!strcmp(prop_name, "parent")) { - *vp = wid->parent ? OBJECT_TO_JSVAL(wid->parent->obj) : JSVAL_NULL; - } - else if (!strcmp(prop_name, "activated")) { - *vp = BOOLEAN_TO_JSVAL( wid->activated ? JS_TRUE : JS_FALSE); - } - else if (!strcmp(prop_name, "section")) { - s = JS_NewStringCopyZ(c, (const char *) wid->secname); - *vp = STRING_TO_JSVAL(s); - } - else if (!strcmp(prop_name, "num_instances")) { - *vp = INT_TO_JSVAL( wid->widget->nb_instances); - } - else if (!strcmp(prop_name, "num_interfaces")) { - *vp = INT_TO_JSVAL( gf_list_count(wid->widget->main->interfaces)); - } - else if (!strcmp(prop_name, "num_components")) { - *vp = INT_TO_JSVAL( gf_list_count(wid->components)); - } - else if (!strcmp(prop_name, "num_bound_interfaces")) { - *vp = INT_TO_JSVAL( gf_list_count(wid->bound_ifces)); - } - /*all variables used by the WidgetManager script but not stored*/ - else if (!strcmp(prop_name, "originating_device_ip") - || !strcmp(prop_name, "originating_device") - || !strcmp(prop_name, "device") - ) { - } - /* - Widget properties, common to each implementation - */ - else { - char szName[1024]; - sprintf(szName, "WM:%s", prop_name); - opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, szName); - if (opt) { - Double val=0; - if (!strcmp(opt, "true")) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); - else if (!strcmp(opt, "false")) *vp = BOOLEAN_TO_JSVAL(JS_FALSE); - else if (sscanf(opt, "%lf", &val)==1) { - *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, val) ); - } else { - s = JS_NewStringCopyZ(c, opt); - *vp = STRING_TO_JSVAL(s); - } +/* + Widget Manager special properties (common to all implementations) +*/ +else if (!strcmp(prop_name, "permanent")) { + *vp = BOOLEAN_TO_JSVAL( wid->permanent ? JS_TRUE : JS_FALSE); +} +else if (!strcmp(prop_name, "is_component")) { + *vp = BOOLEAN_TO_JSVAL( wid->parent ? JS_TRUE : JS_FALSE); +} +else if (!strcmp(prop_name, "parent")) { + *vp = wid->parent ? OBJECT_TO_JSVAL(wid->parent->obj) : JSVAL_NULL; +} +else if (!strcmp(prop_name, "activated")) { + *vp = BOOLEAN_TO_JSVAL( wid->activated ? JS_TRUE : JS_FALSE); +} +else if (!strcmp(prop_name, "section")) { + s = JS_NewStringCopyZ(c, (const char *) wid->secname); + *vp = STRING_TO_JSVAL(s); +} +else if (!strcmp(prop_name, "num_instances")) { + *vp = INT_TO_JSVAL( wid->widget->nb_instances); +} +else if (!strcmp(prop_name, "num_interfaces")) { + *vp = INT_TO_JSVAL( gf_list_count(wid->widget->main->interfaces)); +} +else if (!strcmp(prop_name, "num_components")) { + *vp = INT_TO_JSVAL( gf_list_count(wid->components)); +} +else if (!strcmp(prop_name, "num_bound_interfaces")) { + *vp = INT_TO_JSVAL( gf_list_count(wid->bound_ifces)); +} +/*all variables used by the WidgetManager script but not stored*/ +else if (!strcmp(prop_name, "originating_device_ip") + || !strcmp(prop_name, "originating_device") + || !strcmp(prop_name, "device") + ) { +} +/* + Widget properties, common to each implementation +*/ +else { + char szName[1024]; + sprintf(szName, "WM:%s", prop_name); + opt = gf_cfg_get_key(wid->widget->wm->term->user->config, (const char *) wid->secname, szName); + if (opt) { + Double val=0; + if (!strcmp(opt, "true")) *vp = BOOLEAN_TO_JSVAL(JS_TRUE); + else if (!strcmp(opt, "false")) *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + else if (sscanf(opt, "%lf", &val)==1) { + *vp = DOUBLE_TO_JSVAL( JS_NewDouble(c, val) ); + } else { + s = JS_NewStringCopyZ(c, opt); + *vp = STRING_TO_JSVAL(s); } } - SMJS_FREE(c, prop_name); - return JS_TRUE; +} +SMJS_FREE(c, prop_name); +return JS_TRUE; } static SMJS_FUNC_PROP_SET( wm_widget_setProperty) - char szVal[32]; - jsdouble val; - char *prop_name; - GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); - if (!wid) return JS_FALSE; +char szVal[32]; +jsdouble val; +char *prop_name; +GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); +if (!wid) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - /*internal to WidgetManager, never stored*/ - if (!strcmp(prop_name, "permanent")) { - wid->permanent = (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? 1 : 0; - } - - /*any widget properties*/ - else { - char szName[1024], *value, *_val = NULL; +/*internal to WidgetManager, never stored*/ +if (!strcmp(prop_name, "permanent")) { + wid->permanent = (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? 1 : 0; +} - if (JSVAL_IS_STRING(*vp)) { - value = _val = SMJS_CHARS(c, *vp); - if (!value) value = ""; - } - else if (JSVAL_IS_BOOLEAN(*vp)) { - strcpy(szVal, (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? "true" : "false"); - value = szVal; - } - else if (JSVAL_IS_NUMBER(*vp)) { - JS_ValueToNumber(c, *vp, &val); - sprintf(szVal, "%f", val); - value = szVal; - } else { - SMJS_FREE(c, prop_name); - return JS_TRUE; - } +/*any widget properties*/ +else { + char szName[1024], *value, *_val = NULL; - sprintf(szName, "WM:%s", prop_name); - gf_cfg_set_key(wid->widget->wm->term->user->config, (const char *) wid->secname, szName, value); - SMJS_FREE(c, _val); + if (JSVAL_IS_STRING(*vp)) { + value = _val = SMJS_CHARS(c, *vp); + if (!value) value = ""; + } + else if (JSVAL_IS_BOOLEAN(*vp)) { + strcpy(szVal, (JSVAL_TO_BOOLEAN(*vp)==JS_TRUE) ? "true" : "false"); + value = szVal; + } + else if (JSVAL_IS_NUMBER(*vp)) { + JS_ValueToNumber(c, *vp, &val); + sprintf(szVal, "%f", val); + value = szVal; + } else { + SMJS_FREE(c, prop_name); + return JS_TRUE; } - SMJS_FREE(c, prop_name); - return JS_TRUE; + sprintf(szName, "WM:%s", prop_name); + gf_cfg_set_key(wid->widget->wm->term->user->config, (const char *) wid->secname, szName, value); + SMJS_FREE(c, _val); +} + +SMJS_FREE(c, prop_name); +return JS_TRUE; } @@ -2231,7 +2231,7 @@ static JSBool SMJS_FUNCTION(wm_load) GF_WidgetInstance *parent_widget; if (!GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[1]), &wm->wmWidgetClass, NULL) ) return JS_FALSE; parent_widget = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[1]) ); - + if (parent_widget->widget->url) url = gf_url_concatenate(parent_widget->widget->url, manifest); } @@ -2313,44 +2313,44 @@ static JSBool SMJS_FUNCTION(wm_unload) static SMJS_FUNC_PROP_GET( wm_getProperty) - char *prop_name; - GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); - if (!wm) return JS_FALSE; +char *prop_name; +GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); +if (!wm) return JS_FALSE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!prop_name) return JS_FALSE; +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!prop_name) return JS_FALSE; - if (!strcmp(prop_name, "num_widgets")) { - *vp = INT_TO_JSVAL(gf_list_count(wm->widget_instances)); - } - else if (!strcmp(prop_name, "last_widget_dir")) { - const char *opt = gf_cfg_get_key(wm->term->user->config, "Widgets", "last_widget_dir"); - if (!opt) opt = "/"; - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, opt)); - } - SMJS_FREE(c, prop_name); - return JS_TRUE; +if (!strcmp(prop_name, "num_widgets")) { + *vp = INT_TO_JSVAL(gf_list_count(wm->widget_instances)); +} +else if (!strcmp(prop_name, "last_widget_dir")) { + const char *opt = gf_cfg_get_key(wm->term->user->config, "Widgets", "last_widget_dir"); + if (!opt) opt = "/"; + *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(c, opt)); +} +SMJS_FREE(c, prop_name); +return JS_TRUE; } static SMJS_FUNC_PROP_SET( wm_setProperty) - char *prop_name; - GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); - if (!wm) return JS_FALSE; +char *prop_name; +GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); +if (!wm) return JS_FALSE; - if (!JSVAL_IS_STRING(*vp)) return JS_TRUE; - if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; - prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); +if (!JSVAL_IS_STRING(*vp)) return JS_TRUE; +if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; +prop_name = SMJS_CHARS_FROM_STRING(c, SMJS_ID_TO_STRING(id)); - if (!strcmp(prop_name, "last_widget_dir")) { - char *v = SMJS_CHARS(c, *vp); - gf_cfg_set_key(wm->term->user->config, "Widgets", "last_widget_dir", v); - SMJS_FREE(c, v); - } - SMJS_FREE(c, prop_name); - return JS_TRUE; +if (!strcmp(prop_name, "last_widget_dir")) { + char *v = SMJS_CHARS(c, *vp); + gf_cfg_set_key(wm->term->user->config, "Widgets", "last_widget_dir", v); + SMJS_FREE(c, v); +} +SMJS_FREE(c, prop_name); +return JS_TRUE; } static JSBool SMJS_FUNCTION(wm_get) @@ -2726,20 +2726,20 @@ static char *wm_get_single_attribute(const char *input) { j = 0; for (i = 0; ins && (!widget_ns_prefix || strcmp(root->ns, widget_ns_prefix) || strcmp(root->name, "widget"))) || - (!root->ns && (widget_ns_prefix || strcmp(root->name, "widget")))) + (!root->ns && (widget_ns_prefix || strcmp(root->name, "widget")))) goto exit; @@ -3183,8 +3183,8 @@ GF_WidgetInstance *wm_load_widget(GF_WidgetManager *wm, const char *path, u32 In i=0; while ((icon = gf_list_enum(root->content, &i))) { if (icon->type==GF_XML_NODE_TYPE && - icon->name && !strcmp(icon->name, "icon") && - ((!widget_ns_prefix && !icon->ns) || !strcmp(widget_ns_prefix, icon->ns))) { + icon->name && !strcmp(icon->name, "icon") && + ((!widget_ns_prefix && !icon->ns) || !strcmp(widget_ns_prefix, icon->ns))) { char *sep; char relocated[GF_MAX_PATH], localized_path[GF_MAX_PATH]; char *icon_width, *icon_height; @@ -3290,8 +3290,8 @@ GF_WidgetInstance *wm_load_widget(GF_WidgetManager *wm, const char *path, u32 In i=0; while ((xml_node = gf_list_enum(root->content, &i))) { if (xml_node->type==GF_XML_NODE_TYPE && - xml_node->name && !strcmp(xml_node->name, "feature") && - ((!widget_ns_prefix && !xml_node->ns) || !strcmp(widget_ns_prefix, xml_node->ns))) { + xml_node->name && !strcmp(xml_node->name, "feature") && + ((!widget_ns_prefix && !xml_node->ns) || !strcmp(widget_ns_prefix, xml_node->ns))) { u32 i, count; Bool already_in = 0; @@ -3328,8 +3328,8 @@ GF_WidgetInstance *wm_load_widget(GF_WidgetManager *wm, const char *path, u32 In j = 0; while ((param_node = gf_list_enum(xml_node->content, &j))) { if (param_node->type==GF_XML_NODE_TYPE && - param_node->name && !strcmp(param_node->name, "param") && - ((!widget_ns_prefix && !param_node->ns) || !strcmp(widget_ns_prefix, param_node->ns))) { + param_node->name && !strcmp(param_node->name, "param") && + ((!widget_ns_prefix && !param_node->ns) || !strcmp(widget_ns_prefix, param_node->ns))) { GF_WidgetFeatureParam *wfp; const char *param_name, *param_value; char *npname, *npvalue; @@ -3550,32 +3550,32 @@ static void widgetmanager_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, { - JSPropertySpec wmWidgetClassProps[] = { - SMJS_PROPERTY_SPEC(0, 0, 0, 0, 0) - }; - JSFunctionSpec wmWidgetClassFuncs[] = { - SMJS_FUNCTION_SPEC("activate", wm_widget_activate, 1), - SMJS_FUNCTION_SPEC("deactivate", wm_widget_deactivate, 0), - SMJS_FUNCTION_SPEC("get_interface", wm_widget_get_interface, 1), - SMJS_FUNCTION_SPEC("bind_output_trigger", wm_widget_bind_output_trigger, 2), - SMJS_FUNCTION_SPEC("set_input", wm_widget_set_input, 2), - SMJS_FUNCTION_SPEC("bind_interface", wm_widget_bind_interface, 2), - SMJS_FUNCTION_SPEC("unbind_interface", wm_widget_unbind_interface, 1), - SMJS_FUNCTION_SPEC("call_input_action", wm_widget_call_input_action, 1), - SMJS_FUNCTION_SPEC("call_input_script", wm_widget_call_input_script, 2), - SMJS_FUNCTION_SPEC("is_interface_bound", wm_widget_is_interface_bound, 1), - SMJS_FUNCTION_SPEC("get_param_value", wm_widget_get_param_value, 1), - SMJS_FUNCTION_SPEC("get_context", wm_widget_get_context, 0), - SMJS_FUNCTION_SPEC("get_component", wm_widget_get_component, 2), - - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - /*setup JS bindings*/ - JS_SETUP_CLASS(wm->wmWidgetClass, "WMWIDGET", JSCLASS_HAS_PRIVATE, wm_widget_getProperty, wm_widget_setProperty, JS_FinalizeStub); - GF_JS_InitClass(c, global, 0, &wm->wmWidgetClass, 0, 0, wmWidgetClassProps, wmWidgetClassFuncs, 0, 0); - - JS_SETUP_CLASS(wm->widgetAnyClass, "WIDGETANY", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - GF_JS_InitClass(c, global, 0, &wm->widgetAnyClass, 0, 0, 0, 0, 0, 0); + JSPropertySpec wmWidgetClassProps[] = { + SMJS_PROPERTY_SPEC(0, 0, 0, 0, 0) + }; + JSFunctionSpec wmWidgetClassFuncs[] = { + SMJS_FUNCTION_SPEC("activate", wm_widget_activate, 1), + SMJS_FUNCTION_SPEC("deactivate", wm_widget_deactivate, 0), + SMJS_FUNCTION_SPEC("get_interface", wm_widget_get_interface, 1), + SMJS_FUNCTION_SPEC("bind_output_trigger", wm_widget_bind_output_trigger, 2), + SMJS_FUNCTION_SPEC("set_input", wm_widget_set_input, 2), + SMJS_FUNCTION_SPEC("bind_interface", wm_widget_bind_interface, 2), + SMJS_FUNCTION_SPEC("unbind_interface", wm_widget_unbind_interface, 1), + SMJS_FUNCTION_SPEC("call_input_action", wm_widget_call_input_action, 1), + SMJS_FUNCTION_SPEC("call_input_script", wm_widget_call_input_script, 2), + SMJS_FUNCTION_SPEC("is_interface_bound", wm_widget_is_interface_bound, 1), + SMJS_FUNCTION_SPEC("get_param_value", wm_widget_get_param_value, 1), + SMJS_FUNCTION_SPEC("get_context", wm_widget_get_context, 0), + SMJS_FUNCTION_SPEC("get_component", wm_widget_get_component, 2), + + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + /*setup JS bindings*/ + JS_SETUP_CLASS(wm->wmWidgetClass, "WMWIDGET", JSCLASS_HAS_PRIVATE, wm_widget_getProperty, wm_widget_setProperty, JS_FinalizeStub); + GF_JS_InitClass(c, global, 0, &wm->wmWidgetClass, 0, 0, wmWidgetClassProps, wmWidgetClassFuncs, 0, 0); + + JS_SETUP_CLASS(wm->widgetAnyClass, "WIDGETANY", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + GF_JS_InitClass(c, global, 0, &wm->widgetAnyClass, 0, 0, 0, 0, 0, 0); } JS_SETUP_CLASS(wm->widgetClass, "MPEGWidget", JSCLASS_HAS_PRIVATE, widget_getProperty, widget_setProperty, JS_FinalizeStub); @@ -3608,21 +3608,21 @@ static GF_JSUserExtension *gwm_new() static void gwm_delete(GF_BaseInterface *ifce) { - GF_WidgetManager *wm; + GF_WidgetManager *wm; GF_JSUserExtension *dr = (GF_JSUserExtension *) ifce; - if (!dr) - return; - wm = dr->udta; - if (!wm) - return; - if (wm->widget_instances) - gf_list_del(wm->widget_instances); - wm->widget_instances = NULL; - if (wm->widgets) - gf_list_del(wm->widgets); - wm->widgets = NULL; + if (!dr) + return; + wm = dr->udta; + if (!wm) + return; + if (wm->widget_instances) + gf_list_del(wm->widget_instances); + wm->widget_instances = NULL; + if (wm->widgets) + gf_list_del(wm->widgets); + wm->widgets = NULL; gf_free(wm); - dr->udta = NULL; + dr->udta = NULL; gf_free(dr); } #endif diff --git a/modules/widgetman/widgetman.h b/modules/widgetman/widgetman.h index b7b5195..8980e32 100644 --- a/modules/widgetman/widgetman.h +++ b/modules/widgetman/widgetman.h @@ -1,7 +1,7 @@ //This software module was originally developed by TelecomParisTech in the //course of the development of MPEG-U Widgets (ISO/IEC 23007-1) standard. // -//This software module is an implementation of a part of one or +//This software module is an implementation of a part of one or //more MPEG-U Widgets (ISO/IEC 23007-1) tools as specified by the MPEG-U Widgets //(ISO/IEC 23007-1) standard. ISO/IEC gives users of the MPEG-U Widgets //(ISO/IEC 23007-1) free license to this software module or modifications @@ -10,13 +10,13 @@ //module in hardware or software products are advised that its use may //infringe existing patents. //The original developer of this software module and his/her company, the -//subsequent editors and their companies, and ISO/IEC have no liability -//for use of this software module or modifications thereof in an implementation. -//Copyright is not released for non MPEG-U Widgets (ISO/IEC 23007-1) conforming -//products. -//Telecom ParisTech retains full right to use the code for his/her own purpose, -//assign or donate the code to a third party and to inhibit third parties from -//using the code for non MPEG-U Widgets (ISO/IEC 23007-1) conforming products. +//subsequent editors and their companies, and ISO/IEC have no liability +//for use of this software module or modifications thereof in an implementation. +//Copyright is not released for non MPEG-U Widgets (ISO/IEC 23007-1) conforming +//products. +//Telecom ParisTech retains full right to use the code for his/her own purpose, +//assign or donate the code to a third party and to inhibit third parties from +//using the code for non MPEG-U Widgets (ISO/IEC 23007-1) conforming products. // //This copyright notice must be included in all copies or derivative works. // @@ -32,7 +32,7 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Authors: +// Authors: // Jean Le Feuvre, Telecom ParisTech // Cyril Concolato, Telecom ParisTech // @@ -96,9 +96,9 @@ typedef struct _widget_manager enum { - GF_WPIN_STRING, - GF_WPIN_INTEGER, - GF_WPIN_NUMBER, + GF_WPIN_STRING, + GF_WPIN_INTEGER, + GF_WPIN_NUMBER, }; typedef struct @@ -124,7 +124,7 @@ typedef struct _widget_package_relocator enum { - GF_WM_PARAM_OUTPUT, + GF_WM_PARAM_OUTPUT, GF_WM_PARAM_INPUT, GF_WM_INPUT_ACTION, GF_WM_OUTPUT_TRIGGER, @@ -143,7 +143,7 @@ enum #define GF_WM_PARAM_SCRIPT_BOOL (u16) 1 #define GF_WM_PARAM_SCRIPT_NUMBER (u16) 2 -typedef struct +typedef struct { struct __widget_message *msg; @@ -203,19 +203,19 @@ enum GF_WM_PREF_MIGRATE = 1<<2, }; -typedef struct +typedef struct { char *name, *value; u32 flags; GF_WidgetPin *connectTo; } GF_WidgetPreference; -typedef struct +typedef struct { char *name, *value; } GF_WidgetFeatureParam; -typedef struct +typedef struct { char *name; Bool required; @@ -255,27 +255,27 @@ typedef struct _widget char *manifest_path; GF_List *icons; -/* - GF_WidgetContent *simple; - char *icon_url; -*/ + /* + GF_WidgetContent *simple; + char *icon_url; + */ GF_WidgetContent *main; GF_WidgetPackage *wpack; /*misc metadata for W3C Widgets API*/ - char *name, *shortname, *identifier, - *authorName, *authorEmail, *authorHref, - *description, *version, - *uuid, *license, *licenseHref, *viewmodes; - + char *name, *shortname, *identifier, + *authorName, *authorEmail, *authorHref, + *description, *version, + *uuid, *license, *licenseHref, *viewmodes; + u32 width, height; GF_List *features; Bool discardable, multipleInstance; - /*when a widget is being received from a remote peer, + /*when a widget is being received from a remote peer, we remember where we locally store it to be able to further remote it This is only supported for packaged widgets*/ char *local_path; @@ -312,7 +312,7 @@ typedef struct _widget_instance } GF_WidgetInstance; -typedef struct +typedef struct { GF_WidgetInterface *ifce; GF_WidgetInstance *wid; @@ -321,7 +321,7 @@ typedef struct JSObject *cookie; } GF_WidgetInterfaceInstance; -typedef struct +typedef struct { GF_WidgetComponent *comp; GF_WidgetInstance *wid; diff --git a/modules/wiiis/wiiis.c b/modules/wiiis/wiiis.c index 179133f..e2d01cc 100644 --- a/modules/wiiis/wiiis.c +++ b/modules/wiiis/wiiis.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2009-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -80,7 +80,7 @@ static Bool WII_RegisterDevice(struct __input_device *ifce, const char *urn, GF_ if (IS_JUST_PRESSED(wm, _b)) { gf_bs_write_int(bs, 1, 1); gf_bs_write_int(bs, 1, 1); } \ else if (IS_RELEASED(wm, _b)) { gf_bs_write_int(bs, 1, 1); gf_bs_write_int(bs, 0, 1); } \ else gf_bs_write_int(bs, 0, 1); \ - + #define WII_PI 3.1415926535898f @@ -100,7 +100,7 @@ static u32 WII_Run(void *par) if (opt) scan_delay = atoi(opt); /*locate the wiimotes*/ - count = wiiuse_find(wii->wiimotes, wii->nb_wiimotes, scan_delay); + count = wiiuse_find(wii->wiimotes, wii->nb_wiimotes, scan_delay); GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[Wii] Found %d wiimotes\n", count)); count = wiiuse_connect(wii->wiimotes, wii->nb_wiimotes); if (count) { @@ -131,24 +131,24 @@ static u32 WII_Run(void *par) } } - while (wii->running) { + while (wii->running) { count = wiiuse_poll(wii->wiimotes, wii->nb_wiimotes); if (!count) { continue; } for (i=0; iwiimotes[i]; - switch (wm->event) { + switch (wm->event) { case WIIUSE_EVENT:/* A generic event occured on the wiimote. */ /*create the data frame*/ bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); /*if not the same wiimote write the UID*/ if (wii->prev_id != wm->unid) { - gf_bs_write_int(bs, 1, 1); - gf_bs_write_int(bs, wm->unid, 32); + gf_bs_write_int(bs, 1, 1); + gf_bs_write_int(bs, wm->unid, 32); wii->prev_id = wm->unid; } else { - gf_bs_write_int(bs, 0, 1); + gf_bs_write_int(bs, 0, 1); } /*write buttons state*/ @@ -165,13 +165,13 @@ static u32 WII_Run(void *par) WRITE_BUTTON(WIIMOTE_BUTTON_UP); /*write yaw-pitch-roll - FIXME: wiiuse seems to output NaN in these values upon init*/ - gf_bs_write_int(bs, 1, 1); + gf_bs_write_int(bs, 1, 1); gf_bs_write_float(bs, WII_PI * wm->orient.yaw / 24 ); gf_bs_write_float(bs, WII_PI * wm->orient.pitch / 180); gf_bs_write_float(bs, WII_PI * wm->orient.roll / 180); /*write gravity - FIXME: wiiuse seems to output NaN in these values upon init*/ - gf_bs_write_int(bs, 1, 1); + gf_bs_write_int(bs, 1, 1); gf_bs_write_float(bs, wm->gforce.x); gf_bs_write_float(bs, wm->gforce.y); gf_bs_write_float(bs, wm->gforce.z); @@ -189,16 +189,16 @@ static u32 WII_Run(void *par) break; case WIIUSE_READ_DATA:/* Data was returned that was previously requested from the wiimote ROM/registers. */ break; - case WIIUSE_NUNCHUK_INSERTED: + case WIIUSE_NUNCHUK_INSERTED: case WIIUSE_NUNCHUK_REMOVED: - case WIIUSE_CLASSIC_CTRL_INSERTED: + case WIIUSE_CLASSIC_CTRL_INSERTED: case WIIUSE_CLASSIC_CTRL_REMOVED: case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED: case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED: break; } } - } + } return 0; } @@ -217,7 +217,7 @@ static void WII_Stop(struct __input_device *ifce) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_INPUT_DEVICE_INTERFACE, @@ -252,7 +252,7 @@ void ShutdownInterface(GF_BaseInterface *bi) GF_WiiMote *wii; GF_InputSensorDevice *ifce = (GF_InputSensorDevice*)bi; if (ifce->InterfaceType!=GF_INPUT_DEVICE_INTERFACE) return; - + wii = ifce->udta; if (wii->wiimotes) { wiiuse_cleanup(wii->wiimotes, wii->nb_wiimotes); diff --git a/modules/x11_out/x11_out.c b/modules/x11_out/x11_out.c index d8ee106..3373612 100644 --- a/modules/x11_out/x11_out.c +++ b/modules/x11_out/x11_out.c @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ static void X11_DestroyOverlay(XWindow *xwin) { if (xwin->overlay) XFree(xwin->overlay); xwin->overlay = NULL; - xwin->xv_pf_format = 0; + xwin->xv_pf_format = 0; if (xwin->xvport>=0) { XvUngrabPort(xwin->display, xwin->xvport, CurrentTime ); xwin->xvport = -1; @@ -99,89 +99,90 @@ static int X11_GetXVideoPort(GF_VideoOutput *vout, u32 pixel_format, Bool check_ unsigned int nb_adaptors; int selected_port; - if (XvQueryExtension(xwin->display, &i, &i, &i, &i, &i ) != Success) return -1; - if (XvQueryAdaptors(xwin->display, DefaultRootWindow(xwin->display), &nb_adaptors, &adaptors) != Success) return -1; + if (XvQueryExtension(xwin->display, &i, &i, &i, &i, &i ) != Success) return -1; + if (XvQueryAdaptors(xwin->display, DefaultRootWindow(xwin->display), &nb_adaptors, &adaptors) != Success) return -1; - selected_port = -1; - for (i=0; i < nb_adaptors; i++) { - XvImageFormatValues *formats; - int j, num_formats, port; + selected_port = -1; + for (i=0; i < nb_adaptors; i++) { + XvImageFormatValues *formats; + int j, num_formats, port; - if( !( adaptors[i].type & XvInputMask ) || !(adaptors[i].type & XvImageMask ) ) - continue; + if( !( adaptors[i].type & XvInputMask ) || !(adaptors[i].type & XvImageMask ) ) + continue; - /* Check for our format... */ - formats = XvListImageFormats(xwin->display, adaptors[i].base_id, &num_formats); + /* Check for our format... */ + formats = XvListImageFormats(xwin->display, adaptors[i].base_id, &num_formats); - for (j=0; jxvport) continue; + /* Grab first port supporting this format */ + for (port=adaptors[i].base_id; (port < (int)(adaptors[i].base_id + adaptors[i].num_ports) ) && (selected_port == -1); port++) { + if (port==xwin->xvport) continue; - attr = XvQueryPortAttributes(xwin->display, port, &nb_attributes); - for (k=0; kdisplay, "XV_COLORKEY", False); - XvGetPortAttribute(xwin->display, port, ckey, &vout->overlay_color_key); - has_color_key = 1; - vout->overlay_color_key |= 0xFF000000; - } -/* else if (!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { - const Atom paint = XInternAtom(xwin->display, "XV_AUTOPAINT_COLORKEY", False); - XvSetPortAttribute(xwin->display, port, paint, 1); + attr = XvQueryPortAttributes(xwin->display, port, &nb_attributes); + for (k=0; kdisplay, "XV_COLORKEY", False); + XvGetPortAttribute(xwin->display, port, ckey, &vout->overlay_color_key); + has_color_key = 1; + vout->overlay_color_key |= 0xFF000000; + } + /* else if (!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { + const Atom paint = XInternAtom(xwin->display, "XV_AUTOPAINT_COLORKEY", False); + XvSetPortAttribute(xwin->display, port, paint, 1); + } + */ } -*/ } - if (check_color && !has_color_key) continue; + if (check_color && !has_color_key) continue; - if (XvGrabPort(xwin->display, port, CurrentTime) == Success) { - selected_port = port; - xwin->xv_pf_format = formats[j].id; + if (XvGrabPort(xwin->display, port, CurrentTime) == Success) { + selected_port = port; + xwin->xv_pf_format = formats[j].id; + } } + if (selected_port == -1 ) + continue; + } - if (selected_port == -1 ) - continue; - - } - if (formats != NULL) XFree(formats); - } - if (nb_adaptors > 0) - XvFreeAdaptorInfo(adaptors); - - return selected_port; + if (formats != NULL) XFree(formats); + } + if (nb_adaptors > 0) + XvFreeAdaptorInfo(adaptors); + + return selected_port; } static GF_Err X11_InitOverlay(GF_VideoOutput *vout, u32 VideoWidth, u32 VideoHeight) { XWindow *xwin = (XWindow *)vout->opaque; if (xwin->overlay && (VideoWidth<=xwin->overlay->width) && (VideoHeight<=xwin->overlay->height)) { - return GF_OK; + return GF_OK; } X11_DestroyOverlay(xwin); xwin->xvport = X11_GetXVideoPort(vout, GF_PIXEL_I420, 0); - if (xwin->xvport<0) + if (xwin->xvport<0) xwin->xvport = X11_GetXVideoPort(vout, GF_PIXEL_YUY2, 0); if (xwin->xvport<0) { return GF_NOT_SUPPORTED; } - /* Create overlay image */ + /* Create overlay image */ xwin->overlay = XvCreateImage(xwin->display, xwin->xvport, xwin->xv_pf_format, NULL, VideoWidth, VideoHeight); if (!xwin->overlay) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Xv Overlay Creation Failure\n")); return GF_IO_ERR; } - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Overlay init %d x %d - pixel format %s - XV port %d\n", - VideoWidth, VideoHeight, - gf_4cc_to_str(vout->yuv_pixel_format), xwin->xvport )); + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Overlay init %d x %d - pixel format %s - XV port %d\n", + VideoWidth, VideoHeight, + gf_4cc_to_str(vout->yuv_pixel_format), xwin->xvport )); return GF_OK; } @@ -216,8 +217,8 @@ GF_Err X11_Blit(struct _video_out *vout, GF_VideoSurface *video_src, GF_Window * if (!xwin->overlay) return GF_IO_ERR; } GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[X11] Blit surface to dest %d x %d - overlay type %s\n", dest->w, dest->h, - (overlay_type==0)? "none" : ((overlay_type==1) ? "Top-Level" : "ColorKey") - )); + (overlay_type==0)? "none" : ((overlay_type==1) ? "Top-Level" : "ColorKey") + )); overlay = xwin->overlay; xvport = xwin->xvport; @@ -239,9 +240,9 @@ GF_Err X11_Blit(struct _video_out *vout, GF_VideoSurface *video_src, GF_Window * } dst_dr = xwin->pixmap; } - XvPutImage(xwin->display, xvport, dst_dr, xwin->the_gc, overlay, - src->x, src->y, src->w, src->h, - dest->x, dest->y, dest->w, dest->h); + XvPutImage(xwin->display, xvport, dst_dr, xwin->the_gc, overlay, + src->x, src->y, src->w, src->h, + dest->x, dest->y, dest->w, dest->h); return GF_OK; } @@ -276,14 +277,14 @@ GF_Err X11_Flush(struct _video_out *vout, GF_Window * dest) } else if (xWindow->use_shared_memory) { XSync(xWindow->display, False); XShmPutImage (xWindow->display, cur_wnd, xWindow->the_gc, xWindow->surface, - 0, 0, dest->x, dest->y, dest->w, dest->h, True); + 0, 0, dest->x, dest->y, dest->w, dest->h, True); } else #endif { XSync(xWindow->display, False); //XRaiseWindow(xWindow->display, xWindow->wnd); XPutImage (xWindow->display, cur_wnd, xWindow->the_gc, xWindow->surface, - 0, 0, dest->x, dest->y, dest->w, dest->h); + 0, 0, dest->x, dest->y, dest->w, dest->h); } return GF_OK; } @@ -299,182 +300,380 @@ static void x11_translate_key(u32 X11Key, GF_EventKey *evt) evt->hw_code = X11Key & 0xFF; switch (X11Key) { - case XK_BackSpace: evt->key_code = GF_KEY_BACKSPACE; break; - case XK_Tab: evt->key_code = GF_KEY_TAB; break; + case XK_BackSpace: + evt->key_code = GF_KEY_BACKSPACE; + break; + case XK_Tab: + evt->key_code = GF_KEY_TAB; + break; //case XK_Linefeed: evt->key_code = GF_KEY_LINEFEED; break; - case XK_Clear: evt->key_code = GF_KEY_CLEAR; break; + case XK_Clear: + evt->key_code = GF_KEY_CLEAR; + break; case XK_KP_Enter: - evt->flags = GF_KEY_EXT_NUMPAD; - case XK_Return: - evt->key_code = GF_KEY_ENTER; - break; - case XK_Pause: evt->key_code = GF_KEY_PAUSE; break; - case XK_Caps_Lock: evt->key_code = GF_KEY_CAPSLOCK; break; - case XK_Scroll_Lock: evt->key_code = GF_KEY_SCROLL; break; - case XK_Escape: evt->key_code = GF_KEY_ESCAPE; break; - case XK_Delete: - evt->key_code = GF_KEY_DEL; - break; - - case XK_Kanji: evt->key_code = GF_KEY_KANJIMODE; break; - case XK_Katakana: evt->key_code = GF_KEY_JAPANESEKATAKANA; break; - case XK_Romaji: evt->key_code = GF_KEY_JAPANESEROMAJI; break; - case XK_Hiragana: evt->key_code = GF_KEY_JAPANESEHIRAGANA; break; - case XK_Kana_Lock: evt->key_code = GF_KEY_KANAMODE; break; - - case XK_Home: evt->key_code = GF_KEY_HOME; break; - case XK_Left: evt->key_code = GF_KEY_LEFT; break; - case XK_Up: evt->key_code = GF_KEY_UP; break; - case XK_Right: evt->key_code = GF_KEY_RIGHT; break; - case XK_Down: evt->key_code = GF_KEY_DOWN; break; - case XK_Page_Up: evt->key_code = GF_KEY_PAGEUP; break; - case XK_Page_Down: evt->key_code = GF_KEY_PAGEDOWN; break; - case XK_End: evt->key_code = GF_KEY_END; break; + evt->flags = GF_KEY_EXT_NUMPAD; + case XK_Return: + evt->key_code = GF_KEY_ENTER; + break; + case XK_Pause: + evt->key_code = GF_KEY_PAUSE; + break; + case XK_Caps_Lock: + evt->key_code = GF_KEY_CAPSLOCK; + break; + case XK_Scroll_Lock: + evt->key_code = GF_KEY_SCROLL; + break; + case XK_Escape: + evt->key_code = GF_KEY_ESCAPE; + break; + case XK_Delete: + evt->key_code = GF_KEY_DEL; + break; + + case XK_Kanji: + evt->key_code = GF_KEY_KANJIMODE; + break; + case XK_Katakana: + evt->key_code = GF_KEY_JAPANESEKATAKANA; + break; + case XK_Romaji: + evt->key_code = GF_KEY_JAPANESEROMAJI; + break; + case XK_Hiragana: + evt->key_code = GF_KEY_JAPANESEHIRAGANA; + break; + case XK_Kana_Lock: + evt->key_code = GF_KEY_KANAMODE; + break; + + case XK_Home: + evt->key_code = GF_KEY_HOME; + break; + case XK_Left: + evt->key_code = GF_KEY_LEFT; + break; + case XK_Up: + evt->key_code = GF_KEY_UP; + break; + case XK_Right: + evt->key_code = GF_KEY_RIGHT; + break; + case XK_Down: + evt->key_code = GF_KEY_DOWN; + break; + case XK_Page_Up: + evt->key_code = GF_KEY_PAGEUP; + break; + case XK_Page_Down: + evt->key_code = GF_KEY_PAGEDOWN; + break; + case XK_End: + evt->key_code = GF_KEY_END; + break; //case XK_Begin: evt->key_code = GF_KEY_BEGIN; break; - case XK_Select: evt->key_code = GF_KEY_SELECT; break; - case XK_Print: evt->key_code = GF_KEY_PRINTSCREEN; break; - case XK_Execute: evt->key_code = GF_KEY_EXECUTE; break; - case XK_Insert: evt->key_code = GF_KEY_INSERT; break; - case XK_Undo: evt->key_code = GF_KEY_UNDO; break; + case XK_Select: + evt->key_code = GF_KEY_SELECT; + break; + case XK_Print: + evt->key_code = GF_KEY_PRINTSCREEN; + break; + case XK_Execute: + evt->key_code = GF_KEY_EXECUTE; + break; + case XK_Insert: + evt->key_code = GF_KEY_INSERT; + break; + case XK_Undo: + evt->key_code = GF_KEY_UNDO; + break; //case XK_Redo: evt->key_code = GF_KEY_BEGIN; break; //case XK_Menu: evt->key_code = GF_KEY_BEGIN; break; - case XK_Find: evt->key_code = GF_KEY_FIND; break; - case XK_Cancel: evt->key_code = GF_KEY_CANCEL; break; - case XK_Help: evt->key_code = GF_KEY_HELP; break; + case XK_Find: + evt->key_code = GF_KEY_FIND; + break; + case XK_Cancel: + evt->key_code = GF_KEY_CANCEL; + break; + case XK_Help: + evt->key_code = GF_KEY_HELP; + break; //case XK_Break: evt->key_code = GF_KEY_BREAK; break; //case XK_Mode_switch: evt->key_code = GF_KEY_BEGIN; break; - case XK_Num_Lock: evt->key_code = GF_KEY_NUMLOCK; break; - - case XK_F1: evt->key_code = GF_KEY_F1; break; - case XK_F2: evt->key_code = GF_KEY_F2; break; - case XK_F3: evt->key_code = GF_KEY_F3; break; - case XK_F4: evt->key_code = GF_KEY_F4; break; - case XK_F5: evt->key_code = GF_KEY_F5; break; - case XK_F6: evt->key_code = GF_KEY_F6; break; - case XK_F7: evt->key_code = GF_KEY_F7; break; - case XK_F8: evt->key_code = GF_KEY_F8; break; - case XK_F9: evt->key_code = GF_KEY_F9; break; - case XK_F10: evt->key_code = GF_KEY_F10; break; - case XK_F11: evt->key_code = GF_KEY_F11; break; - case XK_F12: evt->key_code = GF_KEY_F12; break; - case XK_F13: evt->key_code = GF_KEY_F13; break; - case XK_F14: evt->key_code = GF_KEY_F14; break; - case XK_F15: evt->key_code = GF_KEY_F15; break; - case XK_F16: evt->key_code = GF_KEY_F16; break; - case XK_F17: evt->key_code = GF_KEY_F17; break; - case XK_F18: evt->key_code = GF_KEY_F18; break; - case XK_F19: evt->key_code = GF_KEY_F19; break; - case XK_F20: evt->key_code = GF_KEY_F20; break; - case XK_F21: evt->key_code = GF_KEY_F21; break; - case XK_F22: evt->key_code = GF_KEY_F22; break; - case XK_F23: evt->key_code = GF_KEY_F23; break; - case XK_F24: evt->key_code = GF_KEY_F24; break; - - case XK_KP_Delete: - case XK_KP_Decimal: - evt->flags = GF_KEY_EXT_NUMPAD; - evt->key_code = GF_KEY_COMMA; + case XK_Num_Lock: + evt->key_code = GF_KEY_NUMLOCK; + break; + + case XK_F1: + evt->key_code = GF_KEY_F1; + break; + case XK_F2: + evt->key_code = GF_KEY_F2; + break; + case XK_F3: + evt->key_code = GF_KEY_F3; + break; + case XK_F4: + evt->key_code = GF_KEY_F4; + break; + case XK_F5: + evt->key_code = GF_KEY_F5; + break; + case XK_F6: + evt->key_code = GF_KEY_F6; + break; + case XK_F7: + evt->key_code = GF_KEY_F7; + break; + case XK_F8: + evt->key_code = GF_KEY_F8; + break; + case XK_F9: + evt->key_code = GF_KEY_F9; + break; + case XK_F10: + evt->key_code = GF_KEY_F10; + break; + case XK_F11: + evt->key_code = GF_KEY_F11; + break; + case XK_F12: + evt->key_code = GF_KEY_F12; + break; + case XK_F13: + evt->key_code = GF_KEY_F13; + break; + case XK_F14: + evt->key_code = GF_KEY_F14; + break; + case XK_F15: + evt->key_code = GF_KEY_F15; + break; + case XK_F16: + evt->key_code = GF_KEY_F16; + break; + case XK_F17: + evt->key_code = GF_KEY_F17; + break; + case XK_F18: + evt->key_code = GF_KEY_F18; + break; + case XK_F19: + evt->key_code = GF_KEY_F19; + break; + case XK_F20: + evt->key_code = GF_KEY_F20; + break; + case XK_F21: + evt->key_code = GF_KEY_F21; + break; + case XK_F22: + evt->key_code = GF_KEY_F22; + break; + case XK_F23: + evt->key_code = GF_KEY_F23; + break; + case XK_F24: + evt->key_code = GF_KEY_F24; + break; + + case XK_KP_Delete: + case XK_KP_Decimal: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_COMMA; break; case XK_KP_Insert: - case XK_KP_0: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_0; break; + case XK_KP_0: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_0; + break; case XK_KP_End: - case XK_KP_1: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_1; break; - case XK_KP_Down: - case XK_KP_2: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_2; break; - case XK_KP_Page_Down: + case XK_KP_1: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_1; + break; + case XK_KP_Down: + case XK_KP_2: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_2; + break; + case XK_KP_Page_Down: case XK_KP_3: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_3; break; - case XK_KP_Left: - case XK_KP_4: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_4; break; - case XK_KP_Begin: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_3; + break; + case XK_KP_Left: + case XK_KP_4: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_4; + break; + case XK_KP_Begin: case XK_KP_5: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_5; break; - case XK_KP_Right: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_5; + break; + case XK_KP_Right: case XK_KP_6: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_6; break; - case XK_KP_Home: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_6; + break; + case XK_KP_Home: case XK_KP_7: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_7; break; - case XK_KP_Up: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_7; + break; + case XK_KP_Up: case XK_KP_8: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_8; break; - case XK_KP_Page_Up: + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_8; + break; + case XK_KP_Page_Up: case XK_KP_9: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_9; break; + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_9; + break; case XK_KP_Add: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_PLUS; break; + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_PLUS; + break; case XK_KP_Subtract: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_HYPHEN; break; + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_HYPHEN; + break; case XK_KP_Multiply: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_STAR; break; + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_STAR; + break; case XK_KP_Divide: - evt->flags = GF_KEY_EXT_NUMPAD; evt->key_code = GF_KEY_SLASH; break; + evt->flags = GF_KEY_EXT_NUMPAD; + evt->key_code = GF_KEY_SLASH; + break; case XK_Shift_R: evt->flags = GF_KEY_EXT_RIGHT; case XK_Shift_L: - evt->key_code = GF_KEY_SHIFT; + evt->key_code = GF_KEY_SHIFT; break; case XK_Control_R: evt->flags = GF_KEY_EXT_RIGHT; case XK_Control_L: - evt->key_code = GF_KEY_CONTROL; + evt->key_code = GF_KEY_CONTROL; break; case XK_Alt_R: evt->flags = GF_KEY_EXT_RIGHT; case XK_Alt_L: - evt->key_code = GF_KEY_ALT; + evt->key_code = GF_KEY_ALT; break; case XK_Super_R: evt->flags = GF_KEY_EXT_RIGHT; case XK_Super_L: - evt->key_code = GF_KEY_WIN; + evt->key_code = GF_KEY_WIN; break; - case XK_Menu: evt->key_code = GF_KEY_META; break; + case XK_Menu: + evt->key_code = GF_KEY_META; + break; #ifdef XK_XKB_KEYS - case XK_ISO_Level3_Shift: evt->key_code = GF_KEY_ALTGRAPH; break; + case XK_ISO_Level3_Shift: + evt->key_code = GF_KEY_ALTGRAPH; + break; #endif - case '!': evt->key_code = GF_KEY_EXCLAMATION; break; - case '"': evt->key_code = GF_KEY_QUOTATION; break; - case '#': evt->key_code = GF_KEY_NUMBER; break; - case '$': evt->key_code = GF_KEY_DOLLAR; break; - case '&': evt->key_code = GF_KEY_AMPERSAND; break; - case '\'': evt->key_code = GF_KEY_APOSTROPHE; break; - case '(': evt->key_code = GF_KEY_LEFTPARENTHESIS; break; - case ')': evt->key_code = GF_KEY_RIGHTPARENTHESIS; break; - case ',': evt->key_code = GF_KEY_COMMA; break; - case ':': evt->key_code = GF_KEY_COLON; break; - case ';': evt->key_code = GF_KEY_SEMICOLON; break; - case '<': evt->key_code = GF_KEY_LESSTHAN; break; - case '>': evt->key_code = GF_KEY_GREATERTHAN; break; - case '?': evt->key_code = GF_KEY_QUESTION; break; - case '@': evt->key_code = GF_KEY_AT; break; - case '[': evt->key_code = GF_KEY_LEFTSQUAREBRACKET; break; - case ']': evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; break; - case '\\': evt->key_code = GF_KEY_BACKSLASH; break; - case '_': evt->key_code = GF_KEY_UNDERSCORE; break; - case '`': evt->key_code = GF_KEY_GRAVEACCENT; break; - case ' ': evt->key_code = GF_KEY_SPACE; break; - case '/': evt->key_code = GF_KEY_SLASH; break; - case '*': evt->key_code = GF_KEY_STAR; break; - case '-': evt->key_code = GF_KEY_HYPHEN; break; - case '+': evt->key_code = GF_KEY_PLUS; break; - case '=': evt->key_code = GF_KEY_EQUALS; break; - case '^': evt->key_code = GF_KEY_CIRCUM; break; - case '{': evt->key_code = GF_KEY_LEFTCURLYBRACKET; break; - case '}': evt->key_code = GF_KEY_RIGHTCURLYBRACKET; break; - case '|': evt->key_code = GF_KEY_PIPE; break; + case '!': + evt->key_code = GF_KEY_EXCLAMATION; + break; + case '"': + evt->key_code = GF_KEY_QUOTATION; + break; + case '#': + evt->key_code = GF_KEY_NUMBER; + break; + case '$': + evt->key_code = GF_KEY_DOLLAR; + break; + case '&': + evt->key_code = GF_KEY_AMPERSAND; + break; + case '\'': + evt->key_code = GF_KEY_APOSTROPHE; + break; + case '(': + evt->key_code = GF_KEY_LEFTPARENTHESIS; + break; + case ')': + evt->key_code = GF_KEY_RIGHTPARENTHESIS; + break; + case ',': + evt->key_code = GF_KEY_COMMA; + break; + case ':': + evt->key_code = GF_KEY_COLON; + break; + case ';': + evt->key_code = GF_KEY_SEMICOLON; + break; + case '<': + evt->key_code = GF_KEY_LESSTHAN; + break; + case '>': + evt->key_code = GF_KEY_GREATERTHAN; + break; + case '?': + evt->key_code = GF_KEY_QUESTION; + break; + case '@': + evt->key_code = GF_KEY_AT; + break; + case '[': + evt->key_code = GF_KEY_LEFTSQUAREBRACKET; + break; + case ']': + evt->key_code = GF_KEY_RIGHTSQUAREBRACKET; + break; + case '\\': + evt->key_code = GF_KEY_BACKSLASH; + break; + case '_': + evt->key_code = GF_KEY_UNDERSCORE; + break; + case '`': + evt->key_code = GF_KEY_GRAVEACCENT; + break; + case ' ': + evt->key_code = GF_KEY_SPACE; + break; + case '/': + evt->key_code = GF_KEY_SLASH; + break; + case '*': + evt->key_code = GF_KEY_STAR; + break; + case '-': + evt->key_code = GF_KEY_HYPHEN; + break; + case '+': + evt->key_code = GF_KEY_PLUS; + break; + case '=': + evt->key_code = GF_KEY_EQUALS; + break; + case '^': + evt->key_code = GF_KEY_CIRCUM; + break; + case '{': + evt->key_code = GF_KEY_LEFTCURLYBRACKET; + break; + case '}': + evt->key_code = GF_KEY_RIGHTCURLYBRACKET; + break; + case '|': + evt->key_code = GF_KEY_PIPE; + break; default: if ((X11Key>='0') && (X11Key<='9')) evt->key_code = GF_KEY_0 + X11Key - '0'; else if ((X11Key>='A') && (X11Key<='Z')) evt->key_code = GF_KEY_A + X11Key - 'A'; @@ -484,7 +683,7 @@ static void x11_translate_key(u32 X11Key, GF_EventKey *evt) evt->hw_code = X11Key - 'a' + 'A'; } else { - evt->key_code = 0; + evt->key_code = 0; GF_LOG(GF_LOG_WARNING, GF_LOG_MMIO, ("[X11] Unrecognized key %X\n", X11Key)); } break; @@ -494,7 +693,7 @@ static void x11_translate_key(u32 X11Key, GF_EventKey *evt) /* taken from SDL - Ack! XPending() actually performs a blocking read if no events available + Ack! XPending() actually performs a blocking read if no events available */ static int X11_Pending(Display *display) { @@ -534,52 +733,52 @@ static void X11_HandleEvents(GF_VideoOutput *vout) XSync(xWindow->display, False); while (X11_Pending(xWindow->display)) { - XNextEvent(xWindow->display, &xevent); - if (xevent.xany.window!=the_window) continue; - switch (xevent.type) { - /* - * X11 window resized event - * must inform GPAC - */ - case ConfigureNotify: - if ((unsigned int) xevent.xconfigure.width != xWindow->w_width - || (unsigned int) xevent.xconfigure.height != xWindow->w_height) - { - evt.type = GF_EVENT_SIZE; - xWindow->w_width = evt.size.width = xevent.xconfigure.width; - xWindow->w_height = evt.size.height = xevent.xconfigure.height; - vout->on_event(vout->evt_cbk_hdl, &evt); - } else { - evt.type = GF_EVENT_MOVE; - evt.move.x = xevent.xconfigure.x; - evt.move.y = xevent.xconfigure.y; - vout->on_event(vout->evt_cbk_hdl, &evt); - } - break; - /* - * Windows need repaint - */ - case Expose: - if (xevent.xexpose.count > 0) break; - evt.type = GF_EVENT_REFRESH; - vout->on_event (vout->evt_cbk_hdl, &evt); - break; - - /* Have we been requested to quit (or another client message?) */ - case ClientMessage: - if ( (xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == xWindow->WM_DELETE_WINDOW) ) { + XNextEvent(xWindow->display, &xevent); + if (xevent.xany.window!=the_window) continue; + switch (xevent.type) { + /* + * X11 window resized event + * must inform GPAC + */ + case ConfigureNotify: + if ((unsigned int) xevent.xconfigure.width != xWindow->w_width + || (unsigned int) xevent.xconfigure.height != xWindow->w_height) + { + evt.type = GF_EVENT_SIZE; + xWindow->w_width = evt.size.width = xevent.xconfigure.width; + xWindow->w_height = evt.size.height = xevent.xconfigure.height; + vout->on_event(vout->evt_cbk_hdl, &evt); + } else { + evt.type = GF_EVENT_MOVE; + evt.move.x = xevent.xconfigure.x; + evt.move.y = xevent.xconfigure.y; + vout->on_event(vout->evt_cbk_hdl, &evt); + } + break; + /* + * Windows need repaint + */ + case Expose: + if (xevent.xexpose.count > 0) break; + evt.type = GF_EVENT_REFRESH; + vout->on_event (vout->evt_cbk_hdl, &evt); + break; + + /* Have we been requested to quit (or another client message?) */ + case ClientMessage: + if ( (xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == xWindow->WM_DELETE_WINDOW) ) { memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_QUIT; - vout->on_event(vout->evt_cbk_hdl, &evt); - } - break; - - case KeyPress: - case KeyRelease: - x11_translate_key(XKeycodeToKeysym (xWindow->display, xevent.xkey.keycode, 0), &evt.key); + evt.type = GF_EVENT_QUIT; + vout->on_event(vout->evt_cbk_hdl, &evt); + } + break; + + case KeyPress: + case KeyRelease: + x11_translate_key(XKeycodeToKeysym (xWindow->display, xevent.xkey.keycode, 0), &evt.key); evt.type = (xevent.type ==KeyPress) ? GF_EVENT_KEYDOWN : GF_EVENT_KEYUP; vout->on_event (vout->evt_cbk_hdl, &evt); - + if (xevent.type ==KeyPress) { s32 len; len = XLookupString (&xevent.xkey, (char *) keybuf, sizeof(keybuf), NULL, &state); @@ -595,128 +794,130 @@ static void X11_HandleEvents(GF_VideoOutput *vout) else if (evt.key.key_code==GF_KEY_META) xWindow->meta_down = (xevent.type==KeyPress) ? 1 : 0; if ((evt.type==GF_EVENT_KEYUP) && (evt.key.key_code==GF_KEY_V) && xWindow->ctrl_down) { - int sformat; - unsigned long nb_bytes, overflow; - unsigned char *data; - Window owner; - Atom selection, stype; - Atom clipb_atom = XInternAtom(xWindow->display, "CLIPBOARD", 0); - if (clipb_atom == None) break; - owner = XGetSelectionOwner(xWindow->display, clipb_atom); - if ((owner == None) || (owner == the_window)) { - owner = DefaultRootWindow(xWindow->display); - selection = XA_CUT_BUFFER0; - } else { - owner = the_window; - selection = XInternAtom(xWindow->display, "GPAC_TEXT_SEL", False); - XConvertSelection(xWindow->display, clipb_atom, XA_STRING, selection, owner, CurrentTime); - } - - - if (XGetWindowProperty(xWindow->display, owner, selection, 0, INT_MAX/4, False, AnyPropertyType, &stype, &sformat, &nb_bytes, &overflow, &data) == Success) { - if (stype == XA_STRING) { - char *text = gf_malloc(sizeof(char)*(nb_bytes+1)); - if (text) { - memcpy(text, data, nb_bytes); - text[nb_bytes] = 0; - evt.type = GF_EVENT_PASTE_TEXT; - evt.message.message = (const char *) text; - vout->on_event(vout->evt_cbk_hdl, &evt); - gf_free(text); - } - } - XFree(data); - } - } + int sformat; + unsigned long nb_bytes, overflow; + unsigned char *data; + Window owner; + Atom selection, stype; + Atom clipb_atom = XInternAtom(xWindow->display, "CLIPBOARD", 0); + if (clipb_atom == None) break; + owner = XGetSelectionOwner(xWindow->display, clipb_atom); + if ((owner == None) || (owner == the_window)) { + owner = DefaultRootWindow(xWindow->display); + selection = XA_CUT_BUFFER0; + } else { + owner = the_window; + selection = XInternAtom(xWindow->display, "GPAC_TEXT_SEL", False); + XConvertSelection(xWindow->display, clipb_atom, XA_STRING, selection, owner, CurrentTime); + } + + + if (XGetWindowProperty(xWindow->display, owner, selection, 0, INT_MAX/4, False, AnyPropertyType, &stype, &sformat, &nb_bytes, &overflow, &data) == Success) { + if (stype == XA_STRING) { + char *text = gf_malloc(sizeof(char)*(nb_bytes+1)); + if (text) { + memcpy(text, data, nb_bytes); + text[nb_bytes] = 0; + evt.type = GF_EVENT_PASTE_TEXT; + evt.message.message = (const char *) text; + vout->on_event(vout->evt_cbk_hdl, &evt); + gf_free(text); + } + } + XFree(data); + } + } else if ((evt.type==GF_EVENT_KEYUP) && (evt.key.key_code==GF_KEY_C) && xWindow->ctrl_down) { Atom clipb_atom = XInternAtom(xWindow->display, "CLIPBOARD", 0); evt.type = GF_EVENT_COPY_TEXT; if (vout->on_event(vout->evt_cbk_hdl, &evt)==GF_TRUE) { const char *txt = evt.message.message; - XChangeProperty(xWindow->display, DefaultRootWindow(xWindow->display), XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, (const unsigned char *)txt, strlen(txt)); + if (txt) { + XChangeProperty(xWindow->display, DefaultRootWindow(xWindow->display), XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, (const unsigned char *)txt, strlen(txt)); + } if ((clipb_atom != None) && XGetSelectionOwner(xWindow->display, clipb_atom) != the_window) { - XSetSelectionOwner(xWindow->display, clipb_atom, the_window, CurrentTime); + XSetSelectionOwner(xWindow->display, clipb_atom, the_window, CurrentTime); } if (XGetSelectionOwner(xWindow->display, XA_PRIMARY) != the_window) { XSetSelectionOwner(xWindow->display, XA_PRIMARY, the_window, CurrentTime); - } + } } } break; - - case ButtonPress: - if (!xWindow->fullscreen && !xWindow->has_focus) { - xWindow->has_focus = 1; - XSetInputFocus(xWindow->display, xWindow->wnd, RevertToParent, CurrentTime); - } - case ButtonRelease: - // last_mouse_move = xevent.xbutton.time; - evt.mouse.x = xevent.xbutton.x; - evt.mouse.y = xevent.xbutton.y; + + case ButtonPress: + if (!xWindow->fullscreen && !xWindow->has_focus) { + xWindow->has_focus = 1; + XSetInputFocus(xWindow->display, xWindow->wnd, RevertToParent, CurrentTime); + } + case ButtonRelease: + // last_mouse_move = xevent.xbutton.time; + evt.mouse.x = xevent.xbutton.x; + evt.mouse.y = xevent.xbutton.y; evt.type = (xevent.type == ButtonRelease) ? GF_EVENT_MOUSEUP : GF_EVENT_MOUSEDOWN; - - switch (xevent.xbutton.button) { - case Button1: - evt.mouse.button = GF_MOUSE_LEFT; - vout->on_event (vout->evt_cbk_hdl, &evt); - break; - case Button2: - evt.mouse.button = GF_MOUSE_MIDDLE; - vout->on_event (vout->evt_cbk_hdl, &evt); - break; - case Button3: - evt.mouse.button = GF_MOUSE_RIGHT; - vout->on_event (vout->evt_cbk_hdl, &evt); - break; - case Button4: - evt.type = GF_EVENT_MOUSEWHEEL; - evt.mouse.wheel_pos = FIX_ONE; - vout->on_event(vout->evt_cbk_hdl, &evt); - break; - case Button5: - evt.type = GF_EVENT_MOUSEWHEEL; - evt.mouse.wheel_pos = -FIX_ONE; - vout->on_event(vout->evt_cbk_hdl, &evt); - break; - } - if (!xWindow->fullscreen && (xevent.type==ButtonPress) ) - XSetInputFocus(xWindow->display, xWindow->wnd, RevertToNone, CurrentTime); - break; - - case MotionNotify: - evt.type = GF_EVENT_MOUSEMOVE; - evt.mouse.x = xevent.xmotion.x; - evt.mouse.y = xevent.xmotion.y; - vout->on_event (vout->evt_cbk_hdl, &evt); - break; - case PropertyNotify: - break; - case MapNotify: - break; - case CirculateNotify: - break; - case UnmapNotify: - break; - case ReparentNotify: - break; - case FocusOut: + + switch (xevent.xbutton.button) { + case Button1: + evt.mouse.button = GF_MOUSE_LEFT; + vout->on_event (vout->evt_cbk_hdl, &evt); + break; + case Button2: + evt.mouse.button = GF_MOUSE_MIDDLE; + vout->on_event (vout->evt_cbk_hdl, &evt); + break; + case Button3: + evt.mouse.button = GF_MOUSE_RIGHT; + vout->on_event (vout->evt_cbk_hdl, &evt); + break; + case Button4: + evt.type = GF_EVENT_MOUSEWHEEL; + evt.mouse.wheel_pos = FIX_ONE; + vout->on_event(vout->evt_cbk_hdl, &evt); + break; + case Button5: + evt.type = GF_EVENT_MOUSEWHEEL; + evt.mouse.wheel_pos = -FIX_ONE; + vout->on_event(vout->evt_cbk_hdl, &evt); + break; + } + if (!xWindow->fullscreen && (xevent.type==ButtonPress) ) + XSetInputFocus(xWindow->display, xWindow->wnd, RevertToNone, CurrentTime); + break; + + case MotionNotify: + evt.type = GF_EVENT_MOUSEMOVE; + evt.mouse.x = xevent.xmotion.x; + evt.mouse.y = xevent.xmotion.y; + vout->on_event (vout->evt_cbk_hdl, &evt); + break; + case PropertyNotify: + break; + case MapNotify: + break; + case CirculateNotify: + break; + case UnmapNotify: + break; + case ReparentNotify: + break; + case FocusOut: if (!xWindow->fullscreen) xWindow->has_focus = 0; - break; - case FocusIn: + break; + case FocusIn: if (!xWindow->fullscreen) xWindow->has_focus = 1; - break; - - case DestroyNotify: - memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_QUIT; - vout->on_event(vout->evt_cbk_hdl, &evt); - break; - - default: - break; - } - } + break; + + case DestroyNotify: + memset(&evt, 0, sizeof(GF_Event)); + evt.type = GF_EVENT_QUIT; + vout->on_event(vout->evt_cbk_hdl, &evt); + break; + + default: + break; + } + } } @@ -725,94 +926,94 @@ static void X11_HandleEvents(GF_VideoOutput *vout) #ifdef GPAC_HAS_OPENGL static GF_Err X11_SetupGL(GF_VideoOutput *vout) { - GF_Event evt; - XWindow *xWin = (XWindow *)vout->opaque; - - if (!xWin->glx_visualinfo) return GF_IO_ERR; - memset(&evt, 0, sizeof(GF_Event)); - - if (!xWin->glx_context) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[X11] Setting up GL for display %d\n", xWin->display)); - XSync(xWin->display, False); - xWin->glx_context = glXCreateContext(xWin->display,xWin->glx_visualinfo, NULL, True); - XSync(xWin->display, False); - if (!xWin->glx_context) return GF_IO_ERR; - if (xWin->output_3d_mode==2) return GF_IO_ERR; - - evt.setup.hw_reset = 1; - } - if ( ! glXMakeCurrent(xWin->display, xWin->fullscreen ? xWin->full_wnd : xWin->wnd, xWin->glx_context) ) return GF_IO_ERR; - XSync(xWin->display, False); - - evt.type = GF_EVENT_VIDEO_SETUP; - vout->on_event (vout->evt_cbk_hdl,&evt); - xWin->is_init = 1; - return GF_OK; + GF_Event evt; + XWindow *xWin = (XWindow *)vout->opaque; + + if (!xWin->glx_visualinfo) return GF_IO_ERR; + memset(&evt, 0, sizeof(GF_Event)); + + if (!xWin->glx_context) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_MMIO, ("[X11] Setting up GL for display %d\n", xWin->display)); + XSync(xWin->display, False); + xWin->glx_context = glXCreateContext(xWin->display,xWin->glx_visualinfo, NULL, True); + XSync(xWin->display, False); + if (!xWin->glx_context) return GF_IO_ERR; + if (xWin->output_3d_mode==2) return GF_IO_ERR; + + evt.setup.hw_reset = 1; + } + if ( ! glXMakeCurrent(xWin->display, xWin->fullscreen ? xWin->full_wnd : xWin->wnd, xWin->glx_context) ) return GF_IO_ERR; + XSync(xWin->display, False); + + evt.type = GF_EVENT_VIDEO_SETUP; + vout->on_event (vout->evt_cbk_hdl,&evt); + xWin->is_init = 1; + return GF_OK; } static GF_Err X11_SetupGLPixmap(GF_VideoOutput *vout, u32 width, u32 height) { - XWindow *xWin = (XWindow *)vout->opaque; - - if (xWin->glx_context) { - glXMakeCurrent(xWin->display, None, NULL); - glXDestroyContext(xWin->display, xWin->glx_context); - xWin->glx_context = NULL; - } - if (xWin->gl_offscreen) glXDestroyGLXPixmap(xWin->display, xWin->gl_offscreen); - xWin->gl_offscreen = 0; - if (xWin->gl_pixmap) XFreePixmap(xWin->display, xWin->gl_pixmap); - xWin->gl_pixmap = 0; - - if (xWin->offscreen_type) { - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using offscreen GL context through XWindow\n")); - if (xWin->offscreen_type==2) { + XWindow *xWin = (XWindow *)vout->opaque; + + if (xWin->glx_context) { + glXMakeCurrent(xWin->display, None, NULL); + glXDestroyContext(xWin->display, xWin->glx_context); + xWin->glx_context = NULL; + } + if (xWin->gl_offscreen) glXDestroyGLXPixmap(xWin->display, xWin->gl_offscreen); + xWin->gl_offscreen = 0; + if (xWin->gl_pixmap) XFreePixmap(xWin->display, xWin->gl_pixmap); + xWin->gl_pixmap = 0; + + if (xWin->offscreen_type) { + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using offscreen GL context through XWindow\n")); + if (xWin->offscreen_type==2) { + XSync(xWin->display, False); + XMapWindow (xWin->display, (Window) xWin->gl_wnd); + XSync(xWin->display, False); +// XSetWMNormalHints (xWin->display, xWin->gl_wnd, Hints); + XStoreName (xWin->display, xWin->gl_wnd, "GPAC Offscreeen Window - debug mode"); + } + XSync(xWin->display, False); - XMapWindow (xWin->display, (Window) xWin->gl_wnd); + xWin->glx_context = glXCreateContext(xWin->display,xWin->glx_visualinfo, NULL, True); XSync(xWin->display, False); -// XSetWMNormalHints (xWin->display, xWin->gl_wnd, Hints); - XStoreName (xWin->display, xWin->gl_wnd, "GPAC Offscreeen Window - debug mode"); + if (!xWin->glx_context) return GF_IO_ERR; + if ( ! glXMakeCurrent(xWin->display, xWin->gl_wnd, xWin->glx_context) ) return GF_IO_ERR; + XSync(xWin->display, False); + + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using offscreen GL context through glXPixmap\n")); + xWin->gl_pixmap = XCreatePixmap(xWin->display, xWin->gl_wnd, width, height, xWin->depth); + if (!xWin->gl_pixmap) return GF_IO_ERR; + + xWin->gl_offscreen = glXCreateGLXPixmap(xWin->display, xWin->glx_visualinfo, xWin->gl_pixmap); + if (!xWin->gl_offscreen) return GF_IO_ERR; + + XSync(xWin->display, False); + xWin->glx_context = glXCreateContext(xWin->display, xWin->glx_visualinfo, 0, GL_FALSE); + XSync(xWin->display, False); + if (!xWin->glx_context) return GF_IO_ERR; + + XSync(xWin->display, False); + GF_LOG(GF_LOG_WARNING, GF_LOG_MMIO, ("[X11] Activating GLContext on GLPixmap - this may crash !!\n")); + glXMakeCurrent(xWin->display, xWin->gl_offscreen, xWin->glx_context); } - XSync(xWin->display, False); - xWin->glx_context = glXCreateContext(xWin->display,xWin->glx_visualinfo, NULL, True); - XSync(xWin->display, False); - if (!xWin->glx_context) return GF_IO_ERR; - if ( ! glXMakeCurrent(xWin->display, xWin->gl_wnd, xWin->glx_context) ) return GF_IO_ERR; - XSync(xWin->display, False); - - } else { - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using offscreen GL context through glXPixmap\n")); - xWin->gl_pixmap = XCreatePixmap(xWin->display, xWin->gl_wnd, width, height, xWin->depth); - if (!xWin->gl_pixmap) return GF_IO_ERR; - - xWin->gl_offscreen = glXCreateGLXPixmap(xWin->display, xWin->glx_visualinfo, xWin->gl_pixmap); - if (!xWin->gl_offscreen) return GF_IO_ERR; - - XSync(xWin->display, False); - xWin->glx_context = glXCreateContext(xWin->display, xWin->glx_visualinfo, 0, GL_FALSE); - XSync(xWin->display, False); - if (!xWin->glx_context) return GF_IO_ERR; - - XSync(xWin->display, False); - GF_LOG(GF_LOG_WARNING, GF_LOG_MMIO, ("[X11] Activating GLContext on GLPixmap - this may crash !!\n")); - glXMakeCurrent(xWin->display, xWin->gl_offscreen, xWin->glx_context); - } - - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Offscreen GL context setup\n")); - return GF_OK; + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Offscreen GL context setup\n")); + return GF_OK; } static void X11_ReleaseGL(XWindow *xWin) { - XSync(xWin->display, False); - if (xWin->glx_context) { - glXMakeCurrent(xWin->display, None, NULL); - glXDestroyContext(xWin->display, xWin->glx_context); - xWin->glx_context = NULL; - } - xWin->is_init = 0; - XSync(xWin->display, False); + XSync(xWin->display, False); + if (xWin->glx_context) { + glXMakeCurrent(xWin->display, None, NULL); + glXDestroyContext(xWin->display, xWin->glx_context); + xWin->glx_context = NULL; + } + xWin->is_init = 0; + XSync(xWin->display, False); } #endif @@ -849,7 +1050,7 @@ static void X11_ReleaseBackBuffer (GF_VideoOutput * vout) #ifdef GPAC_HAS_X11_XV X11_DestroyOverlay(xWindow); #endif - + } /* @@ -870,8 +1071,8 @@ GF_Err X11_InitBackBuffer (GF_VideoOutput * vout, u32 VideoWidth, u32 VideoHeigh X11_ReleaseBackBuffer(vout); /*WATCHOUT seems we need even width when using shared memory extensions*/ - if (xWindow->use_shared_memory && (VideoWidth%2)) - VideoWidth++; + if (xWindow->use_shared_memory && (VideoWidth%2)) + VideoWidth++; size = VideoWidth * VideoHeight * xWindow->bpp; cur_wnd = xWindow->fullscreen ? xWindow->full_wnd : xWindow->wnd; @@ -887,8 +1088,8 @@ GF_Err X11_InitBackBuffer (GF_VideoOutput * vout, u32 VideoWidth, u32 VideoHeigh GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Failed to attach shared memory!\n")); } xWindow->pixmap = XShmCreatePixmap(xWindow->display, cur_wnd, - (unsigned char *) xWindow->shmseginfo->shmaddr, xWindow->shmseginfo, - VideoWidth, VideoHeight, xWindow->depth); + (unsigned char *) xWindow->shmseginfo->shmaddr, xWindow->shmseginfo, + VideoWidth, VideoHeight, xWindow->depth); memset((unsigned char *) xWindow->shmseginfo->shmaddr, 0, sizeof(char)*size); XSetWindowBackgroundPixmap (xWindow->display, cur_wnd, xWindow->pixmap); xWindow->pwidth = VideoWidth; @@ -897,10 +1098,10 @@ GF_Err X11_InitBackBuffer (GF_VideoOutput * vout, u32 VideoWidth, u32 VideoHeigh } else if (xWindow->use_shared_memory) { GF_SAFEALLOC(xWindow->shmseginfo, XShmSegmentInfo); xWindow->surface = XShmCreateImage (xWindow->display, xWindow->visual, - xWindow->depth, ZPixmap, NULL, xWindow->shmseginfo, - VideoWidth, VideoHeight); + xWindow->depth, ZPixmap, NULL, xWindow->shmseginfo, + VideoWidth, VideoHeight); xWindow->shmseginfo->shmid = shmget(IPC_PRIVATE, xWindow->surface->bytes_per_line * xWindow->surface->height, - IPC_CREAT | 0777); + IPC_CREAT | 0777); xWindow->surface->data = xWindow->shmseginfo->shmaddr = shmat(xWindow->shmseginfo->shmid, NULL, 0); xWindow->shmseginfo->readOnly = False; @@ -910,11 +1111,11 @@ GF_Err X11_InitBackBuffer (GF_VideoOutput * vout, u32 VideoWidth, u32 VideoHeigh { char *data = (char *) gf_malloc(sizeof(char)*size); xWindow->surface = XCreateImage (xWindow->display, xWindow->visual, - xWindow->depth, ZPixmap, - 0, - data, - VideoWidth, VideoHeight, - xWindow->bpp*8, xWindow->bpp*VideoWidth); + xWindow->depth, ZPixmap, + 0, + data, + VideoWidth, VideoHeight, + xWindow->bpp*8, xWindow->bpp*VideoWidth); if (!xWindow->surface) { gf_free(data); return GF_IO_ERR; @@ -948,49 +1149,49 @@ GF_Err X11_ProcessEvent (struct _video_out * vout, GF_Event * evt) if (evt) { - switch (evt->type) { - case GF_EVENT_SET_CURSOR: - break; - case GF_EVENT_SET_CAPTION: - if (!xWindow->par_wnd) XStoreName (xWindow->display, xWindow->wnd, evt->caption.caption); - break; - case GF_EVENT_SHOWHIDE: - break; - case GF_EVENT_SIZE: - /*if owning the window and not in fullscreen, resize it (initial scene size)*/ - xWindow->w_width = evt->size.width; - xWindow->w_height = evt->size.height; - - if (!xWindow->fullscreen) { - if (xWindow->par_wnd) { - XWindowAttributes pwa; - XGetWindowAttributes(xWindow->display, xWindow->par_wnd, &pwa); - XMoveResizeWindow(xWindow->display, xWindow->wnd, pwa.x, pwa.y, evt->size.width, evt->size.height); - if (!xWindow->no_select_input) XSetInputFocus(xWindow->display, xWindow->wnd, RevertToNone, CurrentTime); - } else { - XResizeWindow (xWindow->display, xWindow->wnd, evt->size.width, evt->size.height); - } - } - break; - case GF_EVENT_VIDEO_SETUP: - switch (evt->setup.opengl_mode){ + switch (evt->type) { + case GF_EVENT_SET_CURSOR: + break; + case GF_EVENT_SET_CAPTION: + if (!xWindow->par_wnd) XStoreName (xWindow->display, xWindow->wnd, evt->caption.caption); + break; + case GF_EVENT_SHOWHIDE: + break; + case GF_EVENT_SIZE: + /*if owning the window and not in fullscreen, resize it (initial scene size)*/ + xWindow->w_width = evt->size.width; + xWindow->w_height = evt->size.height; + + if (!xWindow->fullscreen) { + if (xWindow->par_wnd) { + XWindowAttributes pwa; + XGetWindowAttributes(xWindow->display, xWindow->par_wnd, &pwa); + XMoveResizeWindow(xWindow->display, xWindow->wnd, pwa.x, pwa.y, evt->size.width, evt->size.height); + if (!xWindow->no_select_input) XSetInputFocus(xWindow->display, xWindow->wnd, RevertToNone, CurrentTime); + } else { + XResizeWindow (xWindow->display, xWindow->wnd, evt->size.width, evt->size.height); + } + } + break; + case GF_EVENT_VIDEO_SETUP: + switch (evt->setup.opengl_mode) { #ifdef GPAC_HAS_OPENGL - case 1: - xWindow->output_3d_mode = 1; - return X11_SetupGL(vout); - case 2: - xWindow->output_3d_mode = 2; - return X11_SetupGLPixmap(vout, evt->setup.width, evt->setup.height); + case 1: + xWindow->output_3d_mode = 1; + return X11_SetupGL(vout); + case 2: + xWindow->output_3d_mode = 2; + return X11_SetupGLPixmap(vout, evt->setup.width, evt->setup.height); #endif - case 0: - xWindow->output_3d_mode = 0; - return X11_ResizeBackBuffer(vout, evt->setup.width, evt->setup.height); - default: - return GF_NOT_SUPPORTED; + case 0: + xWindow->output_3d_mode = 0; + return X11_ResizeBackBuffer(vout, evt->setup.width, evt->setup.height); + default: + return GF_NOT_SUPPORTED; + } } - } } else { - X11_HandleEvents(vout); + X11_HandleEvents(vout); } return GF_OK; @@ -1016,9 +1217,9 @@ GF_Err X11_SetFullScreen (struct _video_out * vout, u32 bFullScreenOn, u32 * scr xWindow->the_gc = XCreateGC (xWindow->display, xWindow->full_wnd, 0, NULL); XMoveResizeWindow (xWindow->display, - (Window) xWindow->full_wnd, 0, 0, - vout->max_screen_width, - vout->max_screen_height); + (Window) xWindow->full_wnd, 0, 0, + vout->max_screen_width, + vout->max_screen_height); *screen_width = xWindow->w_width; *screen_height = xWindow->w_height; XUnmapWindow (xWindow->display, xWindow->wnd); @@ -1083,7 +1284,7 @@ GF_Err X11_LockBackBuffer(struct _video_out * vout, GF_VideoSurface * vi, u32 do static XErrorHandler old_handler = NULL; static int selectinput_err = 0; static int X11_BadAccess_ByPass(Display * display, - XErrorEvent * event) + XErrorEvent * event) { char msg[60]; if (event->error_code == BadAccess) @@ -1105,14 +1306,14 @@ static int X11_BadAccess_ByPass(Display * display, static void X11_XScreenSaverState(XWindow *xwin, Bool turn_on) { return; - if (turn_on) { + if (turn_on) { if (!xwin->ss_t) return; - XSetScreenSaver(xwin->display, xwin->ss_t, xwin->ss_i, xwin->ss_b, xwin->ss_e); + XSetScreenSaver(xwin->display, xwin->ss_t, xwin->ss_i, xwin->ss_b, xwin->ss_e); } else { /* Save state information */ XGetScreenSaver(xwin->display, &xwin->ss_t, &xwin->ss_i, &xwin->ss_b, &xwin->ss_e); if (xwin->ss_t) - XSetScreenSaver(xwin->display, 0, xwin->ss_i, xwin->ss_b, xwin->ss_e); + XSetScreenSaver(xwin->display, 0, xwin->ss_i, xwin->ss_b, xwin->ss_e); } } @@ -1124,7 +1325,7 @@ X11_SetupWindow (GF_VideoOutput * vout) { X11VID (); const char *sOpt; - Bool autorepeat, supported; + Bool autorepeat, supported; xWindow->display = XOpenDisplay (NULL); xWindow->screennum = DefaultScreen (xWindow->display); @@ -1138,7 +1339,7 @@ X11_SetupWindow (GF_VideoOutput * vout) Float screenHeight = (Float)XHeightOfScreen(xWindow->screenptr); Float screenHeightIn = (Float)XHeightMMOfScreen(xWindow->screenptr) / 25.4f; vout->dpi_x = (u32)(screenWidth / screenWidthIn); - vout->dpi_y = (u32)(screenHeight / screenHeightIn); + vout->dpi_y = (u32)(screenHeight / screenHeightIn); } switch (xWindow->depth) { @@ -1158,7 +1359,7 @@ X11_SetupWindow (GF_VideoOutput * vout) xWindow->bpp = xWindow->depth / 8; xWindow->bpp = xWindow->bpp == 3 ? 4 : xWindow->bpp; -xWindow->screennum=0; + xWindow->screennum=0; vout->max_screen_width = DisplayWidth(xWindow->display, xWindow->screennum); vout->max_screen_height = DisplayHeight(xWindow->display, xWindow->screennum); vout->max_screen_bpp = 8; @@ -1167,24 +1368,24 @@ xWindow->screennum=0; * Full screen wnd */ xWindow->full_wnd = XCreateWindow (xWindow->display, - RootWindowOfScreen (xWindow->screenptr), - 0, 0, - vout->max_screen_width, - vout->max_screen_height, 0, - xWindow->depth, InputOutput, - xWindow->visual, 0, NULL); + RootWindowOfScreen (xWindow->screenptr), + 0, 0, + vout->max_screen_width, + vout->max_screen_height, 0, + xWindow->depth, InputOutput, + xWindow->visual, 0, NULL); XSelectInput(xWindow->display, xWindow->full_wnd, - FocusChangeMask | ExposureMask | PointerMotionMask | ButtonReleaseMask | ButtonPressMask | KeyPressMask | KeyReleaseMask); + FocusChangeMask | ExposureMask | PointerMotionMask | ButtonReleaseMask | ButtonPressMask | KeyPressMask | KeyReleaseMask); if (!xWindow->par_wnd) { xWindow->w_width = 320; xWindow->w_height = 240; xWindow->wnd = XCreateWindow (xWindow->display, - RootWindowOfScreen(xWindow->screenptr), 0, 0, - xWindow->w_width, xWindow->w_height, 0, - xWindow->depth, InputOutput, - xWindow->visual, 0, NULL); + RootWindowOfScreen(xWindow->screenptr), 0, 0, + xWindow->w_width, xWindow->w_height, 0, + xWindow->depth, InputOutput, + xWindow->visual, 0, NULL); XMapWindow (xWindow->display, (Window) xWindow->wnd); } else { XWindowAttributes pwa; @@ -1192,9 +1393,9 @@ xWindow->screennum=0; xWindow->w_width = pwa.width; xWindow->w_height = pwa.height; xWindow->wnd = XCreateWindow (xWindow->display, xWindow->par_wnd, pwa.x, pwa.y, - xWindow->w_width, xWindow->w_height, 0, - xWindow->depth, InputOutput, - xWindow->visual, 0, NULL); + xWindow->w_width, xWindow->w_height, 0, + xWindow->depth, InputOutput, + xWindow->visual, 0, NULL); XMapWindow (xWindow->display, (Window) xWindow->wnd); } @@ -1204,15 +1405,15 @@ xWindow->screennum=0; old_handler = XSetErrorHandler(X11_BadAccess_ByPass); selectinput_err = 0; XSelectInput(xWindow->display, xWindow->wnd, - FocusChangeMask | StructureNotifyMask | PropertyChangeMask | ExposureMask | - PointerMotionMask | ButtonReleaseMask | ButtonPressMask | - KeyPressMask | KeyReleaseMask); + FocusChangeMask | StructureNotifyMask | PropertyChangeMask | ExposureMask | + PointerMotionMask | ButtonReleaseMask | ButtonPressMask | + KeyPressMask | KeyReleaseMask); XSync(xWindow->display, False); XSetErrorHandler(old_handler); if (selectinput_err) { - XSelectInput(xWindow->display, xWindow->wnd, - StructureNotifyMask | PropertyChangeMask | ExposureMask | - KeyPressMask | KeyReleaseMask); + XSelectInput(xWindow->display, xWindow->wnd, + StructureNotifyMask | PropertyChangeMask | ExposureMask | + KeyPressMask | KeyReleaseMask); GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Cannot select input focus\n")); } @@ -1234,6 +1435,13 @@ xWindow->screennum=0; Hints->flags |= USPosition; XSetWMNormalHints (xWindow->display, xWindow->full_wnd, Hints); + { + XClassHint hint; + hint.res_name = "gpac"; + hint.res_class = "gpac"; + XSetClassHint(xWindow->display, xWindow->wnd, &hint); + } + autorepeat = 1; XkbSetDetectableAutoRepeat(xWindow->display, autorepeat, &supported); @@ -1241,18 +1449,18 @@ xWindow->screennum=0; if (xWindow->init_flags & GF_TERM_WINDOW_NO_DECORATION) { #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 #define MWM_HINTS_DECORATIONS (1L << 1) - struct { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long inputMode; - unsigned long status; - } hints = {2, 0, 0, 0, 0}; + struct { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; + } hints = {2, 0, 0, 0, 0}; - hints.flags = MWM_HINTS_DECORATIONS; - hints.decorations = 0; + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = 0; - XChangeProperty(xWindow->display, xWindow->wnd, XInternAtom(xWindow->display,"_MOTIF_WM_HINTS", False), XInternAtom(xWindow->display, "_MOTIF_WM_HINTS", False), 32, PropModeReplace, (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); + XChangeProperty(xWindow->display, xWindow->wnd, XInternAtom(xWindow->display,"_MOTIF_WM_HINTS", False), XInternAtom(xWindow->display, "_MOTIF_WM_HINTS", False), 32, PropModeReplace, (unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS); } @@ -1261,16 +1469,16 @@ xWindow->screennum=0; #ifdef GPAC_HAS_X11_SHM sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "UseHardwareMemory"); - if (sOpt && !strcmp(sOpt, "yes")) { - int XShmMajor, XShmMinor; - Bool XShmPixmaps; - if (XShmQueryVersion(xWindow->display, &XShmMajor, &XShmMinor, &XShmPixmaps)) { - xWindow->use_shared_memory = 1; - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using X11 Shared Memory\n")); - if ((XShmPixmaps==True) && (XShmPixmapFormat(xWindow->display)==ZPixmap)) { - GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] X11 Shared Memory Pixmaps available\n")); + if (sOpt && !strcmp(sOpt, "yes")) { + int XShmMajor, XShmMinor; + Bool XShmPixmaps; + if (XShmQueryVersion(xWindow->display, &XShmMajor, &XShmMinor, &XShmPixmaps)) { + xWindow->use_shared_memory = 1; + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using X11 Shared Memory\n")); + if ((XShmPixmaps==True) && (XShmPixmapFormat(xWindow->display)==ZPixmap)) { + GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] X11 Shared Memory Pixmaps available\n")); + } } - } } #endif @@ -1305,7 +1513,7 @@ xWindow->screennum=0; GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[X11] Using XV Offscreen YUV2RGB acceleration\n")); } #endif - } + } #endif XSetWindowAttributes xsw; @@ -1316,7 +1524,7 @@ xWindow->screennum=0; xsw.override_redirect = True; XChangeWindowAttributes(xWindow->display, xWindow->full_wnd, - CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWWinGravity, &xsw); + CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWWinGravity, &xsw); if (!xWindow->par_wnd) { xWindow->WM_DELETE_WINDOW = XInternAtom (xWindow->display, "WM_DELETE_WINDOW", False); @@ -1337,108 +1545,108 @@ xWindow->screennum=0; ev.xclient.data.l[1] = CurrentTime; mask = SubstructureRedirectMask; XSendEvent (xWindow->display,RootWindowOfScreen (xWindow->screenptr), False, - mask, &ev); + mask, &ev); } /*openGL setup*/ #ifdef GPAC_HAS_OPENGL { - int attribs[64]; - int i, nb_bits, nb_depth_bits; - - sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "GLNbBitsPerComponent"); - /* Most outputs are 24/32 bits these days, use 8 bits per channel instead of 5, works better on MacOS X */ - nb_bits = sOpt ? atoi(sOpt) : 8; - if (!sOpt){ - gf_modules_set_option((GF_BaseInterface *)vout, "Video", "GLNbBitsPerComponent", "8"); - } + int attribs[64]; + int i, nb_bits, nb_depth_bits; + + sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "GLNbBitsPerComponent"); + /* Most outputs are 24/32 bits these days, use 8 bits per channel instead of 5, works better on MacOS X */ + nb_bits = sOpt ? atoi(sOpt) : 8; + if (!sOpt) { + gf_modules_set_option((GF_BaseInterface *)vout, "Video", "GLNbBitsPerComponent", "8"); + } retry_8bpp: - i=0; - if (nb_bits>8) { - attribs[i++] = GLX_DRAWABLE_TYPE; - attribs[i++] = GLX_WINDOW_BIT; - attribs[i++] = GLX_RENDER_TYPE; - attribs[i++] = GLX_RGBA_BIT; - } else { - attribs[i++] = GLX_RGBA; - } - attribs[i++] = GLX_RED_SIZE; - attribs[i++] = nb_bits; - attribs[i++] = GLX_GREEN_SIZE; - attribs[i++] = nb_bits; - attribs[i++] = GLX_BLUE_SIZE; - attribs[i++] = nb_bits; - if (nb_bits==10) { - attribs[i++] = GLX_ALPHA_SIZE; - attribs[i++] = 2; - } - - sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "GLNbBitsDepth"); - nb_depth_bits = sOpt ? atoi(sOpt) : 16; - if (!sOpt){ - gf_modules_set_option((GF_BaseInterface *)vout, "Video", "GLNbBitsDepth", "16"); - } - if (nb_bits) { - attribs[i++] = GLX_DEPTH_SIZE; - attribs[i++] = nb_depth_bits; - } - sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "UseGLDoubleBuffering"); - if (!sOpt){ - gf_modules_set_option((GF_BaseInterface *)vout, "Video", "UseGLDoubleBuffering", "yes"); - } - if (!sOpt || !strcmp(sOpt, "yes")) { - attribs[i++] = GLX_DOUBLEBUFFER; - attribs[i++] = True; - } - attribs[i++] = None; - - if (nb_bits>8) { - int fbcount=0; - GLXFBConfig *fb=NULL; - typedef GLXFBConfig * (* FnGlXChooseFBConfigProc)( Display *, int, int const *,int * ); - typedef XVisualInfo * (* FnGlXGetVisualFromFBConfigProc)( Display *, GLXFBConfig ); - typedef int (* FnGlXGetFBConfigAttrib) (Display * dpy, GLXFBConfig config, int attribute, int * value); - - - FnGlXChooseFBConfigProc my_glXChooseFBConfig = (FnGlXChooseFBConfigProc) glXGetProcAddress((GLubyte*) "glXChooseFBConfig"); - FnGlXGetVisualFromFBConfigProc my_glXGetVisualFromFBConfig = (FnGlXGetVisualFromFBConfigProc)glXGetProcAddress((GLubyte*) "glXGetVisualFromFBConfig"); - FnGlXGetFBConfigAttrib my_glXGetFBConfigAttrib = (FnGlXGetFBConfigAttrib)glXGetProcAddress((GLubyte*) "glXGetFBConfigAttrib"); - - if (my_glXChooseFBConfig && my_glXGetVisualFromFBConfig) { - fb = my_glXChooseFBConfig(xWindow->display, xWindow->screennum, attribs, &fbcount); + i=0; + if (nb_bits>8) { + attribs[i++] = GLX_DRAWABLE_TYPE; + attribs[i++] = GLX_WINDOW_BIT; + attribs[i++] = GLX_RENDER_TYPE; + attribs[i++] = GLX_RGBA_BIT; + } else { + attribs[i++] = GLX_RGBA; + } + attribs[i++] = GLX_RED_SIZE; + attribs[i++] = nb_bits; + attribs[i++] = GLX_GREEN_SIZE; + attribs[i++] = nb_bits; + attribs[i++] = GLX_BLUE_SIZE; + attribs[i++] = nb_bits; + if (nb_bits==10) { + attribs[i++] = GLX_ALPHA_SIZE; + attribs[i++] = 2; } - if (fbcount==0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Failed to choose GLX config for 10 bit depth - retrying with 8 bit depth\n")); - nb_bits = 8; - goto retry_8bpp; + sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "GLNbBitsDepth"); + nb_depth_bits = sOpt ? atoi(sOpt) : 16; + if (!sOpt) { + gf_modules_set_option((GF_BaseInterface *)vout, "Video", "GLNbBitsDepth", "16"); + } + if (nb_bits) { + attribs[i++] = GLX_DEPTH_SIZE; + attribs[i++] = nb_depth_bits; } - xWindow->glx_visualinfo = my_glXGetVisualFromFBConfig(xWindow->display, fb[0]); - - if (my_glXGetFBConfigAttrib && fb) { - int r, g, b; - glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_RED_SIZE, &r); - glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_GREEN_SIZE, &g); - glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_BLUE_SIZE, &b); - GF_LOG(GF_LOG_WARNING, GF_LOG_MMIO, ("[GLX] Configured display asked %d bits got r:%d g:%d b:%d bits\n", nb_bits, r, g, b)); + sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "UseGLDoubleBuffering"); + if (!sOpt) { + gf_modules_set_option((GF_BaseInterface *)vout, "Video", "UseGLDoubleBuffering", "yes"); + } + if (!sOpt || !strcmp(sOpt, "yes")) { + attribs[i++] = GLX_DOUBLEBUFFER; + attribs[i++] = True; + } + attribs[i++] = None; + + if (nb_bits>8) { + int fbcount=0; + GLXFBConfig *fb=NULL; + typedef GLXFBConfig * (* FnGlXChooseFBConfigProc)( Display *, int, int const *,int * ); + typedef XVisualInfo * (* FnGlXGetVisualFromFBConfigProc)( Display *, GLXFBConfig ); + typedef int (* FnGlXGetFBConfigAttrib) (Display * dpy, GLXFBConfig config, int attribute, int * value); + + + FnGlXChooseFBConfigProc my_glXChooseFBConfig = (FnGlXChooseFBConfigProc) glXGetProcAddress((GLubyte*) "glXChooseFBConfig"); + FnGlXGetVisualFromFBConfigProc my_glXGetVisualFromFBConfig = (FnGlXGetVisualFromFBConfigProc)glXGetProcAddress((GLubyte*) "glXGetVisualFromFBConfig"); + FnGlXGetFBConfigAttrib my_glXGetFBConfigAttrib = (FnGlXGetFBConfigAttrib)glXGetProcAddress((GLubyte*) "glXGetFBConfigAttrib"); + + if (my_glXChooseFBConfig && my_glXGetVisualFromFBConfig) { + fb = my_glXChooseFBConfig(xWindow->display, xWindow->screennum, attribs, &fbcount); + } + + if (fbcount==0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Failed to choose GLX config for 10 bit depth - retrying with 8 bit depth\n")); + nb_bits = 8; + goto retry_8bpp; + } + xWindow->glx_visualinfo = my_glXGetVisualFromFBConfig(xWindow->display, fb[0]); + + if (my_glXGetFBConfigAttrib && fb) { + int r, g, b; + glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_RED_SIZE, &r); + glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_GREEN_SIZE, &g); + glXGetFBConfigAttrib(xWindow->display, fb[0], GLX_BLUE_SIZE, &b); + GF_LOG(GF_LOG_WARNING, GF_LOG_MMIO, ("[GLX] Configured display asked %d bits got r:%d g:%d b:%d bits\n", nb_bits, r, g, b)); + } + } else { + xWindow->glx_visualinfo = glXChooseVisual(xWindow->display, xWindow->screennum, attribs); + } + vout->max_screen_bpp = nb_bits; + + if (!xWindow->glx_visualinfo) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Error selecting GL display\n")); } - } else { - xWindow->glx_visualinfo = glXChooseVisual(xWindow->display, xWindow->screennum, attribs); - } - vout->max_screen_bpp = nb_bits; - - if (!xWindow->glx_visualinfo) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Error selecting GL display\n")); - } } xWindow->gl_wnd = XCreateWindow (xWindow->display, RootWindowOfScreen (xWindow->screenptr), - 0, - 0, - 200, - 200, 0, - xWindow->depth, InputOutput, - xWindow->visual, 0, NULL); + 0, + 0, + 200, + 200, 0, + xWindow->depth, InputOutput, + xWindow->visual, 0, NULL); XSync(xWindow->display, False); XUnmapWindow(xWindow->display, (Window) xWindow->gl_wnd); @@ -1447,12 +1655,12 @@ retry_8bpp: sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "X113DOffscreenMode"); if (!sOpt) gf_modules_set_option((GF_BaseInterface *)vout, "Video", "X113DOffscreenMode", "Pixmap"); - if (sOpt && !strcmp(sOpt, "Window")) { + if (sOpt && !strcmp(sOpt, "Window")) { xWindow->offscreen_type = 1; - } else if (sOpt && !strcmp(sOpt, "VisibleWindow")) { + } else if (sOpt && !strcmp(sOpt, "VisibleWindow")) { xWindow->offscreen_type = 2; XSetWMNormalHints (xWindow->display, xWindow->gl_wnd, Hints); - } else if (sOpt && !strcmp(sOpt, "Pixmap")) { + } else if (sOpt && !strcmp(sOpt, "Pixmap")) { xWindow->offscreen_type = 0; } else { xWindow->offscreen_type = 0; @@ -1495,7 +1703,7 @@ void X11_Shutdown (struct _video_out *vout) } #ifdef GPAC_HAS_OPENGL if (xWindow->glx_visualinfo) - XFree(xWindow->glx_visualinfo); + XFree(xWindow->glx_visualinfo); xWindow->glx_visualinfo = NULL; #endif XFreeGC (xWindow->display, xWindow->the_gc); @@ -1558,7 +1766,7 @@ DeleteX11VideoOutput (GF_VideoOutput * vout) * interface query */ GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { GF_VIDEO_OUTPUT_INTERFACE, diff --git a/modules/x11_out/x11_out.h b/modules/x11_out/x11_out.h index 2a786e0..a02a4de 100644 --- a/modules/x11_out/x11_out.h +++ b/modules/x11_out/x11_out.h @@ -1,7 +1,7 @@ /* * GPAC Multimedia Framework * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _X11_OUT_H @@ -65,7 +65,7 @@ extern "C" #endif #define X11VID() XWindow *xWindow = (XWindow *)vout->opaque; - + #define RGB555(r,g,b) (((r&248)<<7) + ((g&248)<<2) + (b>>3)) #define RGB565(r,g,b) (((r&248)<<8) + ((g&252)<<3) + (b>>3)) @@ -88,13 +88,13 @@ typedef struct Bool use_shared_memory; // /*screensaver state*/ - int ss_t, ss_b, ss_i, ss_e; + int ss_t, ss_b, ss_i, ss_e; #ifdef GPAC_HAS_X11_SHM XShmSegmentInfo *shmseginfo; #endif - /*YUV overlay*/ + /*YUV overlay*/ #ifdef GPAC_HAS_X11_XV int xvport; u32 xv_pf_format; @@ -126,7 +126,7 @@ typedef struct } XWindow; void StretchBits (void *dst, u32 dst_bpp, u32 dst_w, u32 dst_h, u32 dst_pitch, - void *src, u32 src_bpp, u32 src_w, u32 src_h, u32 src_pitch, Bool FlipIt); + void *src, u32 src_bpp, u32 src_w, u32 src_h, u32 src_pitch, Bool FlipIt); #endif /* _X11_OUT_H */ diff --git a/modules/xvid_dec/xvid_dec.c b/modules/xvid_dec/xvid_dec.c index 8376a4f..9696f4c 100644 --- a/modules/xvid_dec/xvid_dec.c +++ b/modules/xvid_dec/xvid_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -85,7 +85,7 @@ static GF_Err XVID_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) xvid_dec_frame_t frame; xvid_dec_create_t par; #endif - + XVIDCTX(); if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return GF_NON_COMPLIANT_BITSTREAM; @@ -166,14 +166,14 @@ static GF_Err XVID_DetachStream(GF_BaseDecoder *ifcg, u16 ES_ID) ctx->base_codec = NULL; ctx->base_ES_ID = 0; ctx->width = ctx->height = ctx->out_size = 0; - } + } else if (ctx->depth_ES_ID == ES_ID) { if (ctx->depth_codec) xvid_decore(ctx->depth_codec, XVID_DEC_DESTROY, NULL, NULL); ctx->depth_codec = NULL; ctx->depth_ES_ID = 0; if (ctx->temp_uv) gf_free(ctx->temp_uv); ctx->temp_uv = NULL; - } + } return GF_OK; } static GF_Err XVID_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *capability) @@ -224,7 +224,7 @@ static GF_Err XVID_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap const char *sOpt = gf_modules_get_option((GF_BaseInterface *)ifcg, "XviD", "Threaded"); capability->cap.valueInt = (sOpt && stricmp(sOpt, "yes")) ? 1 : 0; } - break; + break; /*not known at our level...*/ case GF_CODEC_CU_DURATION: default: @@ -238,11 +238,11 @@ static GF_Err XVID_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa /*return unsupported to avoid confusion by the player (like color space changing ...) */ return GF_NOT_SUPPORTED; } -static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { #ifdef XVID_USE_OLD_API XVID_DEC_FRAME frame; @@ -336,7 +336,12 @@ static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, postproc = 0; /*xvid may keep the first I frame and force a 1-frame delay, so we simply trick it*/ - if (ctx->first_frame) { outBuffer[0] = 'v'; outBuffer[1] = 'o'; outBuffer[2] = 'i'; outBuffer[3] = 'd'; } + if (ctx->first_frame) { + outBuffer[0] = 'v'; + outBuffer[1] = 'o'; + outBuffer[2] = 'i'; + outBuffer[3] = 'd'; + } res = xvid_decore(codec, XVID_DEC_DECODE, &frame, NULL); if (res < 0) { @@ -352,7 +357,7 @@ static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, switch (mmlevel) { case GF_CODEC_LEVEL_SEEK: case GF_CODEC_LEVEL_DROP: - if (ES_ID == ctx->base_ES_ID) + if (ES_ID == ctx->base_ES_ID) *outBufferLength = 0; break; default: @@ -401,7 +406,7 @@ GF_BaseDecoder *NewXVIDDec() const char *sOpt; GF_MediaDecoder *ifcd; XVIDDec *dec; - + GF_SAFEALLOC(ifcd, GF_MediaDecoder); GF_SAFEALLOC(dec, XVIDDec); GF_REGISTER_MODULE_INTERFACE(ifcd, GF_MEDIA_DECODER_INTERFACE, "XviD Decoder", "gpac distribution") @@ -451,7 +456,7 @@ GF_BaseDecoder *NewXVIDDec() } } - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = XVID_AttachStream; ifcd->DetachStream = XVID_DetachStream; ifcd->GetCapabilities = XVID_GetCapabilities; @@ -475,7 +480,7 @@ void DeleteXVIDDec(GF_BaseDecoder *ifcg) GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS @@ -483,11 +488,11 @@ const u32 *QueryInterfaces() #endif 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *)NewXVIDDec(); @@ -500,7 +505,7 @@ void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS - case GF_MEDIA_DECODER_INTERFACE: + case GF_MEDIA_DECODER_INTERFACE: DeleteXVIDDec((GF_BaseDecoder*)ifce); break; #endif diff --git a/modules/xvid_dec/xvid_dec_wce.cpp b/modules/xvid_dec/xvid_dec_wce.cpp index 48fa777..37ddce1 100644 --- a/modules/xvid_dec/xvid_dec_wce.cpp +++ b/modules/xvid_dec/xvid_dec_wce.cpp @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -141,7 +141,7 @@ static GF_Err XVID_GetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability *cap const char *sOpt = gf_modules_get_option((GF_BaseInterface *)ifcg, "XviD", "Threaded"); capability->cap.valueInt = (sOpt && stricmp(sOpt, "yes")) ? 1 : 0; } - break; + break; /*not known at our level...*/ case GF_CODEC_CU_DURATION: default: @@ -155,11 +155,11 @@ static GF_Err XVID_SetCapabilities(GF_BaseDecoder *ifcg, GF_CodecCapability capa /*return unsupported to avoid confusion by the player (like color space changing ...) */ return GF_NOT_SUPPORTED; } -static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, - char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 *CTS, - char *outBuffer, u32 *outBufferLength, - u8 PaddingBits, u32 mmlevel) +static GF_Err XVID_ProcessData(GF_MediaDecoder *ifcg, + char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 *CTS, + char *outBuffer, u32 *outBufferLength, + u8 PaddingBits, u32 mmlevel) { unsigned char *pY, *pU, *pV; u32 i, uv_w, half_h; @@ -235,13 +235,13 @@ GF_BaseDecoder *NewXVIDDec() ifcd = (GF_MediaDecoder*) gf_malloc(sizeof(GF_MediaDecoder)); memset(ifcd, 0, sizeof(GF_MediaDecoder)); - + dec = (XVIDDec*) gf_malloc(sizeof(XVIDDec)); memset(dec, 0, sizeof(XVIDDec)); dec->cb_size = 4; dec->cb_trig = 1; - /*setup our own interface*/ + /*setup our own interface*/ ifcd->AttachStream = XVID_AttachStream; ifcd->DetachStream = XVID_DetachStream; ifcd->GetCapabilities = XVID_GetCapabilities; @@ -268,7 +268,7 @@ extern "C" { #endif GPAC_MODULE_EXPORT -const u32 *QueryInterfaces() +const u32 *QueryInterfaces() { static u32 si [] = { #ifndef GPAC_DISABLE_AV_PARSERS @@ -276,11 +276,11 @@ const u32 *QueryInterfaces() #endif 0 }; - return si; + return si; } GPAC_MODULE_EXPORT -GF_BaseInterface *LoadInterface(u32 InterfaceType) +GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *) NewXVIDDec(); return NULL; @@ -290,7 +290,7 @@ GPAC_MODULE_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { - case GF_MEDIA_DECODER_INTERFACE: + case GF_MEDIA_DECODER_INTERFACE: DeleteXVIDDec((GF_BaseDecoder *)ifce); break; } diff --git a/packagers/win32_64/nsis/gpac_installer.nsi b/packagers/win32_64/nsis/gpac_installer.nsi index cfc28b7..39d709b 100644 --- a/packagers/win32_64/nsis/gpac_installer.nsi +++ b/packagers/win32_64/nsis/gpac_installer.nsi @@ -353,9 +353,10 @@ Section "FFMPEG" SecFFMPEG File "${GPAC_BIN}\avfilter-*.dll" File "${GPAC_BIN}\avformat-*.dll" File "${GPAC_BIN}\avutil-*.dll" - File "${GPAC_BIN}\postproc-*.dll" + File "${GPAC_BIN}\avresample-*.dll" File "${GPAC_BIN}\swresample-*.dll" File "${GPAC_BIN}\swscale-*.dll" + File "${GPAC_BIN}\libx264-*.dll" SectionEnd Section "XviD Video Decoder" SecXVID diff --git a/src/Makefile b/src/Makefile index 0000600..a259298 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,13 +37,17 @@ LIBGPAC_BIFS=bifs/arith_decoder.o bifs/bifs_codec.o bifs/bifs_node_tables.o bifs endif ## libgpac objects gathering: src/isomedia -LIBGPAC_ISOM=isomedia/avc_ext.o isomedia/box_code_3gpp.o isomedia/box_code_apple.o isomedia/box_code_base.o isomedia/box_code_drm.o isomedia/box_code_meta.o isomedia/box_dump.o isomedia/box_funcs.o isomedia/data_map.o isomedia/drm_sample.o isomedia/isom_intern.o isomedia/isom_read.o isomedia/isom_store.o isomedia/isom_write.o isomedia/media.o isomedia/media_odf.o isomedia/meta.o isomedia/movie_fragments.o isomedia/sample_descs.o isomedia/stbl_read.o isomedia/stbl_write.o isomedia/track.o isomedia/tx3g.o isomedia/ttml.o +LIBGPAC_ISOM=isomedia/avc_ext.o isomedia/box_code_3gpp.o isomedia/box_code_apple.o isomedia/box_code_base.o isomedia/box_code_drm.o isomedia/box_code_meta.o isomedia/box_dump.o isomedia/box_funcs.o isomedia/data_map.o isomedia/drm_sample.o isomedia/isom_intern.o isomedia/isom_read.o isomedia/isom_store.o isomedia/isom_write.o isomedia/media.o isomedia/media_odf.o isomedia/meta.o isomedia/movie_fragments.o isomedia/sample_descs.o isomedia/stbl_read.o isomedia/stbl_write.o isomedia/track.o isomedia/tx3g.o ifeq ($(DISABLE_ISOFF_HINT), no) LIBGPAC_ISOM+=isomedia/hint_track.o isomedia/hinting.o endif ifeq ($(DISABLE_ISOM_ADOBE), no) LIBGPAC_ISOM+=isomedia/box_code_adobe.o endif +ifeq ($(DISABLE_TTML), no) +LIBGPAC_ISOM+=isomedia/ttml.o +endif + ## libgpac objects gathering: src/odf LIBGPAC_ODF=odf/desc_private.o odf/descriptors.o odf/odf_code.o odf/odf_codec.o odf/odf_command.o odf/qos.o odf/slc.o diff --git a/src/bifs/arith_decoder.c b/src/bifs/arith_decoder.c index 331d5dc..cb8371f 100644 --- a/src/bifs/arith_decoder.c +++ b/src/bifs/arith_decoder.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * diff --git a/src/bifs/bifs_codec.c b/src/bifs/bifs_codec.c index bfff6e9..5a80e93 100644 --- a/src/bifs/bifs_codec.c +++ b/src/bifs/bifs_codec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,7 +64,7 @@ static GF_Err ParseConfig(GF_BitStream *bs, BIFSStreamInfo *info, u32 version) info->config.BAnimRAP = gf_bs_read_int(bs, 1); info->config.elementaryMasks = gf_list_new(); while (1) { - /*u32 node_id = */gf_bs_read_int(bs, info->config.NodeIDBits); + /*u32 node_id = */gf_bs_read_int(bs, info->config.NodeIDBits); /*this assumes only FDP, BDP and IFS2D (no elem mask)*/ if (gf_bs_read_int(bs, 1) == 0) break; } @@ -93,7 +93,7 @@ GF_BifsDecoder *gf_bifs_decoder_new(GF_SceneGraph *scenegraph, Bool command_dec) tmp->QPs = gf_list_new(); tmp->streamInfo = gf_list_new(); - tmp->info = NULL; + tmp->info = NULL; tmp->pCurrentProto = NULL; tmp->scenegraph = scenegraph; @@ -127,7 +127,7 @@ GF_Err gf_bifs_decoder_configure_stream(GF_BifsDecoder * codec, u16 ESID, char * GF_BitStream *bs; BIFSStreamInfo *pInfo; GF_Err e; - + if (!DecoderSpecificInfo) { /* Hack for T-DMB non compliant streams */ GF_SAFEALLOC(pInfo, BIFSStreamInfo); @@ -204,7 +204,7 @@ GF_Err gf_bifs_decoder_remove_stream(GF_BifsDecoder *codec, u16 ESID) GF_EXPORT void gf_bifs_decoder_del(GF_BifsDecoder *codec) -{ +{ assert(gf_list_count(codec->QPs)==0); gf_list_del(codec->QPs); @@ -270,7 +270,7 @@ GF_Err gf_bifs_decode_au(GF_BifsDecoder *codec, u16 ESID, const char *data, u32 // gf_mx_v(codec->mx); return e; } - + void gf_bifs_decoder_set_time_offset(GF_BifsDecoder *codec, Double ts) { @@ -296,7 +296,7 @@ GF_BifsEncoder *gf_bifs_encoder_new(GF_SceneGraph *graph) if (!tmp) return NULL; tmp->QPs = gf_list_new(); tmp->streamInfo = gf_list_new(); - tmp->info = NULL; + tmp->info = NULL; tmp->encoded_nodes = gf_list_new(); tmp->scene_graph = graph; return tmp; @@ -316,7 +316,7 @@ static BIFSStreamInfo *BE_GetStream(GF_BifsEncoder * codec, u16 ESID) GF_EXPORT void gf_bifs_encoder_del(GF_BifsEncoder *codec) -{ +{ assert(gf_list_count(codec->QPs)==0); gf_list_del(codec->QPs); /*destroy all config*/ @@ -334,15 +334,15 @@ void gf_bifs_encoder_del(GF_BifsEncoder *codec) GF_EXPORT GF_Err gf_bifs_encoder_new_stream(GF_BifsEncoder *codec, u16 ESID, GF_BIFSConfig *cfg, Bool encodeNames, Bool has_predictive) { - u32 i, count; + u32 i, count; BIFSStreamInfo *pInfo; - + // gf_mx_p(codec->mx); if (BE_GetStream(codec, ESID) != NULL) { // gf_mx_v(codec->mx); return GF_BAD_PARAM; } - + GF_SAFEALLOC(pInfo, BIFSStreamInfo); pInfo->ESID = ESID; codec->UseName = encodeNames; @@ -368,7 +368,7 @@ GF_Err gf_bifs_encoder_new_stream(GF_BifsEncoder *codec, u16 ESID, GF_BIFSConfig gf_list_add(pInfo->config.elementaryMasks, bem); } } - + gf_list_add(codec->streamInfo, pInfo); // gf_mx_v(codec->mx); return GF_OK; @@ -450,7 +450,7 @@ GF_Err gf_bifs_encoder_get_config(GF_BifsEncoder *codec, u16 ESID, char **out_da gf_bs_write_int(bs, 0, 1); } } - + gf_bs_align(bs); gf_bs_get_content(bs, out_data, out_data_length); gf_bs_del(bs); @@ -484,12 +484,12 @@ GF_Err gf_bifs_get_field_index(GF_Node *Node, u32 inField, u8 IndexMode, u32 *al switch (Node->sgprivate->tag) { case TAG_ProtoNode: return gf_sg_proto_get_field_ind_static(Node, inField, IndexMode, allField); - case TAG_MPEG4_Script: + case TAG_MPEG4_Script: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Script: + case TAG_X3D_Script: #endif return gf_sg_script_get_field_index(Node, inField, IndexMode, allField); - default: + default: return gf_sg_mpeg4_node_get_field_index(Node, inField, IndexMode, allField); } } @@ -500,8 +500,10 @@ GF_EXPORT Bool gf_bifs_get_aq_info(GF_Node *Node, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (Node->sgprivate->tag) { - case TAG_ProtoNode: return gf_sg_proto_get_aq_info(Node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - default: return gf_sg_mpeg4_node_get_aq_info(Node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_ProtoNode: + return gf_sg_proto_get_aq_info(Node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + default: + return gf_sg_mpeg4_node_get_aq_info(Node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); } } @@ -513,7 +515,7 @@ void gf_bifs_decoder_set_extraction_path(GF_BifsDecoder *codec, const char *path codec->extraction_path = path ? gf_strdup(path) : NULL; if (codec->service_url) gf_free(codec->service_url); codec->service_url = service_url ? gf_strdup(service_url) : NULL; - + } #endif /*GPAC_DISABLE_BIFS*/ diff --git a/src/bifs/bifs_node_tables.c b/src/bifs/bifs_node_tables.c index 987ffde..4f75ca7 100644 --- a/src/bifs/bifs_node_tables.c +++ b/src/bifs/bifs_node_tables.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -1145,7 +1145,8 @@ u32 gf_bifs_get_node_type(u32 NDT_Tag, u32 NodeTag, u32 Version) default: return 0; } -}u32 GetChildrenNDT(GF_Node *node) +} +u32 GetChildrenNDT(GF_Node *node) { if (!node) return 0; switch (gf_node_get_tag(node)) { diff --git a/src/bifs/com_dec.c b/src/bifs/com_dec.c index e0e3365..73ef756 100644 --- a/src/bifs/com_dec.c +++ b/src/bifs/com_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,21 +11,21 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "math.h" #include -#include "quant.h" +#include "quant.h" #ifndef GPAC_DISABLE_BIFS @@ -185,7 +185,7 @@ static GF_Err BD_XReplace(GF_BifsDecoder * codec, GF_BitStream *bs) } gf_bifs_check_field_change(target, &targetField); return GF_OK; - } + } switch (targetField.fieldType) { case GF_SG_VRML_SFNODE: { @@ -243,9 +243,9 @@ static GF_Err BD_XReplace(GF_BifsDecoder * codec, GF_BitStream *bs) if (e) return e; if (fromNode) { - if (fromField.fieldType == targetField.fieldType) + if (fromField.fieldType == targetField.fieldType) gf_sg_vrml_field_clone(targetField.far_ptr, fromField.far_ptr, targetField.fieldType, codec->current_graph); - } else { + } else { e = gf_bifs_dec_field(codec, bs, target, &targetField, 0); } break; @@ -288,7 +288,7 @@ static GF_Err BD_DecMultipleIndexReplace(GF_BifsDecoder * codec, GF_BitStream *b GF_Node *node, *new_node; GF_Err e; GF_FieldInfo field, sffield; - + ID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, ID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; @@ -307,7 +307,7 @@ static GF_Err BD_DecMultipleIndexReplace(GF_BifsDecoder * codec, GF_BitStream *b /*cf index value replace */ if (field.fieldType == GF_SG_VRML_MFNODE) { while (count) { - pos = gf_bs_read_int(bs, lenpos); + pos = gf_bs_read_int(bs, lenpos); /*first decode*/ new_node = gf_bifs_dec_node(codec, bs, field.NDTtype); if (!new_node) return codec->LastError; @@ -350,7 +350,7 @@ static GF_Err BD_DecMultipleReplace(GF_BifsDecoder * codec, GF_BitStream *bs) NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, NodeID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; - + flag = gf_bs_read_int(bs, 1); if (flag) { e = gf_bifs_dec_node_mask(codec, bs, node, 0); @@ -372,7 +372,7 @@ static GF_Err BD_DecGlobalQuantizer(GF_BifsDecoder * codec, GF_BitStream *bs) codec->scenegraph->global_qp = NULL; } codec->ActiveQP = NULL; - + if (!node || (gf_node_get_tag(node) != TAG_MPEG4_QuantizationParameter)) { if (node) gf_node_unregister(node, NULL); return codec->LastError; @@ -438,7 +438,7 @@ static GF_Err BD_DecOperandReplace(GF_BifsDecoder * codec, GF_BitStream *bs) case 3: /*-1 means append*/ pos = ((GenMFField *)field.far_ptr)->count; - if (!pos) + if (!pos) return GF_NON_COMPLIANT_BITSTREAM; pos -= 1; break; @@ -483,7 +483,7 @@ static GF_Err BD_DecOperandReplace(GF_BifsDecoder * codec, GF_BitStream *bs) case 3: /*-1 means append*/ pos = ((GenMFField *)src_field.far_ptr)->count; - if (!pos) + if (!pos) return GF_NON_COMPLIANT_BITSTREAM; pos -= 1; break; @@ -632,7 +632,7 @@ static GF_Err BD_DecIndexInsert(GF_BifsDecoder * codec, GF_BitStream *bs) } else { e = gf_node_list_insert_child((GF_ChildNodeItem **) field.far_ptr, node, pos); } - + if (!e) gf_bifs_check_field_change(def, &field); } else { if (pos == -1) { @@ -678,7 +678,7 @@ static GF_Err BD_DecIndexDelete(GF_BifsDecoder * codec, GF_BitStream *bs) GF_Node *node; GF_Err e; GF_FieldInfo field; - + NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, NodeID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; @@ -713,7 +713,7 @@ static GF_Err BD_DecIndexDelete(GF_BifsDecoder * codec, GF_BitStream *bs) GF_ChildNodeItem** nlist_ptr = (GF_ChildNodeItem**) field.far_ptr; if (*nlist_ptr) { e = gf_node_replace_child(node, nlist_ptr, pos, NULL); - } + } } else { e = gf_sg_vrml_mf_remove(field.far_ptr, field.fieldType, pos); } @@ -760,16 +760,16 @@ static GF_Err BD_DecNodeReplace(GF_BifsDecoder * codec, GF_BitStream *bs) u32 NodeID; GF_Node *node, *new_node; GF_Err e; - + NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); /*this is delete / new on a DEF node: replace ALL instances*/ node = gf_sg_find_node(codec->current_graph, NodeID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; - + /*and just parse a new GF_Node - it is encoded in SFWorldNode table */ new_node = gf_bifs_dec_node(codec, bs, NDT_SFWorldNode); if (!new_node && codec->LastError) return codec->LastError; - + e = gf_node_replace(node, new_node, 0); return e; } @@ -858,7 +858,7 @@ static GF_Err BD_DecIndexValueReplace(GF_BifsDecoder * codec, GF_BitStream *bs) default: return GF_NON_COMPLIANT_BITSTREAM; } - + /*if MFNode remove the child and parse new node*/ if (field.fieldType == GF_SG_VRML_MFNODE) { /*get the new node*/ @@ -904,14 +904,14 @@ static GF_Err BD_DecRouteReplace(GF_BifsDecoder * codec, GF_BitStream *bs) GF_Node *OutNode, *InNode; RouteID = 1+gf_bs_read_int(bs, codec->info->config.RouteIDBits); - + r = gf_sg_route_find(codec->current_graph, RouteID); #ifdef MPEG4_STRICT if (!r) return GF_NON_COMPLIANT_BITSTREAM; ptr = gf_sg_route_get_name(r); gf_sg_route_del(r); #else - ptr = NULL; + ptr = NULL; if (r) { ptr = gf_sg_route_get_name(r); // gf_sg_route_del(r); @@ -1020,7 +1020,7 @@ GF_Err gf_bifs_dec_proto_list(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List /*create a proto in the current graph*/ proto = gf_sg_proto_new(codec->current_graph, ID, name, proto_list ? 1 : 0); if (proto_list) gf_list_add(proto_list, proto); - + /*during parsing, this proto is the current active one - all nodes/proto defined/declared below it will belong to its namespace*/ codec->current_graph = gf_sg_proto_get_graph(proto); @@ -1031,7 +1031,7 @@ GF_Err gf_bifs_dec_proto_list(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List while (flag) { event_type = gf_bs_read_int(bs, 2); field_type = gf_bs_read_int(bs, 6); - + if (codec->UseName) { gf_bifs_dec_name(bs, name); } else { @@ -1109,7 +1109,7 @@ GF_Err gf_bifs_dec_proto_list(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List if (e) goto exit; flag = 1; - + while (flag) { /*parse all nodes in SFWorldNode table*/ node = gf_bifs_dec_node(codec, bs, NDT_SFWorldNode); @@ -1131,7 +1131,7 @@ GF_Err gf_bifs_dec_proto_list(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List gf_sg_proto_add_node_code(proto, node); flag = gf_bs_read_int(bs, 1); } - + /*routes*/ flag = gf_bs_read_int(bs, 1); if (flag) { @@ -1189,7 +1189,7 @@ GF_Err gf_bifs_dec_proto_list(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List break; } field.fieldType = qpsftype; - + qp_min_value = gf_sg_vrml_field_pointer_new(qpsftype); field.name = "QPMinValue"; field.far_ptr = qp_min_value; @@ -1319,7 +1319,7 @@ GF_Err BD_DecSceneReplace(GF_BifsDecoder * codec, GF_BitStream *bs, GF_List *pro /*Parse the routes*/ flag = gf_bs_read_int(bs, 1); - + if (flag) { flag = gf_bs_read_int(bs, 1); if (flag) { diff --git a/src/bifs/com_enc.c b/src/bifs/com_enc.c index 7f86875..52ff239 100644 --- a/src/bifs/com_enc.c +++ b/src/bifs/com_enc.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,21 +11,21 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include -#include "quant.h" +#include "quant.h" #ifndef GPAC_DISABLE_BIFS_ENC @@ -54,10 +54,10 @@ static GF_Err BE_XReplace(GF_BifsEncoder * codec, GF_Command *com, GF_BitStream GF_FieldInfo field; GF_Err e; GF_CommandField *inf; - if (!gf_list_count(com->command_fields)) return GF_BAD_PARAM; + if (!gf_list_count(com->command_fields)) return GF_BAD_PARAM; inf = (GF_CommandField *)gf_list_get(com->command_fields, 0); - + gf_bs_write_int(bs, gf_node_get_id(com->node)-1, codec->info->config.NodeIDBits); nbBits = gf_get_bit_size(gf_node_get_num_fields_in_mode(com->node, GF_SG_FIELD_CODING_IN)-1); gf_bifs_field_index_by_mode(com->node, inf->fieldIndex, GF_SG_FIELD_CODING_IN, &i); @@ -122,8 +122,8 @@ static GF_Err BE_XReplace(GF_BifsEncoder * codec, GF_Command *com, GF_BitStream GF_BIFS_WRITE_INT(codec, bs, i, nbBits, "sourceField", NULL); return GF_OK; - } - + } + GF_BIFS_WRITE_INT(codec, bs, 0, 1, "valueFromNode", NULL); field.far_ptr = inf->field_ptr; @@ -138,10 +138,10 @@ static GF_Err BE_MultipleIndexedReplace(GF_BifsEncoder * codec, GF_Command *com, GF_FieldInfo field; GF_Err e; GF_CommandField *inf; - if (!gf_list_count(com->command_fields)) return GF_OK; + if (!gf_list_count(com->command_fields)) return GF_OK; inf = (GF_CommandField *)gf_list_get(com->command_fields, 0); - + gf_bs_write_int(bs, gf_node_get_id(com->node)-1, codec->info->config.NodeIDBits); nbBits = gf_get_bit_size(gf_node_get_num_fields_in_mode(com->node, GF_SG_FIELD_CODING_IN)-1); gf_bifs_field_index_by_mode(com->node, inf->fieldIndex, GF_SG_FIELD_CODING_IN, &i); @@ -158,7 +158,7 @@ static GF_Err BE_MultipleIndexedReplace(GF_BifsEncoder * codec, GF_Command *com, } nbBitsPos = gf_get_bit_size(maxPos); GF_BIFS_WRITE_INT(codec, bs, nbBitsPos, 5, "nbBitsPos", NULL); - + nbBits = gf_get_bit_size(count); GF_BIFS_WRITE_INT(codec, bs, nbBits, 5, "nbBits", NULL); GF_BIFS_WRITE_INT(codec, bs, count, nbBits, "count", NULL); @@ -227,7 +227,7 @@ static GF_Err BE_GlobalQuantizer(GF_BifsEncoder * codec, GF_Command *com, GF_Bit if (!gf_list_count(com->command_fields)) return GF_OK; inf = (GF_CommandField *)gf_list_get(com->command_fields, 0); if (inf->new_node) ((M_QuantizationParameter *)inf->new_node)->isLocal = 0; - e = gf_bifs_enc_node(codec, inf->new_node, NDT_SFWorldNode, bs); + e = gf_bifs_enc_node(codec, inf->new_node, NDT_SFWorldNode, bs, NULL); if (e) return e; /*reset global QP*/ @@ -236,7 +236,7 @@ static GF_Err BE_GlobalQuantizer(GF_BifsEncoder * codec, GF_Command *com, GF_Bit codec->scene_graph->global_qp = NULL; } codec->ActiveQP = NULL; - + /*no QP*/ if (!inf->new_node) return GF_OK; @@ -326,7 +326,7 @@ GF_Err BE_NodeInsert(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) GF_BIFS_WRITE_INT(codec, bs, inf->pos, 8, "pos", NULL); break; } - return gf_bifs_enc_node(codec, inf->new_node, NDT, bs); + return gf_bifs_enc_node(codec, inf->new_node, NDT, bs, NULL); } GF_Err BE_IndexInsert(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) @@ -359,7 +359,7 @@ GF_Err BE_IndexInsert(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) } e = gf_node_get_field(com->node, inf->fieldIndex, &field); if (e) return e; - if (gf_sg_vrml_is_sf_field(field.fieldType)) + if (gf_sg_vrml_is_sf_field(field.fieldType)) return GF_NON_COMPLIANT_BITSTREAM; memcpy(&sffield, &field, sizeof(GF_FieldInfo)); @@ -368,7 +368,7 @@ GF_Err BE_IndexInsert(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) /*rescale the MFField and parse the SFField*/ if (field.fieldType==GF_SG_VRML_MFNODE) { - return gf_bifs_enc_node(codec, inf->new_node, field.NDTtype, bs); + return gf_bifs_enc_node(codec, inf->new_node, field.NDTtype, bs, com->node); } else { return gf_bifs_enc_sf_field(codec, bs, com->node, &sffield); } @@ -412,7 +412,7 @@ GF_Err BE_NodeReplace(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) if (!gf_list_count(com->command_fields)) return GF_OK; inf = (GF_CommandField *)gf_list_get(com->command_fields, 0); GF_BIFS_WRITE_INT(codec, bs, gf_node_get_id(com->node) - 1, codec->info->config.NodeIDBits, "NodeID", NULL); - return gf_bifs_enc_node(codec, inf->new_node, NDT_SFWorldNode, bs); + return gf_bifs_enc_node(codec, inf->new_node, NDT_SFWorldNode, bs, NULL); } GF_Err BE_FieldReplace(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) @@ -433,7 +433,7 @@ GF_Err BE_FieldReplace(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *bs) e = gf_node_get_field(com->node, inf->fieldIndex, &field); if (e) return e; field.far_ptr = inf->field_ptr; - + /* Warning: To be changed when proper solution is found */ if (gf_sg_vrml_get_sf_type(field.fieldType) == GF_SG_VRML_SFSCRIPT) codec->is_encoding_command = 1; @@ -458,9 +458,9 @@ GF_Err BE_IndexFieldReplace(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream GF_BIFS_WRITE_INT(codec, bs, ind, NumBits, "field", NULL); e = gf_node_get_field(com->node, inf->fieldIndex, &field); - if (gf_sg_vrml_is_sf_field(field.fieldType)) + if (gf_sg_vrml_is_sf_field(field.fieldType)) return GF_NON_COMPLIANT_BITSTREAM; - + switch (inf->pos) { case 0: GF_BIFS_WRITE_INT(codec, bs, 2, 2, "FIRST", "idx"); @@ -473,9 +473,9 @@ GF_Err BE_IndexFieldReplace(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream GF_BIFS_WRITE_INT(codec, bs, inf->pos, 16, "pos", NULL); break; } - + if (field.fieldType == GF_SG_VRML_MFNODE) { - e = gf_bifs_enc_node(codec, inf->new_node, field.NDTtype, bs); + e = gf_bifs_enc_node(codec, inf->new_node, field.NDTtype, bs, com->node); } else { memcpy(&sffield, &field, sizeof(GF_FieldInfo)); sffield.fieldType = gf_sg_vrml_get_sf_type(field.fieldType); @@ -538,7 +538,7 @@ GF_Err BE_EncProtoList(GF_BifsEncoder *codec, GF_List *protoList, GF_BitStream * GF_BIFS_WRITE_INT(codec, bs, 0, 1, "moreProto", NULL); return GF_OK; } - if (!codec->info->config.ProtoIDBits) + if (!codec->info->config.ProtoIDBits) return GF_NON_COMPLIANT_BITSTREAM; /*store state*/ @@ -567,7 +567,7 @@ GF_Err BE_EncProtoList(GF_BifsEncoder *codec, GF_List *protoList, GF_BitStream * GF_BIFS_WRITE_INT(codec, bs, 1, 1, "moreField", NULL); GF_BIFS_WRITE_INT(codec, bs, proto_field->EventType, 2, "eventType", NULL); GF_BIFS_WRITE_INT(codec, bs, proto_field->FieldType, 6, "fieldType", NULL); - + if (codec->UseName) gf_bifs_enc_name(codec, bs, proto_field->FieldName); switch (proto_field->EventType) { case GF_SG_EVENT_EXPOSED_FIELD: @@ -586,7 +586,7 @@ GF_Err BE_EncProtoList(GF_BifsEncoder *codec, GF_List *protoList, GF_BitStream * if (proto_field->Anim_Type) useAnim = 1; } GF_BIFS_WRITE_INT(codec, bs, 0, 1, "moreField", NULL); - + GF_BIFS_WRITE_INT(codec, bs, proto->ExternProto.count ? 1 : 0, 1, "externProto", NULL); /*externProto*/ if (proto->ExternProto.count) { @@ -606,13 +606,13 @@ GF_Err BE_EncProtoList(GF_BifsEncoder *codec, GF_List *protoList, GF_BitStream * count = gf_list_count(proto->node_code); /*BIFS cannot encode empty protos ! We therefore encode a NULL node instead*/ if (!count) { - gf_bifs_enc_node(codec, NULL, NDT_SFWorldNode, bs); + gf_bifs_enc_node(codec, NULL, NDT_SFWorldNode, bs, NULL); GF_BIFS_WRITE_INT(codec, bs, 0, 1, "moreNodes", NULL); } else { for (j=0; jnode_code, j); - e = gf_bifs_enc_node(codec, node, NDT_SFWorldNode, bs); + e = gf_bifs_enc_node(codec, node, NDT_SFWorldNode, bs, NULL); if (e) goto exit; GF_BIFS_WRITE_INT(codec, bs, (j+1==count) ? 0 : 1, 1, "moreNodes", NULL); } @@ -755,7 +755,7 @@ GF_Err BE_SceneReplaceEx(GF_BifsEncoder *codec, GF_Command *com, GF_BitStream *b } /*NULL root is valid for ProtoLibraries*/ - e = gf_bifs_enc_node(codec, com->node, NDT_SFTopNode, bs); + e = gf_bifs_enc_node(codec, com->node, NDT_SFTopNode, bs, NULL); if (e || !gf_list_count(routes) ) { GF_BIFS_WRITE_INT(codec, bs, 0, 1, "hasRoute", NULL); return codec->LastError = e; @@ -802,7 +802,7 @@ GF_Err BE_SceneReplace(GF_BifsEncoder *codec, GF_SceneGraph *graph, GF_BitStream if (e) goto exit; /*NULL root is valid for ProtoLibraries*/ - e = gf_bifs_enc_node(codec, graph ? graph->RootNode : NULL, NDT_SFTopNode, bs); + e = gf_bifs_enc_node(codec, graph ? graph->RootNode : NULL, NDT_SFTopNode, bs, NULL); if (e || !graph || !gf_list_count(graph->Routes) ) { GF_BIFS_WRITE_INT(codec, bs, 0, 1, "hasRoute", NULL); return codec->LastError = e; @@ -853,7 +853,7 @@ GF_Err gf_bifs_enc_commands(GF_BifsEncoder *codec, GF_List *comList, GF_BitStrea /*reset node context*/ while (gf_list_count(codec->encoded_nodes)) gf_list_rem(codec->encoded_nodes, 0); GF_BIFS_WRITE_INT(codec, bs, 3, 2, "SceneReplace", NULL); - + if (!com->aggregated) { routes = gf_list_new(); /*now the trick: get all following InsertRoutes and convert as routes*/ @@ -882,7 +882,7 @@ GF_Err gf_bifs_enc_commands(GF_BifsEncoder *codec, GF_List *comList, GF_BitStrea e = BE_SceneReplaceEx(codec, com, bs, codec->scene_graph->Routes); } } - break; + break; /*replace commands*/ case GF_SG_NODE_REPLACE: GF_BIFS_WRITE_INT(codec, bs, 2, 2, "Replace", NULL); @@ -970,7 +970,7 @@ GF_Err gf_bifs_encoder_get_rap(GF_BifsEncoder *codec, char **out_data, u32 *out_ gf_bs_get_content(bs, out_data, out_data_length); } gf_bs_del(bs); - + /*restore context*/ gf_list_del(codec->encoded_nodes); codec->encoded_nodes = ctx_bck; diff --git a/src/bifs/conditional.c b/src/bifs/conditional.c index 2a1db48..50b19a8 100644 --- a/src/bifs/conditional.c +++ b/src/bifs/conditional.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/src/bifs/field_decode.c b/src/bifs/field_decode.c index b8f084b..63c62ae 100644 --- a/src/bifs/field_decode.c +++ b/src/bifs/field_decode.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,23 +11,23 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include -#include "quant.h" -#include "script.h" +#include "quant.h" +#include "script.h" #ifndef GPAC_DISABLE_BIFS @@ -54,7 +54,7 @@ void BD_OffsetSFTime(GF_BifsDecoder * codec, Double *time) void BD_CheckSFTimeOffset(GF_BifsDecoder *codec, GF_Node *node, GF_FieldInfo *inf) { if (gf_node_get_tag(node) != TAG_ProtoNode) { - if (!stricmp(inf->name, "startTime") || !stricmp(inf->name, "stopTime")) + if (!stricmp(inf->name, "startTime") || !stricmp(inf->name, "stopTime")) BD_OffsetSFTime(codec, (Double *)inf->far_ptr); } else if (gf_sg_proto_field_is_sftime_offset(node, inf)) { BD_OffsetSFTime(codec, (Double *)inf->far_ptr); @@ -64,7 +64,7 @@ void BD_CheckSFTimeOffset(GF_BifsDecoder *codec, GF_Node *node, GF_FieldInfo *in Fixed BD_ReadSFFloat(GF_BifsDecoder * codec, GF_BitStream *bs) { - if (codec->ActiveQP && codec->ActiveQP->useEfficientCoding) + if (codec->ActiveQP && codec->ActiveQP->useEfficientCoding) return gf_bifs_dec_mantissa_float(codec, bs); return FLT2FIX(gf_bs_read_float(bs)); @@ -140,7 +140,7 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n ((SFString *)field->far_ptr)->buffer = (char *)gf_malloc(sizeof(char)*(length+1)); memset(((SFString *)field->far_ptr)->buffer , 0, length+1); for (i=0; ifar_ptr)->buffer[i] = gf_bs_read_int(bs, 8); + ((SFString *)field->far_ptr)->buffer[i] = gf_bs_read_int(bs, 8); } } break; @@ -174,7 +174,7 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n } } } - break; + break; case GF_SG_VRML_SFIMAGE: if (((SFImage *)field->far_ptr)->pixels) gf_free(((SFImage *)field->far_ptr)->pixels); w = gf_bs_read_int(bs, 12); @@ -198,7 +198,7 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n { SFCommandBuffer *sfcb = (SFCommandBuffer *)field->far_ptr; if (sfcb->buffer) { - gf_free(sfcb->buffer); + gf_free(sfcb->buffer); sfcb->buffer = NULL; } while (gf_list_count(sfcb->commandList)) { @@ -219,7 +219,7 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n sfcb->buffer[i] = gf_bs_read_int(bs, 8); } } - //notify the node - this is needed in case an enhencement layer replaces the buffer, in which case + //notify the node - this is needed in case an enhencement layer replaces the buffer, in which case //the # ID Bits may change SFCommandBufferChanged(codec, node); @@ -233,8 +233,8 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n cbi->cb = sfcb; gf_list_add(codec->command_buffers, cbi); } - } - break; + } + break; case GF_SG_VRML_SFNODE: //for nodes the field ptr is a ptr to the field, which is a node ptr ;) new_node = gf_bifs_dec_node(codec, bs, field->NDTtype); @@ -265,7 +265,7 @@ GF_Err gf_bifs_dec_sf_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *n codec->LastError = gf_bifs_get_field_index(ar->node, field_ref, GF_SG_FIELD_CODING_DEF, &ar->fieldIndex); } } - break; + break; default: return GF_NON_COMPLIANT_BITSTREAM; } @@ -281,7 +281,7 @@ GF_Err BD_DecMFFieldList(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node u32 nbF; GF_FieldInfo sffield; - + memset(&sffield, 0, sizeof(GF_FieldInfo)); sffield.fieldIndex = field->fieldIndex; sffield.fieldType = gf_sg_vrml_get_sf_type(field->fieldType); @@ -321,10 +321,10 @@ GF_Err BD_DecMFFieldList(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node gf_node_register(new_node, NULL); gf_node_unregister(new_node, node); } - } else + } else //this is generic MFNode container e = gf_node_list_add_child_last(field->far_ptr, new_node, &last); - + } //proto coding: directly add the child else if (codec->pCurrentProto) { @@ -339,7 +339,7 @@ GF_Err BD_DecMFFieldList(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node endFlag = gf_bs_read_int(bs, 1); - //according to the spec, the QP applies to the current node itself, + //according to the spec, the QP applies to the current node itself, //not just children. If IsLocal is TRUE remove the node if (qp_on && qp_local) { if (qp_local == 2) { @@ -370,7 +370,7 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, u8 qp_local, qp_on, initial_qp; GF_Node *new_node; GF_FieldInfo sffield; - + memset(&sffield, 0, sizeof(GF_FieldInfo)); sffield.fieldIndex = field->fieldIndex; sffield.fieldType = gf_sg_vrml_get_sf_type(field->fieldType); @@ -378,7 +378,7 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, initial_qp = qp_local = qp_on = 0; - //vector description - alloc the MF size before + //vector description - alloc the MF size before NbBits = gf_bs_read_int(bs, 5); nbFields = gf_bs_read_int(bs, NbBits); @@ -392,14 +392,14 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, e = gf_sg_vrml_mf_alloc(field->far_ptr, field->fieldType, nbFields); if (e) return e; - for (i=0;ifar_ptr, field->fieldType, & sffield.far_ptr, i); if (e) return e; e = gf_bifs_dec_sf_field(codec, bs, node, &sffield, 0); } } else { last = NULL; - for (i=0;iNDTtype); if (new_node) { e = gf_node_register(new_node, is_mem_com ? NULL : node); @@ -410,7 +410,7 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, if (gf_node_get_tag(new_node) == TAG_MPEG4_QuantizationParameter) { qp_local = ((M_QuantizationParameter *)new_node)->isLocal; /*we have a QP in the same scope, remove previous - NB: we assume this is the right behaviour, the spec doesn't say + NB: we assume this is the right behaviour, the spec doesn't say whether QP is cumulative or not*/ if (qp_on) gf_bifs_dec_qp_remove(codec, 0); @@ -427,7 +427,7 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, } else { e = gf_node_list_add_child_last(field->far_ptr, new_node, &last); } - } + } /*proto coding*/ else if (codec->pCurrentProto) { /*TO DO: what happens if this is a QP node on the interface ?*/ @@ -437,7 +437,7 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node, return codec->LastError ? codec->LastError : GF_NON_COMPLIANT_BITSTREAM; } } - /*according to the spec, the QP applies to the current node itself, not just children. + /*according to the spec, the QP applies to the current node itself, not just children. If IsLocal is TRUE remove the node*/ if (qp_on && qp_local) { if (qp_local == 2) { @@ -480,7 +480,7 @@ GF_Err gf_bifs_dec_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node assert(node); // if (field->fieldType == GF_SG_VRML_UNKNOWN) return GF_NON_COMPLIANT_BITSTREAM; - + if (gf_sg_vrml_is_sf_field(field->fieldType)) { e = gf_bifs_dec_sf_field(codec, bs, node, field, is_mem_com); if (e) return e; @@ -499,7 +499,7 @@ GF_Err gf_bifs_dec_field(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node /*predictiveMFField*/ if (codec->info->config.UsePredictiveMFField) { flag = gf_bs_read_int(bs, 1); - if (flag) { + if (flag) { GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[BIFS] Stream uses Predictive Field Coding!\n")); #ifdef GPAC_ENABLE_BIFS_PMF return gf_bifs_dec_pred_mf_field(codec, bs, node, field); @@ -617,7 +617,7 @@ GF_Err gf_bifs_dec_node_mask(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node * if (e) return e; e = BD_SetProtoISed(codec, flag, node, i); } - //regular field, parse it (nb: no contextual coding for protos in maskNode, + //regular field, parse it (nb: no contextual coding for protos in maskNode, //all node fields are coded else { e = gf_node_get_field(node, i, &field); @@ -684,7 +684,7 @@ static void UpdateTimeNode(GF_BifsDecoder * codec, GF_Node *node) BD_CheckSFTimeOffset(codec, node, &inf); } } - break; + break; } } @@ -726,21 +726,21 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) /*restore QP14 length*/ switch (gf_node_get_tag(new_node)) { case TAG_MPEG4_Coordinate: - { - u32 nbCoord = ((M_Coordinate *)new_node)->point.count; - gf_bifs_dec_qp14_enter(codec, 1); - gf_bifs_dec_qp14_set_length(codec, nbCoord); - gf_bifs_dec_qp14_enter(codec, 0); - } - break; + { + u32 nbCoord = ((M_Coordinate *)new_node)->point.count; + gf_bifs_dec_qp14_enter(codec, 1); + gf_bifs_dec_qp14_set_length(codec, nbCoord); + gf_bifs_dec_qp14_enter(codec, 0); + } + break; case TAG_MPEG4_Coordinate2D: - { - u32 nbCoord = ((M_Coordinate2D *)new_node)->point.count; - gf_bifs_dec_qp14_enter(codec, 1); - gf_bifs_dec_qp14_set_length(codec, nbCoord); - gf_bifs_dec_qp14_enter(codec, 0); - } - break; + { + u32 nbCoord = ((M_Coordinate2D *)new_node)->point.count; + gf_bifs_dec_qp14_enter(codec, 1); + gf_bifs_dec_qp14_set_length(codec, nbCoord); + gf_bifs_dec_qp14_enter(codec, 0); + } + break; } } return new_node; @@ -842,7 +842,7 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) } } #endif - + if (!new_node) { if (proto) { skip_init = 1; @@ -857,7 +857,7 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) return NULL; } - /*VRML: "The transformation hierarchy shall be a directed acyclic graph; results are undefined if a node + /*VRML: "The transformation hierarchy shall be a directed acyclic graph; results are undefined if a node in the transformation hierarchy is its own ancestor" that's good, because the scene graph can't handle cyclic graphs (destroy will never be called). We therefore only register the node once parsed*/ @@ -878,7 +878,7 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) /*if coords were not stored for QP14 before coding this node, reset QP14 it when leaving*/ reset_qp14 = !codec->coord_stored; - /*QP 14 is a special quant mode for IndexFace/Line(2D)Set to quantize the + /*QP 14 is a special quant mode for IndexFace/Line(2D)Set to quantize the coordonate(2D) child, based on the first field parsed we must check the type of the node and notfy the QP*/ switch (node_tag) { @@ -892,7 +892,7 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) } else { e = gf_bifs_dec_node_list(codec, bs, new_node, proto ? 1 : 0); } - if (codec->coord_stored && reset_qp14) + if (codec->coord_stored && reset_qp14) gf_bifs_dec_qp14_reset(codec); if (e) { @@ -904,7 +904,7 @@ GF_Node *gf_bifs_dec_node(GF_BifsDecoder * codec, GF_BitStream *bs, u32 NDT_Tag) return NULL; } - if (!skip_init) + if (!skip_init) gf_node_init(new_node); switch (node_tag) { diff --git a/src/bifs/field_encode.c b/src/bifs/field_encode.c index 321b445..227fe80 100644 --- a/src/bifs/field_encode.c +++ b/src/bifs/field_encode.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -27,8 +27,8 @@ #include #include -#include "quant.h" -#include "script.h" +#include "quant.h" +#include "script.h" #ifndef GPAC_DISABLE_BIFS_ENC @@ -55,7 +55,7 @@ void BE_WriteSFFloat(GF_BifsEncoder *codec, Fixed val, GF_BitStream *bs, char *c gf_bifs_enc_mantissa_float(codec, val, bs); } else { gf_bs_write_float(bs, FIX2FLT(val)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] SFFloat\t\t32\t\t%g\t\t%s\n", FIX2FLT(val), com ? com : "") ); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] SFFloat\t\t32\t\t%g\t\t%s\n", FIX2FLT(val), com ? com : "") ); } } @@ -132,7 +132,7 @@ GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no BE_WriteSFFloat(codec, ((SFVec2f *)field->far_ptr)->x, bs, "vec2f.x"); BE_WriteSFFloat(codec, ((SFVec2f *)field->far_ptr)->y, bs, "vec2f.y"); break; - + case GF_SG_VRML_SFVEC3F: BE_WriteSFFloat(codec, ((SFVec3f *)field->far_ptr)->x, bs, "vec3f.x"); BE_WriteSFFloat(codec, ((SFVec3f *)field->far_ptr)->y, bs, "vec3f.y"); @@ -154,7 +154,7 @@ GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] string\t\t%d\t\t%s\t\t//SFURL\n", 8*len, url->url)); } } - break; + break; case GF_SG_VRML_SFIMAGE: { u32 size, i; @@ -166,7 +166,7 @@ GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no for (i=0; ipixels[i], 8); GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] pixels\t\t%d\t\tnot dumped\t\t//SFImage\n", 8*size)); } - break; + break; case GF_SG_VRML_SFCOMMANDBUFFER: { @@ -193,10 +193,10 @@ GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no GF_BIFS_WRITE_INT(codec, bs, 0, 5, "NbBits", NULL); } } - break; + break; case GF_SG_VRML_SFNODE: - return gf_bifs_enc_node(codec, *((GF_Node **)field->far_ptr), field->NDTtype, bs); + return gf_bifs_enc_node(codec, *((GF_Node **)field->far_ptr), field->NDTtype, bs, node); case GF_SG_VRML_SFSCRIPT: #ifdef GPAC_HAS_SPIDERMONKEY @@ -211,11 +211,11 @@ GF_Err gf_bifs_enc_sf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no SFAttrRef *ar = (SFAttrRef *)field->far_ptr; u32 nbBitsDEF = gf_get_bit_size(gf_node_get_num_fields_in_mode(ar->node, GF_SG_FIELD_CODING_DEF) - 1); GF_BIFS_WRITE_INT(codec, bs, gf_node_get_id(ar->node) - 1, codec->info->config.NodeIDBits, "NodeID", NULL); - + gf_bifs_field_index_by_mode(ar->node, ar->fieldIndex, GF_SG_FIELD_CODING_DEF, &idx); GF_BIFS_WRITE_INT(codec, bs, idx, nbBitsDEF, "field", NULL); } - break; + break; default: return GF_NOT_SUPPORTED; } @@ -231,7 +231,7 @@ GF_Err gf_bifs_enc_mf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no Bool use_list, qp_on, initial_qp; u32 nbF, i; GF_FieldInfo sffield; - + nbF = 0; if (field->fieldType != GF_SG_VRML_MFNODE) { nbF = field->far_ptr ? ((GenMFField *)field->far_ptr)->count : 0; @@ -278,7 +278,7 @@ GF_Err gf_bifs_enc_mf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no e = gf_bifs_enc_sf_field(codec, bs, node, &sffield); } else { assert(list); - e = gf_bifs_enc_node(codec, list->node, field->NDTtype, bs); + e = gf_bifs_enc_node(codec, list->node, field->NDTtype, bs, node); /*activate QP*/ if (list->node->sgprivate->tag == TAG_MPEG4_QuantizationParameter) { @@ -291,7 +291,7 @@ GF_Err gf_bifs_enc_mf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no } list = list->next; } - + if (e) return e; if (qp_on && qp_local) { @@ -314,9 +314,9 @@ GF_Err gf_bifs_enc_mf_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node *no GF_Err gf_bifs_enc_field(GF_BifsEncoder * codec, GF_BitStream *bs, GF_Node *node, GF_FieldInfo *field) { assert(node); - if (field->fieldType == GF_SG_VRML_UNKNOWN) + if (field->fieldType == GF_SG_VRML_UNKNOWN) return GF_NON_COMPLIANT_BITSTREAM; - + if (gf_sg_vrml_is_sf_field(field->fieldType)) { return gf_bifs_enc_sf_field(codec, bs, node, field); } @@ -393,7 +393,7 @@ GF_Err EncNodeFields(GF_BifsEncoder * codec, GF_BitStream *bs, GF_Node *node) clone = gf_node_new(node->sgprivate->scenegraph, node->sgprivate->tag); } if (clone) gf_node_register(clone, NULL); - + numBitsDEF = gf_get_bit_size(gf_node_get_num_fields_in_mode(node, GF_SG_FIELD_CODING_DEF) - 1); enc_fields = (s32*)gf_malloc(sizeof(s32) * count); @@ -423,23 +423,36 @@ GF_Err EncNodeFields(GF_BifsEncoder * codec, GF_BitStream *bs, GF_Node *node) /*if field is default skip*/ switch (field.fieldType) { case GF_SG_VRML_SFNODE: - if (* (GF_Node **) field.far_ptr) { enc_fields[i] = allInd; nbFinal++; } + if (* (GF_Node **) field.far_ptr) { + enc_fields[i] = allInd; + nbFinal++; + } break; case GF_SG_VRML_MFNODE: - if (* (GF_ChildNodeItem **) field.far_ptr) { enc_fields[i] = allInd; nbFinal++; } + if (* (GF_ChildNodeItem **) field.far_ptr) { + enc_fields[i] = allInd; + nbFinal++; + } break; case GF_SG_VRML_SFCOMMANDBUFFER: { SFCommandBuffer *cb = (SFCommandBuffer *)field.far_ptr; - if (gf_list_count(cb->commandList)) { enc_fields[i] = allInd; nbFinal++; } + if (gf_list_count(cb->commandList)) { + enc_fields[i] = allInd; + nbFinal++; + } } - break; + break; case GF_SG_VRML_MFSCRIPT: - enc_fields[i] = allInd; nbFinal++; + enc_fields[i] = allInd; + nbFinal++; break; default: gf_node_get_field(clone, allInd, &clone_field); - if (!gf_sg_vrml_field_equal(clone_field.far_ptr, field.far_ptr, field.fieldType)) { enc_fields[i] = allInd; nbFinal++; } + if (!gf_sg_vrml_field_equal(clone_field.far_ptr, field.far_ptr, field.fieldType)) { + enc_fields[i] = allInd; + nbFinal++; + } break; } } @@ -456,7 +469,7 @@ GF_Err EncNodeFields(GF_BifsEncoder * codec, GF_BitStream *bs, GF_Node *node) use_list = 1; } /*number of bits in mask node is count*1, in list node is 1+nbFinal*(1+numBitsDEF) */ - else if (count < 1+nbFinal*(1+numBitsDEF)) + else if (count < 1+nbFinal*(1+numBitsDEF)) use_list = 0; GF_BIFS_WRITE_INT(codec, bs, use_list ? 0 : 1, 1, "isMask", NULL); @@ -532,7 +545,7 @@ Bool BE_NodeIsUSE(GF_BifsEncoder * codec, GF_Node *node) return 0; } -GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_BitStream *bs) +GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_BitStream *bs, GF_Node *parent_node) { u32 NDTBits, node_type, node_tag, BVersion, node_id; const char *node_name; @@ -541,6 +554,7 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B GF_Err e; assert(codec->info); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[BIFS] Encode node %s\n", gf_node_get_class_name(node) )); /*NULL node is a USE of maxID*/ if (!node) { @@ -555,9 +569,9 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B if (flag) { gf_bs_write_int(bs, gf_node_get_id(node) - 1, codec->info->config.NodeIDBits); new_node = gf_bifs_enc_find_node(codec, gf_node_get_id(node) ); - if (!new_node) + if (!new_node) return codec->LastError = GF_SG_UNKNOWN_NODE; - + /*restore QP14 length*/ switch (gf_node_get_tag(new_node)) { case TAG_MPEG4_Coordinate: @@ -567,7 +581,7 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B gf_bifs_enc_qp14_set_length(codec, nbCoord); gf_bifs_enc_qp14_enter(codec, 0); } - break; + break; case TAG_MPEG4_Coordinate2D: { u32 nbCoord = ((M_Coordinate2D *)new_node)->point.count; @@ -575,7 +589,7 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B gf_bifs_enc_qp14_set_length(codec, nbCoord); gf_bifs_enc_qp14_enter(codec, 0); } - break; + break; } return GF_OK; } @@ -590,7 +604,14 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B if (node_type) break; BVersion += 1; - if (BVersion > GF_BIFS_NUM_VERSION) return codec->LastError = GF_BIFS_UNKNOWN_VERSION; + if (BVersion > GF_BIFS_NUM_VERSION) { + if (parent_node) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[BIFS] Cannot encode node %s as a child of %s\n", gf_node_get_class_name(node), gf_node_get_class_name(parent_node) )); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[BIFS] Cannot encode node %s in the SFWorldNode context\n", gf_node_get_class_name(node) )); + } + return codec->LastError = GF_BIFS_UNKNOWN_VERSION; + } } if (BVersion==2 && node_type==1) { GF_Proto *proto = ((GF_ProtoInstance *)node)->proto_interface; @@ -622,7 +643,7 @@ GF_Err gf_bifs_enc_node(GF_BifsEncoder * codec, GF_Node *node, u32 NDT_Tag, GF_B e = EncNodeFields(codec, bs, node); if (e) return e; - if (codec->coord_stored && reset_qp14) + if (codec->coord_stored && reset_qp14) gf_bifs_enc_qp14_reset(codec); switch (node_tag) { diff --git a/src/bifs/memory_decoder.c b/src/bifs/memory_decoder.c index 3d57eb9..edd1b57 100644 --- a/src/bifs/memory_decoder.c +++ b/src/bifs/memory_decoder.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,7 +48,7 @@ static GF_Err BM_ParseMultipleIndexedReplace(GF_BifsDecoder *codec, GF_BitStream GF_Command *com; GF_CommandField *inf; GF_FieldInfo field; - + ID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, ID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; @@ -62,7 +62,7 @@ static GF_Err BM_ParseMultipleIndexedReplace(GF_BifsDecoder *codec, GF_BitStream lenpos = gf_bs_read_int(bs, 5); lennum = gf_bs_read_int(bs, 5); count = gf_bs_read_int(bs, lennum); - + com = gf_sg_command_new(codec->current_graph, GF_SG_MULTIPLE_INDEXED_REPLACE); BM_SetCommandNode(com, node); field.fieldType = gf_sg_vrml_get_sf_type(field.fieldType); @@ -72,7 +72,7 @@ static GF_Err BM_ParseMultipleIndexedReplace(GF_BifsDecoder *codec, GF_BitStream inf->pos = gf_bs_read_int(bs, lenpos); inf->fieldIndex = field.fieldIndex; inf->fieldType = field.fieldType; - + if (field.fieldType==GF_SG_VRML_SFNODE) { inf->new_node = gf_bifs_dec_node(codec, bs, field.NDTtype); if (codec->LastError) goto err; @@ -104,7 +104,7 @@ static GF_Err BM_ParseMultipleReplace(GF_BifsDecoder *codec, GF_BitStream *bs, G NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, NodeID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; - + e = GF_OK; com = gf_sg_command_new(codec->current_graph, GF_SG_MULTIPLE_REPLACE); BM_SetCommandNode(com, node); @@ -155,7 +155,7 @@ static GF_Err BM_ParseMultipleReplace(GF_BifsDecoder *codec, GF_BitStream *bs, G } } - + exit: if (e) gf_sg_command_del(com); else gf_list_add(com_list, com); @@ -175,7 +175,7 @@ static GF_Err BM_ParseGlobalQuantizer(GF_BifsDecoder *codec, GF_BitStream *bs, G } codec->ActiveQP = NULL; codec->scenegraph->global_qp = NULL; - + if (node && (gf_node_get_tag(node) != TAG_MPEG4_QuantizationParameter)) { gf_node_unregister(node, NULL); return GF_NON_COMPLIANT_BITSTREAM; @@ -239,7 +239,7 @@ static GF_Err BM_XReplace(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com_ id = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); target = gf_sg_find_node(codec->current_graph, id); if (!target) return GF_SG_UNKNOWN_NODE; - + e = GF_OK; com = gf_sg_command_new(codec->current_graph, GF_SG_XREPLACE); BM_SetCommandNode(com, target); @@ -364,7 +364,7 @@ static GF_Err BM_ParseExtendedUpdates(GF_BifsDecoder *codec, GF_BitStream *bs, G if (e) gf_sg_command_del(com); else gf_list_add(com_list, com); } - return e; + return e; case 1: return BM_ParseProtoDelete(codec, bs, com_list); case 2: @@ -388,7 +388,7 @@ static GF_Err BM_ParseExtendedUpdates(GF_BifsDecoder *codec, GF_BitStream *bs, G BM_SetCommandNode(com, n); gf_list_add(com_list, com); } - return GF_OK; + return GF_OK; case 7: return BM_XReplace(codec, bs, com_list); @@ -599,7 +599,7 @@ GF_Err BM_ParseIndexDelete(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com GF_Err e; GF_CommandField *inf; GF_FieldInfo field; - + NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); node = gf_sg_find_node(codec->current_graph, NodeID); if (!node) return GF_NON_COMPLIANT_BITSTREAM; @@ -675,7 +675,7 @@ GF_Err BM_ParseNodeReplace(GF_BifsDecoder *codec, GF_BitStream *bs, GF_List *com GF_Command *com; GF_Node *node; GF_CommandField *inf; - + NodeID = 1 + gf_bs_read_int(bs, codec->info->config.NodeIDBits); /*this is delete / new on a DEF node: replace ALL instances*/ node = gf_sg_find_node(codec->current_graph, NodeID); @@ -767,7 +767,7 @@ GF_Err BM_ParseIndexValueReplace(GF_BifsDecoder *codec, GF_BitStream *bs, GF_Lis default: return GF_NON_COMPLIANT_BITSTREAM; } - + com = gf_sg_command_new(codec->current_graph, GF_SG_INDEXED_REPLACE); BM_SetCommandNode(com, node); inf = gf_sg_command_field_new(com); diff --git a/src/bifs/predictive_mffield.c b/src/bifs/predictive_mffield.c index 8d0c426..a4397cd 100644 --- a/src/bifs/predictive_mffield.c +++ b/src/bifs/predictive_mffield.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,7 +42,7 @@ typedef struct SFVec3f BMin, BMax; s32 direction, orientation, inverse; - + u32 cur_field; GF_AAModel *models[3]; @@ -73,7 +73,7 @@ Fixed PMF_UnquantizeFloat(s32 vq, Fixed BMin, Fixed BMax, u32 NbBits, Bool unit_ scale = width/2; } } - return BMin + scale * vq; + return BMin + scale * vq; } GF_Err PMF_UnquantizeNormal(PredMF *pmf, GF_FieldInfo *field) @@ -81,17 +81,17 @@ GF_Err PMF_UnquantizeNormal(PredMF *pmf, GF_FieldInfo *field) void *slot; Fixed comp[3]; Fixed tang[2]; - u32 i; + u32 i; Fixed delta=FIX_ONE; - for (i=0; i<2; i++) { + for (i=0; i<2; i++) { Fixed v = PMF_UnquantizeFloat(pmf->current_val[i] - (1<< (pmf->QNbBits -1) ), 0 , FIX_ONE, pmf->QNbBits, 1); tang[i]= gf_tan(gf_mulfix(GF_PI * 4, v)); delta += gf_mulfix(tang[i], tang[i]); } - delta = gf_divfix(pmf->direction, gf_sqrt(delta) ); + delta = gf_divfix(pmf->direction, gf_sqrt(delta) ); - comp[(pmf->orientation) % 3] = delta; - for (i=0; i<2; i++) + comp[(pmf->orientation) % 3] = delta; + for (i=0; i<2; i++) comp[(pmf->orientation + i+1)%3] = gf_mulfix(tang[i], delta); gf_sg_vrml_mf_get_item(field->far_ptr, field->fieldType, &slot, pmf->cur_field); @@ -114,12 +114,12 @@ GF_Err PMF_UnquantizeRotation(PredMF *pmf, GF_FieldInfo *field) tang[i] = gf_tan(gf_mulfix(GF_PI / 4, v)); delta += gf_mulfix(tang[i], tang[i]); } - delta = gf_divfix(pmf->direction , gf_sqrt(delta) ); + delta = gf_divfix(pmf->direction , gf_sqrt(delta) ); - comp[(pmf->orientation)%4] = delta; - for (i=0; i<3; i++) + comp[(pmf->orientation)%4] = delta; + for (i=0; i<3; i++) comp[(pmf->orientation + i+1)%4] = gf_mulfix(tang[i], delta); - + gf_sg_vrml_mf_get_item(field->far_ptr, field->fieldType, &slot, pmf->cur_field); delta = 2 * gf_acos(comp[0]); sine = gf_sin(delta / 2); @@ -204,44 +204,44 @@ GF_Err PMF_ParsePValue(PredMF *pmf, GF_BitStream *bs, GF_FieldInfo *field) case QC_NORMALS: case QC_ROTATION: /*NOT TESTED*/ - { - s32 temp_val[3]; - s32 diff_dir = prev_dir * (pmf->direction ? -1 : 1); - s32 inv=1; - s32 diff_ori = 0; - s32 shift = 1 << (pmf->QNbBits - 1); - - for (i=0; i<3; i++) { - pmf->previous_val[i] -= shift; - pmf->current_val[i] -= shift; + { + s32 temp_val[3]; + s32 diff_dir = prev_dir * (pmf->direction ? -1 : 1); + s32 inv=1; + s32 diff_ori = 0; + s32 shift = 1 << (pmf->QNbBits - 1); + + for (i=0; i<3; i++) { + pmf->previous_val[i] -= shift; + pmf->current_val[i] -= shift; + } + for (i=0; i< pmf->num_comp; i++) { + temp_val[i] = pmf->previous_val[i] + pmf->current_val[i]; + if ( abs(temp_val[i]) > shift - 1) { + diff_ori = i+1; + inv = ( temp_val[i] > 0) ? 1 : -1; + break; } - for (i=0; i< pmf->num_comp; i++) { - temp_val[i] = pmf->previous_val[i] + pmf->current_val[i]; - if ( abs(temp_val[i]) > shift - 1) { - diff_ori = i+1; - inv = ( temp_val[i] > 0) ? 1 : -1; - break; - } + } + if (diff_ori != 0) { + s32 k=0; + for (i=0; i< pmf->num_comp - diff_ori; i++) { + k = (i + diff_ori) % pmf->num_comp; + temp_val[i] = inv * ( pmf->previous_val[i] + pmf->current_val[i]); } - if (diff_ori != 0) { - s32 k=0; - for (i=0; i< pmf->num_comp - diff_ori; i++) { - k = (i + diff_ori) % pmf->num_comp; - temp_val[i] = inv * ( pmf->previous_val[i] + pmf->current_val[i]); - } - k = diff_ori - 1; - temp_val[pmf->num_comp - diff_ori] = inv * 2 * (shift - 1) - (pmf->previous_val[k] + pmf->current_val[k]) ; - for (i = pmf->num_comp - diff_ori + 1; inum_comp; i++) { - k = (i+diff_ori-1) % pmf->num_comp; - temp_val[i] = inv * (pmf->previous_val[k] + pmf->current_val[k]); - } + k = diff_ori - 1; + temp_val[pmf->num_comp - diff_ori] = inv * 2 * (shift - 1) - (pmf->previous_val[k] + pmf->current_val[k]) ; + for (i = pmf->num_comp - diff_ori + 1; inum_comp; i++) { + k = (i+diff_ori-1) % pmf->num_comp; + temp_val[i] = inv * (pmf->previous_val[k] + pmf->current_val[k]); } - pmf->orientation = (pmf->orientation + diff_ori) % (pmf->num_comp + 1); - pmf->direction = diff_dir * inv; - for (i=0; i< pmf->num_comp; i++) - pmf->current_val[i]= temp_val[i] + shift; } - break; + pmf->orientation = (pmf->orientation + diff_ori) % (pmf->num_comp + 1); + pmf->direction = diff_dir * inv; + for (i=0; i< pmf->num_comp; i++) + pmf->current_val[i]= temp_val[i] + shift; + } + break; default: for (i=0; i< pmf->num_comp; i++) pmf->current_val[i] += pmf->previous_val[i]; @@ -309,14 +309,14 @@ GF_Err gf_bifs_dec_pred_mf_field(GF_BifsDecoder *codec, GF_BitStream *bs, GF_Nod Fixed b_min, b_max; u32 i, flag; PredMF pmf; - + memset(&pmf, 0, sizeof(PredMF)); - + HasQ = gf_bifs_get_aq_info(node, field->fieldIndex, &pmf.QType, &AType, &b_min, &b_max, &pmf.QNbBits); if (!HasQ || !pmf.QType) return GF_EOS; /*get NbBits for QP14 (QC_COORD_INDEX)*/ - if (pmf.QType == QC_COORD_INDEX) + if (pmf.QType == QC_COORD_INDEX) pmf.QNbBits = gf_bifs_dec_qp14_get_bits(codec); pmf.BMin.x = pmf.BMin.y = pmf.BMin.z = b_min; @@ -324,7 +324,7 @@ GF_Err gf_bifs_dec_pred_mf_field(GF_BifsDecoder *codec, GF_BitStream *bs, GF_Nod /*check is the QP is on and retrieves the bounds*/ if (!Q_IsTypeOn(codec->ActiveQP, pmf.QType, &pmf.QNbBits, &pmf.BMin, &pmf.BMax)) return GF_EOS; - + switch (field->fieldType) { case GF_SG_VRML_MFCOLOR: case GF_SG_VRML_MFVEC3F: @@ -355,7 +355,7 @@ GF_Err gf_bifs_dec_pred_mf_field(GF_BifsDecoder *codec, GF_BitStream *bs, GF_Nod case 1: flag = gf_bs_read_int(bs, 5); pmf.intra_inter = gf_bs_read_int(bs, flag); - /*no break*/ + /*no break*/ case 2: case 0: pmf.compNbBits = gf_bs_read_int(bs, 5); diff --git a/src/bifs/quant.h b/src/bifs/quant.h index 6d45add..5543d15 100644 --- a/src/bifs/quant.h +++ b/src/bifs/quant.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,20 +35,20 @@ enum { QC_NONE = 0, - QC_3DPOS = 1, - QC_2DPOS = 2, - QC_ORDER = 3, - QC_COLOR = 4, - QC_TEXTURE_COORD = 5, - QC_ANGLE = 6, - QC_SCALE = 7, - QC_INTERPOL_KEYS = 8, - QC_NORMALS = 9, - QC_ROTATION = 10, - QC_SIZE_3D = 11, - QC_SIZE_2D = 12, - QC_LINEAR_SCALAR = 13, - QC_COORD_INDEX = 14, + QC_3DPOS = 1, + QC_2DPOS = 2, + QC_ORDER = 3, + QC_COLOR = 4, + QC_TEXTURE_COORD = 5, + QC_ANGLE = 6, + QC_SCALE = 7, + QC_INTERPOL_KEYS = 8, + QC_NORMALS = 9, + QC_ROTATION = 10, + QC_SIZE_3D = 11, + QC_SIZE_2D = 12, + QC_LINEAR_SCALAR = 13, + QC_COORD_INDEX = 14, QC_RESERVED = 15, QC_NOTDEF = 16, }; @@ -119,4 +119,4 @@ void gp_bifs_aa_dec_reset(GF_AADecoder *dec); #endif /*GPAC_DISABLE_BIFS*/ -#endif +#endif diff --git a/src/bifs/quantize.c b/src/bifs/quantize.c index b38b403..cd61ea9 100644 --- a/src/bifs/quantize.c +++ b/src/bifs/quantize.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -33,9 +33,9 @@ GF_Err gf_bifs_enc_qp_set(GF_BifsEncoder *codec, GF_Node *qp) if (gf_node_get_tag(qp) != TAG_MPEG4_QuantizationParameter) return GF_BAD_PARAM; /*if we have an active QP, push it into the stack*/ - if (codec->ActiveQP && ((GF_Node*)codec->ActiveQP != codec->scene_graph->global_qp) ) + if (codec->ActiveQP && ((GF_Node*)codec->ActiveQP != codec->scene_graph->global_qp) ) gf_list_insert(codec->QPs, codec->ActiveQP, 0); - + codec->ActiveQP = (M_QuantizationParameter *)qp; return GF_OK; } @@ -58,7 +58,7 @@ GF_Err gf_bifs_enc_qp_remove(GF_BifsEncoder *codec, Bool ActivatePrev) u32 gf_bifs_enc_qp14_get_bits(GF_BifsEncoder *codec) { if (!codec->ActiveQP || !codec->coord_stored) return 0; - return (u32) ceil(log(codec->NumCoord+1) / log(2) ); + return (u32) ceil(log(codec->NumCoord+1) / log(2) ); } void gf_bifs_enc_qp14_enter(GF_BifsEncoder *codec, Bool Enter) @@ -90,31 +90,31 @@ void gf_bifs_enc_mantissa_float(GF_BifsEncoder *codec, Fixed ft, GF_BitStream *b s32 exp; union - { + { Float f; s32 l; } ft_val; if (ft == 0) { - gf_bs_write_int(bs, 0, 4); + gf_bs_write_int(bs, 0, 4); return; } ft_val.f = FIX2FLT(ft); - + mantSign = ((ft_val.l & 0x80000000) >> 31) & 0x1; mantissa = (ft_val.l & 0x007FFFFF) >> 9; mantLength = 15; expSign=0; exp =(((ft_val.l & 0x7F800000) >> 23)-127); expLength = 8; - + if (mantissa == 0) mantLength = 1; - + if (exp) { if (exp< 0) { expSign = 1; - exp = -exp; + exp = -exp; } while ((exp & (1<<(--expLength)))==0) { } exp &= ~(1<0; ++nbBits) i >>= 1; @@ -207,7 +207,7 @@ GF_Err Q_EncInt(GF_BifsEncoder *codec, GF_BitStream *bs, u32 QType, SFInt32 b_mi } } -GF_Err Q_EncCoordOnUnitSphere(GF_BifsEncoder *codec, GF_BitStream *bs, u32 NbBits, u32 NbComp, Fixed *m_ft) +GF_Err Q_EncCoordOnUnitSphere(GF_BifsEncoder *codec, GF_BitStream *bs, u32 NbBits, u32 NbComp, Fixed *m_ft) { u32 i; u32 len = NbComp+1; @@ -219,7 +219,7 @@ GF_Err Q_EncCoordOnUnitSphere(GF_BifsEncoder *codec, GF_BitStream *bs, u32 NbBit orientation = i; } } - if(NbComp==2) gf_bs_write_int(bs, ((m_ft[orientation]>0) ? 0 : 1), 1); + if(NbComp==2) gf_bs_write_int(bs, ((m_ft[orientation]>0) ? 0 : 1), 1); gf_bs_write_int(bs, orientation, 2); for (i=0; ifieldIndex, &QType, &AType, &b_min, &b_max, &NbBits); if (!HasQ || !QType) return GF_EOS; @@ -288,7 +288,7 @@ GF_Err gf_bifs_enc_quant_field(GF_BifsEncoder *codec, GF_BitStream *bs, GF_Node if (QType == QC_COORD_INDEX) { NbBits = gf_bifs_enc_qp14_get_bits(codec); /*QP14 is always on, not having NbBits set means the coord field is set after the index field, hence not decodable*/ - if (!NbBits) + if (!NbBits) return GF_NON_COMPLIANT_BITSTREAM; } diff --git a/src/bifs/script.h b/src/bifs/script.h index d60fa97..5a43241 100644 --- a/src/bifs/script.h +++ b/src/bifs/script.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,14 +34,14 @@ #define NUMBITS_EXPR_TYPE 6 #define MAX_NUM_EXPR 100 -enum +enum { - ST_IF=0, - ST_FOR=1, - ST_WHILE=2, - ST_RETURN=3, - ST_BREAK=5, - ST_CONTINUE=6, + ST_IF=0, + ST_FOR=1, + ST_WHILE=2, + ST_RETURN=3, + ST_BREAK=5, + ST_CONTINUE=6, ST_COMPOUND_EXPR=4, ST_SWITCH=7 }; @@ -90,7 +90,7 @@ enum ET_MOD=39, ET_LAND=40, ET_LOR=41, - ET_AND=42, + ET_AND=42, ET_OR=43, ET_XOR=44, ET_LSHIFT=45, diff --git a/src/bifs/script_dec.c b/src/bifs/script_dec.c index f1461b6..7827e2c 100644 --- a/src/bifs/script_dec.c +++ b/src/bifs/script_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -136,9 +136,15 @@ GF_Err ParseScriptField(ScriptParser *parser) return parser->codec->LastError; } -static void SFS_IncIndent(ScriptParser *pars) { pars->indent++; } -static void SFS_DecIndent(ScriptParser *pars) { pars->indent--; } -static void SFS_Space(ScriptParser *pars) { if (pars->new_line) SFS_AddString(pars, " ");} +static void SFS_IncIndent(ScriptParser *pars) { + pars->indent++; +} +static void SFS_DecIndent(ScriptParser *pars) { + pars->indent--; +} +static void SFS_Space(ScriptParser *pars) { + if (pars->new_line) SFS_AddString(pars, " "); +} static void SFS_Indent(ScriptParser *pars) { u32 i; @@ -177,7 +183,7 @@ GF_Err SFScript_Parse(GF_BifsDecoder *codec, SFScript *script_field, GF_BitStrea if (gf_bs_read_int(bs, 1)) { //endFlag - while (!gf_bs_read_int(bs, 1)){ + while (!gf_bs_read_int(bs, 1)) { e = ParseScriptField(&parser); if (e) goto exit; } @@ -237,7 +243,7 @@ void SFS_Identifier(ScriptParser *parser) SFS_AddString(parser, (char *)gf_list_get(parser->identifiers, index)); } //parse - else{ + else { gf_bifs_dec_name(parser->bs, name); gf_list_add(parser->identifiers, gf_strdup(name)); SFS_AddString(parser, name); @@ -263,7 +269,7 @@ void SFS_StatementBlock(ScriptParser *parser, Bool funcBody) { if (parser->codec->LastError) return; - if (gf_bs_read_int(parser->bs, 1)) { + if (gf_bs_read_int(parser->bs, 1)) { SFS_AddString(parser, "{"); SFS_IncIndent(parser); @@ -486,16 +492,16 @@ void SFS_Expression(ScriptParser *parser) SFS_FunctionCall(parser); break; case ET_NEW: - SFS_NewObject(parser); + SFS_NewObject(parser); break; case ET_OBJECT_MEMBER_ACCESS: - SFS_ObjectMemberAccess(parser); + SFS_ObjectMemberAccess(parser); break; case ET_OBJECT_METHOD_CALL: - SFS_ObjectMethodCall(parser); + SFS_ObjectMethodCall(parser); break; case ET_ARRAY_DEREFERENCE: - SFS_ArrayDeref(parser); + SFS_ArrayDeref(parser); break; case ET_MULTIPLY: @@ -653,9 +659,9 @@ void SFS_Expression(ScriptParser *parser) SFS_AddString(parser, "|="); SFS_Expression(parser); break; - case ET_BOOLEAN: + case ET_BOOLEAN: SFS_GetBoolean(parser); - break; + break; case ET_VAR: SFS_AddString(parser, "var "); SFS_Arguments(parser, 1); @@ -675,7 +681,7 @@ void SFS_NewObject(ScriptParser *parser) { if (parser->codec->LastError) return; SFS_AddString(parser, "new "); - SFS_Identifier(parser); + SFS_Identifier(parser); SFS_AddString(parser, "("); SFS_Params(parser); SFS_AddString(parser, ") "); @@ -685,7 +691,7 @@ void SFS_ArrayDeref(ScriptParser *parser) { if (parser->codec->LastError) return; SFS_Expression(parser); - SFS_AddString(parser, "["); + SFS_AddString(parser, "["); SFS_CompoundExpression(parser); SFS_AddString(parser, "]"); } @@ -704,7 +710,7 @@ void SFS_ObjectMemberAccess(ScriptParser *parser) if (parser->codec->LastError) return; SFS_Expression(parser); SFS_AddString(parser, "."); - SFS_Identifier(parser); + SFS_Identifier(parser); } @@ -752,7 +758,7 @@ void SFS_GetNumber(ScriptParser *parser) SFS_AddChar(parser, '.'); } else if (val==11) { SFS_AddChar(parser, 'E'); - } else if (val==12){ + } else if (val==12) { SFS_AddChar(parser, '-'); } val = gf_bs_read_int(parser->bs, 4); diff --git a/src/bifs/script_enc.c b/src/bifs/script_enc.c index 4ebf8ae..2c7323d 100644 --- a/src/bifs/script_enc.c +++ b/src/bifs/script_enc.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -33,7 +33,7 @@ #if !defined(GPAC_DISABLE_BIFS) && !defined(GPAC_DISABLE_BIFS_ENC) && defined(GPAC_HAS_SPIDERMONKEY) -typedef struct +typedef struct { GF_Node *script; GF_BifsEncoder *codec; @@ -57,7 +57,7 @@ typedef struct #define SFE_WRITE_INT(sc_enc, val, nbBits, str1, str2) \ if (!sc_enc->emul) GF_BIFS_WRITE_INT(sc_enc->codec, sc_enc->bs, val, nbBits, str1, str2); \ - + static GF_Err EncScriptFields(ScriptEnc *sc_enc) { @@ -134,7 +134,7 @@ static GF_Err EncScriptFields(ScriptEnc *sc_enc) -enum +enum { TOK_FUNCTION, TOK_IF, @@ -201,7 +201,7 @@ enum TOK_STRING, TOK_NUMBER, TOK_EOF, - TOK_BOOLEAN + TOK_BOOLEAN }; const char *tok_names[] = @@ -218,7 +218,7 @@ const char *tok_names[] = "switch", "case", "default", - "var", + "var", "{", "}", "(", @@ -269,7 +269,7 @@ const char *tok_names[] = "identifier", "string", "number", - "boolean", + "boolean", "end of script" }; @@ -294,13 +294,13 @@ Bool SFE_GetNumber(ScriptEnc *sc_enc) { u32 i = 0; Bool exp = 0; - while ( isdigit(sc_enc->cur_buf[i]) - || (toupper(sc_enc->cur_buf[i])=='X') - || ((toupper(sc_enc->cur_buf[i]) >='A') && (toupper(sc_enc->cur_buf[i])<='F')) - || (sc_enc->cur_buf[i]=='.') - || (tolower(sc_enc->cur_buf[i])=='e') - || (exp && (sc_enc->cur_buf[i] == '-')) - ) { + while ( isdigit(sc_enc->cur_buf[i]) + || (toupper(sc_enc->cur_buf[i])=='X') + || ((toupper(sc_enc->cur_buf[i]) >='A') && (toupper(sc_enc->cur_buf[i])<='F')) + || (sc_enc->cur_buf[i]=='.') + || (tolower(sc_enc->cur_buf[i])=='e') + || (exp && (sc_enc->cur_buf[i] == '-')) + ) { sc_enc->token[i] = sc_enc->cur_buf[i]; if (tolower(sc_enc->cur_buf[i])=='e') exp = 1; i++; @@ -362,9 +362,9 @@ Bool SFE_NextToken(ScriptEnc *sc_enc) /*get a number*/ if (isdigit(sc_enc->cur_buf[i])) return SFE_GetNumber(sc_enc); /*get a string*/ - if ((sc_enc->cur_buf[i]=='\'') || (sc_enc->cur_buf[i]=='\"') - || ((sc_enc->cur_buf[i]=='\\') && (sc_enc->cur_buf[i+1]=='\"')) - ) { + if ((sc_enc->cur_buf[i]=='\'') || (sc_enc->cur_buf[i]=='\"') + || ((sc_enc->cur_buf[i]=='\\') && (sc_enc->cur_buf[i+1]=='\"')) + ) { char end; Bool skip_last = 0; end = sc_enc->cur_buf[i]; @@ -407,7 +407,7 @@ Bool SFE_NextToken(ScriptEnc *sc_enc) } else { sc_enc->token_code = TOK_ASSIGN; } - break; + break; case '+': if(sc_enc->cur_buf[i+1]=='=') { sc_enc->token_code = TOK_PLUSEQ; @@ -575,7 +575,7 @@ Bool SFE_CheckToken(ScriptEnc *sc_enc, u32 token) return 1; } -void SFE_PutIdentifier(ScriptEnc *sc_enc, char *id) +void SFE_PutIdentifier(ScriptEnc *sc_enc, char *id) { u32 i; u32 nbBits, length; @@ -589,11 +589,14 @@ void SFE_PutIdentifier(ScriptEnc *sc_enc, char *id) nbBits = 0; length = gf_list_count(sc_enc->identifiers) - 1; - while (length > 0) { length >>= 1; nbBits ++; } + while (length > 0) { + length >>= 1; + nbBits ++; + } GF_BIFS_WRITE_INT(sc_enc->codec, sc_enc->bs, 1, 1, "received", str); GF_BIFS_WRITE_INT(sc_enc->codec, sc_enc->bs, i-1, nbBits, "identifierCode", str); return; - } + } GF_BIFS_WRITE_INT(sc_enc->codec, sc_enc->bs, 0, 1, "received", id); gf_list_add(sc_enc->identifiers, gf_strdup(id)); gf_bifs_enc_name(sc_enc->codec, sc_enc->bs, id); @@ -643,7 +646,7 @@ u32 SFE_LoadExpression(ScriptEnc *sc_enc, u32 *expr_sep) u32 nbExpr = 1; u32 nbIndir = 0; expr_sep[0] = 0; - + sc_enc->expr_toks_len = 0; while ( (sc_enc->token_code != TOK_SEMICOLON) && (sc_enc->token_code != TOK_RIGHT_CURVE) ) { @@ -681,16 +684,16 @@ u32 SFE_LoadExpression(ScriptEnc *sc_enc, u32 *expr_sep) else if (sc_enc->token_code == TOK_LEFT_BRACE) close_code = TOK_RIGHT_BRACE; /*other expr*/ - if ((sc_enc->token_code == TOK_COMMA) && (sc_enc->expr_toks[0] != TOK_VAR) ){ + if ((sc_enc->token_code == TOK_COMMA) && (sc_enc->expr_toks[0] != TOK_VAR) ) { expr_sep[nbExpr++] = sc_enc->expr_toks_len - 1; - } + } /*sub-expr*/ else if (close_code) { count++; do { SFE_NextToken(sc_enc); - if ((sc_enc->token_code == TOK_IDENTIFIER) || (sc_enc->token_code == TOK_NUMBER) - || (sc_enc->token_code == TOK_STRING) || (sc_enc->token_code == TOK_BOOLEAN) ) { + if ((sc_enc->token_code == TOK_IDENTIFIER) || (sc_enc->token_code == TOK_NUMBER) + || (sc_enc->token_code == TOK_STRING) || (sc_enc->token_code == TOK_BOOLEAN) ) { gf_list_add(sc_enc->id_buf, gf_strdup(sc_enc->token)); } sc_enc->expr_toks[sc_enc->expr_toks_len] = sc_enc->token_code; @@ -708,11 +711,11 @@ break_loop: return 0; } expr_sep[nbExpr] = sc_enc->expr_toks_len; - if ((sc_enc->token_code == TOK_IDENTIFIER) || (sc_enc->token_code == TOK_NUMBER) - || (sc_enc->token_code == TOK_STRING) || (sc_enc->token_code == TOK_BOOLEAN) ) { + if ((sc_enc->token_code == TOK_IDENTIFIER) || (sc_enc->token_code == TOK_NUMBER) + || (sc_enc->token_code == TOK_STRING) || (sc_enc->token_code == TOK_BOOLEAN) ) { gf_list_add(sc_enc->id_buf, gf_strdup(sc_enc->token)); } - + if ((sc_enc->token_code != TOK_CONDSEP) && (sc_enc->token_code != TOK_RIGHT_BRACE) && (sc_enc->expr_toks[0] != TOK_VAR)) { sc_enc->expr_toks[sc_enc->expr_toks_len] = sc_enc->token_code; sc_enc->expr_toks_len++; @@ -813,11 +816,11 @@ void SFE_ForStatement(ScriptEnc *sc_enc) SFE_NextToken(sc_enc); SFE_OptionalExpression(sc_enc); SFE_CheckToken(sc_enc, TOK_SEMICOLON); - + SFE_NextToken(sc_enc); SFE_OptionalExpression(sc_enc); SFE_CheckToken(sc_enc, TOK_SEMICOLON); - + SFE_NextToken(sc_enc); SFE_OptionalExpression(sc_enc); SFE_CheckToken(sc_enc, TOK_RIGHT_CURVE); @@ -853,18 +856,18 @@ void SFE_CaseBlock(ScriptEnc *sc_enc) SFE_NextToken(sc_enc); if (sc_enc->token_code == TOK_LEFT_BRACE) { SFE_NextToken(sc_enc); - while (sc_enc->token_code != TOK_RIGHT_BRACE) { + while (sc_enc->token_code != TOK_RIGHT_BRACE) { SFE_WRITE_INT(sc_enc, 1, 1, "hasStatement", NULL); - SFE_Statement(sc_enc); + SFE_Statement(sc_enc); SFE_NextToken(sc_enc); - } + } SFE_NextToken(sc_enc); } - while ((sc_enc->token_code != TOK_CASE) && (sc_enc->token_code != TOK_DEFAULT) && (sc_enc->token_code != TOK_RIGHT_BRACE)) { + while ((sc_enc->token_code != TOK_CASE) && (sc_enc->token_code != TOK_DEFAULT) && (sc_enc->token_code != TOK_RIGHT_BRACE)) { SFE_WRITE_INT(sc_enc, 1, 1, "hasStatement", NULL); SFE_Statement(sc_enc); SFE_NextToken(sc_enc); - } + } SFE_WRITE_INT(sc_enc, 0, 1, "hasStatement", NULL); } @@ -914,7 +917,7 @@ void SFE_SwitchStatement(ScriptEnc *sc_enc) sc_enc->emul = 1; SFE_NextToken(sc_enc); - while (sc_enc->token_code == TOK_CASE) { + while (sc_enc->token_code == TOK_CASE) { SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_NUMBER); nbBits = SFE_PutCaseInteger(sc_enc, sc_enc->token, 0); @@ -923,19 +926,19 @@ void SFE_SwitchStatement(ScriptEnc *sc_enc) SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_CONDSEP); - SFE_CaseBlock(sc_enc); + SFE_CaseBlock(sc_enc); SFE_WRITE_INT(sc_enc, (sc_enc->token_code == TOK_CASE) ? 1 : 0, 1, "hasMoreCases", NULL); - } + } /*second pass in parent mode*/ sc_enc->cur_buf = buf_bck; - sc_enc->token_code = tok_bck; + sc_enc->token_code = tok_bck; sc_enc->emul = prev_emu; maxBits ++; SFE_WRITE_INT(sc_enc, maxBits, 5, "caseNbBits", NULL); SFE_NextToken(sc_enc); - while (sc_enc->token_code == TOK_CASE) { + while (sc_enc->token_code == TOK_CASE) { SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_NUMBER); SFE_PutCaseInteger(sc_enc, sc_enc->token, maxBits); @@ -943,18 +946,18 @@ void SFE_SwitchStatement(ScriptEnc *sc_enc) SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_CONDSEP); - SFE_CaseBlock(sc_enc); + SFE_CaseBlock(sc_enc); SFE_WRITE_INT(sc_enc, (sc_enc->token_code == TOK_CASE) ? 1 : 0, 1, "hasMoreCases", NULL); - } + } - if (sc_enc->token_code == TOK_DEFAULT) { + if (sc_enc->token_code == TOK_DEFAULT) { SFE_WRITE_INT(sc_enc, 1, 1, "hasDefault", NULL); SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_CONDSEP); - SFE_CaseBlock(sc_enc); - } else { + SFE_CaseBlock(sc_enc); + } else { SFE_WRITE_INT(sc_enc, 0, 1, "hasDefault", NULL); - } + } SFE_CheckToken(sc_enc, TOK_RIGHT_BRACE); } @@ -1029,7 +1032,7 @@ void SFE_Function(ScriptEnc *sc_enc) SFE_CheckToken(sc_enc, TOK_IDENTIFIER); strcpy(szName, sc_enc->token); SFE_PutIdentifier(sc_enc, sc_enc->token); - + SFE_NextToken(sc_enc); SFE_CheckToken(sc_enc, TOK_LEFT_CURVE); @@ -1057,7 +1060,7 @@ GF_Err SFScript_Encode(GF_BifsEncoder *codec, SFScript *script_field, GF_BitStre if (codec->is_encoding_command) { GF_BIFS_WRITE_INT(codec, bs, 1, 1, "Script::isList", NULL); GF_BIFS_WRITE_INT(codec, bs, 1, 1, "end", NULL); - } else { + } else { EncScriptFields(&sc_enc); } /*reserevd*/ @@ -1069,10 +1072,10 @@ GF_Err SFScript_Encode(GF_BifsEncoder *codec, SFScript *script_field, GF_BitStre sc_enc.cur_buf = (char *)((M_Script*)n)->url.vals[0].script_text; } if (sc_enc.cur_buf) { - if (!strnicmp(sc_enc.cur_buf, "javascript:", 11) - || !strnicmp(sc_enc.cur_buf, "vrmlscript:", 11) - || !strnicmp(sc_enc.cur_buf, "ECMAScript:", 11) - ) { + if (!strnicmp(sc_enc.cur_buf, "javascript:", 11) + || !strnicmp(sc_enc.cur_buf, "vrmlscript:", 11) + || !strnicmp(sc_enc.cur_buf, "ECMAScript:", 11) + ) { sc_enc.cur_buf += 11; } else if (!strnicmp(sc_enc.cur_buf, "mpeg4script:", 12) ) { sc_enc.cur_buf += 12; @@ -1105,7 +1108,7 @@ GF_Err SFScript_Encode(GF_BifsEncoder *codec, SFScript *script_field, GF_BitStre gf_free(ptr); } gf_list_del(sc_enc.id_buf); - + return sc_enc.err; } @@ -1116,14 +1119,22 @@ void SFE_PutReal(ScriptEnc *sc_enc, char *str) size_t length = strlen(str); for (i=0; i= '0' && c <= '9') - { SFE_WRITE_INT(sc_enc, c-'0', 4, "floatChar", "Digital"); } - else if (c == '.') - { SFE_WRITE_INT(sc_enc, 10, 4, "floatChar", "Decimal Point"); } - else if (c == 'e' || c == 'E') - { SFE_WRITE_INT(sc_enc, 11, 4, "floatChar", "Exponential");} - else if (c == '-') - {SFE_WRITE_INT(sc_enc, 12, 4, "floatChar", "Sign");} + if (c >= '0' && c <= '9') + { + SFE_WRITE_INT(sc_enc, c-'0', 4, "floatChar", "Digital"); + } + else if (c == '.') + { + SFE_WRITE_INT(sc_enc, 10, 4, "floatChar", "Decimal Point"); + } + else if (c == 'e' || c == 'E') + { + SFE_WRITE_INT(sc_enc, 11, 4, "floatChar", "Exponential"); + } + else if (c == '-') + { + SFE_WRITE_INT(sc_enc, 12, 4, "floatChar", "Sign"); + } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[bifs] Script encoding: %s is not a real number\n", str)); sc_enc->err = GF_BAD_PARAM; @@ -1133,9 +1144,9 @@ void SFE_PutReal(ScriptEnc *sc_enc, char *str) SFE_WRITE_INT(sc_enc, 15, 4, "floatChar", "End Symbol"); } -void SFE_PutNumber(ScriptEnc *sc_enc, char *str) +void SFE_PutNumber(ScriptEnc *sc_enc, char *str) { - if (strpbrk(str,".eE-") == 0) { + if (strpbrk(str,".eE-") == 0) { SFE_WRITE_INT(sc_enc, 1, 1, "isInteger", "integer"); SFE_PutInteger(sc_enc, str); } else { @@ -1146,7 +1157,7 @@ void SFE_PutNumber(ScriptEnc *sc_enc, char *str) void SFE_PutBoolean(ScriptEnc *sc_enc, char *str) { - u32 v = 1; + u32 v = 1; if (!stricmp(str, "false") || !strcmp(str, "0")) v = 0; SFE_WRITE_INT(sc_enc, v, 1, "value", "bolean"); } @@ -1157,49 +1168,86 @@ void SFE_PutBoolean(ScriptEnc *sc_enc, char *str) GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[bifs] Script encoding: Token %s read, %s expected\n", tok_names[curTok], tok_names[x])); \ sc_enc->err = GF_BAD_PARAM; \ } \ - + u32 TOK_To_ET(u32 tok) { switch(tok) { - case TOK_INCREMENT: return ET_INCREMENT; - case TOK_DECREMENT: return ET_DECREMENT; - case TOK_NOT: return ET_NOT; - case TOK_ONESCOMP: return ET_ONESCOMP; - case TOK_MULTIPLY : return ET_MULTIPLY; - case TOK_DIVIDE : return ET_DIVIDE; - case TOK_MOD : return ET_MOD; - case TOK_PLUS : return ET_PLUS; - case TOK_MINUS : return ET_MINUS; - case TOK_LSHIFT : return ET_LSHIFT; - case TOK_RSHIFT : return ET_RSHIFT; - case TOK_RSHIFTFILL : return ET_RSHIFTFILL; - case TOK_LT : return ET_LT; - case TOK_LE : return ET_LE; - case TOK_GT : return ET_GT; - case TOK_GE : return ET_GE; - case TOK_EQ : return ET_EQ; - case TOK_NE : return ET_NE; - case TOK_AND : return ET_AND; - case TOK_XOR : return ET_XOR; - case TOK_OR : return ET_OR; - case TOK_LAND : return ET_LAND; - case TOK_LOR : return ET_LOR; - case TOK_CONDTEST : return ET_CONDTEST; - case TOK_ASSIGN : return ET_ASSIGN; - case TOK_PLUSEQ : return ET_PLUSEQ; - case TOK_MINUSEQ : return ET_MINUSEQ; - case TOK_MULTIPLYEQ : return ET_MULTIPLYEQ; - case TOK_DIVIDEEQ : return ET_DIVIDEEQ; - case TOK_MODEQ : return ET_MODEQ; - case TOK_LSHIFTEQ : return ET_LSHIFTEQ; - case TOK_RSHIFTEQ : return ET_RSHIFTEQ; - case TOK_RSHIFTFILLEQ : return ET_RSHIFTFILLEQ; - case TOK_ANDEQ : return ET_ANDEQ; - case TOK_XOREQ : return ET_XOREQ; - case TOK_OREQ : return ET_OREQ; - case TOK_FUNCTION: return ET_FUNCTION_CALL; - case TOK_VAR: + case TOK_INCREMENT: + return ET_INCREMENT; + case TOK_DECREMENT: + return ET_DECREMENT; + case TOK_NOT: + return ET_NOT; + case TOK_ONESCOMP: + return ET_ONESCOMP; + case TOK_MULTIPLY : + return ET_MULTIPLY; + case TOK_DIVIDE : + return ET_DIVIDE; + case TOK_MOD : + return ET_MOD; + case TOK_PLUS : + return ET_PLUS; + case TOK_MINUS : + return ET_MINUS; + case TOK_LSHIFT : + return ET_LSHIFT; + case TOK_RSHIFT : + return ET_RSHIFT; + case TOK_RSHIFTFILL : + return ET_RSHIFTFILL; + case TOK_LT : + return ET_LT; + case TOK_LE : + return ET_LE; + case TOK_GT : + return ET_GT; + case TOK_GE : + return ET_GE; + case TOK_EQ : + return ET_EQ; + case TOK_NE : + return ET_NE; + case TOK_AND : + return ET_AND; + case TOK_XOR : + return ET_XOR; + case TOK_OR : + return ET_OR; + case TOK_LAND : + return ET_LAND; + case TOK_LOR : + return ET_LOR; + case TOK_CONDTEST : + return ET_CONDTEST; + case TOK_ASSIGN : + return ET_ASSIGN; + case TOK_PLUSEQ : + return ET_PLUSEQ; + case TOK_MINUSEQ : + return ET_MINUSEQ; + case TOK_MULTIPLYEQ : + return ET_MULTIPLYEQ; + case TOK_DIVIDEEQ : + return ET_DIVIDEEQ; + case TOK_MODEQ : + return ET_MODEQ; + case TOK_LSHIFTEQ : + return ET_LSHIFTEQ; + case TOK_RSHIFTEQ : + return ET_RSHIFTEQ; + case TOK_RSHIFTFILLEQ : + return ET_RSHIFTFILLEQ; + case TOK_ANDEQ : + return ET_ANDEQ; + case TOK_XOREQ : + return ET_XOREQ; + case TOK_OREQ : + return ET_OREQ; + case TOK_FUNCTION: + return ET_FUNCTION_CALL; + case TOK_VAR: return ET_VAR; default: assert(0); @@ -1207,58 +1255,58 @@ u32 TOK_To_ET(u32 tok) } } -static const char *expr_name[] ={ -"ET_CURVED_EXPR", -"ET_NEGATIVE", -"ET_NOT", -"ET_ONESCOMP", -"ET_INCREMENT", -"ET_DECREMENT", -"ET_POST_INCREMENT", -"ET_POST_DECREMENT", -"ET_CONDTEST", -"ET_STRING", -"ET_NUMBER", -"ET_IDENTIFIER", -"ET_FUNCTION_CALL", -"ET_NEW", -"ET_OBJECT_MEMBER_ACCESS", -"ET_OBJECT_METHOD_CALL", -"ET_ARRAY_DEREFERENCE", -"ET_ASSIGN", -"ET_PLUSEQ", -"ET_MINUSEQ", -"ET_MULTIPLYEQ", -"ET_DIVIDEEQ", -"ET_MODEQ", -"ET_ANDEQ", -"ET_OREQ", -"ET_XOREQ", -"ET_LSHIFTEQ", -"ET_RSHIFTEQ", -"ET_RSHIFTFILLEQ", -"ET_EQ", -"ET_NE", -"ET_LT", -"ET_LE", -"ET_GT", -"ET_GE", -"ET_PLUS", -"ET_MINUS", -"ET_MULTIPLY", -"ET_DIVIDE", -"ET_MOD", -"ET_LAND", -"ET_LOR", -"ET_AND", -"ET_OR", -"ET_XOR", -"ET_LSHIFT", -"ET_RSHIFT", -"ET_RSHIFTFILL", -"ET_BOOLEAN", -"ET_VAR", -"NUMBER_OF_EXPR_TYPE" +static const char *expr_name[] = { + "ET_CURVED_EXPR", + "ET_NEGATIVE", + "ET_NOT", + "ET_ONESCOMP", + "ET_INCREMENT", + "ET_DECREMENT", + "ET_POST_INCREMENT", + "ET_POST_DECREMENT", + "ET_CONDTEST", + "ET_STRING", + "ET_NUMBER", + "ET_IDENTIFIER", + "ET_FUNCTION_CALL", + "ET_NEW", + "ET_OBJECT_MEMBER_ACCESS", + "ET_OBJECT_METHOD_CALL", + "ET_ARRAY_DEREFERENCE", + "ET_ASSIGN", + "ET_PLUSEQ", + "ET_MINUSEQ", + "ET_MULTIPLYEQ", + "ET_DIVIDEEQ", + "ET_MODEQ", + "ET_ANDEQ", + "ET_OREQ", + "ET_XOREQ", + "ET_LSHIFTEQ", + "ET_RSHIFTEQ", + "ET_RSHIFTFILLEQ", + "ET_EQ", + "ET_NE", + "ET_LT", + "ET_LE", + "ET_GT", + "ET_GE", + "ET_PLUS", + "ET_MINUS", + "ET_MULTIPLY", + "ET_DIVIDE", + "ET_MOD", + "ET_LAND", + "ET_LOR", + "ET_AND", + "ET_OR", + "ET_XOR", + "ET_LSHIFT", + "ET_RSHIFT", + "ET_RSHIFTFILL", + "ET_BOOLEAN", + "ET_VAR", + "NUMBER_OF_EXPR_TYPE" }; #define NUMBER_OF_RANK 15 @@ -1315,23 +1363,23 @@ static s32 ET_Rank[NUMBER_OF_EXPR_TYPE] = 0, // ET_BOOLEAN 14 // ET_VAR -/* - 0, 0, 0, // variable, number, string - 1, 1, 1, 1, 1, // curved expr, call, member, array - 2, 2, 2, 2, 2, 2, 2, 2, // unary operator - 3, 3, 3, // multiply, divide, mod - 4, 4, // add, subtract - 5, 5, 5, // bitwise shift - 6, 6, 6, 6, // relational - 7, 7, // equality - 8, // bitwise and - 9, // bitwise xor - 10, // bitwise or - 11, // logical and - 12, // logical or - 13, // conditional - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 // assignment - */ + /* + 0, 0, 0, // variable, number, string + 1, 1, 1, 1, 1, // curved expr, call, member, array + 2, 2, 2, 2, 2, 2, 2, 2, // unary operator + 3, 3, 3, // multiply, divide, mod + 4, 4, // add, subtract + 5, 5, 5, // bitwise shift + 6, 6, 6, 6, // relational + 7, 7, // equality + 8, // bitwise and + 9, // bitwise xor + 10, // bitwise or + 11, // logical and + 12, // logical or + 13, // conditional + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 // assignment + */ }; static s32 ET_leftAssoc[NUMBER_OF_RANK] = {1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; @@ -1339,7 +1387,7 @@ u32 MoveToToken(ScriptEnc *sc_enc, u32 endTok, u32 cur, u32 end) { u32 cnt = 0; u32 startTok = TOK_EOF, curTok; - + if (endTok == TOK_RIGHT_CURVE) startTok = TOK_LEFT_CURVE; else if (endTok == TOK_RIGHT_BRACKET) startTok = TOK_LEFT_BRACKET; else if (endTok == TOK_RIGHT_BRACE) startTok = TOK_LEFT_BRACE; @@ -1388,9 +1436,9 @@ u32 SFE_Expression(ScriptEnc *sc_enc, u32 start, u32 end, Bool memberAccess) case TOK_NUMBER: curExpr = ET_NUMBER; break; - case TOK_BOOLEAN: - curExpr = ET_BOOLEAN; - break; + case TOK_BOOLEAN: + curExpr = ET_BOOLEAN; + break; case TOK_STRING: curExpr = ET_STRING; break; @@ -1430,10 +1478,10 @@ u32 SFE_Expression(ScriptEnc *sc_enc, u32 start, u32 end, Bool memberAccess) break; case TOK_PLUS: if ( - prevTok==TOK_RIGHT_CURVE || prevTok==TOK_RIGHT_BRACKET || - prevTok==TOK_IDENTIFIER || prevTok==TOK_NUMBER || - prevTok==TOK_STRING || prevTok==TOK_INCREMENT || - prevTok==TOK_DECREMENT + prevTok==TOK_RIGHT_CURVE || prevTok==TOK_RIGHT_BRACKET || + prevTok==TOK_IDENTIFIER || prevTok==TOK_NUMBER || + prevTok==TOK_STRING || prevTok==TOK_INCREMENT || + prevTok==TOK_DECREMENT ) { curExpr = ET_PLUS; } else { @@ -1442,10 +1490,10 @@ u32 SFE_Expression(ScriptEnc *sc_enc, u32 start, u32 end, Bool memberAccess) break; case TOK_MINUS: if ( - prevTok==TOK_RIGHT_CURVE || prevTok==TOK_RIGHT_BRACKET || - prevTok==TOK_IDENTIFIER || prevTok==TOK_NUMBER || - prevTok==TOK_STRING || prevTok==TOK_INCREMENT || - prevTok==TOK_DECREMENT + prevTok==TOK_RIGHT_CURVE || prevTok==TOK_RIGHT_BRACKET || + prevTok==TOK_IDENTIFIER || prevTok==TOK_NUMBER || + prevTok==TOK_STRING || prevTok==TOK_INCREMENT || + prevTok==TOK_DECREMENT ) { curExpr = ET_MINUS; } else { @@ -1478,8 +1526,8 @@ u32 SFE_Expression(ScriptEnc *sc_enc, u32 start, u32 end, Bool memberAccess) break; default: - if (curTok && (curTok != TOK_VAR) - && (curTok < TOK_MULTIPLY || curTok > TOK_OREQ)) { + if (curTok && (curTok != TOK_VAR) + && (curTok < TOK_MULTIPLY || curTok > TOK_OREQ)) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[bifs] Script encoding: illegal token %s read\n", tok_names[curTok])); sc_enc->err = GF_BAD_PARAM; return 0; @@ -1523,7 +1571,7 @@ skip_token: return expr; } } - + SFE_WRITE_INT(sc_enc, expr, NUMBITS_EXPR_TYPE, "expressionType", (char *) expr_name[expr]); switch (expr) { @@ -1570,7 +1618,7 @@ skip_token: } SFE_Expression(sc_enc, finalPos+1, end, 0); } - break; + break; case ET_IDENTIFIER: str = (char *)gf_list_get(sc_enc->id_buf, 0); @@ -1588,13 +1636,13 @@ skip_token: SFE_PutNumber(sc_enc, str); gf_free(str); break; - case ET_BOOLEAN: + case ET_BOOLEAN: str = (char *)gf_list_get(sc_enc->id_buf, 0); gf_list_rem(sc_enc->id_buf, 0); SFE_PutBoolean(sc_enc, str); gf_free(str); break; - case ET_VAR: + case ET_VAR: while (1) { str = (char *)gf_list_get(sc_enc->id_buf, 0); if (!str) break; @@ -1690,7 +1738,7 @@ void SFE_ObjectMemberAccess(ScriptEnc *sc_enc, u32 start, u32 op, u32 end) CHECK_TOK(TOK_IDENTIFIER); str = (char *)gf_list_get(sc_enc->id_buf, 0); gf_list_rem(sc_enc->id_buf, 0); - SFE_PutIdentifier(sc_enc, str); + SFE_PutIdentifier(sc_enc, str); gf_free(str); } @@ -1706,7 +1754,7 @@ void SFE_ObjectMethodCall(ScriptEnc *sc_enc, u32 start, u32 op, u32 end) CHECK_TOK(TOK_IDENTIFIER); str = (char *)gf_list_get(sc_enc->id_buf, 0); gf_list_rem(sc_enc->id_buf, 0); - SFE_PutIdentifier(sc_enc, str); + SFE_PutIdentifier(sc_enc, str); gf_free(str); curTok = sc_enc->expr_toks[op+2]; CHECK_TOK(TOK_LEFT_CURVE); @@ -1768,10 +1816,10 @@ void SFE_Params(ScriptEnc *sc_enc, u32 start, u32 end) curTok = sc_enc->expr_toks[start]; if (curTok != TOK_RIGHT_CURVE) { - SFE_WRITE_INT(sc_enc, 1, 1, "hasParam", NULL); + SFE_WRITE_INT(sc_enc, 1, 1, "hasParam", NULL); SFE_CompoundExpression(sc_enc, start, end, 1); } else { - SFE_WRITE_INT(sc_enc, 0, 1, "hasParam", NULL); + SFE_WRITE_INT(sc_enc, 0, 1, "hasParam", NULL); } } diff --git a/src/bifs/unquantize.c b/src/bifs/unquantize.c index ec33773..ce8b628 100644 --- a/src/bifs/unquantize.c +++ b/src/bifs/unquantize.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -282,8 +282,8 @@ GF_Err Q_DecInt(GF_BifsDecoder *codec, GF_BitStream *bs, u32 QType, SFInt32 b_mi //in the UnitSphere (R=1.0) GF_Err Q_DecCoordOnUnitSphere(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBits, u32 NbComp, Fixed *m_ft) { - u32 i, orient, sign; - s32 value; + u32 i, orient, sign; + s32 value; Fixed tang[4], delta; s32 dir; diff --git a/src/compositor/audio_input.c b/src/compositor/audio_input.c index ae170fc..7e2ae29 100644 --- a/src/compositor/audio_input.c +++ b/src/compositor/audio_input.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,7 +58,7 @@ static char *gf_audio_input_fetch_frame(void *callback, u32 *size, u32 audio_del GF_AudioInput *ai = (GF_AudioInput *) callback; /*even if the stream is signaled as finished we must check it, because it may have been restarted by a mediaControl*/ if (!ai->stream) return NULL; - + frame = gf_mo_fetch_data(ai->stream, 0, &ai->stream_finished, &ts, size, NULL, NULL); /*invalidate scene on end of stream to refresh audio graph*/ if (ai->stream_finished) gf_sc_invalidate(ai->compositor, NULL); @@ -82,7 +82,7 @@ static char *gf_audio_input_fetch_frame(void *callback, u32 *size, u32 audio_del drift = (s32)obj_time; drift -= (s32)ts; } - + #ifdef ENABLE_EARLY_FRAME_DETECTION /*too early (silence insertions), skip*/ if (drift < 0) { @@ -138,7 +138,7 @@ static Bool gf_audio_input_is_muted(void *callback) { GF_AudioInput *ai = (GF_AudioInput *) callback; if (!ai->stream) return 1; - if (ai->is_muted) + if (ai->is_muted) return 1; return gf_mo_is_muted(ai->stream); } @@ -149,7 +149,7 @@ static Bool gf_audio_input_get_config(GF_AudioInterface *aifc, Bool for_recf) if (!ai->stream) return 0; /*watchout for object reuse*/ if (aifc->samplerate && (gf_mo_get_flags(ai->stream) & GF_MO_IS_INIT)) return 1; - if (!for_recf) + if (!for_recf) return 0; gf_mo_get_audio_info(ai->stream, &aifc->samplerate, &aifc->bps , &aifc->chan, &aifc->ch_cfg); @@ -211,11 +211,11 @@ GF_Err gf_sc_audio_open(GF_AudioInput *ai, MFURL *url, Double clipBegin, Double if (ai->filter) gf_af_del(ai->filter); ai->filter = NULL; - + for (i=0; icount; i++) { if (url->vals[i].url && !strnicmp(url->vals[i].url, "#filter=", 8)) { ai->filter = gf_af_new(ai->compositor, &ai->input_ifce, url->vals[i].url+8); - if (ai->filter) + if (ai->filter) break; } } @@ -226,7 +226,7 @@ GF_EXPORT void gf_sc_audio_stop(GF_AudioInput *ai) { if (!ai->is_open) return; - + /*we must make sure audio mixer is not using the stream otherwise we may leave it dirty (with unrelease frame)*/ gf_mixer_lock(ai->compositor->audio_renderer->mixer, 1); @@ -269,12 +269,12 @@ void gf_sc_audio_register(GF_AudioInput *ai, GF_TraverseState *tr_state) /*check interface is valid*/ if (!ai->input_ifce.FetchFrame - || !ai->input_ifce.GetChannelVolume - || !ai->input_ifce.GetConfig - || !ai->input_ifce.GetSpeed - || !ai->input_ifce.IsMuted - || !ai->input_ifce.ReleaseFrame - ) return; + || !ai->input_ifce.GetChannelVolume + || !ai->input_ifce.GetConfig + || !ai->input_ifce.GetSpeed + || !ai->input_ifce.IsMuted + || !ai->input_ifce.ReleaseFrame + ) return; aifce = &ai->input_ifce; if (ai->filter) aifce = &ai->filter->input; @@ -290,7 +290,7 @@ void gf_sc_audio_register(GF_AudioInput *ai, GF_TraverseState *tr_state) ai->register_with_parent = 1; ai->snd = tr_state->sound_holder; } else if (!ai->register_with_renderer) { - + if (ai->register_with_parent) { ai->register_with_parent = 0; /*if used in a parent audio group, do a complete traverse to rebuild the group*/ @@ -331,7 +331,7 @@ static char *gf_af_fetch_frame(void *callback, u32 *size, u32 audio_delay_ms) u32 nb_bytes; char *data = af->src->FetchFrame(af->src->callback, &nb_bytes, audio_delay_ms + af->filter_chain.delay_ms); /*no input data*/ - if (!data || !nb_bytes) + if (!data || !nb_bytes) return NULL; if (nb_bytes > af->filter_chain.min_block_size) nb_bytes = af->filter_chain.min_block_size; @@ -376,7 +376,7 @@ static Bool gf_af_is_muted(void *callback) static Bool gf_af_get_config(GF_AudioInterface *ai, Bool for_reconf) { GF_AudioFilterItem *af = (GF_AudioFilterItem *)ai->callback; - + Bool res = af->src->GetConfig(af->src, for_reconf); if (!res) return 0; if (!for_reconf) return 1; diff --git a/src/compositor/audio_mixer.c b/src/compositor/audio_mixer.c index 9f6a416..18b29b8 100644 --- a/src/compositor/audio_mixer.c +++ b/src/compositor/audio_mixer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ Notes about the mixer: 1- spatialization is out of scope for the mixer (eg that's the sound node responsability) 2- mixing is performed by resampling input source & deinterleaving its channels into dedicated buffer. - We could directly deinterleave in the main mixer ouput buffer, but this would prevent any future + We could directly deinterleave in the main mixer ouput buffer, but this would prevent any future gain correction. */ typedef struct @@ -44,7 +44,7 @@ typedef struct u32 buffer_size; u32 bytes_per_sec; - + Bool has_prev; s32 last_channels[GF_SR_MAX_CHANNELS]; @@ -97,7 +97,7 @@ GF_AudioMixer *gf_mixer_new(struct _audio_render *ar) return am; } -Bool gf_mixer_must_reconfig(GF_AudioMixer *am) +Bool gf_mixer_must_reconfig(GF_AudioMixer *am) { return am->must_reconfig; } @@ -123,7 +123,7 @@ void gf_mixer_remove_all(GF_AudioMixer *am) gf_free(in); } am->isEmpty = 1, - gf_mixer_lock(am, 0); + gf_mixer_lock(am, 0); } Bool gf_mixer_is_src_present(GF_AudioMixer *am, GF_AudioInterface *ifce) @@ -223,8 +223,8 @@ void gf_mixer_get_config(GF_AudioMixer *am, u32 *outSR, u32 *outCH, u32 *outBPS, GF_EXPORT void gf_mixer_set_config(GF_AudioMixer *am, u32 outSR, u32 outCH, u32 outBPS, u32 outChCfg) { - if ((am->bits_per_sample == outBPS) && (am->nb_channels == outCH) - && (am->sample_rate==outSR) && (am->channel_cfg == outChCfg)) return; + if ((am->bits_per_sample == outBPS) && (am->nb_channels == outCH) + && (am->sample_rate==outSR) && (am->channel_cfg == outChCfg)) return; gf_mixer_lock(am, 1); am->bits_per_sample = outBPS; @@ -306,7 +306,7 @@ Bool gf_mixer_reconfig(GF_AudioMixer *am) memset(&in->last_channels, 0, sizeof(s16)*GF_SR_MAX_CHANNELS); } } - + if (cfg_changed || (max_sample_rate && (max_sample_rate != am->sample_rate)) ) { if (max_channels>2) { if (ch_cfg != am->channel_cfg) { @@ -328,7 +328,7 @@ Bool gf_mixer_reconfig(GF_AudioMixer *am) } gf_mixer_set_config(am, max_sample_rate, max_channels, max_bps, ch_cfg); } - + if (numInit == count) am->must_reconfig = 0; gf_mixer_lock(am, 0); @@ -474,7 +474,7 @@ static void gf_mixer_fetch_input(GF_AudioMixer *am, MixerInput *in, u32 audio_de in_s8 = NULL; } - /*just in case, if only 1 sample available in src, copy over and discard frame since we cannot + /*just in case, if only 1 sample available in src, copy over and discard frame since we cannot interpolate audio*/ if (src_samp==1) { in->has_prev = 1; @@ -494,14 +494,14 @@ static void gf_mixer_fetch_input(GF_AudioMixer *am, MixerInput *in, u32 audio_de next = prev+1; frac = (i*ratio) - 255*prev; if (frac && (next==src_samp)) break; - if (use_prev && prev) + if (use_prev && prev) use_prev = 0; if (in_s16) { for (j=0; jlast_channels[j] : in_s16[in_ch*prev + j]; inChanNext[j] = in_s16[in_ch*next + j]; - inChan[j] = (frac*inChanNext[j] + (255-frac)*inChan[j]) / 255; + inChan[j] = (frac*inChanNext[j] + (255-frac)*inChan[j]) / 255; } } else { for (j=0; jmuted = single_source->src->IsMuted(single_source->src->callback); /*this happens if input SR cannot be mapped to output audio hardware*/ if (single_source->src->samplerate != am->sample_rate) goto do_mix; - /*note we don't check output cfg: if the number of channel is the same then the channel cfg is the + /*note we don't check output cfg: if the number of channel is the same then the channel cfg is the same*/ if (single_source->src->chan != am->nb_channels) goto do_mix; if (single_source->src->GetSpeed(single_source->src->callback)!=FIX_ONE) goto do_mix; @@ -654,16 +654,16 @@ do_mix: in->muted = in->src->IsMuted(in->src->callback); if (in->muted) continue; - if (in->buffer_size < nb_samples) { + if (in->buffer_size < nb_samples) { for (j=0; jch_buf[j]) gf_free(in->ch_buf[j]); + if (in->ch_buf[j]) gf_free(in->ch_buf[j]); in->ch_buf[j] = (s32 *) gf_malloc(sizeof(s32) * nb_samples); } - in->buffer_size = nb_samples; + in->buffer_size = nb_samples; } in->speed = in->src->GetSpeed(in->src->callback); if (in->speed<0) in->speed *= -1; - + in->out_samples_written = 0; in->in_bytes_used = 0; @@ -677,11 +677,11 @@ do_mix: } in->muted = 1; continue; - } + } //otherwise fallthrou, mixer keeps the same config force_mix = GF_TRUE; - } - + } + if (in->speed==0) { in->out_samples_to_write = 0; } else { @@ -692,9 +692,9 @@ do_mix: } else { if (!force_mix && !in->src->GetChannelVolume(in->src->callback, in->pan)) { /*track first active source with same cfg as mixer*/ - if (!single_source && (in->src->samplerate == am->sample_rate) - && (in->src->chan == am->nb_channels) && (in->speed == FIX_ONE) - ) + if (!single_source && (in->src->samplerate == am->sample_rate) + && (in->src->chan == am->nb_channels) && (in->speed == FIX_ONE) + ) single_source = in; } } @@ -791,7 +791,7 @@ do_mix: } nb_written *= am->nb_channels*am->bits_per_sample/8; - if (buffer_size > nb_written) + if (buffer_size > nb_written) memset((char *)buffer + nb_written, 0, sizeof(char)*(buffer_size-nb_written)); gf_mixer_lock(am, 0); diff --git a/src/compositor/audio_render.c b/src/compositor/audio_render.c index 5e0c94a..1b19202 100644 --- a/src/compositor/audio_render.c +++ b/src/compositor/audio_render.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,24 +11,24 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include GF_Err gf_afc_load(GF_AudioFilterChain *afc, GF_User *user, char *filterstring) -{ +{ struct _audiofilterentry *prev_filter = NULL; - + while (filterstring) { u32 i, count; GF_AudioFilter *filter; @@ -41,13 +41,13 @@ GF_Err gf_afc_load(GF_AudioFilterChain *afc, GF_User *user, char *filterstring) filter = (GF_AudioFilter *)gf_modules_load_interface(user->modules, i, GF_AUDIO_FILTER_INTERFACE); if (filter) { if (filter->SetFilter - && filter->Configure - && filter->Process - && filter->Reset - && filter->SetOption - && filter->GetOption - && filter->SetFilter(filter, filterstring) - ) + && filter->Configure + && filter->Process + && filter->Reset + && filter->SetOption + && filter->GetOption + && filter->SetFilter(filter, filterstring) + ) break; gf_modules_close_interface((GF_BaseInterface *)filter); @@ -101,7 +101,7 @@ GF_Err gf_afc_setup(GF_AudioFilterChain *afc, u32 bps, u32 sr, u32 chan, u32 ch_ if (entry->filter->Configure(entry->filter, sr, bps, chan, ch_cfg, &och, &ocfg, &block_len, &entry->delay_ms, &entry->in_place)==GF_OK) { u32 out_block_size; entry->in_block_size = chan * bps * block_len / 8; - if (!afc->min_block_size || (afc->min_block_size > entry->in_block_size)) + if (!afc->min_block_size || (afc->min_block_size > entry->in_block_size)) afc->min_block_size = entry->in_block_size; out_block_size = och * bps * block_len / 8; @@ -168,7 +168,7 @@ u32 gf_afc_process(GF_AudioFilterChain *afc, u32 nb_bytes) /*copy bytes in input*/ memcpy(entry->in_block + entry->nb_bytes, inptr, nb_bytes); entry->nb_bytes += nb_bytes; - + /*and process*/ while (entry->nb_bytes >= entry->in_block_size) { u32 done; @@ -179,7 +179,7 @@ u32 gf_afc_process(GF_AudioFilterChain *afc, u32 nb_bytes) processed += entry->in_block_size; } /*move remaining data at the begining of the buffer*/ - if (processed && entry->nb_bytes) + if (processed && entry->nb_bytes) memmove(entry->in_block, entry->in_block+processed, entry->nb_bytes); nb_bytes = nb_bytes_out; @@ -246,7 +246,7 @@ static GF_Err gf_ar_setup_output_format(GF_AudioRenderer *ar) nb_chan = och; /*try to reconfigure audio output*/ - if (!e) + if (!e) e = ar->audio_out->ConfigureOutput(ar->audio_out, &osr, &och, &obps, ocfg); /*output module cannot support filter output, disable it ...*/ @@ -271,7 +271,7 @@ static GF_Err gf_ar_setup_output_format(GF_AudioRenderer *ar) } if (e) return e; } - gf_mixer_set_config(ar->mixer, in_freq, in_ch, in_bps, in_cfg); + gf_mixer_set_config(ar->mixer, freq, nb_chan, nb_bits, in_cfg); ar->audio_delay = ar->audio_out->GetAudioDelay(ar->audio_out); ar->audio_out->SetVolume(ar->audio_out, ar->volume); @@ -283,7 +283,7 @@ static GF_Err gf_ar_setup_output_format(GF_AudioRenderer *ar) while ((l = gf_list_enum(ar->audio_listeners, &k))) { l->on_audio_reconfig(l->udta, in_freq, in_bps, in_ch, in_cfg); } - } + } return GF_OK; } @@ -308,7 +308,7 @@ static u32 gf_ar_fill_output(void *ptr, char *buffer, u32 buffer_size) /*fill input block*/ nb_bytes = gf_mixer_get_output(ar->mixer, ar->filter_chain.tmp_block1, ar->filter_chain.min_block_size, delay_ms); - if (!nb_bytes) + if (!nb_bytes) return written; /*delay used to check for late frames - we only use it on the first call to gf_mixer_get_output()*/ @@ -357,9 +357,9 @@ u32 gf_ar_proc(void *p) while (ar->audio_th_state == 1) { //GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Audio simulation step\n")); - - /*THIS IS NEEDED FOR SYMBIAN - if no yield here, the audio module always grabs the - main mixer mutex and it takes forever before it can be grabed by another thread, + + /*THIS IS NEEDED FOR SYMBIAN - if no yield here, the audio module always grabs the + main mixer mutex and it takes forever before it can be grabed by another thread, for instance when reconfiguring scene*/ // gf_sleep(1); @@ -403,7 +403,7 @@ GF_AudioRenderer *gf_sc_ar_load(GF_User *user) ar->disable_resync = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0; sOpt = gf_cfg_get_key(user->config, "Audio", "DisableMultiChannel"); ar->disable_multichannel = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0; - + ar->mixer = gf_mixer_new(ar); ar->user = user; @@ -458,7 +458,7 @@ GF_AudioRenderer *gf_sc_ar_load(GF_User *user) ar->audio_out->audio_renderer = ar; GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Setting up audio module %s\n", ar->audio_out->module_name)); e = ar->audio_out->Setup(ar->audio_out, ar->user->os_window_handler, num_buffers, total_duration); - + /*load main audio filter*/ gf_afc_load(&ar->filter_chain, user, (char*)gf_cfg_get_key(user->config, "Audio", "Filter")); @@ -553,7 +553,7 @@ void gf_sc_ar_control(GF_AudioRenderer *ar, u32 PauseType) } void gf_sc_ar_set_volume(GF_AudioRenderer *ar, u32 Volume) -{ +{ char sOpt[10]; gf_mixer_lock(ar->mixer, 1); ar->volume = MIN(Volume, 100); @@ -565,7 +565,7 @@ void gf_sc_ar_set_volume(GF_AudioRenderer *ar, u32 Volume) } void gf_sc_ar_mute(GF_AudioRenderer *ar, Bool mute) -{ +{ gf_mixer_lock(ar->mixer, 1); ar->mute = mute; if (ar->audio_out) ar->audio_out->SetVolume(ar->audio_out, mute ? 0 : ar->volume); @@ -592,7 +592,7 @@ void gf_sc_ar_add_src(GF_AudioRenderer *ar, GF_AudioInterface *source) recfg = gf_mixer_reconfig(ar->mixer); if (!ar->need_reconfig) ar->need_reconfig = recfg; - if (!gf_mixer_empty(ar->mixer) && ar->audio_out && ar->audio_out->Play) + if (!gf_mixer_empty(ar->mixer) && ar->audio_out && ar->audio_out->Play) ar->audio_out->Play(ar->audio_out, 1); /*unlock mixer*/ gf_mixer_lock(ar->mixer, 0); @@ -602,7 +602,7 @@ void gf_sc_ar_remove_src(GF_AudioRenderer *ar, GF_AudioInterface *source) { if (ar) { gf_mixer_remove_input(ar->mixer, source); - if (gf_mixer_empty(ar->mixer) && ar->audio_out && ar->audio_out->Play) + if (gf_mixer_empty(ar->mixer) && ar->audio_out && ar->audio_out->Play) ar->audio_out->Play(ar->audio_out, 0); } } @@ -624,10 +624,10 @@ void gf_sc_ar_reconfig(GF_AudioRenderer *ar) gf_mixer_lock(ar->mixer, 1); gf_ar_freeze_intern(ar, 1, 1, 0); - ar->need_reconfig = 0; + ar->need_reconfig = 0; gf_ar_setup_output_format(ar); gf_ar_freeze_intern(ar, 0, 1, 0); - + /*unlock mixer*/ gf_mixer_lock(ar->mixer, 0); } @@ -656,7 +656,7 @@ void gf_sc_reload_audio_filters(GF_Compositor *compositor) gf_afc_load(&ar->filter_chain, ar->user, (char*)gf_cfg_get_key(ar->user->config, "Audio", "Filter")); gf_ar_freeze_intern(ar, 1, 1, 0); - ar->need_reconfig = 0; + ar->need_reconfig = 0; gf_ar_setup_output_format(ar); gf_ar_freeze_intern(ar, 0, 1, 0); diff --git a/src/compositor/bindable.c b/src/compositor/bindable.c index e36d21f..7b84003 100644 --- a/src/compositor/bindable.c +++ b/src/compositor/bindable.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -33,28 +33,30 @@ GF_List *Bindable_GetStack(GF_Node *bindable) if (!bindable) return 0; st = gf_node_get_private(bindable); switch (gf_node_get_tag(bindable)) { - case TAG_MPEG4_Background2D: return ((Background2DStack*)st)->reg_stacks; + case TAG_MPEG4_Background2D: + return ((Background2DStack*)st)->reg_stacks; case TAG_MPEG4_Viewport: - case TAG_MPEG4_NavigationInfo: + case TAG_MPEG4_NavigationInfo: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NavigationInfo: + case TAG_X3D_NavigationInfo: #endif return ((ViewStack*)st)->reg_stacks; #ifndef GPAC_DISABLE_3D - case TAG_MPEG4_Background: + case TAG_MPEG4_Background: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Background: + case TAG_X3D_Background: #endif return ((BackgroundStack*)st)->reg_stacks; - case TAG_MPEG4_Viewpoint: - case TAG_MPEG4_Fog: + case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Fog: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: case TAG_X3D_Fog: #endif return ((ViewStack*)st)->reg_stacks; #endif - default: return NULL; + default: + return NULL; } } @@ -62,29 +64,32 @@ Bool Bindable_GetIsBound(GF_Node *bindable) { if (!bindable) return 0; switch (gf_node_get_tag(bindable)) { - case TAG_MPEG4_Background2D: return ((M_Background2D*)bindable)->isBound; - case TAG_MPEG4_Viewport: return ((M_Viewport*)bindable)->isBound; - case TAG_MPEG4_Background: + case TAG_MPEG4_Background2D: + return ((M_Background2D*)bindable)->isBound; + case TAG_MPEG4_Viewport: + return ((M_Viewport*)bindable)->isBound; + case TAG_MPEG4_Background: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Background: + case TAG_X3D_Background: #endif return ((M_Background*)bindable)->isBound; - case TAG_MPEG4_NavigationInfo: + case TAG_MPEG4_NavigationInfo: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NavigationInfo: + case TAG_X3D_NavigationInfo: #endif return ((M_NavigationInfo*)bindable)->isBound; - case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Viewpoint: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: #endif return ((M_Viewpoint*)bindable)->isBound; - case TAG_MPEG4_Fog: + case TAG_MPEG4_Fog: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Fog: + case TAG_X3D_Fog: #endif return ((M_Fog*)bindable)->isBound; - default: return 0; + default: + return 0; } } @@ -93,7 +98,7 @@ void Bindable_SetIsBound(GF_Node *bindable, Bool val) Bool has_bind_time = 0; if (!bindable) return; switch (gf_node_get_tag(bindable)) { - case TAG_MPEG4_Background2D: + case TAG_MPEG4_Background2D: if ( ((M_Background2D*)bindable)->isBound == val) return; ((M_Background2D*)bindable)->isBound = val; break; @@ -116,20 +121,20 @@ void Bindable_SetIsBound(GF_Node *bindable, Bool val) ((M_Background*)bindable)->isBound = val; break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NavigationInfo: + case TAG_X3D_NavigationInfo: if ( ((X_NavigationInfo*)bindable)->isBound == val) return; ((X_NavigationInfo*)bindable)->isBound = val; ((X_NavigationInfo*)bindable)->bindTime = gf_node_get_scene_time(bindable); has_bind_time = 1; break; #endif - case TAG_MPEG4_NavigationInfo: + case TAG_MPEG4_NavigationInfo: if ( ((M_NavigationInfo*)bindable)->isBound == val) return; ((M_NavigationInfo*)bindable)->isBound = val; break; - case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Viewpoint: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: #endif if ( ((M_Viewpoint*)bindable)->isBound == val) return; ((M_Viewpoint*)bindable)->isBound = val; @@ -137,18 +142,18 @@ void Bindable_SetIsBound(GF_Node *bindable, Bool val) has_bind_time = 1; break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Fog: + case TAG_X3D_Fog: if ( ((X_Fog*)bindable)->isBound == val) return; ((X_Fog*)bindable)->isBound = val; ((X_Fog*)bindable)->bindTime = gf_node_get_scene_time(bindable); has_bind_time = 1; break; #endif - case TAG_MPEG4_Fog: + case TAG_MPEG4_Fog: if ( ((M_Fog*)bindable)->isBound == val) return; ((M_Fog*)bindable)->isBound = val; break; - default: + default: return; } gf_node_event_out_str(bindable, "isBound"); @@ -162,29 +167,32 @@ Bool Bindable_GetSetBind(GF_Node *bindable) { if (!bindable) return 0; switch (gf_node_get_tag(bindable)) { - case TAG_MPEG4_Background2D: return ((M_Background2D*)bindable)->set_bind; - case TAG_MPEG4_Viewport: return ((M_Viewport*)bindable)->set_bind; - case TAG_MPEG4_Background: + case TAG_MPEG4_Background2D: + return ((M_Background2D*)bindable)->set_bind; + case TAG_MPEG4_Viewport: + return ((M_Viewport*)bindable)->set_bind; + case TAG_MPEG4_Background: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Background: + case TAG_X3D_Background: #endif return ((M_Background*)bindable)->set_bind; - case TAG_MPEG4_NavigationInfo: + case TAG_MPEG4_NavigationInfo: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NavigationInfo: + case TAG_X3D_NavigationInfo: #endif return ((M_NavigationInfo*)bindable)->set_bind; - case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Viewpoint: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: #endif return ((M_Viewpoint*)bindable)->set_bind; - case TAG_MPEG4_Fog: + case TAG_MPEG4_Fog: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Fog: + case TAG_X3D_Fog: #endif return ((M_Fog*)bindable)->set_bind; - default: return 0; + default: + return 0; } } @@ -192,43 +200,44 @@ void Bindable_SetSetBindEx(GF_Node *bindable, Bool val, GF_List *stack) { if (!bindable) return; switch (gf_node_get_tag(bindable)) { - case TAG_MPEG4_Background2D: + case TAG_MPEG4_Background2D: ((M_Background2D*)bindable)->set_bind = val; ((M_Background2D*)bindable)->on_set_bind(bindable, NULL); break; - case TAG_MPEG4_Viewport: + case TAG_MPEG4_Viewport: ((M_Viewport*)bindable)->set_bind = val; ((M_Viewport*)bindable)->on_set_bind(bindable, (GF_Route*)stack); break; - case TAG_MPEG4_Background: + case TAG_MPEG4_Background: #ifndef GPAC_DISABLE_X3D case TAG_X3D_Background: #endif ((M_Background*)bindable)->set_bind = val; ((M_Background*)bindable)->on_set_bind(bindable, NULL); break; - case TAG_MPEG4_NavigationInfo: + case TAG_MPEG4_NavigationInfo: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NavigationInfo: + case TAG_X3D_NavigationInfo: #endif ((M_NavigationInfo*)bindable)->set_bind = val; ((M_NavigationInfo*)bindable)->on_set_bind(bindable, NULL); break; - case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Viewpoint: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: #endif ((M_Viewpoint*)bindable)->set_bind = val; ((M_Viewpoint*)bindable)->on_set_bind(bindable, NULL); break; - case TAG_MPEG4_Fog: + case TAG_MPEG4_Fog: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Fog: + case TAG_X3D_Fog: #endif ((M_Fog*)bindable)->set_bind = val; ((M_Fog*)bindable)->on_set_bind(bindable, NULL); break; - default: return; + default: + return; } } void Bindable_SetSetBind(GF_Node *bindable, Bool val) diff --git a/src/compositor/camera.c b/src/compositor/camera.c index a9b01c0..489711e 100644 --- a/src/compositor/camera.c +++ b/src/compositor/camera.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -95,7 +95,9 @@ static void camera_frustum_from_matrix(GF_Camera *cam, GF_Matrix *mx) vy = FIX2FLT(cam->planes[i].normal.y); vz = FIX2FLT(cam->planes[i].normal.z); nor = (Float) sqrt(vx*vx + vy*vy + vz*vz); - vx /= nor; vy /= nor; vz /= nor; + vx /= nor; + vy /= nor; + vz /= nor; cam->planes[i].d = FLT2FIX (FIX2FLT(cam->planes[i].d) / nor); cam->planes[i].normal.x = FLT2FIX(vx); cam->planes[i].normal.y = FLT2FIX(vy); @@ -122,26 +124,40 @@ SFRotation camera_get_orientation(SFVec3f pos, SFVec3f target, SFVec3f up) tmp = gf_vec_scale(dir, gf_vec_dot(up, dir)); gf_vec_diff(v, up, tmp); gf_vec_norm(&v); - axis.x = dir.y; axis.y = -dir.x; axis.z = 0; + axis.x = dir.y; + axis.y = -dir.x; + axis.z = 0; if (gf_vec_dot(axis, axis) < FIX_EPSILON) { if (dir.z> 0) { - norm.x = 0; norm.y = FIX_ONE; norm.z = 0; norm.q = 0; + norm.x = 0; + norm.y = FIX_ONE; + norm.z = 0; + norm.q = 0; } else { - norm.x = 0; norm.y = 0; norm.z = 0; norm.q = FIX_ONE; + norm.x = 0; + norm.y = 0; + norm.z = 0; + norm.q = FIX_ONE; } } else { gf_vec_norm(&axis); norm = gf_quat_from_axis_cos(axis, -dir.z); } /* Find the inverse rotation. */ - inv_norm.x = -norm.x; inv_norm.y = -norm.y; inv_norm.z = -norm.z; inv_norm.q = norm.q; + inv_norm.x = -norm.x; + inv_norm.y = -norm.y; + inv_norm.z = -norm.z; + inv_norm.q = norm.q; /* Rotate the y. */ - y_quat.x = y_quat.z = y_quat.q = 0; y_quat.y = FIX_ONE; + y_quat.x = y_quat.z = y_quat.q = 0; + y_quat.y = FIX_ONE; ny_quat = gf_quat_multiply(&norm, &y_quat); ny_quat = gf_quat_multiply(&ny_quat, &inv_norm); - new_y.x = ny_quat.x; new_y.y = ny_quat.y; new_y.z = ny_quat.z; + new_y.x = ny_quat.x; + new_y.y = ny_quat.y; + new_y.z = ny_quat.z; tmp = gf_vec_cross(new_y, v); @@ -149,9 +165,13 @@ SFRotation camera_get_orientation(SFVec3f pos, SFVec3f target, SFVec3f up) /* The old and new may be pointing in the same or opposite. Need ** to generate a vector perpendicular to the old or new y. */ - tmp.x = 0; tmp.y = -v.z; tmp.z = v.y; + tmp.x = 0; + tmp.y = -v.z; + tmp.z = v.y; if (gf_vec_dot(tmp, tmp) < FIX_EPSILON) { - tmp.x = v.z; tmp.y = 0; tmp.z = -v.x; + tmp.x = v.z; + tmp.y = 0; + tmp.z = -v.x; } } gf_vec_norm(&tmp); @@ -174,11 +194,15 @@ void camera_set_2d(GF_Camera *cam) { cam->is_3D = 0; #ifdef FORCE_CAMERA_3D - cam->position.x = cam->position.y = 0; cam->position.z = INT2FIX(NEAR_PLANE_2D); - cam->up.x = cam->up.z = 0; cam->up.y = FIX_ONE; + cam->position.x = cam->position.y = 0; + cam->position.z = INT2FIX(NEAR_PLANE_2D); + cam->up.x = cam->up.z = 0; + cam->up.y = FIX_ONE; cam->target.x = cam->target.y = cam->target.z = 0; cam->vp_position = cam->position; - cam->vp_orientation.x = cam->vp_orientation.y = 0; cam->vp_orientation.q = 0; cam->vp_orientation.y = FIX_ONE; + cam->vp_orientation.x = cam->vp_orientation.y = 0; + cam->vp_orientation.q = 0; + cam->vp_orientation.y = FIX_ONE; cam->vp_fov = cam->fieldOfView = FLT2FIX(0.785398); cam->vp_dist = INT2FIX(NEAR_PLANE_2D); cam->end_zoom = FIX_ONE; @@ -255,8 +279,12 @@ void camera_update_stereo(GF_Camera *cam, GF_Matrix2D *user_transform, Bool cent vlen = cam->z_far - cam->z_near; h = gf_mulfix(vlen , gf_tan(cam->fieldOfView / 2)); w = gf_mulfix(h, ar); - center.x = 0; center.y = 0; center.z = cam->z_near + vlen / 2; - corner.x = w; corner.y = h; corner.z = vlen; + center.x = 0; + center.y = 0; + center.z = cam->z_near + vlen / 2; + corner.x = w; + corner.y = h; + corner.z = vlen; gf_vec_diff(corner, corner, center); cam->radius = gf_vec_len(corner); gf_vec_diff(cam->center, cam->target, cam->position); @@ -290,7 +318,7 @@ void camera_update_stereo(GF_Camera *cam, GF_Matrix2D *user_transform, Bool cent if (! (cam->flags & CAM_NO_LOOKAT)) { GF_Matrix mx; gf_mx_from_mx2d(&mx, user_transform); - mx.m[10] = mx.m[0]; + mx.m[10] = mx.m[0]; gf_mx_add_matrix(&post_model_view, &mx); } else #endif @@ -345,7 +373,7 @@ void camera_update_stereo(GF_Camera *cam, GF_Matrix2D *user_transform, Bool cent gf_vec_diff(center, cam->world_bbox.center, cam->position); vlen = gf_vec_len(center); vlen += gf_mulfix(view_distance_offset, gf_divfix(vlen, nominal_view_distance)); - + gf_vec_diff(eye, cam->target, cam->position); gf_vec_norm(&eye); tar = gf_vec_scale(eye, vlen); @@ -409,7 +437,7 @@ void camera_reset_viewpoint(GF_Camera *cam, Bool animate) return; } #ifndef FORCE_CAMERA_3D - if (cam->is_3D) + if (cam->is_3D) #endif { cam->start_pos = cam->position; @@ -507,12 +535,12 @@ Bool camera_animate(GF_Camera *cam) if (now > cam->anim_len) { cam->anim_len = 0; #ifndef FORCE_CAMERA_3D - if (cam->is_3D) + if (cam->is_3D) #endif { camera_set_vectors(cam, cam->end_pos, cam->end_ori, cam->end_fov); cam->end_zoom = FIX_ONE; - } + } #ifndef FORCE_CAMERA_3D else { cam->flags |= CAM_IS_DIRTY; @@ -543,7 +571,7 @@ Bool camera_animate(GF_Camera *cam) dif = gf_vec_scale(dif, frac); gf_vec_add(pos, cam->start_pos, dif); fov = gf_mulfix(cam->end_fov - cam->start_fov, frac) + cam->start_fov; - cam->end_zoom = frac + gf_mulfix((FIX_ONE-frac), cam->start_zoom); + cam->end_zoom = frac + gf_mulfix((FIX_ONE-frac), cam->start_zoom); camera_set_vectors(cam, pos, rot, fov); } return 1; diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 4445953..a0552a6 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,9 +64,9 @@ static void gf_sc_set_fullscreen(GF_Compositor *compositor) if (compositor->fullscreen && (compositor->scene_width>=compositor->scene_height) #ifndef GPAC_DISABLE_3D - && !compositor->visual->type_3d + && !compositor->visual->type_3d #endif - ) { + ) { e = compositor->video_out->SetFullScreen(compositor->video_out, 2, &compositor->display_width, &compositor->display_height); } else { e = compositor->video_out->SetFullScreen(compositor->video_out, compositor->fullscreen, &compositor->display_width, &compositor->display_height); @@ -92,9 +92,9 @@ static void gf_sc_set_fullscreen(GF_Compositor *compositor) /*this is needed for: -- audio: since the audio compositor may not be threaded, it must be reconfigured by another thread otherwise +- audio: since the audio compositor may not be threaded, it must be reconfigured by another thread otherwise we lock the audio module -- video: this is typical to OpenGL&co: multithreaded is forbidden, so resizing/fullscreen MUST be done by the same +- video: this is typical to OpenGL&co: multithreaded is forbidden, so resizing/fullscreen MUST be done by the same thread accessing the HW ressources */ static void gf_sc_reconfig_task(GF_Compositor *compositor) @@ -102,7 +102,7 @@ static void gf_sc_reconfig_task(GF_Compositor *compositor) GF_Event evt; Bool notif_size=GF_FALSE; u32 width,height; - + /*reconfig audio if needed (non-threaded compositors)*/ if (compositor->audio_renderer && !compositor->audio_renderer->th) gf_sc_ar_reconfig(compositor->audio_renderer); @@ -162,7 +162,7 @@ static void gf_sc_reconfig_task(GF_Compositor *compositor) gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); } notif_size=1; - + } /*aspect ratio modif*/ if (compositor->msg_type & GF_SR_CFG_AR) { @@ -172,7 +172,7 @@ static void gf_sc_reconfig_task(GF_Compositor *compositor) /*fullscreen on/off request*/ if (compositor->msg_type & GF_SR_CFG_FULLSCREEN) { compositor->msg_type &= ~GF_SR_CFG_FULLSCREEN; - //video is about to resetup, wait for the setup + //video is about to resetup, wait for the setup if (compositor->recompute_ar) { compositor->fullscreen_postponed = 1; } else { @@ -213,10 +213,10 @@ static void gf_sc_reconfig_task(GF_Compositor *compositor) GF_EXPORT Bool gf_sc_draw_frame(GF_Compositor *compositor, u32 *ms_till_next) -{ +{ gf_sc_simulation_tick(compositor); if (ms_till_next) { - if ((s32) compositor->next_frame_delay == -1) + if ((s32) compositor->next_frame_delay == -1) *ms_till_next = compositor->frame_duration; else *ms_till_next = MIN(compositor->next_frame_delay, compositor->frame_duration); @@ -230,7 +230,7 @@ Bool gf_sc_draw_frame(GF_Compositor *compositor, u32 *ms_till_next) /*forces graphics redraw*/ GF_EXPORT void gf_sc_reset_graphics(GF_Compositor *compositor) -{ +{ if (compositor) { Bool locked = gf_mx_try_lock(compositor->mx); compositor->reset_graphics = 1; @@ -274,7 +274,7 @@ static GF_Err gf_sc_load(GF_Compositor *compositor) compositor->focus_use_stack = gf_list_new(); compositor->env_tests = gf_list_new(); - + /*setup main visual*/ compositor->visual = visual_new(compositor); compositor->visual->GetSurfaceAccess = compositor_2d_get_video_access; @@ -284,7 +284,7 @@ static GF_Err gf_sc_load(GF_Compositor *compositor) compositor_2d_init_callbacks(compositor); - // default value for depth gain is not zero + // default value for depth gain is not zero #ifdef GF_SR_USE_DEPTH compositor->traverse_state->depth_gain = FIX_ONE; #endif @@ -300,7 +300,7 @@ static GF_Err gf_sc_load(GF_Compositor *compositor) gf_node_register(compositor->focus_highlight->node, NULL); gf_node_set_callback_function(compositor->focus_highlight->node, drawable_traverse_focus); - + #ifndef GPAC_DISABLE_3D /*default collision mode*/ compositor->collide_mode = GF_COLLISION_DISPLACEMENT; //GF_COLLISION_NORMAL @@ -309,6 +309,7 @@ static GF_Err gf_sc_load(GF_Compositor *compositor) /*create default unit sphere and box for bounds*/ compositor->unit_bbox = new_mesh(); mesh_new_unit_bbox(compositor->unit_bbox); + gf_mx_init(compositor->traverse_state->model_matrix); #endif compositor->was_system_memory=1; @@ -421,7 +422,7 @@ static GF_Err gf_sc_create(GF_Compositor *compositor) compositor->textures = gf_list_new(); compositor->textures_gc = gf_list_new(); - compositor->frame_rate = 30.0; + compositor->frame_rate = 30.0; compositor->frame_duration = 33; compositor->time_nodes = gf_list_new(); compositor->event_queue = gf_list_new(); @@ -432,14 +433,14 @@ static GF_Err gf_sc_create(GF_Compositor *compositor) compositor->cached_groups = gf_list_new(); compositor->cached_groups_queue = gf_list_new(); #endif - + /*load audio renderer*/ if (!compositor->audio_renderer) - compositor->audio_renderer = gf_sc_ar_load(compositor->user); + compositor->audio_renderer = gf_sc_ar_load(compositor->user); - gf_sc_reset_framerate(compositor); + gf_sc_reset_framerate(compositor); compositor->font_manager = gf_font_manager_new(compositor->user); - + compositor->extra_scenes = gf_list_new(); compositor->interaction_level = GF_INTERACT_NORMAL | GF_INTERACT_INPUT_SENSOR | GF_INTERACT_NAVIGATION; @@ -458,12 +459,12 @@ enum }; static u32 gf_sc_proc(void *par) -{ +{ GF_Err e; GF_Compositor *compositor = (GF_Compositor *) par; GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Compositor] Entering thread ID %d\n", gf_th_id() )); - + compositor->video_th_state = GF_COMPOSITOR_THREAD_START; e = gf_sc_create(compositor); if (e != GF_OK) { @@ -472,14 +473,14 @@ static u32 gf_sc_proc(void *par) return 1; } - compositor->video_th_state = GF_COMPOSITOR_THREAD_RUN; + compositor->video_th_state = GF_COMPOSITOR_THREAD_RUN; while (compositor->video_th_state == GF_COMPOSITOR_THREAD_RUN) { if (compositor->is_hidden==1) { if (!compositor->bench_mode) { compositor->scene_sampled_clock = gf_sc_ar_get_clock(compositor->audio_renderer); } gf_sleep(compositor->frame_duration); - } else + } else gf_sc_simulation_tick(compositor); } @@ -504,7 +505,7 @@ GF_Compositor *gf_sc_new(GF_User *user, Bool self_threaded, GF_Terminal *term) GF_Compositor *tmp; GF_SAFEALLOC(tmp, GF_Compositor); - if (!tmp){ + if (!tmp) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Failed to allocate compositor : OUT OF MEMORY!\n")); return NULL; } @@ -532,7 +533,7 @@ GF_Compositor *gf_sc_new(GF_User *user, Bool self_threaded, GF_Terminal *term) while (tmp->video_th_state < GF_COMPOSITOR_THREAD_RUN) { gf_sleep(1); } - /*init failure*/ + /*init failure*/ if (tmp->video_th_state == GF_COMPOSITOR_THREAD_INIT_FAILED) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("GF_COMPOSITOR_THREAD_INIT_FAILED : Deleting compositor.\n")); gf_sc_del(tmp); @@ -546,7 +547,7 @@ GF_Compositor *gf_sc_new(GF_User *user, Bool self_threaded, GF_Terminal *term) return NULL; } } - + if ((tmp->user->init_flags & GF_TERM_NO_REGULATION) || !tmp->VisualThread) tmp->no_regulation = GF_TRUE; @@ -665,7 +666,7 @@ void gf_sc_del(GF_Compositor *compositor) if (compositor->time_nodes) gf_list_del(compositor->time_nodes); if (compositor->extra_scenes) gf_list_del(compositor->extra_scenes); if (compositor->video_listeners) gf_list_del(compositor->video_listeners); - + gf_sc_lock(compositor, GF_FALSE); gf_mx_del(compositor->mx); gf_free(compositor); @@ -677,7 +678,7 @@ void gf_sc_set_fps(GF_Compositor *compositor, Double fps) if (fps) { compositor->frame_rate = fps; compositor->frame_duration = (u32) (1000 / fps); - gf_sc_reset_framerate(compositor); + gf_sc_reset_framerate(compositor); } } @@ -697,10 +698,20 @@ static void gf_sc_set_play_state(GF_Compositor *compositor, u32 PlayState) /*step mode*/ if (PlayState==GF_STATE_STEP_PAUSE) { compositor->step_mode = 1; - if (!compositor->paused) + if (!compositor->paused) gf_term_set_option(compositor->term, GF_OPT_PLAY_STATE, GF_STATE_PAUSED); - else - gf_term_step_clocks(compositor->term, compositor->frame_duration); + else { + u32 dur = compositor->frame_duration; + u32 i, count = gf_list_count(compositor->textures); + for (i=0; itextures, i); + if (txh->stream) { + u32 d = gf_mo_get_min_frame_dur(txh->stream); + if (d && dterm, dur); + } } else { compositor->step_mode = 0; if (compositor->audio_renderer) gf_sc_ar_control(compositor->audio_renderer, (compositor->paused && (PlayState==0xFF)) ? 2 : compositor->paused); @@ -793,7 +804,7 @@ void compositor_set_ar_scale(GF_Compositor *compositor, Fixed scaleX, Fixed scal static void gf_sc_reset(GF_Compositor *compositor, Bool has_scene) { Bool draw_mode; - + GF_VisualManager *visual; u32 i=0; while ((visual = (GF_VisualManager *)gf_list_enum(compositor->visuals, &i))) { @@ -889,7 +900,7 @@ GF_Err gf_sc_set_scene(GF_Compositor *compositor, GF_SceneGraph *scene_graph) gf_free(qev); } gf_mx_v(compositor->evq_mx); - + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor] Reseting compositor module\n")); /*reset main surface*/ gf_sc_reset(compositor, scene_graph ? 1 : 0); @@ -931,11 +942,11 @@ GF_Err gf_sc_set_scene(GF_Compositor *compositor, GF_SceneGraph *scene_graph) if ((tag>=GF_NODE_RANGE_FIRST_SVG) && (tag<=GF_NODE_RANGE_LAST_SVG)) { GF_FieldInfo info; is_svg = 1; - if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_width, 0, 0, &info)==GF_OK) + if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_width, 0, 0, &info)==GF_OK) w = info.far_ptr; - if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_height, 0, 0, &info)==GF_OK) + if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_height, 0, 0, &info)==GF_OK) h = info.far_ptr; - if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_viewBox, 0, 0, &info)==GF_OK) + if (gf_node_get_attribute_by_tag(top_node, TAG_SVG_ATT_viewBox, 0, 0, &info)==GF_OK) vb = info.far_ptr; } /*default back color is white*/ @@ -965,7 +976,7 @@ GF_Err gf_sc_set_scene(GF_Compositor *compositor, GF_SceneGraph *scene_graph) if (is_svg) { compositor->has_size_info = 0; gf_sc_focus_switch_ring(compositor, 0, NULL, 0); - } else + } else #endif { GF_Node *keynav = gf_scene_get_keynav(compositor->scene, NULL); @@ -1009,8 +1020,8 @@ GF_Err gf_sc_set_scene(GF_Compositor *compositor, GF_SceneGraph *scene_graph) } } - gf_sc_reset_framerate(compositor); - + gf_sc_reset_framerate(compositor); + gf_sc_lock(compositor, 0); if (scene_graph) gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); @@ -1021,13 +1032,13 @@ GF_Err gf_sc_set_scene(GF_Compositor *compositor, GF_SceneGraph *scene_graph) if (do_notif) { GF_Event evt; /*wait for user ack*/ - gf_sc_next_frame_state(compositor, GF_SC_DRAW_NONE); +// gf_sc_next_frame_state(compositor, GF_SC_DRAW_NONE); evt.type = GF_EVENT_SCENE_SIZE; evt.size.width = width; evt.size.height = height; gf_term_send_event(compositor->term, &evt); - } + } return GF_OK; } @@ -1058,14 +1069,14 @@ GF_Err gf_sc_set_size(GF_Compositor *compositor, u32 NewWidth, u32 NewHeight) compositor->msg_type |= GF_SR_CFG_AR; return GF_OK; } - /*EXTRA CARE HERE: the caller (user app) is likely a different thread than the compositor one, and depending on window + /*EXTRA CARE HERE: the caller (user app) is likely a different thread than the compositor one, and depending on window manager we may get called here as a result of a message sent to user but not yet returned */ lock_ok = gf_mx_try_lock(compositor->mx); - + compositor->new_width = NewWidth; compositor->new_height = NewHeight; compositor->msg_type |= GF_SR_CFG_SET_SIZE; - + /*if same size only request for video setup */ compositor->msg_type &= ~GF_SR_CFG_WINDOWSIZE_NOTIF; if ((compositor->display_width == NewWidth) && (compositor->display_height == NewHeight) ) { @@ -1083,7 +1094,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) /*changing drivers needs exclusive access*/ gf_sc_lock(compositor, 1); - + sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "FrameRate"); if (!sOpt) { @@ -1109,7 +1120,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) gf_sc_set_option(compositor, GF_OPT_ANTIALIAS, GF_ANTIALIAS_FULL); } - + sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "FocusHighlightFill"); if (sOpt) sscanf(sOpt, "%x", &compositor->highlight_fill); sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "FocusHighlightStroke"); @@ -1122,7 +1133,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) compositor->highlight_stroke_width = FLT2FIX(v); } else compositor->highlight_stroke_width = FIX_ONE; - + compositor->text_sel_color = 0xFFAAAAFF; sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "TextSelectHighlight"); @@ -1134,7 +1145,10 @@ void gf_sc_reload_config(GF_Compositor *compositor) compositor->traverse_state->immediate_draw = 1; } else { sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "DrawMode"); - if (!sOpt) { sOpt = "defer"; gf_cfg_set_key(compositor->user->config, "Compositor", "DrawMode", sOpt); } + if (!sOpt) { + sOpt = "defer"; + gf_cfg_set_key(compositor->user->config, "Compositor", "DrawMode", sOpt); + } if (!strcmp(sOpt, "immediate")) compositor->traverse_state->immediate_draw = 1; else if (!strcmp(sOpt, "defer-debug")) { @@ -1143,7 +1157,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) } else compositor->traverse_state->immediate_draw = 0; } - + sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "ScalableZoom"); compositor->scalable_zoom = (!sOpt || !stricmp(sOpt, "yes") ) ? 1 : 0; sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "DisableYUV"); @@ -1196,7 +1210,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "TextureFromDecoderMemory"); compositor->texture_from_decoder_memory = (sOpt && !strcmp(sOpt, "yes")) ? GF_TRUE : GF_FALSE; - if (!sOpt) + if (!sOpt) gf_cfg_set_key(compositor->user->config, "Compositor", "TextureFromDecoderMemory", "no"); #ifndef GPAC_DISABLE_3D @@ -1222,7 +1236,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) if (sOpt && !strcmp(sOpt, "Walk")) compositor->default_navigation_mode = GF_NAVIGATE_WALK; else if (sOpt && !strcmp(sOpt, "Examine")) compositor->default_navigation_mode = GF_NAVIGATE_EXAMINE; else if (sOpt && !strcmp(sOpt, "Fly")) compositor->default_navigation_mode = GF_NAVIGATE_FLY; - + #ifdef GPAC_HAS_GLU sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "RasterOutlines"); compositor->raster_outlines = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; @@ -1233,12 +1247,9 @@ void gf_sc_reload_config(GF_Compositor *compositor) #ifndef GPAC_USE_OGL_ES sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "EmulatePOW2"); compositor->emul_pow2 = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; - sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "BitmapCopyPixels"); - compositor->bitmap_use_pixels = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; #else compositor->raster_outlines = 1; compositor->emul_pow2 = 1; - compositor->bitmap_use_pixels = 0; #endif sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "PolygonAA"); @@ -1260,7 +1271,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) else compositor->draw_normals = GF_NORMALS_NONE; sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "DisableGLUScale"); - compositor->disable_glu_scale = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; + compositor->disable_glu_scale = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "DisableRectExt"); compositor->disable_rect_ext = (sOpt && !stricmp(sOpt, "yes") ) ? 1 : 0; @@ -1313,12 +1324,12 @@ void gf_sc_reload_config(GF_Compositor *compositor) else if (!strcmp(sOpt, "Columns")) compositor->visual->autostereo_type = GF_3D_STEREO_COLUMNS; else if (!strcmp(sOpt, "Rows")) compositor->visual->autostereo_type = GF_3D_STEREO_ROWS; else if (!strcmp(sOpt, "SPV19")) compositor->visual->autostereo_type = GF_3D_STEREO_5VSP19; - + else { compositor->visual->autostereo_type = GF_3D_STEREO_NONE; compositor->visual->nb_views = 1; } - if (compositor->visual->autostereo_type) + if (compositor->visual->autostereo_type) compositor->force_opengl_2d = 1; switch (compositor->visual->autostereo_type) { @@ -1351,7 +1362,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) if (sOpt && !strcmp(sOpt, "yes")) compositor->visual->reverse_views = 1; #endif //GPAC_DISABLE_3D - + #ifdef GF_SR_USE_DEPTH sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "AutoStereoCalibration"); compositor->auto_calibration = (sOpt && !strcmp(sOpt, "yes")) ? 1 : 0; @@ -1368,14 +1379,14 @@ void gf_sc_reload_config(GF_Compositor *compositor) if (!compositor->video_out->view_distance) { sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "ViewDistance"); - compositor->video_out->view_distance = FLT2FIX( sOpt ? (Float) atof(sOpt) : 50.0f ); + compositor->video_out->view_distance = FLT2FIX( sOpt ? (Float) atof(sOpt) : 50.0f ); } #ifndef GPAC_DISABLE_3D sOpt = gf_cfg_get_key(compositor->user->config, "Compositor", "FocusDistance"); compositor->focus_distance = 0; - if (sOpt) - compositor->focus_distance = FLT2FIX( atof(sOpt) ); + if (sOpt) + compositor->focus_distance = FLT2FIX( atof(sOpt) ); else gf_cfg_set_key(compositor->user->config, "Compositor", "FocusDistance", "0"); #endif @@ -1397,56 +1408,56 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) e = GF_OK; switch (type) { - case GF_OPT_PLAY_STATE: - gf_sc_set_play_state(compositor, value); + case GF_OPT_PLAY_STATE: + gf_sc_set_play_state(compositor, value); break; - case GF_OPT_AUDIO_VOLUME: - gf_sc_ar_set_volume(compositor->audio_renderer, value); + case GF_OPT_AUDIO_VOLUME: + gf_sc_ar_set_volume(compositor->audio_renderer, value); break; - case GF_OPT_AUDIO_PAN: - gf_sc_ar_set_pan(compositor->audio_renderer, value); + case GF_OPT_AUDIO_PAN: + gf_sc_ar_set_pan(compositor->audio_renderer, value); break; - case GF_OPT_AUDIO_MUTE: - gf_sc_ar_mute(compositor->audio_renderer, value); + case GF_OPT_AUDIO_MUTE: + gf_sc_ar_mute(compositor->audio_renderer, value); break; case GF_OPT_OVERRIDE_SIZE: compositor->override_size_flags = value ? 1 : 0; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_STRESS_MODE: - compositor->stress_mode = value; + case GF_OPT_STRESS_MODE: + compositor->stress_mode = value; break; - case GF_OPT_ANTIALIAS: - compositor->antiAlias = value; + case GF_OPT_ANTIALIAS: + compositor->antiAlias = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_HIGHSPEED: - compositor->high_speed = value; + case GF_OPT_HIGHSPEED: + compositor->high_speed = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_DRAW_BOUNDS: - compositor->draw_bvol = value; + case GF_OPT_DRAW_BOUNDS: + compositor->draw_bvol = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_TEXTURE_TEXT: - compositor->texture_text_mode = value; + case GF_OPT_TEXTURE_TEXT: + compositor->texture_text_mode = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_ASPECT_RATIO: - compositor->aspect_ratio = value; + case GF_OPT_ASPECT_RATIO: + compositor->aspect_ratio = value; compositor->msg_type |= GF_SR_CFG_AR; break; - case GF_OPT_INTERACTION_LEVEL: - compositor->interaction_level = value; + case GF_OPT_INTERACTION_LEVEL: + compositor->interaction_level = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_REFRESH: - gf_sc_reset_graphics(compositor); - compositor->traverse_state->invalidate_all = 1; + case GF_OPT_REFRESH: + gf_sc_reset_graphics(compositor); + compositor->traverse_state->invalidate_all = 1; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; case GF_OPT_FULLSCREEN: - if (compositor->fullscreen != value) compositor->msg_type |= GF_SR_CFG_FULLSCREEN; + if (compositor->fullscreen != value) compositor->msg_type |= GF_SR_CFG_FULLSCREEN; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; case GF_OPT_ORIGINAL_VIEW: @@ -1463,11 +1474,11 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) } gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_FREEZE_DISPLAY: + case GF_OPT_FREEZE_DISPLAY: compositor->freeze_display = value; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; - case GF_OPT_RELOAD_CONFIG: + case GF_OPT_RELOAD_CONFIG: gf_sc_reload_config(compositor); gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); break; @@ -1484,7 +1495,7 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) /*emulate size message to force AR recompute*/ compositor->msg_type |= GF_SR_CFG_AR; break; - case GF_OPT_USE_OPENGL: + case GF_OPT_USE_OPENGL: if (compositor->force_opengl_2d != value) { compositor->force_opengl_2d = value; /*force resetup*/ @@ -1502,7 +1513,7 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) case GF_OPT_YUV_HARDWARE: compositor->enable_yuv_hw = value; break; - case GF_OPT_NAVIGATION_TYPE: + case GF_OPT_NAVIGATION_TYPE: compositor->rotation = 0; compositor_2d_set_user_transform(compositor, FIX_ONE, 0, 0, 0); #ifndef GPAC_DISABLE_3D @@ -1515,48 +1526,48 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) e = GF_NOT_SUPPORTED; } else #ifndef GPAC_DISABLE_3D - if (compositor->visual->type_3d || compositor->active_layer) { - GF_Camera *cam = compositor_3d_get_camera(compositor); - if (cam->navigation_flags & NAV_ANY) { - /*if not specifying mode, try to (un)bind top*/ - if (!value) { + if (compositor->visual->type_3d || compositor->active_layer) { + GF_Camera *cam = compositor_3d_get_camera(compositor); + if (cam->navigation_flags & NAV_ANY) { + /*if not specifying mode, try to (un)bind top*/ + if (!value) { #ifndef GPAC_DISABLE_VRML - if (compositor->active_layer) { - compositor_layer3d_bind_camera(compositor->active_layer, 0, value); - } else { - GF_Node *n = (GF_Node*)gf_list_get(compositor->visual->navigation_stack, 0); - if (n) - Bindable_SetSetBind(n, 0); - else - cam->navigate_mode = value; - } + if (compositor->active_layer) { + compositor_layer3d_bind_camera(compositor->active_layer, 0, value); + } else { + GF_Node *n = (GF_Node*)gf_list_get(compositor->visual->navigation_stack, 0); + if (n) + Bindable_SetSetBind(n, 0); + else + cam->navigate_mode = value; + } #else - cam->navigate_mode = value; + cam->navigate_mode = value; #endif - } else { - cam->navigate_mode = value; + } else { + cam->navigate_mode = value; + } + break; } - break; - } - } else + } else #endif - { - if ((value!=GF_NAVIGATE_NONE) && (value!=GF_NAVIGATE_SLIDE) && (value!=GF_NAVIGATE_EXAMINE)) { - e = GF_NOT_SUPPORTED; + { + if ((value!=GF_NAVIGATE_NONE) && (value!=GF_NAVIGATE_SLIDE) && (value!=GF_NAVIGATE_EXAMINE)) { + e = GF_NOT_SUPPORTED; + break; + } + compositor->navigate_mode = value; break; } - compositor->navigate_mode = value; - break; - } e = GF_NOT_SUPPORTED; break; - case GF_OPT_HEADLIGHT: + case GF_OPT_HEADLIGHT: #ifndef GPAC_DISABLE_3D if (compositor->visual->type_3d || compositor->active_layer) { GF_Camera *cam = compositor_3d_get_camera(compositor); if (cam->navigation_flags & NAV_ANY) { - if (value) + if (value) cam->navigation_flags |= NAV_HEADLIGHT; else cam->navigation_flags &= ~NAV_HEADLIGHT; @@ -1566,16 +1577,28 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) #endif e = GF_NOT_SUPPORTED; break; - + #ifndef GPAC_DISABLE_3D - case GF_OPT_EMULATE_POW2: compositor->emul_pow2 = value; break; - case GF_OPT_POLYGON_ANTIALIAS: compositor->poly_aa = value; break; - case GF_OPT_BACK_CULL: compositor->backcull = value; break; - case GF_OPT_WIREFRAME: compositor->wiremode = value; break; - case GF_OPT_NORMALS: compositor->draw_normals = value; break; + case GF_OPT_EMULATE_POW2: + compositor->emul_pow2 = value; + break; + case GF_OPT_POLYGON_ANTIALIAS: + compositor->poly_aa = value; + break; + case GF_OPT_BACK_CULL: + compositor->backcull = value; + break; + case GF_OPT_WIREFRAME: + compositor->wiremode = value; + break; + case GF_OPT_NORMALS: + compositor->draw_normals = value; + break; #ifdef GPAC_HAS_GLU - case GF_OPT_RASTER_OUTLINES: compositor->raster_outlines = value; break; + case GF_OPT_RASTER_OUTLINES: + compositor->raster_outlines = value; + break; #endif case GF_OPT_NO_RECT_TEXTURE: @@ -1585,17 +1608,18 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) gf_sc_reset_graphics(compositor); } break; - case GF_OPT_BITMAP_COPY: compositor->bitmap_use_pixels = value; break; - case GF_OPT_COLLISION: compositor->collide_mode = value; break; - case GF_OPT_GRAVITY: - { + case GF_OPT_COLLISION: + compositor->collide_mode = value; + break; + case GF_OPT_GRAVITY: + { GF_Camera *cam = compositor_3d_get_camera(compositor); compositor->gravity_on = value; /*force collision pass*/ cam->last_pos.z -= 1; gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); } - break; + break; #endif case GF_OPT_VIDEO_CACHE_SIZE: @@ -1606,7 +1630,7 @@ GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) #endif break; - default: + default: e = GF_BAD_PARAM; break; } @@ -1627,27 +1651,27 @@ Bool gf_sc_is_over(GF_Compositor *compositor, GF_SceneGraph *scene_graph) switch (gf_node_get_tag((GF_Node *)tn->udta)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_TimeSensor: + case TAG_MPEG4_TimeSensor: #endif #ifndef GPAC_DISABLE_X3D - case TAG_X3D_TimeSensor: + case TAG_X3D_TimeSensor: #endif return 0; #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_MovieTexture: + case TAG_MPEG4_MovieTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_MovieTexture: + case TAG_X3D_MovieTexture: #endif if (((M_MovieTexture *)tn->udta)->loop) return 0; break; - case TAG_MPEG4_AudioClip: + case TAG_MPEG4_AudioClip: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_AudioClip: + case TAG_X3D_AudioClip: #endif if (((M_AudioClip*)tn->udta)->loop) return 0; break; - case TAG_MPEG4_AnimationStream: + case TAG_MPEG4_AnimationStream: if (((M_AnimationStream*)tn->udta)->loop) return 0; break; #endif @@ -1660,35 +1684,53 @@ Bool gf_sc_is_over(GF_Compositor *compositor, GF_SceneGraph *scene_graph) u32 gf_sc_get_option(GF_Compositor *compositor, u32 type) { switch (type) { - case GF_OPT_PLAY_STATE: return compositor->paused ? 1 : 0; - case GF_OPT_OVERRIDE_SIZE: return (compositor->override_size_flags & 1) ? 1 : 0; + case GF_OPT_PLAY_STATE: + return compositor->paused ? 1 : 0; + case GF_OPT_OVERRIDE_SIZE: + return (compositor->override_size_flags & 1) ? 1 : 0; case GF_OPT_IS_FINISHED: if (compositor->interaction_sensors) return 0; case GF_OPT_IS_OVER: return gf_sc_is_over(compositor, NULL); - case GF_OPT_STRESS_MODE: return compositor->stress_mode; - case GF_OPT_AUDIO_VOLUME: return compositor->audio_renderer->volume; - case GF_OPT_AUDIO_PAN: return compositor->audio_renderer->pan; - case GF_OPT_AUDIO_MUTE: return compositor->audio_renderer->mute; - - case GF_OPT_ANTIALIAS: return compositor->antiAlias; - case GF_OPT_HIGHSPEED: return compositor->high_speed; - case GF_OPT_ASPECT_RATIO: return compositor->aspect_ratio; - case GF_OPT_FULLSCREEN: return compositor->fullscreen; - case GF_OPT_INTERACTION_LEVEL: return compositor->interaction_level; - case GF_OPT_VISIBLE: return !compositor->is_hidden; - case GF_OPT_FREEZE_DISPLAY: return compositor->freeze_display; - case GF_OPT_TEXTURE_TEXT: return compositor->texture_text_mode; - case GF_OPT_USE_OPENGL: return compositor->force_opengl_2d; + case GF_OPT_STRESS_MODE: + return compositor->stress_mode; + case GF_OPT_AUDIO_VOLUME: + return compositor->audio_renderer->volume; + case GF_OPT_AUDIO_PAN: + return compositor->audio_renderer->pan; + case GF_OPT_AUDIO_MUTE: + return compositor->audio_renderer->mute; + + case GF_OPT_ANTIALIAS: + return compositor->antiAlias; + case GF_OPT_HIGHSPEED: + return compositor->high_speed; + case GF_OPT_ASPECT_RATIO: + return compositor->aspect_ratio; + case GF_OPT_FULLSCREEN: + return compositor->fullscreen; + case GF_OPT_INTERACTION_LEVEL: + return compositor->interaction_level; + case GF_OPT_VISIBLE: + return !compositor->is_hidden; + case GF_OPT_FREEZE_DISPLAY: + return compositor->freeze_display; + case GF_OPT_TEXTURE_TEXT: + return compositor->texture_text_mode; + case GF_OPT_USE_OPENGL: + return compositor->force_opengl_2d; case GF_OPT_DRAW_MODE: if (compositor->traverse_state->immediate_draw) return GF_DRAW_MODE_IMMEDIATE; if (compositor->debug_defer) return GF_DRAW_MODE_DEFER_DEBUG; return GF_DRAW_MODE_DEFER; - case GF_OPT_SCALABLE_ZOOM: return compositor->scalable_zoom; - case GF_OPT_YUV_HARDWARE: return compositor->enable_yuv_hw; - case GF_OPT_YUV_FORMAT: return compositor->enable_yuv_hw ? compositor->video_out->yuv_pixel_format : 0; - case GF_OPT_NAVIGATION_TYPE: + case GF_OPT_SCALABLE_ZOOM: + return compositor->scalable_zoom; + case GF_OPT_YUV_HARDWARE: + return compositor->enable_yuv_hw; + case GF_OPT_YUV_FORMAT: + return compositor->enable_yuv_hw ? compositor->video_out->yuv_pixel_format : 0; + case GF_OPT_NAVIGATION_TYPE: #ifndef GPAC_DISABLE_3D if (compositor->navigation_disabled) return GF_NAVIGATE_TYPE_NONE; if (compositor->visual->type_3d || compositor->active_layer) { @@ -1696,23 +1738,26 @@ u32 gf_sc_get_option(GF_Compositor *compositor, u32 type) if (!(cam->navigation_flags & NAV_ANY)) return GF_NAVIGATE_TYPE_NONE; // return ((cam->is_3D || compositor->active_layer) ? GF_NAVIGATE_TYPE_3D : GF_NAVIGATE_TYPE_2D); return GF_NAVIGATE_TYPE_3D; - } else + } else #endif { return GF_NAVIGATE_TYPE_2D; } - case GF_OPT_NAVIGATION: + case GF_OPT_NAVIGATION: #ifndef GPAC_DISABLE_3D if (compositor->visual->type_3d || compositor->active_layer) { GF_Camera *cam = compositor_3d_get_camera(compositor); return cam->navigate_mode; - } + } #endif return compositor->navigate_mode; - case GF_OPT_HEADLIGHT: return 0; - case GF_OPT_COLLISION: return GF_COLLISION_NONE; - case GF_OPT_GRAVITY: return 0; + case GF_OPT_HEADLIGHT: + return 0; + case GF_OPT_COLLISION: + return GF_COLLISION_NONE; + case GF_OPT_GRAVITY: + return 0; case GF_OPT_VIDEO_CACHE_SIZE: #ifdef GF_SR_USE_VIDEO_CACHE @@ -1730,7 +1775,8 @@ u32 gf_sc_get_option(GF_Compositor *compositor, u32 type) #endif return 1; - default: return 0; + default: + return 0; } } @@ -1752,13 +1798,14 @@ GF_Err gf_sc_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *frame gf_mx_p(compositor->mx); #ifndef GPAC_DISABLE_3D - if (compositor->visual->type_3d) e = compositor_3d_get_screen_buffer(compositor, framebuffer, depth_dump_mode); + if (compositor->visual->type_3d || compositor->hybrid_opengl) + e = compositor_3d_get_screen_buffer(compositor, framebuffer, depth_dump_mode); else #endif - /*no depth dump in 2D mode*/ - if (depth_dump_mode) e = GF_NOT_SUPPORTED; - else e = compositor->video_out->LockBackBuffer(compositor->video_out, framebuffer, 1); - + /*no depth dump in 2D mode*/ + if (depth_dump_mode) e = GF_NOT_SUPPORTED; + else e = compositor->video_out->LockBackBuffer(compositor->video_out, framebuffer, 1); + if (e != GF_OK) gf_mx_v(compositor->mx); return e; } @@ -1786,10 +1833,11 @@ GF_Err gf_sc_release_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *f if (!compositor || !framebuffer) return GF_BAD_PARAM; #ifndef GPAC_DISABLE_3D - if (compositor->visual->type_3d) e = compositor_3d_release_screen_buffer(compositor, framebuffer); + if (compositor->visual->type_3d || compositor->hybrid_opengl) + e = compositor_3d_release_screen_buffer(compositor, framebuffer); else #endif - e = compositor->video_out->LockBackBuffer(compositor->video_out, framebuffer, 0); + e = compositor->video_out->LockBackBuffer(compositor->video_out, framebuffer, 0); gf_mx_v(compositor->mx); return e; @@ -1823,7 +1871,7 @@ Double gf_sc_get_fps(GF_Compositor *compositor, Bool absoluteFPS) fidx = compositor->current_frame; frames = 0; run_time = compositor->frame_time[fidx]; - fidx = (fidx+1)% GF_SR_FPS_COMPUTE_SIZE; + fidx = (fidx+1)% GF_SR_FPS_COMPUTE_SIZE; assert(run_time >= compositor->frame_time[fidx]); run_time -= compositor->frame_time[fidx]; frames = GF_SR_FPS_COMPUTE_SIZE-1; @@ -1858,6 +1906,85 @@ GF_Node *gf_sc_pick_node(GF_Compositor *compositor, s32 X, s32 Y) return NULL; } +static void gf_sc_recompute_ar(GF_Compositor *compositor, GF_Node *top_node) +{ + +#ifndef GPAC_DISABLE_LOG + compositor->visual_config_time = 0; +#endif + if (compositor->recompute_ar) { +#ifndef GPAC_DISABLE_LOG + u32 time=0; + + if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { + time = gf_sys_clock(); + } +#endif + + gf_sc_ar_control(compositor->audio_renderer, 0); +#ifndef GPAC_DISABLE_3D + if (compositor->autoconfig_opengl) { + compositor->visual->type_3d = 1; + } + if (compositor->visual->type_3d) { + compositor_3d_set_aspect_ratio(compositor); + gf_sc_load_opengl_extensions(compositor, compositor->visual->type_3d); + if (compositor->autoconfig_opengl) { +#ifndef GPAC_USE_OGL_ES + visual_3d_init_yuv_shader(compositor->visual); +#endif + compositor->autoconfig_opengl = 0; + compositor->visual->type_3d = 0; + compositor->force_opengl_2d = 0; + + //enable hybrid mode by default + if (compositor->visual->yuv_rect_glsl_program) { + gf_cfg_set_key(compositor->user->config, "Compositor", "OpenGLMode", "hybrid"); + compositor->hybrid_opengl = 1; + } else { + gf_cfg_set_key(compositor->user->config, "Compositor", "OpenGLMode", "disable"); + } + } + + } + if (!compositor->visual->type_3d) +#endif + { + compositor_2d_set_aspect_ratio(compositor); +#ifndef GPAC_DISABLE_3D + if (compositor->hybrid_opengl) { + gf_sc_load_opengl_extensions(compositor, GF_TRUE); +#ifndef GPAC_USE_OGL_ES + visual_3d_init_yuv_shader(compositor->visual); +#endif + if (!compositor->visual->hybgl_drawn.list) { + ra_init(&compositor->visual->hybgl_drawn); + } + } +#endif + } + + gf_sc_ar_control(compositor->audio_renderer, 1); + +#ifndef GPAC_DISABLE_LOG + if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { + compositor->visual_config_time = gf_sys_clock() - time; + } +#endif + +#ifndef GPAC_DISABLE_VRML + compositor_evaluate_envtests(compositor, 0); +#endif + //fullscreen was postponed, retry now that the AR has been recomputed + if (compositor->fullscreen_postponed) { + compositor->fullscreen_postponed = 0; + compositor->msg_type |= GF_SR_CFG_FULLSCREEN; + } + + } +} + + static void gf_sc_setup_root_visual(GF_Compositor *compositor, GF_Node *top_node) { @@ -1886,7 +2013,7 @@ static void gf_sc_setup_root_visual(GF_Compositor *compositor, GF_Node *top_node if (compositor->display_depth) { compositor->visual->type_3d = 0; compositor->visual->camera.is_3D = 0; - } else + } else #endif { compositor->visual->type_3d = 0; @@ -1923,7 +2050,7 @@ static void gf_sc_setup_root_visual(GF_Compositor *compositor, GF_Node *top_node if (compositor->display_depth) { compositor->visual->type_3d = 2; compositor->visual->camera.is_3D = 1; - } else + } else #endif { compositor->visual->type_3d = 0; @@ -1936,7 +2063,7 @@ static void gf_sc_setup_root_visual(GF_Compositor *compositor, GF_Node *top_node #endif /*GPAC_DISABLE_SVG*/ } - /*!! by default we don't set the focus on the content - this is conform to SVG and avoids displaying the + /*!! by default we don't set the focus on the content - this is conform to SVG and avoids displaying the focus box for MPEG-4 !! */ /*setup OpenGL & camera mode*/ @@ -1974,85 +2101,6 @@ static void gf_sc_setup_root_visual(GF_Compositor *compositor, GF_Node *top_node } } -static void gf_sc_recompute_ar(GF_Compositor *compositor, GF_Node *top_node) -{ - -#ifndef GPAC_DISABLE_LOG - compositor->visual_config_time = 0; -#endif - if (compositor->recompute_ar) { -#ifndef GPAC_DISABLE_LOG - u32 time=0; - - if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { - time = gf_sys_clock(); - } -#endif - - gf_sc_ar_control(compositor->audio_renderer, 0); -#ifndef GPAC_DISABLE_3D - if (compositor->autoconfig_opengl) { - compositor->visual->type_3d = 1; - } - if (compositor->visual->type_3d) { - compositor_3d_set_aspect_ratio(compositor); - gf_sc_load_opengl_extensions(compositor, compositor->visual->type_3d); - if (compositor->autoconfig_opengl) { -#ifndef GPAC_USE_OGL_ES - visual_3d_init_yuv_shader(compositor->visual); -#endif - compositor->autoconfig_opengl = 0; - - //enable hybrid mode by default - if (compositor->visual->yuv_rect_glsl_program) { - gf_cfg_set_key(compositor->user->config, "Compositor", "OpenGLMode", "hybrid"); - compositor->force_opengl_2d = 0; - compositor->hybrid_opengl = 1; - } else { - gf_cfg_set_key(compositor->user->config, "Compositor", "OpenGLMode", "disable"); - compositor->force_opengl_2d = 0; - compositor->visual->type_3d = 0; - } - } - - } - if (!compositor->visual->type_3d) -#endif - { - compositor_2d_set_aspect_ratio(compositor); -#ifndef GPAC_DISABLE_3D - if (compositor->hybrid_opengl) { - gf_sc_load_opengl_extensions(compositor, GF_TRUE); -#ifndef GPAC_USE_OGL_ES - visual_3d_init_yuv_shader(compositor->visual); -#endif - if (!compositor->visual->hybgl_drawn.list) { - ra_init(&compositor->visual->hybgl_drawn); - } - } -#endif - } - - gf_sc_ar_control(compositor->audio_renderer, 1); - - gf_sc_next_frame_state(compositor, GF_SC_DRAW_NONE); - -#ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { - compositor->visual_config_time = gf_sys_clock() - time; - } -#endif - - compositor_evaluate_envtests(compositor, 0); - - //fullscreen was postponed, retry now that the AR has been recomputed - if (compositor->fullscreen_postponed) { - compositor->fullscreen_postponed = 0; - compositor->msg_type |= GF_SR_CFG_FULLSCREEN; - } - - } -} static void gf_sc_draw_scene(GF_Compositor *compositor) { @@ -2065,8 +2113,6 @@ static void gf_sc_draw_scene(GF_Compositor *compositor) return; } - gf_sc_recompute_ar(compositor, top_node); - #ifdef GF_SR_USE_VIDEO_CACHE if (!compositor->video_cache_max_size) compositor->traverse_state->in_group_cache = 1; @@ -2117,7 +2163,7 @@ static void compositor_release_textures(GF_Compositor *compositor, Bool frame_dr for (i=0; itextures, i); gf_sc_texture_release_stream(txh); - if (frame_drawn && txh->tx_io && !(txh->flags & GF_SR_TEXTURE_USED)) + if (frame_drawn && txh->tx_io && !(txh->flags & GF_SR_TEXTURE_USED)) gf_sc_texture_reset(txh); /*remove the use flag*/ txh->flags &= ~GF_SR_TEXTURE_USED; @@ -2126,8 +2172,10 @@ static void compositor_release_textures(GF_Compositor *compositor, Bool frame_dr void gf_sc_simulation_tick(GF_Compositor *compositor) -{ +{ +#ifndef GPAC_DISABLE_SCENEGRAPH GF_SceneGraph *sg; +#endif GF_List *temp_queue; u32 in_time, end_time, i, count; Bool frame_drawn, has_timed_nodes=GF_FALSE, all_tx_done=GF_TRUE; @@ -2158,7 +2206,7 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) /* if there is no scene*/ if (!compositor->scene && !gf_list_count(compositor->extra_scenes) ) { gf_sc_draw_scene(compositor); - //increase clock in bench mode before releasing mutex + //increase clock in bench mode before releasing mutex if (compositor->bench_mode && (compositor->force_bench_frame==1)) { compositor->scene_sampled_clock += compositor->frame_duration; } @@ -2183,7 +2231,7 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) gf_mx_p(compositor->evq_mx); temp_queue = compositor->event_queue; compositor->event_queue = compositor->event_queue_back; - compositor->event_queue_back = temp_queue; + compositor->event_queue_back = temp_queue; gf_mx_v(compositor->evq_mx); while (gf_list_count(compositor->event_queue_back)) { GF_QueuedEvent *qev = (GF_QueuedEvent*)gf_list_get(compositor->event_queue_back, 0); @@ -2240,7 +2288,7 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) if (!txh->stream_finished) all_tx_done=0; } - //it may happen that we have a reconfigure request at this stage, especially if updating one of the textures + //it may happen that we have a reconfigure request at this stage, especially if updating one of the textures //forced a relayout - do it right away if (compositor->msg_type) { gf_sc_lock(compositor, 0); @@ -2276,13 +2324,13 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) #ifndef GPAC_DISABLE_SVG #if SVG_FIXME - { /* Experimental (Not SVG compliant system events (i.e. battery, cpu ...) triggered to the root node)*/ + { /* Experimental (Not SVG compliant system events (i.e. battery, cpu ...) triggered to the root node)*/ GF_Node *root = gf_sg_get_root_node(compositor->scene); GF_DOM_Event evt; if (gf_dom_listener_count(root)) { u32 i, count; count = gf_dom_listener_count(root); - for (i=0;ievent.type == GF_EVENT_CPU) { GF_SystemRTInfo sys_rti; @@ -2291,7 +2339,7 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) evt.cpu_percentage = sys_rti.total_cpu_usage; //fprintf(stderr, "%d\n",sys_rti.total_cpu_usage); gf_dom_event_fire(root, NULL, &evt); - } + } } else if (l->event.type == GF_EVENT_BATTERY) { //&& l->observer.target == (SVG_SA_Element *)node) { evt.type = GF_EVENT_BATTERY; gf_sys_get_battery_state(&evt.onBattery, &evt.batteryState, &evt.batteryLevel, NULL, NULL); @@ -2301,6 +2349,10 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) } } #endif +#endif //GPAC_DISABLE_SVG + + +#ifndef GPAC_DISABLE_SVG #ifndef GPAC_DISABLE_LOG smil_timing_time = gf_sys_clock(); @@ -2319,8 +2371,8 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) smil_timing_time = gf_sys_clock() - smil_timing_time; #endif -#endif - +#endif //GPAC_DISABLE_SVG + #ifndef GPAC_DISABLE_LOG time_node_time = gf_sys_clock(); @@ -2388,6 +2440,9 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) /*setup root visual BEFORE updating the composite textures (since they may depend on root setup)*/ gf_sc_setup_root_visual(compositor, gf_sg_get_root_node(compositor->scene)); + /*setup display before updating composite textures (some may require a valid openGL context)*/ + gf_sc_recompute_ar(compositor, gf_sg_get_root_node(compositor->scene) ); + #ifndef GPAC_DISABLE_LOG txtime = gf_sys_clock(); #endif @@ -2486,9 +2541,9 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) //release compositor in case we have vsync gf_sc_lock(compositor, 0); - rc.x = rc.y = 0; - rc.w = compositor->display_width; - rc.h = compositor->display_height; + rc.x = rc.y = 0; + rc.w = compositor->display_width; + rc.h = compositor->display_height; compositor->video_out->Flush(compositor->video_out, &rc); gf_sc_lock(compositor, 1); } else { @@ -2533,25 +2588,25 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) compositor->last_frame_time = gf_sys_clock(); end_time = compositor->last_frame_time - in_time; - GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("[RTI]\tCompositor Cycle Log\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - compositor->networks_time, - compositor->decoders_time, - compositor->frame_number, - compositor->traverse_state->immediate_draw, - compositor->visual_config_time, - event_time, - route_time, - smil_timing_time, - time_node_time, - texture_time, - time_spent_in_anim, - compositor->traverse_setup_time, - compositor->traverse_and_direct_draw_time, - compositor->traverse_and_direct_draw_time - time_spent_in_anim, - compositor->indirect_draw_time, - traverse_time, - flush_time, - end_time)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("[RTI]\tCompositor Cycle Log\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", + compositor->networks_time, + compositor->decoders_time, + compositor->frame_number, + compositor->traverse_state->immediate_draw, + compositor->visual_config_time, + event_time, + route_time, + smil_timing_time, + time_node_time, + texture_time, + time_spent_in_anim, + compositor->traverse_setup_time, + compositor->traverse_and_direct_draw_time, + compositor->traverse_and_direct_draw_time - time_spent_in_anim, + compositor->indirect_draw_time, + traverse_time, + flush_time, + end_time)); if (frame_drawn) { compositor->current_frame = (compositor->current_frame+1) % GF_SR_FPS_COMPUTE_SIZE; @@ -2566,19 +2621,10 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) compositor->video_frame_pending=0; gf_sc_lock(compositor, 0); -#if 0 - /*step mode on, pause and return*/ - if (frame_drawn && compositor->step_mode) { - compositor->step_mode = 0; - if (compositor->term) gf_term_set_option(compositor->term, GF_OPT_PLAY_STATE, GF_STATE_PAUSED); - return; - } -#else if (frame_drawn) compositor->step_mode = 0; -#endif /*let the owner decide*/ - if (compositor->no_regulation) + if (compositor->no_regulation) return; /*we are in bench mode, just release for a moment the composition, oherwise we will constantly lock the compositor wich may have impact on scene decoding*/ @@ -2587,7 +2633,7 @@ void gf_sc_simulation_tick(GF_Compositor *compositor) return; } - //we have a pending frame, return asap - we could sleep until frames matures but this give weird regulation + //we have a pending frame, return asap - we could sleep until frames matures but this give weird regulation if (compositor->next_frame_delay != (u32) -1) { if (compositor->next_frame_delay>end_time) compositor->next_frame_delay-=end_time; else compositor->next_frame_delay=0; @@ -2657,7 +2703,7 @@ void gf_sc_traverse_subscene_ex(GF_Compositor *compositor, GF_Node *inline_paren inline_root = gf_sg_get_root_node(subscene); if (!inline_root) return; - + if (!gf_scene_is_over(subscene)) tr_state->subscene_not_over ++; @@ -2681,16 +2727,16 @@ void gf_sc_traverse_subscene_ex(GF_Compositor *compositor, GF_Node *inline_paren of bindable stacks and gives us free 2D/3D integration*/ if (tag==TAG_MPEG4_OrderedGroup) { new_tag = TAG_MPEG4_Layer2D; - } else if ((tag==TAG_MPEG4_Group) + } else if ((tag==TAG_MPEG4_Group) #ifndef GPAC_DISABLE_X3D - || (tag==TAG_X3D_Group) + || (tag==TAG_X3D_Group) #endif - ) { + ) { new_tag = TAG_MPEG4_Layer3D; } } #if !defined(GPAC_DISABLE_X3D) && !defined(GPAC_DISABLE_3D) - /*if the inlined root node is a 3D one except Layer3D and we are not in a 3D context, insert + /*if the inlined root node is a 3D one except Layer3D and we are not in a 3D context, insert a Layer3D at the root*/ else if (!tr_state->visual->type_3d && ((tag==TAG_MPEG4_Group) || (tag==TAG_X3D_Group))) { new_tag = TAG_MPEG4_Layer3D; @@ -2733,12 +2779,14 @@ void gf_sc_traverse_subscene_ex(GF_Compositor *compositor, GF_Node *inline_paren if (flip_coords) gf_mx2d_add_scale(&transf, FIX_ONE, -FIX_ONE); - /*if scene size is given in the child document, scale to fit the entire vp*/ + /*if scene size is given in the child document, scale to fit the entire vp unless our VP is the full output*/ if (w && h) { - Fixed scale_w = tr_state->vp_size.x/w; - Fixed scale_h = tr_state->vp_size.y/h; - vp_scale = MIN(scale_w, scale_h); - gf_mx2d_add_scale(&transf, vp_scale, vp_scale); + if ((compositor->scene_width != tr_state->vp_size.x) || (compositor->scene_height != tr_state->vp_size.y)) { + Fixed scale_w = tr_state->vp_size.x/w; + Fixed scale_h = tr_state->vp_size.y/h; + vp_scale = MIN(scale_w, scale_h); + gf_mx2d_add_scale(&transf, vp_scale, vp_scale); + } } if (flip_coords) { gf_mx2d_add_translation(&transf, flip_coords * tr_state->vp_size.x/2, tr_state->vp_size.y/2); @@ -2779,14 +2827,7 @@ void gf_sc_traverse_subscene_ex(GF_Compositor *compositor, GF_Node *inline_paren /*copy over z scale*/ mx.m[10] = mx.m[5]; gf_mx_add_matrix(&tr_state->model_matrix, &mx); - if (tr_state->traversing_mode==TRAVERSE_SORT) { - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, mx.m); - gf_node_traverse(inline_root, rs); - visual_3d_matrix_pop(tr_state->visual); - } else { - gf_node_traverse(inline_root, rs); - } + gf_node_traverse(inline_root, rs); gf_mx_copy(tr_state->model_matrix, mx_bck); } else @@ -2815,13 +2856,13 @@ static Bool gf_sc_handle_event_intern(GF_Compositor *compositor, GF_Event *event gf_term_mouse_input(compositor->term, &evt.mouse); } -/* if (!compositor->interaction_level || (compositor->interaction_level==GF_INTERACT_INPUT_SENSOR) ) { - if (!from_user) { - GF_USER_SENDEVENT(compositor->user, event); + /* if (!compositor->interaction_level || (compositor->interaction_level==GF_INTERACT_INPUT_SENSOR) ) { + if (!from_user) { + GF_USER_SENDEVENT(compositor->user, event); + } + return 0; } - return 0; - } -*/ + */ gf_mx_p(compositor->mx); ret = gf_sc_exec_event(compositor, event); gf_sc_lock(compositor, GF_FALSE); @@ -2837,7 +2878,7 @@ void gf_sc_traverse_subscene(GF_Compositor *compositor, GF_Node *inline_parent, gf_sc_traverse_subscene_ex(compositor, inline_parent, subscene, rs); - while ( (subsg = gf_scene_enum_extra_scene(subscene, &i))) + while ( (subsg = gf_scene_enum_extra_scene(subscene, &i))) gf_sc_traverse_subscene_ex(compositor, inline_parent, subsg, rs); } @@ -2850,7 +2891,7 @@ static Bool gf_sc_on_event_ex(GF_Compositor *compositor , GF_Event *event, Bool if (compositor->msg_type & GF_SR_IN_RECONFIG) { if (event->type==GF_EVENT_VIDEO_SETUP) { gf_sc_reset_graphics(compositor); - if (event->setup.back_buffer) + if (event->setup.back_buffer) compositor->recompute_ar = 1; } return GF_FALSE; @@ -2860,32 +2901,32 @@ static Bool gf_sc_on_event_ex(GF_Compositor *compositor , GF_Event *event, Bool case GF_EVENT_REFRESH: if (!compositor->frame_draw_type) { /*when refreshing the window in 3D or with overlays we redraw the scene */ - if (compositor->last_had_overlays + if (compositor->last_had_overlays #ifndef GPAC_DISABLE_3D - || compositor->visual->type_3d + || compositor->visual->type_3d #endif - ) { + ) { gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); } /*reflush only*/ - else + else gf_sc_next_frame_state(compositor, GF_SC_DRAW_FLUSH); } break; case GF_EVENT_VIDEO_SETUP: - { - Bool locked = gf_mx_try_lock(compositor->mx); - if (event->setup.hw_reset) - gf_sc_reset_graphics(compositor); - - if (event->setup.back_buffer) - compositor->recompute_ar = 1; - if (locked) gf_mx_v(compositor->mx); - } - break; + { + Bool locked = gf_mx_try_lock(compositor->mx); + if (event->setup.hw_reset) + gf_sc_reset_graphics(compositor); + + if (event->setup.back_buffer) + compositor->recompute_ar = 1; + if (locked) gf_mx_v(compositor->mx); + } + break; case GF_EVENT_SIZE: /*user consummed the resize event, do nothing*/ - if ( gf_term_send_event(compositor->term, event) ) + if ( gf_term_send_event(compositor->term, event) ) return GF_TRUE; /*not consummed and compositor "owns" the output window (created by the output module), resize*/ @@ -2913,36 +2954,36 @@ static Bool gf_sc_on_event_ex(GF_Compositor *compositor , GF_Event *event, Bool { Bool ret; switch (event->key.key_code) { - case GF_KEY_SHIFT: + case GF_KEY_SHIFT: if (event->type==GF_EVENT_KEYDOWN) { - compositor->key_states |= GF_KEY_MOD_SHIFT; + compositor->key_states |= GF_KEY_MOD_SHIFT; } else { - compositor->key_states &= ~GF_KEY_MOD_SHIFT; + compositor->key_states &= ~GF_KEY_MOD_SHIFT; } break; - case GF_KEY_CONTROL: + case GF_KEY_CONTROL: if (event->type==GF_EVENT_KEYDOWN) { - compositor->key_states |= GF_KEY_MOD_CTRL; + compositor->key_states |= GF_KEY_MOD_CTRL; } else { - compositor->key_states &= ~GF_KEY_MOD_CTRL; + compositor->key_states &= ~GF_KEY_MOD_CTRL; } break; - case GF_KEY_ALT: + case GF_KEY_ALT: if (event->type==GF_EVENT_KEYDOWN) { compositor->key_states |= GF_KEY_MOD_ALT; } else { compositor->key_states &= ~GF_KEY_MOD_ALT; } break; - - } - + + } + ret = GF_FALSE; event->key.flags |= compositor->key_states; /*key sensor*/ if (compositor->term && (compositor->interaction_level & GF_INTERACT_INPUT_SENSOR) ) { ret = gf_term_keyboard_input(compositor->term, event->key.key_code, event->key.hw_code, (event->type==GF_EVENT_KEYUP) ? GF_TRUE : GF_FALSE); - } + } ret += gf_sc_handle_event_intern(compositor, event, from_user); return ret; } @@ -3024,28 +3065,49 @@ u32 gf_sc_get_audio_delay(GF_Compositor *compositor) Bool gf_sc_script_action(GF_Compositor *compositor, u32 type, GF_Node *n, GF_JSAPIParam *param) { switch (type) { - case GF_JSAPI_OP_GET_SCALE: param->val = compositor->zoom; return GF_TRUE; - case GF_JSAPI_OP_SET_SCALE: compositor_2d_set_user_transform(compositor, param->val, compositor->trans_x, compositor->trans_y, GF_FALSE); return GF_TRUE; - case GF_JSAPI_OP_GET_ROTATION: param->val = gf_divfix(180*compositor->rotation, GF_PI); return GF_TRUE; - case GF_JSAPI_OP_SET_ROTATION: compositor->rotation = gf_mulfix(GF_PI, param->val/180); compositor_2d_set_user_transform(compositor, compositor->zoom, compositor->trans_x, compositor->trans_y, GF_FALSE); return GF_TRUE; - case GF_JSAPI_OP_GET_TRANSLATE: param->pt.x = compositor->trans_x; param->pt.y = compositor->trans_y; return GF_TRUE; - case GF_JSAPI_OP_SET_TRANSLATE: compositor_2d_set_user_transform(compositor, compositor->zoom, param->pt.x, param->pt.y, GF_FALSE); return GF_TRUE; + case GF_JSAPI_OP_GET_SCALE: + param->val = compositor->zoom; + return GF_TRUE; + case GF_JSAPI_OP_SET_SCALE: + compositor_2d_set_user_transform(compositor, param->val, compositor->trans_x, compositor->trans_y, GF_FALSE); + return GF_TRUE; + case GF_JSAPI_OP_GET_ROTATION: + param->val = gf_divfix(180*compositor->rotation, GF_PI); + return GF_TRUE; + case GF_JSAPI_OP_SET_ROTATION: + compositor->rotation = gf_mulfix(GF_PI, param->val/180); + compositor_2d_set_user_transform(compositor, compositor->zoom, compositor->trans_x, compositor->trans_y, GF_FALSE); + return GF_TRUE; + case GF_JSAPI_OP_GET_TRANSLATE: + param->pt.x = compositor->trans_x; + param->pt.y = compositor->trans_y; + return GF_TRUE; + case GF_JSAPI_OP_SET_TRANSLATE: + compositor_2d_set_user_transform(compositor, compositor->zoom, param->pt.x, param->pt.y, GF_FALSE); + return GF_TRUE; /*FIXME - better SMIL timelines support*/ - case GF_JSAPI_OP_GET_TIME: param->time = gf_node_get_scene_time(n); return GF_TRUE; - case GF_JSAPI_OP_SET_TIME: /*seek_to(param->time);*/ return GF_FALSE; + case GF_JSAPI_OP_GET_TIME: + param->time = gf_node_get_scene_time(n); + return GF_TRUE; + case GF_JSAPI_OP_SET_TIME: /*seek_to(param->time);*/ + return GF_FALSE; /*FIXME - this will not work for inline docs, we will have to store the clipper at the level*/ - case GF_JSAPI_OP_GET_VIEWPORT: + case GF_JSAPI_OP_GET_VIEWPORT: #ifndef GPAC_DISABLE_SVG if (compositor_svg_get_viewport(n, ¶m->rc)) return GF_TRUE; #endif - param->rc = gf_rect_center(compositor->traverse_state->vp_size.x, compositor->traverse_state->vp_size.y); + param->rc = gf_rect_center(compositor->traverse_state->vp_size.x, compositor->traverse_state->vp_size.y); if (!compositor->visual->center_coords) { param->rc.x = 0; param->rc.y = 0; } return GF_TRUE; - case GF_JSAPI_OP_SET_FOCUS: compositor->focus_node = param->node; return GF_TRUE; - case GF_JSAPI_OP_GET_FOCUS: param->node = compositor->focus_node; return GF_TRUE; + case GF_JSAPI_OP_SET_FOCUS: + compositor->focus_node = param->node; + return GF_TRUE; + case GF_JSAPI_OP_GET_FOCUS: + param->node = compositor->focus_node; + return GF_TRUE; /*same routine: traverse tree from root to target, collecting both bounds and transform matrix*/ case GF_JSAPI_OP_GET_LOCAL_BBOX: @@ -3092,7 +3154,7 @@ Bool gf_sc_script_action(GF_Compositor *compositor, u32 type, GF_Node *n, GF_JSA } if (!tr_state.abort_bounds_traverse) param->bbox.is_set = GF_FALSE; } - return GF_TRUE; + return GF_TRUE; case GF_JSAPI_OP_LOAD_URL: { #ifndef GPAC_DISABLE_VRML @@ -3124,9 +3186,15 @@ Bool gf_sc_script_action(GF_Compositor *compositor, u32 type, GF_Node *n, GF_JSA u32 tag = gf_node_get_tag(n); switch(tag) { #ifndef GPAC_DISABLE_SVG - case TAG_SVG_audio: svg_pause_audio(n, GF_TRUE); break; - case TAG_SVG_video: svg_pause_video(n, GF_TRUE); break; - case TAG_SVG_animation: svg_pause_animation(n, GF_TRUE); break; + case TAG_SVG_audio: + svg_pause_audio(n, GF_TRUE); + break; + case TAG_SVG_video: + svg_pause_video(n, GF_TRUE); + break; + case TAG_SVG_animation: + svg_pause_animation(n, GF_TRUE); + break; #endif } } else { @@ -3134,21 +3202,27 @@ Bool gf_sc_script_action(GF_Compositor *compositor, u32 type, GF_Node *n, GF_JSA } return GF_TRUE; case GF_JSAPI_OP_RESUME_SVG: - { - u32 tag = gf_node_get_tag(n); - switch(tag) { + { + u32 tag = gf_node_get_tag(n); + switch(tag) { #ifndef GPAC_DISABLE_SVG - case TAG_SVG_audio: svg_pause_audio(n, GF_FALSE); break; - case TAG_SVG_video: svg_pause_video(n, GF_FALSE); break; - case TAG_SVG_animation: svg_pause_animation(n, GF_FALSE); break; + case TAG_SVG_audio: + svg_pause_audio(n, GF_FALSE); + break; + case TAG_SVG_video: + svg_pause_video(n, GF_FALSE); + break; + case TAG_SVG_animation: + svg_pause_animation(n, GF_FALSE); + break; #endif - } } - return GF_TRUE; - case GF_JSAPI_OP_GET_DPI_X: + } + return GF_TRUE; + case GF_JSAPI_OP_GET_DPI_X: param->opt = compositor->video_out->dpi_x; return GF_TRUE; - case GF_JSAPI_OP_GET_DPI_Y: + case GF_JSAPI_OP_GET_DPI_Y: param->opt = compositor->video_out->dpi_y; return GF_TRUE; } @@ -3167,10 +3241,10 @@ Bool gf_sc_pick_in_clipper(GF_TraverseState *tr_state, GF_Rect *clip) r = tr_state->ray; gf_mx_apply_ray(&mx, &r); if (!compositor_get_2d_plane_intersection(&r, &pos)) return GF_FALSE; - if ( (pos.x < clip->x) || (pos.y > clip->y) - || (pos.x > clip->x + clip->width) || (pos.y < clip->y - clip->height) ) return GF_FALSE; + if ( (pos.x < clip->x) || (pos.y > clip->y) + || (pos.x > clip->x + clip->width) || (pos.y < clip->y - clip->height) ) return GF_FALSE; - } else + } else #endif { GF_Rect rc = *clip; @@ -3179,8 +3253,8 @@ Bool gf_sc_pick_in_clipper(GF_TraverseState *tr_state, GF_Rect *clip) pt.x = tr_state->ray.orig.x; pt.y = tr_state->ray.orig.y; - if ( (pt.x < rc.x) || (pt.y > rc.y) - || (pt.x > rc.x + rc.width) || (pt.y < rc.y - rc.height) ) return GF_FALSE; + if ( (pt.x < rc.x) || (pt.y > rc.y) + || (pt.x > rc.x + rc.width) || (pt.y < rc.y - rc.height) ) return GF_FALSE; } return GF_TRUE; } @@ -3353,15 +3427,15 @@ static void sc_cleanup_event_queue(GF_List *evq, GF_Node *node, GF_SceneGraph *s if (qev->node) { if (node && qev->node) del = 1; - if (sg && (gf_node_get_graph(qev->node)==sg)) + if (sg && (gf_node_get_graph(qev->node)==sg)) del = 1; } if (qev->sg==sg) del = 1; - else if (qev->target && (qev->target->ptr_type == GF_DOM_EVENT_TARGET_NODE)) { - if (node && ((GF_Node *)qev->target->ptr==node)) + else if (qev->target && (qev->target->ptr_type == GF_DOM_EVENT_TARGET_NODE)) { + if (node && ((GF_Node *)qev->target->ptr==node)) del = 1; - if (sg && (gf_node_get_graph((GF_Node *)qev->target->ptr)==sg)) + if (sg && (gf_node_get_graph((GF_Node *)qev->target->ptr)==sg)) del = 1; } diff --git a/src/compositor/compositor_2d.c b/src/compositor/compositor_2d.c index a6af564..b097df8 100644 --- a/src/compositor/compositor_2d.c +++ b/src/compositor/compositor_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -29,14 +29,14 @@ #include "nodes_stacks.h" #include #include +#include "texturing.h" #ifdef OPENGL_RASTER #include "gl_inc.h" -#include "texturing.h" static void c2d_gl_fill_no_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color) { - return; + return; #if defined(GPAC_USE_OGL_ES) GLfloat line[4]; @@ -64,7 +64,7 @@ static void c2d_gl_fill_no_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Colo static void c2d_gl_fill_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color, u8 alpha) { - return; + return; #if defined(GPAC_USE_OGL_ES) GLfloat line[4]; @@ -95,7 +95,7 @@ static void c2d_gl_fill_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color c static void c2d_gl_fill_rect(void *cbk, u32 x, u32 y, u32 width, u32 height, GF_Color color) { - return; + return; #if defined(GPAC_USE_OGL_ES) GLfloat line[8]; @@ -138,25 +138,36 @@ static void c2d_gl_fill_rect(void *cbk, u32 x, u32 y, u32 width, u32 height, GF_ #ifndef GPAC_DISABLE_3D -void compositor_2d_hybgl_clear_surface(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor) +void compositor_2d_hybgl_clear_surface_ex(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor, Bool is_offscreen_clear) { SFColor rgb; if (!visual->is_attached) return; - + if (!BackColor && !visual->offscreen) { if (!visual->compositor->user || !(visual->compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT)) { BackColor = visual->compositor->back_color & 0x00FFFFFF; } } - if (rc) { + if (is_offscreen_clear) { visual->compositor->rasterizer->surface_clear(visual->raster_surface, rc, BackColor); + //if we clear the canvas with non-0 alpha, remember the area cleared in case we have to erase it later (overlapping bitmap) + if (GF_COL_A(BackColor)) { + ra_union_rect(&visual->hybgl_drawn, rc); + } } else { + Fixed a; rgb.red = INT2FIX( GF_COL_R(BackColor) ) / 255; rgb.green = INT2FIX( GF_COL_G(BackColor) )/255; rgb.blue = INT2FIX( GF_COL_B(BackColor) )/255; - visual_3d_clear(visual, rgb , GF_COL_A(BackColor)); + a = INT2FIX( GF_COL_A(BackColor) )/255; + visual_3d_clear(visual, rgb , a); } } +void compositor_2d_hybgl_clear_surface(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor) +{ + compositor_2d_hybgl_clear_surface_ex(visual, rc, BackColor, 1); +} + void compositor_2d_hybgl_flush_video(GF_Compositor *compositor, GF_IRect *area) { @@ -182,6 +193,8 @@ void compositor_2d_hybgl_flush_video(GF_Compositor *compositor, GF_IRect *area) goto exit; a_tr_state.visual = compositor->visual; + a_tr_state.camera = &compositor->visual->camera; + gf_mx_init(a_tr_state.model_matrix); visual_3d_set_state(compositor->visual, V3D_STATE_LIGHT, 0); visual_3d_enable_antialias(compositor->visual, 0); @@ -224,7 +237,7 @@ void compositor_2d_hybgl_flush_video(GF_Compositor *compositor, GF_IRect *area) visual_3d_mesh_paint(&a_tr_state, compositor->hybgl_mesh); gf_sc_texture_disable(compositor->hybgl_txh); - + if (area) { SFVec2f size; size.x = INT2FIX(compositor->vp_width); @@ -264,6 +277,7 @@ Bool c2d_gl_draw_bitmap(GF_VisualManager *visual, GF_TraverseState *tr_state, Dr } else { visual_3d_set_state(visual, V3D_STATE_BLEND, 0); } +#ifndef GPAC_DISABLE_VRML /*ignore texture transform for bitmap*/ tr_state->mesh_num_textures = gf_sc_texture_enable(ctx->aspect.fill_texture, tr_state->appear ? ((M_Appearance *)tr_state->appear)->textureTransform : NULL); if (tr_state->mesh_num_textures) { @@ -283,6 +297,7 @@ Bool c2d_gl_draw_bitmap(GF_VisualManager *visual, GF_TraverseState *tr_state, Dr tr_state->mesh_num_textures = 0; return 1; } +#endif return 0; } @@ -317,7 +332,7 @@ void compositor_2d_reset_gl_auto(GF_Compositor *compositor) gf_free(compositor->hybgl_txh->data); compositor->hybgl_txh->data = NULL; } - if (compositor->hybgl_txh->tx_io) + if (compositor->hybgl_txh->tx_io) gf_sc_texture_release(compositor->hybgl_txh); gf_free(compositor->hybgl_txh); @@ -335,12 +350,14 @@ void compositor_2d_reset_gl_auto(GF_Compositor *compositor) static GF_Err compositor_2d_setup_opengl(GF_VisualManager *visual) { - GF_Matrix mx; Fixed hh, hw; GF_Compositor *compositor = visual->compositor; visual->is_attached = 1; visual_3d_setup(visual); + visual->compositor->traverse_state->camera = &visual->camera; + + glClear(GL_DEPTH_BUFFER_BIT); glViewport(0, 0, compositor->vp_width, compositor->vp_height); @@ -357,7 +374,7 @@ static GF_Err compositor_2d_setup_opengl(GF_VisualManager *visual) glDisable(GL_NORMALIZE); glDisable(GL_DEPTH_TEST); //glDepthFunc(GL_LEQUAL); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (compositor->opengl_raster) { @@ -368,22 +385,17 @@ static GF_Err compositor_2d_setup_opengl(GF_VisualManager *visual) hw = INT2FIX(compositor->vp_width)/2; hh = INT2FIX(compositor->vp_height)/2; - gf_mx_ortho(&mx, -hw, hw, -hh, hh, 50, -50); + gf_mx_ortho(&visual->camera.projection, -hw, hw, -hh, hh, 50, -50); + visual_3d_projection_matrix_modified(visual); - visual_3d_set_matrix_mode(visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_load(visual, mx.m); + gf_mx_init(visual->camera.modelview); - visual_3d_set_matrix_mode(visual, V3D_MATRIX_MODELVIEW); - gf_mx_init(mx); #ifdef OPENGL_RASTER if (compositor->opengl_raster) { - gf_mx_add_scale(&mx, 1, -1, 1); - gf_mx_add_translation(&mx, -hw, -hh, 0); + gf_mx_add_scale(&visual->camera.modelview, 1, -1, 1); + gf_mx_add_translation(&visual->camera.modelview, -hw, -hh, 0); } #endif - - visual_3d_matrix_load(visual, mx.m); - return GF_OK; } #endif @@ -403,11 +415,11 @@ GF_Err compositor_2d_get_video_access(GF_VisualManager *visual) callbacks.fill_run_no_alpha = c2d_gl_fill_no_alpha; callbacks.fill_rect = c2d_gl_fill_rect; - visual->DrawBitmap = compositor_2d_hybgl_draw_bitmap; + visual->DrawBitmap = c2d_gl_draw_bitmap; e = compositor->rasterizer->surface_attach_to_callbacks(visual->raster_surface, &callbacks, compositor->vp_width, compositor->vp_height); if (e) return e; - + return compositor_2d_setup_opengl(visual); } #endif @@ -423,11 +435,11 @@ GF_Err compositor_2d_get_video_access(GF_VisualManager *visual) if ((compositor->hybgl_txh->width != compositor->vp_width) || (compositor->hybgl_txh->height != compositor->vp_height)) { SFVec2f size; - compositor->hybgl_txh->data = gf_realloc(compositor->hybgl_txh->data, 4*compositor->vp_width*compositor->vp_height); + compositor->hybgl_txh->data = gf_realloc(compositor->hybgl_txh->data, 4*compositor->vp_width*compositor->vp_height); - if (compositor->hybgl_txh->tx_io) + if (compositor->hybgl_txh->tx_io) gf_sc_texture_release(compositor->hybgl_txh); - + compositor->hybgl_txh->width = compositor->vp_width; compositor->hybgl_txh->height = compositor->vp_height; compositor->hybgl_txh->stride = 4*compositor->vp_width; @@ -456,11 +468,11 @@ GF_Err compositor_2d_get_video_access(GF_VisualManager *visual) memset(compositor->hybgl_txh->data, 0, 4*compositor->hybgl_txh->width*compositor->hybgl_txh->height); e = compositor->rasterizer->surface_attach_to_buffer(visual->raster_surface, compositor->hybgl_txh->data, - compositor->hybgl_txh->width, - compositor->hybgl_txh->height, - 0, - compositor->hybgl_txh->width * 4, - (GF_PixelFormat) GF_PIXEL_RGBA); + compositor->hybgl_txh->width, + compositor->hybgl_txh->height, + 0, + compositor->hybgl_txh->width * 4, + (GF_PixelFormat) GF_PIXEL_RGBA); if (e) return e; e = compositor_2d_setup_opengl(visual); if (e) return e; @@ -475,9 +487,9 @@ GF_Err compositor_2d_get_video_access(GF_VisualManager *visual) /*try from video memory handle (WIN32) if supported*/ if ((compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_HWND_HDC) - && compositor->rasterizer->surface_attach_to_device - && compositor->video_out->LockOSContext - ) { + && compositor->rasterizer->surface_attach_to_device + && compositor->video_out->LockOSContext + ) { compositor->hw_context = compositor->video_out->LockOSContext(compositor->video_out, 1); if (compositor->hw_context) { e = compositor->rasterizer->surface_attach_to_device(visual->raster_surface, compositor->hw_context, compositor->vp_width, compositor->vp_height); @@ -508,11 +520,11 @@ GF_Err compositor_2d_get_video_access(GF_VisualManager *visual) compositor->hw_locked = 1; e = compositor->rasterizer->surface_attach_to_buffer(visual->raster_surface, compositor->hw_surface.video_buffer, - compositor->hw_surface.width, - compositor->hw_surface.height, - compositor->hw_surface.pitch_x, - compositor->hw_surface.pitch_y, - (GF_PixelFormat) compositor->hw_surface.pixel_format); + compositor->hw_surface.width, + compositor->hw_surface.height, + compositor->hw_surface.pitch_x, + compositor->hw_surface.pitch_y, + (GF_PixelFormat) compositor->hw_surface.pixel_format); if (!e) { visual->is_attached = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor2D] Video surface memory attached to raster - w=%d h=%d pitch_x=%d pitch_y=%d\n", compositor->hw_surface.width, compositor->hw_surface.height, compositor->hw_surface.pitch_x, compositor->hw_surface.pitch_y)); @@ -555,21 +567,21 @@ void compositor_2d_release_video_access(GF_VisualManager *visual) #ifndef GPAC_DISABLE_LOGS static void log_blit_times(GF_TextureHandler *txh, u32 push_time) { - u32 ck; - if (!txh->stream) return; - push_time = gf_sys_clock() - push_time; - gf_mo_get_object_time(txh->stream, &ck); - if (ck>txh->last_frame_time) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor2D] Bliting frame (CTS %d) %d ms too late\n", txh->last_frame_time, ck - txh->last_frame_time )); - } - if (txh->nb_frames==100) { - txh->nb_frames = 0; - txh->upload_time = 0; - } - txh->nb_frames ++; - txh->upload_time += push_time; - - GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[2D Blitter] At %d Blit texture (CTS %d) %d ms after due date - blit in %d ms - average push time %d ms\n", ck, txh->last_frame_time, ck - txh->last_frame_time, push_time, txh->upload_time / txh->nb_frames)); + u32 ck; + if (!txh->stream) return; + push_time = gf_sys_clock() - push_time; + gf_mo_get_object_time(txh->stream, &ck); + if (ck>txh->last_frame_time) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor2D] Bliting frame (CTS %d) %d ms too late\n", txh->last_frame_time, ck - txh->last_frame_time )); + } + if (txh->nb_frames==100) { + txh->nb_frames = 0; + txh->upload_time = 0; + } + txh->nb_frames ++; + txh->upload_time += push_time; + + GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[2D Blitter] At %d Blit texture (CTS %d) %d ms after due date - blit in %d ms - average push time %d ms\n", ck, txh->last_frame_time, ck - txh->last_frame_time, push_time, txh->upload_time / txh->nb_frames)); } #endif @@ -715,11 +727,11 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan if (!txh->data) return GF_TRUE; if (!visual->compositor->has_size_info && !(visual->compositor->msg_type & GF_SR_CFG_OVERRIDE_SIZE) - && (visual->compositor->override_size_flags & 1) - && !(visual->compositor->override_size_flags & 2) - ) { + && (visual->compositor->override_size_flags & 1) + && !(visual->compositor->override_size_flags & 2) + ) { if ( (visual->compositor->scene_width < txh->width) - || (visual->compositor->scene_height < txh->height)) { + || (visual->compositor->scene_height < txh->height)) { visual->compositor->scene_width = txh->width; visual->compositor->scene_height = txh->height; visual->compositor->msg_type |= GF_SR_CFG_OVERRIDE_SIZE; @@ -728,7 +740,7 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan } if (!compositor_texture_rectangles(visual, txh, clip, unclip, &src_wnd, &dst_wnd, &use_blit, &has_scale)) return GF_TRUE; - + /*can we use hardware blitter ?*/ hw_caps = visual->compositor->video_out->hw_caps; overlay_type = 0; @@ -779,8 +791,8 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan } /*disable based on settings*/ if (!visual->compositor->enable_yuv_hw - || (ctx->col_mat || (alpha!=0xFF) || !visual->compositor->video_out->Blit) - ) { + || (ctx->col_mat || (alpha!=0xFF) || !visual->compositor->video_out->Blit) + ) { use_soft_stretch = GF_TRUE; overlay_type = 0; } @@ -899,10 +911,10 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan push_time = gf_sys_clock(); e = visual->compositor->video_out->Blit(visual->compositor->video_out, &video_src, &src_wnd, &dst_wnd, 1); - if (!e) { + if (!e) { #ifndef GPAC_DISABLE_LOG - log_blit_times(txh, push_time); -#endif + log_blit_times(txh, push_time); +#endif /*mark drawable as overlay*/ ctx->drawable->flags |= DRAWABLE_IS_OVERLAY; visual->has_overlays = GF_TRUE; @@ -940,7 +952,7 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan } #ifndef GPAC_DISABLE_LOG else { - log_blit_times(txh, push_time); + log_blit_times(txh, push_time); } #endif } @@ -952,10 +964,10 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan GF_VideoSurface backbuffer; e = visual->compositor->video_out->LockBackBuffer(visual->compositor->video_out, &backbuffer, GF_TRUE); if (!e) { - u32 push_time = gf_sys_clock(); + u32 push_time = gf_sys_clock(); gf_stretch_bits(&backbuffer, &video_src, &dst_wnd, &src_wnd, alpha, 0, col_key, ctx->col_mat); #ifndef GPAC_DISABLE_LOG - log_blit_times(txh, push_time); + log_blit_times(txh, push_time); #endif e = visual->compositor->video_out->LockBackBuffer(visual->compositor->video_out, &backbuffer, GF_FALSE); } else { @@ -972,7 +984,7 @@ static Bool compositor_2d_draw_bitmap_ex(GF_VisualManager *visual, GF_TextureHan } } visual->has_modif = GF_TRUE; -// if (is_attached) visual_2d_init_raster(visual); + if (is_attached) visual_2d_init_raster(visual); return GF_TRUE; } @@ -1022,8 +1034,8 @@ Bool compositor_2d_draw_bitmap(GF_VisualManager *visual, GF_TraverseState *tr_st case GF_PIXEL_NV21: case GF_PIXEL_YUVA: case GF_PIXEL_RGBS: - case GF_PIXEL_RGBAS: - case GF_PIXEL_YV12_10: + case GF_PIXEL_RGBAS: + case GF_PIXEL_YV12_10: break; case GF_PIXEL_YUVD: case GF_PIXEL_RGBD: @@ -1046,11 +1058,11 @@ Bool compositor_2d_draw_bitmap(GF_VisualManager *visual, GF_TraverseState *tr_st if (visual->compositor->video_out->BlitTexture) { if (! visual->compositor->video_out->BlitTexture(visual->compositor->video_out, ctx->aspect.fill_texture, &ctx->transform, &ctx->bi->clip, alpha, col_key #ifdef GF_SR_USE_DEPTH - , ctx->depth_offset, ctx->depth_gain + , ctx->depth_offset, ctx->depth_gain #else - , 0, 0 + , 0, 0 #endif - )) + )) return GF_FALSE; } else { if (!compositor_2d_draw_bitmap_ex(visual, ctx->aspect.fill_texture, ctx, &ctx->bi->clip, &ctx->bi->unclip, alpha, col_key, tr_state, 0)) @@ -1072,12 +1084,12 @@ Bool compositor_2d_draw_bitmap(GF_VisualManager *visual, GF_TraverseState *tr_st if (visual->compositor->video_out->BlitTexture) { if (!visual->compositor->video_out->BlitTexture(visual->compositor->video_out, ctx->aspect.fill_texture, &ctx->transform, &ctx->bi->clip, alpha, col_key #ifdef GF_SR_USE_DEPTH - , ctx->depth_offset, ctx->depth_gain + , ctx->depth_offset, ctx->depth_gain #else - , 0, 0 + , 0, 0 #endif - )) - return 0; + )) + return 0; } else if (!compositor_2d_draw_bitmap_ex(visual, ctx->aspect.fill_texture, ctx, &clip, &ctx->bi->unclip, alpha, col_key, tr_state, 0)) { return 0; } @@ -1174,10 +1186,10 @@ GF_Err compositor_2d_set_aspect_ratio(GF_Compositor *compositor) scaleX = scaleY = FIX_ONE; } else { -/* - compositor->output_width = compositor->vp_width; - compositor->output_height = compositor->vp_height; -*/ + /* + compositor->output_width = compositor->vp_width; + compositor->output_height = compositor->vp_height; + */ compositor->output_width = compositor->display_width; compositor->output_height = compositor->display_height; compositor->vp_width = compositor->display_width; @@ -1218,12 +1230,12 @@ GF_Err compositor_2d_set_aspect_ratio(GF_Compositor *compositor) else if (old_vp_width != compositor->vp_width) changed=1; else if (old_vp_height != compositor->vp_height) changed=1; else if (compositor->is_opengl != evt.setup.opengl_mode) changed=1; - + if (changed) { GF_LOG(GF_LOG_INFO, GF_LOG_COMPOSE, ("[Compositor2D] Reconfiguring display size %d x %d - opengl %s - use %s memory\n", evt.setup.width, evt.setup.height, - (evt.setup.opengl_mode==2) ? "Offscreen" : (evt.setup.opengl_mode==1) ? "yes" : "no", evt.setup.system_memory ? "systems" : "video" - )); + (evt.setup.opengl_mode==2) ? "Offscreen" : (evt.setup.opengl_mode==1) ? "yes" : "no", evt.setup.system_memory ? "systems" : "video" + )); e = compositor->video_out->ProcessEvent(compositor->video_out, &evt); if (e) { @@ -1244,7 +1256,7 @@ GF_Err compositor_2d_set_aspect_ratio(GF_Compositor *compositor) } compositor->is_opengl = evt.setup.opengl_mode; - compositor->was_system_memory = evt.setup.system_memory; + compositor->was_system_memory = evt.setup.system_memory; } if (compositor->has_size_info) { compositor->traverse_state->vp_size.x = INT2FIX(compositor->scene_width); @@ -1409,7 +1421,7 @@ GF_Rect compositor_2d_update_clipper(GF_TraverseState *tr_state, GF_Rect this_cl gf_mx2d_inverse(&mx2d); gf_mx2d_apply_rect(&mx2d, &orig); } - + if (clip.x < orig.x) { clip.width -= (orig.x - clip.x); clip.x = orig.x; diff --git a/src/compositor/compositor_3d.c b/src/compositor/compositor_3d.c index db29271..c06a36e 100644 --- a/src/compositor/compositor_3d.c +++ b/src/compositor/compositor_3d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -118,7 +118,7 @@ GF_Err compositor_3d_set_aspect_ratio(GF_Compositor *compositor) return GF_OK; } -#if defined(GPAC_USE_TINYGL) +#if defined(GPAC_USE_TINYGL) { u32 bpp; GF_VideoSurface bb; @@ -150,12 +150,12 @@ GF_Err compositor_3d_set_aspect_ratio(GF_Compositor *compositor) } } #endif - + return GF_OK; } -GF_Camera *compositor_3d_get_camera(GF_Compositor *compositor) +GF_Camera *compositor_3d_get_camera(GF_Compositor *compositor) { #ifndef GPAC_DISABLE_VRML if (compositor->active_layer) { @@ -180,133 +180,82 @@ void compositor_3d_reset_camera(GF_Compositor *compositor) void compositor_3d_draw_bitmap(Drawable *stack, DrawAspect2D *asp, GF_TraverseState *tr_state, Fixed width, Fixed height, Fixed bmp_scale_x, Fixed bmp_scale_y) { u8 alpha; -#if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) - Fixed x, y; - Fixed sx, sy; - char *data; - u32 format; -#endif GF_TextureHandler *txh; GF_Compositor *compositor = tr_state->visual->compositor; - Bool use_texture = !compositor->bitmap_use_pixels; - if (!asp->fill_texture) + if (!asp->fill_texture) return; txh = asp->fill_texture; - if (!txh || !txh->tx_io || !txh->width || !txh->height) + if (!txh || !txh->tx_io || !txh->width || !txh->height) return; - + if (((txh->pixelformat==GF_PIXEL_RGBD) || (txh->pixelformat==GF_PIXEL_YUVD))) { if (compositor->depth_gl_type) { if (txh->data && gf_sc_texture_convert(txh) ) visual_3d_point_sprite(tr_state->visual, stack, txh, tr_state); return; - } else { - use_texture = 1; } - } + } alpha = GF_COL_A(asp->fill_color); /*THIS IS A HACK, will not work when setting filled=0, transparency and XLineProps*/ if (!alpha) alpha = GF_COL_A(asp->line_color); - /*texture is available in hw, use it - if blending, force using texture*/ - if (use_texture || !gf_sc_texture_needs_reload(txh) || (alpha != 0xFF) -#ifdef GF_SR_USE_DEPTH - || tr_state->depth_offset -#endif - ) { - visual_3d_set_state(tr_state->visual, V3D_STATE_LIGHT, 0); - visual_3d_enable_antialias(tr_state->visual, 0); - if (alpha && (alpha != 0xFF)) { - visual_3d_set_material_2d_argb(tr_state->visual, GF_COL_ARGB(alpha, 0xFF, 0xFF, 0xFF)); - gf_sc_texture_set_blend_mode(txh, TX_MODULATE); - } else if (gf_sc_texture_is_transparent(txh)) { - gf_sc_texture_set_blend_mode(txh, TX_REPLACE); - } else { - visual_3d_set_state(tr_state->visual, V3D_STATE_BLEND, 0); + visual_3d_set_state(tr_state->visual, V3D_STATE_LIGHT, 0); + visual_3d_enable_antialias(tr_state->visual, 0); + if (alpha && (alpha != 0xFF)) { + visual_3d_set_material_2d_argb(tr_state->visual, GF_COL_ARGB(alpha, 0xFF, 0xFF, 0xFF)); + gf_sc_texture_set_blend_mode(txh, TX_MODULATE); + } else if (gf_sc_texture_is_transparent(txh)) { + gf_sc_texture_set_blend_mode(txh, TX_REPLACE); + } else { + visual_3d_set_state(tr_state->visual, V3D_STATE_BLEND, 0); + } + /*ignore texture transform for bitmap*/ + tr_state->mesh_num_textures = gf_sc_texture_enable(txh, NULL); + if (tr_state->mesh_num_textures) { + /*we must check the w & h passed are correct because of bitmap node initialization*/ + if (width && height) { + if (!stack->mesh) { + SFVec2f size; + size.x = width; + size.y = height; + + stack->mesh = new_mesh(); + mesh_new_rectangle(stack->mesh, size, NULL, 0); + } } - /*ignore texture transform for bitmap*/ - tr_state->mesh_num_textures = gf_sc_texture_enable(txh, NULL); - if (tr_state->mesh_num_textures) { - /*we must check the w & h passed are correct because of bitmap node initialization*/ - if (width && height) { - if (!stack->mesh) { - SFVec2f size; - size.x = width; - size.y = height; - - stack->mesh = new_mesh(); - mesh_new_rectangle(stack->mesh, size, NULL, 0); - } - } - if (stack->mesh) { + if (stack->mesh) { #ifdef GF_SR_USE_DEPTH - if (tr_state->depth_offset) { - GF_Matrix mx; - Fixed offset; - Fixed disp_depth = (compositor->display_depth<0) ? INT2FIX(tr_state->visual->height) : INT2FIX(compositor->display_depth); - if (disp_depth) { - if (!tr_state->pixel_metrics) disp_depth = gf_divfix(disp_depth, tr_state->min_hsize); - gf_mx_init(mx); - /*add recalibration by the scene*/ - offset = tr_state->depth_offset; - if (tr_state->visual->depth_vp_range) { - offset = gf_divfix(offset, tr_state->visual->depth_vp_range/2); - } - gf_mx_add_translation(&mx, 0, 0, gf_mulfix(offset, disp_depth/2) ); - - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, mx.m); - visual_3d_mesh_paint(tr_state, stack->mesh); - visual_3d_matrix_pop(tr_state->visual); - } else { - visual_3d_mesh_paint(tr_state, stack->mesh); + if (tr_state->depth_offset) { + GF_Matrix mx; + Fixed offset; + Fixed disp_depth = (compositor->display_depth<0) ? INT2FIX(tr_state->visual->height) : INT2FIX(compositor->display_depth); + if (disp_depth) { + GF_Matrix bck_mx; + if (!tr_state->pixel_metrics) disp_depth = gf_divfix(disp_depth, tr_state->min_hsize); + gf_mx_init(mx); + /*add recalibration by the scene*/ + offset = tr_state->depth_offset; + if (tr_state->visual->depth_vp_range) { + offset = gf_divfix(offset, tr_state->visual->depth_vp_range/2); } - } else -#endif - visual_3d_mesh_paint(tr_state, stack->mesh); - } - gf_sc_texture_disable(txh); - tr_state->mesh_num_textures = 0; - return; - } - } - - /*otherwise use glDrawPixels*/ -#if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) - data = gf_sc_texture_get_data(txh, &format); - if (!data) return; - - x = INT2FIX(txh->width) / -2; - y = INT2FIX(txh->height) / 2; + gf_mx_add_translation(&mx, 0, 0, gf_mulfix(offset, disp_depth/2) ); - { - Fixed g[16]; - - sx = bmp_scale_x; if (sx<0) sx = FIX_ONE; - sy = bmp_scale_y; if (sy<0) sy = FIX_ONE; -#ifndef GPAC_DISABLE_VRML - compositor_adjust_scale(txh->owner, &sx, &sy); + gf_mx_copy(bck_mx, tr_state->model_matrix); + gf_mx_add_matrix(&tr_state->model_matrix, &mx); + visual_3d_mesh_paint(tr_state, stack->mesh); + gf_mx_copy(tr_state->model_matrix, bck_mx); + } else { + visual_3d_mesh_paint(tr_state, stack->mesh); + } + } else #endif - - /*add top level scale if any*/ - sx = gf_mulfix(sx, compositor->scale_x); - sy = gf_mulfix(sy, compositor->scale_y); - - /*get & apply current transform scale*/ - visual_3d_matrix_get(tr_state->visual, V3D_MATRIX_MODELVIEW, g); - - if (g[0]<0) g[0] *= -FIX_ONE; - if (g[5]<0) g[5] *= -FIX_ONE; - sx = gf_mulfix(sx, g[0]); - sy = gf_mulfix(sy, g[5]); - x = gf_mulfix(x, sx); - y = gf_mulfix(y, sy); - + visual_3d_mesh_paint(tr_state, stack->mesh); + } + gf_sc_texture_disable(txh); + tr_state->mesh_num_textures = 0; } - visual_3d_draw_image(tr_state->visual, x, y, txh->width, txh->height, format, data, sx, sy); -#endif } diff --git a/src/compositor/compositor_node_init.c b/src/compositor/compositor_node_init.c index e17e7e3..901ba8e 100644 --- a/src/compositor/compositor_node_init.c +++ b/src/compositor/compositor_node_init.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,110 +48,184 @@ void gf_sc_on_node_init(GF_Compositor *compositor, GF_Node *node) { switch (gf_node_get_tag(node)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_AnimationStream: compositor_init_animationstream(compositor, node); break; - case TAG_MPEG4_AudioBuffer: compositor_init_audiobuffer(compositor, node); break; - case TAG_MPEG4_AudioSource: compositor_init_audiosource(compositor, node); break; - case TAG_MPEG4_AudioClip: + case TAG_MPEG4_AnimationStream: + compositor_init_animationstream(compositor, node); + break; + case TAG_MPEG4_AudioBuffer: + compositor_init_audiobuffer(compositor, node); + break; + case TAG_MPEG4_AudioSource: + compositor_init_audiosource(compositor, node); + break; + case TAG_MPEG4_AudioClip: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_AudioClip: + case TAG_X3D_AudioClip: #endif - compositor_init_audioclip(compositor, node); break; - case TAG_MPEG4_TimeSensor: + compositor_init_audioclip(compositor, node); + break; + case TAG_MPEG4_TimeSensor: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_TimeSensor: + case TAG_X3D_TimeSensor: #endif - compositor_init_timesensor(compositor, node); break; - case TAG_MPEG4_ImageTexture: + compositor_init_timesensor(compositor, node); + break; + case TAG_MPEG4_ImageTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_ImageTexture: + case TAG_X3D_ImageTexture: #endif - case TAG_MPEG4_CacheTexture: - compositor_init_imagetexture(compositor, node); break; + case TAG_MPEG4_CacheTexture: + compositor_init_imagetexture(compositor, node); + break; - case TAG_MPEG4_PixelTexture: + case TAG_MPEG4_PixelTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_PixelTexture: + case TAG_X3D_PixelTexture: #endif - compositor_init_pixeltexture(compositor, node); break; - case TAG_MPEG4_MovieTexture: + compositor_init_pixeltexture(compositor, node); + break; + case TAG_MPEG4_MovieTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_MovieTexture: + case TAG_X3D_MovieTexture: #endif - compositor_init_movietexture(compositor, node); break; + compositor_init_movietexture(compositor, node); + break; + + case TAG_MPEG4_Background2D: + compositor_init_background2d(compositor, node); + break; + case TAG_MPEG4_Bitmap: + compositor_init_bitmap(compositor, node); + break; + case TAG_MPEG4_ColorTransform: + compositor_init_colortransform(compositor, node); + break; + case TAG_MPEG4_Circle: + compositor_init_circle(compositor, node); + break; + case TAG_MPEG4_Curve2D: + compositor_init_curve2d(compositor, node); + break; + case TAG_MPEG4_XCurve2D: + compositor_init_curve2d(compositor, node); + break; + case TAG_MPEG4_Ellipse: + compositor_init_ellipse(compositor, node); + break; + case TAG_MPEG4_OrderedGroup: + compositor_init_orderedgroup(compositor, node); + break; + case TAG_MPEG4_PointSet2D: + compositor_init_pointset2d(compositor, node); + break; + case TAG_MPEG4_Transform2D: + compositor_init_transform2d(compositor, node); + break; + case TAG_MPEG4_TransformMatrix2D: + compositor_init_transformmatrix2d(compositor, node); + break; + case TAG_MPEG4_LineProperties: + compositor_init_lineprops(compositor, node); + break; + case TAG_MPEG4_XLineProperties: + compositor_init_lineprops(compositor, node); + break; + case TAG_MPEG4_Viewport: + compositor_init_viewport(compositor, node); + break; + + case TAG_MPEG4_IndexedLineSet2D: + compositor_init_indexed_line_set2d(compositor, node); + break; + case TAG_MPEG4_IndexedFaceSet2D: + compositor_init_indexed_face_set2d(compositor, node); + break; - case TAG_MPEG4_Background2D: compositor_init_background2d(compositor, node); break; - case TAG_MPEG4_Bitmap: compositor_init_bitmap(compositor, node); break; - case TAG_MPEG4_ColorTransform: compositor_init_colortransform(compositor, node); break; - case TAG_MPEG4_Circle: compositor_init_circle(compositor, node); break; - case TAG_MPEG4_Curve2D: compositor_init_curve2d(compositor, node); break; - case TAG_MPEG4_XCurve2D: compositor_init_curve2d(compositor, node); break; - case TAG_MPEG4_Ellipse: compositor_init_ellipse(compositor, node); break; - case TAG_MPEG4_OrderedGroup: compositor_init_orderedgroup(compositor, node); break; - case TAG_MPEG4_PointSet2D: compositor_init_pointset2d(compositor, node); break; - case TAG_MPEG4_Transform2D: compositor_init_transform2d(compositor, node); break; - case TAG_MPEG4_TransformMatrix2D: compositor_init_transformmatrix2d(compositor, node); break; - case TAG_MPEG4_LineProperties: compositor_init_lineprops(compositor, node); break; - case TAG_MPEG4_XLineProperties: compositor_init_lineprops(compositor, node); break; - case TAG_MPEG4_Viewport: compositor_init_viewport(compositor, node); break; + case TAG_MPEG4_Sound2D: + compositor_init_sound2d(compositor, node); + break; - case TAG_MPEG4_IndexedLineSet2D: compositor_init_indexed_line_set2d(compositor, node); break; - case TAG_MPEG4_IndexedFaceSet2D: compositor_init_indexed_face_set2d(compositor, node); break; - - case TAG_MPEG4_Sound2D: compositor_init_sound2d(compositor, node); break; + case TAG_MPEG4_LinearGradient: + compositor_init_linear_gradient(compositor, node); + break; + case TAG_MPEG4_RadialGradient: + compositor_init_radial_gradient(compositor, node); + break; + + case TAG_MPEG4_CompositeTexture2D: + compositor_init_compositetexture2d(compositor, node); + break; + case TAG_MPEG4_MatteTexture: + compositor_init_mattetexture(compositor, node); + break; - case TAG_MPEG4_LinearGradient: compositor_init_linear_gradient(compositor, node); break; - case TAG_MPEG4_RadialGradient: compositor_init_radial_gradient(compositor, node); break; + case TAG_MPEG4_Form: + compositor_init_form(compositor, node); + break; + case TAG_MPEG4_Layer2D: + compositor_init_layer2d(compositor, node); + break; + case TAG_MPEG4_Layout: + compositor_init_layout(compositor, node); + break; + case TAG_MPEG4_PathLayout: + compositor_init_path_layout(compositor, node); + break; - case TAG_MPEG4_CompositeTexture2D: compositor_init_compositetexture2d(compositor, node); break; - case TAG_MPEG4_MatteTexture: compositor_init_mattetexture(compositor, node); break; - case TAG_MPEG4_Form: compositor_init_form(compositor, node); break; - case TAG_MPEG4_Layer2D: compositor_init_layer2d(compositor, node); break; - case TAG_MPEG4_Layout: compositor_init_layout(compositor, node); break; - case TAG_MPEG4_PathLayout: compositor_init_path_layout(compositor, node); break; - - /*sensors*/ - case TAG_MPEG4_Anchor: + case TAG_MPEG4_Anchor: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Anchor: + case TAG_X3D_Anchor: #endif - compositor_init_anchor(compositor, node); break; - case TAG_MPEG4_DiscSensor: compositor_init_disc_sensor(compositor, node); break; - case TAG_MPEG4_PlaneSensor2D: compositor_init_plane_sensor2d(compositor, node); break; - case TAG_MPEG4_ProximitySensor2D: compositor_init_proximity_sensor2d(compositor, node); break; - case TAG_MPEG4_TouchSensor: + compositor_init_anchor(compositor, node); + break; + case TAG_MPEG4_DiscSensor: + compositor_init_disc_sensor(compositor, node); + break; + case TAG_MPEG4_PlaneSensor2D: + compositor_init_plane_sensor2d(compositor, node); + break; + case TAG_MPEG4_ProximitySensor2D: + compositor_init_proximity_sensor2d(compositor, node); + break; + case TAG_MPEG4_TouchSensor: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_TouchSensor: + case TAG_X3D_TouchSensor: #endif - compositor_init_touch_sensor(compositor, node); break; + compositor_init_touch_sensor(compositor, node); + break; - case TAG_MPEG4_Group: + case TAG_MPEG4_Group: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Group: + case TAG_X3D_Group: #endif - compositor_init_group(compositor, node); break; - case TAG_MPEG4_Rectangle: + compositor_init_group(compositor, node); + break; + case TAG_MPEG4_Rectangle: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Rectangle2D: + case TAG_X3D_Rectangle2D: #endif - compositor_init_rectangle(compositor, node); break; - case TAG_MPEG4_Shape: + compositor_init_rectangle(compositor, node); + break; + case TAG_MPEG4_Shape: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Shape: + case TAG_X3D_Shape: #endif - compositor_init_shape(compositor, node); break; - case TAG_MPEG4_Switch: + compositor_init_shape(compositor, node); + break; + case TAG_MPEG4_Switch: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Switch: + case TAG_X3D_Switch: #endif - compositor_init_switch(compositor, node); break; + compositor_init_switch(compositor, node); + break; - case TAG_MPEG4_Text: + case TAG_MPEG4_Text: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Text: + case TAG_X3D_Text: #endif - compositor_init_text(compositor, node); break; + compositor_init_text(compositor, node); + break; #ifndef GPAC_DISABLE_3D case TAG_MPEG4_Background: @@ -316,7 +390,7 @@ void gf_sc_on_node_init(GF_Compositor *compositor, GF_Node *node) break; case TAG_MPEG4_Layer3D: - compositor_init_layer3d(compositor, node); + compositor_init_layer3d(compositor, node); break; case TAG_MPEG4_CompositeTexture3D: compositor_init_compositetexture3d(compositor, node); @@ -328,82 +402,168 @@ void gf_sc_on_node_init(GF_Compositor *compositor, GF_Node *node) #endif - /*X3D nodes*/ + /*X3D nodes*/ #ifndef GPAC_DISABLE_X3D - case TAG_X3D_StaticGroup: compositor_init_static_group(compositor, node); break; - case TAG_X3D_Disk2D: compositor_init_disk2d(compositor, node); break; - case TAG_X3D_Arc2D: case TAG_X3D_ArcClose2D: compositor_init_arc2d(compositor, node); break; - case TAG_X3D_Polyline2D: compositor_init_polyline2d(compositor, node); break; - case TAG_X3D_TriangleSet2D: compositor_init_triangle_set2d(compositor, node); break; + case TAG_X3D_StaticGroup: + compositor_init_static_group(compositor, node); + break; + case TAG_X3D_Disk2D: + compositor_init_disk2d(compositor, node); + break; + case TAG_X3D_Arc2D: + case TAG_X3D_ArcClose2D: + compositor_init_arc2d(compositor, node); + break; + case TAG_X3D_Polyline2D: + compositor_init_polyline2d(compositor, node); + break; + case TAG_X3D_TriangleSet2D: + compositor_init_triangle_set2d(compositor, node); + break; #ifndef GPAC_DISABLE_3D - case TAG_X3D_Polypoint2D: compositor_init_polypoint2d(compositor, node); break; - case TAG_X3D_LineSet: compositor_init_lineset(compositor, node); break; - case TAG_X3D_TriangleSet: compositor_init_triangle_set(compositor, node); break; - case TAG_X3D_TriangleStripSet: compositor_init_triangle_strip_set(compositor, node); break; - case TAG_X3D_TriangleFanSet: compositor_init_triangle_fan_set(compositor, node); break; - case TAG_X3D_IndexedTriangleFanSet: compositor_init_indexed_triangle_fan_set(compositor, node); break; - case TAG_X3D_IndexedTriangleStripSet: compositor_init_indexed_triangle_strip_set(compositor, node); break; - case TAG_X3D_IndexedTriangleSet: compositor_init_indexed_triangle_set(compositor, node); break; + case TAG_X3D_Polypoint2D: + compositor_init_polypoint2d(compositor, node); + break; + case TAG_X3D_LineSet: + compositor_init_lineset(compositor, node); + break; + case TAG_X3D_TriangleSet: + compositor_init_triangle_set(compositor, node); + break; + case TAG_X3D_TriangleStripSet: + compositor_init_triangle_strip_set(compositor, node); + break; + case TAG_X3D_TriangleFanSet: + compositor_init_triangle_fan_set(compositor, node); + break; + case TAG_X3D_IndexedTriangleFanSet: + compositor_init_indexed_triangle_fan_set(compositor, node); + break; + case TAG_X3D_IndexedTriangleStripSet: + compositor_init_indexed_triangle_strip_set(compositor, node); + break; + case TAG_X3D_IndexedTriangleSet: + compositor_init_indexed_triangle_set(compositor, node); + break; #endif #endif /*GPAC_DISABLE_X3D*/ - case TAG_ProtoNode: compositor_init_hardcoded_proto(compositor, node); break; + case TAG_ProtoNode: + compositor_init_hardcoded_proto(compositor, node); + break; - case TAG_MPEG4_SBVCAnimation: - compositor_init_afx_node(compositor, node, & ((M_SBVCAnimation *)node)->url); + case TAG_MPEG4_SBVCAnimation: + compositor_init_afx_node(compositor, node, & ((M_SBVCAnimation *)node)->url); break; - case TAG_MPEG4_BitWrapper: - compositor_init_afx_node(compositor, node, & ((M_BitWrapper *)node)->url); + case TAG_MPEG4_BitWrapper: + compositor_init_afx_node(compositor, node, & ((M_BitWrapper *)node)->url); break; #endif /*GPAC_DISABLE_VRML*/ #ifndef GPAC_DISABLE_SVG /* SVG Part */ - case TAG_SVG_svg: compositor_init_svg_svg(compositor, node); break; - case TAG_SVG_g: compositor_init_svg_g(compositor, node); break; - case TAG_SVG_switch: compositor_init_svg_switch(compositor, node); break; - case TAG_SVG_rect: compositor_init_svg_rect(compositor, node); break; - case TAG_SVG_path: compositor_init_svg_path(compositor, node); break; - case TAG_SVG_circle: compositor_init_svg_circle(compositor, node); break; - case TAG_SVG_ellipse: compositor_init_svg_ellipse(compositor, node); break; - case TAG_SVG_line: compositor_init_svg_line(compositor, node); break; - case TAG_SVG_polyline: compositor_init_svg_polyline(compositor, node); break; - case TAG_SVG_polygon: compositor_init_svg_polygon(compositor, node); break; - case TAG_SVG_a: compositor_init_svg_a(compositor, node); break; - - case TAG_SVG_linearGradient: compositor_init_svg_linearGradient(compositor, node); break; - case TAG_SVG_radialGradient: compositor_init_svg_radialGradient(compositor, node); break; - case TAG_SVG_solidColor: compositor_init_svg_solidColor(compositor, node); break; - case TAG_SVG_stop: compositor_init_svg_stop(compositor, node); break; - - case TAG_SVG_text: compositor_init_svg_text(compositor, node); break; - case TAG_SVG_tspan: compositor_init_svg_tspan(compositor, node); break; - case TAG_SVG_textArea: compositor_init_svg_textarea(compositor, node); break; - case TAG_SVG_tbreak: compositor_init_svg_tbreak(compositor, node); break; - - case TAG_SVG_image: compositor_init_svg_image(compositor, node); break; - case TAG_SVG_video: compositor_init_svg_video(compositor, node); break; - case TAG_SVG_audio: compositor_init_svg_audio(compositor, node, 0); break; + case TAG_SVG_svg: + compositor_init_svg_svg(compositor, node); + break; + case TAG_SVG_g: + compositor_init_svg_g(compositor, node); + break; + case TAG_SVG_switch: + compositor_init_svg_switch(compositor, node); + break; + case TAG_SVG_rect: + compositor_init_svg_rect(compositor, node); + break; + case TAG_SVG_path: + compositor_init_svg_path(compositor, node); + break; + case TAG_SVG_circle: + compositor_init_svg_circle(compositor, node); + break; + case TAG_SVG_ellipse: + compositor_init_svg_ellipse(compositor, node); + break; + case TAG_SVG_line: + compositor_init_svg_line(compositor, node); + break; + case TAG_SVG_polyline: + compositor_init_svg_polyline(compositor, node); + break; + case TAG_SVG_polygon: + compositor_init_svg_polygon(compositor, node); + break; + case TAG_SVG_a: + compositor_init_svg_a(compositor, node); + break; + + case TAG_SVG_linearGradient: + compositor_init_svg_linearGradient(compositor, node); + break; + case TAG_SVG_radialGradient: + compositor_init_svg_radialGradient(compositor, node); + break; + case TAG_SVG_solidColor: + compositor_init_svg_solidColor(compositor, node); + break; + case TAG_SVG_stop: + compositor_init_svg_stop(compositor, node); + break; + + case TAG_SVG_text: + compositor_init_svg_text(compositor, node); + break; + case TAG_SVG_tspan: + compositor_init_svg_tspan(compositor, node); + break; + case TAG_SVG_textArea: + compositor_init_svg_textarea(compositor, node); + break; + case TAG_SVG_tbreak: + compositor_init_svg_tbreak(compositor, node); + break; + + case TAG_SVG_image: + compositor_init_svg_image(compositor, node); + break; + case TAG_SVG_video: + compositor_init_svg_video(compositor, node); + break; + case TAG_SVG_audio: + compositor_init_svg_audio(compositor, node, 0); + break; /*SVG font support - note that we initialize the font when parsing the font-face element, not the font element*/ - case TAG_SVG_font_face: compositor_init_svg_font(compositor, node); break; + case TAG_SVG_font_face: + compositor_init_svg_font(compositor, node); + break; case TAG_SVG_missing_glyph: case TAG_SVG_glyph: - compositor_init_svg_glyph(compositor, node); + compositor_init_svg_glyph(compositor, node); break; case TAG_SVG_font_face_uri: - compositor_init_svg_font_face_uri(compositor, node); break; + compositor_init_svg_font_face_uri(compositor, node); + break; - case TAG_SVG_use: compositor_init_svg_use(compositor, node); break; - case TAG_SVG_animation: compositor_init_svg_animation(compositor, node); break; - case TAG_SVG_foreignObject: compositor_init_svg_foreign_object(compositor, node); break; + case TAG_SVG_use: + compositor_init_svg_use(compositor, node); + break; + case TAG_SVG_animation: + compositor_init_svg_animation(compositor, node); + break; + case TAG_SVG_foreignObject: + compositor_init_svg_foreign_object(compositor, node); + break; - case TAG_SVG_filter: compositor_init_svg_filter(compositor, node); break; + case TAG_SVG_filter: + compositor_init_svg_filter(compositor, node); + break; - case TAG_LSR_updates: compositor_init_svg_updates(compositor, node); break; + case TAG_LSR_updates: + compositor_init_svg_updates(compositor, node); + break; #endif default: @@ -422,47 +582,66 @@ void gf_sc_invalidate(GF_Compositor *compositor, GF_Node *byObj) } switch (gf_node_get_tag(byObj)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_AnimationStream: compositor_animationstream_modified(byObj); break; - case TAG_MPEG4_AudioBuffer: compositor_audiobuffer_modified(byObj); break; - case TAG_MPEG4_AudioSource: compositor_audiosource_modified(byObj); break; - case TAG_MPEG4_AudioClip: + case TAG_MPEG4_AnimationStream: + compositor_animationstream_modified(byObj); + break; + case TAG_MPEG4_AudioBuffer: + compositor_audiobuffer_modified(byObj); + break; + case TAG_MPEG4_AudioSource: + compositor_audiosource_modified(byObj); + break; + case TAG_MPEG4_AudioClip: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_AudioClip: + case TAG_X3D_AudioClip: #endif - compositor_audioclip_modified(byObj); break; - case TAG_MPEG4_TimeSensor: + compositor_audioclip_modified(byObj); + break; + case TAG_MPEG4_TimeSensor: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_TimeSensor: + case TAG_X3D_TimeSensor: #endif - compositor_timesensor_modified(byObj); break; - case TAG_MPEG4_ImageTexture: + compositor_timesensor_modified(byObj); + break; + case TAG_MPEG4_ImageTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_ImageTexture: + case TAG_X3D_ImageTexture: #endif - case TAG_MPEG4_CacheTexture: - compositor_imagetexture_modified(byObj); break; + case TAG_MPEG4_CacheTexture: + compositor_imagetexture_modified(byObj); + break; - case TAG_MPEG4_MovieTexture: + case TAG_MPEG4_MovieTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_MovieTexture: + case TAG_X3D_MovieTexture: #endif - compositor_movietexture_modified(byObj); break; + compositor_movietexture_modified(byObj); + break; - case TAG_MPEG4_Background2D: compositor_background2d_modified(byObj); break; + case TAG_MPEG4_Background2D: + compositor_background2d_modified(byObj); + break; #ifndef GPAC_DISABLE_3D case TAG_MPEG4_Background: #ifndef GPAC_DISABLE_X3D case TAG_X3D_Background: #endif - compositor_background_modified(byObj); break; + compositor_background_modified(byObj); + break; #endif - case TAG_MPEG4_Layout: compositor_layout_modified(compositor, byObj); break; - case TAG_MPEG4_EnvironmentTest: compositor_envtest_modified(byObj); break; + case TAG_MPEG4_Layout: + compositor_layout_modified(compositor, byObj); + break; + case TAG_MPEG4_EnvironmentTest: + compositor_envtest_modified(byObj); + break; #endif /*GPAC_DISABLE_VRML*/ #ifndef GPAC_DISABLE_SVG - case TAG_SVG_video: compositor_svg_video_modified(compositor, byObj); break; + case TAG_SVG_video: + compositor_svg_video_modified(compositor, byObj); + break; #endif /*GPAC_DISABLE_SVG*/ default: diff --git a/src/compositor/drawable.c b/src/compositor/drawable.c index af78bf5..b5207b8 100644 --- a/src/compositor/drawable.c +++ b/src/compositor/drawable.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -30,7 +30,7 @@ /*default draw routine*/ -void drawable_draw(Drawable *drawable, GF_TraverseState *tr_state) +void drawable_draw(Drawable *drawable, GF_TraverseState *tr_state) { visual_2d_texture_path(tr_state->visual, tr_state->ctx->drawable->path, tr_state->ctx, tr_state); visual_2d_draw_path(tr_state->visual, tr_state->ctx->drawable->path, tr_state->ctx, NULL, NULL, tr_state); @@ -51,7 +51,7 @@ void vrml_drawable_pick(Drawable *drawable, GF_TraverseState *tr_state) if (tr_state->visual->type_3d) { visual_3d_vrml_drawable_pick(drawable->node, tr_state, NULL, drawable); return; - } + } #endif gf_mx2d_copy(inv_2d, tr_state->transform); gf_mx2d_inverse(&inv_2d); @@ -64,9 +64,9 @@ void vrml_drawable_pick(Drawable *drawable, GF_TraverseState *tr_state) /*MPEG-4 picking is always on regardless of color properties*/ if (/*tr_state->ctx->aspect.fill_texture */ - /* (tr_state->pick_typepick_typepath, x, y)) { goto picked; } @@ -91,14 +91,15 @@ picked: gf_list_reset(compositor->hit_use_stack); compositor->hit_node = drawable->node; compositor->hit_use_dom_events = 0; - compositor->hit_normal.x = compositor->hit_normal.y = 0; compositor->hit_normal.z = FIX_ONE; + compositor->hit_normal.x = compositor->hit_normal.y = 0; + compositor->hit_normal.z = FIX_ONE; compositor->hit_texcoords.x = gf_divfix(x - drawable->path->bbox.x, drawable->path->bbox.width); compositor->hit_texcoords.y = FIX_ONE - gf_divfix(drawable->path->bbox.y - y, drawable->path->bbox.height); #ifndef GPAC_DISABLE_VRML if (compositor_is_composite_texture(tr_state->appear)) { compositor->hit_appear = tr_state->appear; - } else + } else #endif { compositor->hit_appear = NULL; @@ -160,7 +161,7 @@ void drawable_del_ex(Drawable *dr, GF_Compositor *compositor) dri = dr->dri; while (dri) { is_reg = compositor ? gf_sc_visual_is_registered(compositor, dri->visual) : 0; - + bi = dri->current_bounds; while (bi) { _cur = bi; @@ -188,7 +189,7 @@ void drawable_del_ex(Drawable *dr, GF_Compositor *compositor) gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); /*check node isn't being tracked*/ - if (compositor->grab_node==dr->node) + if (compositor->grab_node==dr->node) compositor->grab_node = NULL; if (compositor->focus_node==dr->node) { @@ -259,7 +260,7 @@ static BoundInfo *drawable_check_alloc_bounds(struct _drawable_context *ctx, GF_ else ctx->drawable->dri = dri; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Visual2D] Allocating new bound info storage on visual %08x for drawable %s\n", visual, gf_node_get_class_name(ctx->drawable->node))); } - + /*get available bound info slot*/ _prev = NULL; bi = dri->current_bounds; @@ -348,7 +349,7 @@ Bool drawable_flush_bounds(Drawable *drawable, GF_VisualManager *on_visual, u32 drawable->flags &= ~DRAWABLE_DRAWN_ON_VISUAL; return was_drawn; -} +} /* return 1 if same bound is found in previous list (and remove it from the list) @@ -359,7 +360,7 @@ Bool drawable_has_same_bounds(struct _drawable_context *ctx, GF_VisualManager *v { DRInfo *dri; BoundInfo *bi; - + dri = ctx->drawable->dri; while (dri) { if (dri->visual == visual) break; @@ -370,16 +371,16 @@ Bool drawable_has_same_bounds(struct _drawable_context *ctx, GF_VisualManager *v bi = dri->previous_bounds; while (bi) { if ( - /*if 0, end of bounds used in the previous pass*/ - bi->clip.width - /*we need the same Appearance || parent */ - && (bi->extra_check == ctx->appear) - /*we need exact same cliper*/ - && (bi->clip.x==ctx->bi->clip.x) && (bi->clip.y==ctx->bi->clip.y) - && (bi->clip.width==ctx->bi->clip.width) && (bi->clip.height==ctx->bi->clip.height) - /*only check x and y (if w or h have changed, object has changed -> bounds info has been reset*/ - && (bi->unclip.x==ctx->bi->unclip.x) && (bi->unclip.y==ctx->bi->unclip.y) - ) { + /*if 0, end of bounds used in the previous pass*/ + bi->clip.width + /*we need the same Appearance || parent */ + && (bi->extra_check == ctx->appear) + /*we need exact same cliper*/ + && (bi->clip.x==ctx->bi->clip.x) && (bi->clip.y==ctx->bi->clip.y) + && (bi->clip.width==ctx->bi->clip.width) && (bi->clip.height==ctx->bi->clip.height) + /*only check x and y (if w or h have changed, object has changed -> bounds info has been reset*/ + && (bi->unclip.x==ctx->bi->unclip.x) && (bi->unclip.y==ctx->bi->unclip.y) + ) { /*remove*/ bi->clip.width = 0; return 1; @@ -466,7 +467,7 @@ void drawctx_update_info(DrawableContext *ctx, GF_VisualManager *visual) dri = dri->next; } if (drawn) { - ctx->drawable->flags |= DRAWABLE_DRAWN_ON_VISUAL; + ctx->drawable->flags |= DRAWABLE_DRAWN_ON_VISUAL; /*node has been modified, do not check bounds, just assumed it moved*/ if (ctx->drawable->flags & DRAWABLE_HAS_CHANGED) { moved = 1; @@ -475,7 +476,7 @@ void drawctx_update_info(DrawableContext *ctx, GF_VisualManager *visual) moved = !drawable_has_same_bounds(ctx, visual); } - if (need_redraw || moved) + if (need_redraw || moved) ctx->flags |= CTX_REDRAW_MASK; } @@ -533,20 +534,20 @@ u32 drawable_get_aspect_2d_mpeg4(GF_Node *node, DrawAspect2D *asp, GF_TraverseSt #ifndef GPAC_DISABLE_X3D case TAG_X3D_Material: #endif - { + { M_Material *mat = (M_Material *)m; asp->pen_props.width = 0; asp->fill_color = GF_COL_ARGB_FIXED(FIX_ONE, mat->diffuseColor.red, mat->diffuseColor.green, mat->diffuseColor.blue); - if (!tr_state->color_mat.identity) + if (!tr_state->color_mat.identity) asp->fill_color = gf_cmx_apply(&tr_state->color_mat, asp->fill_color); } - return 0; + return 0; default: return 0; } asp->fill_color = GF_COL_ARGB_FIXED(FIX_ONE-m->transparency, m->emissiveColor.red, m->emissiveColor.green, m->emissiveColor.blue); - if (!tr_state->color_mat.identity) + if (!tr_state->color_mat.identity) asp->fill_color = gf_cmx_apply(&tr_state->color_mat, asp->fill_color); asp->line_color = asp->fill_color; @@ -590,7 +591,7 @@ check_default: asp->pen_props.width = 0; return 0; } - if (m->lineProps && drawable_lineprops_dirty(m->lineProps)) + if (m->lineProps && drawable_lineprops_dirty(m->lineProps)) ret = CTX_APP_DIRTY; if (LP) { @@ -601,7 +602,7 @@ check_default: asp->line_color = gf_cmx_apply(&tr_state->color_mat, asp->line_color); } return ret; - } + } asp->pen_props.dash = (u8) XLP->lineStyle; asp->line_color = GF_COL_ARGB_FIXED(FIX_ONE-XLP->transparency, XLP->lineColor.red, XLP->lineColor.green, XLP->lineColor.blue); @@ -609,7 +610,7 @@ check_default: if (!tr_state->color_mat.identity) { asp->line_color = gf_cmx_apply(&tr_state->color_mat, asp->line_color); } - + asp->line_scale = XLP->isScalable ? FIX_ONE : 0; asp->pen_props.align = XLP->isCenterAligned ? GF_PATH_LINE_CENTER : GF_PATH_LINE_INSIDE; asp->pen_props.cap = (u8) XLP->lineCap; @@ -648,6 +649,9 @@ DrawableContext *drawable_init_context_mpeg4(Drawable *drawable, GF_TraverseStat { DrawableContext *ctx; Bool skipFill; +#ifndef GPAC_DISABLE_3D + Bool texture_ready=0; +#endif assert(tr_state->visual); /*switched-off geometry nodes are not drawn*/ @@ -663,13 +667,13 @@ DrawableContext *drawable_init_context_mpeg4(Drawable *drawable, GF_TraverseStat ctx->drawable = drawable; /*usually set by colorTransform or changes in OrderedGroup*/ - if (tr_state->invalidate_all) + if (tr_state->invalidate_all) ctx->flags |= CTX_APP_DIRTY; ctx->aspect.fill_texture = NULL; if (tr_state->appear) { ctx->appear = tr_state->appear; - if (gf_node_dirty_get(tr_state->appear)) + if (gf_node_dirty_get(tr_state->appear)) ctx->flags |= CTX_APP_DIRTY; } /*todo cliper*/ @@ -685,14 +689,14 @@ DrawableContext *drawable_init_context_mpeg4(Drawable *drawable, GF_TraverseStat ctx->aspect.fill_texture = NULL; switch (gf_node_get_tag(ctx->drawable->node) ) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_IndexedLineSet2D: + case TAG_MPEG4_IndexedLineSet2D: skipFill = 1; break; #endif default: break; } - + ctx->flags |= drawable_get_aspect_2d_mpeg4(drawable->node, &ctx->aspect, tr_state); /*Update texture info - draw even if texture not created (this may happen if the media is removed)*/ @@ -701,40 +705,55 @@ DrawableContext *drawable_init_context_mpeg4(Drawable *drawable, GF_TraverseStat ctx->flags |= CTX_TEXTURE_DIRTY; } #ifndef GPAC_DISABLE_3D - //in autoGL mode, a texture is dirty only if transparent. If not, the area covered over the video doesn't need to be repainted if unchanged + //in autoGL mode, a texture is dirty only if transparent. If not, the area covered over the video doesn't need to be repainted if unchanged //disable for color matrix as we don't yet handle them in GL if (tr_state->visual->compositor->hybrid_opengl && !tr_state->visual->offscreen) { u8 alpha = GF_COL_A(ctx->aspect.fill_color); if (!alpha) alpha = GF_COL_A(ctx->aspect.line_color); - if (!ctx->aspect.fill_texture->transparent && (alpha==0xFF) && !ctx->aspect.fill_texture->compute_gradient_matrix) + if (!ctx->aspect.fill_texture->transparent && (alpha==0xFF) && !ctx->aspect.fill_texture->compute_gradient_matrix && (drawable->flags & DRAWABLE_HYBGL_INIT)) { ctx->flags |= CTX_HYBOGL_NO_CLEAR; - //if texture is transparent, we need to redraw all object below, wether they changed ot not, bacause we have erased this part of the canvas - else + } + //otherwise, we need to redraw all object below, wether they changed ot not, because we have erased this part of the canvas + else { ctx->flags |= CTX_TEXTURE_DIRTY; + } + //wait untill we have something to draw to decide that the texture is ready, otherwise we will not clear the canvas when texture is ready + if (ctx->aspect.fill_texture->compute_gradient_matrix || ctx->aspect.fill_texture->data) + texture_ready=1; } #endif } //same as above if (ctx->aspect.line_texture) { - if (ctx->aspect.line_texture->needs_refresh) + if (ctx->aspect.line_texture->needs_refresh) ctx->flags |= CTX_TEXTURE_DIRTY; #ifndef GPAC_DISABLE_3D - //in autoGL mode, a texture is dirty only if transparent. If not, the area covered over the video doesn't need to be repainted if unchanged + //in autoGL mode, a texture is dirty only if transparent. If not, the area covered over the video doesn't need to be repainted if unchanged //disable for color matrix as we don't yet handle them in GL if (tr_state->visual->compositor->hybrid_opengl && !tr_state->visual->offscreen) { u8 alpha = GF_COL_A(ctx->aspect.line_color); - if (!ctx->aspect.line_texture->transparent && (alpha==0xFF) && !ctx->aspect.line_texture->compute_gradient_matrix) + if (!ctx->aspect.line_texture->transparent && (alpha==0xFF) && !ctx->aspect.line_texture->compute_gradient_matrix && (drawable->flags & DRAWABLE_HYBGL_INIT)) ctx->flags |= CTX_HYBOGL_NO_CLEAR; - //if texture is transparent, we need to redraw all object below, wether they changed ot not, bacause we have erased this part of the canvas + //otherwise, we need to redraw all object below, wether they changed ot not, bacause we have erased this part of the canvas else ctx->flags |= CTX_TEXTURE_DIRTY; + + //wait untill we have something to draw to decide that the texture is ready, otherwise we will not clear the canvas when texture is ready + if (ctx->aspect.line_texture->compute_gradient_matrix || ctx->aspect.line_texture->data) + texture_ready=1; } #endif } + +#ifndef GPAC_DISABLE_3D + //from now on, we won't clear the canvas when updating this texture (unless transparent, cf above) + if (texture_ready) + drawable->flags |= DRAWABLE_HYBGL_INIT; +#endif - /*not clear in the spec: what happens when a transparent node is in form/layout ?? this may + /*not clear in the spec: what happens when a transparent node is in form/layout ?? this may completely break layout of children. We consider the node should be drawn*/ if (!tr_state->parent && check_transparent_skip(ctx, skipFill)) { visual_2d_remove_last_context(tr_state->visual); @@ -748,8 +767,8 @@ DrawableContext *drawable_init_context_mpeg4(Drawable *drawable, GF_TraverseStat ctx->flags |= CTX_FLIPED_COORDS; #ifdef GF_SR_USE_DEPTH - ctx->depth_gain=tr_state->depth_gain; - ctx->depth_offset=tr_state->depth_offset; + ctx->depth_gain=tr_state->depth_gain; + ctx->depth_offset=tr_state->depth_offset; #endif return ctx; @@ -787,7 +806,7 @@ static Bool drawable_finalize_end(struct _drawable_context *ctx, GF_TraverseStat //GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor2D] Registering new drawn node %s on visual\n", gf_node_get_class_name(it->drawable->node))); ctx->drawable->flags |= DRAWABLE_REGISTERED_WITH_VISUAL; } - + /*we are in direct draw mode, draw ...*/ if (res) { /*if over an overlay we cannot remove the context and cannot draw directly*/ @@ -804,7 +823,7 @@ static Bool drawable_finalize_end(struct _drawable_context *ctx, GF_TraverseStat } else { drawable_draw(ctx->drawable, tr_state); } - + tr_state->ctx = NULL; tr_state->traversing_mode = TRAVERSE_SORT; } @@ -857,7 +876,7 @@ void drawable_finalize_sort_ex(DrawableContext *ctx, GF_TraverseState *tr_state, } else { gf_path_get_bounds(ctx->drawable->path, &store_orig_bounds); } - //if (store_orig_bounds) fprintf(stderr, "store_orig_bounds: %d\n", (int) store_orig_bounds.width ); + //if (store_orig_bounds) fprintf(stderr, "store_orig_bounds: %d\n", (int) store_orig_bounds.width ); ctx->bi->unclip = store_orig_bounds; gf_mx2d_apply_rect(&tr_state->transform, &ctx->bi->unclip); @@ -865,7 +884,7 @@ void drawable_finalize_sort_ex(DrawableContext *ctx, GF_TraverseState *tr_state, if (ctx->aspect.pen_props.width) { StrikeInfo2D *si = NULL; - if (!ctx->aspect.line_scale) + if (!ctx->aspect.line_scale) drawable_compute_line_scale(tr_state, &ctx->aspect); #if 0 @@ -917,7 +936,7 @@ void drawable_finalize_sort_ex(DrawableContext *ctx, GF_TraverseState *tr_state, /*remove if this is the last context*/ #ifdef REMVE_UNUSED_CTX - if (can_remove && (tr_state->visual->cur_context == ctx)) + if (can_remove && (tr_state->visual->cur_context == ctx)) tr_state->visual->cur_context->drawable = NULL; #endif } @@ -944,7 +963,7 @@ void drawable_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, G if (compositor->focus_used) { u32 count = gf_list_count(tr_state->use_stack); - if (!count || (gf_list_get(tr_state->use_stack, count-1)!=compositor->focus_used) ) + if (!count || (gf_list_get(tr_state->use_stack, count-1)!=compositor->focus_used) ) return; } @@ -964,7 +983,7 @@ void drawable_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, G tr_state->bounds.x = tr_state->bounds.y = 0; gf_sc_get_nodes_bounds(node, ((GF_ParentNode *)node)->children, tr_state, NULL); - + tr_state->traversing_mode = prev_mode; gf_mx2d_copy(tr_state->transform, cur); bounds = &tr_state->bounds; @@ -1006,7 +1025,7 @@ void drawable_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, G } -void drawable_traverse_focus(GF_Node *node, void *rs, Bool is_destroy) +void drawable_traverse_focus(GF_Node *node, void *rs, Bool is_destroy) { GF_TraverseState *tr_state = (GF_TraverseState *)rs; if (is_destroy) return; @@ -1081,7 +1100,7 @@ StrikeInfo2D *drawable_get_strikeinfo(GF_Compositor *compositor, Drawable *drawa #ifndef GPAC_DISABLE_3D if (tr_state && !asp->line_scale) { drawable_compute_line_scale(tr_state, asp); - } + } #endif /*picking*/ @@ -1108,9 +1127,9 @@ StrikeInfo2D *drawable_get_strikeinfo(GF_Compositor *compositor, Drawable *drawa #endif /*apply scale whether scalable or not (if not scalable, scale is still needed for scalable zoom)*/ asp->pen_props.width = gf_mulfix(asp->pen_props.width, asp->line_scale); - if (asp->pen_props.dash != GF_DASH_STYLE_SVG) + if (asp->pen_props.dash != GF_DASH_STYLE_SVG) asp->pen_props.dash_offset = gf_mulfix(asp->pen_props.dash_offset, asp->pen_props.width); - + if (asp->pen_props.dash_set) { for(i=0; ipen_props.dash_set->num_dash; i++) { asp->pen_props.dash_set->dashes[i] = gf_mulfix(asp->pen_props.dash_set->dashes[i], asp->line_scale); @@ -1176,8 +1195,8 @@ static void DestroyLineProps(GF_Node *n, void *rs, Bool is_destroy) StrikeInfo2D *si, *cur, *prev; u32 i; LinePropStack *st; - if (!is_destroy) return; - + if (!is_destroy) return; + st = (LinePropStack *)gf_node_get_private(n); i = 0; @@ -1204,9 +1223,9 @@ static void DestroyLineProps(GF_Node *n, void *rs, Bool is_destroy) delete_strikeinfo2d(si); } } - + gf_free(st); - + } void compositor_init_lineprops(GF_Compositor *compositor, GF_Node *node) @@ -1238,10 +1257,10 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta Fixed clamped_opacity = FIX_ONE; Fixed clamped_solid_opacity = FIX_ONE; Fixed clamped_fill_opacity = (props->fill_opacity->value < 0 ? 0 : (props->fill_opacity->value > FIX_ONE ? FIX_ONE : props->fill_opacity->value)); - Fixed clamped_stroke_opacity = (props->stroke_opacity->value < 0 ? 0 : (props->stroke_opacity->value > FIX_ONE ? FIX_ONE : props->stroke_opacity->value)); + Fixed clamped_stroke_opacity = (props->stroke_opacity->value < 0 ? 0 : (props->stroke_opacity->value > FIX_ONE ? FIX_ONE : props->stroke_opacity->value)); if (props->opacity) { - clamped_opacity = (props->opacity->value < 0 ? 0 : (props->opacity->value > FIX_ONE ? FIX_ONE : props->opacity->value)); + clamped_opacity = (props->opacity->value < 0 ? 0 : (props->opacity->value > FIX_ONE ? FIX_ONE : props->opacity->value)); if (clamped_opacity!=FIX_ONE) { clamped_fill_opacity = gf_mulfix(clamped_fill_opacity, clamped_opacity); clamped_stroke_opacity = gf_mulfix(clamped_stroke_opacity, clamped_opacity); @@ -1262,7 +1281,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta gf_free(iri->string); iri->string = NULL; } - } + } /* If paint server not found, paint is equivalent to none */ if (props->fill->iri.type == XMLRI_ELEMENTID) { asp->fill_color = GF_COL_ARGB_FIXED(clamped_opacity, 0, 0, 0); @@ -1273,7 +1292,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta gf_svg_flatten_attributes((SVG_Element*)props->fill->iri.target, &all_atts); gf_node_traverse(props->fill->iri.target, tr_state); - + ret += compositor_svg_solid_color_dirty(tr_state->visual->compositor, props->fill->iri.target); if (all_atts.solid_color) { @@ -1285,13 +1304,13 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta asp->fill_color = GF_COL_ARGB_FIXED(clamped_solid_opacity, all_atts.solid_color->color.red, all_atts.solid_color->color.green, all_atts.solid_color->color.blue); } } - break; - case TAG_SVG_linearGradient: - case TAG_SVG_radialGradient: + break; + case TAG_SVG_linearGradient: + case TAG_SVG_radialGradient: asp->fill_texture = gf_sc_texture_get_handler((GF_Node *)props->fill->iri.target); break; /*FIXME*/ - default: + default: break; } } @@ -1305,7 +1324,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta asp->fill_color |= ((u32) (clamped_fill_opacity*255) ) << 24; } } - if (!tr_state->color_mat.identity) + if (!tr_state->color_mat.identity) asp->fill_color = gf_cmx_apply(&tr_state->color_mat, asp->fill_color); asp->line_color = 0; @@ -1323,7 +1342,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta gf_free(iri->string); iri->string = NULL; } - } + } /* Paint server not found, stroke is equivalent to none */ if (props->stroke->iri.type == XMLRI_ELEMENTID) { switch (gf_node_get_tag((GF_Node *)props->stroke->iri.target)) { @@ -1344,17 +1363,17 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta asp->line_color = GF_COL_ARGB_FIXED(clamped_solid_opacity, all_atts.solid_color->color.red, all_atts.solid_color->color.green, all_atts.solid_color->color.blue); } } - break; - case TAG_SVG_linearGradient: - case TAG_SVG_radialGradient: + break; + case TAG_SVG_linearGradient: + case TAG_SVG_radialGradient: asp->line_texture = gf_sc_texture_get_handler((GF_Node *)props->stroke->iri.target); break; - default: + default: break; } } } else if (props->stroke->type == SVG_PAINT_COLOR) { - if (props->stroke->color.type == SVG_COLOR_CURRENTCOLOR) { + if (props->stroke->color.type == SVG_COLOR_CURRENTCOLOR) { asp->line_color = GF_COL_ARGB_FIXED(clamped_stroke_opacity, props->color->color.red, props->color->color.green, props->color->color.blue); } else if (props->stroke->color.type == SVG_COLOR_RGBCOLOR) { asp->line_color = GF_COL_ARGB_FIXED(clamped_stroke_opacity, props->stroke->color.red, props->stroke->color.green, props->stroke->color.blue); @@ -1363,7 +1382,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta asp->line_color |= ((u32) (clamped_stroke_opacity*255)) << 24; } } - if (!tr_state->color_mat.identity) + if (!tr_state->color_mat.identity) asp->line_color = gf_cmx_apply(&tr_state->color_mat, asp->line_color); if (props->stroke_dasharray->type != SVG_STROKEDASHARRAY_NONE) { @@ -1372,7 +1391,7 @@ Bool drawable_get_aspect_2d_svg(GF_Node *node, DrawAspect2D *asp, GF_TraverseSta asp->pen_props.dash_set = (GF_DashSettings *) &(props->stroke_dasharray->array); } asp->line_scale = (props->vector_effect && (*props->vector_effect == SVG_VECTOREFFECT_NONSCALINGSTROKE)) ? 0 : FIX_ONE; - + asp->pen_props.cap = (u8) *props->stroke_linecap; asp->pen_props.join = (u8) *props->stroke_linejoin; asp->pen_props.miterLimit = props->stroke_miterlimit->value; @@ -1406,14 +1425,14 @@ static Bool svg_appearance_flag_dirty(u32 flags) /* gradients stops and solidcolor do not affect appearance directly */ return 0; #else - if (flags & - (GF_SG_SVG_FILL_DIRTY | GF_SG_SVG_FILLOPACITY_DIRTY | GF_SG_SVG_FILLRULE_DIRTY - | GF_SG_SVG_STROKE_DIRTY | GF_SG_SVG_STROKEDASHARRAY_DIRTY - | GF_SG_SVG_STROKEDASHOFFSET_DIRTY | GF_SG_SVG_STROKELINECAP_DIRTY - | GF_SG_SVG_STROKELINEJOIN_DIRTY | GF_SG_SVG_STROKEMITERLIMIT_DIRTY - | GF_SG_SVG_STROKEOPACITY_DIRTY | GF_SG_SVG_STROKEWIDTH_DIRTY - | GF_SG_SVG_VECTOREFFECT_DIRTY) ) - return 1; + if (flags & + (GF_SG_SVG_FILL_DIRTY | GF_SG_SVG_FILLOPACITY_DIRTY | GF_SG_SVG_FILLRULE_DIRTY + | GF_SG_SVG_STROKE_DIRTY | GF_SG_SVG_STROKEDASHARRAY_DIRTY + | GF_SG_SVG_STROKEDASHOFFSET_DIRTY | GF_SG_SVG_STROKELINECAP_DIRTY + | GF_SG_SVG_STROKELINEJOIN_DIRTY | GF_SG_SVG_STROKEMITERLIMIT_DIRTY + | GF_SG_SVG_STROKEOPACITY_DIRTY | GF_SG_SVG_STROKEWIDTH_DIRTY + | GF_SG_SVG_VECTOREFFECT_DIRTY) ) + return 1; return 0; #endif } @@ -1438,14 +1457,14 @@ DrawableContext *drawable_init_context_svg(Drawable *drawable, GF_TraverseState ctx->flags |= CTX_APP_DIRTY; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("Node %s dirty - invalidating\n", gf_node_get_log_name(drawable->node) )); } - if (tr_state->svg_flags & (GF_SG_SVG_STROKEDASHARRAY_DIRTY | - GF_SG_SVG_STROKEDASHOFFSET_DIRTY | - GF_SG_SVG_STROKELINECAP_DIRTY | - GF_SG_SVG_STROKELINEJOIN_DIRTY | - GF_SG_SVG_STROKEMITERLIMIT_DIRTY | - GF_SG_SVG_STROKEWIDTH_DIRTY | - GF_SG_SVG_VECTOREFFECT_DIRTY )) - ctx->flags |= CTX_SVG_OUTLINE_GEOMETRY_DIRTY; + if (tr_state->svg_flags & (GF_SG_SVG_STROKEDASHARRAY_DIRTY | + GF_SG_SVG_STROKEDASHOFFSET_DIRTY | + GF_SG_SVG_STROKELINECAP_DIRTY | + GF_SG_SVG_STROKELINEJOIN_DIRTY | + GF_SG_SVG_STROKEMITERLIMIT_DIRTY | + GF_SG_SVG_STROKEWIDTH_DIRTY | + GF_SG_SVG_VECTOREFFECT_DIRTY )) + ctx->flags |= CTX_SVG_OUTLINE_GEOMETRY_DIRTY; ctx->aspect.fill_texture = NULL; @@ -1454,7 +1473,7 @@ DrawableContext *drawable_init_context_svg(Drawable *drawable, GF_TraverseState GF_SAFEALLOC(ctx->col_mat, GF_ColorMatrix); gf_cmx_copy(ctx->col_mat, &tr_state->color_mat); } - + switch (gf_node_get_tag(ctx->drawable->node) ) { case TAG_SVG_image: case TAG_SVG_video: @@ -1488,8 +1507,8 @@ DrawableContext *drawable_init_context_svg(Drawable *drawable, GF_TraverseState #ifdef GF_SR_USE_DEPTH - ctx->depth_gain=tr_state->depth_gain; - ctx->depth_offset=tr_state->depth_offset; + ctx->depth_gain=tr_state->depth_gain; + ctx->depth_offset=tr_state->depth_offset; #endif return ctx; diff --git a/src/compositor/drawable.h b/src/compositor/drawable.h index 615d403..93cf010 100644 --- a/src/compositor/drawable.h +++ b/src/compositor/drawable.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,7 +39,7 @@ typedef struct _bound_info GF_IRect clip; /*uncliped bounds - needed to track moving objects fully contained in visual and for image bliting*/ GF_Rect unclip; - /* extra_check: + /* extra_check: for MPEG-4: pointer to appearance node (due to DEF/USE) in order to detect same bounds and appearance node change for SVG: currently not used, should be needed for */ @@ -65,14 +65,14 @@ typedef struct _dirty_rect_info enum { /*user defined flags*/ - /*if flag set, the node callback function will be used to draw the node. Otherwise, + /*if flag set, the node callback function will be used to draw the node. Otherwise, high-level draw operations on the drawable & drawable context will be used*/ DRAWABLE_USE_TRAVERSE_DRAW = 1, /*bounds tracker flags, INTERNAL TO RENDERER */ /*flag set by drawable_mark_modified during a TRAVERSE_SORT pass when geometry's node has been modified. This forces clearing of the node - and skips bounds checking. + and skips bounds checking. Flag is cleared by the compositor*/ DRAWABLE_HAS_CHANGED = 1<<1, /*same flag as above except set when picking/getting bounds out of the main scene traversal routine (user event, script)*/ @@ -87,8 +87,11 @@ enum { /*drawable is an overlay surface*/ DRAWABLE_IS_OVERLAY = 1<<5, - /**/ + /*drawable has a cache texture*/ DRAWABLE_IS_CACHED = 1<<6, + + /*drawable has been initialized for hybrid GL mode - used to perform the initial clear of the overlay graphics*/ + DRAWABLE_HYBGL_INIT = 1<<7, }; struct _drawable @@ -146,7 +149,7 @@ void drawable_mark_modified(Drawable *st, GF_TraverseState *tr_state); /*checks if the current object is the focused one, and insert the focus drawable at the current pos*/ void drawable_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, GF_Rect *orig_bounds); -/*reset the highlight state (bounds) if associated with the current node. This is automatically called +/*reset the highlight state (bounds) if associated with the current node. This is automatically called whenever reseting a drawable but must be called when a grouping node is modified*/ void drawable_reset_group_highlight(GF_TraverseState *tr_state, GF_Node *n); @@ -255,13 +258,13 @@ struct _drawable_context for SVG: parent node if any */ GF_Node *appear; - + #ifdef GF_SR_USE_DEPTH - //local gain and offset - Fixed depth_gain, depth_offset; + //local gain and offset + Fixed depth_gain, depth_offset; #endif - -}; + +}; DrawableContext *NewDrawableContext(); void DeleteDrawableContext(DrawableContext *); diff --git a/src/compositor/events.c b/src/compositor/events.c index f775a18..2535b13 100644 --- a/src/compositor/events.c +++ b/src/compositor/events.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -74,15 +74,15 @@ static void flush_text_node_edit(GF_Compositor *compositor, Bool final_flush) size_t len; if (!compositor->edited_text) return; - /* if this is the final editing and there is text, - we need to remove the caret from the text selection buffer */ + /* if this is the final editing and there is text, + we need to remove the caret from the text selection buffer */ if (final_flush && compositor->sel_buffer_len) { memmove(&compositor->sel_buffer[compositor->caret_pos], &compositor->sel_buffer[compositor->caret_pos+1], sizeof(u16)*(compositor->sel_buffer_len-compositor->caret_pos)); compositor->sel_buffer_len--; compositor->sel_buffer[compositor->sel_buffer_len] = 0; } - /* Recomputes the edited text */ + /* Recomputes the edited text */ if (*compositor->edited_text) { gf_free(*compositor->edited_text); *compositor->edited_text = NULL; @@ -108,8 +108,8 @@ static void flush_text_node_edit(GF_Compositor *compositor, Bool final_flush) gf_node_set_private(compositor->focus_highlight->node, NULL); - /* if this is the final flush, we free the selection buffer and edited text buffer - and signal a text content change in the focus node */ + /* if this is the final flush, we free the selection buffer and edited text buffer + and signal a text content change in the focus node */ if (final_flush) { GF_FieldInfo info; if (compositor->sel_buffer) gf_free(compositor->sel_buffer); @@ -122,7 +122,9 @@ static void flush_text_node_edit(GF_Compositor *compositor, Bool final_flush) info.fieldIndex = (u32) -1; if (compositor->focus_text_type>=3) { gf_node_get_field(compositor->focus_node, 0, &info); +#ifndef GPAC_DISABLE_VRML gf_node_event_out(compositor->focus_node, 0); +#endif } gf_node_changed(compositor->focus_node, &info); } @@ -338,18 +340,18 @@ static Bool load_text_node(GF_Compositor *compositor, u32 cmd_type) } res = &((GF_DOMText *)child->node)->textContent; } -/* if (1) { - GF_ChildNodeItem *child = ((GF_ParentNode *) compositor->focus_node)->children; - fprintf(stderr, "Dumping text tree:\n"); - while (child) { - switch (gf_node_get_tag(child->node)) { - case TAG_SVG_tbreak: fprintf(stderr, "\ttbreak\n"); break; - case TAG_DOMText: fprintf(stderr, "\ttext: %s\n", ((GF_DOMText *)child->node)->textContent); break; - } - child = child->next; - } - } -*/ + /* if (1) { + GF_ChildNodeItem *child = ((GF_ParentNode *) compositor->focus_node)->children; + fprintf(stderr, "Dumping text tree:\n"); + while (child) { + switch (gf_node_get_tag(child->node)) { + case TAG_SVG_tbreak: fprintf(stderr, "\ttbreak\n"); break; + case TAG_DOMText: fprintf(stderr, "\ttext: %s\n", ((GF_DOMText *)child->node)->textContent); break; + } + child = child->next; + } + } + */ break; } child = child->next; @@ -476,7 +478,7 @@ static void exec_text_input(GF_Compositor *compositor, GF_Event *event) if (compositor->caret_pos+1sel_buffer_len) { if (event->key.flags & GF_KEY_MOD_CTRL) { while ((compositor->caret_pos+1sel_buffer_len) - && (compositor->sel_buffer[compositor->caret_pos] != ' ')) + && (compositor->sel_buffer[compositor->caret_pos] != ' ')) compositor->caret_pos++; } else { compositor->caret_pos++; @@ -542,12 +544,12 @@ static void exec_text_input(GF_Compositor *compositor, GF_Event *event) flush_text_node_edit(compositor, is_end); } -static void fireTermEvent(GF_Compositor * compositor, u32 eventType){ - if (compositor->term){ - GF_Event evt; - memset(&evt, 0, sizeof(GF_Event)); - evt.type = eventType; - gf_term_user_event(compositor->term, &evt); +static void fireTermEvent(GF_Compositor * compositor, u32 eventType) { + if (compositor->term) { + GF_Event evt; + memset(&evt, 0, sizeof(GF_Event)); + evt.type = eventType; + gf_term_user_event(compositor->term, &evt); } } @@ -558,9 +560,9 @@ static Bool hit_node_editable(GF_Compositor *compositor, Bool check_focus_node) #endif u32 tag; GF_Node *text = check_focus_node ? compositor->focus_node : compositor->hit_node; - if (!text){ - fireTermEvent(compositor, GF_EVENT_TEXT_EDITING_END); - return 0; + if (!text) { + fireTermEvent(compositor, GF_EVENT_TEXT_EDITING_END); + return 0; } if (compositor->hit_node==compositor->focus_node) return compositor->focus_text_type ? 1 : 0; @@ -569,9 +571,9 @@ static Bool hit_node_editable(GF_Compositor *compositor, Bool check_focus_node) #ifndef GPAC_DISABLE_VRML if ( (tag==TAG_MPEG4_Text) #ifndef GPAC_DISABLE_X3D - || (tag==TAG_X3D_Text) + || (tag==TAG_X3D_Text) #endif - ) { + ) { M_FontStyle *fs = (M_FontStyle *) ((M_Text *)text)->fontStyle; if (!fs || !fs->style.buffer) return 0; if (strstr(fs->style.buffer, "editable") || strstr(fs->style.buffer, "EDITABLE")) { @@ -654,8 +656,8 @@ static Bool exec_event_dom(GF_Compositor *compositor, GF_Event *event) cursor_type = GF_CURSOR_NORMAL; /*all mouse events*/ if ((event->type<=GF_EVENT_MOUSEWHEEL) - // && (gf_node_get_dom_event_filter(gf_sg_get_root_node(compositor->scene)) & GF_DOM_EVENT_MOUSE) - ) { + // && (gf_node_get_dom_event_filter(gf_sg_get_root_node(compositor->scene)) & GF_DOM_EVENT_MOUSE) + ) { Fixed X = compositor->hit_world_point.x; Fixed Y = compositor->hit_world_point.y; /*flip back to origin at top-left*/ @@ -726,11 +728,11 @@ static Bool exec_event_dom(GF_Compositor *compositor, GF_Event *event) evt.button = event->mouse.button; evt.detail = compositor->num_clicks; ret += gf_dom_event_fire_ex(compositor->grab_node, &evt, compositor->hit_use_stack); -/* -TODO quick- fix for iPhone as well -TODO clean: figure out whether we use a mouse or a touch device - if touch device, remove this test -*/ -#if !defined(_WIN32_WCE) || !defined(GPAC_ANDROID) + /* + TODO quick- fix for iPhone as well + TODO clean: figure out whether we use a mouse or a touch device - if touch device, remove this test + */ +#if !defined(_WIN32_WCE) || !defined(GPAC_ANDROID) if ((compositor->grab_x == X) && (compositor->grab_y == Y)) #endif { @@ -796,7 +798,7 @@ TODO clean: figure out whether we use a mouse or a touch device - if touch devic evt.detail = event->key.key_code; evt.key_hw_code = event->key.hw_code; target = compositor->focus_node; - + /*dirty hack to simulate browserback*/ if (event->key.key_code==GF_KEY_BACKSPACE && (event->key.flags & GF_KEY_MOD_CTRL)) { event->key.key_code = GF_KEY_BROWSERBACK; @@ -823,7 +825,7 @@ TODO clean: figure out whether we use a mouse or a touch device - if touch devic case '\r': case '\n': case '\t': - //case '\b': + //case '\b': break; default: memset(&evt, 0, sizeof(GF_DOM_Event)); @@ -905,14 +907,14 @@ Bool gf_sc_exec_event_vrml(GF_Compositor *compositor, GF_Event *ev) keynav = gf_scene_get_keynav(gf_node_get_graph(hs->sensor), hs->sensor); if (keynav) gf_sc_change_key_navigator(compositor, keynav); - /*call the sensor LAST, as this may triger a destroy of the scene the sensor is in + /*call the sensor LAST, as this may triger a destroy of the scene the sensor is in this is only true for anchors, as other other sensors output events are queued as routes untill next pass*/ res += hs->OnUserEvent(hs, 1, 0, ev, compositor); if ((stype == TAG_MPEG4_Anchor) #ifndef GPAC_DISABLE_X3D - || (stype == TAG_X3D_Anchor) + || (stype == TAG_X3D_Anchor) #endif - ) { + ) { /*subscene with active sensor has been deleted, we cannot continue process the sensors stack*/ if (count != gf_list_count(compositor->sensors)) break; @@ -979,7 +981,9 @@ Bool gf_sc_exec_event_vrml(GF_Compositor *compositor, GF_Event *ev) break; #endif - default: stype = GF_CURSOR_NORMAL; break; + default: + stype = GF_CURSOR_NORMAL; + break; } if ((stype != GF_CURSOR_NORMAL) || (compositor->sensor_type != stype)) { GF_Event evt; @@ -1161,11 +1165,20 @@ u32 gf_sc_svg_focus_navigate(GF_Compositor *compositor, u32 key_code) n=NULL; gf_svg_flatten_attributes((SVG_Element *)compositor->focus_node, &atts); switch (key_code) { - case GF_KEY_LEFT: focus = atts.nav_left; break; - case GF_KEY_RIGHT: focus = atts.nav_right; break; - case GF_KEY_UP: focus = atts.nav_up; break; - case GF_KEY_DOWN: focus = atts.nav_down; break; - default: return 0; + case GF_KEY_LEFT: + focus = atts.nav_left; + break; + case GF_KEY_RIGHT: + focus = atts.nav_right; + break; + case GF_KEY_UP: + focus = atts.nav_up; + break; + case GF_KEY_DOWN: + focus = atts.nav_down; + break; + default: + return 0; } if (!focus) return 0; @@ -1260,7 +1273,7 @@ static Bool is_focus_target(GF_Node *elt) gf_node_set_cyclic_traverse_flag(elt, 0);\ return NULL; \ } \ - + #ifndef GPAC_DISABLE_SVG static void rebuild_focus_ancestor(GF_Compositor *compositor, GF_Node *elt) { @@ -1353,7 +1366,7 @@ test_grouping: #ifndef GPAC_DISABLE_X3D case TAG_X3D_Switch: #endif - { + { s32 i, wc; GF_ChildNodeItem *child; #ifndef GPAC_DISABLE_X3D @@ -1412,7 +1425,7 @@ test_grouping: return elt; } } - break; + break; case TAG_ProtoNode: /*hardcoded proto acting as a grouping node*/ @@ -1687,7 +1700,8 @@ static GF_Node *browse_parent_for_focus(GF_Compositor *compositor, GF_Node *elt, case TAG_X3D_Collision: case TAG_X3D_LOD: #endif - case TAG_MPEG4_CompositeTexture2D: case TAG_MPEG4_CompositeTexture3D: + case TAG_MPEG4_CompositeTexture2D: + case TAG_MPEG4_CompositeTexture3D: child = ((GF_ParentNode*)par)->children; break; case TAG_ProtoNode: @@ -1695,8 +1709,8 @@ static GF_Node *browse_parent_for_focus(GF_Compositor *compositor, GF_Node *elt, if (gf_node_proto_is_grouping(par)) { GF_FieldInfo info; if ((gf_node_get_field_by_name(par, "children", &info) == GF_OK) - && (info.fieldType == GF_SG_VRML_MFNODE) - ) { + && (info.fieldType == GF_SG_VRML_MFNODE) + ) { child = *(GF_ChildNodeItem **) info.far_ptr; break; } @@ -1916,10 +1930,18 @@ Bool gf_sc_execute_event(GF_Compositor *compositor, GF_TraverseState *tr_state, GF_Node *next_nav = NULL; #ifndef GPAC_DISABLE_VRML switch (ev->key.key_code) { - case GF_KEY_UP: next_nav = ((M_KeyNavigator*)compositor->keynav_node)->up; break; - case GF_KEY_DOWN: next_nav = ((M_KeyNavigator*)compositor->keynav_node)->down; break; - case GF_KEY_LEFT: next_nav = ((M_KeyNavigator*)compositor->keynav_node)->left; break; - case GF_KEY_RIGHT: next_nav = ((M_KeyNavigator*)compositor->keynav_node)->right; break; + case GF_KEY_UP: + next_nav = ((M_KeyNavigator*)compositor->keynav_node)->up; + break; + case GF_KEY_DOWN: + next_nav = ((M_KeyNavigator*)compositor->keynav_node)->down; + break; + case GF_KEY_LEFT: + next_nav = ((M_KeyNavigator*)compositor->keynav_node)->left; + break; + case GF_KEY_RIGHT: + next_nav = ((M_KeyNavigator*)compositor->keynav_node)->right; + break; } #endif if (next_nav) { @@ -1975,13 +1997,13 @@ Bool gf_sc_exec_event(GF_Compositor *compositor, GF_Event *evt) } /*process regular events except if navigation is grabbed*/ - if ( (compositor->navigation_state<2) && (compositor->interaction_level & GF_INTERACT_NORMAL)) { - Bool res; - res = gf_sc_execute_event(compositor, compositor->traverse_state, evt, NULL); - if (res) { - compositor->navigation_state = 0; - ret = 1; - } + if ( (compositor->navigation_state<2) && (compositor->interaction_level & GF_INTERACT_NORMAL)) { + Bool res; + res = gf_sc_execute_event(compositor, compositor->traverse_state, evt, NULL); + if (res) { + compositor->navigation_state = 0; + ret = 1; + } } if (switch_coords) { evt->mouse.x = x; @@ -2002,9 +2024,9 @@ Bool gf_sc_exec_event(GF_Compositor *compositor, GF_Event *evt) return ret; } -#ifndef GPAC_DISABLE_VRML void gf_sc_change_key_navigator(GF_Compositor *sr, GF_Node *n) { +#ifndef GPAC_DISABLE_VRML GF_Node *par; M_KeyNavigator *kn; @@ -2026,8 +2048,8 @@ void gf_sc_change_key_navigator(GF_Compositor *sr, GF_Node *n) if (par) par = gf_node_get_parent(par, 0); gf_sc_focus_switch_ring(sr, 0, par, 1); -} #endif +} void gf_sc_key_navigator_del(GF_Compositor *sr, GF_Node *n) { diff --git a/src/compositor/font_engine.c b/src/compositor/font_engine.c index cbd1489..455eeed 100644 --- a/src/compositor/font_engine.c +++ b/src/compositor/font_engine.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK - * - * Authors: Jean Le Feuvre + * + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -167,7 +167,7 @@ GF_Err gf_font_manager_register_font(GF_FontManager *fm, GF_Font *font) GF_Err gf_font_manager_unregister_font(GF_FontManager *fm, GF_Font *font) { GF_Font *prev_font, *a_font; - + prev_font = NULL; a_font = fm->font; while (a_font) { @@ -211,15 +211,15 @@ GF_Font *gf_font_manager_set_font_ex(GF_FontManager *fm, char **alt_fonts, u32 n if (opt) font_name = (char*)opt; } else if (!stricmp(font_name, "TYPEWRITER") || !stricmp(font_name, "monospace")) { - opt = gf_modules_get_option((GF_BaseInterface *)fm->reader, "FontEngine", "FontFixed"); - if (opt) font_name = (char*)opt; + opt = gf_modules_get_option((GF_BaseInterface *)fm->reader, "FontEngine", "FontFixed"); + if (opt) font_name = (char*)opt; } while (font) { if (fm->wait_font_load && font->not_loaded && !check_only && !stricmp(font->name, font_name)) { GF_Font *a_font = NULL; if (font->get_alias) a_font = font->get_alias(font->udta); - if (!a_font || a_font->not_loaded) + if (!a_font || a_font->not_loaded) return font; } if ((check_only || !font->not_loaded) && font->name && !stricmp(font->name, font_name)) { @@ -230,7 +230,7 @@ GF_Font *gf_font_manager_set_font_ex(GF_FontManager *fm, char **alt_fonts, u32 n Bool ft_has_weight; if (check_only) return font; - + ft_has_weight = (font->styles & GF_FONT_WEIGHT_MASK) ? 1 : 0; if (font->styles == styles) { the_font = font; @@ -288,7 +288,7 @@ GF_Font *gf_font_manager_set_font_ex(GF_FontManager *fm, char **alt_fonts, u32 n fm->reader->get_font_info(fm->reader, &the_font->name, &the_font->em_size, &the_font->ascent, &the_font->descent, &the_font->underline, &the_font->line_spacing, &the_font->max_advance_h, &the_font->max_advance_v); the_font->styles = styles; if (!the_font->name) the_font->name = gf_strdup(font_name); - + if (fm->font) { font = fm->font; while (font->next) font = font->next; @@ -317,7 +317,7 @@ GF_Font *gf_font_manager_set_font_ex(GF_FontManager *fm, char **alt_fonts, u32 n the_font = fm->default_font; } /*embeded font*/ - if (the_font && !the_font->get_glyphs) + if (the_font && !the_font->get_glyphs) fm->reader->set_font(fm->reader, the_font->name, the_font->styles); return the_font; @@ -363,7 +363,7 @@ static GF_Glyph *gf_font_get_glyph(GF_FontManager *fm, GF_Font *font, u32 name) glyph = font->load_glyph(font->udta, name); } else { if (!fm->reader) return NULL; - // fm->reader->set_font(fm->reader, font->name, font->styles); + // fm->reader->set_font(fm->reader, font->name, font->styles); glyph = fm->reader->load_glyph(fm->reader, name); } } @@ -405,7 +405,7 @@ GF_TextSpan *gf_font_manager_create_span(GF_FontManager *fm, GF_Font *font, char fm->id_buffer_size = len; fm->id_buffer = gf_realloc(fm->id_buffer, sizeof(u32) * len); if (!fm->id_buffer) return NULL; - + if (font->get_glyphs) e = font->get_glyphs(font->udta, text, fm->id_buffer, &len, xml_lang, &is_rtl); else @@ -416,7 +416,7 @@ GF_TextSpan *gf_font_manager_create_span(GF_FontManager *fm, GF_Font *font, char GF_SAFEALLOC(span, GF_TextSpan); span->font = font; span->font_size = font_size; - if (font->em_size) + if (font->em_size) span->font_scale = font_size / font->em_size; span->x_scale = span->y_scale = FIX_ONE; // span->lang = xml_lang; @@ -436,12 +436,12 @@ GF_TextSpan *gf_font_manager_create_span(GF_FontManager *fm, GF_Font *font, char span->rot = gf_malloc(sizeof(Fixed)*len); memset(span->rot, 0, sizeof(Fixed)*len); } - + for (i=0; iglyphs[i] = gf_font_get_glyph(fm, font, fm->id_buffer[i]); } span->user = user; - if (span->font->spans) + if (span->font->spans) gf_list_add(font->spans, span); if (is_rtl) span->flags |= GF_TEXT_SPAN_RIGHT_TO_LEFT; return span; @@ -449,7 +449,7 @@ GF_TextSpan *gf_font_manager_create_span(GF_FontManager *fm, GF_Font *font, char -typedef struct _span_internal +typedef struct _span_internal { /*zoom when texture was computed*/ Fixed last_zoom; @@ -528,7 +528,7 @@ void gf_font_manager_refresh_span_bounds(GF_TextSpan *span) } span->bounds = gf_rect_center(0, 0); - for (i=0;inb_glyphs; i++) { + for (i=0; inb_glyphs; i++) { Fixed g_width; GF_Rect rc; @@ -542,7 +542,7 @@ void gf_font_manager_refresh_span_bounds(GF_TextSpan *span) if (span->dy) { if (span->dy[i] - descent < min_y) min_y = span->dy[i] - descent; if (span->dy[i] + ascent > max_y) max_y = span->dy[i] + ascent; - } + } else if (span->glyphs[i]) { Fixed size = span->glyphs[i]->height * span->font_scale; if (size > max_y-min_y) max_y = size + min_y; @@ -694,7 +694,7 @@ static Bool span_setup_texture(GF_Compositor *compositor, GF_TextSpan *span, Boo } if ((gf_mulfix(scale, bounds.width)>max) || (gf_mulfix(scale, bounds.height)>max)) { scale = MIN(gf_divfix(max, bounds.width), gf_divfix(max, bounds.height)); - } + } else if ((gf_mulfix(scale, bounds.width)stencil_new(raster, GF_STENCIL_SOLID); raster->stencil_set_brush_color(brush, 0xFF000000); - cx = bounds.x + bounds.width/2; + cx = bounds.x + bounds.width/2; cy = bounds.y - bounds.height/2; gf_mx2d_init(mx); @@ -865,7 +865,7 @@ void gf_font_spans_draw_3d(GF_List *spans, GF_TraverseState *tr_state, DrawAspec if (text_hl && (fill_2d || !asp) ) { /*reverse video: highlighting uses the text color, and text color is inverted (except alpha channel) - the ideal impl would be to use the background color for the text, but since the text may be + the ideal impl would be to use the background color for the text, but since the text may be displayed over anything non uniform this would require clipping the highlight rect with the text which is too onerous (and not supported anyway) */ if (text_hl == 0x00FFFFFF) { @@ -883,7 +883,7 @@ void gf_font_spans_draw_3d(GF_List *spans, GF_TraverseState *tr_state, DrawAspec ((M_Material *) ((M_Appearance *) tr_state->appear)->material)->diffuseColor = rc; visual_3d_setup_appearance(tr_state); ((M_Material *) ((M_Appearance *) tr_state->appear)->material)->diffuseColor = c; - } else + } else #endif /*GPAC_DISABLE_VRML*/ { hl_color.red = hl_color.green = hl_color.blue = 0; @@ -932,7 +932,8 @@ void gf_font_spans_draw_3d(GF_List *spans, GF_TraverseState *tr_state, DrawAspec while ((span = (GF_TextSpan *)gf_list_enum(spans, &i))) { if (text_hl) { visual_3d_fill_rect(tr_state->visual, span->bounds, hl_color); - if (fill_2d) + + if (fill_2d) visual_3d_set_material_2d_argb(tr_state->visual, asp->fill_color); else visual_3d_setup_appearance(tr_state); @@ -1068,7 +1069,7 @@ void gf_font_underline_span(GF_TraverseState *tr_state, GF_TextSpan *span, Drawa gf_mx2d_copy(mx, ctx->transform); sx = gf_mulfix(span->font_scale, span->x_scale); diff = span->font_scale * span->font->underline; - if (span->flags & GF_TEXT_SPAN_FLIP) + if (span->flags & GF_TEXT_SPAN_FLIP) diff = sx * (span->font->descent - span->font->underline); else diff = sx * (- span->font->ascent + span->font->underline); @@ -1092,7 +1093,7 @@ void gf_font_underline_span(GF_TraverseState *tr_state, GF_TextSpan *span, Drawa } #if 0 -static u32 col_reverse_video(u32 col) +static u32 col_reverse_video(u32 col) { u32 a, r, g, b; a = GF_COL_A(col); @@ -1108,7 +1109,7 @@ static GF_Rect font_get_sel_rect(GF_TraverseState *tr_state) GF_Vec s, e; GF_Rect rc; GF_Compositor *compositor = tr_state->visual->compositor; - + e.x = compositor->end_sel.x; e.y = compositor->end_sel.y; e.z = 0; @@ -1172,7 +1173,7 @@ static void gf_font_spans_select(GF_TextSpan *span, GF_TraverseState *tr_state, } color = compositor->text_sel_color; - + for (i=0; inb_glyphs; i++) { GF_Rect g_rc; Bool end_of_line = 0; @@ -1184,7 +1185,7 @@ static void gf_font_spans_select(GF_TextSpan *span, GF_TraverseState *tr_state, if (dx + advance/2 < rc->x) { dx += advance; continue; - } + } g_rc.height = ascent-descent; @@ -1227,12 +1228,12 @@ static void gf_font_spans_select(GF_TextSpan *span, GF_TraverseState *tr_state, if (!end_of_line && !gf_rect_overlaps(g_rc, *rc)) continue; -/* - if (dy < rc.y-rc.height) { - if (!span->dx) break; - continue; - } -*/ + /* + if (dy < rc.y-rc.height) { + if (!span->dx) break; + continue; + } + */ has_selection = 1; if (ctx) { g_rc.width+=2; @@ -1287,7 +1288,7 @@ void gf_font_spans_draw_2d(GF_List *spans, GF_TraverseState *tr_state, u32 hl_co GF_TextSpan *span; DrawableContext *ctx = tr_state->ctx; GF_Rect rc; - + use_texture_text = 0; if (force_texture_text || (compositor->texture_text_mode==GF_TEXTURE_TEXT_ALWAYS) ) { use_texture_text = !ctx->aspect.fill_texture && !ctx->aspect.pen_props.width; @@ -1296,13 +1297,13 @@ void gf_font_spans_draw_2d(GF_List *spans, GF_TraverseState *tr_state, u32 hl_co is_rv = 0; if (hl_color) { /*reverse video: highlighting uses the text color, and text color is inverted (except alpha channel) - the ideal impl would be to use the background color for the text, but since the text may be + the ideal impl would be to use the background color for the text, but since the text may be displayed over anything non uniform this would require clipping the highlight rect with the text which is too onerous (and not supported anyway) */ if (hl_color==0x00FFFFFF) { u32 a, r, g, b; hl_color = tr_state->ctx->aspect.fill_color; - + a = GF_COL_A(tr_state->ctx->aspect.fill_color); if (a) { r = GF_COL_R(tr_state->ctx->aspect.fill_color); @@ -1317,11 +1318,11 @@ void gf_font_spans_draw_2d(GF_List *spans, GF_TraverseState *tr_state, u32 hl_co count = gf_list_count(spans); i=ctx->sub_path_index ? ctx->sub_path_index-1 : 0; - for(;itext_selection) gf_font_spans_select(span, tr_state, ctx, (i+1visual, ctx, &span->bounds, hl_color, 0, tr_state); if (use_texture_text && span_setup_texture(compositor, span, 0, tr_state)) { @@ -1352,7 +1353,7 @@ void gf_font_spans_pick(GF_Node *node, GF_List *spans, GF_TraverseState *tr_stat if (compositor->text_selection != tr_state->text_parent) return; if (compositor->store_text_state==GF_SC_TSEL_FROZEN) return; } - + /*TODO: pick the real glyph and not just the bounds of the text span*/ count = gf_list_count(spans); @@ -1370,7 +1371,7 @@ void gf_font_spans_pick(GF_Node *node, GF_List *spans, GF_TraverseState *tr_stat x = local_pt.x; y = local_pt.y; - } else + } else #endif { gf_mx2d_copy(inv_2d, tr_state->transform); @@ -1392,9 +1393,9 @@ void gf_font_spans_pick(GF_Node *node, GF_List *spans, GF_TraverseState *tr_stat span = (GF_TextSpan*)gf_list_get(spans, i); if ((x>=span->bounds.x) - && (y<=span->bounds.y) - && (x<=span->bounds.x+span->bounds.width) - && (y>=span->bounds.y-span->bounds.height)) { + && (y<=span->bounds.y) + && (x<=span->bounds.x+span->bounds.width) + && (y>=span->bounds.y-span->bounds.height)) { } else { continue; } @@ -1461,7 +1462,7 @@ picked: if (tr_state->visual->type_3d) { gf_mx_copy(compositor->hit_world_to_local, tr_state->model_matrix); gf_mx_copy(compositor->hit_local_to_world, inv_mx); - } else + } else #endif { gf_mx_from_mx2d(&compositor->hit_world_to_local, &tr_state->transform); @@ -1485,14 +1486,15 @@ picked: compositor->hit_text = tr_state->text_parent; compositor->hit_use_dom_events = use_dom_events; - compositor->hit_normal.x = compositor->hit_normal.y = 0; compositor->hit_normal.z = FIX_ONE; + compositor->hit_normal.x = compositor->hit_normal.y = 0; + compositor->hit_normal.z = FIX_ONE; compositor->hit_texcoords.x = gf_divfix(x, node_bounds->width) + FIX_ONE/2; compositor->hit_texcoords.y = gf_divfix(y, node_bounds->height) + FIX_ONE/2; #ifndef GPAC_DISABLE_VRML if (compositor_is_composite_texture(tr_state->appear)) { compositor->hit_appear = tr_state->appear; - } else + } else #endif /*GPAC_DISABLE_VRML*/ { compositor->hit_appear = NULL; diff --git a/src/compositor/gl_inc.h b/src/compositor/gl_inc.h index 020dffd..3371f75 100644 --- a/src/compositor/gl_inc.h +++ b/src/compositor/gl_inc.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -100,7 +100,7 @@ #define GLDECL(ret, funname, args) \ typedef ret (GLAPICAST proc_ ## funname)args; \ extern proc_ ## funname funname; \ - + #define GLDECL_STATIC(funname) proc_ ## funname funname = NULL #if defined GPAC_USE_TINYGL @@ -109,18 +109,18 @@ extern proc_ ## funname funname; \ //no extensions with OpenGL ES #elif defined(WIN32) || defined (GPAC_CONFIG_WIN32) #define LOAD_GL_FUNCS -#define GET_GLFUN(funname) funname = (proc_ ## funname) wglGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) wglGetProcAddress(#funname) #elif defined(CONFIG_DARWIN_GL) extern void (*glutGetProcAddress(const GLubyte *procname))( void ); -#define GET_GLFUN(funname) funname = (proc_ ## funname) glutGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) glutGetProcAddress(#funname) #else #define LOAD_GL_FUNCS extern void (*glXGetProcAddress(const GLubyte *procname))( void ); -#define GET_GLFUN(funname) funname = (proc_ ## funname) glXGetProcAddress(#funname) +#define GET_GLFUN(funname) funname = (proc_ ## funname) glXGetProcAddress(#funname) #endif -#if !defined(GPAC_USE_OGL_ES) +#if !defined(GPAC_USE_OGL_ES) /*redefine all ext needed*/ @@ -174,6 +174,9 @@ extern void (*glXGetProcAddress(const GLubyte *procname))( void ); #define GL_DISTANCE_ATTENUATION_EXT 0x8129 #endif +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif #ifndef GL_VERSION_1_3 diff --git a/src/compositor/hardcoded_protos.c b/src/compositor/hardcoded_protos.c index 7b36591..984309a 100644 --- a/src/compositor/hardcoded_protos.c +++ b/src/compositor/hardcoded_protos.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,14 +40,14 @@ typedef struct { - GF_Node *geometry; - MFVec3f *spine; - Bool beginCap; - Bool endCap; - Fixed creaseAngle; - MFRotation *orientation; - MFVec2f *scale; - Bool txAlongSpine; + GF_Node *geometry; + MFVec3f *spine; + Bool beginCap; + Bool endCap; + Fixed creaseAngle; + MFRotation *orientation; + MFVec2f *scale; + Bool txAlongSpine; } PathExtrusion; static Bool PathExtrusion_GetNode(GF_Node *node, PathExtrusion *path_ext) @@ -87,7 +87,7 @@ static void TraversePathExtrusion(GF_Node *node, void *rs, Bool is_destroy) Drawable *stack_2d; GF_TraverseState *tr_state = (GF_TraverseState *)rs; Drawable3D *stack = (Drawable3D *)gf_node_get_private(node); - + if (is_destroy) { drawable_3d_del(node); return; @@ -138,16 +138,16 @@ static void compositor_init_path_extrusion(GF_Compositor *compositor, GF_Node *n /*PlanarExtrusion hardcoded proto*/ typedef struct { - GF_Node *geometry; - GF_Node *spine; - Bool beginCap; - Bool endCap; - Fixed creaseAngle; + GF_Node *geometry; + GF_Node *spine; + Bool beginCap; + Bool endCap; + Fixed creaseAngle; MFFloat *orientationKeys; - MFRotation *orientation; + MFRotation *orientation; MFFloat *scaleKeys; - MFVec2f *scale; - Bool txAlongSpine; + MFVec2f *scale; + Bool txAlongSpine; } PlanarExtrusion; static Bool PlanarExtrusion_GetNode(GF_Node *node, PlanarExtrusion *path_ext) @@ -259,7 +259,7 @@ static void TraversePlanarExtrusion(GF_Node *node, void *rs, Bool is_destroy) for (i=0; in_contours; i++) { nb_pts = 1 + spine->contours[i] - cur; spine_vec.vals = NULL; - gf_sg_vrml_mf_alloc(&spine_vec, GF_SG_VRML_MFVEC3F, nb_pts); + gf_sg_vrml_mf_alloc(&spine_vec, GF_SG_VRML_MFVEC3F, nb_pts); spine_len = 0; for (j=cur; jpoints[j].x; @@ -272,9 +272,9 @@ static void TraversePlanarExtrusion(GF_Node *node, void *rs, Bool is_destroy) } cur += nb_pts; if (!plane_ext.orientation->count && !plane_ext.scale->count) { - mesh_extrude_path_ext(stack->mesh, geo, &spine_vec, plane_ext.creaseAngle, - bounds.x, bounds.y-bounds.height, bounds.width, bounds.height, - plane_ext.beginCap, plane_ext.endCap, NULL, NULL, plane_ext.txAlongSpine); + mesh_extrude_path_ext(stack->mesh, geo, &spine_vec, plane_ext.creaseAngle, + bounds.x, bounds.y-bounds.height, bounds.width, bounds.height, + plane_ext.beginCap, plane_ext.endCap, NULL, NULL, plane_ext.txAlongSpine); } /*interpolate orientation and scale along subpath line*/ else { @@ -306,8 +306,8 @@ static void TraversePlanarExtrusion(GF_Node *node, void *rs, Bool is_destroy) for (k=1; kcount; k++) { Fixed kDiff = plane_ext.orientationKeys->vals[k] - plane_ext.orientationKeys->vals[k-1]; if (!kDiff) continue; - if (frac < plane_ext.orientationKeys->vals[k-1]) continue; - if (frac > plane_ext.orientationKeys->vals[k]) continue; + if (frac < plane_ext.orientationKeys->vals[k-1]) continue; + if (frac > plane_ext.orientationKeys->vals[k]) continue; frac = gf_divfix(frac - plane_ext.orientationKeys->vals[k-1], kDiff); break; } @@ -323,8 +323,8 @@ static void TraversePlanarExtrusion(GF_Node *node, void *rs, Bool is_destroy) for (k=1; kcount; k++) { Fixed kDiff = plane_ext.scaleKeys->vals[k] - plane_ext.scaleKeys->vals[k-1]; if (!kDiff) continue; - if (frac < plane_ext.scaleKeys->vals[k-1]) continue; - if (frac > plane_ext.scaleKeys->vals[k]) continue; + if (frac < plane_ext.scaleKeys->vals[k-1]) continue; + if (frac > plane_ext.scaleKeys->vals[k]) continue; frac = gf_divfix(frac - plane_ext.scaleKeys->vals[k-1], kDiff); break; } @@ -334,9 +334,9 @@ static void TraversePlanarExtrusion(GF_Node *node, void *rs, Bool is_destroy) } } - mesh_extrude_path_ext(stack->mesh, geo, &spine_vec, plane_ext.creaseAngle, - bounds.x, bounds.y-bounds.height, bounds.width, bounds.height, - plane_ext.beginCap, plane_ext.endCap, &ori, &scale, plane_ext.txAlongSpine); + mesh_extrude_path_ext(stack->mesh, geo, &spine_vec, plane_ext.creaseAngle, + bounds.x, bounds.y-bounds.height, bounds.width, bounds.height, + plane_ext.beginCap, plane_ext.endCap, &ori, &scale, plane_ext.txAlongSpine); gf_sg_vrml_mf_reset(&ori, GF_SG_VRML_MFROTATION); gf_sg_vrml_mf_reset(&scale, GF_SG_VRML_MFVEC2F); @@ -367,7 +367,7 @@ typedef struct BASE_NODE CHILDREN - GF_Plane plane; + GF_Plane plane; } PlaneClipper; typedef struct @@ -415,7 +415,9 @@ static void TraversePlaneClipper(GF_Node *node, void *rs, Bool is_destroy) } if (tr_state->traversing_mode == TRAVERSE_SORT) { - visual_3d_set_clip_plane(tr_state->visual, stack->pc.plane); + GF_Matrix mx; + gf_mx_copy(mx, tr_state->model_matrix); + visual_3d_set_clip_plane(tr_state->visual, stack->pc.plane, &mx, 0); tr_state->num_clip_planes++; group_3d_traverse((GF_Node*)&stack->pc, (GroupingNode*)stack, tr_state); @@ -425,9 +427,9 @@ static void TraversePlaneClipper(GF_Node *node, void *rs, Bool is_destroy) tr_state->clip_planes[tr_state->num_clip_planes] = stack->pc.plane; gf_mx_apply_plane(&tr_state->model_matrix, &tr_state->clip_planes[tr_state->num_clip_planes]); tr_state->num_clip_planes++; - + group_3d_traverse((GF_Node*)&stack->pc, (GroupingNode*)stack, tr_state); - + tr_state->num_clip_planes--; } @@ -533,7 +535,7 @@ static void TraverseOffscreenGroup(GF_Node *node, void *rs, Bool is_destroy) tr_state->subscene_not_over = 0; group_cache_traverse((GF_Node *)&stack->og, stack->cache, tr_state, stack->cache->force_recompute, 1, stack->detached ? 1 : 0); - + if (gf_node_dirty_get(node)) { gf_node_dirty_clear(node, GF_SG_CHILD_DIRTY); } else if ((stack->og.offscreen==2) && !stack->detached && !tr_state->subscene_not_over && stack->cache->txh.width && stack->cache->txh.height) { @@ -590,7 +592,7 @@ typedef struct BASE_NODE CHILDREN - Fixed depth_gain, depth_offset; + Fixed depth_gain, depth_offset; } DepthGroup; @@ -654,10 +656,10 @@ static void TraverseDepthGroup(GF_Node *node, void *rs, Bool is_destroy) depth_gain = tr_state->depth_gain; depth_offset = tr_state->depth_offset; - // new offset is multiplied by parent gain and added to parent offset + // new offset is multiplied by parent gain and added to parent offset tr_state->depth_offset = gf_mulfix(stack->dg.depth_offset, tr_state->depth_gain) + tr_state->depth_offset; - // gain is multiplied by parent gain + // gain is multiplied by parent gain tr_state->depth_gain = gf_mulfix(tr_state->depth_gain, stack->dg.depth_gain); #endif @@ -669,20 +671,10 @@ static void TraverseDepthGroup(GF_Node *node, void *rs, Bool is_destroy) gf_mx_init(mx); mx.m[14] = gf_mulfix(stack->dg.depth_offset, tr_state->visual->compositor->depth_gl_scale); gf_mx_add_matrix(&tr_state->model_matrix, &mx); - - if (tr_state->traversing_mode == TRAVERSE_SORT) { - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, mx.m); - - group_2d_traverse((GF_Node *)&stack->dg, (GroupingNode2D*)stack, tr_state); - - visual_3d_matrix_pop(tr_state->visual); - } else { - group_2d_traverse((GF_Node *)&stack->dg, (GroupingNode2D*)stack, tr_state); - } + group_2d_traverse((GF_Node *)&stack->dg, (GroupingNode2D*)stack, tr_state); gf_mx_copy(tr_state->model_matrix, mx_bckup); - } else + } else #endif { @@ -690,8 +682,8 @@ static void TraverseDepthGroup(GF_Node *node, void *rs, Bool is_destroy) } #ifdef GF_SR_USE_DEPTH - tr_state->depth_gain = depth_gain; - tr_state->depth_offset = depth_offset; + tr_state->depth_gain = depth_gain; + tr_state->depth_offset = depth_offset; #endif } @@ -706,7 +698,7 @@ void compositor_init_depth_group(GF_Compositor *compositor, GF_Node *node) stack->dg = dg; gf_node_proto_set_grouping(node); } else GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Compositor2D] Unable to initialize depth group \n")); - + } #ifdef GF_SR_USE_DEPTH @@ -756,10 +748,10 @@ typedef struct { BASE_NODE - GF_Node *point; - Fixed fineness; - MFInt32 type; - MFInt32 index; + GF_Node *point; + Fixed fineness; + MFInt32 type; + MFInt32 index; } IndexedCurve2D; static Bool IndexedCurve2D_GetNode(GF_Node *node, IndexedCurve2D *ic2d) @@ -772,7 +764,7 @@ static Bool IndexedCurve2D_GetNode(GF_Node *node, IndexedCurve2D *ic2d) if (gf_node_get_field(node, 0, &field) != GF_OK) return 0; if (field.fieldType != GF_SG_VRML_SFNODE) return 0; ic2d->point = * (GF_Node **) field.far_ptr; - + if (gf_node_get_field(node, 1, &field) != GF_OK) return 0; if (field.fieldType != GF_SG_VRML_SFFLOAT) return 0; ic2d->fineness = *(SFFloat *) field.far_ptr; @@ -796,7 +788,7 @@ static void TraverseIndexedCurve2D(GF_Node *node, void *rs, Bool is_destroy) IndexedCurve2D ic2d; GF_TraverseState *tr_state = (GF_TraverseState *)rs; Drawable *stack = (Drawable *)gf_node_get_private(node); - + if (is_destroy) { drawable_node_del(node); return; @@ -909,22 +901,15 @@ static void TraverseUntransform(GF_Node *node, void *rs, Bool is_destroy) if (tr_state->traversing_mode == TRAVERSE_SORT) { - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->projection.m); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->modelview.m); - visual_3d_set_viewport(tr_state->visual, tr_state->camera->vp); + visual_3d_projection_matrix_modified(tr_state->visual); gf_node_traverse_children((GF_Node *)&stack->untr, tr_state); gf_mx_copy(tr_state->model_matrix, mx_model); memcpy(tr_state->camera, &backup_cam, sizeof(GF_Camera)); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->projection.m); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->modelview.m); + visual_3d_projection_matrix_modified(tr_state->visual); visual_3d_set_viewport(tr_state->visual, tr_state->camera->vp); } else if (tr_state->traversing_mode == TRAVERSE_PICK) { @@ -943,11 +928,11 @@ static void TraverseUntransform(GF_Node *node, void *rs, Bool is_destroy) gf_mx_copy(tr_state->model_matrix, mx_model); memcpy(tr_state->camera, &backup_cam, sizeof(GF_Camera)); tr_state->ray = r; - + /*nothing picked, restore previous pick*/ - if (!tr_state->visual->compositor->hit_square_dist) + if (!tr_state->visual->compositor->hit_square_dist) tr_state->visual->compositor->hit_square_dist = prev_dist; - + } else { gf_node_traverse_children((GF_Node *)&stack->untr, tr_state); @@ -955,7 +940,7 @@ static void TraverseUntransform(GF_Node *node, void *rs, Bool is_destroy) memcpy(tr_state->camera, &backup_cam, sizeof(GF_Camera)); } - } else + } else #endif { GF_Matrix2D mx2d_backup; @@ -1026,7 +1011,7 @@ void compositor_init_hardcoded_proto(GF_Compositor *compositor, GF_Node *node) if (!strcmp(url, "urn:inet:gpac:builtin:DepthViewPoint")) { compositor_init_depth_viewpoint(compositor, node); return; - } + } if (!strcmp(url, "urn:inet:gpac:builtin:IndexedCurve2D")) { compositor_init_idx_curve2d(compositor, node); return; diff --git a/src/compositor/hc_flash_shape.c b/src/compositor/hc_flash_shape.c index 0c9e8fc..ba2fde5 100644 --- a/src/compositor/hc_flash_shape.c +++ b/src/compositor/hc_flash_shape.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -90,7 +90,7 @@ static void build_shape(FSStack *st, GF_Node *node) u32 wi, li, fi, ci, command, i, has_ci; FSItem *fill_item, *line_item; Fixed w; - SFVec2f cur, pt, ct1={0,0}, ct2, *pts; + SFVec2f cur, pt, ct1= {0,0}, ct2, *pts; GF_Rect rc; u32 line_col, fill_col; Bool need_line, need_fill; @@ -127,39 +127,39 @@ static void build_shape(FSStack *st, GF_Node *node) /*implicit commands: 0 1 2 3*/ -/* - if (widthIndex->count) { - w = (widthIndex->vals[wi]==-1) ? 0 : widths->vals[widthIndex->vals[wi]]; - if (!w) { - need_line = 0; - line_item = NULL; - } else { - need_line = 1; - if (st->max_widthmax_width = w; + /* + if (widthIndex->count) { + w = (widthIndex->vals[wi]==-1) ? 0 : widths->vals[widthIndex->vals[wi]]; + if (!w) { + need_line = 0; + line_item = NULL; + } else { + need_line = 1; + if (st->max_widthmax_width = w; + } + wi++; } - wi++; - } - if (lineIndex->count) { - if (w) { - line_col = SFCOL_MAKE_ARGB(colors->vals[lineIndex->vals[li]]); - need_line = 1; + if (lineIndex->count) { + if (w) { + line_col = SFCOL_MAKE_ARGB(colors->vals[lineIndex->vals[li]]); + need_line = 1; + } + li++; } - li++; - } - if (fillIndex->count) { - if (fillIndex->vals[fi]==-1) { - fill_col = 0; - fill_item = NULL; - } else { - fill_col = SFCOL_MAKE_ARGB(colors->vals[fillIndex->vals[fi]]); - need_fill = 1; + if (fillIndex->count) { + if (fillIndex->vals[fi]==-1) { + fill_col = 0; + fill_item = NULL; + } else { + fill_col = SFCOL_MAKE_ARGB(colors->vals[fillIndex->vals[fi]]); + need_fill = 1; + } + fi++; } - fi++; - } - if (!coordIndex->count) return; - cur = coords->vals[coordIndex->vals[ci]]; - ci++; -*/ + if (!coordIndex->count) return; + cur = coords->vals[coordIndex->vals[ci]]; + ci++; + */ for (command=0; commandcount; command++) { switch (com->vals[command]) { @@ -167,7 +167,7 @@ static void build_shape(FSStack *st, GF_Node *node) case 0: if (wi >= widthIndex->count) return; w = (widthIndex->vals[wi]==-1) ? 0 : widths->vals[widthIndex->vals[wi]]; - if (!w) + if (!w) line_item = NULL; else { need_line = 1; @@ -354,7 +354,7 @@ static void build_shape(FSStack *st, GF_Node *node) break; } } - + /*compute bounds*/ st->bounds.width = st->bounds.height = 0; for (i=0; iitems); i++) { @@ -438,7 +438,11 @@ static void fs_traverse(GF_Node *node, void *rs, Bool is_destroy) if (tr_state->visual->type_3d) return; #endif /*finalize*/ +#ifndef GPAC_DISABLE_VRML ctx = drawable_init_context_mpeg4(st->drawable, tr_state); +#else + ctx = NULL; +#endif if (!ctx) return; /*force width to max width used for clipper compute*/ diff --git a/src/compositor/mesh.c b/src/compositor/mesh.c index f9bd6b7..97ae443 100644 --- a/src/compositor/mesh.c +++ b/src/compositor/mesh.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,7 +39,7 @@ #define HIGH_SPEED_RATIO 2 -/*size alloc for meshes doubles memory at each gf_realloc rather than using a fix-size increment +/*size alloc for meshes doubles memory at each gf_realloc rather than using a fix-size increment (this really speeds up large meshes constructing). Final memory usage is adjusted when updating mesh bounds */ #define MESH_CHECK_VERTEX(m) \ @@ -47,13 +47,13 @@ m->v_alloc *= 2; \ m->vertices = (GF_Vertex *)gf_realloc(m->vertices, sizeof(GF_Vertex)*m->v_alloc); \ } \ - + #define MESH_CHECK_IDX(m) \ if (m->i_count == m->i_alloc) { \ m->i_alloc *= 2; \ m->indices = (IDX_TYPE*)gf_realloc(m->indices, sizeof(IDX_TYPE)*m->i_alloc); \ } \ - + static void del_aabb_node(AABBNode *node) @@ -137,8 +137,12 @@ void mesh_update_bounds(GF_Mesh *mesh) if (Myy) My=v->y; if (Mzz) Mz=v->z; } - mesh->bounds.min_edge.x = mx; mesh->bounds.min_edge.y = my; mesh->bounds.min_edge.z = mz; - mesh->bounds.max_edge.x = Mx; mesh->bounds.max_edge.y = My; mesh->bounds.max_edge.z = Mz; + mesh->bounds.min_edge.x = mx; + mesh->bounds.min_edge.y = my; + mesh->bounds.min_edge.z = mz; + mesh->bounds.max_edge.x = Mx; + mesh->bounds.max_edge.y = My; + mesh->bounds.max_edge.z = Mz; gf_bbox_refresh(&mesh->bounds); } @@ -173,11 +177,17 @@ static GFINLINE GF_Vertex set_vertex(Fixed x, Fixed y, Fixed z, Fixed nx, Fixed { SFVec3f nor; GF_Vertex res; - res.pos.x = x; res.pos.y = y; res.pos.z = z; - nor.x = nx; nor.y = ny; nor.z = nz; gf_vec_norm(&nor); + res.pos.x = x; + res.pos.y = y; + res.pos.z = z; + nor.x = nx; + nor.y = ny; + nor.z = nz; + gf_vec_norm(&nor); MESH_SET_NORMAL(res, nor); - res.texcoords.x = u; res.texcoords.y = v; + res.texcoords.x = u; + res.texcoords.y = v; #ifdef MESH_USE_SFCOLOR res.color.blue = res.color.red = res.color.green = res.color.alpha = FIX_ONE; #else @@ -292,42 +302,52 @@ void mesh_new_box(GF_Mesh *mesh, SFVec3f size) mesh_set_vertex(mesh, -hx, -hy, -hz, 0, 0, -FIX_ONE, FIX_ONE, 0); mesh_set_vertex(mesh, -hx, hy, -hz, 0, 0, -FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, hx, hy, -hz, 0, 0, -FIX_ONE, 0, FIX_ONE); - mesh_set_triangle(mesh, 0, 1, 2); mesh_set_triangle(mesh, 0, 2, 3); + mesh_set_triangle(mesh, 0, 1, 2); + mesh_set_triangle(mesh, 0, 2, 3); /*top face*/ mesh_set_vertex(mesh, -hx, hy, hz, 0, FIX_ONE, 0, 0, 0); mesh_set_vertex(mesh, hx, hy, hz, 0, FIX_ONE, 0, FIX_ONE, 0); mesh_set_vertex(mesh, hx, hy, -hz, 0, FIX_ONE, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, -hx, hy, -hz, 0, FIX_ONE, 0, 0, FIX_ONE); - mesh_set_triangle(mesh, 4, 5, 6); mesh_set_triangle(mesh, 4, 6, 7); + mesh_set_triangle(mesh, 4, 5, 6); + mesh_set_triangle(mesh, 4, 6, 7); /*front face*/ mesh_set_vertex(mesh, -hx, -hy, hz, 0, 0, FIX_ONE, 0, 0); mesh_set_vertex(mesh, hx, -hy, hz, 0, 0, FIX_ONE, FIX_ONE, 0); mesh_set_vertex(mesh, hx, hy, hz, 0, 0, FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, -hx, hy, hz, 0, 0, FIX_ONE, 0, FIX_ONE); - mesh_set_triangle(mesh, 8, 9, 10); mesh_set_triangle(mesh, 8, 10, 11); + mesh_set_triangle(mesh, 8, 9, 10); + mesh_set_triangle(mesh, 8, 10, 11); /*left face*/ mesh_set_vertex(mesh, -hx, -hy, -hz, -FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(mesh, -hx, -hy, hz, -FIX_ONE, 0, 0, FIX_ONE, 0); mesh_set_vertex(mesh, -hx, hy, hz, -FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, -hx, hy, -hz, -FIX_ONE, 0, 0, 0, FIX_ONE); - mesh_set_triangle(mesh, 12, 13, 14); mesh_set_triangle(mesh, 12, 14, 15); + mesh_set_triangle(mesh, 12, 13, 14); + mesh_set_triangle(mesh, 12, 14, 15); /*bottom face*/ mesh_set_vertex(mesh, -hx, -hy, -hz, 0, -FIX_ONE, 0, 0, 0); mesh_set_vertex(mesh, hx, -hy, -hz, 0, -FIX_ONE, 0, FIX_ONE, 0); mesh_set_vertex(mesh, hx, -hy, hz, 0, -FIX_ONE, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, -hx, -hy, hz, 0, -FIX_ONE, 0, 0, FIX_ONE); - mesh_set_triangle(mesh, 16, 17, 18); mesh_set_triangle(mesh, 16, 18, 19); + mesh_set_triangle(mesh, 16, 17, 18); + mesh_set_triangle(mesh, 16, 18, 19); /*right face*/ mesh_set_vertex(mesh, hx, -hy, hz, FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(mesh, hx, -hy, -hz, FIX_ONE, 0, 0, FIX_ONE, 0); mesh_set_vertex(mesh, hx, hy, -hz, FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(mesh, hx, hy, hz, FIX_ONE, 0, 0, 0, FIX_ONE); - mesh_set_triangle(mesh, 20, 21, 22); mesh_set_triangle(mesh, 20, 22, 23); + mesh_set_triangle(mesh, 20, 21, 22); + mesh_set_triangle(mesh, 20, 22, 23); - mesh->flags |= MESH_IS_SOLID; - mesh->bounds.min_edge.x = -hx; mesh->bounds.min_edge.y = -hy; mesh->bounds.min_edge.z = -hz; - mesh->bounds.max_edge.x = hx; mesh->bounds.max_edge.y = hy; mesh->bounds.max_edge.z = hz; + mesh->flags |= MESH_IS_SOLID; + mesh->bounds.min_edge.x = -hx; + mesh->bounds.min_edge.y = -hy; + mesh->bounds.min_edge.z = -hz; + mesh->bounds.max_edge.x = hx; + mesh->bounds.max_edge.y = hy; + mesh->bounds.max_edge.z = hz; gf_bbox_refresh(&mesh->bounds); gf_mesh_build_aabbtree(mesh); } @@ -350,11 +370,17 @@ void mesh_new_unit_bbox(GF_Mesh *mesh) mesh_set_point(mesh, s, s, s, col); mesh_set_point(mesh, -s, s, s, col); - mesh_set_line(mesh, 0, 1); mesh_set_line(mesh, 1, 2); mesh_set_line(mesh, 2, 3); mesh_set_line(mesh, 3, 0); - mesh_set_line(mesh, 4, 5); mesh_set_line(mesh, 5, 6); mesh_set_line(mesh, 6, 7); mesh_set_line(mesh, 7, 4); - mesh_set_line(mesh, 0, 4); - mesh_set_line(mesh, 1, 5); - mesh_set_line(mesh, 2, 6); + mesh_set_line(mesh, 0, 1); + mesh_set_line(mesh, 1, 2); + mesh_set_line(mesh, 2, 3); + mesh_set_line(mesh, 3, 0); + mesh_set_line(mesh, 4, 5); + mesh_set_line(mesh, 5, 6); + mesh_set_line(mesh, 6, 7); + mesh_set_line(mesh, 7, 4); + mesh_set_line(mesh, 0, 4); + mesh_set_line(mesh, 1, 5); + mesh_set_line(mesh, 2, 6); mesh_set_line(mesh, 3, 7); gf_bbox_refresh(&mesh->bounds); } @@ -397,34 +423,34 @@ void mesh_new_cylinder(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, B for (i=0; iv_count-4, mesh->v_count-1, mesh->v_count-3); - mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-2, mesh->v_count-1); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-2, mesh->v_count-1); } } /*top*/ mesh_set_vertex(mesh, coords[0].x, coords[0].y, coords[0].z, - coords[0].x, 0, coords[0].z, - texcoords[0].x - FIX_ONE, FIX_ONE); + coords[0].x, 0, coords[0].z, + texcoords[0].x - FIX_ONE, FIX_ONE); /*bottom*/ mesh_set_vertex(mesh, coords[0].x, -1*coords[0].y, coords[0].z, - coords[0].x, 0, coords[0].z, - texcoords[0].x - FIX_ONE, 0); + coords[0].x, 0, coords[0].z, + texcoords[0].x - FIX_ONE, 0); - mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); - mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-2, mesh->v_count-1); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-2, mesh->v_count-1); } if (bottom) { @@ -435,39 +461,39 @@ void mesh_new_cylinder(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, B c_idx = mesh->v_count-1; for (i=0; iv_count-2, mesh->v_count-1); } mesh_set_vertex(mesh, coords[0].x, -1*coords[0].y, coords[0].z, - 0, -FIX_ONE, 0, - (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); + 0, -FIX_ONE, 0, + (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); } - if (top) { - Fixed aincr = GF_2PI / nfacets; - Fixed angle = GF_PI + aincr; + if (top) { + Fixed aincr = GF_2PI / nfacets; + Fixed angle = GF_PI + aincr; mesh_set_vertex(mesh, 0, height/2, 0, 0, FIX_ONE, 0, FIX_ONE/2, FIX_ONE/2); - c_idx = mesh->v_count-1; - for (i=nfacets; i>0; --i, angle += aincr) { + c_idx = mesh->v_count-1; + for (i=nfacets; i>0; --i, angle += aincr) { mesh_set_vertex(mesh, coords[i - 1].x, coords[i - 1].y, coords[i - 1].z, - 0, FIX_ONE, 0, - (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); + 0, FIX_ONE, 0, + (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); if (i) mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); - } + } mesh_set_vertex(mesh, coords[nfacets - 1].x, coords[nfacets - 1].y, coords[nfacets - 1].z, - 0, FIX_ONE, 0, - (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); + 0, FIX_ONE, 0, + (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); - } + } gf_free(texcoords); gf_free(coords); - if (top && bottom && side) mesh->flags |= MESH_IS_SOLID; + if (top && bottom && side) mesh->flags |= MESH_IS_SOLID; mesh->bounds.min_edge.x = mesh->bounds.min_edge.z = -radius; mesh->bounds.max_edge.x = mesh->bounds.max_edge.z = radius; @@ -481,18 +507,18 @@ void mesh_new_cylinder(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, B #define CONE_SUBDIV 24 void mesh_new_cone(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, Bool side, Bool low_res) { - u32 nfacets, i, c_idx; - SFVec3f *coords; + u32 nfacets, i, c_idx; + SFVec3f *coords; SFVec2f *texcoords; mesh_reset(mesh); - if (!bottom && !side) return; + if (!bottom && !side) return; - nfacets = CONE_SUBDIV; - if (low_res) nfacets /= HIGH_SPEED_RATIO; - coords = (SFVec3f*)gf_malloc(sizeof(SFVec3f) * nfacets); + nfacets = CONE_SUBDIV; + if (low_res) nfacets /= HIGH_SPEED_RATIO; + coords = (SFVec3f*)gf_malloc(sizeof(SFVec3f) * nfacets); texcoords = (SFVec2f*)gf_malloc(sizeof(SFVec2f) * nfacets); - + compute_cylinder(height, radius, nfacets, coords, texcoords); if (side) { @@ -500,26 +526,26 @@ void mesh_new_cone(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, Bool for (i = 0; i < nfacets; ++i) { /*top*/ - mesh_set_vertex(mesh, 0, coords[i].y, 0, - coords[i].x, Ny, coords[i].z, - texcoords[i].x, FIX_ONE); + mesh_set_vertex(mesh, 0, coords[i].y, 0, + coords[i].x, Ny, coords[i].z, + texcoords[i].x, FIX_ONE); /*base*/ - mesh_set_vertex(mesh, coords[i].x, -1*coords[i].y, coords[i].z, - coords[i].x, Ny, coords[i].z, - texcoords[i].x, 0); + mesh_set_vertex(mesh, coords[i].x, -1*coords[i].y, coords[i].z, + coords[i].x, Ny, coords[i].z, + texcoords[i].x, 0); if (i) { - mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); } } /*top*/ mesh_set_vertex(mesh, 0, coords[0].y, 0, coords[0].x, Ny, coords[0].z, texcoords[0].x - FIX_ONE, FIX_ONE); /*base*/ - mesh_set_vertex(mesh, coords[0].x, -1*coords[0].y, coords[0].z, - coords[0].x, Ny, coords[0].z, - texcoords[0].x - FIX_ONE, 0); + mesh_set_vertex(mesh, coords[0].x, -1*coords[0].y, coords[0].z, + coords[0].x, Ny, coords[0].z, + texcoords[0].x - FIX_ONE, 0); - mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); + mesh_set_triangle(mesh, mesh->v_count-4, mesh->v_count-1, mesh->v_count-3); } if (bottom) { @@ -530,21 +556,21 @@ void mesh_new_cone(GF_Mesh *mesh, Fixed height, Fixed radius, Bool bottom, Bool c_idx = mesh->v_count - 1; for (i=0; iv_count-2, mesh->v_count-1); + if (i) + mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); } mesh_set_vertex(mesh, coords[0].x, -1*coords[0].y, coords[0].z, - 0, -FIX_ONE, 0, - (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); - mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); + 0, -FIX_ONE, 0, + (FIX_ONE + gf_sin(angle))/2, FIX_ONE - (FIX_ONE + gf_cos(angle))/2); + mesh_set_triangle(mesh, c_idx, mesh->v_count-2, mesh->v_count-1); } gf_free(texcoords); gf_free(coords); - if (bottom && side) mesh->flags |= MESH_IS_SOLID; + if (bottom && side) mesh->flags |= MESH_IS_SOLID; mesh->bounds.min_edge.x = mesh->bounds.min_edge.z = -radius; mesh->bounds.max_edge.x = mesh->bounds.max_edge.z = radius; @@ -561,21 +587,21 @@ void compute_sphere(Fixed radius, SFVec3f *coords, SFVec2f *texcoords, u32 num_s Fixed r, angle, x, y, z; u32 i, j; - for (i=0; iv_count-3, mesh->v_count-4, mesh->v_count-2); mesh_set_triangle(mesh, mesh->v_count-3, mesh->v_count-2, mesh->v_count-1); } - } - mesh_set_vertex(mesh, coords[n + num_steps].x, coords[n + num_steps].y, coords[n + num_steps].z, - coords[n + num_steps].x, coords[n + num_steps].y, coords[n + num_steps].z, - 0/*FIX_ONE*/, texcoords[n + num_steps].y); - mesh_set_vertex(mesh, coords[n].x, coords[n].y, coords[n].z, - coords[n].x, coords[n].y, coords[n].z, - 0/*FIX_ONE*/, texcoords[n].y); - mesh_set_triangle(mesh, mesh->v_count-3, mesh->v_count-4, mesh->v_count-2); + } + mesh_set_vertex(mesh, coords[n + num_steps].x, coords[n + num_steps].y, coords[n + num_steps].z, + coords[n + num_steps].x, coords[n + num_steps].y, coords[n + num_steps].z, + 0/*FIX_ONE*/, texcoords[n + num_steps].y); + mesh_set_vertex(mesh, coords[n].x, coords[n].y, coords[n].z, + coords[n].x, coords[n].y, coords[n].z, + 0/*FIX_ONE*/, texcoords[n].y); + mesh_set_triangle(mesh, mesh->v_count-3, mesh->v_count-4, mesh->v_count-2); mesh_set_triangle(mesh, mesh->v_count-3, mesh->v_count-2, mesh->v_count-1); } @@ -652,12 +678,17 @@ void mesh_new_rectangle(GF_Mesh *mesh, SFVec2f size, SFVec2f *orig, Bool flip) mesh_set_vertex(mesh, x+size.x, y, 0, 0, 0, FIX_ONE, FIX_ONE, tmax); mesh_set_vertex(mesh, x, y, 0, 0, 0, FIX_ONE, 0, tmax); - mesh_set_triangle(mesh, 0, 1, 2); mesh_set_triangle(mesh, 0, 2, 3); - + mesh_set_triangle(mesh, 0, 1, 2); + mesh_set_triangle(mesh, 0, 2, 3); + mesh->flags |= MESH_IS_2D; - mesh->bounds.min_edge.x = x; mesh->bounds.min_edge.y = y-size.y; mesh->bounds.min_edge.z = 0; - mesh->bounds.max_edge.x = x+size.x; mesh->bounds.max_edge.y = y; mesh->bounds.max_edge.z = 0; + mesh->bounds.min_edge.x = x; + mesh->bounds.min_edge.y = y-size.y; + mesh->bounds.min_edge.z = 0; + mesh->bounds.max_edge.x = x+size.x; + mesh->bounds.max_edge.y = y; + mesh->bounds.max_edge.z = 0; gf_bbox_refresh(&mesh->bounds); } @@ -671,7 +702,7 @@ void mesh_new_ellipse(GF_Mesh *mesh, Fixed a_dia, Fixed b_dia, Bool low_res) /*no begin/end draw since we always use generic 2D node drawing methods*/ end = GF_2PI; step = end / ELLIPSE_SUBDIV; - if (low_res) step *= HIGH_SPEED_RATIO; + if (low_res) step *= HIGH_SPEED_RATIO; mesh_reset(mesh); @@ -681,18 +712,22 @@ void mesh_new_ellipse(GF_Mesh *mesh, Fixed a_dia, Fixed b_dia, Bool low_res) cosa = gf_cos(cur); sina = gf_sin(cur); - mesh_set_vertex(mesh, gf_mulfix(a_dia, cosa), gf_mulfix(b_dia, sina), 0, - 0, 0, FIX_ONE, - (FIX_ONE + cosa)/2, (FIX_ONE + sina)/2); + mesh_set_vertex(mesh, gf_mulfix(a_dia, cosa), gf_mulfix(b_dia, sina), 0, + 0, 0, FIX_ONE, + (FIX_ONE + cosa)/2, (FIX_ONE + sina)/2); - if (cur) mesh_set_triangle(mesh, 0, mesh->v_count-2, mesh->v_count-1); + if (cur) mesh_set_triangle(mesh, 0, mesh->v_count-2, mesh->v_count-1); } mesh_set_vertex(mesh, a_dia, 0, 0, 0, 0, FIX_ONE, FIX_ONE, FIX_ONE/2); - mesh_set_triangle(mesh, 0, mesh->v_count-2, mesh->v_count-1); + mesh_set_triangle(mesh, 0, mesh->v_count-2, mesh->v_count-1); mesh->flags |= MESH_IS_2D; - mesh->bounds.min_edge.x = -a_dia; mesh->bounds.min_edge.y = -b_dia; mesh->bounds.min_edge.z = 0; - mesh->bounds.max_edge.x = a_dia; mesh->bounds.max_edge.y = b_dia; mesh->bounds.max_edge.z = 0; + mesh->bounds.min_edge.x = -a_dia; + mesh->bounds.min_edge.y = -b_dia; + mesh->bounds.min_edge.z = 0; + mesh->bounds.max_edge.x = a_dia; + mesh->bounds.max_edge.y = b_dia; + mesh->bounds.max_edge.z = 0; gf_bbox_refresh(&mesh->bounds); } @@ -739,8 +774,12 @@ void mesh_from_path_intern(GF_Mesh *mesh, GF_Path *path, Bool make_ccw) mesh_set_triangle(mesh, 0, i, i+1); } } - mesh->bounds.min_edge.x = bounds.x; mesh->bounds.min_edge.y = bounds.y-bounds.height; mesh->bounds.min_edge.z = 0; - mesh->bounds.max_edge.x = bounds.x+bounds.width; mesh->bounds.max_edge.y = bounds.y; mesh->bounds.max_edge.z = 0; + mesh->bounds.min_edge.x = bounds.x; + mesh->bounds.min_edge.y = bounds.y-bounds.height; + mesh->bounds.min_edge.z = 0; + mesh->bounds.max_edge.x = bounds.x+bounds.width; + mesh->bounds.max_edge.y = bounds.y; + mesh->bounds.max_edge.z = 0; gf_bbox_refresh(&mesh->bounds); return; default: @@ -793,12 +832,12 @@ void mesh_get_outline(GF_Mesh *mesh, GF_Path *path) if (colorRGB && ((u32) index < colorRGB->color.count) ) COL_TO_RGBA(thecol, colorRGB->color.vals[index]) \ else if (colorRGBA && (u32) index < colorRGBA->color.count) thecol = colorRGBA->color.vals[index]; \ } \ - + void mesh_new_ils(GF_Mesh *mesh, GF_Node *__coord, MFInt32 *coordIndex, GF_Node *__color, MFInt32 *colorIndex, Bool colorPerVertex, Bool do_close) { u32 i, n, count, c_count, col_count; u32 index; - u32 first_idx, last_idx; + u32 first_idx, last_idx; Bool move_to; SFVec3f pt; SFColorRGBA colRGBA; @@ -824,7 +863,7 @@ void mesh_new_ils(GF_Mesh *mesh, GF_Node *__coord, MFInt32 *coordIndex, GF_Node count = coordIndex->count; has_coord = count ? 1 : 0; - if (!has_coord) count = c_count; + if (!has_coord) count = c_count; if (!colorIndex->vals) colorIndex = coordIndex; col_count = colorIndex->count ? colorIndex->count : c_count; @@ -843,7 +882,7 @@ void mesh_new_ils(GF_Mesh *mesh, GF_Node *__coord, MFInt32 *coordIndex, GF_Node #endif { #ifndef GPAC_DISABLE_X3D - colorRGBA = NULL; + colorRGBA = NULL; #endif has_color = (colorRGB->color.count) ? 1 : 0; } @@ -952,7 +991,7 @@ void mesh_new_ps(GF_Mesh *mesh, GF_Node *__coord, GF_Node *__color) if (gf_node_get_tag(__color)==TAG_X3D_ColorRGBA) { colorRGB = NULL; has_color = (colorRGBA->color.count) ? 1 : 0; - } else + } else #endif { #ifndef GPAC_DISABLE_X3D @@ -1023,8 +1062,8 @@ void register_face_in_point(struct pt_info *pi, u32 face_index) pi->face_count++; } -static GFINLINE SFVec3f smooth_face_normals(struct pt_info *pts, u32 nb_pts, struct face_info *faces, u32 nb_faces, - u32 pt_idx_in_face, u32 face_idx, Fixed creaseAngleCos) +static GFINLINE SFVec3f smooth_face_normals(struct pt_info *pts, u32 nb_pts, struct face_info *faces, u32 nb_faces, + u32 pt_idx_in_face, u32 face_idx, Fixed creaseAngleCos) { u32 i=0; SFVec3f nor; @@ -1050,12 +1089,12 @@ static GFINLINE SFVec3f smooth_face_normals(struct pt_info *pts, u32 nb_pts, str if (idxcount && (array->vals[idx]>=0) ) index = array->vals[idx]; \ else if (idxcount; has_coord = count ? 1 : 0; - if (!has_coord) count = c_count; + if (!has_coord) count = c_count; smooth_normals = (!has_normal && coord && (creaseAngle > FIX_EPSILON)) ? 1 : 0; @@ -1195,7 +1234,7 @@ void mesh_new_ifs_intern(GF_Mesh *mesh, GF_Node *__coord, MFInt32 *coordIndex, /*don't forget last face*/ if (coordIndex->vals[count-1] != -1) face_count++; } - + faces = (GF_Mesh**)gf_malloc(sizeof(GF_Mesh *)*face_count); for (i=0; iGF_PI) cosCrease = -FIX_ONE; else cosCrease = gf_cos(creaseAngle); - for (i=0; iv_count; j++) { - SFVec3f n = smooth_face_normals(pts_info, c_count, faces_info, face_count, j, i, cosCrease); + for (i=0; iv_count; j++) { + SFVec3f n = smooth_face_normals(pts_info, c_count, faces_info, face_count, j, i, cosCrease); MESH_SET_NORMAL(faces[i]->vertices[j], n); - } } + } + } if (faces_info) { for (i=0; iflags |= MESH_IS_SMOOTHED; } else { - for (i=0; ivertices[1].pos, faces[i]->vertices[0].pos); gf_vec_diff(v2, faces[i]->vertices[2].pos, faces[i]->vertices[0].pos); n = gf_vec_cross(v1, v2); if (!n.x && !n.y && !n.z) n.z = FIX_ONE; else gf_vec_norm(&n); - for (j=0; jv_count; j++) + for (j=0; jv_count; j++) MESH_SET_NORMAL(faces[i]->vertices[j], n); } } @@ -1354,8 +1395,8 @@ void mesh_new_ifs2d(GF_Mesh *mesh, GF_Node *node) { M_IndexedFaceSet2D *ifs2D = (M_IndexedFaceSet2D *)node; mesh_new_ifs_intern(mesh, ifs2D->coord, &ifs2D->coordIndex, - ifs2D->color, &ifs2D->colorIndex, ifs2D->colorPerVertex, - NULL, NULL, 0, ifs2D->texCoord, &ifs2D->texCoordIndex, 0); + ifs2D->color, &ifs2D->colorIndex, ifs2D->colorPerVertex, + NULL, NULL, 0, ifs2D->texCoord, &ifs2D->texCoordIndex, 0); mesh->flags |= MESH_IS_2D; } @@ -1364,7 +1405,7 @@ void mesh_new_ifs(GF_Mesh *mesh, GF_Node *node) { M_IndexedFaceSet *ifs = (M_IndexedFaceSet *)node; mesh_new_ifs_intern(mesh, ifs->coord, &ifs->coordIndex, ifs->color, &ifs->colorIndex, ifs->colorPerVertex, - ifs->normal, &ifs->normalIndex, ifs->normalPerVertex, ifs->texCoord, &ifs->texCoordIndex, ifs->creaseAngle); + ifs->normal, &ifs->normalIndex, ifs->normalPerVertex, ifs->texCoord, &ifs->texCoordIndex, ifs->creaseAngle); if (ifs->solid) mesh->flags |= MESH_IS_SOLID; if (!ifs->ccw) mesh->flags |= MESH_IS_CW; @@ -1401,7 +1442,7 @@ void mesh_new_elevation_grid(GF_Mesh *mesh, GF_Node *node) if (gf_node_get_tag(eg->color)==TAG_X3D_ColorRGBA) { colorRGB = NULL; has_color = colorRGBA->color.count ? 1 : 0; - } else + } else #endif { #ifndef GPAC_DISABLE_X3D @@ -1449,8 +1490,10 @@ void mesh_new_elevation_grid(GF_Mesh *mesh, GF_Node *node) gf_vec_diff(v2, mesh->vertices[i+z1+1].pos, mesh->vertices[i+z0+1].pos); n = gf_vec_cross(v1, v2); gf_vec_norm(&n); - MESH_SET_NORMAL(mesh->vertices[i+z0], n); MESH_SET_NORMAL(mesh->vertices[i+z0+1], n); - MESH_SET_NORMAL(mesh->vertices[i+z1], n); MESH_SET_NORMAL(mesh->vertices[i+z1+1], n); + MESH_SET_NORMAL(mesh->vertices[i+z0], n); + MESH_SET_NORMAL(mesh->vertices[i+z0+1], n); + MESH_SET_NORMAL(mesh->vertices[i+z1], n); + MESH_SET_NORMAL(mesh->vertices[i+z1+1], n); } } mesh->mesh_type = MESH_TRIANGLES; @@ -1475,13 +1518,13 @@ void mesh_new_elevation_grid(GF_Mesh *mesh, GF_Node *node) for (i = 0; i < xDimension-1; i++) { u32 k, l; /*get face color*/ - if (has_color && !eg->colorPerVertex) { + if (has_color && !eg->colorPerVertex) { idx = i + j * (xDimension-1); #ifndef GPAC_DISABLE_X3D MESH_GET_COL(rgba, idx); #endif vx.color = MESH_MAKE_COL(rgba); - } + } /*get face normal*/ if (has_normal && !eg->normalPerVertex) { idx = i + j * (xDimension-1); @@ -1556,8 +1599,10 @@ void mesh_new_elevation_grid(GF_Mesh *mesh, GF_Node *node) gf_vec_diff(v2, mesh->vertices[pt_idx+3].pos, mesh->vertices[pt_idx+1].pos); n = gf_vec_cross(v1, v2); gf_vec_norm(&n); - MESH_SET_NORMAL(mesh->vertices[pt_idx+0], n); MESH_SET_NORMAL(mesh->vertices[pt_idx+1], n); - MESH_SET_NORMAL(mesh->vertices[pt_idx+2], n); MESH_SET_NORMAL(mesh->vertices[pt_idx+3], n); + MESH_SET_NORMAL(mesh->vertices[pt_idx+0], n); + MESH_SET_NORMAL(mesh->vertices[pt_idx+1], n); + MESH_SET_NORMAL(mesh->vertices[pt_idx+2], n); + MESH_SET_NORMAL(mesh->vertices[pt_idx+3], n); } pt_idx+=4; } @@ -1571,10 +1616,12 @@ void mesh_new_elevation_grid(GF_Mesh *mesh, GF_Node *node) if (eg->creaseAngle>GF_PI) cosCrease = -FIX_ONE; else cosCrease = gf_cos(eg->creaseAngle); - for (i=0; iv_count; j++) { - SFVec3f n = smooth_face_normals(pts_info, pt_count, faces_info, face_count, j, i, cosCrease); - MESH_SET_NORMAL(faces[i]->vertices[j], n); - } } + for (i=0; iv_count; j++) { + SFVec3f n = smooth_face_normals(pts_info, pt_count, faces_info, face_count, j, i, cosCrease); + MESH_SET_NORMAL(faces[i]->vertices[j], n); + } + } if (faces_info) { for (i=0; iflags |= MESH_IS_SMOOTHED; - + for (i=0; iv_count) { u32 init_idx; @@ -1639,9 +1686,9 @@ typedef struct register_face_in_point(&pts_info[pidx], fidx); \ } \ } \ + - -#define NEAR_ZERO(__x) (ABS(__x)<=FIX_EPSILON) +#define NEAR_ZERO(__x) (ABS(__x)<=FIX_EPSILON) static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thespine, Fixed creaseAngle, Fixed min_cx, Fixed min_cy, Fixed width_cx, Fixed width_cy, Bool begin_cap, Bool end_cap, MFRotation *spine_ori, MFVec2f *spine_scale, Bool tx_along_spine) { @@ -1688,11 +1735,11 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes begin_face = end_face = 0; face_spines = face_count = (thespine->count-1)*faces_per_cross; if (begin_cap) { - begin_face = face_count; + begin_face = face_count; face_count ++; } if (end_cap) { - end_face = face_count; + end_face = face_count; face_count ++; } @@ -1703,7 +1750,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes for (i=0; ivals; nb_spine = thespine->count; SCPs = (SCP *)gf_malloc(sizeof(SCP) * nb_spine); @@ -1720,7 +1767,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes SCPi = (SCPInfo *) gf_malloc(sizeof(SCPInfo) * nb_spine); memset(SCPi, 0, sizeof(SCPInfo) * nb_spine); - /*collect all # SCPs: + /*collect all # SCPs: 1- if a spine has identical consecutive points with # orientation, these points use the same SCPs 2- if 2 segs of the spine are colinear, they also use the same SCP */ @@ -1744,7 +1791,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes if (gf_vec_equal(SCPi[nb_scp-1].pt, spine[i])) { SCPi[nb_scp-1].max_idx = i; continue; - } + } /*last point in spine*/ if (i+1 == nb_spine) { nb_scp++; @@ -1770,9 +1817,15 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes /*all colinear!!*/ if (nb_scp<=2) { - SCPi[0].xaxis.x = FIX_ONE; SCPi[0].xaxis.y = 0; SCPi[0].xaxis.z = 0; - SCPi[0].yaxis.x = 0; SCPi[0].yaxis.y = FIX_ONE; SCPi[0].yaxis.z = 0; - SCPi[0].zaxis.x = 0; SCPi[0].zaxis.y = 0; SCPi[0].zaxis.z = FIX_ONE; + SCPi[0].xaxis.x = FIX_ONE; + SCPi[0].xaxis.y = 0; + SCPi[0].xaxis.z = 0; + SCPi[0].yaxis.x = 0; + SCPi[0].yaxis.y = FIX_ONE; + SCPi[0].yaxis.z = 0; + SCPi[0].zaxis.x = 0; + SCPi[0].zaxis.y = 0; + SCPi[0].zaxis.z = FIX_ONE; /*compute rotation from (0, 1, 0) to spine_vec*/ if (!check_first_spine_vec) { Fixed alpha, gamma; @@ -1838,7 +1891,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes SCPs[i].yaxis = SCPi[0].yaxis; SCPs[i].zaxis = SCPi[0].zaxis; } - } + } /*not colinear*/ else { assert(nb_scp<=nb_spine); @@ -1876,7 +1929,9 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes for (i=0; ixaxis = gf_vec_cross(curSCP->yaxis, curSCP->zaxis); - gf_vec_norm(&curSCP->xaxis); gf_vec_norm(&curSCP->yaxis); gf_vec_norm(&curSCP->zaxis); + gf_vec_norm(&curSCP->xaxis); + gf_vec_norm(&curSCP->yaxis); + gf_vec_norm(&curSCP->zaxis); if (spine_ori && (icount)) r = spine_ori->vals[i]; if (spine_scale && (icount)) scale = spine_scale->vals[i]; @@ -1989,7 +2047,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes /*previous face "below" face*/ if (k) REGISTER_POINT_FACE(k-1 + cur_face_in_cross + (i-1)*faces_per_cross); } - + if (k+1points[k+1+cur].x - path->points[k+cur].x; @@ -2007,7 +2065,7 @@ static void mesh_extrude_path_intern(GF_Mesh *mesh, GF_Path *path, MFVec3f *thes cur_spine += gf_vec_len(v1); } } - + /*generate triangles & normals*/ for (i=0; iGF_PI) cosCrease = -FIX_ONE; else cosCrease = gf_cos(creaseAngle); - for (i=0; iv_count; j++) { - SFVec3f n = smooth_face_normals(pts_info, pt_count, faces_info, face_count, j, i, cosCrease); + for (i=0; iv_count; j++) { + SFVec3f n = smooth_face_normals(pts_info, pt_count, faces_info, face_count, j, i, cosCrease); MESH_SET_NORMAL(faces[i]->vertices[j], n); - } } + } + } if (faces_info) { for (i=0; isubpathlen && path->subpath[0]->closed && ((begin_face && end_face) || spine_closed)) - mesh->flags |= MESH_IS_SOLID; - else - mesh->flags &= ~MESH_IS_SOLID; -*/ + /* + if (path->subpathlen && path->subpath[0]->closed && ((begin_face && end_face) || spine_closed)) + mesh->flags |= MESH_IS_SOLID; + else + mesh->flags &= ~MESH_IS_SOLID; + */ } void mesh_extrude_path_ext(GF_Mesh *mesh, GF_Path *path, MFVec3f *thespine, Fixed creaseAngle, Fixed min_cx, Fixed min_cy, Fixed width_cx, Fixed width_cy, Bool begin_cap, Bool end_cap, MFRotation *spine_ori, MFVec2f *spine_scale, Bool tx_along_spine) diff --git a/src/compositor/mesh_collide.c b/src/compositor/mesh_collide.c index 7294588..c40d3c3 100644 --- a/src/compositor/mesh_collide.c +++ b/src/compositor/mesh_collide.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ AABB tree syntax&construction code is a quick extract from OPCODE (c) Pierre Terdiman, http://www.codercorner.com/Opcode.htm */ -typedef struct +typedef struct { /*max tree depth, 0 is unlimited*/ u32 max_depth; @@ -55,13 +55,20 @@ static GFINLINE void update_node_bounds(GF_Mesh *mesh, AABBNode *node) IDX_TYPE *idx = &mesh->indices[3*node->indices[i]]; for (j=0; j<3; j++) { SFVec3f *v = &mesh->vertices[idx[j]].pos; - if (mx>v->x) mx=v->x; if (Mxx) Mx=v->x; - if (my>v->y) my=v->y; if (Myy) My=v->y; - if (mz>v->z) mz=v->z; if (Mzz) Mz=v->z; + if (mx>v->x) mx=v->x; + if (Mxx) Mx=v->x; + if (my>v->y) my=v->y; + if (Myy) My=v->y; + if (mz>v->z) mz=v->z; + if (Mzz) Mz=v->z; } } - node->min.x = mx; node->min.y = my; node->min.z = mz; - node->max.x = Mx; node->max.y = My; node->max.z = Mz; + node->min.x = mx; + node->min.y = my; + node->min.z = mz; + node->max.x = Mx; + node->max.y = My; + node->max.z = Mz; } static GFINLINE u32 gf_vec_main_axis(SFVec3f v) @@ -125,7 +132,7 @@ static void mesh_subdivide_aabbtree(GF_Mesh *mesh, AABBNode *node, AABSplitParam if (node->nb_idx==1) return; if (node->nb_idx <= aab_par->min_tri_limit) return; if (aab_par->max_depth == aab_par->depth) { - aab_par->depth --; + aab_par->depth --; return; } do_split = 1; @@ -141,11 +148,14 @@ static void mesh_subdivide_aabbtree(GF_Mesh *mesh, AABBNode *node, AABSplitParam else if (aab_par->split_type==AABB_BALANCED) { Fixed res[3]; num_pos = aabb_split(mesh, node, 0); - res[0] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; res[0] = gf_mulfix(res[0], res[0]); + res[0] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; + res[0] = gf_mulfix(res[0], res[0]); num_pos = aabb_split(mesh, node, 1); - res[1] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; res[1] = gf_mulfix(res[1], res[1]); + res[1] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; + res[1] = gf_mulfix(res[1], res[1]); num_pos = aabb_split(mesh, node, 2); - res[2] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; res[2] = gf_mulfix(res[2], res[2]);; + res[2] = gf_divfix(INT2FIX(num_pos), INT2FIX(node->nb_idx)) - FIX_ONE/2; + res[2] = gf_mulfix(res[2], res[2]);; axis = 0; if (res[1] < res[axis]) axis = 1; @@ -289,14 +299,14 @@ Bool gf_mesh_aabb_ray_hit(GF_Mesh *mesh, AABBNode *n, GF_Ray *ray, Fixed *closes /*check bbox intersection*/ inters = gf_ray_hit_box(ray, n->min, n->max, NULL); if (!inters) return 0; - + if (n->pos) { /*we really want to check all possible intersections to get the closest point on ray*/ Bool res = gf_mesh_aabb_ray_hit(mesh, n->pos, ray, closest, outPoint, outNormal, outTexCoords); res += gf_mesh_aabb_ray_hit(mesh, n->neg, ray, closest, outPoint, outNormal, outTexCoords); return res; - } + } inters_idx = 0; @@ -307,9 +317,9 @@ Bool gf_mesh_aabb_ray_hit(GF_Mesh *mesh, AABBNode *n, GF_Ray *ray, Fixed *closes for (i=0; inb_idx; i++) { Fixed res; IDX_TYPE *idx = &mesh->indices[3*n->indices[i]]; - if (gf_ray_hit_triangle(ray, - &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, - &res)) { + if (gf_ray_hit_triangle(ray, + &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, + &res)) { if ((res>0) && (resindices[3*n->indices[inters_idx]];; - ray_hit_triangle_get_u_v(ray, - &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, - &outTexCoords->x, &outTexCoords->y); + ray_hit_triangle_get_u_v(ray, + &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, + &outTexCoords->x, &outTexCoords->y); } } return inters; @@ -369,9 +379,9 @@ Bool gf_mesh_intersect_ray(GF_Mesh *mesh, GF_Ray *ray, SFVec3f *outPoint, SFVec3 for (i=0; ii_count; i+=3) { Fixed res; IDX_TYPE *idx = &mesh->indices[i]; - if (gf_ray_hit_triangle(ray, - &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, - &res)) { + if (gf_ray_hit_triangle(ray, + &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, + &res)) { if ((res>0) && (resvertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, - &d); + inters = mesh_collide_triangle(&r, + &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, + &d); if (inters) { /*we're behind the face, get inverse normal*/ @@ -572,9 +582,9 @@ Bool gf_mesh_closest_face(GF_Mesh *mesh, SFVec3f pos, Fixed min_dist, SFVec3f *o /*intersect inverse normal from position to face with face*/ r.dir = n; gf_vec_rev(r.dir); - inters = mesh_collide_triangle(&r, - &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, - &d); + inters = mesh_collide_triangle(&r, + &mesh->vertices[idx[0]].pos, &mesh->vertices[idx[1]].pos, &mesh->vertices[idx[2]].pos, + &d); if (inters) { /*we're behind the face, get inverse normal*/ diff --git a/src/compositor/mesh_tesselate.c b/src/compositor/mesh_tesselate.c index 115f69f..e30e90c 100644 --- a/src/compositor/mesh_tesselate.c +++ b/src/compositor/mesh_tesselate.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,14 +50,18 @@ typedef struct GLUtesselator *tess_obj; GF_Mesh *mesh; - /*vertex indices: we cannot use a static array because reallocating the array will likely change memory + /*vertex indices: we cannot use a static array because reallocating the array will likely change memory address of indices, hence break triangulator*/ GF_List *vertex_index; } MeshTess; -static void CALLBACK mesh_tess_begin(GLenum which) { assert(which==GL_TRIANGLES); } +static void CALLBACK mesh_tess_begin(GLenum which) { + assert(which==GL_TRIANGLES); +} static void CALLBACK mesh_tess_end(void) { } -static void CALLBACK mesh_tess_error(GLenum error_code) { GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Mesh] Tesselate error %s\n", gluErrorString(error_code))); } +static void CALLBACK mesh_tess_error(GLenum error_code) { + GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Mesh] Tesselate error %s\n", gluErrorString(error_code))); +} /*only needed to force GL_TRIANGLES*/ static void CALLBACK mesh_tess_edgeflag(GLenum flag) { } @@ -141,8 +145,8 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) tess = gf_malloc(sizeof(MeshTess)); if (!tess) return; memset(tess, 0, sizeof(MeshTess)); - tess->tess_obj = gluNewTess(); - if (!tess->tess_obj) { + tess->tess_obj = gluNewTess(); + if (!tess->tess_obj) { gf_free(tess); return; } @@ -151,18 +155,18 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) mesh_reset(mesh); mesh->flags |= MESH_IS_2D; if (outline_style==1) mesh->flags |= MESH_NO_TEXTURE; - + tess->mesh = mesh; - gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); - gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); - gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); - gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); - gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); + gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); + gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); + gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); + gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); + gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); gluTessCallback(tess->tess_obj, GLU_EDGE_FLAG,(void (CALLBACK*)()) &mesh_tess_edgeflag); if (path->flags & GF_PATH_FILL_ZERO_NONZERO) gluTessProperty(tess->tess_obj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO); - gluTessBeginPolygon(tess->tess_obj, tess); + gluTessBeginPolygon(tess->tess_obj, tess); gluTessNormal(tess->tess_obj, 0, 0, 1); gf_path_flatten(path); @@ -197,7 +201,7 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) cur+=nb_pts; } - gluTessEndPolygon(tess->tess_obj); + gluTessEndPolygon(tess->tess_obj); gluDeleteTess(tess->tess_obj); @@ -229,7 +233,7 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) { } if (!direction) { pt.x = - apt.pos.z; pt.y = apt.pos.y; } \ else if (direction==1) { pt.x = apt.pos.z; pt.y = apt.pos.x; } \ else if (direction==2) { pt.x = apt.pos.x; pt.y = apt.pos.y; } \ - + #define ConvCompare(delta) \ ( (delta.x > 0) ? -1 : \ @@ -244,7 +248,7 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) { } GetPoint2D(pcur, pts[iread]); iread++; \ delta.x = pcur.x - pprev.x; \ delta.y = pcur.y - pprev.y; \ - + #define ConvCross(p, q) gf_mulfix(p.x,q.y) - gf_mulfix(p.y,q.x); #define ConvCheckTriple \ @@ -265,7 +269,7 @@ void gf_mesh_tesselate_path(GF_Mesh *mesh, GF_Path *path, u32 outline_style) { } pSecond = pThird; \ dprev.x = dcur.x; \ dprev.y = dcur.y; \ - + u32 polygon_check_convexity(GF_Vertex *pts, u32 len, u32 direction) { s32 curDir, thisDir = 0, dirChanges = 0, angleSign = 0; @@ -280,46 +284,46 @@ u32 polygon_check_convexity(GF_Vertex *pts, u32 len, u32 direction) pThird = pSecond; GetPoint2D(pThird, pts[0]); - /* Get different point, return if less than 3 diff points. */ - if (len < 3 ) return GF_POLYGON_CONVEX_LINE; - iread = 1; + /* Get different point, return if less than 3 diff points. */ + if (len < 3 ) return GF_POLYGON_CONVEX_LINE; + iread = 1; ConvGetPointDelta(dprev, pThird, pSecond); - pSaveSecond = pSecond; + pSaveSecond = pSecond; /*initial direction */ - curDir = ConvCompare(dprev); - while ( iread < len) { + curDir = ConvCompare(dprev); + while ( iread < len) { /* Get different point, break if no more points */ ConvGetPointDelta(dcur, pSecond, pThird ); if ( (dcur.x == 0) && (dcur.y == 0) ) continue; /* Check current three points */ ConvCheckTriple; - } + } - /* Must check for direction changes from last vertex back to first */ + /* Must check for direction changes from last vertex back to first */ /* Prepare for 'ConvexCheckTriple' */ GetPoint2D(pThird, pts[0]); - dcur.x = pThird.x - pSecond.x; - dcur.y = pThird.y - pSecond.y; - if ( ConvCompare(dcur) ) ConvCheckTriple; + dcur.x = pThird.x - pSecond.x; + dcur.y = pThird.y - pSecond.y; + if ( ConvCompare(dcur) ) ConvCheckTriple; - /* and check for direction changes back to second vertex */ - dcur.x = pSaveSecond.x - pSecond.x; - dcur.y = pSaveSecond.y - pSecond.y; + /* and check for direction changes back to second vertex */ + dcur.x = pSaveSecond.x - pSecond.x; + dcur.y = pSaveSecond.y - pSecond.y; /* Don't care about 'pThird' now */ - ConvCheckTriple; + ConvCheckTriple; - /* Decide on polygon type given accumulated status */ - if ( dirChanges > 2 ) return GF_POLYGON_COMPLEX; - if ( angleSign > 0 ) return GF_POLYGON_CONVEX_CCW; - if ( angleSign < 0 ) return GF_POLYGON_CONVEX_CW; - return GF_POLYGON_CONVEX_LINE; + /* Decide on polygon type given accumulated status */ + if ( dirChanges > 2 ) return GF_POLYGON_COMPLEX; + if ( angleSign > 0 ) return GF_POLYGON_CONVEX_CCW; + if ( angleSign < 0 ) return GF_POLYGON_CONVEX_CW; + return GF_POLYGON_CONVEX_LINE; } void TesselateFaceMesh(GF_Mesh *dest, GF_Mesh *orig) { u32 poly_type, i, nb_pts, init_idx, direction; - Fixed max_nor_coord, c; + Fixed max_nor_coord, c; SFVec3f nor; #ifdef GPAC_HAS_GLU u32 *idx; @@ -329,7 +333,8 @@ void TesselateFaceMesh(GF_Mesh *dest, GF_Mesh *orig) /*get normal*/ if (orig->flags & MESH_IS_2D) { - nor.x = nor.y = 0; nor.z = FIX_ONE; + nor.x = nor.y = 0; + nor.z = FIX_ONE; } else { MESH_GET_NORMAL(nor, orig->vertices[0]); } @@ -367,27 +372,27 @@ void TesselateFaceMesh(GF_Mesh *dest, GF_Mesh *orig) } #ifdef GPAC_HAS_GLU - + /*tesselate it*/ tess = gf_malloc(sizeof(MeshTess)); if (!tess) return; memset(tess, 0, sizeof(MeshTess)); - tess->tess_obj = gluNewTess(); - if (!tess->tess_obj) { + tess->tess_obj = gluNewTess(); + if (!tess->tess_obj) { gf_free(tess); return; } tess->vertex_index = gf_list_new(); tess->mesh = dest; - gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); - gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); - gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); - gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); - gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); + gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); + gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); + gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); + gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); + gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); gluTessCallback(tess->tess_obj, GLU_EDGE_FLAG,(void (CALLBACK*)()) &mesh_tess_edgeflag); - gluTessBeginPolygon(tess->tess_obj, tess); + gluTessBeginPolygon(tess->tess_obj, tess); gluTessBeginContour(tess->tess_obj); @@ -404,7 +409,7 @@ void TesselateFaceMesh(GF_Mesh *dest, GF_Mesh *orig) } gluTessEndContour(tess->tess_obj); - gluTessEndPolygon(tess->tess_obj); + gluTessEndPolygon(tess->tess_obj); gluDeleteTess(tess->tess_obj); while (gf_list_count(tess->vertex_index)) { @@ -427,34 +432,34 @@ void TesselateFaceMeshComplex(GF_Mesh *dest, GF_Mesh *orig, u32 nbFaces, u32 *pt u32 *idx; GLdouble vertex[3]; MeshTess *tess; - + /*tesselate it*/ tess = gf_malloc(sizeof(MeshTess)); if (!tess) return; memset(tess, 0, sizeof(MeshTess)); - tess->tess_obj = gluNewTess(); - if (!tess->tess_obj) { + tess->tess_obj = gluNewTess(); + if (!tess->tess_obj) { gf_free(tess); return; } tess->vertex_index = gf_list_new(); tess->mesh = dest; - gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); - gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); - gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); - gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); - gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); + gluTessCallback(tess->tess_obj, GLU_TESS_VERTEX_DATA, (void (CALLBACK*)()) &mesh_tess_vertex); + gluTessCallback(tess->tess_obj, GLU_TESS_BEGIN, (void (CALLBACK*)()) &mesh_tess_begin); + gluTessCallback(tess->tess_obj, GLU_TESS_END, (void (CALLBACK*)()) &mesh_tess_end); + gluTessCallback(tess->tess_obj, GLU_TESS_COMBINE_DATA, (void (CALLBACK*)()) &mesh_tess_combine); + gluTessCallback(tess->tess_obj, GLU_TESS_ERROR, (void (CALLBACK*)()) &mesh_tess_error); gluTessCallback(tess->tess_obj, GLU_EDGE_FLAG,(void (CALLBACK*)()) &mesh_tess_edgeflag); - gluTessBeginPolygon(tess->tess_obj, tess); + gluTessBeginPolygon(tess->tess_obj, tess); gluTessBeginContour(tess->tess_obj); cur_pt_faces = 0; cur_face = 0; for (i=0; iv_count; i++) { - + if (i>= cur_pt_faces + ptsPerFaces[cur_face]) { cur_pt_faces += ptsPerFaces[cur_face]; cur_face++; @@ -475,7 +480,7 @@ void TesselateFaceMeshComplex(GF_Mesh *dest, GF_Mesh *orig, u32 nbFaces, u32 *pt } gluTessEndContour(tess->tess_obj); - gluTessEndPolygon(tess->tess_obj); + gluTessEndPolygon(tess->tess_obj); gluDeleteTess(tess->tess_obj); while (gf_list_count(tess->vertex_index)) { diff --git a/src/compositor/mpeg4_animstream.c b/src/compositor/mpeg4_animstream.c index a19c411..9bcff37 100644 --- a/src/compositor/mpeg4_animstream.c +++ b/src/compositor/mpeg4_animstream.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -119,7 +119,7 @@ static void animationstream_deactivate(AnimationStreamStack *stack, M_AnimationS gf_node_event_out_str((GF_Node*)as, "isActive"); } if (stack->stream) { - if (gf_mo_url_changed(stack->stream, &as->url)) + if (gf_mo_url_changed(stack->stream, &as->url)) gf_mo_set_flag(stack->stream, GF_MO_DISPLAY_REMOVE, 1); gf_mo_stop(stack->stream); } @@ -132,7 +132,7 @@ static void animationstream_update_time(GF_TimeNode *st) Double time; M_AnimationStream *as = (M_AnimationStream *)st->udta; AnimationStreamStack *stack = (AnimationStreamStack *)gf_node_get_private(st->udta); - + /*not active, store start time and speed*/ if ( ! as->isActive) { stack->start_time = as->startTime; @@ -142,7 +142,7 @@ static void animationstream_update_time(GF_TimeNode *st) if ((time < stack->start_time) || (stack->start_time < 0)) return; if (animationstream_get_speed(stack, as) && as->isActive) { - //if stoptime is reached (>startTime) deactivate + //if stoptime is reached (>startTime) deactivate if ((as->stopTime > stack->start_time) && (time >= as->stopTime) ) { animationstream_deactivate(stack, as); return; @@ -157,7 +157,7 @@ static void animationstream_update_time(GF_TimeNode *st) } /*we're (about to be) active: VRML: - "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or + "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or equal to startTime, an isActive TRUE event is generated and the time-dependent node becomes active */ if (!as->isActive && !st->needs_unregister) animationstream_activate(stack, as); } @@ -170,10 +170,10 @@ void compositor_init_animationstream(GF_Compositor *compositor, GF_Node *node) st->compositor = compositor; st->time_handle.UpdateTimeNode = animationstream_update_time; st->time_handle.udta = node; - + gf_node_set_private(node, st); gf_node_set_callback_function(node, animationstream_destroy); - + gf_sc_register_time_node(compositor, &st->time_handle); } @@ -186,13 +186,13 @@ void compositor_animationstream_modified(GF_Node *node) if (!st) return; /*update state if we're active*/ - if (as->isActive) + if (as->isActive) animationstream_update_time(&st->time_handle); /*check URL change*/ animationstream_check_url(st, as); - if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) + if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) gf_sc_register_time_node(st->compositor, &st->time_handle); else st->time_handle.needs_unregister = 0; diff --git a/src/compositor/mpeg4_audio.c b/src/compositor/mpeg4_audio.c index b948dfe..e44cae8 100644 --- a/src/compositor/mpeg4_audio.c +++ b/src/compositor/mpeg4_audio.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -111,7 +111,7 @@ static void audioclip_update_time(GF_TimeNode *tn) } time = gf_node_get_scene_time(tn->udta); if ((timestart_time) || (st->start_time<0)) return; - + if (ac->isActive) { if ( (ac->stopTime > st->start_time) && (time>=ac->stopTime)) { audioclip_deactivate(st, ac); @@ -165,7 +165,7 @@ void compositor_audioclip_modified(GF_Node *node) } /*make sure we are still registered*/ - if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) + if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) gf_sc_register_time_node(st->input.compositor, &st->time_handle); else st->time_handle.needs_unregister = 0; @@ -212,7 +212,7 @@ static void audiosource_traverse(GF_Node *node, void *rs, Bool is_destroy) gf_free(st); return; } - + /*check end of stream*/ if (st->input.stream && st->input.stream_finished) { @@ -243,7 +243,7 @@ static void audiosource_update_time(GF_TimeNode *tn) } time = gf_node_get_scene_time(tn->udta); if ((timestart_time) || (st->start_time<0)) return; - + if (st->input.input_ifce.GetSpeed(st->input.input_ifce.callback) && st->is_active) { if ( (as->stopTime > st->start_time) && (time>=as->stopTime)) { audiosource_deactivate(st, as); @@ -292,7 +292,7 @@ void compositor_audiosource_modified(GF_Node *node) } /*make sure we are still registered*/ - if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) + if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) gf_sc_register_time_node(st->input.compositor, &st->time_handle); else st->time_handle.needs_unregister = 0; @@ -337,7 +337,7 @@ static void audiobuffer_traverse(GF_Node *node, void *rs, Bool is_destroy) if (is_destroy) { gf_sc_audio_unregister(&st->output); - if (st->time_handle.is_registered) + if (st->time_handle.is_registered) gf_sc_unregister_time_node(st->output.compositor, &st->time_handle); gf_mixer_del(st->am); @@ -358,7 +358,7 @@ static void audiobuffer_traverse(GF_Node *node, void *rs, Bool is_destroy) /*if no new inputs don't change mixer config*/ update_mixer = gf_list_count(st->new_inputs) ? 1 : 0; - + if (gf_mixer_get_src_count(st->am) == gf_list_count(st->new_inputs)) { u32 count = gf_list_count(st->new_inputs); update_mixer = 0; @@ -386,7 +386,7 @@ static void audiobuffer_traverse(GF_Node *node, void *rs, Bool is_destroy) tr_state->audio_parent = parent; /*Note the audio buffer is ALWAYS registered untill destroyed since buffer filling shall happen even when inactive*/ - if (!st->output.register_with_parent || !st->output.register_with_renderer) + if (!st->output.register_with_parent || !st->output.register_with_renderer) gf_sc_audio_register(&st->output, tr_state); /*store mute flag*/ @@ -423,7 +423,7 @@ static void audiobuffer_update_time(GF_TimeNode *tn) } time = gf_node_get_scene_time(tn->udta); if ((timestart_time) || (st->start_time<0)) return; - + if (ab->isActive) { if ( (ab->stopTime > st->start_time) && (time>=ab->stopTime)) { audiobuffer_deactivate(st, ab); @@ -598,11 +598,11 @@ void compositor_audiobuffer_modified(GF_Node *node) if (!st) return; //update state if we're active - if (ab->isActive) + if (ab->isActive) audiobuffer_update_time(&st->time_handle); /*make sure we are still registered*/ - if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) + if (!st->time_handle.is_registered && !st->time_handle.needs_unregister) gf_sc_register_time_node(st->output.compositor, &st->time_handle); else st->time_handle.needs_unregister = 0; diff --git a/src/compositor/mpeg4_background.c b/src/compositor/mpeg4_background.c index 8b0c44c..b0cc00c 100644 --- a/src/compositor/mpeg4_background.c +++ b/src/compositor/mpeg4_background.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -90,7 +90,7 @@ static void DestroyBackground(GF_Node *node) if (ptr->sky_mesh) mesh_free(ptr->sky_mesh); if (ptr->ground_mesh) mesh_free(ptr->ground_mesh); - + gf_sg_vrml_mf_reset(&ptr->ground_ang, GF_SG_VRML_MFFLOAT); gf_sg_vrml_mf_reset(&ptr->sky_ang, GF_SG_VRML_MFFLOAT); gf_sg_vrml_mf_reset(&ptr->ground_col, GF_SG_VRML_MFCOLOR); @@ -103,14 +103,14 @@ static void DestroyBackground(GF_Node *node) mesh_free(ptr->left_mesh); mesh_free(ptr->right_mesh); - + gf_sc_texture_destroy(&ptr->txh_front); gf_sc_texture_destroy(&ptr->txh_back); gf_sc_texture_destroy(&ptr->txh_top); gf_sc_texture_destroy(&ptr->txh_bottom); gf_sc_texture_destroy(&ptr->txh_left); gf_sc_texture_destroy(&ptr->txh_right); - + gf_free(ptr); } @@ -142,14 +142,15 @@ static void back_build_dome(GF_Mesh *mesh, MFFloat *angles, MFColor *color, Bool start_col.alpha = end_col.alpha = FIX_ONE; vx.texcoords.x = vx.texcoords.y = 0; vx.color = MESH_MAKE_COL(start_col); - vx.pos.x = vx.pos.z = 0; vx.pos.y = FIX_ONE; - vx.normal.x = vx.normal.z = 0; + vx.pos.x = vx.pos.z = 0; + vx.pos.y = FIX_ONE; + vx.normal.x = vx.normal.z = 0; vx.normal.y = -MESH_NORMAL_UNIT; mesh_set_vertex_vx(mesh, &vx); last_idx = 0; ang_idx = 0; - + pad = 1; next_angle = first_angle = 0; if (angles->count) { @@ -163,13 +164,13 @@ static void back_build_dome(GF_Mesh *mesh, MFFloat *angles, MFColor *color, Bool if (ground_dome) { step_div_h *= 2; i=1; - } - + } + for (; iv_count; - for (j = 0; j < step_div_h; j++) { + for (j = 0; j < step_div_h; j++) { SFVec3f n; - Fixed lon = 2 * GF_PI * j / step_div_h; - vx.pos.x = gf_mulfix(gf_sin(lon), r); - vx.pos.z = gf_mulfix(gf_cos(lon), r); + Fixed lon = 2 * GF_PI * j / step_div_h; + vx.pos.x = gf_mulfix(gf_sin(lon), r); + vx.pos.z = gf_mulfix(gf_cos(lon), r); n = gf_vec_scale(vx.pos, FIX_ONE /*-FIX_ONE*/); gf_vec_norm(&n); MESH_SET_NORMAL(vx, n); @@ -224,7 +225,7 @@ static void back_build_dome(GF_Mesh *mesh, MFFloat *angles, MFColor *color, Bool mesh_set_triangle(mesh, 0, new_idx+j, new_idx+j-1); } } - } + } if (i>1) { mesh_set_triangle(mesh, last_idx, new_idx, new_idx+step_div_h-1); mesh_set_triangle(mesh, last_idx, new_idx+step_div_h-1, last_idx+step_div_h-1); @@ -236,8 +237,9 @@ static void back_build_dome(GF_Mesh *mesh, MFFloat *angles, MFColor *color, Bool if (!ground_dome) { new_idx = mesh->v_count; - vx.pos.x = vx.pos.z = 0; vx.pos.y = -FIX_ONE; - vx.normal.x = vx.normal.z = 0; + vx.pos.x = vx.pos.z = 0; + vx.pos.y = -FIX_ONE; + vx.normal.x = vx.normal.z = 0; vx.normal.y = MESH_NORMAL_UNIT; mesh_set_vertex_vx(mesh, &vx); @@ -283,7 +285,7 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) st = (BackgroundStack *) gf_node_get_private(node); compositor = (GF_Compositor*)st->compositor; - + /*may happen in get_bounds*/ if (!tr_state->backgrounds) return; @@ -310,7 +312,13 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) return; } if (!bck->isBound) return; - if (tr_state->traversing_mode != TRAVERSE_BINDABLE) return; + + if (tr_state->traversing_mode != TRAVERSE_BINDABLE) { + if (tr_state->traversing_mode == TRAVERSE_SORT) { + gf_mx_copy(st->current_mx, tr_state->model_matrix); + } + return; + } front_tx = back_gf_sc_texture_enabled(&bck->frontUrl, &st->txh_front); back_tx = back_gf_sc_texture_enabled(&bck->backUrl, &st->txh_back); @@ -333,7 +341,8 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) } /*undo translation*/ - res.x = res.y = res.z = 0; res.q = FIX_ONE; + res.x = res.y = res.z = 0; + res.q = FIX_ONE; gf_mx_apply_vec_4x4(&tr_state->camera->unprojection, &res); assert(res.q); res.x = gf_divfix(res.x, res.q); @@ -345,11 +354,15 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) visual_3d_set_background_state(tr_state->visual, 1); if (has_sky) { + GF_Matrix bck_mx; + gf_mx_copy(bck_mx, tr_state->model_matrix); + gf_mx_copy(tr_state->model_matrix, st->current_mx); + if (!st->sky_mesh) { st->sky_mesh = new_mesh(); back_build_dome(st->sky_mesh, &bck->skyAngle, &bck->skyColor, 0); } - visual_3d_matrix_push(tr_state->visual); + gf_mx_init(mx); gf_mx_add_translation(&mx, res.x, res.y, res.z); @@ -362,17 +375,23 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) #endif gf_mx_add_scale(&mx, scale, scale, scale); - visual_3d_matrix_add(tr_state->visual, mx.m); + gf_mx_add_matrix(&tr_state->model_matrix, &mx); + visual_3d_mesh_paint(tr_state, st->sky_mesh); - visual_3d_matrix_pop(tr_state->visual); + + gf_mx_copy(tr_state->model_matrix, bck_mx); } if (has_ground) { + GF_Matrix bck_mx; + gf_mx_copy(bck_mx, tr_state->model_matrix); + gf_mx_copy(tr_state->model_matrix, st->current_mx); + if (!st->ground_mesh) { st->ground_mesh = new_mesh(); back_build_dome(st->ground_mesh, &bck->groundAngle, &bck->groundColor, 1); } - visual_3d_matrix_push(tr_state->visual); + gf_mx_init(mx); gf_mx_add_translation(&mx, res.x, res.y, res.z); /*cf above*/ @@ -382,13 +401,17 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) scale = 85*tr_state->camera->z_far/100; #endif gf_mx_add_scale(&mx, scale, -scale, scale); - visual_3d_matrix_add(tr_state->visual, mx.m); + + gf_mx_add_matrix(&tr_state->model_matrix, &mx); visual_3d_mesh_paint(tr_state, st->ground_mesh); - visual_3d_matrix_pop(tr_state->visual); + gf_mx_copy(tr_state->model_matrix, bck_mx); } if (front_tx || back_tx || left_tx || right_tx || top_tx || bottom_tx) { - visual_3d_matrix_push(tr_state->visual); + GF_Matrix bck_mx; + gf_mx_copy(bck_mx, tr_state->model_matrix); + gf_mx_copy(tr_state->model_matrix, st->current_mx); + gf_mx_init(mx); gf_mx_add_translation(&mx, res.x, res.y, res.z); #ifdef GPAC_FIXED_POINT @@ -397,10 +420,10 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) #else gf_mx_add_scale(&mx, tr_state->camera->z_far, tr_state->camera->z_far, tr_state->camera->z_far); #endif - visual_3d_matrix_add(tr_state->visual, mx.m); - visual_3d_enable_antialias(tr_state->visual, 1); + gf_mx_add_matrix(&tr_state->model_matrix, &mx); + if (front_tx) back_draw_texture(tr_state, &st->txh_front, st->front_mesh); if (back_tx) back_draw_texture(tr_state, &st->txh_back, st->back_mesh); if (top_tx) back_draw_texture(tr_state, &st->txh_top, st->top_mesh); @@ -408,7 +431,7 @@ static void TraverseBackground(GF_Node *node, void *rs, Bool is_destroy) if (left_tx) back_draw_texture(tr_state, &st->txh_left, st->left_mesh); if (right_tx) back_draw_texture(tr_state, &st->txh_right, st->right_mesh); - visual_3d_matrix_pop(tr_state->visual); + gf_mx_copy(tr_state->model_matrix, bck_mx); } /*enable background state (turn off all quality options)*/ @@ -433,6 +456,7 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) ptr->reg_stacks = gf_list_new(); ((M_Background *)node)->on_set_bind = back_set_bind; + gf_mx_init(ptr->current_mx); /*build texture cube*/ ptr->front_mesh = new_mesh(); @@ -440,7 +464,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->front_mesh, PLANE_HSIZE, -PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, FIX_ONE, 0); mesh_set_vertex(ptr->front_mesh, PLANE_HSIZE, PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_vertex(ptr->front_mesh, -PLANE_HSIZE, PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, 0, FIX_ONE); - mesh_set_triangle(ptr->front_mesh, 0, 1, 2); mesh_set_triangle(ptr->front_mesh, 0, 2, 3); + mesh_set_triangle(ptr->front_mesh, 0, 1, 2); + mesh_set_triangle(ptr->front_mesh, 0, 2, 3); mesh_update_bounds(ptr->front_mesh); ptr->back_mesh = new_mesh(); @@ -448,7 +473,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->back_mesh, PLANE_HSIZE, -PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, 0, 0); mesh_set_vertex(ptr->back_mesh, PLANE_HSIZE, PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, 0, FIX_ONE); mesh_set_vertex(ptr->back_mesh, -PLANE_HSIZE, PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, FIX_ONE, FIX_ONE); - mesh_set_triangle(ptr->back_mesh, 0, 1, 2); mesh_set_triangle(ptr->back_mesh, 0, 2, 3); + mesh_set_triangle(ptr->back_mesh, 0, 1, 2); + mesh_set_triangle(ptr->back_mesh, 0, 2, 3); mesh_update_bounds(ptr->back_mesh); ptr->top_mesh = new_mesh(); @@ -456,7 +482,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->top_mesh, PLANE_HSIZE, PLANE_HSIZE_LOW, PLANE_HSIZE, 0, -FIX_ONE, 0, 0, FIX_ONE); mesh_set_vertex(ptr->top_mesh, PLANE_HSIZE, PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, -FIX_ONE, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(ptr->top_mesh, -PLANE_HSIZE, PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, -FIX_ONE, 0, FIX_ONE, 0); - mesh_set_triangle(ptr->top_mesh, 0, 1, 2); mesh_set_triangle(ptr->top_mesh, 0, 2, 3); + mesh_set_triangle(ptr->top_mesh, 0, 1, 2); + mesh_set_triangle(ptr->top_mesh, 0, 2, 3); mesh_update_bounds(ptr->top_mesh); ptr->bottom_mesh = new_mesh(); @@ -464,7 +491,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->bottom_mesh, PLANE_HSIZE, -PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, FIX_ONE, 0, FIX_ONE, 0); mesh_set_vertex(ptr->bottom_mesh, PLANE_HSIZE, -PLANE_HSIZE_LOW, PLANE_HSIZE, 0, FIX_ONE, 0, 0, 0); mesh_set_vertex(ptr->bottom_mesh, -PLANE_HSIZE, -PLANE_HSIZE_LOW, PLANE_HSIZE, 0, FIX_ONE, 0, 0, FIX_ONE); - mesh_set_triangle(ptr->bottom_mesh, 0, 1, 2); mesh_set_triangle(ptr->bottom_mesh, 0, 2, 3); + mesh_set_triangle(ptr->bottom_mesh, 0, 1, 2); + mesh_set_triangle(ptr->bottom_mesh, 0, 2, 3); mesh_update_bounds(ptr->bottom_mesh); ptr->left_mesh = new_mesh(); @@ -472,7 +500,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, -PLANE_HSIZE, PLANE_HSIZE, FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, PLANE_HSIZE, PLANE_HSIZE, FIX_ONE, 0, 0, 0, FIX_ONE); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, PLANE_HSIZE, -PLANE_HSIZE, FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); - mesh_set_triangle(ptr->left_mesh, 0, 1, 2); mesh_set_triangle(ptr->left_mesh, 0, 2, 3); + mesh_set_triangle(ptr->left_mesh, 0, 1, 2); + mesh_set_triangle(ptr->left_mesh, 0, 2, 3); mesh_update_bounds(ptr->left_mesh); ptr->right_mesh = new_mesh(); @@ -480,7 +509,8 @@ void compositor_init_background(GF_Compositor *compositor, GF_Node *node) mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, -PLANE_HSIZE, -PLANE_HSIZE, -FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, PLANE_HSIZE, -PLANE_HSIZE, -FIX_ONE, 0, 0, 0, FIX_ONE); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, PLANE_HSIZE, PLANE_HSIZE, -FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); - mesh_set_triangle(ptr->right_mesh, 0, 1, 2); mesh_set_triangle(ptr->right_mesh, 0, 2, 3); + mesh_set_triangle(ptr->right_mesh, 0, 1, 2); + mesh_set_triangle(ptr->right_mesh, 0, 2, 3); mesh_update_bounds(ptr->right_mesh); @@ -509,8 +539,8 @@ void compositor_background_modified(GF_Node *node) if (!st) return; if (!gf_sg_vrml_field_equal(&bck->skyColor, &st->sky_col, GF_SG_VRML_MFCOLOR) - || !gf_sg_vrml_field_equal(&bck->skyAngle, &st->sky_ang, GF_SG_VRML_MFFLOAT) - ) { + || !gf_sg_vrml_field_equal(&bck->skyAngle, &st->sky_ang, GF_SG_VRML_MFFLOAT) + ) { if (st->sky_mesh) mesh_free(st->sky_mesh); st->sky_mesh = NULL; @@ -518,8 +548,8 @@ void compositor_background_modified(GF_Node *node) gf_sg_vrml_field_copy(&st->sky_ang, &bck->skyAngle, GF_SG_VRML_MFFLOAT); } if (!gf_sg_vrml_field_equal(&bck->groundColor, &st->ground_col, GF_SG_VRML_MFCOLOR) - || !gf_sg_vrml_field_equal(&bck->groundAngle, &st->ground_ang, GF_SG_VRML_MFFLOAT) - ) { + || !gf_sg_vrml_field_equal(&bck->groundAngle, &st->ground_ang, GF_SG_VRML_MFFLOAT) + ) { if (st->ground_mesh) mesh_free(st->ground_mesh); st->ground_mesh = NULL; @@ -534,7 +564,7 @@ void compositor_background_modified(GF_Node *node) back_check_gf_sc_texture_change(&st->txh_left, &bck->leftUrl); back_check_gf_sc_texture_change(&st->txh_right, &bck->rightUrl); - + gf_sc_invalidate(st->compositor, NULL); } diff --git a/src/compositor/mpeg4_background2d.c b/src/compositor/mpeg4_background2d.c index 2d8fab7..edf3595 100644 --- a/src/compositor/mpeg4_background2d.c +++ b/src/compositor/mpeg4_background2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -102,7 +102,7 @@ static Bool back_use_texture(M_Background2D *bck) static void DrawBackground2D_2D(DrawableContext *ctx, GF_TraverseState *tr_state) { - Bool clear_all = GF_TRUE; + Bool clear_all = GF_TRUE; u32 color; Background2DStack *stack; if (!ctx || !ctx->drawable || !ctx->drawable->node) return; @@ -118,10 +118,10 @@ static void DrawBackground2D_2D(DrawableContext *ctx, GF_TraverseState *tr_state if (!tr_state->visual->DrawBitmap(tr_state->visual, tr_state, ctx, NULL)) { /*set target rect*/ gf_path_reset(stack->drawable->path); - gf_path_add_rect_center(stack->drawable->path, - ctx->bi->unclip.x + ctx->bi->unclip.width/2, - ctx->bi->unclip.y - ctx->bi->unclip.height/2, - ctx->bi->unclip.width, ctx->bi->unclip.height); + gf_path_add_rect_center(stack->drawable->path, + ctx->bi->unclip.x + ctx->bi->unclip.width/2, + ctx->bi->unclip.y - ctx->bi->unclip.height/2, + ctx->bi->unclip.width, ctx->bi->unclip.height); /*draw texture*/ visual_2d_texture_path(tr_state->visual, stack->drawable->path, ctx, tr_state); @@ -143,14 +143,14 @@ static void DrawBackground2D_2D(DrawableContext *ctx, GF_TraverseState *tr_state if (clear_all && !tr_state->visual->offscreen && tr_state->visual->compositor->hybrid_opengl) { if (ctx->flags & CTX_BACKROUND_NOT_LAYER) { color &= 0x00FFFFFF; - tr_state->visual->ClearSurface(tr_state->visual, NULL, color); + compositor_2d_hybgl_clear_surface_ex(tr_state->visual, NULL, color, GF_FALSE); clear_all = GF_FALSE; } } #endif /*direct drawing, draw without clippers */ if (tr_state->immediate_draw - ) { + ) { /*directly clear with specified color*/ if (clear_all) tr_state->visual->ClearSurface(tr_state->visual, &ctx->bi->clip, color); @@ -190,32 +190,27 @@ static Bool back_texture_enabled(M_Background2D *bck, GF_TextureHandler *txh) static void DrawBackground2D_3D(M_Background2D *bck, Background2DStack *st, GF_TraverseState *tr_state) { - GF_Matrix mx; + GF_Matrix mx, bck_mx, bck_mx_cam; Bool use_texture; use_texture = back_texture_enabled(bck, &st->txh); visual_3d_set_background_state(tr_state->visual, 1); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_push(tr_state->visual); - -/* visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_TEXTURE); - gf_sc_texture_get_transform(&st->txh, NULL, &mx, 0); - visual_3d_matrix_load(tr_state->visual, mx.m); -*/ + gf_mx_copy(bck_mx_cam, tr_state->camera->modelview); + gf_mx_copy(bck_mx, tr_state->model_matrix); /*little opt: if we clear the main visual clear it entirely */ if (! tr_state->is_layer) { visual_3d_clear(tr_state->visual, bck->backColor, FIX_ONE); if (!use_texture) { - visual_3d_matrix_pop(tr_state->visual); visual_3d_set_background_state(tr_state->visual, 0); return; } /*we need a hack here because main vp is always traversed before main background, and in the case of a 2D viewport it modifies the modelview matrix, which we don't want ...*/ - visual_3d_matrix_reset(tr_state->visual); + gf_mx_init(tr_state->model_matrix); + gf_mx_init(tr_state->camera->modelview); } if (!use_texture || (!tr_state->is_layer && st->txh.transparent) ) visual_3d_set_material_2d(tr_state->visual, bck->backColor, FIX_ONE); if (use_texture) { @@ -231,7 +226,8 @@ static void DrawBackground2D_3D(M_Background2D *bck, Background2DStack *st, GF_T mesh_set_vertex(st->mesh, B2D_PLANE_HSIZE, -B2D_PLANE_HSIZE, 0, 0, 0, FIX_ONE, FIX_ONE, 0); mesh_set_vertex(st->mesh, B2D_PLANE_HSIZE, B2D_PLANE_HSIZE, 0, 0, 0, FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_vertex(st->mesh, -B2D_PLANE_HSIZE, B2D_PLANE_HSIZE, 0, 0, 0, FIX_ONE, 0, FIX_ONE); - mesh_set_triangle(st->mesh, 0, 1, 2); mesh_set_triangle(st->mesh, 0, 2, 3); + mesh_set_triangle(st->mesh, 0, 1, 2); + mesh_set_triangle(st->mesh, 0, 2, 3); st->mesh->flags |= MESH_IS_2D; } @@ -239,7 +235,7 @@ static void DrawBackground2D_3D(M_Background2D *bck, Background2DStack *st, GF_T if (tr_state->camera->is_3D) { Fixed sx, sy; /*reset matrix*/ - visual_3d_matrix_reset(tr_state->visual); + gf_mx_init(tr_state->model_matrix); sx = sy = 2 * gf_mulfix(gf_tan(tr_state->camera->fieldOfView/2), tr_state->camera->z_far); if (tr_state->camera->width > tr_state->camera->height) { sx = gf_muldiv(sx, tr_state->camera->width, tr_state->camera->height); @@ -253,9 +249,9 @@ static void DrawBackground2D_3D(M_Background2D *bck, Background2DStack *st, GF_T gf_mx_add_translation(&mx, 0, 0, -0.995f*tr_state->camera->z_far); #endif } else { - gf_mx_add_scale(&mx, tr_state->bbox.max_edge.x - tr_state->bbox.min_edge.x, - tr_state->bbox.max_edge.y - tr_state->bbox.min_edge.y, - FIX_ONE); + gf_mx_add_scale(&mx, tr_state->bbox.max_edge.x - tr_state->bbox.min_edge.x, + tr_state->bbox.max_edge.y - tr_state->bbox.min_edge.y, + FIX_ONE); /*when in layer2D, DON'T MOVE BACKGROUND TO ZFAR*/ if (!tr_state->is_layer) { Fixed tr; @@ -268,14 +264,16 @@ static void DrawBackground2D_3D(M_Background2D *bck, Background2DStack *st, GF_T gf_mx_add_translation(&mx, 0, 0, tr); } } - visual_3d_matrix_add(tr_state->visual, mx.m); + gf_mx_add_matrix(&tr_state->model_matrix, &mx); visual_3d_mesh_paint(tr_state, st->mesh); if (tr_state->mesh_num_textures) { gf_sc_texture_disable(&st->txh); tr_state->mesh_num_textures = 0; } - visual_3d_matrix_pop(tr_state->visual); + gf_mx_copy(tr_state->model_matrix, bck_mx); + gf_mx_copy(tr_state->camera->modelview, bck_mx_cam); + visual_3d_set_background_state(tr_state->visual, 0); } #endif @@ -295,7 +293,7 @@ static void TraverseBackground2D(GF_Node *node, void *rs, Bool is_destroy) bck = (M_Background2D *)node; - /*special case for background in Layer2D: the background is seen as a regular drawable, so + /*special case for background in Layer2D: the background is seen as a regular drawable, so RENDER_BINDABLE is not used*/ switch (tr_state->traversing_mode) { case TRAVERSE_DRAW_2D: @@ -345,17 +343,18 @@ static void TraverseBackground2D(GF_Node *node, void *rs, Bool is_destroy) status->ctx.aspect.fill_color = col; stack->flags |= CTX_APP_DIRTY; } - } + } if (back_use_texture(bck) ) { - if (stack->txh.tx_io && !(status->ctx.flags & CTX_APP_DIRTY) && stack->txh.needs_refresh) { - stack->flags |= CTX_TEXTURE_DIRTY; - } #ifndef GPAC_DISABLE_3D - if (stack->txh.compositor->hybrid_opengl && !tr_state->visual->offscreen) { + if (stack->txh.compositor->hybrid_opengl && !tr_state->visual->offscreen && stack->hybgl_init) { stack->flags |= CTX_HYBOGL_NO_CLEAR; } + stack->hybgl_init = 1; #endif + if (stack->txh.tx_io && !(status->ctx.flags & CTX_APP_DIRTY) && stack->txh.needs_refresh) { + stack->flags |= CTX_TEXTURE_DIRTY; + } } status->ctx.flags = stack->flags; @@ -401,7 +400,7 @@ static void UpdateBackgroundTexture(GF_TextureHandler *txh) { gf_sc_texture_update_frame(txh, 0); /*restart texture if needed (movie background controled by MediaControl)*/ - if (txh->stream_finished && gf_mo_get_loop(txh->stream, 0)) + if (txh->stream_finished && gf_mo_get_loop(txh->stream, 0)) gf_sc_texture_restart(txh); } @@ -444,7 +443,7 @@ void compositor_background2d_modified(GF_Node *node) return; } /*if not open and changed play*/ - if (bck->url.count) + if (bck->url.count) gf_sc_texture_play(&st->txh, &bck->url); gf_sc_invalidate(st->txh.compositor, NULL); } @@ -454,7 +453,7 @@ Bool compositor_background_transparent(GF_Node *node) if (node && (gf_node_get_tag(node) == TAG_MPEG4_Background2D)) { Background2DStack *st; if (!((M_Background2D *)node)->isBound) return 1; - + st = (Background2DStack *) gf_node_get_private(node); if (st->txh.transparent) return 1; return 0; diff --git a/src/compositor/mpeg4_bitmap.c b/src/compositor/mpeg4_bitmap.c index ac53c18..dc65c90 100644 --- a/src/compositor/mpeg4_bitmap.c +++ b/src/compositor/mpeg4_bitmap.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,9 +56,9 @@ static void Bitmap_BuildGraph(GF_Node *node, BitmapStack *st, GF_TraverseState * /*bitmap not ready*/ if (!txh || !txh->width || !txh->height #ifndef GPAC_DISABLE_3D - || (tr_state->visual->type_3d && !txh->tx_io) + || (tr_state->visual->type_3d && !txh->tx_io) #endif - ) { + ) { if (notify_changes) gf_node_dirty_set(node, 0, 1); return; } @@ -71,8 +71,10 @@ static void Bitmap_BuildGraph(GF_Node *node, BitmapStack *st, GF_TraverseState * st->prev_tx_w = txh->width; st->prev_tx_h = txh->height; - sx = bmp->scale.x; if (sx<0) sx = FIX_ONE; - sy = bmp->scale.y; if (sy<0) sy = FIX_ONE; + sx = bmp->scale.x; + if (sx<0) sx = FIX_ONE; + sy = bmp->scale.y; + if (sy<0) sy = FIX_ONE; compositor_adjust_scale(txh->owner, &sx, &sy); @@ -96,7 +98,7 @@ static void Bitmap_BuildGraph(GF_Node *node, BitmapStack *st, GF_TraverseState * gf_node_dirty_clear(node, 0); - if ((st->size.x==size.x) && (st->size.y==size.y)) return; + if ((st->size.x==size.x) && (st->size.y==size.y)) return; st->size = size; /*change in size*/ @@ -198,13 +200,13 @@ static void TraverseBitmap(GF_Node *node, void *rs, Bool is_destroy) vrml_drawable_pick(st->graph, tr_state); return; case TRAVERSE_GET_BOUNDS: - Bitmap_BuildGraph(node, st, tr_state, &tr_state->bounds, + Bitmap_BuildGraph(node, st, tr_state, &tr_state->bounds, #ifndef GPAC_DISABLE_3D - tr_state->visual->type_3d ? 1 : 0 + tr_state->visual->type_3d ? 1 : 0 #else - 0 + 0 #endif - ); + ); return; case TRAVERSE_SORT: @@ -246,7 +248,7 @@ static void TraverseBitmap(GF_Node *node, void *rs, Bool is_destroy) } ctx->flags |= CTX_IS_TRANSPARENT; } - } + } else if (!tr_state->color_mat.identity) { ctx->flags |= CTX_IS_TRANSPARENT; } else { @@ -257,7 +259,7 @@ static void TraverseBitmap(GF_Node *node, void *rs, Bool is_destroy) } } - /*bounds are stored when building graph*/ + /*bounds are stored when building graph*/ drawable_finalize_sort(ctx, tr_state, &rc); } diff --git a/src/compositor/mpeg4_composite.c b/src/compositor/mpeg4_composite.c index b2fda12..2739c7a 100644 --- a/src/compositor/mpeg4_composite.c +++ b/src/compositor/mpeg4_composite.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -157,7 +157,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f case TAG_MPEG4_CompositeTexture3D: { M_CompositeTexture3D*c3d = (M_CompositeTexture3D*)n; - if (force_check || gf_node_dirty_get(c3d->background)) { gf_node_traverse(c3d->background, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c3d->background)) { + gf_node_traverse(c3d->background, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->backgrounds, 0); if (btop != c3d->background) { gf_node_unregister(c3d->background, n); @@ -166,7 +169,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f gf_node_event_out_str(n, "background"); ret = 1; } - if (force_check || gf_node_dirty_get(c3d->viewpoint)) { gf_node_traverse(c3d->viewpoint, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c3d->viewpoint)) { + gf_node_traverse(c3d->viewpoint, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->viewpoints, 0); if (btop != c3d->viewpoint) { gf_node_unregister(c3d->viewpoint, n); @@ -176,7 +182,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f ret = 1; } - if (force_check || gf_node_dirty_get(c3d->fog)) { gf_node_traverse(c3d->fog, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c3d->fog)) { + gf_node_traverse(c3d->fog, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->fogs, 0); if (btop != c3d->fog) { gf_node_unregister(c3d->fog, n); @@ -186,7 +195,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f ret = 1; } - if (force_check || gf_node_dirty_get(c3d->navigationInfo)) { gf_node_traverse(c3d->navigationInfo, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c3d->navigationInfo)) { + gf_node_traverse(c3d->navigationInfo, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->navigations, 0); if (btop != c3d->navigationInfo) { gf_node_unregister(c3d->navigationInfo, n); @@ -201,7 +213,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f case TAG_MPEG4_CompositeTexture2D: { M_CompositeTexture2D *c2d = (M_CompositeTexture2D*)n; - if (force_check || gf_node_dirty_get(c2d->background)) { gf_node_traverse(c2d->background, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c2d->background)) { + gf_node_traverse(c2d->background, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->backgrounds, 0); if (btop != c2d->background) { gf_node_unregister(c2d->background, n); @@ -211,7 +226,10 @@ static Bool composite_do_bindable(GF_Node *n, GF_TraverseState *tr_state, Bool f ret = 1; } - if (force_check || gf_node_dirty_get(c2d->viewport)) { gf_node_traverse(c2d->viewport, tr_state); ret = 1; } + if (force_check || gf_node_dirty_get(c2d->viewport)) { + gf_node_traverse(c2d->viewport, tr_state); + ret = 1; + } btop = (GF_Node*)gf_list_get(tr_state->viewpoints, 0); if (btop != c2d->viewport) { gf_node_unregister(c2d->viewport, n); @@ -242,12 +260,12 @@ static void composite_update(GF_TextureHandler *txh) if (st->unsupported) return; -/* - if (compositor->recompute_ar) { - gf_node_dirty_set(txh->owner, 0, 0); - return; - } -*/ + /* + if (compositor->recompute_ar) { + gf_node_dirty_set(txh->owner, 0, 0); + return; + } + */ if (!compositor->rebuild_offscreen_textures && (!compositor->text_edit_changed || !st->visual->has_text_edit ) && !gf_node_dirty_get(txh->owner)) { txh->needs_refresh = 0; return; @@ -338,9 +356,9 @@ static void composite_update(GF_TextureHandler *txh) /*rebuild stencil*/ if (!txh->tx_io - || (w != (s32) txh->width) || ( h != (s32) txh->height) - || (new_pixel_format != txh->pixelformat) - ) { + || (w != (s32) txh->width) || ( h != (s32) txh->height) + || (new_pixel_format != txh->pixelformat) + ) { Bool needs_stencil = 1; if (txh->tx_io) { @@ -348,7 +366,7 @@ static void composite_update(GF_TextureHandler *txh) if (st->tgl_ctx) ostgl_delete_context(st->tgl_ctx); #endif gf_sc_texture_release(txh); - if (txh->data) + if (txh->data) gf_free(txh->data); txh->data = NULL; } @@ -356,9 +374,9 @@ static void composite_update(GF_TextureHandler *txh) /*we don't use rect ext because of no support for texture transforms*/ if (1 #ifndef GPAC_DISABLE_3D - || compositor->gl_caps.npot_texture + || compositor->gl_caps.npot_texture #endif - ) { + ) { st->txh.width = w; st->txh.height = h; st->sx = st->sy = FIX_ONE; @@ -436,7 +454,7 @@ static void composite_update(GF_TextureHandler *txh) if (needs_stencil) { txh->data = (char*)gf_malloc(sizeof(unsigned char) * txh->stride * txh->height); memset(txh->data, 0, sizeof(unsigned char) * txh->stride * txh->height); - + /*set stencil texture - we don't check error as an image could not be supported by the rasterizer but still supported by the blitter (case of RGBD/RGBDS)*/ raster->stencil_set_texture(stencil, txh->data, txh->width, txh->height, txh->stride, txh->pixelformat, txh->pixelformat, 0); @@ -487,7 +505,7 @@ static void composite_update(GF_TextureHandler *txh) txh->transparent = (st->visual->last_had_back==2) ? 0 : 1; - if (!compositor->edited_text && st->visual->has_text_edit) + if (!compositor->edited_text && st->visual->has_text_edit) st->visual->has_text_edit = 0; @@ -662,8 +680,8 @@ Bool compositor_compositetexture_handle_event(GF_Compositor *compositor, GF_Node stack = gf_node_get_private(ap->texture); if (!stack->txh.tx_io) return 0; - tr_state = NULL; - children = NULL; + tr_state = NULL; + children = NULL; if (!is_flush) { @@ -674,8 +692,10 @@ Bool compositor_compositetexture_handle_event(GF_Compositor *compositor, GF_Node /*tx coords are inverted when mapping, thus applying directly the matrix will give us the untransformed coords*/ gf_mx_apply_vec(&mx, &txcoord); - while (txcoord.x<0) txcoord.x += FIX_ONE; while (txcoord.x>FIX_ONE) txcoord.x -= FIX_ONE; - while (txcoord.y<0) txcoord.y += FIX_ONE; while (txcoord.y>FIX_ONE) txcoord.y -= FIX_ONE; + while (txcoord.x<0) txcoord.x += FIX_ONE; + while (txcoord.x>FIX_ONE) txcoord.x -= FIX_ONE; + while (txcoord.y<0) txcoord.y += FIX_ONE; + while (txcoord.y>FIX_ONE) txcoord.y -= FIX_ONE; } /*convert to tx space*/ @@ -696,10 +716,10 @@ Bool compositor_compositetexture_handle_event(GF_Compositor *compositor, GF_Node #ifndef GPAC_DISABLE_3D gf_mx_init(tr_state->model_matrix); #endif - /*collect sensors*/ + /*collect sensors but not anchors*/ l = children = ((M_CompositeTexture2D*)ap->texture)->children; while (l) { - GF_SensorHandler *hsens = compositor_mpeg4_get_sensor_handler(l->node); + GF_SensorHandler *hsens = compositor_mpeg4_get_sensor_handler_ex(l->node, GF_TRUE); if (hsens) gf_list_add(tr_state->vrml_sensors, hsens); l = l->next; } @@ -727,7 +747,7 @@ Bool compositor_compositetexture_handle_event(GF_Compositor *compositor, GF_Node world_pt = compositor->hit_world_point; gf_mx_copy(l2w_mx, compositor->hit_local_to_world); gf_mx_copy(w2l_mx, compositor->hit_world_to_local); - + if (compositor->text_selection) had_text_sel=1; if (is_flush) { @@ -821,11 +841,11 @@ Bool compositor_is_composite_texture(GF_Node *appear) u32 tag; if (!appear) return 0; tag = gf_node_get_tag(appear); - if ((tag==TAG_MPEG4_Appearance) + if ((tag==TAG_MPEG4_Appearance) #ifndef GPAC_DISABLE_X3D - || (tag==TAG_X3D_Appearance) + || (tag==TAG_X3D_Appearance) #endif - ) { + ) { M_Appearance *ap = (M_Appearance *)appear; if (!ap->texture) return 0; switch (gf_node_get_tag(((M_Appearance *)appear)->texture)) { diff --git a/src/compositor/mpeg4_form.c b/src/compositor/mpeg4_form.c index 8877736..4223e98 100644 --- a/src/compositor/mpeg4_form.c +++ b/src/compositor/mpeg4_form.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -324,7 +324,7 @@ static void TraverseForm(GF_Node *n, void *rs, Bool is_destroy) } /*check picking*/ - if ((tr_state->traversing_mode==TRAVERSE_PICK) && !gf_sc_pick_in_clipper(tr_state, &st->clip)) + if ((tr_state->traversing_mode==TRAVERSE_PICK) && !gf_sc_pick_in_clipper(tr_state, &st->clip)) return; #if !FORM_CLIPS @@ -349,11 +349,11 @@ static void TraverseForm(GF_Node *n, void *rs, Bool is_destroy) while ((cg = gf_list_enum(st->groups, &i))) { parent_node_child_traverse(cg, tr_state); } - + tr_state->visual->top_clipper = prev_clip; if (had_clip) tr_state->clipper = prev_clipper; tr_state->has_clip = had_clip; - } else + } else #endif { i=0; @@ -408,9 +408,9 @@ static void shin_apply(FormStack *st, u32 *group_idx, u32 count) if (!i) { form_get_group(st, group_idx[0])->final.x = st->clip.x + inter_space; } else { - form_get_group(st, group_idx[i])->final.x = - form_get_group(st, group_idx[i-1])->final.x + form_get_group(st, group_idx[i-1])->final.width - + inter_space; + form_get_group(st, group_idx[i])->final.x = + form_get_group(st, group_idx[i-1])->final.x + form_get_group(st, group_idx[i-1])->final.width + + inter_space; } fg_update_bounds(form_get_group(st, group_idx[i])); } @@ -433,8 +433,8 @@ static void sh_apply(FormStack *st, Fixed space, u32 *group_idx, u32 count) inter_space /= (count-1); } else { inter_space = space; - } - + } + k = count - 1; if (space != -1) k += 1; for (i=1; iclip.height; len = 0; - for (i=0; ifinal.height; len++; @@ -462,15 +462,15 @@ static void svin_apply(FormStack *st, u32 *group_idx, u32 count) } inter_space -= tot_len; inter_space /= (len+1); - + for (i=0; ifinal.y = st->clip.y - inter_space; } else { form_get_group(st, group_idx[i])->final.y = - form_get_group(st, group_idx[i-1])->final.y - form_get_group(st, group_idx[i-1])->final.height - - inter_space; + form_get_group(st, group_idx[i-1])->final.y - form_get_group(st, group_idx[i-1])->final.height - + inter_space; } fg_update_bounds(form_get_group(st, group_idx[i])); } @@ -493,8 +493,8 @@ static void sv_apply(FormStack *st, Fixed space, u32 *group_idx, u32 count) for (i=1; ifinal.height; inter_space -= tot_len; inter_space /= count-1; - } - + } + k = count-1; if (space > -1) k += 1; for (i=1; ifinal; max_x = rc->x + rc->width; - + if(space>-FIX_ONE) { max_x -= space; start = 1; diff --git a/src/compositor/mpeg4_geometry_2d.c b/src/compositor/mpeg4_geometry_2d.c index 47c56b9..11d9496 100644 --- a/src/compositor/mpeg4_geometry_2d.c +++ b/src/compositor/mpeg4_geometry_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -38,7 +38,8 @@ Bool compositor_get_2d_plane_intersection(GF_Ray *ray, SFVec3f *res) res->z = 0; return 1; } - p.normal.x = p.normal.y = 0; p.normal.z = FIX_ONE; + p.normal.x = p.normal.y = 0; + p.normal.z = FIX_ONE; p.d = 0; t2 = gf_vec_dot(p.normal, ray->dir); if (t2 == 0) return 0; @@ -263,11 +264,11 @@ static void compositor_2d_draw_rectangle(GF_TraverseState *tr_state) { DrawableContext *ctx = tr_state->ctx; - if (ctx->aspect.fill_texture && ctx->aspect.fill_texture->data + if (ctx->aspect.fill_texture && ctx->aspect.fill_texture->data #ifndef GPAC_DISABLE_3D - && !tr_state->visual->compositor->hybrid_opengl + && !tr_state->visual->compositor->hybrid_opengl #endif - ) { + ) { Bool res; /*get image size WITHOUT line size or antialias margin*/ diff --git a/src/compositor/mpeg4_geometry_3d.c b/src/compositor/mpeg4_geometry_3d.c index 90ee5ac..a6f94a0 100644 --- a/src/compositor/mpeg4_geometry_3d.c +++ b/src/compositor/mpeg4_geometry_3d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -304,12 +304,12 @@ void compositor_init_extrusion(GF_Compositor *compositor, GF_Node *node) /* NonLinearDeformer - NOTE: AFX spec is just hmm, well, hmm. NonLinearDeformer.extend interpretation differ from type to + NOTE: AFX spec is just hmm, well, hmm. NonLinearDeformer.extend interpretation differ from type to type within the spec, and between the spec and the ref soft. This is GPAC interpretation * all params are specified with default transform axis (Z axis) * NLD.type = 0 (taper): * taping radius = NLD.param - * extend = N * [diff, perc] with + * extend = N * [diff, perc] with - diff : relative position along taper axis (for default, diff=0: z min, diff=1: z max) - perc: mult ratio for base taper radius extend works like key/keyValue for a scalar interpolator @@ -317,7 +317,7 @@ void compositor_init_extrusion(GF_Compositor *compositor, GF_Node *node) * NLD.type = 1 (twister): * twisting angle = NLD.param - * extend = N * [diff, perc] with + * extend = N * [diff, perc] with - diff : relative position along twister axis (for default, diff=0: z min, diff=1: z max) - perc: mult ratio for base twister angle extend works like key/keyValue for a scalar interpolator @@ -325,14 +325,14 @@ void compositor_init_extrusion(GF_Compositor *compositor, GF_Node *node) * NLD.type = 2 (bender): * bending curvature = NLD.param - * extend = N * [diff, perc] with + * extend = N * [diff, perc] with - diff : relative position along bender axis (for default, diff=0: z min, diff=1: z max) - perc: mult ratio for base bender curvature extend works like key/keyValue for a scalar interpolator final curvature: c(z) = LinearInterp(extend[min key], extend[min key + 1]) * param Another pb of NLD is that the spec says nothing about object/axis alignment: should we center - the object at 0,0,0 (local coords) or not? the results are quite different. Here we don't + the object at 0,0,0 (local coords) or not? the results are quite different. Here we don't recenter the object before transform */ @@ -345,7 +345,8 @@ static Bool NLD_GetMatrix(M_NonLinearDeformer *nld, GF_Matrix *mx) /*compute rotation matrix from NLD axis to 0 0 1*/ v1 = nld->axis; gf_vec_norm(&v1); - v2.x = v2.y = 0; v2.z = FIX_ONE; + v2.x = v2.y = 0; + v2.z = FIX_ONE; if (gf_vec_equal(v1, v2)) return 0; l1 = gf_vec_len(v1); @@ -373,7 +374,7 @@ static GFINLINE void NLD_GetKey(M_NonLinearDeformer *nld, Fixed frac, Fixed *f_m if (frac>=nld->extend.vals[i]) { *f_min = nld->extend.vals[i]; *min = nld->extend.vals[i+1]; - } + } if ((i+2extend.vals[i+2])) { *f_max = nld->extend.vals[i+2]; *max = nld->extend.vals[i+3]; @@ -399,7 +400,7 @@ static void NLD_Apply(M_NonLinearDeformer *nld, GF_Mesh *mesh) param = nld->param; if (!param) param = 1; - + if (mesh->bounds.min_edge.z == mesh->bounds.max_edge.z) return; z_min = FIX_MAX; @@ -418,7 +419,7 @@ static void NLD_Apply(M_NonLinearDeformer *nld, GF_Mesh *mesh) z_min = mesh->bounds.min_edge.z; z_max = mesh->bounds.max_edge.z; } - + for (i=0; iv_count; i++) { SFVec3f old = mesh->vertices[i].pos; frac = gf_divfix(old.z - z_min, z_max - z_min); diff --git a/src/compositor/mpeg4_geometry_ifs2d.c b/src/compositor/mpeg4_geometry_ifs2d.c index 7970308..58dd9e7 100644 --- a/src/compositor/mpeg4_geometry_ifs2d.c +++ b/src/compositor/mpeg4_geometry_ifs2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -94,7 +94,7 @@ static void IFS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) M_IndexedFaceSet2D *ifs2D = (M_IndexedFaceSet2D *)node; M_Coordinate2D *coord = (M_Coordinate2D*) ifs2D->coord; M_Color *color = (M_Color *) ifs2D->color; - + col.red = col.green = col.blue = 0; /*simple case, no color specified*/ if (!ifs2D->color) { @@ -134,7 +134,7 @@ static void IFS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) gf_path_add_move_to(path, start.x, start.y); i++; - while (ifs2D->coordIndex.vals[i] != -1) { + while (ifs2D->coordIndex.vals[i] != -1) { start = pts[ifs2D->coordIndex.vals[i]]; gf_path_add_line_to(path, start.x, start.y); i++; @@ -187,7 +187,7 @@ static void IFS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) gf_path_add_move_to(path, start.x, start.y); num_col = 1; i+=1; - while (ifs2D->coordIndex.vals[i] != -1) { + while (ifs2D->coordIndex.vals[i] != -1) { end = pts[ifs2D->coordIndex.vals[i]]; gf_path_add_line_to(path, end.x, end.y); i++; @@ -229,7 +229,7 @@ static void IFS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) raster->stencil_set_vertex_colors(grad, colors, num_col); gf_free(colors); - + col_cen.blue /= num_col; col_cen.green /= num_col; col_cen.red /= num_col; @@ -246,7 +246,7 @@ static void IFS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) //goto next point i++; - ind_col += num_col + 1; + ind_col += num_col + 1; if (i >= ci_count) break; grad = raster->stencil_new(raster, GF_STENCIL_VERTEX_GRADIENT); ctx->flags &= ~CTX_PATH_FILLED; @@ -298,7 +298,7 @@ static void TraverseIFS2D(GF_Node *node, void *rs, Bool is_destroy) visual_3d_draw_2d_with_aspect(stack, tr_state, &asp); } return; - } + } #endif case TRAVERSE_PICK: vrml_drawable_pick(stack, tr_state); diff --git a/src/compositor/mpeg4_geometry_ils2d.c b/src/compositor/mpeg4_geometry_ils2d.c index df4014a..66f3f38 100644 --- a/src/compositor/mpeg4_geometry_ils2d.c +++ b/src/compositor/mpeg4_geometry_ils2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -191,7 +191,8 @@ static void ILS2D_Draw(GF_Node *node, GF_TraverseState *tr_state) col = color->color.vals[col_ind+1]; linear[1] = GF_COL_ARGB_FIXED(alpha, col.red, col.green, col.blue); } - pos[0] = 0; pos[1] = FIX_ONE; + pos[0] = 0; + pos[1] = FIX_ONE; raster->stencil_set_linear_gradient(grad, start.x, start.y, end.x, end.y); raster->stencil_set_gradient_interpolation(grad, pos, linear, 2); } else { diff --git a/src/compositor/mpeg4_gradients.c b/src/compositor/mpeg4_gradients.c index ba2b2ba..de2801b 100644 --- a/src/compositor/mpeg4_gradients.c +++ b/src/compositor/mpeg4_gradients.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,15 +58,19 @@ void GradientGetMatrix(GF_Node *transform, GF_Matrix2D *mat) gf_mx2d_add_rotation(mat, tr->center.x, tr->center.y, tr->rotationAngle); gf_mx2d_add_translation(mat, tr->translation.x, tr->translation.y); } - break; + break; case TAG_MPEG4_TransformMatrix2D: { M_TransformMatrix2D *tm = (M_TransformMatrix2D*)transform; gf_mx2d_init(*mat); - mat->m[0] = tm->mxx; mat->m[1] = tm->mxy; mat->m[2] = tm->tx; - mat->m[3] = tm->myx; mat->m[4] = tm->myy; mat->m[5] = tm->ty; + mat->m[0] = tm->mxx; + mat->m[1] = tm->mxy; + mat->m[2] = tm->tx; + mat->m[3] = tm->myx; + mat->m[4] = tm->myy; + mat->m[5] = tm->ty; } - break; + break; default: break; } @@ -173,7 +177,7 @@ static void BuildLinearGradientTexture(GF_TextureHandler *txh) if (!(txh->flags & GF_SR_TEXTURE_GRAD_REGISTERED)) { txh->flags |= GF_SR_TEXTURE_GRAD_REGISTERED; - if (gf_list_find(txh->compositor->textures, txh)<0) + if (gf_list_find(txh->compositor->textures, txh)<0) gf_list_insert(txh->compositor->textures, txh, 0); } @@ -189,7 +193,7 @@ static void BuildLinearGradientTexture(GF_TextureHandler *txh) end = lg->endPoint; transparent = (lg->opacity.count==1) ? (lg->opacity.vals[0]!=FIX_ONE) : 1; - + /*init our 2D graphics stuff*/ texture2D = raster->stencil_new(raster, GF_STENCIL_TEXTURE); if (!texture2D) return; @@ -204,7 +208,7 @@ static void BuildLinearGradientTexture(GF_TextureHandler *txh) gf_free(st->tx_data); st->tx_data = NULL; } - + if (transparent) { if (!st->tx_data) { st->tx_data = (char *) gf_malloc(sizeof(char)*GRAD_TEXTURE_SIZE*GRAD_TEXTURE_SIZE*4); @@ -327,13 +331,13 @@ void compositor_init_linear_gradient(GF_Compositor *compositor, GF_Node *node) GF_SAFEALLOC(st, GradientStack); /*!!! Gradients are textures but are not registered as textures with the compositor in order to avoid updating - too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order + too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order to release associated HW resource when no longer used*/ st->txh.owner = node; st->txh.compositor = compositor; st->txh.update_texture_fcnt = UpdateLinearGradient; st->txh.compute_gradient_matrix = LG_ComputeMatrix; - + gf_node_set_private(node, st); gf_node_set_callback_function(node, DestroyGradient); } @@ -362,7 +366,7 @@ static void BuildRadialGradientTexture(GF_TextureHandler *txh) if (!(txh->flags & GF_SR_TEXTURE_GRAD_REGISTERED)) { txh->flags |= GF_SR_TEXTURE_GRAD_REGISTERED; - if (gf_list_find(txh->compositor->textures, txh)<0) + if (gf_list_find(txh->compositor->textures, txh)<0) gf_list_insert(txh->compositor->textures, txh, 0); } @@ -375,7 +379,7 @@ static void BuildRadialGradientTexture(GF_TextureHandler *txh) if (rg->key.count != rg->keyValue.count) return; transparent = (rg->opacity.count==1) ? ((rg->opacity.vals[0]!=FIX_ONE) ? 1 : 0) : 1; - + /*init our 2D graphics stuff*/ texture2D = raster->stencil_new(raster, GF_STENCIL_TEXTURE); if (!texture2D) return; @@ -390,7 +394,7 @@ static void BuildRadialGradientTexture(GF_TextureHandler *txh) gf_free(st->tx_data); st->tx_data = NULL; } - + if (transparent) { if (!st->tx_data) { st->tx_data = (char *) gf_malloc(sizeof(char)*GRAD_TEXTURE_SIZE*GRAD_TEXTURE_SIZE*4); @@ -591,7 +595,7 @@ void compositor_init_radial_gradient(GF_Compositor *compositor, GF_Node *node) GF_SAFEALLOC(st, GradientStack); /*!!! Gradients are textures but are not registered as textures with the compositor in order to avoid updating - too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order + too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order to release associated HW resource when no longer used*/ st->txh.owner = node; st->txh.compositor = compositor; diff --git a/src/compositor/mpeg4_grouping.c b/src/compositor/mpeg4_grouping.c index 4286683..158877e 100644 --- a/src/compositor/mpeg4_grouping.c +++ b/src/compositor/mpeg4_grouping.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -53,11 +53,11 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t but still mark the group as empty*/ group->bounds.width = 0; /*special case for anchor which is a parent node acting as a sensor*/ - if ((ntag==TAG_MPEG4_Anchor) + if ((ntag==TAG_MPEG4_Anchor) #ifndef GPAC_DISABLE_X3D - || (ntag==TAG_X3D_Anchor) + || (ntag==TAG_X3D_Anchor) #endif - ) { + ) { GF_SensorHandler *gf_sc_anchor_get_handler(GF_Node *n); hsens = gf_sc_anchor_get_handler(node); @@ -69,7 +69,7 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t } else { child = ((GF_ParentNode *)node)->children; while (child) { - hsens = compositor_mpeg4_get_sensor_handler(child->node); + hsens = compositor_mpeg4_get_sensor_handler_ex(child->node, GF_TRUE); if (hsens) { if (!group->sensors) group->sensors = gf_list_new(); gf_list_add(group->sensors, hsens); @@ -92,7 +92,7 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t /*now here is the trick: ExternProtos may not be loaded at this point, in which case we can't perform proper culling. Unloaded ExternProto signal themselves by invalidating their parent - graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing + graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing bounds otherwise we'll never re-invalidate the subgraph anymore*/ gf_node_dirty_clear(node, GF_SG_CHILD_DIRTY); @@ -122,13 +122,13 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t tr_state->bounds.width = tr_state->bounds.height = 0; #ifndef GPAC_DISABLE_3D tr_state->bbox.is_set = 0; -#endif +#endif while (child) { gf_node_traverse(child->node, tr_state); if (tr_state->disable_cull) { group->flags |= GROUP_SKIP_CULLING; tr_state->disable_cull = 0; - } + } /*handle 3D nodes in 2D groups*/ #ifndef GPAC_DISABLE_3D if (tr_state->bbox.is_set) { @@ -143,7 +143,7 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t tr_state->bounds = group->bounds; - if (group->flags & GROUP_SKIP_CULLING) + if (group->flags & GROUP_SKIP_CULLING) tr_state->disable_cull = 1; tr_state->text_split_mode = backup; } @@ -169,10 +169,10 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t gf_node_traverse(child->node, tr_state); child = child->next; #ifdef GF_SR_USE_VIDEO_CACHE - if (tr_state->cache_too_small) + if (tr_state->cache_too_small) cache_too_small++; #endif - } + } tr_state->invalidate_all = prev_inv; @@ -180,7 +180,7 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t if (cache_too_small) { tr_state->cache_too_small = 1; } else { - /*get the traversal time for each group*/ + /*get the traversal time for each group*/ traverse_time = gf_sys_clock() - traverse_time; group->traverse_time += traverse_time; /*record the traversal information and turn cache on if possible*/ @@ -195,7 +195,7 @@ void group_2d_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseState *t while (child) { gf_node_traverse(child->node, tr_state); child = child->next; - } + } } @@ -225,11 +225,11 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave group->flags &= ~GROUP_HAS_SENSORS; drawable_reset_group_highlight(tr_state, node); /*special case for anchor which is a parent node acting as a sensor*/ - if ((ntag==TAG_MPEG4_Anchor) + if ((ntag==TAG_MPEG4_Anchor) #ifndef GPAC_DISABLE_X3D - || (ntag==TAG_X3D_Anchor) + || (ntag==TAG_X3D_Anchor) #endif - ) { + ) { GF_SensorHandler *gf_sc_anchor_get_handler(GF_Node *n); hsens = gf_sc_anchor_get_handler(node); @@ -241,7 +241,7 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave } else { list = ((GF_ParentNode *)node)->children; while (list) { - hsens = compositor_mpeg4_get_sensor_handler(list->node); + hsens = compositor_mpeg4_get_sensor_handler_ex(list->node, GF_TRUE); if (hsens) { if (!group->sensors) group->sensors = gf_list_new(); gf_list_add(group->sensors, hsens); @@ -263,7 +263,7 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave /*now here is the trick: ExternProtos may not be loaded at this point, in which case we can't perform proper culling. Unloaded ExternProto signal themselves by invalidating their parent - graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing + graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing bounds otherwise we'll never re-invalidate the subgraph anymore*/ gf_node_dirty_clear(node, GF_SG_CHILD_DIRTY); @@ -289,7 +289,7 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave tr_state->bounds.width = tr_state->bounds.height = 0; #ifndef GPAC_DISABLE_3D tr_state->bbox.is_set = 0; -#endif +#endif count = gf_node_list_get_count(list); for (i=0; idisable_cull) { group->flags |= GROUP_SKIP_CULLING; tr_state->disable_cull = 0; - } + } /*handle 3D nodes in 2D groups*/ #ifndef GPAC_DISABLE_3D if (tr_state->bbox.is_set) { @@ -310,11 +310,11 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave } tr_state->bounds = group->bounds; - if (group->flags & GROUP_SKIP_CULLING) + if (group->flags & GROUP_SKIP_CULLING) tr_state->disable_cull = 1; tr_state->text_split_mode = backup; - /*TRAVERSE_SORT */ + /*TRAVERSE_SORT */ } else if (tr_state->traversing_mode==TRAVERSE_SORT) { Bool prev_inv = tr_state->invalidate_all; #ifdef GF_SR_USE_VIDEO_CACHE @@ -337,17 +337,17 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave child = gf_node_list_get_child(list, positions[i]); gf_node_traverse(child, tr_state); #ifdef GF_SR_USE_VIDEO_CACHE - if (tr_state->cache_too_small) + if (tr_state->cache_too_small) cache_too_small++; #endif - } + } tr_state->invalidate_all = prev_inv; #ifdef GF_SR_USE_VIDEO_CACHE if (cache_too_small) { tr_state->cache_too_small = 1; } else { - /*get the traversal time for each group*/ + /*get the traversal time for each group*/ traverse_time = gf_sys_clock() - traverse_time; group->traverse_time += traverse_time; /*record the traversal information and turn cache on if possible*/ @@ -362,7 +362,7 @@ void group_2d_traverse_with_order(GF_Node *node, GroupingNode2D *group, GF_Trave for (i=0; iflags |= GROUP_HAS_SENSORS; + ) group->flags |= GROUP_HAS_SENSORS; l = ((GF_ParentNode*)node)->children; while (l) { - hsens = compositor_mpeg4_get_sensor_handler(l->node); + hsens = compositor_mpeg4_get_sensor_handler_ex(l->node, GF_TRUE); if (hsens) { group->flags |= GROUP_HAS_SENSORS; break; @@ -460,7 +460,7 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ /*now here is the trick: ExternProtos may not be loaded at this point, in which case we can't perform proper culling. Unloaded ExternProto signal themselves by invalidating their parent - graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing + graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing bounds otherwise we'll never re-invalidate the subgraph anymore*/ gf_node_dirty_clear(node, GF_SG_CHILD_DIRTY); } @@ -477,16 +477,16 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ mode_back=tr_state->cull_flag; /*if culling not disabled*/ - if (!(group->flags & GROUP_SKIP_CULLING) - /*for geometry AND lights*/ - && (tr_state->traversing_mode==TRAVERSE_SORT) - /*do cull*/ - && !visual_3d_node_cull(tr_state, &group->bbox, 0)) { + if (!(group->flags & GROUP_SKIP_CULLING) + /*for geometry AND lights*/ + && (tr_state->traversing_mode==TRAVERSE_SORT) + /*do cull*/ + && !visual_3d_node_cull(tr_state, &group->bbox, 0)) { tr_state->cull_flag = mode_back; return; } - + /*picking: collect sensors*/ sensor_backup = NULL; @@ -497,8 +497,8 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ l = ((GF_ParentNode*)node)->children; while (l) { - hsens = compositor_mpeg4_get_sensor_handler(l->node); - if (hsens && hsens->IsEnabled(l->node)) + hsens = compositor_mpeg4_get_sensor_handler_ex(l->node, GF_TRUE); + if (hsens && hsens->IsEnabled(l->node)) gf_list_add(tr_state->vrml_sensors, hsens); l = l->next; @@ -539,7 +539,7 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ } } - + if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) { l = ((GF_ParentNode*)node)->children; split_text_backup = tr_state->text_split_mode; @@ -553,7 +553,7 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ if (tr_state->disable_cull) { group->flags |= GROUP_SKIP_CULLING; tr_state->disable_cull = 0; - } + } /*handle 2D nodes in 3D groups*/ if (tr_state->bounds.width) { gf_bbox_from_rect(&tr_state->bbox, &tr_state->bounds); @@ -567,7 +567,7 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ l = l->next; } tr_state->bbox = group->bbox; - if (group->flags & GROUP_SKIP_CULLING) + if (group->flags & GROUP_SKIP_CULLING) tr_state->disable_cull = 1; tr_state->text_split_mode = split_text_backup; } else { @@ -577,7 +577,7 @@ void group_3d_traverse(GF_Node *node, GroupingNode *group, GF_TraverseState *tr_ l = l->next; } - if (tr_state->traversing_mode==TRAVERSE_SORT) + if (tr_state->traversing_mode==TRAVERSE_SORT) drawable3d_check_focus_highlight(node, tr_state, NULL); } tr_state->cull_flag = mode_back; @@ -681,16 +681,17 @@ void parent_node_traverse(GF_Node *node, ParentNode2D *group, GF_TraverseState * u32 ntag = gf_node_get_tag(node); group->flags &= ~GROUP_HAS_SENSORS; /*special case for anchor which is a parent node acting as a sensor*/ - if ((ntag==TAG_MPEG4_Anchor) + if ((ntag==TAG_MPEG4_Anchor) #ifndef GPAC_DISABLE_X3D - || (ntag==TAG_X3D_Anchor) + || (ntag==TAG_X3D_Anchor) #endif - ) { + ) { group->flags |= GROUP_HAS_SENSORS | GROUP_IS_ANCHOR; } else { l = ((GF_ParentNode *)node)->children; while (l) { - if (compositor_mpeg4_is_sensor_node(l->node)) { + GF_SensorHandler *hsens = compositor_mpeg4_get_sensor_handler_ex(l->node, GF_TRUE); + if (hsens) { group->flags |= GROUP_HAS_SENSORS; break; } @@ -700,14 +701,14 @@ void parent_node_traverse(GF_Node *node, ParentNode2D *group, GF_TraverseState * /*now here is the trick: ExternProtos may not be loaded at this point, in which case we can't perform proper culling. Unloaded ExternProto signal themselves by invalidating their parent - graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing + graph to get a new traversal. We must therefore reset the CHILD_DIRTY flag before computing bounds otherwise we'll never re-invalidate the subgraph anymore*/ gf_node_dirty_clear(node, GF_SG_CHILD_DIRTY); } gf_node_dirty_clear(node, GF_SG_NODE_DIRTY); /*no culling in 2D*/ - + /*picking: collect sensors*/ sensor_backup = NULL; if ((tr_state->traversing_mode==TRAVERSE_PICK) && (group->flags & GROUP_HAS_SENSORS) ) { @@ -720,7 +721,7 @@ void parent_node_traverse(GF_Node *node, ParentNode2D *group, GF_TraverseState * /*add sensor(s) to traversing state*/ l = ((GF_ParentNode *)node)->children; while (l) { - hsens = compositor_mpeg4_get_sensor_handler(l->node); + hsens = compositor_mpeg4_get_sensor_handler_ex(l->node, GF_TRUE); if (hsens) gf_list_add(tr_state->vrml_sensors, hsens); l = l->next; } @@ -733,14 +734,14 @@ void parent_node_traverse(GF_Node *node, ParentNode2D *group, GF_TraverseState * tr_state->bounds.width = tr_state->bounds.height = 0; #ifndef GPAC_DISABLE_3D tr_state->bbox.is_set = 0; -#endif +#endif l = ((GF_ParentNode *)node)->children; while (l) { parent_node_start_group(group, l->node, 0); - + tr_state->bounds.width = tr_state->bounds.height = 0; - + gf_node_traverse(l->node, tr_state); /*handle 3D nodes in 2D groups*/ @@ -766,7 +767,7 @@ void parent_node_traverse(GF_Node *node, ParentNode2D *group, GF_TraverseState * void parent_node_child_traverse(ChildGroup *cg, GF_TraverseState *tr_state) { Fixed dx, dy; - + dx = cg->final.x - cg->original.x + cg->scroll_x; dy = cg->final.y - cg->original.y + cg->scroll_y; tr_state->text_split_idx = cg->text_split_idx; @@ -777,20 +778,9 @@ void parent_node_child_traverse(ChildGroup *cg, GF_TraverseState *tr_state) gf_mx_copy(mx_bckup, tr_state->model_matrix); gf_mx_add_translation(&tr_state->model_matrix, dx, dy, 0); - - if (tr_state->traversing_mode==TRAVERSE_SORT) { - GF_Matrix mx; - gf_mx_init(mx); - gf_mx_add_translation(&mx, dx, dy, 0); - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, mx.m); - gf_node_traverse(cg->child, tr_state); - visual_3d_matrix_pop(tr_state->visual); - } else { - gf_node_traverse(cg->child, tr_state); - } + gf_node_traverse(cg->child, tr_state); gf_mx_copy(tr_state->model_matrix, mx_bckup); - } else + } else #endif { GF_Matrix2D mx2d; @@ -807,7 +797,7 @@ void parent_node_child_traverse(ChildGroup *cg, GF_TraverseState *tr_state) void parent_node_child_traverse_matrix(ChildGroup *cg, GF_TraverseState *tr_state, GF_Matrix2D *mat2D) { if (!mat2D) return; - + tr_state->text_split_idx = cg->text_split_idx; #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { @@ -815,16 +805,9 @@ void parent_node_child_traverse_matrix(ChildGroup *cg, GF_TraverseState *tr_stat gf_mx_from_mx2d(&mx, mat2D); gf_mx_copy(mx_bckup, tr_state->model_matrix); gf_mx_add_matrix(&tr_state->model_matrix, &mx); - if (tr_state->traversing_mode==TRAVERSE_SORT) { - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, mx.m); - gf_node_traverse(cg->child, tr_state); - visual_3d_matrix_pop(tr_state->visual); - } else { - gf_node_traverse(cg->child, tr_state); - } + gf_node_traverse(cg->child, tr_state); gf_mx_copy(tr_state->model_matrix, mx_bckup); - } else + } else #endif { GF_Matrix2D mx2d; diff --git a/src/compositor/mpeg4_grouping.h b/src/compositor/mpeg4_grouping.h index dc42405..831f056 100644 --- a/src/compositor/mpeg4_grouping.h +++ b/src/compositor/mpeg4_grouping.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -65,20 +65,20 @@ typedef struct u32 cached_size; \ /*number of objects in cache - for debug purposes only*/ \ u32 nb_objects; \ - + #else #define GROUPING_NODE_STACK_2D \ u32 flags; \ GF_Rect bounds; \ - + #endif #define GROUPING_MPEG4_STACK_2D \ GROUPING_NODE_STACK_2D \ GF_List *sensors; \ - + typedef struct _mpeg4_group2d { GROUPING_MPEG4_STACK_2D @@ -116,7 +116,7 @@ void group_2d_destroy_svg(GF_Node *node, GroupingNode2D *group); #define GROUPING_NODE_STACK_3D \ u32 flags; \ GF_BBox bbox; \ - + typedef struct _parent_node_3d { GROUPING_NODE_STACK_3D @@ -138,14 +138,14 @@ void group_3d_traverse(GF_Node *n, GroupingNode *group, GF_TraverseState *tr_sta */ -typedef struct +typedef struct { /*the associated child (can be a group or a shape)*/ GF_Node *child; /*child bounds before and after placement*/ GF_Rect original, final; - + /*layout run-time scroll*/ Fixed scroll_x, scroll_y; @@ -161,7 +161,7 @@ typedef struct #define PARENT_MPEG4_STACK_2D \ GROUPING_MPEG4_STACK_2D \ /*list of ChildGroup drawn (can be fully transparents) - used for post placement*/ \ - GF_List *groups; + GF_List *groups; typedef struct _parent_node_2d diff --git a/src/compositor/mpeg4_grouping_2d.c b/src/compositor/mpeg4_grouping_2d.c index f1a70e0..77423e4 100644 --- a/src/compositor/mpeg4_grouping_2d.c +++ b/src/compositor/mpeg4_grouping_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -43,7 +43,7 @@ static void TraverseSwitch(GF_Node *node, void *rs, Bool is_destroy) s32 whichChoice; GF_Node *child; SwitchStack *st = (SwitchStack *)gf_node_get_private(node); - GF_TraverseState *tr_state; + GF_TraverseState *tr_state; tr_state = (GF_TraverseState *)rs; children = NULL; @@ -75,7 +75,7 @@ static void TraverseSwitch(GF_Node *node, void *rs, Bool is_destroy) i=0; l = children; while (l) { - // if ((s32) i!=whichChoice) gf_node_traverse(l->node, tr_state); + // if ((s32) i!=whichChoice) gf_node_traverse(l->node, tr_state); if ((s32) i == st->last_switch) gf_node_traverse(l->node, tr_state); l = l->next; i++; @@ -103,7 +103,7 @@ static void TraverseSwitch(GF_Node *node, void *rs, Bool is_destroy) child = (GF_Node*)gf_node_list_get_child(children, idx); gf_node_traverse(child, tr_state); return; - } else + } else #endif //GPAC_DISABLE_3D { /*fallback to first view*/ @@ -141,33 +141,22 @@ static void traverse_transform(GF_Node *node, Transform2DStack *stack, GF_Traver /*note we don't clear dirty flag, this is done in traversing*/ if (stack->is_identity) { group_2d_traverse(node, (GroupingNode2D *)stack, tr_state); - } + } #ifndef GPAC_DISABLE_3D else if (tr_state->visual->type_3d) { GF_Matrix mx_bckup; gf_mx_copy(mx_bckup, tr_state->model_matrix); gf_mx_add_matrix_2d(&tr_state->model_matrix, &stack->mat); - - if (tr_state->traversing_mode == TRAVERSE_SORT) { - GF_Matrix tmp; - gf_mx_from_mx2d(&tmp, &stack->mat); - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, tmp.m); - group_2d_traverse(node, (GroupingNode2D *)stack, tr_state); - visual_3d_matrix_pop(tr_state->visual); - } else { - group_2d_traverse(node, (GroupingNode2D *)stack, tr_state); - } - + group_2d_traverse(node, (GroupingNode2D *)stack, tr_state); gf_mx_copy(tr_state->model_matrix, mx_bckup); - } + } #endif else { GF_Matrix2D bckup; gf_mx2d_copy(bckup, tr_state->transform); gf_mx2d_pre_multiply(&tr_state->transform, &stack->mat); - + group_2d_traverse(node, (GroupingNode2D *)stack, tr_state); gf_mx2d_copy(tr_state->transform, bckup); @@ -184,7 +173,7 @@ static void TraverseTransform2D(GF_Node *node, void *rs, Bool is_destroy) M_Transform2D *tr = (M_Transform2D *)node; Transform2DStack *ptr = (Transform2DStack *)gf_node_get_private(node); GF_TraverseState *tr_state; - + if (is_destroy) { gf_sc_check_focus_upon_destroy(node); group_2d_destroy(node, (GroupingNode2D*)ptr); @@ -256,7 +245,7 @@ static void TraverseTransformMatrix2D(GF_Node *node, void *rs, Bool is_destroy) M_TransformMatrix2D *tr = (M_TransformMatrix2D*)node; tr_mx2d_get_matrix(node, &ptr->mat); if ((tr->mxx==FIX_ONE) && (tr->mxy==0) && (tr->tx==0) - && (tr->myx==0) && (tr->myy==FIX_ONE) && (tr->ty==0) ) + && (tr->myx==0) && (tr->myy==FIX_ONE) && (tr->ty==0) ) ptr->is_identity = 1; else ptr->is_identity = 0; @@ -308,18 +297,18 @@ static void TraverseColorTransform(GF_Node *node, void *rs, Bool is_destroy) prev_inv = tr_state->invalidate_all; c_changed = 0; if (gf_node_dirty_get(node) & GF_SG_NODE_DIRTY) { - gf_cmx_set(&ptr->cmat, - tr->mrr , tr->mrg, tr->mrb, tr->mra, tr->tr, - tr->mgr , tr->mgg, tr->mgb, tr->mga, tr->tg, - tr->mbr, tr->mbg, tr->mbb, tr->mba, tr->tb, - tr->mar, tr->mag, tr->mab, tr->maa, tr->ta); + gf_cmx_set(&ptr->cmat, + tr->mrr , tr->mrg, tr->mrb, tr->mra, tr->tr, + tr->mgr , tr->mgg, tr->mgb, tr->mga, tr->tg, + tr->mbr, tr->mbg, tr->mbb, tr->mba, tr->tb, + tr->mar, tr->mag, tr->mab, tr->maa, tr->ta); c_changed = 1; gf_node_dirty_clear(node, GF_SG_NODE_DIRTY); } - if ((tr_state->traversing_mode==TRAVERSE_SORT) - && !tr->maa && !tr->mar && !tr->mag && !tr->mab && !tr->ta) - return; + if ((tr_state->traversing_mode==TRAVERSE_SORT) + && !tr->maa && !tr->mar && !tr->mag && !tr->mab && !tr->ta) + return; /*if modified redraw all nodes*/ if (c_changed) tr_state->invalidate_all = 1; @@ -412,7 +401,7 @@ static void TraverseOrderedGroup(GF_Node *node, void *rs, Bool is_destroy) stack->positions = (u32*)gf_malloc(sizeof(u32) * count); for (i=0; ipositions[i] = priorities[i].position; gf_free(priorities); - + tr_state->invalidate_all = 1; gf_node_dirty_clear(node, GF_SG_NODE_DIRTY); } @@ -423,7 +412,7 @@ static void TraverseOrderedGroup(GF_Node *node, void *rs, Bool is_destroy) void compositor_init_orderedgroup(GF_Compositor *compositor, GF_Node *node) { OrderedGroupStack *ptr; - GF_SAFEALLOC(ptr, OrderedGroupStack); + GF_SAFEALLOC(ptr, OrderedGroupStack); gf_node_set_private(node, ptr); gf_node_set_callback_function(node, TraverseOrderedGroup); } diff --git a/src/compositor/mpeg4_grouping_3d.c b/src/compositor/mpeg4_grouping_3d.c index 9088433..ae525a3 100644 --- a/src/compositor/mpeg4_grouping_3d.c +++ b/src/compositor/mpeg4_grouping_3d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -49,7 +49,7 @@ static void TraverseGroup(GF_Node *node, void *rs, Bool is_destroy) void compositor_init_group(GF_Compositor *compositor, GF_Node *node) { GroupingNode2D *ptr; - GF_SAFEALLOC(ptr, GroupingNode2D); + GF_SAFEALLOC(ptr, GroupingNode2D); gf_node_set_private(node, ptr); gf_node_set_callback_function(node, TraverseGroup); } @@ -153,7 +153,7 @@ typedef struct { GROUPING_NODE_STACK_3D - GF_Matrix mx; + GF_Matrix mx; Bool has_scale; } TransformStack; @@ -173,14 +173,6 @@ static void NewTransformStack(GF_Compositor *compositor, GF_Node *node, GF_Child gf_node_set_private(node, st); } -#define TRANS_PUSH_MX \ - if (tr_state->traversing_mode == TRAVERSE_SORT) { \ - visual_3d_matrix_push(tr_state->visual); \ - visual_3d_matrix_add(tr_state->visual, st->mx.m); \ - } \ - -#define TRANS_POP_MX if (tr_state->traversing_mode==TRAVERSE_SORT) visual_3d_matrix_pop(tr_state->visual); - static void TraverseTransform(GF_Node *n, void *rs, Bool is_destroy) { GF_Matrix gf_mx_bckup; @@ -197,39 +189,34 @@ static void TraverseTransform(GF_Node *n, void *rs, Bool is_destroy) if (gf_node_dirty_get(n) & GF_SG_NODE_DIRTY) { Bool scale_rot, recenter; gf_mx_init(st->mx); - if (tr->translation.x || tr->translation.y || tr->translation.z) + if (tr->translation.x || tr->translation.y || tr->translation.z) gf_mx_add_translation(&st->mx, tr->translation.x, tr->translation.y, tr->translation.z); recenter = (tr->center.x || tr->center.y || tr->center.z) ? 1 : 0; - if (recenter) + if (recenter) gf_mx_add_translation(&st->mx, tr->center.x, tr->center.y, tr->center.z); if (tr->rotation.q) gf_mx_add_rotation(&st->mx, tr->rotation.q, tr->rotation.x, tr->rotation.y, tr->rotation.z); scale_rot = (tr->scaleOrientation.q) ? 1 : 0; - if (scale_rot) + if (scale_rot) gf_mx_add_rotation(&st->mx, tr->scaleOrientation.q, tr->scaleOrientation.x, tr->scaleOrientation.y, tr->scaleOrientation.z); - if ((tr->scale.x != FIX_ONE) || (tr->scale.y != FIX_ONE) || (tr->scale.z != FIX_ONE)) + if ((tr->scale.x != FIX_ONE) || (tr->scale.y != FIX_ONE) || (tr->scale.z != FIX_ONE)) gf_mx_add_scale(&st->mx, tr->scale.x, tr->scale.y, tr->scale.z); - if (scale_rot) + if (scale_rot) gf_mx_add_rotation(&st->mx, -tr->scaleOrientation.q, tr->scaleOrientation.x, tr->scaleOrientation.y, tr->scaleOrientation.z); - if (recenter) + if (recenter) gf_mx_add_translation(&st->mx, -tr->center.x, -tr->center.y, -tr->center.z); st->has_scale = ((tr->scale.x != FIX_ONE) || (tr->scale.y != FIX_ONE) || (tr->scale.z != FIX_ONE)) ? 1 : 0; - } + } gf_mx_copy(gf_mx_bckup, tr_state->model_matrix); gf_mx_add_matrix(&tr_state->model_matrix, &st->mx); - TRANS_PUSH_MX - /*note we don't clear dirty flag, this is done in traversing*/ group_3d_traverse(n, (GroupingNode *) st, tr_state); - TRANS_POP_MX - - gf_mx_copy(tr_state->model_matrix, gf_mx_bckup); - if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) + if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) gf_mx_apply_bbox(&st->mx, &tr_state->bbox); } @@ -293,7 +280,8 @@ static void TraverseBillboard(GF_Node *n, void *rs, Bool is_destroy) gf_vec_add(user_pos, user_pos, tmp); gf_vec_norm(&user_pos); - z.x = z.y = 0; z.z = FIX_ONE; + z.x = z.y = 0; + z.z = FIX_ONE; d = -gf_vec_dot(axis, z); tmp = gf_vec_scale(axis, d); gf_vec_add(z, z, tmp); @@ -302,7 +290,7 @@ static void TraverseBillboard(GF_Node *n, void *rs, Bool is_destroy) cosw = gf_vec_dot(user_pos, z); tmp = gf_vec_cross(user_pos, z); sinw = gf_vec_len(tmp); - angle = gf_acos(cosw); + angle = gf_acos(cosw); gf_vec_norm(&tmp); if ((sinw>0) && (gf_vec_dot(axis, tmp) > 0)) gf_vec_rev(axis); gf_mx_add_rotation(&st->mx, angle, axis.x, axis.y, axis.z); @@ -311,14 +299,10 @@ static void TraverseBillboard(GF_Node *n, void *rs, Bool is_destroy) gf_mx_copy(gf_mx_bckup, tr_state->model_matrix); gf_mx_add_matrix(&tr_state->model_matrix, &st->mx); - - TRANS_PUSH_MX /*note we don't clear dirty flag, this is done in traversing*/ group_3d_traverse(n, (GroupingNode *) st, tr_state); - TRANS_POP_MX - gf_mx_copy(tr_state->model_matrix, gf_mx_bckup); if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) gf_mx_apply_bbox(&st->mx, &tr_state->bbox); @@ -365,7 +349,7 @@ static void TraverseLOD(GF_Node *node, void *rs, Bool is_destroy) if (!children) return; nb_children = gf_node_list_get_count(children); - + if (!tr_state->camera) { do_all = 1; which_child = 0; @@ -393,7 +377,7 @@ static void TraverseLOD(GF_Node *node, void *rs, Bool is_destroy) do_all = 1; } } - + if (do_all) { u32 i; Bool prev_switch = tr_state->switched_off; diff --git a/src/compositor/mpeg4_layer_2d.c b/src/compositor/mpeg4_layer_2d.c index 0a3efe1..19e31e7 100644 --- a/src/compositor/mpeg4_layer_2d.c +++ b/src/compositor/mpeg4_layer_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,17 +50,17 @@ static void l2d_CheckBindables(GF_Node *n, GF_TraverseState *tr_state, Bool forc l2d = (M_Layer2D *)n; if (force_traverse) gf_node_traverse(l2d->background, tr_state); btop = (GF_Node*)gf_list_get(tr_state->backgrounds, 0); - if (btop != l2d->background) { + if (btop != l2d->background) { gf_node_unregister(l2d->background, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l2d->background = btop; gf_node_event_out_str(n, "background"); } if (force_traverse) gf_node_traverse(l2d->viewport, tr_state); btop = (GF_Node*)gf_list_get(tr_state->viewpoints, 0); - if (btop != l2d->viewport) { + if (btop != l2d->viewport) { gf_node_unregister(l2d->viewport, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l2d->viewport = btop; gf_node_event_out_str(n, "viewport"); } @@ -71,23 +71,23 @@ static void l2d_CheckBindables(GF_Node *n, GF_TraverseState *tr_state, Bool forc static void rect_intersect(GF_Rect *rc1, GF_Rect *rc2) { if (! gf_rect_overlaps(*rc1, *rc2)) { - rc1->width = rc1->height = 0; + rc1->width = rc1->height = 0; return; } if (rc2->x > rc1->x) { rc1->width -= rc2->x - rc1->x; rc1->x = rc2->x; - } + } if (rc2->x + rc2->width < rc1->x + rc1->width) { rc1->width = rc2->width + rc2->x - rc1->x; - } + } if (rc2->y < rc1->y) { - rc1->height -= rc1->y - rc2->y; + rc1->height -= rc1->y - rc2->y; rc1->y = rc2->y; - } + } if (rc2->y - rc2->height > rc1->y - rc1->height) { rc1->height = rc1->y - rc2->y + rc2->height; - } + } } #endif @@ -109,11 +109,11 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) GF_Rect prev_clipper; Bool had_clip; #endif - + M_Layer2D *l = (M_Layer2D *)node; Layer2DStack *st = (Layer2DStack *) gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *) rs; - + if (is_destroy) { BindableStackDelete(st->backs); BindableStackDelete(st->views); @@ -155,7 +155,7 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) st->clip = gf_rect_center(st->clip.width, st->clip.height); st->bounds = st->clip; } - + prev_vp = tr_state->vp_size; tr_state->vp_size.x = st->clip.width; tr_state->vp_size.y = st->clip.height; @@ -167,12 +167,14 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) gf_mx_copy(prev_layer_mx, tr_state->layer_matrix); tr_state->layer_clipper = compositor_2d_update_clipper(tr_state, st->clip, &had_clip, &prev_clipper, 1); - visual_3d_matrix_push(tr_state->visual); gf_mx_copy(mx3d, tr_state->model_matrix); /*setup clipping*/ - visual_3d_set_clipper_2d(tr_state->visual, tr_state->layer_clipper); - + if (had_clip) { + visual_3d_reset_clipper_2d(tr_state->visual); + } + visual_3d_set_clipper_2d(tr_state->visual, tr_state->layer_clipper, &mx3d, 0); + /*apply background BEFORE viewport*/ if (back) { tr_state->traversing_mode = TRAVERSE_BINDABLE; @@ -185,7 +187,6 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) tr_state->traversing_mode = TRAVERSE_BINDABLE; tr_state->bounds = st->clip; gf_node_traverse(viewport, tr_state); - visual_3d_matrix_add(tr_state->visual, tr_state->model_matrix.m); } @@ -203,8 +204,6 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) gf_list_del(tr_state->visual->alpha_nodes_to_draw); tr_state->visual->alpha_nodes_to_draw = node_list_backup; - - visual_3d_matrix_pop(tr_state->visual); gf_mx_copy(tr_state->model_matrix, mx3d); visual_3d_reset_clipper_2d(tr_state->visual); @@ -213,16 +212,16 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) if (had_clip) { tr_state->layer_clipper = prev_clipper; gf_mx_copy(tr_state->layer_matrix, prev_layer_mx); - visual_3d_set_clipper_2d(tr_state->visual, tr_state->layer_clipper); + visual_3d_set_clipper_2d(tr_state->visual, tr_state->layer_clipper, &prev_layer_mx, 0); } - } else + } else #endif { gf_mx2d_copy(backup, tr_state->transform); prev_clip = tr_state->visual->top_clipper; rc = st->clip; - + /*get clipper in world coordinate*/ gf_mx2d_apply_rect(&tr_state->transform, &rc); @@ -238,8 +237,10 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) #endif } - rc.x -= FIX_ONE; rc.width += 2*FIX_ONE; - rc.y += FIX_ONE; rc.height += 2*FIX_ONE; + rc.x -= FIX_ONE; + rc.width += 2*FIX_ONE; + rc.y += FIX_ONE; + rc.height += 2*FIX_ONE; tr_state->visual->top_clipper = gf_rect_pixelize(&rc); gf_irect_intersect(&tr_state->visual->top_clipper, &prev_clip); tr_state->traversing_mode = TRAVERSE_SORT; @@ -295,11 +296,11 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) gf_mx2d_copy(tr_state->transform, backup); } break; - - /*check picking - we must fall in our 2D clipper*/ + + /*check picking - we must fall in our 2D clipper*/ case TRAVERSE_PICK: if (gf_sc_pick_in_clipper(tr_state, &st->clip)) { - + #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { /*apply viewport*/ @@ -314,7 +315,7 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) } else { group_2d_traverse(node, (GroupingNode2D *)st, tr_state); } - } else + } else #endif { if (viewport) { @@ -328,7 +329,7 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) } else { group_2d_traverse(node, (GroupingNode2D *)st, tr_state); } - } + } } break; case TRAVERSE_GET_BOUNDS: @@ -353,7 +354,7 @@ static void TraverseLayer2D(GF_Node *node, void *rs, Bool is_destroy) break; #endif } - + /*restore traversing state*/ tr_state->vp_size = prev_vp; tr_state->backgrounds = oldb; diff --git a/src/compositor/mpeg4_layer_3d.c b/src/compositor/mpeg4_layer_3d.c index 89323df..3e86362 100644 --- a/src/compositor/mpeg4_layer_3d.c +++ b/src/compositor/mpeg4_layer_3d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -97,33 +97,33 @@ static void l3d_CheckBindables(GF_Node *n, GF_TraverseState *tr_state, Bool forc if (force_traverse) gf_node_traverse(l3d->background, tr_state); btop = (GF_Node*)gf_list_get(tr_state->backgrounds, 0); - if (btop != l3d->background) { + if (btop != l3d->background) { gf_node_unregister(l3d->background, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l3d->background = btop; gf_node_event_out_str(n, "background"); } if (force_traverse) gf_node_traverse(l3d->viewpoint, tr_state); btop = (GF_Node*)gf_list_get(tr_state->viewpoints, 0); - if (btop != l3d->viewpoint) { + if (btop != l3d->viewpoint) { gf_node_unregister(l3d->viewpoint, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l3d->viewpoint = btop; gf_node_event_out_str(n, "viewpoint"); } if (force_traverse) gf_node_traverse(l3d->navigationInfo, tr_state); btop = (GF_Node*)gf_list_get(tr_state->navigations, 0); - if (btop != l3d->navigationInfo) { + if (btop != l3d->navigationInfo) { gf_node_unregister(l3d->navigationInfo, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l3d->navigationInfo = btop; gf_node_event_out_str(n, "navigationInfo"); } if (force_traverse) gf_node_traverse(l3d->fog, tr_state); btop = (GF_Node*)gf_list_get(tr_state->fogs, 0); - if (btop != l3d->fog) { + if (btop != l3d->fog) { gf_node_unregister(l3d->fog, n); - gf_node_register(btop, n); + gf_node_register(btop, n); l3d->fog = btop; gf_node_event_out_str(n, "fog"); } @@ -147,12 +147,12 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t } #endif -/* - if (tr_state->visual->compositor->recompute_ar) { - gf_node_dirty_set(node, 0, 0); - return 0; - } -*/ + /* + if (tr_state->visual->compositor->recompute_ar) { + gf_node_dirty_set(node, 0, 0); + return 0; + } + */ new_pixel_format = GF_PIXEL_RGBA; #ifndef GPAC_USE_TINYGL @@ -164,7 +164,7 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t new_pixel_format = GF_PIXEL_RGBA; #else /*no support for alpha in offscreen rendering*/ - if (!(compositor->video_out->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA)) + if (!(compositor->video_out->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN_ALPHA)) new_pixel_format = GF_PIXEL_RGB_24; #endif @@ -174,7 +174,7 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t #if defined(GF_SR_USE_DEPTH) && !defined(GPAC_DISABLE_3D) if (st->visual->type_3d && (compositor->video_out->hw_caps & GF_VIDEO_HW_HAS_DEPTH) ) new_pixel_format = GF_PIXEL_RGBDS; #endif - + w = (u32) FIX2INT(gf_ceil(width)); h = (u32) FIX2INT(gf_ceil(height)); @@ -189,12 +189,12 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t if (!w || !h) return 0; if (st->txh.tx_io - && (new_pixel_format == st->txh.pixelformat) - && (w == st->txh.width) - && (h == st->txh.height) - && (compositor->offscreen_width >= w) - && (compositor->offscreen_height >= h) - ) + && (new_pixel_format == st->txh.pixelformat) + && (w == st->txh.width) + && (h == st->txh.height) + && (compositor->offscreen_width >= w) + && (compositor->offscreen_height >= h) + ) return 2; if (st->txh.tx_io) { @@ -217,10 +217,10 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t if (new_pixel_format==GF_PIXEL_RGBA) { st->txh.stride = w * 4; st->txh.transparent = 1; - } + } else if (new_pixel_format==GF_PIXEL_RGBDS) { - st->txh.stride = w * 4; - st->txh.transparent = 1; + st->txh.stride = w * 4; + st->txh.transparent = 1; } else { st->txh.stride = w * 3; @@ -258,7 +258,7 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t #endif st->txh.data = (char*)gf_malloc(sizeof(unsigned char) * st->txh.stride * st->txh.height); memset(st->txh.data, 0, sizeof(unsigned char) * st->txh.stride * st->txh.height); - + /*set stencil texture - we don't check error as an image could not be supported by the rasterizer but still supported by the blitter (case of RGBD/RGBDS)*/ compositor->rasterizer->stencil_set_texture(stencil, st->txh.data, st->txh.width, st->txh.height, st->txh.stride, st->txh.pixelformat, st->txh.pixelformat, 0); @@ -282,7 +282,7 @@ u32 layer3d_setup_offscreen(GF_Node *node, Layer3DStack *st, GF_TraverseState *t static void layer3d_draw_2d(GF_Node *node, GF_TraverseState *tr_state) { DrawableContext *ctx = tr_state->ctx; - if (tr_state->visual->DrawBitmap(tr_state->visual, tr_state, ctx, NULL)) + if (tr_state->visual->DrawBitmap(tr_state->visual, tr_state, ctx, NULL)) return; visual_2d_texture_path(tr_state->visual, ctx->drawable->path, ctx, tr_state); @@ -348,7 +348,7 @@ static void TraverseLayer3D(GF_Node *node, void *rs, Bool is_destroy) M_Layer3D *l = (M_Layer3D *)node; Layer3DStack *st = (Layer3DStack *) gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *) rs; - + if (is_destroy) { DestroyLayer3D(node); return; @@ -432,12 +432,12 @@ static void TraverseLayer3D(GF_Node *node, void *rs, Bool is_destroy) } else { gf_mx2d_apply_rect(&tr_state->transform, &rc); -/* if (tr_state->visual->compositor->visual==tr_state->visual) { - gf_mx2d_init(mx2d_backup); - gf_mx2d_add_scale(&mx2d_backup, tr_state->visual->compositor->scale_x, tr_state->visual->compositor->scale_y); - gf_mx2d_apply_rect(&mx2d_backup, &rc); - } -*/ + /* if (tr_state->visual->compositor->visual==tr_state->visual) { + gf_mx2d_init(mx2d_backup); + gf_mx2d_add_scale(&mx2d_backup, tr_state->visual->compositor->scale_x, tr_state->visual->compositor->scale_y); + gf_mx2d_apply_rect(&mx2d_backup, &rc); + } + */ /*switch visual*/ tr_state->visual = st->visual; } @@ -451,6 +451,7 @@ static void TraverseLayer3D(GF_Node *node, void *rs, Bool is_destroy) /*drawing a layer means drawing all subelements as a whole (no depth sorting with parents)*/ if (tr_state->traversing_mode==TRAVERSE_SORT) { + u32 old_type_3d = tr_state->visual->type_3d; if (gf_node_dirty_get(node)) changed = 1; gf_node_dirty_clear(node, GF_SG_NODE_DIRTY|GF_SG_VRML_BINDABLE_DIRTY); @@ -478,25 +479,14 @@ static void TraverseLayer3D(GF_Node *node, void *rs, Bool is_destroy) rc = st->vp; /*setup GL*/ visual_3d_setup(tr_state->visual); - - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_reset(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_TEXTURE); - visual_3d_matrix_reset(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_reset(tr_state->visual); - } else { - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_push(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_TEXTURE); - visual_3d_matrix_push(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_push(tr_state->visual); } GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Layer3D] Redrawing\n")); layer3d_setup_clip(st, tr_state, prev_cam ? 1 : 0, rc); + tr_state->visual->type_3d = 2; + visual_3d_clear_all_lights(tr_state->visual); + cur_lights = tr_state->visual->num_lights; /*this will init projection. Note that we're binding the viewpoint in the current pixelMetrics context even if the viewpoint was declared in an inline below @@ -524,31 +514,28 @@ static void TraverseLayer3D(GF_Node *node, void *rs, Bool is_destroy) } tr_state->traversing_mode = TRAVERSE_SORT; + tr_state->visual->type_3d = old_type_3d; + //reload previous projection matrix if (prev_cam) { - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_pop(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_TEXTURE); - visual_3d_matrix_pop(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_pop(tr_state->visual); + visual_3d_projection_matrix_modified(tr_state->visual); } /*!! we were in a 2D mode, create drawable context!!*/ if (!prev_cam) { DrawableContext *ctx; - + /*with TinyGL we draw directly to the offscreen buffer*/ #ifndef GPAC_USE_TINYGL gf_sc_copy_to_stencil(&st->txh); #else - if (st->txh.pixelformat==GF_PIXEL_RGBDS) - gf_get_tinygl_depth(&st->txh); + if (st->txh.pixelformat==GF_PIXEL_RGBDS) + gf_get_tinygl_depth(&st->txh); #endif - if (tr_state->visual->compositor->rasterizer->stencil_texture_modified) - tr_state->visual->compositor->rasterizer->stencil_texture_modified(gf_sc_texture_get_stencil(&st->txh) ); + if (tr_state->visual->compositor->rasterizer->stencil_texture_modified) + tr_state->visual->compositor->rasterizer->stencil_texture_modified(gf_sc_texture_get_stencil(&st->txh) ); gf_sc_texture_set_stencil(&st->txh, gf_sc_texture_get_stencil(&st->txh) ); changed = 1; @@ -558,7 +545,7 @@ layer3d_unchanged_2d: tr_state->visual = old_visual; tr_state->layer3d = NULL; tr_state->appear = NULL; - // tr_state->camera = prev_cam; + // tr_state->camera = prev_cam; ctx = drawable_init_context_mpeg4(st->drawable, tr_state); if (!ctx) return; @@ -586,8 +573,8 @@ layer3d_unchanged_2d: } if (!prev_cam) gf_mx_from_mx2d(&tr_state->model_matrix, &tr_state->transform); - - if (!do_pick && !gf_list_count(tr_state->visual->compositor->sensors)) + + if (!do_pick && !gf_list_count(tr_state->visual->compositor->sensors)) do_pick = gf_sc_pick_in_clipper(tr_state, &st->clip); if (!do_pick) goto l3d_exit; @@ -611,15 +598,21 @@ layer3d_unchanged_2d: visual_3d_setup_projection(tr_state, 1); in_x = 2 * gf_divfix(start.x, st->visual->camera.width); in_y = 2 * gf_divfix(start.y, st->visual->camera.height); - - res.x = in_x; res.y = in_y; res.z = -FIX_ONE; res.q = FIX_ONE; + + res.x = in_x; + res.y = in_y; + res.z = -FIX_ONE; + res.q = FIX_ONE; gf_mx_apply_vec_4x4(&st->visual->camera.unprojection, &res); if (!res.q) goto l3d_exit; start.x = gf_divfix(res.x, res.q); start.y = gf_divfix(res.y, res.q); start.z = gf_divfix(res.z, res.q); - res.x = in_x; res.y = in_y; res.z = FIX_ONE; res.q = FIX_ONE; + res.x = in_x; + res.y = in_y; + res.z = FIX_ONE; + res.q = FIX_ONE; gf_mx_apply_vec_4x4(&st->visual->camera.unprojection, &res); if (!res.q) goto l3d_exit; end.x = gf_divfix(res.x, res.q); @@ -627,10 +620,10 @@ layer3d_unchanged_2d: end.z = gf_divfix(res.z, res.q); tr_state->ray = gf_ray(start, end); - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Layer3D] Picking: cast ray\n\tOrigin %.4f %.4f %.4f - End %.4f %.4f %.4f\n\tDir %.4f %.4f %.4f\n", - FIX2FLT(tr_state->ray.orig.x), FIX2FLT(tr_state->ray.orig.y), FIX2FLT(tr_state->ray.orig.z), - FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z), - FIX2FLT(tr_state->ray.dir.x), FIX2FLT(tr_state->ray.dir.y), FIX2FLT(tr_state->ray.dir.z))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Layer3D] Picking: cast ray\n\tOrigin %.4f %.4f %.4f - End %.4f %.4f %.4f\n\tDir %.4f %.4f %.4f\n", + FIX2FLT(tr_state->ray.orig.x), FIX2FLT(tr_state->ray.orig.y), FIX2FLT(tr_state->ray.orig.z), + FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z), + FIX2FLT(tr_state->ray.dir.x), FIX2FLT(tr_state->ray.dir.y), FIX2FLT(tr_state->ray.dir.z))); group_3d_traverse(node, (GroupingNode *)st, tr_state); tr_state->ray = prev_r; diff --git a/src/compositor/mpeg4_layout.c b/src/compositor/mpeg4_layout.c index 30934d2..2b997bd 100644 --- a/src/compositor/mpeg4_layout.c +++ b/src/compositor/mpeg4_layout.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ typedef struct { PARENT_MPEG4_STACK_2D - + Bool is_scrolling; u32 start_scroll_type; Double start_time, pause_time; @@ -105,7 +105,7 @@ static void get_lines_info(LayoutStack *st, M_Layout *l) max_w = st->clip.width; max_h = st->clip.height; layout_reset_lines(st); - + count = gf_list_count(st->groups); if (!count) return; @@ -139,7 +139,7 @@ static void get_lines_info(LayoutStack *st, M_Layout *l) li->width -= prev_discard_width; li->nb_children--; } - if ((cg->text_type==1) && (i+1==count)) break; + if ((cg->text_type==1) && (i+1==count)) break; li = new_line_info(st); li->first_child = i; @@ -147,9 +147,9 @@ static void get_lines_info(LayoutStack *st, M_Layout *l) li->first_child++; continue; } - } + } } - + /*get ascent/descent for text or height for non-text*/ if (cg->ascent) { if (li->ascent < cg->ascent) li->ascent = cg->ascent; @@ -177,7 +177,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) get_lines_info(st, l); major = get_justify(l, 0); minor = get_justify(l, 1); - + st->scroll_len = 0; nbLines = gf_list_count(st->lines); if (l->horizontal) { @@ -197,7 +197,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) if (!l->leftToRight) first += li->nb_children - 1; if (!l->topToBottom && k) current_top += li->height; - + /*set major alignment (X) */ cg = (ChildGroup *)gf_list_get(st->groups, first); switch (major) { @@ -222,10 +222,10 @@ static void layout_justify(LayoutStack *st, M_Layout *l) if ( (k+1==nbLines) || li->line_break) { spacing = 0; } - } + } } break; - } + } /*for each in the run */ @@ -267,7 +267,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) if (l->leftToRight && (i==li->first_child + li->nb_children)) break; else if (!l->leftToRight && (i==li->first_child - 1)) - break; + break; } if (l->topToBottom) { current_top -= gf_mulfix(l->spacing, li->height); @@ -299,7 +299,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) first = li->first_child; if (!l->topToBottom) first += li->nb_children - 1; - + /*set major alignment (Y) */ cg = (ChildGroup *)gf_list_get(st->groups, first); switch (major) { @@ -320,7 +320,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) if (spacing<0) spacing = 0; } break; - } + } /*for each in the run */ i = first; @@ -352,7 +352,7 @@ static void layout_justify(LayoutStack *st, M_Layout *l) if (l->topToBottom && (i==li->first_child + li->nb_children)) break; else if (!l->topToBottom && (i==li->first_child - 1)) - break; + break; } if (l->leftToRight) { current_left += gf_mulfix(l->spacing, li->width); @@ -409,7 +409,7 @@ static void layout_setup_scroll_bounds(LayoutStack *st, M_Layout *l) } break; } - } + } /*scroll-in only*/ else { st->scroll_max = 0; @@ -486,12 +486,12 @@ static void layout_scroll(GF_TraverseState *tr_state, LayoutStack *st, M_Layout time = gf_node_get_scene_time((GF_Node *)l); - // if (st->scale_scroll && (st->prev_rate!=st->scale_scroll)) st->start_scroll_type = 1; + // if (st->scale_scroll && (st->prev_rate!=st->scale_scroll)) st->start_scroll_type = 1; - /*if scroll rate changed to previous non-zero value, this is a + /*if scroll rate changed to previous non-zero value, this is a scroll restart, don't re-update bounds*/ if ((st->start_scroll_type==2) && (st->prev_rate==st->scale_scroll)) st->start_scroll_type = 0; - + if (st->start_scroll_type) { st->start_time = time; st->is_scrolling = 1; @@ -580,7 +580,7 @@ static void layout_scroll(GF_TraverseState *tr_state, LayoutStack *st, M_Layout scrolled = scroll_diff; } - if (do_scroll) + if (do_scroll) st->last_scroll = scrolled; else scrolled = st->last_scroll; @@ -635,7 +635,7 @@ static void TraverseLayout(GF_Node *node, void *rs, Bool is_destroy) gf_free(st); return; } - + /*note we don't clear dirty flag, this is done in traversing*/ if (gf_node_dirty_get(node) & GF_SG_NODE_DIRTY) { @@ -651,12 +651,12 @@ static void TraverseLayout(GF_Node *node, void *rs, Bool is_destroy) st->bounds = st->clip = gf_rect_center(st->clip.width, st->clip.height); if (st->scale_scroll && !st->start_scroll_type) st->start_scroll_type = 1; - + drawable_reset_group_highlight(tr_state, node); } /*don't waste time traversing is pick ray not in clipper*/ - if ((tr_state->traversing_mode==TRAVERSE_PICK) && !gf_sc_pick_in_clipper(tr_state, &st->clip)) + if ((tr_state->traversing_mode==TRAVERSE_PICK) && !gf_sc_pick_in_clipper(tr_state, &st->clip)) goto layout_exit; if ((tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) && !tr_state->for_node) { @@ -668,7 +668,7 @@ static void TraverseLayout(GF_Node *node, void *rs, Bool is_destroy) } recompute_layout = 0; - if (gf_node_dirty_get(node)) + if (gf_node_dirty_get(node)) recompute_layout = 1; /*setup clipping*/ @@ -707,7 +707,7 @@ static void TraverseLayout(GF_Node *node, void *rs, Bool is_destroy) /*apply justification*/ layout_justify(st, l); - + /*if scrolling, update bounds*/ if (l->scrollRate && st->is_scrolling) { layout_setup_scroll_bounds(st, l); @@ -816,7 +816,7 @@ void compositor_layout_modified(GF_Compositor *compositor, GF_Node *node) /*if modif other than scrollrate restart scroll*/ if (st->scroll_rate == ((M_Layout*)node)->scrollRate) { st->start_scroll_type = 1; - } + } /*if modif on scroll rate only, indicate continous restart*/ else if (((M_Layout*)node)->scrollRate) { st->start_scroll_type = 2; diff --git a/src/compositor/mpeg4_lighting.c b/src/compositor/mpeg4_lighting.c index c86a1ab..061207b 100644 --- a/src/compositor/mpeg4_lighting.c +++ b/src/compositor/mpeg4_lighting.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,7 +44,10 @@ static void TraverseSpotLight(GF_Node *n, void *rs, Bool is_destroy) gf_free(vis); return; } - if (!sl->on) return; + if (!sl->on) { + visual_3d_has_inactive_light(tr_state->visual); + return; + } /*store local bounds for culling*/ if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) { @@ -64,14 +67,10 @@ static void TraverseSpotLight(GF_Node *n, void *rs, Bool is_destroy) else if (tr_state->traversing_mode == TRAVERSE_LIGHTING) { Bool *visible = gf_node_get_private(n); if (*visible) { - - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, tr_state->model_matrix.m); - - visual_3d_add_spot_light(tr_state->visual, sl->ambientIntensity, sl->attenuation, sl->beamWidth, - sl->color, sl->cutOffAngle, sl->direction, sl->intensity, sl->location); - - visual_3d_matrix_pop(tr_state->visual); + visual_3d_add_spot_light(tr_state->visual, sl->ambientIntensity, sl->attenuation, sl->beamWidth, + sl->color, sl->cutOffAngle, sl->direction, sl->intensity, sl->location, &tr_state->model_matrix); + } else { + visual_3d_has_inactive_light(tr_state->visual); } } } @@ -95,7 +94,10 @@ static void TraversePointLight(GF_Node *n, void *rs, Bool is_destroy) gf_free(vis); return; } - if (!pl->on) return; + if (!pl->on) { + visual_3d_has_inactive_light(tr_state->visual); + return; + } /*store local bounds for culling*/ if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) { @@ -114,13 +116,10 @@ static void TraversePointLight(GF_Node *n, void *rs, Bool is_destroy) else if (tr_state->traversing_mode == TRAVERSE_LIGHTING) { Bool *visible = gf_node_get_private(n); if (*visible) { - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_add(tr_state->visual, tr_state->model_matrix.m); - - visual_3d_add_point_light(tr_state->visual, pl->ambientIntensity, pl->attenuation, pl->color, - pl->intensity, pl->location); - - visual_3d_matrix_pop(tr_state->visual); + visual_3d_add_point_light(tr_state->visual, pl->ambientIntensity, pl->attenuation, pl->color, + pl->intensity, pl->location, &tr_state->model_matrix); + } else { + visual_3d_has_inactive_light(tr_state->visual); } } } @@ -145,17 +144,21 @@ static void TraverseDirectionalLight(GF_Node *n, void *rs, Bool is_destroy) gf_free(stack); return; } - if (tr_state->switched_off || !dl->on) return; + if (tr_state->switched_off || !dl->on) { + visual_3d_has_inactive_light(tr_state->visual); + return; + } /*1- DL only lights the parent group, no need for culling it*/ /*DL is set dynamically while traversing, the only mode that interest us is draw*/ if (tr_state->traversing_mode) return; if (tr_state->local_light_on) { - *stack = visual_3d_add_directional_light(tr_state->visual, dl->ambientIntensity, dl->color, dl->intensity, dl->direction); + *stack = visual_3d_add_directional_light(tr_state->visual, dl->ambientIntensity, dl->color, dl->intensity, dl->direction, &tr_state->model_matrix); } else { if (*stack) visual_3d_remove_last_light(tr_state->visual); *stack = 0; + visual_3d_has_inactive_light(tr_state->visual); } } diff --git a/src/compositor/mpeg4_path_layout.c b/src/compositor/mpeg4_path_layout.c index a8f5420..efb9a99 100644 --- a/src/compositor/mpeg4_path_layout.c +++ b/src/compositor/mpeg4_path_layout.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ typedef struct { PARENT_MPEG4_STACK_2D - + GF_Node *last_geom; GF_PathIterator *iter; } PathLayoutStack; @@ -55,7 +55,7 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) PathLayoutStack *gr = (PathLayoutStack*) gf_node_get_private(node); M_PathLayout *pl = (M_PathLayout *)node; GF_TraverseState *tr_state = (GF_TraverseState *) rs; - + if (is_destroy) { parent_node_predestroy((ParentNode2D *)gr); if (gr->iter) gf_path_iterator_del(gr->iter); @@ -63,12 +63,15 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) return; } if (!pl->geometry) return; - + /*only low-level primitives allowed*/ switch (gf_node_get_tag((GF_Node *) pl->geometry)) { - case TAG_MPEG4_Rectangle: return; - case TAG_MPEG4_Circle: return; - case TAG_MPEG4_Ellipse: return; + case TAG_MPEG4_Rectangle: + return; + case TAG_MPEG4_Circle: + return; + case TAG_MPEG4_Ellipse: + return; } /*store traversing state*/ @@ -76,7 +79,7 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) gf_mx_copy(mat, tr_state->model_matrix); gf_mx_init(tr_state->model_matrix); #endif - + gf_mx2d_copy(mx2d, tr_state->transform); gf_mx2d_init(tr_state->transform); @@ -142,7 +145,7 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) gf_mx2d_copy(tr_state->transform, mx2d); count = gf_list_count(gr->groups); - + length = gf_path_iterator_get_length(gr->iter); /*place all children*/ offset = gf_mulfix(length, pl->pathOffset); @@ -197,22 +200,22 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) switch (minor) { /*top alignment*/ case 3: - if (cg->ascent) + if (cg->ascent) gf_mx2d_add_translation(&mx2d, 0, -1 * cg->ascent); - else + else gf_mx2d_add_translation(&mx2d, 0, -1 * cg->original.height / 2); - + break; /*baseline*/ case 1: /*move to bottom align if not text*/ - if (!cg->ascent) + if (!cg->ascent) gf_mx2d_add_translation(&mx2d, 0, cg->original.height / 2); break; /*middle*/ case 2: /*if text use (asc+desc) /2 as line height since glyph height differ*/ - if (cg->ascent) + if (cg->ascent) gf_mx2d_add_translation(&mx2d, 0, cg->descent - (cg->ascent + cg->descent) / 2); break; /*bottomline alignment*/ @@ -222,7 +225,7 @@ static void TraversePathLayout(GF_Node *node, void *rs, Bool is_destroy) gf_mx2d_add_translation(&mx2d, 0, cg->descent); else gf_mx2d_add_translation(&mx2d, 0, cg->original.height / 2); - + break; } res = gf_path_iterator_get_transform(gr->iter, offset, (Bool) (pl->wrapMode==2), &mx2d, 1, length_after_point); @@ -257,7 +260,7 @@ next: } /*undrawn nodes*/ - for (;igroups, i); parent_node_child_traverse_matrix(cg, (GF_TraverseState *)rs, NULL); } diff --git a/src/compositor/mpeg4_sensors.c b/src/compositor/mpeg4_sensors.c index 13170d0..96f498a 100644 --- a/src/compositor/mpeg4_sensors.c +++ b/src/compositor/mpeg4_sensors.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,7 +48,7 @@ static void mpeg4_sensor_deleted(GF_Node *node, GF_SensorHandler *hdl) gf_list_del_item(compositor->previous_sensors, hdl); if (compositor->interaction_sensors) compositor->interaction_sensors--; while ( (visual=gf_list_enum(compositor->visuals, &i)) ) { - if (visual->offscreen) + if (visual->offscreen) compositor_compositetexture_sensor_delete(visual->offscreen, hdl); } @@ -165,9 +165,9 @@ static Bool OnAnchor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_Even if ((ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT)) st->active = 1; else if ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) st->active = 1; else if (st->active && ( - /*mouse*/ ((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*mouse*/((ev->type==GF_EVENT_KEYUP) && (ev->key.key_code==GF_KEY_ENTER)) - ) ) { + /*mouse*/ ((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*mouse*/((ev->type==GF_EVENT_KEYUP) && (ev->key.key_code==GF_KEY_ENTER)) + ) ) { if (!is_cancel) anchor_activation(sh->sensor, st, compositor); } else if (is_over && !st->over) { st->over = 1; @@ -233,7 +233,7 @@ void compositor_init_anchor(GF_Compositor *compositor, GF_Node *node) } -typedef struct +typedef struct { GF_SensorHandler hdl; GF_Compositor *compositor; @@ -262,12 +262,12 @@ static Bool OnDiscSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_ Bool is_mouse = (ev->type<=GF_EVENT_MOUSEWHEEL) ? 1 : 0; M_DiscSensor *ds = (M_DiscSensor *)sh->sensor; DiscSensorStack *stack = (DiscSensorStack *) gf_node_get_private(sh->sensor); - - if (ds->isActive && - (!ds->enabled - || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) - ) ) { + + if (ds->isActive && + (!ds->enabled + || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) + ) ) { if (ds->autoOffset) { ds->offset = ds->rotation_changed; /*that's an exposedField*/ @@ -294,7 +294,7 @@ static Bool OnDiscSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_ loc_ray = compositor->hit_world_ray; gf_mx_apply_ray(&stack->initial_matrix, &loc_ray); compositor_get_2d_plane_intersection(&loc_ray, &res); - + rot = gf_atan2(res.y, res.x) - stack->start_angle + ds->offset; if (ds->minAngle < ds->maxAngle) { /*FIXME this doesn't work properly*/ @@ -303,8 +303,8 @@ static Bool OnDiscSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_ } ds->rotation_changed = rot; gf_node_event_out_str(sh->sensor, "rotation_changed"); - ds->trackPoint_changed.x = res.x; - ds->trackPoint_changed.y = res.y; + ds->trackPoint_changed.x = res.x; + ds->trackPoint_changed.y = res.y; gf_node_event_out_str(sh->sensor, "trackPoint_changed"); return 1; } @@ -320,18 +320,18 @@ static Bool OnDiscSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_ Fixed diff = (ev->key.flags & GF_KEY_MOD_SHIFT) ? GF_PI/8 : GF_PI/64; res = stack->start_angle; switch (ev->key.key_code) { - case GF_KEY_LEFT: - case GF_KEY_UP: - res += -diff; + case GF_KEY_LEFT: + case GF_KEY_UP: + res += -diff; break; - case GF_KEY_RIGHT: - case GF_KEY_DOWN: + case GF_KEY_RIGHT: + case GF_KEY_DOWN: res += diff; break; case GF_KEY_HOME: res = ds->offset; break; - default: + default: return 0; } if (ds->minAngle < ds->maxAngle) { @@ -369,7 +369,7 @@ void compositor_init_disc_sensor(GF_Compositor *compositor, GF_Node *node) } -typedef struct +typedef struct { SFVec2f start_drag; GF_Matrix initial_matrix; @@ -399,11 +399,11 @@ static Bool OnPlaneSensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, PS2DStack *stack = (PS2DStack *) gf_node_get_private(sh->sensor); - if (ps->isActive && - (!ps->enabled - || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) - ) ) { + if (ps->isActive && + (!ps->enabled + || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) + ) ) { if (ps->autoOffset) { ps->offset = ps->translation_changed; if (!is_cancel) gf_node_event_out_str(sh->sensor, "offset"); @@ -423,7 +423,7 @@ static Bool OnPlaneSensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, sh->grabbed = 1; /*fallthrough to fire mouse coords*/ //return 1; - } + } if (ps->isActive) { SFVec3f res; GF_Ray loc_ray; @@ -444,9 +444,9 @@ static Bool OnPlaneSensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, if (res.x > ps->maxPosition.x) res.x = ps->maxPosition.x; } if (ps->minPosition.y <= ps->maxPosition.y) { - if (res.y < ps->minPosition.y) + if (res.y < ps->minPosition.y) res.y = ps->minPosition.y; - if (res.y > ps->maxPosition.y) + if (res.y > ps->maxPosition.y) res.y = ps->maxPosition.y; } ps->translation_changed.x = res.x; @@ -468,12 +468,22 @@ static Bool OnPlaneSensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, diff = gf_divfix(diff, INT2FIX(compositor->vp_width/2)); res = stack->start_drag; switch (ev->key.key_code) { - case GF_KEY_LEFT: res.x += -diff; break; - case GF_KEY_RIGHT: res.x += diff; break; - case GF_KEY_UP: res.y += diff; break; - case GF_KEY_DOWN: res.y += -diff; break; - case GF_KEY_HOME: res = ps->offset; break; - default: + case GF_KEY_LEFT: + res.x += -diff; + break; + case GF_KEY_RIGHT: + res.x += diff; + break; + case GF_KEY_UP: + res.y += diff; + break; + case GF_KEY_DOWN: + res.y += -diff; + break; + case GF_KEY_HOME: + res = ps->offset; + break; + default: return 0; } /*clip*/ @@ -518,7 +528,7 @@ void compositor_init_plane_sensor2d(GF_Compositor *compositor, GF_Node *node) } -typedef struct +typedef struct { Double last_time; GF_Compositor *compositor; @@ -552,9 +562,9 @@ static Bool OnProximitySensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_canc { M_ProximitySensor2D *ps = (M_ProximitySensor2D *)sh->sensor; Prox2DStack *stack = (Prox2DStack *) gf_node_get_private(sh->sensor); - + assert(ps->enabled); - + if (is_over) { stack->last_time = gf_node_get_scene_time(sh->sensor); if (is_cancel) return 0; @@ -571,7 +581,7 @@ static Bool OnProximitySensor2D(GF_SensorHandler *sh, Bool is_over, Bool is_canc } return 1; } - } + } /*either we're not over the shape or we're not in sensor*/ if (ps->isActive) { ps->exitTime = stack->last_time; @@ -604,7 +614,7 @@ void compositor_init_proximity_sensor2d(GF_Compositor *compositor, GF_Node *node gf_node_set_callback_function(node, DestroyProximitySensor2D); } -typedef struct +typedef struct { GF_SensorHandler hdl; Bool mouse_down; @@ -629,7 +639,7 @@ static Bool OnTouchSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF { Bool is_mouse = (ev->type<=GF_EVENT_MOUSEWHEEL); M_TouchSensor *ts = (M_TouchSensor *)sh->sensor; - + /*this is not specified in VRML, however we consider that a de-enabled sensor will not sent deactivation events*/ if (!ts->enabled) { if (ts->isActive) { @@ -641,26 +651,26 @@ static Bool OnTouchSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF /*isActive becomes false, send touch time*/ if (ts->isActive) { if ( - /*mouse*/ ((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT) ) - || /*keyboard*/ ((ev->type==GF_EVENT_KEYUP) && (ev->key.key_code==GF_KEY_ENTER) ) + /*mouse*/ ((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT) ) + || /*keyboard*/ ((ev->type==GF_EVENT_KEYUP) && (ev->key.key_code==GF_KEY_ENTER) ) ) { ts->touchTime = gf_node_get_scene_time(sh->sensor); if (!is_cancel) gf_node_event_out_str(sh->sensor, "touchTime"); ts->isActive = 0; if (!is_cancel) gf_node_event_out_str(sh->sensor, "isActive"); sh->grabbed = 0; - return is_cancel ? 0 : 1; + return is_cancel ? 0 : 1; } } if (is_over != ts->isOver) { ts->isOver = is_over; if (!is_cancel) gf_node_event_out_str(sh->sensor, "isOver"); - return is_cancel ? 0 : 1; + return is_cancel ? 0 : 1; } if (!ts->isActive && is_over) { - if (/*mouse*/ ((ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboard*/ ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) - ) { + if (/*mouse*/ ((ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboard*/ ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) + ) { ts->isActive = 1; gf_node_event_out_str(sh->sensor, "isActive"); sh->grabbed = 1; @@ -669,7 +679,7 @@ static Bool OnTouchSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF if (ev->type==GF_EVENT_MOUSEUP) return 0; } if (is_over && is_mouse) { - /*THIS IS NOT CONFORMANT, the hitpoint should be in the touchsensor coordinate system, eg we + /*THIS IS NOT CONFORMANT, the hitpoint should be in the touchsensor coordinate system, eg we should store the matrix from TS -> shape and apply that ...*/ ts->hitPoint_changed = compositor->hit_local_point; gf_node_event_out_str(sh->sensor, "hitPoint_changed"); @@ -734,9 +744,9 @@ void TraverseProximitySensor(GF_Node *node, void *rs, Bool is_destroy) if (dist.y<0) dist.y *= -1; if (dist.z<0) dist.z *= -1; - if ((2*dist.x <= ps->size.x) - && (2*dist.y <= ps->size.y) - && (2*dist.z <= ps->size.z) ) { + if ((2*dist.x <= ps->size.x) + && (2*dist.y <= ps->size.y) + && (2*dist.z <= ps->size.z) ) { if (!ps->isActive) { ps->isActive = 1; @@ -745,8 +755,8 @@ void TraverseProximitySensor(GF_Node *node, void *rs, Bool is_destroy) gf_node_event_out_str(node, "enterTime"); } if ((ps->position_changed.x != user_pos.x) - || (ps->position_changed.y != user_pos.y) - || (ps->position_changed.z != user_pos.z) ) + || (ps->position_changed.y != user_pos.y) + || (ps->position_changed.z != user_pos.z) ) { ps->position_changed = user_pos; gf_node_event_out_str(node, "position_changed"); @@ -757,9 +767,9 @@ void TraverseProximitySensor(GF_Node *node, void *rs, Bool is_destroy) gf_mx_apply_vec(&mx, &up); ori = camera_get_orientation(user_pos, dist, tr_state->camera->up); if ((ori.q != ps->orientation_changed.q) - || (ori.x != ps->orientation_changed.x) - || (ori.y != ps->orientation_changed.y) - || (ori.z != ps->orientation_changed.z) ) { + || (ori.x != ps->orientation_changed.x) + || (ori.y != ps->orientation_changed.y) + || (ori.z != ps->orientation_changed.z) ) { ps->orientation_changed = ori; gf_node_event_out_str(node, "orientation_changed"); } @@ -777,7 +787,7 @@ void compositor_init_proximity_sensor(GF_Compositor *compositor, GF_Node *node) } -typedef struct +typedef struct { SFVec3f start_drag; GF_Plane tracker; @@ -807,11 +817,11 @@ static Bool OnPlaneSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF M_PlaneSensor *ps = (M_PlaneSensor *)sh->sensor; PSStack *stack = (PSStack *) gf_node_get_private(sh->sensor); - - if (ps->isActive && - ( /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) - ) ) { + + if (ps->isActive && + ( /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER))) ) + ) ) { if (ps->autoOffset) { ps->offset = ps->translation_changed; if (!is_cancel) gf_node_event_out_str(sh->sensor, "offset"); @@ -819,14 +829,15 @@ static Bool OnPlaneSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF ps->isActive = 0; if (!is_cancel) gf_node_event_out_str(sh->sensor, "isActive"); sh->grabbed = 0; - return is_cancel ? 0 : 1; + return is_cancel ? 0 : 1; } /*mouse*/ else if (is_mouse) { if (!ps->isActive && (ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT) ) { gf_mx_copy(stack->initial_matrix, compositor->hit_local_to_world); gf_vec_diff(stack->start_drag, compositor->hit_local_point, ps->offset); - stack->tracker.normal.x = stack->tracker.normal.y = 0; stack->tracker.normal.z = FIX_ONE; + stack->tracker.normal.x = stack->tracker.normal.y = 0; + stack->tracker.normal.z = FIX_ONE; stack->tracker.d = - gf_vec_dot(stack->start_drag, stack->tracker.normal); ps->isActive = 1; gf_node_event_out_str(sh->sensor, "isActive"); @@ -871,12 +882,22 @@ static Bool OnPlaneSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF res = stack->start_drag; switch (ev->key.key_code) { - case GF_KEY_LEFT: res.x -= diff; break; - case GF_KEY_RIGHT: res.x += diff; break; - case GF_KEY_UP: res.y += diff; break; - case GF_KEY_DOWN: res.y -= diff; break; - case GF_KEY_HOME: res = ps->offset; break; - default: + case GF_KEY_LEFT: + res.x -= diff; + break; + case GF_KEY_RIGHT: + res.x += diff; + break; + case GF_KEY_UP: + res.y += diff; + break; + case GF_KEY_DOWN: + res.y -= diff; + break; + case GF_KEY_HOME: + res = ps->offset; + break; + default: return 0; } /*clip*/ @@ -917,7 +938,7 @@ void compositor_init_plane_sensor(GF_Compositor *compositor, GF_Node *node) gf_node_set_callback_function(node, DestroyPlaneSensor); } -typedef struct +typedef struct { GF_SensorHandler hdl; GF_Compositor *compositor; @@ -948,10 +969,10 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, M_CylinderSensor *cs = (M_CylinderSensor *)sh->sensor; CylinderSensorStack *st = (CylinderSensorStack *) gf_node_get_private(sh->sensor); - if (cs->isActive && (!cs->enabled - || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)))) - ) ) { + if (cs->isActive && (!cs->enabled + || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)))) + ) ) { if (cs->autoOffset) { cs->offset = cs->rotation_changed.q; if (!is_cancel) gf_node_event_out_str(sh->sensor, "offset"); @@ -979,7 +1000,7 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, yaxis.x = yaxis.z = 0; yaxis.y = FIX_ONE; acute = gf_vec_dot(bearing, yaxis); - if (acute < -FIX_ONE) acute = -FIX_ONE; + if (acute < -FIX_ONE) acute = -FIX_ONE; else if (acute > FIX_ONE) acute = FIX_ONE; acute = gf_acos(acute); reva = ABS(GF_PI - acute); @@ -988,7 +1009,8 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, st->grab_start = compositor->hit_local_point; /*cos we're lazy*/ - st->yplane.d = 0; st->yplane.normal.x = st->yplane.normal.z = st->yplane.normal.y = 0; + st->yplane.d = 0; + st->yplane.normal.x = st->yplane.normal.z = st->yplane.normal.y = 0; st->zplane = st->xplane = st->yplane; st->xplane.normal.x = FIX_ONE; st->yplane.normal.y = FIX_ONE; @@ -1027,14 +1049,18 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, if (!gf_plane_intersect_line(&project_to, &r.orig, &r.dir, &compositor->hit_local_point)) return 0; } - dir1.x = compositor->hit_local_point.x; dir1.y = 0; dir1.z = compositor->hit_local_point.z; + dir1.x = compositor->hit_local_point.x; + dir1.y = 0; + dir1.z = compositor->hit_local_point.z; if (st->disk_mode) { radius = FIX_ONE; } else { radius = gf_vec_len(dir1); } gf_vec_norm(&dir1); - dir2.x = st->grab_start.x; dir2.y = 0; dir2.z = st->grab_start.z; + dir2.x = st->grab_start.x; + dir2.y = 0; + dir2.z = st->grab_start.z; gf_vec_norm(&dir2); cx = gf_vec_cross(dir2, dir1); gf_vec_norm(&cx); @@ -1050,7 +1076,7 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, cs->rotation_changed.q = rot; gf_node_event_out_str(sh->sensor, "rotation_changed"); return 1; - } + } } else { if (!cs->isActive && is_over && (ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) { cs->isActive = 1; @@ -1066,10 +1092,17 @@ static Bool OnCylinderSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, res = cs->rotation_changed.q; switch (ev->key.key_code) { - case GF_KEY_LEFT: res -= diff; break; - case GF_KEY_RIGHT: res += diff; break; - case GF_KEY_HOME: res = cs->offset; break; - default: return 0; + case GF_KEY_LEFT: + res -= diff; + break; + case GF_KEY_RIGHT: + res += diff; + break; + case GF_KEY_HOME: + res = cs->offset; + break; + default: + return 0; } /*clip*/ if (cs->minAngle <= cs->maxAngle) { @@ -1105,7 +1138,7 @@ void compositor_init_cylinder_sensor(GF_Compositor *compositor, GF_Node *node) } -typedef struct +typedef struct { GF_SensorHandler hdl; GF_Compositor *compositor; @@ -1136,10 +1169,10 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G SphereSensorStack *st = (SphereSensorStack *) gf_node_get_private(sh->sensor); - if (sphere->isActive && (!sphere->enabled - || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) - || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)))) - ) ) { + if (sphere->isActive && (!sphere->enabled + || /*mouse*/((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) + || /*keyboar*/(!is_mouse && (!is_over|| ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)))) + ) ) { if (sphere->autoOffset) { sphere->offset = sphere->rotation_changed; if (!is_cancel) gf_node_event_out_str(sh->sensor, "offset"); @@ -1147,7 +1180,7 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G sphere->isActive = 0; if (!is_cancel) gf_node_event_out_str(sh->sensor, "isActive"); sh->grabbed = 0; - return is_cancel ? 0 : 1; + return is_cancel ? 0 : 1; } else if (is_mouse) { if (!sphere->isActive && (ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT)) { @@ -1191,7 +1224,9 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G if (gf_vec_dot(st->grab_vec, vec) < 0) r.q += GF_PI / 2; gf_vec_norm(&axis); - r.x = axis.x; r.y = axis.y; r.z = axis.z; + r.x = axis.x; + r.y = axis.y; + r.z = axis.z; q1 = gf_quat_from_rotation(r); if (sphere->autoOffset) { q2 = gf_quat_from_rotation(sphere->offset); @@ -1200,7 +1235,7 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G sphere->rotation_changed = gf_quat_to_rotation(&q1); gf_node_event_out_str(sh->sensor, "rotation_changed"); return 1; - } + } } else { if (!sphere->isActive && is_over && (ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) { sphere->isActive = 1; @@ -1214,10 +1249,13 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G res = sphere->rotation_changed; switch (ev->key.key_code) { - case GF_KEY_LEFT: + case GF_KEY_LEFT: diff = -diff; - case GF_KEY_RIGHT: - rot.x = 0; rot.y = FIX_ONE; rot.z = 0; rot.q = diff; + case GF_KEY_RIGHT: + rot.x = 0; + rot.y = FIX_ONE; + rot.z = 0; + rot.q = diff; res = gf_quat_from_rotation(res); rot = gf_quat_from_rotation(rot); rot = gf_quat_multiply(&rot, &res); @@ -1227,18 +1265,24 @@ static Bool OnSphereSensor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, G diff = -diff; case GF_KEY_UP: if (ev->key.flags & GF_KEY_MOD_SHIFT) { - rot.x = 0; rot.z = FIX_ONE; + rot.x = 0; + rot.z = FIX_ONE; } else { - rot.x = FIX_ONE; rot.z = 0; + rot.x = FIX_ONE; + rot.z = 0; } - rot.y = 0; rot.q = diff; + rot.y = 0; + rot.q = diff; res = gf_quat_from_rotation(res); rot = gf_quat_from_rotation(rot); rot = gf_quat_multiply(&rot, &res); res = gf_quat_to_rotation(&rot); break; - case GF_KEY_HOME: res = sphere->offset; break; - default: return 0; + case GF_KEY_HOME: + res = sphere->offset; + break; + default: + return 0; } sphere->rotation_changed = res; gf_node_event_out_str(sh->sensor, "rotation_changed"); @@ -1272,7 +1316,7 @@ void TraverseVisibilitySensor(GF_Node *node, void *rs, Bool is_destroy) { GF_TraverseState *tr_state = (GF_TraverseState *)rs; M_VisibilitySensor *vs = (M_VisibilitySensor *)node; - + if (is_destroy || !vs->enabled) return; if (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) { @@ -1319,24 +1363,30 @@ void compositor_init_visibility_sensor(GF_Compositor *compositor, GF_Node *node) #endif GF_SensorHandler *compositor_mpeg4_get_sensor_handler(GF_Node *n) +{ + return compositor_mpeg4_get_sensor_handler_ex(n, GF_FALSE); +} +GF_SensorHandler *compositor_mpeg4_get_sensor_handler_ex(GF_Node *n, Bool skip_anchors) { GF_SensorHandler *hs; switch (gf_node_get_tag(n)) { /*anchor is not considered as a child sensor node when picking sensors*/ - case TAG_MPEG4_Anchor: - hs = gf_sc_anchor_get_handler(n); + case TAG_MPEG4_Anchor: + if (skip_anchors) return NULL; + hs = gf_sc_anchor_get_handler(n); break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Anchor: - hs = gf_sc_anchor_get_handler(n); + case TAG_X3D_Anchor: + if (skip_anchors) return NULL; + hs = gf_sc_anchor_get_handler(n); break; #endif - case TAG_MPEG4_DiscSensor: - hs = disc_sensor_get_handler(n); + case TAG_MPEG4_DiscSensor: + hs = disc_sensor_get_handler(n); break; - case TAG_MPEG4_PlaneSensor2D: - hs = plane_sensor2d_get_handler(n); + case TAG_MPEG4_PlaneSensor2D: + hs = plane_sensor2d_get_handler(n); break; case TAG_MPEG4_ProximitySensor2D: hs = proximity_sensor2d_get_handler(n); @@ -1350,28 +1400,29 @@ GF_SensorHandler *compositor_mpeg4_get_sensor_handler(GF_Node *n) break; #endif #ifndef GPAC_DISABLE_3D - case TAG_MPEG4_CylinderSensor: + case TAG_MPEG4_CylinderSensor: hs = cylinder_sensor_get_handler(n); break; - case TAG_MPEG4_PlaneSensor: + case TAG_MPEG4_PlaneSensor: hs = plane_sensor_get_handler(n); break; - case TAG_MPEG4_SphereSensor: + case TAG_MPEG4_SphereSensor: hs = sphere_get_handler(n); break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_CylinderSensor: + case TAG_X3D_CylinderSensor: hs = cylinder_sensor_get_handler(n); break; - case TAG_X3D_PlaneSensor: + case TAG_X3D_PlaneSensor: hs = plane_sensor_get_handler(n); break; - case TAG_X3D_SphereSensor: + case TAG_X3D_SphereSensor: hs = sphere_get_handler(n); break; #endif #endif /*GPAC_DISABLE_3D*/ - default: return NULL; + default: + return NULL; } if (hs && hs->IsEnabled(n)) return hs; return NULL; @@ -1510,7 +1561,7 @@ void compositor_evaluate_envtests(GF_Compositor *compositor, u32 param_type) { u32 i, count; count = gf_list_count(compositor->env_tests); - for (i=0;ienv_tests, i); if (!((M_EnvironmentTest *)envtest)->evaluateOnChange) continue; @@ -1531,7 +1582,7 @@ void compositor_evaluate_envtests(GF_Compositor *compositor, u32 param_type) case 6: if (param_type==2) envtest_evaluate(envtest, NULL); break; - /*the rest are static events*/ + /*the rest are static events*/ } } } diff --git a/src/compositor/mpeg4_sound.c b/src/compositor/mpeg4_sound.c index 19df81f..6ddb29b 100644 --- a/src/compositor/mpeg4_sound.c +++ b/src/compositor/mpeg4_sound.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,7 +42,7 @@ static void TraverseSound2D(GF_Node *node, void *rs, Bool is_destroy) GF_TraverseState *tr_state = (GF_TraverseState*) rs; M_Sound2D *snd = (M_Sound2D *)node; Sound2DStack *st = (Sound2DStack *)gf_node_get_private(node); - + if (is_destroy) { gf_free(st); return; @@ -54,12 +54,12 @@ static void TraverseSound2D(GF_Node *node, void *rs, Bool is_destroy) st->pos.y = snd->location.y; st->pos.z = 0; #ifndef GPAC_DISABLE_3D - if (tr_state->visual->type_3d) + if (tr_state->visual->type_3d) gf_mx_apply_vec(&tr_state->model_matrix, &st->pos); else #endif gf_mx2d_apply_coords(&tr_state->transform, &st->pos.x, &st->pos.y); - + tr_state->sound_holder = &st->snd_ifce; gf_node_traverse((GF_Node *) snd->source, tr_state); @@ -93,7 +93,7 @@ void compositor_init_sound2d(GF_Compositor *compositor, GF_Node *node) #ifndef GPAC_DISABLE_3D static Fixed snd_compute_gain(Fixed min_b, Fixed min_f, Fixed max_b, Fixed max_f, SFVec3f pos) -{ +{ Fixed sqpos_x, sqpos_z; Fixed y_pos, x_pos, dist_ellip, viewp_dist, dist_from_foci_min, dist_from_foci_max, d_min, d_max, sqb_min, sqb_max; Fixed a_in = (min_f+min_b)/2; @@ -114,7 +114,7 @@ static Fixed snd_compute_gain(Fixed min_b, Fixed min_f, Fixed max_b, Fixed max_f sqpos_z = gf_mulfix(pos.z, pos.z); dist_from_foci_min = gf_sqrt(sqpos_z + sqpos_x) + gf_sqrt( gf_mulfix(pos.z - dist_foci_min, pos.z - dist_foci_min) + sqpos_x); - dist_from_foci_max = gf_sqrt(sqpos_z + sqpos_x) + gf_sqrt( gf_mulfix(pos.z - dist_foci_max, pos.z - dist_foci_max) + sqpos_x); + dist_from_foci_max = gf_sqrt(sqpos_z + sqpos_x) + gf_sqrt( gf_mulfix(pos.z - dist_foci_max, pos.z - dist_foci_max) + sqpos_x); d_min = min_f+min_b; d_max = max_f+max_b; if(dist_from_foci_max > d_max) return 0; @@ -210,7 +210,7 @@ static void TraverseSound(GF_Node *node, void *rs, Bool is_destroy) mag = gf_vec_len(usr); if (!mag) mag = FIX_ONE/10; ang = gf_divfix(gf_vec_dot(snd_dir, usr), mag); - + usr.z = gf_mulfix(ang, mag); usr.x = gf_sqrt(gf_mulfix(mag, mag) - gf_mulfix(usr.z, usr.z)); usr.y = 0; diff --git a/src/compositor/mpeg4_text.c b/src/compositor/mpeg4_text.c index 467eb10..752fe7b 100644 --- a/src/compositor/mpeg4_text.c +++ b/src/compositor/mpeg4_text.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -86,7 +86,7 @@ static void build_text_split(TextStack *st, M_Text *txt, GF_TraverseState *tr_st if (fontSize <= 0) { fontSize = INT2FIX(12); if (!tr_state->pixel_metrics) fontSize = gf_divfix(fontSize, tr_state->visual->compositor->output_width); - } + } styles = 0; if (fs && fs->style.buffer) { @@ -113,7 +113,7 @@ static void build_text_split(TextStack *st, M_Text *txt, GF_TraverseState *tr_st else { start_y = st->ascent; } - + st->bounds.width = st->bounds.x = st->bounds.height = 0; idx = 0; split_words = (tr_state->text_split_mode==1) ? 1 : 0; @@ -138,9 +138,9 @@ static void build_text_split(TextStack *st, M_Text *txt, GF_TraverseState *tr_st /*we currently only split sentences at spaces*/ if (tspan->glyphs[j]->utf_name == (unsigned short) ' ') is_space = 1; - else if (tspan->glyphs[j]->utf_name == (unsigned short) '\n') + else if (tspan->glyphs[j]->utf_name == (unsigned short) '\n') is_space = 2; - if (split_words && (j+1!=len) && !is_space) + if (split_words && (j+1!=len) && !is_space) continue; span = (GF_TextSpan*) gf_malloc(sizeof(GF_TextSpan)); @@ -213,7 +213,7 @@ static void build_text(TextStack *st, M_Text *txt, GF_TraverseState *tr_state) if (fontSize <= 0) { fontSize = INT2FIX(12); if (!tr_state->pixel_metrics) fontSize = gf_divfix(fontSize, tr_state->visual->compositor->output_width); - } + } horizontal = FSHORIZ; start_x = start_y = 0; @@ -254,7 +254,7 @@ static void build_text(TextStack *st, M_Text *txt, GF_TraverseState *tr_state) tspan = gf_font_manager_create_span(ft_mgr, font, txt->string.vals[i], fontSize, 0, 0, 0, NULL, 0, styles, (GF_Node*)txt); if (!tspan) continue; - + if (horizontal) tspan->flags |= GF_TEXT_SPAN_HORIZONTAL; size = 0; @@ -327,7 +327,7 @@ static void build_text(TextStack *st, M_Text *txt, GF_TraverseState *tr_state) } if (trim_tspan) gf_font_manager_delete_span(ft_mgr, trim_tspan); - + max_scale = FIX_ONE; if (horizontal) { if ((maxExtent > 0) && (tot_width>maxExtent)) { @@ -405,7 +405,7 @@ static void build_text(TextStack *st, M_Text *txt, GF_TraverseState *tr_state) } } } - + /*major-justification*/ if (!strcmp(FSMAJOR, "MIDDLE") ) { @@ -568,9 +568,9 @@ static void text_check_changes(GF_Node *node, TextStack *stack, GF_TraverseState gf_node_dirty_clear(node, 0); drawable_mark_modified(stack->graph, tr_state); } - + if (tr_state->visual->compositor->edited_text && (tr_state->visual->compositor->focus_node==node)) { - drawable_mark_modified(stack->graph, tr_state); + drawable_mark_modified(stack->graph, tr_state); tr_state->visual->has_text_edit = 1; if (!stack->bounds.width) stack->bounds.width = INT2FIX(1)/100; if (!stack->bounds.height) stack->bounds.height = INT2FIX(1)/100; @@ -649,12 +649,12 @@ static void Text_Traverse(GF_Node *n, void *rs, Bool is_destroy) /*if text selection mode, we must force redraw of the entire text span because we don't if glyphs have been (un)selected*/ - if (!tr_state->immediate_draw && - /*text selection on*/ - (tr_state->visual->compositor->text_selection - /*text sel release*/ - || (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED)) - ) { + if (!tr_state->immediate_draw && + /*text selection on*/ + (tr_state->visual->compositor->text_selection + /*text sel release*/ + || (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED)) + ) { GF_TextSpan *span; u32 i = 0; Bool unselect = (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED) ? 1 : 0; diff --git a/src/compositor/mpeg4_textures.c b/src/compositor/mpeg4_textures.c index 5e10d32..f3e46ce 100644 --- a/src/compositor/mpeg4_textures.c +++ b/src/compositor/mpeg4_textures.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -38,8 +38,8 @@ extern "C" { /*for cache texture decode and hash*/ #include #include - - + + typedef struct { GF_TextureHandler txh; @@ -92,7 +92,7 @@ static void movietexture_update(GF_TextureHandler *txh) { M_MovieTexture *txnode = (M_MovieTexture *) txh->owner; MovieTextureStack *st = (MovieTextureStack *) gf_node_get_private(txh->owner); - + /*setup texture if needed*/ if (!txh->is_open) return; if (!txnode->isActive && st->first_frame_fetched) return; @@ -133,7 +133,7 @@ static void movietexture_update_time(GF_TimeNode *st) Double time; M_MovieTexture *mt = (M_MovieTexture *)st->udta; MovieTextureStack *stack = (MovieTextureStack *)gf_node_get_private(st->udta); - + /*not active, store start time and speed*/ if ( ! mt->isActive) { stack->start_time = mt->startTime; @@ -141,10 +141,10 @@ static void movietexture_update_time(GF_TimeNode *st) time = gf_node_get_scene_time(st->udta); if (time < stack->start_time || - /*special case if we're getting active AFTER stoptime */ - (!mt->isActive && (mt->stopTime > stack->start_time) && (time>=mt->stopTime)) + /*special case if we're getting active AFTER stoptime */ + (!mt->isActive && (mt->stopTime > stack->start_time) && (time>=mt->stopTime)) // || (!stack->start_time && !stack->is_x3d && !mt->loop) - ) { + ) { /*opens stream only at first access to fetch first frame*/ if (stack->fetch_first_frame) { stack->fetch_first_frame = 0; @@ -165,7 +165,7 @@ static void movietexture_update_time(GF_TimeNode *st) } /*we're (about to be) active: VRML: - "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or + "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or equal to startTime, an isActive TRUE event is generated and the time-dependent node becomes active */ if (! mt->isActive) movietexture_activate(stack, mt, time); @@ -183,14 +183,14 @@ void compositor_init_movietexture(GF_Compositor *compositor, GF_Node *node) st->txh.flags = 0; if (((M_MovieTexture*)node)->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S; if (((M_MovieTexture*)node)->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T; - + #ifndef GPAC_DISABLE_X3D st->is_x3d = (gf_node_get_tag(node)==TAG_X3D_MovieTexture) ? 1 : 0; #endif gf_node_set_private(node, st); gf_node_set_callback_function(node, movietexture_destroy); - + gf_sc_register_time_node(compositor, &st->time_handle); } @@ -210,7 +210,7 @@ void compositor_movietexture_modified(GF_Node *node) if (gf_sc_texture_check_url_change(&st->txh, &mt->url)) { if (st->txh.is_open) gf_sc_texture_stop(&st->txh); if (mt->isActive) gf_sc_texture_play(&st->txh, &mt->url); - } + } /*update state if we're active*/ else if (mt->isActive) { movietexture_update_time(&st->time_handle); @@ -225,8 +225,8 @@ static void imagetexture_destroy(GF_Node *node, void *rs, Bool is_destroy) { if (is_destroy) { GF_TextureHandler *txh = (GF_TextureHandler *) gf_node_get_private(node); - - /*cleanup cache if needed*/ + + /*cleanup cache if needed*/ if (gf_node_get_tag(node)==TAG_MPEG4_CacheTexture) { char section[16]; const char *opt, *file; @@ -266,18 +266,18 @@ static void imagetexture_update(GF_TextureHandler *txh) gf_sc_texture_play(txh, &url); } gf_sc_texture_update_frame(txh, 0); - + if ( - /*URL is present but not opened - redraw till fetch*/ - /* (txh->stream && !txh->tx_io) && */ - /*image has been updated*/ - txh->needs_refresh) { + /*URL is present but not opened - redraw till fetch*/ + /* (txh->stream && !txh->tx_io) && */ + /*image has been updated*/ + txh->needs_refresh) { /*mark all subtrees using this image as dirty*/ gf_node_dirty_parents(txh->owner); gf_sc_invalidate(txh->compositor, NULL); } return; - } + } /*cache texture case*/ else { M_CacheTexture *ct = (M_CacheTexture *) txh->owner; @@ -295,7 +295,7 @@ static void imagetexture_update(GF_TextureHandler *txh) txh->needs_refresh = 1; txh->stride = out_size / txh->height; } - } + } /*BIFS decoded playback*/ else { switch (ct->objectTypeIndication) { @@ -463,7 +463,7 @@ void compositor_imagetexture_modified(GF_Node *node) return; } /*if not open and changed play*/ - if (url.count) + if (url.count) gf_sc_texture_play(txh, &url); } @@ -493,8 +493,8 @@ static void pixeltexture_update(GF_TextureHandler *txh) if (!gf_node_dirty_get(txh->owner)) return; gf_node_dirty_clear(txh->owner, 0); - - /*pixel texture doesn not use any media object but has data in the content. + + /*pixel texture doesn not use any media object but has data in the content. However we still use the same texture object, just be carefull not to use media funtcions*/ txh->transparent = 0; stride = pt->image.width; @@ -534,7 +534,7 @@ static void pixeltexture_update(GF_TextureHandler *txh) for (i=0; iimage.height; i++) { memcpy(st->pixels + i * stride, pt->image.pixels + i * stride, stride); } - } + } /*revert pixel ordering...*/ else { for (i=0; iimage.height; i++) { diff --git a/src/compositor/mpeg4_timesensor.c b/src/compositor/mpeg4_timesensor.c index 4cc31a4..78cd2e6 100644 --- a/src/compositor/mpeg4_timesensor.c +++ b/src/compositor/mpeg4_timesensor.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -88,7 +88,7 @@ void timesensor_update_time(GF_TimeNode *st) stack->start_time = TS->startTime; stack->cycle_interval = TS->cycleInterval; } - + currentTime = gf_node_get_scene_time(st->udta); if (!TS->isActive) { if (currentTime < stack->start_time) return; @@ -144,7 +144,7 @@ void timesensor_update_time(GF_TimeNode *st) } /*we're (about to be) active: VRML: - "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or + "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or equal to startTime, an isActive TRUE event is generated and the time-dependent node becomes active */ if (!TS->isActive) { @@ -181,7 +181,7 @@ void compositor_init_timesensor(GF_Compositor *compositor, GF_Node *node) gf_node_set_private(node, st); gf_node_set_callback_function(node, timesensor_destroy); /*time sensor needs to be run only if def'ed, otherwise it doesn't impact scene*/ - //if (gf_node_get_id(node)) + //if (gf_node_get_id(node)) gf_sc_register_time_node(compositor, &st->time_handle); } diff --git a/src/compositor/mpeg4_viewport.c b/src/compositor/mpeg4_viewport.c index 18495f8..c94f15f 100644 --- a/src/compositor/mpeg4_viewport.c +++ b/src/compositor/mpeg4_viewport.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,14 +42,20 @@ GF_Err gf_sc_get_viewpoint(GF_Compositor *compositor, u32 viewpoint_idx, const c n = (GF_Node*)gf_list_get(compositor->visual->view_stack, viewpoint_idx-1); switch (gf_node_get_tag(n)) { - case TAG_MPEG4_Viewport: *outName = ((M_Viewport*)n)->description.buffer; *is_bound = ((M_Viewport*)n)->isBound;return GF_OK; - case TAG_MPEG4_Viewpoint: + case TAG_MPEG4_Viewport: + *outName = ((M_Viewport*)n)->description.buffer; + *is_bound = ((M_Viewport*)n)->isBound; + return GF_OK; + case TAG_MPEG4_Viewpoint: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: + case TAG_X3D_Viewpoint: #endif - *outName = ((M_Viewpoint*)n)->description.buffer; *is_bound = ((M_Viewpoint*)n)->isBound; + *outName = ((M_Viewpoint*)n)->description.buffer; + *is_bound = ((M_Viewpoint*)n)->isBound; + return GF_OK; + default: + *outName = NULL; return GF_OK; - default: *outName = NULL; return GF_OK; } #else return GF_NOT_SUPPORTED; @@ -73,22 +79,23 @@ GF_Err gf_sc_set_viewpoint(GF_Compositor *compositor, u32 viewpoint_idx, const c Bindable_SetSetBind(n, !bind); return GF_OK; } - for (i=0; ivisual->view_stack, viewpoint_idx-1); switch (gf_node_get_tag(n)) { - case TAG_MPEG4_Viewport: - name = ((M_Viewport*)n)->description.buffer; + case TAG_MPEG4_Viewport: + name = ((M_Viewport*)n)->description.buffer; break; - case TAG_MPEG4_Viewpoint: - name = ((M_Viewpoint*)n)->description.buffer; + case TAG_MPEG4_Viewpoint: + name = ((M_Viewpoint*)n)->description.buffer; break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Viewpoint: - name = ((M_Viewpoint*)n)->description.buffer; + case TAG_X3D_Viewpoint: + name = ((M_Viewpoint*)n)->description.buffer; break; #endif - default: break; + default: + break; } if (name && !stricmp(name, viewpoint_name)) { Bool bind = Bindable_GetIsBound(n); @@ -142,7 +149,7 @@ static void TraverseViewport(GF_Node *node, void *rs, Bool is_destroy) ViewStack *st = (ViewStack *) gf_node_get_private(node); M_Viewport *vp = (M_Viewport *) node; GF_TraverseState *tr_state = (GF_TraverseState *)rs; - + if (is_destroy) { DestroyViewStack(node); return; @@ -172,14 +179,14 @@ static void TraverseViewport(GF_Node *node, void *rs, Bool is_destroy) if (tr_state->traversing_mode != TRAVERSE_BINDABLE) return; if (!vp->isBound) return; - if (gf_list_get(tr_state->viewpoints, 0) != vp) + if (gf_list_get(tr_state->viewpoints, 0) != vp) return; #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { w = tr_state->bbox.max_edge.x - tr_state->bbox.min_edge.x; h = tr_state->bbox.max_edge.y - tr_state->bbox.min_edge.y; - } else + } else #endif { w = tr_state->bounds.width; @@ -256,7 +263,7 @@ static void TraverseViewport(GF_Node *node, void *rs, Bool is_destroy) else if (vp->alignment.vals[1]==1) ty = h/2 - rc.height/2; } } - + gf_mx2d_init(mat); if (tr_state->pixel_metrics) { gf_mx2d_add_scale(&mat, sx, sy); @@ -279,7 +286,7 @@ static void TraverseViewport(GF_Node *node, void *rs, Bool is_destroy) if (tr_state->is_layer) { gf_mx_from_mx2d(&mx, &mat); gf_mx_add_matrix(&tr_state->model_matrix, &mx); - } + } /*otherwise add to camera viewport matrix*/ else { gf_mx_from_mx2d(&tr_state->camera->viewport, &mat); @@ -310,7 +317,7 @@ static void viewpoint_set_bind(GF_Node *node, GF_Route *route) GF_Compositor *rend = gf_sc_get_compositor(node); ViewStack *st = (ViewStack *) gf_node_get_private(node); - if (!((M_Viewpoint*)node)->isBound ) + if (!((M_Viewpoint*)node)->isBound ) st->prev_was_bound = 0; Bindable_OnSetBind(node, st->reg_stacks, NULL); gf_sc_invalidate(rend, NULL); @@ -356,7 +363,7 @@ static void TraverseViewpoint(GF_Node *node, void *rs, Bool is_destroy) /*not evaluating vp, return*/ if (tr_state->traversing_mode != TRAVERSE_BINDABLE) { /*store model matrix if changed - NOTE: we always have a 1-frame delay between VP used and real world... - we could remove this by pre-traversing the scene before applying vp, but that would mean 2 scene + we could remove this by pre-traversing the scene before applying vp, but that would mean 2 scene traversals*/ if ((tr_state->traversing_mode==TRAVERSE_SORT) || (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) ) { if (!gf_mx_equal(&st->world_view_mx, &tr_state->model_matrix)) { @@ -490,7 +497,7 @@ static void TraverseNavigationInfo(GF_Node *node, void *rs, Bool is_destroy) scale = gf_vec_len(end); tr_state->camera->speed = gf_mulfix(scale, ni->speed); - tr_state->camera->visibility = gf_mulfix(scale, ni->visibilityLimit); + tr_state->camera->visibility = gf_mulfix(scale, ni->visibilityLimit); if (ni->avatarSize.count) tr_state->camera->avatar_size.x = gf_mulfix(scale, ni->avatarSize.vals[0]); if (ni->avatarSize.count>1) tr_state->camera->avatar_size.y = gf_mulfix(scale, ni->avatarSize.vals[1]); if (ni->avatarSize.count>2) tr_state->camera->avatar_size.z = gf_mulfix(scale, ni->avatarSize.vals[2]); @@ -499,7 +506,7 @@ static void TraverseNavigationInfo(GF_Node *node, void *rs, Bool is_destroy) u32 s = MAX(tr_state->visual->width, tr_state->visual->height); s /= 2; // tr_state->camera->speed = ni->speed; - tr_state->camera->visibility *= s; + tr_state->camera->visibility *= s; tr_state->camera->avatar_size.x *= s; tr_state->camera->avatar_size.y *= s; tr_state->camera->avatar_size.z *= s; @@ -562,7 +569,7 @@ static void TraverseFog(GF_Node *node, void *rs, Bool is_destroy) } /*not evaluating, return*/ if (tr_state->traversing_mode != TRAVERSE_BINDABLE) { - if ((tr_state->traversing_mode==TRAVERSE_SORT) || (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) ) + if ((tr_state->traversing_mode==TRAVERSE_SORT) || (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) ) gf_mx_copy(st->world_view_mx, tr_state->model_matrix); return; } @@ -575,7 +582,8 @@ static void TraverseFog(GF_Node *node, void *rs, Bool is_destroy) if (vp && vp->isBound) vp_st = (ViewStack *) gf_node_get_private((GF_Node *)vp); start.x = start.y = start.z = 0; - end.x = end.y = 0; end.z = fog->visibilityRange; + end.x = end.y = 0; + end.z = fog->visibilityRange; if (vp_st) { gf_mx_apply_vec(&vp_st->world_view_mx, &start); gf_mx_apply_vec(&vp_st->world_view_mx, &end); diff --git a/src/compositor/navigate.c b/src/compositor/navigate.c index 6986025..db8769e 100644 --- a/src/compositor/navigate.c +++ b/src/compositor/navigate.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,9 +39,9 @@ static void camera_changed(GF_Compositor *compositor, GF_Camera *cam) #endif -static void nav_set_zoom_trans_2d(GF_VisualManager *visual, Fixed zoom, Fixed dx, Fixed dy) +static void nav_set_zoom_trans_2d(GF_VisualManager *visual, Fixed zoom, Fixed dx, Fixed dy) { - compositor_2d_set_user_transform(visual->compositor, zoom, visual->compositor->trans_x + dx, visual->compositor->trans_y + dy, 0); + compositor_2d_set_user_transform(visual->compositor, zoom, visual->compositor->trans_x + dx, visual->compositor->trans_y + dy, 0); #ifndef GPAC_DISABLE_3D if (visual->type_3d) camera_changed(visual->compositor, &visual->camera); #endif @@ -58,7 +58,7 @@ static void gf_mx_rotation_matrix(GF_Matrix *mx, SFVec3f axis_pt, SFVec3f axis, gf_mx_add_rotation(mx, angle, axis.x, axis.y, axis.z); gf_mx_add_translation(mx, -axis_pt.x, -axis_pt.y, -axis_pt.z); } - + static void view_orbit_x(GF_Compositor *compositor, GF_Camera *cam, Fixed dx) { GF_Matrix mx; @@ -182,7 +182,8 @@ static void view_zoom(GF_Compositor *compositor, GF_Camera *cam, Fixed z) Fixed oz; if ((z>FIX_ONE) || (z<-FIX_ONE)) return; oz = gf_divfix(cam->vp_fov, cam->fieldOfView); - if (ozfieldOfView = gf_divfix(cam->vp_fov, oz); @@ -242,7 +243,7 @@ Bool gf_sc_fit_world_to_screen(GF_Compositor *compositor) return 1; } } - + diff = gf_vec_scale(camera_get_pos_dir(cam), dist); gf_vec_add(pos, tr_state.bbox.center, diff); diff = cam->position; @@ -276,9 +277,9 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event if (compositor->active_layer) { cam = compositor_layer3d_get_camera(compositor->active_layer); #ifdef SCALE_NAV - is_pixel_metrics = gf_sg_use_pixel_metrics(gf_node_get_graph(compositor->active_layer)); + is_pixel_metrics = gf_sg_use_pixel_metrics(gf_node_get_graph(compositor->active_layer)); #endif - } + } #endif if (!cam) { @@ -299,7 +300,7 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event y = gf_divfix( INT2FIX(ev->mouse.y - (s32) compositor->visual->height/2), INT2FIX(compositor->visual->height)); } - dx = (x - compositor->grab_x); + dx = (x - compositor->grab_x); dy = (compositor->grab_y - y); #ifdef SCALE_NAV @@ -343,7 +344,7 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event camera_changed(compositor, cam); return 1; } - } + } /*right*/ else if (ev->mouse.button==GF_MOUSE_RIGHT) { if (compositor->navigation_state && (cam->navigate_mode==GF_NAVIGATE_WALK)) { @@ -476,7 +477,8 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event return 1; } break; - case GF_KEY_LEFT: key_inv = -1; + case GF_KEY_LEFT: + key_inv = -1; case GF_KEY_RIGHT: if (keys & GF_KEY_MOD_ALT) { if ( (keys & GF_KEY_MOD_SHIFT) && (compositor->visual->nb_views > 1) ) { @@ -488,7 +490,7 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event return 1; } return 0; - } + } switch (cam->navigate_mode) { @@ -504,8 +506,12 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event if (keys & GF_KEY_MOD_CTRL) view_translate_x(compositor, cam, key_inv * key_trans); else view_orbit_x(compositor, cam, -key_inv * key_exam); break; - case GF_NAVIGATE_GAME: view_translate_x(compositor, cam, key_inv * key_trans); break; - case GF_NAVIGATE_VR: view_pan_x(compositor, cam, -key_inv * key_pan); break; + case GF_NAVIGATE_GAME: + view_translate_x(compositor, cam, key_inv * key_trans); + break; + case GF_NAVIGATE_VR: + view_pan_x(compositor, cam, -key_inv * key_pan); + break; /*walk/fly/pan*/ default: if (keys & GF_KEY_MOD_CTRL) view_translate_x(compositor, cam, key_inv * key_trans); @@ -513,7 +519,8 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event break; } return 1; - case GF_KEY_DOWN: key_inv = -1; + case GF_KEY_DOWN: + key_inv = -1; case GF_KEY_UP: if (keys & GF_KEY_MOD_ALT) { if ( (keys & GF_KEY_MOD_SHIFT) && (compositor->visual->nb_views > 1) ) { @@ -524,7 +531,7 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event return 1; } return 0; - } + } switch (cam->navigate_mode) { case GF_NAVIGATE_SLIDE: if (keys & GF_KEY_MOD_CTRL) view_translate_z(compositor, cam, key_inv * key_trans); @@ -542,7 +549,9 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event if (keys & GF_KEY_MOD_CTRL) view_translate_y(compositor, cam, key_inv * key_trans); else view_pan_y(compositor, cam, key_inv * key_pan); break; - case GF_NAVIGATE_GAME: view_translate_z(compositor, cam, key_inv * key_trans); break; + case GF_NAVIGATE_GAME: + view_translate_z(compositor, cam, key_inv * key_trans); + break; case GF_NAVIGATE_VR: if (keys & GF_KEY_MOD_CTRL) view_zoom(compositor, cam, key_inv * key_pan); else view_pan_y(compositor, cam, key_inv * key_pan); @@ -556,10 +565,16 @@ static Bool compositor_handle_navigation_3d(GF_Compositor *compositor, GF_Event return 1; case GF_KEY_PAGEDOWN: - if (keys & GF_KEY_MOD_CTRL) { view_zoom(compositor, cam, FIX_ONE/10); return 1; } + if (keys & GF_KEY_MOD_CTRL) { + view_zoom(compositor, cam, FIX_ONE/10); + return 1; + } break; case GF_KEY_PAGEUP: - if (keys & GF_KEY_MOD_CTRL) { view_zoom(compositor, cam, -FIX_ONE/10); return 1; } + if (keys & GF_KEY_MOD_CTRL) { + view_zoom(compositor, cam, -FIX_ONE/10); + return 1; + } break; } break; @@ -599,7 +614,10 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * } else { dy = y - visual->compositor->grab_y; } - if (!is_pixel_metrics) { dx /= visual->width; dy /= visual->height; } + if (!is_pixel_metrics) { + dx /= visual->width; + dy /= visual->height; + } key_inv = 1; key_trans = INT2FIX(2); @@ -612,7 +630,9 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * key_trans*=4; } - if (!is_pixel_metrics) { key_trans /= visual->width;} + if (!is_pixel_metrics) { + key_trans /= visual->width; + } switch (ev->type) { case GF_EVENT_MOUSEDOWN: @@ -645,7 +665,7 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * nav_set_zoom_trans_2d(visual, new_zoom, 0, 0); return 1; case GF_NAVIGATE_EXAMINE: - if (ev->mouse.wheel_pos>0) + if (ev->mouse.wheel_pos>0) visual->compositor->rotation += gf_asin( GF_PI / 10); else visual->compositor->rotation -= gf_asin( GF_PI / 10); @@ -681,7 +701,7 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * visual->compositor->rotation += gf_asin(sin); nav_set_zoom_trans_2d(visual, zoom, 0, 0); } - break; + break; } visual->compositor->grab_x = x; visual->compositor->grab_y = y; @@ -699,7 +719,8 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * nav_set_zoom_trans_2d(visual, FIX_ONE, 0, 0); } return 1; - case GF_KEY_LEFT: key_inv = -1; + case GF_KEY_LEFT: + key_inv = -1; case GF_KEY_RIGHT: if (navigation_mode == GF_NAVIGATE_SLIDE) { nav_set_zoom_trans_2d(visual, zoom, key_inv*key_trans, 0); @@ -709,7 +730,8 @@ static Bool compositor_handle_navigation_2d(GF_VisualManager *visual, GF_Event * nav_set_zoom_trans_2d(visual, zoom, 0, 0); } return 1; - case GF_KEY_DOWN: key_inv = -1; + case GF_KEY_DOWN: + key_inv = -1; case GF_KEY_UP: if (navigation_mode == GF_NAVIGATE_SLIDE) { if (keys & GF_KEY_MOD_CTRL) { @@ -736,7 +758,7 @@ Bool compositor_handle_navigation(GF_Compositor *compositor, GF_Event *ev) { if (!compositor->scene) return 0; #ifndef GPAC_DISABLE_3D - if ( (compositor->visual->type_3d>0) || compositor->active_layer) + if ( (compositor->visual->type_3d>0) || compositor->active_layer) return compositor_handle_navigation_3d(compositor, ev); #endif return compositor_handle_navigation_2d(compositor->visual, ev); diff --git a/src/compositor/nodes_stacks.h b/src/compositor/nodes_stacks.h index 94934a4..a50f11b 100644 --- a/src/compositor/nodes_stacks.h +++ b/src/compositor/nodes_stacks.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -79,7 +79,7 @@ void BindableStackDelete(GF_List *stack); /*for user-modif of viewport/viewpoint*/ void Bindable_SetSetBind(GF_Node *bindable, Bool val); -/*special user-modif of viewport/viewpoint: +/*special user-modif of viewport/viewpoint: if stack is not NULL, binding is only performed in this stack otherwise, binding is performed on all stack*/ void Bindable_SetSetBindEx(GF_Node *bindable, Bool val, GF_List *stack); @@ -108,6 +108,7 @@ typedef struct #ifndef GPAC_DISABLE_3D GF_Mesh *mesh; GF_BBox prev_bounds; + Bool hybgl_init; #endif u32 flags; } Background2DStack; @@ -124,6 +125,7 @@ typedef struct GF_Mesh *front_mesh, *back_mesh, *top_mesh, *bottom_mesh, *left_mesh, *right_mesh; GF_TextureHandler txh_front, txh_back, txh_top, txh_bottom, txh_left, txh_right; + GF_Matrix current_mx; } BackgroundStack; #endif diff --git a/src/compositor/offscreen_cache.c b/src/compositor/offscreen_cache.c index e8d5797..6588f2b 100644 --- a/src/compositor/offscreen_cache.c +++ b/src/compositor/offscreen_cache.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,12 +36,25 @@ //#define CACHE_DEBUG_ALPHA //#define CACHE_DEBUG_CENTER -void group_cache_draw(GroupCache *cache, GF_TraverseState *tr_state) +void group_cache_draw(GroupCache *cache, GF_TraverseState *tr_state) { GF_TextureHandler *old_txh = tr_state->ctx->aspect.fill_texture; /*switch the texture to our offscreen cache*/ tr_state->ctx->aspect.fill_texture = &cache->txh; + +#ifndef GPAC_DISABLE_3D + if (tr_state->traversing_mode == TRAVERSE_DRAW_3D) { + if (!cache->drawable->mesh) { + cache->drawable->mesh = new_mesh(); + } + mesh_from_path(cache->drawable->mesh, cache->drawable->path); + + visual_3d_draw_2d(cache->drawable, tr_state); + return; + } +#endif + if (! tr_state->visual->DrawBitmap(tr_state->visual, tr_state, tr_state->ctx, NULL)) { visual_2d_texture_path(tr_state->visual, cache->drawable->path, tr_state->ctx, tr_state); } @@ -82,7 +95,7 @@ void group_cache_setup(GroupCache *cache, GF_Rect *path_bounds, GF_IRect *pix_bo cache->txh.pixelformat = for_gl ? GF_PIXEL_RGBA : GF_PIXEL_ARGB; cache->txh.transparent = 1; - if (cache->txh.data) + if (cache->txh.data) gf_free(cache->txh.data); #ifdef CACHE_DEBUG_ALPHA cache->txh.stride = pix_bounds->width * 3; @@ -98,16 +111,16 @@ void group_cache_setup(GroupCache *cache, GF_Rect *path_bounds, GF_IRect *pix_bo /*set a rectangle to the path Attention, we want to center the cached bitmap at the center of the screen (main visual), so we use the local coordinate to parameterize the path*/ - gf_path_add_rect_center(cache->drawable->path, - path_bounds->x + path_bounds->width/2, - path_bounds->y - path_bounds->height/2, - path_bounds->width, path_bounds->height); + gf_path_add_rect_center(cache->drawable->path, + path_bounds->x + path_bounds->width/2, + path_bounds->y - path_bounds->height/2, + path_bounds->width, path_bounds->height); } Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr_state, Bool force_recompute, Bool is_mpeg4, Bool auto_fit_vp) { GF_Matrix2D backup; - DrawableContext *group_ctx = NULL; + DrawableContext *group_ctx = NULL; GF_ChildNodeItem *l; if (!cache) return 0; @@ -148,7 +161,7 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr tr_state->visual->type_3d = 0; #endif - /*step 2: collect the bounds of all children*/ + /*step 2: collect the bounds of all children*/ tr_state->traversing_mode = TRAVERSE_GET_BOUNDS; cache_bounds.width = cache_bounds.height = 0; l = ((GF_ParentNode*)node)->children; @@ -220,12 +233,12 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr /*attach the buffer to visual*/ r2d->surface_attach_to_buffer(offscreen_surface, cache->txh.data, - cache->txh.width, - cache->txh.height, - 0, - cache->txh.stride, - cache->txh.pixelformat); - + cache->txh.width, + cache->txh.height, + 0, + cache->txh.stride, + cache->txh.pixelformat); + /*recompute the bounds with the final scaling used*/ scale_x = gf_divfix(INT2FIX(rc1.width), tr_state->bounds.width); @@ -244,8 +257,8 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr } else { temp_y += cache_bounds.height; } - gf_mx2d_add_translation(&tr_state->transform, temp_x, temp_y); - + gf_mx2d_add_translation(&tr_state->transform, temp_x, temp_y); + /*override top clippers*/ rc1 = tr_state->visual->surf_rect; rc2 = tr_state->visual->top_clipper; @@ -274,9 +287,9 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr child_ctx = group_ctx->next; while (child_ctx && child_ctx->drawable) { drawable_reset_bounds(child_ctx->drawable, tr_state->visual); - child_ctx->drawable = NULL; + child_ctx->drawable = NULL; child_ctx = child_ctx->next; - } + } /*and set ourselves as the last context on the main visual*/ tr_state->visual->cur_context = group_ctx; @@ -294,7 +307,7 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr #endif tr_state->visual->surf_rect = rc1; tr_state->visual->top_clipper = rc2; - + /*update texture*/ cache->txh.transparent = 1; cache->txh.flags |= GF_SR_TEXTURE_NO_GL_FLIP; @@ -317,7 +330,7 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr } if (!group_ctx) return 0; group_ctx->flags |= CTX_NO_ANTIALIAS; - if (cache->opacity != FIX_ONE) + if (cache->opacity != FIX_ONE) group_ctx->aspect.fill_color = GF_COL_ARGB_FIXED(cache->opacity, FIX_ONE, FIX_ONE, FIX_ONE); else group_ctx->aspect.fill_color = 0; @@ -356,10 +369,10 @@ Bool group_cache_traverse(GF_Node *node, GroupCache *cache, GF_TraverseState *tr } visual_3d_draw_from_context(group_ctx, tr_state); group_ctx->drawable = NULL; - } else + } else #endif drawable_finalize_sort(group_ctx, tr_state, NULL); - + #ifndef CACHE_DEBUG_CENTER if (auto_fit_vp) #endif @@ -395,18 +408,18 @@ static void group_cache_insert_entry(GF_Node *node, GroupingNode2D *group, GF_Tr tr_state->visual->compositor->video_cache_current_size += group->cached_size; /*log the information*/ GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE]\tAdding object %s\tObjects: %d\tSlope: %g\tSize: %d\tTime: %d\n", - gf_node_get_log_name(node), - group->nb_objects, - FIX2FLT(group->priority), - group->cached_size, - group->traverse_time)); + gf_node_get_log_name(node), + group->nb_objects, + FIX2FLT(group->priority), + group->cached_size, + group->traverse_time)); GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (KB): Max: %d\tUsed: %d\tNb Groups: %d\n", - tr_state->visual->compositor->video_cache_max_size, - tr_state->visual->compositor->video_cache_current_size, - gf_list_count(tr_state->visual->compositor->cached_groups) - )); -} + tr_state->visual->compositor->video_cache_max_size, + tr_state->visual->compositor->video_cache_current_size, + gf_list_count(tr_state->visual->compositor->cached_groups) + )); +} static Bool gf_cache_remove_entry(GF_Compositor *compositor, GF_Node *node, GroupingNode2D *group) @@ -433,7 +446,7 @@ static Bool gf_cache_remove_entry(GF_Compositor *compositor, GF_Node *node, Grou /*the discarded bytes*/ bytes_remove = group->cached_size; } - + /*indicates cache destruction for next frame*/ if (group->cache && (group->flags & GROUP_IS_CACHED)) { group->flags &= ~GROUP_IS_CACHED; @@ -447,17 +460,17 @@ static Bool gf_cache_remove_entry(GF_Compositor *compositor, GF_Node *node, Grou compositor->video_cache_current_size -= bytes_remove; GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Removing cache %s:\t Objects: %d\tSlope: %g\tBytes: %d\tTime: %d\n", - gf_node_get_log_name(node), - group->nb_objects, - FIX2FLT(group->priority), - group->cached_size, - FIX2FLT(group->traverse_time))); - + gf_node_get_log_name(node), + group->nb_objects, + FIX2FLT(group->priority), + group->cached_size, + FIX2FLT(group->traverse_time))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (B): Max: %d\tUsed: %d\tNb Groups: %d\n", - compositor->video_cache_max_size, - compositor->video_cache_current_size, - gf_list_count(compositor->cached_groups) - )); + compositor->video_cache_max_size, + compositor->video_cache_current_size, + gf_list_count(compositor->cached_groups) + )); return 1; } @@ -508,7 +521,7 @@ Bool group_2d_cache_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseSt if (!cache_on) { if (is_dirty) { group->changed = 1; - } + } /*ask for stats again*/ else if (group->changed) { group->changed = 0; @@ -524,7 +537,7 @@ Bool group_2d_cache_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseSt tr_state->visual->compositor->traverse_state->invalidate_all = 1; /*force redraw*/ tr_state->visual->compositor->draw_next_frame = 1; - } + } return 0; } } @@ -559,9 +572,9 @@ Bool group_2d_cache_traverse(GF_Node *node, GroupingNode2D *group, GF_TraverseSt else if (group->cache) { Fixed scale = MAX(tr_state->transform.m[0], tr_state->transform.m[4]); - if (100*scale >= group->cache->scale*(100 + tr_state->visual->compositor->cache_tolerance)) + if (100*scale >= group->cache->scale*(100 + tr_state->visual->compositor->cache_tolerance)) zoom_changed = 1; - else if ((100+tr_state->visual->compositor->cache_tolerance)*scale <= 100*group->cache->scale) + else if ((100+tr_state->visual->compositor->cache_tolerance)*scale <= 100*group->cache->scale) zoom_changed = 1; else zoom_changed = 0; @@ -628,7 +641,7 @@ Bool group_cache_compute_stats(GF_Node *node, GroupingNode2D *group, GF_Traverse while (ctx && ctx->drawable) { //Fixed area; u32 alpha_comp; - + /*get area and compute alpha/opaque coverage*/ alpha_comp = GF_COL_A(ctx->aspect.fill_color); @@ -637,12 +650,12 @@ Bool group_cache_compute_stats(GF_Node *node, GroupingNode2D *group, GF_Traverse nb_objects++; /*no alpha*/ - if ((alpha_comp==0xFF) - /*no transparent texture*/ - && (!ctx->aspect.fill_texture || !ctx->aspect.fill_texture->transparent) - ) { + if ((alpha_comp==0xFF) + /*no transparent texture*/ + && (!ctx->aspect.fill_texture || !ctx->aspect.fill_texture->transparent) + ) { - ra_union_rect(&ra, &ctx->bi->clip); + ra_union_rect(&ra, &ctx->bi->clip); } nb_segments += ctx->drawable->path->n_points; @@ -650,31 +663,31 @@ Bool group_cache_compute_stats(GF_Node *node, GroupingNode2D *group, GF_Traverse } if ( - /*TEST 1: discard visually empty groups*/ - (!group_bounds.width || !group_bounds.height) - || - /*TEST 2: discard small groups*/ - (nb_objectspriority = INT2FIX(nb_objects*1024*group->traverse_time) / cache_size / group->nb_stats_frame; + group->priority = INT2FIX(nb_objects*1024*group->traverse_time) / cache_size / group->nb_stats_frame; /*OK, group is a good candidate for caching*/ group->nb_objects = nb_objects; group->cached_size = cache_size; @@ -726,7 +739,7 @@ Bool group_cache_compute_stats(GF_Node *node, GroupingNode2D *group, GF_Traverse group_reject: group->nb_objects = nb_objects; - + if ((group->flags & GROUP_IS_CACHABLE) || group->cache) { group->flags &= ~GROUP_IS_CACHABLE; @@ -738,21 +751,21 @@ group_reject: gf_list_del_item(tr_state->visual->compositor->cached_groups, group); tr_state->visual->compositor->video_cache_current_size -= cache_size; } - + #if 0 GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] REJECT %s\tObjects: %d\tSlope: %g\tBytes: %d\tTime: %d\n", - gf_node_get_log_name(node), - group->nb_objects, - FIX2FLT(group->priority), - group->cached_size, - group->traverse_time - )); + gf_node_get_log_name(node), + group->nb_objects, + FIX2FLT(group->priority), + group->cached_size, + group->traverse_time + )); GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (B): Max: %d\tUsed: %d\tNb Groups: %d\n", - tr_state->visual->compositor->video_cache_max_size, - tr_state->visual->compositor->video_cache_current_size, - gf_list_count(tr_state->visual->compositor->cached_groups) - )); + tr_state->visual->compositor->video_cache_max_size, + tr_state->visual->compositor->video_cache_current_size, + gf_list_count(tr_state->visual->compositor->cached_groups) + )); #endif return 0; } @@ -764,7 +777,7 @@ void group_2d_cache_evaluate(GF_Node *node, GroupingNode2D *group, GF_TraverseSt Fixed priority; GF_Compositor *compositor = tr_state->visual->compositor; - /*first frame is unusable for stats because lot of time is being spent building the path and allocating + /*first frame is unusable for stats because lot of time is being spent building the path and allocating the drawable contexts*/ if (!compositor->video_cache_max_size || !compositor->frame_number || group->changed || tr_state->in_group_cache) { group->traverse_time = 0; @@ -773,7 +786,7 @@ void group_2d_cache_evaluate(GF_Node *node, GroupingNode2D *group, GF_TraverseSt if (group->nb_stats_frame < NUM_STATS_FRAMES) { group->nb_stats_frame++; - tr_state->visual->compositor->draw_next_frame = 1; + tr_state->visual->compositor->draw_next_frame = 1; return; } if (group->nb_stats_frame > NUM_STATS_FRAMES) return; @@ -807,7 +820,7 @@ void group_2d_cache_evaluate(GF_Node *node, GroupingNode2D *group, GF_TraverseSt gf_list_rem(compositor->cached_groups_queue, last_cache_idx); } priority = INT2FIX (group->nb_objects*1024*1024*avg_time) / group->cached_size; - + /*when the memory exceeds the constraint, remove the subgroups that have the lowest deltas*/ while (compositor->video_cache_current_size > compositor->video_cache_max_size) { gf_cache_remove_entry(compositor, node, NULL); diff --git a/src/compositor/offscreen_cache.h b/src/compositor/offscreen_cache.h index 85cbc40..1191687 100644 --- a/src/compositor/offscreen_cache.h +++ b/src/compositor/offscreen_cache.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -41,6 +41,7 @@ typedef struct _group_cache /*user scale (zoom and AR) of the group*/ Fixed scale; SFVec2f orig_vp; + } GroupCache; GroupCache *group_cache_new(GF_Compositor *compositor, GF_Node *node); diff --git a/src/compositor/svg_base.c b/src/compositor/svg_base.c index 1517836..a68af7e 100644 --- a/src/compositor/svg_base.c +++ b/src/compositor/svg_base.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,53 +50,38 @@ void compositor_svg_apply_local_transformation(GF_TraverseState *tr_state, SVGAl { #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d && backup_matrix) { - GF_Matrix tmp; Bool is_draw = (tr_state->traversing_mode==TRAVERSE_SORT) ? 1 : 0; gf_mx_copy(*backup_matrix, tr_state->model_matrix); - if (is_draw) visual_3d_matrix_push(tr_state->visual); - if (atts->transform && atts->transform->is_ref) { gf_mx_from_mx2d(&tr_state->model_matrix, &tr_state->vb_transform); if (is_draw) { - GF_Matrix tmp; - gf_mx_init(tmp); - gf_mx_add_translation(&tmp, -tr_state->camera->width/2, tr_state->camera->height/2, 0); - gf_mx_add_scale(&tmp, FIX_ONE, -FIX_ONE, FIX_ONE); - gf_mx_add_matrix(&tmp, &tr_state->model_matrix); - visual_3d_matrix_load(tr_state->visual, tmp.m); + gf_mx_init(tr_state->model_matrix); + gf_mx_add_translation(&tr_state->model_matrix, -tr_state->camera->width/2, tr_state->camera->height/2, 0); + gf_mx_add_scale(&tr_state->model_matrix, FIX_ONE, -FIX_ONE, FIX_ONE); + gf_mx_add_matrix_2d(&tr_state->model_matrix, &tr_state->vb_transform); } } if (atts->motionTransform) { - if (is_draw) { - gf_mx_from_mx2d(&tmp, atts->motionTransform); - visual_3d_matrix_add(tr_state->visual, tmp.m); - } else { - gf_mx_add_matrix_2d(&tr_state->model_matrix, atts->motionTransform); - } + gf_mx_add_matrix_2d(&tr_state->model_matrix, atts->motionTransform); } if (atts->transform) { - if (is_draw) { - gf_mx_from_mx2d(&tmp, &atts->transform->mat); - visual_3d_matrix_add(tr_state->visual, tmp.m); - } else { - gf_mx_add_matrix_2d(&tr_state->model_matrix, &atts->transform->mat); - } + gf_mx_add_matrix_2d(&tr_state->model_matrix, &atts->transform->mat); } return; - } + } #endif gf_mx2d_copy(*backup_matrix_2d, tr_state->transform); - if (atts->transform && atts->transform->is_ref) + if (atts->transform && atts->transform->is_ref) gf_mx2d_copy(tr_state->transform, tr_state->vb_transform); - if (atts->motionTransform) + if (atts->motionTransform) gf_mx2d_pre_multiply(&tr_state->transform, atts->motionTransform); - if (atts->transform) + if (atts->transform) gf_mx2d_pre_multiply(&tr_state->transform, &atts->transform->mat); } @@ -105,17 +90,15 @@ void compositor_svg_restore_parent_transformation(GF_TraverseState *tr_state, GF { #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d && backup_matrix) { - if (tr_state->traversing_mode==TRAVERSE_SORT) - visual_3d_matrix_pop(tr_state->visual); - gf_mx_copy(tr_state->model_matrix, *backup_matrix); + gf_mx_copy(tr_state->model_matrix, *backup_matrix); return; - } + } #endif - gf_mx2d_copy(tr_state->transform, *backup_matrix_2d); + gf_mx2d_copy(tr_state->transform, *backup_matrix_2d); } #ifdef GPAC_UNUSED_FUNC -static void gf_svg_apply_inheritance_no_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers *render_svg_props) +static void gf_svg_apply_inheritance_no_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers *render_svg_props) { #define CHECK_PROP(a, b) if (b) a = b; @@ -124,7 +107,7 @@ static void gf_svg_apply_inheritance_no_inheritance(SVGAllAttributes *all_atts, CHECK_PROP(render_svg_props->fill, all_atts->fill); CHECK_PROP(render_svg_props->fill_opacity, all_atts->fill_opacity); CHECK_PROP(render_svg_props->fill_rule, all_atts->fill_rule); - CHECK_PROP(render_svg_props->solid_color, all_atts->solid_color); + CHECK_PROP(render_svg_props->solid_color, all_atts->solid_color); CHECK_PROP(render_svg_props->solid_opacity, all_atts->solid_opacity); CHECK_PROP(render_svg_props->stop_color, all_atts->stop_color); CHECK_PROP(render_svg_props->stop_opacity, all_atts->stop_opacity); @@ -140,7 +123,10 @@ static void gf_svg_apply_inheritance_no_inheritance(SVGAllAttributes *all_atts, } #endif /*GPAC_UNUSED_FUNC*/ -static const struct svg_11_feature { const char *name; Bool supported; } svg11_features[] = +static const struct svg_11_feature { + const char *name; + Bool supported; +} svg11_features[] = { { "Animation", 1}, { "AnimationEventsAttribute", 1}, @@ -193,46 +179,49 @@ static const struct svg_11_feature { const char *name; Bool supported; } svg11_f { "SVGDOM-dynamic", 0}, { "SVGDOM-static", 0}, }; -static const struct svg_12_feature { const char *name; Bool supported; } svg12_features[] = +static const struct svg_12_feature { + const char *name; + Bool supported; +} svg12_features[] = { - { "CoreAttribute", 1}, - { "NavigationAttribute", 1}, - { "Structure", 1}, - { "ConditionalProcessing", 1}, - { "ConditionalProcessingAttribute", 1}, - { "Image", 1}, - { "Prefetch", 1}, - { "Discard", 1}, - { "Shape", 1}, - { "Text", 1}, - { "PaintAttribute", 1}, - { "OpacityAttribute", 1}, - { "GraphicsAttribute", 1}, - { "Gradient", 1}, - { "SolidColor", 1}, - { "Hyperlinking", 1}, - { "XlinkAttribute", 1}, - { "ExternalResourcesRequired", 1}, - { "Scripting", 1}, - { "Handler", 1}, - { "Listener", 1}, - { "TimedAnimation", 1}, - { "Animation", 1}, - { "Audio", 1}, - { "Video", 1}, - { "Font", 1}, - { "Extensibility", 1}, - { "MediaAttribute", 1}, - { "TextFlow", 1}, - { "TransformedVideo", 1}, - { "ComposedVideo", 1}, - { "EditableTextAttribute", 1}, - - { "SVG-static", 1}, - { "SVG-static-DOM", 1}, - { "SVG-animated", 1}, - { "SVG-all", 1}, - { "SVG-interactive", 1}, + { "CoreAttribute", 1}, + { "NavigationAttribute", 1}, + { "Structure", 1}, + { "ConditionalProcessing", 1}, + { "ConditionalProcessingAttribute", 1}, + { "Image", 1}, + { "Prefetch", 1}, + { "Discard", 1}, + { "Shape", 1}, + { "Text", 1}, + { "PaintAttribute", 1}, + { "OpacityAttribute", 1}, + { "GraphicsAttribute", 1}, + { "Gradient", 1}, + { "SolidColor", 1}, + { "Hyperlinking", 1}, + { "XlinkAttribute", 1}, + { "ExternalResourcesRequired", 1}, + { "Scripting", 1}, + { "Handler", 1}, + { "Listener", 1}, + { "TimedAnimation", 1}, + { "Animation", 1}, + { "Audio", 1}, + { "Video", 1}, + { "Font", 1}, + { "Extensibility", 1}, + { "MediaAttribute", 1}, + { "TextFlow", 1}, + { "TransformedVideo", 1}, + { "ComposedVideo", 1}, + { "EditableTextAttribute", 1}, + + { "SVG-static", 1}, + { "SVG-static-DOM", 1}, + { "SVG-animated", 1}, + { "SVG-all", 1}, + { "SVG-interactive", 1}, }; @@ -244,7 +233,7 @@ Bool compositor_svg_evaluate_conditional(GF_Compositor *compositor, SVGAllAttrib /*process required features*/ count = atts->requiredFeatures ? gf_list_count(*atts->requiredFeatures) : 0; - for (i=0;irequiredFeatures, i); if (!iri->string) continue; @@ -314,14 +303,20 @@ Bool compositor_svg_evaluate_conditional(GF_Compositor *compositor, SVGAllAttrib found = 1; } - for (i=0;isystemLanguage, i); /*3 char-code*/ if (strlen(lang)==3) { - if (!stricmp(lang, lang_3cc)) { found = 1; break; } + if (!stricmp(lang, lang_3cc)) { + found = 1; + break; + } } /*2 char-code, only check first 2 chars - TODO FIXME*/ - else if (!strnicmp(lang, lang_2cc, 2)) { found = 1; break; } + else if (!strnicmp(lang, lang_2cc, 2)) { + found = 1; + break; + } } if (!found) return 0; @@ -348,18 +343,18 @@ Bool compositor_svg_evaluate_conditional(GF_Compositor *compositor, SVGAllAttrib return 0; } } - + /*OK, we can render this one*/ return 1; } -Bool compositor_svg_traverse_base(GF_Node *node, SVGAllAttributes *atts, GF_TraverseState *tr_state, - SVGPropertiesPointers *backup_props, u32 *backup_flags) +Bool compositor_svg_traverse_base(GF_Node *node, SVGAllAttributes *atts, GF_TraverseState *tr_state, + SVGPropertiesPointers *backup_props, u32 *backup_flags) { u32 inherited_flags_mask, flags; - if (atts->requiredFeatures || atts->requiredExtensions || atts->systemLanguage - || atts->requiredFonts || atts->requiredFormats) { + if (atts->requiredFeatures || atts->requiredExtensions || atts->systemLanguage + || atts->requiredFonts || atts->requiredFormats) { if (!compositor_svg_evaluate_conditional(tr_state->visual->compositor, atts)) return 0; } @@ -369,11 +364,11 @@ Bool compositor_svg_traverse_base(GF_Node *node, SVGAllAttributes *atts, GF_Trav #if 0 // applying inheritance and determining which group of properties are being inherited - inherited_flags_mask = gf_svg_apply_inheritance(atts, tr_state->svg_props); + inherited_flags_mask = gf_svg_apply_inheritance(atts, tr_state->svg_props); gf_svg_apply_animations(node, tr_state->svg_props); // including again inheritance if values are 'inherit' #else /* animation (including possibly inheritance) then full inheritance */ - gf_svg_apply_animations(node, tr_state->svg_props); + gf_svg_apply_animations(node, tr_state->svg_props); inherited_flags_mask = gf_svg_apply_inheritance(atts, tr_state->svg_props); // gf_svg_apply_inheritance_no_inheritance(atts, tr_state->svg_props); // inherited_flags_mask = 0xFFFFFFFF; diff --git a/src/compositor/svg_filters.c b/src/compositor/svg_filters.c index 53cae89..2efce58 100644 --- a/src/compositor/svg_filters.c +++ b/src/compositor/svg_filters.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,16 +54,30 @@ void apply_feComponentTransfer(GF_Node *node, GF_TextureHandler *source, GF_Rect char *ptr = NULL; /*FIXME: unused u32 tag = gf_node_get_tag(l->node);*/ GF_DOMAttribute *att = ((SVG_Element *)l->node)->attributes; - + while (att) { switch (att->tag) { - case TAG_SVG_ATT_filter_transfer_type: type = *(u8*)att->data; break; - case TAG_SVG_ATT_filter_table_values: table = *(GF_List **)att->data; break; - case TAG_SVG_ATT_slope: slope = ((SVG_Number *)att->data)->value; break; - case TAG_SVG_ATT_filter_intercept: intercept = ((SVG_Number *)att->data)->value; break; - case TAG_SVG_ATT_filter_amplitude: amplitude = ((SVG_Number *)att->data)->value; break; - case TAG_SVG_ATT_filter_exponent: exponent = ((SVG_Number *)att->data)->value; break; - case TAG_SVG_ATT_offset: offset = ((SVG_Number *)att->data)->value; break; + case TAG_SVG_ATT_filter_transfer_type: + type = *(u8*)att->data; + break; + case TAG_SVG_ATT_filter_table_values: + table = *(GF_List **)att->data; + break; + case TAG_SVG_ATT_slope: + slope = ((SVG_Number *)att->data)->value; + break; + case TAG_SVG_ATT_filter_intercept: + intercept = ((SVG_Number *)att->data)->value; + break; + case TAG_SVG_ATT_filter_amplitude: + amplitude = ((SVG_Number *)att->data)->value; + break; + case TAG_SVG_ATT_filter_exponent: + exponent = ((SVG_Number *)att->data)->value; + break; + case TAG_SVG_ATT_offset: + offset = ((SVG_Number *)att->data)->value; + break; } att = att->next; } @@ -238,15 +252,15 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) Warning, we want to center the cached bitmap at the center of the screen (main visual)*/ gf_path_reset(st->drawable->path); - gf_path_add_rect_center(st->drawable->path, - bounds.x + bounds.width/2, - bounds.y - bounds.height/2, - bounds.width, - bounds.height); + gf_path_add_rect_center(st->drawable->path, + bounds.x + bounds.width/2, + bounds.y - bounds.height/2, + bounds.width, + bounds.height); old_surf = tr_state->visual->raster_surface; - offscreen_surface = tr_state->visual->compositor->rasterizer->surface_new(tr_state->visual->compositor->rasterizer, tr_state->visual->center_coords); + offscreen_surface = tr_state->visual->compositor->rasterizer->surface_new(tr_state->visual->compositor->rasterizer, tr_state->visual->center_coords); tr_state->visual->raster_surface = offscreen_surface; gf_mx2d_copy(backup, tr_state->transform); @@ -254,11 +268,11 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) /*attach the buffer to visual*/ tr_state->visual->compositor->rasterizer->surface_attach_to_buffer(offscreen_surface, st->txh.data, - st->txh.width, - st->txh.height, - 0, - st->txh.stride, - st->txh.pixelformat); + st->txh.width, + st->txh.height, + 0, + st->txh.stride, + st->txh.pixelformat); prev_flags = tr_state->immediate_draw; tr_state->immediate_draw = 1; @@ -282,7 +296,7 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) temp_x = -rc.x; temp_y = rc.height - rc.y; } - gf_mx2d_add_translation(&tr_state->transform, temp_x, temp_y); + gf_mx2d_add_translation(&tr_state->transform, temp_x, temp_y); rc1 = tr_state->visual->surf_rect; @@ -310,9 +324,9 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) child_ctx = ctx->next; while (child_ctx && child_ctx->drawable) { drawable_reset_bounds(child_ctx->drawable, tr_state->visual); - child_ctx->drawable = NULL; + child_ctx->drawable = NULL; child_ctx = child_ctx->next; - } + } tr_state->visual->cur_context = ctx; @@ -333,7 +347,7 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) st->txh.flags |= GF_SR_TEXTURE_NO_GL_FLIP; gf_sc_texture_set_data(&st->txh); #ifndef GPAC_DISABLE_3D - if (tr_state->visual->type_3d) + if (tr_state->visual->type_3d) gf_sc_texture_push_image(&st->txh, 0, 0); else #endif @@ -378,7 +392,7 @@ void svg_draw_filter(GF_Node *filter, GF_Node *node, GF_TraverseState *tr_state) visual_3d_draw_from_context(tr_state->ctx, tr_state); ctx->drawable = NULL; return; - } + } #endif /*we computed the texture in final screen coordinate, so use the identity matrix for the context*/ diff --git a/src/compositor/svg_font.c b/src/compositor/svg_font.c index a02bf24..eb9c4d2 100644 --- a/src/compositor/svg_font.c +++ b/src/compositor/svg_font.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2007-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -79,7 +79,7 @@ static GF_Err svg_font_get_glyphs(void *udta, const char *utf_string, u32 *glyph gl_idx = 0; prev_c = 0; - for (i=0;ichildren; @@ -90,7 +90,7 @@ static GF_Err svg_font_get_glyphs(void *udta, const char *utf_string, u32 *glyph } else if (tag ==TAG_SVG_glyph) { Bool glyph_ok = 0; SVGAllAttributes atts; - + st = gf_node_get_private(child->node); if (!st) { child = child->next; @@ -150,15 +150,15 @@ static GF_Err svg_font_get_glyphs(void *udta, const char *utf_string, u32 *glyph } prev_c = glyph_buffer[i]; - if (!st) + if (!st) st = missing_glyph; glyph_buffer[gl_idx] = st ? st->glyph.ID : 0; if (st && st->uni_len>1) i++; - + gl_idx++; } *io_glyph_buffer_size = /* len = */ gl_idx; - + return GF_OK; } @@ -176,7 +176,7 @@ static GF_Glyph *svg_font_load_glyph(void *udta, u32 glyph_name) } child = child->next; } - + return NULL; } @@ -264,25 +264,51 @@ void compositor_init_svg_font(GF_Compositor *compositor, GF_Node *node) if (atts.font_weight) { switch(*atts.font_weight) { - case SVG_FONTWEIGHT_100: font->styles |= GF_FONT_WEIGHT_100; break; - case SVG_FONTWEIGHT_LIGHTER: font->styles |= GF_FONT_WEIGHT_LIGHTER; break; - case SVG_FONTWEIGHT_200: font->styles |= GF_FONT_WEIGHT_200; break; - case SVG_FONTWEIGHT_300: font->styles |= GF_FONT_WEIGHT_300; break; - case SVG_FONTWEIGHT_400: font->styles |= GF_FONT_WEIGHT_400; break; - case SVG_FONTWEIGHT_NORMAL: font->styles |= GF_FONT_WEIGHT_NORMAL; break; - case SVG_FONTWEIGHT_500: font->styles |= GF_FONT_WEIGHT_500; break; - case SVG_FONTWEIGHT_600: font->styles |= GF_FONT_WEIGHT_600; break; - case SVG_FONTWEIGHT_700: font->styles |= GF_FONT_WEIGHT_700; break; - case SVG_FONTWEIGHT_BOLD: font->styles |= GF_FONT_WEIGHT_BOLD; break; - case SVG_FONTWEIGHT_800: font->styles |= GF_FONT_WEIGHT_800; break; - case SVG_FONTWEIGHT_900: font->styles |= GF_FONT_WEIGHT_900; break; - case SVG_FONTWEIGHT_BOLDER: font->styles |= GF_FONT_WEIGHT_BOLDER; break; + case SVG_FONTWEIGHT_100: + font->styles |= GF_FONT_WEIGHT_100; + break; + case SVG_FONTWEIGHT_LIGHTER: + font->styles |= GF_FONT_WEIGHT_LIGHTER; + break; + case SVG_FONTWEIGHT_200: + font->styles |= GF_FONT_WEIGHT_200; + break; + case SVG_FONTWEIGHT_300: + font->styles |= GF_FONT_WEIGHT_300; + break; + case SVG_FONTWEIGHT_400: + font->styles |= GF_FONT_WEIGHT_400; + break; + case SVG_FONTWEIGHT_NORMAL: + font->styles |= GF_FONT_WEIGHT_NORMAL; + break; + case SVG_FONTWEIGHT_500: + font->styles |= GF_FONT_WEIGHT_500; + break; + case SVG_FONTWEIGHT_600: + font->styles |= GF_FONT_WEIGHT_600; + break; + case SVG_FONTWEIGHT_700: + font->styles |= GF_FONT_WEIGHT_700; + break; + case SVG_FONTWEIGHT_BOLD: + font->styles |= GF_FONT_WEIGHT_BOLD; + break; + case SVG_FONTWEIGHT_800: + font->styles |= GF_FONT_WEIGHT_800; + break; + case SVG_FONTWEIGHT_900: + font->styles |= GF_FONT_WEIGHT_900; + break; + case SVG_FONTWEIGHT_BOLDER: + font->styles |= GF_FONT_WEIGHT_BOLDER; + break; } } gf_svg_flatten_attributes((SVG_Element*)node_font, &atts); font->max_advance_h = atts.horiz_adv_x ? FIX2INT( gf_ceil(atts.horiz_adv_x->value) ) : 0; - + font->not_loaded = 1; /*wait for onLoad event before activating the font, otherwise we may not have all the glyphs*/ @@ -293,7 +319,7 @@ void compositor_init_svg_font(GF_Compositor *compositor, GF_Node *node) static void svg_traverse_glyph(GF_Node *node, void *rs, Bool is_destroy) -{ +{ if (is_destroy) { GF_Font *font; GF_Glyph *prev_glyph, *a_glyph; @@ -370,7 +396,7 @@ reg_common: st->glyph.height = FIX2INT( gf_ceil(rc.height) ); } st->glyph.vert_advance = st->glyph.height; - if (!st->glyph.vert_advance) + if (!st->glyph.vert_advance) st->glyph.vert_advance = font->max_advance_v; /*register glyph*/ @@ -419,7 +445,7 @@ static Bool svg_font_uri_check(GF_Node *node, FontURIStack *st) if (!atts.xlink_href->target) return 0; } font_elt = atts.xlink_href->target; - if (gf_node_get_tag(font_elt) != TAG_SVG_font) return 0; + if (gf_node_get_tag(font_elt) != TAG_SVG_font) return 0; font = gf_node_get_private(font_elt); if (!font) return 0; st->alias = font; diff --git a/src/compositor/svg_geometry.c b/src/compositor/svg_geometry.c index 96e097a..f95f391 100644 --- a/src/compositor/svg_geometry.c +++ b/src/compositor/svg_geometry.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,18 +54,18 @@ Bool svg_drawable_is_over(Drawable *drawable, Fixed x, Fixed y, DrawAspect2D *as gf_path_get_bounds(drawable->path, &rc); } inside = ( (x >= rc.x) && (y <= rc.y) && (x <= rc.x + rc.width) && (y >= rc.y - rc.height) ) ? 1 : 0; - + if (ptr_evt==SVG_POINTEREVENTS_BOUNDINGBOX) return inside; check_fill = check_stroke = check_over = check_outline = check_vis = 0; /* check_vis: if set, return FALSE when visible property is not "visible" - check_fill: + check_fill: if 1, checks whether point is over path, - if 2, checks if the path is painted (even with fill-opacity=0) before - check_stroke: + if 2, checks if the path is painted (even with fill-opacity=0) before + check_stroke: if 1, checks whether point is over path outline, - if 2, checks if the path outline is painted (even with stroke-opacity=0) before + if 2, checks if the path outline is painted (even with stroke-opacity=0) before */ switch (ptr_evt) { case SVG_POINTEREVENTS_VISIBLE: @@ -145,7 +145,7 @@ Bool svg_drawable_is_over(Drawable *drawable, Fixed x, Fixed y, DrawAspect2D *as if (glyph_rc) return 1; si = drawable_get_strikeinfo(tr_state->visual->compositor, drawable, asp, tr_state->appear, NULL, 0, NULL); /*point is over outline*/ - if (si && si->outline && gf_path_point_over(si->outline, x, y)) + if (si && si->outline && gf_path_point_over(si->outline, x, y)) return 1; } } @@ -166,7 +166,7 @@ void svg_clone_use_stack(GF_Compositor *compositor, GF_TraverseState *tr_state) #ifndef GPAC_DISABLE_3D -void svg_drawable_3d_pick(Drawable *drawable, GF_TraverseState *tr_state, DrawAspect2D *asp) +void svg_drawable_3d_pick(Drawable *drawable, GF_TraverseState *tr_state, DrawAspect2D *asp) { SFVec3f local_pt, world_pt, vdiff; SFVec3f hit_normal; @@ -208,7 +208,8 @@ void svg_drawable_3d_pick(Drawable *drawable, GF_TraverseState *tr_state, DrawAs if (!node_is_over) return; - hit_normal.x = hit_normal.y = 0; hit_normal.z = FIX_ONE; + hit_normal.x = hit_normal.y = 0; + hit_normal.z = FIX_ONE; text_coords.x = gf_divfix(local_pt.x, drawable->path->bbox.width) + FIX_ONE/2; text_coords.y = gf_divfix(local_pt.y, drawable->path->bbox.height) + FIX_ONE/2; @@ -256,7 +257,7 @@ void svg_drawable_3d_pick(Drawable *drawable, GF_TraverseState *tr_state, DrawAs compositor->hit_use_dom_events = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[SVG Picking] node %s (def %s) is under mouse - hit %g %g %g\n", gf_node_get_class_name(drawable->node), gf_node_get_name(drawable->node), - FIX2FLT(world_pt.x), FIX2FLT(world_pt.y), FIX2FLT(world_pt.z))); + FIX2FLT(world_pt.x), FIX2FLT(world_pt.y), FIX2FLT(world_pt.z))); } #endif @@ -292,7 +293,7 @@ void svg_drawable_pick(GF_Node *node, Drawable *drawable, GF_TraverseState *tr_s compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &mx_3d); memcpy(tr_state->svg_props, &backup_props, sizeof(SVGPropertiesPointers)); return; - } + } #endif gf_mx2d_copy(inv_2d, tr_state->transform); gf_mx2d_inverse(&inv_2d); @@ -313,7 +314,8 @@ void svg_drawable_pick(GF_Node *node, Drawable *drawable, GF_TraverseState *tr_s compositor->hit_node = drawable->node; compositor->hit_use_dom_events = 1; - compositor->hit_normal.x = compositor->hit_normal.y = 0; compositor->hit_normal.z = FIX_ONE; + compositor->hit_normal.x = compositor->hit_normal.y = 0; + compositor->hit_normal.z = FIX_ONE; compositor->hit_texcoords.x = gf_divfix(x, drawable->path->bbox.width) + FIX_ONE/2; compositor->hit_texcoords.y = gf_divfix(y, drawable->path->bbox.height) + FIX_ONE/2; svg_clone_use_stack(compositor, tr_state); @@ -336,8 +338,8 @@ void svg_drawable_pick(GF_Node *node, Drawable *drawable, GF_TraverseState *tr_s } static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, - void (*rebuild_path)(GF_Node *, Drawable *, SVGAllAttributes *), - Bool is_svg_rect, Bool is_svg_path) + void (*rebuild_path)(GF_Node *, Drawable *, SVGAllAttributes *), + Bool is_svg_rect, Bool is_svg_path) { GF_Matrix2D backup_matrix; GF_Matrix mx_3d; @@ -358,7 +360,7 @@ static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, } assert(tr_state->traversing_mode!=TRAVERSE_DRAW_2D); - + if (tr_state->traversing_mode==TRAVERSE_PICK) { svg_drawable_pick(node, drawable, tr_state); return; @@ -368,7 +370,7 @@ static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, gf_svg_flatten_attributes((SVG_Element *)node, &all_atts); if (!compositor_svg_traverse_base(node, &all_atts, (GF_TraverseState *)rs, &backup_props, &backup_flags)) return; - + /* Recreates the path (i.e the shape) only if the node is dirty */ if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) { /*the rebuild function is responsible for cleaning the path*/ @@ -416,7 +418,7 @@ static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, gf_node_dirty_clear(node, 0); if (!compositor_svg_is_display_off(tr_state->svg_props) && - ( *(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) ) { + ( *(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) ) { compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &mx_3d); @@ -428,12 +430,12 @@ static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, else if (ctx->transform.m[1] || ctx->transform.m[3]) {} else { ctx->flags &= ~CTX_IS_TRANSPARENT; - if (!ctx->aspect.pen_props.width) + if (!ctx->aspect.pen_props.width) ctx->flags |= CTX_NO_ANTIALIAS; } } - if (all_atts.pathLength && all_atts.pathLength->type==SVG_NUMBER_VALUE) + if (all_atts.pathLength && all_atts.pathLength->type==SVG_NUMBER_VALUE) ctx->aspect.pen_props.path_length = all_atts.pathLength->value; #ifndef GPAC_DISABLE_3D @@ -444,7 +446,7 @@ static void svg_drawable_traverse(GF_Node *node, void *rs, Bool is_destroy, } visual_3d_draw_from_context(ctx, tr_state); ctx->drawable = NULL; - } else + } else #endif { drawable_finalize_sort(ctx, tr_state, NULL); @@ -509,34 +511,38 @@ static void svg_rect_rebuild(GF_Node *node, Drawable *stack, SVGAllAttributes *a if (width-rx!=rx) gf_path_add_line_to(stack->path, x+width-rx, y); - cx = x+width-rx; cy = y+ry; + cx = x+width-rx; + cy = y+ry; svg_rect_add_arc(stack->path, x+width, y+ry, cx, cy, rx, ry); - + if (height-ry!=ry) gf_path_add_line_to(stack->path, x+width, y+height-ry); - cx = x+width-rx; cy = y+height-ry; + cx = x+width-rx; + cy = y+height-ry; svg_rect_add_arc(stack->path, x+width-rx, y+height, cx, cy, rx, ry); - + if (width-rx!=rx) gf_path_add_line_to(stack->path, x+rx, y+height); - cx = x+rx; cy = y+height-ry; + cx = x+rx; + cy = y+height-ry; svg_rect_add_arc(stack->path, x, y+height-ry, cx, cy, rx, ry); - + if (height-ry!=ry) gf_path_add_line_to(stack->path, x, y+ry); - cx = x+rx; cy = y+ry; + cx = x+rx; + cy = y+ry; svg_rect_add_arc(stack->path, x+rx, y, cx, cy, rx, ry); gf_path_close(stack->path); } else { gf_path_add_move_to(stack->path, x, y); - gf_path_add_line_to(stack->path, x+width, y); - gf_path_add_line_to(stack->path, x+width, y+height); - gf_path_add_line_to(stack->path, x, y+height); - gf_path_close(stack->path); + gf_path_add_line_to(stack->path, x+width, y); + gf_path_add_line_to(stack->path, x+width, y+height); + gf_path_add_line_to(stack->path, x, y+height); + gf_path_close(stack->path); } } @@ -572,10 +578,10 @@ void compositor_init_svg_circle(GF_Compositor *compositor, GF_Node *node) static void svg_ellipse_rebuild(GF_Node *node, Drawable *stack, SVGAllAttributes *atts) { drawable_reset_path(stack); - gf_path_add_ellipse(stack->path, (atts->cx ? atts->cx->value : 0), - (atts->cy ? atts->cy->value : 0), - (atts->rx ? 2*atts->rx->value : 0), - (atts->ry ? 2*atts->ry->value : 0)); + gf_path_add_ellipse(stack->path, (atts->cx ? atts->cx->value : 0), + (atts->cy ? atts->cy->value : 0), + (atts->rx ? 2*atts->rx->value : 0), + (atts->ry ? 2*atts->ry->value : 0)); } static void svg_traverse_ellipse(GF_Node *node, void *rs, Bool is_destroy) { @@ -609,9 +615,9 @@ static void svg_polyline_rebuild(GF_Node *node, Drawable *stack, SVGAllAttribute { u32 i, nbPoints; drawable_reset_path(stack); - if (atts->points) + if (atts->points) nbPoints = gf_list_count(*atts->points); - else + else nbPoints = 0; if (nbPoints) { @@ -640,9 +646,9 @@ static void svg_polygon_rebuild(GF_Node *node, Drawable *stack, SVGAllAttributes { u32 i, nbPoints; drawable_reset_path(stack); - if (atts->points) + if (atts->points) nbPoints = gf_list_count(*atts->points); - else + else nbPoints = 0; if (nbPoints) { diff --git a/src/compositor/svg_grouping.c b/src/compositor/svg_grouping.c index 51cce0b..e0f5a25 100644 --- a/src/compositor/svg_grouping.c +++ b/src/compositor/svg_grouping.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ #include "mpeg4_grouping.h" -typedef struct +typedef struct { Bool root_svg; SVGPropertiesPointers *svg_props; @@ -55,7 +55,7 @@ typedef struct } SVGsvgStack; -static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *stack, GF_TraverseState *tr_state, SVGAllAttributes *atts) +static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *stack, GF_TraverseState *tr_state, SVGAllAttributes *atts) { GF_Matrix2D mx; SVG_ViewBox ext_vb, *vb; @@ -64,7 +64,7 @@ static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *st Fixed parent_width, parent_height, doc_width, doc_height; /*canvas size negociation has already been done when attaching the scene to the compositor*/ - if (atts->width && (atts->width->type==SVG_NUMBER_PERCENTAGE) ) { + if (atts->width && (atts->width->type==SVG_NUMBER_PERCENTAGE) ) { parent_width = gf_mulfix(tr_state->vp_size.x, atts->width->value/100); doc_width = 0; } else if (!stack->root_svg) { @@ -74,7 +74,7 @@ static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *st doc_width = atts->width ? atts->width->value : 0; } - if (atts->height && (atts->height->type==SVG_NUMBER_PERCENTAGE) ) { + if (atts->height && (atts->height->type==SVG_NUMBER_PERCENTAGE) ) { parent_height = gf_mulfix(tr_state->vp_size.y, atts->height->value/100); doc_height = 0; } else if (!stack->root_svg) { @@ -107,9 +107,9 @@ static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *st } else if (!strncmp(frag_uri, "svgView(transform(", 18)) { Bool ret = gf_svg_parse_transformlist(&mx, (char *) frag_uri+18); - if (!ret) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error parsing SVG View transform component: %s\n", frag_uri+18)); - } + if (!ret) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error parsing SVG View transform component: %s\n", frag_uri+18)); + } } } /*fragID*/ @@ -170,7 +170,7 @@ static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *st if (tr_state->parent_anim_atts) { if (tr_state->parent_anim_atts->preserveAspectRatio) { if (tr_state->parent_anim_atts->preserveAspectRatio->defer) { - if (atts->preserveAspectRatio) + if (atts->preserveAspectRatio) par = *atts->preserveAspectRatio; } else { par = *tr_state->parent_anim_atts->preserveAspectRatio; @@ -207,45 +207,45 @@ static void svg_recompute_viewport_transformation(GF_Node *node, SVGsvgStack *st if (par.align==SVG_PRESERVEASPECTRATIO_NONE) { stack->viewbox_mx.m[0] = gf_divfix(parent_width, vb->width); stack->viewbox_mx.m[4] = gf_divfix(parent_height, vb->height); - stack->viewbox_mx.m[2] = - gf_muldiv(vb->x, parent_width, vb->width); - stack->viewbox_mx.m[5] = - gf_muldiv(vb->y, parent_height, vb->height); + stack->viewbox_mx.m[2] = - gf_muldiv(vb->x, parent_width, vb->width); + stack->viewbox_mx.m[5] = - gf_muldiv(vb->y, parent_height, vb->height); } else { Fixed dx, dy; stack->viewbox_mx.m[0] = stack->viewbox_mx.m[4] = scale; - stack->viewbox_mx.m[2] = - gf_mulfix(vb->x, scale); - stack->viewbox_mx.m[5] = - gf_mulfix(vb->y, scale); + stack->viewbox_mx.m[2] = - gf_mulfix(vb->x, scale); + stack->viewbox_mx.m[5] = - gf_mulfix(vb->y, scale); dx = dy = 0; switch (par.align) { case SVG_PRESERVEASPECTRATIO_XMINYMIN: break; case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - dx = ( parent_width - vp_w) / 2; + dx = ( parent_width - vp_w) / 2; break; case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - dx = parent_width - vp_w; + dx = parent_width - vp_w; break; case SVG_PRESERVEASPECTRATIO_XMINYMID: - dy = ( parent_height - vp_h) / 2; + dy = ( parent_height - vp_h) / 2; break; case SVG_PRESERVEASPECTRATIO_XMIDYMID: - dx = ( parent_width - vp_w) / 2; - dy = ( parent_height - vp_h) / 2; + dx = ( parent_width - vp_w) / 2; + dy = ( parent_height - vp_h) / 2; break; case SVG_PRESERVEASPECTRATIO_XMAXYMID: - dx = parent_width - vp_w; - dy = ( parent_height - vp_h) / 2; + dx = parent_width - vp_w; + dy = ( parent_height - vp_h) / 2; break; case SVG_PRESERVEASPECTRATIO_XMINYMAX: - dy = parent_height - vp_h; + dy = parent_height - vp_h; break; case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - dx = (parent_width - vp_w) / 2; - dy = parent_height - vp_h; + dx = (parent_width - vp_w) / 2; + dy = parent_height - vp_h; break; case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - dx = parent_width - vp_w; - dy = parent_height - vp_h; + dx = parent_width - vp_w; + dy = parent_height - vp_h; break; } gf_mx2d_add_translation(&stack->viewbox_mx, dx, dy); @@ -311,7 +311,7 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) tr_state->svg_props = stack->svg_props; if (!tr_state->svg_props) return; } - + gf_svg_flatten_attributes((SVG_Element *)node, &all_atts); if (!compositor_svg_traverse_base(node, &all_atts, tr_state, &backup_props, &backup_flags)) { tr_state->svg_props = prev_props; @@ -333,11 +333,11 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) #ifndef GPAC_DISABLE_3D //commented to get rid of GCC warning - //if (tr_state->visual->type_3d) - gf_mx_copy(bck_mx, tr_state->model_matrix); - + //if (tr_state->visual->type_3d) + gf_mx_copy(bck_mx, tr_state->model_matrix); + #endif - + invalidate_flag = tr_state->invalidate_all; is_dirty = gf_node_dirty_get(node); @@ -356,7 +356,7 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) gf_mx2d_copy(tr_state->vb_transform, stack->viewbox_mx); - rootmost_svg = (stack->root_svg && !tr_state->parent_anim_atts) ? 1 : 0; + rootmost_svg = (stack->root_svg && !tr_state->parent_anim_atts) ? 1 : 0; if (tr_state->traversing_mode == TRAVERSE_SORT) { SVG_Paint *vp_fill = NULL; Fixed vp_opacity; @@ -367,7 +367,7 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) } else { vp_fill = tr_state->svg_props->viewport_fill; vp_opacity = tr_state->svg_props->viewport_fill_opacity ? tr_state->svg_props->viewport_fill_opacity->value : FIX_ONE; - } + } if (vp_fill && (vp_fill->type != SVG_PAINT_NONE) && vp_opacity) { Bool col_dirty = 0; @@ -411,21 +411,13 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) } - if (!stack->root_svg && (all_atts.x || all_atts.y)) + if (!stack->root_svg && (all_atts.x || all_atts.y)) gf_mx2d_add_translation(&tr_state->vb_transform, all_atts.x->value, all_atts.y->value); #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { - if (tr_state->traversing_mode==TRAVERSE_SORT) { - GF_Matrix tmp; - visual_3d_matrix_push(tr_state->visual); - - gf_mx_from_mx2d(&tmp, &tr_state->vb_transform); - visual_3d_matrix_add(tr_state->visual, tmp.m); - } else { - gf_mx_add_matrix_2d(&tr_state->model_matrix, &tr_state->vb_transform); - } - } else + gf_mx_add_matrix_2d(&tr_state->model_matrix, &tr_state->vb_transform); + } else #endif { gf_mx2d_pre_multiply(&tr_state->transform, &tr_state->vb_transform); @@ -435,7 +427,7 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) prev_vp = tr_state->vp_size; tr_state->vp_size = stack->vp; - /*the event may trigger scripts which may delete nodes / modify the scene. We therefore send the resize event + /*the event may trigger scripts which may delete nodes / modify the scene. We therefore send the resize event before traversing the scene*/ if (send_resize) { GF_DOM_Event evt; @@ -446,8 +438,8 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) } if ((stack->vp.x != prev_vp.x) || (stack->vp.y != prev_vp.y)) { GF_Scene *scene = node->sgprivate->scenegraph->userpriv; - - if (scene) { + + if (scene) { GF_DOM_Event evt; memset(&evt, 0, sizeof(GF_DOM_Event)); evt.bubbles = 0; @@ -471,11 +463,10 @@ static void svg_traverse_svg(GF_Node *node, void *rs, Bool is_destroy) #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { - if (tr_state->traversing_mode==TRAVERSE_SORT) visual_3d_matrix_pop(tr_state->visual); gf_mx_copy(tr_state->model_matrix, bck_mx); } #endif - gf_mx2d_copy(tr_state->transform, backup_matrix); + gf_mx2d_copy(tr_state->transform, backup_matrix); gf_mx2d_copy(tr_state->vb_transform, vb_bck); memcpy(tr_state->svg_props, &backup_props, styling_size); tr_state->svg_flags = backup_flags; @@ -505,7 +496,7 @@ void compositor_init_svg_svg(GF_Compositor *compositor, GF_Node *node) gf_node_set_callback_function(node, svg_traverse_svg); } -Bool compositor_svg_get_viewport(GF_Node *n, GF_Rect *rc) +Bool compositor_svg_get_viewport(GF_Node *n, GF_Rect *rc) { SVGsvgStack *stack; if (gf_node_get_tag(n) != TAG_SVG_svg) return 0; @@ -550,7 +541,11 @@ static void svg_traverse_g(GF_Node *node, void *rs, Bool is_destroy) return; } /*group cache traverse routine*/ - else if (tr_state->traversing_mode == TRAVERSE_DRAW_2D) { + else if ((tr_state->traversing_mode == TRAVERSE_DRAW_2D) +#ifndef GPAC_DISABLE_3D + || (tr_state->traversing_mode == TRAVERSE_DRAW_3D) +#endif + ) { SVGgStack *group = gf_node_get_private(node); group_cache_draw(group->cache, tr_state); return; @@ -562,16 +557,16 @@ static void svg_traverse_g(GF_Node *node, void *rs, Bool is_destroy) return; if (compositor_svg_is_display_off(tr_state->svg_props)) { -/* u32 prev_flags = tr_state->switched_off; - tr_state->switched_off = 1; - compositor_svg_traverse_children(((SVG_Element *)node)->children, tr_state); - tr_state->switched_off = prev_flags;*/ + /* u32 prev_flags = tr_state->switched_off; + tr_state->switched_off = 1; + compositor_svg_traverse_children(((SVG_Element *)node)->children, tr_state); + tr_state->switched_off = prev_flags;*/ memcpy(tr_state->svg_props, &backup_props, styling_size); tr_state->svg_flags = backup_flags; return; - } - + } + compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &mx_3d); if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { gf_sc_get_nodes_bounds(node, ((SVG_Element *)node)->children, tr_state, NULL); @@ -582,7 +577,7 @@ static void svg_traverse_g(GF_Node *node, void *rs, Bool is_destroy) Fixed opacity = FIX_ONE; Bool clear = 0; SVGgStack *group; - + if (!tr_state->in_svg_filter && all_atts.filter && all_atts.filter->iri.target) { svg_draw_filter(all_atts.filter->iri.target, node, tr_state); return; @@ -648,14 +643,14 @@ static void svg_traverse_g(GF_Node *node, void *rs, Bool is_destroy) while (child) { gf_node_traverse(child->node, tr_state); child = child->next; - if (tr_state->cache_too_small) + if (tr_state->cache_too_small) cache_too_small++; } if (cache_too_small) { tr_state->cache_too_small = 1; } else { - /*get the traversal time for each group*/ + /*get the traversal time for each group*/ traverse_time = gf_sys_clock() - traverse_time; group->traverse_time += traverse_time; /*record the traversal information and turn cache on if possible*/ @@ -675,7 +670,7 @@ static void svg_traverse_g(GF_Node *node, void *rs, Bool is_destroy) tr_state->depth_offset = offset; #endif } else { - compositor_svg_traverse_children(((SVG_Element *)node)->children, tr_state); + compositor_svg_traverse_children(((SVG_Element *)node)->children, tr_state); } compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &mx_3d); memcpy(tr_state->svg_props, &backup_props, styling_size); @@ -774,7 +769,7 @@ static void svg_traverse_switch(GF_Node *node, void *rs, Bool is_destroy) tr_state->svg_flags = backup_flags; return; } - + if (*selected_idx >= 0) { compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &mx_3d); if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { @@ -830,8 +825,8 @@ static void svg_traverse_a(GF_Node *node, void *rs, Bool is_destroy) memcpy(tr_state->svg_props, &backup_props, styling_size); tr_state->svg_flags = backup_flags; return; - } - + } + compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &mx_3d); if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { gf_sc_get_nodes_bounds(node, ((SVG_Element *)node)->children, tr_state, NULL); @@ -872,7 +867,7 @@ static void svg_a_set_view(GF_Node *handler, GF_Compositor *compositor, const ch compositor->trans_x = compositor->trans_y = 0; compositor->rotation = 0; compositor->zoom = FIX_ONE; - compositor_2d_set_user_transform(compositor, FIX_ONE, 0, 0, 0); + compositor_2d_set_user_transform(compositor, FIX_ONE, 0, 0, 0); gf_sc_invalidate(compositor, NULL); } @@ -896,7 +891,7 @@ static void svg_a_handle_event(GF_Node *handler, GF_DOM_Event *event, GF_Node *o if (event->type==GF_EVENT_MOUSEOVER) { evt.type = GF_EVENT_NAVIGATE_INFO; - + if (all_atts.xlink_title) evt.navigate.to_url = *all_atts.xlink_title; else if (all_atts.xlink_href->string) evt.navigate.to_url = all_atts.xlink_href->string; else { @@ -909,7 +904,7 @@ static void svg_a_handle_event(GF_Node *handler, GF_DOM_Event *event, GF_Node *o } evt.type = GF_EVENT_NAVIGATE; - + if (all_atts.xlink_href->type == XMLRI_STRING) { evt.navigate.to_url = gf_term_resolve_xlink(handler, all_atts.xlink_href->string); if (evt.navigate.to_url) { @@ -943,11 +938,11 @@ static void svg_a_handle_event(GF_Node *handler, GF_DOM_Event *event, GF_Node *o } if (!all_atts.xlink_href->target) { return; - } + } /*this is a time event*/ if (is_timing_target(all_atts.xlink_href->target)) { gf_smil_timing_insert_clock(all_atts.xlink_href->target, 0, gf_node_get_scene_time((GF_Node *)handler) ); - } + } /*this is an implicit SVGView event*/ else { svg_a_set_view(handler, compositor, gf_node_get_name(all_atts.xlink_href->target)); @@ -994,7 +989,7 @@ static void svg_traverse_resource(GF_Node *node, void *rs, Bool is_destroy, Bool { GF_Matrix2D backup_matrix; GF_Matrix mx_3d; - GF_Matrix2D translate; + GF_Matrix2D translate; SVGPropertiesPointers backup_props; u32 backup_flags, dirty; Bool is_fragment, parent_is_use; @@ -1086,25 +1081,19 @@ static void svg_traverse_resource(GF_Node *node, void *rs, Bool is_destroy, Bool if (!compositor_svg_is_display_off(tr_state->svg_props)) { gf_node_traverse(used_node, tr_state); gf_mx2d_apply_rect(&translate, &tr_state->bounds); - } + } compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &mx_3d); } /*SORT mode and visible, traverse*/ - else if (!compositor_svg_is_display_off(tr_state->svg_props) - && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN)) { + else if (!compositor_svg_is_display_off(tr_state->svg_props) + && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN)) { compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &mx_3d); #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { gf_mx_add_matrix_2d(&tr_state->model_matrix, &translate); - - if (tr_state->traversing_mode==TRAVERSE_SORT) { - GF_Matrix tmp; - gf_mx_from_mx2d(&tmp, &translate); - visual_3d_matrix_add(tr_state->visual, tmp.m); - } - } else + } else #endif gf_mx2d_pre_multiply(&tr_state->transform, &translate); @@ -1115,7 +1104,7 @@ static void svg_traverse_resource(GF_Node *node, void *rs, Bool is_destroy, Bool } else { gf_sc_traverse_subscene(tr_state->visual->compositor, node, stack->inline_sg, tr_state); } - compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &mx_3d); + compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &mx_3d); } gf_list_rem_last(tr_state->use_stack); @@ -1167,9 +1156,9 @@ static void svg_animation_smil_update(GF_Node *node, SVGlinkStack *stack, Fixed if (stack->needs_play) { gf_mo_play(stack->resource, clipBegin, clipEnd, 0); stack->needs_play = 0; - } else { - Bool primary = all_atts.gpac_useAsPrimary ? *all_atts.gpac_useAsPrimary : 1; - new_res = gf_mo_load_xlink_resource(node, primary, clipBegin, clipEnd); + } else { + Bool primary = all_atts.gpac_useAsPrimary ? *all_atts.gpac_useAsPrimary : 1; + new_res = gf_mo_load_xlink_resource(node, primary, clipBegin, clipEnd); if (new_res != stack->resource) { if (stack->resource) gf_mo_unload_xlink_resource(node, stack->resource); if (all_atts.xlink_href) all_atts.xlink_href->target = NULL; @@ -1237,7 +1226,7 @@ static void svg_traverse_animation(GF_Node *node, void *rs, Bool is_destroy) GF_IRect clip, prev_clip; SVGAllAttributes *prev_vp_atts; GF_TraverseState *tr_state = (GF_TraverseState*)rs; - GF_Matrix2D translate; + GF_Matrix2D translate; SVGPropertiesPointers *old_props; SVGlinkStack *stack = gf_node_get_private(node); @@ -1267,9 +1256,9 @@ static void svg_traverse_animation(GF_Node *node, void *rs, Bool is_destroy) if (!compositor_svg_traverse_base(node, &all_atts, tr_state, &backup_props, &backup_flags)) return; - + if (compositor_svg_is_display_off(tr_state->svg_props) || - *(tr_state->svg_props->visibility) == SVG_VISIBILITY_HIDDEN) { + *(tr_state->svg_props->visibility) == SVG_VISIBILITY_HIDDEN) { goto end; } @@ -1282,20 +1271,14 @@ static void svg_traverse_animation(GF_Node *node, void *rs, Bool is_destroy) #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { gf_mx_add_matrix_2d(&tr_state->model_matrix, &translate); - - if (tr_state->traversing_mode==TRAVERSE_SORT) { - GF_Matrix tmp; - gf_mx_from_mx2d(&tmp, &translate); - visual_3d_matrix_add(tr_state->visual, tmp.m); - } - } else + } else #endif gf_mx2d_pre_multiply(&tr_state->transform, &translate); /*reset SVG props to reload a new inheritance context*/ old_props = tr_state->svg_props; tr_state->svg_props = NULL; - + /*store this node's attribute to compute PAR/ViewBox of the child */ prev_vp_atts = tr_state->parent_anim_atts; tr_state->parent_anim_atts = &all_atts; @@ -1340,7 +1323,7 @@ static void svg_traverse_animation(GF_Node *node, void *rs, Bool is_destroy) tr_state->parent_anim_atts = prev_vp_atts; tr_state->vp_size = prev_vp; - compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &backup_matrix3d); + compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &backup_matrix3d); end: memcpy(tr_state->svg_props, &backup_props, sizeof(SVGPropertiesPointers)); @@ -1361,7 +1344,7 @@ void compositor_init_svg_animation(GF_Compositor *compositor, GF_Node *node) gf_node_dirty_set(node, GF_SG_SVG_XLINK_HREF_DIRTY, 0); } -void svg_pause_animation(GF_Node *n, Bool pause) +void svg_pause_animation(GF_Node *n, Bool pause) { SVGlinkStack *st = gf_node_get_private(n); if (!st) return; diff --git a/src/compositor/svg_media.c b/src/compositor/svg_media.c index 645c046..3cf4cf7 100644 --- a/src/compositor/svg_media.c +++ b/src/compositor/svg_media.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,7 +37,7 @@ typedef struct { GF_TextureHandler txh; Drawable *graph; - MFURL txurl; + MFURL txurl; Bool first_frame_fetched; GF_Node *audio; Bool audio_dirty; @@ -96,7 +96,7 @@ static void SVG_Build_Bitmap_Graph(SVG_video_stack *stack, GF_TraverseState *tr_ SVG_Element *e = (SVG_Element *)stack->graph->node; gf_svg_flatten_attributes(e, &atts); - + tag = gf_node_get_tag(stack->graph->node); switch (tag) { case TAG_SVG_image: @@ -111,7 +111,7 @@ static void SVG_Build_Bitmap_Graph(SVG_video_stack *stack, GF_TraverseState *tr_ } if (!width || !height) return; - + txheight = INT2FIX(stack->txh.height); txwidth = INT2FIX(stack->txh.width); @@ -134,7 +134,7 @@ static void SVG_Build_Bitmap_Graph(SVG_video_stack *stack, GF_TraverseState *tr_ if (pAR.align==SVG_PRESERVEASPECTRATIO_NONE) { rectwidth = width; - rectheight = height; + rectheight = height; rectx = x+rectwidth/2; recty = y+rectheight/2; } else { @@ -169,32 +169,32 @@ static void SVG_Build_Bitmap_Graph(SVG_video_stack *stack, GF_TraverseState *tr_ case SVG_PRESERVEASPECTRATIO_XMINYMIN: break; case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - rectx += (width - rectwidth)/ 2; + rectx += (width - rectwidth)/ 2; break; case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - rectx += width - rectwidth; + rectx += width - rectwidth; break; case SVG_PRESERVEASPECTRATIO_XMINYMID: - recty += (height - rectheight)/ 2; + recty += (height - rectheight)/ 2; break; case SVG_PRESERVEASPECTRATIO_XMIDYMID: - rectx += (width - rectwidth)/ 2; - recty += (height - rectheight) / 2; + rectx += (width - rectwidth)/ 2; + recty += (height - rectheight) / 2; break; case SVG_PRESERVEASPECTRATIO_XMAXYMID: - rectx += width - rectwidth; - recty += ( txheight - rectheight) / 2; + rectx += width - rectwidth; + recty += ( txheight - rectheight) / 2; break; case SVG_PRESERVEASPECTRATIO_XMINYMAX: - recty += height - rectheight; + recty += height - rectheight; break; case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - rectx += (width - rectwidth)/ 2; - recty += height - rectheight; + rectx += (width - rectwidth)/ 2; + recty += height - rectheight; break; case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - rectx += width - rectwidth; - recty += height - rectheight; + rectx += width - rectwidth; + recty += height - rectheight; break; } } @@ -205,7 +205,7 @@ static void SVG_Build_Bitmap_Graph(SVG_video_stack *stack, GF_TraverseState *tr_ drawable_reset_path(stack->graph); gf_path_add_rect_center(stack->graph->path, rectx, recty, rectwidth, rectheight); gf_path_get_bounds(stack->graph->path, &new_rc); - if (!gf_rect_equal(rc, new_rc)) + if (!gf_rect_equal(rc, new_rc)) drawable_mark_modified(stack->graph, tr_state); else if (stack->txh.flags & GF_SR_TEXTURE_PRIVATE_MEDIA) drawable_mark_modified(stack->graph, tr_state); @@ -230,11 +230,11 @@ static void svg_play_texture(SVG_video_stack *stack, SVGAllAttributes *atts) } if (atts->syncBehavior) lock_scene = (*atts->syncBehavior == SMIL_SYNCBEHAVIOR_LOCKED) ? GF_TRUE : GF_FALSE; - gf_sc_texture_play_from_to(&stack->txh, &stack->txurl, - atts->clipBegin ? (*atts->clipBegin) : 0.0, - atts->clipEnd ? (*atts->clipEnd) : -1.0, - GF_FALSE, - lock_scene); + gf_sc_texture_play_from_to(&stack->txh, &stack->txurl, + atts->clipBegin ? (*atts->clipBegin) : 0.0, + atts->clipEnd ? (*atts->clipEnd) : -1.0, + GF_FALSE, + lock_scene); } static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) @@ -260,7 +260,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) } gf_free(stack); return; - } + } /*TRAVERSE_DRAW is NEVER called in 3D mode*/ if (tr_state->traversing_mode==TRAVERSE_DRAW_2D) { @@ -280,7 +280,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) if (gf_node_dirty_get(node) & GF_SG_SVG_XLINK_HREF_DIRTY) { gf_term_get_mfurl_from_xlink(node, &stack->txurl); stack->txh.width = stack->txh.height = 0; - + /*remove associated audio if any*/ if (stack->audio) { svg_audio_smil_evaluate_ex(NULL, 0, SMIL_TIMING_EVAL_REMOVE, stack->audio, stack->txh.owner); @@ -288,7 +288,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) stack->audio = NULL; } stack->audio_dirty = GF_TRUE; - + if (stack->txurl.count) svg_play_texture(stack, &all_atts); gf_node_dirty_clear(node, GF_SG_SVG_XLINK_HREF_DIRTY); } @@ -299,8 +299,8 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) gf_node_dirty_clear(node, 0); SVG_Build_Bitmap_Graph((SVG_video_stack*)gf_node_get_private(node), tr_state); } - - } + + } if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { if (!compositor_svg_is_display_off(tr_state->svg_props)) { @@ -338,7 +338,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) gf_mx2d_copy(mx_bck, tr_state->transform); restore_mx = GF_TRUE; - + gf_mx2d_init(tr_state->transform); gf_mx2d_add_rotation(&tr_state->transform, cx, cy, angle); } @@ -353,7 +353,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) ctx->flags |= CTX_IS_TRANSPARENT; ctx->flags &= ~CTX_NO_ANTIALIAS; } - else if (ctx->aspect.fill_texture->transparent) + else if (ctx->aspect.fill_texture->transparent) ctx->flags |= CTX_IS_TRANSPARENT; else if (tr_state->svg_props->opacity && (tr_state->svg_props->opacity->type==SVG_NUMBER_VALUE) && (tr_state->svg_props->opacity->value!=FIX_ONE)) { ctx->flags = CTX_IS_TRANSPARENT; @@ -368,7 +368,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) } compositor_3d_draw_bitmap(stack->graph, &ctx->aspect, tr_state, 0, 0, FIX_ONE, FIX_ONE); ctx->drawable = NULL; - } else + } else #endif { drawable_finalize_sort(ctx, tr_state, NULL); @@ -389,7 +389,7 @@ static void svg_traverse_bitmap(GF_Node *node, void *rs, Bool is_destroy) /*********************/ static void SVG_Update_image(GF_TextureHandler *txh) -{ +{ MFURL *txurl = &(((SVG_video_stack *)gf_node_get_private(txh->owner))->txurl); /*setup texture if needed*/ @@ -437,7 +437,7 @@ static void SVG_Update_video(GF_TextureHandler *txh) { GF_FieldInfo init_vis_info; SVG_video_stack *stack = (SVG_video_stack *) gf_node_get_private(txh->owner); - + if (!txh->stream) { svg_open_texture(stack); @@ -455,10 +455,10 @@ static void SVG_Update_video(GF_TextureHandler *txh) if (init_vis == SVG_INITIALVISIBILTY_ALWAYS) { svg_play_texture((SVG_video_stack*)stack, NULL); gf_sc_invalidate(txh->compositor, NULL); - } + } } return; - } + } /*when fetching the first frame disable resync*/ gf_sc_texture_update_frame(txh, GF_FALSE); @@ -493,12 +493,12 @@ static void SVG_Update_video(GF_TextureHandler *txh) } } } - + /*we have no choice but retraversing the graph until we're inactive since the movie framerate and the compositor framerate are likely to be different */ - if (!txh->stream_finished) - if (txh->needs_refresh) - gf_sc_invalidate(txh->compositor, NULL); + if (!txh->stream_finished) + if (txh->needs_refresh) + gf_sc_invalidate(txh->compositor, NULL); if (stack->stop_requested) { stack->stop_requested = GF_FALSE; @@ -512,12 +512,12 @@ static void svg_video_smil_evaluate(SMIL_Timing_RTI *rti, Fixed normalized_scene switch (status) { case SMIL_TIMING_EVAL_UPDATE: - if (!stack->txh.is_open) { + if (!stack->txh.is_open) { if (stack->txurl.count) { svg_play_texture((SVG_video_stack*)stack, NULL); } } - else if (stack->txh.stream_finished && (gf_smil_get_media_duration(rti)<0) ) { + else if (stack->txh.stream_finished && (gf_smil_get_media_duration(rti)<0) ) { Double dur = gf_mo_get_duration(stack->txh.stream); if (dur <= 0) { dur = stack->txh.last_frame_time; @@ -614,10 +614,10 @@ static void svg_audio_smil_evaluate_ex(SMIL_Timing_RTI *rti, Fixed normalized_sc if (!audio) audio = gf_smil_get_element(rti); stack = (SVG_audio_stack *)gf_node_get_private(audio); - + switch (status) { case SMIL_TIMING_EVAL_UPDATE: - if (!stack->is_active && !stack->is_error) { + if (!stack->is_active && !stack->is_error) { if (stack->aurl.count) { SVGAllAttributes atts; Bool lock_timeline = GF_FALSE; @@ -626,9 +626,9 @@ static void svg_audio_smil_evaluate_ex(SMIL_Timing_RTI *rti, Fixed normalized_sc if (atts.syncBehavior) lock_timeline = (*atts.syncBehavior == SMIL_SYNCBEHAVIOR_LOCKED) ? GF_TRUE : GF_FALSE; if (gf_sc_audio_open(&stack->input, &stack->aurl, - atts.clipBegin ? (*atts.clipBegin) : 0.0, - atts.clipEnd ? (*atts.clipEnd) : -1.0, - lock_timeline) == GF_OK) + atts.clipBegin ? (*atts.clipBegin) : 0.0, + atts.clipEnd ? (*atts.clipEnd) : -1.0, + lock_timeline) == GF_OK) { gf_mo_set_speed(stack->input.stream, FIX_ONE); stack->is_active = GF_TRUE; @@ -637,7 +637,7 @@ static void svg_audio_smil_evaluate_ex(SMIL_Timing_RTI *rti, Fixed normalized_sc } } } - else if (!slave_audio && stack->input.stream_finished && (gf_smil_get_media_duration(rti) < 0) ) { + else if (!slave_audio && stack->input.stream_finished && (gf_smil_get_media_duration(rti) < 0) ) { Double dur = gf_mo_get_duration(stack->input.stream); if (dur <= 0) { dur = gf_mo_get_last_frame_time(stack->input.stream); @@ -647,7 +647,7 @@ static void svg_audio_smil_evaluate_ex(SMIL_Timing_RTI *rti, Fixed normalized_sc } break; case SMIL_TIMING_EVAL_REPEAT: - if (stack->is_active) + if (stack->is_active) gf_sc_audio_restart(&stack->input); break; case SMIL_TIMING_EVAL_FREEZE: @@ -704,11 +704,11 @@ static void svg_traverse_audio_ex(GF_Node *node, void *rs, Bool is_destroy, SVGP if (gf_node_dirty_get(node) & GF_SG_SVG_XLINK_HREF_DIRTY) { SVGAllAttributes atts; Bool lock_timeline = GF_FALSE; - if (stack->is_active) + if (stack->is_active) gf_sc_audio_stop(&stack->input); stack->is_error = GF_FALSE; - + gf_node_dirty_clear(node, GF_SG_SVG_XLINK_HREF_DIRTY); gf_term_get_mfurl_from_xlink(node, &(stack->aurl)); @@ -716,11 +716,11 @@ static void svg_traverse_audio_ex(GF_Node *node, void *rs, Bool is_destroy, SVGP if (atts.syncBehavior) lock_timeline = (*atts.syncBehavior == SMIL_SYNCBEHAVIOR_LOCKED) ? GF_TRUE : GF_FALSE; if (stack->aurl.count && (gf_sc_audio_open(&stack->input, &stack->aurl, - atts.clipBegin ? (*atts.clipBegin) : 0.0, - atts.clipEnd ? (*atts.clipEnd) : -1.0, - lock_timeline) == GF_OK) + atts.clipBegin ? (*atts.clipBegin) : 0.0, + atts.clipEnd ? (*atts.clipEnd) : -1.0, + lock_timeline) == GF_OK) - ) { + ) { gf_mo_set_speed(stack->input.stream, FIX_ONE); stack->is_active = GF_TRUE; } else if (stack->is_active) { @@ -732,9 +732,9 @@ static void svg_traverse_audio_ex(GF_Node *node, void *rs, Bool is_destroy, SVGP /*store mute flag*/ stack->input.is_muted = GF_FALSE; if (tr_state->switched_off - || compositor_svg_is_display_off(props) - || (*(props->visibility) == SVG_VISIBILITY_HIDDEN) ) { - + || compositor_svg_is_display_off(props) + || (*(props->visibility) == SVG_VISIBILITY_HIDDEN) ) { + stack->input.is_muted = GF_TRUE; } @@ -760,7 +760,7 @@ void compositor_init_svg_audio(GF_Compositor *compositor, GF_Node *node, Bool sl /*force first processing of xlink-href*/ gf_node_dirty_set(node, GF_SG_SVG_XLINK_HREF_DIRTY, GF_FALSE); - if (!slaved_timing) + if (!slaved_timing) gf_smil_set_evaluation_callback(node, svg_audio_smil_evaluate); gf_node_set_private(node, stack); @@ -798,11 +798,11 @@ static void svg_updates_smil_evaluate(SMIL_Timing_RTI *rti, Fixed normalized_sce switch (status) { case SMIL_TIMING_EVAL_UPDATE: - if (!stack->is_open) { + if (!stack->is_open) { if (stack->resource ) gf_mo_play(stack->resource, stack->clipBegin, stack->clipEnd, GF_FALSE); stack->is_open = GF_TRUE; } - else if (gf_mo_is_done(stack->resource) && (gf_smil_get_media_duration(rti)<0) ) { + else if (gf_mo_is_done(stack->resource) && (gf_smil_get_media_duration(rti)<0) ) { Double dur = gf_mo_get_duration(stack->resource); gf_smil_set_media_duration(rti, dur); } @@ -838,7 +838,7 @@ static void svg_traverse_updates(GF_Node *node, void *rs, Bool is_destroy) } gf_free(stack); return; - } + } if (tr_state->traversing_mode!=TRAVERSE_SORT) return; @@ -864,7 +864,7 @@ static void svg_traverse_updates(GF_Node *node, void *rs, Bool is_destroy) new_res = gf_mo_register(node, &url, lock_timeline, GF_FALSE); gf_sg_mfurl_del(url); - + if (stack->resource!=new_res) { if (stack->resource) { gf_mo_stop(stack->resource); diff --git a/src/compositor/svg_paint_servers.c b/src/compositor/svg_paint_servers.c index fa71565..a81e620 100644 --- a/src/compositor/svg_paint_servers.c +++ b/src/compositor/svg_paint_servers.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -125,16 +125,16 @@ static void svg_gradient_traverse(GF_Node *node, GF_TraverseState *tr_state, Boo compositor_svg_traverse_base(node, &all_atts, tr_state, &backup_props_1, &backup_flags_1); if (real_traverse && - ! (tr_state->svg_flags & (GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY|GF_SG_SVG_COLOR_DIRTY)) - && !gf_node_dirty_get(node) - && !st->txh.needs_refresh) + ! (tr_state->svg_flags & (GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY|GF_SG_SVG_COLOR_DIRTY)) + && !gf_node_dirty_get(node) + && !st->txh.needs_refresh) { memcpy(tr_state->svg_props, &backup_props_1, sizeof(SVGPropertiesPointers)); tr_state->svg_flags = backup_flags_1; return; } - /*for gradients we must traverse the gradient stops to trigger animations, even if the + /*for gradients we must traverse the gradient stops to trigger animations, even if the gradient is not marked as dirty*/ all_dirty = tr_state->svg_flags & (GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY|GF_SG_SVG_COLOR_DIRTY); is_dirty = 0; @@ -195,7 +195,7 @@ static void svg_gradient_traverse(GF_Node *node, GF_TraverseState *tr_state, Boo if (all_atts.offset) { key = all_atts.offset->value; - if (all_atts.offset->type==SVG_NUMBER_PERCENTAGE) key/=100; + if (all_atts.offset->type==SVG_NUMBER_PERCENTAGE) key/=100; } else { key=0; } @@ -356,7 +356,7 @@ void compositor_svg_build_gradient_texture(GF_TextureHandler *txh) if (!(txh->flags & GF_SR_TEXTURE_GRAD_REGISTERED)) { txh->flags |= GF_SR_TEXTURE_GRAD_REGISTERED; - if (gf_list_find(txh->compositor->textures, txh)<0) + if (gf_list_find(txh->compositor->textures, txh)<0) gf_list_insert(txh->compositor->textures, txh, 0); } @@ -366,7 +366,7 @@ void compositor_svg_build_gradient_texture(GF_TextureHandler *txh) } stencil = gf_sc_texture_get_stencil(txh); if (!stencil) return; - + /*init our 2D graphics stuff*/ texture2D = raster->stencil_new(raster, GF_STENCIL_TEXTURE); if (!texture2D) return; @@ -378,7 +378,7 @@ void compositor_svg_build_gradient_texture(GF_TextureHandler *txh) transparent = st->txh.transparent; if (st->txh.flags & GF_SR_TEXTURE_GRAD_NO_RGB) transparent = 1; - + if (transparent) { if (!txh->data) { txh->data = (char *) gf_malloc(sizeof(char)*GRAD_TEXTURE_SIZE*GRAD_TEXTURE_SIZE*4); @@ -517,7 +517,7 @@ static void SVG_LG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat /*gradient is a texture, only update the bounds*/ if (for_3d) { GF_Rect rc; - if (!all_atts.gradientUnits || (*(SVG_GradientUnit*)all_atts.gradientUnits==SVG_GRADIENTUNITS_OBJECT)) + if (!all_atts.gradientUnits || (*(SVG_GradientUnit*)all_atts.gradientUnits==SVG_GRADIENTUNITS_OBJECT)) return; /*get gradient bounds in local coord system*/ @@ -527,7 +527,7 @@ static void SVG_LG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat return; } - if (all_atts.gradientTransform) + if (all_atts.gradientTransform) gf_mx2d_copy(*mat, all_atts.gradientTransform->mat ); if (all_atts.x1) { @@ -572,7 +572,7 @@ void compositor_init_svg_linearGradient(GF_Compositor *compositor, GF_Node *node GF_SAFEALLOC(st, SVG_GradientStack); /*!!! Gradients are textures but are not registered as textures with the compositor in order to avoid updating - too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order + too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order to release associated HW resource when no longer used*/ st->txh.owner = node; st->txh.compositor = compositor; @@ -622,7 +622,7 @@ static void SVG_RG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat /*gradient is a texture, only update the bounds*/ if (for_3d && bounds) { GF_Rect rc; - if (!all_atts.gradientUnits || (*(SVG_GradientUnit*)all_atts.gradientUnits==SVG_GRADIENTUNITS_OBJECT)) + if (!all_atts.gradientUnits || (*(SVG_GradientUnit*)all_atts.gradientUnits==SVG_GRADIENTUNITS_OBJECT)) return; /*get gradient bounds in local coord system*/ @@ -634,9 +634,9 @@ static void SVG_RG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat return; } - if (all_atts.gradientTransform) + if (all_atts.gradientTransform) gf_mx2d_copy(*mat, all_atts.gradientTransform->mat); - + if (all_atts.r) { radius = all_atts.r->value; if (all_atts.r->type==SVG_NUMBER_PERCENTAGE) radius /= 100; @@ -673,8 +673,8 @@ static void SVG_RG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat /* clamping fx/fy according to: http://www.w3.org/TR/SVG11/pservers.html#RadialGradients - If the point defined by ‘fxÂ’ and ‘fyÂ’ lies outside the circle defined by ‘cxÂ’, ‘cyÂ’ and ‘rÂ’, - then the user agent shall set the focal point to the intersection of the line from (‘cxÂ’, ‘cyÂ’) + If the point defined by ‘fxÂ’ and ‘fyÂ’ lies outside the circle defined by ‘cxÂ’, ‘cyÂ’ and ‘rÂ’, + then the user agent shall set the focal point to the intersection of the line from (‘cxÂ’, ‘cyÂ’) to (‘fxÂ’, ‘fyÂ’) with the circle defined by ‘cxÂ’, ‘cyÂ’ and ‘rÂ’.*/ { Fixed norm = gf_v2d_distance(&focal, ¢er); @@ -690,7 +690,7 @@ static void SVG_RG_ComputeMatrix(GF_TextureHandler *txh, GF_Rect *bounds, GF_Mat /*move to local coord system - cf SVG spec*/ gf_mx2d_add_scale(mat, bounds->width, bounds->height); gf_mx2d_add_translation(mat, bounds->x, bounds->y - bounds->height); - } + } txh->compositor->rasterizer->stencil_set_radial_gradient(stencil, center.x, center.y, focal.x, focal.y, radius, radius); } @@ -700,7 +700,7 @@ void compositor_init_svg_radialGradient(GF_Compositor *compositor, GF_Node *node GF_SAFEALLOC(st, SVG_GradientStack); /*!!! Gradients are textures but are not registered as textures with the compositor in order to avoid updating - too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order + too many textures each frame - gradients are only registered with the compositor when they are used in OpenGL, in order to release associated HW resource when no longer used*/ st->txh.owner = node; st->txh.compositor = compositor; @@ -730,7 +730,7 @@ static void svg_traverse_PaintServer(GF_Node *node, void *rs, Bool is_destroy, B gf_svg_flatten_attributes(elt, &all_atts); compositor_svg_traverse_base(node, &all_atts, tr_state, &backup_props, &backup_flags); - + if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { return; } else { diff --git a/src/compositor/svg_text.c b/src/compositor/svg_text.c index dae5a15..fa6029f 100644 --- a/src/compositor/svg_text.c +++ b/src/compositor/svg_text.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Cyril Concolato + * Authors: Cyril Concolato * Copyright (c) Telecom ParisTech 2004-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -30,7 +30,7 @@ #include "visual_manager.h" #include "nodes_stacks.h" -typedef struct +typedef struct { Drawable *drawable; Fixed prev_size; @@ -71,16 +71,16 @@ static void svg_finalize_sort(DrawableContext *ctx, SVG_TextStack *st, GF_Traver drawable_check_focus_highlight(ctx->drawable->node, tr_state, &st->bounds); ctx->drawable = NULL; return; - } + } #endif /*if text selection mode, we must force redraw of the entire text span because we don't if glyphs have been (un)selected*/ - if (!tr_state->immediate_draw && - /*text selection on*/ - (tr_state->visual->compositor->text_selection - /*text sel release*/ - || (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED)) - ) { + if (!tr_state->immediate_draw && + /*text selection on*/ + (tr_state->visual->compositor->text_selection + /*text sel release*/ + || (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED)) + ) { GF_TextSpan *span; u32 i = 0; Bool unselect = (tr_state->visual->compositor->store_text_state==GF_SC_TSEL_RELEASED) ? 1 : 0; @@ -106,23 +106,49 @@ static u32 svg_get_font_styles(GF_TraverseState * tr_state) styles = GF_FONT_OBLIQUE; break; } - if (*tr_state->svg_props->font_variant==SVG_FONTVARIANT_SMALLCAPS) + if (*tr_state->svg_props->font_variant==SVG_FONTVARIANT_SMALLCAPS) styles |= GF_FONT_SMALLCAPS; switch(*tr_state->svg_props->font_weight) { - case SVG_FONTWEIGHT_100: styles |= GF_FONT_WEIGHT_100; break; - case SVG_FONTWEIGHT_LIGHTER: styles |= GF_FONT_WEIGHT_LIGHTER; break; - case SVG_FONTWEIGHT_200: styles |= GF_FONT_WEIGHT_200; break; - case SVG_FONTWEIGHT_300: styles |= GF_FONT_WEIGHT_300; break; - case SVG_FONTWEIGHT_400: styles |= GF_FONT_WEIGHT_400; break; - case SVG_FONTWEIGHT_NORMAL: styles |= GF_FONT_WEIGHT_NORMAL; break; - case SVG_FONTWEIGHT_500: styles |= GF_FONT_WEIGHT_500; break; - case SVG_FONTWEIGHT_600: styles |= GF_FONT_WEIGHT_600; break; - case SVG_FONTWEIGHT_700: styles |= GF_FONT_WEIGHT_700; break; - case SVG_FONTWEIGHT_BOLD: styles |= GF_FONT_WEIGHT_BOLD; break; - case SVG_FONTWEIGHT_800: styles |= GF_FONT_WEIGHT_800; break; - case SVG_FONTWEIGHT_900: styles |= GF_FONT_WEIGHT_900; break; - case SVG_FONTWEIGHT_BOLDER: styles |= GF_FONT_WEIGHT_BOLDER; break; + case SVG_FONTWEIGHT_100: + styles |= GF_FONT_WEIGHT_100; + break; + case SVG_FONTWEIGHT_LIGHTER: + styles |= GF_FONT_WEIGHT_LIGHTER; + break; + case SVG_FONTWEIGHT_200: + styles |= GF_FONT_WEIGHT_200; + break; + case SVG_FONTWEIGHT_300: + styles |= GF_FONT_WEIGHT_300; + break; + case SVG_FONTWEIGHT_400: + styles |= GF_FONT_WEIGHT_400; + break; + case SVG_FONTWEIGHT_NORMAL: + styles |= GF_FONT_WEIGHT_NORMAL; + break; + case SVG_FONTWEIGHT_500: + styles |= GF_FONT_WEIGHT_500; + break; + case SVG_FONTWEIGHT_600: + styles |= GF_FONT_WEIGHT_600; + break; + case SVG_FONTWEIGHT_700: + styles |= GF_FONT_WEIGHT_700; + break; + case SVG_FONTWEIGHT_BOLD: + styles |= GF_FONT_WEIGHT_BOLD; + break; + case SVG_FONTWEIGHT_800: + styles |= GF_FONT_WEIGHT_800; + break; + case SVG_FONTWEIGHT_900: + styles |= GF_FONT_WEIGHT_900; + break; + case SVG_FONTWEIGHT_BOLDER: + styles |= GF_FONT_WEIGHT_BOLDER; + break; } return styles; @@ -159,7 +185,7 @@ GF_Font *gf_compositor_svg_set_font(GF_FontManager *fm, char *a_font, u32 styles nb_fonts++; if (skip) a_font[len-skip] = ' '; } - + if (sep) { sep[0] = ','; a_font = sep+1; @@ -208,7 +234,7 @@ static void svg_apply_text_anchor(GF_TraverseState * tr_state, Fixed *width) } } -static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed font_size, Bool x_offsets, Bool y_offsets, Bool rotate, SVGAllAttributes *atts, char *textContent, const char *lang, GF_TraverseState *tr_state) +static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed font_size, Bool x_offsets, Bool y_offsets, Bool rotate, SVGAllAttributes *atts, char *textContent, const char *lang, GF_TraverseState *tr_state) { GF_TextSpan *span = NULL; char *dup_text; @@ -219,7 +245,7 @@ static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed f len = (u32) strlen(textContent); dup_text = gf_malloc(len+1); - + switch (tr_state->last_char_type) { case 2: prev = 0; @@ -232,7 +258,7 @@ static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed f } for (i = 0, j = 0; i < len; i++) { if (textContent[i] == ' ') { - if (prev == ' ' && !preserve) { + if (prev == ' ' && !preserve) { /* ignore space */ } else { dup_text[j] = textContent[i]; @@ -240,7 +266,7 @@ static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed f j++; } } else if (textContent[i] == '\t') { - if (prev == ' ' && !preserve) { + if (prev == ' ' && !preserve) { /* ignore space */ } else { dup_text[j] = ' '; @@ -248,9 +274,9 @@ static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed f j++; } } else if ((textContent[i] == '\n') || - (textContent[i] == '\r') - ) { - if (prev == ' ' && preserve) { + (textContent[i] == '\r') + ) { + if (prev == ' ' && preserve) { dup_text[j] = ' '; prev = dup_text[j]; j++; @@ -259,9 +285,9 @@ static GF_TextSpan *svg_get_text_span(GF_FontManager *fm, GF_Font *font, Fixed f j++; } } else if ( - (((u8) textContent[i] == 0xc2) && ((u8) textContent[i+1] == 0xa0)) + (((u8) textContent[i] == 0xc2) && ((u8) textContent[i+1] == 0xa0)) ) { - if (prev == ' ' && !preserve) { + if (prev == ' ' && !preserve) { /* ignore space */ } else { dup_text[j] = ' '; @@ -339,7 +365,7 @@ static void svg_text_area_queue_state(GF_TraverseState *tr_state, GF_TextSpan *s st->last_glyph = last_glyph; return; } - } + } st = gf_malloc(sizeof(textArea_state)); st->first_glyph = first_glyph; st->last_glyph = last_glyph; @@ -394,7 +420,7 @@ static void svg_traverse_dom_text_area(GF_Node *node, SVGAllAttributes *atts, GF tr_state->line_spacing = gf_mulfix(span->font_size, FLT2FIX(1.0) ); } tr_state->text_end_y += tr_state->line_spacing; - } + } line_spacing = gf_mulfix(span->font_size, FLT2FIX(1.0) ); @@ -428,7 +454,7 @@ static void svg_traverse_dom_text_area(GF_Node *node, SVGAllAttributes *atts, GF word_size += font->max_advance_h * span->font_scale; } i++; - } + } /* word doesn't fit on line, escape*/ if (!word_size && !last_char_size) break; @@ -503,8 +529,8 @@ static void get_domtext_width(GF_Node *node, SVGAllAttributes *atts, GF_Traverse i=0; //count_x, _y: number of x- (y-) position of characters to come in the text flow while ( (inb_glyphs) - && ( (tr_state->count_x>1) || (tr_state->count_y>1) ) - ) { + && ( (tr_state->count_x>1) || (tr_state->count_y>1) ) + ) { block_width = (span->glyphs[i] ? span->glyphs[i]->horiz_advance : font->max_advance_h) * span->font_scale; //store width in tr_state->x_anchors @@ -528,7 +554,7 @@ static void get_domtext_width(GF_Node *node, SVGAllAttributes *atts, GF_Traverse } //if last indicated position, create a new item if ((tr_state->count_x==1)||(tr_state->count_y==1) - || !gf_list_count(tr_state->x_anchors) ) { + || !gf_list_count(tr_state->x_anchors) ) { entry = (Fixed*)gf_malloc(sizeof(Fixed)); *entry = block_width; @@ -564,10 +590,10 @@ static void get_tspan_width(GF_Node *node, void *rs) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_DOMText: - get_domtext_width(child->node, &atts, tr_state); + get_domtext_width(child->node, &atts, tr_state); break; case TAG_SVG_tspan: - get_tspan_width(child->node, tr_state); + get_tspan_width(child->node, tr_state); break; default: break; @@ -615,12 +641,12 @@ void svg_traverse_domtext(GF_Node *node, SVGAllAttributes *atts, GF_TraverseStat i=0; /* - if character position is given in (x, y) attributes, use it. + if character position is given in (x, y) attributes, use it. Otherwise add text at tr_state->text_end_x. - */ + */ while ((inb_glyphs) - && ( (tr_state->count_x>1) || (tr_state->count_y>1) ) - ) { + && ( (tr_state->count_x>1) || (tr_state->count_y>1) ) + ) { //get x and y positions if (tr_state->count_x==0) { x = tr_state->text_end_x; @@ -636,7 +662,7 @@ void svg_traverse_domtext(GF_Node *node, SVGAllAttributes *atts, GF_TraverseStat y = yc->value; (tr_state->count_y)--; } - + /*apply x-anchor*/ ptr = (Fixed *)gf_list_get(tr_state->x_anchors, tr_state->chunk_index); @@ -716,10 +742,10 @@ static void svg_compute_text_width(GF_Node *node, SVGAllAttributes *atts, GF_Tra /*compute length of all text blocks*/ switch (gf_node_get_tag(node)) { case TAG_DOMText: - get_domtext_width(node, atts, tr_state); + get_domtext_width(node, atts, tr_state); break; case TAG_SVG_tspan: - get_tspan_width(node, tr_state); + get_tspan_width(node, tr_state); break; case TAG_SVG_switch: is_switch = 1; @@ -750,12 +776,12 @@ static void svg_traverse_text_block(GF_Node *node, SVGAllAttributes *atts, GF_Tr Bool is_switch = 0; switch (gf_node_get_tag(node)) { case TAG_DOMText: - svg_traverse_domtext(node, atts, tr_state, spans, NULL); + svg_traverse_domtext(node, atts, tr_state, spans, NULL); break; case TAG_SVG_tspan: /*mark tspan as dirty to force rebuild*/ gf_node_dirty_set(node, 0, 0); - gf_node_traverse(node, tr_state); + gf_node_traverse(node, tr_state); break; case TAG_SVG_switch: is_switch = 1; @@ -770,7 +796,7 @@ static void svg_traverse_text_block(GF_Node *node, SVGAllAttributes *atts, GF_Tr break; } } else if (gf_node_get_tag(child->node)==TAG_DOMText) { - svg_traverse_domtext(child->node, atts, tr_state, spans, node); + svg_traverse_domtext(child->node, atts, tr_state, spans, node); } child = child->next; } @@ -839,7 +865,7 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -857,7 +883,7 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) if (tr_state->traversing_mode==TRAVERSE_PICK) { compositor_svg_apply_local_transformation(tr_state, &atts, &backup_matrix, &mx3d); - if (*tr_state->svg_props->pointer_events!=SVG_POINTEREVENTS_NONE) + if (*tr_state->svg_props->pointer_events!=SVG_POINTEREVENTS_NONE) gf_font_spans_pick(node, st->spans, tr_state, &st->bounds, 1, st->drawable); /*and browse children*/ @@ -865,7 +891,7 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -888,12 +914,12 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) compositor_svg_apply_local_transformation(tr_state, &atts, &backup_matrix, &mx3d); - if ( (st->prev_size != tr_state->svg_props->font_size->value) || - (st->prev_flags != *tr_state->svg_props->font_style) || - (st->prev_anchor != *tr_state->svg_props->text_anchor) || - (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) - || tr_state->visual->compositor->reset_fonts - ) { + if ( (st->prev_size != tr_state->svg_props->font_size->value) || + (st->prev_flags != *tr_state->svg_props->font_style) || + (st->prev_anchor != *tr_state->svg_props->text_anchor) || + (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) + || tr_state->visual->compositor->reset_fonts + ) { u32 mode; child = ((GF_ParentNode *) text)->children; @@ -922,7 +948,7 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) /*apply justification of all blocks*/ imax=gf_list_count(tr_state->x_anchors); - for (i=0;ix_anchors, i); svg_apply_text_anchor(tr_state, lw); } @@ -938,11 +964,11 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) tr_state->chunk_index = 0; /*initialize current text position*/ - if (!tr_state->text_end_x){ + if (!tr_state->text_end_x) { SVG_Coordinate *xc = (atts.text_x ? (SVG_Coordinate *) gf_list_get(*atts.text_x, 0) : NULL); tr_state->text_end_x = (xc ? xc->value : 0); } - if (!tr_state->text_end_y){ + if (!tr_state->text_end_y) { SVG_Coordinate *yc = (atts.text_y ? (SVG_Coordinate *) gf_list_get(*atts.text_y, 0) : NULL); tr_state->text_end_y = (yc ? yc->value : 0); } @@ -951,9 +977,9 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) tr_state->text_x = atts.text_x; tr_state->text_y = atts.text_y; tr_state->text_rotate = atts.text_rotate; - + drawable_reset_path(st->drawable); - + /*switch to bounds mode, and recompute children*/ mode = tr_state->traversing_mode; tr_state->traversing_mode = TRAVERSE_GET_BOUNDS; @@ -978,18 +1004,18 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) } gf_list_del(tr_state->x_anchors); tr_state->x_anchors = NULL; - + svg_update_bounds(st); - } + } if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { if (!compositor_svg_is_display_off(tr_state->svg_props)) tr_state->bounds = st->bounds; - } else if ((tr_state->traversing_mode == TRAVERSE_SORT) - && !compositor_svg_is_display_off(tr_state->svg_props) - && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) - ) { + } else if ((tr_state->traversing_mode == TRAVERSE_SORT) + && !compositor_svg_is_display_off(tr_state->svg_props) + && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) + ) { ctx = drawable_init_context_svg(st->drawable, tr_state); if (ctx) svg_finalize_sort(ctx, st, tr_state); @@ -998,10 +1024,10 @@ static void svg_traverse_text(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; case TAG_SVG_switch: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -1030,7 +1056,7 @@ void compositor_init_svg_text(GF_Compositor *compositor, GF_Node *node) static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) -{ +{ SVGPropertiesPointers backup_props; u32 backup_flags; GF_Matrix2D backup_matrix; @@ -1060,7 +1086,7 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -1075,7 +1101,7 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) return; if (tr_state->traversing_mode==TRAVERSE_PICK) { - if (*tr_state->svg_props->pointer_events!=SVG_POINTEREVENTS_NONE) + if (*tr_state->svg_props->pointer_events!=SVG_POINTEREVENTS_NONE) gf_font_spans_pick(node, st->spans, tr_state, &st->bounds, 1, st->drawable); /*and browse children*/ @@ -1083,7 +1109,7 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -1092,18 +1118,18 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) tr_state->svg_flags = backup_flags; return; } - + compositor_svg_apply_local_transformation(tr_state, &atts, &backup_matrix, &mx3d); - if ( (st->prev_size != tr_state->svg_props->font_size->value) || - (st->prev_flags != *tr_state->svg_props->font_style) || - (st->prev_anchor != *tr_state->svg_props->text_anchor) || - (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) - ) { + if ( (st->prev_size != tr_state->svg_props->font_size->value) || + (st->prev_flags != *tr_state->svg_props->font_style) || + (st->prev_anchor != *tr_state->svg_props->text_anchor) || + (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) + ) { u32 mode; - + /*tspan has been modified in the SORT stage, which means that an anim local to tspan has modified the node. - The result of the parent (text, textArea) will thus be wrong if we try to update the tspan. We therefore + The result of the parent (text, textArea) will thus be wrong if we try to update the tspan. We therefore keep the previous computed drawable, and invalidate the parent for next frame*/ if (tr_state->traversing_mode==TRAVERSE_SORT) { gf_node_dirty_set(node, 0, 1); @@ -1120,16 +1146,16 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) while (child) { switch (gf_node_get_tag(child->node)) { case TAG_DOMText: - svg_traverse_domtext(child->node, &atts, tr_state, st->spans, NULL); + svg_traverse_domtext(child->node, &atts, tr_state, st->spans, NULL); break; case TAG_SVG_tspan: gf_node_dirty_set(child->node, 0, 0); - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; case TAG_SVG_switch: case TAG_SVG_a: case TAG_SVG_tbreak: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; @@ -1144,12 +1170,12 @@ static void svg_traverse_tspan(GF_Node *node, void *rs, Bool is_destroy) st->prev_anchor = *tr_state->svg_props->text_anchor; svg_update_bounds(st); - } + } skip_changes: if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { if (tr_state->refresh_children_bounds) { - if (tr_state->base_shift) + if (tr_state->base_shift) svg_text_area_shift_bounds(st, tr_state); else svg_update_bounds(st); @@ -1159,7 +1185,7 @@ skip_changes: case TAG_SVG_tspan: case TAG_SVG_switch: case TAG_SVG_a: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; @@ -1170,14 +1196,14 @@ skip_changes: if (!compositor_svg_is_display_off(tr_state->svg_props)) tr_state->bounds = st->bounds; - } + } else if ( - (tr_state->traversing_mode == TRAVERSE_SORT) - && !compositor_svg_is_display_off(tr_state->svg_props) - && ( *(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) + (tr_state->traversing_mode == TRAVERSE_SORT) + && !compositor_svg_is_display_off(tr_state->svg_props) + && ( *(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) ) { child = ((GF_ParentNode *) tspan)->children; - + ctx = drawable_init_context_svg(st->drawable, tr_state); if (ctx) svg_finalize_sort(ctx, st, tr_state); @@ -1186,7 +1212,7 @@ skip_changes: case TAG_SVG_tspan: case TAG_SVG_switch: case TAG_SVG_a: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; @@ -1214,7 +1240,7 @@ void compositor_init_svg_tspan(GF_Compositor *compositor, GF_Node *node) static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) -{ +{ SVGPropertiesPointers backup_props; u32 backup_flags; GF_Matrix mx3d; @@ -1247,7 +1273,7 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) switch (gf_node_get_tag(child->node)) { case TAG_SVG_tspan: case TAG_SVG_a: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; } child = child->next; @@ -1283,15 +1309,15 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) tr_state->text_parent = NULL; return; } - + compositor_svg_apply_local_transformation(tr_state, &atts, &backup_matrix, &mx3d); - if ( (st->prev_size != tr_state->svg_props->font_size->value) || - (st->prev_flags != *tr_state->svg_props->font_style) || - (st->prev_anchor != *tr_state->svg_props->text_anchor) || - (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) - || tr_state->visual->compositor->reset_fonts - ) { + if ( (st->prev_size != tr_state->svg_props->font_size->value) || + (st->prev_flags != *tr_state->svg_props->font_style) || + (st->prev_anchor != *tr_state->svg_props->text_anchor) || + (gf_node_dirty_get(node) & (GF_SG_SVG_GEOMETRY_DIRTY | GF_SG_CHILD_DIRTY) ) + || tr_state->visual->compositor->reset_fonts + ) { u32 mode; child = ((GF_ParentNode *) text)->children; @@ -1329,17 +1355,17 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) c++; switch (gf_node_get_tag(child->node)) { case TAG_DOMText: - svg_traverse_dom_text_area(child->node, &atts, tr_state, st->spans); + svg_traverse_dom_text_area(child->node, &atts, tr_state, st->spans); break; case TAG_SVG_tspan: /*mark tspan as dirty to force rebuild*/ gf_node_dirty_set(child->node, 0, 0); - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; case TAG_SVG_switch: case TAG_SVG_a: case TAG_SVG_tbreak: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; @@ -1382,7 +1408,7 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) tr_state->base_shift = remain; svg_text_area_shift_bounds(st, tr_state); } - } + } if (refresh_to_idx) { tr_state->refresh_children_bounds=1; @@ -1395,7 +1421,7 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) case TAG_SVG_tspan: case TAG_SVG_switch: case TAG_SVG_a: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; @@ -1410,19 +1436,19 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) tr_state->refresh_children_bounds = prev_refresh; } svg_update_bounds(st); - } - + } + if (tr_state->traversing_mode == TRAVERSE_GET_BOUNDS) { if (!compositor_svg_is_display_off(tr_state->svg_props)) tr_state->bounds = st->bounds; - } else if ( (tr_state->traversing_mode == TRAVERSE_SORT) - && !compositor_svg_is_display_off(tr_state->svg_props) - && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) - ) { + } else if ( (tr_state->traversing_mode == TRAVERSE_SORT) + && !compositor_svg_is_display_off(tr_state->svg_props) + && (*(tr_state->svg_props->visibility) != SVG_VISIBILITY_HIDDEN) + ) { ctx = drawable_init_context_svg(st->drawable, tr_state); if (ctx) svg_finalize_sort(ctx, st, tr_state); - + child = ((GF_ParentNode *) text)->children; while (child) { switch (gf_node_get_tag(child->node)) { @@ -1431,7 +1457,7 @@ static void svg_traverse_textArea(GF_Node *node, void *rs, Bool is_destroy) case TAG_SVG_tspan: case TAG_SVG_switch: case TAG_SVG_a: - gf_node_traverse(child->node, tr_state); + gf_node_traverse(child->node, tr_state); break; default: break; diff --git a/src/compositor/texturing.c b/src/compositor/texturing.c index d207647..ecf7519 100644 --- a/src/compositor/texturing.c +++ b/src/compositor/texturing.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ void gf_sc_texture_setup(GF_TextureHandler *txh, GF_Compositor *compositor, GF_N txh->owner = owner; txh->compositor = compositor; /*insert texture in reverse order, so that textures in sub documents/scenes are updated before parent ones*/ - if (gf_list_find(compositor->textures, txh)<0) + if (gf_list_find(compositor->textures, txh)<0) gf_list_insert(compositor->textures, txh, 0); if (!txh->update_texture_fcnt) txh->update_texture_fcnt = update_texture_void; } @@ -149,12 +149,12 @@ void gf_sc_texture_restart(GF_TextureHandler *txh) static void setup_texture_object(GF_TextureHandler *txh, Bool private_media) { if (!txh->tx_io) { - gf_sc_texture_allocate(txh); + gf_sc_texture_allocate(txh); if (!txh->tx_io) return; gf_mo_get_visual_info(txh->stream, &txh->width, &txh->height, &txh->stride, &txh->pixel_ar, &txh->pixelformat, &txh->is_flipped); - - if (private_media) { + + if (private_media) { txh->transparent = 1; txh->pixelformat = GF_PIXEL_ARGB; txh->flags |= GF_SR_TEXTURE_PRIVATE_MEDIA; @@ -241,7 +241,7 @@ void gf_sc_texture_update_frame(GF_TextureHandler *txh, Bool disable_resync) } return; } - txh->needs_release = 1; + txh->needs_release = 1; txh->last_frame_time = ts; if (txh->raw_memory) { gf_mo_get_raw_image_planes(txh->stream, (u8 **) &txh->data, (u8 **) &txh->pU, (u8 **) &txh->pV); @@ -289,17 +289,19 @@ GF_TextureHandler *gf_sc_texture_get_handler(GF_Node *n) if (!n) return NULL; switch (gf_node_get_tag(n)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_ImageTexture: - case TAG_MPEG4_CacheTexture: + case TAG_MPEG4_ImageTexture: + case TAG_MPEG4_CacheTexture: return it_get_texture(n); - case TAG_MPEG4_MovieTexture: return mt_get_texture(n); - case TAG_MPEG4_PixelTexture: return pt_get_texture(n); + case TAG_MPEG4_MovieTexture: + return mt_get_texture(n); + case TAG_MPEG4_PixelTexture: + return pt_get_texture(n); - case TAG_MPEG4_CompositeTexture2D: - case TAG_MPEG4_CompositeTexture3D: + case TAG_MPEG4_CompositeTexture2D: + case TAG_MPEG4_CompositeTexture3D: return compositor_get_composite_texture(n); - case TAG_MPEG4_LinearGradient: - case TAG_MPEG4_RadialGradient: + case TAG_MPEG4_LinearGradient: + case TAG_MPEG4_RadialGradient: return compositor_mpeg4_get_gradient_texture(n); case TAG_MPEG4_MatteTexture: @@ -311,21 +313,25 @@ GF_TextureHandler *gf_sc_texture_get_handler(GF_Node *n) #endif /*GPAC_DISABLE_VRML*/ #ifndef GPAC_DISABLE_X3D - case TAG_X3D_ImageTexture: return it_get_texture(n); - case TAG_X3D_MovieTexture: return mt_get_texture(n); - case TAG_X3D_PixelTexture: return pt_get_texture(n); + case TAG_X3D_ImageTexture: + return it_get_texture(n); + case TAG_X3D_MovieTexture: + return mt_get_texture(n); + case TAG_X3D_PixelTexture: + return pt_get_texture(n); #endif #ifndef GPAC_DISABLE_SVG - case TAG_SVG_linearGradient: - case TAG_SVG_radialGradient: + case TAG_SVG_linearGradient: + case TAG_SVG_radialGradient: return compositor_svg_get_gradient_texture(n); case TAG_SVG_image: case TAG_SVG_video: return compositor_svg_get_image_texture(n); #endif - default: return NULL; + default: + return NULL; } } diff --git a/src/compositor/texturing.h b/src/compositor/texturing.h index ab6a618..f4bf1f8 100644 --- a/src/compositor/texturing.h +++ b/src/compositor/texturing.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/src/compositor/texturing_gl.c b/src/compositor/texturing_gl.c index b7189ff..402a979 100644 --- a/src/compositor/texturing_gl.c +++ b/src/compositor/texturing_gl.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -96,7 +96,7 @@ struct __texture_wrapper #ifdef GF_SR_USE_DEPTH char *depth_data; #endif - + }; GF_Err gf_sc_texture_allocate(GF_TextureHandler *txh) @@ -298,7 +298,7 @@ void gf_sc_texture_disable(GF_TextureHandler *txh) { if (txh && txh->tx_io) { -#ifndef GPAC_USE_OGL_ES +#ifndef GPAC_USE_OGL_ES if (txh->tx_io->yuv_shader) { glUseProgram(0); txh->compositor->visual->current_texture_glsl_program = 0; @@ -357,9 +357,9 @@ static Bool tx_setup_format(GF_TextureHandler *txh) Bool is_pow2, use_rect, flip, use_yuv_shaders; GF_Compositor *compositor = (GF_Compositor *)txh->compositor; - /*first setup, this will force recompute bounds in case used with bitmap - we could refine and only + /*first setup, this will force recompute bounds in case used with bitmap - we could refine and only invalidate for bitmaps only*/ - if (txh->owner && (!txh->tx_io->rescale_width || !txh->tx_io->rescale_height)) + if (txh->owner && (!txh->tx_io->rescale_width || !txh->tx_io->rescale_height)) gf_node_dirty_set(txh->owner, 0, 1); txh->tx_io->rescale_width = gf_get_next_pow2(txh->width); @@ -402,16 +402,16 @@ static Bool tx_setup_format(GF_TextureHandler *txh) txh->tx_io->gl_format = GL_RGB; txh->tx_io->nb_comp = 3; break; - case GF_PIXEL_BGR_32: - txh->tx_io->gl_format = GL_RGBA; - txh->tx_io->nb_comp = 4; - break; + case GF_PIXEL_BGR_32: + txh->tx_io->gl_format = GL_RGBA; + txh->tx_io->nb_comp = 4; + break; case GF_PIXEL_RGB_32: case GF_PIXEL_RGBA: txh->tx_io->gl_format = GL_RGBA; txh->tx_io->nb_comp = 4; break; -#ifndef GPAC_USE_OGL_ES +#ifndef GPAC_USE_OGL_ES case GF_PIXEL_ARGB: if (!compositor->gl_caps.bgra_texture) return 0; txh->tx_io->gl_format = GL_BGRA_EXT; @@ -421,18 +421,18 @@ static Bool tx_setup_format(GF_TextureHandler *txh) case GF_PIXEL_YV12: case GF_PIXEL_YV12_10: case GF_PIXEL_NV21: -#ifndef GPAC_USE_OGL_ES - if (compositor->gl_caps.has_shaders && (is_pow2 || compositor->visual->yuv_rect_glsl_program) ) { - use_yuv_shaders = 1; - break; - } else if (!compositor->disable_yuvgl && compositor->gl_caps.yuv_texture && !(txh->tx_io->flags & TX_MUST_SCALE) ) { +#ifndef GPAC_USE_OGL_ES + if (compositor->gl_caps.has_shaders && (is_pow2 || compositor->visual->yuv_rect_glsl_program) ) { + use_yuv_shaders = 1; + break; + } else if (!compositor->disable_yuvgl && compositor->gl_caps.yuv_texture && !(txh->tx_io->flags & TX_MUST_SCALE) ) { txh->tx_io->gl_format = compositor->gl_caps.yuv_texture; txh->tx_io->nb_comp = 3; txh->tx_io->gl_dtype = UNSIGNED_SHORT_8_8_MESA; break; } #endif - //fallthrough + //fallthrough case GF_PIXEL_YUY2: case GF_PIXEL_YUVD: if (compositor->gl_caps.has_shaders && (is_pow2 || compositor->visual->yuv_rect_glsl_program) ) { @@ -473,7 +473,7 @@ static Bool tx_setup_format(GF_TextureHandler *txh) tx_id[2] = txh->tx_io->v_id; nb_tx = 3; - if (txh->tx_io->flags & TX_IS_RECT) { + if (0 && txh->tx_io->flags & TX_IS_RECT) { GLint loc; glUseProgram(compositor->visual->yuv_rect_glsl_program); loc = glGetUniformLocation(compositor->visual->yuv_rect_glsl_program, "width"); @@ -494,7 +494,7 @@ static Bool tx_setup_format(GF_TextureHandler *txh) } } #endif - + #if !defined(GPAC_USE_TINYGL) && !defined(GPAC_USE_OGL_ES) if (txh->compositor->gl_caps.pbo && txh->compositor->enable_pbo) { u32 size = txh->stride*txh->height; @@ -560,17 +560,18 @@ static Bool tx_setup_format(GF_TextureHandler *txh) #else #ifndef GPAC_USE_TINYGL - if (txh->tx_io->gl_type == GL_TEXTURE_2D) { + if (txh->tx_io->gl_type == GL_TEXTURE_2D) { GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_S, (txh->flags & GF_SR_TEXTURE_REPEAT_S) ? GL_REPEAT : GL_CLAMP); GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_T, (txh->flags & GF_SR_TEXTURE_REPEAT_T) ? GL_REPEAT : GL_CLAMP); } else #endif - { - GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_S, GL_CLAMP); - GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_T, GL_CLAMP); + //clamp to edge for NPOT textures + { + GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } - if (txh->tx_io->gl_type == GL_TEXTURE_2D) { + if (txh->tx_io->gl_type == GL_TEXTURE_2D) { GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_MAG_FILTER, txh->compositor->high_speed ? GL_NEAREST : GL_LINEAR); GLTEXPARAM(txh->tx_io->gl_type, GL_TEXTURE_MIN_FILTER, txh->compositor->high_speed ? GL_NEAREST : GL_LINEAR); } else { @@ -581,16 +582,16 @@ static Bool tx_setup_format(GF_TextureHandler *txh) if (txh->tx_io->yuv_shader && (txh->pixelformat==GF_PIXEL_YV12_10)) { //will never happen on GLES for now since we don't have GLES2 support yet ... -#ifndef GPAC_USE_OGL_ES - glPixelStorei(GL_UNPACK_ALIGNMENT, 2); +#ifndef GPAC_USE_OGL_ES + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); //we use 10 bits but GL will normalise using 16 bits, so we need to multiply the nomralized result by 2^6 glPixelTransferi(GL_RED_SCALE, 64); #endif } else { -#ifndef GPAC_USE_OGL_ES +#ifndef GPAC_USE_OGL_ES glPixelTransferi(GL_RED_SCALE, 1); #endif - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } glDisable(txh->tx_io->gl_type); } @@ -626,7 +627,7 @@ void txh_unpack_yuv(GF_TextureHandler *txh) v = p_v + (idx/2) * txh->stride/2; dst = (u8 *) txh->tx_io->conv_data + 2*i*txh->stride; - for (j=0; jwidth/2;j++) { + for (j=0; jwidth/2; j++) { *dst = *u; dst++; u++; @@ -668,9 +669,9 @@ Bool gf_sc_texture_convert(GF_TextureHandler *txh) case GF_PIXEL_BGR_24: bpp = 3; break; - case GF_PIXEL_BGR_32: - bpp = 4; - break; + case GF_PIXEL_BGR_32: + bpp = 4; + break; case GF_PIXEL_GREYSCALE: case GF_PIXEL_ALPHAGREY: case GF_PIXEL_RGB_24: @@ -688,10 +689,10 @@ common: txh->tx_io->conv_data = gf_malloc(sizeof(char)*txh->stride*txh->height); txh->tx_io->conv_format = txh->pixelformat; } -assert(txh->tx_io->conv_data ); -assert(txh->data ); -/*if texture is using RECT extension, flip image manually because - texture transforms are not supported in this case ...*/ + assert(txh->tx_io->conv_data ); + assert(txh->data ); + /*if texture is using RECT extension, flip image manually because + texture transforms are not supported in this case ...*/ for (i=0; iheight; i++) { memcpy(txh->tx_io->conv_data + (txh->height - 1 - i) * txh->stride, txh->data + i*txh->stride, txh->stride); } @@ -760,14 +761,14 @@ assert(txh->data ); case GF_PIXEL_NV21: case GF_PIXEL_I420: case GF_PIXEL_BGR_24: - case GF_PIXEL_BGR_32: - txh->tx_io->conv_format = dst.pixel_format = GF_PIXEL_RGB_24; + case GF_PIXEL_BGR_32: + txh->tx_io->conv_format = dst.pixel_format = GF_PIXEL_RGB_24; /*stretch and flip*/ gf_stretch_bits(&dst, &src, NULL, NULL, 0xFF, !txh->is_flipped, NULL, NULL); - if ( !txh->is_flipped) - txh->flags |= GF_SR_TEXTURE_NO_GL_FLIP; + if ( !txh->is_flipped) + txh->flags |= GF_SR_TEXTURE_NO_GL_FLIP; break; - case GF_PIXEL_YUVD: + case GF_PIXEL_YUVD: if ((txh->compositor->depth_gl_type==GF_SC_DEPTH_GL_NONE) || (txh->compositor->depth_gl_type==GF_SC_DEPTH_GL_VBO)) { src.pixel_format = GF_PIXEL_YV12; txh->tx_io->conv_format = GF_PIXEL_RGB_24_DEPTH; @@ -819,18 +820,18 @@ static void do_tex_image_2d(GF_TextureHandler *txh, GLint tx_mode, Bool first_lo { Bool needs_stride; if (txh->tx_io->gl_dtype==GL_UNSIGNED_SHORT) { - needs_stride = (stride != 2*w*txh->tx_io->nb_comp) ? GF_TRUE : GF_FALSE; + needs_stride = (stride != 2*w*txh->tx_io->nb_comp) ? GF_TRUE : GF_FALSE; if (needs_stride) stride /= 2; } else { - needs_stride = (stride!=w*txh->tx_io->nb_comp) ? GF_TRUE : GF_FALSE; + needs_stride = (stride!=w*txh->tx_io->nb_comp) ? GF_TRUE : GF_FALSE; } #if !defined(GPAC_USE_OGL_ES) - if (needs_stride) - glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); + if (needs_stride) + glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); #else - u32 i; - if (needs_stride) { + u32 i; + if (needs_stride) { #endif #if !defined(GPAC_USE_TINYGL) && !defined(GPAC_USE_OGL_ES) @@ -839,37 +840,37 @@ static void do_tex_image_2d(GF_TextureHandler *txh, GLint tx_mode, Bool first_lo glTexImage2D(txh->tx_io->gl_type, 0, tx_mode, w, h, 0, txh->tx_io->gl_format, txh->tx_io->gl_dtype, NULL); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0); } - else + else #endif - if (first_load) { - glTexImage2D(txh->tx_io->gl_type, 0, tx_mode, w, h, 0, txh->tx_io->gl_format, txh->tx_io->gl_dtype, data); - } else { - glTexSubImage2D(txh->tx_io->gl_type, 0, 0, 0, w, h, txh->tx_io->gl_format, txh->tx_io->gl_dtype, data); - } + if (first_load) { + glTexImage2D(txh->tx_io->gl_type, 0, tx_mode, w, h, 0, txh->tx_io->gl_format, txh->tx_io->gl_dtype, data); + } else { + glTexSubImage2D(txh->tx_io->gl_type, 0, 0, 0, w, h, txh->tx_io->gl_format, txh->tx_io->gl_dtype, data); + } #if !defined(GPAC_USE_OGL_ES) - if (needs_stride) - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - return; + if (needs_stride) + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + return; #else - } +} + +if (!needs_stride) + return; - if (!needs_stride) - return; - - //no GL_UNPACK_ROW_LENGTH on GLES, push line by line ... - if (first_load) { - glTexImage2D(txh->tx_io->gl_type, 0, tx_mode, w, h, 0, txh->tx_io->gl_format, txh->tx_io->gl_dtype, NULL); - } - for (i=0; itx_io->gl_type, 0, 0, 0, w, 1, txh->tx_io->gl_format, txh->tx_io->gl_dtype, ptr); - } +//no GL_UNPACK_ROW_LENGTH on GLES, push line by line ... +if (first_load) { + glTexImage2D(txh->tx_io->gl_type, 0, tx_mode, w, h, 0, txh->tx_io->gl_format, txh->tx_io->gl_dtype, NULL); +} +for (i=0; itx_io->gl_type, 0, 0, 0, w, 1, txh->tx_io->gl_format, txh->tx_io->gl_dtype, ptr); +} #endif } #endif - + Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Bool for2d) { #ifndef GPAC_DISABLE_3D @@ -912,7 +913,7 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Texturing] Allocating OpenGL texture %d\n", txh->tx_io->id)); } if (!txh->tx_io->gl_type) return 0; - + /*if data not yet ready don't push the texture*/ if (txh->data) { /*convert image*/ @@ -969,7 +970,7 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo pV = (u8 *) pU + txh->height*txh->stride/4; } -#ifndef GPAC_USE_OGL_ES +#ifndef GPAC_USE_OGL_ES if (txh->pixelformat==GF_PIXEL_YV12_10) { glPixelStorei(GL_UNPACK_ALIGNMENT, 2); //we use 10 bits but GL will normalise using 16 bits, so we need to multiply the nomralized result by 2^6 @@ -978,18 +979,18 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo #endif push_time = gf_sys_clock(); - + do_tex_image_2d(txh, tx_mode, first_load, pY, txh->stride, w, h, txh->tx_io->pbo_id); - GL_CHECK_ERR + GL_CHECK_ERR glBindTexture(txh->tx_io->gl_type, txh->tx_io->u_id); - do_tex_image_2d(txh, tx_mode, first_load, pU, txh->stride/2, w/2, h/2, txh->tx_io->u_pbo_id); - GL_CHECK_ERR - - glBindTexture(txh->tx_io->gl_type, txh->tx_io->v_id); - do_tex_image_2d(txh, tx_mode, first_load, pV, txh->stride/2, w/2, h/2, txh->tx_io->v_pbo_id); - GL_CHECK_ERR - + do_tex_image_2d(txh, tx_mode, first_load, pU, txh->stride/2, w/2, h/2, txh->tx_io->u_pbo_id); + GL_CHECK_ERR + + glBindTexture(txh->tx_io->gl_type, txh->tx_io->v_id); + do_tex_image_2d(txh, tx_mode, first_load, pV, txh->stride/2, w/2, h/2, txh->tx_io->v_pbo_id); + GL_CHECK_ERR + push_time = gf_sys_clock() - push_time; if (txh->nb_frames==100) { @@ -999,7 +1000,7 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo txh->nb_frames ++; txh->upload_time += push_time; -#ifndef GPAC_USE_OGL_ES +#ifndef GPAC_USE_OGL_ES if (txh->pixelformat==GF_PIXEL_YV12_10) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelTransferi(GL_RED_SCALE, 1); @@ -1007,12 +1008,12 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo #endif #ifndef GPAC_DISABLE_LOGS - gf_mo_get_object_time(txh->stream, &ck); + gf_mo_get_object_time(txh->stream, &ck); GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[GL Texture] Texture (CTS %d) %d ms after due date - Pushed Y,U,V textures in %d ms - average push time %d ms (PBO enabled %s)\n", txh->last_frame_time, ck - txh->last_frame_time, push_time, txh->upload_time / txh->nb_frames, txh->tx_io->pbo_pushed ? "yes" : "no")); #endif txh->tx_io->pbo_pushed = 0; } else { - do_tex_image_2d(txh, tx_mode, first_load, (u8 *) data, txh->stride, w, h, txh->tx_io->pbo_id); + do_tex_image_2d(txh, tx_mode, first_load, (u8 *) data, txh->stride, w, h, txh->tx_io->pbo_id); txh->tx_io->pbo_pushed = 0; } } else { @@ -1020,7 +1021,7 @@ Bool gf_sc_texture_push_image(GF_TextureHandler *txh, Bool generate_mipmaps, Boo #ifdef GPAC_HAS_GLU if (!txh->compositor->disable_glu_scale) { gluScaleImage(txh->tx_io->gl_format, txh->width, txh->height, txh->tx_io->gl_dtype, data, txh->tx_io->rescale_width, txh->tx_io->rescale_height, txh->tx_io->gl_dtype, txh->tx_io->scale_data); - } else + } else #endif { /*it appears gluScaleImage is quite slow - use ourt own resampler which is not as nice but a but faster*/ @@ -1085,7 +1086,7 @@ void gf_sc_copy_to_texture(GF_TextureHandler *txh) glGenTextures(1, &txh->tx_io->id); tx_setup_format(txh); } - + tx_bind(txh); glCopyTexImage2D(txh->tx_io->gl_type, 0, txh->tx_io->gl_format, 0, 0, txh->width, txh->height, 0); glDisable(txh->tx_io->gl_type); @@ -1108,44 +1109,44 @@ void gf_sc_copy_to_stencil(GF_TextureHandler *txh) glReadPixels(0, 0, txh->width, txh->height, GL_RGBA, GL_UNSIGNED_BYTE, txh->data); } else if (txh->pixelformat==GF_PIXEL_RGB_24) { glReadPixels(0, 0, txh->width, txh->height, GL_RGB, GL_UNSIGNED_BYTE, txh->data); - } + } #ifdef GF_SR_USE_DEPTH else if (txh->pixelformat==GF_PIXEL_RGBDS) { /*we'll work with one alpha bit (=shape). we'll take the heaviest weighted as this threshold*/ glReadPixels(0, 0, txh->width, txh->height, GL_RGBA, GL_UNSIGNED_BYTE, txh->data); - + /*NOTES on OpenGL's z-buffer perspective inversion: * option 1: extract float depth buffer, undoing depth perspective transform PIXEL per PIXEL and then * convert to byte (computationally costly) - * + * * option 2: use gain and offset to make up an approximation of the linear z-buffer (the original) * it can be achieved by scaling the interval where the inflection point is located * i.e. z' = G*z - (G - 1), the offset so that z still belongs to [0..1]* */ - - //glPixelTransferf(GL_DEPTH_SCALE, txh->compositor->OGLDepthGain); - //glPixelTransferf(GL_DEPTH_BIAS, txh->compositor->OGLDepthOffset); - + + //glPixelTransferf(GL_DEPTH_SCALE, txh->compositor->OGLDepthGain); + //glPixelTransferf(GL_DEPTH_BIAS, txh->compositor->OGLDepthOffset); + #ifndef GPAC_USE_OGL_ES - /*obtain depthmap*/ + /*obtain depthmap*/ if (!txh->tx_io->depth_data) txh->tx_io->depth_data = (char*)gf_malloc(sizeof(char)*txh->width*txh->height); glReadPixels(0, 0, txh->width, txh->height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, txh->tx_io->depth_data); - /* depth = alpha & 0xfe + /* depth = alpha & 0xfe shape = plan alpha & 0x01 */ /*this corresponds to the RGBDS ordering*/ for (i=0; iheight*txh->width; i++) { u8 alpha; - //inversion - u8 ds = (char) (255 - (int)txh->tx_io->depth_data[i]); + //inversion + u8 ds = (char) (255 - (int)txh->tx_io->depth_data[i]); /*get alpha*/ alpha = (txh->data[i*4 + 3]); /* if heaviest-weighted alpha bit is set (>128) , turn on shape bit*/ //if (ds & 0x80) depth |= 0x01; if (alpha & 0x80) ds = (ds >> 1) | 0x80; - else ds = 0x0; - txh->data[i*4+3] = ds; /*insert depth onto alpha*/ + else ds = 0x0; + txh->data[i*4+3] = ds; /*insert depth onto alpha*/ } #endif @@ -1161,7 +1162,7 @@ void gf_sc_copy_to_stencil(GF_TextureHandler *txh) memcpy(txh->data + (txh->height - 1 - i) * txh->stride, tmp, txh->stride); } gf_free(tmp); - //dump depth and rgbds texture + //dump depth and rgbds texture } #else @@ -1188,16 +1189,15 @@ Bool gf_sc_texture_get_transform(GF_TextureHandler *txh, GF_Node *tx_transform, ret = 1; } - /*WATCHOUT: GL_TEXTURE_RECTANGLE coords are w, h not 1.0, 1.0*/ + /*WATCHOUT: GL_TEXTURE_RECTANGLE coords are w, h not 1.0, 1.0 (but not with shaders, we do the txcoord conversion in the fragment shader*/ if (txh->tx_io->flags & TX_IS_RECT) { - if (!for_picking) { +#ifndef GPAC_DISABLE_3D + if (!for_picking && !txh->tx_io->yuv_shader) { gf_mx_add_scale(mx, INT2FIX(txh->width), INT2FIX(txh->height), FIX_ONE); -// gf_mx_add_translation(mx, 0, INT2FIX(txh->height), 0); + ret = 1; } - /*disable any texture transforms when using RECT textures (no repeat) ??*/ - /*tx_transform = NULL;*/ - ret = 1; - } +#endif + } else if (txh->tx_io->flags & TX_EMULE_POW2) { #ifndef GPAC_DISABLE_3D gf_mx_add_scale(mx, txh->tx_io->conv_wscale, txh->tx_io->conv_hscale, FIX_ONE); @@ -1217,14 +1217,15 @@ Bool gf_sc_texture_get_transform(GF_TextureHandler *txh, GF_Node *tx_transform, GF_Matrix2D mat; M_TextureTransform *tt = (M_TextureTransform *)tx_transform; gf_mx2d_init(mat); - /*1- translate*/ - gf_mx2d_add_translation(&mat, tt->translation.x, tt->translation.y); - /*2- rotate*/ - if (fabs(tt->rotation) > FIX_EPSILON) gf_mx2d_add_rotation(&mat, tt->center.x, tt->center.y, tt->rotation); - /*3- centered-scale*/ + + /*cf VRML spec: Tc' = -C × S × R × C × T × Tc*/ gf_mx2d_add_translation(&mat, -tt->center.x, -tt->center.y); gf_mx2d_add_scale(&mat, tt->scale.x, tt->scale.y); + if (fabs(tt->rotation) > FIX_EPSILON) gf_mx2d_add_rotation(&mat, tt->center.x, tt->center.y, tt->rotation); gf_mx2d_add_translation(&mat, tt->center.x, tt->center.y); + + gf_mx2d_add_translation(&mat, tt->translation.x, tt->translation.y); + if (ret) { gf_mx_from_mx2d(&tmp, &mat); gf_mx_add_matrix(mx, &tmp); @@ -1233,13 +1234,15 @@ Bool gf_sc_texture_get_transform(GF_TextureHandler *txh, GF_Node *tx_transform, } ret = 1; } - break; + break; case TAG_MPEG4_TransformMatrix2D: { M_TransformMatrix2D *tm = (M_TransformMatrix2D *)tx_transform; memset(tmp.m, 0, sizeof(Fixed)*16); - tmp.m[0] = tm->mxx; tmp.m[4] = tm->mxy; /*0*/ tmp.m[12] = tm->tx; - tmp.m[1] = tm->myx; tmp.m[5] = tm->myy; /*0*/ tmp.m[13] = tm->ty; + tmp.m[0] = tm->mxx; + tmp.m[4] = tm->mxy; /*0*/ tmp.m[12] = tm->tx; + tmp.m[1] = tm->myx; + tmp.m[5] = tm->myy; /*0*/ tmp.m[13] = tm->ty; /*rest is all 0 excep both diag*/ tmp.m[10] = tmp.m[15] = FIX_ONE; @@ -1250,7 +1253,7 @@ Bool gf_sc_texture_get_transform(GF_TextureHandler *txh, GF_Node *tx_transform, } ret = 1; } - break; + break; default: break; } @@ -1274,12 +1277,12 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) MFFloat coefficients; #endif M_MatteTexture *matte = (M_MatteTexture *)n; - + b_surf = gf_sc_texture_get_handler(matte->surfaceB); - + if (!b_surf || !b_surf->tx_io) return 0; - glEnable(GL_BLEND); + glEnable(GL_BLEND); tx_set_image(b_surf, 0); #if defined(GPAC_USE_TINYGL) || defined(GPAC_USE_OGL_ES) @@ -1287,7 +1290,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) return 1; #else -/*To remove: gcc 4.6 introduces this warning*/ + /*To remove: gcc 4.6 introduces this warning*/ #if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress" @@ -1296,7 +1299,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) tx_bind(b_surf); return 1; } -/*To remove: gcc 4.6 introduces this warning*/ + /*To remove: gcc 4.6 introduces this warning*/ #if __GNUC__ == 4 && __GNUC_MINOR__ == 6 #pragma GCC diagnostic pop #endif @@ -1311,7 +1314,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) action = (matte->operation).buffer; glDisable(GL_TEXTURE_2D); - + /* SCALE */ if (! strcmp(action,"SCALE") || !strcmp(action,"BIAS") ) { TexEnvType operand; @@ -1324,7 +1327,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) texture[1] = (u8) FIX2INT( 255 * coefficients.vals[1]); texture[2] = (u8) FIX2INT( 255 * coefficients.vals[2]); texture[3] = 255; - if (coefficients.count >= 4) + if (coefficients.count >= 4) texture[3] = (u8) FIX2INT( 255 * coefficients.vals[3]); glActiveTexture(GL_TEXTURE0); @@ -1362,11 +1365,11 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) /* CROSS_FADE */ if (! strcmp(action,"CROSS_FADE")) { tmp = FIX2INT(255 * matte->fraction); - texture[0] = (unsigned char) tmp; + texture[0] = (unsigned char) tmp; texture[1] = (unsigned char) tmp; texture[2] = (unsigned char) tmp; texture[3] = (unsigned char) 255; // donne l'alpha de l'image de sortie - + glActiveTexture(GL_TEXTURE0); if (!matte_hdl->tx_io->id) { glGenTextures(1, &matte_hdl->tx_io->id); @@ -1379,9 +1382,9 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) GLTEXPARAM( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT ); GLTEXPARAM( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT ); glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,1,1,0,GL_RGBA,GL_UNSIGNED_BYTE,texture); - + /* fin de la g\E9n\E9ration de la texture donn\E9e par la fraction ! */ - + /* m\E9lange effectif des textures ! } */ glActiveTexture(GL_TEXTURE1); tx_bind(b_surf); @@ -1398,9 +1401,9 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) GLTEXENV(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); GLTEXENV(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE0 ); GLTEXENV(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR); - } + } return 3; - } + } /* end CROSS_FADE */ /*REVEAL */ @@ -1417,7 +1420,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) glActiveTexture(GL_TEXTURE2); tx_set_image(a_surf, 0); tx_bind(a_surf); - + GLTEXENV(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); GLTEXENV(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); GLTEXENV(GL_TEXTURE_ENV, GL_SOURCE0_RGB , GL_TEXTURE0); @@ -1426,7 +1429,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) GLTEXENV(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); GLTEXENV(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE1); GLTEXENV(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); - + } return 3; } @@ -1454,7 +1457,7 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) if (!strcmp(action,"REPLACE_ALPHA")) { glActiveTexture(GL_TEXTURE0); tx_bind(b_surf); - + if (alpha_surf) { glEnable(GL_BLEND); glActiveTexture(GL_TEXTURE1); @@ -1618,16 +1621,16 @@ u32 gf_sc_texture_enable_ex(GF_TextureHandler *txh, GF_Node *tx_transform, GF_Re if (txh->matteTexture) { u32 ret = gf_sc_texture_enable_matte_texture(txh->matteTexture); if (!ret) return 0; - visual_3d_set_matrix_mode(compositor->visual, V3D_MATRIX_TEXTURE); - if (gf_sc_texture_get_transform(txh, tx_transform, &mx, 0)) - visual_3d_matrix_load(compositor->visual, mx.m); + + if (gf_sc_texture_get_transform(txh, tx_transform, &mx, 0)) + visual_3d_set_texture_matrix(compositor->visual, &mx); else - visual_3d_matrix_reset(compositor->visual); - visual_3d_set_matrix_mode(compositor->visual, V3D_MATRIX_MODELVIEW); + visual_3d_set_texture_matrix(compositor->visual, NULL); + return ret; } #endif - if (!txh || !txh->tx_io) + if (!txh || !txh->tx_io) return 0; if (txh->compute_gradient_matrix && gf_sc_texture_needs_reload(txh) ) { @@ -1636,33 +1639,43 @@ u32 gf_sc_texture_enable_ex(GF_TextureHandler *txh, GF_Node *tx_transform, GF_Re tx_set_image(txh, 0); - visual_3d_set_matrix_mode(compositor->visual, V3D_MATRIX_TEXTURE); if (bounds && txh->compute_gradient_matrix) { GF_Matrix2D mx2d; txh->compute_gradient_matrix(txh, bounds, &mx2d, 1); gf_mx_from_mx2d(&mx, &mx2d); - visual_3d_matrix_load(compositor->visual, mx.m); + visual_3d_set_texture_matrix(compositor->visual, &mx); } else if (gf_sc_texture_get_transform(txh, tx_transform, &mx, 0)) { - visual_3d_matrix_load(compositor->visual, mx.m); + visual_3d_set_texture_matrix(compositor->visual, &mx); } else { - visual_3d_matrix_reset(compositor->visual); + visual_3d_set_texture_matrix(compositor->visual, NULL); } - visual_3d_set_matrix_mode(compositor->visual, V3D_MATRIX_MODELVIEW); txh->flags |= GF_SR_TEXTURE_USED; #ifndef GPAC_USE_OGL_ES if (txh->tx_io->yuv_shader) { + GLint loc; /*use our program*/ Bool is_rect = txh->tx_io->flags & TX_IS_RECT; compositor->visual->current_texture_glsl_program = is_rect ? compositor->visual->yuv_rect_glsl_program : compositor->visual->yuv_glsl_program; - GL_CHECK_ERR + GL_CHECK_ERR glUseProgram(compositor->visual->current_texture_glsl_program); - GL_CHECK_ERR + GL_CHECK_ERR glEnable(txh->tx_io->gl_type); - + + loc = glGetUniformLocation(compositor->visual->current_texture_glsl_program, "width"); + if (loc >=0) { + GLfloat w = (GLfloat) txh->width; + glUniform1f(loc, w); + } + loc = glGetUniformLocation(compositor->visual->current_texture_glsl_program, "height"); + if (loc >= 0) { + GLfloat h = (GLfloat) txh->height; + glUniform1f(loc, h); + } + glActiveTexture(GL_TEXTURE2); glBindTexture(txh->tx_io->gl_type, txh->tx_io->v_id); @@ -1671,12 +1684,12 @@ u32 gf_sc_texture_enable_ex(GF_TextureHandler *txh, GF_Node *tx_transform, GF_Re glActiveTexture(GL_TEXTURE0 ); glBindTexture(txh->tx_io->gl_type, txh->tx_io->id); - + tx_bind_with_mode(txh, txh->transparent, txh->tx_io->blend_mode, 1); glClientActiveTexture(GL_TEXTURE0); - } else + } else #endif - { + { tx_bind(txh); } return 1; diff --git a/src/compositor/visual_manager.c b/src/compositor/visual_manager.c index 510693f..fcf634c 100644 --- a/src/compositor/visual_manager.c +++ b/src/compositor/visual_manager.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -145,9 +145,9 @@ void visual_clean_contexts(GF_VisualManager *visual) while (ctx && ctx->drawable) { /*remove visual registration flag*/ ctx->drawable->flags &= ~DRAWABLE_REGISTERED_WITH_VISUAL; - if (is_root_visual && (ctx->flags & CTX_HAS_APPEARANCE)) + if (is_root_visual && (ctx->flags & CTX_HAS_APPEARANCE)) gf_node_dirty_reset(ctx->appear, 0); - + #ifndef GPAC_DISABLE_3D /*this may happen when switching a visual from 2D to 3D - discard context*/ if (visual->type_3d) ctx->drawable=NULL; @@ -159,14 +159,14 @@ void visual_clean_contexts(GF_VisualManager *visual) if (!is_root_visual) return; /*reset all flags of all appearance nodes registered on all visuals but main one (done above) - this must be done once all visuals have been drawn, otherwise we won't detect the changes + this must be done once all visuals have been drawn, otherwise we won't detect the changes for nodes drawn on several visuals*/ count = gf_list_count(visual->compositor->visuals); for (i=1; icompositor->visuals, i); ctx = a_vis->context; while (ctx && ctx->drawable) { - if (ctx->flags & CTX_HAS_APPEARANCE) + if (ctx->flags & CTX_HAS_APPEARANCE) gf_node_dirty_reset(ctx->appear, 0); ctx->drawable = NULL; @@ -208,9 +208,15 @@ void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_Traver size.x = size.y = -FIX_ONE; #ifndef GPAC_DISABLE_VRML switch (gf_node_get_tag(self)) { - case TAG_MPEG4_Layer2D: size = ((M_Layer2D *)self)->size; break; - case TAG_MPEG4_Layer3D: size = ((M_Layer3D *)self)->size; break; - case TAG_MPEG4_Form: size = ((M_Form *)self)->size; break; + case TAG_MPEG4_Layer2D: + size = ((M_Layer2D *)self)->size; + break; + case TAG_MPEG4_Layer3D: + size = ((M_Layer3D *)self)->size; + break; + case TAG_MPEG4_Form: + size = ((M_Form *)self)->size; + break; } #endif if ((size.x>=0) && (size.y>=0)) { @@ -231,7 +237,7 @@ void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_Traver tr_state->bounds = gf_rect_center(0,0); /*we hit the target node*/ - if (children->node == tr_state->for_node) + if (children->node == tr_state->for_node) tr_state->abort_bounds_traverse = 1; gf_node_traverse(children->node, tr_state); @@ -244,7 +250,7 @@ void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_Traver gf_mx2d_apply_rect(&tr_state->transform, &tr_state->bounds); gf_rect_union(&rc, &tr_state->bounds); children = children->next; - if (child_idx) + if (child_idx) break; } @@ -258,7 +264,7 @@ void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_Traver tr_state->bounds = gf_rect_center(0,0); /*we hit the target node*/ - if (iri == tr_state->for_node) + if (iri == tr_state->for_node) tr_state->abort_bounds_traverse = 1; gf_node_traverse(iri, tr_state); @@ -274,7 +280,7 @@ void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_Traver } } #endif - + gf_mx2d_copy(tr_state->transform, cur_mx); if (self != tr_state->for_node) { gf_mx2d_apply_rect(&tr_state->transform, &rc); diff --git a/src/compositor/visual_manager.h b/src/compositor/visual_manager.h index 9634d34..14eb1ae 100644 --- a/src/compositor/visual_manager.h +++ b/src/compositor/visual_manager.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -35,7 +35,7 @@ #include "visual_manager_3d.h" -enum +enum { GF_3D_STEREO_NONE = 0, GF_3D_STEREO_TOP, @@ -54,7 +54,7 @@ enum GF_3D_STEREO_5VSP19, }; -enum +enum { GF_3D_CAMERA_STRAIGHT = 0, GF_3D_CAMERA_OFFAXIS, @@ -96,7 +96,7 @@ struct _visual_manager GF_RectArray to_redraw; u32 draw_node_index; - /*display list (list of drawable context). The first context with no drawable attached to + /*display list (list of drawable context). The first context with no drawable attached to it (ctx->drawable==NULL) marks the end of the display list*/ DrawableContext *context, *cur_context; @@ -124,7 +124,7 @@ struct _visual_manager /*clear given rect or all visual if no rect specified - clear color depends on visual's type: BackColor for background nodes - 0x00000000 for composite, + 0x00000000 for composite, compositor clear color otherwise */ void (*ClearSurface)(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor); @@ -149,10 +149,10 @@ struct _visual_manager #ifndef GPAC_DISABLE_3D /* - * Visual Manager part for 3D drawing + * Visual Manager part for 3D drawing */ -#if defined( _LP64 ) && 0 && defined(CONFIG_DARWIN_GL) +#if defined( _LP64 ) && defined(CONFIG_DARWIN_GL) #define GF_SHADERID u64 #else #define GF_SHADERID u32 @@ -193,13 +193,39 @@ struct _visual_manager GF_Mesh *autostereo_mesh; GF_SHADERID autostereo_glsl_program; GF_SHADERID autostereo_glsl_fragment; - + GF_SHADERID yuv_glsl_program; GF_SHADERID yuv_glsl_fragment; GF_SHADERID yuv_rect_glsl_program; GF_SHADERID yuv_rect_glsl_fragment; GF_SHADERID current_texture_glsl_program; + + + Bool has_mat_2d; + SFColorRGBA mat_2d; + + Bool has_mat; + SFColorRGBA materials[4]; + Float shininess; + + Bool state_light_on, state_blend_on, state_color_on; + + GF_ClipInfo clippers[GF_MAX_GL_CLIPS]; + + Bool has_tx_matrix; + GF_Matrix tx_matrix; + + Bool needs_projection_matrix_reload; + + GF_LightInfo lights[GF_MAX_GL_LIGHTS]; + Bool has_inactive_lights; + + Bool has_fog; + u32 fog_type; + SFColor fog_color; + Fixed fog_density, fog_visibility; + #endif #ifdef GF_SR_USE_DEPTH diff --git a/src/compositor/visual_manager_2d.c b/src/compositor/visual_manager_2d.c index 5dc4542..8de00e8 100644 --- a/src/compositor/visual_manager_2d.c +++ b/src/compositor/visual_manager_2d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,30 +44,33 @@ Bool gf_irect_overlaps(GF_IRect *rc1, GF_IRect *rc2) void gf_irect_intersect(GF_IRect *rc1, GF_IRect *rc2) { if (! gf_irect_overlaps(rc1, rc2)) { - rc1->width = rc1->height = 0; + rc1->width = rc1->height = 0; return; } if (rc2->x > rc1->x) { rc1->width -= rc2->x - rc1->x; rc1->x = rc2->x; - } + } if (rc2->x + rc2->width < rc1->x + rc1->width) { rc1->width = rc2->width + rc2->x - rc1->x; - } + } if (rc2->y < rc1->y) { - rc1->height -= rc1->y - rc2->y; + rc1->height -= rc1->y - rc2->y; rc1->y = rc2->y; - } + } if (rc2->y - rc2->height > rc1->y - rc1->height) { rc1->height = rc1->y - rc2->y + rc2->height; - } + } } GF_Rect gf_rect_ft(GF_IRect *rc) { GF_Rect rcft; - rcft.x = INT2FIX(rc->x); rcft.y = INT2FIX(rc->y); rcft.width = INT2FIX(rc->width); rcft.height = INT2FIX(rc->height); + rcft.x = INT2FIX(rc->x); + rcft.y = INT2FIX(rc->y); + rcft.width = INT2FIX(rc->width); + rcft.height = INT2FIX(rc->height); return rcft; } @@ -147,7 +150,7 @@ void visual_2d_drawable_delete(GF_VisualManager *visual, struct _drawable *drawa gf_free(it); break; } - + ctx = visual->context; while (ctx && ctx->drawable) { /*remove visual registration flag*/ @@ -228,6 +231,10 @@ void visual_2d_setup_projection(GF_VisualManager *visual, GF_TraverseState *tr_s } #endif +#ifndef GPAC_DISABLE_3D + gf_mx_init(tr_state->model_matrix); +#endif + visual->top_clipper = gf_rect_pixelize(&rc); tr_state->clipper = rc; // GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Visual2D] Cliper setup - %d:%d@%dx%d\n", visual->top_clipper.x, visual->top_clipper.y, visual->top_clipper.width, visual->top_clipper.height)); @@ -243,7 +250,7 @@ GF_Err visual_2d_init_draw(GF_VisualManager *visual, GF_TraverseState *tr_state) M_Background2D *bck; #endif u32 draw_mode; - + /*reset display list*/ visual->cur_context = visual->context; if (visual->context) visual->context->drawable = NULL; @@ -251,7 +258,7 @@ GF_Err visual_2d_init_draw(GF_VisualManager *visual, GF_TraverseState *tr_state) visual->has_overlays = 0; visual_2d_setup_projection(visual, tr_state); - if (!visual->top_clipper.width || !visual->top_clipper.height) + if (!visual->top_clipper.width || !visual->top_clipper.height) return GF_OK; tr_state->traversing_mode = TRAVERSE_SORT; @@ -259,7 +266,7 @@ GF_Err visual_2d_init_draw(GF_VisualManager *visual, GF_TraverseState *tr_state) /*setup raster surface, brush and pen */ e = visual_2d_init_raster(visual); - if (e) + if (e) return e; draw_mode = 0; @@ -279,7 +286,7 @@ GF_Err visual_2d_init_draw(GF_VisualManager *visual, GF_TraverseState *tr_state) /*node was not drawn on this visual*/ if (!drawable_flush_bounds(it->drawable, visual, draw_mode)) { GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Visual2D] Unregistering previously drawn node %s from visual\n", gf_node_get_class_name(it->drawable->node))); - + /*remove all bounds info related to this visual and unreg node */ drawable_reset_bounds(it->drawable, visual); @@ -333,7 +340,7 @@ GF_Err visual_2d_init_draw(GF_VisualManager *visual, GF_TraverseState *tr_state) /*@rc2 fully contained in @rc1*/ -Bool gf_irect_inside(GF_IRect *rc1, GF_IRect *rc2) +Bool gf_irect_inside(GF_IRect *rc1, GF_IRect *rc2) { if (!rc1->width || !rc1->height) return 0; if ( (rc1->x <= rc2->x) && (rc1->y >= rc2->y) && (rc1->x + rc1->width >= rc2->x + rc2->width) && (rc1->y - rc1->height <= rc2->y - rc2->height) ) @@ -349,9 +356,12 @@ Bool gf_irect_inside(GF_IRect *rc1, GF_IRect *rc2) #define ra_is_empty(ra) (!((ra)->count)) /*adds @rc2 to @rc1 - the new @rc1 contains the old @rc1 and @rc2*/ -void gf_irect_union(GF_IRect *rc1, GF_IRect *rc2) +void gf_irect_union(GF_IRect *rc1, GF_IRect *rc2) { - if (!rc1->width || !rc1->height) {*rc1=*rc2; return;} + if (!rc1->width || !rc1->height) { + *rc1=*rc2; + return; + } if (rc2->x < rc1->x) { rc1->width += rc1->x - rc2->x; @@ -367,19 +377,19 @@ void gf_irect_union(GF_IRect *rc1, GF_IRect *rc2) /*adds rectangle to the list performing union test*/ -void ra_union_rect(GF_RectArray *ra, GF_IRect *rc) +void ra_union_rect(GF_RectArray *ra, GF_IRect *rc) { u32 i; assert(rc->width && rc->height); - for (i=0; icount; i++) { - if (gf_irect_overlaps(&ra->list[i].rect, rc)) { - gf_irect_union(&ra->list[i].rect, rc); - return; - } + for (i=0; icount; i++) { + if (gf_irect_overlaps(&ra->list[i].rect, rc)) { + gf_irect_union(&ra->list[i].rect, rc); + return; + } } - ra_add(ra, rc); + ra_add(ra, rc); } /*returns relation between rc1 and rc2: @@ -417,7 +427,7 @@ void ra_refresh(GF_RectArray *ra) /*current dirty rect is no longer opaque*/ ra->list[i].opaque_node_index = 0; #endif - /*FALLTHROUGH*/ + /*FALLTHROUGH*/ /*first rectangle covers second, just remove*/ case 2: /*remove rect*/ @@ -425,7 +435,7 @@ void ra_refresh(GF_RectArray *ra) if (k) { memmove(&ra->list[j], & ra->list[j+1], sizeof(GF_IRect)*k); } - ra->count--; + ra->count--; if (ra->count>=2) ra_refresh(ra); return; @@ -463,23 +473,23 @@ static u32 register_context_rect(GF_RectArray *ra, DrawableContext *ctx, u32 ctx if ((*first_opaque==NULL) && needs_redraw) *first_opaque = ctx; } - for (i=0; icount; i++) { + for (i=0; icount; i++) { if (needs_redraw) { - switch (gf_irect_relation(&ra->list[i].rect, rc)) { + switch (gf_irect_relation(&ra->list[i].rect, rc)) { /*context intersects an existing rectangle, merge them and remove opaque idx info*/ case 1: - gf_irect_union(&ra->list[i].rect, rc); + gf_irect_union(&ra->list[i].rect, rc); #ifdef TRACK_OPAQUE_REGIONS - ra->list[i].opaque_node_index = 0; + ra->list[i].opaque_node_index = 0; #endif - return 1; + return 1; /*context covers an existing rectangle, replace rect and add opaque idx info*/ case 2: - ra->list[i].rect= *rc; + ra->list[i].rect= *rc; #ifdef TRACK_OPAQUE_REGIONS - ra->list[i].opaque_node_index = is_transparent ? 0 : ctx_idx; + ra->list[i].opaque_node_index = is_transparent ? 0 : ctx_idx; #endif - return 1; + return 1; } } #ifdef TRACK_OPAQUE_REGIONS @@ -490,16 +500,16 @@ static u32 register_context_rect(GF_RectArray *ra, DrawableContext *ctx, u32 ctx if (k) { memmove(&ra->list[i], & ra->list[i+1], sizeof(GF_RectArrayEntry)*k); } - ra->count--; + ra->count--; i--; } #endif } /*not found, add rect*/ if (needs_redraw) { - ra_add(ra, rc); + ra_add(ra, rc); #ifdef TRACK_OPAQUE_REGIONS - ra->list[ra->count-1].opaque_node_index = is_transparent ? 0 : ctx_idx; + ra->list[ra->count-1].opaque_node_index = is_transparent ? 0 : ctx_idx; #endif } return 1; @@ -513,31 +523,31 @@ static void register_dirty_rect(GF_RectArray *ra, GF_IRect *rc) #ifdef TRACK_OPAQUE_REGIONS u32 i; - for (i=0; icount; i++) { - switch (gf_irect_relation(rc, &ra->list[i].rect)) { + for (i=0; icount; i++) { + switch (gf_irect_relation(rc, &ra->list[i].rect)) { /*dirty area intersects this dirty rectangle, merge them and remove opaque idx info*/ case 1: - gf_irect_union(&ra->list[i].rect, rc); - ra->list[i].opaque_node_index = 0; - return; + gf_irect_union(&ra->list[i].rect, rc); + ra->list[i].opaque_node_index = 0; + return; /*dirty area is covered by this dirty rectangle, nothing to do*/ case 2: - return; + return; } } #endif /*not found, add rect*/ - ra_add(ra, rc); + ra_add(ra, rc); #ifdef TRACK_OPAQUE_REGIONS - ra->list[ra->count-1].opaque_node_index = 0; + ra->list[ra->count-1].opaque_node_index = 0; #endif #else - ra_add(ra, rc); + ra_add(ra, rc); #ifdef TRACK_OPAQUE_REGIONS - ra->list[ra->count-1].opaque_node_index = 0; + ra->list[ra->count-1].opaque_node_index = 0; #endif #endif @@ -598,14 +608,14 @@ Bool visual_2d_terminate_draw(GF_VisualManager *visual, GF_TraverseState *tr_sta } visual->last_had_back = (bck_ctx->aspect.fill_texture && !bck_ctx->aspect.fill_texture->transparent) ? 2 : 1; } - } else + } else #endif - if (visual->last_had_back) { - visual->last_had_back = 0; - if (redraw_all_on_background_change) redraw_all = 1; - else hyb_force_redraw = 1; - } - + if (visual->last_had_back) { + visual->last_had_back = 0; + if (redraw_all_on_background_change) redraw_all = 1; + else hyb_force_redraw = 1; + } + num_nodes = 0; ctx = visual->context; while (ctx && ctx->drawable) { @@ -714,7 +724,7 @@ Bool visual_2d_terminate_draw(GF_VisualManager *visual, GF_TraverseState *tr_sta bck_ctx->flags |= CTX_BACKROUND_NOT_LAYER; gf_node_traverse(bck_ctx->drawable->node, tr_state); bck_ctx->flags &= ~CTX_BACKROUND_NOT_LAYER; - } else + } else #endif /*GPAC_DISABLE_VRML*/ { count = visual->to_redraw.count; @@ -727,9 +737,11 @@ Bool visual_2d_terminate_draw(GF_VisualManager *visual, GF_TraverseState *tr_sta rc = visual->to_redraw.list[k].rect; visual->ClearSurface(visual, &rc, 0); } +#ifndef GPAC_DISABLE_3D if (!count && hyb_force_redraw) { - visual->ClearSurface(visual, NULL, 0); + compositor_2d_hybgl_clear_surface_ex(tr_state->visual, NULL, 0, GF_FALSE); } +#endif } if (!redraw_all && !has_clear) visual->has_modif=0; @@ -746,7 +758,7 @@ skip_background: } } #endif - + visual->draw_node_index = 0; ctx = visual->context; @@ -842,7 +854,7 @@ Bool visual_2d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseSt gf_mx2d_copy(tr_state->transform, backup); res = visual_2d_terminate_draw(visual, tr_state); - + #ifndef GPAC_DISABLE_LOG if (!tr_state->immediate_draw) { visual->compositor->indirect_draw_time = gf_sys_clock() - time; @@ -869,7 +881,7 @@ void visual_2d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, G tr_state->ray.dir.x = 0; tr_state->ray.dir.y = 0; tr_state->ray.dir.z = -FIX_ONE; - + visual->compositor->hit_world_point = tr_state->ray.orig; visual->compositor->hit_world_ray = tr_state->ray; visual->compositor->hit_square_dist = 0; diff --git a/src/compositor/visual_manager_2d.h b/src/compositor/visual_manager_2d.h index a4df5af..f8c5438 100644 --- a/src/compositor/visual_manager_2d.h +++ b/src/compositor/visual_manager_2d.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ GF_Rect gf_rect_ft(GF_IRect *rc); Bool gf_irect_inside(GF_IRect *rc1, GF_IRect *rc2); /*@rc1 equales @rc2*/ -#define gf_rect_equal(rc1, rc2) ((rc1.width == rc2.width) && (rc1.height == rc2.height) && (rc1.x == rc2.x) && (rc1.y == rc2.y)) +#define gf_rect_equal(rc1, rc2) ((rc1.width == rc2.width) && (rc1.height == rc2.height) && (rc1.x == rc2.x) && (rc1.y == rc2.y)) //#define TRACK_OPAQUE_REGIONS @@ -42,7 +42,7 @@ Bool gf_irect_inside(GF_IRect *rc1, GF_IRect *rc2); #define RA_DEFAULT_STEP 10 typedef struct -{ +{ GF_IRect rect; #ifdef TRACK_OPAQUE_REGIONS /*list of nodes covering (no transparency) each rect, or 0 otherwise.*/ @@ -51,7 +51,7 @@ typedef struct } GF_RectArrayEntry; typedef struct -{ +{ GF_RectArrayEntry *list; u32 count, alloc; } GF_RectArray; @@ -126,7 +126,7 @@ void visual_2d_draw_path_extended(GF_VisualManager *visual, GF_Path *path, Drawa /*video overlay context*/ -typedef struct _video_overlay +typedef struct _video_overlay { struct _video_overlay *next; GF_Window src, dst; @@ -134,7 +134,7 @@ typedef struct _video_overlay GF_RectArray ra; } GF_OverlayStack; -/*check if the object is over an overlay. If so, adds its cliper to the list of rectangles to redraw for the overlay +/*check if the object is over an overlay. If so, adds its cliper to the list of rectangles to redraw for the overlay and returns 1 (in which case it shouldn't be drawn)*/ Bool visual_2d_overlaps_overlay(GF_VisualManager *visual, DrawableContext *ctx, GF_TraverseState *tr_state); /*draw all partial overlays in software and all overlaping objects*/ diff --git a/src/compositor/visual_manager_2d_draw.c b/src/compositor/visual_manager_2d_draw.c index 074f549..21dc81d 100644 --- a/src/compositor/visual_manager_2d_draw.c +++ b/src/compositor/visual_manager_2d_draw.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -44,7 +44,7 @@ GF_Err visual_2d_init_raster(GF_VisualManager *visual) void visual_2d_release_raster(GF_VisualManager *visual) { if (visual->raster_surface) { - if (visual->compositor->rasterizer->surface_flush) + if (visual->compositor->rasterizer->surface_flush) visual->compositor->rasterizer->surface_flush(visual->raster_surface); visual->ReleaseSurfaceAccess(visual); @@ -58,7 +58,7 @@ void visual_2d_clear_surface(GF_VisualManager *visual, GF_IRect *rc, u32 BackCol return; #endif if (!visual->is_attached) return; - + if (!BackColor && !visual->offscreen) { if (!visual->compositor->user || !(visual->compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT)) { BackColor = visual->compositor->back_color; @@ -111,7 +111,7 @@ static void visual_2d_fill_path(GF_VisualManager *visual, DrawableContext *ctx, has_modif = GF_TRUE; } - } + } /*indirect drawing, draw path in all dirty areas*/ else { u32 i; @@ -141,7 +141,7 @@ static void visual_2d_fill_path(GF_VisualManager *visual, DrawableContext *ctx, if (has_modif) { visual->has_modif = 1; #ifndef GPAC_DISABLE_3D - if (!visual->offscreen && visual->compositor->hybrid_opengl && !is_erase) + if (!visual->offscreen && visual->compositor->hybrid_opengl && !is_erase) ra_union_rect(&visual->hybgl_drawn, &ctx->bi->clip); #endif } @@ -177,7 +177,7 @@ static void visual_2d_set_options(GF_Compositor *compositor, GF_SURFACE rend, Bo static void visual_2d_get_texture_transform(GF_Node *__appear, GF_TextureHandler *txh, GF_Matrix2D *mat, Bool line_texture, Fixed final_width, Fixed final_height) { u32 node_tag; - M_Appearance *appear; + M_Appearance *appear; GF_Node *txtrans = NULL; gf_mx2d_init(*mat); @@ -233,14 +233,14 @@ static void visual_2d_draw_gradient(GF_VisualManager *visual, GF_Path *path, GF_ GF_Raster2D *raster = visual->compositor->rasterizer; if (!txh) txh = ctx->aspect.fill_texture; - + gf_path_get_bounds(path, &rc); if (!rc.width || !rc.height || !txh->tx_io) return; if (orig_bounds) { - txh->compute_gradient_matrix(txh, orig_bounds, &g_mat, 0); + txh->compute_gradient_matrix(txh, orig_bounds, &g_mat, 0); } else { - txh->compute_gradient_matrix(txh, &rc, &g_mat, 0); + txh->compute_gradient_matrix(txh, &rc, &g_mat, 0); } stencil = gf_sc_texture_get_stencil(txh); if (!stencil) return; @@ -258,11 +258,11 @@ static void visual_2d_draw_gradient(GF_VisualManager *visual, GF_Path *path, GF_ if (orig_bounds) gf_mx2d_add_translation(&g_mat, (orig_bounds->x), (orig_bounds->y - orig_bounds->height)); gf_mx2d_add_matrix(&g_mat, &ctx->transform); - + raster->stencil_set_matrix(stencil, &g_mat); raster->stencil_set_color_matrix(stencil, ctx->col_mat); - /*MPEG-4/VRML context or no fill info*/ + /*MPEG-4/VRML context or no fill info*/ if (ctx->flags & CTX_HAS_APPEARANCE || !ctx->aspect.fill_color) raster->stencil_set_alpha(stencil, 0xFF); else @@ -300,18 +300,18 @@ void visual_2d_texture_path_text(GF_VisualManager *visual, DrawableContext *txt_ /*get original bounds*/ orig_rc = *object_bounds; - + /*get scaling ratio so that active texture view is stretched to original bounds (std 2D shape texture mapping in MPEG4)*/ sS = gf_divfix(orig_rc.width, INT2FIX(txh->width)); sT = gf_divfix(orig_rc.height, INT2FIX(txh->height)); - + gf_mx2d_init(gf_mx2d_txt); gf_mx2d_add_scale(&gf_mx2d_txt, sS, sT); /*move to bottom-left corner of bounds */ gf_mx2d_add_translation(&gf_mx2d_txt, (orig_rc.x), (orig_rc.y - orig_rc.height)); - /*move to final coordinate system*/ + /*move to final coordinate system*/ gf_mx2d_add_matrix(&gf_mx2d_txt, &txt_ctx->transform); /*set path transform, except for background2D node which is directly build in the final coord system*/ @@ -351,7 +351,7 @@ void visual_2d_texture_path_text(GF_VisualManager *visual, DrawableContext *txt_ #ifndef GPAC_DISABLE_3D void visual_2d_texture_path_opengl_auto(GF_VisualManager *visual, GF_Path *path, GF_TextureHandler *txh, struct _drawable_context *ctx, GF_Rect *orig_bounds, GF_Matrix2D *ext_mx, GF_TraverseState *tr_state) { - GF_Matrix mx; + GF_Rect clipper; u32 prev_mode = tr_state->traversing_mode; u32 prev_type_3d = tr_state->visual->type_3d; @@ -396,15 +396,10 @@ void visual_2d_texture_path_opengl_auto(GF_VisualManager *visual, GF_Path *path, assert(nb_obj_left_on_canvas); nb_obj_left_on_canvas--; } - } + } //erase all part of the canvas below us - if (!tr_state->immediate_draw) { - visual_2d_draw_path_extended(visual, ctx->drawable->path, ctx, NULL, NULL, tr_state, NULL, NULL, GF_TRUE); - //this part of the canvas is now dirty for next pass ! - if (!tr_state->immediate_draw) { - } - } + visual_2d_draw_path_extended(visual, ctx->drawable->path, ctx, NULL, NULL, tr_state, NULL, NULL, GF_TRUE); } ctx->bi->clip = rc; } @@ -423,20 +418,28 @@ void visual_2d_texture_path_opengl_auto(GF_VisualManager *visual, GF_Path *path, tr_state->visual->type_3d = 4; tr_state->appear = ctx->appear; - if (ctx->col_mat) gf_cmx_copy(&tr_state->color_mat, ctx->col_mat); + if (ctx->col_mat) gf_cmx_copy(&tr_state->color_mat, ctx->col_mat);// tr_state->traversing_mode=TRAVERSE_DRAW_3D; - gf_mx_from_mx2d(&mx, &ctx->transform); - visual_3d_matrix_push(visual); - visual_3d_matrix_add(visual, mx.m); + gf_mx_from_mx2d(&tr_state->model_matrix, &ctx->transform); + + + clipper.x = INT2FIX(ctx->bi->clip.x); + clipper.y = INT2FIX(ctx->bi->clip.y); + clipper.width = INT2FIX(ctx->bi->clip.width); + clipper.height = INT2FIX(ctx->bi->clip.height); + visual_3d_set_clipper_2d(tr_state->visual, clipper, NULL, 1); + gf_node_allow_cyclic_traverse(ctx->drawable->node); gf_node_traverse(ctx->drawable->node, tr_state); - visual_3d_matrix_pop(visual); + tr_state->visual->type_3d=prev_type_3d; tr_state->traversing_mode=prev_mode; if (ctx->col_mat) gf_cmx_init(&tr_state->color_mat); ctx->flags |= CTX_PATH_FILLED; + + visual_3d_reset_clipper_2d(tr_state->visual); } #endif @@ -468,7 +471,7 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF return; } - + #ifndef GPAC_DISABLE_3D if (visual->compositor->hybrid_opengl) { visual_2d_texture_path_opengl_auto(visual, path, txh, ctx, orig_bounds, ext_mx, tr_state); @@ -484,9 +487,9 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF if (!txh->width || !txh->height) { gf_mo_get_visual_info(txh->stream, &txh->width, &txh->height, &txh->stride, &txh->pixel_ar, &txh->pixelformat, &txh->is_flipped); /*in case the node is an MPEG-4 bitmap, force stack rebuild at next frame */ - gf_node_dirty_set(ctx->drawable->node, GF_SG_NODE_DIRTY, 1); + gf_node_dirty_set(ctx->drawable->node, GF_SG_NODE_DIRTY, 1); } - + if (compositor_texture_rectangles(visual, txh, &ctx->bi->clip, &ctx->bi->unclip, &src, &dst, NULL, NULL)) { if (txh->stream && gf_mo_set_position(txh->stream, &src, &dst)) { gf_mo_get_visual_info(txh->stream, &txh->width, &txh->height, &txh->stride, &txh->pixel_ar, &txh->pixelformat, &txh->is_flipped); @@ -495,8 +498,8 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF gf_sc_next_frame_state(visual->compositor, GF_SC_DRAW_FRAME); } } - - + + return; } @@ -517,7 +520,7 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF /*get scaling ratio so that active texture view is stretched to original bounds (std 2D shape texture mapping in MPEG4)*/ sS = orig_rc.width / txh->width; sT = orig_rc.height / txh->height; - + gf_mx2d_init(mx_texture); gf_mx2d_add_scale(&mx_texture, sS, sT); @@ -535,7 +538,7 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF if (ext_mx) gf_mx2d_add_matrix(&mx_texture, ext_mx); - /*move to final coordinate system (except background which is built directly in final coord system)*/ + /*move to final coordinate system (except background which is built directly in final coord system)*/ if (!(ctx->flags & CTX_IS_BACKGROUND) ) gf_mx2d_add_matrix(&mx_texture, &ctx->transform); /*set path transform*/ @@ -568,7 +571,7 @@ void visual_2d_texture_path_extended(GF_VisualManager *visual, GF_Path *path, GF raster->surface_set_path(visual->raster_surface, NULL); - + ctx->flags |= CTX_PATH_FILLED; } @@ -608,7 +611,7 @@ void visual_2d_draw_path_extended(GF_VisualManager *visual, GF_Path *path, Drawa return; } - if (! (ctx->flags & CTX_IS_BACKGROUND) ) + if (! (ctx->flags & CTX_IS_BACKGROUND) ) visual_2d_set_options(visual->compositor, visual->raster_surface, ctx->flags & CTX_IS_TEXT, ctx->flags & CTX_NO_ANTIALIAS); dofill = dostrike = 0; @@ -636,7 +639,7 @@ void visual_2d_draw_path_extended(GF_VisualManager *visual, GF_Path *path, Drawa #if ADAPTATION_SIZE if ((ctx->bi->clip.widthbi->clip.heightsurface_clear(visual->raster_surface, &ctx->bi->clip, ctx->aspect.fill_color); - } else + } else #endif { /*push path*/ @@ -649,11 +652,11 @@ void visual_2d_draw_path_extended(GF_VisualManager *visual, GF_Path *path, Drawa if (dostrike) { #if ADAPTATION_SIZE if ((ctx->bi->clip.widthbi->clip.heightraster_brush; raster->stencil_set_brush_color(pen, ctx->aspect.line_color); @@ -719,7 +722,7 @@ void visual_2d_fill_rect(GF_VisualManager *visual, DrawableContext *ctx, GF_Rect gf_path_add_line_to(path, rc->x+rc->width, rc->y); gf_path_add_line_to(path, rc->x, rc->y); gf_path_close(path); - + if (color) { /*push path*/ @@ -736,7 +739,7 @@ void visual_2d_fill_rect(GF_VisualManager *visual, DrawableContext *ctx, GF_Rect pen.join = GF_LINE_JOIN_BEVEL; pen.dash = GF_DASH_STYLE_DOT; raster->stencil_set_brush_color(visual->raster_brush, strike_color); - outline = gf_path_get_outline(path, pen); + outline = gf_path_get_outline(path, pen); outline->flags &= ~GF_PATH_FILL_ZERO_NONZERO; raster->surface_set_path(visual->raster_surface, outline); visual_2d_fill_path(visual, ctx, visual->raster_brush, tr_state, 0); @@ -790,7 +793,7 @@ void visual_2d_fill_irect(GF_VisualManager *visual, GF_IRect *rc, u32 fill, u32 pen.width = 2; pen.align = GF_PATH_LINE_INSIDE; pen.join = GF_LINE_JOIN_BEVEL; - outline = gf_path_get_outline(path, pen); + outline = gf_path_get_outline(path, pen); outline->flags &= ~GF_PATH_FILL_ZERO_NONZERO; raster->surface_set_path(visual->raster_surface, outline); diff --git a/src/compositor/visual_manager_3d.c b/src/compositor/visual_manager_3d.c index 020ee36..8a48919 100644 --- a/src/compositor/visual_manager_3d.c +++ b/src/compositor/visual_manager_3d.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -86,7 +86,7 @@ void drawable3d_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, // gf_sc_get_nodes_bounds(node, ((GF_ParentNode *)node)->children, tr_state, 1); gf_node_traverse_children(node, tr_state); - + tr_state->traversing_mode = prev_mode; gf_mx_copy(tr_state->model_matrix, cur); bounds = &tr_state->bbox; @@ -116,7 +116,7 @@ static void visual_3d_setup_traversing_state(GF_VisualManager *visual, GF_Traver /*main visual, set AR*/ if (visual->compositor->visual==visual) { if (tr_state->visual->compositor->has_size_info) { - tr_state->camera->vp.x = INT2FIX(tr_state->visual->compositor->vp_x); + tr_state->camera->vp.x = INT2FIX(tr_state->visual->compositor->vp_x); tr_state->camera->vp.y = INT2FIX(tr_state->visual->compositor->vp_y); tr_state->camera->vp.width = INT2FIX(tr_state->visual->compositor->vp_width); tr_state->camera->vp.height = INT2FIX(tr_state->visual->compositor->vp_height); @@ -135,9 +135,9 @@ static void visual_3d_setup_traversing_state(GF_VisualManager *visual, GF_Traver sh = INT2FIX(tr_state->visual->compositor->vp_height); /*AR changed, rebuild camera*/ - if (tr_state->visual->compositor->recompute_ar - || (sw!=tr_state->camera->vp.width) - || (sh!=tr_state->camera->vp.height)) { + if (tr_state->visual->compositor->recompute_ar + || (sw!=tr_state->camera->vp.width) + || (sh!=tr_state->camera->vp.height)) { tr_state->camera->width = tr_state->camera->vp.width = INT2FIX(tr_state->visual->compositor->vp_width); tr_state->camera->height = tr_state->camera->vp.height = INT2FIX(tr_state->visual->compositor->vp_height); tr_state->camera->flags |= CAM_IS_DIRTY; @@ -176,36 +176,35 @@ void visual_3d_viewpoint_change(GF_TraverseState *tr_state, GF_Node *vp, Bool an /*update znear&zfar*/ - tr_state->camera->z_near = tr_state->camera->avatar_size.x ; + tr_state->camera->z_near = tr_state->camera->avatar_size.x ; if (tr_state->camera->z_near<=0) tr_state->camera->z_near = FIX_ONE/2; /*if pixel metrics, the default znear may be way too far and lead to weird navigation*/ else if (tr_state->camera->z_near>=FIX_ONE) tr_state->camera->z_near = FIX_ONE/2; tr_state->camera->z_near /= 2; - tr_state->camera->z_far = tr_state->camera->visibility; + tr_state->camera->z_far = tr_state->camera->visibility; /*z_far is selected so that an object the size of the viewport measures - one pixel when located at the far plane. It can be found through the projection + one pixel when located at the far plane. It can be found through the projection transformation (projection matrix) of x and y - x transformation is: x'= (1/(ar*tg(fov/2)) )*x/z + x transformation is: x'= (1/(ar*tg(fov/2)) )*x/z y transformation is: y'=(1/(tg(fov/2)))*x/z - therefore when z=z_far and x=max(width/2, height/2), then + therefore when z=z_far and x=max(width/2, height/2), then x' = 1/max(vp_size.x, vp_size.y) (transformed OpenGL viewport measures one) this yields z_far = max(vp_size.x, vp_size.y) * max(width/2, height/2) * max(1/(ar*tg(fov/2)), 1/tg(fov/2)) z_far = max(vp_size.x, vp_size.y) * max(width, height) / (2*min(1, ar)*tg(fov/2)) ) - + to choose a z_far so that the size is more than one pixel, then z_far' = z_far/n_pixels*/ - //if (tr_state->camera->z_far<=0) - { + if (tr_state->camera->z_far<0) { Fixed ar = gf_divfix(tr_state->vp_size.x, tr_state->vp_size.y); if (ar>FIX_ONE) ar = FIX_ONE; tr_state->camera->z_far = gf_muldiv( - MAX(tr_state->vp_size.x,tr_state->vp_size.y), - MAX(tr_state->camera->width, tr_state->camera->height), - gf_mulfix(ar*2, gf_tan(fieldOfView/2)) - ); + MAX(tr_state->vp_size.x,tr_state->vp_size.y), + MAX(tr_state->camera->width, tr_state->camera->height), + gf_mulfix(ar*2, gf_tan(fieldOfView/2)) + ); /*fixed-point overflow*/ if (tr_state->camera->z_far <= tr_state->camera->z_near) { @@ -224,14 +223,14 @@ void visual_3d_viewpoint_change(GF_TraverseState *tr_state, GF_Node *vp, Bool an gf_mx_apply_vec(&mx, &local_center); } } - /*default VP setup - this is undocumented in the spec. Default VP pos is (0, 0, 10) but not really nice + /*default VP setup - this is undocumented in the spec. Default VP pos is (0, 0, 10) but not really nice in pixel metrics. We set z so that we see just the whole visual*/ else if (tr_state->pixel_metrics) { position.z = gf_divfix(tr_state->camera->width, 2*gf_tan(fieldOfView/2) ); - + } #ifdef GF_SR_USE_DEPTH - /* 3D world calibration for stereoscopic screen */ + /* 3D world calibration for stereoscopic screen */ if (tr_state->visual->compositor->auto_calibration && tr_state->visual->compositor->video_out->view_distance) { Fixed view_distance, disparity; @@ -253,10 +252,10 @@ void visual_3d_viewpoint_change(GF_TraverseState *tr_state, GF_Node *vp, Bool an position.z = view_distance; //near plane will match front side of the display's stereoscopic box - //-> n=D- (dD)/(e+d) - tr_state->camera->z_near = view_distance - - gf_divfix( gf_mulfix(disparity,view_distance), (half_interocular_dist_pixel + disparity)); - } + //-> n=D- (dD)/(e+d) + tr_state->camera->z_near = view_distance - + gf_divfix( gf_mulfix(disparity,view_distance), (half_interocular_dist_pixel + disparity)); + } else if (tr_state->visual->compositor->display_depth) { Fixed dist = INT2FIX(tr_state->visual->compositor->display_depth); if (dist<0) dist = INT2FIX(tr_state->visual->height); @@ -275,7 +274,7 @@ void visual_3d_viewpoint_change(GF_TraverseState *tr_state, GF_Node *vp, Bool an } } #endif - + gf_vec_diff(d, position, local_center); dist = gf_vec_len(d); @@ -283,7 +282,7 @@ void visual_3d_viewpoint_change(GF_TraverseState *tr_state, GF_Node *vp, Bool an if (dist > tr_state->camera->z_far) tr_state->camera->z_far = 2*dist; dist = 10 * tr_state->camera->avatar_size.x; - if ((distcamera->z_near) || (dist > tr_state->camera->z_far)) + if ((distcamera->z_near) || (dist > tr_state->camera->z_far)) dist = (tr_state->camera->avatar_size.x + tr_state->camera->z_far) / 5; } tr_state->camera->vp_dist = dist; @@ -311,46 +310,48 @@ void visual_3d_setup_projection(GF_TraverseState *tr_state, Bool is_layer) if (Bindable_GetIsBound(bindable)) { gf_node_traverse(bindable, tr_state); tr_state->camera->had_viewpoint = 1; - } else + } else #endif - if (tr_state->camera->had_viewpoint) { - u32 had_vp = tr_state->camera->had_viewpoint; - tr_state->camera->had_viewpoint = 0; - if (tr_state->camera->is_3D) { - SFVec3f pos, center; - SFRotation r; - Fixed fov = GF_PI/4; + if (tr_state->camera->had_viewpoint) { + u32 had_vp = tr_state->camera->had_viewpoint; + tr_state->camera->had_viewpoint = 0; + if (tr_state->camera->is_3D) { + SFVec3f pos, center; + SFRotation r; + Fixed fov = GF_PI/4; #ifdef GF_SR_USE_DEPTH - /* 3D world calibration for stereoscopic screen */ - if (tr_state->visual->compositor->auto_calibration && tr_state->visual->compositor->video_out->view_distance) { - /*get view distance in pixels*/ - Fixed view_distance = tr_state->visual->compositor->video_out->view_distance * tr_state->visual->compositor->video_out->dpi_x; - view_distance = gf_divfix(view_distance , FLT2FIX(2.54f) ); + /* 3D world calibration for stereoscopic screen */ + if (tr_state->visual->compositor->auto_calibration && tr_state->visual->compositor->video_out->view_distance) { + /*get view distance in pixels*/ + Fixed view_distance = tr_state->visual->compositor->video_out->view_distance * tr_state->visual->compositor->video_out->dpi_x; + view_distance = gf_divfix(view_distance , FLT2FIX(2.54f) ); - fov = 2*gf_atan2( INT2FIX(tr_state->visual->compositor->video_out->max_screen_width)/2, view_distance); - } + fov = 2*gf_atan2( INT2FIX(tr_state->visual->compositor->video_out->max_screen_width)/2, view_distance); + } #endif - /*default viewpoint*/ - pos.x = pos.y = 0; pos.z = INT2FIX(10); - center.x = center.y = center.z = 0; - r.q = r.x = r.z = 0; r.y = FIX_ONE; - /*this takes care of pixelMetrics*/ - visual_3d_viewpoint_change(tr_state, NULL, 0, fov, pos, r, center); - /*initial vp compute, don't animate*/ - if (had_vp == 2) { - camera_stop_anim(tr_state->camera); - camera_reset_viewpoint(tr_state->camera, 0); - /*scene not yet ready, force a recompute of world bounds at next frame*/ - if (!is_layer && gf_sc_fit_world_to_screen(tr_state->visual->compositor) == 0) { - tr_state->camera->had_viewpoint = 2; + /*default viewpoint*/ + pos.x = pos.y = 0; + pos.z = INT2FIX(10); + center.x = center.y = center.z = 0; + r.q = r.x = r.z = 0; + r.y = FIX_ONE; + /*this takes care of pixelMetrics*/ + visual_3d_viewpoint_change(tr_state, NULL, 0, fov, pos, r, center); + /*initial vp compute, don't animate*/ + if (had_vp == 2) { + camera_stop_anim(tr_state->camera); + camera_reset_viewpoint(tr_state->camera, 0); + /*scene not yet ready, force a recompute of world bounds at next frame*/ + if (!is_layer && gf_sc_fit_world_to_screen(tr_state->visual->compositor) == 0) { + tr_state->camera->had_viewpoint = 2; + } } + } else { + tr_state->camera->flags &= ~CAM_HAS_VIEWPORT; + tr_state->camera->flags |= CAM_IS_DIRTY; } - } else { - tr_state->camera->flags &= ~CAM_HAS_VIEWPORT; - tr_state->camera->flags |= CAM_IS_DIRTY; } - } if (tr_state->visual->nb_views>1) { s32 view_idx; @@ -373,11 +374,10 @@ void visual_3d_setup_projection(GF_TraverseState *tr_state, Bool is_layer) camera_update(tr_state->camera, &tr_state->transform, tr_state->visual->center_coords); } - /*setup projection/modelview*/ - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->projection.m); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_load(tr_state->visual, tr_state->camera->modelview.m); + /*setup projection (we do this to avoidloading the projection matrix for each draw operation in non-GL3/GLES2 modes + modelview will be loaded at each object + */ + visual_3d_projection_matrix_modified(tr_state->visual); gf_mx_init(tr_state->model_matrix); tr_state->traversing_mode = mode; @@ -416,29 +416,29 @@ static void visual_3d_draw_background(GF_TraverseState *tr_state, u32 layer_type gf_node_traverse(bindable, tr_state); } /*clear if not in layer*/ - else + else #endif - if (!layer_type) { - SFColor col; - Fixed alpha = 0; - col.red = INT2FIX((tr_state->visual->compositor->back_color>>16)&0xFF) / 255; - col.green = INT2FIX((tr_state->visual->compositor->back_color>>8)&0xFF) / 255; - col.blue = INT2FIX((tr_state->visual->compositor->back_color)&0xFF) / 255; - /*if composite visual, clear with alpha = 0*/ - if (tr_state->visual==tr_state->visual->compositor->visual) { - alpha = FIX_ONE; - if (tr_state->visual->compositor->user && (tr_state->visual->compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT) ) { - alpha = 0; + if (!layer_type) { + SFColor col; + Fixed alpha = 0; + col.red = INT2FIX((tr_state->visual->compositor->back_color>>16)&0xFF) / 255; + col.green = INT2FIX((tr_state->visual->compositor->back_color>>8)&0xFF) / 255; + col.blue = INT2FIX((tr_state->visual->compositor->back_color)&0xFF) / 255; + /*if composite visual, clear with alpha = 0*/ + if (tr_state->visual==tr_state->visual->compositor->visual) { + alpha = FIX_ONE; + if (tr_state->visual->compositor->user && (tr_state->visual->compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT) ) { + alpha = 0; + } } + visual_3d_clear(tr_state->visual, col, alpha); } - visual_3d_clear(tr_state->visual, col, alpha); - } tr_state->traversing_mode = mode; } /*in off-axis, projection matrix is not aligned with view axis, however we need to draw the background -centered !! +centered !! In this case we draw the background before setting up the projection but after setting up scissor and Viewport*/ static void visual_3d_draw_background_on_axis(GF_TraverseState *tr_state, u32 layer_type) { @@ -447,18 +447,22 @@ static void visual_3d_draw_background_on_axis(GF_TraverseState *tr_state, u32 la Fixed ar = gf_divfix(cam->width, cam->height); tr_state->visual->camera_layout = 0; + gf_mx_copy(proj, cam->projection); + gf_mx_copy(model, cam->modelview); - gf_mx_perspective(&proj, cam->fieldOfView, ar, cam->z_near, cam->z_far); - /*setup modelview*/ - gf_mx_lookat(&model, cam->position, cam->target, cam->up); + gf_mx_perspective(&cam->projection, cam->fieldOfView, ar, cam->z_near, cam->z_far); + visual_3d_projection_matrix_modified(tr_state->visual); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_PROJECTION); - visual_3d_matrix_load(tr_state->visual, proj.m); - visual_3d_set_matrix_mode(tr_state->visual, V3D_MATRIX_MODELVIEW); - visual_3d_matrix_load(tr_state->visual, model.m); + /*setup modelview*/ + gf_mx_lookat(&cam->modelview, cam->position, cam->target, cam->up); visual_3d_draw_background(tr_state, layer_type); + tr_state->visual->camera_layout = GF_3D_CAMERA_OFFAXIS; + gf_mx_copy(cam->projection, proj); + gf_mx_copy(cam->modelview, model); + + } void visual_3d_init_draw(GF_TraverseState *tr_state, u32 layer_type) @@ -476,45 +480,47 @@ void visual_3d_init_draw(GF_TraverseState *tr_state, u32 layer_type) if (Bindable_GetIsBound(bindable)) { gf_node_traverse(bindable, tr_state); tr_state->camera->had_nav_info = 1; - } else + } else #endif - if (tr_state->camera->had_nav_info) { - /*if no navigation specified, use default VRML one*/ - tr_state->camera->avatar_size.x = FLT2FIX(0.25f); tr_state->camera->avatar_size.y = FLT2FIX(1.6f); tr_state->camera->avatar_size.z = FLT2FIX(0.75f); - tr_state->camera->visibility = 0; - tr_state->camera->speed = FIX_ONE; - /*not specified in the spec, but by default we forbid navigation in layer*/ - if (layer_type) { - tr_state->camera->navigation_flags = NAV_HEADLIGHT; - tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; - } else { - tr_state->camera->navigation_flags = NAV_ANY | NAV_HEADLIGHT; - if (tr_state->camera->is_3D) { - if (tr_state->visual->compositor->default_navigation_mode != GF_NAVIGATE_NONE) { - tr_state->camera->navigate_mode = tr_state->visual->compositor->default_navigation_mode; - } else { - /*X3D is by default examine, VRML/MPEG4 is WALK*/ - tr_state->camera->navigate_mode = (tr_state->visual->type_3d==3) ? GF_NAVIGATE_EXAMINE : GF_NAVIGATE_WALK; - } - + if (tr_state->camera->had_nav_info) { + /*if no navigation specified, use default VRML one*/ + tr_state->camera->avatar_size.x = FLT2FIX(0.25f); + tr_state->camera->avatar_size.y = FLT2FIX(1.6f); + tr_state->camera->avatar_size.z = FLT2FIX(0.75f); + tr_state->camera->visibility = 0; + tr_state->camera->speed = FIX_ONE; + /*not specified in the spec, but by default we forbid navigation in layer*/ + if (layer_type) { + tr_state->camera->navigation_flags = NAV_HEADLIGHT; + tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; + } else { + tr_state->camera->navigation_flags = NAV_ANY | NAV_HEADLIGHT; + if (tr_state->camera->is_3D) { + if (tr_state->visual->compositor->default_navigation_mode != GF_NAVIGATE_NONE) { + tr_state->camera->navigate_mode = tr_state->visual->compositor->default_navigation_mode; + } else { + /*X3D is by default examine, VRML/MPEG4 is WALK*/ + tr_state->camera->navigate_mode = (tr_state->visual->type_3d==3) ? GF_NAVIGATE_EXAMINE : GF_NAVIGATE_WALK; + } + #ifdef GF_SR_USE_DEPTH -/* if (tr_state->visual->compositor->display_depth) - tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; -*/ + /* if (tr_state->visual->compositor->display_depth) + tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; + */ #endif - } else { - tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; + } else { + tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; + } } - } - tr_state->camera->had_nav_info = 0; + tr_state->camera->had_nav_info = 0; - if (tr_state->pixel_metrics) { - tr_state->camera->visibility = gf_mulfix(tr_state->camera->visibility, tr_state->min_hsize); - tr_state->camera->avatar_size.x = gf_mulfix(tr_state->camera->avatar_size.x, tr_state->min_hsize); - tr_state->camera->avatar_size.y = gf_mulfix(tr_state->camera->avatar_size.y, tr_state->min_hsize); - tr_state->camera->avatar_size.z = gf_mulfix(tr_state->camera->avatar_size.z, tr_state->min_hsize); + if (tr_state->pixel_metrics) { + tr_state->camera->visibility = gf_mulfix(tr_state->camera->visibility, tr_state->min_hsize); + tr_state->camera->avatar_size.x = gf_mulfix(tr_state->camera->avatar_size.x, tr_state->min_hsize); + tr_state->camera->avatar_size.y = gf_mulfix(tr_state->camera->avatar_size.y, tr_state->min_hsize); + tr_state->camera->avatar_size.z = gf_mulfix(tr_state->camera->avatar_size.z, tr_state->min_hsize); + } } - } /*animate current camera - if returns TRUE draw next frame*/ if (camera_animate(tr_state->camera)) { @@ -526,13 +532,10 @@ void visual_3d_init_draw(GF_TraverseState *tr_state, u32 layer_type) /*turn off depth buffer in 2D*/ visual_3d_enable_depth_buffer(tr_state->visual, tr_state->camera->is_3D); - /*set headlight if any*/ - visual_3d_enable_headlight(tr_state->visual, (tr_state->camera->navigation_flags & NAV_HEADLIGHT) ? 1 : 0, tr_state->camera); - if (tr_state->visual->autostereo_type==GF_3D_STEREO_SIDE) { GF_Rect orig_vp; orig_vp = tr_state->camera->vp; - + tr_state->camera->vp.width = gf_divfix(tr_state->camera->vp.width, INT2FIX(tr_state->visual->nb_views)); tr_state->camera->vp.x += gf_mulfix(INT2FIX(tr_state->visual->current_view), tr_state->camera->vp.width); @@ -550,7 +553,7 @@ void visual_3d_init_draw(GF_TraverseState *tr_state, u32 layer_type) } else if (tr_state->visual->autostereo_type==GF_3D_STEREO_TOP) { GF_Rect orig_vp; orig_vp = tr_state->camera->vp; - + tr_state->camera->vp.height = gf_divfix(tr_state->camera->vp.height, INT2FIX(tr_state->visual->nb_views)); tr_state->camera->vp.y += gf_mulfix(INT2FIX(tr_state->visual->current_view), tr_state->camera->vp.height); // tr_state->camera->vp.y = orig_vp.height - tr_state->camera->vp.height - tr_state->camera->vp.y; @@ -584,11 +587,18 @@ void visual_3d_init_draw(GF_TraverseState *tr_state, u32 layer_type) visual_3d_clear_depth(tr_state->visual); } } + /*regular background draw*/ if (!tr_state->camera->is_3D || tr_state->visual->camera_layout != GF_3D_CAMERA_OFFAXIS) { visual_3d_draw_background(tr_state, layer_type); } + /*set headlight if any*/ + if (tr_state->visual->type_3d>1) { + visual_3d_enable_headlight(tr_state->visual, (tr_state->camera->navigation_flags & NAV_HEADLIGHT) ? 1 : 0, tr_state->camera); + } + + visual_3d_set_scissor(tr_state->visual, NULL); } @@ -597,7 +607,7 @@ static GFINLINE Bool visual_3d_has_alpha(GF_TraverseState *tr_state, GF_Node *ge { Bool is_mat3D; Drawable3D *stack; - + is_mat3D = 0; #ifndef GPAC_DISABLE_VRML @@ -660,20 +670,17 @@ void visual_3d_register_context(GF_TraverseState *tr_state, GF_Node *geometry) tr_state->traversing_mode = TRAVERSE_DRAW_3D; /*layout/form clipper, set it in world coords only*/ if (tr_state->has_clip) { - visual_3d_matrix_push(tr_state->visual); - visual_3d_matrix_reset(tr_state->visual); - visual_3d_set_clipper_2d(tr_state->visual, tr_state->clipper); - visual_3d_matrix_pop(tr_state->visual); + visual_3d_set_clipper_2d(tr_state->visual, tr_state->clipper, NULL, 0); } - + gf_node_traverse(geometry, tr_state); /*clear appearance flag once drawn in 3D - not doing so would prevent - dirty flag propagation in the tree, whcih would typically prevent redrawing + dirty flag propagation in the tree, whcih would typically prevent redrawing layers/offscreen groups when texture changes*/ if (tr_state->appear) gf_node_dirty_clear(tr_state->appear, 0); - + /*back to SORT*/ tr_state->traversing_mode = TRAVERSE_SORT; @@ -693,7 +700,7 @@ void visual_3d_register_context(GF_TraverseState *tr_state, GF_Node *geometry) ctx->pixel_metrics = tr_state->pixel_metrics; ctx->text_split_idx = tr_state->text_split_idx; - + i=0; while ((ol = (DirectionalLightContext*)gf_list_enum(tr_state->local_lights, &i))) { nl = (DirectionalLightContext*)gf_malloc(sizeof(DirectionalLightContext)); @@ -709,7 +716,7 @@ void visual_3d_register_context(GF_TraverseState *tr_state, GF_Node *geometry) /*get bbox and and insert from further to closest*/ tr_state->bbox = drawable->mesh->bounds; - + gf_mx_apply_bbox(&ctx->model_matrix, &tr_state->bbox); gf_mx_apply_bbox(&tr_state->camera->modelview, &tr_state->bbox); ctx->zmax = tr_state->bbox.max_edge.z; @@ -742,32 +749,29 @@ void visual_3d_flush_contexts(GF_VisualManager *visual, GF_TraverseState *tr_sta DirectionalLightContext *dl; Drawable3DContext *ctx = (Drawable3DContext *)gf_list_get(visual->alpha_nodes_to_draw, idx); - visual_3d_matrix_push(visual); - /*apply directional lights*/ tr_state->local_light_on = 1; i=0; while ((dl = (DirectionalLightContext*)gf_list_enum(ctx->directional_lights, &i))) { - visual_3d_matrix_push(visual); - visual_3d_matrix_add(visual, dl->light_matrix.m); + GF_Matrix mx; + gf_mx_copy(mx, tr_state->model_matrix); + + gf_mx_add_matrix(&tr_state->model_matrix, &dl->light_matrix); gf_node_traverse(dl->dlight, tr_state); - visual_3d_matrix_pop(visual); + + gf_mx_copy(tr_state->model_matrix, mx); } - + /*clipper, set it in world coords only*/ if (ctx->has_clipper) { - visual_3d_matrix_push(visual); - visual_3d_matrix_reset(visual); - visual_3d_set_clipper_2d(visual, ctx->clipper); - visual_3d_matrix_pop(visual); + visual_3d_set_clipper_2d(visual, ctx->clipper, NULL, 0); } /*clip planes, set it in world coords only*/ for (i=0; inum_clip_planes; i++) - visual_3d_set_clip_plane(visual, ctx->clip_planes[i]); + visual_3d_set_clip_plane(visual, ctx->clip_planes[i], NULL, 0); /*restore traversing state*/ - visual_3d_matrix_add(visual, ctx->model_matrix.m); memcpy(&tr_state->model_matrix, &ctx->model_matrix, sizeof(GF_Matrix)); tr_state->color_mat.identity = ctx->color_mat.identity; if (!tr_state->color_mat.identity) memcpy(&tr_state->color_mat, &ctx->color_mat, sizeof(GF_ColorMatrix)); @@ -783,7 +787,7 @@ void visual_3d_flush_contexts(GF_VisualManager *visual, GF_TraverseState *tr_sta gf_node_traverse(ctx->geometry, tr_state); /*clear appearance flag once drawn in 3D - not doing so would prevent - dirty flag propagation in the tree, whcih would typically prevent redrawing + dirty flag propagation in the tree, whcih would typically prevent redrawing layers/offscreen groups when texture changes*/ if (tr_state->appear) { gf_node_dirty_clear(tr_state->appear, 0); @@ -801,8 +805,6 @@ void visual_3d_flush_contexts(GF_VisualManager *visual, GF_TraverseState *tr_sta if (ctx->has_clipper) visual_3d_reset_clipper_2d(visual); for (i=0; inum_clip_planes; i++) visual_3d_reset_clip_plane(visual); - visual_3d_matrix_pop(visual); - /*and destroy*/ gf_list_del(ctx->directional_lights); gf_free(ctx); @@ -820,7 +822,7 @@ static void visual_3d_draw_node(GF_TraverseState *tr_state, GF_Node *root_node) visual_3d_init_draw(tr_state, 0); /*main visual, handle collisions*/ - if ((tr_state->visual==tr_state->visual->compositor->visual) && tr_state->camera->is_3D) + if ((tr_state->visual==tr_state->visual->compositor->visual) && tr_state->camera->is_3D) visual_3d_check_collisions(tr_state, NULL); #ifndef GPAC_DISABLE_VRML @@ -835,7 +837,7 @@ static void visual_3d_draw_node(GF_TraverseState *tr_state, GF_Node *root_node) tr_state->traversing_mode = TRAVERSE_LIGHTING; gf_node_traverse(root_node, tr_state); } - + /*sort graph*/ tr_state->traversing_mode = TRAVERSE_SORT; gf_node_traverse(root_node, tr_state); @@ -854,7 +856,7 @@ Bool visual_3d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseSt #endif visual_3d_setup(visual); - + /*setup our traversing state*/ visual_3d_setup_traversing_state(visual, tr_state); @@ -869,14 +871,14 @@ Bool visual_3d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseSt #ifndef GPAC_USE_OGL_ES visual_3d_init_yuv_shader(visual); #endif - + for (visual->current_view=0; visual->current_view < visual->nb_views; visual->current_view++) { GF_SceneGraph *sg; u32 i; visual_3d_draw_node(tr_state, root); /*extra scene graphs*/ - i=0; + i=0; while ((sg = (GF_SceneGraph*)gf_list_enum(visual->compositor->extra_scenes, &i))) { tr_state->traversing_mode = TRAVERSE_SORT; gf_sc_traverse_subscene(visual->compositor, root, sg, tr_state); @@ -893,7 +895,7 @@ Bool visual_3d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseSt visual_3d_draw_node(tr_state, root); } GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("[RTI] Frame\t%d\t3D drawn in \t%d\tms\n", visual->compositor->frame_number, gf_sys_clock() - time)); - + return 1; } @@ -936,7 +938,7 @@ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *no gf_vec_diff(dir, tr_state->camera->position, tr_state->camera->last_pos); pos_diff = gf_vec_len(dir); gf_vec_norm(&dir); - + diff = 0; go = 1; tr_state->camera->last_had_col = 0; @@ -952,8 +954,8 @@ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *no diff += pos_diff; go = 0; } - n = gf_vec_scale(dir, diff); - gf_vec_add(tr_state->camera->position, tr_state->camera->last_pos, n); + n = gf_vec_scale(dir, diff); + gf_vec_add(tr_state->camera->position, tr_state->camera->last_pos, n); if (!node_list) { gf_node_traverse(gf_sg_get_root_node(tr_state->visual->compositor->scene), tr_state); } else { @@ -974,13 +976,13 @@ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *no tr_state->camera->position = tr_state->camera->last_pos; tr_state->camera->flags |= CAM_IS_DIRTY; } else { - if ((tr_state->camera->jumping && fabs(diff)>tr_state->camera->dheight) - || (!tr_state->camera->jumping && (ABS(diff)>FIX_ONE/1000) )) { + if ((tr_state->camera->jumping && fabs(diff)>tr_state->camera->dheight) + || (!tr_state->camera->jumping && (ABS(diff)>FIX_ONE/1000) )) { tr_state->camera->last_had_ground = 1; n = gf_vec_scale(tr_state->camera->up, -diff); - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Ground detected camera position: %g %g %g - offset: %g %g %g (dist %g)\n", - FIX2FLT(tr_state->camera->position.x), FIX2FLT(tr_state->camera->position.y), FIX2FLT(tr_state->camera->position.z), - FIX2FLT(n.x), FIX2FLT(n.y), FIX2FLT(n.z), FIX2FLT(diff))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Ground detected camera position: %g %g %g - offset: %g %g %g (dist %g)\n", + FIX2FLT(tr_state->camera->position.x), FIX2FLT(tr_state->camera->position.y), FIX2FLT(tr_state->camera->position.z), + FIX2FLT(n.x), FIX2FLT(n.y), FIX2FLT(n.z), FIX2FLT(diff))); gf_vec_add(tr_state->camera->position, tr_state->camera->position, n); gf_vec_add(tr_state->camera->target, tr_state->camera->target, n); @@ -1016,9 +1018,9 @@ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *no gf_vec_diff(n, tr_state->camera->position, tr_state->camera->collide_point); gf_vec_norm(&n); n = gf_vec_scale(n, tr_state->camera->avatar_size.x - tr_state->camera->collide_dist); - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] offseting camera: position: %g %g %g - offset: %g %g %g\n", - FIX2FLT(tr_state->camera->position.x), FIX2FLT(tr_state->camera->position.y), FIX2FLT(tr_state->camera->position.z), - FIX2FLT(n.x), FIX2FLT(n.y), FIX2FLT(n.z))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] offseting camera: position: %g %g %g - offset: %g %g %g\n", + FIX2FLT(tr_state->camera->position.x), FIX2FLT(tr_state->camera->position.y), FIX2FLT(tr_state->camera->position.z), + FIX2FLT(n.x), FIX2FLT(n.y), FIX2FLT(n.z))); gf_vec_add(tr_state->camera->position, tr_state->camera->position, n); gf_vec_add(tr_state->camera->target, tr_state->camera->target, n); @@ -1042,13 +1044,13 @@ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *no //#define DISABLE_VIEW_CULL #ifndef GPAC_DISABLE_LOG -static const char *szPlaneNames [] = +static const char *szPlaneNames [] = { "Near", "Far", "Left", "Right", "Bottom", "Top" }; #endif -Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_near) +Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_near) { #ifdef DISABLE_VIEW_CULL tr_state->cull_flag = CULL_INSIDE; @@ -1073,7 +1075,7 @@ Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_ne /*get bbox sphere in world space*/ b = *bbox; - gf_mx_apply_bbox_sphere(&tr_state->model_matrix, &b); + gf_mx_apply_bbox_sphere(&tr_state->model_matrix, &b); cam = tr_state->camera; /*if camera is inside bbox consider we intersect*/ @@ -1093,12 +1095,12 @@ Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_ne } } - /*second check: sphere vs frustum planes intersection, if any intersection is detected switch + /*second check: sphere vs frustum planes intersection, if any intersection is detected switch to n/p vertex check.*/ rad = b.radius; irad = -b.radius; do_sphere = 1; - + /*skip near/far tests in ortho mode, and near in 3D*/ i = (tr_state->camera->is_3D) ? (skip_near ? 1 : 0) : 2; for (; i<6; i++) { @@ -1130,7 +1132,7 @@ Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_ne GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Culling] Node out (p-vertex test) plane %s - Distance %g\n", szPlaneNames[i], FIX2FLT(d) )); return 0; } - + /*check n-vertex: if not in plane, we're intersecting - don't check for near and far planes*/ if (i>1) { d = gf_plane_get_distance(&cam->planes[i], &vertices[7-p_idx]); @@ -1157,7 +1159,8 @@ void visual_3d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, G visual_3d_setup_traversing_state(visual, tr_state); visual_3d_setup_projection(tr_state, 0); - x = INT2FIX(ev->mouse.x); y = INT2FIX(ev->mouse.y); + x = INT2FIX(ev->mouse.x); + y = INT2FIX(ev->mouse.y); /*if coordinate system is not centered, move to centered coord before applying camera transform because the (un)projection matrices include this transform*/ @@ -1178,7 +1181,7 @@ void visual_3d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, G start.z = visual->camera.z_near; end.z = visual->camera.z_far; if (!tr_state->camera->is_3D && !tr_state->pixel_metrics) { - start.x = end.x = gf_divfix(x, tr_state->min_hsize); + start.x = end.x = gf_divfix(x, tr_state->min_hsize); start.y = end.y = gf_divfix(y, tr_state->min_hsize); } else { start.x = end.x = x; @@ -1188,27 +1191,37 @@ void visual_3d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, G /*unproject to world coords*/ in_x = 2*x/ (s32) visual->width; in_y = 2*y/ (s32) visual->height; - - res.x = in_x; res.y = in_y; res.z = -FIX_ONE; res.q = FIX_ONE; + + res.x = in_x; + res.y = in_y; + res.z = -FIX_ONE; + res.q = FIX_ONE; gf_mx_apply_vec_4x4(&visual->camera.unprojection, &res); if (!res.q) return; - start.x = gf_divfix(res.x, res.q); start.y = gf_divfix(res.y, res.q); start.z = gf_divfix(res.z, res.q); - - res.x = in_x; res.y = in_y; res.z = FIX_ONE; res.q = FIX_ONE; + start.x = gf_divfix(res.x, res.q); + start.y = gf_divfix(res.y, res.q); + start.z = gf_divfix(res.z, res.q); + + res.x = in_x; + res.y = in_y; + res.z = FIX_ONE; + res.q = FIX_ONE; gf_mx_apply_vec_4x4(&visual->camera.unprojection, &res); if (!res.q) return; - end.x = gf_divfix(res.x, res.q); end.y = gf_divfix(res.y, res.q); end.z = gf_divfix(res.z, res.q); + end.x = gf_divfix(res.x, res.q); + end.y = gf_divfix(res.y, res.q); + end.z = gf_divfix(res.z, res.q); tr_state->ray = gf_ray(start, end); /*also update hit info world ray in case we have a grabbed sensor with mouse off*/ visual->compositor->hit_world_ray = tr_state->ray; - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Picking] cast ray\n\tOrigin %.4f %.4f %.4f - End %.4f %.4f %.4f\n\tDir %.4f %.4f %.4f\n", - FIX2FLT(tr_state->ray.orig.x), FIX2FLT(tr_state->ray.orig.y), FIX2FLT(tr_state->ray.orig.z), - FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z), - FIX2FLT(tr_state->ray.dir.x), FIX2FLT(tr_state->ray.dir.y), FIX2FLT(tr_state->ray.dir.z))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Picking] cast ray\n\tOrigin %.4f %.4f %.4f - End %.4f %.4f %.4f\n\tDir %.4f %.4f %.4f\n", + FIX2FLT(tr_state->ray.orig.x), FIX2FLT(tr_state->ray.orig.y), FIX2FLT(tr_state->ray.orig.z), + FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z), + FIX2FLT(tr_state->ray.dir.x), FIX2FLT(tr_state->ray.dir.y), FIX2FLT(tr_state->ray.dir.z))); + - visual->compositor->hit_square_dist = 0; visual->compositor->hit_node = NULL; @@ -1227,7 +1240,7 @@ void visual_3d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, G #ifndef GPAC_DISABLE_VRML -void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mesh *mesh, Drawable *drawable) +void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mesh *mesh, Drawable *drawable) { SFVec3f local_pt, world_pt, vdiff; SFVec3f hit_normal; @@ -1247,7 +1260,7 @@ void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mes node_is_over = 0; if (mesh) { - if (mesh->mesh_type!=MESH_TRIANGLES) + if (mesh->mesh_type!=MESH_TRIANGLES) return; if (!visual_3d_node_cull(tr_state, &mesh->bounds, 0)) { tr_state->cull_flag = cull_bckup; @@ -1268,7 +1281,7 @@ void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mes gf_mx_apply_vec(&mx, &hit); p.normal = r.dir; p.d = -1 * gf_vec_dot(p.normal, hit); - if (mesh) + if (mesh) box = mesh->bounds; else gf_bbox_from_rect(&box, &drawable->path->bbox); @@ -1283,7 +1296,8 @@ void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mes node_is_over = 0; if (compositor_get_2d_plane_intersection(&r, &local_pt)) { if (gf_path_point_over(drawable->path, local_pt.x, local_pt.y)) { - hit_normal.x = hit_normal.y = 0; hit_normal.z = FIX_ONE; + hit_normal.x = hit_normal.y = 0; + hit_normal.z = FIX_ONE; text_coords.x = gf_divfix(local_pt.x, drawable->path->bbox.width) + FIX_ONE/2; text_coords.y = gf_divfix(local_pt.y, drawable->path->bbox.height) + FIX_ONE/2; node_is_over = 1; @@ -1293,7 +1307,8 @@ void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mes if (asp.pen_props.width || asp.line_texture ) { StrikeInfo2D *si = drawable_get_strikeinfo(tr_state->visual->compositor, drawable, &asp, tr_state->appear, NULL, 0, NULL); if (si && si->outline && gf_path_point_over(si->outline, local_pt.x, local_pt.y)) { - hit_normal.x = hit_normal.y = 0; hit_normal.z = FIX_ONE; + hit_normal.x = hit_normal.y = 0; + hit_normal.z = FIX_ONE; text_coords.x = gf_divfix(local_pt.x, si->outline->bbox.width) + FIX_ONE/2; text_coords.y = gf_divfix(local_pt.y, si->outline->bbox.height) + FIX_ONE/2; node_is_over = 1; @@ -1346,7 +1361,7 @@ void visual_3d_vrml_drawable_pick(GF_Node *n, GF_TraverseState *tr_state, GF_Mes compositor->hit_node = n; compositor->hit_use_dom_events = 0; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Picking] node %s (def %s) is under mouse - hit %g %g %g\n", gf_node_get_class_name(n), gf_node_get_name(n), - FIX2FLT(world_pt.x), FIX2FLT(world_pt.y), FIX2FLT(world_pt.z))); + FIX2FLT(world_pt.x), FIX2FLT(world_pt.y), FIX2FLT(world_pt.z))); } @@ -1417,16 +1432,16 @@ void visual_3d_vrml_drawable_collide(GF_Node *node, GF_TraverseState *tr_state) tr_state->camera->collide_point = collide_pt; #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_COMPOSE, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_COMPOSE, GF_LOG_DEBUG)) { gf_vec_diff(v1, pos, collide_pt); gf_vec_norm(&v1); - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] found at %g %g %g (WC) - dist (%g) - local normal %g %g %g\n", - FIX2FLT(tr_state->camera->collide_point.x), FIX2FLT(tr_state->camera->collide_point.y), FIX2FLT(tr_state->camera->collide_point.z), - FIX2FLT(dist), - FIX2FLT(v1.x), FIX2FLT(v1.y), FIX2FLT(v1.z))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] found at %g %g %g (WC) - dist (%g) - local normal %g %g %g\n", + FIX2FLT(tr_state->camera->collide_point.x), FIX2FLT(tr_state->camera->collide_point.y), FIX2FLT(tr_state->camera->collide_point.z), + FIX2FLT(dist), + FIX2FLT(v1.x), FIX2FLT(v1.y), FIX2FLT(v1.z))); } #endif - } + } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Existing collision (dist %g) closer than current collsion (dist %g)\n", FIX2FLT(tr_state->camera->collide_dist), FIX2FLT(dist) )); } @@ -1449,15 +1464,15 @@ void visual_3d_vrml_drawable_collide(GF_Node *node, GF_TraverseState *tr_state) tr_state->camera->ground_dist = dist; tr_state->camera->collide_flags |= CF_GRAVITY; tr_state->camera->ground_point = collide_pt; - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Ground found at %g %g %g (WC) - dist %g - local normal %g %g %g\n", - FIX2FLT(tr_state->camera->ground_point.x), FIX2FLT(tr_state->camera->ground_point.y), FIX2FLT(tr_state->camera->ground_point.z), - FIX2FLT(dist), - FIX2FLT(v1.x), FIX2FLT(v1.y), FIX2FLT(v1.z))); - } + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Ground found at %g %g %g (WC) - dist %g - local normal %g %g %g\n", + FIX2FLT(tr_state->camera->ground_point.x), FIX2FLT(tr_state->camera->ground_point.y), FIX2FLT(tr_state->camera->ground_point.z), + FIX2FLT(dist), + FIX2FLT(v1.x), FIX2FLT(v1.y), FIX2FLT(v1.z))); + } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Collision] Existing ground (dist %g) closer than current (dist %g)\n", FIX2FLT(tr_state->camera->ground_dist), FIX2FLT(dist))); } - } + } } } @@ -1493,10 +1508,10 @@ void visual_3d_set_2d_strike(GF_TraverseState *tr_state, DrawAspect2D *asp) { if (asp->line_texture) { GF_Node *txtrans = NULL; - if (tr_state->appear - && (gf_node_get_tag( ((M_Appearance *)tr_state->appear)->material) == TAG_MPEG4_Material2D) - && (gf_node_get_tag(((M_Material2D *) ((M_Appearance *)tr_state->appear)->material)->lineProps) == TAG_MPEG4_XLineProperties) - ) { + if (tr_state->appear + && (gf_node_get_tag( ((M_Appearance *)tr_state->appear)->material) == TAG_MPEG4_Material2D) + && (gf_node_get_tag(((M_Material2D *) ((M_Appearance *)tr_state->appear)->material)->lineProps) == TAG_MPEG4_XLineProperties) + ) { txtrans = ((M_XLineProperties *) ((M_Material2D *) ((M_Appearance *)tr_state->appear)->material)->lineProps)->textureTransform; } @@ -1531,9 +1546,13 @@ void visual_3d_draw_2d_with_aspect(Drawable *st, GF_TraverseState *tr_state, Dra if (fill_txh || (GF_COL_A(asp->fill_color)) ) { if (!st->mesh) return; - if (asp->fill_color) + if (asp->fill_color) visual_3d_set_material_2d_argb(tr_state->visual, asp->fill_color); - + else if (GF_COL_A(asp->line_color) && !(asp->line_color & 0x00FFFFFF)) { + u32 col = asp->line_color | 0x00FFFFFF; + visual_3d_set_material_2d_argb(tr_state->visual, col); + } + visual_3d_mesh_paint(tr_state, st->mesh); /*reset texturing in case of line texture*/ if (tr_state->mesh_num_textures) { @@ -1556,7 +1575,7 @@ void visual_3d_draw_2d_with_aspect(Drawable *st, GF_TraverseState *tr_state, Dra #ifdef GPAC_HAS_GLU if (si->is_vectorial) { gf_mesh_tesselate_path(si->mesh_outline, si->outline, asp->line_texture ? 2 : 1); - } else + } else #endif mesh_get_outline(si->mesh_outline, st->path); } @@ -1572,7 +1591,7 @@ void visual_3d_draw_2d_with_aspect(Drawable *st, GF_TraverseState *tr_state, Dra if (asp->line_texture) { gf_sc_texture_disable(asp->line_texture); tr_state->mesh_num_textures = 0; - } + } } #ifndef GPAC_DISABLE_VRML @@ -1625,8 +1644,8 @@ static GFINLINE Bool visual_3d_setup_material(GF_TraverseState *tr_state, u32 me /*use material2D to disable lighting (cf VRML specs)*/ visual_3d_set_material_2d(tr_state->visual, def, FIX_ONE); return 1; - } - + } + switch (gf_node_get_tag((GF_Node *)__mat)) { case TAG_MPEG4_Material: #ifndef GPAC_DISABLE_X3D @@ -1696,7 +1715,7 @@ static GFINLINE Bool visual_3d_setup_material(GF_TraverseState *tr_state, u32 me vec[3] = spec_a; visual_3d_set_material(tr_state->visual, V3D_MATERIAL_SPECULAR, vec); - + vec[0] = emi.red; vec[1] = emi.green; vec[2] = emi.blue; @@ -1706,7 +1725,7 @@ static GFINLINE Bool visual_3d_setup_material(GF_TraverseState *tr_state, u32 me visual_3d_set_shininess(tr_state->visual, mat->shininess); if (diffuse_alpha) *diffuse_alpha = diff_a; } - break; + break; case TAG_MPEG4_Material2D: { SFColor emi; @@ -1735,8 +1754,8 @@ static GFINLINE Bool visual_3d_setup_material(GF_TraverseState *tr_state, u32 me /*regular mat 2D*/ visual_3d_set_state(tr_state->visual, V3D_STATE_LIGHT | V3D_STATE_COLOR, 0); visual_3d_set_material_2d(tr_state->visual, emi, emi_a); - } - break; + } + break; default: break; } @@ -1764,7 +1783,8 @@ Bool visual_3d_setup_texture(GF_TraverseState *tr_state, Fixed diffuse_alpha) switch (txh->pixelformat) { /*override diffuse color with full intensity, but keep material alpha (cf VRML lighting)*/ case GF_PIXEL_RGB_24: - v[0] = v[1] = v[2] = FIX_ONE; v[3] = diffuse_alpha; + v[0] = v[1] = v[2] = FIX_ONE; + v[3] = diffuse_alpha; visual_3d_set_material(tr_state->visual, V3D_MATERIAL_DIFFUSE, v); break; /*override diffuse color AND material alpha (cf VRML lighting)*/ @@ -1773,10 +1793,10 @@ Bool visual_3d_setup_texture(GF_TraverseState *tr_state, Fixed diffuse_alpha) visual_3d_set_material(tr_state->visual, V3D_MATERIAL_DIFFUSE, v); tr_state->mesh_is_transparent = 1; break; -/* case GF_PIXEL_GREYSCALE: - tr_state->mesh_num_textures = 2; - break; -*/ + /* case GF_PIXEL_GREYSCALE: + tr_state->mesh_num_textures = 2; + break; + */ } } return tr_state->mesh_num_textures; @@ -1815,7 +1835,7 @@ void visual_3d_draw(GF_TraverseState *tr_state, GF_Mesh *mesh) } else if (visual_3d_setup_appearance(tr_state)) { visual_3d_mesh_paint(tr_state, mesh); visual_3d_disable_texture(tr_state); - + #if !defined(GPAC_DISABLE_VRML) && !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) && !defined(GPAC_DISABLE_X3D) if (tr_state->appear && gf_node_get_tag(tr_state->appear)==TAG_X3D_Appearance) { X_Appearance *ap = (X_Appearance *)tr_state->appear; @@ -1826,6 +1846,205 @@ void visual_3d_draw(GF_TraverseState *tr_state, GF_Mesh *mesh) } } +void visual_3d_projection_matrix_modified(GF_VisualManager *visual) +{ + visual->needs_projection_matrix_reload = 1; +} + +void visual_3d_enable_headlight(GF_VisualManager *visual, Bool bOn, GF_Camera *cam) +{ + SFVec3f dir; + SFColor col; + + if (!bOn) return; + //if we have lights in the scene don't turn the headlight on + if (visual->has_inactive_lights || visual->num_lights) return; + col.blue = col.red = col.green = FIX_ONE; + dir.x = dir.y = 0; + dir.z = -FIX_ONE; + if (cam->is_3D) dir = camera_get_target_dir(cam); + + visual_3d_add_directional_light(visual, 0, col, FIX_ONE, dir, &cam->modelview); +} + +void visual_3d_set_material_2d(GF_VisualManager *visual, SFColor col, Fixed alpha) +{ + visual->has_mat_2d = alpha ? 1 : 0; + if (visual->has_mat_2d) { + visual->mat_2d.red = col.red; + visual->mat_2d.green = col.green; + visual->mat_2d.blue = col.blue; + visual->mat_2d.alpha = alpha; + } + +} + +void visual_3d_set_material_2d_argb(GF_VisualManager *visual, u32 col) +{ + u32 a = GF_COL_A(col); + visual->has_mat_2d = a ? 1 : 0; + if (visual->has_mat_2d) { + visual->mat_2d.red = INT2FIX( GF_COL_R(col) ) / 255; + visual->mat_2d.green = INT2FIX( GF_COL_G(col) ) / 255; + visual->mat_2d.blue = INT2FIX( GF_COL_B(col) ) / 255; + visual->mat_2d.alpha = INT2FIX( a ) / 255;; + } +} + +void visual_3d_set_clipper_2d(GF_VisualManager *visual, GF_Rect clip, GF_Matrix *mx_at_clipper, Bool is_2d_clip) +{ + GF_Plane p; + + if (visual->num_clips + 4 > visual->max_clips) + return; + + p.normal.z = 0; + p.normal.y = 0; + p.normal.x = -FIX_ONE; + p.d = clip.x + clip.width; + visual_3d_set_clip_plane(visual, p, mx_at_clipper, is_2d_clip); + + p.normal.x = FIX_ONE; + p.d = -clip.x; + visual_3d_set_clip_plane(visual, p, mx_at_clipper, is_2d_clip); + + p.normal.x = 0; + p.normal.y = -FIX_ONE; + p.d = clip.y; + visual_3d_set_clip_plane(visual, p, mx_at_clipper, is_2d_clip); + + p.normal.y = FIX_ONE; + p.d = clip.height - clip.y; + visual_3d_set_clip_plane(visual, p, mx_at_clipper, is_2d_clip); +} + +void visual_3d_reset_clipper_2d(GF_VisualManager *visual) +{ + if (visual->num_clips < 4) return; + visual->num_clips -= 4; +} + +void visual_3d_set_clip_plane(GF_VisualManager *visual, GF_Plane p, GF_Matrix *mx_at_clipper, Bool is_2d_clip) +{ + if (visual->num_clips==GF_MAX_GL_CLIPS) return; + gf_vec_norm(&p.normal); + visual->clippers[visual->num_clips].p = p; + visual->clippers[visual->num_clips].is_2d_clip = is_2d_clip; + visual->clippers[visual->num_clips].mx_clipper = mx_at_clipper; + visual->num_clips++; +} + +void visual_3d_reset_clip_plane(GF_VisualManager *visual) +{ + if (!visual->num_clips) return; + visual->num_clips -= 1; +} + +void visual_3d_set_material(GF_VisualManager *visual, u32 material_type, Fixed *rgba) +{ + visual->materials[material_type].red = rgba[0]; + visual->materials[material_type].green = rgba[1]; + visual->materials[material_type].blue = rgba[2]; + visual->materials[material_type].alpha = rgba[3]; + + visual->has_mat = 1; +} + +void visual_3d_set_shininess(GF_VisualManager *visual, Fixed shininess) +{ + visual->shininess = shininess; +} + +void visual_3d_set_state(GF_VisualManager *visual, u32 flag_mask, Bool setOn) +{ + if (flag_mask & V3D_STATE_LIGHT) visual->state_light_on = setOn; + if (flag_mask & V3D_STATE_BLEND) visual->state_blend_on = setOn; + if (flag_mask & V3D_STATE_COLOR) visual->state_color_on = setOn; +} + + +void visual_3d_set_texture_matrix(GF_VisualManager *visual, GF_Matrix *mx) +{ + visual->has_tx_matrix = mx ? 1 : 0; + if (mx) gf_mx_copy(visual->tx_matrix, *mx); +} + +void visual_3d_has_inactive_light(GF_VisualManager *visual) +{ + visual->has_inactive_lights = GF_TRUE; +} + +Bool visual_3d_add_point_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, SFColor color, Fixed intensity, SFVec3f location, GF_Matrix *light_mx) +{ + if (visual->num_lights==visual->max_lights) return 0; + visual->lights[visual->num_lights].type = 2; + visual->lights[visual->num_lights].ambientIntensity = ambientIntensity; + visual->lights[visual->num_lights].attenuation = attenuation; + visual->lights[visual->num_lights].color = color; + visual->lights[visual->num_lights].intensity = intensity; + visual->lights[visual->num_lights].position = location; + memcpy(&visual->lights[visual->num_lights].light_mx, light_mx, sizeof(GF_Matrix) ); + visual->num_lights++; + return 1; +} + +Bool visual_3d_add_spot_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, Fixed beamWidth, + SFColor color, Fixed cutOffAngle, SFVec3f direction, Fixed intensity, SFVec3f location, GF_Matrix *light_mx) +{ + if (visual->num_lights==visual->max_lights) return 0; + visual->lights[visual->num_lights].type = 1; + visual->lights[visual->num_lights].ambientIntensity = ambientIntensity; + visual->lights[visual->num_lights].attenuation = attenuation; + visual->lights[visual->num_lights].beamWidth = beamWidth; + visual->lights[visual->num_lights].cutOffAngle = cutOffAngle; + visual->lights[visual->num_lights].color = color; + visual->lights[visual->num_lights].direction = direction; + visual->lights[visual->num_lights].intensity = intensity; + visual->lights[visual->num_lights].position = location; + memcpy(&visual->lights[visual->num_lights].light_mx, light_mx, sizeof(GF_Matrix) ); + visual->num_lights++; + return 1; +} + +Bool visual_3d_add_directional_light(GF_VisualManager *visual, Fixed ambientIntensity, SFColor color, Fixed intensity, SFVec3f direction, GF_Matrix *light_mx) +{ + if (visual->num_lights==visual->max_lights) return 0; + visual->lights[visual->num_lights].type = 0; + visual->lights[visual->num_lights].ambientIntensity = ambientIntensity; + visual->lights[visual->num_lights].color = color; + visual->lights[visual->num_lights].intensity = intensity; + visual->lights[visual->num_lights].direction = direction; + memcpy(&visual->lights[visual->num_lights].light_mx, light_mx, sizeof(GF_Matrix) ); + visual->num_lights++; + return 1; +} + + +void visual_3d_remove_last_light(GF_VisualManager *visual) +{ + if (visual->num_lights) { + visual->num_lights--; + } +} + +void visual_3d_clear_all_lights(GF_VisualManager *visual) +{ + visual->num_lights = 0; + visual->has_inactive_lights = GF_FALSE; +} + +void visual_3d_set_fog(GF_VisualManager *visual, const char *type, SFColor color, Fixed density, Fixed visibility) +{ + visual->has_fog = GF_TRUE; + if (!type || !stricmp(type, "LINEAR")) visual->fog_type = 0; + else if (!stricmp(type, "EXPONENTIAL")) visual->fog_type = 1; + else if (!stricmp(type, "EXPONENTIAL2")) visual->fog_type = 2; + + visual->fog_color = color; + visual->fog_density = density; + visual->fog_visibility = visibility; +} #endif + diff --git a/src/compositor/visual_manager_3d.h b/src/compositor/visual_manager_3d.h index 4c083b7..3ca0323 100644 --- a/src/compositor/visual_manager_3d.h +++ b/src/compositor/visual_manager_3d.h @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -30,9 +30,13 @@ #ifndef GPAC_DISABLE_3D - /* - * Visual 3D functions - */ + +#define GF_MAX_GL_CLIPS 12 +#define GF_MAX_GL_LIGHTS 12 + +/* +* Visual 3D functions +*/ /*draw frame, performing collisions, camera displacement and drawing*/ Bool visual_3d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseState *tr_state, Bool is_root_visual); @@ -40,7 +44,7 @@ Bool visual_3d_draw_frame(GF_VisualManager *visual, GF_Node *root, GF_TraverseSt /*traverse the scene and picks the node under the current ray, if any*/ void visual_3d_pick_node(GF_VisualManager *visual, GF_TraverseState *tr_state, GF_Event *ev, GF_ChildNodeItem *children); -/*checks a bounding box against the visual frustum. Returns true if box is visible, false otherwise. +/*checks a bounding box against the visual frustum. Returns true if box is visible, false otherwise. The cull_flag of the traversing state is updated to the box/frustum relation (in/out/intersect)*/ Bool visual_3d_node_cull(GF_TraverseState *tr_state, GF_BBox *bbox, Bool skip_near); @@ -74,7 +78,7 @@ void visual_3d_draw_2d(Drawable *st, GF_TraverseState *tr_state); #endif -/*sets 2D strike aspect +/*sets 2D strike aspect - exported for text drawing*/ void visual_3d_set_2d_strike(GF_TraverseState *tr_state, DrawAspect2D *asp); /*sets 3D material. Returns false is object is not visible due to appearance @@ -83,7 +87,7 @@ Bool visual_3d_setup_appearance(GF_TraverseState *tr_state); /*sets 3D texture. Returns true if a texture is found and successfully bound - exported for text drawing*/ Bool visual_3d_setup_texture(GF_TraverseState *tr_state, Fixed diffuse_alpha); -/*disables texture +/*disables texture - exported for text drawing*/ void visual_3d_disable_texture(GF_TraverseState *tr_state); @@ -91,8 +95,8 @@ void visual_3d_disable_texture(GF_TraverseState *tr_state); - exported for Layer3D - try to harmonize*/ void visual_3d_check_collisions(GF_TraverseState *tr_state, GF_ChildNodeItem *node_list); -/*init drawing pass - exported for Layer3D - @layer_type: +/*init drawing pass - exported for Layer3D + @layer_type: 0: not a layer 1: 3D layer in 3D context, depth clear but no color clear 2: 3D layer in 2D context (offscreen rendering), depth and color clear with alpha=0 @@ -103,7 +107,7 @@ void visual_3d_setup_projection(GF_TraverseState *tr_state, Bool is_layer); /*base 3D drawable*/ -typedef struct +typedef struct { /*3D object for drawable if needed - ALLOCATED BY DEFAULT*/ GF_Mesh *mesh; @@ -119,7 +123,7 @@ void drawable_3d_base_traverse(GF_Node *n, void *rs, Bool is_destroy, void (*bui void drawable3d_check_focus_highlight(GF_Node *node, GF_TraverseState *tr_state, GF_BBox *orig_bounds); -typedef struct +typedef struct { /*the directional light*/ GF_Node *dlight; @@ -161,8 +165,29 @@ typedef struct #endif } Drawable3DContext; + +typedef struct +{ + //0: directional - 1: spot - 2: point + u32 type; + SFVec3f direction, position, attenuation; + Fixed ambientIntensity, intensity, beamWidth, cutOffAngle; + SFColor color; + GF_Matrix light_mx; +} GF_LightInfo; + + +typedef struct +{ + //0: directional - 1: spot - 2: point + GF_Plane p; + Bool is_2d_clip; + GF_Matrix *mx_clipper; +} GF_ClipInfo; + + /* - till end of file: all 3D specific calls. + till end of file: all 3D specific calls. */ /*setup visual (hint & co)*/ @@ -194,25 +219,13 @@ void visual_3d_clear_depth(GF_VisualManager *visual); /*turns background state on/off. When on, all quality options are disabled in order to draw as fast as possible*/ void visual_3d_set_background_state(GF_VisualManager *visual, Bool on); -/*matrix mode types*/ -enum -{ - V3D_MATRIX_MODELVIEW, - V3D_MATRIX_PROJECTION, - V3D_MATRIX_TEXTURE, -}; -/*set current matrix type*/ -void visual_3d_set_matrix_mode(GF_VisualManager *visual, u32 mat_type); -/*push matrix stack*/ -void visual_3d_matrix_push(GF_VisualManager *visual); -/*reset current matrix (identity)*/ -void visual_3d_matrix_reset(GF_VisualManager *visual); -/*multiply current matrix with given matrix (16 coefs)*/ -void visual_3d_matrix_add(GF_VisualManager *visual, Fixed *mat); -/*loads given matrix (16 coefs) as current one*/ -void visual_3d_matrix_load(GF_VisualManager *visual, Fixed *mat); -/*pop matrix stack*/ -void visual_3d_matrix_pop(GF_VisualManager *visual); + +void visual_3d_set_texture_matrix(GF_VisualManager *visual, GF_Matrix *mx); +//depending on platforms / GL rendering mode, the projection matrix is not loaded at each object Draw(). This function is used to notify a change +//in the projection matrix to force a reload of the camera's projection +void visual_3d_projection_matrix_modified(GF_VisualManager *visual); + + /*setup viewport (vp: top-left, width, height)*/ void visual_3d_set_viewport(GF_VisualManager *visual, GF_Rect vp); @@ -221,13 +234,20 @@ void visual_3d_set_scissor(GF_VisualManager *visual, GF_Rect *vp); /*setup rectangular cliper (clip: top-left, width, height) NOTE: 2D clippers can only be set from a 2D context, hence will always take the 4 first GL clip planes. -In order to allow multiple Layer2D in Layer2D, THERE IS ALWAYS AT MOST ONE 2D CLIPPER USED AT ANY TIME, -it is the caller responsability to restore previous 2D clipers*/ -void visual_3d_set_clipper_2d(GF_VisualManager *visual, GF_Rect clip); +In order to allow multiple Layer2D in Layer2D, THERE IS ALWAYS AT MOST ONE 2D CLIPPER USED AT ANY TIME, +it is the caller responsability to restore previous 2D clipers + +the matrix is not copied, care should be taken to keep it unmodified until the cliper is reset (unless desired otherwise) +if NULL, no specific clipping transform will be used*/ +void visual_3d_set_clipper_2d(GF_VisualManager *visual, GF_Rect clip, GF_Matrix *mx_at_clipper, Bool is_2d_clip); /*remove 2D clipper*/ void visual_3d_reset_clipper_2d(GF_VisualManager *visual); -/*set clipping plane*/ -void visual_3d_set_clip_plane(GF_VisualManager *visual, GF_Plane p); + +/*set clipping plane +the matrix is not copied, care should be taken to keep it unmodified until the cliper is reset (unless desired otherwise) +if NULL, no specific clipping transform will be used*/ +void visual_3d_set_clip_plane(GF_VisualManager *visual, GF_Plane p, GF_Matrix *mx_at_clipper, Bool is_2d_clip); + /*reset last clipping plane set*/ void visual_3d_reset_clip_plane(GF_VisualManager *visual); @@ -239,9 +259,7 @@ void visual_3d_mesh_strike(GF_TraverseState *tr_state, GF_Mesh *mesh, Fixed widt /*material types*/ enum { - /*default material*/ - V3D_MATERIAL_NONE, - V3D_MATERIAL_AMBIENT, + V3D_MATERIAL_AMBIENT=0, V3D_MATERIAL_DIFFUSE, V3D_MATERIAL_SPECULAR, V3D_MATERIAL_EMISSIVE, @@ -261,12 +279,15 @@ void visual_3d_remove_last_light(GF_VisualManager *visual); /*disables all lights*/ void visual_3d_clear_all_lights(GF_VisualManager *visual); /*insert spot light - returns 0 if too many lights*/ -Bool visual_3d_add_spot_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, Fixed beamWidth, - SFColor color, Fixed cutOffAngle, SFVec3f direction, Fixed intensity, SFVec3f location); +Bool visual_3d_add_spot_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, Fixed beamWidth, + SFColor color, Fixed cutOffAngle, SFVec3f direction, Fixed intensity, SFVec3f location, GF_Matrix *light_mx); /*insert point light - returns 0 if too many lights*/ -Bool visual_3d_add_point_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, SFColor color, Fixed intensity, SFVec3f location); +Bool visual_3d_add_point_light(GF_VisualManager *visual, Fixed ambientIntensity, SFVec3f attenuation, SFColor color, Fixed intensity, SFVec3f location, GF_Matrix *light_mx); /*insert directional light - returns 0 if too many lights*/ -Bool visual_3d_add_directional_light(GF_VisualManager *visual, Fixed ambientIntensity, SFColor color, Fixed intensity, SFVec3f direction); +Bool visual_3d_add_directional_light(GF_VisualManager *visual, Fixed ambientIntensity, SFColor color, Fixed intensity, SFVec3f direction, GF_Matrix *light_mx); + +void visual_3d_has_inactive_light(GF_VisualManager *visual); + /*set fog*/ void visual_3d_set_fog(GF_VisualManager *visual, const char *type, SFColor color, Fixed density, Fixed visibility); /*fill given rect with given color (used for text hilighting only) - context shall not be altered*/ @@ -276,20 +297,8 @@ void visual_3d_point_sprite(GF_VisualManager *visual, Drawable *stack, GF_Textur /*non-oglES functions*/ #ifndef GPAC_USE_OGL_ES - -/*draws image data: - pos_x, pos_y: top-left pos of image - width, height: size of image - pixelformat: image pixel format - data: image data - scale_x, scale_y: x & y scale -*/ -void visual_3d_draw_image(GF_VisualManager *visual, Fixed pos_x, Fixed pos_y, u32 width, u32 height, u32 pixelformat, char *data, Fixed scale_x, Fixed scale_y); -/*get matrix for the desired mode*/ -void visual_3d_matrix_get(GF_VisualManager *visual, u32 mat_type, Fixed *mat); /*X3D hatching*/ void visual_3d_mesh_hatch(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 hatchStyle, SFColor hatchColor); - #endif diff --git a/src/compositor/visual_manager_3d_gl.c b/src/compositor/visual_manager_3d_gl.c index 6c5be0f..bbe3195 100644 --- a/src/compositor/visual_manager_3d_gl.c +++ b/src/compositor/visual_manager_3d_gl.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -149,7 +149,7 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context #else const char *ext = NULL; - if (compositor->visual->type_3d || compositor->hybrid_opengl) + if (compositor->visual->type_3d || compositor->hybrid_opengl) ext = (const char *) glGetString(GL_EXTENSIONS); if (!ext) ext = gf_cfg_get_key(compositor->user->config, "Compositor", "OpenGLExtensions"); @@ -161,13 +161,13 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context memset(&compositor->gl_caps, 0, sizeof(GLCaps)); - if (CHECK_GL_EXT("GL_ARB_multisample") || CHECK_GL_EXT("GLX_ARB_multisample") || CHECK_GL_EXT("WGL_ARB_multisample")) + if (CHECK_GL_EXT("GL_ARB_multisample") || CHECK_GL_EXT("GLX_ARB_multisample") || CHECK_GL_EXT("WGL_ARB_multisample")) compositor->gl_caps.multisample = 1; - if (CHECK_GL_EXT("GL_ARB_texture_non_power_of_two")) + if (CHECK_GL_EXT("GL_ARB_texture_non_power_of_two")) compositor->gl_caps.npot_texture = 1; - if (CHECK_GL_EXT("GL_EXT_abgr")) + if (CHECK_GL_EXT("GL_EXT_abgr")) compositor->gl_caps.abgr_texture = 1; - if (CHECK_GL_EXT("GL_EXT_bgra")) + if (CHECK_GL_EXT("GL_EXT_bgra")) compositor->gl_caps.bgra_texture = 1; if (CHECK_GL_EXT("GL_ARB_point_parameters")) { @@ -192,7 +192,7 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context /*we have a GL context, init the rest (proc addresses & co)*/ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &compositor->gl_caps.max_texture_size); - + #ifdef LOAD_GL_1_3 if (CHECK_GL_EXT("GL_ARB_multitexture")) { GET_GLFUN(glActiveTexture); @@ -200,7 +200,7 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context } GET_GLFUN(glBlendEquation); #endif - + #ifdef LOAD_GL_1_4 if (compositor->gl_caps.point_sprite) { GET_GLFUN(glPointParameterf); @@ -219,7 +219,7 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context if (CHECK_GL_EXT("GL_ARB_pixel_buffer_object")) { GET_GLFUN(glMapBuffer); GET_GLFUN(glUnmapBuffer); - + compositor->gl_caps.pbo=1; } #endif @@ -229,7 +229,7 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context #ifdef LOAD_GL_2_0 GET_GLFUN(glCreateProgram); - + if (glCreateProgram != NULL) { GET_GLFUN(glDeleteProgram); GET_GLFUN(glLinkProgram); @@ -296,34 +296,14 @@ void gf_sc_load_opengl_extensions(GF_Compositor *compositor, Bool has_gl_context static char *default_glsl_vertex = "\ varying vec3 gfNormal;\ - varying vec3 gfView;\ varying vec2 TexCoord;\ void main(void)\ {\ - gfView = vec3(gl_ModelViewMatrix * gl_Vertex);\ gfNormal = normalize(gl_NormalMatrix * gl_Normal);\ + gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\ - TexCoord = gl_MultiTexCoord0.st;\ - }"; - -#ifdef GPAC_UNUSED_FUNC -static char *default_glsl_lighting = "\ - varying vec3 gfNormal;\ - varying vec3 gfView;\ - varying vec2 TexCoord;\ - void gpac_lighting (void) \ - { \ - vec3 L = normalize(gl_LightSource[0].position.xyz - gfView);\ - vec3 E = normalize(-gfView); \ - vec3 R = normalize(-reflect(L,gfNormal));\ - vec4 Iamb = gl_FrontLightProduct[0].ambient;\ - vec4 Idiff = gl_FrontLightProduct[0].diffuse * max(dot(gfNormal,L), 0.0);\ - Idiff = clamp(Idiff, 0.0, 1.0);\ - vec4 Ispec = gl_FrontLightProduct[0].specular * pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess);\ - Ispec = clamp(Ispec, 0.0, 1.0);\ - gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff + Ispec;\ + TexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);\ }"; -#endif /*GPAC_UNUSED_FUNC*/ static char *glsl_view_anaglyph = "\ uniform sampler2D gfView1;\ @@ -419,7 +399,6 @@ static char *glsl_yuv_shader = "\ vec2 texc;\n\ vec3 yuv, rgb;\n\ texc = TexCoord.st;\n\ - texc.y = 1.0 - texc.y;\n\ yuv.x = texture2D(y_plane, texc).r;\n\ yuv.y = texture2D(u_plane, texc).r;\n\ yuv.z = texture2D(v_plane, texc).r;\n\ @@ -451,7 +430,6 @@ static char *glsl_yuv_rect_shader_strict = "\ vec2 texc;\n\ vec3 yuv, rgb;\n\ texc = TexCoord.st;\n\ - texc.y = 1.0 - texc.y;\n\ texc.x *= width;\n\ texc.y *= height;\n\ yuv.x = texture2DRect(y_plane, texc).r;\n\ @@ -483,7 +461,6 @@ static char *glsl_yuv_rect_shader_relaxed= "\ vec2 texc;\n\ vec3 yuv, rgb;\n\ texc = TexCoord.st;\n\ - texc.y = 1.0 - texc.y;\n\ texc.x *= width;\n\ texc.y *= height;\n\ yuv.x = texture2DRect(y_plane, texc).r;\n\ @@ -501,15 +478,15 @@ static char *glsl_yuv_rect_shader_relaxed= "\ Bool visual_3d_compile_shader(GF_SHADERID shader_id, const char *name, const char *source) { - GLint blen = 0; + GLint blen = 0; GLsizei slen = 0; s32 len; if (!source || !shader_id) return 0; len = (u32) strlen(source); glShaderSource(shader_id, 1, &source, &len); glCompileShader(shader_id); - - glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH , &blen); + + glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH , &blen); if (blen > 1) { char* compiler_log = (char*) gf_malloc(blen); #ifdef CONFIG_DARWIN_GL @@ -518,7 +495,7 @@ Bool visual_3d_compile_shader(GF_SHADERID shader_id, const char *name, const cha glGetInfoLogARB(shader_id, blen, &slen, compiler_log); #endif GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[GLSL] Failed to compile shader %s: %s\n", name, compiler_log)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[GLSL] ***** faulty shader code ****\n%s\n**********************\n", source)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[GLSL] ***** faulty shader code ****\n%s\n**********************\n", source)); gf_free (compiler_log); return 0; } @@ -554,10 +531,10 @@ static GF_SHADERID visual_3d_shader_from_source_file(const char *src_path, u32 s void visual_3d_init_stereo_shaders(GF_VisualManager *visual) { - if (!visual->compositor->gl_caps.has_shaders) return; - + if (!visual->compositor->gl_caps.has_shaders) return; + if (visual->autostereo_glsl_program) return; - + visual->autostereo_glsl_program = glCreateProgram(); if (!visual->base_glsl_vertex) { @@ -589,12 +566,12 @@ void visual_3d_init_stereo_shaders(GF_VisualManager *visual) visual->autostereo_glsl_fragment = visual_3d_shader_from_source_file(sOpt, GL_FRAGMENT_SHADER); } } - break; + break; } glAttachShader(visual->autostereo_glsl_program, visual->base_glsl_vertex); glAttachShader(visual->autostereo_glsl_program, visual->autostereo_glsl_fragment); - glLinkProgram(visual->autostereo_glsl_program); + glLinkProgram(visual->autostereo_glsl_program); } #define DEL_SHADER(_a) if (_a) { glDeleteShader(_a); _a = 0; } @@ -604,11 +581,11 @@ void visual_3d_init_yuv_shader(GF_VisualManager *visual) { u32 i; GLint loc; - if (!visual->compositor->gl_caps.has_shaders) return; + if (!visual->compositor->gl_caps.has_shaders) return; GL_CHECK_ERR if (visual->yuv_glsl_program) return; - + visual->yuv_glsl_program = glCreateProgram(); if (!visual->base_glsl_vertex) { @@ -621,10 +598,10 @@ void visual_3d_init_yuv_shader(GF_VisualManager *visual) glAttachShader(visual->yuv_glsl_program, visual->base_glsl_vertex); glAttachShader(visual->yuv_glsl_program, visual->yuv_glsl_fragment); - glLinkProgram(visual->yuv_glsl_program); + glLinkProgram(visual->yuv_glsl_program); //sets uniforms: y, u, v textures point to texture slots 0, 1 and 2 - glUseProgram(visual->yuv_glsl_program); + glUseProgram(visual->yuv_glsl_program); for (i=0; i<3; i++) { const char *txname = (i==0) ? "y_plane" : (i==1) ? "u_plane" : "v_plane"; loc = glGetUniformLocation(visual->yuv_glsl_program, txname); @@ -634,7 +611,7 @@ void visual_3d_init_yuv_shader(GF_VisualManager *visual) } glUniform1i(loc, i); } - glUseProgram(0); + glUseProgram(0); if (visual->compositor->gl_caps.rect_texture) { Bool res; @@ -670,10 +647,10 @@ void visual_3d_init_yuv_shader(GF_VisualManager *visual) if (visual->yuv_rect_glsl_program) { glAttachShader(visual->yuv_rect_glsl_program, visual->base_glsl_vertex); glAttachShader(visual->yuv_rect_glsl_program, visual->yuv_rect_glsl_fragment); - glLinkProgram(visual->yuv_rect_glsl_program); + glLinkProgram(visual->yuv_rect_glsl_program); //sets uniforms: y, u, v textures point to texture slots 0, 1 and 2 - glUseProgram(visual->yuv_rect_glsl_program); + glUseProgram(visual->yuv_rect_glsl_program); for (i=0; i<3; i++) { const char *txname = (i==0) ? "y_plane" : (i==1) ? "u_plane" : "v_plane"; loc = glGetUniformLocation(visual->yuv_rect_glsl_program, txname); @@ -694,7 +671,7 @@ void visual_3d_init_yuv_shader(GF_VisualManager *visual) GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Compositor] Failed to locate width in YUV shader\n")); } - glUseProgram(0); + glUseProgram(0); } } } @@ -731,7 +708,7 @@ GF_Err visual_3d_init_autostereo(GF_VisualManager *visual) u32 bw, bh; SFVec2f s; if (visual->gl_textures) return GF_OK; - + visual->gl_textures = gf_malloc(sizeof(GLuint) * visual->nb_views); glGenTextures(visual->nb_views, visual->gl_textures); @@ -757,7 +734,6 @@ GF_Err visual_3d_init_autostereo(GF_VisualManager *visual) s.x = INT2FIX(bw); s.y = INT2FIX(bh); mesh_new_rectangle(visual->autostereo_mesh, s, NULL, 0); -// mesh_new_ellipse(visual->autostereo_mesh, s.x, s.y, 0); GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[Visual3D] AutoStereo initialized - width %d height %d\n", visual->auto_stereo_width, visual->auto_stereo_height) ); @@ -786,11 +762,11 @@ void visual_3d_end_auto_stereo_pass(GF_VisualManager *visual) glBindTexture(GL_TEXTURE_2D, visual->gl_textures[visual->current_view]); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, visual->auto_stereo_width, visual->auto_stereo_height, 0); @@ -845,10 +821,10 @@ void visual_3d_end_auto_stereo_pass(GF_VisualManager *visual) glActiveTexture(GL_TEXTURE0 + i); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D, visual->gl_textures[i]); @@ -936,8 +912,13 @@ void visual_3d_setup(GF_VisualManager *visual) glShadeModel(GL_SMOOTH); glGetIntegerv(GL_MAX_LIGHTS, (GLint*)&visual->max_lights); + if (visual->max_lights>GF_MAX_GL_LIGHTS) + visual->max_lights=GF_MAX_GL_LIGHTS; + #ifdef GL_MAX_CLIP_PLANES glGetIntegerv(GL_MAX_CLIP_PLANES, (GLint*)&visual->max_clips); + if (visual->max_clips>GF_MAX_GL_CLIPS) + visual->max_clips=GF_MAX_GL_CLIPS; #endif visual_3d_setup_quality(visual); @@ -949,8 +930,9 @@ void visual_3d_setup(GF_VisualManager *visual) glDisable(GL_TEXTURE_2D); glDisable(GL_CULL_FACE); glDisable(GL_FOG); + visual->has_fog = GF_FALSE; /*Note: we cannot enable/disable normalization on the fly, because we have no clue when the GL implementation - will actually compute the related fragments. Since a typical world always use scaling, we always turn normalization on + will actually compute the related fragments. Since a typical world always use scaling, we always turn normalization on to avoid tracking scale*/ glEnable(GL_NORMALIZE); @@ -1000,21 +982,6 @@ void visual_3d_enable_depth_buffer(GF_VisualManager *visual, Bool on) else glDisable(GL_DEPTH_TEST); } -void visual_3d_enable_headlight(GF_VisualManager *visual, Bool bOn, GF_Camera *cam) -{ - SFVec3f dir; - SFColor col; - if (!bOn) return; - - col.blue = col.red = col.green = FIX_ONE; - if (cam->is_3D) { - dir = camera_get_target_dir(cam); - } else { - dir.x = dir.y = 0; dir.z = FIX_ONE; - } - visual_3d_add_directional_light(visual, 0, col, FIX_ONE, dir); -} - void visual_3d_set_viewport(GF_VisualManager *visual, GF_Rect vp) { glViewport(FIX2INT(vp.x), FIX2INT(vp.y), FIX2INT(vp.width), FIX2INT(vp.height)); @@ -1037,10 +1004,10 @@ void visual_3d_clear_depth(GF_VisualManager *visual) glClear(GL_DEPTH_BUFFER_BIT); } -void VS3D_DrawAABBNode(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 prim_type, GF_Plane *fplanes, u32 *p_indices, AABBNode *n) +static void visual_3d_draw_aabb_node(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 prim_type, GF_Plane *fplanes, u32 *p_indices, AABBNode *n) { u32 i; - + /*if not leaf do cull*/ if (n->pos) { u32 p_idx, cull; @@ -1051,16 +1018,22 @@ void VS3D_DrawAABBNode(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 prim_type, for (i=0; i<6; i++) { p_idx = p_indices[i]; /*check p-vertex: if not in plane, we're out (since p-vertex is the closest point to the plane)*/ - if (gf_plane_get_distance(&fplanes[i], &vertices[p_idx])<0) { cull = CULL_OUTSIDE; break; } + if (gf_plane_get_distance(&fplanes[i], &vertices[p_idx])<0) { + cull = CULL_OUTSIDE; + break; + } /*check n-vertex: if not in plane, we're intersecting*/ - if (gf_plane_get_distance(&fplanes[i], &vertices[7-p_idx])<0) { cull = CULL_INTERSECTS; break;} + if (gf_plane_get_distance(&fplanes[i], &vertices[7-p_idx])<0) { + cull = CULL_INTERSECTS; + break; + } } if (cull==CULL_OUTSIDE) return; if (cull==CULL_INTERSECTS) { - VS3D_DrawAABBNode(tr_state, mesh, prim_type, fplanes, p_indices, n->pos); - VS3D_DrawAABBNode(tr_state, mesh, prim_type, fplanes, p_indices, n->neg); + visual_3d_draw_aabb_node(tr_state, mesh, prim_type, fplanes, p_indices, n->pos); + visual_3d_draw_aabb_node(tr_state, mesh, prim_type, fplanes, p_indices, n->neg); return; } } @@ -1078,10 +1051,391 @@ void VS3D_DrawAABBNode(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 prim_type, } } -void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) +static void visual_3d_matrix_load(GF_VisualManager *visual, Fixed *mat) +{ + if (!mat) { + glLoadIdentity(); + return; + } +#ifdef GPAC_USE_OGL_ES + glLoadMatrixx(mat); +#elif defined(GPAC_FIXED_POINT) + Float _mat[16]; + u32 i; + for (i=0; i<16; i++) _mat[i] = FIX2FLT(mat[i]); + glLoadMatrixf(_mat); +#else + glLoadMatrixf(mat); +#endif +} + +static void visual_3d_matrix_add(GF_VisualManager *visual, Fixed *mat) +{ +#ifdef GPAC_USE_OGL_ES + glMultMatrixx(mat); +#elif defined(GPAC_FIXED_POINT) + u32 i; + Float _mat[16]; + for (i=0; i<16; i++) _mat[i] = FIX2FLT(mat[i]); + glMultMatrixf(_mat); +#else + glMultMatrixf(mat); +#endif +} + + +static void visual_3d_update_matrices(GF_TraverseState *tr_state) +{ + if (tr_state->visual->needs_projection_matrix_reload) { + tr_state->visual->needs_projection_matrix_reload = 0; + glMatrixMode(GL_PROJECTION); + visual_3d_matrix_load(tr_state->visual, tr_state->camera->projection.m); + glMatrixMode(GL_MODELVIEW); + } + + visual_3d_matrix_load(tr_state->visual, tr_state->camera->modelview.m); + visual_3d_matrix_add(tr_state->visual, tr_state->model_matrix.m); +} + + +static void visual_3d_set_clippers(GF_VisualManager *visual, GF_TraverseState *tr_state) +{ +#ifdef GL_MAX_CLIP_PLANES + u32 i; + GF_Matrix inv_mx; + + gf_mx_copy(inv_mx, tr_state->model_matrix); + gf_mx_inverse(&inv_mx); + + for (i=0; inum_clips; i++) { + u32 idx = GL_CLIP_PLANE0 + i; +#ifdef GPAC_USE_OGL_ES + Fixed g[4]; +#else + Double g[4]; +#endif + GF_Matrix mx; + GF_Plane p = visual->clippers[i].p; + + if (visual->clippers[i].is_2d_clip) { + visual_3d_matrix_load(tr_state->visual, tr_state->camera->modelview.m); + } else { + gf_mx_copy(mx, inv_mx); + if (visual->clippers[i].mx_clipper != NULL) { + gf_mx_add_matrix(&mx, visual->clippers[i].mx_clipper); + } + gf_mx_apply_plane(&mx, &p); + } + +#ifdef GPAC_USE_OGL_ES + g[0] = p.normal.x; + g[1] = p.normal.y; + g[2] = p.normal.z; + g[3] = p.d; + glClipPlanex(idx, g); +#else + g[0] = FIX2FLT(p.normal.x); + g[1] = FIX2FLT(p.normal.y); + g[2] = FIX2FLT(p.normal.z); + g[3] = FIX2FLT(p.d); + glClipPlane(idx, g); +#endif + glEnable(idx); + + if (visual->clippers[i].is_2d_clip) { + visual_3d_update_matrices(tr_state); + } + + } +#endif + +} + +static void visual_3d_reset_clippers(GF_VisualManager *visual) +{ +#ifdef GL_MAX_CLIP_PLANES + u32 i; + for (i=0; inum_clips; i++) { + glDisable(GL_CLIP_PLANE0 + i); + } +#endif +} + + +void visual_3d_reset_lights(GF_VisualManager *visual) +{ + u32 i; + if (!visual->num_lights) return; + for (i=0; inum_lights; i++) { + glDisable(GL_LIGHT0 + i); + } + glDisable(GL_LIGHTING); +} + + +static void visual_3d_set_lights(GF_VisualManager *visual) +{ + u32 i; +#ifdef GPAC_USE_OGL_ES + Fixed vals[4], exp; +#else + Float vals[4], intensity, cutOffAngle, beamWidth, ambientIntensity, exp; +#endif + + if (!visual->num_lights) return; + + for (i=0; inum_lights; i++) { + GF_LightInfo *li = &visual->lights[i]; + GLint iLight = GL_LIGHT0 + i; + + visual_3d_matrix_load(visual, visual->camera.modelview.m); + visual_3d_matrix_add(visual, li->light_mx.m); + + glEnable(iLight); + + switch (li->type) { + //directionnal light + case 0: +#ifdef GPAC_USE_OGL_ES + vals[0] = -li->direction.x; + vals[1] = -li->direction.y; + vals[2] = -li->direction.z; + vals[3] = 0; + glLightxv(iLight, GL_POSITION, vals); + vals[0] = gf_mulfix(li->color.red, li->intensity); + vals[1] = gf_mulfix(li->color.green, li->intensity); + vals[2] = gf_mulfix(li->color.blue, li->intensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_DIFFUSE, vals); + glLightxv(iLight, GL_SPECULAR, vals); + vals[0] = gf_mulfix(li->color.red, li->ambientIntensity); + vals[1] = gf_mulfix(li->color.green, li->ambientIntensity); + vals[2] = gf_mulfix(li->color.blue, li->ambientIntensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_AMBIENT, vals); + + glLightx(iLight, GL_CONSTANT_ATTENUATION, FIX_ONE); + glLightx(iLight, GL_LINEAR_ATTENUATION, 0); + glLightx(iLight, GL_QUADRATIC_ATTENUATION, 0); + glLightx(iLight, GL_SPOT_CUTOFF, INT2FIX(180) ); +#else + ambientIntensity = FIX2FLT(li->ambientIntensity); + intensity = FIX2FLT(li->intensity); + + vals[0] = -FIX2FLT(li->direction.x); + vals[1] = -FIX2FLT(li->direction.y); + vals[2] = -FIX2FLT(li->direction.z); + vals[3] = 0; + glLightfv(iLight, GL_POSITION, vals); + vals[0] = FIX2FLT(li->color.red)*intensity; + vals[1] = FIX2FLT(li->color.green)*intensity; + vals[2] = FIX2FLT(li->color.blue)*intensity; + vals[3] = 1; + glLightfv(iLight, GL_DIFFUSE, vals); + glLightfv(iLight, GL_SPECULAR, vals); + vals[0] = FIX2FLT(li->color.red)*ambientIntensity; + vals[1] = FIX2FLT(li->color.green)*ambientIntensity; + vals[2] = FIX2FLT(li->color.blue)*ambientIntensity; + vals[3] = 1; + glLightfv(iLight, GL_AMBIENT, vals); + + glLightf(iLight, GL_CONSTANT_ATTENUATION, 1.0f); + glLightf(iLight, GL_LINEAR_ATTENUATION, 0); + glLightf(iLight, GL_QUADRATIC_ATTENUATION, 0); + glLightf(iLight, GL_SPOT_CUTOFF, 180); +#endif + break; + + + //spot light + case 1: +#ifndef GPAC_USE_OGL_ES + ambientIntensity = FIX2FLT(li->ambientIntensity); + intensity = FIX2FLT(li->intensity); + cutOffAngle = FIX2FLT(li->cutOffAngle); + beamWidth = FIX2FLT(li->beamWidth); +#endif + +#ifdef GPAC_USE_OGL_ES + vals[0] = li->direction.x; + vals[1] = li->direction.y; + vals[2] = li->direction.z; + vals[3] = FIX_ONE; + glLightxv(iLight, GL_SPOT_DIRECTION, vals); + vals[0] = li->position.x; + vals[1] = li->position.y; + vals[2] = li->position.z; + vals[3] = FIX_ONE; + glLightxv(iLight, GL_POSITION, vals); + glLightx(iLight, GL_CONSTANT_ATTENUATION, li->attenuation.x ? li->attenuation.x : FIX_ONE); + glLightx(iLight, GL_LINEAR_ATTENUATION, li->attenuation.y); + glLightx(iLight, GL_QUADRATIC_ATTENUATION, li->attenuation.z); + vals[0] = gf_mulfix(li->color.red, li->intensity); + vals[1] = gf_mulfix(li->color.green, li->intensity); + vals[2] = gf_mulfix(li->color.blue, li->intensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_DIFFUSE, vals); + glLightxv(iLight, GL_SPECULAR, vals); + vals[0] = gf_mulfix(li->color.red, li->ambientIntensity); + vals[1] = gf_mulfix(li->color.green, li->ambientIntensity); + vals[2] = gf_mulfix(li->color.blue, li->ambientIntensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_AMBIENT, vals); + + if (!li->beamWidth) exp = FIX_ONE; + else if (li->beamWidth > li->cutOffAngle) exp = 0; + else { + exp = FIX_ONE - gf_cos(li->beamWidth); + if (exp>FIX_ONE) exp = FIX_ONE; + } + glLightx(iLight, GL_SPOT_EXPONENT, exp*128); + glLightx(iLight, GL_SPOT_CUTOFF, gf_divfix(180*li->cutOffAngle, GF_PI) ); +#else + vals[0] = FIX2FLT(li->direction.x); + vals[1] = FIX2FLT(li->direction.y); + vals[2] = FIX2FLT(li->direction.z); + vals[3] = 1; + glLightfv(iLight, GL_SPOT_DIRECTION, vals); + vals[0] = FIX2FLT(li->position.x); + vals[1] = FIX2FLT(li->position.y); + vals[2] = FIX2FLT(li->position.z); + vals[3] = 1; + glLightfv(iLight, GL_POSITION, vals); + glLightf(iLight, GL_CONSTANT_ATTENUATION, li->attenuation.x ? FIX2FLT(li->attenuation.x) : 1.0f); + glLightf(iLight, GL_LINEAR_ATTENUATION, FIX2FLT(li->attenuation.y)); + glLightf(iLight, GL_QUADRATIC_ATTENUATION, FIX2FLT(li->attenuation.z)); + vals[0] = FIX2FLT(li->color.red)*intensity; + vals[1] = FIX2FLT(li->color.green)*intensity; + vals[2] = FIX2FLT(li->color.blue)*intensity; + vals[3] = 1; + glLightfv(iLight, GL_DIFFUSE, vals); + glLightfv(iLight, GL_SPECULAR, vals); + vals[0] = FIX2FLT(li->color.red)*ambientIntensity; + vals[1] = FIX2FLT(li->color.green)*ambientIntensity; + vals[2] = FIX2FLT(li->color.blue)*ambientIntensity; + vals[3] = 1; + glLightfv(iLight, GL_AMBIENT, vals); + + //glLightf(iLight, GL_SPOT_EXPONENT, 0.5f * (beamWidth+0.001f) /*(Float) (0.5 * log(0.5) / log(cos(beamWidth)) ) */); + if (!beamWidth) exp = 1; + else if (beamWidth>cutOffAngle) exp = 0; + else { + exp = 1.0f - (Float) cos(beamWidth); + if (exp>1) exp = 1; + } + glLightf(iLight, GL_SPOT_EXPONENT, exp*128); + glLightf(iLight, GL_SPOT_CUTOFF, 180*cutOffAngle/FIX2FLT(GF_PI)); +#endif + break; + + + //point light + case 2: +#ifdef GPAC_USE_OGL_ES + vals[0] = li->position.x; + vals[1] = li->position.y; + vals[2] = li->position.z; + vals[3] = FIX_ONE; + glLightxv(iLight, GL_POSITION, vals); + glLightx(iLight, GL_CONSTANT_ATTENUATION, li->attenuation.x ? li->attenuation.x : FIX_ONE); + glLightx(iLight, GL_LINEAR_ATTENUATION, li->attenuation.y); + glLightx(iLight, GL_QUADRATIC_ATTENUATION, li->attenuation.z); + vals[0] = gf_mulfix(li->color.red, li->intensity); + vals[1] = gf_mulfix(li->color.green, li->intensity); + vals[2] = gf_mulfix(li->color.blue, li->intensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_DIFFUSE, vals); + glLightxv(iLight, GL_SPECULAR, vals); + vals[0] = gf_mulfix(li->color.red, li->ambientIntensity); + vals[1] = gf_mulfix(li->color.green, li->ambientIntensity); + vals[2] = gf_mulfix(li->color.blue, li->ambientIntensity); + vals[3] = FIX_ONE; + glLightxv(iLight, GL_AMBIENT, vals); + + glLightx(iLight, GL_SPOT_EXPONENT, 0); + glLightx(iLight, GL_SPOT_CUTOFF, INT2FIX(180) ); +#else + ambientIntensity = FIX2FLT(li->ambientIntensity); + intensity = FIX2FLT(li->intensity); + + vals[0] = FIX2FLT(li->position.x); + vals[1] = FIX2FLT(li->position.y); + vals[2] = FIX2FLT(li->position.z); + vals[3] = 1; + glLightfv(iLight, GL_POSITION, vals); + glLightf(iLight, GL_CONSTANT_ATTENUATION, li->attenuation.x ? FIX2FLT(li->attenuation.x) : 1.0f); + glLightf(iLight, GL_LINEAR_ATTENUATION, FIX2FLT(li->attenuation.y)); + glLightf(iLight, GL_QUADRATIC_ATTENUATION, FIX2FLT(li->attenuation.z)); + vals[0] = FIX2FLT(li->color.red)*intensity; + vals[1] = FIX2FLT(li->color.green)*intensity; + vals[2] = FIX2FLT(li->color.blue)*intensity; + vals[3] = 1; + glLightfv(iLight, GL_DIFFUSE, vals); + glLightfv(iLight, GL_SPECULAR, vals); + vals[0] = FIX2FLT(li->color.red)*ambientIntensity; + vals[1] = FIX2FLT(li->color.green)*ambientIntensity; + vals[2] = FIX2FLT(li->color.blue)*ambientIntensity; + vals[3] = 1; + glLightfv(iLight, GL_AMBIENT, vals); + + glLightf(iLight, GL_SPOT_EXPONENT, 0); + glLightf(iLight, GL_SPOT_CUTOFF, 180); +#endif + break; + } + } + + glEnable(GL_LIGHTING); + +} + +void visual_3d_enable_fog(GF_VisualManager *visual) +{ + +#ifndef GPAC_USE_TINYGL + +#ifdef GPAC_USE_OGL_ES + Fixed vals[4]; + glEnable(GL_FOG); + if (!visual->fog_type) glFogx(GL_FOG_MODE, GL_LINEAR); + else if (visual->fog_type==1) glFogx(GL_FOG_MODE, GL_EXP); + else if (visual->fog_type==2) glFogx(GL_FOG_MODE, GL_EXP2); + glFogx(GL_FOG_DENSITY, visual->fog_density); + glFogx(GL_FOG_START, 0); + glFogx(GL_FOG_END, visual->fog_visibility); + vals[0] = visual->fog_color.red; + vals[1] = visual->fog_color.green; + vals[2] = visual->fog_color.blue; + vals[3] = FIX_ONE; + glFogxv(GL_FOG_COLOR, vals); + glHint(GL_FOG_HINT, visual->compositor->high_speed ? GL_FASTEST : GL_NICEST); +#else + Float vals[4]; + glEnable(GL_FOG); + if (!visual->fog_type) glFogi(GL_FOG_MODE, GL_LINEAR); + else if (visual->fog_type==1) glFogi(GL_FOG_MODE, GL_EXP); + else if (visual->fog_type==2) glFogi(GL_FOG_MODE, GL_EXP2); + glFogf(GL_FOG_DENSITY, FIX2FLT(visual->fog_density)); + glFogf(GL_FOG_START, 0); + glFogf(GL_FOG_END, FIX2FLT(visual->fog_visibility)); + vals[0] = FIX2FLT(visual->fog_color.red); + vals[1] = FIX2FLT(visual->fog_color.green); + vals[2] = FIX2FLT(visual->fog_color.blue); + vals[3] = 1; + glFogfv(GL_FOG_COLOR, vals); + glHint(GL_FOG_HINT, visual->compositor->high_speed ? GL_FASTEST : GL_NICEST); +#endif + +#endif + +} + + +static void visual_3d_draw_mesh(GF_TraverseState *tr_state, GF_Mesh *mesh) { Bool has_col, has_tx, has_norm; u32 prim_type; + GF_VisualManager *visual = tr_state->visual; GF_Compositor *compositor = tr_state->visual->compositor; void *base_address = NULL; #if defined(GPAC_FIXED_POINT) && !defined(GPAC_USE_OGL_ES) @@ -1093,6 +1447,13 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) has_col = has_tx = has_norm = 0; GF_LOG(GF_LOG_DEBUG, GF_LOG_COMPOSE, ("[V3D] Drawing mesh %p\n", mesh)); + //set lights before pushing modelview matrix + visual_3d_set_lights(visual); + + visual_3d_update_matrices(tr_state); + + if (visual->has_fog) visual_3d_enable_fog(visual); + if ((compositor->reset_graphics==2) && mesh->vbo) { /*we lost OpenGL context at previous frame, recreate VBO*/ @@ -1132,7 +1493,109 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) glVertexPointer(3, GL_FLOAT, sizeof(GF_Vertex), base_address); #endif - if (!tr_state->mesh_num_textures && (mesh->flags & MESH_HAS_COLOR)) { + /*enable states*/ +#if 0 + if (visual->state_light_on) glEnable(GL_LIGHTING); + else glDisable(GL_LIGHTING); +#endif + + + if (visual->state_color_on) glEnable(GL_COLOR_MATERIAL); + else glDisable(GL_COLOR_MATERIAL); + + if (visual->state_blend_on) glEnable(GL_BLEND); + + + if (visual->num_clips) + visual_3d_set_clippers(visual, tr_state); + + /* + * Enable colors: + if mat2d is set, use mat2d and no lighting + */ + if (visual->has_mat_2d) { + glDisable(GL_LIGHTING); + +#if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) + if (visual->compositor->visual->current_texture_glsl_program) { + int loc = glGetUniformLocation(visual->compositor->visual->current_texture_glsl_program, "alpha"); + if (loc == -1) { + GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Compositor] Failed to locate uniform \"alpha\" in YUV shader\n")); + } else { + glUniform1f(loc, FIX2FLT(visual->mat_2d.alpha) ); + } + } else +#endif + { + if (visual->mat_2d.alpha != FIX_ONE) { + glEnable(GL_BLEND); + visual_3d_enable_antialias(visual, 0); + } else { + //disable blending only if no texture ! + if (!tr_state->mesh_num_textures) + glDisable(GL_BLEND); + visual_3d_enable_antialias(visual, visual->compositor->antiAlias ? 1 : 0); + } +#ifdef GPAC_USE_OGL_ES + glColor4x( FIX2INT(visual->mat_2d.red * 255), FIX2INT(visual->mat_2d.green * 255), FIX2INT(visual->mat_2d.blue * 255), FIX2INT(visual->mat_2d.alpha * 255)); +#else + glColor4f(visual->mat_2d.red, visual->mat_2d.green, visual->mat_2d.blue, visual->mat_2d.alpha); +#endif + } + } + + + //setup material color + if (visual->has_mat) { + u32 i; + GL_CHECK_ERR + for (i=0; i<4; i++) { + GLenum mode; + Fixed *rgba = (Fixed *) & visual->materials[i]; +#if defined(GPAC_USE_OGL_ES) + Fixed *_rgba = (Fixed *) rgba; +#elif defined(GPAC_FIXED_POINT) + Float _rgba[4]; + _rgba[0] = FIX2FLT(rgba[0]); + _rgba[1] = FIX2FLT(rgba[1]); + _rgba[2] = FIX2FLT(rgba[2]); + _rgba[3] = FIX2FLT(rgba[3]); +#else + Float *_rgba = (Float *) rgba; +#endif + + switch (i) { + case 0: + mode = GL_AMBIENT; + break; + case 1: + mode = GL_DIFFUSE; + break; + case 2: + mode = GL_SPECULAR; + break; + default: + mode = GL_EMISSION; + break; + } + +#ifdef GPAC_USE_OGL_ES + glMaterialxv(GL_FRONT_AND_BACK, mode, _rgba); +#else + glMaterialfv(GL_FRONT_AND_BACK, mode, _rgba); +#endif + GL_CHECK_ERR + } +#ifdef GPAC_USE_OGL_ES + glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, visual->shininess * 128); +#else + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, FIX2FLT(visual->shininess) * 128); +#endif + GL_CHECK_ERR + } + + //otherwise setup mesh color + if (!tr_state->mesh_num_textures && (mesh->flags & MESH_HAS_COLOR)) { glEnable(GL_COLOR_MATERIAL); #if !defined (GPAC_USE_OGL_ES) glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); @@ -1185,7 +1648,7 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(GF_Vertex), ((char *)base_address + MESH_COLOR_OFFSET)); #endif /*MESH_USE_SFCOLOR*/ -#else +#else #ifdef MESH_USE_SFCOLOR if (mesh->flags & MESH_HAS_ALPHA) { @@ -1210,6 +1673,16 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) if (tr_state->mesh_num_textures && !mesh->mesh_type && !(mesh->flags & MESH_NO_TEXTURE)) { has_tx = 1; + + glMatrixMode(GL_TEXTURE); + if (visual->has_tx_matrix) { + visual_3d_matrix_load(visual, visual->tx_matrix.m); + } else { + glLoadIdentity(); + } + glMatrixMode(GL_MODELVIEW); + + #if defined(GPAC_USE_OGL_ES) glTexCoordPointer(2, GL_FIXED, sizeof(GF_Vertex), ((char *)base_address + MESH_TEX_OFFSET)); glEnableClientState(GL_TEXTURE_COORD_ARRAY ); @@ -1253,7 +1726,7 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) #if !defined(GPAC_USE_TINYGL) && !defined(GL_ES_CL_PROFILE) glLineWidth(1.0f); #endif - + } else { u32 normal_type = GL_FLOAT; has_norm = 1; @@ -1275,9 +1748,9 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) glNormalPointer(normal_type, sizeof(GF_Vertex), ((char *)base_address + MESH_NORMAL_OFFSET)); if (!mesh->mesh_type) { - if (compositor->backcull - && (!tr_state->mesh_is_transparent || (compositor->backcull ==GF_BACK_CULL_ALPHA) ) - && (mesh->flags & MESH_IS_SOLID)) { + if (compositor->backcull + && (!tr_state->mesh_is_transparent || (compositor->backcull ==GF_BACK_CULL_ALPHA) ) + && (mesh->flags & MESH_IS_SOLID)) { glEnable(GL_CULL_FACE); glFrontFace((mesh->flags & MESH_IS_CW) ? GL_CW : GL_CCW); } else { @@ -1287,9 +1760,15 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) } switch (mesh->mesh_type) { - case MESH_LINESET: prim_type = GL_LINES; break; - case MESH_POINTSET: prim_type = GL_POINTS; break; - default: prim_type = GL_TRIANGLES; break; + case MESH_LINESET: + prim_type = GL_LINES; + break; + case MESH_POINTSET: + prim_type = GL_POINTS; + break; + default: + prim_type = GL_TRIANGLES; + break; } #if 1 @@ -1301,8 +1780,8 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) glDrawElements(prim_type, mesh->i_count, GL_UNSIGNED_INT, mesh->indices); #endif } else { - /*otherwise cull aabb against frustum - after some testing it appears (as usual) that there must - be a compromise: we're slowing down the compositor here, however the gain is really appreciable for + /*otherwise cull aabb against frustum - after some testing it appears (as usual) that there must + be a compromise: we're slowing down the compositor here, however the gain is really appreciable for large meshes, especially terrains/elevation grids*/ /*first get transformed frustum in local space*/ @@ -1317,8 +1796,8 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) p_idx[i] = gf_plane_get_p_vertex_idx(&fplanes[i]); } /*then recursively cull & draw AABB tree*/ - VS3D_DrawAABBNode(tr_state, mesh, prim_type, fplanes, p_idx, mesh->aabb_root->pos); - VS3D_DrawAABBNode(tr_state, mesh, prim_type, fplanes, p_idx, mesh->aabb_root->neg); + visual_3d_draw_aabb_node(tr_state, mesh, prim_type, fplanes, p_idx, mesh->aabb_root->pos); + visual_3d_draw_aabb_node(tr_state, mesh, prim_type, fplanes, p_idx, mesh->aabb_root->neg); } #endif @@ -1330,7 +1809,7 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) if (has_tx) glDisableClientState(GL_TEXTURE_COORD_ARRAY); if (has_norm) glDisableClientState(GL_NORMAL_ARRAY); - if (mesh->vbo) + if (mesh->vbo) glBindBuffer(GL_ARRAY_BUFFER, 0); #if defined(GPAC_FIXED_POINT) && !defined(GPAC_USE_OGL_ES) @@ -1342,36 +1821,34 @@ void VS3D_DrawMeshIntern(GF_TraverseState *tr_state, GF_Mesh *mesh) } glPopMatrix(); #endif - + + + visual_3d_reset_lights(visual); + + glDisable(GL_COLOR_MATERIAL); + + //reset all our states + if (visual->num_clips) + visual_3d_reset_clippers(visual); + visual->has_mat_2d = 0; + visual->has_mat = 0; + visual->state_color_on = 0; if (tr_state->mesh_is_transparent) glDisable(GL_BLEND); tr_state->mesh_is_transparent = 0; } -#ifdef GPAC_USE_OGL_ES -u32 ogles_push_enable(u32 mask) -{ - u32 attrib = 0; -#if !defined(__SYMBIAN32__) && !defined(GL_ES_CL_PROFILE) - if ((mask & GL_LIGHTING) && glIsEnabled(GL_LIGHTING) ) attrib |= GL_LIGHTING; - if ((mask & GL_BLEND) && glIsEnabled(GL_BLEND) ) attrib |= GL_BLEND; - if ((mask & GL_COLOR_MATERIAL) && glIsEnabled(GL_COLOR_MATERIAL) ) attrib |= GL_COLOR_MATERIAL; - if ((mask & GL_TEXTURE_2D) && glIsEnabled(GL_TEXTURE_2D) ) attrib |= GL_TEXTURE_2D; -#endif - return attrib; -} -void ogles_pop_enable(u32 mask) +static void visual_3d_set_debug_color(u32 col) { -#if !defined(__SYMBIAN32__) && !defined(GL_ES_CL_PROFILE) - if (mask & GL_LIGHTING) glEnable(GL_LIGHTING); - if (mask & GL_BLEND) glEnable(GL_BLEND); - if (mask & GL_COLOR_MATERIAL) glEnable(GL_COLOR_MATERIAL); - if (mask & GL_TEXTURE_2D) glEnable(GL_TEXTURE_2D); +#ifdef GPAC_USE_OGL_ES + glColor4x( (col ? GF_COL_R(col) : 255) , (col ? GF_COL_G(col) : 0) , (col ? GF_COL_B(col) : 255), 255); +#else + glColor4f(col ? GF_COL_R(col)/255.0f : 1, col ? GF_COL_G(col)/255.0f : 0, col ? GF_COL_B(col)/255.0f : 1, 1); #endif } -#endif + /*note we don't perform any culling for normal drawing...*/ -void VS3D_DrawNormals(GF_TraverseState *tr_state, GF_Mesh *mesh) +static void visual_3d_draw_normals(GF_TraverseState *tr_state, GF_Mesh *mesh) { #ifndef GPAC_USE_TINYGL @@ -1382,18 +1859,10 @@ void VS3D_DrawNormals(GF_TraverseState *tr_state, GF_Mesh *mesh) #ifdef GPAC_USE_OGL_ES GF_Vec va[2]; u16 indices[2]; - u32 attrib = ogles_push_enable(GL_LIGHTING | GL_BLEND | GL_COLOR_MATERIAL | GL_TEXTURE_2D); glEnableClientState(GL_VERTEX_ARRAY); -#else - glPushAttrib(GL_ENABLE_BIT); #endif - glDisable(GL_LIGHTING | GL_BLEND | GL_COLOR_MATERIAL | GL_TEXTURE_2D); -#ifdef GPAC_USE_OGL_ES - glColor4x(0, 0, 0, 1); -#else - glColor3f(1, 1, 1); -#endif + visual_3d_set_debug_color(0); if (tr_state->visual->compositor->draw_normals==GF_NORMALS_VERTEX) { IDX_TYPE *idx = mesh->indices; @@ -1428,138 +1897,115 @@ void VS3D_DrawNormals(GF_TraverseState *tr_state, GF_Mesh *mesh) MESH_GET_NORMAL(end, mesh->vertices[idx[0]]); end = gf_vec_scale(end, scale); gf_vec_add(end, pt, end); + #ifdef GPAC_USE_OGL_ES - va[0] = pt; - va[1] = end; - indices[0] = 0; - indices[1] = 1; - glVertexPointer(3, GL_FIXED, 0, va); - glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, indices); + va[0] = pt; + va[1] = end; + indices[0] = 0; + indices[1] = 1; + glVertexPointer(3, GL_FIXED, 0, va); + glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, indices); #else - glBegin(GL_LINES); - glVertex3f(FIX2FLT(pt.x), FIX2FLT(pt.y), FIX2FLT(pt.z)); - glVertex3f(FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z)); - glEnd(); + glBegin(GL_LINES); + glVertex3f(FIX2FLT(pt.x), FIX2FLT(pt.y), FIX2FLT(pt.z)); + glVertex3f(FIX2FLT(end.x), FIX2FLT(end.y), FIX2FLT(end.z)); + glEnd(); #endif idx += 3; } } #ifdef GPAC_USE_OGL_ES - ogles_pop_enable(attrib); glDisableClientState(GL_VERTEX_ARRAY); -#else - glPopAttrib(); #endif #endif /*GPAC_USE_TINYGL*/ } -void VS3D_DrawAABBNodeBounds(GF_TraverseState *tr_state, AABBNode *node) +void visual_3d_draw_aabb_nodeBounds(GF_TraverseState *tr_state, AABBNode *node) { if (node->pos) { - VS3D_DrawAABBNodeBounds(tr_state, node->pos); - VS3D_DrawAABBNodeBounds(tr_state, node->neg); + visual_3d_draw_aabb_nodeBounds(tr_state, node->pos); + visual_3d_draw_aabb_nodeBounds(tr_state, node->neg); } else { + GF_Matrix mx; SFVec3f c, s; gf_vec_diff(s, node->max, node->min); c = gf_vec_scale(s, FIX_ONE/2); gf_vec_add(c, node->min, c); - glPushMatrix(); -#ifdef GPAC_USE_OGL_ES - glTranslatex(c.x, c.y, c.z); - glScalex(s.x, s.y, s.z); -#else - glTranslatef(FIX2FLT(c.x), FIX2FLT(c.y), FIX2FLT(c.z)); - glScalef(FIX2FLT(s.x), FIX2FLT(s.y), FIX2FLT(s.z)); -#endif - VS3D_DrawMeshIntern(tr_state, tr_state->visual->compositor->unit_bbox); - glPopMatrix(); + gf_mx_copy(mx, tr_state->model_matrix); + gf_mx_add_translation(&tr_state->model_matrix, c.x, c.y, c.z); + gf_mx_add_scale(&tr_state->model_matrix, s.x, s.y, s.z); + + visual_3d_draw_mesh(tr_state, tr_state->visual->compositor->unit_bbox); + + gf_mx_copy(tr_state->model_matrix, mx); } } -void visual_3d_draw_bbox(GF_TraverseState *tr_state, GF_BBox *box) +void visual_3d_draw_bbox_ex(GF_TraverseState *tr_state, GF_BBox *box, Bool is_debug) { + GF_Matrix mx; SFVec3f c, s; -#ifdef GPAC_USE_TINYGL -#elif defined(GPAC_USE_OGL_ES) - u32 atts = ogles_push_enable(GL_LIGHTING); -#else - glPushAttrib(GL_ENABLE_BIT); -#endif + if (! is_debug) { + visual_3d_set_debug_color(tr_state->visual->compositor->highlight_stroke); + } + gf_vec_diff(s, box->max_edge, box->min_edge); c.x = box->min_edge.x + s.x/2; c.y = box->min_edge.y + s.y/2; c.z = box->min_edge.z + s.z/2; - visual_3d_set_material_2d_argb(tr_state->visual, tr_state->visual->compositor->highlight_stroke); - glPushMatrix(); - -#ifdef GPAC_USE_OGL_ES - glTranslatex(c.x, c.y, c.z); - glScalex(s.x, s.y, s.z); -#else - glTranslatef(FIX2FLT(c.x), FIX2FLT(c.y), FIX2FLT(c.z)); - glScalef(FIX2FLT(s.x), FIX2FLT(s.y), FIX2FLT(s.z)); -// glScalef(1.1f, 1.1f, 1.1f); -#endif - VS3D_DrawMeshIntern(tr_state, tr_state->visual->compositor->unit_bbox); - glPopMatrix(); - -#ifdef GPAC_USE_TINYGL - -#elif defined(GPAC_USE_OGL_ES) - ogles_pop_enable(atts); -#else - glPopAttrib(); -#endif + gf_mx_copy(mx, tr_state->model_matrix); + gf_mx_add_translation(&tr_state->model_matrix, c.x, c.y, c.z); + gf_mx_add_scale(&tr_state->model_matrix, s.x, s.y, s.z); + visual_3d_draw_mesh(tr_state, tr_state->visual->compositor->unit_bbox); + gf_mx_copy(tr_state->model_matrix, mx); } -//#endif +void visual_3d_draw_bbox(GF_TraverseState *tr_state, GF_BBox *box) +{ + visual_3d_draw_bbox_ex(tr_state, box, 0); +} -void VS3D_DrawMeshBoundingVolume(GF_TraverseState *tr_state, GF_Mesh *mesh) +static void visual_3d_draw_bounds(GF_TraverseState *tr_state, GF_Mesh *mesh) { -#ifndef GPAC_USE_TINYGL + visual_3d_set_debug_color(0); + if (mesh->aabb_root && (tr_state->visual->compositor->draw_bvol==GF_BOUNDS_AABB)) { -#ifdef GPAC_USE_OGL_ES - u32 atts = ogles_push_enable(GL_LIGHTING); -#else - glPushAttrib(GL_ENABLE_BIT); -#endif - glDisable(GL_LIGHTING); - VS3D_DrawAABBNodeBounds(tr_state, mesh->aabb_root); -#ifdef GPAC_USE_OGL_ES - ogles_pop_enable(atts); -#else - glPopAttrib(); -#endif + visual_3d_draw_aabb_nodeBounds(tr_state, mesh->aabb_root); } else { - visual_3d_draw_bbox(tr_state, &mesh->bounds); + visual_3d_draw_bbox_ex(tr_state, &mesh->bounds, 1); } - - -#endif /*GPAC_USE_TINYGL*/ } void visual_3d_mesh_paint(GF_TraverseState *tr_state, GF_Mesh *mesh) { Bool mesh_drawn = 0; if (tr_state->visual->compositor->wiremode != GF_WIREFRAME_ONLY) { - VS3D_DrawMeshIntern(tr_state, mesh); + visual_3d_draw_mesh(tr_state, mesh); mesh_drawn = 1; } - if (tr_state->visual->compositor->draw_normals) VS3D_DrawNormals(tr_state, mesh); + if (tr_state->visual->compositor->draw_normals) { + if (!mesh_drawn) { + visual_3d_update_matrices(tr_state); + mesh_drawn=1; + } + visual_3d_draw_normals(tr_state, mesh); + } + if (!mesh->mesh_type && (tr_state->visual->compositor->wiremode != GF_WIREFRAME_NONE)) { glDisable(GL_LIGHTING); -#ifdef GPAC_USE_OGL_ES - if (mesh_drawn) glColor4x(0, 0, 0, FIX_ONE); -#else - if (mesh_drawn) glColor4f(0, 0, 0, 1.0f); -#endif + visual_3d_set_debug_color(0xFFFFFFFF); + + if (!mesh_drawn) + visual_3d_update_matrices(tr_state); + + glEnableClientState(GL_VERTEX_ARRAY); #ifdef GPAC_USE_OGL_ES glVertexPointer(3, GL_FIXED, sizeof(GF_Vertex), &mesh->vertices[0].pos); @@ -1570,7 +2016,7 @@ void visual_3d_mesh_paint(GF_TraverseState *tr_state, GF_Mesh *mesh) #endif glDisableClientState(GL_VERTEX_ARRAY); } - if (tr_state->visual->compositor->draw_bvol) VS3D_DrawMeshBoundingVolume(tr_state, mesh); + if (tr_state->visual->compositor->draw_bvol) visual_3d_draw_bounds(tr_state, mesh); } #if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) @@ -1701,12 +2147,24 @@ void visual_3d_mesh_hatch(GF_TraverseState *tr_state, GF_Mesh *mesh, u32 hatchSt glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /*can't access ISO International Register of Graphical Items www site :)*/ switch (hatchStyle) { - case 5: glPolygonStipple(hatch_cross); break; - case 4: glPolygonStipple(hatch_up); break; - case 3: glPolygonStipple(hatch_down); break; - case 2: glPolygonStipple(hatch_vert); break; - case 1: glPolygonStipple(hatch_horiz); break; - default: glDisable(GL_POLYGON_STIPPLE); break; + case 5: + glPolygonStipple(hatch_cross); + break; + case 4: + glPolygonStipple(hatch_up); + break; + case 3: + glPolygonStipple(hatch_down); + break; + case 2: + glPolygonStipple(hatch_vert); + break; + case 1: + glPolygonStipple(hatch_horiz); + break; + default: + glDisable(GL_POLYGON_STIPPLE); + break; } glColor3f(FIX2FLT(hatchColor.red), FIX2FLT(hatchColor.green), FIX2FLT(hatchColor.blue)); glDrawElements(GL_TRIANGLES, mesh->i_count, GL_UNSIGNED_INT, mesh->indices); @@ -1721,7 +2179,7 @@ void visual_3d_mesh_strike(GF_TraverseState *tr_state, GF_Mesh *mesh, Fixed widt #if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) u16 style; #endif - + if (mesh->mesh_type != MESH_LINESET) return; if (line_scale) width = gf_mulfix(width, line_scale); width/=2; @@ -1732,11 +2190,21 @@ void visual_3d_mesh_strike(GF_TraverseState *tr_state, GF_Mesh *mesh, Fixed widt #if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) switch (dash_style) { - case GF_DASH_STYLE_DASH: style = 0x1F1F; break; - case GF_DASH_STYLE_DOT: style = 0x3333; break; - case GF_DASH_STYLE_DASH_DOT: style = 0x6767; break; - case GF_DASH_STYLE_DASH_DASH_DOT: style = 0x33CF; break; - case GF_DASH_STYLE_DASH_DOT_DOT: style = 0x330F; break; + case GF_DASH_STYLE_DASH: + style = 0x1F1F; + break; + case GF_DASH_STYLE_DOT: + style = 0x3333; + break; + case GF_DASH_STYLE_DASH_DOT: + style = 0x6767; + break; + case GF_DASH_STYLE_DASH_DASH_DOT: + style = 0x33CF; + break; + case GF_DASH_STYLE_DASH_DOT_DOT: + style = 0x330F; + break; default: style = 0; break; @@ -1745,61 +2213,14 @@ void visual_3d_mesh_strike(GF_TraverseState *tr_state, GF_Mesh *mesh, Fixed widt u32 factor = FIX2INT(width); if (!factor) factor = 1; glEnable(GL_LINE_STIPPLE); - glLineStipple(factor, style); + glLineStipple(factor, style); visual_3d_mesh_paint(tr_state, mesh); glDisable (GL_LINE_STIPPLE); - } else + } else #endif visual_3d_mesh_paint(tr_state, mesh); } -void visual_3d_set_material_2d(GF_VisualManager *visual, SFColor col, Fixed alpha) -{ - glDisable(GL_LIGHTING); - if (alpha != FIX_ONE) { - glEnable(GL_BLEND); - visual_3d_enable_antialias(visual, 0); - } else { - glDisable(GL_BLEND); - visual_3d_enable_antialias(visual, visual->compositor->antiAlias ? 1 : 0); - } -#ifdef GPAC_USE_OGL_ES - glColor4x(col.red, col.green, col.blue, alpha); -#else - glColor4f(FIX2FLT(col.red), FIX2FLT(col.green), FIX2FLT(col.blue), FIX2FLT(alpha)); -#endif -} - -void visual_3d_set_material_2d_argb(GF_VisualManager *visual, u32 col) -{ - u32 a = GF_COL_A(col); - -#if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) - if (visual->compositor->visual->current_texture_glsl_program) { - int loc = glGetUniformLocation(visual->compositor->visual->current_texture_glsl_program, "alpha"); - if (loc == -1) { - GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Compositor] Failed to locate uniform \"alpha\" in YUV shader\n")); - } else { - GLfloat alpha = (GLfloat) a / 255.0f; - glUniform1f(loc, alpha); - } - return; - } -#endif - glDisable(GL_LIGHTING); - if (a != 0xFF) { - glEnable(GL_BLEND); - visual_3d_enable_antialias(visual, 0); - } else { - glDisable(GL_BLEND); - visual_3d_enable_antialias(visual, visual->compositor->antiAlias ? 1 : 0); - } -#ifdef GPAC_USE_OGL_ES - glColor4x(GF_COL_R(col)<<8, GF_COL_G(col)<<8, GF_COL_B(col)<<8, a<<8); -#else - glColor4f(GF_COL_R(col)/255.0f, GF_COL_G(col)/255.0f, GF_COL_B(col)/255.0f, a/255.0f); -#endif -} void visual_3d_clear(GF_VisualManager *visual, SFColor color, Fixed alpha) { @@ -1812,512 +2233,6 @@ void visual_3d_clear(GF_VisualManager *visual, SFColor color, Fixed alpha) } -#if !defined(GPAC_USE_OGL_ES) && !defined(GPAC_USE_TINYGL) - -void visual_3d_draw_image(GF_VisualManager *visual, Fixed pos_x, Fixed pos_y, u32 width, u32 height, u32 pixelformat, char *data, Fixed scale_x, Fixed scale_y) -{ - u32 gl_format; - glPixelZoom(FIX2FLT(scale_x), FIX2FLT(scale_y)); - - gl_format = 0; - switch (pixelformat) { - case GF_PIXEL_RGB_24: - gl_format = GL_RGB; - break; - case GF_PIXEL_RGB_32: - case GF_PIXEL_RGBA: - gl_format = GL_RGBA; - break; - case GF_PIXEL_ARGB: - if (!visual->compositor->gl_caps.bgra_texture) return; - gl_format = GL_BGRA_EXT; - break; - default: - return; - } - - /*glRasterPos2f doesn't accept point outside the view volume (it invalidates all draw pixel, draw bitmap) - so we move to the center of the local coord system, draw a NULL bitmap with raster pos displacement*/ - glRasterPos2f(0, 0); - glBitmap(0, 0, 0, 0, FIX2FLT(pos_x), -FIX2FLT(pos_y), NULL); - glDrawPixels(width, height, gl_format, GL_UNSIGNED_BYTE, data); - glBitmap(0, 0, 0, 0, -FIX2FLT(pos_x), FIX2FLT(pos_y), NULL); - -} - - -void visual_3d_matrix_get(GF_VisualManager *visual, u32 mat_type, Fixed *mat) -{ -#ifdef GPAC_FIXED_POINT - u32 i = 0; -#endif - Float _mat[16]; - switch (mat_type) { - case V3D_MATRIX_MODELVIEW: - glGetFloatv(GL_MODELVIEW_MATRIX, _mat); - break; - case V3D_MATRIX_PROJECTION: - glGetFloatv(GL_PROJECTION_MATRIX, _mat); - break; - case V3D_MATRIX_TEXTURE: - glGetFloatv(GL_TEXTURE_MATRIX, _mat); - break; - } -#ifdef GPAC_FIXED_POINT - for (i=0; i<16; i++) mat[i] = FLT2FIX(_mat[i]); -#else - memcpy(mat, _mat, sizeof(Fixed)*16); -#endif -} - -#endif - -void visual_3d_set_matrix_mode(GF_VisualManager *visual, u32 mat_type) -{ - switch (mat_type) { - case V3D_MATRIX_MODELVIEW: - glMatrixMode(GL_MODELVIEW); - break; - case V3D_MATRIX_PROJECTION: - glMatrixMode(GL_PROJECTION); - break; - case V3D_MATRIX_TEXTURE: - glMatrixMode(GL_TEXTURE); - break; - } -} - -void visual_3d_matrix_reset(GF_VisualManager *visual) -{ - glLoadIdentity(); -} -void visual_3d_matrix_push(GF_VisualManager *visual) -{ - glPushMatrix(); -} -void visual_3d_matrix_add(GF_VisualManager *visual, Fixed *mat) -{ -#ifdef GPAC_USE_OGL_ES - glMultMatrixx(mat); -#elif defined(GPAC_FIXED_POINT) - u32 i; - Float _mat[16]; - for (i=0; i<16; i++) _mat[i] = FIX2FLT(mat[i]); - glMultMatrixf(_mat); -#else - glMultMatrixf(mat); -#endif -} - -void visual_3d_matrix_pop(GF_VisualManager *visual) -{ - glPopMatrix(); -} - -void visual_3d_matrix_load(GF_VisualManager *visual, Fixed *mat) -{ -#ifdef GPAC_USE_OGL_ES - glLoadMatrixx(mat); -#elif defined(GPAC_FIXED_POINT) - Float _mat[16]; - u32 i; - for (i=0; i<16; i++) _mat[i] = FIX2FLT(mat[i]); - glLoadMatrixf(_mat); -#else - glLoadMatrixf(mat); -#endif -} - - -void visual_3d_set_clipper_2d(GF_VisualManager *visual, GF_Rect clip) -{ -#ifdef GL_MAX_CLIP_PLANES - -#ifdef GPAC_USE_OGL_ES - - Fixed g[4]; - u32 cp; - visual_3d_reset_clipper_2d(visual); - if (visual->num_clips + 4 > visual->max_clips) return; - cp = visual->num_clips; - g[2] = 0; g[1] = 0; - g[3] = clip.x + clip.width; g[0] = -FIX_ONE; - glClipPlanex(GL_CLIP_PLANE0 + cp, g); glEnable(GL_CLIP_PLANE0 + cp); - g[3] = -clip.x; g[0] = FIX_ONE; - glClipPlanex(GL_CLIP_PLANE0 + cp + 1, g); glEnable(GL_CLIP_PLANE0 + cp + 1); - g[0] = 0; - g[3] = clip.y; g[1] = -FIX_ONE; - glClipPlanex(GL_CLIP_PLANE0 + cp + 2, g); glEnable(GL_CLIP_PLANE0 + cp + 2); - g[3] = clip.height - clip.y; g[1] = FIX_ONE; - glClipPlanex(GL_CLIP_PLANE0 + cp + 3, g); glEnable(GL_CLIP_PLANE0 + cp + 3); - visual->num_clips += 4; -#else - Double g[4]; - u32 cp; - visual_3d_reset_clipper_2d(visual); - if (visual->num_clips + 4 > visual->max_clips) return; - cp = visual->num_clips; - g[2] = 0; - g[1] = 0; - g[3] = FIX2FLT(clip.x) + FIX2FLT(clip.width); g[0] = -1; - glClipPlane(GL_CLIP_PLANE0 + cp, g); glEnable(GL_CLIP_PLANE0 + cp); - g[3] = -FIX2FLT(clip.x); g[0] = 1; - glClipPlane(GL_CLIP_PLANE0 + cp + 1, g); glEnable(GL_CLIP_PLANE0 + cp + 1); - g[0] = 0; - g[3] = FIX2FLT(clip.y); g[1] = -1; - glClipPlane(GL_CLIP_PLANE0 + cp + 2, g); glEnable(GL_CLIP_PLANE0 + cp + 2); - g[3] = FIX2FLT(clip.height-clip.y); g[1] = 1; - glClipPlane(GL_CLIP_PLANE0 + cp + 3, g); glEnable(GL_CLIP_PLANE0 + cp + 3); - visual->num_clips += 4; -#endif - -#endif -} - -void visual_3d_reset_clipper_2d(GF_VisualManager *visual) -{ -#ifdef GL_MAX_CLIP_PLANES - u32 cp; - if (visual->num_clips < 4) return; - cp = visual->num_clips - 4; - glDisable(GL_CLIP_PLANE0 + cp + 3); - glDisable(GL_CLIP_PLANE0 + cp + 2); - glDisable(GL_CLIP_PLANE0 + cp + 1); - glDisable(GL_CLIP_PLANE0 + cp); - visual->num_clips -= 4; -#endif -} - -void visual_3d_set_clip_plane(GF_VisualManager *visual, GF_Plane p) -{ -#ifdef GL_MAX_CLIP_PLANES - -#ifdef GPAC_USE_OGL_ES - Fixed g[4]; - if (visual->num_clips + 1 > visual->max_clips) return; - gf_vec_norm(&p.normal); - g[0] = p.normal.x; - g[1] = p.normal.y; - g[2] = p.normal.z; - g[3] = p.d; - glClipPlanex(GL_CLIP_PLANE0 + visual->num_clips, g); -#else - Double g[4]; - if (visual->num_clips + 1 > visual->max_clips) return; - gf_vec_norm(&p.normal); - g[0] = FIX2FLT(p.normal.x); - g[1] = FIX2FLT(p.normal.y); - g[2] = FIX2FLT(p.normal.z); - g[3] = FIX2FLT(p.d); - glClipPlane(GL_CLIP_PLANE0 + visual->num_clips, g); -#endif - glEnable(GL_CLIP_PLANE0 + visual->num_clips); - visual->num_clips++; -#endif - -} - -void visual_3d_reset_clip_plane(GF_VisualManager *visual) -{ -#ifdef GL_MAX_CLIP_PLANES - if (!visual->num_clips) return; - glDisable(GL_CLIP_PLANE0 + visual->num_clips-1); - visual->num_clips -= 1; -#endif -} - -void visual_3d_set_material(GF_VisualManager *visual, u32 material_type, Fixed *rgba) -{ - GLenum mode; -#if defined(GPAC_USE_OGL_ES) - Fixed *_rgba = rgba; -#elif defined(GPAC_FIXED_POINT) - Float _rgba[4]; - _rgba[0] = FIX2FLT(rgba[0]); _rgba[1] = FIX2FLT(rgba[1]); _rgba[2] = FIX2FLT(rgba[2]); _rgba[3] = FIX2FLT(rgba[3]); -#else - Float *_rgba = rgba; -#endif - - switch (material_type) { - case V3D_MATERIAL_AMBIENT: mode = GL_AMBIENT; break; - case V3D_MATERIAL_DIFFUSE: mode = GL_DIFFUSE; break; - case V3D_MATERIAL_SPECULAR: mode = GL_SPECULAR; break; - case V3D_MATERIAL_EMISSIVE: mode = GL_EMISSION; break; - - case V3D_MATERIAL_NONE: -#ifdef GPAC_USE_OGL_ES - glColor4x(_rgba[0], _rgba[1], _rgba[2], _rgba[3]); -#else - glColor4fv(_rgba); -#endif - /*fall-through*/ - default: - return; - } -#ifdef GPAC_USE_OGL_ES - glMaterialxv(GL_FRONT_AND_BACK, mode, _rgba); -#else - glMaterialfv(GL_FRONT_AND_BACK, mode, _rgba); -#endif -} - -void visual_3d_set_shininess(GF_VisualManager *visual, Fixed shininess) -{ -#ifdef GPAC_USE_OGL_ES - glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, shininess * 128); -#else - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, FIX2FLT(shininess) * 128); -#endif -} - -void visual_3d_set_state(GF_VisualManager *visual, u32 flag_mask, Bool setOn) -{ - if (setOn) { - if (flag_mask & V3D_STATE_LIGHT) glEnable(GL_LIGHTING); - if (flag_mask & V3D_STATE_BLEND) glEnable(GL_BLEND); - if (flag_mask & V3D_STATE_COLOR) glEnable(GL_COLOR_MATERIAL); - } else { - if (flag_mask & V3D_STATE_LIGHT) - glDisable(GL_LIGHTING); - if (flag_mask & V3D_STATE_BLEND) glDisable(GL_BLEND); -#ifdef GPAC_USE_OGL_ES - if (flag_mask & V3D_STATE_COLOR) glDisable(GL_COLOR_MATERIAL); -#else - if (flag_mask & V3D_STATE_COLOR) glDisable(GL_COLOR_MATERIAL | GL_COLOR_MATERIAL_FACE); -#endif - } -} - -Bool visual_3d_add_spot_light(GF_VisualManager *visual, Fixed _ambientIntensity, SFVec3f attenuation, Fixed _beamWidth, - SFColor color, Fixed _cutOffAngle, SFVec3f direction, Fixed _intensity, SFVec3f location) -{ -#ifdef GPAC_USE_OGL_ES - Fixed vals[4], exp; -#else - Float vals[4], intensity, cutOffAngle, beamWidth, ambientIntensity, exp; -#endif - GLint iLight; - - if (!visual->num_lights) glEnable(GL_LIGHTING); - if (visual->num_lights==visual->max_lights) return 0; - iLight = GL_LIGHT0 + visual->num_lights; - visual->num_lights++; - glEnable(iLight); - -#ifndef GPAC_USE_OGL_ES - ambientIntensity = FIX2FLT(_ambientIntensity); - intensity = FIX2FLT(_intensity); - cutOffAngle = FIX2FLT(_cutOffAngle); - beamWidth = FIX2FLT(_beamWidth); -#endif - - /*in case...*/ - gf_vec_norm(&direction); - -#ifdef GPAC_USE_OGL_ES - vals[0] = direction.x; vals[1] = direction.y; vals[2] = direction.z; vals[3] = FIX_ONE; - glLightxv(iLight, GL_SPOT_DIRECTION, vals); - vals[0] = location.x; vals[1] = location.y; vals[2] = location.z; vals[3] = FIX_ONE; - glLightxv(iLight, GL_POSITION, vals); - glLightx(iLight, GL_CONSTANT_ATTENUATION, attenuation.x ? attenuation.x : FIX_ONE); - glLightx(iLight, GL_LINEAR_ATTENUATION, attenuation.y); - glLightx(iLight, GL_QUADRATIC_ATTENUATION, attenuation.z); - vals[0] = gf_mulfix(color.red, _intensity); vals[1] = gf_mulfix(color.green, _intensity); vals[2] = gf_mulfix(color.blue, _intensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_DIFFUSE, vals); - glLightxv(iLight, GL_SPECULAR, vals); - vals[0] = gf_mulfix(color.red, _ambientIntensity); vals[1] = gf_mulfix(color.green, _ambientIntensity); vals[2] = gf_mulfix(color.blue, _ambientIntensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_AMBIENT, vals); - - if (!_beamWidth) exp = FIX_ONE; - else if (_beamWidth>_cutOffAngle) exp = 0; - else { - exp = FIX_ONE - gf_cos(_beamWidth); - if (exp>FIX_ONE) exp = FIX_ONE; - } - glLightx(iLight, GL_SPOT_EXPONENT, exp*128); - glLightx(iLight, GL_SPOT_CUTOFF, gf_divfix(180*_cutOffAngle, GF_PI) ); -#else - vals[0] = FIX2FLT(direction.x); vals[1] = FIX2FLT(direction.y); vals[2] = FIX2FLT(direction.z); vals[3] = 1; - glLightfv(iLight, GL_SPOT_DIRECTION, vals); - vals[0] = FIX2FLT(location.x); vals[1] = FIX2FLT(location.y); vals[2] = FIX2FLT(location.z); vals[3] = 1; - glLightfv(iLight, GL_POSITION, vals); - glLightf(iLight, GL_CONSTANT_ATTENUATION, attenuation.x ? FIX2FLT(attenuation.x) : 1.0f); - glLightf(iLight, GL_LINEAR_ATTENUATION, FIX2FLT(attenuation.y)); - glLightf(iLight, GL_QUADRATIC_ATTENUATION, FIX2FLT(attenuation.z)); - vals[0] = FIX2FLT(color.red)*intensity; vals[1] = FIX2FLT(color.green)*intensity; vals[2] = FIX2FLT(color.blue)*intensity; vals[3] = 1; - glLightfv(iLight, GL_DIFFUSE, vals); - glLightfv(iLight, GL_SPECULAR, vals); - vals[0] = FIX2FLT(color.red)*ambientIntensity; vals[1] = FIX2FLT(color.green)*ambientIntensity; vals[2] = FIX2FLT(color.blue)*ambientIntensity; vals[3] = 1; - glLightfv(iLight, GL_AMBIENT, vals); - - //glLightf(iLight, GL_SPOT_EXPONENT, 0.5f * (beamWidth+0.001f) /*(Float) (0.5 * log(0.5) / log(cos(beamWidth)) ) */); - if (!beamWidth) exp = 1; - else if (beamWidth>cutOffAngle) exp = 0; - else { - exp = 1.0f - (Float) cos(beamWidth); - if (exp>1) exp = 1; - } - glLightf(iLight, GL_SPOT_EXPONENT, exp*128); - glLightf(iLight, GL_SPOT_CUTOFF, 180*cutOffAngle/FIX2FLT(GF_PI)); -#endif - - return 1; -} - -/*insert pointlight - returns 0 if too many lights*/ -Bool visual_3d_add_point_light(GF_VisualManager *visual, Fixed _ambientIntensity, SFVec3f attenuation, SFColor color, Fixed _intensity, SFVec3f location) -{ -#ifdef GPAC_USE_OGL_ES - Fixed vals[4]; -#else - Float vals[4], ambientIntensity, intensity; -#endif - u32 iLight; - - if (!visual->num_lights) glEnable(GL_LIGHTING); - if (visual->num_lights==visual->max_lights) return 0; - iLight = GL_LIGHT0 + visual->num_lights; - visual->num_lights++; - glEnable(iLight); - -#ifdef GPAC_USE_OGL_ES - vals[0] = location.x; vals[1] = location.y; vals[2] = location.z; vals[3] = FIX_ONE; - glLightxv(iLight, GL_POSITION, vals); - glLightx(iLight, GL_CONSTANT_ATTENUATION, attenuation.x ? attenuation.x : FIX_ONE); - glLightx(iLight, GL_LINEAR_ATTENUATION, attenuation.y); - glLightx(iLight, GL_QUADRATIC_ATTENUATION, attenuation.z); - vals[0] = gf_mulfix(color.red, _intensity); vals[1] = gf_mulfix(color.green, _intensity); vals[2] = gf_mulfix(color.blue, _intensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_DIFFUSE, vals); - glLightxv(iLight, GL_SPECULAR, vals); - vals[0] = gf_mulfix(color.red, _ambientIntensity); vals[1] = gf_mulfix(color.green, _ambientIntensity); vals[2] = gf_mulfix(color.blue, _ambientIntensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_AMBIENT, vals); - - glLightx(iLight, GL_SPOT_EXPONENT, 0); - glLightx(iLight, GL_SPOT_CUTOFF, INT2FIX(180) ); -#else - ambientIntensity = FIX2FLT(_ambientIntensity); - intensity = FIX2FLT(_intensity); - - vals[0] = FIX2FLT(location.x); vals[1] = FIX2FLT(location.y); vals[2] = FIX2FLT(location.z); vals[3] = 1; - glLightfv(iLight, GL_POSITION, vals); - - glLightf(iLight, GL_CONSTANT_ATTENUATION, attenuation.x ? FIX2FLT(attenuation.x) : 1.0f); - glLightf(iLight, GL_LINEAR_ATTENUATION, FIX2FLT(attenuation.y)); - glLightf(iLight, GL_QUADRATIC_ATTENUATION, FIX2FLT(attenuation.z)); - vals[0] = FIX2FLT(color.red)*intensity; vals[1] = FIX2FLT(color.green)*intensity; vals[2] = FIX2FLT(color.blue)*intensity; vals[3] = 1; - glLightfv(iLight, GL_DIFFUSE, vals); - glLightfv(iLight, GL_SPECULAR, vals); - vals[0] = FIX2FLT(color.red)*ambientIntensity; vals[1] = FIX2FLT(color.green)*ambientIntensity; vals[2] = FIX2FLT(color.blue)*ambientIntensity; vals[3] = 1; - glLightfv(iLight, GL_AMBIENT, vals); - - glLightf(iLight, GL_SPOT_EXPONENT, 0); - glLightf(iLight, GL_SPOT_CUTOFF, 180); -#endif - return 1; -} - -Bool visual_3d_add_directional_light(GF_VisualManager *visual, Fixed _ambientIntensity, SFColor color, Fixed _intensity, SFVec3f direction) -{ -#ifdef GPAC_USE_OGL_ES - Fixed vals[4]; -#else - Float vals[4], ambientIntensity, intensity; -#endif - u32 iLight; - if (!visual->num_lights) glEnable(GL_LIGHTING); - if (visual->num_lights==visual->max_lights) return 0; - iLight = GL_LIGHT0 + visual->num_lights; - visual->num_lights++; - glEnable(iLight); - - /*in case...*/ - gf_vec_norm(&direction); -#ifdef GPAC_USE_OGL_ES - vals[0] = -direction.x; vals[1] = -direction.y; vals[2] = -direction.z; vals[3] = 0; - glLightxv(iLight, GL_POSITION, vals); - vals[0] = gf_mulfix(color.red, _intensity); vals[1] = gf_mulfix(color.green, _intensity); vals[2] = gf_mulfix(color.blue, _intensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_DIFFUSE, vals); - glLightxv(iLight, GL_SPECULAR, vals); - vals[0] = gf_mulfix(color.red, _ambientIntensity); vals[1] = gf_mulfix(color.green, _ambientIntensity); vals[2] = gf_mulfix(color.blue, _ambientIntensity); vals[3] = FIX_ONE; - glLightxv(iLight, GL_AMBIENT, vals); - - glLightx(iLight, GL_CONSTANT_ATTENUATION, FIX_ONE); - glLightx(iLight, GL_LINEAR_ATTENUATION, 0); - glLightx(iLight, GL_QUADRATIC_ATTENUATION, 0); - glLightx(iLight, GL_SPOT_CUTOFF, INT2FIX(180) ); -#else - ambientIntensity = FIX2FLT(_ambientIntensity); - intensity = FIX2FLT(_intensity); - - vals[0] = -FIX2FLT(direction.x); vals[1] = -FIX2FLT(direction.y); vals[2] = -FIX2FLT(direction.z); vals[3] = 0; - glLightfv(iLight, GL_POSITION, vals); - vals[0] = FIX2FLT(color.red)*intensity; vals[1] = FIX2FLT(color.green)*intensity; vals[2] = FIX2FLT(color.blue)*intensity; vals[3] = 1; - glLightfv(iLight, GL_DIFFUSE, vals); - glLightfv(iLight, GL_SPECULAR, vals); - vals[0] = FIX2FLT(color.red)*ambientIntensity; vals[1] = FIX2FLT(color.green)*ambientIntensity; vals[2] = FIX2FLT(color.blue)*ambientIntensity; vals[3] = 1; - glLightfv(iLight, GL_AMBIENT, vals); - - glLightf(iLight, GL_CONSTANT_ATTENUATION, 1.0f); - glLightf(iLight, GL_LINEAR_ATTENUATION, 0); - glLightf(iLight, GL_QUADRATIC_ATTENUATION, 0); - glLightf(iLight, GL_SPOT_CUTOFF, 180); -#endif - return 1; -} - -void visual_3d_remove_last_light(GF_VisualManager *visual) -{ - if (visual->num_lights) { - glDisable(GL_LIGHT0+visual->num_lights-1); - visual->num_lights--; - } -} - -void visual_3d_clear_all_lights(GF_VisualManager *visual) -{ - u32 i; - for (i=visual->num_lights; i>0; i--) { - glDisable(GL_LIGHT0+i-1); - } - visual->num_lights = 0; - //glDisable(GL_LIGHTING); -} - -void visual_3d_set_fog(GF_VisualManager *visual, const char *type, SFColor color, Fixed density, Fixed visibility) -{ - -#ifndef GPAC_USE_TINYGL - -#ifdef GPAC_USE_OGL_ES - Fixed vals[4]; - glEnable(GL_FOG); - if (!type || !stricmp(type, "LINEAR")) glFogx(GL_FOG_MODE, GL_LINEAR); - else if (!stricmp(type, "EXPONENTIAL")) glFogx(GL_FOG_MODE, GL_EXP); - else if (!stricmp(type, "EXPONENTIAL2")) glFogx(GL_FOG_MODE, GL_EXP2); - glFogx(GL_FOG_DENSITY, density); - glFogx(GL_FOG_START, 0); - glFogx(GL_FOG_END, visibility); - vals[0] = color.red; vals[1] = color.green; vals[2] = color.blue; vals[3] = FIX_ONE; - glFogxv(GL_FOG_COLOR, vals); - glHint(GL_FOG_HINT, visual->compositor->high_speed ? GL_FASTEST : GL_NICEST); -#else - Float vals[4]; - glEnable(GL_FOG); - if (!type || !stricmp(type, "LINEAR")) glFogi(GL_FOG_MODE, GL_LINEAR); - else if (!stricmp(type, "EXPONENTIAL")) glFogi(GL_FOG_MODE, GL_EXP); - else if (!stricmp(type, "EXPONENTIAL2")) glFogi(GL_FOG_MODE, GL_EXP2); - glFogf(GL_FOG_DENSITY, FIX2FLT(density)); - glFogf(GL_FOG_START, 0); - glFogf(GL_FOG_END, FIX2FLT(visibility)); - vals[0] = FIX2FLT(color.red); vals[1] = FIX2FLT(color.green); vals[2] = FIX2FLT(color.blue); vals[3] = 1; - glFogfv(GL_FOG_COLOR, vals); - glHint(GL_FOG_HINT, visual->compositor->high_speed ? GL_FASTEST : GL_NICEST); -#endif - -#endif - -} - void visual_3d_fill_rect(GF_VisualManager *visual, GF_Rect rc, SFColorRGBA color) { glDisable(GL_BLEND | GL_LIGHTING | GL_TEXTURE_2D); @@ -2333,14 +2248,18 @@ void visual_3d_fill_rect(GF_VisualManager *visual, GF_Rect rc, SFColorRGBA color indices[1] = 1; indices[2] = 2; - v[0] = rc.x; v[1] = rc.y; - v[2] = rc.x+rc.width; v[3] = rc.y-rc.height; - v[4] = rc.x+rc.width; v[5] = rc.y; + v[0] = rc.x; + v[1] = rc.y; + v[2] = rc.x+rc.width; + v[3] = rc.y-rc.height; + v[4] = rc.x+rc.width; + v[5] = rc.y; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FIXED, 0, v); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indices); - v[4] = rc.x; v[5] = rc.y-rc.height; + v[4] = rc.x; + v[5] = rc.y-rc.height; glVertexPointer(2, GL_FIXED, 0, v); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indices); @@ -2360,7 +2279,7 @@ void visual_3d_fill_rect(GF_VisualManager *visual, GF_Rect rc, SFColorRGBA color glVertex3f(FIX2FLT(rc.x+rc.width), FIX2FLT(rc.y-rc.height), 0); glVertex3f(FIX2FLT(rc.x+rc.width), FIX2FLT(rc.y), 0); glEnd(); - + glDisable(GL_COLOR_MATERIAL | GL_COLOR_MATERIAL_FACE); #endif @@ -2381,32 +2300,42 @@ GF_Err compositor_3d_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurfac /*depthmap-only dump*/ if (depth_dump_mode==1) { - + Float *depthp; + Float zFar, zNear; #ifdef GPAC_USE_OGL_ES return GF_NOT_SUPPORTED; #else fb->pitch_x = 0; - fb->pitch_y = compositor->vp_width; /* multiply by 4 if float depthbuffer */ + fb->pitch_y = compositor->vp_width; fb->video_buffer = (char*)gf_malloc(sizeof(char)* fb->pitch_y * fb->height); + //read as float + depthp = (Float*)gf_malloc(sizeof(Float)* fb->pitch_y * fb->height); fb->pixel_format = GF_PIXEL_GREYSCALE; #ifndef GPAC_USE_TINYGL - //glPixelTransferf(GL_DEPTH_SCALE, FIX2FLT(compositor->OGLDepthGain) ); - //glPixelTransferf(GL_DEPTH_BIAS, FIX2FLT(compositor->OGLDepthOffset) ); + //glPixelTransferf(GL_DEPTH_SCALE, FIX2FLT(compositor->OGLDepthGain) ); + //glPixelTransferf(GL_DEPTH_BIAS, FIX2FLT(compositor->OGLDepthOffset) ); #endif - glReadPixels(compositor->vp_x, compositor->vp_y, fb->width, fb->height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, fb->video_buffer); - //inversion - to check - for (i=0; iheight*fb->width; i++) - fb->video_buffer[i] = (char)(255 - (int) fb->video_buffer[i]) ; + glReadPixels(compositor->vp_x, compositor->vp_y, fb->width, fb->height, GL_DEPTH_COMPONENT, GL_FLOAT, depthp); + + //linearize z buffer, from 0 (zfar) to 1 (znear) + zFar = compositor->visual->camera.z_far; + zNear = compositor->visual->camera.z_near; + for (i=0; iheight*fb->width; i++) { + Float res = ( (2.0f * zNear) / (zFar + zNear - depthp[i] * (zFar - zNear)) ) ; + fb->video_buffer[i] = (u8) ( 255.0 * (1.0 - res)); + } + + gf_free(depthp); #endif /*GPAC_USE_OGL_ES*/ - } + } /* RGBDS or RGBD dump*/ - else if (depth_dump_mode==2 || depth_dump_mode==3){ + else if (depth_dump_mode==2 || depth_dump_mode==3) { #ifdef GPAC_USE_OGL_ES GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Compositor]: RGB+Depth format not implemented in OpenGL ES\n")); return GF_NOT_SUPPORTED; @@ -2422,14 +2351,14 @@ GF_Err compositor_3d_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurfac #endif - -#ifndef GPAC_USE_TINYGL - + +#ifndef GPAC_USE_TINYGL + glReadPixels(0, 0, fb->width, fb->height, GL_RGBA, GL_UNSIGNED_BYTE, fb->video_buffer); /* - glPixelTransferf(GL_DEPTH_SCALE, FIX2FLT(compositor->OGLDepthGain)); - glPixelTransferf(GL_DEPTH_BIAS, FIX2FLT(compositor->OGLDepthOffset)); + glPixelTransferf(GL_DEPTH_SCALE, FIX2FLT(compositor->OGLDepthGain)); + glPixelTransferf(GL_DEPTH_BIAS, FIX2FLT(compositor->OGLDepthOffset)); */ depth_data = (char*) gf_malloc(sizeof(char)*fb->width*fb->height); @@ -2438,46 +2367,47 @@ GF_Err compositor_3d_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurfac if (depth_dump_mode==2) { u32 i; fb->pixel_format = GF_PIXEL_RGBDS; - + /*this corresponds to the RGBDS ordering*/ for (i=0; iheight*fb->width; i++) { u8 ds; /* erase lowest-weighted depth bit */ - u8 depth = depth_data[i] & 0xfe; + u8 depth = depth_data[i] & 0xfe; /*get alpha*/ ds = (fb->video_buffer[i*4 + 3]); /* if heaviest-weighted alpha bit is set (>128) , turn on shape bit*/ if (ds & 0x80) depth |= 0x01; - fb->video_buffer[i*4+3] = depth; /*insert depth onto alpha*/ + fb->video_buffer[i*4+3] = depth; /*insert depth onto alpha*/ } - /*this corresponds to RGBD ordering*/ + /*this corresponds to RGBD ordering*/ } else if (depth_dump_mode==3) { u32 i; fb->pixel_format = GF_PIXEL_RGBD; - for (i=0; iheight*fb->width; i++) + for (i=0; iheight*fb->width; i++) fb->video_buffer[i*4+3] = depth_data[i]; } #else GF_LOG(GF_LOG_ERROR, GF_LOG_COMPOSE, ("[Compositor]: RGB+Depth format not implemented in TinyGL\n")); return GF_NOT_SUPPORTED; #endif - + #endif /*GPAC_USE_OGL_ES*/ - - } else if (compositor->user && (compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT)) { + + } else { /*if (compositor->user && (compositor->user->init_flags & GF_TERM_WINDOW_TRANSPARENT))*/ fb->pitch_x = 4; fb->pitch_y = 4*compositor->vp_width; fb->video_buffer = (char*)gf_malloc(sizeof(char) * fb->pitch_y * fb->height); fb->pixel_format = GF_PIXEL_RGBA; glReadPixels(compositor->vp_x, compositor->vp_y, fb->width, fb->height, GL_RGBA, GL_UNSIGNED_BYTE, fb->video_buffer); - } else { - fb->pitch_x = 3; - fb->pitch_y = 3*compositor->vp_width; - fb->video_buffer = (char*)gf_malloc(sizeof(char) * fb->pitch_y * fb->height); - fb->pixel_format = GF_PIXEL_RGB_24; + /* } else { + fb->pitch_x = 3; + fb->pitch_y = 3*compositor->vp_width; + fb->video_buffer = (char*)gf_malloc(sizeof(char) * fb->pitch_y * fb->height); + fb->pixel_format = GF_PIXEL_RGB_24; - glReadPixels(compositor->vp_x, compositor->vp_y, fb->width, fb->height, GL_RGB, GL_UNSIGNED_BYTE, fb->video_buffer); + glReadPixels(compositor->vp_x, compositor->vp_y, fb->width, fb->height, GL_RGB, GL_UNSIGNED_BYTE, fb->video_buffer); + */ } #ifndef GPAC_USE_TINYGL @@ -2572,19 +2502,25 @@ void visual_3d_point_sprite(GF_VisualManager *visual, Drawable *stack, GF_Textur inc = 1; if (!tr_state->pixel_metrics) inc /= FIX2FLT(tr_state->min_hsize); x = 0; - y = 1; y = gf_mulfix(y, INT2FIX(txh->height/2)); + y = 1; + y = gf_mulfix(y, INT2FIX(txh->height/2)); if (!tr_state->pixel_metrics) y = gf_divfix(y, tr_state->min_hsize); glBegin(GL_POINTS); for (h=0; hheight; h++) { - x = -1; x = gf_mulfix(x, INT2FIX(txh->width/2)); + x = -1; + x = gf_mulfix(x, INT2FIX(txh->width/2)); if (!tr_state->pixel_metrics) x = gf_divfix(x, tr_state->min_hsize); for (w=0; wwidth; w++) { u8 *p = data + h*stride + w*4; - r = p[0]; r /= 255; - g = p[1]; g /= 255; - b = p[2]; b /= 255; - z = p[3]; z = z / 255; + r = p[0]; + r /= 255; + g = p[1]; + g /= 255; + b = p[2]; + b /= 255; + z = p[3]; + z = z / 255; glColor4f(r, g, b, 1.0); glVertex3f(FIX2FLT(x), FIX2FLT(y), FIX2FLT(-z)*60); @@ -2622,13 +2558,15 @@ restart: inc = 1; if (!tr_state->pixel_metrics) inc /= FIX2FLT(tr_state->min_hsize); x = 0; - y = 1; y = gf_mulfix(y, INT2FIX(txh->height/2));; + y = 1; + y = gf_mulfix(y, INT2FIX(txh->height/2));; if (!tr_state->pixel_metrics) y = gf_divfix(y, tr_state->min_hsize); in_strip = 0; for (h=0; hheight - 1; h++) { u8 *src = data + h*stride; - x = -1; x = gf_mulfix(x, INT2FIX(txh->width/2)); + x = -1; + x = gf_mulfix(x, INT2FIX(txh->width/2)); if (!tr_state->pixel_metrics) x = gf_divfix(x, tr_state->min_hsize); for (w=0; wwidth; w++) { @@ -2637,7 +2575,7 @@ restart: Float z1 = p1[3]; Float z2 = p2[3]; if (first_pass==1) { - if ((z1>delta) || (z2>delta)) + if ((z1>delta) || (z2>delta)) { if (0 && in_strip) { glEnd(); @@ -2647,7 +2585,7 @@ restart: continue; } } else if (first_pass==0) { - if ((z1<=delta) || (z2<=delta)) + if ((z1<=delta) || (z2<=delta)) { if (in_strip) { glEnd(); @@ -2709,12 +2647,14 @@ restart: inc = 1; if (!tr_state->pixel_metrics) inc /= FIX2FLT(tr_state->min_hsize); x = 0; - y = 1; y = gf_mulfix(y, FLT2FIX(txh->height/2)); + y = 1; + y = gf_mulfix(y, FLT2FIX(txh->height/2)); if (!tr_state->pixel_metrics) y = gf_divfix(y, tr_state->min_hsize); for (h=0; hheight; h++) { u32 idx_offset = h ? ((h-1)*txh->width) : 0; - x = -1; x = gf_mulfix(x, FLT2FIX(txh->width/2)); + x = -1; + x = gf_mulfix(x, FLT2FIX(txh->width/2)); if (!tr_state->pixel_metrics) x = gf_divfix(x, tr_state->min_hsize); for (w=0; wwidth; w++) { @@ -2756,13 +2696,14 @@ restart: stack->mesh->vbo_dirty = 1; } tr_state->mesh_num_textures = gf_sc_texture_enable(txh, ((M_Appearance *)tr_state->appear)->textureTransform); - VS3D_DrawMeshIntern(tr_state, stack->mesh); + visual_3d_draw_mesh(tr_state, stack->mesh); visual_3d_disable_texture(tr_state); #endif //GPAC_USE_OGL_ES } + #endif /*GPAC_DISABLE_3D*/ diff --git a/src/compositor/x3d_geometry.c b/src/compositor/x3d_geometry.c index a31d723..76e15f2 100644 --- a/src/compositor/x3d_geometry.c +++ b/src/compositor/x3d_geometry.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -264,9 +264,10 @@ static void TraverseTriangleSet2D(GF_Node *node, void *rs, Bool is_destroy) stack->mesh = new_mesh(); stack->mesh->mesh_type = MESH_TRIANGLES; - col.red = col.green = col.blue = 0; col.alpha = FIX_ONE; + col.red = col.green = col.blue = 0; + col.alpha = FIX_ONE; v1.color = MESH_MAKE_COL(col); - v1.normal.x = v1.normal.y = 0; + v1.normal.x = v1.normal.y = 0; v1.normal.z = MESH_NORMAL_UNIT; v1.pos.z = 0; v3 = v2 = v1; @@ -330,7 +331,8 @@ static void build_polypoint2d(GF_Node *node, Drawable3D *stack, GF_TraverseState X_Polypoint2D *p = (X_Polypoint2D *)node; stack->mesh->mesh_type = MESH_POINTSET; - col.red = col.green = col.blue = 0; col.alpha = FIX_ONE; + col.red = col.green = col.blue = 0; + col.alpha = FIX_ONE; for (i=0; ipoint.count; i++) { mesh_set_point(stack->mesh, p->point.vals[i].x, p->point.vals[i].y, 0, col); mesh_set_index(stack->mesh, stack->mesh->v_count-1); @@ -420,9 +422,9 @@ static void BuildTriangleSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color, G Bool rgba_col; SFColorRGBA rgba; X_Coordinate *c = (X_Coordinate *) _coords; - + mesh_reset(mesh); - + cols = NULL; rgba_col = 0; if (_color) { @@ -481,13 +483,22 @@ static void BuildTriangleSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color, G } if (txcoords) { if (txcoords->count>idx) vx.texcoords = txcoords->vals[idx]; - } + } /*X3D says nothing about default texture mapping here...*/ else if (!generate_tx) { switch (i%3) { - case 2: vx.texcoords.x = FIX_ONE; vx.texcoords.y = 0; break; - case 1: vx.texcoords.x = FIX_ONE/2; vx.texcoords.y = FIX_ONE; break; - case 0: vx.texcoords.x = 0; vx.texcoords.y = 0; break; + case 2: + vx.texcoords.x = FIX_ONE; + vx.texcoords.y = 0; + break; + case 1: + vx.texcoords.x = FIX_ONE/2; + vx.texcoords.y = FIX_ONE; + break; + case 0: + vx.texcoords.x = 0; + vx.texcoords.y = 0; + break; } } mesh_set_vertex_vx(mesh, &vx); @@ -564,9 +575,9 @@ static void BuildTriangleStripSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_col Bool rgba_col; SFColorRGBA rgba; X_Coordinate *c = (X_Coordinate *) _coords; - + mesh_reset(mesh); - + cols = NULL; rgba_col = 0; if (_color) { @@ -630,13 +641,22 @@ static void BuildTriangleStripSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_col } if (txcoords) { if (txcoords->count>idx) vx.texcoords = txcoords->vals[idx]; - } + } /*X3D says nothing about default texture mapping here...*/ else if (!generate_tx) { switch (idx%3) { - case 2: vx.texcoords.x = FIX_ONE; vx.texcoords.y = 0; break; - case 1: vx.texcoords.x = FIX_ONE/2; vx.texcoords.y = FIX_ONE; break; - case 0: vx.texcoords.x = 0; vx.texcoords.y = 0; break; + case 2: + vx.texcoords.x = FIX_ONE; + vx.texcoords.y = 0; + break; + case 1: + vx.texcoords.x = FIX_ONE/2; + vx.texcoords.y = FIX_ONE; + break; + case 0: + vx.texcoords.x = 0; + vx.texcoords.y = 0; + break; } } if (i>2) { @@ -690,7 +710,10 @@ static void BuildTriangleStripSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_col SFVec3f n_0, n_1, n_2, n_avg; u32 nb_face; if (stripList->vals[strip] < 3) continue; - if (stripList->vals[strip] <= 3) { cur_face ++; continue; } + if (stripList->vals[strip] <= 3) { + cur_face ++; + continue; + } /*first face normal*/ MESH_GET_NORMAL(n_0, mesh->vertices[mesh->indices[3*cur_face]]); @@ -754,7 +777,8 @@ static void build_indexed_triangle_strip_set(GF_Node *node, Drawable3D *stack, G if (!itss->coord) return; - stripList.count = 0; stripList.vals = NULL; + stripList.count = 0; + stripList.vals = NULL; nb_strips = 0; for (i=0; iindex.count; i++) { if (itss->index.vals[i]==-1) { @@ -809,7 +833,7 @@ static void BuildTriangleFanSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color SFColorRGBA rgba; X_Coordinate *c = (X_Coordinate *) _coords; mesh_reset(mesh); - + cols = NULL; rgba_col = 0; if (_color) { @@ -873,13 +897,22 @@ static void BuildTriangleFanSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color } if (txcoords) { if (txcoords->count>idx) vx.texcoords = txcoords->vals[idx]; - } + } /*X3D says nothing about default texture mapping here...*/ else if (!generate_tx) { switch (idx%3) { - case 2: vx.texcoords.x = FIX_ONE; vx.texcoords.y = 0; break; - case 1: vx.texcoords.x = FIX_ONE/2; vx.texcoords.y = FIX_ONE; break; - case 0: vx.texcoords.x = 0; vx.texcoords.y = 0; break; + case 2: + vx.texcoords.x = FIX_ONE; + vx.texcoords.y = 0; + break; + case 1: + vx.texcoords.x = FIX_ONE/2; + vx.texcoords.y = FIX_ONE; + break; + case 0: + vx.texcoords.x = 0; + vx.texcoords.y = 0; + break; } } mesh_set_vertex_vx(mesh, &vx); @@ -888,7 +921,7 @@ static void BuildTriangleFanSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color if (indices) { if (cur_idx>=indices->count) break; } else if (cur_idx==c->point.count) break; - + if (i>1) { mesh_set_vertex_vx(mesh, &mesh->vertices[start_idx]); mesh_set_vertex_vx(mesh, &vx); @@ -913,8 +946,11 @@ static void BuildTriangleFanSet(GF_Mesh *mesh, GF_Node *_coords, GF_Node *_color SFVec3f n_0, n_1, n_avg, n_tot; u32 nb_face, start_face; if (fanList->vals[fan] < 3) continue; - if (fanList->vals[fan] == 3) { cur_face++; continue; } - + if (fanList->vals[fan] == 3) { + cur_face++; + continue; + } + start_face = cur_face; /*first face normal*/ @@ -970,7 +1006,8 @@ static void build_indexed_triangle_fan_set(GF_Node *node, Drawable3D *stack, GF_ gf_node_dirty_clear(node, 0); if (!itfs->coord) return; - fanList.count = 0; fanList.vals = NULL; + fanList.count = 0; + fanList.vals = NULL; nb_fans = 0; for (i=0; iindex.count; i++) { if (itfs->index.vals[i]==-1) { diff --git a/src/export.cpp b/src/export.cpp index 1899362..9a8d31a 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -1,25 +1,25 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * - * This file is part of GPAC + * This file is part of GPAC * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -267,6 +267,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_url_remove_last_delimiter) ) #pragma comment (linker, EXPORT_SYMBOL(gf_url_get_ressource_extension) ) #pragma comment (linker, EXPORT_SYMBOL(gf_utc_time_since_1970) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_gettimeofday) ) #pragma comment (linker, EXPORT_SYMBOL(gf_net_get_ntp) ) #pragma comment (linker, EXPORT_SYMBOL(gf_net_get_utc) ) #pragma comment (linker, EXPORT_SYMBOL(gf_net_parse_date) ) @@ -275,10 +276,12 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_net_is_ipv6) ) #pragma comment (linker, EXPORT_SYMBOL(gf_net_mobileip_set_callback) ) +#ifndef GPAC_DISABLE_CORE_TOOLS #pragma comment (linker, EXPORT_SYMBOL(gf_base64_encode) ) #pragma comment (linker, EXPORT_SYMBOL(gf_base64_decode) ) #pragma comment (linker, EXPORT_SYMBOL(gf_base16_encode) ) #pragma comment (linker, EXPORT_SYMBOL(gf_base16_decode) ) +#endif #pragma comment (linker, EXPORT_SYMBOL(gf_bin128_parse) ) @@ -329,6 +332,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_utf8_reorder_bidi) ) #endif +#ifndef GPAC_DISABLE_CORE_TOOLS #pragma comment (linker, EXPORT_SYMBOL(gf_dm_new) ) #pragma comment (linker, EXPORT_SYMBOL(gf_dm_sess_new) ) #pragma comment (linker, EXPORT_SYMBOL(gf_dm_sess_new_simple) ) @@ -405,6 +409,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_xml_dom_parse_string) ) #pragma comment (linker, EXPORT_SYMBOL(gf_xml_parse_bit_sequence) ) #pragma comment (linker, EXPORT_SYMBOL(gf_xml_dom_detach_root) ) +#endif #ifndef GPAC_DISABLE_SVG #pragma comment (linker, EXPORT_SYMBOL(gf_dom_get_key_name) ) @@ -590,6 +595,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_odf_avc_cfg_del) ) #pragma comment (linker, EXPORT_SYMBOL(gf_odf_avc_cfg_new) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_odf_hevc_cfg_new) ) #pragma comment (linker, EXPORT_SYMBOL(gf_odf_hevc_cfg_read) ) #pragma comment (linker, EXPORT_SYMBOL(gf_odf_hevc_cfg_del) ) @@ -790,10 +796,15 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_composition_offset_shift) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_has_scalable_layer) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_last_producer_time_box) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_sync_table) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_current_tfdt) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_is_adobe_protection_media) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_adobe_protection_info) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_sample_group_info) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_get_tile_info) ) + +#ifndef GPAC_DISABLE_ISOM_WRITE +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_sync_table) ) +#endif # ifndef GPAC_DISABLE_ISOM_DUMP #pragma comment (linker, EXPORT_SYMBOL(gf_isom_dump) ) @@ -924,6 +935,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_isom_avc_config_update) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_avc_set_inband_config) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_svc_config_update) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_hevc_config_new) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_hevc_config_update) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_hevc_set_inband_config) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_shvc_config_update) ) @@ -954,7 +966,8 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_sample_cenc_group) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_composition_offset_mode) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_output_buffering) ) - +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_add_sample_group_info) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_add_sample_info) ) #ifndef GPAC_DISABLE_ISOM_HINTING #pragma comment (linker, EXPORT_SYMBOL(gf_isom_setup_hint_track) ) @@ -989,7 +1002,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_isom_fragment_add_sample) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_fragment_append_data) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_fragment_add_sai) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_isom_clone_pssh) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_isom_clone_pssh) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_start_segment) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_close_segment) ) #pragma comment (linker, EXPORT_SYMBOL(gf_isom_set_traf_base_media_decode_time) ) @@ -1033,34 +1046,20 @@ #endif /*GPAC_DISABLE_ISOM*/ -/*plugin_network.h exports*/ +/*service.h exports*/ #ifndef GPAC_DISABLE_PLAYER -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_message) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_connect) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_disconnect) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_command) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_sl_packet) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_service_url) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_on_service_event) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_add_media) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_service_interface) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_register_mime_type) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_check_extension) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_download_new) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_download_del) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_download_update_stats) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_scene_update) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_process_step) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_screen_buffer) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_release_screen_buffer) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_offscreen_buffer) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_process_shortcut) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_set_speed) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_relocate_url) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_add_event_filter) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_remove_event_filter) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_lock_media_queue) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_current_service_id) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_connect_ack) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_disconnect_ack) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_command) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_send_packet) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_get_url) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_declare_media) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_get_interface) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_register_mime) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_check_mime_register) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_download_new) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_download_del) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_download_update_stats) ) /*mediaobject.h exports*/ #pragma comment (linker, EXPORT_SYMBOL(gf_mo_register) ) @@ -1091,11 +1090,16 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_mo_set_position) ) #pragma comment (linker, EXPORT_SYMBOL(gf_mo_get_flags) ) #pragma comment (linker, EXPORT_SYMBOL(gf_mo_set_flag) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_mo_get_min_frame_dur) ) + +#ifndef GPAC_DISABLE_SVG #pragma comment (linker, EXPORT_SYMBOL(gf_mo_load_xlink_resource) ) #pragma comment (linker, EXPORT_SYMBOL(gf_mo_unload_xlink_resource) ) #pragma comment (linker, EXPORT_SYMBOL(gf_mo_get_scenegraph) ) #endif +#endif + /*ietf.h exports*/ #ifndef GPAC_DISABLE_STREAMING #pragma comment (linker, EXPORT_SYMBOL(gf_rtsp_nc_to_string) ) @@ -1262,6 +1266,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_hevc_get_sps_info) ) #pragma comment (linker, EXPORT_SYMBOL(gf_hevc_get_profile_name) ) #pragma comment (linker, EXPORT_SYMBOL(gf_hevc_get_sps_info_with_state) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_media_hevc_parse_nalu) ) #endif //GPAC_DISABLE_HEVC @@ -1327,9 +1332,12 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_mp3_version) ) #pragma comment (linker, EXPORT_SYMBOL(gf_mp3_version_name) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m4a_object_type_name) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_m4a_get_profile) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m4a_get_profile_name) ) +#ifndef GPAC_DISABLE_AV_PARSERS +#pragma comment (linker, EXPORT_SYMBOL(gf_m4a_get_profile) ) +#endif + #if !defined(GPAC_DISABLE_MCRYPT) && !defined(GPAC_DISABLE_ISOM_WRITE) /*ismacryp.h exports*/ #pragma comment (linker, EXPORT_SYMBOL(gf_crypt_file) ) @@ -1643,7 +1651,7 @@ #ifdef GPAC_HAS_SPIDERMONKEY #ifndef GPAC_DISABLE_SVG #pragma comment (linker, EXPORT_SYMBOL(gf_sg_handle_dom_event_for_vrml) ) -#endif +#endif #endif #endif /*GPAC_DISABLE_VRML*/ @@ -1670,6 +1678,8 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_object) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_object_subscene_type) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_select_object) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_select_service) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_toggle_addons) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_object_info) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_download_info) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_channel_net_info) ) @@ -1688,7 +1698,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_simulation_frame_rate) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_step_clocks) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_process_flush) ) -#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_service_interface) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_service_get_interface) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_service_info) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_text_selection) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_paste_text) ) @@ -1702,6 +1712,18 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_term_lock_compositor) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_switch_quality) ) #pragma comment (linker, EXPORT_SYMBOL(gf_term_get_visual_output_size) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_scene_update) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_process_step) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_screen_buffer) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_release_screen_buffer) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_offscreen_buffer) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_process_shortcut) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_set_speed) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_relocate_url) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_add_event_filter) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_remove_event_filter) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_lock_media_queue) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_term_get_current_service_id) ) /*terminal_dev exports*/ #pragma comment (linker, EXPORT_SYMBOL(gf_scene_new) ) @@ -1806,6 +1828,9 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_crc32_check) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_restamp) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_demux_file) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_pes_get_framing_mode) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_get_sdt_info) ) + /* carousel.h */ #ifdef GPAC_ENABLE_DSMCC @@ -1820,6 +1845,7 @@ #ifndef GPAC_DISABLE_MPEG2TS_MUX #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_new) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_del) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_set_pcr_max_interval) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_program_add) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_program_stream_add) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_program_stream_update_ts_scale) ) @@ -1829,6 +1855,9 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_get_ts_clock) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_use_single_au_pes_mode) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_set_initial_pcr) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_program_set_name) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_enable_sdt) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_mux_program_find) ) #endif /*GPAC_DISABLE_MPEG2TS_MUX*/ /* M3U8 & MPD related functions */ @@ -1843,9 +1872,9 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_demuxer_setup)) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_demuxer_play) ) #pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_demuxer_close) ) +#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_get_socket) ) #endif /*GPAC_DISABLE_MPEG2TS*/ -#pragma comment (linker, EXPORT_SYMBOL(gf_m2ts_get_socket) ) /*laser.h exports*/ #ifndef GPAC_DISABLE_LASER @@ -1864,20 +1893,26 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_laser_encoder_get_rap) ) #endif /*GPAC_DISABLE_LASER*/ +#ifndef GPAC_DISABLE_CORE_TOOLS /*download.h exports*/ #pragma comment (linker, EXPORT_SYMBOL(gf_dm_wget) ) #pragma comment (linker, EXPORT_SYMBOL(gf_dm_wget_with_cache) ) +#endif #ifndef GPAC_DISABLE_ISOM_WRITE /*to be removed once TS fragmenter is moved to libgpac */ #pragma comment (linker, EXPORT_SYMBOL(gf_media_mpd_format_segment_name) ) + +#pragma comment (linker, EXPORT_SYMBOL(gf_media_get_rfc_6381_codec_name) ) #ifndef GPAC_DISABLE_ISOM_FRAGMENTS #pragma comment (linker, EXPORT_SYMBOL(gf_media_fragment_file) ) #endif #endif +#ifndef GPAC_DISABLE_ISOM_WRITE #pragma comment (linker, EXPORT_SYMBOL(gf_dasher_segment_files) ) #pragma comment (linker, EXPORT_SYMBOL(gf_dasher_next_update_time) ) +#endif /* dvb_mpe.h */ #ifdef GPAC_ENST_PRIVATE @@ -1942,7 +1977,7 @@ #pragma comment (linker, EXPORT_SYMBOL(gf_dash_set_user_buffer) ) #endif -#ifndef GPAC_DISABLE_VTT +#ifndef GPAC_DISABLE_ISOM_WRITE #pragma comment (linker, EXPORT_SYMBOL(gf_webvtt_js_addCue) ) #pragma comment (linker, EXPORT_SYMBOL(gf_webvtt_js_removeCues) ) #pragma comment (linker, EXPORT_SYMBOL(gf_webvtt_parse_cues_from_data) ) diff --git a/src/ietf/rtcp.c b/src/ietf/rtcp.c index 3fafcc0..cdeccd2 100644 --- a/src/ietf/rtcp.c +++ b/src/ietf/rtcp.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,7 +58,7 @@ GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size, Bool *has_ GF_Err e = GF_OK; if (has_sr) *has_sr=0; - + //bad RTCP packet if (pck_size < 4 ) return GF_NON_COMPLIANT_BITSTREAM; bs = gf_bs_new(pck, pck_size, GF_BITSTREAM_READ); @@ -74,7 +74,7 @@ GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size, Bool *has_ rtcp_hdr.Padding = gf_bs_read_int(bs, 1); rtcp_hdr.Count = gf_bs_read_int(bs, 5); rtcp_hdr.PayloadType = gf_bs_read_u8(bs); - rtcp_hdr.Length = 1 + gf_bs_read_u16(bs); + rtcp_hdr.Length = 1 + gf_bs_read_u16(bs); //check pck size if (pck_size < (u32) rtcp_hdr.Length * 4) { @@ -86,20 +86,20 @@ GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size, Bool *has_ pck_size -= rtcp_hdr.Length * 4; /*we read the RTCP header*/ - rtcp_hdr.Length -= 1; + rtcp_hdr.Length -= 1; //in all RTCP Compounds (>1 pck), the first RTCP report SHALL be SR or RR without padding if (first) { if ( ( (rtcp_hdr.PayloadType!=200) && (rtcp_hdr.PayloadType!=201) ) - || rtcp_hdr.Padding - ) { + || rtcp_hdr.Padding + ) { gf_bs_del(bs); GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTCP] Corrupted RTCP packet: payload type %d (200 or 201 expected) - Padding %d (0 expected)\n", rtcp_hdr.PayloadType, rtcp_hdr.Padding)); return GF_CORRUPTED_DATA; } first = 0; } - + //specific extensions switch (rtcp_hdr.PayloadType) { //Sender report - we assume there's only one sender @@ -134,16 +134,16 @@ GF_Err gf_rtp_decode_rtcp(GF_RTPChannel *ch, char *pck, u32 pck_size, Bool *has_ #else const char *ascTime = "Not Available"; #endif - GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] RTCP SR: SSRC %d - RTP Time %d - Nb Pck %d - Nb Bytes %d - Time %s\n", - ch->SenderSSRC, - ch->last_SR_rtp_time, - ch->total_pck, - ch->total_bytes, - ascTime - )); + GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] RTCP SR: SSRC %d - RTP Time %d - Nb Pck %d - Nb Bytes %d - Time %s\n", + ch->SenderSSRC, + ch->last_SR_rtp_time, + ch->total_pck, + ch->total_bytes, + ascTime + )); } #endif - + //common encoding for SR and RR goto process_reports; @@ -226,26 +226,26 @@ process_reports: rtcp_hdr.Length -= 1; } break; -/* - //APP packet - case 204: + /* + //APP packet + case 204: - //sender ssrc - sender_ssrc = gf_bs_read_u32(bs); - //ASCI 4 char type - gf_bs_read_u8(bs); - gf_bs_read_u8(bs); - gf_bs_read_u8(bs); - gf_bs_read_u8(bs); - - rtcp_hdr.Length -= 2; - - //till endd of pck - gf_bs_read_data(bs, sdes_buffer, rtcp_hdr.Length*4); - rtcp_hdr.Length = 0; - break; -*/ + //sender ssrc + sender_ssrc = gf_bs_read_u32(bs); + //ASCI 4 char type + gf_bs_read_u8(bs); + gf_bs_read_u8(bs); + gf_bs_read_u8(bs); + gf_bs_read_u8(bs); + + rtcp_hdr.Length -= 2; + + //till endd of pck + gf_bs_read_data(bs, sdes_buffer, rtcp_hdr.Length*4); + rtcp_hdr.Length = 0; + break; + */ default: //read all till end gf_bs_read_data(bs, sdes_buffer, rtcp_hdr.Length*4); @@ -291,7 +291,7 @@ static u32 RTCP_FormatReport(GF_RTPChannel *ch, GF_BitStream *bs, u32 NTP_Time) gf_bs_write_int(bs, 0, 1); //count - only one for now in RR, 0 in sender mode gf_bs_write_int(bs, !is_sr, 5); - //if we have sent stuff send an SR, otherwise an RR. We need to determine whether + //if we have sent stuff send an SR, otherwise an RR. We need to determine whether //we are active or not //type gf_bs_write_u8(bs, is_sr ? 200 : 201); @@ -335,7 +335,7 @@ static u32 RTCP_FormatReport(GF_RTPChannel *ch, GF_BitStream *bs, u32 NTP_Time) extended = ( (ch->num_sn_loops << 16) | ch->last_pck_sn); expected = extended - ch->rtp_first_SN; expect_diff = expected - ch->tot_num_pck_expected; - loss_diff = expect_diff - ch->last_num_pck_rcv; + loss_diff = expect_diff - ch->last_num_pck_rcv; if (!expect_diff || (loss_diff <= 0)) loss_diff = 0; else loss_diff = (loss_diff<<8) / expect_diff; @@ -350,7 +350,7 @@ static u32 RTCP_FormatReport(GF_RTPChannel *ch, GF_BitStream *bs, u32 NTP_Time) //Extend sequence number gf_bs_write_u32(bs, extended); - + //Jitter //RTP specs annexe A.8 gf_bs_write_u32(bs, ( ch->Jitter >> 4)); @@ -370,14 +370,14 @@ static u32 RTCP_FormatReport(GF_RTPChannel *ch, GF_BitStream *bs, u32 NTP_Time) #else const char *ascTime = "Not Available"; #endif - GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] RTCP-RR\t%d\t%d\t%d\t%d\t%d\t%s\n", - ch->SSRC, - ch->Jitter >> 4, - extended, - expect_diff, - loss_diff, - ascTime - )); + GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] RTCP-RR\t%d\t%d\t%d\t%d\t%d\t%s\n", + ch->SSRC, + ch->Jitter >> 4, + extended, + expect_diff, + loss_diff, + ascTime + )); } #endif @@ -404,16 +404,16 @@ static u32 RTCP_FormatSDES(GF_RTPChannel *ch, GF_BitStream *bs) padd = 0; length = length/4; } - + //common part as usual gf_bs_write_int(bs, 2, 2); - //notify padding? according to RFC1889 "In a compound RTCP packet, padding should - //only be required on the last individual packet because the compound packet is - //encrypted as a whole" -> we write it without notifying it (this is a bit messy in + //notify padding? according to RFC1889 "In a compound RTCP packet, padding should + //only be required on the last individual packet because the compound packet is + //encrypted as a whole" -> we write it without notifying it (this is a bit messy in //the spec IMO) gf_bs_write_int(bs, 0, 1); //report count is one - gf_bs_write_int(bs, 1, 5); + gf_bs_write_int(bs, 1, 5); //SDES pck type gf_bs_write_u8(bs, 202); //write length minus one @@ -425,7 +425,7 @@ static u32 RTCP_FormatSDES(GF_RTPChannel *ch, GF_BitStream *bs) //CNAME type gf_bs_write_u8(bs, 1); //length and cname - gf_bs_write_u8(bs, (u32) strlen(ch->CName)); + gf_bs_write_u8(bs, (u32) strlen(ch->CName)); gf_bs_write_data(bs, ch->CName, (u32) strlen(ch->CName)); gf_bs_write_u8(bs, 0); @@ -456,8 +456,8 @@ static u32 RTCP_FormatBYE(GF_RTPChannel *ch, GF_BitStream *bs) GF_EXPORT GF_Err gf_rtp_send_bye(GF_RTPChannel *ch, - GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), - void *rtsp_cbk) + GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), + void *rtsp_cbk) { GF_BitStream *bs; u32 report_size; @@ -486,7 +486,7 @@ GF_Err gf_rtp_send_bye(GF_RTPChannel *ch, if (ch->rtcp) { e = gf_sk_send(ch->rtcp, report_buf, report_size); } else { - if (RTP_TCPCallback) + if (RTP_TCPCallback) e = RTP_TCPCallback(rtsp_cbk, report_buf, report_size); else e = GF_BAD_PARAM; @@ -496,9 +496,9 @@ GF_Err gf_rtp_send_bye(GF_RTPChannel *ch, } GF_EXPORT -GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, - GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), - void *rtsp_cbk) +GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, + GF_Err (*RTP_TCPCallback)(void *cbk, char *pck, u32 pck_size), + void *rtsp_cbk) { u32 Time, report_size; GF_BitStream *bs; @@ -507,7 +507,7 @@ GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, /*skip first SR when acting as a receiver*/ if (!ch->forced_ntp_sec && ch->first_SR) return GF_OK; - Time = gf_rtp_get_report_time(); + Time = gf_rtp_get_report_time(); if ( Time < ch->next_report_time) return GF_OK; bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); @@ -531,7 +531,7 @@ GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, if (ch->rtcp) { e = gf_sk_send(ch->rtcp, report_buf, report_size); } else { - if (RTP_TCPCallback) + if (RTP_TCPCallback) e = RTP_TCPCallback(rtsp_cbk, report_buf, report_size); else e = GF_BAD_PARAM; @@ -540,10 +540,14 @@ GF_Err gf_rtp_send_rtcp_report(GF_RTPChannel *ch, ch->rtcp_bytes_sent += report_size; gf_free(report_buf); - + if (!e) { //Update the channel record if no error - otherwise next RTCP will triger an RR ch->last_num_pck_rcv = ch->last_num_pck_expected = ch->last_num_pck_loss = 0; + GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTCP] SSRC %d: sending RTCP report\n", ch->SSRC)); + } + else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTCP] SSRC %d: error when sending RTCP report\n", ch->SSRC)); } gf_rtp_get_next_report_time(ch); return e; diff --git a/src/ietf/rtp.c b/src/ietf/rtp.c index 6f38be5..444bafa 100644 --- a/src/ietf/rtp.c +++ b/src/ietf/rtp.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -83,10 +83,10 @@ GF_Err gf_rtp_setup_transport(GF_RTPChannel *ch, GF_RTSPTransport *trans_info, c ch->net_info.source = NULL; memcpy(&ch->net_info, trans_info, sizeof(GF_RTSPTransport)); - if (trans_info->destination) + if (trans_info->destination) ch->net_info.destination = gf_strdup(trans_info->destination); - if (trans_info->Profile) + if (trans_info->Profile) ch->net_info.Profile = gf_strdup(trans_info->Profile); if (!ch->net_info.IsUnicast && trans_info->destination) { @@ -180,27 +180,27 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 ch->rtp_time = 0; //create sockets for RTP/AVP profile only - if (ch->net_info.Profile && - ( !stricmp(ch->net_info.Profile, GF_RTSP_PROFILE_RTP_AVP) - || !stricmp(ch->net_info.Profile, "RTP/AVP/UDP") - || !stricmp(ch->net_info.Profile, "RTP/SAVP") - ) - ) { + if (ch->net_info.Profile && + ( !stricmp(ch->net_info.Profile, GF_RTSP_PROFILE_RTP_AVP) + || !stricmp(ch->net_info.Profile, "RTP/AVP/UDP") + || !stricmp(ch->net_info.Profile, "RTP/SAVP") + ) + ) { //destination MUST be specified for unicast if (IsSource && ch->net_info.IsUnicast && !ch->net_info.destination) return GF_BAD_PARAM; - /* forcing unicast when the address is not a multicast */ - if (!ch->net_info.IsUnicast) { - if (IsSource){ - if (ch->net_info.destination && !gf_sk_is_multicast_address(ch->net_info.destination)) { - ch->net_info.IsUnicast = 1; - } - } else { - if (ch->net_info.source && !gf_sk_is_multicast_address(ch->net_info.source)) { - ch->net_info.IsUnicast = 1; - } - } - } + /* forcing unicast when the address is not a multicast */ + if (!ch->net_info.IsUnicast) { + if (IsSource) { + if (ch->net_info.destination && !gf_sk_is_multicast_address(ch->net_info.destination)) { + ch->net_info.IsUnicast = 1; + } + } else { + if (ch->net_info.source && !gf_sk_is_multicast_address(ch->net_info.source)) { + ch->net_info.IsUnicast = 1; + } + } + } // // RTP // @@ -224,7 +224,7 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 if (e) return e; } } else { - //Bind to multicast (auto-join the group). + //Bind to multicast (auto-join the group). //we do not bind the socket if this is a source-only channel because some servers //don't like that on local loop ... e = gf_sk_setup_multicast(ch->rtp, ch->net_info.source, ch->net_info.port_first, ch->net_info.TTL, 0, local_ip); @@ -237,7 +237,7 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 ch->send_buffer = (char *) gf_malloc(sizeof(char) * PathMTU); ch->send_buffer_size = PathMTU; } - + //create re-ordering queue for UDP only, and receive if (ReorederingSize && !IsSource) { @@ -270,7 +270,7 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 if (e) return e; } } - + //format CNAME if not done yet if (!ch->CName) { //this is the real CName setup @@ -288,14 +288,14 @@ GF_Err gf_rtp_initialize(GF_RTPChannel *ch, u32 UDPBufferSize, Bool IsSource, u3 ch->CName = gf_strdup(name); } } - + #ifndef GPAC_DISABLE_LOG if (gf_log_tool_level_on(GF_LOG_RTP, GF_LOG_DEBUG)) { GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] Packet Log Format: SSRC SequenceNumber TimeStamp NTP@recvTime deviance, Jiter, PckLost PckTotal BytesTotal\n")); } #endif - + return GF_OK; } @@ -343,10 +343,10 @@ u32 gf_rtp_read_rtp(GF_RTPChannel *ch, char *buffer, u32 buffer_size) e = gf_sk_receive(ch->rtp, buffer, buffer_size, 0, &res); if (!res || e || (res < 12)) res = 0; - if (res){ - ch->total_bytes+=res; - ch->total_pck++; - } + if (res) { + ch->total_bytes+=res; + ch->total_pck++; + } //add the packet to our Queue if any if (ch->po) { if (res) { @@ -365,7 +365,7 @@ u32 gf_rtp_read_rtp(GF_RTPChannel *ch, char *buffer, u32 buffer_size) if (ch->nat_keepalive_time_period) { u32 now = gf_sys_clock(); if (res) { - ch->last_nat_keepalive_time = now; + ch->last_nat_keepalive_time = now; } else { if (now - ch->last_nat_keepalive_time >= ch->nat_keepalive_time_period) { #if 0 @@ -454,11 +454,11 @@ GF_Err gf_rtp_decode_rtp(GF_RTPChannel *ch, char *pck, u32 pck_size, GF_RTPHeade ch->last_pck_sn = (u32) rtp_hdr->SequenceNumber-1; } /*this is a loop in SN - add it*/ - if ( (ch->last_pck_sn + 1 > rtp_hdr->SequenceNumber) - && (rtp_hdr->SequenceNumber >= ch->last_pck_sn + MAX_RTP_SN/2)) { + if ( (ch->last_pck_sn + 1 > rtp_hdr->SequenceNumber) + && (rtp_hdr->SequenceNumber >= ch->last_pck_sn + MAX_RTP_SN/2)) { ch->num_sn_loops += 1; } - + ntp = gf_rtp_channel_time(ch); deviance = ntp - rtp_hdr->TimeStamp; delta = deviance - ch->last_deviance; @@ -472,7 +472,7 @@ GF_Err gf_rtp_decode_rtp(GF_RTPChannel *ch, char *pck, u32 pck_size, GF_RTPHeade CurrSeq = (u32) rtp_hdr->SequenceNumber; ch->packet_loss = 0; /*next sequential pck*/ - if ( ( (LastSeq + 1) & 0xffff ) == CurrSeq ) { + if ( ( (LastSeq + 1) & 0xffff ) == CurrSeq ) { ch->last_num_pck_rcv += 1; ch->last_num_pck_expected += 1; } @@ -500,17 +500,17 @@ GF_Err gf_rtp_decode_rtp(GF_RTPChannel *ch, char *pck, u32 pck_size, GF_RTPHeade ch->total_pck++; ch->total_bytes += pck_size-12; - GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP]\t%d\t%d\t%u\t%d\t%d\t%d\t%d\t%d\t%d\n", - ch->SenderSSRC, - rtp_hdr->SequenceNumber, - rtp_hdr->TimeStamp, - ntp, - delta, - ch->Jitter >> 4, - lost, - ch->total_pck, - ch->total_bytes - )); + GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP]\t%d\t%d\t%u\t%d\t%d\t%d\t%d\t%d\t%d\n", + ch->SenderSSRC, + rtp_hdr->SequenceNumber, + rtp_hdr->TimeStamp, + ntp, + delta, + ch->Jitter >> 4, + lost, + ch->total_pck, + ch->total_bytes + )); } #endif @@ -548,15 +548,15 @@ GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *pck, u GF_BitStream *bs; - if (!ch || !rtp_hdr - || !ch->send_buffer - || !pck - || (rtp_hdr->CSRCCount && !rtp_hdr->CSRC) - || (rtp_hdr->CSRCCount > 15)) return GF_BAD_PARAM; - + if (!ch || !rtp_hdr + || !ch->send_buffer + || !pck + || (rtp_hdr->CSRCCount && !rtp_hdr->CSRC) + || (rtp_hdr->CSRCCount > 15)) return GF_BAD_PARAM; + if (rtp_hdr->CSRCCount) fast_send=0; - if (12 + pck_size + 4*rtp_hdr->CSRCCount > ch->send_buffer_size) return GF_IO_ERR; + if (12 + pck_size + 4*rtp_hdr->CSRCCount > ch->send_buffer_size) return GF_IO_ERR; if (fast_send) { hdr = pck - 12; @@ -586,7 +586,7 @@ GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *pck, u if (fast_send) { e = gf_sk_send(ch->rtp, hdr, pck_size+12); } else { - memcpy(ch->send_buffer + Start, pck, pck_size); + memcpy(ch->send_buffer + Start, pck, pck_size); e = gf_sk_send(ch->rtp, ch->send_buffer, Start + pck_size); } if (e) return e; @@ -719,12 +719,12 @@ u32 gf_rtp_get_local_ssrc(GF_RTPChannel *ch) #if 0 - "#RTP log format:\n" - "#RTP SenderSSRC RTP_TimeStamp RTP_SeqNum NTP@Recv Deviance Jitter NbLost NbTotPck NbTotBytes\n" - "#RTCP Sender reports log format:\n" - "#RTCP-SR SenderSSRC RTP_TimeStamp@NTP NbTotPck NbTotBytes NTP\n" - "#RTCP Receiver reports log format:\n" - "#RTCP-RR StreamSSRC Jitter ExtendedSeqNum ExpectDiff LossDiff NTP\n" +"#RTP log format:\n" +"#RTP SenderSSRC RTP_TimeStamp RTP_SeqNum NTP@Recv Deviance Jitter NbLost NbTotPck NbTotBytes\n" +"#RTCP Sender reports log format:\n" +"#RTCP-SR SenderSSRC RTP_TimeStamp@NTP NbTotPck NbTotBytes NTP\n" +"#RTCP Receiver reports log format:\n" +"#RTCP-RR StreamSSRC Jitter ExtendedSeqNum ExpectDiff LossDiff NTP\n" #endif GF_EXPORT @@ -763,7 +763,7 @@ GF_EXPORT GF_RTPReorder *gf_rtp_reorderer_new(u32 MaxCount, u32 MaxDelay) { GF_RTPReorder *tmp; - + if (MaxCount <= 1 || !MaxDelay) return NULL; GF_SAFEALLOC(tmp , GF_RTPReorder); @@ -869,7 +869,7 @@ GF_Err gf_rtp_reorderer_add(GF_RTPReorder *po, const void * pck, u32 pck_size, u //are we in the bounds ?? if ( ( (u16) (cur->pck_seq_num + bounds) < (u16) (pck_seqnum + bounds) ) - && ( (u16) (pck_seqnum + bounds) < (u16) (cur->next->pck_seq_num + bounds)) ) { + && ( (u16) (pck_seqnum + bounds) < (u16) (cur->next->pck_seq_num + bounds)) ) { //insert it->next = cur->next; @@ -882,7 +882,7 @@ GF_Err gf_rtp_reorderer_add(GF_RTPReorder *po, const void * pck, u32 pck_size, u } cur = cur->next; } - + discard: gf_free(it->pck); @@ -910,8 +910,8 @@ void *gf_rtp_reorderer_get(GF_RTPReorder *po, u32 *pck_size) //check we have received the first packet if ( po->head_seqnum && po->MaxCount - && (po->MaxCount > po->Count) - && (po->in->pck_seq_num != po->head_seqnum)) + && (po->MaxCount > po->Count) + && (po->in->pck_seq_num != po->head_seqnum)) return NULL; //no entry @@ -921,11 +921,11 @@ void *gf_rtp_reorderer_get(GF_RTPReorder *po, u32 *pck_size) if ( (po->head_seqnum >= 0xf000 ) || (po->head_seqnum <= 0x1000) ) bounds = 0x2000; //release the output if SN in order or maxCount reached - if (( (u16) (po->in->pck_seq_num + bounds + 1) == (u16) (po->in->next->pck_seq_num + bounds)) - || (po->MaxCount && (po->Count >= po->MaxCount)) ) { + if (( (u16) (po->in->pck_seq_num + bounds + 1) == (u16) (po->in->next->pck_seq_num + bounds)) + || (po->MaxCount && (po->Count >= po->MaxCount)) ) { #ifndef GPAC_DISABLE_LOG - if (po->in->pck_seq_num + 1 != po->in->next->pck_seq_num) + if (po->in->pck_seq_num + 1 != po->in->next->pck_seq_num) GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[rtp] WARNING Packet Loss: Sending %d out of the queue but next is %d\n", po->in->pck_seq_num, po->in->next->pck_seq_num )); #endif goto send_it; diff --git a/src/ietf/rtp_depacketizer.c b/src/ietf/rtp_depacketizer.c index 9fd8569..802d8db 100644 --- a/src/ietf/rtp_depacketizer.c +++ b/src/ietf/rtp_depacketizer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,16 +11,16 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * */ #include @@ -87,7 +87,7 @@ static void gf_rtp_parse_mpeg4(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char au_size = rtp->sl_map.ConstantSize; /*not signaled, assume max one AU per packet*/ if (!au_size) au_size = size - pay_start; - + if ((!num_au && rtp->sl_map.auh_first_min_len) || (num_au && rtp->sl_map.auh_min_len)) { /*ISMACryp*/ if (rtp->flags & GF_RTP_HAS_ISMACRYP) { @@ -98,7 +98,7 @@ static void gf_rtp_parse_mpeg4(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char gf_bs_read_int(hdr_bs, 7); au_hdr_size -= 8; } - /*Note: ISMACryp ALWAYS indicates IV (BSO) and KEYIDX, even when sample is not encrypted. + /*Note: ISMACryp ALWAYS indicates IV (BSO) and KEYIDX, even when sample is not encrypted. This is quite a waste when using selective encryption....*/ if (!num_au) { nbbits = 8*rtp->sl_map.IV_length; @@ -197,7 +197,7 @@ static void gf_rtp_parse_mpeg4(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char rtp->sl_hdr.packetSequenceNumber += 1; /*force indication of CTS whenever we have a new AU*/ - + rtp->sl_hdr.compositionTimeStampFlag = (rtp->flags & GF_RTP_NEW_AU) ? 1 : 0; /*locate VOP start code*/ @@ -219,7 +219,7 @@ static void gf_rtp_parse_mpeg4(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char rtp->on_sl_packet(rtp->udta, payload + pay_start, (u32) au_size, &rtp->sl_hdr, GF_OK); rtp->sl_hdr.compositionTimeStampFlag = 0; - + if (rtp->flags & GF_RTP_HAS_ISMACRYP) rtp->sl_hdr.isma_BSO += au_size; if (au_hdr_size < rtp->sl_map.auh_min_len) break; @@ -285,7 +285,7 @@ static void gf_rtp_parse_mpeg12_audio(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr payload += rtp->sl_hdr.accessUnitLength; size -= rtp->sl_hdr.accessUnitLength; rtp->sl_hdr.accessUnitLength = 0; - + /*if fragmented there shall not be other frames in the packet*/ if (!rtp->sl_hdr.accessUnitStartFlag) return; if (!size) break; @@ -494,7 +494,7 @@ static void gf_rtp_parse_ttxt(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char * if (type==1) { /*flush any existing packet*/ gf_rtp_ttxt_flush(rtp, (u32) rtp->sl_hdr.compositionTimeStamp); - + /*bad ttu(1)*/ if (ttu_len<8) break; rtp->sl_hdr.compositionTimeStamp = ts; @@ -523,9 +523,9 @@ static void gf_rtp_parse_ttxt(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char * sidx = gf_bs_read_u8(bs); gf_bs_read_u16(bs);/*complete text sample size, ignored*/ txt_size = size - 10; - - /*init - 3GPP/MPEG-4 spliting is IMHO stupid: - - nb frag & cur frags are not needed: rtp reordering insures packet are in order, and + + /*init - 3GPP/MPEG-4 spliting is IMHO stupid: + - nb frag & cur frags are not needed: rtp reordering insures packet are in order, and !!!we assume fragments are sent in order!!! - any other TTU suffices to indicate end of text string (modifiers or != RTP TS) - replacing these 8bits field with a 16 bit absolute character offset would add error recovery @@ -596,9 +596,13 @@ static void gf_rtp_h264_flush(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, Bool m nal_s = data_size-4; if (rtp->flags & GF_RTP_AVC_USE_ANNEX_B) { - data[0] = data[1] = data[2] = 0; data[3] = 1; + data[0] = data[1] = data[2] = 0; + data[3] = 1; } else { - data[0] = nal_s>>24; data[1] = nal_s>>16; data[2] = nal_s>>8; data[3] = nal_s&0xFF; + data[0] = nal_s>>24; + data[1] = nal_s>>16; + data[2] = nal_s>>8; + data[3] = nal_s&0xFF; } /*set F-bit since nal is corrupted*/ if (missed_end) data[4] |= 0x80; @@ -650,10 +654,16 @@ void gf_rtp_parse_h264(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char *payload rtp->sl_hdr.accessUnitEndFlag = 0; if (rtp->flags & GF_RTP_AVC_USE_ANNEX_B) { - nalhdr[0] = 0; nalhdr[1] = 0; nalhdr[2] = 0; nalhdr[3] = 1; + nalhdr[0] = 0; + nalhdr[1] = 0; + nalhdr[2] = 0; + nalhdr[3] = 1; } else { /*signal NALU size on 4 bytes*/ - nalhdr[0] = size>>24; nalhdr[1] = size>>16; nalhdr[2] = size>>8; nalhdr[3] = size&0xFF; + nalhdr[0] = size>>24; + nalhdr[1] = size>>16; + nalhdr[2] = size>>8; + nalhdr[3] = size&0xFF; } rtp->on_sl_packet(rtp->udta, nalhdr, 4, &rtp->sl_hdr, GF_OK); @@ -670,7 +680,9 @@ void gf_rtp_parse_h264(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char *payload u32 offset = 1; while (offsetsl_hdr.randomAccessPointFlag = 1; @@ -681,9 +693,15 @@ void gf_rtp_parse_h264(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char *payload if (send) { /*signal NALU size on 4 bytes*/ if (rtp->flags & GF_RTP_AVC_USE_ANNEX_B) { - nalhdr[0] = 0; nalhdr[1] = 0; nalhdr[2] = 0; nalhdr[3] = 1; + nalhdr[0] = 0; + nalhdr[1] = 0; + nalhdr[2] = 0; + nalhdr[3] = 1; } else { - nalhdr[0] = nal_size>>24; nalhdr[1] = nal_size>>16; nalhdr[2] = nal_size>>8; nalhdr[3] = nal_size&0xFF; + nalhdr[0] = nal_size>>24; + nalhdr[1] = nal_size>>16; + nalhdr[2] = nal_size>>8; + nalhdr[3] = nal_size&0xFF; } rtp->on_sl_packet(rtp->udta, nalhdr, 4, &rtp->sl_hdr, GF_OK); rtp->sl_hdr.accessUnitStartFlag = 0; @@ -741,7 +759,10 @@ static void gf_rtp_hevc_flush(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, Bool m rtp->inter_bs = NULL; nal_s = data_size-4; - data[0] = nal_s>>24; data[1] = nal_s>>16; data[2] = nal_s>>8; data[3] = nal_s&0xFF; + data[0] = nal_s>>24; + data[1] = nal_s>>16; + data[2] = nal_s>>8; + data[3] = nal_s&0xFF; /*set F-bit since nal is corrupted*/ if (missed_end) data[4] |= 0x80; @@ -778,17 +799,22 @@ static void gf_rtp_parse_hevc(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char * rtp->flags |= GF_RTP_UNRELIABLE_M; GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[HEVC RTP] error in Marker bit - switching to unreliable mode\n")); } - + /*Single NALU*/ if (nal_type <= 40) { + /*FIXME: strict condition for randomAccessPointFlag because of decoder's issue*/ if ((nal_type==GF_HEVC_NALU_SLICE_IDR_W_DLP) || (nal_type==GF_HEVC_NALU_SLICE_IDR_N_LP)) { + //if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { rtp->sl_hdr.randomAccessPointFlag = 1; } rtp->sl_hdr.accessUnitEndFlag = 0; /*signal NALU size on 4 bytes*/ - nalu_size[0] = size>>24; nalu_size[1] = size>>16; nalu_size[2] = size>>8; nalu_size[3] = size&0xFF; + nalu_size[0] = size>>24; + nalu_size[1] = size>>16; + nalu_size[2] = size>>8; + nalu_size[3] = size&0xFF; rtp->on_sl_packet(rtp->udta, nalu_size, 4, &rtp->sl_hdr, GF_OK); rtp->sl_hdr.accessUnitStartFlag = 0; @@ -803,15 +829,22 @@ static void gf_rtp_parse_hevc(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char * else if (nal_type == 48) { u32 offset = 2; while (offset> 1; - if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { + /*FIXME: strict condition for randomAccessPointFlag because of decoder's issue*/ + if ((nal_type==GF_HEVC_NALU_SLICE_IDR_W_DLP) || (nal_type==GF_HEVC_NALU_SLICE_IDR_N_LP)) { + //if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { rtp->sl_hdr.randomAccessPointFlag = 1; } /*signal NALU size on 4 bytes*/ - nalu_size[0] = nal_size>>24; nalu_size[1] = nal_size>>16; nalu_size[2] = nal_size>>8; nalu_size[3] = nal_size&0xFF; + nalu_size[0] = nal_size>>24; + nalu_size[1] = nal_size>>16; + nalu_size[2] = nal_size>>8; + nalu_size[3] = nal_size&0xFF; rtp->on_sl_packet(rtp->udta, nalu_size, 4, &rtp->sl_hdr, GF_OK); rtp->sl_hdr.accessUnitStartFlag = 0; @@ -829,7 +862,9 @@ static void gf_rtp_parse_hevc(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, char * if (is_start) gf_rtp_hevc_flush(rtp, hdr, 1); nal_type = payload[2] & 0x3F; - if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { + /*FIXME: strict condition for randomAccessPointFlag because of decoder's issue*/ + if ((nal_type==GF_HEVC_NALU_SLICE_IDR_W_DLP) || (nal_type==GF_HEVC_NALU_SLICE_IDR_N_LP)) { + //if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { rtp->sl_hdr.randomAccessPointFlag = 1; } @@ -917,7 +952,7 @@ static void gf_rtp_parse_3gpp_dims(GF_RTPDepacketizer *rtp, GF_RTPHeader *hdr, c rtp->sl_hdr.accessUnitStartFlag = 0; offset += du_size; } - break; + break; case 1: if (rtp->inter_bs) gf_bs_del(rtp->inter_bs); @@ -1073,7 +1108,7 @@ static GF_Err payt_set_param(GF_RTPDepacketizer *rtp, char *param_name, char *pa //decode the buffer - the string buffer is MSB hexadecimal bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); valS[2] = 0; - for (i=0; isl_map.ConstantSize = atoi(param_val); @@ -1098,7 +1133,7 @@ static GF_Err payt_set_param(GF_RTPDepacketizer *rtp, char *param_name, char *pa else if (!stricmp(param_name, "ObjectType")) { rtp->sl_map.ObjectTypeIndication = atoi(param_val); } - else if (!stricmp(param_name, "StreamType")) + else if (!stricmp(param_name, "StreamType")) rtp->sl_map.StreamType = atoi(param_val); else if (!stricmp(param_name, "mode")) { strcpy(rtp->sl_map.mode, param_val); @@ -1124,17 +1159,17 @@ static GF_Err payt_set_param(GF_RTPDepacketizer *rtp, char *param_name, char *pa else if (!stricmp(param_name, "AuxiliaryDataSizeLength")) rtp->sl_map.AuxiliaryDataSizeLength = atoi(param_val); /*H264/AVC config - we only handle mode 0 and 1*/ - else if (!stricmp(param_name, "packetization-mode")) + else if (!stricmp(param_name, "packetization-mode")) rtp->h264_pck_mode = 1; /*AMR config*/ else if (!stricmp(param_name, "octet-align")) { - if (!stricmp(param_val, "1")) + if (!stricmp(param_val, "1")) rtp->flags |= GF_RTP_AMR_ALIGN; } /*ISMACryp config*/ else if (!stricmp(param_name, "ISMACrypCryptoSuite")) { - if (!stricmp(param_val, "AES_CTR_128")) + if (!stricmp(param_val, "AES_CTR_128")) rtp->isma_scheme = GF_4CC('i','A','E','C'); - else + else rtp->isma_scheme = 0; } else if (!stricmp(param_name, "ISMACrypSelectiveEncryption")) { @@ -1143,16 +1178,16 @@ static GF_Err payt_set_param(GF_RTPDepacketizer *rtp, char *param_name, char *pa else rtp->flags &= ~GF_RTP_ISMA_SEL_ENC; } - else if (!stricmp(param_name, "ISMACrypIVLength")) + else if (!stricmp(param_name, "ISMACrypIVLength")) rtp->sl_map.IV_length = atoi(param_val); - else if (!stricmp(param_name, "ISMACrypDeltaIVLength")) + else if (!stricmp(param_name, "ISMACrypDeltaIVLength")) rtp->sl_map.IV_delta_length = atoi(param_val); - else if (!stricmp(param_name, "ISMACrypKeyIndicatorLength")) + else if (!stricmp(param_name, "ISMACrypKeyIndicatorLength")) rtp->sl_map.KI_length = atoi(param_val); else if (!stricmp(param_name, "ISMACrypKeyIndicatorPerAU")) { if (!stricmp(param_val, "1") || !stricmp(param_val, "true")) rtp->flags |= GF_RTP_ISMA_HAS_KEY_IDX; - else + else rtp->flags &= ~GF_RTP_ISMA_HAS_KEY_IDX; } else if (!stricmp(param_name, "ISMACrypKey")) { rtp->key = gf_strdup(param_val); @@ -1167,7 +1202,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM /*reset sl map*/ memset(&rtp->sl_map, 0, sizeof(GP_RTPSLMap)); - + if (!stricmp(map->payload_name, "enc-mpeg4-generic")) rtp->flags |= GF_RTP_HAS_ISMACRYP; @@ -1240,7 +1275,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM /*assign depacketizer*/ rtp->depacketize = gf_rtp_parse_latm; } - break; + break; #endif case GF_RTP_PAYT_MPEG4: /*mark if AU header is present*/ @@ -1317,59 +1352,59 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM break; case GF_RTP_PAYT_AMR: case GF_RTP_PAYT_AMR_WB: - { - GF_BitStream *bs; - rtp->sl_map.StreamType = GF_STREAM_AUDIO; - rtp->sl_map.ObjectTypeIndication = GPAC_OTI_MEDIA_GENERIC; - /*create DSI*/ - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - if (rtp->payt == GF_RTP_PAYT_AMR) { - gf_bs_write_u32(bs, GF_4CC('s', 'a', 'm', 'r')); - gf_bs_write_u32(bs, 8000); - gf_bs_write_u16(bs, 1); - gf_bs_write_u16(bs, 160); - } else { - gf_bs_write_u32(bs, GF_4CC('s', 'a', 'w', 'b')); - gf_bs_write_u32(bs, 16000); - gf_bs_write_u16(bs, 1); - gf_bs_write_u16(bs, 320); - } - gf_bs_write_u8(bs, 16); - gf_bs_write_u8(bs, 1); - gf_bs_get_content(bs, &rtp->sl_map.config, &rtp->sl_map.configSize); - gf_bs_del(bs); - /*assign depacketizer*/ - rtp->depacketize = gf_rtp_parse_amr; + { + GF_BitStream *bs; + rtp->sl_map.StreamType = GF_STREAM_AUDIO; + rtp->sl_map.ObjectTypeIndication = GPAC_OTI_MEDIA_GENERIC; + /*create DSI*/ + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + if (rtp->payt == GF_RTP_PAYT_AMR) { + gf_bs_write_u32(bs, GF_4CC('s', 'a', 'm', 'r')); + gf_bs_write_u32(bs, 8000); + gf_bs_write_u16(bs, 1); + gf_bs_write_u16(bs, 160); + } else { + gf_bs_write_u32(bs, GF_4CC('s', 'a', 'w', 'b')); + gf_bs_write_u32(bs, 16000); + gf_bs_write_u16(bs, 1); + gf_bs_write_u16(bs, 320); } - break; + gf_bs_write_u8(bs, 16); + gf_bs_write_u8(bs, 1); + gf_bs_get_content(bs, &rtp->sl_map.config, &rtp->sl_map.configSize); + gf_bs_del(bs); + /*assign depacketizer*/ + rtp->depacketize = gf_rtp_parse_amr; + } + break; case GF_RTP_PAYT_H263: - { - u32 x, y, w, h; - GF_X_Attribute *att; - GF_BitStream *bs; - x = y = w = h = 0; - j=0; - while ((att = (GF_X_Attribute *)gf_list_enum(media->Attributes, &j))) { - if (stricmp(att->Name, "cliprect")) continue; - /*only get the display area*/ - sscanf(att->Value, "%u,%u,%u,%u", &y, &x, &h, &w); - } - - rtp->sl_map.StreamType = GF_STREAM_VISUAL; - rtp->sl_map.ObjectTypeIndication = GPAC_OTI_MEDIA_GENERIC; - /*create DSI*/ - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - gf_bs_write_u32(bs, GF_4CC('h', '2', '6', '3')); - gf_bs_write_u16(bs, w); - gf_bs_write_u16(bs, h); - gf_bs_get_content(bs, &rtp->sl_map.config, &rtp->sl_map.configSize); - gf_bs_del(bs); - /*we signal RAPs*/ - rtp->sl_map.RandomAccessIndication = 1; - /*assign depacketizer*/ - rtp->depacketize = gf_rtp_parse_h263; + { + u32 x, y, w, h; + GF_X_Attribute *att; + GF_BitStream *bs; + x = y = w = h = 0; + j=0; + while ((att = (GF_X_Attribute *)gf_list_enum(media->Attributes, &j))) { + if (stricmp(att->Name, "cliprect")) continue; + /*only get the display area*/ + sscanf(att->Value, "%u,%u,%u,%u", &y, &x, &h, &w); } - break; + + rtp->sl_map.StreamType = GF_STREAM_VISUAL; + rtp->sl_map.ObjectTypeIndication = GPAC_OTI_MEDIA_GENERIC; + /*create DSI*/ + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + gf_bs_write_u32(bs, GF_4CC('h', '2', '6', '3')); + gf_bs_write_u16(bs, w); + gf_bs_write_u16(bs, h); + gf_bs_get_content(bs, &rtp->sl_map.config, &rtp->sl_map.configSize); + gf_bs_del(bs); + /*we signal RAPs*/ + rtp->sl_map.RandomAccessIndication = 1; + /*assign depacketizer*/ + rtp->depacketize = gf_rtp_parse_h263; + } + break; case GF_RTP_PAYT_3GPP_TEXT: { char *tx3g, *a_tx3g; @@ -1453,7 +1488,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM /*assign depacketizer*/ rtp->depacketize = gf_rtp_parse_ttxt; } - break; + break; #ifndef GPAC_DISABLE_AV_PARSERS case GF_RTP_PAYT_H264_AVC: case GF_RTP_PAYT_H264_SVC: @@ -1489,7 +1524,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM b64size = (u32) strlen(nal_ptr); b64_d = (char*)gf_malloc(sizeof(char)*b64size); - ret = gf_base64_decode(nal_ptr, b64size, b64_d, b64size); + ret = gf_base64_decode(nal_ptr, b64size, b64_d, b64size); b64_d[ret] = 0; nalt = b64_d[0] & 0x1F; @@ -1503,7 +1538,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM } else { gf_list_add(avcc->pictureParameterSets, sl); } - } + } gf_free(b64_d); if (sep) { @@ -1519,8 +1554,8 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM gf_odf_avc_cfg_del(avcc); } /*assign depacketizer*/ - rtp->depacketize = gf_rtp_parse_h264; - break; + rtp->depacketize = gf_rtp_parse_h264; + break; case GF_RTP_PAYT_HEVC: case GF_RTP_PAYT_SHVC: #ifndef GPAC_DISABLE_HEVC @@ -1569,7 +1604,7 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM b64size = (u32) strlen(nal_ptr); b64_d = (char*)gf_malloc(sizeof(char)*b64size); - ret = gf_base64_decode(nal_ptr, b64size, b64_d, b64size); + ret = gf_base64_decode(nal_ptr, b64size, b64_d, b64size); b64_d[ret] = 0; sl = (GF_AVCConfigSlot *)gf_malloc(sizeof(GF_AVCConfigSlot)); @@ -1594,11 +1629,11 @@ static GF_Err gf_rtp_payt_setup(GF_RTPDepacketizer *rtp, GF_RTPMap *map, GF_SDPM gf_odf_hevc_cfg_write(hevcc, &rtp->sl_map.config, &rtp->sl_map.configSize); gf_odf_hevc_cfg_del(hevcc); } - rtp->depacketize = gf_rtp_parse_hevc; + rtp->depacketize = gf_rtp_parse_hevc; #else - return GF_NOT_SUPPORTED; + return GF_NOT_SUPPORTED; #endif - break; + break; #endif /*GPAC_DISABLE_AV_PARSERS*/ /*todo - rewrite DIMS config*/ diff --git a/src/ietf/rtp_packetizer.c b/src/ietf/rtp_packetizer.c index 22e175e..bf57b3a 100644 --- a/src/ietf/rtp_packetizer.c +++ b/src/ietf/rtp_packetizer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,12 +37,12 @@ void InitSL_RTP(GF_SLConfig *slc); GF_EXPORT GP_RTPPacketizer *gf_rtp_builder_new(u32 rtp_payt, GF_SLConfig *slc, u32 flags, - void *cbk_obj, - void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), - void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), - void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), - void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head) - ) + void *cbk_obj, + void (*OnNewPacket)(void *cbk, GF_RTPHeader *header), + void (*OnPacketDone)(void *cbk, GF_RTPHeader *header), + void (*OnDataReference)(void *cbk, u32 payload_size, u32 offset_from_orig), + void (*OnData)(void *cbk, char *data, u32 data_size, Bool is_head) + ) { GP_RTPPacketizer *tmp; if (!rtp_payt || !cbk_obj | !OnPacketDone) return NULL; @@ -69,7 +69,7 @@ GP_RTPPacketizer *gf_rtp_builder_new(u32 rtp_payt, GF_SLConfig *slc, u32 flags, tmp->sl_header.packetSequenceNumber = 1; //we assume we start on a new AU - tmp->sl_header.accessUnitStartFlag = 1; + tmp->sl_header.accessUnitStartFlag = 1; return tmp; } @@ -111,16 +111,16 @@ GF_Err gf_rtp_builder_process(GP_RTPPacketizer *builder, char *data, u32 data_si return gp_rtp_builder_do_qcelp(builder, data, data_size, IsAUEnd, FullAUSize); case GF_RTP_PAYT_EVRC_SMV: return gp_rtp_builder_do_smv(builder, data, data_size, IsAUEnd, FullAUSize); - case GF_RTP_PAYT_LATM: - return gp_rtp_builder_do_latm(builder, data, data_size, IsAUEnd, FullAUSize, duration); - case GF_RTP_PAYT_3GPP_DIMS: - return gp_rtp_builder_do_dims(builder, data, data_size, IsAUEnd, FullAUSize, duration); - case GF_RTP_PAYT_AC3: - return gp_rtp_builder_do_ac3(builder, data, data_size, IsAUEnd, FullAUSize); + case GF_RTP_PAYT_LATM: + return gp_rtp_builder_do_latm(builder, data, data_size, IsAUEnd, FullAUSize, duration); + case GF_RTP_PAYT_3GPP_DIMS: + return gp_rtp_builder_do_dims(builder, data, data_size, IsAUEnd, FullAUSize, duration); + case GF_RTP_PAYT_AC3: + return gp_rtp_builder_do_ac3(builder, data, data_size, IsAUEnd, FullAUSize); case GF_RTP_PAYT_HEVC: case GF_RTP_PAYT_SHVC: - return gp_rtp_builder_do_hevc(builder, data, data_size, IsAUEnd, FullAUSize); - default: + return gp_rtp_builder_do_hevc(builder, data, data_size, IsAUEnd, FullAUSize); + default: return GF_NOT_SUPPORTED; } } @@ -128,12 +128,12 @@ GF_Err gf_rtp_builder_process(GP_RTPPacketizer *builder, char *data, u32 data_si //Compute the #params of the slMap GF_EXPORT -void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, u32 max_ptime, - u32 StreamType, u32 OTI, u32 PL_ID, - u32 avgSize, u32 maxSize, - u32 avgTS, u32 maxDTS, - u32 IV_length, u32 KI_length, - char *pref_mode) +void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, u32 max_ptime, + u32 StreamType, u32 OTI, u32 PL_ID, + u32 avgSize, u32 maxSize, + u32 avgTS, u32 maxDTS, + u32 IV_length, u32 KI_length, + char *pref_mode) { u32 k, ismacrypt_flags; @@ -198,8 +198,8 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, /*remove all MPEG-4 and ISMA flags */ builder->flags &= 0x07; } - return; - case GF_RTP_PAYT_LATM: + return; + case GF_RTP_PAYT_LATM: case GF_RTP_PAYT_MPEG4: break; default: @@ -207,7 +207,7 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, builder->flags &= 0x07; /*disable aggregation for visual streams, except for AVC where STAP/MTAP can be used*/ if (StreamType==GF_STREAM_VISUAL) { - if ((OTI != GPAC_OTI_VIDEO_AVC) && (OTI != GPAC_OTI_VIDEO_SVC) && (OTI != GPAC_OTI_VIDEO_HEVC)) { + if ((OTI != GPAC_OTI_VIDEO_AVC) && (OTI != GPAC_OTI_VIDEO_SVC) && (OTI != GPAC_OTI_VIDEO_HEVC) && (OTI != GPAC_OTI_VIDEO_SHVC)) { builder->flags &= ~GP_RTP_PCK_USE_MULTI; } } @@ -215,7 +215,7 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, builder->flags &= ~GP_RTP_PCK_USE_MULTI; } return; - } + } builder->slMap.IV_length = IV_length; builder->slMap.KI_length = KI_length; @@ -265,7 +265,7 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, } /*generic setup by flags*/ - + /*size*/ if (builder->flags & GP_RTP_PCK_SIGNAL_SIZE) { if (avgSize==maxSize) { @@ -298,7 +298,7 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, builder->slMap.CTSDeltaLength = 0; /*DTS Delta depends on the video type*/ - if ((builder->flags & GP_RTP_PCK_SIGNAL_TS) && maxDTS ) + if ((builder->flags & GP_RTP_PCK_SIGNAL_TS) && maxDTS ) builder->slMap.DTSDeltaLength = gf_get_bit_size(maxDTS); else builder->slMap.DTSDeltaLength = 0; @@ -346,8 +346,8 @@ void gf_rtp_builder_init(GP_RTPPacketizer *builder, u8 PayloadType, u32 PathMTU, /*compute CTS delta*/ builder->slMap.CTSDeltaLength = gf_get_bit_size(k*avgTS); - /*compute DTS delta. Delta is ALWAYS from the CTS of the same sample*/ - if (maxDTS) + /*compute DTS delta. Delta is ALWAYS from the CTS of the same sample*/ + if (maxDTS) builder->slMap.DTSDeltaLength = gf_get_bit_size(maxDTS); else builder->slMap.DTSDeltaLength = 0; @@ -378,33 +378,33 @@ check_header: } /*ISMACryp video mode*/ if ((builder->slMap.StreamType==GF_STREAM_VISUAL) && (builder->slMap.ObjectTypeIndication==GPAC_OTI_VIDEO_MPEG4_PART2) - && (builder->flags & GP_RTP_PCK_SIGNAL_RAP) && builder->slMap.IV_length - && !(builder->flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(builder->flags & GP_RTP_PCK_SIGNAL_SIZE) - /*shall have SignalTS*/ - && (builder->flags & GP_RTP_PCK_SIGNAL_TS) && !(builder->flags & GP_RTP_PCK_USE_MULTI) - ) { + && (builder->flags & GP_RTP_PCK_SIGNAL_RAP) && builder->slMap.IV_length + && !(builder->flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(builder->flags & GP_RTP_PCK_SIGNAL_SIZE) + /*shall have SignalTS*/ + && (builder->flags & GP_RTP_PCK_SIGNAL_TS) && !(builder->flags & GP_RTP_PCK_USE_MULTI) + ) { strcpy(builder->slMap.mode, "mpeg4-video"); } /*ISMACryp AVC video mode*/ else if ((builder->slMap.StreamType==GF_STREAM_VISUAL) && (builder->slMap.ObjectTypeIndication==GPAC_OTI_VIDEO_AVC) - && (builder->flags & GP_RTP_PCK_SIGNAL_RAP) && builder->slMap.IV_length - && !(builder->flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(builder->flags & GP_RTP_PCK_SIGNAL_SIZE) - /*shall have SignalTS*/ - && (builder->flags & GP_RTP_PCK_SIGNAL_TS) && !(builder->flags & GP_RTP_PCK_USE_MULTI) - ) { + && (builder->flags & GP_RTP_PCK_SIGNAL_RAP) && builder->slMap.IV_length + && !(builder->flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(builder->flags & GP_RTP_PCK_SIGNAL_SIZE) + /*shall have SignalTS*/ + && (builder->flags & GP_RTP_PCK_SIGNAL_TS) && !(builder->flags & GP_RTP_PCK_USE_MULTI) + ) { strcpy(builder->slMap.mode, "avc-video"); } /*check if we use AU header or not*/ - if (!builder->slMap.SizeLength - && !builder->slMap.IndexLength - && !builder->slMap.IndexDeltaLength - && !builder->slMap.DTSDeltaLength - && !builder->slMap.CTSDeltaLength - && !builder->slMap.RandomAccessIndication - && !builder->slMap.IV_length - && !builder->slMap.KI_length - ) { + if (!builder->slMap.SizeLength + && !builder->slMap.IndexLength + && !builder->slMap.IndexDeltaLength + && !builder->slMap.DTSDeltaLength + && !builder->slMap.CTSDeltaLength + && !builder->slMap.RandomAccessIndication + && !builder->slMap.IV_length + && !builder->slMap.KI_length + ) { builder->has_AU_header= 0; } else { builder->has_AU_header = 1; @@ -421,9 +421,9 @@ void gp_rtp_builder_set_cryp_info(GP_RTPPacketizer *builder, u64 IV, char *key_i builder->key_indicator = NULL; } } else if (!builder->key_indicator - || - memcmp(builder->key_indicator, key_indicator, sizeof(char)*builder->slMap.KI_length) - ) { + || + memcmp(builder->key_indicator, key_indicator, sizeof(char)*builder->slMap.KI_length) + ) { /*force flush if no provision for keyIndicator per AU*/ builder->force_flush = (builder->flags & GP_RTP_PCK_KEY_IDX_PER_AU) ? 0 : 1; @@ -451,22 +451,22 @@ Bool gf_rtp_builder_get_payload_name(GP_RTPPacketizer *rtpb, char *szPayloadName strcpy(szMediaName, "video"); /*ISMACryp video*/ if ( (flags & GP_RTP_PCK_SIGNAL_RAP) && rtpb->slMap.IV_length - && !(flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(flags & GP_RTP_PCK_SIGNAL_SIZE) - && (flags & GP_RTP_PCK_SIGNAL_TS) && !(flags & GP_RTP_PCK_USE_MULTI) - ) + && !(flags & GP_RTP_PCK_SIGNAL_AU_IDX) && !(flags & GP_RTP_PCK_SIGNAL_SIZE) + && (flags & GP_RTP_PCK_SIGNAL_TS) && !(flags & GP_RTP_PCK_USE_MULTI) + ) { strcpy(szPayloadName, "enc-mpeg4-generic"); return 1; } /*mpeg4-generic*/ - if ( (flags & GP_RTP_PCK_SIGNAL_RAP) || (flags & GP_RTP_PCK_SIGNAL_AU_IDX) || (flags & GP_RTP_PCK_SIGNAL_SIZE) - || (flags & GP_RTP_PCK_SIGNAL_TS) || (flags & GP_RTP_PCK_USE_MULTI) ) { + if ( (flags & GP_RTP_PCK_SIGNAL_RAP) || (flags & GP_RTP_PCK_SIGNAL_AU_IDX) || (flags & GP_RTP_PCK_SIGNAL_SIZE) + || (flags & GP_RTP_PCK_SIGNAL_TS) || (flags & GP_RTP_PCK_USE_MULTI) ) { strcpy(szPayloadName, "mpeg4-generic"); return 1; } else { strcpy(szPayloadName, "MP4V-ES"); return 1; - } + } } /*for all other types*/ if (rtpb->slMap.StreamType==GF_STREAM_AUDIO) strcpy(szMediaName, "audio"); @@ -512,17 +512,17 @@ Bool gf_rtp_builder_get_payload_name(GP_RTPPacketizer *rtpb, char *szPayloadName /*header-free version*/ if (rtpb->auh_size<=1) strcat(szPayloadName, "0"); return 1; - case GF_RTP_PAYT_LATM: - strcpy(szMediaName, "audio"); - strcpy(szPayloadName, "MP4A-LATM"); - return 1; - case GF_RTP_PAYT_3GPP_DIMS: - strcpy(szMediaName, "video"); - strcpy(szPayloadName, "richmedia+xml"); - return 1; - case GF_RTP_PAYT_AC3: - strcpy(szMediaName, "audio"); - strcpy(szPayloadName, "ac3"); + case GF_RTP_PAYT_LATM: + strcpy(szMediaName, "audio"); + strcpy(szPayloadName, "MP4A-LATM"); + return 1; + case GF_RTP_PAYT_3GPP_DIMS: + strcpy(szMediaName, "video"); + strcpy(szPayloadName, "richmedia+xml"); + return 1; + case GF_RTP_PAYT_AC3: + strcpy(szMediaName, "audio"); + strcpy(szPayloadName, "ac3"); return 1; case GF_RTP_PAYT_H264_SVC: strcpy(szMediaName, "video"); @@ -553,17 +553,17 @@ GF_Err gf_rtp_builder_format_sdp(GP_RTPPacketizer *builder, char *payload_name, Bool is_first = 1; if ((builder->rtp_payt!=GF_RTP_PAYT_MPEG4) && (builder->rtp_payt!=GF_RTP_PAYT_LATM) ) return GF_BAD_PARAM; - + #define SDP_ADD_INT(_name, _val) { if (!is_first) strcat(sdpLine, "; "); sprintf(buffer, "%s=%d", _name, _val); strcat(sdpLine, buffer); is_first = 0;} #define SDP_ADD_STR(_name, _val) { if (!is_first) strcat(sdpLine, "; "); sprintf(buffer, "%s=%s", _name, _val); strcat(sdpLine, buffer); is_first = 0;} sprintf(sdpLine, "a=fmtp:%d ", builder->PayloadType); - + /*mandatory fields*/ if (builder->slMap.PL_ID) SDP_ADD_INT("profile-level-id", builder->slMap.PL_ID); - if (builder->rtp_payt == GF_RTP_PAYT_LATM) SDP_ADD_INT("cpresent", 0); - + if (builder->rtp_payt == GF_RTP_PAYT_LATM) SDP_ADD_INT("cpresent", 0); + if (dsi && dsi_size) { k = 0; for (i=0; ibytesInPacket + size > builder->Path_MTU) + if (builder->bytesInPacket + size > builder->Path_MTU) rtp_evrc_smv_flush(builder); /*need new*/ @@ -290,7 +290,7 @@ GF_Err gp_rtp_builder_do_h263(GP_RTPPacketizer *builder, char *data, u32 data_si u32 offset, size, max_size; builder->rtp_header.TimeStamp = (u32) builder->sl_header.compositionTimeStamp; - + /*the H263 hinter doesn't perform inter-sample concatenation*/ if (!data) return GF_OK; @@ -302,10 +302,10 @@ GF_Err gp_rtp_builder_do_h263(GP_RTPPacketizer *builder, char *data, u32 data_si max_size = builder->Path_MTU - 2; while(data_size > 0) { - if(data_size > max_size){ + if(data_size > max_size) { size = max_size; builder->rtp_header.Marker = 0; - }else{ + } else { size = data_size; builder->rtp_header.Marker = 1; } @@ -315,7 +315,7 @@ GF_Err gp_rtp_builder_do_h263(GP_RTPPacketizer *builder, char *data, u32 data_si /*create new RTP Packet */ builder->rtp_header.SequenceNumber += 1; builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); - + bs = gf_bs_new(hdr, 2, GF_BITSTREAM_WRITE); gf_bs_write_int(bs, 0, 5); gf_bs_write_int(bs, Pbit, 1); @@ -325,7 +325,7 @@ GF_Err gp_rtp_builder_do_h263(GP_RTPPacketizer *builder, char *data, u32 data_si /*add header*/ builder->OnData(builder->cbk_obj, (char*) hdr, 2, 1); /*add payload*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, size, offset); else builder->OnData(builder->cbk_obj, data + offset, size, 0); @@ -344,7 +344,7 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si char *hdr; u32 samp_size, txt_size, pay_start, hdr_size, txt_done, cur_frag, nb_frag; Bool is_utf_16 = 0; - + if (!data) { /*flush packet*/ if (builder->bytesInPacket) { @@ -354,7 +354,9 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si return GF_OK; } /*cfg packet*/ - txt_size = data[0]; txt_size <<= 8; txt_size |= (unsigned char) data[1]; + txt_size = data[0]; + txt_size <<= 8; + txt_size |= (unsigned char) data[1]; /*remove BOM*/ pay_start = 2; if (txt_size>2) { @@ -395,7 +397,7 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si builder->OnData(builder->cbk_obj, (char *) hdr, hdr_size, 0); builder->bytesInPacket += hdr_size; gf_free(hdr); - + if (txt_size) { if (builder->OnDataReference) { builder->OnDataReference(builder->cbk_obj, samp_size, pay_start); @@ -463,7 +465,7 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si builder->OnData(builder->cbk_obj, (char *) hdr, hdr_size, 0); builder->bytesInPacket += hdr_size; gf_free(hdr); - + if (builder->OnDataReference) { builder->OnDataReference(builder->cbk_obj, size, pay_start + txt_done); } else { @@ -471,7 +473,7 @@ GF_Err gp_rtp_builder_do_tx3g(GP_RTPPacketizer *builder, char *data, u32 data_si } builder->bytesInPacket += size; cur_frag++; - + /*flush packet*/ if (cur_frag == nb_frag) { txt_done = txt_size; @@ -559,7 +561,7 @@ GF_Err gp_rtp_builder_do_dims(GP_RTPPacketizer *builder, char *data, u32 data_si u32 du_offset = 0; u32 hdr_offset = 0; u32 orig_size, du_size; - + orig_size = du_size = 2+gf_bs_read_u16(bs); /*if dims size is >0xFFFF, use our internal hack for large units*/ if (du_size==2) { @@ -599,7 +601,7 @@ GF_Err gp_rtp_builder_do_dims(GP_RTPPacketizer *builder, char *data, u32 data_si else frag_state = 2; builder->rtp_header.Marker = 0; - } + } /*last fragment*/ else if (frag_state) { size = du_size; @@ -618,7 +620,7 @@ GF_Err gp_rtp_builder_do_dims(GP_RTPPacketizer *builder, char *data, u32 data_si /*need a new packet*/ if (!builder->bytesInPacket) { char dims_rtp_hdr[1]; - + /*the unit is critical, increase counter (coded on 3 bits)*/ if (! (data[2+hdr_offset] & GF_DIMS_UNIT_P) && (frag_state <= 1) ) { builder->last_au_sn++; @@ -638,12 +640,12 @@ GF_Err gp_rtp_builder_do_dims(GP_RTPPacketizer *builder, char *data, u32 data_si } /*add payload*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, size, offset+du_offset+size_offset); else builder->OnData(builder->cbk_obj, data+offset+du_offset+size_offset, size, 0); - /*if fragmentation, force packet flush even on last packet since aggregation unit do not + /*if fragmentation, force packet flush even on last packet since aggregation unit do not use the same packet format*/ if (frag_state) { builder->OnPacketDone(builder->cbk_obj, &builder->rtp_header); @@ -692,21 +694,21 @@ GF_Err gp_rtp_builder_do_ac3(GP_RTPPacketizer *builder, char *data, u32 data_siz gf_rtp_ac3_flush(builder); return GF_OK; } - + if ( - /*AU does not fit*/ - (builder->bytesInPacket + data_size > builder->Path_MTU) - || - /*aggregation is not enabled*/ - !(builder->flags & GP_RTP_PCK_USE_MULTI) - || - /*max ptime is exceeded*/ - (builder->max_ptime && ( (u32) builder->sl_header.compositionTimeStamp >= builder->rtp_header.TimeStamp + builder->max_ptime) ) + /*AU does not fit*/ + (builder->bytesInPacket + data_size > builder->Path_MTU) + || + /*aggregation is not enabled*/ + !(builder->flags & GP_RTP_PCK_USE_MULTI) + || + /*max ptime is exceeded*/ + (builder->max_ptime && ( (u32) builder->sl_header.compositionTimeStamp >= builder->rtp_header.TimeStamp + builder->max_ptime) ) ) { gf_rtp_ac3_flush(builder); } - + /*fits*/ if (builder->bytesInPacket + data_size < builder->Path_MTU) { /*need a new packet*/ @@ -721,7 +723,7 @@ GF_Err gp_rtp_builder_do_ac3(GP_RTPPacketizer *builder, char *data, u32 data_siz } /*add payload*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, data_size, 0); else builder->OnData(builder->cbk_obj, data, data_size, 0); @@ -759,7 +761,7 @@ GF_Err gp_rtp_builder_do_ac3(GP_RTPPacketizer *builder, char *data, u32 data_siz builder->OnData(builder->cbk_obj, hdr, 2, 1); /*add payload*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, pck_size, offset); else builder->OnData(builder->cbk_obj, data+offset, pck_size, 0); diff --git a/src/ietf/rtp_pck_mpeg12.c b/src/ietf/rtp_pck_mpeg12.c index 8ed5dd0..ce2f589 100644 --- a/src/ietf/rtp_pck_mpeg12.c +++ b/src/ietf/rtp_pck_mpeg12.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -90,7 +90,7 @@ GF_Err gp_rtp_builder_do_mpeg12_audio(GP_RTPPacketizer *builder, char *data, u32 builder->bytesInPacket = 2; } /*add reference*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, pck_size, offset); else gf_bs_write_data(builder->payload, data + offset, pck_size); @@ -127,7 +127,7 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 offset = 0; have_seq = 0; - while (1) { + while (1) { u32 oldoffset; oldoffset = offset; if (gf_mv12_next_start_code((unsigned char *) data + offset, data_size - offset, &offset, &startcode) < 0) @@ -146,12 +146,12 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 pic_type = (payload[1] >> 3) & 0x7; /*first 6 bits (MBZ and T bit) not used*/ /*temp ref on 10 bits*/ - mpv_hdr[0] = (payload[0] >> 6) & 0x3; - mpv_hdr[1] = (payload[0] << 2) | ((payload[1] >> 6) & 0x3); - mpv_hdr[2] = pic_type; - mpv_hdr[3] = 0; + mpv_hdr[0] = (payload[0] >> 6) & 0x3; + mpv_hdr[1] = (payload[0] << 2) | ((payload[1] >> 6) & 0x3); + mpv_hdr[2] = pic_type; + mpv_hdr[3] = 0; - if ((pic_type==2) || (pic_type== 3)) { + if ((pic_type==2) || (pic_type== 3)) { mpv_hdr[3] = payload[3] << 5; if ((payload[4] & 0x80) != 0) mpv_hdr[3] |= 0x10; if (pic_type == 3) mpv_hdr[3] |= (payload[4] >> 3) & 0xf; @@ -164,9 +164,9 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); buffer = data; - prev_slice = 0; + prev_slice = 0; start_with_slice = (gf_mv12_next_slice_start((unsigned char *)buffer, offset, data_size, &next_slice) >= 0) ? 1 : 0; - offset = 0; + offset = 0; slices_done = 0; got_slice = start_with_slice; first_slice = 1; @@ -174,16 +174,16 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 while (data_size > 0) { Bool last_pck; u32 len_to_write; - + if (data_size <= max_pck_size) { len_to_write = data_size; - last_pck = 1; + last_pck = 1; prev_slice = 0; } else { got_slice = (!first_slice && !slices_done && (next_slice <= max_pck_size)) ? 1 : 0; first_slice = 0; last_pck = 0; - + while (!slices_done && (next_slice <= max_pck_size)) { prev_slice = next_slice; if (gf_mv12_next_slice_start((unsigned char *)buffer, next_slice + 4, data_size, &next_slice) >= 0) { @@ -194,33 +194,33 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 } if (got_slice) len_to_write = prev_slice; else len_to_write = MIN(max_pck_size, data_size); - } + } mpv_hdr[2] = pic_type; - + if (have_seq) { mpv_hdr[2] |= 0x20; have_seq = 0; } if (first_slice) mpv_hdr[2] |= 0x10; - + if (got_slice || last_pck) { mpv_hdr[2] |= 0x08; start_with_slice = 1; } else { start_with_slice = 0; } - + builder->OnData(builder->cbk_obj, mpv_hdr, 4, 0); if (builder->OnDataReference) { builder->OnDataReference(builder->cbk_obj, len_to_write, offset); } else { builder->OnData(builder->cbk_obj, data + offset, len_to_write, 0); } - + builder->rtp_header.Marker = last_pck ? 1 : 0; builder->OnPacketDone(builder->cbk_obj, &builder->rtp_header); - + offset += len_to_write; data_size -= len_to_write; prev_slice = 0; @@ -232,7 +232,7 @@ GF_Err gp_rtp_builder_do_mpeg12_video(GP_RTPPacketizer *builder, char *data, u32 builder->rtp_header.SequenceNumber += 1; builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); } - } + } return GF_OK; } diff --git a/src/ietf/rtp_pck_mpeg4.c b/src/ietf/rtp_pck_mpeg4.c index cfffc69..7a721be 100644 --- a/src/ietf/rtp_pck_mpeg4.c +++ b/src/ietf/rtp_pck_mpeg4.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -107,7 +107,7 @@ u32 gf_rtp_build_au_hdr_write(GP_RTPPacketizer *builder, u32 PayloadSize, u32 RT { u32 nbBits = 0; s32 delta; - + /*selective encryption*/ if (builder->flags & GP_RTP_PCK_SELECTIVE_ENCRYPTION) { gf_bs_write_int(builder->pck_hdr, builder->is_encrypted, 1); @@ -205,7 +205,7 @@ u32 gf_rtp_build_au_hdr_write(GP_RTPPacketizer *builder, u32 PayloadSize, u32 RT GF_Err gp_rtp_builder_do_mpeg4(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize) { char *sl_buffer, *payl_buffer; - u32 sl_buffer_size, payl_buffer_size; + u32 sl_buffer_size, payl_buffer_size; u32 auh_size_tmp, bytesLeftInPacket, infoSize, pckSize; u64 pos; u8 flush_pck, no_split; @@ -236,11 +236,11 @@ GF_Err gp_rtp_builder_do_mpeg4(GP_RTPPacketizer *builder, char *data, u32 data_s //we decide if we go with the same RTP TS serie or not if (builder->payload) { //don't store more than what we can (that is 2^slMap->CTSDelta - 1) - if ( (builder->flags & GP_RTP_PCK_SIGNAL_TS) - && (builder->sl_header.compositionTimeStamp - builder->rtp_header.TimeStamp >= (u32) ( 1 << builder->slMap.CTSDeltaLength) ) ) { + if ( (builder->flags & GP_RTP_PCK_SIGNAL_TS) + && (builder->sl_header.compositionTimeStamp - builder->rtp_header.TimeStamp >= (u32) ( 1 << builder->slMap.CTSDeltaLength) ) ) { goto flush_packet; } - //don't split AU if # TS , start a new RTP pck + //don't split AU if # TS , start a new RTP pck if (builder->sl_header.compositionTimeStamp != builder->rtp_header.TimeStamp) no_split = 1; } @@ -268,19 +268,19 @@ GF_Err gp_rtp_builder_do_mpeg4(GP_RTPPacketizer *builder, char *data, u32 data_s if (builder->has_AU_header) { builder->auh_size = 16; gf_bs_write_int(builder->pck_hdr, 0, 16); - } + } flush_pck = 0; /*and create packet*/ builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); } //make sure we are not interleaving too much - this should never happen actually - if (builder->slMap.IndexDeltaLength - && !builder->first_sl_in_rtp - && (builder->sl_header.AU_sequenceNumber - builder->last_au_sn >= (u32) 1<slMap.IndexDeltaLength)) { + if (builder->slMap.IndexDeltaLength + && !builder->first_sl_in_rtp + && (builder->sl_header.AU_sequenceNumber - builder->last_au_sn >= (u32) 1<slMap.IndexDeltaLength)) { //we cannot write this packet here goto flush_packet; - } + } /*check max ptime*/ if (builder->max_ptime && ( (u32) builder->sl_header.compositionTimeStamp >= builder->rtp_header.TimeStamp + builder->max_ptime) ) goto flush_packet; @@ -299,7 +299,7 @@ GF_Err gp_rtp_builder_do_mpeg4(GP_RTPPacketizer *builder, char *data, u32 data_s builder->sl_header.accessUnitEndFlag = IsAUEnd; builder->auh_size += auh_size_tmp; - + builder->sl_header.paddingFlag = builder->sl_header.paddingBits ? 1 : 0; } else { @@ -316,9 +316,9 @@ GF_Err gp_rtp_builder_do_mpeg4(GP_RTPPacketizer *builder, char *data, u32 data_s } gf_rtp_build_au_hdr_write(builder, pckSize, builder->rtp_header.TimeStamp); - + //notify the user of our data structure - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, pckSize, data_size - bytesLeftInPacket); else gf_bs_write_data(builder->payload, data + (data_size - bytesLeftInPacket), pckSize); @@ -355,11 +355,11 @@ flush_packet: /*no aux data yet*/ if (builder->slMap.AuxiliaryDataSizeLength) { //write RSLH after the MSLH - gf_bs_write_int(builder->pck_hdr, 0, builder->slMap.AuxiliaryDataSizeLength); - } + gf_bs_write_int(builder->pck_hdr, 0, builder->slMap.AuxiliaryDataSizeLength); + } /*rewrite the size header*/ if (builder->has_AU_header) { - pos = gf_bs_get_position(builder->pck_hdr); + pos = gf_bs_get_position(builder->pck_hdr); gf_bs_seek(builder->pck_hdr, 0); builder->auh_size -= 16; gf_bs_write_int(builder->pck_hdr, builder->auh_size, 16); @@ -374,7 +374,7 @@ flush_packet: payl_buffer = NULL; payl_buffer_size = 0; - if (!builder->OnDataReference) + if (!builder->OnDataReference) gf_bs_get_content(builder->payload, &payl_buffer, &payl_buffer_size); gf_bs_del(builder->payload); @@ -454,7 +454,7 @@ GF_Err gp_rtp_builder_do_avc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_siz Bool use_stap = 1; /*if this is the AU end and no NALU in packet, go for single mode*/ if (IsAUEnd && !builder->bytesInPacket) use_stap = 0; - + if (use_stap) { /*declare STAP-A NAL*/ if (!builder->bytesInPacket) { @@ -470,7 +470,7 @@ GF_Err gp_rtp_builder_do_avc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_siz builder->bytesInPacket += 2; } /*add data*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, nalu_size, 0); else builder->OnData(builder->cbk_obj, nalu, nalu_size, 0); @@ -510,7 +510,7 @@ GF_Err gp_rtp_builder_do_avc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_siz builder->OnData(builder->cbk_obj, (char *)shdr, 2, 0); /*add data*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, size, offset); else builder->OnData(builder->cbk_obj, nalu+offset, size, 0); @@ -571,10 +571,10 @@ GF_Err gp_rtp_builder_do_hevc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_si /*at this point we're sure the NALU fits in current packet OR must be splitted*/ /*check that we should use single NALU packet mode or aggreation packets mode*/ if (builder->bytesInPacket+nalu_size+4 < builder->Path_MTU) { - Bool use_AP = 1; + Bool use_AP = (builder->flags & GP_RTP_PCK_USE_MULTI) ? 1 : 0; /*if this is the AU end and no NALU in packet, go for single NALU packet mode*/ if (IsAUEnd && !builder->bytesInPacket) use_AP = 0; - + if (use_AP) { char nal_s[2]; /*declare PayloadHdr for AP*/ @@ -610,7 +610,7 @@ GF_Err gp_rtp_builder_do_hevc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_si builder->bytesInPacket += 2; } /*add data*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, nalu_size, 0); else builder->OnData(builder->cbk_obj, nalu, nalu_size, 0); @@ -666,7 +666,7 @@ GF_Err gp_rtp_builder_do_hevc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_si builder->OnData(builder->cbk_obj, &shdr, 1, 0); /*add data*/ - if (builder->OnDataReference) + if (builder->OnDataReference) builder->OnDataReference(builder->cbk_obj, size, offset); else builder->OnData(builder->cbk_obj, nalu+offset, size, 0); @@ -693,76 +693,76 @@ GF_Err gp_rtp_builder_do_hevc(GP_RTPPacketizer *builder, char *nalu, u32 nalu_si void latm_flush(GP_RTPPacketizer *builder) { if (builder->bytesInPacket) { - builder->OnPacketDone(builder->cbk_obj, &builder->rtp_header); + builder->OnPacketDone(builder->cbk_obj, &builder->rtp_header); builder->bytesInPacket = 0; } - builder->rtp_header.TimeStamp = (u32) builder->sl_header.compositionTimeStamp; + builder->rtp_header.TimeStamp = (u32) builder->sl_header.compositionTimeStamp; } -GF_Err gp_rtp_builder_do_latm(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration) +GF_Err gp_rtp_builder_do_latm(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration) { - u32 size, latm_hdr_size, i, data_offset; - Bool fragmented; - unsigned char *latm_hdr; + u32 size, latm_hdr_size, i, data_offset; + Bool fragmented; + unsigned char *latm_hdr; if (!data) { latm_flush(builder); - return GF_OK; + return GF_OK; } - + if ((builder->flags & GP_RTP_PCK_USE_MULTI) && builder->max_ptime) { - if ((u32) builder->sl_header.compositionTimeStamp + duration >= builder->rtp_header.TimeStamp + builder->max_ptime) + if ((u32) builder->sl_header.compositionTimeStamp + duration >= builder->rtp_header.TimeStamp + builder->max_ptime) latm_flush(builder); } /*compute max size for frame, flush current if this doesn't fit*/ - latm_hdr_size = (data_size / 255) + 1; + latm_hdr_size = (data_size / 255) + 1; if (latm_hdr_size+data_size > builder->Path_MTU - builder->bytesInPacket) { latm_flush(builder); } data_offset = 0; fragmented = 0; - while (data_size > 0) { - latm_hdr_size = (data_size / 255) + 1; + while (data_size > 0) { + latm_hdr_size = (data_size / 255) + 1; /*fragmenting*/ if (latm_hdr_size + data_size > builder->Path_MTU) { assert(!builder->bytesInPacket); fragmented = 1; - latm_hdr_size = (builder->Path_MTU / 255) + 1; - size = builder->Path_MTU - latm_hdr_size; - builder->rtp_header.Marker = 0; + latm_hdr_size = (builder->Path_MTU / 255) + 1; + size = builder->Path_MTU - latm_hdr_size; + builder->rtp_header.Marker = 0; } /*last fragment or full AU*/ - else { + else { fragmented = 0; - size = data_size; - builder->rtp_header.Marker = 1; - } - data_size -= size; - - /*create new RTP Packet if needed*/ + size = data_size; + builder->rtp_header.Marker = 1; + } + data_size -= size; + + /*create new RTP Packet if needed*/ if (!builder->bytesInPacket) { - builder->rtp_header.SequenceNumber += 1; - builder->rtp_header.TimeStamp = (u32) builder->sl_header.compositionTimeStamp; - builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); + builder->rtp_header.SequenceNumber += 1; + builder->rtp_header.TimeStamp = (u32) builder->sl_header.compositionTimeStamp; + builder->OnNewPacket(builder->cbk_obj, &builder->rtp_header); } - - /* compute AudioMuxUnit header */ - latm_hdr_size = (size / 255) + 1; - latm_hdr = (unsigned char *)gf_malloc( sizeof(char) * latm_hdr_size); - for (i=0; iOnData(builder->cbk_obj, (char*) latm_hdr, latm_hdr_size, 0); builder->bytesInPacket += latm_hdr_size; gf_free(latm_hdr); - - /*add payload*/ + + /*add payload*/ if (builder->OnDataReference) { - builder->OnDataReference(builder->cbk_obj, size, data_offset); - } else - builder->OnData(builder->cbk_obj, data, size, 0); + builder->OnDataReference(builder->cbk_obj, size, data_offset); + } else + builder->OnData(builder->cbk_obj, data, size, 0); builder->bytesInPacket += size; @@ -770,12 +770,12 @@ GF_Err gp_rtp_builder_do_latm(GP_RTPPacketizer *builder, char *data, u32 data_si /*fragmented AU, always flush packet*/ if (!builder->rtp_header.Marker) latm_flush(builder); - } + } /*if the AU has been fragmented or we don't use RTP aggregation, flush*/ if (! (builder->flags & GP_RTP_PCK_USE_MULTI) ) fragmented = 1; if (fragmented) latm_flush(builder); - - return GF_OK; + + return GF_OK; } diff --git a/src/ietf/rtp_streamer.c b/src/ietf/rtp_streamer.c index 4126278..a4531ee 100644 --- a/src/ietf/rtp_streamer.c +++ b/src/ietf/rtp_streamer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,7 +37,7 @@ struct __rtp_streamer { GP_RTPPacketizer *packetizer; - GF_RTPChannel *channel; + GF_RTPChannel *channel; /* The current packet being formed */ char *buffer; @@ -57,7 +57,7 @@ static void rtp_stream_on_packet_done(void *cbk, GF_RTPHeader *header) { GF_RTPStreamer *rtp = cbk; GF_Err e = gf_rtp_send_packet(rtp->channel, header, rtp->buffer+12, rtp->payload_len, 1); - + #ifndef GPAC_DISABLE_LOG if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("Error %s sending RTP packet\n", gf_error_to_string(e))); @@ -126,18 +126,18 @@ static GF_Err rtp_stream_init_channel(GF_RTPStreamer *rtp, u32 path_mtu, const c return res; } return GF_OK; -} +} GF_EXPORT -GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale, - const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, - u32 flags, char *dsi, u32 dsi_len, - - u32 PayloadType, u32 sample_rate, u32 nb_ch, - Bool is_crypted, u32 IV_length, u32 KI_length, - u32 MinSize, u32 MaxSize, u32 avgTS, u32 maxDTSDelta, u32 const_dur, u32 bandwidth, u32 max_ptime, - u32 au_sn_len - ) +GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale, + const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, + u32 flags, char *dsi, u32 dsi_len, + + u32 PayloadType, u32 sample_rate, u32 nb_ch, + Bool is_crypted, u32 IV_length, u32 KI_length, + u32 MinSize, u32 MaxSize, u32 avgTS, u32 maxDTSDelta, u32 const_dur, u32 bandwidth, u32 max_ptime, + u32 au_sn_len + ) { GF_SLConfig slc; GF_RTPStreamer *stream; @@ -217,11 +217,11 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc mpeg4mode = "CELP"; break; } - } + } #endif break; - /*MPEG1/2 audio*/ + /*MPEG1/2 audio*/ case GPAC_OTI_AUDIO_MPEG2_PART3: case GPAC_OTI_AUDIO_MPEG1: if (!is_crypted) { @@ -318,12 +318,12 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc case GF_STREAM_SCENE: case GF_STREAM_OD: - if (oti == GPAC_OTI_SCENE_DIMS) { - rtp_type = GF_RTP_PAYT_3GPP_DIMS; - has_mpeg4_mapping = 0; - } else { - rtp_type = GF_RTP_PAYT_MPEG4; - } + if (oti == GPAC_OTI_SCENE_DIMS) { + rtp_type = GF_RTP_PAYT_3GPP_DIMS; + has_mpeg4_mapping = 0; + } else { + rtp_type = GF_RTP_PAYT_MPEG4; + } break; @@ -370,7 +370,7 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc oti = GPAC_OTI_VIDEO_AVC; PL_ID = 0x0F; } - break; + break; case GF_ISOM_SUBTYPE_3GP_QCELP: required_rate = 8000; rtp_type = GF_RTP_PAYT_QCELP; @@ -397,7 +397,7 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc /*not supported*/ if (!rtp_type) return NULL; - + /*override hinter type if requested and possible*/ if (has_mpeg4_mapping && (flags & GP_RTP_PCK_FORCE_MPEG4)) { rtp_type = GF_RTP_PAYT_MPEG4; @@ -445,19 +445,19 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc slc.hasRandomAccessUnitsOnlyFlag = 1; } - stream->packetizer = gf_rtp_builder_new(rtp_type, &slc, flags, - stream, - rtp_stream_on_new_packet, rtp_stream_on_packet_done, - NULL, rtp_stream_on_data); - + stream->packetizer = gf_rtp_builder_new(rtp_type, &slc, flags, + stream, + rtp_stream_on_new_packet, rtp_stream_on_packet_done, + NULL, rtp_stream_on_data); + if (!stream->packetizer) { GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTP Packetizer] Failed to create packetizer\n")); gf_free(stream); return NULL; } - + gf_rtp_builder_init(stream->packetizer, PayloadType, MTU, max_ptime, - streamType, oti, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode); + streamType, oti, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode); if (force_dts_delta) stream->packetizer->slMap.DTSDeltaLength = force_dts_delta; @@ -479,13 +479,13 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc GF_EXPORT -GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, - const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, - u32 flags, char *dsi, u32 dsi_len) +GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, + const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, + u32 flags, char *dsi, u32 dsi_len) { return gf_rtp_streamer_new_extended(streamType, oti, timeScale, ip_dest, port, MTU, TTL, ifce_addr, flags, dsi, dsi_len, - 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } @@ -495,7 +495,7 @@ void gf_rtp_streamer_del(GF_RTPStreamer *streamer) if (streamer) { if (streamer->channel) gf_rtp_del(streamer->channel); if (streamer->packetizer) gf_rtp_builder_del(streamer->packetizer); - if (streamer->buffer) gf_free(streamer->buffer); + if (streamer->buffer) gf_free(streamer->buffer); gf_free(streamer); } } @@ -546,8 +546,8 @@ void gf_media_format_ttxt_sdp(GP_RTPPacketizer *builder, char *payload_name, cha GF_EXPORT -GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, GF_ISOFile *isofile, u32 isotrack, char *KMS_URI, u32 width, u32 height, char **out_sdp_buffer) -{ +GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, GF_ISOFile *isofile, u32 isotrack, char *KMS_URI, u32 width, u32 height, char **out_sdp_buffer) +{ u32 size; u16 port; char mediaName[30], payloadName[30]; @@ -561,9 +561,9 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * sprintf(sdp, "m=%s %d RTP/%s %d\n", mediaName, port, rtp->packetizer->slMap.IV_length ? "SAVP" : "AVP", rtp->packetizer->PayloadType); sprintf(sdpLine, "a=rtpmap:%d %s/%d\n", rtp->packetizer->PayloadType, payloadName, rtp->packetizer->sl_config.timestampResolution); strcat(sdp, sdpLine); - if (ESID && (rtp->packetizer->rtp_payt != GF_RTP_PAYT_3GPP_DIMS)) { + if (ESID && (rtp->packetizer->rtp_payt != GF_RTP_PAYT_3GPP_DIMS)) { sprintf(sdpLine, "a=mpeg4-esid:%d\n", ESID); - strcat(sdp, sdpLine); + strcat(sdp, sdpLine); } if (width && height) { @@ -575,7 +575,7 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * sprintf(sdpLine, "a=framesize:%d %d-%d\n", rtp->packetizer->PayloadType, width, height); strcat(sdp, sdpLine); } - + strcpy(sdpLine, ""); /*AMR*/ @@ -634,7 +634,7 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * for (i = 0; i < count; i++) { GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(hevcc->param_array, i); if (ar->type==GF_HEVC_NALU_SEQ_PARAM) { - strcat(sdpLine, "; sprop-sps="); + strcat(sdpLine, "; sprop-sps="); } else if (ar->type==GF_HEVC_NALU_PIC_PARAM) { strcat(sdpLine, "; sprop-pps="); } else if (ar->type==GF_HEVC_NALU_VID_PARAM) { @@ -668,41 +668,41 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * strcat(sdpLine, "\n"); } } - /*DIMS decoder config*/ - else if (rtp->packetizer->rtp_payt==GF_RTP_PAYT_3GPP_DIMS) { - sprintf(sdpLine, "a=fmtp:%d Version-profile=%d", rtp->packetizer->PayloadType, 10); - if (rtp->packetizer->flags & GP_RTP_DIMS_COMPRESSED) { - strcat(sdpLine, ";content-coding=deflate"); - } + /*DIMS decoder config*/ + else if (rtp->packetizer->rtp_payt==GF_RTP_PAYT_3GPP_DIMS) { + sprintf(sdpLine, "a=fmtp:%d Version-profile=%d", rtp->packetizer->PayloadType, 10); + if (rtp->packetizer->flags & GP_RTP_DIMS_COMPRESSED) { + strcat(sdpLine, ";content-coding=deflate"); + } strcat(sdpLine, "\n"); - } + } /*MPEG-4 Audio LATM*/ - else if (rtp->packetizer->rtp_payt==GF_RTP_PAYT_LATM) { - GF_BitStream *bs; - char *config_bytes; - u32 config_size; - - /* form config string */ - bs = gf_bs_new(NULL, 32, GF_BITSTREAM_WRITE); - gf_bs_write_int(bs, 0, 1); /* AudioMuxVersion */ - gf_bs_write_int(bs, 1, 1); /* all streams same time */ - gf_bs_write_int(bs, 0, 6); /* numSubFrames */ - gf_bs_write_int(bs, 0, 4); /* numPrograms */ - gf_bs_write_int(bs, 0, 3); /* numLayer */ + else if (rtp->packetizer->rtp_payt==GF_RTP_PAYT_LATM) { + GF_BitStream *bs; + char *config_bytes; + u32 config_size; + + /* form config string */ + bs = gf_bs_new(NULL, 32, GF_BITSTREAM_WRITE); + gf_bs_write_int(bs, 0, 1); /* AudioMuxVersion */ + gf_bs_write_int(bs, 1, 1); /* all streams same time */ + gf_bs_write_int(bs, 0, 6); /* numSubFrames */ + gf_bs_write_int(bs, 0, 4); /* numPrograms */ + gf_bs_write_int(bs, 0, 3); /* numLayer */ /* audio-specific config - PacketVideo patch: don't signal SBR and PS stuff, not allowed in LATM with audioMuxVersion=0*/ - if (dsi) gf_bs_write_data(bs, dsi, MIN(dsi_len, 2) ); - - /* other data */ - gf_bs_write_int(bs, 0, 3); /* frameLengthType */ - gf_bs_write_int(bs, 0xff, 8); /* latmBufferFullness */ - gf_bs_write_int(bs, 0, 1); /* otherDataPresent */ - gf_bs_write_int(bs, 0, 1); /* crcCheckPresent */ - gf_bs_get_content(bs, &config_bytes, &config_size); - gf_bs_del(bs); - - gf_rtp_builder_format_sdp(rtp->packetizer, payloadName, sdpLine, config_bytes, config_size); - gf_free(config_bytes); + if (dsi) gf_bs_write_data(bs, dsi, MIN(dsi_len, 2) ); + + /* other data */ + gf_bs_write_int(bs, 0, 3); /* frameLengthType */ + gf_bs_write_int(bs, 0xff, 8); /* latmBufferFullness */ + gf_bs_write_int(bs, 0, 1); /* otherDataPresent */ + gf_bs_write_int(bs, 0, 1); /* crcCheckPresent */ + gf_bs_get_content(bs, &config_bytes, &config_size); + gf_bs_del(bs); + + gf_rtp_builder_format_sdp(rtp->packetizer, payloadName, sdpLine, config_bytes, config_size); + gf_free(config_bytes); strcat(sdpLine, "\n"); } @@ -719,10 +719,10 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * strcat(*out_sdp_buffer, sdp); } return GF_OK; -} +} GF_EXPORT -GF_Err gf_rtp_streamer_append_sdp_decoding_dependency(GF_ISOFile *isofile, u32 isotrack, u8 *payload_type, char **out_sdp_buffer) +GF_Err gf_rtp_streamer_append_sdp_decoding_dependency(GF_ISOFile *isofile, u32 isotrack, u8 *payload_type, char **out_sdp_buffer) { u32 size, i, ref_track; s32 count; @@ -735,7 +735,7 @@ GF_Err gf_rtp_streamer_append_sdp_decoding_dependency(GF_ISOFile *isofile, u32 i { sprintf(sdpLine, "a=depend:%d lay", payload_type[isotrack-1]); strcat(sdp, sdpLine); - for (i = 0; i < (u32) count; i++) + for (i = 0; i < (u32) count; i++) { gf_isom_get_reference(isofile, isotrack, GF_ISOM_REF_SCAL, i+1, &ref_track); sprintf(sdpLine, " L%d:%d", ref_track, payload_type[ref_track-1]); @@ -771,8 +771,8 @@ char *gf_rtp_streamer_format_sdp_header(char *app_name, char *ip_dest, char *ses fprintf(tmp, "s=%s\n", (session_name ? session_name : "GPAC Scene Streaming Session")); fprintf(tmp, "c=IN IP%d %s\n", gf_net_is_ipv6(ip_dest) ? 6 : 4, ip_dest); fprintf(tmp, "t=0 0\n"); - - if (iod64) fprintf(tmp, "a=mpeg4-iod:\"data:application/mpeg4-iod;base64,%s\"\n", iod64); + + if (iod64) fprintf(tmp, "a=mpeg4-iod:\"data:application/mpeg4-iod;base64,%s\"\n", iod64); gf_f64_seek(tmp, 0, SEEK_END); size = gf_f64_tell(tmp); @@ -785,7 +785,7 @@ char *gf_rtp_streamer_format_sdp_header(char *app_name, char *ip_dest, char *ses } GF_EXPORT -GF_Err gf_rtp_streamer_append_sdp(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, char *KMS_URI, char **out_sdp_buffer) +GF_Err gf_rtp_streamer_append_sdp(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, char *KMS_URI, char **out_sdp_buffer) { return gf_rtp_streamer_append_sdp_extended(rtp, ESID, dsi, dsi_len, NULL, 0, KMS_URI, 0, 0, out_sdp_buffer); } diff --git a/src/ietf/rtsp_command.c b/src/ietf/rtsp_command.c index c39288f..728efa2 100644 --- a/src/ietf/rtsp_command.c +++ b/src/ietf/rtsp_command.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -72,8 +72,8 @@ void gf_rtsp_command_reset(GF_RTSPCommand *com) //this is for server only, set to OK by default com->StatusCode = NC_RTSP_OK; - - + + com->user_data = NULL; com->Bandwidth = com->Blocksize = com->Content_Length = com->CSeq = 0; @@ -106,8 +106,8 @@ void gf_rtsp_command_del(GF_RTSPCommand *com) } -GF_Err RTSP_WriteCommand(GF_RTSPSession *sess, GF_RTSPCommand *com, unsigned char *req_buffer, - unsigned char **out_buffer, u32 *out_size) +GF_Err RTSP_WriteCommand(GF_RTSPSession *sess, GF_RTSPCommand *com, unsigned char *req_buffer, + unsigned char **out_buffer, u32 *out_size) { u32 i, cur_pos, size, count; char *buffer, temp[50]; @@ -125,59 +125,59 @@ GF_Err RTSP_WriteCommand(GF_RTSPSession *sess, GF_RTSPCommand *com, unsigned cha //then all headers RTSP_WRITE_HEADER(buffer, size, cur_pos, "Accept", com->Accept); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Accept-Encoding", com->Accept_Encoding); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Accept-Language", com->Accept_Language); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Authorization", com->Authorization); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Accept-Encoding", com->Accept_Encoding); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Accept-Language", com->Accept_Language); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Authorization", com->Authorization); if (com->Bandwidth) { - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Bandwidth: "); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Bandwidth: "); RTSP_WRITE_INT(buffer, size, cur_pos, com->Bandwidth, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } if (com->Blocksize) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Blocksize: "); RTSP_WRITE_INT(buffer, size, cur_pos, com->Blocksize, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Cache-Control", com->Cache_Control); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Conference", com->Conference); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Cache-Control", com->Cache_Control); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Conference", com->Conference); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Connection", com->Connection); //if we have a body write the content length if (com->body) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Content-Length: "); RTSP_WRITE_INT(buffer, size, cur_pos, (u32) strlen(com->body), 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } //write the CSeq - use the SESSION CSeq RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "CSeq: "); RTSP_WRITE_INT(buffer, size, cur_pos, sess->CSeq, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "From", com->From); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Proxy-Authorization", com->Proxy_Authorization); - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Proxy-Require", com->Proxy_Require); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "From", com->From); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Proxy-Authorization", com->Proxy_Authorization); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Proxy-Require", com->Proxy_Require); //Range, only NPT if (com->Range && !com->Range->UseSMPTE) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Range: npt="); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, com->Range->start); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "-"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "-"); if (com->Range->end > com->Range->start) { RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, com->Range->end); } - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Referer", com->Referer); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Referer", com->Referer); if (com->Scale != 0.0) { - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Scale: "); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Scale: "); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, com->Scale); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } - RTSP_WRITE_HEADER(buffer, size, cur_pos, "Session", com->Session); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "Session", com->Session); if (com->Speed != 0.0) { - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Speed: "); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Speed: "); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, com->Speed); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } //transport info @@ -243,14 +243,14 @@ GF_Err RTSP_WriteCommand(GF_RTSPSession *sess, GF_RTSPCommand *com, unsigned cha //done with transport RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } - RTSP_WRITE_HEADER(buffer, size, cur_pos, "User-Agent", com->User_Agent); + RTSP_WRITE_HEADER(buffer, size, cur_pos, "User-Agent", com->User_Agent); //eXtensions count = gf_list_count(com->Xtensions); for (i=0; iXtensions, i); RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "x-"); - RTSP_WRITE_HEADER(buffer, size, cur_pos, att->Name, att->Value); + RTSP_WRITE_HEADER(buffer, size, cur_pos, att->Name, att->Value); } //the end of header @@ -267,7 +267,7 @@ GF_Err RTSP_WriteCommand(GF_RTSPSession *sess, GF_RTSPCommand *com, unsigned cha //format a DESCRIBE, SETUP, PLAY or PAUSE on a session -//YOUR COMMAND MUST BE FORMATTED ACCORDINGLY +//YOUR COMMAND MUST BE FORMATTED ACCORDINGLY //sCtrl contains a control string if needed, formating the REQUEST as server_url/service_name/sCtrl GF_EXPORT GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com) @@ -284,39 +284,39 @@ GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com) //NB: OPTIONS is not sent this way if (strcmp(com->method, GF_RTSP_DESCRIBE) - && strcmp(com->method, GF_RTSP_ANNOUNCE) - && strcmp(com->method, GF_RTSP_GET_PARAMETER) - && strcmp(com->method, GF_RTSP_SET_PARAMETER) - && strcmp(com->method, GF_RTSP_SETUP) - && strcmp(com->method, GF_RTSP_PLAY) - && strcmp(com->method, GF_RTSP_PAUSE) - && strcmp(com->method, GF_RTSP_RECORD) - && strcmp(com->method, GF_RTSP_REDIRECTE) - && strcmp(com->method, GF_RTSP_TEARDOWN) - && strcmp(com->method, GF_RTSP_OPTIONS) - - ) return GF_BAD_PARAM; + && strcmp(com->method, GF_RTSP_ANNOUNCE) + && strcmp(com->method, GF_RTSP_GET_PARAMETER) + && strcmp(com->method, GF_RTSP_SET_PARAMETER) + && strcmp(com->method, GF_RTSP_SETUP) + && strcmp(com->method, GF_RTSP_PLAY) + && strcmp(com->method, GF_RTSP_PAUSE) + && strcmp(com->method, GF_RTSP_RECORD) + && strcmp(com->method, GF_RTSP_REDIRECTE) + && strcmp(com->method, GF_RTSP_TEARDOWN) + && strcmp(com->method, GF_RTSP_OPTIONS) + + ) return GF_BAD_PARAM; //check the state machine - if (strcmp(com->method, GF_RTSP_PLAY) - && strcmp(com->method, GF_RTSP_PAUSE) - && strcmp(com->method, GF_RTSP_RECORD) - && sess->RTSP_State != GF_RTSP_STATE_INIT) + if (strcmp(com->method, GF_RTSP_PLAY) + && strcmp(com->method, GF_RTSP_PAUSE) + && strcmp(com->method, GF_RTSP_RECORD) + && sess->RTSP_State != GF_RTSP_STATE_INIT) return GF_SERVICE_ERROR; //aggregation is ONLY for the same request - unclear in RFC2326 ... //it is often mentioned "queued requests" at the server, like 3 PLAYS //and a PAUSE .... - + /* - else if (sess->RTSP_State == GF_RTSP_STATE_WAIT_FOR_CONTROL + else if (sess->RTSP_State == GF_RTSP_STATE_WAIT_FOR_CONTROL && strcmp(com->method, sess->RTSPLastRequest)) && strcmp(com->method, GF_RTSP_OPTIONS)) return GF_BAD_PARAM; -*/ + */ - //OPTIONS must have a parameter string + //OPTIONS must have a parameter string if (!strcmp(com->method, GF_RTSP_OPTIONS) && !sCtrl) return GF_BAD_PARAM; @@ -353,10 +353,10 @@ GF_Err gf_rtsp_send_command(GF_RTSPSession *sess, GF_RTSPCommand *com) //Body on ANNOUNCE, GET_PARAMETER, SET_PARAMETER ONLY body = NULL; - if (strcmp(com->method, GF_RTSP_ANNOUNCE) - && strcmp(com->method, GF_RTSP_GET_PARAMETER) - && strcmp(com->method, GF_RTSP_SET_PARAMETER) - ) { + if (strcmp(com->method, GF_RTSP_ANNOUNCE) + && strcmp(com->method, GF_RTSP_GET_PARAMETER) + && strcmp(com->method, GF_RTSP_SET_PARAMETER) + ) { //this is an error, but don't say anything if (com->body) { body = com->body; @@ -468,7 +468,7 @@ GF_Err RTSP_ParseCommandHeader(GF_RTSPSession *sess, GF_RTSPCommand *com, u32 Bo Pos = gf_token_get(LineBuffer, Pos, " \t\r\n", ValBuf, 1024); if (Pos <= 0) return GF_OK; com->service_name = gf_strdup(ValBuf); - + //RTSP version Pos = gf_token_get(LineBuffer, Pos, "\t\r\n", ValBuf, 1024); if (Pos <= 0) return GF_OK; @@ -478,7 +478,7 @@ GF_Err RTSP_ParseCommandHeader(GF_RTSPSession *sess, GF_RTSPCommand *com, u32 Bo } com->StatusCode = NC_RTSP_OK; - + return gf_rtsp_parse_header(buffer + ret, Size - ret, BodyStart, com, NULL); } @@ -517,7 +517,7 @@ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com) if (!e && com->Content_Length) { com->body = (char *) gf_malloc(sizeof(char) * (com->Content_Length)); memcpy(com->body, sess->TCPBuffer+sess->CurrentPos + BodyStart, com->Content_Length); - } + } //reset TCP buffer sess->CurrentPos += BodyStart + com->Content_Length; @@ -530,7 +530,7 @@ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com) //dynamically, nor reset the session ourselves as we don't know the details of the session //(eg TEARDOWN may keep resources up or not, ...) - //we also have the same pb for CSeq, as nothing forbids a server to buffer commands (and it + //we also have the same pb for CSeq, as nothing forbids a server to buffer commands (and it //happens during aggregation of PLAY/PAUSE with overlapping ranges) //however store the last CSeq in case for client checking @@ -539,7 +539,7 @@ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com) } //check we're in the right range else { - if (sess->CSeq >= com->CSeq) + if (sess->CSeq >= com->CSeq) com->StatusCode = NC_RTSP_Header_Field_Not_Valid; else sess->CSeq = com->CSeq; @@ -548,20 +548,20 @@ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com) // //if a connection closed is signal, check this is the good session // and reset it (the client is no longer connected) - if (sess->last_session_id && com->Session && !strcmp(com->Session, sess->last_session_id) - && com->Connection && !stricmp(com->Connection, "Close")) { + if (sess->last_session_id && com->Session && !strcmp(com->Session, sess->last_session_id) + && com->Connection && !stricmp(com->Connection, "Close")) { gf_rtsp_session_reset(sess, 0); //destroy the socket if (sess->connection) gf_sk_del(sess->connection); sess->connection = NULL; - + //destroy the http tunnel if any if (sess->HasTunnel && sess->http) { gf_sk_del(sess->http); sess->http = NULL; } - } + } exit: gf_mx_v(sess->mx); diff --git a/src/ietf/rtsp_common.c b/src/ietf/rtsp_common.c index 2661d55..a440634 100644 --- a/src/ietf/rtsp_common.c +++ b/src/ietf/rtsp_common.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ GF_Err gf_rtsp_read_reply(GF_RTSPSession *sess) while (1) { //Locate header / body if (!BodyStart) gf_rtsp_get_body_info(sess, &BodyStart, &body_size); - + if (BodyStart) { //enough data res = sess->CurrentSize - sess->CurrentPos; @@ -73,11 +73,11 @@ void gf_rtsp_get_body_info(GF_RTSPSession *sess, u32 *body_start, u32 *body_size //if found add the 2 "\r\n" and parse it *body_start = start + 4; - + //get the content length cl_str = strstr(buffer, "Content-Length: "); if (!cl_str) cl_str = strstr(buffer, "Content-length: "); - + if (cl_str) { cl_str += 16; i = 0; @@ -114,9 +114,9 @@ GF_Err gf_rtsp_refill_buffer(GF_RTSPSession *sess) sess->CurrentSize = res; //now read from current pos - e = gf_sk_receive(sess->connection, sess->TCPBuffer + sess->CurrentSize, - RTSP_TCP_BUF_SIZE - sess->CurrentSize, - 0, &res); + e = gf_sk_receive(sess->connection, sess->TCPBuffer + sess->CurrentSize, + RTSP_TCP_BUF_SIZE - sess->CurrentSize, + 0, &res); if (!e) { sess->CurrentSize += res; @@ -157,7 +157,7 @@ GF_RTSPTransport *gf_rtsp_transport_parse(char *buffer) IsFirst = 1; pos = 0; - while (1) { + while (1) { pos = gf_token_get(buffer, pos, " ;", buf, 100); if (pos <= 0) break; if (strstr(buf, "=")) { @@ -166,7 +166,7 @@ GF_RTSPTransport *gf_rtsp_transport_parse(char *buffer) } else { strcpy(param_name, buf); } - + //very first param is the profile if (IsFirst) { tmp->Profile = gf_strdup(param_name); @@ -236,10 +236,10 @@ GF_Err gf_rtsp_parse_header(char *buffer, u32 BufferSize, u32 BodyStart, GF_RTSP HeaderLine = 0; LinePos = gf_token_get_line(buffer, LinePos, BufferSize, LineBuffer, 1024); if (LinePos <= 0) return GF_REMOTE_SERVICE_ERROR; - - //extract field header and value. Warning: some params (transport, ..) may be on several lines + + //extract field header and value. Warning: some params (transport, ..) may be on several lines Pos = gf_token_get(LineBuffer, 0, ":\r\n", temp, 400); - + //end of header if (Pos <= 0) { HeaderLine = 2; @@ -298,9 +298,9 @@ const char *gf_rtsp_nc_to_string(u32 ErrCode) switch (ErrCode) { case NC_RTSP_Continue: return "Continue"; - case NC_RTSP_OK: + case NC_RTSP_OK: return "OK"; - case NC_RTSP_Created: + case NC_RTSP_Created: return "Created"; case NC_RTSP_Low_on_Storage_Space: return "Low on Storage Space"; diff --git a/src/ietf/rtsp_response.c b/src/ietf/rtsp_response.c index 8464c27..bb285c2 100644 --- a/src/ietf/rtsp_response.c +++ b/src/ietf/rtsp_response.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -98,7 +98,7 @@ void gf_rtsp_response_reset(GF_RTSPResponse *rsp) rsp->Scale = rsp->Speed = 0.0; if (rsp->Range) gf_free(rsp->Range); rsp->Range = NULL; - + rsp->SessionTimeOut = 0; while (gf_list_count(rsp->Transports)) { @@ -126,7 +126,7 @@ GF_EXPORT void gf_rtsp_response_del(GF_RTSPResponse *rsp) { if (!rsp) return; - + gf_rtsp_response_reset(rsp); gf_list_del(rsp->RTP_Infos); gf_list_del(rsp->Xtensions); @@ -142,12 +142,12 @@ GF_RTSPRange *gf_rtsp_range_parse(char *range_buf) GF_RTSPRange *rg; if (!strstr(range_buf, "npt")) return NULL; - + GF_SAFEALLOC(rg, GF_RTSPRange); if (sscanf(range_buf, "npt=%lf-%lf", &rg->start, &rg->end) != 2) { rg->end = -1.0; sscanf(range_buf, "npt=%lf-", &rg->start); - } + } return rg; } @@ -166,8 +166,8 @@ GF_RTSPTransport *gf_rtsp_transport_clone(GF_RTSPTransport *original) { GF_RTSPTransport *tr; - if (!original) return NULL; - + if (!original) return NULL; + tr = (GF_RTSPTransport*) gf_malloc(sizeof(GF_RTSPTransport)); memcpy(tr, original, sizeof(GF_RTSPTransport)); tr->destination = tr->source = tr->Profile = NULL; @@ -210,36 +210,36 @@ void gf_rtsp_set_response_value(GF_RTSPResponse *rsp, char *Header, char *Value) else if (!stricmp(Header, "Cache-Control")) rsp->Cache_Control = gf_strdup(Value); else if (!stricmp(Header, "Conference")) rsp->Conference = gf_strdup(Value); else if (!stricmp(Header, "Connection")) rsp->Connection = gf_strdup(Value); - else if (!stricmp(Header, "Content-Base")) rsp->Content_Base = gf_strdup(Value); - else if (!stricmp(Header, "Content-Encoding")) rsp->Content_Encoding = gf_strdup(Value); + else if (!stricmp(Header, "Content-Base")) rsp->Content_Base = gf_strdup(Value); + else if (!stricmp(Header, "Content-Encoding")) rsp->Content_Encoding = gf_strdup(Value); else if (!stricmp(Header, "Content-Length")) sscanf(Value, "%u", &rsp->Content_Length); - else if (!stricmp(Header, "Content-Language")) rsp->Content_Language = gf_strdup(Value); - else if (!stricmp(Header, "Content-Location")) rsp->Content_Location = gf_strdup(Value); - else if (!stricmp(Header, "Content-Type")) rsp->Content_Type = gf_strdup(Value); + else if (!stricmp(Header, "Content-Language")) rsp->Content_Language = gf_strdup(Value); + else if (!stricmp(Header, "Content-Location")) rsp->Content_Location = gf_strdup(Value); + else if (!stricmp(Header, "Content-Type")) rsp->Content_Type = gf_strdup(Value); else if (!stricmp(Header, "CSeq")) sscanf(Value, "%u", &rsp->CSeq); - else if (!stricmp(Header, "Date")) rsp->Date = gf_strdup(Value); - else if (!stricmp(Header, "Expires")) rsp->Expires = gf_strdup(Value); - else if (!stricmp(Header, "From")) rsp->From = gf_strdup(Value); - else if (!stricmp(Header, "Host")) rsp->Host = gf_strdup(Value); - else if (!stricmp(Header, "If-Match")) rsp->If_Match = gf_strdup(Value); - else if (!stricmp(Header, "If-Modified-Since")) rsp->If_Modified_Since = gf_strdup(Value); - else if (!stricmp(Header, "Last-Modified")) rsp->Last_Modified = gf_strdup(Value); - else if (!stricmp(Header, "Location")) rsp->Location = gf_strdup(Value); - else if (!stricmp(Header, "Proxy-Authenticate")) rsp->Proxy_Authenticate = gf_strdup(Value); - else if (!stricmp(Header, "Proxy-Require")) rsp->Proxy_Require = gf_strdup(Value); - else if (!stricmp(Header, "Public")) rsp->Public = gf_strdup(Value); - else if (!stricmp(Header, "Referer")) rsp->Referer = gf_strdup(Value); - else if (!stricmp(Header, "Require")) rsp->Require = gf_strdup(Value); - else if (!stricmp(Header, "Retry-After")) rsp->Retry_After = gf_strdup(Value); + else if (!stricmp(Header, "Date")) rsp->Date = gf_strdup(Value); + else if (!stricmp(Header, "Expires")) rsp->Expires = gf_strdup(Value); + else if (!stricmp(Header, "From")) rsp->From = gf_strdup(Value); + else if (!stricmp(Header, "Host")) rsp->Host = gf_strdup(Value); + else if (!stricmp(Header, "If-Match")) rsp->If_Match = gf_strdup(Value); + else if (!stricmp(Header, "If-Modified-Since")) rsp->If_Modified_Since = gf_strdup(Value); + else if (!stricmp(Header, "Last-Modified")) rsp->Last_Modified = gf_strdup(Value); + else if (!stricmp(Header, "Location")) rsp->Location = gf_strdup(Value); + else if (!stricmp(Header, "Proxy-Authenticate")) rsp->Proxy_Authenticate = gf_strdup(Value); + else if (!stricmp(Header, "Proxy-Require")) rsp->Proxy_Require = gf_strdup(Value); + else if (!stricmp(Header, "Public")) rsp->Public = gf_strdup(Value); + else if (!stricmp(Header, "Referer")) rsp->Referer = gf_strdup(Value); + else if (!stricmp(Header, "Require")) rsp->Require = gf_strdup(Value); + else if (!stricmp(Header, "Retry-After")) rsp->Retry_After = gf_strdup(Value); else if (!stricmp(Header, "Scale")) sscanf(Value, "%lf", &rsp->Scale); - else if (!stricmp(Header, "Server")) rsp->Server = gf_strdup(Value); + else if (!stricmp(Header, "Server")) rsp->Server = gf_strdup(Value); else if (!stricmp(Header, "Speed")) sscanf(Value, "%lf", &rsp->Speed); - else if (!stricmp(Header, "Timestamp")) rsp->Timestamp = gf_strdup(Value); - else if (!stricmp(Header, "Unsupported")) rsp->Unsupported = gf_strdup(Value); - else if (!stricmp(Header, "User-Agent")) rsp->User_Agent = gf_strdup(Value); - else if (!stricmp(Header, "Vary")) rsp->Vary = gf_strdup(Value); - else if (!stricmp(Header, "Via")) rsp->Vary = gf_strdup(Value); - else if (!stricmp(Header, "WWW_Authenticate")) rsp->Vary = gf_strdup(Value); + else if (!stricmp(Header, "Timestamp")) rsp->Timestamp = gf_strdup(Value); + else if (!stricmp(Header, "Unsupported")) rsp->Unsupported = gf_strdup(Value); + else if (!stricmp(Header, "User-Agent")) rsp->User_Agent = gf_strdup(Value); + else if (!stricmp(Header, "Vary")) rsp->Vary = gf_strdup(Value); + else if (!stricmp(Header, "Via")) rsp->Vary = gf_strdup(Value); + else if (!stricmp(Header, "WWW_Authenticate")) rsp->Vary = gf_strdup(Value); else if (!stricmp(Header, "Transport")) { LinePos = 0; while (1) { @@ -274,7 +274,7 @@ void gf_rtsp_set_response_value(GF_RTSPResponse *rsp, char *Header, char *Value) GF_SAFEALLOC(info, GF_RTPInfo); Pos = 0; - while (1) { + while (1) { Pos = gf_token_get(LineBuffer, Pos, " ;", buf, 1000); if (Pos <= 0) break; if (strstr(buf, "=")) { @@ -325,17 +325,17 @@ GF_Err RTSP_ParseResponseHeader(GF_RTSPSession *sess, GF_RTSPResponse *rsp, u32 //parse first line ret = gf_token_get_line(buffer, 0, Size, LineBuffer, 1024); - if (ret < 0) + if (ret < 0) return GF_REMOTE_SERVICE_ERROR; //RTSP/1.0 Pos = gf_token_get(LineBuffer, 0, " \t\r\n", ValBuf, 400); - if (Pos <= 0) + if (Pos <= 0) return GF_REMOTE_SERVICE_ERROR; if (strcmp(ValBuf, GF_RTSP_VERSION)) return GF_SERVICE_ERROR; //CODE Pos = gf_token_get(LineBuffer, Pos, " \t\r\n", ValBuf, 400); - if (Pos <= 0) + if (Pos <= 0) return GF_REMOTE_SERVICE_ERROR; rsp->ResponseCode = atoi(ValBuf); //string info @@ -368,7 +368,7 @@ GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp) GF_Err e; Bool force_reset = 0; u32 BodyStart, size; - + if (!sess || !rsp) return GF_BAD_PARAM; gf_rtsp_response_reset(rsp); @@ -378,12 +378,12 @@ GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp) e = gf_rtsp_check_connection(sess); - if (e) + if (e) goto exit; //push data in our queue e = gf_rtsp_fill_buffer(sess); - if (e) + if (e) goto exit; //this is interleaved data @@ -404,15 +404,15 @@ GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp) if (!e && rsp->Content_Length) { rsp->body = (char *)gf_malloc(sizeof(char) * (rsp->Content_Length)); memcpy(rsp->body, sess->TCPBuffer+sess->CurrentPos + BodyStart, rsp->Content_Length); - } + } GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTSP] Got Response:\n%s\n", sess->TCPBuffer+sess->CurrentPos)); - + //reset TCP buffer sess->CurrentPos += BodyStart + rsp->Content_Length; if (e) goto exit; - + //update RTSP aggreagation info if (sess->NbPending) sess->NbPending -= 1; @@ -467,14 +467,14 @@ exit: //destroy the socket if (sess->connection) gf_sk_del(sess->connection); sess->connection = NULL; - + //destroy the http tunnel if any if (sess->HasTunnel && sess->http) { gf_sk_del(sess->http); sess->http = NULL; } - } - + } + gf_mx_v(sess->mx); return e; } @@ -482,8 +482,8 @@ exit: -GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, - unsigned char **out_buffer, u32 *out_size) +GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, + unsigned char **out_buffer, u32 *out_size) { u32 i, cur_pos, size, count; char *buffer, temp[50]; @@ -513,14 +513,14 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, RTSP_WRITE_HEADER(buffer, size, cur_pos, "Allow", rsp->Allow); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Authorization", rsp->Authorization); if (rsp->Bandwidth) { - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Bandwidth: "); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Bandwidth: "); RTSP_WRITE_INT(buffer, size, cur_pos, rsp->Bandwidth, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } if (rsp->Blocksize) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Blocksize: "); RTSP_WRITE_INT(buffer, size, cur_pos, rsp->Blocksize, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } RTSP_WRITE_HEADER(buffer, size, cur_pos, "Cache-Control", rsp->Cache_Control); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Conference", rsp->Conference); @@ -532,14 +532,14 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, if (rsp->body) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Content-Length: "); RTSP_WRITE_INT(buffer, size, cur_pos, (u32) strlen(rsp->body), 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } RTSP_WRITE_HEADER(buffer, size, cur_pos, "Content-Location", rsp->Content_Location); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Content-Type", rsp->Content_Type); //write the CSeq - use the RESPONSE CSeq RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "CSeq: "); RTSP_WRITE_INT(buffer, size, cur_pos, rsp->CSeq, 0); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Date", rsp->Date); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Expires", rsp->Expires); @@ -557,11 +557,11 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, if (rsp->Range && !rsp->Range->UseSMPTE) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Range: npt:"); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, rsp->Range->start); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "-"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "-"); if (rsp->Range->end > rsp->Range->start) { RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, rsp->Range->end); } - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } RTSP_WRITE_HEADER(buffer, size, cur_pos, "Referer", rsp->Referer); @@ -577,7 +577,7 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, //line separator for headers if (i) RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n ,"); info = (GF_RTPInfo*)gf_list_get(rsp->RTP_Infos, i); - + if (info->url) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "url="); RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, info->url); @@ -590,18 +590,18 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, } RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } - + if (rsp->Scale != 0.0) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Scale: "); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, rsp->Scale); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } RTSP_WRITE_HEADER(buffer, size, cur_pos, "Server", rsp->Server); RTSP_WRITE_HEADER(buffer, size, cur_pos, "Session", rsp->Session); if (rsp->Speed != 0.0) { RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "Scale: "); RTSP_WRITE_FLOAT_WITHOUT_CHECK(buffer, size, cur_pos, rsp->Speed); - RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); + RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); } RTSP_WRITE_HEADER(buffer, size, cur_pos, "Timestamp", rsp->Timestamp); @@ -680,7 +680,7 @@ GF_Err RTSP_WriteResponse(GF_RTSPSession *sess, GF_RTSPResponse *rsp, for (i=0; iXtensions, i); RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "x-"); - RTSP_WRITE_HEADER(buffer, size, cur_pos, att->Name, att->Value); + RTSP_WRITE_HEADER(buffer, size, cur_pos, att->Name, att->Value); } //end of header RTSP_WRITE_ALLOC_STR(buffer, size, cur_pos, "\r\n"); diff --git a/src/ietf/rtsp_session.c b/src/ietf/rtsp_session.c index a3614d0..29ef73a 100644 --- a/src/ietf/rtsp_session.c +++ b/src/ietf/rtsp_session.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ GF_Err RTSP_UnpackURL(char *sURL, char *Server, u16 *Port, char *Service, Bool * strcpy(Server, ""); strcpy(Service, ""); *Port = *useTCP =0; - + if (!strchr(sURL, ':')) return GF_BAD_PARAM; //extract the schema @@ -54,12 +54,12 @@ GF_Err RTSP_UnpackURL(char *sURL, char *Server, u16 *Port, char *Service, Bool * found: schema[i] = 0; - if (stricmp(schema, "rtsp") && stricmp(schema, "rtspu")) return GF_URL_ERROR; + if (stricmp(schema, "rtsp") && stricmp(schema, "rtspu")) return GF_URL_ERROR; //check for user/pass - not allowed -/* - test = strstr(sURL, "@"); - if (test) return GF_NOT_SUPPORTED; -*/ + /* + test = strstr(sURL, "@"); + if (test) return GF_NOT_SUPPORTED; + */ test = strstr(sURL, "://"); if (!test) return GF_URL_ERROR; test += 3; @@ -115,7 +115,7 @@ GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort) GF_Err e; u16 Port; Bool UseTCP; - + if (!sURL) return NULL; e = RTSP_UnpackURL(sURL, server, &Port, service, &UseTCP); @@ -132,7 +132,7 @@ GF_RTSPSession *gf_rtsp_session_new(char *sURL, u16 DefaultPort) if (sess->Port == 80) { sess->ConnectionType = GF_SOCK_TYPE_TCP; sess->HasTunnel = 1; - } + } sess->Server = gf_strdup(server); sess->Service = gf_strdup(service); @@ -147,7 +147,7 @@ GF_EXPORT void gf_rtsp_reset_aggregation(GF_RTSPSession *sess) { if (!sess) return; - + gf_mx_p(sess->mx); if (sess->RTSP_State == GF_RTSP_STATE_WAIT_FOR_CONTROL) { strcpy(sess->RTSPLastRequest, "RESET"); @@ -190,7 +190,7 @@ void gf_rtsp_session_reset(GF_RTSPSession *sess, Bool ResetConnection) sess->http = NULL; } } - + sess->RTSP_State = GF_RTSP_STATE_INIT; // sess->CSeq = sess->NbPending = 0; sess->InterID = (u8) -1; @@ -224,7 +224,7 @@ u32 gf_rtsp_get_session_state(GF_RTSPSession *sess) { u32 state; if (!sess) return GF_RTSP_STATE_INVALIDATED; - + gf_mx_p(sess->mx); state = sess->RTSP_State; gf_mx_v(sess->mx); @@ -375,7 +375,7 @@ GF_Err gf_rtsp_set_deinterleave(GF_RTSPSession *sess) if (Size <= 4) return gf_rtsp_refill_buffer(sess); //break if we get RTSP response on the wire - if (!strncmp(buffer, "RTSP", 4)) + if (!strncmp(buffer, "RTSP", 4)) return GF_IP_NETWORK_EMPTY; //new packet @@ -414,7 +414,7 @@ GF_Err gf_rtsp_set_deinterleave(GF_RTSPSession *sess) sess->CurrentPos += Size; assert(sess->CurrentPos <= sess->CurrentSize); } - } + } /*end of packet*/ else if (sess->payloadSize - sess->pck_start <= Size) { // GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP over RTSP] Missed begining of packet (%d bytes) in stream %d\n", Size, sess->InterID)); @@ -465,7 +465,7 @@ GF_Err RTSP_ResetInterleaving(GF_RTSPSession *sess, Bool ResetChannels) sess->InterID = (u8) -1; if (ResetChannels) RemoveTCPChannels(sess); gf_mx_v(sess->mx); - + return GF_OK; } @@ -526,8 +526,8 @@ GF_Err gf_rtsp_register_interleave(GF_RTSPSession *sess, void *the_ch, u8 LowInt GF_EXPORT GF_Err gf_rtsp_set_interleave_callback(GF_RTSPSession *sess, - GF_Err (*SignalData)(GF_RTSPSession *sess, void *chan, char *buffer, u32 bufferSize, Bool IsRTCP) - ) + GF_Err (*SignalData)(GF_RTSPSession *sess, void *chan, char *buffer, u32 bufferSize, Bool IsRTCP) + ) { if (!sess) return GF_BAD_PARAM; @@ -582,7 +582,7 @@ void RTSP_GenerateHTTPCookie(GF_RTSPSession *sess) temp = (num >> (i * 4)) & 0x0f; sess->HTTP_Cookie[sess->CookieRadLen + i] = (u8) temp + sess->HTTP_Cookie[0]; } - sess->HTTP_Cookie[sess->CookieRadLen + i] = 0; + sess->HTTP_Cookie[sess->CookieRadLen + i] = 0; } @@ -606,16 +606,16 @@ GF_Err gf_rtsp_http_tunnel_start(GF_RTSPSession *sess, char *UserAgent) pos += sprintf(buffer + pos, "x-sessioncookie: %s\r\n", sess->HTTP_Cookie); pos += sprintf(buffer + pos, "Accept: application/x-rtsp-tunnelled\r\n" ); pos += sprintf(buffer + pos, "Pragma: no-cache\r\n" ); - pos += sprintf(buffer + pos, "Cache-Control: no-cache\r\n\r\n" ); - + pos += sprintf(buffer + pos, "Cache-Control: no-cache\r\n\r\n" ); + // send it! e = gf_sk_send_wait(sess->connection, buffer, (u32) strlen(buffer), HTTP_WAIT_SEC); if (e) return e; - + // 2. wait for "HTTP/1.0 200 OK" e = gf_sk_receive_wait(sess->connection, buffer, GF_RTSP_DEFAULT_BUFFER, 0, &size, HTTP_WAIT_SEC); if (e) return e; - + //get HTTP/1.0 200 OK if (strncmp(buffer, HTTP_RSP_OK, strlen(HTTP_RSP_OK))) return GF_REMOTE_SERVICE_ERROR; @@ -625,7 +625,7 @@ GF_Err gf_rtsp_http_tunnel_start(GF_RTSPSession *sess, char *UserAgent) if (!sess->http ) return GF_IP_NETWORK_FAILURE; /*mobileIP is enabled, bind first*/ - if (gf_sk_connect(sess->http, sess->Server, sess->Port, sess->MobileIP)) return GF_IP_CONNECTION_FAILURE; + if (gf_sk_connect(sess->http, sess->Server, sess->Port, sess->MobileIP)) return GF_IP_CONNECTION_FAILURE; memset(buffer, 0, GF_RTSP_DEFAULT_BUFFER); pos = 0; @@ -634,13 +634,13 @@ GF_Err gf_rtsp_http_tunnel_start(GF_RTSPSession *sess, char *UserAgent) pos += sprintf(buffer + pos, "x-sessioncookie: %s\r\n", sess->HTTP_Cookie); pos += sprintf(buffer + pos, "Accept: application/x-rtsp-tunnelled\r\n"); pos += sprintf(buffer + pos, "Pragma: no-cache\r\n"); - pos += sprintf(buffer + pos, "Cache-Control: no-cache\r\n"); + pos += sprintf(buffer + pos, "Cache-Control: no-cache\r\n"); pos += sprintf(buffer + pos, "Content-Length: 32767\r\n"); pos += sprintf(buffer + pos, "Expires: Sun. 9 Jan 1972 00:00:00 GMT\r\n\r\n"); - + // send it! e = gf_sk_send_wait(sess->http, buffer, (u32) strlen(buffer), HTTP_WAIT_SEC); - + return e; } @@ -661,8 +661,8 @@ GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener) char name[GF_MAX_IP_NAME_LEN]; if (!rtsp_listener) return NULL; - - + + e = gf_sk_accept(rtsp_listener, &new_conn); if (!new_conn || e) return NULL; @@ -681,7 +681,7 @@ GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener) gf_sk_del(new_conn); return NULL; } - + //OK create a new session GF_SAFEALLOC(sess, GF_RTSPSession); @@ -690,7 +690,7 @@ GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener) sess->ConnectionType = fam; gf_sk_get_host_name(name); sess->Server = gf_strdup(name); - + sess->TCPChannels = gf_list_new(); return sess; } diff --git a/src/ietf/sdp.c b/src/ietf/sdp.c index 3d53594..3473409 100644 --- a/src/ietf/sdp.c +++ b/src/ietf/sdp.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -275,7 +275,7 @@ void gf_sdp_media_del(GF_SDPMedia *media) gf_list_rem(media->RTPMaps, 0); } gf_list_del(media->RTPMaps); - + while (gf_list_count(media->Connections)) { conn = (GF_SDPConnection*)gf_list_get(media->Connections, 0); gf_list_rem(media->Connections, 0); @@ -360,7 +360,7 @@ void gf_sdp_info_reset(GF_SDPInfo *sdp) GF_X_Attribute *att; if (!sdp) return; - + while (gf_list_count(sdp->media_desc)) { media = (GF_SDPMedia*)gf_list_get(sdp->media_desc, 0); gf_list_rem(sdp->media_desc, 0); @@ -416,7 +416,7 @@ void gf_sdp_info_reset(GF_SDPInfo *sdp) GF_EXPORT void gf_sdp_info_del(GF_SDPInfo *sdp) -{ +{ if (!sdp) return; gf_sdp_info_reset(sdp); gf_list_del(sdp->media_desc); @@ -440,7 +440,7 @@ Bool SDP_IsDynamicPayload(GF_SDPMedia *media, char *payt) return 0; } -//translate h || m || d in sec. Fractions are not allowed with this writing +//translate h || m || d in sec. Fractions are not allowed with this writing s32 SDP_MakeSeconds(char *buf) { s32 sign; @@ -508,7 +508,7 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) sdp->o_session_id = gf_strdup(comp); pos = gf_token_get(LineBuf, pos, " \t\r\n", comp, 3000); sdp->o_version = gf_strdup(comp); - + pos = gf_token_get(LineBuf, pos, " \t\r\n", comp, 3000); sdp->o_net_type = gf_strdup(comp); @@ -541,12 +541,12 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) case 'c': //if at session level, only 1 is allowed for all SDP if (sdp->c_connection) break; - + conn = gf_sdp_conn_new(); pos = gf_token_get(LineBuf, 2, " \t\r\n", comp, 3000); conn->net_type = gf_strdup(comp); - + pos = gf_token_get(LineBuf, pos, " \t\r\n", comp, 3000); conn->add_type = gf_strdup(comp); @@ -568,9 +568,9 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) conn->add_count = atoi(comp); } } - if (!media) + if (!media) sdp->c_connection = conn; - else + else gf_list_add(media->Connections, conn); break; @@ -645,12 +645,12 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) break; case 'm': pos = gf_token_get(LineBuf, 2, " \t\r\n", comp, 3000); - if (strcmp(comp, "audio") - && strcmp(comp, "data") - && strcmp(comp, "control") - && strcmp(comp, "video") - && strcmp(comp, "text") - && strcmp(comp, "application")) { + if (strcmp(comp, "audio") + && strcmp(comp, "data") + && strcmp(comp, "control") + && strcmp(comp, "video") + && strcmp(comp, "text") + && strcmp(comp, "application")) { return GF_SERVICE_ERROR; } media = gf_sdp_media_new(); @@ -661,7 +661,7 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) else if (!strcmp(comp, "data")) media->Type = 4; else if (!strcmp(comp, "control")) media->Type = 5; else media->Type = 0; - //port numbers + //port numbers gf_token_get(LineBuf, pos, " ", comp, 3000); if (!strstr(comp, "/")) { pos = gf_token_get(LineBuf, pos, " \r\n", comp, 3000); @@ -683,7 +683,7 @@ GF_Err gf_sdp_info_parse(GF_SDPInfo *sdp, char *sdp_text, u32 text_size) break; } } - //finally rewrite the fmt_list for all media, and remove dynamic payloads + //finally rewrite the fmt_list for all media, and remove dynamic payloads //from the list i=0; while ((media = (GF_SDPMedia*)gf_list_enum(sdp->media_desc, &i))) { @@ -745,7 +745,7 @@ GF_Err gf_sdp_info_check(GF_SDPInfo *sdp) //normative fields //o= - if (!sdp->o_add_type || !sdp->o_address || !sdp->o_username || !sdp->o_session_id || !sdp->o_version) + if (!sdp->o_add_type || !sdp->o_address || !sdp->o_username || !sdp->o_session_id || !sdp->o_version) return GF_REMOTE_SERVICE_ERROR; //s= //commented for intermedia demos @@ -753,7 +753,7 @@ GF_Err gf_sdp_info_check(GF_SDPInfo *sdp) //t= // if () return GF_REMOTE_SERVICE_ERROR; //c= - if (sdp->c_connection) { + if (sdp->c_connection) { e = SDP_CheckConnection(sdp->c_connection); if (e) return e; //multiple addresses are only for media desc @@ -777,7 +777,7 @@ GF_Err gf_sdp_info_check(GF_SDPInfo *sdp) //too many connections specified if (HasGlobalConnection && gf_list_count(media->Connections)) return GF_REMOTE_SERVICE_ERROR; - //check all connections, and make sure we don't have multiple addresses + //check all connections, and make sure we don't have multiple addresses //and multiple ports at the same time count = gf_list_count(media->Connections); if (count>1 && HasSeveralPorts) return GF_REMOTE_SERVICE_ERROR; @@ -786,7 +786,7 @@ GF_Err gf_sdp_info_check(GF_SDPInfo *sdp) conn = (GF_SDPConnection*)gf_list_get(media->Connections, j); e = SDP_CheckConnection(conn); if (e) return e; - if ((conn->add_count >= 2) && HasSeveralPorts) return GF_REMOTE_SERVICE_ERROR; + if ((conn->add_count >= 2) && HasSeveralPorts) return GF_REMOTE_SERVICE_ERROR; } //RTPMaps. 0 is tolerated, but if some are specified check them j=0; @@ -821,7 +821,7 @@ GF_Err gf_sdp_info_check(GF_SDPInfo *sdp) if (str) { \ SDP_WRITE_ALLOC_STR_WITHOUT_CHECK(str, space); \ } \ - + #define SDP_WRITE_ALLOC_INT(d, spa, sig) \ if (sig < 0) { \ sprintf(temp, "%d", d); \ @@ -1134,7 +1134,7 @@ GF_Err gf_sdp_info_write(GF_SDPInfo *sdp, char **out_str_buf) SDP_WRITE_ALLOC_STR("a=quality:", 0); SDP_WRITE_ALLOC_INT(media->Quality, 0, 0); SDP_WRITE_ALLOC_STR("\r\n", 0); - } + } //the rest j=0; while ((att = (GF_X_Attribute*)gf_list_enum(media->Attributes, &j))) { @@ -1154,6 +1154,6 @@ GF_Err gf_sdp_info_write(GF_SDPInfo *sdp, char **out_str_buf) buf = (char *)gf_realloc(buf, pos); *out_str_buf = buf; return GF_OK; -} +} #endif /*GPAC_DISABLE_STREAMING*/ diff --git a/src/isomedia/avc_ext.c b/src/isomedia/avc_ext.c index cd0b263..cb21f70 100644 --- a/src/isomedia/avc_ext.c +++ b/src/isomedia/avc_ext.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -73,14 +73,15 @@ static void rewrite_nalus_list(GF_List *nalus, GF_BitStream *bs, Bool rewrite_st if (rewrite_start_codes) gf_bs_write_u32(bs, 1); else gf_bs_write_int(bs, sl->size, 8*nal_unit_size_field); gf_bs_write_data(bs, sl->data, sl->size); - } + } } -static GF_Err process_extractor(GF_ISOFile *file, u32 sampleNumber, u32 nal_size, u16 nal_hdr, u32 nal_unit_size_field, Bool is_hevc, Bool rewrite_ps, Bool rewrite_start_codes, GF_BitStream *src_bs, GF_BitStream *dst_bs, u32 extractor_mode) +static GF_Err process_extractor(GF_ISOFile *file, GF_MediaBox *mdia, u32 sampleNumber, u32 nal_size, u16 nal_hdr, u32 nal_unit_size_field, Bool is_hevc, Bool rewrite_ps, Bool rewrite_start_codes, GF_BitStream *src_bs, GF_BitStream *dst_bs, u32 extractor_mode) { GF_Err e; - u32 di, ref_track_ID, ref_track_num, data_offset, data_length, cur_extract_mode, ref_extract_mode, ref_nalu_size, nb_bytes_nalh; + u32 di, ref_track_index, ref_track_num, data_offset, data_length, cur_extract_mode, ref_extract_mode, ref_nalu_size, nb_bytes_nalh; + GF_TrackReferenceTypeBox *dpnd; GF_ISOSample *ref_samp; GF_BitStream *ref_bs; GF_TrackBox *ref_trak; @@ -93,13 +94,20 @@ static GF_Err process_extractor(GF_ISOFile *file, u32 sampleNumber, u32 nal_size switch (extractor_mode) { case 0: if (!is_hevc) gf_bs_read_int(src_bs, 24); //1 byte for HEVC , 3 bytes for AVC of NALUHeader in extractor - ref_track_ID = gf_bs_read_u8(src_bs); + ref_track_index = gf_bs_read_u8(src_bs); sample_offset = (s8) gf_bs_read_int(src_bs, 8); data_offset = gf_bs_read_int(src_bs, nal_unit_size_field*8); data_length = gf_bs_read_int(src_bs, nal_unit_size_field*8); - ref_track_num = gf_isom_get_track_by_id(file, ref_track_ID); - if (!ref_track_num) return GF_ISOM_INVALID_FILE; + Track_FindRef(mdia->mediaTrack, GF_4CC('s','c','a','l'), &dpnd); + ref_track_num = 0; + if (dpnd && (ref_track_index<=dpnd->trackIDCount)) + ref_track_num = gf_isom_get_track_by_id(file, dpnd->trackIDs[ref_track_index-1]); + + if (!ref_track_num) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("ISOBMF: Extractor target track is not present in file - skipping.\n")); + return GF_OK; + } cur_extract_mode = gf_isom_get_nalu_extract_mode(file, ref_track_num); @@ -116,7 +124,7 @@ static GF_Err process_extractor(GF_ISOFile *file, u32 sampleNumber, u32 nal_size //fixeme - we assume that the sampleNumber in the refered track is the same as this sample number //are there cases were this wouldn't be the case ? - if (sample_offset < -sample_offset) + if (sample_offset < -sample_offset) sample_offset = 0; e = Media_GetSample(ref_trak->Media, sampleNumber + sample_offset, &ref_samp, &di, 0, NULL); @@ -140,27 +148,29 @@ static GF_Err process_extractor(GF_ISOFile *file, u32 sampleNumber, u32 nal_size if (!data_length) data_length = ref_samp->dataLength - data_offset; - assert(ref_samp->dataLength - data_offset >= data_length); + if (ref_samp->dataLength - data_offset >= data_length) { - while (data_length && gf_bs_available(ref_bs)) { - ref_nalu_size = gf_bs_read_int(ref_bs, 8*nal_unit_size_field); - assert(ref_nalu_size <= data_length); - - if (ref_nalu_size > max_size) { - buffer = (char*) gf_realloc(buffer, sizeof(char) * ref_nalu_size ); - max_size = ref_nalu_size; - } - gf_bs_read_data(ref_bs, buffer, ref_nalu_size); + while (data_length && gf_bs_available(ref_bs)) { + ref_nalu_size = gf_bs_read_int(ref_bs, 8*nal_unit_size_field); + assert(ref_nalu_size <= data_length); - if (rewrite_start_codes) - gf_bs_write_u32(dst_bs, 1); - else - gf_bs_write_int(dst_bs, ref_nalu_size, 8*nal_unit_size_field); + if (ref_nalu_size > max_size) { + buffer = (char*) gf_realloc(buffer, sizeof(char) * ref_nalu_size ); + max_size = ref_nalu_size; + } + gf_bs_read_data(ref_bs, buffer, ref_nalu_size); - gf_bs_write_data(dst_bs, buffer, ref_nalu_size); - data_length -= ref_nalu_size + nal_unit_size_field; - } + if (rewrite_start_codes) + gf_bs_write_u32(dst_bs, 1); + else + gf_bs_write_int(dst_bs, ref_nalu_size, 8*nal_unit_size_field); + gf_bs_write_data(dst_bs, buffer, ref_nalu_size); + data_length -= ref_nalu_size + nal_unit_size_field; + } + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("ISOBMF: Extractor size is larger than refered sample size - skipping.\n")); + } gf_isom_sample_del(&ref_samp); ref_samp = NULL; gf_bs_del(ref_bs); @@ -175,7 +185,7 @@ static GF_Err process_extractor(GF_ISOFile *file, u32 sampleNumber, u32 nal_size case 2: buffer = (char*) gf_malloc( sizeof(char) * (nal_size - nb_bytes_nalh)); gf_bs_read_data(src_bs, buffer, nal_size - nb_bytes_nalh); - if (rewrite_start_codes) + if (rewrite_start_codes) gf_bs_write_u32(dst_bs, 1); else gf_bs_write_int(dst_bs, nal_size, 8*nal_unit_size_field); @@ -193,13 +203,13 @@ static u8 is_sample_idr(GF_ISOSample *sample, GF_MPEGVisualSampleEntryBox *entry Bool is_hevc = 0; u32 nalu_size_field = 0; GF_BitStream *bs; - if (entry->avc_config) nalu_size_field = entry->avc_config->config->nal_unit_size; - else if (entry->svc_config) nalu_size_field = entry->svc_config->config->nal_unit_size; - else if (entry->hevc_config) { + if (entry->avc_config && entry->avc_config->config) nalu_size_field = entry->avc_config->config->nal_unit_size; + else if (entry->svc_config && entry->svc_config->config) nalu_size_field = entry->svc_config->config->nal_unit_size; + else if (entry->hevc_config && entry->hevc_config->config) { nalu_size_field = entry->hevc_config->config->nal_unit_size; is_hevc = 1; } - else if (entry->shvc_config) { + else if (entry->shvc_config && entry->shvc_config->config) { nalu_size_field = entry->shvc_config->config->nal_unit_size; is_hevc = 1; } @@ -260,7 +270,7 @@ static u8 is_sample_idr(GF_ISOSample *sample, GF_MPEGVisualSampleEntryBox *entry return 0; } gf_bs_skip_bytes(bs, size - 2); - } + } } gf_bs_del(bs); return 0; @@ -304,7 +314,8 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 { Bool is_hevc = 0; //if only one sync given in the sample sync table, insert sps/pps/vps before cra/bla in hevc - Bool check_cra_bla = (mdia->information->sampleTable->SyncSample && mdia->information->sampleTable->SyncSample->nb_entries>1) ? 0 : 1; +// Bool check_cra_bla = (mdia->information->sampleTable->SyncSample && mdia->information->sampleTable->SyncSample->nb_entries>1) ? 0 : 1; + Bool check_cra_bla = 1; Bool insert_nalu_delim = 1; GF_Err e = GF_OK; GF_ISOSample *ref_samp; @@ -316,12 +327,15 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 u32 temporal_id = 0; char *buffer; GF_ISOFile *file = mdia->mediaTrack->moov->mov; + GF_TrackReferenceTypeBox *scal = NULL; + Track_FindRef(mdia->mediaTrack, GF_4CC('s','c','a','l'), &scal); src_bs = ref_bs = dst_bs = ps_bs = NULL; ref_samp = NULL; buffer = NULL; rewrite_ps = (mdia->mediaTrack->extractor_mode & GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG) ? 1 : 0; - if ( mdia->information->sampleTable->no_sync_found) { + + if (mdia->information->sampleTable->no_sync_found || (!sample->IsRAP && check_cra_bla) ) { sample->IsRAP = is_sample_idr(sample, entry); } if (!sample->IsRAP) @@ -336,7 +350,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 insert_vdrd_code = 0; //this is a compatible HEVC, don't insert VDRD, insert NALU delim - if (entry->shvc_config && entry->hevc_config) + if (entry->shvc_config && entry->hevc_config) insert_vdrd_code = 0; if (extractor_mode == GF_ISOM_NALU_EXTRACT_INSPECT) { @@ -357,7 +371,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 } /*otherwise do nothing*/ - else if (!rewrite_ps && !rewrite_start_codes) { + else if (!rewrite_ps && !rewrite_start_codes && !scal) { return GF_OK; } @@ -413,8 +427,6 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 //in inspect mode or single-layer mode just use the xPS from this layer if (extractor_mode == GF_ISOM_NALU_EXTRACT_DEFAULT) { u32 i; - GF_TrackReferenceTypeBox *scal = NULL; - Track_FindRef(mdia->mediaTrack, GF_4CC('s','c','a','l'), &scal); if (scal) { for (i=0; itrackIDCount; i++) { @@ -433,7 +445,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 if (is_hevc) { /*little optimization if we are not asked to start codes: copy over the sample*/ - if (!rewrite_start_codes && !entry->shvc_config) { + if (!rewrite_start_codes && !entry->shvc_config && !scal) { if (ps_bs) { u8 nal_type = (sample->data[nal_unit_size_field] & 0x7E) >> 1; //temp fix - if we detect xPS in the begining of the sample do NOT copy the ps bitstream @@ -464,7 +476,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 } /*little optimization if we are not asked to rewrite extractors or start codes: copy over the sample*/ - if (!entry->svc_config && !entry->shvc_config && !rewrite_start_codes && !rewrite_ps) { + if (!scal && !rewrite_start_codes && !rewrite_ps) { if (ps_bs) { gf_bs_transfer(dst_bs, ps_bs); @@ -494,7 +506,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 } else { nal_hdr = gf_bs_read_u8(src_bs); nal_type = nal_hdr & 0x1F; - } + } if (is_hevc) { if (ps_bs) { @@ -512,7 +524,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 switch (nal_type) { //extractor case 49: - e = process_extractor(file, sampleNumber, nal_size, nal_hdr, nal_unit_size_field, GF_TRUE, rewrite_ps, rewrite_start_codes, src_bs, dst_bs, extractor_mode); + e = process_extractor(file, mdia, sampleNumber, nal_size, nal_hdr, nal_unit_size_field, GF_TRUE, rewrite_ps, rewrite_start_codes, src_bs, dst_bs, extractor_mode); if (e) goto exit; break; @@ -543,7 +555,7 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 default: /*rewrite nal*/ gf_bs_read_data(src_bs, buffer, nal_size-2); - if (rewrite_start_codes) + if (rewrite_start_codes) gf_bs_write_u32(dst_bs, 1); else gf_bs_write_int(dst_bs, nal_size, 8*nal_unit_size_field); @@ -552,45 +564,45 @@ GF_Err gf_isom_nalu_sample_rewrite(GF_MediaBox *mdia, GF_ISOSample *sample, u32 gf_bs_write_data(dst_bs, buffer, nal_size-2); } #endif - + //done with HEVC continue; - } - + } + switch(nal_type) { - case GF_AVC_NALU_ACCESS_UNIT: - /*we already wrote this stuff*/ - gf_bs_skip_bytes(src_bs, nal_size-1); - continue; - //extractor - case 31: - e = process_extractor(file, sampleNumber, nal_size, nal_hdr, nal_unit_size_field, GF_FALSE, rewrite_ps, rewrite_start_codes, src_bs, dst_bs, extractor_mode); - if (e) goto exit; - break; + case GF_AVC_NALU_ACCESS_UNIT: + /*we already wrote this stuff*/ + gf_bs_skip_bytes(src_bs, nal_size-1); + continue; + //extractor + case 31: + e = process_extractor(file, mdia, sampleNumber, nal_size, nal_hdr, nal_unit_size_field, GF_FALSE, rewrite_ps, rewrite_start_codes, src_bs, dst_bs, extractor_mode); + if (e) goto exit; + break; // case GF_AVC_NALU_SEI: - case GF_AVC_NALU_SEQ_PARAM: - case GF_AVC_NALU_PIC_PARAM: - case GF_AVC_NALU_SEQ_PARAM_EXT: - case GF_AVC_NALU_SVC_SUBSEQ_PARAM: - // we will rewrite the sps/pps if and only if there is no sps/pps in bistream - if (ps_bs) { - gf_bs_del(ps_bs); - ps_bs = NULL; - } - default: - if (ps_bs) { - gf_bs_transfer(dst_bs, ps_bs); - gf_bs_del(ps_bs); - ps_bs = NULL; - } - gf_bs_read_data(src_bs, buffer, nal_size-1); - if (rewrite_start_codes) - gf_bs_write_u32(dst_bs, 1); - else - gf_bs_write_int(dst_bs, nal_size, 8*nal_unit_size_field); + case GF_AVC_NALU_SEQ_PARAM: + case GF_AVC_NALU_PIC_PARAM: + case GF_AVC_NALU_SEQ_PARAM_EXT: + case GF_AVC_NALU_SVC_SUBSEQ_PARAM: + // we will rewrite the sps/pps if and only if there is no sps/pps in bistream + if (ps_bs) { + gf_bs_del(ps_bs); + ps_bs = NULL; + } + default: + if (ps_bs) { + gf_bs_transfer(dst_bs, ps_bs); + gf_bs_del(ps_bs); + ps_bs = NULL; + } + gf_bs_read_data(src_bs, buffer, nal_size-1); + if (rewrite_start_codes) + gf_bs_write_u32(dst_bs, 1); + else + gf_bs_write_int(dst_bs, nal_size, 8*nal_unit_size_field); - gf_bs_write_u8(dst_bs, nal_hdr); - gf_bs_write_data(dst_bs, buffer, nal_size-1); + gf_bs_write_u8(dst_bs, nal_hdr); + gf_bs_write_data(dst_bs, buffer, nal_size-1); } } @@ -620,7 +632,7 @@ GF_HEVCConfig *HEVC_DuplicateConfig(GF_HEVCConfig *cfg) u32 data_size; GF_HEVCConfig *new_cfg; GF_BitStream *bs; - + if (!cfg) return NULL; bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); gf_odf_hevc_cfg_write_bs(cfg, bs); @@ -682,7 +694,7 @@ static GF_AVCConfig *AVC_DuplicateConfig(GF_AVCConfig *cfg) gf_list_add(cfg_new->sequenceParameterSetExtensions, p2); } } - return cfg_new; + return cfg_new; } static void merge_avc_config(GF_AVCConfig *dst_cfg, GF_AVCConfig *src_cfg) @@ -726,7 +738,7 @@ void merge_hevc_config(GF_HEVCConfig *dst_cfg, GF_HEVCConfig *src_cfg, Bool forc while (gf_list_count(ar->nalus)) { GF_AVCConfigSlot *p = (GF_AVCConfigSlot*)gf_list_get(ar->nalus, 0); gf_list_rem(ar->nalus, 0); - if (force_insert) + if (force_insert) gf_list_insert(ar_h->nalus, p, 0); else gf_list_add(ar_h->nalus, p); @@ -767,16 +779,16 @@ void merge_all_config(GF_AVCConfig *avc_cfg, GF_HEVCConfig *hevc_cfg, GF_MediaBo if (!an_entry) continue; - if (avc_cfg && an_entry->svc_config && an_entry->svc_config->config) + if (avc_cfg && an_entry->svc_config && an_entry->svc_config->config) merge_avc_config(avc_cfg, an_entry->svc_config->config); - - if (avc_cfg && an_entry->avc_config && an_entry->avc_config->config) + + if (avc_cfg && an_entry->avc_config && an_entry->avc_config->config) merge_avc_config(avc_cfg, an_entry->avc_config->config); - if (hevc_cfg && an_entry->shvc_config && an_entry->shvc_config->config) + if (hevc_cfg && an_entry->shvc_config && an_entry->shvc_config->config) merge_hevc_config(hevc_cfg, an_entry->shvc_config->config, GF_TRUE); - if (hevc_cfg && an_entry->hevc_config && an_entry->hevc_config->config) + if (hevc_cfg && an_entry->hevc_config && an_entry->hevc_config->config) merge_hevc_config(hevc_cfg, an_entry->hevc_config->config, GF_TRUE); } @@ -801,13 +813,13 @@ void AVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *avc, GF_MediaBox *md avc->emul_esd->decoderConfig->maxBitrate = avc->bitrate->maxBitrate; } if (avc->descr) { - u32 i=0; + u32 i=0; GF_Descriptor *desc,*clone; i=0; while ((desc = (GF_Descriptor *)gf_list_enum(avc->descr->descriptors, &i))) { clone = NULL; gf_odf_desc_copy(desc, &clone); - if (gf_odf_desc_add_desc((GF_Descriptor *)avc->emul_esd, clone) != GF_OK) + if (gf_odf_desc_add_desc((GF_Descriptor *)avc->emul_esd, clone) != GF_OK) gf_odf_desc_del(clone); } } @@ -844,7 +856,7 @@ void HEVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *hevc, GF_MediaBox * hevc->emul_esd = gf_odf_desc_esd_new(2); hevc->emul_esd->decoderConfig->streamType = GF_STREAM_VISUAL; hevc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_HEVC; - if (hevc->shvc_config && !hevc->hevc_config) + if (hevc->shvc_config && !hevc->hevc_config) hevc->emul_esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_SHVC; if (hevc->bitrate) { @@ -853,13 +865,13 @@ void HEVC_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *hevc, GF_MediaBox * hevc->emul_esd->decoderConfig->maxBitrate = hevc->bitrate->maxBitrate; } if (hevc->descr) { - u32 i=0; + u32 i=0; GF_Descriptor *desc,*clone; i=0; while ((desc = (GF_Descriptor *)gf_list_enum(hevc->descr->descriptors, &i))) { clone = NULL; gf_odf_desc_copy(desc, &clone); - if (gf_odf_desc_add_desc((GF_Descriptor *)hevc->emul_esd, clone) != GF_OK) + if (gf_odf_desc_add_desc((GF_Descriptor *)hevc->emul_esd, clone) != GF_OK) gf_odf_desc_del(clone); } } @@ -896,15 +908,24 @@ GF_Err AVC_HEVC_UpdateESD(GF_MPEGVisualSampleEntryBox *avc, GF_ESD *esd) avc->bitrate->bufferSizeDB = esd->decoderConfig->bufferSizeDB; if (gf_list_count(esd->IPIDataSet) - || gf_list_count(esd->IPMPDescriptorPointers) - || esd->langDesc - || gf_list_count(esd->extensionDescriptors) - || esd->ipiPtr || esd->qos || esd->RegDescriptor) { + || gf_list_count(esd->IPMPDescriptorPointers) + || esd->langDesc + || gf_list_count(esd->extensionDescriptors) + || esd->ipiPtr || esd->qos || esd->RegDescriptor) { avc->descr = (GF_MPEG4ExtensionDescriptorsBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_M4DS); - if (esd->RegDescriptor) { gf_list_add(avc->descr->descriptors, esd->RegDescriptor); esd->RegDescriptor = NULL; } - if (esd->qos) { gf_list_add(avc->descr->descriptors, esd->qos); esd->qos = NULL; } - if (esd->ipiPtr) { gf_list_add(avc->descr->descriptors, esd->ipiPtr); esd->ipiPtr= NULL; } + if (esd->RegDescriptor) { + gf_list_add(avc->descr->descriptors, esd->RegDescriptor); + esd->RegDescriptor = NULL; + } + if (esd->qos) { + gf_list_add(avc->descr->descriptors, esd->qos); + esd->qos = NULL; + } + if (esd->ipiPtr) { + gf_list_add(avc->descr->descriptors, esd->ipiPtr); + esd->ipiPtr= NULL; + } while (gf_list_count(esd->IPIDataSet)) { GF_Descriptor *desc = (GF_Descriptor *)gf_list_get(esd->IPIDataSet, 0); @@ -964,7 +985,7 @@ GF_Err gf_isom_avc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfi e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !cfg) return GF_BAD_PARAM; @@ -1044,7 +1065,7 @@ static GF_Err gf_isom_avc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber break; /*AVCC removal and switch to avc3*/ case 3: - if (!entry->avc_config || !entry->avc_config->config) + if (!entry->avc_config || !entry->avc_config->config) return GF_BAD_PARAM; if (entry->svc_config) { @@ -1117,9 +1138,9 @@ GF_Err gf_isom_svc_config_del(GF_ISOFile *the_file, u32 trackNumber, u32 Descrip } if (entry->svc_config) { - gf_isom_box_del((GF_Box*)entry->svc_config); - entry->svc_config = NULL; - } + gf_isom_box_del((GF_Box*)entry->svc_config); + entry->svc_config = NULL; + } AVC_RewriteESDescriptor(entry); return GF_OK; } @@ -1146,6 +1167,7 @@ GF_Err gf_isom_set_ipod_compatible(GF_ISOFile *the_file, u32 trackNumber) case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_HVC1: case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_OK; @@ -1166,7 +1188,7 @@ GF_Err gf_isom_svc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfi e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !cfg) return GF_BAD_PARAM; @@ -1192,6 +1214,7 @@ GF_Err gf_isom_svc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfi return e; } +GF_EXPORT GF_Err gf_isom_hevc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_HEVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex) { GF_TrackBox *trak; @@ -1201,7 +1224,7 @@ GF_Err gf_isom_hevc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_HEVCCon e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !cfg) return GF_BAD_PARAM; @@ -1227,6 +1250,15 @@ GF_Err gf_isom_hevc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_HEVCCon return e; } +enum +{ + GF_ISOM_HVCC_UPDATE = 0, + GF_ISOM_HVCC_SET_INBAND, + GF_ISOM_HVCC_SET_TILE, + GF_ISOM_HVCC_SET_SHVC, + GF_ISOM_HVCC_SET_SHVC_REM_HEVC, +} HevcConfigUpdateType; + static GF_Err gf_isom_hevc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg, u32 operand_type) { @@ -1248,26 +1280,34 @@ GF_Err gf_isom_hevc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber, u32 case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_BAD_PARAM; } - if (operand_type<=1) { + + if (operand_type == GF_ISOM_HVCC_SET_TILE) { + if (!entry->hevc_config) entry->hevc_config = (GF_HEVCConfigurationBox*)gf_isom_box_new(GF_ISOM_BOX_TYPE_HVCC); + if (entry->hevc_config->config) gf_odf_hevc_cfg_del(entry->hevc_config->config); + entry->hevc_config->config = NULL; + entry->type = GF_ISOM_BOX_TYPE_HVT1; + } else if (operand_type < GF_ISOM_HVCC_SET_SHVC) { if (!entry->hevc_config) entry->hevc_config = (GF_HEVCConfigurationBox*)gf_isom_box_new(GF_ISOM_BOX_TYPE_HVCC); if (cfg) { if (entry->hevc_config->config) gf_odf_hevc_cfg_del(entry->hevc_config->config); entry->hevc_config->config = HEVC_DuplicateConfig(cfg); - } else { - operand_type=1; + } else if (operand_type != GF_ISOM_HVCC_SET_TILE) { + operand_type=GF_ISOM_HVCC_SET_INBAND; } array_incomplete = 0; for (i=0; ihevc_config->config->param_array); i++) { GF_HEVCParamArray *ar = gf_list_get(entry->hevc_config->config->param_array, i); - + /*we want to force hev1*/ - if (operand_type==1) ar->array_completeness = 0; + if (operand_type==GF_ISOM_HVCC_SET_INBAND) + ar->array_completeness = 0; if (!ar->array_completeness) { array_incomplete = 1; @@ -1289,7 +1329,7 @@ GF_Err gf_isom_hevc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber, u32 } else { /*SVCC replacement*/ - if (operand_type==2) { + if (operand_type==GF_ISOM_HVCC_SET_SHVC) { if (!cfg) return GF_BAD_PARAM; if (!entry->shvc_config) entry->shvc_config = (GF_HEVCConfigurationBox*)gf_isom_box_new(GF_ISOM_BOX_TYPE_SHCC); if (entry->shvc_config->config) gf_odf_hevc_cfg_del(entry->shvc_config->config); @@ -1297,7 +1337,7 @@ GF_Err gf_isom_hevc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber, u32 entry->type = GF_ISOM_BOX_TYPE_HVC1; } /*SVCC replacement and HEVC removal*/ - else if (operand_type==3) { + else if (operand_type==GF_ISOM_HVCC_SET_SHVC_REM_HEVC) { if (!cfg) { if (entry->shvc_config) { gf_isom_box_del((GF_Box*)entry->shvc_config); @@ -1325,19 +1365,25 @@ GF_Err gf_isom_hevc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber, u32 GF_EXPORT GF_Err gf_isom_hevc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg) { - return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, 0);; + return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, GF_ISOM_HVCC_UPDATE); } GF_EXPORT GF_Err gf_isom_hevc_set_inband_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex) { - return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, NULL, 1); + return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, NULL, GF_ISOM_HVCC_SET_INBAND); +} + +GF_EXPORT +GF_Err gf_isom_hevc_set_tile_config(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg) +{ + return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, GF_ISOM_HVCC_SET_TILE); } -GF_Err gf_isom_shvc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg, Bool is_add) +GF_Err gf_isom_shvc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_HEVCConfig *cfg, Bool is_additional) { if (cfg) cfg->is_shvc = 1; - return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, is_add ? 2 : 3); + return gf_isom_hevc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, is_additional ? GF_ISOM_HVCC_SET_SHVC : GF_ISOM_HVCC_SET_SHVC_REM_HEVC); } #endif /*GPAC_DISABLE_ISOM_WRITE*/ @@ -1401,7 +1447,7 @@ u32 gf_isom_get_avc_svc_type(GF_ISOFile *the_file, u32 trackNumber, u32 Descript if (trak->Media->handler->handlerType != GF_ISOM_MEDIA_VISUAL) return GF_ISOM_AVCTYPE_NONE; entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, DescriptionIndex-1); type = entry->type; - + if (type == GF_ISOM_BOX_TYPE_ENCV) { GF_ProtectionInfoBox *sinf = (GF_ProtectionInfoBox *) gf_list_get(entry->protections, 0); if (sinf && sinf->original_format) type = sinf->original_format->data_format; @@ -1434,7 +1480,7 @@ u32 gf_isom_get_hevc_shvc_type(GF_ISOFile *the_file, u32 trackNumber, u32 Descri if (trak->Media->handler->handlerType != GF_ISOM_MEDIA_VISUAL) return GF_ISOM_HEVCTYPE_NONE; entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, DescriptionIndex-1); type = entry->type; - + if (type == GF_ISOM_BOX_TYPE_ENCV) { GF_ProtectionInfoBox *sinf = (GF_ProtectionInfoBox *) gf_list_get(entry->protections, 0); if (sinf && sinf->original_format) type = sinf->original_format->data_format; @@ -1447,6 +1493,7 @@ u32 gf_isom_get_hevc_shvc_type(GF_ISOFile *the_file, u32 trackNumber, u32 Descri case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_ISOM_HEVCTYPE_NONE; @@ -1778,11 +1825,11 @@ GF_Err avcc_Size(GF_Box *s) } ptr->size += 7; count = gf_list_count(ptr->config->sequenceParameterSets); - for (i=0; isize += 2 + ((GF_AVCConfigSlot *)gf_list_get(ptr->config->sequenceParameterSets, i))->size; count = gf_list_count(ptr->config->pictureParameterSets); - for (i=0; isize += 2 + ((GF_AVCConfigSlot *)gf_list_get(ptr->config->pictureParameterSets, i))->size; if (ptr->type==GF_ISOM_BOX_TYPE_AVCC) { @@ -1793,7 +1840,7 @@ GF_Err avcc_Size(GF_Box *s) case 144: ptr->size += 4; count = ptr->config->sequenceParameterSetExtensions ?gf_list_count(ptr->config->sequenceParameterSetExtensions) : 0; - for (i=0; isize += 2 + ((GF_AVCConfigSlot *)gf_list_get(ptr->config->sequenceParameterSetExtensions, i))->size; break; } @@ -1817,7 +1864,7 @@ GF_Err hvcc_Read(GF_Box *s, GF_BitStream *bs) GF_HEVCConfigurationBox *ptr = (GF_HEVCConfigurationBox *)s; if (ptr->config) gf_odf_hevc_cfg_del(ptr->config); - + pos = gf_bs_get_position(bs); ptr->config = gf_odf_hevc_cfg_read_bs(bs, (s->type == GF_ISOM_BOX_TYPE_HVCC) ? 0 : 1); pos = gf_bs_get_position(bs) - pos ; diff --git a/src/isomedia/box_code_3gpp.c b/src/isomedia/box_code_3gpp.c index c773bf4..0512039 100644 --- a/src/isomedia/box_code_3gpp.c +++ b/src/isomedia/box_code_3gpp.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -175,7 +175,7 @@ GF_Err gppc_Read(GF_Box *s, GF_BitStream *bs) ptr->cfg.AMR_mode_change_period = gf_bs_read_u8(bs); ptr->cfg.frames_per_sample = gf_bs_read_u8(bs); break; - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: ptr->cfg.frames_per_sample = gf_bs_read_u8(bs); @@ -253,7 +253,7 @@ void ftab_del(GF_Box *s) GF_FontTableBox *ptr = (GF_FontTableBox *)s; if (ptr->fonts) { u32 i; - for (i=0; ientry_count; i++) + for (i=0; ientry_count; i++) if (ptr->fonts[i].fontName) gf_free(ptr->fonts[i].fontName); gf_free(ptr->fonts); } @@ -342,7 +342,7 @@ GF_Box *tx3g_New() void tx3g_del(GF_Box *s) { GF_Tx3gSampleEntryBox *ptr = (GF_Tx3gSampleEntryBox*)s; - + gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s); if (ptr->font_table) @@ -358,9 +358,12 @@ static u32 gpp_read_rgba(GF_BitStream *bs) g = gf_bs_read_u8(bs); b = gf_bs_read_u8(bs); a = gf_bs_read_u8(bs); - col = a; col<<=8; - col |= r; col<<=8; - col |= g; col<<=8; + col = a; + col<<=8; + col |= r; + col<<=8; + col |= g; + col<<=8; col |= b; return col; } @@ -1015,7 +1018,7 @@ GF_Err tsel_Read(GF_Box *s,GF_BitStream *bs) ptr->attributeListCount = (u32)ptr->size/4; ptr->attributeList = gf_malloc(ptr->attributeListCount*sizeof(u32)); if (ptr->attributeList == NULL) return GF_OUT_OF_MEM; - + for (i=0; i< ptr->attributeListCount; i++) { ptr->attributeList[i] = gf_bs_read_u32(bs); } @@ -1037,7 +1040,7 @@ GF_Err tsel_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_TrackSelectionBox *ptr = (GF_TrackSelectionBox *) s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs,ptr->switchGroup); @@ -1045,7 +1048,7 @@ GF_Err tsel_Write(GF_Box *s, GF_BitStream *bs) for (i = 0; i < ptr->attributeListCount; i++ ) { gf_bs_write_u32(bs, ptr->attributeList[i]); } - + return GF_OK; } @@ -1091,7 +1094,7 @@ GF_Err dimC_Read(GF_Box *s, GF_BitStream *bs) p->streamType = gf_bs_read_int(bs, 1); p->containsRedundant = gf_bs_read_int(bs, 2); s->size -= 3; - + i=0; str[0]=0; while (1) { @@ -1220,15 +1223,15 @@ static GF_Err dims_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_DIMC: if (ptr->config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->config = (GF_DIMSSceneConfigBox*)a; + ptr->config = (GF_DIMSSceneConfigBox*)a; break; case GF_ISOM_BOX_TYPE_DIST: if (ptr->scripts) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->scripts = (GF_DIMSScriptTypesBox*)a; + ptr->scripts = (GF_DIMSScriptTypesBox*)a; break; case GF_ISOM_BOX_TYPE_BTRT: if (ptr->bitrate) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->bitrate = (GF_MPEG4BitRateBox*)a; + ptr->bitrate = (GF_MPEG4BitRateBox*)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); @@ -1276,19 +1279,19 @@ GF_Err dims_Size(GF_Box *s) GF_DIMSSampleEntryBox *p = (GF_DIMSSampleEntryBox *)s; if (e) return e; s->size += 8; - + if (p->config) { - e = gf_isom_box_size((GF_Box *) p->config); + e = gf_isom_box_size((GF_Box *) p->config); if (e) return e; p->size += p->config->size; } if (p->bitrate) { - e = gf_isom_box_size((GF_Box *) p->bitrate); + e = gf_isom_box_size((GF_Box *) p->bitrate); if (e) return e; p->size += p->bitrate->size; } if (p->scripts) { - e = gf_isom_box_size((GF_Box *) p->scripts); + e = gf_isom_box_size((GF_Box *) p->scripts); if (e) return e; p->size += p->scripts->size; } diff --git a/src/isomedia/box_code_adobe.c b/src/isomedia/box_code_adobe.c index 0aab4af..3b5db45 100644 --- a/src/isomedia/box_code_adobe.c +++ b/src/isomedia/box_code_adobe.c @@ -13,15 +13,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -101,7 +101,7 @@ GF_Err abst_Read(GF_Box *s, GF_BitStream *bs) } if (i) ptr->movie_identifier = gf_strdup(tmp_str); - + ptr->server_entry_count = gf_bs_read_u8(bs); for (i=0; iserver_entry_count; i++) { int j=0; @@ -115,7 +115,7 @@ GF_Err abst_Read(GF_Box *s, GF_BitStream *bs) } gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i); } - + ptr->quality_entry_count = gf_bs_read_u8(bs); for (i=0; iquality_entry_count; i++) { int j=0; @@ -153,7 +153,7 @@ GF_Err abst_Read(GF_Box *s, GF_BitStream *bs) } if (i) ptr->meta_data = gf_strdup(tmp_str); - + ptr->segment_run_table_count = gf_bs_read_u8(bs); for (i=0; isegment_run_table_count; i++) { GF_AdobeSegmentRunTableBox *asrt; @@ -161,10 +161,10 @@ GF_Err abst_Read(GF_Box *s, GF_BitStream *bs) if (e) return e; gf_list_insert(ptr->segment_run_table_entries, asrt, i); } - + ptr->fragment_run_table_count = gf_bs_read_u8(bs); for (i=0; ifragment_run_table_count; i++) { - GF_AdobeFragmentRunTableBox *afrt; + GF_AdobeFragmentRunTableBox *afrt; e = gf_isom_parse_box((GF_Box **)&afrt, bs); if (e) return e; gf_list_insert(ptr->fragment_run_table_entries, afrt, i); @@ -252,25 +252,25 @@ GF_Err abst_Size(GF_Box *s) GF_Err e; int i; GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s; - + e = gf_isom_full_box_get_size(s); if (e) return e; s->size += 25 - + (ptr->movie_identifier ? (strlen(ptr->movie_identifier) + 1) : 1) - + 1; + + (ptr->movie_identifier ? (strlen(ptr->movie_identifier) + 1) : 1) + + 1; for (i=0; iserver_entry_count; i++) - s->size += strlen(gf_list_get(ptr->server_entry_table, i)) + 1; + s->size += strlen(gf_list_get(ptr->server_entry_table, i)) + 1; s->size += 1; for (i=0; iquality_entry_count; i++) - s->size += strlen(gf_list_get(ptr->quality_entry_table, i)) + 1; + s->size += strlen(gf_list_get(ptr->quality_entry_table, i)) + 1; s->size += (ptr->drm_data ? (strlen(ptr->drm_data) + 1) : 1) - + (ptr->meta_data ? (strlen(ptr->meta_data) + 1) : 1) - + 1; + + (ptr->meta_data ? (strlen(ptr->meta_data) + 1) : 1) + + 1; for (i=0; isegment_run_table_count; i++) { GF_Box *box = (GF_Box *)gf_list_get(ptr->segment_run_table_entries, i); @@ -278,7 +278,7 @@ GF_Err abst_Size(GF_Box *s) if (e) return e; s->size += box->size; } - + s->size += 1; for (i=0; ifragment_run_table_count; i++) { GF_Box *box = (GF_Box *)gf_list_get(ptr->fragment_run_table_entries, i); @@ -355,7 +355,7 @@ GF_Err afra_Read(GF_Box *s, GF_BitStream *bs) if (ptr->long_offsets) { ae->afra_offset = gf_bs_read_u64(bs); ae->offset_from_afra = gf_bs_read_u64(bs); - }else { + } else { ae->afra_offset = gf_bs_read_u32(bs); ae->offset_from_afra = gf_bs_read_u32(bs); } @@ -437,8 +437,8 @@ GF_Err afra_Size(GF_Box *s) if (e) return e; s->size += 9 - + ptr->entry_count * (ptr->long_offsets ? 16 : 12) - + (ptr->global_entries ? 4 + ptr->global_entry_count * (4 + (ptr->long_offsets ? 16 : 8) + (ptr->long_ids ? 8 : 4)) : 0); + + ptr->entry_count * (ptr->long_offsets ? 16 : 12) + + (ptr->global_entries ? 4 + ptr->global_entry_count * (4 + (ptr->long_offsets ? 16 : 8) + (ptr->long_ids ? 8 : 4)) : 0); return GF_OK; } diff --git a/src/isomedia/box_code_apple.c b/src/isomedia/box_code_apple.c index a2b2514..4c72598 100644 --- a/src/isomedia/box_code_apple.c +++ b/src/isomedia/box_code_apple.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2006-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -82,7 +82,7 @@ GF_Err ilst_Size(GF_Box *s) { GF_Err e; // GF_ItemListBox *ptr = (GF_ItemListBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; @@ -139,7 +139,7 @@ GF_Box *ListItem_New(u32 type) tmp->data = (GF_DataBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_DATA); - if (tmp->data == NULL){ + if (tmp->data == NULL) { gf_free(tmp); return NULL; } @@ -215,7 +215,7 @@ GF_Err data_Read(GF_Box *s,GF_BitStream *bs) ptr->data[ptr->dataSize] = 0; gf_bs_read_data(bs, ptr->data, ptr->dataSize); } - + return GF_OK; } @@ -238,7 +238,7 @@ GF_Err data_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_int(bs, ptr->reserved, 32); - if(ptr->data != NULL && ptr->dataSize > 0){ + if(ptr->data != NULL && ptr->dataSize > 0) { gf_bs_write_data(bs, ptr->data, ptr->dataSize); } return GF_OK; @@ -251,7 +251,7 @@ GF_Err data_Size(GF_Box *s) e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 4; - if(ptr->data != NULL && ptr->dataSize > 0){ + if(ptr->data != NULL && ptr->dataSize > 0) { ptr->size += ptr->dataSize; } return GF_OK; @@ -271,7 +271,7 @@ GF_MetaBox *gf_isom_apple_get_meta_extensions(GF_ISOFile *mov) map = udta_getEntry(mov->moov->udta, GF_ISOM_BOX_TYPE_META, NULL); if (!map) return NULL; - for(i = 0; i < gf_list_count(map->other_boxes); i++){ + for(i = 0; i < gf_list_count(map->other_boxes); i++) { meta = (GF_MetaBox*)gf_list_get(map->other_boxes, i); if(meta != NULL && meta->handler != NULL && meta->handler->handlerType == GF_ISOM_HANDLER_TYPE_MDIR) return meta; @@ -290,14 +290,14 @@ GF_MetaBox *gf_isom_apple_create_meta_extensions(GF_ISOFile *mov) if (!mov || !mov->moov) return NULL; - if (!mov->moov->udta){ + if (!mov->moov->udta) { e = moov_AddBox((GF_Box*)mov->moov, gf_isom_box_new(GF_ISOM_BOX_TYPE_UDTA)); if (e) return NULL; } map = udta_getEntry(mov->moov->udta, GF_ISOM_BOX_TYPE_META, NULL); - if (map){ - for(i = 0; i < gf_list_count(map->other_boxes); i++){ + if (map) { + for(i = 0; i < gf_list_count(map->other_boxes); i++) { meta = (GF_MetaBox*)gf_list_get(map->other_boxes, i); if(meta != NULL && meta->handler != NULL && meta->handler->handlerType == GF_ISOM_HANDLER_TYPE_MDIR) return meta; @@ -306,9 +306,9 @@ GF_MetaBox *gf_isom_apple_create_meta_extensions(GF_ISOFile *mov) meta = (GF_MetaBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_META); - if(meta != NULL){ + if(meta != NULL) { meta->handler = (GF_HandlerBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_HDLR); - if(meta->handler == NULL){ + if(meta->handler == NULL) { gf_isom_box_del((GF_Box *)meta); return NULL; } diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c index 0cc2863..4c3ddb0 100644 --- a/src/isomedia/box_code_base.c +++ b/src/isomedia/box_code_base.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -57,7 +57,7 @@ GF_Err co64_Read(GF_Box *s,GF_BitStream *bs) GF_Box *co64_New() { - ISOM_DECL_BOX_ALLOC(GF_ChunkLargeOffsetBox, GF_ISOM_BOX_TYPE_CO64); + ISOM_DECL_BOX_ALLOC(GF_ChunkLargeOffsetBox, GF_ISOM_BOX_TYPE_CO64); gf_isom_full_box_init((GF_Box *)tmp); return (GF_Box *)tmp; } @@ -70,7 +70,7 @@ GF_Err co64_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_ChunkLargeOffsetBox *ptr = (GF_ChunkLargeOffsetBox *) s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->nb_entries); @@ -107,7 +107,7 @@ GF_Box *chpl_New() ISOM_DECL_BOX_ALLOC(GF_ChapterListBox, GF_ISOM_BOX_TYPE_CHPL); tmp->list = gf_list_new(); gf_isom_full_box_init((GF_Box *)tmp); - tmp->version = 1; + tmp->version = 1; return (GF_Box *)tmp; } @@ -153,7 +153,7 @@ GF_Err chpl_Read(GF_Box *s,GF_BitStream *bs) ce->name = gf_strdup(""); } - for (i=0;ilist, i); if (ace->start_time >= ce->start_time) { gf_list_insert(ptr->list, ce, i); @@ -186,7 +186,8 @@ GF_Err chpl_Write(GF_Box *s, GF_BitStream *bs) GF_ChapterEntry *ce = (GF_ChapterEntry *)gf_list_get(ptr->list, i); gf_bs_write_u64(bs, ce->start_time); if (ce->name) { - len = (u32) strlen(ce->name); if (len>255) len = 255; + len = (u32) strlen(ce->name); + if (len>255) len = 255; gf_bs_write_u8(bs, len); gf_bs_write_data(bs, ce->name, len); } else { @@ -313,7 +314,7 @@ GF_Err ctts_Read(GF_Box *s, GF_BitStream *bs) u32 i; u32 sampleCount; GF_CompositionOffsetBox *ptr = (GF_CompositionOffsetBox *)s; - + e = gf_isom_full_box_read(s, bs); if (e) return e; ptr->nb_entries = gf_bs_read_u32(bs); @@ -352,7 +353,7 @@ GF_Err ctts_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_CompositionOffsetBox *ptr = (GF_CompositionOffsetBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->nb_entries); @@ -432,7 +433,7 @@ GF_Err cslg_Size(GF_Box *s) { GF_Err e; GF_CompositionToDecodeBox *ptr = (GF_CompositionToDecodeBox *)s; - + e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 20; @@ -483,7 +484,7 @@ GF_Err url_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_full_box_write(s, bs); if (e) return e; //the flag set indicates we have a string (WE HAVE TO for URLs) - if ( !(ptr->flags & 1)) { + if ( !(ptr->flags & 1)) { if (ptr->location) { gf_bs_write_data(bs, ptr->location, (u32)strlen(ptr->location) + 1); } @@ -495,7 +496,7 @@ GF_Err url_Size(GF_Box *s) { GF_Err e; GF_DataEntryURLBox *ptr = (GF_DataEntryURLBox *)s; - + e = gf_isom_full_box_get_size(s); if (e) return e; if ( !(ptr->flags & 1)) { @@ -586,7 +587,7 @@ GF_Err urn_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_full_box_write(s, bs); if (e) return e; //the flag set indicates we have a string (WE HAVE TO for URLs) - if ( !(ptr->flags & 1)) { + if ( !(ptr->flags & 1)) { //to check, the spec says: First name, then location if (ptr->nameURN) { gf_bs_write_data(bs, ptr->nameURN, (u32)strlen(ptr->nameURN) + 1); @@ -656,7 +657,7 @@ GF_Err defa_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_box_write_header(s, bs); if (e) return e; - if (ptr->data) { + if (ptr->data) { gf_bs_write_data(bs, ptr->data, ptr->dataSize); } return GF_OK; @@ -716,7 +717,7 @@ GF_Err uuid_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_box_write_header(s, bs); if (e) return e; - if (ptr->data) { + if (ptr->data) { gf_bs_write_data(bs, ptr->data, ptr->dataSize); } return GF_OK; @@ -751,12 +752,12 @@ GF_Err dinf_AddBox(GF_Box *s, GF_Box *a) case GF_ISOM_BOX_TYPE_DREF: if (ptr->dref) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->dref = (GF_DataReferenceBox *)a; - return GF_OK; + ptr->dref = (GF_DataReferenceBox *)a; + return GF_OK; default: return gf_isom_box_add_default(s, a); } - return GF_OK; + return GF_OK; } GF_Err dinf_Read(GF_Box *s, GF_BitStream *bs) @@ -828,11 +829,11 @@ GF_Err dref_Read(GF_Box *s, GF_BitStream *bs) GF_Err e; //u32 count; GF_DataReferenceBox *ptr = (GF_DataReferenceBox *)s; - + if (ptr == NULL) return GF_BAD_PARAM; e = gf_isom_full_box_read(s, bs); if (e) return e; - //count = + //count = gf_bs_read_u32(bs); ptr->size -= 4; @@ -895,7 +896,7 @@ GF_Err edts_AddBox(GF_Box *s, GF_Box *a) } else { return gf_isom_box_add_default(s, a); } - return GF_OK; + return GF_OK; } @@ -976,7 +977,7 @@ GF_Err elst_Read(GF_Box *s, GF_BitStream *bs) u32 nb_entries; GF_EdtsEntry *p; GF_EditListBox *ptr = (GF_EditListBox *)s; - + e = gf_isom_full_box_read(s, bs); if (e) return e; nb_entries = gf_bs_read_u32(bs); @@ -1136,7 +1137,7 @@ GF_Err esds_Write(GF_Box *s, GF_BitStream *bs) char *enc_desc; u32 descSize = 0; GF_ESDBox *ptr = (GF_ESDBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; e = gf_odf_desc_write((GF_Descriptor *)ptr->desc, &enc_desc, &descSize); @@ -1175,9 +1176,9 @@ GF_Err free_Read(GF_Box *s, GF_BitStream *bs) GF_FreeSpaceBox *ptr = (GF_FreeSpaceBox *)s; if (ptr->size > 0xFFFFFFFF) return GF_IO_ERR; - + bytesToRead = (u32) (ptr->size); - + if (bytesToRead) { ptr->data = (char*)gf_malloc(bytesToRead * sizeof(char)); gf_bs_read_data(bs, ptr->data, bytesToRead); @@ -1200,17 +1201,17 @@ GF_Err free_Write(GF_Box *s, GF_BitStream *bs) GF_FreeSpaceBox *ptr = (GF_FreeSpaceBox *)s; e = gf_isom_box_write_header(s, bs); if (e) return e; - if (ptr->dataSize) { - if (ptr->data) { - gf_bs_write_data(bs, ptr->data, ptr->dataSize); - } else { - u32 i = 0; - while (idataSize) { - gf_bs_write_u8(bs, 0); - i++; - } - } - } + if (ptr->dataSize) { + if (ptr->data) { + gf_bs_write_data(bs, ptr->data, ptr->dataSize); + } else { + u32 i = 0; + while (idataSize) { + gf_bs_write_u8(bs, 0); + i++; + } + } + } return GF_OK; } @@ -1283,7 +1284,7 @@ GF_Err ftyp_Size(GF_Box *s) { GF_Err e; GF_FileTypeBox *ptr = (GF_FileTypeBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; ptr->size += 8 + ptr->altCount * 4; @@ -1317,7 +1318,7 @@ GF_Err gnrm_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s; - + //carefull we are not writing the box type but the entry type so switch for write ptr->type = ptr->EntryType; e = gf_isom_box_write_header(s, bs); @@ -1366,7 +1367,7 @@ GF_Err gnrv_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_GenericVisualSampleEntryBox *ptr = (GF_GenericVisualSampleEntryBox *)s; - + //carefull we are not writing the box type but the entry type so switch for write ptr->type = ptr->EntryType; e = gf_isom_box_write_header(s, bs); @@ -1417,7 +1418,7 @@ GF_Err gnra_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_GenericAudioSampleEntryBox *ptr = (GF_GenericAudioSampleEntryBox *)s; - + //carefull we are not writing the box type but the entry type so switch for write ptr->type = ptr->EntryType; e = gf_isom_box_write_header(s, bs); @@ -1570,7 +1571,7 @@ GF_Err hinf_Size(GF_Box *s) // GF_HintInfoBox *ptr = (GF_HintInfoBox *)s; return gf_isom_box_get_size(s); } -#endif /*GPAC_DISABLE_ISOM_WRITE*/ +#endif /*GPAC_DISABLE_ISOM_WRITE*/ void hmhd_del(GF_Box *s) { @@ -1598,7 +1599,7 @@ GF_Err hmhd_Read(GF_Box *s,GF_BitStream *bs) GF_Box *hmhd_New() { ISOM_DECL_BOX_ALLOC(GF_HintMediaHeaderBox, GF_ISOM_BOX_TYPE_HMHD); - + gf_isom_full_box_init((GF_Box *)tmp); return (GF_Box *)tmp; } @@ -1610,7 +1611,7 @@ GF_Err hmhd_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_HintMediaHeaderBox *ptr = (GF_HintMediaHeaderBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u16(bs, ptr->maxPDUSize); @@ -1827,7 +1828,7 @@ GF_Err sdp_Read(GF_Box *s, GF_BitStream *bs) //sdp text has no delimiter !!! ptr->sdpText = (char*)gf_malloc(sizeof(char) * (length+1)); if (!ptr->sdpText) return GF_OUT_OF_MEM; - + gf_bs_read_data(bs, ptr->sdpText, length); ptr->sdpText[length] = 0; return GF_OK; @@ -1889,7 +1890,7 @@ GF_Err trpy_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; GF_TRPYBox *ptr = (GF_TRPYBox *)s; if (ptr == NULL) return GF_BAD_PARAM; - + e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_u64(bs, ptr->nbBytes); @@ -2623,7 +2624,7 @@ void mdat_del(GF_Box *s) { GF_MediaDataBox *ptr = (GF_MediaDataBox *)s; if (!s) return; - + if (ptr->data) gf_free(ptr->data); gf_free(ptr); } @@ -2669,7 +2670,7 @@ GF_Err mdat_Size(GF_Box *s) GF_MediaDataBox *ptr = (GF_MediaDataBox *)s; e = gf_isom_box_get_size(s); if (e) return e; - + ptr->size += ptr->dataSize; return GF_OK; } @@ -2705,7 +2706,7 @@ GF_Err mdhd_Read(GF_Box *s, GF_BitStream *bs) GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Media header timescale is invalid (0) - defaulting to 90000\n" )); ptr->timeScale = 90000; } - + //our padding bit gf_bs_read_int(bs, 1); //the spec is unclear here, just says "the value 0 is interpreted as undetermined" @@ -2747,7 +2748,7 @@ GF_Err mdhd_Write(GF_Box *s, GF_BitStream *bs) GF_MediaHeaderBox *ptr = (GF_MediaHeaderBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; - if (ptr->version == 1) { + if (ptr->version == 1) { gf_bs_write_u64(bs, ptr->creationTime); gf_bs_write_u64(bs, ptr->modificationTime); gf_bs_write_u32(bs, ptr->timeScale); @@ -2798,36 +2799,36 @@ GF_Err mdia_AddBox(GF_Box *s, GF_Box *a) GF_MediaBox *ptr = (GF_MediaBox *)s; switch(a->type) { case GF_ISOM_BOX_TYPE_MDHD: - if (ptr->mediaHeader) ERROR_ON_DUPLICATED_BOX(a, ptr) + if (ptr->mediaHeader) ERROR_ON_DUPLICATED_BOX(a, ptr) + + ptr->mediaHeader = (GF_MediaHeaderBox *)a; + return GF_OK; - ptr->mediaHeader = (GF_MediaHeaderBox *)a; - return GF_OK; - case GF_ISOM_BOX_TYPE_HDLR: - if (ptr->handler) ERROR_ON_DUPLICATED_BOX(a, ptr) + if (ptr->handler) ERROR_ON_DUPLICATED_BOX(a, ptr) + + ptr->handler = (GF_HandlerBox *)a; + return GF_OK; - ptr->handler = (GF_HandlerBox *)a; - return GF_OK; - case GF_ISOM_BOX_TYPE_MINF: - if (ptr->information) ERROR_ON_DUPLICATED_BOX(a, ptr) + if (ptr->information) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->information = (GF_MediaInformationBox *)a; - return GF_OK; + ptr->information = (GF_MediaInformationBox *)a; + return GF_OK; default: return gf_isom_box_add_default(s, a); } - return GF_OK; + return GF_OK; } GF_Err mdia_Read(GF_Box *s, GF_BitStream *bs) -{ +{ return gf_isom_read_box_list(s, bs, mdia_AddBox); } GF_Box *mdia_New() -{ +{ ISOM_DECL_BOX_ALLOC(GF_MediaBox, GF_ISOM_BOX_TYPE_MDIA); return (GF_Box *)tmp; } @@ -2868,7 +2869,7 @@ GF_Err mdia_Size(GF_Box *s) e = gf_isom_box_size((GF_Box *) ptr->mediaHeader); if (e) return e; ptr->size += ptr->mediaHeader->size; - } + } if (ptr->handler) { e = gf_isom_box_size((GF_Box *) ptr->handler); if (e) return e; @@ -2970,19 +2971,19 @@ GF_Err minf_AddBox(GF_Box *s, GF_Box *a) case GF_ISOM_BOX_TYPE_GMHD: if (ptr->InfoHeader) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->InfoHeader = a; + ptr->InfoHeader = a; return GF_OK; - + case GF_ISOM_BOX_TYPE_DINF: if (ptr->dataInformation) ERROR_ON_DUPLICATED_BOX(a, ptr) - - ptr->dataInformation = (GF_DataInformationBox *)a; + + ptr->dataInformation = (GF_DataInformationBox *)a; return GF_OK; - + case GF_ISOM_BOX_TYPE_STBL: if (ptr->sampleTable ) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->sampleTable = (GF_SampleTableBox *)a; + ptr->sampleTable = (GF_SampleTableBox *)a; return GF_OK; default: return gf_isom_box_add_default(s, a); @@ -3010,7 +3011,7 @@ GF_Err minf_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; GF_MediaInformationBox *ptr = (GF_MediaInformationBox *)s; if (!s) return GF_BAD_PARAM; - + e = gf_isom_box_write_header(s, bs); if (e) return e; @@ -3018,12 +3019,12 @@ GF_Err minf_Write(GF_Box *s, GF_BitStream *bs) if (ptr->InfoHeader) { e = gf_isom_box_write((GF_Box *) ptr->InfoHeader, bs); if (e) return e; - } + } //then dataInfo if (ptr->dataInformation) { e = gf_isom_box_write((GF_Box *) ptr->dataInformation, bs); if (e) return e; - } + } //then sampleTable if (ptr->sampleTable) { e = gf_isom_box_write((GF_Box *) ptr->sampleTable, bs); @@ -3036,24 +3037,24 @@ GF_Err minf_Size(GF_Box *s) { GF_Err e; GF_MediaInformationBox *ptr = (GF_MediaInformationBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; if (ptr->InfoHeader) { e = gf_isom_box_size((GF_Box *) ptr->InfoHeader); if (e) return e; ptr->size += ptr->InfoHeader->size; - } + } if (ptr->dataInformation) { e = gf_isom_box_size((GF_Box *) ptr->dataInformation); if (e) return e; ptr->size += ptr->dataInformation->size; - } + } if (ptr->sampleTable) { e = gf_isom_box_size((GF_Box *) ptr->sampleTable); if (e) return e; ptr->size += ptr->sampleTable->size; - } + } return GF_OK; } @@ -3079,7 +3080,7 @@ GF_Err moof_AddBox(GF_Box *s, GF_Box *a) case GF_ISOM_BOX_TYPE_MFHD: if (ptr->mfhd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->mfhd = (GF_MovieFragmentHeaderBox *) a; + ptr->mfhd = (GF_MovieFragmentHeaderBox *) a; return GF_OK; case GF_ISOM_BOX_TYPE_TRAF: return gf_list_add(ptr->TrackList, a); @@ -3109,7 +3110,7 @@ GF_Err moof_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; GF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *) s; if (!s) return GF_BAD_PARAM; - + e = gf_isom_box_write_header(s, bs); if (e) return e; //Header First @@ -3128,7 +3129,7 @@ GF_Err moof_Size(GF_Box *s) e = gf_isom_box_get_size(s); if (e) return e; - + if (ptr->mfhd) { e = gf_isom_box_size((GF_Box *) ptr->mfhd); if (e) return e; @@ -3167,37 +3168,37 @@ GF_Err moov_AddBox(GF_Box *s, GF_Box *a) switch (a->type ) { case GF_ISOM_BOX_TYPE_IODS: if (ptr->iods) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->iods = (GF_ObjectDescriptorBox *)a; + ptr->iods = (GF_ObjectDescriptorBox *)a; //if no IOD, delete the box if (!ptr->iods->descriptor) { ptr->iods = NULL; gf_isom_box_del(a); } return GF_OK; - + case GF_ISOM_BOX_TYPE_MVHD: if (ptr->mvhd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->mvhd = (GF_MovieHeaderBox *)a; + ptr->mvhd = (GF_MovieHeaderBox *)a; return GF_OK; - + case GF_ISOM_BOX_TYPE_UDTA: if (ptr->udta) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->udta = (GF_UserDataBox *)a; + ptr->udta = (GF_UserDataBox *)a; return GF_OK; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS case GF_ISOM_BOX_TYPE_MVEX: if (ptr->mvex) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->mvex = (GF_MovieExtendsBox *)a; + ptr->mvex = (GF_MovieExtendsBox *)a; ptr->mvex->mov = ptr->mov; return GF_OK; #endif case GF_ISOM_BOX_TYPE_META: if (ptr->meta) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->meta = (GF_MetaBox *)a; + ptr->meta = (GF_MetaBox *)a; return GF_OK; - + case GF_ISOM_BOX_TYPE_TRAK: //set our pointer to this obj ((GF_TrackBox *)a)->moov = ptr; @@ -3226,7 +3227,7 @@ GF_Box *moov_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE @@ -3255,7 +3256,7 @@ GF_Err moov_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_box_write((GF_Box *) ptr->mvex, bs); if (e) return e; } -#endif +#endif e = gf_isom_box_array_write(s, ptr->trackList, bs); if (e) return e; @@ -3324,14 +3325,14 @@ GF_Err mp4a_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_ESDS: if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->esd = (GF_ESDBox *)a; + ptr->esd = (GF_ESDBox *)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); break; case GF_4CC('w','a','v','e'): if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) - /*HACK for QT files: get the esds box from the track*/ + /*HACK for QT files: get the esds box from the track*/ { GF_UnknownBox *wave = (GF_UnknownBox *)a; u32 offset = 0; @@ -3372,7 +3373,7 @@ GF_Err mp4a_Read(GF_Box *s, GF_BitStream *bs) e = gf_isom_read_box_list(s, bs, mp4a_AddBox); if (!e) return GF_OK; - /*hack for some weird files (possibly recorded with live.com tools, needs further investigations)*/ + /*hack for some weird files (possibly recorded with live.com tools, needs further investigations)*/ ptr = (GF_MPEGAudioSampleEntryBox *)s; gf_bs_seek(bs, pos); data = (char*)gf_malloc(sizeof(char) * size); @@ -3396,14 +3397,14 @@ GF_Box *mp4a_New() return (GF_Box *)tmp; } -GF_Box *enca_New() +GF_Box *enca_New() { ISOM_DECL_BOX_ALLOC(GF_MPEGAudioSampleEntryBox, GF_ISOM_BOX_TYPE_ENCA); gf_isom_audio_sample_entry_init((GF_AudioSampleEntryBox*)tmp); return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err mp4a_Write(GF_Box *s, GF_BitStream *bs) @@ -3454,7 +3455,7 @@ GF_Err mp4s_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_ESDS: if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->esd = (GF_ESDBox *)a; + ptr->esd = (GF_ESDBox *)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); @@ -3488,7 +3489,7 @@ GF_Box *encs_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err mp4s_Write(GF_Box *s, GF_BitStream *bs) @@ -3509,7 +3510,7 @@ GF_Err mp4s_Size(GF_Box *s) { GF_Err e; GF_MPEGSampleEntryBox *ptr = (GF_MPEGSampleEntryBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; ptr->size += 8; @@ -3551,46 +3552,46 @@ GF_Err mp4v_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_ESDS: if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->esd = (GF_ESDBox *)a; + ptr->esd = (GF_ESDBox *)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); break; case GF_ISOM_BOX_TYPE_AVCC: if (ptr->avc_config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->avc_config = (GF_AVCConfigurationBox *)a; + ptr->avc_config = (GF_AVCConfigurationBox *)a; break; case GF_ISOM_BOX_TYPE_HVCC: if (ptr->hevc_config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->hevc_config = (GF_HEVCConfigurationBox *)a; + ptr->hevc_config = (GF_HEVCConfigurationBox *)a; break; case GF_ISOM_BOX_TYPE_SVCC: if (ptr->svc_config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->svc_config = (GF_AVCConfigurationBox *)a; + ptr->svc_config = (GF_AVCConfigurationBox *)a; break; case GF_ISOM_BOX_TYPE_SHCC: if (ptr->shvc_config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->shvc_config = (GF_HEVCConfigurationBox *)a; + ptr->shvc_config = (GF_HEVCConfigurationBox *)a; break; case GF_ISOM_BOX_TYPE_BTRT: if (ptr->bitrate) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->bitrate = (GF_MPEG4BitRateBox *)a; + ptr->bitrate = (GF_MPEG4BitRateBox *)a; break; case GF_ISOM_BOX_TYPE_M4DS: if (ptr->descr) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->descr = (GF_MPEG4ExtensionDescriptorsBox *)a; + ptr->descr = (GF_MPEG4ExtensionDescriptorsBox *)a; break; case GF_ISOM_BOX_TYPE_UUID: if (ptr->ipod_ext) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->ipod_ext = (GF_UnknownUUIDBox *)a; + ptr->ipod_ext = (GF_UnknownUUIDBox *)a; break; case GF_ISOM_BOX_TYPE_PASP: if (ptr->pasp) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->pasp = (GF_PixelAspectRatioBox *)a; + ptr->pasp = (GF_PixelAspectRatioBox *)a; break; case GF_ISOM_BOX_TYPE_RVCC: if (ptr->rvcc) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->rvcc = (GF_RVCConfigurationBox *)a; + ptr->rvcc = (GF_RVCConfigurationBox *)a; break; default: return gf_isom_box_add_default(s, a); @@ -3609,7 +3610,8 @@ GF_Err mp4v_Read(GF_Box *s, GF_BitStream *bs) /*this is an AVC sample desc*/ if (mp4v->avc_config || mp4v->svc_config) AVC_RewriteESDescriptor(mp4v); /*this is an HEVC sample desc*/ - if (mp4v->hevc_config || mp4v->shvc_config) HEVC_RewriteESDescriptor(mp4v); + if (mp4v->hevc_config || mp4v->shvc_config || (mp4v->type==GF_ISOM_BOX_TYPE_HVT1)) + HEVC_RewriteESDescriptor(mp4v); return GF_OK; } @@ -3697,7 +3699,7 @@ GF_Err mp4v_Size(GF_Box *s) if (e) return e; ptr->size += ptr->esd->size; } else { - if (!ptr->avc_config && !ptr->svc_config && !ptr->hevc_config && !ptr->shvc_config) { + if (!ptr->avc_config && !ptr->svc_config && !ptr->hevc_config && !ptr->shvc_config && (ptr->type!=GF_ISOM_BOX_TYPE_HVT1) ) { return GF_ISOM_INVALID_FILE; } @@ -3705,22 +3707,22 @@ GF_Err mp4v_Size(GF_Box *s) e = gf_isom_box_size((GF_Box *)ptr->hevc_config); if (e) return e; ptr->size += ptr->hevc_config->size; - } - + } + if (ptr->avc_config && ptr->avc_config->config) { - e = gf_isom_box_size((GF_Box *) ptr->avc_config); + e = gf_isom_box_size((GF_Box *) ptr->avc_config); if (e) return e; ptr->size += ptr->avc_config->size; } if (ptr->svc_config && ptr->svc_config->config) { - e = gf_isom_box_size((GF_Box *) ptr->svc_config); + e = gf_isom_box_size((GF_Box *) ptr->svc_config); if (e) return e; ptr->size += ptr->svc_config->size; } if (ptr->shvc_config && ptr->shvc_config->config) { - e = gf_isom_box_size((GF_Box *) ptr->shvc_config); + e = gf_isom_box_size((GF_Box *) ptr->shvc_config); if (e) return e; ptr->size += ptr->shvc_config->size; } @@ -3773,7 +3775,7 @@ void mvex_del(GF_Box *s) GF_Err mvex_AddBox(GF_Box *s, GF_Box *a) { GF_MovieExtendsBox *ptr = (GF_MovieExtendsBox *)s; - + switch (a->type) { case GF_ISOM_BOX_TYPE_TREX: return gf_list_add(ptr->TrackExList, a); @@ -3784,7 +3786,7 @@ GF_Err mvex_AddBox(GF_Box *s, GF_Box *a) default: return gf_isom_box_add_default(s, a); } - return GF_OK; + return GF_OK; } @@ -3806,7 +3808,7 @@ GF_Box *mvex_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE @@ -3962,7 +3964,7 @@ GF_Box *mvhd_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err mvhd_Write(GF_Box *s, GF_BitStream *bs) @@ -4043,7 +4045,7 @@ GF_Box *nmhd_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err nmhd_Write(GF_Box *s, GF_BitStream *bs) @@ -4102,7 +4104,7 @@ GF_Box *padb_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err padb_Write(GF_Box *s, GF_BitStream *bs) @@ -4114,7 +4116,7 @@ GF_Err padb_Write(GF_Box *s, GF_BitStream *bs) e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_int(bs, ptr->SampleCount, 32); - + for (i=0 ; iSampleCount; i += 2) { gf_bs_write_int(bs, 0, 1); if (i+1 < ptr->SampleCount) { @@ -4259,7 +4261,7 @@ GF_Box *smhd_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err smhd_Write(GF_Box *s, GF_BitStream *bs) @@ -4367,39 +4369,39 @@ GF_Err stbl_AddBox(GF_SampleTableBox *ptr, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_STTS: if (ptr->TimeToSample) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->TimeToSample = (GF_TimeToSampleBox *)a; + ptr->TimeToSample = (GF_TimeToSampleBox *)a; break; case GF_ISOM_BOX_TYPE_CTTS: if (ptr->CompositionOffset) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->CompositionOffset = (GF_CompositionOffsetBox *)a; + ptr->CompositionOffset = (GF_CompositionOffsetBox *)a; break; case GF_ISOM_BOX_TYPE_CSLG: if (ptr->CompositionToDecode) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->CompositionToDecode = (GF_CompositionToDecodeBox *)a; + ptr->CompositionToDecode = (GF_CompositionToDecodeBox *)a; break; case GF_ISOM_BOX_TYPE_STSS: if (ptr->SyncSample) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SyncSample = (GF_SyncSampleBox *)a; + ptr->SyncSample = (GF_SyncSampleBox *)a; break; case GF_ISOM_BOX_TYPE_STSD: if (ptr->SampleDescription) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SampleDescription =(GF_SampleDescriptionBox *)a; + ptr->SampleDescription =(GF_SampleDescriptionBox *)a; break; case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: if (ptr->SampleSize) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SampleSize = (GF_SampleSizeBox *)a; + ptr->SampleSize = (GF_SampleSizeBox *)a; break; case GF_ISOM_BOX_TYPE_STSC: if (ptr->SampleToChunk) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SampleToChunk = (GF_SampleToChunkBox *)a; + ptr->SampleToChunk = (GF_SampleToChunkBox *)a; break; case GF_ISOM_BOX_TYPE_PADB: if (ptr->PaddingBits) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->PaddingBits = (GF_PaddingBitsBox *) a; + ptr->PaddingBits = (GF_PaddingBitsBox *) a; break; - //WARNING: AS THIS MAY CHANGE DYNAMICALLY DURING EDIT, + //WARNING: AS THIS MAY CHANGE DYNAMICALLY DURING EDIT, case GF_ISOM_BOX_TYPE_CO64: case GF_ISOM_BOX_TYPE_STCO: if (ptr->ChunkOffset) { @@ -4409,25 +4411,25 @@ GF_Err stbl_AddBox(GF_SampleTableBox *ptr, GF_Box *a) return GF_OK; case GF_ISOM_BOX_TYPE_STSH: if (ptr->ShadowSync) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->ShadowSync = (GF_ShadowSyncBox *)a; + ptr->ShadowSync = (GF_ShadowSyncBox *)a; break; case GF_ISOM_BOX_TYPE_STDP: if (ptr->DegradationPriority) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->DegradationPriority = (GF_DegradationPriorityBox *)a; + ptr->DegradationPriority = (GF_DegradationPriorityBox *)a; break; case GF_ISOM_BOX_TYPE_SDTP: if (ptr->SampleDep) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SampleDep= (GF_SampleDependencyTypeBox *)a; + ptr->SampleDep= (GF_SampleDependencyTypeBox *)a; break; case GF_ISOM_BOX_TYPE_STSF: if (ptr->Fragments) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->Fragments = (GF_SampleFragmentBox *)a; + ptr->Fragments = (GF_SampleFragmentBox *)a; break; - + case GF_ISOM_BOX_TYPE_SUBS: if (ptr->SubSamples) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->SubSamples = (GF_SubSampleInformationBox *)a; + ptr->SubSamples = (GF_SubSampleInformationBox *)a; break; case GF_ISOM_BOX_TYPE_SBGP: @@ -4454,7 +4456,7 @@ GF_Err stbl_AddBox(GF_SampleTableBox *ptr, GF_Box *a) case GF_ISOM_BOX_UUID_PSEC: ptr->piff_psec = a; return gf_isom_box_add_default((GF_Box *)ptr, a); - case GF_ISOM_BOX_TYPE_UUID: + case GF_ISOM_BOX_TYPE_UUID: if (((GF_UnknownUUIDBox *)a)->internal_4cc == GF_ISOM_BOX_UUID_PSEC) { ptr->piff_psec = a; return gf_isom_box_add_default((GF_Box *)ptr, a); @@ -4480,14 +4482,14 @@ GF_Err stbl_Read(GF_Box *s, GF_BitStream *bs) e = gf_isom_parse_box(&a, bs); if (e) return e; //we need to read the DegPriority in a different way... - if ((a->type == GF_ISOM_BOX_TYPE_STDP) || (a->type == GF_ISOM_BOX_TYPE_SDTP)) { + if ((a->type == GF_ISOM_BOX_TYPE_STDP) || (a->type == GF_ISOM_BOX_TYPE_SDTP)) { u64 s = a->size; -/* - if (!ptr->SampleSize) { - gf_isom_box_del(a); - return GF_ISOM_INVALID_FILE; - } -*/ + /* + if (!ptr->SampleSize) { + gf_isom_box_del(a); + return GF_ISOM_INVALID_FILE; + } + */ if (a->type == GF_ISOM_BOX_TYPE_STDP) { if (ptr->SampleSize) ((GF_DegradationPriorityBox *)a)->nb_entries = ptr->SampleSize->sampleCount; e = stdp_Read(a, bs); @@ -4515,7 +4517,7 @@ GF_Err stbl_Read(GF_Box *s, GF_BitStream *bs) e = stbl_AddBox(ptr, a); if (e) return e; } - if (!ptr->SyncSample) + if (!ptr->SyncSample) ptr->no_sync_found = 1; return GF_OK; @@ -4531,7 +4533,7 @@ GF_Box *stbl_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stbl_Write(GF_Box *s, GF_BitStream *bs) @@ -4643,7 +4645,7 @@ GF_Err stbl_Size(GF_Box *s) e = gf_isom_box_size((GF_Box *) ptr->SampleToChunk); if (e) return e; ptr->size += ptr->SampleToChunk->size; - } + } if (ptr->TimeToSample) { e = gf_isom_box_size((GF_Box *) ptr->TimeToSample); if (e) return e; @@ -4709,19 +4711,19 @@ GF_Err stbl_Size(GF_Box *s) if (ptr->sampleGroups) { e = gf_isom_box_array_size(s, ptr->sampleGroups); if (e) return e; - } + } if (ptr->sampleGroupsDescription) { e = gf_isom_box_array_size(s, ptr->sampleGroupsDescription); if (e) return e; - } + } if (ptr->sai_sizes) { e = gf_isom_box_array_size(s, ptr->sai_sizes); if (e) return e; - } + } if (ptr->sai_offsets) { e = gf_isom_box_array_size(s, ptr->sai_offsets); if (e) return e; - } + } return GF_OK; } @@ -4767,7 +4769,7 @@ GF_Box *stco_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stco_Write(GF_Box *s, GF_BitStream *bs) @@ -4835,7 +4837,7 @@ GF_Box *stdp_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stdp_Write(GF_Box *s, GF_BitStream *bs) @@ -4886,7 +4888,7 @@ GF_Err stsc_Read(GF_Box *s, GF_BitStream *bs) ptr->alloc_size = ptr->nb_entries; ptr->entries = gf_malloc(sizeof(GF_StscEntry)*ptr->alloc_size); if (!ptr->entries) return GF_OUT_OF_MEM; - + for (i = 0; i < ptr->nb_entries; i++) { ptr->entries[i].firstChunk = gf_bs_read_u32(bs); ptr->entries[i].samplesPerChunk = gf_bs_read_u32(bs); @@ -4911,13 +4913,13 @@ GF_Box *stsc_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stsc_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; - u32 i; + u32 i; GF_SampleToChunkBox *ptr = (GF_SampleToChunkBox *)s; e = gf_isom_full_box_write(s, bs); @@ -4973,6 +4975,7 @@ GF_Err stsd_AddBox(GF_SampleDescriptionBox *ptr, GF_Box *a) case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: + case GF_ISOM_BOX_TYPE_HVT1: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: case GF_ISOM_BOX_TYPE_TX3G: @@ -4987,7 +4990,7 @@ GF_Err stsd_AddBox(GF_SampleDescriptionBox *ptr, GF_Box *a) case GF_ISOM_BOX_TYPE_WVTT: case GF_ISOM_BOX_TYPE_STPP: case GF_ISOM_BOX_TYPE_SBTT: - return gf_isom_box_add_default((GF_Box*)ptr, a); + return gf_isom_box_add_default((GF_Box*)ptr, a); /*for 3GP config, we must set the type*/ case GF_ISOM_SUBTYPE_3GP_AMR: case GF_ISOM_SUBTYPE_3GP_AMR_WB: @@ -5046,7 +5049,7 @@ GF_Box *stsd_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stsd_Write(GF_Box *s, GF_BitStream *bs) @@ -5081,13 +5084,13 @@ void stsf_del(GF_Box *s) GF_StsfEntry *pe; GF_SampleFragmentBox *ptr = (GF_SampleFragmentBox *)s; if (ptr == NULL) return; - + if (ptr->entryList) { nb_entries = gf_list_count(ptr->entryList); for ( i = 0; i < nb_entries; i++ ) { pe = (GF_StsfEntry*)gf_list_get(ptr->entryList, i); if (pe->fragmentSizes) gf_free(pe->fragmentSizes); - gf_free(pe); + gf_free(pe); } gf_list_del(ptr->entryList); } @@ -5103,7 +5106,7 @@ GF_Err stsf_Read(GF_Box *s, GF_BitStream *bs) u32 nb_entries; GF_StsfEntry *p; GF_SampleFragmentBox *ptr = (GF_SampleFragmentBox *)s; - + p = NULL; if (!ptr) return GF_BAD_PARAM; e = gf_isom_full_box_read(s, bs); @@ -5144,7 +5147,7 @@ GF_Box *stsf_New() - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stsf_Write(GF_Box *s, GF_BitStream *bs) @@ -5154,16 +5157,16 @@ GF_Err stsf_Write(GF_Box *s, GF_BitStream *bs) u32 nb_entries; GF_StsfEntry *p; GF_SampleFragmentBox *ptr = (GF_SampleFragmentBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; - nb_entries = gf_list_count(ptr->entryList); + nb_entries = gf_list_count(ptr->entryList); gf_bs_write_u32(bs, nb_entries); for ( i = 0; i < nb_entries; i++ ) { p = (GF_StsfEntry*)gf_list_get(ptr->entryList, i); gf_bs_write_u32(bs, p->SampleNumber); gf_bs_write_u32(bs, p->fragmentCount); - for (j=0;jfragmentCount;j++) { + for (j=0; jfragmentCount; j++) { gf_bs_write_u16(bs, p->fragmentSizes[j]); } } @@ -5181,7 +5184,7 @@ GF_Err stsf_Size(GF_Box *s) if (e) return e; nb_entries = gf_list_count(ptr->entryList); ptr->size += 4; - for (i=0;ientryList, i); ptr->size += 8 + 2*p->fragmentCount; } @@ -5239,7 +5242,7 @@ GF_Box *stsh_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stsh_Write(GF_Box *s, GF_BitStream *bs) @@ -5308,7 +5311,7 @@ GF_Box *stss_New() return (GF_Box*)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stss_Write(GF_Box *s, GF_BitStream *bs) @@ -5380,7 +5383,7 @@ GF_Err stsz_Read(GF_Box *s, GF_BitStream *bs) if (!ptr->sampleCount) { ptr->sampleSize = 16; return GF_OK; - } + } estSize = (u32) (ptr->size) / ptr->sampleCount; if (!estSize && ((ptr->sampleCount+1)/2 == (ptr->size)) ) { ptr->sampleSize = 4; @@ -5440,7 +5443,7 @@ GF_Box *stsz_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stsz_Write(GF_Box *s, GF_BitStream *bs) @@ -5448,7 +5451,7 @@ GF_Err stsz_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_SampleSizeBox *ptr = (GF_SampleSizeBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; //in both versions this is still valid @@ -5542,7 +5545,7 @@ GF_Err stsz_Size(GF_Box *s) ptr->size += (4 * ptr->sampleCount); return GF_OK; } - + //make sure we are a compact table (no need to change the mem representation) ptr->type = GF_ISOM_BOX_TYPE_STZ2; ptr->sampleSize = fieldSize; @@ -5589,7 +5592,7 @@ GF_Err stts_Read(GF_Box *s, GF_BitStream *bs) ptr->w_currentSampleNum += ptr->entries[i].sampleCount; ptr->w_LastDTS += ptr->entries[i].sampleCount * ptr->entries[i].sampleDelta; #endif - + if (!ptr->entries[i].sampleDelta) { if ((i+1nb_entries) ) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Found stss entry with sample_delta=0 - forbidden ! Fixing to 1\n" )); @@ -5614,7 +5617,7 @@ GF_Box *stts_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stts_Write(GF_Box *s, GF_BitStream *bs) @@ -5622,11 +5625,11 @@ GF_Err stts_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_TimeToSampleBox *ptr = (GF_TimeToSampleBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->nb_entries); - for (i=0; inb_entries;i++) { + for (i=0; inb_entries; i++) { gf_bs_write_u32(bs, ptr->entries[i].sampleCount); gf_bs_write_u32(bs, ptr->entries[i].sampleDelta); } @@ -5660,11 +5663,11 @@ GF_Err tfhd_Read(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_TrackFragmentHeaderBox *ptr = (GF_TrackFragmentHeaderBox *)s; - + e = gf_isom_full_box_read(s, bs); if (e) return e; - - ptr->trackID = gf_bs_read_u32(bs); + + ptr->trackID = gf_bs_read_u32(bs); //The rest depends on the flags if (ptr->flags & GF_ISOM_TRAF_BASE_OFFSET) { @@ -5693,7 +5696,7 @@ GF_Box *tfhd_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE @@ -5789,7 +5792,7 @@ GF_Err tims_Size(GF_Box *s) return GF_OK; } -#endif /*GPAC_DISABLE_ISOM_WRITE*/ +#endif /*GPAC_DISABLE_ISOM_WRITE*/ void tkhd_del(GF_Box *s) @@ -5851,7 +5854,7 @@ GF_Box *tkhd_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err tkhd_Write(GF_Box *s, GF_BitStream *bs) @@ -5934,34 +5937,34 @@ void traf_del(GF_Box *s) GF_Err traf_AddBox(GF_Box *s, GF_Box *a) { GF_TrackFragmentBox *ptr = (GF_TrackFragmentBox *)s; - + switch (a->type) { case GF_ISOM_BOX_TYPE_TFHD: if (ptr->tfhd) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->tfhd = (GF_TrackFragmentHeaderBox *) a; + ptr->tfhd = (GF_TrackFragmentHeaderBox *) a; return GF_OK; case GF_ISOM_BOX_TYPE_TRUN: return gf_list_add(ptr->TrackRuns, a); case GF_ISOM_BOX_TYPE_SDTP: if (ptr->sdtp) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->sdtp = (GF_SampleDependencyTypeBox *)a; + ptr->sdtp = (GF_SampleDependencyTypeBox *)a; return GF_OK; - case GF_ISOM_BOX_TYPE_TFDT: - if (ptr->tfdt) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->tfdt = (GF_TFBaseMediaDecodeTimeBox*) a; + case GF_ISOM_BOX_TYPE_TFDT: + if (ptr->tfdt) ERROR_ON_DUPLICATED_BOX(a, ptr) + ptr->tfdt = (GF_TFBaseMediaDecodeTimeBox*) a; return GF_OK; case GF_ISOM_BOX_TYPE_SUBS: if (ptr->subs) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->subs = (GF_SubSampleInformationBox *)a; + ptr->subs = (GF_SubSampleInformationBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_SBGP: if (!ptr->sampleGroups) ptr->sampleGroups = gf_list_new(); gf_list_add(ptr->sampleGroups, a); - return GF_OK; + return GF_OK; case GF_ISOM_BOX_TYPE_SGPD: if (!ptr->sampleGroupsDescription) ptr->sampleGroupsDescription = gf_list_new(); gf_list_add(ptr->sampleGroupsDescription, a); - return GF_OK; + return GF_OK; case GF_ISOM_BOX_TYPE_SAIZ: if (!ptr->sai_sizes) ptr->sai_sizes = gf_list_new(); gf_list_add(ptr->sai_sizes, a); @@ -5969,25 +5972,25 @@ GF_Err traf_AddBox(GF_Box *s, GF_Box *a) case GF_ISOM_BOX_TYPE_SAIO: if (!ptr->sai_offsets) ptr->sai_offsets = gf_list_new(); gf_list_add(ptr->sai_offsets, a); - return GF_OK; + return GF_OK; case GF_ISOM_BOX_TYPE_UUID: if ( ((GF_UUIDBox *)a)->internal_4cc==GF_ISOM_BOX_UUID_PSEC) { if (ptr->piff_sample_encryption) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->piff_sample_encryption = (GF_PIFFSampleEncryptionBox *)a; + ptr->piff_sample_encryption = (GF_PIFFSampleEncryptionBox *)a; ptr->piff_sample_encryption->traf = ptr; return GF_OK; } else { return gf_isom_box_add_default(s, a); } case GF_ISOM_BOX_TYPE_SENC: - if (ptr->sample_encryption) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->sample_encryption = (GF_SampleEncryptionBox *)a; + if (ptr->sample_encryption) ERROR_ON_DUPLICATED_BOX(a, ptr) + ptr->sample_encryption = (GF_SampleEncryptionBox *)a; ptr->sample_encryption->traf = ptr; return GF_OK; default: return gf_isom_box_add_default(s, a); } - return GF_OK; + return GF_OK; } @@ -6003,7 +6006,7 @@ GF_Err traf_Read(GF_Box *s, GF_BitStream *bs) //we need to read the DegPriority in a different way... - if ((a->type == GF_ISOM_BOX_TYPE_STDP) || (a->type == GF_ISOM_BOX_TYPE_SDTP)) { + if ((a->type == GF_ISOM_BOX_TYPE_STDP) || (a->type == GF_ISOM_BOX_TYPE_SDTP)) { u32 nb_samples=0, i=0; u64 s = a->size; for (i=0; iTrackRuns); i++) { @@ -6041,7 +6044,7 @@ GF_Box *traf_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err traf_Write(GF_Box *s, GF_BitStream *bs) @@ -6065,7 +6068,7 @@ GF_Err traf_Write(GF_Box *s, GF_BitStream *bs) if (ptr->tfdt) { e = gf_isom_box_write((GF_Box *) ptr->tfdt, bs); if (e) return e; - } + } if (ptr->sdtp) { e = gf_isom_box_write((GF_Box *) ptr->sdtp, bs); if (e) return e; @@ -6163,7 +6166,7 @@ GF_Err traf_Size(GF_Box *s) #endif /*GPAC_DISABLE_ISOM_WRITE*/ #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/ - + void trak_del(GF_Box *s) { @@ -6176,7 +6179,7 @@ void trak_del(GF_Box *s) if (ptr->References) gf_isom_box_del((GF_Box *)ptr->References); if (ptr->editBox) gf_isom_box_del((GF_Box *)ptr->editBox); if (ptr->meta) gf_isom_box_del((GF_Box *)ptr->meta); - if (ptr->name) gf_free(ptr->name); + if (ptr->name) gf_free(ptr->name); gf_free(ptr); } @@ -6218,6 +6221,7 @@ static void gf_isom_check_sample_desc(GF_TrackBox *trak) case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: + case GF_ISOM_BOX_TYPE_HVT1: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: case GF_ISOM_BOX_TYPE_TX3G: @@ -6274,24 +6278,24 @@ static void gf_isom_check_sample_desc(GF_TrackBox *trak) default: /*remove entry*/ - if (a->data && a->size) { - gf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1); - genm = (GF_GenericSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRM); - genm->size = a->size; - bs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ); - gf_bs_read_data(bs, genm->reserved, 6); - genm->dataReferenceIndex = gf_bs_read_u16(bs); - genm->data_size = (u32) gf_bs_available(bs); - if (genm->data_size) { - genm->data = (char*)gf_malloc(sizeof(char) * genm->data_size); - gf_bs_read_data(bs, genm->data, genm->data_size); - } - gf_bs_del(bs); - genm->size = a->size; - genm->EntryType = a->type; - gf_isom_box_del((GF_Box *)a); - gf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genm, i-1); - } + if (a->data && a->size) { + gf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1); + genm = (GF_GenericSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRM); + genm->size = a->size; + bs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ); + gf_bs_read_data(bs, genm->reserved, 6); + genm->dataReferenceIndex = gf_bs_read_u16(bs); + genm->data_size = (u32) gf_bs_available(bs); + if (genm->data_size) { + genm->data = (char*)gf_malloc(sizeof(char) * genm->data_size); + gf_bs_read_data(bs, genm->data, genm->data_size); + } + gf_bs_del(bs); + genm->size = a->size; + genm->EntryType = a->type; + gf_isom_box_del((GF_Box *)a); + gf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genm, i-1); + } break; } @@ -6306,27 +6310,27 @@ GF_Err trak_AddBox(GF_Box *s, GF_Box *a) switch(a->type) { case GF_ISOM_BOX_TYPE_TKHD: if (ptr->Header) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->Header = (GF_TrackHeaderBox *)a; + ptr->Header = (GF_TrackHeaderBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_EDTS: if (ptr->editBox) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->editBox = (GF_EditBox *)a; + ptr->editBox = (GF_EditBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_UDTA: if (ptr->udta) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->udta = (GF_UserDataBox *)a; + ptr->udta = (GF_UserDataBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_META: if (ptr->meta) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->meta = (GF_MetaBox *)a; + ptr->meta = (GF_MetaBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_TREF: if (ptr->References) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->References = (GF_TrackReferenceBox *)a; + ptr->References = (GF_TrackReferenceBox *)a; return GF_OK; case GF_ISOM_BOX_TYPE_MDIA: if (ptr->Media) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->Media = (GF_MediaBox *)a; + ptr->Media = (GF_MediaBox *)a; ((GF_MediaBox *)a)->mediaTrack = ptr; return GF_OK; default: @@ -6362,7 +6366,7 @@ GF_Box *trak_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err trak_Write(GF_Box *s, GF_BitStream *bs) @@ -6403,7 +6407,7 @@ GF_Err trak_Size(GF_Box *s) { GF_Err e; GF_TrackBox *ptr = (GF_TrackBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; @@ -6468,7 +6472,7 @@ GF_Box *tref_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err tref_Write(GF_Box *s, GF_BitStream *bs) @@ -6506,7 +6510,7 @@ GF_Err reftype_Read(GF_Box *s, GF_BitStream *bs) ptr->trackIDCount = (u32) (bytesToRead) / sizeof(u32); ptr->trackIDs = (u32 *) gf_malloc(ptr->trackIDCount * sizeof(u32)); if (!ptr->trackIDs) return GF_OUT_OF_MEM; - + for (i = 0; i < ptr->trackIDCount; i++) { ptr->trackIDs[i] = gf_bs_read_u32(bs); } @@ -6543,7 +6547,7 @@ GF_Err reftype_AddRefTrack(GF_TrackReferenceTypeBox *ref, u32 trackID, u16 *outR } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err reftype_Write(GF_Box *s, GF_BitStream *bs) @@ -6614,7 +6618,7 @@ GF_Box *trex_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE @@ -6659,7 +6663,7 @@ void trun_del(GF_Box *s) GF_TrunEntry *p; GF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s; if (ptr == NULL) return; - + while (gf_list_count(ptr->entries)) { p = (GF_TrunEntry*)gf_list_get(ptr->entries, 0); gf_list_rem(ptr->entries, 0); @@ -6676,12 +6680,12 @@ GF_Err trun_Read(GF_Box *s, GF_BitStream *bs) u32 i; GF_TrunEntry *p; GF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s; - + e = gf_isom_full_box_read(s, bs); if (e) return e; //check this is a good file - if ((ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) && (ptr->flags & GF_ISOM_TRUN_FLAGS)) + if ((ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) && (ptr->flags & GF_ISOM_TRUN_FLAGS)) return GF_ISOM_INVALID_FILE; ptr->sample_count = gf_bs_read_u32(bs); @@ -6722,7 +6726,7 @@ GF_Err trun_Read(GF_Box *s, GF_BitStream *bs) gf_list_add(ptr->entries, p); if (ptr->sizesize-=trun_size; - } + } return GF_OK; } @@ -6735,7 +6739,7 @@ GF_Box *trun_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE @@ -6778,7 +6782,7 @@ GF_Err trun_Write(GF_Box *s, GF_BitStream *bs) if (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) { gf_bs_write_u32(bs, p->CTS_Offset); } - } + } return GF_OK; } @@ -6790,7 +6794,7 @@ GF_Err trun_Size(GF_Box *s) e = gf_isom_full_box_get_size(s); if (e) return e; - + ptr->size += 4; //The rest depends on the flags if (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) ptr->size += 4; @@ -6805,7 +6809,7 @@ GF_Err trun_Size(GF_Box *s) if (ptr->flags & GF_ISOM_TRUN_FLAGS) ptr->size += 4; if (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) ptr->size += 4; } - + return GF_OK; } @@ -6814,7 +6818,7 @@ GF_Err trun_Size(GF_Box *s) #endif /*GPAC_DISABLE_ISOM_WRITE*/ #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/ - + void tsro_del(GF_Box *s) { @@ -6902,9 +6906,9 @@ GF_Err udta_AddBox(GF_UserDataBox *ptr, GF_Box *a) map = (GF_UserDataMap *) gf_malloc(sizeof(GF_UserDataMap)); if (map == NULL) return GF_OUT_OF_MEM; memset(map, 0, sizeof(GF_UserDataMap)); - + map->boxType = a->type; - if (a->type == GF_ISOM_BOX_TYPE_UUID) + if (a->type == GF_ISOM_BOX_TYPE_UUID) memcpy(map->uuid, ((GF_UUIDBox *)a)->uuid, 16); map->other_boxes = gf_list_new(); if (!map->other_boxes) { @@ -6953,7 +6957,7 @@ GF_Box *udta_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err udta_Write(GF_Box *s, GF_BitStream *bs) @@ -6971,7 +6975,7 @@ GF_Err udta_Write(GF_Box *s, GF_BitStream *bs) //but the UDTA box. The parent itself is not an box, we don't care about it e = gf_isom_box_array_write(s, map->other_boxes, bs); if (e) return e; - } + } return GF_OK; } @@ -6981,7 +6985,7 @@ GF_Err udta_Size(GF_Box *s) u32 i; GF_UserDataMap *map; GF_UserDataBox *ptr = (GF_UserDataBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; i=0; @@ -7024,14 +7028,14 @@ GF_Box *vmhd_New() } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err vmhd_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u64(bs, ptr->reserved); @@ -7069,7 +7073,7 @@ GF_Box *void_New() return tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err void_Write(GF_Box *s, GF_BitStream *bs) @@ -7126,7 +7130,7 @@ GF_Err pdin_Read(GF_Box *s, GF_BitStream *bs) return GF_OK; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err pdin_Write(GF_Box *s, GF_BitStream *bs) @@ -7191,7 +7195,7 @@ GF_Err sdtp_Read(GF_Box *s, GF_BitStream *bs) return GF_OK; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err sdtp_Write(GF_Box *s, GF_BitStream *bs) @@ -7241,7 +7245,7 @@ GF_Err pasp_Read(GF_Box *s, GF_BitStream *bs) return GF_OK; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err pasp_Write(GF_Box *s, GF_BitStream *bs) @@ -7298,7 +7302,7 @@ GF_Err metx_AddBox(GF_Box *s, GF_Box *a) break; case GF_ISOM_BOX_TYPE_BTRT: if (ptr->bitrate) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->bitrate = (GF_MPEG4BitRateBox *)a; + ptr->bitrate = (GF_MPEG4BitRateBox *)a; break; default: return gf_isom_box_add_default(s, a); @@ -7355,7 +7359,7 @@ GF_Err metx_Read(GF_Box *s, GF_BitStream *bs) return gf_isom_read_box_list(s, bs, metx_AddBox); } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err metx_Write(GF_Box *s, GF_BitStream *bs) @@ -7367,19 +7371,19 @@ GF_Err metx_Write(GF_Box *s, GF_BitStream *bs) gf_bs_write_data(bs, ptr->reserved, 6); gf_bs_write_u16(bs, ptr->dataReferenceIndex); - if (ptr->content_encoding) + if (ptr->content_encoding) gf_bs_write_data(bs, ptr->content_encoding, (u32) strlen(ptr->content_encoding)); gf_bs_write_u8(bs, 0); - if (ptr->mime_type_or_namespace) + if (ptr->mime_type_or_namespace) gf_bs_write_data(bs, ptr->mime_type_or_namespace, (u32) strlen(ptr->mime_type_or_namespace)); gf_bs_write_u8(bs, 0); - - if (ptr->type == GF_ISOM_BOX_TYPE_METX) { - if (ptr->xml_schema_loc) - gf_bs_write_data(bs, ptr->xml_schema_loc, (u32) strlen(ptr->xml_schema_loc)); - gf_bs_write_u8(bs, 0); - } + + if (ptr->type == GF_ISOM_BOX_TYPE_METX) { + if (ptr->xml_schema_loc) + gf_bs_write_data(bs, ptr->xml_schema_loc, (u32) strlen(ptr->xml_schema_loc)); + gf_bs_write_u8(bs, 0); + } if (ptr->bitrate) { e = gf_isom_box_write((GF_Box *)ptr->bitrate, bs); @@ -7402,10 +7406,10 @@ GF_Err metx_Size(GF_Box *s) ptr->size += strlen(ptr->mime_type_or_namespace); ptr->size++; if (ptr->type == GF_ISOM_BOX_TYPE_METX) { - if (ptr->xml_schema_loc) - ptr->size += strlen(ptr->xml_schema_loc); - ptr->size++; - } + if (ptr->xml_schema_loc) + ptr->size += strlen(ptr->xml_schema_loc); + ptr->size++; + } if (ptr->bitrate) { e = gf_isom_box_size((GF_Box *)ptr->bitrate); @@ -7435,7 +7439,7 @@ void stse_del(GF_Box *s) if (ptr->content_encoding) gf_free(ptr->content_encoding); if (ptr->mime_type) gf_free(ptr->mime_type); if (ptr->bitrate) gf_isom_box_del((GF_Box *)ptr->bitrate); - if (ptr->config) gf_isom_box_del((GF_Box *)ptr->config); + if (ptr->config) gf_isom_box_del((GF_Box *)ptr->config); gf_free(ptr); } @@ -7446,11 +7450,11 @@ GF_Err stse_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_STTC: if (ptr->config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->config = (GF_StringBox *)a; + ptr->config = (GF_StringBox *)a; break; case GF_ISOM_BOX_TYPE_BTRT: if (ptr->bitrate) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->bitrate = (GF_MPEG4BitRateBox *)a; + ptr->bitrate = (GF_MPEG4BitRateBox *)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); @@ -7499,7 +7503,7 @@ GF_Err stse_Read(GF_Box *s, GF_BitStream *bs) return gf_isom_read_box_list(s, bs, stse_AddBox); } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stse_Write(GF_Box *s, GF_BitStream *bs) @@ -7511,14 +7515,14 @@ GF_Err stse_Write(GF_Box *s, GF_BitStream *bs) gf_bs_write_data(bs, ptr->reserved, 6); gf_bs_write_u16(bs, ptr->dataReferenceIndex); - if (ptr->content_encoding) + if (ptr->content_encoding) gf_bs_write_data(bs, ptr->content_encoding, (u32) strlen(ptr->content_encoding)); gf_bs_write_u8(bs, 0); - if (ptr->mime_type) + if (ptr->mime_type) gf_bs_write_data(bs, ptr->mime_type, (u32) strlen(ptr->mime_type)); gf_bs_write_u8(bs, 0); - + if (ptr->bitrate) { e = gf_isom_box_write((GF_Box *)ptr->bitrate, bs); if (e) return e; @@ -7609,7 +7613,7 @@ GF_Err dac3_Read(GF_Box *s, GF_BitStream *bs) return GF_OK; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err dac3_Write(GF_Box *s, GF_BitStream *bs) @@ -7664,7 +7668,7 @@ GF_Err dac3_Size(GF_Box *s) s->size += 2; for (i=0; icfg.nb_streams; i++) { s->size += 3; - if (ptr->cfg.streams[i].nb_dep_sub) + if (ptr->cfg.streams[i].nb_dep_sub) s->size += 1; } } else { @@ -7708,7 +7712,7 @@ GF_Box *ac3_New(u32 boxType) return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err ac3_Write(GF_Box *s, GF_BitStream *bs) @@ -7763,7 +7767,7 @@ GF_Box *lsrc_New() return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err lsrc_Write(GF_Box *s, GF_BitStream *bs) @@ -7808,15 +7812,15 @@ GF_Err lsr1_AddBox(GF_Box *s, GF_Box *a) switch (a->type) { case GF_ISOM_BOX_TYPE_LSRC: if (ptr->lsr_config) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->lsr_config = (GF_LASERConfigurationBox *)a; + ptr->lsr_config = (GF_LASERConfigurationBox *)a; break; case GF_ISOM_BOX_TYPE_BTRT: if (ptr->bitrate) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->bitrate = (GF_MPEG4BitRateBox *)a; + ptr->bitrate = (GF_MPEG4BitRateBox *)a; break; case GF_ISOM_BOX_TYPE_M4DS: if (ptr->descr) ERROR_ON_DUPLICATED_BOX(a, ptr) - ptr->descr = (GF_MPEG4ExtensionDescriptorsBox *)a; + ptr->descr = (GF_MPEG4ExtensionDescriptorsBox *)a; break; default: return gf_isom_box_add_default(s, a); @@ -7954,7 +7958,7 @@ GF_Err sidx_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_SegmentIndexBox *ptr = (GF_SegmentIndexBox*) s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; @@ -8039,7 +8043,7 @@ GF_Err pcrb_Write(GF_Box *s, GF_BitStream *bs) GF_Err e; u32 i; GF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s; - + e = gf_isom_box_write_header(s, bs); if (e) return e; @@ -8064,7 +8068,7 @@ GF_Err pcrb_Size(GF_Box *s) ptr->size += 4; ptr->size += ptr->subsegment_count * 8; - + return GF_OK; } @@ -8081,7 +8085,7 @@ GF_Box *subs_New() void subs_del(GF_Box *s) { GF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *)s; - if (ptr == NULL) return; + if (ptr == NULL) return; while (gf_list_count(ptr->Samples)) { GF_SubSampleInfoEntry *pSamp; @@ -8091,7 +8095,7 @@ void subs_del(GF_Box *s) pSubSamp = (GF_SubSampleEntry*) gf_list_get(pSamp->SubSamples, 0); gf_free(pSubSamp); gf_list_rem(pSamp->SubSamples, 0); - } + } gf_list_del(pSamp->SubSamples); gf_free(pSamp); gf_list_rem(ptr->Samples, 0); @@ -8117,15 +8121,15 @@ GF_Err subs_Write(GF_Box *s, GF_BitStream *bs) if (e) return e; entry_count = gf_list_count(ptr->Samples); gf_bs_write_u32(bs, entry_count); - + for (i=0; iSamples, i); subsample_count = gf_list_count(pSamp->SubSamples); gf_bs_write_u32(bs, pSamp->sample_delta); gf_bs_write_u16(bs, subsample_count); - + for (j=0; jSubSamples, j); + pSubSamp = (GF_SubSampleEntry*) gf_list_get(pSamp->SubSamples, j); if (ptr->version == 1) { gf_bs_write_u32(bs, pSubSamp->subsample_size); } else { @@ -8147,7 +8151,7 @@ GF_Err subs_Size(GF_Box *s) u32 entry_count, i; u16 subsample_count; - // determine the size of the full box + // determine the size of the full box e = gf_isom_full_box_get_size(s); if (e) return e; @@ -8377,11 +8381,11 @@ GF_Err sbgp_Write(GF_Box *s, GF_BitStream *bs) u32 i; GF_Err e; GF_SampleGroupBox *p = (GF_SampleGroupBox*)s; - + e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, p->grouping_type); - if (p->version==1) + if (p->version==1) gf_bs_write_u32(bs, p->grouping_type_parameter); gf_bs_write_u32(bs, p->entry_count); @@ -8436,6 +8440,14 @@ static void *sgpd_parse_entry(u32 grouping_type, GF_BitStream *bs, u32 entry_siz *total_bytes = 20; return ptr; } + case GF_4CC( 't', 'r', 'i', 'f' ): + { + u32 flags = gf_bs_peek_bits(bs, 24, 0); + flags &= 0x0000FF; + if (flags & 0x20) entry_size=9; + else entry_size=11; + //fallthrough + } default: { GF_DefaultSampleGroupDescriptionEntry *ptr; @@ -8486,12 +8498,14 @@ void sgpd_write_entry(u32 grouping_type, void *entry, GF_BitStream *bs) gf_bs_write_data(bs, (char *)((GF_CENCSampleEncryptionGroupEntry *)entry)->KID, 16); return; default: - { + { GF_DefaultSampleGroupDescriptionEntry *ptr = (GF_DefaultSampleGroupDescriptionEntry *)entry; gf_bs_write_data(bs, (char *) ptr->data, ptr->length); - } + } } } + +#ifndef GPAC_DISABLE_ISOM_WRITE static u32 sgpd_size_entry(u32 grouping_type, void *entry) { switch (grouping_type) { @@ -8505,6 +8519,7 @@ static u32 sgpd_size_entry(u32 grouping_type, void *entry) return ((GF_DefaultSampleGroupDescriptionEntry *)entry)->length; } } +#endif GF_Box *sgpd_New() { @@ -8536,11 +8551,15 @@ GF_Err sgpd_Read(GF_Box *s, GF_BitStream *bs) p->grouping_type = gf_bs_read_u32(bs); p->size -= 4; - + if (p->version==1) { p->default_length = gf_bs_read_u32(bs); p->size -= 4; } + if (p->version>=2) { + p->default_description_index = gf_bs_read_u32(bs); + p->size -= 4; + } entry_count = gf_bs_read_u32(bs); p->size -= 4; @@ -8573,6 +8592,7 @@ GF_Err sgpd_Write(GF_Box *s, GF_BitStream *bs) gf_bs_write_u32(bs, p->grouping_type); if (p->version==1) gf_bs_write_u32(bs, p->default_length); + if (p->version>=2) gf_bs_write_u32(bs, p->default_description_index); gf_bs_write_u32(bs, gf_list_count(p->group_descriptions) ); for (i=0; igroup_descriptions); i++) { @@ -8595,6 +8615,7 @@ GF_Err sgpd_Size(GF_Box *s) if (e) return e; p->size += 8; if (p->version==1) p->size += 4; + if (p->version>=2) p->size += 4; p->default_length = 0; for (i=0; igroup_descriptions); i++) { @@ -8652,7 +8673,7 @@ GF_Box *saiz_New() ISOM_DECL_BOX_ALLOC(GF_SampleAuxiliaryInfoSizeBox, GF_ISOM_BOX_TYPE_SAIZ); return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err saiz_Write(GF_Box *s, GF_BitStream *bs) @@ -8739,7 +8760,7 @@ GF_Box *saio_New() ISOM_DECL_BOX_ALLOC(GF_SampleAuxiliaryInfoOffsetBox, GF_ISOM_BOX_TYPE_SAIO); return (GF_Box *)tmp; } - + #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err saio_Write(GF_Box *s, GF_BitStream *bs) @@ -8823,7 +8844,7 @@ GF_Err prft_Read(GF_Box *s,GF_BitStream *bs) GF_Box *prft_New() { - ISOM_DECL_BOX_ALLOC(GF_ProducerReferenceTimeBox, GF_ISOM_BOX_TYPE_PRFT); + ISOM_DECL_BOX_ALLOC(GF_ProducerReferenceTimeBox, GF_ISOM_BOX_TYPE_PRFT); gf_isom_full_box_init((GF_Box *)tmp); return (GF_Box *)tmp; } diff --git a/src/isomedia/box_code_drm.c b/src/isomedia/box_code_drm.c index faa820d..1c3adae 100644 --- a/src/isomedia/box_code_drm.c +++ b/src/isomedia/box_code_drm.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,19 +48,19 @@ GF_Err sinf_AddBox(GF_Box *s, GF_Box *a) { GF_ProtectionInfoBox *ptr = (GF_ProtectionInfoBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_FRMA: + case GF_ISOM_BOX_TYPE_FRMA: if (ptr->original_format) return GF_ISOM_INVALID_FILE; - ptr->original_format = (GF_OriginalFormatBox*)a; + ptr->original_format = (GF_OriginalFormatBox*)a; break; - case GF_ISOM_BOX_TYPE_SCHM: + case GF_ISOM_BOX_TYPE_SCHM: if (ptr->scheme_type) return GF_ISOM_INVALID_FILE; - ptr->scheme_type = (GF_SchemeTypeBox*)a; + ptr->scheme_type = (GF_SchemeTypeBox*)a; break; - case GF_ISOM_BOX_TYPE_SCHI: + case GF_ISOM_BOX_TYPE_SCHI: if (ptr->info) return GF_ISOM_INVALID_FILE; - ptr->info = (GF_SchemeInformationBox*)a; + ptr->info = (GF_SchemeInformationBox*)a; break; - default: + default: return gf_isom_box_add_default(s, a); } return GF_OK; @@ -524,7 +524,7 @@ GF_Err ohdr_Read(GF_Box *s, GF_BitStream *bs) gf_bs_read_data(bs, ptr->RightsIssuerURL, ri_len); ptr->RightsIssuerURL[ri_len]=0; } - + if (ptr->TextualHeadersLen) { ptr->TextualHeaders = (char *)gf_malloc(sizeof(char)*(ptr->TextualHeadersLen+1)); gf_bs_read_data(bs, ptr->TextualHeaders, ptr->TextualHeadersLen); @@ -548,7 +548,7 @@ GF_Err ohdr_Write(GF_Box *s, GF_BitStream *bs) gf_bs_write_u8(bs, ptr->EncryptionMethod); gf_bs_write_u8(bs, ptr->PaddingScheme); gf_bs_write_u64(bs, ptr->PlaintextLength); - + cid_len = ptr->ContentID ? (u32) strlen(ptr->ContentID) : 0; gf_bs_write_u16(bs, cid_len); ri_len = ptr->RightsIssuerURL ? (u32) strlen(ptr->RightsIssuerURL) : 0; @@ -613,7 +613,7 @@ GF_Err grpi_Read(GF_Box *s, GF_BitStream *bs) ptr->GroupID = gf_malloc(sizeof(char)*(gid_len+1)); gf_bs_read_data(bs, ptr->GroupID, gid_len); ptr->GroupID[gid_len]=0; - + ptr->GroupKey = (char *)gf_malloc(sizeof(char)*ptr->GKLength); gf_bs_read_data(bs, ptr->GroupKey, ptr->GKLength); ptr->size -= gid_len+ptr->GKLength; @@ -949,13 +949,13 @@ GF_Err pssh_Write(GF_Box *s, GF_BitStream *bs) if (ptr->version > 0) { u32 i; gf_bs_write_u32(bs, ptr->KID_count); - for (i=0; iKID_count; i++) + for (i=0; iKID_count; i++) gf_bs_write_data(bs, (char *) ptr->KIDs[i], 16); } if (ptr->private_data) { gf_bs_write_u32(bs, ptr->private_data_size); gf_bs_write_data(bs, (char *) ptr->private_data, ptr->private_data_size); - } else + } else gf_bs_write_u32(bs, 0); return GF_OK; } @@ -1398,7 +1398,7 @@ GF_Err senc_Size(GF_Box *s) GF_CENCSampleAuxInfo *sai = (GF_CENCSampleAuxInfo *)gf_list_get(ptr->samp_aux_info, i); if (! sai->IV_size) continue; ptr->size += sai->IV_size; - if (ptr->flags & 0x00000002) + if (ptr->flags & 0x00000002) ptr->size += 2 + 6*sai->subsample_count; } } @@ -1427,16 +1427,16 @@ GF_Err adkm_AddBox(GF_Box *s, GF_Box *a) { GF_AdobeDRMKeyManagementSystemBox *ptr = (GF_AdobeDRMKeyManagementSystemBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_AHDR: + case GF_ISOM_BOX_TYPE_AHDR: if (ptr->header) return GF_ISOM_INVALID_FILE; - ptr->header = (GF_AdobeDRMHeaderBox *)a; + ptr->header = (GF_AdobeDRMHeaderBox *)a; break; - case GF_ISOM_BOX_TYPE_ADAF: + case GF_ISOM_BOX_TYPE_ADAF: if (ptr->au_format) return GF_ISOM_INVALID_FILE; - ptr->au_format = (GF_AdobeDRMAUFormatBox *)a; + ptr->au_format = (GF_AdobeDRMAUFormatBox *)a; break; - default: + default: return gf_isom_box_add_default(s, a); } return GF_OK; @@ -1506,12 +1506,12 @@ GF_Err ahdr_AddBox(GF_Box *s, GF_Box *a) { GF_AdobeDRMHeaderBox *ptr = (GF_AdobeDRMHeaderBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_APRM: + case GF_ISOM_BOX_TYPE_APRM: if (ptr->std_enc_params) return GF_ISOM_INVALID_FILE; - ptr->std_enc_params = (GF_AdobeStdEncryptionParamsBox *)a; + ptr->std_enc_params = (GF_AdobeStdEncryptionParamsBox *)a; break; - default: + default: return gf_isom_box_add_default(s, a); } return GF_OK; @@ -1574,16 +1574,16 @@ GF_Err aprm_AddBox(GF_Box *s, GF_Box *a) { GF_AdobeStdEncryptionParamsBox *ptr = (GF_AdobeStdEncryptionParamsBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_AHDR: + case GF_ISOM_BOX_TYPE_AHDR: if (ptr->enc_info) return GF_ISOM_INVALID_FILE; - ptr->enc_info = (GF_AdobeEncryptionInfoBox *)a; + ptr->enc_info = (GF_AdobeEncryptionInfoBox *)a; break; - case GF_ISOM_BOX_TYPE_ADAF: + case GF_ISOM_BOX_TYPE_ADAF: if (ptr->key_info) return GF_ISOM_INVALID_FILE; - ptr->key_info = (GF_AdobeKeyInfoBox *)a; + ptr->key_info = (GF_AdobeKeyInfoBox *)a; break; - default: + default: return gf_isom_box_add_default(s, a); } return GF_OK; @@ -1718,11 +1718,11 @@ GF_Err akey_AddBox(GF_Box *s, GF_Box *a) { GF_AdobeKeyInfoBox *ptr = (GF_AdobeKeyInfoBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_FLXS: + case GF_ISOM_BOX_TYPE_FLXS: if (ptr->params) return GF_ISOM_INVALID_FILE; - ptr->params = (GF_AdobeFlashAccessParamsBox *)a; + ptr->params = (GF_AdobeFlashAccessParamsBox *)a; break; - default: + default: return gf_isom_box_add_default(s, a); } return GF_OK; @@ -1817,7 +1817,7 @@ GF_Err flxs_Size(GF_Box *s) GF_AdobeFlashAccessParamsBox *ptr = (GF_AdobeFlashAccessParamsBox*)s; e = gf_isom_box_get_size(s); if (e) return e; - if (ptr->metadata) + if (ptr->metadata) ptr->size += strlen(ptr->metadata) + 1; return GF_OK; } diff --git a/src/isomedia/box_code_meta.c b/src/isomedia/box_code_meta.c index 8140919..a58b677 100644 --- a/src/isomedia/box_code_meta.c +++ b/src/isomedia/box_code_meta.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -52,36 +52,36 @@ GF_Err meta_AddBox(GF_Box *s, GF_Box *a) { GF_MetaBox *ptr = (GF_MetaBox *)s; switch (a->type) { - case GF_ISOM_BOX_TYPE_HDLR: + case GF_ISOM_BOX_TYPE_HDLR: if (ptr->handler) return GF_ISOM_INVALID_FILE; - ptr->handler = (GF_HandlerBox*)a; + ptr->handler = (GF_HandlerBox*)a; break; - case GF_ISOM_BOX_TYPE_PITM: + case GF_ISOM_BOX_TYPE_PITM: if (ptr->primary_resource) return GF_ISOM_INVALID_FILE; - ptr->primary_resource = (GF_PrimaryItemBox*)a; + ptr->primary_resource = (GF_PrimaryItemBox*)a; break; - case GF_ISOM_BOX_TYPE_DINF: + case GF_ISOM_BOX_TYPE_DINF: if (ptr->file_locations) return GF_ISOM_INVALID_FILE; - ptr->file_locations = (GF_DataInformationBox*)a; + ptr->file_locations = (GF_DataInformationBox*)a; break; - case GF_ISOM_BOX_TYPE_ILOC: + case GF_ISOM_BOX_TYPE_ILOC: if (ptr->item_locations) return GF_ISOM_INVALID_FILE; - ptr->item_locations = (GF_ItemLocationBox*)a; + ptr->item_locations = (GF_ItemLocationBox*)a; break; - case GF_ISOM_BOX_TYPE_IPRO: + case GF_ISOM_BOX_TYPE_IPRO: if (ptr->protections) return GF_ISOM_INVALID_FILE; - ptr->protections = (GF_ItemProtectionBox*)a; + ptr->protections = (GF_ItemProtectionBox*)a; break; - case GF_ISOM_BOX_TYPE_IINF: + case GF_ISOM_BOX_TYPE_IINF: if (ptr->item_infos) return GF_ISOM_INVALID_FILE; - ptr->item_infos = (GF_ItemInfoBox*)a; + ptr->item_infos = (GF_ItemInfoBox*)a; break; //case ???: ptr->IPMP_control = (???*)a; break; - case GF_ISOM_BOX_TYPE_XML: - case GF_ISOM_BOX_TYPE_BXML: - case GF_ISOM_BOX_TYPE_ILST: - default: - return gf_isom_box_add_default(s, a); + case GF_ISOM_BOX_TYPE_XML: + case GF_ISOM_BOX_TYPE_BXML: + case GF_ISOM_BOX_TYPE_ILST: + default: + return gf_isom_box_add_default(s, a); } return GF_OK; } @@ -296,22 +296,28 @@ GF_Box *iloc_New() return (GF_Box *)tmp; } +void iloc_entry_del(GF_ItemLocationEntry *location) +{ + u32 j, extent_count; + extent_count = gf_list_count(location->extent_entries); + for (j = 0; j < extent_count; j++) { + GF_ItemExtentEntry *extent = (GF_ItemExtentEntry *)gf_list_get(location->extent_entries, j); + gf_free(extent); + } + gf_list_del(location->extent_entries); + gf_free(location); +} + void iloc_del(GF_Box *s) { - u32 i, j, item_count, extent_count; + u32 i, item_count; GF_ItemLocationBox *ptr = (GF_ItemLocationBox *)s; if (ptr == NULL) return; item_count = gf_list_count(ptr->location_entries); if (item_count) { for (i = 0; i < item_count; i++) { GF_ItemLocationEntry *location = (GF_ItemLocationEntry *)gf_list_get(ptr->location_entries, i); - extent_count = gf_list_count(location->extent_entries); - for (j = 0; j < extent_count; j++) { - GF_ItemExtentEntry *extent = (GF_ItemExtentEntry *)gf_list_get(location->extent_entries, j); - gf_free(extent); - } - gf_list_del(location->extent_entries); - gf_free(location); + iloc_entry_del(location); } gf_list_del(ptr->location_entries); } @@ -424,7 +430,7 @@ GF_Err pitm_Read(GF_Box *s, GF_BitStream *bs) GF_Err e; GF_PrimaryItemBox *ptr = (GF_PrimaryItemBox *)s; e = gf_isom_full_box_read(s, bs); - if (e) return e; + if (e) return e; ptr->item_ID = gf_bs_read_u16(bs); return GF_OK; } @@ -478,9 +484,9 @@ void ipro_del(GF_Box *s) GF_Err ipro_AddBox(GF_Box *s, GF_Box *a) { GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; - if (a->type == GF_ISOM_BOX_TYPE_SINF) + if (a->type == GF_ISOM_BOX_TYPE_SINF) return gf_list_add(ptr->protection_information, a); - else + else return gf_isom_box_add_default(s, a); } GF_Err ipro_Read(GF_Box *s, GF_BitStream *bs) @@ -560,7 +566,7 @@ GF_Err infe_Read(GF_Box *s, GF_BitStream *bs) if (ptr == NULL) return GF_BAD_PARAM; e = gf_isom_full_box_read(s, bs); if (e) return e; - + ptr->item_ID = gf_bs_read_u16(bs); ptr->item_protection_index = gf_bs_read_u16(bs); ptr->size -= 4; @@ -569,7 +575,7 @@ GF_Err infe_Read(GF_Box *s, GF_BitStream *bs) if (buf_len != gf_bs_read_data(bs, buf, buf_len)) { gf_free(buf); return GF_ISOM_INVALID_FILE; - } + } string_len = 1; string_start = 0; for (i = 0; i < buf_len; i++) { @@ -674,8 +680,8 @@ GF_Err iinf_Read(GF_Box *s, GF_BitStream *bs) if (ptr->sizesize) return GF_ISOM_INVALID_FILE; if (a->type == GF_ISOM_BOX_TYPE_INFE) - gf_list_add(ptr->item_infos, a); - else + gf_list_add(ptr->item_infos, a); + else gf_isom_box_del(a); count --; } diff --git a/src/isomedia/box_dump.c b/src/isomedia/box_dump.c index 669c693..b5f0c45 100644 --- a/src/isomedia/box_dump.c +++ b/src/isomedia/box_dump.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -192,13 +192,13 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) return chpl_dump(a, trace); case GF_ISOM_BOX_TYPE_PDIN: return dpin_dump(a, trace); - case GF_ISOM_BOX_TYPE_SBGP: + case GF_ISOM_BOX_TYPE_SBGP: return sbgp_dump(a, trace); - case GF_ISOM_BOX_TYPE_SGPD: + case GF_ISOM_BOX_TYPE_SGPD: return sgpd_dump(a, trace); - case GF_ISOM_BOX_TYPE_SAIZ: + case GF_ISOM_BOX_TYPE_SAIZ: return saiz_dump(a, trace); - case GF_ISOM_BOX_TYPE_SAIO: + case GF_ISOM_BOX_TYPE_SAIO: return saio_dump(a, trace); case GF_ISOM_BOX_TYPE_RTP_STSD: @@ -252,9 +252,9 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) case GF_ISOM_BOX_TYPE_NAME: return name_dump(a, trace); - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - return ftyp_dump(a, trace); + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + return ftyp_dump(a, trace); case GF_ISOM_BOX_TYPE_PADB: return padb_dump(a, trace); @@ -276,9 +276,9 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) case GF_ISOM_BOX_TYPE_TRUN: return trun_dump(a, trace); case GF_ISOM_BOX_TYPE_TFDT: - return tfdt_dump(a, trace); + return tfdt_dump(a, trace); #endif - + case GF_ISOM_BOX_TYPE_SUBS: return subs_dump(a, trace); case GF_ISOM_BOX_TYPE_RVCC: @@ -304,34 +304,35 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) case GF_ISOM_BOX_TYPE_D263: return gppc_dump(a, trace); - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: return avcc_dump(a, trace); - case GF_ISOM_BOX_TYPE_HVCC: - case GF_ISOM_BOX_TYPE_SHCC: + case GF_ISOM_BOX_TYPE_HVCC: + case GF_ISOM_BOX_TYPE_SHCC: return hvcc_dump(a, trace); case GF_ISOM_BOX_TYPE_BTRT: return btrt_dump(a, trace); case GF_ISOM_BOX_TYPE_M4DS: return m4ds_dump(a, trace); - case GF_ISOM_BOX_TYPE_AVC1: - case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_SVC1: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: return mp4v_dump(a, trace); case GF_ISOM_BOX_TYPE_PASP: return pasp_dump(a, trace); case GF_ISOM_BOX_TYPE_FTAB: return ftab_dump(a, trace); - case GF_ISOM_BOX_TYPE_TX3G: + case GF_ISOM_BOX_TYPE_TX3G: return tx3g_dump(a, trace); case GF_ISOM_BOX_TYPE_TEXT: return text_dump(a, trace); @@ -483,11 +484,14 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) case GF_ISOM_BOX_TYPE_UUID: switch ( ((GF_UnknownUUIDBox *)a)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: return piff_tenc_dump(a, trace); - case GF_ISOM_BOX_UUID_PSEC: return piff_psec_dump(a, trace); - case GF_ISOM_BOX_UUID_PSSH: return piff_pssh_dump(a, trace); - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: + case GF_ISOM_BOX_UUID_TENC: + return piff_tenc_dump(a, trace); + case GF_ISOM_BOX_UUID_PSEC: + return piff_psec_dump(a, trace); + case GF_ISOM_BOX_UUID_PSSH: + return piff_pssh_dump(a, trace); + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: default: return defa_dump(a, trace); } @@ -515,7 +519,7 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) return metx_dump(a, trace); #endif - /*Adobe's protection boxes*/ + /*Adobe's protection boxes*/ case GF_ISOM_BOX_TYPE_ADKM: return adkm_dump(a, trace); case GF_ISOM_BOX_TYPE_AHDR: @@ -530,8 +534,8 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) return akey_dump(a, trace); case GF_ISOM_BOX_TYPE_FLXS: return flxs_dump(a, trace); - - default: + + default: return defa_dump(a, trace); } } @@ -553,7 +557,7 @@ void gf_box_dump_done(char *name, GF_Box *ptr, FILE *trace) if (ptr && ptr->other_boxes) { gf_box_array_dump(ptr->other_boxes, trace); } - if (name) + if (name) fprintf(trace, "\n", name); } @@ -625,11 +629,21 @@ GF_Err reftype_dump(GF_Box *a, FILE * trace) p->type = p->reference_type; switch (a->type) { - case GF_ISOM_BOX_TYPE_HINT: s = "Hint"; break; - case GF_ISOM_BOX_TYPE_DPND: s = "Stream"; break; - case GF_ISOM_BOX_TYPE_MPOD: s = "OD"; break; - case GF_ISOM_BOX_TYPE_SYNC: s = "Sync"; break; - case GF_ISOM_BOX_TYPE_CHAP: s = "Chapter"; break; + case GF_ISOM_BOX_TYPE_HINT: + s = "Hint"; + break; + case GF_ISOM_BOX_TYPE_DPND: + s = "Stream"; + break; + case GF_ISOM_BOX_TYPE_MPOD: + s = "OD"; + break; + case GF_ISOM_BOX_TYPE_SYNC: + s = "Sync"; + break; + case GF_ISOM_BOX_TYPE_CHAP: + s = "Chapter"; + break; default: s = (char *) gf_4cc_to_str(a->type); break; @@ -812,7 +826,7 @@ GF_Err stbl_dump(GF_Box *a, FILE * trace) gf_box_dump(saio, trace); } } - + gf_box_dump_done("SampleTableBox", a, trace); return GF_OK; } @@ -1097,7 +1111,7 @@ GF_Err gnrv_dump(GF_Box *a, FILE * trace) { GF_GenericVisualSampleEntryBox *p = (GF_GenericVisualSampleEntryBox *)a; fprintf(trace, "\n", - p->dataReferenceIndex, p->version, p->revision, p->vendor, p->temporal_quality, p->spatial_quality, p->Width, p->Height, p->horiz_res, p->vert_res, p->compressor_name+1, p->bit_depth); + p->dataReferenceIndex, p->version, p->revision, p->vendor, p->temporal_quality, p->spatial_quality, p->Width, p->Height, p->horiz_res, p->vert_res, p->compressor_name+1, p->bit_depth); a->type = p->EntryType; DumpBox(a, trace); a->type = GF_ISOM_BOX_TYPE_GNRV; @@ -1109,7 +1123,7 @@ GF_Err gnra_dump(GF_Box *a, FILE * trace) { GF_GenericAudioSampleEntryBox *p = (GF_GenericAudioSampleEntryBox *)a; fprintf(trace, "\n", - p->dataReferenceIndex, p->version, p->revision, p->vendor, p->channel_count, p->bitspersample, p->samplerate_hi); + p->dataReferenceIndex, p->version, p->revision, p->vendor, p->channel_count, p->bitspersample, p->samplerate_hi); a->type = p->EntryType; DumpBox(a, trace); a->type = GF_ISOM_BOX_TYPE_GNRA; @@ -1199,7 +1213,7 @@ GF_Err ctts_dump(GF_Box *a, FILE * trace) gf_full_box_dump(a, trace); nb_samples = 0; - for (i=0; inb_entries;i++) { + for (i=0; inb_entries; i++) { fprintf(trace, "\n", p->entries[i].decodingOffset, p->entries[i].sampleCount); nb_samples += p->entries[i].sampleCount; } @@ -1394,22 +1408,46 @@ GF_Err sdtp_dump(GF_Box *a, FILE * trace) u8 flag = p->sample_info[i]; fprintf(trace, "> 4) & 3) { - case 0: fprintf(trace, "dependsOnOther=\"unknown\" "); break; - case 1: fprintf(trace, "dependsOnOther=\"yes\" "); break; - case 2: fprintf(trace, "dependsOnOther=\"no\" "); break; - case 3: fprintf(trace, "dependsOnOther=\"!! RESERVED !!\" "); break; + case 0: + fprintf(trace, "dependsOnOther=\"unknown\" "); + break; + case 1: + fprintf(trace, "dependsOnOther=\"yes\" "); + break; + case 2: + fprintf(trace, "dependsOnOther=\"no\" "); + break; + case 3: + fprintf(trace, "dependsOnOther=\"!! RESERVED !!\" "); + break; } switch ( (flag >> 2) & 3) { - case 0: fprintf(trace, "dependedOn=\"unknown\" "); break; - case 1: fprintf(trace, "dependedOn=\"yes\" "); break; - case 2: fprintf(trace, "dependedOn=\"no\" "); break; - case 3: fprintf(trace, "dependedOn=\"!! RESERVED !!\" "); break; + case 0: + fprintf(trace, "dependedOn=\"unknown\" "); + break; + case 1: + fprintf(trace, "dependedOn=\"yes\" "); + break; + case 2: + fprintf(trace, "dependedOn=\"no\" "); + break; + case 3: + fprintf(trace, "dependedOn=\"!! RESERVED !!\" "); + break; } switch ( flag & 3) { - case 0: fprintf(trace, "hasRedundancy=\"unknown\" "); break; - case 1: fprintf(trace, "hasRedundancy=\"yes\" "); break; - case 2: fprintf(trace, "hasRedundancy=\"no\" "); break; - case 3: fprintf(trace, "hasRedundancy=\"!! RESERVED !!\" "); break; + case 0: + fprintf(trace, "hasRedundancy=\"unknown\" "); + break; + case 1: + fprintf(trace, "hasRedundancy=\"yes\" "); + break; + case 2: + fprintf(trace, "hasRedundancy=\"no\" "); + break; + case 3: + fprintf(trace, "hasRedundancy=\"!! RESERVED !!\" "); + break; } fprintf(trace, " />\n"); } @@ -1482,7 +1520,7 @@ GF_Err tkhd_dump(GF_Box *a, FILE * trace) fprintf(trace, "creationTime, LLD_CAST p->modificationTime, p->trackID, LLD_CAST p->duration); + LLD_CAST p->creationTime, LLD_CAST p->modificationTime, p->trackID, LLD_CAST p->duration); if (p->alternate_group) fprintf(trace, " AlternateGroupID=\"%d\"", p->alternate_group); if (p->volume) { @@ -1496,9 +1534,9 @@ GF_Err tkhd_dump(GF_Box *a, FILE * trace) fprintf(trace, "", - p->matrix[0], p->matrix[1], p->matrix[2], - p->matrix[3], p->matrix[4], p->matrix[5], - p->matrix[6], p->matrix[7], p->matrix[8]); + p->matrix[0], p->matrix[1], p->matrix[2], + p->matrix[3], p->matrix[4], p->matrix[5], + p->matrix[6], p->matrix[7], p->matrix[8]); } DumpBox(a, trace); gf_full_box_dump(a, trace); @@ -1548,7 +1586,7 @@ GF_Err ftyp_dump(GF_Box *a, FILE * trace) u32 i; p = (GF_FileTypeBox *)a; - fprintf(trace, "<%s MajorBrand=\"%s\" MinorVersion=\"%d\">\n", (a->type == GF_ISOM_BOX_TYPE_FTYP ? "FileTypeBox" : "SegmentTypeBox"), gf_4cc_to_str(p->majorBrand), p->minorVersion); + fprintf(trace, "<%s MajorBrand=\"%s\" MinorVersion=\"%d\">\n", (a->type == GF_ISOM_BOX_TYPE_FTYP ? "FileTypeBox" : "SegmentTypeBox"), gf_4cc_to_str(p->majorBrand), p->minorVersion); DumpBox(a, trace); for (i=0; ialtCount; i++) { @@ -1589,7 +1627,7 @@ GF_Err stsf_dump(GF_Box *a, FILE * trace) for (i=0; ientryList, i); fprintf(trace, "\n", ent->SampleNumber, ent->fragmentCount); - for (j=0;jfragmentCount;j++) fprintf(trace, "\n", ent->fragmentSizes[j]); + for (j=0; jfragmentCount; j++) fprintf(trace, "\n", ent->fragmentSizes[j]); fprintf(trace, "\n"); } @@ -1603,12 +1641,24 @@ GF_Err gppa_dump(GF_Box *a, FILE * trace) char *szName; GF_3GPPAudioSampleEntryBox *p = (GF_3GPPAudioSampleEntryBox *)a; switch (p->type) { - case GF_ISOM_SUBTYPE_3GP_AMR: szName = "AMRSampleDescription"; break; - case GF_ISOM_SUBTYPE_3GP_AMR_WB: szName = "AMR_WB_SampleDescription"; break; - case GF_ISOM_SUBTYPE_3GP_EVRC: szName = "EVRCSampleDescription"; break; - case GF_ISOM_SUBTYPE_3GP_QCELP: szName = "QCELPSampleDescription"; break; - case GF_ISOM_SUBTYPE_3GP_SMV: szName = "SMVSampleDescription"; break; - default: szName = "3GPAudioSampleDescription"; break; + case GF_ISOM_SUBTYPE_3GP_AMR: + szName = "AMRSampleDescription"; + break; + case GF_ISOM_SUBTYPE_3GP_AMR_WB: + szName = "AMR_WB_SampleDescription"; + break; + case GF_ISOM_SUBTYPE_3GP_EVRC: + szName = "EVRCSampleDescription"; + break; + case GF_ISOM_SUBTYPE_3GP_QCELP: + szName = "QCELPSampleDescription"; + break; + case GF_ISOM_SUBTYPE_3GP_SMV: + szName = "SMVSampleDescription"; + break; + default: + szName = "3GPAudioSampleDescription"; + break; } fprintf(trace, "<%sBox", szName); base_audio_entry_dump((GF_AudioSampleEntryBox *)p, trace); @@ -1631,8 +1681,12 @@ GF_Err gppv_dump(GF_Box *a, FILE * trace) GF_3GPPVisualSampleEntryBox *p = (GF_3GPPVisualSampleEntryBox *)a; switch (p->type) { - case GF_ISOM_SUBTYPE_3GP_H263: szName = "H263SampleDescription"; break; - default: szName = "3GPVisualSampleDescription"; break; + case GF_ISOM_SUBTYPE_3GP_H263: + szName = "H263SampleDescription"; + break; + default: + szName = "3GPVisualSampleDescription"; + break; } fprintf(trace, "<%sBox", szName); base_visual_entry_dump((GF_VisualSampleEntryBox *)p, trace); @@ -1698,9 +1752,9 @@ GF_Err avcc_dump(GF_Box *a, FILE * trace) fprintf(trace, "<%sConfigurationBox>\n", name); fprintf(trace, "<%sDecoderConfigurationRecord configurationVersion=\"%d\" AVCProfileIndication=\"%d\" profile_compatibility=\"%d\" AVCLevelIndication=\"%d\" nal_unit_size=\"%d\"", - name, p->config->configurationVersion, p->config->AVCProfileIndication, p->config->profile_compatibility, p->config->AVCLevelIndication, p->config->nal_unit_size); + name, p->config->configurationVersion, p->config->AVCProfileIndication, p->config->profile_compatibility, p->config->AVCLevelIndication, p->config->nal_unit_size); - if (p->type==GF_ISOM_BOX_TYPE_SVCC) + if (p->type==GF_ISOM_BOX_TYPE_SVCC) fprintf(trace, " complete_representation=\"%d\"", p->config->complete_representation); if (p->type==GF_ISOM_BOX_TYPE_AVCC) { @@ -1773,7 +1827,7 @@ GF_Err hvcc_dump(GF_Box *a, FILE * trace) fprintf(trace, "parallelismType=\"%d\" ", p->config->parallelismType); fprintf(trace, "chroma_format=\"%d\" luma_bit_depth=\"%d\" chroma_bit_depth=\"%d\" avgFrameRate=\"%d\" constantFrameRate=\"%d\" numTemporalLayers=\"%d\" temporalIdNested=\"%d\"", - p->config->chromaFormat, p->config->luma_bit_depth, p->config->chroma_bit_depth, p->config->avgFrameRate, p->config->constantFrameRate, p->config->numTemporalLayers, p->config->temporalIdNested); + p->config->chromaFormat, p->config->luma_bit_depth, p->config->chroma_bit_depth, p->config->avgFrameRate, p->config->constantFrameRate, p->config->numTemporalLayers, p->config->temporalIdNested); if (p->config->is_shvc) { fprintf(trace, " completeRepresentation=\"%d\" nonHEVCBaseLayer=\"%d\" numLayers=\"%d\" scalabilityMask=\"0x%02X\" ", p->config->complete_representation, p->config->non_hevc_base_layer, p->config->num_layers, p->config->scalability_mask); @@ -1877,7 +1931,7 @@ GF_Err tx3g_dump(GF_Box *a, FILE * trace) { GF_Tx3gSampleEntryBox *p = (GF_Tx3gSampleEntryBox *)a; fprintf(trace, "dataReferenceIndex, p->displayFlags, p->horizontal_justification, p->vertical_justification); + p->dataReferenceIndex, p->displayFlags, p->horizontal_justification, p->vertical_justification); gpp_dump_rgba8(trace, "background-color", p->back_color); fprintf(trace, ">\n"); @@ -1898,7 +1952,7 @@ GF_Err text_dump(GF_Box *a, FILE * trace) { GF_TextSampleEntryBox *p = (GF_TextSampleEntryBox *)a; fprintf(trace, "dataReferenceIndex, p->displayFlags, p->textJustification); + p->dataReferenceIndex, p->displayFlags, p->textJustification); if (p->textName) fprintf(trace, "textName=%s ", p->textName); gpp_dump_rgb16(trace, "background-color", p->background_color); @@ -2092,7 +2146,7 @@ GF_Err iloc_dump(GF_Box *a, FILE * trace) DumpBox(a, trace); gf_full_box_dump(a, trace); count = gf_list_count(p->location_entries); - for (i=0;ilocation_entries, i); count2 = gf_list_count(ie->extent_entries); fprintf(trace, "\n", ie->item_ID, ie->data_reference_index, LLD_CAST ie->base_offset); @@ -2339,7 +2393,7 @@ GF_Err ghnt_dump(GF_Box *a, FILE * trace) p = (GF_HintSampleEntryBox *)a; fprintf(trace, "\n", - gf_4cc_to_str(p->type), p->dataReferenceIndex, p->HintTrackVersion, p->LastCompatibleVersion, p->MaxPacketSize); + gf_4cc_to_str(p->type), p->dataReferenceIndex, p->HintTrackVersion, p->LastCompatibleVersion, p->MaxPacketSize); DumpBox(a, trace); gf_box_array_dump(p->HintDataTable, trace); @@ -2503,8 +2557,8 @@ GF_Err traf_dump(GF_Box *a, FILE * trace) static void frag_dump_sample_flags(FILE * trace, u32 flags) { fprintf(trace, " SamplePadding=\"%d\" Sync=\"%d\" DegradationPriority=\"%d\" IsLeading=\"%d\" DependsOn=\"%d\" IsDependedOn=\"%d\" HasRedundancy=\"%d\"", - GF_ISOM_GET_FRAG_PAD(flags), GF_ISOM_GET_FRAG_SYNC(flags), GF_ISOM_GET_FRAG_DEG(flags), - GF_ISOM_GET_FRAG_LEAD(flags), GF_ISOM_GET_FRAG_DEPENDS(flags), GF_ISOM_GET_FRAG_DEPENDED(flags), GF_ISOM_GET_FRAG_REDUNDANT(flags)); + GF_ISOM_GET_FRAG_PAD(flags), GF_ISOM_GET_FRAG_SYNC(flags), GF_ISOM_GET_FRAG_DEG(flags), + GF_ISOM_GET_FRAG_LEAD(flags), GF_ISOM_GET_FRAG_DEPENDS(flags), GF_ISOM_GET_FRAG_DEPENDED(flags), GF_ISOM_GET_FRAG_REDUNDANT(flags)); } @@ -2610,12 +2664,12 @@ GF_Err DTE_Dump(GF_List *dte, FILE * trace) case 2: s_p = (GF_SampleDTE *) p; fprintf(trace, "\n", - s_p->dataLength, s_p->byteOffset, s_p->sampleNumber, s_p->trackRefIndex); + s_p->dataLength, s_p->byteOffset, s_p->sampleNumber, s_p->trackRefIndex); break; case 3: sd_p = (GF_StreamDescDTE *) p; fprintf(trace, "\n", - sd_p->dataLength, sd_p->byteOffset, sd_p->streamDescIndex, sd_p->trackRefIndex); + sd_p->dataLength, sd_p->byteOffset, sd_p->streamDescIndex, sd_p->trackRefIndex); break; default: fprintf(trace, "\n"); @@ -2672,10 +2726,10 @@ GF_Err gf_isom_dump_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 Sampl pck = (GF_RTPPacket *)gf_list_get(s->packetTable, i); fprintf(trace, "P_bit, pck->X_bit, pck->M_bit, pck->payloadType); + i+1, pck->P_bit, pck->X_bit, pck->M_bit, pck->payloadType); fprintf(trace, " SequenceNumber=\"%d\" RepeatedPacket=\"%d\" DropablePacket=\"%d\" RelativeTransmissionTime=\"%d\" FullPacketSize=\"%d\">\n", - pck->SequenceNumber, pck->R_bit, pck->B_bit, pck->relativeTransTime, gf_isom_hint_rtp_length(pck)); + pck->SequenceNumber, pck->R_bit, pck->B_bit, pck->relativeTransTime, gf_isom_hint_rtp_length(pck)); //TLV is made of Boxes @@ -2812,15 +2866,27 @@ static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dum fprintf(dump, "horizontal_justification) { - case 1: fprintf(dump, "center"); break; - case -1: fprintf(dump, "right"); break; - default: fprintf(dump, "left"); break; + case 1: + fprintf(dump, "center"); + break; + case -1: + fprintf(dump, "right"); + break; + default: + fprintf(dump, "left"); + break; } fprintf(dump, "\" verticalJustification=\""); switch (txt->vertical_justification) { - case 1: fprintf(dump, "center"); break; - case -1: fprintf(dump, "bottom"); break; - default: fprintf(dump, "top"); break; + case 1: + fprintf(dump, "center"); + break; + case -1: + fprintf(dump, "bottom"); + break; + default: + fprintf(dump, "top"); + break; } fprintf(dump, "\" "); gpp_dump_rgba8(dump, "backColor", txt->back_color); @@ -2841,11 +2907,21 @@ static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dum if (has_scroll) { u32 mode = (txt->displayFlags & GF_TXT_SCROLL_DIRECTION)>>7; switch (mode) { - case GF_TXT_SCROLL_CREDITS: fprintf(dump, " scrollMode=\"Credits\""); break; - case GF_TXT_SCROLL_MARQUEE: fprintf(dump, " scrollMode=\"Marquee\""); break; - case GF_TXT_SCROLL_DOWN: fprintf(dump, " scrollMode=\"Down\""); break; - case GF_TXT_SCROLL_RIGHT: fprintf(dump, " scrollMode=\"Right\""); break; - default: fprintf(dump, " scrollMode=\"Unknown\""); break; + case GF_TXT_SCROLL_CREDITS: + fprintf(dump, " scrollMode=\"Credits\""); + break; + case GF_TXT_SCROLL_MARQUEE: + fprintf(dump, " scrollMode=\"Marquee\""); + break; + case GF_TXT_SCROLL_DOWN: + fprintf(dump, " scrollMode=\"Down\""); + break; + case GF_TXT_SCROLL_RIGHT: + fprintf(dump, " scrollMode=\"Right\""); + break; + default: + fprintf(dump, " scrollMode=\"Unknown\""); + break; } } fprintf(dump, ">\n"); @@ -2938,11 +3014,21 @@ static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dum } else { switch (utf16Line[j]) { - case '\'': fprintf(dump, "'"); break; - case '\"': fprintf(dump, """); break; - case '&': fprintf(dump, "&"); break; - case '>': fprintf(dump, ">"); break; - case '<': fprintf(dump, "<"); break; + case '\'': + fprintf(dump, "'"); + break; + case '\"': + fprintf(dump, """); + break; + case '&': + fprintf(dump, "&"); + break; + case '>': + fprintf(dump, ">"); + break; + case '<': + fprintf(dump, "<"); + break; default: if (utf16Line[j] < 128) { fprintf(dump, "%c", (u8) utf16Line[j]); @@ -2988,7 +3074,7 @@ static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dum gpp_print_char_offsets(dump, ht->startcharoffset, ht->endcharoffset, shift_offset, so_count); fprintf(dump, "URL=\"%s\" URLToolTip=\"%s\"/>\n", ht->URL ? ht->URL : "", ht->URL_hint ? ht->URL_hint : ""); } - break; + break; case GF_ISOM_BOX_TYPE_BLNK: fprintf(dump, "startcharoffset, ((GF_TextBlinkBox *)a)->endcharoffset, shift_offset, so_count); @@ -3011,7 +3097,7 @@ static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dum } fprintf(dump, "\n"); } - break; + break; } } @@ -3086,7 +3172,7 @@ static GF_Err gf_isom_dump_srt_track(GF_ISOFile *the_file, u32 track, FILE *dump if (!txt->len) { fprintf(dump, "\n"); - }else { + } else { u32 styles, char_num, new_styles; u16 utf16Line[10000]; @@ -3102,71 +3188,71 @@ static GF_Err gf_isom_dump_srt_track(GF_ISOFile *the_file, u32 track, FILE *dump len = (u32) res; utf16Line[len] = 0; } - char_num = 0; - styles = 0; - new_styles = txtd->default_style.style_flags; - for (j=0; jstyles) { - new_styles = txtd->default_style.style_flags; - for (k=0; kstyles->entry_count; k++) { - if (txt->styles->styles[k].startCharOffset>char_num) continue; - if (txt->styles->styles[k].endCharOffsetstyles->styles[k].style_flags & (GF_TXT_STYLE_ITALIC | GF_TXT_STYLE_BOLD | GF_TXT_STYLE_UNDERLINED)) { - new_styles = txt->styles->styles[k].style_flags; - break; - } - } - } - if (new_styles != styles) { - if ((new_styles & GF_TXT_STYLE_BOLD) && !(styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); - if ((new_styles & GF_TXT_STYLE_ITALIC) && !(styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); - if ((new_styles & GF_TXT_STYLE_UNDERLINED) && !(styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); - - if ((styles & GF_TXT_STYLE_BOLD) && !(new_styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); - if ((styles & GF_TXT_STYLE_ITALIC) && !(new_styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); - if ((styles & GF_TXT_STYLE_UNDERLINED) && !(new_styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); - - styles = new_styles; - } - - /*not sure if styles must be reseted at line breaks in srt...*/ - is_new_line = 0; - if ((utf16Line[j]=='\n') || (utf16Line[j]=='\r') ) { - if ((utf16Line[j]=='\r') && (utf16Line[j+1]=='\n')) j++; - fprintf(dump, "\n"); - is_new_line = 1; - } - - if (!is_new_line) { - size_t sl; - char szChar[30]; - s16 swT[2], *swz; - swT[0] = utf16Line[j]; - swT[1] = 0; - swz= (s16 *)swT; - sl = gf_utf8_wcstombs(szChar, 30, (const unsigned short **) &swz); - if (sl == (size_t)-1) sl=0; + char_num = 0; + styles = 0; + new_styles = txtd->default_style.style_flags; + for (j=0; jstyles) { + new_styles = txtd->default_style.style_flags; + for (k=0; kstyles->entry_count; k++) { + if (txt->styles->styles[k].startCharOffset>char_num) continue; + if (txt->styles->styles[k].endCharOffsetstyles->styles[k].style_flags & (GF_TXT_STYLE_ITALIC | GF_TXT_STYLE_BOLD | GF_TXT_STYLE_UNDERLINED)) { + new_styles = txt->styles->styles[k].style_flags; + break; + } + } + } + if (new_styles != styles) { + if ((new_styles & GF_TXT_STYLE_BOLD) && !(styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); + if ((new_styles & GF_TXT_STYLE_ITALIC) && !(styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); + if ((new_styles & GF_TXT_STYLE_UNDERLINED) && !(styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); + + if ((styles & GF_TXT_STYLE_BOLD) && !(new_styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); + if ((styles & GF_TXT_STYLE_ITALIC) && !(new_styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); + if ((styles & GF_TXT_STYLE_UNDERLINED) && !(new_styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); + + styles = new_styles; + } + + /*not sure if styles must be reseted at line breaks in srt...*/ + is_new_line = 0; + if ((utf16Line[j]=='\n') || (utf16Line[j]=='\r') ) { + if ((utf16Line[j]=='\r') && (utf16Line[j+1]=='\n')) j++; + fprintf(dump, "\n"); + is_new_line = 1; + } + + if (!is_new_line) { + size_t sl; + char szChar[30]; + s16 swT[2], *swz; + swT[0] = utf16Line[j]; + swT[1] = 0; + swz= (s16 *)swT; + sl = gf_utf8_wcstombs(szChar, 30, (const unsigned short **) &swz); + if (sl == (size_t)-1) sl=0; szChar[(u32) sl]=0; - fprintf(dump, "%s", szChar); - } - char_num++; - } - new_styles = 0; - if (new_styles != styles) { - if ((new_styles & GF_TXT_STYLE_BOLD) && !(styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); - if ((new_styles & GF_TXT_STYLE_ITALIC) && !(styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); - if ((new_styles & GF_TXT_STYLE_UNDERLINED) && !(styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); - - if ((styles & GF_TXT_STYLE_BOLD) && !(new_styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); - if ((styles & GF_TXT_STYLE_ITALIC) && !(new_styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); - if ((styles & GF_TXT_STYLE_UNDERLINED) && !(new_styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); - - styles = new_styles; - } - fprintf(dump, "\n"); + fprintf(dump, "%s", szChar); + } + char_num++; + } + new_styles = 0; + if (new_styles != styles) { + if ((new_styles & GF_TXT_STYLE_BOLD) && !(styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); + if ((new_styles & GF_TXT_STYLE_ITALIC) && !(styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); + if ((new_styles & GF_TXT_STYLE_UNDERLINED) && !(styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); + + if ((styles & GF_TXT_STYLE_BOLD) && !(new_styles & GF_TXT_STYLE_BOLD)) fprintf(dump, ""); + if ((styles & GF_TXT_STYLE_ITALIC) && !(new_styles & GF_TXT_STYLE_ITALIC)) fprintf(dump, ""); + if ((styles & GF_TXT_STYLE_UNDERLINED) && !(new_styles & GF_TXT_STYLE_UNDERLINED)) fprintf(dump, ""); + + styles = new_styles; + } + fprintf(dump, "\n"); } gf_isom_sample_del(&s); gf_isom_delete_text_sample(txt); @@ -3442,30 +3528,75 @@ static GF_Err apple_tag_dump(GF_Box *a, FILE * trace) char *name = "Unknown"; GF_ListItemBox *itune = (GF_ListItemBox *)a; switch (itune->type) { - case GF_ISOM_BOX_TYPE_0xA9NAM: name = "Name"; break; - case GF_ISOM_BOX_TYPE_0xA9CMT: name = "Comment"; break; - case GF_ISOM_BOX_TYPE_0xA9DAY: name = "Created"; break; - case GF_ISOM_BOX_TYPE_0xA9ART: name = "Artist"; break; - case GF_ISOM_BOX_TYPE_0xA9TRK: name = "Track"; break; - case GF_ISOM_BOX_TYPE_0xA9ALB: name = "Album"; break; - case GF_ISOM_BOX_TYPE_0xA9COM: name = "Compositor"; break; - case GF_ISOM_BOX_TYPE_0xA9WRT: name = "Writer"; break; - case GF_ISOM_BOX_TYPE_0xA9TOO: name = "Tool"; break; - case GF_ISOM_BOX_TYPE_0xA9CPY: name = "Copyright"; break; - case GF_ISOM_BOX_TYPE_0xA9DES: name = "Description"; break; + case GF_ISOM_BOX_TYPE_0xA9NAM: + name = "Name"; + break; + case GF_ISOM_BOX_TYPE_0xA9CMT: + name = "Comment"; + break; + case GF_ISOM_BOX_TYPE_0xA9DAY: + name = "Created"; + break; + case GF_ISOM_BOX_TYPE_0xA9ART: + name = "Artist"; + break; + case GF_ISOM_BOX_TYPE_0xA9TRK: + name = "Track"; + break; + case GF_ISOM_BOX_TYPE_0xA9ALB: + name = "Album"; + break; + case GF_ISOM_BOX_TYPE_0xA9COM: + name = "Compositor"; + break; + case GF_ISOM_BOX_TYPE_0xA9WRT: + name = "Writer"; + break; + case GF_ISOM_BOX_TYPE_0xA9TOO: + name = "Tool"; + break; + case GF_ISOM_BOX_TYPE_0xA9CPY: + name = "Copyright"; + break; + case GF_ISOM_BOX_TYPE_0xA9DES: + name = "Description"; + break; case GF_ISOM_BOX_TYPE_0xA9GEN: case GF_ISOM_BOX_TYPE_GNRE: - name = "Genre"; break; - case GF_ISOM_BOX_TYPE_aART: name = "AlbumArtist"; break; - case GF_ISOM_BOX_TYPE_PGAP: name = "Gapeless"; break; - case GF_ISOM_BOX_TYPE_DISK: name = "Disk"; break; - case GF_ISOM_BOX_TYPE_TRKN: name = "TrackNumber"; break; - case GF_ISOM_BOX_TYPE_TMPO: name = "Tempo"; break; - case GF_ISOM_BOX_TYPE_CPIL: name = "Compilation"; break; - case GF_ISOM_BOX_TYPE_COVR: name = "CoverArt"; no_dump = 1; break; - case GF_ISOM_BOX_TYPE_iTunesSpecificInfo: name = "iTunesSpecific"; no_dump = 1; break; - case GF_ISOM_BOX_TYPE_0xA9GRP: name = "Group"; break; - case GF_ISOM_ITUNE_ENCODER: name = "Encoder"; break; + name = "Genre"; + break; + case GF_ISOM_BOX_TYPE_aART: + name = "AlbumArtist"; + break; + case GF_ISOM_BOX_TYPE_PGAP: + name = "Gapeless"; + break; + case GF_ISOM_BOX_TYPE_DISK: + name = "Disk"; + break; + case GF_ISOM_BOX_TYPE_TRKN: + name = "TrackNumber"; + break; + case GF_ISOM_BOX_TYPE_TMPO: + name = "Tempo"; + break; + case GF_ISOM_BOX_TYPE_CPIL: + name = "Compilation"; + break; + case GF_ISOM_BOX_TYPE_COVR: + name = "CoverArt"; + no_dump = 1; + break; + case GF_ISOM_BOX_TYPE_iTunesSpecificInfo: + name = "iTunesSpecific"; + no_dump = 1; + break; + case GF_ISOM_BOX_TYPE_0xA9GRP: + name = "Group"; + break; + case GF_ISOM_ITUNE_ENCODER: + name = "Encoder"; + break; } fprintf(trace, "<%sBox", name); if (!no_dump) { @@ -3522,7 +3653,7 @@ GF_Err abst_dump(GF_Box *a, FILE * trace) u32 i; GF_AdobeBootstrapInfoBox *p = (GF_AdobeBootstrapInfoBox*)a; fprintf(trace, "bootstrapinfo_version, p->profile, p->live, p->update, p->time_scale, p->current_media_time, p->smpte_time_code_offset); + p->bootstrapinfo_version, p->profile, p->live, p->update, p->time_scale, p->current_media_time, p->smpte_time_code_offset); if (p->movie_identifier) fprintf(trace, "MovieIdentifier=\"%s\" ", p->movie_identifier); if (p->drm_data) @@ -3569,7 +3700,7 @@ GF_Err afra_dump(GF_Box *a, FILE * trace) for (i=0; iglobal_entry_count; i++) { GF_GlobalAfraEntry *gae = (GF_GlobalAfraEntry *)gf_list_get(p->global_access_entries, i); fprintf(trace, "\n", - gae->time, gae->segment, gae->fragment, gae->afra_offset, gae->offset_from_afra); + gae->time, gae->segment, gae->fragment, gae->afra_offset, gae->offset_from_afra); } gf_box_dump_done("AdobeFragmentRandomAccessBox", a, trace); @@ -3608,7 +3739,7 @@ GF_Err asrt_dump(GF_Box *a, FILE * trace) fprintf(trace, "\n"); DumpBox(a, trace); gf_full_box_dump(a, trace); - + for (i=0; iquality_entry_count; i++) { char *str = (char*)gf_list_get(p->quality_segment_url_modifiers, i); fprintf(trace, "%s\n", str); @@ -3666,7 +3797,7 @@ GF_Err ohdr_dump(GF_Box *a, FILE * trace) { GF_OMADRMCommonHeaderBox *ptr = (GF_OMADRMCommonHeaderBox *)a; fprintf(trace, "EncryptionMethod, ptr->PaddingScheme, ptr->PlaintextLength); + ptr->EncryptionMethod, ptr->PaddingScheme, ptr->PlaintextLength); if (ptr->RightsIssuerURL) fprintf(trace, "RightsIssuerURL=\"%s\" ", ptr->RightsIssuerURL); if (ptr->ContentID) fprintf(trace, "ContentID=\"%s\" ", ptr->ContentID); if (ptr->TextualHeaders) { @@ -3754,7 +3885,7 @@ GF_Err tsel_dump(GF_Box *a, FILE * trace) u32 i; GF_TrackSelectionBox *ptr = (GF_TrackSelectionBox *)a; fprintf(trace, "switchGroup); - for (i=0; iattributeListCount;i++) { + for (i=0; iattributeListCount; i++) { if (i) fprintf(trace, ";"); fprintf(trace, "%s", gf_4cc_to_str(ptr->attributeList[i])); } @@ -3835,7 +3966,7 @@ GF_Err dimC_dump(GF_Box *a, FILE * trace) GF_DIMSSceneConfigBox *p = (GF_DIMSSceneConfigBox *)a; fprintf(trace, "\n", - p->profile, p->level, p->pathComponents, p->fullRequestHost, p->streamType, p->containsRedundant, p->textEncoding, p->contentEncoding); + p->profile, p->level, p->pathComponents, p->fullRequestHost, p->streamType, p->containsRedundant, p->textEncoding, p->contentEncoding); DumpBox(a, trace); gf_box_dump_done("DIMSSceneConfigBox", a, trace); return GF_OK; @@ -3851,7 +3982,7 @@ GF_Err dac3_dump(GF_Box *a, FILE * trace) fprintf(trace, "\n", p->cfg.nb_streams, p->cfg.brcode); for (i=0; icfg.nb_streams; i++) { fprintf(trace, "\n", - p->cfg.streams[i].fscod, p->cfg.streams[i].bsid, p->cfg.streams[i].bsmod, p->cfg.streams[i].acmod, p->cfg.streams[i].lfon, p->cfg.streams[i].nb_dep_sub, p->cfg.streams[i].chan_loc); + p->cfg.streams[i].fscod, p->cfg.streams[i].bsid, p->cfg.streams[i].bsmod, p->cfg.streams[i].acmod, p->cfg.streams[i].lfon, p->cfg.streams[i].nb_dep_sub, p->cfg.streams[i].chan_loc); } a->type = GF_ISOM_BOX_TYPE_DEC3; DumpBox(a, trace); @@ -3859,7 +3990,7 @@ GF_Err dac3_dump(GF_Box *a, FILE * trace) gf_box_dump_done("EC3SpecificBox", a, trace); } else { fprintf(trace, "\n", - p->cfg.streams[0].fscod, p->cfg.streams[0].bsid, p->cfg.streams[0].bsmod, p->cfg.streams[0].acmod, p->cfg.streams[0].lfon, p->cfg.brcode); + p->cfg.streams[0].fscod, p->cfg.streams[0].bsid, p->cfg.streams[0].bsmod, p->cfg.streams[0].acmod, p->cfg.streams[0].lfon, p->cfg.brcode); DumpBox(a, trace); gf_box_dump_done("AC3SpecificBox", a, trace); } @@ -3918,7 +4049,7 @@ GF_Err sidx_dump(GF_Box *a, FILE * trace) fprintf(trace, "\n", p->reference_ID, p->timescale, p->earliest_presentation_time, p->first_offset); DumpBox(a, trace); gf_full_box_dump(a, trace); - + for (i=0; inb_refs; i++) { fprintf(trace, "\n", p->refs[i].reference_type, p->refs[i].reference_size, p->refs[i].subsegment_duration, p->refs[i].starts_with_SAP, p->refs[i].SAP_type, p->refs[i].SAP_delta_time); } @@ -3932,7 +4063,7 @@ GF_Err pcrb_dump(GF_Box *a, FILE * trace) GF_PcrInfoBox *p = (GF_PcrInfoBox *)a; fprintf(trace, "\n", p->subsegment_count); DumpBox(a, trace); - + for (i=0; isubsegment_count; i++) { fprintf(trace, "\n", p->pcr_values[i]); } @@ -3962,11 +4093,11 @@ GF_Err subs_dump(GF_Box *a, FILE * trace) fprintf(trace, "\n", pSamp->sample_delta, subsample_count); for (j=0; jSubSamples, j); + pSubSamp = (GF_SubSampleEntry*) gf_list_get(pSamp->SubSamples, j); fprintf(trace, "\n", pSubSamp->subsample_size, pSubSamp->subsample_priority, pSubSamp->discardable, pSubSamp->reserved); } fprintf(trace, "\n"); - } + } gf_box_dump_done("SubSampleInformationBox", a, trace); return GF_OK; @@ -4025,6 +4156,7 @@ GF_Err sgpd_dump(GF_Box *a, FILE * trace) fprintf(trace, "grouping_type) ); if (ptr->version==1) fprintf(trace, " default_length=\"%d\"", ptr->default_length); + if ((ptr->version>=2) && ptr->default_description_index) fprintf(trace, " default_group_index=\"%d\"", ptr->default_description_index); fprintf(trace, ">\n"); DumpBox(a, trace); gf_full_box_dump((GF_Box *)a, trace); @@ -4044,6 +4176,18 @@ GF_Err sgpd_dump(GF_Box *a, FILE * trace) DumpDataHex(trace, (char *)((GF_CENCSampleEncryptionGroupEntry*)entry)->KID, 16); fprintf(trace, "\"/>\n"); break; + case GF_4CC( 't', 'r', 'i', 'f' ): + { + u32 x,y,w,h, id, independent; + Bool full_frame; + + gf_isom_parse_trif_info( ((GF_DefaultSampleGroupDescriptionEntry*)entry)->data, ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length, &id, &independent, &full_frame, &x, &y, &w, &h); + + fprintf(trace, "\n", w, h); + } + break; default: fprintf(trace, "length); DumpData(trace, (char *) ((GF_DefaultSampleGroupDescriptionEntry*)entry)->data, ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length); @@ -4062,7 +4206,7 @@ GF_Err saiz_dump(GF_Box *a, FILE * trace) fprintf(trace, "default_sample_info_size, ptr->sample_count); if (ptr->flags & 1) { - if (isalnum(ptr->aux_info_type>>24)) { + if (isalnum(ptr->aux_info_type>>24)) { fprintf(trace, " aux_info_type=\"%s\" aux_info_type_parameter=\"%d\"", gf_4cc_to_str(ptr->aux_info_type), ptr->aux_info_type_parameter); } else { fprintf(trace, " aux_info_type=\"%d\" aux_info_type_parameter=\"%d\"", ptr->aux_info_type, ptr->aux_info_type_parameter); @@ -4088,7 +4232,7 @@ GF_Err saio_dump(GF_Box *a, FILE * trace) fprintf(trace, "entry_count); if (ptr->flags & 1) { - if (isalnum(ptr->aux_info_type>>24)) { + if (isalnum(ptr->aux_info_type>>24)) { fprintf(trace, " aux_info_type=\"%s\" aux_info_type_parameter=\"%d\"", gf_4cc_to_str(ptr->aux_info_type), ptr->aux_info_type_parameter); } else { fprintf(trace, " aux_info_type=\"%d\" aux_info_type_parameter=\"%d\"", ptr->aux_info_type, ptr->aux_info_type_parameter); @@ -4199,7 +4343,7 @@ GF_Err piff_psec_dump(GF_Box *a, FILE * trace) } fprintf(trace, ">\n"); DumpBox(a, trace); - + if (sample_count) { for (i=0; isamp_aux_info, i); @@ -4211,7 +4355,7 @@ GF_Err piff_psec_dump(GF_Box *a, FILE * trace) if (ptr->flags & 0x2) { fprintf(trace, "\" SubsampleCount=\"%d\"", cenc_sample->subsample_count); fprintf(trace, ">\n"); - + for (j=0; jsubsample_count; j++) { fprintf(trace, "\n", cenc_sample->subsamples[j].bytes_clear_data, cenc_sample->subsamples[j].bytes_encrypted_data); } @@ -4246,7 +4390,7 @@ GF_Err senc_dump(GF_Box *a, FILE * trace) if (ptr->flags & 0x2) { fprintf(trace, " SubsampleCount=\"%d\"", cenc_sample->subsample_count); fprintf(trace, ">\n"); - + for (j=0; jsubsample_count; j++) { fprintf(trace, "\n", cenc_sample->subsamples[j].bytes_clear_data, cenc_sample->subsamples[j].bytes_encrypted_data); } diff --git a/src/isomedia/box_funcs.c b/src/isomedia/box_funcs.c index bfa0128..87389e4 100644 --- a/src/isomedia/box_funcs.c +++ b/src/isomedia/box_funcs.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -61,15 +61,15 @@ u32 gf_isom_solve_uuid_box(char *UUID) sprintf(strChar, "%02X", (unsigned char) UUID[i]); strcat(strUUID, strChar); } - if (!strnicmp(strUUID, "8974dbce7be74c5184f97148f9882554", 32)) + if (!strnicmp(strUUID, "8974dbce7be74c5184f97148f9882554", 32)) return GF_ISOM_BOX_UUID_TENC; - if (!strnicmp(strUUID, "D4807EF2CA3946958E5426CB9E46A79F", 32)) + if (!strnicmp(strUUID, "D4807EF2CA3946958E5426CB9E46A79F", 32)) return GF_ISOM_BOX_UUID_TFRF; - if (!strnicmp(strUUID, "6D1D9B0542D544E680E2141DAFF757B2", 32)) + if (!strnicmp(strUUID, "6D1D9B0542D544E680E2141DAFF757B2", 32)) return GF_ISOM_BOX_UUID_TFXD; - if (!strnicmp(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32)) + if (!strnicmp(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32)) return GF_ISOM_BOX_UUID_PSEC; - if (!strnicmp(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32)) + if (!strnicmp(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32)) return GF_ISOM_BOX_UUID_PSSH; return 0; } @@ -125,7 +125,7 @@ proceed_box: hdr_size += 16; uuid_type = gf_isom_solve_uuid_box(uuid); } - + //handle large box if (size == 1) { size = gf_bs_read_u64(bs); @@ -154,7 +154,7 @@ proceed_box: ((GF_UnknownUUIDBox *)newBox)->internal_4cc = uuid_type; } - if (!newBox->type) newBox->type = type; + if (!newBox->type) newBox->type = type; end = gf_bs_available(bs); if (size - hdr_size > end ) { @@ -168,9 +168,9 @@ proceed_box: *outBox = newBox; return GF_OK; } - + newBox->size = size - hdr_size; - e = gf_isom_box_read(newBox, bs); + e = gf_isom_box_read(newBox, bs); newBox->size = size; end = gf_bs_get_position(bs); @@ -225,7 +225,7 @@ void gf_isom_box_array_del(GF_List *other_boxes) u32 count, i; GF_Box *a; if (!other_boxes) return; - count = gf_list_count(other_boxes); + count = gf_list_count(other_boxes); for (i = 0; i < count; i++) { a = (GF_Box *)gf_list_get(other_boxes, i); if (a) gf_isom_box_del(a); @@ -237,7 +237,7 @@ GF_Err gf_isom_read_box_list_ex(GF_Box *parent, GF_BitStream *bs, GF_Err (*add_b { GF_Err e; GF_Box *a = NULL; - + while (parent->size) { e = gf_isom_parse_box_ex(&a, bs, parent_type); if (e) { @@ -305,15 +305,15 @@ GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs) char strUUID[32]; switch (((GF_UUIDBox*)ptr)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: - memcpy(strUUID, "8974dbce7be74c5184f97148f9882554", 32); - break; - case GF_ISOM_BOX_UUID_PSEC: - memcpy(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32); - break; - case GF_ISOM_BOX_UUID_PSSH: - memcpy(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32); - break; + case GF_ISOM_BOX_UUID_TENC: + memcpy(strUUID, "8974dbce7be74c5184f97148f9882554", 32); + break; + case GF_ISOM_BOX_UUID_PSEC: + memcpy(strUUID, "A2394F525A9B4F14A2446C427C648DF4", 32); + break; + case GF_ISOM_BOX_UUID_PSSH: + memcpy(strUUID, "D08A4F1810F34A82B6C832D8ABA183D3", 32); + break; } for (i = 0; i < 16; i++) { @@ -326,7 +326,7 @@ GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs) gf_bs_write_data(bs, uuid, 16); } - if (ptr->size > 0xFFFFFFFF) + if (ptr->size > 0xFFFFFFFF) gf_bs_write_u64(bs, ptr->size); return GF_OK; } @@ -354,7 +354,10 @@ GF_Err gf_isom_box_array_write(GF_Box *parent, GF_List *list, GF_BitStream *bs) a = (GF_Box *)gf_list_get(list, i); if (a) { e = gf_isom_box_write(a, bs); - if (e) return e; + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("ISOBMF: Error %s writing box %s\n", gf_error_to_string(e), gf_4cc_to_str(a->type) )); + return e; + } } } return GF_OK; @@ -372,7 +375,10 @@ GF_Err gf_isom_box_array_size(GF_Box *parent, GF_List *list) a = (GF_Box *)gf_list_get(list, i); if (a) { e = gf_isom_box_size(a); - if (e) return e; + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("ISOBMF: Error %s computing box %s size\n", gf_error_to_string(e), gf_4cc_to_str(a->type) )); + return e; + } parent->size += a->size; } } @@ -388,18 +394,26 @@ GF_Box *gf_isom_box_new(u32 boxType) switch (boxType) { case GF_ISOM_BOX_TYPE_REFT: return reftype_New(); - case GF_ISOM_BOX_TYPE_FREE: return free_New(); + case GF_ISOM_BOX_TYPE_FREE: + return free_New(); case GF_ISOM_BOX_TYPE_SKIP: a = free_New(); if (a) a->type = GF_ISOM_BOX_TYPE_SKIP; return a; - case GF_ISOM_BOX_TYPE_MDAT: return mdat_New(); - case GF_ISOM_BOX_TYPE_MOOV: return moov_New(); - case GF_ISOM_BOX_TYPE_MVHD: return mvhd_New(); - case GF_ISOM_BOX_TYPE_MDHD: return mdhd_New(); - case GF_ISOM_BOX_TYPE_VMHD: return vmhd_New(); - case GF_ISOM_BOX_TYPE_SMHD: return smhd_New(); - case GF_ISOM_BOX_TYPE_HMHD: return hmhd_New(); + case GF_ISOM_BOX_TYPE_MDAT: + return mdat_New(); + case GF_ISOM_BOX_TYPE_MOOV: + return moov_New(); + case GF_ISOM_BOX_TYPE_MVHD: + return mvhd_New(); + case GF_ISOM_BOX_TYPE_MDHD: + return mdhd_New(); + case GF_ISOM_BOX_TYPE_VMHD: + return vmhd_New(); + case GF_ISOM_BOX_TYPE_SMHD: + return smhd_New(); + case GF_ISOM_BOX_TYPE_HMHD: + return hmhd_New(); case GF_ISOM_BOX_TYPE_ODHD: case GF_ISOM_BOX_TYPE_CRHD: case GF_ISOM_BOX_TYPE_SDHD: @@ -408,103 +422,179 @@ GF_Box *gf_isom_box_new(u32 boxType) a = nmhd_New(); if (a) a->type = boxType; return a; - case GF_ISOM_BOX_TYPE_STBL: return stbl_New(); - case GF_ISOM_BOX_TYPE_DINF: return dinf_New(); - case GF_ISOM_BOX_TYPE_URL: return url_New(); - case GF_ISOM_BOX_TYPE_URN: return urn_New(); - case GF_ISOM_BOX_TYPE_CPRT: return cprt_New(); - case GF_ISOM_BOX_TYPE_CHPL: return chpl_New(); - case GF_ISOM_BOX_TYPE_HDLR: return hdlr_New(); - case GF_ISOM_BOX_TYPE_IODS: return iods_New(); - case GF_ISOM_BOX_TYPE_TRAK: return trak_New(); - case GF_ISOM_BOX_TYPE_MP4S: return mp4s_New(); - case GF_ISOM_BOX_TYPE_MP4A: return mp4a_New(); - case GF_ISOM_BOX_TYPE_GNRM: return gnrm_New(); - case GF_ISOM_BOX_TYPE_GNRV: return gnrv_New(); - case GF_ISOM_BOX_TYPE_GNRA: return gnra_New(); - case GF_ISOM_BOX_TYPE_EDTS: return edts_New(); - case GF_ISOM_BOX_TYPE_UDTA: return udta_New(); - case GF_ISOM_BOX_TYPE_DREF: return dref_New(); - case GF_ISOM_BOX_TYPE_STSD: return stsd_New(); - case GF_ISOM_BOX_TYPE_STTS: return stts_New(); - case GF_ISOM_BOX_TYPE_CTTS: return ctts_New(); - case GF_ISOM_BOX_TYPE_CSLG: return cslg_New(); - case GF_ISOM_BOX_TYPE_STSH: return stsh_New(); - case GF_ISOM_BOX_TYPE_ELST: return elst_New(); - case GF_ISOM_BOX_TYPE_STSC: return stsc_New(); + case GF_ISOM_BOX_TYPE_STBL: + return stbl_New(); + case GF_ISOM_BOX_TYPE_DINF: + return dinf_New(); + case GF_ISOM_BOX_TYPE_URL: + return url_New(); + case GF_ISOM_BOX_TYPE_URN: + return urn_New(); + case GF_ISOM_BOX_TYPE_CPRT: + return cprt_New(); + case GF_ISOM_BOX_TYPE_CHPL: + return chpl_New(); + case GF_ISOM_BOX_TYPE_HDLR: + return hdlr_New(); + case GF_ISOM_BOX_TYPE_IODS: + return iods_New(); + case GF_ISOM_BOX_TYPE_TRAK: + return trak_New(); + case GF_ISOM_BOX_TYPE_MP4S: + return mp4s_New(); + case GF_ISOM_BOX_TYPE_MP4A: + return mp4a_New(); + case GF_ISOM_BOX_TYPE_GNRM: + return gnrm_New(); + case GF_ISOM_BOX_TYPE_GNRV: + return gnrv_New(); + case GF_ISOM_BOX_TYPE_GNRA: + return gnra_New(); + case GF_ISOM_BOX_TYPE_EDTS: + return edts_New(); + case GF_ISOM_BOX_TYPE_UDTA: + return udta_New(); + case GF_ISOM_BOX_TYPE_DREF: + return dref_New(); + case GF_ISOM_BOX_TYPE_STSD: + return stsd_New(); + case GF_ISOM_BOX_TYPE_STTS: + return stts_New(); + case GF_ISOM_BOX_TYPE_CTTS: + return ctts_New(); + case GF_ISOM_BOX_TYPE_CSLG: + return cslg_New(); + case GF_ISOM_BOX_TYPE_STSH: + return stsh_New(); + case GF_ISOM_BOX_TYPE_ELST: + return elst_New(); + case GF_ISOM_BOX_TYPE_STSC: + return stsc_New(); case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: a = stsz_New(); if (a) a->type = boxType; return a; - case GF_ISOM_BOX_TYPE_STCO: return stco_New(); - case GF_ISOM_BOX_TYPE_STSS: return stss_New(); - case GF_ISOM_BOX_TYPE_STDP: return stdp_New(); - case GF_ISOM_BOX_TYPE_SDTP: return sdtp_New(); - case GF_ISOM_BOX_TYPE_CO64: return co64_New(); - case GF_ISOM_BOX_TYPE_ESDS: return esds_New(); - case GF_ISOM_BOX_TYPE_MINF: return minf_New(); - case GF_ISOM_BOX_TYPE_TKHD: return tkhd_New(); - case GF_ISOM_BOX_TYPE_TREF: return tref_New(); - case GF_ISOM_BOX_TYPE_MDIA: return mdia_New(); - - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - a = ftyp_New(); - if (a) a->type = boxType; - return a; - case GF_ISOM_BOX_TYPE_PADB: return padb_New(); - case GF_ISOM_BOX_TYPE_VOID: return void_New(); - case GF_ISOM_BOX_TYPE_STSF: return stsf_New(); - case GF_ISOM_BOX_TYPE_PDIN: return pdin_New(); - case GF_ISOM_BOX_TYPE_SBGP: return sbgp_New(); - case GF_ISOM_BOX_TYPE_SGPD: return sgpd_New(); - case GF_ISOM_BOX_TYPE_SAIZ: return saiz_New(); - case GF_ISOM_BOX_TYPE_SAIO: return saio_New(); - case GF_ISOM_BOX_TYPE_PSSH: return pssh_New(); - case GF_ISOM_BOX_TYPE_TENC: return tenc_New(); + case GF_ISOM_BOX_TYPE_STCO: + return stco_New(); + case GF_ISOM_BOX_TYPE_STSS: + return stss_New(); + case GF_ISOM_BOX_TYPE_STDP: + return stdp_New(); + case GF_ISOM_BOX_TYPE_SDTP: + return sdtp_New(); + case GF_ISOM_BOX_TYPE_CO64: + return co64_New(); + case GF_ISOM_BOX_TYPE_ESDS: + return esds_New(); + case GF_ISOM_BOX_TYPE_MINF: + return minf_New(); + case GF_ISOM_BOX_TYPE_TKHD: + return tkhd_New(); + case GF_ISOM_BOX_TYPE_TREF: + return tref_New(); + case GF_ISOM_BOX_TYPE_MDIA: + return mdia_New(); + + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + a = ftyp_New(); + if (a) a->type = boxType; + return a; + case GF_ISOM_BOX_TYPE_PADB: + return padb_New(); + case GF_ISOM_BOX_TYPE_VOID: + return void_New(); + case GF_ISOM_BOX_TYPE_STSF: + return stsf_New(); + case GF_ISOM_BOX_TYPE_PDIN: + return pdin_New(); + case GF_ISOM_BOX_TYPE_SBGP: + return sbgp_New(); + case GF_ISOM_BOX_TYPE_SGPD: + return sgpd_New(); + case GF_ISOM_BOX_TYPE_SAIZ: + return saiz_New(); + case GF_ISOM_BOX_TYPE_SAIO: + return saio_New(); + case GF_ISOM_BOX_TYPE_PSSH: + return pssh_New(); + case GF_ISOM_BOX_TYPE_TENC: + return tenc_New(); #ifndef GPAC_DISABLE_ISOM_HINTING case GF_ISOM_BOX_TYPE_RTP_STSD: a = ghnt_New(); if (a) a->type = boxType; return a; - case GF_ISOM_BOX_TYPE_RTPO: return rtpo_New(); - case GF_ISOM_BOX_TYPE_HNTI: return hnti_New(); - case GF_ISOM_BOX_TYPE_SDP: return sdp_New(); - case GF_ISOM_BOX_TYPE_HINF: return hinf_New(); - case GF_ISOM_BOX_TYPE_RELY: return rely_New(); - case GF_ISOM_BOX_TYPE_TIMS: return tims_New(); - case GF_ISOM_BOX_TYPE_TSRO: return tsro_New(); - case GF_ISOM_BOX_TYPE_SNRO: return snro_New(); - case GF_ISOM_BOX_TYPE_TRPY: return trpy_New(); - case GF_ISOM_BOX_TYPE_NUMP: return nump_New(); - case GF_ISOM_BOX_TYPE_TOTL: return totl_New(); - case GF_ISOM_BOX_TYPE_NPCK: return npck_New(); - case GF_ISOM_BOX_TYPE_TPYL: return tpyl_New(); - case GF_ISOM_BOX_TYPE_TPAY: return tpay_New(); - case GF_ISOM_BOX_TYPE_MAXR: return maxr_New(); - case GF_ISOM_BOX_TYPE_DMED: return dmed_New(); - case GF_ISOM_BOX_TYPE_DIMM: return dimm_New(); - case GF_ISOM_BOX_TYPE_DREP: return drep_New(); - case GF_ISOM_BOX_TYPE_TMIN: return tmin_New(); - case GF_ISOM_BOX_TYPE_TMAX: return tmax_New(); - case GF_ISOM_BOX_TYPE_PMAX: return pmax_New(); - case GF_ISOM_BOX_TYPE_DMAX: return dmax_New(); - case GF_ISOM_BOX_TYPE_PAYT: return payt_New(); - case GF_ISOM_BOX_TYPE_NAME: return name_New(); + case GF_ISOM_BOX_TYPE_RTPO: + return rtpo_New(); + case GF_ISOM_BOX_TYPE_HNTI: + return hnti_New(); + case GF_ISOM_BOX_TYPE_SDP: + return sdp_New(); + case GF_ISOM_BOX_TYPE_HINF: + return hinf_New(); + case GF_ISOM_BOX_TYPE_RELY: + return rely_New(); + case GF_ISOM_BOX_TYPE_TIMS: + return tims_New(); + case GF_ISOM_BOX_TYPE_TSRO: + return tsro_New(); + case GF_ISOM_BOX_TYPE_SNRO: + return snro_New(); + case GF_ISOM_BOX_TYPE_TRPY: + return trpy_New(); + case GF_ISOM_BOX_TYPE_NUMP: + return nump_New(); + case GF_ISOM_BOX_TYPE_TOTL: + return totl_New(); + case GF_ISOM_BOX_TYPE_NPCK: + return npck_New(); + case GF_ISOM_BOX_TYPE_TPYL: + return tpyl_New(); + case GF_ISOM_BOX_TYPE_TPAY: + return tpay_New(); + case GF_ISOM_BOX_TYPE_MAXR: + return maxr_New(); + case GF_ISOM_BOX_TYPE_DMED: + return dmed_New(); + case GF_ISOM_BOX_TYPE_DIMM: + return dimm_New(); + case GF_ISOM_BOX_TYPE_DREP: + return drep_New(); + case GF_ISOM_BOX_TYPE_TMIN: + return tmin_New(); + case GF_ISOM_BOX_TYPE_TMAX: + return tmax_New(); + case GF_ISOM_BOX_TYPE_PMAX: + return pmax_New(); + case GF_ISOM_BOX_TYPE_DMAX: + return dmax_New(); + case GF_ISOM_BOX_TYPE_PAYT: + return payt_New(); + case GF_ISOM_BOX_TYPE_NAME: + return name_New(); #endif /*GPAC_DISABLE_ISOM_HINTING*/ #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_MVEX: return mvex_New(); - case GF_ISOM_BOX_TYPE_MEHD: return mehd_New(); - case GF_ISOM_BOX_TYPE_TREX: return trex_New(); - case GF_ISOM_BOX_TYPE_MOOF: return moof_New(); - case GF_ISOM_BOX_TYPE_MFHD: return mfhd_New(); - case GF_ISOM_BOX_TYPE_TRAF: return traf_New(); - case GF_ISOM_BOX_TYPE_TFHD: return tfhd_New(); - case GF_ISOM_BOX_TYPE_TRUN: return trun_New(); -#endif + case GF_ISOM_BOX_TYPE_MVEX: + return mvex_New(); + case GF_ISOM_BOX_TYPE_MEHD: + return mehd_New(); + case GF_ISOM_BOX_TYPE_TREX: + return trex_New(); + case GF_ISOM_BOX_TYPE_MOOF: + return moof_New(); + case GF_ISOM_BOX_TYPE_MFHD: + return mfhd_New(); + case GF_ISOM_BOX_TYPE_TRAF: + return traf_New(); + case GF_ISOM_BOX_TYPE_TFHD: + return tfhd_New(); + case GF_ISOM_BOX_TYPE_TRUN: + return trun_New(); +#endif /*3GPP boxes*/ case GF_ISOM_SUBTYPE_3GP_AMR: @@ -513,31 +603,33 @@ GF_Box *gf_isom_box_new(u32 boxType) case GF_ISOM_SUBTYPE_3GP_QCELP: case GF_ISOM_SUBTYPE_3GP_SMV: return gppa_New(boxType); - case GF_ISOM_SUBTYPE_3GP_H263: + case GF_ISOM_SUBTYPE_3GP_H263: return gppv_New(boxType); - case GF_ISOM_BOX_TYPE_DAMR: - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_BOX_TYPE_DAMR: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: case GF_ISOM_BOX_TYPE_D263: return gppc_New(boxType); /*AVC boxes*/ - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: a = avcc_New(); if (a) a->type = boxType; return a; - case GF_ISOM_BOX_TYPE_HVCC: + case GF_ISOM_BOX_TYPE_HVCC: case GF_ISOM_BOX_TYPE_SHCC: a = hvcc_New(); if (a) a->type = boxType; return a; - case GF_ISOM_BOX_TYPE_BTRT: return btrt_New(); - case GF_ISOM_BOX_TYPE_M4DS: return m4ds_New(); + case GF_ISOM_BOX_TYPE_BTRT: + return btrt_New(); + case GF_ISOM_BOX_TYPE_M4DS: + return m4ds_New(); - case GF_ISOM_BOX_TYPE_MP4V: + case GF_ISOM_BOX_TYPE_MP4V: case GF_ISOM_BOX_TYPE_ENCV: case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: @@ -550,63 +642,101 @@ GF_Box *gf_isom_box_new(u32 boxType) case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: return mp4v_encv_avc_hevc_new(boxType); /*3GPP streaming text*/ - case GF_ISOM_BOX_TYPE_FTAB: return ftab_New(); - case GF_ISOM_BOX_TYPE_TX3G: return tx3g_New(); - case GF_ISOM_BOX_TYPE_TEXT: return text_New(); - case GF_ISOM_BOX_TYPE_STYL: return styl_New(); - case GF_ISOM_BOX_TYPE_HLIT: return hlit_New(); - case GF_ISOM_BOX_TYPE_HCLR: return hclr_New(); - case GF_ISOM_BOX_TYPE_KROK: return krok_New(); - case GF_ISOM_BOX_TYPE_DLAY: return dlay_New(); - case GF_ISOM_BOX_TYPE_HREF: return href_New(); - case GF_ISOM_BOX_TYPE_TBOX: return tbox_New(); - case GF_ISOM_BOX_TYPE_BLNK: return blnk_New(); - case GF_ISOM_BOX_TYPE_TWRP: return twrp_New(); + case GF_ISOM_BOX_TYPE_FTAB: + return ftab_New(); + case GF_ISOM_BOX_TYPE_TX3G: + return tx3g_New(); + case GF_ISOM_BOX_TYPE_TEXT: + return text_New(); + case GF_ISOM_BOX_TYPE_STYL: + return styl_New(); + case GF_ISOM_BOX_TYPE_HLIT: + return hlit_New(); + case GF_ISOM_BOX_TYPE_HCLR: + return hclr_New(); + case GF_ISOM_BOX_TYPE_KROK: + return krok_New(); + case GF_ISOM_BOX_TYPE_DLAY: + return dlay_New(); + case GF_ISOM_BOX_TYPE_HREF: + return href_New(); + case GF_ISOM_BOX_TYPE_TBOX: + return tbox_New(); + case GF_ISOM_BOX_TYPE_BLNK: + return blnk_New(); + case GF_ISOM_BOX_TYPE_TWRP: + return twrp_New(); /* ISMA 1.0 Encryption and Authentication V 1.0 */ - case GF_ISOM_BOX_TYPE_IKMS: return iKMS_New(); - case GF_ISOM_BOX_TYPE_ISFM: return iSFM_New(); + case GF_ISOM_BOX_TYPE_IKMS: + return iKMS_New(); + case GF_ISOM_BOX_TYPE_ISFM: + return iSFM_New(); /* ISO FF extensions for MPEG-21 */ - case GF_ISOM_BOX_TYPE_META: return meta_New(); - case GF_ISOM_BOX_TYPE_XML: return xml_New(); - case GF_ISOM_BOX_TYPE_BXML: return bxml_New(); - case GF_ISOM_BOX_TYPE_ILOC: return iloc_New(); - case GF_ISOM_BOX_TYPE_PITM: return pitm_New(); - case GF_ISOM_BOX_TYPE_IPRO: return ipro_New(); - case GF_ISOM_BOX_TYPE_INFE: return infe_New(); - case GF_ISOM_BOX_TYPE_IINF: return iinf_New(); - case GF_ISOM_BOX_TYPE_SINF: return sinf_New(); - case GF_ISOM_BOX_TYPE_FRMA: return frma_New(); - case GF_ISOM_BOX_TYPE_SCHM: return schm_New(); - case GF_ISOM_BOX_TYPE_SCHI: return schi_New(); - case GF_ISOM_BOX_TYPE_ENCA: return enca_New(); - case GF_ISOM_BOX_TYPE_ENCS: return encs_New(); - - case GF_ISOM_BOX_TYPE_SENC: return senc_New(); - - case GF_ISOM_BOX_UUID_TENC: return piff_tenc_New(); - case GF_ISOM_BOX_UUID_PSEC: return piff_psec_New(); - case GF_ISOM_BOX_UUID_PSSH: return piff_pssh_New(); - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: - case GF_ISOM_BOX_TYPE_UUID: + case GF_ISOM_BOX_TYPE_META: + return meta_New(); + case GF_ISOM_BOX_TYPE_XML: + return xml_New(); + case GF_ISOM_BOX_TYPE_BXML: + return bxml_New(); + case GF_ISOM_BOX_TYPE_ILOC: + return iloc_New(); + case GF_ISOM_BOX_TYPE_PITM: + return pitm_New(); + case GF_ISOM_BOX_TYPE_IPRO: + return ipro_New(); + case GF_ISOM_BOX_TYPE_INFE: + return infe_New(); + case GF_ISOM_BOX_TYPE_IINF: + return iinf_New(); + case GF_ISOM_BOX_TYPE_SINF: + return sinf_New(); + case GF_ISOM_BOX_TYPE_FRMA: + return frma_New(); + case GF_ISOM_BOX_TYPE_SCHM: + return schm_New(); + case GF_ISOM_BOX_TYPE_SCHI: + return schi_New(); + case GF_ISOM_BOX_TYPE_ENCA: + return enca_New(); + case GF_ISOM_BOX_TYPE_ENCS: + return encs_New(); + + case GF_ISOM_BOX_TYPE_SENC: + return senc_New(); + + case GF_ISOM_BOX_UUID_TENC: + return piff_tenc_New(); + case GF_ISOM_BOX_UUID_PSEC: + return piff_psec_New(); + case GF_ISOM_BOX_UUID_PSSH: + return piff_pssh_New(); + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: + case GF_ISOM_BOX_TYPE_UUID: return uuid_New(); #ifndef GPAC_DISABLE_ISOM_ADOBE /* Adobe extensions */ - case GF_ISOM_BOX_TYPE_ABST: return abst_New(); - case GF_ISOM_BOX_TYPE_AFRA: return afra_New(); - case GF_ISOM_BOX_TYPE_ASRT: return asrt_New(); - case GF_ISOM_BOX_TYPE_AFRT: return afrt_New(); + case GF_ISOM_BOX_TYPE_ABST: + return abst_New(); + case GF_ISOM_BOX_TYPE_AFRA: + return afra_New(); + case GF_ISOM_BOX_TYPE_ASRT: + return asrt_New(); + case GF_ISOM_BOX_TYPE_AFRT: + return afrt_New(); #endif /* Apple extensions */ - case GF_ISOM_BOX_TYPE_ILST: return ilst_New(); - + case GF_ISOM_BOX_TYPE_ILST: + return ilst_New(); + case GF_ISOM_BOX_TYPE_0xA9NAM: case GF_ISOM_BOX_TYPE_0xA9CMT: case GF_ISOM_BOX_TYPE_0xA9DAY: @@ -631,74 +761,113 @@ GF_Box *gf_isom_box_new(u32 boxType) case GF_ISOM_BOX_TYPE_COVR: return ListItem_New(boxType); - case GF_ISOM_BOX_TYPE_DATA: return data_New(); - - case GF_ISOM_BOX_TYPE_OHDR: return ohdr_New(); - case GF_ISOM_BOX_TYPE_GRPI: return grpi_New(); - case GF_ISOM_BOX_TYPE_MDRI: return mdri_New(); - case GF_ISOM_BOX_TYPE_ODTT: return odtt_New(); - case GF_ISOM_BOX_TYPE_ODRB: return odrb_New(); - case GF_ISOM_BOX_TYPE_ODKM: return odkm_New(); - case GF_ISOM_BOX_TYPE_ODAF: + case GF_ISOM_BOX_TYPE_DATA: + return data_New(); + + case GF_ISOM_BOX_TYPE_OHDR: + return ohdr_New(); + case GF_ISOM_BOX_TYPE_GRPI: + return grpi_New(); + case GF_ISOM_BOX_TYPE_MDRI: + return mdri_New(); + case GF_ISOM_BOX_TYPE_ODTT: + return odtt_New(); + case GF_ISOM_BOX_TYPE_ODRB: + return odrb_New(); + case GF_ISOM_BOX_TYPE_ODKM: + return odkm_New(); + case GF_ISOM_BOX_TYPE_ODAF: a = iSFM_New(); a->type = GF_ISOM_BOX_TYPE_ODAF; return a; - case GF_ISOM_BOX_TYPE_PASP: return pasp_New(); - case GF_ISOM_BOX_TYPE_TSEL: return tsel_New(); + case GF_ISOM_BOX_TYPE_PASP: + return pasp_New(); + case GF_ISOM_BOX_TYPE_TSEL: + return tsel_New(); - case GF_ISOM_BOX_TYPE_DIMS: return dims_New(); - case GF_ISOM_BOX_TYPE_DIMC: return dimC_New(); - case GF_ISOM_BOX_TYPE_DIST: return diST_New(); + case GF_ISOM_BOX_TYPE_DIMS: + return dims_New(); + case GF_ISOM_BOX_TYPE_DIMC: + return dimC_New(); + case GF_ISOM_BOX_TYPE_DIST: + return diST_New(); case GF_ISOM_BOX_TYPE_METX: case GF_ISOM_BOX_TYPE_METT: return metx_New(boxType); - case GF_ISOM_BOX_TYPE_AC3: - case GF_ISOM_BOX_TYPE_EC3: + case GF_ISOM_BOX_TYPE_AC3: + case GF_ISOM_BOX_TYPE_EC3: return ac3_New(boxType); - case GF_ISOM_BOX_TYPE_DAC3: - case GF_ISOM_BOX_TYPE_DEC3: + case GF_ISOM_BOX_TYPE_DAC3: + case GF_ISOM_BOX_TYPE_DEC3: return dac3_New(boxType); - - case GF_ISOM_BOX_TYPE_LSRC: return lsrc_New(); - case GF_ISOM_BOX_TYPE_LSR1: return lsr1_New(); + + case GF_ISOM_BOX_TYPE_LSRC: + return lsrc_New(); + case GF_ISOM_BOX_TYPE_LSR1: + return lsr1_New(); #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_SIDX: return sidx_New(); - case GF_ISOM_BOX_TYPE_SUBS: return subs_New(); - case GF_ISOM_BOX_TYPE_TFDT: return tfdt_New(); - case GF_ISOM_BOX_TYPE_PCRB: return pcrb_New(); + case GF_ISOM_BOX_TYPE_SIDX: + return sidx_New(); + case GF_ISOM_BOX_TYPE_SUBS: + return subs_New(); + case GF_ISOM_BOX_TYPE_TFDT: + return tfdt_New(); + case GF_ISOM_BOX_TYPE_PCRB: + return pcrb_New(); #endif - case GF_ISOM_BOX_TYPE_RVCC: return rvcc_New(); + case GF_ISOM_BOX_TYPE_RVCC: + return rvcc_New(); - case GF_ISOM_BOX_TYPE_PRFT: return prft_New(); + case GF_ISOM_BOX_TYPE_PRFT: + return prft_New(); #ifndef GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_STSE: return stse_New(); - case GF_ISOM_BOX_TYPE_STTC: return boxstring_New(GF_ISOM_BOX_TYPE_STTC); - - case GF_ISOM_BOX_TYPE_VTCU: return vtcu_New(); - case GF_ISOM_BOX_TYPE_VTTE: return vtte_New(); - case GF_ISOM_BOX_TYPE_VTTC: return boxstring_New(GF_ISOM_BOX_TYPE_VTTC); - case GF_ISOM_BOX_TYPE_CTIM: return boxstring_New(GF_ISOM_BOX_TYPE_CTIM); - case GF_ISOM_BOX_TYPE_IDEN: return boxstring_New(GF_ISOM_BOX_TYPE_IDEN); - case GF_ISOM_BOX_TYPE_STTG: return boxstring_New(GF_ISOM_BOX_TYPE_STTG); - case GF_ISOM_BOX_TYPE_PAYL: return boxstring_New(GF_ISOM_BOX_TYPE_PAYL); - case GF_ISOM_BOX_TYPE_WVTT: return wvtt_New(); - - case GF_ISOM_BOX_TYPE_STPP: return stpp_New(); - case GF_ISOM_BOX_TYPE_SBTT: return metx_New(GF_ISOM_BOX_TYPE_SBTT); + case GF_ISOM_BOX_TYPE_STSE: + return stse_New(); + case GF_ISOM_BOX_TYPE_STTC: + return boxstring_New(GF_ISOM_BOX_TYPE_STTC); + + case GF_ISOM_BOX_TYPE_VTCU: + return vtcu_New(); + case GF_ISOM_BOX_TYPE_VTTE: + return vtte_New(); + case GF_ISOM_BOX_TYPE_VTTC: + return boxstring_New(GF_ISOM_BOX_TYPE_VTTC); + case GF_ISOM_BOX_TYPE_CTIM: + return boxstring_New(GF_ISOM_BOX_TYPE_CTIM); + case GF_ISOM_BOX_TYPE_IDEN: + return boxstring_New(GF_ISOM_BOX_TYPE_IDEN); + case GF_ISOM_BOX_TYPE_STTG: + return boxstring_New(GF_ISOM_BOX_TYPE_STTG); + case GF_ISOM_BOX_TYPE_PAYL: + return boxstring_New(GF_ISOM_BOX_TYPE_PAYL); + case GF_ISOM_BOX_TYPE_WVTT: + return wvtt_New(); + + case GF_ISOM_BOX_TYPE_STPP: + return stpp_New(); + case GF_ISOM_BOX_TYPE_SBTT: + return metx_New(GF_ISOM_BOX_TYPE_SBTT); #endif //GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_ADKM: return adkm_New(); - case GF_ISOM_BOX_TYPE_AHDR: return ahdr_New(); - case GF_ISOM_BOX_TYPE_APRM: return aprm_New(); - case GF_ISOM_BOX_TYPE_AEIB: return aeib_New(); - case GF_ISOM_BOX_TYPE_AKEY: return akey_New(); - case GF_ISOM_BOX_TYPE_FLXS: return flxs_New(); - case GF_ISOM_BOX_TYPE_ADAF: return adaf_New(); + case GF_ISOM_BOX_TYPE_ADKM: + return adkm_New(); + case GF_ISOM_BOX_TYPE_AHDR: + return ahdr_New(); + case GF_ISOM_BOX_TYPE_APRM: + return aprm_New(); + case GF_ISOM_BOX_TYPE_AEIB: + return aeib_New(); + case GF_ISOM_BOX_TYPE_AKEY: + return akey_New(); + case GF_ISOM_BOX_TYPE_FLXS: + return flxs_New(); + case GF_ISOM_BOX_TYPE_ADAF: + return adaf_New(); default: a = defa_New(); @@ -733,115 +902,285 @@ void gf_isom_box_del(GF_Box *a) case GF_ISOM_BOX_TYPE_SKIP: free_del(a); return; - case GF_ISOM_BOX_TYPE_MDAT: mdat_del(a); return; - case GF_ISOM_BOX_TYPE_MOOV: moov_del(a); return; - case GF_ISOM_BOX_TYPE_MVHD: mvhd_del(a); return; - case GF_ISOM_BOX_TYPE_MDHD: mdhd_del(a); return; - case GF_ISOM_BOX_TYPE_VMHD: vmhd_del(a); return; - case GF_ISOM_BOX_TYPE_SMHD: smhd_del(a); return; - case GF_ISOM_BOX_TYPE_HMHD: hmhd_del(a); return; + case GF_ISOM_BOX_TYPE_MDAT: + mdat_del(a); + return; + case GF_ISOM_BOX_TYPE_MOOV: + moov_del(a); + return; + case GF_ISOM_BOX_TYPE_MVHD: + mvhd_del(a); + return; + case GF_ISOM_BOX_TYPE_MDHD: + mdhd_del(a); + return; + case GF_ISOM_BOX_TYPE_VMHD: + vmhd_del(a); + return; + case GF_ISOM_BOX_TYPE_SMHD: + smhd_del(a); + return; + case GF_ISOM_BOX_TYPE_HMHD: + hmhd_del(a); + return; case GF_ISOM_BOX_TYPE_ODHD: case GF_ISOM_BOX_TYPE_CRHD: case GF_ISOM_BOX_TYPE_SDHD: case GF_ISOM_BOX_TYPE_NMHD: nmhd_del(a); return; - case GF_ISOM_BOX_TYPE_STBL: stbl_del(a); return; - case GF_ISOM_BOX_TYPE_DINF: dinf_del(a); return; - case GF_ISOM_BOX_TYPE_URL: url_del(a); return; - case GF_ISOM_BOX_TYPE_URN: urn_del(a); return; - case GF_ISOM_BOX_TYPE_CHPL: chpl_del(a); return; - case GF_ISOM_BOX_TYPE_CPRT: cprt_del(a); return; - case GF_ISOM_BOX_TYPE_HDLR: hdlr_del(a); return; - case GF_ISOM_BOX_TYPE_IODS: iods_del(a); return; - case GF_ISOM_BOX_TYPE_TRAK: trak_del(a); return; - case GF_ISOM_BOX_TYPE_MP4S: mp4s_del(a); return; - case GF_4CC('2','6','4','b'): - case GF_ISOM_BOX_TYPE_MP4V: - mp4v_del(a); - return; - case GF_ISOM_BOX_TYPE_MP4A: mp4a_del(a); return; - case GF_ISOM_BOX_TYPE_GNRM: gnrm_del(a); return; - case GF_ISOM_BOX_TYPE_GNRV: gnrv_del(a); return; - case GF_ISOM_BOX_TYPE_GNRA: gnra_del(a); return; - case GF_ISOM_BOX_TYPE_EDTS: edts_del(a); return; - case GF_ISOM_BOX_TYPE_UDTA: udta_del(a); return; - case GF_ISOM_BOX_TYPE_DREF: dref_del(a); return; - case GF_ISOM_BOX_TYPE_STSD: stsd_del(a); return; - case GF_ISOM_BOX_TYPE_STTS: stts_del(a); return; - case GF_ISOM_BOX_TYPE_CTTS: ctts_del(a); return; - case GF_ISOM_BOX_TYPE_CSLG: cslg_del(a); return; - case GF_ISOM_BOX_TYPE_STSH: stsh_del(a); return; - case GF_ISOM_BOX_TYPE_ELST: elst_del(a); return; - case GF_ISOM_BOX_TYPE_STSC: stsc_del(a); return; + case GF_ISOM_BOX_TYPE_STBL: + stbl_del(a); + return; + case GF_ISOM_BOX_TYPE_DINF: + dinf_del(a); + return; + case GF_ISOM_BOX_TYPE_URL: + url_del(a); + return; + case GF_ISOM_BOX_TYPE_URN: + urn_del(a); + return; + case GF_ISOM_BOX_TYPE_CHPL: + chpl_del(a); + return; + case GF_ISOM_BOX_TYPE_CPRT: + cprt_del(a); + return; + case GF_ISOM_BOX_TYPE_HDLR: + hdlr_del(a); + return; + case GF_ISOM_BOX_TYPE_IODS: + iods_del(a); + return; + case GF_ISOM_BOX_TYPE_TRAK: + trak_del(a); + return; + case GF_ISOM_BOX_TYPE_MP4S: + mp4s_del(a); + return; + case GF_4CC('2','6','4','b'): + case GF_ISOM_BOX_TYPE_MP4V: + mp4v_del(a); + return; + case GF_ISOM_BOX_TYPE_MP4A: + mp4a_del(a); + return; + case GF_ISOM_BOX_TYPE_GNRM: + gnrm_del(a); + return; + case GF_ISOM_BOX_TYPE_GNRV: + gnrv_del(a); + return; + case GF_ISOM_BOX_TYPE_GNRA: + gnra_del(a); + return; + case GF_ISOM_BOX_TYPE_EDTS: + edts_del(a); + return; + case GF_ISOM_BOX_TYPE_UDTA: + udta_del(a); + return; + case GF_ISOM_BOX_TYPE_DREF: + dref_del(a); + return; + case GF_ISOM_BOX_TYPE_STSD: + stsd_del(a); + return; + case GF_ISOM_BOX_TYPE_STTS: + stts_del(a); + return; + case GF_ISOM_BOX_TYPE_CTTS: + ctts_del(a); + return; + case GF_ISOM_BOX_TYPE_CSLG: + cslg_del(a); + return; + case GF_ISOM_BOX_TYPE_STSH: + stsh_del(a); + return; + case GF_ISOM_BOX_TYPE_ELST: + elst_del(a); + return; + case GF_ISOM_BOX_TYPE_STSC: + stsc_del(a); + return; case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: stsz_del(a); return; - case GF_ISOM_BOX_TYPE_STCO: stco_del(a); return; - case GF_ISOM_BOX_TYPE_STSS: stss_del(a); return; - case GF_ISOM_BOX_TYPE_STDP: stdp_del(a); return; - case GF_ISOM_BOX_TYPE_SDTP: sdtp_del(a); return; - case GF_ISOM_BOX_TYPE_CO64: co64_del(a); return; - case GF_ISOM_BOX_TYPE_ESDS: esds_del(a); return; - case GF_ISOM_BOX_TYPE_MINF: minf_del(a); return; - case GF_ISOM_BOX_TYPE_TKHD: tkhd_del(a); return; - case GF_ISOM_BOX_TYPE_TREF: tref_del(a); return; - case GF_ISOM_BOX_TYPE_MDIA: mdia_del(a); return; - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - ftyp_del(a); - return; - case GF_ISOM_BOX_TYPE_PADB: padb_del(a); return; - case GF_ISOM_BOX_TYPE_VOID: void_del(a); return; - case GF_ISOM_BOX_TYPE_STSF: stsf_del(a); return; - case GF_ISOM_BOX_TYPE_PDIN: pdin_del(a); return; - case GF_ISOM_BOX_TYPE_SBGP: sbgp_del(a); return; - case GF_ISOM_BOX_TYPE_SGPD: sgpd_del(a); return; - case GF_ISOM_BOX_TYPE_SAIZ: saiz_del(a); return; - case GF_ISOM_BOX_TYPE_SAIO: saio_del(a); return; - case GF_ISOM_BOX_TYPE_PSSH: pssh_del(a); return; - case GF_ISOM_BOX_TYPE_TENC: tenc_del(a); return; + case GF_ISOM_BOX_TYPE_STCO: + stco_del(a); + return; + case GF_ISOM_BOX_TYPE_STSS: + stss_del(a); + return; + case GF_ISOM_BOX_TYPE_STDP: + stdp_del(a); + return; + case GF_ISOM_BOX_TYPE_SDTP: + sdtp_del(a); + return; + case GF_ISOM_BOX_TYPE_CO64: + co64_del(a); + return; + case GF_ISOM_BOX_TYPE_ESDS: + esds_del(a); + return; + case GF_ISOM_BOX_TYPE_MINF: + minf_del(a); + return; + case GF_ISOM_BOX_TYPE_TKHD: + tkhd_del(a); + return; + case GF_ISOM_BOX_TYPE_TREF: + tref_del(a); + return; + case GF_ISOM_BOX_TYPE_MDIA: + mdia_del(a); + return; + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + ftyp_del(a); + return; + case GF_ISOM_BOX_TYPE_PADB: + padb_del(a); + return; + case GF_ISOM_BOX_TYPE_VOID: + void_del(a); + return; + case GF_ISOM_BOX_TYPE_STSF: + stsf_del(a); + return; + case GF_ISOM_BOX_TYPE_PDIN: + pdin_del(a); + return; + case GF_ISOM_BOX_TYPE_SBGP: + sbgp_del(a); + return; + case GF_ISOM_BOX_TYPE_SGPD: + sgpd_del(a); + return; + case GF_ISOM_BOX_TYPE_SAIZ: + saiz_del(a); + return; + case GF_ISOM_BOX_TYPE_SAIO: + saio_del(a); + return; + case GF_ISOM_BOX_TYPE_PSSH: + pssh_del(a); + return; + case GF_ISOM_BOX_TYPE_TENC: + tenc_del(a); + return; #ifndef GPAC_DISABLE_ISOM_HINTING - case GF_ISOM_BOX_TYPE_RTP_STSD: ghnt_del(a); return; - case GF_ISOM_BOX_TYPE_RTPO: rtpo_del(a); return; - case GF_ISOM_BOX_TYPE_HNTI: hnti_del(a); return; - case GF_ISOM_BOX_TYPE_SDP: sdp_del(a); return; - case GF_ISOM_BOX_TYPE_HINF: hinf_del(a); return; - case GF_ISOM_BOX_TYPE_RELY: rely_del(a); return; - case GF_ISOM_BOX_TYPE_TIMS: tims_del(a); return; - case GF_ISOM_BOX_TYPE_TSRO: tsro_del(a); return; - case GF_ISOM_BOX_TYPE_SNRO: snro_del(a); return; - case GF_ISOM_BOX_TYPE_TRPY: trpy_del(a); return; - case GF_ISOM_BOX_TYPE_NUMP: nump_del(a); return; - case GF_ISOM_BOX_TYPE_TOTL: totl_del(a); return; - case GF_ISOM_BOX_TYPE_NPCK: npck_del(a); return; - case GF_ISOM_BOX_TYPE_TPYL: tpyl_del(a); return; - case GF_ISOM_BOX_TYPE_TPAY: tpay_del(a); return; - case GF_ISOM_BOX_TYPE_MAXR: maxr_del(a); return; - case GF_ISOM_BOX_TYPE_DMED: dmed_del(a); return; - case GF_ISOM_BOX_TYPE_DIMM: dimm_del(a); return; - case GF_ISOM_BOX_TYPE_DREP: drep_del(a); return; - case GF_ISOM_BOX_TYPE_TMIN: tmin_del(a); return; - case GF_ISOM_BOX_TYPE_TMAX: tmax_del(a); return; - case GF_ISOM_BOX_TYPE_PMAX: pmax_del(a); return; - case GF_ISOM_BOX_TYPE_DMAX: dmax_del(a); return; - case GF_ISOM_BOX_TYPE_PAYT: payt_del(a); return; - case GF_ISOM_BOX_TYPE_NAME: name_del(a); return; + case GF_ISOM_BOX_TYPE_RTP_STSD: + ghnt_del(a); + return; + case GF_ISOM_BOX_TYPE_RTPO: + rtpo_del(a); + return; + case GF_ISOM_BOX_TYPE_HNTI: + hnti_del(a); + return; + case GF_ISOM_BOX_TYPE_SDP: + sdp_del(a); + return; + case GF_ISOM_BOX_TYPE_HINF: + hinf_del(a); + return; + case GF_ISOM_BOX_TYPE_RELY: + rely_del(a); + return; + case GF_ISOM_BOX_TYPE_TIMS: + tims_del(a); + return; + case GF_ISOM_BOX_TYPE_TSRO: + tsro_del(a); + return; + case GF_ISOM_BOX_TYPE_SNRO: + snro_del(a); + return; + case GF_ISOM_BOX_TYPE_TRPY: + trpy_del(a); + return; + case GF_ISOM_BOX_TYPE_NUMP: + nump_del(a); + return; + case GF_ISOM_BOX_TYPE_TOTL: + totl_del(a); + return; + case GF_ISOM_BOX_TYPE_NPCK: + npck_del(a); + return; + case GF_ISOM_BOX_TYPE_TPYL: + tpyl_del(a); + return; + case GF_ISOM_BOX_TYPE_TPAY: + tpay_del(a); + return; + case GF_ISOM_BOX_TYPE_MAXR: + maxr_del(a); + return; + case GF_ISOM_BOX_TYPE_DMED: + dmed_del(a); + return; + case GF_ISOM_BOX_TYPE_DIMM: + dimm_del(a); + return; + case GF_ISOM_BOX_TYPE_DREP: + drep_del(a); + return; + case GF_ISOM_BOX_TYPE_TMIN: + tmin_del(a); + return; + case GF_ISOM_BOX_TYPE_TMAX: + tmax_del(a); + return; + case GF_ISOM_BOX_TYPE_PMAX: + pmax_del(a); + return; + case GF_ISOM_BOX_TYPE_DMAX: + dmax_del(a); + return; + case GF_ISOM_BOX_TYPE_PAYT: + payt_del(a); + return; + case GF_ISOM_BOX_TYPE_NAME: + name_del(a); + return; #endif /*GPAC_DISABLE_ISOM_HINTING*/ #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_MVEX: mvex_del(a); return; - case GF_ISOM_BOX_TYPE_MEHD: mehd_del(a); return; - case GF_ISOM_BOX_TYPE_TREX: trex_del(a); return; - case GF_ISOM_BOX_TYPE_MOOF: moof_del(a); return; - case GF_ISOM_BOX_TYPE_MFHD: mfhd_del(a); return; - case GF_ISOM_BOX_TYPE_TRAF: traf_del(a); return; - case GF_ISOM_BOX_TYPE_TFHD: tfhd_del(a); return; - case GF_ISOM_BOX_TYPE_TFDT: tfdt_del(a); return; - case GF_ISOM_BOX_TYPE_TRUN: trun_del(a); return; + case GF_ISOM_BOX_TYPE_MVEX: + mvex_del(a); + return; + case GF_ISOM_BOX_TYPE_MEHD: + mehd_del(a); + return; + case GF_ISOM_BOX_TYPE_TREX: + trex_del(a); + return; + case GF_ISOM_BOX_TYPE_MOOF: + moof_del(a); + return; + case GF_ISOM_BOX_TYPE_MFHD: + mfhd_del(a); + return; + case GF_ISOM_BOX_TYPE_TRAF: + traf_del(a); + return; + case GF_ISOM_BOX_TYPE_TFHD: + tfhd_del(a); + return; + case GF_ISOM_BOX_TYPE_TFDT: + tfdt_del(a); + return; + case GF_ISOM_BOX_TYPE_TRUN: + trun_del(a); + return; #endif case GF_ISOM_SUBTYPE_3GP_AMR: @@ -851,91 +1190,156 @@ void gf_isom_box_del(GF_Box *a) case GF_ISOM_SUBTYPE_3GP_SMV: gppa_del(a); return; - case GF_ISOM_SUBTYPE_3GP_H263: gppv_del(a); return; - case GF_ISOM_BOX_TYPE_DAMR: - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_SUBTYPE_3GP_H263: + gppv_del(a); + return; + case GF_ISOM_BOX_TYPE_DAMR: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: - case GF_ISOM_BOX_TYPE_D263: - gppc_del(a); return; + case GF_ISOM_BOX_TYPE_D263: + gppc_del(a); + return; /*AVC boxes*/ - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: - avcc_del(a); return; - case GF_ISOM_BOX_TYPE_BTRT: btrt_del(a); return; - case GF_ISOM_BOX_TYPE_M4DS: m4ds_del(a); return; - case GF_ISOM_BOX_TYPE_AVC1: - case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: + avcc_del(a); + return; + case GF_ISOM_BOX_TYPE_BTRT: + btrt_del(a); + return; + case GF_ISOM_BOX_TYPE_M4DS: + m4ds_del(a); + return; + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_HVC1: case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: - mp4v_del(a); return; + case GF_ISOM_BOX_TYPE_HVT1: + mp4v_del(a); + return; case GF_ISOM_BOX_TYPE_HVCC: case GF_ISOM_BOX_TYPE_SHCC: - hvcc_del(a); return; + hvcc_del(a); + return; /*3GPP streaming text*/ - case GF_ISOM_BOX_TYPE_FTAB: ftab_del(a); return; - case GF_ISOM_BOX_TYPE_TX3G: tx3g_del(a); return; - case GF_ISOM_BOX_TYPE_TEXT: text_del(a); return; - case GF_ISOM_BOX_TYPE_STYL: styl_del(a); return; - case GF_ISOM_BOX_TYPE_HLIT: hlit_del(a); return; - case GF_ISOM_BOX_TYPE_HCLR: hclr_del(a); return; - case GF_ISOM_BOX_TYPE_KROK: krok_del(a); return; - case GF_ISOM_BOX_TYPE_DLAY: dlay_del(a); return; - case GF_ISOM_BOX_TYPE_HREF: href_del(a); return; - case GF_ISOM_BOX_TYPE_TBOX: tbox_del(a); return; - case GF_ISOM_BOX_TYPE_BLNK: blnk_del(a); return; - case GF_ISOM_BOX_TYPE_TWRP: twrp_del(a); return; + case GF_ISOM_BOX_TYPE_FTAB: + ftab_del(a); + return; + case GF_ISOM_BOX_TYPE_TX3G: + tx3g_del(a); + return; + case GF_ISOM_BOX_TYPE_TEXT: + text_del(a); + return; + case GF_ISOM_BOX_TYPE_STYL: + styl_del(a); + return; + case GF_ISOM_BOX_TYPE_HLIT: + hlit_del(a); + return; + case GF_ISOM_BOX_TYPE_HCLR: + hclr_del(a); + return; + case GF_ISOM_BOX_TYPE_KROK: + krok_del(a); + return; + case GF_ISOM_BOX_TYPE_DLAY: + dlay_del(a); + return; + case GF_ISOM_BOX_TYPE_HREF: + href_del(a); + return; + case GF_ISOM_BOX_TYPE_TBOX: + tbox_del(a); + return; + case GF_ISOM_BOX_TYPE_BLNK: + blnk_del(a); + return; + case GF_ISOM_BOX_TYPE_TWRP: + twrp_del(a); + return; /* ISMA 1.0 Encryption and Authentication V 1.0 */ - case GF_ISOM_BOX_TYPE_IKMS: iKMS_del(a); return; - case GF_ISOM_BOX_TYPE_ISFM: iSFM_del(a); return; + case GF_ISOM_BOX_TYPE_IKMS: + iKMS_del(a); + return; + case GF_ISOM_BOX_TYPE_ISFM: + iSFM_del(a); + return; /* ISO FF extensions for MPEG-21 */ - case GF_ISOM_BOX_TYPE_META: meta_del(a); return; - case GF_ISOM_BOX_TYPE_XML: xml_del(a); return; - case GF_ISOM_BOX_TYPE_BXML: bxml_del(a); return; - case GF_ISOM_BOX_TYPE_ILOC: iloc_del(a); return; - case GF_ISOM_BOX_TYPE_PITM: pitm_del(a); return; - case GF_ISOM_BOX_TYPE_IPRO: ipro_del(a); return; - case GF_ISOM_BOX_TYPE_INFE: infe_del(a); return; - case GF_ISOM_BOX_TYPE_IINF: iinf_del(a); return; - case GF_ISOM_BOX_TYPE_SINF: sinf_del(a); return; - case GF_ISOM_BOX_TYPE_FRMA: frma_del(a); return; - case GF_ISOM_BOX_TYPE_SCHM: schm_del(a); return; - case GF_ISOM_BOX_TYPE_SCHI: schi_del(a); return; - - case GF_ISOM_BOX_TYPE_ENCA: + case GF_ISOM_BOX_TYPE_META: + meta_del(a); + return; + case GF_ISOM_BOX_TYPE_XML: + xml_del(a); + return; + case GF_ISOM_BOX_TYPE_BXML: + bxml_del(a); + return; + case GF_ISOM_BOX_TYPE_ILOC: + iloc_del(a); + return; + case GF_ISOM_BOX_TYPE_PITM: + pitm_del(a); + return; + case GF_ISOM_BOX_TYPE_IPRO: + ipro_del(a); + return; + case GF_ISOM_BOX_TYPE_INFE: + infe_del(a); + return; + case GF_ISOM_BOX_TYPE_IINF: + iinf_del(a); + return; + case GF_ISOM_BOX_TYPE_SINF: + sinf_del(a); + return; + case GF_ISOM_BOX_TYPE_FRMA: + frma_del(a); + return; + case GF_ISOM_BOX_TYPE_SCHM: + schm_del(a); + return; + case GF_ISOM_BOX_TYPE_SCHI: + schi_del(a); + return; + + case GF_ISOM_BOX_TYPE_ENCA: case GF_ISOM_BOX_TYPE_ENCV: case GF_ISOM_BOX_TYPE_ENCS: - { - GF_ProtectionInfoBox *sinf = gf_list_get(((GF_SampleEntryBox *)a)->protections, 0); - a->type = sinf->original_format->data_format; - gf_isom_box_del(a); - } + { + GF_ProtectionInfoBox *sinf = gf_list_get(((GF_SampleEntryBox *)a)->protections, 0); + a->type = sinf->original_format->data_format; + gf_isom_box_del(a); + } + return; + case GF_ISOM_BOX_TYPE_SENC: + senc_del(a); return; - case GF_ISOM_BOX_TYPE_SENC: senc_del(a); return; case GF_ISOM_BOX_TYPE_UUID: switch (((GF_UnknownUUIDBox *)a)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: + case GF_ISOM_BOX_UUID_TENC: piff_tenc_del(a); - return; - case GF_ISOM_BOX_UUID_PSEC: + return; + case GF_ISOM_BOX_UUID_PSEC: piff_psec_del(a); - return; - case GF_ISOM_BOX_UUID_PSSH: + return; + case GF_ISOM_BOX_UUID_PSSH: piff_pssh_del(a); - return; - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: + return; + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: default: uuid_del(a); return; @@ -944,15 +1348,25 @@ void gf_isom_box_del(GF_Box *a) #ifndef GPAC_DISABLE_ISOM_ADOBE /* Adobe extensions */ - case GF_ISOM_BOX_TYPE_ABST: abst_del(a); return; - case GF_ISOM_BOX_TYPE_AFRA: afra_del(a); return; - case GF_ISOM_BOX_TYPE_ASRT: asrt_del(a); return; - case GF_ISOM_BOX_TYPE_AFRT: afrt_del(a); return; + case GF_ISOM_BOX_TYPE_ABST: + abst_del(a); + return; + case GF_ISOM_BOX_TYPE_AFRA: + afra_del(a); + return; + case GF_ISOM_BOX_TYPE_ASRT: + asrt_del(a); + return; + case GF_ISOM_BOX_TYPE_AFRT: + afrt_del(a); + return; #endif /* Apple extensions */ - case GF_ISOM_BOX_TYPE_ILST: ilst_del(a); return; - + case GF_ISOM_BOX_TYPE_ILST: + ilst_del(a); + return; + case GF_ISOM_BOX_TYPE_0xA9NAM: case GF_ISOM_BOX_TYPE_0xA9CMT: case GF_ISOM_BOX_TYPE_0xA9DAY: @@ -978,66 +1392,148 @@ void gf_isom_box_del(GF_Box *a) ListItem_del(a); return; - case GF_ISOM_BOX_TYPE_DATA: data_del(a); return; + case GF_ISOM_BOX_TYPE_DATA: + data_del(a); + return; - case GF_ISOM_BOX_TYPE_OHDR: ohdr_del(a); return; - case GF_ISOM_BOX_TYPE_GRPI: grpi_del(a); return; - case GF_ISOM_BOX_TYPE_MDRI: mdri_del(a); return; - case GF_ISOM_BOX_TYPE_ODTT: odtt_del(a); return; - case GF_ISOM_BOX_TYPE_ODRB: odrb_del(a); return; - case GF_ISOM_BOX_TYPE_ODKM: odkm_del(a); return; - case GF_ISOM_BOX_TYPE_ODAF: iSFM_del(a); return; + case GF_ISOM_BOX_TYPE_OHDR: + ohdr_del(a); + return; + case GF_ISOM_BOX_TYPE_GRPI: + grpi_del(a); + return; + case GF_ISOM_BOX_TYPE_MDRI: + mdri_del(a); + return; + case GF_ISOM_BOX_TYPE_ODTT: + odtt_del(a); + return; + case GF_ISOM_BOX_TYPE_ODRB: + odrb_del(a); + return; + case GF_ISOM_BOX_TYPE_ODKM: + odkm_del(a); + return; + case GF_ISOM_BOX_TYPE_ODAF: + iSFM_del(a); + return; - case GF_ISOM_BOX_TYPE_PASP: pasp_del(a); return; - case GF_ISOM_BOX_TYPE_TSEL: tsel_del(a); return; + case GF_ISOM_BOX_TYPE_PASP: + pasp_del(a); + return; + case GF_ISOM_BOX_TYPE_TSEL: + tsel_del(a); + return; case GF_ISOM_BOX_TYPE_METX: case GF_ISOM_BOX_TYPE_METT: metx_del(a); return; - case GF_ISOM_BOX_TYPE_DIMS: dims_del(a); return; - case GF_ISOM_BOX_TYPE_DIMC: dimC_del(a); return; - case GF_ISOM_BOX_TYPE_DIST: diST_del(a); return; + case GF_ISOM_BOX_TYPE_DIMS: + dims_del(a); + return; + case GF_ISOM_BOX_TYPE_DIMC: + dimC_del(a); + return; + case GF_ISOM_BOX_TYPE_DIST: + diST_del(a); + return; - case GF_ISOM_BOX_TYPE_AC3: ac3_del(a); return; - case GF_ISOM_BOX_TYPE_DAC3: dac3_del(a); return; + case GF_ISOM_BOX_TYPE_AC3: + ac3_del(a); + return; + case GF_ISOM_BOX_TYPE_DAC3: + dac3_del(a); + return; - case GF_ISOM_BOX_TYPE_LSRC: lsrc_del(a); return; - case GF_ISOM_BOX_TYPE_LSR1: lsr1_del(a); return; + case GF_ISOM_BOX_TYPE_LSRC: + lsrc_del(a); + return; + case GF_ISOM_BOX_TYPE_LSR1: + lsr1_del(a); + return; - case GF_ISOM_BOX_TYPE_SIDX: sidx_del(a); return; - case GF_ISOM_BOX_TYPE_PCRB: pcrb_del(a); return; - case GF_ISOM_BOX_TYPE_SUBS: subs_del(a); return; - case GF_ISOM_BOX_TYPE_RVCC: rvcc_del(a); return; + case GF_ISOM_BOX_TYPE_SIDX: + sidx_del(a); + return; + case GF_ISOM_BOX_TYPE_PCRB: + pcrb_del(a); + return; + case GF_ISOM_BOX_TYPE_SUBS: + subs_del(a); + return; + case GF_ISOM_BOX_TYPE_RVCC: + rvcc_del(a); + return; - case GF_ISOM_BOX_TYPE_PRFT: prft_del(a); return; + case GF_ISOM_BOX_TYPE_PRFT: + prft_del(a); + return; #ifndef GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_STSE: stse_del(a); return; - case GF_ISOM_BOX_TYPE_STTC: boxstring_del(a); return; + case GF_ISOM_BOX_TYPE_STSE: + stse_del(a); + return; + case GF_ISOM_BOX_TYPE_STTC: + boxstring_del(a); + return; - case GF_ISOM_BOX_TYPE_VTCU: vtcu_del(a); return; - case GF_ISOM_BOX_TYPE_VTTE: vtte_del(a); return; - case GF_ISOM_BOX_TYPE_VTTC: boxstring_del(a); return; - case GF_ISOM_BOX_TYPE_CTIM: boxstring_del(a); return; - case GF_ISOM_BOX_TYPE_IDEN: boxstring_del(a); return; - case GF_ISOM_BOX_TYPE_STTG: boxstring_del(a); return; - case GF_ISOM_BOX_TYPE_PAYL: boxstring_del(a); return; - case GF_ISOM_BOX_TYPE_WVTT: wvtt_del(a); return; + case GF_ISOM_BOX_TYPE_VTCU: + vtcu_del(a); + return; + case GF_ISOM_BOX_TYPE_VTTE: + vtte_del(a); + return; + case GF_ISOM_BOX_TYPE_VTTC: + boxstring_del(a); + return; + case GF_ISOM_BOX_TYPE_CTIM: + boxstring_del(a); + return; + case GF_ISOM_BOX_TYPE_IDEN: + boxstring_del(a); + return; + case GF_ISOM_BOX_TYPE_STTG: + boxstring_del(a); + return; + case GF_ISOM_BOX_TYPE_PAYL: + boxstring_del(a); + return; + case GF_ISOM_BOX_TYPE_WVTT: + wvtt_del(a); + return; - case GF_ISOM_BOX_TYPE_STPP: stpp_del(a); return; - case GF_ISOM_BOX_TYPE_SBTT: metx_del(a); return; + case GF_ISOM_BOX_TYPE_STPP: + stpp_del(a); + return; + case GF_ISOM_BOX_TYPE_SBTT: + metx_del(a); + return; #endif // GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_ADKM: adkm_del(a); return; - case GF_ISOM_BOX_TYPE_AHDR: ahdr_del(a); return; - case GF_ISOM_BOX_TYPE_APRM: aprm_del(a); return; - case GF_ISOM_BOX_TYPE_AEIB: aeib_del(a); return; - case GF_ISOM_BOX_TYPE_AKEY: akey_del(a); return; - case GF_ISOM_BOX_TYPE_FLXS: flxs_del(a); return; - case GF_ISOM_BOX_TYPE_ADAF: adaf_del(a); return; + case GF_ISOM_BOX_TYPE_ADKM: + adkm_del(a); + return; + case GF_ISOM_BOX_TYPE_AHDR: + ahdr_del(a); + return; + case GF_ISOM_BOX_TYPE_APRM: + aprm_del(a); + return; + case GF_ISOM_BOX_TYPE_AEIB: + aeib_del(a); + return; + case GF_ISOM_BOX_TYPE_AKEY: + akey_del(a); + return; + case GF_ISOM_BOX_TYPE_FLXS: + flxs_del(a); + return; + case GF_ISOM_BOX_TYPE_ADAF: + adaf_del(a); + return; default: defa_del(a); @@ -1054,108 +1550,191 @@ GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_FREE: case GF_ISOM_BOX_TYPE_SKIP: return free_Read(a, bs); - case GF_ISOM_BOX_TYPE_MDAT: return mdat_Read(a, bs); - case GF_ISOM_BOX_TYPE_MOOV: return moov_Read(a, bs); - case GF_ISOM_BOX_TYPE_MVHD: return mvhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_MDHD: return mdhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_VMHD: return vmhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_SMHD: return smhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_HMHD: return hmhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_MDAT: + return mdat_Read(a, bs); + case GF_ISOM_BOX_TYPE_MOOV: + return moov_Read(a, bs); + case GF_ISOM_BOX_TYPE_MVHD: + return mvhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_MDHD: + return mdhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_VMHD: + return vmhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_SMHD: + return smhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_HMHD: + return hmhd_Read(a, bs); case GF_ISOM_BOX_TYPE_ODHD: case GF_ISOM_BOX_TYPE_CRHD: case GF_ISOM_BOX_TYPE_SDHD: case GF_ISOM_BOX_TYPE_NMHD: case GF_ISOM_BOX_TYPE_STHD: return nmhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_STBL: return stbl_Read(a, bs); - case GF_ISOM_BOX_TYPE_DINF: return dinf_Read(a, bs); - case GF_ISOM_BOX_TYPE_URL: return url_Read(a, bs); - case GF_ISOM_BOX_TYPE_URN: return urn_Read(a, bs); - case GF_ISOM_BOX_TYPE_CPRT: return cprt_Read(a, bs); - case GF_ISOM_BOX_TYPE_HDLR: return hdlr_Read(a, bs); - case GF_ISOM_BOX_TYPE_IODS: return iods_Read(a, bs); - case GF_ISOM_BOX_TYPE_TRAK: return trak_Read(a, bs); - case GF_ISOM_BOX_TYPE_MP4S: return mp4s_Read(a, bs); - case GF_ISOM_BOX_TYPE_MP4V: return mp4v_Read(a, bs); - case GF_ISOM_BOX_TYPE_MP4A: return mp4a_Read(a, bs); - case GF_ISOM_BOX_TYPE_EDTS: return edts_Read(a, bs); - case GF_ISOM_BOX_TYPE_UDTA: return udta_Read(a, bs); - case GF_ISOM_BOX_TYPE_DREF: return dref_Read(a, bs); - case GF_ISOM_BOX_TYPE_STSD: return stsd_Read(a, bs); - case GF_ISOM_BOX_TYPE_STTS: return stts_Read(a, bs); - case GF_ISOM_BOX_TYPE_CTTS: return ctts_Read(a, bs); - case GF_ISOM_BOX_TYPE_CSLG: return cslg_Read(a, bs); - case GF_ISOM_BOX_TYPE_STSH: return stsh_Read(a, bs); - case GF_ISOM_BOX_TYPE_ELST: return elst_Read(a, bs); - case GF_ISOM_BOX_TYPE_STSC: return stsc_Read(a, bs); + case GF_ISOM_BOX_TYPE_STBL: + return stbl_Read(a, bs); + case GF_ISOM_BOX_TYPE_DINF: + return dinf_Read(a, bs); + case GF_ISOM_BOX_TYPE_URL: + return url_Read(a, bs); + case GF_ISOM_BOX_TYPE_URN: + return urn_Read(a, bs); + case GF_ISOM_BOX_TYPE_CPRT: + return cprt_Read(a, bs); + case GF_ISOM_BOX_TYPE_HDLR: + return hdlr_Read(a, bs); + case GF_ISOM_BOX_TYPE_IODS: + return iods_Read(a, bs); + case GF_ISOM_BOX_TYPE_TRAK: + return trak_Read(a, bs); + case GF_ISOM_BOX_TYPE_MP4S: + return mp4s_Read(a, bs); + case GF_ISOM_BOX_TYPE_MP4V: + return mp4v_Read(a, bs); + case GF_ISOM_BOX_TYPE_MP4A: + return mp4a_Read(a, bs); + case GF_ISOM_BOX_TYPE_EDTS: + return edts_Read(a, bs); + case GF_ISOM_BOX_TYPE_UDTA: + return udta_Read(a, bs); + case GF_ISOM_BOX_TYPE_DREF: + return dref_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSD: + return stsd_Read(a, bs); + case GF_ISOM_BOX_TYPE_STTS: + return stts_Read(a, bs); + case GF_ISOM_BOX_TYPE_CTTS: + return ctts_Read(a, bs); + case GF_ISOM_BOX_TYPE_CSLG: + return cslg_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSH: + return stsh_Read(a, bs); + case GF_ISOM_BOX_TYPE_ELST: + return elst_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSC: + return stsc_Read(a, bs); case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: return stsz_Read(a, bs); - case GF_ISOM_BOX_TYPE_STCO: return stco_Read(a, bs); - case GF_ISOM_BOX_TYPE_STSS: return stss_Read(a, bs); - case GF_ISOM_BOX_TYPE_STDP: return stdp_Read(a, bs); - case GF_ISOM_BOX_TYPE_SDTP: return sdtp_Read(a, bs); - case GF_ISOM_BOX_TYPE_CO64: return co64_Read(a, bs); - case GF_ISOM_BOX_TYPE_ESDS: return esds_Read(a, bs); - case GF_ISOM_BOX_TYPE_MINF: return minf_Read(a, bs); - case GF_ISOM_BOX_TYPE_TKHD: return tkhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_TREF: return tref_Read(a, bs); - case GF_ISOM_BOX_TYPE_MDIA: return mdia_Read(a, bs); - case GF_ISOM_BOX_TYPE_CHPL: return chpl_Read(a, bs); - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - return ftyp_Read(a, bs); - case GF_ISOM_BOX_TYPE_PADB: return padb_Read(a, bs); - case GF_ISOM_BOX_TYPE_VOID: return void_Read(a, bs); - case GF_ISOM_BOX_TYPE_STSF: return stsf_Read(a, bs); - case GF_ISOM_BOX_TYPE_PDIN: return pdin_Read(a, bs); - case GF_ISOM_BOX_TYPE_SBGP: return sbgp_Read(a, bs); - case GF_ISOM_BOX_TYPE_SGPD: return sgpd_Read(a, bs); - case GF_ISOM_BOX_TYPE_SAIZ: return saiz_Read(a, bs); - case GF_ISOM_BOX_TYPE_SAIO: return saio_Read(a, bs); - case GF_ISOM_BOX_TYPE_PSSH: return pssh_Read(a, bs); - case GF_ISOM_BOX_TYPE_TENC: return tenc_Read(a, bs); + case GF_ISOM_BOX_TYPE_STCO: + return stco_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSS: + return stss_Read(a, bs); + case GF_ISOM_BOX_TYPE_STDP: + return stdp_Read(a, bs); + case GF_ISOM_BOX_TYPE_SDTP: + return sdtp_Read(a, bs); + case GF_ISOM_BOX_TYPE_CO64: + return co64_Read(a, bs); + case GF_ISOM_BOX_TYPE_ESDS: + return esds_Read(a, bs); + case GF_ISOM_BOX_TYPE_MINF: + return minf_Read(a, bs); + case GF_ISOM_BOX_TYPE_TKHD: + return tkhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_TREF: + return tref_Read(a, bs); + case GF_ISOM_BOX_TYPE_MDIA: + return mdia_Read(a, bs); + case GF_ISOM_BOX_TYPE_CHPL: + return chpl_Read(a, bs); + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + return ftyp_Read(a, bs); + case GF_ISOM_BOX_TYPE_PADB: + return padb_Read(a, bs); + case GF_ISOM_BOX_TYPE_VOID: + return void_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSF: + return stsf_Read(a, bs); + case GF_ISOM_BOX_TYPE_PDIN: + return pdin_Read(a, bs); + case GF_ISOM_BOX_TYPE_SBGP: + return sbgp_Read(a, bs); + case GF_ISOM_BOX_TYPE_SGPD: + return sgpd_Read(a, bs); + case GF_ISOM_BOX_TYPE_SAIZ: + return saiz_Read(a, bs); + case GF_ISOM_BOX_TYPE_SAIO: + return saio_Read(a, bs); + case GF_ISOM_BOX_TYPE_PSSH: + return pssh_Read(a, bs); + case GF_ISOM_BOX_TYPE_TENC: + return tenc_Read(a, bs); #ifndef GPAC_DISABLE_ISOM_HINTING - case GF_ISOM_BOX_TYPE_RTP_STSD: return ghnt_Read(a, bs); - case GF_ISOM_BOX_TYPE_RTPO: return rtpo_Read(a, bs); - case GF_ISOM_BOX_TYPE_HNTI: return hnti_Read(a, bs); - case GF_ISOM_BOX_TYPE_SDP: return sdp_Read(a, bs); - case GF_ISOM_BOX_TYPE_HINF: return hinf_Read(a, bs); - case GF_ISOM_BOX_TYPE_RELY: return rely_Read(a, bs); - case GF_ISOM_BOX_TYPE_TIMS: return tims_Read(a, bs); - case GF_ISOM_BOX_TYPE_TSRO: return tsro_Read(a, bs); - case GF_ISOM_BOX_TYPE_SNRO: return snro_Read(a, bs); - case GF_ISOM_BOX_TYPE_TRPY: return trpy_Read(a, bs); - case GF_ISOM_BOX_TYPE_NUMP: return nump_Read(a, bs); - case GF_ISOM_BOX_TYPE_TOTL: return totl_Read(a, bs); - case GF_ISOM_BOX_TYPE_NPCK: return npck_Read(a, bs); - case GF_ISOM_BOX_TYPE_TPYL: return tpyl_Read(a, bs); - case GF_ISOM_BOX_TYPE_TPAY: return tpay_Read(a, bs); - case GF_ISOM_BOX_TYPE_MAXR: return maxr_Read(a, bs); - case GF_ISOM_BOX_TYPE_DMED: return dmed_Read(a, bs); - case GF_ISOM_BOX_TYPE_DIMM: return dimm_Read(a, bs); - case GF_ISOM_BOX_TYPE_DREP: return drep_Read(a, bs); - case GF_ISOM_BOX_TYPE_TMIN: return tmin_Read(a, bs); - case GF_ISOM_BOX_TYPE_TMAX: return tmax_Read(a, bs); - case GF_ISOM_BOX_TYPE_PMAX: return pmax_Read(a, bs); - case GF_ISOM_BOX_TYPE_DMAX: return dmax_Read(a, bs); - case GF_ISOM_BOX_TYPE_PAYT: return payt_Read(a, bs); - case GF_ISOM_BOX_TYPE_NAME: return name_Read(a, bs); + case GF_ISOM_BOX_TYPE_RTP_STSD: + return ghnt_Read(a, bs); + case GF_ISOM_BOX_TYPE_RTPO: + return rtpo_Read(a, bs); + case GF_ISOM_BOX_TYPE_HNTI: + return hnti_Read(a, bs); + case GF_ISOM_BOX_TYPE_SDP: + return sdp_Read(a, bs); + case GF_ISOM_BOX_TYPE_HINF: + return hinf_Read(a, bs); + case GF_ISOM_BOX_TYPE_RELY: + return rely_Read(a, bs); + case GF_ISOM_BOX_TYPE_TIMS: + return tims_Read(a, bs); + case GF_ISOM_BOX_TYPE_TSRO: + return tsro_Read(a, bs); + case GF_ISOM_BOX_TYPE_SNRO: + return snro_Read(a, bs); + case GF_ISOM_BOX_TYPE_TRPY: + return trpy_Read(a, bs); + case GF_ISOM_BOX_TYPE_NUMP: + return nump_Read(a, bs); + case GF_ISOM_BOX_TYPE_TOTL: + return totl_Read(a, bs); + case GF_ISOM_BOX_TYPE_NPCK: + return npck_Read(a, bs); + case GF_ISOM_BOX_TYPE_TPYL: + return tpyl_Read(a, bs); + case GF_ISOM_BOX_TYPE_TPAY: + return tpay_Read(a, bs); + case GF_ISOM_BOX_TYPE_MAXR: + return maxr_Read(a, bs); + case GF_ISOM_BOX_TYPE_DMED: + return dmed_Read(a, bs); + case GF_ISOM_BOX_TYPE_DIMM: + return dimm_Read(a, bs); + case GF_ISOM_BOX_TYPE_DREP: + return drep_Read(a, bs); + case GF_ISOM_BOX_TYPE_TMIN: + return tmin_Read(a, bs); + case GF_ISOM_BOX_TYPE_TMAX: + return tmax_Read(a, bs); + case GF_ISOM_BOX_TYPE_PMAX: + return pmax_Read(a, bs); + case GF_ISOM_BOX_TYPE_DMAX: + return dmax_Read(a, bs); + case GF_ISOM_BOX_TYPE_PAYT: + return payt_Read(a, bs); + case GF_ISOM_BOX_TYPE_NAME: + return name_Read(a, bs); #endif /*GPAC_DISABLE_ISOM_HINTING*/ - + #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_MVEX: return mvex_Read(a, bs); - case GF_ISOM_BOX_TYPE_MEHD: return mehd_Read(a, bs); - case GF_ISOM_BOX_TYPE_TREX: return trex_Read(a, bs); - case GF_ISOM_BOX_TYPE_MOOF: return moof_Read(a, bs); - case GF_ISOM_BOX_TYPE_MFHD: return mfhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_TRAF: return traf_Read(a, bs); - case GF_ISOM_BOX_TYPE_TFHD: return tfhd_Read(a, bs); - case GF_ISOM_BOX_TYPE_TFDT: return tfdt_Read(a, bs); - case GF_ISOM_BOX_TYPE_TRUN: return trun_Read(a, bs); + case GF_ISOM_BOX_TYPE_MVEX: + return mvex_Read(a, bs); + case GF_ISOM_BOX_TYPE_MEHD: + return mehd_Read(a, bs); + case GF_ISOM_BOX_TYPE_TREX: + return trex_Read(a, bs); + case GF_ISOM_BOX_TYPE_MOOF: + return moof_Read(a, bs); + case GF_ISOM_BOX_TYPE_MFHD: + return mfhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_TRAF: + return traf_Read(a, bs); + case GF_ISOM_BOX_TYPE_TFHD: + return tfhd_Read(a, bs); + case GF_ISOM_BOX_TYPE_TFDT: + return tfdt_Read(a, bs); + case GF_ISOM_BOX_TYPE_TRUN: + return trun_Read(a, bs); #endif - + /*3GPP boxes*/ case GF_ISOM_SUBTYPE_3GP_AMR: @@ -1164,91 +1743,133 @@ GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs) case GF_ISOM_SUBTYPE_3GP_QCELP: case GF_ISOM_SUBTYPE_3GP_SMV: return gppa_Read(a, bs); - case GF_ISOM_SUBTYPE_3GP_H263: return gppv_Read(a, bs); + case GF_ISOM_SUBTYPE_3GP_H263: + return gppv_Read(a, bs); case GF_ISOM_BOX_TYPE_DAMR: - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: case GF_ISOM_BOX_TYPE_D263: return gppc_Read(a, bs); - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: return avcc_Read(a, bs); - case GF_ISOM_BOX_TYPE_BTRT: return btrt_Read(a, bs); - case GF_ISOM_BOX_TYPE_M4DS: return m4ds_Read(a, bs); - case GF_ISOM_BOX_TYPE_AVC1: - case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_BTRT: + return btrt_Read(a, bs); + case GF_ISOM_BOX_TYPE_M4DS: + return m4ds_Read(a, bs); + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_HVC1: case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: return mp4v_Read(a, bs); - case GF_ISOM_BOX_TYPE_HVCC: + case GF_ISOM_BOX_TYPE_HVCC: case GF_ISOM_BOX_TYPE_SHCC: return hvcc_Read(a, bs); /*3GPP streaming text*/ - case GF_ISOM_BOX_TYPE_FTAB: return ftab_Read(a, bs); - case GF_ISOM_BOX_TYPE_TEXT: return text_Read(a, bs); - case GF_ISOM_BOX_TYPE_TX3G: return tx3g_Read(a, bs); - case GF_ISOM_BOX_TYPE_STYL: return styl_Read(a, bs); - case GF_ISOM_BOX_TYPE_HLIT: return hlit_Read(a, bs); - case GF_ISOM_BOX_TYPE_HCLR: return hclr_Read(a, bs); - case GF_ISOM_BOX_TYPE_KROK: return krok_Read(a, bs); - case GF_ISOM_BOX_TYPE_DLAY: return dlay_Read(a, bs); - case GF_ISOM_BOX_TYPE_HREF: return href_Read(a, bs); - case GF_ISOM_BOX_TYPE_TBOX: return tbox_Read(a, bs); - case GF_ISOM_BOX_TYPE_BLNK: return blnk_Read(a, bs); - case GF_ISOM_BOX_TYPE_TWRP: return twrp_Read(a, bs); + case GF_ISOM_BOX_TYPE_FTAB: + return ftab_Read(a, bs); + case GF_ISOM_BOX_TYPE_TEXT: + return text_Read(a, bs); + case GF_ISOM_BOX_TYPE_TX3G: + return tx3g_Read(a, bs); + case GF_ISOM_BOX_TYPE_STYL: + return styl_Read(a, bs); + case GF_ISOM_BOX_TYPE_HLIT: + return hlit_Read(a, bs); + case GF_ISOM_BOX_TYPE_HCLR: + return hclr_Read(a, bs); + case GF_ISOM_BOX_TYPE_KROK: + return krok_Read(a, bs); + case GF_ISOM_BOX_TYPE_DLAY: + return dlay_Read(a, bs); + case GF_ISOM_BOX_TYPE_HREF: + return href_Read(a, bs); + case GF_ISOM_BOX_TYPE_TBOX: + return tbox_Read(a, bs); + case GF_ISOM_BOX_TYPE_BLNK: + return blnk_Read(a, bs); + case GF_ISOM_BOX_TYPE_TWRP: + return twrp_Read(a, bs); /* ISMA 1.0 Encryption and Authentication V 1.0 */ - case GF_ISOM_BOX_TYPE_IKMS: return iKMS_Read(a, bs); - case GF_ISOM_BOX_TYPE_ISFM: return iSFM_Read(a, bs); + case GF_ISOM_BOX_TYPE_IKMS: + return iKMS_Read(a, bs); + case GF_ISOM_BOX_TYPE_ISFM: + return iSFM_Read(a, bs); /* ISO FF extensions for MPEG-21 */ - case GF_ISOM_BOX_TYPE_META: return meta_Read(a, bs); - case GF_ISOM_BOX_TYPE_XML: return xml_Read(a, bs); - case GF_ISOM_BOX_TYPE_BXML: return bxml_Read(a, bs); - case GF_ISOM_BOX_TYPE_ILOC: return iloc_Read(a, bs); - case GF_ISOM_BOX_TYPE_PITM: return pitm_Read(a, bs); - case GF_ISOM_BOX_TYPE_IPRO: return ipro_Read(a, bs); - case GF_ISOM_BOX_TYPE_INFE: return infe_Read(a, bs); - case GF_ISOM_BOX_TYPE_IINF: return iinf_Read(a, bs); - case GF_ISOM_BOX_TYPE_SINF: return sinf_Read(a, bs); - case GF_ISOM_BOX_TYPE_FRMA: return frma_Read(a, bs); - case GF_ISOM_BOX_TYPE_SCHM: return schm_Read(a, bs); - case GF_ISOM_BOX_TYPE_SCHI: return schi_Read(a, bs); - case GF_ISOM_BOX_TYPE_ENCA: return mp4a_Read(a, bs); - case GF_ISOM_BOX_TYPE_ENCV: return mp4v_Read(a, bs); - case GF_ISOM_BOX_TYPE_ENCS: return mp4s_Read(a, bs); - case GF_ISOM_BOX_TYPE_SENC: return senc_Read(a, bs); - case GF_ISOM_BOX_TYPE_UUID: + case GF_ISOM_BOX_TYPE_META: + return meta_Read(a, bs); + case GF_ISOM_BOX_TYPE_XML: + return xml_Read(a, bs); + case GF_ISOM_BOX_TYPE_BXML: + return bxml_Read(a, bs); + case GF_ISOM_BOX_TYPE_ILOC: + return iloc_Read(a, bs); + case GF_ISOM_BOX_TYPE_PITM: + return pitm_Read(a, bs); + case GF_ISOM_BOX_TYPE_IPRO: + return ipro_Read(a, bs); + case GF_ISOM_BOX_TYPE_INFE: + return infe_Read(a, bs); + case GF_ISOM_BOX_TYPE_IINF: + return iinf_Read(a, bs); + case GF_ISOM_BOX_TYPE_SINF: + return sinf_Read(a, bs); + case GF_ISOM_BOX_TYPE_FRMA: + return frma_Read(a, bs); + case GF_ISOM_BOX_TYPE_SCHM: + return schm_Read(a, bs); + case GF_ISOM_BOX_TYPE_SCHI: + return schi_Read(a, bs); + case GF_ISOM_BOX_TYPE_ENCA: + return mp4a_Read(a, bs); + case GF_ISOM_BOX_TYPE_ENCV: + return mp4v_Read(a, bs); + case GF_ISOM_BOX_TYPE_ENCS: + return mp4s_Read(a, bs); + case GF_ISOM_BOX_TYPE_SENC: + return senc_Read(a, bs); + case GF_ISOM_BOX_TYPE_UUID: switch (((GF_UnknownUUIDBox *)a)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: return piff_tenc_Read(a, bs); - case GF_ISOM_BOX_UUID_PSEC: return piff_psec_Read(a, bs); - case GF_ISOM_BOX_UUID_PSSH: return piff_pssh_Read(a, bs); - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: + case GF_ISOM_BOX_UUID_TENC: + return piff_tenc_Read(a, bs); + case GF_ISOM_BOX_UUID_PSEC: + return piff_psec_Read(a, bs); + case GF_ISOM_BOX_UUID_PSSH: + return piff_pssh_Read(a, bs); + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: default: return uuid_Read(a, bs); } #ifndef GPAC_DISABLE_ISOM_ADOBE /* Adobe extensions */ - case GF_ISOM_BOX_TYPE_ABST: return abst_Read(a, bs); - case GF_ISOM_BOX_TYPE_AFRA: return afra_Read(a, bs); - case GF_ISOM_BOX_TYPE_ASRT: return asrt_Read(a, bs); - case GF_ISOM_BOX_TYPE_AFRT: return afrt_Read(a, bs); + case GF_ISOM_BOX_TYPE_ABST: + return abst_Read(a, bs); + case GF_ISOM_BOX_TYPE_AFRA: + return afra_Read(a, bs); + case GF_ISOM_BOX_TYPE_ASRT: + return asrt_Read(a, bs); + case GF_ISOM_BOX_TYPE_AFRT: + return afrt_Read(a, bs); #endif /* Apple extensions */ - case GF_ISOM_BOX_TYPE_ILST: return ilst_Read(a, bs); + case GF_ISOM_BOX_TYPE_ILST: + return ilst_Read(a, bs); case GF_ISOM_BOX_TYPE_0xA9NAM: case GF_ISOM_BOX_TYPE_0xA9CMT: @@ -1274,64 +1895,105 @@ GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_COVR: return ListItem_Read(a, bs); - case GF_ISOM_BOX_TYPE_DATA: return data_Read(a, bs); - - case GF_ISOM_BOX_TYPE_OHDR: return ohdr_Read(a, bs); - case GF_ISOM_BOX_TYPE_GRPI: return grpi_Read(a, bs); - case GF_ISOM_BOX_TYPE_MDRI: return mdri_Read(a, bs); - case GF_ISOM_BOX_TYPE_ODTT: return odtt_Read(a, bs); - case GF_ISOM_BOX_TYPE_ODRB: return odrb_Read(a, bs); - case GF_ISOM_BOX_TYPE_ODKM: return odkm_Read(a, bs); - case GF_ISOM_BOX_TYPE_ODAF: return iSFM_Read(a, bs); - - case GF_ISOM_BOX_TYPE_PASP: return pasp_Read(a, bs); - case GF_ISOM_BOX_TYPE_TSEL: return tsel_Read(a, bs); + case GF_ISOM_BOX_TYPE_DATA: + return data_Read(a, bs); + + case GF_ISOM_BOX_TYPE_OHDR: + return ohdr_Read(a, bs); + case GF_ISOM_BOX_TYPE_GRPI: + return grpi_Read(a, bs); + case GF_ISOM_BOX_TYPE_MDRI: + return mdri_Read(a, bs); + case GF_ISOM_BOX_TYPE_ODTT: + return odtt_Read(a, bs); + case GF_ISOM_BOX_TYPE_ODRB: + return odrb_Read(a, bs); + case GF_ISOM_BOX_TYPE_ODKM: + return odkm_Read(a, bs); + case GF_ISOM_BOX_TYPE_ODAF: + return iSFM_Read(a, bs); + + case GF_ISOM_BOX_TYPE_PASP: + return pasp_Read(a, bs); + case GF_ISOM_BOX_TYPE_TSEL: + return tsel_Read(a, bs); case GF_ISOM_BOX_TYPE_METX: case GF_ISOM_BOX_TYPE_METT: return metx_Read(a, bs); - case GF_ISOM_BOX_TYPE_DIMS: return dims_Read(a, bs); - case GF_ISOM_BOX_TYPE_DIMC: return dimC_Read(a, bs); - case GF_ISOM_BOX_TYPE_DIST: return diST_Read(a, bs); - - case GF_ISOM_BOX_TYPE_AC3: return ac3_Read(a, bs); - case GF_ISOM_BOX_TYPE_DAC3: return dac3_Read(a, bs); - - case GF_ISOM_BOX_TYPE_LSRC: return lsrc_Read(a, bs); - case GF_ISOM_BOX_TYPE_LSR1: return lsr1_Read(a, bs); - - case GF_ISOM_BOX_TYPE_SIDX: return sidx_Read(a, bs); - case GF_ISOM_BOX_TYPE_SUBS: return subs_Read(a, bs); - case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Read(a, bs); - case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Read(a, bs); - case GF_ISOM_BOX_TYPE_PRFT: return prft_Read(a, bs); + case GF_ISOM_BOX_TYPE_DIMS: + return dims_Read(a, bs); + case GF_ISOM_BOX_TYPE_DIMC: + return dimC_Read(a, bs); + case GF_ISOM_BOX_TYPE_DIST: + return diST_Read(a, bs); + + case GF_ISOM_BOX_TYPE_AC3: + return ac3_Read(a, bs); + case GF_ISOM_BOX_TYPE_DAC3: + return dac3_Read(a, bs); + + case GF_ISOM_BOX_TYPE_LSRC: + return lsrc_Read(a, bs); + case GF_ISOM_BOX_TYPE_LSR1: + return lsr1_Read(a, bs); + + case GF_ISOM_BOX_TYPE_SIDX: + return sidx_Read(a, bs); + case GF_ISOM_BOX_TYPE_SUBS: + return subs_Read(a, bs); + case GF_ISOM_BOX_TYPE_RVCC: + return rvcc_Read(a, bs); + case GF_ISOM_BOX_TYPE_PCRB: + return pcrb_Read(a, bs); + case GF_ISOM_BOX_TYPE_PRFT: + return prft_Read(a, bs); #ifndef GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_STSE: return stse_Read(a, bs); - case GF_ISOM_BOX_TYPE_STTC: return boxstring_Read(a, bs); - - case GF_ISOM_BOX_TYPE_VTCU: return vtcu_Read(a, bs); - case GF_ISOM_BOX_TYPE_VTTE: return vtte_Read(a, bs); - case GF_ISOM_BOX_TYPE_VTTC: return boxstring_Read(a, bs); - case GF_ISOM_BOX_TYPE_CTIM: return boxstring_Read(a, bs); - case GF_ISOM_BOX_TYPE_IDEN: return boxstring_Read(a, bs); - case GF_ISOM_BOX_TYPE_STTG: return boxstring_Read(a, bs); - case GF_ISOM_BOX_TYPE_PAYL: return boxstring_Read(a, bs); - case GF_ISOM_BOX_TYPE_WVTT: return wvtt_Read(a, bs); - - case GF_ISOM_BOX_TYPE_STPP: return stpp_Read(a, bs); - case GF_ISOM_BOX_TYPE_SBTT: return metx_Read(a, bs); + case GF_ISOM_BOX_TYPE_STSE: + return stse_Read(a, bs); + case GF_ISOM_BOX_TYPE_STTC: + return boxstring_Read(a, bs); + + case GF_ISOM_BOX_TYPE_VTCU: + return vtcu_Read(a, bs); + case GF_ISOM_BOX_TYPE_VTTE: + return vtte_Read(a, bs); + case GF_ISOM_BOX_TYPE_VTTC: + return boxstring_Read(a, bs); + case GF_ISOM_BOX_TYPE_CTIM: + return boxstring_Read(a, bs); + case GF_ISOM_BOX_TYPE_IDEN: + return boxstring_Read(a, bs); + case GF_ISOM_BOX_TYPE_STTG: + return boxstring_Read(a, bs); + case GF_ISOM_BOX_TYPE_PAYL: + return boxstring_Read(a, bs); + case GF_ISOM_BOX_TYPE_WVTT: + return wvtt_Read(a, bs); + + case GF_ISOM_BOX_TYPE_STPP: + return stpp_Read(a, bs); + case GF_ISOM_BOX_TYPE_SBTT: + return metx_Read(a, bs); #endif // GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_ADKM: return adkm_Read(a, bs); - case GF_ISOM_BOX_TYPE_AHDR: return ahdr_Read(a, bs); - case GF_ISOM_BOX_TYPE_APRM: return aprm_Read(a, bs); - case GF_ISOM_BOX_TYPE_AEIB: return aeib_Read(a, bs); - case GF_ISOM_BOX_TYPE_AKEY: return akey_Read(a, bs); - case GF_ISOM_BOX_TYPE_FLXS: return flxs_Read(a, bs); - case GF_ISOM_BOX_TYPE_ADAF: return adaf_Read(a, bs); + case GF_ISOM_BOX_TYPE_ADKM: + return adkm_Read(a, bs); + case GF_ISOM_BOX_TYPE_AHDR: + return ahdr_Read(a, bs); + case GF_ISOM_BOX_TYPE_APRM: + return aprm_Read(a, bs); + case GF_ISOM_BOX_TYPE_AEIB: + return aeib_Read(a, bs); + case GF_ISOM_BOX_TYPE_AKEY: + return akey_Read(a, bs); + case GF_ISOM_BOX_TYPE_FLXS: + return flxs_Read(a, bs); + case GF_ISOM_BOX_TYPE_ADAF: + return adaf_Read(a, bs); default: return defa_Read(a, bs); @@ -1348,110 +2010,196 @@ GF_Err gf_isom_box_write_listing(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_FREE: case GF_ISOM_BOX_TYPE_SKIP: return free_Write(a, bs); - case GF_ISOM_BOX_TYPE_MDAT: return mdat_Write(a, bs); - case GF_ISOM_BOX_TYPE_MOOV: return moov_Write(a, bs); - case GF_ISOM_BOX_TYPE_MVHD: return mvhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_MDHD: return mdhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_VMHD: return vmhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_SMHD: return smhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_HMHD: return hmhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_MDAT: + return mdat_Write(a, bs); + case GF_ISOM_BOX_TYPE_MOOV: + return moov_Write(a, bs); + case GF_ISOM_BOX_TYPE_MVHD: + return mvhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_MDHD: + return mdhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_VMHD: + return vmhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_SMHD: + return smhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_HMHD: + return hmhd_Write(a, bs); case GF_ISOM_BOX_TYPE_ODHD: case GF_ISOM_BOX_TYPE_CRHD: case GF_ISOM_BOX_TYPE_SDHD: case GF_ISOM_BOX_TYPE_NMHD: case GF_ISOM_BOX_TYPE_STHD: return nmhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_STBL: return stbl_Write(a, bs); - case GF_ISOM_BOX_TYPE_DINF: return dinf_Write(a, bs); - case GF_ISOM_BOX_TYPE_URL: return url_Write(a, bs); - case GF_ISOM_BOX_TYPE_URN: return urn_Write(a, bs); - case GF_ISOM_BOX_TYPE_CHPL: return chpl_Write(a, bs); - case GF_ISOM_BOX_TYPE_CPRT: return cprt_Write(a, bs); - case GF_ISOM_BOX_TYPE_HDLR: return hdlr_Write(a, bs); - case GF_ISOM_BOX_TYPE_IODS: return iods_Write(a, bs); - case GF_ISOM_BOX_TYPE_TRAK: return trak_Write(a, bs); - case GF_ISOM_BOX_TYPE_MP4S: return mp4s_Write(a, bs); - case GF_ISOM_BOX_TYPE_MP4V: return mp4v_Write(a, bs); - case GF_ISOM_BOX_TYPE_MP4A: return mp4a_Write(a, bs); - case GF_ISOM_BOX_TYPE_GNRM: return gnrm_Write(a, bs); - case GF_ISOM_BOX_TYPE_GNRV: return gnrv_Write(a, bs); - case GF_ISOM_BOX_TYPE_GNRA: return gnra_Write(a, bs); - case GF_ISOM_BOX_TYPE_EDTS: return edts_Write(a, bs); - case GF_ISOM_BOX_TYPE_UDTA: return udta_Write(a, bs); - case GF_ISOM_BOX_TYPE_DREF: return dref_Write(a, bs); - case GF_ISOM_BOX_TYPE_STSD: return stsd_Write(a, bs); - case GF_ISOM_BOX_TYPE_STTS: return stts_Write(a, bs); - case GF_ISOM_BOX_TYPE_CTTS: return ctts_Write(a, bs); - case GF_ISOM_BOX_TYPE_CSLG: return cslg_Write(a, bs); - case GF_ISOM_BOX_TYPE_STSH: return stsh_Write(a, bs); - case GF_ISOM_BOX_TYPE_ELST: return elst_Write(a, bs); - case GF_ISOM_BOX_TYPE_STSC: return stsc_Write(a, bs); + case GF_ISOM_BOX_TYPE_STBL: + return stbl_Write(a, bs); + case GF_ISOM_BOX_TYPE_DINF: + return dinf_Write(a, bs); + case GF_ISOM_BOX_TYPE_URL: + return url_Write(a, bs); + case GF_ISOM_BOX_TYPE_URN: + return urn_Write(a, bs); + case GF_ISOM_BOX_TYPE_CHPL: + return chpl_Write(a, bs); + case GF_ISOM_BOX_TYPE_CPRT: + return cprt_Write(a, bs); + case GF_ISOM_BOX_TYPE_HDLR: + return hdlr_Write(a, bs); + case GF_ISOM_BOX_TYPE_IODS: + return iods_Write(a, bs); + case GF_ISOM_BOX_TYPE_TRAK: + return trak_Write(a, bs); + case GF_ISOM_BOX_TYPE_MP4S: + return mp4s_Write(a, bs); + case GF_ISOM_BOX_TYPE_MP4V: + return mp4v_Write(a, bs); + case GF_ISOM_BOX_TYPE_MP4A: + return mp4a_Write(a, bs); + case GF_ISOM_BOX_TYPE_GNRM: + return gnrm_Write(a, bs); + case GF_ISOM_BOX_TYPE_GNRV: + return gnrv_Write(a, bs); + case GF_ISOM_BOX_TYPE_GNRA: + return gnra_Write(a, bs); + case GF_ISOM_BOX_TYPE_EDTS: + return edts_Write(a, bs); + case GF_ISOM_BOX_TYPE_UDTA: + return udta_Write(a, bs); + case GF_ISOM_BOX_TYPE_DREF: + return dref_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSD: + return stsd_Write(a, bs); + case GF_ISOM_BOX_TYPE_STTS: + return stts_Write(a, bs); + case GF_ISOM_BOX_TYPE_CTTS: + return ctts_Write(a, bs); + case GF_ISOM_BOX_TYPE_CSLG: + return cslg_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSH: + return stsh_Write(a, bs); + case GF_ISOM_BOX_TYPE_ELST: + return elst_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSC: + return stsc_Write(a, bs); case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: return stsz_Write(a, bs); - case GF_ISOM_BOX_TYPE_STCO: return stco_Write(a, bs); - case GF_ISOM_BOX_TYPE_STSS: return stss_Write(a, bs); - case GF_ISOM_BOX_TYPE_STDP: return stdp_Write(a, bs); - case GF_ISOM_BOX_TYPE_SDTP: return sdtp_Write(a, bs); - case GF_ISOM_BOX_TYPE_CO64: return co64_Write(a, bs); - case GF_ISOM_BOX_TYPE_ESDS: return esds_Write(a, bs); - case GF_ISOM_BOX_TYPE_MINF: return minf_Write(a, bs); - case GF_ISOM_BOX_TYPE_TKHD: return tkhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_TREF: return tref_Write(a, bs); - case GF_ISOM_BOX_TYPE_MDIA: return mdia_Write(a, bs); - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - return ftyp_Write(a, bs); - case GF_ISOM_BOX_TYPE_PADB: return padb_Write(a, bs); - case GF_ISOM_BOX_TYPE_VOID: return void_Write(a, bs); - case GF_ISOM_BOX_TYPE_STSF: return stsf_Write(a, bs); - case GF_ISOM_BOX_TYPE_PDIN: return pdin_Write(a, bs); - case GF_ISOM_BOX_TYPE_SBGP: return sbgp_Write(a, bs); - case GF_ISOM_BOX_TYPE_SGPD: return sgpd_Write(a, bs); - case GF_ISOM_BOX_TYPE_SAIZ: return saiz_Write(a, bs); - case GF_ISOM_BOX_TYPE_SAIO: return saio_Write(a, bs); - case GF_ISOM_BOX_TYPE_PSSH: return pssh_Write(a, bs); - case GF_ISOM_BOX_TYPE_TENC: return tenc_Write(a, bs); + case GF_ISOM_BOX_TYPE_STCO: + return stco_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSS: + return stss_Write(a, bs); + case GF_ISOM_BOX_TYPE_STDP: + return stdp_Write(a, bs); + case GF_ISOM_BOX_TYPE_SDTP: + return sdtp_Write(a, bs); + case GF_ISOM_BOX_TYPE_CO64: + return co64_Write(a, bs); + case GF_ISOM_BOX_TYPE_ESDS: + return esds_Write(a, bs); + case GF_ISOM_BOX_TYPE_MINF: + return minf_Write(a, bs); + case GF_ISOM_BOX_TYPE_TKHD: + return tkhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_TREF: + return tref_Write(a, bs); + case GF_ISOM_BOX_TYPE_MDIA: + return mdia_Write(a, bs); + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + return ftyp_Write(a, bs); + case GF_ISOM_BOX_TYPE_PADB: + return padb_Write(a, bs); + case GF_ISOM_BOX_TYPE_VOID: + return void_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSF: + return stsf_Write(a, bs); + case GF_ISOM_BOX_TYPE_PDIN: + return pdin_Write(a, bs); + case GF_ISOM_BOX_TYPE_SBGP: + return sbgp_Write(a, bs); + case GF_ISOM_BOX_TYPE_SGPD: + return sgpd_Write(a, bs); + case GF_ISOM_BOX_TYPE_SAIZ: + return saiz_Write(a, bs); + case GF_ISOM_BOX_TYPE_SAIO: + return saio_Write(a, bs); + case GF_ISOM_BOX_TYPE_PSSH: + return pssh_Write(a, bs); + case GF_ISOM_BOX_TYPE_TENC: + return tenc_Write(a, bs); #ifndef GPAC_DISABLE_ISOM_HINTING - case GF_ISOM_BOX_TYPE_RTP_STSD: return ghnt_Write(a, bs); - case GF_ISOM_BOX_TYPE_RTPO: return rtpo_Write(a, bs); - case GF_ISOM_BOX_TYPE_HNTI: return hnti_Write(a, bs); - case GF_ISOM_BOX_TYPE_SDP: return sdp_Write(a, bs); - case GF_ISOM_BOX_TYPE_HINF: return hinf_Write(a, bs); - case GF_ISOM_BOX_TYPE_RELY: return rely_Write(a, bs); - case GF_ISOM_BOX_TYPE_TIMS: return tims_Write(a, bs); - case GF_ISOM_BOX_TYPE_TSRO: return tsro_Write(a, bs); - case GF_ISOM_BOX_TYPE_SNRO: return snro_Write(a, bs); - case GF_ISOM_BOX_TYPE_TRPY: return trpy_Write(a, bs); - case GF_ISOM_BOX_TYPE_NUMP: return nump_Write(a, bs); - case GF_ISOM_BOX_TYPE_TOTL: return totl_Write(a, bs); - case GF_ISOM_BOX_TYPE_NPCK: return npck_Write(a, bs); - case GF_ISOM_BOX_TYPE_TPYL: return tpyl_Write(a, bs); - case GF_ISOM_BOX_TYPE_TPAY: return tpay_Write(a, bs); - case GF_ISOM_BOX_TYPE_MAXR: return maxr_Write(a, bs); - case GF_ISOM_BOX_TYPE_DMED: return dmed_Write(a, bs); - case GF_ISOM_BOX_TYPE_DIMM: return dimm_Write(a, bs); - case GF_ISOM_BOX_TYPE_DREP: return drep_Write(a, bs); - case GF_ISOM_BOX_TYPE_TMIN: return tmin_Write(a, bs); - case GF_ISOM_BOX_TYPE_TMAX: return tmax_Write(a, bs); - case GF_ISOM_BOX_TYPE_PMAX: return pmax_Write(a, bs); - case GF_ISOM_BOX_TYPE_DMAX: return dmax_Write(a, bs); - case GF_ISOM_BOX_TYPE_PAYT: return payt_Write(a, bs); - case GF_ISOM_BOX_TYPE_NAME: return name_Write(a, bs); + case GF_ISOM_BOX_TYPE_RTP_STSD: + return ghnt_Write(a, bs); + case GF_ISOM_BOX_TYPE_RTPO: + return rtpo_Write(a, bs); + case GF_ISOM_BOX_TYPE_HNTI: + return hnti_Write(a, bs); + case GF_ISOM_BOX_TYPE_SDP: + return sdp_Write(a, bs); + case GF_ISOM_BOX_TYPE_HINF: + return hinf_Write(a, bs); + case GF_ISOM_BOX_TYPE_RELY: + return rely_Write(a, bs); + case GF_ISOM_BOX_TYPE_TIMS: + return tims_Write(a, bs); + case GF_ISOM_BOX_TYPE_TSRO: + return tsro_Write(a, bs); + case GF_ISOM_BOX_TYPE_SNRO: + return snro_Write(a, bs); + case GF_ISOM_BOX_TYPE_TRPY: + return trpy_Write(a, bs); + case GF_ISOM_BOX_TYPE_NUMP: + return nump_Write(a, bs); + case GF_ISOM_BOX_TYPE_TOTL: + return totl_Write(a, bs); + case GF_ISOM_BOX_TYPE_NPCK: + return npck_Write(a, bs); + case GF_ISOM_BOX_TYPE_TPYL: + return tpyl_Write(a, bs); + case GF_ISOM_BOX_TYPE_TPAY: + return tpay_Write(a, bs); + case GF_ISOM_BOX_TYPE_MAXR: + return maxr_Write(a, bs); + case GF_ISOM_BOX_TYPE_DMED: + return dmed_Write(a, bs); + case GF_ISOM_BOX_TYPE_DIMM: + return dimm_Write(a, bs); + case GF_ISOM_BOX_TYPE_DREP: + return drep_Write(a, bs); + case GF_ISOM_BOX_TYPE_TMIN: + return tmin_Write(a, bs); + case GF_ISOM_BOX_TYPE_TMAX: + return tmax_Write(a, bs); + case GF_ISOM_BOX_TYPE_PMAX: + return pmax_Write(a, bs); + case GF_ISOM_BOX_TYPE_DMAX: + return dmax_Write(a, bs); + case GF_ISOM_BOX_TYPE_PAYT: + return payt_Write(a, bs); + case GF_ISOM_BOX_TYPE_NAME: + return name_Write(a, bs); #endif /*GPAC_DISABLE_ISOM_HINTING*/ #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_MVEX: return mvex_Write(a, bs); - case GF_ISOM_BOX_TYPE_MEHD: return mehd_Write(a, bs); - case GF_ISOM_BOX_TYPE_TREX: return trex_Write(a, bs); - case GF_ISOM_BOX_TYPE_MOOF: return moof_Write(a, bs); - case GF_ISOM_BOX_TYPE_MFHD: return mfhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_TRAF: return traf_Write(a, bs); - case GF_ISOM_BOX_TYPE_TFHD: return tfhd_Write(a, bs); - case GF_ISOM_BOX_TYPE_TFDT: return tfdt_Write(a, bs); - case GF_ISOM_BOX_TYPE_TRUN: return trun_Write(a, bs); -#endif + case GF_ISOM_BOX_TYPE_MVEX: + return mvex_Write(a, bs); + case GF_ISOM_BOX_TYPE_MEHD: + return mehd_Write(a, bs); + case GF_ISOM_BOX_TYPE_TREX: + return trex_Write(a, bs); + case GF_ISOM_BOX_TYPE_MOOF: + return moof_Write(a, bs); + case GF_ISOM_BOX_TYPE_MFHD: + return mfhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_TRAF: + return traf_Write(a, bs); + case GF_ISOM_BOX_TYPE_TFHD: + return tfhd_Write(a, bs); + case GF_ISOM_BOX_TYPE_TFDT: + return tfdt_Write(a, bs); + case GF_ISOM_BOX_TYPE_TRUN: + return trun_Write(a, bs); +#endif /*3GPP boxes*/ case GF_ISOM_SUBTYPE_3GP_AMR: @@ -1460,94 +2208,135 @@ GF_Err gf_isom_box_write_listing(GF_Box *a, GF_BitStream *bs) case GF_ISOM_SUBTYPE_3GP_QCELP: case GF_ISOM_SUBTYPE_3GP_SMV: return gppa_Write(a, bs); - case GF_ISOM_SUBTYPE_3GP_H263: + case GF_ISOM_SUBTYPE_3GP_H263: return gppv_Write(a, bs); case GF_ISOM_BOX_TYPE_DAMR: - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: case GF_ISOM_BOX_TYPE_D263: return gppc_Write(a, bs); - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: return avcc_Write(a, bs); - case GF_ISOM_BOX_TYPE_HVCC: + case GF_ISOM_BOX_TYPE_HVCC: case GF_ISOM_BOX_TYPE_SHCC: return hvcc_Write(a, bs); - case GF_ISOM_BOX_TYPE_BTRT: return btrt_Write(a, bs); - case GF_ISOM_BOX_TYPE_M4DS: return m4ds_Write(a, bs); - case GF_ISOM_BOX_TYPE_AVC1: - case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_BTRT: + return btrt_Write(a, bs); + case GF_ISOM_BOX_TYPE_M4DS: + return m4ds_Write(a, bs); + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_HVC1: case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: return mp4v_Write(a, bs); /*3GPP streaming text*/ - case GF_ISOM_BOX_TYPE_FTAB: return ftab_Write(a, bs); - case GF_ISOM_BOX_TYPE_TX3G: return tx3g_Write(a, bs); - case GF_ISOM_BOX_TYPE_TEXT: return text_Write(a, bs); - case GF_ISOM_BOX_TYPE_STYL: return styl_Write(a, bs); - case GF_ISOM_BOX_TYPE_HLIT: return hlit_Write(a, bs); - case GF_ISOM_BOX_TYPE_HCLR: return hclr_Write(a, bs); - case GF_ISOM_BOX_TYPE_KROK: return krok_Write(a, bs); - case GF_ISOM_BOX_TYPE_DLAY: return dlay_Write(a, bs); - case GF_ISOM_BOX_TYPE_HREF: return href_Write(a, bs); - case GF_ISOM_BOX_TYPE_TBOX: return tbox_Write(a, bs); - case GF_ISOM_BOX_TYPE_BLNK: return blnk_Write(a, bs); - case GF_ISOM_BOX_TYPE_TWRP: return twrp_Write(a, bs); - + case GF_ISOM_BOX_TYPE_FTAB: + return ftab_Write(a, bs); + case GF_ISOM_BOX_TYPE_TX3G: + return tx3g_Write(a, bs); + case GF_ISOM_BOX_TYPE_TEXT: + return text_Write(a, bs); + case GF_ISOM_BOX_TYPE_STYL: + return styl_Write(a, bs); + case GF_ISOM_BOX_TYPE_HLIT: + return hlit_Write(a, bs); + case GF_ISOM_BOX_TYPE_HCLR: + return hclr_Write(a, bs); + case GF_ISOM_BOX_TYPE_KROK: + return krok_Write(a, bs); + case GF_ISOM_BOX_TYPE_DLAY: + return dlay_Write(a, bs); + case GF_ISOM_BOX_TYPE_HREF: + return href_Write(a, bs); + case GF_ISOM_BOX_TYPE_TBOX: + return tbox_Write(a, bs); + case GF_ISOM_BOX_TYPE_BLNK: + return blnk_Write(a, bs); + case GF_ISOM_BOX_TYPE_TWRP: + return twrp_Write(a, bs); + /* ISMA 1.0 Encryption and Authentication V 1.0 */ - case GF_ISOM_BOX_TYPE_IKMS: return iKMS_Write(a, bs); - case GF_ISOM_BOX_TYPE_ISFM: return iSFM_Write(a, bs); + case GF_ISOM_BOX_TYPE_IKMS: + return iKMS_Write(a, bs); + case GF_ISOM_BOX_TYPE_ISFM: + return iSFM_Write(a, bs); /* ISO FF extensions for MPEG-21 */ - case GF_ISOM_BOX_TYPE_META: return meta_Write(a, bs); - case GF_ISOM_BOX_TYPE_XML: return xml_Write(a, bs); - case GF_ISOM_BOX_TYPE_BXML: return bxml_Write(a, bs); - case GF_ISOM_BOX_TYPE_ILOC: return iloc_Write(a, bs); - case GF_ISOM_BOX_TYPE_PITM: return pitm_Write(a, bs); - case GF_ISOM_BOX_TYPE_IPRO: return ipro_Write(a, bs); - case GF_ISOM_BOX_TYPE_INFE: return infe_Write(a, bs); - case GF_ISOM_BOX_TYPE_IINF: return iinf_Write(a, bs); - case GF_ISOM_BOX_TYPE_SINF: return sinf_Write(a, bs); - case GF_ISOM_BOX_TYPE_FRMA: return frma_Write(a, bs); - case GF_ISOM_BOX_TYPE_SCHM: return schm_Write(a, bs); - case GF_ISOM_BOX_TYPE_SCHI: return schi_Write(a, bs); - case GF_ISOM_BOX_TYPE_ENCA: return mp4a_Write(a, bs); - case GF_ISOM_BOX_TYPE_ENCV: return mp4v_Write(a, bs); - case GF_ISOM_BOX_TYPE_ENCS: return mp4s_Write(a, bs); - - case GF_ISOM_BOX_TYPE_SENC: return senc_Write(a, bs); - - case GF_ISOM_BOX_TYPE_UUID: + case GF_ISOM_BOX_TYPE_META: + return meta_Write(a, bs); + case GF_ISOM_BOX_TYPE_XML: + return xml_Write(a, bs); + case GF_ISOM_BOX_TYPE_BXML: + return bxml_Write(a, bs); + case GF_ISOM_BOX_TYPE_ILOC: + return iloc_Write(a, bs); + case GF_ISOM_BOX_TYPE_PITM: + return pitm_Write(a, bs); + case GF_ISOM_BOX_TYPE_IPRO: + return ipro_Write(a, bs); + case GF_ISOM_BOX_TYPE_INFE: + return infe_Write(a, bs); + case GF_ISOM_BOX_TYPE_IINF: + return iinf_Write(a, bs); + case GF_ISOM_BOX_TYPE_SINF: + return sinf_Write(a, bs); + case GF_ISOM_BOX_TYPE_FRMA: + return frma_Write(a, bs); + case GF_ISOM_BOX_TYPE_SCHM: + return schm_Write(a, bs); + case GF_ISOM_BOX_TYPE_SCHI: + return schi_Write(a, bs); + case GF_ISOM_BOX_TYPE_ENCA: + return mp4a_Write(a, bs); + case GF_ISOM_BOX_TYPE_ENCV: + return mp4v_Write(a, bs); + case GF_ISOM_BOX_TYPE_ENCS: + return mp4s_Write(a, bs); + + case GF_ISOM_BOX_TYPE_SENC: + return senc_Write(a, bs); + + case GF_ISOM_BOX_TYPE_UUID: switch ( ((GF_UnknownUUIDBox *)a)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: return piff_tenc_Write(a, bs); - case GF_ISOM_BOX_UUID_PSEC: return piff_psec_Write(a, bs); - case GF_ISOM_BOX_UUID_PSSH: return piff_pssh_Write(a, bs); - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: + case GF_ISOM_BOX_UUID_TENC: + return piff_tenc_Write(a, bs); + case GF_ISOM_BOX_UUID_PSEC: + return piff_psec_Write(a, bs); + case GF_ISOM_BOX_UUID_PSSH: + return piff_pssh_Write(a, bs); + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: default: return uuid_Write(a, bs); } #ifndef GPAC_DISABLE_ISOM_ADOBE /* Adobe extensions */ - case GF_ISOM_BOX_TYPE_ABST: return abst_Write(a, bs); - case GF_ISOM_BOX_TYPE_AFRA: return afra_Write(a, bs); - case GF_ISOM_BOX_TYPE_ASRT: return asrt_Write(a, bs); - case GF_ISOM_BOX_TYPE_AFRT: return afrt_Write(a, bs); + case GF_ISOM_BOX_TYPE_ABST: + return abst_Write(a, bs); + case GF_ISOM_BOX_TYPE_AFRA: + return afra_Write(a, bs); + case GF_ISOM_BOX_TYPE_ASRT: + return asrt_Write(a, bs); + case GF_ISOM_BOX_TYPE_AFRT: + return afrt_Write(a, bs); #endif /* Apple extensions */ - case GF_ISOM_BOX_TYPE_ILST: return ilst_Write(a, bs); + case GF_ISOM_BOX_TYPE_ILST: + return ilst_Write(a, bs); case GF_ISOM_BOX_TYPE_0xA9NAM: case GF_ISOM_BOX_TYPE_0xA9CMT: @@ -1573,62 +2362,102 @@ GF_Err gf_isom_box_write_listing(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_COVR: return ListItem_Write(a, bs); - case GF_ISOM_BOX_TYPE_DATA: return data_Write(a, bs); - - case GF_ISOM_BOX_TYPE_OHDR: return ohdr_Write(a, bs); - case GF_ISOM_BOX_TYPE_GRPI: return grpi_Write(a, bs); - case GF_ISOM_BOX_TYPE_MDRI: return mdri_Write(a, bs); - case GF_ISOM_BOX_TYPE_ODTT: return odtt_Write(a, bs); - case GF_ISOM_BOX_TYPE_ODRB: return odrb_Write(a, bs); - case GF_ISOM_BOX_TYPE_ODKM: return odkm_Write(a, bs); - case GF_ISOM_BOX_TYPE_ODAF: return iSFM_Write(a, bs); - - case GF_ISOM_BOX_TYPE_PASP: return pasp_Write(a, bs); - case GF_ISOM_BOX_TYPE_TSEL: return tsel_Write(a, bs); + case GF_ISOM_BOX_TYPE_DATA: + return data_Write(a, bs); + + case GF_ISOM_BOX_TYPE_OHDR: + return ohdr_Write(a, bs); + case GF_ISOM_BOX_TYPE_GRPI: + return grpi_Write(a, bs); + case GF_ISOM_BOX_TYPE_MDRI: + return mdri_Write(a, bs); + case GF_ISOM_BOX_TYPE_ODTT: + return odtt_Write(a, bs); + case GF_ISOM_BOX_TYPE_ODRB: + return odrb_Write(a, bs); + case GF_ISOM_BOX_TYPE_ODKM: + return odkm_Write(a, bs); + case GF_ISOM_BOX_TYPE_ODAF: + return iSFM_Write(a, bs); + + case GF_ISOM_BOX_TYPE_PASP: + return pasp_Write(a, bs); + case GF_ISOM_BOX_TYPE_TSEL: + return tsel_Write(a, bs); case GF_ISOM_BOX_TYPE_METX: case GF_ISOM_BOX_TYPE_METT: return metx_Write(a, bs); - case GF_ISOM_BOX_TYPE_DIMS: return dims_Write(a, bs); - case GF_ISOM_BOX_TYPE_DIMC: return dimC_Write(a, bs); - case GF_ISOM_BOX_TYPE_DIST: return diST_Write(a, bs); - - case GF_ISOM_BOX_TYPE_AC3: return ac3_Write(a, bs); - case GF_ISOM_BOX_TYPE_DAC3: return dac3_Write(a, bs); - - case GF_ISOM_BOX_TYPE_LSRC: return lsrc_Write(a, bs); - case GF_ISOM_BOX_TYPE_LSR1: return lsr1_Write(a, bs); - - case GF_ISOM_BOX_TYPE_SIDX: return sidx_Write(a, bs); - case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Write(a, bs); - case GF_ISOM_BOX_TYPE_SUBS: return subs_Write(a, bs); - case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Write(a, bs); + case GF_ISOM_BOX_TYPE_DIMS: + return dims_Write(a, bs); + case GF_ISOM_BOX_TYPE_DIMC: + return dimC_Write(a, bs); + case GF_ISOM_BOX_TYPE_DIST: + return diST_Write(a, bs); + + case GF_ISOM_BOX_TYPE_AC3: + return ac3_Write(a, bs); + case GF_ISOM_BOX_TYPE_DAC3: + return dac3_Write(a, bs); + + case GF_ISOM_BOX_TYPE_LSRC: + return lsrc_Write(a, bs); + case GF_ISOM_BOX_TYPE_LSR1: + return lsr1_Write(a, bs); + + case GF_ISOM_BOX_TYPE_SIDX: + return sidx_Write(a, bs); + case GF_ISOM_BOX_TYPE_PCRB: + return pcrb_Write(a, bs); + case GF_ISOM_BOX_TYPE_SUBS: + return subs_Write(a, bs); + case GF_ISOM_BOX_TYPE_RVCC: + return rvcc_Write(a, bs); #ifndef GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_STSE: return stse_Write(a, bs); - case GF_ISOM_BOX_TYPE_STTC: return boxstring_Write(a, bs); - - case GF_ISOM_BOX_TYPE_VTCU: return vtcu_Write(a, bs); - case GF_ISOM_BOX_TYPE_VTTE: return vtte_Write(a, bs); - case GF_ISOM_BOX_TYPE_VTTC: return boxstring_Write(a, bs); - case GF_ISOM_BOX_TYPE_CTIM: return boxstring_Write(a, bs); - case GF_ISOM_BOX_TYPE_IDEN: return boxstring_Write(a, bs); - case GF_ISOM_BOX_TYPE_STTG: return boxstring_Write(a, bs); - case GF_ISOM_BOX_TYPE_PAYL: return boxstring_Write(a, bs); - case GF_ISOM_BOX_TYPE_WVTT: return wvtt_Write(a, bs); - - case GF_ISOM_BOX_TYPE_STPP: return stpp_Write(a, bs); - case GF_ISOM_BOX_TYPE_SBTT: return metx_Write(a, bs); + case GF_ISOM_BOX_TYPE_STSE: + return stse_Write(a, bs); + case GF_ISOM_BOX_TYPE_STTC: + return boxstring_Write(a, bs); + + case GF_ISOM_BOX_TYPE_VTCU: + return vtcu_Write(a, bs); + case GF_ISOM_BOX_TYPE_VTTE: + return vtte_Write(a, bs); + case GF_ISOM_BOX_TYPE_VTTC: + return boxstring_Write(a, bs); + case GF_ISOM_BOX_TYPE_CTIM: + return boxstring_Write(a, bs); + case GF_ISOM_BOX_TYPE_IDEN: + return boxstring_Write(a, bs); + case GF_ISOM_BOX_TYPE_STTG: + return boxstring_Write(a, bs); + case GF_ISOM_BOX_TYPE_PAYL: + return boxstring_Write(a, bs); + case GF_ISOM_BOX_TYPE_WVTT: + return wvtt_Write(a, bs); + + case GF_ISOM_BOX_TYPE_STPP: + return stpp_Write(a, bs); + case GF_ISOM_BOX_TYPE_SBTT: + return metx_Write(a, bs); #endif//GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_ADKM: return adkm_Write(a, bs); - case GF_ISOM_BOX_TYPE_AHDR: return ahdr_Write(a, bs); - case GF_ISOM_BOX_TYPE_APRM: return aprm_Write(a, bs); - case GF_ISOM_BOX_TYPE_AEIB: return aeib_Write(a, bs); - case GF_ISOM_BOX_TYPE_AKEY: return akey_Write(a, bs); - case GF_ISOM_BOX_TYPE_FLXS: return flxs_Write(a, bs); - case GF_ISOM_BOX_TYPE_ADAF: return adaf_Write(a, bs); + case GF_ISOM_BOX_TYPE_ADKM: + return adkm_Write(a, bs); + case GF_ISOM_BOX_TYPE_AHDR: + return ahdr_Write(a, bs); + case GF_ISOM_BOX_TYPE_APRM: + return aprm_Write(a, bs); + case GF_ISOM_BOX_TYPE_AEIB: + return aeib_Write(a, bs); + case GF_ISOM_BOX_TYPE_AKEY: + return akey_Write(a, bs); + case GF_ISOM_BOX_TYPE_FLXS: + return flxs_Write(a, bs); + case GF_ISOM_BOX_TYPE_ADAF: + return adaf_Write(a, bs); default: return defa_Write(a, bs); @@ -1654,111 +2483,196 @@ static GF_Err gf_isom_box_size_listing(GF_Box *a) case GF_ISOM_BOX_TYPE_FREE: case GF_ISOM_BOX_TYPE_SKIP: return free_Size(a); - case GF_ISOM_BOX_TYPE_MDAT: return mdat_Size(a); - case GF_ISOM_BOX_TYPE_MOOV: return moov_Size(a); - case GF_ISOM_BOX_TYPE_MVHD: return mvhd_Size(a); - case GF_ISOM_BOX_TYPE_MDHD: return mdhd_Size(a); - case GF_ISOM_BOX_TYPE_VMHD: return vmhd_Size(a); - case GF_ISOM_BOX_TYPE_SMHD: return smhd_Size(a); - case GF_ISOM_BOX_TYPE_HMHD: return hmhd_Size(a); + case GF_ISOM_BOX_TYPE_MDAT: + return mdat_Size(a); + case GF_ISOM_BOX_TYPE_MOOV: + return moov_Size(a); + case GF_ISOM_BOX_TYPE_MVHD: + return mvhd_Size(a); + case GF_ISOM_BOX_TYPE_MDHD: + return mdhd_Size(a); + case GF_ISOM_BOX_TYPE_VMHD: + return vmhd_Size(a); + case GF_ISOM_BOX_TYPE_SMHD: + return smhd_Size(a); + case GF_ISOM_BOX_TYPE_HMHD: + return hmhd_Size(a); case GF_ISOM_BOX_TYPE_ODHD: case GF_ISOM_BOX_TYPE_CRHD: case GF_ISOM_BOX_TYPE_SDHD: case GF_ISOM_BOX_TYPE_NMHD: case GF_ISOM_BOX_TYPE_STHD: return nmhd_Size(a); - case GF_ISOM_BOX_TYPE_STBL: return stbl_Size(a); - case GF_ISOM_BOX_TYPE_DINF: return dinf_Size(a); - case GF_ISOM_BOX_TYPE_URL: return url_Size(a); - case GF_ISOM_BOX_TYPE_URN: return urn_Size(a); - case GF_ISOM_BOX_TYPE_CHPL: return chpl_Size(a); - case GF_ISOM_BOX_TYPE_CPRT: return cprt_Size(a); - case GF_ISOM_BOX_TYPE_HDLR: return hdlr_Size(a); - case GF_ISOM_BOX_TYPE_IODS: return iods_Size(a); - case GF_ISOM_BOX_TYPE_TRAK: return trak_Size(a); - case GF_ISOM_BOX_TYPE_MP4S: return mp4s_Size(a); - case GF_ISOM_BOX_TYPE_MP4V: return mp4v_Size(a); - case GF_ISOM_BOX_TYPE_MP4A: return mp4a_Size(a); - case GF_ISOM_BOX_TYPE_GNRM: return gnrm_Size(a); - case GF_ISOM_BOX_TYPE_GNRV: return gnrv_Size(a); - case GF_ISOM_BOX_TYPE_GNRA: return gnra_Size(a); - case GF_ISOM_BOX_TYPE_EDTS: return edts_Size(a); - case GF_ISOM_BOX_TYPE_UDTA: return udta_Size(a); - case GF_ISOM_BOX_TYPE_DREF: return dref_Size(a); - case GF_ISOM_BOX_TYPE_STSD: return stsd_Size(a); - case GF_ISOM_BOX_TYPE_STTS: return stts_Size(a); - case GF_ISOM_BOX_TYPE_CTTS: return ctts_Size(a); - case GF_ISOM_BOX_TYPE_CSLG: return cslg_Size(a); - case GF_ISOM_BOX_TYPE_STSH: return stsh_Size(a); - case GF_ISOM_BOX_TYPE_ELST: return elst_Size(a); - case GF_ISOM_BOX_TYPE_STSC: return stsc_Size(a); + case GF_ISOM_BOX_TYPE_STBL: + return stbl_Size(a); + case GF_ISOM_BOX_TYPE_DINF: + return dinf_Size(a); + case GF_ISOM_BOX_TYPE_URL: + return url_Size(a); + case GF_ISOM_BOX_TYPE_URN: + return urn_Size(a); + case GF_ISOM_BOX_TYPE_CHPL: + return chpl_Size(a); + case GF_ISOM_BOX_TYPE_CPRT: + return cprt_Size(a); + case GF_ISOM_BOX_TYPE_HDLR: + return hdlr_Size(a); + case GF_ISOM_BOX_TYPE_IODS: + return iods_Size(a); + case GF_ISOM_BOX_TYPE_TRAK: + return trak_Size(a); + case GF_ISOM_BOX_TYPE_MP4S: + return mp4s_Size(a); + case GF_ISOM_BOX_TYPE_MP4V: + return mp4v_Size(a); + case GF_ISOM_BOX_TYPE_MP4A: + return mp4a_Size(a); + case GF_ISOM_BOX_TYPE_GNRM: + return gnrm_Size(a); + case GF_ISOM_BOX_TYPE_GNRV: + return gnrv_Size(a); + case GF_ISOM_BOX_TYPE_GNRA: + return gnra_Size(a); + case GF_ISOM_BOX_TYPE_EDTS: + return edts_Size(a); + case GF_ISOM_BOX_TYPE_UDTA: + return udta_Size(a); + case GF_ISOM_BOX_TYPE_DREF: + return dref_Size(a); + case GF_ISOM_BOX_TYPE_STSD: + return stsd_Size(a); + case GF_ISOM_BOX_TYPE_STTS: + return stts_Size(a); + case GF_ISOM_BOX_TYPE_CTTS: + return ctts_Size(a); + case GF_ISOM_BOX_TYPE_CSLG: + return cslg_Size(a); + case GF_ISOM_BOX_TYPE_STSH: + return stsh_Size(a); + case GF_ISOM_BOX_TYPE_ELST: + return elst_Size(a); + case GF_ISOM_BOX_TYPE_STSC: + return stsc_Size(a); case GF_ISOM_BOX_TYPE_STZ2: case GF_ISOM_BOX_TYPE_STSZ: return stsz_Size(a); - case GF_ISOM_BOX_TYPE_STCO: return stco_Size(a); - case GF_ISOM_BOX_TYPE_STSS: return stss_Size(a); - case GF_ISOM_BOX_TYPE_SDTP: return sdtp_Size(a); - case GF_ISOM_BOX_TYPE_CO64: return co64_Size(a); - case GF_ISOM_BOX_TYPE_ESDS: return esds_Size(a); - case GF_ISOM_BOX_TYPE_MINF: return minf_Size(a); - case GF_ISOM_BOX_TYPE_TKHD: return tkhd_Size(a); - case GF_ISOM_BOX_TYPE_TREF: return tref_Size(a); - case GF_ISOM_BOX_TYPE_MDIA: return mdia_Size(a); - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_STYP: - return ftyp_Size(a); - case GF_ISOM_BOX_TYPE_PADB: return padb_Size(a); - case GF_ISOM_BOX_TYPE_VOID: return void_Size(a); - case GF_ISOM_BOX_TYPE_STSF: return stsf_Size(a); - case GF_ISOM_BOX_TYPE_PDIN: return pdin_Size(a); - case GF_ISOM_BOX_TYPE_SBGP: return sbgp_Size(a); - case GF_ISOM_BOX_TYPE_SGPD: return sgpd_Size(a); - case GF_ISOM_BOX_TYPE_SAIZ: return saiz_Size(a); - case GF_ISOM_BOX_TYPE_SAIO: return saio_Size(a); - case GF_ISOM_BOX_TYPE_PSSH: return pssh_Size(a); - case GF_ISOM_BOX_TYPE_TENC: return tenc_Size(a); + case GF_ISOM_BOX_TYPE_STCO: + return stco_Size(a); + case GF_ISOM_BOX_TYPE_STSS: + return stss_Size(a); + case GF_ISOM_BOX_TYPE_SDTP: + return sdtp_Size(a); + case GF_ISOM_BOX_TYPE_CO64: + return co64_Size(a); + case GF_ISOM_BOX_TYPE_ESDS: + return esds_Size(a); + case GF_ISOM_BOX_TYPE_MINF: + return minf_Size(a); + case GF_ISOM_BOX_TYPE_TKHD: + return tkhd_Size(a); + case GF_ISOM_BOX_TYPE_TREF: + return tref_Size(a); + case GF_ISOM_BOX_TYPE_MDIA: + return mdia_Size(a); + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_STYP: + return ftyp_Size(a); + case GF_ISOM_BOX_TYPE_PADB: + return padb_Size(a); + case GF_ISOM_BOX_TYPE_VOID: + return void_Size(a); + case GF_ISOM_BOX_TYPE_STSF: + return stsf_Size(a); + case GF_ISOM_BOX_TYPE_PDIN: + return pdin_Size(a); + case GF_ISOM_BOX_TYPE_SBGP: + return sbgp_Size(a); + case GF_ISOM_BOX_TYPE_SGPD: + return sgpd_Size(a); + case GF_ISOM_BOX_TYPE_SAIZ: + return saiz_Size(a); + case GF_ISOM_BOX_TYPE_SAIO: + return saio_Size(a); + case GF_ISOM_BOX_TYPE_PSSH: + return pssh_Size(a); + case GF_ISOM_BOX_TYPE_TENC: + return tenc_Size(a); #ifndef GPAC_DISABLE_ISOM_HINTING - case GF_ISOM_BOX_TYPE_RTP_STSD: return ghnt_Size(a); - case GF_ISOM_BOX_TYPE_RTPO: return rtpo_Size(a); - case GF_ISOM_BOX_TYPE_HNTI: return hnti_Size(a); - case GF_ISOM_BOX_TYPE_SDP: return sdp_Size(a); - case GF_ISOM_BOX_TYPE_HINF: return hinf_Size(a); - case GF_ISOM_BOX_TYPE_RELY: return rely_Size(a); - case GF_ISOM_BOX_TYPE_TIMS: return tims_Size(a); - case GF_ISOM_BOX_TYPE_TSRO: return tsro_Size(a); - case GF_ISOM_BOX_TYPE_SNRO: return snro_Size(a); - case GF_ISOM_BOX_TYPE_TRPY: return trpy_Size(a); - case GF_ISOM_BOX_TYPE_NUMP: return nump_Size(a); - case GF_ISOM_BOX_TYPE_TOTL: return totl_Size(a); - case GF_ISOM_BOX_TYPE_NPCK: return npck_Size(a); - case GF_ISOM_BOX_TYPE_TPYL: return tpyl_Size(a); - case GF_ISOM_BOX_TYPE_TPAY: return tpay_Size(a); - case GF_ISOM_BOX_TYPE_MAXR: return maxr_Size(a); - case GF_ISOM_BOX_TYPE_DMED: return dmed_Size(a); - case GF_ISOM_BOX_TYPE_DIMM: return dimm_Size(a); - case GF_ISOM_BOX_TYPE_DREP: return drep_Size(a); - case GF_ISOM_BOX_TYPE_TMIN: return tmin_Size(a); - case GF_ISOM_BOX_TYPE_TMAX: return tmax_Size(a); - case GF_ISOM_BOX_TYPE_PMAX: return pmax_Size(a); - case GF_ISOM_BOX_TYPE_DMAX: return dmax_Size(a); - case GF_ISOM_BOX_TYPE_PAYT: return payt_Size(a); - case GF_ISOM_BOX_TYPE_NAME: return name_Size(a); + case GF_ISOM_BOX_TYPE_RTP_STSD: + return ghnt_Size(a); + case GF_ISOM_BOX_TYPE_RTPO: + return rtpo_Size(a); + case GF_ISOM_BOX_TYPE_HNTI: + return hnti_Size(a); + case GF_ISOM_BOX_TYPE_SDP: + return sdp_Size(a); + case GF_ISOM_BOX_TYPE_HINF: + return hinf_Size(a); + case GF_ISOM_BOX_TYPE_RELY: + return rely_Size(a); + case GF_ISOM_BOX_TYPE_TIMS: + return tims_Size(a); + case GF_ISOM_BOX_TYPE_TSRO: + return tsro_Size(a); + case GF_ISOM_BOX_TYPE_SNRO: + return snro_Size(a); + case GF_ISOM_BOX_TYPE_TRPY: + return trpy_Size(a); + case GF_ISOM_BOX_TYPE_NUMP: + return nump_Size(a); + case GF_ISOM_BOX_TYPE_TOTL: + return totl_Size(a); + case GF_ISOM_BOX_TYPE_NPCK: + return npck_Size(a); + case GF_ISOM_BOX_TYPE_TPYL: + return tpyl_Size(a); + case GF_ISOM_BOX_TYPE_TPAY: + return tpay_Size(a); + case GF_ISOM_BOX_TYPE_MAXR: + return maxr_Size(a); + case GF_ISOM_BOX_TYPE_DMED: + return dmed_Size(a); + case GF_ISOM_BOX_TYPE_DIMM: + return dimm_Size(a); + case GF_ISOM_BOX_TYPE_DREP: + return drep_Size(a); + case GF_ISOM_BOX_TYPE_TMIN: + return tmin_Size(a); + case GF_ISOM_BOX_TYPE_TMAX: + return tmax_Size(a); + case GF_ISOM_BOX_TYPE_PMAX: + return pmax_Size(a); + case GF_ISOM_BOX_TYPE_DMAX: + return dmax_Size(a); + case GF_ISOM_BOX_TYPE_PAYT: + return payt_Size(a); + case GF_ISOM_BOX_TYPE_NAME: + return name_Size(a); #endif /*GPAC_DISABLE_ISOM_HINTING*/ #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_MVEX: return mvex_Size(a); - case GF_ISOM_BOX_TYPE_MEHD: return mehd_Size(a); - case GF_ISOM_BOX_TYPE_TREX: return trex_Size(a); - case GF_ISOM_BOX_TYPE_MOOF: return moof_Size(a); - case GF_ISOM_BOX_TYPE_MFHD: return mfhd_Size(a); - case GF_ISOM_BOX_TYPE_TRAF: return traf_Size(a); - case GF_ISOM_BOX_TYPE_TFHD: return tfhd_Size(a); - case GF_ISOM_BOX_TYPE_TFDT: return tfdt_Size(a); - case GF_ISOM_BOX_TYPE_TRUN: return trun_Size(a); + case GF_ISOM_BOX_TYPE_MVEX: + return mvex_Size(a); + case GF_ISOM_BOX_TYPE_MEHD: + return mehd_Size(a); + case GF_ISOM_BOX_TYPE_TREX: + return trex_Size(a); + case GF_ISOM_BOX_TYPE_MOOF: + return moof_Size(a); + case GF_ISOM_BOX_TYPE_MFHD: + return mfhd_Size(a); + case GF_ISOM_BOX_TYPE_TRAF: + return traf_Size(a); + case GF_ISOM_BOX_TYPE_TFHD: + return tfhd_Size(a); + case GF_ISOM_BOX_TYPE_TFDT: + return tfdt_Size(a); + case GF_ISOM_BOX_TYPE_TRUN: + return trun_Size(a); #endif - + /*3GPP boxes*/ case GF_ISOM_SUBTYPE_3GP_AMR: case GF_ISOM_SUBTYPE_3GP_AMR_WB: @@ -1766,91 +2680,133 @@ static GF_Err gf_isom_box_size_listing(GF_Box *a) case GF_ISOM_SUBTYPE_3GP_QCELP: case GF_ISOM_SUBTYPE_3GP_SMV: return gppa_Size(a); - case GF_ISOM_SUBTYPE_3GP_H263: return gppv_Size(a); + case GF_ISOM_SUBTYPE_3GP_H263: + return gppv_Size(a); case GF_ISOM_BOX_TYPE_DAMR: - case GF_ISOM_BOX_TYPE_DEVC: + case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: case GF_ISOM_BOX_TYPE_D263: return gppc_Size(a); - case GF_ISOM_BOX_TYPE_AVCC: - case GF_ISOM_BOX_TYPE_SVCC: + case GF_ISOM_BOX_TYPE_AVCC: + case GF_ISOM_BOX_TYPE_SVCC: return avcc_Size(a); - case GF_ISOM_BOX_TYPE_HVCC: + case GF_ISOM_BOX_TYPE_HVCC: case GF_ISOM_BOX_TYPE_SHCC: return hvcc_Size(a); - case GF_ISOM_BOX_TYPE_BTRT: return btrt_Size(a); - case GF_ISOM_BOX_TYPE_M4DS: return m4ds_Size(a); - case GF_ISOM_BOX_TYPE_AVC1: - case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_SVC1: + case GF_ISOM_BOX_TYPE_BTRT: + return btrt_Size(a); + case GF_ISOM_BOX_TYPE_M4DS: + return m4ds_Size(a); + case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC2: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_HVC1: case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: return mp4v_Size(a); /*3GPP streaming text*/ - case GF_ISOM_BOX_TYPE_FTAB: return ftab_Size(a); - case GF_ISOM_BOX_TYPE_TX3G: return tx3g_Size(a); - case GF_ISOM_BOX_TYPE_TEXT: return text_Size(a); - case GF_ISOM_BOX_TYPE_STYL: return styl_Size(a); - case GF_ISOM_BOX_TYPE_HLIT: return hlit_Size(a); - case GF_ISOM_BOX_TYPE_HCLR: return hclr_Size(a); - case GF_ISOM_BOX_TYPE_KROK: return krok_Size(a); - case GF_ISOM_BOX_TYPE_DLAY: return dlay_Size(a); - case GF_ISOM_BOX_TYPE_HREF: return href_Size(a); - case GF_ISOM_BOX_TYPE_TBOX: return tbox_Size(a); - case GF_ISOM_BOX_TYPE_BLNK: return blnk_Size(a); - case GF_ISOM_BOX_TYPE_TWRP: return twrp_Size(a); + case GF_ISOM_BOX_TYPE_FTAB: + return ftab_Size(a); + case GF_ISOM_BOX_TYPE_TX3G: + return tx3g_Size(a); + case GF_ISOM_BOX_TYPE_TEXT: + return text_Size(a); + case GF_ISOM_BOX_TYPE_STYL: + return styl_Size(a); + case GF_ISOM_BOX_TYPE_HLIT: + return hlit_Size(a); + case GF_ISOM_BOX_TYPE_HCLR: + return hclr_Size(a); + case GF_ISOM_BOX_TYPE_KROK: + return krok_Size(a); + case GF_ISOM_BOX_TYPE_DLAY: + return dlay_Size(a); + case GF_ISOM_BOX_TYPE_HREF: + return href_Size(a); + case GF_ISOM_BOX_TYPE_TBOX: + return tbox_Size(a); + case GF_ISOM_BOX_TYPE_BLNK: + return blnk_Size(a); + case GF_ISOM_BOX_TYPE_TWRP: + return twrp_Size(a); /* ISMA 1.0 Encryption and Authentication V 1.0 */ - case GF_ISOM_BOX_TYPE_IKMS: return iKMS_Size(a); - case GF_ISOM_BOX_TYPE_ISFM: return iSFM_Size(a); + case GF_ISOM_BOX_TYPE_IKMS: + return iKMS_Size(a); + case GF_ISOM_BOX_TYPE_ISFM: + return iSFM_Size(a); /* ISO FF extensions for MPEG-21 */ - case GF_ISOM_BOX_TYPE_META: return meta_Size(a); - case GF_ISOM_BOX_TYPE_XML: return xml_Size(a); - case GF_ISOM_BOX_TYPE_BXML: return bxml_Size(a); - case GF_ISOM_BOX_TYPE_ILOC: return iloc_Size(a); - case GF_ISOM_BOX_TYPE_PITM: return pitm_Size(a); - case GF_ISOM_BOX_TYPE_IPRO: return ipro_Size(a); - case GF_ISOM_BOX_TYPE_INFE: return infe_Size(a); - case GF_ISOM_BOX_TYPE_IINF: return iinf_Size(a); - case GF_ISOM_BOX_TYPE_SINF: return sinf_Size(a); - case GF_ISOM_BOX_TYPE_FRMA: return frma_Size(a); - case GF_ISOM_BOX_TYPE_SCHM: return schm_Size(a); - case GF_ISOM_BOX_TYPE_SCHI: return schi_Size(a); - case GF_ISOM_BOX_TYPE_ENCA: return mp4a_Size(a); - case GF_ISOM_BOX_TYPE_ENCV: return mp4v_Size(a); - case GF_ISOM_BOX_TYPE_ENCS: return mp4s_Size(a); - case GF_ISOM_BOX_TYPE_SENC: return senc_Size(a); + case GF_ISOM_BOX_TYPE_META: + return meta_Size(a); + case GF_ISOM_BOX_TYPE_XML: + return xml_Size(a); + case GF_ISOM_BOX_TYPE_BXML: + return bxml_Size(a); + case GF_ISOM_BOX_TYPE_ILOC: + return iloc_Size(a); + case GF_ISOM_BOX_TYPE_PITM: + return pitm_Size(a); + case GF_ISOM_BOX_TYPE_IPRO: + return ipro_Size(a); + case GF_ISOM_BOX_TYPE_INFE: + return infe_Size(a); + case GF_ISOM_BOX_TYPE_IINF: + return iinf_Size(a); + case GF_ISOM_BOX_TYPE_SINF: + return sinf_Size(a); + case GF_ISOM_BOX_TYPE_FRMA: + return frma_Size(a); + case GF_ISOM_BOX_TYPE_SCHM: + return schm_Size(a); + case GF_ISOM_BOX_TYPE_SCHI: + return schi_Size(a); + case GF_ISOM_BOX_TYPE_ENCA: + return mp4a_Size(a); + case GF_ISOM_BOX_TYPE_ENCV: + return mp4v_Size(a); + case GF_ISOM_BOX_TYPE_ENCS: + return mp4s_Size(a); + case GF_ISOM_BOX_TYPE_SENC: + return senc_Size(a); case GF_ISOM_BOX_TYPE_UUID: switch ( ((GF_UnknownUUIDBox *)a)->internal_4cc) { - case GF_ISOM_BOX_UUID_TENC: return piff_tenc_Size(a); - case GF_ISOM_BOX_UUID_PSEC: return piff_psec_Size(a); - case GF_ISOM_BOX_UUID_PSSH: return piff_pssh_Size(a); - case GF_ISOM_BOX_UUID_TFRF: - case GF_ISOM_BOX_UUID_TFXD: + case GF_ISOM_BOX_UUID_TENC: + return piff_tenc_Size(a); + case GF_ISOM_BOX_UUID_PSEC: + return piff_psec_Size(a); + case GF_ISOM_BOX_UUID_PSSH: + return piff_pssh_Size(a); + case GF_ISOM_BOX_UUID_TFRF: + case GF_ISOM_BOX_UUID_TFXD: default: return uuid_Size(a); } #ifndef GPAC_DISABLE_ISOM_ADOBE /* Adobe extensions */ - case GF_ISOM_BOX_TYPE_ABST: return abst_Size(a); - case GF_ISOM_BOX_TYPE_AFRA: return afra_Size(a); - case GF_ISOM_BOX_TYPE_ASRT: return asrt_Size(a); - case GF_ISOM_BOX_TYPE_AFRT: return afrt_Size(a); + case GF_ISOM_BOX_TYPE_ABST: + return abst_Size(a); + case GF_ISOM_BOX_TYPE_AFRA: + return afra_Size(a); + case GF_ISOM_BOX_TYPE_ASRT: + return asrt_Size(a); + case GF_ISOM_BOX_TYPE_AFRT: + return afrt_Size(a); #endif /* Apple extensions */ - case GF_ISOM_BOX_TYPE_ILST: return ilst_Size(a); + case GF_ISOM_BOX_TYPE_ILST: + return ilst_Size(a); case GF_ISOM_BOX_TYPE_0xA9NAM: case GF_ISOM_BOX_TYPE_0xA9CMT: @@ -1876,64 +2832,105 @@ static GF_Err gf_isom_box_size_listing(GF_Box *a) case GF_ISOM_BOX_TYPE_COVR: return ListItem_Size(a); - case GF_ISOM_BOX_TYPE_DATA: return data_Size(a); - - case GF_ISOM_BOX_TYPE_OHDR: return ohdr_Size(a); - case GF_ISOM_BOX_TYPE_GRPI: return grpi_Size(a); - case GF_ISOM_BOX_TYPE_MDRI: return mdri_Size(a); - case GF_ISOM_BOX_TYPE_ODTT: return odtt_Size(a); - case GF_ISOM_BOX_TYPE_ODRB: return odrb_Size(a); - case GF_ISOM_BOX_TYPE_ODKM: return odkm_Size(a); - case GF_ISOM_BOX_TYPE_ODAF: return iSFM_Size(a); - - case GF_ISOM_BOX_TYPE_PASP: return pasp_Size(a); - case GF_ISOM_BOX_TYPE_TSEL: return tsel_Size(a); + case GF_ISOM_BOX_TYPE_DATA: + return data_Size(a); + + case GF_ISOM_BOX_TYPE_OHDR: + return ohdr_Size(a); + case GF_ISOM_BOX_TYPE_GRPI: + return grpi_Size(a); + case GF_ISOM_BOX_TYPE_MDRI: + return mdri_Size(a); + case GF_ISOM_BOX_TYPE_ODTT: + return odtt_Size(a); + case GF_ISOM_BOX_TYPE_ODRB: + return odrb_Size(a); + case GF_ISOM_BOX_TYPE_ODKM: + return odkm_Size(a); + case GF_ISOM_BOX_TYPE_ODAF: + return iSFM_Size(a); + + case GF_ISOM_BOX_TYPE_PASP: + return pasp_Size(a); + case GF_ISOM_BOX_TYPE_TSEL: + return tsel_Size(a); case GF_ISOM_BOX_TYPE_METX: case GF_ISOM_BOX_TYPE_METT: return metx_Size(a); - case GF_ISOM_BOX_TYPE_DIMS: return dims_Size(a); - case GF_ISOM_BOX_TYPE_DIMC: return dimC_Size(a); - case GF_ISOM_BOX_TYPE_DIST: return diST_Size(a); - - case GF_ISOM_BOX_TYPE_AC3: return ac3_Size(a); - case GF_ISOM_BOX_TYPE_DAC3: return dac3_Size(a); - - case GF_ISOM_BOX_TYPE_LSRC: return lsrc_Size(a); - case GF_ISOM_BOX_TYPE_LSR1: return lsr1_Size(a); - - case GF_ISOM_BOX_TYPE_SIDX: return sidx_Size(a); - case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Size(a); - case GF_ISOM_BOX_TYPE_SUBS: return subs_Size(a); - case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Size(a); + case GF_ISOM_BOX_TYPE_DIMS: + return dims_Size(a); + case GF_ISOM_BOX_TYPE_DIMC: + return dimC_Size(a); + case GF_ISOM_BOX_TYPE_DIST: + return diST_Size(a); + + case GF_ISOM_BOX_TYPE_AC3: + return ac3_Size(a); + case GF_ISOM_BOX_TYPE_DAC3: + return dac3_Size(a); + + case GF_ISOM_BOX_TYPE_LSRC: + return lsrc_Size(a); + case GF_ISOM_BOX_TYPE_LSR1: + return lsr1_Size(a); + + case GF_ISOM_BOX_TYPE_SIDX: + return sidx_Size(a); + case GF_ISOM_BOX_TYPE_PCRB: + return pcrb_Size(a); + case GF_ISOM_BOX_TYPE_SUBS: + return subs_Size(a); + case GF_ISOM_BOX_TYPE_RVCC: + return rvcc_Size(a); #ifndef GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_STSE: return stse_Size(a); - case GF_ISOM_BOX_TYPE_STTC: return boxstring_Size(a); - - case GF_ISOM_BOX_TYPE_VTCU: return vtcu_Size(a); - case GF_ISOM_BOX_TYPE_VTTE: return vtte_Size(a); - case GF_ISOM_BOX_TYPE_VTTC: return boxstring_Size(a); - case GF_ISOM_BOX_TYPE_CTIM: return boxstring_Size(a); - case GF_ISOM_BOX_TYPE_IDEN: return boxstring_Size(a); - case GF_ISOM_BOX_TYPE_STTG: return boxstring_Size(a); - case GF_ISOM_BOX_TYPE_PAYL: return boxstring_Size(a); - case GF_ISOM_BOX_TYPE_WVTT: return wvtt_Size(a); - - case GF_ISOM_BOX_TYPE_STPP: return stpp_Size(a); - case GF_ISOM_BOX_TYPE_SBTT: return metx_Size(a); + case GF_ISOM_BOX_TYPE_STSE: + return stse_Size(a); + case GF_ISOM_BOX_TYPE_STTC: + return boxstring_Size(a); + + case GF_ISOM_BOX_TYPE_VTCU: + return vtcu_Size(a); + case GF_ISOM_BOX_TYPE_VTTE: + return vtte_Size(a); + case GF_ISOM_BOX_TYPE_VTTC: + return boxstring_Size(a); + case GF_ISOM_BOX_TYPE_CTIM: + return boxstring_Size(a); + case GF_ISOM_BOX_TYPE_IDEN: + return boxstring_Size(a); + case GF_ISOM_BOX_TYPE_STTG: + return boxstring_Size(a); + case GF_ISOM_BOX_TYPE_PAYL: + return boxstring_Size(a); + case GF_ISOM_BOX_TYPE_WVTT: + return wvtt_Size(a); + + case GF_ISOM_BOX_TYPE_STPP: + return stpp_Size(a); + case GF_ISOM_BOX_TYPE_SBTT: + return metx_Size(a); #endif // GPAC_DISABLE_TTXT - case GF_ISOM_BOX_TYPE_ADKM: return adkm_Size(a); - case GF_ISOM_BOX_TYPE_AHDR: return ahdr_Size(a); - case GF_ISOM_BOX_TYPE_APRM: return aprm_Size(a); - case GF_ISOM_BOX_TYPE_AEIB: return aeib_Size(a); - case GF_ISOM_BOX_TYPE_AKEY: return akey_Size(a); - case GF_ISOM_BOX_TYPE_FLXS: return flxs_Size(a); - case GF_ISOM_BOX_TYPE_ADAF: return adaf_Size(a); + case GF_ISOM_BOX_TYPE_ADKM: + return adkm_Size(a); + case GF_ISOM_BOX_TYPE_AHDR: + return ahdr_Size(a); + case GF_ISOM_BOX_TYPE_APRM: + return aprm_Size(a); + case GF_ISOM_BOX_TYPE_AEIB: + return aeib_Size(a); + case GF_ISOM_BOX_TYPE_AKEY: + return akey_Size(a); + case GF_ISOM_BOX_TYPE_FLXS: + return flxs_Size(a); + case GF_ISOM_BOX_TYPE_ADAF: + return adaf_Size(a); - default: return defa_Size(a); + default: + return defa_Size(a); } } @@ -1949,6 +2946,6 @@ GF_Err gf_isom_box_size(GF_Box *a) return GF_OK; } -#endif /*GPAC_DISABLE_ISOM_WRITE*/ +#endif /*GPAC_DISABLE_ISOM_WRITE*/ #endif /*GPAC_DISABLE_ISOM*/ diff --git a/src/isomedia/data_map.c b/src/isomedia/data_map.c index da4abcb..0969885 100644 --- a/src/isomedia/data_map.c +++ b/src/isomedia/data_map.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -38,12 +38,16 @@ static u32 default_write_buffering_size = 0; GF_EXPORT GF_Err gf_isom_set_output_buffering(GF_ISOFile *movie, u32 size) { +#ifndef GPAC_DISABLE_ISOM_WRITE if (!movie) { default_write_buffering_size = size; return GF_OK; } if (!movie->editFileMap) return GF_BAD_PARAM; return gf_bs_set_output_buffering(movie->editFileMap->bs, size); +#else + return GF_NOT_SUPPORTED; +#endif } @@ -168,7 +172,7 @@ GF_Err gf_isom_datamap_new(const char *location, const char *parentPath, u8 mode if (mode == GF_ISOM_DATA_MAP_READ_ONLY) { mode = GF_ISOM_DATA_MAP_READ; - /*It seems win32 file mapping is reported in prog mem usage -> large increases of occupancy. Should not be a pb + /*It seems win32 file mapping is reported in prog mem usage -> large increases of occupancy. Should not be a pb but unless you want mapping, only regular IO will be used...*/ #if 0 if (IsLargeFile(sPath)) { @@ -255,9 +259,9 @@ GF_Err gf_isom_datamap_open(GF_MediaBox *mdia, u32 dataRefIndex, u8 Edit) #else //this should never be the case in an read-only MP4 file return GF_BAD_PARAM; -#endif +#endif } - //else this is a URL (read mode only) + //else this is a URL (read mode only) } else { e = gf_isom_datamap_new(ent->location, mdia->mediaTrack->moov->mov->fileName, GF_ISOM_DATA_MAP_READ, & mdia->information->dataHandler); if (e) return (e==GF_URL_ERROR) ? GF_ISOM_UNKNOWN_DATA_REF : e; @@ -339,7 +343,7 @@ GF_DataMap *gf_isom_fdm_new_temp(const char *sPath) memset(tmp, 0, sizeof(GF_FileDataMap)); tmp->type = GF_ISOM_DATA_FILE; tmp->mode = GF_ISOM_DATA_MAP_WRITE; - + if (!sPath) { tmp->stream = gf_temp_file_new(); } else { @@ -411,7 +415,7 @@ GF_DataMap *gf_isom_fdm_new(const char *sPath, u8 mode) if (!tmp->stream) tmp->stream = gf_f64_open(sPath, "rb"); bs_mode = GF_BITSTREAM_READ; break; - ///we open the file in READ/WRITE mode, in case + ///we open the file in READ/WRITE mode, in case case GF_ISOM_DATA_MAP_WRITE: if (!strcmp(sPath, "std")) { tmp->stream = stdout; @@ -422,7 +426,7 @@ GF_DataMap *gf_isom_fdm_new(const char *sPath, u8 mode) if (!tmp->stream) tmp->stream = gf_f64_open(sPath, "wb"); bs_mode = GF_BITSTREAM_WRITE; break; - ///we open the file in CAT mode, in case + ///we open the file in CAT mode, in case case GF_ISOM_DATA_MAP_CAT: if (!strcmp(sPath, "std")) { tmp->stream = stdout; @@ -572,24 +576,24 @@ GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode) if (!tmp) return NULL; memset(tmp, 0, sizeof(GF_FileMappingDataMap)); tmp->type = GF_ISOM_DATA_FILE_MAPPING; - tmp->mode = mode; + tmp->mode = mode; tmp->name = gf_strdup(sPath); // - // Open the file + // Open the file // #ifdef _WIN32_WCE //convert to WIDE CE_CharToWide((char *)sPath, sWPath); fileH = CreateFileForMapping(sWPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - (FILE_ATTRIBUTE_READONLY | FILE_FLAG_RANDOM_ACCESS), NULL ); + (FILE_ATTRIBUTE_READONLY | FILE_FLAG_RANDOM_ACCESS), NULL ); #else fileH = CreateFile(sPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - (FILE_ATTRIBUTE_READONLY | FILE_FLAG_RANDOM_ACCESS), NULL ); + (FILE_ATTRIBUTE_READONLY | FILE_FLAG_RANDOM_ACCESS), NULL ); #endif - + if (fileH == INVALID_HANDLE_VALUE) { gf_free(tmp->name); gf_free(tmp); @@ -615,7 +619,7 @@ GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode) err = GetLastError(); return NULL; } - + tmp->byte_map = MapViewOfFile(fileMapH, FILE_MAP_READ, 0, 0, 0); if (tmp->byte_map == NULL) { CloseHandle(fileMapH); @@ -626,7 +630,7 @@ GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode) } CloseHandle(fileH); - CloseHandle(fileMapH); + CloseHandle(fileMapH); //finaly open our bitstream (from buffer) tmp->bs = gf_bs_new(tmp->byte_map, tmp->file_size, GF_BITSTREAM_READ); @@ -659,9 +663,13 @@ u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, char *buffer, u32 bufferLen #else -GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode) { return gf_isom_fdm_new(sPath, mode); } -void gf_isom_fmo_del(GF_FileMappingDataMap *ptr) { gf_isom_fdm_del((GF_FileDataMap *)ptr); } -u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, char *buffer, u32 bufferLength, u64 fileOffset) +GF_DataMap *gf_isom_fmo_new(const char *sPath, u8 mode) { + return gf_isom_fdm_new(sPath, mode); +} +void gf_isom_fmo_del(GF_FileMappingDataMap *ptr) { + gf_isom_fdm_del((GF_FileDataMap *)ptr); +} +u32 gf_isom_fmo_get_data(GF_FileMappingDataMap *ptr, char *buffer, u32 bufferLength, u64 fileOffset) { return gf_isom_fdm_get_data((GF_FileDataMap *)ptr, buffer, bufferLength, fileOffset); } diff --git a/src/isomedia/drm_sample.c b/src/isomedia/drm_sample.c index 42588be..90e81eb 100644 --- a/src/isomedia/drm_sample.c +++ b/src/isomedia/drm_sample.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -52,9 +52,9 @@ GF_ISMASample *gf_isom_ismacryp_sample_from_data(char *data, u32 dataLength, Boo if (!data || !dataLength) { return gf_isom_ismacryp_new_sample(); } - + s = gf_isom_ismacryp_new_sample(); - + /*empty sample*/ if (!data || !dataLength) return s; @@ -106,7 +106,7 @@ GF_Err gf_isom_ismacryp_sample_to_sample(GF_ISMASample *s, GF_ISOSample *dest) if (s->flags & GF_ISOM_ISMA_USE_SEL_ENC) { gf_bs_write_int(bs, (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) ? 1 : 0, 1); gf_bs_write_int(bs, 0, 7); - } + } if (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) { if (s->IV_length) gf_bs_write_long_int(bs, (s64) s->IV, 8*s->IV_length); if (s->KI_length) gf_bs_write_data(bs, (char*)s->key_indicator, s->KI_length); @@ -206,7 +206,7 @@ Bool gf_isom_is_ismacryp_media(GF_ISOFile *the_file, u32 trackNumber, u32 sample if (!sinf) return 0; /*non-encrypted or non-ISMA*/ - if (!sinf->info || !sinf->info->ikms || !sinf->info->isfm ) + if (!sinf->info || !sinf->info->ikms || !sinf->info->isfm ) return 0; return 1; @@ -225,7 +225,7 @@ Bool gf_isom_is_omadrm_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDe if (!sinf) return 0; /*non-encrypted or non-OMA*/ - if (!sinf->info || !sinf->info->okms || !sinf->info->okms->hdr) + if (!sinf->info || !sinf->info->okms || !sinf->info->okms->hdr) return 0; return 1; @@ -237,7 +237,7 @@ GF_Err gf_isom_get_ismacryp_info(GF_ISOFile *the_file, u32 trackNumber, u32 samp { GF_TrackBox *trak; GF_ProtectionInfoBox *sinf; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -273,12 +273,12 @@ GF_Err gf_isom_get_ismacryp_info(GF_ISOFile *the_file, u32 trackNumber, u32 samp /*retrieves ISMACryp info for the given track & SDI*/ GF_EXPORT GF_Err gf_isom_get_omadrm_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat, - u32 *outSchemeType, u32 *outSchemeVersion, - const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength) + u32 *outSchemeType, u32 *outSchemeVersion, + const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength) { GF_TrackBox *trak; GF_ProtectionInfoBox *sinf; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -325,7 +325,7 @@ GF_Err gf_isom_remove_track_protection(GF_ISOFile *the_file, u32 trackNumber, u3 e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !sampleDescriptionIndex) return GF_BAD_PARAM; @@ -355,7 +355,7 @@ GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !sampleDescriptionIndex) return GF_BAD_PARAM; @@ -375,8 +375,8 @@ GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, } -static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u8 version, u32 flags, - u32 scheme_type, u32 scheme_version, char *scheme_uri, Bool is_isma, GF_ProtectionInfoBox **out_sinf) +static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u8 version, u32 flags, + u32 scheme_type, u32 scheme_version, char *scheme_uri, Bool is_isma, GF_ProtectionInfoBox **out_sinf) { u32 original_format; GF_Err e; @@ -407,20 +407,21 @@ static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, /*special case for AVC1*/ case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: - if (is_isma) + if (is_isma) original_format = GF_4CC('2','6','4','b'); sea->type = GF_ISOM_BOX_TYPE_ENCV; break; - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: - if (is_isma) + case GF_ISOM_BOX_TYPE_HVT1: + if (is_isma) original_format = GF_4CC('2','6','5','b'); sea->type = GF_ISOM_BOX_TYPE_ENCV; break; @@ -436,7 +437,7 @@ static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, default: return GF_BAD_PARAM; } - + sinf = (GF_ProtectionInfoBox *)sinf_New(); gf_list_add(sea->protections, sinf); @@ -452,7 +453,7 @@ static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, sinf->original_format = (GF_OriginalFormatBox *)frma_New(); sinf->original_format->data_format = original_format; - + //common to isma, cenc and oma sinf->info = (GF_SchemeInformationBox *)schi_New(); @@ -460,9 +461,9 @@ static GF_Err gf_isom_set_protected_entry(GF_ISOFile *the_file, u32 trackNumber, return GF_OK; } -GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, - u32 scheme_version, char *scheme_uri, char *kms_URI, - Bool selective_encryption, u32 KI_length, u32 IV_length) +GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, + u32 scheme_version, char *scheme_uri, char *kms_URI, + Bool selective_encryption, u32 KI_length, u32 IV_length) { GF_Err e; GF_ProtectionInfoBox *sinf; @@ -487,8 +488,8 @@ GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u3 } GF_Err gf_isom_set_oma_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, - char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len, - Bool selective_encryption, u32 KI_length, u32 IV_length) + char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len, + Bool selective_encryption, u32 KI_length, u32 IV_length) { GF_ProtectionInfoBox *sinf; GF_Err e; @@ -516,7 +517,7 @@ GF_Err gf_isom_set_oma_protection(GF_ISOFile *the_file, u32 trackNumber, u32 des } return GF_OK; } - +#endif // GPAC_DISABLE_ISOM_WRITE GF_EXPORT GF_Err gf_isom_get_original_format_type(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat) @@ -555,7 +556,7 @@ Bool gf_isom_is_cenc_media(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDesc if (!sinf) return GF_FALSE; /*non-encrypted or non-CENC*/ - if (!sinf->info || !sinf->info->tenc) + if (!sinf->info || !sinf->info->tenc) return GF_FALSE; return GF_TRUE; @@ -566,7 +567,7 @@ GF_Err gf_isom_get_cenc_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDe { GF_TrackBox *trak; GF_ProtectionInfoBox *sinf; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -592,8 +593,10 @@ GF_Err gf_isom_get_cenc_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDe return GF_OK; } -GF_Err gf_isom_set_cenc_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, - u32 scheme_version, u32 default_IsEncrypted, u8 default_IV_size, bin128 default_KID) +#ifndef GPAC_DISABLE_ISOM_WRITE + +GF_Err gf_isom_set_cenc_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, + u32 scheme_version, u32 default_IsEncrypted, u8 default_IV_size, bin128 default_KID) { GF_Err e; GF_ProtectionInfoBox *sinf; @@ -735,7 +738,7 @@ GF_Err gf_isom_remove_samp_enc_box(GF_ISOFile *the_file, u32 trackNumber) gf_list_rem(stbl->other_boxes, i); i--; } - else if (a->type == GF_ISOM_BOX_TYPE_SENC){ + else if (a->type == GF_ISOM_BOX_TYPE_SENC) { senc_del(a); gf_list_rem(stbl->other_boxes, i); i--; @@ -811,7 +814,7 @@ GF_Err gf_isom_remove_pssh_box(GF_ISOFile *the_file) #endif /*GPAC_DISABLE_ISOM_WRITE*/ -GF_PIFFSampleEncryptionBox * gf_isom_create_piff_psec_box(u8 version, u32 flags, u32 AlgorithmID, u8 IV_size, bin128 KID) +GF_PIFFSampleEncryptionBox * gf_isom_create_piff_psec_box(u8 version, u32 flags, u32 AlgorithmID, u8 IV_size, bin128 KID) { GF_PIFFSampleEncryptionBox *psec; @@ -830,7 +833,7 @@ GF_PIFFSampleEncryptionBox * gf_isom_create_piff_psec_box(u8 version, u32 flags, return psec; } -GF_SampleEncryptionBox * gf_isom_create_samp_enc_box(u8 version, u32 flags) +GF_SampleEncryptionBox * gf_isom_create_samp_enc_box(u8 version, u32 flags) { GF_SampleEncryptionBox *senc; @@ -844,7 +847,7 @@ GF_SampleEncryptionBox * gf_isom_create_samp_enc_box(u8 version, u32 flags) return senc; } -GF_Err gf_isom_cenc_allocate_storage(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u32 AlgorithmID, u8 IV_size, bin128 KID) +GF_Err gf_isom_cenc_allocate_storage(GF_ISOFile *the_file, u32 trackNumber, u32 container_type, u32 AlgorithmID, u8 IV_size, bin128 KID) { GF_SampleTableBox *stbl; GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber); @@ -854,13 +857,13 @@ GF_Err gf_isom_cenc_allocate_storage(GF_ISOFile *the_file, u32 trackNumber, u32 if (!stbl) return GF_BAD_PARAM; switch (container_type) { - case GF_ISOM_BOX_UUID_PSEC: + case GF_ISOM_BOX_UUID_PSEC: if (stbl->piff_psec) return GF_OK; stbl->piff_psec = (GF_Box *)gf_isom_create_piff_psec_box(1, 0, AlgorithmID, IV_size, KID); //senc will be written and destroyed with the other boxes return gf_isom_box_add_default((GF_Box *) stbl, stbl->piff_psec); - case GF_ISOM_BOX_TYPE_SENC: + case GF_ISOM_BOX_TYPE_SENC: if (stbl->senc) return GF_OK; stbl->senc = (GF_Box *)gf_isom_create_samp_enc_box(0, 0); //senc will be written and destroyed with the other boxes @@ -877,7 +880,7 @@ void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox senc->cenc_saiz = (GF_SampleAuxiliaryInfoSizeBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_SAIZ); senc->cenc_saiz->aux_info_type = GF_4CC('c', 'e', 'n', 'c'); senc->cenc_saiz->aux_info_type_parameter = 0; - if (stbl) + if (stbl) stbl_AddBox(stbl, (GF_Box *)senc->cenc_saiz); else traf_AddBox((GF_Box*)traf, (GF_Box *)senc->cenc_saiz); @@ -887,7 +890,7 @@ void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox senc->cenc_saio->aux_info_type = GF_4CC('c', 'e', 'n', 'c'); senc->cenc_saio->aux_info_type_parameter = 0; senc->cenc_saio->entry_count = 1; - if (stbl) + if (stbl) stbl_AddBox(stbl, (GF_Box *)senc->cenc_saio); else traf_AddBox((GF_Box*)traf, (GF_Box *)senc->cenc_saio); @@ -909,21 +912,21 @@ void gf_isom_cenc_set_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox } } -void gf_isom_cenc_merge_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, u32 offset, u32 len) +void gf_isom_cenc_merge_saiz_saio(GF_SampleEncryptionBox *senc, GF_SampleTableBox *stbl, u32 offset, u32 len) { u32 i; if (!senc->cenc_saiz) { senc->cenc_saiz = (GF_SampleAuxiliaryInfoSizeBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_SAIZ); senc->cenc_saiz->aux_info_type = GF_4CC('c', 'e', 'n', 'c'); senc->cenc_saiz->aux_info_type_parameter = 0; - if (stbl) + if (stbl) stbl_AddBox(stbl, (GF_Box *)senc->cenc_saiz); } if (!senc->cenc_saio) { senc->cenc_saio = (GF_SampleAuxiliaryInfoOffsetBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_SAIO); senc->cenc_saio->aux_info_type = GF_4CC('c', 'e', 'n', 'c'); senc->cenc_saio->aux_info_type_parameter = 0; - if (stbl) + if (stbl) stbl_AddBox(stbl, (GF_Box *)senc->cenc_saio); } @@ -990,7 +993,7 @@ GF_Err gf_isom_track_cenc_add_sample_info(GF_ISOFile *the_file, u32 trackNumber, sai->subsamples[i].bytes_clear_data = gf_bs_read_u16(bs); sai->subsamples[i].bytes_encrypted_data = gf_bs_read_u32(bs); } - gf_bs_del(bs); + gf_bs_del(bs); } gf_list_add(senc->samp_aux_info, sai); @@ -1015,7 +1018,7 @@ Bool gf_isom_cenc_has_saiz_saio(GF_SampleTableBox *stbl, GF_TrackFragmentBox *tr GF_List *sai_sizes, *sai_offsets; Bool has_saiz, has_saio; has_saiz = has_saio = GF_FALSE; - + if (stbl) { sai_sizes = stbl->sai_sizes; sai_offsets = stbl->sai_offsets; @@ -1033,15 +1036,22 @@ Bool gf_isom_cenc_has_saiz_saio(GF_SampleTableBox *stbl, GF_TrackFragmentBox *tr break; } } + //assume CENC if we find a senc box - hack for some ultraviolet files :( + if (!has_saiz && traf && (traf->sample_encryption || traf->piff_sample_encryption) ) + has_saiz = GF_TRUE; for (i = 0; i < gf_list_count(sai_offsets); i++) { GF_SampleAuxiliaryInfoOffsetBox *saio = (GF_SampleAuxiliaryInfoOffsetBox *)gf_list_get(sai_offsets, i); if (saio->aux_info_type == GF_4CC('c', 'e', 'n', 'c')) { has_saio = GF_TRUE; break; - } + } } - + + //assume CENC if we find a senc box - hack for some ultraviolet files :( + if (!has_saio && traf && (traf->sample_encryption || traf->piff_sample_encryption) ) + has_saio = GF_TRUE; + return (has_saiz && has_saio); } @@ -1052,7 +1062,7 @@ static GF_Err gf_isom_cenc_get_sai_by_saiz_saio(GF_MediaBox *mdia, u32 sampleNum u64 cur_position; GF_Err e = GF_OK; char *buffer; - + nb_saio = size = offset = prev_sai_size = 0; for (i = 0; i < gf_list_count(mdia->information->sampleTable->sai_offsets); i++) { @@ -1064,7 +1074,7 @@ static GF_Err gf_isom_cenc_get_sai_by_saiz_saio(GF_MediaBox *mdia, u32 sampleNum offset = saio->offsets[sampleNumber-1]; nb_saio = saio->entry_count; break; - } + } } for (i = 0; i < gf_list_count(mdia->information->sampleTable->sai_sizes); i++) { @@ -1085,7 +1095,7 @@ static GF_Err gf_isom_cenc_get_sai_by_saiz_saio(GF_MediaBox *mdia, u32 sampleNum gf_bs_seek(mdia->information->dataHandler->bs, cur_position); *sai = (GF_CENCSampleAuxInfo *)gf_malloc(sizeof(GF_CENCSampleAuxInfo)); - memset(*sai, 0, sizeof(GF_CENCSampleAuxInfo)); + memset(*sai, 0, sizeof(GF_CENCSampleAuxInfo)); bs = gf_bs_new(buffer, size, GF_BITSTREAM_READ); gf_bs_read_data(bs, (char *)(*sai)->IV, IV_size); if (size > IV_size) { @@ -1097,7 +1107,7 @@ static GF_Err gf_isom_cenc_get_sai_by_saiz_saio(GF_MediaBox *mdia, u32 sampleNum } } gf_bs_del(bs); - + return e; } @@ -1153,11 +1163,11 @@ GF_Err gf_isom_cenc_get_sample_aux_info(GF_ISOFile *the_file, u32 trackNumber, u a_sai = NULL; switch (type) { case GF_ISOM_BOX_UUID_PSEC: - if (a_box) + if (a_box) a_sai = (GF_CENCSampleAuxInfo *)gf_list_get(((GF_PIFFSampleEncryptionBox *)a_box)->samp_aux_info, sampleNumber-1); break; case GF_ISOM_BOX_TYPE_SENC: - if (a_box) + if (a_box) a_sai = (GF_CENCSampleAuxInfo *)gf_list_get(((GF_SampleEncryptionBox *)a_box)->samp_aux_info, sampleNumber-1); break; } @@ -1175,7 +1185,7 @@ GF_Err gf_isom_cenc_get_sample_aux_info(GF_ISOFile *the_file, u32 trackNumber, u return GF_OK; } -void gf_isom_cenc_get_default_info_ex(GF_TrackBox *trak, u32 sampleDescriptionIndex, u32 *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID) +void gf_isom_cenc_get_default_info_ex(GF_TrackBox *trak, u32 sampleDescriptionIndex, u32 *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID) { GF_ProtectionInfoBox *sinf; @@ -1192,7 +1202,7 @@ void gf_isom_cenc_get_default_info_ex(GF_TrackBox *trak, u32 sampleDescriptionIn if (default_IV_size) *default_IV_size = sinf->info->tenc->IV_size; if (default_KID) memmove(*default_KID, sinf->info->tenc->KID, 16); } - + } GF_EXPORT void gf_isom_cenc_get_default_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *default_IsEncrypted, u8 *default_IV_size, bin128 *default_KID) @@ -1207,12 +1217,16 @@ void gf_isom_cenc_get_default_info(GF_ISOFile *the_file, u32 trackNumber, u32 sa */ GF_Err gf_isom_set_adobe_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, u32 scheme_version, Bool is_selective_enc, char *metadata, u32 len) { - GF_Err e; GF_ProtectionInfoBox *sinf; //setup generic protection +#ifndef GPAC_DISABLE_ISOM_WRITE + GF_Err e; e = gf_isom_set_protected_entry(the_file, trackNumber, desc_index, 1, 0, scheme_type, scheme_version, NULL, GF_FALSE, &sinf); if (e) return e; +#else + return GF_NOT_SUPPORTED; +#endif sinf->info->adkm = (GF_AdobeDRMKeyManagementSystemBox *)adkm_New(); @@ -1260,7 +1274,7 @@ Bool gf_isom_is_adobe_protection_media(GF_ISOFile *the_file, u32 trackNumber, u3 if (!sinf) return GF_FALSE; /*non-encrypted or non-ADOBE*/ - if (!sinf->info || !sinf->info->adkm) + if (!sinf->info || !sinf->info->adkm) return GF_FALSE; return GF_TRUE; @@ -1271,7 +1285,7 @@ GF_Err gf_isom_get_adobe_protection_info(GF_ISOFile *the_file, u32 trackNumber, { GF_TrackBox *trak; GF_ProtectionInfoBox *sinf; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -1294,7 +1308,7 @@ GF_Err gf_isom_get_adobe_protection_info(GF_ISOFile *the_file, u32 trackNumber, void gf_isom_ipmpx_remove_tool_list(GF_ISOFile *the_file) { - /*remove IPMPToolList if any*/ + /*remove IPMPToolList if any*/ if (the_file && the_file->moov && the_file->moov->iods && (the_file ->moov->iods->descriptor->tag == GF_ODF_ISOM_IOD_TAG) ) { GF_IsomInitialObjectDescriptor *iod = (GF_IsomInitialObjectDescriptor *)the_file ->moov->iods->descriptor; if (iod->IPMPToolList) gf_odf_desc_del((GF_Descriptor*) iod->IPMPToolList); diff --git a/src/isomedia/hint_track.c b/src/isomedia/hint_track.c index eb31ed4..97216d4 100644 --- a/src/isomedia/hint_track.c +++ b/src/isomedia/hint_track.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,8 +31,8 @@ Bool IsHintTrack(GF_TrackBox *trak) { if (trak->Media->handler->handlerType != GF_ISOM_MEDIA_HINT) return 0; //QT doesn't specify any InfoHeader on HintTracks - if (trak->Media->information->InfoHeader - && trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_HMHD) + if (trak->Media->information->InfoHeader + && trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_HMHD) return 0; return 1; @@ -65,7 +65,7 @@ GF_Err AdjustHintInfo(GF_HintSampleEntryBox *entry, u32 HintSampleNumber) offset = gf_isom_hint_sample_size(entry->hint_sample) - entry->hint_sample->dataLength; count = gf_list_count(entry->hint_sample->packetTable); - + for (i=0; ihint_sample->packetTable, i); if (offset && entry->hint_sample->dataLength) { @@ -115,7 +115,7 @@ GF_Err gf_isom_setup_hint_track(GF_ISOFile *movie, u32 trackNumber, u32 HintType //store the HintTrack format for later use... hmhd->subType = HintType; - + //hint tracks always have a tref and everything ... if (!trak->References) { if (!trak->References) { @@ -153,13 +153,13 @@ GF_Err gf_isom_setup_hint_track(GF_ISOFile *movie, u32 trackNumber, u32 HintType e = udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI)); if (e) return e; -/* - //NAME - e = udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_NAME)); - if (e) return e; - //HINF - return udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HINF)); -*/ + /* + //NAME + e = udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_NAME)); + if (e) return e; + //HINF + return udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HINF)); + */ return GF_OK; } @@ -234,7 +234,7 @@ GF_Err gf_isom_rtp_set_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 Hint for (i=0; i< count; i++) { ent = (GF_TSHintEntryBox *)gf_list_get(hdesc->HintDataTable, i); - if (ent->type == GF_ISOM_BOX_TYPE_TIMS) { + if (ent->type == GF_ISOM_BOX_TYPE_TIMS) { ent->timeScale = TimeScale; return GF_OK; } @@ -263,7 +263,7 @@ GF_Err gf_isom_rtp_set_time_offset(GF_ISOFile *the_file, u32 trackNumber, u32 Hi for (i=0; i< count; i++) { ent = (GF_TimeOffHintEntryBox *)gf_list_get(hdesc->HintDataTable, i); - if (ent->type == GF_ISOM_BOX_TYPE_TSRO) { + if (ent->type == GF_ISOM_BOX_TYPE_TSRO) { ent->TimeOffset = TimeOffset; return GF_OK; } @@ -292,7 +292,7 @@ GF_Err gf_isom_rtp_set_time_sequence_offset(GF_ISOFile *the_file, u32 trackNumbe for (i=0; i< count; i++) { ent = (GF_SeqOffHintEntryBox *)gf_list_get(hdesc->HintDataTable, i); - if (ent->type == GF_ISOM_BOX_TYPE_SNRO) { + if (ent->type == GF_ISOM_BOX_TYPE_SNRO) { ent->SeqOffset = SequenceNumberOffset; return GF_OK; } @@ -343,7 +343,7 @@ GF_Err gf_isom_begin_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 Hint } //stores the hint sample in the file -//set IsRandomAccessPoint if you want to indicate that this is a random access point +//set IsRandomAccessPoint if you want to indicate that this is a random access point //in the stream GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint) { @@ -364,8 +364,8 @@ GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRando //first of all, we need to adjust the offset for data referenced IN THIS hint sample //and get some PckSize e = AdjustHintInfo(entry, trak->Media->information->sampleTable->SampleSize->sampleCount + 1); - if (e) return e; - + if (e) return e; + //ok, let's write the sample bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); e = gf_isom_hint_sample_write(entry->hint_sample, bs); @@ -381,7 +381,7 @@ GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRando gf_bs_get_content(bs, &samp->data, &samp->dataLength); gf_bs_del(bs); - //finally add the sample + //finally add the sample e = gf_isom_add_sample(the_file, trackNumber, trak->Media->information->sampleTable->currentEntryIndex, samp); gf_isom_sample_del(&samp); @@ -417,7 +417,7 @@ GF_Err gf_isom_hint_blank_data(GF_ISOFile *the_file, u32 trackNumber, u8 AtBegin } -//adds a chunk of data (max 14 bytes) in the packet that is directly copied +//adds a chunk of data (max 14 bytes) in the packet that is directly copied //while streaming GF_Err gf_isom_hint_direct_data(GF_ISOFile *the_file, u32 trackNumber, char *data, u32 dataLength, u8 AtBegin) { @@ -476,7 +476,7 @@ GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, u32 Sourc //we're getting data from another track if (SourceTrackID != trak->Header->trackID) { - //get (or set) the track reference index + //get (or set) the track reference index e = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint); if (e) return e; e = reftype_AddRefTrack(hint, SourceTrackID, &refIndex); @@ -543,7 +543,7 @@ GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumbe if (SourceTrackID == trak->Header->trackID) { dte->trackRefIndex = (s8) -1; } else { - //get (or set) the track reference index + //get (or set) the track reference index e = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint); if (e) return e; e = reftype_AddRefTrack(hint, SourceTrackID, &refIndex); @@ -556,11 +556,11 @@ GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumbe GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, - u8 PackingBit, - u8 eXtensionBit, - u8 MarkerBit, - u8 disposable_packet, - u8 IsRepeatedPacket) + u8 PackingBit, + u8 eXtensionBit, + u8 MarkerBit, + u8 disposable_packet, + u8 IsRepeatedPacket) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; @@ -587,15 +587,15 @@ GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, return GF_OK; } -GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, - s32 relativeTime, - u8 PackingBit, - u8 eXtensionBit, - u8 MarkerBit, - u8 PayloadType, - u8 B_frame, - u8 IsRepeatedPacket, - u16 SequenceNumber) +GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, + s32 relativeTime, + u8 PackingBit, + u8 eXtensionBit, + u8 MarkerBit, + u8 PayloadType, + u8 B_frame, + u8 IsRepeatedPacket, + u16 SequenceNumber) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; @@ -624,8 +624,8 @@ GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, } -//set the time offset of this packet. This enables packets to be placed in the hint track -//in decoding order, but have their presentation time-stamp in the transmitted +//set the time offset of this packet. This enables packets to be placed in the hint track +//in decoding order, but have their presentation time-stamp in the transmitted //packet be in a different order. Typically used for MPEG video with B-frames GF_Err gf_isom_rtp_packet_set_offset(GF_ISOFile *the_file, u32 trackNumber, s32 timeOffset) { @@ -752,7 +752,7 @@ GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const c strcat(buf, "\r\n"); gf_free(sdp->sdpText); ReorderSDP(buf, 0); - sdp->sdpText = buf; + sdp->sdpText = buf; return GF_OK; } @@ -820,7 +820,7 @@ GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text) hnti = (GF_HintTrackInfoBox *)gf_list_get(map->other_boxes, 0); if (!hnti->SDP) { - //we have to create it by hand, as we have a duplication of box type + //we have to create it by hand, as we have a duplication of box type //(GF_RTPSampleEntryBox and GF_RTPBox have the same type...) rtp = (GF_RTPBox *) gf_malloc(sizeof(GF_RTPBox)); rtp->subType = GF_ISOM_BOX_TYPE_SDP; @@ -842,7 +842,7 @@ GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text) strcat(buf, "\r\n"); gf_free(rtp->sdpText); ReorderSDP(buf, 1); - rtp->sdpText = buf; + rtp->sdpText = buf; return GF_OK; } diff --git a/src/isomedia/hinting.c b/src/isomedia/hinting.c index 947fd74..c57207f 100644 --- a/src/isomedia/hinting.c +++ b/src/isomedia/hinting.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,7 +48,7 @@ GF_Box *ghnt_New() void ghnt_del(GF_Box *s) { GF_HintSampleEntryBox *ptr; - + ptr = (GF_HintSampleEntryBox *)s; gf_isom_box_array_del(ptr->HintDataTable); if (ptr->hint_sample) gf_isom_hint_sample_del(ptr->hint_sample); @@ -102,7 +102,7 @@ GF_Err ghnt_Size(GF_Box *s) { GF_Err e; GF_HintSampleEntryBox *ptr = (GF_HintSampleEntryBox *)s; - + e = gf_isom_box_get_size(s); if (e) return e; ptr->size += 16; @@ -235,9 +235,9 @@ u32 gf_isom_hint_sample_size(GF_HintSample *ptr) GF_HintPacket *gf_isom_hint_pck_new(u8 HintType) { switch (HintType) { - case GF_ISMO_HINT_RTP: + case GF_ISMO_HINT_RTP: return (GF_HintPacket *) gf_isom_hint_rtp_new(); - default: + default: return NULL; } } @@ -394,16 +394,24 @@ GF_GenericDTE *NewDTE(u8 type) Deletion of DataTable entries in the RTP sample ********************************************************************/ void Del_EmptyDTE(GF_EmptyDTE *dte) -{ gf_free(dte); } +{ + gf_free(dte); +} void Del_ImmediateDTE(GF_ImmediateDTE *dte) -{ gf_free(dte); } +{ + gf_free(dte); +} void Del_SampleDTE(GF_SampleDTE *dte) -{ gf_free(dte); } +{ + gf_free(dte); +} void Del_StreamDescDTE(GF_StreamDescDTE *dte) -{ gf_free(dte); } +{ + gf_free(dte); +} //deletion of DTEs void DelDTE(GF_GenericDTE *dte) @@ -561,7 +569,7 @@ GF_Err OffsetDTE(GF_GenericDTE *dte, u32 offset, u32 HintSampleNumber) default: return GF_OK; } - + sDTE = (GF_SampleDTE *)dte; //we only adjust for intra HintTrack reference if (sDTE->trackRefIndex != (s8) -1) return GF_OK; @@ -621,10 +629,10 @@ GF_Err gf_isom_hint_rtp_read(GF_RTPPacket *ptr, GF_BitStream *bs) ptr->B_bit = gf_bs_read_int(bs, 1); ptr->R_bit = gf_bs_read_int(bs, 1); count = gf_bs_read_u16(bs); - + //read the TLV if (hasTLV) { - tempSize = 4; //TLVsize includes its field length + tempSize = 4; //TLVsize includes its field length TLVsize = gf_bs_read_u32(bs); while (tempSize < TLVsize) { e = gf_isom_parse_box(&a, bs); @@ -858,7 +866,7 @@ static GF_ISOSample *gf_isom_get_data_sample(GF_HintSample *hsamp, GF_TrackBox * hdc->samp = samp; hdc->sample_num = sample_num; hdc->trak = trak; - /*we insert all new samples, since they're more likely to be fetched next (except for audio + /*we insert all new samples, since they're more likely to be fetched next (except for audio interleaving and other multiplex)*/ gf_list_insert(hsamp->sample_cache, hdc, 0); return samp; @@ -926,21 +934,21 @@ GF_Err gf_isom_next_hint_packet(GF_ISOFile *the_file, u32 trackNumber, char **pc ts = (u32) (entry->hint_sample->TransmissionTime + pck->relativeTransTime + entry->ts_offset + cts_off); gf_bs_write_u32(bs, ts ); gf_bs_write_u32(bs, entry->ssrc); /*SSRC*/ - + /*then build all data*/ count = gf_list_count(pck->DataTable); for (i=0; iDataTable, i); switch (dte->source) { /*empty*/ - case 0: + case 0: break; /*immediate data*/ case 1: gf_bs_write_data(bs, ((GF_ImmediateDTE *)dte)->data, ((GF_ImmediateDTE *)dte)->dataLength); break; /*sample data*/ - case 2: + case 2: { GF_ISOSample *samp; GF_SampleDTE *sdte = (GF_SampleDTE *)dte; @@ -963,9 +971,9 @@ GF_Err gf_isom_next_hint_packet(GF_ISOFile *the_file, u32 trackNumber, char **pc } gf_bs_write_data(bs, samp->data + sdte->byteOffset, sdte->dataLength); } - break; + break; /*sample desc data - currently NOT SUPPORTED !!!*/ - case 3: + case 3: break; } } diff --git a/src/isomedia/isom_intern.c b/src/isomedia/isom_intern.c index 7c03133..4403795 100644 --- a/src/isomedia/isom_intern.c +++ b/src/isomedia/isom_intern.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -43,7 +43,7 @@ GF_Err MergeFragment(GF_MovieFragmentBox *moof, GF_ISOFile *mov) u64 MaxDur; GF_TrackFragmentBox *traf; GF_TrackBox *trak; - + MaxDur = 0; //we shall have a MOOV and its MVEX BEFORE any MOOF @@ -52,7 +52,7 @@ GF_Err MergeFragment(GF_MovieFragmentBox *moof, GF_ISOFile *mov) return GF_ISOM_INVALID_FILE; } //and all fragments must be continous - we do not throw an error as we may still want to be able to concatenate dependent representations in DASH and - //we will likely a-have R1(moofSN 1, 3, 5, 7) plus R2(moofSN 2, 4, 6, 8) + //we will likely a-have R1(moofSN 1, 3, 5, 7) plus R2(moofSN 2, 4, 6, 8) if (mov->NextMoofNumber && (mov->NextMoofNumber >= moof->mfhd->sequence_number)) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Warning: wrong sequence number: got %d but last one was %d\n", moof->mfhd->sequence_number, mov->NextMoofNumber)); // return GF_ISOM_INVALID_FILE; @@ -84,14 +84,14 @@ GF_Err MergeFragment(GF_MovieFragmentBox *moof, GF_ISOFile *mov) //update trak duration SetTrackDuration(trak); - if (trak->Header->duration > MaxDur) + if (trak->Header->duration > MaxDur) MaxDur = trak->Header->duration; trak->first_traf_merged = 1; } if (moof->other_boxes) { - GF_Box *a; + GF_Box *a; i = 0; while ((a = (GF_Box *)gf_list_enum(moof->other_boxes, &i))) { if (a->type == GF_ISOM_BOX_TYPE_PSSH) { @@ -173,9 +173,9 @@ GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progre /*set our pointer to the movie*/ mov->moov->mov = mov; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - if (mov->moov->mvex) mov->moov->mvex->mov = mov; + if (mov->moov->mvex) mov->moov->mvex->mov = mov; #endif - e = gf_list_add(mov->TopBoxes, a); + e = gf_list_add(mov->TopBoxes, a); if (e) { return e; } @@ -287,10 +287,10 @@ GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progre ((GF_MovieFragmentBox *)a)->mov = mov; totSize += a->size; - mov->moof = (GF_MovieFragmentBox *) a; + mov->moof = (GF_MovieFragmentBox *) a; /*read & debug: store at root level*/ if (mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG) { - u32 k; + u32 k; gf_list_add(mov->TopBoxes, a); /*also update pointers to trex for debug*/ if (mov->moov) { @@ -329,13 +329,13 @@ GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progre { GF_UnknownBox *box = (GF_UnknownBox*)a; u8 *c = (u8 *) box->data; - if ((box->dataSize==4) - && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A)) - mov->is_jp2 = 1; + if ((box->dataSize==4) + && (GF_4CC(c[0],c[1],c[2],c[3])==(u32)0x0D0A870A)) + mov->is_jp2 = 1; gf_isom_box_del(a); } - break; + break; case GF_ISOM_BOX_TYPE_PRFT: if (!(mov->FragmentsFlags & GF_ISOM_FRAG_READ_DEBUG)) { @@ -346,7 +346,7 @@ GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progre mov->last_producer_ref_time = (GF_ProducerReferenceTimeBox *)a; break; } - //fallthrough + //fallthrough default: @@ -362,12 +362,12 @@ GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u64 *bytesMissing, Bool progre } /*we need at least moov or meta*/ - if (!mov->moov && !mov->meta + if (!mov->moov && !mov->meta #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - && !mov->moof && !mov->is_index_segment + && !mov->moof && !mov->is_index_segment #endif - ) { - return GF_ISOM_INCOMPLETE_FILE; + ) { + return GF_ISOM_INCOMPLETE_FILE; } /*we MUST have movie header*/ if (mov->moov && !mov->moov->mvhd) { @@ -417,7 +417,7 @@ GF_ISOFile *gf_isom_new_movie() gf_free(mov); return NULL; } - + /*default storage mode is flat*/ mov->storageMode = GF_ISOM_STORE_FLAT; return mov; @@ -439,10 +439,10 @@ GF_ISOFile *gf_isom_open_file(const char *fileName, u32 OpenMode, const char *tm mov->openMode = GF_ISOM_OPEN_READ; mov->es_id_default_sync = -1; //for open, we do it the regular way and let the GF_DataMap assign the appropriate struct - //this can be FILE (the only one supported...) as well as remote + //this can be FILE (the only one supported...) as well as remote //(HTTP, ...),not suported yet //the bitstream IS PART OF the GF_DataMap - //as this is read-only, use a FileMapping. this is the only place where + //as this is read-only, use a FileMapping. this is the only place where //we use file mapping e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_READ_ONLY, &mov->movieFileMap); if (e) { @@ -544,7 +544,7 @@ void gf_isom_delete_movie(GF_ISOFile *mov) gf_free(mov); } -GF_TrackBox *gf_isom_get_track_from_id(GF_MovieBox *moov, u32 trackID) +GF_TrackBox *gf_isom_get_track_from_id(GF_MovieBox *moov, u32 trackID) { u32 i, count; GF_TrackBox *trak; @@ -558,7 +558,7 @@ GF_TrackBox *gf_isom_get_track_from_id(GF_MovieBox *moov, u32 trackID) return NULL; } -GF_TrackBox *gf_isom_get_track_from_original_id(GF_MovieBox *moov, u32 originalID, u32 originalFile) +GF_TrackBox *gf_isom_get_track_from_original_id(GF_MovieBox *moov, u32 originalID, u32 originalFile) { u32 i, count; GF_TrackBox *trak; @@ -621,7 +621,7 @@ GF_Err GetMediaTime(GF_TrackBox *trak, Bool force_non_empty, u64 movieTime, u64 //check this is in our media time line if ((*MediaTime > lastSampleTime) #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - && !trak->moov->mov->moof + && !trak->moov->mov->moof #endif ) { *MediaTime = lastSampleTime; @@ -694,7 +694,7 @@ ent_found: *useEdit = 2; return GF_OK; } - + /*WARNING: this can be "-1" when doing searchForward mode (to prevent jumping to next entry)*/ mtime = ent->mediaTime + movieTime - (time * trak->Media->mediaHeader->timeScale / trak->moov->mvhd->timeScale); if (mtime<0) mtime = 0; @@ -708,7 +708,7 @@ ent_found: //we have to find a COMPOSITION time e = findEntryForTime(stbl, (u32) *MediaTime, 1, &sampleNumber, &prevSampleNumber); if (e) return e; - + //first case: our time is after the last sample DTS (it's a broken editList somehow) //set the media time to the last sample if (!sampleNumber && !prevSampleNumber) { @@ -738,7 +738,7 @@ ent_found: //and store the "time offset" of the desired sample in this segment //this is weird, used to rebuild the timeStamp when reading from the track, not the //media ... - *MediaOffset = firstDTS; + *MediaOffset = firstDTS; #endif return GF_OK; } @@ -848,7 +848,7 @@ GF_ISOFile *gf_isom_create_movie(const char *fileName, u32 OpenMode, const char mov->fileName = gf_strdup(fileName); e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_WRITE, & mov->editFileMap); if (e) goto err_exit; - + /*brand is set to ISOM by default - it may be touched until sample data is added to track*/ gf_isom_set_brand_info( (GF_ISOFile *) mov, GF_ISOM_BRAND_ISOM, 1); } else { @@ -868,7 +868,7 @@ GF_ISOFile *gf_isom_create_movie(const char *fileName, u32 OpenMode, const char //create an MDAT mov->mdat = (GF_MediaDataBox *) mdat_New(); gf_list_add(mov->TopBoxes, mov->mdat); - + //default behaviour is capture mode, no interleaving (eg, no rewrite of mdat) mov->storageMode = GF_ISOM_STORE_FLAT; return mov; @@ -917,8 +917,8 @@ GF_Err gf_isom_add_subsample_info(GF_SubSampleInformationBox *sub_samples, u32 s for (i=0; iSamples, i); /*TODO - do we need to support insertion of subsample info ?*/ - if (last_sample + pSamp->sample_delta > sampleNumber) return GF_NOT_SUPPORTED; - if (last_sample + pSamp->sample_delta == sampleNumber) break; + if (last_sample + pSamp->sample_delta > sampleNumber) return GF_NOT_SUPPORTED; + if (last_sample + pSamp->sample_delta == sampleNumber) break; last_sample += pSamp->sample_delta; pSamp = NULL; } diff --git a/src/isomedia/isom_read.c b/src/isomedia/isom_read.c index 382155b..0ee42be 100644 --- a/src/isomedia/isom_read.c +++ b/src/isomedia/isom_read.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -56,6 +56,7 @@ u8 gf_isom_get_mode(GF_ISOFile *the_file) return the_file->openMode; } +GF_EXPORT u64 gf_isom_get_file_size(GF_ISOFile *the_file) { if (!the_file) return 0; @@ -99,7 +100,7 @@ u32 gf_isom_probe_file(const char *fileName) u8 *mem_address; if (sscanf(fileName, "gmem://%d@%p", &size, &mem_address) != 2) { return 0; - } + } if (size>8) type = GF_4CC(mem_address[4], mem_address[5], mem_address[6], mem_address[7]); } else { @@ -264,7 +265,7 @@ GF_Err gf_isom_close(GF_ISOFile *movie) for (i=0; imoov->trackList); i++) { GF_TrackBox *trak = gf_list_get(movie->moov->trackList, i); /*delete any pending dataHandler of scalable enhancements*/ - if (trak->Media->information->scalableDataHandler && (trak->Media->information->scalableDataHandler != movie->movieFileMap)) + if (trak->Media->information->scalableDataHandler && (trak->Media->information->scalableDataHandler != movie->movieFileMap)) gf_isom_datamap_del(trak->Media->information->scalableDataHandler); } } @@ -453,19 +454,19 @@ GF_EXPORT Bool gf_isom_has_segment(GF_ISOFile *file, u32 *brand, u32 *version) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - u32 i; - GF_Box *a; - i = 0; - while (NULL != (a = gf_list_enum(file->TopBoxes, &i))) { + u32 i; + GF_Box *a; + i = 0; + while (NULL != (a = gf_list_enum(file->TopBoxes, &i))) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - if (a->type == GF_ISOM_BOX_TYPE_STYP) { - GF_SegmentTypeBox *styp = (GF_SegmentTypeBox *)a; - *brand = styp->majorBrand; - *version = styp->minorVersion; - return 1; - } + if (a->type == GF_ISOM_BOX_TYPE_STYP) { + GF_SegmentTypeBox *styp = (GF_SegmentTypeBox *)a; + *brand = styp->majorBrand; + *version = styp->minorVersion; + return 1; + } #endif - } + } #endif return 0; } @@ -474,7 +475,7 @@ GF_EXPORT u32 gf_isom_segment_get_fragment_count(GF_ISOFile *file) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - if (file) { + if (file) { u32 i, count = 0; for (i=0; iTopBoxes); i++) { GF_Box *a = gf_list_get(file->TopBoxes, i); @@ -504,7 +505,7 @@ u32 gf_isom_segment_get_track_fragment_count(GF_ISOFile *file, u32 moof_index) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS GF_MovieFragmentBox *moof; - if (!file) return 0; + if (!file) return 0; gf_list_count(file->TopBoxes); moof = gf_isom_get_moof(file, moof_index); return moof ? gf_list_count(moof->TrackList) : 0; @@ -518,7 +519,7 @@ u32 gf_isom_segment_get_track_fragment_decode_time(GF_ISOFile *file, u32 moof_in #ifndef GPAC_DISABLE_ISOM_FRAGMENTS GF_MovieFragmentBox *moof; GF_TrackFragmentBox *traf; - if (!file) return 0; + if (!file) return 0; gf_list_count(file->TopBoxes); moof = gf_isom_get_moof(file, moof_index); traf = moof ? gf_list_get(moof->TrackList, traf_index-1) : NULL; @@ -606,7 +607,7 @@ u8 gf_isom_is_track_in_root_od(GF_ISOFile *movie, u32 trackNumber) case GF_ODF_ISOM_OD_TAG: inc_list = ((GF_IsomObjectDescriptor *)desc)->ES_ID_IncDescriptors; break; - //files without IOD are possible ! + //files without IOD are possible ! default: return 0; } @@ -1156,9 +1157,9 @@ u32 gf_isom_get_sample_count(GF_ISOFile *the_file, u32 trackNumber) if (!trak) return 0; return trak->Media->information->sampleTable->SampleSize->sampleCount #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - + trak->sample_count_at_seg_start + + trak->sample_count_at_seg_start #endif - ; + ; } u32 gf_isom_get_constant_sample_size(GF_ISOFile *the_file, u32 trackNumber) @@ -1456,7 +1457,7 @@ GF_Err gf_isom_get_sample_for_media_time(GF_ISOFile *the_file, u32 trackNumber, if (IsSync) { //get the SyncNumber e = Media_FindSyncSample(trak->Media->information->sampleTable, - sampleNumber, &syncNum, SearchMode); + sampleNumber, &syncNum, SearchMode); if (e) return e; if (syncNum) sampleNumber = syncNum; syncNum = 0; @@ -1466,7 +1467,7 @@ GF_Err gf_isom_get_sample_for_media_time(GF_ISOFile *the_file, u32 trackNumber, else if (SearchMode == GF_ISOM_SEARCH_SYNC_SHADOW) { //get the SyncNumber e = Media_FindSyncSample(trak->Media->information->sampleTable, - sampleNumber, &syncNum, GF_ISOM_SEARCH_SYNC_BACKWARD); + sampleNumber, &syncNum, GF_ISOM_SEARCH_SYNC_BACKWARD); if (e) return e; } @@ -1487,7 +1488,7 @@ GF_Err gf_isom_get_sample_for_media_time(GF_ISOFile *the_file, u32 trackNumber, if ((sampleNumber < syncNum) || (!shadowSync)) { sampleNumber = syncNum; } else { - //otherwise, we have a better alternate sample in the shadowSync for this sample + //otherwise, we have a better alternate sample in the shadowSync for this sample useShadow = 1; } } @@ -1549,9 +1550,9 @@ GF_Err gf_isom_get_sample_for_movie_time(GF_ISOFile *the_file, u32 trackNumber, } else if ((movieTime * trak->moov->mvhd->timeScale > trak->Header->duration * trak->Media->mediaHeader->timeScale) #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - && !trak->dts_at_seg_start + && !trak->dts_at_seg_start #endif - ) { + ) { *sample = NULL; if (sampleNumber) *sampleNumber = 0; *StreamDescriptionIndex = 0; @@ -1565,7 +1566,7 @@ GF_Err gf_isom_get_sample_for_movie_time(GF_ISOFile *the_file, u32 trackNumber, e = GetMediaTime(trak, (SearchMode==GF_ISOM_SEARCH_SYNC_FORWARD) ? 1 : 0, movieTime, &mediaTime, &segStartTime, &mediaOffset, &useEdit, &nextMediaTime); if (e) return e; - + /*here we check if we were playing or not and return no sample in normal search modes*/ if (useEdit && mediaOffset == -1) { if ((SearchMode==GF_ISOM_SEARCH_FORWARD) || (SearchMode==GF_ISOM_SEARCH_BACKWARD)) { @@ -1715,9 +1716,9 @@ GF_Err gf_isom_get_edit_segment(GF_ISOFile *the_file, u32 trackNumber, u32 Segme if (!trak) return GF_BAD_PARAM; if (!trak->editBox || - !trak->editBox->editList || - (SegmentIndex > gf_list_count(trak->editBox->editList->entryList)) || - !SegmentIndex) + !trak->editBox->editList || + (SegmentIndex > gf_list_count(trak->editBox->editList->entryList)) || + !SegmentIndex) return GF_BAD_PARAM; elst = trak->editBox->editList; @@ -1808,7 +1809,7 @@ GF_Err gf_isom_get_sample_padding_bits(GF_ISOFile *the_file, u32 trackNumber, u3 //Padding info return stbl_GetPaddingBits(trak->Media->information->sampleTable->PaddingBits, - sampleNumber, NbBits); + sampleNumber, NbBits); } @@ -1947,7 +1948,7 @@ GF_Err gf_isom_get_chunks_infos(GF_ISOFile *movie, u32 trackNumber, u32 *dur_min chunk_dur += dur; stbl_GetSampleSize(trak->Media->information->sampleTable->SampleSize, k+sample_idx, &size); chunk_size += size; - + } if (dmin>chunk_dur) dmin = chunk_dur; if (dmaxchunk_size) smin = chunk_size; if (smaxentries[i].samplesPerChunk; if (i+1==stsc->nb_entries) break; @@ -2002,8 +2003,8 @@ u16 gf_isom_get_sample_fragment_size(GF_ISOFile *the_file, u32 trackNumber, u32 GF_EXPORT GF_Err gf_isom_get_fragment_defaults(GF_ISOFile *the_file, u32 trackNumber, - u32 *defaultDuration, u32 *defaultSize, u32 *defaultDescriptionIndex, - u32 *defaultRandomAccess, u8 *defaultPadding, u16 *defaultDegradationPriority) + u32 *defaultDuration, u32 *defaultSize, u32 *defaultDescriptionIndex, + u32 *defaultRandomAccess, u8 *defaultPadding, u16 *defaultDegradationPriority) { GF_TrackBox *trak; GF_StscEntry *sc_ent; @@ -2066,7 +2067,7 @@ GF_Err gf_isom_get_fragment_defaults(GF_ISOFile *the_file, u32 trackNumber, //no sync table is ALL RAP *defaultRandomAccess = stbl->SyncSample ? 0 : 1; if (stbl->SyncSample - && (stbl->SyncSample->nb_entries >= stbl->SampleSize->sampleCount/2)) { + && (stbl->SyncSample->nb_entries >= stbl->SampleSize->sampleCount/2)) { *defaultRandomAccess = 1; } } @@ -2130,9 +2131,9 @@ GF_Err gf_isom_refresh_fragmented(GF_ISOFile *movie, u64 *MissingBytes, const ch Bool delete_map; GF_DataMap *previous_movie_fileMap_address = movie->movieFileMap; GF_Err e; - + e = gf_isom_datamap_new(new_location, NULL, GF_ISOM_DATA_MAP_READ_ONLY, &movie->movieFileMap); - if (e) return e; + if (e) return e; delete_map = (previous_movie_fileMap_address != NULL ? GF_TRUE: GF_FALSE); for (i=0; imoov->trackList); i++) { @@ -2160,13 +2161,13 @@ GF_Err gf_isom_refresh_fragmented(GF_ISOFile *movie, u64 *MissingBytes, const ch } GF_EXPORT -void gf_isom_set_single_moof_mode(GF_ISOFile *movie, Bool mode) +void gf_isom_set_single_moof_mode(GF_ISOFile *movie, Bool mode) { movie->single_moof_mode = mode; } GF_EXPORT -GF_Err gf_isom_reset_data_offset(GF_ISOFile *movie, u64 *top_box_start) +GF_Err gf_isom_reset_data_offset(GF_ISOFile *movie, u64 *top_box_start) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (!movie || !movie->moov || !movie->moov->mvex) return GF_BAD_PARAM; @@ -2181,10 +2182,10 @@ GF_Err gf_isom_reset_data_offset(GF_ISOFile *movie, u64 *top_box_start) GF_EXPORT -GF_Err gf_isom_reset_tables(GF_ISOFile *movie, Bool reset_sample_count) +GF_Err gf_isom_reset_tables(GF_ISOFile *movie, Bool reset_sample_count) { #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - u32 i; + u32 i; if (!movie || !movie->moov || !movie->moov->mvex) return GF_BAD_PARAM; for (i=0; imoov->trackList); i++) { GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(movie->moov->trackList, i); @@ -2207,7 +2208,7 @@ GF_Err gf_isom_reset_tables(GF_ISOFile *movie, Bool reset_sample_count) gf_isom_box_del((GF_Box *)_a);\ _a = __cast gf_isom_box_new(type);\ }\ - + RECREATE_BOX(stbl->ChunkOffset, (GF_Box *)); RECREATE_BOX(stbl->CompositionOffset, (GF_CompositionOffsetBox *)); RECREATE_BOX(stbl->DegradationPriority, (GF_DegradationPriorityBox *)); @@ -2290,7 +2291,7 @@ GF_Err gf_isom_release_segment(GF_ISOFile *movie, Bool reset_tables) gf_isom_box_del((GF_Box *)_a);\ _a = __cast gf_isom_box_new(type);\ }\ - + RECREATE_BOX(stbl->ChunkOffset, (GF_Box *)); RECREATE_BOX(stbl->CompositionOffset, (GF_CompositionOffsetBox *)); RECREATE_BOX(stbl->DegradationPriority, (GF_DegradationPriorityBox *)); @@ -2304,7 +2305,7 @@ GF_Err gf_isom_release_segment(GF_ISOFile *movie, Bool reset_tables) } - j = 0; + j = 0; while ((a = (GF_Box *)gf_list_enum(movie->moov->other_boxes, &j))) { if (a->type == GF_ISOM_BOX_TYPE_PSSH) { gf_isom_box_del(a); @@ -2355,10 +2356,10 @@ GF_Err gf_isom_open_segment(GF_ISOFile *movie, const char *fileName, u64 start_r if (end_range > start_range) { gf_bs_seek(movie->movieFileMap->bs, end_range+1); gf_bs_truncate(movie->movieFileMap->bs); - gf_bs_seek(movie->movieFileMap->bs, start_range); + gf_bs_seek(movie->movieFileMap->bs, start_range); movie->current_top_box_start = start_range; } - + for (i=0; imoov->trackList); i++) { GF_TrackBox *trak = gf_list_get(movie->moov->trackList, i); @@ -2375,14 +2376,14 @@ GF_Err gf_isom_open_segment(GF_ISOFile *movie, const char *fileName, u64 start_r //ok parse root boxes e = gf_isom_parse_movie_boxes(movie, &MissingBytes, 1); - - if (!is_scalable_segment) + + if (!is_scalable_segment) return e; for (i=0; imoov->trackList); i++) { GF_TrackBox *trak = gf_list_get(movie->moov->trackList, i); if (trak->present_in_scalable_segment) { - /*store the temp dataHandler into scalableDataHandler so that it will not be destroyed + /*store the temp dataHandler into scalableDataHandler so that it will not be destroyed if we append another representation - destruction of this data handler is done in release_segment*/ trak->Media->information->scalableDataHandler = tmp; if (!segment_map_assigned) { @@ -2406,7 +2407,7 @@ u32 gf_isom_get_highest_track_in_scalable_segment(GF_ISOFile *movie, u32 for_bas #else s32 max_ref; u32 i, j, track_id; - + max_ref = 0; track_id = 0; for (i=0; imoov->trackList); i++) { @@ -2552,16 +2553,17 @@ GF_Err gf_isom_get_visual_info(GF_ISOFile *movie, u32 trackNumber, u32 StreamDes case GF_ISOM_SUBTYPE_3GP_H263: case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_GNRV: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: *Width = ((GF_VisualSampleEntryBox*)entry)->Width; *Height = ((GF_VisualSampleEntryBox*)entry)->Height; return GF_OK; @@ -2636,16 +2638,17 @@ GF_Err gf_isom_get_pixel_aspect_ratio(GF_ISOFile *movie, u32 trackNumber, u32 St case GF_ISOM_SUBTYPE_3GP_H263: case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: - case GF_ISOM_BOX_TYPE_AVC3: - case GF_ISOM_BOX_TYPE_AVC4: + case GF_ISOM_BOX_TYPE_AVC3: + case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_GNRV: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: *hSpacing = ((GF_VisualSampleEntryBox*)entry)->pasp ? ((GF_VisualSampleEntryBox*)entry)->pasp->hSpacing : 0; *vSpacing = ((GF_VisualSampleEntryBox*)entry)->pasp ? ((GF_VisualSampleEntryBox*)entry)->pasp->vSpacing : 0; return GF_OK; @@ -2675,12 +2678,18 @@ u8 gf_isom_get_pl_indication(GF_ISOFile *movie, u8 PL_Code) iod = (GF_IsomInitialObjectDescriptor *)movie->moov->iods->descriptor; switch (PL_Code) { - case GF_ISOM_PL_AUDIO: return iod->audio_profileAndLevel; - case GF_ISOM_PL_VISUAL: return iod->visual_profileAndLevel; - case GF_ISOM_PL_GRAPHICS: return iod->graphics_profileAndLevel; - case GF_ISOM_PL_SCENE: return iod->scene_profileAndLevel; - case GF_ISOM_PL_OD: return iod->OD_profileAndLevel; - case GF_ISOM_PL_INLINE: return iod->inlineProfileFlag; + case GF_ISOM_PL_AUDIO: + return iod->audio_profileAndLevel; + case GF_ISOM_PL_VISUAL: + return iod->visual_profileAndLevel; + case GF_ISOM_PL_GRAPHICS: + return iod->graphics_profileAndLevel; + case GF_ISOM_PL_SCENE: + return iod->scene_profileAndLevel; + case GF_ISOM_PL_OD: + return iod->OD_profileAndLevel; + case GF_ISOM_PL_INLINE: + return iod->inlineProfileFlag; case GF_ISOM_PL_MPEGJ: default: return 0xFF; @@ -2721,7 +2730,7 @@ u64 gf_isom_get_media_data_size(GF_ISOFile *movie, u32 trackNumber) stsz = tk->Media->information->sampleTable->SampleSize; if (stsz->sampleSize) return stsz->sampleSize*stsz->sampleCount; size = 0; - for (i=0; isampleCount;i++) size += stsz->sizes[i]; + for (i=0; isampleCount; i++) size += stsz->sizes[i]; return size; } @@ -2819,17 +2828,27 @@ u32 gf_isom_guess_specification(GF_ISOFile *file) case GF_ISOM_SUBTYPE_3GP_AMR_WB: nb_amr++; break; - case GF_ISOM_SUBTYPE_3GP_H263: nb_h263++; break; - case GF_ISOM_SUBTYPE_3GP_EVRC: nb_evrc++; break; - case GF_ISOM_SUBTYPE_3GP_QCELP: nb_qcelp++; break; - case GF_ISOM_SUBTYPE_3GP_SMV: nb_smv++; break; + case GF_ISOM_SUBTYPE_3GP_H263: + nb_h263++; + break; + case GF_ISOM_SUBTYPE_3GP_EVRC: + nb_evrc++; + break; + case GF_ISOM_SUBTYPE_3GP_QCELP: + nb_qcelp++; + break; + case GF_ISOM_SUBTYPE_3GP_SMV: + nb_smv++; + break; case GF_ISOM_SUBTYPE_AVC_H264: - case GF_ISOM_SUBTYPE_AVC2_H264: - case GF_ISOM_SUBTYPE_AVC3_H264: - case GF_ISOM_SUBTYPE_AVC4_H264: - nb_avc++; + case GF_ISOM_SUBTYPE_AVC2_H264: + case GF_ISOM_SUBTYPE_AVC3_H264: + case GF_ISOM_SUBTYPE_AVC4_H264: + nb_avc++; + break; + case GF_ISOM_SUBTYPE_SVC_H264: + nb_avc++; break; - case GF_ISOM_SUBTYPE_SVC_H264: nb_avc++; break; case GF_ISOM_SUBTYPE_MPEG4: case GF_ISOM_SUBTYPE_MPEG4_CRYP: { @@ -2844,18 +2863,26 @@ u32 gf_isom_guess_specification(GF_ISOFile *file) switch (dcd->objectTypeIndication) { case GPAC_OTI_AUDIO_AAC_MPEG2_MP: case GPAC_OTI_AUDIO_AAC_MPEG2_LCP: - case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: - case GPAC_OTI_AUDIO_AAC_MPEG4: - nb_aac++; + case GPAC_OTI_AUDIO_AAC_MPEG2_SSRP: + case GPAC_OTI_AUDIO_AAC_MPEG4: + nb_aac++; break; - case GPAC_OTI_AUDIO_MPEG2_PART3: - case GPAC_OTI_AUDIO_MPEG1: - nb_mp3++; + case GPAC_OTI_AUDIO_MPEG2_PART3: + case GPAC_OTI_AUDIO_MPEG1: + nb_mp3++; + break; + case GPAC_OTI_AUDIO_EVRC_VOICE: + nb_evrc++; + break; + case GPAC_OTI_AUDIO_SMV_VOICE: + nb_smv++; + break; + case GPAC_OTI_AUDIO_13K_VOICE: + nb_qcelp++; + break; + default: + nb_a++; break; - case GPAC_OTI_AUDIO_EVRC_VOICE: nb_evrc++; break; - case GPAC_OTI_AUDIO_SMV_VOICE: nb_smv++; break; - case GPAC_OTI_AUDIO_13K_VOICE: nb_qcelp++; break; - default: nb_a++; break; } break; /*SHOULD NEVER HAPPEN - IF SO, BROKEN MPEG4 FILE*/ @@ -2865,7 +2892,7 @@ u32 gf_isom_guess_specification(GF_ISOFile *file) } gf_odf_desc_del((GF_Descriptor *)dcd); } - break; + break; default: if (mtype==GF_ISOM_MEDIA_VISUAL) nb_v++; else nb_a++; @@ -3089,18 +3116,19 @@ GF_Err gf_isom_get_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptio if (!entry ) return GF_BAD_PARAM; switch (entry->type) { case GF_ISOM_BOX_TYPE_MP4V: - case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_ENCV: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_BAD_PARAM; @@ -3173,9 +3201,9 @@ GF_Err gf_isom_get_sample_rap_roll_info(GF_ISOFile *the_file, u32 trackNumber, u if (roll_distance) { s32 max_roll = 0; u32 j; - for (j=0; jgroup_descriptions);j++) { + for (j=0; jgroup_descriptions); j++) { GF_RollRecoveryEntry *roll_entry = gf_list_get(sgdesc->group_descriptions, j); - if (max_roll < roll_entry->roll_distance) + if (max_roll < roll_entry->roll_distance) max_roll = roll_entry->roll_distance; } if (*roll_distance < max_roll) *roll_distance = max_roll; @@ -3233,6 +3261,49 @@ GF_Err gf_isom_get_sample_rap_roll_info(GF_ISOFile *the_file, u32 trackNumber, u return GF_OK; } +GF_EXPORT +Bool gf_isom_get_sample_group_info(GF_ISOFile *the_file, u32 trackNumber, u32 sample_description_index, u32 grouping_type, u32 *default_index, const char **data, u32 *size) +{ + + GF_TrackBox *trak; + u32 i, count; + + if (default_index) *default_index = 0; + if (size) *size = 0; + if (data) *data = NULL; + + trak = gf_isom_get_track_from_file(the_file, trackNumber); + if (!trak || !sample_description_index) return 0; + if (!trak->Media->information->sampleTable->sampleGroupsDescription) return 0; + + count = gf_list_count(trak->Media->information->sampleTable->sampleGroupsDescription); + for (i=0; iMedia->information->sampleTable->sampleGroupsDescription, i); + if (sgdesc->grouping_type != grouping_type) + continue; + + if (sgdesc->default_description_index && !sample_description_index) sample_description_index = sgdesc->default_description_index; + if (default_index) *default_index = sgdesc->default_description_index ; + + if (!sample_description_index) return 0; + + switch (grouping_type) { + case GF_4CC('r','a','p',' '): + case GF_4CC('r','o','l','l'): + case GF_4CC( 's', 'e', 'i', 'g' ): + return 1; + default: + entry = gf_list_get(sgdesc->group_descriptions, sample_description_index-1); + if (entry && data) *data = entry->data; + if (entry && size) *size = entry->length; + return 1; + } + } + return 0; +} + + #ifndef GPAC_DISABLE_ISOM_FRAGMENTS //return the duration of the movie+fragments if known, 0 if error GF_EXPORT @@ -3252,10 +3323,10 @@ u32 gf_isom_get_fragments_count(GF_ISOFile *movie, Bool segments_only) GF_Box *b; while ((b=gf_list_enum(movie->TopBoxes, &i))) { if (segments_only) { - if (b->type==GF_ISOM_BOX_TYPE_SIDX) + if (b->type==GF_ISOM_BOX_TYPE_SIDX) nb_frags++; } else { - if (b->type==GF_ISOM_BOX_TYPE_MOOF) + if (b->type==GF_ISOM_BOX_TYPE_MOOF) nb_frags++; } } @@ -3270,7 +3341,7 @@ GF_Err gf_isom_get_fragmented_samples_info(GF_ISOFile *movie, u32 trackID, u32 * u64 def_duration, samp_dur; GF_MovieFragmentBox *moof; GF_TrackFragmentBox *traf; - + *nb_samples = 0; *duration = 0; while ((moof=gf_list_enum(movie->TopBoxes, &i))) { @@ -3337,7 +3408,7 @@ s32 gf_isom_get_composition_offset_shift(GF_ISOFile *file, u32 track) } GF_EXPORT -Bool gf_isom_has_scalable_layer(GF_ISOFile *file) +Bool gf_isom_has_scalable_layer(GF_ISOFile *file) { u32 count, i; if (!file) @@ -3360,7 +3431,7 @@ void gf_isom_keep_utc_times(GF_ISOFile *file, Bool keep_utc) GF_EXPORT -u32 gf_isom_get_pssh_count(GF_ISOFile *file) +u32 gf_isom_get_pssh_count(GF_ISOFile *file) { u32 count=0; u32 i=0; @@ -3373,7 +3444,7 @@ u32 gf_isom_get_pssh_count(GF_ISOFile *file) } GF_EXPORT -GF_Err gf_isom_get_pssh_info(GF_ISOFile *file, u32 pssh_index, bin128 SystemID, u32 *KID_count, const bin128 **KIDs, const u8 **private_data, u32 *private_data_size) +GF_Err gf_isom_get_pssh_info(GF_ISOFile *file, u32 pssh_index, bin128 SystemID, u32 *KID_count, const bin128 **KIDs, const u8 **private_data, u32 *private_data_size) { u32 count=1; u32 i=0; @@ -3410,7 +3481,12 @@ GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, GF_TrackFragmentBox *t if (IV_size) *IV_size = 0; if (KID) memset(*KID, 0, 16); - stbl_GetSampleInfos(trak->Media->information->sampleTable, sample_number, &offset, &chunkNum, &descIndex, &edit); + if (trak->Media->information->sampleTable->SampleSize && trak->Media->information->sampleTable->SampleSize->sampleCount>=sample_number) { + stbl_GetSampleInfos(trak->Media->information->sampleTable, sample_number, &offset, &chunkNum, &descIndex, &edit); + } else { + //this is dump mode of fragments, we haven't merged tables yet :( + descIndex = 1; + } gf_isom_cenc_get_default_info_ex(trak, descIndex, IsEncrypted, IV_size, KID); @@ -3420,7 +3496,7 @@ GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, GF_TrackFragmentBox *t count = gf_list_count(trak->Media->information->sampleTable->sampleGroups); for (i=0; iMedia->information->sampleTable->sampleGroups, i); - if (sample_group->grouping_type == GF_4CC( 's', 'e', 'i', 'g' )) + if (sample_group->grouping_type == GF_4CC( 's', 'e', 'i', 'g' )) break; sample_group = NULL; } @@ -3443,10 +3519,10 @@ GF_Err gf_isom_get_sample_cenc_info_ex(GF_TrackBox *trak, GF_TrackFragmentBox *t for (i=0; isampleGroups, i); - if (sample_group->grouping_type == GF_4CC( 's', 'e', 'i', 'g' )) + if (sample_group->grouping_type == GF_4CC( 's', 'e', 'i', 'g' )) break; sample_group = NULL; - } + } if (sample_group) { first_sample_in_entry = 1; for (j=0; jentry_count; j++) { @@ -3535,5 +3611,33 @@ u64 gf_isom_get_current_tfdt(GF_ISOFile *the_file, u32 trackNumber) #endif } +void gf_isom_parse_trif_info(const char *data, u32 size, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h) +{ + GF_BitStream *bs; + bs = gf_bs_new(data, size, GF_BITSTREAM_READ); + *id = gf_bs_read_u16(bs); + *independent = gf_bs_read_int(bs, 2); + *full_frame = gf_bs_read_int(bs, 1); + gf_bs_read_int(bs, 5); + *x = *full_frame ? 0 : gf_bs_read_u16(bs); + *y = *full_frame ? 0 : gf_bs_read_u16(bs); + *w = gf_bs_read_u16(bs); + *h = gf_bs_read_u16(bs); + gf_bs_del(bs); + +} + +GF_EXPORT +Bool gf_isom_get_tile_info(GF_ISOFile *file, u32 trackNumber, u32 sample_description_index, u32 *default_sample_group_index, u32 *id, u32 *independent, Bool *full_frame, u32 *x, u32 *y, u32 *w, u32 *h) +{ + const char *data; + u32 size; + + if (!gf_isom_get_sample_group_info(file, trackNumber, sample_description_index, GF_4CC('t','r','i','f'), default_sample_group_index, &data, &size)) + return 0; + gf_isom_parse_trif_info(data, size, id, independent, full_frame, x, y, w, h); + return 1; +} + #endif /*GPAC_DISABLE_ISOM*/ diff --git a/src/isomedia/isom_store.c b/src/isomedia/isom_store.c index e89e68a..f108778 100644 --- a/src/isomedia/isom_store.c +++ b/src/isomedia/isom_store.c @@ -2,7 +2,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -12,15 +12,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -59,7 +59,7 @@ static GF_Err gf_isom_insert_copyright(GF_ISOFile *movie) return gf_list_add(movie->TopBoxes, _free); } -typedef struct +typedef struct { /*the curent sample of this track*/ u32 sampleNumber; @@ -137,7 +137,7 @@ GF_Err SetupWriters(MovieWriter *mw, GF_List *writers, u8 interleaving) trackCount = gf_list_count(movie->moov->trackList); for (i = 0; i < trackCount; i++) { trak = gf_isom_get_track(movie->moov, i+1); - + GF_SAFEALLOC(writer, TrackWriter); if (!writer) goto exit; writer->sampleNumber = 1; @@ -158,12 +158,12 @@ GF_Err SetupWriters(MovieWriter *mw, GF_List *writers, u8 interleaving) if (Media_IsSelfContained(writer->mdia, 1)) mw->total_samples += trak->Media->information->sampleTable->SampleSize->sampleCount; /*optimization for interleaving: put audio last (this can be overriden by priorities)*/ if (movie->storageMode != GF_ISOM_STORE_INTERLEAVED) { - gf_list_add(writers, writer); + gf_list_add(writers, writer); } else { if (writer->mdia->information->InfoHeader && writer->mdia->information->InfoHeader->type == GF_ISOM_BOX_TYPE_SMHD) { - gf_list_add(writers, writer); + gf_list_add(writers, writer); } else { - gf_list_insert(writers, writer, 0); + gf_list_insert(writers, writer, 0); } } } @@ -231,7 +231,7 @@ static GF_Err ShiftOffset(GF_ISOFile *file, GF_List *writers, u64 offset) gf_isom_box_del((GF_Box *)co64); return GF_OUT_OF_MEM; } - //duplicate the table + //duplicate the table for (l = 0; l < co64->nb_entries; l++) { co64->offsets[l] = (u64) stco->offsets[l]; if (l + 1 == k) co64->offsets[l] += offset; @@ -253,7 +253,7 @@ static GF_Err ShiftOffset(GF_ISOFile *file, GF_List *writers, u64 offset) } } } - + return GF_OK; } @@ -292,7 +292,7 @@ static GF_Err WriteMoovAndMeta(GF_ISOFile *movie, GF_List *writers, GF_BitStream e = gf_isom_box_size((GF_Box *)movie->moov); if (e) return e; e = gf_isom_box_write((GF_Box *)movie->moov, bs); - //and re-switch our table. We have to do it that way because it is + //and re-switch our table. We have to do it that way because it is //needed when the moov is written first i=0; while ((writer = (TrackWriter*)gf_list_enum(writers, &i))) { @@ -364,11 +364,11 @@ GF_Err WriteSample(MovieWriter *mw, u32 size, u64 offset, u8 isEdited, GF_BitStr } //get the payload... bytes = gf_isom_datamap_get_data(map, mw->buffer, size, offset); - if (bytes != size) + if (bytes != size) return GF_IO_ERR; //write it to our stream... bytes = gf_bs_write_data(bs, mw->buffer, size); - if (bytes != size) + if (bytes != size) return GF_IO_ERR; mw->nb_done++; @@ -412,11 +412,11 @@ GF_Err DoWriteMeta(GF_ISOFile *file, GF_MetaBox *meta, GF_BitStream *bs, Bool Em /*for self contained only*/ if (!iloc->data_reference_index) { iloc->base_offset = baseOffset; - + /*new resource*/ if (iinf->full_path) { FILE *src=NULL; - + if (!iinf->data_len) { src = gf_f64_open(iinf->full_path, "rb"); if (!src) continue; @@ -453,7 +453,7 @@ GF_Err DoWriteMeta(GF_ISOFile *file, GF_MetaBox *meta, GF_BitStream *bs, Bool Em } } if (src) fclose(src); - } + } else if (gf_list_count(iloc->extent_entries)) { u32 j; j=0; @@ -497,7 +497,7 @@ GF_Err DoWriteMeta(GF_ISOFile *file, GF_MetaBox *meta, GF_BitStream *bs, Bool Em /*update offset & size length fields*/ if (baseOffset>0xFFFFFFFF) meta->item_locations->base_offset_size = 8; else if (baseOffset) meta->item_locations->base_offset_size = 4; - + if (maxExtendSize>0xFFFFFFFF) meta->item_locations->length_size = 8; else if (maxExtendSize) meta->item_locations->length_size = 4; @@ -558,11 +558,11 @@ GF_Err DoWrite(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emulation e = stbl_GetSampleSize(writer->mdia->information->sampleTable->SampleSize, writer->sampleNumber, &sampSize); if (e) return e; - //update our chunks. + //update our chunks. force = 0; if (movie->openMode == GF_ISOM_OPEN_WRITE) { offset = sampOffset; - if (predOffset != offset) + if (predOffset != offset) force = 1; } //update our global offset... @@ -633,14 +633,18 @@ GF_Err WriteFlat(MovieWriter *mw, u8 moovFirst, GF_BitStream *bs) begin += 12; } if (movie->brand) { - e = gf_isom_box_size((GF_Box *)movie->brand); if (e) goto exit; - e = gf_isom_box_write((GF_Box *)movie->brand, movie->editFileMap->bs); if (e) goto exit; + e = gf_isom_box_size((GF_Box *)movie->brand); + if (e) goto exit; + e = gf_isom_box_write((GF_Box *)movie->brand, movie->editFileMap->bs); + if (e) goto exit; totSize += movie->brand->size; begin += movie->brand->size; } if (movie->pdin) { - e = gf_isom_box_size((GF_Box *)movie->pdin); if (e) goto exit; - e = gf_isom_box_write((GF_Box *)movie->pdin, movie->editFileMap->bs); if (e) goto exit; + e = gf_isom_box_size((GF_Box *)movie->pdin); + if (e) goto exit; + e = gf_isom_box_write((GF_Box *)movie->pdin, movie->editFileMap->bs); + if (e) goto exit; totSize += movie->pdin->size; begin += movie->pdin->size; } @@ -747,11 +751,11 @@ GF_Err WriteFlat(MovieWriter *mw, u8 moovFirst, GF_BitStream *bs) goto exit; } - //nope, we have to write the moov first. The pb is that + //nope, we have to write the moov first. The pb is that //1 - we don't know its size till the mdat is written //2 - we don't know the ofset at which the mdat will start... //3 - once the mdat is written, the chunkOffset table can have changed... - + if (movie->is_jp2) { gf_bs_write_u32(bs, 12); gf_bs_write_u32(bs, GF_4CC('j','P',' ',' ')); @@ -774,7 +778,7 @@ GF_Err WriteFlat(MovieWriter *mw, u8 moovFirst, GF_BitStream *bs) //note: this will set the size of the mdat e = DoWrite(mw, writers, bs, 1, gf_bs_get_position(bs)); if (e) goto exit; - + firstSize = GetMoovAndMetaSize(movie, writers); //offset = (firstSize > 0xFFFFFFFF ? firstSize + 8 : firstSize) + 8 + (movie->mdat->dataSize > 0xFFFFFFFF ? 8 : 0); offset = firstSize + 8 + (movie->mdat->dataSize > 0xFFFFFFFF ? 8 : 0); @@ -855,7 +859,7 @@ GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 writeGroup = 1; tracksDone = 0; - + //browse each groups while (1) { writeGroup = 1; @@ -876,7 +880,7 @@ GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 if (tmp->isDone || tmp->mdia->information->sampleTable->groupID != curGroupID) continue; //OK, get the current sample in this track - stbl_GetSampleDTS(tmp->mdia->information->sampleTable->TimeToSample, tmp->sampleNumber, &DTS); + stbl_GetSampleDTS(tmp->mdia->information->sampleTable->TimeToSample, tmp->sampleNumber, &DTS); res = TStmp ? DTStmp * tmp->timeScale - DTS * TStmp : 0; if (res < 0) continue; if ((!res) && curTrackPriority <= tmp->mdia->information->sampleTable->trackPriority) continue; @@ -903,7 +907,7 @@ GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 if (e) return e; e = stbl_GetSampleSize(curWriter->mdia->information->sampleTable->SampleSize, curWriter->sampleNumber, &sampSize); if (e) return e; - + //do we actually write, or do we emulate ? if (Emulation) { //are we in the same track ??? If not, force a new chunk when adding this sample @@ -922,7 +926,7 @@ GF_Err DoFullInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 if (curWriter->prev_offset != sampOffset) forceNewChunk = 1; curWriter->prev_offset = sampOffset + sampSize; - //we have a DataRef, so use the offset idicated in sampleToChunk + //we have a DataRef, so use the offset idicated in sampleToChunk //and ChunkOffset tables... e = stbl_SetChunkAndOffset(curWriter->mdia->information->sampleTable, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, sampOffset, 0); if (e) return e; @@ -1018,7 +1022,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul - if (movie->storageMode == GF_ISOM_STORE_TIGHT) + if (movie->storageMode == GF_ISOM_STORE_TIGHT) return DoFullInterleave(mw, writers, bs, Emulation, StartOffset); e = GF_OK; @@ -1048,7 +1052,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul curWriter = NULL; for (i=0 ; i < count; i++) { tmp = (TrackWriter*)gf_list_get(writers, i); - + //is it done writing ? if (tmp->isDone) continue; @@ -1069,9 +1073,9 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul //can this sample fit in our chunk ? if ( ( (DTS - tmp->DTSprev) + tmp->chunkDur) * movie->moov->mvhd->timeScale > movie->interleavingTime * tmp->timeScale - /*drfit check: reject sample if outside our check window*/ - || (drift_inter && chunkLastDTS && ( ((u64)tmp->DTSprev*chunkLastScale) > ((u64)chunkLastDTS*tmp->timeScale)) ) - ) { + /*drfit check: reject sample if outside our check window*/ + || (drift_inter && chunkLastDTS && ( ((u64)tmp->DTSprev*chunkLastScale) > ((u64)chunkLastDTS*tmp->timeScale)) ) + ) { //in case the sample is longer than InterleaveTime if (!tmp->chunkDur) { forceNewChunk = 1; @@ -1085,7 +1089,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul } //OK, we can write this track curWriter = tmp; - + //small check for first 2 samples (DTS = 0 :) if (tmp->sampleNumber == 2 && !tmp->chunkDur) forceNewChunk = 0; @@ -1096,7 +1100,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul if (e) return e; e = stbl_GetSampleSize(curWriter->mdia->information->sampleTable->SampleSize, curWriter->sampleNumber, &sampSize); if (e) return e; - + //do we actually write, or do we emulate ? if (Emulation) { //update our offsets... @@ -1109,7 +1113,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul if (curWriter->prev_offset != sampOffset) forceNewChunk = 1; curWriter->prev_offset = sampOffset + sampSize; - //we have a DataRef, so use the offset idicated in sampleToChunk + //we have a DataRef, so use the offset idicated in sampleToChunk //and ChunkOffset tables... e = stbl_SetChunkAndOffset(curWriter->mdia->information->sampleTable, curWriter->sampleNumber, descIndex, curWriter->stsc, &curWriter->stco, sampOffset, forceNewChunk); if (e) return e; @@ -1137,7 +1141,7 @@ GF_Err DoInterleave(MovieWriter *mw, GF_List *writers, GF_BitStream *bs, u8 Emul chunkLastDTS = curWriter->DTSprev; /*add one interleave window drift - since the "maxDTS" is the previously written one, we will have the following cases: - - sample doesn't fit: post-pone and force new chunk + - sample doesn't fit: post-pone and force new chunk - sample time larger than previous chunk time + interleave: post-pone and force new chunk - otherwise store and track becomes current reference @@ -1287,7 +1291,7 @@ GF_Err WriteToFile(GF_ISOFile *movie) //OK, we need a new bitstream stream = is_stdout ? stdout : gf_f64_open(movie->finalName, "w+b"); - if (!stream) + if (!stream) return GF_IO_ERR; bs = gf_bs_from_file(stream, GF_BITSTREAM_WRITE); if (!bs) { @@ -1315,7 +1319,7 @@ GF_Err WriteToFile(GF_ISOFile *movie) e = WriteFlat(&mw, 0, bs); break; } - + gf_bs_del(bs); if (!is_stdout) fclose(stream); diff --git a/src/isomedia/isom_write.c b/src/isomedia/isom_write.c index 1bdb4a0..dd72ec8 100644 --- a/src/isomedia/isom_write.c +++ b/src/isomedia/isom_write.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -92,7 +92,7 @@ GF_Err AddMovieIOD(GF_MovieBox *moov, u8 isIOD) { GF_Descriptor *od; GF_ObjectDescriptorBox *iods; - + //do we have an IOD ?? If not, create one. if (moov->iods) return GF_OK; @@ -119,7 +119,7 @@ GF_Err gf_isom_add_track_to_root_od(GF_ISOFile *movie, u32 trackNumber) e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; gf_isom_insert_moov(movie); - + if (!movie->moov->iods) AddMovieIOD(movie->moov, 0); if (gf_isom_is_track_in_root_od(movie, trackNumber) == 1) return GF_OK; @@ -325,7 +325,7 @@ GF_Err gf_isom_set_timescale(GF_ISOFile *movie, u32 timeScale) e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; gf_isom_insert_moov(movie); - + movie->moov->mvhd->timeScale = timeScale; movie->interleavingTime = timeScale; return GF_OK; @@ -473,7 +473,7 @@ u32 gf_isom_new_track(GF_ISOFile *movie, u32 trakID, u32 MediaType, u32 TimeScal return 0; } } - + //OK, now create a track... trak = (GF_TrackBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_TRAK); if (!trak) { @@ -501,11 +501,13 @@ u32 gf_isom_new_track(GF_ISOFile *movie, u32 trakID, u32 MediaType, u32 TimeScal //OK, add this media to our track mdia->mediaTrack = trak; - e = trak_AddBox((GF_Box*)trak, (GF_Box *) tkhd); if (e) goto err_exit; - e = trak_AddBox((GF_Box*)trak, (GF_Box *) mdia); if (e) goto err_exit; + e = trak_AddBox((GF_Box*)trak, (GF_Box *) tkhd); + if (e) goto err_exit; + e = trak_AddBox((GF_Box*)trak, (GF_Box *) mdia); + if (e) goto err_exit; tkhd->trackID = trakID; - + //some default properties for Audio, Visual or private tracks switch (MediaType) { case GF_ISOM_MEDIA_VISUAL: @@ -525,9 +527,10 @@ u32 gf_isom_new_track(GF_ISOFile *movie, u32 trakID, u32 MediaType, u32 TimeScal trak->Header->creationTime = trak->Header->modificationTime = now; //OK, add our trak - e = moov_AddBox((GF_Box*)movie->moov, (GF_Box *)trak); if (e) goto err_exit; + e = moov_AddBox((GF_Box*)movie->moov, (GF_Box *)trak); + if (e) goto err_exit; //set the new ID available - if (trakID+1> movie->moov->mvhd->nextTrackID) + if (trakID+1> movie->moov->mvhd->nextTrackID) movie->moov->mvhd->nextTrackID = trakID+1; //and return our track number @@ -544,11 +547,11 @@ err_exit: //Create a new StreamDescription in the file. The URL and URN are used to describe external media GF_EXPORT GF_Err gf_isom_new_mpeg4_description(GF_ISOFile *movie, - u32 trackNumber, - GF_ESD *esd, - char *URLname, - char *URNname, - u32 *outDescriptionIndex) + u32 trackNumber, + GF_ESD *esd, + char *URLname, + char *URNname, + u32 *outDescriptionIndex) { GF_TrackBox *trak; GF_Err e; @@ -557,11 +560,11 @@ GF_Err gf_isom_new_mpeg4_description(GF_ISOFile *movie, e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media || - !esd || !esd->decoderConfig || - !esd->slConfig) return GF_BAD_PARAM; + if (!trak || !trak->Media || + !esd || !esd->decoderConfig || + !esd->slConfig) return GF_BAD_PARAM; //get or create the data ref e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); @@ -703,7 +706,7 @@ GF_Err gf_isom_add_sample_shadow(GF_ISOFile *movie, u32 trackNumber, GF_ISOSampl if (e) return e; data_offset = gf_isom_datamap_get_offset(trak->Media->information->dataHandler); - if (offset_times) sample->DTS += 1; + if (offset_times) sample->DTS += 1; /*REWRITE ANY OD STUFF*/ if (trak->Media->handler->handlerType == GF_ISOM_MEDIA_OD) { @@ -717,7 +720,7 @@ GF_Err gf_isom_add_sample_shadow(GF_ISOFile *movie, u32 trackNumber, GF_ISOSampl if (!e) e = gf_isom_datamap_add_data(trak->Media->information->dataHandler, sample->data, sample->dataLength); } if (e) return e; - if (offset_times) sample->DTS -= 1; + if (offset_times) sample->DTS -= 1; //OK, update duration e = Media_SetDuration(trak); @@ -800,7 +803,7 @@ GF_Err gf_isom_add_sample_reference(GF_ISOFile *movie, u32 trackNumber, u32 Stre e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -1011,7 +1014,7 @@ GF_Err gf_isom_remove_sample(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumbe //remove padding e = stbl_RemovePaddingBits(trak->Media->information->sampleTable, sampleNumber); if (e) return e; - + return SetTrackDuration(trak); } @@ -1028,8 +1031,8 @@ GF_Err gf_isom_set_final_name(GF_ISOFile *movie, char *filename) if (filename) { //we don't allow file overwriting - if ( (movie->openMode == GF_ISOM_OPEN_EDIT) - && movie->fileName && !strcmp(filename, movie->fileName)) + if ( (movie->openMode == GF_ISOM_OPEN_EDIT) + && movie->fileName && !strcmp(filename, movie->fileName)) return GF_BAD_PARAM; if (movie->finalName) gf_free(movie->finalName); movie->finalName = gf_strdup(filename); @@ -1049,10 +1052,10 @@ GF_Err gf_isom_add_desc_to_description(GF_ISOFile *movie, u32 trackNumber, u32 S GF_ESD *esd; GF_TrackReferenceBox *tref; GF_TrackReferenceTypeBox *dpnd; - + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; @@ -1070,19 +1073,19 @@ GF_Err gf_isom_add_desc_to_description(GF_ISOFile *movie, u32 trackNumber, u32 S switch (desc->tag) { case GF_ODF_IPI_PTR_TAG: goto insertIPI; - + default: return gf_odf_desc_add_desc((GF_Descriptor *)esd, desc); } - + insertIPI: if (esd->ipiPtr) { gf_odf_desc_del((GF_Descriptor *) esd->ipiPtr); esd->ipiPtr = NULL; } - ipiD = (GF_IPIPtr *) desc; + ipiD = (GF_IPIPtr *) desc; //find a tref if (!trak->References) { tref = (GF_TrackReferenceBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_TREF); @@ -1187,12 +1190,13 @@ GF_Err gf_isom_set_visual_info(GF_ISOFile *movie, u32 trackNumber, u32 StreamDes case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: ((GF_VisualSampleEntryBox*)entry)->Width = Width; ((GF_VisualSampleEntryBox*)entry)->Height = Height; trak->Header->width = Width<<16; @@ -1240,12 +1244,13 @@ GF_Err gf_isom_set_pixel_aspect_ratio(GF_ISOFile *movie, u32 trackNumber, u32 St case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_BAD_PARAM; @@ -1367,7 +1372,7 @@ GF_Err gf_isom_set_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditTime //get the prev entry to this startTime if any i=0; while ((ent = (GF_EdtsEntry *)gf_list_enum(elst->entryList, &i))) { - if ( (startTime <= EditTime) && (startTime + ent->segmentDuration > EditTime) ) + if ( (startTime <= EditTime) && (startTime + ent->segmentDuration > EditTime) ) goto found; startTime += ent->segmentDuration; } @@ -1379,11 +1384,11 @@ GF_Err gf_isom_set_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditTime gf_list_add(elst->entryList, newEnt); return SetTrackDuration(trak); } - + startTime -= ent->segmentDuration; found: - + //if same time, we erase the current one... if (startTime == EditTime) { ent->segmentDuration = EditDuration; @@ -1616,14 +1621,18 @@ GF_Err gf_isom_remove_track(GF_ISOFile *movie, u32 trackNumber) } } - //remove the track ref from any "tref" box in all tracks (except the one to delete ;) + //remove the track ref from any "tref" box in all tracks, except the one to delete + //note that we don't touch scal references, as we don't want to rewrite AVC/HEVC samples ... i=0; while ((trak = (GF_TrackBox *)gf_list_enum(movie->moov->trackList, &i))) { if (trak == the_trak) continue; if (! trak->References || ! gf_list_count(trak->References->other_boxes)) continue; - + j=0; while ((tref = (GF_TrackReferenceTypeBox *)gf_list_enum(trak->References->other_boxes, &j))) { + if (tref->reference_type==GF_4CC('s','c','a','l')) + continue; + found = 0; for (k=0; ktrackIDCount; k++) { if (tref->trackIDs[k] == the_trak->Header->trackID) found++; @@ -1658,7 +1667,7 @@ GF_Err gf_isom_remove_track(GF_ISOFile *movie, u32 trackNumber) //delete the track gf_isom_box_del((GF_Box *)the_trak); - + /*update next track ID*/ movie->moov->mvhd->nextTrackID = 0; i=0; @@ -1677,7 +1686,7 @@ GF_Err gf_isom_set_copyright(GF_ISOFile *movie, const char *threeCharCode, char GF_CopyrightBox *ptr; GF_UserDataMap *map; u32 count, i; - + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; @@ -1690,7 +1699,7 @@ GF_Err gf_isom_set_copyright(GF_ISOFile *movie, const char *threeCharCode, char if (e) return e; } map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_CPRT, NULL); - + if (map) { //try to find one in our language... count = gf_list_count(map->other_boxes); @@ -1718,7 +1727,7 @@ GF_Err gf_isom_add_chapter(GF_ISOFile *movie, u32 trackNumber, u64 timestamp, ch { GF_Err e; GF_ChapterListBox *ptr; - u32 i, count; + u32 i, count; GF_ChapterEntry *ce; GF_UserDataBox *udta; GF_UserDataMap *map; @@ -1763,7 +1772,7 @@ GF_Err gf_isom_add_chapter(GF_ISOFile *movie, u32 trackNumber, u64 timestamp, ch ce->start_time = timestamp * 10000L; ce->name = name ? gf_strdup(name) : NULL; - /*insert in order*/ + /*insert in order*/ count = gf_list_count(ptr->list); for (i=0; ilist, i); @@ -1812,7 +1821,7 @@ GF_Err gf_isom_remove_chapter(GF_ISOFile *movie, u32 trackNumber, u32 index) if (!map) return GF_OK; ptr = (GF_ChapterListBox*)gf_list_get(map->other_boxes, 0); if (!ptr) return GF_OK; - + if (index) { ce = (GF_ChapterEntry *)gf_list_get(ptr->list, index-1); if (!ce) return GF_BAD_PARAM; @@ -1841,7 +1850,7 @@ GF_Err gf_isom_remove_copyright(GF_ISOFile *movie, u32 index) GF_CopyrightBox *ptr; GF_UserDataMap *map; u32 count; - + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; gf_isom_insert_moov(movie); @@ -1886,7 +1895,7 @@ GF_Err gf_isom_set_watermark(GF_ISOFile *movie, bin128 UUID, u8* data, u32 lengt e = moov_AddBox((GF_Box*)movie->moov, gf_isom_box_new(GF_ISOM_BOX_TYPE_UDTA)); if (e) return e; } - + map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_UUID, (bin128 *) & UUID); if (map) { ptr = (GF_UnknownUUIDBox *)gf_list_get(map->other_boxes, 0); @@ -1934,7 +1943,7 @@ u8 gf_isom_get_storage_mode(GF_ISOFile *movie) -//use a compact track version for sample size. This is not usually recommended +//use a compact track version for sample size. This is not usually recommended //except for speech codecs where the track has a lot of small samples //compaction is done automatically while writing based on the track's sample sizes GF_Err gf_isom_use_compact_size(GF_ISOFile *movie, u32 trackNumber, u8 CompactionOn) @@ -1949,13 +1958,13 @@ GF_Err gf_isom_use_compact_size(GF_ISOFile *movie, u32 trackNumber, u8 Compactio trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; - + if (!trak->Media || !trak->Media->information - || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->SampleSize) + || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->SampleSize) return GF_ISOM_INVALID_FILE; stsz = trak->Media->information->sampleTable->SampleSize; - + //switch to regular table if (!CompactionOn) { if (stsz->type == GF_ISOM_BOX_TYPE_STSZ) return GF_OK; @@ -2005,7 +2014,7 @@ GF_Err gf_isom_set_brand_info(GF_ISOFile *movie, u32 MajorBrand, u32 MinorVersio u32 i, *p; if (!MajorBrand) return GF_BAD_PARAM; - + #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (! (movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY)) { GF_Err e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); @@ -2020,7 +2029,7 @@ GF_Err gf_isom_set_brand_info(GF_ISOFile *movie, u32 MajorBrand, u32 MinorVersio movie->brand = (GF_FileTypeBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_FTYP); gf_list_add(movie->TopBoxes, movie->brand); } - + movie->brand->majorBrand = MajorBrand; movie->brand->minorVersion = MinorVersion; @@ -2050,14 +2059,14 @@ GF_EXPORT GF_Err gf_isom_modify_alternate_brand(GF_ISOFile *movie, u32 Brand, u8 AddIt) { u32 i, k, *p; - + if (!Brand) return GF_BAD_PARAM; #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (! (movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY)) { GF_Err e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + e = CheckNoData(movie); if (e) return e; } @@ -2119,12 +2128,12 @@ found: GF_Err gf_isom_reset_alt_brands(GF_ISOFile *movie) { u32 *p; - + #ifndef GPAC_DISABLE_ISOM_FRAGMENTS if (! (movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY)) { GF_Err e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + e = CheckNoData(movie); if (e) return e; } @@ -2153,7 +2162,7 @@ GF_Err gf_isom_set_sample_padding_bits(GF_ISOFile *movie, u32 trackNumber, u32 s trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || NbBits > 7) return GF_BAD_PARAM; - + //set Padding info return stbl_SetPaddingBits(trak->Media->information->sampleTable, sampleNumber, NbBits); } @@ -2171,7 +2180,7 @@ GF_Err gf_isom_remove_user_data_item(GF_ISOFile *movie, u32 trackNumber, u32 Use e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + if (UserDataType == GF_ISOM_BOX_TYPE_UUID) UserDataType = 0; memset(t, 1, 16); @@ -2198,7 +2207,7 @@ found: if (UserDataIndex > gf_list_count(map->other_boxes) ) return GF_BAD_PARAM; //delete the box a = (GF_Box*)gf_list_get(map->other_boxes, UserDataIndex-1); - + gf_list_rem(map->other_boxes, UserDataIndex-1); gf_isom_box_del(a); @@ -2223,7 +2232,7 @@ GF_Err gf_isom_remove_user_data(GF_ISOFile *movie, u32 trackNumber, u32 UserData e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + if (UserDataType == GF_ISOM_BOX_TYPE_UUID) UserDataType = 0; memset(t, 1, 16); @@ -2263,7 +2272,7 @@ GF_Err gf_isom_add_user_data(GF_ISOFile *movie, u32 trackNumber, u32 UserDataTyp e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + if (UserDataType == GF_ISOM_BOX_TYPE_UUID) UserDataType = 0; if (trackNumber) { @@ -2350,7 +2359,7 @@ GF_Err gf_isom_clone_pl_indications(GF_ISOFile *orig, GF_ISOFile *dest) if (!orig->moov->iods || !orig->moov->iods->descriptor) return GF_OK; if (orig->moov->iods->descriptor->tag != GF_ODF_ISOM_IOD_TAG) return GF_OK; - AddMovieIOD(dest->moov, 1); + AddMovieIOD(dest->moov, 1); gf_odf_desc_del((GF_Descriptor *)dest->moov->iods->descriptor); gf_odf_desc_copy((GF_Descriptor *)orig->moov->iods->descriptor, (GF_Descriptor **)&dest->moov->iods->descriptor); iod_d = (GF_IsomInitialObjectDescriptor *) dest->moov->iods->descriptor; @@ -2398,7 +2407,7 @@ GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool cl GF_Err e; u32 i; GF_Box *box; - + e = CanAccessMovie(dest_file, GF_ISOM_OPEN_WRITE); if (e) return e; @@ -2437,7 +2446,7 @@ GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool cl dest_file->moov->mvex = NULL; } - if (clone_tracks) { + if (clone_tracks) { for (i=0; imoov->trackList); i++) { GF_TrackBox *trak = gf_list_get( orig_file->moov->trackList, i); if (!trak) continue; @@ -2446,7 +2455,7 @@ GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool cl if (e) return e; } } - if (iods) + if (iods) gf_isom_clone_box((GF_Box *)orig_file->moov->iods, (GF_Box **)dest_file->moov->iods); } else { dest_file->moov->mvhd->nextTrackID = 1; @@ -2470,30 +2479,30 @@ GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool cl i=0; while ((box = (GF_Box*)gf_list_get(orig_file->TopBoxes, i++))) { switch(box->type) { - case GF_ISOM_BOX_TYPE_MOOV: - case GF_ISOM_BOX_TYPE_META: - case GF_ISOM_BOX_TYPE_MDAT: - case GF_ISOM_BOX_TYPE_FTYP: - case GF_ISOM_BOX_TYPE_PDIN: + case GF_ISOM_BOX_TYPE_MOOV: + case GF_ISOM_BOX_TYPE_META: + case GF_ISOM_BOX_TYPE_MDAT: + case GF_ISOM_BOX_TYPE_FTYP: + case GF_ISOM_BOX_TYPE_PDIN: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS - case GF_ISOM_BOX_TYPE_STYP: - case GF_ISOM_BOX_TYPE_SIDX: - case GF_ISOM_BOX_TYPE_MOOF: + case GF_ISOM_BOX_TYPE_STYP: + case GF_ISOM_BOX_TYPE_SIDX: + case GF_ISOM_BOX_TYPE_MOOF: #endif - case GF_4CC('j','P',' ',' '): - break; - - case GF_ISOM_BOX_TYPE_PSSH: - if (!keep_pssh) - break; + case GF_4CC('j','P',' ',' '): + break; - default: - { - GF_Box *box2 = NULL; - gf_isom_clone_box(box, &box2); - gf_list_add(dest_file->TopBoxes, box2); - } + case GF_ISOM_BOX_TYPE_PSSH: + if (!keep_pssh) break; + + default: + { + GF_Box *box2 = NULL; + gf_isom_clone_box(box, &box2); + gf_list_add(dest_file->TopBoxes, box2); + } + break; } } @@ -2513,7 +2522,7 @@ GF_Err gf_isom_clone_track(GF_ISOFile *orig_file, u32 orig_track, GF_ISOFile *de GF_Err e; GF_SampleEntryBox *entry; GF_SampleTableBox *stbl, *stbl_temp; - + e = CanAccessMovie(dest_file, GF_ISOM_OPEN_WRITE); if (e) return e; gf_isom_insert_moov(dest_file); @@ -2600,7 +2609,7 @@ GF_Err gf_isom_clone_track(GF_ISOFile *orig_file, u32 orig_track, GF_ISOFile *de *dest_track = gf_list_count(dest_file->moov->trackList); - if (dest_file->moov->mvhd->nextTrackID<= new_tk->Header->trackID) + if (dest_file->moov->mvhd->nextTrackID<= new_tk->Header->trackID) dest_file->moov->mvhd->nextTrackID = new_tk->Header->trackID+1; return GF_OK; @@ -2642,7 +2651,7 @@ GF_Err gf_isom_clone_sample_description(GF_ISOFile *the_file, u32 trackNumber, G GF_Box *entry; GF_Err e; u32 dataRefIndex; - + e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; @@ -2683,12 +2692,12 @@ GF_Err gf_isom_clone_sample_description(GF_ISOFile *the_file, u32 trackNumber, G e = gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, entry); *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); - /*also clone track w/h info*/ + /*also clone track w/h info*/ if (gf_isom_get_media_type(the_file, trackNumber) == GF_ISOM_MEDIA_VISUAL) { gf_isom_set_visual_info(the_file, trackNumber, (*outDescriptionIndex), ((GF_VisualSampleEntryBox*)entry)->Width, ((GF_VisualSampleEntryBox*)entry)->Height); } return e; - + exit: gf_isom_box_del(entry); return e; @@ -2703,7 +2712,7 @@ GF_Err gf_isom_new_generic_sample_description(GF_ISOFile *movie, u32 trackNumber e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !udesc) return GF_BAD_PARAM; @@ -2824,7 +2833,7 @@ GF_Err gf_isom_change_generic_sample_description(GF_ISOFile *movie, u32 trackNum e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !StreamDescriptionIndex) return GF_BAD_PARAM; @@ -3025,7 +3034,7 @@ GF_Err gf_isom_set_track_id(GF_ISOFile *movie, u32 trackNumber, u32 trackID) } } } - + /*and update IOD if any*/ if (movie->moov->iods && movie->moov->iods->descriptor) { GF_ES_ID_Inc *inc; @@ -3050,7 +3059,7 @@ GF_Err gf_isom_rewrite_track_dependencies(GF_ISOFile *movie, u32 trackNumber) trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; - if (!trak->References) + if (!trak->References) return GF_OK; i=0; @@ -3087,7 +3096,7 @@ GF_Err gf_isom_remove_cts_info(GF_ISOFile *the_file, u32 trackNumber) GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; if (!trak->Media->information->sampleTable->CompositionOffset) return GF_OK; - + gf_isom_box_del((GF_Box *)trak->Media->information->sampleTable->CompositionOffset); trak->Media->information->sampleTable->CompositionOffset = NULL; return GF_OK; @@ -3247,7 +3256,7 @@ GF_Err gf_isom_load_movie_config(GF_ISOFile *movie) if (len) { u32 k; trak->name = (char*)gf_malloc(sizeof(char)*(len+1)); - for (k=0;kname[k] = gf_bs_read_u8(bs); + for (k=0; kname[k] = gf_bs_read_u8(bs); trak->name[k] = 0; } gf_bs_del(bs); @@ -3309,7 +3318,7 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index GF_ESD *esd1, *esd2; GF_Box *a; Bool ret, need_memcmp; - + /*get orig sample desc and clone it*/ trak1 = gf_isom_get_track_from_file(f1, tk1); if (!trak1 || !trak1->Media) return 0; @@ -3352,6 +3361,8 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index if (!esd1->decoderConfig->decoderSpecificInfo || !esd2->decoderConfig->decoderSpecificInfo) continue; if (memcmp(esd1->decoderConfig->decoderSpecificInfo->data, esd2->decoderConfig->decoderSpecificInfo->data, sizeof(char)*esd1->decoderConfig->decoderSpecificInfo->dataLength)!=0) return 0; break; + case GF_ISOM_BOX_TYPE_HVT1: + return 1; case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: @@ -3371,6 +3382,8 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); if (avc1->hevc_config) a = (GF_Box *) avc1->hevc_config; + else if (avc1->shvc_config) + a = (GF_Box *) avc1->shvc_config; else if (avc1->svc_config) a = (GF_Box *) avc1->svc_config; else @@ -3383,6 +3396,8 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); if (avc2->hevc_config) a = (GF_Box *) avc2->hevc_config; + else if (avc2->shvc_config) + a = (GF_Box *) avc2->shvc_config; else if (avc2->svc_config) a = (GF_Box *) avc2->svc_config; else @@ -3391,7 +3406,7 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index gf_isom_box_write(a, bs); gf_bs_get_content(bs, &data2, &data2_size); gf_bs_del(bs); - + ret = 0; if (data1_size == data2_size) { ret = (memcmp(data1, data2, sizeof(char)*data1_size)==0) ? 1 : 0; @@ -3400,60 +3415,60 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index gf_free(data2); return ret; } - break; + break; case GF_ISOM_BOX_TYPE_LSR1: { GF_LASeRSampleEntryBox *lsr1 = (GF_LASeRSampleEntryBox *)ent1; GF_LASeRSampleEntryBox *lsr2 = (GF_LASeRSampleEntryBox *)ent2; - if (lsr1->lsr_config && lsr2->lsr_config - && lsr1->lsr_config->hdr && lsr2->lsr_config->hdr - && (lsr1->lsr_config->hdr_size==lsr2->lsr_config->hdr_size) - && !memcmp(lsr1->lsr_config->hdr, lsr2->lsr_config->hdr, lsr2->lsr_config->hdr_size) - ) { + if (lsr1->lsr_config && lsr2->lsr_config + && lsr1->lsr_config->hdr && lsr2->lsr_config->hdr + && (lsr1->lsr_config->hdr_size==lsr2->lsr_config->hdr_size) + && !memcmp(lsr1->lsr_config->hdr, lsr2->lsr_config->hdr, lsr2->lsr_config->hdr_size) + ) { return 1; } return 0; } - break; + break; case GF_ISOM_BOX_TYPE_WVTT: - { - GF_WebVTTSampleEntryBox *wvtt1 = (GF_WebVTTSampleEntryBox *)ent1; - GF_WebVTTSampleEntryBox *wvtt2 = (GF_WebVTTSampleEntryBox *)ent2; - if (wvtt1->config && wvtt2->config && - (wvtt1->config->string && wvtt1->config->string && !strcmp(wvtt1->config->string, wvtt2->config->string))) { - return 1; - } - return 0; + { + GF_WebVTTSampleEntryBox *wvtt1 = (GF_WebVTTSampleEntryBox *)ent1; + GF_WebVTTSampleEntryBox *wvtt2 = (GF_WebVTTSampleEntryBox *)ent2; + if (wvtt1->config && wvtt2->config && + (wvtt1->config->string && wvtt1->config->string && !strcmp(wvtt1->config->string, wvtt2->config->string))) { + return 1; } - break; + return 0; + } + break; case GF_ISOM_BOX_TYPE_STPP: - { - GF_XMLSubtitleSampleEntryBox *stpp1 = (GF_XMLSubtitleSampleEntryBox *)ent1; - GF_XMLSubtitleSampleEntryBox *stpp2 = (GF_XMLSubtitleSampleEntryBox *)ent2; - if (stpp1->xmlnamespace && stpp2->xmlnamespace && !strcmp(stpp1->xmlnamespace, stpp2->xmlnamespace)) { - return 1; - } - return 0; + { + GF_XMLSubtitleSampleEntryBox *stpp1 = (GF_XMLSubtitleSampleEntryBox *)ent1; + GF_XMLSubtitleSampleEntryBox *stpp2 = (GF_XMLSubtitleSampleEntryBox *)ent2; + if (stpp1->xmlnamespace && stpp2->xmlnamespace && !strcmp(stpp1->xmlnamespace, stpp2->xmlnamespace)) { + return 1; } - break; + return 0; + } + break; case GF_ISOM_BOX_TYPE_SBTT: - { - return 0; - } - break; + { + return 0; + } + break; case GF_ISOM_BOX_TYPE_STSE: - { - GF_SimpleTextSampleEntryBox *stse1 = (GF_SimpleTextSampleEntryBox *)ent1; - GF_SimpleTextSampleEntryBox *stse2 = (GF_SimpleTextSampleEntryBox *)ent2; - if (stse1->mime_type && stse2->mime_type && - ( (!stse1->config && !stse2->config) || - (stse1->config && stse2->config && stse1->config->string && stse2->config->string && - !strcmp(stse1->config->string, stse2->config->string)))) { - return 1; - } - return 0; + { + GF_SimpleTextSampleEntryBox *stse1 = (GF_SimpleTextSampleEntryBox *)ent1; + GF_SimpleTextSampleEntryBox *stse2 = (GF_SimpleTextSampleEntryBox *)ent2; + if (stse1->mime_type && stse2->mime_type && + ( (!stse1->config && !stse2->config) || + (stse1->config && stse2->config && stse1->config->string && stse2->config->string && + !strcmp(stse1->config->string, stse2->config->string)))) { + return 1; } - break; + return 0; + } + break; } if (sdesc_index1 && sdesc_index2) break; @@ -3476,7 +3491,7 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index gf_isom_box_write(a, bs); gf_bs_get_content(bs, &data2, &data2_size); gf_bs_del(bs); - + if (data1_size == data2_size) { ret = (memcmp(data1, data2, sizeof(char)*data1_size)==0) ? 1 : 0; } @@ -3733,7 +3748,7 @@ GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const cha gf_f64_seek(f, 0, SEEK_END); size = gf_f64_tell(f); gf_f64_seek(f, 0, SEEK_SET); - if (3!=fread(BOM, sizeof(char), 3, f)){ + if (3!=fread(BOM, sizeof(char), 3, f)) { fclose(f); return GF_CORRUPTED_DATA; } @@ -3764,18 +3779,30 @@ GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const cha } /*UTF8 2 bytes char */ else if ( (szOrig[i] & 0xe0) == 0xc0) { - szLine[j] = szOrig[i]; i++; j++; + szLine[j] = szOrig[i]; + i++; + j++; } /*UTF8 3 bytes char */ else if ( (szOrig[i] & 0xf0) == 0xe0) { - szLine[j] = szOrig[i]; i++; j++; - szLine[j] = szOrig[i]; i++; j++; + szLine[j] = szOrig[i]; + i++; + j++; + szLine[j] = szOrig[i]; + i++; + j++; } /*UTF8 4 bytes char */ else if ( (szOrig[i] & 0xf8) == 0xf0) { - szLine[j] = szOrig[i]; i++; j++; - szLine[j] = szOrig[i]; i++; j++; - szLine[j] = szOrig[i]; i++; j++; + szLine[j] = szOrig[i]; + i++; + j++; + szLine[j] = szOrig[i]; + i++; + j++; + szLine[j] = szOrig[i]; + i++; + j++; } } szLine[j] = szOrig[i]; @@ -3871,7 +3898,7 @@ GF_Err gf_isom_remove_uuid(GF_ISOFile *movie, u32 trackNumber, bin128 UUID) if (!movie) return GF_BAD_PARAM; list = movie->moov->other_boxes; } - + count = list ? gf_list_count(list) : 0; for (i=0; imoov->other_boxes) movie->moov->other_boxes = gf_list_new(); list = movie->moov->other_boxes; } - + GF_SAFEALLOC(uuid, GF_UnknownUUIDBox); uuid->type = GF_ISOM_BOX_TYPE_UUID; memcpy(uuid->uuid, UUID, sizeof(bin128)); @@ -3982,7 +4009,7 @@ GF_Err gf_isom_apple_set_tag(GF_ISOFile *mov, u32 tag, const char *data, u32 dat info->data->dataSize = data_len; info->data->data = (char*)gf_malloc(sizeof(char)*data_len); memcpy(info->data->data , data, sizeof(char)*data_len); - } + } else if (data_len && (tag==GF_ISOM_ITUNE_GENRE)) { info = (GF_ListItemBox *)gf_isom_box_new(btype); if (info == NULL) return GF_OUT_OF_MEM; @@ -4042,7 +4069,7 @@ GF_Err gf_isom_set_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u3 } else { alternateGroupID = trak->Header->alternate_group; } - } + } if (!alternateGroupID) { /*there is a function for this ....*/ if (trak->Header->alternate_group) return GF_BAD_PARAM; @@ -4050,7 +4077,7 @@ GF_Err gf_isom_set_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u3 } if (is_switch_group) { - u32 i=0; + u32 i=0; while (i< gf_isom_get_track_count(movie) ) { //locate first available ID GF_TrackBox *a_trak = gf_isom_get_track_from_file(movie, i+1); @@ -4068,7 +4095,7 @@ GF_Err gf_isom_set_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u3 if (a_trak->Header->alternate_group != alternateGroupID) return GF_BAD_PARAM; } } else { - if (tsel->switchGroup && (tsel->switchGroup>=next_switch_group_id) ) + if (tsel->switchGroup && (tsel->switchGroup>=next_switch_group_id) ) next_switch_group_id = tsel->switchGroup; } } @@ -4080,7 +4107,7 @@ GF_Err gf_isom_set_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u3 if (! *switchGroupID) *switchGroupID = next_switch_group_id+1; } - + trak->Header->alternate_group = alternateGroupID; tsel = NULL; @@ -4141,7 +4168,7 @@ GF_Err gf_isom_reset_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, alternateGroupID = trak->Header->alternate_group; if (reset_all_group) { - u32 i=0; + u32 i=0; while (i< gf_isom_get_track_count(movie) ) { //locate first available ID GF_TrackBox *a_trak = gf_isom_get_track_from_file(movie, i+1); @@ -4158,7 +4185,7 @@ GF_Err gf_isom_reset_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, GF_EXPORT GF_Err gf_isom_reset_switch_parameters(GF_ISOFile *movie) { - u32 i=0; + u32 i=0; while (i< gf_isom_get_track_count(movie) ) { //locate first available ID GF_TrackBox *a_trak = gf_isom_get_track_from_file(movie, i+1); @@ -4177,14 +4204,14 @@ GF_Err gf_isom_timed_meta_data_config_new(GF_ISOFile *movie, u32 trackNumber, Bo e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !mime_or_namespace) return GF_BAD_PARAM; if (trak->Media->handler->handlerType==GF_ISOM_MEDIA_META) return GF_BAD_PARAM; - + //get or create the data ref e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); if (e) return e; @@ -4217,11 +4244,11 @@ GF_Err gf_isom_add_subsample(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, track); if (!trak || !trak->Media || !trak->Media->information->sampleTable) return GF_BAD_PARAM; - + if (!trak->Media->information->sampleTable->SubSamples) { trak->Media->information->sampleTable->SubSamples = (GF_SubSampleInformationBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_SUBS); sub_samples = trak->Media->information->sampleTable->SubSamples; @@ -4251,18 +4278,19 @@ GF_Err gf_isom_set_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptio if (!entry ) return GF_BAD_PARAM; switch (entry->type) { case GF_ISOM_BOX_TYPE_MP4V: - case GF_ISOM_BOX_TYPE_AVC1: + case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_ENCV: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: break; default: return GF_BAD_PARAM; @@ -4280,7 +4308,7 @@ GF_Err gf_isom_set_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptio if (!rvc_predefined) { e = gf_isom_set_meta_type(movie, 0, track, GF_4CC('r','v','c','i')); if (e) return e; - gf_isom_modify_alternate_brand(movie, GF_ISOM_BRAND_ISO2, 1); + gf_isom_modify_alternate_brand(movie, GF_ISOM_BRAND_ISO2, 1); e = gf_isom_add_meta_item_memory(movie, 0, track, "rvcconfig.xml", 0, mime, NULL, data, size); if (e) return e; entry->rvcc->rvc_meta_idx = gf_isom_get_meta_item_count(movie, 0, track); @@ -4370,15 +4398,11 @@ static GF_Err gf_isom_add_sample_group_entry(GF_List *sampleGroups, u32 sample_n } -static GF_Err gf_isom_set_sample_group_info_ex(GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf, u32 sample_number, u32 grouping_type, void *udta, void *(*sg_create_entry)(void *udta), Bool (*sg_compare_entry)(void *udta, void *entry)) +static GF_SampleGroupDescriptionBox *get_sgdp(GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf, u32 grouping_type) { GF_List *groupList; - void *entry; - GF_SampleGroupDescriptionBox *sgdesc = NULL; - u32 i, count, entry_idx; - - if (!stbl && !traf) return GF_BAD_PARAM; - + GF_SampleGroupDescriptionBox *sgdesc=NULL; + u32 count, i; /*look in stbl or traf for sample sampleGroupsDescription*/ if (traf) { if (!traf->sampleGroupsDescription) @@ -4401,6 +4425,21 @@ static GF_Err gf_isom_set_sample_group_info_ex(GF_SampleTableBox *stbl, GF_Track sgdesc->grouping_type = grouping_type; gf_list_add(groupList, sgdesc); } + return sgdesc; +} + +static GF_Err gf_isom_set_sample_group_info_ex(GF_SampleTableBox *stbl, GF_TrackFragmentBox *traf, u32 sample_number, u32 grouping_type, void *udta, void *(*sg_create_entry)(void *udta), Bool (*sg_compare_entry)(void *udta, void *entry)) +{ + GF_List *groupList; + void *entry; + GF_SampleGroupDescriptionBox *sgdesc = NULL; + u32 i, entry_idx; + + if (!stbl && !traf) return GF_BAD_PARAM; + + sgdesc = get_sgdp(stbl, traf, grouping_type); + if (!sgdesc) return GF_OUT_OF_MEM; + entry = NULL; for (i=0; igroup_descriptions); i++) { entry = gf_list_get(sgdesc->group_descriptions, i); @@ -4445,6 +4484,69 @@ static GF_Err gf_isom_set_sample_group_info(GF_ISOFile *movie, u32 track, u32 sa return gf_isom_set_sample_group_info_ex(trak->Media->information->sampleTable, NULL, sample_number, grouping_type, udta, sg_create_entry, sg_compare_entry); } + +GF_EXPORT +GF_Err gf_isom_add_sample_group_info(GF_ISOFile *movie, u32 track, u32 grouping_type, void *data, u32 data_size, Bool is_default, u32 *sampleGroupDescriptionIndex) +{ + GF_Err e; + GF_TrackBox *trak; + GF_DefaultSampleGroupDescriptionEntry *entry; + GF_SampleGroupDescriptionBox *sgdesc = NULL; + + if (sampleGroupDescriptionIndex) *sampleGroupDescriptionIndex = 0; + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return e; + + trak = gf_isom_get_track_from_file(movie, track); + if (!trak) return GF_BAD_PARAM; + + + sgdesc = get_sgdp(trak->Media->information->sampleTable, NULL, grouping_type); + if (!sgdesc) return GF_OUT_OF_MEM; + + GF_SAFEALLOC(entry, GF_DefaultSampleGroupDescriptionEntry); + if (!entry) return GF_OUT_OF_MEM; + entry->data = gf_malloc(sizeof(char) * data_size); + if (!entry->data) { + gf_free(entry); + return GF_OUT_OF_MEM; + } + entry->length = data_size; + memcpy(entry->data, data, sizeof(char) * data_size); + e = gf_list_add(sgdesc->group_descriptions, entry); + if (e) { + gf_free(entry->data); + gf_free(entry); + return e; + } + + if (is_default) { + sgdesc->default_description_index = 1 + gf_list_find(sgdesc->group_descriptions, entry); + sgdesc->version = 2; + } + if (sampleGroupDescriptionIndex) *sampleGroupDescriptionIndex = 1 + gf_list_find(sgdesc->group_descriptions, entry); + + return GF_OK; +} + +GF_Err gf_isom_add_sample_info(GF_ISOFile *movie, u32 track, u32 sample_number, u32 grouping_type, u32 sampleGroupDescriptionIndex) +{ + GF_Err e; + GF_TrackBox *trak; + GF_List *groupList; + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return e; + + trak = gf_isom_get_track_from_file(movie, track); + if (!trak) return GF_BAD_PARAM; + + if (!trak->Media->information->sampleTable->sampleGroups) + trak->Media->information->sampleTable->sampleGroups = gf_list_new(); + + groupList = trak->Media->information->sampleTable->sampleGroups; + return gf_isom_add_sample_group_entry(groupList, sample_number, grouping_type, sampleGroupDescriptionIndex); +} + void *sg_rap_create_entry(void *udta) { GF_VisualRandomAccessEntry *entry; @@ -4523,7 +4625,7 @@ Bool sg_encryption_compare_entry(void *udta, void *entry) GF_Err gf_isom_copy_sample_group_entry_to_traf(GF_TrackFragmentBox *traf, GF_SampleTableBox *stbl, u32 grouping_type, u32 sampleGroupDescriptionIndex, Bool sgpd_in_traf) { if (sgpd_in_traf) { - void *entry = NULL; + void *entry = NULL; u32 i, count; GF_SampleGroupDescriptionBox *sgdesc = NULL; GF_BitStream *bs; @@ -4541,35 +4643,35 @@ GF_Err gf_isom_copy_sample_group_entry_to_traf(GF_TrackFragmentBox *traf, GF_Sam entry = gf_list_get(sgdesc->group_descriptions, sampleGroupDescriptionIndex-1); if (!entry) return GF_BAD_PARAM; - + switch (grouping_type) { - case GF_4CC( 'r', 'a', 'p', ' ' ): - { - char udta[2]; - bs = gf_bs_new(udta, 2*sizeof(char), GF_BITSTREAM_WRITE); - gf_bs_write_u8(bs, ((GF_VisualRandomAccessEntry *)entry)->num_leading_samples_known); - gf_bs_write_u8(bs, ((GF_VisualRandomAccessEntry *)entry)->num_leading_samples); - return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_rap_create_entry, sg_rap_compare_entry); - } - case GF_4CC( 'r', 'o', 'l', 'l' ): - { - char udta[2]; - bs = gf_bs_new(udta, 2*sizeof(char), GF_BITSTREAM_WRITE); - gf_bs_write_u16(bs, ((GF_RollRecoveryEntry *)entry)->roll_distance); - return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_roll_create_entry, sg_roll_compare_entry); - } - case GF_4CC( 's', 'e', 'i', 'g' ): - { - char udta[20]; - bs = gf_bs_new(udta, 20*sizeof(char), GF_BITSTREAM_WRITE); - gf_bs_write_u24(bs, ((GF_CENCSampleEncryptionGroupEntry *)entry)->IsEncrypted); - gf_bs_write_u8(bs, ((GF_CENCSampleEncryptionGroupEntry *)entry)->IV_size); - gf_bs_write_data(bs, (char *) ((GF_CENCSampleEncryptionGroupEntry *)entry)->KID, 16); - gf_bs_del(bs); - return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_encryption_create_entry, sg_encryption_compare_entry); - } - default: - return GF_BAD_PARAM; + case GF_4CC( 'r', 'a', 'p', ' ' ): + { + char udta[2]; + bs = gf_bs_new(udta, 2*sizeof(char), GF_BITSTREAM_WRITE); + gf_bs_write_u8(bs, ((GF_VisualRandomAccessEntry *)entry)->num_leading_samples_known); + gf_bs_write_u8(bs, ((GF_VisualRandomAccessEntry *)entry)->num_leading_samples); + return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_rap_create_entry, sg_rap_compare_entry); + } + case GF_4CC( 'r', 'o', 'l', 'l' ): + { + char udta[2]; + bs = gf_bs_new(udta, 2*sizeof(char), GF_BITSTREAM_WRITE); + gf_bs_write_u16(bs, ((GF_RollRecoveryEntry *)entry)->roll_distance); + return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_roll_create_entry, sg_roll_compare_entry); + } + case GF_4CC( 's', 'e', 'i', 'g' ): + { + char udta[20]; + bs = gf_bs_new(udta, 20*sizeof(char), GF_BITSTREAM_WRITE); + gf_bs_write_u24(bs, ((GF_CENCSampleEncryptionGroupEntry *)entry)->IsEncrypted); + gf_bs_write_u8(bs, ((GF_CENCSampleEncryptionGroupEntry *)entry)->IV_size); + gf_bs_write_data(bs, (char *) ((GF_CENCSampleEncryptionGroupEntry *)entry)->KID, 16); + gf_bs_del(bs); + return gf_isom_set_sample_group_info_ex(NULL, traf, 0, grouping_type, udta, sg_encryption_create_entry, sg_encryption_compare_entry); + } + default: + return GF_BAD_PARAM; } } @@ -4604,7 +4706,7 @@ static GF_Err gf_isom_set_ctts_v1(GF_ISOFile *file, u32 track, GF_TrackBox *trak ctts = trak->Media->information->sampleTable->CompositionOffset; shift = ctts->entries[0].decodingOffset; leastCTTS = 0; - greatestCTTS = 0; + greatestCTTS = 0; for (i=0; inb_entries; i++) { ctts->entries[i].decodingOffset -= shift; if ((s32)ctts->entries[i].decodingOffset < leastCTTS) @@ -4640,8 +4742,8 @@ static GF_Err gf_isom_set_ctts_v0(GF_ISOFile *file, GF_TrackBox *trak) GF_CompositionToDecodeBox *cslg; ctts = trak->Media->information->sampleTable->CompositionOffset; - - if (!trak->Media->information->sampleTable->CompositionToDecode) + + if (!trak->Media->information->sampleTable->CompositionToDecode) { shift = 0; for (i=0; inb_entries; i++) { diff --git a/src/isomedia/media.c b/src/isomedia/media.c index 31209a8..91e8361 100644 --- a/src/isomedia/media.c +++ b/src/isomedia/media.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,7 +64,7 @@ GF_Err Media_GetSampleDescIndex(GF_MediaBox *mdia, u64 DTS, u32 *sampleDescIndex if (gf_list_count(mdia->information->sampleTable->SampleDescription->other_boxes)) { (*sampleDescIndex) = 1; return GF_OK; - } + } return GF_BAD_PARAM; } return stbl_GetSampleInfos(mdia->information->sampleTable, ( sampleNumber ? sampleNumber : prevSampleNumber), &offset, &num, sampleDescIndex, &isEdited); @@ -79,7 +79,7 @@ static GF_Err gf_isom_get_3gpp_audio_esd(GF_SampleTableBox *stbl, GF_GenericAudi (*out_esd)->decoderConfig->streamType = GF_STREAM_AUDIO; /*official mapping to MPEG-4*/ switch (entry->type) { - case GF_ISOM_SUBTYPE_3GP_EVRC: + case GF_ISOM_SUBTYPE_3GP_EVRC: (*out_esd)->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_EVRC_VOICE; return GF_OK; case GF_ISOM_SUBTYPE_3GP_QCELP: @@ -125,7 +125,7 @@ static GF_Err gf_isom_get_3gpp_audio_esd(GF_SampleTableBox *stbl, GF_GenericAudi gf_bs_get_content(bs, & (*out_esd)->decoderConfig->decoderSpecificInfo->data, & (*out_esd)->decoderConfig->decoderSpecificInfo->dataLength); gf_bs_del(bs); } - return GF_OK; + return GF_OK; case GF_ISOM_SUBTYPE_3GP_SMV: (*out_esd)->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_SMV_VOICE; return GF_OK; @@ -152,7 +152,7 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo GF_MPEGSampleEntryBox *entry = NULL; GF_ESDBox *ESDa; GF_SampleDescriptionBox *stsd = mdia->information->sampleTable->SampleDescription; - + *out_esd = NULL; if (!stsd || !stsd->other_boxes || !sampleDescIndex || (sampleDescIndex > gf_list_count(stsd->other_boxes)) ) return GF_BAD_PARAM; @@ -175,10 +175,11 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: + case GF_ISOM_BOX_TYPE_HVT1: esd = ((GF_MPEGVisualSampleEntryBox*) entry)->emul_esd; break; case GF_ISOM_BOX_TYPE_SVC1: @@ -216,48 +217,48 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo else return GF_ISOM_INVALID_MEDIA; #ifndef GPAC_DISABLE_TTXT case GF_ISOM_BOX_TYPE_WVTT: - { - GF_BitStream *bs; - esd = gf_odf_desc_esd_new(2); - *out_esd = esd; - esd->decoderConfig->streamType = GF_STREAM_TEXT; - esd->decoderConfig->objectTypeIndication = GPAC_OTI_SCENE_VTT_MP4; - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - gf_bs_write_u32(bs, entry->type); - boxstring_Write((GF_Box *)((GF_WebVTTSampleEntryBox*)entry)->config, bs); - gf_bs_get_content(bs, & esd->decoderConfig->decoderSpecificInfo->data, & esd->decoderConfig->decoderSpecificInfo->dataLength); - gf_bs_del(bs); - } - break; + { + GF_BitStream *bs; + esd = gf_odf_desc_esd_new(2); + *out_esd = esd; + esd->decoderConfig->streamType = GF_STREAM_TEXT; + esd->decoderConfig->objectTypeIndication = GPAC_OTI_SCENE_VTT_MP4; + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + gf_bs_write_u32(bs, entry->type); + boxstring_Write((GF_Box *)((GF_WebVTTSampleEntryBox*)entry)->config, bs); + gf_bs_get_content(bs, & esd->decoderConfig->decoderSpecificInfo->data, & esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_bs_del(bs); + } + break; case GF_ISOM_BOX_TYPE_STPP: - { - /* TODO */ - } - break; + { + /* TODO */ + } + break; case GF_ISOM_BOX_TYPE_SBTT: - { - /* TODO */ - } - break; + { + /* TODO */ + } + break; case GF_ISOM_BOX_TYPE_STSE: - { - GF_BitStream *bs; - esd = gf_odf_desc_esd_new(2); - *out_esd = esd; - esd->decoderConfig->streamType = GF_STREAM_TEXT; - esd->decoderConfig->objectTypeIndication = GPAC_OTI_SCENE_SIMPLE_TEXT_MP4; - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - gf_bs_write_u32(bs, entry->type); - boxstring_Write((GF_Box *)((GF_SimpleTextSampleEntryBox*)entry)->config, bs); - gf_bs_get_content(bs, & esd->decoderConfig->decoderSpecificInfo->data, & esd->decoderConfig->decoderSpecificInfo->dataLength); - gf_bs_del(bs); - } - break; + { + GF_BitStream *bs; + esd = gf_odf_desc_esd_new(2); + *out_esd = esd; + esd->decoderConfig->streamType = GF_STREAM_TEXT; + esd->decoderConfig->objectTypeIndication = GPAC_OTI_SCENE_SIMPLE_TEXT_MP4; + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + gf_bs_write_u32(bs, entry->type); + boxstring_Write((GF_Box *)((GF_SimpleTextSampleEntryBox*)entry)->config, bs); + gf_bs_get_content(bs, & esd->decoderConfig->decoderSpecificInfo->data, & esd->decoderConfig->decoderSpecificInfo->dataLength); + gf_bs_del(bs); + } + break; #endif case GF_ISOM_SUBTYPE_3GP_AMR: case GF_ISOM_SUBTYPE_3GP_AMR_WB: - case GF_ISOM_SUBTYPE_3GP_EVRC: + case GF_ISOM_SUBTYPE_3GP_EVRC: case GF_ISOM_SUBTYPE_3GP_QCELP: case GF_ISOM_SUBTYPE_3GP_SMV: if (!true_desc_only) { @@ -266,7 +267,7 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo break; } else return GF_ISOM_INVALID_MEDIA; - case GF_ISOM_SUBTYPE_3GP_H263: + case GF_ISOM_SUBTYPE_3GP_H263: if (true_desc_only) { return GF_ISOM_INVALID_MEDIA; } else { @@ -284,7 +285,7 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo break; } - case GF_ISOM_SUBTYPE_LSR1: + case GF_ISOM_SUBTYPE_LSR1: if (true_desc_only) { return GF_ISOM_INVALID_MEDIA; } else { @@ -299,7 +300,8 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo break; } - default: return GF_ISOM_INVALID_MEDIA; + default: + return GF_ISOM_INVALID_MEDIA; } if (true_desc_only) { @@ -335,7 +337,7 @@ GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, u8 isEdited; GF_SampleEntryBox *entry; - + if (!mdia || !mdia->information->sampleTable) return GF_BAD_PARAM; //OK, here we go.... @@ -389,10 +391,10 @@ GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, e = Media_GetSampleDesc(mdia, *sIDX, &entry, &dataRefIndex); if (e) return e; - // Open the data handler - check our mode, don't reopen in read only if this is - //the same entry. In other modes we have no choice because the main data map is + // Open the data handler - check our mode, don't reopen in read only if this is + //the same entry. In other modes we have no choice because the main data map is //divided into the original and the edition files - if (mdia->mediaTrack->moov->mov->openMode == GF_ISOM_OPEN_READ) { + if (mdia->mediaTrack->moov->mov->openMode == GF_ISOM_OPEN_READ) { //same as last call in read mode if (!mdia->information->dataHandler) { e = gf_isom_datamap_open(mdia, dataRefIndex, isEdited); @@ -409,19 +411,19 @@ GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, if (no_data) return GF_OK; /*and finally get the data, include padding if needed*/ - (*samp)->data = (char *) gf_malloc(sizeof(char) * ( (*samp)->dataLength + mdia->mediaTrack->padding_bytes) ); + (*samp)->data = (char *) gf_malloc(sizeof(char) * ( (*samp)->dataLength + mdia->mediaTrack->padding_bytes) ); if (mdia->mediaTrack->padding_bytes) memset((*samp)->data + (*samp)->dataLength, 0, sizeof(char) * mdia->mediaTrack->padding_bytes); //check if we can get the sample (make sure we have enougth data...) new_size = gf_bs_get_size(mdia->information->dataHandler->bs); if (offset + (*samp)->dataLength > new_size) { - //always refresh the size to avoid wrong info on http/ftp + //always refresh the size to avoid wrong info on http/ftp new_size = gf_bs_get_refreshed_size(mdia->information->dataHandler->bs); if (offset + (*samp)->dataLength > new_size) { mdia->BytesMissing = offset + (*samp)->dataLength - new_size; return GF_ISOM_INCOMPLETE_FILE; - } + } } bytesRead = gf_isom_datamap_get_data(mdia->information->dataHandler, (*samp)->data, (*samp)->dataLength, offset); @@ -436,16 +438,16 @@ GF_Err Media_GetSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample **samp, if (e) return e; } /*FIXME: we don NOT rewrite sample if we have a encrypted track*/ - else if (gf_isom_is_nalu_based_entry(mdia, entry) && - !gf_isom_is_track_encrypted(mdia->mediaTrack->moov->mov, gf_isom_get_tracknum_from_id(mdia->mediaTrack->moov, mdia->mediaTrack->Header->trackID)) - ) { + else if (gf_isom_is_nalu_based_entry(mdia, entry) && + !gf_isom_is_track_encrypted(mdia->mediaTrack->moov->mov, gf_isom_get_tracknum_from_id(mdia->mediaTrack->moov, mdia->mediaTrack->Header->trackID)) + ) { e = gf_isom_nalu_sample_rewrite(mdia, *samp, sampleNumber, (GF_MPEGVisualSampleEntryBox *)entry); if (e) return e; - } - else if (mdia->mediaTrack->moov->mov->convert_streaming_text - && ((mdia->handler->handlerType == GF_ISOM_MEDIA_TEXT) || (mdia->handler->handlerType == GF_ISOM_MEDIA_SUBT)) - && (entry->type == GF_ISOM_BOX_TYPE_TX3G || entry->type == GF_ISOM_BOX_TYPE_TEXT) - ) { + } + else if (mdia->mediaTrack->moov->mov->convert_streaming_text + && ((mdia->handler->handlerType == GF_ISOM_MEDIA_TEXT) || (mdia->handler->handlerType == GF_ISOM_MEDIA_SUBT)) + && (entry->type == GF_ISOM_BOX_TYPE_TX3G || entry->type == GF_ISOM_BOX_TYPE_TEXT) + ) { u64 dur; if (sampleNumber == mdia->information->sampleTable->SampleSize->sampleCount) { dur = mdia->mediaHeader->duration - (*samp)->DTS; @@ -472,7 +474,7 @@ GF_Err Media_CheckDataEntry(GF_MediaBox *mdia, u32 dataEntryIndex) entry = (GF_DataEntryURLBox*)gf_list_get(mdia->information->dataInformation->dref->other_boxes, dataEntryIndex - 1); if (!entry) return GF_ISOM_INVALID_FILE; if (entry->flags == 1) return GF_OK; - + //ok, not self contained, let's go for it... //we don't know what's a URN yet if (entry->type == GF_ISOM_BOX_TYPE_URN) return GF_NOT_SUPPORTED; @@ -515,7 +517,7 @@ GF_Err Media_FindSyncSample(GF_SampleTableBox *stbl, u32 searchFromSample, u32 * u32 next, prev; if (!stbl || !stbl->SyncSample) return GF_BAD_PARAM; - //set to current sample if we don't find a RAP + //set to current sample if we don't find a RAP *sampleNumber = searchFromSample; //this is not the exact sample, but the prev move to next sample if enough samples.... @@ -594,7 +596,7 @@ GF_Err Media_SetDuration(GF_TrackBox *trak) GF_SttsEntry *ent; u32 nbSamp = trak->Media->information->sampleTable->SampleSize->sampleCount; - //we need to check how many samples we have. + //we need to check how many samples we have. // == 1 -> last sample duration == default duration // > 1 -> last sample duration == prev sample duration switch (nbSamp) { @@ -669,9 +671,9 @@ GF_Err Media_SetDuration(GF_TrackBox *trak) #ifndef GPAC_DISABLE_ISOM_WRITE - + GF_Err Media_CreateDataRef(GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex) -{ +{ GF_Err e; GF_DataEntryURLBox *entry; @@ -761,7 +763,7 @@ GF_Err Media_AddSample(GF_MediaBox *mdia, u64 data_offset, GF_ISOSample *sample, //The first non sync sample we see must create a syncTable if (sample->IsRAP) { //insert it only if we have a sync table and if we have an IDR slice - if (stbl->SyncSample && (sample->IsRAP == 1)){ + if (stbl->SyncSample && (sample->IsRAP == 1)) { e = stbl_AddRAP(stbl->SyncSample, sampleNumber); if (e) return e; } @@ -842,7 +844,7 @@ GF_Err Media_UpdateSample(GF_MediaBox *mdia, u32 sampleNumber, GF_ISOSample *sam if (!mdia || !sample || !sampleNumber || !mdia->mediaTrack->moov->mov->editFileMap) return GF_BAD_PARAM; - + stbl = mdia->information->sampleTable; if (!data_only) { diff --git a/src/isomedia/media_odf.c b/src/isomedia/media_odf.c index cef8684..ab18c88 100644 --- a/src/isomedia/media_odf.c +++ b/src/isomedia/media_odf.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample) GF_ODCodec *ODdecode; GF_ODCodec *ODencode; GF_ODCom *com; - + //the commands we proceed GF_ESDUpdate *esdU, *esdU2; GF_ESDRemove *esdR, *esdR2; @@ -92,7 +92,7 @@ GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample) } e = gf_odf_desc_copy(desc, (GF_Descriptor **)&isom_od); if (e) goto err_exit; - + //create our OD... if (desc->tag == GF_ODF_ISOM_IOD_TAG) { od = (GF_ObjectDescriptor *) gf_malloc(sizeof(GF_InitialObjectDescriptor)); @@ -115,7 +115,7 @@ GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample) isom_od->IPMP_Descriptors = NULL; od->OCIDescriptors = isom_od->OCIDescriptors; isom_od->OCIDescriptors = NULL; - + //init as IOD if (isom_od->tag == GF_ODF_ISOM_IOD_TAG) { ((GF_InitialObjectDescriptor *)od)->audio_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->audio_profileAndLevel; @@ -127,10 +127,10 @@ GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample) ((GF_InitialObjectDescriptor *)od)->IPMPToolList = ((GF_IsomInitialObjectDescriptor *)isom_od)->IPMPToolList; ((GF_IsomInitialObjectDescriptor *)isom_od)->IPMPToolList = NULL; } - + //then rewrite the ESDesc j=0; - while ((ref = (GF_ES_ID_Ref*)gf_list_enum(isom_od->ES_ID_RefDescriptors, &j))){ + while ((ref = (GF_ES_ID_Ref*)gf_list_enum(isom_od->ES_ID_RefDescriptors, &j))) { //if the ref index is not valid, skip this desc... if (!mpod->trackIDs || gf_isom_get_track_from_id(mdia->mediaTrack->moov, mpod->trackIDs[ref->trackRef - 1]) == NULL) continue; //OK, get the esd @@ -324,7 +324,7 @@ GF_Err Media_ParseODFrame(GF_MediaBox *mdia, GF_ISOSample *sample, GF_ISOSample //in OD stream only ref desc are accepted isom_od->ES_ID_RefDescriptors = gf_list_new(); isom_od->ES_ID_IncDescriptors = NULL; - + //TO DO: check that a given sampleDescription exists isom_od->extensionDescriptors = od->extensionDescriptors; od->extensionDescriptors = NULL; @@ -471,12 +471,13 @@ static u32 Media_FindOD_ID(GF_MediaBox *mdia, GF_ISOSample *sample, u32 track_id switch (desc->tag) { case GF_ODF_OD_TAG: case GF_ODF_IOD_TAG: - esd_list = ((GF_ObjectDescriptor *)desc)->ESDescriptors; break; + esd_list = ((GF_ObjectDescriptor *)desc)->ESDescriptors; + break; default: continue; - } + } j=0; - while ((esd = (GF_ESD*)gf_list_enum( esd_list, &j))){ + while ((esd = (GF_ESD*)gf_list_enum( esd_list, &j))) { if (esd->ESID==track_id) { the_od_id = ((GF_IsomObjectDescriptor*)desc)->objectDescriptorID; break; diff --git a/src/isomedia/meta.c b/src/isomedia/meta.c index ef62acd..a84f963 100644 --- a/src/isomedia/meta.c +++ b/src/isomedia/meta.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -83,7 +83,7 @@ GF_Err gf_isom_extract_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, } } if (!xml || !xml->xml || !xml->xml_length) return GF_BAD_PARAM; - + didfile = gf_f64_open(outName, "wb"); if (!didfile) return GF_IO_ERR; gf_fwrite(xml->xml, xml->xml_length, 1, didfile); @@ -125,10 +125,10 @@ u32 gf_isom_get_meta_item_count(GF_ISOFile *file, Bool root_meta, u32 track_num) } GF_EXPORT -GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num, - u32 *itemID, u32 *protection_idx, Bool *is_self_reference, - const char **item_name, const char **item_mime_type, const char **item_encoding, - const char **item_url, const char **item_urn) +GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_num, + u32 *itemID, u32 *protection_idx, Bool *is_self_reference, + const char **item_name, const char **item_mime_type, const char **item_encoding, + const char **item_url, const char **item_urn) { GF_ItemInfoEntryBox *iinf; u32 i, count; @@ -137,7 +137,7 @@ GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_nu iinf = (GF_ItemInfoEntryBox *)gf_list_get(meta->item_infos->item_infos, item_num-1); if (!iinf) return GF_BAD_PARAM; - + if (itemID) (*itemID) = iinf->item_ID; if (protection_idx) (*protection_idx) = iinf->item_protection_index; if (item_name) (*item_name) = iinf->item_name; @@ -165,9 +165,9 @@ GF_Err gf_isom_get_meta_item_info(GF_ISOFile *file, Bool root_meta, u32 track_nu GF_ItemExtentEntry *entry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0); if (!entry->extent_length #ifndef GPAC_DISABLE_ISOM_WRITE - && !entry->original_extent_offset + && !entry->original_extent_offset #endif - ) + ) *is_self_reference = 1; } } @@ -204,7 +204,7 @@ GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num); if (!meta || !meta->item_infos || !meta->item_locations) return GF_BAD_PARAM; - + if (out_mime) *out_mime = NULL; item_num = gf_isom_get_meta_item_by_id(file, root_meta, track_num, item_id); @@ -212,7 +212,7 @@ GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 GF_ItemInfoEntryBox *item_entry = (GF_ItemInfoEntryBox *)gf_list_get(meta->item_infos->item_infos, item_num-1); item_name = item_entry->item_name; if (out_mime) *out_mime = item_entry->content_type; - } + } location_entry = NULL; count = gf_list_count(meta->item_locations->location_entries); @@ -241,11 +241,11 @@ GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 count = gf_list_count(location_entry->extent_entries); if (!location_entry->base_offset && (count==1)) { extent_entry = (GF_ItemExtentEntry *)gf_list_get(location_entry->extent_entries, 0); - if (!extent_entry->extent_length + if (!extent_entry->extent_length #ifndef GPAC_DISABLE_ISOM_WRITE - && !extent_entry->original_extent_offset + && !extent_entry->original_extent_offset #endif - ) return GF_BAD_PARAM; + ) return GF_BAD_PARAM; } item_bs = NULL; @@ -262,7 +262,7 @@ GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 resource = gf_f64_open(szPath, "wb"); item_bs = gf_bs_from_file(resource, GF_BITSTREAM_WRITE); } - + for (i=0; ihandler) + if (!meta->handler) meta->handler = (GF_HandlerBox *)hdlr_New(); if (meta->handler->nameUTF8) gf_free(meta->handler->nameUTF8); @@ -530,7 +530,7 @@ GF_Err gf_isom_add_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 trac } memset(location_entry, 0, sizeof(GF_ItemLocationEntry)); location_entry->extent_entries = gf_list_new(); - + /*Creates an mdat if it does not exist*/ if (!file->mdat) { file->mdat = (GF_MediaDataBox *)mdat_New(); @@ -544,7 +544,7 @@ GF_Err gf_isom_add_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 trac location_entry->item_ID = item_id; } else { location_entry->item_ID = lastItemID; - } + } if (!meta->item_infos) meta->item_infos = (GF_ItemInfoBox *) iinf_New(); e = gf_list_add(meta->item_infos->item_infos, infe); @@ -667,7 +667,7 @@ GF_Err gf_isom_remove_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, if (iloc->data_reference_index) { } gf_list_rem(meta->item_locations->location_entries, i); - gf_isom_box_del((GF_Box *)iloc); + iloc_entry_del(iloc); break; } } diff --git a/src/isomedia/movie_fragments.c b/src/isomedia/movie_fragments.c index 7f49186..b7a7091 100644 --- a/src/isomedia/movie_fragments.c +++ b/src/isomedia/movie_fragments.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -98,7 +98,7 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *movie, u32 media_segment_type) if (!movie->moov->mvex->mehd || !movie->moov->mvex->mehd->fragment_duration) { //update durations gf_isom_get_duration(movie); - } + } i=0; while ((trex = (GF_TrackExtendsBox *)gf_list_enum(movie->moov->mvex->TrackExList, &i))) { @@ -113,7 +113,7 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *movie, u32 media_segment_type) if (e) return e; } - //make sure we do have all we need. If not this is not an error, just consider + //make sure we do have all we need. If not this is not an error, just consider //the file closed if (!movie->moov->mvex || !gf_list_count(movie->moov->mvex->TrackExList)) return GF_OK; @@ -123,7 +123,7 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *movie, u32 media_segment_type) //we could also check all our data refs are local but we'll do that at run time //in order to allow a mix of both (remote refs in MOOV and local in MVEX) - //one thing that MUST be done is OD cross-dependancies. The movie fragment spec + //one thing that MUST be done is OD cross-dependancies. The movie fragment spec //is broken here, since it cannot allow dynamic insertion of new ESD and their //dependancies } @@ -144,7 +144,7 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *movie, u32 media_segment_type) gf_isom_reset_alt_brands(movie); /* msdh: it's a media segment - sims: it's a media segment with an SSIX + sims: it's a media segment with an SSIX msix: it's a media segment with an index lmsg: it's the last media segment */ @@ -152,13 +152,13 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *movie, u32 media_segment_type) return GF_OK; } -GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID, - u32 DefaultSampleDescriptionIndex, - u32 DefaultSampleDuration, - u32 DefaultSampleSize, - u8 DefaultSampleIsSync, - u8 DefaultSamplePadding, - u16 DefaultDegradationPriority) +GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID, + u32 DefaultSampleDescriptionIndex, + u32 DefaultSampleDuration, + u32 DefaultSampleSize, + u8 DefaultSampleIsSync, + u8 DefaultSamplePadding, + u16 DefaultDegradationPriority) { GF_MovieExtendsBox *mvex; GF_TrackExtendsBox *trex; @@ -186,13 +186,13 @@ GF_Err gf_isom_change_track_fragment_defaults(GF_ISOFile *movie, u32 TrackID, } GF_EXPORT -GF_Err gf_isom_setup_track_fragment(GF_ISOFile *movie, u32 TrackID, - u32 DefaultSampleDescriptionIndex, - u32 DefaultSampleDuration, - u32 DefaultSampleSize, - u8 DefaultSampleIsSync, - u8 DefaultSamplePadding, - u16 DefaultDegradationPriority) +GF_Err gf_isom_setup_track_fragment(GF_ISOFile *movie, u32 TrackID, + u32 DefaultSampleDescriptionIndex, + u32 DefaultSampleDuration, + u32 DefaultSampleSize, + u8 DefaultSampleIsSync, + u8 DefaultSamplePadding, + u16 DefaultDegradationPriority) { GF_MovieExtendsBox *mvex; GF_TrackExtendsBox *trex; @@ -385,13 +385,13 @@ u32 UpdateRuns(GF_ISOFile *movie, GF_TrackFragmentBox *traf) u32 sampleCount, i, j, RunSize, UseDefaultSize, RunDur, UseDefaultDur, RunFlags, NeedFlags, UseDefaultFlag, UseCTS, count; GF_TrackFragmentRunBox *trun; GF_TrunEntry *ent, *first_ent; - + sampleCount = 0; #ifndef USE_BASE_DATA_OFFSET if (movie->use_segments) { traf->tfhd->flags = GF_ISOM_MOOF_BASE_OFFSET; - } else + } else #endif { traf->tfhd->flags = GF_ISOM_TRAF_BASE_OFFSET; @@ -434,7 +434,7 @@ u32 UpdateRuns(GF_ISOFile *movie, GF_TrackFragmentBox *traf) first_ent = ent; RunSize = ent->size; RunDur = ent->Duration; - } + } //we may have one entry only ... if (j || (count==1)) { //flags are only after first entry @@ -464,14 +464,14 @@ u32 UpdateRuns(GF_ISOFile *movie, GF_TrackFragmentBox *traf) if (!UseDefaultSize) UseDefaultSize = 1; else if (UseDefaultSize==2) RunSize = 0; } - //we could check for single entry runs and set the default size in the tfhd but + //we could check for single entry runs and set the default size in the tfhd but //that's no bit saving... else { RunSize=0; } if (!RunSize) trun->flags |= GF_ISOM_TRUN_SIZE; - + //duration checking if (RunDur && (traf->trex->def_sample_duration == RunDur)) { if (!UseDefaultDur) UseDefaultDur = 2; @@ -515,7 +515,7 @@ u32 UpdateRuns(GF_ISOFile *movie, GF_TrackFragmentBox *traf) //CTS flag if (UseCTS) trun->flags |= GF_ISOM_TRUN_CTS_OFFSET; - //run data offset if the offset indicated is 0 (first sample in this MDAT) don't + //run data offset if the offset indicated is 0 (first sample in this MDAT) don't //indicate it if (trun->data_offset) trun->flags |= GF_ISOM_TRUN_DATA_OFFSET; @@ -645,9 +645,9 @@ u32 moof_get_duration(GF_MovieFragmentBox *moof, u32 refTrackID) while ((trun = gf_list_enum(traf->TrackRuns, &i))) { j=0; while ((ent = gf_list_enum(trun->entries, &j))) { - if (ent->flags & GF_ISOM_TRAF_SAMPLE_DUR) + if (ent->flags & GF_ISOM_TRAF_SAMPLE_DUR) duration += ent->Duration; - else + else duration += traf->trex->def_sample_duration; } } @@ -704,7 +704,7 @@ GF_Err StoreFragment(GF_ISOFile *movie, Bool load_mdat_only, s32 data_offset_dif if (!s_count) continue; trun = (GF_TrackFragmentRunBox *)gf_list_get(traf->TrackRuns, s_count-1); if (!trun->cache || !trun->sample_count) continue; - + //update offset trun->data_offset = (u32) (gf_bs_get_position(bs) - movie->moof->fragment_offset - 8); //write cache @@ -808,20 +808,20 @@ GF_Err StoreFragment(GF_ISOFile *movie, Bool load_mdat_only, s32 data_offset_dif //4- Write moof e = gf_isom_box_size((GF_Box *) movie->moof); if (e) return e; - /*moof first, update traf headers - THIS WILL IMPACT THE MOOF SIZE IF WE + /*moof first, update traf headers - THIS WILL IMPACT THE MOOF SIZE IF WE DECIDE NOT TO USE THE DATA-OFFSET FLAG*/ - if (movie->moof_first + if (movie->moof_first #ifndef USE_BASE_DATA_OFFSET - && !movie->use_segments + && !movie->use_segments #endif - ) { + ) { i=0; while ((traf = (GF_TrackFragmentBox*)gf_list_enum(movie->moof->TrackList, &i))) { /*offset increases by moof size*/ traf->tfhd->base_data_offset += movie->moof->size; traf->tfhd->base_data_offset += data_offset_diff; } - } + } #ifndef USE_BASE_DATA_OFFSET else if (movie->use_segments) { if (offset != (movie->moof->size+8)) { @@ -865,7 +865,7 @@ GF_Err StoreFragment(GF_ISOFile *movie, Bool load_mdat_only, s32 data_offset_dif if (moof_size) *moof_size = (u32) movie->moof->size; if (!movie->use_segments) { - gf_isom_box_del((GF_Box *) movie->moof); + gf_isom_box_del((GF_Box *) movie->moof); movie->moof = NULL; } return GF_OK; @@ -954,7 +954,7 @@ GF_Err gf_isom_flush_fragments(GF_ISOFile *movie, Bool last_segment) { GF_BitStream *temp_bs = NULL; GF_Err e; - + if (!movie || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) return GF_BAD_PARAM; if (movie->openMode != GF_ISOM_OPEN_WRITE) return GF_ISOM_INVALID_MODE; @@ -1049,7 +1049,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re GF_TrackBox *trak = NULL; GF_Err e; /*number of subsegment in this segment (eg nb references in the first SIDX found)*/ - u32 nb_subsegs=0; + u32 nb_subsegs=0; /*number of subsegment per sidx (eg number of references of any sub-SIDX*/ u32 subseg_per_sidx; /*number of fragments per subsegment*/ @@ -1104,7 +1104,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re if (referenceTrackID) { trak = gf_isom_get_track_from_id(movie->moov, referenceTrackID); } - + if (subsegments_per_sidx < 0) { referenceTrackID = 0; subsegments_per_sidx = 0; @@ -1117,7 +1117,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re frags_per_subseg = 0; subseg_per_sidx = 0; frags_per_subsidx = 0; - + prev_earliest_cts = 0; if (daisy_chain_sidx) @@ -1156,9 +1156,9 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re sidx->earliest_presentation_time = prev_earliest_cts; /*if more subsegments requested than fragments available, make a single sidx*/ - if ((s32) count <= subsegments_per_sidx) + if ((s32) count <= subsegments_per_sidx) subsegments_per_sidx = 0; - + if (daisy_chain_sidx && (subsegments_per_sidx<2)) subsegments_per_sidx = 2; @@ -1177,7 +1177,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re else if (daisy_chain_sidx) { frags_per_subsidx = count/subsegments_per_sidx; if (frags_per_subsidx * subsegments_per_sidx < count) frags_per_subsidx++; - + nb_subsegs = subsegments_per_sidx; /*we consider that each fragment is a subsegment - this could be controled by another parameter*/ @@ -1186,12 +1186,12 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re if (subseg_per_sidx * frags_per_subseg < frags_per_subsidx) subseg_per_sidx++; sidx->nb_refs = subseg_per_sidx + 1; - } + } /*hierarchical SIDX*/ else { frags_per_subsidx = count/subsegments_per_sidx; if (frags_per_subsidx * subsegments_per_sidx < count) frags_per_subsidx++; - + nb_subsegs = subsegments_per_sidx; /*we consider that each fragment is a subsegment - this could be controled by another parameter*/ @@ -1275,7 +1275,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re sidx->refs = gf_malloc(sizeof(GF_SIDXReference)*sidx->nb_refs); memset(sidx->refs, 0, sizeof(GF_SIDXReference)*sidx->nb_refs); - if (root_sidx) + if (root_sidx) root_sidx->refs[sidx_idx].reference_type = 1; /*remember start of sidx*/ @@ -1347,7 +1347,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re /*we are switching subsegment*/ frag_count--; - if (count==frags_per_subseg) { + if (count==frags_per_subseg) { count = 0; first_frag_in_subseg = 1; idx++; @@ -1393,12 +1393,12 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re cur_dur = 0; count = 0; idx=0; - if (movie->root_sidx) + if (movie->root_sidx) movie->root_sidx_index++; sidx_idx++; } } - } + } gf_isom_box_del((GF_Box *) movie->moof); movie->moof = NULL; } @@ -1418,7 +1418,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re movie->root_sidx = NULL; } return GF_OK; - } + } if (sidx) { assert(!root_sidx); @@ -1501,7 +1501,7 @@ GF_Err gf_isom_start_segment(GF_ISOFile *movie, char *SegName, Bool memory_mode) if (!movie || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) return GF_BAD_PARAM; if (movie->openMode != GF_ISOM_OPEN_WRITE) return GF_ISOM_INVALID_MODE; - if (gf_list_count(movie->moof_list)) + if (gf_list_count(movie->moof_list)) return GF_BAD_PARAM; movie->segment_bs = NULL; @@ -1547,12 +1547,12 @@ GF_Err gf_isom_start_fragment(GF_ISOFile *movie, Bool moof_first) GF_TrackFragmentBox *traf; GF_Err e; //and only at setup - if (!movie || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) + if (!movie || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) return GF_BAD_PARAM; if (movie->openMode != GF_ISOM_OPEN_WRITE) return GF_ISOM_INVALID_MODE; count = gf_list_count(movie->moov->mvex->TrackExList); - if (!count) + if (!count) return GF_BAD_PARAM; /*always force cached mode when writing movie segments*/ @@ -1564,13 +1564,13 @@ GF_Err gf_isom_start_fragment(GF_ISOFile *movie, Bool moof_first) e = StoreFragment(movie, movie->use_segments ? 1 : 0, 0, NULL); if (e) return e; } - + //create new fragment movie->moof = (GF_MovieFragmentBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MOOF); movie->moof->mfhd = (GF_MovieFragmentHeaderBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MFHD); movie->moof->mfhd->sequence_number = movie->NextMoofNumber; movie->NextMoofNumber ++; - if (movie->use_segments) + if (movie->use_segments) gf_list_add(movie->moof_list, movie->moof); @@ -1579,7 +1579,7 @@ GF_Err gf_isom_start_fragment(GF_ISOFile *movie, Bool moof_first) /*prepare MDAT*/ gf_bs_write_u32(movie->editFileMap->bs, 0); gf_bs_write_u32(movie->editFileMap->bs, GF_ISOM_BOX_TYPE_MDAT); - + //we create a TRAF for each setup track, unused ones will be removed at store time for (i=0; imoov->mvex->TrackExList, i); @@ -1600,7 +1600,7 @@ GF_Err gf_isom_clone_pssh(GF_ISOFile *output, GF_ISOFile *input, Bool in_moof) { GF_Box *a; u32 i; i = 0; - + while ((a = (GF_Box *)gf_list_enum(input->moov->other_boxes, &i))) { if (a->type == GF_ISOM_BOX_TYPE_PSSH) { GF_ProtectionSystemHeaderBox *pssh = (GF_ProtectionSystemHeaderBox *)pssh_New(); @@ -1631,8 +1631,8 @@ u32 GetRunSize(GF_TrackFragmentRunBox *trun) } GF_EXPORT -GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample *sample, u32 DescIndex, - u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redundant_coding) +GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample *sample, u32 DescIndex, + u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redundant_coding) { u32 count, buffer_size; char *buffer; @@ -1641,18 +1641,18 @@ GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample GF_TrunEntry *ent; GF_TrackFragmentBox *traf, *traf_2; GF_TrackFragmentRunBox *trun; - if (!movie->moof || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) || !sample) + if (!movie->moof || !(movie->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) || !sample) return GF_BAD_PARAM; traf = GetTraf(movie, TrackID); - if (!traf) + if (!traf) return GF_BAD_PARAM; if (!traf->tfhd->sample_desc_index) traf->tfhd->sample_desc_index = DescIndex ? DescIndex : traf->trex->def_sample_desc_index; pos = gf_bs_get_position(movie->editFileMap->bs); - + //WARNING: we change stream description, create a new TRAF if ( DescIndex && (traf->tfhd->sample_desc_index != DescIndex)) { //if we're caching flush the current run @@ -1693,9 +1693,9 @@ GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample //check data offset when no caching as trun entries shall ALWAYS be contiguous samples if (!traf->DataCache && (movie->moof->fragment_offset + 8 + trun->data_offset + GetRunSize(trun) != pos) ) count = 0; - + //check I-frame detection - if (traf->tfhd->IFrameSwitching && sample->IsRAP) + if (traf->tfhd->IFrameSwitching && sample->IsRAP) count = 0; if (traf->DataCache && (traf->DataCache==trun->sample_count) ) @@ -1720,7 +1720,7 @@ GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample gf_list_add(traf->TrackRuns, trun); //if we use data caching, create a bitstream - if (traf->DataCache) + if (traf->DataCache) trun->cache = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); } @@ -1733,7 +1733,7 @@ GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample ent->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(0, 2, 0, (redundant_coding ? 1 : 0) ); } gf_list_add(trun->entries, ent); - + trun->sample_count += 1; //rewrite OD frames @@ -1940,7 +1940,7 @@ GF_Err gf_isom_fragment_copy_subsample(GF_ISOFile *dest, u32 TrackID, GF_ISOFile traf->subs = (GF_SubSampleInformationBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_SUBS); traf->subs->version = 0; } - + count = gf_list_count(sub_sample->SubSamples); for (i=0; iMedia->information->sampleTable->sampleGroups, i); for (j=0; jentry_count; j++) { last_sample_in_entry = first_sample_in_entry + sg->sample_entries[j].sample_count - 1; @@ -1992,12 +1992,12 @@ GF_EXPORT u32 gf_isom_is_fragmented(GF_ISOFile *movie) { if (!movie || !movie->moov) return 0; - /* By default if the Moov has an mvex, the file is fragmented */ - if (movie->moov->mvex) return 1; - /* deprecated old code */ + /* By default if the Moov has an mvex, the file is fragmented */ + if (movie->moov->mvex) return 1; + /* deprecated old code */ /*only check moof number (in read mode, mvex can be deleted on the fly)*/ //return movie->NextMoofNumber ? 1 : 0; - return 0; + return 0; } GF_EXPORT @@ -2024,13 +2024,13 @@ GF_Err gf_isom_finalize_for_fragment(GF_ISOFile *the_file, u32 media_segment_typ return GF_NOT_SUPPORTED; } -GF_Err gf_isom_setup_track_fragment(GF_ISOFile *the_file, u32 TrackID, - u32 DefaultSampleDescriptionIndex, - u32 DefaultSampleDuration, - u32 DefaultSampleSize, - u8 DefaultSampleIsSync, - u8 DefaultSamplePadding, - u16 DefaultDegradationPriority) +GF_Err gf_isom_setup_track_fragment(GF_ISOFile *the_file, u32 TrackID, + u32 DefaultSampleDescriptionIndex, + u32 DefaultSampleDuration, + u32 DefaultSampleSize, + u8 DefaultSampleIsSync, + u8 DefaultSamplePadding, + u16 DefaultDegradationPriority) { return GF_NOT_SUPPORTED; } @@ -2045,8 +2045,8 @@ GF_Err gf_isom_start_fragment(GF_ISOFile *the_file, u32 free_data_insert_size) return GF_NOT_SUPPORTED; } -GF_Err gf_isom_fragment_add_sample(GF_ISOFile *the_file, u32 TrackID, GF_ISOSample *sample, u32 DescIndex, - u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redCoded) +GF_Err gf_isom_fragment_add_sample(GF_ISOFile *the_file, u32 TrackID, GF_ISOSample *sample, u32 DescIndex, + u32 Duration, u8 PaddingBits, u16 DegradationPriority, Bool redCoded) { return GF_NOT_SUPPORTED; } diff --git a/src/isomedia/sample_descs.c b/src/isomedia/sample_descs.c index 74d8cc5..c164d70 100644 --- a/src/isomedia/sample_descs.c +++ b/src/isomedia/sample_descs.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -75,7 +75,7 @@ void gf_isom_video_sample_entry_write(GF_VisualSampleEntryBox *ptr, GF_BitStream { gf_bs_write_data(bs, ptr->reserved, 6); gf_bs_write_u16(bs, ptr->dataReferenceIndex); - + gf_bs_write_u16(bs, ptr->version); gf_bs_write_u16(bs, ptr->revision); gf_bs_write_u32(bs, ptr->vendor); @@ -240,7 +240,7 @@ GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfi e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !cfg) return GF_BAD_PARAM; @@ -250,7 +250,7 @@ GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfi if (trak->Media->handler->handlerType!=GF_ISOM_MEDIA_AUDIO) return GF_BAD_PARAM; cfg_type = GF_ISOM_BOX_TYPE_DAMR; break; - case GF_ISOM_SUBTYPE_3GP_EVRC: + case GF_ISOM_SUBTYPE_3GP_EVRC: if (trak->Media->handler->handlerType!=GF_ISOM_MEDIA_AUDIO) return GF_BAD_PARAM; cfg_type = GF_ISOM_BOX_TYPE_DEVC; break; @@ -266,7 +266,8 @@ GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfi if (trak->Media->handler->handlerType!=GF_ISOM_MEDIA_VISUAL) return GF_BAD_PARAM; cfg_type = GF_ISOM_BOX_TYPE_D263; break; - case 0: return GF_BAD_PARAM; + case 0: + return GF_BAD_PARAM; default: return GF_NOT_SUPPORTED; } @@ -301,7 +302,7 @@ GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfi e = gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, entry); *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); } - break; + break; case GF_ISOM_SUBTYPE_3GP_H263: { GF_3GPPVisualSampleEntryBox *entry = (GF_3GPPVisualSampleEntryBox *) gf_isom_box_new(cfg->type); @@ -316,7 +317,7 @@ GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfi e = gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, entry); *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); } - break; + break; } return e; } @@ -330,7 +331,7 @@ GF_Err gf_isom_3gp_config_update(GF_ISOFile *the_file, u32 trackNumber, GF_3GPCo e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !param || !DescriptionIndex) return GF_BAD_PARAM; @@ -366,7 +367,7 @@ GF_Err gf_isom_ac3_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AC3Confi e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !cfg) return GF_BAD_PARAM; @@ -437,7 +438,7 @@ GF_Err gf_isom_new_dims_description(GF_ISOFile *movie, u32 trackNumber, GF_DIMSD e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media) return GF_BAD_PARAM; @@ -485,7 +486,7 @@ GF_Err gf_isom_update_dims_description(GF_ISOFile *movie, u32 trackNumber, GF_DI e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !desc || !DescriptionIndex) return GF_BAD_PARAM; @@ -536,15 +537,24 @@ GF_Err LSR_UpdateESD(GF_LASeRSampleEntryBox *lsr, GF_ESD *esd) lsr->bitrate->bufferSizeDB = esd->decoderConfig->bufferSizeDB; if (gf_list_count(esd->IPIDataSet) - || gf_list_count(esd->IPMPDescriptorPointers) - || esd->langDesc - || gf_list_count(esd->extensionDescriptors) - || esd->ipiPtr || esd->qos || esd->RegDescriptor) { + || gf_list_count(esd->IPMPDescriptorPointers) + || esd->langDesc + || gf_list_count(esd->extensionDescriptors) + || esd->ipiPtr || esd->qos || esd->RegDescriptor) { lsr->descr = (GF_MPEG4ExtensionDescriptorsBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_M4DS); - if (esd->RegDescriptor) { gf_list_add(lsr->descr->descriptors, esd->RegDescriptor); esd->RegDescriptor = NULL; } - if (esd->qos) { gf_list_add(lsr->descr->descriptors, esd->qos); esd->qos = NULL; } - if (esd->ipiPtr) { gf_list_add(lsr->descr->descriptors, esd->ipiPtr); esd->ipiPtr= NULL; } + if (esd->RegDescriptor) { + gf_list_add(lsr->descr->descriptors, esd->RegDescriptor); + esd->RegDescriptor = NULL; + } + if (esd->qos) { + gf_list_add(lsr->descr->descriptors, esd->qos); + esd->qos = NULL; + } + if (esd->ipiPtr) { + gf_list_add(lsr->descr->descriptors, esd->ipiPtr); + esd->ipiPtr= NULL; + } while (gf_list_count(esd->IPIDataSet)) { GF_Descriptor *desc = (GF_Descriptor *)gf_list_get(esd->IPIDataSet, 0); diff --git a/src/isomedia/stbl_read.c b/src/isomedia/stbl_read.c index fb5f8ce..7ec4aa0 100644 --- a/src/isomedia/stbl_read.c +++ b/src/isomedia/stbl_read.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -38,13 +38,13 @@ GF_Err findEntryForTime(GF_SampleTableBox *stbl, u64 DTS, u8 useCTS, u32 *sample (*prevSampleNumber) = 0; if (!stbl->CompositionOffset) useCTS = 0; - /*FIXME: CTS is ALWAYS disabled for now to make sure samples are fetched in + /*FIXME: CTS is ALWAYS disabled for now to make sure samples are fetched in decoding order. */ useCTS = 0; //our cache if (stbl->TimeToSample->r_FirstSampleInEntry && - (DTS >= stbl->TimeToSample->r_CurrentDTS) ) { + (DTS >= stbl->TimeToSample->r_CurrentDTS) ) { //if we're using CTS, we don't really know whether we're in the good entry or not //(eg, the real DTS of the sample could be in a previous entry i = stbl->TimeToSample->r_currentEntryIndex; @@ -107,7 +107,7 @@ entry_found: if (curDTS + CTSOffset == DTS) { (*sampleNumber) = curSampNum; } - //if we match the exact DTS also select this sample + //if we match the exact DTS also select this sample else if (curDTS == DTS) { (*sampleNumber) = curSampNum; } else { @@ -132,7 +132,7 @@ GF_Err stbl_GetSampleSize(GF_SampleSizeBox *stsz, u32 SampleNumber, u32 *Size) (*Size) = stsz->sampleSize; } else if (stsz->sizes) { (*Size) = stsz->sizes[SampleNumber - 1]; - } + } return GF_OK; } @@ -183,10 +183,10 @@ GF_Err stbl_GetSampleDTS_and_Duration(GF_TimeToSampleBox *stts, u32 SampleNumber ent = NULL; //use our cache count = stts->nb_entries; - if (stts->r_FirstSampleInEntry - && (stts->r_FirstSampleInEntry <= SampleNumber) - //this is for read/write access - && (stts->r_currentEntryIndex < count) ) { + if (stts->r_FirstSampleInEntry + && (stts->r_FirstSampleInEntry <= SampleNumber) + //this is for read/write access + && (stts->r_currentEntryIndex < count) ) { i = stts->r_currentEntryIndex; } else { @@ -203,7 +203,7 @@ GF_Err stbl_GetSampleDTS_and_Duration(GF_TimeToSampleBox *stts, u32 SampleNumber j = SampleNumber - stts->r_FirstSampleInEntry; goto found; } - + //update our cache stts->r_CurrentDTS += ent->sampleCount * ent->sampleDelta; stts->r_currentEntryIndex += 1; @@ -292,7 +292,7 @@ GF_Err stbl_SearchSAPs(GF_SampleTableBox *stbl, u32 SampleNumber, u8 *IsRAP, u32 sgdp = NULL; } if (! sgdp) continue; - + first_sample_in_entry=1; for (j=0; jentry_count; j++) { u32 first_rap_in_entry, last_rap_in_entry; @@ -329,7 +329,7 @@ GF_Err stbl_SearchSAPs(GF_SampleTableBox *stbl, u32 SampleNumber, u8 *IsRAP, u32 if (nextRAP) { *nextRAP = last_rap_in_entry; } - + /*sample lies in this (rap) group, it is rap*/ if (is_rap_group) { if ((first_rap_in_entry <= SampleNumber) && (SampleNumber <= last_rap_in_entry)) { @@ -415,8 +415,8 @@ GF_Err stbl_GetSampleInfos(GF_SampleTableBox *stbl, u32 sampleNumber, u64 *offse //check our cache if (stbl->SampleToChunk->firstSampleInCurrentChunk && - (stbl->SampleToChunk->firstSampleInCurrentChunk < sampleNumber)) { - + (stbl->SampleToChunk->firstSampleInCurrentChunk < sampleNumber)) { + i = stbl->SampleToChunk->currentIndex; // ent = gf_list_get(stbl->SampleToChunk->entryList, i); ent = &stbl->SampleToChunk->entries[stbl->SampleToChunk->currentIndex]; @@ -439,7 +439,7 @@ GF_Err stbl_GetSampleInfos(GF_SampleTableBox *stbl, u32 sampleNumber, u64 *offse //browse all the samples in this chunk for (j = 0; j < ent->samplesPerChunk; j++) { //ok, this is our sample - if (stbl->SampleToChunk->firstSampleInCurrentChunk + j == sampleNumber ) + if (stbl->SampleToChunk->firstSampleInCurrentChunk + j == sampleNumber ) goto sample_found; } //nope, get to next chunk @@ -539,7 +539,7 @@ GF_Err stbl_GetPaddingBits(GF_PaddingBitsBox *padb, u32 SampleNumber, u8 *PadBit if (!PadBits) return GF_BAD_PARAM; *PadBits = 0; if (!padb || !padb->padbits) return GF_OK; - //the spec says "should" not shall. return 0 padding + //the spec says "should" not shall. return 0 padding if (padb->SampleCount < SampleNumber) return GF_OK; *PadBits = padb->padbits[SampleNumber-1]; return GF_OK; @@ -573,7 +573,7 @@ u32 stbl_GetSampleFragmentCount(GF_SampleFragmentBox *stsf, u32 sampleNumber) stsf->r_currentEntryIndex = 0; } i = stsf->r_currentEntryIndex; - + count = gf_list_count(stsf->entryList); for (; ientryList, i); diff --git a/src/isomedia/stbl_write.c b/src/isomedia/stbl_write.c index dec328f..b4f86f8 100644 --- a/src/isomedia/stbl_write.c +++ b/src/isomedia/stbl_write.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -27,7 +27,7 @@ #ifndef GPAC_DISABLE_ISOM -/*macro used for table gf_realloc - we allocate much more than needed in order to keep the number of +/*macro used for table gf_realloc - we allocate much more than needed in order to keep the number of gf_realloc low, which greatly impacts performances for large files*/ #define ALLOC_INC(a) a = ((a<10) ? 100 : (a*3)/2); @@ -242,7 +242,7 @@ GF_Err stbl_AddCTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 CTSoffset) sampNum ++; } } - + /*we will at most add 2 new entries (spliting of an existing one)*/ if (ctts->nb_entries+2>=ctts->alloc_size) { ctts->alloc_size += 2; @@ -265,7 +265,7 @@ GF_Err stbl_AddCTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 CTSoffset) } } gf_free(CTSs); - + /*we've inserted a sample, therefore the last sample (n) has now number n+1 we cannot use SampleCount because we have probably skipped some samples (we're calling AddCTS only if the sample has a CTSOffset !!!)*/ @@ -309,7 +309,7 @@ GF_Err stbl_unpackCTS(GF_SampleTableBox *stbl) ctts->entries = NULL; ctts->nb_entries = 0; ctts->alloc_size = 0; - for (i=0;inb_entries == ctts->alloc_size) { ALLOC_INC(ctts->alloc_size); @@ -549,7 +549,7 @@ GF_Err stbl_AddChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u32 StreamDescIn co64->offsets = (u64*)gf_malloc(sizeof(u64) * co64->nb_entries); if (!co64->offsets) return GF_OUT_OF_MEM; k = 0; - for (i=0;inb_entries; i++) { + for (i=0; inb_entries; i++) { if (i + 1 == sampleNumber) { co64->offsets[i] = offset; k = 1; @@ -643,7 +643,7 @@ GF_Err stbl_AddChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u32 StreamDescIn //OK, now if we've inserted a chunk, update the sample to chunk info... if (sampleNumber == stsc->nb_entries + 1) { ent->nextChunk = stsc->nb_entries + 1; - if (stsc->nb_entries) + if (stsc->nb_entries) stsc->entries[stsc->nb_entries-1].nextChunk = ent->firstChunk; stbl->SampleToChunk->currentIndex = stsc->nb_entries; @@ -688,7 +688,7 @@ GF_Err stbl_SetChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u64 offset) co64->alloc_size = co64->nb_entries; co64->offsets = (u64*)gf_malloc(sizeof(u64)*co64->nb_entries); if (!co64->offsets) return GF_OUT_OF_MEM; - for (i=0;inb_entries; i++) { + for (i=0; inb_entries; i++) { co64->offsets[i] = (u64) ((GF_ChunkOffsetBox *)stbl->ChunkOffset)->offsets[i]; } co64->offsets[ent->firstChunk - 1] = offset; @@ -830,7 +830,7 @@ GF_Err stbl_RemoveDTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 LastAUDefDu stts = stbl->TimeToSample; - //we're removing the only sample: empty the sample table + //we're removing the only sample: empty the sample table if (stbl->SampleSize->sampleCount == 1) { stts->nb_entries = 0; stts->r_FirstSampleInEntry = stts->r_currentEntryIndex = 0; @@ -873,7 +873,7 @@ GF_Err stbl_RemoveDTS(GF_SampleTableBox *stbl, u32 sampleNumber, u32 LastAUDefDu for (i=1; iSampleSize->sampleCount-1; i++) { if (i+1 == stbl->SampleSize->sampleCount-1) { //and by default, our last sample has the same delta as the prev - // stts->entries[j].sampleCount++; + // stts->entries[j].sampleCount++; } else if (DTSs[i+1] - DTSs[i] == stts->entries[j].sampleDelta) { stts->entries[j].sampleCount += 1; } else { @@ -1042,7 +1042,7 @@ GF_Err stbl_RemoveRAP(GF_SampleTableBox *stbl, u32 sampleNumber) memmove(&stss->sampleNumbers[i], &stss->sampleNumbers[i+1], sizeof(u32)* (stss->nb_entries-i-1) ); stss->nb_entries--; } - + if (sampleNumber < stss->sampleNumbers[i]) { assert(stss->sampleNumbers[i]); stss->sampleNumbers[i]--; @@ -1144,7 +1144,7 @@ GF_Err stbl_RemovePaddingBits(GF_SampleTableBox *stbl, u32 SampleNumber) k++; } } - + stbl->PaddingBits->SampleCount -= 1; gf_free(stbl->PaddingBits->padbits); stbl->PaddingBits->padbits = p; @@ -1157,7 +1157,7 @@ GF_Err stbl_AddSampleFragment(GF_SampleTableBox *stbl, u32 sampleNumber, u16 siz GF_Err e; u32 i, count; GF_StsfEntry *ent; - GF_SampleFragmentBox *stsf; + GF_SampleFragmentBox *stsf; stsf = stbl->Fragments; if (!stsf) { @@ -1245,7 +1245,7 @@ GF_Err stbl_SampleSizeAppend(GF_SampleSizeBox *stsz, u32 data_size) { u32 i; if (!stsz || !stsz->sampleCount) return GF_BAD_PARAM; - + //we must realloc our table if (stsz->sampleSize) { stsz->sizes = (u32*)gf_malloc(sizeof(u32)*stsz->sampleCount); @@ -1310,7 +1310,7 @@ void stbl_AppendSize(GF_SampleTableBox *stbl, u32 size) memset(&stbl->SampleSize->sizes[stbl->SampleSize->sampleCount], 0, sizeof(u32) * (stbl->SampleSize->alloc_size - stbl->SampleSize->sampleCount) ); if (init_table) { - for (i=0; iSampleSize->sampleCount;i++) + for (i=0; iSampleSize->sampleCount; i++) stbl->SampleSize->sizes[i] = stbl->SampleSize->sampleSize; } } @@ -1377,7 +1377,7 @@ void stbl_AppendSampleToChunk(GF_SampleTableBox *stbl, u32 DescIndex, u32 sample if (stsc->nb_entries) { ent = &stsc->entries[stsc->nb_entries-1]; //good we can use this one - if ( (ent->sampleDescriptionIndex == DescIndex) && (ent->samplesPerChunk==samplesInChunk)) + if ( (ent->sampleDescriptionIndex == DescIndex) && (ent->samplesPerChunk==samplesInChunk)) return; //set the next chunk btw ... @@ -1413,7 +1413,7 @@ void stbl_AppendRAP(GF_SampleTableBox *stbl, u8 isRap) if (stbl->SampleSize->sampleCount > 1) { stbl->SyncSample->sampleNumbers = (u32*)gf_malloc(sizeof(u32) * (stbl->SampleSize->sampleCount-1)); if (!stbl->SyncSample->sampleNumbers) return; - for (i=0; iSampleSize->sampleCount-1; i++) + for (i=0; iSampleSize->sampleCount-1; i++) stbl->SyncSample->sampleNumbers[i] = i+1; } @@ -1454,10 +1454,10 @@ void stbl_AppendCTSOffset(GF_SampleTableBox *stbl, u32 CTSOffset) GF_CompositionOffsetBox *ctts; if (!stbl->CompositionOffset) stbl->CompositionOffset = (GF_CompositionOffsetBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_CTTS); - + ctts = stbl->CompositionOffset; - if (ctts->nb_entries && (ctts->entries[ctts->nb_entries-1].decodingOffset == CTSOffset) ){ + if (ctts->nb_entries && (ctts->entries[ctts->nb_entries-1].decodingOffset == CTSOffset) ) { ctts->entries[ctts->nb_entries-1].sampleCount++; return; } @@ -1574,7 +1574,7 @@ GF_Err stbl_UnpackOffsets(GF_SampleTableBox *stbl) } //close the list if (ent) ent->nextChunk = 0; - + //done, remove our previous tables gf_isom_box_del(stbl->ChunkOffset); @@ -1655,7 +1655,7 @@ static GFINLINE GF_Err stbl_AddOffset(GF_Box **a, u64 offset) //This function packs the offset after easy editing, eg samples //are re-arranged in chunks according to the chunkOffsets -//NOTE: this has to be called once interleaving or whatever is done and +//NOTE: this has to be called once interleaving or whatever is done and //the final MDAT is written!!! GF_Err stbl_SetChunkAndOffset(GF_SampleTableBox *stbl, u32 sampleNumber, u32 StreamDescIndex, GF_SampleToChunkBox *the_stsc, GF_Box **the_stco, u64 data_offset, u8 forceNewChunk) { @@ -1680,10 +1680,10 @@ GF_Err stbl_SetChunkAndOffset(GF_SampleTableBox *stbl, u32 sampleNumber, u32 Str newChunk = 1; } else { cur_ent = &the_stsc->entries[the_stsc->nb_entries - 1]; - //3 - make sure we do not exceed the MaxSamplesPerChunk and we have the same descIndex - if (StreamDescIndex != cur_ent->sampleDescriptionIndex) + //3 - make sure we do not exceed the MaxSamplesPerChunk and we have the same descIndex + if (StreamDescIndex != cur_ent->sampleDescriptionIndex) newChunk = 1; - if (stbl->MaxSamplePerChunk && cur_ent->samplesPerChunk == stbl->MaxSamplePerChunk) + if (stbl->MaxSamplePerChunk && cur_ent->samplesPerChunk == stbl->MaxSamplePerChunk) newChunk = 1; } @@ -1698,8 +1698,8 @@ GF_Err stbl_SetChunkAndOffset(GF_SampleTableBox *stbl, u32 sampleNumber, u32 Str if (the_stsc->nb_entries > 1) { ent = &the_stsc->entries[the_stsc->nb_entries - 2]; if ( (ent->sampleDescriptionIndex == cur_ent->sampleDescriptionIndex) - && (ent->samplesPerChunk == cur_ent->samplesPerChunk) - ) { + && (ent->samplesPerChunk == cur_ent->samplesPerChunk) + ) { //OK, it's the same SampleToChunk, so delete it ent->nextChunk = cur_ent->firstChunk; the_stsc->nb_entries--; diff --git a/src/isomedia/track.c b/src/isomedia/track.c index 53e2162..07dc14e 100644 --- a/src/isomedia/track.c +++ b/src/isomedia/track.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -88,7 +88,7 @@ GF_Err GetESD(GF_MovieBox *moov, u32 trackID, u32 StreamDescIndex, GF_ESD **outE if (e) return e; //set the ID esd->ESID = trackID; - + //find stream dependencies e = Track_FindRef(trak, GF_ISOM_BOX_TYPE_DPND , &dpnd); if (e) return e; @@ -175,12 +175,14 @@ default_sync: } if ((trak->Media->mediaHeader->packedLanguage[0] != 'u') - || (trak->Media->mediaHeader->packedLanguage[1] != 'n') - || (trak->Media->mediaHeader->packedLanguage[2] != 'd') ) { + || (trak->Media->mediaHeader->packedLanguage[1] != 'n') + || (trak->Media->mediaHeader->packedLanguage[2] != 'd') ) { if (!esd->langDesc) esd->langDesc = (GF_Language *) gf_odf_desc_new(GF_ODF_LANG_TAG); - esd->langDesc->langCode = trak->Media->mediaHeader->packedLanguage[0]; esd->langDesc->langCode <<= 8; - esd->langDesc->langCode |= trak->Media->mediaHeader->packedLanguage[1]; esd->langDesc->langCode <<= 8; + esd->langDesc->langCode = trak->Media->mediaHeader->packedLanguage[0]; + esd->langDesc->langCode <<= 8; + esd->langDesc->langCode |= trak->Media->mediaHeader->packedLanguage[1]; + esd->langDesc->langCode <<= 8; esd->langDesc->langCode |= trak->Media->mediaHeader->packedLanguage[2]; } @@ -239,7 +241,7 @@ default_sync: return GF_OK; } //otherwise use the regular mapping - + //this is a desc for a media in the file, let's rewrite some param esd->slConfig->timestampLength = 32; esd->slConfig->timestampResolution = trak->Media->mediaHeader->timeScale; @@ -249,7 +251,7 @@ default_sync: // if (OCRTrack) esd->slConfig->OCRResolution = OCRTrack->Media->mediaHeader->timeScale; stbl = trak->Media->information->sampleTable; - // a little optimization here: if all our samples are sync, + // a little optimization here: if all our samples are sync, //set the RAPOnly to true... for external users... if (! stbl->SyncSample) { if (moov->mvex && (esd->decoderConfig->streamType==GF_STREAM_VISUAL)) { @@ -304,7 +306,7 @@ GF_Err GetESDForTime(GF_MovieBox *moov, u32 trackID, u64 CTS, GF_ESD **outESD) trak = gf_isom_get_track(moov, gf_isom_get_tracknum_from_id(moov, trackID)); if (!trak) return GF_ISOM_INVALID_FILE; - + e = Media_GetSampleDescIndex(trak->Media, CTS, &sampleDescIndex ); if (e) return e; return GetESD(moov, trackID, sampleDescIndex, outESD); @@ -330,7 +332,7 @@ GF_Err Track_FindRef(GF_TrackBox *trak, u32 ReferenceType, GF_TrackReferenceType } } *dpnd = NULL; - return GF_OK; + return GF_OK; } Bool Track_IsMPEG4Stream(u32 HandlerType) @@ -338,7 +340,7 @@ Bool Track_IsMPEG4Stream(u32 HandlerType) switch (HandlerType) { case GF_ISOM_MEDIA_VISUAL: case GF_ISOM_MEDIA_AUDIO: - case GF_ISOM_MEDIA_SUBPIC: + case GF_ISOM_MEDIA_SUBPIC: case GF_ISOM_MEDIA_OD: case GF_ISOM_MEDIA_OCR: case GF_ISOM_MEDIA_SCENE: @@ -374,7 +376,7 @@ GF_Err SetTrackDuration(GF_TrackBox *trak) if (!trak->moov->mvhd->timeScale || !trak->Media->mediaHeader->timeScale) return GF_ISOM_INVALID_FILE; trackDuration = (trak->Media->mediaHeader->duration * trak->moov->mvhd->timeScale) / trak->Media->mediaHeader->timeScale; - //if we have an edit list, the duration is the sum of all the editList + //if we have an edit list, the duration is the sum of all the editList //entries' duration (always expressed in MovieTimeScale) if (trak->editBox && trak->editBox->editList) { trackDuration = 0; @@ -398,10 +400,11 @@ GF_Err SetTrackDuration(GF_TrackBox *trak) Bool gf_isom_is_identical_sgpd(void *ptr1, void *ptr2, u32 grouping_type) { + Bool res = GF_FALSE; +#ifndef GPAC_DISABLE_ISOM_WRITE GF_BitStream *bs1, *bs2; char *buf1, *buf2; u32 len1, len2; - Bool res = GF_FALSE; if (!ptr1 || !ptr2) return GF_FALSE; @@ -422,7 +425,7 @@ Bool gf_isom_is_identical_sgpd(void *ptr1, void *ptr2, u32 grouping_type) sgpd_Write((GF_Box *)ptr2, bs2); } gf_bs_get_content(bs2, &buf2, &len2); - gf_bs_del(bs2); + gf_bs_del(bs2); if ((len1==len2) && !memcmp(buf1, buf2, len1)) @@ -430,7 +433,7 @@ Bool gf_isom_is_identical_sgpd(void *ptr1, void *ptr2, u32 grouping_type) gf_free(buf1); gf_free(buf2); - +#endif return res; } @@ -454,7 +457,7 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, void stbl_AppendPadding(GF_SampleTableBox *stbl, u8 padding); void stbl_AppendDegradation(GF_SampleTableBox *stbl, u16 DegradationPriority); - if (trak->Header->trackID != traf->tfhd->trackID) return GF_OK; + if (trak->Header->trackID != traf->tfhd->trackID) return GF_OK; //setup all our defaults DescIndex = (traf->tfhd->flags & GF_ISOM_TRAF_SAMPLE_DESC) ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index; @@ -486,12 +489,12 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, i=0; while ((trun = (GF_TrackFragmentRunBox *)gf_list_enum(traf->TrackRuns, &i))) { //merge the run - for (j=0;jsample_count; j++) { + for (j=0; jsample_count; j++) { ent = (GF_TrunEntry*)gf_list_get(trun->entries, j); size = def_size; duration = def_duration; flags = def_flags; - + if (ent) { if (trun->flags & GF_ISOM_TRUN_DURATION) duration = ent->Duration; if (trun->flags & GF_ISOM_TRUN_SIZE) size = ent->size; @@ -509,7 +512,7 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, if (!j) { data_offset = base_offset; //aggregated offset if base-data-offset-present is not set AND if default-base-is-moof is not set - if (!(traf->tfhd->flags & GF_ISOM_TRAF_BASE_OFFSET) && !(traf->tfhd->flags & GF_ISOM_MOOF_BASE_OFFSET) ) + if (!(traf->tfhd->flags & GF_ISOM_TRAF_BASE_OFFSET) && !(traf->tfhd->flags & GF_ISOM_MOOF_BASE_OFFSET) ) data_offset += chunk_size; if (trun->flags & GF_ISOM_TRUN_DATA_OFFSET) { @@ -524,16 +527,16 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, } stbl_AppendChunk(trak->Media->information->sampleTable, data_offset); //then sampleToChunk - stbl_AppendSampleToChunk(trak->Media->information->sampleTable, - DescIndex, trun->sample_count); + stbl_AppendSampleToChunk(trak->Media->information->sampleTable, + DescIndex, trun->sample_count); } chunk_size += size; - + //CTS cts_offset = (trun->flags & GF_ISOM_TRUN_CTS_OFFSET) ? ent->CTS_Offset : 0; stbl_AppendCTSOffset(trak->Media->information->sampleTable, cts_offset); - + //flags sync = GF_ISOM_GET_FRAG_SYNC(flags); if (trak->Media->information->sampleTable->no_sync_found && sync) { @@ -612,7 +615,7 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, groups = trak->Media->information->sampleTable->sampleGroups; for (i=0; isampleGroups); i++) { - GF_SampleGroupBox *stbl_group = NULL; + GF_SampleGroupBox *stbl_group = NULL; GF_SampleGroupBox *frag_group = gf_list_get(traf->sampleGroups, i); @@ -634,9 +637,9 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, //adjust sgpd index: in traf index start at 0x1001 for (j = 0; j < frag_group->entry_count; j++) frag_group->sample_entries[j].group_description_index &= 0x0FFFF; - if (frag_group->entry_count && stbl_group->entry_count && - (frag_group->sample_entries[0].group_description_index==stbl_group->sample_entries[stbl_group->entry_count-1].group_description_index) - ) { + if (frag_group->entry_count && stbl_group->entry_count && + (frag_group->sample_entries[0].group_description_index==stbl_group->sample_entries[stbl_group->entry_count-1].group_description_index) + ) { stbl_group->sample_entries[stbl_group->entry_count - 1].sample_count += frag_group->sample_entries[0].sample_count; if (frag_group->entry_count>1) { stbl_group->sample_entries = gf_realloc(stbl_group->sample_entries, sizeof(GF_SampleGroupEntry) * (stbl_group->entry_count + frag_group->entry_count - 1)); @@ -679,7 +682,7 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, if (!trak->Media->information->sampleTable->other_boxes) trak->Media->information->sampleTable->other_boxes = gf_list_new(); gf_list_add(trak->Media->information->sampleTable->other_boxes, senc); } - + sais = traf->piff_sample_encryption->samp_aux_info; } else if (traf->sample_encryption) { @@ -713,21 +716,23 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, for (i = 0; i < gf_list_count(traf->sai_offsets); i++) { saio = (GF_SampleAuxiliaryInfoOffsetBox *)gf_list_get(traf->sai_offsets, i); - if (saio->aux_info_type == GF_4CC('c', 'e', 'n', 'c')) { + /*if we have only 1 sai_offsets, assume that its type is cenc*/ + if ((saio->aux_info_type == GF_4CC('c', 'e', 'n', 'c')) || (gf_list_count(traf->sai_offsets) == 1)) { offset = saio->offsets[0] + moof_offset; nb_saio = saio->entry_count; break; - } + } } for (i = 0; i < gf_list_count(traf->sai_sizes); i++) { saiz = (GF_SampleAuxiliaryInfoSizeBox *)gf_list_get(traf->sai_sizes, i); - if (saiz->aux_info_type == GF_4CC('c', 'e', 'n', 'c')) { + /*if we have only 1 sai_sizes, assume that its type is cenc*/ + if ((saiz->aux_info_type == GF_4CC('c', 'e', 'n', 'c')) || (gf_list_count(traf->sai_sizes) == 1)) { break; } } if (saiz) { for (i = 0; i < saiz->sample_count; i++) { - if (nb_saio != 1) + if (nb_saio != 1) offset = saio->offsets[i] + moof_offset; size = saiz->default_sample_info_size ? saiz->default_sample_info_size : saiz->sample_info_size[i]; @@ -753,7 +758,7 @@ GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, u64 moof_offset, if (sai->subsample_count) senc->flags = 0x00000002;*/ gf_isom_cenc_merge_saiz_saio(senc, trak->Media->information->sampleTable, (u32)offset, size); if (nb_saio == 1) - offset += size; + offset += size; } } } else if (sais) { @@ -813,7 +818,7 @@ GF_Err Track_RemoveRef(GF_TrackBox *trak, u32 ReferenceType) return GF_OK; } } - return GF_OK; + return GF_OK; } GF_Err NewMedia(GF_MediaBox **mdia, u32 MediaType, u32 TimeScale) @@ -928,15 +933,22 @@ GF_Err NewMedia(GF_MediaBox **mdia, u32 MediaType, u32 TimeScale) //Create a data reference WITHOUT DATA ENTRY (we don't know anything yet about the media Data) dref = (GF_DataReferenceBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_DREF); - e = dinf_AddBox((GF_Box*)dinf, (GF_Box *)dref); if (e) goto err_exit; - - e = minf_AddBox((GF_Box*)minf, (GF_Box *) mediaInfo); if (e) goto err_exit; - e = minf_AddBox((GF_Box*)minf, (GF_Box *) stbl); if (e) goto err_exit; - e = minf_AddBox((GF_Box*)minf, (GF_Box *) dinf); if (e) goto err_exit; - - e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) mdhd); if (e) goto err_exit; - e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) minf); if (e) goto err_exit; - e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) hdlr); if (e) goto err_exit; + e = dinf_AddBox((GF_Box*)dinf, (GF_Box *)dref); + if (e) goto err_exit; + + e = minf_AddBox((GF_Box*)minf, (GF_Box *) mediaInfo); + if (e) goto err_exit; + e = minf_AddBox((GF_Box*)minf, (GF_Box *) stbl); + if (e) goto err_exit; + e = minf_AddBox((GF_Box*)minf, (GF_Box *) dinf); + if (e) goto err_exit; + + e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) mdhd); + if (e) goto err_exit; + e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) minf); + if (e) goto err_exit; + e = mdia_AddBox((GF_Box*)*mdia, (GF_Box *) hdlr); + if (e) goto err_exit; return GF_OK; @@ -967,7 +979,7 @@ GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, if (!trak || !esd || (!outStreamIndex && !DataReferenceIndex) ) return GF_BAD_PARAM; if (!Track_IsMPEG4Stream(trak->Media->handler->handlerType)) return GF_ISOM_INVALID_MEDIA; - + esd->ESID = 0; //set SL to predefined if no url if (esd->URLString == NULL) { @@ -1084,12 +1096,13 @@ GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: - case GF_ISOM_BOX_TYPE_HVC1: - case GF_ISOM_BOX_TYPE_HEV1: + case GF_ISOM_BOX_TYPE_HVC1: + case GF_ISOM_BOX_TYPE_HEV1: case GF_ISOM_BOX_TYPE_HVC2: case GF_ISOM_BOX_TYPE_HEV2: case GF_ISOM_BOX_TYPE_SHC1: case GF_ISOM_BOX_TYPE_SHV1: + case GF_ISOM_BOX_TYPE_HVT1: e = AVC_HEVC_UpdateESD((GF_MPEGVisualSampleEntryBox*)entry, esd); if (e) return e; break; @@ -1100,10 +1113,10 @@ GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, case GF_ISOM_BOX_TYPE_STSE: case GF_ISOM_BOX_TYPE_WVTT: case GF_ISOM_BOX_TYPE_STPP: - /* TODO */ - assert(0); + /* TODO */ + assert(0); break; - + default: //gf_odf_desc_del((GF_Descriptor *) esd); break; @@ -1120,7 +1133,7 @@ GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, //OK, check the handler and create the entry switch (trak->Media->handler->handlerType) { case GF_ISOM_MEDIA_VISUAL: - if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)){ + if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)) { entry_v = (GF_MPEGVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_AVC1); if (!entry_v) return GF_OUT_OF_MEM; e = AVC_HEVC_UpdateESD((GF_MPEGVisualSampleEntryBox*)entry_v, esd); @@ -1128,7 +1141,7 @@ GF_Err Track_SetStreamDescriptor(GF_TrackBox *trak, u32 StreamDescriptionIndex, entry_v = (GF_MPEGVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_HVC1); if (!entry_v) return GF_OUT_OF_MEM; e = AVC_HEVC_UpdateESD((GF_MPEGVisualSampleEntryBox*)entry_v, esd); - + } else { entry_v = (GF_MPEGVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_MP4V); if (!entry_v) return GF_OUT_OF_MEM; diff --git a/src/isomedia/ttml.c b/src/isomedia/ttml.c index 6febb25..70219b8 100644 --- a/src/isomedia/ttml.c +++ b/src/isomedia/ttml.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,48 +31,48 @@ #ifndef GPAC_DISABLE_TTML -GF_Box *stpp_New() +GF_Box *stpp_New() { - ISOM_DECL_BOX_ALLOC(GF_XMLSubtitleSampleEntryBox, GF_ISOM_BOX_TYPE_STPP); + ISOM_DECL_BOX_ALLOC(GF_XMLSubtitleSampleEntryBox, GF_ISOM_BOX_TYPE_STPP); gf_isom_sample_entry_init((GF_SampleEntryBox*)tmp); - return (GF_Box *)tmp; + return (GF_Box *)tmp; } void stpp_del(GF_Box *s) { - GF_XMLSubtitleSampleEntryBox *stpp= (GF_XMLSubtitleSampleEntryBox *)s; + GF_XMLSubtitleSampleEntryBox *stpp= (GF_XMLSubtitleSampleEntryBox *)s; if (stpp == NULL) return; gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s); - if (stpp->xmlnamespace) gf_free(stpp->xmlnamespace); - if (stpp->schema_location) gf_free(stpp->schema_location); - if (stpp->auxiliary_mime_types) gf_free(stpp->auxiliary_mime_types); - gf_free(s); + if (stpp->xmlnamespace) gf_free(stpp->xmlnamespace); + if (stpp->schema_location) gf_free(stpp->schema_location); + if (stpp->auxiliary_mime_types) gf_free(stpp->auxiliary_mime_types); + gf_free(s); } static GF_Err stpp_Add(GF_Box *s, GF_Box *a) { - GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; - switch(a->type) { + GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; + switch(a->type) { case GF_ISOM_BOX_TYPE_BTRT: if (stpp->bitrate) ERROR_ON_DUPLICATED_BOX(a, s) - stpp->bitrate = (GF_MPEG4BitRateBox *)a; + stpp->bitrate = (GF_MPEG4BitRateBox *)a; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(stpp->protections, a); break; - default: - return gf_isom_box_add_default(s, a); - } - return GF_OK; + default: + return gf_isom_box_add_default(s, a); + } + return GF_OK; } GF_Err stpp_Read(GF_Box *s, GF_BitStream *bs) { u32 size, i; char *str; - GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; - gf_bs_read_data(bs, stpp->reserved, 6); - stpp->dataReferenceIndex = gf_bs_read_u16(bs); + GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; + gf_bs_read_data(bs, stpp->reserved, 6); + stpp->dataReferenceIndex = gf_bs_read_u16(bs); size = (u32) stpp->size - 8; str = (char *)gf_malloc(sizeof(char)*size); @@ -109,26 +109,26 @@ GF_Err stpp_Read(GF_Box *s, GF_BitStream *bs) stpp->size = size; gf_free(str); - return gf_isom_read_box_list(s, bs, stpp_Add); + return gf_isom_read_box_list(s, bs, stpp_Add); } #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err stpp_Write(GF_Box *s, GF_BitStream *bs) { - GF_Err e; - GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; - e = gf_isom_box_write_header(s, bs); - gf_bs_write_data(bs, stpp->reserved, 6); - gf_bs_write_u16(bs, stpp->dataReferenceIndex); + GF_Err e; + GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; + e = gf_isom_box_write_header(s, bs); + gf_bs_write_data(bs, stpp->reserved, 6); + gf_bs_write_u16(bs, stpp->dataReferenceIndex); gf_bs_write_data(bs, stpp->xmlnamespace, (u32) strlen(stpp->xmlnamespace)); gf_bs_write_u8(bs, 0); - if (stpp->schema_location) + if (stpp->schema_location) gf_bs_write_data(bs, stpp->schema_location, (u32) strlen(stpp->schema_location)); gf_bs_write_u8(bs, 0); - if (stpp->auxiliary_mime_types) + if (stpp->auxiliary_mime_types) gf_bs_write_data(bs, stpp->auxiliary_mime_types, (u32) strlen(stpp->auxiliary_mime_types)); gf_bs_write_u8(bs, 0); @@ -140,11 +140,11 @@ GF_Err stpp_Write(GF_Box *s, GF_BitStream *bs) GF_Err stpp_Size(GF_Box *s) { - GF_Err e; - GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; - e = gf_isom_box_get_size(s); - if (e) return e; - s->size += 8; // reserved and dataReferenceIndex + GF_Err e; + GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)s; + e = gf_isom_box_get_size(s); + if (e) return e; + s->size += 8; // reserved and dataReferenceIndex stpp->size += strlen(stpp->xmlnamespace); stpp->size++; @@ -152,7 +152,7 @@ GF_Err stpp_Size(GF_Box *s) if (stpp->schema_location) stpp->size += strlen(stpp->schema_location); stpp->size++; - + if (stpp->auxiliary_mime_types) stpp->size += strlen(stpp->auxiliary_mime_types); stpp->size++; @@ -172,7 +172,7 @@ void gf_box_dump_done(char *name, GF_Box *ptr, FILE *trace); GF_Err stpp_dump(GF_Box *a, FILE * trace) { - GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)a; + GF_XMLSubtitleSampleEntryBox *stpp = (GF_XMLSubtitleSampleEntryBox *)a; const char *name = "XMLSubtitleSampleEntryBox"; fprintf(trace, "<%s ", name); @@ -191,10 +191,12 @@ GF_Err stpp_dump(GF_Box *a, FILE * trace) #endif /* GPAC_DISABLE_ISOM_DUMP */ -GF_Err gf_isom_update_xml_subtitle_description( GF_ISOFile *movie, - u32 trackNumber, - u32 descriptionIndex, - GF_GenericSubtitleSampleDescriptor *desc) +#ifndef GPAC_DISABLE_ISOM_WRITE + +GF_Err gf_isom_update_xml_subtitle_description( GF_ISOFile *movie, + u32 trackNumber, + u32 descriptionIndex, + GF_GenericSubtitleSampleDescriptor *desc) { GF_TrackBox *trak; GF_Err e; @@ -202,7 +204,7 @@ GF_Err gf_isom_update_xml_subtitle_description( GF_ISOFile if (!descriptionIndex || !desc) return GF_BAD_PARAM; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media) return GF_BAD_PARAM; @@ -219,12 +221,12 @@ GF_Err gf_isom_update_xml_subtitle_description( GF_ISOFile return e; } -GF_Err gf_isom_new_xml_subtitle_description(GF_ISOFile *movie, - u32 trackNumber, - char *xmlnamespace, - char *xml_schema_loc, - char *mimes, - u32 *outDescriptionIndex) +GF_Err gf_isom_new_xml_subtitle_description(GF_ISOFile *movie, + u32 trackNumber, + char *xmlnamespace, + char *xml_schema_loc, + char *mimes, + u32 *outDescriptionIndex) { GF_TrackBox *trak; GF_Err e; @@ -235,7 +237,7 @@ GF_Err gf_isom_new_xml_subtitle_description(GF_ISOFile *movie, e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media) return GF_BAD_PARAM; @@ -262,12 +264,13 @@ GF_Err gf_isom_new_xml_subtitle_description(GF_ISOFile *movie, if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); stpp->bitrate = (GF_MPEG4BitRateBox *)btrt_New(); - stpp->xmlnamespace = gf_strdup(xmlnamespace); - stpp->schema_location = gf_strdup(xml_schema_loc); - stpp->auxiliary_mime_types = gf_strdup(mimes); + stpp->xmlnamespace = gf_strdup(xmlnamespace); + stpp->schema_location = gf_strdup(xml_schema_loc); + stpp->auxiliary_mime_types = gf_strdup(mimes); return e; } +#endif /* blindly adds text to a sample following 3GPP Timed Text style */ GF_Err gf_isom_xml_subtitle_sample_add_text(GF_GenericSubtitleSample *samp, char *text_data, u32 text_len) @@ -280,8 +283,8 @@ GF_Err gf_isom_xml_subtitle_sample_add_text(GF_GenericSubtitleSample *samp, char return GF_OK; } -/* - * Writing the xml sample structure into a sample buffer +/* + * Writing the xml sample structure into a sample buffer * - putting the text or XML in the sample directly * - optionally handle secondary resources (TODO) */ @@ -294,7 +297,7 @@ GF_ISOSample *gf_isom_xml_subtitle_to_sample(GF_GenericSubtitleSample *samp) bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); if (samp->len) gf_bs_write_data(bs, samp->text, samp->len); - else gf_bs_write_data(bs, "", 1); + else gf_bs_write_data(bs, "", 1); res = gf_isom_sample_new(); if (!res) { @@ -335,17 +338,17 @@ GF_EXPORT GF_GenericSubtitleSample *gf_isom_parse_xml_subtitle_sample(GF_BitStream *bs) { GF_GenericSubtitleSample *s = gf_isom_new_xml_subtitle_sample(); - + /*empty sample*/ if (!bs || !gf_bs_available(bs)) return s; s->len = gf_bs_read_u16(bs); if (s->len) { - /*2 extra bytes for UTF-16 term char just in case (we don't know if a BOM marker is present or + /*2 extra bytes for UTF-16 term char just in case (we don't know if a BOM marker is present or not since this may be a sample carried over RTP*/ s->text = (char *) gf_malloc(sizeof(char)*(s->len+2) ); - s->text[s->len] = 0; - s->text[s->len+1] = 0; + s->text[s->len] = 0; + s->text[s->len+1] = 0; gf_bs_read_data(bs, s->text, s->len); } return s; @@ -359,7 +362,7 @@ GF_GenericSubtitleSample *gf_isom_parse_xml_subtitle_sample_from_data(char *data if (!data || !dataLength) { return gf_isom_new_xml_subtitle_sample(); } - + bs = gf_bs_new(data, dataLength, GF_BITSTREAM_READ); s = gf_isom_parse_xml_subtitle_sample(bs); gf_bs_del(bs); diff --git a/src/isomedia/tx3g.c b/src/isomedia/tx3g.c index 530e99a..045143e 100644 --- a/src/isomedia/tx3g.c +++ b/src/isomedia/tx3g.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ GF_Err gf_isom_update_text_description(GF_ISOFile *movie, u32 trackNumber, u32 d if (!descriptionIndex || !desc) return GF_BAD_PARAM; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !desc->font_count) return GF_BAD_PARAM; @@ -65,7 +65,7 @@ GF_Err gf_isom_update_text_description(GF_ISOFile *movie, u32 trackNumber, u32 d if (!movie->keep_utc) trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); - txt->back_color = desc->back_color; + txt->back_color = desc->back_color; txt->default_box = desc->default_pos; txt->default_style = desc->default_style; txt->displayFlags = desc->displayFlags; @@ -92,7 +92,7 @@ GF_Err gf_isom_new_text_description(GF_ISOFile *movie, u32 trackNumber, GF_TextS e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !desc->font_count) return GF_BAD_PARAM; @@ -119,7 +119,7 @@ GF_Err gf_isom_new_text_description(GF_ISOFile *movie, u32 trackNumber, GF_TextS gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, txt); if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); - txt->back_color = desc->back_color; + txt->back_color = desc->back_color; txt->default_box = desc->default_pos; txt->default_style = desc->default_style; txt->displayFlags = desc->displayFlags; @@ -137,7 +137,7 @@ GF_Err gf_isom_new_text_description(GF_ISOFile *movie, u32 trackNumber, GF_TextS } -/*blindly adds text - note we don't rely on terminaison characters to handle utf8 and utf16 data +/*blindly adds text - note we don't rely on terminaison characters to handle utf8 and utf16 data in the same way. It is the user responsability to signal UTF16*/ GF_Err gf_isom_text_add_text(GF_TextSample *samp, char *text_data, u32 text_len) { @@ -196,9 +196,12 @@ GF_Err gf_isom_text_set_highlight_color(GF_TextSample *samp, u8 r, u8 g, u8 b, u samp->highlight_color = (GF_TextHighlightColorBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_HCLR); if (!samp->highlight_color) return GF_OUT_OF_MEM; } - samp->highlight_color->hil_color = a; samp->highlight_color->hil_color <<= 8; - samp->highlight_color->hil_color = r; samp->highlight_color->hil_color <<= 8; - samp->highlight_color->hil_color = g; samp->highlight_color->hil_color <<= 8; + samp->highlight_color->hil_color = a; + samp->highlight_color->hil_color <<= 8; + samp->highlight_color->hil_color = r; + samp->highlight_color->hil_color <<= 8; + samp->highlight_color->hil_color = g; + samp->highlight_color->hil_color <<= 8; samp->highlight_color->hil_color = b; return GF_OK; } @@ -361,7 +364,7 @@ GF_Err gf_isom_text_has_similar_description(GF_ISOFile *movie, u32 trackNumber, if (!desc) return GF_BAD_PARAM; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return GF_BAD_PARAM; - + trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak || !trak->Media || !desc->font_count) return GF_BAD_PARAM; @@ -454,16 +457,17 @@ GF_EXPORT GF_TextSample *gf_isom_parse_texte_sample(GF_BitStream *bs) { GF_TextSample *s = gf_isom_new_text_sample(); - + /*empty sample*/ if (!bs || !gf_bs_available(bs)) return s; s->len = gf_bs_read_u16(bs); if (s->len) { - /*2 extra bytes for UTF-16 term char just in case (we don't know if a BOM marker is present or + /*2 extra bytes for UTF-16 term char just in case (we don't know if a BOM marker is present or not since this may be a sample carried over RTP*/ s->text = (char *) gf_malloc(sizeof(char)*(s->len+2) ); - s->text[s->len] = 0; s->text[s->len+1] = 0; + s->text[s->len] = 0; + s->text[s->len+1] = 0; gf_bs_read_data(bs, s->text, s->len); } @@ -528,7 +532,7 @@ GF_TextSample *gf_isom_parse_texte_sample_from_data(char *data, u32 dataLength) if (!data || !dataLength) { return gf_isom_new_text_sample(); } - + bs = gf_bs_new(data, dataLength, GF_BITSTREAM_READ); s = gf_isom_parse_texte_sample(bs); gf_bs_del(bs); @@ -542,20 +546,24 @@ GF_TextSample *gf_isom_parse_texte_sample_from_data(char *data, u32 dataLength) static void gf_isom_write_tx3g(GF_Tx3gSampleEntryBox *a, GF_BitStream *bs, u32 sidx, u32 sidx_offset) { - u32 size, j; + u32 size, j, fount_count; void gpp_write_rgba(GF_BitStream *bs, u32 col); void gpp_write_box(GF_BitStream *bs, GF_BoxRecord *rec); void gpp_write_style(GF_BitStream *bs, GF_StyleRecord *rec); - + if (sidx_offset) gf_bs_write_u8(bs, sidx + sidx_offset); /*SINCE WINCE HAS A READONLY VERSION OF MP4 WE MUST DO IT BY HAND*/ size = 8 + 18 + 8 + 12; size += 8 + 2; - for (j=0; jfont_table->entry_count; j++) { - size += 3; - if (a->font_table->fonts[j].fontName) size += (u32) strlen(a->font_table->fonts[j].fontName); + fount_count = 0; + if (a->font_table) { + fount_count = a->font_table->entry_count; + for (j=0; jfont_table->fonts[j].fontName) size += (u32) strlen(a->font_table->fonts[j].fontName); + } } /*write TextSampleEntry box*/ gf_bs_write_u32(bs, size); @@ -572,8 +580,9 @@ static void gf_isom_write_tx3g(GF_Tx3gSampleEntryBox *a, GF_BitStream *bs, u32 s size -= (8 + 18 + 8 + 12); gf_bs_write_u32(bs, size); gf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_FTAB); - gf_bs_write_u16(bs, a->font_table->entry_count); - for (j=0; jfont_table->entry_count; j++) { + + gf_bs_write_u16(bs, fount_count); + for (j=0; jfont_table->fonts[j].fontID); if (a->font_table->fonts[j].fontName) { u32 len = (u32) strlen(a->font_table->fonts[j].fontName); @@ -598,7 +607,7 @@ GF_Err gf_isom_get_ttxt_esd(GF_MediaBox *mdia, GF_ESD **out_esd) sampleDesc = mdia->information->sampleTable->SampleDescription->other_boxes; count = gf_list_count(sampleDesc); if (!count) return GF_ISOM_INVALID_MEDIA; - + esd = gf_odf_desc_esd_new(2); esd->decoderConfig->streamType = GF_STREAM_TEXT; esd->decoderConfig->objectTypeIndication = 0x08; @@ -645,9 +654,11 @@ GF_Err gf_isom_get_ttxt_esd(GF_MediaBox *mdia, GF_ESD **out_esd) /*which video shall we pick for MPEG-4, and how is the associations indicated in 3GP ???*/ gf_bs_write_u16(bs, 0); gf_bs_write_u16(bs, 0); - trans = mdia->mediaTrack->Header->matrix[6]; trans >>= 16; + trans = mdia->mediaTrack->Header->matrix[6]; + trans >>= 16; gf_bs_write_u16(bs, trans); - trans = mdia->mediaTrack->Header->matrix[7]; trans >>= 16; + trans = mdia->mediaTrack->Header->matrix[7]; + trans >>= 16; gf_bs_write_u16(bs, trans); } @@ -704,14 +715,14 @@ GF_Err gf_isom_text_get_encoded_tx3g(GF_ISOFile *file, u32 track, u32 sidx, u32 GF_BitStream *bs; GF_TrackBox *trak; GF_Tx3gSampleEntryBox *a; - + trak = gf_isom_get_track_from_file(file, track); if (!trak) return GF_BAD_PARAM; a = (GF_Tx3gSampleEntryBox *) gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, sidx-1); if (!a) return GF_BAD_PARAM; if ((a->type != GF_ISOM_BOX_TYPE_TX3G) && (a->type != GF_ISOM_BOX_TYPE_TEXT)) return GF_BAD_PARAM; - + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); gf_isom_write_tx3g(a, bs, sidx, sidx_offset); *tx3g = NULL; diff --git a/src/laser/lsr_dec.c b/src/laser/lsr_dec.c index f87cf6e..09a80f1 100644 --- a/src/laser/lsr_dec.c +++ b/src/laser/lsr_dec.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2005-2012 * All rights reserved * @@ -36,7 +36,7 @@ (_val) = gf_bs_read_int(_codec->bs, _nbBits); \ GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[LASeR] %s\t\t%d\t\t%d\n", _str, _nbBits, _val)); \ }\ - + static void lsr_read_group_content(GF_LASeRCodec *lsr, GF_Node *elt, Bool skip_object_content); static void lsr_read_group_content_post_init(GF_LASeRCodec *lsr, SVG_Element *elt, Bool skip_init); @@ -146,7 +146,7 @@ GF_Err gf_laser_decoder_remove_stream(GF_LASeRCodec *codec, u16 ESID) { u32 i, count; count = gf_list_count(codec->streamInfo); - for (i=0;istreamInfo, i); if (ptr->ESID==ESID) { gf_free(ptr); @@ -275,7 +275,10 @@ static void lsr_read_extension(GF_LASeRCodec *lsr, const char *name) gf_bs_read_data(lsr->bs, *out_data, len); *out_len = len; #else - while (len) { gf_bs_read_int(lsr->bs, 8); len--; } + while (len) { + gf_bs_read_int(lsr->bs, 8); + len--; + } #endif } @@ -346,16 +349,16 @@ static void lsr_read_private_attribute_container(GF_LASeRCodec *lsr) uint(nameSpaceIndexBits) nameSpaceIndex; gf_bs_align(lsr->bs); byte[skipLen - ((nameSpaceIndexBits+7)%8)] data; - break; + break; default: /*TODO - spec is wrong here (typo, "len" instead of "skipLen" )*/ gf_bs_skip_bytes(skipLen); break; - } + } #endif gf_bs_align(lsr->bs); GF_LSR_READ_INT(lsr, val, 1, "hasMorePrivateData"); - } while (val); + } while (val); } static void lsr_read_any_attribute(GF_LASeRCodec *lsr, GF_Node *node, Bool skippable) @@ -365,7 +368,7 @@ static void lsr_read_any_attribute(GF_LASeRCodec *lsr, GF_Node *node, Bool skipp if (val) { do { GF_LSR_READ_INT(lsr, val, lsr->info->cfg.extensionIDBits, "reserved"); - val = lsr_read_vluimsbf5(lsr, "len");//len in BITS + val = lsr_read_vluimsbf5(lsr, "len");//len in BITS GF_LSR_READ_INT(lsr, val, val, "reserved_val"); GF_LSR_READ_INT(lsr, val, 1, "hasNextExtension"); } while (val); @@ -496,7 +499,10 @@ static void lsr_read_byte_align_string(GF_LASeRCodec *lsr, char **str, const cha (*str) [len] = 0; } } else { - while (len) { gf_bs_read_int(lsr->bs, 8); len--; } + while (len) { + gf_bs_read_int(lsr->bs, 8); + len--; + } } GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[LASeR] %s\t\t%d\t\t%s\n", name, 8*len, *str)); } @@ -590,7 +596,7 @@ static void lsr_read_any_uri(GF_LASeRCodec *lsr, XMLRI *iri, const char *name) gf_bs_read_data(lsr->bs, iri->string + len_rad + 1, len); iri->string[len_rad + 1 + len] = 0; } - } + } GF_LSR_READ_INT(lsr, val, 1, "hasID"); if (val) lsr_read_codec_IDREF(lsr, iri, "idref"); @@ -621,9 +627,16 @@ static void lsr_read_paint(GF_LASeRCodec *lsr, SVG_Paint *paint, const char *nam case 0: GF_LSR_READ_INT(lsr, val, 2, "choice"); switch (val) { - case 0: paint->type = SVG_PAINT_INHERIT; break; - case 1: paint->type = SVG_PAINT_COLOR; paint->color.type = SVG_COLOR_CURRENTCOLOR; break; - default: paint->type = SVG_PAINT_NONE; break; + case 0: + paint->type = SVG_PAINT_INHERIT; + break; + case 1: + paint->type = SVG_PAINT_COLOR; + paint->color.type = SVG_COLOR_CURRENTCOLOR; + break; + default: + paint->type = SVG_PAINT_NONE; + break; } break; case 1: @@ -643,7 +656,7 @@ static void lsr_read_paint(GF_LASeRCodec *lsr, SVG_Paint *paint, const char *nam paint->iri.target = iri.target; } } - break; + break; case 2: { char *sysPaint=NULL; @@ -654,7 +667,7 @@ static void lsr_read_paint(GF_LASeRCodec *lsr, SVG_Paint *paint, const char *nam gf_free(sysPaint); } } - break; + break; case 3: lsr_read_extension(lsr, name); break; @@ -681,7 +694,7 @@ static void lsr_read_id(GF_LASeRCodec *lsr, GF_Node *n) if (!val) return; name = NULL; - id = 1+lsr_read_vluimsbf5(lsr, "ID"); + id = 1+lsr_read_vluimsbf5(lsr, "ID"); gf_node_set_id(n, id, name); GF_LSR_READ_INT(lsr, val, 1, "reserved"); @@ -990,27 +1003,47 @@ err_exit: static u32 lsr_to_dom_key(u32 lsr_k) { switch (lsr_k) { - case 0: return GF_KEY_STAR; - case 1: return GF_KEY_0; - case 2: return GF_KEY_1; - case 3: return GF_KEY_2; - case 4: return GF_KEY_3; - case 5: return GF_KEY_4; - case 6: return GF_KEY_5; - case 7: return GF_KEY_6; - case 8: return GF_KEY_7; - case 9: return GF_KEY_8; - case 10: return GF_KEY_9; - case 12: return GF_KEY_DOWN; - case 14: return GF_KEY_LEFT; - case 16: return GF_KEY_RIGHT; - case 20: return GF_KEY_UP; + case 0: + return GF_KEY_STAR; + case 1: + return GF_KEY_0; + case 2: + return GF_KEY_1; + case 3: + return GF_KEY_2; + case 4: + return GF_KEY_3; + case 5: + return GF_KEY_4; + case 6: + return GF_KEY_5; + case 7: + return GF_KEY_6; + case 8: + return GF_KEY_7; + case 9: + return GF_KEY_8; + case 10: + return GF_KEY_9; + case 12: + return GF_KEY_DOWN; + case 14: + return GF_KEY_LEFT; + case 16: + return GF_KEY_RIGHT; + case 20: + return GF_KEY_UP; /*WHAT IS ANY_KEY (11) ??*/ - case 13: return GF_KEY_ENTER; - case 15: return GF_KEY_ESCAPE; - case 17: return GF_KEY_NUMBER; - case 18: return GF_KEY_CELL_SOFT1; - case 19: return GF_KEY_CELL_SOFT2; + case 13: + return GF_KEY_ENTER; + case 15: + return GF_KEY_ESCAPE; + case 17: + return GF_KEY_NUMBER; + case 18: + return GF_KEY_CELL_SOFT1; + case 19: + return GF_KEY_CELL_SOFT2; default: /*use '*' by default ... */ return 0; @@ -1050,39 +1083,105 @@ static void lsr_read_event_type(GF_LASeRCodec *lsr, XMLEV_Event *evtType) evtType->parameter = 0; GF_LSR_READ_INT(lsr, flag, 6, "event"); switch (flag) { - case LSR_EVT_abort: evtType->type = GF_EVENT_ABORT; break; - case LSR_EVT_accessKey: evtType->type = GF_EVENT_KEYDOWN; break; - case LSR_EVT_activate: evtType->type = GF_EVENT_ACTIVATE; break; - case LSR_EVT_activatedEvent: evtType->type = GF_EVENT_ACTIVATED; break; - case LSR_EVT_beginEvent: evtType->type = GF_EVENT_BEGIN_EVENT; break; - case LSR_EVT_click: evtType->type = GF_EVENT_CLICK; break; - case LSR_EVT_deactivatedEvent: evtType->type = GF_EVENT_DEACTIVATED; break; - case LSR_EVT_endEvent: evtType->type = GF_EVENT_END_EVENT; break; - case LSR_EVT_error: evtType->type = GF_EVENT_ERROR; break; - case LSR_EVT_executionTime: evtType->type = GF_EVENT_EXECUTION_TIME; break; - case LSR_EVT_focusin: evtType->type = GF_EVENT_FOCUSIN; break; - case LSR_EVT_focusout: evtType->type = GF_EVENT_FOCUSOUT; break; - case LSR_EVT_keydown: evtType->type = GF_EVENT_KEYDOWN; break; - case LSR_EVT_keyup: evtType->type = GF_EVENT_KEYUP; break; - case LSR_EVT_load: evtType->type = GF_EVENT_LOAD; break; - case LSR_EVT_longAccessKey: evtType->type = GF_EVENT_LONGKEYPRESS; break; - case LSR_EVT_mousedown: evtType->type = GF_EVENT_MOUSEDOWN; break; - case LSR_EVT_mousemove: evtType->type = GF_EVENT_MOUSEMOVE; break; - case LSR_EVT_mouseout: evtType->type = GF_EVENT_MOUSEOUT; break; - case LSR_EVT_mouseover: evtType->type = GF_EVENT_MOUSEOVER; break; - case LSR_EVT_mouseup: evtType->type = GF_EVENT_MOUSEUP; break; - case LSR_EVT_pause: evtType->type = GF_EVENT_PAUSE; break; - case LSR_EVT_pausedEvent: evtType->type = GF_EVENT_PAUSED_EVENT; break; - case LSR_EVT_play: evtType->type = GF_EVENT_PLAY; break; - case LSR_EVT_repeatEvent: evtType->type = GF_EVENT_REPEAT_EVENT; break; - case LSR_EVT_repeatKey: evtType->type = GF_EVENT_REPEAT_KEY; break; - case LSR_EVT_resize: evtType->type = GF_EVENT_RESIZE; break; - case LSR_EVT_resumedEvent: evtType->type = GF_EVENT_RESUME_EVENT; break; - case LSR_EVT_scroll: evtType->type = GF_EVENT_SCROLL; break; - case LSR_EVT_shortAccessKey: evtType->type = GF_EVENT_SHORT_ACCESSKEY; break; - case LSR_EVT_textinput: evtType->type = GF_EVENT_TEXTINPUT; break; - case LSR_EVT_unload: evtType->type = GF_EVENT_UNLOAD; break; - case LSR_EVT_zoom: evtType->type = GF_EVENT_ZOOM; break; + case LSR_EVT_abort: + evtType->type = GF_EVENT_ABORT; + break; + case LSR_EVT_accessKey: + evtType->type = GF_EVENT_KEYDOWN; + break; + case LSR_EVT_activate: + evtType->type = GF_EVENT_ACTIVATE; + break; + case LSR_EVT_activatedEvent: + evtType->type = GF_EVENT_ACTIVATED; + break; + case LSR_EVT_beginEvent: + evtType->type = GF_EVENT_BEGIN_EVENT; + break; + case LSR_EVT_click: + evtType->type = GF_EVENT_CLICK; + break; + case LSR_EVT_deactivatedEvent: + evtType->type = GF_EVENT_DEACTIVATED; + break; + case LSR_EVT_endEvent: + evtType->type = GF_EVENT_END_EVENT; + break; + case LSR_EVT_error: + evtType->type = GF_EVENT_ERROR; + break; + case LSR_EVT_executionTime: + evtType->type = GF_EVENT_EXECUTION_TIME; + break; + case LSR_EVT_focusin: + evtType->type = GF_EVENT_FOCUSIN; + break; + case LSR_EVT_focusout: + evtType->type = GF_EVENT_FOCUSOUT; + break; + case LSR_EVT_keydown: + evtType->type = GF_EVENT_KEYDOWN; + break; + case LSR_EVT_keyup: + evtType->type = GF_EVENT_KEYUP; + break; + case LSR_EVT_load: + evtType->type = GF_EVENT_LOAD; + break; + case LSR_EVT_longAccessKey: + evtType->type = GF_EVENT_LONGKEYPRESS; + break; + case LSR_EVT_mousedown: + evtType->type = GF_EVENT_MOUSEDOWN; + break; + case LSR_EVT_mousemove: + evtType->type = GF_EVENT_MOUSEMOVE; + break; + case LSR_EVT_mouseout: + evtType->type = GF_EVENT_MOUSEOUT; + break; + case LSR_EVT_mouseover: + evtType->type = GF_EVENT_MOUSEOVER; + break; + case LSR_EVT_mouseup: + evtType->type = GF_EVENT_MOUSEUP; + break; + case LSR_EVT_pause: + evtType->type = GF_EVENT_PAUSE; + break; + case LSR_EVT_pausedEvent: + evtType->type = GF_EVENT_PAUSED_EVENT; + break; + case LSR_EVT_play: + evtType->type = GF_EVENT_PLAY; + break; + case LSR_EVT_repeatEvent: + evtType->type = GF_EVENT_REPEAT_EVENT; + break; + case LSR_EVT_repeatKey: + evtType->type = GF_EVENT_REPEAT_KEY; + break; + case LSR_EVT_resize: + evtType->type = GF_EVENT_RESIZE; + break; + case LSR_EVT_resumedEvent: + evtType->type = GF_EVENT_RESUME_EVENT; + break; + case LSR_EVT_scroll: + evtType->type = GF_EVENT_SCROLL; + break; + case LSR_EVT_shortAccessKey: + evtType->type = GF_EVENT_SHORT_ACCESSKEY; + break; + case LSR_EVT_textinput: + evtType->type = GF_EVENT_TEXTINPUT; + break; + case LSR_EVT_unload: + evtType->type = GF_EVENT_UNLOAD; + break; + case LSR_EVT_zoom: + evtType->type = GF_EVENT_ZOOM; + break; default: GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[LASeR] Undefined LASeR event %d\n", flag)); break; @@ -1282,7 +1381,7 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_audio_level: ((SVG_Number*)info.far_ptr)->value = lsr_read_fixed_clamp(lsr, "audio-level"); break; - case TAG_SVG_ATT_color: + case TAG_SVG_ATT_color: lsr_read_paint(lsr, (SVG_Paint *)info.far_ptr, "color"); break; case TAG_SVG_ATT_color_rendering: @@ -1291,13 +1390,14 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_display: GF_LSR_READ_INT(lsr, *(SVG_Display*)info.far_ptr, 5, "display"); break; - case TAG_SVG_ATT_display_align: - GF_LSR_READ_INT(lsr, *(SVG_DisplayAlign*)info.far_ptr, 3, "display-align"); break; + case TAG_SVG_ATT_display_align: + GF_LSR_READ_INT(lsr, *(SVG_DisplayAlign*)info.far_ptr, 3, "display-align"); + break; case TAG_SVG_ATT_fill_opacity: ((SVG_Number*)info.far_ptr)->type = SVG_NUMBER_VALUE; ((SVG_Number*)info.far_ptr)->value = lsr_read_fixed_clamp(lsr, "fill-opacity"); break; - case TAG_SVG_ATT_fill_rule: + case TAG_SVG_ATT_fill_rule: GF_LSR_READ_INT(lsr, *(SVG_FillRule*)info.far_ptr, 2, "fill-rule"); break; case TAG_SVG_ATT_image_rendering: @@ -1306,20 +1406,20 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_line_increment: lsr_read_line_increment_type(lsr, info.far_ptr, "line-increment"); break; - case TAG_SVG_ATT_pointer_events: + case TAG_SVG_ATT_pointer_events: GF_LSR_READ_INT(lsr, *(SVG_PointerEvents*)info.far_ptr, 4, "pointer-events"); break; case TAG_SVG_ATT_shape_rendering: GF_LSR_READ_INT(lsr, *(SVG_RenderingHint*)info.far_ptr, 3, "shape-rendering"); break; - case TAG_SVG_ATT_solid_color: + case TAG_SVG_ATT_solid_color: lsr_read_paint(lsr, info.far_ptr, "solid-color"); break; case TAG_SVG_ATT_solid_opacity: ((SVG_Number*)info.far_ptr)->type = SVG_NUMBER_VALUE; ((SVG_Number*)info.far_ptr)->value = lsr_read_fixed_clamp(lsr, "solid-opacity"); break; - case TAG_SVG_ATT_stop_color: + case TAG_SVG_ATT_stop_color: lsr_read_paint(lsr, info.far_ptr, "stop-color"); break; case TAG_SVG_ATT_stop_opacity: @@ -1337,12 +1437,12 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) da->type=SVG_STROKEDASHARRAY_ARRAY; da->array.count = lsr_read_vluimsbf5(lsr, "len"); da->array.vals = (Fixed*)gf_malloc(sizeof(Fixed)*da->array.count); - for (j=0; jarray.count; j++) { - da->array.vals[j] = lsr_read_fixed_16_8(lsr, "dash"); + for (j=0; jarray.count; j++) { + da->array.vals[j] = lsr_read_fixed_16_8(lsr, "dash"); } } } - break; + break; case TAG_SVG_ATT_stroke_dashoffset: lsr_read_fixed_16_8i(lsr, info.far_ptr, "dashOffset"); break; @@ -1369,7 +1469,7 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_text_rendering: GF_LSR_READ_INT(lsr, *(SVG_RenderingHint*)info.far_ptr, 3, "text-rendering"); break; - case TAG_SVG_ATT_viewport_fill: + case TAG_SVG_ATT_viewport_fill: lsr_read_paint(lsr, info.far_ptr, "viewport-fill"); break; case TAG_SVG_ATT_viewport_fill_opacity: @@ -1379,16 +1479,16 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_vector_effect: GF_LSR_READ_INT(lsr, *(SVG_VectorEffect*)info.far_ptr, 4, "vector-effect"); break; - case TAG_SVG_ATT_visibility: + case TAG_SVG_ATT_visibility: GF_LSR_READ_INT(lsr, *(SVG_Visibility*)info.far_ptr, 2, "visibility"); break; case TAG_SVG_ATT_requiredExtensions: lsr_read_byte_align_string_list(lsr, *(GF_List**)info.far_ptr, "requiredExtensions", 1); break; - case TAG_SVG_ATT_requiredFormats: + case TAG_SVG_ATT_requiredFormats: lsr_read_byte_align_string_list(lsr, *(GF_List**)info.far_ptr, "requiredFormats", 0); break; - case TAG_SVG_ATT_requiredFeatures: + case TAG_SVG_ATT_requiredFeatures: { u32 j, fcount = lsr_read_vluimsbf5(lsr, "count"); for (j=0; jstring, "xml:base"); ((XMLRI*)info.far_ptr)->type = XMLRI_STRING; break; - case TAG_XML_ATT_lang: + case TAG_XML_ATT_lang: lsr_read_byte_align_string(lsr, info.far_ptr, "xml:lang"); break; - case TAG_XML_ATT_space: + case TAG_XML_ATT_space: GF_LSR_READ_INT(lsr, *(XML_Space*)info.far_ptr, 1, "xml:space"); break; /*focusable*/ case TAG_SVG_ATT_nav_next: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNext"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNext"); + break; case TAG_SVG_ATT_nav_up: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorth"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorth"); + break; case TAG_SVG_ATT_nav_up_left: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorthEast"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorthEast"); + break; case TAG_SVG_ATT_nav_up_right: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorthWest"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusNorthWest"); + break; case TAG_SVG_ATT_nav_prev: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusPrev"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusPrev"); + break; case TAG_SVG_ATT_nav_down: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouth"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouth"); + break; case TAG_SVG_ATT_nav_down_left: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouthEast"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouthEast"); + break; case TAG_SVG_ATT_nav_down_right: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouthWest"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusSouthWest"); + break; case TAG_SVG_ATT_nav_left: - lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusEast"); break; + lsr_read_focus(lsr, (SVG_Focus*)info.far_ptr, "focusEast"); + break; case TAG_SVG_ATT_focusable: /*wrong !!*/ GF_LSR_READ_INT(lsr, *(SVG_Focusable*)info.far_ptr, 2, "focusable"); @@ -1444,7 +1553,7 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) assert(0); break; - case TAG_SVG_ATT_font_variant: + case TAG_SVG_ATT_font_variant: GF_LSR_READ_INT(lsr, *(SVG_FontVariant*)info.far_ptr, 2, "font-variant"); break; case TAG_SVG_ATT_font_family: @@ -1461,7 +1570,7 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) if (ft) ((SVG_FontFamily*)info.far_ptr)->value = gf_strdup(ft); } } - break; + break; case TAG_SVG_ATT_font_size: lsr_read_fixed_16_8i(lsr, info.far_ptr, "fontSize"); break; @@ -1495,8 +1604,12 @@ static void lsr_read_rare_full(GF_LASeRCodec *lsr, GF_Node *n) case TAG_SVG_ATT_end: lsr_read_smil_times(lsr, NULL, 0, info.far_ptr, "end", 0); break; - case TAG_SVG_ATT_max: lsr_read_duration_ex(lsr, NULL, 0, info.far_ptr, "min", 0); break; - case TAG_SVG_ATT_min: lsr_read_duration_ex(lsr, NULL, 0, info.far_ptr, "min", 0); break; + case TAG_SVG_ATT_max: + lsr_read_duration_ex(lsr, NULL, 0, info.far_ptr, "min", 0); + break; + case TAG_SVG_ATT_min: + lsr_read_duration_ex(lsr, NULL, 0, info.far_ptr, "min", 0); + break; } if (lsr->last_error) break; } @@ -1619,7 +1732,7 @@ static void lsr_translate_anim_value(SMIL_AnimateValue *val, u32 coded_type) val->value = da; } } - break; + break; case SVG_ViewBox_datatype: { SVG_ViewBox *vb; @@ -1639,7 +1752,7 @@ static void lsr_translate_anim_value(SMIL_AnimateValue *val, u32 coded_type) gf_list_del(l); val->value = vb; } - break; + break; case SVG_Coordinates_datatype: { SVG_Coordinates *coords; @@ -1668,7 +1781,7 @@ static void lsr_translate_anim_value(SMIL_AnimateValue *val, u32 coded_type) val->value = coords; } } - break; + break; case SVG_Motion_datatype: if (coded_type==9) { GF_Matrix2D *mat; @@ -1712,7 +1825,7 @@ static void lsr_translate_anim_values(SMIL_AnimateValues *val, u32 coded_type) gf_list_insert(list, da, i); } } - break; + break; case SVG_ViewBox_datatype: { SVG_ViewBox *vb; @@ -1733,7 +1846,7 @@ static void lsr_translate_anim_values(SMIL_AnimateValues *val, u32 coded_type) gf_list_rem(list, i); gf_list_insert(list, vb, i); } - break; + break; case SVG_Coordinates_datatype: { SVG_Coordinates *coords; @@ -1755,7 +1868,7 @@ static void lsr_translate_anim_values(SMIL_AnimateValues *val, u32 coded_type) gf_list_rem(list, i); gf_list_insert(list, coords, i); } - break; + break; case SVG_Motion_datatype: if (coded_type==9) { @@ -1996,12 +2109,12 @@ static void *lsr_read_an_anim_value(GF_LASeRCodec *lsr, u32 coded_type, const ch GF_LSR_READ_INT(lsr, escapeFlag, 1, "escapeFlag"); if (escapeFlag) GF_LSR_READ_INT(lsr, escape_val, 2, "escapeEnum"); - switch (coded_type) { - case 0: + switch (coded_type) { + case 0: string = NULL; lsr_read_byte_align_string(lsr, &string, name); return string; - case 1: + case 1: num = (SVG_Number*)gf_malloc(sizeof(SVG_Number)); if (escapeFlag) { num->type = escape_val; @@ -2010,19 +2123,19 @@ static void *lsr_read_an_anim_value(GF_LASeRCodec *lsr, u32 coded_type, const ch num->value = lsr_read_fixed_16_8(lsr, name); } return num; - case 2: + case 2: { SVG_PathData *pd = (SVG_PathData *)gf_svg_create_attribute_value(SVG_PathData_datatype); lsr_read_path_type(lsr, NULL, 0, pd, name); return pd; } - case 3: + case 3: { SVG_Points *pts = (SVG_Points *)gf_svg_create_attribute_value(SVG_Points_datatype); lsr_read_point_sequence(lsr, *pts, name); return pts; } - case 4: + case 4: num = (SVG_Number*)gf_malloc(sizeof(SVG_Number)); if (escapeFlag) { num->type = escape_val; @@ -2031,7 +2144,7 @@ static void *lsr_read_an_anim_value(GF_LASeRCodec *lsr, u32 coded_type, const ch num->value = lsr_read_fixed_clamp(lsr, name); } return num; - case 5: + case 5: GF_SAFEALLOC(paint, SVG_Paint); if (escapeFlag) { paint->type = SVG_PAINT_INHERIT; @@ -2039,50 +2152,50 @@ static void *lsr_read_an_anim_value(GF_LASeRCodec *lsr, u32 coded_type, const ch lsr_read_paint(lsr, paint, name); } return paint; - case 6: + case 6: enum_val = (u8*)gf_malloc(sizeof(u8)); *enum_val = lsr_read_vluimsbf5(lsr, name); return enum_val; - /*TODO check this is correct*/ + /*TODO check this is correct*/ case 7: { GF_List *l = gf_list_new(); u32 i, count; count = lsr_read_vluimsbf5(lsr, "count"); - for (i=0; icoord_bits, "valX"); pt->x = lsr_translate_coords(lsr, flag, lsr->coord_bits); GF_LSR_READ_INT(lsr, flag, lsr->coord_bits, "valY"); pt->y = lsr_translate_coords(lsr, flag, lsr->coord_bits); return pt; - case 10: + case 10: id_val = (u32*)gf_malloc(sizeof(u32)); *id_val = lsr_read_vluimsbf5(lsr, name); return id_val; - case 11: + case 11: { SVG_FontFamily *ft; u32 idx; @@ -2097,14 +2210,14 @@ static void *lsr_read_an_anim_value(GF_LASeRCodec *lsr, u32 coded_type, const ch } return ft; } - case 12: + case 12: GF_SAFEALLOC(iri, XMLRI); lsr_read_any_uri(lsr, iri, name); return iri; - default: + default: lsr_read_extension(lsr, name); - break; - } + break; + } return NULL; } @@ -2145,11 +2258,20 @@ static void lsr_translate_anim_trans_value(SMIL_AnimateValue *val, u32 transform if (coded_type==8) { GF_List *l = (GF_List *)val->value; f = (Fixed*)gf_list_get(l, 0); - if (f) { p->angle = *f; gf_free(f); } + if (f) { + p->angle = *f; + gf_free(f); + } f = (Fixed*)gf_list_get(l, 1); - if (f) { p->x = *f; gf_free(f); } + if (f) { + p->x = *f; + gf_free(f); + } f = (Fixed*)gf_list_get(l, 2); - if (f) { p->y = *f; gf_free(f); } + if (f) { + p->y = *f; + gf_free(f); + } gf_list_del(l); } else { p->angle = ((SVG_Number *)val->value)->value; @@ -2164,9 +2286,15 @@ static void lsr_translate_anim_trans_value(SMIL_AnimateValue *val, u32 transform GF_List *l = (GF_List *)val->value; GF_SAFEALLOC(pt , SVG_Point); f = (Fixed*)gf_list_get(l, 0); - if (f) { pt->x = *f; gf_free(f); } + if (f) { + pt->x = *f; + gf_free(f); + } f = (Fixed*)gf_list_get(l, 1); - if (f) { pt->y = *f; gf_free(f); } + if (f) { + pt->y = *f; + gf_free(f); + } else pt->y = pt->x; gf_list_del(l); val->value = pt; @@ -2220,7 +2348,7 @@ static void lsr_translate_anim_trans_values(SMIL_AnimateValues *val, u32 transfo if (transform_type==SVG_TRANSFORM_TRANSLATE) return; - for (i=0;ivalues, i); switch (transform_type) { case SVG_TRANSFORM_ROTATE: @@ -2376,7 +2504,7 @@ static void lsr_read_float_list(GF_LASeRCodec *lsr, GF_Node *n, u32 tag, SVG_Coo } } count = lsr_read_vluimsbf5(lsr, "count"); - for (i=0;ix = lsr_translate_coords(lsr, v, nb_bits); GF_LSR_READ_INT(lsr, v, nb_bits, "y"); pt->y = lsr_translate_coords(lsr, v, nb_bits); - } - } else { + } + } else { u32 nb_dx, nb_dy, k; Fixed x, y; SVG_Point *pt = (SVG_Point *)gf_malloc(sizeof(SVG_Point)); @@ -2432,7 +2560,7 @@ static void lsr_read_point_sequence(GF_LASeRCodec *lsr, GF_List *pts, const char pt->y = y + lsr_translate_coords(lsr, k, nb_dy); y = pt->y; } - } + } } } static void lsr_read_path_type(GF_LASeRCodec *lsr, GF_Node *n, u32 tag, SVG_PathData *path, const char *name) @@ -2554,9 +2682,9 @@ exit: gf_free(v); } - count = lsr_read_vluimsbf5(lsr, "nbOfTypes"); - for (i=0; icommands, type); - } + } #endif } @@ -2690,7 +2818,7 @@ static void lsr_read_coord_list(GF_LASeRCodec *lsr, GF_Node *elt, u32 tag, const u32 i, count; GF_LSR_READ_INT(lsr, count, 1, name); if (!count) return; - count = lsr_read_vluimsbf5(lsr, "nb_coords"); + count = lsr_read_vluimsbf5(lsr, "nb_coords"); if (!count) return; if (count>1000000) { lsr->last_error = GF_NON_COMPLIANT_BITSTREAM; @@ -2741,9 +2869,14 @@ static void lsr_read_script_type(GF_LASeRCodec *lsr, GF_Node *n) if (flag) { GF_LSR_READ_INT(lsr, flag, 1, "script"); switch (flag) { - case 0: *(SVG_String*)info.far_ptr = gf_strdup("application/ecmascript"); break; - case 1: *(SVG_String*)info.far_ptr = gf_strdup("application/jar-archive"); break; - default: break; + case 0: + *(SVG_String*)info.far_ptr = gf_strdup("application/ecmascript"); + break; + case 1: + *(SVG_String*)info.far_ptr = gf_strdup("application/jar-archive"); + break; + default: + break; } } else { lsr_read_byte_align_string(lsr, info.far_ptr, "type"); @@ -2760,14 +2893,28 @@ static void lsr_read_value_with_units(GF_LASeRCodec *lsr, SVG_Number *n, const c n->value = INT2FIX(val) / (1<<8); #endif GF_LSR_READ_INT(lsr, val, 3, "units"); - switch (val) { - case 1: n->type = SVG_NUMBER_IN; break; - case 2: n->type = SVG_NUMBER_CM; break; - case 3: n->type = SVG_NUMBER_MM; break; - case 4: n->type = SVG_NUMBER_PT; break; - case 5: n->type = SVG_NUMBER_PC; break; - case 6: n->type = SVG_NUMBER_PERCENTAGE; break; - default: n->type = SVG_NUMBER_VALUE; break; + switch (val) { + case 1: + n->type = SVG_NUMBER_IN; + break; + case 2: + n->type = SVG_NUMBER_CM; + break; + case 3: + n->type = SVG_NUMBER_MM; + break; + case 4: + n->type = SVG_NUMBER_PT; + break; + case 5: + n->type = SVG_NUMBER_PC; + break; + case 6: + n->type = SVG_NUMBER_PERCENTAGE; + break; + default: + n->type = SVG_NUMBER_VALUE; + break; } } @@ -2815,16 +2962,36 @@ static void lsr_read_preserve_aspect_ratio(GF_LASeRCodec *lsr, GF_Node *n) GF_LSR_READ_INT(lsr, par->defer, 1, "choice (defer)"); GF_LSR_READ_INT(lsr, flag, 4, "alignXandY"); switch (flag) { - case 1: par->align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; break; - case 2: par->align = SVG_PRESERVEASPECTRATIO_XMAXYMID; break; - case 3: par->align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; break; - case 4: par->align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; break; - case 5: par->align = SVG_PRESERVEASPECTRATIO_XMIDYMID; break; - case 6: par->align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; break; - case 7: par->align = SVG_PRESERVEASPECTRATIO_XMINYMAX; break; - case 8: par->align = SVG_PRESERVEASPECTRATIO_XMINYMID; break; - case 9: par->align = SVG_PRESERVEASPECTRATIO_XMINYMIN; break; - default: par->align = SVG_PRESERVEASPECTRATIO_NONE; break; + case 1: + par->align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; + break; + case 2: + par->align = SVG_PRESERVEASPECTRATIO_XMAXYMID; + break; + case 3: + par->align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; + break; + case 4: + par->align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; + break; + case 5: + par->align = SVG_PRESERVEASPECTRATIO_XMIDYMID; + break; + case 6: + par->align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; + break; + case 7: + par->align = SVG_PRESERVEASPECTRATIO_XMINYMAX; + break; + case 8: + par->align = SVG_PRESERVEASPECTRATIO_XMINYMID; + break; + case 9: + par->align = SVG_PRESERVEASPECTRATIO_XMINYMIN; + break; + default: + par->align = SVG_PRESERVEASPECTRATIO_NONE; + break; } } @@ -2964,11 +3131,21 @@ static GF_Node *lsr_read_animateTransform(GF_LASeRCodec *lsr, SVG_Element *paren /*enumeration rotate{0} scale{1} skewX{2} skewY{3} translate{4}*/ GF_LSR_READ_INT(lsr, flag, 3, "rotscatra"); switch (flag) { - case 0: type = SVG_TRANSFORM_ROTATE; break; - case 1: type = SVG_TRANSFORM_SCALE; break; - case 2: type = SVG_TRANSFORM_SKEWX; break; - case 3: type = SVG_TRANSFORM_SKEWY; break; - case 4: type = SVG_TRANSFORM_TRANSLATE; break; + case 0: + type = SVG_TRANSFORM_ROTATE; + break; + case 1: + type = SVG_TRANSFORM_SCALE; + break; + case 2: + type = SVG_TRANSFORM_SKEWX; + break; + case 3: + type = SVG_TRANSFORM_SKEWY; + break; + case 4: + type = SVG_TRANSFORM_TRANSLATE; + break; } if (gf_node_get_attribute_by_tag(elt, TAG_SVG_ATT_transform_type, 1, 0, &info)==GF_OK) { *(SVG_TransformType *)info.far_ptr = type; @@ -3120,15 +3297,15 @@ static GF_Node *lsr_read_foreignObject(GF_LASeRCodec *lsr) lsr_read_coordinate_ptr(lsr, elt, TAG_SVG_ATT_y, 1, "y"); lsr_read_any_attribute(lsr, elt, 1); -/* TODO - bit(1) opt_group; - if(opt_group) { - vluimsbf5 occ1; - for(int t=0;tlast_error = gf_node_get_attribute_by_tag(elt, TAG_SVG_ATT_syncBehaviorDefault, 1, 0, &info); GF_LSR_READ_INT(lsr, flag, 2, "syncBehaviorDefault"); switch (flag) { - case 0: *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_CANSLIP; break; - case 1: *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_INDEPENDENT; break; - case 3: *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_LOCKED; break; - default: *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_INHERIT; break; + case 0: + *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_CANSLIP; + break; + case 1: + *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_INDEPENDENT; + break; + case 3: + *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_LOCKED; + break; + default: + *((SMIL_SyncBehavior*)info.far_ptr) = SMIL_SYNCBEHAVIOR_INHERIT; + break; } } GF_LSR_READ_INT(lsr, flag, 1, "hasSyncToleranceDefault"); @@ -3542,7 +3727,7 @@ static GF_Node *lsr_read_svg(GF_LASeRCodec *lsr, Bool init_node) lsr->last_error = gf_node_get_attribute_by_tag(elt, TAG_SVG_ATT_syncToleranceDefault, 1, 0, &info); ((SMIL_SyncTolerance*)info.far_ptr)->type = SMIL_SYNCTOLERANCE_VALUE; GF_LSR_READ_INT(lsr, flag, 1, "choice"); - ((SMIL_SyncTolerance*)info.far_ptr)->value = lsr_read_vluimsbf5(lsr, "value"); + ((SMIL_SyncTolerance*)info.far_ptr)->value = lsr_read_vluimsbf5(lsr, "value"); ((SMIL_SyncTolerance*)info.far_ptr)->value /= lsr->time_resolution; } GF_LSR_READ_INT(lsr, flag, 1, "hasTimelineBegin"); @@ -3835,61 +4020,171 @@ static GF_Node *lsr_read_scene_content_model(GF_LASeRCodec *lsr, SVG_Element *pa GF_LSR_READ_INT(lsr, ntype, 6, "ch4"); n = NULL; switch (ntype) { - case LSR_SCENE_CONTENT_MODEL_a: n = lsr_read_a(lsr); break; - case LSR_SCENE_CONTENT_MODEL_animate: n = lsr_read_animate(lsr, parent, 0); break; - case LSR_SCENE_CONTENT_MODEL_animateColor: n = lsr_read_animate(lsr, parent, 1); break; - case LSR_SCENE_CONTENT_MODEL_animateMotion: n = lsr_read_animateMotion(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_animateTransform: n = lsr_read_animateTransform(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_audio: n = lsr_read_audio(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_circle: n = lsr_read_circle(lsr); break; - case LSR_SCENE_CONTENT_MODEL_conditional: n = lsr_read_conditional(lsr); break; - case LSR_SCENE_CONTENT_MODEL_cursorManager: n = lsr_read_cursorManager(lsr); break; - case LSR_SCENE_CONTENT_MODEL_defs: n = lsr_read_defs(lsr); break; - case LSR_SCENE_CONTENT_MODEL_desc: n = lsr_read_data(lsr, TAG_SVG_desc); break; - case LSR_SCENE_CONTENT_MODEL_ellipse: n = lsr_read_ellipse(lsr); break; - case LSR_SCENE_CONTENT_MODEL_foreignObject: n = lsr_read_foreignObject(lsr); break; - case LSR_SCENE_CONTENT_MODEL_g: n = lsr_read_g(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_image: n = lsr_read_image(lsr); break; - case LSR_SCENE_CONTENT_MODEL_line: n = lsr_read_line(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_linearGradient: n = lsr_read_linearGradient(lsr); break; - case LSR_SCENE_CONTENT_MODEL_metadata: n = lsr_read_data(lsr, TAG_SVG_metadata); break; - case LSR_SCENE_CONTENT_MODEL_mpath: n = lsr_read_mpath(lsr); break; - case LSR_SCENE_CONTENT_MODEL_path: n = lsr_read_path(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_polygon: n = lsr_read_polygon(lsr, 0, 0); break; - case LSR_SCENE_CONTENT_MODEL_polyline: n = lsr_read_polygon(lsr, 1, 0); break; - case LSR_SCENE_CONTENT_MODEL_radialGradient: n = lsr_read_radialGradient(lsr); break; - case LSR_SCENE_CONTENT_MODEL_rect: n = lsr_read_rect(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_rectClip: n = lsr_read_rectClip(lsr); break; - case LSR_SCENE_CONTENT_MODEL_sameg: n = lsr_read_g(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_sameline: n = lsr_read_line(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_samepath: n = lsr_read_path(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_samepathfill: n = lsr_read_path(lsr, 2); break; - case LSR_SCENE_CONTENT_MODEL_samepolygon: n = lsr_read_polygon(lsr, 0, 1); break; - case LSR_SCENE_CONTENT_MODEL_samepolygonfill: n = lsr_read_polygon(lsr, 0, 2); break; - case LSR_SCENE_CONTENT_MODEL_samepolygonstroke: n = lsr_read_polygon(lsr, 0, 3); break; - case LSR_SCENE_CONTENT_MODEL_samepolyline: n = lsr_read_polygon(lsr, 1, 1); break; - case LSR_SCENE_CONTENT_MODEL_samepolylinefill: n = lsr_read_polygon(lsr, 1, 2); break; - case LSR_SCENE_CONTENT_MODEL_samepolylinestroke: n = lsr_read_polygon(lsr, 1, 3); break; - case LSR_SCENE_CONTENT_MODEL_samerect: n = lsr_read_rect(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_samerectfill: n = lsr_read_rect(lsr, 2); break; - case LSR_SCENE_CONTENT_MODEL_sametext: n = lsr_read_text(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_sametextfill: n = lsr_read_text(lsr, 2); break; - case LSR_SCENE_CONTENT_MODEL_sameuse: n = lsr_read_use(lsr, 1); break; - case LSR_SCENE_CONTENT_MODEL_script: n = lsr_read_script(lsr); break; - case LSR_SCENE_CONTENT_MODEL_selector: n = lsr_read_selector(lsr); break; - case LSR_SCENE_CONTENT_MODEL_set: n = lsr_read_set(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_simpleLayout: n = lsr_read_simpleLayout(lsr); break; - case LSR_SCENE_CONTENT_MODEL_stop: n = lsr_read_stop(lsr); break; - case LSR_SCENE_CONTENT_MODEL_switch: n = lsr_read_switch(lsr); break; - case LSR_SCENE_CONTENT_MODEL_text: n = lsr_read_text(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_title: n = lsr_read_data(lsr, TAG_SVG_title); break; - case LSR_SCENE_CONTENT_MODEL_tspan: n = lsr_read_tspan(lsr); break; - case LSR_SCENE_CONTENT_MODEL_use: n = lsr_read_use(lsr, 0); break; - case LSR_SCENE_CONTENT_MODEL_video: n = lsr_read_video(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_listener: n = lsr_read_listener(lsr, parent); break; - case LSR_SCENE_CONTENT_MODEL_element_any: lsr_read_extend_class(lsr, NULL, 0, "node"); break; - case LSR_SCENE_CONTENT_MODEL_privateContainer: lsr_read_private_element_container(lsr); break; - case LSR_SCENE_CONTENT_MODEL_textContent: lsr_read_text_content(lsr, (GF_Node*)parent); break; + case LSR_SCENE_CONTENT_MODEL_a: + n = lsr_read_a(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_animate: + n = lsr_read_animate(lsr, parent, 0); + break; + case LSR_SCENE_CONTENT_MODEL_animateColor: + n = lsr_read_animate(lsr, parent, 1); + break; + case LSR_SCENE_CONTENT_MODEL_animateMotion: + n = lsr_read_animateMotion(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_animateTransform: + n = lsr_read_animateTransform(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_audio: + n = lsr_read_audio(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_circle: + n = lsr_read_circle(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_conditional: + n = lsr_read_conditional(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_cursorManager: + n = lsr_read_cursorManager(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_defs: + n = lsr_read_defs(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_desc: + n = lsr_read_data(lsr, TAG_SVG_desc); + break; + case LSR_SCENE_CONTENT_MODEL_ellipse: + n = lsr_read_ellipse(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_foreignObject: + n = lsr_read_foreignObject(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_g: + n = lsr_read_g(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_image: + n = lsr_read_image(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_line: + n = lsr_read_line(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_linearGradient: + n = lsr_read_linearGradient(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_metadata: + n = lsr_read_data(lsr, TAG_SVG_metadata); + break; + case LSR_SCENE_CONTENT_MODEL_mpath: + n = lsr_read_mpath(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_path: + n = lsr_read_path(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_polygon: + n = lsr_read_polygon(lsr, 0, 0); + break; + case LSR_SCENE_CONTENT_MODEL_polyline: + n = lsr_read_polygon(lsr, 1, 0); + break; + case LSR_SCENE_CONTENT_MODEL_radialGradient: + n = lsr_read_radialGradient(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_rect: + n = lsr_read_rect(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_rectClip: + n = lsr_read_rectClip(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_sameg: + n = lsr_read_g(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_sameline: + n = lsr_read_line(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_samepath: + n = lsr_read_path(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_samepathfill: + n = lsr_read_path(lsr, 2); + break; + case LSR_SCENE_CONTENT_MODEL_samepolygon: + n = lsr_read_polygon(lsr, 0, 1); + break; + case LSR_SCENE_CONTENT_MODEL_samepolygonfill: + n = lsr_read_polygon(lsr, 0, 2); + break; + case LSR_SCENE_CONTENT_MODEL_samepolygonstroke: + n = lsr_read_polygon(lsr, 0, 3); + break; + case LSR_SCENE_CONTENT_MODEL_samepolyline: + n = lsr_read_polygon(lsr, 1, 1); + break; + case LSR_SCENE_CONTENT_MODEL_samepolylinefill: + n = lsr_read_polygon(lsr, 1, 2); + break; + case LSR_SCENE_CONTENT_MODEL_samepolylinestroke: + n = lsr_read_polygon(lsr, 1, 3); + break; + case LSR_SCENE_CONTENT_MODEL_samerect: + n = lsr_read_rect(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_samerectfill: + n = lsr_read_rect(lsr, 2); + break; + case LSR_SCENE_CONTENT_MODEL_sametext: + n = lsr_read_text(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_sametextfill: + n = lsr_read_text(lsr, 2); + break; + case LSR_SCENE_CONTENT_MODEL_sameuse: + n = lsr_read_use(lsr, 1); + break; + case LSR_SCENE_CONTENT_MODEL_script: + n = lsr_read_script(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_selector: + n = lsr_read_selector(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_set: + n = lsr_read_set(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_simpleLayout: + n = lsr_read_simpleLayout(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_stop: + n = lsr_read_stop(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_switch: + n = lsr_read_switch(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_text: + n = lsr_read_text(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_title: + n = lsr_read_data(lsr, TAG_SVG_title); + break; + case LSR_SCENE_CONTENT_MODEL_tspan: + n = lsr_read_tspan(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_use: + n = lsr_read_use(lsr, 0); + break; + case LSR_SCENE_CONTENT_MODEL_video: + n = lsr_read_video(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_listener: + n = lsr_read_listener(lsr, parent); + break; + case LSR_SCENE_CONTENT_MODEL_element_any: + lsr_read_extend_class(lsr, NULL, 0, "node"); + break; + case LSR_SCENE_CONTENT_MODEL_privateContainer: + lsr_read_private_element_container(lsr); + break; + case LSR_SCENE_CONTENT_MODEL_textContent: + lsr_read_text_content(lsr, (GF_Node*)parent); + break; default: break; } @@ -3911,9 +4206,11 @@ static GF_Node *lsr_read_update_content_model(GF_LASeRCodec *lsr, SVG_Element *p GF_LSR_READ_INT(lsr, flag, 3, "ch61"); switch (flag) { case LSR_UPDATE_CONTENT_MODEL2_conditional: - n = lsr_read_conditional(lsr); break; + n = lsr_read_conditional(lsr); + break; case LSR_UPDATE_CONTENT_MODEL2_cursorManager: - n = lsr_read_cursorManager(lsr); break; + n = lsr_read_cursorManager(lsr); + break; case LSR_UPDATE_CONTENT_MODEL2_extend: lsr_read_extend_class(lsr, NULL, 0, "extend"); return NULL; @@ -3921,48 +4218,117 @@ static GF_Node *lsr_read_update_content_model(GF_LASeRCodec *lsr, SVG_Element *p lsr_read_private_element_container(lsr); return NULL; case LSR_UPDATE_CONTENT_MODEL2_rectClip: - n = lsr_read_rectClip(lsr); break; + n = lsr_read_rectClip(lsr); + break; case LSR_UPDATE_CONTENT_MODEL2_simpleLayout: - n = lsr_read_simpleLayout(lsr); break; + n = lsr_read_simpleLayout(lsr); + break; case LSR_UPDATE_CONTENT_MODEL2_selector: - n = lsr_read_selector(lsr); break; + n = lsr_read_selector(lsr); + break; } } else { GF_LSR_READ_INT(lsr, flag, 6, "ch6"); switch(flag) { - case LSR_UPDATE_CONTENT_MODEL_a: n = lsr_read_a(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_animate: n = lsr_read_animate(lsr, parent, 0); break; - case LSR_UPDATE_CONTENT_MODEL_animateColor: n = lsr_read_animate(lsr, parent, 1); break; - case LSR_UPDATE_CONTENT_MODEL_animateMotion: n = lsr_read_animateMotion(lsr, parent); break; - case LSR_UPDATE_CONTENT_MODEL_animateTransform: n = lsr_read_animateTransform(lsr, parent); break; - case LSR_UPDATE_CONTENT_MODEL_audio: n = lsr_read_audio(lsr, parent); break; - case LSR_UPDATE_CONTENT_MODEL_circle: n = lsr_read_circle(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_defs: n = lsr_read_defs(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_desc: n = lsr_read_data(lsr, TAG_SVG_desc); break; - case LSR_UPDATE_CONTENT_MODEL_ellipse: n = lsr_read_ellipse(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_foreignObject: n = lsr_read_foreignObject(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_g: n = lsr_read_g(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_image: n = lsr_read_image(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_line: n = lsr_read_line(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_linearGradient: n = lsr_read_linearGradient(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_metadata: n = lsr_read_data(lsr, TAG_SVG_metadata); break; - case LSR_UPDATE_CONTENT_MODEL_mpath: n = lsr_read_mpath(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_path: n = lsr_read_path(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_polygon: n = lsr_read_polygon(lsr, 0, 0); break; - case LSR_UPDATE_CONTENT_MODEL_polyline: n = lsr_read_polygon(lsr, 1, 0); break; - case LSR_UPDATE_CONTENT_MODEL_radialGradient: n = lsr_read_radialGradient(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_rect: n = lsr_read_rect(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_script: n = lsr_read_script(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_set: n = lsr_read_set(lsr, parent); break; - case LSR_UPDATE_CONTENT_MODEL_stop: n = lsr_read_stop(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_svg: n = lsr_read_svg(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_switch: n = lsr_read_switch(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_text: n = lsr_read_text(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_title: n = lsr_read_data(lsr, TAG_SVG_title); break; - case LSR_UPDATE_CONTENT_MODEL_tspan: n = lsr_read_tspan(lsr); break; - case LSR_UPDATE_CONTENT_MODEL_use: n = lsr_read_use(lsr, 0); break; - case LSR_UPDATE_CONTENT_MODEL_video: n = lsr_read_video(lsr, parent); break; - case LSR_UPDATE_CONTENT_MODEL_listener: n = lsr_read_listener(lsr, parent); break; + case LSR_UPDATE_CONTENT_MODEL_a: + n = lsr_read_a(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_animate: + n = lsr_read_animate(lsr, parent, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_animateColor: + n = lsr_read_animate(lsr, parent, 1); + break; + case LSR_UPDATE_CONTENT_MODEL_animateMotion: + n = lsr_read_animateMotion(lsr, parent); + break; + case LSR_UPDATE_CONTENT_MODEL_animateTransform: + n = lsr_read_animateTransform(lsr, parent); + break; + case LSR_UPDATE_CONTENT_MODEL_audio: + n = lsr_read_audio(lsr, parent); + break; + case LSR_UPDATE_CONTENT_MODEL_circle: + n = lsr_read_circle(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_defs: + n = lsr_read_defs(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_desc: + n = lsr_read_data(lsr, TAG_SVG_desc); + break; + case LSR_UPDATE_CONTENT_MODEL_ellipse: + n = lsr_read_ellipse(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_foreignObject: + n = lsr_read_foreignObject(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_g: + n = lsr_read_g(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_image: + n = lsr_read_image(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_line: + n = lsr_read_line(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_linearGradient: + n = lsr_read_linearGradient(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_metadata: + n = lsr_read_data(lsr, TAG_SVG_metadata); + break; + case LSR_UPDATE_CONTENT_MODEL_mpath: + n = lsr_read_mpath(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_path: + n = lsr_read_path(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_polygon: + n = lsr_read_polygon(lsr, 0, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_polyline: + n = lsr_read_polygon(lsr, 1, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_radialGradient: + n = lsr_read_radialGradient(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_rect: + n = lsr_read_rect(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_script: + n = lsr_read_script(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_set: + n = lsr_read_set(lsr, parent); + break; + case LSR_UPDATE_CONTENT_MODEL_stop: + n = lsr_read_stop(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_svg: + n = lsr_read_svg(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_switch: + n = lsr_read_switch(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_text: + n = lsr_read_text(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_title: + n = lsr_read_data(lsr, TAG_SVG_title); + break; + case LSR_UPDATE_CONTENT_MODEL_tspan: + n = lsr_read_tspan(lsr); + break; + case LSR_UPDATE_CONTENT_MODEL_use: + n = lsr_read_use(lsr, 0); + break; + case LSR_UPDATE_CONTENT_MODEL_video: + n = lsr_read_video(lsr, parent); + break; + case LSR_UPDATE_CONTENT_MODEL_listener: + n = lsr_read_listener(lsr, parent); + break; } } if (n && n->sgprivate->interact && n->sgprivate->interact->dom_evt) { @@ -4040,35 +4406,35 @@ static void *lsr_read_update_value_indexed(GF_LASeRCodec *lsr, GF_Node*node, u32 SVG_Point *pt; SVG_Number num; - switch (fieldType) { - case SVG_Points_datatype/*ITYPE_point*/: + switch (fieldType) { + case SVG_Points_datatype/*ITYPE_point*/: pt = (SVG_Point*)gf_malloc(sizeof(SVG_Point)); - lsr_read_coordinate(lsr, &num, 0, "coordX"); + lsr_read_coordinate(lsr, &num, 0, "coordX"); pt->x = num.value; - lsr_read_coordinate(lsr, &num, 0, "coordY"); + lsr_read_coordinate(lsr, &num, 0, "coordY"); pt->y = num.value; - return pt; - case SMIL_KeySplines_datatype/*ITYPE_float*/: + return pt; + case SMIL_KeySplines_datatype/*ITYPE_float*/: case SVG_StrokeDashArray_datatype: case SVG_ViewBox_datatype: - f_val = (Fixed*)gf_malloc(sizeof(Fixed)); + f_val = (Fixed*)gf_malloc(sizeof(Fixed)); *f_val = lsr_read_fixed_16_8(lsr, "floatValue"); - return f_val; - case SMIL_KeyTimes_datatype/*ITYPE_keyTime*/: + return f_val; + case SMIL_KeyTimes_datatype/*ITYPE_keyTime*/: f_val = lsr_read_fraction_12_item(lsr); - break; - case SMIL_KeyPoints_datatype/*ITYPE_0to1 - keyPoints*/: + break; + case SMIL_KeyPoints_datatype/*ITYPE_0to1 - keyPoints*/: pt = (SVG_Point*)gf_malloc(sizeof(SVG_Point)); pt->x = lsr_read_fixed_clamp(lsr, "valueX"); - f_val = (Fixed*)gf_malloc(sizeof(Fixed)); + f_val = (Fixed*)gf_malloc(sizeof(Fixed)); pt->y = lsr_read_fixed_clamp(lsr, "valueY"); return pt; - case SMIL_Times_datatype/*ITYPE_smil_time*/: + case SMIL_Times_datatype/*ITYPE_smil_time*/: return lsr_read_smil_time(lsr, node); - default: - lsr_read_extension(lsr, "privateData"); - break; - } + default: + lsr_read_extension(lsr, "privateData"); + break; + } return NULL; } @@ -4085,17 +4451,17 @@ static void lsr_read_update_value(GF_LASeRCodec *lsr, GF_Node *node, u32 att_tag case SVG_Paint_datatype: lsr_read_paint(lsr, (SVG_Paint*)val, "val"); break; -/* - case SVG_AudioLevel_datatype: - n = val; - GF_LSR_READ_INT(lsr, is_default, 1, "isDefaultValue"); - if (is_default) n->type=SVG_NUMBER_INHERIT; - else { - n->type = SVG_NUMBER_VALUE; - n->value = lsr_read_fixed_clamp(lsr, "val"); - } - break; -*/ + /* + case SVG_AudioLevel_datatype: + n = val; + GF_LSR_READ_INT(lsr, is_default, 1, "isDefaultValue"); + if (is_default) n->type=SVG_NUMBER_INHERIT; + else { + n->type = SVG_NUMBER_VALUE; + n->value = lsr_read_fixed_clamp(lsr, "val"); + } + break; + */ case SVG_Transform_Scale_datatype: ((SVG_Point *)val)->x = lsr_read_fixed_16_8(lsr, "scale_x"); ((SVG_Point *)val)->y = lsr_read_fixed_16_8(lsr, "scale_y"); @@ -4204,13 +4570,24 @@ static void lsr_read_update_value(GF_LASeRCodec *lsr, GF_Node *node, u32 att_tag vb->is_set = 1; GF_LSR_READ_INT(lsr, count, 1, "escapeFlag"); count = lsr_read_vluimsbf5(lsr, "count"); - if (count) { vb->x = lsr_read_fixed_16_8(lsr, "val"); count--; } - if (count) { vb->y = lsr_read_fixed_16_8(lsr, "val"); count--; } - if (count) { vb->width = lsr_read_fixed_16_8(lsr, "val"); count--; } - if (count) { vb->height = lsr_read_fixed_16_8(lsr, "val"); } + if (count) { + vb->x = lsr_read_fixed_16_8(lsr, "val"); + count--; + } + if (count) { + vb->y = lsr_read_fixed_16_8(lsr, "val"); + count--; + } + if (count) { + vb->width = lsr_read_fixed_16_8(lsr, "val"); + count--; + } + if (count) { + vb->height = lsr_read_fixed_16_8(lsr, "val"); + } } } - break; + break; case XMLRI_datatype: case SVG_Focus_datatype: if ((att_tag==TAG_XLINK_ATT_href) || (att_tag==TAG_SVG_ATT_syncReference)) { @@ -4283,8 +4660,8 @@ static void lsr_read_update_value(GF_LASeRCodec *lsr, GF_Node *node, u32 att_tag } } } - break; - break; + break; + break; case LASeR_Choice_datatype: GF_LSR_READ_INT(lsr, is_default, 1, "isDefaultValue"); if (is_default) ((LASeR_Choice *)val)->type = LASeR_CHOICE_ALL; @@ -4503,13 +4880,19 @@ static GF_Err lsr_read_add_replace_insert(GF_LASeRCodec *lsr, GF_List *com_list, break; /*matrix.translation, scale or rotate*/ case LSR_UPDATE_TYPE_SCALE: - info.far_ptr = (void *)&matrix_tmp; field_type = SVG_Transform_Scale_datatype; is_lsr_transform = 1; + info.far_ptr = (void *)&matrix_tmp; + field_type = SVG_Transform_Scale_datatype; + is_lsr_transform = 1; break; case LSR_UPDATE_TYPE_ROTATE: - info.far_ptr = (void *)&matrix_tmp_rot; field_type = SVG_Transform_Rotate_datatype; is_lsr_transform = 1; + info.far_ptr = (void *)&matrix_tmp_rot; + field_type = SVG_Transform_Rotate_datatype; + is_lsr_transform = 1; break; case LSR_UPDATE_TYPE_TRANSLATION: - info.far_ptr = (void *)&matrix_tmp; field_type = SVG_Transform_Translate_datatype; is_lsr_transform = 1; + info.far_ptr = (void *)&matrix_tmp; + field_type = SVG_Transform_Translate_datatype; + is_lsr_transform = 1; break; default: fieldIndex = gf_lsr_anim_type_to_attribute(att_type); @@ -4618,10 +5001,18 @@ static GF_Err lsr_read_add_replace_insert(GF_LASeRCodec *lsr, GF_List *com_list, case SVG_ViewBox_datatype: v1 = (Fixed*)tmp; switch (idx) { - case 0: ((SVG_ViewBox*)info.far_ptr)->x = *v1; break; - case 1: ((SVG_ViewBox*)info.far_ptr)->y = *v1; break; - case 2: ((SVG_ViewBox*)info.far_ptr)->width = *v1; break; - case 3: ((SVG_ViewBox*)info.far_ptr)->height = *v1; break; + case 0: + ((SVG_ViewBox*)info.far_ptr)->x = *v1; + break; + case 1: + ((SVG_ViewBox*)info.far_ptr)->y = *v1; + break; + case 2: + ((SVG_ViewBox*)info.far_ptr)->width = *v1; + break; + case 3: + ((SVG_ViewBox*)info.far_ptr)->height = *v1; + break; } gf_free(tmp); gf_node_changed((GF_Node*)n, NULL); @@ -5069,7 +5460,7 @@ static GF_Err lsr_read_command_list(GF_LASeRCodec *lsr, GF_List *com_list, SVG_E } } } - break; + break; default: return (lsr->last_error = GF_NON_COMPLIANT_BITSTREAM); } @@ -5196,7 +5587,7 @@ static GF_Err lsr_decode_laser_unit(GF_LASeRCodec *lsr, GF_List *com_list) } GF_LSR_READ_INT(lsr, flag, 1, "hasAttrs"); if (flag) { - u32 k, c2 = lsr_read_vluimsbf5(lsr, "nbAttrNames"); + u32 k, c2 = lsr_read_vluimsbf5(lsr, "nbAttrNames"); for (k=0; kbs, _val, _nbBits); \ GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[LASeR] %s\t\t%d\t\t%d\n", _str, _nbBits, _val)); \ }\ - + static void lsr_write_group_content(GF_LASeRCodec *lsr, SVG_Element *elt, Bool skip_object_content); static GF_Err lsr_write_command_list(GF_LASeRCodec *lsr, GF_List *comList, SVG_Element *script, Bool first_implicit); static GF_Err lsr_write_laser_unit(GF_LASeRCodec *lsr, GF_List *com_list, Bool reset_encoding_context); @@ -516,7 +516,7 @@ static Bool lsr_float_list_equal(GF_List *l1, GF_List *l2) { u32 i, count = gf_list_count(l1); if (count != gf_list_count(l2)) return 0; - for (i=0;iinfo->cfg.extensionIDBits, "reserved"); - lsr_write_vluimsbf5(lsr, 0, "len");//len in BITS - GF_LSR_WRITE_INT(lsr, 0, 0, "reserved_val"); - } while () -*/ + /* + do () { + GF_LSR_WRITE_INT(lsr, 0, lsr->info->cfg.extensionIDBits, "reserved"); + lsr_write_vluimsbf5(lsr, 0, "len");//len in BITS + GF_LSR_WRITE_INT(lsr, 0, 0, "reserved_val"); + } while () + */ } } @@ -568,11 +568,11 @@ static void lsr_write_id(GF_LASeRCodec *lsr, GF_Node *n) u32 id = gf_node_get_id(n); if (id) { GF_LSR_WRITE_INT(lsr, 1, 1, "has_id"); - lsr_write_vluimsbf5(lsr, id-1, "ID"); + lsr_write_vluimsbf5(lsr, id-1, "ID"); #if TODO_LASER_EXTENSIONS if (0) { GF_LSR_WRITE_INT(lsr, 1, 1, "reserved"); - lsr_write_vluimsbf5(lsr, reserved_len, "len"); + lsr_write_vluimsbf5(lsr, reserved_len, "len"); GF_LSR_WRITE_INT(lsr, 0, reserved_len, "reserved"); } else #endif @@ -602,7 +602,7 @@ static u32 lsr_translate_coords(GF_LASeRCodec *lsr, Fixed x, u32 nb_bits) return (u32) res; } res += 1<<(nb_bits); - if (res<=max){ + if (res<=max) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[LASeR] nb_bits %d not large enough to encode negative number %g!\n", nb_bits, FIX2FLT(x) )); res = max+1; } @@ -687,21 +687,36 @@ static void lsr_write_fixed_clamp(GF_LASeRCodec *lsr, Fixed f, const char *name) u32 dom_to_lsr_key(u32 dom_k) { switch (dom_k) { - case GF_KEY_STAR: return 0; - case GF_KEY_0: return 1; - case GF_KEY_1: return 2; - case GF_KEY_2: return 3; - case GF_KEY_3: return 4; - case GF_KEY_4: return 5; - case GF_KEY_5: return 6; - case GF_KEY_6: return 7; - case GF_KEY_7: return 8; - case GF_KEY_8: return 9; - case GF_KEY_9: return 10; - case GF_KEY_DOWN: return 12; - case GF_KEY_LEFT: return 14; - case GF_KEY_RIGHT: return 16; - case GF_KEY_UP: return 20; + case GF_KEY_STAR: + return 0; + case GF_KEY_0: + return 1; + case GF_KEY_1: + return 2; + case GF_KEY_2: + return 3; + case GF_KEY_3: + return 4; + case GF_KEY_4: + return 5; + case GF_KEY_5: + return 6; + case GF_KEY_6: + return 7; + case GF_KEY_7: + return 8; + case GF_KEY_8: + return 9; + case GF_KEY_9: + return 10; + case GF_KEY_DOWN: + return 12; + case GF_KEY_LEFT: + return 14; + case GF_KEY_RIGHT: + return 16; + case GF_KEY_UP: + return 20; /*WHAT IS ANY_KEY (11) ??*/ case GF_KEY_ENTER: case GF_KEY_EXECUTE: @@ -754,76 +769,108 @@ static void lsr_write_event_type(GF_LASeRCodec *lsr, u32 evtType, u32 evtParam) GF_LSR_WRITE_INT(lsr, 1, 1, "choice"); switch (evtType) { case GF_EVENT_ABORT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_abort, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_abort, 6, "event"); + break; case GF_EVENT_ACTIVATE: - GF_LSR_WRITE_INT(lsr, LSR_EVT_activate, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_activate, 6, "event"); + break; case GF_EVENT_ACTIVATED: - GF_LSR_WRITE_INT(lsr, LSR_EVT_activatedEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_activatedEvent, 6, "event"); + break; case GF_EVENT_BEGIN:/*SPEC IS BROKEN, CANNOT ENCODE elt.begin !! */ case GF_EVENT_BEGIN_EVENT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_beginEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_beginEvent, 6, "event"); + break; case GF_EVENT_CLICK: - GF_LSR_WRITE_INT(lsr, LSR_EVT_click, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_click, 6, "event"); + break; case GF_EVENT_DEACTIVATED: - GF_LSR_WRITE_INT(lsr, LSR_EVT_deactivatedEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_deactivatedEvent, 6, "event"); + break; case GF_EVENT_END:/*SPEC IS BROKEN, CANNOT ENCODE elt.end !! */ case GF_EVENT_END_EVENT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_endEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_endEvent, 6, "event"); + break; case GF_EVENT_ERROR: - GF_LSR_WRITE_INT(lsr, LSR_EVT_error, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_error, 6, "event"); + break; case GF_EVENT_EXECUTION_TIME: - GF_LSR_WRITE_INT(lsr, LSR_EVT_executionTime, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_executionTime, 6, "event"); + break; case GF_EVENT_FOCUSIN: - GF_LSR_WRITE_INT(lsr, LSR_EVT_focusin, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_focusin, 6, "event"); + break; case GF_EVENT_FOCUSOUT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_focusout, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_focusout, 6, "event"); + break; case GF_EVENT_KEYDOWN: /*encode as accessKey() if param*/ GF_LSR_WRITE_INT(lsr, evtParam ? LSR_EVT_accessKey : LSR_EVT_keydown, 6, "event"); break; case GF_EVENT_KEYUP: - GF_LSR_WRITE_INT(lsr, LSR_EVT_keyup, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_keyup, 6, "event"); + break; case GF_EVENT_LOAD: - GF_LSR_WRITE_INT(lsr, LSR_EVT_load, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_load, 6, "event"); + break; case GF_EVENT_LONGKEYPRESS: - GF_LSR_WRITE_INT(lsr, LSR_EVT_longAccessKey, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_longAccessKey, 6, "event"); + break; case GF_EVENT_MOUSEDOWN: - GF_LSR_WRITE_INT(lsr, LSR_EVT_mousedown, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_mousedown, 6, "event"); + break; case GF_EVENT_MOUSEMOVE: - GF_LSR_WRITE_INT(lsr, LSR_EVT_mousemove, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_mousemove, 6, "event"); + break; case GF_EVENT_MOUSEOUT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseout, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseout, 6, "event"); + break; case GF_EVENT_MOUSEOVER: - GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseover, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseover, 6, "event"); + break; case GF_EVENT_MOUSEUP: - GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseup, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_mouseup, 6, "event"); + break; case GF_EVENT_PAUSE: - GF_LSR_WRITE_INT(lsr, LSR_EVT_pause, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_pause, 6, "event"); + break; case GF_EVENT_PAUSED_EVENT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_pausedEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_pausedEvent, 6, "event"); + break; case GF_EVENT_PLAY: - GF_LSR_WRITE_INT(lsr, LSR_EVT_play, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_play, 6, "event"); + break; case GF_EVENT_REPEAT_EVENT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_repeatEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_repeatEvent, 6, "event"); + break; case GF_EVENT_REPEAT_KEY: - GF_LSR_WRITE_INT(lsr, LSR_EVT_repeatKey, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_repeatKey, 6, "event"); + break; case GF_EVENT_RESIZE: - GF_LSR_WRITE_INT(lsr, LSR_EVT_resize, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_resize, 6, "event"); + break; case GF_EVENT_RESUME_EVENT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_resumedEvent, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_resumedEvent, 6, "event"); + break; case GF_EVENT_SCROLL: - GF_LSR_WRITE_INT(lsr, LSR_EVT_scroll, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_scroll, 6, "event"); + break; case GF_EVENT_SHORT_ACCESSKEY: - GF_LSR_WRITE_INT(lsr, LSR_EVT_shortAccessKey, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_shortAccessKey, 6, "event"); + break; case GF_EVENT_TEXTINPUT: - GF_LSR_WRITE_INT(lsr, LSR_EVT_textinput, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_textinput, 6, "event"); + break; case GF_EVENT_UNLOAD: - GF_LSR_WRITE_INT(lsr, LSR_EVT_unload, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_unload, 6, "event"); + break; case GF_EVENT_ZOOM: - GF_LSR_WRITE_INT(lsr, LSR_EVT_zoom, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, LSR_EVT_zoom, 6, "event"); + break; default: GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[LASeR] Unsupported LASER event %d\n", evtType) ); - GF_LSR_WRITE_INT(lsr, 0, 6, "event"); break; + GF_LSR_WRITE_INT(lsr, 0, 6, "event"); + break; return; } switch (evtType) { @@ -1050,7 +1097,9 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) u32 size, cur_bits; u32 len = 2+3; switch (att->tag) { - case TAG_SVG_ATT_syncMaster: len +=1; break; + case TAG_SVG_ATT_syncMaster: + len +=1; + break; case TAG_SVG_ATT_requiredFonts: len += 8 * (u32) strlen(*(SVG_String*)att->data); /*get vluimsbf5 field size with one extra word (4 bits, enough to code string alignment)*/ @@ -1063,7 +1112,9 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) } is_string = 1; break; - default: len +=2; break; + default: + len +=2; + break; } GF_LSR_WRITE_INT(lsr, 49, 6, "attributeRARE"); GF_LSR_WRITE_INT(lsr, 2, lsr->info->cfg.extensionIDBits, "extensionID"); @@ -1103,23 +1154,55 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) GF_LSR_WRITE_INT(lsr, (u32)field_rare, 6, "attributeRARE"); switch (att->tag) { - case TAG_SVG_ATT__class: lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "class"); break; - - case TAG_SVG_ATT_audio_level: lsr_write_fixed_clamp(lsr, ((SVG_Number *) att->data)->value, "audio-level"); break; - case TAG_SVG_ATT_color: lsr_write_paint(lsr, (SVG_Paint*) att->data, "color"); break; - case TAG_SVG_ATT_color_rendering: GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 2, "color-rendering"); break; - case TAG_SVG_ATT_display: GF_LSR_WRITE_INT(lsr, *(SVG_Display*)att->data, 5, "display"); break; - case TAG_SVG_ATT_display_align: GF_LSR_WRITE_INT(lsr, *(SVG_DisplayAlign*)att->data, 3, "display-align"); break; - case TAG_SVG_ATT_fill_opacity: lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "fill-opacity"); break; - case TAG_SVG_ATT_fill_rule: GF_LSR_WRITE_INT(lsr, *(SVG_FillRule*)att->data, 2, "fill-rule"); break; - case TAG_SVG_ATT_image_rendering: GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 2, "image-rendering"); break; - case TAG_SVG_ATT_line_increment: lsr_write_line_increment_type(lsr, (SVG_Number*)att->data, "lineIncrement"); break; - case TAG_SVG_ATT_pointer_events: GF_LSR_WRITE_INT(lsr, *(SVG_PointerEvents*)att->data, 4, "pointer-events"); break; - case TAG_SVG_ATT_shape_rendering: GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 3, "shape-rendering"); break; - case TAG_SVG_ATT_solid_color: lsr_write_paint(lsr, (SVG_Paint*)att->data, "solid-color"); break; - case TAG_SVG_ATT_solid_opacity: lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "solid-opacity"); break; - case TAG_SVG_ATT_stop_color: lsr_write_paint(lsr, (SVG_Paint*)att->data, "stop-color"); break; - case TAG_SVG_ATT_stop_opacity: lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "stop-opacity"); break; + case TAG_SVG_ATT__class: + lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "class"); + break; + + case TAG_SVG_ATT_audio_level: + lsr_write_fixed_clamp(lsr, ((SVG_Number *) att->data)->value, "audio-level"); + break; + case TAG_SVG_ATT_color: + lsr_write_paint(lsr, (SVG_Paint*) att->data, "color"); + break; + case TAG_SVG_ATT_color_rendering: + GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 2, "color-rendering"); + break; + case TAG_SVG_ATT_display: + GF_LSR_WRITE_INT(lsr, *(SVG_Display*)att->data, 5, "display"); + break; + case TAG_SVG_ATT_display_align: + GF_LSR_WRITE_INT(lsr, *(SVG_DisplayAlign*)att->data, 3, "display-align"); + break; + case TAG_SVG_ATT_fill_opacity: + lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "fill-opacity"); + break; + case TAG_SVG_ATT_fill_rule: + GF_LSR_WRITE_INT(lsr, *(SVG_FillRule*)att->data, 2, "fill-rule"); + break; + case TAG_SVG_ATT_image_rendering: + GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 2, "image-rendering"); + break; + case TAG_SVG_ATT_line_increment: + lsr_write_line_increment_type(lsr, (SVG_Number*)att->data, "lineIncrement"); + break; + case TAG_SVG_ATT_pointer_events: + GF_LSR_WRITE_INT(lsr, *(SVG_PointerEvents*)att->data, 4, "pointer-events"); + break; + case TAG_SVG_ATT_shape_rendering: + GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 3, "shape-rendering"); + break; + case TAG_SVG_ATT_solid_color: + lsr_write_paint(lsr, (SVG_Paint*)att->data, "solid-color"); + break; + case TAG_SVG_ATT_solid_opacity: + lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "solid-opacity"); + break; + case TAG_SVG_ATT_stop_color: + lsr_write_paint(lsr, (SVG_Paint*)att->data, "stop-color"); + break; + case TAG_SVG_ATT_stop_opacity: + lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "stop-opacity"); + break; case TAG_SVG_ATT_stroke_dasharray: { u32 j; @@ -1129,29 +1212,56 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) } else { GF_LSR_WRITE_INT(lsr, 0, 1, "dashArray"); lsr_write_vluimsbf5(lsr, da->array.count, "len"); - for (j=0; jarray.count; j++) { - lsr_write_fixed_16_8(lsr, da->array.vals[j], "dash"); + for (j=0; jarray.count; j++) { + lsr_write_fixed_16_8(lsr, da->array.vals[j], "dash"); } } } - break; + break; case TAG_SVG_ATT_stroke_dashoffset: - lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "dashOffset"); break; - - case TAG_SVG_ATT_stroke_linecap: GF_LSR_WRITE_INT(lsr, *(SVG_StrokeLineCap*)att->data, 2, "stroke-linecap"); break; - case TAG_SVG_ATT_stroke_linejoin: GF_LSR_WRITE_INT(lsr, *(SVG_StrokeLineJoin*)att->data, 2, "stroke-linejoin"); break; - case TAG_SVG_ATT_stroke_miterlimit: lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "miterLimit"); break; - case TAG_SVG_ATT_stroke_opacity: lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "stroke-opacity"); break; - case TAG_SVG_ATT_stroke_width: lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "strokeWidth"); break; - case TAG_SVG_ATT_text_anchor: GF_LSR_WRITE_INT(lsr, *(SVG_TextAnchor*)att->data, 2, "text-achor"); break; - case TAG_SVG_ATT_text_rendering: GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 3, "text-rendering"); break; - case TAG_SVG_ATT_viewport_fill: lsr_write_paint(lsr, (SVG_Paint*)att->data, "viewport-fill"); break; - case TAG_SVG_ATT_viewport_fill_opacity: lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "viewport-fill-opacity"); break; - case TAG_SVG_ATT_vector_effect: GF_LSR_WRITE_INT(lsr, *(SVG_VectorEffect*)att->data, 4, "vector-effect"); break; - case TAG_SVG_ATT_visibility: GF_LSR_WRITE_INT(lsr, *(SVG_PointerEvents*)att->data, 2, "visibility"); break; - case TAG_SVG_ATT_requiredExtensions: lsr_write_byte_align_string_list(lsr, *(GF_List **)att->data, "requiredExtensions", 1); break; - case TAG_SVG_ATT_requiredFormats: lsr_write_byte_align_string_list(lsr, *(GF_List **)att->data, "requiredFormats", 0); break; - case TAG_SVG_ATT_requiredFeatures: + lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "dashOffset"); + break; + + case TAG_SVG_ATT_stroke_linecap: + GF_LSR_WRITE_INT(lsr, *(SVG_StrokeLineCap*)att->data, 2, "stroke-linecap"); + break; + case TAG_SVG_ATT_stroke_linejoin: + GF_LSR_WRITE_INT(lsr, *(SVG_StrokeLineJoin*)att->data, 2, "stroke-linejoin"); + break; + case TAG_SVG_ATT_stroke_miterlimit: + lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "miterLimit"); + break; + case TAG_SVG_ATT_stroke_opacity: + lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "stroke-opacity"); + break; + case TAG_SVG_ATT_stroke_width: + lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "strokeWidth"); + break; + case TAG_SVG_ATT_text_anchor: + GF_LSR_WRITE_INT(lsr, *(SVG_TextAnchor*)att->data, 2, "text-achor"); + break; + case TAG_SVG_ATT_text_rendering: + GF_LSR_WRITE_INT(lsr, *(SVG_RenderingHint*)att->data, 3, "text-rendering"); + break; + case TAG_SVG_ATT_viewport_fill: + lsr_write_paint(lsr, (SVG_Paint*)att->data, "viewport-fill"); + break; + case TAG_SVG_ATT_viewport_fill_opacity: + lsr_write_fixed_clamp(lsr, ((SVG_Number *)att->data)->value, "viewport-fill-opacity"); + break; + case TAG_SVG_ATT_vector_effect: + GF_LSR_WRITE_INT(lsr, *(SVG_VectorEffect*)att->data, 4, "vector-effect"); + break; + case TAG_SVG_ATT_visibility: + GF_LSR_WRITE_INT(lsr, *(SVG_PointerEvents*)att->data, 2, "visibility"); + break; + case TAG_SVG_ATT_requiredExtensions: + lsr_write_byte_align_string_list(lsr, *(GF_List **)att->data, "requiredExtensions", 1); + break; + case TAG_SVG_ATT_requiredFormats: + lsr_write_byte_align_string_list(lsr, *(GF_List **)att->data, "requiredFormats", 0); + break; + case TAG_SVG_ATT_requiredFeatures: { GF_List *l = *(GF_List **)att->data; u32 j, tot_count, count = gf_list_count(l); @@ -1163,67 +1273,197 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) if (iri->type != XMLRI_STRING) continue; ext = strchr(iri->string, '#'); if (!ext) continue; - if (!stricmp(ext, "Animation")) { vals[tot_count] = 0; tot_count++; } - else if (!stricmp(ext, "Audio")) { vals[tot_count] = 1; tot_count++; } - else if (!stricmp(ext, "ComposedVideo")) { vals[tot_count] = 2; tot_count++; } - else if (!stricmp(ext, "ConditionalProcessing")) { vals[tot_count] = 3; tot_count++; } - else if (!stricmp(ext, "ConditionalProcessingAttribute")) { vals[tot_count] = 4; tot_count++; } - else if (!stricmp(ext, "CoreAttribute")) { vals[tot_count] = 5; tot_count++; } - else if (!stricmp(ext, "Extensibility")) { vals[tot_count] = 6; tot_count++; } - else if (!stricmp(ext, "ExternalResourcesRequired")) { vals[tot_count] = 7; tot_count++; } - else if (!stricmp(ext, "Font")) { vals[tot_count] = 8; tot_count++; } - else if (!stricmp(ext, "Gradient")) { vals[tot_count] = 9; tot_count++; } - else if (!stricmp(ext, "GraphicsAttribute")) { vals[tot_count] = 10; tot_count++; } - else if (!stricmp(ext, "Handler")) { vals[tot_count] = 11; tot_count++; } - else if (!stricmp(ext, "Hyperlinking")) { vals[tot_count] = 12; tot_count++; } - else if (!stricmp(ext, "Image")) { vals[tot_count] = 13; tot_count++; } - else if (!stricmp(ext, "OpacityAttribute")) { vals[tot_count] = 14; tot_count++; } - else if (!stricmp(ext, "PaintAttribute")) { vals[tot_count] = 15; tot_count++; } - else if (!stricmp(ext, "Prefetch")) { vals[tot_count] = 16; tot_count++; } - else if (!stricmp(ext, "SVG")) { vals[tot_count] = 17; tot_count++; } - else if (!stricmp(ext, "SVG-animation")) { vals[tot_count] = 18; tot_count++; } - else if (!stricmp(ext, "SVG-dynamic")) { vals[tot_count] = 19; tot_count++; } - else if (!stricmp(ext, "SVG-static")) { vals[tot_count] = 20; tot_count++; } - else if (!stricmp(ext, "SVGDOM")) { vals[tot_count] = 21; tot_count++; } - else if (!stricmp(ext, "SVGDOM-animation")) { vals[tot_count] = 22; tot_count++; } - else if (!stricmp(ext, "SVGDOM-dynamic")) { vals[tot_count] = 23; tot_count++; } - else if (!stricmp(ext, "SVGDOM-static")) { vals[tot_count] = 24; tot_count++; } - else if (!stricmp(ext, "Script")) { vals[tot_count] = 25; tot_count++; } - else if (!stricmp(ext, "Shape")) { vals[tot_count] = 26; tot_count++; } - else if (!stricmp(ext, "SolidColor")) { vals[tot_count] = 27; tot_count++; } - else if (!stricmp(ext, "Structure")) { vals[tot_count] = 28; tot_count++; } - else if (!stricmp(ext, "Text")) { vals[tot_count] = 29; tot_count++; } - else if (!stricmp(ext, "TimedAnimation")) { vals[tot_count] = 30; tot_count++; } - else if (!stricmp(ext, "TransformedVideo")) { vals[tot_count] = 31; tot_count++; } - else if (!stricmp(ext, "Video")) { vals[tot_count] = 32; tot_count++; } - else if (!stricmp(ext, "XlinkAttribute")) { vals[tot_count] = 33; tot_count++; } + if (!stricmp(ext, "Animation")) { + vals[tot_count] = 0; + tot_count++; + } + else if (!stricmp(ext, "Audio")) { + vals[tot_count] = 1; + tot_count++; + } + else if (!stricmp(ext, "ComposedVideo")) { + vals[tot_count] = 2; + tot_count++; + } + else if (!stricmp(ext, "ConditionalProcessing")) { + vals[tot_count] = 3; + tot_count++; + } + else if (!stricmp(ext, "ConditionalProcessingAttribute")) { + vals[tot_count] = 4; + tot_count++; + } + else if (!stricmp(ext, "CoreAttribute")) { + vals[tot_count] = 5; + tot_count++; + } + else if (!stricmp(ext, "Extensibility")) { + vals[tot_count] = 6; + tot_count++; + } + else if (!stricmp(ext, "ExternalResourcesRequired")) { + vals[tot_count] = 7; + tot_count++; + } + else if (!stricmp(ext, "Font")) { + vals[tot_count] = 8; + tot_count++; + } + else if (!stricmp(ext, "Gradient")) { + vals[tot_count] = 9; + tot_count++; + } + else if (!stricmp(ext, "GraphicsAttribute")) { + vals[tot_count] = 10; + tot_count++; + } + else if (!stricmp(ext, "Handler")) { + vals[tot_count] = 11; + tot_count++; + } + else if (!stricmp(ext, "Hyperlinking")) { + vals[tot_count] = 12; + tot_count++; + } + else if (!stricmp(ext, "Image")) { + vals[tot_count] = 13; + tot_count++; + } + else if (!stricmp(ext, "OpacityAttribute")) { + vals[tot_count] = 14; + tot_count++; + } + else if (!stricmp(ext, "PaintAttribute")) { + vals[tot_count] = 15; + tot_count++; + } + else if (!stricmp(ext, "Prefetch")) { + vals[tot_count] = 16; + tot_count++; + } + else if (!stricmp(ext, "SVG")) { + vals[tot_count] = 17; + tot_count++; + } + else if (!stricmp(ext, "SVG-animation")) { + vals[tot_count] = 18; + tot_count++; + } + else if (!stricmp(ext, "SVG-dynamic")) { + vals[tot_count] = 19; + tot_count++; + } + else if (!stricmp(ext, "SVG-static")) { + vals[tot_count] = 20; + tot_count++; + } + else if (!stricmp(ext, "SVGDOM")) { + vals[tot_count] = 21; + tot_count++; + } + else if (!stricmp(ext, "SVGDOM-animation")) { + vals[tot_count] = 22; + tot_count++; + } + else if (!stricmp(ext, "SVGDOM-dynamic")) { + vals[tot_count] = 23; + tot_count++; + } + else if (!stricmp(ext, "SVGDOM-static")) { + vals[tot_count] = 24; + tot_count++; + } + else if (!stricmp(ext, "Script")) { + vals[tot_count] = 25; + tot_count++; + } + else if (!stricmp(ext, "Shape")) { + vals[tot_count] = 26; + tot_count++; + } + else if (!stricmp(ext, "SolidColor")) { + vals[tot_count] = 27; + tot_count++; + } + else if (!stricmp(ext, "Structure")) { + vals[tot_count] = 28; + tot_count++; + } + else if (!stricmp(ext, "Text")) { + vals[tot_count] = 29; + tot_count++; + } + else if (!stricmp(ext, "TimedAnimation")) { + vals[tot_count] = 30; + tot_count++; + } + else if (!stricmp(ext, "TransformedVideo")) { + vals[tot_count] = 31; + tot_count++; + } + else if (!stricmp(ext, "Video")) { + vals[tot_count] = 32; + tot_count++; + } + else if (!stricmp(ext, "XlinkAttribute")) { + vals[tot_count] = 33; + tot_count++; + } } lsr_write_vluimsbf5(lsr, tot_count, "len"); - for (j=0; jdata, "systemLanguage", 0); break; - case TAG_XML_ATT_base: lsr_write_byte_align_string(lsr, ((XMLRI*)att->data)->string, "xml:base"); break; - case TAG_XML_ATT_lang: lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "xml:lang"); break; - case TAG_XML_ATT_space: GF_LSR_WRITE_INT(lsr, *(XML_Space *)att->data, 1, "xml:space"); break; - case TAG_SVG_ATT_nav_next: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNext"); break; - case TAG_SVG_ATT_nav_up: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorth"); break; - case TAG_SVG_ATT_nav_up_left: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorthEast"); break; - case TAG_SVG_ATT_nav_up_right: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorthWest"); break; - case TAG_SVG_ATT_nav_prev: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusPrev"); break; - case TAG_SVG_ATT_nav_down: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouth"); break; - case TAG_SVG_ATT_nav_down_left: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouthEast"); break; - case TAG_SVG_ATT_nav_down_right: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouthWest"); break; - case TAG_SVG_ATT_nav_right: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusWest"); break; - case TAG_SVG_ATT_nav_left: lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusEast"); break; - - case TAG_SVG_ATT_font_variant: GF_LSR_WRITE_INT(lsr, *(SVG_FontVariant *)att->data, 2, "font-variant"); break; + case TAG_XML_ATT_base: + lsr_write_byte_align_string(lsr, ((XMLRI*)att->data)->string, "xml:base"); + break; + case TAG_XML_ATT_lang: + lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "xml:lang"); + break; + case TAG_XML_ATT_space: + GF_LSR_WRITE_INT(lsr, *(XML_Space *)att->data, 1, "xml:space"); + break; + case TAG_SVG_ATT_nav_next: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNext"); + break; + case TAG_SVG_ATT_nav_up: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorth"); + break; + case TAG_SVG_ATT_nav_up_left: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorthEast"); + break; + case TAG_SVG_ATT_nav_up_right: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusNorthWest"); + break; + case TAG_SVG_ATT_nav_prev: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusPrev"); + break; + case TAG_SVG_ATT_nav_down: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouth"); + break; + case TAG_SVG_ATT_nav_down_left: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouthEast"); + break; + case TAG_SVG_ATT_nav_down_right: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusSouthWest"); + break; + case TAG_SVG_ATT_nav_right: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusWest"); + break; + case TAG_SVG_ATT_nav_left: + lsr_write_focus(lsr, (SVG_Focus*)att->data, "focusEast"); + break; + + case TAG_SVG_ATT_font_variant: + GF_LSR_WRITE_INT(lsr, *(SVG_FontVariant *)att->data, 2, "font-variant"); + break; case TAG_SVG_ATT_font_family: { s32 idx = lsr_get_font_index(lsr, (SVG_FontFamily*)att->data); @@ -1234,23 +1474,49 @@ static void lsr_write_rare(GF_LASeRCodec *lsr, GF_Node *n) GF_LSR_WRITE_INT(lsr, idx, lsr->fontIndexBits, "fontIndex"); } } + break; + case TAG_SVG_ATT_font_size: + lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "fontSize"); + break; + case TAG_SVG_ATT_font_style: + GF_LSR_WRITE_INT(lsr, *((SVG_FontStyle *)att->data), 3, "fontStyle"); + break; + case TAG_SVG_ATT_font_weight: + GF_LSR_WRITE_INT(lsr, *((SVG_FontWeight *)att->data), 4, "fontWeight"); break; - case TAG_SVG_ATT_font_size: lsr_write_fixed_16_8i(lsr, (SVG_Number*)att->data, "fontSize"); break; - case TAG_SVG_ATT_font_style: GF_LSR_WRITE_INT(lsr, *((SVG_FontStyle *)att->data), 3, "fontStyle"); break; - case TAG_SVG_ATT_font_weight: GF_LSR_WRITE_INT(lsr, *((SVG_FontWeight *)att->data), 4, "fontWeight"); break; - case TAG_XLINK_ATT_title: lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "xlink:title"); break; + case TAG_XLINK_ATT_title: + lsr_write_byte_align_string(lsr, *(SVG_String *)att->data, "xlink:title"); + break; /*TODO FIXME*/ - case TAG_XLINK_ATT_type: GF_LSR_WRITE_INT(lsr, 0, 3, "xlink:type"); break; - case TAG_XLINK_ATT_role: lsr_write_any_uri(lsr, (XMLRI*)att->data, "xlink:role"); break; - case TAG_XLINK_ATT_arcrole: lsr_write_any_uri(lsr, (XMLRI*)att->data, "xlink:arcrole"); break; + case TAG_XLINK_ATT_type: + GF_LSR_WRITE_INT(lsr, 0, 3, "xlink:type"); + break; + case TAG_XLINK_ATT_role: + lsr_write_any_uri(lsr, (XMLRI*)att->data, "xlink:role"); + break; + case TAG_XLINK_ATT_arcrole: + lsr_write_any_uri(lsr, (XMLRI*)att->data, "xlink:arcrole"); + break; /*TODO FIXME*/ - case TAG_XLINK_ATT_actuate: GF_LSR_WRITE_INT(lsr, 0, 2, "xlink:actuate"); break; - case TAG_XLINK_ATT_show: GF_LSR_WRITE_INT(lsr, 0, 3, "xlink:show"); break; - case TAG_SVG_ATT_end: lsr_write_smil_times(lsr, (GF_List **)att->data, "end", 0); break; - case TAG_SVG_ATT_min: lsr_write_duration_ex(lsr, (SMIL_Duration*)att->data, "min", 0); break; - case TAG_SVG_ATT_max: lsr_write_duration_ex(lsr, (SMIL_Duration*)att->data, "max", 0); break; - case TAG_SVG_ATT_transform: lsr_write_matrix(lsr, (SVG_Transform*)att->data); break; + case TAG_XLINK_ATT_actuate: + GF_LSR_WRITE_INT(lsr, 0, 2, "xlink:actuate"); + break; + case TAG_XLINK_ATT_show: + GF_LSR_WRITE_INT(lsr, 0, 3, "xlink:show"); + break; + case TAG_SVG_ATT_end: + lsr_write_smil_times(lsr, (GF_List **)att->data, "end", 0); + break; + case TAG_SVG_ATT_min: + lsr_write_duration_ex(lsr, (SMIL_Duration*)att->data, "min", 0); + break; + case TAG_SVG_ATT_max: + lsr_write_duration_ex(lsr, (SMIL_Duration*)att->data, "max", 0); + break; + case TAG_SVG_ATT_transform: + lsr_write_matrix(lsr, (SVG_Transform*)att->data); + break; } att = att->next; @@ -1395,10 +1661,10 @@ static u32 svg_type_to_lsr_anim(u32 svg_type, u32 transform_type, GF_List *vals, case SVG_Points_datatype: return 3; /*all 0 - 1 types*/ -/* - case SVG_Opacity_datatype: - return 4; -*/ + /* + case SVG_Opacity_datatype: + return 4; + */ case SVG_Paint_datatype: return 5; /*all enums (u8) types*/ @@ -1422,13 +1688,13 @@ static u32 svg_type_to_lsr_anim(u32 svg_type, u32 transform_type, GF_List *vals, case SVG_PlaybackOrder_datatype: case SVG_TimelineBegin_datatype: return 6; - /*all list-of-int types*/ //return 7; +/*all list-of-int types*/ //return 7; /*all list-of-float types*/ case SVG_StrokeDashArray_datatype: case SVG_ViewBox_datatype: case SVG_Coordinates_datatype: return 8; - /*ID (u32) types*/ //return 10; +/*ID (u32) types*/ //return 10; case SVG_FontFamily_datatype: return 11; case XMLRI_datatype: @@ -1437,8 +1703,10 @@ static u32 svg_type_to_lsr_anim(u32 svg_type, u32 transform_type, GF_List *vals, return 9; /*ARG LOOKS LIKE THE SPEC IS BROKEN HERE*/ - case SVG_Transform_Translate_datatype: return 9; - case SVG_Transform_Scale_datatype: return 8; + case SVG_Transform_Translate_datatype: + return 9; + case SVG_Transform_Scale_datatype: + return 8; case SVG_Transform_Rotate_datatype: if (vals) { u32 i=0; @@ -1451,10 +1719,12 @@ static u32 svg_type_to_lsr_anim(u32 svg_type, u32 transform_type, GF_List *vals, if (pt->x || pt->y) return 8; } return 1; - case SVG_Transform_SkewX_datatype: return 1; - case SVG_Transform_SkewY_datatype: return 1; + case SVG_Transform_SkewX_datatype: + return 1; + case SVG_Transform_SkewY_datatype: + return 1; //case SVG_Transform_datatype: return; - /*FALL THROUH*/ + /*FALL THROUH*/ default: return 255; } @@ -1500,7 +1770,7 @@ static void lsr_write_an_anim_value(GF_LASeRCodec *lsr, void *val, u32 lsr_type, GF_LSR_WRITE_INT(lsr, 0, 1, "escapeFlag"); } } - break; + break; } } else if (svg_type==SVG_StrokeDashArray_datatype) { SVG_StrokeDashArray *da = (SVG_StrokeDashArray *)val; @@ -1514,9 +1784,11 @@ static void lsr_write_an_anim_value(GF_LASeRCodec *lsr, void *val, u32 lsr_type, GF_LSR_WRITE_INT(lsr, 0, 1, "escapeFlag"); } - switch(lsr_type) { - case 0: lsr_write_byte_align_string(lsr, *(DOM_String *)val, name); break; - case 1: + switch(lsr_type) { + case 0: + lsr_write_byte_align_string(lsr, *(DOM_String *)val, name); + break; + case 1: if (svg_type==SVG_Transform_Rotate_datatype) { Fixed angle = ((SVG_Point_Angle *) val)->angle; angle = gf_muldiv(angle, INT2FIX(180), GF_PI); @@ -1527,14 +1799,28 @@ static void lsr_write_an_anim_value(GF_LASeRCodec *lsr, void *val, u32 lsr_type, lsr_write_fixed_16_8(lsr, ((SVG_Number *) val)->value, name); } break; - case 12: lsr_write_any_uri(lsr, (XMLRI*)val, name); break; - case 2: lsr_write_path_type(lsr, (SVG_PathData*)val, name); break; - case 3: lsr_write_point_sequence(lsr, (GF_List **)val, name); break; - case 4: lsr_write_fixed_clamp(lsr, ((SVG_Number *) val)->value, name); break; - case 5: lsr_write_paint(lsr, (SVG_Paint*)val, name); break; - case 6: lsr_write_vluimsbf5(lsr, (u32) *(u8 *) val, name); break; - case 10: lsr_write_vluimsbf5(lsr, *(u32 *) val, name); break; - case 11: + case 12: + lsr_write_any_uri(lsr, (XMLRI*)val, name); + break; + case 2: + lsr_write_path_type(lsr, (SVG_PathData*)val, name); + break; + case 3: + lsr_write_point_sequence(lsr, (GF_List **)val, name); + break; + case 4: + lsr_write_fixed_clamp(lsr, ((SVG_Number *) val)->value, name); + break; + case 5: + lsr_write_paint(lsr, (SVG_Paint*)val, name); + break; + case 6: + lsr_write_vluimsbf5(lsr, (u32) *(u8 *) val, name); + break; + case 10: + lsr_write_vluimsbf5(lsr, *(u32 *) val, name); + break; + case 11: { s32 idx = lsr_get_font_index(lsr, (SVG_FontFamily*)val); if (idx<0) { @@ -1543,19 +1829,19 @@ static void lsr_write_an_anim_value(GF_LASeRCodec *lsr, void *val, u32 lsr_type, } lsr_write_vluimsbf5(lsr, idx, name); } - break; - case 7: + break; + case 7: { GF_List *l = *(GF_List **)val; u32 i, count = gf_list_count(l); lsr_write_vluimsbf5(lsr, count, "count"); - for (i=0; im[2], 0, "valX"); lsr_write_coordinate(lsr, ((GF_Matrix2D*)val)->m[5], 0, "valY"); @@ -1614,11 +1900,11 @@ static void lsr_write_an_anim_value(GF_LASeRCodec *lsr, void *val, u32 lsr_type, lsr_write_coordinate(lsr, ((SVG_Point *)val)->x, 0, "valX"); lsr_write_coordinate(lsr, ((SVG_Point *)val)->y, 0, "valY"); } - break; - default: + break; + default: lsr_write_extension(lsr, NULL, 0, name); - break; - } + break; + } } static void lsr_write_anim_value(GF_LASeRCodec *lsr, SMIL_AnimateValue *val, const char *name) @@ -1693,7 +1979,7 @@ static void lsr_write_float_list(GF_LASeRCodec *lsr, GF_List **l, const char *na } GF_LSR_WRITE_INT(lsr, 1, 1, name); lsr_write_vluimsbf5(lsr, count, "count"); - for (i=0;ix); if (k>nb_bits) nb_bits = k; - k = lsr_get_bit_size(lsr, pt->y); if (k>nb_bits) nb_bits = k; + k = lsr_get_bit_size(lsr, pt->x); + if (k>nb_bits) nb_bits = k; + k = lsr_get_bit_size(lsr, pt->y); + if (k>nb_bits) nb_bits = k; } GF_LSR_WRITE_INT(lsr, nb_bits, 5, "bits"); - for (i=0; ix, nb_bits); GF_LSR_WRITE_INT(lsr, v, nb_bits, "x"); v = lsr_translate_coords(lsr, pt->y, nb_bits); GF_LSR_WRITE_INT(lsr, v, nb_bits, "y"); - } - } else { + } + } else { Fixed c_x, c_y; u32 k, nb_dx, nb_dy; SVG_Point *pt = (SVG_Point *)gf_list_get(*pts, 0); nb_dx = 0; - k = lsr_get_bit_size(lsr, pt->x); if (k>nb_dx) nb_dx = k; - k = lsr_get_bit_size(lsr, pt->y); if (k>nb_dx) nb_dx = k; + k = lsr_get_bit_size(lsr, pt->x); + if (k>nb_dx) nb_dx = k; + k = lsr_get_bit_size(lsr, pt->y); + if (k>nb_dx) nb_dx = k; GF_LSR_WRITE_INT(lsr, nb_dx, 5, "bits"); k = lsr_translate_coords(lsr, pt->x, nb_dx); GF_LSR_WRITE_INT(lsr, k, nb_dx, "x"); @@ -1749,8 +2039,10 @@ static void lsr_write_point_sequence(GF_LASeRCodec *lsr, GF_List **pts, const ch nb_dx = nb_dy = 0; for (i=1; ix - c_x); if (k>nb_dx) nb_dx = k; - k = lsr_get_bit_size(lsr, pt->y - c_y); if (k>nb_dy) nb_dy = k; + k = lsr_get_bit_size(lsr, pt->x - c_x); + if (k>nb_dx) nb_dx = k; + k = lsr_get_bit_size(lsr, pt->y - c_y); + if (k>nb_dy) nb_dy = k; c_x = pt->x; c_y = pt->y; } @@ -1767,7 +2059,7 @@ static void lsr_write_point_sequence(GF_LASeRCodec *lsr, GF_List **pts, const ch c_x = pt->x; c_y = pt->y; } - } + } } } static void lsr_write_path_type(GF_LASeRCodec *lsr, SVG_PathData *path, const char *name) @@ -1843,11 +2135,11 @@ static void lsr_write_path_type(GF_LASeRCodec *lsr, SVG_PathData *path, const ch lsr_write_point_sequence(lsr, path->points, "seq"); /*initial move is not coded*/ count = gf_list_count(path->commands); - lsr_write_vluimsbf5(lsr, count, "nbOfTypes"); - for (i; icommands, i); + lsr_write_vluimsbf5(lsr, count, "nbOfTypes"); + for (i; icommands, i); GF_LSR_WRITE_INT(lsr, type, 5, name); - } + } #endif } @@ -1891,7 +2183,7 @@ static void lsr_write_coord_list(GF_LASeRCodec *lsr, GF_List **coords, const cha GF_LSR_WRITE_INT(lsr, 0, 1, name); } else { GF_LSR_WRITE_INT(lsr, 1, 1, name); - lsr_write_vluimsbf5(lsr, count, "nb_coords"); + lsr_write_vluimsbf5(lsr, count, "nb_coords"); for (i=0; ivalue, lsr->coord_bits); @@ -1947,14 +2239,28 @@ static void lsr_write_value_with_units(GF_LASeRCodec *lsr, SVG_Number *n, const s32 val = (s32) (n->value * (1<<8) ); #endif GF_LSR_WRITE_INT(lsr, val, 32, name); - switch (n->type) { - case SVG_NUMBER_IN: GF_LSR_WRITE_INT(lsr, 1, 3, "units"); break; - case SVG_NUMBER_CM: GF_LSR_WRITE_INT(lsr, 2, 3, "units"); break; - case SVG_NUMBER_MM: GF_LSR_WRITE_INT(lsr, 3, 3, "units"); break; - case SVG_NUMBER_PT: GF_LSR_WRITE_INT(lsr, 4, 3, "units"); break; - case SVG_NUMBER_PC: GF_LSR_WRITE_INT(lsr, 5, 3, "units"); break; - case SVG_NUMBER_PERCENTAGE: GF_LSR_WRITE_INT(lsr, 6, 3, "units"); break; - default: GF_LSR_WRITE_INT(lsr, 0, 3, "units"); break; + switch (n->type) { + case SVG_NUMBER_IN: + GF_LSR_WRITE_INT(lsr, 1, 3, "units"); + break; + case SVG_NUMBER_CM: + GF_LSR_WRITE_INT(lsr, 2, 3, "units"); + break; + case SVG_NUMBER_MM: + GF_LSR_WRITE_INT(lsr, 3, 3, "units"); + break; + case SVG_NUMBER_PT: + GF_LSR_WRITE_INT(lsr, 4, 3, "units"); + break; + case SVG_NUMBER_PC: + GF_LSR_WRITE_INT(lsr, 5, 3, "units"); + break; + case SVG_NUMBER_PERCENTAGE: + GF_LSR_WRITE_INT(lsr, 6, 3, "units"); + break; + default: + GF_LSR_WRITE_INT(lsr, 0, 3, "units"); + break; } } @@ -1967,7 +2273,7 @@ static void lsr_write_clip_time(GF_LASeRCodec *lsr, SVG_Clock *clock, const char GF_LSR_WRITE_INT(lsr, 1, 1, name); GF_LSR_WRITE_INT(lsr, 0, 1, "isEnum"); GF_LSR_WRITE_INT(lsr, 0, 1, "sign"); - lsr_write_vluimsbf5(lsr, (u32) (lsr->time_resolution* *clock), "val"); + lsr_write_vluimsbf5(lsr, (u32) (lsr->time_resolution**clock), "val"); } } @@ -1997,16 +2303,36 @@ static void lsr_write_preserve_aspect_ratio(GF_LASeRCodec *lsr, SVG_PreserveAspe GF_LSR_WRITE_INT(lsr, 0, 1, "choice (meetOrSlice)"); GF_LSR_WRITE_INT(lsr, preserveAspectRatio->defer ? 1 : 0, 1, "choice (defer)"); switch (preserveAspectRatio->align) { - case SVG_PRESERVEASPECTRATIO_XMAXYMAX: GF_LSR_WRITE_INT(lsr, 1, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMAXYMID: GF_LSR_WRITE_INT(lsr, 2, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMAXYMIN: GF_LSR_WRITE_INT(lsr, 3, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMIDYMAX: GF_LSR_WRITE_INT(lsr, 4, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMIDYMID: GF_LSR_WRITE_INT(lsr, 5, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMIDYMIN: GF_LSR_WRITE_INT(lsr, 6, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMINYMAX: GF_LSR_WRITE_INT(lsr, 7, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMINYMID: GF_LSR_WRITE_INT(lsr, 8, 4, "alignXandY"); break; - case SVG_PRESERVEASPECTRATIO_XMINYMIN: GF_LSR_WRITE_INT(lsr, 9, 4, "alignXandY"); break; - default: GF_LSR_WRITE_INT(lsr, 0, 4, "alignXandY"); break; + case SVG_PRESERVEASPECTRATIO_XMAXYMAX: + GF_LSR_WRITE_INT(lsr, 1, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMAXYMID: + GF_LSR_WRITE_INT(lsr, 2, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMAXYMIN: + GF_LSR_WRITE_INT(lsr, 3, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMIDYMAX: + GF_LSR_WRITE_INT(lsr, 4, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMIDYMID: + GF_LSR_WRITE_INT(lsr, 5, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMIDYMIN: + GF_LSR_WRITE_INT(lsr, 6, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMINYMAX: + GF_LSR_WRITE_INT(lsr, 7, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMINYMID: + GF_LSR_WRITE_INT(lsr, 8, 4, "alignXandY"); + break; + case SVG_PRESERVEASPECTRATIO_XMINYMIN: + GF_LSR_WRITE_INT(lsr, 9, 4, "alignXandY"); + break; + default: + GF_LSR_WRITE_INT(lsr, 0, 4, "alignXandY"); + break; } } @@ -2117,11 +2443,21 @@ static void lsr_write_animateTransform(GF_LASeRCodec *lsr, SVG_Element *elt, SVG type = atts.transform_type ? *atts.transform_type : SVG_TRANSFORM_TRANSLATE; /*enumeration rotate{0} scale{1} skewX{2} skewY{3} translate{4}*/ switch (type) { - case SVG_TRANSFORM_ROTATE: GF_LSR_WRITE_INT(lsr, 0, 3, "rotscatra"); break; - case SVG_TRANSFORM_SCALE: GF_LSR_WRITE_INT(lsr, 1, 3, "rotscatra"); break; - case SVG_TRANSFORM_SKEWX: GF_LSR_WRITE_INT(lsr, 2, 3, "rotscatra"); break; - case SVG_TRANSFORM_SKEWY: GF_LSR_WRITE_INT(lsr, 3, 3, "rotscatra"); break; - case SVG_TRANSFORM_TRANSLATE: GF_LSR_WRITE_INT(lsr, 4, 3, "rotscatra"); break; + case SVG_TRANSFORM_ROTATE: + GF_LSR_WRITE_INT(lsr, 0, 3, "rotscatra"); + break; + case SVG_TRANSFORM_SCALE: + GF_LSR_WRITE_INT(lsr, 1, 3, "rotscatra"); + break; + case SVG_TRANSFORM_SKEWX: + GF_LSR_WRITE_INT(lsr, 2, 3, "rotscatra"); + break; + case SVG_TRANSFORM_SKEWY: + GF_LSR_WRITE_INT(lsr, 3, 3, "rotscatra"); + break; + case SVG_TRANSFORM_TRANSLATE: + GF_LSR_WRITE_INT(lsr, 4, 3, "rotscatra"); + break; } lsr_write_accumulate(lsr, atts.accumulate); @@ -2271,15 +2607,15 @@ static void lsr_write_foreignObject(GF_LASeRCodec *lsr, SVG_Element *elt) lsr_write_coordinate_ptr(lsr, atts.y, 1, "y"); lsr_write_any_attribute(lsr, elt, 1); -/* TODO - bit(1) opt_group; - if(opt_group) { - vluimsbf5 occ1; - for(int t=0;tprev_g, &same_fill, NULL, 0) - && same_fill - ) { + && lsr_elt_has_same_base(lsr, &atts, lsr->prev_g, &same_fill, NULL, 0) + && same_fill + ) { /*samegType*/ GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_sameg, 6, "ch4"); lsr_write_id(lsr, (GF_Node *) elt); @@ -2349,8 +2685,8 @@ static void lsr_write_line(GF_LASeRCodec *lsr, SVG_Element *elt, Bool ommit_tag) gf_svg_flatten_attributes(elt, &atts); if (!ommit_tag && lsr_elt_has_same_base(lsr, &atts, lsr->prev_line, &same_fill, NULL, 0) - && same_fill - ) { + && same_fill + ) { /*samelineType*/ GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_sameline, 6, "ch4"); lsr_write_id(lsr, (GF_Node *) elt); @@ -2452,7 +2788,7 @@ static void lsr_write_polygon(GF_LASeRCodec *lsr, SVG_Element *elt, Bool is_poly gf_svg_flatten_attributes(elt, &atts); if (!ommit_tag && lsr_elt_has_same_base(lsr, &atts, lsr->prev_polygon, &same_fill, &same_stroke, 1) - ) { + ) { if (same_fill && same_stroke) same_type = 1; else if (same_fill) same_type = 3; else if (same_stroke) same_type = 2; @@ -2509,7 +2845,7 @@ static void lsr_write_rect(GF_LASeRCodec *lsr, SVG_Element *elt, Bool ommit_tag) gf_svg_flatten_attributes(elt, &atts); if (!ommit_tag && lsr_elt_has_same_base(lsr, &atts, lsr->prev_rect, &same_fill, NULL, 0) - ) { + ) { if (!same_fill) { same_type = 2; /*samerectfillType*/ @@ -2685,17 +3021,25 @@ static void lsr_write_svg(GF_LASeRCodec *lsr, SVG_Element *elt) GF_LSR_WRITE_INT(lsr, atts.syncBehaviorDefault ? 1 : 0, 1, "hasSyncBehavior"); if (atts.syncBehaviorDefault) { switch (*atts.syncBehaviorDefault) { - case SMIL_SYNCBEHAVIOR_CANSLIP: GF_LSR_WRITE_INT(lsr, 0, 2, "syncBehavior"); break; - case SMIL_SYNCBEHAVIOR_INDEPENDENT: GF_LSR_WRITE_INT(lsr, 1, 2, "syncBehavior"); break; - case SMIL_SYNCBEHAVIOR_LOCKED: GF_LSR_WRITE_INT(lsr, 3, 2, "syncBehavior"); break; - default: GF_LSR_WRITE_INT(lsr, 2, 2, "syncBehavior"); break; + case SMIL_SYNCBEHAVIOR_CANSLIP: + GF_LSR_WRITE_INT(lsr, 0, 2, "syncBehavior"); + break; + case SMIL_SYNCBEHAVIOR_INDEPENDENT: + GF_LSR_WRITE_INT(lsr, 1, 2, "syncBehavior"); + break; + case SMIL_SYNCBEHAVIOR_LOCKED: + GF_LSR_WRITE_INT(lsr, 3, 2, "syncBehavior"); + break; + default: + GF_LSR_WRITE_INT(lsr, 2, 2, "syncBehavior"); + break; } } GF_LSR_WRITE_INT(lsr, atts.syncToleranceDefault ? 1 : 0, 1, "hasSyncToleranceDefault"); if (atts.syncToleranceDefault) { if (atts.syncToleranceDefault->type==SMIL_SYNCTOLERANCE_VALUE) { GF_LSR_WRITE_INT(lsr, 0, 1, "choice"); - lsr_write_vluimsbf5(lsr, (u32) (atts.syncToleranceDefault->value*lsr->time_resolution), "value"); + lsr_write_vluimsbf5(lsr, (u32) (atts.syncToleranceDefault->value*lsr->time_resolution), "value"); } else { GF_LSR_WRITE_INT(lsr, 1, 1, "choice"); } @@ -2795,8 +3139,8 @@ static void lsr_write_use(GF_LASeRCodec *lsr, SVG_Element *elt, Bool ommit_tag) gf_svg_flatten_attributes(elt, &atts); if (!ommit_tag && lsr_elt_has_same_base(lsr, &atts, lsr->prev_use, NULL, NULL, 0) - /*TODO check overflow*/ - ) { + /*TODO check overflow*/ + ) { is_same = 1; /*sameuseType*/ GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_sameuse, 6, "ch4"); @@ -2958,7 +3302,8 @@ static void lsr_write_scene_content_model(GF_LASeRCodec *lsr, SVG_Element *paren GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_circle, 6, "ch4"); lsr_write_circle(lsr, node); break; - case TAG_LSR_cursorManager: GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_cursorManager, 6, "ch4"); + case TAG_LSR_cursorManager: + GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_cursorManager, 6, "ch4"); lsr_write_cursorManager(lsr, node); break; case TAG_SVG_defs: @@ -3088,7 +3433,7 @@ static void lsr_write_scene_content_model(GF_LASeRCodec *lsr, SVG_Element *paren default: #if 0 - /*case extend*/ + /*case extend*/ GF_LSR_WRITE_INT(lsr, LSR_SCENE_CONTENT_MODEL_element_any, 6, "ch4"); lsr_write_extend_class(lsr, NULL, 0, node); break; @@ -3129,39 +3474,138 @@ static void lsr_write_update_content_model(GF_LASeRCodec *lsr, SVG_Element *pare } else { GF_LSR_WRITE_INT(lsr, 0, 1, "ch4"); switch(tag) { - case TAG_SVG_a: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_a, 6, "ch6"); lsr_write_a(lsr, node); break; - case TAG_SVG_animate: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animate, 6, "ch6"); lsr_write_animate(lsr, node, parent); break; - case TAG_SVG_animateColor: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateColor, 6, "ch6"); lsr_write_animate(lsr, node, parent); break; - case TAG_SVG_animateMotion: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateMotion, 6, "ch6"); lsr_write_animateMotion(lsr, node, parent); break; - case TAG_SVG_animateTransform: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateTransform, 6, "ch6"); lsr_write_animateTransform(lsr, node, parent); break; - case TAG_SVG_audio: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_audio, 6, "ch6"); lsr_write_audio(lsr, node); break; - case TAG_SVG_circle: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_circle, 6, "ch6"); lsr_write_circle(lsr, node); break; - case TAG_SVG_defs: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_defs, 6, "ch6"); lsr_write_defs(lsr, node); break; - case TAG_SVG_desc: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_desc, 6, "ch6"); lsr_write_data(lsr, node); break; - case TAG_SVG_ellipse: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_ellipse, 6, "ch6"); lsr_write_ellipse(lsr, node); break; - case TAG_SVG_foreignObject: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_foreignObject, 6, "ch6"); lsr_write_foreignObject(lsr, node); break; - case TAG_SVG_g: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_g, 6, "ch6"); lsr_write_g(lsr, node, 1); break; - case TAG_SVG_image: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_image, 6, "ch6"); lsr_write_image(lsr, node); break; - case TAG_SVG_line: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_line, 6, "ch6"); lsr_write_line(lsr, node, 1); break; - case TAG_SVG_linearGradient: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_linearGradient, 6, "ch6"); lsr_write_linearGradient(lsr, node); break; - case TAG_SVG_metadata: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_metadata, 6, "ch6"); lsr_write_data(lsr, node); break; - case TAG_SVG_mpath: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_mpath, 6, "ch6"); lsr_write_mpath(lsr, node); break; - case TAG_SVG_path: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_path, 6, "ch6"); lsr_write_path(lsr, node, 1); break; - case TAG_SVG_polygon: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_polygon, 6, "ch6"); lsr_write_polygon(lsr, node, 0, 1); break; - case TAG_SVG_polyline: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_polyline, 6, "ch6"); lsr_write_polygon(lsr, node, 1, 1); break; - case TAG_SVG_radialGradient: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_radialGradient, 6, "ch6"); lsr_write_radialGradient(lsr, node); break; - case TAG_SVG_rect: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_rect, 6, "ch6"); lsr_write_rect(lsr, node, 1); break; - case TAG_SVG_script: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_script, 6, "ch6"); lsr_write_script(lsr, node); break; - case TAG_SVG_set: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_set, 6, "ch6"); lsr_write_set(lsr, node, parent); break; - case TAG_SVG_stop: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_stop, 6, "ch6"); lsr_write_stop(lsr, node); break; - case TAG_SVG_svg: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_svg, 6, "ch6"); lsr_write_svg(lsr, node); break; - case TAG_SVG_switch: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_switch, 6, "ch6"); lsr_write_switch(lsr, node); break; - case TAG_SVG_text: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_text, 6, "ch6"); lsr_write_text(lsr, node, 1); break; - case TAG_SVG_title: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_title, 6, "ch6"); lsr_write_data(lsr, node); break; - case TAG_SVG_tspan: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_tspan, 6, "ch6"); lsr_write_tspan(lsr, node); break; - case TAG_SVG_use: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_use, 6, "ch6"); lsr_write_use(lsr, node, 1); break; - case TAG_SVG_video: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_video, 6, "ch6"); lsr_write_video(lsr, node); break; - case TAG_SVG_listener: GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_listener, 6, "ch6"); lsr_write_listener(lsr, node); break; + case TAG_SVG_a: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_a, 6, "ch6"); + lsr_write_a(lsr, node); + break; + case TAG_SVG_animate: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animate, 6, "ch6"); + lsr_write_animate(lsr, node, parent); + break; + case TAG_SVG_animateColor: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateColor, 6, "ch6"); + lsr_write_animate(lsr, node, parent); + break; + case TAG_SVG_animateMotion: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateMotion, 6, "ch6"); + lsr_write_animateMotion(lsr, node, parent); + break; + case TAG_SVG_animateTransform: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_animateTransform, 6, "ch6"); + lsr_write_animateTransform(lsr, node, parent); + break; + case TAG_SVG_audio: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_audio, 6, "ch6"); + lsr_write_audio(lsr, node); + break; + case TAG_SVG_circle: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_circle, 6, "ch6"); + lsr_write_circle(lsr, node); + break; + case TAG_SVG_defs: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_defs, 6, "ch6"); + lsr_write_defs(lsr, node); + break; + case TAG_SVG_desc: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_desc, 6, "ch6"); + lsr_write_data(lsr, node); + break; + case TAG_SVG_ellipse: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_ellipse, 6, "ch6"); + lsr_write_ellipse(lsr, node); + break; + case TAG_SVG_foreignObject: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_foreignObject, 6, "ch6"); + lsr_write_foreignObject(lsr, node); + break; + case TAG_SVG_g: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_g, 6, "ch6"); + lsr_write_g(lsr, node, 1); + break; + case TAG_SVG_image: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_image, 6, "ch6"); + lsr_write_image(lsr, node); + break; + case TAG_SVG_line: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_line, 6, "ch6"); + lsr_write_line(lsr, node, 1); + break; + case TAG_SVG_linearGradient: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_linearGradient, 6, "ch6"); + lsr_write_linearGradient(lsr, node); + break; + case TAG_SVG_metadata: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_metadata, 6, "ch6"); + lsr_write_data(lsr, node); + break; + case TAG_SVG_mpath: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_mpath, 6, "ch6"); + lsr_write_mpath(lsr, node); + break; + case TAG_SVG_path: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_path, 6, "ch6"); + lsr_write_path(lsr, node, 1); + break; + case TAG_SVG_polygon: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_polygon, 6, "ch6"); + lsr_write_polygon(lsr, node, 0, 1); + break; + case TAG_SVG_polyline: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_polyline, 6, "ch6"); + lsr_write_polygon(lsr, node, 1, 1); + break; + case TAG_SVG_radialGradient: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_radialGradient, 6, "ch6"); + lsr_write_radialGradient(lsr, node); + break; + case TAG_SVG_rect: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_rect, 6, "ch6"); + lsr_write_rect(lsr, node, 1); + break; + case TAG_SVG_script: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_script, 6, "ch6"); + lsr_write_script(lsr, node); + break; + case TAG_SVG_set: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_set, 6, "ch6"); + lsr_write_set(lsr, node, parent); + break; + case TAG_SVG_stop: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_stop, 6, "ch6"); + lsr_write_stop(lsr, node); + break; + case TAG_SVG_svg: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_svg, 6, "ch6"); + lsr_write_svg(lsr, node); + break; + case TAG_SVG_switch: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_switch, 6, "ch6"); + lsr_write_switch(lsr, node); + break; + case TAG_SVG_text: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_text, 6, "ch6"); + lsr_write_text(lsr, node, 1); + break; + case TAG_SVG_title: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_title, 6, "ch6"); + lsr_write_data(lsr, node); + break; + case TAG_SVG_tspan: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_tspan, 6, "ch6"); + lsr_write_tspan(lsr, node); + break; + case TAG_SVG_use: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_use, 6, "ch6"); + lsr_write_use(lsr, node, 1); + break; + case TAG_SVG_video: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_video, 6, "ch6"); + lsr_write_video(lsr, node); + break; + case TAG_SVG_listener: + GF_LSR_WRITE_INT(lsr, LSR_UPDATE_CONTENT_MODEL_listener, 6, "ch6"); + lsr_write_listener(lsr, node); + break; } } } @@ -3207,25 +3651,25 @@ static void lsr_write_update_value(GF_LASeRCodec *lsr, SVG_Element *elt, u32 fie lsr_write_coordinate(lsr, pt->x, 0, "x"); lsr_write_coordinate(lsr, pt->y, 0, "y"); } - break; + break; case SMIL_Times_datatype:/*smil_times*/ { SMIL_Time *st = gf_list_get(*(GF_List **)val, 0); lsr_write_smil_time(lsr, st); } - break; + break; case SMIL_KeyPoints_datatype:/*0to1*/ { Fixed *f = gf_list_get(*(GF_List **)val, 0); lsr_write_fixed_clamp(lsr, *f, "v"); } - break; + break; case SMIL_KeySplines_datatype:/*float*/ { Fixed *f = gf_list_get(*(GF_List **)val, 0); lsr_write_fixed_16_8(lsr, *f, "v"); } - break; + break; case SMIL_KeyTimes_datatype:/*keyTime*/ { Fixed *v = gf_list_get(*(GF_List **)val, 0); @@ -3238,7 +3682,7 @@ static void lsr_write_update_value(GF_LASeRCodec *lsr, SVG_Element *elt, u32 fie lsr_write_fixed_clamp(lsr, f, "timevalue"); } } - break; + break; case SVG_StrokeDashArray_datatype:/*float*/ case SVG_ViewBox_datatype:/*float*/ break; @@ -3389,7 +3833,7 @@ static void lsr_write_update_value(GF_LASeRCodec *lsr, SVG_Element *elt, u32 fie } } } - break; + break; case SVG_ViewBox_datatype: { SVG_ViewBox *b = (SVG_ViewBox *)val; @@ -3401,7 +3845,7 @@ static void lsr_write_update_value(GF_LASeRCodec *lsr, SVG_Element *elt, u32 fie lsr_write_fixed_16_8(lsr, b->width, "width"); lsr_write_fixed_16_8(lsr, b->width, "height"); } - break; + break; case SVG_FontFamily_datatype: { SVG_FontFamily *ff = (SVG_FontFamily *)val; @@ -3416,7 +3860,7 @@ static void lsr_write_update_value(GF_LASeRCodec *lsr, SVG_Element *elt, u32 fie lsr_write_vluimsbf5(lsr, (u32) idx, "nb1"); } } - break; + break; default: if ((fieldType>=SVG_FillRule_datatype) && (fieldType<=SVG_LAST_U8_PROPERTY)) { u8 v = *(u8 *)val; @@ -3651,7 +4095,7 @@ static GF_Err lsr_write_command_list(GF_LASeRCodec *lsr, GF_List *com_list, SVG_ GF_LSR_WRITE_INT(lsr, (com->tag==GF_SG_LSR_ACTIVATE) ? 1 : 2, 2, "ch5"); lsr_write_codec_IDREF_Node(lsr, com->node, "ref"); } - break; + break; default: return GF_BAD_PARAM; } @@ -3754,7 +4198,7 @@ static void lsr_check_font_and_color(GF_LASeRCodec *lsr, SVG_Element *elt) else if (!strcmp(an->name, "font-family")) check_anim_font = 1; } } - break; + break; } att = att->next; } @@ -3778,7 +4222,7 @@ static void lsr_check_font_and_color(GF_LASeRCodec *lsr, SVG_Element *elt) else if (check_anim_col == 2) lsr_check_col_index(lsr, (SVG_Color*)gf_list_get(vals->values, i), NULL); } } - break; + break; } att = att->next; } diff --git a/src/laser/lsr_tables.c b/src/laser/lsr_tables.c index 8b962a9..8a4fc64 100644 --- a/src/laser/lsr_tables.c +++ b/src/laser/lsr_tables.c @@ -14,7 +14,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -36,140 +36,274 @@ s32 gf_lsr_anim_type_from_attribute(u32 tag) { switch(tag) { - case TAG_SVG_ATT_target: return 0; - case TAG_SVG_ATT_accumulate: return 1; - case TAG_SVG_ATT_additive: return 2; - case TAG_SVG_ATT_audio_level: return 3; - case TAG_SVG_ATT_bandwidth: return 4; - case TAG_SVG_ATT_begin: return 5; - case TAG_SVG_ATT_calcMode: return 6; - case TAG_LSR_ATT_children: return 7; - case TAG_SVG_ATT_choice: return 8; - case TAG_SVG_ATT_clipBegin: return 9; - case TAG_SVG_ATT_clipEnd: return 10; - case TAG_SVG_ATT_color: return 11; - case TAG_SVG_ATT_color_rendering: return 12; - case TAG_SVG_ATT_cx: return 13; - case TAG_SVG_ATT_cy: return 14; - case TAG_SVG_ATT_d: return 15; - case TAG_SVG_ATT_delta: return 16; - case TAG_SVG_ATT_display: return 17; - case TAG_SVG_ATT_display_align: return 18; - case TAG_SVG_ATT_dur: return 19; - case TAG_SVG_ATT_editable: return 20; - case TAG_LSR_ATT_enabled: return 21; - case TAG_SVG_ATT_end: return 22; - case TAG_XMLEV_ATT_event: return 23; - case TAG_SVG_ATT_externalResourcesRequired: return 24; - case TAG_SVG_ATT_fill: return 25; - case TAG_SVG_ATT_fill_opacity: return 26; - case TAG_SVG_ATT_fill_rule: return 27; - case TAG_SVG_ATT_focusable: return 28; - case TAG_SVG_ATT_font_family: return 29; - case TAG_SVG_ATT_font_size: return 30; - case TAG_SVG_ATT_font_style: return 31; - case TAG_SVG_ATT_font_variant: return 32; - case TAG_SVG_ATT_font_weight: return 33; - case TAG_SVG_ATT_fullscreen: return 34; - case TAG_SVG_ATT_gradientUnits: return 35; - case TAG_XMLEV_ATT_handler: return 36; - case TAG_SVG_ATT_height: return 37; - case TAG_SVG_ATT_image_rendering: return 38; - case TAG_SVG_ATT_keyPoints: return 39; - case TAG_SVG_ATT_keySplines: return 40; - case TAG_SVG_ATT_keyTimes: return 41; - case TAG_SVG_ATT_line_increment: return 42; - case TAG_XMLEV_ATT_target: return 43; - case TAG_SVG_ATT_mediaCharacterEncoding: return 44; - case TAG_SVG_ATT_mediaContentEncodings: return 45; - case TAG_SVG_ATT_mediaSize: return 46; - case TAG_SVG_ATT_mediaTime: return 47; - case TAG_SVG_ATT_nav_down: return 48; - case TAG_SVG_ATT_nav_down_left: return 49; - case TAG_SVG_ATT_nav_down_right: return 50; - case TAG_SVG_ATT_nav_left: return 51; - case TAG_SVG_ATT_nav_next: return 52; - case TAG_SVG_ATT_nav_prev: return 53; - case TAG_SVG_ATT_nav_right: return 54; - case TAG_SVG_ATT_nav_up: return 55; - case TAG_SVG_ATT_nav_up_left: return 56; - case TAG_SVG_ATT_nav_up_right: return 57; - case TAG_XMLEV_ATT_observer: return 58; - case TAG_SVG_ATT_offset: return 59; - case TAG_SVG_ATT_opacity: return 60; - case TAG_SVG_ATT_overflow: return 61; - case TAG_SVG_ATT_overlay: return 62; - case TAG_SVG_ATT_path: return 63; - case TAG_SVG_ATT_pathLength: return 64; - case TAG_SVG_ATT_pointer_events: return 65; - case TAG_SVG_ATT_points: return 66; - case TAG_SVG_ATT_preserveAspectRatio: return 67; - case TAG_SVG_ATT_r: return 68; - case TAG_SVG_ATT_repeatCount: return 69; - case TAG_SVG_ATT_repeatDur: return 70; - case TAG_SVG_ATT_requiredExtensions: return 71; - case TAG_SVG_ATT_requiredFeatures: return 72; - case TAG_SVG_ATT_requiredFormats: return 73; - case TAG_SVG_ATT_restart: return 74; - case TAG_SVG_ATT_rotate: return 75; - case TAG_LSR_ATT_rotation: return 76; - case TAG_SVG_ATT_rx: return 77; - case TAG_SVG_ATT_ry: return 78; - case TAG_LSR_ATT_scale: return 79; - case TAG_SVG_ATT_shape_rendering: return 80; - case TAG_SVG_ATT_size: return 81; - case TAG_SVG_ATT_solid_color: return 82; - case TAG_SVG_ATT_solid_opacity: return 83; - case TAG_SVG_ATT_stop_color: return 84; - case TAG_SVG_ATT_stop_opacity: return 85; - case TAG_SVG_ATT_stroke: return 86; - case TAG_SVG_ATT_stroke_dasharray: return 87; - case TAG_SVG_ATT_stroke_dashoffset: return 88; - case TAG_SVG_ATT_stroke_linecap: return 89; - case TAG_SVG_ATT_stroke_linejoin: return 90; - case TAG_SVG_ATT_stroke_miterlimit: return 91; - case TAG_SVG_ATT_stroke_opacity: return 92; - case TAG_SVG_ATT_stroke_width: return 93; - case TAG_LSR_ATT_svg_height: return 94; - case TAG_LSR_ATT_svg_width: return 95; - case TAG_SVG_ATT_syncBehavior: return 96; - case TAG_SVG_ATT_syncBehaviorDefault: return 97; - case TAG_SVG_ATT_syncReference: return 98; - case TAG_SVG_ATT_syncTolerance: return 99; - case TAG_SVG_ATT_syncToleranceDefault: return 100; - case TAG_SVG_ATT_systemLanguage: return 101; - case TAG_SVG_ATT_text_align: return 102; - case TAG_SVG_ATT_text_anchor: return 103; - case TAG_SVG_ATT_text_decoration: return 104; - case TAG_LSR_ATT_text_display: return 105; - case TAG_SVG_ATT_text_rendering: return 106; - case TAG_LSR_ATT_textContent: return 107; - case TAG_SVG_ATT_transform: return 108; - case TAG_SVG_ATT_transformBehavior: return 109; - case TAG_LSR_ATT_translation: return 110; - case TAG_SVG_ATT_vector_effect: return 111; - case TAG_SVG_ATT_viewBox: return 112; - case TAG_SVG_ATT_viewport_fill: return 113; - case TAG_SVG_ATT_viewport_fill_opacity: return 114; - case TAG_SVG_ATT_visibility: return 115; - case TAG_SVG_ATT_width: return 116; - case TAG_SVG_ATT_x: return 117; - case TAG_SVG_ATT_x1: return 118; - case TAG_SVG_ATT_x2: return 119; - case TAG_XLINK_ATT_actuate: return 120; - case TAG_XLINK_ATT_arcrole: return 121; - case TAG_XLINK_ATT_href: return 122; - case TAG_XLINK_ATT_role: return 123; - case TAG_XLINK_ATT_show: return 124; - case TAG_XLINK_ATT_title: return 125; - case TAG_XLINK_ATT_type: return 126; - case TAG_XML_ATT_base: return 127; - case TAG_XML_ATT_lang: return 128; - case TAG_SVG_ATT_y: return 129; - case TAG_SVG_ATT_y1: return 130; - case TAG_SVG_ATT_y2: return 131; - case TAG_SVG_ATT_zoomAndPan: return 132; - default: return -1; + case TAG_SVG_ATT_target: + return 0; + case TAG_SVG_ATT_accumulate: + return 1; + case TAG_SVG_ATT_additive: + return 2; + case TAG_SVG_ATT_audio_level: + return 3; + case TAG_SVG_ATT_bandwidth: + return 4; + case TAG_SVG_ATT_begin: + return 5; + case TAG_SVG_ATT_calcMode: + return 6; + case TAG_LSR_ATT_children: + return 7; + case TAG_SVG_ATT_choice: + return 8; + case TAG_SVG_ATT_clipBegin: + return 9; + case TAG_SVG_ATT_clipEnd: + return 10; + case TAG_SVG_ATT_color: + return 11; + case TAG_SVG_ATT_color_rendering: + return 12; + case TAG_SVG_ATT_cx: + return 13; + case TAG_SVG_ATT_cy: + return 14; + case TAG_SVG_ATT_d: + return 15; + case TAG_SVG_ATT_delta: + return 16; + case TAG_SVG_ATT_display: + return 17; + case TAG_SVG_ATT_display_align: + return 18; + case TAG_SVG_ATT_dur: + return 19; + case TAG_SVG_ATT_editable: + return 20; + case TAG_LSR_ATT_enabled: + return 21; + case TAG_SVG_ATT_end: + return 22; + case TAG_XMLEV_ATT_event: + return 23; + case TAG_SVG_ATT_externalResourcesRequired: + return 24; + case TAG_SVG_ATT_fill: + return 25; + case TAG_SVG_ATT_fill_opacity: + return 26; + case TAG_SVG_ATT_fill_rule: + return 27; + case TAG_SVG_ATT_focusable: + return 28; + case TAG_SVG_ATT_font_family: + return 29; + case TAG_SVG_ATT_font_size: + return 30; + case TAG_SVG_ATT_font_style: + return 31; + case TAG_SVG_ATT_font_variant: + return 32; + case TAG_SVG_ATT_font_weight: + return 33; + case TAG_SVG_ATT_fullscreen: + return 34; + case TAG_SVG_ATT_gradientUnits: + return 35; + case TAG_XMLEV_ATT_handler: + return 36; + case TAG_SVG_ATT_height: + return 37; + case TAG_SVG_ATT_image_rendering: + return 38; + case TAG_SVG_ATT_keyPoints: + return 39; + case TAG_SVG_ATT_keySplines: + return 40; + case TAG_SVG_ATT_keyTimes: + return 41; + case TAG_SVG_ATT_line_increment: + return 42; + case TAG_XMLEV_ATT_target: + return 43; + case TAG_SVG_ATT_mediaCharacterEncoding: + return 44; + case TAG_SVG_ATT_mediaContentEncodings: + return 45; + case TAG_SVG_ATT_mediaSize: + return 46; + case TAG_SVG_ATT_mediaTime: + return 47; + case TAG_SVG_ATT_nav_down: + return 48; + case TAG_SVG_ATT_nav_down_left: + return 49; + case TAG_SVG_ATT_nav_down_right: + return 50; + case TAG_SVG_ATT_nav_left: + return 51; + case TAG_SVG_ATT_nav_next: + return 52; + case TAG_SVG_ATT_nav_prev: + return 53; + case TAG_SVG_ATT_nav_right: + return 54; + case TAG_SVG_ATT_nav_up: + return 55; + case TAG_SVG_ATT_nav_up_left: + return 56; + case TAG_SVG_ATT_nav_up_right: + return 57; + case TAG_XMLEV_ATT_observer: + return 58; + case TAG_SVG_ATT_offset: + return 59; + case TAG_SVG_ATT_opacity: + return 60; + case TAG_SVG_ATT_overflow: + return 61; + case TAG_SVG_ATT_overlay: + return 62; + case TAG_SVG_ATT_path: + return 63; + case TAG_SVG_ATT_pathLength: + return 64; + case TAG_SVG_ATT_pointer_events: + return 65; + case TAG_SVG_ATT_points: + return 66; + case TAG_SVG_ATT_preserveAspectRatio: + return 67; + case TAG_SVG_ATT_r: + return 68; + case TAG_SVG_ATT_repeatCount: + return 69; + case TAG_SVG_ATT_repeatDur: + return 70; + case TAG_SVG_ATT_requiredExtensions: + return 71; + case TAG_SVG_ATT_requiredFeatures: + return 72; + case TAG_SVG_ATT_requiredFormats: + return 73; + case TAG_SVG_ATT_restart: + return 74; + case TAG_SVG_ATT_rotate: + return 75; + case TAG_LSR_ATT_rotation: + return 76; + case TAG_SVG_ATT_rx: + return 77; + case TAG_SVG_ATT_ry: + return 78; + case TAG_LSR_ATT_scale: + return 79; + case TAG_SVG_ATT_shape_rendering: + return 80; + case TAG_SVG_ATT_size: + return 81; + case TAG_SVG_ATT_solid_color: + return 82; + case TAG_SVG_ATT_solid_opacity: + return 83; + case TAG_SVG_ATT_stop_color: + return 84; + case TAG_SVG_ATT_stop_opacity: + return 85; + case TAG_SVG_ATT_stroke: + return 86; + case TAG_SVG_ATT_stroke_dasharray: + return 87; + case TAG_SVG_ATT_stroke_dashoffset: + return 88; + case TAG_SVG_ATT_stroke_linecap: + return 89; + case TAG_SVG_ATT_stroke_linejoin: + return 90; + case TAG_SVG_ATT_stroke_miterlimit: + return 91; + case TAG_SVG_ATT_stroke_opacity: + return 92; + case TAG_SVG_ATT_stroke_width: + return 93; + case TAG_LSR_ATT_svg_height: + return 94; + case TAG_LSR_ATT_svg_width: + return 95; + case TAG_SVG_ATT_syncBehavior: + return 96; + case TAG_SVG_ATT_syncBehaviorDefault: + return 97; + case TAG_SVG_ATT_syncReference: + return 98; + case TAG_SVG_ATT_syncTolerance: + return 99; + case TAG_SVG_ATT_syncToleranceDefault: + return 100; + case TAG_SVG_ATT_systemLanguage: + return 101; + case TAG_SVG_ATT_text_align: + return 102; + case TAG_SVG_ATT_text_anchor: + return 103; + case TAG_SVG_ATT_text_decoration: + return 104; + case TAG_LSR_ATT_text_display: + return 105; + case TAG_SVG_ATT_text_rendering: + return 106; + case TAG_LSR_ATT_textContent: + return 107; + case TAG_SVG_ATT_transform: + return 108; + case TAG_SVG_ATT_transformBehavior: + return 109; + case TAG_LSR_ATT_translation: + return 110; + case TAG_SVG_ATT_vector_effect: + return 111; + case TAG_SVG_ATT_viewBox: + return 112; + case TAG_SVG_ATT_viewport_fill: + return 113; + case TAG_SVG_ATT_viewport_fill_opacity: + return 114; + case TAG_SVG_ATT_visibility: + return 115; + case TAG_SVG_ATT_width: + return 116; + case TAG_SVG_ATT_x: + return 117; + case TAG_SVG_ATT_x1: + return 118; + case TAG_SVG_ATT_x2: + return 119; + case TAG_XLINK_ATT_actuate: + return 120; + case TAG_XLINK_ATT_arcrole: + return 121; + case TAG_XLINK_ATT_href: + return 122; + case TAG_XLINK_ATT_role: + return 123; + case TAG_XLINK_ATT_show: + return 124; + case TAG_XLINK_ATT_title: + return 125; + case TAG_XLINK_ATT_type: + return 126; + case TAG_XML_ATT_base: + return 127; + case TAG_XML_ATT_lang: + return 128; + case TAG_SVG_ATT_y: + return 129; + case TAG_SVG_ATT_y1: + return 130; + case TAG_SVG_ATT_y2: + return 131; + case TAG_SVG_ATT_zoomAndPan: + return 132; + default: + return -1; } } @@ -177,75 +311,144 @@ s32 gf_lsr_anim_type_from_attribute(u32 tag) { s32 gf_lsr_rare_type_from_attribute(u32 tag) { switch(tag) { - case TAG_SVG_ATT__class: return 0; - case TAG_SVG_ATT_audio_level: return 1; - case TAG_SVG_ATT_color: return 2; - case TAG_SVG_ATT_color_rendering: return 3; - case TAG_SVG_ATT_display: return 4; - case TAG_SVG_ATT_display_align: return 5; - case TAG_SVG_ATT_fill_opacity: return 6; - case TAG_SVG_ATT_fill_rule: return 7; - case TAG_SVG_ATT_image_rendering: return 8; - case TAG_SVG_ATT_line_increment: return 9; - case TAG_SVG_ATT_pointer_events: return 10; - case TAG_SVG_ATT_shape_rendering: return 11; - case TAG_SVG_ATT_solid_color: return 12; - case TAG_SVG_ATT_solid_opacity: return 13; - case TAG_SVG_ATT_stop_color: return 14; - case TAG_SVG_ATT_stop_opacity: return 15; - case TAG_SVG_ATT_stroke_dasharray: return 16; - case TAG_SVG_ATT_stroke_dashoffset: return 17; - case TAG_SVG_ATT_stroke_linecap: return 18; - case TAG_SVG_ATT_stroke_linejoin: return 19; - case TAG_SVG_ATT_stroke_miterlimit: return 20; - case TAG_SVG_ATT_stroke_opacity: return 21; - case TAG_SVG_ATT_stroke_width: return 22; - case TAG_SVG_ATT_text_anchor: return 23; - case TAG_SVG_ATT_text_rendering: return 24; - case TAG_SVG_ATT_viewport_fill: return 25; - case TAG_SVG_ATT_viewport_fill_opacity: return 26; - case TAG_SVG_ATT_vector_effect: return 27; - case TAG_SVG_ATT_visibility: return 28; - case TAG_SVG_ATT_requiredExtensions: return 29; - case TAG_SVG_ATT_requiredFeatures: return 30; - case TAG_SVG_ATT_requiredFormats: return 31; - case TAG_SVG_ATT_systemLanguage: return 32; - case TAG_XML_ATT_base: return 33; - case TAG_XML_ATT_lang: return 34; - case TAG_XML_ATT_space: return 35; - case TAG_SVG_ATT_nav_next: return 36; - case TAG_SVG_ATT_nav_up: return 37; - case TAG_SVG_ATT_nav_up_left: return 38; - case TAG_SVG_ATT_nav_up_right: return 39; - case TAG_SVG_ATT_nav_prev: return 40; - case TAG_SVG_ATT_nav_down: return 41; - case TAG_SVG_ATT_nav_down_left: return 42; - case TAG_SVG_ATT_nav_down_right: return 43; - case TAG_SVG_ATT_nav_left: return 44; - case TAG_SVG_ATT_focusable: return 45; - case TAG_SVG_ATT_nav_right: return 46; - case TAG_SVG_ATT_transform: return 47; - case TAG_SVG_ATT_text_decoration: return 48; - case TAG_SVG_ATT_syncMaster: return 49; - case TAG_SVG_ATT_focusHighlight: return 49; - case TAG_SVG_ATT_initialVisibility: return 49; - case TAG_SVG_ATT_fullscreen: return 49; - case TAG_SVG_ATT_requiredFonts: return 49; - case TAG_SVG_ATT_font_variant: return 50; - case TAG_SVG_ATT_font_family: return 51; - case TAG_SVG_ATT_font_size: return 52; - case TAG_SVG_ATT_font_style: return 53; - case TAG_SVG_ATT_font_weight: return 54; - case TAG_XLINK_ATT_title: return 55; - case TAG_XLINK_ATT_type: return 56; - case TAG_XLINK_ATT_role: return 57; - case TAG_XLINK_ATT_arcrole: return 58; - case TAG_XLINK_ATT_actuate: return 59; - case TAG_XLINK_ATT_show: return 60; - case TAG_SVG_ATT_end: return 61; - case TAG_SVG_ATT_max: return 62; - case TAG_SVG_ATT_min: return 63; - default: return -1; + case TAG_SVG_ATT__class: + return 0; + case TAG_SVG_ATT_audio_level: + return 1; + case TAG_SVG_ATT_color: + return 2; + case TAG_SVG_ATT_color_rendering: + return 3; + case TAG_SVG_ATT_display: + return 4; + case TAG_SVG_ATT_display_align: + return 5; + case TAG_SVG_ATT_fill_opacity: + return 6; + case TAG_SVG_ATT_fill_rule: + return 7; + case TAG_SVG_ATT_image_rendering: + return 8; + case TAG_SVG_ATT_line_increment: + return 9; + case TAG_SVG_ATT_pointer_events: + return 10; + case TAG_SVG_ATT_shape_rendering: + return 11; + case TAG_SVG_ATT_solid_color: + return 12; + case TAG_SVG_ATT_solid_opacity: + return 13; + case TAG_SVG_ATT_stop_color: + return 14; + case TAG_SVG_ATT_stop_opacity: + return 15; + case TAG_SVG_ATT_stroke_dasharray: + return 16; + case TAG_SVG_ATT_stroke_dashoffset: + return 17; + case TAG_SVG_ATT_stroke_linecap: + return 18; + case TAG_SVG_ATT_stroke_linejoin: + return 19; + case TAG_SVG_ATT_stroke_miterlimit: + return 20; + case TAG_SVG_ATT_stroke_opacity: + return 21; + case TAG_SVG_ATT_stroke_width: + return 22; + case TAG_SVG_ATT_text_anchor: + return 23; + case TAG_SVG_ATT_text_rendering: + return 24; + case TAG_SVG_ATT_viewport_fill: + return 25; + case TAG_SVG_ATT_viewport_fill_opacity: + return 26; + case TAG_SVG_ATT_vector_effect: + return 27; + case TAG_SVG_ATT_visibility: + return 28; + case TAG_SVG_ATT_requiredExtensions: + return 29; + case TAG_SVG_ATT_requiredFeatures: + return 30; + case TAG_SVG_ATT_requiredFormats: + return 31; + case TAG_SVG_ATT_systemLanguage: + return 32; + case TAG_XML_ATT_base: + return 33; + case TAG_XML_ATT_lang: + return 34; + case TAG_XML_ATT_space: + return 35; + case TAG_SVG_ATT_nav_next: + return 36; + case TAG_SVG_ATT_nav_up: + return 37; + case TAG_SVG_ATT_nav_up_left: + return 38; + case TAG_SVG_ATT_nav_up_right: + return 39; + case TAG_SVG_ATT_nav_prev: + return 40; + case TAG_SVG_ATT_nav_down: + return 41; + case TAG_SVG_ATT_nav_down_left: + return 42; + case TAG_SVG_ATT_nav_down_right: + return 43; + case TAG_SVG_ATT_nav_left: + return 44; + case TAG_SVG_ATT_focusable: + return 45; + case TAG_SVG_ATT_nav_right: + return 46; + case TAG_SVG_ATT_transform: + return 47; + case TAG_SVG_ATT_text_decoration: + return 48; + case TAG_SVG_ATT_syncMaster: + return 49; + case TAG_SVG_ATT_focusHighlight: + return 49; + case TAG_SVG_ATT_initialVisibility: + return 49; + case TAG_SVG_ATT_fullscreen: + return 49; + case TAG_SVG_ATT_requiredFonts: + return 49; + case TAG_SVG_ATT_font_variant: + return 50; + case TAG_SVG_ATT_font_family: + return 51; + case TAG_SVG_ATT_font_size: + return 52; + case TAG_SVG_ATT_font_style: + return 53; + case TAG_SVG_ATT_font_weight: + return 54; + case TAG_XLINK_ATT_title: + return 55; + case TAG_XLINK_ATT_type: + return 56; + case TAG_XLINK_ATT_role: + return 57; + case TAG_XLINK_ATT_arcrole: + return 58; + case TAG_XLINK_ATT_actuate: + return 59; + case TAG_XLINK_ATT_show: + return 60; + case TAG_SVG_ATT_end: + return 61; + case TAG_SVG_ATT_max: + return 62; + case TAG_SVG_ATT_min: + return 63; + default: + return -1; } } @@ -253,140 +456,274 @@ s32 gf_lsr_rare_type_from_attribute(u32 tag) { s32 gf_lsr_anim_type_to_attribute(u32 tag) { switch(tag) { - case 0: return TAG_SVG_ATT_target; - case 1: return TAG_SVG_ATT_accumulate; - case 2: return TAG_SVG_ATT_additive; - case 3: return TAG_SVG_ATT_audio_level; - case 4: return TAG_SVG_ATT_bandwidth; - case 5: return TAG_SVG_ATT_begin; - case 6: return TAG_SVG_ATT_calcMode; - case 7: return TAG_LSR_ATT_children; - case 8: return TAG_SVG_ATT_choice; - case 9: return TAG_SVG_ATT_clipBegin; - case 10: return TAG_SVG_ATT_clipEnd; - case 11: return TAG_SVG_ATT_color; - case 12: return TAG_SVG_ATT_color_rendering; - case 13: return TAG_SVG_ATT_cx; - case 14: return TAG_SVG_ATT_cy; - case 15: return TAG_SVG_ATT_d; - case 16: return TAG_SVG_ATT_delta; - case 17: return TAG_SVG_ATT_display; - case 18: return TAG_SVG_ATT_display_align; - case 19: return TAG_SVG_ATT_dur; - case 20: return TAG_SVG_ATT_editable; - case 21: return TAG_LSR_ATT_enabled; - case 22: return TAG_SVG_ATT_end; - case 23: return TAG_XMLEV_ATT_event; - case 24: return TAG_SVG_ATT_externalResourcesRequired; - case 25: return TAG_SVG_ATT_fill; - case 26: return TAG_SVG_ATT_fill_opacity; - case 27: return TAG_SVG_ATT_fill_rule; - case 28: return TAG_SVG_ATT_focusable; - case 29: return TAG_SVG_ATT_font_family; - case 30: return TAG_SVG_ATT_font_size; - case 31: return TAG_SVG_ATT_font_style; - case 32: return TAG_SVG_ATT_font_variant; - case 33: return TAG_SVG_ATT_font_weight; - case 34: return TAG_SVG_ATT_fullscreen; - case 35: return TAG_SVG_ATT_gradientUnits; - case 36: return TAG_XMLEV_ATT_handler; - case 37: return TAG_SVG_ATT_height; - case 38: return TAG_SVG_ATT_image_rendering; - case 39: return TAG_SVG_ATT_keyPoints; - case 40: return TAG_SVG_ATT_keySplines; - case 41: return TAG_SVG_ATT_keyTimes; - case 42: return TAG_SVG_ATT_line_increment; - case 43: return TAG_XMLEV_ATT_target; - case 44: return TAG_SVG_ATT_mediaCharacterEncoding; - case 45: return TAG_SVG_ATT_mediaContentEncodings; - case 46: return TAG_SVG_ATT_mediaSize; - case 47: return TAG_SVG_ATT_mediaTime; - case 48: return TAG_SVG_ATT_nav_down; - case 49: return TAG_SVG_ATT_nav_down_left; - case 50: return TAG_SVG_ATT_nav_down_right; - case 51: return TAG_SVG_ATT_nav_left; - case 52: return TAG_SVG_ATT_nav_next; - case 53: return TAG_SVG_ATT_nav_prev; - case 54: return TAG_SVG_ATT_nav_right; - case 55: return TAG_SVG_ATT_nav_up; - case 56: return TAG_SVG_ATT_nav_up_left; - case 57: return TAG_SVG_ATT_nav_up_right; - case 58: return TAG_XMLEV_ATT_observer; - case 59: return TAG_SVG_ATT_offset; - case 60: return TAG_SVG_ATT_opacity; - case 61: return TAG_SVG_ATT_overflow; - case 62: return TAG_SVG_ATT_overlay; - case 63: return TAG_SVG_ATT_path; - case 64: return TAG_SVG_ATT_pathLength; - case 65: return TAG_SVG_ATT_pointer_events; - case 66: return TAG_SVG_ATT_points; - case 67: return TAG_SVG_ATT_preserveAspectRatio; - case 68: return TAG_SVG_ATT_r; - case 69: return TAG_SVG_ATT_repeatCount; - case 70: return TAG_SVG_ATT_repeatDur; - case 71: return TAG_SVG_ATT_requiredExtensions; - case 72: return TAG_SVG_ATT_requiredFeatures; - case 73: return TAG_SVG_ATT_requiredFormats; - case 74: return TAG_SVG_ATT_restart; - case 75: return TAG_SVG_ATT_rotate; - case 76: return TAG_LSR_ATT_rotation; - case 77: return TAG_SVG_ATT_rx; - case 78: return TAG_SVG_ATT_ry; - case 79: return TAG_LSR_ATT_scale; - case 80: return TAG_SVG_ATT_shape_rendering; - case 81: return TAG_SVG_ATT_size; - case 82: return TAG_SVG_ATT_solid_color; - case 83: return TAG_SVG_ATT_solid_opacity; - case 84: return TAG_SVG_ATT_stop_color; - case 85: return TAG_SVG_ATT_stop_opacity; - case 86: return TAG_SVG_ATT_stroke; - case 87: return TAG_SVG_ATT_stroke_dasharray; - case 88: return TAG_SVG_ATT_stroke_dashoffset; - case 89: return TAG_SVG_ATT_stroke_linecap; - case 90: return TAG_SVG_ATT_stroke_linejoin; - case 91: return TAG_SVG_ATT_stroke_miterlimit; - case 92: return TAG_SVG_ATT_stroke_opacity; - case 93: return TAG_SVG_ATT_stroke_width; - case 94: return TAG_LSR_ATT_svg_height; - case 95: return TAG_LSR_ATT_svg_width; - case 96: return TAG_SVG_ATT_syncBehavior; - case 97: return TAG_SVG_ATT_syncBehaviorDefault; - case 98: return TAG_SVG_ATT_syncReference; - case 99: return TAG_SVG_ATT_syncTolerance; - case 100: return TAG_SVG_ATT_syncToleranceDefault; - case 101: return TAG_SVG_ATT_systemLanguage; - case 102: return TAG_SVG_ATT_text_align; - case 103: return TAG_SVG_ATT_text_anchor; - case 104: return TAG_SVG_ATT_text_decoration; - case 105: return TAG_LSR_ATT_text_display; - case 106: return TAG_SVG_ATT_text_rendering; - case 107: return TAG_LSR_ATT_textContent; - case 108: return TAG_SVG_ATT_transform; - case 109: return TAG_SVG_ATT_transformBehavior; - case 110: return TAG_LSR_ATT_translation; - case 111: return TAG_SVG_ATT_vector_effect; - case 112: return TAG_SVG_ATT_viewBox; - case 113: return TAG_SVG_ATT_viewport_fill; - case 114: return TAG_SVG_ATT_viewport_fill_opacity; - case 115: return TAG_SVG_ATT_visibility; - case 116: return TAG_SVG_ATT_width; - case 117: return TAG_SVG_ATT_x; - case 118: return TAG_SVG_ATT_x1; - case 119: return TAG_SVG_ATT_x2; - case 120: return TAG_XLINK_ATT_actuate; - case 121: return TAG_XLINK_ATT_arcrole; - case 122: return TAG_XLINK_ATT_href; - case 123: return TAG_XLINK_ATT_role; - case 124: return TAG_XLINK_ATT_show; - case 125: return TAG_XLINK_ATT_title; - case 126: return TAG_XLINK_ATT_type; - case 127: return TAG_XML_ATT_base; - case 128: return TAG_XML_ATT_lang; - case 129: return TAG_SVG_ATT_y; - case 130: return TAG_SVG_ATT_y1; - case 131: return TAG_SVG_ATT_y2; - case 132: return TAG_SVG_ATT_zoomAndPan; - default: return -1; + case 0: + return TAG_SVG_ATT_target; + case 1: + return TAG_SVG_ATT_accumulate; + case 2: + return TAG_SVG_ATT_additive; + case 3: + return TAG_SVG_ATT_audio_level; + case 4: + return TAG_SVG_ATT_bandwidth; + case 5: + return TAG_SVG_ATT_begin; + case 6: + return TAG_SVG_ATT_calcMode; + case 7: + return TAG_LSR_ATT_children; + case 8: + return TAG_SVG_ATT_choice; + case 9: + return TAG_SVG_ATT_clipBegin; + case 10: + return TAG_SVG_ATT_clipEnd; + case 11: + return TAG_SVG_ATT_color; + case 12: + return TAG_SVG_ATT_color_rendering; + case 13: + return TAG_SVG_ATT_cx; + case 14: + return TAG_SVG_ATT_cy; + case 15: + return TAG_SVG_ATT_d; + case 16: + return TAG_SVG_ATT_delta; + case 17: + return TAG_SVG_ATT_display; + case 18: + return TAG_SVG_ATT_display_align; + case 19: + return TAG_SVG_ATT_dur; + case 20: + return TAG_SVG_ATT_editable; + case 21: + return TAG_LSR_ATT_enabled; + case 22: + return TAG_SVG_ATT_end; + case 23: + return TAG_XMLEV_ATT_event; + case 24: + return TAG_SVG_ATT_externalResourcesRequired; + case 25: + return TAG_SVG_ATT_fill; + case 26: + return TAG_SVG_ATT_fill_opacity; + case 27: + return TAG_SVG_ATT_fill_rule; + case 28: + return TAG_SVG_ATT_focusable; + case 29: + return TAG_SVG_ATT_font_family; + case 30: + return TAG_SVG_ATT_font_size; + case 31: + return TAG_SVG_ATT_font_style; + case 32: + return TAG_SVG_ATT_font_variant; + case 33: + return TAG_SVG_ATT_font_weight; + case 34: + return TAG_SVG_ATT_fullscreen; + case 35: + return TAG_SVG_ATT_gradientUnits; + case 36: + return TAG_XMLEV_ATT_handler; + case 37: + return TAG_SVG_ATT_height; + case 38: + return TAG_SVG_ATT_image_rendering; + case 39: + return TAG_SVG_ATT_keyPoints; + case 40: + return TAG_SVG_ATT_keySplines; + case 41: + return TAG_SVG_ATT_keyTimes; + case 42: + return TAG_SVG_ATT_line_increment; + case 43: + return TAG_XMLEV_ATT_target; + case 44: + return TAG_SVG_ATT_mediaCharacterEncoding; + case 45: + return TAG_SVG_ATT_mediaContentEncodings; + case 46: + return TAG_SVG_ATT_mediaSize; + case 47: + return TAG_SVG_ATT_mediaTime; + case 48: + return TAG_SVG_ATT_nav_down; + case 49: + return TAG_SVG_ATT_nav_down_left; + case 50: + return TAG_SVG_ATT_nav_down_right; + case 51: + return TAG_SVG_ATT_nav_left; + case 52: + return TAG_SVG_ATT_nav_next; + case 53: + return TAG_SVG_ATT_nav_prev; + case 54: + return TAG_SVG_ATT_nav_right; + case 55: + return TAG_SVG_ATT_nav_up; + case 56: + return TAG_SVG_ATT_nav_up_left; + case 57: + return TAG_SVG_ATT_nav_up_right; + case 58: + return TAG_XMLEV_ATT_observer; + case 59: + return TAG_SVG_ATT_offset; + case 60: + return TAG_SVG_ATT_opacity; + case 61: + return TAG_SVG_ATT_overflow; + case 62: + return TAG_SVG_ATT_overlay; + case 63: + return TAG_SVG_ATT_path; + case 64: + return TAG_SVG_ATT_pathLength; + case 65: + return TAG_SVG_ATT_pointer_events; + case 66: + return TAG_SVG_ATT_points; + case 67: + return TAG_SVG_ATT_preserveAspectRatio; + case 68: + return TAG_SVG_ATT_r; + case 69: + return TAG_SVG_ATT_repeatCount; + case 70: + return TAG_SVG_ATT_repeatDur; + case 71: + return TAG_SVG_ATT_requiredExtensions; + case 72: + return TAG_SVG_ATT_requiredFeatures; + case 73: + return TAG_SVG_ATT_requiredFormats; + case 74: + return TAG_SVG_ATT_restart; + case 75: + return TAG_SVG_ATT_rotate; + case 76: + return TAG_LSR_ATT_rotation; + case 77: + return TAG_SVG_ATT_rx; + case 78: + return TAG_SVG_ATT_ry; + case 79: + return TAG_LSR_ATT_scale; + case 80: + return TAG_SVG_ATT_shape_rendering; + case 81: + return TAG_SVG_ATT_size; + case 82: + return TAG_SVG_ATT_solid_color; + case 83: + return TAG_SVG_ATT_solid_opacity; + case 84: + return TAG_SVG_ATT_stop_color; + case 85: + return TAG_SVG_ATT_stop_opacity; + case 86: + return TAG_SVG_ATT_stroke; + case 87: + return TAG_SVG_ATT_stroke_dasharray; + case 88: + return TAG_SVG_ATT_stroke_dashoffset; + case 89: + return TAG_SVG_ATT_stroke_linecap; + case 90: + return TAG_SVG_ATT_stroke_linejoin; + case 91: + return TAG_SVG_ATT_stroke_miterlimit; + case 92: + return TAG_SVG_ATT_stroke_opacity; + case 93: + return TAG_SVG_ATT_stroke_width; + case 94: + return TAG_LSR_ATT_svg_height; + case 95: + return TAG_LSR_ATT_svg_width; + case 96: + return TAG_SVG_ATT_syncBehavior; + case 97: + return TAG_SVG_ATT_syncBehaviorDefault; + case 98: + return TAG_SVG_ATT_syncReference; + case 99: + return TAG_SVG_ATT_syncTolerance; + case 100: + return TAG_SVG_ATT_syncToleranceDefault; + case 101: + return TAG_SVG_ATT_systemLanguage; + case 102: + return TAG_SVG_ATT_text_align; + case 103: + return TAG_SVG_ATT_text_anchor; + case 104: + return TAG_SVG_ATT_text_decoration; + case 105: + return TAG_LSR_ATT_text_display; + case 106: + return TAG_SVG_ATT_text_rendering; + case 107: + return TAG_LSR_ATT_textContent; + case 108: + return TAG_SVG_ATT_transform; + case 109: + return TAG_SVG_ATT_transformBehavior; + case 110: + return TAG_LSR_ATT_translation; + case 111: + return TAG_SVG_ATT_vector_effect; + case 112: + return TAG_SVG_ATT_viewBox; + case 113: + return TAG_SVG_ATT_viewport_fill; + case 114: + return TAG_SVG_ATT_viewport_fill_opacity; + case 115: + return TAG_SVG_ATT_visibility; + case 116: + return TAG_SVG_ATT_width; + case 117: + return TAG_SVG_ATT_x; + case 118: + return TAG_SVG_ATT_x1; + case 119: + return TAG_SVG_ATT_x2; + case 120: + return TAG_XLINK_ATT_actuate; + case 121: + return TAG_XLINK_ATT_arcrole; + case 122: + return TAG_XLINK_ATT_href; + case 123: + return TAG_XLINK_ATT_role; + case 124: + return TAG_XLINK_ATT_show; + case 125: + return TAG_XLINK_ATT_title; + case 126: + return TAG_XLINK_ATT_type; + case 127: + return TAG_XML_ATT_base; + case 128: + return TAG_XML_ATT_lang; + case 129: + return TAG_SVG_ATT_y; + case 130: + return TAG_SVG_ATT_y1; + case 131: + return TAG_SVG_ATT_y2; + case 132: + return TAG_SVG_ATT_zoomAndPan; + default: + return -1; } } @@ -394,70 +731,134 @@ s32 gf_lsr_anim_type_to_attribute(u32 tag) { s32 gf_lsr_rare_type_to_attribute(u32 tag) { switch(tag) { - case 0: return TAG_SVG_ATT__class; - case 1: return TAG_SVG_ATT_audio_level; - case 2: return TAG_SVG_ATT_color; - case 3: return TAG_SVG_ATT_color_rendering; - case 4: return TAG_SVG_ATT_display; - case 5: return TAG_SVG_ATT_display_align; - case 6: return TAG_SVG_ATT_fill_opacity; - case 7: return TAG_SVG_ATT_fill_rule; - case 8: return TAG_SVG_ATT_image_rendering; - case 9: return TAG_SVG_ATT_line_increment; - case 10: return TAG_SVG_ATT_pointer_events; - case 11: return TAG_SVG_ATT_shape_rendering; - case 12: return TAG_SVG_ATT_solid_color; - case 13: return TAG_SVG_ATT_solid_opacity; - case 14: return TAG_SVG_ATT_stop_color; - case 15: return TAG_SVG_ATT_stop_opacity; - case 16: return TAG_SVG_ATT_stroke_dasharray; - case 17: return TAG_SVG_ATT_stroke_dashoffset; - case 18: return TAG_SVG_ATT_stroke_linecap; - case 19: return TAG_SVG_ATT_stroke_linejoin; - case 20: return TAG_SVG_ATT_stroke_miterlimit; - case 21: return TAG_SVG_ATT_stroke_opacity; - case 22: return TAG_SVG_ATT_stroke_width; - case 23: return TAG_SVG_ATT_text_anchor; - case 24: return TAG_SVG_ATT_text_rendering; - case 25: return TAG_SVG_ATT_viewport_fill; - case 26: return TAG_SVG_ATT_viewport_fill_opacity; - case 27: return TAG_SVG_ATT_vector_effect; - case 28: return TAG_SVG_ATT_visibility; - case 29: return TAG_SVG_ATT_requiredExtensions; - case 30: return TAG_SVG_ATT_requiredFeatures; - case 31: return TAG_SVG_ATT_requiredFormats; - case 32: return TAG_SVG_ATT_systemLanguage; - case 33: return TAG_XML_ATT_base; - case 34: return TAG_XML_ATT_lang; - case 35: return TAG_XML_ATT_space; - case 36: return TAG_SVG_ATT_nav_next; - case 37: return TAG_SVG_ATT_nav_up; - case 38: return TAG_SVG_ATT_nav_up_left; - case 39: return TAG_SVG_ATT_nav_up_right; - case 40: return TAG_SVG_ATT_nav_prev; - case 41: return TAG_SVG_ATT_nav_down; - case 42: return TAG_SVG_ATT_nav_down_left; - case 43: return TAG_SVG_ATT_nav_down_right; - case 44: return TAG_SVG_ATT_nav_left; - case 45: return TAG_SVG_ATT_focusable; - case 46: return TAG_SVG_ATT_nav_right; - case 47: return TAG_SVG_ATT_transform; - case 48: return TAG_SVG_ATT_text_decoration; - case 50: return TAG_SVG_ATT_font_variant; - case 51: return TAG_SVG_ATT_font_family; - case 52: return TAG_SVG_ATT_font_size; - case 53: return TAG_SVG_ATT_font_style; - case 54: return TAG_SVG_ATT_font_weight; - case 55: return TAG_XLINK_ATT_title; - case 56: return TAG_XLINK_ATT_type; - case 57: return TAG_XLINK_ATT_role; - case 58: return TAG_XLINK_ATT_arcrole; - case 59: return TAG_XLINK_ATT_actuate; - case 60: return TAG_XLINK_ATT_show; - case 61: return TAG_SVG_ATT_end; - case 62: return TAG_SVG_ATT_max; - case 63: return TAG_SVG_ATT_min; - default: return -1; + case 0: + return TAG_SVG_ATT__class; + case 1: + return TAG_SVG_ATT_audio_level; + case 2: + return TAG_SVG_ATT_color; + case 3: + return TAG_SVG_ATT_color_rendering; + case 4: + return TAG_SVG_ATT_display; + case 5: + return TAG_SVG_ATT_display_align; + case 6: + return TAG_SVG_ATT_fill_opacity; + case 7: + return TAG_SVG_ATT_fill_rule; + case 8: + return TAG_SVG_ATT_image_rendering; + case 9: + return TAG_SVG_ATT_line_increment; + case 10: + return TAG_SVG_ATT_pointer_events; + case 11: + return TAG_SVG_ATT_shape_rendering; + case 12: + return TAG_SVG_ATT_solid_color; + case 13: + return TAG_SVG_ATT_solid_opacity; + case 14: + return TAG_SVG_ATT_stop_color; + case 15: + return TAG_SVG_ATT_stop_opacity; + case 16: + return TAG_SVG_ATT_stroke_dasharray; + case 17: + return TAG_SVG_ATT_stroke_dashoffset; + case 18: + return TAG_SVG_ATT_stroke_linecap; + case 19: + return TAG_SVG_ATT_stroke_linejoin; + case 20: + return TAG_SVG_ATT_stroke_miterlimit; + case 21: + return TAG_SVG_ATT_stroke_opacity; + case 22: + return TAG_SVG_ATT_stroke_width; + case 23: + return TAG_SVG_ATT_text_anchor; + case 24: + return TAG_SVG_ATT_text_rendering; + case 25: + return TAG_SVG_ATT_viewport_fill; + case 26: + return TAG_SVG_ATT_viewport_fill_opacity; + case 27: + return TAG_SVG_ATT_vector_effect; + case 28: + return TAG_SVG_ATT_visibility; + case 29: + return TAG_SVG_ATT_requiredExtensions; + case 30: + return TAG_SVG_ATT_requiredFeatures; + case 31: + return TAG_SVG_ATT_requiredFormats; + case 32: + return TAG_SVG_ATT_systemLanguage; + case 33: + return TAG_XML_ATT_base; + case 34: + return TAG_XML_ATT_lang; + case 35: + return TAG_XML_ATT_space; + case 36: + return TAG_SVG_ATT_nav_next; + case 37: + return TAG_SVG_ATT_nav_up; + case 38: + return TAG_SVG_ATT_nav_up_left; + case 39: + return TAG_SVG_ATT_nav_up_right; + case 40: + return TAG_SVG_ATT_nav_prev; + case 41: + return TAG_SVG_ATT_nav_down; + case 42: + return TAG_SVG_ATT_nav_down_left; + case 43: + return TAG_SVG_ATT_nav_down_right; + case 44: + return TAG_SVG_ATT_nav_left; + case 45: + return TAG_SVG_ATT_focusable; + case 46: + return TAG_SVG_ATT_nav_right; + case 47: + return TAG_SVG_ATT_transform; + case 48: + return TAG_SVG_ATT_text_decoration; + case 50: + return TAG_SVG_ATT_font_variant; + case 51: + return TAG_SVG_ATT_font_family; + case 52: + return TAG_SVG_ATT_font_size; + case 53: + return TAG_SVG_ATT_font_style; + case 54: + return TAG_SVG_ATT_font_weight; + case 55: + return TAG_XLINK_ATT_title; + case 56: + return TAG_XLINK_ATT_type; + case 57: + return TAG_XLINK_ATT_role; + case 58: + return TAG_XLINK_ATT_arcrole; + case 59: + return TAG_XLINK_ATT_actuate; + case 60: + return TAG_XLINK_ATT_show; + case 61: + return TAG_SVG_ATT_end; + case 62: + return TAG_SVG_ATT_max; + case 63: + return TAG_SVG_ATT_min; + default: + return -1; } } diff --git a/src/mcrypt/cbc.c b/src/mcrypt/cbc.c index eec3e9a..9b7e075 100644 --- a/src/mcrypt/cbc.c +++ b/src/mcrypt/cbc.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -32,47 +32,47 @@ typedef struct cbc_buf { static GF_Err _init_mcrypt( void* _buf,void *key, int lenofkey, void *IV, int size) { - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; -/* For cbc */ + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + /* For cbc */ buf->previous_ciphertext = - buf->previous_cipher = NULL; + buf->previous_cipher = NULL; buf->blocksize = size; - + buf->previous_ciphertext = gf_malloc( size); buf->previous_cipher = gf_malloc( size); - + if (buf->previous_ciphertext==NULL || - buf->previous_cipher==NULL) goto freeall; - + buf->previous_cipher==NULL) goto freeall; + if (IV!=NULL) { memcpy(buf->previous_ciphertext, IV, size); } else { - memset(buf->previous_ciphertext, 0, size); + memset(buf->previous_ciphertext, 0, size); } return GF_OK; - freeall: - if (buf->previous_ciphertext) gf_free(buf->previous_ciphertext); - if (buf->previous_cipher) gf_free(buf->previous_cipher); - return GF_OUT_OF_MEM; +freeall: + if (buf->previous_ciphertext) gf_free(buf->previous_ciphertext); + if (buf->previous_cipher) gf_free(buf->previous_cipher); + return GF_OUT_OF_MEM; } static GF_Err _mcrypt_set_state( void* _buf, void *IV, int size) { -/* For cbc */ - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + /* For cbc */ + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; memcpy(buf->previous_ciphertext, IV, size); memcpy(buf->previous_cipher, IV, size); - + return GF_OK; } static GF_Err _mcrypt_get_state( void* _buf, void *IV, int *size) { - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; if (*size < buf->blocksize) { *size = buf->blocksize; return GF_BAD_PARAM; @@ -86,21 +86,21 @@ static GF_Err _mcrypt_get_state( void* _buf, void *IV, int *size) static void _end_mcrypt( void* _buf) { - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; gf_free(buf->previous_ciphertext); gf_free(buf->previous_cipher); } static GF_Err _mcrypt( void* _buf, void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) { - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; u32 *fplain = plaintext; u32 *plain; - int dblock, dlen, i, j; + int dblock, dlen, i, j; void (*_mcrypt_block_encrypt) (void *, void *); _mcrypt_block_encrypt = func; - + dblock = blocksize / sizeof(u32); dlen = len / blocksize; for (j = 0; j < dlen ; j++) { @@ -124,10 +124,10 @@ static GF_Err _mcrypt( void* _buf, void *plaintext, int len, int blocksize, void static GF_Err _mdecrypt( void* _buf, void *ciphertext, int len, int blocksize,void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) { - CBC_BUFFER* buf = (CBC_BUFFER* )_buf; + CBC_BUFFER* buf = (CBC_BUFFER* )_buf; u32 *cipher; u32 *fcipher = ciphertext; - int i, j, dlen, dblock; + int i, j, dlen, dblock; void (*_mcrypt_block_decrypt) (void *, void *); _mcrypt_block_decrypt = func2; diff --git a/src/mcrypt/cfb.c b/src/mcrypt/cfb.c index fd4c228..43a75f4 100644 --- a/src/mcrypt/cfb.c +++ b/src/mcrypt/cfb.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001,2002 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -32,28 +32,28 @@ typedef struct cfb_buf { static GF_Err _init_mcrypt( CFB_BUFFER* buf, void *key, int lenofkey, void *IV, int size) { - buf->s_register = buf->enc_s_register = NULL; - - buf->blocksize = size; -/* For cfb */ + buf->s_register = buf->enc_s_register = NULL; + + buf->blocksize = size; + /* For cfb */ buf->s_register=gf_malloc( size); - if (buf->s_register==NULL) goto freeall; + if (buf->s_register==NULL) goto freeall; buf->enc_s_register=gf_malloc( size); - if (buf->enc_s_register==NULL) goto freeall; + if (buf->enc_s_register==NULL) goto freeall; if (IV!=NULL) { memcpy(buf->s_register, IV, size); } else { - memset(buf->s_register, 0, size); + memset(buf->s_register, 0, size); } -/* End cfb */ + /* End cfb */ return GF_OK; - freeall: - if (buf->s_register) gf_free(buf->s_register); - if (buf->enc_s_register) gf_free(buf->enc_s_register); - return GF_OUT_OF_MEM; +freeall: + if (buf->s_register) gf_free(buf->s_register); + if (buf->enc_s_register) gf_free(buf->enc_s_register); + return GF_OUT_OF_MEM; } @@ -85,7 +85,7 @@ static void _end_mcrypt( CFB_BUFFER* buf) { } static GF_Err _mcrypt( CFB_BUFFER* buf, void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is 1 u8 (8bit cfb) */ +{ /* plaintext is 1 u8 (8bit cfb) */ char *plain = plaintext; int i, j; void (*_mcrypt_block_encrypt) (void *, void *); @@ -100,7 +100,7 @@ static GF_Err _mcrypt( CFB_BUFFER* buf, void *plaintext, int len, int blocksize, plain[j] ^= buf->enc_s_register[0]; -/* Shift the register */ + /* Shift the register */ for (i = 0; i < (blocksize - 1); i++) buf->s_register[i] = buf->s_register[i + 1]; @@ -113,7 +113,7 @@ static GF_Err _mcrypt( CFB_BUFFER* buf, void *plaintext, int len, int blocksize, static GF_Err _mdecrypt( CFB_BUFFER* buf, void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is 1 u8 (8bit ofb) */ +{ /* plaintext is 1 u8 (8bit ofb) */ char *plain = plaintext; int i, j; void (*_mcrypt_block_encrypt) (void *, void *); @@ -126,7 +126,7 @@ static GF_Err _mdecrypt( CFB_BUFFER* buf, void *plaintext, int len, int blocksiz _mcrypt_block_encrypt(akey, buf->enc_s_register); -/* Shift the register */ + /* Shift the register */ for (i = 0; i < (blocksize - 1); i++) buf->s_register[i] = buf->s_register[i + 1]; diff --git a/src/mcrypt/ctr.c b/src/mcrypt/ctr.c index 467db0f..569159d 100644 --- a/src/mcrypt/ctr.c +++ b/src/mcrypt/ctr.c @@ -1,9 +1,9 @@ /* * Copyright (C) 2002 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -34,9 +34,9 @@ typedef struct ctr_buf { * has been reached. */ static void increase_counter( u8 *x, int x_size) { -register int i, y=0; + register int i, y=0; - for (i=x_size-1;i>=0;i--) { + for (i=x_size-1; i>=0; i--) { y = 0; if ( x[i] == 0xff) { x[i] = 0; @@ -55,30 +55,30 @@ register int i, y=0; */ GF_Err _init_mcrypt( void *buf, void *key, int lenofkey, void *IV, int size) { - ((CTR_BUFFER* )buf)->c_counter = ((CTR_BUFFER* )buf)->enc_counter = NULL; + ((CTR_BUFFER* )buf)->c_counter = ((CTR_BUFFER* )buf)->enc_counter = NULL; -/* For ctr */ - ((CTR_BUFFER* )buf)->c_counter_pos = 0; - ((CTR_BUFFER* )buf)->blocksize = size; + /* For ctr */ + ((CTR_BUFFER* )buf)->c_counter_pos = 0; + ((CTR_BUFFER* )buf)->blocksize = size; ((CTR_BUFFER* )buf)->c_counter = (u8 *)gf_malloc(size); - if (((CTR_BUFFER* )buf)->c_counter==NULL) goto freeall; + if (((CTR_BUFFER* )buf)->c_counter==NULL) goto freeall; ((CTR_BUFFER* )buf)->enc_counter = (u8 *)gf_malloc(size); - if (((CTR_BUFFER* )buf)->enc_counter==NULL) goto freeall; - - if (IV!=NULL) { - memcpy(((CTR_BUFFER* )buf)->enc_counter, IV, size); - memcpy(((CTR_BUFFER* )buf)->c_counter, IV, size); - } + if (((CTR_BUFFER* )buf)->enc_counter==NULL) goto freeall; + + if (IV!=NULL) { + memcpy(((CTR_BUFFER* )buf)->enc_counter, IV, size); + memcpy(((CTR_BUFFER* )buf)->c_counter, IV, size); + } -/* End ctr */ + /* End ctr */ return GF_OK; - freeall: - gf_free(((CTR_BUFFER* )buf)->c_counter); - gf_free(((CTR_BUFFER* )buf)->enc_counter); - return GF_OUT_OF_MEM; +freeall: + gf_free(((CTR_BUFFER* )buf)->c_counter); + gf_free(((CTR_BUFFER* )buf)->enc_counter); + return GF_OUT_OF_MEM; } GF_Err _mcrypt_set_state(void *_buf, void *IV, int size) @@ -112,7 +112,7 @@ void _end_mcrypt(void *buf) { } static GFINLINE -void xor_stuff( CTR_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* plain, int blocksize, int xor_size) +void xor_stuff( CTR_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* plain, int blocksize, int xor_size) { void (*_mcrypt_block_encrypt) (void *, void *); @@ -133,15 +133,15 @@ void xor_stuff( CTR_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* plai int size = blocksize - ((CTR_BUFFER* )buf)->c_counter_pos; memxor( plain, &((CTR_BUFFER* )buf)->enc_counter[((CTR_BUFFER* )buf)->c_counter_pos], - size); - + size); + increase_counter( ((CTR_BUFFER* )buf)->c_counter, blocksize); memcpy( ((CTR_BUFFER* )buf)->enc_counter, ((CTR_BUFFER* )buf)->c_counter, blocksize); _mcrypt_block_encrypt(akey, ((CTR_BUFFER* )buf)->enc_counter); memxor( &plain[size], ((CTR_BUFFER* )buf)->enc_counter, - ((CTR_BUFFER* )buf)->c_counter_pos); + ((CTR_BUFFER* )buf)->c_counter_pos); /* ((CTR_BUFFER* )buf)->c_counter_pos remains the same */ @@ -158,7 +158,7 @@ void xor_stuff( CTR_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* plai int min_size = size < xor_size ? size: xor_size; memxor( plain, &((CTR_BUFFER* )buf)->enc_counter[((CTR_BUFFER* )buf)->c_counter_pos], - min_size); + min_size); ((CTR_BUFFER* )buf)->c_counter_pos += min_size; @@ -171,18 +171,18 @@ void xor_stuff( CTR_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* plai _mcrypt_block_encrypt(akey, ((CTR_BUFFER* )buf)->enc_counter); memxor( &plain[min_size], ((CTR_BUFFER* )buf)->enc_counter, - xor_size - min_size); + xor_size - min_size); ((CTR_BUFFER* )buf)->c_counter_pos = xor_size - min_size; } - + } return; } GF_Err _mcrypt(void * buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext can be any size */ +{ /* plaintext can be any size */ u8 *plain; int dlen, j=0; int modlen; @@ -195,7 +195,7 @@ GF_Err _mcrypt(void * buf,void *plaintext, int len, int blocksize, void* akey, v plain += blocksize; -/* Put the new register */ + /* Put the new register */ } modlen = len % blocksize; @@ -208,13 +208,13 @@ GF_Err _mcrypt(void * buf,void *plaintext, int len, int blocksize, void* akey, v xor_stuff( (CTR_BUFFER*)buf, akey, func, plain, blocksize, modlen); } - + return GF_OK; } GF_Err _mdecrypt(void * buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext can be any size */ +{ /* plaintext can be any size */ return _mcrypt( buf, plaintext, len, blocksize, akey, func, func2); } diff --git a/src/mcrypt/des.c b/src/mcrypt/des.c index df27960..5a829b6 100644 --- a/src/mcrypt/des.c +++ b/src/mcrypt/des.c @@ -10,7 +10,7 @@ * char kn[16][8]; */ -/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos +/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ @@ -29,7 +29,7 @@ typedef struct des_key { static void permute_ip(), permute_fp(), perminit_ip(), spinit(), -perminit_fp(); + perminit_fp(); static u32 f(); @@ -109,52 +109,60 @@ static char pc2[] = { /* The (in)famous S-boxes */ static char si[8][64] = { /* S1 */ - {14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, - 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, - 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, - 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}, + { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 + }, /* S2 */ - {15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, - 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, - 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, - 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}, + { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 + }, /* S3 */ - {10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, - 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, - 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, - 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}, + { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 + }, /* S4 */ - {7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, - 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, - 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, - 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}, + { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 + }, /* S5 */ - {2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, - 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, - 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, - 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}, + { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 + }, /* S6 */ - {12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, - 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, - 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, - 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}, + { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 + }, /* S7 */ - {4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, - 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, - 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, - 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}, + { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 + }, /* S8 */ - {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, - 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, - 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, - 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}, + { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 + }, }; @@ -215,15 +223,15 @@ static GF_Err _mcrypt_set_key(DES_KEY * dkey, char *user_key, int len) l = pc1[j] - 1; /* integer bit location */ m = l & 07; /* find bit */ pc1m[j] = (user_key[l >> 3] & /* find which key byte l is in */ - bytebit[m]) /* and which bit of that byte */ - ? 1 : 0; /* and store 1-bit result */ + bytebit[m]) /* and which bit of that byte */ + ? 1 : 0; /* and store 1-bit result */ } for (i = 0; i < 16; i++) { /* key chunk for each iteration */ for (j = 0; j < 56; j++) /* rotate pc1 the right amount */ pcr[j] = pc1m[(l = j + totrot[i]) < - (j < 28 ? 28 : 56) ? l : l - 28]; + (j < 28 ? 28 : 56) ? l : l - 28]; /* rotate left and right halves independently */ for (j = 0; j < 48; j++) { /* select bits individually */ /* check bit that goes to kn[j] */ @@ -433,9 +441,9 @@ static u32 f(DES_KEY * key, register u32 r, register char *subkey) #ifdef TRACE fprintf(stderr, "f(%08lx, %02x %02x %02x %02x %02x %02x %02x %02x) = ", - r, - subkey[0], subkey[1], subkey[2], - subkey[3], subkey[4], subkey[5], subkey[6], subkey[7]); + r, + subkey[0], subkey[1], subkey[2], + subkey[3], subkey[4], subkey[5], subkey[6], subkey[7]); #endif /* Run E(R) ^ K through the combined S & P boxes. * This code takes advantage of a convenient regularity in @@ -545,7 +553,7 @@ static void spinit(DES_KEY * key) */ rowcol = (i & 32) | ((i & 1) ? 16 : 0) | ((i >> 1) & - 0xf); + 0xf); for (j = 0; j < 4; j++) { /* For each output bit */ if (si[s][rowcol] & (8 >> j)) { val |= @@ -556,7 +564,7 @@ static void spinit(DES_KEY * key) #ifdef DEBUG fprintf(stderr, "sp[%d][%2d] = %08lx\n", s, i, - key->sp[s][i]); + key->sp[s][i]); #endif } } @@ -570,7 +578,7 @@ void gf_crypt_register_des(GF_Crypt *td) td->algo_name = "DES"; td->algo_version = 20010801; td->num_key_sizes = 1; - td->key_sizes[0] = 8; + td->key_sizes[0] = 8; td->key_size = 8; td->is_block_algo = 1; td->algo_block_size = 8; diff --git a/src/mcrypt/ecb.c b/src/mcrypt/ecb.c index 68c888e..570d5f3 100644 --- a/src/mcrypt/ecb.c +++ b/src/mcrypt/ecb.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -27,8 +27,12 @@ static GF_Err _init_mcrypt( void* ign, void *key, int lenofkey, void *IV, int si } -static GF_Err _mcrypt_set_state( void* buf, void *IV, int size) { return GF_BAD_PARAM; } -static GF_Err _mcrypt_get_state( void* buf, void *IV, int *size) { return GF_BAD_PARAM; } +static GF_Err _mcrypt_set_state( void* buf, void *IV, int size) { + return GF_BAD_PARAM; +} +static GF_Err _mcrypt_get_state( void* buf, void *IV, int *size) { + return GF_BAD_PARAM; +} static void _end_mcrypt (void* buf) {} @@ -39,7 +43,7 @@ static GF_Err _mcrypt( void* ign, void *plaintext, int len, int blocksize, void* void (*_mcrypt_block_encrypt) (void *, void *); _mcrypt_block_encrypt = func; - + for (j = 0; j < len / blocksize; j++) { _mcrypt_block_encrypt(akey, &plain[j * blocksize]); } @@ -56,7 +60,7 @@ static GF_Err _mdecrypt( void* ign, void *ciphertext, int len, int blocksize, vo void (*_mcrypt_block_decrypt) (void *, void *); _mcrypt_block_decrypt = func2; - + for (j = 0; j < len / blocksize; j++) { _mcrypt_block_decrypt(akey, &cipher[j * blocksize]); } diff --git a/src/mcrypt/g_crypt.c b/src/mcrypt/g_crypt.c index dc5917e..e9b4734 100644 --- a/src/mcrypt/g_crypt.c +++ b/src/mcrypt/g_crypt.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -31,26 +31,65 @@ static Bool gf_crypt_assign_algo(GF_Crypt *td, const char *algorithm) { - if (!stricmp(algorithm, "AES-128") || !stricmp(algorithm, "Rijndael-128")) { gf_crypt_register_rijndael_128(td); return 1; } + if (!stricmp(algorithm, "AES-128") || !stricmp(algorithm, "Rijndael-128")) { + gf_crypt_register_rijndael_128(td); + return 1; + } #ifndef GPAC_CRYPT_ISMA_ONLY - else if (!stricmp(algorithm, "AES-192") || !stricmp(algorithm, "Rijndael-192")) { gf_crypt_register_rijndael_192(td); return 1; } - else if (!stricmp(algorithm, "AES-256") || !stricmp(algorithm, "Rijndael-256")) { gf_crypt_register_rijndael_256(td); return 1; } - else if (!stricmp(algorithm, "DES")) { gf_crypt_register_des(td); return 1; } - else if (!stricmp(algorithm, "3DES")) { gf_crypt_register_3des(td); return 1; } + else if (!stricmp(algorithm, "AES-192") || !stricmp(algorithm, "Rijndael-192")) { + gf_crypt_register_rijndael_192(td); + return 1; + } + else if (!stricmp(algorithm, "AES-256") || !stricmp(algorithm, "Rijndael-256")) { + gf_crypt_register_rijndael_256(td); + return 1; + } + else if (!stricmp(algorithm, "DES")) { + gf_crypt_register_des(td); + return 1; + } + else if (!stricmp(algorithm, "3DES")) { + gf_crypt_register_3des(td); + return 1; + } #endif return 0; } static Bool gf_crypt_assign_mode(GF_Crypt *td, const char *mode) { - if (!stricmp(mode, "CTR")) { gf_crypt_register_ctr(td); return 1; } - else if (!stricmp(mode, "CBC")) { gf_crypt_register_cbc(td); return 1; } + if (!stricmp(mode, "CTR")) { + gf_crypt_register_ctr(td); + return 1; + } + else if (!stricmp(mode, "CBC")) { + gf_crypt_register_cbc(td); + return 1; + } #ifndef GPAC_CRYPT_ISMA_ONLY - else if (!stricmp(mode, "CFB")) { gf_crypt_register_cfb(td); return 1; } - else if (!stricmp(mode, "ECB")) { gf_crypt_register_ecb(td); return 1; } - else if (!stricmp(mode, "nCFB")) { gf_crypt_register_ncfb(td); return 1; } - else if (!stricmp(mode, "nOFB")) { gf_crypt_register_nofb(td); return 1; } - else if (!stricmp(mode, "OFB")) { gf_crypt_register_ofb(td); return 1; } - else if (!stricmp(mode, "STREAM")) { gf_crypt_register_stream(td); return 1; } + else if (!stricmp(mode, "CFB")) { + gf_crypt_register_cfb(td); + return 1; + } + else if (!stricmp(mode, "ECB")) { + gf_crypt_register_ecb(td); + return 1; + } + else if (!stricmp(mode, "nCFB")) { + gf_crypt_register_ncfb(td); + return 1; + } + else if (!stricmp(mode, "nOFB")) { + gf_crypt_register_nofb(td); + return 1; + } + else if (!stricmp(mode, "OFB")) { + gf_crypt_register_ofb(td); + return 1; + } + else if (!stricmp(mode, "STREAM")) { + gf_crypt_register_stream(td); + return 1; + } #endif return 0; } @@ -59,11 +98,11 @@ static GF_Crypt *gf_crypt_open_intern(const char *algorithm, const char *mode, B { GF_Crypt *td; if ((!algorithm || !mode) && !is_check) return NULL; - + GF_SAFEALLOC(td, GF_Crypt); if (td==NULL) return NULL; - + if (algorithm && !gf_crypt_assign_algo(td, algorithm)) { gf_free(td); return NULL; @@ -79,7 +118,7 @@ static GF_Crypt *gf_crypt_open_intern(const char *algorithm, const char *mode, B return NULL; } if (!td->_mcrypt || !td->_mdecrypt || !td->_mcrypt_set_state - || !td->a_decrypt || !td->a_encrypt || !td->a_set_key) + || !td->a_decrypt || !td->a_encrypt || !td->a_set_key) { gf_free(td); return NULL; @@ -137,7 +176,7 @@ GF_Err gf_crypt_set_key(GF_Crypt *td, void *key, u32 keysize, const void *IV) } GF_EXPORT -GF_Err gf_crypt_set_state(GF_Crypt *td, const void *iv, int size) +GF_Err gf_crypt_set_state(GF_Crypt *td, const void *iv, int size) { if (!td) return GF_BAD_PARAM; return td->_mcrypt_set_state(td->abuf, (void *) iv, size); @@ -149,16 +188,20 @@ GF_Err gf_crypt_get_state(GF_Crypt *td, void *iv, int *size) return td->_mcrypt_get_state(td->abuf, iv, size); } -u32 gf_crypt_get_block_size(GF_Crypt *td) { return td ? td->algo_block_size : 0; } +u32 gf_crypt_get_block_size(GF_Crypt *td) { + return td ? td->algo_block_size : 0; +} -u32 gf_crypt_get_iv_size(GF_Crypt *td) +u32 gf_crypt_get_iv_size(GF_Crypt *td) { if (!td) return 0; if (td->is_block_algo_mode) return td->algo_block_size; return td->algo_IV_size; } -u32 gf_crypt_get_key_size(GF_Crypt *td) { return td ? td->key_size : 0; } +u32 gf_crypt_get_key_size(GF_Crypt *td) { + return td ? td->key_size : 0; +} u32 gf_crypt_get_supported_key_sizes(GF_Crypt *td, u32 *key_sizes) { @@ -168,14 +211,30 @@ u32 gf_crypt_get_supported_key_sizes(GF_Crypt *td, u32 *key_sizes) return td->num_key_sizes; } -Bool gf_crypt_is_block_algorithm(GF_Crypt *td) { return td ? td->is_block_algo : 0; } -const char *gf_crypt_get_algorithm_name(GF_Crypt *td) { return td ? td->algo_name : NULL; } -const char *gf_crypt_get_mode_name(GF_Crypt *td) { return td ? td->mode_name : NULL; } -Bool gf_crypt_is_block_mode(GF_Crypt *td) { return td ? td->is_block_mode : 0; } -Bool gf_crypt_mode_has_iv(GF_Crypt *td) { return td ? td->has_IV : 0; } -Bool gf_crypt_is_block_algorithm_mode(GF_Crypt *td) { return td ? td->is_block_algo_mode : 0; } -u32 gf_crypt_get_algorithm_version(GF_Crypt *td) { return td ? td->algo_version : 0; } -u32 gf_crypt_get_mode_version(GF_Crypt *td) { return td ? td->mode_version : 0; } +Bool gf_crypt_is_block_algorithm(GF_Crypt *td) { + return td ? td->is_block_algo : 0; +} +const char *gf_crypt_get_algorithm_name(GF_Crypt *td) { + return td ? td->algo_name : NULL; +} +const char *gf_crypt_get_mode_name(GF_Crypt *td) { + return td ? td->mode_name : NULL; +} +Bool gf_crypt_is_block_mode(GF_Crypt *td) { + return td ? td->is_block_mode : 0; +} +Bool gf_crypt_mode_has_iv(GF_Crypt *td) { + return td ? td->has_IV : 0; +} +Bool gf_crypt_is_block_algorithm_mode(GF_Crypt *td) { + return td ? td->is_block_algo_mode : 0; +} +u32 gf_crypt_get_algorithm_version(GF_Crypt *td) { + return td ? td->algo_version : 0; +} +u32 gf_crypt_get_mode_version(GF_Crypt *td) { + return td ? td->mode_version : 0; +} @@ -217,8 +276,8 @@ GF_Err gf_crypt_init(GF_Crypt *td, void *key, u32 lenofkey, const void *IV) } td->keyword_given = (char*)gf_malloc(sizeof(char)*gf_crypt_get_key_size(td)); - if (td->keyword_given==NULL) return GF_OUT_OF_MEM; - + if (td->keyword_given==NULL) return GF_OUT_OF_MEM; + memmove(td->keyword_given, key, lenofkey); td->akey = (char*)gf_malloc(sizeof(char)*td->algo_size); diff --git a/src/mcrypt/ncfb.c b/src/mcrypt/ncfb.c index 1e3f48a..17db3a7 100644 --- a/src/mcrypt/ncfb.c +++ b/src/mcrypt/ncfb.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -32,17 +32,17 @@ typedef struct ncfb_buf { static GF_Err _init_mcrypt( nCFB_BUFFER* buf, void *key, int lenofkey, void *IV, int size) { - buf->enc_s_register = buf->s_register = NULL; - buf->s_register_pos = 0; - - buf->blocksize = size; + buf->enc_s_register = buf->s_register = NULL; + buf->s_register_pos = 0; + + buf->blocksize = size; -/* For cfb */ + /* For cfb */ buf->enc_s_register=gf_malloc( size); - if (buf->enc_s_register==NULL) goto freeall; - + if (buf->enc_s_register==NULL) goto freeall; + buf->s_register=gf_malloc( size); - if (buf->s_register==NULL) goto freeall; + if (buf->s_register==NULL) goto freeall; if (IV!=NULL) { memcpy(buf->enc_s_register, IV, size); @@ -52,13 +52,13 @@ static GF_Err _init_mcrypt( nCFB_BUFFER* buf, void *key, int lenofkey, void *IV, memset(buf->s_register, 0, size); } -/* End ncfb */ + /* End ncfb */ return GF_OK; - freeall: - if (buf->enc_s_register) gf_free(buf->enc_s_register); - if (buf->s_register) gf_free(buf->s_register); - return GF_BAD_PARAM; +freeall: + if (buf->enc_s_register) gf_free(buf->enc_s_register); + if (buf->s_register) gf_free(buf->s_register); + return GF_BAD_PARAM; } static GF_Err _mcrypt_set_state( nCFB_BUFFER* buf, u8 *IV, int size) @@ -102,7 +102,7 @@ void xor_stuff_en( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* memcpy(buf->enc_s_register, buf->s_register, blocksize); _mcrypt_block_encrypt(akey, buf->enc_s_register); - + memxor( plain, buf->enc_s_register, blocksize); memcpy(buf->s_register, plain, blocksize); @@ -111,17 +111,17 @@ void xor_stuff_en( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* int size = blocksize - buf->s_register_pos; memxor( plain, &buf->enc_s_register[buf->s_register_pos], - size); - + size); + memcpy(buf->enc_s_register, buf->s_register, blocksize); _mcrypt_block_encrypt(akey, buf->enc_s_register); memxor( &plain[size], buf->enc_s_register, - buf->s_register_pos); + buf->s_register_pos); - memcpy( &buf->s_register[size], - plain, buf->s_register_pos); + memcpy( &buf->s_register[size], + plain, buf->s_register_pos); /* buf->s_register_pos remains the same */ } @@ -130,7 +130,7 @@ void xor_stuff_en( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* memcpy(buf->enc_s_register, buf->s_register, blocksize); _mcrypt_block_encrypt(akey, buf->enc_s_register); - + memxor( plain, buf->enc_s_register, xor_size); memcpy(buf->s_register, plain, xor_size); @@ -141,7 +141,7 @@ void xor_stuff_en( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* int min_size = size < xor_size ? size: xor_size; memxor( plain, &buf->enc_s_register[buf->s_register_pos], - min_size); + min_size); memcpy( &buf->s_register[buf->s_register_pos], plain, min_size); @@ -155,13 +155,13 @@ void xor_stuff_en( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* _mcrypt_block_encrypt(akey, buf->enc_s_register); memxor( &plain[min_size], buf->s_register, - xor_size - min_size); + xor_size - min_size); buf->s_register_pos = xor_size - min_size; memcpy(buf->s_register, plain, xor_size - min_size); } - + } return; } @@ -181,7 +181,7 @@ void xor_stuff_de( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* _mcrypt_block_encrypt(akey, buf->enc_s_register); memcpy(buf->s_register, cipher, blocksize); - + memxor( cipher, buf->enc_s_register, blocksize); @@ -189,17 +189,17 @@ void xor_stuff_de( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* int size = blocksize - buf->s_register_pos; memxor( cipher, &buf->enc_s_register[buf->s_register_pos], - size); - + size); + memcpy(buf->enc_s_register, buf->s_register, blocksize); _mcrypt_block_encrypt(akey, buf->enc_s_register); - memcpy( &buf->s_register[size], - cipher, buf->s_register_pos); + memcpy( &buf->s_register[size], + cipher, buf->s_register_pos); memxor( &cipher[size], buf->enc_s_register, - buf->s_register_pos); + buf->s_register_pos); /* buf->s_register_pos remains the same */ @@ -211,7 +211,7 @@ void xor_stuff_de( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* _mcrypt_block_encrypt(akey, buf->enc_s_register); memcpy(buf->s_register, cipher, xor_size); - + memxor( cipher, buf->enc_s_register, xor_size); @@ -221,7 +221,7 @@ void xor_stuff_de( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* int min_size = size < xor_size ? size: xor_size; memxor( cipher, &buf->enc_s_register[buf->s_register_pos], - min_size); + min_size); memcpy( &buf->s_register[buf->s_register_pos], cipher, min_size); @@ -237,65 +237,65 @@ void xor_stuff_de( nCFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* memcpy(buf->s_register, cipher, xor_size - min_size); memxor( &cipher[min_size], buf->s_register, - xor_size - min_size); + xor_size - min_size); buf->s_register_pos = xor_size - min_size; } - + } return; } static GF_Err _mcrypt( nCFB_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is n*blocksize bytes (nbit cfb) */ +{ /* plaintext is n*blocksize bytes (nbit cfb) */ u8* plain; int dlen, j=0; void (*_mcrypt_block_encrypt) (void *, void *); int modlen; - + _mcrypt_block_encrypt = func; dlen = len / blocksize; plain = plaintext; for (j = 0; j < dlen; j++) { - xor_stuff_en( buf, akey, func, plain, blocksize, blocksize); - + xor_stuff_en( buf, akey, func, plain, blocksize, blocksize); + plain += blocksize; } modlen = len % blocksize; if (modlen > 0) { - xor_stuff_en( buf, akey, func, plain, blocksize, modlen); + xor_stuff_en( buf, akey, func, plain, blocksize, modlen); } - + return GF_OK; } static GF_Err _mdecrypt( nCFB_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is n*blocksize bytes (nbit cfb) */ +{ /* plaintext is n*blocksize bytes (nbit cfb) */ u8* plain; int dlen, j=0; void (*_mcrypt_block_encrypt) (void *, void *); int modlen; - + _mcrypt_block_encrypt = func; dlen = len / blocksize; plain = plaintext; for (j = 0; j < dlen; j++) { - xor_stuff_de( buf, akey, func, plain, blocksize, blocksize); - + xor_stuff_de( buf, akey, func, plain, blocksize, blocksize); + plain += blocksize; } modlen = len % blocksize; if (modlen > 0) { - xor_stuff_de( buf, akey, func, plain, blocksize, modlen); + xor_stuff_de( buf, akey, func, plain, blocksize, modlen); } - + return GF_OK; } diff --git a/src/mcrypt/nofb.c b/src/mcrypt/nofb.c index 1a04930..6597938 100644 --- a/src/mcrypt/nofb.c +++ b/src/mcrypt/nofb.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -32,16 +32,16 @@ typedef struct ncfb_buf { static GF_Err _init_mcrypt( nOFB_BUFFER* buf, void *key, int lenofkey, void *IV, int size) { - buf->enc_s_register = buf->s_register = NULL; - buf->s_register_pos = 0; + buf->enc_s_register = buf->s_register = NULL; + buf->s_register_pos = 0; - buf->blocksize = size; -/* For ofb */ + buf->blocksize = size; + /* For ofb */ buf->enc_s_register=gf_malloc( size); - if (buf->enc_s_register==NULL) goto freeall; - + if (buf->enc_s_register==NULL) goto freeall; + buf->s_register=gf_malloc( size); - if (buf->s_register==NULL) goto freeall; + if (buf->s_register==NULL) goto freeall; if (IV!=NULL) { memcpy(buf->enc_s_register, IV, size); @@ -51,13 +51,13 @@ static GF_Err _init_mcrypt( nOFB_BUFFER* buf, void *key, int lenofkey, void *IV, memset(buf->s_register, 0, size); } -/* End nofb */ + /* End nofb */ return GF_OK; - freeall: - if (buf->enc_s_register) gf_free(buf->enc_s_register); - if (buf->s_register) gf_free(buf->s_register); - return GF_OUT_OF_MEM; +freeall: + if (buf->enc_s_register) gf_free(buf->enc_s_register); + if (buf->s_register) gf_free(buf->s_register); + return GF_OUT_OF_MEM; } static GF_Err _mcrypt_set_state( nOFB_BUFFER* buf, u8 *IV, int size) @@ -104,24 +104,24 @@ void xor_stuff( nOFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* pla _mcrypt_block_encrypt(akey, buf->enc_s_register); memcpy(buf->s_register, buf->enc_s_register, blocksize); - + memxor( plain, buf->enc_s_register, blocksize); } else { int size = blocksize - buf->s_register_pos; memxor( plain, &buf->enc_s_register[buf->s_register_pos], - size); - + size); + memcpy(buf->enc_s_register, buf->s_register, blocksize); _mcrypt_block_encrypt(akey, buf->enc_s_register); - memcpy( buf->s_register, - buf->enc_s_register, blocksize); + memcpy( buf->s_register, + buf->enc_s_register, blocksize); memxor( &plain[size], buf->enc_s_register, - buf->s_register_pos); + buf->s_register_pos); /* buf->s_register_pos remains the same */ } @@ -132,7 +132,7 @@ void xor_stuff( nOFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* pla _mcrypt_block_encrypt(akey, buf->enc_s_register); memcpy(buf->s_register, buf->enc_s_register, blocksize); - + memxor( plain, buf->enc_s_register, xor_size); buf->s_register_pos = xor_size; @@ -141,7 +141,7 @@ void xor_stuff( nOFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* pla int min_size = size < xor_size ? size: xor_size; memxor( plain, &buf->enc_s_register[buf->s_register_pos], - min_size); + min_size); buf->s_register_pos += min_size; @@ -155,39 +155,39 @@ void xor_stuff( nOFB_BUFFER *buf, void* akey, void (*func)(void*,void*), u8* pla memcpy(buf->s_register, buf->enc_s_register, blocksize); memxor( &plain[min_size], buf->s_register, - xor_size - min_size); + xor_size - min_size); buf->s_register_pos = xor_size - min_size; } - + } return; } static GF_Err _mcrypt( nOFB_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is n*blocksize bytes (nbit cfb) */ +{ /* plaintext is n*blocksize bytes (nbit cfb) */ u8* plain; int dlen, j=0; void (*_mcrypt_block_encrypt) (void *, void *); int modlen; - + _mcrypt_block_encrypt = func; dlen = len / blocksize; plain = plaintext; for (j = 0; j < dlen; j++) { - xor_stuff( buf, akey, func, plain, blocksize, blocksize); - + xor_stuff( buf, akey, func, plain, blocksize, blocksize); + plain += blocksize; } modlen = len % blocksize; if (modlen > 0) { - xor_stuff( buf, akey, func, plain, blocksize, modlen); + xor_stuff( buf, akey, func, plain, blocksize, modlen); } - + return GF_OK; } diff --git a/src/mcrypt/ofb.c b/src/mcrypt/ofb.c index 3daf363..d7f23a0 100644 --- a/src/mcrypt/ofb.c +++ b/src/mcrypt/ofb.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001,2002 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -33,30 +33,30 @@ typedef struct ofb_buf { static GF_Err _init_mcrypt( OFB_BUFFER* buf, void *key, int lenofkey, void *IV, int size) { - buf->s_register = buf->enc_s_register = NULL; + buf->s_register = buf->enc_s_register = NULL; + + buf->blocksize = size; - buf->blocksize = size; - - /* For ofb */ + /* For ofb */ buf->s_register=gf_malloc( size); - if (buf->s_register==NULL) goto freeall; + if (buf->s_register==NULL) goto freeall; buf->enc_s_register=gf_malloc( size); - if (buf->enc_s_register==NULL) goto freeall; + if (buf->enc_s_register==NULL) goto freeall; if (IV!=NULL) { memcpy(buf->s_register, IV, size); } else { memset(buf->s_register, 0, size); } -/* End ofb */ + /* End ofb */ return GF_OK; - freeall: - if (buf->s_register) gf_free(buf->s_register); - if (buf->enc_s_register) gf_free(buf->enc_s_register); - return GF_OUT_OF_MEM; +freeall: + if (buf->s_register) gf_free(buf->s_register); + if (buf->enc_s_register) gf_free(buf->enc_s_register); + return GF_OUT_OF_MEM; } static GF_Err _mcrypt_get_state( OFB_BUFFER* buf, u8 *IV, int *size) @@ -88,7 +88,7 @@ static void _end_mcrypt( OFB_BUFFER* buf) { static GF_Err _mcrypt( OFB_BUFFER* buf,void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*) ) -{ /* plaintext is 1 u8 (8bit ofb) */ +{ /* plaintext is 1 u8 (8bit ofb) */ char *plain = plaintext; int i, j; void (*_mcrypt_block_encrypt) (void *, void *); @@ -103,7 +103,7 @@ static GF_Err _mcrypt( OFB_BUFFER* buf,void *plaintext, int len, int blocksize, plain[j] ^= buf->enc_s_register[0]; -/* Shift the register */ + /* Shift the register */ for (i = 0; i < (blocksize - 1); i++) buf->s_register[i] = buf->s_register[i + 1]; @@ -116,7 +116,7 @@ static GF_Err _mcrypt( OFB_BUFFER* buf,void *plaintext, int len, int blocksize, static GF_Err _mdecrypt( OFB_BUFFER* buf, void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*), void (*func2)(void*,void*)) -{ /* plaintext is 1 u8 (8bit ofb) */ +{ /* plaintext is 1 u8 (8bit ofb) */ char *plain = plaintext; int i, j; void (*_mcrypt_block_encrypt) (void *, void *); @@ -129,7 +129,7 @@ static GF_Err _mdecrypt( OFB_BUFFER* buf, void *plaintext, int len, int blocksiz _mcrypt_block_encrypt(akey, buf->enc_s_register); -/* Shift the register */ + /* Shift the register */ for (i = 0; i < (blocksize - 1); i++) buf->s_register[i] = buf->s_register[i + 1]; diff --git a/src/mcrypt/rijndael-128.c b/src/mcrypt/rijndael-128.c index 2efdc32..518559b 100644 --- a/src/mcrypt/rijndael-128.c +++ b/src/mcrypt/rijndael-128.c @@ -4,18 +4,18 @@ Copyright (c) 1999 Mike Scott See rijndael documentation - Permission for free direct or derivative use is granted subject - to compliance with any conditions that the originators of the - algorithm place on its exploitation. + Permission for free direct or derivative use is granted subject + to compliance with any conditions that the originators of the + algorithm place on its exploitation. Inspiration from Brian Gladman's implementation is acknowledged. Written for clarity, rather than speed. - Full implementation. + Full implementation. Endian indifferent. */ -/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos +/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ @@ -58,14 +58,14 @@ static int tables_ok = 0; /* in "rijndael.h" */ static u32 pack(u8 * b) -{ /* pack bytes into a 32-bit Word */ +{ /* pack bytes into a 32-bit Word */ return ((u32) b[3] << 24) | ((u32) b[2] << 16) | ((u32) - b[1] << 8) - | (u32) b[0]; + b[1] << 8) + | (u32) b[0]; } static void unpack(u32 a, u8 * b) -{ /* unpack bytes from a word */ +{ /* unpack bytes from a word */ b[0] = (u8) a; b[1] = (u8) (a >> 8); b[2] = (u8) (a >> 16); @@ -86,7 +86,7 @@ static u8 xtime(u8 a) } static u8 bmul(u8 x, u8 y) -{ /* x.y= AntiLog(Log(x) + Log(y)) */ +{ /* x.y= AntiLog(Log(x) + Log(y)) */ if (x && y) return ptab[(ltab[x] + ltab[y]) % 255]; else @@ -105,17 +105,17 @@ static u32 SubByte(u32 a) } static u8 product(u32 x, u32 y) -{ /* dot product of two 4-u8 arrays */ +{ /* dot product of two 4-u8 arrays */ u8 xb[4], yb[4]; unpack(x, xb); unpack(y, yb); return bmul(xb[0], yb[0]) ^ bmul(xb[1], yb[1]) ^ bmul(xb[2], - yb[2]) ^ - bmul(xb[3], yb[3]); + yb[2]) ^ + bmul(xb[3], yb[3]); } static u32 InvMixCol(u32 x) -{ /* matrix Multiplication */ +{ /* matrix Multiplication */ u32 y, m; u8 b[4]; @@ -148,7 +148,7 @@ static u8 ByteSub(u8 x) } static void _mcrypt_rijndael_gentables(void) -{ /* generate tables */ +{ /* generate tables */ int i; u8 y, b[4]; @@ -198,7 +198,7 @@ static void _mcrypt_rijndael_gentables(void) } static int _mcrypt_set_key(RI * rinst, u8 * key, int nk) -{ /* blocksize=32*nb bits. Key=32*nk bits */ +{ /* blocksize=32*nb bits. Key=32*nk bits */ /* currently nb,bk = 4, 6 or 8 */ /* key comes as 4*rinst->Nk bytes */ /* Key Scheduler. Create expanded encryption key */ @@ -254,32 +254,32 @@ static int _mcrypt_set_key(RI * rinst, u8 * key, int nk) for (j = rinst->Nk, k = 0; j < N; j += rinst->Nk, k++) { rinst->fkey[j] = rinst->fkey[j - - rinst->Nk] ^ SubByte(ROTL24(rinst-> - fkey[j - - 1])) ^ + rinst->Nk] ^ SubByte(ROTL24(rinst-> + fkey[j - + 1])) ^ rco[k]; if (rinst->Nk <= 6) { for (i = 1; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } else { for (i = 1; i < 4 && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; if ((j + 4) < N) rinst->fkey[j + 4] = rinst->fkey[j + 4 - - rinst-> - Nk] ^ SubByte(rinst-> - fkey[j + 3]); + rinst-> + Nk] ^ SubByte(rinst-> + fkey[j + 3]); for (i = 5; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } @@ -317,32 +317,32 @@ static void _mcrypt_encrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of fi[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of fi[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* deal with each 32-bit element of the State */ /* This is the time-critical bit */ y[j] = rinst->fkey[k++] ^ ftable[(u8) x[j]] ^ - ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16(ftable - [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); + ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16(ftable + [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->fkey[k++] ^ (u32) fbsub[(u8) x[j]] ^ - ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16((u32) - fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); + ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16((u32) + fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -364,31 +364,31 @@ static void _mcrypt_decrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of ri[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of ri[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* This is the time-critical bit */ y[j] = rinst->rkey[k++] ^ rtable[(u8) x[j]] ^ - ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16(rtable - [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); + ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16(rtable + [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->rkey[k++] ^ (u32) rbsub[(u8) x[j]] ^ - ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16((u32) - rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); + ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16((u32) + rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -405,9 +405,9 @@ void gf_crypt_register_rijndael_128(GF_Crypt *td) td->algo_name = "Rijndael-128"; td->algo_version = 20010801; td->num_key_sizes = 3; - td->key_sizes[0] = 16; - td->key_sizes[1] = 24; - td->key_sizes[2] = 32; + td->key_sizes[0] = 16; + td->key_sizes[1] = 24; + td->key_sizes[2] = 32; td->key_size = 32; td->is_block_algo = 1; td->algo_block_size = 16; diff --git a/src/mcrypt/rijndael-192.c b/src/mcrypt/rijndael-192.c index e930541..0cf18fc 100644 --- a/src/mcrypt/rijndael-192.c +++ b/src/mcrypt/rijndael-192.c @@ -4,18 +4,18 @@ Copyright (c) 1999 Mike Scott See rijndael documentation - Permission for free direct or derivative use is granted subject - to compliance with any conditions that the originators of the - algorithm place on its exploitation. + Permission for free direct or derivative use is granted subject + to compliance with any conditions that the originators of the + algorithm place on its exploitation. Inspiration from Brian Gladman's implementation is acknowledged. Written for clarity, rather than speed. - Full implementation. + Full implementation. Endian indifferent. */ -/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos +/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ @@ -61,14 +61,14 @@ static int tables_ok = 0; /* in "rijndael.h" */ static u32 pack(u8 * b) -{ /* pack bytes into a 32-bit Word */ +{ /* pack bytes into a 32-bit Word */ return ((u32) b[3] << 24) | ((u32) b[2] << 16) | ((u32) - b[1] << 8) - | (u32) b[0]; + b[1] << 8) + | (u32) b[0]; } static void unpack(u32 a, u8 * b) -{ /* unpack bytes from a word */ +{ /* unpack bytes from a word */ b[0] = (u8) a; b[1] = (u8) (a >> 8); b[2] = (u8) (a >> 16); @@ -88,7 +88,7 @@ static u8 xtime(u8 a) } static u8 bmul(u8 x, u8 y) -{ /* x.y= AntiLog(Log(x) + Log(y)) */ +{ /* x.y= AntiLog(Log(x) + Log(y)) */ if (x && y) return ptab[(ltab[x] + ltab[y]) % 255]; else @@ -107,17 +107,17 @@ static u32 SubByte(u32 a) } static u8 product(u32 x, u32 y) -{ /* dot product of two 4-u8 arrays */ +{ /* dot product of two 4-u8 arrays */ u8 xb[4], yb[4]; unpack(x, xb); unpack(y, yb); return bmul(xb[0], yb[0]) ^ bmul(xb[1], yb[1]) ^ bmul(xb[2], - yb[2]) ^ - bmul(xb[3], yb[3]); + yb[2]) ^ + bmul(xb[3], yb[3]); } static u32 InvMixCol(u32 x) -{ /* matrix Multiplication */ +{ /* matrix Multiplication */ u32 y, m; u8 b[4]; @@ -150,7 +150,7 @@ static u8 ByteSub(u8 x) } static void _mcrypt_rijndael_gentables(void) -{ /* generate tables */ +{ /* generate tables */ int i; u8 y, b[4]; @@ -200,7 +200,7 @@ static void _mcrypt_rijndael_gentables(void) } static GF_Err _mcrypt_set_key(RI * rinst, u8 * key, int nk) -{ /* blocksize=32*nb bits. Key=32*nk bits */ +{ /* blocksize=32*nb bits. Key=32*nk bits */ /* currently nb,bk = 4, 6 or 8 */ /* key comes as 4*rinst->Nk bytes */ /* Key Scheduler. Create expanded encryption key */ @@ -254,32 +254,32 @@ static GF_Err _mcrypt_set_key(RI * rinst, u8 * key, int nk) for (j = rinst->Nk, k = 0; j < N; j += rinst->Nk, k++) { rinst->fkey[j] = rinst->fkey[j - - rinst->Nk] ^ SubByte(ROTL24(rinst-> - fkey[j - - 1])) ^ + rinst->Nk] ^ SubByte(ROTL24(rinst-> + fkey[j - + 1])) ^ rco[k]; if (rinst->Nk <= 6) { for (i = 1; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } else { for (i = 1; i < 4 && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; if ((j + 4) < N) rinst->fkey[j + 4] = rinst->fkey[j + 4 - - rinst-> - Nk] ^ SubByte(rinst-> - fkey[j + 3]); + rinst-> + Nk] ^ SubByte(rinst-> + fkey[j + 3]); for (i = 5; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } @@ -317,32 +317,32 @@ static void _mcrypt_encrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of fi[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of fi[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* deal with each 32-bit element of the State */ /* This is the time-critical bit */ y[j] = rinst->fkey[k++] ^ ftable[(u8) x[j]] ^ - ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16(ftable - [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); + ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16(ftable + [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->fkey[k++] ^ (u32) fbsub[(u8) x[j]] ^ - ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16((u32) - fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); + ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16((u32) + fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -364,31 +364,31 @@ static void _mcrypt_decrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of ri[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of ri[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* This is the time-critical bit */ y[j] = rinst->rkey[k++] ^ rtable[(u8) x[j]] ^ - ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16(rtable - [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); + ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16(rtable + [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->rkey[k++] ^ (u32) rbsub[(u8) x[j]] ^ - ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16((u32) - rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); + ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16((u32) + rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -405,9 +405,9 @@ void gf_crypt_register_rijndael_192(GF_Crypt *td) td->algo_name = "Rijndael-192"; td->algo_version = 20010801; td->num_key_sizes = 3; - td->key_sizes[0] = 16; - td->key_sizes[1] = 24; - td->key_sizes[2] = 32; + td->key_sizes[0] = 16; + td->key_sizes[1] = 24; + td->key_sizes[2] = 32; td->key_size = 32; td->is_block_algo = 1; td->algo_block_size = 24; diff --git a/src/mcrypt/rijndael-256.c b/src/mcrypt/rijndael-256.c index 41aee2e..d3f6dc3 100644 --- a/src/mcrypt/rijndael-256.c +++ b/src/mcrypt/rijndael-256.c @@ -4,18 +4,18 @@ Copyright (c) 1999 Mike Scott See rijndael documentation - Permission for free direct or derivative use is granted subject - to compliance with any conditions that the originators of the - algorithm place on its exploitation. + Permission for free direct or derivative use is granted subject + to compliance with any conditions that the originators of the + algorithm place on its exploitation. Inspiration from Brian Gladman's implementation is acknowledged. Written for clarity, rather than speed. - Full implementation. + Full implementation. Endian indifferent. */ -/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos +/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ @@ -60,14 +60,14 @@ static int tables_ok = 0; /* in "rijndael.h" */ static u32 pack(u8 * b) -{ /* pack bytes into a 32-bit Word */ +{ /* pack bytes into a 32-bit Word */ return ((u32) b[3] << 24) | ((u32) b[2] << 16) | ((u32) - b[1] << 8) - | (u32) b[0]; + b[1] << 8) + | (u32) b[0]; } static void unpack(u32 a, u8 * b) -{ /* unpack bytes from a word */ +{ /* unpack bytes from a word */ b[0] = (u8) a; b[1] = (u8) (a >> 8); b[2] = (u8) (a >> 16); @@ -87,7 +87,7 @@ static u8 xtime(u8 a) } static u8 bmul(u8 x, u8 y) -{ /* x.y= AntiLog(Log(x) + Log(y)) */ +{ /* x.y= AntiLog(Log(x) + Log(y)) */ if (x && y) return ptab[(ltab[x] + ltab[y]) % 255]; else @@ -106,17 +106,17 @@ static u32 SubByte(u32 a) } static u8 product(u32 x, u32 y) -{ /* dot product of two 4-u8 arrays */ +{ /* dot product of two 4-u8 arrays */ u8 xb[4], yb[4]; unpack(x, xb); unpack(y, yb); return bmul(xb[0], yb[0]) ^ bmul(xb[1], yb[1]) ^ bmul(xb[2], - yb[2]) ^ - bmul(xb[3], yb[3]); + yb[2]) ^ + bmul(xb[3], yb[3]); } static u32 InvMixCol(u32 x) -{ /* matrix Multiplication */ +{ /* matrix Multiplication */ u32 y, m; u8 b[4]; @@ -149,7 +149,7 @@ static u8 ByteSub(u8 x) } static void _mcrypt_rijndael_gentables(void) -{ /* generate tables */ +{ /* generate tables */ int i; u8 y, b[4]; @@ -199,7 +199,7 @@ static void _mcrypt_rijndael_gentables(void) } static GF_Err _mcrypt_set_key(RI * rinst, u8 * key, int nk) -{ /* blocksize=32*nb bits. Key=32*nk bits */ +{ /* blocksize=32*nb bits. Key=32*nk bits */ /* currently nb,bk = 4, 6 or 8 */ /* key comes as 4*rinst->Nk bytes */ /* Key Scheduler. Create expanded encryption key */ @@ -253,32 +253,32 @@ static GF_Err _mcrypt_set_key(RI * rinst, u8 * key, int nk) for (j = rinst->Nk, k = 0; j < N; j += rinst->Nk, k++) { rinst->fkey[j] = rinst->fkey[j - - rinst->Nk] ^ SubByte(ROTL24(rinst-> - fkey[j - - 1])) ^ + rinst->Nk] ^ SubByte(ROTL24(rinst-> + fkey[j - + 1])) ^ rco[k]; if (rinst->Nk <= 6) { for (i = 1; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } else { for (i = 1; i < 4 && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; if ((j + 4) < N) rinst->fkey[j + 4] = rinst->fkey[j + 4 - - rinst-> - Nk] ^ SubByte(rinst-> - fkey[j + 3]); + rinst-> + Nk] ^ SubByte(rinst-> + fkey[j + 3]); for (i = 5; i < rinst->Nk && (i + j) < N; i++) rinst->fkey[i + j] = rinst->fkey[i + j - - rinst->Nk] ^ rinst-> + rinst->Nk] ^ rinst-> fkey[i + j - 1]; } @@ -316,32 +316,32 @@ static void _mcrypt_encrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of fi[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of fi[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* deal with each 32-bit element of the State */ /* This is the time-critical bit */ y[j] = rinst->fkey[k++] ^ ftable[(u8) x[j]] ^ - ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16(ftable - [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); + ROTL8(ftable[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16(ftable + [(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24(ftable[x[rinst->fi[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->fkey[k++] ^ (u32) fbsub[(u8) x[j]] ^ - ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ - ROTL16((u32) - fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ - ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); + ROTL8((u32) fbsub[(u8) (x[rinst->fi[m]] >> 8)]) ^ + ROTL16((u32) + fbsub[(u8) (x[rinst->fi[m + 1]] >> 16)]) ^ + ROTL24((u32) fbsub[x[rinst->fi[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -363,31 +363,31 @@ static void _mcrypt_decrypt(RI * rinst, u8 * buff) x = a; y = b; -/* State alternates between a and b */ + /* State alternates between a and b */ for (i = 1; i < rinst->Nr; i++) { /* rinst->Nr is number of rounds. May be odd. */ -/* if rinst->Nb is fixed - unroll this next - loop and hard-code in the values of ri[] */ + /* if rinst->Nb is fixed - unroll this next + loop and hard-code in the values of ri[] */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { /* This is the time-critical bit */ y[j] = rinst->rkey[k++] ^ rtable[(u8) x[j]] ^ - ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16(rtable - [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); + ROTL8(rtable[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16(rtable + [(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24(rtable[x[rinst->ri[m + 2]] >> 24]); } t = x; x = y; y = t; /* swap pointers */ } -/* Last Round - unroll if possible */ + /* Last Round - unroll if possible */ for (m = j = 0; j < rinst->Nb; j++, m += 3) { y[j] = rinst->rkey[k++] ^ (u32) rbsub[(u8) x[j]] ^ - ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ - ROTL16((u32) - rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ - ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); + ROTL8((u32) rbsub[(u8) (x[rinst->ri[m]] >> 8)]) ^ + ROTL16((u32) + rbsub[(u8) (x[rinst->ri[m + 1]] >> 16)]) ^ + ROTL24((u32) rbsub[x[rinst->ri[m + 2]] >> 24]); } for (i = j = 0; i < rinst->Nb; i++, j += 4) { unpack(y[i], &buff[j]); @@ -404,9 +404,9 @@ void gf_crypt_register_rijndael_256(GF_Crypt *td) td->algo_name = "Rijndael-256"; td->algo_version = 20010801; td->num_key_sizes = 3; - td->key_sizes[0] = 16; - td->key_sizes[1] = 24; - td->key_sizes[2] = 32; + td->key_sizes[0] = 16; + td->key_sizes[1] = 24; + td->key_sizes[2] = 32; td->key_size = 32; td->is_block_algo = 1; td->algo_block_size = 32; diff --git a/src/mcrypt/stream.c b/src/mcrypt/stream.c index ee1aa42..09225e6 100644 --- a/src/mcrypt/stream.c +++ b/src/mcrypt/stream.c @@ -1,9 +1,9 @@ /* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -21,10 +21,16 @@ #if !defined(GPAC_CRYPT_ISMA_ONLY) && !defined(GPAC_DISABLE_MCRYPT) -static GF_Err _init_mcrypt( void* ign, void *key, int lenofkey, void *IV, int size) { return GF_OK; } +static GF_Err _init_mcrypt( void* ign, void *key, int lenofkey, void *IV, int size) { + return GF_OK; +} -static GF_Err _mcrypt_set_state( void* buf, void *IV, int size) { return GF_BAD_PARAM; } -static GF_Err _mcrypt_get_state( void* buf, void *IV, int *size) { return GF_BAD_PARAM; } +static GF_Err _mcrypt_set_state( void* buf, void *IV, int size) { + return GF_BAD_PARAM; +} +static GF_Err _mcrypt_get_state( void* buf, void *IV, int *size) { + return GF_BAD_PARAM; +} static void _end_mcrypt(void* ign) {} diff --git a/src/mcrypt/tripledes.c b/src/mcrypt/tripledes.c index 1f6d5ca..bf2b25a 100644 --- a/src/mcrypt/tripledes.c +++ b/src/mcrypt/tripledes.c @@ -12,7 +12,7 @@ * char kn[16][8]; */ -/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos +/* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ @@ -112,52 +112,60 @@ static char pc2[] = { /* The (in)famous S-boxes */ static char si[8][64] = { /* S1 */ - {14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, - 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, - 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, - 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}, + { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 + }, /* S2 */ - {15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, - 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, - 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, - 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}, + { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 + }, /* S3 */ - {10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, - 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, - 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, - 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}, + { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 + }, /* S4 */ - {7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, - 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, - 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, - 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}, + { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 + }, /* S5 */ - {2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, - 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, - 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, - 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}, + { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 + }, /* S6 */ - {12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, - 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, - 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, - 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}, + { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 + }, /* S7 */ - {4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, - 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, - 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, - 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}, + { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 + }, /* S8 */ - {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, - 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, - 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, - 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}, + { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 + }, }; @@ -226,15 +234,15 @@ static GF_Err _mcrypt_set_key(TRIPLEDES_KEY * dkey, char *user_key, int len) l = pc1[j] - 1; /* integer bit location */ m = l & 07; /* find bit */ pc1m[j] = (user_key1[l >> 3] & /* find which key byte l is in */ - bytebit[m]) /* and which bit of that byte */ - ? 1 : 0; /* and store 1-bit result */ + bytebit[m]) /* and which bit of that byte */ + ? 1 : 0; /* and store 1-bit result */ } for (i = 0; i < 16; i++) { /* key chunk for each iteration */ for (j = 0; j < 56; j++) /* rotate pc1 the right amount */ pcr[j] = pc1m[(l = j + totrot[i]) < - (j < 28 ? 28 : 56) ? l : l - 28]; + (j < 28 ? 28 : 56) ? l : l - 28]; /* rotate left and right halves independently */ for (j = 0; j < 48; j++) { /* select bits individually */ /* check bit that goes to kn[j] */ @@ -245,20 +253,20 @@ static GF_Err _mcrypt_set_key(TRIPLEDES_KEY * dkey, char *user_key, int len) } } } -/* DES 2 */ + /* DES 2 */ for (j = 0; j < 56; j++) { /* convert pc1 to bits of key */ l = pc1[j] - 1; /* integer bit location */ m = l & 07; /* find bit */ pc1m[j] = (user_key2[l >> 3] & /* find which key byte l is in */ - bytebit[m]) /* and which bit of that byte */ - ? 1 : 0; /* and store 1-bit result */ + bytebit[m]) /* and which bit of that byte */ + ? 1 : 0; /* and store 1-bit result */ } for (i = 0; i < 16; i++) { /* key chunk for each iteration */ for (j = 0; j < 56; j++) /* rotate pc1 the right amount */ pcr[j] = pc1m[(l = j + totrot[i]) < - (j < 28 ? 28 : 56) ? l : l - 28]; + (j < 28 ? 28 : 56) ? l : l - 28]; /* rotate left and right halves independently */ for (j = 0; j < 48; j++) { /* select bits individually */ /* check bit that goes to kn[j] */ @@ -269,20 +277,20 @@ static GF_Err _mcrypt_set_key(TRIPLEDES_KEY * dkey, char *user_key, int len) } } } -/* DES 3 */ + /* DES 3 */ for (j = 0; j < 56; j++) { /* convert pc1 to bits of key */ l = pc1[j] - 1; /* integer bit location */ m = l & 07; /* find bit */ pc1m[j] = (user_key3[l >> 3] & /* find which key byte l is in */ - bytebit[m]) /* and which bit of that byte */ - ? 1 : 0; /* and store 1-bit result */ + bytebit[m]) /* and which bit of that byte */ + ? 1 : 0; /* and store 1-bit result */ } for (i = 0; i < 16; i++) { /* key chunk for each iteration */ for (j = 0; j < 56; j++) /* rotate pc1 the right amount */ pcr[j] = pc1m[(l = j + totrot[i]) < - (j < 28 ? 28 : 56) ? l : l - 28]; + (j < 28 ? 28 : 56) ? l : l - 28]; /* rotate left and right halves independently */ for (j = 0; j < 48; j++) { /* select bits individually */ /* check bit that goes to kn[j] */ @@ -307,7 +315,7 @@ static void _mcrypt_encrypt(TRIPLEDES_KEY * key, char *block) register char *knp; u32 work[2]; /* Working data storage */ -/* DES 1 */ + /* DES 1 */ permute(block, key->iperm, (char *) work); /* Initial Permutation */ #ifndef WORDS_BIGENDIAN left = byteswap32(work[0]); @@ -355,7 +363,7 @@ static void _mcrypt_encrypt(TRIPLEDES_KEY * key, char *block) knp += 8; right ^= f(key, 0, left, knp); -/* DES 2 */ + /* DES 2 */ /* Do the 16 rounds in reverse order. * The rounds are numbered from 15 to 0. On even rounds @@ -466,7 +474,7 @@ static void _mcrypt_decrypt(TRIPLEDES_KEY * key, char *block) left = work[1]; #endif -/* DES 3 */ + /* DES 3 */ /* Do the 16 rounds in reverse order. * The rounds are numbered from 15 to 0. On even rounds @@ -507,7 +515,7 @@ static void _mcrypt_decrypt(TRIPLEDES_KEY * key, char *block) left ^= f(key, 2, right, knp); -/* DES 2*/ + /* DES 2*/ /* Do the 16 rounds. * The rounds are numbered from 0 to 15. On even rounds * the right half is fed to f() and the result exclusive-ORs @@ -546,7 +554,7 @@ static void _mcrypt_decrypt(TRIPLEDES_KEY * key, char *block) knp += 8; right ^= f(key, 1, left, knp); -/* DES 1 */ + /* DES 1 */ /* Do the 16 rounds in reverse order. * The rounds are numbered from 15 to 0. On even rounds * the right half is fed to f() and the result exclusive-ORs @@ -630,7 +638,7 @@ static void permute(char *inblock, char perm[16][16][8], char *outblock) /* The nonlinear function f(r,k), the heart of DES */ static u32 f(TRIPLEDES_KEY * key, int pos, register u32 r, - register char *subkey) + register char *subkey) { register u32 *spp; register u32 rval, rt; @@ -638,9 +646,9 @@ static u32 f(TRIPLEDES_KEY * key, int pos, register u32 r, #ifdef TRACE fprintf(stderr, "f(%08lx, %02x %02x %02x %02x %02x %02x %02x %02x) = ", - r, - subkey[0], subkey[1], subkey[2], - subkey[3], subkey[4], subkey[5], subkey[6], subkey[7]); + r, + subkey[0], subkey[1], subkey[2], + subkey[3], subkey[4], subkey[5], subkey[6], subkey[7]); #endif /* Run E(R) ^ K through the combined S & P boxes. * This code takes advantage of a convenient regularity in @@ -729,7 +737,7 @@ static void spinit(TRIPLEDES_KEY * key, int pos) */ rowcol = (i & 32) | ((i & 1) ? 16 : 0) | ((i >> 1) & - 0xf); + 0xf); for (j = 0; j < 4; j++) { /* For each output bit */ if (si[s][rowcol] & (8 >> j)) { val |= @@ -749,7 +757,7 @@ void gf_crypt_register_3des(GF_Crypt *td) td->algo_name = "3DES"; td->algo_version = 19991129; td->num_key_sizes = 1; - td->key_sizes[0] = 24; + td->key_sizes[0] = 24; td->key_size = 24; td->is_block_algo = 1; td->algo_block_size = 8; diff --git a/src/media_tools/ait.c b/src/media_tools/ait.c index 0eb510c..db9e62f 100644 --- a/src/media_tools/ait.c +++ b/src/media_tools/ait.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,24 +48,24 @@ GF_M2TS_ES *gf_ait_section_new(u32 service_id) } -void on_ait_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +void on_ait_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { GF_M2TS_SL_PCK *pck = (GF_M2TS_SL_PCK *)par; char *data; u32 u32_data_size; u32 u32_table_id; - + if (evt_type == GF_M2TS_EVT_AIT_FOUND) { GF_M2TS_AIT* ait; GF_M2TS_AIT_CARRY* ait_carry = (GF_M2TS_AIT_CARRY*)pck->stream; data = pck->data; - if(!check_ait_already_received(ts->ChannelAppList,ait_carry->pid,data)){ - GF_SAFEALLOC(ait, GF_M2TS_AIT); + if(!check_ait_already_received(ts->ChannelAppList,ait_carry->pid,data)) { + GF_SAFEALLOC(ait, GF_M2TS_AIT); u32_data_size = pck->data_len; - u32_table_id = data[0]; + u32_table_id = data[0]; ait->pid = ait_carry->pid; ait->service_id = ait_carry->service_id; gf_m2ts_decode_ait(ait, data, u32_data_size, u32_table_id); @@ -73,7 +73,7 @@ void on_ait_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) gf_ait_destroy(ait); if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_AIT_FOUND, pck->stream); } - + } } @@ -91,49 +91,49 @@ static GF_Err gf_m2ts_decode_ait(GF_M2TS_AIT *ait, char *data, u32 data_size, u bs = gf_bs_new(data,data_size,GF_BITSTREAM_READ); ait->common_descriptors = gf_list_new(); - if(ait->common_descriptors == NULL){ + if(ait->common_descriptors == NULL) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Error during common_descriptors list initialization, abording processing \n")); return GF_CORRUPTED_DATA; } ait->application_decoded = gf_list_new(); - if(ait->application_decoded == NULL){ + if(ait->application_decoded == NULL) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Error during application list initialization, abording processing \n")); return GF_CORRUPTED_DATA; } - ait->table_id = gf_bs_read_int(bs,8); + ait->table_id = gf_bs_read_int(bs,8); ait->section_syntax_indicator = gf_bs_read_int(bs,1); gf_bs_read_int(bs,3); - ait->section_length = gf_bs_read_int(bs,12); - if( (data[1] & 0x0C) != 0){ + ait->section_length = gf_bs_read_int(bs,12); + if( (data[1] & 0x0C) != 0) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] section length is not correct abroding \n")); - }else if( ait->section_length > AIT_SECTION_LENGTH_MAX){ + } else if( ait->section_length > AIT_SECTION_LENGTH_MAX) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] section length should not exceed 1021. Wrong section, abording processing \n")); } ait->test_application_flag = gf_bs_read_int(bs,1); - if(ait->test_application_flag == 1){ + if(ait->test_application_flag == 1) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] test application flag is at 1. API transmitted for testing, abording processing \n")); return GF_CORRUPTED_DATA; } - ait->application_type = gf_bs_read_int(bs,15); - if(ait->application_type != APPLICATION_TYPE_HTTP_APPLICATION){ + ait->application_type = gf_bs_read_int(bs,15); + if(ait->application_type != APPLICATION_TYPE_HTTP_APPLICATION) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] application type should 0x10. Wrong section, abording processing \n")); return GF_CORRUPTED_DATA; } gf_bs_read_int(bs,2); ait->version_number = gf_bs_read_int(bs,5); - ait->current_next_indicator = gf_bs_read_int(bs,1); - if(!ait->current_next_indicator){ + ait->current_next_indicator = gf_bs_read_int(bs,1); + if(!ait->current_next_indicator) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] current next indicator should be at 1 \n")); return GF_CORRUPTED_DATA; } ait->section_number = gf_bs_read_int(bs,8); - ait->last_section_number = gf_bs_read_int(bs,8); + ait->last_section_number = gf_bs_read_int(bs,8); gf_bs_read_int(bs,4);/* bit shifting */ - ait->common_descriptors_length = gf_bs_read_int(bs,12); + ait->common_descriptors_length = gf_bs_read_int(bs,12); gf_bs_read_int(bs,(unsigned int)ait->common_descriptors_length/8); - gf_bs_read_int(bs,4);/* bit shifting */ + gf_bs_read_int(bs,4);/* bit shifting */ ait->application_loop_length = gf_bs_read_int(bs,12); data_shift = (u32)(gf_bs_get_position(bs)) + ait->common_descriptors_length/8; @@ -146,11 +146,11 @@ static GF_Err gf_m2ts_decode_ait(GF_M2TS_AIT *ait, char *data, u32 data_size, u application->index_app_desc_id = 0; /* application loop */ - application->organisation_id = gf_bs_read_int(bs,32); + application->organisation_id = gf_bs_read_int(bs,32); application->application_id= gf_bs_read_int(bs,16); application->application_control_code= gf_bs_read_int(bs,8); gf_bs_read_int(bs,4);/* bit shifting */ - application->application_descriptors_loop_length= gf_bs_read_int(bs,12); + application->application_descriptors_loop_length= gf_bs_read_int(bs,12); ait_app_data_shift += 9; app_desc_data_shift = 0; @@ -159,244 +159,244 @@ static GF_Err gf_m2ts_decode_ait(GF_M2TS_AIT *ait, char *data, u32 data_size, u while (app_desc_data_shift< application->application_descriptors_loop_length) { temp_descriptor_tag = gf_bs_read_int(bs,8); switch (temp_descriptor_tag) { - case APPLICATION_DESCRIPTOR: - { - u64 pre_processing_pos; - u8 i; - GF_M2TS_APPLICATION_DESCRIPTOR *application_descriptor; - GF_SAFEALLOC(application_descriptor, GF_M2TS_APPLICATION_DESCRIPTOR); - application_descriptor->descriptor_tag = temp_descriptor_tag; - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - application_descriptor->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - application_descriptor->application_profiles_length = gf_bs_read_int(bs,8); - application_descriptor->application_profile = gf_bs_read_int(bs,16); - application_descriptor->version_major = gf_bs_read_int(bs,8); - application_descriptor->version_minor = gf_bs_read_int(bs,8); - application_descriptor->version_micro = gf_bs_read_int(bs,8); - application_descriptor->service_bound_flag = gf_bs_read_int(bs,1); - application_descriptor->visibility = gf_bs_read_int(bs,2); - gf_bs_read_int(bs,5); /*bit shift*/ - application_descriptor->application_priority = gf_bs_read_int(bs,8); - if (nb_of_protocol > 0) { - for (i=0; itransport_protocol_label[i] = gf_bs_read_int(bs,8); - } - } else { - application_descriptor->transport_protocol_label[0] = gf_bs_read_int(bs,8); - } - if (pre_processing_pos+application_descriptor->descriptor_length != gf_bs_get_position(bs) || application_descriptor->application_profile == 2 /* PVR feature */) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),application_descriptor->descriptor_length)); - gf_free(application_descriptor); - return GF_CORRUPTED_DATA; - } - gf_list_add(application->application_descriptors,application_descriptor); - app_desc_data_shift += (2+ application_descriptor->descriptor_length); - break; - } - case APPLICATION_NAME_DESCRIPTOR: - { - u64 pre_processing_pos; - GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor; - GF_SAFEALLOC(name_descriptor, GF_M2TS_APPLICATION_NAME_DESCRIPTOR); - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - name_descriptor->descriptor_tag = temp_descriptor_tag; - name_descriptor->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - name_descriptor->ISO_639_language_code = gf_bs_read_int(bs,24); - name_descriptor->application_name_length = gf_bs_read_int(bs,8); - name_descriptor->application_name_char = (char*) gf_calloc(name_descriptor->application_name_length+1,sizeof(char)); - gf_bs_read_data(bs,name_descriptor->application_name_char,name_descriptor->application_name_length); - name_descriptor->application_name_char[name_descriptor->application_name_length] = 0 ; - if (pre_processing_pos+name_descriptor->descriptor_length != gf_bs_get_position(bs)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),name_descriptor->descriptor_length)); - gf_free(name_descriptor->application_name_char); - gf_free(name_descriptor); - return GF_CORRUPTED_DATA; - } - gf_list_add(application->application_descriptors,name_descriptor); - app_desc_data_shift += (2+ name_descriptor->descriptor_length); - break; + case APPLICATION_DESCRIPTOR: + { + u64 pre_processing_pos; + u8 i; + GF_M2TS_APPLICATION_DESCRIPTOR *application_descriptor; + GF_SAFEALLOC(application_descriptor, GF_M2TS_APPLICATION_DESCRIPTOR); + application_descriptor->descriptor_tag = temp_descriptor_tag; + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + application_descriptor->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + application_descriptor->application_profiles_length = gf_bs_read_int(bs,8); + application_descriptor->application_profile = gf_bs_read_int(bs,16); + application_descriptor->version_major = gf_bs_read_int(bs,8); + application_descriptor->version_minor = gf_bs_read_int(bs,8); + application_descriptor->version_micro = gf_bs_read_int(bs,8); + application_descriptor->service_bound_flag = gf_bs_read_int(bs,1); + application_descriptor->visibility = gf_bs_read_int(bs,2); + gf_bs_read_int(bs,5); /*bit shift*/ + application_descriptor->application_priority = gf_bs_read_int(bs,8); + if (nb_of_protocol > 0) { + for (i=0; itransport_protocol_label[i] = gf_bs_read_int(bs,8); } - case TRANSPORT_PROTOCOL_DESCRIPTOR: - { - u64 pre_processing_pos; - GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor; - GF_SAFEALLOC(protocol_descriptor, GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR); - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - nb_of_protocol++; - protocol_descriptor->descriptor_tag = temp_descriptor_tag; - protocol_descriptor->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - protocol_descriptor->protocol_id = gf_bs_read_int(bs,16); - protocol_descriptor->transport_protocol_label = gf_bs_read_int(bs,8); - switch (protocol_descriptor->protocol_id) { + } else { + application_descriptor->transport_protocol_label[0] = gf_bs_read_int(bs,8); + } + if (pre_processing_pos+application_descriptor->descriptor_length != gf_bs_get_position(bs) || application_descriptor->application_profile == 2 /* PVR feature */) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),application_descriptor->descriptor_length)); + gf_free(application_descriptor); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,application_descriptor); + app_desc_data_shift += (2+ application_descriptor->descriptor_length); + break; + } + case APPLICATION_NAME_DESCRIPTOR: + { + u64 pre_processing_pos; + GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor; + GF_SAFEALLOC(name_descriptor, GF_M2TS_APPLICATION_NAME_DESCRIPTOR); + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + name_descriptor->descriptor_tag = temp_descriptor_tag; + name_descriptor->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + name_descriptor->ISO_639_language_code = gf_bs_read_int(bs,24); + name_descriptor->application_name_length = gf_bs_read_int(bs,8); + name_descriptor->application_name_char = (char*) gf_calloc(name_descriptor->application_name_length+1,sizeof(char)); + gf_bs_read_data(bs,name_descriptor->application_name_char,name_descriptor->application_name_length); + name_descriptor->application_name_char[name_descriptor->application_name_length] = 0 ; + if (pre_processing_pos+name_descriptor->descriptor_length != gf_bs_get_position(bs)) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),name_descriptor->descriptor_length)); + gf_free(name_descriptor->application_name_char); + gf_free(name_descriptor); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,name_descriptor); + app_desc_data_shift += (2+ name_descriptor->descriptor_length); + break; + } + case TRANSPORT_PROTOCOL_DESCRIPTOR: + { + u64 pre_processing_pos; + GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor; + GF_SAFEALLOC(protocol_descriptor, GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR); + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + nb_of_protocol++; + protocol_descriptor->descriptor_tag = temp_descriptor_tag; + protocol_descriptor->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + protocol_descriptor->protocol_id = gf_bs_read_int(bs,16); + protocol_descriptor->transport_protocol_label = gf_bs_read_int(bs,8); + switch (protocol_descriptor->protocol_id) { case CAROUSEL: - { - GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte; - GF_SAFEALLOC(Carousel_selector_byte, GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE); - Carousel_selector_byte->remote_connection = gf_bs_read_int(bs,1); - gf_bs_read_int(bs,7); /* bit shifting */ - if (Carousel_selector_byte->remote_connection) { - Carousel_selector_byte->original_network_id = gf_bs_read_int(bs,16); - Carousel_selector_byte->transport_stream_id = gf_bs_read_int(bs,16); - Carousel_selector_byte->service_id = gf_bs_read_int(bs,16); - } - Carousel_selector_byte->component_tag = gf_bs_read_int(bs,8); - protocol_descriptor->selector_byte = Carousel_selector_byte; - break; + { + GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte; + GF_SAFEALLOC(Carousel_selector_byte, GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE); + Carousel_selector_byte->remote_connection = gf_bs_read_int(bs,1); + gf_bs_read_int(bs,7); /* bit shifting */ + if (Carousel_selector_byte->remote_connection) { + Carousel_selector_byte->original_network_id = gf_bs_read_int(bs,16); + Carousel_selector_byte->transport_stream_id = gf_bs_read_int(bs,16); + Carousel_selector_byte->service_id = gf_bs_read_int(bs,16); } + Carousel_selector_byte->component_tag = gf_bs_read_int(bs,8); + protocol_descriptor->selector_byte = Carousel_selector_byte; + break; + } case TRANSPORT_HTTP: - { - u32 i; - GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte; - GF_SAFEALLOC(Transport_http_selector_byte, GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE); - Transport_http_selector_byte->URL_base_length = gf_bs_read_int(bs,8); - //fprintf(stderr, "Transport_http_selector_byte->URL_base_length %d \n",Transport_http_selector_byte->URL_base_length); - Transport_http_selector_byte->URL_base_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_base_length+1,sizeof(char)); - gf_bs_read_data(bs,Transport_http_selector_byte->URL_base_byte ,(u32)(Transport_http_selector_byte->URL_base_length)); - Transport_http_selector_byte->URL_base_byte[Transport_http_selector_byte->URL_base_length] = 0; - Transport_http_selector_byte->URL_extension_count = gf_bs_read_int(bs,8); - if (Transport_http_selector_byte->URL_extension_count) { - Transport_http_selector_byte->URL_extentions = (GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION*) gf_calloc(Transport_http_selector_byte->URL_extension_count,sizeof(GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION)); - for (i=0; i < Transport_http_selector_byte->URL_extension_count;i++) { - Transport_http_selector_byte->URL_extentions[i].URL_extension_length = gf_bs_read_int(bs,8); - Transport_http_selector_byte->URL_extentions[i].URL_extension_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_extentions[i].URL_extension_length+1,sizeof(char)); - gf_bs_read_data(bs,Transport_http_selector_byte->URL_extentions[i].URL_extension_byte,(u32)(Transport_http_selector_byte->URL_extentions[i].URL_extension_length)); - Transport_http_selector_byte->URL_extentions[i].URL_extension_byte[Transport_http_selector_byte->URL_extentions[i].URL_extension_length] = 0; - } + { + u32 i; + GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte; + GF_SAFEALLOC(Transport_http_selector_byte, GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE); + Transport_http_selector_byte->URL_base_length = gf_bs_read_int(bs,8); + //fprintf(stderr, "Transport_http_selector_byte->URL_base_length %d \n",Transport_http_selector_byte->URL_base_length); + Transport_http_selector_byte->URL_base_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_base_length+1,sizeof(char)); + gf_bs_read_data(bs,Transport_http_selector_byte->URL_base_byte ,(u32)(Transport_http_selector_byte->URL_base_length)); + Transport_http_selector_byte->URL_base_byte[Transport_http_selector_byte->URL_base_length] = 0; + Transport_http_selector_byte->URL_extension_count = gf_bs_read_int(bs,8); + if (Transport_http_selector_byte->URL_extension_count) { + Transport_http_selector_byte->URL_extentions = (GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION*) gf_calloc(Transport_http_selector_byte->URL_extension_count,sizeof(GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION)); + for (i=0; i < Transport_http_selector_byte->URL_extension_count; i++) { + Transport_http_selector_byte->URL_extentions[i].URL_extension_length = gf_bs_read_int(bs,8); + Transport_http_selector_byte->URL_extentions[i].URL_extension_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_extentions[i].URL_extension_length+1,sizeof(char)); + gf_bs_read_data(bs,Transport_http_selector_byte->URL_extentions[i].URL_extension_byte,(u32)(Transport_http_selector_byte->URL_extentions[i].URL_extension_length)); + Transport_http_selector_byte->URL_extentions[i].URL_extension_byte[Transport_http_selector_byte->URL_extentions[i].URL_extension_length] = 0; } - protocol_descriptor->selector_byte = Transport_http_selector_byte; - break; } + protocol_descriptor->selector_byte = Transport_http_selector_byte; + break; + } default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id)); - } - } - if (pre_processing_pos+protocol_descriptor->descriptor_length != gf_bs_get_position(bs)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),protocol_descriptor->descriptor_length)); - if (protocol_descriptor->protocol_id == CAROUSEL) { - GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*) protocol_descriptor->selector_byte; - gf_free(Carousel_selector_byte); - } else if(protocol_descriptor->protocol_id ==TRANSPORT_HTTP) { - u32 i; - GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*) protocol_descriptor->selector_byte; - gf_free(Transport_http_selector_byte->URL_base_byte); - for(i = 0; i < Transport_http_selector_byte->URL_extension_count;i++){ - gf_free(Transport_http_selector_byte->URL_extentions[i].URL_extension_byte); - } - gf_free(Transport_http_selector_byte); - } - gf_free(protocol_descriptor); - return GF_CORRUPTED_DATA; - } - gf_list_add(application->application_descriptors,protocol_descriptor); - app_desc_data_shift += (2+ protocol_descriptor->descriptor_length); - break; - } - case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: - { - u64 pre_processing_pos; - GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location; - GF_SAFEALLOC(Simple_application_location, GF_M2TS_SIMPLE_APPLICATION_LOCATION); - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - Simple_application_location->descriptor_tag = temp_descriptor_tag; - Simple_application_location->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - Simple_application_location->initial_path_bytes = (char*)gf_calloc(Simple_application_location->descriptor_length+1,sizeof(char)); - gf_bs_read_data(bs,Simple_application_location->initial_path_bytes ,(u32)(Simple_application_location->descriptor_length)); - Simple_application_location->initial_path_bytes[Simple_application_location->descriptor_length] = 0; - if (pre_processing_pos+Simple_application_location->descriptor_length != gf_bs_get_position(bs)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Simple_application_location->descriptor_length)); - gf_free(Simple_application_location->initial_path_bytes); - gf_free(Simple_application_location); - return GF_CORRUPTED_DATA; + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id)); + } + } + if (pre_processing_pos+protocol_descriptor->descriptor_length != gf_bs_get_position(bs)) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),protocol_descriptor->descriptor_length)); + if (protocol_descriptor->protocol_id == CAROUSEL) { + GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*) protocol_descriptor->selector_byte; + gf_free(Carousel_selector_byte); + } else if(protocol_descriptor->protocol_id ==TRANSPORT_HTTP) { + u32 i; + GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*) protocol_descriptor->selector_byte; + gf_free(Transport_http_selector_byte->URL_base_byte); + for(i = 0; i < Transport_http_selector_byte->URL_extension_count; i++) { + gf_free(Transport_http_selector_byte->URL_extentions[i].URL_extension_byte); } - gf_list_add(application->application_descriptors,Simple_application_location); - app_desc_data_shift += (2+ Simple_application_location->descriptor_length); - break; + gf_free(Transport_http_selector_byte); } - case APPLICATION_USAGE_DESCRIPTOR: - { - u64 pre_processing_pos; - GF_M2TS_APPLICATION_USAGE* Application_usage; - GF_SAFEALLOC(Application_usage, GF_M2TS_APPLICATION_USAGE); - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - Application_usage->descriptor_tag = temp_descriptor_tag; - Application_usage->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - Application_usage->usage_type = gf_bs_read_int(bs,8); - if (pre_processing_pos+Application_usage->descriptor_length != gf_bs_get_position(bs)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Application_usage->descriptor_length)); - gf_free(Application_usage); - return GF_CORRUPTED_DATA; + gf_free(protocol_descriptor); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,protocol_descriptor); + app_desc_data_shift += (2+ protocol_descriptor->descriptor_length); + break; + } + case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: + { + u64 pre_processing_pos; + GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location; + GF_SAFEALLOC(Simple_application_location, GF_M2TS_SIMPLE_APPLICATION_LOCATION); + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + Simple_application_location->descriptor_tag = temp_descriptor_tag; + Simple_application_location->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + Simple_application_location->initial_path_bytes = (char*)gf_calloc(Simple_application_location->descriptor_length+1,sizeof(char)); + gf_bs_read_data(bs,Simple_application_location->initial_path_bytes ,(u32)(Simple_application_location->descriptor_length)); + Simple_application_location->initial_path_bytes[Simple_application_location->descriptor_length] = 0; + if (pre_processing_pos+Simple_application_location->descriptor_length != gf_bs_get_position(bs)) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Simple_application_location->descriptor_length)); + gf_free(Simple_application_location->initial_path_bytes); + gf_free(Simple_application_location); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,Simple_application_location); + app_desc_data_shift += (2+ Simple_application_location->descriptor_length); + break; + } + case APPLICATION_USAGE_DESCRIPTOR: + { + u64 pre_processing_pos; + GF_M2TS_APPLICATION_USAGE* Application_usage; + GF_SAFEALLOC(Application_usage, GF_M2TS_APPLICATION_USAGE); + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + Application_usage->descriptor_tag = temp_descriptor_tag; + Application_usage->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + Application_usage->usage_type = gf_bs_read_int(bs,8); + if (pre_processing_pos+Application_usage->descriptor_length != gf_bs_get_position(bs)) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Application_usage->descriptor_length)); + gf_free(Application_usage); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,Application_usage); + app_desc_data_shift += (2+ Application_usage->descriptor_length); + break; + } + case APPLICATION_BOUNDARY_DESCRIPTOR: + { + u64 pre_processing_pos; + u32 i; + GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR* boundary_descriptor; + GF_SAFEALLOC(boundary_descriptor, GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR); + application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; + application->index_app_desc_id++; + boundary_descriptor->descriptor_tag = temp_descriptor_tag; + boundary_descriptor->descriptor_length = gf_bs_read_int(bs,8); + pre_processing_pos = gf_bs_get_position(bs); + boundary_descriptor->boundary_extension_count = gf_bs_read_int(bs,8); + if (boundary_descriptor->boundary_extension_count > 0) { + boundary_descriptor->boundary_extension_info = (GF_M2TS_APPLICATION_BOUNDARY_EXTENSION_INFO*)gf_calloc(boundary_descriptor->boundary_extension_count,sizeof(GF_M2TS_APPLICATION_BOUNDARY_EXTENSION_INFO)); + for (i=0; iboundary_extension_count; i++) { + boundary_descriptor->boundary_extension_info[i].boundary_extension_length = gf_bs_read_int(bs,8); + if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { + boundary_descriptor->boundary_extension_info[i].boundary_extension_byte = (char*)gf_calloc(boundary_descriptor->boundary_extension_info[i].boundary_extension_length+1,sizeof(char)); + gf_bs_read_data(bs,boundary_descriptor->boundary_extension_info[i].boundary_extension_byte ,(u32)(boundary_descriptor->boundary_extension_info[i].boundary_extension_length)); + boundary_descriptor->boundary_extension_info[i].boundary_extension_byte[boundary_descriptor->boundary_extension_info[i].boundary_extension_length] = 0; } - gf_list_add(application->application_descriptors,Application_usage); - app_desc_data_shift += (2+ Application_usage->descriptor_length); - break; } - case APPLICATION_BOUNDARY_DESCRIPTOR: - { - u64 pre_processing_pos; + } + if (pre_processing_pos+boundary_descriptor->descriptor_length != gf_bs_get_position(bs)) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),boundary_descriptor->descriptor_length)); + if (boundary_descriptor->boundary_extension_count > 0) { u32 i; - GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR* boundary_descriptor; - GF_SAFEALLOC(boundary_descriptor, GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR); - application->application_descriptors_id[application->index_app_desc_id] = temp_descriptor_tag; - application->index_app_desc_id++; - boundary_descriptor->descriptor_tag = temp_descriptor_tag; - boundary_descriptor->descriptor_length = gf_bs_read_int(bs,8); - pre_processing_pos = gf_bs_get_position(bs); - boundary_descriptor->boundary_extension_count = gf_bs_read_int(bs,8); - if (boundary_descriptor->boundary_extension_count > 0) { - boundary_descriptor->boundary_extension_info = (GF_M2TS_APPLICATION_BOUNDARY_EXTENSION_INFO*)gf_calloc(boundary_descriptor->boundary_extension_count,sizeof(GF_M2TS_APPLICATION_BOUNDARY_EXTENSION_INFO)); - for (i=0;iboundary_extension_count;i++) { - boundary_descriptor->boundary_extension_info[i].boundary_extension_length = gf_bs_read_int(bs,8); - if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { - boundary_descriptor->boundary_extension_info[i].boundary_extension_byte = (char*)gf_calloc(boundary_descriptor->boundary_extension_info[i].boundary_extension_length+1,sizeof(char)); - gf_bs_read_data(bs,boundary_descriptor->boundary_extension_info[i].boundary_extension_byte ,(u32)(boundary_descriptor->boundary_extension_info[i].boundary_extension_length)); - boundary_descriptor->boundary_extension_info[i].boundary_extension_byte[boundary_descriptor->boundary_extension_info[i].boundary_extension_length] = 0; - } - } - } - if (pre_processing_pos+boundary_descriptor->descriptor_length != gf_bs_get_position(bs)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),boundary_descriptor->descriptor_length)); - if (boundary_descriptor->boundary_extension_count > 0) { - u32 i; - for (i=0;iboundary_extension_count;i++) { - if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { - gf_free(boundary_descriptor->boundary_extension_info[i].boundary_extension_byte); - } - } - gf_free(boundary_descriptor->boundary_extension_info); + for (i=0; iboundary_extension_count; i++) { + if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { + gf_free(boundary_descriptor->boundary_extension_info[i].boundary_extension_byte); } - gf_free(boundary_descriptor); - return GF_CORRUPTED_DATA; } - gf_list_add(application->application_descriptors,boundary_descriptor); - app_desc_data_shift += (2+ boundary_descriptor->descriptor_length); - break; - } - default: - { - u8 length; - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",temp_descriptor_tag)); - /* get descriptor's length */ - length = gf_bs_read_int(bs,8); - /* bit shifting (eq descriptor's length)*/ - gf_bs_read_int(bs,8*length); + gf_free(boundary_descriptor->boundary_extension_info); } + gf_free(boundary_descriptor); + return GF_CORRUPTED_DATA; + } + gf_list_add(application->application_descriptors,boundary_descriptor); + app_desc_data_shift += (2+ boundary_descriptor->descriptor_length); + break; + } + default: + { + u8 length; + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",temp_descriptor_tag)); + /* get descriptor's length */ + length = gf_bs_read_int(bs,8); + /* bit shifting (eq descriptor's length)*/ + gf_bs_read_int(bs,8*length); + } } } - ait_app_data_shift += application->application_descriptors_loop_length; - gf_list_add(ait->application_decoded,application); + ait_app_data_shift += application->application_descriptors_loop_length; + gf_list_add(ait->application_decoded,application); } data_shift +=ait->application_loop_length; @@ -412,7 +412,7 @@ static GF_Err gf_m2ts_decode_ait(GF_M2TS_AIT *ait, char *data, u32 data_size, u return GF_OK; } -static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ +static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait) { u32 nb_app_desc, k, desc_id, nb_of_app, j; GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo; @@ -424,9 +424,9 @@ static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ j=0; /* Link the AIT and the channel */ - ChanAppInfo = gf_m2ts_get_channel_application_info(ts->ChannelAppList,ait->service_id); + ChanAppInfo = gf_m2ts_get_channel_application_info(ts->ChannelAppList,ait->service_id); - if(!ChanAppInfo){ + if(!ChanAppInfo) { GF_SAFEALLOC(ChanAppInfo,GF_M2TS_CHANNEL_APPLICATION_INFO); ChanAppInfo->service_id = ait->service_id; ChanAppInfo->Application = gf_list_new(); @@ -437,12 +437,12 @@ static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ ChanAppInfo->nb_application = nb_of_app; GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[DSMCC] ChanAppInfo->nb_application %d \n",ChanAppInfo->nb_application)); - - for(j=0 ; jApplication,Application); + gf_list_add(ChanAppInfo->Application,Application); Application->http_url = NULL; Application->carousel_url = NULL; @@ -453,96 +453,96 @@ static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ Application->broadband = 0; Application->broadcast = 0; ChanAppInfo->version_number = ait->version_number; - + k=0; - for(k=0 ; kapplication_descriptors_id[k]; - switch(desc_id){ - case APPLICATION_DESCRIPTOR: - { - GF_M2TS_APPLICATION_DESCRIPTOR* application_descriptor = (GF_M2TS_APPLICATION_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); - Application->priority = application_descriptor->application_priority; - Application->application_profile = application_descriptor->application_profile; - - break; - } - case APPLICATION_NAME_DESCRIPTOR: - { - GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor = (GF_M2TS_APPLICATION_NAME_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); - Application->appli_name = gf_strdup(name_descriptor->application_name_char); - break; - } - case TRANSPORT_PROTOCOL_DESCRIPTOR: - { - GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor = (GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); - - switch(protocol_descriptor->protocol_id){ - case CAROUSEL: - { - GF_Err e; - GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*)protocol_descriptor->selector_byte; - if(ts->process_dmscc){ - GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = gf_m2ts_get_dmscc_overlord(ts->dsmcc_controler,ait->service_id); - Application->broadcast = 1; - if(!dsmcc_overlord){ - char app_url[1024], char_service_id[128]; - - memset(&app_url,0,1024*sizeof(char)); - memset(&char_service_id,0,128*sizeof(char)); - - dsmcc_overlord = gf_m2ts_init_dsmcc_overlord(ait->service_id); - dsmcc_overlord->application_id = Application->application_id; - sprintf(char_service_id,"%d",dsmcc_overlord->service_id); - dsmcc_overlord->root_dir = (char*)gf_calloc(strlen(ts->dsmcc_root_dir)+2+strlen(char_service_id),sizeof(char)); - sprintf(dsmcc_overlord->root_dir,"%s%c%s",ts->dsmcc_root_dir,GF_PATH_SEPARATOR,char_service_id); - e = gf_mkdir(dsmcc_overlord->root_dir); - if(e){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the creation of the directory %s \n",dsmcc_overlord->root_dir)); - if(e == GF_BAD_PARAM){ - gf_cleanup_dir(dsmcc_overlord->root_dir); - } - } - sprintf(app_url,"%s%cindex.html",dsmcc_overlord->root_dir,GF_PATH_SEPARATOR); - Application->carousel_url = gf_strdup(app_url); - gf_list_add(ts->dsmcc_controler,dsmcc_overlord); - } - } - if(Carousel_selector_byte->remote_connection){ - Application->carousel_pid = Carousel_selector_byte->service_id; - } - Application->component_tag = Carousel_selector_byte->component_tag; - - break; - } - case TRANSPORT_HTTP: - { - GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*)protocol_descriptor->selector_byte; - url_base = Transport_http_selector_byte->URL_base_byte; - Application->broadband = 1; - } - default: - { - } - } - break; - } - case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: - { - GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location = (GF_M2TS_SIMPLE_APPLICATION_LOCATION*)gf_list_get(application_decoded->application_descriptors,k); - url_appli_path = Simple_application_location->initial_path_bytes; - break; - } - case APPLICATION_USAGE_DESCRIPTOR: - { - break; - } - default: - { - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",desc_id)); + switch(desc_id) { + case APPLICATION_DESCRIPTOR: + { + GF_M2TS_APPLICATION_DESCRIPTOR* application_descriptor = (GF_M2TS_APPLICATION_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); + Application->priority = application_descriptor->application_priority; + Application->application_profile = application_descriptor->application_profile; + + break; + } + case APPLICATION_NAME_DESCRIPTOR: + { + GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor = (GF_M2TS_APPLICATION_NAME_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); + Application->appli_name = gf_strdup(name_descriptor->application_name_char); + break; + } + case TRANSPORT_PROTOCOL_DESCRIPTOR: + { + GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor = (GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR*)gf_list_get(application_decoded->application_descriptors,k); + + switch(protocol_descriptor->protocol_id) { + case CAROUSEL: + { + GF_Err e; + GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*)protocol_descriptor->selector_byte; + if(ts->process_dmscc) { + GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = gf_m2ts_get_dmscc_overlord(ts->dsmcc_controler,ait->service_id); + Application->broadcast = 1; + if(!dsmcc_overlord) { + char app_url[1024], char_service_id[128]; + + memset(&app_url,0,1024*sizeof(char)); + memset(&char_service_id,0,128*sizeof(char)); + + dsmcc_overlord = gf_m2ts_init_dsmcc_overlord(ait->service_id); + dsmcc_overlord->application_id = Application->application_id; + sprintf(char_service_id,"%d",dsmcc_overlord->service_id); + dsmcc_overlord->root_dir = (char*)gf_calloc(strlen(ts->dsmcc_root_dir)+2+strlen(char_service_id),sizeof(char)); + sprintf(dsmcc_overlord->root_dir,"%s%c%s",ts->dsmcc_root_dir,GF_PATH_SEPARATOR,char_service_id); + e = gf_mkdir(dsmcc_overlord->root_dir); + if(e) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the creation of the directory %s \n",dsmcc_overlord->root_dir)); + if(e == GF_BAD_PARAM) { + gf_cleanup_dir(dsmcc_overlord->root_dir); } + } + sprintf(app_url,"%s%cindex.html",dsmcc_overlord->root_dir,GF_PATH_SEPARATOR); + Application->carousel_url = gf_strdup(app_url); + gf_list_add(ts->dsmcc_controler,dsmcc_overlord); + } + } + if(Carousel_selector_byte->remote_connection) { + Application->carousel_pid = Carousel_selector_byte->service_id; + } + Application->component_tag = Carousel_selector_byte->component_tag; + + break; + } + case TRANSPORT_HTTP: + { + GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*)protocol_descriptor->selector_byte; + url_base = Transport_http_selector_byte->URL_base_byte; + Application->broadband = 1; + } + default: + { + } + } + break; + } + case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: + { + GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location = (GF_M2TS_SIMPLE_APPLICATION_LOCATION*)gf_list_get(application_decoded->application_descriptors,k); + url_appli_path = Simple_application_location->initial_path_bytes; + break; + } + case APPLICATION_USAGE_DESCRIPTOR: + { + break; + } + default: + { + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",desc_id)); + } } - if((url_base != NULL) && ( url_appli_path != NULL)){ + if((url_base != NULL) && ( url_appli_path != NULL)) { u32 url_length = (strlen(url_base)+strlen(url_appli_path)); Application->http_url = (char*)gf_calloc(url_length + 1,sizeof(char)); sprintf(Application->http_url,"%s%s",url_base,url_appli_path); @@ -555,40 +555,40 @@ static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ } } - if(ts->process_dmscc){ + if(ts->process_dmscc) { GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = gf_m2ts_get_dmscc_overlord(ts->dsmcc_controler,ait->service_id); - if(dsmcc_overlord && !gf_m2ts_is_dmscc_app(ChanAppInfo)){ + if(dsmcc_overlord && !gf_m2ts_is_dmscc_app(ChanAppInfo)) { gf_cleanup_dir(dsmcc_overlord->root_dir); - gf_rmdir(dsmcc_overlord->root_dir); + gf_rmdir(dsmcc_overlord->root_dir); gf_m2ts_delete_dsmcc_overlord(dsmcc_overlord); } } } -static Bool gf_m2ts_is_dmscc_app(GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo){ - +static Bool gf_m2ts_is_dmscc_app(GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo) { + u32 nb_app,i; nb_app = gf_list_count(ChanAppInfo->Application); - for(i=0;iApplication,i); - if(Application->broadband){ + if(Application->broadband) { return 1; } } return 0; } -GF_M2TS_CHANNEL_APPLICATION_INFO* gf_m2ts_get_channel_application_info(GF_List* ChannelAppList, u32 ait_service_id){ +GF_M2TS_CHANNEL_APPLICATION_INFO* gf_m2ts_get_channel_application_info(GF_List* ChannelAppList, u32 ait_service_id) { u32 i,nb_chanapp; nb_chanapp = gf_list_count(ChannelAppList); - for(i = 0; i < nb_chanapp; i++){ + for(i = 0; i < nb_chanapp; i++) { GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*)gf_list_get(ChannelAppList,i); - if(ChanAppInfo->service_id == ait_service_id){ + if(ChanAppInfo->service_id == ait_service_id) { return ChanAppInfo; } } @@ -599,25 +599,25 @@ GF_M2TS_CHANNEL_APPLICATION_INFO* gf_m2ts_get_channel_application_info(GF_List* static Bool check_ait_already_received(GF_List* ChannelAppList,u32 pid,char* data) { - u32 nb_of_ait; + u32 nb_of_ait; u32 version_number; nb_of_ait = 0; nb_of_ait = gf_list_count(ChannelAppList); - if(nb_of_ait){ + if(nb_of_ait) { u32 i; - for(i = 0;i < nb_of_ait;i++){ + for(i = 0; i < nb_of_ait; i++) { GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*) gf_list_get(ChannelAppList,i); - if(ChanAppInfo->ait_pid == pid){ + if(ChanAppInfo->ait_pid == pid) { version_number = (data[5] &0x3E)>>1; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] AIT ait_list_version number %d, ait->version_number %d \n",ChanAppInfo->version_number,version_number)); - if(ChanAppInfo->version_number >= version_number){ - GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] AIT already received, abording processing \n")); + if(ChanAppInfo->version_number >= version_number) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] AIT already received, abording processing \n")); return 1; - }else{ - while(ChanAppInfo->nb_application != 0){ + } else { + while(ChanAppInfo->nb_application != 0) { GF_M2TS_AIT_APPLICATION* Application = gf_list_get(ChanAppInfo->Application,0); gf_m2ts_free_ait_application(Application); gf_list_rem(ChanAppInfo->Application,0); @@ -628,7 +628,7 @@ static Bool check_ait_already_received(GF_List* ChannelAppList,u32 pid,char* dat } } } - }else{ + } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[Process AIT] No AIT received \n")); } @@ -639,20 +639,20 @@ static void gf_ait_destroy(GF_M2TS_AIT* ait) { u32 common_descr_numb, app_numb; - /* delete de Elementary Stream part of the AIT structure */ + /* delete de Elementary Stream part of the AIT structure */ common_descr_numb = 0; app_numb = 0; - /* delete the common descriptors */ + /* delete the common descriptors */ common_descr_numb = gf_list_count(ait->common_descriptors); - while(common_descr_numb != 0){ + while(common_descr_numb != 0) { //TODO }; gf_list_del(ait->common_descriptors); /* delete the applications and their descriptors */ app_numb = gf_list_count(ait->application_decoded); - while(app_numb != 0){ + while(app_numb != 0) { GF_M2TS_AIT_APPLICATION_DECODE* application = gf_list_get(ait->application_decoded,0); gf_ait_application_decode_destroy(application); gf_list_rem(ait->application_decoded,0); @@ -667,7 +667,7 @@ static void gf_ait_application_decode_destroy(GF_M2TS_AIT_APPLICATION_DECODE* ap u32 app_desc_num,i,app_descr_index; - app_desc_num = app_descr_index = i = 0; + app_desc_num = app_descr_index = i = 0; app_desc_num = gf_list_count(application_decode->application_descriptors); while (app_desc_num != 0) { @@ -675,82 +675,82 @@ static void gf_ait_application_decode_destroy(GF_M2TS_AIT_APPLICATION_DECODE* ap descr_tag = application_decode->application_descriptors_id[i]; GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[DSMCC] descr_tag %d\n", descr_tag)); switch(descr_tag) { - case APPLICATION_DESCRIPTOR: - { - GF_M2TS_APPLICATION_DESCRIPTOR* application_descriptor = (GF_M2TS_APPLICATION_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); - gf_free(application_descriptor); - break; - } - case APPLICATION_NAME_DESCRIPTOR: - { - GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor = (GF_M2TS_APPLICATION_NAME_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); - gf_free(name_descriptor->application_name_char); - gf_free(name_descriptor); - break; - } - case TRANSPORT_PROTOCOL_DESCRIPTOR: - { - GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor = (GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); - switch (protocol_descriptor->protocol_id) { + case APPLICATION_DESCRIPTOR: + { + GF_M2TS_APPLICATION_DESCRIPTOR* application_descriptor = (GF_M2TS_APPLICATION_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); + gf_free(application_descriptor); + break; + } + case APPLICATION_NAME_DESCRIPTOR: + { + GF_M2TS_APPLICATION_NAME_DESCRIPTOR* name_descriptor = (GF_M2TS_APPLICATION_NAME_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); + gf_free(name_descriptor->application_name_char); + gf_free(name_descriptor); + break; + } + case TRANSPORT_PROTOCOL_DESCRIPTOR: + { + GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR* protocol_descriptor = (GF_M2TS_TRANSPORT_PROTOCOL_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors,0); + switch (protocol_descriptor->protocol_id) { case CAROUSEL: - { - GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*)protocol_descriptor->selector_byte; - gf_free(Carousel_selector_byte); - break; - } + { + GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte = (GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE*)protocol_descriptor->selector_byte; + gf_free(Carousel_selector_byte); + break; + } case TRANSPORT_HTTP: - { - u32 i; - GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*)protocol_descriptor->selector_byte; - gf_free(Transport_http_selector_byte->URL_base_byte); - if (Transport_http_selector_byte->URL_extension_count) { - for (i=0; i < Transport_http_selector_byte->URL_extension_count;i++) { - gf_free(Transport_http_selector_byte->URL_extentions[i].URL_extension_byte); - } - gf_free(Transport_http_selector_byte->URL_extentions); + { + u32 i; + GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte = (GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE*)protocol_descriptor->selector_byte; + gf_free(Transport_http_selector_byte->URL_base_byte); + if (Transport_http_selector_byte->URL_extension_count) { + for (i=0; i < Transport_http_selector_byte->URL_extension_count; i++) { + gf_free(Transport_http_selector_byte->URL_extentions[i].URL_extension_byte); } - gf_free(Transport_http_selector_byte); - break; + gf_free(Transport_http_selector_byte->URL_extentions); } + gf_free(Transport_http_selector_byte); + break; + } default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id)); - } - } - gf_free(protocol_descriptor); - break; - } - case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: - { - GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location = (GF_M2TS_SIMPLE_APPLICATION_LOCATION*)gf_list_get(application_decode->application_descriptors,0); - gf_free(Simple_application_location->initial_path_bytes); - gf_free(Simple_application_location); - break; - } - case APPLICATION_USAGE_DESCRIPTOR: - { - GF_M2TS_APPLICATION_USAGE* Application_usage = (GF_M2TS_APPLICATION_USAGE*)gf_list_get(application_decode->application_descriptors,0); - gf_free(Application_usage); - break; - } - case APPLICATION_BOUNDARY_DESCRIPTOR: - { - u32 i; - GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR* boundary_descriptor = (GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors, 0); - if (boundary_descriptor->boundary_extension_count > 0) { - for (i=0; iboundary_extension_count; i++) { - if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { - gf_free(boundary_descriptor->boundary_extension_info[i].boundary_extension_byte); - } - } - gf_free(boundary_descriptor->boundary_extension_info); + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id)); + } + } + gf_free(protocol_descriptor); + break; + } + case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR: + { + GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location = (GF_M2TS_SIMPLE_APPLICATION_LOCATION*)gf_list_get(application_decode->application_descriptors,0); + gf_free(Simple_application_location->initial_path_bytes); + gf_free(Simple_application_location); + break; + } + case APPLICATION_USAGE_DESCRIPTOR: + { + GF_M2TS_APPLICATION_USAGE* Application_usage = (GF_M2TS_APPLICATION_USAGE*)gf_list_get(application_decode->application_descriptors,0); + gf_free(Application_usage); + break; + } + case APPLICATION_BOUNDARY_DESCRIPTOR: + { + u32 i; + GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR* boundary_descriptor = (GF_M2TS_APPLICATION_BOUNDARY_DESCRIPTOR*)gf_list_get(application_decode->application_descriptors, 0); + if (boundary_descriptor->boundary_extension_count > 0) { + for (i=0; iboundary_extension_count; i++) { + if (boundary_descriptor->boundary_extension_info[i].boundary_extension_length > 0) { + gf_free(boundary_descriptor->boundary_extension_info[i].boundary_extension_byte); } - gf_free(boundary_descriptor); - break; - } - default: - { } + gf_free(boundary_descriptor->boundary_extension_info); + } + gf_free(boundary_descriptor); + break; + } + default: + { + } } gf_list_rem(application_decode->application_descriptors,0); app_desc_num = gf_list_count(application_decode->application_descriptors); @@ -760,24 +760,24 @@ static void gf_ait_application_decode_destroy(GF_M2TS_AIT_APPLICATION_DECODE* ap gf_free(application_decode); } -static void gf_m2ts_free_ait_application(GF_M2TS_AIT_APPLICATION* Application){ +static void gf_m2ts_free_ait_application(GF_M2TS_AIT_APPLICATION* Application) { - if(Application->http_url){ + if(Application->http_url) { gf_free(Application->http_url); } - if(Application->carousel_url){ + if(Application->carousel_url) { gf_free(Application->carousel_url); } - if(Application->appli_name){ + if(Application->appli_name) { gf_free(Application->appli_name); } gf_free(Application); } -void gf_m2ts_delete_channel_application_info(GF_M2TS_CHANNEL_APPLICATION_INFO* ChannelApp){ +void gf_m2ts_delete_channel_application_info(GF_M2TS_CHANNEL_APPLICATION_INFO* ChannelApp) { - while(gf_list_count(ChannelApp->Application)){ + while(gf_list_count(ChannelApp->Application)) { GF_M2TS_AIT_APPLICATION* Application = (GF_M2TS_AIT_APPLICATION*)gf_list_get(ChannelApp->Application,0); gf_m2ts_free_ait_application(Application); gf_list_rem(ChannelApp->Application,0); diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c index 83b1817..0bd2534 100644 --- a/src/media_tools/av_parsers.c +++ b/src/media_tools/av_parsers.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre, Romain Bouqueau, Cyril Concolato + * Authors: Jean Le Feuvre, Romain Bouqueau, Cyril Concolato * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,9 +32,11 @@ #include #endif -static const struct { u32 w, h; } std_par[ ] = +static const struct { + u32 w, h; +} std_par[ ] = { - { 4, 3}, {3, 2}, {16, 9}, {5, 3}, {5, 4}, {8, 5}, + { 4, 3}, {3, 2}, {16, 9}, {5, 3}, {5, 4}, {8, 5}, {0, 0}, }; @@ -60,7 +62,7 @@ void gf_media_get_reduced_frame_rate(u32 *timescale, u32 *sample_dur) u32 res; if (! *sample_dur) return; res = *timescale / *sample_dur; - if (res * *sample_dur == *timescale) { + if (res **sample_dur == *timescale) { *timescale = res; *sample_dur = 1; } @@ -70,69 +72,132 @@ GF_EXPORT const char *gf_m4v_get_profile_name(u8 video_pl) { switch (video_pl) { - case 0x00: return "Reserved (0x00) Profile"; - case 0x01: return "Simple Profile @ Level 1"; - case 0x02: return "Simple Profile @ Level 2"; - case 0x03: return "Simple Profile @ Level 3"; - case 0x08: return "Simple Profile @ Level 0"; - case 0x10: return "Simple Scalable Profile @ Level 0"; - case 0x11: return "Simple Scalable Profile @ Level 1"; - case 0x12: return "Simple Scalable Profile @ Level 2"; - case 0x15: return "AVC/H264 Profile"; - case 0x21: return "Core Profile @ Level 1"; - case 0x22: return "Core Profile @ Level 2"; - case 0x32: return "Main Profile @ Level 2"; - case 0x33: return "Main Profile @ Level 3"; - case 0x34: return "Main Profile @ Level 4"; - case 0x42: return "N-bit Profile @ Level 2"; - case 0x51: return "Scalable Texture Profile @ Level 1"; - case 0x61: return "Simple Face Animation Profile @ Level 1"; - case 0x62: return "Simple Face Animation Profile @ Level 2"; - case 0x63: return "Simple FBA Profile @ Level 1"; - case 0x64: return "Simple FBA Profile @ Level 2"; - case 0x71: return "Basic Animated Texture Profile @ Level 1"; - case 0x72: return "Basic Animated Texture Profile @ Level 2"; - case 0x81: return "Hybrid Profile @ Level 1"; - case 0x82: return "Hybrid Profile @ Level 2"; - case 0x91: return "Advanced Real Time Simple Profile @ Level 1"; - case 0x92: return "Advanced Real Time Simple Profile @ Level 2"; - case 0x93: return "Advanced Real Time Simple Profile @ Level 3"; - case 0x94: return "Advanced Real Time Simple Profile @ Level 4"; - case 0xA1: return "Core Scalable Profile @ Level1"; - case 0xA2: return "Core Scalable Profile @ Level2"; - case 0xA3: return "Core Scalable Profile @ Level3"; - case 0xB1: return "Advanced Coding Efficiency Profile @ Level 1"; - case 0xB2: return "Advanced Coding Efficiency Profile @ Level 2"; - case 0xB3: return "Advanced Coding Efficiency Profile @ Level 3"; - case 0xB4: return "Advanced Coding Efficiency Profile @ Level 4"; - case 0xC1: return "Advanced Core Profile @ Level 1"; - case 0xC2: return "Advanced Core Profile @ Level 2"; - case 0xD1: return "Advanced Scalable Texture @ Level1"; - case 0xD2: return "Advanced Scalable Texture @ Level2"; - case 0xE1: return "Simple Studio Profile @ Level 1"; - case 0xE2: return "Simple Studio Profile @ Level 2"; - case 0xE3: return "Simple Studio Profile @ Level 3"; - case 0xE4: return "Simple Studio Profile @ Level 4"; - case 0xE5: return "Core Studio Profile @ Level 1"; - case 0xE6: return "Core Studio Profile @ Level 2"; - case 0xE7: return "Core Studio Profile @ Level 3"; - case 0xE8: return "Core Studio Profile @ Level 4"; - case 0xF0: return "Advanced Simple Profile @ Level 0"; - case 0xF1: return "Advanced Simple Profile @ Level 1"; - case 0xF2: return "Advanced Simple Profile @ Level 2"; - case 0xF3: return "Advanced Simple Profile @ Level 3"; - case 0xF4: return "Advanced Simple Profile @ Level 4"; - case 0xF5: return "Advanced Simple Profile @ Level 5"; - case 0xF7: return "Advanced Simple Profile @ Level 3b"; - case 0xF8: return "Fine Granularity Scalable Profile @ Level 0"; - case 0xF9: return "Fine Granularity Scalable Profile @ Level 1"; - case 0xFA: return "Fine Granularity Scalable Profile @ Level 2"; - case 0xFB: return "Fine Granularity Scalable Profile @ Level 3"; - case 0xFC: return "Fine Granularity Scalable Profile @ Level 4"; - case 0xFD: return "Fine Granularity Scalable Profile @ Level 5"; - case 0xFE: return "Not part of MPEG-4 Visual profiles"; - case 0xFF: return "No visual capability required"; - default: return "ISO Reserved Profile"; + case 0x00: + return "Reserved (0x00) Profile"; + case 0x01: + return "Simple Profile @ Level 1"; + case 0x02: + return "Simple Profile @ Level 2"; + case 0x03: + return "Simple Profile @ Level 3"; + case 0x08: + return "Simple Profile @ Level 0"; + case 0x10: + return "Simple Scalable Profile @ Level 0"; + case 0x11: + return "Simple Scalable Profile @ Level 1"; + case 0x12: + return "Simple Scalable Profile @ Level 2"; + case 0x15: + return "AVC/H264 Profile"; + case 0x21: + return "Core Profile @ Level 1"; + case 0x22: + return "Core Profile @ Level 2"; + case 0x32: + return "Main Profile @ Level 2"; + case 0x33: + return "Main Profile @ Level 3"; + case 0x34: + return "Main Profile @ Level 4"; + case 0x42: + return "N-bit Profile @ Level 2"; + case 0x51: + return "Scalable Texture Profile @ Level 1"; + case 0x61: + return "Simple Face Animation Profile @ Level 1"; + case 0x62: + return "Simple Face Animation Profile @ Level 2"; + case 0x63: + return "Simple FBA Profile @ Level 1"; + case 0x64: + return "Simple FBA Profile @ Level 2"; + case 0x71: + return "Basic Animated Texture Profile @ Level 1"; + case 0x72: + return "Basic Animated Texture Profile @ Level 2"; + case 0x81: + return "Hybrid Profile @ Level 1"; + case 0x82: + return "Hybrid Profile @ Level 2"; + case 0x91: + return "Advanced Real Time Simple Profile @ Level 1"; + case 0x92: + return "Advanced Real Time Simple Profile @ Level 2"; + case 0x93: + return "Advanced Real Time Simple Profile @ Level 3"; + case 0x94: + return "Advanced Real Time Simple Profile @ Level 4"; + case 0xA1: + return "Core Scalable Profile @ Level1"; + case 0xA2: + return "Core Scalable Profile @ Level2"; + case 0xA3: + return "Core Scalable Profile @ Level3"; + case 0xB1: + return "Advanced Coding Efficiency Profile @ Level 1"; + case 0xB2: + return "Advanced Coding Efficiency Profile @ Level 2"; + case 0xB3: + return "Advanced Coding Efficiency Profile @ Level 3"; + case 0xB4: + return "Advanced Coding Efficiency Profile @ Level 4"; + case 0xC1: + return "Advanced Core Profile @ Level 1"; + case 0xC2: + return "Advanced Core Profile @ Level 2"; + case 0xD1: + return "Advanced Scalable Texture @ Level1"; + case 0xD2: + return "Advanced Scalable Texture @ Level2"; + case 0xE1: + return "Simple Studio Profile @ Level 1"; + case 0xE2: + return "Simple Studio Profile @ Level 2"; + case 0xE3: + return "Simple Studio Profile @ Level 3"; + case 0xE4: + return "Simple Studio Profile @ Level 4"; + case 0xE5: + return "Core Studio Profile @ Level 1"; + case 0xE6: + return "Core Studio Profile @ Level 2"; + case 0xE7: + return "Core Studio Profile @ Level 3"; + case 0xE8: + return "Core Studio Profile @ Level 4"; + case 0xF0: + return "Advanced Simple Profile @ Level 0"; + case 0xF1: + return "Advanced Simple Profile @ Level 1"; + case 0xF2: + return "Advanced Simple Profile @ Level 2"; + case 0xF3: + return "Advanced Simple Profile @ Level 3"; + case 0xF4: + return "Advanced Simple Profile @ Level 4"; + case 0xF5: + return "Advanced Simple Profile @ Level 5"; + case 0xF7: + return "Advanced Simple Profile @ Level 3b"; + case 0xF8: + return "Fine Granularity Scalable Profile @ Level 0"; + case 0xF9: + return "Fine Granularity Scalable Profile @ Level 1"; + case 0xFA: + return "Fine Granularity Scalable Profile @ Level 2"; + case 0xFB: + return "Fine Granularity Scalable Profile @ Level 3"; + case 0xFC: + return "Fine Granularity Scalable Profile @ Level 4"; + case 0xFD: + return "Fine Granularity Scalable Profile @ Level 5"; + case 0xFE: + return "Not part of MPEG-4 Visual profiles"; + case 0xFF: + return "No visual capability required"; + default: + return "ISO Reserved Profile"; } } @@ -152,24 +217,24 @@ const char *gf_m4v_get_profile_name(u8 video_pl) s32 gf_mv12_next_start_code(unsigned char *pbuffer, u32 buflen, u32 *optr, u32 *scode) { - u32 value; - u32 offset; + u32 value; + u32 offset; - if (buflen < 4) return -1; - for (offset = 0; offset < buflen - 3; offset++, pbuffer++) { + if (buflen < 4) return -1; + for (offset = 0; offset < buflen - 3; offset++, pbuffer++) { #ifdef GPAC_BIG_ENDIAN - value = *(u32 *)pbuffer >> 8; + value = *(u32 *)pbuffer >> 8; #else - value = (pbuffer[0] << 16) | (pbuffer[1] << 8) | (pbuffer[2] << 0); + value = (pbuffer[0] << 16) | (pbuffer[1] << 8) | (pbuffer[2] << 0); #endif - if (value == MPEG12_START_CODE_PREFIX) { - *optr = offset; - *scode = (value << 8) | pbuffer[3]; - return 0; + if (value == MPEG12_START_CODE_PREFIX) { + *optr = offset; + *scode = (value << 8) | pbuffer[3]; + return 0; + } } - } - return -1; + return -1; } s32 gf_mv12_next_slice_start(unsigned char *pbuffer, u32 startoffset, u32 buflen, u32 *slice_offset) @@ -341,35 +406,73 @@ static GF_Err gf_m4v_parse_config_mpeg12(GF_M4VParser *m4v, GF_M4VDecSpecInfo *d dsi->VideoPL = GPAC_OTI_VIDEO_MPEG1; par = (p[3] >> 4) & 0xf; switch (par) { - case 2: dsi->par_num = dsi->height/3; dsi->par_den = dsi->width/4; break; - case 3: dsi->par_num = dsi->height/9; dsi->par_den = dsi->width/16; break; - case 4: dsi->par_num = dsi->height/2; dsi->par_den = dsi->width/21; break; - default: dsi->par_den = dsi->par_num = 0; break; + case 2: + dsi->par_num = dsi->height/3; + dsi->par_den = dsi->width/4; + break; + case 3: + dsi->par_num = dsi->height/9; + dsi->par_den = dsi->width/16; + break; + case 4: + dsi->par_num = dsi->height/2; + dsi->par_den = dsi->width/21; + break; + default: + dsi->par_den = dsi->par_num = 0; + break; } switch (p[3] & 0xf) { - case 0: break; - case 1: dsi->fps = 24000.0/1001.0; break; - case 2: dsi->fps = 24.0; break; - case 3: dsi->fps = 25.0; break; - case 4: dsi->fps = 30000.0/1001.0; break; - case 5: dsi->fps = 30.0; break; - case 6: dsi->fps = 50.0; break; - case 7: dsi->fps = ((60.0*1000.0)/1001.0); break; - case 8: dsi->fps = 60.0; break; - case 9: dsi->fps = 1; break; - case 10: dsi->fps = 5; break; - case 11: dsi->fps = 10; break; - case 12: dsi->fps = 12; break; - case 13: dsi->fps = 15; break; + case 0: + break; + case 1: + dsi->fps = 24000.0/1001.0; + break; + case 2: + dsi->fps = 24.0; + break; + case 3: + dsi->fps = 25.0; + break; + case 4: + dsi->fps = 30000.0/1001.0; + break; + case 5: + dsi->fps = 30.0; + break; + case 6: + dsi->fps = 50.0; + break; + case 7: + dsi->fps = ((60.0*1000.0)/1001.0); + break; + case 8: + dsi->fps = 60.0; + break; + case 9: + dsi->fps = 1; + break; + case 10: + dsi->fps = 5; + break; + case 11: + dsi->fps = 10; + break; + case 12: + dsi->fps = 12; + break; + case 13: + dsi->fps = 15; + break; } break; case M2V_EXT_START_CODE: gf_bs_read_data(m4v->bs, (char *) p, 4); ext_type = ((p[0] >> 4) & 0xf); if (ext_type == 1) { - dsi->VideoPL = 0x65; - dsi->height = ((p[1] & 0x1) << 13) | ((p[2] & 0x80) << 5) | (dsi->height & 0x0fff); - dsi->width = (((p[2] >> 5) & 0x3) << 12) | (dsi->width & 0x0fff); + dsi->VideoPL = 0x65; + dsi->height = ((p[1] & 0x1) << 13) | ((p[2] & 0x80) << 5) | (dsi->height & 0x0fff); + dsi->width = (((p[2] >> 5) & 0x3) << 12) | (dsi->width & 0x0fff); } break; case M2V_PIC_START_CODE: @@ -389,7 +492,9 @@ static GF_Err gf_m4v_parse_config_mpeg12(GF_M4VParser *m4v, GF_M4VDecSpecInfo *d } -static const struct { u32 w, h; } m4v_sar[6] = { { 0, 0 }, { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 }, { 40, 33 } }; +static const struct { + u32 w, h; +} m4v_sar[6] = { { 0, 0 }, { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 }, { 40, 33 } }; static u8 m4v_get_sar_idx(u32 w, u32 h) { @@ -450,14 +555,14 @@ static GF_Err gf_m4v_parse_config_mpeg4(GF_M4VParser *m4v, GF_M4VDecSpecInfo *ds clock_rate = dsi->clock_rate-1; if (clock_rate >= 65536) clock_rate = 65535; if (clock_rate > 0) { - for (dsi->NumBitsTimeIncrement = 1; dsi->NumBitsTimeIncrement < 16; dsi->NumBitsTimeIncrement++) { + for (dsi->NumBitsTimeIncrement = 1; dsi->NumBitsTimeIncrement < 16; dsi->NumBitsTimeIncrement++) { if (clock_rate == 1) break; clock_rate = (clock_rate >> 1); } } else { /*fix from vivien for divX*/ dsi->NumBitsTimeIncrement = 1; - } + } /*fixed FPS stream*/ dsi->time_increment = 0; if (gf_bs_read_int(m4v->bs, 1)) { @@ -519,7 +624,7 @@ static GF_Err gf_m4v_parse_frame_mpeg12(GF_M4VParser *m4v, GF_M4VDecSpecInfo dsi M4V_Reset(m4v, m4v->current_object_start); go = 1; - + while (go) { o_type = M4V_LoadObject(m4v); switch (o_type) { @@ -618,7 +723,7 @@ static GF_Err gf_m4v_parse_frame_mpeg4(GF_M4VParser *m4v, GF_M4VDecSpecInfo dsi, /*vop_time_inc*/ if (dsi.NumBitsTimeIncrement) vop_inc = gf_bs_read_int(m4v->bs, dsi.NumBitsTimeIncrement); - + m4v->prev_tc_dec = m4v->tc_dec; m4v->prev_tc_disp = m4v->tc_disp; if (dsi.enh_layer || *frame_type!=2) { @@ -735,7 +840,7 @@ GF_Err gf_m4v_rewrite_par(char **o_data, u32 *o_dataLen, s32 par_n, s32 par_d) u32 b = gf_bs_read_int(m4v->bs, 1); gf_bs_write_int(mod, b, 1); } - + gf_m4v_parser_del(m4v); gf_free(*o_data); gf_bs_get_content(mod, o_data, o_dataLen); @@ -778,44 +883,82 @@ GF_EXPORT const char *gf_m4a_object_type_name(u32 objectType) { switch (objectType) { - case 0: return "MPEG-4 Audio Reserved"; - case 1: return "MPEG-4 Audio AAC Main"; - case 2: return "MPEG-4 Audio AAC LC"; - case 3: return "MPEG-4 Audio AAC SSR"; - case 4: return "MPEG-4 Audio AAC LTP"; - case 5: return "MPEG-4 Audio SBR"; - case 6: return "MPEG-4 Audio AAC Scalable"; - case 7: return "MPEG-4 Audio TwinVQ"; - case 8: return "MPEG-4 Audio CELP"; - case 9: return "MPEG-4 Audio HVXC"; - case 10: return "MPEG-4 Audio Reserved"; - case 11: return "MPEG-4 Audio Reserved"; - case 12: return "MPEG-4 Audio TTSI"; - case 13: return "MPEG-4 Audio Main synthetic"; - case 14: return "MPEG-4 Audio Wavetable synthesis"; - case 15: return "MPEG-4 Audio General MIDI"; - case 16: return "MPEG-4 Audio Algorithmic Synthesis and Audio FX"; - case 17: return "MPEG-4 Audio ER AAC LC"; - case 18: return "MPEG-4 Audio Reserved"; - case 19: return "MPEG-4 Audio ER AAC LTP"; - case 20: return "MPEG-4 Audio ER AAC scalable"; - case 21: return "MPEG-4 Audio ER TwinVQ"; - case 22: return "MPEG-4 Audio ER BSAC"; - case 23: return "MPEG-4 Audio ER AAC LD"; - case 24: return "MPEG-4 Audio ER CELP"; - case 25: return "MPEG-4 Audio ER HVXC"; - case 26: return "MPEG-4 Audio ER HILN"; - case 27: return "MPEG-4 Audio ER Parametric"; - case 28: return "MPEG-4 Audio SSC"; - case 29: return "MPEG-4 Audio ParametricStereo"; - case 30: return "MPEG-4 Audio Reserved"; - case 31: return "MPEG-4 Audio Reserved"; - case 32: return "MPEG-1 Audio Layer-1"; - case 33: return "MPEG-1 Audio Layer-2"; - case 34: return "MPEG-1 Audio Layer-3"; - case 35: return "MPEG-4 Audio DST"; - case 36: return "MPEG-4 Audio ALS"; - default: return "MPEG-4 Audio Unknown"; + case 0: + return "MPEG-4 Audio Reserved"; + case 1: + return "MPEG-4 Audio AAC Main"; + case 2: + return "MPEG-4 Audio AAC LC"; + case 3: + return "MPEG-4 Audio AAC SSR"; + case 4: + return "MPEG-4 Audio AAC LTP"; + case 5: + return "MPEG-4 Audio SBR"; + case 6: + return "MPEG-4 Audio AAC Scalable"; + case 7: + return "MPEG-4 Audio TwinVQ"; + case 8: + return "MPEG-4 Audio CELP"; + case 9: + return "MPEG-4 Audio HVXC"; + case 10: + return "MPEG-4 Audio Reserved"; + case 11: + return "MPEG-4 Audio Reserved"; + case 12: + return "MPEG-4 Audio TTSI"; + case 13: + return "MPEG-4 Audio Main synthetic"; + case 14: + return "MPEG-4 Audio Wavetable synthesis"; + case 15: + return "MPEG-4 Audio General MIDI"; + case 16: + return "MPEG-4 Audio Algorithmic Synthesis and Audio FX"; + case 17: + return "MPEG-4 Audio ER AAC LC"; + case 18: + return "MPEG-4 Audio Reserved"; + case 19: + return "MPEG-4 Audio ER AAC LTP"; + case 20: + return "MPEG-4 Audio ER AAC scalable"; + case 21: + return "MPEG-4 Audio ER TwinVQ"; + case 22: + return "MPEG-4 Audio ER BSAC"; + case 23: + return "MPEG-4 Audio ER AAC LD"; + case 24: + return "MPEG-4 Audio ER CELP"; + case 25: + return "MPEG-4 Audio ER HVXC"; + case 26: + return "MPEG-4 Audio ER HILN"; + case 27: + return "MPEG-4 Audio ER Parametric"; + case 28: + return "MPEG-4 Audio SSC"; + case 29: + return "MPEG-4 Audio ParametricStereo"; + case 30: + return "MPEG-4 Audio Reserved"; + case 31: + return "MPEG-4 Audio Reserved"; + case 32: + return "MPEG-1 Audio Layer-1"; + case 33: + return "MPEG-1 Audio Layer-2"; + case 34: + return "MPEG-1 Audio Layer-3"; + case 35: + return "MPEG-4 Audio DST"; + case 36: + return "MPEG-4 Audio ALS"; + default: + return "MPEG-4 Audio Unknown"; } } @@ -823,57 +966,108 @@ GF_EXPORT const char *gf_m4a_get_profile_name(u8 audio_pl) { switch (audio_pl) { - case 0x00: return "ISO Reserved (0x00)"; - case 0x01: return "Main Audio Profile @ Level 1"; - case 0x02: return "Main Audio Profile @ Level 2"; - case 0x03: return "Main Audio Profile @ Level 3"; - case 0x04: return "Main Audio Profile @ Level 4"; - case 0x05: return "Scalable Audio Profile @ Level 1"; - case 0x06: return "Scalable Audio Profile @ Level 2"; - case 0x07: return "Scalable Audio Profile @ Level 3"; - case 0x08: return "Scalable Audio Profile @ Level 4"; - case 0x09: return "Speech Audio Profile @ Level 1"; - case 0x0A: return "Speech Audio Profile @ Level 2"; - case 0x0B: return "Synthetic Audio Profile @ Level 1"; - case 0x0C: return "Synthetic Audio Profile @ Level 2"; - case 0x0D: return "Synthetic Audio Profile @ Level 3"; - case 0x0E: return "High Quality Audio Profile @ Level 1"; - case 0x0F: return "High Quality Audio Profile @ Level 2"; - case 0x10: return "High Quality Audio Profile @ Level 3"; - case 0x11: return "High Quality Audio Profile @ Level 4"; - case 0x12: return "High Quality Audio Profile @ Level 5"; - case 0x13: return "High Quality Audio Profile @ Level 6"; - case 0x14: return "High Quality Audio Profile @ Level 7"; - case 0x15: return "High Quality Audio Profile @ Level 8"; - case 0x16: return "Low Delay Audio Profile @ Level 1"; - case 0x17: return "Low Delay Audio Profile @ Level 2"; - case 0x18: return "Low Delay Audio Profile @ Level 3"; - case 0x19: return "Low Delay Audio Profile @ Level 4"; - case 0x1A: return "Low Delay Audio Profile @ Level 5"; - case 0x1B: return "Low Delay Audio Profile @ Level 6"; - case 0x1C: return "Low Delay Audio Profile @ Level 7"; - case 0x1D: return "Low Delay Audio Profile @ Level 8"; - case 0x1E: return "Natural Audio Profile @ Level 1"; - case 0x1F: return "Natural Audio Profile @ Level 2"; - case 0x20: return "Natural Audio Profile @ Level 3"; - case 0x21: return "Natural Audio Profile @ Level 4"; - case 0x22: return "Mobile Audio Internetworking Profile @ Level 1"; - case 0x23: return "Mobile Audio Internetworking Profile @ Level 2"; - case 0x24: return "Mobile Audio Internetworking Profile @ Level 3"; - case 0x25: return "Mobile Audio Internetworking Profile @ Level 4"; - case 0x26: return "Mobile Audio Internetworking Profile @ Level 5"; - case 0x27: return "Mobile Audio Internetworking Profile @ Level 6"; - case 0x28: return "AAC Profile @ Level 1"; - case 0x29: return "AAC Profile @ Level 2"; - case 0x2A: return "AAC Profile @ Level 4"; - case 0x2B: return "AAC Profile @ Level 5"; - case 0x2C: return "High Efficiency AAC Profile @ Level 2"; - case 0x2D: return "High Efficiency AAC Profile @ Level 3"; - case 0x2E: return "High Efficiency AAC Profile @ Level 4"; - case 0x2F: return "High Efficiency AAC Profile @ Level 5"; - case 0xFE: return "Not part of MPEG-4 audio profiles"; - case 0xFF: return "No audio capability required"; - default: return "ISO Reserved / User Private"; + case 0x00: + return "ISO Reserved (0x00)"; + case 0x01: + return "Main Audio Profile @ Level 1"; + case 0x02: + return "Main Audio Profile @ Level 2"; + case 0x03: + return "Main Audio Profile @ Level 3"; + case 0x04: + return "Main Audio Profile @ Level 4"; + case 0x05: + return "Scalable Audio Profile @ Level 1"; + case 0x06: + return "Scalable Audio Profile @ Level 2"; + case 0x07: + return "Scalable Audio Profile @ Level 3"; + case 0x08: + return "Scalable Audio Profile @ Level 4"; + case 0x09: + return "Speech Audio Profile @ Level 1"; + case 0x0A: + return "Speech Audio Profile @ Level 2"; + case 0x0B: + return "Synthetic Audio Profile @ Level 1"; + case 0x0C: + return "Synthetic Audio Profile @ Level 2"; + case 0x0D: + return "Synthetic Audio Profile @ Level 3"; + case 0x0E: + return "High Quality Audio Profile @ Level 1"; + case 0x0F: + return "High Quality Audio Profile @ Level 2"; + case 0x10: + return "High Quality Audio Profile @ Level 3"; + case 0x11: + return "High Quality Audio Profile @ Level 4"; + case 0x12: + return "High Quality Audio Profile @ Level 5"; + case 0x13: + return "High Quality Audio Profile @ Level 6"; + case 0x14: + return "High Quality Audio Profile @ Level 7"; + case 0x15: + return "High Quality Audio Profile @ Level 8"; + case 0x16: + return "Low Delay Audio Profile @ Level 1"; + case 0x17: + return "Low Delay Audio Profile @ Level 2"; + case 0x18: + return "Low Delay Audio Profile @ Level 3"; + case 0x19: + return "Low Delay Audio Profile @ Level 4"; + case 0x1A: + return "Low Delay Audio Profile @ Level 5"; + case 0x1B: + return "Low Delay Audio Profile @ Level 6"; + case 0x1C: + return "Low Delay Audio Profile @ Level 7"; + case 0x1D: + return "Low Delay Audio Profile @ Level 8"; + case 0x1E: + return "Natural Audio Profile @ Level 1"; + case 0x1F: + return "Natural Audio Profile @ Level 2"; + case 0x20: + return "Natural Audio Profile @ Level 3"; + case 0x21: + return "Natural Audio Profile @ Level 4"; + case 0x22: + return "Mobile Audio Internetworking Profile @ Level 1"; + case 0x23: + return "Mobile Audio Internetworking Profile @ Level 2"; + case 0x24: + return "Mobile Audio Internetworking Profile @ Level 3"; + case 0x25: + return "Mobile Audio Internetworking Profile @ Level 4"; + case 0x26: + return "Mobile Audio Internetworking Profile @ Level 5"; + case 0x27: + return "Mobile Audio Internetworking Profile @ Level 6"; + case 0x28: + return "AAC Profile @ Level 1"; + case 0x29: + return "AAC Profile @ Level 2"; + case 0x2A: + return "AAC Profile @ Level 4"; + case 0x2B: + return "AAC Profile @ Level 5"; + case 0x2C: + return "High Efficiency AAC Profile @ Level 2"; + case 0x2D: + return "High Efficiency AAC Profile @ Level 3"; + case 0x2E: + return "High Efficiency AAC Profile @ Level 4"; + case 0x2F: + return "High Efficiency AAC Profile @ Level 5"; + case 0xFE: + return "Not part of MPEG-4 audio profiles"; + case 0xFF: + return "No audio capability required"; + default: + return "ISO Reserved / User Private"; } } @@ -965,11 +1159,11 @@ GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_k gf_bs_read_int(bs, 5); gf_bs_read_int(bs, 11); } - if ((cfg->base_object_type == 17) - || (cfg->base_object_type == 19) - || (cfg->base_object_type == 20) - || (cfg->base_object_type == 23) - ) { + if ((cfg->base_object_type == 17) + || (cfg->base_object_type == 19) + || (cfg->base_object_type == 20) + || (cfg->base_object_type == 23) + ) { gf_bs_read_int(bs, 1); gf_bs_read_int(bs, 1); gf_bs_read_int(bs, 1); @@ -977,7 +1171,7 @@ GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_k ext_flag = gf_bs_read_int(bs, 1); } } - break; + break; } /*ER cfg*/ switch (cfg->base_object_type) { @@ -999,7 +1193,7 @@ GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_k gf_bs_read_int(bs, 1); } } - break; + break; } if (size_known && (cfg->base_object_type != 5) && (cfg->base_object_type != 29) ) { @@ -1127,7 +1321,7 @@ GF_Err gf_m4a_write_config_bs(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg) gf_bs_write_int(bs, 0, 3); } } - break; + break; } /*ER cfg - not supported*/ @@ -1163,7 +1357,7 @@ GF_Err gf_m4a_write_config(GF_M4ADecSpecInfo *cfg, char **dsi, u32 *dsi_size) GF_EXPORT u8 gf_mp3_version(u32 hdr) { - return ((hdr >> 19) & 0x3); + return ((hdr >> 19) & 0x3); } GF_EXPORT @@ -1171,11 +1365,16 @@ const char *gf_mp3_version_name(u32 hdr) { u32 v = gf_mp3_version(hdr); switch (v) { - case 0: return "MPEG-2.5"; - case 1: return "Reserved"; - case 2: return "MPEG-2"; - case 3: return "MPEG-1"; - default: return "Unknown"; + case 0: + return "MPEG-2.5"; + case 1: + return "Reserved"; + case 2: + return "MPEG-2"; + case 3: + return "MPEG-1"; + default: + return "Unknown"; } } @@ -1204,16 +1403,16 @@ u16 gf_mp3_sampling_rate(u32 hdr) u8 sampleRateIndex = (hdr >> 10) & 0x3; switch (sampleRateIndex) { - case 0: - res = 44100; + case 0: + res = 44100; break; - case 1: - res = 48000; + case 1: + res = 48000; break; - case 2: - res = 32000; + case 2: + res = 32000; break; - default: + default: GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[MPEG-1/2 Audio] Samplerate index not valid\n")); return 0; } @@ -1259,19 +1458,24 @@ u8 gf_mp3_object_type_indication(u32 hdr) static u32 const bitrate_table[5][15] = { - /* MPEG-1 */ - { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ - 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, - { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ - 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, - { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ - 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, - - /* MPEG-2 LSF */ - { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ - 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, - { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ - 64000, 80000, 96000, 112000, 128000, 144000, 160000 } /* II & III */ + /* MPEG-1 */ + { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ + 256000, 288000, 320000, 352000, 384000, 416000, 448000 + }, + { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ + 128000, 160000, 192000, 224000, 256000, 320000, 384000 + }, + { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ + 112000, 128000, 160000, 192000, 224000, 256000, 320000 + }, + + /* MPEG-2 LSF */ + { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ + 128000, 144000, 160000, 176000, 192000, 224000, 256000 + }, + { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ + 64000, 80000, 96000, 112000, 128000, 144000, 160000 + } /* II & III */ }; @@ -1283,15 +1487,15 @@ u32 gf_mp3_bit_rate(u32 hdr) if (bitRateIndex == 15) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[MPEG-1/2 Audio] Bitrate index not valid\n")); - return 0; + return 0; } /*MPEG-1*/ if (version & 1) - return bitrate_table[layer - 1][bitRateIndex]; + return bitrate_table[layer - 1][bitRateIndex]; /*MPEG-2/2.5*/ else - return bitrate_table[3 + (layer >> 1)][bitRateIndex]; + return bitrate_table[3 + (layer >> 1)][bitRateIndex]; } @@ -1312,7 +1516,7 @@ u16 gf_mp3_frame_size(u32 hdr) frameSize = (( 12 * bitrate / samplerate) + pad) * 4; } else { u32 slots_per_frame = 144; - if ((layer == 3) && !(version & 1)) slots_per_frame = 72; + if ((layer == 3) && !(version & 1)) slots_per_frame = 72; frameSize = (slots_per_frame * bitrate / samplerate) + pad; } return (u16) frameSize; @@ -1336,8 +1540,8 @@ u32 gf_mp3_get_next_header(FILE* in) } if (state==2) { if (((b & 0xF0) == 0) || ((b & 0xF0) == 0xF0) || ((b & 0x0C) == 0x0C)) { - if (bytes[1] == 0xFF) state = 1; - else state = 0; + if (bytes[1] == 0xFF) state = 1; + else state = 0; } else { bytes[state] = b; state = 3; @@ -1387,7 +1591,7 @@ u32 gf_mp3_get_next_header_mem(const char *buffer, u32 size, u32 *pos) if (state==3) { u32 val; - bytes[state] = b; + bytes[state] = b; val = GF_4CC(bytes[0], bytes[1], bytes[2], bytes[3]); if (gf_mp3_frame_size(val)) { *pos = dropped; @@ -1399,7 +1603,7 @@ u32 gf_mp3_get_next_header_mem(const char *buffer, u32 size, u32 *pos) if (state==2) { if (((b & 0xF0) == 0) || ((b & 0xF0) == 0xF0) || ((b & 0x0C) == 0x0C)) { if (bytes[1] == 0xFF) { - state = 1; + state = 1; dropped+=1; } else { state = 0; @@ -1440,16 +1644,26 @@ GF_EXPORT const char *gf_avc_get_profile_name(u8 video_prof) { switch (video_prof) { - case 0x42: return "Baseline"; - case 0x4D: return "Main"; - case 0x53: return "Scalable Baseline"; - case 0x56: return "Scalable High"; - case 0x58: return "Extended"; - case 0x64: return "High"; - case 0x6E: return "High 10"; - case 0x7A: return "High 4:2:2"; - case 0x90: return "High 4:4:4"; - default: return "Unknown"; + case 0x42: + return "Baseline"; + case 0x4D: + return "Main"; + case 0x53: + return "Scalable Baseline"; + case 0x56: + return "Scalable High"; + case 0x58: + return "Extended"; + case 0x64: + return "High"; + case 0x6E: + return "High 10"; + case 0x7A: + return "High 4:2:2"; + case 0x90: + return "High 4:4:4"; + default: + return "Unknown"; } } @@ -1457,10 +1671,14 @@ GF_EXPORT const char *gf_hevc_get_profile_name(u8 video_prof) { switch (video_prof) { - case 0x01: return "Main"; - case 0x02: return "Main 10"; - case 0x03: return "Main Still Picture"; - default: return "Unknown"; + case 0x01: + return "Main"; + case 0x02: + return "Main 10"; + case 0x03: + return "Main Still Picture"; + default: + return "Unknown"; } } @@ -1468,21 +1686,21 @@ const char *gf_hevc_get_profile_name(u8 video_prof) static u8 avc_golomb_bits[256] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1507,7 +1725,7 @@ static u32 bs_get_ue(GF_BitStream *bs) return gf_bs_read_int(bs, bits + 1) - 1; } -static s32 bs_get_se(GF_BitStream *bs) +static s32 bs_get_se(GF_BitStream *bs) { u32 v = bs_get_ue(bs); if ((v & 0x1) == 0) return (s32) (0 - (v>>1)); @@ -1543,7 +1761,7 @@ u32 gf_media_nalu_next_start_code_bs(GF_BitStream *bs) u64 end, cache_start, load_size; u64 start = gf_bs_get_position(bs); if (start<3) return 0; - + load_size = 0; bpos = 0; cache_start = 0; @@ -1574,13 +1792,13 @@ u32 gf_media_nalu_next_start_code(u8 *data, u32 data_len, u32 *sc_size) { u32 v, bpos; u32 end; - + bpos = 0; end = 0; v = 0xffffffff; while (!end) { /*refill cache*/ - if (bpos == (u32) data_len) + if (bpos == (u32) data_len) break; v = ( (v<<8) & 0xFFFFFF00) | ((u32) data[bpos]); @@ -1600,20 +1818,20 @@ u32 gf_media_nalu_next_start_code(u8 *data, u32 data_len, u32 *sc_size) return (u32) (end); } -Bool gf_media_avc_slice_is_intra(AVCState *avc) +Bool gf_media_avc_slice_is_intra(AVCState *avc) { switch (avc->s_info.slice_type) { - case GF_AVC_TYPE_I: - case GF_AVC_TYPE2_I: - case GF_AVC_TYPE_SI: - case GF_AVC_TYPE2_SI: - return 1; - default: - return 0; + case GF_AVC_TYPE_I: + case GF_AVC_TYPE2_I: + case GF_AVC_TYPE_SI: + case GF_AVC_TYPE2_SI: + return 1; + default: + return 0; } } -Bool gf_media_avc_slice_is_IDR(AVCState *avc) +Bool gf_media_avc_slice_is_IDR(AVCState *avc) { if (avc->sei.recovery_point.valid) { @@ -1625,7 +1843,9 @@ Bool gf_media_avc_slice_is_IDR(AVCState *avc) return gf_media_avc_slice_is_intra(avc); } -static const struct { u32 w, h; } avc_sar[14] = +static const struct { + u32 w, h; +} avc_sar[14] = { { 0, 0 }, { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 }, { 40, 33 }, { 24, 11 }, { 20, 11 }, @@ -1664,7 +1884,7 @@ static u32 avc_emulation_bytes_add_count(char *buffer, u32 nal_size) { u32 i = 0, emulation_bytes_count = 0; u8 num_zero = 0; - + while (i < nal_size) { /*ISO 14496-10: "Within the NAL unit, any four-byte sequence that starts with 0x000003 other than the following sequences shall not occur at any byte-aligned position: @@ -1688,12 +1908,12 @@ static u32 avc_emulation_bytes_add_count(char *buffer, u32 nal_size) return emulation_bytes_count; } -static u32 avc_add_emulation_bytes(const char *buffer_src, char *buffer_dst, u32 nal_size) -{ +static u32 avc_add_emulation_bytes(const char *buffer_src, char *buffer_dst, u32 nal_size) +{ u32 i = 0, emulation_bytes_count = 0; u8 num_zero = 0; - + while (i < nal_size) { /*ISO 14496-10: "Within the NAL unit, any four-byte sequence that starts with 0x000003 other than the following sequences shall not occur at any byte-aligned position: @@ -1737,9 +1957,9 @@ static u32 avc_emulation_bytes_remove_count(unsigned char *buffer, u32 nal_size) \96 0x00000303" */ if (num_zero == 2 - && buffer[i] == 0x03 - && i+1 < nal_size /*next byte is readable*/ - && buffer[i+1] < 0x04) + && buffer[i] == 0x03 + && i+1 < nal_size /*next byte is readable*/ + && buffer[i+1] < 0x04) { /*emulation code found*/ num_zero = 0; @@ -1760,26 +1980,26 @@ static u32 avc_emulation_bytes_remove_count(unsigned char *buffer, u32 nal_size) #endif /*GPAC_UNUSED_FUNC*/ /*nal_size is updated to allow better error detection*/ -static u32 avc_remove_emulation_bytes(const char *buffer_src, char *buffer_dst, u32 nal_size) -{ +static u32 avc_remove_emulation_bytes(const char *buffer_src, char *buffer_dst, u32 nal_size) +{ u32 i = 0, emulation_bytes_count = 0; - u8 num_zero = 0; - - while (i < nal_size) - { - /*ISO 14496-10: "Within the NAL unit, any four-byte sequence that starts with 0x000003 - other than the following sequences shall not occur at any byte-aligned position: - 0x00000300 - 0x00000301 - 0x00000302 - 0x00000303" - */ - if (num_zero == 2 - && buffer_src[i] == 0x03 - && i+1 < nal_size /*next byte is readable*/ - && buffer_src[i+1] < 0x04) - { - /*emulation code found*/ + u8 num_zero = 0; + + while (i < nal_size) + { + /*ISO 14496-10: "Within the NAL unit, any four-byte sequence that starts with 0x000003 + other than the following sequences shall not occur at any byte-aligned position: + 0x00000300 + 0x00000301 + 0x00000302 + 0x00000303" + */ + if (num_zero == 2 + && buffer_src[i] == 0x03 + && i+1 < nal_size /*next byte is readable*/ + && buffer_src[i+1] < 0x04) + { + /*emulation code found*/ num_zero = 0; emulation_bytes_count++; i++; @@ -1787,16 +2007,16 @@ static u32 avc_remove_emulation_bytes(const char *buffer_src, char *buffer_dst, buffer_dst[i-emulation_bytes_count] = buffer_src[i]; - if (!buffer_src[i]) - num_zero++; - else - num_zero = 0; + if (!buffer_src[i]) + num_zero++; + else + num_zero = 0; + + i++; + } - i++; - } - - return nal_size-emulation_bytes_count; -} + return nal_size-emulation_bytes_count; +} GF_EXPORT s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 subseq_sps, u32 *vui_flag_pos) @@ -1831,7 +2051,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 level_idc = gf_bs_read_int(bs, 8); /*SubsetSps is used to be sure that AVC SPS are not going to be scratched - by subset SPS. According to the SVC standard, subset SPS can have the same sps_id + by subset SPS. According to the SVC standard, subset SPS can have the same sps_id than its base layer, but it does not refer to the same SPS. */ sps_id = bs_get_ue(bs) + GF_SVC_SSPS_ID_SHIFT * subseq_sps; if (sps_id >=32) { @@ -1843,7 +2063,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 sps = &avc->sps[sps_id]; sps->state |= subseq_sps ? AVC_SUBSPS_PARSED : AVC_SPS_PARSED; - /*High Profile and SVC*/ + /*High Profile and SVC*/ switch (profile_idc) { case 100: case 110: @@ -1889,8 +2109,8 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 } } break; - } - + } + sps->profile_idc = profile_idc; sps->level_idc = level_idc; sps->prof_compat = pcomp; @@ -1927,7 +2147,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 if (!sps->frame_mbs_only_flag) gf_bs_read_int(bs, 1); gf_bs_read_int(bs, 1); /*direct_8x8_inference_flag*/ cl = cr = ct = cb = 0; - if (gf_bs_read_int(bs, 1)) /*crop*/ { + if (gf_bs_read_int(bs, 1)) { /*crop*/ cl = bs_get_ue(bs); /*crop_left*/ cr = bs_get_ue(bs); /*crop_right*/ ct = bs_get_ue(bs); /*crop_top*/ @@ -1956,10 +2176,10 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 if(gf_bs_read_int(bs, 1)) /* overscan_info_present_flag */ gf_bs_read_int(bs, 1); /* overscan_appropriate_flag */ - if (gf_bs_read_int(bs, 1)){ /* video_signal_type_present_flag */ + if (gf_bs_read_int(bs, 1)) { /* video_signal_type_present_flag */ gf_bs_read_int(bs, 3); /* video_format */ gf_bs_read_int(bs, 1); /* video_full_range_flag */ - if (gf_bs_read_int(bs, 1)){ /* colour_description_present_flag */ + if (gf_bs_read_int(bs, 1)) { /* colour_description_present_flag */ gf_bs_read_int(bs, 8); /* colour_primaries */ gf_bs_read_int(bs, 8); /* transfer_characteristics */ gf_bs_read_int(bs, 8); /* matrix_coefficients */ @@ -2000,7 +2220,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 /*inter_layer_deblocking_filter_control_present_flag=*/ gf_bs_read_int(bs, 1); extended_spatial_scalability_idc = gf_bs_read_int(bs, 2); - if (ChromaArrayType == 1 || ChromaArrayType == 2) { + if (ChromaArrayType == 1 || ChromaArrayType == 2) { /*chroma_phase_x_plus1_flag*/ gf_bs_read_int(bs, 1); } if( ChromaArrayType == 1 ) { @@ -2012,7 +2232,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 /*seq_ref_layer_chroma_phase_y_plus1*/gf_bs_read_int(bs, 2); } /*seq_scaled_ref_layer_left_offset*/ bs_get_se(bs); - /*seq_scaled_ref_layer_top_offset*/bs_get_se(bs); + /*seq_scaled_ref_layer_top_offset*/bs_get_se(bs); /*seq_scaled_ref_layer_right_offset*/bs_get_se(bs); /*seq_scaled_ref_layer_bottom_offset*/bs_get_se(bs); } @@ -2056,7 +2276,7 @@ s32 gf_media_avc_read_sps(const char *sps_data, u32 sps_size, AVCState *avc, u32 GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] MVC not supported - skipping parsing end of Subset SPS\n")); goto exit; } - + if (gf_bs_read_int(bs, 1)) { GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] skipping parsing end of Subset SPS (additional_extension2)\n")); goto exit; @@ -2095,7 +2315,7 @@ s32 gf_media_avc_read_pps(const char *pps_data, u32 pps_size, AVCState *avc) goto exit; } pps = &avc->pps[pps_id]; - + if (!pps->status) pps->status = 1; pps->sps_id = bs_get_ue(bs); if (pps->sps_id >= 32) { @@ -2118,7 +2338,7 @@ s32 gf_media_avc_read_pps(const char *pps_data, u32 pps_size, AVCState *avc) /* if ((pps->ref_count[0] > 32) || (pps->ref_count[1] > 32)) goto exit; */ - + /*pps->weighted_pred = */gf_bs_read_int(bs, 1); /*pps->weighted_bipred_idc = */gf_bs_read_int(bs, 2); /*pps->init_qp = */bs_get_se(bs) /*+ 26*/; @@ -2145,7 +2365,7 @@ s32 gf_media_avc_read_sps_ext(const char *spse_data, u32 spse_size) spse_data_without_emulation_bytes = gf_malloc(spse_size*sizeof(char)); spse_data_without_emulation_bytes_size = avc_remove_emulation_bytes(spse_data, spse_data_without_emulation_bytes, spse_size); bs = gf_bs_new(spse_data_without_emulation_bytes, spse_data_without_emulation_bytes_size, GF_BITSTREAM_READ); - + /*nal header*/gf_bs_read_u8(bs); sps_id = bs_get_ue(bs); @@ -2171,7 +2391,7 @@ static s32 SVC_ReadNal_header_extension(GF_BitStream *bs, SVC_NALUHeader *NalHea return 1; } -static s32 avc_parse_slice(GF_BitStream *bs, AVCState *avc, Bool svc_idr_flag, AVCSliceInfo *si) +static s32 avc_parse_slice(GF_BitStream *bs, AVCState *avc, Bool svc_idr_flag, AVCSliceInfo *si) { s32 pps_id; @@ -2198,7 +2418,7 @@ static s32 avc_parse_slice(GF_BitStream *bs, AVCState *avc, Bool svc_idr_flag, A } if ((si->nal_unit_type==GF_AVC_NALU_IDR_SLICE) || svc_idr_flag) si->idr_pic_id = bs_get_ue(bs); - + if (si->sps->poc_type==0) { si->poc_lsb = gf_bs_read_int(bs, si->sps->log2_max_poc_lsb); if (si->pps->pic_order_present && !si->field_pic_flag) { @@ -2216,7 +2436,7 @@ static s32 avc_parse_slice(GF_BitStream *bs, AVCState *avc, Bool svc_idr_flag, A } -static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) +static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) { s32 pps_id; @@ -2233,7 +2453,7 @@ static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) if (!si->pps->slice_group_count) return -2; si->sps = &avc->sps[si->pps->sps_id + GF_SVC_SSPS_ID_SHIFT]; - if (!si->sps->log2_max_frame_num) + if (!si->sps->log2_max_frame_num) return -2; si->frame_num = gf_bs_read_int(bs, si->sps->log2_max_frame_num); @@ -2247,10 +2467,10 @@ static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) } if (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE || si ->NalHeader.idr_pic_flag) si->idr_pic_id = bs_get_ue(bs); - + if (si->sps->poc_type==0) { si->poc_lsb = gf_bs_read_int(bs, si->sps->log2_max_poc_lsb); - if (si->pps->pic_order_present && !si->field_pic_flag) { + if (si->pps->pic_order_present && !si->field_pic_flag) { si->delta_poc_bottom = bs_get_se(bs); } } else if ((si->sps->poc_type==1) && !si->sps->delta_pic_order_always_zero_flag) { @@ -2265,7 +2485,7 @@ static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si) } -static s32 avc_parse_recovery_point_sei(GF_BitStream *bs, AVCState *avc) +static s32 avc_parse_recovery_point_sei(GF_BitStream *bs, AVCState *avc) { AVCSeiRecoveryPoint *rp = &avc->sei.recovery_point; @@ -2279,7 +2499,7 @@ static s32 avc_parse_recovery_point_sei(GF_BitStream *bs, AVCState *avc) } /*for interpretation see ISO 14496-10 N.11084, table D-1*/ -static s32 avc_parse_pic_timing_sei(GF_BitStream *bs, AVCState *avc) +static s32 avc_parse_pic_timing_sei(GF_BitStream *bs, AVCState *avc) { int i; int sps_id = avc->sps_active_idx; @@ -2365,18 +2585,18 @@ static void avc_compute_poc(AVCSliceInfo *si) else si->frame_num_offset = si->frame_num_offset_prev; } - + /*ISO 14496-10 N.11084 8.2.1.1*/ if (si->sps->poc_type==0) { const u32 max_poc_lsb = 1 << (si->sps->log2_max_poc_lsb); - + /*ISO 14496-10 N.11084 eq (8-3)*/ if ((si->poc_lsb < si->poc_lsb_prev) && - (si->poc_lsb_prev - si->poc_lsb >= max_poc_lsb / 2) ) + (si->poc_lsb_prev - si->poc_lsb >= max_poc_lsb / 2) ) si->poc_msb = si->poc_msb_prev + max_poc_lsb; else if ((si->poc_lsb > si->poc_lsb_prev) && - (si->poc_lsb - si->poc_lsb_prev > max_poc_lsb / 2)) + (si->poc_lsb - si->poc_lsb_prev > max_poc_lsb / 2)) si->poc_msb = si->poc_msb_prev - max_poc_lsb; else si->poc_msb = si->poc_msb_prev; @@ -2392,7 +2612,7 @@ static void avc_compute_poc(AVCSliceInfo *si) else field_poc[1] = si->poc_msb + si->poc_lsb; } - } + } /*ISO 14496-10 N.11084 8.2.1.2*/ else if (si->sps->poc_type==1) { @@ -2426,7 +2646,7 @@ static void avc_compute_poc(AVCSliceInfo *si) field_poc[0] = expected_poc + si->delta_poc[0]; field_poc[1] = field_poc[0] + si->sps->offset_for_top_to_bottom_field; if (pic_type == AVC_PIC_FRAME) field_poc[1] += si->delta_poc[1]; - } + } /*ISO 14496-10 N.11084 8.2.1.3*/ else if (si->sps->poc_type== 2) { @@ -2462,7 +2682,7 @@ s32 gf_media_avc_parse_nalu(GF_BitStream *bs, u32 nal_hdr, AVCState *avc) memcpy(&n_state, &avc->s_info, sizeof(AVCSliceInfo)); n_state.nal_unit_type = nal_hdr & 0x1F; n_state.nal_ref_idc = (nal_hdr>>5) & 0x3; - + idr_flag = 0; ret = 0; switch (n_state.nal_unit_type) { @@ -2481,7 +2701,7 @@ s32 gf_media_avc_parse_nalu(GF_BitStream *bs, u32 nal_hdr, AVCState *avc) n_state.poc_lsb_prev = avc->s_info.poc_lsb; n_state.poc_msb_prev = avc->s_info.poc_msb; } - if (slice) + if (slice) avc_compute_poc(&n_state); if (avc->s_info.poc != n_state.poc) { @@ -2506,16 +2726,22 @@ s32 gf_media_avc_parse_nalu(GF_BitStream *bs, u32 nal_hdr, AVCState *avc) if (ret<0) return ret; ret = 0; if ( - ((avc->s_info.nal_unit_type > GF_AVC_NALU_IDR_SLICE) || (avc->s_info.nal_unit_type < GF_AVC_NALU_NON_IDR_SLICE)) - && (avc->s_info.nal_unit_type != GF_AVC_NALU_SVC_SLICE) + ((avc->s_info.nal_unit_type > GF_AVC_NALU_IDR_SLICE) || (avc->s_info.nal_unit_type < GF_AVC_NALU_NON_IDR_SLICE)) + && (avc->s_info.nal_unit_type != GF_AVC_NALU_SVC_SLICE) ) { break; } - if (avc->s_info.frame_num != n_state.frame_num) { ret = 1; break; } + if (avc->s_info.frame_num != n_state.frame_num) { + ret = 1; + break; + } - if (avc->s_info.field_pic_flag != n_state.field_pic_flag) { ret = 1; break; } + if (avc->s_info.field_pic_flag != n_state.field_pic_flag) { + ret = 1; + break; + } if ((avc->s_info.nal_ref_idc != n_state.nal_ref_idc) && - (!avc->s_info.nal_ref_idc || !n_state.nal_ref_idc)) { + (!avc->s_info.nal_ref_idc || !n_state.nal_ref_idc)) { ret = 1; break; } @@ -2523,8 +2749,8 @@ s32 gf_media_avc_parse_nalu(GF_BitStream *bs, u32 nal_hdr, AVCState *avc) if (avc->s_info.sps->poc_type == n_state.sps->poc_type) { if (!avc->s_info.sps->poc_type) { - if (!n_state.bottom_field_flag && (avc->s_info.poc_lsb != n_state.poc_lsb)) { - ret = 1; + if (!n_state.bottom_field_flag && (avc->s_info.poc_lsb != n_state.poc_lsb)) { + ret = 1; break; } if (avc->s_info.delta_poc_bottom != n_state.delta_poc_bottom) { @@ -2566,10 +2792,10 @@ s32 gf_media_avc_parse_nalu(GF_BitStream *bs, u32 nal_hdr, AVCState *avc) ret = 1; else if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEQ_PARAM && avc -> s_info .nal_unit_type == GF_AVC_NALU_SVC_SLICE) ret = 1; - else + else ret = 0; break; - } + } /* save _prev values */ if (ret && avc->s_info.sps) { @@ -2641,26 +2867,26 @@ u32 gf_media_avc_reformat_sei(char *buffer, u32 nal_size, AVCState *avc) assert(start+psize+1 < nal_size+1); prev = sei_without_emulation_bytes[start+psize+1]; sei_without_emulation_bytes[start+psize+1] = 0; - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[avc-h264] SEI user message %s\n", sei_without_emulation_bytes+start+16)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[avc-h264] SEI user message %s\n", sei_without_emulation_bytes+start+16)); sei_without_emulation_bytes[start+psize+1] = prev; } - break; - + break; + case 6: /*recovery point*/ - { - GF_BitStream *rp_bs = gf_bs_new(sei_without_emulation_bytes + start, psize, GF_BITSTREAM_READ); - avc_parse_recovery_point_sei(rp_bs, avc); - gf_bs_del(rp_bs); - } - break; + { + GF_BitStream *rp_bs = gf_bs_new(sei_without_emulation_bytes + start, psize, GF_BITSTREAM_READ); + avc_parse_recovery_point_sei(rp_bs, avc); + gf_bs_del(rp_bs); + } + break; case 1: /*pic_timing*/ - { - GF_BitStream *pt_bs = gf_bs_new(sei_without_emulation_bytes + start, psize, GF_BITSTREAM_READ); - avc_parse_pic_timing_sei(pt_bs, avc); - gf_bs_del(pt_bs); - } - break; + { + GF_BitStream *pt_bs = gf_bs_new(sei_without_emulation_bytes + start, psize, GF_BITSTREAM_READ); + avc_parse_pic_timing_sei(pt_bs, avc); + gf_bs_del(pt_bs); + } + break; case 0: /*buffering period*/ case 2: /*pan scan rect*/ @@ -2692,7 +2918,8 @@ u32 gf_media_avc_reformat_sei(char *buffer, u32 nal_size, AVCState *avc) var = psize; while (var>=255) { new_buffer[written] = (char) 0xff; - written++; var-=255; + written++; + var-=255; } new_buffer[written] = (char) var; written++; @@ -2886,7 +3113,7 @@ GF_Err gf_avc_get_pps_info(char *pps_data, u32 pps_size, u32 *pps_id, u32 *sps_i } /*nal hdr*/ gf_bs_read_int(bs, 8); - *pps_id = bs_get_ue(bs); + *pps_id = bs_get_ue(bs); *sps_id = bs_get_ue(bs); exit: @@ -2918,7 +3145,7 @@ Bool gf_media_hevc_slice_is_intra(HEVCState *hevc) } } -Bool gf_media_hevc_slice_is_IDR(HEVCState *hevc) +Bool gf_media_hevc_slice_is_IDR(HEVCState *hevc) { if (hevc->sei.recovery_point.valid) { @@ -2934,7 +3161,7 @@ Bool gf_media_hevc_slice_is_IDR(HEVCState *hevc) } } -static Bool parse_short_term_ref_pic_set(GF_BitStream *bs, HEVC_SPS *sps, u32 idx_rps) +static Bool parse_short_term_ref_pic_set(GF_BitStream *bs, HEVC_SPS *sps, u32 idx_rps) { u32 i; Bool inter_ref_pic_set_prediction_flag = 0; @@ -2948,7 +3175,7 @@ static Bool parse_short_term_ref_pic_set(GF_BitStream *bs, HEVC_SPS *sps, u32 id u32 delta_rps_sign; u32 abs_delta_rps_minus1, nb_ref_pics; s32 deltaRPS; - u32 k = 0, k0 = 0, k1 = 0; + u32 k = 0, k0 = 0, k1 = 0; if (idx_rps == sps->num_short_term_ref_pic_sets) delta_idx_minus1 = bs_get_ue(bs); @@ -2971,14 +3198,14 @@ static Bool parse_short_term_ref_pic_set(GF_BitStream *bs, HEVC_SPS *sps, u32 id } if ((ref_idc==1) || (ref_idc== 2)) { s32 deltaPOC = deltaRPS; - if (i < nb_ref_pics) + if (i < nb_ref_pics) deltaPOC += ref_ps->delta_poc[i]; - + rps->delta_poc[k] = deltaPOC; if (deltaPOC < 0) k0++; else k1++; - + k++; } } @@ -3007,7 +3234,7 @@ static Bool parse_short_term_ref_pic_set(GF_BitStream *bs, HEVC_SPS *sps, u32 id } #define PARSE_FULL_HEADER 0 -static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSliceInfo *si) +s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSliceInfo *si) { #if PARSE_FULL_HEADER u32 i, j; @@ -3017,7 +3244,7 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice s32 pps_id; Bool RapPicFlag = 0; Bool IDRPicFlag = 0; - + si->first_slice_segment_in_pic_flag = gf_bs_read_int(bs, 1); switch (si->nal_unit_type) { @@ -3056,12 +3283,12 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice } else { si->slice_segment_address = 0; } - + if( !si->dependent_slice_segment_flag ) { #if PARSE_FULL_HEADER Bool deblocking_filter_override_flag=0; Bool slice_temporal_mvp_enabled_flag = 0; - Bool slice_sao_luma_flag=0; + Bool slice_sao_luma_flag=0; Bool slice_sao_chroma_flag=0; Bool slice_deblocking_filter_disabled_flag=0; #endif @@ -3073,7 +3300,7 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice if(pps->output_flag_present_flag) /*pic_output_flag = */gf_bs_read_int(bs, 1); - + if (sps->separate_colour_plane_flag == 1) /*colour_plane_id = */gf_bs_read_int(bs, 2); @@ -3090,57 +3317,57 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice Bool ret = parse_short_term_ref_pic_set(bs, sps, sps->num_short_term_ref_pic_sets ); if (!ret) return 0; } else if( sps->num_short_term_ref_pic_sets > 1 ) { - u32 numbits = 0; - s32 short_term_ref_pic_set_idx; - while ( (u32) (1 << numbits) < sps->num_short_term_ref_pic_sets) - numbits++; - if (numbits > 0) - short_term_ref_pic_set_idx = gf_bs_read_int(bs, numbits); - else - short_term_ref_pic_set_idx = 0; + u32 numbits = 0; + s32 short_term_ref_pic_set_idx; + while ( (u32) (1 << numbits) < sps->num_short_term_ref_pic_sets) + numbits++; + if (numbits > 0) + short_term_ref_pic_set_idx = gf_bs_read_int(bs, numbits); + else + short_term_ref_pic_set_idx = 0; } if (sps->long_term_ref_pics_present_flag ) { u8 DeltaPocMsbCycleLt[32]; u32 num_long_term_sps = 0; - u32 num_long_term_pics = 0; + u32 num_long_term_pics = 0; if (sps->num_long_term_ref_pic_sps > 0 ) { num_long_term_sps = bs_get_ue(bs); } num_long_term_pics = bs_get_ue(bs); - for (i = 0; i < num_long_term_sps + num_long_term_pics; i++ ) { - if( i < num_long_term_sps ) { - u8 lt_idx_sps = 0; - if (sps->num_long_term_ref_pic_sps > 1) - lt_idx_sps = gf_bs_read_int(bs, gf_get_bit_size(sps->num_long_term_ref_pic_sps) ); - } else { - /*PocLsbLt[ i ] = */ gf_bs_read_int(bs, sps->log2_max_pic_order_cnt_lsb); - /*UsedByCurrPicLt[ i ] = */ gf_bs_read_int(bs, 1); - } - if (/*delta_poc_msb_present_flag[ i ] = */ gf_bs_read_int(bs, 1) ) { - if( i == 0 || i == num_long_term_sps ) - DeltaPocMsbCycleLt[i] = bs_get_ue(bs); - else - DeltaPocMsbCycleLt[i] = bs_get_ue(bs) + DeltaPocMsbCycleLt[i-1]; + for (i = 0; i < num_long_term_sps + num_long_term_pics; i++ ) { + if( i < num_long_term_sps ) { + u8 lt_idx_sps = 0; + if (sps->num_long_term_ref_pic_sps > 1) + lt_idx_sps = gf_bs_read_int(bs, gf_get_bit_size(sps->num_long_term_ref_pic_sps) ); + } else { + /*PocLsbLt[ i ] = */ gf_bs_read_int(bs, sps->log2_max_pic_order_cnt_lsb); + /*UsedByCurrPicLt[ i ] = */ gf_bs_read_int(bs, 1); + } + if (/*delta_poc_msb_present_flag[ i ] = */ gf_bs_read_int(bs, 1) ) { + if( i == 0 || i == num_long_term_sps ) + DeltaPocMsbCycleLt[i] = bs_get_ue(bs); + else + DeltaPocMsbCycleLt[i] = bs_get_ue(bs) + DeltaPocMsbCycleLt[i-1]; } - } + } } - if (sps->temporal_mvp_enable_flag) - slice_temporal_mvp_enabled_flag = gf_bs_read_int(bs, 1); + if (sps->temporal_mvp_enable_flag) + slice_temporal_mvp_enabled_flag = gf_bs_read_int(bs, 1); } - if (sps->sample_adaptive_offset_enabled_flag) { - slice_sao_luma_flag = gf_bs_read_int(bs, 1); + if (sps->sample_adaptive_offset_enabled_flag) { + slice_sao_luma_flag = gf_bs_read_int(bs, 1); slice_sao_chroma_flag = gf_bs_read_int(bs, 1); - } + } if (si->slice_type == GF_HEVC_TYPE_P || si->slice_type == GF_HEVC_TYPE_B) { - //u32 NumPocTotalCurr; + //u32 NumPocTotalCurr; u32 num_ref_idx_l0_active, num_ref_idx_l1_active; num_ref_idx_l0_active = pps->num_ref_idx_l0_default_active; num_ref_idx_l1_active = 0; if (si->slice_type == GF_HEVC_TYPE_B) - num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active; + num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active; if ( /*num_ref_idx_active_override_flag =*/gf_bs_read_int(bs, 1) ) { num_ref_idx_l0_active = 1 + bs_get_ue(bs); @@ -3149,7 +3376,7 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice } // if (pps->lists_modification_present_flag && NumPocTotalCurr > 1) { - if (pps->lists_modification_present_flag ) { + if (pps->lists_modification_present_flag ) { GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[hehv] ref_pic_lists_modification( ) not implemented\n")); return 0; } @@ -3163,17 +3390,17 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice Bool collocated_from_l0_flag = 0; if (si->slice_type == GF_HEVC_TYPE_B) collocated_from_l0_flag = gf_bs_read_int(bs, 1); - - if ( (collocated_from_l0_flag && num_ref_idx_l0_active-1 > 0 ) - || ( !collocated_from_l0_flag && num_ref_idx_l1_active-1 > 0 ) - ) { + + if ( (collocated_from_l0_flag && num_ref_idx_l0_active-1 > 0 ) + || ( !collocated_from_l0_flag && num_ref_idx_l1_active-1 > 0 ) + ) { /*collocated_ref_idx=*/bs_get_ue(bs); } } - if ( (pps->weighted_pred_flag && si->slice_type == GF_HEVC_TYPE_P ) - || ( pps->weighted_bipred_flag && si->slice_type == GF_HEVC_TYPE_B) - ) { + if ( (pps->weighted_pred_flag && si->slice_type == GF_HEVC_TYPE_P ) + || ( pps->weighted_bipred_flag && si->slice_type == GF_HEVC_TYPE_B) + ) { GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[hehv] pred_weight_table not implemented\n")); return 0; } @@ -3196,8 +3423,8 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice } } if( pps->loop_filter_across_slices_enabled_flag - && ( slice_sao_luma_flag || slice_sao_chroma_flag || !slice_deblocking_filter_disabled_flag ) - ) { + && ( slice_sao_luma_flag || slice_sao_chroma_flag || !slice_deblocking_filter_disabled_flag ) + ) { /*slice_loop_filter_across_slices_enabled_flag = */gf_bs_read_int(bs, 1); } } @@ -3206,22 +3433,22 @@ static s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSlice if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag ) { u32 num_entry_point_offsets = bs_get_ue(bs); if ( num_entry_point_offsets > 0) { - u32 offset = bs_get_ue(bs) + 1; - u32 segments = offset >> 4; - s32 remain = (offset & 15); + u32 offset = bs_get_ue(bs) + 1; + u32 segments = offset >> 4; + s32 remain = (offset & 15); for (i=0; ipoc_msb_prev = 0; break; } - + if ((si->poc_lsb < si->poc_lsb_prev) && ( si->poc_lsb_prev - si->poc_lsb >= max_poc_lsb / 2) ) si->poc_msb = si->poc_msb_prev + max_poc_lsb; else if ((si->poc_lsb > si->poc_lsb_prev) && (si->poc_lsb - si->poc_lsb_prev > max_poc_lsb / 2)) @@ -3276,7 +3503,7 @@ void profile_tier_level(GF_BitStream *bs, Bool ProfilePresentFlag, u8 MaxNumSubL } ptl->level_idc = gf_bs_read_int(bs, 8); for (i=0; isub_ptl[i].profile_present_flag = gf_bs_read_int(bs, 1); + ptl->sub_ptl[i].profile_present_flag = gf_bs_read_int(bs, 1); ptl->sub_ptl[i].level_present_flag = gf_bs_read_int(bs, 1); } if (MaxNumSubLayersMinus1>0) { @@ -3300,11 +3527,11 @@ void profile_tier_level(GF_BitStream *bs, Bool ProfilePresentFlag, u8 MaxNumSubL static u32 scalability_type_to_idx(HEVC_VPS *vps, u32 scalability_type) { - u32 idx = 0, type; - for (type=0; type < scalability_type; type++) { - idx += (vps->scalability_mask[type] ? 1 : 0 ); - } - return idx; + u32 idx = 0, type; + for (type=0; type < scalability_type; type++) { + idx += (vps->scalability_mask[type] ? 1 : 0 ); + } + return idx; } #define SHVC_VIEW_ORDER_INDEX 1 @@ -3313,26 +3540,26 @@ static u32 scalability_type_to_idx(HEVC_VPS *vps, u32 scalability_type) static u32 shvc_get_scalability_id(HEVC_VPS *vps, u32 layer_id_in_vps, u32 scalability_type ) { u32 idx; - if (!vps->scalability_mask[scalability_type]) return 0; + if (!vps->scalability_mask[scalability_type]) return 0; idx = scalability_type_to_idx(vps, scalability_type); return vps->dimension_id[layer_id_in_vps][idx]; } static u32 shvc_get_view_index(HEVC_VPS *vps, u32 id) { - return shvc_get_scalability_id(vps, vps->layer_id_in_vps[id], SHVC_VIEW_ORDER_INDEX); + return shvc_get_scalability_id(vps, vps->layer_id_in_vps[id], SHVC_VIEW_ORDER_INDEX); } static u32 shvc_get_num_views(HEVC_VPS *vps) { - u32 numViews = 1, i; + u32 numViews = 1, i; for (i=0; imax_layers; i++ ) { - u32 layer_id = vps->layer_id_in_nuh[i]; - if (i>0 && ( shvc_get_view_index( vps, layer_id) != shvc_get_scalability_id( vps, i-1, SHVC_VIEW_ORDER_INDEX) )) { - numViews++; - } - } - return numViews; + u32 layer_id = vps->layer_id_in_nuh[i]; + if (i>0 && ( shvc_get_view_index( vps, layer_id) != shvc_get_scalability_id( vps, i-1, SHVC_VIEW_ORDER_INDEX) )) { + numViews++; + } + } + return numViews; } static void shvc_parse_rep_format(HEVC_RepFormat *fmt, GF_BitStream *bs) @@ -3340,9 +3567,9 @@ static void shvc_parse_rep_format(HEVC_RepFormat *fmt, GF_BitStream *bs) u8 chroma_bitdepth_present_flag = gf_bs_read_int(bs, 1); fmt->pic_width_luma_samples = gf_bs_read_int(bs, 16); fmt->pic_height_luma_samples = gf_bs_read_int(bs, 16); - if (chroma_bitdepth_present_flag) { + if (chroma_bitdepth_present_flag) { fmt->chroma_format_idc = gf_bs_read_int(bs, 2); - + if (fmt->chroma_format_idc == 3) fmt->separate_colour_plane_flag = gf_bs_read_int(bs, 1); fmt->bit_depth_luma = 1 + gf_bs_read_int(bs, 4); @@ -3370,16 +3597,16 @@ static void hevc_parse_vps_extension(HEVC_VPS *vps, GF_BitStream *bs) dimension_id_len[i] = 1 + gf_bs_read_int(bs, 3); } - vps->layer_id_in_nuh[0] = 0; - vps->layer_id_in_vps[0] = 0; + vps->layer_id_in_nuh[0] = 0; + vps->layer_id_in_vps[0] = 0; vps_nuh_layer_id_present_flag = gf_bs_read_int(bs, 1); for (i=1; imax_layers; i++) { if (vps_nuh_layer_id_present_flag) { vps->layer_id_in_nuh[i] = gf_bs_read_int(bs, 6); } else { - vps->layer_id_in_nuh[i] = i; + vps->layer_id_in_nuh[i] = i; } - vps->layer_id_in_vps[vps->layer_id_in_nuh[i]] = i; + vps->layer_id_in_vps[vps->layer_id_in_nuh[i]] = i; if (!splitting_flag) { for (j=0; jmax_layers; i++) { for (j=0; jprofile_ref[i] = */gf_bs_read_int(bs, 6); + /*vps->profile_ref[i] = */gf_bs_read_int(bs, 6); } profile_tier_level(bs, vps_profile_present_flag, vps->max_sub_layers-1, &vps->ext_ptl[i-1] ); } @@ -3430,22 +3657,22 @@ static void hevc_parse_vps_extension(HEVC_VPS *vps, GF_BitStream *bs) num_add_output_layer_sets = gf_bs_read_int(bs, 10)+1; NumOutputLayerSets += num_add_output_layer_sets; } - + /*default_one_target_output_layer_flag = 0;*/ if (NumOutputLayerSets > 1) { /*default_one_target_output_layer_flag = */gf_bs_read_int(bs, 1); } vps->profile_level_tier_idx[0] = 0; - for (i=1; i vps->num_layer_sets - 1) { GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] VPS Extensions: not supported number of layers\n")); - } - nb_bits = 1; - while ((u32) (1 << nb_bits) < num_profile_tier_level) { - nb_bits++; - } - vps->profile_level_tier_idx[i] = gf_bs_read_int(bs, nb_bits); + } + nb_bits = 1; + while ((u32) (1 << nb_bits) < num_profile_tier_level) { + nb_bits++; + } + vps->profile_level_tier_idx[i] = gf_bs_read_int(bs, nb_bits); } if (vps->max_layers - 1 > 0 ) @@ -3455,23 +3682,23 @@ static void hevc_parse_vps_extension(HEVC_VPS *vps, GF_BitStream *bs) if (rep_format_idx_present_flag ) { vps->num_rep_formats = 1 + gf_bs_read_int(bs, 8); } else { - vps->num_rep_formats = vps->max_layers; + vps->num_rep_formats = vps->max_layers; } for (i=0; inum_rep_formats; i++) { shvc_parse_rep_format(&vps->rep_formats[i], bs); } - vps->rep_format_idx[0] = 0; - for (i=1; imax_layers; i++) { - if (rep_format_idx_present_flag) { + vps->rep_format_idx[0] = 0; + for (i=1; imax_layers; i++) { + if (rep_format_idx_present_flag) { if (vps->num_rep_formats > 1) { vps->rep_format_idx[i] = gf_bs_read_int(bs, 8); } else { - vps->rep_format_idx[i] = 0; + vps->rep_format_idx[i] = 0; } } else { - vps->rep_format_idx[i] = i; + vps->rep_format_idx[i] = i; } - } + } //TODO - we don't use the rest ... } @@ -3492,7 +3719,7 @@ s32 gf_media_hevc_read_vps(char *data, u32 size, HEVCState *hevc) data_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size); bs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ); if (!bs) goto exit; - + gf_bs_read_u16(bs); vps_id = gf_bs_read_int(bs, 4); @@ -3520,7 +3747,7 @@ s32 gf_media_hevc_read_vps(char *data, u32 size, HEVCState *hevc) } vps->max_layer_id = gf_bs_read_int(bs, 6); vps->num_layer_sets = bs_get_ue(bs) + 1; - for (i=1; i < vps->num_layer_sets; i++) { + for (i=1; i < vps->num_layer_sets; i++) { for (j=0; j <= vps->max_layer_id; j++) { /*layer_id_included_flag[ i ][ j ]*/gf_bs_read_int(bs, 1); } @@ -3554,7 +3781,9 @@ exit: return vps_id; } -static const struct { u32 w, h; } hevc_sar[17] = +static const struct { + u32 w, h; +} hevc_sar[17] = { { 0, 0 }, { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 }, { 40, 33 }, { 24, 11 }, { 20, 11 }, @@ -3586,7 +3815,7 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 data_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size); bs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ); if (!bs) goto exit; - + gf_bs_read_int(bs, 7); layer_id = gf_bs_read_int(bs, 6); /*temporal_id = */gf_bs_read_int(bs, 3); @@ -3597,7 +3826,7 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 } memset(&ptl, 0, sizeof(ptl)); - max_sub_layers_minus1 = 0; + max_sub_layers_minus1 = 0; if (layer_id == 0) { max_sub_layers_minus1 = gf_bs_read_int(bs, 3); /*temporal_id_nesting_flag = */gf_bs_read_int(bs, 1); @@ -3646,10 +3875,25 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 } if (gf_bs_read_int(bs, 1)) { + u32 SubWidthC, SubHeightC; + SubWidthC = SubHeightC = 1; + if (sps->chroma_format_idc==1) { + SubWidthC = SubHeightC = 2; + } + else if (sps->chroma_format_idc==2) { + SubWidthC = 2; + SubHeightC = 1; + } else { + SubWidthC = SubHeightC = 1; + } + sps->cw_left = bs_get_ue(bs); sps->cw_right = bs_get_ue(bs); sps->cw_top = bs_get_ue(bs); sps->cw_bottom = bs_get_ue(bs); + + sps->width -= SubWidthC * (sps->cw_left + sps->cw_right); + sps->height -= SubHeightC * (sps->cw_top + sps->cw_bottom); } if (layer_id == 0) { sps->bit_depth_luma = 8 + bs_get_ue(bs); @@ -3682,7 +3926,7 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 { depth++; } - sps->max_CU_depth = log2_diff_max_min_luma_coding_block_size + depth; + sps->max_CU_depth = log2_diff_max_min_luma_coding_block_size + depth; nb_CTUs = ((sps->width + sps->max_CU_width -1) / sps->max_CU_width) * ((sps->height + sps->max_CU_height-1) / sps->max_CU_height); sps->bitsSliceSegmentAddress = 0; @@ -3691,7 +3935,7 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 } scaling_list_enable_flag = gf_bs_read_int(bs, 1); - if (scaling_list_enable_flag) { + if (scaling_list_enable_flag) { Bool sps_infer_scaling_list_flag = 0; /*u8 sps_scaling_list_ref_layer_id = 0;*/ if (layer_id>0) { @@ -3716,8 +3960,8 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 /*pcm_loop_filter_disable_flag=*/gf_bs_read_int(bs, 1); } sps->num_short_term_ref_pic_sets = bs_get_ue(bs); - for (i=0;inum_short_term_ref_pic_sets; i++) { - Bool ret = parse_short_term_ref_pic_set(bs, sps, i); + for (i=0; inum_short_term_ref_pic_sets; i++) { + Bool ret = parse_short_term_ref_pic_set(bs, sps, i); /*cannot parse short_term_ref_pic_set, skip VUI parsing*/ if (!ret) goto exit; } @@ -3731,12 +3975,12 @@ static s32 gf_media_hevc_read_sps_ex(char *data, u32 size, HEVCState *hevc, u32 sps->temporal_mvp_enable_flag = gf_bs_read_int(bs, 1); /*strong_intra_smoothing_enable_flag*/gf_bs_read_int(bs, 1); - if (vui_flag_pos) + if (vui_flag_pos) *vui_flag_pos = (u32) gf_bs_get_bit_offset(bs); /*fixme - move to latest syntax*/ if (layer_id>0) goto exit; - + if (/*vui_parameters_present_flag*/gf_bs_read_int(bs, 1)) { sps->aspect_ratio_info_present_flag = gf_bs_read_int(bs, 1); @@ -3841,14 +4085,14 @@ s32 gf_media_hevc_read_pps(char *data, u32 size, HEVCState *hevc) data_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size); bs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ); if (!bs) goto exit; - + gf_bs_read_u16(bs); pps_id = bs_get_ue(bs); if (pps_id>=64) goto exit; pps = &hevc->pps[pps_id]; - + if (!pps->state) { pps->id = pps_id; pps->state = 1; @@ -3882,11 +4126,11 @@ s32 gf_media_hevc_read_pps(char *data, u32 size, HEVCState *hevc) pps->num_tile_rows = 1 + bs_get_ue(bs); pps->uniform_spacing_flag = gf_bs_read_int(bs, 1); if (!pps->uniform_spacing_flag ) { - for (i=0; inum_tile_columns; i++) { + for (i=0; inum_tile_columns-1; i++) { pps->column_width[i] = 1 + bs_get_ue(bs); } - for (i=0; inum_tile_rows; i++) { - pps->row_height[i] = bs_get_ue(bs); + for (i=0; inum_tile_rows-1; i++) { + pps->row_height[i] = 1+bs_get_ue(bs); } } pps->loop_filter_across_tiles_enabled_flag = gf_bs_read_int(bs, 1); @@ -3920,6 +4164,7 @@ exit: } +GF_EXPORT s32 gf_media_hevc_parse_nalu(GF_BitStream *bs, HEVCState *hevc, u8 *nal_unit_type, u8 *temporal_id, u8 *layer_id) { u32 reserved; @@ -3981,7 +4226,7 @@ s32 gf_media_hevc_parse_nalu(GF_BitStream *bs, HEVCState *hevc, u8 *nal_unit_typ if (ret<0) return ret; hevc_compute_poc(&n_state); - + ret = 0; if (hevc->s_info.poc != n_state.poc) { @@ -3995,7 +4240,7 @@ s32 gf_media_hevc_parse_nalu(GF_BitStream *bs, HEVCState *hevc, u8 *nal_unit_typ return 0; default: break; - } + } /* save _prev values */ if (ret && hevc->s_info.sps) { @@ -4037,7 +4282,7 @@ GF_Err gf_media_hevc_change_par(GF_HEVCConfig *hvcc, s32 ar_n, s32 ar_d) i=0; spss = NULL; while ((spss = (GF_HEVCParamArray *)gf_list_enum(hvcc->param_array, &i))) { - if (spss->type==GF_HEVC_NALU_SEQ_PARAM) + if (spss->type==GF_HEVC_NALU_SEQ_PARAM) break; spss = NULL; } @@ -4196,27 +4441,27 @@ static Bool AC3_FindSyncCodeBS(GF_BitStream *bs) } static const u32 ac3_sizecod_to_bitrate[] = { - 32000, 40000, 48000, 56000, 64000, 80000, 96000, - 112000, 128000, 160000, 192000, 224000, 256000, - 320000, 384000, 448000, 512000, 576000, 640000 + 32000, 40000, 48000, 56000, 64000, 80000, 96000, + 112000, 128000, 160000, 192000, 224000, 256000, + 320000, 384000, 448000, 512000, 576000, 640000 }; static const u32 ac3_sizecod2_to_framesize[] = { - 96, 120, 144, 168, 192, 240, 288, 336, 384, 480, 576, 672, - 768, 960, 1152, 1344, 1536, 1728, 1920 + 96, 120, 144, 168, 192, 240, 288, 336, 384, 480, 576, 672, + 768, 960, 1152, 1344, 1536, 1728, 1920 }; static const u32 ac3_sizecod1_to_framesize[] = { - 69, 87, 104, 121, 139, 174, 208, 243, 278, 348, 417, 487, - 557, 696, 835, 975, 1114, 1253, 1393 + 69, 87, 104, 121, 139, 174, 208, 243, 278, 348, 417, 487, + 557, 696, 835, 975, 1114, 1253, 1393 }; static const u32 ac3_sizecod0_to_framesize[] = { - 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, - 512, 640, 768, 896, 1024, 1152, 1280 + 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, + 512, 640, 768, 896, 1024, 1152, 1280 }; static const u32 ac3_mod_to_chans[] = { - 2, 1, 2, 3, 3, 4, 4, 5 + 2, 1, 2, 3, 3, 4, 4, 5 }; GF_EXPORT @@ -4248,7 +4493,7 @@ Bool gf_ac3_parser(u8 *buf, u32 buflen, u32 *pos, GF_AC3Header *hdr, Bool full_p if (bsid >= 12) return 0; if (full_parse && hdr) memset(hdr, 0, sizeof(GF_AC3Header)); - + if (hdr) { hdr->bitrate = ac3_sizecod_to_bitrate[frmsizecod / 2]; if (bsid > 8) hdr->bitrate = hdr->bitrate >> (bsid - 8); @@ -4305,7 +4550,7 @@ Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse) if (bsid >= 12) return 0; //memset(hdr, 0, sizeof(GF_AC3Header)); - + hdr->bitrate = ac3_sizecod_to_bitrate[frmsizecod / 2]; if (bsid > 8) hdr->bitrate = hdr->bitrate >> (bsid - 8); @@ -4368,12 +4613,12 @@ static u32 vorbis_book_maptype1_quantvals(u32 entries, u32 dim) u32 acc=1; u32 acc1=1; u32 i; - for (i=0;ientries) return (vals); - else { + else { if (acc>entries) vals--; else vals++; } @@ -4392,7 +4637,7 @@ u32 _ilog_(u32 v) static u32 ilog(u32 v) { - u32 ret=0; + u32 ret=0; if(v) --v; while(v) { ret++; @@ -4422,7 +4667,10 @@ Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len) oggpack_readinit(&opb, (u8*)data, data_len); pack_type = oggpack_read(&opb, 8); i=0; - while (i<6) { szNAME[i] = oggpack_read(&opb, 8); i++;} + while (i<6) { + szNAME[i] = oggpack_read(&opb, 8); + i++; + } szNAME[i] = 0; if (strcmp(szNAME, "vorbis")) return vp->is_init = 0; @@ -4475,7 +4723,7 @@ Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len) } } } else { - for (j=0; jchannels)); oggpack_read(&opb, ilog(vp->channels)); } @@ -4571,7 +4820,7 @@ Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len) if (sub_maps>1) { for(j=0; jchannels; j++) oggpack_read(&opb, 4); } - for (j=0;j> 8)&0xff; - dst[2] = (n>>16)&0xff; - dst[3] = (n>>24)&0xff; + dst[0] = (n )&0xff; + dst[1] = (n>> 8)&0xff; + dst[2] = (n>>16)&0xff; + dst[3] = (n>>24)&0xff; } #ifdef WORDS_BIGENDIAN static void short2str(unsigned char *dst, s32 n) { - dst[0] = (n )&0xff; - dst[1] = (n>> 8)&0xff; + dst[0] = (n )&0xff; + dst[1] = (n>> 8)&0xff; } #endif @@ -130,38 +130,38 @@ static void short2str(unsigned char *dst, s32 n) static u64 str2ullong(unsigned char *str) { - u64 r = (str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24)); - u64 s = (str[4] | (str[5]<<8) | (str[6]<<16) | (str[7]<<24)); + u64 r = (str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24)); + u64 s = (str[4] | (str[5]<<8) | (str[6]<<16) | (str[7]<<24)); #ifdef __GNUC__ - return ((s<<32)&0xffffffff00000000ULL)|(r&0xffffffff); + return ((s<<32)&0xffffffff00000000ULL)|(r&0xffffffff); #else - return ((s<<32)&0xffffffff00000000)|(r&0xffffffff); + return ((s<<32)&0xffffffff00000000)|(r&0xffffffff); #endif } static u32 str2ulong(unsigned char *str) { - return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) ); + return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) ); } static u32 str2ushort(unsigned char *str) { - return ( str[0] | (str[1]<<8) ); + return ( str[0] | (str[1]<<8) ); } // bit 31 denotes a keyframe static u32 str2ulong_len (unsigned char *str) { - return str2ulong(str) & 0x7fffffff; + return str2ulong(str) & 0x7fffffff; } // if bit 31 is 0, its a keyframe static u32 str2ulong_key (unsigned char *str) { - u32 c = str2ulong(str); - c &= 0x80000000; - if (c == 0) return 0x10; - else return 0; + u32 c = str2ulong(str); + c &= 0x80000000; + if (c == 0) return 0x10; + else return 0; } /* Calculate audio sample size from number of bits and number of channels. @@ -169,11 +169,11 @@ static u32 str2ulong_key (unsigned char *str) static int avi_sampsize(avi_t *AVI, int j) { - int s; - s = ((AVI->track[j].a_bits+7)/8)*AVI->track[j].a_chans; - // if(s==0) s=1; /* avoid possible zero divisions */ - if(s<4) s=4; /* avoid possible zero divisions */ - return s; + int s; + s = ((AVI->track[j].a_bits+7)/8)*AVI->track[j].a_chans; + // if(s==0) s=1; /* avoid possible zero divisions */ + if(s<4) s=4; /* avoid possible zero divisions */ + return s; } /* Add a chunk (=tag and data) to the AVI file, @@ -181,34 +181,34 @@ static int avi_sampsize(avi_t *AVI, int j) static int avi_add_chunk(avi_t *AVI, unsigned char *tag, unsigned char *data, u32 length) { - unsigned char c[8]; - char p=0; + unsigned char c[8]; + char p=0; - /* Copy tag and length int c, so that we need only 1 write system call - for these two values */ + /* Copy tag and length int c, so that we need only 1 write system call + for these two values */ - memcpy(c,tag,4); - long2str(c+4,length); + memcpy(c,tag,4); + long2str(c+4,length); - /* Output tag, length and data, restore previous position - if the write fails */ + /* Output tag, length and data, restore previous position + if the write fails */ - if( avi_write(AVI->fdes,(char *)c,8) != 8 || - avi_write(AVI->fdes,(char *)data,length) != length || - avi_write(AVI->fdes,&p,length&1) != (length&1)) // if len is uneven, write a pad byte - { - gf_f64_seek(AVI->fdes,AVI->pos,SEEK_SET); - AVI_errno = AVI_ERR_WRITE; - return -1; - } + if( avi_write(AVI->fdes,(char *)c,8) != 8 || + avi_write(AVI->fdes,(char *)data,length) != length || + avi_write(AVI->fdes,&p,length&1) != (length&1)) // if len is uneven, write a pad byte + { + gf_f64_seek(AVI->fdes,AVI->pos,SEEK_SET); + AVI_errno = AVI_ERR_WRITE; + return -1; + } - /* Update file position */ + /* Update file position */ - AVI->pos += 8 + PAD_EVEN(length); + AVI->pos += 8 + PAD_EVEN(length); - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu %s\n", AVI->pos, tag)); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu %s\n", AVI->pos, tag)); - return 0; + return 0; } #define OUTD(n) long2str((unsigned char*) (ix00+bl),(s32)n); bl+=4 @@ -219,47 +219,47 @@ static int avi_add_chunk(avi_t *AVI, unsigned char *tag, unsigned char *data, u3 // this does the physical writeout of the ix## structure static int avi_ixnn_entry(avi_t *AVI, avistdindex_chunk *ch, avisuperindex_entry *en) { - int bl; + int bl; u32 k; - unsigned int max = ch->nEntriesInUse * sizeof (u32) * ch->wLongsPerEntry + 24; // header - char *ix00 = (char *)gf_malloc (max); - char dfcc[5]; - memcpy (dfcc, ch->fcc, 4); - dfcc[4] = 0; - - bl = 0; - - if (en) { - en->qwOffset = AVI->pos; - en->dwSize = max; - //en->dwDuration = ch->nEntriesInUse -1; // NUMBER OF stream ticks == frames for video/samples for audio - } + unsigned int max = ch->nEntriesInUse * sizeof (u32) * ch->wLongsPerEntry + 24; // header + char *ix00 = (char *)gf_malloc (max); + char dfcc[5]; + memcpy (dfcc, ch->fcc, 4); + dfcc[4] = 0; + + bl = 0; + + if (en) { + en->qwOffset = AVI->pos; + en->dwSize = max; + //en->dwDuration = ch->nEntriesInUse -1; // NUMBER OF stream ticks == frames for video/samples for audio + } #ifdef DEBUG_ODML - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML Write %s: Entries %ld size %d \n", dfcc, ch->nEntriesInUse, max)); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML Write %s: Entries %ld size %d \n", dfcc, ch->nEntriesInUse, max)); #endif - //OUTS(ch->fcc); - //OUTD(max); - OUTW(ch->wLongsPerEntry); - OUTC(ch->bIndexSubType); - OUTC(ch->bIndexType); - OUTD(ch->nEntriesInUse); - OUTS(ch->dwChunkId); - OUTD(ch->qwBaseOffset&0xffffffff); - OUTD((ch->qwBaseOffset>>32)&0xffffffff); - OUTD(ch->dwReserved3); - - for (k = 0; k < ch->nEntriesInUse; k++) { - OUTD(ch->aIndex[k].dwOffset); - OUTD(ch->aIndex[k].dwSize); + //OUTS(ch->fcc); + //OUTD(max); + OUTW(ch->wLongsPerEntry); + OUTC(ch->bIndexSubType); + OUTC(ch->bIndexType); + OUTD(ch->nEntriesInUse); + OUTS(ch->dwChunkId); + OUTD(ch->qwBaseOffset&0xffffffff); + OUTD((ch->qwBaseOffset>>32)&0xffffffff); + OUTD(ch->dwReserved3); + + for (k = 0; k < ch->nEntriesInUse; k++) { + OUTD(ch->aIndex[k].dwOffset); + OUTD(ch->aIndex[k].dwSize); - } - avi_add_chunk (AVI, (unsigned char*)ch->fcc, (unsigned char*)ix00, max); + } + avi_add_chunk (AVI, (unsigned char*)ch->fcc, (unsigned char*)ix00, max); - gf_free(ix00); + gf_free(ix00); - return 0; + return 0; } #undef OUTS #undef OUTW @@ -269,329 +269,339 @@ static int avi_ixnn_entry(avi_t *AVI, avistdindex_chunk *ch, avisuperindex_entry // inits a super index structure including its enclosed stdindex static int avi_init_super_index(avi_t *AVI, unsigned char *idxtag, avisuperindex_chunk **si) { - int k; - - avisuperindex_chunk *sil = NULL; - - if ((sil = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk))) == NULL) { - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } - memcpy (sil->fcc, "indx", 4); - sil->dwSize = 0; // size of this chunk - sil->wLongsPerEntry = 4; - sil->bIndexSubType = 0; - sil->bIndexType = AVI_INDEX_OF_INDEXES; - sil->nEntriesInUse = 0; // none are in use - memcpy (sil->dwChunkId, idxtag, 4); - memset (sil->dwReserved, 0, sizeof (sil->dwReserved)); - - // NR_IXNN_CHUNKS == allow 32 indices which means 32 GB files -- arbitrary - sil->aIndex = (avisuperindex_entry *) gf_malloc (sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (void*)); - if (!sil->aIndex) { - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } - memset (sil->aIndex, 0, sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (u32)); - - sil->stdindex = (avistdindex_chunk **)gf_malloc (NR_IXNN_CHUNKS * sizeof (avistdindex_chunk *)); - if (!sil->stdindex) { - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } - for (k = 0; k < NR_IXNN_CHUNKS; k++) { - sil->stdindex[k] = (avistdindex_chunk *) gf_malloc (sizeof (avistdindex_chunk)); - // gets rewritten later - sil->stdindex[k]->qwBaseOffset = (u64)k * NEW_RIFF_THRES; - sil->stdindex[k]->aIndex = NULL; - } - - *si = sil; - - return 0; + int k; + + avisuperindex_chunk *sil = NULL; + + if ((sil = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk))) == NULL) { + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } + memcpy (sil->fcc, "indx", 4); + sil->dwSize = 0; // size of this chunk + sil->wLongsPerEntry = 4; + sil->bIndexSubType = 0; + sil->bIndexType = AVI_INDEX_OF_INDEXES; + sil->nEntriesInUse = 0; // none are in use + memcpy (sil->dwChunkId, idxtag, 4); + memset (sil->dwReserved, 0, sizeof (sil->dwReserved)); + + // NR_IXNN_CHUNKS == allow 32 indices which means 32 GB files -- arbitrary + sil->aIndex = (avisuperindex_entry *) gf_malloc (sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (void*)); + if (!sil->aIndex) { + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } + memset (sil->aIndex, 0, sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (u32)); + + sil->stdindex = (avistdindex_chunk **)gf_malloc (NR_IXNN_CHUNKS * sizeof (avistdindex_chunk *)); + if (!sil->stdindex) { + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } + for (k = 0; k < NR_IXNN_CHUNKS; k++) { + sil->stdindex[k] = (avistdindex_chunk *) gf_malloc (sizeof (avistdindex_chunk)); + // gets rewritten later + sil->stdindex[k]->qwBaseOffset = (u64)k * NEW_RIFF_THRES; + sil->stdindex[k]->aIndex = NULL; + } + + *si = sil; + + return 0; } // fills an alloc'ed stdindex structure and mallocs some entries for the actual chunks static int avi_add_std_index(avi_t *AVI, unsigned char *idxtag, unsigned char *strtag, - avistdindex_chunk *stdil) + avistdindex_chunk *stdil) { - memcpy (stdil->fcc, idxtag, 4); - stdil->dwSize = 4096; - stdil->wLongsPerEntry = 2; //sizeof(avistdindex_entry)/sizeof(u32); - stdil->bIndexSubType = 0; - stdil->bIndexType = AVI_INDEX_OF_CHUNKS; - stdil->nEntriesInUse = 0; + memcpy (stdil->fcc, idxtag, 4); + stdil->dwSize = 4096; + stdil->wLongsPerEntry = 2; //sizeof(avistdindex_entry)/sizeof(u32); + stdil->bIndexSubType = 0; + stdil->bIndexType = AVI_INDEX_OF_CHUNKS; + stdil->nEntriesInUse = 0; - // cp 00db ChunkId - memcpy(stdil->dwChunkId, strtag, 4); + // cp 00db ChunkId + memcpy(stdil->dwChunkId, strtag, 4); - //stdil->qwBaseOffset = AVI->video_superindex->aIndex[ cur_std_idx ]->qwOffset; + //stdil->qwBaseOffset = AVI->video_superindex->aIndex[ cur_std_idx ]->qwOffset; - stdil->aIndex = (avistdindex_entry *)gf_malloc(stdil->dwSize * sizeof (u32) * stdil->wLongsPerEntry); + stdil->aIndex = (avistdindex_entry *)gf_malloc(stdil->dwSize * sizeof (u32) * stdil->wLongsPerEntry); - if (!stdil->aIndex) { - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } + if (!stdil->aIndex) { + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } - return 0; + return 0; } static int avi_add_odml_index_entry_core(avi_t *AVI, long flags, u64 pos, unsigned long len, avistdindex_chunk *si) { - u32 cur_chunk_idx; - // put new chunk into index - si->nEntriesInUse++; - cur_chunk_idx = si->nEntriesInUse-1; + u32 cur_chunk_idx; + // put new chunk into index + si->nEntriesInUse++; + cur_chunk_idx = si->nEntriesInUse-1; - // need to fetch more memory - if (cur_chunk_idx >= si->dwSize) { - si->dwSize += 4096; - si->aIndex = (avistdindex_entry *)gf_realloc ( si->aIndex, si->dwSize * sizeof (u32) * si->wLongsPerEntry); - } + // need to fetch more memory + if (cur_chunk_idx >= si->dwSize) { + si->dwSize += 4096; + si->aIndex = (avistdindex_entry *)gf_realloc ( si->aIndex, si->dwSize * sizeof (u32) * si->wLongsPerEntry); + } - if(len>AVI->max_len) AVI->max_len=len; + if(len>AVI->max_len) AVI->max_len=len; - // if bit 31 is set, it is NOT a keyframe - if (flags != 0x10) { - len |= 0x80000000; - } + // if bit 31 is set, it is NOT a keyframe + if (flags != 0x10) { + len |= 0x80000000; + } - si->aIndex [ cur_chunk_idx ].dwSize = len; - si->aIndex [ cur_chunk_idx ].dwOffset = (u32) (pos - si->qwBaseOffset + 8); + si->aIndex [ cur_chunk_idx ].dwSize = len; + si->aIndex [ cur_chunk_idx ].dwOffset = (u32) (pos - si->qwBaseOffset + 8); - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: POS: 0x%lX\n", si->aIndex [ cur_chunk_idx ].dwOffset)); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: POS: 0x%lX\n", si->aIndex [ cur_chunk_idx ].dwOffset)); - return 0; + return 0; } static int avi_add_odml_index_entry(avi_t *AVI, unsigned char *tag, long flags, u64 pos, unsigned long len) { - char fcc[5]; + char fcc[5]; - int audio = (strchr ((char*)tag, 'w')?1:0); - int video = !audio; + int audio = (strchr ((char*)tag, 'w')?1:0); + int video = !audio; - unsigned int cur_std_idx; - u32 audtr; - s64 towrite = 0; + unsigned int cur_std_idx; + u32 audtr; + s64 towrite = 0; - if (video) { + if (video) { - if (!AVI->video_superindex) { - if (avi_init_super_index(AVI, (unsigned char *)"ix00", &AVI->video_superindex) < 0) return -1; - AVI->video_superindex->nEntriesInUse++; - cur_std_idx = AVI->video_superindex->nEntriesInUse-1; + if (!AVI->video_superindex) { + if (avi_init_super_index(AVI, (unsigned char *)"ix00", &AVI->video_superindex) < 0) return -1; + AVI->video_superindex->nEntriesInUse++; + cur_std_idx = AVI->video_superindex->nEntriesInUse-1; - if (avi_add_std_index (AVI, (unsigned char *)"ix00", (unsigned char *)"00db", AVI->video_superindex->stdindex[ cur_std_idx ]) < 0) - return -1; - } // init + if (avi_add_std_index (AVI, (unsigned char *)"ix00", (unsigned char *)"00db", AVI->video_superindex->stdindex[ cur_std_idx ]) < 0) + return -1; + } // init - } // video + } // video - if (audio) { + if (audio) { - fcc[0] = 'i'; fcc[1] = 'x'; fcc[2] = tag[0]; fcc[3] = tag[1]; fcc[4] = '\0'; - if (!AVI->track[AVI->aptr].audio_superindex) { + fcc[0] = 'i'; + fcc[1] = 'x'; + fcc[2] = tag[0]; + fcc[3] = tag[1]; + fcc[4] = '\0'; + if (!AVI->track[AVI->aptr].audio_superindex) { #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: fcc = %s\n", fcc)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: fcc = %s\n", fcc)); #endif - if (avi_init_super_index(AVI, (unsigned char *)fcc, &AVI->track[AVI->aptr].audio_superindex) < 0) return -1; + if (avi_init_super_index(AVI, (unsigned char *)fcc, &AVI->track[AVI->aptr].audio_superindex) < 0) return -1; - AVI->track[AVI->aptr].audio_superindex->nEntriesInUse++; + AVI->track[AVI->aptr].audio_superindex->nEntriesInUse++; - sprintf(fcc, "ix%02d", AVI->aptr+1); - if (avi_add_std_index (AVI, (unsigned char *)fcc, tag, AVI->track[AVI->aptr].audio_superindex->stdindex[ - AVI->track[AVI->aptr].audio_superindex->nEntriesInUse - 1 ]) < 0 - ) return -1; - } // init - - } - - towrite = 0; - if (AVI->video_superindex) { - - cur_std_idx = AVI->video_superindex->nEntriesInUse-1; - towrite += AVI->video_superindex->stdindex[cur_std_idx]->nEntriesInUse*8 - + 4+4+2+1+1+4+4+8+4; - if (cur_std_idx == 0) { - towrite += AVI->n_idx*16 + 8; - towrite += HEADERBYTES; - } - } + sprintf(fcc, "ix%02d", AVI->aptr+1); + if (avi_add_std_index (AVI, (unsigned char *)fcc, tag, AVI->track[AVI->aptr].audio_superindex->stdindex[ + AVI->track[AVI->aptr].audio_superindex->nEntriesInUse - 1 ]) < 0 + ) return -1; + } // init - for (audtr=0; audtranum; audtr++) { - if (AVI->track[audtr].audio_superindex) { - cur_std_idx = AVI->track[audtr].audio_superindex->nEntriesInUse-1; - towrite += AVI->track[audtr].audio_superindex->stdindex[cur_std_idx]->nEntriesInUse*8 - + 4+4+2+1+1+4+4+8+4; } - } - towrite += len + (len&1) + 8; - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: towrite = 0x%llX = %"LLD"\n", towrite, towrite)); + towrite = 0; + if (AVI->video_superindex) { - if (AVI->video_superindex && - (s64)(AVI->pos+towrite) > (s64)((s64)NEW_RIFF_THRES*AVI->video_superindex->nEntriesInUse)) { - - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Adding a new RIFF chunk: %d\n", AVI->video_superindex->nEntriesInUse)); - - // rotate ALL indices - AVI->video_superindex->nEntriesInUse++; - cur_std_idx = AVI->video_superindex->nEntriesInUse-1; - - if (AVI->video_superindex->nEntriesInUse > NR_IXNN_CHUNKS) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Internal error in avilib - redefine NR_IXNN_CHUNKS\n")); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] cur_std_idx=%d NR_IXNN_CHUNKS=%d" - "POS=%"LLD" towrite=%"LLD"\n", - cur_std_idx,NR_IXNN_CHUNKS, AVI->pos, towrite)); - return -1; + cur_std_idx = AVI->video_superindex->nEntriesInUse-1; + towrite += AVI->video_superindex->stdindex[cur_std_idx]->nEntriesInUse*8 + + 4+4+2+1+1+4+4+8+4; + if (cur_std_idx == 0) { + towrite += AVI->n_idx*16 + 8; + towrite += HEADERBYTES; + } } - if (avi_add_std_index (AVI, (unsigned char *)"ix00", (unsigned char *)"00db", AVI->video_superindex->stdindex[ cur_std_idx ]) < 0) - return -1; - - for (audtr = 0; audtr < AVI->anum; audtr++) { - char aud[5]; - if (!AVI->track[audtr].audio_superindex) { - // not initialized -> no index - continue; - } - AVI->track[audtr].audio_superindex->nEntriesInUse++; - - sprintf(fcc, "ix%02d", audtr+1); - sprintf(aud, "0%01dwb", audtr+1); - if (avi_add_std_index (AVI, (unsigned char *)fcc, (unsigned char *)aud, AVI->track[audtr].audio_superindex->stdindex[ - AVI->track[audtr].audio_superindex->nEntriesInUse - 1 ]) < 0 - ) return -1; + for (audtr=0; audtranum; audtr++) { + if (AVI->track[audtr].audio_superindex) { + cur_std_idx = AVI->track[audtr].audio_superindex->nEntriesInUse-1; + towrite += AVI->track[audtr].audio_superindex->stdindex[cur_std_idx]->nEntriesInUse*8 + + 4+4+2+1+1+4+4+8+4; + } } + towrite += len + (len&1) + 8; - // write the new riff; - if (cur_std_idx > 0) { + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: towrite = 0x%llX = %"LLD"\n", towrite, towrite)); - // dump the _previous_ == already finished index - avi_ixnn_entry (AVI, AVI->video_superindex->stdindex[cur_std_idx - 1], - &AVI->video_superindex->aIndex[cur_std_idx - 1]); - AVI->video_superindex->aIndex[cur_std_idx - 1].dwDuration = - AVI->video_superindex->stdindex[cur_std_idx - 1]->nEntriesInUse - 1; + if (AVI->video_superindex && + (s64)(AVI->pos+towrite) > (s64)((s64)NEW_RIFF_THRES*AVI->video_superindex->nEntriesInUse)) { - for (audtr = 0; audtr < AVI->anum; audtr++) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Adding a new RIFF chunk: %d\n", AVI->video_superindex->nEntriesInUse)); - if (!AVI->track[audtr].audio_superindex) { - // not initialized -> no index - continue; - } - avi_ixnn_entry (AVI, AVI->track[audtr].audio_superindex->stdindex[cur_std_idx - 1], - &AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1]); - - AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1].dwDuration = - AVI->track[audtr].audio_superindex->stdindex[cur_std_idx - 1]->nEntriesInUse - 1; - if (AVI->track[audtr].a_fmt == 0x1) { - AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1].dwDuration *= - AVI->track[audtr].a_bits*AVI->track[audtr].a_rate*AVI->track[audtr].a_chans/800; + // rotate ALL indices + AVI->video_superindex->nEntriesInUse++; + cur_std_idx = AVI->video_superindex->nEntriesInUse-1; + + if (AVI->video_superindex->nEntriesInUse > NR_IXNN_CHUNKS) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Internal error in avilib - redefine NR_IXNN_CHUNKS\n")); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] cur_std_idx=%d NR_IXNN_CHUNKS=%d" + "POS=%"LLD" towrite=%"LLD"\n", + cur_std_idx,NR_IXNN_CHUNKS, AVI->pos, towrite)); + return -1; } - } - // XXX: dump idx1 structure - if (cur_std_idx == 1) { - avi_add_chunk(AVI, (unsigned char *)"idx1", (unsigned char *)AVI->idx, AVI->n_idx*16); - // qwBaseOffset will contain the start of the second riff chunk - } - // Fix the Offsets later at closing time - avi_add_chunk(AVI, (unsigned char *)"RIFF", (unsigned char *)"AVIXLIST\0\0\0\0movi", 16); + if (avi_add_std_index (AVI, (unsigned char *)"ix00", (unsigned char *)"00db", AVI->video_superindex->stdindex[ cur_std_idx ]) < 0) + return -1; + + for (audtr = 0; audtr < AVI->anum; audtr++) { + char aud[5]; + if (!AVI->track[audtr].audio_superindex) { + // not initialized -> no index + continue; + } + AVI->track[audtr].audio_superindex->nEntriesInUse++; + + sprintf(fcc, "ix%02d", audtr+1); + sprintf(aud, "0%01dwb", audtr+1); + if (avi_add_std_index (AVI, (unsigned char *)fcc, (unsigned char *)aud, AVI->track[audtr].audio_superindex->stdindex[ + AVI->track[audtr].audio_superindex->nEntriesInUse - 1 ]) < 0 + ) return -1; + } - AVI->video_superindex->stdindex[ cur_std_idx ]->qwBaseOffset = AVI->pos -16 -8; + // write the new riff; + if (cur_std_idx > 0) { + + // dump the _previous_ == already finished index + avi_ixnn_entry (AVI, AVI->video_superindex->stdindex[cur_std_idx - 1], + &AVI->video_superindex->aIndex[cur_std_idx - 1]); + AVI->video_superindex->aIndex[cur_std_idx - 1].dwDuration = + AVI->video_superindex->stdindex[cur_std_idx - 1]->nEntriesInUse - 1; + + for (audtr = 0; audtr < AVI->anum; audtr++) { + + if (!AVI->track[audtr].audio_superindex) { + // not initialized -> no index + continue; + } + avi_ixnn_entry (AVI, AVI->track[audtr].audio_superindex->stdindex[cur_std_idx - 1], + &AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1]); + + AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1].dwDuration = + AVI->track[audtr].audio_superindex->stdindex[cur_std_idx - 1]->nEntriesInUse - 1; + if (AVI->track[audtr].a_fmt == 0x1) { + AVI->track[audtr].audio_superindex->aIndex[cur_std_idx - 1].dwDuration *= + AVI->track[audtr].a_bits*AVI->track[audtr].a_rate*AVI->track[audtr].a_chans/800; + } + } + + // XXX: dump idx1 structure + if (cur_std_idx == 1) { + avi_add_chunk(AVI, (unsigned char *)"idx1", (unsigned char *)AVI->idx, AVI->n_idx*16); + // qwBaseOffset will contain the start of the second riff chunk + } + // Fix the Offsets later at closing time + avi_add_chunk(AVI, (unsigned char *)"RIFF", (unsigned char *)"AVIXLIST\0\0\0\0movi", 16); + + AVI->video_superindex->stdindex[ cur_std_idx ]->qwBaseOffset = AVI->pos -16 -8; #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: RIFF No.%02d at Offset 0x%llX\n", cur_std_idx, AVI->pos -16 -8)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML: RIFF No.%02d at Offset 0x%llX\n", cur_std_idx, AVI->pos -16 -8)); #endif - for (audtr = 0; audtr < AVI->anum; audtr++) { - if (AVI->track[audtr].audio_superindex) - AVI->track[audtr].audio_superindex->stdindex[ cur_std_idx ]->qwBaseOffset = - AVI->pos -16 -8; + for (audtr = 0; audtr < AVI->anum; audtr++) { + if (AVI->track[audtr].audio_superindex) + AVI->track[audtr].audio_superindex->stdindex[ cur_std_idx ]->qwBaseOffset = + AVI->pos -16 -8; - } + } - // now we can be sure - AVI->is_opendml++; - } + // now we can be sure + AVI->is_opendml++; + } - } + } - if (video) { - avi_add_odml_index_entry_core(AVI, flags, AVI->pos, len, - AVI->video_superindex->stdindex[ AVI->video_superindex->nEntriesInUse-1 ]); + if (video) { + avi_add_odml_index_entry_core(AVI, flags, AVI->pos, len, + AVI->video_superindex->stdindex[ AVI->video_superindex->nEntriesInUse-1 ]); - AVI->total_frames++; - } // video + AVI->total_frames++; + } // video - if (audio) { - avi_add_odml_index_entry_core(AVI, flags, AVI->pos, len, - AVI->track[AVI->aptr].audio_superindex->stdindex[ - AVI->track[AVI->aptr].audio_superindex->nEntriesInUse-1 ]); - } + if (audio) { + avi_add_odml_index_entry_core(AVI, flags, AVI->pos, len, + AVI->track[AVI->aptr].audio_superindex->stdindex[ + AVI->track[AVI->aptr].audio_superindex->nEntriesInUse-1 ]); + } - return 0; + return 0; } // #undef NR_IXNN_CHUNKS static int avi_add_index_entry(avi_t *AVI, unsigned char *tag, long flags, u64 pos, u64 len) { - void *ptr; + void *ptr; - if(AVI->n_idx>=AVI->max_idx) { - ptr = gf_realloc((void *)AVI->idx,(AVI->max_idx+4096)*16); + if(AVI->n_idx>=AVI->max_idx) { + ptr = gf_realloc((void *)AVI->idx,(AVI->max_idx+4096)*16); - if(ptr == 0) { - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } - AVI->max_idx += 4096; - AVI->idx = (unsigned char((*)[16]) ) ptr; - } + if(ptr == 0) { + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } + AVI->max_idx += 4096; + AVI->idx = (unsigned char((*)[16]) ) ptr; + } - /* Add index entry */ + /* Add index entry */ - // GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] INDEX %s %ld %lu %lu\n", tag, flags, pos, len)); + // GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] INDEX %s %ld %lu %lu\n", tag, flags, pos, len)); - memcpy(AVI->idx[AVI->n_idx],tag,4); - long2str(AVI->idx[AVI->n_idx]+ 4,flags); - long2str(AVI->idx[AVI->n_idx]+ 8, (s32) pos); - long2str(AVI->idx[AVI->n_idx]+12, (s32) len); + memcpy(AVI->idx[AVI->n_idx],tag,4); + long2str(AVI->idx[AVI->n_idx]+ 4,flags); + long2str(AVI->idx[AVI->n_idx]+ 8, (s32) pos); + long2str(AVI->idx[AVI->n_idx]+12, (s32) len); - /* Update counter */ + /* Update counter */ - AVI->n_idx++; + AVI->n_idx++; - if(len>AVI->max_len) AVI->max_len=(u32) len; + if(len>AVI->max_len) AVI->max_len=(u32) len; - return 0; + return 0; } /* Returns 1 if more audio is in that video junk */ int AVI_can_read_audio(avi_t *AVI) { - if(AVI->mode==AVI_MODE_WRITE) { return -1; } - if(!AVI->video_index) { return -1; } - if(!AVI->track[AVI->aptr].audio_index) { return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + return -1; + } + if(!AVI->video_index) { + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + return -1; + } - // is it -1? the last ones got left out --tibit - //if (AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) { - if (AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks) { - return 0; - } + // is it -1? the last ones got left out --tibit + //if (AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) { + if (AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks) { + return 0; + } - if (AVI->video_pos >= AVI->video_frames) return 1; + if (AVI->video_pos >= AVI->video_frames) return 1; - if (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos < AVI->video_index[AVI->video_pos].pos) return 1; - else return 0; + if (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos < AVI->video_index[AVI->video_pos].pos) return 1; + else return 0; } /* AVI_open_output_file: Open an AVI File and write a bunch @@ -603,96 +613,96 @@ int AVI_can_read_audio(avi_t *AVI) GF_EXPORT avi_t* AVI_open_output_file(char * filename) { - avi_t *AVI; - int i; + avi_t *AVI; + int i; - unsigned char AVI_header[HEADERBYTES]; + unsigned char AVI_header[HEADERBYTES]; - /* Allocate the avi_t struct and zero it */ + /* Allocate the avi_t struct and zero it */ - AVI = (avi_t *) gf_malloc(sizeof(avi_t)); - if(AVI==0) - { - AVI_errno = AVI_ERR_NO_MEM; - return 0; - } - memset((void *)AVI,0,sizeof(avi_t)); - - AVI->fdes = gf_f64_open(filename, "w+b"); - if (!AVI->fdes ) - { - AVI_errno = AVI_ERR_OPEN; - gf_free(AVI); - return 0; - } + AVI = (avi_t *) gf_malloc(sizeof(avi_t)); + if(AVI==0) + { + AVI_errno = AVI_ERR_NO_MEM; + return 0; + } + memset((void *)AVI,0,sizeof(avi_t)); + + AVI->fdes = gf_f64_open(filename, "w+b"); + if (!AVI->fdes ) + { + AVI_errno = AVI_ERR_OPEN; + gf_free(AVI); + return 0; + } - /* Write out HEADERBYTES bytes, the header will go here - when we are finished with writing */ - - for (i=0;ifdes,(char *)AVI_header,HEADERBYTES); - if (i != HEADERBYTES) - { - fclose(AVI->fdes); - AVI_errno = AVI_ERR_WRITE; - gf_free(AVI); - return 0; - } + /* Write out HEADERBYTES bytes, the header will go here + when we are finished with writing */ + + for (i=0; ifdes,(char *)AVI_header,HEADERBYTES); + if (i != HEADERBYTES) + { + fclose(AVI->fdes); + AVI_errno = AVI_ERR_WRITE; + gf_free(AVI); + return 0; + } - AVI->pos = HEADERBYTES; - AVI->mode = AVI_MODE_WRITE; /* open for writing */ + AVI->pos = HEADERBYTES; + AVI->mode = AVI_MODE_WRITE; /* open for writing */ - //init - AVI->anum = 0; - AVI->aptr = 0; + //init + AVI->anum = 0; + AVI->aptr = 0; - return AVI; + return AVI; } GF_EXPORT void AVI_set_video(avi_t *AVI, int width, int height, double fps, char *compressor) { - /* may only be called if file is open for writing */ + /* may only be called if file is open for writing */ - if(AVI->mode==AVI_MODE_READ) return; + if(AVI->mode==AVI_MODE_READ) return; - AVI->width = width; - AVI->height = height; - AVI->fps = fps; + AVI->width = width; + AVI->height = height; + AVI->fps = fps; - if(strncmp(compressor, "RGB", 3)==0) { - memset(AVI->compressor, 0, 4); - } else { - memcpy(AVI->compressor,compressor,4); - } + if(strncmp(compressor, "RGB", 3)==0) { + memset(AVI->compressor, 0, 4); + } else { + memcpy(AVI->compressor,compressor,4); + } - AVI->compressor[4] = 0; + AVI->compressor[4] = 0; - avi_update_header(AVI); + avi_update_header(AVI); } void AVI_set_audio(avi_t *AVI, int channels, long rate, int bits, int format, long mp3rate) { - /* may only be called if file is open for writing */ + /* may only be called if file is open for writing */ - if(AVI->mode==AVI_MODE_READ) return; + if(AVI->mode==AVI_MODE_READ) return; - //inc audio tracks - AVI->aptr=AVI->anum; - ++AVI->anum; + //inc audio tracks + AVI->aptr=AVI->anum; + ++AVI->anum; - if(AVI->anum > AVI_MAX_TRACKS) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] error - only %d audio tracks supported\n", AVI_MAX_TRACKS)); - exit(1); - } + if(AVI->anum > AVI_MAX_TRACKS) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] error - only %d audio tracks supported\n", AVI_MAX_TRACKS)); + exit(1); + } - AVI->track[AVI->aptr].a_chans = channels; - AVI->track[AVI->aptr].a_rate = rate; - AVI->track[AVI->aptr].a_bits = bits; - AVI->track[AVI->aptr].a_fmt = format; - AVI->track[AVI->aptr].mp3rate = mp3rate; + AVI->track[AVI->aptr].a_chans = channels; + AVI->track[AVI->aptr].a_rate = rate; + AVI->track[AVI->aptr].a_bits = bits; + AVI->track[AVI->aptr].a_fmt = format; + AVI->track[AVI->aptr].mp3rate = mp3rate; - avi_update_header(AVI); + avi_update_header(AVI); } #define OUT4CC(s) \ @@ -726,47 +736,47 @@ void AVI_set_audio(avi_t *AVI, int channels, long rate, int bits, int format, lo //ThOe write preliminary AVI file header: 0 frames, max vid/aud size int avi_update_header(avi_t *AVI) { - int njunk, sampsize, hasIndex, ms_per_frame, frate, flag; - int movi_len, hdrl_start, strl_start; - u32 j; - unsigned char AVI_header[HEADERBYTES]; - u32 nhb; - unsigned long xd_size, xd_size_align2; - - //assume max size - movi_len = AVI_MAX_LEN - HEADERBYTES + 4; - - //assume index will be written - hasIndex=1; - - if(AVI->fps < 0.001) { - frate=0; - ms_per_frame=0; - } else { - frate = (int) (FRAME_RATE_SCALE*AVI->fps + 0.5); - ms_per_frame=(int) (1000000/AVI->fps + 0.5); - } + int njunk, sampsize, hasIndex, ms_per_frame, frate, flag; + int movi_len, hdrl_start, strl_start; + u32 j; + unsigned char AVI_header[HEADERBYTES]; + u32 nhb; + unsigned long xd_size, xd_size_align2; + + //assume max size + movi_len = AVI_MAX_LEN - HEADERBYTES + 4; + + //assume index will be written + hasIndex=1; + + if(AVI->fps < 0.001) { + frate=0; + ms_per_frame=0; + } else { + frate = (int) (FRAME_RATE_SCALE*AVI->fps + 0.5); + ms_per_frame=(int) (1000000/AVI->fps + 0.5); + } - /* Prepare the file header */ + /* Prepare the file header */ - nhb = 0; + nhb = 0; - /* The RIFF header */ + /* The RIFF header */ - OUT4CC ("RIFF"); - OUTLONG(movi_len); // assume max size - OUT4CC ("AVI "); + OUT4CC ("RIFF"); + OUTLONG(movi_len); // assume max size + OUT4CC ("AVI "); - /* Start the header list */ + /* Start the header list */ - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - hdrl_start = nhb; /* Store start position */ - OUT4CC ("hdrl"); + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + hdrl_start = nhb; /* Store start position */ + OUT4CC ("hdrl"); - /* The main AVI header */ + /* The main AVI header */ - /* The Flags in AVI File header */ + /* The Flags in AVI File header */ #define AVIF_HASINDEX 0x00000010 /* Index at end of file */ #define AVIF_MUSTUSEINDEX 0x00000020 @@ -775,199 +785,200 @@ int avi_update_header(avi_t *AVI) #define AVIF_WASCAPTUREFILE 0x00010000 #define AVIF_COPYRIGHTED 0x00020000 - OUT4CC ("avih"); - OUTLONG(56); /* # of bytes to follow */ - OUTLONG(ms_per_frame); /* Microseconds per frame */ - //ThOe ->0 - // OUTLONG(10000000); /* MaxBytesPerSec, I hope this will never be used */ - OUTLONG(0); - OUTLONG(0); /* PaddingGranularity (whatever that might be) */ - /* Other sources call it 'reserved' */ - flag = AVIF_ISINTERLEAVED; - if(hasIndex) flag |= AVIF_HASINDEX; - if(hasIndex && AVI->must_use_index) flag |= AVIF_MUSTUSEINDEX; - OUTLONG(flag); /* Flags */ - OUTLONG(0); // no frames yet - OUTLONG(0); /* InitialFrames */ - - OUTLONG(AVI->anum+1); - - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(AVI->width); /* Width */ - OUTLONG(AVI->height); /* Height */ - /* MS calls the following 'reserved': */ - OUTLONG(0); /* TimeScale: Unit used to measure time */ - OUTLONG(0); /* DataRate: Data rate of playback */ - OUTLONG(0); /* StartTime: Starting time of AVI data */ - OUTLONG(0); /* DataLength: Size of AVI data chunk */ - - - /* Start the video stream list ---------------------------------- */ - - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - strl_start = nhb; /* Store start position */ - OUT4CC ("strl"); - - /* The video stream header */ - - OUT4CC ("strh"); - OUTLONG(56); /* # of bytes to follow */ - OUT4CC ("vids"); /* Type */ - OUT4CC (AVI->compressor); /* Handler */ - OUTLONG(0); /* Flags */ - OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ - OUTLONG(0); /* InitialFrames */ - OUTLONG(FRAME_RATE_SCALE); /* Scale */ - OUTLONG(frate); /* Rate: Rate/Scale == samples/second */ - OUTLONG(0); /* Start */ - OUTLONG(0); // no frames yet - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(-1); /* Quality */ - OUTLONG(0); /* SampleSize */ - OUTLONG(0); /* Frame */ - OUTLONG(0); /* Frame */ - // OUTLONG(0); /* Frame */ - //OUTLONG(0); /* Frame */ - - /* The video stream format */ - - xd_size = AVI->extradata_size; - xd_size_align2 = (AVI->extradata_size+1) & ~1; - - OUT4CC ("strf"); - OUTLONG(40 + xd_size_align2);/* # of bytes to follow */ - OUTLONG(40 + xd_size); /* Size */ - OUTLONG(AVI->width); /* Width */ - OUTLONG(AVI->height); /* Height */ - OUTSHRT(1); OUTSHRT(24); /* Planes, Count */ - OUT4CC (AVI->compressor); /* Compression */ - // ThOe (*3) - OUTLONG(AVI->width*AVI->height*3); /* SizeImage (in bytes?) */ - OUTLONG(0); /* XPelsPerMeter */ - OUTLONG(0); /* YPelsPerMeter */ - OUTLONG(0); /* ClrUsed: Number of colors used */ - OUTLONG(0); /* ClrImportant: Number of colors important */ - - // write extradata - if (xd_size > 0 && AVI->extradata) { - OUTMEM(AVI->extradata, xd_size); - if (xd_size != xd_size_align2) { - OUTCHR(0); - } - } + OUT4CC ("avih"); + OUTLONG(56); /* # of bytes to follow */ + OUTLONG(ms_per_frame); /* Microseconds per frame */ + //ThOe ->0 + // OUTLONG(10000000); /* MaxBytesPerSec, I hope this will never be used */ + OUTLONG(0); + OUTLONG(0); /* PaddingGranularity (whatever that might be) */ + /* Other sources call it 'reserved' */ + flag = AVIF_ISINTERLEAVED; + if(hasIndex) flag |= AVIF_HASINDEX; + if(hasIndex && AVI->must_use_index) flag |= AVIF_MUSTUSEINDEX; + OUTLONG(flag); /* Flags */ + OUTLONG(0); // no frames yet + OUTLONG(0); /* InitialFrames */ + + OUTLONG(AVI->anum+1); + + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(AVI->width); /* Width */ + OUTLONG(AVI->height); /* Height */ + /* MS calls the following 'reserved': */ + OUTLONG(0); /* TimeScale: Unit used to measure time */ + OUTLONG(0); /* DataRate: Data rate of playback */ + OUTLONG(0); /* StartTime: Starting time of AVI data */ + OUTLONG(0); /* DataLength: Size of AVI data chunk */ + + + /* Start the video stream list ---------------------------------- */ + + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + strl_start = nhb; /* Store start position */ + OUT4CC ("strl"); + + /* The video stream header */ + + OUT4CC ("strh"); + OUTLONG(56); /* # of bytes to follow */ + OUT4CC ("vids"); /* Type */ + OUT4CC (AVI->compressor); /* Handler */ + OUTLONG(0); /* Flags */ + OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ + OUTLONG(0); /* InitialFrames */ + OUTLONG(FRAME_RATE_SCALE); /* Scale */ + OUTLONG(frate); /* Rate: Rate/Scale == samples/second */ + OUTLONG(0); /* Start */ + OUTLONG(0); // no frames yet + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(-1); /* Quality */ + OUTLONG(0); /* SampleSize */ + OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + // OUTLONG(0); /* Frame */ + //OUTLONG(0); /* Frame */ + + /* The video stream format */ + + xd_size = AVI->extradata_size; + xd_size_align2 = (AVI->extradata_size+1) & ~1; + + OUT4CC ("strf"); + OUTLONG(40 + xd_size_align2);/* # of bytes to follow */ + OUTLONG(40 + xd_size); /* Size */ + OUTLONG(AVI->width); /* Width */ + OUTLONG(AVI->height); /* Height */ + OUTSHRT(1); + OUTSHRT(24); /* Planes, Count */ + OUT4CC (AVI->compressor); /* Compression */ + // ThOe (*3) + OUTLONG(AVI->width*AVI->height*3); /* SizeImage (in bytes?) */ + OUTLONG(0); /* XPelsPerMeter */ + OUTLONG(0); /* YPelsPerMeter */ + OUTLONG(0); /* ClrUsed: Number of colors used */ + OUTLONG(0); /* ClrImportant: Number of colors important */ + + // write extradata + if (xd_size > 0 && AVI->extradata) { + OUTMEM(AVI->extradata, xd_size); + if (xd_size != xd_size_align2) { + OUTCHR(0); + } + } - /* Finish stream list, i.e. put number of bytes in the list to proper pos */ + /* Finish stream list, i.e. put number of bytes in the list to proper pos */ - long2str(AVI_header+strl_start-4,nhb-strl_start); + long2str(AVI_header+strl_start-4,nhb-strl_start); - /* Start the audio stream list ---------------------------------- */ + /* Start the audio stream list ---------------------------------- */ - for(j=0; janum; ++j) { + for(j=0; janum; ++j) { - sampsize = avi_sampsize(AVI, j); + sampsize = avi_sampsize(AVI, j); - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - strl_start = nhb; /* Store start position */ - OUT4CC ("strl"); + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + strl_start = nhb; /* Store start position */ + OUT4CC ("strl"); - /* The audio stream header */ + /* The audio stream header */ - OUT4CC ("strh"); - OUTLONG(56); /* # of bytes to follow */ - OUT4CC ("auds"); + OUT4CC ("strh"); + OUTLONG(56); /* # of bytes to follow */ + OUT4CC ("auds"); - // ----------- - // ThOe - OUTLONG(0); /* Format (Optionally) */ - // ----------- + // ----------- + // ThOe + OUTLONG(0); /* Format (Optionally) */ + // ----------- - OUTLONG(0); /* Flags */ - OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ - OUTLONG(0); /* InitialFrames */ + OUTLONG(0); /* Flags */ + OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ + OUTLONG(0); /* InitialFrames */ - // ThOe /4 - OUTLONG(sampsize/4); /* Scale */ - OUTLONG(1000*AVI->track[j].mp3rate/8); - OUTLONG(0); /* Start */ - OUTLONG(4*AVI->track[j].audio_bytes/sampsize); /* Length */ - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(-1); /* Quality */ + // ThOe /4 + OUTLONG(sampsize/4); /* Scale */ + OUTLONG(1000*AVI->track[j].mp3rate/8); + OUTLONG(0); /* Start */ + OUTLONG(4*AVI->track[j].audio_bytes/sampsize); /* Length */ + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(-1); /* Quality */ - // ThOe /4 - OUTLONG(sampsize/4); /* SampleSize */ + // ThOe /4 + OUTLONG(sampsize/4); /* SampleSize */ - OUTLONG(0); /* Frame */ - OUTLONG(0); /* Frame */ - // OUTLONG(0); /* Frame */ - //OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + // OUTLONG(0); /* Frame */ + //OUTLONG(0); /* Frame */ - /* The audio stream format */ + /* The audio stream format */ - OUT4CC ("strf"); - OUTLONG(16); /* # of bytes to follow */ - OUTSHRT(AVI->track[j].a_fmt); /* Format */ - OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ - OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ - // ThOe - OUTLONG(1000*AVI->track[j].mp3rate/8); - //ThOe (/4) + OUT4CC ("strf"); + OUTLONG(16); /* # of bytes to follow */ + OUTSHRT(AVI->track[j].a_fmt); /* Format */ + OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ + OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ + // ThOe + OUTLONG(1000*AVI->track[j].mp3rate/8); + //ThOe (/4) - OUTSHRT(sampsize/4); /* BlockAlign */ + OUTSHRT(sampsize/4); /* BlockAlign */ - OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ + OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ - /* Finish stream list, i.e. put number of bytes in the list to proper pos */ + /* Finish stream list, i.e. put number of bytes in the list to proper pos */ - long2str(AVI_header+strl_start-4,nhb-strl_start); - } + long2str(AVI_header+strl_start-4,nhb-strl_start); + } - /* Finish header list */ + /* Finish header list */ - long2str(AVI_header+hdrl_start-4,nhb-hdrl_start); + long2str(AVI_header+hdrl_start-4,nhb-hdrl_start); - /* Calculate the needed amount of junk bytes, output junk */ + /* Calculate the needed amount of junk bytes, output junk */ - njunk = HEADERBYTES - nhb - 8 - 12; + njunk = HEADERBYTES - nhb - 8 - 12; - /* Safety first: if njunk <= 0, somebody has played with - HEADERBYTES without knowing what (s)he did. - This is a fatal error */ + /* Safety first: if njunk <= 0, somebody has played with + HEADERBYTES without knowing what (s)he did. + This is a fatal error */ - if(njunk<=0) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVI_close_output_file: # of header bytes too small\n")); - exit(1); - } + if(njunk<=0) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVI_close_output_file: # of header bytes too small\n")); + exit(1); + } - OUT4CC ("JUNK"); - OUTLONG(njunk); - memset(AVI_header+nhb,0,njunk); + OUT4CC ("JUNK"); + OUTLONG(njunk); + memset(AVI_header+nhb,0,njunk); - nhb += njunk; + nhb += njunk; - /* Start the movi list */ + /* Start the movi list */ - OUT4CC ("LIST"); - OUTLONG(movi_len); /* Length of list in bytes */ - OUT4CC ("movi"); + OUT4CC ("LIST"); + OUTLONG(movi_len); /* Length of list in bytes */ + OUT4CC ("movi"); - /* Output the header, truncate the file to the number of bytes - actually written, report an error if someting goes wrong */ + /* Output the header, truncate the file to the number of bytes + actually written, report an error if someting goes wrong */ - if ( (gf_f64_seek(AVI->fdes, 0, SEEK_SET) ==(u64)-1) || - avi_write(AVI->fdes,(char *)AVI_header,HEADERBYTES)!=HEADERBYTES || - (gf_f64_seek(AVI->fdes,AVI->pos,SEEK_SET)==(u64)-1) - ) { - AVI_errno = AVI_ERR_CLOSE; - return -1; - } + if ( (gf_f64_seek(AVI->fdes, 0, SEEK_SET) ==(u64)-1) || + avi_write(AVI->fdes,(char *)AVI_header,HEADERBYTES)!=HEADERBYTES || + (gf_f64_seek(AVI->fdes,AVI->pos,SEEK_SET)==(u64)-1) + ) { + AVI_errno = AVI_ERR_CLOSE; + return -1; + } - return 0; + return 0; } @@ -994,117 +1005,117 @@ int avi_update_header(avi_t *AVI) static int avi_close_output_file(avi_t *AVI) { - int ret, njunk, sampsize, hasIndex, ms_per_frame, frate, idxerror, flag; - u64 movi_len; - int hdrl_start, strl_start; - u32 j; - unsigned char AVI_header[HEADERBYTES]; - long nhb; - unsigned long xd_size, xd_size_align2; + int ret, njunk, sampsize, hasIndex, ms_per_frame, frate, idxerror, flag; + u64 movi_len; + int hdrl_start, strl_start; + u32 j; + unsigned char AVI_header[HEADERBYTES]; + long nhb; + unsigned long xd_size, xd_size_align2; #ifdef INFO_LIST - long info_len; - long id_len, real_id_len; - long info_start_pos; + long info_len; + long id_len, real_id_len; + long info_start_pos; // time_t calptr; #endif - /* Calculate length of movi list */ + /* Calculate length of movi list */ - // dump the rest of the index - if (AVI->is_opendml) { - int cur_std_idx = AVI->video_superindex->nEntriesInUse-1; - u32 audtr; + // dump the rest of the index + if (AVI->is_opendml) { + int cur_std_idx = AVI->video_superindex->nEntriesInUse-1; + u32 audtr; #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML dump the rest indices\n")); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] ODML dump the rest indices\n")); #endif - avi_ixnn_entry (AVI, AVI->video_superindex->stdindex[cur_std_idx], - &AVI->video_superindex->aIndex[cur_std_idx]); - - AVI->video_superindex->aIndex[cur_std_idx].dwDuration = - AVI->video_superindex->stdindex[cur_std_idx]->nEntriesInUse - 1; - - for (audtr = 0; audtr < AVI->anum; audtr++) { - if (!AVI->track[audtr].audio_superindex) { - // not initialized -> no index - continue; - } - avi_ixnn_entry (AVI, AVI->track[audtr].audio_superindex->stdindex[cur_std_idx], - &AVI->track[audtr].audio_superindex->aIndex[cur_std_idx]); - AVI->track[audtr].audio_superindex->aIndex[cur_std_idx].dwDuration = - AVI->track[audtr].audio_superindex->stdindex[cur_std_idx]->nEntriesInUse - 1; - if (AVI->track[audtr].a_fmt == 0x1) { - AVI->track[audtr].audio_superindex->aIndex[cur_std_idx].dwDuration *= - AVI->track[audtr].a_bits*AVI->track[audtr].a_rate*AVI->track[audtr].a_chans/800; - } - } - // The AVI->video_superindex->nEntriesInUse contains the offset - AVI->video_superindex->stdindex[ cur_std_idx+1 ]->qwBaseOffset = AVI->pos; - } + avi_ixnn_entry (AVI, AVI->video_superindex->stdindex[cur_std_idx], + &AVI->video_superindex->aIndex[cur_std_idx]); + + AVI->video_superindex->aIndex[cur_std_idx].dwDuration = + AVI->video_superindex->stdindex[cur_std_idx]->nEntriesInUse - 1; + + for (audtr = 0; audtr < AVI->anum; audtr++) { + if (!AVI->track[audtr].audio_superindex) { + // not initialized -> no index + continue; + } + avi_ixnn_entry (AVI, AVI->track[audtr].audio_superindex->stdindex[cur_std_idx], + &AVI->track[audtr].audio_superindex->aIndex[cur_std_idx]); + AVI->track[audtr].audio_superindex->aIndex[cur_std_idx].dwDuration = + AVI->track[audtr].audio_superindex->stdindex[cur_std_idx]->nEntriesInUse - 1; + if (AVI->track[audtr].a_fmt == 0x1) { + AVI->track[audtr].audio_superindex->aIndex[cur_std_idx].dwDuration *= + AVI->track[audtr].a_bits*AVI->track[audtr].a_rate*AVI->track[audtr].a_chans/800; + } + } + // The AVI->video_superindex->nEntriesInUse contains the offset + AVI->video_superindex->stdindex[ cur_std_idx+1 ]->qwBaseOffset = AVI->pos; + } - if (AVI->is_opendml) { - // Correct! - movi_len = AVI->video_superindex->stdindex[ 1 ]->qwBaseOffset - HEADERBYTES+4 - AVI->n_idx*16 - 8; - } else { - movi_len = AVI->pos - HEADERBYTES + 4; - } + if (AVI->is_opendml) { + // Correct! + movi_len = AVI->video_superindex->stdindex[ 1 ]->qwBaseOffset - HEADERBYTES+4 - AVI->n_idx*16 - 8; + } else { + movi_len = AVI->pos - HEADERBYTES + 4; + } - /* Try to ouput the index entries. This may fail e.g. if no space - is left on device. We will report this as an error, but we still - try to write the header correctly (so that the file still may be - readable in the most cases */ + /* Try to ouput the index entries. This may fail e.g. if no space + is left on device. We will report this as an error, but we still + try to write the header correctly (so that the file still may be + readable in the most cases */ - idxerror = 0; - hasIndex = 1; - if (!AVI->is_opendml) { - // GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu, index_len=%ld \n", AVI->pos, AVI->n_idx*16)); - ret = avi_add_chunk(AVI, (unsigned char *)"idx1", (unsigned char *)AVI->idx, AVI->n_idx*16); - hasIndex = (ret==0); - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu, index_len=%d\n", AVI->pos, hasIndex)); + idxerror = 0; + hasIndex = 1; + if (!AVI->is_opendml) { + // GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu, index_len=%ld \n", AVI->pos, AVI->n_idx*16)); + ret = avi_add_chunk(AVI, (unsigned char *)"idx1", (unsigned char *)AVI->idx, AVI->n_idx*16); + hasIndex = (ret==0); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] pos=%lu, index_len=%d\n", AVI->pos, hasIndex)); - if(ret) { - idxerror = 1; - AVI_errno = AVI_ERR_WRITE_INDEX; - } - } + if(ret) { + idxerror = 1; + AVI_errno = AVI_ERR_WRITE_INDEX; + } + } - /* Calculate Microseconds per frame */ + /* Calculate Microseconds per frame */ - if(AVI->fps < 0.001) { - frate=0; - ms_per_frame=0; - } else { - frate = (int) (FRAME_RATE_SCALE*AVI->fps + 0.5); - ms_per_frame=(int) (1000000/AVI->fps + 0.5); - } + if(AVI->fps < 0.001) { + frate=0; + ms_per_frame=0; + } else { + frate = (int) (FRAME_RATE_SCALE*AVI->fps + 0.5); + ms_per_frame=(int) (1000000/AVI->fps + 0.5); + } - /* Prepare the file header */ + /* Prepare the file header */ - nhb = 0; + nhb = 0; - /* The RIFF header */ + /* The RIFF header */ - OUT4CC ("RIFF"); - if (AVI->is_opendml) { - OUTLONG(AVI->video_superindex->stdindex[ 1 ]->qwBaseOffset - 8); /* # of bytes to follow */ - } else { - OUTLONG(AVI->pos - 8); /* # of bytes to follow */ - } + OUT4CC ("RIFF"); + if (AVI->is_opendml) { + OUTLONG(AVI->video_superindex->stdindex[ 1 ]->qwBaseOffset - 8); /* # of bytes to follow */ + } else { + OUTLONG(AVI->pos - 8); /* # of bytes to follow */ + } - OUT4CC ("AVI "); + OUT4CC ("AVI "); - /* Start the header list */ + /* Start the header list */ - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - hdrl_start = nhb; /* Store start position */ - OUT4CC ("hdrl"); + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + hdrl_start = nhb; /* Store start position */ + OUT4CC ("hdrl"); - /* The main AVI header */ + /* The main AVI header */ - /* The Flags in AVI File header */ + /* The Flags in AVI File header */ #define AVIF_HASINDEX 0x00000010 /* Index at end of file */ #define AVIF_MUSTUSEINDEX 0x00000020 @@ -1113,337 +1124,340 @@ static int avi_close_output_file(avi_t *AVI) #define AVIF_WASCAPTUREFILE 0x00010000 #define AVIF_COPYRIGHTED 0x00020000 - OUT4CC ("avih"); - OUTLONG(56); /* # of bytes to follow */ - OUTLONG(ms_per_frame); /* Microseconds per frame */ - //ThOe ->0 - // OUTLONG(10000000); /* MaxBytesPerSec, I hope this will never be used */ - OUTLONG(0); - OUTLONG(0); /* PaddingGranularity (whatever that might be) */ - /* Other sources call it 'reserved' */ - flag = AVIF_ISINTERLEAVED; - if(hasIndex) flag |= AVIF_HASINDEX; - if(hasIndex && AVI->must_use_index) flag |= AVIF_MUSTUSEINDEX; - OUTLONG(flag); /* Flags */ - OUTLONG(AVI->video_frames); /* TotalFrames */ - OUTLONG(0); /* InitialFrames */ - - OUTLONG(AVI->anum+1); + OUT4CC ("avih"); + OUTLONG(56); /* # of bytes to follow */ + OUTLONG(ms_per_frame); /* Microseconds per frame */ + //ThOe ->0 + // OUTLONG(10000000); /* MaxBytesPerSec, I hope this will never be used */ + OUTLONG(0); + OUTLONG(0); /* PaddingGranularity (whatever that might be) */ + /* Other sources call it 'reserved' */ + flag = AVIF_ISINTERLEAVED; + if(hasIndex) flag |= AVIF_HASINDEX; + if(hasIndex && AVI->must_use_index) flag |= AVIF_MUSTUSEINDEX; + OUTLONG(flag); /* Flags */ + OUTLONG(AVI->video_frames); /* TotalFrames */ + OUTLONG(0); /* InitialFrames */ + + OUTLONG(AVI->anum+1); // if (AVI->track[0].audio_bytes) // { OUTLONG(2); } /* Streams */ // else // { OUTLONG(1); } /* Streams */ - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(AVI->width); /* Width */ - OUTLONG(AVI->height); /* Height */ - /* MS calls the following 'reserved': */ - OUTLONG(0); /* TimeScale: Unit used to measure time */ - OUTLONG(0); /* DataRate: Data rate of playback */ - OUTLONG(0); /* StartTime: Starting time of AVI data */ - OUTLONG(0); /* DataLength: Size of AVI data chunk */ - - - /* Start the video stream list ---------------------------------- */ - - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - strl_start = nhb; /* Store start position */ - OUT4CC ("strl"); - - /* The video stream header */ - - OUT4CC ("strh"); - OUTLONG(56); /* # of bytes to follow */ - OUT4CC ("vids"); /* Type */ - OUT4CC (AVI->compressor); /* Handler */ - OUTLONG(0); /* Flags */ - OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ - OUTLONG(0); /* InitialFrames */ - OUTLONG(FRAME_RATE_SCALE); /* Scale */ - OUTLONG(frate); /* Rate: Rate/Scale == samples/second */ - OUTLONG(0); /* Start */ - OUTLONG(AVI->video_frames); /* Length */ - OUTLONG(AVI->max_len); /* SuggestedBufferSize */ - OUTLONG(0); /* Quality */ - OUTLONG(0); /* SampleSize */ - OUTLONG(0); /* Frame */ - OUTLONG(0); /* Frame */ - //OUTLONG(0); /* Frame */ - //OUTLONG(0); /* Frame */ - - /* The video stream format */ - - xd_size = AVI->extradata_size; - xd_size_align2 = (AVI->extradata_size+1) & ~1; - - OUT4CC ("strf"); - OUTLONG(40 + xd_size_align2);/* # of bytes to follow */ - OUTLONG(40 + xd_size); /* Size */ - OUTLONG(AVI->width); /* Width */ - OUTLONG(AVI->height); /* Height */ - OUTSHRT(1); OUTSHRT(24); /* Planes, Count */ - OUT4CC (AVI->compressor); /* Compression */ - // ThOe (*3) - OUTLONG(AVI->width*AVI->height*3); /* SizeImage (in bytes?) */ - OUTLONG(0); /* XPelsPerMeter */ - OUTLONG(0); /* YPelsPerMeter */ - OUTLONG(0); /* ClrUsed: Number of colors used */ - OUTLONG(0); /* ClrImportant: Number of colors important */ - - // write extradata if present - if (xd_size > 0 && AVI->extradata) { - OUTMEM(AVI->extradata, xd_size); - if (xd_size != xd_size_align2) { - OUTCHR(0); - } - } - - // dump index of indices for audio - if (AVI->is_opendml) { - u32 k; - - OUT4CC(AVI->video_superindex->fcc); - OUTLONG(2+1+1+4+4+3*4 + AVI->video_superindex->nEntriesInUse * (8+4+4)); - OUTSHRT(AVI->video_superindex->wLongsPerEntry); - OUTCHR(AVI->video_superindex->bIndexSubType); - OUTCHR(AVI->video_superindex->bIndexType); - OUTLONG(AVI->video_superindex->nEntriesInUse); - OUT4CC(AVI->video_superindex->dwChunkId); - OUTLONG(0); - OUTLONG(0); - OUTLONG(0); - - - for (k = 0; k < AVI->video_superindex->nEntriesInUse; k++) { - u32 r = (u32) ((AVI->video_superindex->aIndex[k].qwOffset >> 32) & 0xffffffff); - u32 s = (u32) ((AVI->video_superindex->aIndex[k].qwOffset) & 0xffffffff); + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(AVI->width); /* Width */ + OUTLONG(AVI->height); /* Height */ + /* MS calls the following 'reserved': */ + OUTLONG(0); /* TimeScale: Unit used to measure time */ + OUTLONG(0); /* DataRate: Data rate of playback */ + OUTLONG(0); /* StartTime: Starting time of AVI data */ + OUTLONG(0); /* DataLength: Size of AVI data chunk */ + + + /* Start the video stream list ---------------------------------- */ + + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + strl_start = nhb; /* Store start position */ + OUT4CC ("strl"); + + /* The video stream header */ + + OUT4CC ("strh"); + OUTLONG(56); /* # of bytes to follow */ + OUT4CC ("vids"); /* Type */ + OUT4CC (AVI->compressor); /* Handler */ + OUTLONG(0); /* Flags */ + OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ + OUTLONG(0); /* InitialFrames */ + OUTLONG(FRAME_RATE_SCALE); /* Scale */ + OUTLONG(frate); /* Rate: Rate/Scale == samples/second */ + OUTLONG(0); /* Start */ + OUTLONG(AVI->video_frames); /* Length */ + OUTLONG(AVI->max_len); /* SuggestedBufferSize */ + OUTLONG(0); /* Quality */ + OUTLONG(0); /* SampleSize */ + OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + //OUTLONG(0); /* Frame */ + //OUTLONG(0); /* Frame */ + + /* The video stream format */ + + xd_size = AVI->extradata_size; + xd_size_align2 = (AVI->extradata_size+1) & ~1; + + OUT4CC ("strf"); + OUTLONG(40 + xd_size_align2);/* # of bytes to follow */ + OUTLONG(40 + xd_size); /* Size */ + OUTLONG(AVI->width); /* Width */ + OUTLONG(AVI->height); /* Height */ + OUTSHRT(1); + OUTSHRT(24); /* Planes, Count */ + OUT4CC (AVI->compressor); /* Compression */ + // ThOe (*3) + OUTLONG(AVI->width*AVI->height*3); /* SizeImage (in bytes?) */ + OUTLONG(0); /* XPelsPerMeter */ + OUTLONG(0); /* YPelsPerMeter */ + OUTLONG(0); /* ClrUsed: Number of colors used */ + OUTLONG(0); /* ClrImportant: Number of colors important */ + + // write extradata if present + if (xd_size > 0 && AVI->extradata) { + OUTMEM(AVI->extradata, xd_size); + if (xd_size != xd_size_align2) { + OUTCHR(0); + } + } - OUTLONG(s); - OUTLONG(r); - OUTLONG(AVI->video_superindex->aIndex[k].dwSize); - OUTLONG(AVI->video_superindex->aIndex[k].dwDuration); - } + // dump index of indices for audio + if (AVI->is_opendml) { + u32 k; + + OUT4CC(AVI->video_superindex->fcc); + OUTLONG(2+1+1+4+4+3*4 + AVI->video_superindex->nEntriesInUse * (8+4+4)); + OUTSHRT(AVI->video_superindex->wLongsPerEntry); + OUTCHR(AVI->video_superindex->bIndexSubType); + OUTCHR(AVI->video_superindex->bIndexType); + OUTLONG(AVI->video_superindex->nEntriesInUse); + OUT4CC(AVI->video_superindex->dwChunkId); + OUTLONG(0); + OUTLONG(0); + OUTLONG(0); + + + for (k = 0; k < AVI->video_superindex->nEntriesInUse; k++) { + u32 r = (u32) ((AVI->video_superindex->aIndex[k].qwOffset >> 32) & 0xffffffff); + u32 s = (u32) ((AVI->video_superindex->aIndex[k].qwOffset) & 0xffffffff); + + OUTLONG(s); + OUTLONG(r); + OUTLONG(AVI->video_superindex->aIndex[k].dwSize); + OUTLONG(AVI->video_superindex->aIndex[k].dwDuration); + } - } + } - /* Finish stream list, i.e. put number of bytes in the list to proper pos */ - - long2str(AVI_header+strl_start-4,nhb-strl_start); - - /* Start the audio stream list ---------------------------------- */ - - for(j=0; janum; ++j) { - - //if (AVI->track[j].a_chans && AVI->track[j].audio_bytes) - { - unsigned long nBlockAlign = 0; - unsigned long avgbsec = 0; - unsigned long scalerate = 0; - - sampsize = avi_sampsize(AVI, j); - sampsize = AVI->track[j].a_fmt==0x1?sampsize*4:sampsize; - - nBlockAlign = (AVI->track[j].a_rate<32000)?576:1152; - /* - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] XXX sampsize (%d) block (%ld) rate (%ld) audio_bytes (%ld) mp3rate(%ld,%ld)\n", - sampsize, nBlockAlign, AVI->track[j].a_rate, - (long int)AVI->track[j].audio_bytes, - 1000*AVI->track[j].mp3rate/8, AVI->track[j].mp3rate)); - */ - - if (AVI->track[j].a_fmt==0x1) { - sampsize = (AVI->track[j].a_chans<2)?sampsize/2:sampsize; - avgbsec = AVI->track[j].a_rate*sampsize/4; - scalerate = AVI->track[j].a_rate*sampsize/4; - } else { - avgbsec = 1000*AVI->track[j].mp3rate/8; - scalerate = 1000*AVI->track[j].mp3rate/8; - } - - OUT4CC ("LIST"); - OUTLONG(0); /* Length of list in bytes, don't know yet */ - strl_start = nhb; /* Store start position */ - OUT4CC ("strl"); - - /* The audio stream header */ - - OUT4CC ("strh"); - OUTLONG(56); /* # of bytes to follow */ - OUT4CC ("auds"); - - // ----------- - // ThOe - OUTLONG(0); /* Format (Optionally) */ - // ----------- - - OUTLONG(0); /* Flags */ - OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ - OUTLONG(0); /* InitialFrames */ - - // VBR - if (AVI->track[j].a_fmt == 0x55 && AVI->track[j].a_vbr) { - OUTLONG(nBlockAlign); /* Scale */ - OUTLONG(AVI->track[j].a_rate); /* Rate */ - OUTLONG(0); /* Start */ - OUTLONG(AVI->track[j].audio_chunks); /* Length */ - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(0); /* Quality */ - OUTLONG(0); /* SampleSize */ - OUTLONG(0); /* Frame */ - OUTLONG(0); /* Frame */ - } else { - OUTLONG(sampsize/4); /* Scale */ - OUTLONG(scalerate); /* Rate */ - OUTLONG(0); /* Start */ - OUTLONG(4*AVI->track[j].audio_bytes/sampsize); /* Length */ - OUTLONG(0); /* SuggestedBufferSize */ - OUTLONG(0xffffffff); /* Quality */ - OUTLONG(sampsize/4); /* SampleSize */ - OUTLONG(0); /* Frame */ - OUTLONG(0); /* Frame */ - } - - /* The audio stream format */ - - OUT4CC ("strf"); - - if (AVI->track[j].a_fmt == 0x55 && AVI->track[j].a_vbr) { - - OUTLONG(30); /* # of bytes to follow */ // mplayer writes 28 - OUTSHRT(AVI->track[j].a_fmt); /* Format */ // 2 - OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ // 2 - OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ // 4 - //ThOe/tibit - OUTLONG(1000*AVI->track[j].mp3rate/8); /* maybe we should write an avg. */ // 4 - OUTSHRT(nBlockAlign); /* BlockAlign */ // 2 - OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ // 2 - - OUTSHRT(12); /* cbSize */ // 2 - OUTSHRT(1); /* wID */ // 2 - OUTLONG(2); /* fdwFlags */ // 4 - OUTSHRT(nBlockAlign); /* nBlockSize */ // 2 - OUTSHRT(1); /* nFramesPerBlock */ // 2 - OUTSHRT(0); /* nCodecDelay */ // 2 - - } else if (AVI->track[j].a_fmt == 0x55 && !AVI->track[j].a_vbr) { - - OUTLONG(30); /* # of bytes to follow */ - OUTSHRT(AVI->track[j].a_fmt); /* Format */ - OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ - OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ - //ThOe/tibit - OUTLONG(1000*AVI->track[j].mp3rate/8); - OUTSHRT(sampsize/4); /* BlockAlign */ - OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ - - OUTSHRT(12); /* cbSize */ - OUTSHRT(1); /* wID */ - OUTLONG(2); /* fdwFlags */ - OUTSHRT(nBlockAlign); /* nBlockSize */ - OUTSHRT(1); /* nFramesPerBlock */ - OUTSHRT(0); /* nCodecDelay */ - - } else { - - OUTLONG(18); /* # of bytes to follow */ - OUTSHRT(AVI->track[j].a_fmt); /* Format */ - OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ - OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ - //ThOe/tibit - OUTLONG(avgbsec); /* Avg bytes/sec */ - OUTSHRT(sampsize/4); /* BlockAlign */ - OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ - OUTSHRT(0); /* cbSize */ - - } - } - if (AVI->is_opendml) { - u32 k; - - if (!AVI->track[j].audio_superindex) { - // not initialized -> no index - continue; - } - - OUT4CC(AVI->track[j].audio_superindex->fcc); /* "indx" */ - OUTLONG(2+1+1+4+4+3*4 + AVI->track[j].audio_superindex->nEntriesInUse * (8+4+4)); - OUTSHRT(AVI->track[j].audio_superindex->wLongsPerEntry); - OUTCHR(AVI->track[j].audio_superindex->bIndexSubType); - OUTCHR(AVI->track[j].audio_superindex->bIndexType); - OUTLONG(AVI->track[j].audio_superindex->nEntriesInUse); - OUT4CC(AVI->track[j].audio_superindex->dwChunkId); - OUTLONG(0); OUTLONG(0); OUTLONG(0); - - for (k = 0; k < AVI->track[j].audio_superindex->nEntriesInUse; k++) { - u32 r = (u32) ((AVI->track[j].audio_superindex->aIndex[k].qwOffset >> 32) & 0xffffffff); - u32 s = (u32) ((AVI->track[j].audio_superindex->aIndex[k].qwOffset) & 0xffffffff); - - /* - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] AUD[%d] NrEntries %d/%ld (%c%c%c%c) |0x%llX|%ld|%ld| \n", j, k, - AVI->track[j].audio_superindex->nEntriesInUse, - AVI->track[j].audio_superindex->dwChunkId[0], AVI->track[j].audio_superindex->dwChunkId[1], - AVI->track[j].audio_superindex->dwChunkId[2], AVI->track[j].audio_superindex->dwChunkId[3], - AVI->track[j].audio_superindex->aIndex[k].qwOffset, - AVI->track[j].audio_superindex->aIndex[k].dwSize, - AVI->track[j].audio_superindex->aIndex[k].dwDuration - )); - */ - - OUTLONG(s); - OUTLONG(r); - OUTLONG(AVI->track[j].audio_superindex->aIndex[k].dwSize); - OUTLONG(AVI->track[j].audio_superindex->aIndex[k].dwDuration); - } - } - /* Finish stream list, i.e. put number of bytes in the list to proper pos */ - long2str(AVI_header+strl_start-4,nhb-strl_start); - } + /* Finish stream list, i.e. put number of bytes in the list to proper pos */ + + long2str(AVI_header+strl_start-4,nhb-strl_start); + + /* Start the audio stream list ---------------------------------- */ + + for(j=0; janum; ++j) { + + //if (AVI->track[j].a_chans && AVI->track[j].audio_bytes) + { + unsigned long nBlockAlign = 0; + unsigned long avgbsec = 0; + unsigned long scalerate = 0; + + sampsize = avi_sampsize(AVI, j); + sampsize = AVI->track[j].a_fmt==0x1?sampsize*4:sampsize; + + nBlockAlign = (AVI->track[j].a_rate<32000)?576:1152; + /* + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] XXX sampsize (%d) block (%ld) rate (%ld) audio_bytes (%ld) mp3rate(%ld,%ld)\n", + sampsize, nBlockAlign, AVI->track[j].a_rate, + (long int)AVI->track[j].audio_bytes, + 1000*AVI->track[j].mp3rate/8, AVI->track[j].mp3rate)); + */ + + if (AVI->track[j].a_fmt==0x1) { + sampsize = (AVI->track[j].a_chans<2)?sampsize/2:sampsize; + avgbsec = AVI->track[j].a_rate*sampsize/4; + scalerate = AVI->track[j].a_rate*sampsize/4; + } else { + avgbsec = 1000*AVI->track[j].mp3rate/8; + scalerate = 1000*AVI->track[j].mp3rate/8; + } + + OUT4CC ("LIST"); + OUTLONG(0); /* Length of list in bytes, don't know yet */ + strl_start = nhb; /* Store start position */ + OUT4CC ("strl"); + + /* The audio stream header */ + + OUT4CC ("strh"); + OUTLONG(56); /* # of bytes to follow */ + OUT4CC ("auds"); + + // ----------- + // ThOe + OUTLONG(0); /* Format (Optionally) */ + // ----------- + + OUTLONG(0); /* Flags */ + OUTLONG(0); /* Reserved, MS says: wPriority, wLanguage */ + OUTLONG(0); /* InitialFrames */ + + // VBR + if (AVI->track[j].a_fmt == 0x55 && AVI->track[j].a_vbr) { + OUTLONG(nBlockAlign); /* Scale */ + OUTLONG(AVI->track[j].a_rate); /* Rate */ + OUTLONG(0); /* Start */ + OUTLONG(AVI->track[j].audio_chunks); /* Length */ + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(0); /* Quality */ + OUTLONG(0); /* SampleSize */ + OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + } else { + OUTLONG(sampsize/4); /* Scale */ + OUTLONG(scalerate); /* Rate */ + OUTLONG(0); /* Start */ + OUTLONG(4*AVI->track[j].audio_bytes/sampsize); /* Length */ + OUTLONG(0); /* SuggestedBufferSize */ + OUTLONG(0xffffffff); /* Quality */ + OUTLONG(sampsize/4); /* SampleSize */ + OUTLONG(0); /* Frame */ + OUTLONG(0); /* Frame */ + } + + /* The audio stream format */ + + OUT4CC ("strf"); + + if (AVI->track[j].a_fmt == 0x55 && AVI->track[j].a_vbr) { + + OUTLONG(30); /* # of bytes to follow */ // mplayer writes 28 + OUTSHRT(AVI->track[j].a_fmt); /* Format */ // 2 + OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ // 2 + OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ // 4 + //ThOe/tibit + OUTLONG(1000*AVI->track[j].mp3rate/8); /* maybe we should write an avg. */ // 4 + OUTSHRT(nBlockAlign); /* BlockAlign */ // 2 + OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ // 2 + + OUTSHRT(12); /* cbSize */ // 2 + OUTSHRT(1); /* wID */ // 2 + OUTLONG(2); /* fdwFlags */ // 4 + OUTSHRT(nBlockAlign); /* nBlockSize */ // 2 + OUTSHRT(1); /* nFramesPerBlock */ // 2 + OUTSHRT(0); /* nCodecDelay */ // 2 + + } else if (AVI->track[j].a_fmt == 0x55 && !AVI->track[j].a_vbr) { + + OUTLONG(30); /* # of bytes to follow */ + OUTSHRT(AVI->track[j].a_fmt); /* Format */ + OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ + OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ + //ThOe/tibit + OUTLONG(1000*AVI->track[j].mp3rate/8); + OUTSHRT(sampsize/4); /* BlockAlign */ + OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ + + OUTSHRT(12); /* cbSize */ + OUTSHRT(1); /* wID */ + OUTLONG(2); /* fdwFlags */ + OUTSHRT(nBlockAlign); /* nBlockSize */ + OUTSHRT(1); /* nFramesPerBlock */ + OUTSHRT(0); /* nCodecDelay */ + + } else { + + OUTLONG(18); /* # of bytes to follow */ + OUTSHRT(AVI->track[j].a_fmt); /* Format */ + OUTSHRT(AVI->track[j].a_chans); /* Number of channels */ + OUTLONG(AVI->track[j].a_rate); /* SamplesPerSec */ + //ThOe/tibit + OUTLONG(avgbsec); /* Avg bytes/sec */ + OUTSHRT(sampsize/4); /* BlockAlign */ + OUTSHRT(AVI->track[j].a_bits); /* BitsPerSample */ + OUTSHRT(0); /* cbSize */ + + } + } + if (AVI->is_opendml) { + u32 k; + + if (!AVI->track[j].audio_superindex) { + // not initialized -> no index + continue; + } + + OUT4CC(AVI->track[j].audio_superindex->fcc); /* "indx" */ + OUTLONG(2+1+1+4+4+3*4 + AVI->track[j].audio_superindex->nEntriesInUse * (8+4+4)); + OUTSHRT(AVI->track[j].audio_superindex->wLongsPerEntry); + OUTCHR(AVI->track[j].audio_superindex->bIndexSubType); + OUTCHR(AVI->track[j].audio_superindex->bIndexType); + OUTLONG(AVI->track[j].audio_superindex->nEntriesInUse); + OUT4CC(AVI->track[j].audio_superindex->dwChunkId); + OUTLONG(0); + OUTLONG(0); + OUTLONG(0); + + for (k = 0; k < AVI->track[j].audio_superindex->nEntriesInUse; k++) { + u32 r = (u32) ((AVI->track[j].audio_superindex->aIndex[k].qwOffset >> 32) & 0xffffffff); + u32 s = (u32) ((AVI->track[j].audio_superindex->aIndex[k].qwOffset) & 0xffffffff); + + /* + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] AUD[%d] NrEntries %d/%ld (%c%c%c%c) |0x%llX|%ld|%ld| \n", j, k, + AVI->track[j].audio_superindex->nEntriesInUse, + AVI->track[j].audio_superindex->dwChunkId[0], AVI->track[j].audio_superindex->dwChunkId[1], + AVI->track[j].audio_superindex->dwChunkId[2], AVI->track[j].audio_superindex->dwChunkId[3], + AVI->track[j].audio_superindex->aIndex[k].qwOffset, + AVI->track[j].audio_superindex->aIndex[k].dwSize, + AVI->track[j].audio_superindex->aIndex[k].dwDuration + )); + */ + + OUTLONG(s); + OUTLONG(r); + OUTLONG(AVI->track[j].audio_superindex->aIndex[k].dwSize); + OUTLONG(AVI->track[j].audio_superindex->aIndex[k].dwDuration); + } + } + /* Finish stream list, i.e. put number of bytes in the list to proper pos */ + long2str(AVI_header+strl_start-4,nhb-strl_start); + } - if (AVI->is_opendml) { - OUT4CC("LIST"); - OUTLONG(16); - OUT4CC("odml"); - OUT4CC("dmlh"); - OUTLONG(4); - OUTLONG(AVI->total_frames); - } + if (AVI->is_opendml) { + OUT4CC("LIST"); + OUTLONG(16); + OUT4CC("odml"); + OUT4CC("dmlh"); + OUTLONG(4); + OUTLONG(AVI->total_frames); + } - /* Finish header list */ + /* Finish header list */ - long2str(AVI_header+hdrl_start-4,nhb-hdrl_start); + long2str(AVI_header+hdrl_start-4,nhb-hdrl_start); - // add INFO list --- (0.6.0pre4) + // add INFO list --- (0.6.0pre4) #ifdef INFO_LIST - OUT4CC ("LIST"); + OUT4CC ("LIST"); - info_start_pos = nhb; - info_len = MAX_INFO_STRLEN + 12; - OUTLONG(info_len); // rewritten later - OUT4CC ("INFO"); + info_start_pos = nhb; + info_len = MAX_INFO_STRLEN + 12; + OUTLONG(info_len); // rewritten later + OUT4CC ("INFO"); - OUT4CC ("ISFT"); - //OUTLONG(MAX_INFO_STRLEN); - memset(id_str, 0, MAX_INFO_STRLEN); + OUT4CC ("ISFT"); + //OUTLONG(MAX_INFO_STRLEN); + memset(id_str, 0, MAX_INFO_STRLEN); - sprintf(id_str, "%s-%s", PACKAGE, VERSION); - real_id_len = id_len = (u32) strlen(id_str)+1; - if (id_len&1) id_len++; + sprintf(id_str, "%s-%s", PACKAGE, VERSION); + real_id_len = id_len = (u32) strlen(id_str)+1; + if (id_len&1) id_len++; - OUTLONG(real_id_len); + OUTLONG(real_id_len); - memset(AVI_header+nhb, 0, id_len); - memcpy(AVI_header+nhb, id_str, id_len); - nhb += id_len; + memset(AVI_header+nhb, 0, id_len); + memcpy(AVI_header+nhb, id_str, id_len); + nhb += id_len; - info_len = 0; + info_len = 0; - // write correct len - long2str(AVI_header+info_start_pos, info_len + id_len + 4+4+4); + // write correct len + long2str(AVI_header+info_start_pos, info_len + id_len + 4+4+4); - nhb += info_len; + nhb += info_len; // OUT4CC ("ICMT"); // OUTLONG(MAX_INFO_STRLEN); @@ -1455,72 +1469,72 @@ static int avi_close_output_file(avi_t *AVI) // nhb += MAX_INFO_STRLEN; #endif - // ---------------------------- + // ---------------------------- - /* Calculate the needed amount of junk bytes, output junk */ + /* Calculate the needed amount of junk bytes, output junk */ - njunk = HEADERBYTES - nhb - 8 - 12; + njunk = HEADERBYTES - nhb - 8 - 12; - /* Safety first: if njunk <= 0, somebody has played with - HEADERBYTES without knowing what (s)he did. - This is a fatal error */ + /* Safety first: if njunk <= 0, somebody has played with + HEADERBYTES without knowing what (s)he did. + This is a fatal error */ - if(njunk<=0) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVI_close_output_file: # of header bytes too small\n")); - exit(1); - } + if(njunk<=0) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVI_close_output_file: # of header bytes too small\n")); + exit(1); + } - OUT4CC ("JUNK"); - OUTLONG(njunk); - memset(AVI_header+nhb,0,njunk); + OUT4CC ("JUNK"); + OUTLONG(njunk); + memset(AVI_header+nhb,0,njunk); - nhb += njunk; + nhb += njunk; - /* Start the movi list */ + /* Start the movi list */ - OUT4CC ("LIST"); - OUTLONG(movi_len); /* Length of list in bytes */ - OUT4CC ("movi"); + OUT4CC ("LIST"); + OUTLONG(movi_len); /* Length of list in bytes */ + OUT4CC ("movi"); - /* Output the header, truncate the file to the number of bytes - actually written, report an error if someting goes wrong */ + /* Output the header, truncate the file to the number of bytes + actually written, report an error if someting goes wrong */ - if ( (gf_f64_seek(AVI->fdes,0,SEEK_SET)==(u64)-1) || - avi_write(AVI->fdes,(char *)AVI_header,HEADERBYTES)!=HEADERBYTES + if ( (gf_f64_seek(AVI->fdes,0,SEEK_SET)==(u64)-1) || + avi_write(AVI->fdes,(char *)AVI_header,HEADERBYTES)!=HEADERBYTES // || ftruncate(AVI->fdes,AVI->pos)<0 - ) - { - AVI_errno = AVI_ERR_CLOSE; - return -1; - } + ) + { + AVI_errno = AVI_ERR_CLOSE; + return -1; + } - // Fix up the empty additional RIFF and LIST chunks - if (AVI->is_opendml) { - u32 k; - char f[4]; - u32 len; - - for (k=1; kvideo_superindex->nEntriesInUse; k++) { - // the len of the RIFF Chunk - gf_f64_seek(AVI->fdes, AVI->video_superindex->stdindex[k]->qwBaseOffset+4, SEEK_SET); - len = (u32) (AVI->video_superindex->stdindex[k+1]->qwBaseOffset - AVI->video_superindex->stdindex[k]->qwBaseOffset - 8); - long2str((unsigned char *)f, len); - avi_write(AVI->fdes, f, 4); - - // len of the LIST/movi chunk - gf_f64_seek(AVI->fdes, 8, SEEK_CUR); - len -= 12; - long2str((unsigned char *)f, len); - avi_write(AVI->fdes, f, 4); - } - } + // Fix up the empty additional RIFF and LIST chunks + if (AVI->is_opendml) { + u32 k; + char f[4]; + u32 len; + + for (k=1; kvideo_superindex->nEntriesInUse; k++) { + // the len of the RIFF Chunk + gf_f64_seek(AVI->fdes, AVI->video_superindex->stdindex[k]->qwBaseOffset+4, SEEK_SET); + len = (u32) (AVI->video_superindex->stdindex[k+1]->qwBaseOffset - AVI->video_superindex->stdindex[k]->qwBaseOffset - 8); + long2str((unsigned char *)f, len); + avi_write(AVI->fdes, f, 4); + + // len of the LIST/movi chunk + gf_f64_seek(AVI->fdes, 8, SEEK_CUR); + len -= 12; + long2str((unsigned char *)f, len); + avi_write(AVI->fdes, f, 4); + } + } - if(idxerror) return -1; + if(idxerror) return -1; - return 0; + return 0; } /* @@ -1535,165 +1549,177 @@ static int avi_close_output_file(avi_t *AVI) static int avi_write_data(avi_t *AVI, char *data, unsigned long length, int audio, int keyframe) { - int n = 0; + int n = 0; - unsigned char astr[5]; + unsigned char astr[5]; - // transcode core itself checks for the size -- unneeded and - // does harm to xvid 2pass encodes where the first pass can get - // _very_ large -- tibit. + // transcode core itself checks for the size -- unneeded and + // does harm to xvid 2pass encodes where the first pass can get + // _very_ large -- tibit. #if 0 - /* Check for maximum file length */ + /* Check for maximum file length */ - if ( (AVI->pos + 8 + length + 8 + (AVI->n_idx+1)*16) > AVI_MAX_LEN ) { - AVI_errno = AVI_ERR_SIZELIM; - return -1; - } + if ( (AVI->pos + 8 + length + 8 + (AVI->n_idx+1)*16) > AVI_MAX_LEN ) { + AVI_errno = AVI_ERR_SIZELIM; + return -1; + } #endif - /* Add index entry */ + /* Add index entry */ - //set tag for current audio track - sprintf((char *)astr, "0%1dwb", (int)(AVI->aptr+1)); + //set tag for current audio track + sprintf((char *)astr, "0%1dwb", (int)(AVI->aptr+1)); - if(audio) { - if (!AVI->is_opendml) n = avi_add_index_entry(AVI,astr,0x10,AVI->pos,length); - n += avi_add_odml_index_entry(AVI,astr,0x10,AVI->pos,length); - } else { - if (!AVI->is_opendml) n = avi_add_index_entry(AVI,(unsigned char *)"00db",((keyframe)?0x10:0x0),AVI->pos,length); - n += avi_add_odml_index_entry(AVI,(unsigned char *)"00db",((keyframe)?0x10:0x0),AVI->pos,length); - } + if(audio) { + if (!AVI->is_opendml) n = avi_add_index_entry(AVI,astr,0x10,AVI->pos,length); + n += avi_add_odml_index_entry(AVI,astr,0x10,AVI->pos,length); + } else { + if (!AVI->is_opendml) n = avi_add_index_entry(AVI,(unsigned char *)"00db",((keyframe)?0x10:0x0),AVI->pos,length); + n += avi_add_odml_index_entry(AVI,(unsigned char *)"00db",((keyframe)?0x10:0x0),AVI->pos,length); + } - if(n) return -1; + if(n) return -1; - /* Output tag and data */ + /* Output tag and data */ - if(audio) - n = avi_add_chunk(AVI,(unsigned char *)astr, (unsigned char *)data, length); - else - n = avi_add_chunk(AVI,(unsigned char *)"00db", (unsigned char *)data, length); + if(audio) + n = avi_add_chunk(AVI,(unsigned char *)astr, (unsigned char *)data, length); + else + n = avi_add_chunk(AVI,(unsigned char *)"00db", (unsigned char *)data, length); - if (n) return -1; + if (n) return -1; - return 0; + return 0; } GF_EXPORT int AVI_write_frame(avi_t *AVI, char *data, long bytes, int keyframe) { - s64 pos; + s64 pos; - if(AVI->mode==AVI_MODE_READ) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_READ) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - pos = AVI->pos; + pos = AVI->pos; - if(avi_write_data(AVI,data,bytes,0,keyframe)) return -1; + if(avi_write_data(AVI,data,bytes,0,keyframe)) return -1; - AVI->last_pos = pos; - AVI->last_len = bytes; - AVI->video_frames++; - return 0; + AVI->last_pos = pos; + AVI->last_len = bytes; + AVI->video_frames++; + return 0; } int AVI_dup_frame(avi_t *AVI) { - if(AVI->mode==AVI_MODE_READ) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_READ) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - if(AVI->last_pos==0) return 0; /* No previous real frame */ - if(avi_add_index_entry(AVI,(unsigned char *)"00db",0x10,AVI->last_pos,AVI->last_len)) return -1; - AVI->video_frames++; - AVI->must_use_index = 1; - return 0; + if(AVI->last_pos==0) return 0; /* No previous real frame */ + if(avi_add_index_entry(AVI,(unsigned char *)"00db",0x10,AVI->last_pos,AVI->last_len)) return -1; + AVI->video_frames++; + AVI->must_use_index = 1; + return 0; } int AVI_write_audio(avi_t *AVI, char *data, long bytes) { - if(AVI->mode==AVI_MODE_READ) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_READ) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - if( avi_write_data(AVI,data,bytes,1,0) ) return -1; - AVI->track[AVI->aptr].audio_bytes += bytes; - AVI->track[AVI->aptr].audio_chunks++; - return 0; + if( avi_write_data(AVI,data,bytes,1,0) ) return -1; + AVI->track[AVI->aptr].audio_bytes += bytes; + AVI->track[AVI->aptr].audio_chunks++; + return 0; } int AVI_append_audio(avi_t *AVI, char *data, long bytes) { - // won't work for >2gb - long i, length, pos; - unsigned char c[4]; + // won't work for >2gb + long i, length, pos; + unsigned char c[4]; - if(AVI->mode==AVI_MODE_READ) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_READ) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - // update last index entry: + // update last index entry: - --AVI->n_idx; - length = str2ulong(AVI->idx[AVI->n_idx]+12); - pos = str2ulong(AVI->idx[AVI->n_idx]+8); + --AVI->n_idx; + length = str2ulong(AVI->idx[AVI->n_idx]+12); + pos = str2ulong(AVI->idx[AVI->n_idx]+8); - //update; - long2str(AVI->idx[AVI->n_idx]+12,length+bytes); + //update; + long2str(AVI->idx[AVI->n_idx]+12,length+bytes); - ++AVI->n_idx; + ++AVI->n_idx; - AVI->track[AVI->aptr].audio_bytes += bytes; + AVI->track[AVI->aptr].audio_bytes += bytes; - //update chunk header - gf_f64_seek(AVI->fdes, pos+4, SEEK_SET); - long2str(c, length+bytes); - avi_write(AVI->fdes, (char *)c, 4); + //update chunk header + gf_f64_seek(AVI->fdes, pos+4, SEEK_SET); + long2str(c, length+bytes); + avi_write(AVI->fdes, (char *)c, 4); - gf_f64_seek(AVI->fdes, pos+8+length, SEEK_SET); + gf_f64_seek(AVI->fdes, pos+8+length, SEEK_SET); - i=PAD_EVEN(length + bytes); + i=PAD_EVEN(length + bytes); - bytes = i - length; - avi_write(AVI->fdes, data, bytes); - AVI->pos = pos + 8 + i; + bytes = i - length; + avi_write(AVI->fdes, data, bytes); + AVI->pos = pos + 8 + i; - return 0; + return 0; } u64 AVI_bytes_remain(avi_t *AVI) { - if(AVI->mode==AVI_MODE_READ) return 0; + if(AVI->mode==AVI_MODE_READ) return 0; - return ( AVI_MAX_LEN - (AVI->pos + 8 + 16*AVI->n_idx)); + return ( AVI_MAX_LEN - (AVI->pos + 8 + 16*AVI->n_idx)); } u64 AVI_bytes_written(avi_t *AVI) { - if(AVI->mode==AVI_MODE_READ) return 0; + if(AVI->mode==AVI_MODE_READ) return 0; - return (AVI->pos + 8 + 16*AVI->n_idx); + return (AVI->pos + 8 + 16*AVI->n_idx); } int AVI_set_audio_track(avi_t *AVI, u32 track) { - if (track + 1 > AVI->anum) return(-1); + if (track + 1 > AVI->anum) return(-1); - //this info is not written to file anyway - AVI->aptr=track; - return 0; + //this info is not written to file anyway + AVI->aptr=track; + return 0; } int AVI_get_audio_track(avi_t *AVI) { - return(AVI->aptr); + return(AVI->aptr); } void AVI_set_audio_vbr(avi_t *AVI, long is_vbr) { - AVI->track[AVI->aptr].a_vbr = is_vbr; + AVI->track[AVI->aptr].a_vbr = is_vbr; } long AVI_get_audio_vbr(avi_t *AVI) { - return(AVI->track[AVI->aptr].a_vbr); + return(AVI->track[AVI->aptr].a_vbr); } @@ -1706,54 +1732,54 @@ long AVI_get_audio_vbr(avi_t *AVI) GF_EXPORT int AVI_close(avi_t *AVI) { - int ret; - u32 j; - - /* If the file was open for writing, the header and index still have - to be written */ - - if(AVI->mode == AVI_MODE_WRITE) - ret = avi_close_output_file(AVI); - else - ret = 0; - - /* Even if there happened an error, we first clean up */ - - fclose(AVI->fdes); - if(AVI->idx) gf_free(AVI->idx); - if(AVI->video_index) gf_free(AVI->video_index); - if(AVI->video_superindex) { - if(AVI->video_superindex->aIndex) gf_free(AVI->video_superindex->aIndex); - if (AVI->video_superindex->stdindex) { - for (j=0; j < NR_IXNN_CHUNKS; j++) { - if (AVI->video_superindex->stdindex[j]->aIndex) - gf_free(AVI->video_superindex->stdindex[j]->aIndex); - gf_free(AVI->video_superindex->stdindex[j]); - } - gf_free(AVI->video_superindex->stdindex); - } - gf_free(AVI->video_superindex); - } + int ret; + u32 j; + + /* If the file was open for writing, the header and index still have + to be written */ + + if(AVI->mode == AVI_MODE_WRITE) + ret = avi_close_output_file(AVI); + else + ret = 0; + + /* Even if there happened an error, we first clean up */ + + fclose(AVI->fdes); + if(AVI->idx) gf_free(AVI->idx); + if(AVI->video_index) gf_free(AVI->video_index); + if(AVI->video_superindex) { + if(AVI->video_superindex->aIndex) gf_free(AVI->video_superindex->aIndex); + if (AVI->video_superindex->stdindex) { + for (j=0; j < NR_IXNN_CHUNKS; j++) { + if (AVI->video_superindex->stdindex[j]->aIndex) + gf_free(AVI->video_superindex->stdindex[j]->aIndex); + gf_free(AVI->video_superindex->stdindex[j]); + } + gf_free(AVI->video_superindex->stdindex); + } + gf_free(AVI->video_superindex); + } - for (j=0; janum; j++) - { - if(AVI->track[j].audio_index) gf_free(AVI->track[j].audio_index); - if(AVI->track[j].audio_superindex) { - if(AVI->track[j].audio_superindex->aIndex) gf_free(AVI->track[j].audio_superindex->aIndex); - gf_free(AVI->track[j].audio_superindex); - } - } + for (j=0; janum; j++) + { + if(AVI->track[j].audio_index) gf_free(AVI->track[j].audio_index); + if(AVI->track[j].audio_superindex) { + if(AVI->track[j].audio_superindex->aIndex) gf_free(AVI->track[j].audio_superindex->aIndex); + gf_free(AVI->track[j].audio_superindex); + } + } - if (AVI->bitmap_info_header) - gf_free(AVI->bitmap_info_header); - for (j = 0; j < AVI->anum; j++) - if (AVI->wave_format_ex[j]) - gf_free(AVI->wave_format_ex[j]); + if (AVI->bitmap_info_header) + gf_free(AVI->bitmap_info_header); + for (j = 0; j < AVI->anum; j++) + if (AVI->wave_format_ex[j]) + gf_free(AVI->wave_format_ex[j]); - gf_free(AVI); - AVI=NULL; + gf_free(AVI); + AVI=NULL; - return ret; + return ret; } @@ -1767,1134 +1793,1237 @@ int AVI_close(avi_t *AVI) avi_t *AVI_open_input_file(char *filename, int getIndex) { - avi_t *AVI=NULL; + avi_t *AVI=NULL; - /* Create avi_t structure */ + /* Create avi_t structure */ - AVI = (avi_t *) gf_malloc(sizeof(avi_t)); - if(AVI==NULL) - { - AVI_errno = AVI_ERR_NO_MEM; - return 0; - } - memset((void *)AVI,0,sizeof(avi_t)); + AVI = (avi_t *) gf_malloc(sizeof(avi_t)); + if(AVI==NULL) + { + AVI_errno = AVI_ERR_NO_MEM; + return 0; + } + memset((void *)AVI,0,sizeof(avi_t)); - AVI->mode = AVI_MODE_READ; /* open for reading */ + AVI->mode = AVI_MODE_READ; /* open for reading */ - /* Open the file */ + /* Open the file */ - AVI->fdes = gf_f64_open(filename,"rb"); - if(!AVI->fdes ) - { - AVI_errno = AVI_ERR_OPEN; - gf_free(AVI); - return 0; - } + AVI->fdes = gf_f64_open(filename,"rb"); + if(!AVI->fdes ) + { + AVI_errno = AVI_ERR_OPEN; + gf_free(AVI); + return 0; + } - AVI_errno = 0; - avi_parse_input_file(AVI, getIndex); + AVI_errno = 0; + avi_parse_input_file(AVI, getIndex); - if (AVI != NULL && !AVI_errno) { - AVI->aptr=0; //reset - } + if (AVI != NULL && !AVI_errno) { + AVI->aptr=0; //reset + } - if (AVI_errno) return NULL; + if (AVI_errno) return NULL; - return AVI; + return AVI; } avi_t *AVI_open_fd(FILE *fd, int getIndex) { - avi_t *AVI=NULL; + avi_t *AVI=NULL; - /* Create avi_t structure */ + /* Create avi_t structure */ - AVI = (avi_t *) gf_malloc(sizeof(avi_t)); - if(AVI==NULL) - { - AVI_errno = AVI_ERR_NO_MEM; - return 0; - } - memset((void *)AVI,0,sizeof(avi_t)); + AVI = (avi_t *) gf_malloc(sizeof(avi_t)); + if(AVI==NULL) + { + AVI_errno = AVI_ERR_NO_MEM; + return 0; + } + memset((void *)AVI,0,sizeof(avi_t)); - AVI->mode = AVI_MODE_READ; /* open for reading */ + AVI->mode = AVI_MODE_READ; /* open for reading */ - // file alread open - AVI->fdes = fd; + // file alread open + AVI->fdes = fd; - AVI_errno = 0; - avi_parse_input_file(AVI, getIndex); + AVI_errno = 0; + avi_parse_input_file(AVI, getIndex); - if (AVI != NULL && !AVI_errno) { - AVI->aptr=0; //reset - } + if (AVI != NULL && !AVI_errno) { + AVI->aptr=0; //reset + } - if (AVI_errno) - return AVI=NULL; - else - return AVI; + if (AVI_errno) + return AVI=NULL; + else + return AVI; } int avi_parse_input_file(avi_t *AVI, int getIndex) { - long i, rate, scale, idx_type; - s64 n; - unsigned char *hdrl_data; - u64 header_offset=0; - long hdrl_len=0; - long nvi, nai[AVI_MAX_TRACKS], ioff; - u64 tot[AVI_MAX_TRACKS]; - u32 j; - int lasttag = 0; - int vids_strh_seen = 0; - int vids_strf_seen = 0; - int auds_strh_seen = 0; - // int auds_strf_seen = 0; - int num_stream = 0; - char data[256]; - s64 oldpos=-1, newpos=-1; - - long aud_chunks = 0; - /* Read first 12 bytes and check that this is an AVI file */ - - if( avi_read(AVI->fdes,data,12) != 12 ) ERR_EXIT(AVI_ERR_READ) - - if( strnicmp(data ,"RIFF",4) !=0 || - strnicmp(data+8,"AVI ",4) !=0 ) ERR_EXIT(AVI_ERR_NO_AVI) - - /* Go through the AVI file and extract the header list, - the start position of the 'movi' list and an optionally - present idx1 tag */ - - hdrl_data = 0; - - - while(1) - { - if( avi_read(AVI->fdes,data,8) != 8 ) break; /* We assume it's EOF */ - newpos = gf_f64_tell(AVI->fdes); - if(oldpos==newpos) { - /* This is a broken AVI stream... */ - return -1; - } - oldpos=newpos; - - n = str2ulong((unsigned char *)data+4); - n = PAD_EVEN(n); - - if(strnicmp(data,"LIST",4) == 0) - { - if( avi_read(AVI->fdes,data,4) != 4 ) ERR_EXIT(AVI_ERR_READ) - n -= 4; - if(strnicmp(data,"hdrl",4) == 0) - { - hdrl_len = (u32) n; - hdrl_data = (unsigned char *) gf_malloc((u32)n); - if(hdrl_data==0) ERR_EXIT(AVI_ERR_NO_MEM); - - // offset of header - - header_offset = gf_f64_tell(AVI->fdes); - - if( avi_read(AVI->fdes,(char *)hdrl_data, (u32) n) != n ) ERR_EXIT(AVI_ERR_READ) - } - else if(strnicmp(data,"movi",4) == 0) - { - AVI->movi_start = gf_f64_tell(AVI->fdes); - if (gf_f64_seek(AVI->fdes,n,SEEK_CUR)==(u64)-1) break; - } - else - if (gf_f64_seek(AVI->fdes,n,SEEK_CUR)==(u64)-1) break; - } - else if(strnicmp(data,"idx1",4) == 0) - { - /* n must be a multiple of 16, but the reading does not - break if this is not the case */ - - AVI->n_idx = AVI->max_idx = (u32) (n/16); - AVI->idx = (unsigned char((*)[16]) ) gf_malloc((u32)n); - if(AVI->idx==0) ERR_EXIT(AVI_ERR_NO_MEM) - if(avi_read(AVI->fdes, (char *) AVI->idx, (u32) n) != n ) { - gf_free( AVI->idx); AVI->idx=NULL; - AVI->n_idx = 0; - } - } - else - gf_f64_seek(AVI->fdes,n,SEEK_CUR); - } + long i, rate, scale, idx_type; + s64 n; + unsigned char *hdrl_data; + u64 header_offset=0; + long hdrl_len=0; + long nvi, nai[AVI_MAX_TRACKS], ioff; + u64 tot[AVI_MAX_TRACKS]; + u32 j; + int lasttag = 0; + int vids_strh_seen = 0; + int vids_strf_seen = 0; + int auds_strh_seen = 0; + // int auds_strf_seen = 0; + int num_stream = 0; + char data[256]; + s64 oldpos=-1, newpos=-1; + + long aud_chunks = 0; + /* Read first 12 bytes and check that this is an AVI file */ + + if( avi_read(AVI->fdes,data,12) != 12 ) ERR_EXIT(AVI_ERR_READ) + + if( strnicmp(data ,"RIFF",4) !=0 || + strnicmp(data+8,"AVI ",4) !=0 ) ERR_EXIT(AVI_ERR_NO_AVI) + + /* Go through the AVI file and extract the header list, + the start position of the 'movi' list and an optionally + present idx1 tag */ + + hdrl_data = 0; + + + while(1) + { + if( avi_read(AVI->fdes,data,8) != 8 ) break; /* We assume it's EOF */ + newpos = gf_f64_tell(AVI->fdes); + if(oldpos==newpos) { + /* This is a broken AVI stream... */ + return -1; + } + oldpos=newpos; + + n = str2ulong((unsigned char *)data+4); + n = PAD_EVEN(n); + + if(strnicmp(data,"LIST",4) == 0) + { + if( avi_read(AVI->fdes,data,4) != 4 ) ERR_EXIT(AVI_ERR_READ) + n -= 4; + if(strnicmp(data,"hdrl",4) == 0) + { + hdrl_len = (u32) n; + hdrl_data = (unsigned char *) gf_malloc((u32)n); + if(hdrl_data==0) ERR_EXIT(AVI_ERR_NO_MEM); + + // offset of header + + header_offset = gf_f64_tell(AVI->fdes); + + if( avi_read(AVI->fdes,(char *)hdrl_data, (u32) n) != n ) ERR_EXIT(AVI_ERR_READ) + } + else if(strnicmp(data,"movi",4) == 0) + { + AVI->movi_start = gf_f64_tell(AVI->fdes); + if (gf_f64_seek(AVI->fdes,n,SEEK_CUR)==(u64)-1) break; + } + else if (gf_f64_seek(AVI->fdes,n,SEEK_CUR)==(u64)-1) break; + } + else if(strnicmp(data,"idx1",4) == 0) + { + /* n must be a multiple of 16, but the reading does not + break if this is not the case */ + + AVI->n_idx = AVI->max_idx = (u32) (n/16); + AVI->idx = (unsigned char((*)[16]) ) gf_malloc((u32)n); + if(AVI->idx==0) ERR_EXIT(AVI_ERR_NO_MEM) + if(avi_read(AVI->fdes, (char *) AVI->idx, (u32) n) != n ) { + gf_free( AVI->idx); + AVI->idx=NULL; + AVI->n_idx = 0; + } + } + else + gf_f64_seek(AVI->fdes,n,SEEK_CUR); + } - if(!hdrl_data ) ERR_EXIT(AVI_ERR_NO_HDRL) - if(!AVI->movi_start) ERR_EXIT(AVI_ERR_NO_MOVI) + if(!hdrl_data ) ERR_EXIT(AVI_ERR_NO_HDRL) + if(!AVI->movi_start) ERR_EXIT(AVI_ERR_NO_MOVI) - /* Interpret the header list */ + /* Interpret the header list */ - for(i=0;icompressor,hdrl_data+i+4,4); - AVI->compressor[4] = 0; - - // ThOe - AVI->v_codech_off = header_offset + i+4; - - scale = str2ulong(hdrl_data+i+20); - rate = str2ulong(hdrl_data+i+24); - if(scale!=0) AVI->fps = (double)rate/(double)scale; - AVI->video_frames = str2ulong(hdrl_data+i+32); - AVI->video_strn = num_stream; - AVI->max_len = 0; - vids_strh_seen = 1; - lasttag = 1; /* vids */ - memcpy(&AVI->video_stream_header, hdrl_data + i, - sizeof(alAVISTREAMHEADER)); - } - else if (strnicmp ((char *)hdrl_data+i,"auds",4) ==0 && ! auds_strh_seen) - { - - //inc audio tracks - AVI->aptr=AVI->anum; - ++AVI->anum; - - if(AVI->anum > AVI_MAX_TRACKS) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] error - only %d audio tracks supported\n", AVI_MAX_TRACKS)); - return(-1); - } - - AVI->track[AVI->aptr].audio_bytes = str2ulong(hdrl_data+i+32)*avi_sampsize(AVI, 0); - AVI->track[AVI->aptr].audio_strn = num_stream; - - // if samplesize==0 -> vbr - AVI->track[AVI->aptr].a_vbr = !str2ulong(hdrl_data+i+44); - - AVI->track[AVI->aptr].padrate = str2ulong(hdrl_data+i+24); - memcpy(&AVI->stream_headers[AVI->aptr], hdrl_data + i, - sizeof(alAVISTREAMHEADER)); - - // auds_strh_seen = 1; - lasttag = 2; /* auds */ - - // ThOe - AVI->track[AVI->aptr].a_codech_off = header_offset + i; - - } - else if (strnicmp ((char*)hdrl_data+i,"iavs",4) ==0 && ! auds_strh_seen) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVILIB: error - DV AVI Type 1 no supported\n")); - return (-1); - } - else - lasttag = 0; - num_stream++; - } - else if(strnicmp((char*)hdrl_data+i,"dmlh",4) == 0) { - AVI->total_frames = str2ulong(hdrl_data+i+8); + if(strnicmp((char *)hdrl_data+i,"vids",4) == 0 && !vids_strh_seen) + { + memcpy(AVI->compressor,hdrl_data+i+4,4); + AVI->compressor[4] = 0; + + // ThOe + AVI->v_codech_off = header_offset + i+4; + + scale = str2ulong(hdrl_data+i+20); + rate = str2ulong(hdrl_data+i+24); + if(scale!=0) AVI->fps = (double)rate/(double)scale; + AVI->video_frames = str2ulong(hdrl_data+i+32); + AVI->video_strn = num_stream; + AVI->max_len = 0; + vids_strh_seen = 1; + lasttag = 1; /* vids */ + memcpy(&AVI->video_stream_header, hdrl_data + i, + sizeof(alAVISTREAMHEADER)); + } + else if (strnicmp ((char *)hdrl_data+i,"auds",4) ==0 && ! auds_strh_seen) + { + + //inc audio tracks + AVI->aptr=AVI->anum; + ++AVI->anum; + + if(AVI->anum > AVI_MAX_TRACKS) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] error - only %d audio tracks supported\n", AVI_MAX_TRACKS)); + return(-1); + } + + AVI->track[AVI->aptr].audio_bytes = str2ulong(hdrl_data+i+32)*avi_sampsize(AVI, 0); + AVI->track[AVI->aptr].audio_strn = num_stream; + + // if samplesize==0 -> vbr + AVI->track[AVI->aptr].a_vbr = !str2ulong(hdrl_data+i+44); + + AVI->track[AVI->aptr].padrate = str2ulong(hdrl_data+i+24); + memcpy(&AVI->stream_headers[AVI->aptr], hdrl_data + i, + sizeof(alAVISTREAMHEADER)); + + // auds_strh_seen = 1; + lasttag = 2; /* auds */ + + // ThOe + AVI->track[AVI->aptr].a_codech_off = header_offset + i; + + } + else if (strnicmp ((char*)hdrl_data+i,"iavs",4) ==0 && ! auds_strh_seen) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] AVILIB: error - DV AVI Type 1 no supported\n")); + return (-1); + } + else + lasttag = 0; + num_stream++; + } + else if(strnicmp((char*)hdrl_data+i,"dmlh",4) == 0) { + AVI->total_frames = str2ulong(hdrl_data+i+8); #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] real number of frames %d\n", AVI->total_frames)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] real number of frames %d\n", AVI->total_frames)); #endif - i += 8; - } - else if(strnicmp((char *)hdrl_data+i,"strf",4)==0) - { - i += 8; - if(lasttag == 1) - { - alBITMAPINFOHEADER bih; - - memcpy(&bih, hdrl_data + i, sizeof(alBITMAPINFOHEADER)); - AVI->bitmap_info_header = (alBITMAPINFOHEADER *) - gf_malloc(str2ulong((unsigned char *)&bih.bi_size)); - if (AVI->bitmap_info_header != NULL) - memcpy(AVI->bitmap_info_header, hdrl_data + i, - str2ulong((unsigned char *)&bih.bi_size)); - - AVI->width = str2ulong(hdrl_data+i+4); - AVI->height = str2ulong(hdrl_data+i+8); - vids_strf_seen = 1; - //ThOe - AVI->v_codecf_off = header_offset + i+16; - - memcpy(AVI->compressor2, hdrl_data+i+16, 4); - AVI->compressor2[4] = 0; - - } - else if(lasttag == 2) - { - alWAVEFORMATEX *wfe; - char *nwfe; - int wfes; - - if ((u32) (hdrl_len - i) < sizeof(alWAVEFORMATEX)) - wfes = hdrl_len - i; - else - wfes = sizeof(alWAVEFORMATEX); - wfe = (alWAVEFORMATEX *)gf_malloc(sizeof(alWAVEFORMATEX)); - if (wfe != NULL) { - memset(wfe, 0, sizeof(alWAVEFORMATEX)); - memcpy(wfe, hdrl_data + i, wfes); - if (str2ushort((unsigned char *)&wfe->cb_size) != 0) { - nwfe = (char *) - gf_realloc(wfe, sizeof(alWAVEFORMATEX) + - str2ushort((unsigned char *)&wfe->cb_size)); - if (nwfe != 0) { - s64 lpos = gf_f64_tell(AVI->fdes); - gf_f64_seek(AVI->fdes, header_offset + i + sizeof(alWAVEFORMATEX), - SEEK_SET); - wfe = (alWAVEFORMATEX *)nwfe; - nwfe = &nwfe[sizeof(alWAVEFORMATEX)]; - avi_read(AVI->fdes, nwfe, - str2ushort((unsigned char *)&wfe->cb_size)); - gf_f64_seek(AVI->fdes, lpos, SEEK_SET); - } - } - AVI->wave_format_ex[AVI->aptr] = wfe; - } - - AVI->track[AVI->aptr].a_fmt = str2ushort(hdrl_data+i ); - - //ThOe - AVI->track[AVI->aptr].a_codecf_off = header_offset + i; - - AVI->track[AVI->aptr].a_chans = str2ushort(hdrl_data+i+2); - AVI->track[AVI->aptr].a_rate = str2ulong (hdrl_data+i+4); - //ThOe: read mp3bitrate - AVI->track[AVI->aptr].mp3rate = 8*str2ulong(hdrl_data+i+8)/1000; - //:ThOe - AVI->track[AVI->aptr].a_bits = str2ushort(hdrl_data+i+14); - // auds_strf_seen = 1; - } - } - else if(strnicmp((char*)hdrl_data+i,"indx",4) == 0) { - char *a; - - if(lasttag == 1) // V I D E O - { - - a = (char*)hdrl_data+i; - - AVI->video_superindex = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk)); - memset(AVI->video_superindex, 0, sizeof (avisuperindex_chunk)); - memcpy (AVI->video_superindex->fcc, a, 4); a += 4; - AVI->video_superindex->dwSize = str2ulong((unsigned char *)a); a += 4; - AVI->video_superindex->wLongsPerEntry = str2ushort((unsigned char *)a); a += 2; - AVI->video_superindex->bIndexSubType = *a; a += 1; - AVI->video_superindex->bIndexType = *a; a += 1; - AVI->video_superindex->nEntriesInUse = str2ulong((unsigned char *)a); a += 4; - memcpy (AVI->video_superindex->dwChunkId, a, 4); a += 4; - - // 3 * reserved - a += 4; a += 4; a += 4; - - if (AVI->video_superindex->bIndexSubType != 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Invalid Header, bIndexSubType != 0\n")); - } - - AVI->video_superindex->aIndex = (avisuperindex_entry*) - gf_malloc (AVI->video_superindex->wLongsPerEntry * AVI->video_superindex->nEntriesInUse * sizeof (u32)); - - // position of ix## chunks - for (j=0; jvideo_superindex->nEntriesInUse; ++j) { - AVI->video_superindex->aIndex[j].qwOffset = str2ullong ((unsigned char*)a); a += 8; - AVI->video_superindex->aIndex[j].dwSize = str2ulong ((unsigned char*)a); a += 4; - AVI->video_superindex->aIndex[j].dwDuration = str2ulong ((unsigned char*)a); a += 4; + i += 8; + } + else if(strnicmp((char *)hdrl_data+i,"strf",4)==0) + { + i += 8; + if(lasttag == 1) + { + alBITMAPINFOHEADER bih; + + memcpy(&bih, hdrl_data + i, sizeof(alBITMAPINFOHEADER)); + AVI->bitmap_info_header = (alBITMAPINFOHEADER *) + gf_malloc(str2ulong((unsigned char *)&bih.bi_size)); + if (AVI->bitmap_info_header != NULL) + memcpy(AVI->bitmap_info_header, hdrl_data + i, + str2ulong((unsigned char *)&bih.bi_size)); + + AVI->width = str2ulong(hdrl_data+i+4); + AVI->height = str2ulong(hdrl_data+i+8); + vids_strf_seen = 1; + //ThOe + AVI->v_codecf_off = header_offset + i+16; + + memcpy(AVI->compressor2, hdrl_data+i+16, 4); + AVI->compressor2[4] = 0; + + } + else if(lasttag == 2) + { + alWAVEFORMATEX *wfe; + char *nwfe; + int wfes; + + if ((u32) (hdrl_len - i) < sizeof(alWAVEFORMATEX)) + wfes = hdrl_len - i; + else + wfes = sizeof(alWAVEFORMATEX); + wfe = (alWAVEFORMATEX *)gf_malloc(sizeof(alWAVEFORMATEX)); + if (wfe != NULL) { + memset(wfe, 0, sizeof(alWAVEFORMATEX)); + memcpy(wfe, hdrl_data + i, wfes); + if (str2ushort((unsigned char *)&wfe->cb_size) != 0) { + nwfe = (char *) + gf_realloc(wfe, sizeof(alWAVEFORMATEX) + + str2ushort((unsigned char *)&wfe->cb_size)); + if (nwfe != 0) { + s64 lpos = gf_f64_tell(AVI->fdes); + gf_f64_seek(AVI->fdes, header_offset + i + sizeof(alWAVEFORMATEX), + SEEK_SET); + wfe = (alWAVEFORMATEX *)nwfe; + nwfe = &nwfe[sizeof(alWAVEFORMATEX)]; + avi_read(AVI->fdes, nwfe, + str2ushort((unsigned char *)&wfe->cb_size)); + gf_f64_seek(AVI->fdes, lpos, SEEK_SET); + } + } + AVI->wave_format_ex[AVI->aptr] = wfe; + } + + AVI->track[AVI->aptr].a_fmt = str2ushort(hdrl_data+i ); + + //ThOe + AVI->track[AVI->aptr].a_codecf_off = header_offset + i; + + AVI->track[AVI->aptr].a_chans = str2ushort(hdrl_data+i+2); + AVI->track[AVI->aptr].a_rate = str2ulong (hdrl_data+i+4); + //ThOe: read mp3bitrate + AVI->track[AVI->aptr].mp3rate = 8*str2ulong(hdrl_data+i+8)/1000; + //:ThOe + AVI->track[AVI->aptr].a_bits = str2ushort(hdrl_data+i+14); + // auds_strf_seen = 1; + } + } + else if(strnicmp((char*)hdrl_data+i,"indx",4) == 0) { + char *a; + + if(lasttag == 1) // V I D E O + { + + a = (char*)hdrl_data+i; + + AVI->video_superindex = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk)); + memset(AVI->video_superindex, 0, sizeof (avisuperindex_chunk)); + memcpy (AVI->video_superindex->fcc, a, 4); + a += 4; + AVI->video_superindex->dwSize = str2ulong((unsigned char *)a); + a += 4; + AVI->video_superindex->wLongsPerEntry = str2ushort((unsigned char *)a); + a += 2; + AVI->video_superindex->bIndexSubType = *a; + a += 1; + AVI->video_superindex->bIndexType = *a; + a += 1; + AVI->video_superindex->nEntriesInUse = str2ulong((unsigned char *)a); + a += 4; + memcpy (AVI->video_superindex->dwChunkId, a, 4); + a += 4; + + // 3 * reserved + a += 4; + a += 4; + a += 4; + + if (AVI->video_superindex->bIndexSubType != 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Invalid Header, bIndexSubType != 0\n")); + } + + AVI->video_superindex->aIndex = (avisuperindex_entry*) + gf_malloc (AVI->video_superindex->wLongsPerEntry * AVI->video_superindex->nEntriesInUse * sizeof (u32)); + + // position of ix## chunks + for (j=0; jvideo_superindex->nEntriesInUse; ++j) { + AVI->video_superindex->aIndex[j].qwOffset = str2ullong ((unsigned char*)a); + a += 8; + AVI->video_superindex->aIndex[j].dwSize = str2ulong ((unsigned char*)a); + a += 4; + AVI->video_superindex->aIndex[j].dwDuration = str2ulong ((unsigned char*)a); + a += 4; #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] 0x%llx 0x%lx %lu\n", j, - (unsigned long long)AVI->video_superindex->aIndex[j].qwOffset, - (unsigned long)AVI->video_superindex->aIndex[j].dwSize, - (unsigned long)AVI->video_superindex->aIndex[j].dwDuration)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] 0x%llx 0x%lx %lu\n", j, + (unsigned long long)AVI->video_superindex->aIndex[j].qwOffset, + (unsigned long)AVI->video_superindex->aIndex[j].dwSize, + (unsigned long)AVI->video_superindex->aIndex[j].dwDuration)); #endif - } + } #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] FOURCC \"%c%c%c%c\"\n", AVI->video_superindex->fcc[0], AVI->video_superindex->fcc[1], - AVI->video_superindex->fcc[2], AVI->video_superindex->fcc[3])); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] LEN \"%ld\"\n", (long)AVI->video_superindex->dwSize)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] wLongsPerEntry \"%d\"\n", AVI->video_superindex->wLongsPerEntry)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexSubType \"%d\"\n", AVI->video_superindex->bIndexSubType)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexType \"%d\"\n", AVI->video_superindex->bIndexType)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] nEntriesInUse \"%ld\"\n", (long)AVI->video_superindex->nEntriesInUse)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] dwChunkId \"%c%c%c%c\"\n", AVI->video_superindex->dwChunkId[0], AVI->video_superindex->dwChunkId[1], - AVI->video_superindex->dwChunkId[2], AVI->video_superindex->dwChunkId[3])); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] FOURCC \"%c%c%c%c\"\n", AVI->video_superindex->fcc[0], AVI->video_superindex->fcc[1], + AVI->video_superindex->fcc[2], AVI->video_superindex->fcc[3])); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] LEN \"%ld\"\n", (long)AVI->video_superindex->dwSize)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] wLongsPerEntry \"%d\"\n", AVI->video_superindex->wLongsPerEntry)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexSubType \"%d\"\n", AVI->video_superindex->bIndexSubType)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexType \"%d\"\n", AVI->video_superindex->bIndexType)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] nEntriesInUse \"%ld\"\n", (long)AVI->video_superindex->nEntriesInUse)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] dwChunkId \"%c%c%c%c\"\n", AVI->video_superindex->dwChunkId[0], AVI->video_superindex->dwChunkId[1], + AVI->video_superindex->dwChunkId[2], AVI->video_superindex->dwChunkId[3])); #endif - AVI->is_opendml = 1; - - } - else if(lasttag == 2) // A U D I O - { - - a = (char*) hdrl_data+i; - - AVI->track[AVI->aptr].audio_superindex = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk)); - memcpy (AVI->track[AVI->aptr].audio_superindex->fcc, a, 4); a += 4; - AVI->track[AVI->aptr].audio_superindex->dwSize = str2ulong((unsigned char*)a); a += 4; - AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry = str2ushort((unsigned char*)a); a += 2; - AVI->track[AVI->aptr].audio_superindex->bIndexSubType = *a; a += 1; - AVI->track[AVI->aptr].audio_superindex->bIndexType = *a; a += 1; - AVI->track[AVI->aptr].audio_superindex->nEntriesInUse = str2ulong((unsigned char*)a); a += 4; - memcpy (AVI->track[AVI->aptr].audio_superindex->dwChunkId, a, 4); a += 4; - - // 3 * reserved - a += 4; a += 4; a += 4; - - if (AVI->track[AVI->aptr].audio_superindex->bIndexSubType != 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Invalid Header, bIndexSubType != 0\n")); - } - - AVI->track[AVI->aptr].audio_superindex->aIndex = (avisuperindex_entry*) - gf_malloc (AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry * - AVI->track[AVI->aptr].audio_superindex->nEntriesInUse * sizeof (u32)); - - // position of ix## chunks - for (j=0; jtrack[AVI->aptr].audio_superindex->nEntriesInUse; ++j) { - AVI->track[AVI->aptr].audio_superindex->aIndex[j].qwOffset = str2ullong ((unsigned char*)a); a += 8; - AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwSize = str2ulong ((unsigned char*)a); a += 4; - AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwDuration = str2ulong ((unsigned char*)a); a += 4; + AVI->is_opendml = 1; + + } + else if(lasttag == 2) // A U D I O + { + + a = (char*) hdrl_data+i; + + AVI->track[AVI->aptr].audio_superindex = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk)); + memcpy (AVI->track[AVI->aptr].audio_superindex->fcc, a, 4); + a += 4; + AVI->track[AVI->aptr].audio_superindex->dwSize = str2ulong((unsigned char*)a); + a += 4; + AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry = str2ushort((unsigned char*)a); + a += 2; + AVI->track[AVI->aptr].audio_superindex->bIndexSubType = *a; + a += 1; + AVI->track[AVI->aptr].audio_superindex->bIndexType = *a; + a += 1; + AVI->track[AVI->aptr].audio_superindex->nEntriesInUse = str2ulong((unsigned char*)a); + a += 4; + memcpy (AVI->track[AVI->aptr].audio_superindex->dwChunkId, a, 4); + a += 4; + + // 3 * reserved + a += 4; + a += 4; + a += 4; + + if (AVI->track[AVI->aptr].audio_superindex->bIndexSubType != 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Invalid Header, bIndexSubType != 0\n")); + } + + AVI->track[AVI->aptr].audio_superindex->aIndex = (avisuperindex_entry*) + gf_malloc (AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry * + AVI->track[AVI->aptr].audio_superindex->nEntriesInUse * sizeof (u32)); + + // position of ix## chunks + for (j=0; jtrack[AVI->aptr].audio_superindex->nEntriesInUse; ++j) { + AVI->track[AVI->aptr].audio_superindex->aIndex[j].qwOffset = str2ullong ((unsigned char*)a); + a += 8; + AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwSize = str2ulong ((unsigned char*)a); + a += 4; + AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwDuration = str2ulong ((unsigned char*)a); + a += 4; #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] 0x%llx 0x%lx %lu\n", j, - (unsigned long long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].qwOffset, - (unsigned long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwSize, - (unsigned long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwDuration)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] 0x%llx 0x%lx %lu\n", j, + (unsigned long long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].qwOffset, + (unsigned long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwSize, + (unsigned long)AVI->track[AVI->aptr].audio_superindex->aIndex[j].dwDuration)); #endif - } + } #ifdef DEBUG_ODML - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] FOURCC \"%.4s\"\n", AVI->track[AVI->aptr].audio_superindex->fcc)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] LEN \"%ld\"\n", (long)AVI->track[AVI->aptr].audio_superindex->dwSize)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] wLongsPerEntry \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexSubType \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->bIndexSubType)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexType \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->bIndexType)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] nEntriesInUse \"%ld\"\n", (long)AVI->track[AVI->aptr].audio_superindex->nEntriesInUse)); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] dwChunkId \"%.4s\"\n", AVI->track[AVI->aptr].audio_superindex->dwChunkId[0])); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] FOURCC \"%.4s\"\n", AVI->track[AVI->aptr].audio_superindex->fcc)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] LEN \"%ld\"\n", (long)AVI->track[AVI->aptr].audio_superindex->dwSize)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] wLongsPerEntry \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->wLongsPerEntry)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexSubType \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->bIndexSubType)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] bIndexType \"%d\"\n", AVI->track[AVI->aptr].audio_superindex->bIndexType)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] nEntriesInUse \"%ld\"\n", (long)AVI->track[AVI->aptr].audio_superindex->nEntriesInUse)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] dwChunkId \"%.4s\"\n", AVI->track[AVI->aptr].audio_superindex->dwChunkId[0])); #endif - } - i += 8; - } - else if((strnicmp((char*)hdrl_data+i,"JUNK",4) == 0) || - (strnicmp((char*)hdrl_data+i,"strn",4) == 0) || - (strnicmp((char*)hdrl_data+i,"vprp",4) == 0)){ - i += 8; - // do not reset lasttag - } else - { - i += 8; - lasttag = 0; - } - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] adding %ld bytes\n", (long int)n)); - - i += (u32) n; - } - - gf_free(hdrl_data); - - if(!vids_strh_seen || !vids_strf_seen) ERR_EXIT(AVI_ERR_NO_VIDS) - - AVI->video_tag[0] = AVI->video_strn/10 + '0'; - AVI->video_tag[1] = AVI->video_strn%10 + '0'; - AVI->video_tag[2] = 'd'; - AVI->video_tag[3] = 'b'; - - /* Audio tag is set to "99wb" if no audio present */ - if(!AVI->track[0].a_chans) AVI->track[0].audio_strn = 99; - - { - int i=0; - for(j=0; janum+1; ++j) { - if (j == AVI->video_strn) continue; - AVI->track[i].audio_tag[0] = j/10 + '0'; - AVI->track[i].audio_tag[1] = j%10 + '0'; - AVI->track[i].audio_tag[2] = 'w'; - AVI->track[i].audio_tag[3] = 'b'; - ++i; - } - } - - gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); - - if(!getIndex) return(0); - - /* if the file has an idx1, check if this is relative - to the start of the file or to the start of the movi list */ - - idx_type = 0; - - if(AVI->idx) - { - s64 pos, len; - - /* Search the first videoframe in the idx1 and look where - it is in the file */ - - for(i=0;in_idx;i++) - if( strnicmp((char *)AVI->idx[i],(char *)AVI->video_tag,3)==0 ) break; - if(i>=AVI->n_idx) ERR_EXIT(AVI_ERR_NO_VIDS) - - pos = str2ulong(AVI->idx[i]+ 8); - len = str2ulong(AVI->idx[i]+12); - - gf_f64_seek(AVI->fdes,pos,SEEK_SET); - if(avi_read(AVI->fdes,data,8)!=8) ERR_EXIT(AVI_ERR_READ) - if( strnicmp(data,(char *)AVI->idx[i],4)==0 && str2ulong((unsigned char *)data+4)==len ) - { - idx_type = 1; /* Index from start of file */ - } - else - { - gf_f64_seek(AVI->fdes,pos+AVI->movi_start-4,SEEK_SET); - if(avi_read(AVI->fdes,data,8)!=8) ERR_EXIT(AVI_ERR_READ) - if( strnicmp(data,(char *)AVI->idx[i],4)==0 && str2ulong((unsigned char *)data+4)==len ) - { - idx_type = 2; /* Index from start of movi list */ - } - } - /* idx_type remains 0 if neither of the two tests above succeeds */ - } - + } + i += 8; + } + else if((strnicmp((char*)hdrl_data+i,"JUNK",4) == 0) || + (strnicmp((char*)hdrl_data+i,"strn",4) == 0) || + (strnicmp((char*)hdrl_data+i,"vprp",4) == 0)) { + i += 8; + // do not reset lasttag + } else + { + i += 8; + lasttag = 0; + } + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] adding %ld bytes\n", (long int)n)); + + i += (u32) n; + } + + gf_free(hdrl_data); + + if(!vids_strh_seen || !vids_strf_seen) ERR_EXIT(AVI_ERR_NO_VIDS) + + AVI->video_tag[0] = AVI->video_strn/10 + '0'; + AVI->video_tag[1] = AVI->video_strn%10 + '0'; + AVI->video_tag[2] = 'd'; + AVI->video_tag[3] = 'b'; + + /* Audio tag is set to "99wb" if no audio present */ + if(!AVI->track[0].a_chans) AVI->track[0].audio_strn = 99; + + { + int i=0; + for(j=0; janum+1; ++j) { + if (j == AVI->video_strn) continue; + AVI->track[i].audio_tag[0] = j/10 + '0'; + AVI->track[i].audio_tag[1] = j%10 + '0'; + AVI->track[i].audio_tag[2] = 'w'; + AVI->track[i].audio_tag[3] = 'b'; + ++i; + } + } - if(idx_type == 0 && !AVI->is_opendml && !AVI->total_frames) - { - /* we must search through the file to get the index */ + gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); + + if(!getIndex) return(0); + + /* if the file has an idx1, check if this is relative + to the start of the file or to the start of the movi list */ + + idx_type = 0; + + if(AVI->idx) + { + s64 pos, len; + + /* Search the first videoframe in the idx1 and look where + it is in the file */ + + for(i=0; in_idx; i++) + if( strnicmp((char *)AVI->idx[i],(char *)AVI->video_tag,3)==0 ) break; + if(i>=AVI->n_idx) ERR_EXIT(AVI_ERR_NO_VIDS) + + pos = str2ulong(AVI->idx[i]+ 8); + len = str2ulong(AVI->idx[i]+12); + + gf_f64_seek(AVI->fdes,pos,SEEK_SET); + if(avi_read(AVI->fdes,data,8)!=8) ERR_EXIT(AVI_ERR_READ) + if( strnicmp(data,(char *)AVI->idx[i],4)==0 && str2ulong((unsigned char *)data+4)==len ) + { + idx_type = 1; /* Index from start of file */ + } + else + { + gf_f64_seek(AVI->fdes,pos+AVI->movi_start-4,SEEK_SET); + if(avi_read(AVI->fdes,data,8)!=8) ERR_EXIT(AVI_ERR_READ) + if( strnicmp(data,(char *)AVI->idx[i],4)==0 && str2ulong((unsigned char *)data+4)==len ) + { + idx_type = 2; /* Index from start of movi list */ + } + } + /* idx_type remains 0 if neither of the two tests above succeeds */ + } - gf_f64_seek(AVI->fdes, AVI->movi_start, SEEK_SET); - AVI->n_idx = 0; + if(idx_type == 0 && !AVI->is_opendml && !AVI->total_frames) + { + /* we must search through the file to get the index */ - while(1) - { - if( avi_read(AVI->fdes,data,8) != 8 ) break; - n = str2ulong((unsigned char *)data+4); + gf_f64_seek(AVI->fdes, AVI->movi_start, SEEK_SET); - /* The movi list may contain sub-lists, ignore them */ + AVI->n_idx = 0; - if(strnicmp(data,"LIST",4)==0) - { - gf_f64_seek(AVI->fdes,4,SEEK_CUR); - continue; - } + while(1) + { + if( avi_read(AVI->fdes,data,8) != 8 ) break; + n = str2ulong((unsigned char *)data+4); - /* Check if we got a tag ##db, ##dc or ##wb */ + /* The movi list may contain sub-lists, ignore them */ - if( ( (data[2]=='d' || data[2]=='D') && - (data[3]=='b' || data[3]=='B' || data[3]=='c' || data[3]=='C') ) - || ( (data[2]=='w' || data[2]=='W') && - (data[3]=='b' || data[3]=='B') ) ) - { - u64 __pos = gf_f64_tell(AVI->fdes) - 8; - avi_add_index_entry(AVI,(unsigned char *)data,0,__pos,n); - } + if(strnicmp(data,"LIST",4)==0) + { + gf_f64_seek(AVI->fdes,4,SEEK_CUR); + continue; + } - gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); - } - idx_type = 1; - } + /* Check if we got a tag ##db, ##dc or ##wb */ - // ************************ - // OPENDML - // ************************ + if( ( (data[2]=='d' || data[2]=='D') && + (data[3]=='b' || data[3]=='B' || data[3]=='c' || data[3]=='C') ) + || ( (data[2]=='w' || data[2]=='W') && + (data[3]=='b' || data[3]=='B') ) ) + { + u64 __pos = gf_f64_tell(AVI->fdes) - 8; + avi_add_index_entry(AVI,(unsigned char *)data,0,__pos,n); + } - // read extended index chunks - if (AVI->is_opendml) { - u64 offset = 0; - int hdrl_len = 4+4+2+1+1+4+4+8+4; - char *en, *chunk_start; - int k = 0; - u32 audtr = 0; - u32 nrEntries = 0; - - AVI->video_index = NULL; + gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); + } + idx_type = 1; + } - nvi = 0; - for(audtr=0; audtranum; ++audtr) { nai[audtr] = 0; tot[audtr] = 0; } + // ************************ + // OPENDML + // ************************ + + // read extended index chunks + if (AVI->is_opendml) { + u64 offset = 0; + int hdrl_len = 4+4+2+1+1+4+4+8+4; + char *en, *chunk_start; + int k = 0; + u32 audtr = 0; + u32 nrEntries = 0; + + AVI->video_index = NULL; + + nvi = 0; + for(audtr=0; audtranum; ++audtr) { + nai[audtr] = 0; + tot[audtr] = 0; + } - // ************************ - // VIDEO - // ************************ + // ************************ + // VIDEO + // ************************ - for (j=0; jvideo_superindex->nEntriesInUse; j++) { + for (j=0; jvideo_superindex->nEntriesInUse; j++) { - // read from file - chunk_start = en = (char*) gf_malloc ((u32) (AVI->video_superindex->aIndex[j].dwSize+hdrl_len) ); + // read from file + chunk_start = en = (char*) gf_malloc ((u32) (AVI->video_superindex->aIndex[j].dwSize+hdrl_len) ); - if (gf_f64_seek(AVI->fdes, AVI->video_superindex->aIndex[j].qwOffset, SEEK_SET) == (u64)-1) { - gf_free(chunk_start); - continue; - } + if (gf_f64_seek(AVI->fdes, AVI->video_superindex->aIndex[j].qwOffset, SEEK_SET) == (u64)-1) { + gf_free(chunk_start); + continue; + } - if (avi_read(AVI->fdes, en, (u32) (AVI->video_superindex->aIndex[j].dwSize+hdrl_len) ) <= 0) { - gf_free(chunk_start); - continue; - } + if (avi_read(AVI->fdes, en, (u32) (AVI->video_superindex->aIndex[j].dwSize+hdrl_len) ) <= 0) { + gf_free(chunk_start); + continue; + } - nrEntries = str2ulong((unsigned char*)en + 12); + nrEntries = str2ulong((unsigned char*)en + 12); #ifdef DEBUG_ODML - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:0] Video nrEntries %ld\n", j, nrEntries)); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:0] Video nrEntries %ld\n", j, nrEntries)); #endif - offset = str2ullong((unsigned char*)en + 20); - - // skip header - en += hdrl_len; - nvi += nrEntries; - AVI->video_index = (video_index_entry *) gf_realloc (AVI->video_index, nvi * sizeof (video_index_entry)); - if (!AVI->video_index) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] out of mem (size = %ld)\n", nvi * sizeof (video_index_entry))); - exit(1); - } - - while (k < nvi) { - - AVI->video_index[k].pos = offset + str2ulong((unsigned char*)en); en += 4; - AVI->video_index[k].len = str2ulong_len((unsigned char*)en); - AVI->video_index[k].key = str2ulong_key((unsigned char*)en); en += 4; - - // completely empty chunk - if (AVI->video_index[k].pos-offset == 0 && AVI->video_index[k].len == 0) { - k--; - nvi--; - } + offset = str2ullong((unsigned char*)en + 20); + + // skip header + en += hdrl_len; + nvi += nrEntries; + AVI->video_index = (video_index_entry *) gf_realloc (AVI->video_index, nvi * sizeof (video_index_entry)); + if (!AVI->video_index) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] out of mem (size = %ld)\n", nvi * sizeof (video_index_entry))); + exit(1); + } + + while (k < nvi) { + + AVI->video_index[k].pos = offset + str2ulong((unsigned char*)en); + en += 4; + AVI->video_index[k].len = str2ulong_len((unsigned char*)en); + AVI->video_index[k].key = str2ulong_key((unsigned char*)en); + en += 4; + + // completely empty chunk + if (AVI->video_index[k].pos-offset == 0 && AVI->video_index[k].len == 0) { + k--; + nvi--; + } #ifdef DEBUG_ODML - /* - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] POS 0x%llX len=%d key=%s offset (%llx) (%ld)\n", k, - AVI->video_index[k].pos, - (int)AVI->video_index[k].len, - AVI->video_index[k].key?"yes":"no ", offset, - AVI->video_superindex->aIndex[j].dwSize)); - */ + /* + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d] POS 0x%llX len=%d key=%s offset (%llx) (%ld)\n", k, + AVI->video_index[k].pos, + (int)AVI->video_index[k].len, + AVI->video_index[k].key?"yes":"no ", offset, + AVI->video_superindex->aIndex[j].dwSize)); + */ #endif - k++; - } + k++; + } - gf_free(chunk_start); - } + gf_free(chunk_start); + } - AVI->video_frames = nvi; - // this should deal with broken 'rec ' odml files. - if (AVI->video_frames == 0) { - AVI->is_opendml=0; - goto multiple_riff; - } + AVI->video_frames = nvi; + // this should deal with broken 'rec ' odml files. + if (AVI->video_frames == 0) { + AVI->is_opendml=0; + goto multiple_riff; + } - // ************************ - // AUDIO - // ************************ + // ************************ + // AUDIO + // ************************ - for(audtr=0; audtranum; ++audtr) { + for(audtr=0; audtranum; ++audtr) { - k = 0; - if (!AVI->track[audtr].audio_superindex) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] (%s) cannot read audio index for track %d\n", __FILE__, audtr)); - continue; - } - for (j=0; jtrack[audtr].audio_superindex->nEntriesInUse; j++) { + k = 0; + if (!AVI->track[audtr].audio_superindex) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] (%s) cannot read audio index for track %d\n", __FILE__, audtr)); + continue; + } + for (j=0; jtrack[audtr].audio_superindex->nEntriesInUse; j++) { - // read from file - chunk_start = en = (char*)gf_malloc ((u32) (AVI->track[audtr].audio_superindex->aIndex[j].dwSize+hdrl_len)); + // read from file + chunk_start = en = (char*)gf_malloc ((u32) (AVI->track[audtr].audio_superindex->aIndex[j].dwSize+hdrl_len)); - if (gf_f64_seek(AVI->fdes, AVI->track[audtr].audio_superindex->aIndex[j].qwOffset, SEEK_SET) == (u64)-1) { - gf_free(chunk_start); - continue; - } + if (gf_f64_seek(AVI->fdes, AVI->track[audtr].audio_superindex->aIndex[j].qwOffset, SEEK_SET) == (u64)-1) { + gf_free(chunk_start); + continue; + } - if (avi_read(AVI->fdes, en, (u32) (AVI->track[audtr].audio_superindex->aIndex[j].dwSize+hdrl_len)) <= 0) { - gf_free(chunk_start); - continue; - } + if (avi_read(AVI->fdes, en, (u32) (AVI->track[audtr].audio_superindex->aIndex[j].dwSize+hdrl_len)) <= 0) { + gf_free(chunk_start); + continue; + } - nrEntries = str2ulong((unsigned char*)en + 12); - //if (nrEntries > 50) nrEntries = 2; // XXX + nrEntries = str2ulong((unsigned char*)en + 12); + //if (nrEntries > 50) nrEntries = 2; // XXX #ifdef DEBUG_ODML - //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:%d] Audio nrEntries %ld\n", j, audtr, nrEntries)); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:%d] Audio nrEntries %ld\n", j, audtr, nrEntries)); #endif - offset = str2ullong((unsigned char*)en + 20); + offset = str2ullong((unsigned char*)en + 20); - // skip header - en += hdrl_len; - nai[audtr] += nrEntries; - AVI->track[audtr].audio_index = (audio_index_entry *) gf_realloc (AVI->track[audtr].audio_index, nai[audtr] * sizeof (audio_index_entry)); + // skip header + en += hdrl_len; + nai[audtr] += nrEntries; + AVI->track[audtr].audio_index = (audio_index_entry *) gf_realloc (AVI->track[audtr].audio_index, nai[audtr] * sizeof (audio_index_entry)); - while (k < nai[audtr]) { + while (k < nai[audtr]) { - AVI->track[audtr].audio_index[k].pos = offset + str2ulong((unsigned char*)en); en += 4; - AVI->track[audtr].audio_index[k].len = str2ulong_len((unsigned char*)en); en += 4; - AVI->track[audtr].audio_index[k].tot = tot[audtr]; - tot[audtr] += AVI->track[audtr].audio_index[k].len; + AVI->track[audtr].audio_index[k].pos = offset + str2ulong((unsigned char*)en); + en += 4; + AVI->track[audtr].audio_index[k].len = str2ulong_len((unsigned char*)en); + en += 4; + AVI->track[audtr].audio_index[k].tot = tot[audtr]; + tot[audtr] += AVI->track[audtr].audio_index[k].len; #ifdef DEBUG_ODML - /* - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:%d] POS 0x%llX len=%d offset (%llx) (%ld)\n", k, audtr, - AVI->track[audtr].audio_index[k].pos, - (int)AVI->track[audtr].audio_index[k].len, - offset, AVI->track[audtr].audio_superindex->aIndex[j].dwSize)); - */ + /* + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] [%d:%d] POS 0x%llX len=%d offset (%llx) (%ld)\n", k, audtr, + AVI->track[audtr].audio_index[k].pos, + (int)AVI->track[audtr].audio_index[k].len, + offset, AVI->track[audtr].audio_superindex->aIndex[j].dwSize)); + */ #endif - ++k; - } + ++k; + } - gf_free(chunk_start); - } + gf_free(chunk_start); + } - AVI->track[audtr].audio_chunks = nai[audtr]; - AVI->track[audtr].audio_bytes = tot[audtr]; - } - } // is opendml + AVI->track[audtr].audio_chunks = nai[audtr]; + AVI->track[audtr].audio_bytes = tot[audtr]; + } + } // is opendml - else if (AVI->total_frames && !AVI->is_opendml && idx_type==0) { + else if (AVI->total_frames && !AVI->is_opendml && idx_type==0) { - // ********************* - // MULTIPLE RIFF CHUNKS (and no index) - // ********************* + // ********************* + // MULTIPLE RIFF CHUNKS (and no index) + // ********************* multiple_riff: - gf_f64_seek(AVI->fdes, AVI->movi_start, SEEK_SET); - - AVI->n_idx = 0; + gf_f64_seek(AVI->fdes, AVI->movi_start, SEEK_SET); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Reconstructing index...")); + AVI->n_idx = 0; - // Number of frames; only one audio track supported - nvi = AVI->video_frames = AVI->total_frames; - nai[0] = AVI->track[0].audio_chunks = AVI->total_frames; - for(j=1; janum; ++j) AVI->track[j].audio_chunks = 0; + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Reconstructing index...")); - AVI->video_index = (video_index_entry *) gf_malloc(nvi*sizeof(video_index_entry)); + // Number of frames; only one audio track supported + nvi = AVI->video_frames = AVI->total_frames; + nai[0] = AVI->track[0].audio_chunks = AVI->total_frames; + for(j=1; janum; ++j) AVI->track[j].audio_chunks = 0; - if(AVI->video_index==0) ERR_EXIT(AVI_ERR_NO_MEM); + AVI->video_index = (video_index_entry *) gf_malloc(nvi*sizeof(video_index_entry)); - for(j=0; janum; ++j) { - if(AVI->track[j].audio_chunks) { - AVI->track[j].audio_index = (audio_index_entry *) gf_malloc((nai[j]+1)*sizeof(audio_index_entry)); - memset(AVI->track[j].audio_index, 0, (nai[j]+1)*(sizeof(audio_index_entry))); - if(AVI->track[j].audio_index==0) ERR_EXIT(AVI_ERR_NO_MEM); - } - } + if(AVI->video_index==0) ERR_EXIT(AVI_ERR_NO_MEM); - nvi = 0; - for(j=0; janum; ++j) {nai[j] = 0; tot[j] = 0;} - - aud_chunks = AVI->total_frames; - - while(1) - { - if (nvi >= AVI->total_frames) break; - - if( avi_read(AVI->fdes,data,8) != 8 ) break; - n = str2ulong((unsigned char *)data+4); + for(j=0; janum; ++j) { + if(AVI->track[j].audio_chunks) { + AVI->track[j].audio_index = (audio_index_entry *) gf_malloc((nai[j]+1)*sizeof(audio_index_entry)); + memset(AVI->track[j].audio_index, 0, (nai[j]+1)*(sizeof(audio_index_entry))); + if(AVI->track[j].audio_index==0) ERR_EXIT(AVI_ERR_NO_MEM); + } + } + nvi = 0; + for(j=0; janum; ++j) { + nai[j] = 0; + tot[j] = 0; + } - j=0; + aud_chunks = AVI->total_frames; - if (aud_chunks - nai[j] -1 <= 0) { - aud_chunks += AVI->total_frames; - AVI->track[j].audio_index = (audio_index_entry *) - gf_realloc( AVI->track[j].audio_index, (aud_chunks+1)*sizeof(audio_index_entry)); - if (!AVI->track[j].audio_index) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Internal error in avilib -- no mem\n")); - AVI_errno = AVI_ERR_NO_MEM; - return -1; - } - } + while(1) + { + if (nvi >= AVI->total_frames) break; - /* Check if we got a tag ##db, ##dc or ##wb */ + if( avi_read(AVI->fdes,data,8) != 8 ) break; + n = str2ulong((unsigned char *)data+4); - // VIDEO - if( - (data[0]=='0' || data[1]=='0') && - (data[2]=='d' || data[2]=='D') && - (data[3]=='b' || data[3]=='B' || data[3]=='c' || data[3]=='C') ) { - AVI->video_index[nvi].key = 0x0; - AVI->video_index[nvi].pos = gf_f64_tell(AVI->fdes); - AVI->video_index[nvi].len = (u32) n; + j=0; - /* - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Frame %ld pos %"LLD" len %"LLD" key %ld\n", - nvi, AVI->video_index[nvi].pos, AVI->video_index[nvi].len, (long)AVI->video_index[nvi].key)); - */ - nvi++; - gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); - } + if (aud_chunks - nai[j] -1 <= 0) { + aud_chunks += AVI->total_frames; + AVI->track[j].audio_index = (audio_index_entry *) + gf_realloc( AVI->track[j].audio_index, (aud_chunks+1)*sizeof(audio_index_entry)); + if (!AVI->track[j].audio_index) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] Internal error in avilib -- no mem\n")); + AVI_errno = AVI_ERR_NO_MEM; + return -1; + } + } - //AUDIO - else if( - (data[0]=='0' || data[1]=='1') && - (data[2]=='w' || data[2]=='W') && - (data[3]=='b' || data[3]=='B') ) { + /* Check if we got a tag ##db, ##dc or ##wb */ + // VIDEO + if( + (data[0]=='0' || data[1]=='0') && + (data[2]=='d' || data[2]=='D') && + (data[3]=='b' || data[3]=='B' || data[3]=='c' || data[3]=='C') ) { - AVI->track[j].audio_index[nai[j]].pos = gf_f64_tell(AVI->fdes); - AVI->track[j].audio_index[nai[j]].len = (u32) n; - AVI->track[j].audio_index[nai[j]].tot = tot[j]; - tot[j] += AVI->track[j].audio_index[nai[j]].len; - nai[j]++; + AVI->video_index[nvi].key = 0x0; + AVI->video_index[nvi].pos = gf_f64_tell(AVI->fdes); + AVI->video_index[nvi].len = (u32) n; - gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); - } - else { - gf_f64_seek(AVI->fdes,-4,SEEK_CUR); - } + /* + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] Frame %ld pos %"LLD" len %"LLD" key %ld\n", + nvi, AVI->video_index[nvi].pos, AVI->video_index[nvi].len, (long)AVI->video_index[nvi].key)); + */ + nvi++; + gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); + } - } - if (nvi < AVI->total_frames) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[avilib] Uh? Some frames seems missing (%ld/%d)\n", - nvi, AVI->total_frames)); - } + //AUDIO + else if( + (data[0]=='0' || data[1]=='1') && + (data[2]=='w' || data[2]=='W') && + (data[3]=='b' || data[3]=='B') ) { - AVI->video_frames = nvi; - AVI->track[0].audio_chunks = nai[0]; + AVI->track[j].audio_index[nai[j]].pos = gf_f64_tell(AVI->fdes); + AVI->track[j].audio_index[nai[j]].len = (u32) n; + AVI->track[j].audio_index[nai[j]].tot = tot[j]; + tot[j] += AVI->track[j].audio_index[nai[j]].len; + nai[j]++; - for(j=0; janum; ++j) AVI->track[j].audio_bytes = tot[j]; - idx_type = 1; - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] done. nvi=%ld nai=%ld tot=%ld\n", nvi, nai[0], tot[0])); + gf_f64_seek(AVI->fdes,PAD_EVEN(n),SEEK_CUR); + } + else { + gf_f64_seek(AVI->fdes,-4,SEEK_CUR); + } - } // total_frames but no indx chunk (xawtv does this) + } + if (nvi < AVI->total_frames) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[avilib] Uh? Some frames seems missing (%ld/%d)\n", + nvi, AVI->total_frames)); + } - else - { - // ****************** - // NO OPENDML - // ****************** + AVI->video_frames = nvi; + AVI->track[0].audio_chunks = nai[0]; - /* Now generate the video index and audio index arrays */ + for(j=0; janum; ++j) AVI->track[j].audio_bytes = tot[j]; + idx_type = 1; + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[avilib] done. nvi=%ld nai=%ld tot=%ld\n", nvi, nai[0], tot[0])); - nvi = 0; - for(j=0; janum; ++j) nai[j] = 0; + } // total_frames but no indx chunk (xawtv does this) - for(i=0;in_idx;i++) { + else - if(strnicmp((char *)AVI->idx[i],AVI->video_tag,3) == 0) nvi++; + { + // ****************** + // NO OPENDML + // ****************** - for(j=0; janum; ++j) if(strnicmp((char *)AVI->idx[i], AVI->track[j].audio_tag,4) == 0) nai[j]++; - } + /* Now generate the video index and audio index arrays */ - AVI->video_frames = nvi; - for(j=0; janum; ++j) AVI->track[j].audio_chunks = nai[j]; + nvi = 0; + for(j=0; janum; ++j) nai[j] = 0; + for(i=0; in_idx; i++) { - if(AVI->video_frames==0) ERR_EXIT(AVI_ERR_NO_VIDS); - AVI->video_index = (video_index_entry *) gf_malloc(nvi*sizeof(video_index_entry)); - if(AVI->video_index==0) ERR_EXIT(AVI_ERR_NO_MEM); + if(strnicmp((char *)AVI->idx[i],AVI->video_tag,3) == 0) nvi++; - for(j=0; janum; ++j) { - if(AVI->track[j].audio_chunks) { - AVI->track[j].audio_index = (audio_index_entry *) gf_malloc((nai[j]+1)*sizeof(audio_index_entry)); - memset(AVI->track[j].audio_index, 0, (nai[j]+1)*(sizeof(audio_index_entry))); - if(AVI->track[j].audio_index==0) ERR_EXIT(AVI_ERR_NO_MEM); - } - } + for(j=0; janum; ++j) if(strnicmp((char *)AVI->idx[i], AVI->track[j].audio_tag,4) == 0) nai[j]++; + } - nvi = 0; - for(j=0; janum; ++j) {nai[j] = 0; tot[j] = 0;} + AVI->video_frames = nvi; + for(j=0; janum; ++j) AVI->track[j].audio_chunks = nai[j]; - ioff = idx_type == 1 ? 8 : (u32)AVI->movi_start+4; - for(i=0;in_idx;i++) { + if(AVI->video_frames==0) ERR_EXIT(AVI_ERR_NO_VIDS); + AVI->video_index = (video_index_entry *) gf_malloc(nvi*sizeof(video_index_entry)); + if(AVI->video_index==0) ERR_EXIT(AVI_ERR_NO_MEM); - //video - if(strnicmp((char *)AVI->idx[i],AVI->video_tag,3) == 0) { - AVI->video_index[nvi].key = str2ulong(AVI->idx[i]+ 4); - AVI->video_index[nvi].pos = str2ulong(AVI->idx[i]+ 8)+ioff; - AVI->video_index[nvi].len = str2ulong(AVI->idx[i]+12); - nvi++; - } + for(j=0; janum; ++j) { + if(AVI->track[j].audio_chunks) { + AVI->track[j].audio_index = (audio_index_entry *) gf_malloc((nai[j]+1)*sizeof(audio_index_entry)); + memset(AVI->track[j].audio_index, 0, (nai[j]+1)*(sizeof(audio_index_entry))); + if(AVI->track[j].audio_index==0) ERR_EXIT(AVI_ERR_NO_MEM); + } + } - //audio - for(j=0; janum; ++j) { + nvi = 0; + for(j=0; janum; ++j) { + nai[j] = 0; + tot[j] = 0; + } - if(strnicmp((char *)AVI->idx[i],AVI->track[j].audio_tag,4) == 0) { - AVI->track[j].audio_index[nai[j]].pos = str2ulong(AVI->idx[i]+ 8)+ioff; - AVI->track[j].audio_index[nai[j]].len = str2ulong(AVI->idx[i]+12); - AVI->track[j].audio_index[nai[j]].tot = tot[j]; - tot[j] += AVI->track[j].audio_index[nai[j]].len; - nai[j]++; - } - } - } + ioff = idx_type == 1 ? 8 : (u32)AVI->movi_start+4; + + for(i=0; in_idx; i++) { + + //video + if(strnicmp((char *)AVI->idx[i],AVI->video_tag,3) == 0) { + AVI->video_index[nvi].key = str2ulong(AVI->idx[i]+ 4); + AVI->video_index[nvi].pos = str2ulong(AVI->idx[i]+ 8)+ioff; + AVI->video_index[nvi].len = str2ulong(AVI->idx[i]+12); + nvi++; + } + + //audio + for(j=0; janum; ++j) { + + if(strnicmp((char *)AVI->idx[i],AVI->track[j].audio_tag,4) == 0) { + AVI->track[j].audio_index[nai[j]].pos = str2ulong(AVI->idx[i]+ 8)+ioff; + AVI->track[j].audio_index[nai[j]].len = str2ulong(AVI->idx[i]+12); + AVI->track[j].audio_index[nai[j]].tot = tot[j]; + tot[j] += AVI->track[j].audio_index[nai[j]].len; + nai[j]++; + } + } + } - for(j=0; janum; ++j) AVI->track[j].audio_bytes = tot[j]; + for(j=0; janum; ++j) AVI->track[j].audio_bytes = tot[j]; - } // is no opendml + } // is no opendml - /* Reposition the file */ + /* Reposition the file */ - gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); - AVI->video_pos = 0; + gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); + AVI->video_pos = 0; - return(0); + return(0); } long AVI_video_frames(avi_t *AVI) { - return AVI->video_frames; + return AVI->video_frames; } int AVI_video_width(avi_t *AVI) { - return AVI->width; + return AVI->width; } int AVI_video_height(avi_t *AVI) { - return AVI->height; + return AVI->height; } double AVI_frame_rate(avi_t *AVI) { - return AVI->fps; + return AVI->fps; } char* AVI_video_compressor(avi_t *AVI) { - return AVI->compressor2; + return AVI->compressor2; } long AVI_max_video_chunk(avi_t *AVI) { - return AVI->max_len; + return AVI->max_len; } int AVI_audio_tracks(avi_t *AVI) { - return(AVI->anum); + return(AVI->anum); } int AVI_audio_channels(avi_t *AVI) { - return AVI->track[AVI->aptr].a_chans; + return AVI->track[AVI->aptr].a_chans; } long AVI_audio_mp3rate(avi_t *AVI) { - return AVI->track[AVI->aptr].mp3rate; + return AVI->track[AVI->aptr].mp3rate; } long AVI_audio_padrate(avi_t *AVI) { - return AVI->track[AVI->aptr].padrate; + return AVI->track[AVI->aptr].padrate; } int AVI_audio_bits(avi_t *AVI) { - return AVI->track[AVI->aptr].a_bits; + return AVI->track[AVI->aptr].a_bits; } int AVI_audio_format(avi_t *AVI) { - return AVI->track[AVI->aptr].a_fmt; + return AVI->track[AVI->aptr].a_fmt; } long AVI_audio_rate(avi_t *AVI) { - return AVI->track[AVI->aptr].a_rate; + return AVI->track[AVI->aptr].a_rate; } long AVI_frame_size(avi_t *AVI, long frame) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->video_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->video_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - if(frame < 0 || frame >= AVI->video_frames) return 0; - return (u32) (AVI->video_index[frame].len); + if(frame < 0 || frame >= AVI->video_frames) return 0; + return (u32) (AVI->video_index[frame].len); } long AVI_audio_size(avi_t *AVI, long frame) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - if(frame < 0 || frame >= AVI->track[AVI->aptr].audio_chunks) return -1; - return (u32) (AVI->track[AVI->aptr].audio_index[frame].len); + if(frame < 0 || frame >= AVI->track[AVI->aptr].audio_chunks) return -1; + return (u32) (AVI->track[AVI->aptr].audio_index[frame].len); } u64 AVI_get_video_position(avi_t *AVI, long frame) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return (u64) -1; } - if(!AVI->video_index) { AVI_errno = AVI_ERR_NO_IDX; return (u64) -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return (u64) -1; + } + if(!AVI->video_index) { + AVI_errno = AVI_ERR_NO_IDX; + return (u64) -1; + } - if(frame < 0 || frame >= AVI->video_frames) return 0; - return(AVI->video_index[frame].pos); + if(frame < 0 || frame >= AVI->video_frames) return 0; + return(AVI->video_index[frame].pos); } int AVI_seek_start(avi_t *AVI) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); - AVI->video_pos = 0; - return 0; + gf_f64_seek(AVI->fdes,AVI->movi_start,SEEK_SET); + AVI->video_pos = 0; + return 0; } int AVI_set_video_position(avi_t *AVI, long frame) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->video_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->video_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - if (frame < 0 ) frame = 0; - AVI->video_pos = frame; - return 0; + if (frame < 0 ) frame = 0; + AVI->video_pos = frame; + return 0; } int AVI_set_audio_bitrate(avi_t *AVI, long bitrate) { - if(AVI->mode==AVI_MODE_READ) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } + if(AVI->mode==AVI_MODE_READ) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } - AVI->track[AVI->aptr].mp3rate = bitrate; - return 0; + AVI->track[AVI->aptr].mp3rate = bitrate; + return 0; } long AVI_read_frame(avi_t *AVI, char *vidbuf, int *keyframe) { - long n; + long n; - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->video_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->video_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - if(AVI->video_pos < 0 || AVI->video_pos >= AVI->video_frames) return -1; - n = (u32) AVI->video_index[AVI->video_pos].len; + if(AVI->video_pos < 0 || AVI->video_pos >= AVI->video_frames) return -1; + n = (u32) AVI->video_index[AVI->video_pos].len; - *keyframe = (AVI->video_index[AVI->video_pos].key==0x10) ? 1:0; + *keyframe = (AVI->video_index[AVI->video_pos].key==0x10) ? 1:0; - if (vidbuf == NULL) { - AVI->video_pos++; - return n; - } + if (vidbuf == NULL) { + AVI->video_pos++; + return n; + } - gf_f64_seek(AVI->fdes, AVI->video_index[AVI->video_pos].pos, SEEK_SET); + gf_f64_seek(AVI->fdes, AVI->video_index[AVI->video_pos].pos, SEEK_SET); - if (avi_read(AVI->fdes,vidbuf,n) != (u32) n) - { - AVI_errno = AVI_ERR_READ; - return -1; - } + if (avi_read(AVI->fdes,vidbuf,n) != (u32) n) + { + AVI_errno = AVI_ERR_READ; + return -1; + } - AVI->video_pos++; + AVI->video_pos++; - return n; + return n; } long AVI_get_audio_position_index(avi_t *AVI) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - return (AVI->track[AVI->aptr].audio_posc); + return (AVI->track[AVI->aptr].audio_posc); } int AVI_set_audio_position_index(avi_t *AVI, long indexpos) { - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } - if(indexpos > AVI->track[AVI->aptr].audio_chunks) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } + if(indexpos > AVI->track[AVI->aptr].audio_chunks) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - AVI->track[AVI->aptr].audio_posc = indexpos; - AVI->track[AVI->aptr].audio_posb = 0; + AVI->track[AVI->aptr].audio_posc = indexpos; + AVI->track[AVI->aptr].audio_posb = 0; - return 0; + return 0; } int AVI_set_audio_position(avi_t *AVI, long byte) { - long n0, n1, n; + long n0, n1, n; - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - if(byte < 0) byte = 0; + if(byte < 0) byte = 0; - /* Binary search in the audio chunks */ + /* Binary search in the audio chunks */ - n0 = 0; - n1 = AVI->track[AVI->aptr].audio_chunks; + n0 = 0; + n1 = AVI->track[AVI->aptr].audio_chunks; - while(n0track[AVI->aptr].audio_index[n].tot>(u32) byte) - n1 = n; - else - n0 = n; - } + while(n0track[AVI->aptr].audio_index[n].tot>(u32) byte) + n1 = n; + else + n0 = n; + } - AVI->track[AVI->aptr].audio_posc = n0; - AVI->track[AVI->aptr].audio_posb = (u32) (byte - AVI->track[AVI->aptr].audio_index[n0].tot); + AVI->track[AVI->aptr].audio_posc = n0; + AVI->track[AVI->aptr].audio_posb = (u32) (byte - AVI->track[AVI->aptr].audio_index[n0].tot); - return 0; + return 0; } long AVI_read_audio(avi_t *AVI, char *audbuf, long bytes, int *continuous) { - long nr, left, todo; - s64 pos; + long nr, left, todo; + s64 pos; - if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; } - if(!AVI->track[AVI->aptr].audio_index) { AVI_errno = AVI_ERR_NO_IDX; return -1; } + if(AVI->mode==AVI_MODE_WRITE) { + AVI_errno = AVI_ERR_NOT_PERM; + return -1; + } + if(!AVI->track[AVI->aptr].audio_index) { + AVI_errno = AVI_ERR_NO_IDX; + return -1; + } - nr = 0; /* total number of bytes read */ + nr = 0; /* total number of bytes read */ - if (bytes==0) { - AVI->track[AVI->aptr].audio_posc++; - AVI->track[AVI->aptr].audio_posb = 0; - } + if (bytes==0) { + AVI->track[AVI->aptr].audio_posc++; + AVI->track[AVI->aptr].audio_posb = 0; + } - *continuous = 1; - while(bytes>0) - { - s64 ret; - left = (long) (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len - AVI->track[AVI->aptr].audio_posb); - if(left==0) - { - if(AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) return nr; - AVI->track[AVI->aptr].audio_posc++; - AVI->track[AVI->aptr].audio_posb = 0; - *continuous = 0; - continue; - } - if(bytestrack[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos + AVI->track[AVI->aptr].audio_posb; - gf_f64_seek(AVI->fdes, pos, SEEK_SET); - if ( (ret = avi_read(AVI->fdes,audbuf+nr,todo)) != todo) - { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] XXX pos = %"LLD", ret = %"LLD", todo = %ld\n", pos, ret, todo)); - AVI_errno = AVI_ERR_READ; - return -1; - } - bytes -= todo; - nr += todo; - AVI->track[AVI->aptr].audio_posb += todo; - } + *continuous = 1; + while(bytes>0) + { + s64 ret; + left = (long) (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len - AVI->track[AVI->aptr].audio_posb); + if(left==0) + { + if(AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) return nr; + AVI->track[AVI->aptr].audio_posc++; + AVI->track[AVI->aptr].audio_posb = 0; + *continuous = 0; + continue; + } + if(bytestrack[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos + AVI->track[AVI->aptr].audio_posb; + gf_f64_seek(AVI->fdes, pos, SEEK_SET); + if ( (ret = avi_read(AVI->fdes,audbuf+nr,todo)) != todo) + { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] XXX pos = %"LLD", ret = %"LLD", todo = %ld\n", pos, ret, todo)); + AVI_errno = AVI_ERR_READ; + return -1; + } + bytes -= todo; + nr += todo; + AVI->track[AVI->aptr].audio_posb += todo; + } - return nr; + return nr; } @@ -2902,73 +3031,72 @@ long AVI_read_audio(avi_t *AVI, char *audbuf, long bytes, int *continuous) without having an index of the file. */ int AVI_read_data(avi_t *AVI, char *vidbuf, long max_vidbuf, - char *audbuf, long max_audbuf, - long *len) + char *audbuf, long max_audbuf, + long *len) { -/* - * Return codes: - * - * 1 = video data read - * 2 = audio data read - * 0 = reached EOF - * -1 = video buffer too small - * -2 = audio buffer too small - */ + /* + * Return codes: + * + * 1 = video data read + * 2 = audio data read + * 0 = reached EOF + * -1 = video buffer too small + * -2 = audio buffer too small + */ - s64 n; - char data[8]; - - if(AVI->mode==AVI_MODE_WRITE) return 0; - - while(1) - { - /* Read tag and length */ - - if( avi_read(AVI->fdes,data,8) != 8 ) return 0; - - /* if we got a list tag, ignore it */ - - if(strnicmp(data,"LIST",4) == 0) - { - gf_f64_seek(AVI->fdes,4,SEEK_CUR); - continue; - } - - n = PAD_EVEN(str2ulong((unsigned char *)data+4)); - - if(strnicmp(data,AVI->video_tag,3) == 0) - { - *len = (u32) n; - AVI->video_pos++; - if(n>max_vidbuf) - { - gf_f64_seek(AVI->fdes,n,SEEK_CUR); - return -1; - } - if(avi_read(AVI->fdes,vidbuf, (u32) n) != n ) return 0; - return 1; - } - else if(strnicmp(data,AVI->track[AVI->aptr].audio_tag,4) == 0) - { - *len = (u32) n; - if(n>max_audbuf) - { - gf_f64_seek(AVI->fdes,n,SEEK_CUR); - return -2; - } - if(avi_read(AVI->fdes,audbuf, (u32) n) != n ) return 0; - return 2; - break; - } - else - if(gf_f64_seek(AVI->fdes,n,SEEK_CUR) == (u64) -1) return 0; - } + s64 n; + char data[8]; + + if(AVI->mode==AVI_MODE_WRITE) return 0; + + while(1) + { + /* Read tag and length */ + + if( avi_read(AVI->fdes,data,8) != 8 ) return 0; + + /* if we got a list tag, ignore it */ + + if(strnicmp(data,"LIST",4) == 0) + { + gf_f64_seek(AVI->fdes,4,SEEK_CUR); + continue; + } + + n = PAD_EVEN(str2ulong((unsigned char *)data+4)); + + if(strnicmp(data,AVI->video_tag,3) == 0) + { + *len = (u32) n; + AVI->video_pos++; + if(n>max_vidbuf) + { + gf_f64_seek(AVI->fdes,n,SEEK_CUR); + return -1; + } + if(avi_read(AVI->fdes,vidbuf, (u32) n) != n ) return 0; + return 1; + } + else if(strnicmp(data,AVI->track[AVI->aptr].audio_tag,4) == 0) + { + *len = (u32) n; + if(n>max_audbuf) + { + gf_f64_seek(AVI->fdes,n,SEEK_CUR); + return -2; + } + if(avi_read(AVI->fdes,audbuf, (u32) n) != n ) return 0; + return 2; + break; + } + else if(gf_f64_seek(AVI->fdes,n,SEEK_CUR) == (u64) -1) return 0; + } } u64 AVI_max_size(void) { - return((u64) AVI_MAX_LEN); + return((u64) AVI_MAX_LEN); } diff --git a/src/media_tools/dash_client.c b/src/media_tools/dash_client.c index 543e4e9..9e008b0 100644 --- a/src/media_tools/dash_client.c +++ b/src/media_tools/dash_client.c @@ -5,7 +5,7 @@ * Copyright (c) Telecom ParisTech 2010- * All rights reserved * -* This file is part of GPAC / Adaptive HTTP Streaming +* This file is part of GPAC / Adaptive HTTP Streaming * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -94,7 +94,7 @@ struct __dash_client u64 start_time_in_active_period; Bool ignore_mpd_duration; - u32 initial_time_shift_percent; + u32 initial_time_shift_value; /*list of groups in the active period*/ GF_List *groups; @@ -108,7 +108,7 @@ struct __dash_client GF_DASH_STATE dash_state; Bool mpd_stop_request; Bool in_period_setup; - + u32 nb_buffering; u32 idle_interval; @@ -217,7 +217,7 @@ struct __dash_group Bool buffering; u32 maybe_end_of_stream; u32 cache_duration; - u32 time_at_first_reload_required; + u32 time_at_first_reload_required; u32 force_representation_idx_plus_one; Bool force_segment_switch; @@ -254,21 +254,21 @@ static const char *gf_dash_get_mime_type(GF_MPD_SubRepresentation *subrep, GF_MP return NULL; } -static void gf_dash_buffer_off(GF_DASH_Group *group) +static void gf_dash_buffer_off(GF_DASH_Group *group) { if (!group->dash->enable_buffering) return; - if (group->buffering) { - assert(group->dash->nb_buffering); - group->dash->nb_buffering--; + if (group->buffering) { + assert(group->dash->nb_buffering); + group->dash->nb_buffering--; if (!group->dash->nb_buffering) { - group->dash->dash_io->on_dash_event(group->dash->dash_io, GF_DASH_EVENT_BUFFER_DONE, -1, GF_OK); + group->dash->dash_io->on_dash_event(group->dash->dash_io, GF_DASH_EVENT_BUFFER_DONE, -1, GF_OK); GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH] Session buffering done\n")); } group->buffering = 0; - } + } } -static void gf_dash_buffer_on(GF_DASH_Group *group) +static void gf_dash_buffer_on(GF_DASH_Group *group) { if (!group->dash->enable_buffering) return; @@ -276,7 +276,7 @@ static void gf_dash_buffer_on(GF_DASH_Group *group) if (!group->dash->nb_buffering) { GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH] Starting session buffering\n")); } - group->dash->nb_buffering++; + group->dash->nb_buffering++; group->buffering = 1; } } @@ -287,7 +287,7 @@ static u64 dash_get_fetch_time(GF_DashClient *dash) if (dash->mpd_dnload && dash->dash_io->get_utc_start_time) utc = dash->dash_io->get_utc_start_time(dash->dash_io, dash->mpd_dnload); - if (!utc) + if (!utc) utc = gf_net_get_utc(); return utc; } @@ -337,7 +337,7 @@ void gf_dash_get_buffer_info_buffering(GF_DashClient *dash, u32 *total_buffer, u nb_buffering += gf_dash_group_count_rep_needed(group); } } - if (*media_buffered > *total_buffer) + if (*media_buffered > *total_buffer) *media_buffered = *total_buffer; *total_buffer /= nb_buffering; *media_buffered /= nb_buffering; @@ -349,7 +349,7 @@ static void gf_dash_update_buffering(GF_DASH_Group *group, GF_DashClient *dash) if (dash->nb_buffering) { dash->dash_io->on_dash_event(dash->dash_io, GF_DASH_EVENT_BUFFERING, -1, GF_OK); - if (group->cached[0].duration && group->nb_cached_segments>=group->max_buffer_segments) + if (group->cached[0].duration && group->nb_cached_segments>=group->max_buffer_segments) gf_dash_buffer_off(group); } } @@ -381,25 +381,25 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 u64 current_time, current_time_no_timeshift, availabilityStartTime; u32 ast_diff, start_number; Double ast_offset = 0; - - if (mpd->type==GF_MPD_TYPE_STATIC) + + if (mpd->type==GF_MPD_TYPE_STATIC) return; - + /*M3U8 does not use NTP sync */ if (group->dash->is_m3u8) return; if (group->broken_timing ) return; - - + + /*if no AST, do not use NTP sync */ if (! group->dash->mpd->availabilityStartTime) { group->broken_timing = 1; return; } - //temp hack + //temp hack mpd->media_presentation_duration = 0; if (!fetch_time) fetch_time = group->dash->mpd_fetch_time; @@ -428,7 +428,7 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 #ifdef FORCE_DESYNC availabilityStartTime -= FORCE_DESYNC; #endif - + ast_diff = (u32) (availabilityStartTime - group->dash->mpd->availabilityStartTime); current_time = fetch_time; @@ -450,11 +450,11 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 } else if (t1 && t2) { t1->tm_year = t2->tm_year; - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Error in UTC clock: current time %d-%02d-%02dT%02d:%02d:%02dZ is less than AST %d-%02d-%02dT%02d:%02d:%02dZ - diff AST-now %d ms\n", - 1900+t1->tm_year, t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min, t1->tm_sec, - 1900+t2->tm_year, t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min, t2->tm_sec, - (u32) (availabilityStartTime - current_time) - )); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Error in UTC clock: current time %d-%02d-%02dT%02d:%02d:%02dZ is less than AST %d-%02d-%02dT%02d:%02d:%02dZ - diff AST-now %d ms\n", + 1900+t1->tm_year, t1->tm_mon+1, t1->tm_mday, t1->tm_hour, t1->tm_min, t1->tm_sec, + 1900+t2->tm_year, t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min, t2->tm_sec, + (u32) (availabilityStartTime - current_time) + )); } else { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Error in UTC clock: could not retrieve time!\n")); } @@ -471,10 +471,10 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 } } else { availabilityStartTime = current_time; - current_time = 0; + current_time = 0; } } - else current_time -= availabilityStartTime; + else current_time -= availabilityStartTime; if (current_time < group->period->start) current_time = 0; else current_time -= group->period->start; @@ -484,7 +484,7 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 s32 diff = (s32) current_time - (s32) (mpd->media_presentation_duration); if (ABS(diff)>10) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Broken UTC timing in client or server - got Media URL is not set in segment list\n")); - + } current_time = mpd->media_presentation_duration; } @@ -493,10 +493,15 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 current_time_no_timeshift = current_time; if ( ((s32) mpd->time_shift_buffer_depth>=0)) { - if (group->dash->initial_time_shift_percent) { - shift = mpd->time_shift_buffer_depth; - shift *= group->dash->initial_time_shift_percent; - shift /= 100; + if (group->dash->initial_time_shift_value) { + if (group->dash->initial_time_shift_value<=100) { + shift = mpd->time_shift_buffer_depth; + shift *= group->dash->initial_time_shift_value; + shift /= 100; + } else { + shift = (u32) group->dash->initial_time_shift_value; + if (shift > mpd->time_shift_buffer_depth) shift = mpd->time_shift_buffer_depth; + } if (current_time < shift) current_time = 0; else current_time -= shift; @@ -568,7 +573,7 @@ static void gf_dash_group_timeline_setup(GF_MPD *mpd, GF_DASH_Group *group, u64 GF_MPD_SegmentTimelineEntry *ent = gf_list_get(timeline->entries, i); if (!i && (current_time_rescale + ent->duration < ent->start_time)) { - current_time_rescale = current_time_no_timeshift * timescale / 1000; + current_time_rescale = current_time_no_timeshift * timescale / 1000; } timeline_duration += (1+ent->repeat_count)*ent->duration; @@ -686,7 +691,7 @@ static Bool gf_dash_is_dash_mime(const char * mime) { u32 i; if (!mime) return 0; - for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i] ; i++){ + for (i = 0 ; GF_DASH_MPD_MIME_TYPES[i] ; i++) { if ( !stricmp(mime, GF_DASH_MPD_MIME_TYPES[i])) return 1; } @@ -752,7 +757,7 @@ GF_Err gf_dash_group_check_bandwidth(GF_DashClient *dash, u32 idx) GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH] Downloading from set #%d at rate %d kbps but media bitrate is %d kbps - no lower bitrate available ...\n", set_idx, download_rate/1024, group->active_bitrate/1024 )); return GF_OK; } - + //TODO - when do we start checking ? if (time_since_start < 200) { @@ -791,13 +796,13 @@ GF_Err gf_dash_group_check_bandwidth(GF_DashClient *dash, u32 idx) //compute min bitrate needed to fetch the segement in another rep, with the time remaining Double ratio = ((u32)group->current_downloaded_segment_duration - time_since_start); ratio /= (u32)group->current_downloaded_segment_duration; - + target_rate = (u32) (download_rate * ratio); - + if (target_rate < group->min_representation_bitrate) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] Download rate lower than min available rate ...\n")); target_rate = group->min_representation_bitrate; - //don't force bandwidth switch, we won't have time to redownload the segment. + //don't force bandwidth switch, we won't have time to redownload the segment. group->force_switch_bandwidth = default_switch_mode; } else { group->force_switch_bandwidth = 1; @@ -812,9 +817,9 @@ GF_Err gf_dash_group_check_bandwidth(GF_DashClient *dash, u32 idx) /*! * Download a file with possible retry if GF_IP_CONNECTION_FAILURE|GF_IP_NETWORK_FAILURE * (I discovered that with my WIFI connection, I had many issues with BFM-TV downloads) -* Similar to gf_term_download_new() and gf_dm_sess_process(). -* Parameters are identical to the ones of gf_term_download_new. -* \see gf_term_download_new() +* Similar to gf_service_download_new() and gf_dm_sess_process(). +* Parameters are identical to the ones of gf_service_download_new. +* \see gf_service_download_new() */ GF_Err gf_dash_download_resource(GF_DASHFileIO *dash_io, GF_DASHFileIOSession *sess, const char *url, u64 start_range, u64 end_range, u32 persistent_mode, GF_DASH_Group *group) { @@ -831,7 +836,7 @@ GF_Err gf_dash_download_resource(GF_DASHFileIO *dash_io, GF_DASHFileIOSession *s if (! *sess) { *sess = dash_io->create(dash_io, persistent_mode ? 1 : 0, url, group_idx); - if (!(*sess)){ + if (!(*sess)) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Cannot try to download %s... OUT of memory ?\n", url)); return GF_OUT_OF_MEM; } @@ -866,7 +871,7 @@ retry: return e; } } - assert(*sess); + assert(*sess); /*issue HTTP GET for headers only*/ e = dash_io->init(dash_io, *sess); @@ -877,12 +882,12 @@ retry: const char *mime = dash_io->get_mime(dash_io, *sess); if (mime && !group->service_mime) { group->service_mime = gf_strdup(mime); - } + } /*we allow servers to give us broken mim types for the representation served ...*/ #if 0 else if (mime && stricmp(group->service_mime, mime)) { GF_MPD_Representation *rep = gf_list_get(group->adaptation_set->representations, group->active_rep_index); - if (! gf_dash_get_mime_type(NULL, rep, group->adaptation_set) ) + if (! gf_dash_get_mime_type(NULL, rep, group->adaptation_set) ) rep->mime_type = gf_strdup(mime); rep->disabled = 1; GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] Disabling representation since mime does not match: expected %s, but had %s for %s!\n", group->service_mime, mime, url)); @@ -902,9 +907,9 @@ retry: if (group->segment_download) dash_io->abort(dash_io, group->segment_download); group->is_downloading = 1; return GF_OK; - } + } group->segment_must_be_streamed = 0; - } + } /*we can download the file*/ e = dash_io->run(dash_io, *sess); @@ -942,16 +947,48 @@ retry: return e; } -static void gf_dash_get_timeline_duration(GF_MPD_SegmentTimeline *timeline, u32 *nb_segments, Double *max_seg_duration) +static void gf_dash_get_timeline_duration(GF_MPD *mpd, GF_MPD_Period *period, GF_MPD_SegmentTimeline *timeline, u32 timescale, u32 *nb_segments, Double *max_seg_duration) { u32 i, count; + u64 period_duration, start_time, dur; + if (period->duration) { + period_duration = period->duration; + } else { + period_duration = mpd->media_presentation_duration - period->start; + } + period_duration *= timescale; + period_duration /= 1000; *nb_segments = 0; if (max_seg_duration) *max_seg_duration = 0; + start_time = 0; + dur = 0; count = gf_list_count(timeline->entries); for (i=0; ientries, i); - *nb_segments += 1 + ent->repeat_count; + if ((s32)ent->repeat_count >=0) { + *nb_segments += 1 + ent->repeat_count; + if (ent->start_time) { + start_time = ent->start_time; + dur = (1 + ent->repeat_count) * ent->duration; + } else { + dur += (1 + ent->repeat_count) * ent->duration; + } + } else { + u32 nb_seg = 0; + if (i+1entries, i+1); + if (ent2->start_time>0) { + nb_seg = (u32) ( (ent2->start_time - start_time - dur) / ent->duration); + dur += nb_seg * ent->duration; + } + } + if (!nb_seg) { + nb_seg = (u32) ( (period_duration - start_time) / ent->duration ); + dur += nb_seg * ent->duration; + } + *nb_segments += nb_seg; + } if (max_seg_duration && (*max_seg_duration < ent->duration)) *max_seg_duration = ent->duration; } } @@ -989,10 +1026,10 @@ static void gf_dash_get_segment_duration(GF_MPD_Representation *rep, GF_MPD_Adap if (! timescale) timescale=1; if (timeline) { - gf_dash_get_timeline_duration(timeline, nb_segments, max_seg_duration); + gf_dash_get_timeline_duration(mpd, period, timeline, timescale, nb_segments, max_seg_duration); if (max_seg_duration) *max_seg_duration /= timescale; } else { - if (segments) + if (segments) *nb_segments = gf_list_count(segments); if (max_seg_duration) { *max_seg_duration = (Double) duration; @@ -1040,7 +1077,7 @@ static void gf_dash_get_segment_duration(GF_MPD_Representation *rep, GF_MPD_Adap } if (timeline) { - gf_dash_get_timeline_duration(timeline, nb_segments, max_seg_duration); + gf_dash_get_timeline_duration(mpd, period, timeline, timescale, nb_segments, max_seg_duration); if (max_seg_duration) *max_seg_duration /= timescale; } else { if (max_seg_duration) { @@ -1048,7 +1085,17 @@ static void gf_dash_get_segment_duration(GF_MPD_Representation *rep, GF_MPD_Adap *max_seg_duration /= timescale; } mediaDuration = period->duration; - if (!mediaDuration) mediaDuration = mpd->media_presentation_duration; + if (!mediaDuration) { + u32 i, count = gf_list_count(mpd->periods); + Double start = 0; + for (i=0; iperiods, i); + if (ap==period) break; + if (ap->start) start = ap->start; + start += ap->duration; + } + mediaDuration = mpd->media_presentation_duration - start; + } if (mediaDuration && duration) { Double nb_seg = (Double) mediaDuration; /*duration is given in ms*/ @@ -1068,10 +1115,10 @@ static u64 gf_dash_segment_timeline_start(GF_MPD_SegmentTimeline *timeline, u32 idx = 0; for (i=0; ientries); i++) { GF_MPD_SegmentTimelineEntry *ent = gf_list_get(timeline->entries, i); - if (ent->start_time) start_time = ent->start_time; + if (ent->start_time) start_time = ent->start_time; for (k=0; krepeat_count+1; k++) { if (idx==segment_index) { - if (segment_duration) + if (segment_duration) *segment_duration = ent->duration; return start_time; } @@ -1128,8 +1175,8 @@ static u64 gf_dash_get_segment_start_time_with_timescale(GF_DASH_Group *group, u } else { start_time = segment_index * duration; } - if (segment_duration) *segment_duration = duration; - if (scale) *scale = timescale; + if (segment_duration) *segment_duration = duration; + if (scale) *scale = timescale; return start_time; } @@ -1156,8 +1203,8 @@ static u64 gf_dash_get_segment_start_time_with_timescale(GF_DASH_Group *group, u } else { start_time = segment_index * duration; } - if (segment_duration) *segment_duration = duration; - if (scale) *scale = timescale; + if (segment_duration) *segment_duration = duration; + if (scale) *scale = timescale; return start_time; } @@ -1316,8 +1363,8 @@ static GF_Err gf_dash_merge_segment_timeline(GF_DASH_Group *group, GF_DashClient if (!old_timeline && !new_timeline) return GF_OK; prev_count = gf_list_count(old_timeline->entries); - - + + if (group) { group->current_start_time = gf_dash_get_segment_start_time_with_timescale(group, NULL, &group->current_timescale); } else { @@ -1326,15 +1373,15 @@ static GF_Err gf_dash_merge_segment_timeline(GF_DASH_Group *group, GF_DashClient a_group->current_start_time = gf_dash_get_segment_start_time_with_timescale(a_group, NULL, &a_group->current_timescale); } } - - + + first_new_entry = gf_list_get(new_timeline->entries, 0); idx = 0; start_time=0; while (1) { GF_MPD_SegmentTimelineEntry *ent = gf_list_get(old_timeline->entries, 0); if (!ent) break; - if (ent->start_time) + if (ent->start_time) start_time = ent->start_time; /*if starttime is equal or greater than first entry in new timeline, we're done*/ if (start_time >= first_new_entry->start_time) @@ -1345,7 +1392,7 @@ static GF_Err gf_dash_merge_segment_timeline(GF_DASH_Group *group, GF_DashClient ent->repeat_count--; } /*we will insert the first entry in the new timeline, make sure we have a start*/ - if (!idx && !ent->start_time) + if (!idx && !ent->start_time) ent->start_time = start_time; start_time += ent->duration * (1 + ent->repeat_count); @@ -1481,7 +1528,7 @@ static GF_Err gf_dash_update_manifest(GF_DashClient *dash) if (!strstr(dash->base_url, "://")) { gf_free(dash->base_url); dash->base_url = gf_strdup(purl); - } + } fetch_only = 1; } } else { @@ -1543,13 +1590,13 @@ static GF_Err gf_dash_update_manifest(GF_DashClient *dash) if (gf_sha1_file( local_url, signature)) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] : cannot SHA1 file %s\n", local_url)); return GF_IO_ERR; - } + } if (! memcmp( signature, dash->lastMPDSignature, sizeof(dash->lastMPDSignature))) { dash->reload_count++; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH] MPD file did not change for %d consecutive reloads\n", dash->reload_count)); - /*if the MPD did not change, we should refresh "soon" but cannot wait a full refresh cycle in case of + /*if the MPD did not change, we should refresh "soon" but cannot wait a full refresh cycle in case of low latencies as we could miss a segment*/ if (dash->is_m3u8) { @@ -1558,7 +1605,7 @@ static GF_Err gf_dash_update_manifest(GF_DashClient *dash) dash->last_update_time = gf_sys_clock(); } return GF_OK; - } + } dash->reload_count = 0; memccpy(dash->lastMPDSignature, signature, sizeof(char), sizeof(dash->lastMPDSignature)); @@ -1811,7 +1858,7 @@ static GF_Err gf_dash_update_manifest(GF_DashClient *dash) if (reset_segment_count) { u32 nb_segs_in_mpd_period = (u32) (dash->mpd->minimum_update_period / (1000*seg_dur) ); group->nb_segments_in_rep = group->download_segment_index + nb_segs_in_mpd_period; - } + } /*check if number of segments are coherent ...*/ else if (!group->maybe_end_of_stream && new_mpd->minimum_update_period && new_mpd->media_presentation_duration) { u32 nb_segs_in_mpd_period = (u32) (dash->mpd->minimum_update_period / (1000*seg_dur) ); @@ -1922,7 +1969,7 @@ static void gf_dash_switch_group_representation(GF_DashClient *mpd, GF_DASH_Grou if (group->force_representation_idx_plus_one) { rep_sel = gf_list_get(group->adaptation_set->representations, group->force_representation_idx_plus_one - 1); group->force_representation_idx_plus_one = 0; - } + } if (!rep_sel) { for (i=0; iadaptation_set->representations); i++) { @@ -2032,7 +2079,7 @@ static GF_Err gf_dash_resolve_url(GF_MPD *mpd, GF_MPD_Representation *rep, GF_DA /*single URL*/ // if (rep->segment_base || set->segment_base || period->segment_base) { - if (!rep->segment_list && !set->segment_list && !period->segment_list && !rep->segment_template && !set->segment_template && !period->segment_template) { + if (!rep->segment_list && !set->segment_list && !period->segment_list && !rep->segment_template && !set->segment_template && !period->segment_template) { GF_MPD_URL *res_url; GF_MPD_SegmentBase *base_seg = NULL; if (item_index > 0) @@ -2082,7 +2129,7 @@ static GF_Err gf_dash_resolve_url(GF_MPD *mpd, GF_MPD_Representation *rep, GF_DA } /*segmentList*/ - if (rep->segment_list || set->segment_list || period->segment_list) { + if (rep->segment_list || set->segment_list || period->segment_list) { GF_MPD_URL *init_url, *index_url; GF_MPD_SegmentURL *segment; GF_List *segments = NULL; @@ -2254,7 +2301,7 @@ static GF_Err gf_dash_resolve_url(GF_MPD *mpd, GF_MPD_Representation *rep, GF_DA } second_sep[0] = 0; format_tag = strchr(first_sep+1, '%'); - + if (format_tag) { strcpy(szPrintFormat, format_tag); format_tag[0] = 0; @@ -2334,7 +2381,7 @@ static GF_Err gf_dash_resolve_url(GF_MPD *mpd, GF_MPD_Representation *rep, GF_DA /*look for next keyword - copy over remaining text if any*/ first_sep = strchr(second_sep+1, '$'); if (first_sep) first_sep[0] = 0; - if (strlen(second_sep+1)) + if (strlen(second_sep+1)) strcat(solved_template, second_sep+1); if (first_sep) first_sep[0] = '$'; } @@ -2491,7 +2538,7 @@ static GF_Err gf_dash_download_init_segment(GF_DashClient *dash, GF_DASH_Group * strcpy(mime, mime_type ? mime_type : ""); strlwr(mime); - if (dash->mimeTypeForM3U8Segments) + if (dash->mimeTypeForM3U8Segments) gf_free(dash->mimeTypeForM3U8Segments); dash->mimeTypeForM3U8Segments = gf_strdup( mime ); mime_type = gf_dash_get_mime_type(NULL, rep, group->adaptation_set); @@ -2531,7 +2578,7 @@ static GF_Err gf_dash_download_init_segment(GF_DashClient *dash, GF_DASH_Group * gf_mx_v(dash->dl_mutex); gf_free(base_init_url); return GF_BAD_PARAM; - } + } assert(!group->nb_cached_segments); group->cached[0].cache = gf_strdup(group->segment_local_url); @@ -2649,7 +2696,7 @@ static void gf_dash_reset_groups(GF_DashClient *dash) gf_dash_group_reset(dash, group); gf_free(group->cached); - if (group->service_mime) + if (group->service_mime) gf_free(group->service_mime); gf_free(group); } @@ -2716,6 +2763,7 @@ GF_Err gf_dash_setup_groups(GF_DashClient *dash) for (j=0; jrepresentations); j++) { Double dur; u32 nb_seg, k; + Bool cp_supported; GF_MPD_Representation *rep = gf_list_get(set->representations, j); gf_dash_get_segment_duration(rep, set, period, dash->mpd, &nb_seg, &dur); if (dur>seg_dur) seg_dur = dur; @@ -2756,7 +2804,36 @@ GF_Err gf_dash_setup_groups(GF_DashClient *dash) } } } - + + for (k=0; kessential_properties); k++) { + GF_MPD_Descriptor *mpd_desc = gf_list_get(rep->essential_properties, k); + //we don't know any defined scheme for now + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] Representation with unrecognized EssentialProperty %s - ignoring because not supported\n", mpd_desc->scheme_id_uri)); + rep->playback.disabled = 1; + break; + } + if (rep->playback.disabled) { + continue; + } + + cp_supported = 1; + for (k=0; kcontent_protection); k++) { + GF_MPD_Descriptor *mpd_desc = gf_list_get(rep->content_protection, k); + //we don't know any defined scheme for now + if (strcmp(mpd_desc->scheme_id_uri, "urn:mpeg:dash:mp4protection:2011")) { + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH] Representation with unrecognized ContentProtection %s\n", mpd_desc->scheme_id_uri)); + cp_supported = 0; + } else { + cp_supported = 1; + break; + } + } + if (!cp_supported) { + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] Representation with no supported ContentProtection\n")); + rep->playback.disabled = 1; + continue; + } + rep->playback.disabled = 0; if (rep->width>set->max_width) { set->max_width = rep->width; @@ -2771,7 +2848,7 @@ GF_Err gf_dash_setup_groups(GF_DashClient *dash) GF_MPD_Representation *a_rep = gf_list_get(set->representations, k); if (a_rep->dependency_id) { char * tmp = strrchr(a_rep->dependency_id, ' '); - if (tmp) + if (tmp) tmp = tmp + 1; else tmp = a_rep->dependency_id; @@ -2840,7 +2917,7 @@ static GF_Err gf_dash_load_sidx(GF_BitStream *bs, GF_MPD_Representation *rep, Bo u32 i, size, type; GF_Err e; u64 offset; - + prev_pos = gf_bs_get_position(bs); gf_bs_seek(bs, sidx_offset); size = gf_bs_read_u32(bs); @@ -2853,7 +2930,7 @@ static GF_Err gf_dash_load_sidx(GF_BitStream *bs, GF_MPD_Representation *rep, Bo gf_bs_seek(bs, sidx_offset); anchor_position = sidx_offset + size; - if (seperate_index) + if (seperate_index) anchor_position = 0; e = gf_isom_parse_box((GF_Box **) &sidx, bs); @@ -2874,7 +2951,7 @@ static GF_Err gf_dash_load_sidx(GF_BitStream *bs, GF_MPD_Representation *rep, Bo GF_SAFEALLOC(seg, GF_MPD_SegmentURL); GF_SAFEALLOC(seg->media_range, GF_MPD_ByteRange); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH] Found media segment size %d - duration %d - start with SAP: %d - SAP type %d - SAP Deltat Time %d\n", - sidx->refs[i].reference_size, sidx->refs[i].subsegment_duration, sidx->refs[i].starts_with_SAP, sidx->refs[i].SAP_type, sidx->refs[i].SAP_delta_time)); + sidx->refs[i].reference_size, sidx->refs[i].subsegment_duration, sidx->refs[i].starts_with_SAP, sidx->refs[i].SAP_type, sidx->refs[i].SAP_delta_time)); seg->media_range->start_range = offset; offset += sidx->refs[i].reference_size; @@ -2899,7 +2976,7 @@ static GF_Err gf_dash_load_representation_sidx(GF_DASH_Group *group, GF_MPD_Repr char *mem_address; if (sscanf(cache_name, "gmem://%d@%p", &size, &mem_address) != 2) { return GF_IO_ERR; - } + } bs = gf_bs_new(mem_address, size, GF_BITSTREAM_READ); } else { FILE *f = gf_f64_open(cache_name, "rb"); @@ -2938,8 +3015,8 @@ static GF_Err dash_load_box_type(const char *cache_name, u32 offset, u32 *box_ty u8 *mem_address; if (sscanf(cache_name, "gmem://%d@%p", &size, &mem_address) != 2) { return GF_IO_ERR; - } - if (offset+8 > size) + } + if (offset+8 > size) return GF_IO_ERR; mem_address+=offset; *box_size = GF_4CC(mem_address[0], mem_address[1], mem_address[2], mem_address[3]); @@ -2968,7 +3045,7 @@ static GF_Err gf_dash_setup_single_index_mode(GF_DASH_Group *group) char *init_url = NULL; char *index_url = NULL; GF_MPD_Representation *rep = gf_list_get(group->adaptation_set->representations, 0); - + if (rep->segment_template || group->adaptation_set->segment_template || group->period->segment_template) return GF_OK; if (rep->segment_list || group->adaptation_set->segment_list || group->period->segment_list) return GF_OK; @@ -2990,7 +3067,7 @@ static GF_Err gf_dash_setup_single_index_mode(GF_DASH_Group *group) if (e) goto exit; - if (is_isom && (init_in_base || index_in_base)) { + if (is_isom && (init_in_base || index_in_base)) { if (!strstr(init_url, "://") || (!strnicmp(init_url, "file://", 7) || !strnicmp(init_url, "views://", 7)) ) { GF_SAFEALLOC(rep->segment_list, GF_MPD_SegmentList); rep->segment_list->segment_URLs =gf_list_new(); @@ -3036,8 +3113,8 @@ static GF_Err gf_dash_setup_single_index_mode(GF_DASH_Group *group) has_seen_sidx = 1; else if (has_seen_sidx) break; - - + + } } if (e<0) goto exit; @@ -3076,7 +3153,7 @@ static GF_Err gf_dash_setup_single_index_mode(GF_DASH_Group *group) } /*reset all seg based stuff*/ - if (rep->segment_base) { + if (rep->segment_base) { gf_mpd_segment_base_free(rep->segment_base); rep->segment_base = NULL; } @@ -3086,7 +3163,7 @@ static GF_Err gf_dash_setup_single_index_mode(GF_DASH_Group *group) gf_free(init_url); init_url = NULL; } - if (group->adaptation_set->segment_base) { + if (group->adaptation_set->segment_base) { gf_mpd_segment_base_free(group->adaptation_set->segment_base); group->adaptation_set->segment_base = NULL; } @@ -3101,7 +3178,7 @@ exit: static GF_Err gf_dash_setup_period(GF_DashClient *dash) { GF_MPD_Period *period; - u32 rep_i, group_i, nb_groups_ok; + u32 rep_i, group_i, j, nb_groups_ok; /*setup all groups*/ gf_dash_setup_groups(dash); @@ -3111,6 +3188,8 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) u32 active_rep, nb_rep; const char *mime_type; u32 nb_rep_ok = 0; + Bool disabled = 0; + Bool cp_supported = 0; GF_DASH_Group *group = gf_list_get(dash->groups, group_i); if ((dash->debug_group_index>=0) && (group_i != (u32) dash->debug_group_index)) { @@ -3129,6 +3208,35 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) continue; } + for (j=0; jadaptation_set->essential_properties); j++) { + GF_MPD_Descriptor *mpd_desc = gf_list_get(group->adaptation_set->essential_properties, j); + //we don't know any defined scheme for now + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] AdaptationSet with unrecognized EssentialProperty %s - ignoring because not supported\n", mpd_desc->scheme_id_uri)); + disabled = 1; + break; + } + if (disabled) { + continue; + } + + cp_supported = 1; + for (j=0; jadaptation_set->content_protection); j++) { + GF_MPD_Descriptor *mpd_desc = gf_list_get(group->adaptation_set->content_protection, j); + //we don't know any defined scheme for now + if (strcmp(mpd_desc->scheme_id_uri, "urn:mpeg:dash:mp4protection:2011")) { + GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH] AdaptationSet with unrecognized ContentProtection %s\n", mpd_desc->scheme_id_uri)); + cp_supported = 0; + } else { + cp_supported = 1; + break; + } + } + if (!cp_supported) { + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] AdaptationSet with no supported ContentProtection - ignoring\n")); + continue; + } + + /*translate from single-indexed file to SegmentList*/ gf_dash_setup_single_index_mode(group); @@ -3193,7 +3301,7 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) } for (rep_i = 0; rep_i < nb_rep; rep_i++) { GF_MPD_Representation *rep = gf_list_get(group->adaptation_set->representations, rep_i); - if (!rep->playback.disabled) + if (!rep->playback.disabled) nb_rep_ok++; } @@ -3207,7 +3315,7 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) gf_dash_set_group_representation(group, rep_sel); - if (dash->playback_start_range>=0) + if (dash->playback_start_range>=0) gf_dash_seek_group(dash, group); mime_type = gf_dash_get_mime_type(NULL, rep_sel, group->adaptation_set); @@ -3219,12 +3327,12 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) /* TODO: Generate segment names if urltemplates are used */ if (!rep_sel->segment_base && !rep_sel->segment_list && !rep_sel->segment_template - && !group->adaptation_set->segment_base && !group->adaptation_set->segment_list && !group->adaptation_set->segment_template - && !group->period->segment_base && !group->period->segment_list && !group->period->segment_template - && !gf_list_count(rep_sel->base_URLs) - ) { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Segment URLs are not present for AdaptationSet - skipping\n")); - continue; + && !group->adaptation_set->segment_base && !group->adaptation_set->segment_list && !group->adaptation_set->segment_template + && !group->period->segment_base && !group->period->segment_list && !group->period->segment_template + && !gf_list_count(rep_sel->base_URLs) + ) { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Segment URLs are not present for AdaptationSet - skipping\n")); + continue; } group->selection = GF_DASH_GROUP_NOT_SELECTED; @@ -3232,8 +3340,8 @@ static GF_Err gf_dash_setup_period(GF_DashClient *dash) } period = gf_list_get(dash->mpd->periods, dash->active_period_index); - - if (period->segment_base) { + + if (period->segment_base) { gf_mpd_segment_base_free(period->segment_base); period->segment_base = NULL; } @@ -3251,7 +3359,7 @@ static void dash_do_rate_adaptation(GF_DashClient *dash, GF_DASH_Group *group, G { GF_MPD_Representation *new_rep; u32 total_size, bytes_per_sec; - + if (group->dash->disable_switching) return; total_size = dash->dash_io->get_total_size(dash->dash_io, group->segment_download); @@ -3278,7 +3386,7 @@ static void dash_do_rate_adaptation(GF_DashClient *dash, GF_DASH_Group *group, G /*find best bandwidth that fits our bitrate*/ new_rep = NULL; - + for (k=0; kadaptation_set->representations); k++) { GF_MPD_Representation *arep = gf_list_get(group->adaptation_set->representations, k); if (arep->playback.disabled) continue; @@ -3440,13 +3548,14 @@ restart_period: if (all_groups_done && dash->request_period_switch) { gf_dash_reset_groups(dash); - if (dash->request_period_switch == 1) + if (dash->request_period_switch == 1) dash->active_period_index++; dash->request_period_switch = 0; goto restart_period; } + gf_sleep(30); } } @@ -3460,8 +3569,8 @@ restart_period: min_wait = 0; /*for each selected groups*/ - for (i=0; igroups, i); - + if (group->selection != GF_DASH_GROUP_SELECTED) { if (group->nb_cached_segments) { gf_dash_group_reset(dash, group); @@ -3523,14 +3632,14 @@ restart_period: GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH] End of segment list reached (%d segments but idx is %d), waiting for next MPD update\n", group->nb_segments_in_rep, group->download_segment_index)); if (group->nb_cached_segments) continue; - + if (!group->time_at_first_reload_required) { group->time_at_first_reload_required = now; continue; } if (now - group->time_at_first_reload_required < group->cache_duration) continue; - + GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] Segment list has not been updated for more than %d ms - assuming end of stream\n", now - group->time_at_first_reload_required)); group->done = 1; break; @@ -3572,7 +3681,7 @@ restart_period: continue; } - clock_time = gf_sys_clock(); + clock_time = gf_sys_clock(); to_wait = (s32) (segment_ast - now); /*if segment AST is greater than now, it is not yet available - we would need an estimate on how long the request takes to be sent to the server in order to be more reactive ...*/ @@ -3616,7 +3725,7 @@ restart_period: /*local file*/ if (!strstr(new_base_seg_url, "://") || (!strnicmp(new_base_seg_url, "file://", 7) || !strnicmp(new_base_seg_url, "gmem://", 7)) ) { - resource_name = local_file_name = (char *) new_base_seg_url; + resource_name = local_file_name = (char *) new_base_seg_url; e = GF_OK; /*do not erase local files*/ group->local_files = 1; @@ -3676,7 +3785,7 @@ restart_period: GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Too many consecutive segments not found, sync or signal has been lost - entering end of stream detection mode\n")); min_wait = 1000; group->maybe_end_of_stream = 1; - } else + } else #endif { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Error in downloading new segment: %s %s\n", new_base_seg_url, gf_error_to_string(e))); @@ -3694,7 +3803,7 @@ restart_period: group->time_at_first_failure = 0; group->nb_consecutive_fail = 0; } - + if ((e==GF_OK) && group->force_switch_bandwidth) { if (!dash->auto_switch_count) { gf_dash_switch_group_representation(dash, group); @@ -3716,13 +3825,13 @@ restart_period: if (group->segment_must_be_streamed) local_file_name = dash->dash_io->get_url(dash->dash_io, group->segment_download); else local_file_name = dash->dash_io->get_cache_name(dash->dash_io, group->segment_download); - + if (dash->dash_io->get_total_size(dash->dash_io, group->segment_download)==0) { empty_file = GF_TRUE; } resource_name = dash->dash_io->get_url(dash->dash_io, group->segment_download); - if (!dash->auto_switch_count) + if (!dash->auto_switch_count) dash_do_rate_adaptation(dash, group, rep); } @@ -3768,7 +3877,7 @@ restart_period: gf_mx_v(dash->dl_mutex); - dash->dash_io->on_dash_event(dash->dash_io, GF_DASH_EVENT_SEGMENT_AVAILABLE, gf_list_find(dash->groups, group), GF_OK); + dash->dash_io->on_dash_event(dash->dash_io, GF_DASH_EVENT_SEGMENT_AVAILABLE, gf_list_find(dash->groups, group), GF_OK); } gf_free(new_base_seg_url); @@ -3903,7 +4012,7 @@ static void gf_dash_seek_group(GF_DashClient *dash, GF_DASH_Group *group) segment_idx = 0; seg_start = 0.0; while (1) { - if ((dash->playback_start_range >= seg_start) && (dash->playback_start_range < seg_start + group->segment_duration)) + if ((dash->playback_start_range >= seg_start) && (dash->playback_start_range < seg_start + group->segment_duration)) break; seg_start += group->segment_duration; segment_idx++; @@ -3920,8 +4029,8 @@ static void gf_dash_seek_group(GF_DashClient *dash, GF_DASH_Group *group) group->force_segment_switch = 1; group->download_segment_index = segment_idx; - - if (group->segment_download) + + if (group->segment_download) dash->dash_io->abort(dash->dash_io, group->segment_download); if (group->urlToDeleteNext) { @@ -4199,17 +4308,16 @@ GF_DashClient *gf_dash_new(GF_DASHFileIO *dash_io, u32 max_cache_duration, u32 a dash->max_cache_duration = max_cache_duration; dash->enable_buffering = enable_buffering; - dash->initial_time_shift_percent = initial_time_shift_percent; - if (initial_time_shift_percent>100) dash->initial_time_shift_percent = 100; + dash->initial_time_shift_value = initial_time_shift_percent; dash->auto_switch_count = auto_switch_count; dash->keep_files = keep_files; dash->disable_switching = disable_switching; - dash->first_select_mode = first_select_mode; + dash->first_select_mode = first_select_mode; dash->idle_interval = 1000; dash->min_timeout_between_404 = 500; dash->segment_lost_after_ms = 100; - + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH] Client created\n")); return dash; } @@ -4220,7 +4328,7 @@ void gf_dash_del(GF_DashClient *dash) gf_dash_close(dash); gf_th_del(dash->dash_thread); - gf_mx_del(dash->dl_mutex); + gf_mx_del(dash->dl_mutex); if (dash->mimeTypeForM3U8Segments) gf_free(dash->mimeTypeForM3U8Segments); if (dash->base_url) gf_free(dash->base_url); @@ -4481,7 +4589,7 @@ const char *gf_dash_group_get_segment_init_url(GF_DashClient *dash, u32 idx, u64 if (!group) return NULL; if (start_range) *start_range = group->local_url_start_range; - if (end_range) *end_range = group->local_url_end_range; + if (end_range) *end_range = group->local_url_end_range; return group->segment_local_url; } @@ -4506,10 +4614,10 @@ void gf_dash_group_select(GF_DashClient *dash, u32 idx, Bool select) /*either one Representation from group 0, if present,*/ if ((group->adaptation_set->group==0) - /*or the combination of at most one Representation from each non-zero group*/ - || (group->adaptation_set->group==agroup->adaptation_set->group) - ) { - agroup->selection = GF_DASH_GROUP_NOT_SELECTED; + /*or the combination of at most one Representation from each non-zero group*/ + || (group->adaptation_set->group==agroup->adaptation_set->group) + ) { + agroup->selection = GF_DASH_GROUP_NOT_SELECTED; } } } @@ -4534,13 +4642,13 @@ void gf_dash_groups_set_language(GF_DashClient *dash, const char *lang_3cc) } GF_EXPORT -Bool gf_dash_is_running(GF_DashClient *dash) +Bool gf_dash_is_running(GF_DashClient *dash) { return (dash->dash_state==GF_DASH_STATE_STOPPED) ? 0 : 1; } GF_EXPORT -u32 gf_dash_get_period_switch_status(GF_DashClient *dash) +u32 gf_dash_get_period_switch_status(GF_DashClient *dash) { return dash->request_period_switch; } @@ -4550,12 +4658,12 @@ void gf_dash_request_period_switch(GF_DashClient *dash) dash->request_period_switch = 1; } GF_EXPORT -Bool gf_dash_in_last_period(GF_DashClient *dash) +Bool gf_dash_in_last_period(GF_DashClient *dash) { return (dash->active_period_index+1 < gf_list_count(dash->mpd->periods)) ? 0 : 1; } GF_EXPORT -Bool gf_dash_in_period_setup(GF_DashClient *dash) +Bool gf_dash_in_period_setup(GF_DashClient *dash) { return dash->in_period_setup; } @@ -4602,7 +4710,7 @@ void gf_dash_group_discard_segment(GF_DashClient *dash, u32 idx) discard_segment: if (!group->nb_cached_segments) { - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return; } if (group->cached[0].cache) { @@ -4685,10 +4793,10 @@ GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 if (switching_index) *switching_index = -1; if (has_next_segment) *has_next_segment = GF_FALSE; - gf_mx_p(dash->dl_mutex); + gf_mx_p(dash->dl_mutex); group = gf_list_get(dash->groups, idx); if (!group->nb_cached_segments) { - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return GF_BAD_PARAM; } @@ -4703,7 +4811,7 @@ GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 if (rep->enhancement_rep_index_plus_one != group->cached[index+1].representation_index + 1) valid = GF_FALSE; if (valid == GF_FALSE) { - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return GF_BAD_PARAM; } index ++; @@ -4712,7 +4820,7 @@ GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 assert(dependent_representation_index==0); *url = group->cached[index].cache; - if (start_range) + if (start_range) *start_range = group->cached[index].start_range; if (end_range) *end_range = group->cached[index].end_range; @@ -4733,13 +4841,13 @@ GF_Err gf_dash_group_get_next_segment_location(GF_DashClient *dash, u32 idx, u32 if (group->cached[index+1].cache) { GF_MPD_Representation *rep; - + rep = gf_list_get(group->adaptation_set->representations, group->cached[index].representation_index); if (rep->enhancement_rep_index_plus_one == group->cached[index+1].representation_index+1) { - if (has_next_segment) *has_next_segment = GF_TRUE; + if (has_next_segment) *has_next_segment = GF_TRUE; } } - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return GF_OK; } @@ -4753,10 +4861,10 @@ GF_Err gf_dash_group_probe_current_download_segment_location(GF_DashClient *dash if (original_url) *original_url = NULL; if (switching_index) *switching_index = -1; - gf_mx_p(dash->dl_mutex); + gf_mx_p(dash->dl_mutex); group = gf_list_get(dash->groups, idx); if (!group) { - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return GF_BAD_PARAM; } @@ -4781,22 +4889,22 @@ GF_Err gf_dash_group_probe_current_download_segment_location(GF_DashClient *dash if (switching_url) *switching_url = rep->playback.cached_init_segment_url; } - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); return GF_OK; } GF_EXPORT void gf_dash_seek(GF_DashClient *dash, Double start_range) { - gf_mx_p(dash->dl_mutex); - + gf_mx_p(dash->dl_mutex); + dash->playback_start_range = start_range; /*first check if we seek to another period*/ if (! gf_dash_seek_periods(dash)) { /*if no, seek in group*/ gf_dash_seek_groups(dash); } - gf_mx_v(dash->dl_mutex); + gf_mx_v(dash->dl_mutex); } GF_EXPORT @@ -5037,7 +5145,7 @@ GF_Err gf_dash_resync_to_segment(GF_DashClient *dash, const char *latest_segment GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Loop in segment start numbers detected - old start %d new seg %d\n", start_number , latest_segment_number)); loop_detected = GF_TRUE; } - //we are behind live + //we are behind live else if (nb_seg_diff<0) { //we fall in the buffer of the sender, we liklely have a loss if (nb_seg_diff + range_in >= 0) { @@ -5058,7 +5166,7 @@ GF_Err gf_dash_resync_to_segment(GF_DashClient *dash, const char *latest_segment group = gf_list_get(dash->groups, i); //force reinit of timeline for this group group->start_number_at_last_ast = 0; - if (loop_detected) + if (loop_detected) group->loop_detected = GF_TRUE; } dash->force_mpd_update = GF_TRUE; @@ -5066,7 +5174,7 @@ GF_Err gf_dash_resync_to_segment(GF_DashClient *dash, const char *latest_segment return GF_OK; } - //TODO segment list adressing: + //TODO segment list adressing: return GF_OK; } diff --git a/src/media_tools/dash_segmenter.c b/src/media_tools/dash_segmenter.c index b6a0b0b..3ef541f 100644 --- a/src/media_tools/dash_segmenter.c +++ b/src/media_tools/dash_segmenter.c @@ -35,6 +35,7 @@ #endif #include +#ifndef GPAC_DISABLE_ISOM_WRITE #ifdef GPAC_DISABLE_ISOM /*we should need a better way to work with sidx when no isom is defined*/ #define GPAC_DISABLE_MPEG2TS @@ -55,7 +56,7 @@ struct _dash_component u32 sample_rate, channels; /*apply to any media. We use 5 bytes because we may use copy data converted from gf_4cc_to_str which is 5 bytes*/ char szLang[5]; -}; +}; typedef struct { @@ -128,13 +129,17 @@ struct _dash_segment_input u32 trackNum, lower_layer_track, nb_representations, idx_representations; //increase sequence number between consecutive segments by this amount (for scalable reps) u32 moof_seqnum_increase; - + u32 protection_scheme_type; /*all these shall be set after call to dasher_get_components_info*/ Double duration; struct _dash_component components[20]; u32 nb_components; + + //spatial info for tiling + u32 x, y, w, h; + }; @@ -152,7 +157,7 @@ struct _dash_segment_input } \ } \ char_template+=1; \ - + GF_EXPORT GF_Err gf_media_mpd_format_segment_name(GF_DashTemplateSegmentType seg_type, Bool is_bs_switching, char *segment_name, const char *output_file_name, const char *rep_id, const char *seg_rad_name, const char *seg_ext, u64 start_time, u32 bandwidth, u32 segment_number, Bool use_segment_timeline) { @@ -167,9 +172,9 @@ GF_Err gf_media_mpd_format_segment_name(GF_DashTemplateSegmentType seg_type, Boo char tmp[100]; strcpy(segment_name, ""); - if (seg_rad_name && (strstr(seg_rad_name, "$RepresentationID$") || strstr(seg_rad_name, "$ID$") || strstr(seg_rad_name, "$Bandwidth$"))) + if (seg_rad_name && (strstr(seg_rad_name, "$RepresentationID$") || strstr(seg_rad_name, "$ID$") || strstr(seg_rad_name, "$Bandwidth$"))) needs_init = GF_FALSE; - + if (!seg_rad_name) { strcpy(segment_name, output_file_name); } else { @@ -177,10 +182,10 @@ GF_Err gf_media_mpd_format_segment_name(GF_DashTemplateSegmentType seg_type, Boo while (1) { char c = seg_rad_name[char_template]; if (!c) break; - - if (!is_template && !is_init_template - && (!strnicmp(& seg_rad_name[char_template], "$RepresentationID$", 18) || !strnicmp(& seg_rad_name[char_template], "$ID$", 4)) - ) { + + if (!is_template && !is_init_template + && (!strnicmp(& seg_rad_name[char_template], "$RepresentationID$", 18) || !strnicmp(& seg_rad_name[char_template], "$ID$", 4)) + ) { char_template+=18; strcat(segment_name, rep_id); needs_init=GF_FALSE; @@ -230,7 +235,7 @@ GF_Err gf_media_mpd_format_segment_name(GF_DashTemplateSegmentType seg_type, Boo char_template += (u32) strlen(seg_rad_name + char_template)+1; if (sep) sep[0] = '$'; } - + else { char_template+=1; sprintf(tmp, "%c", c); @@ -268,6 +273,7 @@ GF_Err gf_dasher_store_segment_info(GF_DASHSegmenterOptions *dash_cfg, const cha #ifndef GPAC_DISABLE_ISOM +GF_EXPORT GF_Err gf_media_get_rfc_6381_codec_name(GF_ISOFile *movie, u32 track, char *szCodec) { GF_ESD *esd; @@ -358,7 +364,7 @@ GF_Err gf_media_get_rfc_6381_codec_name(GF_ISOFile *movie, u32 track, char *szCo //profile idc encoded as a decimal number sprintf(szTemp, "%d", hvcc->profile_idc); strcat(szCodec, szTemp); - //general profile compatibility flags: hexa, bit-reversed + //general profile compatibility flags: hexa, bit-reversed { u32 val = hvcc->general_profile_compatibility_flags; u32 i, res = 0; @@ -406,7 +412,7 @@ GF_Err gf_media_get_rfc_6381_codec_name(GF_ISOFile *movie, u32 track, char *szCo } } } - + gf_odf_hevc_cfg_del(hvcc); } else { sprintf(szCodec, "%s", gf_4cc_to_str(subtype)); @@ -460,13 +466,42 @@ static u64 isom_get_next_sap_time(GF_ISOFile *input, u32 track, u32 sample_count break; } } - if (!found_sample) return 0; + //TRICK: if we don't found next RAP, return time of the last sample in track + if (!found_sample) + found_sample = sample_count; samp = gf_isom_get_sample_info(input, track, found_sample, NULL, NULL); time = samp->DTS; gf_isom_sample_del(&samp); return time; } +typedef struct +{ + u32 nb_segment; + u64 segment_duration; +} GF_DASHSementDuration; + +static void store_segment_duration(GF_List *segment_duration, u64 SegmentDuration) +{ + u32 k; + GF_DASHSementDuration *entry; + + for (k = 0; k < gf_list_count(segment_duration); k++) { + entry = (GF_DASHSementDuration *)gf_list_get(segment_duration, k); + if (SegmentDuration == entry->segment_duration) { + entry->nb_segment++; + return; + } + } + + GF_SAFEALLOC(entry, GF_DASHSementDuration); + entry->segment_duration = SegmentDuration; + entry->nb_segment = 1; + if (!segment_duration) segment_duration = gf_list_new(); + gf_list_add(segment_duration, entry); +} + + static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_file, Double max_duration_sec, GF_DASHSegmenterOptions *dash_cfg, GF_DashSegInput *dash_input, Bool first_in_set) { u8 NbBits; @@ -527,6 +562,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f const char *seg_rad_name = dash_cfg->seg_rad_name; const char *seg_ext = dash_cfg->seg_ext; const char *bs_switching_segment_name = NULL; + GF_List *segment_duration = NULL; SegmentName[0] = 0; SegmentDuration = 0; @@ -542,7 +578,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f is_bs_switching = 1; } } - + sprintf(RepSecName, "Representation_%s", dash_input ? dash_input->representationID : ""); sprintf(RepURLsSecName, "URLs_%s", dash_input ? dash_input->representationID : ""); @@ -605,7 +641,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f opt = gf_cfg_get_key(dash_cfg->dash_ctx, RepSecName, "BitstreamSwitching"); if (opt && !strcmp(opt, "yes")) { is_bs_switching = 1; - if (bs_switch_segment) + if (bs_switch_segment) gf_isom_delete(bs_switch_segment); bs_switch_segment = output; bs_switching_is_output = 1; @@ -621,7 +657,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f sprintf(szMPDTempLine, " \n"); gf_bs_write_data(mpd_timeline_bs, szMPDTempLine, (u32) strlen(szMPDTempLine)); } - + nb_sync = 0; nb_samp = 0; fragmenters = gf_list_new(); @@ -641,10 +677,10 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f } - MaxFragmentDuration = (u32) (dash_cfg->dash_scale * max_duration_sec); + MaxFragmentDuration = (u32) (dash_cfg->dash_scale * max_duration_sec); MaxSegmentDuration = (u32) (dash_cfg->dash_scale * dash_cfg->segment_duration); - /*in single segment mode, only one big SIDX is written between the end of the moov and the first fragment. + /*in single segment mode, only one big SIDX is written between the end of the moov and the first fragment. To speed-up writing, we do a first fragmentation pass without writing any sample to compute the number of segments and fragments per segment in order to allocate / write to file the sidx before the fragmentation. The sidx will then be rewritten when closing the last segment*/ if (dash_cfg->single_file_mode==1) { @@ -656,7 +692,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f seg_rad_name = NULL; } - index_start_range = index_end_range = 0; + index_start_range = index_end_range = 0; tf = tfref = NULL; file_duration = 0; @@ -698,7 +734,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f } // Commenting it the code for Timed Text tracks, it may happen that we have only one long sample, fragmentation is useful -#if 0 +#if 0 //if only one sample, don't fragment track if (gf_isom_get_sample_count(input, i+1) == 1) { sample = gf_isom_get_sample(input, i+1, 1, &descIndex); @@ -717,7 +753,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f avctype = gf_isom_get_avc_svc_type(input, i+1, 1); if (avctype==GF_ISOM_AVCTYPE_AVC_ONLY) { /*for AVC we concatenate SPS/PPS unless SVC base*/ - if (!dash_input->trackNum && dash_cfg->inband_param_set) + if (!dash_input->trackNum && dash_cfg->inband_param_set) gf_isom_set_nalu_extract_mode(input, i+1, GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG); } else if (avctype > GF_ISOM_AVCTYPE_AVC_ONLY) { @@ -725,8 +761,12 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f gf_isom_set_nalu_extract_mode(input, i+1, GF_ISOM_NALU_EXTRACT_INSPECT); } - if (dash_cfg->inband_param_set && (gf_isom_get_media_subtype(input, i+1, 1)==GF_ISOM_SUBTYPE_HVC1)) { - gf_isom_set_nalu_extract_mode(input, i+1, GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG); + if (gf_isom_get_media_subtype(input, i+1, 1)==GF_ISOM_SUBTYPE_HVC1) { + u32 mode = GF_ISOM_NALU_EXTRACT_INSPECT; + if (dash_cfg->inband_param_set) { + mode |= GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG; + } + gf_isom_set_nalu_extract_mode(input, i+1, mode); } if (mtype == GF_ISOM_MEDIA_VISUAL) nb_video++; @@ -739,15 +779,15 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f //setup fragmenters if (! dash_moov_setup) { - //new initialization segment, setup fragmentation + //new initialization segment, setup fragmentation gf_isom_get_fragment_defaults(input, i+1, - &defaultDuration, &defaultSize, &defaultDescriptionIndex, - &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); + &defaultDuration, &defaultSize, &defaultDescriptionIndex, + &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); if (! dash_cfg->no_fragments_defaults) { e = gf_isom_setup_track_fragment(output, gf_isom_get_track_id(output, TrackNum), - defaultDescriptionIndex, defaultDuration, - defaultSize, (u8) defaultRandomAccess, - defaultPadding, defaultDegradationPriority); + defaultDescriptionIndex, defaultDuration, + defaultSize, (u8) defaultRandomAccess, + defaultPadding, defaultDegradationPriority); } else { e = gf_isom_setup_track_fragment(output, gf_isom_get_track_id(output, TrackNum), defaultDescriptionIndex, 0, 0, 0, 0, 0); @@ -755,7 +795,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f if (e) goto err_exit; } else { gf_isom_get_fragment_defaults(output, TrackNum, - &defaultDuration, &defaultSize, &defaultDescriptionIndex, &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); + &defaultDuration, &defaultSize, &defaultDescriptionIndex, &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); } gf_media_get_rfc_6381_codec_name(bs_switch_segment ? bs_switch_segment : input, i+1, szCodec); @@ -801,7 +841,7 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f /*get first edit*/ gf_isom_get_edit_segment(input, i+1, j+1, &EditTime, &SegDuration, &MediaTime, &EditMode); - if (EditMode==GF_ISOM_EDIT_NORMAL) + if (EditMode==GF_ISOM_EDIT_NORMAL) SegDuration = 0; gf_isom_set_edit_segment(output, TrackNum, EditTime, SegDuration, MediaTime, EditMode); @@ -840,25 +880,25 @@ static GF_Err gf_media_isom_segment_file(GF_ISOFile *input, const char *output_f /*otherwise override the fragment defauls so that we are consistent with the shared init segment*/ else { e = gf_isom_get_fragment_defaults(bs_switch_segment, sample_descs_track, - &defaultDuration, &defaultSize, &defaultDescriptionIndex, &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); + &defaultDuration, &defaultSize, &defaultDescriptionIndex, &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority); if (e) goto err_exit; e = gf_isom_change_track_fragment_defaults(output, tf->TrackID, - defaultDescriptionIndex, defaultDuration, defaultSize, defaultRandomAccess, defaultPadding, defaultDegradationPriority); + defaultDescriptionIndex, defaultDuration, defaultSize, defaultRandomAccess, defaultPadding, defaultDegradationPriority); if (e) goto err_exit; } /*and search in new ones the new index*/ - s_count = gf_isom_get_sample_description_count(bs_switch_segment, sample_descs_track); + s_count = gf_isom_get_sample_description_count(bs_switch_segment, sample_descs_track); - /*more than one sampleDesc, we will need to indicate all the sample descs in the file in case we produce a single file, + /*more than one sampleDesc, we will need to indicate all the sample descs in the file in case we produce a single file, otherwise the file would not be compliant*/ if (s_count > 1) { gf_isom_clone_sample_descriptions(output, TrackNum, bs_switch_segment, sample_descs_track, 1); } /*and search in new ones the new index*/ - s_count = gf_isom_get_sample_description_count(bs_switch_segment, sample_descs_track); + s_count = gf_isom_get_sample_description_count(bs_switch_segment, sample_descs_track); if (s_count>1) { u32 k; /*remove all sample descs*/ @@ -1020,7 +1060,7 @@ restart_fragmentation_pass: for (i=0; idash_ctx, RepURLsSecName, i); opt = gf_cfg_get_key(dash_cfg->dash_ctx, RepURLsSecName, key_name); - sprintf(szMPDTempLine, " %s\n", opt); + sprintf(szMPDTempLine, " %s\n", opt); gf_bs_write_data(mpd_bs, szMPDTempLine, (u32) strlen(szMPDTempLine)); } @@ -1089,7 +1129,7 @@ restart_fragmentation_pass: if (!use_url_template) { const char *name = gf_url_get_resource_name(SegmentName); - sprintf(szMPDTempLine, " \n", name ); + sprintf(szMPDTempLine, " \n", name ); gf_bs_write_data(mpd_bs, szMPDTempLine, (u32) strlen(szMPDTempLine)); if (dash_cfg->dash_ctx) { char szKey[100], szVal[4046]; @@ -1107,7 +1147,7 @@ restart_fragmentation_pass: cur_seg++; if (e) goto err_exit; - } + } maxFragDurationOverSegment=0; @@ -1119,14 +1159,15 @@ restart_fragmentation_pass: } else { e = gf_isom_start_fragment(output, 1); if (e) goto err_exit; - + for (i=0; idone) continue; if (dash_cfg->initial_tfdt && (tf->TimeScale != dash_cfg->dash_scale)) { - Double scale = tf->TimeScale; scale /= dash_cfg->dash_scale; + Double scale = tf->TimeScale; + scale /= dash_cfg->dash_scale; gf_isom_set_traf_base_media_decode_time(output, tf->TrackID, (u64) (dash_cfg->initial_tfdt*scale) + tf->InitialTSOffset + tf->next_sample_dts); } else { gf_isom_set_traf_base_media_decode_time(output, tf->TrackID, tf->InitialTSOffset + tf->next_sample_dts); @@ -1145,11 +1186,11 @@ restart_fragmentation_pass: u32 SAP_type = 0; tf = (GF_ISOMTrackFragmenter *)gf_list_get(fragmenters, i); - if (tf == tfref) + if (tf == tfref) has_rap = GF_FALSE; if (tf->done) continue; - + //ok write samples while (1) { Bool stop_frag = GF_FALSE; @@ -1189,7 +1230,7 @@ restart_fragmentation_pass: if (next) { defaultDuration = (u32) (next->DTS - sample->DTS); } else { - defaultDuration = (u32) (gf_isom_get_media_duration(input, tf->OriginalTrack)- sample->DTS); + defaultDuration = (u32) (gf_isom_get_media_duration(input, tf->OriginalTrack)- sample->DTS); } if (tf->splitable) { @@ -1201,12 +1242,12 @@ restart_fragmentation_pass: defaultDuration = (u32) (tf->TimeScale * (MaxSegmentDuration - SegmentDuration) / dash_cfg->dash_scale - tf->FragmentLength); split_sample_duration -= defaultDuration; } - } else if (tfref /* tfref set to NULL after the last sample of tfref is processed */ - /*&& next do not split if no next sample */ + } else if (tfref /* tfref set to NULL after the last sample of tfref is processed */ + /*&& next do not split if no next sample */ - /*next sample DTS */ + /*next sample DTS */ // && ((tf->next_sample_dts /*+ 1 accuracy*/ ) * tfref_timescale < tfref->next_sample_dts * tf->TimeScale) - && ((tf->next_sample_dts + defaultDuration) * tfref_timescale > tfref->next_sample_dts * tf->TimeScale)) { + && ((tf->next_sample_dts + defaultDuration) * tfref_timescale > tfref->next_sample_dts * tf->TimeScale)) { split_sample_duration = defaultDuration; defaultDuration = (u32) ( (tfref->next_sample_dts * tf->TimeScale)/tfref_timescale - tf->next_sample_dts ); split_sample_duration -= defaultDuration; @@ -1221,12 +1262,12 @@ restart_fragmentation_pass: first_sample_in_segment = GF_FALSE; if (! SAP_type) segments_start_with_sap = GF_FALSE; } - if (ref_track_first_dts > sample->DTS) + if (ref_track_first_dts > sample->DTS) ref_track_first_dts = sample->DTS; if (next) { u64 next_cts = next->DTS + next->CTS_Offset; - if (split_sample_duration) + if (split_sample_duration) next_cts -= split_sample_duration; if (ref_track_next_ctsfinalSampleDescriptionIndex; e = gf_isom_fragment_add_sample(output, tf->TrackID, sample, descIndex, - defaultDuration, NbBits, 0, is_redundant_sample); - if (e) + defaultDuration, NbBits, 0, is_redundant_sample); + if (e) goto err_exit; e = gf_isom_fragment_add_sai(output, input, tf->TrackID, tf->SampleNum + 1); @@ -1256,7 +1297,7 @@ restart_fragmentation_pass: /*copy subsample information*/ e = gf_isom_fragment_copy_subsample(output, tf->TrackID, input, tf->OriginalTrack, tf->SampleNum + 1, dash_cfg->samplegroups_in_traf); - if (e) + if (e) goto err_exit; gf_set_progress("ISO File Fragmenting", nb_done, nb_samp); @@ -1333,7 +1374,7 @@ restart_fragmentation_pass: if (tf->FragmentLength == defaultDuration) has_rap = 2; else has_rap = 1; } - } + } } else { next_sample_rap = GF_FALSE; } @@ -1366,7 +1407,7 @@ restart_fragmentation_pass: tf->split_sample_dts_shift += defaultDuration; //if (tf==tfref) - //last_ref_cts = tf->last_sample_cts; + //last_ref_cts = tf->last_sample_cts; break; } @@ -1399,8 +1440,9 @@ restart_fragmentation_pass: if (force_switch_segment || ((SegmentDuration >= MaxSegmentDuration) && (!split_seg_at_rap || next_sample_rap))) { - if (mpd_timeline_bs) { + store_segment_duration(segment_duration, SegmentDuration); + if (mpd_timeline_bs) { if (previous_segment_duration == SegmentDuration) { segment_timeline_repeat_count ++; } else { @@ -1421,15 +1463,15 @@ restart_fragmentation_pass: } gf_bs_write_data(mpd_timeline_bs, szMPDTempLine, (u32) strlen(szMPDTempLine)); segment_timeline_repeat_count = 0; - } + } } segment_start_time += SegmentDuration; nb_segments++; - if (max_segment_duration * dash_cfg->dash_scale <= SegmentDuration) { + /*if (max_segment_duration * dash_cfg->dash_scale <= SegmentDuration) { max_segment_duration = (Double) (s64) SegmentDuration; max_segment_duration /= dash_cfg->dash_scale; - } + }*/ force_switch_segment = GF_FALSE; switch_segment = GF_TRUE; SegmentDuration = 0; @@ -1440,7 +1482,7 @@ restart_fragmentation_pass: if (!simulation_pass) { u64 idx_start_range, idx_end_range; - + gf_isom_close_segment(output, dash_cfg->subsegs_per_sidx, ref_track_id, ref_track_first_dts, tfref ? tfref->media_time_to_pres_time_shift : tf->media_time_to_pres_time_shift, ref_track_next_cts, dash_cfg->daisy_chain_sidx, flush_all_samples ? GF_TRUE : GF_FALSE, dash_cfg->segment_marker_4cc, &idx_start_range, &idx_end_range); @@ -1456,10 +1498,10 @@ restart_fragmentation_pass: file_size = gf_isom_get_file_size(output); end_range = file_size - 1; if (dash_cfg->single_file_mode!=1) { - sprintf(szMPDTempLine, " \n", 3); @@ -1510,6 +1552,8 @@ restart_fragmentation_pass: if (!switch_segment) { u64 idx_start_range, idx_end_range; + store_segment_duration(segment_duration, SegmentDuration); + /*do not update on last segment, we're likely to have a different last GOP*/ #if 0 if (max_segment_duration * dash_cfg->dash_scale <= SegmentDuration) { @@ -1574,10 +1618,24 @@ restart_fragmentation_pass: sprintf(szMPDTempLine, " \n"); gf_bs_write_data(mpd_timeline_bs, szMPDTempLine, (u32) strlen(szMPDTempLine)); } + else { + u32 k; + u32 most_frequent_duration = 0; + + for (k = 0; k < gf_list_count(segment_duration); k++) { + GF_DASHSementDuration *entry; + entry = (GF_DASHSementDuration *)gf_list_get(segment_duration, k); + if (entry->nb_segment > most_frequent_duration) { + max_segment_duration = (Double) ( entry->segment_duration / dash_cfg->dash_scale ); + most_frequent_duration = entry->nb_segment; + } + } + } + if (!bandwidth) bandwidth = (u32) (file_size * 8 / file_duration); - + bandwidth += dash_input->dependency_bandwidth; dash_input->bandwidth = bandwidth; @@ -1586,7 +1644,7 @@ restart_fragmentation_pass: if (!dash_cfg->variable_seg_rad_name && first_in_set) { const char *rad_name = gf_url_get_resource_name(seg_rad_name); gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_TEMPLATE, is_bs_switching, SegmentName, output_file, dash_input->representationID, rad_name, !stricmp(seg_ext, "null") ? NULL : seg_ext, 0, 0, 0, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " dash_scale : mpd_timescale, SegmentName, startNumber); + fprintf(dash_cfg->mpd, " dash_scale : mpd_timescale, SegmentName, startNumber); if (!mpd_timeline_bs) { if (!max_segment_duration) max_segment_duration = dash_cfg->segment_duration; @@ -1599,7 +1657,7 @@ restart_fragmentation_pass: gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_INITIALIZATION_TEMPLATE, is_bs_switching, SegmentName, output_file, dash_input->representationID, rad_name, !stricmp(seg_ext, "null") ? NULL : "mp4", 0, 0, 0, dash_cfg->use_segment_timeline); } fprintf(dash_cfg->mpd, " initialization=\"%s\"", SegmentName); - if (presentationTimeOffset) + if (presentationTimeOffset) fprintf(dash_cfg->mpd, " presentationTimeOffset=\"%d\"", presentationTimeOffset); if (mpd_timeline_bs) { @@ -1618,7 +1676,7 @@ restart_fragmentation_pass: /*in BS switching we share the same IS for all reps, write the SegmentTemplate for the init segment*/ else if (is_bs_switching && first_in_set) { fprintf(dash_cfg->mpd, " mpd, " presentationTimeOffset=\"%d\"", presentationTimeOffset); if (mpd_timeline_bs) { @@ -1651,7 +1709,7 @@ restart_fragmentation_pass: fprintf(dash_cfg->mpd, " representationID) fprintf(dash_cfg->mpd, "id=\"%s\"", dash_input->representationID); else fprintf(dash_cfg->mpd, "id=\"%p\"", output); - + fprintf(dash_cfg->mpd, " mimeType=\"%s/mp4\" codecs=\"%s\"", audio_only ? "audio" : "video", szCodecs); if (width && height) { fprintf(dash_cfg->mpd, " width=\"%d\" height=\"%d\"", width, height); @@ -1679,12 +1737,12 @@ restart_fragmentation_pass: //only appears at AdaptationSet level - need to rewrite the DASH segementer to allow writing this at the proper place // if ((single_file_mode==1) && segments_start_with_sap) fprintf(dash_cfg->mpd, " subsegmentStartsWithSAP=\"%d\"", max_sap_type); - fprintf(dash_cfg->mpd, " bandwidth=\"%d\"", bandwidth); + fprintf(dash_cfg->mpd, " bandwidth=\"%d\"", bandwidth); if (strlen(dash_input->dependencyID)) fprintf(dash_cfg->mpd, " dependencyId=\"%s\"", dash_input->dependencyID); fprintf(dash_cfg->mpd, ">\n"); - if (nb_channels && !is_bs_switching) + if (nb_channels && !is_bs_switching) fprintf(dash_cfg->mpd, " \n", nb_channels); @@ -1698,14 +1756,14 @@ restart_fragmentation_pass: for (i=0; i<4; i++) fprintf(dash_cfg->mpd, "%02x", default_KID[i]); fprintf(dash_cfg->mpd, "-"); for (i=4; i<6; i++) fprintf(dash_cfg->mpd, "%02x", default_KID[i]); - fprintf(dash_cfg->mpd, "-"); + fprintf(dash_cfg->mpd, "-"); for (i=6; i<8; i++) fprintf(dash_cfg->mpd, "%02x", default_KID[i]); fprintf(dash_cfg->mpd, "-"); for (i=8; i<10; i++) fprintf(dash_cfg->mpd, "%02x", default_KID[i]); fprintf(dash_cfg->mpd, "-"); for (i=10; i<16; i++) fprintf(dash_cfg->mpd, "%02x", default_KID[i]); fprintf(dash_cfg->mpd, "\"/>\n"); - } + } //todo for ISMA or OMA DRM } @@ -1732,36 +1790,41 @@ restart_fragmentation_pass: if (dash_cfg->variable_seg_rad_name) { const char *rad_name = gf_url_get_resource_name(seg_rad_name); gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_TEMPLATE, is_bs_switching, SegmentName, output_file, dash_input->representationID, rad_name, !stricmp(seg_ext, "null") ? NULL : seg_ext, 0, bandwidth, 0, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " mpd, " segment_duration; + fprintf(dash_cfg->mpd, " duration=\"%d\"", (u32) (max_segment_duration * mpd_timescale)); + } if (!is_bs_switching) { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_INITIALIZATION_TEMPLATE, is_bs_switching, SegmentName, output_file, dash_input->representationID, rad_name, !stricmp(seg_ext, "null") ? NULL : "mp4", 0, 0, 0, dash_cfg->use_segment_timeline); fprintf(dash_cfg->mpd, " initialization=\"%s\"", SegmentName); } - if (presentationTimeOffset) + if (presentationTimeOffset) fprintf(dash_cfg->mpd, " presentationTimeOffset=\"%d\"", presentationTimeOffset); fprintf(dash_cfg->mpd, "/>\n"); } } else if (dash_cfg->single_file_mode==1) { - fprintf(dash_cfg->mpd, " %s\n", gf_url_get_resource_name( gf_isom_get_filename(output) ) ); - fprintf(dash_cfg->mpd, " mpd, " %s\n", gf_url_get_resource_name( gf_isom_get_filename(output) ) ); + fprintf(dash_cfg->mpd, " mpd, " presentationTimeOffset=\"%d\"", presentationTimeOffset); - fprintf(dash_cfg->mpd, "/>\n"); + fprintf(dash_cfg->mpd, "/>\n"); } else { if (!seg_rad_name) { - fprintf(dash_cfg->mpd, " %s\n", gf_url_get_resource_name( gf_isom_get_filename(output) ) ); + fprintf(dash_cfg->mpd, " %s\n", gf_url_get_resource_name( gf_isom_get_filename(output) ) ); } fprintf(dash_cfg->mpd, " mpd, " timescale=\"%d\" duration=\"%d\"", mpd_timescale, (u32) (max_segment_duration * mpd_timescale)); + fprintf(dash_cfg->mpd, " timescale=\"%d\" duration=\"%d\"", mpd_timescale, (u32) (max_segment_duration * mpd_timescale)); } if (presentationTimeOffset) { fprintf(dash_cfg->mpd, " presentationTimeOffset=\"%d\"", presentationTimeOffset); } - fprintf(dash_cfg->mpd, ">\n"); + fprintf(dash_cfg->mpd, ">\n"); /*we are not in bitstreamSwitching mode*/ if (!is_bs_switching) { - fprintf(dash_cfg->mpd, " mpd, " mpd, " range=\"0-"LLD"\"", init_seg_size-1); } else { @@ -1832,7 +1895,7 @@ restart_fragmentation_pass: } err_exit: - if (fragmenters){ + if (fragmenters) { while (gf_list_count(fragmenters)) { tf = (GF_ISOMTrackFragmenter *)gf_list_get(fragmenters, 0); gf_free(tf); @@ -1844,11 +1907,19 @@ err_exit: if (e) gf_isom_delete(output); else gf_isom_close(output); } - if (!bs_switching_is_output && bs_switch_segment) + if (!bs_switching_is_output && bs_switch_segment) gf_isom_delete(bs_switch_segment); gf_set_progress("ISO File Fragmenting", nb_samp, nb_samp); if (mpd_bs) gf_bs_del(mpd_bs); if (mpd_timeline_bs) gf_bs_del(mpd_timeline_bs); + if (segment_duration) { + while (gf_list_count(segment_duration)) { + GF_DASHSementDuration *entry = (GF_DASHSementDuration *)gf_list_last(segment_duration); + gf_free(entry); + gf_list_rem_last(segment_duration); + } + gf_list_del(segment_duration); + } return e; } @@ -1870,12 +1941,12 @@ static GF_Err dasher_isom_get_input_components_info(GF_DashSegInput *input, GF_D if (input->single_track_num && (input->single_track_num != i+1)) continue; - if (mtype == GF_ISOM_MEDIA_HINT) + if (mtype == GF_ISOM_MEDIA_HINT) continue; - + if (gf_isom_get_sample_count(in, i+1)<2) continue; - + dur = (Double) gf_isom_get_track_duration(in, i+1); dur /= gf_isom_get_timescale(in); if (!dur) { @@ -1910,7 +1981,7 @@ static GF_Err dasher_isom_classify_input(GF_DashSegInput *dash_inputs, u32 nb_da { u32 i, j; GF_ISOFile *set_file; - + if (input_idx+1>=nb_dash_inputs) return GF_OK; @@ -1921,15 +1992,20 @@ static GF_Err dasher_isom_classify_input(GF_DashSegInput *dash_inputs, u32 nb_da Bool assign_to_group = 1; GF_ISOFile *in; - if (dash_inputs[input_idx].period != dash_inputs[i].period) + if (dash_inputs[input_idx].period != dash_inputs[i].period) continue; - + if (strcmp(dash_inputs[input_idx].szMime, dash_inputs[i].szMime)) continue; if (strcmp(dash_inputs[input_idx].role, dash_inputs[i].role)) continue; + if (dash_inputs[input_idx].x != dash_inputs[i].x) continue; + if (dash_inputs[input_idx].y != dash_inputs[i].y) continue; + if (dash_inputs[input_idx].w != dash_inputs[i].w) continue; + if (dash_inputs[input_idx].h != dash_inputs[i].h) continue; + in = gf_isom_open(dash_inputs[i].file_name, GF_ISOM_OPEN_READ, NULL); for (j=0; jstreamType==dcd2->streamType) && (dcd1->objectTypeIndication==dcd2->objectTypeIndication)) { - same_codec = 1; - } else { - same_codec = 0; - } - if (dcd1) gf_odf_desc_del((GF_Descriptor *)dcd1); - if (dcd2) gf_odf_desc_del((GF_Descriptor *)dcd2); + if ((msub_type==GF_ISOM_SUBTYPE_MPEG4) + || (msub_type==GF_ISOM_SUBTYPE_MPEG4_CRYP) + || (msub_type==GF_ISOM_SUBTYPE_AVC_H264) + || (msub_type==GF_ISOM_SUBTYPE_AVC2_H264) + || (msub_type==GF_ISOM_SUBTYPE_AVC3_H264) + || (msub_type==GF_ISOM_SUBTYPE_AVC4_H264) + || (msub_type==GF_ISOM_SUBTYPE_SVC_H264) + || (msub_type==GF_ISOM_SUBTYPE_HVC1) + || (msub_type==GF_ISOM_SUBTYPE_HEV1) + || (msub_type==GF_ISOM_SUBTYPE_LSR1) + ) { + GF_DecoderConfig *dcd1 = gf_isom_get_decoder_config(set_file, j+1, 1); + GF_DecoderConfig *dcd2 = gf_isom_get_decoder_config(in, track, 1); + if (dcd1 && dcd2 && (dcd1->streamType==dcd2->streamType) && (dcd1->objectTypeIndication==dcd2->objectTypeIndication)) { + same_codec = 1; + } else { + same_codec = 0; + } + if (dcd1) gf_odf_desc_del((GF_Descriptor *)dcd1); + if (dcd2) gf_odf_desc_del((GF_Descriptor *)dcd2); } if (!same_codec) { @@ -2063,7 +2139,7 @@ static GF_Err dasher_isom_create_init_segment(GF_DashSegInput *dash_inputs, u32 for (j=0; jnb_refs++; @@ -2513,12 +2590,12 @@ static void m2ts_sidx_finalize_size(GF_TSSegmenter *index_info, u64 file_size) GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Subsegment: position-range ajdustment:%d-%d (%d bytes)\n", index_info->prev_base_offset, (u32)file_size, ref->reference_size)); } -static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) +static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) { - u32 end_offset, size, duration; + u32 end_offset, size, duration; Bool store_segment = 1; - if (index_info->suspend_indexing) + if (index_info->suspend_indexing) return; if (index_info->skip_nb_segments) { @@ -2532,7 +2609,7 @@ static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) end_offset = index_info->last_pat_position; } else { /* split at PES header */ - end_offset = index_info->last_offset; + end_offset = index_info->last_offset; } size = (u32)(end_offset - index_info->base_offset); duration = (u32)(index_info->last_PTS - index_info->base_PTS); @@ -2548,14 +2625,14 @@ static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) /* first encountered PTS on the PID for this subsegment */ index_info->sidx->earliest_presentation_time = index_info->base_PTS; index_info->sidx->first_offset = index_info->base_offset; - + } - + if (!index_info->pcrb) { index_info->pcrb = (GF_PcrInfoBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_PCRB); } - /* close the current index */ + /* close the current index */ SAP_delta_time = (u32)(index_info->first_SAP_PTS - index_info->base_PTS); SAP_offset = (u32)(index_info->first_SAP_offset - index_info->base_offset); m2ts_sidx_add_entry(index_info->sidx, 0, size, duration, index_info->first_pes_sap, index_info->SAP_type, SAP_delta_time); @@ -2568,10 +2645,10 @@ static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) /* adjust the previous index duration */ if (index_info->sidx->nb_refs > 0 && (index_info->base_PTS < index_info->prev_last_PTS) ) { prev_duration = (u32)(index_info->base_PTS-index_info->prev_base_PTS); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (" time-range adj.: %.03f-%.03f / %.03f sec.\n", - (index_info->prev_base_PTS - index_info->first_PTS)/90000.0, - (index_info->base_PTS - index_info->first_PTS)/90000.0, prev_duration/90000.0)); - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (" time-range adj.: %.03f-%.03f / %.03f sec.\n", + (index_info->prev_base_PTS - index_info->first_PTS)/90000.0, + (index_info->base_PTS - index_info->first_PTS)/90000.0, prev_duration/90000.0)); + /*update previous duration*/ if (index_info->sidx->nb_refs) { index_info->sidx->refs[index_info->sidx->nb_refs-1].subsegment_duration = prev_duration; @@ -2581,14 +2658,14 @@ static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) /* Printing result */ GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Subsegment:")); - //time-range:position-range: + //time-range:position-range: GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (" %.03f-%0.3f / %.03f sec., %d-%d / %d bytes, ", - (index_info->base_PTS - index_info->first_PTS)/90000.0, - (index_info->last_PTS - index_info->first_PTS)/90000.0, duration/90000.0, - index_info->base_offset, end_offset, size)); + (index_info->base_PTS - index_info->first_PTS)/90000.0, + (index_info->last_PTS - index_info->first_PTS)/90000.0, duration/90000.0, + index_info->base_offset, end_offset, size)); if (index_info->SAP_type) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("RAP @ %.03f sec. / %d bytes", (index_info->first_SAP_PTS - index_info->first_PTS)/90000.0, - SAP_offset)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("RAP @ %.03f sec. / %d bytes", (index_info->first_SAP_PTS - index_info->first_PTS)/90000.0, + SAP_offset)); } if (index_info->first_pat_position_valid) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, (", PAT @ %d bytes", (u32)(index_info->first_pat_position - index_info->base_offset))); @@ -2626,7 +2703,7 @@ static void m2ts_sidx_flush_entry(GF_TSSegmenter *index_info) index_info->prev_last_cat_position = index_info->last_cat_position; index_info->prev_last_pmt_position = index_info->last_pmt_position; index_info->prev_last_pcr_position = index_info->last_pcr_position; - + /* update the values for the new index*/ index_info->base_offset = end_offset; @@ -2698,7 +2775,7 @@ static void m2ts_check_indexing(GF_TSSegmenter *index_info) if (index_info->segment_at_rap) { s32 diff = (s32) ((s64) current_duration - (s64) segment_duration); if (diff<0)diff=-diff; - //check if below 10% limit + //check if below 10% limit if (diff/900 < 5) { //below 10% limit of segment duration, if we have a RAP flush now if (index_info->pes_after_last_pat_is_sap) @@ -2711,9 +2788,9 @@ static void m2ts_check_indexing(GF_TSSegmenter *index_info) /* we exceed the segment duration flush sidx entry*/ if (current_duration >= target_duration) { m2ts_sidx_flush_entry(index_info); - } + } } -static void dash_m2ts_event_check_pat(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +static void dash_m2ts_event_check_pat(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { GF_TSSegmenter *ts_seg = (GF_TSSegmenter*)ts->user; GF_M2TS_PES_PCK *pck; @@ -2731,7 +2808,7 @@ static void dash_m2ts_event_check_pat(GF_M2TS_Demuxer *ts, u32 evt_type, void *p gf_m2ts_set_pes_framing((GF_M2TS_PES *)es, GF_M2TS_PES_FRAMING_DEFAULT); } } - break; + break; case GF_M2TS_EVT_PMT_REPEAT: if (ts_seg->has_seen_pat) { u32 i, count; @@ -2741,7 +2818,7 @@ static void dash_m2ts_event_check_pat(GF_M2TS_Demuxer *ts, u32 evt_type, void *p for (i=0; istreams, i); if (es->flags&GF_M2TS_ES_IS_PES) { - GF_M2TS_PES *pes = (GF_M2TS_PES *)es; + GF_M2TS_PES *pes = (GF_M2TS_PES *)es; if (!pes->aud_sr && !pes->vid_w) { done = 0; break; @@ -2774,7 +2851,7 @@ static void dash_m2ts_event_check_pat(GF_M2TS_Demuxer *ts, u32 evt_type, void *p } } -static void dash_m2ts_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +static void dash_m2ts_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { GF_M2TS_Program *prog; GF_M2TS_PES_PCK *pck; @@ -2873,11 +2950,11 @@ static void dash_m2ts_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) if (pes->last_pcr_value && pes->before_last_pcr_value_pck_number && pes->last_pcr_value > pes->before_last_pcr_value) { u32 delta_pcr_pck_num = pes->last_pcr_value_pck_number - pes->before_last_pcr_value_pck_number; u32 delta_pts_pcr_pck_num = pes->pes_start_packet_number - pes->last_pcr_value_pck_number; - u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; + u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; if ((pes->pes_start_packet_number > pes->last_pcr_value_pck_number) - && (pes->last_pcr_value > pes->before_last_pcr_value)) { - - pes->last_pcr_value = pes->before_last_pcr_value; + && (pes->last_pcr_value > pes->before_last_pcr_value)) { + + pes->last_pcr_value = pes->before_last_pcr_value; } /* we can compute the interpolated pcr value for the packet containing the PES header */ interpolated_pcr_value = pes->last_pcr_value + (u64)((delta_pcr_value*delta_pts_pcr_pck_num*1.0)/delta_pcr_pck_num); @@ -3026,7 +3103,7 @@ static GF_Err dasher_mp2t_get_components_info(GF_DashSegInput *dash_input, GF_DA #define NB_TSPCK_IO_BYTES 18800 static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char *szOutName, GF_DASHSegmenterOptions *dash_cfg, Bool first_in_set) -{ +{ GF_TSSegmenter ts_seg; Bool rewrite_input = 0; u8 is_pes[GF_M2TS_MAX_STREAMS]; @@ -3047,11 +3124,11 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * /*perform indexation of the file, this info will be destroyed at the end of the segment file routine*/ e = dasher_get_ts_demux(&ts_seg, dash_input->file_name, 0); if (e) return e; - + ts_seg.segment_duration = dash_cfg->segment_duration; ts_seg.segment_at_rap = dash_cfg->segments_start_with_rap; - ts_seg.bandwidth = (u32) (ts_seg.file_size * 8 / dash_input->duration); + ts_seg.bandwidth = (u32) (ts_seg.file_size * 8 / dash_input->duration); /*create bitstreams*/ @@ -3062,7 +3139,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * #ifndef GPAC_DISABLE_ISOM_FRAGMENTS GF_SegmentTypeBox *styp; - gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, szOutName, dash_input->representationID, dash_cfg->seg_rad_name, "six", 0, 0, 0, dash_cfg->use_segment_timeline); + gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, szOutName, dash_input->representationID, dash_cfg->seg_rad_name, "six", 0, 0, 0, dash_cfg->use_segment_timeline); ts_seg.index_file = gf_f64_open(IdxName, "wb"); if (!ts_seg.index_file) { @@ -3084,7 +3161,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * #endif } - gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, basename, dash_input->representationID, dash_cfg->seg_rad_name, "six", 0, 0, 0, dash_cfg->use_segment_timeline); + gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, basename, dash_input->representationID, dash_cfg->seg_rad_name, "six", 0, 0, 0, dash_cfg->use_segment_timeline); ts_seg.PCR_DTS_initial_diff = (u64) -1; ts_seg.subduration = (u32) (dash_cfg->subduration * 90000); @@ -3140,7 +3217,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * m2ts_sidx_finalize_size(&ts_seg, ts_seg.file_size); GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH]: Indexing done (1 sidx, %d entries).\n", ts_seg.sidx->nb_refs)); - gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "six", 0, 0, 0, dash_cfg->use_segment_timeline); + gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_REPINDEX, 1, IdxName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "six", 0, 0, 0, dash_cfg->use_segment_timeline); memset(is_pes, 0, sizeof(u8)*GF_M2TS_MAX_STREAMS); @@ -3178,11 +3255,11 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * /*write segment template for all representations*/ if (first_in_set && dash_cfg->seg_rad_name && dash_cfg->use_url_template && !dash_cfg->variable_seg_rad_name) { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_TEMPLATE, 1, SegName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "ts", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " segment_duration), segment_index, SegName); + fprintf(dash_cfg->mpd, " segment_duration), segment_index, SegName); if (!dash_cfg->dash_ctx) { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_INITIALIZATION_TEMPLATE, 1, IdxName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "six", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " index=\"%s\"", IdxName); - } + fprintf(dash_cfg->mpd, " index=\"%s\"", IdxName); + } fprintf(dash_cfg->mpd, "/>\n"); } @@ -3190,15 +3267,15 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * fprintf(dash_cfg->mpd, " representationID); szCodecs[0] = 0; for (i=0; inb_components; i++) { - if (strlen(dash_input->components[i].szCodec)) + if (strlen(dash_input->components[i].szCodec)) if (strlen(szCodecs)) strcat(szCodecs, ","); strcat(szCodecs, dash_input->components[i].szCodec); - if (dash_input->components[i].width && dash_input->components[i].height) + if (dash_input->components[i].width && dash_input->components[i].height) fprintf(dash_cfg->mpd, " width=\"%d\" height=\"%d\"", dash_input->components[i].width, dash_input->components[i].height); - if (dash_input->components[i].sample_rate) + if (dash_input->components[i].sample_rate) fprintf(dash_cfg->mpd, " audioSamplingRate=\"%d\"", dash_input->components[i].sample_rate); } if (strlen(szCodecs)) @@ -3223,30 +3300,30 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * if (dash_cfg->seg_rad_name && dash_cfg->use_url_template) { if (dash_cfg->variable_seg_rad_name) { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_TEMPLATE, 1, SegName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "ts", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " segment_duration), segment_index, SegName); + fprintf(dash_cfg->mpd, " segment_duration), segment_index, SegName); if (!dash_cfg->dash_ctx) { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_INITIALIZATION_TEMPLATE, 1, IdxName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "six", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); - fprintf(dash_cfg->mpd, " index=\"%s\"", IdxName); + fprintf(dash_cfg->mpd, " index=\"%s\"", IdxName); } - if (dash_cfg->time_shift_depth>=0) - fprintf(dash_cfg->mpd, " presentationTimeOffset=\""LLD"\"", ts_seg.sidx->earliest_presentation_time + pcr_shift); - fprintf(dash_cfg->mpd, "/>\n"); + if (dash_cfg->time_shift_depth>=0) + fprintf(dash_cfg->mpd, " presentationTimeOffset=\""LLD"\"", ts_seg.sidx->earliest_presentation_time + pcr_shift); + fprintf(dash_cfg->mpd, "/>\n"); } else if (dash_cfg->time_shift_depth>=0) { - fprintf(dash_cfg->mpd, " \n", ts_seg.sidx->earliest_presentation_time + pcr_shift); + fprintf(dash_cfg->mpd, " \n", ts_seg.sidx->earliest_presentation_time + pcr_shift); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DASH]: PTSOffset "LLD" - startNumber %d - time %g\n", ts_seg.sidx->earliest_presentation_time + pcr_shift, segment_index, (Double) (s64) (ts_seg.sidx->earliest_presentation_time + pcr_shift) / 90000.0)); } } else { gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_SEGMENT, 1, SegName, basename, dash_input->representationID, gf_url_get_resource_name(dash_cfg->seg_rad_name), "ts", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); if (dash_cfg->single_file_mode) fprintf(dash_cfg->mpd, " %s\n",SegName); - fprintf(dash_cfg->mpd, " segment_duration)); - if (dash_cfg->time_shift_depth>=0) - fprintf(dash_cfg->mpd, " presentationTimeOffset=\""LLD"\"", ts_seg.sidx->earliest_presentation_time + pcr_shift); - fprintf(dash_cfg->mpd, ">\n"); + fprintf(dash_cfg->mpd, " segment_duration)); + if (dash_cfg->time_shift_depth>=0) + fprintf(dash_cfg->mpd, " presentationTimeOffset=\""LLD"\"", ts_seg.sidx->earliest_presentation_time + pcr_shift); + fprintf(dash_cfg->mpd, ">\n"); if (!dash_cfg->dash_ctx) { - fprintf(dash_cfg->mpd, " \n", IdxName); + fprintf(dash_cfg->mpd, " \n", IdxName); } } @@ -3259,7 +3336,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * for (i=0; idash_ctx, szRepURLsSecName, i); opt = gf_cfg_get_key(dash_cfg->dash_ctx, szRepURLsSecName, key_name); - fprintf(dash_cfg->mpd, " %s\n", opt); + fprintf(dash_cfg->mpd, " %s\n", opt); } } @@ -3285,7 +3362,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * gf_media_mpd_format_segment_name(GF_DASH_TEMPLATE_SEGMENT, 1, SegName, szOutName, dash_input->representationID, dash_cfg->seg_rad_name, "ts", 0, bandwidth, segment_index, dash_cfg->use_segment_timeline); - /*warning - we may introduce repeated sequence number when concatenating files. We should use switching + /*warning - we may introduce repeated sequence number when concatenating files. We should use switching segments to force reset of the continuity counter for all our pids - we don't because most players don't car ...*/ if (dash_cfg->use_url_template != 2) { dst = gf_f64_open(SegName, "wb"); @@ -3342,7 +3419,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * } fclose(src); cumulated_duration = current_time; - } + } if (!dash_cfg->seg_rad_name || !dash_cfg->use_url_template) { fprintf(dash_cfg->mpd, " \n"); } @@ -3394,7 +3471,7 @@ static GF_Err dasher_mp2t_segment_file(GF_DashSegInput *dash_input, const char * sprintf(szOpt, LLU, ts_seg.suspend_indexing); gf_cfg_set_key(dash_cfg->dash_ctx, szSectionName, "ByteOffset", ts_seg.suspend_indexing ? szOpt : NULL); - + sprintf(szOpt, LLD, ts_seg.duration_at_last_pass); gf_cfg_set_key(dash_cfg->dash_ctx, szSectionName, "DurationAtLastPass", ts_seg.suspend_indexing ? szOpt : NULL); @@ -3444,7 +3521,7 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d GF_DashSegInput *dash_input = & dash_inputs[idx]; char *uri_frag = strchr(dash_input->file_name, '#'); FILE *t = gf_f64_open(dash_input->file_name, "rb"); - + if (uri_frag) uri_frag[0] = 0; t = gf_f64_open(dash_input->file_name, "rb"); @@ -3455,7 +3532,7 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d if (gf_isom_probe_file(dash_input->file_name)) { GF_ISOFile *file; u32 nb_track, j, max_nb_deps, cur_idx, rep_idx; - + strcpy(dash_input->szMime, "video/mp4"); dash_input->dasher_create_init_segment = dasher_isom_create_init_segment; dash_input->dasher_input_classify = dasher_isom_classify_input; @@ -3466,14 +3543,14 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d if (!file) return gf_isom_last_error(NULL); nb_track = gf_isom_get_track_count(file); - /*if this dash input file has only one track, or this has not the scalable track: let it be*/ + /*if this dash input file has only one track, or this has not the scalable track: handle as one representation*/ if ((nb_track == 1) || !gf_isom_has_scalable_layer(file)) { if (uri_frag) { u32 id = 0; - if (!strnicmp(uri_frag+1, "trackID=", 8)) + if (!strnicmp(uri_frag+1, "trackID=", 8)) id = atoi(uri_frag+9); - else if (!strnicmp(uri_frag+1, "ID=", 3)) + else if (!strnicmp(uri_frag+1, "ID=", 3)) id = atoi(uri_frag+4); else if (!stricmp(uri_frag+1, "audio") || !stricmp(uri_frag+1, "video")) { Bool check_video = !stricmp(uri_frag+1, "video") ? 1 : 0; @@ -3502,10 +3579,13 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d max_nb_deps = 0; for (j = 0; j < nb_track; j++) { + //check scalability if (gf_isom_get_media_type(file, j+1)==GF_ISOM_MEDIA_VISUAL) { - u32 count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_SCAL); - if (count) + u32 count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_BASE); + count += gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_TBAS); + if (count) { max_nb_deps ++; + } } } //scalable input file, realloc @@ -3520,16 +3600,17 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d rep_idx = 1; cur_idx = idx+1; + //create dash inputs for (j = 0; j < nb_track; j++) { GF_DashSegInput *di; - u32 count, t, ref_track; - count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_SCAL); - /*base track, done above*/ + u32 count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_BASE); + count += gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_TBAS); if (!count) { dash_input->trackNum = j+1; continue; } + di = &dash_inputs [cur_idx]; *nb_dash_inputs += 1; cur_idx++; @@ -3542,18 +3623,36 @@ GF_Err gf_dash_segmenter_probe_input(GF_DashSegInput **io_dash_inputs, u32 *nb_d di->protection_scheme_type = gf_isom_is_media_encrypted(file, di->trackNum, 1); - /*dependencyID - FIXME - the delaration of dependency and new dash_input entries should be in DEDENDENCY ORDER*/ di->idx_representations = rep_idx; rep_idx ++; - sprintf(di->dependencyID, "%s", dash_input->representationID); //base track + + if (gf_isom_get_reference_count(file, di->trackNum, GF_ISOM_REF_TBAS)) { + u32 default_sample_group_index, id, independent; + Bool full_frame; + gf_isom_get_tile_info(file, di->trackNum, 1, &default_sample_group_index, &id, &independent, &full_frame, &di->x, &di->y, &di->w, &di->h); + } + } + + + /*dependencyID - FIXME - the delaration of dependency and new dash_input entries should be in DEDENDENCY ORDER*/ + for (j = idx; j < *nb_dash_inputs; j++) { + GF_DashSegInput *di; + u32 count, t, ref_track; + + di = &dash_inputs[j]; + count = gf_isom_get_reference_count(file, di->trackNum, GF_ISOM_REF_SCAL); + if (!count) continue; + di->lower_layer_track = dash_input->trackNum; - for (t = 1; t < count; t++) { - gf_isom_get_reference(file, j+1, GF_ISOM_REF_SCAL, t+1, &ref_track); - if (j) strcat(di->dependencyID, " "); + strcpy(di->dependencyID, ""); + for (t=0; t < count; t++) { + gf_isom_get_reference(file, di->trackNum, GF_ISOM_REF_SCAL, t+1, &ref_track); + if (t) strcat(di->dependencyID, " "); strcat(di->dependencyID, gf_dash_get_representationID(dash_inputs, *nb_dash_inputs, di->file_name, ref_track)); di->lower_layer_track = ref_track; - } + } + } gf_isom_close(file); return GF_OK; @@ -3604,7 +3703,7 @@ static GF_Err write_mpd_header(FILE *mpd, const char *mpd_name, GF_Config *dash_ gf_net_get_ntp(&sec, &frac); sec += ast_shift_sec; - + fprintf(mpd, "\n"); fprintf(mpd, "\n"); /*TODO what should we put for minBufferTime */ - fprintf(mpd, "\n"); - fprintf(mpd, " \n", moreInfoURL ? moreInfoURL : "http://gpac.sourceforge.net"); - if (title) + fprintf(mpd, " \n", moreInfoURL ? moreInfoURL : "http://gpac.sourceforge.net"); + if (title) fprintf(mpd, " %s\n", title); - else + else fprintf(mpd, " %s generated by GPAC\n", mpd_name); - if (source) + if (source) fprintf(mpd, " %s\n", source); if (copyright) fprintf(mpd, " %s\n", copyright); @@ -3709,25 +3808,25 @@ static GF_Err write_period_header(FILE *mpd, const char *szID, Double period_sta Double s; fprintf(mpd, " \n"); + fprintf(mpd, ">\n"); return GF_OK; } @@ -3751,14 +3850,14 @@ static GF_Err write_adaptation_header(FILE *mpd, GF_DashProfile profile, Bool us fprintf(mpd, " lang=\"%s\"", szLang); } /*this should be fixed to use info collected during segmentation process*/ - if (profile==GF_DASH_PROFILE_ONDEMAND) + if (profile==GF_DASH_PROFILE_ONDEMAND) fprintf(mpd, " subsegmentStartsWithSAP=\"1\""); if (!strcmp(first_rep->szMime, "video/mp2t")) fprintf(mpd, " subsegmentAlignment=\"true\""); fprintf(mpd, ">\n"); - + if (first_rep) { u32 i; @@ -3774,9 +3873,9 @@ static GF_Err write_adaptation_header(FILE *mpd, GF_DashProfile profile, Bool us /*set role*/ if (strlen(first_rep->role)) { if (!strcmp(first_rep->role, "caption") || !strcmp(first_rep->role, "subtitle") || !strcmp(first_rep->role, "main") - || !strcmp(first_rep->role, "alternate") || !strcmp(first_rep->role, "supplementary") || !strcmp(first_rep->role, "commentary") - || !strcmp(first_rep->role, "dub") - ) { + || !strcmp(first_rep->role, "alternate") || !strcmp(first_rep->role, "supplementary") || !strcmp(first_rep->role, "commentary") + || !strcmp(first_rep->role, "dub") + ) { fprintf(mpd, " \n", first_rep->role); } else { fprintf(mpd, " \n", first_rep->role); @@ -3814,9 +3913,9 @@ static GF_Err write_adaptation_header(FILE *mpd, GF_DashProfile profile, Bool us } if (bitstream_switching_mode && !use_url_template && (single_file_mode!=1) && strlen(szInitSegment) ) { - fprintf(mpd, " \n"); - fprintf(mpd, " \n", gf_url_get_resource_name( szInitSegment )); - fprintf(mpd, " \n"); + fprintf(mpd, " \n"); + fprintf(mpd, " \n", gf_url_get_resource_name( szInitSegment )); + fprintf(mpd, " \n"); } } return GF_OK; @@ -3833,7 +3932,7 @@ static GF_Err gf_dasher_init_context(GF_Config *dash_ctx, u32 *dynamic, u32 *tim #endif if (!dash_ctx) return GF_BAD_PARAM; - + opt = gf_cfg_get_key(dash_ctx, "DASH", "SessionType"); /*first run, init all options*/ if (!opt) { @@ -3857,7 +3956,7 @@ static GF_Err gf_dasher_init_context(GF_Config *dash_ctx, u32 *dynamic, u32 *tim } gf_cfg_set_key(dash_ctx, "DASH", "PeriodSwitch", "no"); - + gf_net_get_ntp(&sec, &frac); if (first_run) { @@ -3869,7 +3968,7 @@ static GF_Err gf_dasher_init_context(GF_Config *dash_ctx, u32 *dynamic, u32 *tim gf_cfg_set_key(dash_ctx, "DASH", "GenerationNTP", szVal); sprintf(szVal, "%u", frac); gf_cfg_set_key(dash_ctx, "DASH", "GenerationNTPFraction", szVal); - + if (periodID) gf_cfg_set_key(dash_ctx, "DASH", "PeriodID", periodID); } else { @@ -3996,7 +4095,7 @@ static Bool gf_dasher_cleanup(GF_Config *dash_ctx, u32 dash_dynamic, u32 mpd_upd u32 j; const char *fileName = gf_cfg_get_key_name(dash_ctx, "SegmentsStartTimes", i); const char *MPDTime = gf_cfg_get_key(dash_ctx, "SegmentsStartTimes", fileName); - if (!fileName) + if (!fileName) break; seg_time = atof(MPDTime); @@ -4094,7 +4193,7 @@ static void purge_dash_context(GF_Config *dash_ctx) if (!opt) continue; if( !strnicmp(opt, "Representation_", 15) || !strcmp(opt, "SegmentsStartTimes")) { gf_cfg_del_section(dash_ctx, opt); - count--; + count--; i--; } } @@ -4102,14 +4201,14 @@ static void purge_dash_context(GF_Config *dash_ctx) /*dash segmenter*/ GF_EXPORT -GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *inputs, u32 nb_inputs, GF_DashProfile dash_profile, - const char *mpd_title, const char *mpd_source, const char *mpd_copyright, - const char *mpd_moreInfoURL, const char **mpd_base_urls, u32 nb_mpd_base_urls, - u32 use_url_template, Bool use_segment_timeline, Bool single_segment, Bool single_file, GF_DashSwitchingMode bitstream_switching, - Bool seg_at_rap, Double dash_duration, char *seg_name, char *seg_ext, u32 segment_marker_4cc, - Double frag_duration, s32 subsegs_per_sidx, Bool daisy_chain_sidx, Bool frag_at_rap, const char *tmpdir, - GF_Config *dash_ctx, u32 dash_dynamic, u32 mpd_update_time, u32 time_shift_depth, Double subduration, Double min_buffer, - u32 ast_shift_sec, u32 dash_scale, Bool fragments_in_memory, u32 initial_moof_sn, u64 initial_tfdt, Bool no_fragments_defaults, Bool pssh_moof, Bool samplegroups_in_traf) +GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *inputs, u32 nb_inputs, GF_DashProfile dash_profile, + const char *mpd_title, const char *mpd_source, const char *mpd_copyright, + const char *mpd_moreInfoURL, const char **mpd_base_urls, u32 nb_mpd_base_urls, + u32 use_url_template, Bool use_segment_timeline, Bool single_segment, Bool single_file, GF_DashSwitchingMode bitstream_switching, + Bool seg_at_rap, Double dash_duration, char *seg_name, char *seg_ext, u32 segment_marker_4cc, + Double frag_duration, s32 subsegs_per_sidx, Bool daisy_chain_sidx, Bool frag_at_rap, const char *tmpdir, + GF_Config *dash_ctx, u32 dash_dynamic, u32 mpd_update_time, u32 time_shift_depth, Double subduration, Double min_buffer, + u32 ast_shift_sec, u32 dash_scale, Bool fragments_in_memory, u32 initial_moof_sn, u64 initial_tfdt, Bool no_fragments_defaults, Bool pssh_moof, Bool samplegroups_in_traf) { u32 i, j, segment_mode; char *sep, szSegName[GF_MAX_PATH], szSolvedSegName[GF_MAX_PATH], szTempMPD[GF_MAX_PATH], szOpt[GF_MAX_PATH]; @@ -4144,11 +4243,11 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input const char *opt = gf_cfg_get_key(dash_ctx, "DASH", "MaxSegmentDuration"); if (opt) { Double seg_dur = atof(opt); -/* - if (seg_dur != dash_duration) { - return GF_NOT_SUPPORTED; - } -*/ + /* + if (seg_dur != dash_duration) { + return GF_NOT_SUPPORTED; + } + */ dash_duration = seg_dur; } else { char sOpt[100]; @@ -4205,7 +4304,7 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input if (!strcmp(dash_inputs[j].szMime, "video/mp2t")) has_mpeg2 = 1; j += 1+nb_diff; - } + } if (!j) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[DASH] Error: no suitable file found for dashing.\n")); e = GF_BAD_PARAM; @@ -4223,7 +4322,7 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input } for (i=0; i max_width) + if (dash_inputs[i].components[j].width > max_width) max_width = dash_inputs[i].components[j].width; - if (dash_inputs[i].components[j].height > max_height) + if (dash_inputs[i].components[j].height > max_height) max_height = dash_inputs[i].components[j].height; if (! fps_num || !fps_denum) { @@ -4639,8 +4741,8 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input fps_num = dash_inputs[i].components[j].fps_num; fps_denum = dash_inputs[i].components[j].fps_denum; } - - if (dash_inputs[i].components[j].szLang && dash_inputs[i].components[j].szLang[0] && strncmp(dash_inputs[i].components[j].szLang, dash_inputs[i].components[j].szLang, 3) ) { + + if (dash_inputs[i].components[j].szLang && dash_inputs[i].components[j].szLang[0] && strncmp(szLang, dash_inputs[i].components[j].szLang, 3) ) { if (szLang[0]) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[DASH] two languages in adaptation set: %s will be kept %s will be ignored\n", szLang, dash_inputs[i].components[j].szLang)); } else { @@ -4652,7 +4754,7 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input if (max_width && max_height) { gf_media_get_reduced_frame_rate(&fps_num, &fps_denum); - if (fps_denum>1) + if (fps_denum>1) sprintf(szFPS, "%d/%d", fps_num, fps_denum); else if (fps_num) sprintf(szFPS, "%d", fps_num); @@ -4674,7 +4776,8 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input sep = strrchr(szOutName, '.'); if (sep) sep[0] = 0; - dash_opts.variable_seg_rad_name = 0; + /*in scalable case: seg_name is variable*/ + dash_opts.variable_seg_rad_name = (nb_dash_inputs != nb_inputs) ? 1 : 0; if (seg_name) { if (strstr(seg_name, "%s")) { sprintf(szSolvedSegName, seg_name, szOutName); @@ -4690,8 +4793,8 @@ GF_Err gf_dasher_segment_files(const char *mpdfile, GF_DashSegmenterInput *input segment_name = szSolvedSegName; } if ((dash_inputs[i].trackNum || dash_inputs[i].single_track_num) - && (!seg_name || (!strstr(seg_name, "$RepresentationID$") && !strstr(seg_name, "$ID$"))) - ) { + && (!seg_name || (!strstr(seg_name, "$RepresentationID$") && !strstr(seg_name, "$ID$"))) + ) { char tmp[10]; sprintf(tmp, "_track%d", dash_inputs[i].trackNum ? dash_inputs[i].trackNum : dash_inputs[i].single_track_num); strcat(szOutName, tmp); @@ -4772,5 +4875,6 @@ exit: return e; } +#endif /* GPAC_DISABLE_ISOM_WRITE */ diff --git a/src/media_tools/dsmcc.c b/src/media_tools/dsmcc.c index 5fbed75..93d9309 100644 --- a/src/media_tools/dsmcc.c +++ b/src/media_tools/dsmcc.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -78,24 +78,24 @@ static void dsmcc_free_biop_stream_message(GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BI GF_M2TS_DSMCC_OVERLORD* gf_m2ts_init_dsmcc_overlord(u32 service_id) { GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord; - GF_SAFEALLOC(dsmcc_overlord,GF_M2TS_DSMCC_OVERLORD); + GF_SAFEALLOC(dsmcc_overlord,GF_M2TS_DSMCC_OVERLORD); dsmcc_overlord->dsmcc_modules = gf_list_new(); dsmcc_overlord->service_id = service_id; return dsmcc_overlord; } -GF_M2TS_DSMCC_OVERLORD* gf_m2ts_get_dmscc_overlord(GF_List* Dsmcc_controller,u32 service_id) +GF_M2TS_DSMCC_OVERLORD* gf_m2ts_get_dmscc_overlord(GF_List* Dsmcc_controller,u32 service_id) { u16 nb_dsmcc,i; nb_dsmcc = gf_list_count(Dsmcc_controller); - if(!nb_dsmcc){ + if(!nb_dsmcc) { return NULL; - }else{ - for(i =0;iservice_id == service_id){ + if(dsmcc_overlord->service_id == service_id) { return dsmcc_overlord; } } @@ -103,7 +103,7 @@ GF_M2TS_DSMCC_OVERLORD* gf_m2ts_get_dmscc_overlord(GF_List* Dsmcc_controller,u32 return NULL; } -void on_dsmcc_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +void on_dsmcc_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { GF_M2TS_SL_PCK *pck = (GF_M2TS_SL_PCK *)par; char *data; @@ -118,7 +118,7 @@ void on_dsmcc_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) GF_M2TS_DSMCC_SECTION* dsmcc; data = pck->data; u32_data_size = pck->data_len; - u32_table_id = data[0]; + u32_table_id = data[0]; GF_SAFEALLOC(dsmcc,GF_M2TS_DSMCC_SECTION); e = gf_m2ts_process_dsmcc(dsmcc_overlord,dsmcc,data,u32_data_size,u32_table_id); @@ -129,14 +129,14 @@ void on_dsmcc_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) GF_Err gf_m2ts_process_dsmcc(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2TS_DSMCC_SECTION *dsmcc, char *data, u32 data_size, u32 table_id) { - GF_BitStream *bs; + GF_BitStream *bs; u32 data_shift,reserved_test; data_shift = 0; //first_section = *first_section_received; bs = gf_bs_new(data,data_size,GF_BITSTREAM_READ); - dsmcc->table_id = gf_bs_read_int(bs,8); + dsmcc->table_id = gf_bs_read_int(bs,8); dsmcc->section_syntax_indicator = gf_bs_read_int(bs,1); dsmcc->private_indicator = gf_bs_read_int(bs,1); reserved_test = gf_bs_read_int(bs,2); @@ -155,12 +155,12 @@ GF_Err gf_m2ts_process_dsmcc(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2TS_DSMC gf_bs_read_int(bs,2); dsmcc->version_number = gf_bs_read_int(bs,5); - if(dsmcc->version_number != 0 &&(dsmcc->table_id == GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA || dsmcc->table_id == GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE)){ + if(dsmcc->version_number != 0 &&(dsmcc->table_id == GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA || dsmcc->table_id == GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE)) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Version number should be 0 for Encapsulated Data or UN Message, abording processing \n")); return GF_CORRUPTED_DATA; } - dsmcc->current_next_indicator = gf_bs_read_int(bs,1); + dsmcc->current_next_indicator = gf_bs_read_int(bs,1); if (!dsmcc->current_next_indicator) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] current next indicator should be at 1 \n")); return GF_CORRUPTED_DATA; @@ -171,36 +171,36 @@ GF_Err gf_m2ts_process_dsmcc(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2TS_DSMC return GF_CORRUPTED_DATA; } *first_section_received = 1;*/ - dsmcc->last_section_number = gf_bs_read_int(bs,8); + dsmcc->last_section_number = gf_bs_read_int(bs,8); //fprintf(stderr, "\nsection_number %d last_section_number %d\n",dsmcc->section_number,dsmcc->last_section_number); //fprintf(stderr, "dsmcc->table_id %d \n",dsmcc->table_id); switch (dsmcc->table_id) { - case GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA: - { - data_shift = (u32)(gf_bs_get_position(bs)); - break; - } - case GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE: - case GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE: - { - data_shift = (u32)(gf_bs_get_position(bs)); - gf_m2ts_dsmcc_download_data(dsmcc_overlord,dsmcc,data,bs,&data_shift); - break; - } - case GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION: - { - data_shift = (u32)(gf_bs_get_position(bs)); - break; - } - default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown DSMCC Section Type \n")); - break; - } + case GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA: + { + data_shift = (u32)(gf_bs_get_position(bs)); + break; + } + case GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE: + case GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE: + { + data_shift = (u32)(gf_bs_get_position(bs)); + gf_m2ts_dsmcc_download_data(dsmcc_overlord,dsmcc,data,bs,&data_shift); + break; + } + case GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION: + { + data_shift = (u32)(gf_bs_get_position(bs)); + break; + } + default: + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown DSMCC Section Type \n")); + break; + } } if (dsmcc->section_syntax_indicator == 0) { - dsmcc->checksum = gf_bs_read_int(bs,32); + dsmcc->checksum = gf_bs_read_int(bs,32); } else { dsmcc->CRC_32= gf_bs_read_int(bs,32); } @@ -232,214 +232,214 @@ static GF_Err gf_m2ts_dsmcc_download_data(GF_M2TS_DSMCC_OVERLORD *dsmcc_overlord switch (DataMessage->DownloadDataHeader.messageId) { case DOWNLOAD_INFO_REQUEST: - { - GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST* DownloadInfoRequest; - GF_SAFEALLOC(DownloadInfoRequest,GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST); - DataMessage->dataMessagePayload = DownloadInfoRequest; - - /* Payload */ - DownloadInfoRequest->bufferSize = gf_bs_read_int(bs,32); - DownloadInfoRequest->maximumBlockSize = gf_bs_read_int(bs,16); - gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadInfoRequest->CompatibilityDescr,data,bs,data_shift); - DownloadInfoRequest->privateDataLength = gf_bs_read_int(bs,16); - DownloadInfoRequest->privateDataByte = (char*)gf_calloc(DownloadInfoRequest->privateDataLength,sizeof(char)); - gf_bs_read_data(bs,DownloadInfoRequest->privateDataByte,(u32)(DownloadInfoRequest->privateDataLength)); - break; - } - case DOWNLOAD_INFO_REPONSE_INDICATION: - { - u32 i,nb_modules; - GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC* DownloadInfoIndication; - GF_SAFEALLOC(DownloadInfoIndication,GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC); - DataMessage->dataMessagePayload = DownloadInfoIndication; - - /* Payload */ - DownloadInfoIndication->downloadId = gf_bs_read_int(bs,32); - DownloadInfoIndication->blockSize = gf_bs_read_int(bs,16); - DownloadInfoIndication->windowSize = gf_bs_read_int(bs,8); - DownloadInfoIndication->ackPeriod = gf_bs_read_int(bs,8); - DownloadInfoIndication->tCDownloadWindow = gf_bs_read_int(bs,32); - DownloadInfoIndication->tCDownloadScenario = gf_bs_read_int(bs,32); - - /* Compatibility Descr */ - gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadInfoIndication->CompatibilityDescr,data,bs,data_shift); - DownloadInfoIndication->numberOfModules = gf_bs_read_int(bs,16); - /* Versioning of the DownloadInfoIndication is made by the field transactionId (here known as downloadId) */ - if(DataMessage->DownloadDataHeader.downloadId > dsmcc_overlord->transactionId){ - dsmcc_overlord->transactionId = DataMessage->DownloadDataHeader.downloadId; - nb_modules = gf_list_count(dsmcc_overlord->dsmcc_modules); - for(i = 0;inumberOfModules;i++){ - DownloadInfoIndication->Modules.moduleId = gf_bs_read_int(bs,16); - DownloadInfoIndication->Modules.moduleSize = gf_bs_read_int(bs,32); - DownloadInfoIndication->Modules.moduleVersion = gf_bs_read_int(bs,8); - DownloadInfoIndication->Modules.moduleInfoLength = gf_bs_read_int(bs,8); - DownloadInfoIndication->Modules.moduleInfoByte = (char*)gf_calloc(DownloadInfoIndication->Modules.moduleInfoLength,sizeof(char)); - gf_bs_read_data(bs,DownloadInfoIndication->Modules.moduleInfoByte,(u32)(DownloadInfoIndication->Modules.moduleInfoLength)); - if(!dsmcc_create_module_validation(&DownloadInfoIndication->Modules,DownloadInfoIndication->downloadId,dsmcc_overlord,nb_modules)){ - /* Creation of the module */ - GF_M2TS_DSMCC_MODULE*dsmcc_module = dsmcc_create_module(dsmcc_overlord,DownloadInfoIndication); - if(DownloadInfoIndication->Modules.moduleInfoLength){ - GF_Err e; - e = dsmcc_get_biop_module_info(dsmcc_module,DownloadInfoIndication->Modules.moduleInfoByte,DownloadInfoIndication->Modules.moduleInfoLength); - if(e){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in BIOP Module Info for module %d, abording the processing \n",dsmcc_module->moduleId)); - gf_free(DownloadInfoIndication->Modules.moduleInfoByte); - DownloadInfoIndication->Modules.moduleInfoByte = NULL; - return GF_CORRUPTED_DATA; - } + { + GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST* DownloadInfoRequest; + GF_SAFEALLOC(DownloadInfoRequest,GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST); + DataMessage->dataMessagePayload = DownloadInfoRequest; + + /* Payload */ + DownloadInfoRequest->bufferSize = gf_bs_read_int(bs,32); + DownloadInfoRequest->maximumBlockSize = gf_bs_read_int(bs,16); + gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadInfoRequest->CompatibilityDescr,data,bs,data_shift); + DownloadInfoRequest->privateDataLength = gf_bs_read_int(bs,16); + DownloadInfoRequest->privateDataByte = (char*)gf_calloc(DownloadInfoRequest->privateDataLength,sizeof(char)); + gf_bs_read_data(bs,DownloadInfoRequest->privateDataByte,(u32)(DownloadInfoRequest->privateDataLength)); + break; + } + case DOWNLOAD_INFO_REPONSE_INDICATION: + { + u32 i,nb_modules; + GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC* DownloadInfoIndication; + GF_SAFEALLOC(DownloadInfoIndication,GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC); + DataMessage->dataMessagePayload = DownloadInfoIndication; + + /* Payload */ + DownloadInfoIndication->downloadId = gf_bs_read_int(bs,32); + DownloadInfoIndication->blockSize = gf_bs_read_int(bs,16); + DownloadInfoIndication->windowSize = gf_bs_read_int(bs,8); + DownloadInfoIndication->ackPeriod = gf_bs_read_int(bs,8); + DownloadInfoIndication->tCDownloadWindow = gf_bs_read_int(bs,32); + DownloadInfoIndication->tCDownloadScenario = gf_bs_read_int(bs,32); + + /* Compatibility Descr */ + gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadInfoIndication->CompatibilityDescr,data,bs,data_shift); + DownloadInfoIndication->numberOfModules = gf_bs_read_int(bs,16); + /* Versioning of the DownloadInfoIndication is made by the field transactionId (here known as downloadId) */ + if(DataMessage->DownloadDataHeader.downloadId > dsmcc_overlord->transactionId) { + dsmcc_overlord->transactionId = DataMessage->DownloadDataHeader.downloadId; + nb_modules = gf_list_count(dsmcc_overlord->dsmcc_modules); + for(i = 0; inumberOfModules; i++) { + DownloadInfoIndication->Modules.moduleId = gf_bs_read_int(bs,16); + DownloadInfoIndication->Modules.moduleSize = gf_bs_read_int(bs,32); + DownloadInfoIndication->Modules.moduleVersion = gf_bs_read_int(bs,8); + DownloadInfoIndication->Modules.moduleInfoLength = gf_bs_read_int(bs,8); + DownloadInfoIndication->Modules.moduleInfoByte = (char*)gf_calloc(DownloadInfoIndication->Modules.moduleInfoLength,sizeof(char)); + gf_bs_read_data(bs,DownloadInfoIndication->Modules.moduleInfoByte,(u32)(DownloadInfoIndication->Modules.moduleInfoLength)); + if(!dsmcc_create_module_validation(&DownloadInfoIndication->Modules,DownloadInfoIndication->downloadId,dsmcc_overlord,nb_modules)) { + /* Creation of the module */ + GF_M2TS_DSMCC_MODULE*dsmcc_module = dsmcc_create_module(dsmcc_overlord,DownloadInfoIndication); + if(DownloadInfoIndication->Modules.moduleInfoLength) { + GF_Err e; + e = dsmcc_get_biop_module_info(dsmcc_module,DownloadInfoIndication->Modules.moduleInfoByte,DownloadInfoIndication->Modules.moduleInfoLength); + if(e) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in BIOP Module Info for module %d, abording the processing \n",dsmcc_module->moduleId)); + gf_free(DownloadInfoIndication->Modules.moduleInfoByte); + DownloadInfoIndication->Modules.moduleInfoByte = NULL; + return GF_CORRUPTED_DATA; } } - gf_free(DownloadInfoIndication->Modules.moduleInfoByte); - DownloadInfoIndication->Modules.moduleInfoByte = NULL; } - DownloadInfoIndication->privateDataLength = gf_bs_read_int(bs,16); - DownloadInfoIndication->privateDataByte = (char*)gf_calloc(DownloadInfoIndication->privateDataLength,sizeof(char)); - gf_bs_read_data(bs,DownloadInfoIndication->privateDataByte,(u32)(DownloadInfoIndication->privateDataLength)); + gf_free(DownloadInfoIndication->Modules.moduleInfoByte); + DownloadInfoIndication->Modules.moduleInfoByte = NULL; } - break; + DownloadInfoIndication->privateDataLength = gf_bs_read_int(bs,16); + DownloadInfoIndication->privateDataByte = (char*)gf_calloc(DownloadInfoIndication->privateDataLength,sizeof(char)); + gf_bs_read_data(bs,DownloadInfoIndication->privateDataByte,(u32)(DownloadInfoIndication->privateDataLength)); } + break; + } case DOWNLOAD_DATA_BLOCK: - { - u32 modules_count, i; - GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock; - GF_SAFEALLOC(DownloadDataBlock,GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK); - DataMessage->dataMessagePayload = DownloadDataBlock; - modules_count = 0; - modules_count = gf_list_count(dsmcc_overlord->dsmcc_modules); - - if(!modules_count){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Download Information Indicator has not been received yet, waiting before processing data block \n")); - break; - } - - - DownloadDataBlock->moduleId = gf_bs_read_int(bs,16); - //fprintf(stderr, "DownloadDataBlock->moduleId %d \n",DownloadDataBlock->moduleId); - DownloadDataBlock->moduleVersion = gf_bs_read_int(bs,8); - DownloadDataBlock->reserved = gf_bs_read_int(bs,8); - if(DownloadDataBlock->reserved != 0xFF){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] DataHeader reserved slot does not have the correct value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - DownloadDataBlock->blockNumber = gf_bs_read_int(bs,16); - - for(i=0;idsmcc_modules,i); - /* Test if the data are compatible with the module configuration */ - if(!dsmcc_download_data_validation(dsmcc_overlord,DownloadDataBlock,dsmcc_module,DataMessage->DownloadDataHeader.downloadId)){ - //fprintf(stderr, "DownloadDataBlock->blockNumber %d \n\n",DownloadDataBlock->blockNumber); - DownloadDataBlock->dataBlocksize = (DataMessage->DownloadDataHeader.messageLength - 6); - if(dsmcc_module->block_size < DownloadDataBlock->dataBlocksize){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error block_size should be >= to DownloadDataBlock->dataBlocksize , abording the processing \n")); - return GF_CORRUPTED_DATA; - } - DownloadDataBlock->blockDataByte = (char*)gf_calloc(DownloadDataBlock->dataBlocksize,sizeof(char)); - *data_shift = (u32)(gf_bs_get_position(bs)); - gf_bs_read_data(bs,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize); - memcpy(dsmcc_module->buffer+dsmcc_module->byte_sift,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize*sizeof(char)); - dsmcc_module->byte_sift += DownloadDataBlock->dataBlocksize; - dsmcc_module->last_section_number = dsmcc->last_section_number; - dsmcc_module->section_number++; - if(dsmcc_module->section_number == (dsmcc_module->last_section_number+1)){ - dsmcc_module_complete(dsmcc_overlord,dsmcc_module,i); - } - break; - } - } - - break; - } - case DOWNLOAD_DATA_REQUEST: - { - GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE* DownloadDataRequest; - GF_SAFEALLOC(DownloadDataRequest,GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE); - DataMessage->dataMessagePayload = DownloadDataRequest; - DownloadDataRequest->moduleId = gf_bs_read_int(bs,16); - DownloadDataRequest->blockNumber = gf_bs_read_int(bs,16); - DownloadDataRequest->downloadReason = gf_bs_read_int(bs,8); + { + u32 modules_count, i; + GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock; + GF_SAFEALLOC(DownloadDataBlock,GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK); + DataMessage->dataMessagePayload = DownloadDataBlock; + modules_count = 0; + modules_count = gf_list_count(dsmcc_overlord->dsmcc_modules); + + if(!modules_count) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Download Information Indicator has not been received yet, waiting before processing data block \n")); break; } - case DOWNLOAD_DATA_CANCEL: - { - GF_M2TS_DSMCC_DOWNLOAD_CANCEL* DownloadCancel; - GF_SAFEALLOC(DownloadCancel,GF_M2TS_DSMCC_DOWNLOAD_CANCEL); - DataMessage->dataMessagePayload = DownloadCancel; - DownloadCancel->downloadId = gf_bs_read_int(bs,32); - DownloadCancel->moduleId = gf_bs_read_int(bs,16); - DownloadCancel->blockNumber = gf_bs_read_int(bs,16); - DownloadCancel->downloadCancelReason = gf_bs_read_int(bs,8); - DownloadCancel->reserved = gf_bs_read_int(bs,8); - DownloadCancel->privateDataLength = gf_bs_read_int(bs,16); - if(DownloadCancel->privateDataLength){ - DownloadCancel->privateDataByte = (char*)gf_calloc(DownloadCancel->privateDataLength,sizeof(char)); - gf_bs_read_data(bs,DownloadCancel->privateDataByte,(u32)(DownloadCancel->privateDataLength)); - } - break; + DownloadDataBlock->moduleId = gf_bs_read_int(bs,16); + //fprintf(stderr, "DownloadDataBlock->moduleId %d \n",DownloadDataBlock->moduleId); + DownloadDataBlock->moduleVersion = gf_bs_read_int(bs,8); + DownloadDataBlock->reserved = gf_bs_read_int(bs,8); + if(DownloadDataBlock->reserved != 0xFF) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] DataHeader reserved slot does not have the correct value, abording the processing \n")); + return GF_CORRUPTED_DATA; } - case DOWNLOAD_SERVER_INITIATE: - { - GF_Err e; - GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit; - GF_SAFEALLOC(DownloadServerInit,GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT); - DataMessage->dataMessagePayload = DownloadServerInit; - gf_bs_read_data(bs,DownloadServerInit->serverId,20); - gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr,data,bs,data_shift); - DownloadServerInit->privateDataLength = gf_bs_read_int(bs,16); - if(DownloadServerInit->privateDataLength){ - - u32 i; - - GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO* ServiceGateWayInfo; - GF_SAFEALLOC(ServiceGateWayInfo,GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO); - - /* IOR */ - e = dsmcc_biop_get_ior(bs,&ServiceGateWayInfo->IOR); - if(e){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Corrupted IOR, abording the processing \n")); - gf_free(ServiceGateWayInfo); - return GF_CORRUPTED_DATA; - } - ServiceGateWayInfo->downloadTaps_count = gf_bs_read_int(bs,8); - ServiceGateWayInfo->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(ServiceGateWayInfo->downloadTaps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for(i=0;idownloadTaps_count;i++){ - ServiceGateWayInfo->Taps[i].id = gf_bs_read_int(bs,16); - ServiceGateWayInfo->Taps[i].use = gf_bs_read_int(bs,16); - ServiceGateWayInfo->Taps[i].assocTag = gf_bs_read_int(bs,16); - ServiceGateWayInfo->Taps[i].selector_length = gf_bs_read_int(bs,8); - ServiceGateWayInfo->Taps[i].selector_type = gf_bs_read_int(bs,16); - ServiceGateWayInfo->Taps[i].transactionId = gf_bs_read_int(bs,32); - ServiceGateWayInfo->Taps[i].timeout = gf_bs_read_int(bs,32); + DownloadDataBlock->blockNumber = gf_bs_read_int(bs,16); + + for(i=0; idsmcc_modules,i); + /* Test if the data are compatible with the module configuration */ + if(!dsmcc_download_data_validation(dsmcc_overlord,DownloadDataBlock,dsmcc_module,DataMessage->DownloadDataHeader.downloadId)) { + //fprintf(stderr, "DownloadDataBlock->blockNumber %d \n\n",DownloadDataBlock->blockNumber); + DownloadDataBlock->dataBlocksize = (DataMessage->DownloadDataHeader.messageLength - 6); + if(dsmcc_module->block_size < DownloadDataBlock->dataBlocksize) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error block_size should be >= to DownloadDataBlock->dataBlocksize , abording the processing \n")); + return GF_CORRUPTED_DATA; } - ServiceGateWayInfo->serviceContextList_count = gf_bs_read_int(bs,8); - ServiceGateWayInfo->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(ServiceGateWayInfo->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); - dsmcc_biop_get_context(bs,ServiceGateWayInfo->ServiceContext,ServiceGateWayInfo->serviceContextList_count); - ServiceGateWayInfo->userInfoLength = gf_bs_read_int(bs,16); - if(ServiceGateWayInfo->userInfoLength != 0){ - ServiceGateWayInfo->userInfo_data = (char*)gf_calloc(ServiceGateWayInfo->userInfoLength,sizeof(char)); - gf_bs_read_data(bs,ServiceGateWayInfo->userInfo_data,(u32)(ServiceGateWayInfo->userInfoLength)); + DownloadDataBlock->blockDataByte = (char*)gf_calloc(DownloadDataBlock->dataBlocksize,sizeof(char)); + *data_shift = (u32)(gf_bs_get_position(bs)); + gf_bs_read_data(bs,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize); + memcpy(dsmcc_module->buffer+dsmcc_module->byte_sift,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize*sizeof(char)); + dsmcc_module->byte_sift += DownloadDataBlock->dataBlocksize; + dsmcc_module->last_section_number = dsmcc->last_section_number; + dsmcc_module->section_number++; + if(dsmcc_module->section_number == (dsmcc_module->last_section_number+1)) { + dsmcc_module_complete(dsmcc_overlord,dsmcc_module,i); } + break; + } + } - if(!dsmcc_overlord->ServiceGateway && gf_list_count(ServiceGateWayInfo->IOR.taggedProfile)){ - GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(ServiceGateWayInfo->IOR.taggedProfile,0); - dsmcc_overlord->ServiceGateway = (GF_M2TS_DSMCC_SERVICE_GATEWAY*)gf_calloc(1,sizeof(GF_M2TS_DSMCC_SERVICE_GATEWAY)); - dsmcc_overlord->ServiceGateway->downloadId = taggedProfile->BIOPProfileBody->ObjectLocation.carouselId; - dsmcc_overlord->ServiceGateway->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; - dsmcc_overlord->ServiceGateway->service_id = dsmcc_overlord->service_id; - dsmcc_overlord->ServiceGateway->File = gf_list_new(); - dsmcc_overlord->ServiceGateway->Dir = gf_list_new(); - } + break; + } + case DOWNLOAD_DATA_REQUEST: + { + GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE* DownloadDataRequest; + GF_SAFEALLOC(DownloadDataRequest,GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE); + DataMessage->dataMessagePayload = DownloadDataRequest; + DownloadDataRequest->moduleId = gf_bs_read_int(bs,16); + DownloadDataRequest->blockNumber = gf_bs_read_int(bs,16); + DownloadDataRequest->downloadReason = gf_bs_read_int(bs,8); + break; + } + case DOWNLOAD_DATA_CANCEL: + + { + GF_M2TS_DSMCC_DOWNLOAD_CANCEL* DownloadCancel; + GF_SAFEALLOC(DownloadCancel,GF_M2TS_DSMCC_DOWNLOAD_CANCEL); + DataMessage->dataMessagePayload = DownloadCancel; + DownloadCancel->downloadId = gf_bs_read_int(bs,32); + DownloadCancel->moduleId = gf_bs_read_int(bs,16); + DownloadCancel->blockNumber = gf_bs_read_int(bs,16); + DownloadCancel->downloadCancelReason = gf_bs_read_int(bs,8); + DownloadCancel->reserved = gf_bs_read_int(bs,8); + DownloadCancel->privateDataLength = gf_bs_read_int(bs,16); + if(DownloadCancel->privateDataLength) { + DownloadCancel->privateDataByte = (char*)gf_calloc(DownloadCancel->privateDataLength,sizeof(char)); + gf_bs_read_data(bs,DownloadCancel->privateDataByte,(u32)(DownloadCancel->privateDataLength)); + } + break; + + } + case DOWNLOAD_SERVER_INITIATE: + { + GF_Err e; + GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit; + GF_SAFEALLOC(DownloadServerInit,GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT); + DataMessage->dataMessagePayload = DownloadServerInit; + gf_bs_read_data(bs,DownloadServerInit->serverId,20); + gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr,data,bs,data_shift); + DownloadServerInit->privateDataLength = gf_bs_read_int(bs,16); + if(DownloadServerInit->privateDataLength) { + + u32 i; + + GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO* ServiceGateWayInfo; + GF_SAFEALLOC(ServiceGateWayInfo,GF_M2TS_DSMCC_SERVICE_GATEWAY_INFO); + + /* IOR */ + e = dsmcc_biop_get_ior(bs,&ServiceGateWayInfo->IOR); + if(e) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Corrupted IOR, abording the processing \n")); + gf_free(ServiceGateWayInfo); + return GF_CORRUPTED_DATA; + } + ServiceGateWayInfo->downloadTaps_count = gf_bs_read_int(bs,8); + ServiceGateWayInfo->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(ServiceGateWayInfo->downloadTaps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); + for(i=0; idownloadTaps_count; i++) { + ServiceGateWayInfo->Taps[i].id = gf_bs_read_int(bs,16); + ServiceGateWayInfo->Taps[i].use = gf_bs_read_int(bs,16); + ServiceGateWayInfo->Taps[i].assocTag = gf_bs_read_int(bs,16); + ServiceGateWayInfo->Taps[i].selector_length = gf_bs_read_int(bs,8); + ServiceGateWayInfo->Taps[i].selector_type = gf_bs_read_int(bs,16); + ServiceGateWayInfo->Taps[i].transactionId = gf_bs_read_int(bs,32); + ServiceGateWayInfo->Taps[i].timeout = gf_bs_read_int(bs,32); + } + ServiceGateWayInfo->serviceContextList_count = gf_bs_read_int(bs,8); + ServiceGateWayInfo->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(ServiceGateWayInfo->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); + dsmcc_biop_get_context(bs,ServiceGateWayInfo->ServiceContext,ServiceGateWayInfo->serviceContextList_count); + ServiceGateWayInfo->userInfoLength = gf_bs_read_int(bs,16); + if(ServiceGateWayInfo->userInfoLength != 0) { + ServiceGateWayInfo->userInfo_data = (char*)gf_calloc(ServiceGateWayInfo->userInfoLength,sizeof(char)); + gf_bs_read_data(bs,ServiceGateWayInfo->userInfo_data,(u32)(ServiceGateWayInfo->userInfoLength)); } - break; + if(!dsmcc_overlord->ServiceGateway && gf_list_count(ServiceGateWayInfo->IOR.taggedProfile)) { + GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(ServiceGateWayInfo->IOR.taggedProfile,0); + dsmcc_overlord->ServiceGateway = (GF_M2TS_DSMCC_SERVICE_GATEWAY*)gf_calloc(1,sizeof(GF_M2TS_DSMCC_SERVICE_GATEWAY)); + dsmcc_overlord->ServiceGateway->downloadId = taggedProfile->BIOPProfileBody->ObjectLocation.carouselId; + dsmcc_overlord->ServiceGateway->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; + dsmcc_overlord->ServiceGateway->service_id = dsmcc_overlord->service_id; + dsmcc_overlord->ServiceGateway->File = gf_list_new(); + dsmcc_overlord->ServiceGateway->Dir = gf_list_new(); + } } + break; + } + default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown dataMessagePayload Type \n")); - break; - } + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown dataMessagePayload Type \n")); + break; + } } //dsmcc->DSMCC_Extension = DataMessage; @@ -501,11 +501,11 @@ static GF_Err gf_m2ts_dsmcc_process_compatibility_descriptor(GF_M2TS_DSMCC_COMPA CompatibilityDesc->compatibilityDescriptorLength = gf_bs_read_int(bs,16); - if(CompatibilityDesc->compatibilityDescriptorLength){ + if(CompatibilityDesc->compatibilityDescriptorLength) { CompatibilityDesc->descriptorCount = gf_bs_read_int(bs,16); - if(CompatibilityDesc->descriptorCount){ + if(CompatibilityDesc->descriptorCount) { CompatibilityDesc->Descriptor = (GF_M2TS_DSMCC_DESCRIPTOR*)gf_calloc(CompatibilityDesc->descriptorCount,sizeof(GF_M2TS_DSMCC_DESCRIPTOR)); - for(i=0;idescriptorCount;i++){ + for(i=0; idescriptorCount; i++) { CompatibilityDesc->Descriptor[i].descriptorType = gf_bs_read_int(bs,8); CompatibilityDesc->Descriptor[i].descriptorLength = gf_bs_read_int(bs,8); CompatibilityDesc->Descriptor[i].specifierType = gf_bs_read_int(bs,8); @@ -513,12 +513,12 @@ static GF_Err gf_m2ts_dsmcc_process_compatibility_descriptor(GF_M2TS_DSMCC_COMPA CompatibilityDesc->Descriptor[i].model = gf_bs_read_int(bs,16); CompatibilityDesc->Descriptor[i].version = gf_bs_read_int(bs,16); CompatibilityDesc->Descriptor[i].subDescriptorCount = gf_bs_read_int(bs,8); - if(CompatibilityDesc->Descriptor[i].subDescriptorCount){ + if(CompatibilityDesc->Descriptor[i].subDescriptorCount) { CompatibilityDesc->Descriptor[i].SubDescriptor = (GF_M2TS_DSMCC_SUBDESCRIPTOR*)gf_calloc(CompatibilityDesc->Descriptor[i].subDescriptorCount,sizeof(GF_M2TS_DSMCC_SUBDESCRIPTOR)); - for(j=0;j>CompatibilityDesc->Descriptor[i].subDescriptorCount;j++){ + for(j=0; j>CompatibilityDesc->Descriptor[i].subDescriptorCount; j++) { CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorType = gf_bs_read_int(bs,8); CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorLength = gf_bs_read_int(bs,8); - if(CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorLength){ + if(CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorLength) { CompatibilityDesc->Descriptor[i].SubDescriptor[j].additionalInformation = (char*)gf_calloc(CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorLength,sizeof(char)); gf_bs_read_data(bs,CompatibilityDesc->Descriptor[i].SubDescriptor[j].additionalInformation,(u32)(CompatibilityDesc->Descriptor[i].SubDescriptor[j].subDescriptorLength)); } @@ -530,7 +530,7 @@ static GF_Err gf_m2ts_dsmcc_process_compatibility_descriptor(GF_M2TS_DSMCC_COMPA } *data_shift = (u32)(gf_bs_get_position(bs)); - if(*data_shift != byte_shift+2+CompatibilityDesc->compatibilityDescriptorLength){ + if(*data_shift != byte_shift+2+CompatibilityDesc->compatibilityDescriptorLength) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Descriptor length not respected, difference between %d and %d \n",(*data_shift - byte_shift),2+CompatibilityDesc->compatibilityDescriptorLength)); return GF_CORRUPTED_DATA; } @@ -538,7 +538,7 @@ static GF_Err gf_m2ts_dsmcc_process_compatibility_descriptor(GF_M2TS_DSMCC_COMPA return GF_OK; } -static GF_Err dsmcc_create_module_validation(GF_M2TS_DSMCC_INFO_MODULES* InfoModules, u32 downloadId, GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,u32 nb_module){ +static GF_Err dsmcc_create_module_validation(GF_M2TS_DSMCC_INFO_MODULES* InfoModules, u32 downloadId, GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,u32 nb_module) { u32 i; for (i=0; iServiceGateway){ + if(dsmcc_overlord->ServiceGateway) { if ((dsmcc_overlord->Got_ServiceGateway || dsmcc_module->moduleId == dsmcc_overlord->ServiceGateway->moduleId)&& - ((dsmcc_module->moduleId == DownloadDataBlock->moduleId) && (dsmcc_module->section_number == DownloadDataBlock->blockNumber) && - (dsmcc_module->downloadId == downloadId) && (dsmcc_module->version_number == DownloadDataBlock->moduleVersion))){ - return GF_OK; + ((dsmcc_module->moduleId == DownloadDataBlock->moduleId) && (dsmcc_module->section_number == DownloadDataBlock->blockNumber) && + (dsmcc_module->downloadId == downloadId) && (dsmcc_module->version_number == DownloadDataBlock->moduleVersion))) { + return GF_OK; } } - + return GF_CORRUPTED_DATA; } @@ -608,16 +608,16 @@ static GF_Err dsmcc_module_complete(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2 GF_M2TS_DSMCC_PROCESSED dsmcc_process = dsmcc_overlord->processed[i]; if ((dsmcc_module->moduleId == dsmcc_process.moduleId) && dsmcc_module->version_number == dsmcc_process.version_number && dsmcc_module->downloadId == dsmcc_process.downloadId) { /*process buffer*/ - if(dsmcc_module->Gzip){ + if(dsmcc_module->Gzip) { u32 uncomp_size; char* uncompressed_data; gf_gz_decompress_payload(dsmcc_module->buffer,dsmcc_module->byte_sift,&uncompressed_data, &uncomp_size); //dsmcc_process_biop_data(dsmcc_overlord,dsmcc_module,uncompressed_data,dsmcc_module->original_size); - - if(dsmcc_module->original_size == uncomp_size){ + + if(dsmcc_module->original_size == uncomp_size) { e = dsmcc_process_biop_data(dsmcc_overlord,dsmcc_module,uncompressed_data,dsmcc_module->original_size); - }else{ + } else { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Buffer size is not equal to the module size. Flushing the data \n")); gf_free(dsmcc_module->buffer); dsmcc_module->buffer = NULL; @@ -625,18 +625,18 @@ static GF_Err dsmcc_module_complete(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2 dsmcc_module->section_number = 0; return GF_CORRUPTED_DATA; } - }else{ - e = dsmcc_process_biop_data(dsmcc_overlord,dsmcc_module,dsmcc_module->buffer,dsmcc_module->size); + } else { + e = dsmcc_process_biop_data(dsmcc_overlord,dsmcc_module,dsmcc_module->buffer,dsmcc_module->size); } - if(e){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the processing of the module data. Flushing the data \n")); - gf_free(dsmcc_module->buffer); - dsmcc_module->buffer = NULL; - dsmcc_module->buffer = (char*)gf_calloc(dsmcc_module->size,sizeof(char)); - dsmcc_module->section_number = 0; - return GF_CORRUPTED_DATA; - }else{ - dsmcc_process.done = 1; + if(e) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the processing of the module data. Flushing the data \n")); + gf_free(dsmcc_module->buffer); + dsmcc_module->buffer = NULL; + dsmcc_module->buffer = (char*)gf_calloc(dsmcc_module->size,sizeof(char)); + dsmcc_module->section_number = 0; + return GF_CORRUPTED_DATA; + } else { + dsmcc_process.done = 1; dsmcc_module_delete(dsmcc_module); gf_list_rem(dsmcc_overlord->dsmcc_modules,moduleIndex); } @@ -650,7 +650,7 @@ static GF_Err dsmcc_module_complete(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2 static GF_Err gf_m2ts_dsmcc_delete_compatibility_descriptor(GF_M2TS_DSMCC_COMPATIBILITY_DESCRIPTOR *CompatibilityDesc) { - u32 i,j; + u32 i,j; if (CompatibilityDesc->compatibilityDescriptorLength) { if (CompatibilityDesc->descriptorCount) { for (i=0; idescriptorCount; i++) { @@ -670,8 +670,8 @@ static GF_Err gf_m2ts_dsmcc_delete_compatibility_descriptor(GF_M2TS_DSMCC_COMPAT } static GF_Err gf_m2ts_dsmcc_delete_message_header(GF_M2TS_DSMCC_MESSAGE_DATA_HEADER *MessageHeader) -{ - if (MessageHeader->adaptationLength > 0) { +{ + if (MessageHeader->adaptationLength > 0) { gf_free(MessageHeader->DsmccAdaptationHeader->adaptationDataByte); gf_free(MessageHeader->DsmccAdaptationHeader); } @@ -680,76 +680,76 @@ static GF_Err gf_m2ts_dsmcc_delete_message_header(GF_M2TS_DSMCC_MESSAGE_DATA_HEA static GF_Err gf_m2ts_dsmcc_section_delete(GF_M2TS_DSMCC_SECTION *dsmcc) { - GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE* DataMessage = (GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE*)dsmcc->DSMCC_Extension; + GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE* DataMessage = (GF_M2TS_DSMCC_DOWNLOAD_DATA_MESSAGE*)dsmcc->DSMCC_Extension; - if(!DataMessage){ + if(!DataMessage) { return GF_OK; } switch (DataMessage->DownloadDataHeader.messageId) { case DOWNLOAD_INFO_REQUEST: - { - GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST* DownloadInfoRequest = (GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST*)DataMessage->dataMessagePayload; - if(DownloadInfoRequest->privateDataLength){ - gf_free(DownloadInfoRequest->privateDataByte); - } - gf_free(DownloadInfoRequest); - break; + { + GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST* DownloadInfoRequest = (GF_M2TS_DSMCC_DOWNLOAD_INFO_REQUEST*)DataMessage->dataMessagePayload; + if(DownloadInfoRequest->privateDataLength) { + gf_free(DownloadInfoRequest->privateDataByte); } + gf_free(DownloadInfoRequest); + break; + } case DOWNLOAD_INFO_REPONSE_INDICATION: - { - GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC* DownloadInfoIndication = (GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC*)DataMessage->dataMessagePayload; - - /* Compatibility Descr */ - gf_m2ts_dsmcc_delete_compatibility_descriptor(&DownloadInfoIndication->CompatibilityDescr); - - if (DownloadInfoIndication->privateDataLength) { - gf_free(DownloadInfoIndication->privateDataByte); - } - gf_free(DownloadInfoIndication); - break; + { + GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC* DownloadInfoIndication = (GF_M2TS_DSMCC_DOWNLOAD_INFO_RESP_INDIC*)DataMessage->dataMessagePayload; + + /* Compatibility Descr */ + gf_m2ts_dsmcc_delete_compatibility_descriptor(&DownloadInfoIndication->CompatibilityDescr); + + if (DownloadInfoIndication->privateDataLength) { + gf_free(DownloadInfoIndication->privateDataByte); } + gf_free(DownloadInfoIndication); + break; + } case DOWNLOAD_DATA_BLOCK: - { - GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock = (GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK*)DataMessage->dataMessagePayload; - if (DownloadDataBlock->dataBlocksize) { - gf_free(DownloadDataBlock->blockDataByte); - } - gf_free(DownloadDataBlock); - break; + { + GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock = (GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK*)DataMessage->dataMessagePayload; + if (DownloadDataBlock->dataBlocksize) { + gf_free(DownloadDataBlock->blockDataByte); } + gf_free(DownloadDataBlock); + break; + } case DOWNLOAD_DATA_REQUEST: - { - GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE* DownloadDataRequest = (GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE*)DataMessage->dataMessagePayload; - gf_free(DownloadDataRequest); - break; - } + { + GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE* DownloadDataRequest = (GF_M2TS_DSMCC_DOWNLOAD_DATA_REQUEST_MESSAGE*)DataMessage->dataMessagePayload; + gf_free(DownloadDataRequest); + break; + } case DOWNLOAD_DATA_CANCEL: - { - GF_M2TS_DSMCC_DOWNLOAD_CANCEL* DownloadCancel = (GF_M2TS_DSMCC_DOWNLOAD_CANCEL*)DataMessage->dataMessagePayload; - if (DownloadCancel->privateDataLength) { - gf_free(DownloadCancel->privateDataByte); - } - gf_free(DownloadCancel); - break; + { + GF_M2TS_DSMCC_DOWNLOAD_CANCEL* DownloadCancel = (GF_M2TS_DSMCC_DOWNLOAD_CANCEL*)DataMessage->dataMessagePayload; + if (DownloadCancel->privateDataLength) { + gf_free(DownloadCancel->privateDataByte); } + gf_free(DownloadCancel); + break; + } case DOWNLOAD_SERVER_INITIATE: - { - GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit = (GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT*)DataMessage->dataMessagePayload; - gf_m2ts_dsmcc_delete_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr); - if (DownloadServerInit->privateDataLength) { - gf_free(DownloadServerInit->privateDataByte); - } - gf_free(DownloadServerInit); - break; + { + GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit = (GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT*)DataMessage->dataMessagePayload; + gf_m2ts_dsmcc_delete_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr); + if (DownloadServerInit->privateDataLength) { + gf_free(DownloadServerInit->privateDataByte); } + gf_free(DownloadServerInit); + break; + } default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown dataMessagePayload Type \n")); - break; - } - } + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unknown dataMessagePayload Type \n")); + break; + } + } /* Header */ gf_m2ts_dsmcc_delete_message_header(&DataMessage->DownloadDataHeader); @@ -760,7 +760,7 @@ static GF_Err gf_m2ts_dsmcc_section_delete(GF_M2TS_DSMCC_SECTION *dsmcc) } -static GF_Err dsmcc_module_delete(GF_M2TS_DSMCC_MODULE* dsmcc_module){ +static GF_Err dsmcc_module_delete(GF_M2TS_DSMCC_MODULE* dsmcc_module) { gf_free(dsmcc_module->buffer); gf_free(dsmcc_module); @@ -770,7 +770,7 @@ static GF_Err dsmcc_module_delete(GF_M2TS_DSMCC_MODULE* dsmcc_module){ /* BIOP MESSAGE */ -static GF_Err dsmcc_get_biop_module_info(GF_M2TS_DSMCC_MODULE* dsmcc_module,char* data,u8 data_size){ +static GF_Err dsmcc_get_biop_module_info(GF_M2TS_DSMCC_MODULE* dsmcc_module,char* data,u8 data_size) { GF_M2TS_DSMCC_BIOP_MODULE_INFO* BIOP_ModuleInfo; GF_BitStream *bs; @@ -785,90 +785,90 @@ static GF_Err dsmcc_get_biop_module_info(GF_M2TS_DSMCC_MODULE* dsmcc_module,char BIOP_ModuleInfo->blockTimeOut = gf_bs_read_int(bs,32); BIOP_ModuleInfo->minBlockTime = gf_bs_read_int(bs,32); BIOP_ModuleInfo->taps_count = gf_bs_read_int(bs,8); - if(!BIOP_ModuleInfo->taps_count){ + if(!BIOP_ModuleInfo->taps_count) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Corrupted payload for BIOP Module Info \n")); - gf_list_del(BIOP_ModuleInfo->descriptor); + gf_list_del(BIOP_ModuleInfo->descriptor); gf_free(BIOP_ModuleInfo); - return GF_CORRUPTED_DATA; + return GF_CORRUPTED_DATA; } BIOP_ModuleInfo->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(BIOP_ModuleInfo->taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for(i = 0; i < BIOP_ModuleInfo->taps_count; i++){ + for(i = 0; i < BIOP_ModuleInfo->taps_count; i++) { BIOP_ModuleInfo->Taps[i].id = gf_bs_read_int(bs,16); BIOP_ModuleInfo->Taps[i].use = gf_bs_read_int(bs,16); BIOP_ModuleInfo->Taps[i].assocTag = gf_bs_read_int(bs,16); BIOP_ModuleInfo->Taps[i].selector_length = gf_bs_read_int(bs,8); - if(BIOP_ModuleInfo->Taps[i].selector_length){ + if(BIOP_ModuleInfo->Taps[i].selector_length) { BIOP_ModuleInfo->Taps[i].selector_data = (char*)gf_calloc(BIOP_ModuleInfo->Taps[i].selector_length,sizeof(char)); gf_bs_read_data(bs,BIOP_ModuleInfo->Taps[i].selector_data,(u8)(BIOP_ModuleInfo->Taps[i].selector_length)); } - if(i == 0 && (BIOP_ModuleInfo->Taps[i].id != 0x00 || BIOP_ModuleInfo->Taps[i].use != 0x17 || BIOP_ModuleInfo->Taps[i].selector_length != 0x00)){ + if(i == 0 && (BIOP_ModuleInfo->Taps[i].id != 0x00 || BIOP_ModuleInfo->Taps[i].use != 0x17 || BIOP_ModuleInfo->Taps[i].selector_length != 0x00)) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Corrupted payload for BIOP Module Info \n")); gf_free(BIOP_ModuleInfo->Taps); gf_list_del(BIOP_ModuleInfo->descriptor); gf_free(BIOP_ModuleInfo); - return GF_CORRUPTED_DATA; + return GF_CORRUPTED_DATA; } } BIOP_ModuleInfo->userInfoLength = gf_bs_read_int(bs,8); - if(BIOP_ModuleInfo->userInfoLength){ + if(BIOP_ModuleInfo->userInfoLength) { u32 nb_desc,j; u8* descr_tag; - dsmcc_biop_descriptor(bs,BIOP_ModuleInfo->descriptor,(u32)(BIOP_ModuleInfo->userInfoLength)); + dsmcc_biop_descriptor(bs,BIOP_ModuleInfo->descriptor,(u32)(BIOP_ModuleInfo->userInfoLength)); nb_desc = gf_list_count(BIOP_ModuleInfo->descriptor); j = 0; - while(jdescriptor,j); - - switch(*descr_tag){ - case CACHING_PRIORITY_DESCRIPTOR: - { - //GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr = (GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR*)gf_list_get(BIOP_ModuleInfo->descriptor,j); - break; - } - case COMPRESSED_MODULE_DESCRIPTOR: - { - u8 comp_meth; - GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr = (GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR*)gf_list_get(BIOP_ModuleInfo->descriptor,j); - /*if CompModuleDescr->compression_method least significant nibble is eq to 0x08, the terminal shall support the Deflate compression algorithm (GZIP)*/ - comp_meth = (CompModuleDescr->compression_method &0x0F); - if(comp_meth == 0x08){ - dsmcc_module->Gzip = 1; - } - dsmcc_module->original_size = CompModuleDescr->original_size; - break; + switch(*descr_tag) { - } - default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); - break; - } - } + case CACHING_PRIORITY_DESCRIPTOR: + { + //GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr = (GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR*)gf_list_get(BIOP_ModuleInfo->descriptor,j); + break; + } + case COMPRESSED_MODULE_DESCRIPTOR: + { + u8 comp_meth; + GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr = (GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR*)gf_list_get(BIOP_ModuleInfo->descriptor,j); + /*if CompModuleDescr->compression_method least significant nibble is eq to 0x08, the terminal shall support the Deflate compression algorithm (GZIP)*/ + comp_meth = (CompModuleDescr->compression_method &0x0F); + if(comp_meth == 0x08) { + dsmcc_module->Gzip = 1; + } + dsmcc_module->original_size = CompModuleDescr->original_size; + break; + + } + default: + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); + break; + } + } j++; } } - + dsmcc_free_biop_descriptor(BIOP_ModuleInfo->descriptor); - for(i = 0; i < BIOP_ModuleInfo->taps_count; i++){ - if(BIOP_ModuleInfo->Taps[i].selector_length){ + for(i = 0; i < BIOP_ModuleInfo->taps_count; i++) { + if(BIOP_ModuleInfo->Taps[i].selector_length) { gf_free(BIOP_ModuleInfo->Taps[i].selector_data); - } + } } gf_free(BIOP_ModuleInfo->Taps); - gf_free(BIOP_ModuleInfo); + gf_free(BIOP_ModuleInfo); return GF_OK; } -static GF_Err dsmcc_process_biop_data(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2TS_DSMCC_MODULE* dsmcc_module,char* data,u32 data_size){ +static GF_Err dsmcc_process_biop_data(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_M2TS_DSMCC_MODULE* dsmcc_module,char* data,u32 data_size) { GF_BitStream *bs; GF_Err e; @@ -884,54 +884,54 @@ static GF_Err dsmcc_process_biop_data(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord,GF_ byte_shift = (u32)(gf_bs_get_position(bs)); - while(byte_shift < data_size){ + while(byte_shift < data_size) { BIOP_Header = dsmcc_process_biop_header(bs); - if(BIOP_Header){ - if(!strcmp(BIOP_Header->objectKind_data,"fil")){ + if(BIOP_Header) { + if(!strcmp(BIOP_Header->objectKind_data,"fil")) { e = dsmcc_process_biop_file(bs,BIOP_Header,dsmcc_overlord,dsmcc_module->moduleId,dsmcc_module->downloadId); - }else if(!strcmp(BIOP_Header->objectKind_data,"dir")){ + } else if(!strcmp(BIOP_Header->objectKind_data,"dir")) { e = dsmcc_process_biop_directory(bs,BIOP_Header,dsmcc_overlord,0); - }else if(!strcmp(BIOP_Header->objectKind_data,"srg")){ + } else if(!strcmp(BIOP_Header->objectKind_data,"srg")) { e = dsmcc_process_biop_directory(bs,BIOP_Header,dsmcc_overlord,1); - if(e == GF_OK){ + if(e == GF_OK) { dsmcc_overlord->Got_ServiceGateway = 1; } - }else if(!strcmp(BIOP_Header->objectKind_data,"str")){ + } else if(!strcmp(BIOP_Header->objectKind_data,"str")) { dsmcc_process_biop_stream_message(bs,BIOP_Header,ServiceGateway); - }else if(!strcmp(BIOP_Header->objectKind_data,"ste")){ + } else if(!strcmp(BIOP_Header->objectKind_data,"ste")) { dsmcc_process_biop_stream_event(bs,BIOP_Header,ServiceGateway); - }else{ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported BIOP Message, abording process \n")); + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported BIOP Message, abording process \n")); } } byte_shift = (u32)(gf_bs_get_position(bs)); - if((e || !BIOP_Header) && (byte_shift < data_size)){ + if((e || !BIOP_Header) && (byte_shift < data_size)) { /* Error inside the data. Read next byte until a new "BIOP" is found or data_size is reached */ gf_bs_read_int(bs,8); Error = 1; } - if(BIOP_Header){ + if(BIOP_Header) { dsmcc_free_biop_header(BIOP_Header); } - + } - if(Error){ + if(Error) { return GF_CORRUPTED_DATA; } return GF_OK; } -static GF_M2TS_DSMCC_BIOP_HEADER* dsmcc_process_biop_header(GF_BitStream* bs){ - +static GF_M2TS_DSMCC_BIOP_HEADER* dsmcc_process_biop_header(GF_BitStream* bs) { + GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header; GF_SAFEALLOC(BIOP_Header,GF_M2TS_DSMCC_BIOP_HEADER); BIOP_Header->magic = gf_bs_read_int(bs,32); - if(BIOP_Header->magic != 0x42494F50){ + if(BIOP_Header->magic != 0x42494F50) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Wrong BIOP Header, abording process \n")); return NULL; } @@ -941,11 +941,11 @@ static GF_M2TS_DSMCC_BIOP_HEADER* dsmcc_process_biop_header(GF_BitStream* bs){ BIOP_Header->message_type = gf_bs_read_int(bs,8); BIOP_Header->message_size = gf_bs_read_int(bs,32); BIOP_Header->objectKey_length = gf_bs_read_int(bs,8); - if(BIOP_Header->objectKey_length){ + if(BIOP_Header->objectKey_length) { BIOP_Header->objectKey_data = gf_bs_read_int(bs,BIOP_Header->objectKey_length*8); } BIOP_Header->objectKind_length = gf_bs_read_int(bs,32); - if(BIOP_Header->objectKind_length){ + if(BIOP_Header->objectKind_length) { BIOP_Header->objectKind_data = (char*)gf_calloc(BIOP_Header->objectKind_length,sizeof(char)); gf_bs_read_data(bs,BIOP_Header->objectKind_data,(u32)(BIOP_Header->objectKind_length)); } @@ -954,9 +954,9 @@ static GF_M2TS_DSMCC_BIOP_HEADER* dsmcc_process_biop_header(GF_BitStream* bs){ return BIOP_Header; } -static GF_Err dsmcc_process_biop_file(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_OVERLORD*dsmcc_overlord,u16 moduleId,u32 downloadId){ +static GF_Err dsmcc_process_biop_file(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_OVERLORD*dsmcc_overlord,u16 moduleId,u32 downloadId) { - u32 nb_desc,descr_size; + u32 nb_desc,descr_size; GF_M2TS_DSMCC_BIOP_FILE* BIOP_File; GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway; GF_M2TS_DSMCC_FILE* File; @@ -967,73 +967,73 @@ static GF_Err dsmcc_process_biop_file(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER ServiceGateway = dsmcc_overlord->ServiceGateway; - BIOP_File->Header = BIOP_Header; - BIOP_File->ContentSize = gf_bs_read_int(bs,64); + BIOP_File->Header = BIOP_Header; + BIOP_File->ContentSize = gf_bs_read_int(bs,64); descr_size = BIOP_File->Header->objectInfo_length-8; - if(descr_size){ + if(descr_size) { dsmcc_biop_descriptor(bs,BIOP_File->descriptor,descr_size); } - gf_bs_read_int(bs,(u32)(descr_size)); + gf_bs_read_int(bs,(u32)(descr_size)); nb_desc = gf_list_count(BIOP_File->descriptor); - while(nb_desc){ + while(nb_desc) { /* get the descriptor tag */ - descr_tag = (u8*)gf_list_get(BIOP_File->descriptor,0); + descr_tag = (u8*)gf_list_get(BIOP_File->descriptor,0); - switch(*descr_tag){ - case CONTENT_TYPE_DESCRIPTOR: - { - //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0); - } - default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); - break; - } - } + switch(*descr_tag) { + case CONTENT_TYPE_DESCRIPTOR: + { + //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0); + } + default: + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); + break; + } + } nb_desc--; } BIOP_File->serviceContextList_count = gf_bs_read_int(bs,8); - if(BIOP_File->serviceContextList_count){ + if(BIOP_File->serviceContextList_count) { BIOP_File->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_File->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); dsmcc_biop_get_context(bs,BIOP_File->ServiceContext,BIOP_File->serviceContextList_count); } BIOP_File->messageBody_length = gf_bs_read_int(bs,32); BIOP_File->content_length = gf_bs_read_int(bs,32); - if(BIOP_File->content_length){ + if(BIOP_File->content_length) { BIOP_File->content_byte = (char*)gf_calloc(BIOP_File->content_length,sizeof(char)); gf_bs_read_data(bs,BIOP_File->content_byte,(u32)(BIOP_File->content_length)); } GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("module_Id %d \n",moduleId)); - File = dsmcc_get_file(ServiceGateway->File,moduleId,downloadId,BIOP_File->Header->objectKey_data); - if(File){ + File = dsmcc_get_file(ServiceGateway->File,moduleId,downloadId,BIOP_File->Header->objectKey_data); + if(File) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Fichier: %s module_Id %d place :%d \n",File->Path,moduleId,File->objectKey_data)); pFile = fopen(File->Path,"wb"); - if (pFile!=NULL){ - gf_fwrite(BIOP_File->content_byte,1,BIOP_File->content_length ,pFile); + if (pFile!=NULL) { + gf_fwrite(BIOP_File->content_byte,1,BIOP_File->content_length ,pFile); fclose(pFile); GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Fichier créé \n\n")); - if(!strcmp(File->name,"index.html")){ + if(!strcmp(File->name,"index.html")) { dsmcc_overlord->get_index = 1; } } - }else{ + } else { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[DSMCC] File vould not be created\n")); } - dsmcc_free_biop_file(BIOP_File); + dsmcc_free_biop_file(BIOP_File); return GF_OK; } -static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_OVERLORD*dsmcc_overlord,Bool IsServiceGateway){ +static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_OVERLORD*dsmcc_overlord,Bool IsServiceGateway) { GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directory; GF_M2TS_DSMCC_DIR* Dir; @@ -1046,25 +1046,25 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H /* Get the Header */ BIOP_Directory->Header = BIOP_Header; - - if(BIOP_Directory->Header->objectInfo_length != 0x0){ + + if(BIOP_Directory->Header->objectInfo_length != 0x0) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] ObjectInfo_length value is not correct \n")); return GF_CORRUPTED_DATA; } - - if(IsServiceGateway){ - /* create a "dir" struct with no parent */ + + if(IsServiceGateway) { + /* create a "dir" struct with no parent */ Dir = (GF_M2TS_DSMCC_DIR*)ServiceGateway; ServiceGateway->objectKey_data = BIOP_Directory->Header->objectKey_data; - ServiceGateway->parent = NULL; + ServiceGateway->parent = NULL; ServiceGateway->name = (char*)gf_strdup(dsmcc_overlord->root_dir); - }else{ + } else { /* get the dir related to the payload */ - Dir = dsmcc_get_directory(ServiceGateway->Dir,BIOP_Directory->Header->objectKey_data); + Dir = dsmcc_get_directory(ServiceGateway->Dir,BIOP_Directory->Header->objectKey_data); } BIOP_Directory->serviceContextList_count = gf_bs_read_int(bs,8); - if(BIOP_Directory->serviceContextList_count){ + if(BIOP_Directory->serviceContextList_count) { BIOP_Directory->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_Directory->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); dsmcc_biop_get_context(bs,BIOP_Directory->ServiceContext,BIOP_Directory->serviceContextList_count); } @@ -1073,44 +1073,44 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H BIOP_Directory->Name = (GF_M2TS_DSMCC_BIOP_NAME*)gf_calloc(BIOP_Directory->bindings_count,sizeof(GF_M2TS_DSMCC_BIOP_NAME)); /* Get the linked files */ - for(i = 0; ibindings_count;i++){ + for(i = 0; ibindings_count; i++) { u32 descr_length,nb_desc,j; u8* descr_tag; GF_Err e; BIOP_Directory->Name[i].nameComponents_count = gf_bs_read_int(bs,8); BIOP_Directory->Name[i].id_length = gf_bs_read_int(bs,8); - if(BIOP_Directory->Name[i].id_length){ + if(BIOP_Directory->Name[i].id_length) { BIOP_Directory->Name[i].id_data = (char*)gf_calloc(BIOP_Directory->Name[i].id_length,sizeof(char)); gf_bs_read_data(bs,BIOP_Directory->Name[i].id_data,(u32)(BIOP_Directory->Name[i].id_length)); } BIOP_Directory->Name[i].kind_length = gf_bs_read_int(bs,8); - if(BIOP_Directory->Name[i].kind_length > 0x04){ + if(BIOP_Directory->Name[i].kind_length > 0x04) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] kind_length value is not valid\n")); return GF_CORRUPTED_DATA; } - if(BIOP_Directory->Name[i].kind_length){ + if(BIOP_Directory->Name[i].kind_length) { BIOP_Directory->Name[i].kind_data = (char*)gf_calloc(BIOP_Directory->Name[i].kind_length,sizeof(char)); gf_bs_read_data(bs,BIOP_Directory->Name[i].kind_data,(u32)(BIOP_Directory->Name[i].kind_length)); } - + BIOP_Directory->Name[i].BindingType = gf_bs_read_int(bs,8); /* IOR */ e = dsmcc_biop_get_ior(bs,&BIOP_Directory->Name[i].IOR); - if(e){ + if(e) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in IOR processing\n")); return GF_CORRUPTED_DATA; } BIOP_Directory->Name[i].objectInfo_length = gf_bs_read_int(bs,16); - if(!strcmp(BIOP_Directory->Name[i].kind_data,"fil")){ + if(!strcmp(BIOP_Directory->Name[i].kind_data,"fil")) { BIOP_Directory->Name[i].ContentSize = gf_bs_read_int(bs,64); descr_length = BIOP_Directory->Name[i].objectInfo_length - 8; - }else{ + } else { descr_length = BIOP_Directory->Name[i].objectInfo_length; } - if(descr_length){ + if(descr_length) { BIOP_Directory->Name[i].descriptor = gf_list_new(); dsmcc_biop_descriptor(bs,BIOP_Directory->Name[i].descriptor,descr_length); } @@ -1119,68 +1119,68 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H nb_desc = gf_list_count(BIOP_Directory->Name[i].descriptor); j = 0; - while(jName[i].descriptor ,0); + descr_tag = (u8*)gf_list_get(BIOP_Directory->Name[i].descriptor ,0); - switch(*descr_tag){ - case CONTENT_TYPE_DESCRIPTOR: - { - //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j); - } - default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); - break; - } - } + switch(*descr_tag) { + case CONTENT_TYPE_DESCRIPTOR: + { + //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j); + } + default: + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported descriptor Type \n")); + break; + } + } j++; } - - if(!strcmp(BIOP_Directory->Name[i].kind_data,"dir")){ - if(!dsmcc_check_element_validation(ServiceGateway->Dir,ServiceGateway->name,BIOP_Directory->Name[i])){ + + if(!strcmp(BIOP_Directory->Name[i].kind_data,"dir")) { + if(!dsmcc_check_element_validation(ServiceGateway->Dir,ServiceGateway->name,BIOP_Directory->Name[i])) { GF_Err e; GF_M2TS_DSMCC_DIR* Directory; - GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(BIOP_Directory->Name[i].IOR.taggedProfile,0); + GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(BIOP_Directory->Name[i].IOR.taggedProfile,0); GF_SAFEALLOC(Directory,GF_M2TS_DSMCC_DIR); Directory->name = (char*)gf_strdup(BIOP_Directory->Name[i].id_data); Directory->File = gf_list_new(); Directory->objectKey_data = taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data; Directory->downloadId = taggedProfile->BIOPProfileBody->ObjectLocation.carouselId; - Directory->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; + Directory->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; Directory->parent = Dir; Directory->Path = dsmcc_get_file_namepath(Dir,Directory->name); e = gf_mkdir(Directory->Path); - if(e){ + if(e) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the creation of the directory %s \n",Directory->Path)); } gf_list_add(ServiceGateway->Dir,Directory); } - }else if(!strcmp(BIOP_Directory->Name[i].kind_data,"fil")){ - if(!dsmcc_check_element_validation(ServiceGateway->File,ServiceGateway->name,BIOP_Directory->Name[i])){ + } else if(!strcmp(BIOP_Directory->Name[i].kind_data,"fil")) { + if(!dsmcc_check_element_validation(ServiceGateway->File,ServiceGateway->name,BIOP_Directory->Name[i])) { GF_M2TS_DSMCC_FILE* File; - GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(BIOP_Directory->Name[i].IOR.taggedProfile,0); + GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(BIOP_Directory->Name[i].IOR.taggedProfile,0); GF_SAFEALLOC(File,GF_M2TS_DSMCC_FILE); - File->name = (char*)gf_strdup(BIOP_Directory->Name[i].id_data); + File->name = (char*)gf_strdup(BIOP_Directory->Name[i].id_data); File->objectKey_data = taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data; File->downloadId = taggedProfile->BIOPProfileBody->ObjectLocation.carouselId; - File->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; + File->moduleId = taggedProfile->BIOPProfileBody->ObjectLocation.moduleId; File->parent = Dir; File->Path = dsmcc_get_file_namepath(Dir,File->name); gf_list_add(ServiceGateway->File,File); } - } + } } dsmcc_free_biop_directory(BIOP_Directory); - + return GF_OK; } -static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway){ +static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway) { - u32 i; + u32 i; GF_M2TS_DSMCC_BIOP_STREAM_EVENT* BIOP_StreamEvent; - //GF_M2TS_DSMCC_FILE* File; + //GF_M2TS_DSMCC_FILE* File; u32 eventdata; GF_SAFEALLOC(BIOP_StreamEvent,GF_M2TS_DSMCC_BIOP_STREAM_EVENT); @@ -1190,7 +1190,7 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO BIOP_StreamEvent->Header = BIOP_Header; /* Get Info */ BIOP_StreamEvent->Info.aDescription_length = gf_bs_read_int(bs,8); - if(BIOP_StreamEvent->Info.aDescription_length){ + if(BIOP_StreamEvent->Info.aDescription_length) { BIOP_StreamEvent->Info.aDescription_bytes = (char*)gf_calloc(BIOP_StreamEvent->Info.aDescription_length,sizeof(char)); gf_bs_read_data(bs,BIOP_StreamEvent->Info.aDescription_bytes,(u8)(BIOP_StreamEvent->Info.aDescription_length)); } @@ -1202,12 +1202,12 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO /* Event List */ BIOP_StreamEvent->eventNames_count = gf_bs_read_int(bs,16); - if(BIOP_StreamEvent->eventNames_count){ + if(BIOP_StreamEvent->eventNames_count) { BIOP_StreamEvent->EventList = (GF_M2TS_DSMCC_BIOP_EVENT_LIST*)gf_calloc(BIOP_StreamEvent->eventNames_count,sizeof(GF_M2TS_DSMCC_BIOP_EVENT_LIST)); - for(i=0;ieventNames_count;i++){ + for(i=0; ieventNames_count; i++) { BIOP_StreamEvent->EventList[i].eventName_length = gf_bs_read_int(bs,8); eventdata += BIOP_StreamEvent->EventList[i].eventName_length; - if(BIOP_StreamEvent->EventList[i].eventName_length){ + if(BIOP_StreamEvent->EventList[i].eventName_length) { BIOP_StreamEvent->EventList[i].eventName_data_byte = (char*)gf_calloc(BIOP_StreamEvent->EventList[i].eventName_length,sizeof(char)); gf_bs_read_data(bs,BIOP_StreamEvent->EventList[i].eventName_data_byte,(u8)(BIOP_StreamEvent->EventList[i].eventName_length)); } @@ -1218,28 +1218,28 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO if (BIOP_StreamEvent->serviceContextList_count) { BIOP_StreamEvent->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamEvent->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); dsmcc_biop_get_context(bs,BIOP_StreamEvent->ServiceContext,BIOP_StreamEvent->serviceContextList_count); - } - + } + BIOP_StreamEvent->messageBody_length = gf_bs_read_int(bs,32); BIOP_StreamEvent->taps_count = gf_bs_read_int(bs,8); BIOP_StreamEvent->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(BIOP_StreamEvent->taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for (i=0;itaps_count;i++) { - BIOP_StreamEvent->Taps[i].id = gf_bs_read_int(bs,16); - BIOP_StreamEvent->Taps[i].use = gf_bs_read_int(bs,16); + for (i=0; itaps_count; i++) { + BIOP_StreamEvent->Taps[i].id = gf_bs_read_int(bs,16); + BIOP_StreamEvent->Taps[i].use = gf_bs_read_int(bs,16); BIOP_StreamEvent->Taps[i].assocTag = gf_bs_read_int(bs,16); BIOP_StreamEvent->Taps[i].selector_length = gf_bs_read_int(bs,8); - if(BIOP_StreamEvent->Taps[i].selector_length != 0x00){ + if(BIOP_StreamEvent->Taps[i].selector_length != 0x00) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Stream Event : selector_length has a wrong value, abording the processing \n")); return GF_CORRUPTED_DATA; - } + } } BIOP_StreamEvent->eventIds_count = gf_bs_read_int(bs,8); - if(BIOP_StreamEvent->eventIds_count != BIOP_StreamEvent->eventNames_count){ + if(BIOP_StreamEvent->eventIds_count != BIOP_StreamEvent->eventNames_count) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Stream Event : eventIds_count has a wrong value, abording the processing \n")); return GF_CORRUPTED_DATA; - }else if(BIOP_StreamEvent->eventIds_count){ + } else if(BIOP_StreamEvent->eventIds_count) { BIOP_StreamEvent->eventId = (u16*)gf_calloc(BIOP_StreamEvent->eventIds_count,sizeof(u16)); - for(i =0;ieventIds_count;i++){ + for(i =0; ieventIds_count; i++) { BIOP_StreamEvent->eventId[i] = gf_bs_read_int(bs,16); } } @@ -1249,9 +1249,9 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO return GF_OK; } -static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway){ +static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway) { - u32 i; + u32 i; GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage; GF_SAFEALLOC(BIOP_StreamMessage,GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE); @@ -1259,7 +1259,7 @@ static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_B BIOP_StreamMessage->Header = BIOP_Header; /* Get Info */ BIOP_StreamMessage->Info.aDescription_length = gf_bs_read_int(bs,8); - if(BIOP_StreamMessage->Info.aDescription_length){ + if(BIOP_StreamMessage->Info.aDescription_length) { BIOP_StreamMessage->Info.aDescription_bytes = (char*)gf_calloc(BIOP_StreamMessage->Info.aDescription_length,sizeof(char)); gf_bs_read_data(bs,BIOP_StreamMessage->Info.aDescription_bytes,(u8)(BIOP_StreamMessage->Info.aDescription_length)); } @@ -1268,25 +1268,25 @@ static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_B BIOP_StreamMessage->Info.audio = gf_bs_read_int(bs,8); BIOP_StreamMessage->Info.video = gf_bs_read_int(bs,8); BIOP_StreamMessage->Info.data = gf_bs_read_int(bs,8); - + BIOP_StreamMessage->serviceContextList_count = gf_bs_read_int(bs,8); - if(BIOP_StreamMessage->serviceContextList_count){ + if(BIOP_StreamMessage->serviceContextList_count) { BIOP_StreamMessage->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamMessage->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); dsmcc_biop_get_context(bs,BIOP_StreamMessage->ServiceContext,BIOP_StreamMessage->serviceContextList_count); } - + BIOP_StreamMessage->messageBody_length = gf_bs_read_int(bs,32); BIOP_StreamMessage->taps_count = gf_bs_read_int(bs,8); BIOP_StreamMessage->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(BIOP_StreamMessage->taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for(i=0;itaps_count;i++){ - BIOP_StreamMessage->Taps[i].id = gf_bs_read_int(bs,16); - BIOP_StreamMessage->Taps[i].use = gf_bs_read_int(bs,16); + for(i=0; itaps_count; i++) { + BIOP_StreamMessage->Taps[i].id = gf_bs_read_int(bs,16); + BIOP_StreamMessage->Taps[i].use = gf_bs_read_int(bs,16); BIOP_StreamMessage->Taps[i].assocTag = gf_bs_read_int(bs,16); BIOP_StreamMessage->Taps[i].selector_length = gf_bs_read_int(bs,8); - if(BIOP_StreamMessage->Taps[i].selector_length != 0x00){ + if(BIOP_StreamMessage->Taps[i].selector_length != 0x00) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Stream Event : selector_length has a wrong value, abording the processing \n")); return GF_CORRUPTED_DATA; - } + } } dsmcc_free_biop_stream_message(BIOP_StreamMessage); @@ -1317,63 +1317,63 @@ static GF_M2TS_DSMCC_MODULE* dsmcc_create_module(GF_M2TS_DSMCC_OVERLORD* dsmcc_o return dsmcc_module; } -static void dsmcc_biop_descriptor(GF_BitStream* bs,GF_List* list,u32 size){ +static void dsmcc_biop_descriptor(GF_BitStream* bs,GF_List* list,u32 size) { u8 descr_tag; u32 data_shift,start_pos; start_pos = (u32)(gf_bs_get_position(bs)); - data_shift = 0; - - while(size > data_shift){ - descr_tag = gf_bs_read_int(bs,8); - - switch(descr_tag){ - - case CACHING_PRIORITY_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr; - GF_SAFEALLOC(CachingPriorityDescr,GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR); - CachingPriorityDescr->descriptor_tag = descr_tag; - CachingPriorityDescr->descriptor_length = gf_bs_read_int(bs,8); - CachingPriorityDescr->priority_value = gf_bs_read_int(bs,8); - CachingPriorityDescr->transparency_level = gf_bs_read_int(bs,8); - gf_list_add(list,CachingPriorityDescr); - break; - } - case COMPRESSED_MODULE_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr; - GF_SAFEALLOC(CompModuleDescr,GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR); - CompModuleDescr->descriptor_tag = descr_tag; - CompModuleDescr->descriptor_length = gf_bs_read_int(bs,8); - CompModuleDescr->compression_method = gf_bs_read_int(bs,8); - /* if CompModuleDescr->compression_method least significant nibble is eq to 0x08, the terminal shall support the Deflate compression algorithm (GZIP) */ - CompModuleDescr->original_size = gf_bs_read_int(bs,32); - gf_list_add(list,CompModuleDescr); - break; + data_shift = 0; - } - case CONTENT_TYPE_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr; - GF_SAFEALLOC(ContentTypeDescr,GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR); - ContentTypeDescr->descriptor_tag = descr_tag; - ContentTypeDescr->descriptor_length = gf_bs_read_int(bs,8); - ContentTypeDescr->content_type_data_byte = (char*)gf_calloc(ContentTypeDescr->descriptor_length,sizeof(char)); - gf_bs_read_data(bs,ContentTypeDescr->content_type_data_byte,(u32)(ContentTypeDescr->descriptor_length)); - gf_list_add(list,ContentTypeDescr); - } - default: - { - u32 size; - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported Descriptor Type \n")); - /* byte shift - in descriptors length is on thr second byte*/ - size = gf_bs_read_int(bs,8); - gf_bs_read_int(bs,8*size); - break; - } - } - data_shift = (u32)(gf_bs_get_position(bs)) - start_pos; + while(size > data_shift) { + descr_tag = gf_bs_read_int(bs,8); + + switch(descr_tag) { + + case CACHING_PRIORITY_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr; + GF_SAFEALLOC(CachingPriorityDescr,GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR); + CachingPriorityDescr->descriptor_tag = descr_tag; + CachingPriorityDescr->descriptor_length = gf_bs_read_int(bs,8); + CachingPriorityDescr->priority_value = gf_bs_read_int(bs,8); + CachingPriorityDescr->transparency_level = gf_bs_read_int(bs,8); + gf_list_add(list,CachingPriorityDescr); + break; + } + case COMPRESSED_MODULE_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr; + GF_SAFEALLOC(CompModuleDescr,GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR); + CompModuleDescr->descriptor_tag = descr_tag; + CompModuleDescr->descriptor_length = gf_bs_read_int(bs,8); + CompModuleDescr->compression_method = gf_bs_read_int(bs,8); + /* if CompModuleDescr->compression_method least significant nibble is eq to 0x08, the terminal shall support the Deflate compression algorithm (GZIP) */ + CompModuleDescr->original_size = gf_bs_read_int(bs,32); + gf_list_add(list,CompModuleDescr); + break; + + } + case CONTENT_TYPE_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr; + GF_SAFEALLOC(ContentTypeDescr,GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR); + ContentTypeDescr->descriptor_tag = descr_tag; + ContentTypeDescr->descriptor_length = gf_bs_read_int(bs,8); + ContentTypeDescr->content_type_data_byte = (char*)gf_calloc(ContentTypeDescr->descriptor_length,sizeof(char)); + gf_bs_read_data(bs,ContentTypeDescr->content_type_data_byte,(u32)(ContentTypeDescr->descriptor_length)); + gf_list_add(list,ContentTypeDescr); + } + default: + { + u32 size; + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported Descriptor Type \n")); + /* byte shift - in descriptors length is on thr second byte*/ + size = gf_bs_read_int(bs,8); + gf_bs_read_int(bs,8*size); + break; + } + } + data_shift = (u32)(gf_bs_get_position(bs)) - start_pos; } } @@ -1381,10 +1381,10 @@ static void dsmcc_biop_get_context(GF_BitStream* bs,GF_M2TS_DSMCC_SERVICE_CONTEX { u32 i; - for(i=0;itype_id_length = gf_bs_read_int(bs,32); - if(IOR->type_id_length > 0xA){ + if(IOR->type_id_length > 0xA) { //return GF_CORRUPTED_DATA; } IOR->type_id_byte = (char*)gf_calloc(IOR->type_id_length,sizeof(char)); gf_bs_read_data(bs,IOR->type_id_byte,(u32)(IOR->type_id_length)); IOR->taggedProfiles_count = gf_bs_read_int(bs,32); IOR->taggedProfile = gf_list_new(); - for(i = 0; i < IOR->taggedProfiles_count;i++){ + for(i = 0; i < IOR->taggedProfiles_count; i++) { GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile; GF_SAFEALLOC(taggedProfile,GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE); gf_list_add(IOR->taggedProfile,taggedProfile); taggedProfile->profileId_tag = gf_bs_read_int(bs,32); taggedProfile->profile_data_length = gf_bs_read_int(bs,32); taggedProfile->profile_data_byte_order = gf_bs_read_int(bs,8); - if(taggedProfile->profile_data_byte_order != 0x00){ + if(taggedProfile->profile_data_byte_order != 0x00) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in IOR processing : profile data byte order has a wrong value, abording the processing \n")); return GF_CORRUPTED_DATA; } taggedProfile->lite_component_count = gf_bs_read_int(bs,8); left_lite_component = taggedProfile->lite_component_count; - switch(taggedProfile->profileId_tag){ - case TAG_BIOP: - { - /* Object Location */ - u32 j; - GF_SAFEALLOC(taggedProfile->BIOPProfileBody,GF_M2TS_DSMCC_BIOP_PROFILE_BODY); - taggedProfile->BIOPProfileBody->ObjectLocation.componentId_tag = gf_bs_read_int(bs,32); - if(taggedProfile->BIOPProfileBody->ObjectLocation.componentId_tag != 0x49534F50){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : component tag has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ObjectLocation.component_data_length = gf_bs_read_int(bs,8); - taggedProfile->BIOPProfileBody->ObjectLocation.carouselId = gf_bs_read_int(bs,32); - taggedProfile->BIOPProfileBody->ObjectLocation.moduleId = gf_bs_read_int(bs,16); - taggedProfile->BIOPProfileBody->ObjectLocation.version_major = gf_bs_read_int(bs,8); - if(taggedProfile->BIOPProfileBody->ObjectLocation.version_major != 0x01){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : version major has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ObjectLocation.version_minor = gf_bs_read_int(bs,8); - if(taggedProfile->BIOPProfileBody->ObjectLocation.version_minor != 0x00){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : version minor has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length = gf_bs_read_int(bs,8); - if(taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length){ - taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data = gf_bs_read_int(bs,taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length*8); - } - /* ConnBinder */ - - taggedProfile->BIOPProfileBody->ConnBinder.componentId_tag = gf_bs_read_int(bs,32); - if(taggedProfile->BIOPProfileBody->ConnBinder.componentId_tag != 0x49534F40){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : componentId tag has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ConnBinder.component_data_length = gf_bs_read_int(bs,8); - taggedProfile->BIOPProfileBody->ConnBinder.taps_count = gf_bs_read_int(bs,8); - taggedProfile->BIOPProfileBody->ConnBinder.Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(taggedProfile->BIOPProfileBody->ConnBinder.taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for(j=0;jBIOPProfileBody->ConnBinder.taps_count;j++){ - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].id = gf_bs_read_int(bs,16); - if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].id != 0x00){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : id has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].use = gf_bs_read_int(bs,16); - if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].use != 0x016){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : use has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].assocTag = gf_bs_read_int(bs,16); - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_length = gf_bs_read_int(bs,8); - if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_length != 0x0A){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : selector_length has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_type = gf_bs_read_int(bs,16); - if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_type != 0x001){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : selector_type has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].transactionId = gf_bs_read_int(bs,32); - taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].timeout = gf_bs_read_int(bs,32); - } - if(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18 != 0){ - taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte = (char*)gf_calloc(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18,sizeof(char)); - gf_bs_read_data(bs,taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte,(u32)(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18)); - } - left_lite_component = left_lite_component - 2; - break; - } - case TAG_LITE_OPTIONS: - { - /* Service Location */ - u32 j; - GF_SAFEALLOC(taggedProfile->ServiceLocation,GF_M2TS_DSMCC_BIOP_SERVICE_LOCATION); - taggedProfile->ServiceLocation->componentId_tag = gf_bs_read_int(bs,32); - if(taggedProfile->ServiceLocation->componentId_tag != 0x49534F46){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Location : component tag has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->ServiceLocation->component_data_length = gf_bs_read_int(bs,8); - taggedProfile->ServiceLocation->serviceDomain_length = gf_bs_read_int(bs,8); - if(taggedProfile->ServiceLocation->serviceDomain_length != 0x14){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Location : Service Domain Length tag has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->ServiceLocation->serviceDomain_data.AFI = gf_bs_read_int(bs,8); - taggedProfile->ServiceLocation->serviceDomain_data.type = gf_bs_read_int(bs,8); - taggedProfile->ServiceLocation->serviceDomain_data.carouselId = gf_bs_read_int(bs,32); - taggedProfile->ServiceLocation->serviceDomain_data.specifierType = gf_bs_read_int(bs,8); - taggedProfile->ServiceLocation->serviceDomain_data.specifierData = gf_bs_read_int(bs,24); - taggedProfile->ServiceLocation->serviceDomain_data.transport_stream_id = gf_bs_read_int(bs,16); - taggedProfile->ServiceLocation->serviceDomain_data.original_network_id = gf_bs_read_int(bs,16); - taggedProfile->ServiceLocation->serviceDomain_data.service_id = gf_bs_read_int(bs,16); - taggedProfile->ServiceLocation->serviceDomain_data.reserved = gf_bs_read_int(bs,32); - if(taggedProfile->ServiceLocation->serviceDomain_data.reserved != 0xFFFFFFFF){ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Domain Data : reserved has a wrong value, abording the processing \n")); - return GF_CORRUPTED_DATA; - } - taggedProfile->ServiceLocation->nameComponents_count = gf_bs_read_int(bs,32); - taggedProfile->ServiceLocation->NameComponent = (GF_M2TS_DSMCC_BIOP_NAME_COMPONENT*)gf_calloc(taggedProfile->ServiceLocation->nameComponents_count,sizeof(GF_M2TS_DSMCC_BIOP_NAME_COMPONENT)); - for(j = 0; j < taggedProfile->ServiceLocation->nameComponents_count; j++){ - taggedProfile->ServiceLocation->NameComponent[j].id_length = gf_bs_read_int(bs,32); - if(taggedProfile->ServiceLocation->NameComponent[j].id_length != 0){ - taggedProfile->ServiceLocation->NameComponent[j].id_data = (char*)gf_calloc(taggedProfile->ServiceLocation->NameComponent[j].id_length,sizeof(char)); - gf_bs_read_data(bs,taggedProfile->ServiceLocation->NameComponent[i].id_data,(u32)(taggedProfile->ServiceLocation->NameComponent[j].id_length)); - } - taggedProfile->ServiceLocation->NameComponent[j].kind_length = gf_bs_read_int(bs,32); - if(taggedProfile->ServiceLocation->NameComponent[j].kind_length != 0){ - taggedProfile->ServiceLocation->NameComponent[j].kind_data = (char*)gf_calloc(taggedProfile->ServiceLocation->NameComponent[j].kind_length,sizeof(char)); - gf_bs_read_data(bs,taggedProfile->ServiceLocation->NameComponent[j].kind_data,(u32)(taggedProfile->ServiceLocation->NameComponent[j].kind_length)); - } - } - taggedProfile->ServiceLocation->initialContext_length = gf_bs_read_int(bs,8); - if(taggedProfile->ServiceLocation->initialContext_length != 0){ - taggedProfile->ServiceLocation->InitialContext_data_byte = (char*)gf_calloc(taggedProfile->ServiceLocation->initialContext_length,sizeof(char)); - gf_bs_read_data(bs,taggedProfile->ServiceLocation->InitialContext_data_byte,(u32)(taggedProfile->ServiceLocation->initialContext_length)); - } - left_lite_component = left_lite_component - 1; - break; - } - default: - { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported Service gateway profile tag \n")); - break; - } + switch(taggedProfile->profileId_tag) { + case TAG_BIOP: + { + /* Object Location */ + u32 j; + GF_SAFEALLOC(taggedProfile->BIOPProfileBody,GF_M2TS_DSMCC_BIOP_PROFILE_BODY); + taggedProfile->BIOPProfileBody->ObjectLocation.componentId_tag = gf_bs_read_int(bs,32); + if(taggedProfile->BIOPProfileBody->ObjectLocation.componentId_tag != 0x49534F50) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : component tag has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ObjectLocation.component_data_length = gf_bs_read_int(bs,8); + taggedProfile->BIOPProfileBody->ObjectLocation.carouselId = gf_bs_read_int(bs,32); + taggedProfile->BIOPProfileBody->ObjectLocation.moduleId = gf_bs_read_int(bs,16); + taggedProfile->BIOPProfileBody->ObjectLocation.version_major = gf_bs_read_int(bs,8); + if(taggedProfile->BIOPProfileBody->ObjectLocation.version_major != 0x01) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : version major has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ObjectLocation.version_minor = gf_bs_read_int(bs,8); + if(taggedProfile->BIOPProfileBody->ObjectLocation.version_minor != 0x00) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Profile Body : version minor has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length = gf_bs_read_int(bs,8); + if(taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length) { + taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data = gf_bs_read_int(bs,taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_length*8); + } + /* ConnBinder */ + + taggedProfile->BIOPProfileBody->ConnBinder.componentId_tag = gf_bs_read_int(bs,32); + if(taggedProfile->BIOPProfileBody->ConnBinder.componentId_tag != 0x49534F40) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : componentId tag has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ConnBinder.component_data_length = gf_bs_read_int(bs,8); + taggedProfile->BIOPProfileBody->ConnBinder.taps_count = gf_bs_read_int(bs,8); + taggedProfile->BIOPProfileBody->ConnBinder.Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(taggedProfile->BIOPProfileBody->ConnBinder.taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); + for(j=0; jBIOPProfileBody->ConnBinder.taps_count; j++) { + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].id = gf_bs_read_int(bs,16); + if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].id != 0x00) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : id has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].use = gf_bs_read_int(bs,16); + if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].use != 0x016) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : use has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].assocTag = gf_bs_read_int(bs,16); + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_length = gf_bs_read_int(bs,8); + if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_length != 0x0A) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : selector_length has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_type = gf_bs_read_int(bs,16); + if(taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].selector_type != 0x001) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in ConnBinder : selector_type has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].transactionId = gf_bs_read_int(bs,32); + taggedProfile->BIOPProfileBody->ConnBinder.Taps[i].timeout = gf_bs_read_int(bs,32); + } + if(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18 != 0) { + taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte = (char*)gf_calloc(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18,sizeof(char)); + gf_bs_read_data(bs,taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte,(u32)(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18)); + } + left_lite_component = left_lite_component - 2; + break; + } + case TAG_LITE_OPTIONS: + { + /* Service Location */ + u32 j; + GF_SAFEALLOC(taggedProfile->ServiceLocation,GF_M2TS_DSMCC_BIOP_SERVICE_LOCATION); + taggedProfile->ServiceLocation->componentId_tag = gf_bs_read_int(bs,32); + if(taggedProfile->ServiceLocation->componentId_tag != 0x49534F46) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Location : component tag has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->ServiceLocation->component_data_length = gf_bs_read_int(bs,8); + taggedProfile->ServiceLocation->serviceDomain_length = gf_bs_read_int(bs,8); + if(taggedProfile->ServiceLocation->serviceDomain_length != 0x14) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Location : Service Domain Length tag has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->ServiceLocation->serviceDomain_data.AFI = gf_bs_read_int(bs,8); + taggedProfile->ServiceLocation->serviceDomain_data.type = gf_bs_read_int(bs,8); + taggedProfile->ServiceLocation->serviceDomain_data.carouselId = gf_bs_read_int(bs,32); + taggedProfile->ServiceLocation->serviceDomain_data.specifierType = gf_bs_read_int(bs,8); + taggedProfile->ServiceLocation->serviceDomain_data.specifierData = gf_bs_read_int(bs,24); + taggedProfile->ServiceLocation->serviceDomain_data.transport_stream_id = gf_bs_read_int(bs,16); + taggedProfile->ServiceLocation->serviceDomain_data.original_network_id = gf_bs_read_int(bs,16); + taggedProfile->ServiceLocation->serviceDomain_data.service_id = gf_bs_read_int(bs,16); + taggedProfile->ServiceLocation->serviceDomain_data.reserved = gf_bs_read_int(bs,32); + if(taggedProfile->ServiceLocation->serviceDomain_data.reserved != 0xFFFFFFFF) { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error in Service Domain Data : reserved has a wrong value, abording the processing \n")); + return GF_CORRUPTED_DATA; + } + taggedProfile->ServiceLocation->nameComponents_count = gf_bs_read_int(bs,32); + taggedProfile->ServiceLocation->NameComponent = (GF_M2TS_DSMCC_BIOP_NAME_COMPONENT*)gf_calloc(taggedProfile->ServiceLocation->nameComponents_count,sizeof(GF_M2TS_DSMCC_BIOP_NAME_COMPONENT)); + for(j = 0; j < taggedProfile->ServiceLocation->nameComponents_count; j++) { + taggedProfile->ServiceLocation->NameComponent[j].id_length = gf_bs_read_int(bs,32); + if(taggedProfile->ServiceLocation->NameComponent[j].id_length != 0) { + taggedProfile->ServiceLocation->NameComponent[j].id_data = (char*)gf_calloc(taggedProfile->ServiceLocation->NameComponent[j].id_length,sizeof(char)); + gf_bs_read_data(bs,taggedProfile->ServiceLocation->NameComponent[i].id_data,(u32)(taggedProfile->ServiceLocation->NameComponent[j].id_length)); + } + taggedProfile->ServiceLocation->NameComponent[j].kind_length = gf_bs_read_int(bs,32); + if(taggedProfile->ServiceLocation->NameComponent[j].kind_length != 0) { + taggedProfile->ServiceLocation->NameComponent[j].kind_data = (char*)gf_calloc(taggedProfile->ServiceLocation->NameComponent[j].kind_length,sizeof(char)); + gf_bs_read_data(bs,taggedProfile->ServiceLocation->NameComponent[j].kind_data,(u32)(taggedProfile->ServiceLocation->NameComponent[j].kind_length)); + } + } + taggedProfile->ServiceLocation->initialContext_length = gf_bs_read_int(bs,8); + if(taggedProfile->ServiceLocation->initialContext_length != 0) { + taggedProfile->ServiceLocation->InitialContext_data_byte = (char*)gf_calloc(taggedProfile->ServiceLocation->initialContext_length,sizeof(char)); + gf_bs_read_data(bs,taggedProfile->ServiceLocation->InitialContext_data_byte,(u32)(taggedProfile->ServiceLocation->initialContext_length)); + } + left_lite_component = left_lite_component - 1; + break; + } + default: + { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Unsupported Service gateway profile tag \n")); + break; + } } taggedProfile->LiteComponent = (GF_M2TS_DSMCC_BIOP_LITE_COMPONENT*)gf_calloc(left_lite_component,sizeof(GF_M2TS_DSMCC_BIOP_LITE_COMPONENT)); - for(j = 0; jLiteComponent[j].componentId_tag = gf_bs_read_int(bs,32); + for(j = 0; jLiteComponent[j].componentId_tag = gf_bs_read_int(bs,32); taggedProfile->LiteComponent[j].component_data_length = gf_bs_read_int(bs,8); - if(taggedProfile->LiteComponent[j].component_data_length != 0){ + if(taggedProfile->LiteComponent[j].component_data_length != 0) { taggedProfile->LiteComponent[j].component_data_byte = (char*)gf_calloc(taggedProfile->ServiceLocation->initialContext_length,sizeof(char)); gf_bs_read_data(bs,taggedProfile->LiteComponent[j].component_data_byte,(u32)(taggedProfile->LiteComponent[j].component_data_length)); - } + } } } @@ -1562,35 +1562,35 @@ static GF_Err dsmcc_check_element_validation(GF_List* List,char* Parent_name,GF_ { u32 nb_elt,i; - GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(Name.IOR.taggedProfile,0); + GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = (GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE*)gf_list_get(Name.IOR.taggedProfile,0); nb_elt = gf_list_count(List); - - for(i = 0; i < nb_elt;i++){ + + for(i = 0; i < nb_elt; i++) { GF_M2TS_DSMCC_FILE* File = (GF_M2TS_DSMCC_FILE*)gf_list_get(List,i); if(!strcmp(File->name,Name.id_data) && !strcmp(File->parent,Parent_name) && - (File->objectKey_data == taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data) && File->moduleId == taggedProfile->BIOPProfileBody->ObjectLocation.moduleId){ + (File->objectKey_data == taggedProfile->BIOPProfileBody->ObjectLocation.objectKey_data) && File->moduleId == taggedProfile->BIOPProfileBody->ObjectLocation.moduleId) { /* File or Dir already received */ - return GF_BAD_PARAM; + return GF_BAD_PARAM; } } return GF_OK; } -static GF_M2TS_DSMCC_DIR* dsmcc_get_directory(GF_List* List, u32 objectKey_data){ +static GF_M2TS_DSMCC_DIR* dsmcc_get_directory(GF_List* List, u32 objectKey_data) { u32 nb_elt,i; nb_elt = gf_list_count(List); - for(i = 0;iobjectKey_data == objectKey_data){ + if(Dir->objectKey_data == objectKey_data) { return Dir; } - if(gf_list_count(Dir->Dir)){ + if(gf_list_count(Dir->Dir)) { TmpDir = dsmcc_get_directory(Dir->Dir,objectKey_data); - if(TmpDir){ + if(TmpDir) { return TmpDir; } } @@ -1598,25 +1598,25 @@ static GF_M2TS_DSMCC_DIR* dsmcc_get_directory(GF_List* List, u32 objectKey_data) return NULL; } -static GF_M2TS_DSMCC_FILE* dsmcc_get_file(GF_List* ServiceGateway_List, u16 moduleId,u32 downloadId,u32 objectKey_data){ +static GF_M2TS_DSMCC_FILE* dsmcc_get_file(GF_List* ServiceGateway_List, u16 moduleId,u32 downloadId,u32 objectKey_data) { u32 nb_elt,i; nb_elt = gf_list_count(ServiceGateway_List); - for(i = 0;iobjectKey_data == objectKey_data) && File->moduleId == moduleId && File->downloadId == downloadId){ + if((File->objectKey_data == objectKey_data) && File->moduleId == moduleId && File->downloadId == downloadId) { return File; - } + } } return NULL; } -static char* dsmcc_get_file_namepath(GF_M2TS_DSMCC_DIR* Dir,char* name){ +static char* dsmcc_get_file_namepath(GF_M2TS_DSMCC_DIR* Dir,char* name) { char* Path; GF_M2TS_DSMCC_DIR* directory = Dir; Path = gf_calloc(512,sizeof(char)); sprintf(Path,"%s%c%s",directory->name,GF_PATH_SEPARATOR,name); - while(directory->parent != NULL){ + while(directory->parent != NULL) { GF_M2TS_DSMCC_DIR* tempdir; char* tempPath = gf_strdup(Path); tempdir = (GF_M2TS_DSMCC_DIR*)directory->parent; @@ -1632,43 +1632,43 @@ static char* dsmcc_get_file_namepath(GF_M2TS_DSMCC_DIR* Dir,char* name){ static void dsmcc_delete_module(GF_M2TS_DSMCC_MODULE* module) { - if(module->buffer){ + if(module->buffer) { gf_free(module->buffer); } gf_free(module); } -static void dmscc_delete_file(GF_M2TS_DSMCC_FILE* File){ +static void dmscc_delete_file(GF_M2TS_DSMCC_FILE* File) { - if(File->name){ + if(File->name) { gf_free(File->name); } - if(File->Path){ + if(File->Path) { gf_free(File->Path); } } -static void dmscc_delete_dir(GF_M2TS_DSMCC_DIR* Dir){ +static void dmscc_delete_dir(GF_M2TS_DSMCC_DIR* Dir) { u32 nb_file, nb_dir,i; - if(Dir->name){ + if(Dir->name) { gf_free(Dir->name); } - if(Dir->Path){ + if(Dir->Path) { gf_free(Dir->Path); } nb_file = gf_list_count(Dir->File); - for(i=0;iFile,i); dmscc_delete_file(File); } gf_list_del(Dir->File); nb_dir = gf_list_count(Dir->Dir); - for(i=0;iDir,i); dmscc_delete_dir(Sub_Dir); } @@ -1676,22 +1676,22 @@ static void dmscc_delete_dir(GF_M2TS_DSMCC_DIR* Dir){ gf_free(Dir); } -static void dmscc_delete_servicegateway(GF_M2TS_DSMCC_SERVICE_GATEWAY* Servicegateway){ +static void dmscc_delete_servicegateway(GF_M2TS_DSMCC_SERVICE_GATEWAY* Servicegateway) { u32 nb_file, nb_dir,i; - if(Servicegateway->name){ + if(Servicegateway->name) { gf_free(Servicegateway->name); } nb_file = gf_list_count(Servicegateway->File); - for(i=0;iFile,i); dmscc_delete_file(File); } gf_list_del(Servicegateway->File); nb_dir = gf_list_count(Servicegateway->Dir); - for(i=0;iDir,i); dmscc_delete_dir(Dir); } @@ -1699,39 +1699,39 @@ static void dmscc_delete_servicegateway(GF_M2TS_DSMCC_SERVICE_GATEWAY* Servicega gf_free(Servicegateway); } -void gf_m2ts_delete_dsmcc_overlord(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord) +void gf_m2ts_delete_dsmcc_overlord(GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord) { u16 nb_module,i; nb_module = gf_list_count(dsmcc_overlord->dsmcc_modules); - for(i=0;idsmcc_modules,i); dsmcc_delete_module(module); } gf_list_del(dsmcc_overlord->dsmcc_modules); nb_module = gf_list_count(dsmcc_overlord->Unprocessed_module); - for(i=0;iUnprocessed_module,i); dsmcc_delete_module(module); } gf_list_del(dsmcc_overlord->dsmcc_modules); dmscc_delete_servicegateway(dsmcc_overlord->ServiceGateway); - if(dsmcc_overlord->root_dir){ + if(dsmcc_overlord->root_dir) { gf_free(dsmcc_overlord->root_dir); } gf_free(dsmcc_overlord); } -static void dsmcc_free_biop_header(GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header){ +static void dsmcc_free_biop_header(GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header) { - gf_free(BIOP_Header->objectKind_data); + gf_free(BIOP_Header->objectKind_data); gf_free(BIOP_Header); } -static void dsmcc_free_biop_directory(GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directory){ +static void dsmcc_free_biop_directory(GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directory) { gf_free(BIOP_Directory->objectInfo_data); dsmcc_free_biop_context(BIOP_Directory->ServiceContext,BIOP_Directory->serviceContextList_count); @@ -1739,117 +1739,117 @@ static void dsmcc_free_biop_directory(GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directo gf_free(BIOP_Directory); } -static void dsmcc_free_biop_file(GF_M2TS_DSMCC_BIOP_FILE* BIOP_File){ +static void dsmcc_free_biop_file(GF_M2TS_DSMCC_BIOP_FILE* BIOP_File) { dsmcc_free_biop_descriptor(BIOP_File->descriptor); - dsmcc_free_biop_context(BIOP_File->ServiceContext,BIOP_File->serviceContextList_count); - if(BIOP_File->content_length){ + dsmcc_free_biop_context(BIOP_File->ServiceContext,BIOP_File->serviceContextList_count); + if(BIOP_File->content_length) { gf_free(BIOP_File->content_byte); } gf_free(BIOP_File); } -static void dsmcc_free_biop_stream_event(GF_M2TS_DSMCC_BIOP_STREAM_EVENT* BIOP_StreamEvent){ +static void dsmcc_free_biop_stream_event(GF_M2TS_DSMCC_BIOP_STREAM_EVENT* BIOP_StreamEvent) { u32 i; - if(BIOP_StreamEvent->Info.aDescription_length){ + if(BIOP_StreamEvent->Info.aDescription_length) { gf_free(BIOP_StreamEvent->Info.aDescription_bytes); } - if(BIOP_StreamEvent->objectInfo_byte){ + if(BIOP_StreamEvent->objectInfo_byte) { gf_free(BIOP_StreamEvent->objectInfo_byte); } - - if(BIOP_StreamEvent->eventNames_count){ - for(i=0;ieventNames_count;i++){ - if(BIOP_StreamEvent->EventList[i].eventName_length){ + + if(BIOP_StreamEvent->eventNames_count) { + for(i=0; ieventNames_count; i++) { + if(BIOP_StreamEvent->EventList[i].eventName_length) { gf_free(BIOP_StreamEvent->EventList[i].eventName_data_byte); } } gf_free(BIOP_StreamEvent->EventList); } - - if(BIOP_StreamEvent->taps_count){ + + if(BIOP_StreamEvent->taps_count) { gf_free(BIOP_StreamEvent->Taps); } dsmcc_free_biop_context(BIOP_StreamEvent->ServiceContext,BIOP_StreamEvent->serviceContextList_count); - - if(BIOP_StreamEvent->eventId){ + + if(BIOP_StreamEvent->eventId) { gf_free(BIOP_StreamEvent->eventId); } } -static void dsmcc_free_biop_stream_message(GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage){ +static void dsmcc_free_biop_stream_message(GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage) { - if(BIOP_StreamMessage->Info.aDescription_length){ + if(BIOP_StreamMessage->Info.aDescription_length) { gf_free(BIOP_StreamMessage->Info.aDescription_bytes); } - - if(BIOP_StreamMessage->objectInfo_byte){ + + if(BIOP_StreamMessage->objectInfo_byte) { gf_free(BIOP_StreamMessage->objectInfo_byte); - } - - if(BIOP_StreamMessage->taps_count){ + } + + if(BIOP_StreamMessage->taps_count) { gf_free(BIOP_StreamMessage->Taps); } - dsmcc_free_biop_context(BIOP_StreamMessage->ServiceContext,BIOP_StreamMessage->serviceContextList_count); + dsmcc_free_biop_context(BIOP_StreamMessage->ServiceContext,BIOP_StreamMessage->serviceContextList_count); } static void dsmcc_free_biop_ior(GF_M2TS_DSMCC_IOR* IOR) { u32 i,left_lite_component; - - if(IOR->type_id_length){ + + if(IOR->type_id_length) { gf_free(IOR->type_id_byte); - } - for(i = 0; i < IOR->taggedProfiles_count;i++){ + } + for(i = 0; i < IOR->taggedProfiles_count; i++) { GF_M2TS_DSMCC_BIOP_TAGGED_PROFILE* taggedProfile = gf_list_get(IOR->taggedProfile,0); left_lite_component = taggedProfile->lite_component_count; - switch(taggedProfile->profileId_tag){ - - case TAG_BIOP: - { - /* Object Location */ - GF_SAFEALLOC(taggedProfile->BIOPProfileBody,GF_M2TS_DSMCC_BIOP_PROFILE_BODY); - - gf_free(taggedProfile->BIOPProfileBody->ConnBinder.Taps); - if(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18 != 0){ - gf_free(taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte); - } - gf_free(taggedProfile->BIOPProfileBody); - left_lite_component = left_lite_component - 2; - break; - } - case TAG_LITE_OPTIONS: - { - /* Service Location */ - u32 j; - - for(j = 0; j < taggedProfile->ServiceLocation->nameComponents_count; j++){ - - if(taggedProfile->ServiceLocation->NameComponent[j].id_length != 0){ - gf_free(taggedProfile->ServiceLocation->NameComponent[j].id_data); - } - if(taggedProfile->ServiceLocation->NameComponent[j].kind_length != 0){ - gf_free(taggedProfile->ServiceLocation->NameComponent[j].kind_data); - } - } - gf_free(taggedProfile->ServiceLocation->NameComponent); - - if(taggedProfile->ServiceLocation->initialContext_length != 0){ - gf_free(taggedProfile->ServiceLocation->InitialContext_data_byte); - } - left_lite_component = left_lite_component - 1; - break; - } - } - - for(i = 0; iLiteComponent[i].component_data_length != 0){ + switch(taggedProfile->profileId_tag) { + + case TAG_BIOP: + { + /* Object Location */ + GF_SAFEALLOC(taggedProfile->BIOPProfileBody,GF_M2TS_DSMCC_BIOP_PROFILE_BODY); + + gf_free(taggedProfile->BIOPProfileBody->ConnBinder.Taps); + if(taggedProfile->BIOPProfileBody->ConnBinder.component_data_length-18 != 0) { + gf_free(taggedProfile->BIOPProfileBody->ConnBinder.additional_tap_byte); + } + gf_free(taggedProfile->BIOPProfileBody); + left_lite_component = left_lite_component - 2; + break; + } + case TAG_LITE_OPTIONS: + { + /* Service Location */ + u32 j; + + for(j = 0; j < taggedProfile->ServiceLocation->nameComponents_count; j++) { + + if(taggedProfile->ServiceLocation->NameComponent[j].id_length != 0) { + gf_free(taggedProfile->ServiceLocation->NameComponent[j].id_data); + } + if(taggedProfile->ServiceLocation->NameComponent[j].kind_length != 0) { + gf_free(taggedProfile->ServiceLocation->NameComponent[j].kind_data); + } + } + gf_free(taggedProfile->ServiceLocation->NameComponent); + + if(taggedProfile->ServiceLocation->initialContext_length != 0) { + gf_free(taggedProfile->ServiceLocation->InitialContext_data_byte); + } + left_lite_component = left_lite_component - 1; + break; + } + } + + for(i = 0; iLiteComponent[i].component_data_length != 0) { gf_free(taggedProfile->LiteComponent[i].component_data_byte); } @@ -1867,70 +1867,70 @@ static void dsmcc_free_biop_descriptor(GF_List* list) while(gf_list_count(list)) { - descr_tag = (u8*)gf_list_get(list,0); + descr_tag = (u8*)gf_list_get(list,0); switch(*descr_tag) { - case CACHING_PRIORITY_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr = (GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR*)gf_list_get(list,0); - gf_list_rem(list,0); - gf_free(CachingPriorityDescr); - break; - } - case COMPRESSED_MODULE_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr = (GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR*)gf_list_get(list,0); - gf_list_rem(list,0); - gf_free(CompModuleDescr); - break; + case CACHING_PRIORITY_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR* CachingPriorityDescr = (GF_M2TS_DSMCC_BIOP_CACHING_PRIORITY_DESCRIPTOR*)gf_list_get(list,0); + gf_list_rem(list,0); + gf_free(CachingPriorityDescr); + break; + } + case COMPRESSED_MODULE_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR* CompModuleDescr = (GF_M2TS_DSMCC_BIOP_COMPRESSED_MODULE_DESCRIPTOR*)gf_list_get(list,0); + gf_list_rem(list,0); + gf_free(CompModuleDescr); + break; - } - case CONTENT_TYPE_DESCRIPTOR: - { - GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(list,0); - gf_list_rem(list,0); - if(ContentTypeDescr->descriptor_length){ - gf_free(ContentTypeDescr->content_type_data_byte); - } - gf_free(ContentTypeDescr); - break; - } - default: - { + } + case CONTENT_TYPE_DESCRIPTOR: + { + GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(list,0); + gf_list_rem(list,0); + if(ContentTypeDescr->descriptor_length) { + gf_free(ContentTypeDescr->content_type_data_byte); + } + gf_free(ContentTypeDescr); + break; + } + default: + { - break; - } - } + break; + } + } } gf_list_del(list); } -static void dsmcc_free_biop_name(GF_M2TS_DSMCC_BIOP_NAME* Name, u32 nb_name){ +static void dsmcc_free_biop_name(GF_M2TS_DSMCC_BIOP_NAME* Name, u32 nb_name) { u32 i; - for(i =0;idata; u32_data_size = pck->data_len; u32_table_id = data[0]; - + switch(u32_table_id) { case GF_M2TS_TABLE_ID_INT: gf_m2ts_process_int(ts, (GF_M2TS_SECTION_ES *)pck->stream, data, u32_data_size, u32_table_id); @@ -46,14 +46,14 @@ static void on_dvb_mpe_section(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) else { //fprintf(stderr, "Time Slice Parameters for MPE-FEC have not been found yet \n"); } - break; + break; default: return; } } } -static void on_dvb_mpe_fec_frame(GF_M2TS_Demuxer *ts, MPE_FEC_FRAME *mff) +static void on_dvb_mpe_fec_frame(GF_M2TS_Demuxer *ts, MPE_FEC_FRAME *mff) { if (ts->ip_platform != NULL) { if(ts->dvb_h_demux == 0) { @@ -80,11 +80,11 @@ void gf_dvb_mpe_shutdown(GF_M2TS_Demuxer *ts) if (!ip_platform) return; - if (ip_platform->ip_streams){ - while(gf_list_count(ip_platform->ip_streams)){ - ip_stream_buff=gf_list_get(ip_platform->ip_streams, 0); - - while (gf_list_count(ip_stream_buff->targets)){ + if (ip_platform->ip_streams) { + while(gf_list_count(ip_platform->ip_streams)) { + ip_stream_buff=gf_list_get(ip_platform->ip_streams, 0); + + while (gf_list_count(ip_stream_buff->targets)) { GF_M2TS_IP_Target *ip_targets = gf_list_get(ip_stream_buff->targets, 0); gf_free(ip_targets); gf_list_rem(ip_stream_buff->targets,0); @@ -96,8 +96,8 @@ void gf_dvb_mpe_shutdown(GF_M2TS_Demuxer *ts) gf_list_del(ip_platform->ip_streams); } ip_platform->ip_streams = NULL; - if (ip_platform->socket_struct){ - while(gf_list_count(ip_platform->socket_struct)){ + if (ip_platform->socket_struct) { + while(gf_list_count(ip_platform->socket_struct)) { GF_SOCK_ENTRY *socket_struct = gf_list_get(ip_platform->socket_struct, 0); gf_free(socket_struct); gf_list_rem(ip_platform->socket_struct,0); @@ -105,7 +105,7 @@ void gf_dvb_mpe_shutdown(GF_M2TS_Demuxer *ts) gf_list_del(ip_platform->socket_struct); } ip_platform->socket_struct = NULL; - gf_free(ip_platform); + gf_free(ip_platform); ts->ip_platform = NULL; } @@ -140,17 +140,17 @@ void gf_dvb_mpe_section_del(GF_M2TS_ES *es) { u32 i; for (i = 0; i < length; i ++) { - if (i%line_length == 0) { - fprintf(stderr, "%2d: ", i/line_length); + if (i%line_length == 0) { + fprintf(stderr, "%2d: ", i/line_length); } else if (i%8 == 0) { - fprintf(stderr, " "); + fprintf(stderr, " "); } fprintf(stderr, "%02x", data[i]); - if ((i+1)%line_length == 0) { - fprintf(stderr, "\n"); + if ((i+1)%line_length == 0) { + fprintf(stderr, "\n"); } } - if (last_line) fprintf(stderr, "\n"); + if (last_line) fprintf(stderr, "\n"); } */ @@ -159,8 +159,8 @@ void gf_m2ts_process_mpe(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_MPE *mpe, unsigned GF_M2TS_IP_Stream *ip_stream_buff; GF_M2TS_IP_PLATFORM * ip_platform = ts->ip_platform; u32 table_boundry_flag; - u32 frame_boundry_flag; - u32 offset; + u32 frame_boundry_flag; + u32 offset; u32 i_streams,j; u32 section_number, last_section_number; s32 len_left = data_size; @@ -170,16 +170,16 @@ void gf_m2ts_process_mpe(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_MPE *mpe, unsigned i_streams = 0; // fprintf(stderr, "Processing MPE/MPE-FEC data PID %d (%d/%d)\n",mpe->pid, data[6],data[7]); - + if (!gf_m2ts_crc32_check(data, data_size - 4)) { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("CRC error in the MPE/MPE-FEC data \n")); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("CRC error in the MPE/MPE-FEC data \n")); } - + /*get number of rows of mpe_fec_frame from descriptor*/ - section_number = data[6]; + section_number = data[6]; last_section_number = data[7]; - //fprintf(stderr, "table_id: %x section_length: %d section_number: %d last : %d \n", data[0], (data[1] & 0xF)<<8|data[2], section_number, last_section_number); - + //fprintf(stderr, "table_id: %x section_length: %d section_number: %d last : %d \n", data[0], (data[1] & 0xF)<<8|data[2], section_number, last_section_number); + if (ts->direct_mpe) { if (table_id != GF_M2TS_TABLE_ID_DSM_CC_PRIVATE) return; if (section_number != last_section_number) { @@ -187,51 +187,51 @@ void gf_m2ts_process_mpe(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_MPE *mpe, unsigned return; } /* send the IP data : - Remove the first 12 bytes of header (from table id to end of real time parameters + Remove the first 12 bytes of header (from table id to end of real time parameters Remove also the last four 4 bytes of the section (CRC 32) */ - gf_m2ts_mpe_send_datagram(ts, mpe->pid, data +12, data_size - (12+4)); - return; + gf_m2ts_mpe_send_datagram(ts, mpe->pid, data +12, data_size - (12+4)); + return; } /*get number of rows of mpe_fec_frame from descriptor*/ - /* Real-Time Parameters */ - //delta_t = (data[8]<<4)|(data[9]>>4); + /* Real-Time Parameters */ + //delta_t = (data[8]<<4)|(data[9]>>4); table_boundry_flag = (data[9] >> 3 )& 0x1; - frame_boundry_flag = (data[9] >> 2 )& 0x1; - + frame_boundry_flag = (data[9] >> 2 )& 0x1; + offset = ((data[9] & 0x3)<< 16) | (data[10] << 8)| data[11]; /* Using MFF structure attached to the MPE Stream */ - if(mpe->mff){ - if(!mpe->mff->mpe_holes){ + if(mpe->mff) { + if(!mpe->mff->mpe_holes) { mpe->mff->mpe_holes = gf_list_new(); } - }else if(offset != 0){ + } else if(offset != 0) { /* If no MFF structure is attached to the MPE Stream, wait for a new IP Datagram before processing data */ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[IpdcEgine] buffer is not null, waiting for a new IP Datagram before processing data\n")); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[IpdcEgine] buffer is not null, waiting for a new IP Datagram before processing data\n")); return; - }else{ - GF_SAFEALLOC(mpe->mff,MPE_FEC_FRAME); - + } else { + GF_SAFEALLOC(mpe->mff,MPE_FEC_FRAME); + assert( ip_platform ); assert(ip_platform->ip_streams); i_streams = gf_list_count(ip_platform->ip_streams); - for(j=0;jip_streams, j); - if(mpe->program->number == ip_stream_buff->location.service_id){ - switch(ip_stream_buff->time_slice_fec.frame_size){ + if(mpe->program->number == ip_stream_buff->location.service_id) { + switch(ip_stream_buff->time_slice_fec.frame_size) { case 0: - mpe->mff->rows =256; + mpe->mff->rows =256; break; case 1: - mpe->mff->rows =512; + mpe->mff->rows =512; + break; + case 2: + mpe->mff->rows =768; break; - case 2: - mpe->mff->rows =768; - break; case 3: mpe->mff->rows =1024; break; @@ -241,65 +241,65 @@ void gf_m2ts_process_mpe(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_MPE *mpe, unsigned break; } } - /*initialize the mpe fec frame */ + /*initialize the mpe fec frame */ if (init_frame(mpe->mff, mpe->mff->rows)) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MFF initialization successed \n")); } else { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MFF initialization failed \n")); - return; - } + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MFF initialization failed \n")); + return; + } } - + //fprintf(stderr, "PID: %4d, sec: %2d/%2d, t_id: %2d, d: %3d, tb: %d, fb: %d, add.: %8d\n", mpe->pid, section_number, last_section_number, id, delta_t, table_boundry_flag, frame_boundry_flag, offset); - mpe->mff->PID = mpe->pid; - - while (len_left>0) { + mpe->mff->PID = mpe->pid; + + while (len_left>0) { switch (table_id) { case GF_M2TS_TABLE_ID_DSM_CC_PRIVATE: /* MPE */ /* Sets the IP data in the Application Data Table - Remove the first 12 bytes of header (from table id to end of real time parameters + Remove the first 12 bytes of header (from table id to end of real time parameters Remove also the last four 4 bytes of the section (CRC 32)*/ - setIpDatagram( mpe->mff, offset, data +12, data_size-(12+4)); - len_left = 0; + setIpDatagram( mpe->mff, offset, data +12, data_size-(12+4)); + len_left = 0; break; case GF_M2TS_TABLE_ID_MPE_FEC: - /* RS data is set by column, one column at a time */ + /* RS data is set by column, one column at a time */ //setColRS( mpe->mff, offset, data + 12, mpe->mff->rows); len_left = 0; //data += (mff->rows +12+4 ); break; default: - // fprintf(stderr, "Unknown table id %x \n", table_id ); - len_left = 0; + // fprintf(stderr, "Unknown table id %x \n", table_id ); + len_left = 0; } - - if(table_boundry_flag == 1) /* end of reception of ADT data or RS data */{ - if(table_id == 0x3E) /* end of ADT */{ - mpe->mff->ADT_done =1; - if(mpe->mff->current_offset_adt+1 != mpe->mff->capacity_total){ - memset( mpe->mff->p_adt+mpe->mff->current_offset_adt,0, mpe->mff->capacity_total-( mpe->mff->current_offset_adt+1)); - } - } - /* end of RS should be catched below by frame_boundary_flag */ + + if(table_boundry_flag == 1) { /* end of reception of ADT data or RS data */ + if(table_id == 0x3E) { /* end of ADT */ + mpe->mff->ADT_done =1; + if(mpe->mff->current_offset_adt+1 != mpe->mff->capacity_total) { + memset( mpe->mff->p_adt+mpe->mff->current_offset_adt,0, mpe->mff->capacity_total-( mpe->mff->current_offset_adt+1)); + } } + /* end of RS should be catched below by frame_boundary_flag */ + } - if(frame_boundry_flag == 1){ - if(table_id == 0x78){ - if( mpe->mff->current_offset_rs+1 != mpe->mff->rows*64){ - memset( mpe->mff->p_rs+ mpe->mff->current_offset_rs,0,( mpe->mff->rows*64)-( mpe->mff->current_offset_rs+1)); - } + if(frame_boundry_flag == 1) { + if(table_id == 0x78) { + if( mpe->mff->current_offset_rs+1 != mpe->mff->rows*64) { + memset( mpe->mff->p_rs+ mpe->mff->current_offset_rs,0,( mpe->mff->rows*64)-( mpe->mff->current_offset_rs+1)); } } + } } - if (frame_boundry_flag && table_boundry_flag && mpe->mff->ADT_done ==1 ) { + if (frame_boundry_flag && table_boundry_flag && mpe->mff->ADT_done ==1 ) { //decode_fec(mpe->mff); on_dvb_mpe_fec_frame(ts, mpe->mff); - resetMFF(mpe->mff); - /*for each IP datagram reconstructed*/ - } + resetMFF(mpe->mff); + /*for each IP datagram reconstructed*/ + } } @@ -317,30 +317,30 @@ void gf_m2ts_process_ipdatagram(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *ts) ip_datagram = mff->p_adt; GF_SAFEALLOC(ip_packet,GF_M2TS_IP_Packet); - + while(offsetcurrent_offset_adt) { /* Find the parts of the ADT which contain errors and skip them */ - if((mff->p_error_adt+offset)[0] == 0x01010101){ - i_holes = gf_list_count(mff->mpe_holes); - for(i=0;ip_error_adt+offset)[0] == 0x01010101) { + i_holes = gf_list_count(mff->mpe_holes); + for(i=0; impe_holes, i); - if(mff_holes->offset == offset){ + if(mff_holes->offset == offset) { offset += mff_holes->length; break; } - } + } } - - if(gf_m2ts_ipdatagram_reader(ip_datagram, ip_packet, offset)){ - - + + if(gf_m2ts_ipdatagram_reader(ip_datagram, ip_packet, offset)) { + + /* update the offset */ //offset += ip_packet->u32_total_length; offset += (ip_packet->u32_hdr_length*4) + ip_packet->u32_udp_data_size; - + /* 224.0.23.14 IP Bosstrap */ ip_adress_bootstrap[0]=224; ip_adress_bootstrap[1]=0; @@ -348,24 +348,24 @@ void gf_m2ts_process_ipdatagram(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *ts) ip_adress_bootstrap[3]=14; socket_simu(ip_packet,ts, 1); - if(ip_packet->u8_rx_adr[3] == 8){ - fprintf(stderr, "\n"); + if(ip_packet->u8_rx_adr[3] == 8) { + fprintf(stderr, "\n"); } /* compare the destination ip adress and the ESG Bootstrap adress */ Boostrap_ip = gf_m2ts_compare_ip(ip_packet->u8_rx_adr,ip_adress_bootstrap); - if(Boostrap_ip){ - fprintf(stderr, "ESG Bootstrap found !\n"); - } - }else{ - offset += (ip_packet->u32_total_length); - } - - if(ip_packet->data){ - gf_free(ip_packet->data); - } - ip_packet->data = NULL; - + if(Boostrap_ip) { + fprintf(stderr, "ESG Bootstrap found !\n"); + } + } else { + offset += (ip_packet->u32_total_length); + } + + if(ip_packet->data) { + gf_free(ip_packet->data); + } + ip_packet->data = NULL; + } //gf_memory_print(); @@ -373,7 +373,7 @@ void gf_m2ts_process_ipdatagram(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *ts) empty_list(mff->mpe_holes); gf_list_del(mff->mpe_holes); - mff->mpe_holes = NULL; + mff->mpe_holes = NULL; gf_m2ts_Delete_IpPacket(ip_packet); } @@ -400,19 +400,19 @@ void gf_m2ts_mpe_send_datagram(GF_M2TS_Demuxer *ts, u32 mpe_pid, unsigned char * udp_data = data+(hdr_len*4); ip_pck.u32_tx_udp_port = udp_data[0]<<8 | udp_data[1]; - if(!ip_pck.u32_tx_udp_port){ + if(!ip_pck.u32_tx_udp_port) { return; } ip_pck.u32_rx_udp_port = udp_data[2]<<8 | udp_data[3]; - if(!ip_pck.u32_rx_udp_port){ + if(!ip_pck.u32_rx_udp_port) { return; } ip_pck.u32_udp_data_size = udp_data[4]<<8 | udp_data[5]; - if(ip_pck.u32_udp_data_size == 0){ + if(ip_pck.u32_udp_data_size == 0) { return; } ip_pck.u32_udp_chksm = udp_data[6]<<8 | udp_data[7]; - + /*excluding UDP header*/ ip_pck.data = udp_data + 8; @@ -450,20 +450,20 @@ u32 gf_m2ts_ipdatagram_reader(u8 *datagram,GF_M2TS_IP_Packet *ip_packet, u32 off memcpy(ip_packet->u8_rx_adr,(datagram+offset)+16,sizeof(ip_packet->u8_rx_adr)); ip_packet->u32_tx_udp_port = ((datagram+offset)+(ip_packet->u32_hdr_length*4))[0]<<8|((datagram+offset)+(ip_packet->u32_hdr_length*4))[1]; - if(!ip_packet->u32_tx_udp_port){ + if(!ip_packet->u32_tx_udp_port) { return 0; } ip_packet->u32_rx_udp_port = ((datagram+offset)+(ip_packet->u32_hdr_length*4))[2]<<8|((datagram+offset)+(ip_packet->u32_hdr_length*4))[3]; - if(!ip_packet->u32_rx_udp_port){ + if(!ip_packet->u32_rx_udp_port) { return 0; } ip_packet->u32_udp_data_size = ((datagram+offset)+(ip_packet->u32_hdr_length*4))[4]<<8|((datagram+offset)+(ip_packet->u32_hdr_length*4))[5]; - if(ip_packet->u32_udp_data_size == 0){ + if(ip_packet->u32_udp_data_size == 0) { return 0; } ip_packet->u32_udp_chksm = ((datagram+offset)+(ip_packet->u32_hdr_length*4))[6]<<8|((datagram+offset)+(ip_packet->u32_hdr_length*4))[7]; - - + + ip_packet->data = gf_malloc((ip_packet->u32_udp_data_size-8)*sizeof(u8)); memcpy(ip_packet->data,datagram+offset+(ip_packet->u32_hdr_length*4)+8,(ip_packet->u32_udp_data_size-8)*sizeof(u8)); /*ip_packet->data = gf_malloc((ip_packet->u32_total_length-ip_packet->u32_hdr_length)*sizeof(char)); @@ -485,14 +485,14 @@ static void gf_m2ts_Delete_IpPacket(GF_M2TS_IP_Packet *ip_packet) ip_packet->u32_frag_offset = 0; ip_packet->u32_TTL = 0; ip_packet->u32_protocol = 0; - ip_packet->u32_crc = 0; - ip_packet->u32_tx_udp_port = 0; + ip_packet->u32_crc = 0; + ip_packet->u32_tx_udp_port = 0; ip_packet->u32_rx_udp_port = 0; ip_packet->u32_udp_data_size = 0; ip_packet->u32_udp_chksm = 0; - - if(ip_packet->data){ - gf_free(ip_packet->data); + + if(ip_packet->data) { + gf_free(ip_packet->data); } gf_free(ip_packet); ip_packet = NULL; @@ -501,13 +501,13 @@ static void gf_m2ts_Delete_IpPacket(GF_M2TS_IP_Packet *ip_packet) void gf_m2ts_process_int(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ip_table, unsigned char *data, u32 data_size, u32 table_id) -{ +{ - GF_M2TS_IP_PLATFORM * ip_platform = ts->ip_platform ; + GF_M2TS_IP_PLATFORM * ip_platform = ts->ip_platform ; assert( ts ); // fprintf(stderr, "Processing IP/MAC Notification table (PID %d) %s\n", ip_table->pid, (status==GF_M2TS_TABLE_REPEAT)?"repeated":""); - //if ( status == GF_M2TS_TABLE_REPEAT ) return ; - if ( ip_platform == NULL ) + //if ( status == GF_M2TS_TABLE_REPEAT ) return ; + if ( ip_platform == NULL ) { GF_SAFEALLOC(ip_platform,GF_M2TS_IP_PLATFORM ); ip_platform->ip_streams= gf_list_new(); @@ -529,13 +529,13 @@ void section_DSMCC_INT(GF_M2TS_IP_PLATFORM* ip_platform,u8 *data, u32 data_size) s32 length,i; - - length = data_size ; - data += 12 ; - + length = data_size ; + + data += 12 ; + assert( ip_platform); - i = dsmcc_pto_platform_descriptor_loop(ip_platform,data); + i = dsmcc_pto_platform_descriptor_loop(ip_platform,data); data += i; length -= i; @@ -543,18 +543,18 @@ void section_DSMCC_INT(GF_M2TS_IP_PLATFORM* ip_platform,u8 *data, u32 data_size) GF_M2TS_IP_Stream *ip_str; GF_SAFEALLOC(ip_str,GF_M2TS_IP_Stream ); - i = dsmcc_pto_descriptor_loop(ip_str,data); + i = dsmcc_pto_descriptor_loop(ip_str,data); data += i; length -= i; - i = dsmcc_pto_descriptor_loop(ip_str,data); + i = dsmcc_pto_descriptor_loop(ip_str,data); data += i; length -= i; assert( ip_platform->ip_streams ); gf_list_add(ip_platform->ip_streams, ip_str); - } - - return ; + } + + return ; } @@ -562,58 +562,60 @@ void section_DSMCC_INT(GF_M2TS_IP_PLATFORM* ip_platform,u8 *data, u32 data_size) u32 dsmcc_pto_platform_descriptor_loop(GF_M2TS_IP_PLATFORM* ip_platform, u8 *data) { - u32 loop_length; - s32 length,i; - - - loop_length = ((data[0]) & 0xF ) | data[1]; - length = loop_length; - data += 2; - while (length > 0) { - assert( ip_platform); - i = platform_descriptorDSMCC_INT_UNT(ip_platform,data); - data += i; - length -= i; - } - - return (loop_length+2); + u32 loop_length; + s32 length,i; + + + loop_length = ((data[0]) & 0xF ) | data[1]; + length = loop_length; + data += 2; + while (length > 0) { + assert( ip_platform); + i = platform_descriptorDSMCC_INT_UNT(ip_platform,data); + data += i; + length -= i; + } + + return (loop_length+2); } u32 platform_descriptorDSMCC_INT_UNT(GF_M2TS_IP_PLATFORM* ip_platform, u8 *data) { - u32 length; - u32 id; + u32 length; + u32 id; - id = data[0]; - length = data[1]+2; + id = data[0]; + length = data[1]+2; - switch (id) { + switch (id) { - - case GF_M2TS_DVB_IP_MAC_PLATFORM_NAME_DESCRIPTOR: - { - //fprintf(stderr, " Information on the ip platform found \n"); - gf_ip_platform_descriptor(ip_platform, data); - }break; - case GF_M2TS_DVB_IP_MAC_PLATFORM_PROVIDER_NAME_DESCRIPTOR: - { - //fprintf(stderr, " Information on the ip platform found \n"); - gf_ip_platform_provider_descriptor(ip_platform, data); - }break; - default: + case GF_M2TS_DVB_IP_MAC_PLATFORM_NAME_DESCRIPTOR: + { + //fprintf(stderr, " Information on the ip platform found \n"); + gf_ip_platform_descriptor(ip_platform, data); + } break; - } + case GF_M2TS_DVB_IP_MAC_PLATFORM_PROVIDER_NAME_DESCRIPTOR: + { + //fprintf(stderr, " Information on the ip platform found \n"); + gf_ip_platform_provider_descriptor(ip_platform, data); + } + break; + + default: + break; + } return length; // (descriptor total length) } void gf_ip_platform_descriptor(GF_M2TS_IP_PLATFORM* ip_platform,u8 * data) { u32 length; - length = data[1]; + length = data[1]; assert( ip_platform ); /* allocation ofr the name of the platform */ ip_platform->name = gf_malloc(sizeof(char)*(length-3+1)); @@ -625,13 +627,13 @@ void gf_ip_platform_descriptor(GF_M2TS_IP_PLATFORM* ip_platform,u8 * data) void gf_ip_platform_provider_descriptor(GF_M2TS_IP_PLATFORM* ip_platform, u8 * data) { u32 length; - length = data[1]; + length = data[1]; /* allocation of the name of the platform */ assert( ip_platform ); ip_platform->provider_name = gf_malloc(sizeof(char)*(length-3+1)); memcpy(ip_platform->provider_name, data+5, length-3); ip_platform->provider_name[length-3] = 0; - return ; + return ; } @@ -639,81 +641,82 @@ void gf_ip_platform_provider_descriptor(GF_M2TS_IP_PLATFORM* ip_platform, u8 * d /* IP Stream Descriptors */ u32 dsmcc_pto_descriptor_loop ( GF_M2TS_IP_Stream *ip_str,u8 *data) { - u32 loop_length; - s32 length,i; - - loop_length = ((data[0]) & 0xF ) | data[1]; - - length = loop_length; - data += 2; - while (length > 0) { - i = descriptorDSMCC_INT_UNT(ip_str,data); - data += i; - length -= i; - } - - return (loop_length+2); + u32 loop_length; + s32 length,i; + + loop_length = ((data[0]) & 0xF ) | data[1]; + + length = loop_length; + data += 2; + while (length > 0) { + i = descriptorDSMCC_INT_UNT(ip_str,data); + data += i; + length -= i; + } + + return (loop_length+2); } u32 descriptorDSMCC_INT_UNT(GF_M2TS_IP_Stream *ip_str,u8 *data) { - u32 length; - u32 id; - - id = data[0]; - length = data[1] +2; - - switch (id) { - - - case GF_M2TS_DVB_TARGET_IP_SLASH_DESCRIPTOR: - { - - gf_m2ts_target_ip(ip_str,data); - } - break; - - case GF_M2TS_DVB_TIME_SLICE_FEC_DESCRIPTOR: - { - descriptorTime_slice_fec_identifier(ip_str,data); - } - break; - case GF_M2TS_DVB_STREAM_LOCATION_DESCRIPTOR: - { - descriptorLocation(ip_str , data); - }break; - default: + u32 length; + u32 id; + + id = data[0]; + length = data[1] +2; + + switch (id) { + + + case GF_M2TS_DVB_TARGET_IP_SLASH_DESCRIPTOR: + { + + gf_m2ts_target_ip(ip_str,data); + } + break; + + case GF_M2TS_DVB_TIME_SLICE_FEC_DESCRIPTOR: + { + descriptorTime_slice_fec_identifier(ip_str,data); + } break; - } + case GF_M2TS_DVB_STREAM_LOCATION_DESCRIPTOR: + { + descriptorLocation(ip_str , data); + } + break; + default: + break; + } - return length; // (descriptor total length) + return length; // (descriptor total length) } void descriptorTime_slice_fec_identifier( GF_M2TS_IP_Stream *ip_str,u8 * data) { ip_str->time_slice_fec.time_slicing = (data[2] >> 7) & 0x1; - ip_str->time_slice_fec.mpe_fec = (data[2] >> 5 ) & 0x3 ; - ip_str->time_slice_fec.frame_size = data[2] & 0x7 ; - ip_str->time_slice_fec.max_burst_duration = data[3]; - ip_str->time_slice_fec.max_average_rate = (data[4] >> 4) & 0xf ; - ip_str->time_slice_fec.time_slice_fec_id = data[4] & 0xf; - ip_str->time_slice_fec.id_selector = gf_malloc( data[1] - 3 ) ; + ip_str->time_slice_fec.mpe_fec = (data[2] >> 5 ) & 0x3 ; + ip_str->time_slice_fec.frame_size = data[2] & 0x7 ; + ip_str->time_slice_fec.max_burst_duration = data[3]; + ip_str->time_slice_fec.max_average_rate = (data[4] >> 4) & 0xf ; + ip_str->time_slice_fec.time_slice_fec_id = data[4] & 0xf; + ip_str->time_slice_fec.id_selector = gf_malloc( data[1] - 3 ) ; memcpy(ip_str->time_slice_fec.id_selector, data + 4, data[1]-3 ); - return ; + return ; } void descriptorLocation(GF_M2TS_IP_Stream *ip_str , u8 * data) { ip_str->location.network_id = (data[2]<<8)|data[3]; - ip_str->location.original_network_id = (data[4]<<8)|data[5]; - ip_str->location.transport_stream_id = (data[6]<<8)|data[7]; + ip_str->location.original_network_id = (data[4]<<8)|data[5]; + ip_str->location.transport_stream_id = (data[6]<<8)|data[7]; ip_str->location.service_id = (data[8]<<8)|data[9]; ip_str->location.component_tag = data[10]; - return; + return; } void gf_m2ts_target_ip(GF_M2TS_IP_Stream* ip_str, u8 * data) @@ -723,7 +726,7 @@ void gf_m2ts_target_ip(GF_M2TS_IP_Stream* ip_str, u8 * data) i=j=0; ip_str->targets = gf_list_new(); length = data[1]; - for(i=0;iaddress_mask = 0; memcpy(ip_data->address, data+2+i, 4); ip_data->slash_mask=data[2+i+4]; - + gf_list_add(ip_str->targets,ip_data); } @@ -749,7 +752,7 @@ void encode_fec(MPE_FEC_FRAME * mff) u32 i = 0; u32 cols = 0; - cols = mff->col_adt; + cols = mff->col_adt; for ( i = 0; i < rows; i ++ ) { /* read a row from ADT into buffer */ getRowFromADT(mff, i, adt_rs_en_buffer); @@ -772,7 +775,7 @@ void decode_fec(MPE_FEC_FRAME * mff) u8 linebuffer[255]; //fprintf(stderr, "Starting FEC decoding ...\n"); - + data = gf_malloc((mff->rows*191)*sizeof(char)); memset(data,0,sizeof(data)); @@ -809,13 +812,13 @@ void decode_fec(MPE_FEC_FRAME * mff) if(correct_errors_erasures (linebuffer, ML, nerasures, erasures) == 0) { //fprintf(stderr, "Correction Error line %d \n", i); - } + } /* TODO: replace the current line in MFF */ - } + } - memcpy(data+offset,linebuffer,sizeof(data)); - offset += 191; + memcpy(data+offset,linebuffer,sizeof(data)); + offset += 191; } //fprintf(stderr, "FEC decoding done.\n"); memcpy(mff->p_adt,data,sizeof(data)); @@ -837,7 +840,7 @@ void gf_m2ts_gather_ipdatagram_information(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *t GF_M2TS_IP_Stream *ip_stream_buff; GF_M2TS_IP_Target *ip_targets; GF_M2TS_IP_PLATFORM * ip_platform = ts->ip_platform; - + assert( ts ); offset =0; ip_datagram = mff->p_adt; @@ -850,7 +853,7 @@ void gf_m2ts_gather_ipdatagram_information(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *t if((mff->p_error_adt+offset)[0] == 0x01010101) { i_holes = gf_list_count(mff->mpe_holes); - for(i=0;impe_holes, i); if(mff_holes->offset == offset) @@ -859,12 +862,12 @@ void gf_m2ts_gather_ipdatagram_information(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *t break; } } - + } - - if(gf_m2ts_ipdatagram_reader(ip_datagram, ip_packet, offset)){ - - + + if(gf_m2ts_ipdatagram_reader(ip_datagram, ip_packet, offset)) { + + /* update the offset */ //offset += ip_packet->u32_total_length; offset += (ip_packet->u32_hdr_length*4) + ip_packet->u32_udp_data_size; @@ -874,55 +877,56 @@ void gf_m2ts_gather_ipdatagram_information(MPE_FEC_FRAME *mff,GF_M2TS_Demuxer *t i_streams = 0; i_targets = 0; - + assert( ip_platform->ip_streams ); i_streams = gf_list_count(ip_platform->ip_streams); - for(k=0;kip_streams, k); + for(k=0; kip_streams, k); - if(ip_stream_buff == NULL || ip_stream_buff->stream_info_gathered ==1) + if(ip_stream_buff == NULL || ip_stream_buff->stream_info_gathered ==1) { break; } else - { + { i_targets = gf_list_count(ip_stream_buff->targets); l=0; - for(j=0;jtargets, j); - + if(gf_m2ts_compare_ip(ip_packet->u8_rx_adr,ip_targets->address)) { - for(l=0;l<9;l++) + for(l=0; l<9; l++) { if(ip_targets->rx_port[l] == ip_packet->u32_rx_udp_port) goto next; if(ip_targets->rx_port[l] ==0) break; } - - ip_targets->rx_port[l] = ip_packet->u32_rx_udp_port; - ip_stream_buff->PID = mff->PID; - goto next; - - + + ip_targets->rx_port[l] = ip_packet->u32_rx_udp_port; + ip_stream_buff->PID = mff->PID; + goto next; + + } - + } } } } - }else{ + } else { - offset += (ip_packet->u32_hdr_length*4) + ip_packet->u32_udp_data_size; + offset += (ip_packet->u32_hdr_length*4) + ip_packet->u32_udp_data_size; } -next :; - +next : + ; + } empty_list(mff->mpe_holes); gf_list_del(mff->mpe_holes); - mff->mpe_holes = NULL; + mff->mpe_holes = NULL; gf_m2ts_Delete_IpPacket(ip_packet); } @@ -946,19 +950,19 @@ void gf_m2ts_print_mpe_info(GF_M2TS_Demuxer *ts) assert(ip_platform->ip_streams); i_streams = gf_list_count(ip_platform->ip_streams); - for(i=0;iip_streams, i); fprintf(stderr, "PID:%d \n",ip_stream_buff->PID); - fprintf(stderr, "Target IP Adress : \n"); + fprintf(stderr, "Target IP Adress : \n"); /*Print the target IP adress */ i_targets = gf_list_count(ip_stream_buff->targets); - for(j=0;jtargets, j); - + l=0; - + ip_adress = ip_targets->address; fprintf(stderr, "%d.%d.%d.%d/%d ",ip_adress[0],ip_adress[1],ip_adress[2],ip_adress[3],ip_targets->slash_mask); fprintf(stderr, "RX port :"); @@ -968,8 +972,8 @@ void gf_m2ts_print_mpe_info(GF_M2TS_Demuxer *ts) l++; } fprintf(stderr, "\n"); - - + + } /*Print the time slice fec descriptor */ @@ -978,60 +982,64 @@ void gf_m2ts_print_mpe_info(GF_M2TS_Demuxer *ts) if(ip_stream_buff->time_slice_fec.time_slicing==0) { fprintf(stderr, " No Time Slicing \n"); - }else + } else { - fprintf(stderr, " Time Slicing\n"); + fprintf(stderr, " Time Slicing\n"); } if(ip_stream_buff->time_slice_fec.mpe_fec==0) { fprintf(stderr, " No MPE FEC used \n"); - }else + } else { - fprintf(stderr, " MPE FEC used \n"); + fprintf(stderr, " MPE FEC used \n"); } - - switch(ip_stream_buff->time_slice_fec.frame_size) - { - case 0: - { - fprintf(stderr, " Frame size : 256 rows \n"); - fprintf(stderr, " Max Burst Duration 512 kbits\n"); - }break; - case 1: - { - fprintf(stderr, " Frame size : 512 rows \n"); - fprintf(stderr, " Max Burst Duration 1024 kbits\n"); - }break; - case 2: - { - fprintf(stderr, " Frame size : 768 rows \n"); - fprintf(stderr, " Max Burst Duration 1536 kbits\n"); - }break; - case 3: - { - fprintf(stderr, " Frame size : 1024 rows \n"); - fprintf(stderr, " Max Burst Duration 2048 kbits\n"); - }break; - default: - break; - } - fprintf(stderr, " Time Slice Fec ID : %x\n",ip_stream_buff->time_slice_fec.time_slice_fec_id); + switch(ip_stream_buff->time_slice_fec.frame_size) + { + case 0: + { + fprintf(stderr, " Frame size : 256 rows \n"); + fprintf(stderr, " Max Burst Duration 512 kbits\n"); + } + break; + case 1: + { + fprintf(stderr, " Frame size : 512 rows \n"); + fprintf(stderr, " Max Burst Duration 1024 kbits\n"); + } + break; + case 2: + { + fprintf(stderr, " Frame size : 768 rows \n"); + fprintf(stderr, " Max Burst Duration 1536 kbits\n"); + } + break; + case 3: + { + fprintf(stderr, " Frame size : 1024 rows \n"); + fprintf(stderr, " Max Burst Duration 2048 kbits\n"); + } + break; + default: + break; + } - /* Locayion descriptor */ + fprintf(stderr, " Time Slice Fec ID : %x\n",ip_stream_buff->time_slice_fec.time_slice_fec_id); - fprintf(stderr, "Location Descriptor \n"); - fprintf(stderr, "Network ID:%d \n",ip_stream_buff->location.network_id); - fprintf(stderr, "Original Network ID:%d \n",ip_stream_buff->location.original_network_id); - fprintf(stderr, "Transport Stream ID:%d \n",ip_stream_buff->location.transport_stream_id); - fprintf(stderr, "Service ID:%d \n",ip_stream_buff->location.service_id); - fprintf(stderr, "Component Tag:%d \n",ip_stream_buff->location.component_tag); + /* Locayion descriptor */ + fprintf(stderr, "Location Descriptor \n"); + fprintf(stderr, "Network ID:%d \n",ip_stream_buff->location.network_id); + fprintf(stderr, "Original Network ID:%d \n",ip_stream_buff->location.original_network_id); + fprintf(stderr, "Transport Stream ID:%d \n",ip_stream_buff->location.transport_stream_id); + fprintf(stderr, "Service ID:%d \n",ip_stream_buff->location.service_id); + fprintf(stderr, "Component Tag:%d \n",ip_stream_buff->location.component_tag); + + + getchar(); // attendre l'appuie d'une touche + } - getchar(); // attendre l'appuie d'une touche - } - } @@ -1052,7 +1060,7 @@ void socket_simu(GF_M2TS_IP_Packet *ip_packet, GF_M2TS_Demuxer *ts, Bool yield) ipv4_addr = GF_4CC(ip_packet->u8_rx_adr[0], ip_packet->u8_rx_adr[1], ip_packet->u8_rx_adr[2], ip_packet->u8_rx_adr[3]); nb_socket_struct = gf_list_count(ts->ip_platform->socket_struct); - for(i=0;iip_platform->socket_struct,i); if ((Sock_Struct->ipv4_addr==ipv4_addr)&& (Sock_Struct->port == (u16) ip_packet->u32_rx_udp_port)) { if (Sock_Struct->bind_failure) return; @@ -1077,12 +1085,12 @@ void socket_simu(GF_M2TS_IP_Packet *ip_packet, GF_M2TS_Demuxer *ts, Bool yield) e = gf_sk_setup_multicast(Sock_Struct->sock, name, ip_packet->u32_rx_udp_port, 1/*TTL - FIXME this should be in a cfg file*/, 0, NULL/*FIXME this should be in a cfg file*/); GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Setting up multicast socket for MPE on %s:%d\n", name, ip_packet->u32_rx_udp_port )); } else { - /* - binding of the socket to send data to port 4600 on the local machine + /* + binding of the socket to send data to port 4600 on the local machine the first adress / port parameters are NULL or 0 because there are not needed for sending UDP datagrams the second adress is "localhost" and the port is the destination port on localhost */ - e = gf_sk_bind(Sock_Struct->sock, "127.0.0.1", ip_packet->u32_rx_udp_port,/*name*/"127.0.0.1", ip_packet->u32_rx_udp_port, 0); + e = gf_sk_bind(Sock_Struct->sock, "127.0.0.1", ip_packet->u32_rx_udp_port,/*name*/"127.0.0.1", ip_packet->u32_rx_udp_port, 0); GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Setting up socket for MPE on 127.0.0.1:%d\n", ip_packet->u32_rx_udp_port )); } @@ -1098,7 +1106,7 @@ void socket_simu(GF_M2TS_IP_Packet *ip_packet, GF_M2TS_Demuxer *ts, Bool yield) // ******************************************************** e = gf_sk_send(Sock_Struct->sock, ip_packet->data, ip_packet->u32_udp_data_size - 8); - if (e != GF_OK){ + if (e != GF_OK) { fprintf(stderr, "Error sending to \n"); } if (yield) gf_sleep(10); @@ -1115,54 +1123,54 @@ Bool init_frame(MPE_FEC_FRAME * mff, u32 rows) { assert (mff != NULL); if (rows != 256 && rows != 512 && rows != 768 && rows != 1024) return 0; - mff->rows = rows ; + mff->rows = rows ; mff->col_adt = MPE_ADT_COLS; - mff->col_rs = MPE_RS_COLS; - mff->p_adt = (u8 *)gf_calloc(MPE_ADT_COLS*rows,sizeof(u8)); + mff->col_rs = MPE_RS_COLS; + mff->p_adt = (u8 *)gf_calloc(MPE_ADT_COLS*rows,sizeof(u8)); mff->p_rs = (u8 *)gf_calloc(MPE_RS_COLS*rows,sizeof(u8)); fprintf(stderr, "MPE_RS_COLS*rows :%d \n",MPE_RS_COLS*rows); - mff->capacity_total = mff->col_adt*rows; - mff->p_error_adt = (u32 *)gf_calloc(mff->col_adt*rows,sizeof(u32)); + mff->capacity_total = mff->col_adt*rows; + mff->p_error_adt = (u32 *)gf_calloc(mff->col_adt*rows,sizeof(u32)); mff->p_error_rs = (u32 *)gf_calloc(mff->col_rs*rows,sizeof(u32)); mff->current_offset_adt = 0; mff->current_offset_rs = 0; mff->ADT_done = 0; mff->PID = 0; // fprintf(stderr, "MFF: rows: %d, adt_col: %d, rs_col : %d, capacity : %d\n", mff->rows, mff->col_adt, mff->col_rs, mff->capacity_total ); - mff->mpe_holes = gf_list_new(); + mff->mpe_holes = gf_list_new(); mff->initialized = 1; return 1; } -void resetMFF(MPE_FEC_FRAME * mff) +void resetMFF(MPE_FEC_FRAME * mff) { mff->current_offset_adt = 0; - mff->current_offset_rs = 0; + mff->current_offset_rs = 0; memset(mff->p_error_adt, 0, mff->col_adt * mff->rows*sizeof(u32)); memset(mff->p_error_rs, 0, mff->col_rs * mff->rows*sizeof(u32)); - memset(mff->p_adt, 0, MPE_ADT_COLS* mff->rows*sizeof(u8)); + memset(mff->p_adt, 0, MPE_ADT_COLS* mff->rows*sizeof(u8)); memset(mff->p_rs, 0, MPE_RS_COLS* mff->rows*sizeof(u8)); mff->ADT_done = 0; mff->PID = 0; - if(mff->mpe_holes){ + if(mff->mpe_holes) { empty_list(mff->mpe_holes); //gf_list_del(mff->mpe_holes); } - + } /* return a row of appplicatio data table*/ void getRowFromADT(MPE_FEC_FRAME * mff, u32 index, u8* adt_row) { u32 i = 0 ; - u32 base = 0; + u32 base = 0; //assert ( sizeof ( adt_row ) >= MPE_ADT_COLS ); for ( i = 0; i < mff->col_adt ; i ++ ) { adt_row [ i ] = mff -> p_adt [ index + base ]; - base += mff-> rows ; + base += mff-> rows ; } } @@ -1170,44 +1178,44 @@ void getRowFromADT(MPE_FEC_FRAME * mff, u32 index, u8* adt_row) void getRowFromRS (MPE_FEC_FRAME * mff, u32 index, u8* rs_row) { u32 i = 0 ; - u32 base = 0; + u32 base = 0; assert (rs_row != NULL ); //assert (sizeof ( rs_row ) >= MPE_ADT_COLS ); for ( i = 0; i < mff->col_rs ; i ++ ) { rs_row [ i ] = mff -> p_rs [ index + base ]; - base += mff -> rows ; + base += mff -> rows ; } } void setRowRS(MPE_FEC_FRAME *mff, u32 index, u8 *p_rs) { - u32 i = 0; - u32 base = 0; + u32 i = 0; + u32 base = 0; assert ( p_rs != NULL ); //assert ( sizeof (p_rs ) >= MPE_RS_COLS ) ; for ( i = 0; i < mff -> col_rs; i ++ ) { mff -> p_rs [ base + index ] = p_rs [ i]; - base += mff -> rows; + base += mff -> rows; } } void addPadding(MPE_FEC_FRAME *mff , u32 offset) { - u32 i = 0; + u32 i = 0; fprintf(stderr, "add paddings from %d to the end %d\n", offset, mff->capacity_total ); for ( i = offset ; i capacity_total; i ++ ) - mff -> p_adt [i] = 0xff ; + mff -> p_adt [i] = 0xff ; } #ifdef GPAC_UNUSED_FUNC static void print_bytes2(u8 * data, u32 length ) /*print_bytes2 */ { - u32 i = 0; - u32 row_num = 0; - u32 k = 0; + u32 i = 0; + u32 row_num = 0; + u32 k = 0; for ( i = 0; i < length ; i ++ ) { if (k == 0) { - fprintf(stderr, "%x0 : ", row_num); - k = 0; + fprintf(stderr, "%x0 : ", row_num); + k = 0; } fprintf(stderr, "%#x ", data[i]); k++; @@ -1224,9 +1232,9 @@ static void print_bytes2(u8 * data, u32 length ) /*print_bytes2 */ void setIpDatagram(MPE_FEC_FRAME * mff, u32 offset, u8* dgram, u32 length ) { MPE_Error_Holes *mpe_error_holes; - + GF_SAFEALLOC(mpe_error_holes,MPE_Error_Holes); - + if (offset >= mff->capacity_total) { fprintf(stderr, "Offset %d bigger than capacity %d \n", offset, mff->capacity_total ); @@ -1237,7 +1245,7 @@ void setIpDatagram(MPE_FEC_FRAME * mff, u32 offset, u8* dgram, u32 length ) if (mff->current_offset_adt != offset) { if (mff->current_offset_adt > offset) { fprintf(stderr, "We missed an offset reset (%d to %d)\n", mff->current_offset_adt, offset); - mff->current_offset_adt = offset; + mff->current_offset_adt = offset; } else { fprintf(stderr, "there is an error hole in the ADT from %d to %d \n", mff->current_offset_adt, offset); } @@ -1246,24 +1254,24 @@ void setIpDatagram(MPE_FEC_FRAME * mff, u32 offset, u8* dgram, u32 length ) mpe_error_holes->length = offset - mff->current_offset_adt; gf_list_add(mff->mpe_holes,mpe_error_holes); mff->current_offset_adt = offset ; // update the offset - } - + } + memcpy(mff->p_adt+mff->current_offset_adt,dgram, length); mff->current_offset_adt = offset+length ; // update the offset - + } /*set RS data into mpe fec frame*/ -void setColRS( MPE_FEC_FRAME * mff, u32 offset, u8 * pds, u32 length ) +void setColRS( MPE_FEC_FRAME * mff, u32 offset, u8 * pds, u32 length ) { if ( mff->current_offset_rs != offset) { fprintf(stderr, "there is an error hole in the RS from %d to %d \n", mff->current_offset_rs, offset ); setErrorIndicator( mff->p_error_rs , mff->current_offset_rs , (offset - mff->current_offset_rs)*sizeof(u32)); - mff->current_offset_rs = offset; - } + mff->current_offset_rs = offset; + } assert(mff->rows == length); memcpy(mff->p_rs + mff->current_offset_rs , pds, length*sizeof(u8) ); - mff->current_offset_rs = offset + length ; - + mff->current_offset_rs = offset + length ; + } void getColRS(MPE_FEC_FRAME * mff, u32 offset, u8 * pds, u32 length) @@ -1273,32 +1281,32 @@ void getColRS(MPE_FEC_FRAME * mff, u32 offset, u8 * pds, u32 length) void getErrorPositions(MPE_FEC_FRAME *mff, u32 row, u32 * errPositions) { - u32 i = 0 ; - u32 base = row; + u32 i = 0 ; + u32 base = row; /*get error from adt*/ for ( i = 0; i < mff->col_adt ; i ++ ) { - errPositions [i] = mff->p_error_adt[base ]; - base += mff->rows; + errPositions [i] = mff->p_error_adt[base ]; + base += mff->rows; } - base = row; + base = row; for ( i = mff->col_adt ; i < mff->col_adt + mff-> col_rs ; i ++ ) { - errPositions [i] = mff->p_error_rs [ base ]; - base += mff->rows ; + errPositions [i] = mff->p_error_rs [ base ]; + base += mff->rows ; } } u32 getErrasurePositions( MPE_FEC_FRAME *mff , u32 row, u32 *errasures) { - u32 i = 0; + u32 i = 0; u32 base = row; - u32 nb = 0; + u32 nb = 0; u32 k =0; for ( i = 0 ; i < mff-> col_rs ; i ++ ) { if ( mff->p_error_rs[base] == 1 ) { - errasures [k++] = mff->p_error_rs [ base ]; + errasures [k++] = mff->p_error_rs [ base ]; nb ++; } - base += mff->rows ; + base += mff->rows ; } fprintf(stderr, " the erasure locations is:\n"); for ( i = 0; i < nb ; i ++ ) diff --git a/src/media_tools/filestreamer.c b/src/media_tools/filestreamer.c index 4134726..877d85d 100644 --- a/src/media_tools/filestreamer.c +++ b/src/media_tools/filestreamer.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre, Cyril Concolato + * Authors: Jean Le Feuvre, Cyril Concolato * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,7 +56,7 @@ typedef struct __tag_rtp_track /*loaded AU info*/ GF_ISOSample *au; - u32 current_au; + u32 current_au; u32 sample_duration; u32 sample_desc_index; /*normalized DTS in micro-sec*/ @@ -76,7 +76,7 @@ struct __isom_rtp_streamer Bool loop; Bool force_mpeg4_generic; /*timeline origin of our session (all tracks) in microseconds*/ - u32 timelineOrigin; + u32 timelineOrigin; /*list of streams in session*/ GF_RTPTrack *stream; @@ -91,8 +91,8 @@ struct __isom_rtp_streamer -static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename, char **out_sdp_buffer) -{ +static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename, char **out_sdp_buffer) +{ GF_RTPTrack *track; FILE *sdp_out; char filename[GF_MAX_PATH]; @@ -173,7 +173,7 @@ static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpf gf_isom_get_ismacryp_info(streamer->isom, track->track_num, 1, NULL, NULL, NULL, NULL, &KMS, NULL, NULL, NULL); - /*TODO retrieve DIMS content encoding from track to set the flags */ + /*TODO retrieve DIMS content encoding from track to set the flags */ gf_rtp_streamer_append_sdp_extended(track->rtp, gf_isom_get_track_id(streamer->isom, track->track_num), dsi, dsi_len, streamer->isom, track->track_num, (char *)KMS, w, h, &sdp_media); if (streamer->base_track) gf_rtp_streamer_append_sdp_decoding_dependency(streamer->isom, track->track_num, payload_type, &sdp_media); @@ -183,7 +183,7 @@ static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpf } if (dcd) gf_odf_desc_del((GF_Descriptor *)dcd); - + track = track->next; } fprintf(sdp_out, "\n"); @@ -204,15 +204,15 @@ static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpf gf_free(payload_type); return GF_OK; -} +} GF_EXPORT -GF_Err gf_isom_streamer_write_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename) +GF_Err gf_isom_streamer_write_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename) { return gf_isom_streamer_setup_sdp(streamer, sdpfilename, NULL); } -GF_Err gf_isom_streamer_get_sdp(GF_ISOMRTPStreamer *streamer, char **out_sdp_buffer) +GF_Err gf_isom_streamer_get_sdp(GF_ISOMRTPStreamer *streamer, char **out_sdp_buffer) { return gf_isom_streamer_setup_sdp(streamer, NULL, out_sdp_buffer); } @@ -239,7 +239,7 @@ void gf_isom_streamer_reset(GF_ISOMRTPStreamer *streamer, Bool is_loop) } GF_EXPORT -GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ahead_delay, s32 max_sleep_time) +GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ahead_delay, s32 max_sleep_time) { GF_Err e = GF_OK; GF_RTPTrack *track, *to_send; @@ -248,7 +248,7 @@ GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ u64 min_ts, dts, cts; if (!streamer) return GF_BAD_PARAM; - + /*browse all sessions and locate most mature stream*/ to_send = NULL; min_ts = (u64) -1; @@ -300,7 +300,7 @@ GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ /*no input data ...*/ if( !to_send) return GF_EOS; - + /*we are about to send scalable base: trigger RTCP reports with the same NTP. This avoids NTP drift due to system clock precision which could break sync decoding*/ if (!streamer->first_RTCP_sent || (streamer->base_track && streamer->base_track==to_send->track_num)) { @@ -321,8 +321,8 @@ GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ min_ts /= 1000; if (max_sleep_time) { - diff = ((u32) min_ts) - gf_sys_clock(); - if (diff>max_sleep_time) + diff = ((u32) min_ts) - gf_sys_clock(); + if (diff>max_sleep_time) return GF_OK; } @@ -330,7 +330,7 @@ GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ /*sleep until TS is mature*/ while (1) { diff = ((u32) min_ts) - gf_sys_clock(); - + if (diff > send_ahead_delay) { gf_sleep(1); } else { @@ -406,8 +406,8 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d GF_Err e = GF_OK; const char *opt = NULL; /*GF_Config *configFile = NULL; */ - u32 i, max_ptime, au_sn_len; - u8 payt; + u32 i, max_ptime, au_sn_len; + u8 payt; GF_ISOFile *file; GF_RTPTrack *track, *prev_track; u16 first_port; @@ -438,14 +438,14 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d sess_data_size = 0; prev_track = NULL; - + nb_tracks = gf_isom_get_track_count(streamer->isom); for (i=0; iisom, track->track_num, 1); if (esd) { streamType = esd->decoderConfig->streamType; @@ -514,7 +514,7 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d if (gf_isom_has_sync_shadows(streamer->isom, track->track_num) || gf_isom_has_sample_dependency(streamer->isom, track->track_num)) flags |= GP_RTP_PCK_SYSTEMS_CAROUSEL; } - + if (esd->decoderConfig->decoderSpecificInfo) { dsi = esd->decoderConfig->decoderSpecificInfo->data; dsi_len = esd->decoderConfig->decoderSpecificInfo->dataLength; @@ -524,7 +524,7 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d gf_odf_desc_del((GF_Descriptor*)esd); } } - break; + break; case GF_ISOM_SUBTYPE_AVC_H264: case GF_ISOM_SUBTYPE_AVC2_H264: case GF_ISOM_SUBTYPE_AVC3_H264: @@ -550,7 +550,7 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d } break; } - break; + break; case GF_ISOM_SUBTYPE_HVC1: case GF_ISOM_SUBTYPE_HEV1: case GF_ISOM_SUBTYPE_HVC2: @@ -575,13 +575,13 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d flags |= GP_RTP_PCK_USE_MULTI; break; } - break; + break; default: streamType = GF_STREAM_4CC; oti = TrackMediaSubType; break; } - + /*get sample info*/ gf_media_get_sample_average_infos(streamer->isom, track->track_num, &MinSize, &MaxSize, &avgTS, &maxDTSDelta, &const_dur, &bandwidth); @@ -591,17 +591,17 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d if (use_sel_enc) flags |= GP_RTP_PCK_SELECTIVE_ENCRYPTION; } - track->rtp = gf_rtp_streamer_new_extended(streamType, oti, track->timescale, - (char *) streamer->dest_ip, track->port, path_mtu, ttl, ifce_addr, - flags, dsi, dsi_len, - payt, samplerate, nb_ch, - is_crypted, IV_length, KI_length, - MinSize, MaxSize, avgTS, maxDTSDelta, const_dur, bandwidth, max_ptime, au_sn_len); + track->rtp = gf_rtp_streamer_new_extended(streamType, oti, track->timescale, + (char *) streamer->dest_ip, track->port, path_mtu, ttl, ifce_addr, + flags, dsi, dsi_len, + payt, samplerate, nb_ch, + is_crypted, IV_length, KI_length, + MinSize, MaxSize, avgTS, maxDTSDelta, const_dur, bandwidth, max_ptime, au_sn_len); if (!track->rtp) { GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("Could not initialize RTP streamer: %s\n", gf_error_to_string(e))); goto exit; - } + } payt++; track->microsec_ts_scale = 1000000; @@ -626,10 +626,10 @@ GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_d exit: gf_free(streamer); return NULL; -} +} GF_EXPORT -void gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer) +void gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer) { GF_RTPTrack *track = streamer->stream; while (track) { diff --git a/src/media_tools/gpac_ogg.c b/src/media_tools/gpac_ogg.c index 80e490b..7b633a9 100644 --- a/src/media_tools/gpac_ogg.c +++ b/src/media_tools/gpac_ogg.c @@ -29,426 +29,427 @@ #define BUFFER_INCREMENT 256 static u32 mask[]= -{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, - 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, - 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, - 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, - 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, - 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, - 0x3fffffff,0x7fffffff,0xffffffff }; +{ 0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, + 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, + 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, + 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, + 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, + 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, + 0x3fffffff,0x7fffffff,0xffffffff +}; static u32 mask8B[]= {0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; -void oggpack_writeinit(oggpack_buffer *b){ - memset(b,0,sizeof(*b)); - b->ptr = b->buffer = (unsigned char *)gf_malloc(BUFFER_INCREMENT); - b->buffer[0]='\0'; - b->storage=BUFFER_INCREMENT; +void oggpack_writeinit(oggpack_buffer *b) { + memset(b,0,sizeof(*b)); + b->ptr = b->buffer = (unsigned char *)gf_malloc(BUFFER_INCREMENT); + b->buffer[0]='\0'; + b->storage=BUFFER_INCREMENT; } -void oggpackB_writeinit(oggpack_buffer *b){ - oggpack_writeinit(b); +void oggpackB_writeinit(oggpack_buffer *b) { + oggpack_writeinit(b); } -void oggpack_writetrunc(oggpack_buffer *b,s32 bits){ - s32 bytes=bits>>3; - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask[bits]; +void oggpack_writetrunc(oggpack_buffer *b,s32 bits) { + s32 bytes=bits>>3; + bits-=bytes*8; + b->ptr=b->buffer+bytes; + b->endbit=bits; + b->endbyte=bytes; + *b->ptr&=mask[bits]; } -void oggpackB_writetrunc(oggpack_buffer *b,s32 bits){ - s32 bytes=bits>>3; - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask8B[bits]; +void oggpackB_writetrunc(oggpack_buffer *b,s32 bits) { + s32 bytes=bits>>3; + bits-=bytes*8; + b->ptr=b->buffer+bytes; + b->endbit=bits; + b->endbyte=bytes; + *b->ptr&=mask8B[bits]; } /* Takes only up to 32 bits. */ -void oggpack_write(oggpack_buffer *b,u32 value,s32 bits){ - if(b->endbyte+4>=b->storage){ - b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value&=mask[bits]; - bits+=b->endbit; - - b->ptr[0]|=value<endbit; - - if(bits>=8){ - b->ptr[1]=value>>(8-b->endbit); - if(bits>=16){ - b->ptr[2]=value>>(16-b->endbit); - if(bits>=24){ - b->ptr[3]=value>>(24-b->endbit); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=value>>(32-b->endbit); - else - b->ptr[4]=0; +void oggpack_write(oggpack_buffer *b,u32 value,s32 bits) { + if(b->endbyte+4>=b->storage) { + b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage+BUFFER_INCREMENT); + b->storage+=BUFFER_INCREMENT; + b->ptr=b->buffer+b->endbyte; } - } - } - } - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; + value&=mask[bits]; + bits+=b->endbit; + + b->ptr[0]|=value<endbit; + + if(bits>=8) { + b->ptr[1]=value>>(8-b->endbit); + if(bits>=16) { + b->ptr[2]=value>>(16-b->endbit); + if(bits>=24) { + b->ptr[3]=value>>(24-b->endbit); + if(bits>=32) { + if(b->endbit) + b->ptr[4]=value>>(32-b->endbit); + else + b->ptr[4]=0; + } + } + } + } + + b->endbyte+=bits/8; + b->ptr+=bits/8; + b->endbit=bits&7; } /* Takes only up to 32 bits. */ -void oggpackB_write(oggpack_buffer *b,u32 value,s32 bits){ - if(b->endbyte+4>=b->storage){ - b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value=(value&mask[bits])<<(32-bits); - bits+=b->endbit; - - b->ptr[0]|=value>>(24+b->endbit); - - if(bits>=8){ - b->ptr[1]=value>>(16+b->endbit); - if(bits>=16){ - b->ptr[2]=value>>(8+b->endbit); - if(bits>=24){ - b->ptr[3]=value>>(b->endbit); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=value<<(8-b->endbit); - else - b->ptr[4]=0; +void oggpackB_write(oggpack_buffer *b,u32 value,s32 bits) { + if(b->endbyte+4>=b->storage) { + b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage+BUFFER_INCREMENT); + b->storage+=BUFFER_INCREMENT; + b->ptr=b->buffer+b->endbyte; } - } - } - } - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; + value=(value&mask[bits])<<(32-bits); + bits+=b->endbit; + + b->ptr[0]|=value>>(24+b->endbit); + + if(bits>=8) { + b->ptr[1]=value>>(16+b->endbit); + if(bits>=16) { + b->ptr[2]=value>>(8+b->endbit); + if(bits>=24) { + b->ptr[3]=value>>(b->endbit); + if(bits>=32) { + if(b->endbit) + b->ptr[4]=value<<(8-b->endbit); + else + b->ptr[4]=0; + } + } + } + } + + b->endbyte+=bits/8; + b->ptr+=bits/8; + b->endbit=bits&7; } -void oggpack_writealign(oggpack_buffer *b){ - s32 bits=8-b->endbit; - if(bits<8) - oggpack_write(b,0,bits); +void oggpack_writealign(oggpack_buffer *b) { + s32 bits=8-b->endbit; + if(bits<8) + oggpack_write(b,0,bits); } -void oggpackB_writealign(oggpack_buffer *b){ - s32 bits=8-b->endbit; - if(bits<8) - oggpackB_write(b,0,bits); +void oggpackB_writealign(oggpack_buffer *b) { + s32 bits=8-b->endbit; + if(bits<8) + oggpackB_write(b,0,bits); } static void oggpack_writecopy_helper(oggpack_buffer *b, - void *source, - s32 bits, - void (*w)(oggpack_buffer *, - u32, - s32), - s32 msb){ - unsigned char *ptr=(unsigned char *)source; - - s32 bytes=bits/8; - bits-=bytes*8; + void *source, + s32 bits, + void (*w)(oggpack_buffer *, + u32, + s32), + s32 msb) { + unsigned char *ptr=(unsigned char *)source; + + s32 bytes=bits/8; + bits-=bytes*8; + + if(b->endbit) { + s32 i; + /* unaligned copy. Do it the hard way. */ + for(i=0; iendbyte+bytes+1>=b->storage) { + b->storage=b->endbyte+bytes+BUFFER_INCREMENT; + b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage); + b->ptr=b->buffer+b->endbyte; + } + + memmove(b->ptr,source,bytes); + b->ptr+=bytes; + b->buffer+=bytes; + *b->ptr=0; - if(b->endbit){ - s32 i; - /* unaligned copy. Do it the hard way. */ - for(i=0;iendbyte+bytes+1>=b->storage){ - b->storage=b->endbyte+bytes+BUFFER_INCREMENT; - b->buffer = (unsigned char *)gf_realloc(b->buffer,b->storage); - b->ptr=b->buffer+b->endbyte; - } - - memmove(b->ptr,source,bytes); - b->ptr+=bytes; - b->buffer+=bytes; - *b->ptr=0; - - } - if(bits){ - if(msb) - w(b,(u32)(ptr[bytes]>>(8-bits)),bits); - else - w(b,(u32)(ptr[bytes]),bits); - } + } + if(bits) { + if(msb) + w(b,(u32)(ptr[bytes]>>(8-bits)),bits); + else + w(b,(u32)(ptr[bytes]),bits); + } } -void oggpack_writecopy(oggpack_buffer *b,void *source,s32 bits){ - oggpack_writecopy_helper(b,source,bits,oggpack_write,0); +void oggpack_writecopy(oggpack_buffer *b,void *source,s32 bits) { + oggpack_writecopy_helper(b,source,bits,oggpack_write,0); } -void oggpackB_writecopy(oggpack_buffer *b,void *source,s32 bits){ - oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); +void oggpackB_writecopy(oggpack_buffer *b,void *source,s32 bits) { + oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); } -void oggpack_reset(oggpack_buffer *b){ - b->ptr=b->buffer; - b->buffer[0]=0; - b->endbit=b->endbyte=0; +void oggpack_reset(oggpack_buffer *b) { + b->ptr=b->buffer; + b->buffer[0]=0; + b->endbit=b->endbyte=0; } -void oggpackB_reset(oggpack_buffer *b){ - oggpack_reset(b); +void oggpackB_reset(oggpack_buffer *b) { + oggpack_reset(b); } -void oggpack_writeclear(oggpack_buffer *b){ - gf_free(b->buffer); - memset(b,0,sizeof(*b)); +void oggpack_writeclear(oggpack_buffer *b) { + gf_free(b->buffer); + memset(b,0,sizeof(*b)); } -void oggpackB_writeclear(oggpack_buffer *b){ - oggpack_writeclear(b); +void oggpackB_writeclear(oggpack_buffer *b) { + oggpack_writeclear(b); } -void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,s32 bytes){ - memset(b,0,sizeof(*b)); - b->buffer=b->ptr=buf; - b->storage=bytes; +void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,s32 bytes) { + memset(b,0,sizeof(*b)); + b->buffer=b->ptr=buf; + b->storage=bytes; } -void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,s32 bytes){ - oggpack_readinit(b,buf,bytes); +void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,s32 bytes) { + oggpack_readinit(b,buf,bytes); } /* Read in bits without advancing the bitptr; bits <= 32 */ -s32 oggpack_look(oggpack_buffer *b,s32 bits){ - u32 ret; - u32 m=mask[bits]; - - bits+=b->endbit; - - if(b->endbyte+4>=b->storage){ - /* not the main path */ - if(b->endbyte*8+bits>b->storage*8)return(-1); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]<<(32-b->endbit); - } - } - } - return(m&ret); +s32 oggpack_look(oggpack_buffer *b,s32 bits) { + u32 ret; + u32 m=mask[bits]; + + bits+=b->endbit; + + if(b->endbyte+4>=b->storage) { + /* not the main path */ + if(b->endbyte*8+bits>b->storage*8)return(-1); + } + + ret=b->ptr[0]>>b->endbit; + if(bits>8) { + ret|=b->ptr[1]<<(8-b->endbit); + if(bits>16) { + ret|=b->ptr[2]<<(16-b->endbit); + if(bits>24) { + ret|=b->ptr[3]<<(24-b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]<<(32-b->endbit); + } + } + } + return(m&ret); } /* Read in bits without advancing the bitptr; bits <= 32 */ -s32 oggpackB_look(oggpack_buffer *b,s32 bits){ - u32 ret; - s32 m=32-bits; +s32 oggpackB_look(oggpack_buffer *b,s32 bits) { + u32 ret; + s32 m=32-bits; - bits+=b->endbit; + bits+=b->endbit; - if(b->endbyte+4>=b->storage){ - /* not the main path */ - if(b->endbyte*8+bits>b->storage*8)return(-1); - } - - ret=b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - return (ret>>(m>>1))>>((m+1)>>1); + if(b->endbyte+4>=b->storage) { + /* not the main path */ + if(b->endbyte*8+bits>b->storage*8)return(-1); + } + + ret=b->ptr[0]<<(24+b->endbit); + if(bits>8) { + ret|=b->ptr[1]<<(16+b->endbit); + if(bits>16) { + ret|=b->ptr[2]<<(8+b->endbit); + if(bits>24) { + ret|=b->ptr[3]<<(b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]>>(8-b->endbit); + } + } + } + return (ret>>(m>>1))>>((m+1)>>1); } -s32 oggpack_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>b->endbit)&1); +s32 oggpack_look1(oggpack_buffer *b) { + if(b->endbyte>=b->storage)return(-1); + return((b->ptr[0]>>b->endbit)&1); } -s32 oggpackB_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>(7-b->endbit))&1); +s32 oggpackB_look1(oggpack_buffer *b) { + if(b->endbyte>=b->storage)return(-1); + return((b->ptr[0]>>(7-b->endbit))&1); } -void oggpack_adv(oggpack_buffer *b,s32 bits){ - bits+=b->endbit; - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; +void oggpack_adv(oggpack_buffer *b,s32 bits) { + bits+=b->endbit; + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; } -void oggpackB_adv(oggpack_buffer *b,s32 bits){ - oggpack_adv(b,bits); +void oggpackB_adv(oggpack_buffer *b,s32 bits) { + oggpack_adv(b,bits); } -void oggpack_adv1(oggpack_buffer *b){ - if(++(b->endbit)>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } +void oggpack_adv1(oggpack_buffer *b) { + if(++(b->endbit)>7) { + b->endbit=0; + b->ptr++; + b->endbyte++; + } } -void oggpackB_adv1(oggpack_buffer *b){ - oggpack_adv1(b); +void oggpackB_adv1(oggpack_buffer *b) { + oggpack_adv1(b); } /* bits <= 32 */ -s32 oggpack_read(oggpack_buffer *b,s32 bits){ - u32 ret; - u32 m=mask[bits]; - - bits+=b->endbit; - - if(b->endbyte+4>=b->storage){ - /* not the main path */ - ret=(u32) (-1); - if(b->endbyte*8+bits>b->storage*8)goto overflow; - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit){ - ret|=b->ptr[4]<<(32-b->endbit); +s32 oggpack_read(oggpack_buffer *b,s32 bits) { + u32 ret; + u32 m=mask[bits]; + + bits+=b->endbit; + + if(b->endbyte+4>=b->storage) { + /* not the main path */ + ret=(u32) (-1); + if(b->endbyte*8+bits>b->storage*8)goto overflow; } - } - } - } - ret&=m; - - overflow: - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return(ret); + ret=b->ptr[0]>>b->endbit; + if(bits>8) { + ret|=b->ptr[1]<<(8-b->endbit); + if(bits>16) { + ret|=b->ptr[2]<<(16-b->endbit); + if(bits>24) { + ret|=b->ptr[3]<<(24-b->endbit); + if(bits>32 && b->endbit) { + ret|=b->ptr[4]<<(32-b->endbit); + } + } + } + } + ret&=m; + +overflow: + + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return(ret); } /* bits <= 32 */ -s32 oggpackB_read(oggpack_buffer *b,s32 bits){ - u32 ret; - s32 m=32-bits; - - bits+=b->endbit; - - if(b->endbyte+4>=b->storage){ - /* not the main path */ - ret=(u32) (-1); - if(b->endbyte*8+bits>b->storage*8)goto overflow; - } - - ret=b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - ret=(ret>>(m>>1))>>((m+1)>>1); - - overflow: - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return(ret); -} - -s32 oggpack_read1(oggpack_buffer *b){ - u32 ret; - - if(b->endbyte>=b->storage){ - /* not the main path */ - ret=(u32) (-1); - goto overflow; - } - - ret=(b->ptr[0]>>b->endbit)&1; - - overflow: - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return(ret); -} - -s32 oggpackB_read1(oggpack_buffer *b){ - u32 ret; - - if(b->endbyte>=b->storage){ - /* not the main path */ - ret=(u32) (-1); - goto overflow; - } - - ret=(b->ptr[0]>>(7-b->endbit))&1; - - overflow: - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return(ret); -} - -s32 oggpack_bytes(oggpack_buffer *b){ - return(b->endbyte+(b->endbit+7)/8); -} - -s32 oggpack_bits(oggpack_buffer *b){ - return(b->endbyte*8+b->endbit); -} - -s32 oggpackB_bytes(oggpack_buffer *b){ - return oggpack_bytes(b); -} - -s32 oggpackB_bits(oggpack_buffer *b){ - return oggpack_bits(b); -} - -unsigned char *oggpack_get_buffer(oggpack_buffer *b){ - return(b->buffer); -} - -unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ - return oggpack_get_buffer(b); +s32 oggpackB_read(oggpack_buffer *b,s32 bits) { + u32 ret; + s32 m=32-bits; + + bits+=b->endbit; + + if(b->endbyte+4>=b->storage) { + /* not the main path */ + ret=(u32) (-1); + if(b->endbyte*8+bits>b->storage*8)goto overflow; + } + + ret=b->ptr[0]<<(24+b->endbit); + if(bits>8) { + ret|=b->ptr[1]<<(16+b->endbit); + if(bits>16) { + ret|=b->ptr[2]<<(8+b->endbit); + if(bits>24) { + ret|=b->ptr[3]<<(b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]>>(8-b->endbit); + } + } + } + ret=(ret>>(m>>1))>>((m+1)>>1); + +overflow: + + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return(ret); +} + +s32 oggpack_read1(oggpack_buffer *b) { + u32 ret; + + if(b->endbyte>=b->storage) { + /* not the main path */ + ret=(u32) (-1); + goto overflow; + } + + ret=(b->ptr[0]>>b->endbit)&1; + +overflow: + + b->endbit++; + if(b->endbit>7) { + b->endbit=0; + b->ptr++; + b->endbyte++; + } + return(ret); +} + +s32 oggpackB_read1(oggpack_buffer *b) { + u32 ret; + + if(b->endbyte>=b->storage) { + /* not the main path */ + ret=(u32) (-1); + goto overflow; + } + + ret=(b->ptr[0]>>(7-b->endbit))&1; + +overflow: + + b->endbit++; + if(b->endbit>7) { + b->endbit=0; + b->ptr++; + b->endbyte++; + } + return(ret); +} + +s32 oggpack_bytes(oggpack_buffer *b) { + return(b->endbyte+(b->endbit+7)/8); +} + +s32 oggpack_bits(oggpack_buffer *b) { + return(b->endbyte*8+b->endbit); +} + +s32 oggpackB_bytes(oggpack_buffer *b) { + return oggpack_bytes(b); +} + +s32 oggpackB_bits(oggpack_buffer *b) { + return oggpack_bits(b); +} + +unsigned char *oggpack_get_buffer(oggpack_buffer *b) { + return(b->buffer); +} + +unsigned char *oggpackB_get_buffer(oggpack_buffer *b) { + return oggpack_get_buffer(b); } @@ -456,47 +457,47 @@ unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ /* A complete description of Ogg framing exists in docs/framing.html */ -s32 ogg_page_version(ogg_page *og){ - return((s32)(og->header[4])); +s32 ogg_page_version(ogg_page *og) { + return((s32)(og->header[4])); } -s32 ogg_page_continued(ogg_page *og){ - return((s32)(og->header[5]&0x01)); +s32 ogg_page_continued(ogg_page *og) { + return((s32)(og->header[5]&0x01)); } -s32 ogg_page_bos(ogg_page *og){ - return((s32)(og->header[5]&0x02)); +s32 ogg_page_bos(ogg_page *og) { + return((s32)(og->header[5]&0x02)); } -s32 ogg_page_eos(ogg_page *og){ - return((s32)(og->header[5]&0x04)); +s32 ogg_page_eos(ogg_page *og) { + return((s32)(og->header[5]&0x04)); } -s64 ogg_page_granulepos(ogg_page *og){ - unsigned char *page=og->header; - s64 granulepos=page[13]&(0xff); - granulepos= (granulepos<<8)|(page[12]&0xff); - granulepos= (granulepos<<8)|(page[11]&0xff); - granulepos= (granulepos<<8)|(page[10]&0xff); - granulepos= (granulepos<<8)|(page[9]&0xff); - granulepos= (granulepos<<8)|(page[8]&0xff); - granulepos= (granulepos<<8)|(page[7]&0xff); - granulepos= (granulepos<<8)|(page[6]&0xff); - return(granulepos); +s64 ogg_page_granulepos(ogg_page *og) { + unsigned char *page=og->header; + s64 granulepos=page[13]&(0xff); + granulepos= (granulepos<<8)|(page[12]&0xff); + granulepos= (granulepos<<8)|(page[11]&0xff); + granulepos= (granulepos<<8)|(page[10]&0xff); + granulepos= (granulepos<<8)|(page[9]&0xff); + granulepos= (granulepos<<8)|(page[8]&0xff); + granulepos= (granulepos<<8)|(page[7]&0xff); + granulepos= (granulepos<<8)|(page[6]&0xff); + return(granulepos); } -s32 ogg_page_serialno(ogg_page *og){ - return(og->header[14] | - (og->header[15]<<8) | - (og->header[16]<<16) | - (og->header[17]<<24)); +s32 ogg_page_serialno(ogg_page *og) { + return(og->header[14] | + (og->header[15]<<8) | + (og->header[16]<<16) | + (og->header[17]<<24)); } - -s32 ogg_page_pageno(ogg_page *og){ - return(og->header[18] | - (og->header[19]<<8) | - (og->header[20]<<16) | - (og->header[21]<<24)); + +s32 ogg_page_pageno(ogg_page *og) { + return(og->header[18] | + (og->header[19]<<8) | + (og->header[20]<<16) | + (og->header[21]<<24)); } @@ -508,21 +509,21 @@ s32 ogg_page_pageno(ogg_page *og){ /* NOTE: If a page consists of a packet begun on a previous page, and a new packet begun (but not completed) on this page, the return will be: - ogg_page_packets(page) ==1, + ogg_page_packets(page) ==1, ogg_page_continued(page) !=0 If a page happens to be a single packet that was begun on a previous page, and spans to the next page (in the case of a three or -more page packet), the return will be: - ogg_page_packets(page) ==0, +more page packet), the return will be: + ogg_page_packets(page) ==0, ogg_page_continued(page) !=0 */ -s32 ogg_page_packets(ogg_page *og){ - s32 i,n=og->header[26],count=0; - for(i=0;iheader[27+i]<255)count++; - return(count); +s32 ogg_page_packets(ogg_page *og) { + s32 i,n=og->header[26],count=0; + for(i=0; iheader[27+i]<255)count++; + return(count); } @@ -530,220 +531,221 @@ s32 ogg_page_packets(ogg_page *og){ /* helper to initialize lookup for direct-table CRC (illustrative; we use the static init below) */ -static u32 _ogg_crc_entry(u32 index){ - s32 i; - u32 r; +static u32 _ogg_crc_entry(u32 index) { + s32 i; + u32 r; - r = index << 24; - for (i=0; i<8; i++) - if (r & 0x80000000UL) - r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator + r = index << 24; + for (i=0; i<8; i++) + if (r & 0x80000000UL) + r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator polynomial, although we use an unreflected alg and an init/final of 0, not 0xffffffff */ - else - r<<=1; - return (r & 0xffffffffUL); + else + r<<=1; + return (r & 0xffffffffUL); } #endif -static u32 crc_lookup[256]={ - 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, - 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, - 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, - 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, - 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, - 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, - 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, - 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, - 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, - 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, - 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, - 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, - 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, - 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, - 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, - 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, - 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, - 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, - 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, - 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, - 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, - 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, - 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, - 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, - 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, - 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, - 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, - 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, - 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, - 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, - 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, - 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, - 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, - 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, - 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, - 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, - 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, - 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, - 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, - 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, - 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, - 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, - 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, - 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, - 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, - 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, - 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, - 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, - 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, - 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, - 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, - 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, - 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, - 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, - 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, - 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, - 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, - 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, - 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, - 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, - 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, - 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, - 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, - 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}; +static u32 crc_lookup[256]= { + 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, + 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, + 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, + 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, + 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, + 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, + 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, + 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, + 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, + 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, + 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, + 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, + 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, + 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, + 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, + 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, + 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, + 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, + 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, + 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, + 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, + 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, + 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, + 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, + 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, + 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, + 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, + 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, + 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, + 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, + 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, + 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, + 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, + 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, + 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, + 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, + 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, + 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, + 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, + 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, + 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, + 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, + 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, + 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, + 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, + 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, + 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, + 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, + 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, + 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, + 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, + 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, + 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, + 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, + 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, + 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, + 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, + 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, + 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, + 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, + 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, + 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, + 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, + 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4 +}; /* init the encode/decode logical stream state */ -s32 ogg_stream_init(ogg_stream_state *os,s32 serialno){ - if(os){ - memset(os,0,sizeof(*os)); - os->body_storage=16*1024; - os->body_data = (unsigned char *)gf_malloc(os->body_storage*sizeof(*os->body_data)); +s32 ogg_stream_init(ogg_stream_state *os,s32 serialno) { + if(os) { + memset(os,0,sizeof(*os)); + os->body_storage=16*1024; + os->body_data = (unsigned char *)gf_malloc(os->body_storage*sizeof(*os->body_data)); - os->lacing_storage=1024; - os->lacing_vals=(s32 *)gf_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=(s64*)gf_malloc(os->lacing_storage*sizeof(*os->granule_vals)); + os->lacing_storage=1024; + os->lacing_vals=(s32 *)gf_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); + os->granule_vals=(s64*)gf_malloc(os->lacing_storage*sizeof(*os->granule_vals)); - os->serialno=serialno; + os->serialno=serialno; - return(0); - } - return(-1); -} + return(0); + } + return(-1); +} /* _clear does not free os, only the non-flat storage within */ -s32 ogg_stream_clear(ogg_stream_state *os){ - if(os){ - if(os->body_data)gf_free(os->body_data); - if(os->lacing_vals)gf_free(os->lacing_vals); - if(os->granule_vals)gf_free(os->granule_vals); - - memset(os,0,sizeof(*os)); - } - return(0); -} - -s32 ogg_stream_destroy(ogg_stream_state *os){ - if(os){ - ogg_stream_clear(os); - gf_free(os); - } - return(0); -} +s32 ogg_stream_clear(ogg_stream_state *os) { + if(os) { + if(os->body_data)gf_free(os->body_data); + if(os->lacing_vals)gf_free(os->lacing_vals); + if(os->granule_vals)gf_free(os->granule_vals); + + memset(os,0,sizeof(*os)); + } + return(0); +} + +s32 ogg_stream_destroy(ogg_stream_state *os) { + if(os) { + ogg_stream_clear(os); + gf_free(os); + } + return(0); +} /* Helpers for ogg_stream_encode; this keeps the structure and what's happening fairly clear */ -static void _os_body_expand(ogg_stream_state *os,s32 needed){ - if(os->body_storage<=os->body_fill+needed){ - os->body_storage+=(needed+1024); - os->body_data = (unsigned char *)gf_realloc(os->body_data,os->body_storage*sizeof(*os->body_data)); - } +static void _os_body_expand(ogg_stream_state *os,s32 needed) { + if(os->body_storage<=os->body_fill+needed) { + os->body_storage+=(needed+1024); + os->body_data = (unsigned char *)gf_realloc(os->body_data,os->body_storage*sizeof(*os->body_data)); + } } -static void _os_lacing_expand(ogg_stream_state *os,s32 needed){ - if(os->lacing_storage<=os->lacing_fill+needed){ - os->lacing_storage+=(needed+32); - os->lacing_vals=(s32*)gf_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=(s64*)gf_realloc(os->granule_vals,os->lacing_storage*sizeof(*os->granule_vals)); - } +static void _os_lacing_expand(ogg_stream_state *os,s32 needed) { + if(os->lacing_storage<=os->lacing_fill+needed) { + os->lacing_storage+=(needed+32); + os->lacing_vals=(s32*)gf_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals)); + os->granule_vals=(s64*)gf_realloc(os->granule_vals,os->lacing_storage*sizeof(*os->granule_vals)); + } } /* checksum the page */ /* Direct table CRC; note that this will be faster in the future if we perform the checksum silmultaneously with other copies */ -void ogg_page_checksum_set(ogg_page *og){ - if(og){ - u32 crc_reg=0; - s32 i; - - /* safety; needed for API behavior, but not framing code */ - og->header[22]=0; - og->header[23]=0; - og->header[24]=0; - og->header[25]=0; - - for(i=0;iheader_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; - for(i=0;ibody_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; - - og->header[22]=crc_reg&0xff; - og->header[23]=(crc_reg>>8)&0xff; - og->header[24]=(crc_reg>>16)&0xff; - og->header[25]=(crc_reg>>24)&0xff; - } +void ogg_page_checksum_set(ogg_page *og) { + if(og) { + u32 crc_reg=0; + s32 i; + + /* safety; needed for API behavior, but not framing code */ + og->header[22]=0; + og->header[23]=0; + og->header[24]=0; + og->header[25]=0; + + for(i=0; iheader_len; i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; + for(i=0; ibody_len; i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; + + og->header[22]=crc_reg&0xff; + og->header[23]=(crc_reg>>8)&0xff; + og->header[24]=(crc_reg>>16)&0xff; + og->header[25]=(crc_reg>>24)&0xff; + } } /* submit data to the internal buffer of the framing engine */ -s32 ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){ - s32 lacing_vals=op->bytes/255+1,i; - - if(os->body_returned){ - /* advance packet data according to the body_returned pointer. We - had to keep it around to return a pointer into the buffer last - call */ - - os->body_fill-=os->body_returned; - if(os->body_fill) - memmove(os->body_data,os->body_data+os->body_returned, - os->body_fill); - os->body_returned=0; - } - - /* make sure we have the buffer storage */ - _os_body_expand(os,op->bytes); - _os_lacing_expand(os,lacing_vals); - - /* Copy in the submitted packet. Yes, the copy is a waste; this is - the liability of overly clean abstraction for the time being. It - will actually be fairly easy to eliminate the extra copy in the - future */ - - memcpy(os->body_data+os->body_fill,op->packet,op->bytes); - os->body_fill+=op->bytes; - - /* Store lacing vals for this packet */ - for(i=0;ilacing_vals[os->lacing_fill+i]=255; - os->granule_vals[os->lacing_fill+i]=os->granulepos; - } - os->lacing_vals[os->lacing_fill+i]=(op->bytes)%255; - os->granulepos=os->granule_vals[os->lacing_fill+i]=op->granulepos; - - /* flag the first segment as the beginning of the packet */ - os->lacing_vals[os->lacing_fill]|= 0x100; - - os->lacing_fill+=lacing_vals; - - /* for the sake of completeness */ - os->packetno++; - - if(op->e_o_s)os->e_o_s=1; - - return(0); +s32 ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op) { + s32 lacing_vals=op->bytes/255+1,i; + + if(os->body_returned) { + /* advance packet data according to the body_returned pointer. We + had to keep it around to return a pointer into the buffer last + call */ + + os->body_fill-=os->body_returned; + if(os->body_fill) + memmove(os->body_data,os->body_data+os->body_returned, + os->body_fill); + os->body_returned=0; + } + + /* make sure we have the buffer storage */ + _os_body_expand(os,op->bytes); + _os_lacing_expand(os,lacing_vals); + + /* Copy in the submitted packet. Yes, the copy is a waste; this is + the liability of overly clean abstraction for the time being. It + will actually be fairly easy to eliminate the extra copy in the + future */ + + memcpy(os->body_data+os->body_fill,op->packet,op->bytes); + os->body_fill+=op->bytes; + + /* Store lacing vals for this packet */ + for(i=0; ilacing_vals[os->lacing_fill+i]=255; + os->granule_vals[os->lacing_fill+i]=os->granulepos; + } + os->lacing_vals[os->lacing_fill+i]=(op->bytes)%255; + os->granulepos=os->granule_vals[os->lacing_fill+i]=op->granulepos; + + /* flag the first segment as the beginning of the packet */ + os->lacing_vals[os->lacing_fill]|= 0x100; + + os->lacing_fill+=lacing_vals; + + /* for the sake of completeness */ + os->packetno++; + + if(op->e_o_s)os->e_o_s=1; + + return(0); } /* This will flush remaining packets into a page (returning nonzero), @@ -757,115 +759,115 @@ s32 ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){ since ogg_stream_flush will flush the last page in a stream even if it's undersized, you almost certainly want to use ogg_stream_pageout - (and *not* ogg_stream_flush) unless you specifically need to flush + (and *not* ogg_stream_flush) unless you specifically need to flush an page regardless of size in the middle of a stream. */ -s32 ogg_stream_flush(ogg_stream_state *os,ogg_page *og){ - s32 i; - s32 vals=0; - s32 maxvals=(os->lacing_fill>255?255:os->lacing_fill); - s32 bytes=0; - s32 acc=0; - s64 granule_pos=os->granule_vals[0]; - - if(maxvals==0)return(0); - - /* construct a page */ - /* decide how many segments to include */ - - /* If this is the initial header case, the first page must only include - the initial header packet */ - if(os->b_o_s==0){ /* 'initial header page' case */ - granule_pos=0; - for(vals=0;valslacing_vals[vals]&0x0ff)<255){ - vals++; - break; - } - } - }else{ - for(vals=0;vals4096)break; - acc+=os->lacing_vals[vals]&0x0ff; - granule_pos=os->granule_vals[vals]; - } - } - - /* construct the header in temp storage */ - memcpy(os->header,"OggS",4); - - /* stream structure version */ - os->header[4]=0x00; - - /* continued packet flag? */ - os->header[5]=0x00; - if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; - /* first page flag? */ - if(os->b_o_s==0)os->header[5]|=0x02; - /* last page flag? */ - if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; - os->b_o_s=1; - - /* 64 bits of PCM position */ - for(i=6;i<14;i++){ - os->header[i]=(u8) (granule_pos&0xff); - granule_pos>>=8; - } - - /* 32 bits of stream serial number */ - { - s32 serialno=os->serialno; - for(i=14;i<18;i++){ - os->header[i]=(serialno&0xff); - serialno>>=8; - } - } - - /* 32 bits of page counter (we have both counter and page header - because this val can roll over) */ - if(os->pageno==-1)os->pageno=0; /* because someone called +s32 ogg_stream_flush(ogg_stream_state *os,ogg_page *og) { + s32 i; + s32 vals=0; + s32 maxvals=(os->lacing_fill>255?255:os->lacing_fill); + s32 bytes=0; + s32 acc=0; + s64 granule_pos=os->granule_vals[0]; + + if(maxvals==0)return(0); + + /* construct a page */ + /* decide how many segments to include */ + + /* If this is the initial header case, the first page must only include + the initial header packet */ + if(os->b_o_s==0) { /* 'initial header page' case */ + granule_pos=0; + for(vals=0; valslacing_vals[vals]&0x0ff)<255) { + vals++; + break; + } + } + } else { + for(vals=0; vals4096)break; + acc+=os->lacing_vals[vals]&0x0ff; + granule_pos=os->granule_vals[vals]; + } + } + + /* construct the header in temp storage */ + memcpy(os->header,"OggS",4); + + /* stream structure version */ + os->header[4]=0x00; + + /* continued packet flag? */ + os->header[5]=0x00; + if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; + /* first page flag? */ + if(os->b_o_s==0)os->header[5]|=0x02; + /* last page flag? */ + if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; + os->b_o_s=1; + + /* 64 bits of PCM position */ + for(i=6; i<14; i++) { + os->header[i]=(u8) (granule_pos&0xff); + granule_pos>>=8; + } + + /* 32 bits of stream serial number */ + { + s32 serialno=os->serialno; + for(i=14; i<18; i++) { + os->header[i]=(serialno&0xff); + serialno>>=8; + } + } + + /* 32 bits of page counter (we have both counter and page header + because this val can roll over) */ + if(os->pageno==-1)os->pageno=0; /* because someone called stream_reset; this would be a strange thing to do in an encode stream, but it has plausible uses */ - { - s32 pageno=os->pageno++; - for(i=18;i<22;i++){ - os->header[i]=(pageno&0xff); - pageno>>=8; - } - } - - /* zero for computation; filled in later */ - os->header[22]=0; - os->header[23]=0; - os->header[24]=0; - os->header[25]=0; - - /* segment table */ - os->header[26]=vals&0xff; - for(i=0;iheader[i+27]=(os->lacing_vals[i]&0xff); - - /* set pointers in the ogg_page struct */ - og->header=os->header; - og->header_len=os->header_fill=vals+27; - og->body=os->body_data+os->body_returned; - og->body_len=bytes; - - /* advance the lacing data and set the body_returned pointer */ - - os->lacing_fill-=vals; - memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); - os->body_returned+=bytes; - - /* calculate the checksum */ - - ogg_page_checksum_set(og); - - /* done */ - return(1); + { + s32 pageno=os->pageno++; + for(i=18; i<22; i++) { + os->header[i]=(pageno&0xff); + pageno>>=8; + } + } + + /* zero for computation; filled in later */ + os->header[22]=0; + os->header[23]=0; + os->header[24]=0; + os->header[25]=0; + + /* segment table */ + os->header[26]=vals&0xff; + for(i=0; iheader[i+27]=(os->lacing_vals[i]&0xff); + + /* set pointers in the ogg_page struct */ + og->header=os->header; + og->header_len=os->header_fill=vals+27; + og->body=os->body_data+os->body_returned; + og->body_len=bytes; + + /* advance the lacing data and set the body_returned pointer */ + + os->lacing_fill-=vals; + memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); + os->body_returned+=bytes; + + /* calculate the checksum */ + + ogg_page_checksum_set(og); + + /* done */ + return(1); } @@ -873,22 +875,22 @@ s32 ogg_stream_flush(ogg_stream_state *os,ogg_page *og){ returned are to static buffers; do not free. The returned buffers are good only until the next call (using the same ogg_stream_state) */ -s32 ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){ +s32 ogg_stream_pageout(ogg_stream_state *os, ogg_page *og) { + + if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ + os->body_fill-os->body_returned > 4096 ||/* 'page nominal size' case */ + os->lacing_fill>=255 || /* 'segment table full' case */ + (os->lacing_fill&&!os->b_o_s)) { /* 'initial header page' case */ + + return(ogg_stream_flush(os,og)); + } - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - os->body_fill-os->body_returned > 4096 ||/* 'page nominal size' case */ - os->lacing_fill>=255 || /* 'segment table full' case */ - (os->lacing_fill&&!os->b_o_s)){ /* 'initial header page' case */ - - return(ogg_stream_flush(os,og)); - } - - /* not enough data to construct a page and not end of stream */ - return(0); + /* not enough data to construct a page and not end of stream */ + return(0); } -s32 ogg_stream_eos(ogg_stream_state *os){ - return os->e_o_s; +s32 ogg_stream_eos(ogg_stream_state *os) { + return os->e_o_s; } /* DECODING PRIMITIVES: packet streaming layer **********************/ @@ -908,59 +910,59 @@ s32 ogg_stream_eos(ogg_stream_state *os){ example code. */ /* initialize the struct to a known state */ -s32 ogg_sync_init(ogg_sync_state *oy){ - if(oy){ - memset(oy,0,sizeof(*oy)); - } - return(0); +s32 ogg_sync_init(ogg_sync_state *oy) { + if(oy) { + memset(oy,0,sizeof(*oy)); + } + return(0); } /* clear non-flat storage within */ -s32 ogg_sync_clear(ogg_sync_state *oy){ - if(oy){ - if(oy->data)gf_free(oy->data); - ogg_sync_init(oy); - } - return(0); +s32 ogg_sync_clear(ogg_sync_state *oy) { + if(oy) { + if(oy->data)gf_free(oy->data); + ogg_sync_init(oy); + } + return(0); } -s32 ogg_sync_destroy(ogg_sync_state *oy){ - if(oy){ - ogg_sync_clear(oy); - gf_free(oy); - } - return(0); +s32 ogg_sync_destroy(ogg_sync_state *oy) { + if(oy) { + ogg_sync_clear(oy); + gf_free(oy); + } + return(0); } -char *ogg_sync_buffer(ogg_sync_state *oy, s32 size){ +char *ogg_sync_buffer(ogg_sync_state *oy, s32 size) { - /* first, clear out any space that has been previously returned */ - if(oy->returned){ - oy->fill-=oy->returned; - if(oy->fill>0) - memmove(oy->data,oy->data+oy->returned,oy->fill); - oy->returned=0; - } + /* first, clear out any space that has been previously returned */ + if(oy->returned) { + oy->fill-=oy->returned; + if(oy->fill>0) + memmove(oy->data,oy->data+oy->returned,oy->fill); + oy->returned=0; + } - if(size>oy->storage-oy->fill){ - /* We need to extend the internal buffer */ - s32 newsize=size+oy->fill+4096; /* an extra page to be nice */ + if(size>oy->storage-oy->fill) { + /* We need to extend the internal buffer */ + s32 newsize=size+oy->fill+4096; /* an extra page to be nice */ - if(oy->data) - oy->data = (unsigned char *)gf_realloc(oy->data,newsize); - else - oy->data = (unsigned char *)gf_malloc(newsize); - oy->storage=newsize; - } + if(oy->data) + oy->data = (unsigned char *)gf_realloc(oy->data,newsize); + else + oy->data = (unsigned char *)gf_malloc(newsize); + oy->storage=newsize; + } - /* expose a segment at least as large as requested at the fill mark */ - return((char *)oy->data+oy->fill); + /* expose a segment at least as large as requested at the fill mark */ + return((char *)oy->data+oy->fill); } -s32 ogg_sync_wrote(ogg_sync_state *oy, s32 bytes){ - if(oy->fill+bytes>oy->storage)return(-1); - oy->fill+=bytes; - return(0); +s32 ogg_sync_wrote(ogg_sync_state *oy, s32 bytes) { + if(oy->fill+bytes>oy->storage)return(-1); + oy->fill+=bytes; + return(0); } /* sync the stream. This is meant to be useful for finding page @@ -970,92 +972,92 @@ s32 ogg_sync_wrote(ogg_sync_state *oy, s32 bytes){ -n) skipped n bytes 0) page not ready; more data (no bytes skipped) n) page synced at current location; page length n bytes - + */ -s32 ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ - unsigned char *page=oy->data+oy->returned; - unsigned char *next; - s32 bytes=oy->fill-oy->returned; - - if(oy->headerbytes==0){ - s32 headerbytes,i; - if(bytes<27)return(0); /* not enough for a header */ - - /* verify capture pattern */ - if(memcmp(page,"OggS",4))goto sync_fail; - - headerbytes=page[26]+27; - if(bytesbodybytes+=page[27+i]; - oy->headerbytes=headerbytes; - } - - if(oy->bodybytes+oy->headerbytes>bytes)return(0); - - /* The whole test page is buffered. Verify the checksum */ - { - /* Grab the checksum bytes, set the header field to zero */ - char chksum[4]; - ogg_page log; - - memcpy(chksum,page+22,4); - memset(page+22,0,4); - - /* set up a temp page struct and recompute the checksum */ - log.header=page; - log.header_len=oy->headerbytes; - log.body=page+oy->headerbytes; - log.body_len=oy->bodybytes; - ogg_page_checksum_set(&log); - - /* Compare */ - if(memcmp(chksum,page+22,4)){ - /* D'oh. Mismatch! Corrupt page (or miscapture and not a page - at all) */ - /* replace the computed checksum with the one actually read in */ - memcpy(page+22,chksum,4); - - /* Bad checksum. Lose sync */ - goto sync_fail; - } - } - - /* yes, have a whole page all ready to go */ - { - unsigned char *page=oy->data+oy->returned; - s32 bytes; - - if(og){ - og->header=page; - og->header_len=oy->headerbytes; - og->body=page+oy->headerbytes; - og->body_len=oy->bodybytes; - } - - oy->unsynced=0; - oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); - oy->headerbytes=0; - oy->bodybytes=0; - return(bytes); - } - - sync_fail: - - oy->headerbytes=0; - oy->bodybytes=0; - - /* search for possible capture */ - next = (unsigned char *)memchr(page+1,'O',bytes-1); - if(!next) - next=oy->data+oy->fill; - - oy->returned = (s32) (next-oy->data); - return (s32) (-(next-page)); +s32 ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og) { + unsigned char *page=oy->data+oy->returned; + unsigned char *next; + s32 bytes=oy->fill-oy->returned; + + if(oy->headerbytes==0) { + s32 headerbytes,i; + if(bytes<27)return(0); /* not enough for a header */ + + /* verify capture pattern */ + if(memcmp(page,"OggS",4))goto sync_fail; + + headerbytes=page[26]+27; + if(bytesbodybytes+=page[27+i]; + oy->headerbytes=headerbytes; + } + + if(oy->bodybytes+oy->headerbytes>bytes)return(0); + + /* The whole test page is buffered. Verify the checksum */ + { + /* Grab the checksum bytes, set the header field to zero */ + char chksum[4]; + ogg_page log; + + memcpy(chksum,page+22,4); + memset(page+22,0,4); + + /* set up a temp page struct and recompute the checksum */ + log.header=page; + log.header_len=oy->headerbytes; + log.body=page+oy->headerbytes; + log.body_len=oy->bodybytes; + ogg_page_checksum_set(&log); + + /* Compare */ + if(memcmp(chksum,page+22,4)) { + /* D'oh. Mismatch! Corrupt page (or miscapture and not a page + at all) */ + /* replace the computed checksum with the one actually read in */ + memcpy(page+22,chksum,4); + + /* Bad checksum. Lose sync */ + goto sync_fail; + } + } + + /* yes, have a whole page all ready to go */ + { + unsigned char *page=oy->data+oy->returned; + s32 bytes; + + if(og) { + og->header=page; + og->header_len=oy->headerbytes; + og->body=page+oy->headerbytes; + og->body_len=oy->bodybytes; + } + + oy->unsynced=0; + oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); + oy->headerbytes=0; + oy->bodybytes=0; + return(bytes); + } + +sync_fail: + + oy->headerbytes=0; + oy->bodybytes=0; + + /* search for possible capture */ + next = (unsigned char *)memchr(page+1,'O',bytes-1); + if(!next) + next=oy->data+oy->fill; + + oy->returned = (s32) (next-oy->data); + return (s32) (-(next-page)); } /* sync the stream and get a page. Keep trying until we find a page. @@ -1069,260 +1071,260 @@ s32 ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ Returns pointers into buffered data; invalidated by next call to _stream, _clear, _init, or _buffer */ -s32 ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ +s32 ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og) { - /* all we need to do is verify a page at the head of the stream - buffer. If it doesn't verify, we look for the next potential - frame */ + /* all we need to do is verify a page at the head of the stream + buffer. If it doesn't verify, we look for the next potential + frame */ - while(1){ - s32 ret=ogg_sync_pageseek(oy,og); - if(ret>0){ - /* have a page */ - return(1); - } - if(ret==0){ - /* need more data */ - return(0); - } - - /* head did not start a synced page... skipped some bytes */ - if(!oy->unsynced){ - oy->unsynced=1; - return(-1); - } + while(1) { + s32 ret=ogg_sync_pageseek(oy,og); + if(ret>0) { + /* have a page */ + return(1); + } + if(ret==0) { + /* need more data */ + return(0); + } - /* loop. keep looking */ + /* head did not start a synced page... skipped some bytes */ + if(!oy->unsynced) { + oy->unsynced=1; + return(-1); + } - } + /* loop. keep looking */ + + } } /* add the incoming page to the stream state; we decompose the page into packet segments here as well. */ -s32 ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){ - unsigned char *header=og->header; - unsigned char *body=og->body; - s32 bodysize=og->body_len; - s32 segptr=0; - - s32 version=ogg_page_version(og); - s32 continued=ogg_page_continued(og); - s32 bos=ogg_page_bos(og); - s32 eos=ogg_page_eos(og); - s64 granulepos=ogg_page_granulepos(og); - s32 serialno=ogg_page_serialno(og); - s32 pageno=ogg_page_pageno(og); - s32 segments=header[26]; - - /* clean up 'returned data' */ - { - s32 lr=os->lacing_returned; - s32 br=os->body_returned; - - /* body data */ - if(br){ - os->body_fill-=br; - if(os->body_fill) - memmove(os->body_data,os->body_data+br,os->body_fill); - os->body_returned=0; - } - - if(lr){ - /* segment table */ - if(os->lacing_fill-lr){ - memmove(os->lacing_vals,os->lacing_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->granule_vals)); - } - os->lacing_fill-=lr; - os->lacing_packet-=lr; - os->lacing_returned=0; - } - } - - /* check the serial number */ - if(serialno!=os->serialno)return(-1); - if(version>0)return(-1); - - _os_lacing_expand(os,segments+1); - - /* are we in sequence? */ - if(pageno!=os->pageno){ - s32 i; - - /* unroll previous partial packet (if any) */ - for(i=os->lacing_packet;ilacing_fill;i++) - os->body_fill-=os->lacing_vals[i]&0xff; - os->lacing_fill=os->lacing_packet; - - /* make a note of dropped data in segment table */ - if(os->pageno!=-1){ - os->lacing_vals[os->lacing_fill++]=0x400; - os->lacing_packet++; - } - - /* are we a 'continued packet' page? If so, we'll need to skip - some segments */ - if(continued){ - bos=0; - for(;segptrheader; + unsigned char *body=og->body; + s32 bodysize=og->body_len; + s32 segptr=0; + + s32 version=ogg_page_version(og); + s32 continued=ogg_page_continued(og); + s32 bos=ogg_page_bos(og); + s32 eos=ogg_page_eos(og); + s64 granulepos=ogg_page_granulepos(og); + s32 serialno=ogg_page_serialno(og); + s32 pageno=ogg_page_pageno(og); + s32 segments=header[26]; + + /* clean up 'returned data' */ + { + s32 lr=os->lacing_returned; + s32 br=os->body_returned; + + /* body data */ + if(br) { + os->body_fill-=br; + if(os->body_fill) + memmove(os->body_data,os->body_data+br,os->body_fill); + os->body_returned=0; + } + + if(lr) { + /* segment table */ + if(os->lacing_fill-lr) { + memmove(os->lacing_vals,os->lacing_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->granule_vals)); + } + os->lacing_fill-=lr; + os->lacing_packet-=lr; + os->lacing_returned=0; + } + } + + /* check the serial number */ + if(serialno!=os->serialno)return(-1); + if(version>0)return(-1); + + _os_lacing_expand(os,segments+1); + + /* are we in sequence? */ + if(pageno!=os->pageno) { + s32 i; + + /* unroll previous partial packet (if any) */ + for(i=os->lacing_packet; ilacing_fill; i++) + os->body_fill-=os->lacing_vals[i]&0xff; + os->lacing_fill=os->lacing_packet; + + /* make a note of dropped data in segment table */ + if(os->pageno!=-1) { + os->lacing_vals[os->lacing_fill++]=0x400; + os->lacing_packet++; + } + + /* are we a 'continued packet' page? If so, we'll need to skip + some segments */ + if(continued) { + bos=0; + for(; segptrbody_data+os->body_fill,body,bodysize); + os->body_fill+=bodysize; } - } - } - } - - if(bodysize){ - _os_body_expand(os,bodysize); - memcpy(os->body_data+os->body_fill,body,bodysize); - os->body_fill+=bodysize; - } - - { - s32 saved=-1; - while(segptrlacing_vals[os->lacing_fill]=val; - os->granule_vals[os->lacing_fill]=-1; - - if(bos){ - os->lacing_vals[os->lacing_fill]|=0x100; - bos=0; - } - - if(val<255)saved=os->lacing_fill; - - os->lacing_fill++; - segptr++; - - if(val<255)os->lacing_packet=os->lacing_fill; - } - - /* set the granulepos on the last granuleval of the last full packet */ - if(saved!=-1){ - os->granule_vals[saved]=granulepos; - } - - } - - if(eos){ - os->e_o_s=1; - if(os->lacing_fill>0) - os->lacing_vals[os->lacing_fill-1]|=0x200; - } - - os->pageno=pageno+1; - - return(0); + + { + s32 saved=-1; + while(segptrlacing_vals[os->lacing_fill]=val; + os->granule_vals[os->lacing_fill]=-1; + + if(bos) { + os->lacing_vals[os->lacing_fill]|=0x100; + bos=0; + } + + if(val<255)saved=os->lacing_fill; + + os->lacing_fill++; + segptr++; + + if(val<255)os->lacing_packet=os->lacing_fill; + } + + /* set the granulepos on the last granuleval of the last full packet */ + if(saved!=-1) { + os->granule_vals[saved]=granulepos; + } + + } + + if(eos) { + os->e_o_s=1; + if(os->lacing_fill>0) + os->lacing_vals[os->lacing_fill-1]|=0x200; + } + + os->pageno=pageno+1; + + return(0); } /* clear things to an initial state. Good to call, eg, before seeking */ -s32 ogg_sync_reset(ogg_sync_state *oy){ - oy->fill=0; - oy->returned=0; - oy->unsynced=0; - oy->headerbytes=0; - oy->bodybytes=0; - return(0); +s32 ogg_sync_reset(ogg_sync_state *oy) { + oy->fill=0; + oy->returned=0; + oy->unsynced=0; + oy->headerbytes=0; + oy->bodybytes=0; + return(0); } -s32 ogg_stream_reset(ogg_stream_state *os){ - os->body_fill=0; - os->body_returned=0; +s32 ogg_stream_reset(ogg_stream_state *os) { + os->body_fill=0; + os->body_returned=0; - os->lacing_fill=0; - os->lacing_packet=0; - os->lacing_returned=0; + os->lacing_fill=0; + os->lacing_packet=0; + os->lacing_returned=0; - os->header_fill=0; + os->header_fill=0; - os->e_o_s=0; - os->b_o_s=0; - os->pageno=-1; - os->packetno=0; - os->granulepos=0; + os->e_o_s=0; + os->b_o_s=0; + os->pageno=-1; + os->packetno=0; + os->granulepos=0; - return(0); + return(0); } -s32 ogg_stream_reset_serialno(ogg_stream_state *os,s32 serialno){ - ogg_stream_reset(os); - os->serialno=serialno; - return(0); +s32 ogg_stream_reset_serialno(ogg_stream_state *os,s32 serialno) { + ogg_stream_reset(os); + os->serialno=serialno; + return(0); } -static s32 _packetout(ogg_stream_state *os,ogg_packet *op,s32 adv){ +static s32 _packetout(ogg_stream_state *os,ogg_packet *op,s32 adv) { - /* The last part of decode. We have the stream broken into packet - segments. Now we need to group them into packets (or return the - out of sync markers) */ + /* The last part of decode. We have the stream broken into packet + segments. Now we need to group them into packets (or return the + out of sync markers) */ - s32 ptr=os->lacing_returned; + s32 ptr=os->lacing_returned; - if(os->lacing_packet<=ptr)return(0); + if(os->lacing_packet<=ptr)return(0); - if(os->lacing_vals[ptr]&0x400){ - /* we need to tell the codec there's a gap; it might need to - handle previous packet dependencies. */ - os->lacing_returned++; - os->packetno++; - return(-1); - } + if(os->lacing_vals[ptr]&0x400) { + /* we need to tell the codec there's a gap; it might need to + handle previous packet dependencies. */ + os->lacing_returned++; + os->packetno++; + return(-1); + } - if(!op && !adv)return(1); /* just using peek as an inexpensive way + if(!op && !adv)return(1); /* just using peek as an inexpensive way to ask if there's a whole packet waiting */ - /* Gather the whole packet. We'll have no holes or a partial packet */ - { - s32 size=os->lacing_vals[ptr]&0xff; - s32 bytes=size; - s32 eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ - s32 bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ - - while(size==255){ - s32 val=os->lacing_vals[++ptr]; - size=val&0xff; - if(val&0x200)eos=0x200; - bytes+=size; - } - - if(op){ - op->e_o_s=eos; - op->b_o_s=bos; - op->packet=os->body_data+os->body_returned; - op->packetno=os->packetno; - op->granulepos=os->granule_vals[ptr]; - op->bytes=bytes; - } - - if(adv){ - os->body_returned+=bytes; - os->lacing_returned=ptr+1; - os->packetno++; - } - } - return(1); + /* Gather the whole packet. We'll have no holes or a partial packet */ + { + s32 size=os->lacing_vals[ptr]&0xff; + s32 bytes=size; + s32 eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ + s32 bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ + + while(size==255) { + s32 val=os->lacing_vals[++ptr]; + size=val&0xff; + if(val&0x200)eos=0x200; + bytes+=size; + } + + if(op) { + op->e_o_s=eos; + op->b_o_s=bos; + op->packet=os->body_data+os->body_returned; + op->packetno=os->packetno; + op->granulepos=os->granule_vals[ptr]; + op->bytes=bytes; + } + + if(adv) { + os->body_returned+=bytes; + os->lacing_returned=ptr+1; + os->packetno++; + } + } + return(1); } -s32 ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ - return _packetout(os,op,1); +s32 ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op) { + return _packetout(os,op,1); } -s32 ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ - return _packetout(os,op,0); +s32 ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op) { + return _packetout(os,op,0); } void ogg_packet_clear(ogg_packet *op) { - gf_free(op->packet); - memset(op, 0, sizeof(*op)); + gf_free(op->packet); + memset(op, 0, sizeof(*op)); } #endif /*GPAC_DISABLE_OGG*/ diff --git a/src/media_tools/html5_media.c b/src/media_tools/html5_media.c index 27b3721..8975f53 100644 --- a/src/media_tools/html5_media.c +++ b/src/media_tools/html5_media.c @@ -42,12 +42,12 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_new(u32 timescale) static GF_Err gf_html_timeranges_add_time(GF_HTML_MediaTimeRanges *timeranges, u64 time) { - u64 *t; - if (!timeranges) return GF_BAD_PARAM; - t = (u64 *)gf_malloc(sizeof(u64)); - *t = time; - gf_list_add(timeranges->times, t); - return GF_OK; + u64 *t; + if (!timeranges) return GF_BAD_PARAM; + t = (u64 *)gf_malloc(sizeof(u64)); + *t = time; + gf_list_add(timeranges->times, t); + return GF_OK; } GF_Err gf_html_timeranges_add_start(GF_HTML_MediaTimeRanges *timeranges, u64 start) @@ -62,18 +62,18 @@ GF_Err gf_html_timeranges_add_end(GF_HTML_MediaTimeRanges *timeranges, u64 end) void gf_html_timeranges_reset(GF_HTML_MediaTimeRanges *ranges) { - while (gf_list_count(ranges->times)) - { - u64 *d = (u64 *)gf_list_get(ranges->times, 0); - gf_free(d); - gf_list_rem(ranges->times, 0); - } + while (gf_list_count(ranges->times)) + { + u64 *d = (u64 *)gf_list_get(ranges->times, 0); + gf_free(d); + gf_list_rem(ranges->times, 0); + } } void gf_html_timeranges_del(GF_HTML_MediaTimeRanges *ranges) { gf_html_timeranges_reset(ranges); - gf_list_del(ranges->times); + gf_list_del(ranges->times); ranges->times = NULL; gf_free(ranges); } @@ -124,7 +124,7 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_union(GF_HTML_MediaTimeRanges *a, GF } if (count_a == 0 && count_b == 0) { return NULL; - } else if (count_a == 0) { + } else if (count_a == 0) { GF_HTML_MediaTimeRanges *tmp = a; a = b; b = tmp; @@ -160,7 +160,7 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_union(GF_HTML_MediaTimeRanges *a, GF if (*endb*a->timescale <= *enda*b->timescale) { /* b is contained in a */ /* ignore b, move on to the next b */ j+=2; - } else { /* *endb > *enda, the overlap is only at the start of b */ + } else { /* *endb > *enda, the overlap is only at the start of b */ /* update start of b */ *startb = (u64)((*starta * b->timescale)*1.0 / a->timescale); /* ignore a, move on to the next a */ @@ -239,7 +239,7 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_intersection(GF_HTML_MediaTimeRanges *starta = (u64)((*endb * a->timescale)*1.0 / b->timescale); /* move on to the next b */ j+=2; - } else { /* *endb > *enda, the intersection ends at the end of a */ + } else { /* *endb > *enda, the intersection ends at the end of a */ gf_list_add(intersection_ranges->times, enda); /* update start of b */ *startb = (u64)((*enda * b->timescale)*1.0 / a->timescale); @@ -271,83 +271,83 @@ GF_HTML_MediaTimeRanges *gf_html_timeranges_intersection(GF_HTML_MediaTimeRanges } GF_HTML_Track *html_media_add_new_track_to_list(GF_HTML_TrackList *tracklist, - GF_HTML_TrackType type, const char *mime, Bool enable_or_selected, - const char *id, const char *kind, const char *label, const char *lang) + GF_HTML_TrackType type, const char *mime, Bool enable_or_selected, + const char *id, const char *kind, const char *label, const char *lang) { - GF_HTML_Track *track; - track = gf_html_media_track_new(type, mime, enable_or_selected, id, kind, label, lang); - gf_list_add(tracklist->tracks, track); - return track; + GF_HTML_Track *track; + track = gf_html_media_track_new(type, mime, enable_or_selected, id, kind, label, lang); + gf_list_add(tracklist->tracks, track); + return track; } Bool html_media_tracklist_has_track(GF_HTML_TrackList *tracklist, const char *id) { - GF_HTML_Track *track; - u32 i, count; - count = gf_list_count(tracklist->tracks); - for (i = 0; i < count; i++) - { - track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, i); - if (!strcmp(id, track->id)) - { - return 1; - } - } - return 0; + GF_HTML_Track *track; + u32 i, count; + count = gf_list_count(tracklist->tracks); + for (i = 0; i < count; i++) + { + track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, i); + if (!strcmp(id, track->id)) + { + return 1; + } + } + return 0; } GF_HTML_Track *html_media_tracklist_get_track(GF_HTML_TrackList *tracklist, const char *id) { - GF_HTML_Track *track = NULL; - u32 i, count; - count = gf_list_count(tracklist->tracks); - for (i = 0; i < count; i++) - { - track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, i); - if (!strcmp(id, track->id)) - { - return track; - } - } - return NULL; + GF_HTML_Track *track = NULL; + u32 i, count; + count = gf_list_count(tracklist->tracks); + for (i = 0; i < count; i++) + { + track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, i); + if (!strcmp(id, track->id)) + { + return track; + } + } + return NULL; } void gf_html_tracklist_del(GF_HTML_TrackList *tlist) { - while (gf_list_count(tlist->tracks)) - { - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(tlist->tracks, 0); - gf_html_track_del(track); - gf_list_rem(tlist->tracks, 0); - } - gf_list_del(tlist->tracks); + while (gf_list_count(tlist->tracks)) + { + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(tlist->tracks, 0); + gf_html_track_del(track); + gf_list_rem(tlist->tracks, 0); + } + gf_list_del(tlist->tracks); } GF_HTML_Track *gf_html_media_track_new(GF_HTML_TrackType type, const char *mime, Bool enable_or_selected, const char *id, const char *kind, const char *label, const char *lang) { - GF_HTML_Track *track; - GF_SAFEALLOC(track, GF_HTML_Track); - track->type = type; - track->mime = gf_strdup(mime); - track->id = gf_strdup(id); - track->kind = gf_strdup(kind); - track->label = gf_strdup(label); - track->language = gf_strdup(lang); - track->enabled_or_selected = enable_or_selected; - /* TODO: empty MSE data */ - return track; + GF_HTML_Track *track; + GF_SAFEALLOC(track, GF_HTML_Track); + track->type = type; + track->mime = gf_strdup(mime); + track->id = gf_strdup(id); + track->kind = gf_strdup(kind); + track->label = gf_strdup(label); + track->language = gf_strdup(lang); + track->enabled_or_selected = enable_or_selected; + /* TODO: empty MSE data */ + return track; } void gf_html_track_del(GF_HTML_Track *track) { - if (track->id) gf_free(track->id); - if (track->kind) gf_free(track->kind); - if (track->label) gf_free(track->label); - if (track->language) gf_free(track->language); - if (track->mime) gf_free(track->mime); + if (track->id) gf_free(track->id); + if (track->kind) gf_free(track->kind); + if (track->label) gf_free(track->label); + if (track->language) gf_free(track->language); + if (track->mime) gf_free(track->mime); - if (track->buffer_mutex) { + if (track->buffer_mutex) { gf_mx_p(track->buffer_mutex); while (gf_list_count(track->buffer)) { @@ -366,55 +366,55 @@ void gf_html_track_del(GF_HTML_Track *track) GF_HTML_MediaElement *gf_html_media_element_new(GF_Node *media_node, GF_HTML_MediaController *mc) { - GF_HTML_MediaElement *me; - GF_SAFEALLOC(me, GF_HTML_MediaElement); - me->node = media_node; - me->controller = mc; - me->audioTracks.tracks = gf_list_new(); - me->videoTracks.tracks = gf_list_new(); - me->textTracks.tracks = gf_list_new(); - me->buffered = gf_html_timeranges_new(1); - me->played = gf_html_timeranges_new(1); - me->seekable = gf_html_timeranges_new(1); - return me; + GF_HTML_MediaElement *me; + GF_SAFEALLOC(me, GF_HTML_MediaElement); + me->node = media_node; + me->controller = mc; + me->audioTracks.tracks = gf_list_new(); + me->videoTracks.tracks = gf_list_new(); + me->textTracks.tracks = gf_list_new(); + me->buffered = gf_html_timeranges_new(1); + me->played = gf_html_timeranges_new(1); + me->seekable = gf_html_timeranges_new(1); + return me; } void gf_html_media_element_del(GF_HTML_MediaElement *me) { - if (me->startDate) gf_free(me->startDate); - if (me->currentSrc) gf_free(me->currentSrc); - gf_html_tracklist_del(&me->audioTracks); - gf_html_tracklist_del(&me->videoTracks); - gf_html_tracklist_del(&me->textTracks); - gf_html_timeranges_del(me->buffered); - gf_html_timeranges_del(me->seekable); - gf_html_timeranges_del(me->played); - gf_free(me); + if (me->startDate) gf_free(me->startDate); + if (me->currentSrc) gf_free(me->currentSrc); + gf_html_tracklist_del(&me->audioTracks); + gf_html_tracklist_del(&me->videoTracks); + gf_html_tracklist_del(&me->textTracks); + gf_html_timeranges_del(me->buffered); + gf_html_timeranges_del(me->seekable); + gf_html_timeranges_del(me->played); + gf_free(me); } GF_HTML_MediaController *gf_html_media_controller_new() { - GF_HTML_MediaController *mc; - GF_SAFEALLOC(mc, GF_HTML_MediaController); - mc->buffered = gf_html_timeranges_new(1); - mc->played = gf_html_timeranges_new(1); - mc->seekable = gf_html_timeranges_new(1); - return mc; + GF_HTML_MediaController *mc; + GF_SAFEALLOC(mc, GF_HTML_MediaController); + mc->buffered = gf_html_timeranges_new(1); + mc->played = gf_html_timeranges_new(1); + mc->seekable = gf_html_timeranges_new(1); + return mc; } void gf_html_mediacontroller_del(GF_HTML_MediaController *mc) { - u32 i, count; - /* removing the pointer to that controller from the media elements using it */ - count = gf_list_count(mc->media_elements); - for (i = 0; i < count; i++) { - GF_HTML_MediaElement *me = (GF_HTML_MediaElement *)gf_list_get(mc->media_elements, i); - me->controller = NULL; - } - gf_html_timeranges_del(mc->buffered); - gf_html_timeranges_del(mc->seekable); - gf_html_timeranges_del(mc->played); - gf_free(mc); + u32 i, count; + /* removing the pointer to that controller from the media elements using it */ + count = gf_list_count(mc->media_elements); + for (i = 0; i < count; i++) { + GF_HTML_MediaElement *me = (GF_HTML_MediaElement *)gf_list_get(mc->media_elements, i); + me->controller = NULL; + } + gf_html_timeranges_del(mc->buffered); + gf_html_timeranges_del(mc->seekable); + gf_html_timeranges_del(mc->played); + gf_free(mc); } #endif diff --git a/src/media_tools/html5_mse.c b/src/media_tools/html5_mse.c index d4e3d44..ddfd55a 100644 --- a/src/media_tools/html5_mse.c +++ b/src/media_tools/html5_mse.c @@ -45,7 +45,7 @@ GF_HTML_MediaSource *gf_mse_media_source_new() } GF_EXPORT -void gf_mse_mediasource_del(GF_HTML_MediaSource *ms, Bool del_js) +void gf_mse_mediasource_del(GF_HTML_MediaSource *ms, Bool del_js) { if (ms) { if (del_js) { @@ -69,7 +69,7 @@ void gf_mse_mediasource_del(GF_HTML_MediaSource *ms, Bool del_js) } gf_list_del(ms->sourceBuffers.list); /* all source buffer should have been deleted in the deletion of sourceBuffers */ - gf_list_del(ms->activeSourceBuffers.list); + gf_list_del(ms->activeSourceBuffers.list); if (ms->blobURI) gf_free(ms->blobURI); gf_free(ms->evt_target); gf_free(ms); @@ -77,49 +77,49 @@ void gf_mse_mediasource_del(GF_HTML_MediaSource *ms, Bool del_js) } } -void gf_mse_fire_event(GF_DOMEventTarget *target, GF_EventType event_type) +void gf_mse_fire_event(GF_DOMEventTarget *target, GF_EventType event_type) { GF_SceneGraph *sg = NULL; - GF_DOM_Event mse_event; + GF_DOM_Event mse_event; memset(&mse_event, 0, sizeof(GF_DOM_Event)); - mse_event.type = event_type; + mse_event.type = event_type; mse_event.target = target->ptr; mse_event.target_type = target->ptr_type; switch(target->ptr_type) { case GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE: - { - GF_HTML_MediaSource *ms = (GF_HTML_MediaSource *)target->ptr; - sg = ms->sg; - } - break; + { + GF_HTML_MediaSource *ms = (GF_HTML_MediaSource *)target->ptr; + sg = ms->sg; + } + break; case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST: - { - GF_HTML_SourceBufferList *list = (GF_HTML_SourceBufferList *)target->ptr; - sg = list->parent->sg; - } - break; + { + GF_HTML_SourceBufferList *list = (GF_HTML_SourceBufferList *)target->ptr; + sg = list->parent->sg; + } + break; case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER: - { - GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)target->ptr; - sg = sb->mediasource->sg; - } - break; + { + GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)target->ptr; + sg = sb->mediasource->sg; + } + break; default: break; } assert(sg); - gf_sg_fire_dom_event(target, &mse_event, sg, NULL); + gf_sg_fire_dom_event(target, &mse_event, sg, NULL); } GF_EXPORT -void gf_mse_mediasource_open(GF_HTML_MediaSource *ms, struct _mediaobj *mo) +void gf_mse_mediasource_open(GF_HTML_MediaSource *ms, struct _mediaobj *mo) { if (!ms) return; if (!mo) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[MSE] Cannot open media source without a media object\n")); return; } - ms->readyState = MEDIA_SOURCE_READYSTATE_OPEN; + ms->readyState = MEDIA_SOURCE_READYSTATE_OPEN; /* getting the Scene Tree node attached to this media source */ ms->node = (GF_Node *)gf_event_target_get_node(gf_mo_event_target_get(mo, 0)); ms->sg = gf_node_get_graph(ms->node); @@ -130,7 +130,7 @@ GF_EXPORT void gf_mse_mediasource_close(GF_HTML_MediaSource *ms) { if (!ms) return; - ms->readyState = MEDIA_SOURCE_READYSTATE_CLOSED; + ms->readyState = MEDIA_SOURCE_READYSTATE_CLOSED; gf_mse_fire_event(ms->evt_target, GF_EVENT_HTML_MSE_SOURCE_CLOSE); } @@ -138,39 +138,39 @@ GF_EXPORT void gf_mse_mediasource_end(GF_HTML_MediaSource *ms) { if (!ms) return; - ms->readyState = MEDIA_SOURCE_READYSTATE_ENDED; + ms->readyState = MEDIA_SOURCE_READYSTATE_ENDED; gf_mse_fire_event(ms->evt_target, GF_EVENT_HTML_MSE_SOURCE_ENDED); } GF_HTML_SourceBuffer *gf_mse_source_buffer_new(GF_HTML_MediaSource *mediasource) { - char name[256]; - GF_HTML_SourceBuffer *source; - GF_SAFEALLOC(source, GF_HTML_SourceBuffer); - sprintf(name, "SourceBuffer_Thread_%p", source); - source->mediasource = mediasource; - source->buffered = gf_html_timeranges_new(1); - source->input_buffer = gf_list_new(); - source->tracks = gf_list_new(); + char name[256]; + GF_HTML_SourceBuffer *source; + GF_SAFEALLOC(source, GF_HTML_SourceBuffer); + sprintf(name, "SourceBuffer_Thread_%p", source); + source->mediasource = mediasource; + source->buffered = gf_html_timeranges_new(1); + source->input_buffer = gf_list_new(); + source->tracks = gf_list_new(); source->threads = gf_list_new(); - source->parser_thread = gf_th_new(name); - source->remove_thread = gf_th_new(name); - source->append_mode = MEDIA_SOURCE_APPEND_MODE_SEGMENTS; - source->appendWindowStart = 0; - source->appendWindowEnd = GF_MAX_DOUBLE; + source->parser_thread = gf_th_new(name); + source->remove_thread = gf_th_new(name); + source->append_mode = MEDIA_SOURCE_APPEND_MODE_SEGMENTS; + source->appendWindowStart = 0; + source->appendWindowEnd = GF_MAX_DOUBLE; source->evt_target = gf_dom_event_target_new(GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER, source); source->timescale = 1; - return source; + return source; } -void gf_mse_mediasource_add_source_buffer(GF_HTML_MediaSource *ms, GF_HTML_SourceBuffer *sb) +void gf_mse_mediasource_add_source_buffer(GF_HTML_MediaSource *ms, GF_HTML_SourceBuffer *sb) { - gf_list_add(ms->sourceBuffers.list, sb); + gf_list_add(ms->sourceBuffers.list, sb); gf_mse_fire_event(ms->sourceBuffers.evt_target, GF_EVENT_HTML_MSE_ADD_SOURCE_BUFFER); } -/* Not yet used -void gf_mse_add_active_source_buffer(GF_HTML_MediaSource *ms, GF_HTML_SourceBuffer *sb) +/* Not yet used +void gf_mse_add_active_source_buffer(GF_HTML_MediaSource *ms, GF_HTML_SourceBuffer *sb) { gf_list_add(ms->activeSourceBuffers.list, sb); gf_mse_fire_event(ms->activeSourceBuffers.evt_target, GF_EVENT_HTML_MSE_ADD_SOURCE_BUFFER); @@ -197,21 +197,21 @@ static void gf_mse_reset_input_buffer(GF_List *input_buffer) /* Deletes all unparsed data buffers from all tracks in the source buffer */ static void gf_mse_source_buffer_reset_parser(GF_HTML_SourceBuffer *sb) { - u32 i, track_count; - track_count = gf_list_count(sb->tracks); - - /* wait until all remaining entire AU are parsed and then flush the remaining bytes in the parser */ - - for (i = 0; i < track_count; i++) - { - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); - track->last_dts_set = GF_FALSE; - track->highest_pts_set = GF_FALSE; - track->needs_rap = GF_TRUE; - } - sb->group_end_timestamp_set = GF_FALSE; - gf_mse_reset_input_buffer(sb->input_buffer); - sb->append_state = MEDIA_SOURCE_APPEND_STATE_WAITING_FOR_SEGMENT; + u32 i, track_count; + track_count = gf_list_count(sb->tracks); + + /* wait until all remaining entire AU are parsed and then flush the remaining bytes in the parser */ + + for (i = 0; i < track_count; i++) + { + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); + track->last_dts_set = GF_FALSE; + track->highest_pts_set = GF_FALSE; + track->needs_rap = GF_TRUE; + } + sb->group_end_timestamp_set = GF_FALSE; + gf_mse_reset_input_buffer(sb->input_buffer); + sb->append_state = MEDIA_SOURCE_APPEND_STATE_WAITING_FOR_SEGMENT; } GF_Err gf_mse_source_buffer_abort(GF_HTML_SourceBuffer *sb) @@ -220,19 +220,19 @@ GF_Err gf_mse_source_buffer_abort(GF_HTML_SourceBuffer *sb) /* setting to false should stop the parsing thread */ sb->updating = GF_FALSE; gf_mse_fire_event(sb->evt_target, GF_EVENT_HTML_MSE_UPDATE_ABORT); - gf_mse_fire_event(sb->evt_target, GF_EVENT_HTML_MSE_UPDATE_END); + gf_mse_fire_event(sb->evt_target, GF_EVENT_HTML_MSE_UPDATE_END); } - gf_mse_source_buffer_reset_parser(sb); - sb->appendWindowStart = 0; - sb->appendWindowEnd = GF_MAX_DOUBLE; - return GF_OK; + gf_mse_source_buffer_reset_parser(sb); + sb->appendWindowStart = 0; + sb->appendWindowEnd = GF_MAX_DOUBLE; + return GF_OK; } GF_Err gf_mse_remove_source_buffer(GF_HTML_MediaSource *ms, GF_HTML_SourceBuffer *sb) { s32 pos; pos = gf_list_find(ms->sourceBuffers.list, sb); if (pos < 0) { - return GF_NOT_FOUND; + return GF_NOT_FOUND; } else { gf_mse_source_buffer_abort(sb); /* TODO: update the audio/video/text tracks */ @@ -260,15 +260,15 @@ void gf_mse_detach(GF_HTML_MediaSource *ms) { void gf_mse_source_buffer_del(GF_HTML_SourceBuffer *sb) { - GF_HTML_TrackList tlist; - gf_html_timeranges_del(sb->buffered); - gf_mse_reset_input_buffer(sb->input_buffer); - gf_list_del(sb->input_buffer); + GF_HTML_TrackList tlist; + gf_html_timeranges_del(sb->buffered); + gf_mse_reset_input_buffer(sb->input_buffer); + gf_list_del(sb->input_buffer); if (sb->prev_buffer) gf_arraybuffer_del((GF_HTML_ArrayBuffer *)sb->prev_buffer, GF_FALSE); tlist.tracks = sb->tracks; - gf_html_tracklist_del(&tlist); + gf_html_tracklist_del(&tlist); { u32 i, count; count = gf_list_count(sb->threads); @@ -278,11 +278,11 @@ void gf_mse_source_buffer_del(GF_HTML_SourceBuffer *sb) } gf_list_del(sb->threads); } - gf_th_del(sb->parser_thread); - gf_th_del(sb->remove_thread); + gf_th_del(sb->parser_thread); + gf_th_del(sb->remove_thread); if (sb->service_desc) gf_odf_desc_del((GF_Descriptor *)sb->service_desc); - gf_free(sb); + gf_free(sb); } @@ -301,121 +301,121 @@ void gf_mse_source_buffer_set_update(GF_HTML_SourceBuffer *sb, Bool update) /*locates and loads an input service (demuxer, parser) for this source buffer based on mime type or segment name*/ GF_Err gf_mse_source_buffer_load_parser(GF_HTML_SourceBuffer *sourcebuffer, const char *mime) { - GF_InputService *parser = NULL; + GF_InputService *parser = NULL; - const char *sPlug; - if (mime) { + const char *sPlug; + if (mime) { /* strip the 'codecs' and 'profile' parameters from the MIME type */ char *param = (char *)strchr(mime, ';'); if (param) { *param = 0; } - /* Check MIME type to start the right InputService */ - sPlug = gf_cfg_get_key(sourcebuffer->mediasource->service->term->user->config, "MimeTypes", mime); - if (sPlug) sPlug = strrchr(sPlug, '"'); - if (sPlug) { - sPlug += 2; - parser = (GF_InputService *) gf_modules_load_interface_by_name(sourcebuffer->mediasource->service->term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); - } + /* Check MIME type to start the right InputService */ + sPlug = gf_cfg_get_key(sourcebuffer->mediasource->service->term->user->config, "MimeTypes", mime); + if (sPlug) sPlug = strrchr(sPlug, '"'); + if (sPlug) { + sPlug += 2; + parser = (GF_InputService *) gf_modules_load_interface_by_name(sourcebuffer->mediasource->service->term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); + } if (param) { *param = ';'; } - } - if (parser) { - sourcebuffer->parser = parser; - parser->query_proxy = gf_mse_proxy; - parser->proxy_udta = sourcebuffer; - parser->proxy_type = GF_TRUE; - return GF_OK; - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MSE] Error locating plugin for source - mime type %s\n", mime)); - return GF_BAD_PARAM; - } + } + if (parser) { + sourcebuffer->parser = parser; + parser->query_proxy = gf_mse_proxy; + parser->proxy_udta = sourcebuffer; + parser->proxy_type = GF_TRUE; + return GF_OK; + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MSE] Error locating plugin for source - mime type %s\n", mime)); + return GF_BAD_PARAM; + } } /* create a track based on the ESD and adds it to the source buffer */ static GF_HTML_Track *gf_mse_source_buffer_add_track(GF_HTML_SourceBuffer *sb, GF_ESD *esd) { - GF_HTML_Track *track; - GF_HTML_TrackType type; - - track = NULL; - type = HTML_MEDIA_TRACK_TYPE_UNKNOWN; - if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) { - type = HTML_MEDIA_TRACK_TYPE_VIDEO; - } else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) { - type = HTML_MEDIA_TRACK_TYPE_AUDIO; - } else { - /* TODO: Text tracks */ - } - - track = gf_html_media_track_new(type, "", GF_TRUE, "", "", "", ""); - if (track) { - char mx_name[256]; - track->bin_id = esd->ESID; - track->buffer = gf_list_new(); - sprintf(mx_name, "track_mutex_%d", track->bin_id); - track->buffer_mutex = gf_mx_new(mx_name); - track->timescale = esd->slConfig->timestampResolution; - gf_list_add(sb->tracks, track); - } - return track; + GF_HTML_Track *track; + GF_HTML_TrackType type; + + track = NULL; + type = HTML_MEDIA_TRACK_TYPE_UNKNOWN; + if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) { + type = HTML_MEDIA_TRACK_TYPE_VIDEO; + } else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) { + type = HTML_MEDIA_TRACK_TYPE_AUDIO; + } else { + /* TODO: Text tracks */ + } + + track = gf_html_media_track_new(type, "", GF_TRUE, "", "", "", ""); + if (track) { + char mx_name[256]; + track->bin_id = esd->ESID; + track->buffer = gf_list_new(); + sprintf(mx_name, "track_mutex_%d", track->bin_id); + track->buffer_mutex = gf_mx_new(mx_name); + track->timescale = esd->slConfig->timestampResolution; + gf_list_add(sb->tracks, track); + } + return track; } -/* Creates the different tracks based on the demuxer parser information +/* Creates the different tracks based on the demuxer parser information Needs the parser to be setup and the initialization segment passed */ static GF_Err gf_mse_source_buffer_setup_tracks(GF_HTML_SourceBuffer *sb) { if (!sb || !sb->parser || !sb->parser_connected) return GF_BAD_PARAM; - sb->service_desc = (GF_ObjectDescriptor *)sb->parser->GetServiceDescriptor(sb->parser, GF_MEDIA_OBJECT_UNDEF, NULL); - if (sb->service_desc) { - u32 count; - count = gf_list_count(sb->service_desc->ESDescriptors); - if (count) { - u32 i; - for (i = 0; i < count; i++) { - GF_ESD *esd = (GF_ESD *)gf_list_get(sb->service_desc->ESDescriptors, i); - gf_mse_source_buffer_add_track(sb, esd); - } - } - return GF_OK; - } else { - return GF_BAD_PARAM; - } + sb->service_desc = (GF_ObjectDescriptor *)sb->parser->GetServiceDescriptor(sb->parser, GF_MEDIA_OBJECT_UNDEF, NULL); + if (sb->service_desc) { + u32 count; + count = gf_list_count(sb->service_desc->ESDescriptors); + if (count) { + u32 i; + for (i = 0; i < count; i++) { + GF_ESD *esd = (GF_ESD *)gf_list_get(sb->service_desc->ESDescriptors, i); + gf_mse_source_buffer_add_track(sb, esd); + } + } + return GF_OK; + } else { + return GF_BAD_PARAM; + } } /* Adds the ObjectDescriptor to the associated track (creating a new track if needed) Called in response to addmedia events received from the parser */ static GF_Err gf_mse_source_buffer_store_track_desc(GF_HTML_SourceBuffer *sb, GF_ObjectDescriptor *od) { - u32 i; - u32 count; - GF_ESD *esd; - Bool found = GF_FALSE; - GF_HTML_Track *track; - - esd = (GF_ESD *)gf_list_get(od->ESDescriptors, 0); - count = gf_list_count(sb->tracks); - for (i = 0; i < count; i++) { - track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); - if (track->bin_id == esd->ESID) { - track->od = od; - found = GF_TRUE; - break; - } - } - if (!found) { - track = gf_mse_source_buffer_add_track(sb, esd); - if (track) { - track->od = od; - } else { - /* TODO: error */ - return GF_BAD_PARAM; - } - } - return GF_OK; + u32 i; + u32 count; + GF_ESD *esd; + Bool found = GF_FALSE; + GF_HTML_Track *track; + + esd = (GF_ESD *)gf_list_get(od->ESDescriptors, 0); + count = gf_list_count(sb->tracks); + for (i = 0; i < count; i++) { + track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); + if (track->bin_id == esd->ESID) { + track->od = od; + found = GF_TRUE; + break; + } + } + if (!found) { + track = gf_mse_source_buffer_add_track(sb, esd); + if (track) { + track->od = od; + } else { + /* TODO: error */ + return GF_BAD_PARAM; + } + } + return GF_OK; } #define SECONDS_TO_TIMESCALE(s) ((s)*track->timescale) @@ -454,15 +454,15 @@ GF_HTML_MediaTimeRanges *gf_mse_timeranges_from_track_packets(GF_HTML_Track *tra /* Traverses the list of Access Units already demuxed & parsed to update the buffered status */ void gf_mse_source_buffer_update_buffered(GF_HTML_SourceBuffer *sb) { - u32 i; - u32 track_count; + u32 i; + u32 track_count; - track_count = gf_list_count(sb->tracks); + track_count = gf_list_count(sb->tracks); gf_html_timeranges_reset(sb->buffered); - for (i = 0; i < track_count; i++) { + for (i = 0; i < track_count; i++) { GF_HTML_MediaTimeRanges *track_ranges; - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); - gf_mx_p(track->buffer_mutex); + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); + gf_mx_p(track->buffer_mutex); track_ranges = gf_mse_timeranges_from_track_packets(track); if (i != 0) { GF_HTML_MediaTimeRanges *tmp; @@ -478,13 +478,13 @@ void gf_mse_source_buffer_update_buffered(GF_HTML_SourceBuffer *sb) { sb->buffered->timescale = track_ranges->timescale; gf_free(track_ranges); } - gf_mx_v(track->buffer_mutex); - } + gf_mx_v(track->buffer_mutex); + } } void gf_mse_source_buffer_set_timestampOffset(GF_HTML_SourceBuffer *sb, double d) { u32 i; - sb->timestampOffset = (s64)(d*sb->timescale); + sb->timestampOffset = (s64)(d*sb->timescale); if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE) { sb->group_start_timestamp_flag = GF_TRUE; sb->group_start_timestamp = sb->timestampOffset; @@ -512,58 +512,58 @@ void gf_mse_source_buffer_set_timescale(GF_HTML_SourceBuffer *sb, u32 new_timesc } void gf_mse_packet_del(GF_MSE_Packet *packet) { - gf_free(packet->data); - gf_free(packet); + gf_free(packet->data); + gf_free(packet); } -static GF_MSE_Packet *gf_mse_find_overlapped_packet(GF_HTML_Track *track, - GF_MSE_Packet *packet) +static GF_MSE_Packet *gf_mse_find_overlapped_packet(GF_HTML_Track *track, + GF_MSE_Packet *packet) { - u32 i; - u32 count; - Bool found_previous; - - found_previous = GF_FALSE; - gf_mx_p(track->buffer_mutex); - count = gf_list_count(track->buffer); - for (i = 0; i < count; i++) - { - GF_MSE_Packet *p = (GF_MSE_Packet *)gf_list_get(track->buffer, i); - if (p->sl_header.compositionTimeStamp < packet->sl_header.compositionTimeStamp) { - found_previous = GF_TRUE; - } - if (found_previous == GF_TRUE && p->sl_header.compositionTimeStamp > packet->sl_header.compositionTimeStamp) { - gf_mx_v(track->buffer_mutex); - return p; - } - } - gf_mx_v(track->buffer_mutex); - return NULL; + u32 i; + u32 count; + Bool found_previous; + + found_previous = GF_FALSE; + gf_mx_p(track->buffer_mutex); + count = gf_list_count(track->buffer); + for (i = 0; i < count; i++) + { + GF_MSE_Packet *p = (GF_MSE_Packet *)gf_list_get(track->buffer, i); + if (p->sl_header.compositionTimeStamp < packet->sl_header.compositionTimeStamp) { + found_previous = GF_TRUE; + } + if (found_previous == GF_TRUE && p->sl_header.compositionTimeStamp > packet->sl_header.compositionTimeStamp) { + gf_mx_v(track->buffer_mutex); + return p; + } + } + gf_mx_v(track->buffer_mutex); + return NULL; } -static void gf_mse_remove_frames_from_to(GF_HTML_Track *track, - u64 from, - u64 to) +static void gf_mse_remove_frames_from_to(GF_HTML_Track *track, + u64 from, + u64 to) { - u32 i; + u32 i; - gf_mx_p(track->buffer_mutex); + gf_mx_p(track->buffer_mutex); i = 0; - while (i < gf_list_count(track->buffer)) { - GF_MSE_Packet *frame = (GF_MSE_Packet *)gf_list_get(track->buffer, i); + while (i < gf_list_count(track->buffer)) { + GF_MSE_Packet *frame = (GF_MSE_Packet *)gf_list_get(track->buffer, i); if (frame->sl_header.compositionTimeStamp >= to) { break; } else if (frame->sl_header.compositionTimeStamp >= from && frame->sl_header.compositionTimeStamp < to) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Removing frame with PTS %g s (%d frames remaining)\n", TIMESCALE_TO_SECONDS(frame->sl_header.compositionTimeStamp), gf_list_count(track->buffer))); - gf_list_rem(track->buffer, i); - } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Removing frame with PTS %g s (%d frames remaining)\n", TIMESCALE_TO_SECONDS(frame->sl_header.compositionTimeStamp), gf_list_count(track->buffer))); + gf_list_rem(track->buffer, i); + } else { i++; } - } - gf_mx_v(track->buffer_mutex); + } + gf_mx_v(track->buffer_mutex); } -static void gf_mse_track_buffer_add_packet(GF_HTML_Track *track, GF_MSE_Packet *frame) +static void gf_mse_track_buffer_add_packet(GF_HTML_Track *track, GF_MSE_Packet *frame) { u32 i, count; Bool inserted = GF_FALSE; @@ -582,10 +582,10 @@ static void gf_mse_track_buffer_add_packet(GF_HTML_Track *track, GF_MSE_Packet * if (i > 0) { GF_MSE_Packet *prev_frame = (GF_MSE_Packet *)gf_list_get(track->buffer, i-1); /* we update the frame duration if the newly inserted frame modifies it */ - if (!prev_frame->sl_header.au_duration || - prev_frame->sl_header.au_duration > frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp) { + if (!prev_frame->sl_header.au_duration || + prev_frame->sl_header.au_duration > frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp) { prev_frame->sl_header.au_duration = (u32)(frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp); - } + } } } inserted = GF_TRUE; @@ -599,50 +599,50 @@ static void gf_mse_track_buffer_add_packet(GF_HTML_Track *track, GF_MSE_Packet * if (count > 1) { GF_MSE_Packet *prev_frame = (GF_MSE_Packet *)gf_list_get(track->buffer, count-2); /* we update the frame duration if the newly inserted frame modifies it */ - if (!prev_frame->sl_header.au_duration || - prev_frame->sl_header.au_duration > frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp) { + if (!prev_frame->sl_header.au_duration || + prev_frame->sl_header.au_duration > frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp) { prev_frame->sl_header.au_duration = (u32)(frame->sl_header.decodingTimeStamp - prev_frame->sl_header.decodingTimeStamp); - } + } } } - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Adding frame with PTS %g s and duration %g s (%d frames in buffer)\n", TIMESCALE_TO_SECONDS(frame->sl_header.compositionTimeStamp), TIMESCALE_TO_SECONDS(frame->sl_header.au_duration), gf_list_count(track->buffer))); - gf_mx_v(track->buffer_mutex); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Adding frame with PTS %g s and duration %g s (%d frames in buffer)\n", TIMESCALE_TO_SECONDS(frame->sl_header.compositionTimeStamp), TIMESCALE_TO_SECONDS(frame->sl_header.au_duration), gf_list_count(track->buffer))); + gf_mx_v(track->buffer_mutex); } -static GF_Err gf_mse_process_coded_frame(GF_HTML_SourceBuffer *sb, - GF_HTML_Track *track, - GF_MSE_Packet *frame, - Bool *stored) +static GF_Err gf_mse_process_coded_frame(GF_HTML_SourceBuffer *sb, + GF_HTML_Track *track, + GF_MSE_Packet *frame, + Bool *stored) { s64 PTS_with_offset = frame->sl_header.compositionTimeStamp + frame->sl_header.timeStampOffset; s64 DTS_with_offset = frame->sl_header.decodingTimeStamp + frame->sl_header.timeStampOffset; *stored = GF_FALSE; - if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE && sb->group_start_timestamp_flag) { + if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE && sb->group_start_timestamp_flag) { u32 i, count; /* compute the new offset without taking care of the previous one, since this is a new coded frame group */ /* first adjust existing times to the new timescale */ gf_mse_source_buffer_set_timescale(sb, track->timescale); - sb->timestampOffset = (sb->group_start_timestamp - frame->sl_header.compositionTimeStamp); + sb->timestampOffset = (sb->group_start_timestamp - frame->sl_header.compositionTimeStamp); track->timestampOffset = (sb->group_start_timestamp - frame->sl_header.compositionTimeStamp); sb->group_end_timestamp = sb->group_start_timestamp; count = gf_list_count(sb->tracks); for (i = 0; i < count; i++) { GF_HTML_Track *t = (GF_HTML_Track *)gf_list_get(sb->tracks, i); - t->needs_rap = GF_TRUE; + t->needs_rap = GF_TRUE; } sb->group_start_timestamp_flag = GF_FALSE; - } + } - if (track->timestampOffset != 0) { + if (track->timestampOffset != 0) { frame->sl_header.timeStampOffset = track->timestampOffset; PTS_with_offset = frame->sl_header.compositionTimeStamp + frame->sl_header.timeStampOffset; DTS_with_offset = frame->sl_header.decodingTimeStamp + frame->sl_header.timeStampOffset; - } + } - if (track->last_dts_set) { - if (DTS_with_offset < (s64) track->last_dts || - DTS_with_offset - track->last_dts > 2*track->last_dur) { + if (track->last_dts_set) { + if (DTS_with_offset < (s64) track->last_dts || + DTS_with_offset - track->last_dts > 2*track->last_dur) { /* A discontinuity in the timestamps is detected, this triggers the start of a new coded frame group */ if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEGMENTS) { /* the current group ends at the start of this frame */ @@ -664,115 +664,115 @@ static GF_Err gf_mse_process_coded_frame(GF_HTML_SourceBuffer *sb, t->last_dur = 0; t->highest_pts_set = GF_FALSE; t->highest_pts = 0; - t->needs_rap = GF_TRUE; + t->needs_rap = GF_TRUE; } } return gf_mse_process_coded_frame(sb, track, frame, stored); - } - } - + } + } + /* we only update the timestamps in the frame when we are sure the offset is the right one */ frame->sl_header.compositionTimeStamp += frame->sl_header.timeStampOffset; frame->sl_header.decodingTimeStamp += frame->sl_header.timeStampOffset; frame->sl_header.timeStampOffset = 0; - if (frame->sl_header.compositionTimeStamp < SECONDS_TO_TIMESCALE(sb->appendWindowStart)) { - track->needs_rap = GF_TRUE; - return GF_OK; - } - - if (frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration > SECONDS_TO_TIMESCALE(sb->appendWindowEnd)) { - track->needs_rap = GF_TRUE; - return GF_OK; - } - - if (track->needs_rap) { - if (!frame->sl_header.randomAccessPointFlag) { - return GF_OK; - } - track->needs_rap = GF_FALSE; - } - - if (!track->last_dts_set) { - /* find a frame in the track buffer whose PTS is less than the current packet and whose PTS + dur is greater than the current packet */ - GF_MSE_Packet *overlapped_packet; - overlapped_packet = gf_mse_find_overlapped_packet(track, frame); - if (overlapped_packet) { - gf_mse_remove_frames_from_to(track, overlapped_packet->sl_header.compositionTimeStamp, - overlapped_packet->sl_header.compositionTimeStamp + (u64)SECONDS_TO_TIMESCALE(0.000001)); - } - } - - if (!track->highest_pts_set) { - /* this is the first time a frame is processed in the append sequence */ - gf_mse_remove_frames_from_to(track, frame->sl_header.compositionTimeStamp, frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration); - } else if (track->highest_pts <= frame->sl_header.compositionTimeStamp) { - /* the highest pts has already been set in this append sequence, so we just need to remove frames from that point on, it's safe */ - gf_mse_remove_frames_from_to(track, track->highest_pts, track->highest_pts + track->last_dur); - } - - /* remove dependencies !! */ - - /* TODO: spliced frames */ + if (frame->sl_header.compositionTimeStamp < SECONDS_TO_TIMESCALE(sb->appendWindowStart)) { + track->needs_rap = GF_TRUE; + return GF_OK; + } + + if (frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration > SECONDS_TO_TIMESCALE(sb->appendWindowEnd)) { + track->needs_rap = GF_TRUE; + return GF_OK; + } + + if (track->needs_rap) { + if (!frame->sl_header.randomAccessPointFlag) { + return GF_OK; + } + track->needs_rap = GF_FALSE; + } + + if (!track->last_dts_set) { + /* find a frame in the track buffer whose PTS is less than the current packet and whose PTS + dur is greater than the current packet */ + GF_MSE_Packet *overlapped_packet; + overlapped_packet = gf_mse_find_overlapped_packet(track, frame); + if (overlapped_packet) { + gf_mse_remove_frames_from_to(track, overlapped_packet->sl_header.compositionTimeStamp, + overlapped_packet->sl_header.compositionTimeStamp + (u64)SECONDS_TO_TIMESCALE(0.000001)); + } + } + + if (!track->highest_pts_set) { + /* this is the first time a frame is processed in the append sequence */ + gf_mse_remove_frames_from_to(track, frame->sl_header.compositionTimeStamp, frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration); + } else if (track->highest_pts <= frame->sl_header.compositionTimeStamp) { + /* the highest pts has already been set in this append sequence, so we just need to remove frames from that point on, it's safe */ + gf_mse_remove_frames_from_to(track, track->highest_pts, track->highest_pts + track->last_dur); + } + + /* remove dependencies !! */ + + /* TODO: spliced frames */ *stored = GF_TRUE; /* adds the packet and update the previous frame duration */ gf_mse_track_buffer_add_packet(track, frame); - track->last_dts = frame->sl_header.decodingTimeStamp; - track->last_dts_set = GF_TRUE; - if (frame->sl_header.au_duration) { + track->last_dts = frame->sl_header.decodingTimeStamp; + track->last_dts_set = GF_TRUE; + if (frame->sl_header.au_duration) { track->last_dur = frame->sl_header.au_duration; } else { /* assuming CFR - FIXME */ frame->sl_header.au_duration = track->last_dur; } - if (!track->highest_pts_set || - (frame->sl_header.compositionTimeStamp + track->last_dur) > track->highest_pts) { - track->highest_pts_set = GF_TRUE; - track->highest_pts = frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration; - } + if (!track->highest_pts_set || + (frame->sl_header.compositionTimeStamp + track->last_dur) > track->highest_pts) { + track->highest_pts_set = GF_TRUE; + track->highest_pts = frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration; + } - if (!sb->group_end_timestamp_set || (frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration > sb->group_end_timestamp)) { + if (!sb->group_end_timestamp_set || (frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration > sb->group_end_timestamp)) { /* check if sb.timescale has to be adjusted first with gf_mse_source_buffer_set_timescale(sb, track->timescale);*/ - sb->group_end_timestamp = frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration; - sb->group_end_timestamp_set = GF_TRUE; - } + sb->group_end_timestamp = frame->sl_header.compositionTimeStamp + frame->sl_header.au_duration; + sb->group_end_timestamp_set = GF_TRUE; + } - return GF_OK; + return GF_OK; } -/* Thread run function: called as a result of an append buffer - * Parses/Demultiplexes media segments and places the parsed AU in the track buffers +/* Thread run function: called as a result of an append buffer + * Parses/Demultiplexes media segments and places the parsed AU in the track buffers * * \param par the GF_HTML_SourceBuffer object used for the append */ u32 gf_mse_parse_segment(void *par) { - GF_MSE_Packet *packet; - GF_HTML_Track *track; - GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)par; - u32 i; - u32 track_count; + GF_MSE_Packet *packet; + GF_HTML_Track *track; + GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)par; + u32 i; + u32 track_count; - if (!sb->parser_connected) { + if (!sb->parser_connected) { GF_HTML_ArrayBuffer *buffer = (GF_HTML_ArrayBuffer *)gf_list_get(sb->input_buffer, 0); - gf_list_rem(sb->input_buffer, 0); + gf_list_rem(sb->input_buffer, 0); assert(buffer); /* we expect an initialization segment to connect the service */ if (!buffer->is_init) { /* TODO: set the media element decode error and run the end of stream algo */ goto exit; } - sb->parser->ConnectService(sb->parser, sb->mediasource->service, buffer->url); + sb->parser->ConnectService(sb->parser, sb->mediasource->service, buffer->url); sb->prev_buffer = buffer; - } else { - /* we expect a media segment */ + } else { + /* we expect a media segment */ GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Starting to fetch AUs from parser\n")); /* For each track, ask the parser for all the Access Unit, until it is empty - * AU are placed as GF_MSE_Packets in the track buffer + * AU are placed as GF_MSE_Packets in the track buffer */ track_count = gf_list_count(sb->tracks); while (sb->updating) { @@ -783,9 +783,9 @@ u32 gf_mse_parse_segment(void *par) track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); GF_SAFEALLOC(packet, GF_MSE_Packet); assert(track->channel); - e = sb->parser->ChannelGetSLP(sb->parser, track->channel, - &packet->data, &packet->size, &packet->sl_header, - &packet->is_compressed, &packet->status, &packet->is_new_data); + e = sb->parser->ChannelGetSLP(sb->parser, track->channel, + &packet->data, &packet->size, &packet->sl_header, + &packet->is_compressed, &packet->status, &packet->is_new_data); assert(e == GF_OK); if (packet->status == GF_OK && packet->is_new_data && packet->size) { char *data; @@ -811,10 +811,10 @@ u32 gf_mse_parse_segment(void *par) } /* reaching here, the parser does not have enough data to produce new AU */ GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Done fetching AUs from parser\n")); - } + } exit: gf_mse_source_buffer_set_update(sb, GF_FALSE); - return 0; + return 0; } @@ -823,16 +823,16 @@ void gf_mse_source_buffer_append_arraybuffer(GF_HTML_SourceBuffer *sb, GF_HTML_A assert(sb->parser); gf_mse_source_buffer_set_update(sb, GF_TRUE); - buffer->url = (char *)gf_malloc(256); - sprintf(buffer->url, "gmem://%d@%p", buffer->length, buffer->data); - buffer->reference_count++; + buffer->url = (char *)gf_malloc(256); + sprintf(buffer->url, "gmem://%d@%p", buffer->length, buffer->data); + buffer->reference_count++; buffer->is_init = (gf_isom_probe_file(buffer->url) == 2 ? GF_TRUE : GF_FALSE); - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Appending segment %s to SourceBuffer %p\n", buffer->url, sb)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Appending segment %s to SourceBuffer %p\n", buffer->url, sb)); - gf_list_add(sb->input_buffer, buffer); - /* Call the parser (asynchronously) and return */ - /* the updating attribute will be positioned back to 0 when the parser is done */ - { + gf_list_add(sb->input_buffer, buffer); + /* Call the parser (asynchronously) and return */ + /* the updating attribute will be positioned back to 0 when the parser is done */ + { GF_Thread *t = gf_th_new(NULL); gf_list_add(sb->threads, t); gf_th_run(t, gf_mse_parse_segment, sb); @@ -843,47 +843,47 @@ void gf_mse_source_buffer_append_arraybuffer(GF_HTML_SourceBuffer *sb, GF_HTML_A - Removes data in each track buffer until the next RAP is found */ static u32 gf_mse_source_buffer_remove(void *par) { - GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)par; - u32 i; - u32 j; - u32 track_count; - u32 frame_count; - u64 end = 0; + GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)par; + u32 i; + u32 j; + u32 track_count; + u32 frame_count; + u64 end = 0; gf_mse_source_buffer_set_update(sb, GF_TRUE); - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Removing media until next RAP\n")); + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Removing media until next RAP\n")); - track_count = gf_list_count(sb->tracks); - for (i = 0; i < track_count; i++) { - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); + track_count = gf_list_count(sb->tracks); + for (i = 0; i < track_count; i++) { + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(sb->tracks, i); gf_mse_source_buffer_set_timescale(sb, track->timescale); - /* find the next random access point */ - gf_mx_p(track->buffer_mutex); - frame_count = gf_list_count(track->buffer); - for (j = 0; j < frame_count; j++) { - GF_MSE_Packet *frame = (GF_MSE_Packet *)gf_list_get(track->buffer, j); - if (frame->sl_header.randomAccessPointFlag && - frame->sl_header.compositionTimeStamp >= sb->remove_end) { - end = frame->sl_header.compositionTimeStamp; - break; - } - } - gf_mx_v(track->buffer_mutex); + /* find the next random access point */ + gf_mx_p(track->buffer_mutex); + frame_count = gf_list_count(track->buffer); + for (j = 0; j < frame_count; j++) { + GF_MSE_Packet *frame = (GF_MSE_Packet *)gf_list_get(track->buffer, j); + if (frame->sl_header.randomAccessPointFlag && + frame->sl_header.compositionTimeStamp >= sb->remove_end) { + end = frame->sl_header.compositionTimeStamp; + break; + } + } + gf_mx_v(track->buffer_mutex); if (!end) end = (u64)SECONDS_TO_TIMESCALE(sb->remove_end); - /* remove up to the next RAP found */ - gf_mse_remove_frames_from_to(track, sb->remove_start, end); - } + /* remove up to the next RAP found */ + gf_mse_remove_frames_from_to(track, sb->remove_start, end); + } gf_mse_source_buffer_set_update(sb, GF_FALSE); - return 0; + return 0; } void gf_mse_remove(GF_HTML_SourceBuffer *sb, double start, double end) { sb->remove_start = (u64)(start*sb->timescale); sb->remove_end = (u64)(end*sb->timescale); - { + { GF_Thread *t = gf_th_new(NULL); gf_list_add(sb->threads, t); gf_th_run(t, gf_mse_source_buffer_remove, sb); @@ -893,112 +893,112 @@ void gf_mse_remove(GF_HTML_SourceBuffer *sb, double start, double end) /* Callback functions used by a media parser when parsing events happens */ GF_Err gf_mse_proxy(GF_InputService *parser, GF_NetworkCommand *command) { - if (!parser || !command || !parser->proxy_udta) { - return GF_BAD_PARAM; - } else { - GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)parser->proxy_udta; - switch (command->command_type) { - case GF_NET_SERVICE_QUERY_INIT_RANGE: + if (!parser || !command || !parser->proxy_udta) { + return GF_BAD_PARAM; + } else { + GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)parser->proxy_udta; + switch (command->command_type) { + case GF_NET_SERVICE_QUERY_INIT_RANGE: break; - case GF_NET_SERVICE_QUERY_NEXT: - /* The parser is asking for the next media segment in the buffer, - check for the media time and give the right one */ - { - GF_HTML_ArrayBuffer *buffer; - /* The input buffer should not be modified by append operations at the same time, no need to protect access */ - buffer = (GF_HTML_ArrayBuffer *)gf_list_get(sb->input_buffer, 0); - if (buffer) { - command->url_query.discontinuity_type = 0; - command->url_query.current_download = GF_FALSE; - command->url_query.start_range = 0; - command->url_query.end_range = 0; - command->url_query.switch_start_range = 0; - command->url_query.switch_end_range = 0; - command->url_query.next_url_init_or_switch_segment = NULL; - if (buffer->is_init) { - GF_HTML_ArrayBuffer *next = (GF_HTML_ArrayBuffer *)gf_list_get(sb->input_buffer, 1); - command->url_query.discontinuity_type = 1; - if (next) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Next segment to parse %s with init \n", next->url, buffer->url)); - command->url_query.next_url = next->url; - command->url_query.next_url_init_or_switch_segment = buffer->url; - gf_list_rem(sb->input_buffer, 0); - gf_list_rem(sb->input_buffer, 0); - } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Only one init segment to parse %s, need to wait\n", buffer->url)); - command->url_query.next_url = NULL; - } - } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Next segment to parse %s\n", buffer->url)); - command->url_query.next_url = buffer->url; + case GF_NET_SERVICE_QUERY_NEXT: + /* The parser is asking for the next media segment in the buffer, + check for the media time and give the right one */ + { + GF_HTML_ArrayBuffer *buffer; + /* The input buffer should not be modified by append operations at the same time, no need to protect access */ + buffer = (GF_HTML_ArrayBuffer *)gf_list_get(sb->input_buffer, 0); + if (buffer) { + command->url_query.discontinuity_type = 0; + command->url_query.current_download = GF_FALSE; + command->url_query.start_range = 0; + command->url_query.end_range = 0; + command->url_query.switch_start_range = 0; + command->url_query.switch_end_range = 0; + command->url_query.next_url_init_or_switch_segment = NULL; + if (buffer->is_init) { + GF_HTML_ArrayBuffer *next = (GF_HTML_ArrayBuffer *)gf_list_get(sb->input_buffer, 1); + command->url_query.discontinuity_type = 1; + if (next) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Next segment to parse %s with init \n", next->url, buffer->url)); + command->url_query.next_url = next->url; + command->url_query.next_url_init_or_switch_segment = buffer->url; + gf_list_rem(sb->input_buffer, 0); gf_list_rem(sb->input_buffer, 0); + } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Only one init segment to parse %s, need to wait\n", buffer->url)); + command->url_query.next_url = NULL; } - sb->prev_buffer = buffer; - } else { - command->url_query.next_url = NULL; - command->url_query.discontinuity_type = 0; - } - } - break; - case GF_NET_SERVICE_STATUS_PROXY: - /* The parser is informing the proxy about its status changes: - - new track found + } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Next segment to parse %s\n", buffer->url)); + command->url_query.next_url = buffer->url; + gf_list_rem(sb->input_buffer, 0); + } + sb->prev_buffer = buffer; + } else { + command->url_query.next_url = NULL; + command->url_query.discontinuity_type = 0; + } + } + break; + case GF_NET_SERVICE_STATUS_PROXY: + /* The parser is informing the proxy about its status changes: + - new track found - all tracks parsed - connect/disconnect - */ - if (command->status.is_add_media) { - if (command->status.desc) { - gf_mse_source_buffer_store_track_desc(sb, (GF_ObjectDescriptor *)command->status.desc); - } else { - /* this is the last add media, we can switch updating to false */ - /* the first init segment was correctly processed */ + if (command->status.is_add_media) { + if (command->status.desc) { + gf_mse_source_buffer_store_track_desc(sb, (GF_ObjectDescriptor *)command->status.desc); + } else { + /* this is the last add media, we can switch updating to false */ + /* the first init segment was correctly processed */ gf_mse_source_buffer_set_update(sb, GF_FALSE); - /* TODO: set active tracks and send addsourcebuffer event */ - /* TODO: send media loadedmetadata event */ - } - gf_term_add_media(sb->mediasource->service, command->status.desc, (command->status.desc ? GF_TRUE : GF_FALSE)); - } - /* general connection/disconnection messages from the media parser (not track related) */ - else if (!command->status.channel) { - /* connection message */ - if (!command->status.is_disconnect) { - if (command->status.e == GF_OK) { - /* nothing needs to be done. Setup is done with final add media */ - sb->parser_connected = GF_TRUE; - sb->mediasource->durationType = DURATION_INFINITY; - gf_mse_source_buffer_setup_tracks(sb); - } else { - /* wrong first init segment */ - /* TODO: fire an error event */ - } - gf_term_on_connect(sb->mediasource->service, command->status.channel, command->status.e); - } else { - gf_term_on_disconnect(sb->mediasource->service, command->status.channel, command->status.e); - } - } - /* channel (track related) specific connection/disconnection messages from the media parser */ - else { - if (!command->status.is_disconnect) { - gf_term_on_connect(sb->mediasource->service, command->status.channel, command->status.e); - } else { - gf_term_on_disconnect(sb->mediasource->service, command->status.channel, command->status.e); - } - } - break; - default: - gf_term_on_command(sb->mediasource->service, command, GF_OK); - break; - } - return GF_OK; - } + /* TODO: set active tracks and send addsourcebuffer event */ + /* TODO: send media loadedmetadata event */ + } + gf_service_declare_media(sb->mediasource->service, command->status.desc, (command->status.desc ? GF_TRUE : GF_FALSE)); + } + /* general connection/disconnection messages from the media parser (not track related) */ + else if (!command->status.channel) { + /* connection message */ + if (!command->status.is_disconnect) { + if (command->status.e == GF_OK) { + /* nothing needs to be done. Setup is done with final add media */ + sb->parser_connected = GF_TRUE; + sb->mediasource->durationType = DURATION_INFINITY; + gf_mse_source_buffer_setup_tracks(sb); + } else { + /* wrong first init segment */ + /* TODO: fire an error event */ + } + gf_service_connect_ack(sb->mediasource->service, command->status.channel, command->status.e); + } else { + gf_service_disconnect_ack(sb->mediasource->service, command->status.channel, command->status.e); + } + } + /* channel (track related) specific connection/disconnection messages from the media parser */ + else { + if (!command->status.is_disconnect) { + gf_service_connect_ack(sb->mediasource->service, command->status.channel, command->status.e); + } else { + gf_service_disconnect_ack(sb->mediasource->service, command->status.channel, command->status.e); + } + } + break; + default: + gf_service_command(sb->mediasource->service, command, GF_OK); + break; + } + return GF_OK; + } } -/* Track Buffer Managment: +/* Track Buffer Managment: * - Access Units are parsed/demultiplexed from the SourceBuffer input buffer and placed into individual track buffers * - The parsing/demux is done in a separate thread (so access to the the track buffer is protected by a mutex) * * Track Buffer Length: number of Access Units */ -#define MSE_TRACK_BUFFER_LENGTH 1000 +#define MSE_TRACK_BUFFER_LENGTH 1000 /* When an Access Unit can be released, we check if it needs to be kept or not in the track buffer */ GF_EXPORT @@ -1023,9 +1023,9 @@ GF_Err gf_mse_track_buffer_release_packet(GF_HTML_Track *track) { /* Requests from the decoders to get the next Access Unit: we get it from the track buffer */ GF_EXPORT GF_Err gf_mse_track_buffer_get_next_packet(GF_HTML_Track *track, - char **out_data_ptr, u32 *out_data_size, - GF_SLHeader *out_sl_hdr, Bool *sl_compressed, - GF_Err *out_reception_status, Bool *is_new_data) + char **out_data_ptr, u32 *out_data_size, + GF_SLHeader *out_sl_hdr, Bool *sl_compressed, + GF_Err *out_reception_status, Bool *is_new_data) { GF_MSE_Packet *packet; u32 count; diff --git a/src/media_tools/img.c b/src/media_tools/img.c index 9a8d4a4..79e60eb 100644 --- a/src/media_tools/img.c +++ b/src/media_tools/img.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -127,11 +127,11 @@ void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height else if ((b1==0x89) && (b2==0x50) && (b3==0x4E)) { /*check for PNG sig*/ if ( (gf_bs_read_u8(bs) != 0x47) || (gf_bs_read_u8(bs) != 0x0D) || (gf_bs_read_u8(bs) != 0x0A) - || (gf_bs_read_u8(bs) != 0x1A) || (gf_bs_read_u8(bs) != 0x0A) ) goto exit; + || (gf_bs_read_u8(bs) != 0x1A) || (gf_bs_read_u8(bs) != 0x0A) ) goto exit; gf_bs_read_u32(bs); /*check for PNG IHDR*/ if ( (gf_bs_read_u8(bs) != 'I') || (gf_bs_read_u8(bs) != 'H') - || (gf_bs_read_u8(bs) != 'D') || (gf_bs_read_u8(bs) != 'R')) goto exit; + || (gf_bs_read_u8(bs) != 'D') || (gf_bs_read_u8(bs) != 'R')) goto exit; *width = gf_bs_read_u32(bs); *height = gf_bs_read_u32(bs); @@ -141,7 +141,7 @@ void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height size = gf_bs_read_u8(bs); type = gf_bs_read_u32(bs); if ( ((size==12) && (type==GF_4CC('j','P',' ',' ') )) - || (type==GF_4CC('j','p','2','h') ) ) { + || (type==GF_4CC('j','p','2','h') ) ) { if (type==GF_4CC('j','p','2','h')) { *OTI = GPAC_OTI_IMAGE_JPEG_2000; @@ -188,7 +188,7 @@ j2k_restart: } goto exit; } - break; + break; default: gf_bs_skip_bytes(bs, size-8); break; @@ -214,13 +214,13 @@ typedef struct typedef struct { /*io manager*/ - struct jpeg_source_mgr src; + struct jpeg_source_mgr src; s32 skip; struct jpeg_decompress_struct cinfo; } JPGCtx; -static void gf_jpeg_output_message (j_common_ptr cinfo){ +static void gf_jpeg_output_message (j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; /* Create the message */ (*cinfo->err->format_message) (cinfo, buffer); @@ -237,7 +237,9 @@ static void gf_jpeg_fatal_error(j_common_ptr cinfo) void gf_jpeg_stub(j_decompress_ptr cinfo) {} /*a JPEG is always carried in a complete, single MPEG4 AU so no refill*/ -static boolean gf_jpeg_fill_input_buffer(j_decompress_ptr cinfo) { return 0; } +static boolean gf_jpeg_fill_input_buffer(j_decompress_ptr cinfo) { + return 0; +} static void gf_jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { @@ -287,7 +289,7 @@ GF_Err gf_img_jpeg_dec(char *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pi jpx.src.term_source = gf_jpeg_stub; jpx.skip = 0; jpx.src.next_input_byte = (JOCTET *) jpg; - jpx.src.bytes_in_buffer = jpg_size; + jpx.src.bytes_in_buffer = jpg_size; jpx.cinfo.src = (void *) &jpx.src; /*read header*/ @@ -315,8 +317,8 @@ GF_Err gf_img_jpeg_dec(char *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pi jpeg_destroy_decompress(&jpx.cinfo); return GF_NON_COMPLIANT_BITSTREAM; } - if (*dst_size < *height * *width * jpx.cinfo.num_components) { - *dst_size = *height * *width * jpx.cinfo.num_components; + if (*dst_size < *height **width * jpx.cinfo.num_components) { + *dst_size = *height **width * jpx.cinfo.num_components; jpeg_destroy_decompress(&jpx.cinfo); return GF_BUFFER_TOO_SMALL; } @@ -340,15 +342,15 @@ GF_Err gf_img_jpeg_dec(char *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pi /*read scanlines (the scan is not one line by one line so alloc a placeholder for block scaning) */ scan_line = gf_malloc(sizeof(char) * stride * jpx.cinfo.rec_outbuf_height); - for (i = 0; iin_text_header = 1; return; @@ -190,10 +190,10 @@ void isma_ea_node_start(void *sax_cbck, const char *node_name, const char *name_ tkc = (GF_TrackCryptInfo *)gf_list_last(info->tcis); tkc->KIDs = (bin128 *)gf_realloc(tkc->KIDs, sizeof(bin128)*(tkc->KID_count+1)); tkc->keys = (bin128 *)gf_realloc(tkc->keys, sizeof(bin128)*(tkc->KID_count+1)); - + for (i=0; iname, "KID")) { gf_bin128_parse(att->value, tkc->KIDs[tkc->KID_count]); } @@ -300,7 +300,7 @@ Bool gf_ismacryp_mpeg4ip_get_info(char *kms_uri, char *key, char *salt) Bool got_it; FILE *kms; strcpy(szPath, getenv("HOME")); - strcat(szPath , "/.kms_data"); + strcat(szPath , "/.kms_data"); got_it = 0; kms = gf_f64_open(szPath, "r"); while (kms && !feof(kms)) { @@ -369,7 +369,7 @@ GF_Err gf_ismacryp_decrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( track = gf_isom_get_track_by_id(mp4, tci->trackID); e = gf_isom_get_ismacryp_info(mp4, track, 1, &is_avc, NULL, NULL, NULL, NULL, &use_sel_enc, &IV_size, NULL); is_avc = (is_avc==GF_4CC('2','6','4','b')) ? 1 : 0; - + mc = gf_crypt_open("AES-128", "CTR"); if (!mc) { @@ -394,7 +394,7 @@ GF_Err gf_ismacryp_decrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( count = gf_isom_get_sample_count(mp4, track); gf_isom_set_nalu_extract_mode(mp4, track, GF_ISOM_NALU_EXTRACT_INSPECT); for (i = 0; i < count; i++) { - samp = gf_isom_get_sample(mp4, track, i+1, &si); + samp = gf_isom_get_sample(mp4, track, i+1, &si); ismasamp = gf_isom_get_ismacryp_sample(mp4, track, samp, si); gf_free(samp->data); @@ -491,7 +491,7 @@ GF_Err gf_ismacryp_decrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( gf_isom_update_sample(mp4, i+1, 1, samp, 1); gf_isom_sample_del(&samp); - /*remove IPMPToolList if any*/ + /*remove IPMPToolList if any*/ gf_isom_ipmpx_remove_tool_list(mp4); break; } @@ -546,7 +546,7 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( if (!tci->enc_type && !strlen(tci->Scheme_URI)) strcpy(tci->Scheme_URI, "urn:gpac:isma:encryption_scheme"); if (!gf_isom_has_sync_points(mp4, track) && - ((tci->sel_enc_type==GF_CRYPT_SELENC_RAP) || (tci->sel_enc_type==GF_CRYPT_SELENC_NON_RAP)) ) { + ((tci->sel_enc_type==GF_CRYPT_SELENC_RAP) || (tci->sel_enc_type==GF_CRYPT_SELENC_NON_RAP)) ) { GF_LOG(GF_LOG_WARNING, GF_LOG_AUTHOR, ("[CENC/ISMA] All samples in trackID %d are random access - disabling selective encryption\n", tci->trackID)); tci->sel_enc_type = GF_CRYPT_SELENC_NONE; } @@ -593,21 +593,21 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( /*create ISMA protection*/ if (tci->enc_type==0) { - e = gf_isom_set_ismacryp_protection(mp4, track, 1, GF_ISOM_ISMACRYP_SCHEME, 1, - tci->Scheme_URI, tci->KMS_URI, (tci->sel_enc_type!=0) ? 1 : 0, 0, IV_size); + e = gf_isom_set_ismacryp_protection(mp4, track, 1, GF_ISOM_ISMACRYP_SCHEME, 1, + tci->Scheme_URI, tci->KMS_URI, (tci->sel_enc_type!=0) ? 1 : 0, 0, IV_size); } else { if ((tci->sel_enc_type==GF_CRYPT_SELENC_PREVIEW) && tci->sel_enc_range) { char *szPreview = tci->TextualHeaders + tci->TextualHeadersLen; sprintf(szPreview, "PreviewRange:%d", tci->sel_enc_range); tci->TextualHeadersLen += (u32) strlen(szPreview)+1; } - e = gf_isom_set_oma_protection(mp4, track, 1, - strlen(tci->Scheme_URI) ? tci->Scheme_URI : NULL, - tci->KMS_URI, - tci->encryption, BSO, - tci->TextualHeadersLen ? tci->TextualHeaders : NULL, - tci->TextualHeadersLen, - (tci->sel_enc_type!=0) ? 1 : 0, 0, IV_size); + e = gf_isom_set_oma_protection(mp4, track, 1, + strlen(tci->Scheme_URI) ? tci->Scheme_URI : NULL, + tci->KMS_URI, + tci->encryption, BSO, + tci->TextualHeadersLen ? tci->TextualHeaders : NULL, + tci->TextualHeadersLen, + (tci->sel_enc_type!=0) ? 1 : 0, 0, IV_size); } if (e) return e; @@ -624,7 +624,7 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( count = gf_isom_get_sample_count(mp4, track); gf_isom_set_nalu_extract_mode(mp4, track, GF_ISOM_NALU_EXTRACT_INSPECT); for (i = 0; i < count; i++) { - samp = gf_isom_get_sample(mp4, track, i+1, &di); + samp = gf_isom_get_sample(mp4, track, i+1, &di); isamp = gf_isom_ismacryp_new_sample(); isamp->IV_length = IV_size; @@ -660,7 +660,7 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( if (!(i%tci->sel_enc_type)) isamp->flags |= GF_ISOM_ISMA_IS_ENCRYPTED; break; case GF_CRYPT_SELENC_PREVIEW: - if (samp->DTS + samp->CTS_Offset >= range_end) + if (samp->DTS + samp->CTS_Offset >= range_end) isamp->flags |= GF_ISOM_ISMA_IS_ENCRYPTED; break; case 0: @@ -677,7 +677,8 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( u8 *d = (u8*)samp->data; while (done < samp->dataLength) { u32 nal_size = GF_4CC(d[0], d[1], d[2], d[3]); - d[0] = d[1] = d[2] = 0; d[3] = 1; + d[0] = d[1] = d[2] = 0; + d[3] = 1; d += 4 + nal_size; done += 4 + nal_size; } @@ -710,7 +711,7 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( gf_crypt_close(mc); - /*format as IPMP(X) - note that the ISMACryp spec is broken since it always uses IPMPPointers to a + /*format as IPMP(X) - note that the ISMACryp spec is broken since it always uses IPMPPointers to a single desc which would assume the same protection (eg key & salt) for all streams using it...*/ if (!tci->ipmp_type) return GF_OK; @@ -733,7 +734,8 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( ipmpd->IPMP_DescriptorID = 0xFF; ipmpd->IPMP_DescriptorIDEx = tci->ipmp_desc_id; ipmpd->IPMPS_Type = 0xFFFF; - ipmpd->IPMP_ToolID[14] = 0x49; ipmpd->IPMP_ToolID[15] = 0x53; + ipmpd->IPMP_ToolID[14] = 0x49; + ipmpd->IPMP_ToolID[15] = 0x53; ipmpd->control_point = 1; ipmpd->cp_sequence_code = 0x80; /*format IPMPXData*/ @@ -773,7 +775,8 @@ GF_Err gf_ismacryp_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void ( GF_IPMP_ToolList*ipmptl = (GF_IPMP_ToolList*)gf_odf_desc_new(GF_ODF_IPMP_TL_TAG); GF_IPMP_Tool *ipmpt = (GF_IPMP_Tool*)gf_odf_desc_new(GF_ODF_IPMP_TOOL_TAG); gf_list_add(ipmptl->ipmp_tools, ipmpt); - ipmpt->IPMP_ToolID[14] = 0x49; ipmpt->IPMP_ToolID[15] = 0x53; + ipmpt->IPMP_ToolID[14] = 0x49; + ipmpt->IPMP_ToolID[15] = 0x53; gf_isom_add_desc_to_root_od(mp4, (GF_Descriptor *)ipmptl); gf_odf_desc_del((GF_Descriptor *)ipmptl); } @@ -825,7 +828,7 @@ static void cenc_resync_IV(GF_Crypt *mc, char IV[16], u64 BSO, u8 IV_size, Bool block_count_portion += prev_block_count; gf_bs_write_u64(bs, salt_portion); gf_bs_write_u64(bs, block_count_portion); - } + } gf_crypt_set_state(mc, next_IV, 17); /*decrypt remain bytes*/ @@ -841,7 +844,7 @@ static void cenc_resync_IV(GF_Crypt *mc, char IV[16], u64 BSO, u8 IV_size, Bool } else { u32 j; - digest[0] = 0; + digest[0] = 0; for ( j=0; j<16; j++ ) { t[2] = 0; sprintf ( t, "%02X", (u8) next_IV[j+1] ); @@ -873,7 +876,7 @@ static GF_Err gf_cenc_encrypt_sample_ctr(GF_Crypt *mc, GF_ISOSample *samp, Bool subsamples = gf_list_new(); if (!subsamples) { e = GF_IO_ERR; - goto exit; + goto exit; } while (gf_bs_available(pleintext_bs)) { GF_CENCSubSampleEntry *entry = (GF_CENCSubSampleEntry *)gf_malloc(sizeof(GF_CENCSubSampleEntry)); @@ -904,7 +907,7 @@ static GF_Err gf_cenc_encrypt_sample_ctr(GF_Crypt *mc, GF_ISOSample *samp, Bool gf_crypt_encrypt(mc, buffer, samp->dataLength); gf_bs_write_data(cyphertext_bs, buffer, samp->dataLength); - BSO += samp->dataLength; + BSO += samp->dataLength; entry->bytes_clear_data = 0; entry->bytes_encrypted_data = samp->dataLength; } @@ -962,7 +965,7 @@ static GF_Err gf_cenc_encrypt_sample_cbc(GF_Crypt *mc, GF_ISOSample *samp, Bool subsamples = gf_list_new(); if (!subsamples) { e = GF_IO_ERR; - goto exit; + goto exit; } while (gf_bs_available(pleintext_bs)) { u32 ret; @@ -1127,14 +1130,14 @@ GF_Err gf_cenc_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pro count = gf_isom_get_sample_count(mp4, track); - + has_crypted_samp = GF_FALSE; nb_samp_encrypted = 0; /*Sample Encryption Box*/ e = gf_isom_cenc_allocate_storage(mp4, track, tci->sai_saved_box_type, 0, 0, NULL); if (e) goto exit; - - if (! gf_isom_has_sync_points(mp4, track)) + + if (! gf_isom_has_sync_points(mp4, track)) all_rap = GF_TRUE; gf_isom_set_nalu_extract_mode(mp4, track, GF_ISOM_NALU_EXTRACT_INSPECT); @@ -1145,41 +1148,41 @@ GF_Err gf_cenc_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pro e = GF_IO_ERR; goto exit; } - + switch (tci->sel_enc_type) { - case GF_CRYPT_SELENC_RAP: - if (!samp->IsRAP && !all_rap) { - e = gf_isom_track_cenc_add_sample_info(mp4, track, tci->sai_saved_box_type, 0, NULL, 0); - if (e) - goto exit; - buf = NULL; - - //already done: memset(tmp, 0, 16); - e = gf_isom_set_sample_cenc_group(mp4, track, i+1, 0, 0, NULL); - if (e) goto exit; - - gf_isom_sample_del(&samp); - continue; - } - break; - case GF_CRYPT_SELENC_NON_RAP: - if (samp->IsRAP || all_rap) { - e = gf_isom_track_cenc_add_sample_info(mp4, track, tci->sai_saved_box_type, 0, NULL, 0); - if (e) - goto exit; - buf = NULL; + case GF_CRYPT_SELENC_RAP: + if (!samp->IsRAP && !all_rap) { + e = gf_isom_track_cenc_add_sample_info(mp4, track, tci->sai_saved_box_type, 0, NULL, 0); + if (e) + goto exit; + buf = NULL; + + //already done: memset(tmp, 0, 16); + e = gf_isom_set_sample_cenc_group(mp4, track, i+1, 0, 0, NULL); + if (e) goto exit; - //alreaduy done: memset(tmp, 0, 16); + gf_isom_sample_del(&samp); + continue; + } + break; + case GF_CRYPT_SELENC_NON_RAP: + if (samp->IsRAP || all_rap) { + e = gf_isom_track_cenc_add_sample_info(mp4, track, tci->sai_saved_box_type, 0, NULL, 0); + if (e) + goto exit; + buf = NULL; - e = gf_isom_set_sample_cenc_group(mp4, track, i+1, 0, 0, NULL); - if (e) goto exit; + //alreaduy done: memset(tmp, 0, 16); - gf_isom_sample_del(&samp); - continue; - } - break; - default: - break; + e = gf_isom_set_sample_cenc_group(mp4, track, i+1, 0, 0, NULL); + if (e) goto exit; + + gf_isom_sample_del(&samp); + continue; + } + break; + default: + break; } /*generate initialization vector for the first sample in track ... */ @@ -1188,11 +1191,11 @@ GF_Err gf_cenc_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pro if (tci->IV_size == 8) { memcpy(IV, tci->first_IV, sizeof(char)*8); memset(IV+8, 0, sizeof(char)*8); - } + } else if (tci->IV_size == 16) { memcpy(IV, tci->first_IV, sizeof(char)*16); } - else + else return GF_NOT_SUPPORTED; e = gf_crypt_init(mc, tci->key, 16, IV); @@ -1231,13 +1234,13 @@ GF_Err gf_cenc_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pro gf_crypt_get_state(mc, IV, &IV_size); gf_cenc_encrypt_sample_cbc(mc, samp, is_nalu_video, nalu_size_length, IV, tci->IV_size, &buf, &len, bytes_in_nalhr); } - + gf_isom_update_sample(mp4, track, i+1, samp, 1); gf_isom_sample_del(&samp); samp = NULL; e = gf_isom_track_cenc_add_sample_info(mp4, track, tci->sai_saved_box_type, tci->IV_size, buf, len); - if (e) + if (e) goto exit; gf_free(buf); buf = NULL; @@ -1377,40 +1380,53 @@ GF_Err gf_cenc_decrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pro } } - subsample_count = 0; - while (gf_bs_available(cyphertext_bs)) { - assert(subsample_count < sai->subsample_count); + //sub-sample encryption + if (sai->subsample_count) { + subsample_count = 0; + while (gf_bs_available(cyphertext_bs)) { + assert(subsample_count < sai->subsample_count); - /*read clear data and write it to pleintext bitstream*/ - if (max_size < sai->subsamples[subsample_count].bytes_clear_data) { - buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_clear_data); - max_size = sai->subsamples[subsample_count].bytes_clear_data; - } - gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); - gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); + /*read clear data and write it to pleintext bitstream*/ + if (max_size < sai->subsamples[subsample_count].bytes_clear_data) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_clear_data); + max_size = sai->subsamples[subsample_count].bytes_clear_data; + } + gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); + gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_clear_data); - /*now read encrypted data, decrypted it and write to pleintext bitstream*/ - if (max_size < sai->subsamples[subsample_count].bytes_encrypted_data) { - buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_encrypted_data); - max_size = sai->subsamples[subsample_count].bytes_encrypted_data; - } - gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); - gf_crypt_decrypt(mc, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); - gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + /*now read encrypted data, decrypted it and write to pleintext bitstream*/ + if (max_size < sai->subsamples[subsample_count].bytes_encrypted_data) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*sai->subsamples[subsample_count].bytes_encrypted_data); + max_size = sai->subsamples[subsample_count].bytes_encrypted_data; + } + gf_bs_read_data(cyphertext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + gf_crypt_decrypt(mc, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + gf_bs_write_data(pleintext_bs, buffer, sai->subsamples[subsample_count].bytes_encrypted_data); + + /*update IV for next subsample*/ + if (tci->enc_type == 2) { + BSO += sai->subsamples[subsample_count].bytes_encrypted_data; + if (gf_bs_available(cyphertext_bs)) + cenc_resync_IV(mc, (char *)sai->IV, BSO, tci->IV_size, GF_FALSE); + } - /*update IV for next subsample*/ - if (tci->enc_type == 2) { - BSO += sai->subsamples[subsample_count].bytes_encrypted_data; - if (gf_bs_available(cyphertext_bs)) - cenc_resync_IV(mc, (char *)sai->IV, BSO, tci->IV_size, GF_FALSE); + subsample_count++; } - - subsample_count++; + } + //full sample encryption + else { + if (max_size < samp->dataLength) { + buffer = (char*)gf_realloc(buffer, sizeof(char)*samp->dataLength); + max_size = samp->dataLength; + } + gf_bs_read_data(cyphertext_bs, buffer,samp->dataLength); + gf_crypt_decrypt(mc, buffer, samp->dataLength); + gf_bs_write_data(pleintext_bs, buffer, samp->dataLength); } gf_isom_cenc_samp_aux_info_del(sai); sai = NULL; - + gf_bs_del(cyphertext_bs); cyphertext_bs = NULL; if (samp->data) { @@ -1488,9 +1504,9 @@ GF_Err gf_adobe_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pr e = gf_isom_set_adobe_protection(mp4, track, 1, GF_ISOM_ADOBE_SCHEME, 1, GF_TRUE, tci->metadata, tci->metadata_len); if (e) goto exit; - count = gf_isom_get_sample_count(mp4, track); + count = gf_isom_get_sample_count(mp4, track); has_crypted_samp = GF_FALSE; - if (! gf_isom_has_sync_points(mp4, track)) + if (! gf_isom_has_sync_points(mp4, track)) all_rap = GF_TRUE; gf_isom_set_nalu_extract_mode(mp4, track, GF_ISOM_NALU_EXTRACT_INSPECT); @@ -1508,20 +1524,20 @@ GF_Err gf_adobe_encrypt_track(GF_ISOFile *mp4, GF_TrackCryptInfo *tci, void (*pr memmove(buf, samp->data, len); gf_free(samp->data); samp->dataLength = 0; - + switch (tci->sel_enc_type) { - case GF_CRYPT_SELENC_RAP: - if (!samp->IsRAP && !all_rap) { - is_encrypted_au = GF_FALSE; - } - break; - case GF_CRYPT_SELENC_NON_RAP: - if (samp->IsRAP || all_rap) { - is_encrypted_au = GF_FALSE; - } - break; - default: - break; + case GF_CRYPT_SELENC_RAP: + if (!samp->IsRAP && !all_rap) { + is_encrypted_au = GF_FALSE; + } + break; + case GF_CRYPT_SELENC_NON_RAP: + if (samp->IsRAP || all_rap) { + is_encrypted_au = GF_FALSE; + } + break; + default: + break; } if (is_encrypted_au) { @@ -1721,7 +1737,7 @@ GF_Err gf_decrypt_file(GF_ISOFile *mp4, const char *drm_file) if (!a_tci->trackID) break; } } - + nb_tracks = gf_isom_get_track_count(mp4); e = GF_OK; for (i=0; icrypt_type) { - case 1: - gf_decrypt_track = gf_ismacryp_decrypt_track; - break; - case 2: - tci.enc_type = 2; - gf_decrypt_track = gf_cenc_decrypt_track; - break; - case 3: - tci.enc_type = 3; - gf_decrypt_track = gf_cenc_decrypt_track; - break; - case 4: - gf_decrypt_track = gf_adobe_decrypt_track; - break; - default: - GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Encryption type not supported\n")); - return GF_NOT_SUPPORTED;; + case 1: + gf_decrypt_track = gf_ismacryp_decrypt_track; + break; + case 2: + tci.enc_type = 2; + gf_decrypt_track = gf_cenc_decrypt_track; + break; + case 3: + tci.enc_type = 3; + gf_decrypt_track = gf_cenc_decrypt_track; + break; + case 4: + gf_decrypt_track = gf_adobe_decrypt_track; + break; + default: + GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Encryption type not supported\n")); + return GF_NOT_SUPPORTED;; } if (gf_isom_is_ismacryp_media(mp4, i+1, 1)) { @@ -1775,7 +1791,7 @@ GF_Err gf_decrypt_file(GF_ISOFile *mp4, const char *drm_file) } KMS_URI = "OMA DRM"; is_oma = 1; - } else if (!gf_isom_is_cenc_media(mp4, i+1, 1) && !gf_isom_is_adobe_protection_media(mp4, i+1, 1)){ + } else if (!gf_isom_is_cenc_media(mp4, i+1, 1) && !gf_isom_is_adobe_protection_media(mp4, i+1, 1)) { GF_LOG(GF_LOG_WARNING, GF_LOG_AUTHOR, ("[CENC/ISMA] TrackID %d encrypted with unknown scheme %s - skipping\n", trackID, gf_4cc_to_str(scheme_type) )); continue; } @@ -1826,7 +1842,7 @@ GF_Err gf_decrypt_file(GF_ISOFile *mp4, const char *drm_file) e = gf_isom_set_brand_info(mp4, GF_4CC('i','s','o','2'), 0x00000001); if (!e) e = gf_isom_modify_alternate_brand(mp4, GF_4CC('o','d','c','f'), 0); } - if ((info->crypt_type == 2) || (info->crypt_type == 3)) + if ((info->crypt_type == 2) || (info->crypt_type == 3)) e = gf_isom_remove_pssh_box(mp4); if (info) del_crypt_info(info); return e; @@ -1872,17 +1888,17 @@ static GF_Err gf_cenc_parse_drm_system_info(GF_ISOFile *mp4, const char *drm_fil while ( (att = (GF_XMLAttribute *)gf_list_enum(node->attributes, &j))) { if (!strcmp(att->name, "type")) { - if (!strcmp(att->value, "pssh")) + if (!strcmp(att->value, "pssh")) is_pssh = GF_TRUE; } else if (!strcmp(att->name, "version")) { version = atoi(att->value); } else if (!strcmp(att->name, "cypher-mode")) { /*cypher-mode: 0: data (default mode) - 1: all - 2: clear*/ - if (!strcmp(att->value, "data")) + if (!strcmp(att->value, "data")) cypherMode = 0; - else if (!strcmp(att->value, "all")) + else if (!strcmp(att->value, "all")) cypherMode = 1; - else if (!strcmp(att->value, "clear")) + else if (!strcmp(att->value, "clear")) cypherMode = 2; } else if (!strcmp(att->name, "cypherKey")) { gf_bin128_parse(att->value, cypherKey); @@ -2019,7 +2035,7 @@ GF_Err gf_crypt_file(GF_ISOFile *mp4, const char *drm_file) default: GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Encryption type not sopported\n")); return GF_NOT_SUPPORTED;; - } + } /*default to FILE uri*/ if (!strlen(tci->KMS_URI)) strcpy(tci->KMS_URI, drm_file); diff --git a/src/media_tools/isom_hinter.c b/src/media_tools/isom_hinter.c index 7fc027f..3e35d9f 100644 --- a/src/media_tools/isom_hinter.c +++ b/src/media_tools/isom_hinter.c @@ -1,7 +1,7 @@ /* * GPAC - Multimedia Framework C SDK * - * Authors: Jean Le Feuvre + * Authors: Jean Le Feuvre * Copyright (c) Telecom ParisTech 2000-2012 * All rights reserved * @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -66,7 +66,7 @@ void gf_media_get_sample_average_infos(GF_ISOFile *file, u32 Track, u32 *avgSize prevTS = samp->DTS+samp->CTS_Offset; bw += 8*samp->dataLength; - + //get the CTS delta if ((samp->CTS_Offset>=0) && ((u32)samp->CTS_Offset > *maxCTSDelta)) *maxCTSDelta = samp->CTS_Offset; @@ -169,7 +169,7 @@ void MP4T_OnPacketDone(void *cbk, GF_RTPHeader *header) GF_RTPHinter *tkHint = (GF_RTPHinter *)cbk; if (!tkHint || !tkHint->HintSample) return; assert(header->TimeStamp == tkHint->RTPTime); - + disposable = 0; if (tkHint->avc_nalu_size) { disposable = tkHint->rtp_p->avc_non_idr ? 1 : 0; @@ -190,8 +190,8 @@ void MP4T_OnDataRef(void *cbk, u32 payload_size, u32 offset_from_orig) /*add reference*/ gf_isom_hint_sample_data(tkHint->file, tkHint->HintTrack, tkHint->TrackID, - tkHint->CurrentSample, (u16) payload_size, offset_from_orig + tkHint->base_offset_in_sample, - NULL, 0); + tkHint->CurrentSample, (u16) payload_size, offset_from_orig + tkHint->base_offset_in_sample, + NULL, 0); } void MP4T_OnData(void *cbk, char *data, u32 data_size, Bool is_header) @@ -229,7 +229,7 @@ void MP4T_OnNewPacket(void *cbk, GF_RTPHeader *header) tkHint->RTPTime = header->TimeStamp; tkHint->SampleIsRAP = tkHint->rtp_p->sl_config.hasRandomAccessUnitsOnlyFlag ? 1 : tkHint->rtp_p->sl_header.randomAccessPointFlag; } - /*create an RTP Packet with the appropriated marker flag - note: the flags are temp ones, + /*create an RTP Packet with the appropriated marker flag - note: the flags are temp ones, they are set when the full packet is signaled (to handle multi AUs per RTP)*/ gf_isom_rtp_packet_begin(tkHint->file, tkHint->HintTrack, 0, 0, 0, header->Marker, header->PayloadType, 0, 0, header->SequenceNumber); /*Add the delta TS to make sure RTP TS is indeed the CTS (sampling time)*/ @@ -238,9 +238,9 @@ void MP4T_OnNewPacket(void *cbk, GF_RTPHeader *header) GF_EXPORT -GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, - u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 flags, u8 PayloadID, - Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e) +GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, + u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 flags, u8 PayloadID, + Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e) { GF_SLConfig my_sl; @@ -290,7 +290,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, has_mpeg4_mapping = 1; TrackMediaType = gf_isom_get_media_type(file, TrackNum); TrackMediaSubType = gf_isom_get_media_subtype(file, TrackNum, 1); - + /*for max compatibility with QT*/ if (!default_rtp_rate) default_rtp_rate = 90000; @@ -306,7 +306,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, TrackMediaSubType = gf_isom_get_media_subtype(file, TrackNum, 1); switch (TrackMediaSubType) { - case GF_ISOM_SUBTYPE_MPEG4_CRYP: + case GF_ISOM_SUBTYPE_MPEG4_CRYP: is_crypted = 1; case GF_ISOM_SUBTYPE_MPEG4: esd = gf_isom_get_esd(file, TrackNum, 1); @@ -317,8 +317,8 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, if (esd->URLString) hintType = 0; /*AAC*/ if ((streamType==GF_STREAM_AUDIO) && esd->decoderConfig->decoderSpecificInfo - /*(nb: we use mpeg4 for MPEG-2 AAC)*/ - && ((oti==GPAC_OTI_AUDIO_AAC_MPEG4) || (oti==GPAC_OTI_AUDIO_AAC_MPEG4) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_MP) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_LCP) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_SSRP)) ) { + /*(nb: we use mpeg4 for MPEG-2 AAC)*/ + && ((oti==GPAC_OTI_AUDIO_AAC_MPEG4) || (oti==GPAC_OTI_AUDIO_AAC_MPEG4) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_MP) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_LCP) || (oti==GPAC_OTI_AUDIO_AAC_MPEG2_SSRP)) ) { u32 sample_rate; GF_M4ADecSpecInfo a_cfg; @@ -461,7 +461,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, gf_odf_avc_cfg_del(avcc); gf_odf_avc_cfg_del(svcc); } - break; + break; case GF_ISOM_SUBTYPE_HVC1: case GF_ISOM_SUBTYPE_HEV1: case GF_ISOM_SUBTYPE_HVC2: @@ -470,7 +470,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, GF_HEVCConfig *hevcc = NULL; hevcc = gf_isom_hevc_config_get(file, TrackNum, 1); required_rate = 90000; /* "90 kHz clock rate MUST be used"*/ - hintType = GF_RTP_PAYT_HEVC; + hintType = GF_RTP_PAYT_HEVC; streamType = GF_STREAM_VISUAL; avc_nalu_size = hevcc->nal_unit_size; oti = GPAC_OTI_VIDEO_HEVC; @@ -479,7 +479,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, gf_odf_hevc_cfg_del(hevcc); break; } - break; + break; case GF_ISOM_SUBTYPE_3GP_QCELP: required_rate = 8000; hintType = GF_RTP_PAYT_QCELP; @@ -517,7 +517,7 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, /*we only support self-contained files for hinting*/ gf_isom_get_data_reference(file, TrackNum, 1, &url, &urn); if (url || urn) return NULL; - + *e = GF_OUT_OF_MEM; GF_SAFEALLOC(tmp, GF_RTPHinter); if (!tmp) return NULL; @@ -587,15 +587,15 @@ GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum, // in case a different timescale was provided tmp->OrigTimeScale = gf_isom_get_media_timescale(file, TrackNum); - tmp->rtp_p = gf_rtp_builder_new(hintType, &my_sl, flags, tmp, - MP4T_OnNewPacket, MP4T_OnPacketDone, - /*if copy, no data ref*/ - copy_media ? NULL : MP4T_OnDataRef, - MP4T_OnData); + tmp->rtp_p = gf_rtp_builder_new(hintType, &my_sl, flags, tmp, + MP4T_OnNewPacket, MP4T_OnPacketDone, + /*if copy, no data ref*/ + copy_media ? NULL : MP4T_OnDataRef, + MP4T_OnData); //init the builder gf_rtp_builder_init(tmp->rtp_p, PayloadID, Path_MTU, max_ptime, - streamType, oti, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode); + streamType, oti, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode); /*ISMA compliance is a pain...*/ if (force_dts_delta) tmp->rtp_p->slMap.DTSDeltaLength = force_dts_delta; @@ -684,7 +684,7 @@ GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint) tkHint->TotalSample = gf_isom_get_sample_count(tkHint->file, tkHint->TrackNum); ft = tkHint->rtp_p->sl_config.timestampResolution; ft /= tkHint->OrigTimeScale; - + e = GF_OK; for (i=0; iTotalSample; i++) { samp = gf_isom_get_sample(tkHint->file, tkHint->TrackNum, i+1, &descIndex); @@ -693,7 +693,7 @@ GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint) //setup SL tkHint->CurrentSample = i + 1; - /*keep same AU indicator if sync shadow - TODO FIXME: this assumes shadows are placed interleaved with + /*keep same AU indicator if sync shadow - TODO FIXME: this assumes shadows are placed interleaved with the track content which is the case for GPAC scene carousel generation, but may not always be true*/ if (samp->IsRAP==2) { tkHint->rtp_p->sl_header.AU_sequenceNumber -= 1; @@ -729,7 +729,7 @@ GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint) } else { tkHint->rtp_p->sl_header.paddingBits = 0; } - + duration = gf_isom_get_sample_duration(tkHint->file, tkHint->TrackNum, i+1); ts = (u32) (ft * (s64) (duration)); @@ -817,7 +817,7 @@ static void write_avc_config(char *sdpLine, GF_AVCConfig *avcc, GF_AVCConfig *sv count = write_nalu_config_array(sdpLine, avcc->pictureParameterSets); if (count) strcat(sdpLine, ","); } - + if (svcc) { count = write_nalu_config_array(sdpLine, svcc->sequenceParameterSets); if (count) strcat(sdpLine, ","); @@ -929,41 +929,41 @@ GF_Err gf_hinter_track_finalize(GF_RTPHinter *tkHint, Bool AddSystemInfo) gf_isom_sdp_add_track_line(tkHint->file, tkHint->HintTrack, sdpLine); } /*MPEG-4 Audio LATM*/ - else if (tkHint->rtp_p->rtp_payt==GF_RTP_PAYT_LATM) { - GF_BitStream *bs; - char *config_bytes; - u32 config_size; - - /* form config string */ - bs = gf_bs_new(NULL, 32, GF_BITSTREAM_WRITE); - gf_bs_write_int(bs, 0, 1); /* AudioMuxVersion */ - gf_bs_write_int(bs, 1, 1); /* all streams same time */ - gf_bs_write_int(bs, 0, 6); /* numSubFrames */ - gf_bs_write_int(bs, 0, 4); /* numPrograms */ - gf_bs_write_int(bs, 0, 3); /* numLayer */ - - /* audio-specific config */ - esd = gf_isom_get_esd(tkHint->file, tkHint->TrackNum, 1); - if (esd && esd->decoderConfig && esd->decoderConfig->decoderSpecificInfo) { + else if (tkHint->rtp_p->rtp_payt==GF_RTP_PAYT_LATM) { + GF_BitStream *bs; + char *config_bytes; + u32 config_size; + + /* form config string */ + bs = gf_bs_new(NULL, 32, GF_BITSTREAM_WRITE); + gf_bs_write_int(bs, 0, 1); /* AudioMuxVersion */ + gf_bs_write_int(bs, 1, 1); /* all streams same time */ + gf_bs_write_int(bs, 0, 6); /* numSubFrames */ + gf_bs_write_int(bs, 0, 4); /* numPrograms */ + gf_bs_write_int(bs, 0, 3); /* numLayer */ + + /* audio-specific config */ + esd = gf_isom_get_esd(tkHint->file, tkHint->TrackNum, 1); + if (esd && esd->decoderConfig && esd->decoderConfig->decoderSpecificInfo) { /*PacketVideo patch: don't signal SBR and PS stuff, not allowed in LATM with audioMuxVersion=0*/ - gf_bs_write_data(bs, esd->decoderConfig->decoderSpecificInfo->data, MIN(esd->decoderConfig->decoderSpecificInfo->dataLength, 2) ); - } - if (esd) gf_odf_desc_del((GF_Descriptor *)esd); - - /* other data */ - gf_bs_write_int(bs, 0, 3); /* frameLengthType */ - gf_bs_write_int(bs, 0xff, 8); /* latmBufferFullness */ - gf_bs_write_int(bs, 0, 1); /* otherDataPresent */ - gf_bs_write_int(bs, 0, 1); /* crcCheckPresent */ - gf_bs_get_content(bs, &config_bytes, &config_size); - gf_bs_del(bs); - - gf_rtp_builder_format_sdp(tkHint->rtp_p, payloadName, sdpLine, config_bytes, config_size); - gf_isom_sdp_add_track_line(tkHint->file, tkHint->HintTrack, sdpLine); - gf_free(config_bytes); + gf_bs_write_data(bs, esd->decoderConfig->decoderSpecificInfo->data, MIN(esd->decoderConfig->decoderSpecificInfo->dataLength, 2) ); + } + if (esd) gf_odf_desc_del((GF_Descriptor *)esd); + + /* other data */ + gf_bs_write_int(bs, 0, 3); /* frameLengthType */ + gf_bs_write_int(bs, 0xff, 8); /* latmBufferFullness */ + gf_bs_write_int(bs, 0, 1); /* otherDataPresent */ + gf_bs_write_int(bs, 0, 1); /* crcCheckPresent */ + gf_bs_get_content(bs, &config_bytes, &config_size); + gf_bs_del(bs); + + gf_rtp_builder_format_sdp(tkHint->rtp_p, payloadName, sdpLine, config_bytes, config_size); + gf_isom_sdp_add_track_line(tkHint->file, tkHint->HintTrack, sdpLine); + gf_free(config_bytes); } /*3GPP DIMS*/ - else if (tkHint->rtp_p->rtp_payt==GF_RTP_PAYT_3GPP_DIMS) { + else if (tkHint->rtp_p->rtp_payt==GF_RTP_PAYT_3GPP_DIMS) { GF_DIMSDescription dims; char fmt[200]; gf_isom_get_visual_info(tkHint->file, tkHint->TrackNum, 1, &Width, &Height); @@ -1113,7 +1113,7 @@ GF_Err gf_hinter_finalize(GF_ISOFile *file, u32 IOD_Profile, u32 bandwidth) InitSL_NULL(&slc); slc.predefined = 0; slc.hasRandomAccessUnitsOnlyFlag = 1; - slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, odT); + slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, odT); slc.OCRResolution = 1000; slc.startCTS = samp->DTS+samp->CTS_Offset; slc.startDTS = samp->DTS; @@ -1138,7 +1138,7 @@ GF_Err gf_hinter_finalize(GF_ISOFile *file, u32 IOD_Profile, u32 bandwidth) } if (remove_ocr) esd->OCRESID = 0; else if (esd->OCRESID == esd->ESID) esd->OCRESID = 0; - + //OK, add this to our IOD gf_list_add(iod->ESDescriptors, esd); } @@ -1148,7 +1148,7 @@ GF_Err gf_hinter_finalize(GF_ISOFile *file, u32 IOD_Profile, u32 bandwidth) samp = gf_isom_get_sample(file, sceneT, 1, &descIndex); if (gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_SCENE)) { - slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, sceneT); + slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, sceneT); slc.OCRResolution = 1000; slc.startCTS = samp->DTS+samp->CTS_Offset; slc.startDTS = samp->DTS; diff --git a/src/media_tools/isom_tools.c b/src/media_tools/isom_tools.c index b8f419e..e40a69b 100644 --- a/src/media_tools/isom_tools.c +++ b/src/media_tools/isom_tools.c @@ -40,11 +40,11 @@ GF_Err gf_media_change_par(GF_ISOFile *file, u32 track, s32 ar_num, s32 ar_den) if (e) return e; stype = gf_isom_get_media_subtype(file, track, 1); - if ((stype==GF_ISOM_SUBTYPE_AVC_H264) - || (stype==GF_ISOM_SUBTYPE_AVC2_H264) - || (stype==GF_ISOM_SUBTYPE_AVC3_H264) - || (stype==GF_ISOM_SUBTYPE_AVC4_H264) - ) { + if ((stype==GF_ISOM_SUBTYPE_AVC_H264) + || (stype==GF_ISOM_SUBTYPE_AVC2_H264) + || (stype==GF_ISOM_SUBTYPE_AVC3_H264) + || (stype==GF_ISOM_SUBTYPE_AVC4_H264) + ) { #ifndef GPAC_DISABLE_AV_PARSERS GF_AVCConfig *avcc = gf_isom_avc_config_get(file, track, 1); gf_media_avc_change_par(avcc, ar_num, ar_den); @@ -136,7 +136,7 @@ GF_Err gf_media_remove_non_rap(GF_ISOFile *file, u32 track) #endif /*GPAC_DISABLE_ISOM_WRITE*/ GF_EXPORT -GF_Err gf_media_get_file_hash(const char *file, u8 hash[20]) +GF_Err gf_media_get_file_hash(const char *file, u8 hash[20]) { #ifdef GPAC_DISABLE_CORE_TOOLS return GF_NOT_SUPPORTED; @@ -602,18 +602,18 @@ GF_Err gf_media_make_3gpp(GF_ISOFile *mp4file) nb_avc++; break; case GF_ISOM_SUBTYPE_MPEG4: - { - GF_ESD *esd = gf_isom_get_esd(mp4file, i+1, 1); - /*both MPEG4-Video and H264/AVC/SVC are supported*/ - if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_MPEG4_PART2) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)) { - nb_vid++; - } else { - GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[3GPP convert] Video format not supported by 3GP - removing track ID %d\n", gf_isom_get_track_id(mp4file, i+1) )); - goto remove_track; - } - gf_odf_desc_del((GF_Descriptor *)esd); + { + GF_ESD *esd = gf_isom_get_esd(mp4file, i+1, 1); + /*both MPEG4-Video and H264/AVC/SVC are supported*/ + if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_MPEG4_PART2) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)) { + nb_vid++; + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[3GPP convert] Video format not supported by 3GP - removing track ID %d\n", gf_isom_get_track_id(mp4file, i+1) )); + goto remove_track; } - break; + gf_odf_desc_del((GF_Descriptor *)esd); + } + break; default: GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[3GPP convert] Video format not supported by 3GP - removing track ID %d\n", gf_isom_get_track_id(mp4file, i+1) )); goto remove_track; @@ -650,7 +650,7 @@ GF_Err gf_media_make_3gpp(GF_ISOFile *mp4file) } gf_odf_desc_del((GF_Descriptor *)esd); } - break; + break; default: GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[3GPP convert] Audio format not supported by 3GP - removing track ID %d\n", gf_isom_get_track_id(mp4file, i+1) )); goto remove_track; @@ -873,7 +873,7 @@ GF_ESD *gf_media_map_esd(GF_ISOFile *mp4, u32 track) esd->ESID = gf_isom_get_track_id(mp4, track); esd->OCRESID = esd->ESID; esd->decoderConfig->streamType = GF_STREAM_AUDIO; - esd->decoderConfig->objectTypeIndication = (ac3 && ac3->is_ec3) ? GPAC_OTI_AUDIO_AC3_ENHANCED : GPAC_OTI_AUDIO_AC3; + esd->decoderConfig->objectTypeIndication = (ac3 && ac3->is_ec3) ? GPAC_OTI_AUDIO_EAC3 : GPAC_OTI_AUDIO_AC3; gf_odf_desc_del((GF_Descriptor*)esd->decoderConfig->decoderSpecificInfo); esd->decoderConfig->decoderSpecificInfo = NULL; if (ac3) gf_free(ac3); @@ -1047,7 +1047,7 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) { GF_AVCConfig *svccfg, *cfg; u32 num_svc_track, num_sample, svc_track, dst_track, ref_trackID, ref_trackNum, max_id, di, width, height, size, nalu_size_length, i, j, t, max_size, num_pps, num_sps, num_subseq, NALUnitHeader, data_offset, data_length, count, timescale, cur_extract_mode; - GF_Err e; + GF_Err e; GF_AVCConfigSlot *slc, *sl; AVCState avc; s32 sps_id, pps_id; @@ -1120,7 +1120,7 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) num_svc_track = splitAll ? num_subseq : 1; max_id = gf_isom_get_track_id_max(file); di = 0; - + memset(&avc, 0, sizeof(AVCState)); avc.sps_active_idx = -1; nalu_size_length = 8 * svccfg->nal_unit_size; @@ -1230,12 +1230,12 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) gf_isom_sample_del(&samp); samp = NULL; - + for (t = 0; t < num_svc_track; t++) { e = GF_OK; svc_track = gf_isom_new_track(file, t+1+max_id, GF_ISOM_MEDIA_VISUAL, timescale); - if (!svc_track) + if (!svc_track) { e = gf_isom_last_error(file); goto exit; @@ -1345,7 +1345,7 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) { /*reset*/ memset(buffer, 0, max_size); - + samp = gf_isom_get_sample(file, track, i, &di); if (!samp) { @@ -1419,44 +1419,25 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) goto exit; gf_bs_read_data(bs, buffer, size); offset += size + nalu_size_length/8; - + switch (nal_type) { - case GF_AVC_NALU_PIC_PARAM: - pps_id = gf_media_avc_read_pps(buffer, size, &avc);; - j = 0; - dst_track = 0; - while (j < num_pps) - { - if (pps_id == pps[j]) - break; - j++; - } - if ((j < num_pps) && (is_subseq_pps[j])) - { - if (splitAll) - { - for (t = 0; t < num_svc_track; t++) - { - if (sps[t] == avc.pps[pps_id].sps_id) - { - dst_track = t + 1; - break; - } - } - } - else - dst_track = 1; - } - dst_bs = sample_bs[dst_track]; - break; - case GF_AVC_NALU_SVC_SUBSEQ_PARAM: - sps_id = gf_media_avc_read_sps(buffer, size, &avc, 0, NULL); - dst_track = 0; + case GF_AVC_NALU_PIC_PARAM: + pps_id = gf_media_avc_read_pps(buffer, size, &avc);; + j = 0; + dst_track = 0; + while (j < num_pps) + { + if (pps_id == pps[j]) + break; + j++; + } + if ((j < num_pps) && (is_subseq_pps[j])) + { if (splitAll) { for (t = 0; t < num_svc_track; t++) { - if (sps[t] == sps_id) + if (sps[t] == avc.pps[pps_id].sps_id) { dst_track = t + 1; break; @@ -1465,27 +1446,46 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) } else dst_track = 1; - dst_bs = sample_bs[dst_track]; - break; - case GF_AVC_NALU_SVC_SLICE: - dst_track = 0; - if (splitAll) + } + dst_bs = sample_bs[dst_track]; + break; + case GF_AVC_NALU_SVC_SUBSEQ_PARAM: + sps_id = gf_media_avc_read_sps(buffer, size, &avc, 0, NULL); + dst_track = 0; + if (splitAll) + { + for (t = 0; t < num_svc_track; t++) { - for (t = 0; t < num_svc_track; t++) + if (sps[t] == sps_id) { - if (sps[t] == (avc.s_info.pps)->sps_id) - { - dst_track = t + 1; - break; - } + dst_track = t + 1; + break; } } - else - dst_track = 1; - dst_bs = sample_bs[dst_track]; - break; - default: - dst_bs = sample_bs[0]; + } + else + dst_track = 1; + dst_bs = sample_bs[dst_track]; + break; + case GF_AVC_NALU_SVC_SLICE: + dst_track = 0; + if (splitAll) + { + for (t = 0; t < num_svc_track; t++) + { + if (sps[t] == (avc.s_info.pps)->sps_id) + { + dst_track = t + 1; + break; + } + } + } + else + dst_track = 1; + dst_bs = sample_bs[dst_track]; + break; + default: + dst_bs = sample_bs[0]; } gf_bs_write_int(dst_bs, size, nalu_size_length); @@ -1541,7 +1541,7 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) gf_isom_set_edit_segment(file, t, offset, dur, 0, GF_ISOM_EDIT_NORMAL); } } - + /*if this is a merged file*/ if (!is_splited) { @@ -1553,7 +1553,7 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) else { s32 shift=0; - + for (i = 0; i < gf_list_count(svccfg->sequenceParameterSets); i++) { slc = (GF_AVCConfigSlot *)gf_list_get(svccfg->sequenceParameterSets, i); @@ -1573,21 +1573,21 @@ GF_Err gf_media_split_svc(GF_ISOFile *file, u32 track, Bool splitAll) } for (j = 0; j < gf_list_count(svccfg->pictureParameterSets); j++) + { + slc = (GF_AVCConfigSlot *)gf_list_get(svccfg->pictureParameterSets, j); + pps_id = gf_media_avc_read_pps(slc->data, slc->size, &avc); + if (pps_id < 0) { + e = GF_NON_COMPLIANT_BITSTREAM; + goto exit; + } + if (is_subseq_pps[j+shift]) { - slc = (GF_AVCConfigSlot *)gf_list_get(svccfg->pictureParameterSets, j); - pps_id = gf_media_avc_read_pps(slc->data, slc->size, &avc); - if (pps_id < 0) { - e = GF_NON_COMPLIANT_BITSTREAM; - goto exit; - } - if (is_subseq_pps[j+shift]) - { - gf_list_rem(svccfg->pictureParameterSets, j); - gf_free(slc->data); - gf_free(slc); - j--; - } + gf_list_rem(svccfg->pictureParameterSets, j); + gf_free(slc->data); + gf_free(slc); + j--; } + } e = gf_isom_svc_config_update(file, track, 1, svccfg, 0); if (e) goto exit; @@ -1638,7 +1638,7 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) u64 EditTime, SegmentDuration, MediaTime; u8 EditMode, nal_type; Bool first_sample; - u64 first_DTS, offset, dur; + u64 first_DTS, offset, dur; GF_AVCConfigSlot *slc, *sl; e = GF_OK; @@ -1652,12 +1652,12 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) DQId = NULL; list_track_sorted = cur_sample = max_sample = NULL; DTS_offset = NULL; - + if (gf_isom_get_avc_svc_type(file, track, 1) == GF_ISOM_AVCTYPE_AVC_SVC) goto exit; num_track = gf_isom_get_track_count(file); - if (num_track == 1) + if (num_track == 1) goto exit; gf_isom_get_reference(file, track, GF_ISOM_REF_BASE, 1, &ref_trackNum); ref_trackID = gf_isom_get_track_id(file, ref_trackNum); @@ -1666,7 +1666,7 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) e = GF_ISOM_INVALID_MEDIA; goto exit; } - + list_track_sorted = (u32 *) gf_malloc(num_track * sizeof(u32)); DQId = (s32 *) gf_malloc(num_track * sizeof(s32)); count = 0; @@ -1700,7 +1700,7 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) gf_isom_set_track_enabled(file, merge_track, 1); /*rewrite svccfg*/ svccfg = gf_odf_avc_cfg_new(); - svccfg->complete_representation = 1; + svccfg->complete_representation = 1; /*rewrite visual info*/ if (!mergeAll) { @@ -1847,12 +1847,12 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) if (size>max_size) { buffer = (char*)gf_realloc(buffer, sizeof(char)*size); max_size = size; - } + } gf_bs_read_data(bs, buffer, size); nal_type = buffer[0] & 0x1F; /*skip extractor*/ if (nal_type == 31) - continue; + continue; /*copy to new bitstream*/ gf_bs_write_int(dst_bs, size, nalu_size_length); gf_bs_write_data(dst_bs, buffer, size); @@ -1863,7 +1863,7 @@ GF_Err gf_media_merge_svc(GF_ISOFile *file, u32 track, Bool mergeAll) samp = NULL; cur_sample[t]++; } - + /*add sapmle to track*/ if (gf_bs_get_position(dst_bs)) { @@ -1932,7 +1932,7 @@ exit: /* Split SHVC layers */ -static GF_HEVCParamArray *alloc_hevc_param_array(GF_HEVCConfig *hevc_cfg, u8 type) +static GF_HEVCParamArray *alloc_hevc_param_array(GF_HEVCConfig *hevc_cfg, u8 type) { GF_HEVCParamArray *ar; u32 i, count = hevc_cfg->param_array ? gf_list_count(hevc_cfg->param_array) : 0; @@ -1960,6 +1960,32 @@ typedef struct u32 temporal_id; } SHVCTrackInfo; +static GF_Err gf_isom_adjust_visual_info(GF_ISOFile *file, u32 track) { + u32 width, height, i, j; + GF_HEVCConfig *shvccfg; + HEVCState hevc; + + shvccfg = gf_isom_shvc_config_get(file, track, 1); + if (!shvccfg) return GF_OK; + + for (i = 0; i < gf_list_count(shvccfg->param_array); i++) { + GF_HEVCParamArray *ar = (GF_HEVCParamArray *)gf_list_get(shvccfg->param_array, i); + for (j = 0; j < gf_list_count(ar->nalus); j++) { + GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(ar->nalus, j); + if (ar->type==GF_HEVC_NALU_SEQ_PARAM) { + gf_hevc_get_sps_info_with_state(&hevc, sl->data, sl->size, NULL, &width, &height, NULL, NULL); + } + else if (ar->type==GF_HEVC_NALU_VID_PARAM) { + gf_media_hevc_read_vps(sl->data, sl->size, &hevc); + } + } + } + + if (shvccfg) gf_odf_hevc_cfg_del(shvccfg); + + return gf_isom_set_visual_info(file, track, 1, width, height); +} + GF_EXPORT GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_extractors) { @@ -1994,7 +2020,7 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ GF_AVCConfigSlot *sl = gf_list_get(ar->nalus, j); // u8 nal_type = (sl->data[0] & 0x7E) >> 1; u8 layer_id = ((sl->data[0] & 0x1) << 5) | (sl->data[1] >> 3); - + //this should not happen if (!layer_id) continue; @@ -2068,10 +2094,10 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ GF_BitStream *bs; u32 di; GF_ISOSample *sample; - u8 max_layer_id = 0; - + u8 cur_max_layer_id = 0; + sample = gf_isom_get_sample(file, track, i+1, &di); - + bs = gf_bs_new(sample->data, sample->dataLength, GF_BITSTREAM_READ); while (gf_bs_available(bs)) { u8 orig_layer_id; @@ -2083,8 +2109,9 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ if (!splitAll) layer_id = 1; - if (max_layer_id < layer_id) - max_layer_id = layer_id; + if (cur_max_layer_id < layer_id) { + cur_max_layer_id = layer_id; + } if (!sti[layer_id].bs) sti[layer_id].bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); @@ -2110,15 +2137,20 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ } gf_bs_del(bs); + if (cur_max_layer_id>max_layer_id) { + max_layer_id = cur_max_layer_id; + } gf_free(sample->data); sample->data = NULL; sample->dataLength = 0; - //reset all samples on scalable layers + //reset all samples on all layers found - we may have layers not present in this sample, we still need to process these layers when extractors are used for (j=0; j<=max_layer_id; j++) { if (! sti[j].bs) { - sti[j].data_offset = sti[j].data_size = 0; - continue; + if (!sti[j].track_num || !use_extractors) { + sti[j].data_offset = sti[j].data_size = 0; + continue; + } } //clone track @@ -2134,6 +2166,8 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ gf_isom_set_nalu_extract_mode(file, sti[j].track_num, GF_ISOM_NALU_EXTRACT_INSPECT); + gf_isom_adjust_visual_info(file, sti[j].track_num); + //get lower layer for (k=j; k>0; k--) { if (sti[k-1].track_num) { @@ -2143,7 +2177,7 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ } } - //add empty sample at DTS 0 + //add empty sample at DTS 0 if (sample->DTS ) { u64 dts = sample->DTS; s32 cts = sample->CTS_Offset; @@ -2160,7 +2194,8 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ //get all lower layers for (k=0; knal_unit_size + 4, 8*shvccfg->nal_unit_size); gf_bs_write_int(xbs, 0, 1); @@ -2183,14 +2218,18 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ //we wrote all our references, store offset for upper layers sti[j].data_offset = sample->dataLength; e = gf_isom_add_sample(file, sti[j].track_num, 1, sample); - if (e) goto exit; + if (e) + goto exit; gf_free(sample->data); + sample->data = NULL; //get real content, remember its size and add it to the new bs - gf_bs_get_content(sti[j].bs, &sample->data, &sample->dataLength); - e = gf_isom_append_sample_data(file, sti[j].track_num, sample->data, sample->dataLength); - if (e) goto exit; - + if (sti[j].bs) { + gf_bs_get_content(sti[j].bs, &sample->data, &sample->dataLength); + e = gf_isom_append_sample_data(file, sti[j].track_num, sample->data, sample->dataLength); + if (e) + goto exit; + } } else { //get sample content @@ -2205,15 +2244,17 @@ GF_Err gf_media_split_shvc(GF_ISOFile *file, u32 track, Bool splitAll, Bool use_ } else { e = gf_isom_update_sample(file, sti[j].track_num, i+1, sample, 1); } - if (e) goto exit; + if (e) + goto exit; } - + gf_bs_del(sti[j].bs); sti[j].bs = NULL; - - gf_free(sample->data); - sample->data = NULL; + if (sample->data) { + gf_free(sample->data); + sample->data = NULL; + } sample->dataLength = 0; } gf_isom_sample_del(&sample); @@ -2269,18 +2310,89 @@ GF_Err gf_media_change_pl(GF_ISOFile *file, u32 track, u32 profile, u32 level) return GF_OK; } + +static u32 hevc_get_tile_id(HEVCState *hevc, u32 *tile_x, u32 *tile_y, u32 *tile_width, u32 *tile_height) +{ + HEVCSliceInfo *si = &hevc->s_info; + u32 i, tbX, tbY, PicWidthInCtbsY, PicHeightInCtbsY, tileX, tileY, oX, oY, val; + PicWidthInCtbsY = si->sps->width / si->sps->max_CU_width; + PicHeightInCtbsY = si->sps->height / si->sps->max_CU_width; + + tbX = si->slice_segment_address % PicWidthInCtbsY; + tbY = si->slice_segment_address / PicWidthInCtbsY; + + tileX = tileY = 0; + oX = oY = 0; + for (i=0; ipps->num_tile_columns; i++) { + if (si->pps->uniform_spacing_flag) { + if (ipps->num_tile_columns-1) { + val = (i+1)*PicWidthInCtbsY / si->pps->num_tile_columns - (i)*PicWidthInCtbsY / si->pps->num_tile_columns; + } else { + val = (i)*PicWidthInCtbsY / si->pps->num_tile_columns - (i-1)*PicWidthInCtbsY / si->pps->num_tile_columns; + } + } else { + if (ipps->num_tile_columns-1) { + val = si->pps->column_width[i]; + } else { + val = (PicWidthInCtbsY - si->pps->column_width[i-1]); + } + } + *tile_x = oX; + *tile_width = val; + + if (oX >= tbX) break; + oX += val; + tileX++; + } + for (i=0; ipps->num_tile_rows; i++) { + if (si->pps->uniform_spacing_flag) { + if (ipps->num_tile_rows-1) { + val = (i+1)*PicHeightInCtbsY / si->pps->num_tile_rows - (i)*PicHeightInCtbsY / si->pps->num_tile_rows; + } else { + val = (i)*PicHeightInCtbsY / si->pps->num_tile_rows - (i-1)*PicHeightInCtbsY / si->pps->num_tile_rows; + } + } else { + if (ipps->num_tile_rows-1) { + val = si->pps->row_height[i]; + } else { + val = (PicHeightInCtbsY - si->pps->row_height[i-1]); + } + } + *tile_y = oY; + *tile_height = val; + + if (oY >= tbY) break; + oY += val; + tileY++; + } + *tile_x = *tile_x * si->sps->max_CU_width; + *tile_y = *tile_y * si->sps->max_CU_width; + *tile_width = *tile_width * si->sps->max_CU_width; + *tile_height = *tile_height * si->sps->max_CU_width; + + return tileX + tileY * si->pps->num_tile_columns; +} + +typedef struct +{ + u32 track, track_id; + u32 tx, ty, tw, th; + u32 data_offset; + GF_BitStream *sample_data; +} HEVCTileImport; + GF_EXPORT GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file) { #if defined(GPAC_DISABLE_HEVC) || defined(GPAC_DISABLE_AV_PARSERS) return GF_NOT_SUPPORTED; #else - u32 i, j, cur_tile, count, stype, track, nb_tracks, di, nalu_size_length; - s32 pps_idx=-1; + u32 i, j, cur_tile, count, stype, track, nb_tracks, di, nalu_size_length, tx, ty, tw, th; + s32 pps_idx=-1, ret; + u8 trefidx; GF_Err e; -// HEVCSliceInfo n_state; HEVCState hevc; - u32 *tiles_track; + HEVCTileImport *tiles; GF_HEVCConfig *hvcc; track = 0; @@ -2305,10 +2417,20 @@ GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file) count = gf_list_count(hvcc->param_array); for (i=0; iparam_array, i); - if (ar->type==GF_HEVC_NALU_PIC_PARAM) { - GF_AVCConfigSlot *sl = gf_list_get(ar->nalus, 0); - if (sl) + for (j=0; j < gf_list_count(ar->nalus); j++) { + GF_AVCConfigSlot *sl = gf_list_get(ar->nalus, j); + if (!sl) continue; + switch (ar->type) { + case GF_HEVC_NALU_PIC_PARAM: pps_idx = gf_media_hevc_read_pps(sl->data, sl->size, &hevc); + break; + case GF_HEVC_NALU_SEQ_PARAM: + pps_idx = gf_media_hevc_read_sps(sl->data, sl->size, &hevc); + break; + case GF_HEVC_NALU_VID_PARAM: + pps_idx = gf_media_hevc_read_vps(sl->data, sl->size, &hevc); + break; + } } } gf_odf_hevc_cfg_del(hvcc); @@ -2316,20 +2438,27 @@ GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file) if (pps_idx==-1) return GF_BAD_PARAM; if (! hevc.pps[pps_idx].tiles_enabled_flag) return GF_OK; - nb_tracks = hevc.pps[pps_idx].num_tile_columns * hevc.pps[pps_idx].num_tile_rows; - tiles_track = gf_malloc(sizeof(u32) * nb_tracks); + tiles = gf_malloc(sizeof(HEVCTileImport) * nb_tracks); + + //first clone tracks for (i=0; idataLength = 0; for (j=0; jdata = (char *) data; cur_tile = 0; while (size) { + u8 temporal_id, layer_id; u8 nal_type = 0; u32 nalu_size = 0; for (j=0; j> 1; + src_bs = gf_bs_new((const char *) data + nalu_size_length, nalu_size, GF_BITSTREAM_READ); + ret = gf_media_hevc_parse_nalu(src_bs, &hevc, &nal_type, &temporal_id, &layer_id); + gf_bs_del(src_bs); + //error parsing NAL, set nal to fallback to regular import + if (ret<0) nal_type = GF_HEVC_NALU_VID_PARAM; + switch (nal_type) { case GF_HEVC_NALU_SLICE_TRAIL_N: case GF_HEVC_NALU_SLICE_TRAIL_R: @@ -2368,11 +2504,37 @@ GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file) case GF_HEVC_NALU_SLICE_CRA: case GF_HEVC_NALU_SLICE_RADL_R: case GF_HEVC_NALU_SLICE_RASL_R: - //ret = hevc_parse_slice_segment(bs, hevc, &n_state); - e = gf_isom_append_sample_data(file, tiles_track[cur_tile], (char *) data, nalu_size + nalu_size_length); + tx = ty = tw = th = 0; + cur_tile = hevc_get_tile_id(&hevc, &tx, &ty, &tw, &th); + if (cur_tile>=nb_tracks) { + GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[HEVC Tiles] Tile index %d is greater than number of tiles %d in PPS\n", cur_tile, nb_tracks)); + e = GF_NON_COMPLIANT_BITSTREAM; + } else { + gf_bs_write_data(tiles[cur_tile].sample_data, (char *) data, nalu_size + nalu_size_length); + tiles[cur_tile].tx = tx; + tiles[cur_tile].ty = ty; + tiles[cur_tile].tw = tw; + tiles[cur_tile].th = th; + } if (e) goto err_exit; - cur_tile++; + + //write extractor (12 = 2*nalu_size_length + 4 bytes) + gf_bs_write_int(bs, 2*nalu_size_length + 4, 8*nalu_size_length); + gf_bs_write_int(bs, 0, 1); + gf_bs_write_int(bs, 49, 6); //extractor + gf_bs_write_int(bs, layer_id, 6); + gf_bs_write_int(bs, temporal_id, 3); + //set ref track index + trefidx = (u8) gf_isom_has_track_reference(file, track, GF_ISOM_REF_SCAL, tiles[cur_tile].track_id); + gf_bs_write_int(bs, trefidx, 8); + // no sample offset + gf_bs_write_int(bs, 0, 8); + // data offset: we start from last NAL written in this sample in this tile track + gf_bs_write_int(bs, tiles[cur_tile].data_offset, 8*nalu_size_length); + gf_bs_write_int(bs, nalu_size + nalu_size_length, 8*nalu_size_length); + tiles[cur_tile].data_offset += nalu_size + nalu_size_length; + break; default: gf_bs_write_data(bs, (char *) data, nalu_size + nalu_size_length); @@ -2387,11 +2549,56 @@ GF_Err gf_media_split_hevc_tiles(GF_ISOFile *file) e = gf_isom_update_sample(file, track, i+1, sample, 1); if (e) goto err_exit; + + gf_free(sample->data); + sample->data = NULL; + + for (j=0; jdataLength = 0; + gf_bs_get_content(tiles[j].sample_data, &sample->data, &sample->dataLength); + e = gf_isom_add_sample(file, tiles[j].track, 1, sample); + if (e) goto err_exit; + gf_bs_del(tiles[j].sample_data); + tiles[j].sample_data = NULL; + gf_free(sample->data); + sample->data = NULL; + } + gf_isom_sample_del(&sample); + } + + for (i=0; iTrackID, input, tf->OriginalTrack, tf->SampleNum + 1, GF_FALSE); - if (e) + if (e) goto err_exit; gf_set_progress("ISO File Fragmenting", nb_done, nb_samp); @@ -2577,9 +2785,9 @@ GF_Err gf_media_fragment_file(GF_ISOFile *input, const char *output_file, Double tf->SampleNum += 1; //end of track fragment or track - if ((tf->SampleNum==tf->SampleCount) || - /* TODO: should probably test the time position (not only duratino) to avoid drift */ - (tf->FragmentLength*1000 >= MaxFragmentDuration*tf->TimeScale)) { + if ((tf->SampleNum==tf->SampleCount) || + /* TODO: should probably test the time position (not only duratino) to avoid drift */ + (tf->FragmentLength*1000 >= MaxFragmentDuration*tf->TimeScale)) { gf_isom_sample_del(&next); sample = next = NULL; tf->FragmentLength = 0; @@ -2606,124 +2814,12 @@ err_exit: else gf_isom_close(output); gf_set_progress("ISO File Fragmenting", nb_samp, nb_samp); return e; -} - - -GF_EXPORT -GF_Err gf_media_split_tiles(GF_ISOFile *file) -{ -#if defined(GPAC_DISABLE_HEVC) || defined(GPAC_DISABLE_AV_PARSERS) - return GF_NOT_SUPPORTED; #else - u32 i, j, count, stype, track, nb_tracks, di, nalu_size_length; - s32 pps_idx=-1; -// GF_Err e; -// HEVCSliceInfo n_state; - HEVCState hevc; - u32 *tiles_track; - GF_HEVCConfig *hvcc; - - track = 0; - for (i=0; inal_unit_size; - - count = gf_list_count(hvcc->param_array); - for (i=0; iparam_array, i); - if (ar->type==GF_HEVC_NALU_PIC_PARAM) { - GF_AVCConfigSlot *sl = gf_list_get(ar->nalus, 0); - if (sl) - pps_idx = gf_media_hevc_read_pps(sl->data, sl->size, &hevc); - } - } - gf_odf_hevc_cfg_del(hvcc); - - - if (pps_idx==-1) return GF_BAD_PARAM; - if (! hevc.pps[pps_idx].tiles_enabled_flag) return GF_OK; - - nb_tracks = hevc.pps[pps_idx].num_tile_columns * hevc.pps[pps_idx].num_tile_rows; - tiles_track = gf_malloc(sizeof(u32) * nb_tracks); - for (i=0; idata; - size = sample->dataLength; - sample->data = NULL; - sample->dataLength = 0; - - for (j=0; j> 1; - switch (nal_type) { - case GF_HEVC_NALU_SLICE_TRAIL_N: - case GF_HEVC_NALU_SLICE_TRAIL_R: - case GF_HEVC_NALU_SLICE_TSA_N: - case GF_HEVC_NALU_SLICE_TSA_R: - case GF_HEVC_NALU_SLICE_STSA_N: - case GF_HEVC_NALU_SLICE_STSA_R: - case GF_HEVC_NALU_SLICE_BLA_W_LP: - case GF_HEVC_NALU_SLICE_BLA_W_DLP: - case GF_HEVC_NALU_SLICE_BLA_N_LP: - case GF_HEVC_NALU_SLICE_IDR_W_DLP: - case GF_HEVC_NALU_SLICE_IDR_N_LP: - case GF_HEVC_NALU_SLICE_CRA: - case GF_HEVC_NALU_SLICE_RADL_R: - case GF_HEVC_NALU_SLICE_RASL_R: - //ret = hevc_parse_slice_segment(bs, hevc, &n_state); - gf_isom_append_sample_data(file, track, (char *) data, nalu_size + nalu_size_length); - break; - default: - gf_bs_write_data(bs, (char *) data, nalu_size + nalu_size_length); - break; - } - data += nalu_size + nalu_size_length; - size -= nalu_size + nalu_size_length; - } - gf_free(data); - gf_bs_get_content(bs, &sample->data, &sample->dataLength); - gf_bs_del(bs); - - gf_isom_update_sample(file, track, i+1, sample, 1); - gf_isom_sample_del(&sample); - } + return GF_NOT_SUPPORTED; +#endif /* GPAC_DISABLE_ISOM_WRITE */ +} - return GF_OK; -#endif //GPAC_DISABLE_HEVC -} #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/ diff --git a/src/media_tools/m2ts_mux.c b/src/media_tools/m2ts_mux.c index c023363..73ac537 100644 --- a/src/media_tools/m2ts_mux.c +++ b/src/media_tools/m2ts_mux.c @@ -29,18 +29,16 @@ #if !defined(GPAC_DISABLE_MPEG2TS_MUX) -/*num ms between PCR*/ -#define PCR_UPDATE_MS 200 -/*90khz internal delay between two updates for instant bitrate compute per stream*/ +/*90khz internal delay between two updates for bitrate compute per stream */ #define BITRATE_UPDATE_WINDOW 90000 -/* length of adaptation_field_length; */ +/* length of adaptation_field_length; */ #define ADAPTATION_LENGTH_LENGTH 1 /* discontinuty flag, random access flag ... */ -#define ADAPTATION_FLAGS_LENGTH 1 -/* length of adaptation_extension_field_length; */ +#define ADAPTATION_FLAGS_LENGTH 1 +/* length of adaptation_extension_field_length; */ #define ADAPTATION_EXTENSION_LENGTH_LENGTH 1 /* AF des flags and co... */ -#define ADAPTATION_EXTENSION_FLAGS_LENGTH 1 +#define ADAPTATION_EXTENSION_FLAGS_LENGTH 1 /* length of encoded pcr */ #define PCR_LENGTH 6 @@ -59,10 +57,10 @@ static GFINLINE Bool gf_m2ts_time_less_or_equal(GF_M2TS_Time *a, GF_M2TS_Time *b return 1; } -static GFINLINE void gf_m2ts_time_inc(GF_M2TS_Time *time, u32 delta_inc_num, u32 delta_inc_den) +static GFINLINE void gf_m2ts_time_inc(GF_M2TS_Time *time, u64 delta_inc_num, u32 delta_inc_den) { u64 n_sec; - u32 sec; + u64 sec; /*couldn't compute bitrate - we need to have more info*/ if (!delta_inc_den) return; @@ -70,7 +68,7 @@ static GFINLINE void gf_m2ts_time_inc(GF_M2TS_Time *time, u32 delta_inc_num, u32 sec = delta_inc_num / delta_inc_den; if (sec) { - time->sec += sec; + time->sec += (u32) sec; sec *= delta_inc_den; delta_inc_num = delta_inc_num % sec; } @@ -85,13 +83,24 @@ static GFINLINE void gf_m2ts_time_inc(GF_M2TS_Time *time, u32 delta_inc_num, u32 } } +static GFINLINE s32 gf_m2ts_time_diff_us(GF_M2TS_Time *a, GF_M2TS_Time *b) +{ + s32 drift = b->nanosec; + drift -= a->nanosec; + drift /= 1000; + if (a->sec != b->sec) { + drift += (b->sec - a->sec) * 1000000; + } + return drift; +} + /************************************ - * Section-related functions + * Section-related functions ************************************/ void gf_m2ts_mux_table_update(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table_id_extension, - u8 *table_payload, u32 table_payload_length, - Bool use_syntax_indicator, Bool private_indicator, - Bool use_checksum) + u8 *table_payload, u32 table_payload_length, + Bool use_syntax_indicator, Bool private_indicator, + Bool use_checksum) { u32 overhead_size; u32 offset; @@ -139,11 +148,11 @@ void gf_m2ts_mux_table_update(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table case GF_M2TS_TABLE_ID_TDT: case GF_M2TS_TABLE_ID_TOT: case GF_M2TS_TABLE_ID_BAT: - maxSectionLength = 1024; + maxSectionLength = 1024; break; case GF_M2TS_TABLE_ID_MPEG4_BIFS: case GF_M2TS_TABLE_ID_MPEG4_OD: - maxSectionLength = 4096; + maxSectionLength = 4096; break; default: GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Cannot create sections for table id %d\n", stream->pid, table_id)); @@ -152,10 +161,10 @@ void gf_m2ts_mux_table_update(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table overhead_size = SECTION_HEADER_LENGTH; if (use_syntax_indicator) overhead_size += SECTION_ADDITIONAL_HEADER_LENGTH + CRC_LENGTH; - + section_number = 0; nb_sections = 1; - while (nb_sections*(maxSectionLength - overhead_size)length - SECTION_HEADER_LENGTH, 12); - + if (use_syntax_indicator) { /* second header */ gf_bs_write_int(bs, table_id_extension, 16); @@ -201,24 +210,24 @@ void gf_m2ts_mux_table_update(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table gf_bs_write_data(bs, (char *) table_payload + offset, section->length - overhead_size); offset += section->length - overhead_size; - + if (use_syntax_indicator) { /* place holder for CRC */ gf_bs_write_u32(bs, 0); } - gf_bs_get_content(bs, (char**) §ion->data, §ion->length); + gf_bs_get_content(bs, (char**) §ion->data, §ion->length); gf_bs_del(bs); if (use_syntax_indicator) { u32 CRC; - CRC = gf_crc_32((char *) section->data,section->length-CRC_LENGTH); + CRC = gf_crc_32((char *) section->data,section->length-CRC_LENGTH); section->data[section->length-4] = (CRC >> 24) & 0xFF; section->data[section->length-3] = (CRC >> 16) & 0xFF; section->data[section->length-2] = (CRC >> 8) & 0xFF; section->data[section->length-1] = CRC & 0xFF; } - + if (prev_sec) prev_sec->next = section; else table->section = section; prev_sec = section; @@ -233,9 +242,9 @@ void gf_m2ts_mux_table_update(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table void gf_m2ts_mux_table_update_bitrate(GF_M2TS_Mux *mux, GF_M2TS_Mux_Stream *stream) { GF_M2TS_Mux_Table *table; - + /*update PMT*/ - if (stream->table_needs_update) + if (stream->table_needs_update) stream->process(mux, stream); stream->bit_rate = 0; @@ -263,9 +272,9 @@ void gf_m2ts_mux_table_update_bitrate(GF_M2TS_Mux *mux, GF_M2TS_Mux_Stream *stre } void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 table_id_extension, - char *table_payload, u32 table_payload_length, - Bool use_syntax_indicator, Bool private_indicator, - Bool increment_version_number, Bool use_checksum) + char *table_payload, u32 table_payload_length, + Bool use_syntax_indicator, Bool private_indicator, + Bool increment_version_number, Bool use_checksum) { GF_SLHeader hdr; u32 overhead_size; @@ -310,7 +319,7 @@ void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 overhead_size = SECTION_HEADER_LENGTH; if (use_syntax_indicator) overhead_size += SECTION_ADDITIONAL_HEADER_LENGTH + CRC_LENGTH; - + section_number = 0; nb_sections = 1; hdr = stream->sl_header; @@ -328,14 +337,14 @@ void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 offset += maxSectionLength - overhead_size - sl_size; nb_sections++; } - } + } prev_sec = NULL; offset = 0; hdr = stream->sl_header; while (offset < table_payload_length) { u32 remain; char *slhdr; - u32 slhdr_size; + u32 slhdr_size; GF_SAFEALLOC(section, GF_M2TS_Mux_Section); hdr.accessUnitEndFlag = (section_number+1==nb_sections) ? stream->sl_header.accessUnitEndFlag : 0; @@ -355,10 +364,10 @@ void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 /* first header (not included in section length */ gf_bs_write_int(bs, table_id, 8); gf_bs_write_int(bs, use_syntax_indicator, 1); - gf_bs_write_int(bs, private_indicator, 1); + gf_bs_write_int(bs, private_indicator, 1); gf_bs_write_int(bs, 3, 2); /* reserved bits are all set */ gf_bs_write_int(bs, section->length - SECTION_HEADER_LENGTH, 12); - + if (use_syntax_indicator) { /* second header */ gf_bs_write_int(bs, table_id_extension, 16); @@ -376,24 +385,24 @@ void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 /*write sl data*/ gf_bs_write_data(bs, (char *) table_payload + offset, sl_size); offset += sl_size; - + if (use_syntax_indicator) { /* place holder for CRC */ gf_bs_write_u32(bs, 0); } - gf_bs_get_content(bs, (char**) §ion->data, §ion->length); + gf_bs_get_content(bs, (char**) §ion->data, §ion->length); gf_bs_del(bs); if (use_syntax_indicator) { u32 CRC; - CRC = gf_crc_32((char *) section->data,section->length-CRC_LENGTH); + CRC = gf_crc_32((char *) section->data,section->length-CRC_LENGTH); section->data[section->length-4] = (CRC >> 24) & 0xFF; section->data[section->length-3] = (CRC >> 16) & 0xFF; section->data[section->length-2] = (CRC >> 8) & 0xFF; section->data[section->length-1] = CRC & 0xFF; } - + if (prev_sec) prev_sec->next = section; else table->section = section; prev_sec = section; @@ -408,11 +417,11 @@ void gf_m2ts_mux_table_update_mpeg4(GF_M2TS_Mux_Stream *stream, u8 table_id, u16 /*MPEG-4 tables are input streams for the mux, the bitrate is updated when fetching AUs*/ } -static u32 gf_m2ts_add_adaptation(GF_M2TS_Mux_Program *prog, GF_BitStream *bs, u16 pid, - Bool has_pcr, u64 pcr_time, - Bool is_rap, - u32 padding_length, - char *af_descriptors, u32 af_descriptors_size) +static u32 gf_m2ts_add_adaptation(GF_M2TS_Mux_Program *prog, GF_BitStream *bs, u16 pid, + Bool has_pcr, u64 pcr_time, + Bool is_rap, + u32 padding_length, + char *af_descriptors, u32 af_descriptors_size) { u32 adaptation_length; @@ -427,7 +436,7 @@ static u32 gf_m2ts_add_adaptation(GF_M2TS_Mux_Program *prog, GF_BitStream *bs, u gf_bs_write_int(bs, 0, 1); // discontinuity indicator gf_bs_write_int(bs, is_rap, 1); // random access indicator gf_bs_write_int(bs, 0, 1); // es priority indicator - gf_bs_write_int(bs, has_pcr, 1); // PCR_flag + gf_bs_write_int(bs, has_pcr, 1); // PCR_flag gf_bs_write_int(bs, 0, 1); // OPCR flag gf_bs_write_int(bs, 0, 1); // splicing point flag gf_bs_write_int(bs, 0, 1); // transport private data flag @@ -435,12 +444,12 @@ static u32 gf_m2ts_add_adaptation(GF_M2TS_Mux_Program *prog, GF_BitStream *bs, u if (has_pcr) { u64 PCR_base, PCR_ext; PCR_base = pcr_time/300; - gf_bs_write_long_int(bs, PCR_base, 33); + gf_bs_write_long_int(bs, PCR_base, 33); gf_bs_write_int(bs, 0, 6); // reserved PCR_ext = pcr_time - PCR_base*300; gf_bs_write_long_int(bs, PCR_ext, 9); if (prog->last_pcr > pcr_time) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Sending PCR "LLD" earlier than previous PCR "LLD" - drift %f sec\n", pid, pcr_time, prog->last_pcr, (prog->last_pcr - pcr_time) /27000000.0 )); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Sending PCR "LLD" earlier than previous PCR "LLD" - drift %f sec - discontinuity set\n", pid, pcr_time, prog->last_pcr, (prog->last_pcr - pcr_time) /27000000.0 )); } prog->last_pcr = pcr_time; @@ -460,22 +469,29 @@ static u32 gf_m2ts_add_adaptation(GF_M2TS_Mux_Program *prog, GF_BitStream *bs, u gf_bs_write_int(bs, 0, 1); // seamless_splice_flag gf_bs_write_int(bs, 0, 1); // af_descriptor_not_present_flag gf_bs_write_int(bs, 1, 4); // reserved - + gf_bs_write_data(bs, af_descriptors, af_descriptors_size); } gf_bs_write_byte(bs, 0xFF, padding_length); // stuffing byte - + return adaptation_length + ADAPTATION_LENGTH_LENGTH; } +//#define USE_AF_STUFFING + void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) { GF_BitStream *bs; GF_M2TS_Mux_Table *table; GF_M2TS_Mux_Section *section; - u32 payload_length, padding_length; - u8 adaptation_field_control; + u32 payload_length, payload_start; + u8 adaptation_field_control = GF_M2TS_ADAPTATION_NONE; +#ifndef USE_AF_STUFFING + u32 padded_bytes=0; +#else + u32 padding_length = 0; +#endif stream->table_needs_send = 0; table = stream->current_table; @@ -485,7 +501,7 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) assert(section); bs = gf_bs_new(packet, 188, GF_BITSTREAM_WRITE); - + gf_bs_write_int(bs, 0x47, 8); // sync gf_bs_write_int(bs, 0, 1); // error indicator if (stream->current_section_offset == 0) { @@ -498,10 +514,13 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (!stream->current_section_offset) payload_length = 183; else payload_length = 184; + payload_start = payload_length; + if (section->length - stream->current_section_offset >= payload_length) { - padding_length = 0; - adaptation_field_control = GF_M2TS_ADAPTATION_NONE; - } else { + + } else { + //stuffing using adaptation field - seems not well handled by some equipments ... +#ifdef USE_AF_STUFFING /* in all the following cases, we write an adaptation field */ adaptation_field_control = GF_M2TS_ADAPTATION_AND_PAYLOAD; /* we need at least 2 bytes for adaptation field headers (no pcr) */ @@ -509,12 +528,18 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (section->length - stream->current_section_offset >= payload_length) { padding_length = 0; } else { - padding_length = payload_length - section->length + stream->current_section_offset; + padding_length = payload_length - section->length + stream->current_section_offset; payload_length -= padding_length; } +#else + //stuffing according to annex C.3 + padded_bytes = payload_length - section->length + stream->current_section_offset; + payload_length = section->length - stream->current_section_offset; +#endif } + assert(payload_length + stream->current_section_offset <= section->length); - + gf_bs_write_int(bs, 0, 1); /*priority indicator*/ gf_bs_write_int(bs, stream->pid, 13); /*pid*/ gf_bs_write_int(bs, 0, 2); /*scrambling indicator*/ @@ -523,8 +548,10 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (stream->continuity_counter < 15) stream->continuity_counter++; else stream->continuity_counter=0; +#ifdef USE_AF_STUFFING if (adaptation_field_control != GF_M2TS_ADAPTATION_NONE) gf_m2ts_add_adaptation(stream->program, bs, stream->pid, 0, 0, 0, padding_length, NULL, 0); +#endif /*pointer field*/ if (!stream->current_section_offset) { @@ -533,9 +560,12 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) } gf_bs_del(bs); - memcpy(packet+188-payload_length, section->data + stream->current_section_offset, payload_length); + memcpy(packet+188-payload_start, section->data + stream->current_section_offset, payload_length); stream->current_section_offset += payload_length; - +#ifndef USE_AF_STUFFING + if (padded_bytes) memset(packet+188-payload_start+payload_length, 0xFF, padded_bytes); +#endif + if (stream->current_section_offset == section->length) { stream->current_section_offset = 0; stream->current_section = stream->current_section->next; @@ -558,6 +588,63 @@ void gf_m2ts_mux_table_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) } +u32 gf_m2ts_stream_process_sdt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) +{ + if (stream->table_needs_update) { /* generate table payload */ + GF_M2TS_Mux_Program *prog; + GF_BitStream *bs; + u8 *payload; + u32 size; + + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + + gf_bs_write_u16(bs, muxer->ts_id); + gf_bs_write_u8(bs, 0xFF); //reserved future use + + prog = muxer->programs; + while (prog) { + u32 len = 0; + gf_bs_write_u16(bs, prog->number); + gf_bs_write_int(bs, 0xFF, 6); //reserved future use + gf_bs_write_int(bs, 0, 1); //EIT_schedule_flag + gf_bs_write_int(bs, 0, 1); //EIT_present_following_flag + gf_bs_write_int(bs, 4, 3); //running status + gf_bs_write_int(bs, 0, 1); //free_CA_mode + + if (prog->name) len += (u32) strlen(prog->name); + if (prog->provider) len += (u32) strlen(prog->provider); + + if (len) { + len += 3; + gf_bs_write_int(bs, len + 2, 12); + gf_bs_write_u8(bs, GF_M2TS_DVB_SERVICE_DESCRIPTOR); + gf_bs_write_u8(bs, len); + gf_bs_write_u8(bs, 0x01); + len = prog->provider ? (u32) strlen(prog->provider) : 0; + gf_bs_write_u8(bs, len); + if (prog->provider) gf_bs_write_data(bs, prog->provider, len); + + len = prog->name ? (u32) strlen(prog->name) : 0; + gf_bs_write_u8(bs, len); + if (prog->name) gf_bs_write_data(bs, prog->name, len); + } else { + gf_bs_write_int(bs, 0, 12); + } + prog = prog->next; + } + gf_bs_get_content(bs, (char**)&payload, &size); + gf_bs_del(bs); + gf_m2ts_mux_table_update(stream, GF_M2TS_TABLE_ID_SDT_ACTUAL, muxer->ts_id, payload, size, 1, 0, 0); + stream->table_needs_update = 0; + stream->table_needs_send = 1; + gf_free(payload); + } + if (stream->table_needs_send) + return 1; + if (stream->refresh_rate_ms) + return 1; + return 0; +} u32 gf_m2ts_stream_process_pat(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) { @@ -582,9 +669,9 @@ u32 gf_m2ts_stream_process_pat(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) stream->table_needs_send = 1; gf_free(payload); } - if (stream->table_needs_send) + if (stream->table_needs_send) return 1; - if (stream->refresh_rate_ms) + if (stream->refresh_rate_ms) return 1; return 0; } @@ -604,7 +691,7 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) gf_bs_write_int(bs, 0x7, 3); // reserved gf_bs_write_int(bs, stream->program->pcr->pid, 13); gf_bs_write_int(bs, 0xF, 4); // reserved - + if (stream->program->loop_descriptors) { for (i=0; iprogram->loop_descriptors); i++) { @@ -633,39 +720,39 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) break; } es_stream = es_stream->next; - } + } } bs_iod = gf_bs_new(NULL,0,GF_BITSTREAM_WRITE); gf_odf_write_descriptor(bs_iod, stream->program->iod); - gf_bs_get_content(bs_iod, &iod_data, &iod_data_len); + gf_bs_get_content(bs_iod, &iod_data, &iod_data_len); gf_bs_del(bs_iod); len = iod_data_len + 4; - gf_bs_write_int(bs, len + info_length, 12); // program info length - + gf_bs_write_int(bs, len + info_length, 12); // program info length + gf_bs_write_int(bs, GF_M2TS_MPEG4_IOD_DESCRIPTOR, 8); len = iod_data_len + 2; gf_bs_write_int(bs, len, 8); - - /* Scope_of_IOD_label : + + /* Scope_of_IOD_label : 0x10 iod unique a l'int�rieur de programme 0x11 iod unoque dans le flux ts */ - gf_bs_write_int(bs, 2, 8); + gf_bs_write_int(bs, 2, 8); gf_bs_write_int(bs, 2, 8); // IOD_label - + gf_bs_write_data(bs, iod_data, iod_data_len); gf_free(iod_data); - } + } /*write all other descriptors*/ if (stream->program->loop_descriptors) { for (i=0; iprogram->loop_descriptors); i++) { GF_M2TSDescriptor *desc = gf_list_get(stream->program->loop_descriptors, i); - gf_bs_write_int(bs, desc->tag, 8); - gf_bs_write_int(bs, desc->data_len, 8); - gf_bs_write_data(bs, desc->data, desc->data_len); + gf_bs_write_int(bs, desc->tag, 8); + gf_bs_write_int(bs, desc->data_len, 8); + gf_bs_write_data(bs, desc->data, desc->data_len); } } @@ -693,7 +780,7 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) gf_bs_write_int(bs, 0x7, 3); // reserved gf_bs_write_int(bs, es->pid, 13); gf_bs_write_int(bs, 0xF, 4); // reserved - + /*calculate es_info_length*/ if (stream->program->iod && !(es->ifce->caps & GF_ESI_STREAM_WITHOUT_MPEG4_SYSTEMS)) es_info_length += 4; @@ -716,38 +803,38 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) gf_bs_write_int(bs, es_info_length, 12); if (stream->program->iod && !(es->ifce->caps & GF_ESI_STREAM_WITHOUT_MPEG4_SYSTEMS)) { - gf_bs_write_int(bs, GF_M2TS_MPEG4_SL_DESCRIPTOR, 8); - gf_bs_write_int(bs, 2, 8); + gf_bs_write_int(bs, GF_M2TS_MPEG4_SL_DESCRIPTOR, 8); + gf_bs_write_int(bs, 2, 8); gf_bs_write_int(bs, es->ifce->stream_id, 16); // mpeg4_esid } if (has_lang) { - gf_bs_write_int(bs, GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR, 8); - gf_bs_write_int(bs, 3, 8); - gf_bs_write_int(bs, (es->ifce->lang>>24) & 0xFF, 8); - gf_bs_write_int(bs, (es->ifce->lang>>16) & 0xFF, 8); - gf_bs_write_int(bs, es->ifce->lang & 0xFF, 8); + gf_bs_write_int(bs, GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR, 8); + gf_bs_write_int(bs, 3, 8); + gf_bs_write_int(bs, (es->ifce->lang>>24) & 0xFF, 8); + gf_bs_write_int(bs, (es->ifce->lang>>16) & 0xFF, 8); + gf_bs_write_int(bs, es->ifce->lang & 0xFF, 8); } switch (es->mpeg2_stream_type) { case GF_M2TS_AUDIO_AC3: - gf_bs_write_int(bs, GF_M2TS_REGISTRATION_DESCRIPTOR, 8); - gf_bs_write_int(bs, 4, 8); - gf_bs_write_int(bs, 'A', 8); - gf_bs_write_int(bs, 'C', 8); - gf_bs_write_int(bs, '-', 8); - gf_bs_write_int(bs, '3', 8); + gf_bs_write_int(bs, GF_M2TS_REGISTRATION_DESCRIPTOR, 8); + gf_bs_write_int(bs, 4, 8); + gf_bs_write_int(bs, 'A', 8); + gf_bs_write_int(bs, 'C', 8); + gf_bs_write_int(bs, '-', 8); + gf_bs_write_int(bs, '3', 8); break; case GF_M2TS_VIDEO_VC1: - gf_bs_write_int(bs, GF_M2TS_REGISTRATION_DESCRIPTOR, 8); - gf_bs_write_int(bs, 4, 8); - gf_bs_write_int(bs, 'V', 8); - gf_bs_write_int(bs, 'C', 8); - gf_bs_write_int(bs, '-', 8); - gf_bs_write_int(bs, '1', 8); + gf_bs_write_int(bs, GF_M2TS_REGISTRATION_DESCRIPTOR, 8); + gf_bs_write_int(bs, 4, 8); + gf_bs_write_int(bs, 'V', 8); + gf_bs_write_int(bs, 'C', 8); + gf_bs_write_int(bs, '-', 8); + gf_bs_write_int(bs, '1', 8); break; case GF_M2TS_AUDIO_EC3: - gf_bs_write_int(bs, GF_M2TS_DVB_EAC3_DESCRIPTOR, 8); + gf_bs_write_int(bs, GF_M2TS_DVB_EAC3_DESCRIPTOR, 8); gf_bs_write_int(bs, 0, 8); //check what is in this desc break; } @@ -757,15 +844,15 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) for (i=0; iloop_descriptors); i++) { GF_M2TSDescriptor *desc = (GF_M2TSDescriptor *)gf_list_get(es->loop_descriptors, i); - gf_bs_write_int(bs, desc->tag, 8); - gf_bs_write_int(bs, desc->data_len, 8); + gf_bs_write_int(bs, desc->tag, 8); + gf_bs_write_int(bs, desc->data_len, 8); gf_bs_write_data(bs, desc->data, desc->data_len); } } es = es->next; } - + gf_bs_get_content(bs, (char**)&payload, &length); gf_bs_del(bs); @@ -776,9 +863,9 @@ u32 gf_m2ts_stream_process_pmt(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Updating PMT - Program Number %d - %d streams - size %d%s\n", stream->pid, stream->program->number, nb_streams, length, stream->program->iod ? " - MPEG-4 Systems detected":"")); } - if (stream->table_needs_send) + if (stream->table_needs_send) return 1; - if (stream->refresh_rate_ms) + if (stream->refresh_rate_ms) return 1; return 0; } @@ -792,7 +879,7 @@ static void gf_m2ts_remap_timestamps_for_pes(GF_M2TS_Mux_Stream *stream, u32 pck *cts = (u64) (stream->ts_scale * (s64) *cts); *dts = (u64) (stream->ts_scale * (s64) *dts); if (duration) *duration = (u32) (stream->ts_scale * (u32) *duration); - + } if (!stream->program->initial_ts_set) { u32 nb_bits = (u32) (stream->program->mux->tot_pck_sent - stream->program->num_pck_at_pcr_init) * 1504; @@ -851,6 +938,7 @@ static void id3_tag_create(char **input, u32 *len) u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream) { + u64 time_inc; Bool ret = 0; if (stream->mpeg2_stream_type==GF_M2TS_SYSTEMS_MPEG4_SECTIONS) { @@ -858,17 +946,16 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream if (stream->table_needs_send) return stream->scheduling_priority; /*section is not completely sent yet or this is not the first section of the table*/ - if (stream->current_section && (stream->current_section_offset || stream->current_section!=stream->current_table->section)) + if (stream->current_section && (stream->current_section_offset || stream->current_section!=stream->current_table->section)) return stream->scheduling_priority; if (stream->ifce->repeat_rate && stream->tables) ret = stream->program->pcr_init_time ? stream->scheduling_priority : 0; } else if (stream->curr_pck.data_len && stream->pck_offset < stream->curr_pck.data_len) { /*PES packet not completely sent yet*/ - return stream->scheduling_priority + stream->pcr_priority; + return stream->scheduling_priority; } - stream->pcr_priority = 0; /*PULL mode*/ if (stream->ifce->caps & GF_ESI_AU_PULL_CAP) { if (stream->curr_pck.data_len) { @@ -888,9 +975,9 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream } else { GF_M2TS_Packet *curr_pck; - if (!stream->pck_first && (stream->ifce->caps & GF_ESI_STREAM_IS_OVER)) + if (!stream->pck_first && (stream->ifce->caps & GF_ESI_STREAM_IS_OVER)) return ret; - + /*flush input pipe*/ if (stream->ifce->input_ctrl) stream->ifce->input_ctrl(stream->ifce, GF_ESI_INPUT_DATA_FLUSH, NULL); @@ -1009,7 +1096,7 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream /*moving from PES to SL reallocates a new buffer, force discard even in pull mode*/ stream->discard_data = 1; } - break; + break; /*perform LATM encapsulation*/ case GF_M2TS_AUDIO_LATM_AAC: { @@ -1068,7 +1155,7 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream /*since we reallocated the packet data buffer, force a discard in pull mode*/ stream->discard_data = 1; } - break; + break; /*perform ADTS encapsulation*/ case GF_M2TS_AUDIO_AAC: if (stream->ifce->decoder_config) { @@ -1104,15 +1191,15 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream break; case GF_M2TS_METADATA_PES: case GF_M2TS_METADATA_ID3_HLS: - { - id3_tag_create(&stream->curr_pck.data, &stream->curr_pck.data_len); - stream->discard_data = 1; - } - break; + { + id3_tag_create(&stream->curr_pck.data, &stream->curr_pck.data_len); + stream->discard_data = 1; + } + break; } if (stream->start_pes_at_rap && (stream->curr_pck.flags & GF_ESI_DATA_AU_RAP) - ) { + ) { stream->program->mux->force_pat_pmt_state = GF_SEG_BOUNDARY_FORCE_PAT; stream->program->mux->force_pat = GF_TRUE; } @@ -1123,18 +1210,21 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream /*compute next interesting time in TS unit: this will be DTS of next packet*/ stream->time = stream->program->ts_time_at_pcr_init; - gf_m2ts_time_inc(&stream->time, (u32) stream->curr_pck.dts, 90000); - - /*do we need to send a PCR*/ - if (stream == stream->program->pcr) { - if (muxer->real_time) { - if (gf_sys_clock() > stream->program->last_sys_clock + PCR_UPDATE_MS) - stream->pcr_priority = 1; + time_inc = stream->curr_pck.dts - stream->program->pcr_offset; +#if 0 + if (stream->bit_rate) { + u64 send_time = ((u64)stream->curr_pck.data_len)*720000/*8*90000*/ / stream->bit_rate; + if (send_timeprogram->last_dts || (stream->curr_pck.dts > stream->program->last_dts + PCR_UPDATE_MS*90)) - stream->pcr_priority = 1; + time_inc = 0; } } +#endif + gf_m2ts_time_inc(&stream->time, time_inc, 90000); + + /*PCR injection is now decided when building TS packet*/ + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Next data schedule for %d:%09d - mux time %d:%09d\n", stream->pid, stream->time.sec, stream->time.nanosec, muxer->time.sec, muxer->time.nanosec)); /*compute instant bitrate*/ @@ -1149,40 +1239,36 @@ u32 gf_m2ts_stream_process_stream(GF_M2TS_Mux *muxer, GF_M2TS_Mux_Stream *stream u64 r = 8*stream->bytes_since_last_time; r*=90000; bitrate = (u32) (r / time_diff); - stream->bit_rate = bitrate; + + if (stream->program->mux->fixed_rate || (stream->bit_rate < bitrate)) { + stream->bit_rate = bitrate; + stream->program->mux->needs_reconfig = 1; + } stream->last_br_time = 0; stream->bytes_since_last_time = 0; stream->pes_since_last_time = 0; - stream->program->mux->needs_reconfig = 1; - } - } - - /* in live with no fixed target rate, we have to always compute the bitrate in case we have a peak (IDR), otherwise the mux time will increase too fast and we will send packets way too fast - this is not perfect, we may end up with a too high stream rate and the mux time will increase too slowly, hence packet will be late*/ - if (stream->program->mux->real_time && !stream->program->mux->fixed_rate && stream->curr_pck.duration) { - u64 inst_rate; - inst_rate = 8*stream->curr_pck.data_len; - inst_rate *= 90000; - inst_rate /= stream->curr_pck.duration; - inst_rate /= 8; - if (inst_rate>stream->bit_rate) - { - stream->bit_rate = (u32) inst_rate; - stream->program->mux->needs_reconfig = 1; } } stream->pes_since_last_time ++; - return stream->scheduling_priority + stream->pcr_priority; + return stream->scheduling_priority; } -static GFINLINE u64 gf_m2ts_get_pcr(GF_M2TS_Mux_Program *program) +static GFINLINE u64 gf_m2ts_get_pcr(GF_M2TS_Mux_Stream *stream) { - u32 nb_pck = (u32) (program->mux->tot_pck_sent - program->num_pck_at_pcr_init); - u64 pcr = 27000000; - pcr *= nb_pck*1504; - pcr /= program->mux->bit_rate; - pcr += program->pcr_init_time; + u64 pcr; + /*compute PCR*/ + if (stream->program->mux->fixed_rate ) { + u32 nb_pck = (u32) (stream->program->mux->tot_pck_sent - stream->program->num_pck_at_pcr_init); + pcr = 27000000; + pcr *= nb_pck*1504; + pcr /= stream->program->mux->bit_rate; + pcr += stream->program->pcr_init_time; + } + /*in non-realtime mode with no fixed rate we only insert PCR based on DTS */ + else { + pcr = (stream->curr_pck.dts - stream->program->pcr_offset) * 300; + } return pcr; } @@ -1192,7 +1278,7 @@ void gf_m2ts_stream_update_data_following(GF_M2TS_Mux_Stream *stream) stream->next_payload_size = 0; stream->next_pck_flags = 0; stream->copy_from_next_packets = 0; - + if (stream->program->mux->one_au_per_pes) return; switch (stream->mpeg2_stream_type) { @@ -1241,12 +1327,16 @@ void gf_m2ts_stream_update_data_following(GF_M2TS_Mux_Stream *stream) stream->next_pck_cts = 0; stream->next_pck_dts = 0; stream->next_pck_flags = 0; - } + } if (stream->next_payload_size) { stream->next_payload_size += stream->reframe_overhead; gf_m2ts_remap_timestamps_for_pes(stream, stream->next_pck_flags, &stream->next_pck_dts, &stream->next_pck_cts, NULL); + + + if (!(stream->next_pck_flags & GF_ESI_DATA_HAS_DTS)) + stream->next_pck_dts = stream->next_pck_cts; } } @@ -1260,7 +1350,7 @@ Bool gf_m2ts_stream_compute_pes_length(GF_M2TS_Mux_Stream *stream, u32 payload_l /*if we have next payload ready, compute transmitted size*/ if (stream->next_payload_size) { u32 pck_size = stream->curr_pck.data_len - stream->pck_offset; - u32 ts_bytes = payload_length; + u32 ts_bytes = payload_length; /*finish this AU*/ while (ts_bytes < pck_size) { @@ -1312,8 +1402,8 @@ Bool gf_m2ts_stream_compute_pes_length(GF_M2TS_Mux_Stream *stream, u32 payload_l /*if what will remain after copying next AU is less than the minimum safety copy only copy next AU and realign n+2 AU start with PES*/ if ((stream->copy_from_next_packets > stream->next_payload_size) - && (stream->copy_from_next_packets - stream->next_payload_size < stream->min_bytes_copy_from_next) - ) { + && (stream->copy_from_next_packets - stream->next_payload_size < stream->min_bytes_copy_from_next) + ) { stream->copy_from_next_packets = stream->next_payload_size; } } @@ -1365,9 +1455,9 @@ u32 gf_m2ts_stream_add_pes_header(GF_BitStream *bs, GF_M2TS_Mux_Stream *stream) u64 t, dts, cts; u32 pes_len; Bool use_pts, use_dts; - + gf_bs_write_int(bs, 0x1, 24);//packet start code - gf_bs_write_u8(bs, stream->mpeg2_stream_id);// stream id + gf_bs_write_u8(bs, stream->mpeg2_stream_id);// stream id /*next AU start in current PES and current AU began in previous PES, use next AU timing*/ if (stream->pck_offset && stream->copy_from_next_packets) { @@ -1395,14 +1485,14 @@ u32 gf_m2ts_stream_add_pes_header(GF_BitStream *bs, GF_M2TS_Mux_Stream *stream) if (pes_len>0xFFFF) pes_len = 0; gf_bs_write_int(bs, pes_len, 16); // pes packet length - + gf_bs_write_int(bs, 0x2, 2); // reserved gf_bs_write_int(bs, 0x0, 2); // scrambling gf_bs_write_int(bs, 0x0, 1); // priority gf_bs_write_int(bs, stream->pck_offset ? 0 : 1, 1); // alignment indicator - we could also check start codes to see if we are aligned at slice/video packet level gf_bs_write_int(bs, 0x0, 1); // copyright gf_bs_write_int(bs, 0x0, 1); // original or copy - + gf_bs_write_int(bs, use_pts, 1); gf_bs_write_int(bs, use_dts, 1); gf_bs_write_int(bs, 0x0, 6); //6 flags = 0 (ESCR, ES_rate, DSM_trick, additional_copy, PES_CRC, PES_extension) @@ -1434,7 +1524,7 @@ u32 gf_m2ts_stream_add_pes_header(GF_BitStream *bs, GF_M2TS_Mux_Stream *stream) gf_bs_write_long_int(bs, t, 15); gf_bs_write_int(bs, 1, 1); // marker bit } - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Adding PES header at PCR "LLD" - has PTS %d ("LLU") - has DTS %d ("LLU") - Payload length %d\n", stream->pid, gf_m2ts_get_pcr(stream->program)/300, use_pts, cts, use_dts, dts, pes_len)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS Muxer] PID %d: Adding PES header at PCR "LLD" - has PTS %d ("LLU") - has DTS %d ("LLU") - Payload length %d\n", stream->pid, gf_m2ts_get_pcr(stream)/300, use_pts, cts, use_dts, dts, pes_len)); return pes_len+4; // 4 = start code + stream_id } @@ -1442,7 +1532,7 @@ u32 gf_m2ts_stream_add_pes_header(GF_BitStream *bs, GF_M2TS_Mux_Stream *stream) void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) { GF_BitStream *bs; - Bool needs_pcr, first_pass, is_rap=0; + Bool needs_pcr, first_pass; u32 adaptation_field_control, payload_length, payload_to_copy, padding_length, hdr_len, pos, copy_next; assert(stream->pid); @@ -1460,22 +1550,46 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) gf_m2ts_stream_update_data_following(stream); hdr_len = gf_m2ts_stream_get_pes_header_length(stream); } - + adaptation_field_control = GF_M2TS_ADAPTATION_NONE; payload_length = 184 - hdr_len; payload_to_copy = padding_length = 0; - is_rap = (hdr_len && (stream->curr_pck.flags & GF_ESI_DATA_AU_RAP)) ? GF_TRUE : GF_FALSE; - needs_pcr = (hdr_len && (stream == stream->program->pcr) && (stream->pcr_priority || is_rap) ) ? 1 : 0; +// is_rap = (hdr_len && (stream->curr_pck.flags & GF_ESI_DATA_AU_RAP)) ? GF_TRUE : GF_FALSE; + needs_pcr = 0; - /*if we forced inserting PAT/PMT before new RAP, also insert PCR here*/ - if (stream->program->mux->force_pat_pmt_state == GF_SEG_BOUNDARY_FORCE_PCR) { - if (stream == stream->program->pcr) { + if (stream == stream->program->pcr) { + if (hdr_len) + needs_pcr = 1; + /*if we forced inserting PAT/PMT before new RAP, also insert PCR here*/ + if (stream->program->mux->force_pat_pmt_state == GF_SEG_BOUNDARY_FORCE_PCR) { stream->program->mux->force_pat_pmt_state = GF_SEG_BOUNDARY_NONE; needs_pcr = 1; } + + if (!needs_pcr && (stream->program->mux->real_time || stream->program->mux->fixed_rate) ) { + u64 clock; + u32 diff; + if (stream->program->mux->fixed_rate) { + clock = stream->program->mux->tot_pck_sent - stream->program->nb_pck_last_pcr; + clock *= 1504*1000000; + clock /= stream->program->mux->bit_rate; + if (clock >= (stream->program->mux->pcr_update_ms-5) *1000) { + needs_pcr = 1; + } + } + + if (!needs_pcr && stream->program->mux->real_time) { + clock = gf_sys_clock_high_res(); + diff = (u32) (clock - stream->program->sys_clock_at_last_pcr); + + if (diff >= (stream->program->mux->pcr_update_ms-2) *1000) { + needs_pcr = 1; + } + } + } } - if (needs_pcr) { + if (needs_pcr) { /*AF headers + PCR*/ payload_length -= 8; adaptation_field_control = GF_M2TS_ADAPTATION_AND_PAYLOAD; @@ -1485,9 +1599,9 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) payload_length -= 2; //AF header but no PCR adaptation_field_control = GF_M2TS_ADAPTATION_AND_PAYLOAD; } - payload_length -= 2 + stream->curr_pck.mpeg2_af_descriptors_size; //AF extension field and AF descriptor + payload_length -= 2 + stream->curr_pck.mpeg2_af_descriptors_size; //AF extension field and AF descriptor } - + if (hdr_len) { assert(!stream->pes_data_remain); if (! gf_m2ts_stream_compute_pes_length(stream, payload_length)) { @@ -1513,7 +1627,7 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (payload_to_copy >= payload_length) { padding_length = 0; payload_to_copy = payload_length; - } + } /*packet + next packet exceed payload length*/ else if (payload_to_copy + copy_next >= payload_length) { padding_length = 0; @@ -1534,18 +1648,29 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (payload_to_copy > payload_length) payload_to_copy = payload_length; } else { - padding_length = payload_length - payload_to_copy - copy_next; + padding_length = payload_length - payload_to_copy - copy_next; payload_length -= padding_length; } } +#ifndef GPAC_DISABLE_LOG + if (hdr_len && gf_log_tool_level_on(GF_LOG_DEBUG, GF_LOG_CONTAINER) ) { + u64 pcr = (s64) gf_m2ts_get_pcr(stream)/300; + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Start sending PES: PID %d - %d bytes - DTS "LLD" PCR "LLD" (diff %d) - stream time %d:%09d - mux time %d:%09d (%d us ahead of mux time)\n", + stream->pid, stream->curr_pck.data_len, stream->curr_pck.dts, pcr, (s64) stream->curr_pck.dts - (s64) pcr, + stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec, + gf_m2ts_time_diff_us(&stream->program->mux->time, &stream->time) + )); + } +#endif + gf_bs_write_int(bs, 0x47, 8); // sync byte gf_bs_write_int(bs, 0, 1); // error indicator gf_bs_write_int(bs, hdr_len ? 1 : 0, 1); // start ind gf_bs_write_int(bs, 0, 1); // transport priority gf_bs_write_int(bs, stream->pid, 13); // pid gf_bs_write_int(bs, 0, 2); // scrambling - gf_bs_write_int(bs, adaptation_field_control, 2); // we do not use adaptation field for sections + gf_bs_write_int(bs, adaptation_field_control, 2); // we do not use adaptation field for sections gf_bs_write_int(bs, stream->continuity_counter, 4); // continuity counter if (stream->continuity_counter < 15) stream->continuity_counter++; else stream->continuity_counter=0; @@ -1554,22 +1679,28 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) Bool is_rap; u64 pcr = 0; if (needs_pcr) { - u32 now = gf_sys_clock(); - /*compute PCR - we disabled real-time clock for now and only insert PCR based on DTS / CTS*/ - if (0 && stream->program->mux->real_time) { - pcr = gf_m2ts_get_pcr(stream->program); - } else { - pcr = ( ((stream->curr_pck.flags & GF_ESI_DATA_HAS_DTS) ? stream->curr_pck.dts : stream->curr_pck.cts) - stream->program->pcr_offset) * 300; - if (pcr>stream->program->pcr_init_time) pcr -= stream->program->pcr_init_time; - else pcr = 0; + u64 now = gf_sys_clock_high_res(); + pcr = gf_m2ts_get_pcr(stream); + + if (stream->program->mux->real_time || stream->program->mux->fixed_rate) { + u64 clock; + u32 diff = (s32) (now - stream->program->sys_clock_at_last_pcr); + if (diff > 5000 + stream->program->mux->pcr_update_ms*1000 ) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Sending PCR %d us too late (PCR send rate %d ms)\n", (u32) (diff - stream->program->mux->pcr_update_ms*1000), stream->program->mux->pcr_update_ms )); + } + clock = stream->program->mux->tot_pck_sent - stream->program->nb_pck_last_pcr; + clock *= 1504*1000000; + clock /= stream->program->mux->bit_rate; + +// GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] PCR diff %d us (PCR send rate %d ms) - accuracy %d us\n", (s32) diff , stream->program->mux->pcr_update_ms, (s32) clock)); } - //fprintf(stderr, "PCR Diff in ms %d - sys clock diff in ms %d - DTS diff %d\n", (u32) (pcr - stream->program->last_pcr) / 27000, now - stream->program->last_sys_clock, (stream->curr_pck.dts - stream->program->last_dts)/90); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Inserted PCR "LLD" (%d @90kHz) at mux time %d:%09d\n", pcr, (u32) (pcr/300), stream->program->mux->time.sec, stream->program->mux->time.nanosec )); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] PCR diff to STB in ms %d - sys clock diff in ms %d - DTS diff %d\n", (u32) (pcr - stream->program->last_pcr) / 27000, now - stream->program->sys_clock_at_last_pcr, (stream->curr_pck.dts - stream->program->last_dts)/90)); - stream->program->last_sys_clock = now; - /*if stream does not use DTS, use CTS as base time for PCR*/ - stream->program->last_dts = (stream->curr_pck.flags & GF_ESI_DATA_HAS_DTS) ? stream->curr_pck.dts : stream->curr_pck.cts; - stream->pcr_priority = 0; + stream->program->sys_clock_at_last_pcr = now; + stream->program->last_dts = stream->curr_pck.dts; + stream->program->nb_pck_last_pcr = stream->program->mux->tot_pck_sent; } is_rap = (hdr_len && (stream->curr_pck.flags & GF_ESI_DATA_AU_RAP) ) ? 1 : 0; gf_m2ts_add_adaptation(stream->program, bs, stream->pid, needs_pcr, pcr, is_rap, padding_length, stream->curr_pck.mpeg2_af_descriptors, stream->curr_pck.mpeg2_af_descriptors_size); @@ -1580,10 +1711,9 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) stream->curr_pck.mpeg2_af_descriptors_size = 0; } - if (padding_length) + if (padding_length) stream->program->mux->tot_pes_pad_bytes += padding_length; } - if (hdr_len) gf_m2ts_stream_add_pes_header(bs, stream); pos = (u32) gf_bs_get_position(bs); @@ -1596,13 +1726,32 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) stream->pes_data_remain -= payload_to_copy; /*update stream time, including headers*/ -// gf_m2ts_time_inc(&stream->time, payload_to_copy + pos - 4, stream->bit_rate); - + gf_m2ts_time_inc(&stream->time, 1504/*188*8*/, stream->program->mux->bit_rate); + if (stream->pck_offset == stream->curr_pck.data_len) { + u64 pcr = gf_m2ts_get_pcr(stream)/300; if (stream->program->mux->real_time && !stream->program->mux->fixed_rate && gf_m2ts_time_less(&stream->time, &stream->program->mux->time) ) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES from PID %d TOO LATE: stream time %d:%d - mux time %d:%d (current mux rate %d) \n", stream->pid, stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec, stream->program->mux->bit_rate)); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES TOO LATE: PID %d - DTS "LLD" - PCR "LLD" - stream time %d:%09d - mux time %d:%09d - current mux rate %d\n", + stream->pid, stream->curr_pck.dts, pcr, + stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec, + stream->program->mux->bit_rate + )); + } else if (stream->curr_pck.dts < pcr) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES %d us TOO LATE: PID %d - DTS "LLD" - size %d - PCR "LLD" - - stream time %d:%09d - mux time %d:%09d \n", + pcr - stream->curr_pck.dts, stream->pid, stream->curr_pck.dts, stream->curr_pck.data_len, pcr, + stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec + )); + } else if (stream->curr_pck.cts < pcr) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES %d us TOO LATE: PID %d - DTS "LLD" - size %d - PCR "LLD" - - stream time %d:%09d - mux time %d:%09d \n", + pcr - stream->curr_pck.dts, stream->pid, stream->curr_pck.dts, stream->curr_pck.data_len, pcr, + stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec + )); } else { - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES (%d bytes) from PID %d at stream time %d:%d (DTS "LLD" - PCR "LLD")\n", stream->curr_pck.data_len, stream->pid, stream->time.sec, stream->time.nanosec, stream->curr_pck.dts, gf_m2ts_get_pcr(stream->program)/300)); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Done sending PES: PID %d - DTS "LLD" - PCR "LLD" - stream time %d:%09d - mux time %d:%09d \n", + stream->pid, stream->curr_pck.dts, pcr, + stream->time.sec, stream->time.nanosec, stream->program->mux->time.sec, stream->program->mux->time.nanosec + )); + } /*PES has been sent, discard internal buffer*/ @@ -1611,19 +1760,11 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) stream->curr_pck.data_len = 0; stream->pck_offset = 0; -#ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_CONTAINER, GF_LOG_INFO) - && gf_m2ts_time_less(&stream->program->mux->time, &stream->time) - ) { - s32 drift; - GF_M2TS_Time muxtime = stream->program->mux->time; - drift= stream->time.nanosec; - drift-=muxtime.nanosec; - drift/=1000; - if (muxtime.sec!=stream->time.sec) { - drift += (stream->time.sec - muxtime.sec)*1000000; - } - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] PES PID %d sent %d us too late\n", stream->pid, drift) ); +//#ifndef GPAC_DISABLE_LOG +#if 0 + if (gf_m2ts_time_less(&stream->program->mux->time, &stream->time) ) { + s32 drift = gf_m2ts_time_diff_us(&stream->program->mux->time, &stream->time); + GF_LOG( (drift>1000) ? GF_LOG_WARNING : GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] PES PID %d sent %d us too late\n", stream->pid, drift) ); } #endif @@ -1639,7 +1780,7 @@ void gf_m2ts_mux_pes_get_next_packet(GF_M2TS_Mux_Stream *stream, char *packet) if (!res) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Not enough data to fill current PES (PID %d) - filling with 0xFF\n", stream->pid) ); memset(packet+pos, 0xFF, copy_next); - + if (stream->copy_from_next_packets > copy_next) { stream->copy_from_next_packets -= copy_next; } else { @@ -1908,17 +2049,17 @@ GF_M2TS_Mux_Stream *gf_m2ts_program_stream_add(GF_M2TS_Mux_Program *program, str break; case GPAC_OTI_VIDEO_AVC: stream->mpeg2_stream_type = GF_M2TS_VIDEO_H264; - /*make sure we send AU delim NALU in same PES as first VCL NAL: 6 bytes (start code + 1 nal hdr + AU delim) + /*make sure we send AU delim NALU in same PES as first VCL NAL: 6 bytes (start code + 1 nal hdr + AU delim) + 4 byte start code + first nal header*/ stream->min_bytes_copy_from_next = 11; break; case GPAC_OTI_VIDEO_SVC: stream->mpeg2_stream_type = GF_M2TS_VIDEO_SVC; - /*make sure we send AU delim NALU in same PES as first VCL NAL: 6 bytes (start code + 1 nal hdr + AU delim) + /*make sure we send AU delim NALU in same PES as first VCL NAL: 6 bytes (start code + 1 nal hdr + AU delim) + 4 byte start code + first nal header*/ stream->min_bytes_copy_from_next = 11; gf_m2ts_stream_add_hierarchy_descriptor(stream); - break; + break; case GPAC_OTI_VIDEO_HEVC: stream->mpeg2_stream_type = GF_M2TS_VIDEO_HEVC; /*make sure we send AU delim NALU in same PES as first VCL NAL: 7 bytes (4 start code + 2 nal header + 1 AU delim) @@ -2038,6 +2179,17 @@ GF_Err gf_m2ts_program_stream_update_ts_scale(GF_ESInterface *_self, u32 time_sc return GF_OK; } +GF_EXPORT +GF_M2TS_Mux_Program *gf_m2ts_mux_program_find(GF_M2TS_Mux *muxer, u32 program_number) +{ + GF_M2TS_Mux_Program *program = muxer->programs; + while (program) { + if (program->number == program_number) return program; + program = program->next; + } + return NULL; +} + GF_EXPORT GF_M2TS_Mux_Program *gf_m2ts_mux_program_add(GF_M2TS_Mux *muxer, u32 program_number, u32 pmt_pid, u32 pmt_refresh_rate, u32 pcr_offset, Bool mpeg4_signaling) { @@ -2066,6 +2218,18 @@ GF_M2TS_Mux_Program *gf_m2ts_mux_program_add(GF_M2TS_Mux *muxer, u32 program_num return program; } +GF_EXPORT +void gf_m2ts_mux_program_set_name(GF_M2TS_Mux_Program *program, const char *program_name, const char *provider_name) +{ + if (program->name) gf_free(program->name); + program->name = program_name ? gf_strdup(program_name) : NULL; + + if (program->provider) gf_free(program->provider); + program->provider = provider_name ? gf_strdup(provider_name) : NULL; + + if (program->mux->sdt) program->mux->sdt->table_needs_update = 1; +} + GF_EXPORT GF_M2TS_Mux *gf_m2ts_mux_new(u32 mux_rate, u32 pat_refresh_rate, Bool real_time) { @@ -2092,9 +2256,29 @@ GF_M2TS_Mux *gf_m2ts_mux_new(u32 mux_rate, u32 pat_refresh_rate, Bool real_time) gf_bs_write_int(bs, 0, 4); gf_bs_del(bs); gf_rand_init(0); + muxer->pcr_update_ms = 100; return muxer; } +GF_EXPORT +void gf_m2ts_mux_enable_sdt(GF_M2TS_Mux *mux, u32 refresh_rate_ms) +{ + if (!mux->sdt) { + mux->sdt = gf_m2ts_stream_new(GF_M2TS_PID_SDT_BAT_ST); + mux->sdt->process = gf_m2ts_stream_process_sdt; + mux->sdt->refresh_rate_ms = refresh_rate_ms; + } + mux->sdt->table_needs_update = 1; + return; +} + + +GF_EXPORT +void gf_m2ts_mux_set_pcr_max_interval(GF_M2TS_Mux *muxer, u32 pcr_update_ms) +{ + if (muxer && (pcr_update_ms<=100)) muxer->pcr_update_ms = pcr_update_ms; +} + void gf_m2ts_mux_stream_del(GF_M2TS_Mux_Stream *st) { while (st->tables) { @@ -2145,6 +2329,8 @@ void gf_m2ts_mux_program_del(GF_M2TS_Mux_Program *prog) gf_list_del(prog->loop_descriptors); } gf_m2ts_mux_stream_del(prog->pmt); + if (prog->name) gf_free(prog->name); + if (prog->provider) gf_free(prog->provider); gf_free(prog); } @@ -2157,43 +2343,28 @@ void gf_m2ts_mux_del(GF_M2TS_Mux *mux) mux->programs = p; } gf_m2ts_mux_stream_del(mux->pat); + if (mux->sdt) gf_m2ts_mux_stream_del(mux->sdt); gf_free(mux); } -void gf_m2ts_mux_update_bitrate(GF_M2TS_Mux *mux) +GF_EXPORT +void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time) { GF_M2TS_Mux_Program *prog; - if (!mux || mux->fixed_rate) return; - mux->bit_rate = 0; gf_m2ts_mux_table_update_bitrate(mux, mux->pat); - mux->bit_rate += mux->pat->bit_rate; - - - prog = mux->programs; - while (prog) { - GF_M2TS_Mux_Stream *stream = prog->streams; - gf_m2ts_mux_table_update_bitrate(mux, prog->pmt); - mux->bit_rate += prog->pmt->bit_rate; - while (stream) { - mux->bit_rate += stream->bit_rate; - stream = stream->next; - } - prog = prog->next; + if (mux->sdt) { + gf_m2ts_mux_table_update_bitrate(mux, mux->sdt); } -} - -GF_EXPORT -void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time) -{ - GF_M2TS_Mux_Program *prog; if (!mux->fixed_rate) { mux->bit_rate = 0; /*get PAT bitrate*/ - gf_m2ts_mux_table_update_bitrate(mux, mux->pat); mux->bit_rate += mux->pat->bit_rate; + if (mux->sdt) { + mux->bit_rate += mux->sdt->bit_rate; + } } prog = mux->programs; @@ -2208,23 +2379,27 @@ void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time) stream = stream->next; } /*get PMT bitrate*/ + gf_m2ts_mux_table_update_bitrate(mux, prog->pmt); + if (!mux->fixed_rate) { - gf_m2ts_mux_table_update_bitrate(mux, prog->pmt); mux->bit_rate += prog->pmt->bit_rate; } + prog = prog->next; } + /*reset mux time*/ if (reset_time) { mux->time.sec = mux->time.nanosec = 0; mux->init_sys_time = 0; } + } GF_EXPORT u32 gf_m2ts_get_sys_clock(GF_M2TS_Mux *muxer) { - return gf_sys_clock() - muxer->init_sys_time; + return (u32) (gf_sys_clock_high_res() - muxer->init_sys_time)/1000; } GF_EXPORT @@ -2257,37 +2432,39 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ { GF_M2TS_Mux_Program *program; GF_M2TS_Mux_Stream *stream, *stream_to_process; - GF_M2TS_Time time; - u32 now, nb_streams, nb_streams_done; + GF_M2TS_Time time, max_time; + u32 nb_streams, nb_streams_done; + u64 now_us; char *ret; u32 res, highest_priority; Bool flush_all_pes = 0; + Bool check_max_time = 0; nb_streams = nb_streams_done = 0; *status = GF_M2TS_STATE_IDLE; - now = gf_sys_clock(); + now_us = gf_sys_clock_high_res(); if (muxer->real_time) { if (!muxer->init_sys_time) { //init TS time muxer->time.sec = muxer->time.nanosec = 0; gf_m2ts_time_inc(&muxer->time, (u32) (muxer->init_pcr_value ? muxer->init_pcr_value-1 : 0), 27000000); - muxer->init_sys_time = now; + muxer->init_sys_time = now_us; muxer->init_ts_time = muxer->time; } else { - u32 diff = now - muxer->init_sys_time; + u64 us_diff = now_us - muxer->init_sys_time; GF_M2TS_Time now = muxer->init_ts_time; - gf_m2ts_time_inc(&now, diff, 1000); + gf_m2ts_time_inc(&now, us_diff, 1000000); if (gf_m2ts_time_less(&now, &muxer->time)) { if (usec_till_next) { u32 diff = muxer->time.sec - now.sec; diff *= 1000000; if (now.nanosec <= muxer->time.nanosec) { - diff += (muxer->time.nanosec - now.nanosec) / 1000; + diff += (muxer->time.nanosec - now.nanosec) / 1000; } else { assert(diff); diff -= 1000000; - diff += (1000000000 + muxer->time.nanosec - now.nanosec) / 1000; + diff += (1000000000 + muxer->time.nanosec - now.nanosec) / 1000; } *usec_till_next = diff; } @@ -2298,6 +2475,7 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ stream_to_process = NULL; time = muxer->time; + max_time.sec = max_time.nanosec = 0; /*bitrate have changed*/ if (muxer->needs_reconfig) { @@ -2339,6 +2517,16 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ goto send_pck; } + /*SDT*/ + if (muxer->sdt && !muxer->force_pat_pmt_state) { + res = muxer->sdt->process(muxer, muxer->sdt); + if (res && gf_m2ts_time_less_or_equal(&muxer->sdt->time, &time) ) { + time = muxer->sdt->time; + stream_to_process = muxer->sdt; + goto send_pck; + } + } + /*PMT, for each program*/ program = muxer->programs; while (program) { @@ -2346,7 +2534,7 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ if ((res && gf_m2ts_time_less_or_equal(&program->pmt->time, &time)) || (muxer->force_pat_pmt_state==GF_SEG_BOUNDARY_FORCE_PMT)) { time = program->pmt->time; stream_to_process = program->pmt; - if (muxer->force_pat_pmt_state==GF_SEG_BOUNDARY_FORCE_PMT) + if (muxer->force_pat_pmt_state==GF_SEG_BOUNDARY_FORCE_PMT) muxer->force_pat_pmt_state = GF_SEG_BOUNDARY_FORCE_PCR; /*force sending the PMT regardless of other streams*/ goto send_pck; @@ -2357,7 +2545,11 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ /*if non-fixed rate, just pick the earliest data on all streams*/ if (!muxer->fixed_rate) { - time.sec = 0xFFFFFFFF; + if (!muxer->real_time) { + time.sec = 0xFFFFFFFF; + } else { + check_max_time = 1; + } } #define FORCE_PCR_FIRST 0 @@ -2387,7 +2579,7 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ stream = program->streams; while (stream) { #if FORCE_PCR_FIRST - if (stream != program->pcr) + if (stream != program->pcr) #endif { if (flush_all_pes && !stream->pes_data_remain) { @@ -2413,19 +2605,21 @@ const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status, u32 *usec_till_ } else if (gf_m2ts_time_equal(&stream->time, &time)) { /*if the same priority schedule base stream first*/ - if ((res > highest_priority) || ((res == highest_priority) && !stream->ifce->depends_on_stream)){ - highest_priority = res; - time = stream->time; - stream_to_process = stream; + if ((res > highest_priority) || ((res == highest_priority) && !stream->ifce->depends_on_stream)) { + highest_priority = res; + time = stream->time; + stream_to_process = stream; #if FORCE_PCR_FIRST - goto send_pck; + goto send_pck; #endif - } + } + } else if (check_max_time && gf_m2ts_time_less(&max_time, &stream->time)) { + max_time = stream->time; } } } nb_streams++; - if ((stream->ifce->caps & GF_ESI_STREAM_IS_OVER) && (!res || stream->refresh_rate_ms) ) + if ((stream->ifce->caps & GF_ESI_STREAM_IS_OVER) && (!res || stream->refresh_rate_ms) ) nb_streams_done ++; stream = stream->next; @@ -2444,7 +2638,7 @@ send_pck: } /* padding packets ?? */ if (muxer->fixed_rate) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Inserting empty packet at %d:%d\n", time.sec, time.nanosec)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Inserting empty packet at %d:%09d\n", time.sec, time.nanosec)); ret = muxer->null_pck; muxer->tot_pad_sent++; } @@ -2459,45 +2653,39 @@ send_pck: ret = muxer->dst_pck; *status = GF_M2TS_STATE_DATA; -#ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_CONTAINER, GF_LOG_DEBUG) - && muxer->fixed_rate - ) { - s32 drift; - drift= muxer->time.nanosec; - drift-=time.nanosec; - drift/=1000000; - if (muxer->time.sec!=time.sec) { - drift += (muxer->time.sec - time.sec)*1000; - assert(muxer->time.sec > time.sec); - } -// fprintf(stderr, "\nMux time - Packet PID %d time: %d ms\n", stream_to_process->pid, drift); - } GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG2-TS Muxer] Send %s from PID %d at %d:%09d - mux time %d:%09d\n", stream_to_process->tables ? "table" : "PES", stream_to_process->pid, time.sec, time.nanosec, muxer->time.sec, muxer->time.nanosec)); -#endif - - if (nb_streams && (nb_streams==nb_streams_done)) + if (nb_streams && (nb_streams==nb_streams_done)) *status = GF_M2TS_STATE_EOS; } if (ret) { muxer->tot_pck_sent++; /*increment time*/ - if (muxer->fixed_rate || muxer->real_time) { + if (muxer->fixed_rate ) { gf_m2ts_time_inc(&muxer->time, 1504/*188*8*/, muxer->bit_rate); } + else if (muxer->real_time) { + u64 us_diff = gf_sys_clock_high_res() - muxer->init_sys_time; + muxer->time = muxer->init_ts_time; + gf_m2ts_time_inc(&muxer->time, us_diff, 1000000); + } /*if a stream was found, use it*/ else if (stream_to_process) { muxer->time = time; } muxer->pck_sent_over_br_window++; - if (now - muxer->last_br_time > 1000) { + if (now_us - muxer->last_br_time_us > 1000000) { u64 size = 8*188*muxer->pck_sent_over_br_window; - muxer->average_birate_kbps = (u32) (size /(now - muxer->last_br_time)); - muxer->last_br_time = now; + muxer->average_birate_kbps = (u32) (size*1000 / (now_us - muxer->last_br_time_us)); + muxer->last_br_time_us = now_us; muxer->pck_sent_over_br_window=0; } + } else if (muxer->real_time && !muxer->fixed_rate) { +// u64 us_diff = gf_sys_clock_high_res() - muxer->init_sys_time; +// muxer->time = muxer->init_ts_time; +// gf_m2ts_time_inc(&muxer->time, us_diff, 1000000); + muxer->time = max_time; } return ret; } diff --git a/src/media_tools/m3u8.c b/src/media_tools/m3u8.c index 75e6701..14a4119 100644 --- a/src/media_tools/m3u8.c +++ b/src/media_tools/m3u8.c @@ -238,13 +238,13 @@ GF_Err playlist_element_dump(const PlaylistElement * e, int indent) { return r; } GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[M3U8] PlayListElement[%p, title=%s, codecs=%s, duration=%d, bandwidth=%d, url=%s, type=%s]\n", - (void*)e, - e->title, - e->codecs, - e->durationInfo, - e->bandwidth, - e->url, - e->elementType == TYPE_STREAM ? "stream" : "playlist")); + (void*)e, + e->title, + e->codecs, + e->durationInfo, + e->bandwidth, + e->url, + e->elementType == TYPE_STREAM ? "stream" : "playlist")); if (TYPE_PLAYLIST == e->elementType) { int sz; assert( e->element.playlist.elements); @@ -564,14 +564,15 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const continue; if (currentLineNumber == 1) { /* Playlist MUST start with #EXTM3U */ -/* if (len < 7 || strncmp("#EXTM3U", currentLine, 7)!=0) { - fclose(f); - variant_playlist_del(pl); - GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Failed to parse M3U8 File, it should start with #EXTM3U, but was : %s\n", currentLine)); - return GF_STREAM_NOT_FOUND; - } - continue; -*/ } + /* if (len < 7 || strncmp("#EXTM3U", currentLine, 7)!=0) { + fclose(f); + variant_playlist_del(pl); + GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Failed to parse M3U8 File, it should start with #EXTM3U, but was : %s\n", currentLine)); + return GF_STREAM_NOT_FOUND; + } + continue; + */ + } if (currentLine[0] == '#') { /* A comment or a directive */ if (strncmp("#EXT", currentLine, 4)==0) { @@ -614,8 +615,8 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const } } else */ { fullURL = gf_url_concatenate(baseURL, currentLine); - } - assert( fullURL ); + } + assert( fullURL ); } { u32 count; @@ -661,12 +662,12 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const //assert( 0 ); } currentPlayList = playlist_element_new( - TYPE_UNKNOWN, - fullURL, - attribs.title, - attribs.codecs, - attribs.durationInSeconds, - attribs.byteRangeStart, attribs.byteRangeEnd); + TYPE_UNKNOWN, + fullURL, + attribs.title, + attribs.codecs, + attribs.durationInSeconds, + attribs.byteRangeStart, attribs.byteRangeEnd); if (currentPlayList == NULL) { /* OUT of memory */ variant_playlist_del(*playlist); @@ -689,12 +690,12 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const PlaylistElement * subElement; assert(baseURL); currentPlayList = playlist_element_new( - TYPE_PLAYLIST, - baseURL, - attribs.title, - attribs.codecs, - attribs.durationInSeconds, - attribs.byteRangeStart, attribs.byteRangeEnd); + TYPE_PLAYLIST, + baseURL, + attribs.title, + attribs.codecs, + attribs.durationInSeconds, + attribs.byteRangeStart, attribs.byteRangeEnd); if (currentPlayList == NULL) { /* OUT of memory */ variant_playlist_del(*playlist); @@ -708,12 +709,12 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const currentPlayList->title = NULL; currentPlayList->codecs = NULL; subElement = playlist_element_new( - TYPE_UNKNOWN, - fullURL, - attribs.title, - attribs.codecs, - attribs.durationInSeconds, - attribs.byteRangeStart, attribs.byteRangeEnd); + TYPE_UNKNOWN, + fullURL, + attribs.title, + attribs.codecs, + attribs.durationInSeconds, + attribs.byteRangeStart, attribs.byteRangeEnd); if (subElement == NULL) { variant_playlist_del(*playlist); playlist_element_del(currentPlayList); @@ -723,19 +724,19 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const } gf_list_add(currentPlayList->element.playlist.elements, subElement); gf_list_add(program->bitrates, currentPlayList); - currentPlayList->element.playlist.computed_duration += subElement->durationInfo; + currentPlayList->element.playlist.computed_duration += subElement->durationInfo; assert( program ); assert( program->bitrates); assert( currentPlayList); } else { PlaylistElement * subElement = playlist_element_new( - TYPE_UNKNOWN, - fullURL, - attribs.title, - attribs.codecs, - attribs.durationInSeconds, - attribs.byteRangeStart, attribs.byteRangeEnd); + TYPE_UNKNOWN, + fullURL, + attribs.title, + attribs.codecs, + attribs.durationInSeconds, + attribs.byteRangeStart, attribs.byteRangeEnd); if (currentPlayList->elementType != TYPE_PLAYLIST) { currentPlayList->elementType = TYPE_PLAYLIST; if (!currentPlayList->element.playlist.elements) @@ -749,7 +750,7 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const return GF_OUT_OF_MEM; } gf_list_add(currentPlayList->element.playlist.elements, subElement); - currentPlayList->element.playlist.computed_duration += subElement->durationInfo; + currentPlayList->element.playlist.computed_duration += subElement->durationInfo; } } @@ -759,11 +760,11 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const currentPlayList->element.playlist.target_duration = attribs.targetDurationInSeconds; currentPlayList->durationInfo = attribs.targetDurationInSeconds; } - if (attribs.durationInSeconds) { + if (attribs.durationInSeconds) { if (currentPlayList->durationInfo == 0) { /* we set the playlist duration info as the duration of a segment, only if it's not set - There are cases of playlist with the last segment with a duration different from the others - (example: Apple bipbop test)*/ + There are cases of playlist with the last segment with a duration different from the others + (example: Apple bipbop test)*/ currentPlayList->durationInfo = attribs.durationInSeconds; } } @@ -800,7 +801,7 @@ GF_Err parse_sub_playlist(const char * file, VariantPlaylist ** playlist, const for (j=0; jbitrates); j++) { PlaylistElement *ple = gf_list_get(prog->bitrates, j); if (ple->elementType==TYPE_PLAYLIST) { - if (ple->element.playlist.computed_duration > prog->computed_duration) + if (ple->element.playlist.computed_duration > prog->computed_duration) prog->computed_duration = ple->element.playlist.computed_duration; } } diff --git a/src/media_tools/media_export.c b/src/media_tools/media_export.c index 6b546ca..07d6ffe 100644 --- a/src/media_tools/media_export.c +++ b/src/media_tools/media_export.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -131,7 +131,7 @@ static GF_Err gf_dump_to_ogg(GF_MediaExporter *dumper, char *szName, u32 track) gf_fwrite(og.header, 1, og.header_len, out); gf_fwrite(og.body, 1, og.body_len, out); } - + op.granulepos = -1; count = gf_isom_get_sample_count(dumper->file, track); @@ -179,7 +179,7 @@ static GF_Err gf_dump_to_ogg(GF_MediaExporter *dumper, char *szName, u32 track) gf_fwrite(og.header, 1, og.header_len, out); gf_fwrite(og.body, 1, og.body_len, out); } - ogg_stream_clear(&os); + ogg_stream_clear(&os); if (szName) fclose(out); return GF_OK; #endif @@ -259,7 +259,7 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) Bool is_stdout = GF_FALSE; GF_BitStream *bs; u32 track, i, di, count, m_type, m_stype, dsi_size, is_mj2k; - Bool is_wvtt = GF_FALSE; + Bool is_wvtt = GF_FALSE; if (!(track = gf_isom_get_track_by_id(dumper->file, dumper->trackID))) { GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("Wrong track ID %d for file %s \n", dumper->trackID, gf_isom_get_filename(dumper->file))); @@ -276,7 +276,7 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) dsi = NULL; udesc = NULL; dcfg = NULL; - if ((m_stype==GF_ISOM_SUBTYPE_MPEG4) || (m_stype==GF_ISOM_SUBTYPE_MPEG4_CRYP)) + if ((m_stype==GF_ISOM_SUBTYPE_MPEG4) || (m_stype==GF_ISOM_SUBTYPE_MPEG4_CRYP)) dcfg = gf_isom_get_decoder_config(dumper->file, track, 1); strcpy(szName, dumper->out_name ? dumper->out_name : ""); @@ -345,25 +345,32 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) } break; case GF_STREAM_SCENE: - strcpy(szEXT, ".bifs"); gf_export_message(dumper, GF_OK, "Dumping BIFS sample%s", szNum); + strcpy(szEXT, ".bifs"); + gf_export_message(dumper, GF_OK, "Dumping BIFS sample%s", szNum); break; case GF_STREAM_OD: - strcpy(szEXT, ".od"); gf_export_message(dumper, GF_OK, "Dumping OD sample%s", szNum); + strcpy(szEXT, ".od"); + gf_export_message(dumper, GF_OK, "Dumping OD sample%s", szNum); break; case GF_STREAM_MPEGJ: - strcpy(szEXT, ".mpj"); gf_export_message(dumper, GF_OK, "Dumping MPEG-J sample%s", szNum); + strcpy(szEXT, ".mpj"); + gf_export_message(dumper, GF_OK, "Dumping MPEG-J sample%s", szNum); break; case GF_STREAM_OCI: - strcpy(szEXT, ".oci"); gf_export_message(dumper, GF_OK, "Dumping OCI sample%s", szNum); + strcpy(szEXT, ".oci"); + gf_export_message(dumper, GF_OK, "Dumping OCI sample%s", szNum); break; case GF_STREAM_MPEG7: - strcpy(szEXT, ".mp7"); gf_export_message(dumper, GF_OK, "Dumping MPEG7 sample%s", szNum); + strcpy(szEXT, ".mp7"); + gf_export_message(dumper, GF_OK, "Dumping MPEG7 sample%s", szNum); break; case GF_STREAM_IPMP: - strcpy(szEXT, ".ipmp"); gf_export_message(dumper, GF_OK, "Dumping IPMP sample%s", szNum); + strcpy(szEXT, ".ipmp"); + gf_export_message(dumper, GF_OK, "Dumping IPMP sample%s", szNum); break; case GF_STREAM_TEXT: - strcpy(szEXT, ".tx3g"); gf_export_message(dumper, GF_OK, "Dumping 3GP Text sample%s", szNum); + strcpy(szEXT, ".tx3g"); + gf_export_message(dumper, GF_OK, "Dumping 3GP Text sample%s", szNum); break; default: gf_odf_desc_del((GF_Descriptor *) dcfg); @@ -385,17 +392,17 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) } else if (m_stype==GF_4CC('x','d','v','b') ) { gf_export_message(dumper, GF_OK, "Extracting MPEG-2 sample%s", szNum); strcpy(szEXT, ".m2v"); - } else if ((m_stype==GF_ISOM_SUBTYPE_AVC_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC2_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC3_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC4_H264) - || (m_stype==GF_ISOM_SUBTYPE_SVC_H264) - ) { + } else if ((m_stype==GF_ISOM_SUBTYPE_AVC_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC2_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC3_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC4_H264) + || (m_stype==GF_ISOM_SUBTYPE_SVC_H264) + ) { strcpy(szEXT, ".h264"); gf_export_message(dumper, GF_OK, "Dumping MPEG-4 AVC-H264 Visual sample%s", szNum); - } else if ((m_stype==GF_ISOM_SUBTYPE_HVC1) - || (m_stype==GF_ISOM_SUBTYPE_HEV1) - ) { + } else if ((m_stype==GF_ISOM_SUBTYPE_HVC1) + || (m_stype==GF_ISOM_SUBTYPE_HEV1) + ) { strcpy(szEXT, ".hvc"); gf_export_message(dumper, GF_OK, "Dumping MPEG-H HEVC Visual sample%s", szNum); } else if (m_type==GF_ISOM_MEDIA_FLASH) { @@ -404,7 +411,7 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) } else if (m_stype==GF_ISOM_SUBTYPE_WVTT) { gf_export_message(dumper, GF_OK, "Extracting WebVTT sample%s", szNum); strcpy(szEXT, ".vtt"); - is_wvtt = GF_TRUE; + is_wvtt = GF_TRUE; } else if (m_stype==GF_ISOM_SUBTYPE_STSE) { gf_export_message(dumper, GF_OK, "Extracting Simple Text sample%s", szNum); strcpy(szEXT, ".txt"); @@ -423,8 +430,12 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) strcat(szEXT, gf_4cc_to_str(m_stype)); udesc = gf_isom_get_generic_sample_description(dumper->file, track, 1); switch (m_type) { - case GF_ISOM_MEDIA_VISUAL: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Video - Compressor %s", szEXT, udesc ? udesc->compressor_name: "Unknown"); break; - case GF_ISOM_MEDIA_AUDIO: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Audio - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); break; + case GF_ISOM_MEDIA_VISUAL: + gf_export_message(dumper, GF_OK, "Extracting \'%s\' Video - Compressor %s", szEXT, udesc ? udesc->compressor_name: "Unknown"); + break; + case GF_ISOM_MEDIA_AUDIO: + gf_export_message(dumper, GF_OK, "Extracting \'%s\' Audio - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); + break; default: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Track (type '%s') - Compressor %s sample%s", szEXT, gf_4cc_to_str(m_type), udesc ? udesc->compressor_name : "Unknown", szNum); break; @@ -451,27 +462,27 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) } out = is_stdout ? stdout : gf_f64_open(szName, "wb"); bs = gf_bs_from_file(out, GF_BITSTREAM_WRITE); - if (is_mj2k) + if (is_mj2k) write_jp2_file(bs, samp->data, samp->dataLength, dsi, dsi_size); else { #ifndef GPAC_DISABLE_TTXT - if (is_wvtt) { - GF_Err e; - e = gf_webvtt_dump_header(out, dumper->file, track, 1); - if (e == GF_OK) { - GF_Err gf_webvtt_dump_iso_sample(FILE *dump, u32 timescale, GF_ISOSample *iso_sample); - u32 timescale = gf_isom_get_media_timescale(dumper->file, track); - gf_webvtt_dump_iso_sample(out, timescale, samp); - } - } else + if (is_wvtt) { + GF_Err e; + e = gf_webvtt_dump_header(out, dumper->file, track, 1); + if (e == GF_OK) { + GF_Err gf_webvtt_dump_iso_sample(FILE *dump, u32 timescale, GF_ISOSample *iso_sample); + u32 timescale = gf_isom_get_media_timescale(dumper->file, track); + gf_webvtt_dump_iso_sample(out, timescale, samp); + } + } else #endif - { - gf_bs_write_data(bs, samp->data, samp->dataLength); - } - } + { + gf_bs_write_data(bs, samp->data, samp->dataLength); + } + } gf_isom_sample_del(&samp); gf_bs_del(bs); - + if (!is_stdout) fclose(out); if (dsi) @@ -503,24 +514,24 @@ GF_Err gf_media_export_samples(GF_MediaExporter *dumper) out = is_stdout ? stdout : gf_f64_open(szName, "wb"); bs = gf_bs_from_file(out, GF_BITSTREAM_WRITE); if (dsi) gf_bs_write_data(bs, dsi, dsi_size); - if (is_mj2k) + if (is_mj2k) write_jp2_file(bs, samp->data, samp->dataLength, dsi, dsi_size); else { #ifndef GPAC_DISABLE_TTXT - if (is_wvtt) { - GF_Err e; - e = gf_webvtt_dump_header(out, dumper->file, track, 1); - if (e == GF_OK) { - GF_Err gf_webvtt_dump_iso_sample(FILE *dump, u32 timescale, GF_ISOSample *iso_sample); - u32 timescale = gf_isom_get_media_timescale(dumper->file, track); - gf_webvtt_dump_iso_sample(out, timescale, samp); - } - } else + if (is_wvtt) { + GF_Err e; + e = gf_webvtt_dump_header(out, dumper->file, track, 1); + if (e == GF_OK) { + GF_Err gf_webvtt_dump_iso_sample(FILE *dump, u32 timescale, GF_ISOSample *iso_sample); + u32 timescale = gf_isom_get_media_timescale(dumper->file, track); + gf_webvtt_dump_iso_sample(out, timescale, samp); + } + } else #endif - { - gf_bs_write_data(bs, samp->data, samp->dataLength); - } - } + { + gf_bs_write_data(bs, samp->data, samp->dataLength); + } + } gf_isom_sample_del(&samp); gf_set_progress("Media Export", i+1, count); gf_bs_del(bs); @@ -683,7 +694,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) char *dsi; QCPRateTable rtable[8]; Bool is_stdout=0; - Bool is_webvtt = GF_FALSE; + Bool is_webvtt = GF_FALSE; dsi_size = 0; dsi = NULL; @@ -691,7 +702,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) avccfg = NULL; svccfg = NULL; shvccfg = NULL; - + if (!(track = gf_isom_get_track_by_id(dumper->file, dumper->trackID))) { GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("Wrong track ID %d for file %s \n", dumper->trackID, gf_isom_get_filename(dumper->file))); return GF_BAD_PARAM; @@ -700,7 +711,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) m_type = gf_isom_get_media_type(dumper->file, track); m_stype = gf_isom_get_media_subtype(dumper->file, track, 1); has_qcp_pad = 0; - if (dumper->out_name && !strcmp(dumper->out_name, "std")) + if (dumper->out_name && !strcmp(dumper->out_name, "std")) is_stdout = 1; is_aac = aac_type = 0; @@ -709,7 +720,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) is_vobsub = 0; udesc = NULL; dcfg = NULL; - if ((m_stype==GF_ISOM_SUBTYPE_MPEG4) || (m_stype==GF_ISOM_SUBTYPE_MPEG4_CRYP)) + if ((m_stype==GF_ISOM_SUBTYPE_MPEG4) || (m_stype==GF_ISOM_SUBTYPE_MPEG4_CRYP)) dcfg = gf_isom_get_decoder_config(dumper->file, track, 1); add_ext = (dumper->out_name && strrchr(dumper->out_name , '.')==NULL) ? 1 : 0; @@ -724,7 +735,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) dcfg->decoderSpecificInfo->data = NULL; dsi_size = dcfg->decoderSpecificInfo->dataLength; } - if (add_ext) + if (add_ext) strcat(szName, ".cmp"); gf_export_message(dumper, GF_OK, "Extracting MPEG-4 Visual stream to cmp"); break; @@ -732,7 +743,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) case GPAC_OTI_VIDEO_SVC: avccfg = gf_isom_avc_config_get(dumper->file, track, 1); svccfg = gf_isom_svc_config_get(dumper->file, track, 1); - if (add_ext) + if (add_ext) strcat(szName, ".h264"); gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AVC-H264 stream to h264"); break; @@ -740,37 +751,37 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) case GPAC_OTI_VIDEO_SHVC: hevccfg = gf_isom_hevc_config_get(dumper->file, track, 1); shvccfg = gf_isom_shvc_config_get(dumper->file, track, 1); - if (add_ext) + if (add_ext) strcat(szName, ".hvc"); gf_export_message(dumper, GF_OK, "Extracting MPEG-H HEVC stream to hevc"); break; case GPAC_OTI_VIDEO_MPEG1: - if (add_ext) + if (add_ext) strcat(szName, ".m1v"); gf_export_message(dumper, GF_OK, "Extracting MPEG-1 Visual stream to m1v"); break; - case GPAC_OTI_VIDEO_MPEG2_SIMPLE: - case GPAC_OTI_VIDEO_MPEG2_MAIN: - case GPAC_OTI_VIDEO_MPEG2_SNR: - case GPAC_OTI_VIDEO_MPEG2_SPATIAL: - case GPAC_OTI_VIDEO_MPEG2_HIGH: - case GPAC_OTI_VIDEO_MPEG2_422: - if (add_ext) + case GPAC_OTI_VIDEO_MPEG2_SIMPLE: + case GPAC_OTI_VIDEO_MPEG2_MAIN: + case GPAC_OTI_VIDEO_MPEG2_SNR: + case GPAC_OTI_VIDEO_MPEG2_SPATIAL: + case GPAC_OTI_VIDEO_MPEG2_HIGH: + case GPAC_OTI_VIDEO_MPEG2_422: + if (add_ext) strcat(szName, ".m2v"); gf_export_message(dumper, GF_OK, "Extracting MPEG-2 Visual stream to m2v"); break; case GPAC_OTI_IMAGE_JPEG: - if (add_ext) + if (add_ext) strcat(szName, ".jpg"); gf_export_message(dumper, GF_OK, "Extracting JPEG image"); break; case GPAC_OTI_IMAGE_PNG: - if (add_ext) + if (add_ext) strcat(szName, ".png"); gf_export_message(dumper, GF_OK, "Extracting PNG image"); break; case GPAC_OTI_MEDIA_OGG: - if (add_ext) + if (add_ext) strcat(szName, ".ogg"); gf_export_message(dumper, GF_OK, "Extracting Ogg video"); is_ogg = 1; @@ -788,7 +799,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) dsi = dcfg->decoderSpecificInfo->data; dcfg->decoderSpecificInfo->data = NULL; dsi_size = dcfg->decoderSpecificInfo->dataLength; - if (add_ext) + if (add_ext) strcat(szName, ".aac"); is_aac = 1; aac_type = dcfg->objectTypeIndication - GPAC_OTI_AUDIO_AAC_MPEG2_MP; @@ -804,25 +815,26 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) dcfg->decoderSpecificInfo->data = NULL; dsi_size = dcfg->decoderSpecificInfo->dataLength; is_aac = 2; - if (add_ext) + if (add_ext) strcat(szName, ".aac"); gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AAC"); break; case GPAC_OTI_AUDIO_MPEG2_PART3: case GPAC_OTI_AUDIO_MPEG1: - if (add_ext) + if (add_ext) strcat(szName, ".mp3"); gf_export_message(dumper, GF_OK, "Extracting MPEG-1/2 Audio (MP3)"); break; case GPAC_OTI_MEDIA_OGG: - if (add_ext) + if (add_ext) strcat(szName, ".ogg"); is_ogg = 1; gf_export_message(dumper, GF_OK, "Extracting Ogg audio"); break; case GPAC_OTI_AUDIO_13K_VOICE: - if (add_ext) - strcat(szName, ".qcp"); qcp_type = 1; + if (add_ext) + strcat(szName, ".qcp"); + qcp_type = 1; memcpy(GUID, QCP_QCELP_GUID_1, sizeof(char)*16); gf_export_message(dumper, GF_OK, "Extracting QCELP-13K (QCP file)"); break; @@ -836,15 +848,15 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) memcpy(GUID, QCP_SMV_GUID, sizeof(char)*16); if (dumper->flags & GF_EXPORT_PROBE_ONLY) dumper->flags |= GF_EXPORT_USE_QCP; break; - case 0xD1: + case 0xD1: if (dcfg->decoderSpecificInfo && (dcfg->decoderSpecificInfo->dataLength==8) - && !strnicmp(dcfg->decoderSpecificInfo->data, "pvmm", 4)) { + && !strnicmp(dcfg->decoderSpecificInfo->data, "pvmm", 4)) { qcp_type = 3; memcpy(GUID, QCP_EVRC_GUID, sizeof(char)*16); if (dumper->flags & GF_EXPORT_PROBE_ONLY) dumper->flags |= GF_EXPORT_USE_QCP; break; } - /*fall through*/ + /*fall through*/ default: gf_odf_desc_del((GF_Descriptor *) dcfg); return gf_export_message(dumper, GF_NOT_SUPPORTED, "Unknown audio in track ID %d - use NHNT", dumper->trackID); @@ -858,7 +870,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) dsi = dcfg->decoderSpecificInfo->data; dcfg->decoderSpecificInfo->data = NULL; dsi_size = dcfg->decoderSpecificInfo->dataLength; - if (add_ext) + if (add_ext) strcat(szName, ".idx"); gf_export_message(dumper, GF_OK, "Extracting NeroDigital VobSub subpicture stream"); break; @@ -874,16 +886,17 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) gf_odf_desc_del((GF_Descriptor *) dcfg); } else { if (m_stype==GF_ISOM_SUBTYPE_3GP_AMR) { - if (add_ext) + if (add_ext) strcat(szName, ".amr"); gf_export_message(dumper, GF_OK, "Extracting AMR Audio"); } else if (m_stype==GF_ISOM_SUBTYPE_3GP_AMR_WB) { - if (add_ext) + if (add_ext) strcat(szName, ".awb"); gf_export_message(dumper, GF_OK, "Extracting AMR WideBand Audio"); } else if (m_stype==GF_ISOM_SUBTYPE_3GP_QCELP) { - if (add_ext) - strcat(szName, ".qcp"); qcp_type = 1; + if (add_ext) + strcat(szName, ".qcp"); + qcp_type = 1; memcpy(GUID, QCP_QCELP_GUID_1, sizeof(char)*16); gf_export_message(dumper, GF_OK, "Extracting QCELP-13K (QCP file)"); } else if (m_stype==GF_ISOM_SUBTYPE_3GP_EVRC) { @@ -896,48 +909,48 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) if (dumper->flags & GF_EXPORT_PROBE_ONLY) dumper->flags |= GF_EXPORT_USE_QCP; } else if (m_stype==GF_ISOM_SUBTYPE_3GP_H263) { gf_export_message(dumper, GF_OK, "Extracting H263 Video"); - if (add_ext) + if (add_ext) strcat(szName, ".263"); } else if (m_stype==GF_4CC('x','d','v','b')) { gf_export_message(dumper, GF_OK, "Extracting MPEG-2 Video"); - if (add_ext) + if (add_ext) strcat(szName, ".m2v"); } else if (m_stype==GF_ISOM_SUBTYPE_3GP_DIMS) { return gf_media_export_nhml(dumper, 1); - } else if ((m_stype==GF_ISOM_SUBTYPE_AVC_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC2_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC3_H264) - || (m_stype==GF_ISOM_SUBTYPE_AVC4_H264) - || (m_stype==GF_ISOM_SUBTYPE_SVC_H264) - ) { + } else if ((m_stype==GF_ISOM_SUBTYPE_AVC_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC2_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC3_H264) + || (m_stype==GF_ISOM_SUBTYPE_AVC4_H264) + || (m_stype==GF_ISOM_SUBTYPE_SVC_H264) + ) { avccfg = gf_isom_avc_config_get(dumper->file, track, 1); svccfg = gf_isom_svc_config_get(dumper->file, track, 1); - if (add_ext) + if (add_ext) strcat(szName, ".h264"); gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AVC-H264 stream to h264"); - } else if ((m_stype==GF_ISOM_SUBTYPE_HEV1) - || (m_stype==GF_ISOM_SUBTYPE_HVC1) - || (m_stype==GF_ISOM_SUBTYPE_HVC2) - || (m_stype==GF_ISOM_SUBTYPE_HEV2) - || (m_stype==GF_ISOM_SUBTYPE_SHC1) - || (m_stype==GF_ISOM_SUBTYPE_SHV1) - ) { + } else if ((m_stype==GF_ISOM_SUBTYPE_HEV1) + || (m_stype==GF_ISOM_SUBTYPE_HVC1) + || (m_stype==GF_ISOM_SUBTYPE_HVC2) + || (m_stype==GF_ISOM_SUBTYPE_HEV2) + || (m_stype==GF_ISOM_SUBTYPE_SHC1) + || (m_stype==GF_ISOM_SUBTYPE_SHV1) + ) { hevccfg = gf_isom_hevc_config_get(dumper->file, track, 1); shvccfg = gf_isom_shvc_config_get(dumper->file, track, 1); - if (add_ext) + if (add_ext) strcat(szName, ".hvc"); gf_export_message(dumper, GF_OK, "Extracting MPEG-H HEVC stream to hevc"); } else if (m_type==GF_ISOM_MEDIA_FLASH) { gf_export_message(dumper, GF_OK, "Extracting Macromedia Flash Movie"); - if (add_ext) + if (add_ext) strcat(szName, ".swf"); } else if (m_stype==GF_ISOM_SUBTYPE_AC3) { gf_export_message(dumper, GF_OK, "Extracting AC3 Audio"); - if (add_ext) + if (add_ext) strcat(szName, ".ac3"); } else if (m_stype==GF_ISOM_SUBTYPE_WVTT) { gf_export_message(dumper, GF_OK, "Extracting WebVTT"); - is_webvtt = GF_TRUE; + is_webvtt = GF_TRUE; strcat(szName, ".vtt"); } else if (m_stype==GF_ISOM_SUBTYPE_STSE) { gf_export_message(dumper, GF_OK, "Extracting Simple Text"); @@ -949,12 +962,17 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) } udesc = gf_isom_get_generic_sample_description(dumper->file, track, 1); if (udesc) { - dsi = udesc->extension_buf; udesc->extension_buf = NULL; + dsi = udesc->extension_buf; + udesc->extension_buf = NULL; dsi_size = udesc->extension_buf_size; } switch (m_type) { - case GF_ISOM_MEDIA_VISUAL: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Video - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); break; - case GF_ISOM_MEDIA_AUDIO: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Audio - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); break; + case GF_ISOM_MEDIA_VISUAL: + gf_export_message(dumper, GF_OK, "Extracting \'%s\' Video - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); + break; + case GF_ISOM_MEDIA_AUDIO: + gf_export_message(dumper, GF_OK, "Extracting \'%s\' Audio - Compressor %s", szEXT, udesc ? udesc->compressor_name : "Unknown"); + break; default: gf_export_message(dumper, GF_OK, "Extracting \'%s\' Track (type '%s') - Compressor %s", szEXT, gf_4cc_to_str(m_type), udesc ? udesc->compressor_name : "Unknown"); break; @@ -979,24 +997,24 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) if (is_webvtt) { #ifndef GPAC_DISABLE_TTXT - GF_Err gf_webvtt_dump_iso_track(GF_MediaExporter *dumper, char *szName, u32 track, Bool merge); - return gf_webvtt_dump_iso_track(dumper, szName, track, (dumper->flags & GF_EXPORT_WEBVTT_NOMERGE? GF_FALSE : GF_TRUE)); + GF_Err gf_webvtt_dump_iso_track(GF_MediaExporter *dumper, char *szName, u32 track, Bool merge); + return gf_webvtt_dump_iso_track(dumper, szName, track, (dumper->flags & GF_EXPORT_WEBVTT_NOMERGE? GF_FALSE : GF_TRUE)); #else - return GF_NOT_SUPPORTED; + return GF_NOT_SUPPORTED; #endif - } + } - if (qcp_type>1) { + if (qcp_type>1) { if (dumper->flags & GF_EXPORT_USE_QCP) { - if (add_ext) + if (add_ext) strcat(szName, ".qcp"); gf_export_message(dumper, GF_OK, "Extracting %s audio (QCP file)", (qcp_type==2) ? "SMV" : "EVRC"); } else if (qcp_type==2) { - if (add_ext) + if (add_ext) strcat(szName, ".smv"); gf_export_message(dumper, GF_OK, "Extracting SMV audio"); } else { - if (add_ext) + if (add_ext) strcat(szName, ".evc"); gf_export_message(dumper, GF_OK, "Extracting EVRC audio"); } @@ -1037,7 +1055,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) gf_bs_write_u32(bs, 1); \ gf_bs_write_data(bs, sl->data, sl->size); \ } \ - + #define DUMP_HEVCPARAM(_params) \ count = gf_list_count(_params->param_array); \ for (i=0;idata, sl->size); \ } \ } \ - + if (avccfg) { DUMP_AVCPARAM(avccfg->sequenceParameterSets); @@ -1244,7 +1262,7 @@ GF_Err gf_media_export_native(GF_MediaExporter *dumper) remain = samp->dataLength; while (remain) { nal_size = 0; - if (remaindataLength, nal_unit_size, remain) ); break; } @@ -1301,7 +1319,7 @@ exit: if (hevccfg) gf_odf_hevc_cfg_del(hevccfg); if (shvccfg) gf_odf_hevc_cfg_del(shvccfg); gf_bs_del(bs); - if (!is_stdout) + if (!is_stdout) fclose(out); return e; #endif /*GPAC_DISABLE_AV_PARSERS*/ @@ -1315,7 +1333,7 @@ static GF_Err gf_media_export_avi_track(GF_MediaExporter *dumper) u32 max_size, tot_size, num_samples, i; s32 size; char *comp, *frame; - char szOutFile[1024]; + char szOutFile[1024]; avi_t *in; FILE *fout; @@ -1328,16 +1346,16 @@ static GF_Err gf_media_export_avi_track(GF_MediaExporter *dumper) Bool key; comp = AVI_video_compressor(in); if (!stricmp(comp, "DIVX") || !stricmp(comp, "DX50") /*DivX*/ - || !stricmp(comp, "XVID") /*XviD*/ - || !stricmp(comp, "3iv2") /*3ivX*/ - || !stricmp(comp, "fvfw") /*ffmpeg*/ - || !stricmp(comp, "NDIG") /*nero*/ - || !stricmp(comp, "MP4V") /*!! not tested*/ - || !stricmp(comp, "M4CC") /*Divio - not tested*/ - || !stricmp(comp, "PVMM") /*PacketVideo - not tested*/ - || !stricmp(comp, "SEDG") /*Samsung - not tested*/ - || !stricmp(comp, "RMP4") /*Sigma - not tested*/ - ) { + || !stricmp(comp, "XVID") /*XviD*/ + || !stricmp(comp, "3iv2") /*3ivX*/ + || !stricmp(comp, "fvfw") /*ffmpeg*/ + || !stricmp(comp, "NDIG") /*nero*/ + || !stricmp(comp, "MP4V") /*!! not tested*/ + || !stricmp(comp, "M4CC") /*Divio - not tested*/ + || !stricmp(comp, "PVMM") /*PacketVideo - not tested*/ + || !stricmp(comp, "SEDG") /*Samsung - not tested*/ + || !stricmp(comp, "RMP4") /*Sigma - not tested*/ + ) { sprintf(szOutFile, "%s.cmp", dumper->out_name); } else if (!stricmp(comp, "VSSH") || strstr(comp, "264")) { sprintf(szOutFile, "%s.h264", dumper->out_name); @@ -1350,7 +1368,7 @@ static GF_Err gf_media_export_avi_track(GF_MediaExporter *dumper) is_stdout = 1; else if (strrchr(dumper->out_name, '.')) { strcpy(szOutFile, dumper->out_name); - } + } fout = is_stdout ? stdout : gf_f64_open(szOutFile, "wb"); @@ -1389,22 +1407,54 @@ static GF_Err gf_media_export_avi_track(GF_MediaExporter *dumper) AVI_set_audio_position(in, 0); switch (in->track[in->aptr].a_fmt) { - case WAVE_FORMAT_PCM: comp = "pcm"; break; - case WAVE_FORMAT_ADPCM: comp = "adpcm"; break; - case WAVE_FORMAT_IBM_CVSD: comp = "cvsd"; break; - case WAVE_FORMAT_ALAW: comp = "alaw"; break; - case WAVE_FORMAT_MULAW: comp = "mulaw"; break; - case WAVE_FORMAT_OKI_ADPCM: comp = "oki_adpcm"; break; - case WAVE_FORMAT_DVI_ADPCM: comp = "dvi_adpcm"; break; - case WAVE_FORMAT_DIGISTD: comp = "digistd"; break; - case WAVE_FORMAT_YAMAHA_ADPCM: comp = "yam_adpcm"; break; - case WAVE_FORMAT_DSP_TRUESPEECH: comp = "truespeech"; break; - case WAVE_FORMAT_GSM610: comp = "gsm610"; break; - case IBM_FORMAT_MULAW: comp = "ibm_mulaw"; break; - case IBM_FORMAT_ALAW: comp = "ibm_alaw"; break; - case IBM_FORMAT_ADPCM: comp = "ibm_adpcm"; break; - case 0x55: comp = "mp3"; break; - default: comp = "raw"; break; + case WAVE_FORMAT_PCM: + comp = "pcm"; + break; + case WAVE_FORMAT_ADPCM: + comp = "adpcm"; + break; + case WAVE_FORMAT_IBM_CVSD: + comp = "cvsd"; + break; + case WAVE_FORMAT_ALAW: + comp = "alaw"; + break; + case WAVE_FORMAT_MULAW: + comp = "mulaw"; + break; + case WAVE_FORMAT_OKI_ADPCM: + comp = "oki_adpcm"; + break; + case WAVE_FORMAT_DVI_ADPCM: + comp = "dvi_adpcm"; + break; + case WAVE_FORMAT_DIGISTD: + comp = "digistd"; + break; + case WAVE_FORMAT_YAMAHA_ADPCM: + comp = "yam_adpcm"; + break; + case WAVE_FORMAT_DSP_TRUESPEECH: + comp = "truespeech"; + break; + case WAVE_FORMAT_GSM610: + comp = "gsm610"; + break; + case IBM_FORMAT_MULAW: + comp = "ibm_mulaw"; + break; + case IBM_FORMAT_ALAW: + comp = "ibm_alaw"; + break; + case IBM_FORMAT_ADPCM: + comp = "ibm_adpcm"; + break; + case 0x55: + comp = "mp3"; + break; + default: + comp = "raw"; + break; } sprintf(szOutFile, "%s.%s", dumper->out_name, comp); gf_export_message(dumper, GF_OK, "Extracting AVI %s audio", comp); @@ -1413,7 +1463,7 @@ static GF_Err gf_media_export_avi_track(GF_MediaExporter *dumper) is_stdout = 1; } else if (strrchr(dumper->out_name, '.')) { strcpy(szOutFile, dumper->out_name); - } + } fout = is_stdout ? stdout : gf_f64_open(szOutFile, "wb"); num_samples = 0; @@ -1511,7 +1561,7 @@ GF_Err gf_media_export_nhnt(GF_MediaExporter *dumper) GF_ISOSample *samp = gf_isom_get_sample(dumper->file, track, i+1, &di); if (!samp) break; gf_fwrite(samp->data, samp->dataLength, 1, out_med); - + /*dump nhnt info*/ gf_bs_write_u24(bs, samp->dataLength); gf_bs_write_int(bs, samp->IsRAP, 1); @@ -1610,7 +1660,7 @@ static GF_Err MP4T_CopyTrack(GF_MediaExporter *dumper, GF_ISOFile *infile, u32 i pos = 0; rate = 0; ts = gf_isom_get_media_timescale(infile, inTrackNum); - count = gf_isom_get_sample_count(infile, inTrackNum); + count = gf_isom_get_sample_count(infile, inTrackNum); for (i=0; iout_name, '.')) { strcpy(szName, dumper->out_name); - } else { + } else { ext = (char *) gf_isom_get_filename(dumper->file); if (ext) ext = strrchr(ext, '.'); sprintf(szName, "%s%s", dumper->out_name, ext ? ext : ".mp4"); @@ -1789,13 +1839,13 @@ GF_Err gf_media_export_avi(GF_MediaExporter *dumper) esd = gf_isom_get_esd(dumper->file, track, 1); if (!esd) return gf_export_message(dumper, GF_NON_COMPLIANT_BITSTREAM, "Invalid MPEG-4 stream in track ID %d", dumper->trackID); - if ((esd->decoderConfig->streamType!=GF_STREAM_VISUAL) || - ( (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_MPEG4_PART2) - && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_AVC) - && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_SVC) - && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_HEVC) - && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_SHVC) - ) ) { + if ((esd->decoderConfig->streamType!=GF_STREAM_VISUAL) || + ( (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_MPEG4_PART2) + && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_AVC) + && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_SVC) + && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_HEVC) + && (esd->decoderConfig->objectTypeIndication!=GPAC_OTI_VIDEO_SHVC) + ) ) { gf_odf_desc_del((GF_Descriptor*)esd); return gf_export_message(dumper, GF_NON_COMPLIANT_BITSTREAM, "Track ID %d is not MPEG-4 Visual - cannot extract to AVI", dumper->trackID); } @@ -1826,15 +1876,15 @@ GF_Err gf_media_export_avi(GF_MediaExporter *dumper) frame_d = 0; /*AVC - FIXME dump format is probably wrong...*/ - if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)){ + if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)) { gf_isom_get_visual_info(dumper->file, track, 1, &w, &h); v4CC = "h264"; - } + } /*HEVC - FIXME dump format is probably wrong...*/ - else if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_HEVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SHVC)){ + else if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_HEVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SHVC)) { gf_isom_get_visual_info(dumper->file, track, 1, &w, &h); v4CC = "hevc"; - } + } /*MPEG4*/ else { #ifndef GPAC_DISABLE_AV_PARSERS @@ -1982,7 +2032,7 @@ GF_Err gf_media_export_nhml(GF_MediaExporter *dumper, Bool dims_doc) if (mtype==GF_ISOM_MEDIA_VISUAL) { fprintf(nhml, "codecVendor=\"%s\" codecVersion=\"%d\" codecRevision=\"%d\" ", gf_4cc_to_str(sdesc->vendor_code), sdesc->version, sdesc->revision); fprintf(nhml, "width=\"%d\" height=\"%d\" compressorName=\"%s\" temporalQuality=\"%d\" spatialQuality=\"%d\" horizontalResolution=\"%d\" verticalResolution=\"%d\" bitDepth=\"%d\" ", - sdesc->width, sdesc->height, sdesc->compressor_name, sdesc->temporal_quality, sdesc->spatial_quality, sdesc->h_res, sdesc->v_res, sdesc->depth); + sdesc->width, sdesc->height, sdesc->compressor_name, sdesc->temporal_quality, sdesc->spatial_quality, sdesc->h_res, sdesc->v_res, sdesc->depth); } else if (mtype==GF_ISOM_MEDIA_AUDIO) { fprintf(nhml, "codecVendor=\"%s\" codecVersion=\"%d\" codecRevision=\"%d\" ", gf_4cc_to_str(sdesc->vendor_code), sdesc->version, sdesc->revision); fprintf(nhml, "sampleRate=\"%d\" numChannels=\"%d\" bitsPerSample=\"%d\" ", sdesc->samplerate, sdesc->nb_channels, sdesc->bits_per_sample); @@ -2001,7 +2051,7 @@ GF_Err gf_media_export_nhml(GF_MediaExporter *dumper, Bool dims_doc) if (gf_isom_is_track_in_root_od(dumper->file, track)) fprintf(nhml, "inRootOD=\"yes\" "); fprintf(nhml, "trackID=\"%d\" ", dumper->trackID); - + uncompress = 0; if (mstype == GF_ISOM_MEDIA_DIMS) { @@ -2024,8 +2074,8 @@ GF_Err gf_media_export_nhml(GF_MediaExporter *dumper, Bool dims_doc) } else { fprintf(nhml, "baseMediaFile=\"%s\" ", szMedia); } - - + + fprintf(nhml, ">\n"); @@ -2046,7 +2096,7 @@ GF_Err gf_media_export_nhml(GF_MediaExporter *dumper, Bool dims_doc) u16 size = gf_bs_read_u16(bs); u8 flags = gf_bs_read_u8(bs); u8 prev; - + if (pos+size+2>samp->dataLength) break; @@ -2103,7 +2153,7 @@ GF_Err gf_media_export_nhml(GF_MediaExporter *dumper, Bool dims_doc) gf_fwrite(samp->data+pos+3, size-1, 1, nhml); } fprintf(nhml, "\n"); - + samp->data[pos+2+size] = prev; gf_bs_skip_bytes(bs, size-1); } @@ -2143,7 +2193,7 @@ GF_Err gf_media_export_webvtt_metadata(GF_MediaExporter *dumper) u32 w, h; u32 track, i, di, count, pos; u32 mtype, mstype; - Bool isText; + Bool isText; char *mime = NULL; Bool useBase64 = GF_FALSE; u32 headerLength = 0; @@ -2198,9 +2248,9 @@ GF_Err gf_media_export_webvtt_metadata(GF_MediaExporter *dumper) const char *handler; gf_isom_get_handler_name(dumper->file, track, &handler); fprintf(vtt, "label: %s\n", handler); - } + } if (gf_isom_is_track_in_root_od(dumper->file, track)) fprintf(vtt, "inRootOD: yes\n"); - fprintf(vtt, "trackID: %d\n", dumper->trackID); + fprintf(vtt, "trackID: %d\n", dumper->trackID); if (med) { fprintf(vtt, "baseMediaFile: %s\n", szMedia); } @@ -2256,7 +2306,7 @@ GF_Err gf_media_export_webvtt_metadata(GF_MediaExporter *dumper) } } else #endif - { + { char b64[200]; u32 size = gf_base64_encode(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, b64, 200); useBase64 = GF_TRUE; @@ -2401,21 +2451,21 @@ GF_Err gf_media_export_six(GF_MediaExporter *dumper) sprintf(szName, "%s.six", dumper->out_name); szRootName = "stream"; - + six = gf_f64_open(szName, "wt"); if (!six) { fclose(media); if (esd) gf_odf_desc_del((GF_Descriptor *) esd); return gf_export_message(dumper, GF_IO_ERR, "Error opening %s for writing - check disk access & permissions", szName); } -/* - mtype = gf_isom_get_media_type(dumper->file, track); - if (mtype==GF_ISOM_MEDIA_TEXT || mtype == GF_ISOM_MEDIA_SUBM || mtype == GF_ISOM_MEDIA_SUBT) { - isText = GF_TRUE; - } else { - isText = GF_FALSE; - } -*/ + /* + mtype = gf_isom_get_media_type(dumper->file, track); + if (mtype==GF_ISOM_MEDIA_TEXT || mtype == GF_ISOM_MEDIA_SUBM || mtype == GF_ISOM_MEDIA_SUBT) { + isText = GF_TRUE; + } else { + isText = GF_FALSE; + } + */ mstype = gf_isom_get_media_subtype(dumper->file, track, 1); /*write header*/ @@ -2428,13 +2478,13 @@ GF_Err gf_media_export_six(GF_MediaExporter *dumper) if (esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data) { #ifndef GPAC_DISABLE_TTXT if (mstype == GF_ISOM_SUBTYPE_WVTT || mstype == GF_ISOM_SUBTYPE_STSE) { - gf_webvtt_dump_header_boxed(media, - esd->decoderConfig->decoderSpecificInfo->data+4, - esd->decoderConfig->decoderSpecificInfo->dataLength, - &header_size); + gf_webvtt_dump_header_boxed(media, + esd->decoderConfig->decoderSpecificInfo->data+4, + esd->decoderConfig->decoderSpecificInfo->dataLength, + &header_size); } else #endif - { + { gf_fwrite(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, 1, media); header_size = esd->decoderConfig->decoderSpecificInfo->dataLength; } @@ -2478,7 +2528,7 @@ GF_Err gf_media_export_six(GF_MediaExporter *dumper) } -typedef struct +typedef struct { u32 track_num, stream_id, last_sample, nb_samp; } SAFInfo; @@ -2525,12 +2575,24 @@ GF_Err gf_media_export_saf(GF_MediaExporter *dumper) } else { char *mime = NULL; switch (gf_isom_get_media_subtype(dumper->file, i+1, 1)) { - case GF_ISOM_SUBTYPE_3GP_H263: mime = "video/h263"; break; - case GF_ISOM_SUBTYPE_3GP_AMR: mime = "audio/amr"; break; - case GF_ISOM_SUBTYPE_3GP_AMR_WB: mime = "audio/amr-wb"; break; - case GF_ISOM_SUBTYPE_3GP_EVRC: mime = "audio/evrc"; break; - case GF_ISOM_SUBTYPE_3GP_QCELP: mime = "audio/qcelp"; break; - case GF_ISOM_SUBTYPE_3GP_SMV: mime = "audio/smv"; break; + case GF_ISOM_SUBTYPE_3GP_H263: + mime = "video/h263"; + break; + case GF_ISOM_SUBTYPE_3GP_AMR: + mime = "audio/amr"; + break; + case GF_ISOM_SUBTYPE_3GP_AMR_WB: + mime = "audio/amr-wb"; + break; + case GF_ISOM_SUBTYPE_3GP_EVRC: + mime = "audio/evrc"; + break; + case GF_ISOM_SUBTYPE_3GP_QCELP: + mime = "audio/qcelp"; + break; + case GF_ISOM_SUBTYPE_3GP_SMV: + mime = "audio/smv"; + break; } if (!mime) continue; stream_id = gf_isom_get_track_id(dumper->file, i+1); @@ -2580,7 +2642,7 @@ GF_Err gf_media_export_saf(GF_MediaExporter *dumper) } gf_set_progress("SAF Export", samp_done, tot_samp); if (dumper->flags & GF_EXPORT_DO_ABORT) break; - } + } gf_saf_mux_for_time(mux, (u32) -1, 1, &data, &size); if (data) { gf_fwrite(data, size, 1, saf_f); @@ -2598,13 +2660,13 @@ GF_Err gf_media_export_saf(GF_MediaExporter *dumper) #ifndef GPAC_DISABLE_MPEG2TS -void m2ts_export_check(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +void m2ts_export_check(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { // if (evt_type == GF_M2TS_EVT_PAT_REPEAT) ts->user = NULL; if (evt_type == GF_M2TS_EVT_PMT_REPEAT) ts->user = NULL; else if (evt_type == GF_M2TS_EVT_PAT_FOUND) ts->segment_switch = 1; } -void m2ts_export_dump(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) +void m2ts_export_dump(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) { if (evt_type == GF_M2TS_EVT_PES_PCK) { FILE *dst = (FILE*)ts->user; @@ -2629,7 +2691,7 @@ GF_Err gf_media_export_ts_native(GF_MediaExporter *dumper) FILE *src, *dst; if (dumper->flags & GF_EXPORT_PROBE_ONLY) return GF_OK; - + src = gf_f64_open(dumper->in_name, "rb"); if (!src) return gf_export_message(dumper, GF_CODEC_NOT_FOUND, "Error opening %s", dumper->in_name); @@ -2761,7 +2823,7 @@ GF_Err gf_media_export(GF_MediaExporter *dumper) { if (!dumper) return GF_BAD_PARAM; if (!dumper->out_name && !(dumper->flags & GF_EXPORT_PROBE_ONLY)) return GF_BAD_PARAM; - + if (dumper->flags & GF_EXPORT_NATIVE) { #ifndef GPAC_DISABLE_MPEG2TS if (dumper->in_name) { diff --git a/src/media_tools/media_import.c b/src/media_tools/media_import.c index f6ccfe6..beda643 100644 --- a/src/media_tools/media_import.c +++ b/src/media_tools/media_import.c @@ -70,8 +70,8 @@ static GF_Err gf_media_update_par(GF_ISOFile *file, u32 track) stype = gf_isom_get_media_subtype(file, track, 1); if ((stype==GF_ISOM_SUBTYPE_AVC_H264) || (stype==GF_ISOM_SUBTYPE_AVC2_H264) - || (stype==GF_ISOM_SUBTYPE_AVC3_H264) || (stype==GF_ISOM_SUBTYPE_AVC4_H264) - ) { + || (stype==GF_ISOM_SUBTYPE_AVC3_H264) || (stype==GF_ISOM_SUBTYPE_AVC4_H264) + ) { s32 par_n, par_d; GF_AVCConfig *avcc = gf_isom_avc_config_get(file, track, 1); GF_AVCConfigSlot *slc = (GF_AVCConfigSlot *)gf_list_get(avcc->sequenceParameterSets, 0); @@ -118,7 +118,7 @@ static void MP4T_RecomputeBitRate(GF_ISOFile *file, u32 track) esd->decoderConfig->avgBitrate = 0; esd->decoderConfig->maxBitrate = 0; rate = max_rate = avg_rate = time_wnd = 0; - + timescale = gf_isom_get_media_timescale(file, track); count = gf_isom_get_sample_count(file, track); for (i=0; idest, import->esd->ESID); if (!track) track = gf_isom_new_track(import->dest, import->esd->ESID, GF_ISOM_MEDIA_VISUAL, 1000); @@ -357,7 +357,7 @@ static GF_Err gf_import_afx_sc3dmc(GF_MediaImporter *import, Bool mult_desc_allo track = 0; - if (mult_desc_allowed) + if (mult_desc_allowed) track = gf_isom_get_track_by_id(import->dest, import->esd->ESID); if (!track) track = gf_isom_new_track(import->dest, import->esd->ESID, GF_ISOM_MEDIA_SCENE, 1000); @@ -639,7 +639,7 @@ static Bool LOAS_LoadFrame(GF_BitStream *bs, GF_M4ADecSpecInfo *acfg, u32 *nb_by for (i=0; i<=numProgram; i++) { u32 j, num_lay; num_lay = gf_bs_read_int(bs, 3); - for (j=0;j<=num_lay; j++) { + for (j=0; j<=num_lay; j++) { u32 frameLengthType; Bool same_cfg = 0; if (i || j) same_cfg = gf_bs_read_int(bs, 1); @@ -783,7 +783,7 @@ GF_Err gf_import_aac_loas(GF_MediaImporter *import) samp->IsRAP = 1; samp->dataLength = nbbytes; samp->data = (char *) aac_buf; - + e = gf_isom_add_sample(import->dest, track, di, samp); if (e) goto exit; samp->DTS+=dts_inc; @@ -899,7 +899,7 @@ GF_Err gf_import_aac_adts(GF_MediaImporter *import) } } - if (import->flags & GF_IMPORT_OVSBR) + if (import->flags & GF_IMPORT_OVSBR) timescale = 2*sr; if (import->flags & GF_IMPORT_PS_EXPLICIT) { @@ -953,7 +953,7 @@ GF_Err gf_import_aac_adts(GF_MediaImporter *import) gf_bs_write_int(dsi, hdr.nb_ch, 4); gf_bs_write_int(dsi, sbr_sr ? sbr_sr_idx : hdr.sr_idx, 4); gf_bs_write_int(dsi, hdr.profile, 5); - } + } /*explicit SBR signal (non backward-compatible)*/ else if (import->flags & GF_IMPORT_SBR_EXPLICIT) { gf_bs_write_int(dsi, 5, 5); @@ -1003,13 +1003,13 @@ GF_Err gf_import_aac_adts(GF_MediaImporter *import) samp = NULL; gf_import_message(import, GF_OK, "AAC ADTS import %s%s%s- sample rate %d - %s audio - %d channel%s", - (import->flags & (GF_IMPORT_SBR_IMPLICIT|GF_IMPORT_SBR_EXPLICIT)) ? "SBR" : "", - (import->flags & (GF_IMPORT_PS_IMPLICIT|GF_IMPORT_PS_EXPLICIT)) ? "+PS" : "", - ((import->flags & (GF_IMPORT_SBR_EXPLICIT|GF_IMPORT_PS_EXPLICIT)) ? " (explicit) " : " "), - sr, - (oti==0x40) ? "MPEG-4" : "MPEG-2", - hdr.nb_ch, - (hdr.nb_ch>1) ? "s" : ""); + (import->flags & (GF_IMPORT_SBR_IMPLICIT|GF_IMPORT_SBR_EXPLICIT)) ? "SBR" : "", + (import->flags & (GF_IMPORT_PS_IMPLICIT|GF_IMPORT_PS_EXPLICIT)) ? "+PS" : "", + ((import->flags & (GF_IMPORT_SBR_EXPLICIT|GF_IMPORT_PS_EXPLICIT)) ? " (explicit) " : " "), + sr, + (oti==0x40) ? "MPEG-4" : "MPEG-2", + hdr.nb_ch, + (hdr.nb_ch>1) ? "s" : ""); track = gf_isom_new_track(import->dest, import->esd->ESID, GF_ISOM_MEDIA_AUDIO, timescale); if (!track) { @@ -1430,18 +1430,18 @@ static GF_Err gf_import_avi_video(GF_MediaImporter *import) /*these are/should be OK*/ if (!stricmp(comp, "DIVX") || !stricmp(comp, "DX50") /*DivX*/ - || !stricmp(comp, "XVID") /*XviD*/ - || !stricmp(comp, "3iv2") /*3ivX*/ - || !stricmp(comp, "fvfw") /*ffmpeg*/ - || !stricmp(comp, "NDIG") /*nero*/ - || !stricmp(comp, "MP4V") /*!! not tested*/ - || !stricmp(comp, "M4CC") /*Divio - not tested*/ - || !stricmp(comp, "PVMM") /*PacketVideo - not tested*/ - || !stricmp(comp, "SEDG") /*Samsung - not tested*/ - || !stricmp(comp, "RMP4") /*Sigma - not tested*/ - || !stricmp(comp, "MP43") /*not tested*/ - || !stricmp(comp, "FMP4") /*not tested*/ - ) { + || !stricmp(comp, "XVID") /*XviD*/ + || !stricmp(comp, "3iv2") /*3ivX*/ + || !stricmp(comp, "fvfw") /*ffmpeg*/ + || !stricmp(comp, "NDIG") /*nero*/ + || !stricmp(comp, "MP4V") /*!! not tested*/ + || !stricmp(comp, "M4CC") /*Divio - not tested*/ + || !stricmp(comp, "PVMM") /*PacketVideo - not tested*/ + || !stricmp(comp, "SEDG") /*Samsung - not tested*/ + || !stricmp(comp, "RMP4") /*Sigma - not tested*/ + || !stricmp(comp, "MP43") /*not tested*/ + || !stricmp(comp, "FMP4") /*not tested*/ + ) { e = GF_OK; } else if (!stricmp(comp, "DIV3") || !stricmp(comp, "DIV4")) { @@ -2021,7 +2021,7 @@ GF_Err gf_import_isomedia(GF_MediaImporter *import) gf_import_message(import, GF_OK, "IsoMedia import %s - track ID %d - Audio (SR %d - %d channels)", orig_name, trackID, sr, ch); } } - break; + break; case GF_ISOM_MEDIA_SUBPIC: gf_import_message(import, GF_OK, "IsoMedia import %s - track ID %d - VobSub (size %d x %d)", orig_name, trackID, w, h); break; @@ -2033,7 +2033,7 @@ GF_Err gf_import_isomedia(GF_MediaImporter *import) strcpy(szT, gf_4cc_to_str(mtype)); gf_import_message(import, GF_OK, "IsoMedia import %s - track ID %d - media type \"%s:%s\"", orig_name, trackID, szT, gf_4cc_to_str(mstype)); } - break; + break; } //this may happen with fragmented files @@ -2203,10 +2203,18 @@ GF_Err gf_import_mpeg_ps_video(GF_MediaImporter *import) import->tk_info[import->nb_tracks].track_num = nb_v_str + i+1; import->tk_info[import->nb_tracks].type = GF_ISOM_MEDIA_AUDIO; switch (mpeg2ps_get_audio_stream_type(ps, i)) { - case MPEG_AUDIO_MPEG: import->tk_info[import->nb_tracks].media_type = GF_4CC('M','P','G','A'); break; - case MPEG_AUDIO_AC3: import->tk_info[import->nb_tracks].media_type = GF_4CC('A','C','3',' '); break; - case MPEG_AUDIO_LPCM: import->tk_info[import->nb_tracks].media_type = GF_4CC('L','P','C','M'); break; - default: import->tk_info[import->nb_tracks].media_type = GF_4CC('U','N','K',' '); break; + case MPEG_AUDIO_MPEG: + import->tk_info[import->nb_tracks].media_type = GF_4CC('M','P','G','A'); + break; + case MPEG_AUDIO_AC3: + import->tk_info[import->nb_tracks].media_type = GF_4CC('A','C','3',' '); + break; + case MPEG_AUDIO_LPCM: + import->tk_info[import->nb_tracks].media_type = GF_4CC('L','P','C','M'); + break; + default: + import->tk_info[import->nb_tracks].media_type = GF_4CC('U','N','K',' '); + break; } import->tk_info[import->nb_tracks].audio_info.sample_rate = mpeg2ps_get_audio_stream_sample_freq(ps, i); import->tk_info[import->nb_tracks].audio_info.nb_channels = mpeg2ps_get_audio_stream_channels(ps, i); @@ -2499,9 +2507,9 @@ GF_Err gf_import_nhnt(GF_MediaImporter *import) import->esd->decoderConfig->decoderSpecificInfo->dataLength = (u32) gf_f64_tell(info); import->esd->decoderConfig->decoderSpecificInfo->data = (char*)gf_malloc(sizeof(char) * import->esd->decoderConfig->decoderSpecificInfo->dataLength); gf_f64_seek(info, 0, SEEK_SET); - if (0==fread(import->esd->decoderConfig->decoderSpecificInfo->data, 1, import->esd->decoderConfig->decoderSpecificInfo->dataLength, info)){ + if (0==fread(import->esd->decoderConfig->decoderSpecificInfo->data, 1, import->esd->decoderConfig->decoderSpecificInfo->dataLength, info)) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, - ("[NHML import] Failed to read dataLength\n")); + ("[NHML import] Failed to read dataLength\n")); } fclose(info); } @@ -2646,7 +2654,7 @@ GF_Err gf_import_nhnt(GF_MediaImporter *import) max_size = samp->dataLength; } gf_f64_seek(mdia, offset, SEEK_SET); - if (0==fread( samp->data, 1, samp->dataLength, mdia)){ + if (0==fread( samp->data, 1, samp->dataLength, mdia)) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("Failed to read samp->dataLength\n")); } if (is_start) { @@ -2804,7 +2812,7 @@ GF_Err gf_import_sample_from_xml(GF_MediaImporter *import, GF_ISOSample *samp, c samp->data = (char*)gf_realloc(samp->data, sizeof(char)*samp->dataLength); } gf_f64_seek(xml, breaker.from_pos, SEEK_SET); - if (0==fread(samp->data, 1, samp->dataLength, xml)){ + if (0==fread(samp->data, 1, samp->dataLength, xml)) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("Failed to read samp->dataLength\n")); } @@ -2896,7 +2904,7 @@ static void nhml_on_progress(void *cbk, u64 done, u64 tot) else if (strstr(att->value, "0X")) { u32 __i; sscanf(att->value+2, "%X", &__i); _value = __i; }\ else sscanf(att->value, _fmt, &_value); \ }\ - + /*FIXME - need LARGE FILE support in NHNT - add a new version*/ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) @@ -2979,81 +2987,81 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) i=0; while ((att = (GF_XMLAttribute *)gf_list_enum(root->attributes, &i))) { if (!stricmp(att->name, "streamType")) NHML_SCAN_INT("%u", streamType) - else if (!stricmp(att->name, "mediaType") && (strlen(att->value)==4)) { - mtype = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); - } - else if (!stricmp(att->name, "mediaSubType") && (strlen(att->value)==4)) { - sdesc.codec_tag = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); - } - else if (!stricmp(att->name, "objectTypeIndication")) NHML_SCAN_INT("%u", oti) - else if (!stricmp(att->name, "timeScale")) NHML_SCAN_INT("%u", timescale) - else if (!stricmp(att->name, "width")) NHML_SCAN_INT("%hu", sdesc.width) - else if (!stricmp(att->name, "height")) NHML_SCAN_INT("%hu", sdesc.height) - else if (!stricmp(att->name, "parNum")) NHML_SCAN_INT("%u", par_num) - else if (!stricmp(att->name, "parDen")) NHML_SCAN_INT("%u", par_den) - else if (!stricmp(att->name, "sampleRate")) NHML_SCAN_INT("%u", sdesc.samplerate) - else if (!stricmp(att->name, "numChannels")) NHML_SCAN_INT("%hu", sdesc.nb_channels) - else if (!stricmp(att->name, "baseMediaFile")) strcpy(szMedia, att->value); - else if (!stricmp(att->name, "specificInfoFile")) strcpy(szInfo, att->value); - else if (!stricmp(att->name, "trackID")) NHML_SCAN_INT("%u", tkID) - else if (!stricmp(att->name, "inRootOD")) inRootOD = (!stricmp(att->value, "yes") ); - else if (!stricmp(att->name, "DTS_increment")) NHML_SCAN_INT("%u", dts_inc) - else if (!stricmp(att->name, "gzipSamples")) do_compress = (!stricmp(att->value, "yes")) ? 1 : 0; - else if (!stricmp(att->name, "gzipDictionary")) { - u64 d_size; - if (stricmp(att->value, "self")) { - FILE *d = gf_f64_open(att->value, "rb"); - if (!d) { - gf_import_message(import, GF_IO_ERR, "Cannot open dictionary file %s", att->value); - continue; - } - gf_f64_seek(d, 0, SEEK_END); - d_size = gf_f64_tell(d); - dictionary = (char*)gf_malloc(sizeof(char)*(size_t)(d_size+1)); - gf_f64_seek(d, 0, SEEK_SET); - d_size = fread(dictionary, sizeof(char), (size_t)d_size, d); - dictionary[d_size]=0; - } - use_dict = 1; - } + else if (!stricmp(att->name, "mediaType") && (strlen(att->value)==4)) { + mtype = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); + } + else if (!stricmp(att->name, "mediaSubType") && (strlen(att->value)==4)) { + sdesc.codec_tag = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); + } + else if (!stricmp(att->name, "objectTypeIndication")) NHML_SCAN_INT("%u", oti) + else if (!stricmp(att->name, "timeScale")) NHML_SCAN_INT("%u", timescale) + else if (!stricmp(att->name, "width")) NHML_SCAN_INT("%hu", sdesc.width) + else if (!stricmp(att->name, "height")) NHML_SCAN_INT("%hu", sdesc.height) + else if (!stricmp(att->name, "parNum")) NHML_SCAN_INT("%u", par_num) + else if (!stricmp(att->name, "parDen")) NHML_SCAN_INT("%u", par_den) + else if (!stricmp(att->name, "sampleRate")) NHML_SCAN_INT("%u", sdesc.samplerate) + else if (!stricmp(att->name, "numChannels")) NHML_SCAN_INT("%hu", sdesc.nb_channels) + else if (!stricmp(att->name, "baseMediaFile")) strcpy(szMedia, att->value); + else if (!stricmp(att->name, "specificInfoFile")) strcpy(szInfo, att->value); + else if (!stricmp(att->name, "trackID")) NHML_SCAN_INT("%u", tkID) + else if (!stricmp(att->name, "inRootOD")) inRootOD = (!stricmp(att->value, "yes") ); + else if (!stricmp(att->name, "DTS_increment")) NHML_SCAN_INT("%u", dts_inc) + else if (!stricmp(att->name, "gzipSamples")) do_compress = (!stricmp(att->value, "yes")) ? 1 : 0; + else if (!stricmp(att->name, "gzipDictionary")) { + u64 d_size; + if (stricmp(att->value, "self")) { + FILE *d = gf_f64_open(att->value, "rb"); + if (!d) { + gf_import_message(import, GF_IO_ERR, "Cannot open dictionary file %s", att->value); + continue; + } + gf_f64_seek(d, 0, SEEK_END); + d_size = gf_f64_tell(d); + dictionary = (char*)gf_malloc(sizeof(char)*(size_t)(d_size+1)); + gf_f64_seek(d, 0, SEEK_SET); + d_size = fread(dictionary, sizeof(char), (size_t)d_size, d); + dictionary[d_size]=0; + } + use_dict = 1; + } /*unknow desc related*/ - else if (!stricmp(att->name, "compressorName")) strcpy(sdesc.compressor_name, att->value); - else if (!stricmp(att->name, "codecVersion")) NHML_SCAN_INT("%hu", sdesc.version) - else if (!stricmp(att->name, "codecRevision")) NHML_SCAN_INT("%hu", sdesc.revision) - else if (!stricmp(att->name, "codecVendor") && (strlen(att->value)==4)) { - sdesc.vendor_code = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); - } - else if (!stricmp(att->name, "temporalQuality")) NHML_SCAN_INT("%u", sdesc.temporal_quality) - else if (!stricmp(att->name, "spatialQuality")) NHML_SCAN_INT("%u", sdesc.spatial_quality) - else if (!stricmp(att->name, "horizontalResolution")) NHML_SCAN_INT("%u", sdesc.h_res) - else if (!stricmp(att->name, "verticalResolution")) NHML_SCAN_INT("%u", sdesc.v_res) - else if (!stricmp(att->name, "bitDepth")) NHML_SCAN_INT("%hu", sdesc.depth) - else if (!stricmp(att->name, "bitsPerSample")) NHML_SCAN_INT("%hu", sdesc.bits_per_sample) - - /*DIMS stuff*/ - else if (!stricmp(att->name, "profile")) NHML_SCAN_INT("%c", dims.profile) - else if (!stricmp(att->name, "level")) NHML_SCAN_INT("%c", dims.level) - else if (!stricmp(att->name, "pathComponents")) NHML_SCAN_INT("%c", dims.pathComponents) - else if (!stricmp(att->name, "useFullRequestHost") && !stricmp(att->value, "yes")) dims.fullRequestHost = 1; - else if (!stricmp(att->name, "stream_type") && !stricmp(att->value, "secondary")) dims.streamType = 0; - else if (!stricmp(att->name, "contains_redundant")) { - if (!stricmp(att->value, "main")) dims.containsRedundant = 1; - else if (!stricmp(att->value, "redundant")) dims.containsRedundant = 2; - else if (!stricmp(att->value, "main+redundant")) dims.containsRedundant = 3; - } - else if (!stricmp(att->name, "text_encoding")) dims.textEncoding = att->value; - else if (!stricmp(att->name, "content_encoding")) { - if (!strcmp(att->value, "deflate")) { - dims.contentEncoding = att->value; - do_compress = 1; - } - } - else if (!stricmp(att->name, "content_script_types")) dims.content_script_types = att->value; - else if (!stricmp(att->name, "mime_type")) dims.mime_type = att->value; - else if (!stricmp(att->name, "media_namespace")) dims.mime_type = att->value; - else if (!stricmp(att->name, "media_schema_location")) dims.xml_schema_loc = att->value; - else if (!stricmp(att->name, "xml_namespace")) dims.contentEncoding = att->value; - else if (!stricmp(att->name, "xml_schema_location")) dims.xml_schema_loc = att->value; + else if (!stricmp(att->name, "compressorName")) strcpy(sdesc.compressor_name, att->value); + else if (!stricmp(att->name, "codecVersion")) NHML_SCAN_INT("%hu", sdesc.version) + else if (!stricmp(att->name, "codecRevision")) NHML_SCAN_INT("%hu", sdesc.revision) + else if (!stricmp(att->name, "codecVendor") && (strlen(att->value)==4)) { + sdesc.vendor_code = GF_4CC(att->value[0], att->value[1], att->value[2], att->value[3]); + } + else if (!stricmp(att->name, "temporalQuality")) NHML_SCAN_INT("%u", sdesc.temporal_quality) + else if (!stricmp(att->name, "spatialQuality")) NHML_SCAN_INT("%u", sdesc.spatial_quality) + else if (!stricmp(att->name, "horizontalResolution")) NHML_SCAN_INT("%u", sdesc.h_res) + else if (!stricmp(att->name, "verticalResolution")) NHML_SCAN_INT("%u", sdesc.v_res) + else if (!stricmp(att->name, "bitDepth")) NHML_SCAN_INT("%hu", sdesc.depth) + else if (!stricmp(att->name, "bitsPerSample")) NHML_SCAN_INT("%hu", sdesc.bits_per_sample) + + /*DIMS stuff*/ + else if (!stricmp(att->name, "profile")) NHML_SCAN_INT("%c", dims.profile) + else if (!stricmp(att->name, "level")) NHML_SCAN_INT("%c", dims.level) + else if (!stricmp(att->name, "pathComponents")) NHML_SCAN_INT("%c", dims.pathComponents) + else if (!stricmp(att->name, "useFullRequestHost") && !stricmp(att->value, "yes")) dims.fullRequestHost = 1; + else if (!stricmp(att->name, "stream_type") && !stricmp(att->value, "secondary")) dims.streamType = 0; + else if (!stricmp(att->name, "contains_redundant")) { + if (!stricmp(att->value, "main")) dims.containsRedundant = 1; + else if (!stricmp(att->value, "redundant")) dims.containsRedundant = 2; + else if (!stricmp(att->value, "main+redundant")) dims.containsRedundant = 3; + } + else if (!stricmp(att->name, "text_encoding")) dims.textEncoding = att->value; + else if (!stricmp(att->name, "content_encoding")) { + if (!strcmp(att->value, "deflate")) { + dims.contentEncoding = att->value; + do_compress = 1; + } + } + else if (!stricmp(att->name, "content_script_types")) dims.content_script_types = att->value; + else if (!stricmp(att->name, "mime_type")) dims.mime_type = att->value; + else if (!stricmp(att->name, "media_namespace")) dims.mime_type = att->value; + else if (!stricmp(att->name, "media_schema_location")) dims.xml_schema_loc = att->value; + else if (!stricmp(att->name, "xml_namespace")) dims.contentEncoding = att->value; + else if (!stricmp(att->name, "xml_schema_location")) dims.xml_schema_loc = att->value; } if (sdesc.samplerate && !timescale) timescale = sdesc.samplerate; @@ -3122,7 +3130,9 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) switch (import->esd->decoderConfig->streamType) { - case GF_STREAM_SCENE: mtype = GF_ISOM_MEDIA_SCENE; break; + case GF_STREAM_SCENE: + mtype = GF_ISOM_MEDIA_SCENE; + break; case GF_STREAM_VISUAL: mtype = GF_ISOM_MEDIA_VISUAL; #ifndef GPAC_DISABLE_AV_PARSERS @@ -3144,18 +3154,35 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) if (!sdesc.samplerate) sdesc.samplerate = 44100; if (!sdesc.nb_channels) sdesc.nb_channels = 2; break; - case GF_STREAM_MPEG7: mtype = GF_ISOM_MEDIA_MPEG7; break; - case GF_STREAM_IPMP: mtype = GF_ISOM_MEDIA_IPMP; break; - case GF_STREAM_OCI: mtype = GF_ISOM_MEDIA_OCI; break; - case GF_STREAM_MPEGJ: mtype = GF_ISOM_MEDIA_MPEGJ; break; + case GF_STREAM_MPEG7: + mtype = GF_ISOM_MEDIA_MPEG7; + break; + case GF_STREAM_IPMP: + mtype = GF_ISOM_MEDIA_IPMP; + break; + case GF_STREAM_OCI: + mtype = GF_ISOM_MEDIA_OCI; + break; + case GF_STREAM_MPEGJ: + mtype = GF_ISOM_MEDIA_MPEGJ; + break; /*note we cannot import OD from NHNT*/ - case GF_STREAM_OD: e = GF_NOT_SUPPORTED; goto exit; - case GF_STREAM_INTERACT: mtype = GF_ISOM_MEDIA_SCENE; break; - default: if (!mtype) mtype = GF_ISOM_MEDIA_ESM; break; + case GF_STREAM_OD: + e = GF_NOT_SUPPORTED; + goto exit; + case GF_STREAM_INTERACT: + mtype = GF_ISOM_MEDIA_SCENE; + break; + default: + if (!mtype) mtype = GF_ISOM_MEDIA_ESM; + break; } track = gf_isom_new_track(import->dest, import->esd->ESID, mtype, timescale); - if (!track) { e = gf_isom_last_error(import->dest); goto exit; } + if (!track) { + e = gf_isom_last_error(import->dest); + goto exit; + } e = gf_isom_new_mpeg4_description(import->dest, track, import->esd, (import->flags & GF_IMPORT_USE_DATAREF) ? szMedia : NULL, NULL, &di); if (e) goto exit; @@ -3163,27 +3190,36 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) } else if (is_dims) { track = gf_isom_new_track(import->dest, tkID, mtype, timescale); - if (!track) { e = gf_isom_last_error(import->dest); goto exit; } + if (!track) { + e = gf_isom_last_error(import->dest); + goto exit; + } e = gf_isom_new_dims_description(import->dest, track, &dims, NULL, NULL, &di); if (e) goto exit; gf_import_message(import, GF_OK, "3GPP DIMS import"); - } else if (mtype == GF_ISOM_MEDIA_MPEG_SUBT) { + } else if (mtype == GF_ISOM_MEDIA_MPEG_SUBT) { track = gf_isom_new_track(import->dest, tkID, mtype, timescale); - if (!track) { e = gf_isom_last_error(import->dest); goto exit; } - e = gf_isom_new_xml_subtitle_description(import->dest, track, - (char *)dims.contentEncoding, (char *)dims.xml_schema_loc, (char *)dims.mime_type, - &di); + if (!track) { + e = gf_isom_last_error(import->dest); + goto exit; + } + e = gf_isom_new_xml_subtitle_description(import->dest, track, + (char *)dims.contentEncoding, (char *)dims.xml_schema_loc, (char *)dims.mime_type, + &di); if (e) goto exit; - } else { + } else { char szT[5]; sdesc.extension_buf = specInfo; sdesc.extension_buf_size = specInfoSize; if (!sdesc.vendor_code) sdesc.vendor_code = GF_4CC('G', 'P', 'A', 'C'); track = gf_isom_new_track(import->dest, tkID, mtype, timescale); - if (!track) { e = gf_isom_last_error(import->dest); goto exit; } + if (!track) { + e = gf_isom_last_error(import->dest); + goto exit; + } e = gf_isom_new_generic_sample_description(import->dest, track, (import->flags & GF_IMPORT_USE_DATAREF) ? szMedia : NULL, NULL, &sdesc, &di); if (e) goto exit; @@ -3332,7 +3368,7 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) if (samp->data) gf_free(samp->data ); samp->data = 0; samp->dataLength = 0; - e = gf_xml_parse_bit_sequence(node, &samp->data, &samp->dataLength); + e = gf_xml_parse_bit_sequence(node, &samp->data, &samp->dataLength); max_size = samp->dataLength; } else { Bool close = 0; @@ -3367,7 +3403,7 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) bs = gf_bs_new(samp->data, samp->dataLength+3, GF_BITSTREAM_WRITE); gf_bs_write_u16(bs, samp->dataLength+1); gf_bs_write_u8(bs, (u8) dims_flags); - if (samp->dataLength != fread( samp->data+3, sizeof(char), samp->dataLength, f)){ + if (samp->dataLength != fread( samp->data+3, sizeof(char), samp->dataLength, f)) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[NHML import dims] Failed to fully read samp->dataLength\n")); } gf_bs_del(bs); @@ -3381,7 +3417,7 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) samp->data = (char*)gf_realloc(samp->data, sizeof(char) * samp->dataLength); max_size = samp->dataLength; } - if (samp->dataLength != fread( samp->data, sizeof(char), samp->dataLength, f)){ + if (samp->dataLength != fread( samp->data, sizeof(char), samp->dataLength, f)) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[NHML import dims] Failed to fully read samp->dataLength\n")); } } @@ -3426,7 +3462,7 @@ GF_Err gf_import_nhml_dims(GF_MediaImporter *import, Bool dims_doc) if (e) goto exit; samp->IsRAP = 0; samp->CTS_Offset = 0; - if (sample_duration) + if (sample_duration) samp->DTS += sample_duration; else samp->DTS += dts_inc; @@ -3491,10 +3527,10 @@ GF_Err gf_import_amr_evrc_smv(GF_MediaImporter *import) oti = mtype = 0; sample_rate = 8000; block_size = 160; - if (6 > fread(magic, sizeof(char), 20, mdia)){ + if (6 > fread(magic, sizeof(char), 20, mdia)) { fclose(mdia); return gf_import_message(import, GF_URL_ERROR, "Cannot guess type for file %s, size lower than 6", import->in_name); - + } if (!strnicmp(magic, "#!AMR\n", 6)) { gf_import_message(import, GF_OK, "Importing AMR Audio"); @@ -3536,9 +3572,24 @@ GF_Err gf_import_amr_evrc_smv(GF_MediaImporter *import) } else { char *ext = strrchr(import->in_name, '.'); - if (ext && !stricmp(ext, ".amr")) { mtype = GF_ISOM_SUBTYPE_3GP_AMR; update_gpp_cfg = 1; ext = "AMR"; msg = "Importing AMR";} - else if (ext && !stricmp(ext, ".evc")) { mtype = GF_ISOM_SUBTYPE_3GP_EVRC; oti = GPAC_OTI_AUDIO_EVRC_VOICE; ext = "EVRC"; msg = "Importing EVRC";} - else if (ext && !stricmp(ext, ".smv")) { mtype = GF_ISOM_SUBTYPE_3GP_SMV; oti = GPAC_OTI_AUDIO_SMV_VOICE; ext = "SMV"; msg = "Importing SMV";} + if (ext && !stricmp(ext, ".amr")) { + mtype = GF_ISOM_SUBTYPE_3GP_AMR; + update_gpp_cfg = 1; + ext = "AMR"; + msg = "Importing AMR"; + } + else if (ext && !stricmp(ext, ".evc")) { + mtype = GF_ISOM_SUBTYPE_3GP_EVRC; + oti = GPAC_OTI_AUDIO_EVRC_VOICE; + ext = "EVRC"; + msg = "Importing EVRC"; + } + else if (ext && !stricmp(ext, ".smv")) { + mtype = GF_ISOM_SUBTYPE_3GP_SMV; + oti = GPAC_OTI_AUDIO_SMV_VOICE; + ext = "SMV"; + msg = "Importing SMV"; + } else { fclose(mdia); return gf_import_message(import, GF_NON_COMPLIANT_BITSTREAM, "Corrupted AMR/SMV/EVRC file header"); @@ -3638,7 +3689,7 @@ GF_Err gf_import_amr_evrc_smv(GF_MediaImporter *import) break; } - if (samp->dataLength){ + if (samp->dataLength) { readen = (u32) fread( samp->data + 1, sizeof(char), samp->dataLength, mdia); assert(readen == samp->dataLength); } @@ -3887,7 +3938,10 @@ GF_Err gf_import_qcp(GF_MediaImporter *import) idx = gf_bs_read_u8(bs); chunk_size-=1; for (i=0; idataLength = size+1; } else { @@ -3997,12 +4051,29 @@ u32 H263_NextStartCode(GF_BitStream *bs) static void h263_get_pic_size(GF_BitStream *bs, u32 fmt, u32 *w, u32 *h) { switch (fmt) { - case 1: *w = 128; *h = 96; break; - case 2: *w = 176; *h = 144; break; - case 3: *w = 352; *h = 288; break; - case 4: *w = 704; *h = 576; break; - case 5: *w = 1409; *h = 1152 ; break; - default: *w = *h = 0; break; + case 1: + *w = 128; + *h = 96; + break; + case 2: + *w = 176; + *h = 144; + break; + case 3: + *w = 352; + *h = 288; + break; + case 4: + *w = 704; + *h = 576; + break; + case 5: + *w = 1409; + *h = 1152 ; + break; + default: + *w = *h = 0; + break; } } @@ -4139,11 +4210,11 @@ GF_Err gf_media_avc_rewrite_samples(GF_ISOFile *file, u32 track, u32 prev_size, { u32 i, count, di, remain, msize; char *buffer; - + msize = 4096; buffer = (char*)gf_malloc(sizeof(char)*msize); count = gf_isom_get_sample_count(file, track); - for (i=0; idata, samp->dataLength, GF_BITSTREAM_READ); GF_BitStream *newbs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); @@ -4320,7 +4391,7 @@ restart_import: skip_nal = 0; copy_size = flush_sample = 0; - if (nal_type == GF_AVC_NALU_SVC_SUBSEQ_PARAM || nal_type == GF_AVC_NALU_SVC_PREFIX_NALU || nal_type == GF_AVC_NALU_SVC_SLICE){ + if (nal_type == GF_AVC_NALU_SVC_SUBSEQ_PARAM || nal_type == GF_AVC_NALU_SVC_PREFIX_NALU || nal_type == GF_AVC_NALU_SVC_SLICE) { avc.is_svc = 1; } @@ -4397,11 +4468,11 @@ restart_import: gf_list_add(dstcfg->sequenceParameterSets, slc); /*disable frame rate scan, most bitstreams have wrong values there*/ if (detect_fps && avc.sps[idx].vui.timing_info_present_flag && avc.sps[idx].vui.fixed_frame_rate_flag - /*if detected FPS is greater than 1000, assume wrong timing info*/ - && (avc.sps[idx].vui.time_scale <= 1000*avc.sps[idx].vui.num_units_in_tick) - ) { + /*if detected FPS is greater than 1000, assume wrong timing info*/ + && (avc.sps[idx].vui.time_scale <= 1000*avc.sps[idx].vui.num_units_in_tick) + ) { /*ISO/IEC 14496-10 n11084 Table E-6*/ -/* not used : u8 DeltaTfiDivisorTable[] = {1,1,1,2,2,2,2,3,3,4,6}; */ + /* not used : u8 DeltaTfiDivisorTable[] = {1,1,1,2,2,2,2,3,3,4,6}; */ u8 DeltaTfiDivisorIdx; if (!avc.sps[idx].vui.pic_struct_present_flag) { DeltaTfiDivisorIdx = 1 + (1-avc.s_info.field_pic_flag); @@ -4480,7 +4551,7 @@ restart_import: memcpy(slc->data, buffer, sizeof(char)*slc->size); dstcfg = (import->flags & GF_IMPORT_SVC_EXPLICIT) ? svccfg : avccfg; - /* by default, we put all PPS in the base AVC layer, + /* by default, we put all PPS in the base AVC layer, they will be moved to the SVC layer upon analysis of SVC slice. */ dstcfg = avccfg; @@ -4506,13 +4577,27 @@ restart_import: if (! skip_nal) { copy_size = nal_size; switch (avc.s_info.slice_type) { - case GF_AVC_TYPE_P: case GF_AVC_TYPE2_P: nb_p++; break; - case GF_AVC_TYPE_I: case GF_AVC_TYPE2_I: nb_i++; + case GF_AVC_TYPE_P: + case GF_AVC_TYPE2_P: + nb_p++; + break; + case GF_AVC_TYPE_I: + case GF_AVC_TYPE2_I: + nb_i++; sample_has_islice = 1; break; - case GF_AVC_TYPE_B: case GF_AVC_TYPE2_B: nb_b++; break; - case GF_AVC_TYPE_SP: case GF_AVC_TYPE2_SP: nb_sp++; break; - case GF_AVC_TYPE_SI: case GF_AVC_TYPE2_SI: nb_si++; break; + case GF_AVC_TYPE_B: + case GF_AVC_TYPE2_B: + nb_b++; + break; + case GF_AVC_TYPE_SP: + case GF_AVC_TYPE2_SP: + nb_sp++; + break; + case GF_AVC_TYPE_SI: + case GF_AVC_TYPE2_SI: + nb_si++; + break; } } break; @@ -4533,32 +4618,41 @@ restart_import: copy_size = nal_size; break; case GF_AVC_NALU_SVC_SLICE: - { - u32 i; - for (i = 0; i < gf_list_count(avccfg->pictureParameterSets); i ++) { - slc = gf_list_get(avccfg->pictureParameterSets, i); - if (avc.s_info.pps->id == slc->id) { - /* This PPS is used by an SVC NAL unit, it should be moved to the SVC Config Record) */ - gf_list_rem(avccfg->pictureParameterSets, i); - i--; - gf_list_add(svccfg->pictureParameterSets, slc); - } - } - } - if (import->flags & GF_IMPORT_SVC_NONE) { - skip_nal = 0; - copy_size = 0; - break; - } - if (! skip_nal) { - copy_size = nal_size; - switch (avc.s_info.slice_type) { - case GF_AVC_TYPE_P: case GF_AVC_TYPE2_P: avc.s_info.sps->nb_ep++; break; - case GF_AVC_TYPE_I: case GF_AVC_TYPE2_I: avc.s_info.sps->nb_ei++; break; - case GF_AVC_TYPE_B: case GF_AVC_TYPE2_B: avc.s_info.sps->nb_eb++; break; + { + u32 i; + for (i = 0; i < gf_list_count(avccfg->pictureParameterSets); i ++) { + slc = gf_list_get(avccfg->pictureParameterSets, i); + if (avc.s_info.pps->id == slc->id) { + /* This PPS is used by an SVC NAL unit, it should be moved to the SVC Config Record) */ + gf_list_rem(avccfg->pictureParameterSets, i); + i--; + gf_list_add(svccfg->pictureParameterSets, slc); } } + } + if (import->flags & GF_IMPORT_SVC_NONE) { + skip_nal = 0; + copy_size = 0; break; + } + if (! skip_nal) { + copy_size = nal_size; + switch (avc.s_info.slice_type) { + case GF_AVC_TYPE_P: + case GF_AVC_TYPE2_P: + avc.s_info.sps->nb_ep++; + break; + case GF_AVC_TYPE_I: + case GF_AVC_TYPE2_I: + avc.s_info.sps->nb_ei++; + break; + case GF_AVC_TYPE_B: + case GF_AVC_TYPE2_B: + avc.s_info.sps->nb_eb++; + break; + } + } + break; case GF_AVC_NALU_SEQ_PARAM_EXT: idx = gf_media_avc_read_sps_ext(buffer, nal_size); @@ -4622,8 +4716,8 @@ restart_import: nb_subs = gf_isom_sample_has_subsamples(import->dest, track, cur_samp+1); if (nb_subs) { /* fetch size, priority, reserved and discardable info for last subsample */ - gf_isom_sample_get_subsample(import->dest, track, cur_samp+1, nb_subs, &size, &priority, &reserved, &discardable); - + gf_isom_sample_get_subsample(import->dest, track, cur_samp+1, nb_subs, &size, &priority, &reserved, &discardable); + /*remove last subsample entry!*/ gf_isom_add_subsample(import->dest, track, cur_samp+1, 0, 0, 0, 0); } @@ -4655,7 +4749,7 @@ restart_import: if (sei_recovery_frame_count) { if (!use_opengop_gdr) use_opengop_gdr = 1; e = gf_isom_set_sample_roll_group(import->dest, track, cur_samp, (s16) sei_recovery_frame_count); - } + } /*open-GOP*/ else if (sample_has_islice) { if (!use_opengop_gdr) use_opengop_gdr = 2; @@ -4728,7 +4822,7 @@ restart_import: // priority_id (6 bits) in SVC has inverse meaning -> lower value means higher priority - invert it and scale it to 8 bits prio = (63 - (p[1] & 0x3F)) << 2; - + if (set_subsamples) { gf_isom_add_subsample(import->dest, track, cur_samp+1, copy_size+size_length/8, prio, res, 1); } @@ -4766,7 +4860,7 @@ restart_import: is_paff = 1; slice_is_ref = (avc.s_info.nal_unit_type==GF_AVC_NALU_IDR_SLICE); - if (slice_is_ref) + if (slice_is_ref) nb_idr++; slice_force_ref = 0; @@ -4789,7 +4883,7 @@ restart_import: } } avc.sei.recovery_point.valid = 0; - if (bIntraSlice && (import->flags & GF_IMPORT_FORCE_SYNC) && (sei_recovery_frame_count==0)) + if (bIntraSlice && (import->flags & GF_IMPORT_FORCE_SYNC) && (sei_recovery_frame_count==0)) slice_force_ref = 1; } sample_is_rap = gf_media_avc_slice_is_IDR(&avc); @@ -4826,7 +4920,7 @@ restart_import: } /*forced ref slice*/ else if (slice_force_ref) { - ref_frame = cur_samp+1; + ref_frame = cur_samp+1; /*adjust POC shift as sample will now be marked as sync, so wo must store poc as if IDR (eg POC=0) for our CTS offset computing to be correct*/ poc_shift = avc.s_info.poc; } @@ -4887,7 +4981,7 @@ restart_import: } nal_start = gf_bs_get_position(bs); } - + /*final flush*/ if (sample_data) { GF_ISOSample *samp = gf_isom_sample_new(); @@ -4994,7 +5088,7 @@ restart_import: if (gf_list_count(avccfg->sequenceParameterSets) || !gf_list_count(svccfg->sequenceParameterSets) ) { gf_isom_avc_config_update(import->dest, track, 1, avccfg); if (gf_list_count(svccfg->sequenceParameterSets)) { - gf_isom_svc_config_update(import->dest, track, 1, svccfg, 1); + gf_isom_svc_config_update(import->dest, track, 1, svccfg, 1); } } else { gf_isom_svc_config_update(import->dest, track, 1, svccfg, 0); @@ -5011,10 +5105,10 @@ restart_import: u32 i; if (nb_sp || nb_si) { gf_import_message(import, GF_OK, "AVC Import results: %d samples - Slices: %d I %d P %d B %d SP %d SI - %d SEI - %d IDR", - cur_samp, nb_i, nb_p, nb_b, nb_sp, nb_si, nb_sei, nb_idr); + cur_samp, nb_i, nb_p, nb_b, nb_sp, nb_si, nb_sei, nb_idr); } else { gf_import_message(import, GF_OK, "AVC Import results: %d samples - Slices: %d I %d P %d B - %d SEI - %d IDR", - cur_samp, nb_i, nb_p, nb_b, nb_sei, nb_idr); + cur_samp, nb_i, nb_p, nb_b, nb_sei, nb_idr); } for (i=0; isequenceParameterSets); i++) { @@ -5057,7 +5151,7 @@ exit: } #ifndef GPAC_DISABLE_HEVC -static GF_HEVCParamArray *get_hevc_param_array(GF_HEVCConfig *hevc_cfg, u8 type) +static GF_HEVCParamArray *get_hevc_param_array(GF_HEVCConfig *hevc_cfg, u8 type) { u32 i, count = hevc_cfg->param_array ? gf_list_count(hevc_cfg->param_array) : 0; for (i=0; inalus); - + memset(&hevc, 0, sizeof(HEVCState)); hevc.sps_active_idx = -1; @@ -5157,7 +5251,7 @@ static GF_Err gf_import_hevc(GF_MediaImporter *import) } else { /*fps is forced by the caller*/ detect_fps = GF_FALSE; - } + } } get_video_timing(FPS, ×cale, &dts_inc); @@ -5259,13 +5353,13 @@ restart_import: if (layer_id && (import->flags & GF_IMPORT_SVC_NONE)) { goto next_nal; } - + prev_cfg = dst_cfg; //todo check layer type, for now only scalable (not 3D etc) ... if (import->flags & GF_IMPORT_SVC_EXPLICIT) { dst_cfg = shvc_cfg; force_shvc = 1; - } else + } else dst_cfg = layer_id ? shvc_cfg : hevc_cfg; if (prev_cfg != dst_cfg) { @@ -5399,10 +5493,10 @@ restart_import: gf_list_add(spss->nalus, slc); /*disable frame rate scan, most bitstreams have wrong values there*/ - if (detect_fps && hevc.sps[idx].has_timing_info - /*if detected FPS is greater than 1000, assume wrong timing info*/ - && (hevc.sps[idx].time_scale <= 1000*hevc.sps[idx].num_units_in_tick) - ) { + if (detect_fps && hevc.sps[idx].has_timing_info + /*if detected FPS is greater than 1000, assume wrong timing info*/ + && (hevc.sps[idx].time_scale <= 1000*hevc.sps[idx].num_units_in_tick) + ) { timescale = hevc.sps[idx].time_scale; dts_inc = hevc.sps[idx].num_units_in_tick; FPS = (Double)timescale / dts_inc; @@ -5455,7 +5549,7 @@ restart_import: if (hevc.pps[idx].state==1) { hevc.pps[idx].state = 2; hevc.pps[idx].crc = gf_crc_32(buffer, nal_size); - + if (!ppss) { GF_SAFEALLOC(ppss, GF_HEVCParamArray); ppss->nalus = gf_list_new(); @@ -5489,7 +5583,7 @@ restart_import: case GF_HEVC_NALU_SLICE_STSA_N: case GF_HEVC_NALU_SLICE_STSA_R: case GF_HEVC_NALU_SLICE_RADL_R: - case GF_HEVC_NALU_SLICE_RASL_R: + case GF_HEVC_NALU_SLICE_RASL_R: case GF_HEVC_NALU_SLICE_RADL_N: case GF_HEVC_NALU_SLICE_RASL_N: case GF_HEVC_NALU_SLICE_TRAIL_N: @@ -5503,20 +5597,25 @@ restart_import: case GF_HEVC_NALU_SLICE_IDR_N_LP: case GF_HEVC_NALU_SLICE_CRA: is_slice = 1; -/* if ((hevc.s_info.slice_segment_address<=100) || (hevc.s_info.slice_segment_address>=200)) - skip_nal = 1; - if (!hevc.s_info.slice_segment_address) - skip_nal = 0; -*/ + /* if ((hevc.s_info.slice_segment_address<=100) || (hevc.s_info.slice_segment_address>=200)) + skip_nal = 1; + if (!hevc.s_info.slice_segment_address) + skip_nal = 0; + */ if (! skip_nal) { copy_size = nal_size; has_vcl_nal = 1; switch (hevc.s_info.slice_type) { - case GF_HEVC_TYPE_P: nb_p++; break; - case GF_HEVC_TYPE_I: nb_i++; + case GF_HEVC_TYPE_P: + nb_p++; + break; + case GF_HEVC_TYPE_I: + nb_i++; sample_has_islice = 1; break; - case GF_HEVC_TYPE_B: nb_b++; break; + case GF_HEVC_TYPE_B: + nb_b++; + break; } } break; @@ -5571,7 +5670,7 @@ restart_import: if (sei_recovery_frame_count) { if (!use_opengop_gdr) use_opengop_gdr = 1; e = gf_isom_set_sample_roll_group(import->dest, track, cur_samp, (s16) sei_recovery_frame_count); - } + } /*open-GOP*/ else if (sample_has_islice) { if (!use_opengop_gdr) use_opengop_gdr = 2; @@ -5644,7 +5743,7 @@ restart_import: //fixme with latest SHVC syntax if (!layer_id && is_slice) { slice_is_ref = gf_media_hevc_slice_is_IDR(&hevc); - if (slice_is_ref) + if (slice_is_ref) nb_idr++; slice_force_ref = 0; @@ -5667,7 +5766,7 @@ restart_import: } } hevc.sei.recovery_point.valid = 0; - if (bIntraSlice && (import->flags & GF_IMPORT_FORCE_SYNC) && (sei_recovery_frame_count==0)) + if (bIntraSlice && (import->flags & GF_IMPORT_FORCE_SYNC) && (sei_recovery_frame_count==0)) slice_force_ref = 1; } sample_is_rap = gf_media_hevc_slice_is_IDR(&hevc); @@ -5704,7 +5803,7 @@ restart_import: } /*forced ref slice*/ else if (slice_force_ref) { - ref_frame = cur_samp+1; + ref_frame = cur_samp+1; /*adjust POC shift as sample will now be marked as sync, so wo must store poc as if IDR (eg POC=0) for our CTS offset computing to be correct*/ poc_shift = hevc.s_info.poc; } @@ -5766,7 +5865,7 @@ next_nal: } nal_start = gf_bs_get_position(bs); } - + /*final flush*/ if (sample_data) { GF_ISOSample *samp = gf_isom_sample_new(); @@ -5871,7 +5970,7 @@ next_nal: shvc_cfg->num_layers = 0; for (i=1; i<64; i++) { - if (layer_ids[i]) + if (layer_ids[i]) shvc_cfg->num_layers ++; } @@ -5906,10 +6005,10 @@ next_nal: } else { if (nb_sp || nb_si) { gf_import_message(import, GF_OK, "HEVC Import results: %d samples - Slices: %d I %d P %d B %d SP %d SI - %d SEI - %d IDR", - cur_samp, nb_i, nb_p, nb_b, nb_sp, nb_si, nb_sei, nb_idr); + cur_samp, nb_i, nb_p, nb_b, nb_sp, nb_si, nb_sei, nb_idr); } else { gf_import_message(import, GF_OK, "HEVC Import results: %d samples - Slices: %d I %d P %d B - %d SEI - %d IDR", - cur_samp, nb_i, nb_p, nb_b, nb_sei, nb_idr); + cur_samp, nb_i, nb_p, nb_b, nb_sei, nb_idr); } if (max_total_delay>1) { @@ -6460,20 +6559,43 @@ GF_Err gf_import_raw_unit(GF_MediaImporter *import) if (!src) return gf_import_message(import, GF_URL_ERROR, "Opening file %s failed", import->in_name); switch (import->esd->decoderConfig->streamType) { - case GF_STREAM_SCENE: mtype = GF_ISOM_MEDIA_SCENE; break; - case GF_STREAM_VISUAL: mtype = GF_ISOM_MEDIA_VISUAL; break; - case GF_STREAM_AUDIO: mtype = GF_ISOM_MEDIA_AUDIO; break; - case GF_STREAM_TEXT: mtype = GF_ISOM_MEDIA_TEXT; break; - case GF_STREAM_MPEG7: mtype = GF_ISOM_MEDIA_MPEG7; break; - case GF_STREAM_IPMP: mtype = GF_ISOM_MEDIA_IPMP; break; - case GF_STREAM_OCI: mtype = GF_ISOM_MEDIA_OCI; break; - case GF_STREAM_MPEGJ: mtype = GF_ISOM_MEDIA_MPEGJ; break; - case GF_STREAM_INTERACT: mtype = GF_STREAM_SCENE; break; + case GF_STREAM_SCENE: + mtype = GF_ISOM_MEDIA_SCENE; + break; + case GF_STREAM_VISUAL: + mtype = GF_ISOM_MEDIA_VISUAL; + break; + case GF_STREAM_AUDIO: + mtype = GF_ISOM_MEDIA_AUDIO; + break; + case GF_STREAM_TEXT: + mtype = GF_ISOM_MEDIA_TEXT; + break; + case GF_STREAM_MPEG7: + mtype = GF_ISOM_MEDIA_MPEG7; + break; + case GF_STREAM_IPMP: + mtype = GF_ISOM_MEDIA_IPMP; + break; + case GF_STREAM_OCI: + mtype = GF_ISOM_MEDIA_OCI; + break; + case GF_STREAM_MPEGJ: + mtype = GF_ISOM_MEDIA_MPEGJ; + break; + case GF_STREAM_INTERACT: + mtype = GF_STREAM_SCENE; + break; /*not sure about this one...*/ - case GF_STREAM_IPMP_TOOL: mtype = GF_ISOM_MEDIA_IPMP; break; + case GF_STREAM_IPMP_TOOL: + mtype = GF_ISOM_MEDIA_IPMP; + break; /*not sure about this one...*/ - case GF_STREAM_FONT: mtype = GF_ISOM_MEDIA_MPEGJ; break; - default: mtype = GF_ISOM_MEDIA_ESM; + case GF_STREAM_FONT: + mtype = GF_ISOM_MEDIA_MPEGJ; + break; + default: + mtype = GF_ISOM_MEDIA_ESM; } timescale = import->esd->slConfig ? import->esd->slConfig->timestampResolution : 1000; track = gf_isom_new_track(import->dest, import->esd->ESID, mtype, timescale); @@ -6571,35 +6693,58 @@ GF_Err gf_import_saf(GF_MediaImporter *import) else if (st==GF_STREAM_VISUAL) { mtype = GF_ISOM_MEDIA_VISUAL; switch (oti) { - case GPAC_OTI_VIDEO_AVC: + case GPAC_OTI_VIDEO_AVC: case GPAC_OTI_VIDEO_SVC: - name = "AVC/H264 Video"; + name = "AVC/H264 Video"; stype = GF_4CC('H','2','6','4'); break; - case GPAC_OTI_VIDEO_HEVC: + case GPAC_OTI_VIDEO_HEVC: case GPAC_OTI_VIDEO_SHVC: - name = "HEVC Video"; + name = "HEVC Video"; stype = GF_4CC('H','E','V','C'); break; - case GPAC_OTI_VIDEO_MPEG4_PART2: name = "MPEG-4 Video"; stype = GF_4CC('M','P','4','V'); break; - case GPAC_OTI_VIDEO_MPEG1: name = "MPEG-1 Video"; stype = GF_4CC('M','P','1','V'); break; - case GPAC_OTI_VIDEO_MPEG2_SIMPLE: - case GPAC_OTI_VIDEO_MPEG2_MAIN: - case GPAC_OTI_VIDEO_MPEG2_SNR: - case GPAC_OTI_VIDEO_MPEG2_SPATIAL: - case GPAC_OTI_VIDEO_MPEG2_HIGH: - case GPAC_OTI_VIDEO_MPEG2_422: - name = "MPEG-2 Video"; stype = GF_4CC('M','P','2','V'); break; - case GPAC_OTI_IMAGE_JPEG: name = "JPEG Image"; stype = GF_4CC('J','P','E','G'); break; - case GPAC_OTI_IMAGE_PNG: name = "PNG Image"; stype = GF_4CC('P','N','G',' '); break; + case GPAC_OTI_VIDEO_MPEG4_PART2: + name = "MPEG-4 Video"; + stype = GF_4CC('M','P','4','V'); + break; + case GPAC_OTI_VIDEO_MPEG1: + name = "MPEG-1 Video"; + stype = GF_4CC('M','P','1','V'); + break; + case GPAC_OTI_VIDEO_MPEG2_SIMPLE: + case GPAC_OTI_VIDEO_MPEG2_MAIN: + case GPAC_OTI_VIDEO_MPEG2_SNR: + case GPAC_OTI_VIDEO_MPEG2_SPATIAL: + case GPAC_OTI_VIDEO_MPEG2_HIGH: + case GPAC_OTI_VIDEO_MPEG2_422: + name = "MPEG-2 Video"; + stype = GF_4CC('M','P','2','V'); + break; + case GPAC_OTI_IMAGE_JPEG: + name = "JPEG Image"; + stype = GF_4CC('J','P','E','G'); + break; + case GPAC_OTI_IMAGE_PNG: + name = "PNG Image"; + stype = GF_4CC('P','N','G',' '); + break; } } else if (st==GF_STREAM_AUDIO) { mtype = GF_ISOM_MEDIA_AUDIO; switch (oti) { - case GPAC_OTI_AUDIO_MPEG2_PART3: name = "MPEG-2 Audio"; stype = GF_4CC('M','P','2','A'); break; - case GPAC_OTI_AUDIO_MPEG1: name = "MPEG-1 Audio"; stype = GF_4CC('M','P','1','A'); break; - case GPAC_OTI_AUDIO_AAC_MPEG4: name = "MPEG-4 Audio"; stype = GF_4CC('M','P','4','A'); break; + case GPAC_OTI_AUDIO_MPEG2_PART3: + name = "MPEG-2 Audio"; + stype = GF_4CC('M','P','2','A'); + break; + case GPAC_OTI_AUDIO_MPEG1: + name = "MPEG-1 Audio"; + stype = GF_4CC('M','P','1','A'); + break; + case GPAC_OTI_AUDIO_AAC_MPEG4: + name = "MPEG-4 Audio"; + stype = GF_4CC('M','P','4','A'); + break; } } @@ -6608,7 +6753,10 @@ GF_Err gf_import_saf(GF_MediaImporter *import) u32 i, found; found = 0; for (i=0; inb_tracks; i++) { - if (import->tk_info[i].track_num==stream_id) { found = 1; break; } + if (import->tk_info[i].track_num==stream_id) { + found = 1; + break; + } } if (!found) { import->tk_info[import->nb_tracks].media_type = stype; @@ -6722,7 +6870,7 @@ typedef struct /* Determine the ESD corresponding to the current track info based on the PID and sets the additional info in the track info as described in this esd */ static void m2ts_set_track_mpeg4_probe_info(GF_M2TS_ES *es, GF_ESD *esd, - struct __track_import_info* tk_info) + struct __track_import_info* tk_info) { if (esd && tk_info) { switch (esd->decoderConfig->streamType) { @@ -6780,7 +6928,7 @@ static void m2ts_set_tracks_mpeg4_probe_info(GF_MediaImporter *import, GF_M2TS_P } if (es == NULL) continue; - if (esd->decoderConfig->streamType==GF_STREAM_OD) + if (esd->decoderConfig->streamType==GF_STREAM_OD) es->flags |= GF_M2TS_ES_IS_MPEG4_OD; @@ -6862,6 +7010,8 @@ static void m2ts_create_track(GF_TSImport *tsimp, u32 mtype, u32 stype, u32 oti, import->esd->slConfig->timestampResolution = 90000; gf_isom_set_track_enabled(import->dest, tsimp->track, 1); + //we store annexB format until we rewrite the sample, so don't inspect NALUs + gf_isom_set_nalu_extract_mode(import->dest, tsimp->track, GF_ISOM_NALU_EXTRACT_INSPECT); if (!import->esd->ESID) import->esd->ESID = gf_isom_get_track_id(import->dest, tsimp->track); gf_isom_new_mpeg4_description(import->dest, tsimp->track, import->esd, NULL, NULL, &di); @@ -6901,9 +7051,9 @@ void m2ts_rewrite_nalu_sample(GF_MediaImporter *import, GF_TSImport *tsimp) } gf_bs_seek(bs, start); gf_bs_write_u32(bs, samp->dataLength-start-4); - + gf_bs_del(bs); - + e = gf_isom_update_sample(import->dest, tsimp->track, count, samp, 1); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] Error rewriting AVC NALUs: %s\n", gf_error_to_string(e) )); @@ -6962,12 +7112,12 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) case GF_M2TS_EVT_PMT_REPEAT: /*abort upon first PMT repeat if not using 4on2. Otherwise we must parse the entire bitstream to locate ODs sent in OD updates in order to get their stream types...*/ -/* if (!ts->has_4on2 && (import->flags & GF_IMPORT_PROBE_ONLY) && !import->trackID) - import->flags |= GF_IMPORT_DO_ABORT; -*/ + /* if (!ts->has_4on2 && (import->flags & GF_IMPORT_PROBE_ONLY) && !import->trackID) + import->flags |= GF_IMPORT_DO_ABORT; + */ break; case GF_M2TS_EVT_PMT_UPDATE: - gf_import_message(import, GF_OK, "[MPEG-2 TS] PMT Update found - cannot import any further"); + gf_import_message(import, GF_OK, "[MPEG-2 TS] PMT Update found - cannot import any further"); import->flags |= GF_IMPORT_DO_ABORT; break; case GF_M2TS_EVT_DURATION_ESTIMATED: @@ -7092,7 +7242,7 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) import->tk_info[idx].lang = pes->lang; import->nb_tracks++; tsimp->nb_audio++; - break; + break; case GF_M2TS_SYSTEMS_MPEG4_PES: case GF_M2TS_SYSTEMS_MPEG4_SECTIONS: if (es->stream_type == GF_M2TS_SYSTEMS_MPEG4_PES) { @@ -7118,7 +7268,7 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) import->nb_tracks++; break; default: - gf_import_message(import, GF_OK, "[MPEG-2 TS] Ignoring stream of type %d", es->stream_type); + gf_import_message(import, GF_OK, "[MPEG-2 TS] Ignoring stream of type %d", es->stream_type); } } } else { @@ -7172,28 +7322,29 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) switch (es->stream_type) { case GF_M2TS_VIDEO_MPEG1: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; + stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_MPEG1; break; case GF_M2TS_VIDEO_MPEG2: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_MPEG2_422; + stype = GF_STREAM_VISUAL; + oti = GPAC_OTI_VIDEO_MPEG2_422; break; case GF_M2TS_VIDEO_MPEG4: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; + stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_MPEG4_PART2; break; case GF_M2TS_VIDEO_H264: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; + stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_AVC; tsimp->avccfg = gf_odf_avc_cfg_new(); break; case GF_M2TS_VIDEO_HEVC: case GF_M2TS_VIDEO_SHVC: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; + stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_HEVC; #ifndef GPAC_DISABLE_HEVC tsimp->hevccfg = gf_odf_hevc_cfg_new(); @@ -7201,24 +7352,24 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) break; case GF_M2TS_VIDEO_SVC: mtype = GF_ISOM_MEDIA_VISUAL; - stype = GF_STREAM_VISUAL; + stype = GF_STREAM_VISUAL; oti = GPAC_OTI_VIDEO_SVC; tsimp->avccfg = gf_odf_avc_cfg_new(); break; case GF_M2TS_AUDIO_MPEG1: mtype = GF_ISOM_MEDIA_AUDIO; - stype = GF_STREAM_AUDIO; + stype = GF_STREAM_AUDIO; oti = GPAC_OTI_AUDIO_MPEG1; break; case GF_M2TS_AUDIO_MPEG2: mtype = GF_ISOM_MEDIA_AUDIO; - stype = GF_STREAM_AUDIO; + stype = GF_STREAM_AUDIO; oti = GPAC_OTI_AUDIO_MPEG2_PART3; break; case GF_M2TS_AUDIO_LATM_AAC: case GF_M2TS_AUDIO_AAC: mtype = GF_ISOM_MEDIA_AUDIO; - stype = GF_STREAM_AUDIO; + stype = GF_STREAM_AUDIO; oti = GPAC_OTI_AUDIO_AAC_MPEG4; break; case GF_M2TS_SYSTEMS_MPEG4_PES: @@ -7250,489 +7401,507 @@ void on_m2ts_import_data(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) } break; case GF_M2TS_EVT_PES_PCK: - { - GF_M2TS_PES_PCK *pck = (GF_M2TS_PES_PCK *)par; - is_au_start = (pck->flags & GF_M2TS_PES_PCK_AU_START); - - if (import->flags & GF_IMPORT_PROBE_ONLY) { - for (i=0; inb_tracks; i++) { - if (import->tk_info[i].track_num == pck->stream->pid) { - if (pck->stream->aud_sr && ! import->tk_info[i].audio_info.sample_rate) { - import->tk_info[i].audio_info.sample_rate = pck->stream->aud_sr; - import->tk_info[i].audio_info.nb_channels = pck->stream->aud_nb_ch; - if ((pck->stream->stream_type==GF_M2TS_AUDIO_AAC) || (pck->stream->stream_type==GF_M2TS_AUDIO_LATM_AAC)) { - sprintf(import->tk_info[i].szCodecProfile, "mp4a.40.%02x", (u8) pck->stream->aud_obj_type); - } - import->tk_info[i].audio_info.sample_rate = pck->stream->aud_sr; - import->tk_info[i].audio_info.nb_channels = pck->stream->aud_nb_ch; - tsimp->nb_audio_configured++; - } - /*unpack AVC config*/ - else if (((pck->stream->stream_type==GF_M2TS_VIDEO_H264) || (pck->stream->stream_type==GF_M2TS_VIDEO_SVC)) && !pck->data[0] && !pck->data[1]) { - u32 nal_type = pck->data[4] & 0x1F; - if (nal_type == GF_AVC_NALU_SEQ_PARAM) { - sprintf(import->tk_info[i].szCodecProfile, "avc1.%02x%02x%02x", (u8) pck->data[5], (u8) pck->data[6], (u8) pck->data[7]); - } + { + GF_M2TS_PES_PCK *pck = (GF_M2TS_PES_PCK *)par; + is_au_start = (pck->flags & GF_M2TS_PES_PCK_AU_START); + + if (import->flags & GF_IMPORT_PROBE_ONLY) { + for (i=0; inb_tracks; i++) { + if (import->tk_info[i].track_num == pck->stream->pid) { + if (pck->stream->aud_sr && ! import->tk_info[i].audio_info.sample_rate) { + import->tk_info[i].audio_info.sample_rate = pck->stream->aud_sr; + import->tk_info[i].audio_info.nb_channels = pck->stream->aud_nb_ch; + if ((pck->stream->stream_type==GF_M2TS_AUDIO_AAC) || (pck->stream->stream_type==GF_M2TS_AUDIO_LATM_AAC)) { + sprintf(import->tk_info[i].szCodecProfile, "mp4a.40.%02x", (u8) pck->stream->aud_obj_type); } - else if (pck->stream->stream_type==GF_M2TS_VIDEO_HEVC) { - u32 nal_type = (pck->data[4] & 0x7E) >> 1; - if (nal_type == GF_HEVC_NALU_SEQ_PARAM) { - //todo ..; - sprintf(import->tk_info[i].szCodecProfile, "hvc1"); - } + import->tk_info[i].audio_info.sample_rate = pck->stream->aud_sr; + import->tk_info[i].audio_info.nb_channels = pck->stream->aud_nb_ch; + tsimp->nb_audio_configured++; + } + /*unpack AVC config*/ + else if (((pck->stream->stream_type==GF_M2TS_VIDEO_H264) || (pck->stream->stream_type==GF_M2TS_VIDEO_SVC)) && !pck->data[0] && !pck->data[1]) { + u32 nal_type = pck->data[4] & 0x1F; + if (nal_type == GF_AVC_NALU_SEQ_PARAM) { + sprintf(import->tk_info[i].szCodecProfile, "avc1.%02x%02x%02x", (u8) pck->data[5], (u8) pck->data[6], (u8) pck->data[7]); } - else if ((pck->stream->stream_type==GF_M2TS_AUDIO_EC3) || (pck->stream->stream_type==GF_M2TS_AUDIO_AC3) || (pck->stream->stream_type==GF_M2TS_AUDIO_DTS)) { - if (!import->tk_info[i].audio_info.sample_rate) { - //todo ... - import->tk_info[i].audio_info.sample_rate = 44100; - import->tk_info[i].audio_info.nb_channels = 2; - tsimp->nb_audio_configured++; - } + } + else if (pck->stream->stream_type==GF_M2TS_VIDEO_HEVC) { + u32 nal_type = (pck->data[4] & 0x7E) >> 1; + if (nal_type == GF_HEVC_NALU_SEQ_PARAM) { + //todo ..; + sprintf(import->tk_info[i].szCodecProfile, "hvc1"); } - - if (pck->stream->vid_w && ! import->tk_info[i].video_info.width ) { - import->tk_info[i].video_info.width = pck->stream->vid_w; - import->tk_info[i].video_info.height = pck->stream->vid_h; - tsimp->nb_video_configured++; + } + else if ((pck->stream->stream_type==GF_M2TS_AUDIO_EC3) || (pck->stream->stream_type==GF_M2TS_AUDIO_AC3) || (pck->stream->stream_type==GF_M2TS_AUDIO_DTS)) { + if (!import->tk_info[i].audio_info.sample_rate) { + //todo ... + import->tk_info[i].audio_info.sample_rate = 44100; + import->tk_info[i].audio_info.nb_channels = 2; + tsimp->nb_audio_configured++; } + } - /*consider we are done if not using 4 on 2*/ - if (!ts->has_4on2 - && (tsimp->nb_video_configured == tsimp->nb_video) - && (tsimp->nb_audio_configured == tsimp->nb_audio) - && import->probe_duration - ) { - import->flags |= GF_IMPORT_DO_ABORT; - } - break; + if (pck->stream->vid_w && ! import->tk_info[i].video_info.width ) { + import->tk_info[i].video_info.width = pck->stream->vid_w; + import->tk_info[i].video_info.height = pck->stream->vid_h; + tsimp->nb_video_configured++; + } + + /*consider we are done if not using 4 on 2*/ + if (!ts->has_4on2 + && (tsimp->nb_video_configured == tsimp->nb_video) + && (tsimp->nb_audio_configured == tsimp->nb_audio) + && import->probe_duration + ) { + import->flags |= GF_IMPORT_DO_ABORT; } + break; } - if (!ts->has_4on2 && (import->trackID==pck->stream->pid) && (pck->stream->vid_h || pck->stream->aud_sr) ) - import->flags |= GF_IMPORT_DO_ABORT; - return; } + if (!ts->has_4on2 && (import->trackID==pck->stream->pid) && (pck->stream->vid_h || pck->stream->aud_sr) ) + import->flags |= GF_IMPORT_DO_ABORT; + return; + } - /* Even if we don't import this stream we need to check the first dts of the program */ - if (!(pck->stream->flags & GF_M2TS_ES_FIRST_DTS) && is_au_start) { - pck->stream->flags |= GF_M2TS_ES_FIRST_DTS; - pck->stream->first_dts = (pck->PTS!=pck->DTS) ? pck->DTS : pck->PTS; - if (!pck->stream->program->first_dts || pck->stream->program->first_dts > pck->stream->first_dts) { - pck->stream->program->first_dts = pck->stream->first_dts; + /* Even if we don't import this stream we need to check the first dts of the program */ + if (!(pck->stream->flags & GF_M2TS_ES_FIRST_DTS) && is_au_start) { + pck->stream->flags |= GF_M2TS_ES_FIRST_DTS; + pck->stream->first_dts = (pck->PTS!=pck->DTS) ? pck->DTS : pck->PTS; + if (!pck->stream->program->first_dts || pck->stream->program->first_dts > pck->stream->first_dts) { + pck->stream->program->first_dts = pck->stream->first_dts; - if (pck->stream->pid != import->trackID) { - gf_m2ts_set_pes_framing((GF_M2TS_PES *)pck->stream, GF_M2TS_PES_FRAMING_SKIP); - } + if (pck->stream->pid != import->trackID) { + gf_m2ts_set_pes_framing((GF_M2TS_PES *)pck->stream, GF_M2TS_PES_FRAMING_SKIP); } - } - if (pck->stream->pid != import->trackID) return; - - /*avc data for the current sample is stored in annex-B, as we don't know the size of each nal - when called back (depending on PES packetization, the end of the nal could be in following pes)*/ - if (tsimp->avccfg && !pck->data[0] && !pck->data[1]) { - GF_AVCConfigSlot *slc; - s32 idx; - Bool add_sps, is_subseq = 0; - u32 nal_type = pck->data[4] & 0x1F; - - switch (nal_type) { - case GF_AVC_NALU_SVC_SUBSEQ_PARAM: - is_subseq = 1; - case GF_AVC_NALU_SEQ_PARAM: - idx = gf_media_avc_read_sps(pck->data+4, pck->data_len-4, &tsimp->avc, is_subseq, NULL); + } + } + if (pck->stream->pid != import->trackID) return; - add_sps = 0; - if (idx>=0) { - if (is_subseq) { - if ((tsimp->avc.sps[idx].state & AVC_SUBSPS_PARSED) && !(tsimp->avc.sps[idx].state & AVC_SUBSPS_DECLARED)) { - tsimp->avc.sps[idx].state |= AVC_SUBSPS_DECLARED; - add_sps = 1; - } - } else { - if ((tsimp->avc.sps[idx].state & AVC_SPS_PARSED) && !(tsimp->avc.sps[idx].state & AVC_SPS_DECLARED)) { - tsimp->avc.sps[idx].state |= AVC_SPS_DECLARED; - add_sps = 1; - } + /*avc data for the current sample is stored in annex-B, as we don't know the size of each nal + when called back (depending on PES packetization, the end of the nal could be in following pes)*/ + if (tsimp->avccfg && !pck->data[0] && !pck->data[1]) { + GF_AVCConfigSlot *slc; + s32 idx; + Bool add_sps, is_subseq = 0; + u32 nal_type = pck->data[4] & 0x1F; + + switch (nal_type) { + case GF_AVC_NALU_SVC_SUBSEQ_PARAM: + is_subseq = 1; + case GF_AVC_NALU_SEQ_PARAM: + idx = gf_media_avc_read_sps(pck->data+4, pck->data_len-4, &tsimp->avc, is_subseq, NULL); + + add_sps = 0; + if (idx>=0) { + if (is_subseq) { + if ((tsimp->avc.sps[idx].state & AVC_SUBSPS_PARSED) && !(tsimp->avc.sps[idx].state & AVC_SUBSPS_DECLARED)) { + tsimp->avc.sps[idx].state |= AVC_SUBSPS_DECLARED; + add_sps = 1; } - if (add_sps) { - /*always store nalu size on 4 bytes*/ - tsimp->avccfg->nal_unit_size = 4; - tsimp->avccfg->configurationVersion = 1; - tsimp->avccfg->profile_compatibility = tsimp->avc.sps[idx].prof_compat; - tsimp->avccfg->AVCProfileIndication = tsimp->avc.sps[idx].profile_idc; - tsimp->avccfg->AVCLevelIndication = tsimp->avc.sps[idx].level_idc; - slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); - slc->size = pck->data_len-4; - slc->data = (char*)gf_malloc(sizeof(char)*slc->size); - memcpy(slc->data, pck->data+4, sizeof(char)*slc->size); - gf_list_add(tsimp->avccfg->sequenceParameterSets, slc); - - if (pck->stream->vid_w < tsimp->avc.sps[idx].width) - pck->stream->vid_w = tsimp->avc.sps[idx].width; - if (pck->stream->vid_h < tsimp->avc.sps[idx].height) - pck->stream->vid_h = tsimp->avc.sps[idx].height; + } else { + if ((tsimp->avc.sps[idx].state & AVC_SPS_PARSED) && !(tsimp->avc.sps[idx].state & AVC_SPS_DECLARED)) { + tsimp->avc.sps[idx].state |= AVC_SPS_DECLARED; + add_sps = 1; } } - return; - case GF_AVC_NALU_PIC_PARAM: - idx = gf_media_avc_read_pps(pck->data+4, pck->data_len-4, &tsimp->avc); - if ((idx>=0) && (tsimp->avc.pps[idx].status==1)) { - tsimp->avc.pps[idx].status = 2; + if (add_sps) { + /*always store nalu size on 4 bytes*/ + tsimp->avccfg->nal_unit_size = 4; + tsimp->avccfg->configurationVersion = 1; + tsimp->avccfg->profile_compatibility = tsimp->avc.sps[idx].prof_compat; + tsimp->avccfg->AVCProfileIndication = tsimp->avc.sps[idx].profile_idc; + tsimp->avccfg->AVCLevelIndication = tsimp->avc.sps[idx].level_idc; slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); slc->size = pck->data_len-4; slc->data = (char*)gf_malloc(sizeof(char)*slc->size); memcpy(slc->data, pck->data+4, sizeof(char)*slc->size); - gf_list_add(tsimp->avccfg->pictureParameterSets, slc); - } - /*else discard because of invalid PPS*/ - return; - /*remove*/ - case GF_AVC_NALU_ACCESS_UNIT: - tsimp->force_next_au_start = 1; - return; - case GF_AVC_NALU_FILLER_DATA: - case GF_AVC_NALU_END_OF_SEQ: - case GF_AVC_NALU_END_OF_STREAM: - return; - case GF_AVC_NALU_SEI: - break; - if (tsimp->avc.sps_active_idx != -1) { - idx = gf_media_avc_reformat_sei(pck->data+4, pck->data_len-4, &tsimp->avc); - if (idx>0) pck->data_len = idx+4; + gf_list_add(tsimp->avccfg->sequenceParameterSets, slc); + + if (pck->stream->vid_w < tsimp->avc.sps[idx].width) + pck->stream->vid_w = tsimp->avc.sps[idx].width; + if (pck->stream->vid_h < tsimp->avc.sps[idx].height) + pck->stream->vid_h = tsimp->avc.sps[idx].height; } - break; } - - if (tsimp->force_next_au_start) { - is_au_start = 1; - tsimp->force_next_au_start = 0; + return; + case GF_AVC_NALU_PIC_PARAM: + idx = gf_media_avc_read_pps(pck->data+4, pck->data_len-4, &tsimp->avc); + if ((idx>=0) && (tsimp->avc.pps[idx].status==1)) { + tsimp->avc.pps[idx].status = 2; + slc = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot)); + slc->size = pck->data_len-4; + slc->data = (char*)gf_malloc(sizeof(char)*slc->size); + memcpy(slc->data, pck->data+4, sizeof(char)*slc->size); + gf_list_add(tsimp->avccfg->pictureParameterSets, slc); + } + /*else discard because of invalid PPS*/ + return; + /*remove*/ + case GF_AVC_NALU_ACCESS_UNIT: + tsimp->force_next_au_start = 1; + return; + case GF_AVC_NALU_FILLER_DATA: + case GF_AVC_NALU_END_OF_SEQ: + case GF_AVC_NALU_END_OF_STREAM: + return; + case GF_AVC_NALU_SEI: + break; + if (tsimp->avc.sps_active_idx != -1) { + idx = gf_media_avc_reformat_sei(pck->data+4, pck->data_len-4, &tsimp->avc); + if (idx>0) pck->data_len = idx+4; } + break; } - /*avc data for the current sample is stored in annex-B, as we don't know the size of each nal - when called back (depending on PES packetization, the end of the nal could be in following pes)*/ + if (tsimp->force_next_au_start) { + is_au_start = 1; + tsimp->force_next_au_start = 0; + } + } + + /*avc data for the current sample is stored in annex-B, as we don't know the size of each nal + when called back (depending on PES packetization, the end of the nal could be in following pes)*/ #ifndef GPAC_DISABLE_HEVC - else if (tsimp->hevccfg && !pck->data[0] && !pck->data[1]) { - s32 idx; - Bool add_sps, is_subseq = 0; - u32 nal_type = (pck->data[4] & 0x7E) >> 1; - - switch (nal_type) { - case GF_HEVC_NALU_SEQ_PARAM: - idx = gf_media_hevc_read_sps(pck->data+4, pck->data_len-4, &tsimp->hevc); - add_sps = 0; - if (idx>=0) { - if (is_subseq) { - if ((tsimp->hevc.sps[idx].state & AVC_SUBSPS_PARSED) && !(tsimp->hevc.sps[idx].state & AVC_SUBSPS_DECLARED)) { - tsimp->hevc.sps[idx].state |= AVC_SUBSPS_DECLARED; - add_sps = 1; - } - } else { - if ((tsimp->hevc.sps[idx].state & AVC_SPS_PARSED) && !(tsimp->hevc.sps[idx].state & AVC_SPS_DECLARED)) { - tsimp->hevc.sps[idx].state |= AVC_SPS_DECLARED; - add_sps = 1; - } + else if (tsimp->hevccfg && !pck->data[0] && !pck->data[1]) { + s32 idx; + Bool add_sps, is_subseq = 0; + u32 nal_type = (pck->data[4] & 0x7E) >> 1; + + switch (nal_type) { + case GF_HEVC_NALU_SEQ_PARAM: + idx = gf_media_hevc_read_sps(pck->data+4, pck->data_len-4, &tsimp->hevc); + add_sps = 0; + if (idx>=0) { + if (is_subseq) { + if ((tsimp->hevc.sps[idx].state & AVC_SUBSPS_PARSED) && !(tsimp->hevc.sps[idx].state & AVC_SUBSPS_DECLARED)) { + tsimp->hevc.sps[idx].state |= AVC_SUBSPS_DECLARED; + add_sps = 1; } - if (add_sps) { - /*always store nalu size on 4 bytes*/ - tsimp->hevccfg->nal_unit_size = 4; - tsimp->hevccfg->configurationVersion = 1; - - tsimp->hevccfg->configurationVersion = 1; - tsimp->hevccfg->profile_space = tsimp->hevc.sps[idx].ptl.profile_space; - tsimp->hevccfg->profile_idc = tsimp->hevc.sps[idx].ptl.profile_idc; - tsimp->hevccfg->constraint_indicator_flags = 0; - tsimp->hevccfg->level_idc = tsimp->hevc.sps[idx].ptl.level_idc; - tsimp->hevccfg->general_profile_compatibility_flags = tsimp->hevc.sps[idx].ptl.profile_compatibility_flag; - tsimp->hevccfg->chromaFormat = tsimp->hevc.sps[idx].chroma_format_idc; - tsimp->hevccfg->luma_bit_depth = tsimp->hevc.sps[idx].bit_depth_luma; - tsimp->hevccfg->chroma_bit_depth = tsimp->hevc.sps[idx].bit_depth_chroma; - - hevc_cfg_add_nalu(tsimp->hevccfg, nal_type, pck->data+4, pck->data_len-4); - - if (pck->stream->vid_w < tsimp->avc.sps[idx].width) - pck->stream->vid_w = tsimp->avc.sps[idx].width; - if (pck->stream->vid_h < tsimp->avc.sps[idx].height) - pck->stream->vid_h = tsimp->avc.sps[idx].height; + } else { + if ((tsimp->hevc.sps[idx].state & AVC_SPS_PARSED) && !(tsimp->hevc.sps[idx].state & AVC_SPS_DECLARED)) { + tsimp->hevc.sps[idx].state |= AVC_SPS_DECLARED; + add_sps = 1; } } - return; - case GF_HEVC_NALU_PIC_PARAM: - idx = gf_media_hevc_read_pps(pck->data+4, pck->data_len-4, &tsimp->hevc); - if ((idx>=0) && (tsimp->hevc.pps[idx].state==1)) { - tsimp->hevc.pps[idx].state = 2; - hevc_cfg_add_nalu(tsimp->hevccfg, nal_type, pck->data+4, pck->data_len-4); - } - return; - case GF_HEVC_NALU_VID_PARAM: - idx = gf_media_hevc_read_vps(pck->data+4, pck->data_len-4, &tsimp->hevc); - if ((idx>=0) && (tsimp->hevc.vps[idx].state==1)) { - tsimp->hevc.vps[idx].state = 2; - tsimp->hevccfg->avgFrameRate = tsimp->hevc.vps[idx].rates[0].avg_pic_rate; - tsimp->hevccfg->constantFrameRate = tsimp->hevc.vps[idx].rates[0].constand_pic_rate_idc; - tsimp->hevccfg->numTemporalLayers = tsimp->hevc.vps[idx].max_sub_layers; + if (add_sps) { + /*always store nalu size on 4 bytes*/ + tsimp->hevccfg->nal_unit_size = 4; + tsimp->hevccfg->configurationVersion = 1; + + tsimp->hevccfg->configurationVersion = 1; + tsimp->hevccfg->profile_space = tsimp->hevc.sps[idx].ptl.profile_space; + tsimp->hevccfg->profile_idc = tsimp->hevc.sps[idx].ptl.profile_idc; + tsimp->hevccfg->constraint_indicator_flags = 0; + tsimp->hevccfg->level_idc = tsimp->hevc.sps[idx].ptl.level_idc; + tsimp->hevccfg->general_profile_compatibility_flags = tsimp->hevc.sps[idx].ptl.profile_compatibility_flag; + tsimp->hevccfg->chromaFormat = tsimp->hevc.sps[idx].chroma_format_idc; + tsimp->hevccfg->luma_bit_depth = tsimp->hevc.sps[idx].bit_depth_luma; + tsimp->hevccfg->chroma_bit_depth = tsimp->hevc.sps[idx].bit_depth_chroma; + hevc_cfg_add_nalu(tsimp->hevccfg, nal_type, pck->data+4, pck->data_len-4); + + if (pck->stream->vid_w < tsimp->avc.sps[idx].width) + pck->stream->vid_w = tsimp->avc.sps[idx].width; + if (pck->stream->vid_h < tsimp->avc.sps[idx].height) + pck->stream->vid_h = tsimp->avc.sps[idx].height; } - return; - /*remove*/ - case GF_HEVC_NALU_ACCESS_UNIT: - tsimp->force_next_au_start = 1; - return; - case GF_HEVC_NALU_FILLER_DATA: - case GF_HEVC_NALU_END_OF_SEQ: - case GF_HEVC_NALU_END_OF_STREAM: - return; - case GF_HEVC_NALU_SEI_PREFIX: -/*TODO if (tsimp->avc.sps_active_idx != -1) { - idx = gf_media_avc_reformat_sei(pck->data+4, pck->data_len-4, &tsimp->avc); - if (idx>0) pck->data_len = idx+4; - } -*/ - break; } - - if (tsimp->force_next_au_start) { - is_au_start = 1; - tsimp->force_next_au_start = 0; + return; + case GF_HEVC_NALU_PIC_PARAM: + idx = gf_media_hevc_read_pps(pck->data+4, pck->data_len-4, &tsimp->hevc); + if ((idx>=0) && (tsimp->hevc.pps[idx].state==1)) { + tsimp->hevc.pps[idx].state = 2; + hevc_cfg_add_nalu(tsimp->hevccfg, nal_type, pck->data+4, pck->data_len-4); + } + return; + case GF_HEVC_NALU_VID_PARAM: + idx = gf_media_hevc_read_vps(pck->data+4, pck->data_len-4, &tsimp->hevc); + if ((idx>=0) && (tsimp->hevc.vps[idx].state==1)) { + tsimp->hevc.vps[idx].state = 2; + tsimp->hevccfg->avgFrameRate = tsimp->hevc.vps[idx].rates[0].avg_pic_rate; + tsimp->hevccfg->constantFrameRate = tsimp->hevc.vps[idx].rates[0].constand_pic_rate_idc; + tsimp->hevccfg->numTemporalLayers = tsimp->hevc.vps[idx].max_sub_layers; + hevc_cfg_add_nalu(tsimp->hevccfg, nal_type, pck->data+4, pck->data_len-4); } + return; + /*remove*/ + case GF_HEVC_NALU_ACCESS_UNIT: + tsimp->force_next_au_start = 1; + return; + case GF_HEVC_NALU_FILLER_DATA: + case GF_HEVC_NALU_END_OF_SEQ: + case GF_HEVC_NALU_END_OF_STREAM: + return; + case GF_HEVC_NALU_SEI_PREFIX: + /*TODO if (tsimp->avc.sps_active_idx != -1) { + idx = gf_media_avc_reformat_sei(pck->data+4, pck->data_len-4, &tsimp->avc); + if (idx>0) pck->data_len = idx+4; + } + */ + break; + } + + if (tsimp->force_next_au_start) { + is_au_start = 1; + tsimp->force_next_au_start = 0; } + } #endif //GPAC_DISABLE_HEVC - if (!is_au_start) { - e = gf_isom_append_sample_data(import->dest, tsimp->track, (char*)pck->data, pck->data_len); - if (e) { - if (!gf_isom_get_sample_count(import->dest, tsimp->track)) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] missed begining of sample data\n")); - e = GF_OK; - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] Error appending sample data\n")); - } + if (!is_au_start) { + e = gf_isom_append_sample_data(import->dest, tsimp->track, (char*)pck->data, pck->data_len); + if (e) { + if (!gf_isom_get_sample_count(import->dest, tsimp->track)) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] missed begining of sample data\n")); + e = GF_OK; + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] Error appending sample data\n")); } - if (pck->flags & GF_M2TS_PES_PCK_I_FRAME) tsimp->nb_i++; - if (pck->flags & GF_M2TS_PES_PCK_P_FRAME) tsimp->nb_p++; - if (pck->flags & GF_M2TS_PES_PCK_B_FRAME) tsimp->nb_b++; + } + if (pck->flags & GF_M2TS_PES_PCK_I_FRAME) tsimp->nb_i++; + if (pck->flags & GF_M2TS_PES_PCK_P_FRAME) tsimp->nb_p++; + if (pck->flags & GF_M2TS_PES_PCK_B_FRAME) tsimp->nb_b++; - if (pck->flags & GF_M2TS_PES_PCK_RAP) { - e = gf_isom_set_sample_rap(import->dest, tsimp->track); - } - return; + if (pck->flags & GF_M2TS_PES_PCK_RAP) { + e = gf_isom_set_sample_rap(import->dest, tsimp->track); } + return; + } - samp = gf_isom_sample_new(); - samp->DTS = pck->DTS; - samp->CTS_Offset = (u32) (pck->PTS - samp->DTS); - - if (pck->stream->first_dts==samp->DTS) { - switch (pck->stream->stream_type) { - case GF_M2TS_VIDEO_MPEG1: gf_import_message(import, GF_OK, "MPEG-1 Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_VIDEO_MPEG2: gf_import_message(import, GF_OK, "MPEG-2 Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_VIDEO_MPEG4: gf_import_message(import, GF_OK, "MPEG-4 Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_VIDEO_H264: gf_import_message(import, GF_OK, "MPEG-4 AVC/H264 Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_VIDEO_HEVC: gf_import_message(import, GF_OK, "MPEG-H HEVC Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_VIDEO_SVC: gf_import_message(import, GF_OK, "H264-SVC Video import (TS PID %d)", pck->stream->pid); break; - case GF_M2TS_AUDIO_MPEG1: gf_import_message(import, GF_OK, "MPEG-1 Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); break; - case GF_M2TS_AUDIO_MPEG2: gf_import_message(import, GF_OK, "MPEG-2 Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); break; - case GF_M2TS_AUDIO_AAC: gf_import_message(import, GF_OK, "MPEG-4 AAC Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); break; - } - if (pck->stream->lang) - gf_isom_set_media_language(import->dest, tsimp->track, (char *) gf_4cc_to_str(pck->stream->lang)+1); + samp = gf_isom_sample_new(); + samp->DTS = pck->DTS; + samp->CTS_Offset = (u32) (pck->PTS - samp->DTS); + + if (pck->stream->first_dts==samp->DTS) { + switch (pck->stream->stream_type) { + case GF_M2TS_VIDEO_MPEG1: + gf_import_message(import, GF_OK, "MPEG-1 Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_VIDEO_MPEG2: + gf_import_message(import, GF_OK, "MPEG-2 Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_VIDEO_MPEG4: + gf_import_message(import, GF_OK, "MPEG-4 Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_VIDEO_H264: + gf_import_message(import, GF_OK, "MPEG-4 AVC/H264 Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_VIDEO_HEVC: + gf_import_message(import, GF_OK, "MPEG-H HEVC Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_VIDEO_SVC: + gf_import_message(import, GF_OK, "H264-SVC Video import (TS PID %d)", pck->stream->pid); + break; + case GF_M2TS_AUDIO_MPEG1: + gf_import_message(import, GF_OK, "MPEG-1 Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); + break; + case GF_M2TS_AUDIO_MPEG2: + gf_import_message(import, GF_OK, "MPEG-2 Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); + break; + case GF_M2TS_AUDIO_AAC: + gf_import_message(import, GF_OK, "MPEG-4 AAC Audio import - SampleRate %d Channels %d Language %s (TS PID %d)", pck->stream->aud_sr, pck->stream->aud_nb_ch, gf_4cc_to_str(pck->stream->lang), pck->stream->pid); + break; } - if (!tsimp->stream_setup) { - if (pck->stream->aud_sr) { - gf_isom_set_audio_info(import->dest, tsimp->track, 1, pck->stream->aud_sr, pck->stream->aud_nb_ch, 16); - tsimp->stream_setup = 1; - } - else if (pck->stream->vid_w) { - u32 w = pck->stream->vid_w; - if (pck->stream->vid_par) w = w * (pck->stream->vid_par>>16) / (pck->stream->vid_par&0xffff); - gf_isom_set_visual_info(import->dest, tsimp->track, 1, pck->stream->vid_w, pck->stream->vid_h); - gf_isom_set_track_layout_info(import->dest, tsimp->track, w<<16, pck->stream->vid_h<<16, 0, 0, 0); - if (w != pck->stream->vid_w) - e = gf_isom_set_pixel_aspect_ratio(import->dest, tsimp->track, 1, pck->stream->vid_par>>16, pck->stream->vid_par&0xff); - - tsimp->stream_setup = 1; - } + if (pck->stream->lang) + gf_isom_set_media_language(import->dest, tsimp->track, (char *) gf_4cc_to_str(pck->stream->lang)+1); + } + if (!tsimp->stream_setup) { + if (pck->stream->aud_sr) { + gf_isom_set_audio_info(import->dest, tsimp->track, 1, pck->stream->aud_sr, pck->stream->aud_nb_ch, 16); + tsimp->stream_setup = 1; } + else if (pck->stream->vid_w) { + u32 w = pck->stream->vid_w; + if (pck->stream->vid_par) w = w * (pck->stream->vid_par>>16) / (pck->stream->vid_par&0xffff); + gf_isom_set_visual_info(import->dest, tsimp->track, 1, pck->stream->vid_w, pck->stream->vid_h); + gf_isom_set_track_layout_info(import->dest, tsimp->track, w<<16, pck->stream->vid_h<<16, 0, 0, 0); + if (w != pck->stream->vid_w) + e = gf_isom_set_pixel_aspect_ratio(import->dest, tsimp->track, 1, pck->stream->vid_par>>16, pck->stream->vid_par&0xff); - if (samp->DTS >= pck->stream->first_dts) { - samp->DTS -= pck->stream->first_dts; - samp->IsRAP = (pck->flags & GF_M2TS_PES_PCK_RAP) ? 1 : 0; - samp->data = pck->data; - samp->dataLength = pck->data_len; + tsimp->stream_setup = 1; + } + } - if (samp->DTS && (samp->DTS==tsimp->last_dts)) { - e = gf_isom_append_sample_data(import->dest, tsimp->track, (char*)pck->data, pck->data_len); - } else { + if (samp->DTS >= pck->stream->first_dts) { + samp->DTS -= pck->stream->first_dts; + samp->IsRAP = (pck->flags & GF_M2TS_PES_PCK_RAP) ? 1 : 0; + samp->data = pck->data; + samp->dataLength = pck->data_len; - if (tsimp->avccfg || tsimp->hevccfg) m2ts_rewrite_nalu_sample(import, tsimp); + if (samp->DTS && (samp->DTS==tsimp->last_dts)) { + e = gf_isom_append_sample_data(import->dest, tsimp->track, (char*)pck->data, pck->data_len); + } else { - e = gf_isom_add_sample(import->dest, tsimp->track, 1, samp); - } - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d: Error adding sample: %s\n", pck->stream->pid, gf_error_to_string(e))); - //import->flags |= GF_IMPORT_DO_ABORT; - import->last_error = e; - } - if (import->duration && (import->duration<=(samp->DTS+samp->CTS_Offset)/90)) - //import->flags |= GF_IMPORT_DO_ABORT; + if (tsimp->avccfg || tsimp->hevccfg) m2ts_rewrite_nalu_sample(import, tsimp); - if (pck->flags & GF_M2TS_PES_PCK_I_FRAME) tsimp->nb_i++; - if (pck->flags & GF_M2TS_PES_PCK_P_FRAME) tsimp->nb_p++; - if (pck->flags & GF_M2TS_PES_PCK_B_FRAME) tsimp->nb_b++; - tsimp->last_dts = samp->DTS; - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] negative time sample - skipping\n")); + e = gf_isom_add_sample(import->dest, tsimp->track, 1, samp); } - samp->data = NULL; - gf_isom_sample_del(&samp); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d: Error adding sample: %s\n", pck->stream->pid, gf_error_to_string(e))); + //import->flags |= GF_IMPORT_DO_ABORT; + import->last_error = e; + } + if (import->duration && (import->duration<=(samp->DTS+samp->CTS_Offset)/90)) + //import->flags |= GF_IMPORT_DO_ABORT; + + if (pck->flags & GF_M2TS_PES_PCK_I_FRAME) tsimp->nb_i++; + if (pck->flags & GF_M2TS_PES_PCK_P_FRAME) tsimp->nb_p++; + if (pck->flags & GF_M2TS_PES_PCK_B_FRAME) tsimp->nb_b++; + tsimp->last_dts = samp->DTS; + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] negative time sample - skipping\n")); } - break; + samp->data = NULL; + gf_isom_sample_del(&samp); + } + break; case GF_M2TS_EVT_SL_PCK: - { - GF_M2TS_SL_PCK *sl_pck = (GF_M2TS_SL_PCK *)par; + { + GF_M2TS_SL_PCK *sl_pck = (GF_M2TS_SL_PCK *)par; - /* if there is no IOD for this program we cannot handle SL packets */ - if (!sl_pck->stream->program->pmt_iod) return; + /* if there is no IOD for this program we cannot handle SL packets */ + if (!sl_pck->stream->program->pmt_iod) return; - if (sl_pck->stream->flags & GF_M2TS_ES_IS_SECTION) { - //ses = (GF_M2TS_SECTION_ES *)sl_pck->stream; - } else { - pes = (GF_M2TS_PES *)sl_pck->stream; - } - - if (sl_pck->stream->flags & GF_M2TS_ES_IS_MPEG4_OD) { - /* We need to handle OD streams even if this is not the stream we are importing */ - GF_ESD *esd = gf_m2ts_get_esd(sl_pck->stream); - if (esd) { - GF_SLHeader hdr; - u32 hdr_len; - GF_ODCodec *od_codec = gf_odf_codec_new(); - GF_ODCom *com; - GF_ODUpdate* odU; - u32 com_count, com_index, od_count, od_index; - - gf_sl_depacketize(esd->slConfig, &hdr, sl_pck->data, sl_pck->data_len, &hdr_len); - gf_odf_codec_set_au(od_codec, sl_pck->data+hdr_len, sl_pck->data_len - hdr_len); - gf_odf_codec_decode(od_codec); - com_count = gf_list_count(od_codec->CommandList); - for (com_index = 0; com_index < com_count; com_index++) { - com = (GF_ODCom *)gf_list_get(od_codec->CommandList, com_index); - switch (com->tag) { - case GF_ODF_OD_UPDATE_TAG: - odU = (GF_ODUpdate*)com; - od_count = gf_list_count(odU->objectDescriptors); - for (od_index=0; od_indexobjectDescriptors, od_index); - gf_list_add(sl_pck->stream->program->additional_ods, od); - - /* We need to set the remaining unset track info for the streams declared in this OD */ - m2ts_set_tracks_mpeg4_probe_info(import, sl_pck->stream->program, od->ESDescriptors); - } - gf_list_reset(odU->objectDescriptors); + if (sl_pck->stream->flags & GF_M2TS_ES_IS_SECTION) { + //ses = (GF_M2TS_SECTION_ES *)sl_pck->stream; + } else { + pes = (GF_M2TS_PES *)sl_pck->stream; + } + + if (sl_pck->stream->flags & GF_M2TS_ES_IS_MPEG4_OD) { + /* We need to handle OD streams even if this is not the stream we are importing */ + GF_ESD *esd = gf_m2ts_get_esd(sl_pck->stream); + if (esd) { + GF_SLHeader hdr; + u32 hdr_len; + GF_ODCodec *od_codec = gf_odf_codec_new(); + GF_ODCom *com; + GF_ODUpdate* odU; + u32 com_count, com_index, od_count, od_index; + + gf_sl_depacketize(esd->slConfig, &hdr, sl_pck->data, sl_pck->data_len, &hdr_len); + gf_odf_codec_set_au(od_codec, sl_pck->data+hdr_len, sl_pck->data_len - hdr_len); + gf_odf_codec_decode(od_codec); + com_count = gf_list_count(od_codec->CommandList); + for (com_index = 0; com_index < com_count; com_index++) { + com = (GF_ODCom *)gf_list_get(od_codec->CommandList, com_index); + switch (com->tag) { + case GF_ODF_OD_UPDATE_TAG: + odU = (GF_ODUpdate*)com; + od_count = gf_list_count(odU->objectDescriptors); + for (od_index=0; od_indexobjectDescriptors, od_index); + gf_list_add(sl_pck->stream->program->additional_ods, od); + + /* We need to set the remaining unset track info for the streams declared in this OD */ + m2ts_set_tracks_mpeg4_probe_info(import, sl_pck->stream->program, od->ESDescriptors); } + gf_list_reset(odU->objectDescriptors); } - gf_odf_codec_del(od_codec); } - + gf_odf_codec_del(od_codec); } - if (import->flags & GF_IMPORT_PROBE_ONLY) { - if (pes) { - for (i=0; inb_tracks; i++) { - if (import->tk_info[i].track_num == sl_pck->stream->pid) { - if (pes->aud_sr) { - import->tk_info[i].audio_info.sample_rate = pes->aud_sr; - import->tk_info[i].audio_info.nb_channels = pes->aud_nb_ch; - } else { - import->tk_info[i].video_info.width = pes->vid_w; - import->tk_info[i].video_info.height = pes->vid_h; - } - break; + } + + if (import->flags & GF_IMPORT_PROBE_ONLY) { + if (pes) { + for (i=0; inb_tracks; i++) { + if (import->tk_info[i].track_num == sl_pck->stream->pid) { + if (pes->aud_sr) { + import->tk_info[i].audio_info.sample_rate = pes->aud_sr; + import->tk_info[i].audio_info.nb_channels = pes->aud_nb_ch; + } else { + import->tk_info[i].video_info.width = pes->vid_w; + import->tk_info[i].video_info.height = pes->vid_h; } + break; } -// if (pes->vid_h || pes->aud_sr) import->flags |= GF_IMPORT_DO_ABORT; } - return; +// if (pes->vid_h || pes->aud_sr) import->flags |= GF_IMPORT_DO_ABORT; } + return; + } - if (sl_pck->stream->pid != import->trackID) return; + if (sl_pck->stream->pid != import->trackID) return; - /* we create a track for the stream to import only if it was not created */ - if (!gf_isom_get_track_by_id(import->dest, (import->esd?import->esd->ESID:import->trackID))) { - u32 mtype, stype, oti; - mtype = stype = oti = 0; - import->esd = gf_m2ts_get_esd(sl_pck->stream); - m2ts_set_track_mpeg4_creation_info(import, &mtype, &stype, &oti); - m2ts_create_track(tsimp, mtype, stype, oti, sl_pck->stream->mpeg4_es_id, 0); - } + /* we create a track for the stream to import only if it was not created */ + if (!gf_isom_get_track_by_id(import->dest, (import->esd?import->esd->ESID:import->trackID))) { + u32 mtype, stype, oti; + mtype = stype = oti = 0; + import->esd = gf_m2ts_get_esd(sl_pck->stream); + m2ts_set_track_mpeg4_creation_info(import, &mtype, &stype, &oti); + m2ts_create_track(tsimp, mtype, stype, oti, sl_pck->stream->mpeg4_es_id, 0); + } - if (import->esd) { - GF_SLHeader hdr; - u32 hdr_len; - gf_sl_depacketize(import->esd->slConfig, &hdr, sl_pck->data, sl_pck->data_len, &hdr_len); + if (import->esd) { + GF_SLHeader hdr; + u32 hdr_len; + gf_sl_depacketize(import->esd->slConfig, &hdr, sl_pck->data, sl_pck->data_len, &hdr_len); - if (!hdr.accessUnitStartFlag) { - e = gf_isom_append_sample_data(import->dest, tsimp->track, sl_pck->data + hdr_len, sl_pck->data_len - hdr_len); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] Error appending sample data\n")); + if (!hdr.accessUnitStartFlag) { + e = gf_isom_append_sample_data(import->dest, tsimp->track, sl_pck->data + hdr_len, sl_pck->data_len - hdr_len); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] Error appending sample data\n")); + } + } else { + if (!(sl_pck->stream->flags & GF_M2TS_ES_FIRST_DTS)) { + sl_pck->stream->flags |= GF_M2TS_ES_FIRST_DTS; + + if (!hdr.compositionTimeStampFlag) { + hdr.compositionTimeStamp = sl_pck->stream->program->first_dts; + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d First SL Access unit start flag set without any composition time stamp - defaulting to last CTS seen on program\n", sl_pck->stream->pid)); + } + sl_pck->stream->first_dts = (hdr.decodingTimeStamp?hdr.decodingTimeStamp:hdr.compositionTimeStamp); + if (!sl_pck->stream->program->first_dts || + sl_pck->stream->program->first_dts > sl_pck->stream->first_dts) { + sl_pck->stream->program->first_dts = sl_pck->stream->first_dts; } } else { - if (!(sl_pck->stream->flags & GF_M2TS_ES_FIRST_DTS)) { - sl_pck->stream->flags |= GF_M2TS_ES_FIRST_DTS; - - if (!hdr.compositionTimeStampFlag) { - hdr.compositionTimeStamp = sl_pck->stream->program->first_dts; - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d First SL Access unit start flag set without any composition time stamp - defaulting to last CTS seen on program\n", sl_pck->stream->pid)); - } - sl_pck->stream->first_dts = (hdr.decodingTimeStamp?hdr.decodingTimeStamp:hdr.compositionTimeStamp); - if (!sl_pck->stream->program->first_dts || - sl_pck->stream->program->first_dts > sl_pck->stream->first_dts) { - sl_pck->stream->program->first_dts = sl_pck->stream->first_dts; - } - } else { - if (!hdr.compositionTimeStampFlag) { - hdr.compositionTimeStamp = sl_pck->stream->first_dts + tsimp->last_dts+1; - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d SL Access unit start flag set without any composition time stamp - defaulting to last CTS seen on stream + 1\n", sl_pck->stream->pid)); - } + if (!hdr.compositionTimeStampFlag) { + hdr.compositionTimeStamp = sl_pck->stream->first_dts + tsimp->last_dts+1; + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d SL Access unit start flag set without any composition time stamp - defaulting to last CTS seen on stream + 1\n", sl_pck->stream->pid)); } + } - samp = gf_isom_sample_new(); - samp->DTS = (hdr.decodingTimeStamp?hdr.decodingTimeStamp:hdr.compositionTimeStamp); - samp->CTS_Offset = (u32) (hdr.compositionTimeStamp - samp->DTS); - if (samp->DTS >= sl_pck->stream->first_dts) { - samp->DTS -= sl_pck->stream->first_dts; - samp->IsRAP = import->esd->slConfig->useRandomAccessPointFlag ? hdr.randomAccessPointFlag: 1; + samp = gf_isom_sample_new(); + samp->DTS = (hdr.decodingTimeStamp?hdr.decodingTimeStamp:hdr.compositionTimeStamp); + samp->CTS_Offset = (u32) (hdr.compositionTimeStamp - samp->DTS); + if (samp->DTS >= sl_pck->stream->first_dts) { + samp->DTS -= sl_pck->stream->first_dts; + samp->IsRAP = import->esd->slConfig->useRandomAccessPointFlag ? hdr.randomAccessPointFlag: 1; - /*fix for some DMB streams where TSs are not coded*/ - if ((tsimp->last_dts == samp->DTS) && gf_isom_get_sample_count(import->dest, tsimp->track)) - samp->DTS += gf_isom_get_media_timescale(import->dest, tsimp->track); + /*fix for some DMB streams where TSs are not coded*/ + if ((tsimp->last_dts == samp->DTS) && gf_isom_get_sample_count(import->dest, tsimp->track)) + samp->DTS += gf_isom_get_media_timescale(import->dest, tsimp->track); - samp->data = sl_pck->data + hdr_len; - samp->dataLength = sl_pck->data_len - hdr_len; + samp->data = sl_pck->data + hdr_len; + samp->dataLength = sl_pck->data_len - hdr_len; - e = gf_isom_add_sample(import->dest, tsimp->track, 1, samp); - /*if CTS was not specified, samples will simply be skipped*/ - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d Error adding sample\n", sl_pck->stream->pid)); - } - if (import->duration && (import->duration<=(samp->DTS+samp->CTS_Offset)/90)) { - //import->flags |= GF_IMPORT_DO_ABORT; - } - tsimp->last_dts = samp->DTS; + e = gf_isom_add_sample(import->dest, tsimp->track, 1, samp); + /*if CTS was not specified, samples will simply be skipped*/ + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] PID %d Error adding sample\n", sl_pck->stream->pid)); + } + if (import->duration && (import->duration<=(samp->DTS+samp->CTS_Offset)/90)) { + //import->flags |= GF_IMPORT_DO_ABORT; + } + tsimp->last_dts = samp->DTS; - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] negative time sample - skipping\n")); - sl_pck->stream->first_dts = samp->DTS; - if (!sl_pck->stream->program->first_dts || - sl_pck->stream->program->first_dts > sl_pck->stream->first_dts) { - sl_pck->stream->program->first_dts = sl_pck->stream->first_dts; - } + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS Import] negative time sample - skipping\n")); + sl_pck->stream->first_dts = samp->DTS; + if (!sl_pck->stream->program->first_dts || + sl_pck->stream->program->first_dts > sl_pck->stream->first_dts) { + sl_pck->stream->program->first_dts = sl_pck->stream->first_dts; } - samp->data = NULL; - gf_isom_sample_del(&samp); } + samp->data = NULL; + gf_isom_sample_del(&samp); } } - break; + } + break; } } /* Warning: we start importing only after finding the PMT */ @@ -7792,8 +7961,8 @@ GF_Err gf_import_mpeg_ts(GF_MediaImporter *import) import->last_error = GF_OK; if (tsimp.avccfg) gf_odf_avc_cfg_del(tsimp.avccfg); if (tsimp.hevccfg) gf_odf_hevc_cfg_del(tsimp.hevccfg); - gf_m2ts_demux_del(ts); - fclose(mts); + gf_m2ts_demux_del(ts); + fclose(mts); return e; } import->esd = NULL; @@ -7805,11 +7974,11 @@ GF_Err gf_import_mpeg_ts(GF_MediaImporter *import) if (!(import->flags & GF_IMPORT_PROBE_ONLY)) { es = (GF_M2TS_ES *)ts->ess[import->trackID]; - if (!es) { - gf_m2ts_demux_del(ts); - fclose(mts); - return gf_import_message(import, GF_BAD_PARAM, "Unknown PID %d", import->trackID); - } + if (!es) { + gf_m2ts_demux_del(ts); + fclose(mts); + return gf_import_message(import, GF_BAD_PARAM, "Unknown PID %d", import->trackID); + } if (tsimp.avccfg) { u32 w = ((GF_M2TS_PES*)es)->vid_w; @@ -7841,7 +8010,7 @@ GF_Err gf_import_mpeg_ts(GF_MediaImporter *import) if (tsimp.track) { MP4T_RecomputeBitRate(import->dest, tsimp.track); /* creation of the edit lists */ - if ((es->first_dts != es->program->first_dts) && gf_isom_get_sample_count(import->dest, tsimp.track) ){ + if ((es->first_dts != es->program->first_dts) && gf_isom_get_sample_count(import->dest, tsimp.track) ) { u32 media_ts, moov_ts, offset; u64 dur; Double pdur, poffset; @@ -8035,10 +8204,10 @@ GF_Err gf_import_vobsub(GF_MediaImporter *import) } if (*(u32*)&buf[0x00] != 0xba010000 || - *(u32*)&buf[0x0e] != 0xbd010000 || - !(buf[0x15] & 0x80) || - (buf[0x17] & 0xf0) != 0x20 || - (buf[buf[0x16] + 0x17] & 0xe0) != 0x20) + *(u32*)&buf[0x0e] != 0xbd010000 || + !(buf[0x15] & 0x80) || + (buf[0x17] & 0xf0) != 0x20 || + (buf[buf[0x16] + 0x17] & 0xe0) != 0x20) { gf_import_message(import, GF_CORRUPTED_DATA, "Corrupted data found in file %s", filename); continue; @@ -8087,7 +8256,7 @@ GF_Err gf_import_vobsub(GF_MediaImporter *import) samp->data = packet; samp->dataLength = psize; samp->DTS = pos->start * 90; - + if (last_dts && (last_dts >= samp->DTS)) { err = gf_import_message(import, GF_CORRUPTED_DATA, "Out of order timestamps in vobsub file"); goto error; @@ -8282,19 +8451,19 @@ GF_Err gf_media_import_chapters_file(GF_MediaImporter *import) if (!f) return GF_URL_ERROR; readen = (u32) fread(line, 1, 4, f); - if (readen < 4){ + if (readen < 4) { e = GF_URL_ERROR; goto err_exit; } offset = 0; if ((line[0]==(char)(0xFF)) && (line[1]==(char)(0xFE))) { - if (!line[2] && !line[3]){ + if (!line[2] && !line[3]) { e = GF_NOT_SUPPORTED; goto err_exit; } offset = 2; } else if ((line[0]==(char)(0xFE)) && (line[1]==(char)(0xFF))) { - if (!line[2] && !line[3]){ + if (!line[2] && !line[3]) { e = GF_NOT_SUPPORTED; goto err_exit; } @@ -8354,7 +8523,7 @@ GF_Err gf_media_import_chapters_file(GF_MediaImporter *import) GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[Chapter import] Guessed video frame rate %g (%u:%u)\n", import->video_fps, ts, inc)); break; } - if (!import->video_fps) + if (!import->video_fps) import->video_fps = 25; } @@ -8369,7 +8538,10 @@ GF_Err gf_media_import_chapters_file(GF_MediaImporter *import) u32 len = (u32) strlen(line); if (!len) break; switch (line[len-1]) { - case '\n': case '\t': case '\r': case ' ': + case '\n': + case '\t': + case '\r': + case ' ': line[len-1] = 0; continue; } @@ -8388,13 +8560,19 @@ GF_Err gf_media_import_chapters_file(GF_MediaImporter *import) ts = nb_fr; ts *= 1000; ts = (u64) (((s64) ts ) / import->video_fps); - sL = strchr(sL, ','); strcpy(szTitle, sL+1); sL = strrchr(szTitle, ')'); if (sL) sL[0] = 0; + sL = strchr(sL, ','); + strcpy(szTitle, sL+1); + sL = strrchr(szTitle, ')'); + if (sL) sL[0] = 0; } else if (!strnicmp(sL, "AddChapterBySecond(", 19)) { u32 nb_s; sscanf(sL, "AddChapterBySecond(%u,%s)", &nb_s, szTitle); ts = nb_s; ts *= 1000; - sL = strchr(sL, ','); strcpy(szTitle, sL+1); sL = strrchr(szTitle, ')'); if (sL) sL[0] = 0; + sL = strchr(sL, ','); + strcpy(szTitle, sL+1); + sL = strrchr(szTitle, ')'); + if (sL) sL[0] = 0; } else if (!strnicmp(sL, "AddChapterByTime(", 17)) { u32 h, m, s; sscanf(sL, "AddChapterByTime(%u,%u,%u,%s)", &h, &m, &s, szTitle); @@ -8403,7 +8581,9 @@ GF_Err gf_media_import_chapters_file(GF_MediaImporter *import) sL = strchr(sL, ','); if (sL) sL = strchr(sL+1, ','); if (sL) sL = strchr(sL+1, ','); - strcpy(szTitle, sL+1); sL = strrchr(szTitle, ')'); if (sL) sL[0] = 0; + strcpy(szTitle, sL+1); + sL = strrchr(szTitle, ')'); + if (sL) sL[0] = 0; } /*regular or SMPTE time codes*/ else if ((strlen(sL)>=8) && (sL[2]==':') && (sL[5]==':')) { @@ -8569,9 +8749,9 @@ GF_Err gf_media_import(GF_MediaImporter *importer) #ifndef GPAC_DISABLE_MPEG2PS /*MPEG PS*/ if (!strnicmp(ext, ".mpg", 4) || !strnicmp(ext, ".mpeg", 5) - || !strnicmp(ext, ".vob", 4) || !strnicmp(ext, ".vcd", 4) || !strnicmp(ext, ".svcd", 5) - || !stricmp(fmt, "MPEG1") || !stricmp(fmt, "MPEG-PS") || !stricmp(fmt, "MPEG2-PS") - ) { + || !strnicmp(ext, ".vob", 4) || !strnicmp(ext, ".vcd", 4) || !strnicmp(ext, ".svcd", 5) + || !stricmp(fmt, "MPEG1") || !stricmp(fmt, "MPEG-PS") || !stricmp(fmt, "MPEG2-PS") + ) { e = gf_import_mpeg_ps_video(importer); if (e) return e; return gf_import_mpeg_ps_audio(importer); @@ -8581,11 +8761,11 @@ GF_Err gf_media_import(GF_MediaImporter *importer) #ifndef GPAC_DISABLE_MPEG2TS /*MPEG-2 TS*/ if (!strnicmp(ext, ".ts", 3) || !strnicmp(ext, ".m2t", 4) - || !stricmp(fmt, "MPEGTS") || !stricmp(fmt, "MPEG-TS") - || !stricmp(fmt, "MPGTS") || !stricmp(fmt, "MPG-TS") - || !stricmp(fmt, "MPEG2TS") || !stricmp(fmt, "MPEG2-TS") - || !stricmp(fmt, "MPG2TS") || !stricmp(fmt, "MPG2-TS") - ) { + || !stricmp(fmt, "MPEGTS") || !stricmp(fmt, "MPEG-TS") + || !stricmp(fmt, "MPGTS") || !stricmp(fmt, "MPG-TS") + || !stricmp(fmt, "MPEG2TS") || !stricmp(fmt, "MPEG2-TS") + || !stricmp(fmt, "MPG2TS") || !stricmp(fmt, "MPG2-TS") + ) { return gf_import_mpeg_ts(importer); } #endif @@ -8608,12 +8788,12 @@ GF_Err gf_media_import(GF_MediaImporter *importer) return gf_import_h263(importer); /*H264/AVC video*/ if (!strnicmp(ext, ".h264", 5) || !strnicmp(ext, ".264", 4) || !strnicmp(ext, ".x264", 5) - || !strnicmp(ext, ".h26L", 5) || !strnicmp(ext, ".26l", 4) - || !stricmp(fmt, "AVC") || !stricmp(fmt, "H264") ) + || !strnicmp(ext, ".h26L", 5) || !strnicmp(ext, ".26l", 4) + || !stricmp(fmt, "AVC") || !stricmp(fmt, "H264") ) return gf_import_avc_h264(importer); /*HEVC video*/ if (!strnicmp(ext, ".hevc", 5) || !strnicmp(ext, ".hvc", 4) || !strnicmp(ext, ".265", 4) || !strnicmp(ext, ".shvc", 5) - || !stricmp(fmt, "HEVC") || !stricmp(fmt, "SHVC") || !stricmp(fmt, "H265") ) + || !stricmp(fmt, "HEVC") || !stricmp(fmt, "SHVC") || !stricmp(fmt, "H265") ) return gf_import_hevc(importer); /*AC3*/ if (!strnicmp(ext, ".ac3", 4) || !stricmp(fmt, "AC3") ) @@ -8631,7 +8811,7 @@ GF_Err gf_media_import(GF_MediaImporter *importer) return gf_import_still_image(importer, 1); /*AMR & 3GPP2 speec codecs*/ if (!strnicmp(ext, ".amr", 4) || !strnicmp(ext, ".awb", 4) || !strnicmp(ext, ".smv", 4) || !strnicmp(ext, ".evc", 4) - || !stricmp(fmt, "AMR") || !stricmp(fmt, "EVRC") || !stricmp(fmt, "SMV") ) + || !stricmp(fmt, "AMR") || !stricmp(fmt, "EVRC") || !stricmp(fmt, "SMV") ) return gf_import_amr_evrc_smv(importer); /*QCelp & other in QCP file format*/ if (!strnicmp(ext, ".qcp", 4) || !stricmp(fmt, "QCELP") ) @@ -8641,11 +8821,11 @@ GF_Err gf_media_import(GF_MediaImporter *importer) return gf_import_saf(importer); /*text subtitles*/ if (!strnicmp(ext, ".srt", 4) || !strnicmp(ext, ".sub", 4) || !strnicmp(ext, ".ttxt", 5) || !strnicmp(ext, ".vtt", 4) || !strnicmp(ext, ".ttml", 5) - || !stricmp(fmt, "SRT") || !stricmp(fmt, "SUB") || !stricmp(fmt, "TEXT") || !stricmp(fmt, "VTT") || !stricmp(fmt, "TTML")) { + || !stricmp(fmt, "SRT") || !stricmp(fmt, "SUB") || !stricmp(fmt, "TEXT") || !stricmp(fmt, "VTT") || !stricmp(fmt, "TTML")) { #ifndef GPAC_DISABLE_TTXT - return gf_import_timed_text(importer); + return gf_import_timed_text(importer); #else - return GF_NOT_SUPPORTED; + return GF_NOT_SUPPORTED; #endif } /*VobSub*/ diff --git a/src/media_tools/mpd.c b/src/media_tools/mpd.c index 70708a4..842bd86 100644 --- a/src/media_tools/mpd.c +++ b/src/media_tools/mpd.c @@ -176,7 +176,7 @@ GF_Err gf_mpd_parse_base_url(GF_List *container, GF_XMLNode *node) u32 i; GF_Err e; GF_XMLAttribute *att; - GF_MPD_BaseURL *url; + GF_MPD_BaseURL *url; GF_SAFEALLOC(url, GF_MPD_BaseURL); if (! url) return GF_OUT_OF_MEM; e = gf_list_add(container, url); @@ -277,7 +277,7 @@ static void gf_mpd_parse_segment_base_generic(GF_MPD *mpd, GF_MPD_SegmentBase *s else if (!strcmp(att->name, "timeShiftBufferDepth")) seg->time_shift_buffer_depth = gf_mpd_parse_duration(att->value); } - if (mpd->type == GF_MPD_TYPE_STATIC) + if (mpd->type == GF_MPD_TYPE_STATIC) seg->time_shift_buffer_depth = 0; i = 0; @@ -302,18 +302,18 @@ static GF_MPD_SegmentTimeline *gf_mpd_parse_segment_timeline(GF_MPD *mpd, GF_XML while ( (child = gf_list_enum(root->content, &i))) { if (!gf_mpd_valid_child(mpd, child)) continue; if (!strcmp(child->name, "S")) { - GF_MPD_SegmentTimelineEntry *segent; - GF_SAFEALLOC(segent, GF_MPD_SegmentTimelineEntry); - gf_list_add(seg->entries, segent); + GF_MPD_SegmentTimelineEntry *seg_tl_ent; + GF_SAFEALLOC(seg_tl_ent, GF_MPD_SegmentTimelineEntry); + gf_list_add(seg->entries, seg_tl_ent); j = 0; while ( (att = gf_list_enum(child->attributes, &j)) ) { - if (!strcmp(att->name, "t")) - segent->start_time = gf_mpd_parse_long_int(att->value); - else if (!strcmp(att->name, "d")) - segent->duration = gf_mpd_parse_int(att->value); - else if (!strcmp(att->name, "r")) - segent->repeat_count = gf_mpd_parse_int(att->value); + if (!strcmp(att->name, "t")) + seg_tl_ent->start_time = gf_mpd_parse_long_int(att->value); + else if (!strcmp(att->name, "d")) + seg_tl_ent->duration = gf_mpd_parse_int(att->value); + else if (!strcmp(att->name, "r")) + seg_tl_ent->repeat_count = (u32) gf_mpd_parse_int(att->value); } } } @@ -432,6 +432,17 @@ static GF_Err gf_mpd_parse_content_component(GF_List *container, GF_XMLNode *roo static GF_Err gf_mpd_parse_descriptor(GF_List *container, GF_XMLNode *root) { + GF_XMLAttribute *att; + GF_MPD_Descriptor *mpd_desc; + u32 i = 0; + + GF_SAFEALLOC(mpd_desc, GF_MPD_Descriptor); + while ( (att = gf_list_enum(root->attributes, &i)) ) { + if (!strcmp(att->name, "schemeIdUri")) mpd_desc->scheme_id_uri = gf_mpd_parse_string(att->value); + else if (!strcmp(att->name, "value")) mpd_desc->value = gf_mpd_parse_string(att->value); + else if (!strcmp(att->name, "id")) mpd_desc->id = gf_mpd_parse_string(att->value); + } + gf_list_add(container, mpd_desc); return GF_OK; } @@ -441,7 +452,7 @@ static void gf_mpd_parse_common_representation(GF_MPD *mpd, GF_MPD_CommonAttribu GF_XMLNode *child; u32 i = 0; - /*setup some default*/ + /*setup some default*/ com->max_playout_rate = 1.0; while ( (att = gf_list_enum(root->attributes, &i)) ) { @@ -477,7 +488,13 @@ static void gf_mpd_parse_common_representation(GF_MPD *mpd, GF_MPD_CommonAttribu gf_mpd_parse_content_component(com->audio_channels, child); } else if (!strcmp(child->name, "ContentProtection")) { - gf_mpd_parse_content_component(com->content_protection, child); + gf_mpd_parse_descriptor(com->content_protection, child); + } + else if (!strcmp(child->name, "EssentialProperty")) { + gf_mpd_parse_descriptor(com->essential_properties, child); + } + else if (!strcmp(child->name, "SupplementalProperty")) { + gf_mpd_parse_descriptor(com->supplemental_properties, child); } } } @@ -486,6 +503,8 @@ static void gf_mpd_init_common_attributes(GF_MPD_CommonAttributes *com) { com->audio_channels = gf_list_new(); com->content_protection = gf_list_new(); + com->essential_properties = gf_list_new(); + com->supplemental_properties = gf_list_new(); com->frame_packing = gf_list_new(); } static GF_Err gf_mpd_parse_representation(GF_MPD *mpd, GF_List *container, GF_XMLNode *root) @@ -531,10 +550,10 @@ static GF_Err gf_mpd_parse_representation(GF_MPD *mpd, GF_List *container, GF_XM rep->segment_template = gf_mpd_parse_segment_template(mpd, child); } else if (!strcmp(child->name, "SubRepresentation")) { -/*TODO - e = gf_mpd_parse_subrepresentation(rep->sub_representations, child); - if (e) return e; -*/ + /*TODO + e = gf_mpd_parse_subrepresentation(rep->sub_representations, child); + if (e) return e; + */ } } return GF_OK; @@ -790,8 +809,11 @@ void gf_mpd_segment_template_free(void *_item) } void gf_mpd_descriptor_free(void *item) { - GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD] descriptor not implemented\n")); - gf_free(item); + GF_MPD_Descriptor *mpd_desc = (GF_MPD_Descriptor*) item; + if (mpd_desc->id) gf_free(mpd_desc->id); + if (mpd_desc->scheme_id_uri) gf_free(mpd_desc->scheme_id_uri); + if (mpd_desc->value) gf_free(mpd_desc->value); + gf_free(mpd_desc); } void gf_mpd_content_component_free(void *item) @@ -811,6 +833,8 @@ void gf_mpd_common_attributes_free(GF_MPD_CommonAttributes *ptr) gf_mpd_del_list(ptr->frame_packing, gf_mpd_descriptor_free, 0); gf_mpd_del_list(ptr->audio_channels, gf_mpd_descriptor_free, 0); gf_mpd_del_list(ptr->content_protection, gf_mpd_descriptor_free, 0); + gf_mpd_del_list(ptr->essential_properties, gf_mpd_descriptor_free, 0); + gf_mpd_del_list(ptr->supplemental_properties, gf_mpd_descriptor_free, 0); } void gf_mpd_representation_free(void *_item) @@ -931,8 +955,8 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b att = gf_list_get(root->attributes, att_index); if (!att) { continue; - } - + } + if (!strcmp(att->name, "id")) { mpd->ID = gf_mpd_parse_string(att->value); } else if (!strcmp(att->name, "profiles")) { @@ -962,7 +986,7 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b mpd->max_subsegment_duration = gf_mpd_parse_duration(att->value); } } - if (mpd->type == GF_MPD_TYPE_STATIC) + if (mpd->type == GF_MPD_TYPE_STATIC) mpd->minimum_update_period = mpd->time_shift_buffer_depth = 0; child_index = 0; @@ -995,8 +1019,8 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b GF_EXPORT GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, - const char *mpd_file, - u32 reload_count, char *mimeTypeForM3U8Segments, Bool do_import, Bool use_mpd_templates, GF_FileDownload *getter) + const char *mpd_file, + u32 reload_count, char *mimeTypeForM3U8Segments, Bool do_import, Bool use_mpd_templates, GF_FileDownload *getter) { GF_Err e; char *sep, *template_base, *template_ext; @@ -1017,7 +1041,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, pl = NULL; return e; } - if (mpd_file == NULL){ + if (mpd_file == NULL) { gf_delete_file(m3u8_file); mpd_file = m3u8_file; } @@ -1034,7 +1058,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, u32 k; char *suburl; - if (!pe->url ) + if (!pe->url ) continue; /*filter out duplicated entries (seen on M6 m3u8)*/ @@ -1051,7 +1075,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, suburl = NULL; /*not HLS*/ - if ( !strstr(pe->url, ".m3u8")) + if ( !strstr(pe->url, ".m3u8")) continue; if (strcmp(base_url, pe->url)) @@ -1074,7 +1098,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, getter->del_session(getter); #if 0 - GF_DownloadSession *sess = gf_term_download_new(service, suburl, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL); + GF_DownloadSession *sess = gf_service_download_new(service, suburl, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL); if (!sess) { gf_free(suburl); break; @@ -1083,7 +1107,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, if (e==GF_OK) { e = parse_sub_playlist(gf_dm_sess_get_cache_name(sess), &pl, suburl, prog, pe); } - gf_term_download_del(sess); + gf_service_download_del(sess); #endif gf_free(suburl); } else { /* for use in MP4Box */ @@ -1130,7 +1154,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, assert( mpd_file ); fmpd = gf_f64_open(mpd_file, "wt"); - if (!fmpd){ + if (!fmpd) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD Generator] Cannot write to temp file %s!\n", mpd_file)); variant_playlist_del(pl); return GF_IO_ERR; @@ -1175,7 +1199,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, count2 = gf_list_count(prog->bitrates); for (j = 0; jbitrates, j); - if (pe->elementType != TYPE_PLAYLIST) + if (pe->elementType != TYPE_PLAYLIST) continue; count3 = gf_list_count(pe->element.playlist.elements); @@ -1217,7 +1241,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, for (k=0; kelement.playlist.elements, k); - + if (template_width==2) sprintf(szURL, "%s%02d%s", template_base, template_idx_start + k, template_ext); else if (template_width==3) sprintf(szURL, "%s%03d%s", template_base, template_idx_start + k, template_ext); else if (template_width==4) sprintf(szURL, "%s%04d%s", template_base, template_idx_start + k, template_ext); @@ -1282,7 +1306,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, if (import.nb_tracks>1) { for (k=0; kbitrates, j); - + if (pe->elementType == TYPE_STREAM) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD] NOT SUPPORTED: M3U8 Stream\n")); } else if (pe->elementType != TYPE_PLAYLIST) { @@ -1346,7 +1370,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, if (elt && strstr(elt->url, ".aac")) is_aac = 1; - if (is_aac) + if (is_aac) fprintf(fmpd, ""); continue; } @@ -1493,7 +1517,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, fprintf(fmpd, " \n"); gf_free(base_url); - if (is_aac) + if (is_aac) fprintf(fmpd, " -->\n"); } } diff --git a/src/media_tools/mpeg2_ps.c b/src/media_tools/mpeg2_ps.c index 6518ae6..1fd83ab 100644 --- a/src/media_tools/mpeg2_ps.c +++ b/src/media_tools/mpeg2_ps.c @@ -3,19 +3,19 @@ * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ - * + * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. - * + * * The Original Code is MPEG4IP. - * + * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. - * - * Contributor(s): + * + * Contributor(s): * Bill May wmay@cisco.com */ @@ -30,25 +30,28 @@ static GFINLINE u16 convert16 (u8 *p) { #ifdef GPAC_BIG_ENDIAN - return *(u16 *)p; + return *(u16 *)p; #else - u16 val = p[0]; - val <<= 8; - return (val | p[1]); + u16 val = p[0]; + val <<= 8; + return (val | p[1]); #endif } static GFINLINE u32 convert32 (u8 *p) { #ifdef GPAC_BIG_ENDIAN - return *(u32 *)p; + return *(u32 *)p; #else - u32 val; - val = p[0]; val <<= 8; - val |= p[1]; val <<= 8; - val |= p[2]; val <<= 8; - val |= p[3]; - return val; + u32 val; + val = p[0]; + val <<= 8; + val |= p[1]; + val <<= 8; + val |= p[2]; + val <<= 8; + val |= p[3]; + return val; #endif } @@ -59,63 +62,63 @@ static GFINLINE u32 convert32 (u8 *p) */ typedef struct mpeg2ps_ts_t { - Bool have_pts; - Bool have_dts; - u64 pts; - u64 dts; + Bool have_pts; + Bool have_dts; + u64 pts; + u64 dts; } mpeg2ps_ts_t; typedef struct mpeg2ps_record_pes_t { - struct mpeg2ps_record_pes_t *next_rec; - u64 dts; - u64 location; + struct mpeg2ps_record_pes_t *next_rec; + u64 dts; + u64 location; } mpeg2ps_record_pes_t; /* * information about reading a stream */ -typedef struct mpeg2ps_stream_t -{ - mpeg2ps_record_pes_t *record_first, *record_last; - FILE *m_fd; - Bool is_video; - u8 m_stream_id; // program stream id - u8 m_substream_id; // substream, for program stream id == 0xbd - - mpeg2ps_ts_t next_pes_ts, frame_ts; - u32 frames_since_last_ts; - u64 last_ts; - - Bool have_frame_loaded; - /* - * pes_buffer processing. this contains the raw elementary stream data - */ - u8 *pes_buffer; - u32 pes_buffer_size; - u32 pes_buffer_size_max; - u32 pes_buffer_on; - u32 frame_len; - u32 pict_header_offset; // for mpeg video - - // timing information and locations. - s64 first_pes_loc; - u64 start_dts; - Bool first_pes_has_dts; - s64 end_dts_loc; - u64 end_dts; - // audio stuff - u32 freq; - u32 channels; - u32 bitrate; - u32 samples_per_frame; - u32 layer; - // video stuff - u32 h, w, par; - Double frame_rate; - s32 have_mpeg2; - Double bit_rate; - u64 ticks_per_frame; +typedef struct mpeg2ps_stream_t +{ + mpeg2ps_record_pes_t *record_first, *record_last; + FILE *m_fd; + Bool is_video; + u8 m_stream_id; // program stream id + u8 m_substream_id; // substream, for program stream id == 0xbd + + mpeg2ps_ts_t next_pes_ts, frame_ts; + u32 frames_since_last_ts; + u64 last_ts; + + Bool have_frame_loaded; + /* + * pes_buffer processing. this contains the raw elementary stream data + */ + u8 *pes_buffer; + u32 pes_buffer_size; + u32 pes_buffer_size_max; + u32 pes_buffer_on; + u32 frame_len; + u32 pict_header_offset; // for mpeg video + + // timing information and locations. + s64 first_pes_loc; + u64 start_dts; + Bool first_pes_has_dts; + s64 end_dts_loc; + u64 end_dts; + // audio stuff + u32 freq; + u32 channels; + u32 bitrate; + u32 samples_per_frame; + u32 layer; + // video stuff + u32 h, w, par; + Double frame_rate; + s32 have_mpeg2; + Double bit_rate; + u64 ticks_per_frame; } mpeg2ps_stream_t; @@ -124,15 +127,15 @@ typedef struct mpeg2ps_stream_t * information */ struct mpeg2ps_ { - mpeg2ps_stream_t *video_streams[16]; - mpeg2ps_stream_t *audio_streams[32]; - char *filename; - FILE *fd; - u64 first_dts; - u32 audio_cnt, video_cnt; - s64 end_loc; - u64 max_dts; - u64 max_time; // time is in msec. + mpeg2ps_stream_t *video_streams[16]; + mpeg2ps_stream_t *audio_streams[32]; + char *filename; + FILE *fd; + u64 first_dts; + u32 audio_cnt, video_cnt; + s64 end_loc; + u64 max_dts; + u64 max_time; // time is in msec. }; /************************************************************************* @@ -140,7 +143,7 @@ struct mpeg2ps_ { *************************************************************************/ static FILE *file_open (const char *name) { - return gf_f64_open(name, "rb"); + return gf_f64_open(name, "rb"); } static Bool file_okay (FILE *fd) @@ -150,21 +153,21 @@ static Bool file_okay (FILE *fd) static void file_close (FILE *fd) { - fclose(fd); + fclose(fd); } static Bool file_read_bytes(FILE *fd, - u8 *buffer, - u32 len) + u8 *buffer, + u32 len) { - u32 readval = (u32) fread(buffer, 1, len, fd); - return readval == len; + u32 readval = (u32) fread(buffer, 1, len, fd); + return readval == len; } // note: len could be negative. static void file_skip_bytes (FILE *fd, s32 len) { - gf_f64_seek(fd, len, SEEK_CUR); + gf_f64_seek(fd, len, SEEK_CUR); } #define file_location(__f) gf_f64_tell(__f) @@ -172,224 +175,238 @@ static void file_skip_bytes (FILE *fd, s32 len) static u64 file_size(FILE *fd) { - u64 ret; - gf_f64_seek(fd, 0, SEEK_END); - ret = gf_f64_tell(fd); - gf_f64_seek(fd, 0, SEEK_SET); - return ret; + u64 ret; + gf_f64_seek(fd, 0, SEEK_END); + ret = gf_f64_tell(fd); + gf_f64_seek(fd, 0, SEEK_SET); + return ret; } static mpeg2ps_record_pes_t *create_record (s64 loc, u64 ts) { - mpeg2ps_record_pes_t *ret; - GF_SAFEALLOC(ret, mpeg2ps_record_pes_t); + mpeg2ps_record_pes_t *ret; + GF_SAFEALLOC(ret, mpeg2ps_record_pes_t); - ret->next_rec = NULL; - ret->dts = ts; - ret->location = loc; - return ret; + ret->next_rec = NULL; + ret->dts = ts; + ret->location = loc; + return ret; } #define MPEG2PS_RECORD_TIME ((u64) (5 * 90000)) void mpeg2ps_record_pts (mpeg2ps_stream_t *sptr, s64 location, mpeg2ps_ts_t *pTs) { - u64 ts; - mpeg2ps_record_pes_t *p, *q; - if (sptr->is_video) { - if (pTs->have_dts == 0) return; - ts = pTs->dts; - } else { - if (pTs->have_pts == 0) return; - ts = pTs->pts; - } - - if (sptr->record_first == NULL) { - sptr->record_first = sptr->record_last = create_record(location, ts); - return; - } - if (ts > sptr->record_last->dts) { - if (ts < MPEG2PS_RECORD_TIME + sptr->record_last->dts) return; - sptr->record_last->next_rec = create_record(location, ts); - sptr->record_last = sptr->record_last->next_rec; - return; - } - if (ts < sptr->record_first->dts) { - if (ts < MPEG2PS_RECORD_TIME + sptr->record_first->dts) return; - p = create_record(location, ts); - p->next_rec = sptr->record_first; - sptr->record_first = p; - return; - } - p = sptr->record_first; - q = p->next_rec; - - while (q != NULL && q->dts < ts) { - p = q; - q = q->next_rec; - } - if (p->dts + MPEG2PS_RECORD_TIME <= ts && - ts + MPEG2PS_RECORD_TIME <= q->dts) { - p->next_rec = create_record(location, ts); - p->next_rec->next_rec = q; - } + u64 ts; + mpeg2ps_record_pes_t *p, *q; + if (sptr->is_video) { + if (pTs->have_dts == 0) return; + ts = pTs->dts; + } else { + if (pTs->have_pts == 0) return; + ts = pTs->pts; + } + + if (sptr->record_first == NULL) { + sptr->record_first = sptr->record_last = create_record(location, ts); + return; + } + if (ts > sptr->record_last->dts) { + if (ts < MPEG2PS_RECORD_TIME + sptr->record_last->dts) return; + sptr->record_last->next_rec = create_record(location, ts); + sptr->record_last = sptr->record_last->next_rec; + return; + } + if (ts < sptr->record_first->dts) { + if (ts < MPEG2PS_RECORD_TIME + sptr->record_first->dts) return; + p = create_record(location, ts); + p->next_rec = sptr->record_first; + sptr->record_first = p; + return; + } + p = sptr->record_first; + q = p->next_rec; + + while (q != NULL && q->dts < ts) { + p = q; + q = q->next_rec; + } + if (p->dts + MPEG2PS_RECORD_TIME <= ts && + ts + MPEG2PS_RECORD_TIME <= q->dts) { + p->next_rec = create_record(location, ts); + p->next_rec->next_rec = q; + } } static Double mpeg12_frame_rate_table[16] = { - 0.0, /* Pad */ - 24000.0/1001.0, /* Official frame rates */ - 24.0, - 25.0, - 30000.0/1001.0, - 30.0, - 50.0, - ((60.0*1000.0)/1001.0), - 60.0, - - 1, /* Unofficial economy rates */ - 5, - 10, - 12, - 15, - 0, - 0, + 0.0, /* Pad */ + 24000.0/1001.0, /* Official frame rates */ + 24.0, + 25.0, + 30000.0/1001.0, + 30.0, + 50.0, + ((60.0*1000.0)/1001.0), + 60.0, + + 1, /* Unofficial economy rates */ + 5, + 10, + 12, + 15, + 0, + 0, }; #define SEQ_ID 1 -int MPEG12_ParseSeqHdr(unsigned char *pbuffer, u32 buflen, s32 *have_mpeg2, u32 *height, u32 *width, - Double *frame_rate, Double *bitrate, u32 *aspect_ratio) -{ - u32 aspect_code; - u32 framerate_code; - u32 bitrate_int; - u32 bitrate_ext; - u32 scode, ix; - s32 found = -1; - *have_mpeg2 = 0; - buflen -= 6; - bitrate_int = 0; - for (ix = 0; ix < buflen; ix++, pbuffer++) { - scode = (pbuffer[0] << 24) | (pbuffer[1] << 16) | (pbuffer[2] << 8) | - pbuffer[3]; - - if (scode == MPEG12_SEQUENCE_START_CODE) { - pbuffer += sizeof(u32); - *width = (pbuffer[0]); - *width <<= 4; - *width |= ((pbuffer[1] >> 4) &0xf); - *height = (pbuffer[1] & 0xf); - *height <<= 8; - *height |= pbuffer[2]; - aspect_code = (pbuffer[3] >> 4) & 0xf; - if (aspect_ratio != NULL) { - u32 par = 0; - switch (aspect_code) { - default: *aspect_ratio = 0; break; - case 2: par = 4; par<<=16; par |= 3; break; - case 3: par = 16; par<<=16; par |= 9; break; - case 4: par = 2; par<<=16; par |= 21; break; +int MPEG12_ParseSeqHdr(unsigned char *pbuffer, u32 buflen, s32 *have_mpeg2, u32 *height, u32 *width, + Double *frame_rate, Double *bitrate, u32 *aspect_ratio) +{ + u32 aspect_code; + u32 framerate_code; + u32 bitrate_int; + u32 bitrate_ext; + u32 scode, ix; + s32 found = -1; + *have_mpeg2 = 0; + buflen -= 6; + bitrate_int = 0; + for (ix = 0; ix < buflen; ix++, pbuffer++) { + scode = (pbuffer[0] << 24) | (pbuffer[1] << 16) | (pbuffer[2] << 8) | + pbuffer[3]; + + if (scode == MPEG12_SEQUENCE_START_CODE) { + pbuffer += sizeof(u32); + *width = (pbuffer[0]); + *width <<= 4; + *width |= ((pbuffer[1] >> 4) &0xf); + *height = (pbuffer[1] & 0xf); + *height <<= 8; + *height |= pbuffer[2]; + aspect_code = (pbuffer[3] >> 4) & 0xf; + if (aspect_ratio != NULL) { + u32 par = 0; + switch (aspect_code) { + default: + *aspect_ratio = 0; + break; + case 2: + par = 4; + par<<=16; + par |= 3; + break; + case 3: + par = 16; + par<<=16; + par |= 9; + break; + case 4: + par = 2; + par<<=16; + par |= 21; + break; + } + *aspect_ratio = par; } - *aspect_ratio = par; - } - - - framerate_code = pbuffer[3] & 0xf; - *frame_rate = mpeg12_frame_rate_table[framerate_code]; - // 18 bits - bitrate_int = (pbuffer[4] << 10) | - (pbuffer[5] << 2) | - ((pbuffer[6] >> 6) & 0x3); - *bitrate = bitrate_int; - *bitrate *= 400.0; - ix += sizeof(u32) + 7; - pbuffer += 7; - found = 0; - } else if (found == 0) { - if (scode == MPEG12_EXT_START_CODE) { - pbuffer += sizeof(u32); - ix += sizeof(u32); - switch ((pbuffer[0] >> 4) & 0xf) { - case SEQ_ID: - *have_mpeg2 = 1; - *height = ((pbuffer[1] & 0x1) << 13) | - ((pbuffer[2] & 0x80) << 5) | - (*height & 0x0fff); - *width = (((pbuffer[2] >> 5) & 0x3) << 12) | (*width & 0x0fff); - bitrate_ext = (pbuffer[2] & 0x1f) << 7; - bitrate_ext |= (pbuffer[3] >> 1) & 0x7f; - bitrate_int |= (bitrate_ext << 18); - *bitrate = bitrate_int; - *bitrate *= 400.0; - break; - default: - break; - } - pbuffer++; - ix++; - } else if (scode == MPEG12_PICTURE_START_CODE) { + + + framerate_code = pbuffer[3] & 0xf; + *frame_rate = mpeg12_frame_rate_table[framerate_code]; + // 18 bits + bitrate_int = (pbuffer[4] << 10) | + (pbuffer[5] << 2) | + ((pbuffer[6] >> 6) & 0x3); + *bitrate = bitrate_int; + *bitrate *= 400.0; + ix += sizeof(u32) + 7; + pbuffer += 7; + found = 0; + } else if (found == 0) { + if (scode == MPEG12_EXT_START_CODE) { + pbuffer += sizeof(u32); + ix += sizeof(u32); + switch ((pbuffer[0] >> 4) & 0xf) { + case SEQ_ID: + *have_mpeg2 = 1; + *height = ((pbuffer[1] & 0x1) << 13) | + ((pbuffer[2] & 0x80) << 5) | + (*height & 0x0fff); + *width = (((pbuffer[2] >> 5) & 0x3) << 12) | (*width & 0x0fff); + bitrate_ext = (pbuffer[2] & 0x1f) << 7; + bitrate_ext |= (pbuffer[3] >> 1) & 0x7f; + bitrate_int |= (bitrate_ext << 18); + *bitrate = bitrate_int; + *bitrate *= 400.0; + break; + default: + break; + } + pbuffer++; + ix++; + } else if (scode == MPEG12_PICTURE_START_CODE) { + return found; + } + } + } return found; - } - } - } - return found; } s32 MPEG12_PictHdrType (unsigned char *pbuffer) { - pbuffer += sizeof(u32); - return ((pbuffer[1] >> 3) & 0x7); + pbuffer += sizeof(u32); + return ((pbuffer[1] >> 3) & 0x7); } u16 MPEG12_PictHdrTempRef(unsigned char *pbuffer) { - pbuffer += sizeof(u32); - return ((pbuffer[0] << 2) | ((pbuffer[1] >> 6) & 0x3)); + pbuffer += sizeof(u32); + return ((pbuffer[0] << 2) | ((pbuffer[1] >> 6) & 0x3)); } static u64 read_pts (u8 *pak) { - u64 pts; - u16 temp; - - pts = ((pak[0] >> 1) & 0x7); - pts <<= 15; - temp = convert16(&pak[1]) >> 1; - pts |= temp; - pts <<= 15; - temp = convert16(&pak[3]) >> 1; - pts |= temp; - return pts; + u64 pts; + u16 temp; + + pts = ((pak[0] >> 1) & 0x7); + pts <<= 15; + temp = convert16(&pak[1]) >> 1; + pts |= temp; + pts <<= 15; + temp = convert16(&pak[3]) >> 1; + pts |= temp; + return pts; } static mpeg2ps_stream_t *mpeg2ps_stream_create (u8 stream_id, - u8 substream) -{ - mpeg2ps_stream_t *ptr; - GF_SAFEALLOC(ptr, mpeg2ps_stream_t); - ptr->m_stream_id = stream_id; - ptr->m_substream_id = substream; - ptr->is_video = stream_id >= 0xe0; - ptr->pes_buffer = (u8 *)gf_malloc(4*4096); - ptr->pes_buffer_size_max = 4 * 4096; - return ptr; + u8 substream) +{ + mpeg2ps_stream_t *ptr; + GF_SAFEALLOC(ptr, mpeg2ps_stream_t); + ptr->m_stream_id = stream_id; + ptr->m_substream_id = substream; + ptr->is_video = stream_id >= 0xe0; + ptr->pes_buffer = (u8 *)gf_malloc(4*4096); + ptr->pes_buffer_size_max = 4 * 4096; + return ptr; } static void mpeg2ps_stream_destroy (mpeg2ps_stream_t *sptr) { - mpeg2ps_record_pes_t *p; - while (sptr->record_first != NULL) { - p = sptr->record_first; - sptr->record_first = p->next_rec; - gf_free(p); - } - if (sptr->m_fd != FDNULL) { - file_close(sptr->m_fd); - sptr->m_fd = FDNULL; - } - if (sptr->pes_buffer) gf_free(sptr->pes_buffer); - gf_free(sptr); + mpeg2ps_record_pes_t *p; + while (sptr->record_first != NULL) { + p = sptr->record_first; + sptr->record_first = p->next_rec; + gf_free(p); + } + if (sptr->m_fd != FDNULL) { + file_close(sptr->m_fd); + sptr->m_fd = FDNULL; + } + if (sptr->pes_buffer) gf_free(sptr->pes_buffer); + gf_free(sptr); } @@ -397,118 +414,118 @@ static void mpeg2ps_stream_destroy (mpeg2ps_stream_t *sptr) * adv_past_pack_hdr - read the pack header, advance past it * we don't do anything with the data */ -static void adv_past_pack_hdr (FILE *fd, - u8 *pak, - u32 read_from_start) -{ - u8 stuffed; - u8 readbyte; - u8 val; - if (read_from_start < 5) { - file_skip_bytes(fd, 5 - read_from_start); - file_read_bytes(fd, &readbyte, 1); - val = readbyte; - } else { - val = pak[4]; - } - - // we've read 6 bytes - if ((val & 0xc0) != 0x40) { - // mpeg1 - file_skip_bytes(fd, 12 - read_from_start); // skip 6 more bytes - return; - } - file_skip_bytes(fd, 13 - read_from_start); - file_read_bytes(fd, &readbyte, 1); - stuffed = readbyte & 0x7; - file_skip_bytes(fd, stuffed); +static void adv_past_pack_hdr (FILE *fd, + u8 *pak, + u32 read_from_start) +{ + u8 stuffed; + u8 readbyte; + u8 val; + if (read_from_start < 5) { + file_skip_bytes(fd, 5 - read_from_start); + file_read_bytes(fd, &readbyte, 1); + val = readbyte; + } else { + val = pak[4]; + } + + // we've read 6 bytes + if ((val & 0xc0) != 0x40) { + // mpeg1 + file_skip_bytes(fd, 12 - read_from_start); // skip 6 more bytes + return; + } + file_skip_bytes(fd, 13 - read_from_start); + file_read_bytes(fd, &readbyte, 1); + stuffed = readbyte & 0x7; + file_skip_bytes(fd, stuffed); } /* * find_pack_start - * look for the pack start code in the file - read 512 bytes at a time, + * look for the pack start code in the file - read 512 bytes at a time, * searching for that code. * Note: we may also be okay looking for >= 00 00 01 bb */ -static Bool find_pack_start (FILE *fd, - u8 *saved, - u32 len) -{ - u8 buffer[512]; - u32 buffer_on = 0, new_offset, scode; - memcpy(buffer, saved, len); - if (file_read_bytes(fd, buffer + len, sizeof(buffer) - len) == 0) { - return 0; - } - while (1) { - if (gf_mv12_next_start_code(buffer + buffer_on, - sizeof(buffer) - buffer_on, - &new_offset, - &scode) >= 0) { - buffer_on += new_offset; - if (scode == MPEG2_PS_PACKSTART) { - file_skip_bytes(fd, buffer_on - 512); // go back to header - return 1; - } - buffer_on += 1; - } else { - len = 0; - if (buffer[sizeof(buffer) - 3] == 0 && - buffer[sizeof(buffer) - 2] == 0 && - buffer[sizeof(buffer) - 1] == 1) { - buffer[0] = 0; - buffer[1] = 0; - buffer[2] = 1; - len = 3; - } else if (*(u16 *)(buffer + sizeof(buffer) - 2) == 0) { - buffer[0] = 0; - buffer[1] = 0; - len = 2; - } else if (buffer[sizeof(buffer) - 1] == 0) { - buffer[0] = 0; - len = 1; - } - if (file_read_bytes(fd, buffer + len, sizeof(buffer) - len) == 0) { +static Bool find_pack_start (FILE *fd, + u8 *saved, + u32 len) +{ + u8 buffer[512]; + u32 buffer_on = 0, new_offset, scode; + memcpy(buffer, saved, len); + if (file_read_bytes(fd, buffer + len, sizeof(buffer) - len) == 0) { + return 0; + } + while (1) { + if (gf_mv12_next_start_code(buffer + buffer_on, + sizeof(buffer) - buffer_on, + &new_offset, + &scode) >= 0) { + buffer_on += new_offset; + if (scode == MPEG2_PS_PACKSTART) { + file_skip_bytes(fd, buffer_on - 512); // go back to header + return 1; + } + buffer_on += 1; + } else { + len = 0; + if (buffer[sizeof(buffer) - 3] == 0 && + buffer[sizeof(buffer) - 2] == 0 && + buffer[sizeof(buffer) - 1] == 1) { + buffer[0] = 0; + buffer[1] = 0; + buffer[2] = 1; + len = 3; + } else if (*(u16 *)(buffer + sizeof(buffer) - 2) == 0) { + buffer[0] = 0; + buffer[1] = 0; + len = 2; + } else if (buffer[sizeof(buffer) - 1] == 0) { + buffer[0] = 0; + len = 1; + } + if (file_read_bytes(fd, buffer + len, sizeof(buffer) - len) == 0) { + return 0; + } + buffer_on = 0; + } + } return 0; - } - buffer_on = 0; - } - } - return 0; } /* - * copy_bytes_to_pes_buffer - read pes_len bytes into the buffer, + * copy_bytes_to_pes_buffer - read pes_len bytes into the buffer, * adjusting it if we need it */ -static void copy_bytes_to_pes_buffer (mpeg2ps_stream_t *sptr, - u16 pes_len) -{ - u32 to_move; - - if (sptr->pes_buffer_size + pes_len > sptr->pes_buffer_size_max) { - // if no room in the buffer, we'll move it - otherwise, just fill - // note - we might want a better strategy about moving the buffer - - // right now, we might be moving a number of bytes if we have a large - // followed by large frame. - to_move = sptr->pes_buffer_size - sptr->pes_buffer_on; - memmove(sptr->pes_buffer, - sptr->pes_buffer + sptr->pes_buffer_on, - to_move); - sptr->pes_buffer_size = to_move; - sptr->pes_buffer_on = 0; - //fprintf(stderr, "moving %d bytes\n", to_move); - if (to_move + pes_len > sptr->pes_buffer_size_max) { - sptr->pes_buffer = (u8 *)gf_realloc(sptr->pes_buffer, - to_move + pes_len + 2048); - sptr->pes_buffer_size_max = to_move + pes_len + 2048; - } - } - file_read_bytes(sptr->m_fd, sptr->pes_buffer + sptr->pes_buffer_size, pes_len); - sptr->pes_buffer_size += pes_len; +static void copy_bytes_to_pes_buffer (mpeg2ps_stream_t *sptr, + u16 pes_len) +{ + u32 to_move; + + if (sptr->pes_buffer_size + pes_len > sptr->pes_buffer_size_max) { + // if no room in the buffer, we'll move it - otherwise, just fill + // note - we might want a better strategy about moving the buffer - + // right now, we might be moving a number of bytes if we have a large + // followed by large frame. + to_move = sptr->pes_buffer_size - sptr->pes_buffer_on; + memmove(sptr->pes_buffer, + sptr->pes_buffer + sptr->pes_buffer_on, + to_move); + sptr->pes_buffer_size = to_move; + sptr->pes_buffer_on = 0; + //fprintf(stderr, "moving %d bytes\n", to_move); + if (to_move + pes_len > sptr->pes_buffer_size_max) { + sptr->pes_buffer = (u8 *)gf_realloc(sptr->pes_buffer, + to_move + pes_len + 2048); + sptr->pes_buffer_size_max = to_move + pes_len + 2048; + } + } + file_read_bytes(sptr->m_fd, sptr->pes_buffer + sptr->pes_buffer_size, pes_len); + sptr->pes_buffer_size += pes_len; #if 0 - fprintf(stderr, "copying %u bytes - on %u size %u\n", - pes_len, sptr->pes_buffer_on, sptr->pes_buffer_size); + fprintf(stderr, "copying %u bytes - on %u size %u\n", + pes_len, sptr->pes_buffer_on, sptr->pes_buffer_size); #endif } @@ -519,50 +536,50 @@ static void copy_bytes_to_pes_buffer (mpeg2ps_stream_t *sptr, * 00 00 01 and the next byte > 0xbb. * We return the pes len to read, and the "next byte" */ -static Bool read_to_next_pes_header (FILE *fd, - u8 *stream_id, - u16 *pes_len) -{ - u32 hdr; - u8 local[6]; - - while (1) { - // read the pes header - if (file_read_bytes(fd, local, 6) == 0) { - return 0; - } - - hdr = convert32(local); - // if we're not a 00 00 01, read until we get the next pack start - // we might want to also read until next PES - look into that. - if (((hdr & MPEG2_PS_START_MASK) != MPEG2_PS_START) || - (hdr < MPEG2_PS_END)) { - if (find_pack_start(fd, local, 6) == 0) { - return 0; - } - continue; - } - if (hdr == MPEG2_PS_PACKSTART) { - // pack start code - we can skip down - adv_past_pack_hdr(fd, local, 6); - continue; - } - if (hdr == MPEG2_PS_END) { - file_skip_bytes(fd, -2); - continue; - } - - // we should have a valid stream and pes_len here... - *stream_id = hdr & 0xff; - *pes_len = convert16(local + 4); +static Bool read_to_next_pes_header (FILE *fd, + u8 *stream_id, + u16 *pes_len) +{ + u32 hdr; + u8 local[6]; + + while (1) { + // read the pes header + if (file_read_bytes(fd, local, 6) == 0) { + return 0; + } + + hdr = convert32(local); + // if we're not a 00 00 01, read until we get the next pack start + // we might want to also read until next PES - look into that. + if (((hdr & MPEG2_PS_START_MASK) != MPEG2_PS_START) || + (hdr < MPEG2_PS_END)) { + if (find_pack_start(fd, local, 6) == 0) { + return 0; + } + continue; + } + if (hdr == MPEG2_PS_PACKSTART) { + // pack start code - we can skip down + adv_past_pack_hdr(fd, local, 6); + continue; + } + if (hdr == MPEG2_PS_END) { + file_skip_bytes(fd, -2); + continue; + } + + // we should have a valid stream and pes_len here... + *stream_id = hdr & 0xff; + *pes_len = convert16(local + 4); #if 0 - fprintf(stderr, "loc: "X64" %x len %u\n", file_location(fd) - 6, - local[3], - *pes_len); + fprintf(stderr, "loc: "X64" %x len %u\n", file_location(fd) - 6, + local[3], + *pes_len); #endif - return 1; - } - return 0; + return 1; + } + return 0; } /* @@ -570,173 +587,173 @@ static Bool read_to_next_pes_header (FILE *fd, * this should read past the pes header for the audio and video streams * it will store the timestamps if it reads them */ -static Bool read_pes_header_data (FILE *fd, - u16 orig_pes_len, - u16 *pes_left, - Bool *have_ts, - mpeg2ps_ts_t *ts) -{ - u16 pes_len = orig_pes_len; - u8 local[10]; - u32 hdr_len; - - ts->have_pts = 0; - ts->have_dts = 0; - *have_ts = 0; - if (file_read_bytes(fd, local, 1) == 0) { - return 0; - } - pes_len--; // remove this first byte from length - while (*local == 0xff) { - if (file_read_bytes(fd, local, 1) == 0) { - return 0; - } - pes_len--; - if (pes_len == 0) { - *pes_left = 0; - return 1; - } - } - if ((*local & 0xc0) == 0x40) { - // buffer scale & size - file_skip_bytes(fd, 1); - if (file_read_bytes(fd, local, 1) == 0) { - return 0; - } - pes_len -= 2; - } - - if ((*local & 0xf0) == 0x20) { - // mpeg-1 with pts - if (file_read_bytes(fd, local + 1, 4) == 0) { - return 0; - } - ts->have_pts = 1; - ts->pts = ts->dts = read_pts(local); - //fprintf(stderr, "mpeg1 pts "U64"\n", ts->pts); - *have_ts = 1; - pes_len -= 4; - } else if ((*local & 0xf0) == 0x30) { - // have mpeg 1 pts and dts - if (file_read_bytes(fd, local + 1, 9) == 0) { - return 0; - } - ts->have_pts = 1; - ts->have_dts = 1; - *have_ts = 1; - ts->pts = read_pts(local); - ts->dts = read_pts(local + 5); - pes_len -= 9; - } else if ((*local & 0xc0) == 0x80) { - // mpeg2 pes header - we're pointing at the flags field now - if (file_read_bytes(fd, local + 1, 2) == 0) { - return 0; - } - hdr_len = local[2]; - pes_len -= hdr_len + 2; // first byte removed already - if ((local[1] & 0xc0) == 0x80) { - // just pts - ts->have_pts = 1; - file_read_bytes(fd, local, 5); - ts->pts = ts->dts = read_pts(local); - *have_ts = 1; - hdr_len -= 5; - } else if ((local[1] & 0xc0) == 0xc0) { - // pts and dts - ts->have_pts = 1; - ts->have_dts = 1; - *have_ts = 1; - file_read_bytes(fd, local, 10); - ts->pts = read_pts(local); - ts->dts = read_pts(local + 5); - hdr_len -= 10; - } - file_skip_bytes(fd, hdr_len); - } else if (*local != 0xf) { - file_skip_bytes(fd, pes_len); - pes_len = 0; - } - *pes_left = pes_len; - return 1; +static Bool read_pes_header_data (FILE *fd, + u16 orig_pes_len, + u16 *pes_left, + Bool *have_ts, + mpeg2ps_ts_t *ts) +{ + u16 pes_len = orig_pes_len; + u8 local[10]; + u32 hdr_len; + + ts->have_pts = 0; + ts->have_dts = 0; + *have_ts = 0; + if (file_read_bytes(fd, local, 1) == 0) { + return 0; + } + pes_len--; // remove this first byte from length + while (*local == 0xff) { + if (file_read_bytes(fd, local, 1) == 0) { + return 0; + } + pes_len--; + if (pes_len == 0) { + *pes_left = 0; + return 1; + } + } + if ((*local & 0xc0) == 0x40) { + // buffer scale & size + file_skip_bytes(fd, 1); + if (file_read_bytes(fd, local, 1) == 0) { + return 0; + } + pes_len -= 2; + } + + if ((*local & 0xf0) == 0x20) { + // mpeg-1 with pts + if (file_read_bytes(fd, local + 1, 4) == 0) { + return 0; + } + ts->have_pts = 1; + ts->pts = ts->dts = read_pts(local); + //fprintf(stderr, "mpeg1 pts "U64"\n", ts->pts); + *have_ts = 1; + pes_len -= 4; + } else if ((*local & 0xf0) == 0x30) { + // have mpeg 1 pts and dts + if (file_read_bytes(fd, local + 1, 9) == 0) { + return 0; + } + ts->have_pts = 1; + ts->have_dts = 1; + *have_ts = 1; + ts->pts = read_pts(local); + ts->dts = read_pts(local + 5); + pes_len -= 9; + } else if ((*local & 0xc0) == 0x80) { + // mpeg2 pes header - we're pointing at the flags field now + if (file_read_bytes(fd, local + 1, 2) == 0) { + return 0; + } + hdr_len = local[2]; + pes_len -= hdr_len + 2; // first byte removed already + if ((local[1] & 0xc0) == 0x80) { + // just pts + ts->have_pts = 1; + file_read_bytes(fd, local, 5); + ts->pts = ts->dts = read_pts(local); + *have_ts = 1; + hdr_len -= 5; + } else if ((local[1] & 0xc0) == 0xc0) { + // pts and dts + ts->have_pts = 1; + ts->have_dts = 1; + *have_ts = 1; + file_read_bytes(fd, local, 10); + ts->pts = read_pts(local); + ts->dts = read_pts(local + 5); + hdr_len -= 10; + } + file_skip_bytes(fd, hdr_len); + } else if (*local != 0xf) { + file_skip_bytes(fd, pes_len); + pes_len = 0; + } + *pes_left = pes_len; + return 1; } -static Bool search_for_next_pes_header (mpeg2ps_stream_t *sptr, - u16 *pes_len, - Bool *have_ts, - s64 *found_loc) -{ - u8 stream_id; - u8 local; - s64 loc; - while (1) { - // this will read until we find the next pes. We don't know if the - // stream matches - this will read over pack headers - if (read_to_next_pes_header(sptr->m_fd, &stream_id, pes_len) == 0) { - return 0; - } - - if (stream_id != sptr->m_stream_id) { - file_skip_bytes(sptr->m_fd, *pes_len); - continue; - } - loc = file_location(sptr->m_fd) - 6; - // advance past header, reading pts - if (read_pes_header_data(sptr->m_fd, - *pes_len, - pes_len, - have_ts, - &sptr->next_pes_ts) == 0) { - return 0; - } - - // If we're looking at a private stream, make sure that the sub-stream - // matches. - if (sptr->m_stream_id == 0xbd) { - // ac3 or pcm - file_read_bytes(sptr->m_fd, &local, 1); - *pes_len -= 1; - if (local != sptr->m_substream_id) { - file_skip_bytes(sptr->m_fd, *pes_len); - continue; // skip to the next one - } - *pes_len -= 3; - file_skip_bytes(sptr->m_fd, 3); // 4 bytes - we don't need now... - // we need more here... - } - if (have_ts) { - mpeg2ps_record_pts(sptr, loc, &sptr->next_pes_ts); - } - if (found_loc != NULL) *found_loc = loc; - return 1; - } - return 0; +static Bool search_for_next_pes_header (mpeg2ps_stream_t *sptr, + u16 *pes_len, + Bool *have_ts, + s64 *found_loc) +{ + u8 stream_id; + u8 local; + s64 loc; + while (1) { + // this will read until we find the next pes. We don't know if the + // stream matches - this will read over pack headers + if (read_to_next_pes_header(sptr->m_fd, &stream_id, pes_len) == 0) { + return 0; + } + + if (stream_id != sptr->m_stream_id) { + file_skip_bytes(sptr->m_fd, *pes_len); + continue; + } + loc = file_location(sptr->m_fd) - 6; + // advance past header, reading pts + if (read_pes_header_data(sptr->m_fd, + *pes_len, + pes_len, + have_ts, + &sptr->next_pes_ts) == 0) { + return 0; + } + + // If we're looking at a private stream, make sure that the sub-stream + // matches. + if (sptr->m_stream_id == 0xbd) { + // ac3 or pcm + file_read_bytes(sptr->m_fd, &local, 1); + *pes_len -= 1; + if (local != sptr->m_substream_id) { + file_skip_bytes(sptr->m_fd, *pes_len); + continue; // skip to the next one + } + *pes_len -= 3; + file_skip_bytes(sptr->m_fd, 3); // 4 bytes - we don't need now... + // we need more here... + } + if (have_ts) { + mpeg2ps_record_pts(sptr, loc, &sptr->next_pes_ts); + } + if (found_loc != NULL) *found_loc = loc; + return 1; + } + return 0; } /* - * mpeg2ps_stream_read_next_pes_buffer - for the given stream, + * mpeg2ps_stream_read_next_pes_buffer - for the given stream, * go forward in the file until the next PES for the stream is read. Read * the header (pts, dts), and read the data into the pes_buffer pointer */ static Bool mpeg2ps_stream_read_next_pes_buffer (mpeg2ps_stream_t *sptr) { - u16 pes_len; - Bool have_ts; + u16 pes_len; + Bool have_ts; - if (search_for_next_pes_header(sptr, &pes_len, &have_ts, NULL) == 0) { - return 0; - } + if (search_for_next_pes_header(sptr, &pes_len, &have_ts, NULL) == 0) { + return 0; + } - copy_bytes_to_pes_buffer(sptr, pes_len); + copy_bytes_to_pes_buffer(sptr, pes_len); - return 1; + return 1; } /*************************************************************************** * Frame reading routine. For each stream, the fd's should be different. * we will read from the pes stream, and save it in the stream's pes buffer. - * This will give us raw data that we can search through for frame headers, - * and the like. We shouldn't read more than we need - when we need to read, + * This will give us raw data that we can search through for frame headers, + * and the like. We shouldn't read more than we need - when we need to read, * we'll put the whole next pes buffer in the buffer * * Audio routines are of the format: @@ -748,206 +765,206 @@ static Bool mpeg2ps_stream_read_next_pes_buffer (mpeg2ps_stream_t *sptr) * look for start header (GOP, SEQ, Picture) * look for pict header * look for next start (END, GOP, SEQ, Picture) - * + * ***************************************************************************/ #define IS_MPEG_START(a) ((a) == 0xb3 || (a) == 0x00 || (a) == 0xb8) -static Bool +static Bool mpeg2ps_stream_find_mpeg_video_frame (mpeg2ps_stream_t *sptr) { - u32 offset, scode; - Bool have_pict; - Bool started_new_pes = 0; - u32 start; - /* - * First thing - determine if we have enough bytes to read the header. - * if we do, we have the correct timestamp. If not, we read the new - * pes, so we'd want to use the timestamp we read. - */ - sptr->frame_ts = sptr->next_pes_ts; - if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 4) { - if (sptr->pes_buffer_size != sptr->pes_buffer_on) - started_new_pes = 1; - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - while (gf_mv12_next_start_code(sptr->pes_buffer + sptr->pes_buffer_on, - sptr->pes_buffer_size - sptr->pes_buffer_on, - &offset, - &scode) < 0 || - (!IS_MPEG_START(scode & 0xff))) { - if (sptr->pes_buffer_size > 3) - sptr->pes_buffer_on = sptr->pes_buffer_size - 3; - else { - sptr->pes_buffer_on = sptr->pes_buffer_size; - started_new_pes = 1; - } - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - sptr->pes_buffer_on += offset; - if (offset == 0 && started_new_pes) { - // nothing... we've copied the timestamp already. - } else { - // we found the new start, but we pulled in a new pes header before - // starting. So, we want to use the header that we read. - sptr->frame_ts = sptr->next_pes_ts; // set timestamp after searching - // clear timestamp indication - sptr->next_pes_ts.have_pts = sptr->next_pes_ts.have_dts = 0; - } + u32 offset, scode; + Bool have_pict; + Bool started_new_pes = 0; + u32 start; + /* + * First thing - determine if we have enough bytes to read the header. + * if we do, we have the correct timestamp. If not, we read the new + * pes, so we'd want to use the timestamp we read. + */ + sptr->frame_ts = sptr->next_pes_ts; + if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 4) { + if (sptr->pes_buffer_size != sptr->pes_buffer_on) + started_new_pes = 1; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + while (gf_mv12_next_start_code(sptr->pes_buffer + sptr->pes_buffer_on, + sptr->pes_buffer_size - sptr->pes_buffer_on, + &offset, + &scode) < 0 || + (!IS_MPEG_START(scode & 0xff))) { + if (sptr->pes_buffer_size > 3) + sptr->pes_buffer_on = sptr->pes_buffer_size - 3; + else { + sptr->pes_buffer_on = sptr->pes_buffer_size; + started_new_pes = 1; + } + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + sptr->pes_buffer_on += offset; + if (offset == 0 && started_new_pes) { + // nothing... we've copied the timestamp already. + } else { + // we found the new start, but we pulled in a new pes header before + // starting. So, we want to use the header that we read. + sptr->frame_ts = sptr->next_pes_ts; // set timestamp after searching + // clear timestamp indication + sptr->next_pes_ts.have_pts = sptr->next_pes_ts.have_dts = 0; + } #if 0 - fprintf(stderr, "header %x at %d\n", scode, sptr->pes_buffer_on); + fprintf(stderr, "header %x at %d\n", scode, sptr->pes_buffer_on); #endif - if (scode == MPEG12_PICTURE_START_CODE) { - sptr->pict_header_offset = sptr->pes_buffer_on; - have_pict = 1; - } else have_pict = 0; - - start = 4 + sptr->pes_buffer_on; - while (1) { - - if (gf_mv12_next_start_code(sptr->pes_buffer + start, - sptr->pes_buffer_size - start, - &offset, - &scode) < 0) { - start = sptr->pes_buffer_size - 3; - start -= sptr->pes_buffer_on; - sptr->pict_header_offset -= sptr->pes_buffer_on; - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - start += sptr->pes_buffer_on; - sptr->pict_header_offset += sptr->pes_buffer_on; - } else { + if (scode == MPEG12_PICTURE_START_CODE) { + sptr->pict_header_offset = sptr->pes_buffer_on; + have_pict = 1; + } else have_pict = 0; + + start = 4 + sptr->pes_buffer_on; + while (1) { + + if (gf_mv12_next_start_code(sptr->pes_buffer + start, + sptr->pes_buffer_size - start, + &offset, + &scode) < 0) { + start = sptr->pes_buffer_size - 3; + start -= sptr->pes_buffer_on; + sptr->pict_header_offset -= sptr->pes_buffer_on; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + start += sptr->pes_buffer_on; + sptr->pict_header_offset += sptr->pes_buffer_on; + } else { #if 0 - fprintf(stderr, "2header %x at %d\n", scode, start); + fprintf(stderr, "2header %x at %d\n", scode, start); #endif - start += offset; - if (have_pict == 0) { - if (scode == MPEG12_PICTURE_START_CODE) { - have_pict = 1; - sptr->pict_header_offset = start; - } - } else { - if (IS_MPEG_START(scode & 0xff) || - scode == MPEG12_SEQUENCE_END_START_CODE) { - sptr->frame_len = start - sptr->pes_buffer_on; - sptr->have_frame_loaded = 1; - return 1; - } - } - start += 4; - } - } - return 0; + start += offset; + if (have_pict == 0) { + if (scode == MPEG12_PICTURE_START_CODE) { + have_pict = 1; + sptr->pict_header_offset = start; + } + } else { + if (IS_MPEG_START(scode & 0xff) || + scode == MPEG12_SEQUENCE_END_START_CODE) { + sptr->frame_len = start - sptr->pes_buffer_on; + sptr->have_frame_loaded = 1; + return 1; + } + } + start += 4; + } + } + return 0; } static Bool mpeg2ps_stream_find_ac3_frame (mpeg2ps_stream_t *sptr) { - u32 diff; - GF_AC3Header hdr; - Bool started_new_pes = 0; - sptr->frame_ts = sptr->next_pes_ts; // set timestamp after searching - if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 6) { - if (sptr->pes_buffer_size != sptr->pes_buffer_on) - started_new_pes = 1; - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - while (gf_ac3_parser(sptr->pes_buffer + sptr->pes_buffer_on, - sptr->pes_buffer_size - sptr->pes_buffer_on, - &diff, - &hdr, 0) <= 0) { - // don't have frame - if (sptr->pes_buffer_size > 6) { - sptr->pes_buffer_on = sptr->pes_buffer_size - 6; - started_new_pes = 1; - } else { - sptr->pes_buffer_on = sptr->pes_buffer_size; - } - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - sptr->frame_len = hdr.framesize; - sptr->pes_buffer_on += diff; - if (diff == 0 && started_new_pes) { - // we might have a new PTS - but it's not here - } else { - sptr->frame_ts = sptr->next_pes_ts; - sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; - } - while (sptr->pes_buffer_size - sptr->pes_buffer_on < sptr->frame_len) { + u32 diff; + GF_AC3Header hdr; + Bool started_new_pes = 0; + sptr->frame_ts = sptr->next_pes_ts; // set timestamp after searching + if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 6) { + if (sptr->pes_buffer_size != sptr->pes_buffer_on) + started_new_pes = 1; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + while (gf_ac3_parser(sptr->pes_buffer + sptr->pes_buffer_on, + sptr->pes_buffer_size - sptr->pes_buffer_on, + &diff, + &hdr, 0) <= 0) { + // don't have frame + if (sptr->pes_buffer_size > 6) { + sptr->pes_buffer_on = sptr->pes_buffer_size - 6; + started_new_pes = 1; + } else { + sptr->pes_buffer_on = sptr->pes_buffer_size; + } + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + sptr->frame_len = hdr.framesize; + sptr->pes_buffer_on += diff; + if (diff == 0 && started_new_pes) { + // we might have a new PTS - but it's not here + } else { + sptr->frame_ts = sptr->next_pes_ts; + sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; + } + while (sptr->pes_buffer_size - sptr->pes_buffer_on < sptr->frame_len) { #if 0 - fprintf(stderr, "don't have enough - on %u size %u %u %u\n", sptr->pes_buffer_on, - sptr->pes_buffer_size, - sptr->pes_buffer_size - sptr->pes_buffer_on, - sptr->frame_len); + fprintf(stderr, "don't have enough - on %u size %u %u %u\n", sptr->pes_buffer_on, + sptr->pes_buffer_size, + sptr->pes_buffer_size - sptr->pes_buffer_on, + sptr->frame_len); #endif - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - sptr->have_frame_loaded = 1; - return 1; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + sptr->have_frame_loaded = 1; + return 1; } static Bool mpeg2ps_stream_find_mp3_frame (mpeg2ps_stream_t *sptr) { - u32 diff, hdr; - Bool started_new_pes = 0; - - sptr->frame_ts = sptr->next_pes_ts; - if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 4) { - if (sptr->pes_buffer_size != sptr->pes_buffer_on) - started_new_pes = 1; - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - while ((hdr=gf_mp3_get_next_header_mem((char*)sptr->pes_buffer + sptr->pes_buffer_on, - sptr->pes_buffer_size - sptr->pes_buffer_on, - &diff) ) == 0) { - // don't have frame - if (sptr->pes_buffer_size > 3) { - if (sptr->pes_buffer_on != sptr->pes_buffer_size) { - sptr->pes_buffer_on = sptr->pes_buffer_size - 3; - } - started_new_pes = 1; // we have left over bytes... - } else { - sptr->pes_buffer_on = sptr->pes_buffer_size; - } - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - // have frame. - sptr->frame_len = gf_mp3_frame_size(hdr); - sptr->pes_buffer_on += diff; - if (diff == 0 && started_new_pes) { - - } else { - sptr->frame_ts = sptr->next_pes_ts; - sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; - } - while (sptr->pes_buffer_size - sptr->pes_buffer_on < sptr->frame_len) { + u32 diff, hdr; + Bool started_new_pes = 0; + + sptr->frame_ts = sptr->next_pes_ts; + if (sptr->pes_buffer_size <= sptr->pes_buffer_on + 4) { + if (sptr->pes_buffer_size != sptr->pes_buffer_on) + started_new_pes = 1; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + while ((hdr=gf_mp3_get_next_header_mem((char*)sptr->pes_buffer + sptr->pes_buffer_on, + sptr->pes_buffer_size - sptr->pes_buffer_on, + &diff) ) == 0) { + // don't have frame + if (sptr->pes_buffer_size > 3) { + if (sptr->pes_buffer_on != sptr->pes_buffer_size) { + sptr->pes_buffer_on = sptr->pes_buffer_size - 3; + } + started_new_pes = 1; // we have left over bytes... + } else { + sptr->pes_buffer_on = sptr->pes_buffer_size; + } + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + // have frame. + sptr->frame_len = gf_mp3_frame_size(hdr); + sptr->pes_buffer_on += diff; + if (diff == 0 && started_new_pes) { + + } else { + sptr->frame_ts = sptr->next_pes_ts; + sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; + } + while (sptr->pes_buffer_size - sptr->pes_buffer_on < sptr->frame_len) { #if 0 - fprintf(stderr, "don't have enough - on %u size %u %u %u\n", sptr->pes_buffer_on, - sptr->pes_buffer_size, - sptr->pes_buffer_size - sptr->pes_buffer_on, - sptr->frame_len); + fprintf(stderr, "don't have enough - on %u size %u %u %u\n", sptr->pes_buffer_on, + sptr->pes_buffer_size, + sptr->pes_buffer_size - sptr->pes_buffer_on, + sptr->frame_len); #endif - if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { - return 0; - } - } - sptr->have_frame_loaded = 1; - return 1; + if (mpeg2ps_stream_read_next_pes_buffer(sptr) == 0) { + return 0; + } + } + sptr->have_frame_loaded = 1; + return 1; } /* @@ -955,102 +972,102 @@ static Bool mpeg2ps_stream_find_mp3_frame (mpeg2ps_stream_t *sptr) * advance_pointers is 0 when we want to use the data */ static Bool mpeg2ps_stream_read_frame (mpeg2ps_stream_t *sptr, - u8 **buffer, - u32 *buflen, - Bool advance_pointers) -{ - // Bool done = 0; - if (sptr->is_video) { - if (mpeg2ps_stream_find_mpeg_video_frame(sptr)) { - *buffer = sptr->pes_buffer + sptr->pes_buffer_on; - *buflen = sptr->frame_len; - if (advance_pointers) { - sptr->pes_buffer_on += sptr->frame_len; - } - return 1; - } - return 0; - } else if (sptr->m_stream_id == 0xbd) { - // would need to handle LPCM here - if (mpeg2ps_stream_find_ac3_frame(sptr)) { - *buffer = sptr->pes_buffer + sptr->pes_buffer_on; - *buflen = sptr->frame_len; - if (advance_pointers) - sptr->pes_buffer_on += sptr->frame_len; - return 1; - } - return 0; - } else if (mpeg2ps_stream_find_mp3_frame(sptr)) { - *buffer = sptr->pes_buffer + sptr->pes_buffer_on; - *buflen = sptr->frame_len; - if (advance_pointers) - sptr->pes_buffer_on += sptr->frame_len; - return 1; - } - return 0; + u8 **buffer, + u32 *buflen, + Bool advance_pointers) +{ + // Bool done = 0; + if (sptr->is_video) { + if (mpeg2ps_stream_find_mpeg_video_frame(sptr)) { + *buffer = sptr->pes_buffer + sptr->pes_buffer_on; + *buflen = sptr->frame_len; + if (advance_pointers) { + sptr->pes_buffer_on += sptr->frame_len; + } + return 1; + } + return 0; + } else if (sptr->m_stream_id == 0xbd) { + // would need to handle LPCM here + if (mpeg2ps_stream_find_ac3_frame(sptr)) { + *buffer = sptr->pes_buffer + sptr->pes_buffer_on; + *buflen = sptr->frame_len; + if (advance_pointers) + sptr->pes_buffer_on += sptr->frame_len; + return 1; + } + return 0; + } else if (mpeg2ps_stream_find_mp3_frame(sptr)) { + *buffer = sptr->pes_buffer + sptr->pes_buffer_on; + *buflen = sptr->frame_len; + if (advance_pointers) + sptr->pes_buffer_on += sptr->frame_len; + return 1; + } + return 0; } /* * get_info_from_frame - we have a frame, get the info from it. */ -static void get_info_from_frame (mpeg2ps_stream_t *sptr, - u8 *buffer, - u32 buflen) -{ - if (sptr->is_video) { - if (MPEG12_ParseSeqHdr(buffer, buflen, - &sptr->have_mpeg2, - &sptr->h, - &sptr->w, - &sptr->frame_rate, - &sptr->bit_rate, - &sptr->par) < 0) { - sptr->m_stream_id = 0; - sptr->m_fd = FDNULL; - } - sptr->ticks_per_frame = (u64)(90000.0 / sptr->frame_rate); - return; - } - - if (sptr->m_stream_id >= 0xc0) { - // mpeg audio - u32 hdr = GF_4CC(buffer[0],buffer[1],buffer[2],buffer[3]); - - sptr->channels = gf_mp3_num_channels(hdr); - sptr->freq = gf_mp3_sampling_rate(hdr); - sptr->samples_per_frame = gf_mp3_window_size(hdr); - sptr->bitrate = gf_mp3_bit_rate(hdr) * 1000; // give bps, not kbps - sptr->layer = gf_mp3_layer(hdr); - } else if (sptr->m_stream_id == 0xbd) { - if (sptr->m_substream_id >= 0xa0) { - // PCM - ??? - } else if (sptr->m_substream_id >= 0x80) { - u32 pos; - GF_AC3Header hdr; - gf_ac3_parser(buffer, buflen, &pos, &hdr, 0); - sptr->bitrate = hdr.bitrate; - sptr->freq = hdr.sample_rate; - sptr->channels = hdr.channels; - sptr->samples_per_frame = 256 * 6; - } else { - return; - } - } else { - return; - } +static void get_info_from_frame (mpeg2ps_stream_t *sptr, + u8 *buffer, + u32 buflen) +{ + if (sptr->is_video) { + if (MPEG12_ParseSeqHdr(buffer, buflen, + &sptr->have_mpeg2, + &sptr->h, + &sptr->w, + &sptr->frame_rate, + &sptr->bit_rate, + &sptr->par) < 0) { + sptr->m_stream_id = 0; + sptr->m_fd = FDNULL; + } + sptr->ticks_per_frame = (u64)(90000.0 / sptr->frame_rate); + return; + } + + if (sptr->m_stream_id >= 0xc0) { + // mpeg audio + u32 hdr = GF_4CC(buffer[0],buffer[1],buffer[2],buffer[3]); + + sptr->channels = gf_mp3_num_channels(hdr); + sptr->freq = gf_mp3_sampling_rate(hdr); + sptr->samples_per_frame = gf_mp3_window_size(hdr); + sptr->bitrate = gf_mp3_bit_rate(hdr) * 1000; // give bps, not kbps + sptr->layer = gf_mp3_layer(hdr); + } else if (sptr->m_stream_id == 0xbd) { + if (sptr->m_substream_id >= 0xa0) { + // PCM - ??? + } else if (sptr->m_substream_id >= 0x80) { + u32 pos; + GF_AC3Header hdr; + gf_ac3_parser(buffer, buflen, &pos, &hdr, 0); + sptr->bitrate = hdr.bitrate; + sptr->freq = hdr.sample_rate; + sptr->channels = hdr.channels; + sptr->samples_per_frame = 256 * 6; + } else { + return; + } + } else { + return; + } } /* - * clear_stream_buffer - called when we seek to clear out any data in + * clear_stream_buffer - called when we seek to clear out any data in * the buffers */ static void clear_stream_buffer (mpeg2ps_stream_t *sptr) { - sptr->pes_buffer_on = sptr->pes_buffer_size = 0; - sptr->frame_len = 0; - sptr->have_frame_loaded = 0; - sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; - sptr->frame_ts.have_dts = sptr->frame_ts.have_pts = 0; + sptr->pes_buffer_on = sptr->pes_buffer_size = 0; + sptr->frame_len = 0; + sptr->have_frame_loaded = 0; + sptr->next_pes_ts.have_dts = sptr->next_pes_ts.have_pts = 0; + sptr->frame_ts.have_dts = sptr->frame_ts.have_pts = 0; } /* @@ -1058,101 +1075,101 @@ static void clear_stream_buffer (mpeg2ps_stream_t *sptr) * frames_since_last_ts. */ static u64 convert_ts (mpeg2ps_stream_t *sptr, - mpeg2ps_ts_type_t ts_type, - u64 ts, - u64 base_ts, - u32 frames_since_ts) -{ - u64 ret, calc; - ret = ts - base_ts; - if (sptr->is_video) { - // video - ret += frames_since_ts * sptr->ticks_per_frame; - } else { - // audio - calc = (frames_since_ts * 90000 * sptr->samples_per_frame) / sptr->freq; - ret += calc; - } - if (ts_type == TS_MSEC) - ret /= (u64) (90); // * 1000 / 90000 - - return ret; + mpeg2ps_ts_type_t ts_type, + u64 ts, + u64 base_ts, + u32 frames_since_ts) +{ + u64 ret, calc; + ret = ts - base_ts; + if (sptr->is_video) { + // video + ret += frames_since_ts * sptr->ticks_per_frame; + } else { + // audio + calc = (frames_since_ts * 90000 * sptr->samples_per_frame) / sptr->freq; + ret += calc; + } + if (ts_type == TS_MSEC) + ret /= (u64) (90); // * 1000 / 90000 + + return ret; } /* * find_stream_from_id - given the stream, get the sptr. - * only used in inital set up, really. APIs use index into + * only used in inital set up, really. APIs use index into * video_streams and audio_streams arrays. */ -static mpeg2ps_stream_t *find_stream_from_id (mpeg2ps_t *ps, - u8 stream_id, - u8 substream) -{ - u8 ix; - if (stream_id >= 0xe0) { - for (ix = 0; ix < ps->video_cnt; ix++) { - if (ps->video_streams[ix]->m_stream_id == stream_id) { - return ps->video_streams[ix]; - } - } - } else { - for (ix = 0; ix < ps->audio_cnt; ix++) { - if (ps->audio_streams[ix]->m_stream_id == stream_id && - (stream_id != 0xbd || - substream == ps->audio_streams[ix]->m_substream_id)) { - return ps->audio_streams[ix]; - } - } - } - return NULL; +static mpeg2ps_stream_t *find_stream_from_id (mpeg2ps_t *ps, + u8 stream_id, + u8 substream) +{ + u8 ix; + if (stream_id >= 0xe0) { + for (ix = 0; ix < ps->video_cnt; ix++) { + if (ps->video_streams[ix]->m_stream_id == stream_id) { + return ps->video_streams[ix]; + } + } + } else { + for (ix = 0; ix < ps->audio_cnt; ix++) { + if (ps->audio_streams[ix]->m_stream_id == stream_id && + (stream_id != 0xbd || + substream == ps->audio_streams[ix]->m_substream_id)) { + return ps->audio_streams[ix]; + } + } + } + return NULL; } /* * add_stream - add a new stream */ static Bool add_stream (mpeg2ps_t *ps, - u8 stream_id, - u8 substream, - s64 first_loc, - mpeg2ps_ts_t *ts) -{ - mpeg2ps_stream_t *sptr; - - sptr = find_stream_from_id(ps, stream_id, substream); - if (sptr != NULL) return 0; - - // need to add - - sptr = mpeg2ps_stream_create(stream_id, substream); - sptr->first_pes_loc = first_loc; - if (ts == NULL || - (ts->have_dts == 0 && ts->have_pts == 0)) { - sptr->first_pes_has_dts = 0; - } else { - sptr->start_dts = ts->have_dts ? ts->dts : ts->pts; - sptr->first_pes_has_dts = 1; - } - if (sptr->is_video) { - // can't be more than 16 - e0 to ef... - ps->video_streams[ps->video_cnt] = sptr; - ps->video_cnt++; - } else { - if (ps->audio_cnt >= 32) { - mpeg2ps_stream_destroy(sptr); - return 0; - } - ps->audio_streams[ps->audio_cnt] = sptr; - ps->audio_cnt++; - } - return 1; + u8 stream_id, + u8 substream, + s64 first_loc, + mpeg2ps_ts_t *ts) +{ + mpeg2ps_stream_t *sptr; + + sptr = find_stream_from_id(ps, stream_id, substream); + if (sptr != NULL) return 0; + + // need to add + + sptr = mpeg2ps_stream_create(stream_id, substream); + sptr->first_pes_loc = first_loc; + if (ts == NULL || + (ts->have_dts == 0 && ts->have_pts == 0)) { + sptr->first_pes_has_dts = 0; + } else { + sptr->start_dts = ts->have_dts ? ts->dts : ts->pts; + sptr->first_pes_has_dts = 1; + } + if (sptr->is_video) { + // can't be more than 16 - e0 to ef... + ps->video_streams[ps->video_cnt] = sptr; + ps->video_cnt++; + } else { + if (ps->audio_cnt >= 32) { + mpeg2ps_stream_destroy(sptr); + return 0; + } + ps->audio_streams[ps->audio_cnt] = sptr; + ps->audio_cnt++; + } + return 1; } -static void check_fd_for_stream (mpeg2ps_t *ps, - mpeg2ps_stream_t *sptr) +static void check_fd_for_stream (mpeg2ps_t *ps, + mpeg2ps_stream_t *sptr) { - if (sptr->m_fd != FDNULL) return; + if (sptr->m_fd != FDNULL) return; - sptr->m_fd = file_open(ps->filename); + sptr->m_fd = file_open(ps->filename); } /* @@ -1163,17 +1180,17 @@ static void check_fd_for_stream (mpeg2ps_t *ps, */ static void advance_frame (mpeg2ps_stream_t *sptr) { - sptr->pes_buffer_on += sptr->frame_len; - sptr->have_frame_loaded = 0; - if (sptr->frame_ts.have_dts || sptr->frame_ts.have_pts) { - if (sptr->frame_ts.have_dts) - sptr->last_ts = sptr->frame_ts.dts; - else - sptr->last_ts = sptr->frame_ts.pts; - sptr->frames_since_last_ts = 0; - } else { - sptr->frames_since_last_ts++; - } + sptr->pes_buffer_on += sptr->frame_len; + sptr->have_frame_loaded = 0; + if (sptr->frame_ts.have_dts || sptr->frame_ts.have_pts) { + if (sptr->frame_ts.have_dts) + sptr->last_ts = sptr->frame_ts.dts; + else + sptr->last_ts = sptr->frame_ts.pts; + sptr->frames_since_last_ts = 0; + } else { + sptr->frames_since_last_ts++; + } } /* * get_info_for_all_streams - loop through found streams - read an @@ -1181,69 +1198,69 @@ static void advance_frame (mpeg2ps_stream_t *sptr) */ static void get_info_for_all_streams (mpeg2ps_t *ps) { - u8 stream_ix, max_ix, av; - mpeg2ps_stream_t *sptr; - u8 *buffer; - u32 buflen; + u8 stream_ix, max_ix, av; + mpeg2ps_stream_t *sptr; + u8 *buffer; + u32 buflen; file_seek_to(ps->fd, 0); - // av will be 0 for video streams, 1 for audio streams - // av is just so I don't have to dup a lot of code that does the - // same thing. - for (av = 0; av < 2; av++) { - if (av == 0) max_ix = ps->video_cnt; - else max_ix = ps->audio_cnt; - for (stream_ix = 0; stream_ix < max_ix; stream_ix++) { - if (av == 0) sptr = ps->video_streams[stream_ix]; - else sptr = ps->audio_streams[stream_ix]; - - // we don't open a seperate file descriptor yet (only when they - // start reading or seeking). Use the one from the ps. - sptr->m_fd = ps->fd; // for now - clear_stream_buffer(sptr); - if (mpeg2ps_stream_read_frame(sptr, - &buffer, - &buflen, - 0) == 0) { - sptr->m_stream_id = 0; - sptr->m_fd = FDNULL; - continue; - } - get_info_from_frame(sptr, buffer, buflen); - // here - if (sptr->first_pes_has_dts == 0) should be processed - if (sptr->first_pes_has_dts == 0) { - u32 frames_from_beg = 0; - Bool have_frame; - do { - advance_frame(sptr); - have_frame = - mpeg2ps_stream_read_frame(sptr, &buffer, &buflen, 0); - frames_from_beg++; - } while (have_frame && - sptr->frame_ts.have_dts == 0 && - sptr->frame_ts.have_pts == 0 && - frames_from_beg < 1000); - if (have_frame == 0 || - (sptr->frame_ts.have_dts == 0 && - sptr->frame_ts.have_pts == 0)) { - } else { - sptr->start_dts = sptr->frame_ts.have_dts ? sptr->frame_ts.dts : - sptr->frame_ts.pts; - if (sptr->is_video) { - sptr->start_dts -= frames_from_beg * sptr->ticks_per_frame; - } else { - u64 conv; - conv = sptr->samples_per_frame * 90000; - conv /= (u64)sptr->freq; - sptr->start_dts -= conv; - } - } - } - clear_stream_buffer(sptr); - sptr->m_fd = FDNULL; - } - } + // av will be 0 for video streams, 1 for audio streams + // av is just so I don't have to dup a lot of code that does the + // same thing. + for (av = 0; av < 2; av++) { + if (av == 0) max_ix = ps->video_cnt; + else max_ix = ps->audio_cnt; + for (stream_ix = 0; stream_ix < max_ix; stream_ix++) { + if (av == 0) sptr = ps->video_streams[stream_ix]; + else sptr = ps->audio_streams[stream_ix]; + + // we don't open a seperate file descriptor yet (only when they + // start reading or seeking). Use the one from the ps. + sptr->m_fd = ps->fd; // for now + clear_stream_buffer(sptr); + if (mpeg2ps_stream_read_frame(sptr, + &buffer, + &buflen, + 0) == 0) { + sptr->m_stream_id = 0; + sptr->m_fd = FDNULL; + continue; + } + get_info_from_frame(sptr, buffer, buflen); + // here - if (sptr->first_pes_has_dts == 0) should be processed + if (sptr->first_pes_has_dts == 0) { + u32 frames_from_beg = 0; + Bool have_frame; + do { + advance_frame(sptr); + have_frame = + mpeg2ps_stream_read_frame(sptr, &buffer, &buflen, 0); + frames_from_beg++; + } while (have_frame && + sptr->frame_ts.have_dts == 0 && + sptr->frame_ts.have_pts == 0 && + frames_from_beg < 1000); + if (have_frame == 0 || + (sptr->frame_ts.have_dts == 0 && + sptr->frame_ts.have_pts == 0)) { + } else { + sptr->start_dts = sptr->frame_ts.have_dts ? sptr->frame_ts.dts : + sptr->frame_ts.pts; + if (sptr->is_video) { + sptr->start_dts -= frames_from_beg * sptr->ticks_per_frame; + } else { + u64 conv; + conv = sptr->samples_per_frame * 90000; + conv /= (u64)sptr->freq; + sptr->start_dts -= conv; + } + } + } + clear_stream_buffer(sptr); + sptr->m_fd = FDNULL; + } + } } /* @@ -1252,209 +1269,209 @@ static void get_info_for_all_streams (mpeg2ps_t *ps) */ static void mpeg2ps_scan_file (mpeg2ps_t *ps) { - u8 stream_id, stream_ix, substream, av_ix, max_cnt; - u16 pes_len, pes_left; - mpeg2ps_ts_t ts; - s64 loc, first_video_loc = 0, first_audio_loc = 0; - s64 check, orig_check; - mpeg2ps_stream_t *sptr; - Bool valid_stream; - u8 *buffer; - u32 buflen; - Bool have_ts; - - ps->end_loc = file_size(ps->fd); - orig_check = check = MAX(ps->end_loc / 50, 200 * 1024); - - /* - * This part reads and finds the streams. We check up until we - * find audio and video plus a little, with a max of either 200K or - * the file size / 50 - */ - loc = 0; - while (read_to_next_pes_header(ps->fd, &stream_id, &pes_len) && - loc < check) { - pes_left = pes_len; - if (stream_id >= 0xbd && stream_id < 0xf0) { - loc = file_location(ps->fd) - 6; - if (read_pes_header_data(ps->fd, - pes_len, - &pes_left, - &have_ts, - &ts) == 0) { - return; - } - valid_stream = 0; - substream = 0; - if (stream_id == 0xbd) { - if (file_read_bytes(ps->fd, &substream, 1) == 0) { - return; - } - pes_left--; // remove byte we just read - if ((substream >= 0x80 && substream < 0x90) || - (substream >= 0xa0 && substream < 0xb0)){ - valid_stream = 1; - } - } else if (stream_id >= 0xc0 && - stream_id <= 0xef) { - // audio and video - valid_stream = 1; - } - if (valid_stream) { - if (add_stream(ps, stream_id, substream, loc, &ts)) { - // added - if (stream_id >= 0xe0) { - if (ps->video_cnt == 1) { - first_video_loc = loc; - } - } else if (ps->audio_cnt == 1) { - first_audio_loc = loc; - } - if (ps->audio_cnt > 0 && ps->video_cnt > 0) { - s64 diff; - if (first_audio_loc > first_video_loc) - diff = first_audio_loc - first_video_loc; - else - diff = first_video_loc - first_audio_loc; - diff *= 2; - diff += first_video_loc; - if (diff < check) { - check = diff; - } - } - } - } - } - file_skip_bytes(ps->fd, pes_left); - } - if (ps->video_cnt == 0 && ps->audio_cnt == 0) { - return; - } - /* - * Now, we go to close to the end, and try to find the last - * dts that we can - */ - // fprintf(stderr, "to end "X64"\n", end - orig_check); - file_seek_to(ps->fd, ps->end_loc - orig_check); - - while (read_to_next_pes_header(ps->fd, &stream_id, &pes_len)) { - loc = file_location(ps->fd) - 6; - if (stream_id == 0xbd || (stream_id >= 0xc0 && stream_id < 0xf0)) { - if (read_pes_header_data(ps->fd, - pes_len, - &pes_left, - &have_ts, - &ts) == 0) { - return; - } - if (stream_id == 0xbd) { - if (file_read_bytes(ps->fd, &substream, 1) == 0) { - return; - } - pes_left--; // remove byte we just read - if (!((substream >= 0x80 && substream < 0x90) || - (substream >= 0xa0 && substream < 0xb0))) { - file_skip_bytes(ps->fd, pes_left); - continue; - } - } else { - substream = 0; - } - sptr = find_stream_from_id(ps, stream_id, substream); - if (sptr == NULL) { - add_stream(ps, stream_id, substream, 0, NULL); - sptr = find_stream_from_id(ps, stream_id, substream); - } - if (sptr != NULL && have_ts) { - sptr->end_dts = ts.have_dts ? ts.dts : ts.pts; - sptr->end_dts_loc = loc; - } + u8 stream_id, stream_ix, substream, av_ix, max_cnt; + u16 pes_len, pes_left; + mpeg2ps_ts_t ts; + s64 loc, first_video_loc = 0, first_audio_loc = 0; + s64 check, orig_check; + mpeg2ps_stream_t *sptr; + Bool valid_stream; + u8 *buffer; + u32 buflen; + Bool have_ts; + + ps->end_loc = file_size(ps->fd); + orig_check = check = MAX(ps->end_loc / 50, 200 * 1024); + + /* + * This part reads and finds the streams. We check up until we + * find audio and video plus a little, with a max of either 200K or + * the file size / 50 + */ + loc = 0; + while (read_to_next_pes_header(ps->fd, &stream_id, &pes_len) && + loc < check) { + pes_left = pes_len; + if (stream_id >= 0xbd && stream_id < 0xf0) { + loc = file_location(ps->fd) - 6; + if (read_pes_header_data(ps->fd, + pes_len, + &pes_left, + &have_ts, + &ts) == 0) { + return; + } + valid_stream = 0; + substream = 0; + if (stream_id == 0xbd) { + if (file_read_bytes(ps->fd, &substream, 1) == 0) { + return; + } + pes_left--; // remove byte we just read + if ((substream >= 0x80 && substream < 0x90) || + (substream >= 0xa0 && substream < 0xb0)) { + valid_stream = 1; + } + } else if (stream_id >= 0xc0 && + stream_id <= 0xef) { + // audio and video + valid_stream = 1; + } + if (valid_stream) { + if (add_stream(ps, stream_id, substream, loc, &ts)) { + // added + if (stream_id >= 0xe0) { + if (ps->video_cnt == 1) { + first_video_loc = loc; + } + } else if (ps->audio_cnt == 1) { + first_audio_loc = loc; + } + if (ps->audio_cnt > 0 && ps->video_cnt > 0) { + s64 diff; + if (first_audio_loc > first_video_loc) + diff = first_audio_loc - first_video_loc; + else + diff = first_video_loc - first_audio_loc; + diff *= 2; + diff += first_video_loc; + if (diff < check) { + check = diff; + } + } + } + } + } + file_skip_bytes(ps->fd, pes_left); + } + if (ps->video_cnt == 0 && ps->audio_cnt == 0) { + return; + } + /* + * Now, we go to close to the end, and try to find the last + * dts that we can + */ + // fprintf(stderr, "to end "X64"\n", end - orig_check); + file_seek_to(ps->fd, ps->end_loc - orig_check); + + while (read_to_next_pes_header(ps->fd, &stream_id, &pes_len)) { + loc = file_location(ps->fd) - 6; + if (stream_id == 0xbd || (stream_id >= 0xc0 && stream_id < 0xf0)) { + if (read_pes_header_data(ps->fd, + pes_len, + &pes_left, + &have_ts, + &ts) == 0) { + return; + } + if (stream_id == 0xbd) { + if (file_read_bytes(ps->fd, &substream, 1) == 0) { + return; + } + pes_left--; // remove byte we just read + if (!((substream >= 0x80 && substream < 0x90) || + (substream >= 0xa0 && substream < 0xb0))) { + file_skip_bytes(ps->fd, pes_left); + continue; + } + } else { + substream = 0; + } + sptr = find_stream_from_id(ps, stream_id, substream); + if (sptr == NULL) { + add_stream(ps, stream_id, substream, 0, NULL); + sptr = find_stream_from_id(ps, stream_id, substream); + } + if (sptr != NULL && have_ts) { + sptr->end_dts = ts.have_dts ? ts.dts : ts.pts; + sptr->end_dts_loc = loc; + } #if 0 - fprintf(stderr, "loc "X64" stream %x %x", loc, stream_id, substream); - if (ts.have_pts) fprintf(stderr, " pts "U64, ts.pts); - if (ts.have_dts) fprintf(stderr, " dts "U64, ts.dts); - fprintf(stderr, "\n"); + fprintf(stderr, "loc "X64" stream %x %x", loc, stream_id, substream); + if (ts.have_pts) fprintf(stderr, " pts "U64, ts.pts); + if (ts.have_dts) fprintf(stderr, " dts "U64, ts.dts); + fprintf(stderr, "\n"); #endif - file_skip_bytes(ps->fd, pes_left); - } - } - - /* - * Now, get the info for all streams, so we can use it again - * we could do this before the above, I suppose - */ - get_info_for_all_streams(ps); - - ps->first_dts = (u64) -1; - - /* - * we need to find the earliest start pts - we use that to calc - * the rest of the timing, so we're 0 based. - */ - for (av_ix = 0; av_ix < 2; av_ix++) { - if (av_ix == 0) max_cnt = ps->video_cnt; - else max_cnt = ps->audio_cnt; - - for (stream_ix = 0; stream_ix < max_cnt; stream_ix++) { - sptr = av_ix == 0 ? ps->video_streams[stream_ix] : - ps->audio_streams[stream_ix]; - if (sptr != NULL && sptr->start_dts < ps->first_dts) { - ps->first_dts = sptr->start_dts; - } - } - } - - /* - * Now, for each thread, we'll start at the last pts location, and - * read the number of frames. This will give us a max time - */ - for (av_ix = 0; av_ix < 2; av_ix++) { - if (av_ix == 0) max_cnt = ps->video_cnt; - else max_cnt = ps->audio_cnt; - for (stream_ix = 0; stream_ix < max_cnt; stream_ix++) { - u32 frame_cnt_since_last; - sptr = av_ix == 0 ? ps->video_streams[stream_ix] : - ps->audio_streams[stream_ix]; - - // pick up here - find the final time... - if (sptr->end_dts_loc != 0) { - file_seek_to(ps->fd, sptr->end_dts_loc); - sptr->m_fd = ps->fd; - frame_cnt_since_last = 0; - clear_stream_buffer(sptr); - while (mpeg2ps_stream_read_frame(sptr, - &buffer, - &buflen, - 1)) { - frame_cnt_since_last++; - } - sptr->m_fd = FDNULL; - clear_stream_buffer(sptr); - ps->max_time = MAX(ps->max_time, - convert_ts(sptr, - TS_MSEC, - sptr->end_dts, - ps->first_dts, - frame_cnt_since_last)); - } - } - } - - ps->max_dts = (ps->max_time * 90) + ps->first_dts; - file_seek_to(ps->fd, 0); + file_skip_bytes(ps->fd, pes_left); + } + } + + /* + * Now, get the info for all streams, so we can use it again + * we could do this before the above, I suppose + */ + get_info_for_all_streams(ps); + + ps->first_dts = (u64) -1; + + /* + * we need to find the earliest start pts - we use that to calc + * the rest of the timing, so we're 0 based. + */ + for (av_ix = 0; av_ix < 2; av_ix++) { + if (av_ix == 0) max_cnt = ps->video_cnt; + else max_cnt = ps->audio_cnt; + + for (stream_ix = 0; stream_ix < max_cnt; stream_ix++) { + sptr = av_ix == 0 ? ps->video_streams[stream_ix] : + ps->audio_streams[stream_ix]; + if (sptr != NULL && sptr->start_dts < ps->first_dts) { + ps->first_dts = sptr->start_dts; + } + } + } + + /* + * Now, for each thread, we'll start at the last pts location, and + * read the number of frames. This will give us a max time + */ + for (av_ix = 0; av_ix < 2; av_ix++) { + if (av_ix == 0) max_cnt = ps->video_cnt; + else max_cnt = ps->audio_cnt; + for (stream_ix = 0; stream_ix < max_cnt; stream_ix++) { + u32 frame_cnt_since_last; + sptr = av_ix == 0 ? ps->video_streams[stream_ix] : + ps->audio_streams[stream_ix]; + + // pick up here - find the final time... + if (sptr->end_dts_loc != 0) { + file_seek_to(ps->fd, sptr->end_dts_loc); + sptr->m_fd = ps->fd; + frame_cnt_since_last = 0; + clear_stream_buffer(sptr); + while (mpeg2ps_stream_read_frame(sptr, + &buffer, + &buflen, + 1)) { + frame_cnt_since_last++; + } + sptr->m_fd = FDNULL; + clear_stream_buffer(sptr); + ps->max_time = MAX(ps->max_time, + convert_ts(sptr, + TS_MSEC, + sptr->end_dts, + ps->first_dts, + frame_cnt_since_last)); + } + } + } + + ps->max_dts = (ps->max_time * 90) + ps->first_dts; + file_seek_to(ps->fd, 0); } /************************************************************************* * API routines *************************************************************************/ -u64 mpeg2ps_get_max_time_msec (mpeg2ps_t *ps) +u64 mpeg2ps_get_max_time_msec (mpeg2ps_t *ps) { - return ps->max_time; + return ps->max_time; } u32 mpeg2ps_get_video_stream_count (mpeg2ps_t *ps) { - return ps->video_cnt; + return ps->video_cnt; } #define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name)))) @@ -1462,184 +1479,187 @@ u32 mpeg2ps_get_video_stream_count (mpeg2ps_t *ps) // routine to check stream number passed. static Bool invalid_video_streamno (mpeg2ps_t *ps, u32 streamno) { - if (streamno >= NUM_ELEMENTS_IN_ARRAY(ps->video_streams)) return 1; - if (ps->video_streams[streamno] == NULL) return 1; - return 0; + if (streamno >= NUM_ELEMENTS_IN_ARRAY(ps->video_streams)) return 1; + if (ps->video_streams[streamno] == NULL) return 1; + return 0; } const char *mpeg2ps_get_video_stream_name (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - if (ps->video_streams[streamno]->have_mpeg2) { - return "Mpeg-2"; - } - return "Mpeg-1"; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + if (ps->video_streams[streamno]->have_mpeg2) { + return "Mpeg-2"; + } + return "Mpeg-1"; } -mpeg2ps_video_type_t mpeg2ps_get_video_stream_type (mpeg2ps_t *ps, - u32 streamno) +mpeg2ps_video_type_t mpeg2ps_get_video_stream_type (mpeg2ps_t *ps, + u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return MPEG_VIDEO_UNKNOWN; - } - return ps->video_streams[streamno]->have_mpeg2 ? MPEG_VIDEO_MPEG2 : MPEG_VIDEO_MPEG1; + if (invalid_video_streamno(ps, streamno)) { + return MPEG_VIDEO_UNKNOWN; + } + return ps->video_streams[streamno]->have_mpeg2 ? MPEG_VIDEO_MPEG2 : MPEG_VIDEO_MPEG1; } u32 mpeg2ps_get_video_stream_width (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - return ps->video_streams[streamno]->w; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + return ps->video_streams[streamno]->w; } u32 mpeg2ps_get_video_stream_height (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - return ps->video_streams[streamno]->h; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + return ps->video_streams[streamno]->h; } u32 mpeg2ps_get_video_stream_aspect_ratio (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - return ps->video_streams[streamno]->par; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + return ps->video_streams[streamno]->par; } Double mpeg2ps_get_video_stream_bitrate (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - return ps->video_streams[streamno]->bit_rate; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + return ps->video_streams[streamno]->bit_rate; } Double mpeg2ps_get_video_stream_framerate (mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) { - return 0; - } - return ps->video_streams[streamno]->frame_rate; + if (invalid_video_streamno(ps, streamno)) { + return 0; + } + return ps->video_streams[streamno]->frame_rate; } static Bool invalid_audio_streamno (mpeg2ps_t *ps, u32 streamno) { - if (streamno >= NUM_ELEMENTS_IN_ARRAY(ps->audio_streams)) return 1; - if (ps->audio_streams[streamno] == NULL) return 1; - return 0; + if (streamno >= NUM_ELEMENTS_IN_ARRAY(ps->audio_streams)) return 1; + if (ps->audio_streams[streamno] == NULL) return 1; + return 0; } u32 mpeg2ps_get_audio_stream_count (mpeg2ps_t *ps) { - return ps->audio_cnt; + return ps->audio_cnt; } -const char *mpeg2ps_get_audio_stream_name (mpeg2ps_t *ps, - u32 streamno) -{ - if (invalid_audio_streamno(ps, streamno)) { - return "none"; - } - if (ps->audio_streams[streamno]->m_stream_id >= 0xc0) { - switch (ps->audio_streams[streamno]->layer) { - case 1: return "MP1"; - case 2: return "MP2"; - case 3: return "MP3"; - } - return "unknown mpeg layer"; - } - if (ps->audio_streams[streamno]->m_substream_id >= 0x80 && - ps->audio_streams[streamno]->m_substream_id < 0x90) - return "AC3"; - - return "LPCM"; +const char *mpeg2ps_get_audio_stream_name (mpeg2ps_t *ps, + u32 streamno) +{ + if (invalid_audio_streamno(ps, streamno)) { + return "none"; + } + if (ps->audio_streams[streamno]->m_stream_id >= 0xc0) { + switch (ps->audio_streams[streamno]->layer) { + case 1: + return "MP1"; + case 2: + return "MP2"; + case 3: + return "MP3"; + } + return "unknown mpeg layer"; + } + if (ps->audio_streams[streamno]->m_substream_id >= 0x80 && + ps->audio_streams[streamno]->m_substream_id < 0x90) + return "AC3"; + + return "LPCM"; } -mpeg2ps_audio_type_t mpeg2ps_get_audio_stream_type (mpeg2ps_t *ps, - u32 streamno) +mpeg2ps_audio_type_t mpeg2ps_get_audio_stream_type (mpeg2ps_t *ps, + u32 streamno) { - if (invalid_audio_streamno(ps, streamno)) { - return MPEG_AUDIO_UNKNOWN; - } - if (ps->audio_streams[streamno]->m_stream_id >= 0xc0) { - return MPEG_AUDIO_MPEG; - } - if (ps->audio_streams[streamno]->m_substream_id >= 0x80 && - ps->audio_streams[streamno]->m_substream_id < 0x90) - return MPEG_AUDIO_AC3; + if (invalid_audio_streamno(ps, streamno)) { + return MPEG_AUDIO_UNKNOWN; + } + if (ps->audio_streams[streamno]->m_stream_id >= 0xc0) { + return MPEG_AUDIO_MPEG; + } + if (ps->audio_streams[streamno]->m_substream_id >= 0x80 && + ps->audio_streams[streamno]->m_substream_id < 0x90) + return MPEG_AUDIO_AC3; - return MPEG_AUDIO_LPCM; + return MPEG_AUDIO_LPCM; } u32 mpeg2ps_get_audio_stream_sample_freq (mpeg2ps_t *ps, u32 streamno) { - if (invalid_audio_streamno(ps, streamno)) { - return 0; - } - return ps->audio_streams[streamno]->freq; + if (invalid_audio_streamno(ps, streamno)) { + return 0; + } + return ps->audio_streams[streamno]->freq; } u32 mpeg2ps_get_audio_stream_channels (mpeg2ps_t *ps, u32 streamno) { - if (invalid_audio_streamno(ps, streamno)) { - return 0; - } - return ps->audio_streams[streamno]->channels; + if (invalid_audio_streamno(ps, streamno)) { + return 0; + } + return ps->audio_streams[streamno]->channels; } u32 mpeg2ps_get_audio_stream_bitrate (mpeg2ps_t *ps, u32 streamno) { - if (invalid_audio_streamno(ps, streamno)) { - return 0; - } - return ps->audio_streams[streamno]->bitrate; + if (invalid_audio_streamno(ps, streamno)) { + return 0; + } + return ps->audio_streams[streamno]->bitrate; } mpeg2ps_t *mpeg2ps_init (const char *filename) { - mpeg2ps_t *ps; - GF_SAFEALLOC(ps, mpeg2ps_t); - - if (ps == NULL) { - return NULL; - } - memset(ps, 0, sizeof(*ps)); - ps->fd = file_open(filename); - if (file_okay(ps->fd) == 0) { - gf_free(ps); - return NULL; - } - - ps->filename = gf_strdup(filename); - mpeg2ps_scan_file(ps); - if (ps->video_cnt == 0 && ps->audio_cnt == 0) { - mpeg2ps_close(ps); - return NULL; - } - return ps; + mpeg2ps_t *ps; + GF_SAFEALLOC(ps, mpeg2ps_t); + + if (ps == NULL) { + return NULL; + } + memset(ps, 0, sizeof(*ps)); + ps->fd = file_open(filename); + if (file_okay(ps->fd) == 0) { + gf_free(ps); + return NULL; + } + + ps->filename = gf_strdup(filename); + mpeg2ps_scan_file(ps); + if (ps->video_cnt == 0 && ps->audio_cnt == 0) { + mpeg2ps_close(ps); + return NULL; + } + return ps; } void mpeg2ps_close (mpeg2ps_t *ps) { - u32 ix; - if (ps == NULL) return; - for (ix = 0; ix < ps->video_cnt; ix++) { - mpeg2ps_stream_destroy(ps->video_streams[ix]); - ps->video_streams[ix] = NULL; - } - for (ix = 0; ix < ps->audio_cnt; ix++) { - mpeg2ps_stream_destroy(ps->audio_streams[ix]); - ps->audio_streams[ix] = NULL; - } - - if (ps->filename) gf_free(ps->filename); - if (ps->fd) file_close(ps->fd); - gf_free(ps); + u32 ix; + if (ps == NULL) return; + for (ix = 0; ix < ps->video_cnt; ix++) { + mpeg2ps_stream_destroy(ps->video_streams[ix]); + ps->video_streams[ix] = NULL; + } + for (ix = 0; ix < ps->audio_cnt; ix++) { + mpeg2ps_stream_destroy(ps->audio_streams[ix]); + ps->audio_streams[ix] = NULL; + } + + if (ps->filename) gf_free(ps->filename); + if (ps->fd) file_close(ps->fd); + gf_free(ps); } /* @@ -1653,106 +1673,106 @@ void mpeg2ps_close (mpeg2ps_t *ps) * than 1 time, if needed, without changing any variables, such as * frames_since_last_ts, which gets updated in advance_frame */ -static u64 stream_convert_frame_ts_to_msec (mpeg2ps_stream_t *sptr, - mpeg2ps_ts_type_t ts_type, - u64 base_dts, - u32 *freq_ts) -{ - u64 calc_ts; - u32 frames_since_last = 0; - u64 freq_conv; - - calc_ts = sptr->last_ts; - if (sptr->frame_ts.have_dts) calc_ts = sptr->frame_ts.dts; - else if (sptr->frame_ts.have_pts) calc_ts = sptr->frame_ts.dts; - else frames_since_last = sptr->frames_since_last_ts + 1; - - if (freq_ts != NULL) { - freq_conv = calc_ts - base_dts; - freq_conv *= sptr->freq; - freq_conv /= 90000; - freq_conv += frames_since_last * sptr->samples_per_frame; - *freq_ts = (u32) (freq_conv & 0xffffffff); - } - return convert_ts(sptr, ts_type, calc_ts, base_dts, frames_since_last); +static u64 stream_convert_frame_ts_to_msec (mpeg2ps_stream_t *sptr, + mpeg2ps_ts_type_t ts_type, + u64 base_dts, + u32 *freq_ts) +{ + u64 calc_ts; + u32 frames_since_last = 0; + u64 freq_conv; + + calc_ts = sptr->last_ts; + if (sptr->frame_ts.have_dts) calc_ts = sptr->frame_ts.dts; + else if (sptr->frame_ts.have_pts) calc_ts = sptr->frame_ts.dts; + else frames_since_last = sptr->frames_since_last_ts + 1; + + if (freq_ts != NULL) { + freq_conv = calc_ts - base_dts; + freq_conv *= sptr->freq; + freq_conv /= 90000; + freq_conv += frames_since_last * sptr->samples_per_frame; + *freq_ts = (u32) (freq_conv & 0xffffffff); + } + return convert_ts(sptr, ts_type, calc_ts, base_dts, frames_since_last); } /* * mpeg2ps_get_video_frame - gets the next frame - */ + */ Bool mpeg2ps_get_video_frame(mpeg2ps_t *ps, u32 streamno, - u8 **buffer, - u32 *buflen, - u8 *frame_type, - mpeg2ps_ts_type_t ts_type, - u64 *timestamp) -{ - mpeg2ps_stream_t *sptr; - if (invalid_video_streamno(ps, streamno)) return 0; - - sptr = ps->video_streams[streamno]; - check_fd_for_stream(ps, sptr); - - if (sptr->have_frame_loaded == 0) { - // if we don't have the frame in the buffer (like after a seek), - // read the next frame - if (mpeg2ps_stream_find_mpeg_video_frame(sptr) == 0) { - return 0; - } - } - *buffer = sptr->pes_buffer + sptr->pes_buffer_on; - *buflen = sptr->frame_len; - // determine frame type - if (frame_type != NULL) { - *frame_type = MPEG12_PictHdrType(sptr->pes_buffer + - sptr->pict_header_offset); - } - - // and the timestamp - if (timestamp != NULL) { - *timestamp = stream_convert_frame_ts_to_msec(sptr, ts_type, - ps->first_dts, NULL); - } - - // finally, indicate that we read this frame - get ready for the next one. - advance_frame(sptr); - - return 1; + u8 **buffer, + u32 *buflen, + u8 *frame_type, + mpeg2ps_ts_type_t ts_type, + u64 *timestamp) +{ + mpeg2ps_stream_t *sptr; + if (invalid_video_streamno(ps, streamno)) return 0; + + sptr = ps->video_streams[streamno]; + check_fd_for_stream(ps, sptr); + + if (sptr->have_frame_loaded == 0) { + // if we don't have the frame in the buffer (like after a seek), + // read the next frame + if (mpeg2ps_stream_find_mpeg_video_frame(sptr) == 0) { + return 0; + } + } + *buffer = sptr->pes_buffer + sptr->pes_buffer_on; + *buflen = sptr->frame_len; + // determine frame type + if (frame_type != NULL) { + *frame_type = MPEG12_PictHdrType(sptr->pes_buffer + + sptr->pict_header_offset); + } + + // and the timestamp + if (timestamp != NULL) { + *timestamp = stream_convert_frame_ts_to_msec(sptr, ts_type, + ps->first_dts, NULL); + } + + // finally, indicate that we read this frame - get ready for the next one. + advance_frame(sptr); + + return 1; } -// see above comments +// see above comments Bool mpeg2ps_get_audio_frame(mpeg2ps_t *ps, u32 streamno, - u8 **buffer, - u32 *buflen, - mpeg2ps_ts_type_t ts_type, - u32 *freq_timestamp, - u64 *timestamp) -{ - mpeg2ps_stream_t *sptr; - u64 ts; - if (invalid_audio_streamno(ps, streamno)) return 0; - - sptr = ps->audio_streams[streamno]; - check_fd_for_stream(ps, sptr); - - if (sptr->have_frame_loaded == 0) { - if (mpeg2ps_stream_read_frame(sptr, buffer, buflen, 0) == 0) - return 0; - } - - if (timestamp != NULL || freq_timestamp != NULL) { - ts = stream_convert_frame_ts_to_msec(sptr, - ts_type, - ps->first_dts, - freq_timestamp); - if (timestamp != NULL) { - *timestamp = ts; - } - } - - advance_frame(sptr); - return 1; + u8 **buffer, + u32 *buflen, + mpeg2ps_ts_type_t ts_type, + u32 *freq_timestamp, + u64 *timestamp) +{ + mpeg2ps_stream_t *sptr; + u64 ts; + if (invalid_audio_streamno(ps, streamno)) return 0; + + sptr = ps->audio_streams[streamno]; + check_fd_for_stream(ps, sptr); + + if (sptr->have_frame_loaded == 0) { + if (mpeg2ps_stream_read_frame(sptr, buffer, buflen, 0) == 0) + return 0; + } + + if (timestamp != NULL || freq_timestamp != NULL) { + ts = stream_convert_frame_ts_to_msec(sptr, + ts_type, + ps->first_dts, + freq_timestamp); + if (timestamp != NULL) { + *timestamp = ts; + } + } + + advance_frame(sptr); + return 1; } u64 mpeg2ps_get_ps_size(mpeg2ps_t *ps) @@ -1761,13 +1781,13 @@ u64 mpeg2ps_get_ps_size(mpeg2ps_t *ps) } s64 mpeg2ps_get_video_pos(mpeg2ps_t *ps, u32 streamno) { - if (invalid_video_streamno(ps, streamno)) return 0; - return gf_f64_tell(ps->video_streams[streamno]->m_fd); + if (invalid_video_streamno(ps, streamno)) return 0; + return gf_f64_tell(ps->video_streams[streamno]->m_fd); } s64 mpeg2ps_get_audio_pos(mpeg2ps_t *ps, u32 streamno) { - if (invalid_audio_streamno(ps, streamno)) return 0; - return gf_f64_tell(ps->audio_streams[streamno]->m_fd); + if (invalid_audio_streamno(ps, streamno)) return 0; + return gf_f64_tell(ps->audio_streams[streamno]->m_fd); } #endif /*GPAC_DISABLE_MPEG2PS*/ diff --git a/src/media_tools/mpeg2_ps.h b/src/media_tools/mpeg2_ps.h index 6249edf..aa53dcc 100644 --- a/src/media_tools/mpeg2_ps.h +++ b/src/media_tools/mpeg2_ps.h @@ -3,19 +3,19 @@ * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ - * + * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. - * + * * The Original Code is MPEG4IP. - * + * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved. - * - * Contributor(s): + * + * Contributor(s): * Bill May wmay@cisco.com */ @@ -51,155 +51,155 @@ typedef struct mpeg2ps_ mpeg2ps_t; typedef enum { - TS_MSEC, - TS_90000, + TS_MSEC, + TS_90000, } mpeg2ps_ts_type_t; typedef enum { - MPEG_AUDIO_MPEG = 0, - MPEG_AUDIO_AC3 = 1, - MPEG_AUDIO_LPCM = 2, - MPEG_AUDIO_UNKNOWN = 3 + MPEG_AUDIO_MPEG = 0, + MPEG_AUDIO_AC3 = 1, + MPEG_AUDIO_LPCM = 2, + MPEG_AUDIO_UNKNOWN = 3 } mpeg2ps_audio_type_t; typedef enum { - MPEG_VIDEO_MPEG1 = 0, - MPEG_VIDEO_MPEG2 = 1, - MPEG_VIDEO_UNKNOWN = 2 + MPEG_VIDEO_MPEG1 = 0, + MPEG_VIDEO_MPEG2 = 1, + MPEG_VIDEO_UNKNOWN = 2 } mpeg2ps_video_type_t; -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif - /* - * Interface routines for library. - */ - /* - * mpeg2ps_init() - use to start. It will scan file for all streams - * returns handle to use with rest of calls - */ - mpeg2ps_t *mpeg2ps_init(const char *filename); - - /* - * mpeg2ps_close - clean up - should be called after mpeg2ps_init - */ - void mpeg2ps_close(mpeg2ps_t *ps); - - /* - * mpeg2ps_get_max_time_msec - returns the max time of the longest stream - */ - u64 mpeg2ps_get_max_time_msec(mpeg2ps_t *ps); - /* - * video stream functions - */ - /* - * mpeg2ps_get_video_stream_count - returns count of video streams in file - */ - u32 mpeg2ps_get_video_stream_count(mpeg2ps_t *ps); - /* - * mpeg2ps_get_video_stream_name - returns display name for stream - */ - const char *mpeg2ps_get_video_stream_name(mpeg2ps_t *ps, - u32 streamno); - /* - * mpeg2ps_get_video_stream_type - returns enum type for stream - */ - mpeg2ps_video_type_t mpeg2ps_get_video_stream_type(mpeg2ps_t *ps, - u32 streamno); - /* - * these functions should be fairly self explanatory - */ - u32 mpeg2ps_get_video_stream_width(mpeg2ps_t *ps, u32 streamno); - u32 mpeg2ps_get_video_stream_height(mpeg2ps_t *ps, u32 streamno); - u32 mpeg2ps_get_video_stream_aspect_ratio(mpeg2ps_t *ps, u32 streamno); - double mpeg2ps_get_video_stream_bitrate(mpeg2ps_t *ps, u32 streamno); - double mpeg2ps_get_video_stream_framerate(mpeg2ps_t *ps, u32 streamno); - - /* - * mpeg2ps_get_video_frame - get the next video frame - * returns false at end of stream - * Inputs: - * ps - handle from above - * streamno - stream to read - * buffer - returns pointer to data. Do not free - * buflen - frame length will be stored - * frame_type - if pointer given, frame type I-1, P-2, B-3 will be returned - * msec_timestamp - if pointer, time in msec since start will be given (dts) - */ - Bool mpeg2ps_get_video_frame(mpeg2ps_t *ps, - u32 streamno, - u8 **buffer, - u32 *buflen, - u8 *frame_type, - mpeg2ps_ts_type_t ts_type, - u64 *timestamp); - Bool mpeg2ps_seek_video_frame(mpeg2ps_t *ps, u32 streamno, - u64 msec_timestamp); - - /* - * audio stream functions - */ - /* - * mpeg2ps_get_audio_stream_count - returns count of video streams in file - */ - u32 mpeg2ps_get_audio_stream_count(mpeg2ps_t *ps); - /* - * mpeg2ps_get_audio_stream_name - returns display name for stream - */ - const char *mpeg2ps_get_audio_stream_name(mpeg2ps_t *ps, u32 streamno); - /* - * mpeg2ps_get_audio_stream_type - returns enum type for stream - */ - mpeg2ps_audio_type_t mpeg2ps_get_audio_stream_type(mpeg2ps_t *ps, u32 streamno); - /* - * these functions should be fairly self explanatory - */ - u32 mpeg2ps_get_audio_stream_sample_freq(mpeg2ps_t *ps, u32 streamno); - u32 mpeg2ps_get_audio_stream_channels(mpeg2ps_t *ps, u32 streamno); - u32 mpeg2ps_get_audio_stream_bitrate(mpeg2ps_t *ps, u32 streamno); - - /* - * mpeg2ps_get_audio_frame - get the next audio frame - * returns false at end of stream - * Inputs: - * ps - handle from above - * streamno - stream to read - * buffer - returns pointer to data. Do not free - * buflen - frame length will be stored - * freq_timestamp - will return conversion of timestamp in units of - * sample_frequency. - * msec_timestamp - if pointer, time in msec since start will be given (dts) - */ - Bool mpeg2ps_get_audio_frame(mpeg2ps_t *ps, - u32 streamno, - u8 **buffer, - u32 *buflen, - mpeg2ps_ts_type_t ts_type, - u32 *freq_timestamp, - u64 *msec_timestamp); - Bool mpeg2ps_seek_audio_frame(mpeg2ps_t *ps, u32 streamno, - u64 msec_timestamp); - - - /* - * returns file size - */ - u64 mpeg2ps_get_ps_size(mpeg2ps_t *ps); - /* - * returns position in file - * ps - handle from above - * streamno - stream to read - */ - s64 mpeg2ps_get_video_pos(mpeg2ps_t *ps, u32 streamno); - s64 mpeg2ps_get_audio_pos(mpeg2ps_t *ps, u32 streamno); +/* + * Interface routines for library. + */ +/* + * mpeg2ps_init() - use to start. It will scan file for all streams + * returns handle to use with rest of calls + */ +mpeg2ps_t *mpeg2ps_init(const char *filename); + +/* + * mpeg2ps_close - clean up - should be called after mpeg2ps_init + */ +void mpeg2ps_close(mpeg2ps_t *ps); + +/* + * mpeg2ps_get_max_time_msec - returns the max time of the longest stream + */ +u64 mpeg2ps_get_max_time_msec(mpeg2ps_t *ps); +/* + * video stream functions + */ +/* + * mpeg2ps_get_video_stream_count - returns count of video streams in file + */ +u32 mpeg2ps_get_video_stream_count(mpeg2ps_t *ps); +/* + * mpeg2ps_get_video_stream_name - returns display name for stream + */ +const char *mpeg2ps_get_video_stream_name(mpeg2ps_t *ps, + u32 streamno); +/* + * mpeg2ps_get_video_stream_type - returns enum type for stream + */ +mpeg2ps_video_type_t mpeg2ps_get_video_stream_type(mpeg2ps_t *ps, + u32 streamno); +/* + * these functions should be fairly self explanatory + */ +u32 mpeg2ps_get_video_stream_width(mpeg2ps_t *ps, u32 streamno); +u32 mpeg2ps_get_video_stream_height(mpeg2ps_t *ps, u32 streamno); +u32 mpeg2ps_get_video_stream_aspect_ratio(mpeg2ps_t *ps, u32 streamno); +double mpeg2ps_get_video_stream_bitrate(mpeg2ps_t *ps, u32 streamno); +double mpeg2ps_get_video_stream_framerate(mpeg2ps_t *ps, u32 streamno); + +/* + * mpeg2ps_get_video_frame - get the next video frame + * returns false at end of stream + * Inputs: + * ps - handle from above + * streamno - stream to read + * buffer - returns pointer to data. Do not free + * buflen - frame length will be stored + * frame_type - if pointer given, frame type I-1, P-2, B-3 will be returned + * msec_timestamp - if pointer, time in msec since start will be given (dts) + */ +Bool mpeg2ps_get_video_frame(mpeg2ps_t *ps, + u32 streamno, + u8 **buffer, + u32 *buflen, + u8 *frame_type, + mpeg2ps_ts_type_t ts_type, + u64 *timestamp); +Bool mpeg2ps_seek_video_frame(mpeg2ps_t *ps, u32 streamno, + u64 msec_timestamp); + +/* + * audio stream functions + */ +/* + * mpeg2ps_get_audio_stream_count - returns count of video streams in file + */ +u32 mpeg2ps_get_audio_stream_count(mpeg2ps_t *ps); +/* + * mpeg2ps_get_audio_stream_name - returns display name for stream + */ +const char *mpeg2ps_get_audio_stream_name(mpeg2ps_t *ps, u32 streamno); +/* + * mpeg2ps_get_audio_stream_type - returns enum type for stream + */ +mpeg2ps_audio_type_t mpeg2ps_get_audio_stream_type(mpeg2ps_t *ps, u32 streamno); +/* + * these functions should be fairly self explanatory + */ +u32 mpeg2ps_get_audio_stream_sample_freq(mpeg2ps_t *ps, u32 streamno); +u32 mpeg2ps_get_audio_stream_channels(mpeg2ps_t *ps, u32 streamno); +u32 mpeg2ps_get_audio_stream_bitrate(mpeg2ps_t *ps, u32 streamno); + +/* + * mpeg2ps_get_audio_frame - get the next audio frame + * returns false at end of stream + * Inputs: + * ps - handle from above + * streamno - stream to read + * buffer - returns pointer to data. Do not free + * buflen - frame length will be stored + * freq_timestamp - will return conversion of timestamp in units of + * sample_frequency. + * msec_timestamp - if pointer, time in msec since start will be given (dts) + */ +Bool mpeg2ps_get_audio_frame(mpeg2ps_t *ps, + u32 streamno, + u8 **buffer, + u32 *buflen, + mpeg2ps_ts_type_t ts_type, + u32 *freq_timestamp, + u64 *msec_timestamp); +Bool mpeg2ps_seek_audio_frame(mpeg2ps_t *ps, u32 streamno, + u64 msec_timestamp); + + +/* + * returns file size + */ +u64 mpeg2ps_get_ps_size(mpeg2ps_t *ps); +/* + * returns position in file + * ps - handle from above + * streamno - stream to read + */ +s64 mpeg2ps_get_video_pos(mpeg2ps_t *ps, u32 streamno); +s64 mpeg2ps_get_audio_pos(mpeg2ps_t *ps, u32 streamno); typedef void (*error_msg_func_t)(int loglevel, - const char *lib, - const char *fmt, - va_list ap); + const char *lib, + const char *fmt, + va_list ap); - void mpeg2ps_set_loglevel(int loglevel); - void mpeg2ps_set_error_func(error_msg_func_t func); +void mpeg2ps_set_loglevel(int loglevel); +void mpeg2ps_set_error_func(error_msg_func_t func); #endif /*GPAC_DISABLE_MPEG2PS*/ diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c index 094722d..4b0b309 100644 --- a/src/media_tools/mpegts.c +++ b/src/media_tools/mpegts.c @@ -58,30 +58,51 @@ GF_EXPORT const char *gf_m2ts_get_stream_name(u32 streamType) { switch (streamType) { - case GF_M2TS_VIDEO_MPEG1: return "MPEG-1 Video"; - case GF_M2TS_VIDEO_MPEG2: return "MPEG-2 Video"; - case GF_M2TS_AUDIO_MPEG1: return "MPEG-1 Audio"; - case GF_M2TS_AUDIO_MPEG2: return "MPEG-2 Audio"; - case GF_M2TS_PRIVATE_SECTION: return "Private Section"; - case GF_M2TS_PRIVATE_DATA: return "Private Data"; - case GF_M2TS_AUDIO_AAC: return "AAC Audio"; - case GF_M2TS_VIDEO_MPEG4: return "MPEG-4 Video"; - case GF_M2TS_VIDEO_H264: return "MPEG-4/H264 Video"; - case GF_M2TS_VIDEO_SVC: return "H264-SVC Video"; - case GF_M2TS_VIDEO_HEVC: return "HEVC Video"; - case GF_M2TS_VIDEO_SHVC: return "SHVC Video"; - - case GF_M2TS_AUDIO_AC3: return "Dolby AC3 Audio"; - case GF_M2TS_AUDIO_DTS: return "Dolby DTS Audio"; - case GF_M2TS_SUBTITLE_DVB: return "DVB Subtitle"; - case GF_M2TS_SYSTEMS_MPEG4_PES: return "MPEG-4 SL (PES)"; - case GF_M2TS_SYSTEMS_MPEG4_SECTIONS: return "MPEG-4 SL (Section)"; - case GF_M2TS_MPE_SECTIONS: return "MPE (Section)"; - - case GF_M2TS_METADATA_PES: return "Metadata (PES)"; - case GF_M2TS_METADATA_ID3_HLS: return "ID3/HLS Metadata (PES)"; - - default: return "Unknown"; + case GF_M2TS_VIDEO_MPEG1: + return "MPEG-1 Video"; + case GF_M2TS_VIDEO_MPEG2: + return "MPEG-2 Video"; + case GF_M2TS_AUDIO_MPEG1: + return "MPEG-1 Audio"; + case GF_M2TS_AUDIO_MPEG2: + return "MPEG-2 Audio"; + case GF_M2TS_PRIVATE_SECTION: + return "Private Section"; + case GF_M2TS_PRIVATE_DATA: + return "Private Data"; + case GF_M2TS_AUDIO_AAC: + return "AAC Audio"; + case GF_M2TS_VIDEO_MPEG4: + return "MPEG-4 Video"; + case GF_M2TS_VIDEO_H264: + return "MPEG-4/H264 Video"; + case GF_M2TS_VIDEO_SVC: + return "H264-SVC Video"; + case GF_M2TS_VIDEO_HEVC: + return "HEVC Video"; + case GF_M2TS_VIDEO_SHVC: + return "SHVC Video"; + + case GF_M2TS_AUDIO_AC3: + return "Dolby AC3 Audio"; + case GF_M2TS_AUDIO_DTS: + return "Dolby DTS Audio"; + case GF_M2TS_SUBTITLE_DVB: + return "DVB Subtitle"; + case GF_M2TS_SYSTEMS_MPEG4_PES: + return "MPEG-4 SL (PES)"; + case GF_M2TS_SYSTEMS_MPEG4_SECTIONS: + return "MPEG-4 SL (Section)"; + case GF_M2TS_MPE_SECTIONS: + return "MPE (Section)"; + + case GF_M2TS_METADATA_PES: + return "Metadata (PES)"; + case GF_M2TS_METADATA_ID3_HLS: + return "ID3/HLS Metadata (PES)"; + + default: + return "Unknown"; } } @@ -188,7 +209,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo u8 *au_start = NULL; GF_M2TS_PES_PCK pck; - if (!same_pts) + if (!same_pts) force_new_au = 1; /*dispatch frame*/ @@ -276,7 +297,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo /*check AU start type - if this is an SHVC PID and the first nal is the first byte of the PES payload, consider this is an AU start*/ if ((nal_type==GF_HEVC_NALU_ACCESS_UNIT) || (pes->depends_on_pid && !first_nal_offset_in_pck)) { if (!prev_is_au_delim) { - //this was not a one AU per PES config, dispatch + //this was not a one AU per PES config, dispatch if (au_start) { pck.data = (char *)au_start; pck.data_len = (u32) (data - au_start); @@ -289,7 +310,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo /*FIXME - we should check the AVC framerate to update the timing ...*/ pck.DTS += 3000; pck.PTS += 3000; - // GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID%d: Two AVC AUs start in this PES packet - cannot recompute non-first AU timing\n", pes->pid)); + // GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID%d: Two AVC AUs start in this PES packet - cannot recompute non-first AU timing\n", pes->pid)); } pck.flags = GF_M2TS_PES_PCK_AU_START; @@ -311,7 +332,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo pck.flags |= GF_M2TS_PES_PCK_RAP; } prev_is_au_delim=0; - } + } else #endif //GPAC_DISABLE_HEVC { @@ -343,7 +364,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo if ((nal_type==GF_AVC_NALU_ACCESS_UNIT) || (nal_type==GF_AVC_NALU_VDRD)) { if (!prev_is_au_delim) { - //this was not a one AU per PES config, dispatch + //this was not a one AU per PES config, dispatch if (au_start) { pck.data = (char *)au_start; pck.data_len = (u32) (data - au_start); @@ -356,7 +377,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo /*FIXME - we should check the AVC framerate to update the timing ...*/ pck.DTS += 3000; pck.PTS += 3000; - // GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID%d: Two AVC AUs start in this PES packet - cannot recompute non-first AU timing\n", pes->pid)); + // GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID%d: Two AVC AUs start in this PES packet - cannot recompute non-first AU timing\n", pes->pid)); } pck.flags = GF_M2TS_PES_PCK_AU_START; force_new_au = 0; @@ -396,7 +417,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo /*we did not consume all data*/ if (!start_code_found) { u32 min_size = is_hevc ? 6 : 5; - + if (au_start) { pck.data = (char *)au_start; pck.data_len = (u32) (data - au_start); @@ -405,21 +426,22 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo } /*if not enough data to locate start code, store it*/ - if (data_len < min_size ) + if (data_len < min_size ) return data_len; /*otherwise this is the middle of a frame, let's dispatch it*/ } if (au_start) { + u8 sc_end = ((data[0]==0) && (data[1]==0) && (data[2]==1)) ? 3 : 4; if (is_hevc) { #ifndef GPAC_DISABLE_HEVC - nal_type = (data[4] & 0x7E) >> 1; + nal_type = (data[sc_end] & 0x7E) >> 1; if ((nal_type>=GF_HEVC_NALU_SLICE_BLA_W_LP) && (nal_type<=GF_HEVC_NALU_SLICE_CRA)) { pck.flags |= GF_M2TS_PES_PCK_RAP; } #endif } else { - nal_type = data[4] & 0x1F; + nal_type = data[sc_end] & 0x1F; if (nal_type==GF_AVC_NALU_IDR_SLICE) pck.flags |= GF_M2TS_PES_PCK_RAP; } @@ -456,7 +478,7 @@ static u32 gf_m2ts_reframe_nalu_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo pck.flags = GF_M2TS_PES_PCK_AU_START; } else if (nal_type==GF_AVC_NALU_IDR_SLICE) { pck.flags = GF_M2TS_PES_PCK_RAP; - } + } } } if (force_new_au) { @@ -529,22 +551,38 @@ static u32 gf_m2ts_reframe_mpeg_video(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo pes->vid_par = (p[3] >> 4) & 0xf; switch (pes->vid_par) { - case 2: num = 4; den = 3; break; - case 3: num = 16; den = 9; break; - case 4: num = 221; den = 100; break; + case 2: + num = 4; + den = 3; + break; + case 3: + num = 16; + den = 9; + break; + case 4: + num = 221; + den = 100; + break; default: - pes->vid_par = 0; - den = num = 0; - break; + pes->vid_par = 0; + den = num = 0; + break; } if (den) - pes->vid_par = ((pes->vid_h/den)<<16) | (pes->vid_w/num); break; + pes->vid_par = ((pes->vid_h/den)<<16) | (pes->vid_w/num); + break; } if (pes->frame_state==0x00) { switch ((data[5] >> 3) & 0x7) { - case 1: pck.flags |= GF_M2TS_PES_PCK_I_FRAME; break; - case 2: pck.flags |= GF_M2TS_PES_PCK_P_FRAME; break; - case 3: pck.flags |= GF_M2TS_PES_PCK_B_FRAME; break; + case 1: + pck.flags |= GF_M2TS_PES_PCK_I_FRAME; + break; + case 2: + pck.flags |= GF_M2TS_PES_PCK_P_FRAME; + break; + case 3: + pck.flags |= GF_M2TS_PES_PCK_B_FRAME; + break; } } } @@ -706,8 +744,8 @@ static u32 gf_m2ts_reframe_aac_adts(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool if (first && pes->prev_PTS) { pes->prev_PTS = 0; - } - /*update PTS in case we don't get any update*/ + } + /*update PTS in case we don't get any update*/ else if (pes->aud_sr) { size = 1024*90000/pes->aud_sr; PTS += size; @@ -729,7 +767,7 @@ static u32 gf_m2ts_reframe_aac_latm(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool /*dispatch frame*/ pck.stream = pes; pck.DTS = pes->DTS; - pck.PTS = pes->PTS; + pck.PTS = pes->PTS; pck.flags = 0; /*fixme - we need to test this with more LATM sources were PES framing is on any boundaries*/ @@ -773,7 +811,7 @@ static u32 gf_m2ts_reframe_aac_latm(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Bool for (i=0; i<=numProgram; i++) { u32 j, num_lay; num_lay = gf_bs_read_int(bs, 3); - for (j=0;j<=num_lay; j++) { + for (j=0; j<=num_lay; j++) { GF_M4ADecSpecInfo cfg; u32 frameLengthType; Bool same_cfg = 0; @@ -874,7 +912,12 @@ static u32 gf_m2ts_reframe_mpeg_audio(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, Boo /*check we don't find a sync point within what we should flush - this happens with looping TS streams and other nasty scenarii*/ next_hdr = gf_mp3_get_next_header_mem((char *)data, data_len, &pos); if (next_hdr && remain && (posaud_sr == gf_mp3_sampling_rate(pes->frame_state) ) + && (pes->aud_nb_ch == gf_mp3_num_channels(pes->frame_state)) + ) { + remain = pos; + } } if (remain) { @@ -1030,7 +1073,7 @@ static void add_text(char **buffer, u32 *size, u32 *pos, char *msg, u32 msg_len) if (*pos+msg_len>*size) { *size = *pos+msg_len-*size+256; *buffer = (char *)gf_realloc(*buffer, *size); - } + } strncpy((*buffer)+(*pos), msg, msg_len); *pos += msg_len; } @@ -1040,10 +1083,10 @@ static GF_Err id3_parse_tag(char *data, u32 length, char **output, u32 *output_s u32 size; u32 pos = 0; /* ID3VVFFFFSIZE = 13bytes - * ID3 string + * ID3 string * VV = Version - * F = Flags - * SIZE = 32bits size with first Most Significant bit set to 0 -> 28 bits + * F = Flags + * SIZE = 32bits size with first Most Significant bit set to 0 -> 28 bits * Size starts AFTER this header, meaning we have to add 10 bytes */ if (data[pos] == 'I' && data[pos+1] == 'D' && data[pos+2] == '3') { @@ -1146,7 +1189,7 @@ static u32 gf_m2ts_sync(GF_M2TS_Demuxer *ts, Bool simple_check) Bool gf_m2ts_crc32_check(char *data, u32 len) { - u32 crc = gf_crc_32(data, len); + u32 crc = gf_crc_32(data, len); u32 crc_val = GF_4CC((u8) data[len], (u8) data[len+1], (u8) data[len+2], (u8) data[len+3]); return (crc==crc_val) ? GF_TRUE : GF_FALSE; } @@ -1156,8 +1199,8 @@ static GF_M2TS_SectionFilter *gf_m2ts_section_filter_new(gf_m2ts_section_callbac { GF_M2TS_SectionFilter *sec; GF_SAFEALLOC(sec, GF_M2TS_SectionFilter); - if (!sec){ - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] gf_m2ts_section_filter_new : OUT OF MEMORY\n")); + if (!sec) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] gf_m2ts_section_filter_new : OUT OF MEMORY\n")); return NULL; } sec->cc = -1; @@ -1244,6 +1287,17 @@ static void gf_m2ts_reset_sdt(GF_M2TS_Demuxer *ts) } } +GF_EXPORT +GF_M2TS_SDT *gf_m2ts_get_sdt_info(GF_M2TS_Demuxer *ts, u32 program_id) +{ + u32 i; + for (i=0; iSDTs); i++) { + GF_M2TS_SDT *sdt = (GF_M2TS_SDT *)gf_list_get(ts->SDTs, i); + if (sdt->service_id==program_id) return sdt; + } + return NULL; +} + static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter *sec, GF_M2TS_SECTION_ES *ses) { //seek mode, only process PAT and PMT @@ -1252,11 +1306,11 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter if (sec->section) gf_free(sec->section); sec->section = NULL; sec->length = sec->received = 0; - return; + return; } if (!sec->process_section) { - if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_AIT)) ) { + if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_AIT)) ) { #ifdef GPAC_ENABLE_DSMCC GF_M2TS_SL_PCK pck; pck.data_len = sec->length; @@ -1266,14 +1320,14 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter on_ait_section(ts, GF_M2TS_EVT_AIT_FOUND, &pck); #endif } else if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_ENCAPSULATED_DATA || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_UN_MESSAGE || - sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_PRIVATE)) ) { + sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGE || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_STREAM_DESCRIPTION || sec->section[0]==GF_M2TS_TABLE_ID_DSM_CC_PRIVATE)) ) { #ifdef GPAC_ENABLE_DSMCC GF_M2TS_SL_PCK pck; pck.data_len = sec->length; pck.data = sec->section; pck.stream = (GF_M2TS_ES *)ses; - on_dsmcc_section(ts,GF_M2TS_EVT_DSMCC_FOUND,&pck); + on_dsmcc_section(ts,GF_M2TS_EVT_DSMCC_FOUND,&pck); //ts->on_event(ts, GF_M2TS_EVT_DSMCC_FOUND, &pck); #endif } @@ -1284,7 +1338,7 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter pck.data = sec->section; pck.stream = (GF_M2TS_ES *)ses; ts->on_mpe_event(ts, GF_M2TS_EVT_DVB_MPE, &pck); - } + } #endif else if (ts->on_event) { GF_M2TS_SL_PCK pck; @@ -1311,19 +1365,19 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter if (ts->on_event) { switch (table_id) { - case GF_M2TS_TABLE_ID_PAT: - case GF_M2TS_TABLE_ID_SDT_ACTUAL: - case GF_M2TS_TABLE_ID_PMT: - case GF_M2TS_TABLE_ID_NIT_ACTUAL: - case GF_M2TS_TABLE_ID_TDT: - case GF_M2TS_TABLE_ID_TOT: - { - GF_M2TS_SL_PCK pck; - pck.data_len = sec->length; - pck.data = sec->section; - pck.stream = (GF_M2TS_ES *)ses; - ts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck); - } + case GF_M2TS_TABLE_ID_PAT: + case GF_M2TS_TABLE_ID_SDT_ACTUAL: + case GF_M2TS_TABLE_ID_PMT: + case GF_M2TS_TABLE_ID_NIT_ACTUAL: + case GF_M2TS_TABLE_ID_TDT: + case GF_M2TS_TABLE_ID_TOT: + { + GF_M2TS_SL_PCK pck; + pck.data_len = sec->length; + pck.data = sec->section; + pck.stream = (GF_M2TS_ES *)ses; + ts->on_event(ts, GF_M2TS_EVT_DVB_GENERAL, &pck); + } } } @@ -1581,94 +1635,94 @@ aggregated_section: static void gf_m2ts_process_sdt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status) { - u32 pos, evt_type; - u32 nb_sections; - u32 data_size; - unsigned char *data; - GF_M2TS_Section *section; - - /*wait for the last section */ - if (!(status&GF_M2TS_TABLE_END)) return; - - /*skip if already received*/ - if (status&GF_M2TS_TABLE_REPEAT) { - if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SDT_REPEAT, NULL); - return; - } - - if (table_id != GF_M2TS_TABLE_ID_SDT_ACTUAL) { - gf_m2ts_reset_sdt(ts); - return; - } - - gf_m2ts_reset_sdt(ts); - - nb_sections = gf_list_count(sections); - if (nb_sections > 1) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] SDT on multiple sections not supported\n")); - } - - section = (GF_M2TS_Section *)gf_list_get(sections, 0); - data = section->data; - data_size = section->data_size; - - //orig_net_id = (data[0] << 8) | data[1]; - pos = 3; - while (pos < data_size) { - GF_M2TS_SDT *sdt; - u32 descs_size, d_pos, ulen; - - GF_SAFEALLOC(sdt, GF_M2TS_SDT); - gf_list_add(ts->SDTs, sdt); - - sdt->service_id = (data[pos]<<8) + data[pos+1]; - sdt->EIT_schedule = (data[pos+2] & 0x2) ? 1 : 0; - sdt->EIT_present_following = (data[pos+2] & 0x1); - sdt->running_status = (data[pos+3]>>5) & 0x7; - sdt->free_CA_mode = (data[pos+3]>>4) & 0x1; - descs_size = ((data[pos+3]&0xf)<<8) | data[pos+4]; - pos += 5; - - d_pos = 0; - while (d_pos < descs_size) { - u8 d_tag = data[pos+d_pos]; - u8 d_len = data[pos+d_pos+1]; - - switch (d_tag) { - case GF_M2TS_DVB_SERVICE_DESCRIPTOR: - if (sdt->provider) gf_free(sdt->provider); - sdt->provider = NULL; - if (sdt->service) gf_free(sdt->service); - sdt->service = NULL; - - d_pos+=2; - sdt->service_type = data[pos+d_pos]; - ulen = data[pos+d_pos+1]; - d_pos += 2; - sdt->provider = (char*)gf_malloc(sizeof(char)*(ulen+1)); - memcpy(sdt->provider, data+pos+d_pos, sizeof(char)*ulen); - sdt->provider[ulen] = 0; - d_pos += ulen; - - ulen = data[pos+d_pos]; - d_pos += 1; - sdt->service = (char*)gf_malloc(sizeof(char)*(ulen+1)); - memcpy(sdt->service, data+pos+d_pos, sizeof(char)*ulen); - sdt->service[ulen] = 0; - d_pos += ulen; - break; - - default: - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) not supported\n", d_tag)); - d_pos += d_len; - if (d_len == 0) d_pos = descs_size; - break; - } - } - pos += descs_size; - } - evt_type = GF_M2TS_EVT_SDT_FOUND; - if (ts->on_event) ts->on_event(ts, evt_type, NULL); + u32 pos, evt_type; + u32 nb_sections; + u32 data_size; + unsigned char *data; + GF_M2TS_Section *section; + + /*wait for the last section */ + if (!(status&GF_M2TS_TABLE_END)) return; + + /*skip if already received*/ + if (status&GF_M2TS_TABLE_REPEAT) { + if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_SDT_REPEAT, NULL); + return; + } + + if (table_id != GF_M2TS_TABLE_ID_SDT_ACTUAL) { + gf_m2ts_reset_sdt(ts); + return; + } + + gf_m2ts_reset_sdt(ts); + + nb_sections = gf_list_count(sections); + if (nb_sections > 1) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] SDT on multiple sections not supported\n")); + } + + section = (GF_M2TS_Section *)gf_list_get(sections, 0); + data = section->data; + data_size = section->data_size; + + //orig_net_id = (data[0] << 8) | data[1]; + pos = 3; + while (pos < data_size) { + GF_M2TS_SDT *sdt; + u32 descs_size, d_pos, ulen; + + GF_SAFEALLOC(sdt, GF_M2TS_SDT); + gf_list_add(ts->SDTs, sdt); + + sdt->service_id = (data[pos]<<8) + data[pos+1]; + sdt->EIT_schedule = (data[pos+2] & 0x2) ? 1 : 0; + sdt->EIT_present_following = (data[pos+2] & 0x1); + sdt->running_status = (data[pos+3]>>5) & 0x7; + sdt->free_CA_mode = (data[pos+3]>>4) & 0x1; + descs_size = ((data[pos+3]&0xf)<<8) | data[pos+4]; + pos += 5; + + d_pos = 0; + while (d_pos < descs_size) { + u8 d_tag = data[pos+d_pos]; + u8 d_len = data[pos+d_pos+1]; + + switch (d_tag) { + case GF_M2TS_DVB_SERVICE_DESCRIPTOR: + if (sdt->provider) gf_free(sdt->provider); + sdt->provider = NULL; + if (sdt->service) gf_free(sdt->service); + sdt->service = NULL; + + d_pos+=2; + sdt->service_type = data[pos+d_pos]; + ulen = data[pos+d_pos+1]; + d_pos += 2; + sdt->provider = (char*)gf_malloc(sizeof(char)*(ulen+1)); + memcpy(sdt->provider, data+pos+d_pos, sizeof(char)*ulen); + sdt->provider[ulen] = 0; + d_pos += ulen; + + ulen = data[pos+d_pos]; + d_pos += 1; + sdt->service = (char*)gf_malloc(sizeof(char)*(ulen+1)); + memcpy(sdt->service, data+pos+d_pos, sizeof(char)*ulen); + sdt->service[ulen] = 0; + d_pos += ulen; + break; + + default: + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) not supported\n", d_tag)); + d_pos += d_len; + if (d_len == 0) d_pos = descs_size; + break; + } + } + pos += descs_size; + } + evt_type = GF_M2TS_EVT_SDT_FOUND; + if (ts->on_event) ts->on_event(ts, evt_type, NULL); } static void gf_m2ts_process_mpeg4section(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *es, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status) @@ -1704,14 +1758,14 @@ static void gf_m2ts_process_nit(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *nit_es, See annex C of DVB-SI ETSI EN 300468 */ static void dvb_decode_mjd_date(u32 date, u16 *year, u8 *month, u8 *day) { - u32 yp, mp, k; - yp = (u32)((date - 15078.2)/365.25); - mp = (u32)((date - 14956.1 - (u32)(yp * 365.25))/30.6001); - *day = (u32)(date - 14956 - (u32)(yp * 365.25) - (u32)(mp * 30.6001)); - if (mp == 14 || mp == 15) k = 1; - else k = 0; - *year = yp + k + 1900; - *month = mp - 1 - k*12; + u32 yp, mp, k; + yp = (u32)((date - 15078.2)/365.25); + mp = (u32)((date - 14956.1 - (u32)(yp * 365.25))/30.6001); + *day = (u32)(date - 14956 - (u32)(yp * 365.25) - (u32)(mp * 30.6001)); + if (mp == 14 || mp == 15) k = 1; + else k = 0; + *year = yp + k + 1900; + *month = mp - 1 - k*12; assert(*year>=1900 && *year<=2100 && *month && *month<=12 && *day && *day<=31); } @@ -1729,15 +1783,15 @@ static void gf_m2ts_process_tdt_tot(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *tdt return; switch (table_id) { - case GF_M2TS_TABLE_ID_TDT: - table_name = "TDT"; - break; - case GF_M2TS_TABLE_ID_TOT: - table_name = "TOT"; - break; - default: - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Unimplemented table_id %u for PID %u\n", table_id, GF_M2TS_PID_TDT_TOT_ST)); - return; + case GF_M2TS_TABLE_ID_TDT: + table_name = "TDT"; + break; + case GF_M2TS_TABLE_ID_TOT: + table_name = "TOT"; + break; + default: + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Unimplemented table_id %u for PID %u\n", table_id, GF_M2TS_PID_TDT_TOT_ST)); + return; } nb_sections = gf_list_count(sections); @@ -1762,63 +1816,63 @@ static void gf_m2ts_process_tdt_tot(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *tdt GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream UTC time is %u/%02u/%02u %02u:%02u:%02u\n", time_table->year, time_table->month, time_table->day, time_table->hour, time_table->minute, time_table->second)); switch (table_id) { - case GF_M2TS_TABLE_ID_TDT: - if (ts->TDT_time) gf_free(ts->TDT_time); - ts->TDT_time = time_table; - if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TDT, time_table); - break; - case GF_M2TS_TABLE_ID_TOT: + case GF_M2TS_TABLE_ID_TDT: + if (ts->TDT_time) gf_free(ts->TDT_time); + ts->TDT_time = time_table; + if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TDT, time_table); + break; + case GF_M2TS_TABLE_ID_TOT: #if 0 - { - u32 pos, loop_len; - loop_len = ((data[5]&0x0f) << 8) | (data[6] & 0xff); - data += 7; - pos = 0; - while (pos < loop_len) { - u8 tag = data[pos]; - pos += 2; - if (tag == GF_M2TS_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR) { - char tmp_time[10]; - u16 offset_hours, offset_minutes; - now->country_code[0] = data[pos]; - now->country_code[1] = data[pos+1]; - now->country_code[2] = data[pos+2]; - now->country_region_id = data[pos+3]>>2; - - sprintf(tmp_time, "%02x", data[pos+4]); - offset_hours = atoi(tmp_time); - sprintf(tmp_time, "%02x", data[pos+5]); - offset_minutes = atoi(tmp_time); - now->local_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60; - if (data[pos+3] & 1) now->local_time_offset_seconds *= -1; - - dvb_decode_mjd_to_unix_time(data+pos+6, &now->unix_next_toc); - - sprintf(tmp_time, "%02x", data[pos+11]); - offset_hours = atoi(tmp_time); - sprintf(tmp_time, "%02x", data[pos+12]); - offset_minutes = atoi(tmp_time); - now->next_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60; - if (data[pos+3] & 1) now->next_time_offset_seconds *= -1; - pos+= 13; - } - } - /*TODO: check lengths are ok*/ - if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table); + { + u32 pos, loop_len; + loop_len = ((data[5]&0x0f) << 8) | (data[6] & 0xff); + data += 7; + pos = 0; + while (pos < loop_len) { + u8 tag = data[pos]; + pos += 2; + if (tag == GF_M2TS_DVB_LOCAL_TIME_OFFSET_DESCRIPTOR) { + char tmp_time[10]; + u16 offset_hours, offset_minutes; + now->country_code[0] = data[pos]; + now->country_code[1] = data[pos+1]; + now->country_code[2] = data[pos+2]; + now->country_region_id = data[pos+3]>>2; + + sprintf(tmp_time, "%02x", data[pos+4]); + offset_hours = atoi(tmp_time); + sprintf(tmp_time, "%02x", data[pos+5]); + offset_minutes = atoi(tmp_time); + now->local_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60; + if (data[pos+3] & 1) now->local_time_offset_seconds *= -1; + + dvb_decode_mjd_to_unix_time(data+pos+6, &now->unix_next_toc); + + sprintf(tmp_time, "%02x", data[pos+11]); + offset_hours = atoi(tmp_time); + sprintf(tmp_time, "%02x", data[pos+12]); + offset_minutes = atoi(tmp_time); + now->next_time_offset_seconds = (offset_hours * 60 + offset_minutes) * 60; + if (data[pos+3] & 1) now->next_time_offset_seconds *= -1; + pos+= 13; } + } + /*TODO: check lengths are ok*/ + if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table); + } #endif - /*check CRC32*/ - if (!gf_m2ts_crc32_check(ts->tdt_tot->section, ts->tdt_tot->length-4)) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] corrupted %s table (CRC32 failed)\n", table_name)); - goto error_exit; - } - if (ts->TDT_time) gf_free(ts->TDT_time); - ts->TDT_time = time_table; - if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table); - break; - default: - assert(0); - goto error_exit; + /*check CRC32*/ + if (!gf_m2ts_crc32_check(ts->tdt_tot->section, ts->tdt_tot->length-4)) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] corrupted %s table (CRC32 failed)\n", table_name)); + goto error_exit; + } + if (ts->TDT_time) gf_free(ts->TDT_time); + ts->TDT_time = time_table; + if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TOT, time_table); + break; + default: + assert(0); + goto error_exit; } return; /*success*/ @@ -1844,7 +1898,7 @@ static GF_M2TS_MetadataPointerDescriptor *gf_m2ts_read_metadata_pointer_descript if (d->format == 0xFF) { d->format_identifier = gf_bs_read_u32(bs); size += 4; - } + } d->service_id = gf_bs_read_u8(bs); d->locator_record_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE); d->carriage_flag = (enum metadata_carriage)gf_bs_read_int(bs, 2); @@ -1867,7 +1921,7 @@ static GF_M2TS_MetadataPointerDescriptor *gf_m2ts_read_metadata_pointer_descript } if (length-size > 0) { d->data_size = length-size; - d->data = (char *)gf_malloc(d->data_size); + d->data = (char *)gf_malloc(d->data_size); gf_bs_read_data(bs, d->data, d->data_size); } return d; @@ -1898,7 +1952,7 @@ static GF_M2TS_MetadataDescriptor *gf_m2ts_read_metadata_descriptor(GF_BitStream if (d->format == 0xFF) { d->format_identifier = gf_bs_read_u32(bs); size += 4; - } + } d->service_id = gf_bs_read_u8(bs); d->decoder_config_flags = gf_bs_read_int(bs, 3); d->dsmcc_flag = (gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE); @@ -2001,9 +2055,9 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF metapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len); gf_bs_del(metadatapd_bs); if (metapd->application_format_identifier == GF_4CC('I', 'D', '3', ' ') && - metapd->format_identifier == GF_4CC('I', 'D', '3', ' ') && - metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) { - /*HLS ID3 Metadata */ + metapd->format_identifier == GF_4CC('I', 'D', '3', ' ') && + metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) { + /*HLS ID3 Metadata */ pmt->program->metadata_pointer_descriptor = metapd; } else { /* don't know what to do with it for now, delete */ @@ -2022,15 +2076,15 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF data += 4 + info_length; data_size -= 4 + info_length; pos = 0; - + /* count de number of program related PMT received */ - for(i=0;iprograms);i++){ - GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i); - if(prog->pmt_pid == pmt->pid){ - break; - } + for(i=0; iprograms); i++) { + GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i); + if(prog->pmt_pid == pmt->pid) { + break; + } } - + while (poscc = -1; pes->flags = GF_M2TS_ES_IS_PES; - if (inherit_pcr) + if (inherit_pcr) pes->flags |= GF_M2TS_INHERIT_PCR; es = (GF_M2TS_ES *)pes; break; @@ -2101,16 +2155,16 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF case GF_M2TS_13818_6_ANNEX_B: case GF_M2TS_13818_6_ANNEX_C: case GF_M2TS_13818_6_ANNEX_D: - case GF_M2TS_PRIVATE_SECTION: + case GF_M2TS_PRIVATE_SECTION: GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES); es = (GF_M2TS_ES *)ses; es->flags |= GF_M2TS_ES_IS_SECTION; es->pid = pid; es->service_id = pmt->program->number; - if(stream_type == GF_M2TS_PRIVATE_SECTION){ + if(stream_type == GF_M2TS_PRIVATE_SECTION) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT section found on pid %d\n", pid)); - }else{ - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private section: pid = %d \n", pid)); + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private section: pid = %d \n", pid)); } /* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */ ses->sec = gf_m2ts_section_filter_new(NULL, 1); @@ -2176,13 +2230,13 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF es->stream_type = GF_M2TS_AUDIO_EC3; break; case GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR: - { - u32 id = data[2]<<8 | data[3]; - if ((id == 0xB) && ses && !ses->sec) { - ses->sec = gf_m2ts_section_filter_new(NULL, 1); - } - } - break; + { + u32 id = data[2]<<8 | data[3]; + if ((id == 0xB) && ses && !ses->sec) { + ses->sec = gf_m2ts_section_filter_new(NULL, 1); + } + } + break; case GF_M2TS_DVB_SUBTITLING_DESCRIPTOR: pes->sub.language[0] = data[2]; pes->sub.language[1] = data[3]; @@ -2194,11 +2248,11 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF es->stream_type = GF_M2TS_DVB_SUBTITLE; break; case GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR: - { - es->component_tag = data[2]; - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number)); - } - break; + { + es->component_tag = data[2]; + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number)); + } + break; case GF_M2TS_DVB_TELETEXT_DESCRIPTOR: es->stream_type = GF_M2TS_DVB_TELETEXT; break; @@ -2210,23 +2264,23 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF pes->depends_on_pid = (data[4] & 0x3F) + es->program->pmt_pid; break; case GF_M2TS_METADATA_DESCRIPTOR: - { - GF_BitStream *metadatad_bs; - GF_M2TS_MetadataDescriptor *metad; - metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ); - metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len); - gf_bs_del(metadatad_bs); - if (metad->application_format_identifier == GF_4CC('I', 'D', '3', ' ') && - metad->format_identifier == GF_4CC('I', 'D', '3', ' ')) { - /*HLS ID3 Metadata */ - pes->metadata_descriptor = metad; - pes->stream_type = GF_M2TS_METADATA_ID3_HLS; - } else { - /* don't know what to do with it for now, delete */ - gf_m2ts_metadata_descriptor_del(metad); - } - } - break; + { + GF_BitStream *metadatad_bs; + GF_M2TS_MetadataDescriptor *metad; + metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ); + metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len); + gf_bs_del(metadatad_bs); + if (metad->application_format_identifier == GF_4CC('I', 'D', '3', ' ') && + metad->format_identifier == GF_4CC('I', 'D', '3', ' ')) { + /*HLS ID3 Metadata */ + pes->metadata_descriptor = metad; + pes->stream_type = GF_M2TS_METADATA_ID3_HLS; + } else { + /* don't know what to do with it for now, delete */ + gf_m2ts_metadata_descriptor_del(metad); + } + } + break; default: GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] skipping descriptor (0x%x) not supported\n", tag)); @@ -2256,10 +2310,10 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF GF_M2TS_ES *o_es = ts->ess[es->pid]; if ((o_es->stream_type == es->stream_type) - && ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK)) - && (o_es->mpeg4_es_id == es->mpeg4_es_id) - && ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang) - ) { + && ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK)) + && (o_es->mpeg4_es_id == es->mpeg4_es_id) + && ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang) + ) { gf_free(es); es = NULL; } else { @@ -2278,8 +2332,8 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF } } - - if (nb_es) { + + if (nb_es) { evt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE; if (ts->on_event) ts->on_event(ts, evt_type, pmt->program); } else { @@ -2298,7 +2352,7 @@ static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF u32 data_size; unsigned char *data; GF_M2TS_Section *section; - + nb_pat++; /*wait for the last section */ @@ -2314,7 +2368,7 @@ static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF if (nb_sections > 1) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PAT on multiple sections not supported\n")); } - + section = (GF_M2TS_Section *)gf_list_get(sections, 0); data = section->data; data_size = section->data_size; @@ -2324,14 +2378,14 @@ static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF return; } - nb_progs = data_size / 4; + nb_progs = data_size / 4; for (i=0; init) { ts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0); } @@ -2352,21 +2406,21 @@ static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF } evt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_PAT_UPDATE : GF_M2TS_EVT_PAT_FOUND; - if (ts->on_event) ts->on_event(ts, evt_type, NULL); + if (ts->on_event) ts->on_event(ts, evt_type, NULL); } static void gf_m2ts_process_cat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status) { u32 evt_type; -/* - GF_M2TS_Program *prog; - GF_M2TS_SECTION_ES *pmt; - u32 i, nb_progs; - u32 nb_sections; - u32 data_size; - unsigned char *data; - GF_M2TS_Section *section; -*/ + /* + GF_M2TS_Program *prog; + GF_M2TS_SECTION_ES *pmt; + u32 i, nb_progs; + u32 nb_sections; + u32 data_size; + unsigned char *data; + GF_M2TS_Section *section; + */ /*wait for the last section */ if (!(status&GF_M2TS_TABLE_END)) return; @@ -2376,43 +2430,43 @@ static void gf_m2ts_process_cat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_CAT_REPEAT, NULL); return; } -/* - nb_sections = gf_list_count(sections); - if (nb_sections > 1) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("CAT on multiple sections not supported\n")); - } + /* + nb_sections = gf_list_count(sections); + if (nb_sections > 1) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("CAT on multiple sections not supported\n")); + } - section = (GF_M2TS_Section *)gf_list_get(sections, 0); - data = section->data; - data_size = section->data_size; + section = (GF_M2TS_Section *)gf_list_get(sections, 0); + data = section->data; + data_size = section->data_size; - nb_progs = data_size / 4; + nb_progs = data_size / 4; - for (i=0; init) { - ts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0); + for (i=0; init) { + ts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0); + } + } else { + GF_SAFEALLOC(prog, GF_M2TS_Program); + prog->streams = gf_list_new(); + prog->pmt_pid = pid; + prog->number = number; + gf_list_add(ts->programs, prog); + GF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES); + pmt->flags = GF_M2TS_ES_IS_SECTION; + gf_list_add(prog->streams, pmt); + pmt->pid = prog->pmt_pid; + pmt->program = prog; + ts->ess[pmt->pid] = (GF_M2TS_ES *)pmt; + pmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0); } - } else { - GF_SAFEALLOC(prog, GF_M2TS_Program); - prog->streams = gf_list_new(); - prog->pmt_pid = pid; - prog->number = number; - gf_list_add(ts->programs, prog); - GF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES); - pmt->flags = GF_M2TS_ES_IS_SECTION; - gf_list_add(prog->streams, pmt); - pmt->pid = prog->pmt_pid; - pmt->program = prog; - ts->ess[pmt->pid] = (GF_M2TS_ES *)pmt; - pmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0); } - } -*/ + */ evt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_CAT_UPDATE : GF_M2TS_EVT_CAT_FOUND; if (ts->on_event) ts->on_event(ts, evt_type, NULL); @@ -2420,14 +2474,14 @@ static void gf_m2ts_process_cat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF u64 gf_m2ts_get_pts(unsigned char *data) { - u64 pts; - u32 val; - pts = (u64)((data[0] >> 1) & 0x07) << 30; - val = (data[1] << 8) | data[2]; - pts |= (u64)(val >> 1) << 15; - val = (data[3] << 8) | data[4]; - pts |= (u64)(val >> 1); - return pts; + u64 pts; + u32 val; + pts = (u64)((data[0] >> 1) & 0x07) << 30; + val = (data[1] << 8) | data[2]; + pts |= (u64)(val >> 1) << 15; + val = (data[3] << 8) | data[4]; + pts |= (u64)(val >> 1); + return pts; } void gf_m2ts_pes_header(GF_M2TS_PES *pes, unsigned char *data, u32 data_size, GF_M2TS_PESHeader *pesh) @@ -2440,26 +2494,26 @@ void gf_m2ts_pes_header(GF_M2TS_PES *pes, unsigned char *data, u32 data_size, GF pesh->id = data[0]; pesh->pck_len = (data[1]<<8) | data[2]; -/* - 2bits - scrambling_control = gf_bs_read_int(bs,2); - priority = gf_bs_read_int(bs,1); -*/ + /* + 2bits + scrambling_control = gf_bs_read_int(bs,2); + priority = gf_bs_read_int(bs,1); + */ pesh->data_alignment = (data[3] & 0x4) ? 1 : 0; -/* - copyright = gf_bs_read_int(bs,1); - original = gf_bs_read_int(bs,1); -*/ + /* + copyright = gf_bs_read_int(bs,1); + original = gf_bs_read_int(bs,1); + */ has_pts = (data[4]&0x80); has_dts = has_pts ? (data[4]&0x40) : 0; -/* - ESCR_flag = gf_bs_read_int(bs,1); - ES_rate_flag = gf_bs_read_int(bs,1); - DSM_flag = gf_bs_read_int(bs,1); - additional_copy_flag = gf_bs_read_int(bs,1); - prev_crc_flag = gf_bs_read_int(bs,1); - extension_flag = gf_bs_read_int(bs,1); -*/ + /* + ESCR_flag = gf_bs_read_int(bs,1); + ES_rate_flag = gf_bs_read_int(bs,1); + DSM_flag = gf_bs_read_int(bs,1); + additional_copy_flag = gf_bs_read_int(bs,1); + prev_crc_flag = gf_bs_read_int(bs,1); + extension_flag = gf_bs_read_int(bs,1); + */ pesh->hdr_data_len = data[5]; @@ -2488,10 +2542,10 @@ static void gf_m2ts_flush_temi(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes) GF_M2TS_TemiTimecodeDescriptor temi_tc; GF_BitStream *bs = gf_bs_new(pes->temi_tc_desc, pes->temi_tc_desc_len, GF_BITSTREAM_READ); u32 has_timestamp = gf_bs_read_int(bs, 2); - u32 has_ntp = gf_bs_read_int(bs, 1); - u32 has_ptp = gf_bs_read_int(bs, 1); - u32 has_timecode = gf_bs_read_int(bs, 2); - + /*u32 has_ntp = */gf_bs_read_int(bs, 1); + /*u32 has_ptp = */gf_bs_read_int(bs, 1); + /*u32 has_timecode = */gf_bs_read_int(bs, 2); + memset(&temi_tc, 0, sizeof(GF_M2TS_TemiTimecodeDescriptor)); temi_tc.force_reload = gf_bs_read_int(bs, 1); temi_tc.is_paused = gf_bs_read_int(bs, 1); @@ -2499,8 +2553,8 @@ static void gf_m2ts_flush_temi(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes) gf_bs_read_int(bs, 7); temi_tc.timeline_id = gf_bs_read_int(bs, 8); if (has_timestamp) { - temi_tc.media_timescale = gf_bs_read_u32(bs); - if (has_timestamp==2) + temi_tc.media_timescale = gf_bs_read_u32(bs); + if (has_timestamp==2) temi_tc.media_timestamp = gf_bs_read_u64(bs); else temi_tc.media_timestamp = gf_bs_read_u32(bs); @@ -2518,19 +2572,19 @@ static void gf_m2ts_flush_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes) /*we need at least a full, valid start code !!*/ if ((pes->pck_data_len >= 4) && !pes->pck_data[0] && !pes->pck_data[1] && (pes->pck_data[2]==0x1)) { u32 len; - u32 stream_id = pes->pck_data[3] | 0x100; - if ((stream_id >= 0x1c0 && stream_id <= 0x1df) || - (stream_id >= 0x1e0 && stream_id <= 0x1ef) || - (stream_id == 0x1bd) || - (stream_id == 0x10d) || - /*SL-packetized*/ - ((u8) pes->pck_data[3]==0xfa) - ) { + u32 stream_id = pes->pck_data[3] | 0x100; + if ((stream_id >= 0x1c0 && stream_id <= 0x1df) || + (stream_id >= 0x1e0 && stream_id <= 0x1ef) || + (stream_id == 0x1bd) || + (stream_id == 0x10d) || + /*SL-packetized*/ + ((u8) pes->pck_data[3]==0xfa) + ) { Bool same_pts = 0; /*OK read header*/ gf_m2ts_pes_header(pes, pes->pck_data+3, pes->pck_data_len-3, &pesh); - + /*send PES timing*/ if (ts->notify_pes_timing) { GF_M2TS_PES_PCK pck; @@ -2563,7 +2617,8 @@ static void gf_m2ts_flush_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes) { if (pes->DTS && (pesh.DTS==pes->DTS)) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d - same DTS "LLU" for two consecutive PES packets \n", pes->pid, pes->DTS) ); - } if (pesh.DTSDTS) { + } + if (pesh.DTSDTS) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d - DTS "LLU" less than previous DTS "LLU"\n", pes->pid, pesh.DTS, pes->DTS) ); } } @@ -2600,9 +2655,12 @@ static void gf_m2ts_flush_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes) } //copy over the remaining of previous PES payload before start of this PES payload if (pes->prev_data_len) { - assert(pes->prev_data_len < len); - offset = len - pes->prev_data_len; - memcpy(pes->pck_data + offset, pes->prev_data, pes->prev_data_len); + if (pes->prev_data_len < len) { + offset = len - pes->prev_data_len; + memcpy(pes->pck_data + offset, pes->prev_data, pes->prev_data_len); + } else { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d PES reassembly buffer overflow (%d bytes not processed from previous PES) - discarding prev data\n", pes->pid, pes->prev_data_len )); + } } if (pes->temi_tc_desc_len) @@ -2638,7 +2696,7 @@ static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_H Bool disc=0; Bool flush_pes = 0; - /*duplicated packet, NOT A DISCONTINUITY, we should discard the packet - however we may encounter this configuration in DASH at segment boundaries. + /*duplicated packet, NOT A DISCONTINUITY, we should discard the packet - however we may encounter this configuration in DASH at segment boundaries. If payload start is set, ignore duplication*/ if (hdr->continuity_counter==pes->cc) { if (!hdr->payload_start || (hdr->adaptation_field!=3) ) return; @@ -2653,7 +2711,7 @@ static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_H pes->flags &= ~GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY; disc = 0; } - disc = 0; + disc = 0; if (disc) { if (hdr->payload_start) { if (pes->pck_data_len) { @@ -2705,7 +2763,7 @@ static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_H return; } /*reassemble*/ - if (pes->pck_data_len + data_size > pes->pck_alloc_len ){ + if (pes->pck_data_len + data_size > pes->pck_alloc_len ) { pes->pck_alloc_len = pes->pck_data_len + data_size; pes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len); } @@ -2737,7 +2795,7 @@ static void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_Adaptation paf->adaptation_field_extension_flag = (data[0] & 0x1) ? 1 : 0; af_extension = data + 1; - if (paf->PCR_flag == 1){ + if (paf->PCR_flag == 1) { u32 base = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]; u64 PCR = (u64) base; paf->PCR_base = (PCR << 1) | (data[5] >> 7); @@ -2800,12 +2858,12 @@ static void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_Adaptation GF_M2TS_TemiLocationDescriptor temi_loc; memset(&temi_loc, 0, sizeof(GF_M2TS_TemiLocationDescriptor) ); temi_loc.reload_external = gf_bs_read_int(bs, 1); - temi_loc.is_announce = gf_bs_read_int(bs, 1); + temi_loc.is_announce = gf_bs_read_int(bs, 1); temi_loc.is_splicing = gf_bs_read_int(bs, 1); external_url = gf_bs_read_int(bs, 1); use_base_temi_url = gf_bs_read_int(bs, 1); - gf_bs_read_int(bs, 3); //reserved - temi_loc.timeline_id = gf_bs_read_int(bs, 8); + gf_bs_read_int(bs, 3); //reserved + temi_loc.timeline_id = gf_bs_read_int(bs, 8); if (!external_url) { if (!use_base_temi_url) { char *_url = URL; @@ -2829,7 +2887,7 @@ static void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_Adaptation GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d AF Location descriptor found - URL %s\n", pid, URL)); if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_TEMI_LOCATION, &temi_loc); } - break; + break; case GF_M2TS_AFDESC_TIMELINE_DESCRIPTOR: if (ts->ess[pid] && (ts->ess[pid]->flags & GF_M2TS_ES_IS_PES)) { GF_M2TS_PES *pes = (GF_M2TS_PES *) ts->ess[pid]; @@ -2839,9 +2897,9 @@ static void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_Adaptation } memcpy(pes->temi_tc_desc, desc, desc_len); pes->temi_tc_desc_len = desc_len; - - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d AF Timeline descriptor found\n", pid)); - } + + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d AF Timeline descriptor found\n", pid)); + } break; } gf_bs_del(bs); @@ -2917,7 +2975,7 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid); payload_size = 0; /*no payload and no PCR, return*/ - if (! paf->PCR_flag) + if (! paf->PCR_flag) return; break; /*reserved*/ @@ -2940,7 +2998,7 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data) if (paf && paf->PCR_flag) { if (!es) { u32 i, j; - for(i=0;iprograms);i++){ + for(i=0; iprograms); i++) { GF_M2TS_Program *program = (GF_M2TS_Program *)gf_list_get(ts->programs,i); if(program->pcr_pid != hdr.pid) continue; for (j=0; jstreams); j++) { @@ -2953,7 +3011,7 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data) break; } es = ts->ess[hdr.pid]; - } + } if (es) { GF_M2TS_PES_PCK pck; memset(&pck, 0, sizeof(GF_M2TS_PES_PCK)); @@ -3050,7 +3108,7 @@ GF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, char *data, u32 data_size) } return GF_OK; } - /*process*/ + /*process*/ gf_m2ts_process_packet(ts, (unsigned char *)ts->buffer+pos); pos += 188; } @@ -3154,6 +3212,25 @@ static void gf_m2ts_process_section_discard(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION { } +GF_EXPORT +u32 gf_m2ts_pes_get_framing_mode(GF_M2TS_PES *pes) +{ + if (pes->flags & GF_M2TS_ES_IS_SECTION) { + if (pes->flags & GF_M2TS_ES_IS_SL) { + if ( ((GF_M2TS_SECTION_ES *)pes)->sec->process_section == gf_m2ts_process_section_discard) + return GF_M2TS_PES_FRAMING_DEFAULT; + + } + return GF_M2TS_PES_FRAMING_SKIP_NO_RESET; + } + + if (!pes->reframe ) return GF_M2TS_PES_FRAMING_SKIP_NO_RESET; + if (pes->reframe == gf_m2ts_reframe_default) return GF_M2TS_PES_FRAMING_RAW; + if (pes->reframe == gf_m2ts_reframe_reset) return GF_M2TS_PES_FRAMING_SKIP; + if (pes->single_nal_mode) return GF_M2TS_PES_FRAMING_DEFAULT_NAL; + return GF_M2TS_PES_FRAMING_DEFAULT; +} + GF_EXPORT GF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode) { @@ -3249,7 +3326,7 @@ GF_M2TS_Demuxer *gf_m2ts_demux_new() #endif ts->requested_progs = gf_list_new(); - ts->requested_pids = gf_list_new(); + ts->requested_pids = gf_list_new(); ts->demux_and_play = 0; ts->nb_prog_pmt_received = 0; ts->ChannelAppList = gf_list_new(); @@ -3258,7 +3335,7 @@ GF_M2TS_Demuxer *gf_m2ts_demux_new() } GF_EXPORT -void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts){ +void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts) { char* temp_dir; u32 length; @@ -3266,17 +3343,17 @@ void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts){ ts->dsmcc_controler = gf_list_new(); ts->process_dmscc = 1; - - temp_dir = gf_get_default_cache_directory(); + + temp_dir = gf_get_default_cache_directory(); length = (u32) strlen(temp_dir); - if(temp_dir[length-1] == GF_PATH_SEPARATOR){ + if(temp_dir[length-1] == GF_PATH_SEPARATOR) { temp_dir[length-1] = 0; } ts->dsmcc_root_dir = (char*)gf_calloc(strlen(temp_dir)+strlen("CarouselData")+2,sizeof(char)); sprintf(ts->dsmcc_root_dir,"%s%cCarouselData",temp_dir,GF_PATH_SEPARATOR); e = gf_mkdir(ts->dsmcc_root_dir); - if(e){ + if(e) { GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process DSMCC] Error during the creation of the directory %s \n",ts->dsmcc_root_dir)); } @@ -3314,25 +3391,25 @@ void gf_m2ts_demux_del(GF_M2TS_Demuxer *ts) if (ts->TDT_time) gf_free(ts->TDT_time); gf_m2ts_reset_sdt(ts); if (ts->tdt_tot) - gf_list_del(ts->SDTs); + gf_list_del(ts->SDTs); #ifdef GPAC_ENABLE_MPE gf_dvb_mpe_shutdown(ts); #endif - if(gf_list_count(ts->dsmcc_controler)){ + if(gf_list_count(ts->dsmcc_controler)) { #ifdef GPAC_ENABLE_DSMCC - GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = (GF_M2TS_DSMCC_OVERLORD*)gf_list_get(ts->dsmcc_controler,0); + GF_M2TS_DSMCC_OVERLORD* dsmcc_overlord = (GF_M2TS_DSMCC_OVERLORD*)gf_list_get(ts->dsmcc_controler,0); gf_cleanup_dir(dsmcc_overlord->root_dir); - gf_rmdir(dsmcc_overlord->root_dir); + gf_rmdir(dsmcc_overlord->root_dir); gf_m2ts_delete_dsmcc_overlord(dsmcc_overlord); - if(ts->dsmcc_root_dir){ + if(ts->dsmcc_root_dir) { gf_free(ts->dsmcc_root_dir); } #endif } - while(gf_list_count(ts->ChannelAppList)){ + while(gf_list_count(ts->ChannelAppList)) { #ifdef GPAC_ENABLE_DSMCC GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo = (GF_M2TS_CHANNEL_APPLICATION_INFO*)gf_list_get(ts->ChannelAppList,0); gf_m2ts_delete_channel_application_info(ChanAppInfo); @@ -3380,8 +3457,8 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b if (sscanf(fileName, "gmem://%d@%p", &size, &mem_address) != 2) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[M2TSDemux] Cannot open next file %s\n", fileName)); return GF_URL_ERROR; - } - if (refresh_type==0) + } + if (refresh_type==0) ts->pos_in_stream = 0; //resume where we left @@ -3391,10 +3468,10 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b remain = (size % 188); size -= remain; - /*process chunk*/ + /*process chunk*/ e = gf_m2ts_process_data(ts, mem_address, size); - if (refresh_type==2) + if (refresh_type==2) ts->pos_in_stream = 0; else ts->pos_in_stream += size; @@ -3403,7 +3480,7 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b char data[188000]; f = gf_f64_open(fileName, "rb"); - + if (!f) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[M2TSDemux] Cannot open next file %s\n", fileName)); return GF_URL_ERROR; @@ -3424,8 +3501,8 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b u32 to_read = 188000; Bool done = 0; u64 avail = gf_bs_available(bs); - - if (avail < 188) + + if (avail < 188) break; if (end_byterange && (read + to_read > end_byterange)) { @@ -3453,7 +3530,7 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b } else { ts->pos_in_stream = gf_bs_get_position(bs); } - + gf_bs_del(bs); fclose(f); @@ -3465,7 +3542,7 @@ GF_Err gf_m2ts_demux_file(GF_M2TS_Demuxer *ts, const char *fileName, u64 start_b if (ts->ess[i]->flags & GF_M2TS_ES_IS_PES) { gf_m2ts_flush_pes(ts, (GF_M2TS_PES *) ts->ess[i]); ts->on_event(ts, GF_M2TS_EVT_EOS, (GF_M2TS_PES *) ts->ess[i]); - } + } } } } @@ -3486,7 +3563,7 @@ static u32 gf_m2ts_demuxer_run(void *_p) GF_M2TS_Demuxer *ts = _p; gf_m2ts_reset_parsers(ts); - + #ifdef GPAC_HAS_LINUX_DVB if (ts->tuner) { // in case of DVB @@ -3496,149 +3573,149 @@ static u32 gf_m2ts_demuxer_run(void *_p) } } else #endif - if (ts->sock) { + if (ts->sock) { #ifndef GPAC_DISABLE_STREAMING - u16 seq_num; - GF_RTPReorder *ch = NULL; + u16 seq_num; + GF_RTPReorder *ch = NULL; #endif - u32 nb_empty=0; - Bool first_run, is_rtp; - FILE *record_to = NULL; - if (ts->record_to) - record_to = gf_f64_open(ts->record_to, "wb"); - - first_run = 1; - is_rtp = 0; - while (ts->run_state) { - size = 0; - /*m2ts chunks by chunks*/ - e = gf_sk_receive(ts->sock, data, UDP_BUFFER_SIZE, 0, &size); - if (!size || e) { - nb_empty++; - if (nb_empty==1000) { - gf_sleep(1); - nb_empty=0; + u32 nb_empty=0; + Bool first_run, is_rtp; + FILE *record_to = NULL; + if (ts->record_to) + record_to = gf_f64_open(ts->record_to, "wb"); + + first_run = 1; + is_rtp = 0; + while (ts->run_state) { + size = 0; + /*m2ts chunks by chunks*/ + e = gf_sk_receive(ts->sock, data, UDP_BUFFER_SIZE, 0, &size); + if (!size || e) { + nb_empty++; + if (nb_empty==1000) { + gf_sleep(1); + nb_empty=0; + } + continue; } - continue; - } - if (first_run) { - first_run = 0; - /*FIXME: we assume only simple RTP packaging (no CSRC nor extensions)*/ - if ((data[0] != 0x47) && ((data[1] & 0x7F) == 33) ) { - is_rtp = 1; + if (first_run) { + first_run = 0; + /*FIXME: we assume only simple RTP packaging (no CSRC nor extensions)*/ + if ((data[0] != 0x47) && ((data[1] & 0x7F) == 33) ) { + is_rtp = 1; #ifndef GPAC_DISABLE_STREAMING - ch = gf_rtp_reorderer_new(100, 500); + ch = gf_rtp_reorderer_new(100, 500); #endif + } } - } - /*process chunk*/ - if (is_rtp) { + /*process chunk*/ + if (is_rtp) { #ifndef GPAC_DISABLE_STREAMING - char *pck; - seq_num = ((data[2] << 8) & 0xFF00) | (data[3] & 0xFF); - gf_rtp_reorderer_add(ch, (void *) data, size, seq_num); - - pck = (char *) gf_rtp_reorderer_get(ch, &size); - if (pck) { - gf_m2ts_process_data(ts, pck+12, size-12); - if (record_to) - fwrite(data+12, size-12, 1, record_to); - gf_free(pck); - } + char *pck; + seq_num = ((data[2] << 8) & 0xFF00) | (data[3] & 0xFF); + gf_rtp_reorderer_add(ch, (void *) data, size, seq_num); + + pck = (char *) gf_rtp_reorderer_get(ch, &size); + if (pck) { + gf_m2ts_process_data(ts, pck+12, size-12); + if (record_to) + fwrite(data+12, size-12, 1, record_to); + gf_free(pck); + } #else - gf_m2ts_process_data(ts, data+12, size-12); - if (record_to) - fwrite(data+12, size-12, 1, record_to); + gf_m2ts_process_data(ts, data+12, size-12); + if (record_to) + fwrite(data+12, size-12, 1, record_to); #endif - } else { - gf_m2ts_process_data(ts, data, size); - if (record_to) - fwrite(data, size, 1, record_to); + } else { + gf_m2ts_process_data(ts, data, size); + if (record_to) + fwrite(data, size, 1, record_to); + } } - } - if (record_to) - fclose(record_to); + if (record_to) + fclose(record_to); #ifndef GPAC_DISABLE_STREAMING - if (ch) - gf_rtp_reorderer_del(ch); + if (ch) + gf_rtp_reorderer_del(ch); #endif - } else if (ts->dnload) { - while (ts->run_state) { - gf_dm_sess_process(ts->dnload); - gf_sleep(1); - } - } else { - u32 pos = 0; - GF_BitStream *ts_bs = NULL; - - if (ts->file) - ts_bs = gf_bs_from_file(ts->file, GF_BITSTREAM_READ); - else - ts_bs = gf_bs_new(ts->ts_data_chunk, ts->ts_data_chunk_size, GF_BITSTREAM_READ); + } else if (ts->dnload) { + while (ts->run_state) { + gf_dm_sess_process(ts->dnload); + gf_sleep(1); + } + } else { + u32 pos = 0; + GF_BitStream *ts_bs = NULL; - while (ts->run_state && gf_bs_available(ts_bs) && !ts->force_file_refresh) { + if (ts->file) + ts_bs = gf_bs_from_file(ts->file, GF_BITSTREAM_READ); + else + ts_bs = gf_bs_new(ts->ts_data_chunk, ts->ts_data_chunk_size, GF_BITSTREAM_READ); - if (ts->start_range && ts->duration) { - Double perc = ts->start_range / (1000 * ts->duration); - pos = (u32) (s64) (perc * ts->file_size); - /*align to TS packet size*/ - pos/=188; - pos*=188; + while (ts->run_state && gf_bs_available(ts_bs) && !ts->force_file_refresh) { - if (pos>=ts->file_size) { - pos = 0; + if (ts->start_range && ts->duration) { + Double perc = ts->start_range / (1000 * ts->duration); + pos = (u32) (s64) (perc * ts->file_size); + /*align to TS packet size*/ + pos/=188; + pos*=188; + + if (pos>=ts->file_size) { + pos = 0; + } + ts->start_range = 0; + gf_bs_seek(ts_bs, pos); } - ts->start_range = 0; - gf_bs_seek(ts_bs, pos); - } - /*m2ts chunks by chunks*/ - size = gf_bs_read_data(ts_bs, data, 188); - if (!size && (ts->loop_demux == 1)) { - gf_bs_seek(ts_bs, pos); - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSDemux] Loop \n")); + /*m2ts chunks by chunks*/ size = gf_bs_read_data(ts_bs, data, 188); - } - if (!size) break; - if (size != 188) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS In] %u bytes read from file instead of 188.\n", size)); - } - /*process chunk*/ - gf_m2ts_process_data(ts, data, size); - - ts->nb_pck++; - - //gf_sleep(0); - /*if asked to regulate, wait until we get a play request*/ - while (ts->run_state && !ts->nb_playing && (ts->file_regulate==1)) { - gf_sleep(50); - continue; - } + if (!size && (ts->loop_demux == 1)) { + gf_bs_seek(ts_bs, pos); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSDemux] Loop \n")); + size = gf_bs_read_data(ts_bs, data, 188); + } + if (!size) break; + if (size != 188) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS In] %u bytes read from file instead of 188.\n", size)); + } + /*process chunk*/ + gf_m2ts_process_data(ts, data, size); - if (!gf_bs_available(ts_bs) && ts->loop_demux == 1){ - gf_bs_seek(ts_bs, pos); - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSDemux] Loop \n")); - gf_sleep(3000); - } - } - ts->force_file_refresh = 0; + ts->nb_pck++; + + //gf_sleep(0); + /*if asked to regulate, wait until we get a play request*/ + while (ts->run_state && !ts->nb_playing && (ts->file_regulate==1)) { + gf_sleep(50); + continue; + } + + if (!gf_bs_available(ts_bs) && ts->loop_demux == 1) { + gf_bs_seek(ts_bs, pos); + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSDemux] Loop \n")); + gf_sleep(3000); + } + } + ts->force_file_refresh = 0; - if (ts_bs) { - pos = (u32) gf_bs_get_position(ts_bs); - gf_bs_del(ts_bs); - ts_bs = NULL; + if (ts_bs) { + pos = (u32) gf_bs_get_position(ts_bs); + gf_bs_del(ts_bs); + ts_bs = NULL; + } } - } for (i=0; iess[i]) { if (ts->ess[i]->flags & GF_M2TS_ES_IS_PES) { gf_m2ts_flush_pes(ts, (GF_M2TS_PES *) ts->ess[i]); ts->on_event(ts, GF_M2TS_EVT_EOS, (GF_M2TS_PES *) ts->ess[i]); - } + } } } GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[M2TSDemux] EOS reached\n")); @@ -3669,7 +3746,7 @@ GF_Err gf_m2ts_get_socket(const char *url, const char *mcast_ifce_or_mobileip, u url += 3; *out_socket = gf_sk_new(sock_type); - if (! (*out_socket) ) { + if (! (*out_socket) ) { return GF_IO_ERR; } @@ -3723,7 +3800,7 @@ static GF_Err gf_dvb_tune(GF_Tuner *tuner, const char *url, const char *chan_pat FILE *chanfile; char line[255], chan_name_t[255]; char freq_str[255], inv[255], bw[255], lcr[255], hier[255], cr[255], - mod[255], transm[255], gi[255], apid_str[255], vpid_str[255]; + mod[255], transm[255], gi[255], apid_str[255], vpid_str[255]; const char *chan_conf = ":%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255[^:]:"; char *chan_name; char *tmp; @@ -3819,16 +3896,16 @@ static GF_Err gf_dvb_tune(GF_Tuner *tuner, const char *url, const char *chan_pat sprintf(dvr_name, "/dev/dvb/adapter%d/dvr0", adapter_num); // Open frontend - if((front1 = open(frontend_name,O_RDWR|O_NONBLOCK)) < 0){ + if((front1 = open(frontend_name,O_RDWR|O_NONBLOCK)) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Cannot open frontend %s.\n", frontend_name)); - return GF_IO_ERR; + return GF_IO_ERR; } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Frontend %s opened.\n", frontend_name)); } // Open demuxes - if ((demux1=open(demux_name, O_RDWR|O_NONBLOCK)) < 0){ + if ((demux1=open(demux_name, O_RDWR|O_NONBLOCK)) < 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Cannot open demux %s\n", demux_name)); - return GF_IO_ERR; + return GF_IO_ERR; } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Demux %s opened.\n", demux_name)); } @@ -3843,8 +3920,8 @@ static GF_Err gf_dvb_tune(GF_Tuner *tuner, const char *url, const char *chan_pat frp.u.ofdm.guard_interval = tuner->guardInterval; frp.u.ofdm.hierarchy_information = tuner->hierarchy; // Set frontend - if (ioctl(front1, FE_SET_FRONTEND, &frp) < 0){ - return GF_IO_ERR; + if (ioctl(front1, FE_SET_FRONTEND, &frp) < 0) { + return GF_IO_ERR; } // Set dumex pesFilterParams.pid = 0x2000; // Linux-DVB API take PID=2000 for FULL/RAW TS flag @@ -3852,13 +3929,13 @@ static GF_Err gf_dvb_tune(GF_Tuner *tuner, const char *url, const char *chan_pat pesFilterParams.output = DMX_OUT_TS_TAP; pesFilterParams.pes_type = DMX_PES_OTHER; pesFilterParams.flags = DMX_IMMEDIATE_START; - if (ioctl(demux1, DMX_SET_PES_FILTER, &pesFilterParams) < 0){ - return GF_IO_ERR; + if (ioctl(demux1, DMX_SET_PES_FILTER, &pesFilterParams) < 0) { + return GF_IO_ERR; + } + /* The following code differs from mplayer and alike because the device is opened in blocking mode */ + if ((tuner->ts_fd = open(dvr_name, O_RDONLY/*|O_NONBLOCK*/)) < 0) { + return GF_IO_ERR; } - /* The following code differs from mplayer and alike because the device is opened in blocking mode */ - if ((tuner->ts_fd = open(dvr_name, O_RDONLY/*|O_NONBLOCK*/)) < 0){ - return GF_IO_ERR; - } return GF_OK; } @@ -3945,9 +4022,9 @@ static GF_Err gf_m2ts_demuxer_setup_file(GF_M2TS_Demuxer *ts, char *url) ts->ts_data_chunk = mem_address; } else { - ts->file = gf_f64_open(url, "rb"); + ts->file = gf_f64_open(url, "rb"); if (!ts->file) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[TSDemux] Could not open TS file: %s\n", url)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[TSDemux] Could not open TS file: %s\n", url)); return GF_IO_ERR; } strcpy(ts->filename, url); @@ -3960,7 +4037,7 @@ static GF_Err gf_m2ts_demuxer_setup_file(GF_M2TS_Demuxer *ts, char *url) /* reinitialization for seek */ ts->end_range = ts->start_range = 0; - ts->nb_playing = 0; + ts->nb_playing = 0; return gf_m2ts_demuxer_play(ts); } @@ -3970,17 +4047,17 @@ GF_Err gf_m2ts_demuxer_setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop) { char szURL[2048]; char *frag; - + ts->file_regulate = 0; ts->duration = 0; - if(loop == 1){ - ts->loop_demux = 1; - GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Loop Mode activated \n")); - } + if(loop == 1) { + ts->loop_demux = 1; + GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Loop Mode activated \n")); + } if (!url) { - return gf_m2ts_demuxer_setup_file(ts, NULL); + return gf_m2ts_demuxer_setup_file(ts, NULL); } strcpy(szURL, url); @@ -3988,9 +4065,9 @@ GF_Err gf_m2ts_demuxer_setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop) if (frag) frag[0] = 0; if (!strnicmp(url, "udp://", 6) - || !strnicmp(url, "mpegts-udp://", 13) - || !strnicmp(url, "mpegts-tcp://", 13) - ) { + || !strnicmp(url, "mpegts-udp://", 13) + || !strnicmp(url, "mpegts-tcp://", 13) + ) { return gf_m2ts_demuxer_setup_live(ts, (char *) szURL); } #ifdef GPAC_HAS_LINUX_DVB @@ -3999,7 +4076,7 @@ GF_Err gf_m2ts_demuxer_setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop) } #endif else { - return gf_m2ts_demuxer_setup_file(ts, (char *) szURL); + return gf_m2ts_demuxer_setup_file(ts, (char *) szURL); } return GF_NOT_SUPPORTED; @@ -4026,15 +4103,15 @@ GF_Err gf_m2ts_demuxer_close(GF_M2TS_Demuxer *ts) } GF_EXPORT -GF_Err gf_m2ts_demuxer_play(GF_M2TS_Demuxer *ts){ +GF_Err gf_m2ts_demuxer_play(GF_M2TS_Demuxer *ts) { /*set the state variable outside the TS thread. If inside, we may get called for shutdown before the TS thread has started and we would overwrite the run_state when entering the TS thread, which would make the thread run forever and the stop() wait forever*/ ts->run_state = 1; - if(ts->th){ + if(ts->th) { /*start playing for tune-in*/ return gf_th_run(ts->th, gf_m2ts_demuxer_run, ts); - }else{ + } else { return gf_m2ts_demuxer_run(ts); } @@ -4052,7 +4129,7 @@ Bool gf_m2ts_probe_file(const char *fileName) u8 *mem_address; if (sscanf(fileName, "gmem://%d@%p", &size, &mem_address) != 2) { return GF_FALSE; - } + } while (size>188 && count) { if (mem_address[0] != 0x47) return 0; @@ -4072,7 +4149,7 @@ Bool gf_m2ts_probe_file(const char *fileName) } if (buf[0] != 0x47) break; - if (read<188) + if (read<188) count = 0; else count--; } @@ -4098,7 +4175,7 @@ static void rewrite_pts_dts(unsigned char *ptr, u64 TS) if (_TS < (u64) -ts_shift) _TS = pcr_mod + _TS + ts_shift; \ else _TS = _TS + ts_shift; \ while (_TS > pcr_mod) _TS -= pcr_mod; \ - + GF_Err gf_m2ts_restamp(char *buffer, u32 size, s64 ts_shift, u8 *is_pes) { @@ -4183,7 +4260,7 @@ GF_Err gf_m2ts_restamp(char *buffer, u32 size, s64 ts_shift, u8 *is_pes) } else { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS Restamp] PID %4d: Wrong PES not beginning with start code\n", pid)); } - done+=188; + done+=188; } return GF_OK; } diff --git a/src/media_tools/reedsolomon.c b/src/media_tools/reedsolomon.c index af40457..96ced38 100644 --- a/src/media_tools/reedsolomon.c +++ b/src/media_tools/reedsolomon.c @@ -1,18 +1,18 @@ /***************************** - * + * * * Multiplication and Arithmetic on Galois Field GF(256) * * From Mee, Daniel, "Magnetic Recording, Volume III", Ch. 5 by Patel. - * + * * (c) 1991 Henry Minsky * * ******************************/ - - -#include -#include + + +#include +#include #include #include @@ -23,7 +23,7 @@ * of degree 8 and cycle length 255. (Ch 5, pp. 275, Magnetic Recording) * The high order 1 bit is implicit */ /* x^8 + x^4 + x^3 + x^2 + 1 */ -#define PPOLY 0x1D +#define PPOLY 0x1D int gexp[512]; @@ -35,63 +35,63 @@ static void init_exp_table (void); void init_galois_tables (void) -{ - /* initialize the table of powers of alpha */ - init_exp_table(); +{ + /* initialize the table of powers of alpha */ + init_exp_table(); } static void init_exp_table (void) { - int i, z; - int pinit,p1,p2,p3,p4,p5,p6,p7,p8; - - pinit = p2 = p3 = p4 = p5 = p6 = p7 = p8 = 0; - p1 = 1; - - gexp[0] = 1; - gexp[255] = gexp[0]; - glog[0] = 0; /* shouldn't log[0] be an error? */ - - for (i = 1; i < 256; i++) { - pinit = p8; - p8 = p7; - p7 = p6; - p6 = p5; - p5 = p4 ^ pinit; - p4 = p3 ^ pinit; - p3 = p2 ^ pinit; - p2 = p1; - p1 = pinit; - gexp[i] = p1 + p2*2 + p3*4 + p4*8 + p5*16 + p6*32 + p7*64 + p8*128; - gexp[i+255] = gexp[i]; - } - - for (i = 1; i < 256; i++) { - for (z = 0; z < 256; z++) { - if (gexp[z] == i) { - glog[i] = z; - break; - } - } - } + int i, z; + int pinit,p1,p2,p3,p4,p5,p6,p7,p8; + + pinit = p2 = p3 = p4 = p5 = p6 = p7 = p8 = 0; + p1 = 1; + + gexp[0] = 1; + gexp[255] = gexp[0]; + glog[0] = 0; /* shouldn't log[0] be an error? */ + + for (i = 1; i < 256; i++) { + pinit = p8; + p8 = p7; + p7 = p6; + p6 = p5; + p5 = p4 ^ pinit; + p4 = p3 ^ pinit; + p3 = p2 ^ pinit; + p2 = p1; + p1 = pinit; + gexp[i] = p1 + p2*2 + p3*4 + p4*8 + p5*16 + p6*32 + p7*64 + p8*128; + gexp[i+255] = gexp[i]; + } + + for (i = 1; i < 256; i++) { + for (z = 0; z < 256; z++) { + if (gexp[z] == i) { + glog[i] = z; + break; + } + } + } } /* multiplication using logarithms */ int gmult(int a, int b) { - int i,j; - if (a==0 || b == 0) return (0); - i = glog[a]; - j = glog[b]; - return (gexp[i+j]); + int i,j; + if (a==0 || b == 0) return (0); + i = glog[a]; + j = glog[b]; + return (gexp[i+j]); } - -int ginv (int elt) -{ - return (gexp[255-glog[elt]]); + +int ginv (int elt) +{ + return (gexp[255-glog[elt]]); } @@ -135,65 +135,66 @@ static int NErasures; /* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */ void Modified_Berlekamp_Massey (void) -{ - int n, L, L2, k, d, i; - int psi[MAXDEG], psi2[MAXDEG], D[MAXDEG]; - int gamma[MAXDEG]; - - /* initialize Gamma, the erasure locator polynomial */ - init_gamma(gamma); - - /* initialize to z */ - copy_poly(D, gamma); - mul_z_poly(D); - - copy_poly(psi, gamma); - k = -1; L = NErasures; - - for (n = NErasures; n < NPAR; n++) { - - d = compute_discrepancy(psi, synBytes, L, n); - - if (d != 0) { - - /* psi2 = psi - d*D */ - for (i = 0; i < MAXDEG; i++) psi2[i] = psi[i] ^ gmult(d, D[i]); - - - if (L < (n-k)) { - L2 = n-k; - k = n-L; - /* D = scale_poly(ginv(d), psi); */ - for (i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d)); - L = L2; - } - - /* psi = psi2 */ - for (i = 0; i < MAXDEG; i++) psi[i] = psi2[i]; - } - - mul_z_poly(D); - } - - for(i = 0; i < MAXDEG; i++) Lambda[i] = psi[i]; - compute_modified_omega(); - - +{ + int n, L, L2, k, d, i; + int psi[MAXDEG], psi2[MAXDEG], D[MAXDEG]; + int gamma[MAXDEG]; + + /* initialize Gamma, the erasure locator polynomial */ + init_gamma(gamma); + + /* initialize to z */ + copy_poly(D, gamma); + mul_z_poly(D); + + copy_poly(psi, gamma); + k = -1; + L = NErasures; + + for (n = NErasures; n < NPAR; n++) { + + d = compute_discrepancy(psi, synBytes, L, n); + + if (d != 0) { + + /* psi2 = psi - d*D */ + for (i = 0; i < MAXDEG; i++) psi2[i] = psi[i] ^ gmult(d, D[i]); + + + if (L < (n-k)) { + L2 = n-k; + k = n-L; + /* D = scale_poly(ginv(d), psi); */ + for (i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d)); + L = L2; + } + + /* psi = psi2 */ + for (i = 0; i < MAXDEG; i++) psi[i] = psi2[i]; + } + + mul_z_poly(D); + } + + for(i = 0; i < MAXDEG; i++) Lambda[i] = psi[i]; + compute_modified_omega(); + + } /* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes, - compute the combined erasure/error evaluator polynomial as + compute the combined erasure/error evaluator polynomial as Psi*S mod z^4 */ void compute_modified_omega () { - int i; - int product[MAXDEG*2]; - - mult_polys(product, Lambda, synBytes); - zero_poly(Omega); - for(i = 0; i < NPAR; i++) Omega[i] = product[i]; + int i; + int product[MAXDEG*2]; + + mult_polys(product, Lambda, synBytes); + zero_poly(Omega); + for(i = 0; i < NPAR; i++) Omega[i] = product[i]; } @@ -201,374 +202,375 @@ compute_modified_omega () void mult_polys (int dst[], int p1[], int p2[]) { - int i, j; - int tmp1[MAXDEG*2]; - - for (i=0; i < (MAXDEG*2); i++) dst[i] = 0; - - for (i = 0; i < MAXDEG; i++) { - for(j=MAXDEG; j<(MAXDEG*2); j++) tmp1[j]=0; - - /* scale tmp1 by p1[i] */ - for(j=0; j= i; j--) tmp1[j] = tmp1[j-i]; - for (j = 0; j < i; j++) tmp1[j] = 0; - - /* add into partial product */ - for(j=0; j < (MAXDEG*2); j++) dst[j] ^= tmp1[j]; - } + int i, j; + int tmp1[MAXDEG*2]; + + for (i=0; i < (MAXDEG*2); i++) dst[i] = 0; + + for (i = 0; i < MAXDEG; i++) { + for(j=MAXDEG; j<(MAXDEG*2); j++) tmp1[j]=0; + + /* scale tmp1 by p1[i] */ + for(j=0; j= i; j--) tmp1[j] = tmp1[j-i]; + for (j = 0; j < i; j++) tmp1[j] = 0; + + /* add into partial product */ + for(j=0; j < (MAXDEG*2); j++) dst[j] ^= tmp1[j]; + } } - + /* gamma = product (1-z*a^Ij) for erasure locs Ij */ void init_gamma (int gamma[]) { - int e, tmp[MAXDEG]; - - zero_poly(gamma); - zero_poly(tmp); - gamma[0] = 1; - - for (e = 0; e < NErasures; e++) { - copy_poly(tmp, gamma); - scale_poly(gexp[ErasureLocs[e]], tmp); - mul_z_poly(tmp); - add_polys(gamma, tmp); - } + int e, tmp[MAXDEG]; + + zero_poly(gamma); + zero_poly(tmp); + gamma[0] = 1; + + for (e = 0; e < NErasures; e++) { + copy_poly(tmp, gamma); + scale_poly(gexp[ErasureLocs[e]], tmp); + mul_z_poly(tmp); + add_polys(gamma, tmp); + } } - - - -void + + + +void compute_next_omega (int d, int A[], int dst[], int src[]) { - int i; - for ( i = 0; i < MAXDEG; i++) { - dst[i] = src[i] ^ gmult(d, A[i]); - } + int i; + for ( i = 0; i < MAXDEG; i++) { + dst[i] = src[i] ^ gmult(d, A[i]); + } } - + int compute_discrepancy (int lambda[], int S[], int L, int n) { - int i, sum=0; - - for (i = 0; i <= L; i++) - sum ^= gmult(lambda[i], S[n-i]); - return (sum); + int i, sum=0; + + for (i = 0; i <= L; i++) + sum ^= gmult(lambda[i], S[n-i]); + return (sum); } /********** polynomial arithmetic *******************/ -void add_polys (int dst[], int src[]) +void add_polys (int dst[], int src[]) { - int i; - for (i = 0; i < MAXDEG; i++) dst[i] ^= src[i]; + int i; + for (i = 0; i < MAXDEG; i++) dst[i] ^= src[i]; } -void copy_poly (int dst[], int src[]) +void copy_poly (int dst[], int src[]) { - int i; - for (i = 0; i < MAXDEG; i++) dst[i] = src[i]; + int i; + for (i = 0; i < MAXDEG; i++) dst[i] = src[i]; } -void scale_poly (int k, int poly[]) -{ - int i; - for (i = 0; i < MAXDEG; i++) poly[i] = gmult(k, poly[i]); +void scale_poly (int k, int poly[]) +{ + int i; + for (i = 0; i < MAXDEG; i++) poly[i] = gmult(k, poly[i]); } -void zero_poly (int poly[]) +void zero_poly (int poly[]) { - int i; - for (i = 0; i < MAXDEG; i++) poly[i] = 0; + int i; + for (i = 0; i < MAXDEG; i++) poly[i] = 0; } /* multiply by z, i.e., shift right by 1 */ static void mul_z_poly (int src[]) { - int i; - for (i = MAXDEG-1; i > 0; i--) src[i] = src[i-1]; - src[0] = 0; + int i; + for (i = MAXDEG-1; i > 0; i--) src[i] = src[i-1]; + src[0] = 0; } /* Finds all the roots of an error-locator polynomial with coefficients - * Lambda[j] by evaluating Lambda at successive values of alpha. - * + * Lambda[j] by evaluating Lambda at successive values of alpha. + * * This can be tested with the decoder's equations case. */ -void +void Find_Roots (void) { - int sum, r, k; - NErrors = 0; - - for (r = 1; r < 256; r++) { - sum = 0; - /* evaluate lambda at r */ - for (k = 0; k < NPAR+1; k++) { - sum ^= gmult(gexp[(k*r)%255], Lambda[k]); - } - if (sum == 0) - { - ErrorLocs[NErrors] = (255-r); NErrors++; - if (RS_DEBUG) fprintf(stderr, "Root found at r = %d, (255-r) = %d\n", r, (255-r)); - } - } + int sum, r, k; + NErrors = 0; + + for (r = 1; r < 256; r++) { + sum = 0; + /* evaluate lambda at r */ + for (k = 0; k < NPAR+1; k++) { + sum ^= gmult(gexp[(k*r)%255], Lambda[k]); + } + if (sum == 0) + { + ErrorLocs[NErrors] = (255-r); + NErrors++; + if (RS_DEBUG) fprintf(stderr, "Root found at r = %d, (255-r) = %d\n", r, (255-r)); + } + } } -/* Combined Erasure And Error Magnitude Computation - * +/* Combined Erasure And Error Magnitude Computation + * * Pass in the codeword, its size in bytes, as well as * an array of any known erasure locations, along the number * of these erasures. - * + * * Evaluate Omega(actually Psi)/Lambda' at the roots - * alpha^(-i) for error locs i. + * alpha^(-i) for error locs i. * * Returns 1 if everything ok, or 0 if an out-of-bounds error is found * */ int -correct_errors_erasures (unsigned char codeword[], - int csize, - int nerasures, - int erasures[]) +correct_errors_erasures (unsigned char codeword[], + int csize, + int nerasures, + int erasures[]) { - int r, i, j, err; - - /* If you want to take advantage of erasure correction, be sure to - set NErasures and ErasureLocs[] with the locations of erasures. - */ - NErasures = nerasures; - for (i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i]; - - Modified_Berlekamp_Massey(); - Find_Roots(); - - - if ((NErrors <= NPAR) && NErrors > 0) { - - /* first check for illegal error locs */ - for (r = 0; r < NErrors; r++) { - if (ErrorLocs[r] >= csize) { - if (RS_DEBUG) fprintf(stderr, "Error loc i=%d outside of codeword length %d\n", i, csize); - return(0); - } - } - - for (r = 0; r < NErrors; r++) { - int num, denom; - i = ErrorLocs[r]; - /* evaluate Omega at alpha^(-i) */ - - num = 0; - for (j = 0; j < MAXDEG; j++) - num ^= gmult(Omega[j], gexp[((255-i)*j)%255]); - - /* evaluate Lambda' (derivative) at alpha^(-i) ; all odd powers disappear */ - denom = 0; - for (j = 1; j < MAXDEG; j += 2) { - denom ^= gmult(Lambda[j], gexp[((255-i)*(j-1)) % 255]); - } - - err = gmult(num, ginv(denom)); - if (RS_DEBUG) fprintf(stderr, "Error magnitude %#x at loc %d\n", err, csize-i); - - codeword[csize-i-1] ^= err; - } - return(1); - } - else { - if (RS_DEBUG && NErrors) fprintf(stderr, "Uncorrectable codeword\n"); - return(0); - } + int r, i, j, err; + + /* If you want to take advantage of erasure correction, be sure to + set NErasures and ErasureLocs[] with the locations of erasures. + */ + NErasures = nerasures; + for (i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i]; + + Modified_Berlekamp_Massey(); + Find_Roots(); + + + if ((NErrors <= NPAR) && NErrors > 0) { + + /* first check for illegal error locs */ + for (r = 0; r < NErrors; r++) { + if (ErrorLocs[r] >= csize) { + if (RS_DEBUG) fprintf(stderr, "Error loc i=%d outside of codeword length %d\n", i, csize); + return(0); + } + } + + for (r = 0; r < NErrors; r++) { + int num, denom; + i = ErrorLocs[r]; + /* evaluate Omega at alpha^(-i) */ + + num = 0; + for (j = 0; j < MAXDEG; j++) + num ^= gmult(Omega[j], gexp[((255-i)*j)%255]); + + /* evaluate Lambda' (derivative) at alpha^(-i) ; all odd powers disappear */ + denom = 0; + for (j = 1; j < MAXDEG; j += 2) { + denom ^= gmult(Lambda[j], gexp[((255-i)*(j-1)) % 255]); + } + + err = gmult(num, ginv(denom)); + if (RS_DEBUG) fprintf(stderr, "Error magnitude %#x at loc %d\n", err, csize-i); + + codeword[csize-i-1] ^= err; + } + return(1); + } + else { + if (RS_DEBUG && NErrors) fprintf(stderr, "Uncorrectable codeword\n"); + return(0); + } } - /* - * Reed Solomon Encoder/Decoder - * - * (c) Henry Minsky (hqm@ua.com), Universal Access 1991-1995 - */ - - /* Encoder parity bytes */ - int pBytes[MAXDEG]; - - /* Decoder syndrome bytes */ - int synBytes[MAXDEG]; - - /* generator polynomial */ - int genPoly[MAXDEG*2]; - - int RS_DEBUG = FALSE; - - static void - compute_genpoly (int nbytes, int genpoly[]); - - /* Initialize lookup tables, polynomials, etc. */ - void - initialize_ecc () - { - /* Initialize the galois field arithmetic tables */ - init_galois_tables(); - - /* Compute the encoder generator polynomial */ - compute_genpoly(NPAR, genPoly); - } - - void - zero_fill_from (unsigned char buf[], int from, int to) - { - int i; - for (i = from; i < to; i++) buf[i] = 0; - } - - /* debugging routines */ - void - print_parity (void) - { - int i; - fprintf(stderr, "Parity Bytes: "); - for (i = 0; i < NPAR; i++) - fprintf(stderr, "[%d]:%x, ",i,pBytes[i]); - fprintf(stderr, "\n"); - } - - - void - print_syndrome (void) - { - int i; - fprintf(stderr, "Syndrome Bytes: "); - for (i = 0; i < NPAR; i++) - fprintf(stderr, "[%d]:%x, ",i,synBytes[i]); - fprintf(stderr, "\n"); - } - - /* Append the parity bytes onto the end of the message */ - void - build_codeword (unsigned char msg[], int nbytes, unsigned char dst[]) - { - int i; - - for (i = 0; i < nbytes; i++) dst[i] = msg[i]; - - for (i = 0; i < NPAR; i++) { - dst[i+nbytes] = pBytes[NPAR-1-i]; - } - } - - /********************************************************** - * Reed Solomon Decoder - * - * Computes the syndrome of a codeword. Puts the results - * into the synBytes[] array. - */ - - void - decode_data(unsigned char data[], int nbytes) - { - int i, j, sum; - for (j = 0; j < NPAR; j++) { - sum = 0; - for (i = 0; i < nbytes; i++) { - sum = data[i] ^ gmult(gexp[j+1], sum); - } - synBytes[j] = sum; - } - } - - - /* Check if the syndrome is zero */ - int - check_syndrome (void) - { - int i, nz = 0; - for (i =0 ; i < NPAR; i++) { - if (synBytes[i] != 0) nz = 1; - } - return nz; - } - - - void - debug_check_syndrome (void) - { - int i; - - for (i = 0; i < 3; i++) { - fprintf(stderr, " inv log S[%d]/S[%d] = %d\n", i, i+1, - glog[gmult(synBytes[i], ginv(synBytes[i+1]))]); - } - } - - - /* Create a generator polynomial for an n byte RS code. - * The coefficients are returned in the genPoly arg. - * Make sure that the genPoly array which is passed in is - * at least n+1 bytes long. - */ - - static void - compute_genpoly (int nbytes, int genpoly[]) - { - int i, tp[256], tp1[256]; - - /* multiply (x + a^n) for n = 1 to nbytes */ - - zero_poly(tp1); - tp1[0] = 1; - - for (i = 1; i <= nbytes; i++) { - zero_poly(tp); - tp[0] = gexp[i]; /* set up x+a^n */ - tp[1] = 1; - - mult_polys(genpoly, tp, tp1); - copy_poly(tp1, genpoly); - } - } - - /* Simulate a LFSR with generator polynomial for n byte RS code. - * Pass in a pointer to the data array, and amount of data. - * - * The parity bytes are deposited into pBytes[], and the whole message - * and parity are copied to dest to make a codeword. - * - */ - - void - encode_data (unsigned char msg[], int nbytes, unsigned char dst[]) - { - int i, LFSR[NPAR+1],dbyte, j; - - for(i=0; i < NPAR+1; i++) LFSR[i]=0; - - for (i = 0; i < nbytes; i++) { - dbyte = msg[i] ^ LFSR[NPAR-1]; - for (j = NPAR-1; j > 0; j--) { - LFSR[j] = LFSR[j-1] ^ gmult(genPoly[j], dbyte); - } - LFSR[0] = gmult(genPoly[0], dbyte); - } - - for (i = 0; i < NPAR; i++) - pBytes[i] = LFSR[i]; - - build_codeword(msg, nbytes, dst); - } - - #endif //GPAC_ENABLE_MPE +/* + * Reed Solomon Encoder/Decoder + * + * (c) Henry Minsky (hqm@ua.com), Universal Access 1991-1995 + */ + +/* Encoder parity bytes */ +int pBytes[MAXDEG]; + +/* Decoder syndrome bytes */ +int synBytes[MAXDEG]; + +/* generator polynomial */ +int genPoly[MAXDEG*2]; + +int RS_DEBUG = FALSE; + +static void +compute_genpoly (int nbytes, int genpoly[]); + +/* Initialize lookup tables, polynomials, etc. */ +void +initialize_ecc () +{ + /* Initialize the galois field arithmetic tables */ + init_galois_tables(); + + /* Compute the encoder generator polynomial */ + compute_genpoly(NPAR, genPoly); +} + +void +zero_fill_from (unsigned char buf[], int from, int to) +{ + int i; + for (i = from; i < to; i++) buf[i] = 0; +} + +/* debugging routines */ +void +print_parity (void) +{ + int i; + fprintf(stderr, "Parity Bytes: "); + for (i = 0; i < NPAR; i++) + fprintf(stderr, "[%d]:%x, ",i,pBytes[i]); + fprintf(stderr, "\n"); +} + + +void +print_syndrome (void) +{ + int i; + fprintf(stderr, "Syndrome Bytes: "); + for (i = 0; i < NPAR; i++) + fprintf(stderr, "[%d]:%x, ",i,synBytes[i]); + fprintf(stderr, "\n"); +} + +/* Append the parity bytes onto the end of the message */ +void +build_codeword (unsigned char msg[], int nbytes, unsigned char dst[]) +{ + int i; + + for (i = 0; i < nbytes; i++) dst[i] = msg[i]; + + for (i = 0; i < NPAR; i++) { + dst[i+nbytes] = pBytes[NPAR-1-i]; + } +} + +/********************************************************** + * Reed Solomon Decoder + * + * Computes the syndrome of a codeword. Puts the results + * into the synBytes[] array. + */ + +void +decode_data(unsigned char data[], int nbytes) +{ + int i, j, sum; + for (j = 0; j < NPAR; j++) { + sum = 0; + for (i = 0; i < nbytes; i++) { + sum = data[i] ^ gmult(gexp[j+1], sum); + } + synBytes[j] = sum; + } +} + + +/* Check if the syndrome is zero */ +int +check_syndrome (void) +{ + int i, nz = 0; + for (i =0 ; i < NPAR; i++) { + if (synBytes[i] != 0) nz = 1; + } + return nz; +} + + +void +debug_check_syndrome (void) +{ + int i; + + for (i = 0; i < 3; i++) { + fprintf(stderr, " inv log S[%d]/S[%d] = %d\n", i, i+1, + glog[gmult(synBytes[i], ginv(synBytes[i+1]))]); + } +} + + +/* Create a generator polynomial for an n byte RS code. + * The coefficients are returned in the genPoly arg. + * Make sure that the genPoly array which is passed in is + * at least n+1 bytes long. + */ + +static void +compute_genpoly (int nbytes, int genpoly[]) +{ + int i, tp[256], tp1[256]; + + /* multiply (x + a^n) for n = 1 to nbytes */ + + zero_poly(tp1); + tp1[0] = 1; + + for (i = 1; i <= nbytes; i++) { + zero_poly(tp); + tp[0] = gexp[i]; /* set up x+a^n */ + tp[1] = 1; + + mult_polys(genpoly, tp, tp1); + copy_poly(tp1, genpoly); + } +} + +/* Simulate a LFSR with generator polynomial for n byte RS code. + * Pass in a pointer to the data array, and amount of data. + * + * The parity bytes are deposited into pBytes[], and the whole message + * and parity are copied to dest to make a codeword. + * + */ + +void +encode_data (unsigned char msg[], int nbytes, unsigned char dst[]) +{ + int i, LFSR[NPAR+1],dbyte, j; + + for(i=0; i < NPAR+1; i++) LFSR[i]=0; + + for (i = 0; i < nbytes; i++) { + dbyte = msg[i] ^ LFSR[NPAR-1]; + for (j = NPAR-1; j > 0; j--) { + LFSR[j] = LFSR[j-1] ^ gmult(genPoly[j], dbyte); + } + LFSR[0] = gmult(genPoly[0], dbyte); + } + + for (i = 0; i < NPAR; i++) + pBytes[i] = LFSR[i]; + + build_codeword(msg, nbytes, dst); +} + +#endif //GPAC_ENABLE_MPE diff --git a/src/media_tools/saf.c b/src/media_tools/saf.c index 50961b5..b498a36 100644 --- a/src/media_tools/saf.c +++ b/src/media_tools/saf.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -198,7 +198,7 @@ GF_Err gf_saf_mux_for_time(GF_SAFMuxer *mux, u32 time_ms, Bool force_end_of_sess *out_data = NULL; *out_size = 0; - + gf_mx_p(mux->mx); if (!force_end_of_session && (mux->state!=1)) { gf_mx_v(mux->mx); @@ -234,7 +234,7 @@ GF_Err gf_saf_mux_for_time(GF_SAFMuxer *mux, u32 time_ms, Bool force_end_of_sess u32 len = (u32) strlen(str->remote_url); gf_bs_write_u16(payload, len); gf_bs_write_data(payload, str->remote_url, len); - } + } if (str->dsi) { gf_bs_write_data(payload, str->dsi, str->dsi_len); } @@ -251,7 +251,7 @@ GF_Err gf_saf_mux_for_time(GF_SAFMuxer *mux, u32 time_ms, Bool force_end_of_sess gf_bs_write_int(bs, dlen, 16); gf_bs_write_data(bs, data, dlen); gf_free(data); - + /*mark as signaled*/ str->state |= 1; } diff --git a/src/media_tools/text_import.c b/src/media_tools/text_import.c index 3c219af..493562b 100644 --- a/src/media_tools/text_import.c +++ b/src/media_tools/text_import.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -41,9 +41,9 @@ enum GF_TEXT_IMPORT_SUB, GF_TEXT_IMPORT_TTXT, GF_TEXT_IMPORT_TEXML, - GF_TEXT_IMPORT_WEBVTT, - GF_TEXT_IMPORT_TTML, - GF_TEXT_IMPORT_SWF_SVG, + GF_TEXT_IMPORT_WEBVTT, + GF_TEXT_IMPORT_TTML, + GF_TEXT_IMPORT_SWF_SVG, }; #define REM_TRAIL_MARKS(__str, __sep) while (1) { \ @@ -53,7 +53,7 @@ enum if (strchr(__sep, __str[_len])) __str[_len] = 0; \ else break; \ } \ - + s32 gf_text_get_utf_type(FILE *in_src) { @@ -68,7 +68,7 @@ s32 gf_text_get_utf_type(FILE *in_src) if (!BOM[2] && !BOM[3]) return -1; gf_f64_seek(in_src, 2, SEEK_SET); return 3; - } + } if ((BOM[0]==0xFE) && (BOM[1]==0xFF)) { /*UTF32 not supported*/ if (!BOM[2] && !BOM[3]) return -1; @@ -115,7 +115,7 @@ static GF_Err gf_text_guess_format(char *filename, u32 *fmt) else if (!strnicmp(ext, ".ttml", 5)) *fmt = GF_TEXT_IMPORT_TTML; ext = strstr(szLine, "?>"); if (ext) ext += 2; - if (!ext[0]){ + if (!ext[0]) { if (!fgets(szLine, 2048, test)) szLine[0] = '\0'; } @@ -124,8 +124,8 @@ static GF_Err gf_text_guess_format(char *filename, u32 *fmt) else if (strstr(szLine, "tt")) *fmt = GF_TEXT_IMPORT_TTML; } else if (strstr(szLine, "WEBVTT") ) - *fmt = GF_TEXT_IMPORT_WEBVTT; - else if (strstr(szLine, " --> ") ) + *fmt = GF_TEXT_IMPORT_WEBVTT; + else if (strstr(szLine, " --> ") ) *fmt = GF_TEXT_IMPORT_SRT; /* might want to change the default to WebVTT */ fclose(test); @@ -189,7 +189,7 @@ char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicod unsigned short *sptr; memset(szLine, 0, sizeof(char)*lineSize); - sOK = fgets(szLine, lineSize, txt_in); + sOK = fgets(szLine, lineSize, txt_in); if (!sOK) return NULL; if (unicode_type<=1) { j=0; @@ -204,18 +204,30 @@ char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicod } /*UTF8 2 bytes char*/ else if ( (szLine[i] & 0xe0) == 0xc0) { - szLineConv[j] = szLine[i]; i++; j++; - } + szLineConv[j] = szLine[i]; + i++; + j++; + } /*UTF8 3 bytes char*/ else if ( (szLine[i] & 0xf0) == 0xe0) { - szLineConv[j] = szLine[i]; i++; j++; - szLineConv[j] = szLine[i]; i++; j++; - } + szLineConv[j] = szLine[i]; + i++; + j++; + szLineConv[j] = szLine[i]; + i++; + j++; + } /*UTF8 4 bytes char*/ else if ( (szLine[i] & 0xf8) == 0xf0) { - szLineConv[j] = szLine[i]; i++; j++; - szLineConv[j] = szLine[i]; i++; j++; - szLineConv[j] = szLine[i]; i++; j++; + szLineConv[j] = szLine[i]; + i++; + j++; + szLineConv[j] = szLine[i]; + i++; + j++; + szLineConv[j] = szLine[i]; + i++; + j++; } else { i+=1; continue; @@ -249,7 +261,7 @@ char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicod szLineConv[i] = 0; strcpy(szLine, szLineConv); /*this is ugly indeed: since input is UTF16-LE, there are many chances the fgets never reads the \0 after a \n*/ - if (unicode_type==3) fgetc(txt_in); + if (unicode_type==3) fgetc(txt_in); return sOK; } @@ -305,7 +317,7 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) timescale = 1000; OCR_ES_ID = ID = 0; } - + if (cfg && cfg->timescale) timescale = cfg->timescale; track = gf_isom_new_track(import->dest, ID, GF_ISOM_MEDIA_TEXT, timescale); if (!track) { @@ -404,46 +416,46 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) char *sOK = gf_text_get_utf8_line(szLine, 2048, srt_in, unicode_type); if (sOK) REM_TRAIL_MARKS(szLine, "\r\n\t ") - if (!sOK || !strlen(szLine)) { - rec.style_flags = 0; - rec.startCharOffset = rec.endCharOffset = 0; - if (txt_line) { - if (prev_end && (start != prev_end)) { - GF_TextSample * empty_samp = gf_isom_new_text_sample(); - s = gf_isom_text_to_sample(empty_samp); - gf_isom_delete_text_sample(empty_samp); + if (!sOK || !strlen(szLine)) { + rec.style_flags = 0; + rec.startCharOffset = rec.endCharOffset = 0; + if (txt_line) { + if (prev_end && (start != prev_end)) { + GF_TextSample * empty_samp = gf_isom_new_text_sample(); + s = gf_isom_text_to_sample(empty_samp); + gf_isom_delete_text_sample(empty_samp); + if (state<=2) { + s->DTS = (u64) ((timescale*prev_end)/1000); + s->IsRAP = 1; + gf_isom_add_sample(import->dest, track, 1, s); + nb_samp++; + } + gf_isom_sample_del(&s); + } + + s = gf_isom_text_to_sample(samp); if (state<=2) { - s->DTS = (u64) ((timescale*prev_end)/1000); + s->DTS = (u64) ((timescale*start)/1000); s->IsRAP = 1; gf_isom_add_sample(import->dest, track, 1, s); + gf_isom_sample_del(&s); nb_samp++; + prev_end = end; } - gf_isom_sample_del(&s); + txt_line = 0; + char_len = 0; + set_start_char = set_end_char = GF_FALSE; + rec.startCharOffset = rec.endCharOffset = 0; + gf_isom_text_reset(samp); + + //gf_import_progress(import, nb_samp, nb_samp+1); + gf_set_progress("Importing SRT", gf_f64_tell(srt_in), file_size); + if (duration && (end >= duration)) break; } - - s = gf_isom_text_to_sample(samp); - if (state<=2) { - s->DTS = (u64) ((timescale*start)/1000); - s->IsRAP = 1; - gf_isom_add_sample(import->dest, track, 1, s); - gf_isom_sample_del(&s); - nb_samp++; - prev_end = end; - } - txt_line = 0; - char_len = 0; - set_start_char = set_end_char = GF_FALSE; - rec.startCharOffset = rec.endCharOffset = 0; - gf_isom_text_reset(samp); - - //gf_import_progress(import, nb_samp, nb_samp+1); - gf_set_progress("Importing SRT", gf_f64_tell(srt_in), file_size); - if (duration && (end >= duration)) break; + state = 0; + if (!sOK) break; + continue; } - state = 0; - if (!sOK) break; - continue; - } switch (state) { case 0: @@ -479,11 +491,11 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) nb_samp++; } rec.style_flags = 0; - state = 2; + state = 2; if (end<=prev_end) { gf_import_message(import, GF_OK, "WARNING: overlapping SRT frame %d end "LLD" is at or before previous end "LLD" - removing", curLine, end, prev_end); start = end; - state = 3; + state = 3; } break; @@ -500,11 +512,11 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) ptr = (char *) szLine; { size_t _len = gf_utf8_mbstowcs(uniLine, 5000, (const char **) &ptr); - if (_len == (size_t) -1) { - e = gf_import_message(import, GF_CORRUPTED_DATA, "Invalid UTF data (line %d)", curLine); - goto exit; - } - len = (u32) _len; + if (_len == (size_t) -1) { + e = gf_import_message(import, GF_CORRUPTED_DATA, "Invalid UTF data (line %d)", curLine); + goto exit; + } + len = (u32) _len; } char_line = 0; i=j=0; @@ -525,18 +537,21 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) if (rec.style_flags) gf_isom_text_add_style(samp, &rec); } switch (uniLine[i+1]) { - case 'b': case 'B': - rec.style_flags |= GF_TXT_STYLE_BOLD; + case 'b': + case 'B': + rec.style_flags |= GF_TXT_STYLE_BOLD; set_start_char = GF_TRUE; rec.startCharOffset = char_len + j; break; - case 'i': case 'I': - rec.style_flags |= GF_TXT_STYLE_ITALIC; + case 'i': + case 'I': + rec.style_flags |= GF_TXT_STYLE_ITALIC; set_start_char = GF_TRUE; rec.startCharOffset = char_len + j; break; - case 'u': case 'U': - rec.style_flags |= GF_TXT_STYLE_UNDERLINED; + case 'u': + case 'U': + rec.style_flags |= GF_TXT_STYLE_UNDERLINED; set_start_char = GF_TRUE; rec.startCharOffset = char_len + j; break; @@ -548,18 +563,21 @@ static GF_Err gf_text_import_srt(GF_MediaImporter *import) /*end of prev style*/ if ( (uniLine[i]=='<') && (uniLine[i+1]=='/') && (uniLine[i+3]=='>')) { switch (uniLine[i+2]) { - case 'b': case 'B': - rem_styles |= GF_TXT_STYLE_BOLD; + case 'b': + case 'B': + rem_styles |= GF_TXT_STYLE_BOLD; set_end_char = GF_TRUE; rec.endCharOffset = char_len + j; break; - case 'i': case 'I': - rem_styles |= GF_TXT_STYLE_ITALIC; + case 'i': + case 'I': + rem_styles |= GF_TXT_STYLE_ITALIC; set_end_char = GF_TRUE; rec.endCharOffset = char_len + j; break; - case 'u': case 'U': - rem_styles |= GF_TXT_STYLE_UNDERLINED; + case 'u': + case 'U': + rem_styles |= GF_TXT_STYLE_UNDERLINED; set_end_char = GF_TRUE; rec.endCharOffset = char_len + j; break; @@ -618,40 +636,40 @@ exit: return e; } -/* Structure used to pass importer and track data to the parsers without exposing the GF_MediaImporter structure +/* Structure used to pass importer and track data to the parsers without exposing the GF_MediaImporter structure used by WebVTT and Flash->SVG */ typedef struct { - GF_MediaImporter *import; - u32 timescale; - u32 track; - u32 descriptionIndex; + GF_MediaImporter *import; + u32 timescale; + u32 track; + u32 descriptionIndex; } GF_ISOFlusher; static GF_Err gf_webvtt_import_report(void *user, GF_Err e, char *message, const char *line) { - GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; - return gf_import_message(flusher->import, e, message, line); + GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; + return gf_import_message(flusher->import, e, message, line); } static void gf_webvtt_import_header(void *user, const char *config) { - GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; - gf_isom_update_webvtt_description(flusher->import->dest, flusher->track, flusher->descriptionIndex, config); + GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; + gf_isom_update_webvtt_description(flusher->import->dest, flusher->track, flusher->descriptionIndex, config); } static void gf_webvtt_flush_sample_to_iso(void *user, GF_WebVTTSample *samp) { - GF_ISOSample *s; - GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; - //gf_webvtt_dump_sample(stdout, samp); - s = gf_isom_webvtt_to_sample(samp); - if (s) { - s->DTS = (u64) (flusher->timescale*gf_webvtt_sample_get_start(samp)/1000); - s->IsRAP = 1; - gf_isom_add_sample(flusher->import->dest, flusher->track, flusher->descriptionIndex, s); - gf_isom_sample_del(&s); - } - gf_webvtt_sample_del(samp); + GF_ISOSample *s; + GF_ISOFlusher *flusher = (GF_ISOFlusher *)user; + //gf_webvtt_dump_sample(stdout, samp); + s = gf_isom_webvtt_to_sample(samp); + if (s) { + s->DTS = (u64) (flusher->timescale*gf_webvtt_sample_get_start(samp)/1000); + s->IsRAP = 1; + gf_isom_add_sample(flusher->import->dest, flusher->track, flusher->descriptionIndex, s); + gf_isom_sample_del(&s); + } + gf_webvtt_sample_del(samp); } static GF_Err gf_text_import_webvtt(GF_MediaImporter *import) @@ -688,7 +706,7 @@ static GF_Err gf_text_import_webvtt(GF_MediaImporter *import) timescale = 1000; OCR_ES_ID = ID = 0; } - + if (cfg && cfg->timescale) timescale = cfg->timescale; track = gf_isom_new_track(import->dest, ID, GF_ISOM_MEDIA_TEXT, timescale); if (!track) { @@ -722,32 +740,32 @@ static GF_Err gf_text_import_webvtt(GF_MediaImporter *import) gf_isom_set_track_layout_info(import->dest, track, w<<16, h<<16, 0, 0, 0); gf_isom_new_webvtt_description(import->dest, track, NULL, NULL, NULL, &descIndex); - + gf_import_message(import, GF_OK, "WebVTT import"); } gf_text_import_set_language(import, track); duration = (u32) (((Double) import->duration)*timescale/1000.0); - vttparser = gf_webvtt_parser_new(); - flusher.import = import; - flusher.timescale = timescale; - flusher.track = track; - flusher.descriptionIndex = descIndex; - e = gf_webvtt_parser_init(vttparser, import->in_name, &flusher, gf_webvtt_import_report, gf_webvtt_flush_sample_to_iso, gf_webvtt_import_header); - if (e != GF_OK) { - gf_webvtt_parser_del(vttparser); - return gf_import_message(import, GF_NOT_SUPPORTED, "Unsupported WebVTT UTF encoding"); - } - e = gf_webvtt_parser_parse(vttparser, duration); - if (e != GF_OK) { - gf_isom_remove_track(import->dest, track); - } - /*do not add any empty sample at the end since it modifies track duration and is not needed - it is the player job - to figure out when to stop displaying the last text sample - However update the last sample duration*/ - gf_isom_set_last_sample_duration(import->dest, track, (u32) gf_webvtt_parser_last_duration(vttparser)); - gf_webvtt_parser_del(vttparser); - return e; + vttparser = gf_webvtt_parser_new(); + flusher.import = import; + flusher.timescale = timescale; + flusher.track = track; + flusher.descriptionIndex = descIndex; + e = gf_webvtt_parser_init(vttparser, import->in_name, &flusher, gf_webvtt_import_report, gf_webvtt_flush_sample_to_iso, gf_webvtt_import_header); + if (e != GF_OK) { + gf_webvtt_parser_del(vttparser); + return gf_import_message(import, GF_NOT_SUPPORTED, "Unsupported WebVTT UTF encoding"); + } + e = gf_webvtt_parser_parse(vttparser, duration); + if (e != GF_OK) { + gf_isom_remove_track(import->dest, track); + } + /*do not add any empty sample at the end since it modifies track duration and is not needed - it is the player job + to figure out when to stop displaying the last text sample + However update the last sample duration*/ + gf_isom_set_last_sample_duration(import->dest, track, (u32) gf_webvtt_parser_last_duration(vttparser)); + gf_webvtt_parser_del(vttparser); + return e; } static GF_Err gf_text_import_ttml(GF_MediaImporter *import) @@ -761,53 +779,53 @@ static GF_Err gf_text_import_ttml(GF_MediaImporter *import) /* SimpleText Text tracks -related functions */ GF_SimpleTextSampleEntryBox *gf_isom_get_simpletext_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex) { - GF_SimpleTextSampleEntryBox *stse; - GF_TrackBox *trak; - GF_Err e; - - if (!descriptionIndex) return NULL; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_READ); - if (e) return NULL; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return NULL; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return NULL; - } - - stse = (GF_SimpleTextSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); - if (!stse) return NULL; - return stse; + GF_SimpleTextSampleEntryBox *stse; + GF_TrackBox *trak; + GF_Err e; + + if (!descriptionIndex) return NULL; + + e = CanAccessMovie(movie, GF_ISOM_OPEN_READ); + if (e) return NULL; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return NULL; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return NULL; + } + + stse = (GF_SimpleTextSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); + if (!stse) return NULL; + return stse; } GF_Box *boxstring_new_with_data(u32 type, const char *string); GF_Err gf_isom_update_simpletext_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, const char *config) { - GF_Err e; - GF_SimpleTextSampleEntryBox *stse; - GF_TrackBox *trak; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); - if (e) return GF_BAD_PARAM; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return GF_BAD_PARAM; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return GF_BAD_PARAM; - } - - stse = (GF_SimpleTextSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); - if (!stse) { + GF_Err e; + GF_SimpleTextSampleEntryBox *stse; + GF_TrackBox *trak; + + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return GF_BAD_PARAM; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return GF_BAD_PARAM; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return GF_BAD_PARAM; + } + + stse = (GF_SimpleTextSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); + if (!stse) { return GF_BAD_PARAM; } else { switch (stse->type) { @@ -821,46 +839,46 @@ GF_Err gf_isom_update_simpletext_description(GF_ISOFile *movie, u32 trackNumber, stse->config = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_STTC, config); return GF_OK; - } + } } -GF_Err gf_isom_new_simpletext_description(GF_ISOFile *movie, u32 trackNumber, GF_TextSampleDescriptor *desc, char *URLname, char *URNname, - const char *content_encoding, const char *mime, u32 *outDescriptionIndex) +GF_Err gf_isom_new_simpletext_description(GF_ISOFile *movie, u32 trackNumber, GF_TextSampleDescriptor *desc, char *URLname, char *URNname, + const char *content_encoding, const char *mime, u32 *outDescriptionIndex) { - GF_TrackBox *trak; - GF_Err e; - u32 dataRefIndex; - GF_SimpleTextSampleEntryBox *stse; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); - if (e) return e; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return GF_BAD_PARAM; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return GF_BAD_PARAM; - } - - //get or create the data ref - e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); - if (e) return e; - if (!dataRefIndex) { - e = Media_CreateDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); - if (e) return e; - } + GF_TrackBox *trak; + GF_Err e; + u32 dataRefIndex; + GF_SimpleTextSampleEntryBox *stse; + + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return e; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return GF_BAD_PARAM; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return GF_BAD_PARAM; + } + + //get or create the data ref + e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); + if (e) return e; + if (!dataRefIndex) { + e = Media_CreateDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); + if (e) return e; + } if (!movie->keep_utc) - trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); + trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); - stse = (GF_SimpleTextSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSE); - stse->dataReferenceIndex = dataRefIndex; + stse = (GF_SimpleTextSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSE); + stse->dataReferenceIndex = dataRefIndex; stse->mime_type = gf_strdup(mime); - gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, stse); - if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); - return e; + gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, stse); + if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); + return e; } @@ -941,7 +959,7 @@ GF_Err gf_text_import_swf(GF_MediaImporter *import) timescale = 1000; OCR_ES_ID = ID = 0; } - + if (cfg && cfg->timescale) timescale = cfg->timescale; track = gf_isom_new_track(import->dest, ID, GF_ISOM_MEDIA_TEXT, timescale); if (!track) { @@ -979,7 +997,7 @@ GF_Err gf_text_import_swf(GF_MediaImporter *import) gf_isom_set_track_layout_info(import->dest, track, w<<16, h<<16, 0, 0, 0); gf_isom_new_simpletext_description(import->dest, track, NULL, NULL, NULL, NULL, mime, &descIndex); - + gf_import_message(import, GF_OK, "SWF import (as text - type: %s)", import->streamFormat); } gf_text_import_set_language(import, track); @@ -994,8 +1012,8 @@ GF_Err gf_text_import_swf(GF_MediaImporter *import) gf_swf_reader_set_user_mode(read, &flusher, swf_svg_add_iso_sample, swf_svg_add_iso_header); if (!import->streamFormat || (import->streamFormat && !stricmp(import->streamFormat, "SVG"))) { e = swf_to_svg_init(read, import->swf_flags, import->swf_flatten_angle); - } else /*if (import->streamFormat && !strcmp(import->streamFormat, "BIFS"))*/ { - e = swf_to_bifs_init(read); + } else { /*if (import->streamFormat && !strcmp(import->streamFormat, "BIFS"))*/ + e = swf_to_bifs_init(read); } if (e) { goto exit; @@ -1040,7 +1058,7 @@ static GF_Err gf_text_import_sub(GF_MediaImporter *import) gf_f64_seek(sub_in, 0, SEEK_END); file_size = gf_f64_tell(sub_in); gf_f64_seek(sub_in, 0, SEEK_SET); - + unicode_type = gf_text_get_utf_type(sub_in); if (unicode_type<0) { fclose(sub_in); @@ -1070,7 +1088,7 @@ static GF_Err gf_text_import_sub(GF_MediaImporter *import) timescale = 1000; ID = 0; } - + if (cfg && cfg->timescale) timescale = cfg->timescale; track = gf_isom_new_track(import->dest, ID, GF_ISOM_MEDIA_TEXT, timescale); if (!track) { @@ -1165,7 +1183,7 @@ static GF_Err gf_text_import_sub(GF_MediaImporter *import) REM_TRAIL_MARKS(szLine, "\r\n\t ") line++; - len = (u32) strlen(szLine); + len = (u32) strlen(szLine); if (!len) continue; i=0; @@ -1173,7 +1191,10 @@ static GF_Err gf_text_import_sub(GF_MediaImporter *import) e = gf_import_message(import, GF_NON_COMPLIANT_BITSTREAM, "Bad SUB file (line %d): expecting \"{\" got \"%c\"", line, szLine[i]); goto exit; } - while (szLine[i+1] && szLine[i+1]!='}') { szTime[i] = szLine[i+1]; i++; } + while (szLine[i+1] && szLine[i+1]!='}') { + szTime[i] = szLine[i+1]; + i++; + } szTime[i] = 0; start = atoi(szTime); if (start= duration)) break; } - gf_isom_delete_text_sample(samp); + gf_isom_delete_text_sample(samp); /*do not add any empty sample at the end since it modifies track duration and is not needed - it is the player job to figure out when to stop displaying the last text sample However update the last sample duration*/ @@ -1258,7 +1282,7 @@ exit: e = gf_import_message(import, GF_BAD_PARAM, "Invalid XML formatting (line %d)", parser.line); \ goto exit; \ } \ - + u32 ttxt_get_color(GF_MediaImporter *import, char *val) { @@ -1267,9 +1291,12 @@ u32 ttxt_get_color(GF_MediaImporter *import, char *val) if (sscanf(val, "%x %x %x %x", &r, &g, &b, &a) != 4) { gf_import_message(import, GF_OK, "Warning: color badly formatted"); } - res = (a&0xFF); res<<=8; - res |= (r&0xFF); res<<=8; - res |= (g&0xFF); res<<=8; + res = (a&0xFF); + res<<=8; + res |= (r&0xFF); + res<<=8; + res |= (g&0xFF); + res<<=8; res |= (b&0xFF); return res; } @@ -1340,9 +1367,9 @@ char *ttxt_parse_string(GF_MediaImporter *import, char *str, Bool strip_lines) } state = !state; } else if (state) { - if ( (i+1==len) || - ((str[i+1]==' ') || (str[i+1]=='\n') || (str[i+1]=='\r') || (str[i+1]=='\t') || (str[i+1]=='\'')) - ) { + if ( (i+1==len) || + ((str[i+1]==' ') || (str[i+1]=='\n') || (str[i+1]=='\r') || (str[i+1]=='\t') || (str[i+1]=='\'')) + ) { state = !state; } else { str[k] = str[i]; @@ -1420,7 +1447,10 @@ static GF_Err gf_text_import_ttxt(GF_MediaImporter *import) i=0; while ( (node = (GF_XMLNode*)gf_list_enum(root->content, &i))) { - if (node->type) { nb_children--; continue; } + if (node->type) { + nb_children--; + continue; + } if (!strcmp(node->name, "TextStreamHeader")) { GF_XMLNode *sdesc; @@ -1442,7 +1472,7 @@ static GF_Err gf_text_import_ttxt(GF_MediaImporter *import) else if (!strcmp(att->name, "trefID")) tref_id = atoi(att->value); } - if (tref_id) + if (tref_id) gf_isom_set_track_reference(import->dest, track, GF_ISOM_BOX_TYPE_CHAP, tref_id); gf_isom_set_track_layout_info(import->dest, track, w<<16, h<<16, tx<<16, ty<<16, (s16) layer); @@ -1710,11 +1740,14 @@ u32 tx3g_get_color(GF_MediaImporter *import, char *value) gf_import_message(import, GF_OK, "Warning: color badly formatted"); } v = (u32) (a*255/100); - res = (v&0xFF); res<<=8; + res = (v&0xFF); + res<<=8; v = (u32) (r*255/100); - res |= (v&0xFF); res<<=8; + res |= (v&0xFF); + res<<=8; v = (u32) (g*255/100); - res |= (v&0xFF); res<<=8; + res |= (v&0xFF); + res<<=8; v = (u32) (b*255/100); res |= (v&0xFF); return res; @@ -1744,7 +1777,7 @@ typedef struct u32 i, __m = atoi(att->value); \ _val = 0; \ for (i=0; iname, "transform")) { Float fx, fy; sscanf(att->value, "translate(%f,%f)", &fx, &fy); - tx = (u32) fx; ty = (u32) fy; + tx = (u32) fx; + ty = (u32) fy; } } @@ -1979,7 +2013,7 @@ static GF_Err gf_text_import_texml(GF_MediaImporter *import) for (k=0; kname, "sampleData")) { GF_XMLNode *sub; u16 start, end; @@ -2030,10 +2064,10 @@ static GF_Err gf_text_import_texml(GF_MediaImporter *import) if (styleID && (!same_style || (td.default_style.startCharOffset != styleID))) { GF_StyleRecord st = td.default_style; for (m=0; mattributes, &m))) { if (!strcmp(att->name, "startMarker")) GET_MARKER_POS(start, 0) - else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) - } + else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) + } gf_isom_text_add_highlight(samp, start, end); } else if (!stricmp(sub->name, "blink")) { m=0; while ((att=(GF_XMLAttribute *)gf_list_enum(sub->attributes, &m))) { if (!strcmp(att->name, "startMarker")) GET_MARKER_POS(start, 0) - else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) - } + else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) + } gf_isom_text_add_blink(samp, start, end); } else if (!stricmp(sub->name, "link")) { @@ -2063,9 +2097,9 @@ static GF_Err gf_text_import_texml(GF_MediaImporter *import) m=0; while ((att=(GF_XMLAttribute *)gf_list_enum(sub->attributes, &m))) { if (!strcmp(att->name, "startMarker")) GET_MARKER_POS(start, 0) - else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) - else if (!strcmp(att->name, "URL") || !strcmp(att->name, "href")) url = gf_strdup(att->value); - else if (!strcmp(att->name, "URLToolTip") || !strcmp(att->name, "altString")) url_tt = gf_strdup(att->value); + else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) + else if (!strcmp(att->name, "URL") || !strcmp(att->name, "href")) url = gf_strdup(att->value); + else if (!strcmp(att->name, "URLToolTip") || !strcmp(att->name, "altString")) url_tt = gf_strdup(att->value); } gf_isom_text_add_hyperlink(samp, url, url_tt, start, end); if (url) gf_free(url); @@ -2087,8 +2121,8 @@ static GF_Err gf_text_import_texml(GF_MediaImporter *import) start = end = 0; while ((att=(GF_XMLAttribute *)gf_list_enum(krok->attributes, &u))) { if (!strcmp(att->name, "startMarker")) GET_MARKER_POS(start, 0) - else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) - else if (!strcmp(att->name, "duration")) time += atoi(att->value); + else if (!strcmp(att->name, "endMarker")) GET_MARKER_POS(end, 1) + else if (!strcmp(att->name, "duration")) time += atoi(att->value); } gf_isom_text_set_karaoke_segment(samp, time, start, end); } @@ -2142,14 +2176,22 @@ GF_Err gf_import_timed_text(GF_MediaImporter *import) return GF_OK; } switch (fmt) { - case GF_TEXT_IMPORT_SRT: return gf_text_import_srt(import); - case GF_TEXT_IMPORT_SUB: return gf_text_import_sub(import); - case GF_TEXT_IMPORT_TTXT: return gf_text_import_ttxt(import); - case GF_TEXT_IMPORT_TEXML: return gf_text_import_texml(import); - case GF_TEXT_IMPORT_WEBVTT: return gf_text_import_webvtt(import); - case GF_TEXT_IMPORT_SWF_SVG: return gf_text_import_swf(import); - case GF_TEXT_IMPORT_TTML: return gf_text_import_ttml(import); - default: return GF_BAD_PARAM; + case GF_TEXT_IMPORT_SRT: + return gf_text_import_srt(import); + case GF_TEXT_IMPORT_SUB: + return gf_text_import_sub(import); + case GF_TEXT_IMPORT_TTXT: + return gf_text_import_ttxt(import); + case GF_TEXT_IMPORT_TEXML: + return gf_text_import_texml(import); + case GF_TEXT_IMPORT_WEBVTT: + return gf_text_import_webvtt(import); + case GF_TEXT_IMPORT_SWF_SVG: + return gf_text_import_swf(import); + case GF_TEXT_IMPORT_TTML: + return gf_text_import_ttml(import); + default: + return GF_BAD_PARAM; } } diff --git a/src/media_tools/vobsub.c b/src/media_tools/vobsub.c index f24cca9..c8ebdd9 100644 --- a/src/media_tools/vobsub.c +++ b/src/media_tools/vobsub.c @@ -10,15 +10,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,144 +34,144 @@ typedef struct _tag_lang_type static lang_type lang_table[] = { -{"--", "und" }, -{"aa", "aar" }, -{"ab", "abk" }, -{"af", "afr" }, -{"am", "amh" }, -{"ar", "ara" }, -{"as", "ast" }, -{"ay", "aym" }, -{"az", "aze" }, -{"ba", "bak" }, -{"be", "bel" }, -{"bg", "bul" }, -{"bh", "bih" }, -{"bi", "bis" }, -{"bn", "ben" }, -{"bo", "bod" }, // was "tib" (Tibetan) -{"br", "bre" }, -{"ca", "cat" }, -{"cc", "und" }, -{"co", "cos" }, -{"cs", "ces" }, // was "cze" (Czech) -{"cy", "cym" }, // was "wel" (Welsh) -{"da", "dan" }, -{"de", "deu" }, // was "ger" (German) -{"dz", "dzo" }, -{"el", "ell" }, // was "gre" (Greek, Modern (1453-)) -{"en", "eng" }, -{"eo", "epo" }, -{"es", "spa" }, -{"et", "est" }, -{"eu", "eus" }, // was "baq" (Basque) -{"fa", "fas" }, // was "per" (Persian) -{"fi", "fin" }, -{"fj", "fij" }, -{"fo", "fao" }, -{"fr", "fra" }, // was "fre" (French) -{"fy", "fry" }, -{"ga", "gle" }, -{"gl", "glg" }, -{"gn", "grn" }, -{"gu", "guj" }, -{"ha", "hau" }, -{"he", "heb" }, -{"hi", "hin" }, -{"hr", "scr" }, -{"hu", "hun" }, -{"hy", "hye" }, // was "arm" (Armenian) -{"ia", "ina" }, -{"id", "ind" }, -{"ik", "ipk" }, -{"is", "isl" }, // was "ice" (Icelandic) -{"it", "ita" }, -{"iu", "iku" }, -{"ja", "jpn" }, -{"jv", "jav" }, -{"ka", "kat" }, // was "geo" (Georgian) -{"kk", "kaz" }, -{"kl", "kal" }, -{"km", "khm" }, -{"kn", "kan" }, -{"ko", "kor" }, -{"ks", "kas" }, -{"ku", "kur" }, -{"ky", "kir" }, -{"la", "lat" }, -{"ln", "lin" }, -{"lo", "lao" }, -{"lt", "lit" }, -{"lv", "lav" }, -{"mg", "mlg" }, -{"mi", "mri" }, // was "mao" (Maori) -{"mk", "mkd" }, // was "mac" (Macedonian) -{"ml", "mlt" }, -{"mn", "mon" }, -{"mo", "mol" }, -{"mr", "mar" }, -{"ms", "msa" }, // was "may" (Malay) -{"my", "mya" }, // was "bur" (Burmese) -{"na", "nau" }, -{"ne", "nep" }, -{"nl", "nld" }, // was "dut" (Dutch; Flemish) -{"no", "nor" }, -{"oc", "oci" }, -{"om", "orm" }, -{"or", "ori" }, -{"pa", "pan" }, -{"pl", "pol" }, -{"ps", "pus" }, -{"pt", "por" }, -{"qu", "que" }, -{"rm", "roh" }, -{"rn", "run" }, -{"ro", "ron" }, // was "rum" (Romanian; Moldavian; Moldovan) -{"ru", "rus" }, -{"rw", "kin" }, -{"sa", "san" }, -{"sd", "snd" }, -{"sg", "sag" }, -{"sh", "scr" }, -{"si", "sin" }, -{"sk", "slk" }, // was "slo" (Slovak) -{"sl", "slv" }, -{"sm", "smo" }, -{"sn", "sna" }, -{"so", "som" }, -{"sq", "sqi" }, // was "alb" (Albanian) -{"sr", "srp" }, -{"ss", "ssw" }, -{"st", "sot" }, -{"su", "sun" }, -{"sv", "swe" }, -{"sw", "swa" }, -{"ta", "tam" }, -{"te", "tel" }, -{"tg", "tgk" }, -{"th", "tha" }, -{"ti", "tir" }, -{"tk", "tuk" }, -{"tl", "tgl" }, -{"tn", "tsn" }, -{"to", "tog" }, -{"tr", "tur" }, -{"ts", "tso" }, -{"tt", "tat" }, -{"tw", "twi" }, -{"ug", "uig" }, -{"uk", "ukr" }, -{"ur", "urd" }, -{"uz", "uzb" }, -{"vi", "vie" }, -{"vo", "vol" }, -{"wo", "wol" }, -{"xh", "xho" }, -{"yi", "yid" }, -{"yo", "yor" }, -{"za", "zha" }, -{"zh", "zho" }, // was "chi" (Chinese) -{"zu", "zul" } + {"--", "und" }, + {"aa", "aar" }, + {"ab", "abk" }, + {"af", "afr" }, + {"am", "amh" }, + {"ar", "ara" }, + {"as", "ast" }, + {"ay", "aym" }, + {"az", "aze" }, + {"ba", "bak" }, + {"be", "bel" }, + {"bg", "bul" }, + {"bh", "bih" }, + {"bi", "bis" }, + {"bn", "ben" }, + {"bo", "bod" }, // was "tib" (Tibetan) + {"br", "bre" }, + {"ca", "cat" }, + {"cc", "und" }, + {"co", "cos" }, + {"cs", "ces" }, // was "cze" (Czech) + {"cy", "cym" }, // was "wel" (Welsh) + {"da", "dan" }, + {"de", "deu" }, // was "ger" (German) + {"dz", "dzo" }, + {"el", "ell" }, // was "gre" (Greek, Modern (1453-)) + {"en", "eng" }, + {"eo", "epo" }, + {"es", "spa" }, + {"et", "est" }, + {"eu", "eus" }, // was "baq" (Basque) + {"fa", "fas" }, // was "per" (Persian) + {"fi", "fin" }, + {"fj", "fij" }, + {"fo", "fao" }, + {"fr", "fra" }, // was "fre" (French) + {"fy", "fry" }, + {"ga", "gle" }, + {"gl", "glg" }, + {"gn", "grn" }, + {"gu", "guj" }, + {"ha", "hau" }, + {"he", "heb" }, + {"hi", "hin" }, + {"hr", "scr" }, + {"hu", "hun" }, + {"hy", "hye" }, // was "arm" (Armenian) + {"ia", "ina" }, + {"id", "ind" }, + {"ik", "ipk" }, + {"is", "isl" }, // was "ice" (Icelandic) + {"it", "ita" }, + {"iu", "iku" }, + {"ja", "jpn" }, + {"jv", "jav" }, + {"ka", "kat" }, // was "geo" (Georgian) + {"kk", "kaz" }, + {"kl", "kal" }, + {"km", "khm" }, + {"kn", "kan" }, + {"ko", "kor" }, + {"ks", "kas" }, + {"ku", "kur" }, + {"ky", "kir" }, + {"la", "lat" }, + {"ln", "lin" }, + {"lo", "lao" }, + {"lt", "lit" }, + {"lv", "lav" }, + {"mg", "mlg" }, + {"mi", "mri" }, // was "mao" (Maori) + {"mk", "mkd" }, // was "mac" (Macedonian) + {"ml", "mlt" }, + {"mn", "mon" }, + {"mo", "mol" }, + {"mr", "mar" }, + {"ms", "msa" }, // was "may" (Malay) + {"my", "mya" }, // was "bur" (Burmese) + {"na", "nau" }, + {"ne", "nep" }, + {"nl", "nld" }, // was "dut" (Dutch; Flemish) + {"no", "nor" }, + {"oc", "oci" }, + {"om", "orm" }, + {"or", "ori" }, + {"pa", "pan" }, + {"pl", "pol" }, + {"ps", "pus" }, + {"pt", "por" }, + {"qu", "que" }, + {"rm", "roh" }, + {"rn", "run" }, + {"ro", "ron" }, // was "rum" (Romanian; Moldavian; Moldovan) + {"ru", "rus" }, + {"rw", "kin" }, + {"sa", "san" }, + {"sd", "snd" }, + {"sg", "sag" }, + {"sh", "scr" }, + {"si", "sin" }, + {"sk", "slk" }, // was "slo" (Slovak) + {"sl", "slv" }, + {"sm", "smo" }, + {"sn", "sna" }, + {"so", "som" }, + {"sq", "sqi" }, // was "alb" (Albanian) + {"sr", "srp" }, + {"ss", "ssw" }, + {"st", "sot" }, + {"su", "sun" }, + {"sv", "swe" }, + {"sw", "swa" }, + {"ta", "tam" }, + {"te", "tel" }, + {"tg", "tgk" }, + {"th", "tha" }, + {"ti", "tir" }, + {"tk", "tuk" }, + {"tl", "tgl" }, + {"tn", "tsn" }, + {"to", "tog" }, + {"tr", "tur" }, + {"ts", "tso" }, + {"tt", "tat" }, + {"tw", "twi" }, + {"ug", "uig" }, + {"uk", "ukr" }, + {"ur", "urd" }, + {"uz", "uzb" }, + {"vi", "vie" }, + {"vo", "vol" }, + {"wo", "wol" }, + {"xh", "xho" }, + {"yi", "yid" }, + {"yo", "yor" }, + {"za", "zha" }, + {"zh", "zho" }, // was "chi" (Chinese) + {"zu", "zul" } }; @@ -312,10 +312,10 @@ GF_Err vobsub_read_idx(FILE *file, vobsub_file *vobsub, s32 *version) u8 palette[16][4]; if (sscanf(str, "%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x", - (u32 *) &palette[0], (u32 *) &palette[1], (u32 *) &palette[2], (u32 *) &palette[3], - (u32 *) &palette[4], (u32 *) &palette[5], (u32 *) &palette[6], (u32 *) &palette[7], - (u32 *) &palette[8], (u32 *) &palette[9], (u32 *) &palette[10], (u32 *) &palette[11], - (u32 *) &palette[12],(u32 *) &palette[13],(u32 *) &palette[14], (u32 *) &palette[15]) != 16) + (u32 *) &palette[0], (u32 *) &palette[1], (u32 *) &palette[2], (u32 *) &palette[3], + (u32 *) &palette[4], (u32 *) &palette[5], (u32 *) &palette[6], (u32 *) &palette[7], + (u32 *) &palette[8], (u32 *) &palette[9], (u32 *) &palette[10], (u32 *) &palette[11], + (u32 *) &palette[12],(u32 *) &palette[13],(u32 *) &palette[14], (u32 *) &palette[15]) != 16) { error = 1; continue; @@ -502,14 +502,30 @@ GF_Err vobsub_get_subpic_duration(char *_data, u32 psize, u32 dsize, u32 *durati cmd = data[i++]; switch (cmd) { - case 0x00: len = 0; break; - case 0x01: len = 0; break; - case 0x02: len = 0; break; - case 0x03: len = 2; break; - case 0x04: len = 2; break; - case 0x05: len = 6; break; - case 0x06: len = 4; break; - default: len = 0; break; + case 0x00: + len = 0; + break; + case 0x01: + len = 0; + break; + case 0x02: + len = 0; + break; + case 0x03: + len = 2; + break; + case 0x04: + len = 2; + break; + case 0x05: + len = 6; + break; + case 0x06: + len = 4; + break; + default: + len = 0; + break; } if (i + len > psize) { @@ -540,7 +556,7 @@ GF_Err vobsub_packetize_subpicture(FILE *fsub, u64 pts, char *data, u32 dataSize { u8 buf[0x800], ptsbuf[5]; u8 *p; - int put_pts = 1; + int put_pts = 1; /* Build PTS buffer */ ptsbuf[0] = (u8)(((pts >> 29) & 0x0e) | 0x21); diff --git a/src/media_tools/webvtt.c b/src/media_tools/webvtt.c index 3c8867e..f61be75 100644 --- a/src/media_tools/webvtt.c +++ b/src/media_tools/webvtt.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,9 +32,9 @@ struct _webvtt_sample { - u64 start; - u64 end; - GF_List *cues; + u64 start; + u64 end; + GF_List *cues; }; @@ -42,304 +42,304 @@ struct _webvtt_sample typedef struct { - GF_ISOM_BOX - GF_StringBox *id; - GF_StringBox *time; - GF_StringBox *settings; - GF_StringBox *payload; + GF_ISOM_BOX + GF_StringBox *id; + GF_StringBox *time; + GF_StringBox *settings; + GF_StringBox *payload; } GF_VTTCueBox; GF_Box *boxstring_New(u32 type) { - ISOM_DECL_BOX_ALLOC(GF_StringBox, type); - return (GF_Box *)tmp; + ISOM_DECL_BOX_ALLOC(GF_StringBox, type); + return (GF_Box *)tmp; } GF_Box *boxstring_new_with_data(u32 type, const char *string) { - ISOM_DECL_BOX_ALLOC(GF_StringBox, type); - if (string) tmp->string = gf_strdup(string); - return (GF_Box *)tmp; + ISOM_DECL_BOX_ALLOC(GF_StringBox, type); + if (string) tmp->string = gf_strdup(string); + return (GF_Box *)tmp; } -GF_Box *vtcu_New() +GF_Box *vtcu_New() { - ISOM_DECL_BOX_ALLOC(GF_VTTCueBox, GF_ISOM_BOX_TYPE_VTCU); - return (GF_Box *)tmp; + ISOM_DECL_BOX_ALLOC(GF_VTTCueBox, GF_ISOM_BOX_TYPE_VTCU); + return (GF_Box *)tmp; } GF_Box *vtte_New() { - ISOM_DECL_BOX_ALLOC(GF_Box, GF_ISOM_BOX_TYPE_VTTE); - return (GF_Box *)tmp; + ISOM_DECL_BOX_ALLOC(GF_Box, GF_ISOM_BOX_TYPE_VTTE); + return (GF_Box *)tmp; } -GF_Box *wvtt_New() +GF_Box *wvtt_New() { - ISOM_DECL_BOX_ALLOC(GF_WebVTTSampleEntryBox, GF_ISOM_BOX_TYPE_WVTT); - return (GF_Box *)tmp; + ISOM_DECL_BOX_ALLOC(GF_WebVTTSampleEntryBox, GF_ISOM_BOX_TYPE_WVTT); + return (GF_Box *)tmp; } void boxstring_del(GF_Box *s) { - GF_StringBox *box = (GF_StringBox *)s; - if (box->string) gf_free(box->string); - gf_free(box); + GF_StringBox *box = (GF_StringBox *)s; + if (box->string) gf_free(box->string); + gf_free(box); } -void vtcu_del(GF_Box *s) +void vtcu_del(GF_Box *s) { - GF_VTTCueBox *box = (GF_VTTCueBox *)s; - if (box->id) gf_isom_box_del((GF_Box *)box->id); - if (box->settings) gf_isom_box_del((GF_Box *)box->settings); - if (box->payload) gf_isom_box_del((GF_Box *)box->payload); + GF_VTTCueBox *box = (GF_VTTCueBox *)s; + if (box->id) gf_isom_box_del((GF_Box *)box->id); + if (box->settings) gf_isom_box_del((GF_Box *)box->settings); + if (box->payload) gf_isom_box_del((GF_Box *)box->payload); gf_free(s); } void vtte_del(GF_Box *s) { - gf_free(s); + gf_free(s); } void wvtt_del(GF_Box *s) { - GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; - if (wvtt->config) gf_isom_box_del((GF_Box *)wvtt->config); - gf_free(s); + GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; + if (wvtt->config) gf_isom_box_del((GF_Box *)wvtt->config); + gf_free(s); } GF_Err boxstring_Read(GF_Box *s, GF_BitStream *bs) { - GF_StringBox *box = (GF_StringBox *)s; - box->string = (char *)gf_malloc((u32)(s->size+1)); - gf_bs_read_data(bs, box->string, (u32)(s->size)); - box->string[(u32)(s->size)] = 0; - return GF_OK; + GF_StringBox *box = (GF_StringBox *)s; + box->string = (char *)gf_malloc((u32)(s->size+1)); + gf_bs_read_data(bs, box->string, (u32)(s->size)); + box->string[(u32)(s->size)] = 0; + return GF_OK; } static GF_Err vtcu_Add(GF_Box *s, GF_Box *box) { - GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; - switch(box->type) { - case GF_ISOM_BOX_TYPE_CTIM: - cuebox->time = (GF_StringBox *)box; - break; - case GF_ISOM_BOX_TYPE_IDEN: - cuebox->id = (GF_StringBox *)box; - break; - case GF_ISOM_BOX_TYPE_STTG: - cuebox->settings = (GF_StringBox *)box; - break; - case GF_ISOM_BOX_TYPE_PAYL: - cuebox->payload = (GF_StringBox *)box; - break; - default: - return gf_isom_box_add_default(s, box); - } - return GF_OK; + GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; + switch(box->type) { + case GF_ISOM_BOX_TYPE_CTIM: + cuebox->time = (GF_StringBox *)box; + break; + case GF_ISOM_BOX_TYPE_IDEN: + cuebox->id = (GF_StringBox *)box; + break; + case GF_ISOM_BOX_TYPE_STTG: + cuebox->settings = (GF_StringBox *)box; + break; + case GF_ISOM_BOX_TYPE_PAYL: + cuebox->payload = (GF_StringBox *)box; + break; + default: + return gf_isom_box_add_default(s, box); + } + return GF_OK; } GF_Err vtcu_Read(GF_Box *s, GF_BitStream *bs) { - return gf_isom_read_box_list(s, bs, vtcu_Add); + return gf_isom_read_box_list(s, bs, vtcu_Add); } GF_Err vtte_Read(GF_Box *s, GF_BitStream *bs) { - return gf_isom_read_box_list(s, bs, gf_isom_box_add_default); + return gf_isom_read_box_list(s, bs, gf_isom_box_add_default); } static GF_Err wvtt_Add(GF_Box *s, GF_Box *box) { - GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; - switch(box->type) { - case GF_ISOM_BOX_TYPE_VTTC: - wvtt->config = (GF_StringBox *)box; - break; - default: - return gf_isom_box_add_default(s, box); - } - return GF_OK; + GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; + switch(box->type) { + case GF_ISOM_BOX_TYPE_VTTC: + wvtt->config = (GF_StringBox *)box; + break; + default: + return gf_isom_box_add_default(s, box); + } + return GF_OK; } GF_Err wvtt_Read(GF_Box *s, GF_BitStream *bs) { - GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; - gf_bs_read_data(bs, wvtt->reserved, 6); - wvtt->dataReferenceIndex = gf_bs_read_u16(bs); - wvtt->size -= 8; - return gf_isom_read_box_list(s, bs, wvtt_Add); + GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; + gf_bs_read_data(bs, wvtt->reserved, 6); + wvtt->dataReferenceIndex = gf_bs_read_u16(bs); + wvtt->size -= 8; + return gf_isom_read_box_list(s, bs, wvtt_Add); } #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err boxstring_Write(GF_Box *s, GF_BitStream *bs) { - GF_Err e; - GF_StringBox *box = (GF_StringBox *)s; - e = gf_isom_box_write_header(s, bs); - if (e) return e; - if (box->string) { - gf_bs_write_data(bs, box->string, (u32)(box->size-8)); - } - return e; + GF_Err e; + GF_StringBox *box = (GF_StringBox *)s; + e = gf_isom_box_write_header(s, bs); + if (e) return e; + if (box->string) { + gf_bs_write_data(bs, box->string, (u32)(box->size-8)); + } + return e; } GF_Err vtcu_Write(GF_Box *s, GF_BitStream *bs) { - GF_Err e; - GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; - e = gf_isom_box_write_header(s, bs); - if (e) return e; - if (cuebox->id) { - e = gf_isom_box_write((GF_Box *)cuebox->id, bs); - if (e) return e; - } - if (cuebox->settings) { - e = gf_isom_box_write((GF_Box *)cuebox->settings, bs); - if (e) return e; - } - if (cuebox->payload) { - e = gf_isom_box_write((GF_Box *)cuebox->payload, bs); - } - return e; + GF_Err e; + GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; + e = gf_isom_box_write_header(s, bs); + if (e) return e; + if (cuebox->id) { + e = gf_isom_box_write((GF_Box *)cuebox->id, bs); + if (e) return e; + } + if (cuebox->settings) { + e = gf_isom_box_write((GF_Box *)cuebox->settings, bs); + if (e) return e; + } + if (cuebox->payload) { + e = gf_isom_box_write((GF_Box *)cuebox->payload, bs); + } + return e; } GF_Err vtte_Write(GF_Box *s, GF_BitStream *bs) { - GF_Err e; - e = gf_isom_box_write_header(s, bs); - return e; + GF_Err e; + e = gf_isom_box_write_header(s, bs); + return e; } GF_Err wvtt_Write(GF_Box *s, GF_BitStream *bs) { - GF_Err e; - GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; - e = gf_isom_box_write_header(s, bs); - gf_bs_write_data(bs, wvtt->reserved, 6); - gf_bs_write_u16(bs, wvtt->dataReferenceIndex); + GF_Err e; + GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; + e = gf_isom_box_write_header(s, bs); + gf_bs_write_data(bs, wvtt->reserved, 6); + gf_bs_write_u16(bs, wvtt->dataReferenceIndex); - if (wvtt->config) gf_isom_box_write((GF_Box *)wvtt->config, bs); - return e; + if (wvtt->config) gf_isom_box_write((GF_Box *)wvtt->config, bs); + return e; } GF_Err boxstring_Size(GF_Box *s) { - GF_Err e; - GF_StringBox *box = (GF_StringBox *)s; - e = gf_isom_box_get_size(s); - if (e) return e; - - box->size += strlen(box->string); - return GF_OK; + GF_Err e; + GF_StringBox *box = (GF_StringBox *)s; + e = gf_isom_box_get_size(s); + if (e) return e; + + box->size += strlen(box->string); + return GF_OK; } GF_Err vtcu_Size(GF_Box *s) { - GF_Err e; - GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; - e = gf_isom_box_get_size(s); - if (e) return e; - if (cuebox->id) { - e = gf_isom_box_size((GF_Box *)cuebox->id); - if (e) return e; - cuebox->size += cuebox->id->size; - } - if (cuebox->settings) { - e = gf_isom_box_size((GF_Box *)cuebox->settings); - if (e) return e; - cuebox->size += cuebox->settings->size; - } - if (cuebox->payload) { - e = gf_isom_box_size((GF_Box *)cuebox->payload); - if (e) return e; - cuebox->size += cuebox->payload->size; - } - return GF_OK; + GF_Err e; + GF_VTTCueBox *cuebox = (GF_VTTCueBox *)s; + e = gf_isom_box_get_size(s); + if (e) return e; + if (cuebox->id) { + e = gf_isom_box_size((GF_Box *)cuebox->id); + if (e) return e; + cuebox->size += cuebox->id->size; + } + if (cuebox->settings) { + e = gf_isom_box_size((GF_Box *)cuebox->settings); + if (e) return e; + cuebox->size += cuebox->settings->size; + } + if (cuebox->payload) { + e = gf_isom_box_size((GF_Box *)cuebox->payload); + if (e) return e; + cuebox->size += cuebox->payload->size; + } + return GF_OK; } GF_Err vtte_Size(GF_Box *s) { - return gf_isom_box_get_size(s); + return gf_isom_box_get_size(s); } GF_Err wvtt_Size(GF_Box *s) { - GF_Err e; - GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; - e = gf_isom_box_get_size(s); - if (e) return e; - s->size += 8; // reserved and dataReferenceIndex - if (wvtt->config) { - e = gf_isom_box_size((GF_Box *)wvtt->config); - if (e) return e; - wvtt->size += wvtt->config->size; - } - return e; + GF_Err e; + GF_WebVTTSampleEntryBox *wvtt = (GF_WebVTTSampleEntryBox *)s; + e = gf_isom_box_get_size(s); + if (e) return e; + s->size += 8; // reserved and dataReferenceIndex + if (wvtt->config) { + e = gf_isom_box_size((GF_Box *)wvtt->config); + if (e) return e; + wvtt->size += wvtt->config->size; + } + return e; } static GF_Err webvtt_write_cue(GF_BitStream *bs, GF_WebVTTCue *cue) { - GF_Err e; - GF_VTTCueBox *cuebox; - if (!cue) return GF_OK; + GF_Err e; + GF_VTTCueBox *cuebox; + if (!cue) return GF_OK; - cuebox = (GF_VTTCueBox *)vtcu_New(); - if (cue->id) { - cuebox->id = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_IDEN, cue->id); - } - if (cue->settings) { - cuebox->settings = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_STTG, cue->settings); - } - if (cue->text) { - cuebox->payload = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_PAYL, cue->text); - } + cuebox = (GF_VTTCueBox *)vtcu_New(); + if (cue->id) { + cuebox->id = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_IDEN, cue->id); + } + if (cue->settings) { + cuebox->settings = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_STTG, cue->settings); + } + if (cue->text) { + cuebox->payload = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_PAYL, cue->text); + } - e = gf_isom_box_size((GF_Box *)cuebox); - if (!e) e = gf_isom_box_write((GF_Box *)cuebox, bs); + e = gf_isom_box_size((GF_Box *)cuebox); + if (!e) e = gf_isom_box_write((GF_Box *)cuebox, bs); - gf_isom_box_del((GF_Box *)cuebox); - return e; + gf_isom_box_del((GF_Box *)cuebox); + return e; } GF_ISOSample *gf_isom_webvtt_to_sample(void *s) { - GF_Err e = GF_OK; - GF_ISOSample *res; - GF_BitStream *bs; - u32 i; - GF_WebVTTCue *cue; - GF_WebVTTSample *samp = (GF_WebVTTSample *)s; - if (!samp) return NULL; - - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); - - if (gf_list_count(samp->cues)) { - i=0; - while ((cue = (GF_WebVTTCue *)gf_list_enum(samp->cues, &i))) { - e = webvtt_write_cue(bs, cue); - if (e) break; - } - if (e) { - gf_bs_del(bs); - return NULL; - } - } else { - GF_Box *cuebox = (GF_Box *)vtte_New(); - e = gf_isom_box_size((GF_Box *)cuebox); - if (!e) e = gf_isom_box_write((GF_Box *)cuebox, bs); - gf_isom_box_del((GF_Box *)cuebox); - if (e) { - gf_bs_del(bs); - return NULL; - } - } - res = gf_isom_sample_new(); - if (!res) { - gf_bs_del(bs); - return NULL; - } - gf_bs_get_content(bs, &res->data, &res->dataLength); - gf_bs_del(bs); - res->IsRAP = 1; - return res; + GF_Err e = GF_OK; + GF_ISOSample *res; + GF_BitStream *bs; + u32 i; + GF_WebVTTCue *cue; + GF_WebVTTSample *samp = (GF_WebVTTSample *)s; + if (!samp) return NULL; + + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + + if (gf_list_count(samp->cues)) { + i=0; + while ((cue = (GF_WebVTTCue *)gf_list_enum(samp->cues, &i))) { + e = webvtt_write_cue(bs, cue); + if (e) break; + } + if (e) { + gf_bs_del(bs); + return NULL; + } + } else { + GF_Box *cuebox = (GF_Box *)vtte_New(); + e = gf_isom_box_size((GF_Box *)cuebox); + if (!e) e = gf_isom_box_write((GF_Box *)cuebox, bs); + gf_isom_box_del((GF_Box *)cuebox); + if (e) { + gf_bs_del(bs); + return NULL; + } + } + res = gf_isom_sample_new(); + if (!res) { + gf_bs_del(bs); + return NULL; + } + gf_bs_get_content(bs, &res->data, &res->dataLength); + gf_bs_del(bs); + res->IsRAP = 1; + return res; } #endif /*GPAC_DISABLE_ISOM_WRITE*/ @@ -349,179 +349,183 @@ void gf_box_dump_done(char *name, GF_Box *ptr, FILE *trace); GF_Err boxstring_dump(GF_Box *a, FILE * trace) { - GF_StringBox *sbox = (GF_StringBox *)a; - fprintf(trace, "\n", sbox->string); - DumpBox(a, trace); - gf_box_dump_done("StringBox", a, trace); - return GF_OK; + GF_StringBox *sbox = (GF_StringBox *)a; + fprintf(trace, "\n", sbox->string); + DumpBox(a, trace); + gf_box_dump_done("StringBox", a, trace); + return GF_OK; } GF_Err vtcu_dump(GF_Box *a, FILE * trace) { - GF_VTTCueBox *cuebox = (GF_VTTCueBox *)a; - fprintf(trace, "\n"); - DumpBox(a, trace); - if (cuebox->id) boxstring_dump((GF_Box *)cuebox->id, trace); - if (cuebox->settings) boxstring_dump((GF_Box *)cuebox->settings, trace); - if (cuebox->payload) boxstring_dump((GF_Box *)cuebox->payload, trace); - gf_box_dump_done("WebVTTCueBox", a, trace); - return GF_OK; + GF_VTTCueBox *cuebox = (GF_VTTCueBox *)a; + fprintf(trace, "\n"); + DumpBox(a, trace); + if (cuebox->id) boxstring_dump((GF_Box *)cuebox->id, trace); + if (cuebox->settings) boxstring_dump((GF_Box *)cuebox->settings, trace); + if (cuebox->payload) boxstring_dump((GF_Box *)cuebox->payload, trace); + gf_box_dump_done("WebVTTCueBox", a, trace); + return GF_OK; } -GF_Err vtte_dump(GF_Box *a, FILE * trace) +GF_Err vtte_dump(GF_Box *a, FILE * trace) { - fprintf(trace, "\n"); - DumpBox(a, trace); - gf_box_dump_done("WebVTTEmptyCueBox", a, trace); - return GF_OK; + fprintf(trace, "\n"); + DumpBox(a, trace); + gf_box_dump_done("WebVTTEmptyCueBox", a, trace); + return GF_OK; } GF_Err wvtt_dump(GF_Box *a, FILE * trace) { - GF_WebVTTSampleEntryBox *cuebox = (GF_WebVTTSampleEntryBox *)a; - fprintf(trace, "\n"); - DumpBox(a, trace); - if (cuebox->config) boxstring_dump((GF_Box *)cuebox->config, trace); - gf_box_dump_done("WebVTTSampleEntryBox", a, trace); - return GF_OK; + GF_WebVTTSampleEntryBox *cuebox = (GF_WebVTTSampleEntryBox *)a; + fprintf(trace, "\n"); + DumpBox(a, trace); + if (cuebox->config) boxstring_dump((GF_Box *)cuebox->config, trace); + gf_box_dump_done("WebVTTSampleEntryBox", a, trace); + return GF_OK; } #endif /* GPAC_DISABLE_ISOM_DUMP */ GF_WebVTTSampleEntryBox *gf_webvtt_isom_get_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex) { - GF_WebVTTSampleEntryBox *wvtt; - GF_TrackBox *trak; - GF_Err e; - - if (!descriptionIndex) return NULL; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_READ); - if (e) return NULL; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return NULL; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return NULL; - } - - wvtt = (GF_WebVTTSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); - if (!wvtt) return NULL; - switch (wvtt->type) { - case GF_ISOM_BOX_TYPE_WVTT: - break; - default: - return NULL; - } - return wvtt; + GF_WebVTTSampleEntryBox *wvtt; + GF_TrackBox *trak; + + if (!descriptionIndex) return NULL; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return NULL; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return NULL; + } + + wvtt = (GF_WebVTTSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); + if (!wvtt) return NULL; + switch (wvtt->type) { + case GF_ISOM_BOX_TYPE_WVTT: + break; + default: + return NULL; + } + return wvtt; } GF_Err gf_isom_update_webvtt_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, const char *config) { - GF_Err e; - GF_WebVTTSampleEntryBox *wvtt; - GF_TrackBox *trak; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); - if (e) return GF_BAD_PARAM; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return GF_BAD_PARAM; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return GF_BAD_PARAM; - } - - wvtt = (GF_WebVTTSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); - if (!wvtt) return GF_BAD_PARAM; - switch (wvtt->type) { - case GF_ISOM_BOX_TYPE_WVTT: - break; - default: - return GF_BAD_PARAM; - } - if (wvtt) { +#ifndef GPAC_DISABLE_ISOM_WRITE + GF_Err e; + GF_WebVTTSampleEntryBox *wvtt; + GF_TrackBox *trak; + + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return GF_BAD_PARAM; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return GF_BAD_PARAM; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return GF_BAD_PARAM; + } + + wvtt = (GF_WebVTTSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, descriptionIndex - 1); + if (!wvtt) return GF_BAD_PARAM; + switch (wvtt->type) { + case GF_ISOM_BOX_TYPE_WVTT: + break; + default: + return GF_BAD_PARAM; + } + if (wvtt) { if (!movie->keep_utc) - trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); + trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); - wvtt->config = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_VTTC, config); - } else { - e = GF_BAD_PARAM; - } - return e; + wvtt->config = (GF_StringBox *)boxstring_new_with_data(GF_ISOM_BOX_TYPE_VTTC, config); + } else { + e = GF_BAD_PARAM; + } + return e; +#else + return GF_NOT_SUPPORTED; +#endif } GF_Err gf_isom_new_webvtt_description(GF_ISOFile *movie, u32 trackNumber, GF_TextSampleDescriptor *desc, char *URLname, char *URNname, u32 *outDescriptionIndex) { - GF_TrackBox *trak; - GF_Err e; - u32 dataRefIndex; - GF_WebVTTSampleEntryBox *wvtt; - - e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); - if (e) return e; - - trak = gf_isom_get_track_from_file(movie, trackNumber); - if (!trak || !trak->Media) return GF_BAD_PARAM; - - switch (trak->Media->handler->handlerType) { - case GF_ISOM_MEDIA_TEXT: - break; - default: - return GF_BAD_PARAM; - } - - //get or create the data ref - e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); - if (e) return e; - if (!dataRefIndex) { - e = Media_CreateDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); - if (e) return e; - } +#ifndef GPAC_DISABLE_ISOM_WRITE + GF_TrackBox *trak; + GF_Err e; + u32 dataRefIndex; + GF_WebVTTSampleEntryBox *wvtt; + + e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); + if (e) return e; + + trak = gf_isom_get_track_from_file(movie, trackNumber); + if (!trak || !trak->Media) return GF_BAD_PARAM; + + switch (trak->Media->handler->handlerType) { + case GF_ISOM_MEDIA_TEXT: + break; + default: + return GF_BAD_PARAM; + } + + //get or create the data ref + e = Media_FindDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); + if (e) return e; + if (!dataRefIndex) { + e = Media_CreateDataRef(trak->Media->information->dataInformation->dref, URLname, URNname, &dataRefIndex); + if (e) return e; + } if (!movie->keep_utc) - trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); + trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); - wvtt = (GF_WebVTTSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_WVTT); - wvtt->dataReferenceIndex = dataRefIndex; - gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, wvtt); - if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); - return e; + wvtt = (GF_WebVTTSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_WVTT); + wvtt->dataReferenceIndex = dataRefIndex; + gf_list_add(trak->Media->information->sampleTable->SampleDescription->other_boxes, wvtt); + if (outDescriptionIndex) *outDescriptionIndex = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); + return e; +#else + return GF_NOT_SUPPORTED; +#endif } #endif /*GPAC_DISABLE_ISOM*/ #ifndef GPAC_DISABLE_MEDIA_IMPORT typedef enum { - WEBVTT_PARSER_STATE_WAITING_SIGNATURE, - WEBVTT_PARSER_STATE_WAITING_HEADER, - WEBVTT_PARSER_STATE_WAITING_CUE, - WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP, - WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD + WEBVTT_PARSER_STATE_WAITING_SIGNATURE, + WEBVTT_PARSER_STATE_WAITING_HEADER, + WEBVTT_PARSER_STATE_WAITING_CUE, + WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP, + WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD } GF_WebVTTParserState; struct _webvtt_parser { - GF_WebVTTParserState state; - Bool is_srt; - - /* List of non-overlapping GF_WebVTTSample */ - GF_List *samples; - - FILE *vtt_in; - u64 file_size; - s32 unicode_type; - - u64 last_duration; - void *user; - GF_Err (*report_message)(void *, GF_Err, char *, const char *); - void (*on_header_parsed)(void *, const char *); - void (*on_sample_parsed)(void *, GF_WebVTTSample *); - void (*on_cue_read)(void *, GF_WebVTTCue *); + GF_WebVTTParserState state; + Bool is_srt; + + /* List of non-overlapping GF_WebVTTSample */ + GF_List *samples; + + FILE *vtt_in; + u64 file_size; + s32 unicode_type; + + u64 last_duration; + void *user; + GF_Err (*report_message)(void *, GF_Err, char *, const char *); + void (*on_header_parsed)(void *, const char *); + void (*on_sample_parsed)(void *, GF_WebVTTSample *); + void (*on_cue_read)(void *, GF_WebVTTCue *); }; /* mark the overlapped cue in the previous sample as split */ @@ -529,329 +533,329 @@ struct _webvtt_parser { /* adjust the end of the overlapped cue in the previous sample */ static GF_WebVTTCue *gf_webvtt_cue_split_at(GF_WebVTTCue *cue, GF_WebVTTTimestamp *time) { - GF_WebVTTCue *dup_cue; + GF_WebVTTCue *dup_cue; - cue->split = GF_TRUE; - cue->orig_start = cue->start; - cue->orig_end = cue->end; + cue->split = GF_TRUE; + cue->orig_start = cue->start; + cue->orig_end = cue->end; - GF_SAFEALLOC(dup_cue, GF_WebVTTCue); - dup_cue->split = GF_TRUE; - dup_cue->start = *time; - dup_cue->end = cue->end; - dup_cue->orig_start = cue->orig_start; - dup_cue->orig_end = cue->orig_end; - dup_cue->id = gf_strdup((cue->id ? cue->id : "")); - dup_cue->settings = gf_strdup((cue->settings ? cue->settings : "")); - dup_cue->text = gf_strdup((cue->text ? cue->text : "")); + GF_SAFEALLOC(dup_cue, GF_WebVTTCue); + dup_cue->split = GF_TRUE; + dup_cue->start = *time; + dup_cue->end = cue->end; + dup_cue->orig_start = cue->orig_start; + dup_cue->orig_end = cue->orig_end; + dup_cue->id = gf_strdup((cue->id ? cue->id : "")); + dup_cue->settings = gf_strdup((cue->settings ? cue->settings : "")); + dup_cue->text = gf_strdup((cue->text ? cue->text : "")); - cue->end = *time; - return dup_cue; + cue->end = *time; + return dup_cue; } static GF_Err gf_webvtt_cue_add_property(GF_WebVTTCue *cue, GF_WebVTTCuePropertyType type, char *text_data, u32 text_len) { - char **prop = NULL; - u32 len; - if (!cue) return GF_BAD_PARAM; - if (!text_len) return GF_OK; - switch(type) - { - case WEBVTT_ID: - prop = &cue->id; - break; - case WEBVTT_SETTINGS: - prop = &cue->settings; - break; - case WEBVTT_PAYLOAD: - prop = &cue->text; - break; - case WEBVTT_TIME: - prop = &cue->time; - break; - } - if (*prop) { - len = (u32) strlen(*prop); - *prop = (char*)gf_realloc(*prop, sizeof(char) * (len + text_len + 1) ); - strcpy(*prop + len, text_data); - } else { - len = 0; - *prop = gf_strdup(text_data); - } - return GF_OK; + char **prop = NULL; + u32 len; + if (!cue) return GF_BAD_PARAM; + if (!text_len) return GF_OK; + switch(type) + { + case WEBVTT_ID: + prop = &cue->id; + break; + case WEBVTT_SETTINGS: + prop = &cue->settings; + break; + case WEBVTT_PAYLOAD: + prop = &cue->text; + break; + case WEBVTT_TIME: + prop = &cue->time; + break; + } + if (*prop) { + len = (u32) strlen(*prop); + *prop = (char*)gf_realloc(*prop, sizeof(char) * (len + text_len + 1) ); + strcpy(*prop + len, text_data); + } else { + len = 0; + *prop = gf_strdup(text_data); + } + return GF_OK; } static GF_WebVTTCue *gf_webvtt_cue_new() { - GF_WebVTTCue *cue; - GF_SAFEALLOC(cue, GF_WebVTTCue); - return cue; + GF_WebVTTCue *cue; + GF_SAFEALLOC(cue, GF_WebVTTCue); + return cue; } GF_EXPORT void gf_webvtt_cue_del(GF_WebVTTCue * cue) { - if (cue) { - if (cue->id) gf_free(cue->id); - if (cue->settings) gf_free(cue->settings); - if (cue->time) gf_free(cue->time); - if (cue->text) gf_free(cue->text); - gf_free(cue); - } + if (cue) { + if (cue->id) gf_free(cue->id); + if (cue->settings) gf_free(cue->settings); + if (cue->time) gf_free(cue->time); + if (cue->text) gf_free(cue->text); + gf_free(cue); + } } static GF_WebVTTSample *gf_webvtt_sample_new() { - GF_WebVTTSample *samp; - GF_SAFEALLOC(samp, GF_WebVTTSample); - if (!samp) return NULL; - samp->cues = gf_list_new(); - return samp; + GF_WebVTTSample *samp; + GF_SAFEALLOC(samp, GF_WebVTTSample); + if (!samp) return NULL; + samp->cues = gf_list_new(); + return samp; } u64 gf_webvtt_sample_get_start(GF_WebVTTSample * samp) { - return samp->start; + return samp->start; } void gf_webvtt_sample_del(GF_WebVTTSample * samp) { - while (gf_list_count(samp->cues)) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(samp->cues, 0); - gf_list_rem(samp->cues, 0); - gf_webvtt_cue_del(cue); - } - gf_list_del(samp->cues); - gf_free(samp); + while (gf_list_count(samp->cues)) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(samp->cues, 0); + gf_list_rem(samp->cues, 0); + gf_webvtt_cue_del(cue); + } + gf_list_del(samp->cues); + gf_free(samp); } GF_WebVTTParser *gf_webvtt_parser_new() { - GF_WebVTTParser *parser; - GF_SAFEALLOC(parser, GF_WebVTTParser); - parser->samples = gf_list_new(); - return parser; + GF_WebVTTParser *parser; + GF_SAFEALLOC(parser, GF_WebVTTParser); + parser->samples = gf_list_new(); + return parser; } extern s32 gf_text_get_utf_type(FILE *in_src); -GF_Err gf_webvtt_parser_init(GF_WebVTTParser *parser, const char *input_file, - void *user, GF_Err (*report_message)(void *, GF_Err, char *, const char *), - void (*on_sample_parsed)(void *, GF_WebVTTSample *), - void (*on_header_parsed)(void *, const char *)) +GF_Err gf_webvtt_parser_init(GF_WebVTTParser *parser, const char *input_file, + void *user, GF_Err (*report_message)(void *, GF_Err, char *, const char *), + void (*on_sample_parsed)(void *, GF_WebVTTSample *), + void (*on_header_parsed)(void *, const char *)) { - const char *ext; - if (parser) { - parser->state = WEBVTT_PARSER_STATE_WAITING_SIGNATURE; - - ext = strrchr(input_file, '.'); - if (ext) { - ext++; - if (!strcmp(ext, "srt")) { - parser->is_srt = GF_TRUE; - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; - } - } - parser->vtt_in = gf_f64_open(input_file, "rt"); - gf_f64_seek(parser->vtt_in, 0, SEEK_END); - parser->file_size = gf_f64_tell(parser->vtt_in); - gf_f64_seek(parser->vtt_in, 0, SEEK_SET); - - parser->unicode_type = gf_text_get_utf_type(parser->vtt_in); - if (parser->unicode_type<0) { - fclose(parser->vtt_in); - return GF_NOT_SUPPORTED; - } - - parser->user = user; - parser->report_message = report_message; - parser->on_sample_parsed = on_sample_parsed; - parser->on_header_parsed = on_header_parsed; - return GF_OK; - } - return GF_BAD_PARAM; + const char *ext; + if (parser) { + parser->state = WEBVTT_PARSER_STATE_WAITING_SIGNATURE; + + ext = strrchr(input_file, '.'); + if (ext) { + ext++; + if (!strcmp(ext, "srt")) { + parser->is_srt = GF_TRUE; + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; + } + } + parser->vtt_in = gf_f64_open(input_file, "rt"); + gf_f64_seek(parser->vtt_in, 0, SEEK_END); + parser->file_size = gf_f64_tell(parser->vtt_in); + gf_f64_seek(parser->vtt_in, 0, SEEK_SET); + + parser->unicode_type = gf_text_get_utf_type(parser->vtt_in); + if (parser->unicode_type<0) { + fclose(parser->vtt_in); + return GF_NOT_SUPPORTED; + } + + parser->user = user; + parser->report_message = report_message; + parser->on_sample_parsed = on_sample_parsed; + parser->on_header_parsed = on_header_parsed; + return GF_OK; + } + return GF_BAD_PARAM; } void gf_webvtt_parser_reset(GF_WebVTTParser *parser) { - if (parser) { - while (gf_list_count(parser->samples)) { - gf_webvtt_sample_del((GF_WebVTTSample *)gf_list_get(parser->samples, 0)); - gf_list_rem(parser->samples, 0); - } - if (parser->vtt_in) fclose(parser->vtt_in); - parser->file_size = 0; - parser->last_duration = 0; - parser->on_header_parsed = NULL; - parser->on_sample_parsed = NULL; - parser->report_message = NULL; - parser->state = WEBVTT_PARSER_STATE_WAITING_SIGNATURE; - parser->unicode_type = 0; - parser->user = NULL; - parser->vtt_in = NULL; - } + if (parser) { + while (gf_list_count(parser->samples)) { + gf_webvtt_sample_del((GF_WebVTTSample *)gf_list_get(parser->samples, 0)); + gf_list_rem(parser->samples, 0); + } + if (parser->vtt_in) fclose(parser->vtt_in); + parser->file_size = 0; + parser->last_duration = 0; + parser->on_header_parsed = NULL; + parser->on_sample_parsed = NULL; + parser->report_message = NULL; + parser->state = WEBVTT_PARSER_STATE_WAITING_SIGNATURE; + parser->unicode_type = 0; + parser->user = NULL; + parser->vtt_in = NULL; + } } void gf_webvtt_parser_del(GF_WebVTTParser *parser) { - if (parser) { - gf_webvtt_parser_reset(parser); - gf_list_del(parser->samples); - gf_free(parser); - } + if (parser) { + gf_webvtt_parser_reset(parser); + gf_list_del(parser->samples); + gf_free(parser); + } } u64 gf_webvtt_parser_last_duration(GF_WebVTTParser *parser) { - if (parser) { - return parser->last_duration; - } else { - return 0; - } + if (parser) { + return parser->last_duration; + } else { + return 0; + } } Bool gf_webvtt_timestamp_is_zero(GF_WebVTTTimestamp *ts) { - return (ts->hour == 0 && ts->min == 0 && ts->sec == 0 && ts->ms == 0) ? GF_TRUE : GF_FALSE; + return (ts->hour == 0 && ts->min == 0 && ts->sec == 0 && ts->ms == 0) ? GF_TRUE : GF_FALSE; } void gf_webvtt_timestamp_set(GF_WebVTTTimestamp *ts, u64 value) { - u64 tmp; - tmp = value; - ts->hour = (u32)(tmp/(3600*1000)); - tmp -= ts->hour*3600*1000; - ts->min = (u32)(tmp/(60*1000)); - tmp -= ts->min*60*1000; - ts->sec = (u32)(tmp/1000); - tmp -= ts->sec*1000; - ts->ms = (u32)tmp; + u64 tmp; + tmp = value; + ts->hour = (u32)(tmp/(3600*1000)); + tmp -= ts->hour*3600*1000; + ts->min = (u32)(tmp/(60*1000)); + tmp -= ts->min*60*1000; + ts->sec = (u32)(tmp/1000); + tmp -= ts->sec*1000; + ts->ms = (u32)tmp; } u64 gf_webvtt_timestamp_get(GF_WebVTTTimestamp *ts) { - return (3600*ts->hour + 60*ts->min + ts->sec)*1000 + ts->ms; + return (3600*ts->hour + 60*ts->min + ts->sec)*1000 + ts->ms; } void gf_webvtt_timestamp_dump(GF_WebVTTTimestamp *ts, FILE *dump, Bool dump_hour) { - if (dump_hour || ts->hour != 0) { - fprintf(dump, "%02u:", ts->hour); - } + if (dump_hour || ts->hour != 0) { + fprintf(dump, "%02u:", ts->hour); + } - fprintf(dump, "%02u:%02u.%03u", ts->min, ts->sec, ts->ms); + fprintf(dump, "%02u:%02u.%03u", ts->min, ts->sec, ts->ms); } static GF_Err gf_webvtt_add_cue_to_samples(GF_WebVTTParser *parser, GF_List *samples, GF_WebVTTCue *cue) { - s32 i; - u64 cue_start; - u64 cue_end; - u64 sample_end; - - sample_end = 0; - cue_start = gf_webvtt_timestamp_get(&cue->start); - cue_end = gf_webvtt_timestamp_get(&cue->end); - /* samples in the samples list are contiguous: sample(n)->start == sample(n-1)->end */ - for (i = 0; i < (s32)gf_list_count(samples); i++) { - GF_WebVTTSample *sample; - sample = (GF_WebVTTSample *)gf_list_get(samples, i); - /* save the sample end in case there are no more samples to test */ - sample_end = sample->end; - if (cue_start < sample->start) - { - /* cues must be ordered according to their start time, so drop the cue */ - /* TODO delete the cue */ - return GF_BAD_PARAM; - } - else if (cue_start == sample->start && cue_end == sample->end) - { - /* if the timing of the new cue matches the sample, no need to split, add the cue to the sample */ - gf_list_add(sample->cues, cue); - /* the cue does not need to processed further */ - return GF_OK; - } - else if (cue_start >= sample->end) - { - /* flush the current sample */ - gf_list_del_item(samples, sample); - parser->on_sample_parsed(parser->user, sample); - sample = NULL; - i--; - /* process the cue with next sample (if any) or create a new sample */ - continue; - } - else if (cue_start >= sample->start) - { - u32 j; - if (cue_start > sample->start) { - /* create a new sample, insert it after the current one */ - GF_WebVTTSample *new_sample = gf_webvtt_sample_new(); - new_sample->start = cue_start; - new_sample->end = sample->end; - gf_list_insert(samples, new_sample, i+1); - /* split the cues from the old sample into the new one */ - for (j = 0; j < gf_list_count(sample->cues); j++) { - GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, j); - GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(old_cue, &cue->start); - gf_list_add(new_sample->cues, new_cue); - } - /* adjust the end of the old sample and flush it */ - sample->end = cue_start; - gf_list_del_item(samples, sample); - parser->on_sample_parsed(parser->user, sample); - sample = NULL; - i--; - /* process the cue again with this new sample */ - continue; - } - if (cue_end > sample->end) { - /* the cue is longer than the sample, we split the cue, add one part to the current sample - and reevaluate with the last part of the cue */ - GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, 0); - GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(cue, &old_cue->end); - gf_list_add(sample->cues, cue); - cue = new_cue; - cue_start = sample->end; - /* cue_end unchanged */ - /* process the remaining part of the cue (i.e. the new cue) with the other samples */ - continue; - } else { /* cue_end < sample->end */ - GF_WebVTTSample *new_sample = gf_webvtt_sample_new(); - new_sample->start = cue_end; - new_sample->end = sample->end; - gf_list_insert(samples, new_sample, i+1); - for (j = 0; j < gf_list_count(sample->cues); j++) { - GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, j); - GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(old_cue, &cue->end); - gf_list_add(new_sample->cues, new_cue); - } - gf_list_add(sample->cues, cue); - sample->end = new_sample->start; - /* done with this cue */ - return GF_OK; - } - } - } - /* (a part of) the cue remains (was not overlapping) */ - if (cue_start > sample_end) { - /* if the new cue start is greater than the last sample end, - create an empty sample to fill the gap, flush it */ - GF_WebVTTSample *esample = gf_webvtt_sample_new(); - esample->start = sample_end; - esample->end = cue_start; - parser->on_sample_parsed(parser->user, esample); - } - /* if the cue has not been added to a sample, create a new sample for it */ - { - GF_WebVTTSample *sample; - sample = gf_webvtt_sample_new(); - gf_list_add(samples, sample); - sample->start = cue_start; - sample->end = cue_end; - gf_list_add(sample->cues, cue); - } - return GF_OK; + s32 i; + u64 cue_start; + u64 cue_end; + u64 sample_end; + + sample_end = 0; + cue_start = gf_webvtt_timestamp_get(&cue->start); + cue_end = gf_webvtt_timestamp_get(&cue->end); + /* samples in the samples list are contiguous: sample(n)->start == sample(n-1)->end */ + for (i = 0; i < (s32)gf_list_count(samples); i++) { + GF_WebVTTSample *sample; + sample = (GF_WebVTTSample *)gf_list_get(samples, i); + /* save the sample end in case there are no more samples to test */ + sample_end = sample->end; + if (cue_start < sample->start) + { + /* cues must be ordered according to their start time, so drop the cue */ + /* TODO delete the cue */ + return GF_BAD_PARAM; + } + else if (cue_start == sample->start && cue_end == sample->end) + { + /* if the timing of the new cue matches the sample, no need to split, add the cue to the sample */ + gf_list_add(sample->cues, cue); + /* the cue does not need to processed further */ + return GF_OK; + } + else if (cue_start >= sample->end) + { + /* flush the current sample */ + gf_list_del_item(samples, sample); + parser->on_sample_parsed(parser->user, sample); + sample = NULL; + i--; + /* process the cue with next sample (if any) or create a new sample */ + continue; + } + else if (cue_start >= sample->start) + { + u32 j; + if (cue_start > sample->start) { + /* create a new sample, insert it after the current one */ + GF_WebVTTSample *new_sample = gf_webvtt_sample_new(); + new_sample->start = cue_start; + new_sample->end = sample->end; + gf_list_insert(samples, new_sample, i+1); + /* split the cues from the old sample into the new one */ + for (j = 0; j < gf_list_count(sample->cues); j++) { + GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, j); + GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(old_cue, &cue->start); + gf_list_add(new_sample->cues, new_cue); + } + /* adjust the end of the old sample and flush it */ + sample->end = cue_start; + gf_list_del_item(samples, sample); + parser->on_sample_parsed(parser->user, sample); + sample = NULL; + i--; + /* process the cue again with this new sample */ + continue; + } + if (cue_end > sample->end) { + /* the cue is longer than the sample, we split the cue, add one part to the current sample + and reevaluate with the last part of the cue */ + GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, 0); + GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(cue, &old_cue->end); + gf_list_add(sample->cues, cue); + cue = new_cue; + cue_start = sample->end; + /* cue_end unchanged */ + /* process the remaining part of the cue (i.e. the new cue) with the other samples */ + continue; + } else { /* cue_end < sample->end */ + GF_WebVTTSample *new_sample = gf_webvtt_sample_new(); + new_sample->start = cue_end; + new_sample->end = sample->end; + gf_list_insert(samples, new_sample, i+1); + for (j = 0; j < gf_list_count(sample->cues); j++) { + GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(sample->cues, j); + GF_WebVTTCue *new_cue = gf_webvtt_cue_split_at(old_cue, &cue->end); + gf_list_add(new_sample->cues, new_cue); + } + gf_list_add(sample->cues, cue); + sample->end = new_sample->start; + /* done with this cue */ + return GF_OK; + } + } + } + /* (a part of) the cue remains (was not overlapping) */ + if (cue_start > sample_end) { + /* if the new cue start is greater than the last sample end, + create an empty sample to fill the gap, flush it */ + GF_WebVTTSample *esample = gf_webvtt_sample_new(); + esample->start = sample_end; + esample->end = cue_start; + parser->on_sample_parsed(parser->user, esample); + } + /* if the cue has not been added to a sample, create a new sample for it */ + { + GF_WebVTTSample *sample; + sample = gf_webvtt_sample_new(); + gf_list_add(samples, sample); + sample->start = cue_start; + sample->end = cue_end; + gf_list_add(sample->cues, cue); + } + return GF_OK; } #define REM_TRAIL_MARKS(__str, __sep) while (1) { \ @@ -866,81 +870,81 @@ static GF_Err gf_webvtt_add_cue_to_samples(GF_WebVTTParser *parser, GF_List *sam extern char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicode_type); -GF_Err gf_webvtt_parse_timestamp(GF_WebVTTParser *parser, GF_WebVTTTimestamp *ts, const char *line) +GF_Err gf_webvtt_parse_timestamp(GF_WebVTTParser *parser, GF_WebVTTTimestamp *ts, const char *line) { - u32 len; - u32 pos; - u32 pos2; - u32 value1; - u32 value2; - u32 value3; - u32 value4; - Bool is_hour = GF_FALSE; - if (!ts || !line) return GF_BAD_PARAM; - len = (u32) strlen(line); - if (!len) return GF_BAD_PARAM; - pos = 0; - if (!(line[pos] >= '0' && line[pos] <= '9')) return GF_BAD_PARAM; - value1 = 0; - while (pos < len && line[pos] >= '0' && line[pos] <= '9') { - value1 = value1*10 + (line[pos]-'0'); - pos++; - } - if (pos>2 || value1>59) { - is_hour = GF_TRUE; - } - if (pos == len || line[pos] != ':') { - return GF_BAD_PARAM; - } else { - pos++; - } - value2 = 0; - pos2 = 0; - while (pos < len && line[pos] >= '0' && line[pos] <= '9') { - value2 = value2*10 + (line[pos]-'0'); - pos++; - pos2++; - if (pos2 > 2) return GF_BAD_PARAM; - } - if (is_hour || (pos < len && line[pos] == ':')) { - if (pos == len || line[pos] != ':') { - return GF_BAD_PARAM; - } else { - pos++; - pos2 = 0; - value3 = 0; - while (pos < len && line[pos] >= '0' && line[pos] <= '9') { - value3 = value3*10 + (line[pos]-'0'); - pos++; - pos2++; - if (pos2 > 2) return GF_BAD_PARAM; - } - } - } else { - value3 = value2; - value2 = value1; - value1 = 0; - } - /* checking SRT syntax for timestamp with , */ - if (pos == len || (!parser->is_srt && line[pos] != '.') || (parser->is_srt && line[pos] != ',')) { - return GF_BAD_PARAM; - } else { - pos++; - } - pos2 = 0; - value4 = 0; - while (pos < len && line[pos] >= '0' && line[pos] <= '9') { - value4 = value4*10 + (line[pos]-'0'); - pos++; - pos2++; - if (pos2 > 4) return GF_BAD_PARAM; - } - if (value2>59 || value3 > 59) return GF_BAD_PARAM; - ts->hour = value1; - ts->min = value2; - ts->sec = value3; - ts->ms = value4; - return GF_OK; + u32 len; + u32 pos; + u32 pos2; + u32 value1; + u32 value2; + u32 value3; + u32 value4; + Bool is_hour = GF_FALSE; + if (!ts || !line) return GF_BAD_PARAM; + len = (u32) strlen(line); + if (!len) return GF_BAD_PARAM; + pos = 0; + if (!(line[pos] >= '0' && line[pos] <= '9')) return GF_BAD_PARAM; + value1 = 0; + while (pos < len && line[pos] >= '0' && line[pos] <= '9') { + value1 = value1*10 + (line[pos]-'0'); + pos++; + } + if (pos>2 || value1>59) { + is_hour = GF_TRUE; + } + if (pos == len || line[pos] != ':') { + return GF_BAD_PARAM; + } else { + pos++; + } + value2 = 0; + pos2 = 0; + while (pos < len && line[pos] >= '0' && line[pos] <= '9') { + value2 = value2*10 + (line[pos]-'0'); + pos++; + pos2++; + if (pos2 > 2) return GF_BAD_PARAM; + } + if (is_hour || (pos < len && line[pos] == ':')) { + if (pos == len || line[pos] != ':') { + return GF_BAD_PARAM; + } else { + pos++; + pos2 = 0; + value3 = 0; + while (pos < len && line[pos] >= '0' && line[pos] <= '9') { + value3 = value3*10 + (line[pos]-'0'); + pos++; + pos2++; + if (pos2 > 2) return GF_BAD_PARAM; + } + } + } else { + value3 = value2; + value2 = value1; + value1 = 0; + } + /* checking SRT syntax for timestamp with , */ + if (pos == len || (!parser->is_srt && line[pos] != '.') || (parser->is_srt && line[pos] != ',')) { + return GF_BAD_PARAM; + } else { + pos++; + } + pos2 = 0; + value4 = 0; + while (pos < len && line[pos] >= '0' && line[pos] <= '9') { + value4 = value4*10 + (line[pos]-'0'); + pos++; + pos2++; + if (pos2 > 4) return GF_BAD_PARAM; + } + if (value2>59 || value3 > 59) return GF_BAD_PARAM; + ts->hour = value1; + ts->min = value2; + ts->sec = value3; + ts->ms = value4; + return GF_OK; } #define SKIP_WHITESPACE \ @@ -949,302 +953,314 @@ GF_Err gf_webvtt_parse_timestamp(GF_WebVTTParser *parser, GF_WebVTTTimestamp *ts GF_Err gf_webvtt_parser_parse_timings_settings(GF_WebVTTParser *parser, GF_WebVTTCue *cue, char *line, u32 len) { - GF_Err e; - char *timestamp_string; - u32 pos; - e = GF_OK; - pos = 0; - if (!cue || !line || !len) return GF_BAD_PARAM; - SKIP_WHITESPACE - timestamp_string = line + pos; - while (pos < len && line[pos] != ' ' && line[pos] != '\t') pos++; - if (pos == len) { - e = GF_CORRUPTED_DATA; - parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); - return e; - } - line[pos] = 0; - e = gf_webvtt_parse_timestamp(parser, &cue->start, timestamp_string); - if (e) { - parser->report_message(parser->user, e, "Bad VTT timestamp formatting %s", timestamp_string); - return e; - } - line[pos] = ' '; - SKIP_WHITESPACE - if (pos == len) { - e = GF_CORRUPTED_DATA; - parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); - return e; - } - if ( (pos+2)>= len || line[pos] != '-' || line[pos+1] != '-' || line[pos+2] != '>') { - e = GF_CORRUPTED_DATA; - parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); - return e; - } else { - pos += 3; - SKIP_WHITESPACE - if (pos == len) { - e = GF_CORRUPTED_DATA; - parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); - return e; - } - timestamp_string = line + pos; - while (pos < len && line[pos] != ' ' && line[pos] != '\t') pos++; - if (pos < len) { - line[pos] = 0; - } - e = gf_webvtt_parse_timestamp(parser, &cue->end, timestamp_string); - if (e) { - parser->report_message(parser->user, e, "Bad VTT timestamp formatting %s", timestamp_string); - return e; - } - if (pos < len) { - line[pos] = ' '; - } - SKIP_WHITESPACE - if (pos < len) { - char *settings = line + pos; - e = gf_webvtt_cue_add_property(cue, WEBVTT_SETTINGS, settings, (u32) strlen(settings)); - } - } - return e; + GF_Err e; + char *timestamp_string; + u32 pos; + e = GF_OK; + pos = 0; + if (!cue || !line || !len) return GF_BAD_PARAM; + SKIP_WHITESPACE + timestamp_string = line + pos; + while (pos < len && line[pos] != ' ' && line[pos] != '\t') pos++; + if (pos == len) { + e = GF_CORRUPTED_DATA; + parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); + return e; + } + line[pos] = 0; + e = gf_webvtt_parse_timestamp(parser, &cue->start, timestamp_string); + if (e) { + parser->report_message(parser->user, e, "Bad VTT timestamp formatting %s", timestamp_string); + return e; + } + line[pos] = ' '; + SKIP_WHITESPACE + if (pos == len) { + e = GF_CORRUPTED_DATA; + parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); + return e; + } + if ( (pos+2)>= len || line[pos] != '-' || line[pos+1] != '-' || line[pos+2] != '>') { + e = GF_CORRUPTED_DATA; + parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); + return e; + } else { + pos += 3; + SKIP_WHITESPACE + if (pos == len) { + e = GF_CORRUPTED_DATA; + parser->report_message(parser->user, e, "Error scanning WebVTT cue timing in %s", line); + return e; + } + timestamp_string = line + pos; + while (pos < len && line[pos] != ' ' && line[pos] != '\t') pos++; + if (pos < len) { + line[pos] = 0; + } + e = gf_webvtt_parse_timestamp(parser, &cue->end, timestamp_string); + if (e) { + parser->report_message(parser->user, e, "Bad VTT timestamp formatting %s", timestamp_string); + return e; + } + if (pos < len) { + line[pos] = ' '; + } + SKIP_WHITESPACE + if (pos < len) { + char *settings = line + pos; + e = gf_webvtt_cue_add_property(cue, WEBVTT_SETTINGS, settings, (u32) strlen(settings)); + } + } + return e; } GF_Err gf_webvtt_parser_parse(GF_WebVTTParser *parser, u32 duration) { - char szLine[2048]; - char *sOK; - u32 len; - GF_Err e; - Bool do_parse = GF_TRUE; - GF_WebVTTCue *cue = NULL; - u32 start = 0; - u32 end = 0; - char *prevLine = NULL; - char *header = NULL; - u32 header_len = 0; - Bool had_marks = GF_FALSE; - - if (!parser) return GF_BAD_PARAM; - if (parser->is_srt) { - parser->on_header_parsed(parser->user, gf_strdup("WEBVTT\n")); - } - while (do_parse) { - sOK = gf_text_get_utf8_line(szLine, 2048, parser->vtt_in, parser->unicode_type); - REM_TRAIL_MARKS(szLine, "\r\n") - len = (u32) strlen(szLine); - switch (parser->state) { - case WEBVTT_PARSER_STATE_WAITING_SIGNATURE: - if (!sOK || len < 6 || strnicmp(szLine, "WEBVTT", 6) || (len > 6 && szLine[6] != ' ' && szLine[6] != '\t')) { - e = GF_CORRUPTED_DATA; - parser->report_message(parser->user, e, "Bad WEBVTT file signature %s", szLine); - goto exit; - } else { - if (had_marks) { szLine[len] = '\n'; len++; } - header = gf_strdup(szLine); - header_len = len; - parser->state = WEBVTT_PARSER_STATE_WAITING_HEADER; - } - break; /* proceed to next line */ - case WEBVTT_PARSER_STATE_WAITING_HEADER: - if (prevLine) { - u32 prev_len = (u32) strlen(prevLine); - header = (char *)gf_realloc(header, header_len + prev_len + 1); - strcpy(header+header_len,prevLine); - header_len += prev_len; - gf_free(prevLine); - prevLine = NULL; - } - if (sOK && len) { - if (strstr(szLine, "-->")) { - parser->on_header_parsed(parser->user, header); - /* continue to the next state without breaking */ - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP; - /* no break, continue to the next state*/ - } else { - if (had_marks) { szLine[len] = '\n'; len++; } - prevLine = gf_strdup(szLine); - break; /* proceed to next line */ - } - } else { - parser->on_header_parsed(parser->user, header); - if (!sOK) { - /* end of file, parsing is done */ - do_parse = GF_FALSE; - break; - } else { - /* empty line means end of header */ - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; - /* no break, continue to the next state*/ - } - } - case WEBVTT_PARSER_STATE_WAITING_CUE: - if (sOK && len) { - if (strstr(szLine, "-->")) { - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP; - /* continue to the next state without breaking */ - } else { - /* discard the previous line */ - /* should we do something with it ? callback ?*/ - if (prevLine) { - gf_free(prevLine); - prevLine = NULL; - } - /* save this new line */ - if (had_marks) { szLine[len] = '\n'; len++; } - prevLine = gf_strdup(szLine); - /* stay in the same state */ - break; - } - } else { - /* discard the previous line */ - /* should we do something with it ? callback ?*/ - if (prevLine) { - gf_free(prevLine); - prevLine = NULL; - } - if (!sOK) { - do_parse = GF_FALSE; - break; - } else { - /* remove empty lines and stay in the same state */ - break; - } - } - case WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP: - if (sOK && len) { - if (cue == NULL) { - cue = gf_webvtt_cue_new(); - } - if (prevLine) { - gf_webvtt_cue_add_property(cue, WEBVTT_ID, prevLine, (u32) strlen(prevLine)); - gf_free(prevLine); - prevLine = NULL; - } - e = gf_webvtt_parser_parse_timings_settings(parser, cue, szLine, len); - if (e) { - if (cue) gf_webvtt_cue_del(cue); - cue = NULL; - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; - } else { - start = (u32)gf_webvtt_timestamp_get(&cue->start); - end = (u32)gf_webvtt_timestamp_get(&cue->end); - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD; - } - } else { - /* not possible */ - assert(0); - } - break; - case WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD: - if (sOK && len) { - if (had_marks) { szLine[len] = '\n'; len++; } - gf_webvtt_cue_add_property(cue, WEBVTT_PAYLOAD, szLine, len); - /* remain in the same state as a cue payload can have multiple lines */ - break; - } else { - /* end of the current cue */ - gf_webvtt_add_cue_to_samples(parser, parser->samples, cue); - cue = NULL; - - gf_set_progress("Importing WebVTT", gf_f64_tell(parser->vtt_in), parser->file_size); - if ((duration && (end >= duration)) || !sOK) { - do_parse = GF_FALSE; - break; - } else { - /* empty line, move to next cue */ - parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; - break; - } - } - } - if (duration && (start >= duration)) { - do_parse = GF_FALSE; - break; - } - } - - - /* no more cues to come, flush everything */ - if (cue) { - gf_webvtt_add_cue_to_samples(parser, parser->samples, cue); - cue = NULL; - } - while (gf_list_count(parser->samples) > 0) { - GF_WebVTTSample *sample = (GF_WebVTTSample *)gf_list_get(parser->samples, 0); - parser->last_duration = sample->end - sample->start; - gf_list_rem(parser->samples, 0); - parser->on_sample_parsed(parser->user, sample); - } - gf_set_progress("Importing WebVTT", parser->file_size, parser->file_size); - e = GF_OK; + char szLine[2048]; + char *sOK; + u32 len; + GF_Err e; + Bool do_parse = GF_TRUE; + GF_WebVTTCue *cue = NULL; + u32 start = 0; + u32 end = 0; + char *prevLine = NULL; + char *header = NULL; + u32 header_len = 0; + Bool had_marks = GF_FALSE; + + if (!parser) return GF_BAD_PARAM; + if (parser->is_srt) { + parser->on_header_parsed(parser->user, gf_strdup("WEBVTT\n")); + } + while (do_parse) { + sOK = gf_text_get_utf8_line(szLine, 2048, parser->vtt_in, parser->unicode_type); + REM_TRAIL_MARKS(szLine, "\r\n") + len = (u32) strlen(szLine); + switch (parser->state) { + case WEBVTT_PARSER_STATE_WAITING_SIGNATURE: + if (!sOK || len < 6 || strnicmp(szLine, "WEBVTT", 6) || (len > 6 && szLine[6] != ' ' && szLine[6] != '\t')) { + e = GF_CORRUPTED_DATA; + parser->report_message(parser->user, e, "Bad WEBVTT file signature %s", szLine); + goto exit; + } else { + if (had_marks) { + szLine[len] = '\n'; + len++; + } + header = gf_strdup(szLine); + header_len = len; + parser->state = WEBVTT_PARSER_STATE_WAITING_HEADER; + } + break; /* proceed to next line */ + case WEBVTT_PARSER_STATE_WAITING_HEADER: + if (prevLine) { + u32 prev_len = (u32) strlen(prevLine); + header = (char *)gf_realloc(header, header_len + prev_len + 1); + strcpy(header+header_len,prevLine); + header_len += prev_len; + gf_free(prevLine); + prevLine = NULL; + } + if (sOK && len) { + if (strstr(szLine, "-->")) { + parser->on_header_parsed(parser->user, header); + /* continue to the next state without breaking */ + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP; + /* no break, continue to the next state*/ + } else { + if (had_marks) { + szLine[len] = '\n'; + len++; + } + prevLine = gf_strdup(szLine); + break; /* proceed to next line */ + } + } else { + parser->on_header_parsed(parser->user, header); + if (!sOK) { + /* end of file, parsing is done */ + do_parse = GF_FALSE; + break; + } else { + /* empty line means end of header */ + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; + /* no break, continue to the next state*/ + } + } + case WEBVTT_PARSER_STATE_WAITING_CUE: + if (sOK && len) { + if (strstr(szLine, "-->")) { + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP; + /* continue to the next state without breaking */ + } else { + /* discard the previous line */ + /* should we do something with it ? callback ?*/ + if (prevLine) { + gf_free(prevLine); + prevLine = NULL; + } + /* save this new line */ + if (had_marks) { + szLine[len] = '\n'; + len++; + } + prevLine = gf_strdup(szLine); + /* stay in the same state */ + break; + } + } else { + /* discard the previous line */ + /* should we do something with it ? callback ?*/ + if (prevLine) { + gf_free(prevLine); + prevLine = NULL; + } + if (!sOK) { + do_parse = GF_FALSE; + break; + } else { + /* remove empty lines and stay in the same state */ + break; + } + } + case WEBVTT_PARSER_STATE_WAITING_CUE_TIMESTAMP: + if (sOK && len) { + if (cue == NULL) { + cue = gf_webvtt_cue_new(); + } + if (prevLine) { + gf_webvtt_cue_add_property(cue, WEBVTT_ID, prevLine, (u32) strlen(prevLine)); + gf_free(prevLine); + prevLine = NULL; + } + e = gf_webvtt_parser_parse_timings_settings(parser, cue, szLine, len); + if (e) { + if (cue) gf_webvtt_cue_del(cue); + cue = NULL; + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; + } else { + start = (u32)gf_webvtt_timestamp_get(&cue->start); + end = (u32)gf_webvtt_timestamp_get(&cue->end); + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD; + } + } else { + /* not possible */ + assert(0); + } + break; + case WEBVTT_PARSER_STATE_WAITING_CUE_PAYLOAD: + if (sOK && len) { + if (had_marks) { + szLine[len] = '\n'; + len++; + } + gf_webvtt_cue_add_property(cue, WEBVTT_PAYLOAD, szLine, len); + /* remain in the same state as a cue payload can have multiple lines */ + break; + } else { + /* end of the current cue */ + gf_webvtt_add_cue_to_samples(parser, parser->samples, cue); + cue = NULL; + + gf_set_progress("Importing WebVTT", gf_f64_tell(parser->vtt_in), parser->file_size); + if ((duration && (end >= duration)) || !sOK) { + do_parse = GF_FALSE; + break; + } else { + /* empty line, move to next cue */ + parser->state = WEBVTT_PARSER_STATE_WAITING_CUE; + break; + } + } + } + if (duration && (start >= duration)) { + do_parse = GF_FALSE; + break; + } + } + + + /* no more cues to come, flush everything */ + if (cue) { + gf_webvtt_add_cue_to_samples(parser, parser->samples, cue); + cue = NULL; + } + while (gf_list_count(parser->samples) > 0) { + GF_WebVTTSample *sample = (GF_WebVTTSample *)gf_list_get(parser->samples, 0); + parser->last_duration = sample->end - sample->start; + gf_list_rem(parser->samples, 0); + parser->on_sample_parsed(parser->user, sample); + } + gf_set_progress("Importing WebVTT", parser->file_size, parser->file_size); + e = GF_OK; exit: - if (cue) gf_webvtt_cue_del(cue); - if (prevLine) gf_free(prevLine); - if (header) gf_free(header); - return e; + if (cue) gf_webvtt_cue_del(cue); + if (prevLine) gf_free(prevLine); + if (header) gf_free(header); + return e; } GF_Err gf_webvtt_dump_header_boxed(FILE *dump, const char *data, u32 dataLength, u32 *dumpedLength) { GF_Err e; GF_Box *box; - GF_StringBox *config; + GF_StringBox *config; GF_BitStream *bs; *dumpedLength = 0; bs = gf_bs_new(data, dataLength, GF_BITSTREAM_READ); e = gf_isom_parse_box(&box, bs); - if (!box || (box->type != GF_ISOM_BOX_TYPE_VTTC && box->type != GF_ISOM_BOX_TYPE_STTC)) return GF_BAD_PARAM; + if (!box || (box->type != GF_ISOM_BOX_TYPE_VTTC && box->type != GF_ISOM_BOX_TYPE_STTC)) return GF_BAD_PARAM; config = (GF_StringBox *)box; - if (config->string) { + if (config->string) { fprintf(dump, "%s", config->string); *dumpedLength = (u32)strlen(config->string)+1; - } + } gf_bs_del(bs); gf_isom_box_del(box); - return e; + return e; } GF_Err gf_webvtt_dump_header(FILE *dump, GF_ISOFile *file, u32 track, u32 index) { - GF_WebVTTSampleEntryBox *wvtt; - wvtt = gf_webvtt_isom_get_description(file, track, index); - if (!wvtt) return GF_BAD_PARAM; - fprintf(dump, "%s\n", wvtt->config->string); - return GF_OK; + GF_WebVTTSampleEntryBox *wvtt; + wvtt = gf_webvtt_isom_get_description(file, track, index); + if (!wvtt) return GF_BAD_PARAM; + fprintf(dump, "%s\n", wvtt->config->string); + return GF_OK; } GF_Err gf_webvtt_dump_iso_sample(FILE *dump, u32 timescale, GF_ISOSample *iso_sample) { - GF_Err e; - GF_BitStream *bs; - - bs = gf_bs_new(iso_sample->data, iso_sample->dataLength, GF_BITSTREAM_READ); - while(gf_bs_available(bs)) - { - GF_Box *box; - GF_WebVTTTimestamp ts; - e = gf_isom_parse_box(&box, bs); - if (e) return e; - if (box->type == GF_ISOM_BOX_TYPE_VTCU) { - GF_VTTCueBox *cuebox = (GF_VTTCueBox *)box; - if (cuebox->id) fprintf(dump, "%s", cuebox->id->string); - gf_webvtt_timestamp_set(&ts, (iso_sample->DTS * 1000) / timescale); - gf_webvtt_timestamp_dump(&ts, dump, GF_FALSE); - fprintf(dump, " --> NEXT"); - if (cuebox->settings) fprintf(dump, " %s", cuebox->settings->string); - fprintf(dump, "\n"); - if (cuebox->payload) fprintf(dump, "%s", cuebox->payload->string); - fprintf(dump, "\n"); - } else if (box->type == GF_ISOM_BOX_TYPE_VTTE) { - gf_webvtt_timestamp_set(&ts, (iso_sample->DTS * 1000) / timescale); - gf_webvtt_timestamp_dump(&ts, dump, GF_FALSE); - fprintf(dump, " --> NEXT\n\n"); - } - gf_isom_box_del(box); - } - gf_bs_del(bs); - return GF_OK; + GF_Err e; + GF_BitStream *bs; + + bs = gf_bs_new(iso_sample->data, iso_sample->dataLength, GF_BITSTREAM_READ); + while(gf_bs_available(bs)) + { + GF_Box *box; + GF_WebVTTTimestamp ts; + e = gf_isom_parse_box(&box, bs); + if (e) return e; + if (box->type == GF_ISOM_BOX_TYPE_VTCU) { + GF_VTTCueBox *cuebox = (GF_VTTCueBox *)box; + if (cuebox->id) fprintf(dump, "%s", cuebox->id->string); + gf_webvtt_timestamp_set(&ts, (iso_sample->DTS * 1000) / timescale); + gf_webvtt_timestamp_dump(&ts, dump, GF_FALSE); + fprintf(dump, " --> NEXT"); + if (cuebox->settings) fprintf(dump, " %s", cuebox->settings->string); + fprintf(dump, "\n"); + if (cuebox->payload) fprintf(dump, "%s", cuebox->payload->string); + fprintf(dump, "\n"); + } else if (box->type == GF_ISOM_BOX_TYPE_VTTE) { + gf_webvtt_timestamp_set(&ts, (iso_sample->DTS * 1000) / timescale); + gf_webvtt_timestamp_dump(&ts, dump, GF_FALSE); + fprintf(dump, " --> NEXT\n\n"); + } + gf_isom_box_del(box); + } + gf_bs_del(bs); + return GF_OK; } GF_EXPORT @@ -1256,241 +1272,241 @@ GF_List *gf_webvtt_parse_iso_cues(GF_ISOSample *iso_sample, u64 start) GF_EXPORT GF_List *gf_webvtt_parse_cues_from_data(const char *data, u32 dataLength, u64 start) { - GF_List *cues; - GF_WebVTTCue *cue; - GF_VTTCueBox *cuebox; - GF_BitStream *bs; - cues = gf_list_new(); - bs = gf_bs_new(data, dataLength, GF_BITSTREAM_READ); - while(gf_bs_available(bs)) - { - GF_Err e; - GF_Box *box; - e = gf_isom_parse_box(&box, bs); - if (e) return NULL; - if (box->type == GF_ISOM_BOX_TYPE_VTCU) { - cuebox = (GF_VTTCueBox *)box; - cue = gf_webvtt_cue_new(); - gf_list_add(cues, cue); - gf_webvtt_timestamp_set(&cue->start, start); - if (cuebox->id) { - gf_webvtt_cue_add_property(cue, WEBVTT_ID, cuebox->id->string, (u32) strlen(cuebox->id->string)); - } - if (cuebox->settings) { - gf_webvtt_cue_add_property(cue, WEBVTT_SETTINGS, cuebox->settings->string, (u32) strlen(cuebox->settings->string)); - } - if (cuebox->payload) { - gf_webvtt_cue_add_property(cue, WEBVTT_PAYLOAD, cuebox->payload->string, (u32) strlen(cuebox->payload->string)); - } - } - gf_isom_box_del(box); - } - gf_bs_del(bs); - return cues; + GF_List *cues; + GF_WebVTTCue *cue; + GF_VTTCueBox *cuebox; + GF_BitStream *bs; + cues = gf_list_new(); + bs = gf_bs_new(data, dataLength, GF_BITSTREAM_READ); + while(gf_bs_available(bs)) + { + GF_Err e; + GF_Box *box; + e = gf_isom_parse_box(&box, bs); + if (e) return NULL; + if (box->type == GF_ISOM_BOX_TYPE_VTCU) { + cuebox = (GF_VTTCueBox *)box; + cue = gf_webvtt_cue_new(); + gf_list_add(cues, cue); + gf_webvtt_timestamp_set(&cue->start, start); + if (cuebox->id) { + gf_webvtt_cue_add_property(cue, WEBVTT_ID, cuebox->id->string, (u32) strlen(cuebox->id->string)); + } + if (cuebox->settings) { + gf_webvtt_cue_add_property(cue, WEBVTT_SETTINGS, cuebox->settings->string, (u32) strlen(cuebox->settings->string)); + } + if (cuebox->payload) { + gf_webvtt_cue_add_property(cue, WEBVTT_PAYLOAD, cuebox->payload->string, (u32) strlen(cuebox->payload->string)); + } + } + gf_isom_box_del(box); + } + gf_bs_del(bs); + return cues; } GF_Err gf_webvtt_merge_cues(GF_WebVTTParser *parser, u64 start, GF_List *cues) { - GF_WebVTTSample *wsample; - GF_WebVTTSample *prev_wsample; - Bool has_continuation_cue = GF_FALSE; - - assert(gf_list_count(parser->samples) <= 1); - - wsample = gf_webvtt_sample_new(); - wsample->start = start; - - prev_wsample = (GF_WebVTTSample *)gf_list_last(parser->samples); - if (gf_list_count(cues)) { - while (gf_list_count(cues)) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, 0); - gf_list_rem(cues, 0); - /* add the cue to the current sample */ - gf_list_add(wsample->cues, cue); - /* update with the previous sample */ - if (prev_wsample) { - Bool found = GF_FALSE; - while (!found && gf_list_count(prev_wsample->cues)) { - GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(prev_wsample->cues, 0); - gf_list_rem(prev_wsample->cues, 0); - if ( - ((!cue->id && !old_cue->id) || (old_cue->id && cue->id && !strcmp(old_cue->id, cue->id))) && - ((!cue->settings && !old_cue->settings) || (old_cue->settings && cue->settings && !strcmp(old_cue->settings, cue->settings))) && - ((!cue->text && !old_cue->text) || (old_cue->text && cue->text && !strcmp(old_cue->text, cue->text))) - ) { - /* if it is the same cue, update its start with the initial start */ - cue->start = old_cue->start; - has_continuation_cue = GF_TRUE; - found = GF_TRUE; - /* delete the old cue */ - gf_webvtt_cue_del(old_cue); - } else { - /* finalize the end cue time */ - if (gf_webvtt_timestamp_is_zero(&old_cue->end)) { - gf_webvtt_timestamp_set(&old_cue->end, wsample->start); - } - /* transfer the cue */ - if (!has_continuation_cue) { - /* the cue can be safely serialized while keeping the order */ - parser->on_cue_read(parser->user, old_cue); - } else { - /* keep the cue in the current sample to respect cue start ordering */ - gf_list_add(wsample->cues, old_cue); - } - } - } - } - } - } - /* No cue in the current sample */ - if (prev_wsample) { - while (gf_list_count(prev_wsample->cues)) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(prev_wsample->cues, 0); - gf_list_rem(prev_wsample->cues, 0); - /* finalize the end cue time */ - if (gf_webvtt_timestamp_is_zero(&cue->end)) { - gf_webvtt_timestamp_set(&cue->end, wsample->start); - } - /* transfer the cue */ - if (!has_continuation_cue) { - /* the cue can be safely serialized while keeping the order */ - parser->on_cue_read(parser->user, cue); - } else { - /* keep the cue in the current sample to respect cue start ordering */ - gf_list_add(wsample->cues, cue); - } - } - gf_webvtt_sample_del(prev_wsample); - gf_list_rem_last(parser->samples); - prev_wsample = NULL; - } else { - /* nothing to do */ - } - if (gf_list_count(wsample->cues)) { - gf_list_add(parser->samples, wsample); - } else { - gf_webvtt_sample_del(wsample); - } - return GF_OK; + GF_WebVTTSample *wsample; + GF_WebVTTSample *prev_wsample; + Bool has_continuation_cue = GF_FALSE; + + assert(gf_list_count(parser->samples) <= 1); + + wsample = gf_webvtt_sample_new(); + wsample->start = start; + + prev_wsample = (GF_WebVTTSample *)gf_list_last(parser->samples); + if (gf_list_count(cues)) { + while (gf_list_count(cues)) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, 0); + gf_list_rem(cues, 0); + /* add the cue to the current sample */ + gf_list_add(wsample->cues, cue); + /* update with the previous sample */ + if (prev_wsample) { + Bool found = GF_FALSE; + while (!found && gf_list_count(prev_wsample->cues)) { + GF_WebVTTCue *old_cue = (GF_WebVTTCue *)gf_list_get(prev_wsample->cues, 0); + gf_list_rem(prev_wsample->cues, 0); + if ( + ((!cue->id && !old_cue->id) || (old_cue->id && cue->id && !strcmp(old_cue->id, cue->id))) && + ((!cue->settings && !old_cue->settings) || (old_cue->settings && cue->settings && !strcmp(old_cue->settings, cue->settings))) && + ((!cue->text && !old_cue->text) || (old_cue->text && cue->text && !strcmp(old_cue->text, cue->text))) + ) { + /* if it is the same cue, update its start with the initial start */ + cue->start = old_cue->start; + has_continuation_cue = GF_TRUE; + found = GF_TRUE; + /* delete the old cue */ + gf_webvtt_cue_del(old_cue); + } else { + /* finalize the end cue time */ + if (gf_webvtt_timestamp_is_zero(&old_cue->end)) { + gf_webvtt_timestamp_set(&old_cue->end, wsample->start); + } + /* transfer the cue */ + if (!has_continuation_cue) { + /* the cue can be safely serialized while keeping the order */ + parser->on_cue_read(parser->user, old_cue); + } else { + /* keep the cue in the current sample to respect cue start ordering */ + gf_list_add(wsample->cues, old_cue); + } + } + } + } + } + } + /* No cue in the current sample */ + if (prev_wsample) { + while (gf_list_count(prev_wsample->cues)) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(prev_wsample->cues, 0); + gf_list_rem(prev_wsample->cues, 0); + /* finalize the end cue time */ + if (gf_webvtt_timestamp_is_zero(&cue->end)) { + gf_webvtt_timestamp_set(&cue->end, wsample->start); + } + /* transfer the cue */ + if (!has_continuation_cue) { + /* the cue can be safely serialized while keeping the order */ + parser->on_cue_read(parser->user, cue); + } else { + /* keep the cue in the current sample to respect cue start ordering */ + gf_list_add(wsample->cues, cue); + } + } + gf_webvtt_sample_del(prev_wsample); + gf_list_rem_last(parser->samples); + prev_wsample = NULL; + } else { + /* nothing to do */ + } + if (gf_list_count(wsample->cues)) { + gf_list_add(parser->samples, wsample); + } else { + gf_webvtt_sample_del(wsample); + } + return GF_OK; } GF_Err gf_webvtt_parse_iso_sample(GF_WebVTTParser *parser, u32 timescale, GF_ISOSample *iso_sample, Bool merge) { - if (merge) { - u64 start; - GF_List *cues; - start = (iso_sample->DTS * 1000) / timescale; - cues = gf_webvtt_parse_iso_cues(iso_sample, start); - gf_webvtt_merge_cues(parser, start, cues); - gf_list_del(cues); - } else { - gf_webvtt_dump_iso_sample((FILE *)parser->user, timescale, iso_sample); - } - - return GF_OK; + if (merge) { + u64 start; + GF_List *cues; + start = (iso_sample->DTS * 1000) / timescale; + cues = gf_webvtt_parse_iso_cues(iso_sample, start); + gf_webvtt_merge_cues(parser, start, cues); + gf_list_del(cues); + } else { + gf_webvtt_dump_iso_sample((FILE *)parser->user, timescale, iso_sample); + } + + return GF_OK; } #endif //GPAC_DISABLE_MEDIA_IMPORT #ifndef GPAC_DISABLE_ISOM_DUMP static GF_Err gf_webvtt_parser_dump_finalize(GF_WebVTTParser *parser, u64 duration) { - GF_WebVTTSample *sample; - assert(gf_list_count(parser->samples) <= 1); - sample = (GF_WebVTTSample *)gf_list_get(parser->samples, 0); - if (sample) { - while (gf_list_count(sample->cues)) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(sample->cues, 0); - gf_list_rem(sample->cues, 0); - if (gf_webvtt_timestamp_is_zero(&cue->end)) { - gf_webvtt_timestamp_set(&cue->end, duration); - } - parser->on_cue_read(parser->user, cue); - } - gf_webvtt_sample_del(sample); - gf_list_rem(parser->samples, 0); - } - return GF_OK; + GF_WebVTTSample *sample; + assert(gf_list_count(parser->samples) <= 1); + sample = (GF_WebVTTSample *)gf_list_get(parser->samples, 0); + if (sample) { + while (gf_list_count(sample->cues)) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(sample->cues, 0); + gf_list_rem(sample->cues, 0); + if (gf_webvtt_timestamp_is_zero(&cue->end)) { + gf_webvtt_timestamp_set(&cue->end, duration); + } + parser->on_cue_read(parser->user, cue); + } + gf_webvtt_sample_del(sample); + gf_list_rem(parser->samples, 0); + } + return GF_OK; } static void gf_webvtt_dump_cue(void *user, GF_WebVTTCue *cue) { - FILE *dump = (FILE *)user; - if (!cue || !dump) return; - if (cue->id) fprintf(dump, "%s", cue->id); - if (cue->start.hour || cue->end.hour) { - gf_webvtt_timestamp_dump(&cue->start, dump, GF_TRUE); - fprintf(dump, " --> "); - gf_webvtt_timestamp_dump(&cue->end, dump, GF_TRUE); - } else { - gf_webvtt_timestamp_dump(&cue->start, dump, GF_FALSE); - fprintf(dump, " --> "); - gf_webvtt_timestamp_dump(&cue->end, dump, GF_FALSE); - } - if (cue->settings) { - fprintf(dump, " %s", cue->settings); - } - fprintf(dump, "\n"); - if (cue->text) fprintf(dump, "%s", cue->text); - fprintf(dump, "\n"); + FILE *dump = (FILE *)user; + if (!cue || !dump) return; + if (cue->id) fprintf(dump, "%s", cue->id); + if (cue->start.hour || cue->end.hour) { + gf_webvtt_timestamp_dump(&cue->start, dump, GF_TRUE); + fprintf(dump, " --> "); + gf_webvtt_timestamp_dump(&cue->end, dump, GF_TRUE); + } else { + gf_webvtt_timestamp_dump(&cue->start, dump, GF_FALSE); + fprintf(dump, " --> "); + gf_webvtt_timestamp_dump(&cue->end, dump, GF_FALSE); + } + if (cue->settings) { + fprintf(dump, " %s", cue->settings); + } + fprintf(dump, "\n"); + if (cue->text) fprintf(dump, "%s", cue->text); + fprintf(dump, "\n"); } static GF_Err gf_webvtt_dump_cues(FILE *dump, GF_List *cues) { - u32 i; - for (i = 0; i < gf_list_count(cues); i++) { - GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, i); - gf_webvtt_dump_cue(dump, cue); - } - return GF_OK; + u32 i; + for (i = 0; i < gf_list_count(cues); i++) { + GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, i); + gf_webvtt_dump_cue(dump, cue); + } + return GF_OK; } GF_Err gf_webvtt_dump_sample(FILE *dump, GF_WebVTTSample *samp) { - fprintf(stdout, "NOTE New WebVTT Sample ("LLD"-"LLD")\n\n", samp->start, samp->end); - return gf_webvtt_dump_cues(dump, samp->cues); + fprintf(stdout, "NOTE New WebVTT Sample ("LLD"-"LLD")\n\n", samp->start, samp->end); + return gf_webvtt_dump_cues(dump, samp->cues); } GF_Err gf_webvtt_dump_iso_track(GF_MediaExporter *dumper, char *szName, u32 track, Bool merge) { - GF_Err e; - u32 i; - u32 count; - u32 timescale; - FILE *out; - u32 di; - u64 duration; - GF_WebVTTParser *parser; - - out = szName ? gf_f64_open(szName, "wt") : stdout; - if (!out) return GF_IO_ERR;// gf_export_message(dumper, GF_IO_ERR, "Error opening %s for writing - check disk access & permissions", szName); - - parser = gf_webvtt_parser_new(); - parser->user = out; - parser->on_cue_read = gf_webvtt_dump_cue; - - e = gf_webvtt_dump_header(out, dumper->file, track, 1); - if (e) goto exit; - - timescale = gf_isom_get_media_timescale(dumper->file, track); - - count = gf_isom_get_sample_count(dumper->file, track); - for (i=0; ifile, track, i+1, &di); - if (!samp) { - e = gf_isom_last_error(dumper->file); - goto exit; - } - e = gf_webvtt_parse_iso_sample(parser, timescale, samp, merge); - if (e) goto exit; - //gf_webvtt_dump_iso_sample(out, timescale, samp); - } - duration = gf_isom_get_media_duration(dumper->file, track); - gf_webvtt_parser_dump_finalize(parser, duration); + GF_Err e; + u32 i; + u32 count; + u32 timescale; + FILE *out; + u32 di; + u64 duration; + GF_WebVTTParser *parser; + + out = szName ? gf_f64_open(szName, "wt") : stdout; + if (!out) return GF_IO_ERR;// gf_export_message(dumper, GF_IO_ERR, "Error opening %s for writing - check disk access & permissions", szName); + + parser = gf_webvtt_parser_new(); + parser->user = out; + parser->on_cue_read = gf_webvtt_dump_cue; + + e = gf_webvtt_dump_header(out, dumper->file, track, 1); + if (e) goto exit; + + timescale = gf_isom_get_media_timescale(dumper->file, track); + + count = gf_isom_get_sample_count(dumper->file, track); + for (i=0; ifile, track, i+1, &di); + if (!samp) { + e = gf_isom_last_error(dumper->file); + goto exit; + } + e = gf_webvtt_parse_iso_sample(parser, timescale, samp, merge); + if (e) goto exit; + //gf_webvtt_dump_iso_sample(out, timescale, samp); + } + duration = gf_isom_get_media_duration(dumper->file, track); + gf_webvtt_parser_dump_finalize(parser, duration); exit: - gf_webvtt_parser_del(parser); - if (szName) fclose(out); - return e; + gf_webvtt_parser_del(parser); + if (szName) fclose(out); + return e; } #endif //GPAC_DISABLE_ISOM_DUMP diff --git a/src/odf/desc_private.c b/src/odf/desc_private.c index df63d5e..f90244e 100644 --- a/src/odf/desc_private.c +++ b/src/odf/desc_private.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -146,7 +146,7 @@ GF_Descriptor *gf_odf_create_descriptor(u8 tag) default: //ISO Reserved if ( (tag >= GF_ODF_ISO_RES_BEGIN_TAG) && - (tag <= GF_ODF_ISO_RES_END_TAG) ) { + (tag <= GF_ODF_ISO_RES_END_TAG) ) { return NULL; } desc = gf_odf_new_default(); @@ -345,7 +345,7 @@ GF_Err gf_odf_read_descriptor(GF_BitStream *bs, GF_Descriptor *desc, u32 DescSiz return gf_odf_read_smpte_camera(bs, (GF_SMPTECamera *)desc, DescSize); case GF_ODF_SCI_TAG: return gf_odf_read_sup_cid(bs, (GF_SCIDesc *)desc, DescSize); - + case GF_ODF_IPMP_TL_TAG: return gf_odf_read_ipmp_tool_list(bs, (GF_IPMP_ToolList *)desc, DescSize); case GF_ODF_IPMP_TOOL_TAG: @@ -370,13 +370,13 @@ GF_Err gf_odf_read_descriptor(GF_BitStream *bs, GF_Descriptor *desc, u32 DescSiz GF_Err gf_odf_size_descriptor(GF_Descriptor *desc, u32 *outSize) { switch(desc->tag) { - case GF_ODF_IOD_TAG : + case GF_ODF_IOD_TAG : return gf_odf_size_iod((GF_InitialObjectDescriptor *)desc, outSize); - case GF_ODF_ESD_TAG : + case GF_ODF_ESD_TAG : return gf_odf_size_esd((GF_ESD *)desc, outSize); - case GF_ODF_DCD_TAG : + case GF_ODF_DCD_TAG : return gf_odf_size_dcd((GF_DecoderConfig *)desc, outSize); - case GF_ODF_SLC_TAG : + case GF_ODF_SLC_TAG : return gf_odf_size_slc((GF_SLConfig *)desc, outSize); case GF_ODF_OD_TAG: @@ -396,7 +396,7 @@ GF_Err gf_odf_size_descriptor(GF_Descriptor *desc, u32 *outSize) return gf_odf_size_mediatime((GF_MediaTime *) desc, outSize); case GF_ODF_MUXINFO_TAG: return gf_odf_size_muxinfo((GF_MuxInfo *) desc, outSize); - + case GF_ODF_AUX_VIDEO_DATA: return gf_odf_size_auxvid((GF_AuxVideoDescriptor *)desc, outSize); @@ -469,13 +469,13 @@ GF_Err gf_odf_size_descriptor(GF_Descriptor *desc, u32 *outSize) GF_Err gf_odf_write_descriptor(GF_BitStream *bs, GF_Descriptor *desc) { switch(desc->tag) { - case GF_ODF_IOD_TAG : + case GF_ODF_IOD_TAG : return gf_odf_write_iod(bs, (GF_InitialObjectDescriptor *)desc); - case GF_ODF_ESD_TAG : + case GF_ODF_ESD_TAG : return gf_odf_write_esd(bs, (GF_ESD *)desc); - case GF_ODF_DCD_TAG : + case GF_ODF_DCD_TAG : return gf_odf_write_dcd(bs, (GF_DecoderConfig *)desc); - case GF_ODF_SLC_TAG : + case GF_ODF_SLC_TAG : return gf_odf_write_slc(bs, (GF_SLConfig *)desc); case GF_ODF_ESD_INC_TAG: return gf_odf_write_esd_inc(bs, (GF_ES_ID_Inc *)desc); @@ -586,8 +586,8 @@ GF_ODCom *gf_odf_create_command(u8 tag) return gf_odf_new_ipmp_remove(); default: - if ( (tag >= GF_ODF_COM_ISO_BEGIN_TAG) && - ( tag <= GF_ODF_COM_ISO_END_TAG) ) { + if ( (tag >= GF_ODF_COM_ISO_BEGIN_TAG) && + ( tag <= GF_ODF_COM_ISO_END_TAG) ) { return NULL; } com = gf_odf_new_base_command(); @@ -643,7 +643,7 @@ GF_Err gf_odf_read_command(GF_BitStream *bs, GF_ODCom *com, u32 gf_odf_size_comm case GF_ODF_IPMP_UPDATE_TAG: return gf_odf_read_ipmp_update(bs, (GF_IPMPUpdate *)com, gf_odf_size_command); case GF_ODF_IPMP_REMOVE_TAG: - return gf_odf_read_ipmp_remove(bs, (GF_IPMPRemove *)com, gf_odf_size_command); + return gf_odf_read_ipmp_remove(bs, (GF_IPMPRemove *)com, gf_odf_size_command); default: return gf_odf_read_base_command(bs, (GF_BaseODCom *)com, gf_odf_size_command); } @@ -698,7 +698,7 @@ GF_Err gf_odf_write_command(GF_BitStream *bs, GF_ODCom *com) return gf_odf_write_ipmp_update(bs, (GF_IPMPUpdate *)com); case GF_ODF_IPMP_REMOVE_TAG: return gf_odf_write_ipmp_remove(bs, (GF_IPMPRemove *)com); - + default: return gf_odf_write_base_command(bs, (GF_BaseODCom *)com); } diff --git a/src/odf/descriptors.c b/src/odf/descriptors.c index dc1f78f..5578c91 100644 --- a/src/odf/descriptors.c +++ b/src/odf/descriptors.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,20 +34,34 @@ GF_EXPORT const char *gf_odf_stream_type_name(u32 streamType) { switch (streamType) { - case GF_STREAM_OD: return "ObjectDescriptor"; - case GF_STREAM_OCR: return "ClockReference"; - case GF_STREAM_SCENE: return "SceneDescription"; - case GF_STREAM_VISUAL: return "Visual"; - case GF_STREAM_AUDIO: return "Audio"; - case GF_STREAM_MPEG7: return "MPEG7"; - case GF_STREAM_IPMP: return "IPMP"; - case GF_STREAM_OCI: return "OCI"; - case GF_STREAM_MPEGJ: return "MPEGJ"; - case GF_STREAM_INTERACT: return "Interaction"; - case GF_STREAM_FONT: return "Font"; - case GF_STREAM_TEXT: return "Text"; - case GF_STREAM_ND_SUBPIC: return "NeroDigital Subpicture"; - default: return "Unknown"; + case GF_STREAM_OD: + return "ObjectDescriptor"; + case GF_STREAM_OCR: + return "ClockReference"; + case GF_STREAM_SCENE: + return "SceneDescription"; + case GF_STREAM_VISUAL: + return "Visual"; + case GF_STREAM_AUDIO: + return "Audio"; + case GF_STREAM_MPEG7: + return "MPEG7"; + case GF_STREAM_IPMP: + return "IPMP"; + case GF_STREAM_OCI: + return "OCI"; + case GF_STREAM_MPEGJ: + return "MPEGJ"; + case GF_STREAM_INTERACT: + return "Interaction"; + case GF_STREAM_FONT: + return "Font"; + case GF_STREAM_TEXT: + return "Text"; + case GF_STREAM_ND_SUBPIC: + return "NeroDigital Subpicture"; + default: + return "Unknown"; } } @@ -101,7 +115,7 @@ GF_Err gf_odf_parse_descriptor(GF_BitStream *bs, GF_Descriptor **desc, u32 *desc //tag tag = (u8) gf_bs_read_int(bs, 8); sizeHeader = 1; - + //size size = 0; do { @@ -119,7 +133,7 @@ GF_Err gf_odf_parse_descriptor(GF_BitStream *bs, GF_Descriptor **desc, u32 *desc *desc = NULL; *desc_size = sizeHeader; if ( (tag >= GF_ODF_ISO_RES_BEGIN_TAG) && - (tag <= GF_ODF_ISO_RES_END_TAG) ) { + (tag <= GF_ODF_ISO_RES_END_TAG) ) { return GF_ODF_FORBIDDEN_DESCRIPTOR; } else if (!tag || (tag == 0xFF)) { @@ -145,7 +159,7 @@ GF_Err gf_odf_parse_descriptor(GF_BitStream *bs, GF_Descriptor **desc, u32 *desc } } - //little trick to handle lazy bitstreams that encode + //little trick to handle lazy bitstreams that encode //SizeOfInstance on a fix number of bytes //This nb of bytes is added in Read methods *desc_size += sizeHeader - gf_odf_size_field_size(*desc_size); @@ -182,16 +196,16 @@ GF_Err gf_odf_write_base_descriptor(GF_BitStream *bs, u8 tag, u32 size) unsigned char vals[4]; if (!tag ) return GF_BAD_PARAM; - + length = size; vals[3] = (unsigned char) (length & 0x7f); length >>= 7; - vals[2] = (unsigned char) ((length & 0x7f) | 0x80); + vals[2] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; - vals[1] = (unsigned char) ((length & 0x7f) | 0x80); + vals[1] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; vals[0] = (unsigned char) ((length & 0x7f) | 0x80); - + gf_bs_write_int(bs, tag, 8); if (size < 0x00000080) { gf_bs_write_int(bs, vals[3], 8); @@ -246,7 +260,7 @@ GF_Err gf_odf_write_descriptor_list(GF_BitStream *bs, GF_List *descList) if (tmp) { e = gf_odf_write_descriptor(bs, tmp); if (e) return e; - } + } } return GF_OK; } @@ -264,7 +278,7 @@ GF_Err gf_odf_write_descriptor_list_filter(GF_BitStream *bs, GF_List *descList, if (tmp && (tmp->tag==only_tag) ) { e = gf_odf_write_descriptor(bs, tmp); if (e) return e; - } + } } return GF_OK; } @@ -292,13 +306,16 @@ void gf_ipmpx_write_array(GF_BitStream *bs, char *data, u32 data_len) unsigned char vals[4]; if (!data || !data_len) return; - + length = data_len; - vals[3] = (unsigned char) (length & 0x7f); length >>= 7; - vals[2] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; - vals[1] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; + vals[3] = (unsigned char) (length & 0x7f); + length >>= 7; + vals[2] = (unsigned char) ((length & 0x7f) | 0x80); + length >>= 7; + vals[1] = (unsigned char) ((length & 0x7f) | 0x80); + length >>= 7; vals[0] = (unsigned char) ((length & 0x7f) | 0x80); - + if (data_len < 0x00000080) { gf_bs_write_int(bs, vals[3], 8); } else if (data_len < 0x00004000) { @@ -334,14 +351,14 @@ GF_BIFSConfig *gf_odf_get_bifs_config(GF_DefaultDescriptor *dsi, u8 oti) if (!dsi || !dsi->data || !dsi->dataLength ) { /* Hack for T-DMB non compliant streams (OnTimeTek ?) */ - cfg = (GF_BIFSConfig *) gf_odf_desc_new(GF_ODF_BIFS_CFG_TAG); + cfg = (GF_BIFSConfig *) gf_odf_desc_new(GF_ODF_BIFS_CFG_TAG); cfg->pixelMetrics = 1; cfg->version = 1; return cfg; } bs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ); - - cfg = (GF_BIFSConfig *) gf_odf_desc_new(GF_ODF_BIFS_CFG_TAG); + + cfg = (GF_BIFSConfig *) gf_odf_desc_new(GF_ODF_BIFS_CFG_TAG); if (oti==2) { /*3D Mesh Coding*/ gf_bs_read_int(bs, 1); @@ -351,7 +368,7 @@ GF_BIFSConfig *gf_odf_get_bifs_config(GF_DefaultDescriptor *dsi, u8 oti) cfg->nodeIDbits = gf_bs_read_int(bs, 5); cfg->routeIDbits = gf_bs_read_int(bs, 5); if (oti==2) cfg->protoIDbits = gf_bs_read_int(bs, 5); - + cmd_stream = gf_bs_read_int(bs, 1); if (!cmd_stream) { cfg->elementaryMasks = gf_list_new(); @@ -393,10 +410,10 @@ GF_Err gf_odf_get_laser_config(GF_DefaultDescriptor *dsi, GF_LASERConfig *cfg) cfg->tag = GF_ODF_LASER_CFG_TAG; cfg->profile = gf_bs_read_int(bs, 8); cfg->level = gf_bs_read_int(bs, 8); - /*cfg->reserved = */gf_bs_read_int(bs, 3); - cfg->pointsCodec = gf_bs_read_int(bs, 2); - cfg->pathComponents = gf_bs_read_int(bs, 4); - cfg->fullRequestHost = gf_bs_read_int(bs, 1); + /*cfg->reserved = */gf_bs_read_int(bs, 3); + cfg->pointsCodec = gf_bs_read_int(bs, 2); + cfg->pathComponents = gf_bs_read_int(bs, 4); + cfg->fullRequestHost = gf_bs_read_int(bs, 1); if (gf_bs_read_int(bs, 1)) cfg->time_resolution = gf_bs_read_int(bs, 16); else cfg->time_resolution = 1000; cfg->colorComponentBits = 1 + gf_bs_read_int(bs, 4); @@ -434,7 +451,7 @@ GF_Err gf_odf_get_ui_config(GF_DefaultDescriptor *dsi, GF_UIConfig *cfg) GF_BitStream *bs; if (!dsi || !dsi->data || !dsi->dataLength || !cfg) return GF_BAD_PARAM; memset(cfg, 0, sizeof(GF_UIConfig)); - cfg->tag = GF_ODF_UI_CFG_TAG; + cfg->tag = GF_ODF_UI_CFG_TAG; bs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ); len = gf_bs_read_int(bs, 8); cfg->deviceName = (char*)gf_malloc(sizeof(char) * (len+1)); @@ -649,7 +666,7 @@ GF_Descriptor *gf_odf_new_tx3g() GF_Err gf_odf_del_tx3g(GF_TextSampleDescriptor *sd) { u32 i; - for (i=0; ifont_count; i++) + for (i=0; ifont_count; i++) if (sd->fonts[i].fontName) gf_free(sd->fonts[i].fontName); gf_free(sd->fonts); gf_free(sd); @@ -681,7 +698,7 @@ void ResetTextConfig(GF_TextConfig *desc) } bck = desc->sample_descriptions; memset(desc, 0, sizeof(GF_TextConfig)); - desc->tag = GF_ODF_TEXT_CFG_TAG; + desc->tag = GF_ODF_TEXT_CFG_TAG; desc->sample_descriptions = bck; } @@ -783,7 +800,7 @@ GF_Err gf_odf_get_text_config(GF_DefaultDescriptor *dsi, u8 oti, GF_TextConfig * cfg->horiz_offset = gf_bs_read_int(bs, 16); cfg->vert_offset = gf_bs_read_int(bs, 16); } - + #ifndef GPAC_DISABLE_ISOM exit: #endif @@ -896,7 +913,7 @@ GF_Err gf_odf_hevc_cfg_write(GF_HEVCConfig *cfg, char **outData, u32 *outSize) *outSize = 0; *outData = NULL; e = gf_odf_hevc_cfg_write_bs(cfg, bs); - if (e==GF_OK) + if (e==GF_OK) gf_bs_get_content(bs, outData, outSize); gf_bs_del(bs); @@ -955,7 +972,7 @@ GF_HEVCConfig *gf_odf_hevc_cfg_read_bs(GF_BitStream *bs, Bool is_shvc) GF_SAFEALLOC(ar, GF_HEVCParamArray); ar->nalus = gf_list_new(); gf_list_add(cfg->param_array, ar); - + ar->array_completeness = gf_bs_read_int(bs, 1); gf_bs_read_int(bs, 1); ar->type = gf_bs_read_int(bs, 6); @@ -1041,16 +1058,16 @@ const char *gf_esd_get_textual_description(GF_ESD *esd) case GPAC_OTI_SCENE_BIFS_EXTENDED: return "MPEG-4 Extended BIFS Scene Description"; case GPAC_OTI_SCENE_AFX: - if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) + if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return "AFX Unknown"; return gf_afx_get_type_description(esd->decoderConfig->decoderSpecificInfo->data[0]); case GPAC_OTI_SCENE_LASER: - { - GF_LASERConfig l_cfg; - gf_odf_get_laser_config(esd->decoderConfig->decoderSpecificInfo, &l_cfg); - if (! l_cfg.newSceneIndicator ) return "LASeR Scene Segment Description"; - } - return "LASeR Scene Description"; + { + GF_LASERConfig l_cfg; + gf_odf_get_laser_config(esd->decoderConfig->decoderSpecificInfo, &l_cfg); + if (! l_cfg.newSceneIndicator ) return "LASeR Scene Segment Description"; + } + return "LASeR Scene Description"; case GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE: return "MPEG-4 Synthesized Texture"; case GPAC_OTI_SCENE_SAF: @@ -1118,17 +1135,17 @@ const char *gf_esd_get_textual_description(GF_ESD *esd) case GPAC_OTI_AUDIO_MPEG1: return "MPEG-1 Audio"; case GPAC_OTI_AUDIO_AAC_MPEG4: - { + { #ifdef GPAC_DISABLE_AV_PARSERS - return "MPEG-4 AAC"; + return "MPEG-4 AAC"; #else - GF_M4ADecSpecInfo a_cfg; - if (!esd->decoderConfig->decoderSpecificInfo) return "MPEG-4 AAC"; - gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg); - return gf_m4a_object_type_name(a_cfg.base_object_type); + GF_M4ADecSpecInfo a_cfg; + if (!esd->decoderConfig->decoderSpecificInfo) return "MPEG-4 AAC"; + gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg); + return gf_m4a_object_type_name(a_cfg.base_object_type); #endif - } - break; + } + break; case GPAC_OTI_MEDIA_FFMPEG: return "GPAC FFMPEG Private Audio"; case GPAC_OTI_AUDIO_EVRC_VOICE: @@ -1137,7 +1154,7 @@ const char *gf_esd_get_textual_description(GF_ESD *esd) return "SMV Voice"; case GPAC_OTI_AUDIO_AC3: return "AC-3 audio"; - case GPAC_OTI_AUDIO_AC3_ENHANCED: + case GPAC_OTI_AUDIO_EAC3: return "Enhanced AC-3 Audio"; case GPAC_OTI_AUDIO_DRA: return "DRA Audio"; @@ -1175,30 +1192,30 @@ const char *gf_esd_get_textual_description(GF_ESD *esd) case GF_STREAM_PRIVATE_SCENE: switch (esd->decoderConfig->objectTypeIndication) { case GPAC_OTI_PRIVATE_SCENE_GENERIC: - { - char *ext = strchr(esd->decoderConfig->decoderSpecificInfo->data + 4, '.'); - if (!ext) return "GPAC Internal Scene Description"; - ext += 1; - if (!strnicmp(ext, "bt", 2)) - return "BT Scene Description"; - if (!strnicmp(ext, "xmt", 2)) - return "XMT Scene Description"; - if (!strnicmp(ext, "wrl", 3)) - return "VRML Scene Description"; - if (!strnicmp(ext, "x3d", 3)) - return "W3D Scene Description"; - if (!strnicmp(ext, "x3dv", 4)) - return "X3D Scene Description"; - if (!strnicmp(ext, "swf", 3)) - return "Flash (SWF) Scene Description"; - if (!strnicmp(ext, "xsr", 3)) - return "LASeR-ML Scene Description"; - if (!strnicmp(ext, "wgt", 3)) - return "W3C Widget Package"; - if (!strnicmp(ext, "mgt", 3)) - return "MPEG-U Widget Package"; - } - return "GPAC Internal Scene Description"; + { + char *ext = strchr(esd->decoderConfig->decoderSpecificInfo->data + 4, '.'); + if (!ext) return "GPAC Internal Scene Description"; + ext += 1; + if (!strnicmp(ext, "bt", 2)) + return "BT Scene Description"; + if (!strnicmp(ext, "xmt", 2)) + return "XMT Scene Description"; + if (!strnicmp(ext, "wrl", 3)) + return "VRML Scene Description"; + if (!strnicmp(ext, "x3d", 3)) + return "W3D Scene Description"; + if (!strnicmp(ext, "x3dv", 4)) + return "X3D Scene Description"; + if (!strnicmp(ext, "swf", 3)) + return "Flash (SWF) Scene Description"; + if (!strnicmp(ext, "xsr", 3)) + return "LASeR-ML Scene Description"; + if (!strnicmp(ext, "wgt", 3)) + return "W3C Widget Package"; + if (!strnicmp(ext, "mgt", 3)) + return "MPEG-U Widget Package"; + } + return "GPAC Internal Scene Description"; case GPAC_OTI_PRIVATE_SCENE_SVG: return "SVG"; case GPAC_OTI_PRIVATE_SCENE_LASER: diff --git a/src/odf/ipmpx_code.c b/src/odf/ipmpx_code.c index be5d170..2cf8628 100644 --- a/src/odf/ipmpx_code.c +++ b/src/odf/ipmpx_code.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -34,7 +34,7 @@ memset(__ptr, 0, sizeof(__stname)); \ ((GF_IPMPX_Data *)__ptr)->tag = __tag; \ ((GF_IPMPX_Data *)__ptr)->Version = 0x01; \ - + #define GF_IPMPX_DELETE_ARRAY(__ar) if (__ar) { if (__ar->data) gf_free(__ar->data); gf_free(__ar); } @@ -51,10 +51,13 @@ void write_var_size(GF_BitStream *bs, u32 size) unsigned char vals[4]; u32 length = size; - vals[3] = (unsigned char) (length & 0x7f); length >>= 7; - vals[2] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; - vals[1] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; - vals[0] = (unsigned char) ((length & 0x7f) | 0x80); + vals[3] = (unsigned char) (length & 0x7f); + length >>= 7; + vals[2] = (unsigned char) ((length & 0x7f) | 0x80); + length >>= 7; + vals[1] = (unsigned char) ((length & 0x7f) | 0x80); + length >>= 7; + vals[0] = (unsigned char) ((length & 0x7f) | 0x80); if (size < 0x00000080) { gf_bs_write_int(bs, vals[3], 8); } else if (size < 0x00004000) { @@ -69,7 +72,7 @@ void write_var_size(GF_BitStream *bs, u32 size) gf_bs_write_int(bs, vals[1], 8); gf_bs_write_int(bs, vals[2], 8); gf_bs_write_int(bs, vals[3], 8); - } + } } GF_IPMPX_ByteArray *GF_IPMPX_GetByteArray(GF_BitStream *bs) @@ -111,20 +114,20 @@ void GF_IPMPX_AUTH_Delete(GF_IPMPX_Authentication *auth) if (!auth) return; switch (auth->tag) { case GF_IPMPX_AUTH_AlgorithmDescr_Tag: - { - GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; - GF_IPMPX_DELETE_ARRAY(p->specAlgoID); - GF_IPMPX_DELETE_ARRAY(p->OpaqueData); - gf_free(p); - } - break; + { + GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; + GF_IPMPX_DELETE_ARRAY(p->specAlgoID); + GF_IPMPX_DELETE_ARRAY(p->OpaqueData); + gf_free(p); + } + break; case GF_IPMPX_AUTH_KeyDescr_Tag: - { - GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; - if (p->keyBody) gf_free(p->keyBody); - gf_free(p); - } - break; + { + GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; + if (p->keyBody) gf_free(p->keyBody); + gf_free(p); + } + break; } } @@ -134,20 +137,20 @@ u32 GF_IPMPX_AUTH_Size(GF_IPMPX_Authentication *auth) if (!auth) return 0; switch (auth->tag) { case GF_IPMPX_AUTH_AlgorithmDescr_Tag: - { - GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; - size = 1 + (p->specAlgoID ? GF_IPMPX_GetByteArraySize(p->specAlgoID) : 2); - size += GF_IPMPX_GetByteArraySize(p->OpaqueData); - return size; - } - break; + { + GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; + size = 1 + (p->specAlgoID ? GF_IPMPX_GetByteArraySize(p->specAlgoID) : 2); + size += GF_IPMPX_GetByteArraySize(p->OpaqueData); + return size; + } + break; case GF_IPMPX_AUTH_KeyDescr_Tag: - { - GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; - size = p->keyBodyLength; - return size; - } - break; + { + GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; + size = p->keyBodyLength; + return size; + } + break; default: return 0; } @@ -173,25 +176,25 @@ GF_Err WriteGF_IPMPX_AUTH(GF_BitStream *bs, GF_IPMPX_Authentication *auth) switch (auth->tag) { case GF_IPMPX_AUTH_AlgorithmDescr_Tag: - { - GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; - gf_bs_write_int(bs, p->specAlgoID ? 0 : 1, 1); - gf_bs_write_int(bs, 0, 7); - if (p->specAlgoID) { - GF_IPMPX_WriteByteArray(bs, p->specAlgoID); - } else { - gf_bs_write_int(bs, p->regAlgoID, 16); - } - GF_IPMPX_WriteByteArray(bs, p->OpaqueData); + { + GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)auth; + gf_bs_write_int(bs, p->specAlgoID ? 0 : 1, 1); + gf_bs_write_int(bs, 0, 7); + if (p->specAlgoID) { + GF_IPMPX_WriteByteArray(bs, p->specAlgoID); + } else { + gf_bs_write_int(bs, p->regAlgoID, 16); } - break; + GF_IPMPX_WriteByteArray(bs, p->OpaqueData); + } + break; case GF_IPMPX_AUTH_KeyDescr_Tag: - { - GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; - /*tag*/ - gf_bs_write_data(bs, p->keyBody, p->keyBodyLength); - } - break; + { + GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)auth; + /*tag*/ + gf_bs_write_data(bs, p->keyBody, p->keyBodyLength); + } + break; default: break; } @@ -214,37 +217,37 @@ GF_Err GF_IPMPX_AUTH_Parse(GF_BitStream *bs, GF_IPMPX_Authentication **auth) switch (tag) { case GF_IPMPX_AUTH_KeyDescr_Tag: - { - GF_IPMPX_AUTH_KeyDescriptor *p; - GF_SAFEALLOC(p, GF_IPMPX_AUTH_KeyDescriptor); - if (!p) return GF_OUT_OF_MEM; - p->tag = tag; - p->keyBodyLength = size; - p->keyBody = (char*)gf_malloc(sizeof(char)*size); - gf_bs_read_data(bs, p->keyBody, size); - *auth = (GF_IPMPX_Authentication *)p; - return GF_OK; - } - break; + { + GF_IPMPX_AUTH_KeyDescriptor *p; + GF_SAFEALLOC(p, GF_IPMPX_AUTH_KeyDescriptor); + if (!p) return GF_OUT_OF_MEM; + p->tag = tag; + p->keyBodyLength = size; + p->keyBody = (char*)gf_malloc(sizeof(char)*size); + gf_bs_read_data(bs, p->keyBody, size); + *auth = (GF_IPMPX_Authentication *)p; + return GF_OK; + } + break; case GF_IPMPX_AUTH_AlgorithmDescr_Tag: - { - Bool isReg; - GF_IPMPX_AUTH_AlgorithmDescriptor *p; - GF_SAFEALLOC(p, GF_IPMPX_AUTH_AlgorithmDescriptor); - if (!p) return GF_OUT_OF_MEM; - p->tag = tag; - isReg = gf_bs_read_int(bs, 1); - gf_bs_read_int(bs, 7); - if (isReg) { - p->regAlgoID = gf_bs_read_int(bs, 16); - } else { - p->specAlgoID = GF_IPMPX_GetByteArray(bs); - } - p->OpaqueData = GF_IPMPX_GetByteArray(bs); - *auth = (GF_IPMPX_Authentication *)p; - return GF_OK; + { + Bool isReg; + GF_IPMPX_AUTH_AlgorithmDescriptor *p; + GF_SAFEALLOC(p, GF_IPMPX_AUTH_AlgorithmDescriptor); + if (!p) return GF_OUT_OF_MEM; + p->tag = tag; + isReg = gf_bs_read_int(bs, 1); + gf_bs_read_int(bs, 7); + if (isReg) { + p->regAlgoID = gf_bs_read_int(bs, 16); + } else { + p->specAlgoID = GF_IPMPX_GetByteArray(bs); } - break; + p->OpaqueData = GF_IPMPX_GetByteArray(bs); + *auth = (GF_IPMPX_Authentication *)p; + return GF_OK; + } + break; default: break; } @@ -355,7 +358,7 @@ static GF_IPMPX_Data *NewGF_IPMPX_MutualAuthentication() static void delete_algo_list(GF_List *algos) { u32 i; - for (i=0;ifailedNegotiation = gf_bs_read_int(bs, 1); @@ -462,7 +465,7 @@ static u32 SizeGF_IPMPX_MutualAuthentication(GF_IPMPX_Data *_p) } } if (p->AuthenticationData) size += GF_IPMPX_GetByteArraySize(p->AuthenticationData); - + count = gf_list_count(p->certificates); if (count || p->opaque || p->publicKey) { size += 1; @@ -520,7 +523,7 @@ static GF_Err WriteGF_IPMPX_MutualAuthentication(GF_BitStream *bs, GF_IPMPX_Data } } if (p->AuthenticationData) GF_IPMPX_WriteByteArray(bs, p->AuthenticationData); - + count = gf_list_count(p->certificates); if (count || p->opaque || p->publicKey) { /*type 1*/ @@ -618,7 +621,7 @@ static u32 SizeGF_IPMPX_TrustSecurityMetadata(GF_IPMPX_Data *_p) u32 size, i, j; GF_IPMPX_TrustSecurityMetadata *p = (GF_IPMPX_TrustSecurityMetadata *)_p; size = 2; - for (i=0;iTrustedTools); i++) { + for (i=0; iTrustedTools); i++) { GF_IPMPX_TrustedTool *tt = (GF_IPMPX_TrustedTool *)gf_list_get(p->TrustedTools, i); size += 23; for (j=0; jtrustSpecifications); j++) { @@ -637,7 +640,7 @@ static GF_Err WriteGF_IPMPX_TrustSecurityMetadata(GF_BitStream *bs, GF_IPMPX_Dat c1 = gf_list_count(p->TrustedTools); gf_bs_write_int(bs, c1, 16); - for (i=0;iTrustedTools, i); gf_bs_write_data(bs, (char*)tt->toolID, 16); gf_bs_write_data(bs, (char*)tt->AuditDate, 5); @@ -1064,7 +1067,7 @@ static GF_Err ReadGF_IPMPX_AddToolNotificationListener(GF_BitStream *bs, GF_IPMP p->scope = gf_bs_read_int(bs, 3); gf_bs_read_int(bs, 5); p->eventTypeCount = gf_bs_read_int(bs, 8); - for (i=0;ieventTypeCount; i++) p->eventType[i] = gf_bs_read_int(bs, 8); + for (i=0; ieventTypeCount; i++) p->eventType[i] = gf_bs_read_int(bs, 8); return GF_OK; } static u32 SizeGF_IPMPX_AddToolNotificationListener(GF_IPMPX_Data *_p) @@ -1079,7 +1082,7 @@ static GF_Err WriteGF_IPMPX_AddToolNotificationListener(GF_BitStream *bs, GF_IPM gf_bs_write_int(bs, p->scope, 3); gf_bs_write_int(bs, 0, 5); gf_bs_write_int(bs, p->eventTypeCount, 8); - for (i=0;ieventTypeCount; i++) gf_bs_write_int(bs, p->eventType[i], 8); + for (i=0; ieventTypeCount; i++) gf_bs_write_int(bs, p->eventType[i], 8); return GF_OK; } static GF_IPMPX_Data *NewGF_IPMPX_RemoveToolNotificationListener() @@ -1097,7 +1100,7 @@ static GF_Err ReadGF_IPMPX_RemoveToolNotificationListener(GF_BitStream *bs, GF_I u32 i; GF_IPMPX_RemoveToolNotificationListener*p = (GF_IPMPX_RemoveToolNotificationListener*)_p; p->eventTypeCount = gf_bs_read_int(bs, 8); - for (i=0;ieventTypeCount; i++) p->eventType[i] = gf_bs_read_int(bs, 8); + for (i=0; ieventTypeCount; i++) p->eventType[i] = gf_bs_read_int(bs, 8); return GF_OK; } static u32 SizeGF_IPMPX_RemoveToolNotificationListener(GF_IPMPX_Data *_p) @@ -1110,7 +1113,7 @@ static GF_Err WriteGF_IPMPX_RemoveToolNotificationListener(GF_BitStream *bs, GF_ u32 i; GF_IPMPX_RemoveToolNotificationListener*p = (GF_IPMPX_RemoveToolNotificationListener*)_p; gf_bs_write_int(bs, p->eventTypeCount, 8); - for (i=0;ieventTypeCount; i++) gf_bs_write_int(bs, p->eventType[i], 8); + for (i=0; ieventTypeCount; i++) gf_bs_write_int(bs, p->eventType[i], 8); return GF_OK; } @@ -1695,26 +1698,45 @@ GF_IPMPX_Data *gf_ipmpx_data_new(u8 tag) { switch (tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: return NewGF_IPMPX_OpaqueData(tag); - case GF_IPMPX_KEY_DATA_TAG: return NewGF_IPMPX_KeyData(); - case GF_IPMPX_SECURE_CONTAINER_TAG: return NewGF_IPMPX_SecureContainer(); - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: return NewGF_IPMPX_AddToolNotificationListener(); - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: return NewGF_IPMPX_RemoveToolNotificationListener(); - case GF_IPMPX_INIT_AUTHENTICATION_TAG: return NewGF_IPMPX_InitAuthentication(); - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: return NewGF_IPMPX_MutualAuthentication(); - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: return NewGF_IPMPX_ParametricDescription(); - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: return NewGF_IPMPX_ToolParamCapabilitiesQuery(); - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: return NewGF_IPMPX_ToolParamCapabilitiesResponse(); - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: return NewGF_IPMPX_GetToolsResponse(); - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: return NewGF_IPMPX_GetToolContext(); - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: return NewGF_IPMPX_GetToolContextResponse(); - case GF_IPMPX_CONNECT_TOOL_TAG: return NewGF_IPMPX_ConnectTool(); - case GF_IPMPX_DISCONNECT_TOOL_TAG: return NewGF_IPMPX_DisconnectTool(); - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: return NewGF_IPMPX_NotifyToolEvent(); - case GF_IPMPX_CAN_PROCESS_TAG: return NewGF_IPMPX_CanProcess(); - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: return NewGF_IPMPX_TrustSecurityMetadata(); - case GF_IPMPX_ISMACRYP_TAG: return NewGF_IPMPX_ISMACryp(); - case GF_IPMPX_GET_TOOLS_TAG: + case GF_IPMPX_OPAQUE_DATA_TAG: + return NewGF_IPMPX_OpaqueData(tag); + case GF_IPMPX_KEY_DATA_TAG: + return NewGF_IPMPX_KeyData(); + case GF_IPMPX_SECURE_CONTAINER_TAG: + return NewGF_IPMPX_SecureContainer(); + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + return NewGF_IPMPX_AddToolNotificationListener(); + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + return NewGF_IPMPX_RemoveToolNotificationListener(); + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + return NewGF_IPMPX_InitAuthentication(); + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + return NewGF_IPMPX_MutualAuthentication(); + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + return NewGF_IPMPX_ParametricDescription(); + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + return NewGF_IPMPX_ToolParamCapabilitiesQuery(); + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + return NewGF_IPMPX_ToolParamCapabilitiesResponse(); + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + return NewGF_IPMPX_GetToolsResponse(); + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + return NewGF_IPMPX_GetToolContext(); + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + return NewGF_IPMPX_GetToolContextResponse(); + case GF_IPMPX_CONNECT_TOOL_TAG: + return NewGF_IPMPX_ConnectTool(); + case GF_IPMPX_DISCONNECT_TOOL_TAG: + return NewGF_IPMPX_DisconnectTool(); + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + return NewGF_IPMPX_NotifyToolEvent(); + case GF_IPMPX_CAN_PROCESS_TAG: + return NewGF_IPMPX_CanProcess(); + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + return NewGF_IPMPX_TrustSecurityMetadata(); + case GF_IPMPX_ISMACRYP_TAG: + return NewGF_IPMPX_ISMACryp(); + case GF_IPMPX_GET_TOOLS_TAG: { GF_IPMPX_Data *p; GF_IPMPX_DATA_ALLOC(p, GF_IPMPX_Data, GF_IPMPX_GET_TOOLS_TAG); @@ -1733,13 +1755,15 @@ GF_IPMPX_Data *gf_ipmpx_data_new(u8 tag) GF_IPMPX_DATA_ALLOC(p, GF_IPMPX_TrustSpecification, GF_IPMPX_TRUST_SPECIFICATION_TAG); return (GF_IPMPX_Data *)p; } - case GF_IPMPX_TOOL_API_CONFIG_TAG: return NewGF_IPMPX_ToolAPI_Config(); - case GF_IPMPX_SEL_DEC_INIT_TAG: return NewGF_IPMPX_SelectiveDecryptionInit(); - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: + case GF_IPMPX_TOOL_API_CONFIG_TAG: + return NewGF_IPMPX_ToolAPI_Config(); + case GF_IPMPX_SEL_DEC_INIT_TAG: + return NewGF_IPMPX_SelectiveDecryptionInit(); + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: return NewGF_IPMPX_WatermarkingInit(tag); - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: return NewGF_IPMPX_SendWatermark(tag); case GF_IPMPX_ALGORITHM_DESCRIPTOR_TAG: @@ -1784,11 +1808,12 @@ GF_IPMPX_Data *gf_ipmpx_data_new(u8 tag) return (GF_IPMPX_Data *) p; } -/* - case GF_IPMPX_USER_QUERY_TAG: return NewGF_IPMPX_UserQuery(); - case GF_IPMPX_USER_RESPONSE_TAG: return NewGF_IPMPX_UserQueryResponse(); -*/ - default: return NULL; + /* + case GF_IPMPX_USER_QUERY_TAG: return NewGF_IPMPX_UserQuery(); + case GF_IPMPX_USER_RESPONSE_TAG: return NewGF_IPMPX_UserQueryResponse(); + */ + default: + return NULL; } } @@ -1798,38 +1823,82 @@ void gf_ipmpx_data_del(GF_IPMPX_Data *_p) if (!_p) return; switch (_p->tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: DelGF_IPMPX_OpaqueData(_p); return; - case GF_IPMPX_KEY_DATA_TAG: DelGF_IPMPX_KeyData(_p); return; - case GF_IPMPX_SECURE_CONTAINER_TAG: DelGF_IPMPX_SecureContainer(_p); return; - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: DelGF_IPMPX_AddToolNotificationListener(_p); return; - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: DelGF_IPMPX_RemoveToolNotificationListener(_p); return; - case GF_IPMPX_INIT_AUTHENTICATION_TAG: DelGF_IPMPX_InitAuthentication(_p); return; - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: DelGF_IPMPX_MutualAuthentication(_p); return; - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: DelGF_IPMPX_ParametricDescription(_p); return; - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: DelGF_IPMPX_ToolParamCapabilitiesQuery(_p); return; - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: DelGF_IPMPX_ToolParamCapabilitiesResponse(_p); return; - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: DelGF_IPMPX_GetToolsResponse(_p); return; - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: DelGF_IPMPX_GetToolContext(_p); return; - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: DelGF_IPMPX_GetToolContextResponse(_p); return; - case GF_IPMPX_CONNECT_TOOL_TAG: DelGF_IPMPX_ConnectTool(_p); return; - case GF_IPMPX_DISCONNECT_TOOL_TAG: DelGF_IPMPX_DisconnectTool(_p); return; - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: DelGF_IPMPX_NotifyToolEvent(_p); return; - case GF_IPMPX_CAN_PROCESS_TAG: DelGF_IPMPX_CanProcess(_p); return; - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: DelGF_IPMPX_TrustSecurityMetadata(_p); return; - case GF_IPMPX_TOOL_API_CONFIG_TAG: DelGF_IPMPX_ToolAPI_Config(_p); return; - case GF_IPMPX_ISMACRYP_TAG: DelGF_IPMPX_ISMACryp(_p); return; - case GF_IPMPX_SEL_DEC_INIT_TAG: DelGF_IPMPX_SelectiveDecryptionInit(_p); return; - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: - DelGF_IPMPX_WatermarkingInit(_p); return; - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: - DelGF_IPMPX_SendWatermark(_p); return; + case GF_IPMPX_OPAQUE_DATA_TAG: + DelGF_IPMPX_OpaqueData(_p); + return; + case GF_IPMPX_KEY_DATA_TAG: + DelGF_IPMPX_KeyData(_p); + return; + case GF_IPMPX_SECURE_CONTAINER_TAG: + DelGF_IPMPX_SecureContainer(_p); + return; + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + DelGF_IPMPX_AddToolNotificationListener(_p); + return; + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + DelGF_IPMPX_RemoveToolNotificationListener(_p); + return; + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + DelGF_IPMPX_InitAuthentication(_p); + return; + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + DelGF_IPMPX_MutualAuthentication(_p); + return; + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + DelGF_IPMPX_ParametricDescription(_p); + return; + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + DelGF_IPMPX_ToolParamCapabilitiesQuery(_p); + return; + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + DelGF_IPMPX_ToolParamCapabilitiesResponse(_p); + return; + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + DelGF_IPMPX_GetToolsResponse(_p); + return; + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + DelGF_IPMPX_GetToolContext(_p); + return; + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + DelGF_IPMPX_GetToolContextResponse(_p); + return; + case GF_IPMPX_CONNECT_TOOL_TAG: + DelGF_IPMPX_ConnectTool(_p); + return; + case GF_IPMPX_DISCONNECT_TOOL_TAG: + DelGF_IPMPX_DisconnectTool(_p); + return; + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + DelGF_IPMPX_NotifyToolEvent(_p); + return; + case GF_IPMPX_CAN_PROCESS_TAG: + DelGF_IPMPX_CanProcess(_p); + return; + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + DelGF_IPMPX_TrustSecurityMetadata(_p); + return; + case GF_IPMPX_TOOL_API_CONFIG_TAG: + DelGF_IPMPX_ToolAPI_Config(_p); + return; + case GF_IPMPX_ISMACRYP_TAG: + DelGF_IPMPX_ISMACryp(_p); + return; + case GF_IPMPX_SEL_DEC_INIT_TAG: + DelGF_IPMPX_SelectiveDecryptionInit(_p); + return; + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: + DelGF_IPMPX_WatermarkingInit(_p); + return; + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: + DelGF_IPMPX_SendWatermark(_p); + return; -/* - case GF_IPMPX_USER_QUERY_TAG: DelGF_IPMPX_UserQuery(_p); return; - case GF_IPMPX_USER_RESPONSE_TAG: DelGF_IPMPX_UserQueryResponse(_p); return; -*/ + /* + case GF_IPMPX_USER_QUERY_TAG: DelGF_IPMPX_UserQuery(_p); return; + case GF_IPMPX_USER_RESPONSE_TAG: DelGF_IPMPX_UserQueryResponse(_p); return; + */ case GF_IPMPX_TRUSTED_TOOL_TAG: { GF_IPMPX_TrustedTool *p = (GF_IPMPX_TrustedTool *)_p; @@ -1886,7 +1955,7 @@ void gf_ipmpx_data_del(GF_IPMPX_Data *_p) } case GF_IPMPX_GET_TOOLS_TAG: - default: + default: gf_free(_p); return; } @@ -1896,40 +1965,63 @@ GF_Err GF_IPMPX_ReadData(GF_BitStream *bs, GF_IPMPX_Data *_p, u32 read) { switch (_p->tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: return ReadGF_IPMPX_OpaqueData(bs, _p, read); - case GF_IPMPX_KEY_DATA_TAG: return ReadGF_IPMPX_KeyData(bs, _p, read); - case GF_IPMPX_SECURE_CONTAINER_TAG: return ReadGF_IPMPX_SecureContainer(bs, _p, read); - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: return ReadGF_IPMPX_AddToolNotificationListener(bs, _p, read); - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: return ReadGF_IPMPX_RemoveToolNotificationListener(bs, _p, read); - case GF_IPMPX_INIT_AUTHENTICATION_TAG: return ReadGF_IPMPX_InitAuthentication(bs, _p, read); - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: return ReadGF_IPMPX_MutualAuthentication(bs, _p, read); - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: return ReadGF_IPMPX_ParametricDescription(bs, _p, read); - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: return ReadGF_IPMPX_ToolParamCapabilitiesQuery(bs, _p, read); - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: return ReadGF_IPMPX_ToolParamCapabilitiesResponse(bs, _p, read); - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: return ReadGF_IPMPX_GetToolsResponse(bs, _p, read); - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: return ReadGF_IPMPX_GetToolContext(bs, _p, read); - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: return ReadGF_IPMPX_GetToolContextResponse(bs, _p, read); - case GF_IPMPX_CONNECT_TOOL_TAG: return ReadGF_IPMPX_ConnectTool(bs, _p, read); - case GF_IPMPX_DISCONNECT_TOOL_TAG: return ReadGF_IPMPX_DisconnectTool(bs, _p, read); - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: return ReadGF_IPMPX_NotifyToolEvent(bs, _p, read); - case GF_IPMPX_CAN_PROCESS_TAG: return ReadGF_IPMPX_CanProcess(bs, _p, read); - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: return ReadGF_IPMPX_TrustSecurityMetadata(bs, _p, read); - case GF_IPMPX_TOOL_API_CONFIG_TAG: return ReadGF_IPMPX_ToolAPI_Config(bs, _p, read); - case GF_IPMPX_ISMACRYP_TAG: return ReadGF_IPMPX_ISMACryp(bs, _p, read); - case GF_IPMPX_SEL_DEC_INIT_TAG: return ReadGF_IPMPX_SelectiveDecryptionInit(bs, _p, read); - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: + case GF_IPMPX_OPAQUE_DATA_TAG: + return ReadGF_IPMPX_OpaqueData(bs, _p, read); + case GF_IPMPX_KEY_DATA_TAG: + return ReadGF_IPMPX_KeyData(bs, _p, read); + case GF_IPMPX_SECURE_CONTAINER_TAG: + return ReadGF_IPMPX_SecureContainer(bs, _p, read); + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + return ReadGF_IPMPX_AddToolNotificationListener(bs, _p, read); + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + return ReadGF_IPMPX_RemoveToolNotificationListener(bs, _p, read); + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + return ReadGF_IPMPX_InitAuthentication(bs, _p, read); + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + return ReadGF_IPMPX_MutualAuthentication(bs, _p, read); + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + return ReadGF_IPMPX_ParametricDescription(bs, _p, read); + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + return ReadGF_IPMPX_ToolParamCapabilitiesQuery(bs, _p, read); + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + return ReadGF_IPMPX_ToolParamCapabilitiesResponse(bs, _p, read); + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + return ReadGF_IPMPX_GetToolsResponse(bs, _p, read); + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + return ReadGF_IPMPX_GetToolContext(bs, _p, read); + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + return ReadGF_IPMPX_GetToolContextResponse(bs, _p, read); + case GF_IPMPX_CONNECT_TOOL_TAG: + return ReadGF_IPMPX_ConnectTool(bs, _p, read); + case GF_IPMPX_DISCONNECT_TOOL_TAG: + return ReadGF_IPMPX_DisconnectTool(bs, _p, read); + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + return ReadGF_IPMPX_NotifyToolEvent(bs, _p, read); + case GF_IPMPX_CAN_PROCESS_TAG: + return ReadGF_IPMPX_CanProcess(bs, _p, read); + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + return ReadGF_IPMPX_TrustSecurityMetadata(bs, _p, read); + case GF_IPMPX_TOOL_API_CONFIG_TAG: + return ReadGF_IPMPX_ToolAPI_Config(bs, _p, read); + case GF_IPMPX_ISMACRYP_TAG: + return ReadGF_IPMPX_ISMACryp(bs, _p, read); + case GF_IPMPX_SEL_DEC_INIT_TAG: + return ReadGF_IPMPX_SelectiveDecryptionInit(bs, _p, read); + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: return ReadGF_IPMPX_WatermarkingInit(bs, _p, read); - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: return ReadGF_IPMPX_SendWatermark(bs, _p, read); -/* - case GF_IPMPX_USER_QUERY_TAG: return ReadGF_IPMPX_UserQuery(bs, _p, read); - case GF_IPMPX_USER_RESPONSE_TAG: return ReadGF_IPMPX_UserQueryResponse(bs, _p, read); -*/ - case GF_IPMPX_GET_TOOLS_TAG: return GF_OK; - default: return GF_BAD_PARAM; + /* + case GF_IPMPX_USER_QUERY_TAG: return ReadGF_IPMPX_UserQuery(bs, _p, read); + case GF_IPMPX_USER_RESPONSE_TAG: return ReadGF_IPMPX_UserQueryResponse(bs, _p, read); + */ + case GF_IPMPX_GET_TOOLS_TAG: + return GF_OK; + default: + return GF_BAD_PARAM; } } @@ -1937,40 +2029,63 @@ u32 gf_ipmpx_data_size(GF_IPMPX_Data *_p) { switch (_p->tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: return SizeGF_IPMPX_OpaqueData(_p); - case GF_IPMPX_KEY_DATA_TAG: return SizeGF_IPMPX_KeyData(_p); - case GF_IPMPX_SECURE_CONTAINER_TAG: return SizeGF_IPMPX_SecureContainer(_p); - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: return SizeGF_IPMPX_AddToolNotificationListener(_p); - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: return SizeGF_IPMPX_RemoveToolNotificationListener(_p); - case GF_IPMPX_INIT_AUTHENTICATION_TAG: return SizeGF_IPMPX_InitAuthentication(_p); - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: return SizeGF_IPMPX_MutualAuthentication(_p); - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: return SizeGF_IPMPX_ParametricDescription(_p); - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: return SizeGF_IPMPX_ToolParamCapabilitiesQuery(_p); - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: return SizeGF_IPMPX_ToolParamCapabilitiesResponse(_p); - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: return SizeGF_IPMPX_GetToolsResponse(_p); - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: return SizeGF_IPMPX_GetToolContext(_p); - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: return SizeGF_IPMPX_GetToolContextResponse(_p); - case GF_IPMPX_CONNECT_TOOL_TAG: return SizeGF_IPMPX_ConnectTool(_p); - case GF_IPMPX_DISCONNECT_TOOL_TAG: return SizeGF_IPMPX_DisconnectTool(_p); - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: return SizeGF_IPMPX_NotifyToolEvent(_p); - case GF_IPMPX_CAN_PROCESS_TAG: return SizeGF_IPMPX_CanProcess(_p); - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: return SizeGF_IPMPX_TrustSecurityMetadata(_p); - case GF_IPMPX_TOOL_API_CONFIG_TAG: return SizeGF_IPMPX_ToolAPI_Config(_p); - case GF_IPMPX_ISMACRYP_TAG: return SizeGF_IPMPX_ISMACryp(_p); - case GF_IPMPX_SEL_DEC_INIT_TAG: return SizeGF_IPMPX_SelectiveDecryptionInit(_p); - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: + case GF_IPMPX_OPAQUE_DATA_TAG: + return SizeGF_IPMPX_OpaqueData(_p); + case GF_IPMPX_KEY_DATA_TAG: + return SizeGF_IPMPX_KeyData(_p); + case GF_IPMPX_SECURE_CONTAINER_TAG: + return SizeGF_IPMPX_SecureContainer(_p); + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + return SizeGF_IPMPX_AddToolNotificationListener(_p); + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + return SizeGF_IPMPX_RemoveToolNotificationListener(_p); + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + return SizeGF_IPMPX_InitAuthentication(_p); + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + return SizeGF_IPMPX_MutualAuthentication(_p); + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + return SizeGF_IPMPX_ParametricDescription(_p); + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + return SizeGF_IPMPX_ToolParamCapabilitiesQuery(_p); + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + return SizeGF_IPMPX_ToolParamCapabilitiesResponse(_p); + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + return SizeGF_IPMPX_GetToolsResponse(_p); + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + return SizeGF_IPMPX_GetToolContext(_p); + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + return SizeGF_IPMPX_GetToolContextResponse(_p); + case GF_IPMPX_CONNECT_TOOL_TAG: + return SizeGF_IPMPX_ConnectTool(_p); + case GF_IPMPX_DISCONNECT_TOOL_TAG: + return SizeGF_IPMPX_DisconnectTool(_p); + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + return SizeGF_IPMPX_NotifyToolEvent(_p); + case GF_IPMPX_CAN_PROCESS_TAG: + return SizeGF_IPMPX_CanProcess(_p); + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + return SizeGF_IPMPX_TrustSecurityMetadata(_p); + case GF_IPMPX_TOOL_API_CONFIG_TAG: + return SizeGF_IPMPX_ToolAPI_Config(_p); + case GF_IPMPX_ISMACRYP_TAG: + return SizeGF_IPMPX_ISMACryp(_p); + case GF_IPMPX_SEL_DEC_INIT_TAG: + return SizeGF_IPMPX_SelectiveDecryptionInit(_p); + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: return SizeGF_IPMPX_WatermarkingInit(_p); - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: return SizeGF_IPMPX_SendWatermark(_p); -/* - case GF_IPMPX_USER_QUERY_TAG: return SizeGF_IPMPX_UserQuery(_p); - case GF_IPMPX_USER_RESPONSE_TAG: return SizeGF_IPMPX_UserQueryResponse(_p); -*/ - case GF_IPMPX_GET_TOOLS_TAG: return 0; - default: return GF_BAD_PARAM; + /* + case GF_IPMPX_USER_QUERY_TAG: return SizeGF_IPMPX_UserQuery(_p); + case GF_IPMPX_USER_RESPONSE_TAG: return SizeGF_IPMPX_UserQueryResponse(_p); + */ + case GF_IPMPX_GET_TOOLS_TAG: + return 0; + default: + return GF_BAD_PARAM; } } @@ -1982,40 +2097,63 @@ GF_Err gf_ipmpx_data_write(GF_BitStream *bs, GF_IPMPX_Data *_p) if (e) return e; switch (_p->tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: return WriteGF_IPMPX_OpaqueData(bs, _p); - case GF_IPMPX_KEY_DATA_TAG: return WriteGF_IPMPX_KeyData(bs, _p); - case GF_IPMPX_SECURE_CONTAINER_TAG: return WriteGF_IPMPX_SecureContainer(bs, _p); - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: return WriteGF_IPMPX_AddToolNotificationListener(bs, _p); - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: return WriteGF_IPMPX_RemoveToolNotificationListener(bs, _p); - case GF_IPMPX_INIT_AUTHENTICATION_TAG: return WriteGF_IPMPX_InitAuthentication(bs, _p); - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: return WriteGF_IPMPX_MutualAuthentication(bs, _p); - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: return WriteGF_IPMPX_ParametricDescription(bs, _p); - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: return WriteGF_IPMPX_ToolParamCapabilitiesQuery(bs, _p); - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: return WriteGF_IPMPX_ToolParamCapabilitiesResponse(bs, _p); - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: return WriteGF_IPMPX_GetToolsResponse(bs, _p); - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: return WriteGF_IPMPX_GetToolContext(bs, _p); - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: return WriteGF_IPMPX_GetToolContextResponse(bs, _p); - case GF_IPMPX_CONNECT_TOOL_TAG: return WriteGF_IPMPX_ConnectTool(bs, _p); - case GF_IPMPX_DISCONNECT_TOOL_TAG: return WriteGF_IPMPX_DisconnectTool(bs, _p); - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: return WriteGF_IPMPX_NotifyToolEvent(bs, _p); - case GF_IPMPX_CAN_PROCESS_TAG: return WriteGF_IPMPX_CanProcess(bs, _p); - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: return WriteGF_IPMPX_TrustSecurityMetadata(bs, _p); - case GF_IPMPX_TOOL_API_CONFIG_TAG: return WriteGF_IPMPX_ToolAPI_Config(bs, _p); - case GF_IPMPX_ISMACRYP_TAG: return WriteGF_IPMPX_ISMACryp(bs, _p); - case GF_IPMPX_SEL_DEC_INIT_TAG: return WriteGF_IPMPX_SelectiveDecryptionInit(bs, _p); - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: + case GF_IPMPX_OPAQUE_DATA_TAG: + return WriteGF_IPMPX_OpaqueData(bs, _p); + case GF_IPMPX_KEY_DATA_TAG: + return WriteGF_IPMPX_KeyData(bs, _p); + case GF_IPMPX_SECURE_CONTAINER_TAG: + return WriteGF_IPMPX_SecureContainer(bs, _p); + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + return WriteGF_IPMPX_AddToolNotificationListener(bs, _p); + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + return WriteGF_IPMPX_RemoveToolNotificationListener(bs, _p); + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + return WriteGF_IPMPX_InitAuthentication(bs, _p); + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + return WriteGF_IPMPX_MutualAuthentication(bs, _p); + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + return WriteGF_IPMPX_ParametricDescription(bs, _p); + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + return WriteGF_IPMPX_ToolParamCapabilitiesQuery(bs, _p); + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + return WriteGF_IPMPX_ToolParamCapabilitiesResponse(bs, _p); + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + return WriteGF_IPMPX_GetToolsResponse(bs, _p); + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + return WriteGF_IPMPX_GetToolContext(bs, _p); + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + return WriteGF_IPMPX_GetToolContextResponse(bs, _p); + case GF_IPMPX_CONNECT_TOOL_TAG: + return WriteGF_IPMPX_ConnectTool(bs, _p); + case GF_IPMPX_DISCONNECT_TOOL_TAG: + return WriteGF_IPMPX_DisconnectTool(bs, _p); + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + return WriteGF_IPMPX_NotifyToolEvent(bs, _p); + case GF_IPMPX_CAN_PROCESS_TAG: + return WriteGF_IPMPX_CanProcess(bs, _p); + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + return WriteGF_IPMPX_TrustSecurityMetadata(bs, _p); + case GF_IPMPX_TOOL_API_CONFIG_TAG: + return WriteGF_IPMPX_ToolAPI_Config(bs, _p); + case GF_IPMPX_ISMACRYP_TAG: + return WriteGF_IPMPX_ISMACryp(bs, _p); + case GF_IPMPX_SEL_DEC_INIT_TAG: + return WriteGF_IPMPX_SelectiveDecryptionInit(bs, _p); + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: return WriteGF_IPMPX_WatermarkingInit(bs, _p); - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: return WriteGF_IPMPX_SendWatermark(bs, _p); -/* - case GF_IPMPX_USER_QUERY_TAG: return WriteGF_IPMPX_UserQuery(bs, _p); - case GF_IPMPX_USER_RESPONSE_TAG: return WriteGF_IPMPX_UserQueryResponse(bs, _p); -*/ - case GF_IPMPX_GET_TOOLS_TAG: return GF_OK; - default: return GF_BAD_PARAM; + /* + case GF_IPMPX_USER_QUERY_TAG: return WriteGF_IPMPX_UserQuery(bs, _p); + case GF_IPMPX_USER_RESPONSE_TAG: return WriteGF_IPMPX_UserQueryResponse(bs, _p); + */ + case GF_IPMPX_GET_TOOLS_TAG: + return GF_OK; + default: + return GF_BAD_PARAM; } } diff --git a/src/odf/ipmpx_dump.c b/src/odf/ipmpx_dump.c index 8755ba9..9ea8907 100644 --- a/src/odf/ipmpx_dump.c +++ b/src/odf/ipmpx_dump.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,7 +36,7 @@ for (z=0; zagreedAlgorithms); indent++; @@ -774,7 +774,7 @@ GF_Err gf_ipmpx_dump_SelectiveDecryptionInit(GF_IPMPX_Data *_p, FILE *trace, u32 DumpInt(trace, "keySize", sb->keySize, indent, XMTDump); } EndAttributes(trace, XMTDump, 1); - if (sb->Stream_Cipher_Specific_Init_Info) + if (sb->Stream_Cipher_Specific_Init_Info) gf_ipmpx_dump_ByteArray(sb->Stream_Cipher_Specific_Init_Info, "StreamCipher", trace, indent, XMTDump); indent--; @@ -797,7 +797,7 @@ GF_Err gf_ipmpx_dump_SelectiveDecryptionInit(GF_IPMPX_Data *_p, FILE *trace, u32 DumpInt(trace, "buf", sf->buf, indent, XMTDump); if (sf->mappingTable) DumpData_16(trace, "mappingTable", sf->mappingTable, sf->mappingTableSize, indent, XMTDump); EndAttributes(trace, XMTDump, 1); - if (sf->shuffleSpecificInfo) + if (sf->shuffleSpecificInfo) gf_ipmpx_dump_ByteArray(sf->shuffleSpecificInfo, "shuffleSpecificInfo", trace, indent, XMTDump); indent--; @@ -832,40 +832,63 @@ GF_Err gf_ipmpx_dump_data(GF_IPMPX_Data *_p, FILE *trace, u32 indent, Bool XMTDu { switch (_p->tag) { case GF_IPMPX_RIGHTS_DATA_TAG: - case GF_IPMPX_OPAQUE_DATA_TAG: return gf_ipmpx_dump_OpaqueData(_p, trace, indent, XMTDump); - case GF_IPMPX_KEY_DATA_TAG: return gf_ipmpx_dump_KeyData(_p, trace, indent, XMTDump); - case GF_IPMPX_SECURE_CONTAINER_TAG: return gf_ipmpx_dump_SecureContainer(_p, trace, indent, XMTDump); - case GF_IPMPX_INIT_AUTHENTICATION_TAG: return gf_ipmpx_dump_InitAuthentication(_p, trace, indent, XMTDump); - case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: return gf_ipmpx_dump_TrustSecurityMetadata(_p, trace, indent, XMTDump); - case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: return gf_ipmpx_dump_MutualAuthentication(_p, trace, indent, XMTDump); - case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: return gf_ipmpx_dump_GetToolsResponse(_p, trace, indent, XMTDump); - case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: return gf_ipmpx_dump_ParametricDescription(_p, trace, indent, XMTDump); - case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: return gf_ipmpx_dump_ToolParamCapabilitiesQuery(_p, trace, indent, XMTDump); - case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: return gf_ipmpx_dump_ToolParamCapabilitiesResponse(_p, trace, indent, XMTDump); - case GF_IPMPX_GET_TOOL_CONTEXT_TAG: return gf_ipmpx_dump_GetToolContext(_p, trace, indent, XMTDump); - case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: return gf_ipmpx_dump_GetToolContextResponse(_p, trace, indent, XMTDump); - case GF_IPMPX_CONNECT_TOOL_TAG: return gf_ipmpx_dump_ConnectTool(_p, trace, indent, XMTDump); - case GF_IPMPX_DISCONNECT_TOOL_TAG: return gf_ipmpx_dump_DisconnectTool(_p, trace, indent, XMTDump); - case GF_IPMPX_ADD_TOOL_LISTENER_TAG: return gf_ipmpx_dump_AddToolNotificationListener(_p, trace, indent, XMTDump); - case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: return gf_ipmpx_dump_RemoveToolNotificationListener(_p, trace, indent, XMTDump); - case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: return gf_ipmpx_dump_NotifyToolEvent(_p, trace, indent, XMTDump); - case GF_IPMPX_CAN_PROCESS_TAG: return gf_ipmpx_dump_CanProcess(_p, trace, indent, XMTDump); - case GF_IPMPX_ISMACRYP_TAG: return gf_ipmpx_dump_ISMACryp(_p, trace, indent, XMTDump); - case GF_IPMPX_TOOL_API_CONFIG_TAG: return gf_ipmpx_dump_ToolAPI_Config(_p, trace, indent, XMTDump); - case GF_IPMPX_AUDIO_WM_INIT_TAG: - case GF_IPMPX_VIDEO_WM_INIT_TAG: + case GF_IPMPX_OPAQUE_DATA_TAG: + return gf_ipmpx_dump_OpaqueData(_p, trace, indent, XMTDump); + case GF_IPMPX_KEY_DATA_TAG: + return gf_ipmpx_dump_KeyData(_p, trace, indent, XMTDump); + case GF_IPMPX_SECURE_CONTAINER_TAG: + return gf_ipmpx_dump_SecureContainer(_p, trace, indent, XMTDump); + case GF_IPMPX_INIT_AUTHENTICATION_TAG: + return gf_ipmpx_dump_InitAuthentication(_p, trace, indent, XMTDump); + case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: + return gf_ipmpx_dump_TrustSecurityMetadata(_p, trace, indent, XMTDump); + case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: + return gf_ipmpx_dump_MutualAuthentication(_p, trace, indent, XMTDump); + case GF_IPMPX_GET_TOOLS_RESPONSE_TAG: + return gf_ipmpx_dump_GetToolsResponse(_p, trace, indent, XMTDump); + case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: + return gf_ipmpx_dump_ParametricDescription(_p, trace, indent, XMTDump); + case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: + return gf_ipmpx_dump_ToolParamCapabilitiesQuery(_p, trace, indent, XMTDump); + case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: + return gf_ipmpx_dump_ToolParamCapabilitiesResponse(_p, trace, indent, XMTDump); + case GF_IPMPX_GET_TOOL_CONTEXT_TAG: + return gf_ipmpx_dump_GetToolContext(_p, trace, indent, XMTDump); + case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: + return gf_ipmpx_dump_GetToolContextResponse(_p, trace, indent, XMTDump); + case GF_IPMPX_CONNECT_TOOL_TAG: + return gf_ipmpx_dump_ConnectTool(_p, trace, indent, XMTDump); + case GF_IPMPX_DISCONNECT_TOOL_TAG: + return gf_ipmpx_dump_DisconnectTool(_p, trace, indent, XMTDump); + case GF_IPMPX_ADD_TOOL_LISTENER_TAG: + return gf_ipmpx_dump_AddToolNotificationListener(_p, trace, indent, XMTDump); + case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: + return gf_ipmpx_dump_RemoveToolNotificationListener(_p, trace, indent, XMTDump); + case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: + return gf_ipmpx_dump_NotifyToolEvent(_p, trace, indent, XMTDump); + case GF_IPMPX_CAN_PROCESS_TAG: + return gf_ipmpx_dump_CanProcess(_p, trace, indent, XMTDump); + case GF_IPMPX_ISMACRYP_TAG: + return gf_ipmpx_dump_ISMACryp(_p, trace, indent, XMTDump); + case GF_IPMPX_TOOL_API_CONFIG_TAG: + return gf_ipmpx_dump_ToolAPI_Config(_p, trace, indent, XMTDump); + case GF_IPMPX_AUDIO_WM_INIT_TAG: + case GF_IPMPX_VIDEO_WM_INIT_TAG: return gf_ipmpx_dump_WatermarkingInit(_p, trace, indent, XMTDump); - case GF_IPMPX_AUDIO_WM_SEND_TAG: - case GF_IPMPX_VIDEO_WM_SEND_TAG: + case GF_IPMPX_AUDIO_WM_SEND_TAG: + case GF_IPMPX_VIDEO_WM_SEND_TAG: return gf_ipmpx_dump_SendWatermark(_p, trace, indent, XMTDump); - case GF_IPMPX_SEL_DEC_INIT_TAG: return gf_ipmpx_dump_SelectiveDecryptionInit(_p, trace, indent, XMTDump); - -/* - case GF_IPMPX_USER_QUERY_TAG: return gf_ipmpx_dump_UserQuery(_p, trace, indent, XMTDump); - case GF_IPMPX_USER_RESPONSE_TAG: return gf_ipmpx_dump_UserQueryResponse(_p, trace, indent, XMTDump); -*/ - case GF_IPMPX_GET_TOOLS_TAG: return GF_BAD_PARAM; - default: return GF_BAD_PARAM; + case GF_IPMPX_SEL_DEC_INIT_TAG: + return gf_ipmpx_dump_SelectiveDecryptionInit(_p, trace, indent, XMTDump); + + /* + case GF_IPMPX_USER_QUERY_TAG: return gf_ipmpx_dump_UserQuery(_p, trace, indent, XMTDump); + case GF_IPMPX_USER_RESPONSE_TAG: return gf_ipmpx_dump_UserQueryResponse(_p, trace, indent, XMTDump); + */ + case GF_IPMPX_GET_TOOLS_TAG: + return GF_BAD_PARAM; + default: + return GF_BAD_PARAM; } } diff --git a/src/odf/ipmpx_parse.c b/src/odf/ipmpx_parse.c index 3c55a2e..4d5e9e4 100644 --- a/src/odf/ipmpx_parse.c +++ b/src/odf/ipmpx_parse.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -98,7 +98,7 @@ u32 gf_ipmpx_get_field_type(GF_IPMPX_Data *p, char *fieldName) if (!stricmp(fieldName, "candidateAlgorithms") || !stricmp(fieldName, "agreedAlgorithms")) return GF_ODF_FT_IPMPX_LIST; else if (!stricmp(fieldName, "certificates")) return GF_ODF_FT_IPMPX_BA_LIST; else if (!stricmp(fieldName, "publicKey") || !stricmp(fieldName, "trustData")) return GF_ODF_FT_IPMPX; - else if (!stricmp(fieldName, "authCodes") || !stricmp(fieldName, "opaque") || !stricmp(fieldName, "AuthenticationData")) + else if (!stricmp(fieldName, "authCodes") || !stricmp(fieldName, "opaque") || !stricmp(fieldName, "AuthenticationData")) return GF_ODF_FT_IPMPX_BA; break; case GF_IPMPX_ALGORITHM_DESCRIPTOR_TAG: @@ -111,7 +111,7 @@ u32 gf_ipmpx_get_field_type(GF_IPMPX_Data *p, char *fieldName) if (!stricmp(fieldName, "descriptionComment")) return GF_ODF_FT_IPMPX_BA; else if (!stricmp(fieldName, "descriptions")) return GF_ODF_FT_IPMPX_LIST; break; - case GF_IPMPX_PARAM_DESCRIPTOR_ITEM_TAG: + case GF_IPMPX_PARAM_DESCRIPTOR_ITEM_TAG: /*all is IPMPX data*/ return GF_ODF_FT_IPMPX_BA; case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: @@ -241,7 +241,10 @@ GF_Err GF_IPMPX_ParseEventType(char *val, u8 *eventType, u8 *eventTypeCount) j=0; for (i=0; istartDTS) - else if (!stricmp(fieldName, "startPacketID")) GET_U32(p->startPacketID) - else if (!stricmp(fieldName, "expireDTS")) GET_U32(p->expireDTS) - else if (!stricmp(fieldName, "expirePacketID")) GET_U32(p->expirePacketID) - } - break; + else if (!stricmp(fieldName, "startPacketID")) GET_U32(p->startPacketID) + else if (!stricmp(fieldName, "expireDTS")) GET_U32(p->expireDTS) + else if (!stricmp(fieldName, "expirePacketID")) GET_U32(p->expirePacketID) + } + break; case GF_IPMPX_SECURE_CONTAINER_TAG: { GF_IPMPX_SecureContainer*p = (GF_IPMPX_SecureContainer*)_p; if (!stricmp(fieldName, "isMACEncrypted")) GET_BOOL(p->isMACEncrypted) - } - break; + } + break; case GF_IPMPX_INIT_AUTHENTICATION_TAG: { GF_IPMPX_InitAuthentication *p = (GF_IPMPX_InitAuthentication*)_p; if (!stricmp(fieldName, "Context")) GET_U32(p->Context) - else if (!stricmp(fieldName, "AuthType")) GET_U8(p->AuthType) - } - break; + else if (!stricmp(fieldName, "AuthType")) GET_U8(p->AuthType) + } + break; case GF_IPMPX_TRUSTED_TOOL_TAG: { GF_IPMPX_TrustedTool *p = (GF_IPMPX_TrustedTool*)_p; - if (!stricmp(fieldName, "toolID")) { GF_IPMPX_ParseBin128(val, &p->toolID); ret = 1; } - else if (!stricmp(fieldName, "AuditDate")) { GF_IPMPX_ParseDate(val, &p->AuditDate); ret = 1; } + if (!stricmp(fieldName, "toolID")) { + GF_IPMPX_ParseBin128(val, &p->toolID); + ret = 1; + } + else if (!stricmp(fieldName, "AuditDate")) { + GF_IPMPX_ParseDate(val, &p->AuditDate); + ret = 1; + } } - break; + break; case GF_IPMPX_TRUST_SPECIFICATION_TAG: { GF_IPMPX_TrustSpecification *p = (GF_IPMPX_TrustSpecification*)_p; - if (!stricmp(fieldName, "startDate")) { GF_IPMPX_ParseDate(val, &p->startDate); ret = 1; } + if (!stricmp(fieldName, "startDate")) { + GF_IPMPX_ParseDate(val, &p->startDate); + ret = 1; + } else if (!stricmp(fieldName, "attackerProfile")) GET_U8(p->attackerProfile) - else if (!stricmp(fieldName, "trustedDuration")) GET_U32(p->trustedDuration) - } - break; + else if (!stricmp(fieldName, "trustedDuration")) GET_U32(p->trustedDuration) + } + break; case GF_IPMPX_ALGORITHM_DESCRIPTOR_TAG: { GF_IPMPX_AUTH_AlgorithmDescriptor *p = (GF_IPMPX_AUTH_AlgorithmDescriptor *)_p; if (!stricmp(fieldName, "regAlgoID")) GET_U16(p->regAlgoID) - } - break; + } + break; case GF_IPMPX_KEY_DESCRIPTOR_TAG: { GF_IPMPX_AUTH_KeyDescriptor *p = (GF_IPMPX_AUTH_KeyDescriptor *)_p; if (!stricmp(fieldName, "keyBody")) { u32 s; GF_IPMPX_ParseBinData(val, &p->keyBody, &s); - p->keyBodyLength = s; + p->keyBodyLength = s; ret = 1; } } - break; + break; case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: { GF_IPMPX_ParametricDescription*p = (GF_IPMPX_ParametricDescription*)_p; if (!stricmp(fieldName, "majorVersion")) GET_U8(p->majorVersion) - else if (!stricmp(fieldName, "minorVersion")) GET_U8(p->minorVersion) - } - break; + else if (!stricmp(fieldName, "minorVersion")) GET_U8(p->minorVersion) + } + break; case GF_IPMPX_PARAMETRIC_CAPS_RESPONSE_TAG: { GF_IPMPX_ToolParamCapabilitiesResponse*p = (GF_IPMPX_ToolParamCapabilitiesResponse*)_p; if (!stricmp(fieldName, "capabilitiesSupported")) GET_BOOL(p->capabilitiesSupported) - } - break; + } + break; case GF_IPMPX_DISCONNECT_TOOL_TAG: { GF_IPMPX_DisconnectTool*p = (GF_IPMPX_DisconnectTool*)_p; if (!stricmp(fieldName, "IPMP_ToolContextID")) GET_U16(p->IPMP_ToolContextID) - } - break; + } + break; case GF_IPMPX_GET_TOOL_CONTEXT_TAG: { GF_IPMPX_GetToolContext*p = (GF_IPMPX_GetToolContext*)_p; if (!stricmp(fieldName, "scope")) GET_U8(p->scope) - else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) GET_U16(p->IPMP_DescriptorIDEx) - } - break; + else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) GET_U16(p->IPMP_DescriptorIDEx) + } + break; case GF_IPMPX_GET_TOOL_CONTEXT_RESPONSE_TAG: { GF_IPMPX_GetToolContextResponse*p = (GF_IPMPX_GetToolContextResponse*)_p; if (!stricmp(fieldName, "OD_ID")) GET_U16(p->OD_ID) - else if (!stricmp(fieldName, "ESD_ID")) GET_U16(p->ESD_ID) - else if (!stricmp(fieldName, "IPMP_ToolContextID")) GET_U16(p->IPMP_ToolContextID) - } - break; + else if (!stricmp(fieldName, "ESD_ID")) GET_U16(p->ESD_ID) + else if (!stricmp(fieldName, "IPMP_ToolContextID")) GET_U16(p->IPMP_ToolContextID) + } + break; case GF_IPMPX_ADD_TOOL_LISTENER_TAG: { GF_IPMPX_AddToolNotificationListener*p = (GF_IPMPX_AddToolNotificationListener*)_p; if (!stricmp(fieldName, "eventType")) return GF_IPMPX_ParseEventType(val, p->eventType, &p->eventTypeCount); else if (!stricmp(fieldName, "scope")) GET_U8(p->scope) - } - break; + } + break; case GF_IPMPX_REMOVE_TOOL_LISTENER_TAG: { GF_IPMPX_RemoveToolNotificationListener*p = (GF_IPMPX_RemoveToolNotificationListener*)_p; if (!stricmp(fieldName, "eventType")) return GF_IPMPX_ParseEventType(val, p->eventType, &p->eventTypeCount); } - break; + break; case GF_IPMPX_NOTIFY_TOOL_EVENT_TAG: { GF_IPMPX_NotifyToolEvent*p = (GF_IPMPX_NotifyToolEvent*)_p; if (!stricmp(fieldName, "OD_ID")) GET_U16(p->OD_ID) - else if (!stricmp(fieldName, "ESD_ID")) GET_U16(p->ESD_ID) - else if (!stricmp(fieldName, "IPMP_ToolContextID")) GET_U16(p->IPMP_ToolContextID) - else if (!stricmp(fieldName, "eventType")) GET_U8(p->eventType) - } - break; + else if (!stricmp(fieldName, "ESD_ID")) GET_U16(p->ESD_ID) + else if (!stricmp(fieldName, "IPMP_ToolContextID")) GET_U16(p->IPMP_ToolContextID) + else if (!stricmp(fieldName, "eventType")) GET_U8(p->eventType) + } + break; case GF_IPMPX_CAN_PROCESS_TAG: { GF_IPMPX_CanProcess*p = (GF_IPMPX_CanProcess*)_p; if (!stricmp(fieldName, "canProcess")) GET_BOOL(p->canProcess) - } - break; + } + break; case GF_IPMPX_TOOL_API_CONFIG_TAG: { GF_IPMPX_ToolAPI_Config*p = (GF_IPMPX_ToolAPI_Config*)_p; if (!stricmp(fieldName, "Instantiation_API_ID")) GET_U32(p->Instantiation_API_ID) - else if (!stricmp(fieldName, "Messaging_API_ID")) GET_U32(p->Messaging_API_ID) - } - break; + else if (!stricmp(fieldName, "Messaging_API_ID")) GET_U32(p->Messaging_API_ID) + } + break; case GF_IPMPX_AUDIO_WM_INIT_TAG: case GF_IPMPX_VIDEO_WM_INIT_TAG: { GF_IPMPX_WatermarkingInit *p = (GF_IPMPX_WatermarkingInit*)_p; if (!stricmp(fieldName, "inputFormat")) GET_U8(p->inputFormat) - else if (!stricmp(fieldName, "requiredOp")) GET_U8(p->requiredOp) - else if (!stricmp(fieldName, "nChannels")) GET_U8(p->nChannels) - else if (!stricmp(fieldName, "bitPerSample")) GET_U8(p->bitPerSample) - else if (!stricmp(fieldName, "frequency")) GET_U32(p->frequency) - else if (!stricmp(fieldName, "frame_horizontal_size")) GET_U16(p->frame_horizontal_size) - else if (!stricmp(fieldName, "frame_vertical_size")) GET_U16(p->frame_vertical_size) - else if (!stricmp(fieldName, "chroma_format")) GET_U8(p->chroma_format) - else if (!stricmp(fieldName, "wmPayload")) { ret=1; GF_IPMPX_ParseBinData(val, &p->wmPayload, &p->wmPayloadLen); } - else if (!stricmp(fieldName, "opaqueData")) { ret=1; GF_IPMPX_ParseBinData(val, &p->opaqueData, &p->opaqueDataSize); } - else if (!stricmp(fieldName, "wmRecipientId")) GET_U16(p->wmRecipientId) - } - break; + else if (!stricmp(fieldName, "requiredOp")) GET_U8(p->requiredOp) + else if (!stricmp(fieldName, "nChannels")) GET_U8(p->nChannels) + else if (!stricmp(fieldName, "bitPerSample")) GET_U8(p->bitPerSample) + else if (!stricmp(fieldName, "frequency")) GET_U32(p->frequency) + else if (!stricmp(fieldName, "frame_horizontal_size")) GET_U16(p->frame_horizontal_size) + else if (!stricmp(fieldName, "frame_vertical_size")) GET_U16(p->frame_vertical_size) + else if (!stricmp(fieldName, "chroma_format")) GET_U8(p->chroma_format) + else if (!stricmp(fieldName, "wmPayload")) { + ret=1; + GF_IPMPX_ParseBinData(val, &p->wmPayload, &p->wmPayloadLen); + } + else if (!stricmp(fieldName, "opaqueData")) { + ret=1; + GF_IPMPX_ParseBinData(val, &p->opaqueData, &p->opaqueDataSize); + } + else if (!stricmp(fieldName, "wmRecipientId")) GET_U16(p->wmRecipientId) + } + break; case GF_IPMPX_AUDIO_WM_SEND_TAG: case GF_IPMPX_VIDEO_WM_SEND_TAG: { GF_IPMPX_SendWatermark *p = (GF_IPMPX_SendWatermark*)_p; if (!stricmp(fieldName, "wm_status")) GET_U8(p->wm_status) - else if (!stricmp(fieldName, "compression_status")) GET_U8(p->compression_status) - } - break; + else if (!stricmp(fieldName, "compression_status")) GET_U8(p->compression_status) + } + break; case GF_IPMPX_SEL_DEC_INIT_TAG: { GF_IPMPX_SelectiveDecryptionInit*p = (GF_IPMPX_SelectiveDecryptionInit*)_p; if (!stricmp(fieldName, "mediaTypeExtension")) GET_U8(p->mediaTypeExtension) - else if (!stricmp(fieldName, "mediaTypeExtension")) GET_U8(p->mediaTypeExtension) - else if (!stricmp(fieldName, "mediaTypeIndication")) GET_U8(p->mediaTypeIndication) - else if (!stricmp(fieldName, "profileLevelIndication")) GET_U8(p->profileLevelIndication) - else if (!stricmp(fieldName, "compliance")) GET_U8(p->compliance) - else if (!stricmp(fieldName, "RLE_Data")) { ret=1; gf_ipmpx_data_parse_16(val, &p->RLE_Data, &p->RLE_DataLength); } - } - break; + else if (!stricmp(fieldName, "mediaTypeExtension")) GET_U8(p->mediaTypeExtension) + else if (!stricmp(fieldName, "mediaTypeIndication")) GET_U8(p->mediaTypeIndication) + else if (!stricmp(fieldName, "profileLevelIndication")) GET_U8(p->profileLevelIndication) + else if (!stricmp(fieldName, "compliance")) GET_U8(p->compliance) + else if (!stricmp(fieldName, "RLE_Data")) { + ret=1; + gf_ipmpx_data_parse_16(val, &p->RLE_Data, &p->RLE_DataLength); + } + } + break; case GF_IPMPX_SEL_ENC_BUFFER_TAG: { GF_IPMPX_SelEncBuffer*p = (GF_IPMPX_SelEncBuffer*)_p; - if (!stricmp(fieldName, "cipher_Id")) { GF_IPMPX_ParseBin128(val, &p->cipher_Id); ret = 1; } + if (!stricmp(fieldName, "cipher_Id")) { + GF_IPMPX_ParseBin128(val, &p->cipher_Id); + ret = 1; + } else if (!stricmp(fieldName, "syncBoundary")) GET_U8(p->syncBoundary) - else if (!stricmp(fieldName, "mode")) GET_U8(p->mode) - else if (!stricmp(fieldName, "blockSize")) GET_U16(p->blockSize) - else if (!stricmp(fieldName, "keySize")) GET_U16(p->keySize) - } - break; + else if (!stricmp(fieldName, "mode")) GET_U8(p->mode) + else if (!stricmp(fieldName, "blockSize")) GET_U16(p->blockSize) + else if (!stricmp(fieldName, "keySize")) GET_U16(p->keySize) + } + break; case GF_IPMPX_SEL_ENC_FIELD_TAG: { GF_IPMPX_SelEncField*p = (GF_IPMPX_SelEncField*)_p; if (!stricmp(fieldName, "field_Id")) GET_U8(p->field_Id) - else if (!stricmp(fieldName, "field_Scope")) GET_U8(p->field_Scope) - else if (!stricmp(fieldName, "buf")) GET_U8(p->buf) - else if (!stricmp(fieldName, "mappingTable")) { ret=1; gf_ipmpx_data_parse_16(val, &p->mappingTable, &p->mappingTableSize); } - } - break; + else if (!stricmp(fieldName, "field_Scope")) GET_U8(p->field_Scope) + else if (!stricmp(fieldName, "buf")) GET_U8(p->buf) + else if (!stricmp(fieldName, "mappingTable")) { + ret=1; + gf_ipmpx_data_parse_16(val, &p->mappingTable, &p->mappingTableSize); + } + } + break; case GF_IPMPX_ISMACRYP_TAG: { GF_IPMPX_ISMACryp*p = (GF_IPMPX_ISMACryp*)_p; if (!stricmp(fieldName, "crypto_suite")) GET_U8(p->cryptoSuite) - else if (!stricmp(fieldName, "IV_length")) GET_U8(p->IV_length) - else if (!stricmp(fieldName, "selective_encryption")) GET_BOOL(p->use_selective_encryption) - else if (!stricmp(fieldName, "key_indicator_length")) GET_U8(p->key_indicator_length) - } - break; + else if (!stricmp(fieldName, "IV_length")) GET_U8(p->IV_length) + else if (!stricmp(fieldName, "selective_encryption")) GET_BOOL(p->use_selective_encryption) + else if (!stricmp(fieldName, "key_indicator_length")) GET_U8(p->key_indicator_length) + } + break; } return ret ? GF_OK : GF_BAD_PARAM; } @@ -526,7 +568,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * p->protectedMsg = sp; return GF_OK; } - break; + break; case GF_IPMPX_TRUST_SECURITY_METADATA_TAG: { GF_IPMPX_TrustSecurityMetadata *p = (GF_IPMPX_TrustSecurityMetadata*)_p; @@ -534,7 +576,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * gf_list_add(p->TrustedTools, sp); return GF_OK; } - break; + break; case GF_IPMPX_TRUSTED_TOOL_TAG: { GF_IPMPX_TrustedTool *p = (GF_IPMPX_TrustedTool *)_p; @@ -542,7 +584,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * gf_list_add(p->trustSpecifications, sp); return GF_OK; } - break; + break; case GF_IPMPX_MUTUAL_AUTHENTICATION_TAG: { GF_IPMPX_MutualAuthentication *p = (GF_IPMPX_MutualAuthentication *)_p; @@ -571,7 +613,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * return GF_BAD_PARAM; } } - break; + break; case GF_IPMPX_PARAMETRIC_DESCRIPTION_TAG: { GF_IPMPX_ParametricDescription*p = (GF_IPMPX_ParametricDescription*)_p; @@ -579,7 +621,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * if (!stricmp(fieldName, "descriptions")) return gf_list_add(p->descriptions, sp); else return GF_BAD_PARAM; } - break; + break; case GF_IPMPX_PARAMETRIC_CAPS_QUERY_TAG: { GF_IPMPX_ToolParamCapabilitiesQuery*p = (GF_IPMPX_ToolParamCapabilitiesQuery*)_p; @@ -589,7 +631,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * p->description = (GF_IPMPX_ParametricDescription*)sp; return GF_OK; } - break; + break; case GF_IPMPX_SEL_DEC_INIT_TAG: { GF_IPMPX_SelectiveDecryptionInit*p = (GF_IPMPX_SelectiveDecryptionInit*)_p; @@ -598,7 +640,7 @@ GF_Err gf_ipmpx_set_sub_data(GF_IPMPX_Data *_p, char *fieldName, GF_IPMPX_Data * else if (sp->tag==GF_IPMPX_SEL_ENC_FIELD_TAG) return gf_list_add(p->SelEncFields, sp); else return GF_BAD_PARAM; } - break; + break; } return GF_BAD_PARAM; } diff --git a/src/odf/oci_codec.c b/src/odf/oci_codec.c index 5b6cd35..c2c803b 100644 --- a/src/odf/oci_codec.c +++ b/src/odf/oci_codec.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -50,7 +50,7 @@ struct __tag_oci_event GF_List *OCIDescriptors; }; -struct __tag_oci_codec +struct __tag_oci_codec { //events GF_List *OCIEvents; @@ -85,7 +85,7 @@ void gf_oci_event_del(OCIEvent *event) gf_odf_delete_descriptor(desc); } gf_list_del(event->OCIDescriptors); - gf_free(event); + gf_free(event); } GF_EXPORT @@ -127,7 +127,7 @@ GF_Err gf_oci_event_add_desc(OCIEvent *event, GF_Descriptor *oci_desc) { if (!event || !oci_desc) return GF_BAD_PARAM; if (!OCI_IsOCIDesc(oci_desc)) return GF_ODF_INVALID_DESCRIPTOR; - + gf_list_add(event->OCIDescriptors, oci_desc); return GF_OK; } @@ -143,7 +143,7 @@ GF_Err gf_oci_event_get_id(OCIEvent *event, u16 *ID) GF_EXPORT GF_Err gf_oci_event_get_start_time(OCIEvent *event, u8 *Hours, u8 *Minutes, u8 *Seconds, u8 *HundredSeconds, u8 *IsAbsoluteTime) { - if (!event || !Hours || !Minutes || !Seconds || !HundredSeconds || !IsAbsoluteTime) + if (!event || !Hours || !Minutes || !Seconds || !HundredSeconds || !IsAbsoluteTime) return GF_BAD_PARAM; *IsAbsoluteTime = event->AbsoluteTimeFlag; @@ -157,7 +157,7 @@ GF_Err gf_oci_event_get_start_time(OCIEvent *event, u8 *Hours, u8 *Minutes, u8 * GF_EXPORT GF_Err gf_oci_event_get_duration(OCIEvent *event, u8 *Hours, u8 *Minutes, u8 *Seconds, u8 *HundredSeconds) { - if (!event || !Hours || !Minutes || !Seconds || !HundredSeconds) + if (!event || !Hours || !Minutes || !Seconds || !HundredSeconds) return GF_BAD_PARAM; *Hours = event->duration[0]; @@ -232,16 +232,16 @@ GF_Err WriteSevenBitLength(GF_BitStream *bs, u32 size) unsigned char vals[4]; if (!bs || !size) return GF_BAD_PARAM; - + length = size; vals[3] = (unsigned char) (length & 0x7f); length >>= 7; - vals[2] = (unsigned char) ((length & 0x7f) | 0x80); + vals[2] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; - vals[1] = (unsigned char) ((length & 0x7f) | 0x80); + vals[1] = (unsigned char) ((length & 0x7f) | 0x80); length >>= 7; vals[0] = (unsigned char) ((length & 0x7f) | 0x80); - + if (size < 0x00000080) { gf_bs_write_int(bs, vals[3], 8); } else if (size < 0x00004000) { @@ -269,7 +269,7 @@ GF_Err gf_oci_codec_encode(OCICodec *codec, char **outAU, u32 *au_length) u32 i, size, desc_size; GF_Err e; OCIEvent *ev; - + if (!codec || !codec->Mode || *outAU) return GF_BAD_PARAM; bs = NULL; @@ -300,7 +300,7 @@ GF_Err gf_oci_codec_encode(OCICodec *codec, char **outAU, u32 *au_length) gf_bs_write_int(bs, ev->AbsoluteTimeFlag, 1); gf_bs_write_data(bs, ev->StartingTime, 4); gf_bs_write_data(bs, ev->duration, 4); - + e = gf_odf_write_descriptor_list(bs, ev->OCIDescriptors); gf_oci_event_del(ev); if (e) goto err_exit; @@ -330,7 +330,7 @@ GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length) OCIEvent *ev; GF_BitStream *bs; u32 size, hdrS, desc_size, tot_size, tmp_size, val; - GF_Descriptor *tmp; + GF_Descriptor *tmp; GF_Err e; //must be decoder @@ -346,7 +346,7 @@ GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length) e = GF_OUT_OF_MEM; goto err_exit; } - + //FIX IM1 gf_bs_read_int(bs, 8); @@ -359,7 +359,7 @@ GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length) size <<= 7; size |= val & 0x7F; } while ( val & 0x80 ); - + //parse event vars ev->EventID = gf_bs_read_int(bs, 15); ev->AbsoluteTimeFlag = gf_bs_read_int(bs, 1); @@ -380,7 +380,7 @@ GF_Err gf_oci_codec_decode(OCICodec *codec, char *au, u32 au_length) gf_list_add(ev->OCIDescriptors, tmp); desc_size += tmp_size + gf_odf_size_field_size(tmp_size); } - + if (desc_size != size - 10) { e = GF_CORRUPTED_DATA; goto err_exit; diff --git a/src/odf/odf_code.c b/src/odf/odf_code.c index f0d2337..8ca9aaf 100644 --- a/src/odf/odf_code.c +++ b/src/odf/odf_code.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -98,7 +98,7 @@ GF_Err gf_odf_write_url_string(GF_BitStream *bs, char *string) if (!string) { gf_bs_write_int(bs, 0, 8); return GF_OK; - } + } len = (u32) strlen(string); if (len > 255) { gf_bs_write_int(bs, 0, 8); @@ -225,7 +225,7 @@ GF_Err AddDescriptorToESD(GF_ESD *esd, GF_Descriptor *desc) default: if ( (desc->tag >= GF_ODF_EXT_BEGIN_TAG) && - (desc->tag <= GF_ODF_EXT_END_TAG) ) { + (desc->tag <= GF_ODF_EXT_END_TAG) ) { return gf_list_add(esd->extensionDescriptors, desc); } gf_odf_delete_descriptor(desc); @@ -250,7 +250,7 @@ GF_Err gf_odf_read_esd(GF_BitStream *bs, GF_ESD *esd, u32 DescSize) ocrflag = gf_bs_read_int(bs, 1); esd->streamPriority = gf_bs_read_int(bs, 5); nbBytes += 3; - + if (streamdependflag) { esd->dependsOnESID = gf_bs_read_int(bs, 16); nbBytes += 2; @@ -283,7 +283,7 @@ GF_Err gf_odf_read_esd(GF_BitStream *bs, GF_ESD *esd, u32 DescSize) e = AddDescriptorToESD(esd, tmp); if (e) return e; nbBytes += tmp_size + gf_odf_size_field_size(tmp_size); - + //apple fix if (!tmp_size) nbBytes = DescSize; @@ -321,12 +321,12 @@ GF_Err gf_odf_size_esd(GF_ESD *esd, u32 *outSize) *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } if (esd->ipiPtr) { - e = gf_odf_size_descriptor((GF_Descriptor *) esd->ipiPtr, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) esd->ipiPtr, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } if (esd->langDesc) { - e = gf_odf_size_descriptor((GF_Descriptor *) esd->langDesc, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) esd->langDesc, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } @@ -336,12 +336,12 @@ GF_Err gf_odf_size_esd(GF_ESD *esd, u32 *outSize) e = gf_odf_size_descriptor_list(esd->IPMPDescriptorPointers, outSize); if (e) return e; if (esd->qos) { - e = gf_odf_size_descriptor((GF_Descriptor *) esd->qos, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) esd->qos, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } if (esd->RegDescriptor) { - e = gf_odf_size_descriptor((GF_Descriptor *) esd->RegDescriptor, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) esd->RegDescriptor, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } @@ -455,7 +455,7 @@ GF_Err AddDescriptorToIOD(GF_InitialObjectDescriptor *iod, GF_Descriptor *desc) /*IPMPX*/ case GF_ODF_IPMP_TAG: return gf_list_add(iod->IPMP_Descriptors, desc); - + /*IPMPX*/ case GF_ODF_IPMP_TL_TAG: if (iod->IPMPToolList) gf_odf_desc_del((GF_Descriptor *)iod->IPMPToolList); @@ -482,7 +482,7 @@ GF_Err gf_odf_read_iod(GF_BitStream *bs, GF_InitialObjectDescriptor *iod, u32 De iod->inlineProfileFlag = gf_bs_read_int(bs, 1); /*reserved = */gf_bs_read_int(bs, 4); nbBytes += 2; - + if (urlflag) { e = gf_odf_read_url_string(bs, & iod->URLString, &read); if (e) return e; @@ -532,7 +532,7 @@ GF_Err gf_odf_size_iod(GF_InitialObjectDescriptor *iod, u32 *outSize) if (e) return e; if (iod->IPMPToolList) { u32 tmpSize; - e = gf_odf_size_descriptor((GF_Descriptor *) iod->IPMPToolList, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) iod->IPMPToolList, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } @@ -549,7 +549,7 @@ GF_Err gf_odf_write_iod(GF_BitStream *bs, GF_InitialObjectDescriptor *iod) if (e) return e; e = gf_odf_write_base_descriptor(bs, iod->tag, size); if (e) return e; - + gf_bs_write_int(bs, iod->objectDescriptorID, 10); gf_bs_write_int(bs, iod->URLString != NULL ? 1 : 0, 1); gf_bs_write_int(bs, iod->inlineProfileFlag, 1); @@ -621,13 +621,13 @@ GF_Err AddDescriptorToOD(GF_ObjectDescriptor *od, GF_Descriptor *desc) //check if we can handle ContentClassif tags if ( (desc->tag >= GF_ODF_OCI_BEGIN_TAG) && - (desc->tag <= GF_ODF_OCI_END_TAG) ) { + (desc->tag <= GF_ODF_OCI_END_TAG) ) { return gf_list_add(od->OCIDescriptors, desc); } //or extensions if ( (desc->tag >= GF_ODF_EXT_BEGIN_TAG) && - (desc->tag <= GF_ODF_EXT_END_TAG) ) { + (desc->tag <= GF_ODF_EXT_END_TAG) ) { return gf_list_add(od->extensionDescriptors, desc); } @@ -658,7 +658,7 @@ GF_Err gf_odf_read_od(GF_BitStream *bs, GF_ObjectDescriptor *od, u32 DescSize) urlflag = gf_bs_read_int(bs, 1); /*reserved = */gf_bs_read_int(bs, 5); nbBytes += 2; - + if (urlflag) { u32 read; e = gf_odf_read_url_string(bs, & od->URLString, &read); @@ -708,7 +708,7 @@ GF_Err gf_odf_write_od(GF_BitStream *bs, GF_ObjectDescriptor *od) if (e) return e; e = gf_odf_write_base_descriptor(bs, od->tag, size); if (e) return e; - + gf_bs_write_int(bs, od->objectDescriptorID, 10); gf_bs_write_int(bs, od->URLString != NULL ? 1 : 0, 1); gf_bs_write_int(bs, 31, 5); //reserved: 0b1111.1 == 31 @@ -822,7 +822,7 @@ GF_Err gf_odf_read_isom_iod(GF_BitStream *bs, GF_IsomInitialObjectDescriptor *io iod->inlineProfileFlag = gf_bs_read_int(bs, 1); /*reserved = */gf_bs_read_int(bs, 4); nbBytes += 2; - + if (urlflag) { u32 read; e = gf_odf_read_url_string(bs, & iod->URLString, &read); @@ -871,7 +871,7 @@ GF_Err gf_odf_size_isom_iod(GF_IsomInitialObjectDescriptor *iod, u32 *outSize) } if (iod->IPMPToolList) { u32 tmpSize; - e = gf_odf_size_descriptor((GF_Descriptor *) iod->IPMPToolList, &tmpSize); + e = gf_odf_size_descriptor((GF_Descriptor *) iod->IPMPToolList, &tmpSize); if (e) return e; *outSize += tmpSize + gf_odf_size_field_size(tmpSize); } @@ -888,7 +888,7 @@ GF_Err gf_odf_write_isom_iod(GF_BitStream *bs, GF_IsomInitialObjectDescriptor *i if (e) return e; e = gf_odf_write_base_descriptor(bs, iod->tag, size); if (e) return e; - + gf_bs_write_int(bs, iod->objectDescriptorID, 10); gf_bs_write_int(bs, iod->URLString != NULL ? 1 : 0, 1); gf_bs_write_int(bs, iod->inlineProfileFlag, 1); @@ -964,13 +964,13 @@ GF_Err AddDescriptorToIsomOD(GF_IsomObjectDescriptor *od, GF_Descriptor *desc) //check if we can handle ContentClassif tags if ( (desc->tag >= GF_ODF_OCI_BEGIN_TAG) && - (desc->tag <= GF_ODF_OCI_END_TAG) ) { + (desc->tag <= GF_ODF_OCI_END_TAG) ) { return gf_list_add(od->OCIDescriptors, desc); } //or extension ... if ( (desc->tag >= GF_ODF_EXT_BEGIN_TAG) && - (desc->tag <= GF_ODF_EXT_END_TAG) ) { + (desc->tag <= GF_ODF_EXT_END_TAG) ) { return gf_list_add(od->extensionDescriptors, desc); } @@ -1009,7 +1009,7 @@ GF_Err gf_odf_read_isom_od(GF_BitStream *bs, GF_IsomObjectDescriptor *od, u32 De urlflag = gf_bs_read_int(bs, 1); /*reserved = */gf_bs_read_int(bs, 5); nbBytes += 2; - + if (urlflag) { u32 read; e = gf_odf_read_url_string(bs, & od->URLString, &read); @@ -1061,7 +1061,7 @@ GF_Err gf_odf_write_isom_od(GF_BitStream *bs, GF_IsomObjectDescriptor *od) if (e) return e; e = gf_odf_write_base_descriptor(bs, od->tag, size); if (e) return e; - + gf_bs_write_int(bs, od->objectDescriptorID, 10); gf_bs_write_int(bs, od->URLString != NULL ? 1 : 0, 1); gf_bs_write_int(bs, 31, 5); //reserved: 0b1111.1 == 31 @@ -1369,7 +1369,7 @@ GF_Err gf_odf_write_esd_ref(GF_BitStream *bs, GF_ES_ID_Ref *esd_ref) if (e) return e; e = gf_odf_write_base_descriptor(bs, esd_ref->tag, size); if (e) return e; - + gf_bs_write_int(bs, esd_ref->trackRef, 16); return GF_OK; } @@ -1944,7 +1944,7 @@ GF_Err gf_odf_write_cc_name(GF_BitStream *bs, GF_CC_Name *cnd) } return GF_OK; } - + GF_Descriptor *gf_odf_new_ci() { @@ -2010,7 +2010,7 @@ GF_Err gf_odf_size_ci(GF_CIDesc *cid, u32 *outSize) *outSize = 1; if (cid->contentTypeFlag) *outSize += 1; - if (cid->contentIdentifierFlag) + if (cid->contentIdentifierFlag) *outSize += (u32) strlen((const char*)cid->contentIdentifier) - 1 - cid->contentTypeFlag; return GF_OK; } @@ -2114,7 +2114,7 @@ GF_Err gf_odf_read_exp_text(GF_BitStream *bs, GF_ExpandedTextual *etd, u32 DescS description = (GF_ETD_ItemText*)gf_malloc(sizeof(GF_ETD_ItemText)); if (! description) return GF_OUT_OF_MEM; description->text = NULL; - e = OD_ReadUTF8String(bs, & description->text, etd->isUTF8, &len); + e = OD_ReadUTF8String(bs, & description->text, etd->isUTF8, &len); if (e) return e; e = gf_list_add(etd->itemDescriptionList, description); if (e) return e; @@ -2180,13 +2180,13 @@ GF_Err gf_odf_size_exp_text(GF_ExpandedTextual *etd, u32 *outSize) } len = 255; lentmp = nonLen; - if (lentmp < 255) { + if (lentmp < 255) { len = lentmp; } while (len == 255) { *outSize += 1; lentmp -= 255; - if (lentmp < 255) { + if (lentmp < 255) { len = lentmp; } } @@ -2426,7 +2426,7 @@ GF_Err gf_odf_read_ipmp(GF_BitStream *bs, GF_IPMP_Descriptor *ipmp, u32 DescSize nbBytes += size; ipmp->opaque_data[size] = 0; ipmp->opaque_data_size = size; - + } /*data*/ else { @@ -2716,7 +2716,7 @@ GF_Err gf_odf_del_oci_name(GF_OCICreators *ocn) u32 i; GF_OCICreator_item *tmp; if (!ocn) return GF_BAD_PARAM; - + i=0; while ((tmp = (GF_OCICreator_item *)gf_list_enum(ocn->OCICreators, &i))) { if (tmp->OCICreatorName) gf_free(tmp->OCICreatorName); @@ -2870,7 +2870,7 @@ GF_Err gf_odf_read_rating(GF_BitStream *bs, GF_Rating *rd, u32 DescSize) rd->ratingCriteria = gf_bs_read_int(bs, 16); rd->infoLength = DescSize - 6; nbBytes += 6; - + rd->ratingInfo = (char*)gf_malloc(rd->infoLength); if (! rd->ratingInfo) return GF_OUT_OF_MEM; gf_bs_read_data(bs, rd->ratingInfo, rd->infoLength); @@ -3051,7 +3051,7 @@ GF_Descriptor *gf_odf_new_smpte_camera() GF_Err gf_odf_del_smpte_camera(GF_SMPTECamera *cpd) { u32 i; - GF_SmpteParam *tmp; + GF_SmpteParam *tmp; if (!cpd) return GF_BAD_PARAM; i=0; @@ -3207,7 +3207,7 @@ GF_Err gf_odf_read_ipmp_tool_list(GF_BitStream *bs, GF_IPMP_ToolList *ipmptl, u3 u32 tmpSize; u32 nbBytes = 0; if (! ipmptl) return GF_BAD_PARAM; - + while (nbBytes < DescSize) { GF_Descriptor *tmp = NULL; e = gf_odf_parse_descriptor(bs, &tmp, &tmpSize); @@ -3281,7 +3281,7 @@ GF_Err gf_odf_read_ipmp_tool(GF_BitStream *bs, GF_IPMP_Tool *ipmpt, u32 DescSize } } if (nbBytes>DescSize) return GF_ODF_INVALID_DESCRIPTOR; - + if (is_param) { } if (nbBytesnum_alternate) { u32 i; gf_bs_write_int(bs, ipmpt->num_alternate, 8); - for (i=0;inum_alternate; i++) gf_bs_write_data(bs, (char*)ipmpt->specificToolID[i], 16); + for (i=0; inum_alternate; i++) gf_bs_write_data(bs, (char*)ipmpt->specificToolID[i], 16); } if (ipmpt->tool_url) gf_ipmpx_write_array(bs, ipmpt->tool_url, (u32) strlen(ipmpt->tool_url)); return GF_OK; diff --git a/src/odf/odf_codec.c b/src/odf/odf_codec.c index cbf816a..6710418 100644 --- a/src/odf/odf_codec.c +++ b/src/odf/odf_codec.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,7 +37,7 @@ GF_ODCodec *gf_odf_codec_new() comList = gf_list_new(); if (!comList) return NULL; - + codec = (GF_ODCodec *) gf_malloc(sizeof(GF_ODCodec)); if (!codec) { gf_list_del(comList); @@ -84,7 +84,7 @@ GF_Err gf_odf_codec_encode(GF_ODCodec *codec, u32 cleanup_type) u32 i; if (!codec) return GF_BAD_PARAM; - + //check our bitstream: if existing, this means the previous encoded AU was not retrieved //we DON'T allow that if (codec->bs) return GF_BAD_PARAM; @@ -94,7 +94,8 @@ GF_Err gf_odf_codec_encode(GF_ODCodec *codec, u32 cleanup_type) /*encode each command*/ i = 0; while ((com = (GF_ODCom *)gf_list_enum(codec->CommandList, &i))) { - e = gf_odf_write_command(codec->bs, com); if (e) goto err_exit; + e = gf_odf_write_command(codec->bs, com); + if (e) goto err_exit; //don't forget OD Commands are aligned... gf_bs_align(codec->bs); } @@ -145,10 +146,10 @@ GF_Err gf_odf_codec_set_au(GF_ODCodec *codec, const char *au, u32 au_length) //the bitStream should not be here if (codec->bs) return GF_BAD_PARAM; - + codec->bs = gf_bs_new(au, (u64) au_length, (unsigned char)GF_BITSTREAM_READ); if (!codec->bs) return GF_OUT_OF_MEM; - return GF_OK; + return GF_OK; } @@ -163,7 +164,8 @@ GF_Err gf_odf_codec_decode(GF_ODCodec *codec) bufSize = (u32) gf_bs_available(codec->bs); while (size < bufSize) { - e = gf_odf_parse_command(codec->bs, &com, &comSize); if (e) goto err_exit; + e = gf_odf_parse_command(codec->bs, &com, &comSize); + if (e) goto err_exit; gf_list_add(codec->CommandList, com); size += comSize + gf_odf_size_field_size(comSize); //OD Commands are aligned @@ -286,7 +288,7 @@ GF_ESD *gf_odf_desc_esd_new(u32 sl_predefined) //use this function to decode a standalone descriptor //the desc MUST be formatted with tag and size field!!! GF_EXPORT -GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor * *outDesc) +GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor **outDesc) { GF_Err e; u32 size; @@ -301,13 +303,13 @@ GF_Err gf_odf_desc_read(char *raw_desc, u32 descSize, GF_Descriptor * *outDesc) e = gf_odf_parse_descriptor(bs, outDesc, &size); //the size dosn't have the header in it size += gf_odf_size_field_size(size); -/* - if (size != descSize) { - if (*outDesc) gf_odf_delete_descriptor(*outDesc); - *outDesc = NULL; - e = GF_ODF_INVALID_DESCRIPTOR; - } -*/ + /* + if (size != descSize) { + if (*outDesc) gf_odf_delete_descriptor(*outDesc); + *outDesc = NULL; + e = GF_ODF_INVALID_DESCRIPTOR; + } + */ gf_bs_del(bs); return e; @@ -346,7 +348,7 @@ u32 gf_odf_desc_size(GF_Descriptor *desc) { u32 descSize; GF_Err e; - + if (!desc) return GF_BAD_PARAM; //get the descriptor length e = gf_odf_size_descriptor(desc, &descSize); @@ -357,14 +359,14 @@ u32 gf_odf_desc_size(GF_Descriptor *desc) } -//this is usefull to duplicate on the fly a descriptor (mainly for authoring purposes) +//this is usefull to duplicate on the fly a descriptor (mainly for authoring purposes) GF_EXPORT GF_Err gf_odf_desc_copy(GF_Descriptor *inDesc, GF_Descriptor **outDesc) { GF_Err e; char *desc; u32 size; - + //warning: here we get some data allocated e = gf_odf_desc_write(inDesc, &desc, &size); if (e) return e; @@ -391,7 +393,7 @@ GF_Err gf_odf_desc_add_desc(GF_Descriptor *parentDesc, GF_Descriptor *newDesc) GF_Err AddDescriptorToESD(GF_ESD *esd, GF_Descriptor *desc); GF_Err AddDescriptorToIsomIOD(GF_IsomInitialObjectDescriptor *iod, GF_Descriptor *desc); GF_Err AddDescriptorToIsomOD(GF_IsomObjectDescriptor *od, GF_Descriptor *desc); - + if (!parentDesc || !newDesc) return GF_BAD_PARAM; switch (parentDesc->tag) { @@ -404,11 +406,11 @@ GF_Err gf_odf_desc_add_desc(GF_Descriptor *parentDesc, GF_Descriptor *newDesc) return AddDescriptorToESD((GF_ESD *)parentDesc, newDesc); case GF_ODF_DCD_TAG: dcd = (GF_DecoderConfig *)parentDesc; - if ((newDesc->tag == GF_ODF_DSI_TAG) - || (newDesc->tag == GF_ODF_BIFS_CFG_TAG) - || (newDesc->tag == GF_ODF_UI_CFG_TAG) - || (newDesc->tag == GF_ODF_TEXT_CFG_TAG) - ) { + if ((newDesc->tag == GF_ODF_DSI_TAG) + || (newDesc->tag == GF_ODF_BIFS_CFG_TAG) + || (newDesc->tag == GF_ODF_UI_CFG_TAG) + || (newDesc->tag == GF_ODF_TEXT_CFG_TAG) + ) { if (dcd->decoderSpecificInfo) return GF_ODF_FORBIDDEN_DESCRIPTOR; dcd->decoderSpecificInfo = (GF_DefaultDescriptor *) newDesc; return GF_OK; @@ -449,9 +451,9 @@ GF_Err gf_odf_desc_add_desc(GF_Descriptor *parentDesc, GF_Descriptor *newDesc) /***************************************************************************************** - Since IPMP V2, we introduce a new set of functions to read / write a list of + Since IPMP V2, we introduce a new set of functions to read / write a list of descriptors that have no containers (a bit like an OD command, but for descriptors) - This is usefull for IPMPv2 DecoderSpecificInfo which contains a set of + This is usefull for IPMPv2 DecoderSpecificInfo which contains a set of IPMP_Declarators. As it could be used for other purposes we keep it generic You must create the list yourself, the functions just encode/decode from/to the list @@ -472,7 +474,7 @@ GF_Err gf_odf_desc_list_read(char *raw_list, u32 raw_size, GF_List *descList) size = 0; while (size < raw_size) { - e = gf_odf_parse_descriptor(bs, &desc, &desc_size); + e = gf_odf_parse_descriptor(bs, &desc, &desc_size); if (e) goto exit; gf_list_add(descList, desc); size += desc_size + gf_odf_size_field_size(desc_size); @@ -541,7 +543,8 @@ GF_Err gf_odf_codec_apply_com(GF_ODCodec *codec, GF_ODCom *command) for (j=0; jNbODs; j++) { if (od->objectDescriptorID==odR->OD_ID[j]) { gf_list_rem(odU->objectDescriptors, k); - k--; count--; + k--; + count--; gf_odf_desc_del((GF_Descriptor *)od); break; } @@ -591,7 +594,7 @@ GF_Err gf_odf_codec_apply_com(GF_ODCodec *codec, GF_ODCom *command) for (j=0; jobjectDescriptors, j); if (od2->objectDescriptorID==od->objectDescriptorID) { - found = 1; + found = 1; break; } } diff --git a/src/odf/odf_command.c b/src/odf/odf_command.c index 2c34bd6..a1382e2 100644 --- a/src/odf/odf_command.c +++ b/src/odf/odf_command.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -40,7 +40,7 @@ GF_Err gf_odf_parse_command(GF_BitStream *bs, GF_ODCom **com, u32 *com_size) //tag tag = gf_bs_read_int(bs, 8); sizeHeader = 1; - + //size size = 0; do { @@ -60,7 +60,7 @@ GF_Err gf_odf_parse_command(GF_BitStream *bs, GF_ODCom **com, u32 *com_size) newCom->tag = tag; err = gf_odf_read_command(bs, newCom, *com_size); - //little trick to handle lazy bitstreams that encode + //little trick to handle lazy bitstreams that encode //SizeOfInstance on a fix number of bytes //This nb of bytes is added in Read methods *com_size += sizeHeader - gf_odf_size_field_size(*com_size); @@ -158,7 +158,7 @@ GF_Err gf_odf_size_od_remove(GF_ODRemove *odRem, u32 *outSize) { u32 size; if (!odRem) return GF_BAD_PARAM; - + size = 10 * odRem->NbODs; *outSize = 0; *outSize = size/8; @@ -191,7 +191,7 @@ GF_ODCom *gf_odf_new_od_update() { GF_ODUpdate *newCom = (GF_ODUpdate *) gf_malloc(sizeof(GF_ODUpdate)); if (!newCom) return NULL; - + newCom->objectDescriptors = gf_list_new(); if (! newCom->objectDescriptors) { gf_free(newCom); @@ -297,7 +297,7 @@ GF_ODCom *gf_odf_new_esd_update() { GF_ESDUpdate *newCom = (GF_ESDUpdate *) gf_malloc(sizeof(GF_ESDUpdate)); if (!newCom) return NULL; - + newCom->ESDescriptors = gf_list_new(); if (! newCom->ESDescriptors) { gf_free(newCom); @@ -356,8 +356,8 @@ GF_Err gf_odf_read_esd_update(GF_BitStream *bs, GF_ESDUpdate *esdUp, u32 gf_odf_ if (e) return e; nbBits += ( tmpSize + gf_odf_size_field_size(tmpSize) ) * 8; //our com is aligned, so nbBits is between (gf_odf_size_command-1)*8 and gf_odf_size_command*8 - if ( ( (nbBits >(gf_odf_size_command-1)*8) && (nbBits <= gf_odf_size_command * 8)) - || (nbBits > gf_odf_size_command*8) ) { //this one is a security break + if ( ( (nbBits >(gf_odf_size_command-1)*8) && (nbBits <= gf_odf_size_command * 8)) + || (nbBits > gf_odf_size_command*8) ) { //this one is a security break break; } } diff --git a/src/odf/odf_dump.c b/src/odf/odf_dump.c index ccaf012..1d0a39c 100644 --- a/src/odf/odf_dump.c +++ b/src/odf/odf_dump.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -39,7 +39,7 @@ for (z=0; z" - used because XMT-A OD representations use lots of +/*special close for XML only, appends "/>" - used because XMT-A OD representations use lots of subdescs not present in BT*/ static void EndSubElement(FILE *trace, u32 indent, Bool XMTDump) { @@ -244,7 +244,7 @@ static void StartElement(FILE *trace, const char *attName, u32 indent, Bool XMTD char ind_buf[OD_MAX_TREE]; OD_FORMAT_INDENT(ind_buf, indent); if (!XMTDump) { - if (IsList) + if (IsList) fprintf(trace, "%s%s [\n", ind_buf, attName); else fprintf(trace, "%s%s ", ind_buf, attName); @@ -410,7 +410,7 @@ GF_Err DumpDescListFilter(GF_List *list, FILE *trace, u32 indent, const char *Li if (desc->tag == tag_only) num_desc++; } if (!num_desc) return GF_OK; - + StartElement(trace, ListName, indent, XMTDump, 1); indent++; OD_FORMAT_INDENT(ind_buf, indent); @@ -460,7 +460,7 @@ GF_Err gf_odf_dump_iod(GF_InitialObjectDescriptor *iod, FILE *trace, u32 indent, DumpString(trace, "URLstring", iod->URLString, indent, XMTDump); EndSubElement(trace, indent, XMTDump); } - + if (XMTDump) { StartElement(trace, "Descr", indent, XMTDump, 1); indent++; @@ -478,7 +478,7 @@ GF_Err gf_odf_dump_iod(GF_InitialObjectDescriptor *iod, FILE *trace, u32 indent, gf_odf_dump_desc(iod->IPMPToolList, trace, indent + (XMTDump ? 1 : 0), XMTDump); EndElement(trace, "toolListDescr" , indent, XMTDump, 0); } - + if (XMTDump) { indent--; EndElement(trace, "Descr", indent, XMTDump, 1); @@ -512,7 +512,7 @@ GF_Err gf_odf_dump_esd(GF_ESD *esd, FILE *trace, u32 indent, Bool XMTDump) fprintf(trace, "es%d", esd->dependsOnESID); EndAttribute(trace, indent, XMTDump); } - + if (esd->OCRESID) { StartAttribute(trace, "OCR_ES_ID", indent, XMTDump); fprintf(trace, "es%d", esd->OCRESID); @@ -539,7 +539,7 @@ GF_Err gf_odf_dump_esd(GF_ESD *esd, FILE *trace, u32 indent, Bool XMTDump) StartElement(trace, "slConfigDescr" , indent, XMTDump, 0); gf_odf_dump_desc(esd->slConfig, trace, indent + (XMTDump ? 1 : 0), XMTDump); EndElement(trace, "slConfigDescr" , indent, XMTDump, 0); - }else{ + } else { StartElement(trace, "slConfigDescr" , indent, XMTDump, 0); StartDescDump(trace, "SLConfigDescriptor", indent, XMTDump); EndAttributes(trace, indent, XMTDump); @@ -605,7 +605,7 @@ GF_Err gf_odf_dump_bifs_cfg(GF_BIFSConfig *dsi, FILE *trace, u32 indent, Bool XM u32 i, count; StartDescDump(trace, (dsi->version==1) ? "BIFSConfig" : "BIFSv2Config", indent, XMTDump); indent++; - + if (dsi->version==2) { DumpBool(trace, "use3DMeshCoding", 0, indent, XMTDump); DumpBool(trace, "usePredictiveMFField", 0, indent, XMTDump); @@ -678,7 +678,7 @@ GF_Err DumpRawBIFSConfig(GF_DefaultDescriptor *dsi, FILE *trace, u32 indent, Boo StartDescDump(trace, (oti==1) ? "BIFSConfig" : "BIFSv2Config", indent, XMTDump); indent++; - + if (oti==2) { DumpBool(trace, "use3DMeshCoding", gf_bs_read_int(bs, 1), indent, XMTDump); DumpBool(trace, "usePredictiveMFField", gf_bs_read_int(bs, 1), indent, XMTDump); @@ -686,7 +686,7 @@ GF_Err DumpRawBIFSConfig(GF_DefaultDescriptor *dsi, FILE *trace, u32 indent, Boo DumpInt(trace, "nodeIDbits", gf_bs_read_int(bs, 5), indent, XMTDump); DumpInt(trace, "routeIDbits", gf_bs_read_int(bs, 5), indent, XMTDump); - if (oti==2) + if (oti==2) DumpInt(trace, "protoIDbits", gf_bs_read_int(bs, 5), indent, XMTDump); flag = gf_bs_read_int(bs, 1); @@ -735,9 +735,9 @@ GF_Err DumpRawBIFSConfig(GF_DefaultDescriptor *dsi, FILE *trace, u32 indent, Boo GF_Err gf_odf_dump_laser_cfg(GF_LASERConfig *dsi, FILE *trace, u32 indent, Bool XMTDump) { - fprintf(trace, "profile ? "mini" : "full", - dsi->pointsCodec ? "Unknown" : "ExpGolombPointsCodec"); + fprintf(trace, "profile ? "mini" : "full", + dsi->pointsCodec ? "Unknown" : "ExpGolombPointsCodec"); if (dsi->colorComponentBits) fprintf(trace, " colorComponentBits=\"%d\"", dsi->colorComponentBits); if (dsi->newSceneIndicator) fprintf(trace, " newSceneIndicator=\"true\""); @@ -774,7 +774,7 @@ GF_Err gf_odf_dump_txtcfg(GF_TextConfig *desc, FILE *trace, u32 indent, Bool XMT StartElement(trace, "SampleDescriptions", indent, XMTDump, 1); indent++; OD_FORMAT_INDENT(ind_buf, indent); - + count = gf_list_count(desc->sample_descriptions); for (i=0; ideviceName, indent, XMTDump); - + if (!stricmp(devName, "StringSensor") && uid->termChar) { devName[0] = uid->termChar; devName[1] = 0; @@ -895,7 +895,7 @@ GF_Err DumpRawUIConfig(GF_DefaultDescriptor *dsi, FILE *trace, u32 indent, Bool for (i=0; iisUTF8, indent, XMTDump); DumpString(trace, "nonItemText", etd->NonItemText, indent, XMTDump); EndAttributes(trace, indent, XMTDump); - + count = gf_list_count(etd->itemDescriptionList); for (i=0; iitemDescriptionList, i); it2 = (GF_ETD_ItemText *)gf_list_get(etd->itemTextList, i); - StartSubElement(trace, "item", indent, XMTDump); + StartSubElement(trace, "item", indent, XMTDump); DumpString(trace, "description", it1->text, indent, XMTDump); DumpString(trace, "text", it2->text, indent, XMTDump); - EndSubElement(trace, indent, XMTDump); + EndSubElement(trace, indent, XMTDump); } indent--; EndDescDump(trace, "ExpandedTextualDescriptor", indent, XMTDump); @@ -1268,8 +1268,8 @@ GF_Err gf_odf_dump_ipmp_ptr(GF_IPMPPtr *ipmpd, FILE *trace, u32 indent, Bool XMT DumpInt(trace, "IPMP_DescriptorID", ipmpd->IPMP_DescriptorID, indent, XMTDump); } indent--; - if (XMTDump) - EndSubElement(trace, indent, XMTDump); + if (XMTDump) + EndSubElement(trace, indent, XMTDump); else EndDescDump(trace, "IPMP_DescriptorPointer", indent, XMTDump); return GF_OK; @@ -1308,7 +1308,7 @@ GF_Err gf_odf_dump_lang(GF_Language *ld, FILE *trace, u32 indent, Bool XMTDump) sLan[3] = 0; DumpString(trace, "languageCode", sLan, indent, XMTDump); indent--; - EndSubElement(trace, indent, XMTDump); + EndSubElement(trace, indent, XMTDump); if (!XMTDump) EndDescDump(trace, "LanguageDescriptor", indent, XMTDump); return GF_OK; } @@ -1329,7 +1329,7 @@ GF_Err gf_odf_dump_aux_vid(GF_AuxVideoDescriptor *ld, FILE *trace, u32 indent, B DumpInt(trace, "dref", ld->dref, indent, XMTDump); DumpInt(trace, "wref", ld->wref, indent, XMTDump); indent--; - EndSubElement(trace, indent, XMTDump); + EndSubElement(trace, indent, XMTDump); if (!XMTDump) EndDescDump(trace, "LanguageDescriptor", indent, XMTDump); return GF_OK; } @@ -1337,7 +1337,7 @@ GF_Err gf_odf_dump_aux_vid(GF_AuxVideoDescriptor *ld, FILE *trace, u32 indent, B GF_Err gf_odf_dump_isom_iod(GF_IsomInitialObjectDescriptor *iod, FILE *trace, u32 indent, Bool XMTDump) { - + StartDescDump(trace, "MP4InitialObjectDescriptor", indent, XMTDump); indent++; @@ -1372,7 +1372,7 @@ GF_Err gf_odf_dump_isom_iod(GF_IsomInitialObjectDescriptor *iod, FILE *trace, u3 DumpString(trace, "URLstring", iod->URLString, indent, XMTDump); EndSubElement(trace, indent, XMTDump); } - + if (XMTDump) { StartElement(trace, "Descr", indent, XMTDump, 1); indent++; @@ -1394,7 +1394,7 @@ GF_Err gf_odf_dump_isom_iod(GF_IsomInitialObjectDescriptor *iod, FILE *trace, u3 gf_odf_dump_desc(iod->IPMPToolList, trace, indent + (XMTDump ? 1 : 0), XMTDump); EndElement(trace, "toolListDescr" , indent, XMTDump, 0); } - + if (XMTDump) { indent--; EndElement(trace, "Descr", indent, XMTDump, 1); @@ -1423,7 +1423,7 @@ GF_Err gf_odf_dump_od(GF_ObjectDescriptor *od, FILE *trace, u32 indent, Bool XMT DumpString(trace, "URLstring", od->URLString, indent, XMTDump); EndSubElement(trace, indent, XMTDump); } - + if (XMTDump) { StartElement(trace, "Descr", indent, XMTDump, 1); indent++; @@ -1435,7 +1435,7 @@ GF_Err gf_odf_dump_od(GF_ObjectDescriptor *od, FILE *trace, u32 indent, Bool XMT DumpDescListFilter(od->IPMP_Descriptors, trace, indent, "ipmpDescr", XMTDump, GF_ODF_IPMP_TAG); DumpDescList(od->extensionDescriptors, trace, indent, "extDescr", XMTDump, 0); - + if (XMTDump) { indent--; EndElement(trace, "Descr", indent, XMTDump, 1); @@ -1464,7 +1464,7 @@ GF_Err gf_odf_dump_isom_od(GF_IsomObjectDescriptor *od, FILE *trace, u32 indent, DumpString(trace, "URLstring", od->URLString, indent, XMTDump); EndSubElement(trace, indent, XMTDump); } - + if (XMTDump) { StartElement(trace, "Descr", indent, XMTDump, 1); indent++; @@ -1479,7 +1479,7 @@ GF_Err gf_odf_dump_isom_od(GF_IsomObjectDescriptor *od, FILE *trace, u32 indent, DumpDescListFilter(od->IPMP_Descriptors, trace, indent, "ipmpDescrPtr", XMTDump, GF_ODF_IPMP_PTR_TAG); DumpDescListFilter(od->IPMP_Descriptors, trace, indent, "ipmpDescr", XMTDump, GF_ODF_IPMP_TAG); DumpDescList(od->extensionDescriptors, trace, indent, "extDescr", XMTDump, 0); - + if (XMTDump) { indent--; EndElement(trace, "Descr", indent, XMTDump, 1); @@ -1643,7 +1643,7 @@ GF_Err gf_odf_dump_smpte_camera(GF_SMPTECamera *cpd, FILE *trace, u32 indent, Bo indent++; DumpInt(trace, "cameraID", cpd->cameraID, indent, XMTDump); EndAttributes(trace, indent, XMTDump); - + i=0; while ((p = (GF_SmpteParam *)gf_list_enum(cpd->ParamList, &i))) { StartSubElement(trace, "parameter", indent, XMTDump); @@ -1677,7 +1677,7 @@ GF_Err gf_odf_dump_segment(GF_Segment *sd, FILE *trace, u32 indent, Bool XMTDump DumpDouble(trace, "duration", sd->Duration, indent, XMTDump); DumpString(trace, "name", sd->SegmentName, indent, XMTDump); indent--; - if (XMTDump) + if (XMTDump) EndSubElement(trace, indent, XMTDump); else EndDescDump(trace, "SegmentDescriptor", indent, XMTDump); @@ -1715,7 +1715,7 @@ GF_Err gf_odf_dump_muxinfo(GF_MuxInfo *mi, FILE *trace, u32 indent, Bool XMTDump if (mi->textNode) DumpString(trace, "textNode", mi->textNode, indent, 0); if (mi->fontNode) DumpString(trace, "fontNode", mi->fontNode, indent, 0); - + indent--; EndDescDump(trace, "MuxInfo", indent, 0); return GF_OK; @@ -1947,7 +1947,7 @@ GF_Err gf_oci_dump_event(OCIEvent *ev, FILE *trace, u32 indent, Bool XMTDump) StartAttribute(trace, "duration", indent, XMTDump); fprintf(trace, "%d:%d:%d:%d", H, M, S, hS); EndAttribute(trace, indent, XMTDump); - + StartElement(trace, "OCIDescr", indent, XMTDump, 1); for (i=0; iinlineProfileFlag) - if (!ret) { iod->inlineProfileFlag = 0; ret = 1; } + if (!ret) { + iod->inlineProfileFlag = 0; + ret = 1; + } } else if (!stricmp(fieldName, "ODProfileLevelIndication")) { GET_U8(iod->OD_profileAndLevel) - if (!ret) { iod->OD_profileAndLevel = 0xFE; ret = 1; } + if (!ret) { + iod->OD_profileAndLevel = 0xFE; + ret = 1; + } } else if (!stricmp(fieldName, "sceneProfileLevelIndication")) { GET_U8(iod->scene_profileAndLevel) - if (!ret) { iod->scene_profileAndLevel = 0xFE; ret = 1; } + if (!ret) { + iod->scene_profileAndLevel = 0xFE; + ret = 1; + } } else if (!stricmp(fieldName, "audioProfileLevelIndication")) { GET_U8(iod->audio_profileAndLevel) - if (!ret) { iod->audio_profileAndLevel = 0xFE; ret = 1; } + if (!ret) { + iod->audio_profileAndLevel = 0xFE; + ret = 1; + } } else if (!stricmp(fieldName, "visualProfileLevelIndication")) { GET_U8(iod->visual_profileAndLevel) - if (!ret) { iod->visual_profileAndLevel = 0xFE; ret = 1; } + if (!ret) { + iod->visual_profileAndLevel = 0xFE; + ret = 1; + } } else if (!stricmp(fieldName, "graphicsProfileLevelIndication")) { GET_U8(iod->graphics_profileAndLevel) - if (!ret) { iod->graphics_profileAndLevel = 0xFE; ret = 1; } + if (!ret) { + iod->graphics_profileAndLevel = 0xFE; + ret = 1; + } } } - break; + break; case GF_ODF_OD_TAG: { GF_ObjectDescriptor *od = (GF_ObjectDescriptor *) desc; @@ -255,7 +273,7 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) ret = 1; } } - break; + break; case GF_ODF_DCD_TAG: { GF_DecoderConfig *dcd = (GF_DecoderConfig *)desc; @@ -263,47 +281,128 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) GET_U8(dcd->objectTypeIndication) /*XMT may use string*/ if (!ret) { - if (!stricmp(val, "MPEG4Systems1")) { dcd->objectTypeIndication = 0x01; ret = 1; } - else if (!stricmp(val, "MPEG4Systems2")) { dcd->objectTypeIndication = 0x02; ret = 1; } - else if (!stricmp(val, "MPEG4Visual")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG4_PART2; ret = 1; } - else if (!stricmp(val, "MPEG4Audio")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG4; ret = 1; } - else if (!stricmp(val, "MPEG2VisualSimple")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SIMPLE; ret = 1; } - else if (!stricmp(val, "MPEG2VisualMain")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_MAIN; ret = 1; } - else if (!stricmp(val, "MPEG2VisualSNR")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SNR; ret = 1; } - else if (!stricmp(val, "MPEG2VisualSpatial")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SPATIAL; ret = 1; } - else if (!stricmp(val, "MPEG2VisualHigh")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_HIGH; ret = 1; } - else if (!stricmp(val, "MPEG2Visual422")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_422; ret = 1; } - else if (!stricmp(val, "MPEG2AudioMain")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_MP; ret = 1; } - else if (!stricmp(val, "MPEG2AudioLowComplexity")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_LCP; ret = 1; } - else if (!stricmp(val, "MPEG2AudioScaleableSamplingRate")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_SSRP; ret = 1; } - else if (!stricmp(val, "MPEG2AudioPart3")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_MPEG2_PART3; ret = 1; } - else if (!stricmp(val, "MPEG1Visual")) { dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG1; ret = 1; } - else if (!stricmp(val, "MPEG1Audio")) { dcd->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1; ret = 1; } - else if (!stricmp(val, "JPEG")) { dcd->objectTypeIndication = GPAC_OTI_IMAGE_JPEG; ret = 1; } - else if (!stricmp(val, "PNG")) { dcd->objectTypeIndication = GPAC_OTI_IMAGE_PNG; ret = 1; } + if (!stricmp(val, "MPEG4Systems1")) { + dcd->objectTypeIndication = 0x01; + ret = 1; + } + else if (!stricmp(val, "MPEG4Systems2")) { + dcd->objectTypeIndication = 0x02; + ret = 1; + } + else if (!stricmp(val, "MPEG4Visual")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG4_PART2; + ret = 1; + } + else if (!stricmp(val, "MPEG4Audio")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG4; + ret = 1; + } + else if (!stricmp(val, "MPEG2VisualSimple")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SIMPLE; + ret = 1; + } + else if (!stricmp(val, "MPEG2VisualMain")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_MAIN; + ret = 1; + } + else if (!stricmp(val, "MPEG2VisualSNR")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SNR; + ret = 1; + } + else if (!stricmp(val, "MPEG2VisualSpatial")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_SPATIAL; + ret = 1; + } + else if (!stricmp(val, "MPEG2VisualHigh")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_HIGH; + ret = 1; + } + else if (!stricmp(val, "MPEG2Visual422")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_422; + ret = 1; + } + else if (!stricmp(val, "MPEG2AudioMain")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_MP; + ret = 1; + } + else if (!stricmp(val, "MPEG2AudioLowComplexity")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_LCP; + ret = 1; + } + else if (!stricmp(val, "MPEG2AudioScaleableSamplingRate")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG2_SSRP; + ret = 1; + } + else if (!stricmp(val, "MPEG2AudioPart3")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_MPEG2_PART3; + ret = 1; + } + else if (!stricmp(val, "MPEG1Visual")) { + dcd->objectTypeIndication = GPAC_OTI_VIDEO_MPEG1; + ret = 1; + } + else if (!stricmp(val, "MPEG1Audio")) { + dcd->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1; + ret = 1; + } + else if (!stricmp(val, "JPEG")) { + dcd->objectTypeIndication = GPAC_OTI_IMAGE_JPEG; + ret = 1; + } + else if (!stricmp(val, "PNG")) { + dcd->objectTypeIndication = GPAC_OTI_IMAGE_PNG; + ret = 1; + } } } else if (!stricmp(fieldName, "streamType")) { GET_U8(dcd->streamType) /*XMT may use string*/ if (!ret) { - if (!stricmp(val, "ObjectDescriptor")) { dcd->streamType = GF_STREAM_OD; ret = 1; } - else if (!stricmp(val, "ClockReference")) { dcd->streamType = GF_STREAM_OCR; ret = 1; } - else if (!stricmp(val, "SceneDescription")) { dcd->streamType = GF_STREAM_SCENE; ret = 1; } - else if (!stricmp(val, "Visual")) { dcd->streamType = GF_STREAM_VISUAL; ret = 1; } - else if (!stricmp(val, "Audio")) { dcd->streamType = GF_STREAM_AUDIO; ret = 1; } - else if (!stricmp(val, "MPEG7")) { dcd->streamType = GF_STREAM_MPEG7; ret = 1; } - else if (!stricmp(val, "IPMP")) { dcd->streamType = GF_STREAM_IPMP; ret = 1; } - else if (!stricmp(val, "OCI")) { dcd->streamType = GF_STREAM_OCI; ret = 1; } - else if (!stricmp(val, "MPEGJ")) { dcd->streamType = GF_STREAM_MPEGJ; ret = 1; } + if (!stricmp(val, "ObjectDescriptor")) { + dcd->streamType = GF_STREAM_OD; + ret = 1; + } + else if (!stricmp(val, "ClockReference")) { + dcd->streamType = GF_STREAM_OCR; + ret = 1; + } + else if (!stricmp(val, "SceneDescription")) { + dcd->streamType = GF_STREAM_SCENE; + ret = 1; + } + else if (!stricmp(val, "Visual")) { + dcd->streamType = GF_STREAM_VISUAL; + ret = 1; + } + else if (!stricmp(val, "Audio")) { + dcd->streamType = GF_STREAM_AUDIO; + ret = 1; + } + else if (!stricmp(val, "MPEG7")) { + dcd->streamType = GF_STREAM_MPEG7; + ret = 1; + } + else if (!stricmp(val, "IPMP")) { + dcd->streamType = GF_STREAM_IPMP; + ret = 1; + } + else if (!stricmp(val, "OCI")) { + dcd->streamType = GF_STREAM_OCI; + ret = 1; + } + else if (!stricmp(val, "MPEGJ")) { + dcd->streamType = GF_STREAM_MPEGJ; + ret = 1; + } } } else if (!stricmp(fieldName, "upStream")) GET_BOOL(dcd->upstream) - else if (!stricmp(fieldName, "bufferSizeDB")) ret += sscanf(val, "%u", &dcd->bufferSizeDB); - else if (!stricmp(fieldName, "maxBitRate")) ret += sscanf(val, "%u", &dcd->maxBitrate); - else if (!stricmp(fieldName, "avgBitRate")) ret += sscanf(val, "%u", &dcd->avgBitrate); + else if (!stricmp(fieldName, "bufferSizeDB")) ret += sscanf(val, "%u", &dcd->bufferSizeDB); + else if (!stricmp(fieldName, "maxBitRate")) ret += sscanf(val, "%u", &dcd->maxBitrate); + else if (!stricmp(fieldName, "avgBitRate")) ret += sscanf(val, "%u", &dcd->avgBitrate); } - break; + break; case GF_ODF_ESD_TAG: { GF_ESD *esd = (GF_ESD *)desc; @@ -311,55 +410,55 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) ret += sscanf(val, "%hu", &esd->ESID); } else if (!stricmp(fieldName, "streamPriority")) GET_U8(esd->streamPriority) - else if (!stricmp(fieldName, "dependsOn_ES_ID") || !stricmp(fieldName, "dependsOnESID")) ret += sscanf(val, "%hu", &esd->dependsOnESID); - else if (!stricmp(fieldName, "OCR_ES_ID")) ret += sscanf(val, "%hu", &esd->OCRESID); - else if (!stricmp(fieldName, "URLstring")) { - esd->URLString = gf_strdup(val); - ret = 1; - } + else if (!stricmp(fieldName, "dependsOn_ES_ID") || !stricmp(fieldName, "dependsOnESID")) ret += sscanf(val, "%hu", &esd->dependsOnESID); + else if (!stricmp(fieldName, "OCR_ES_ID")) ret += sscanf(val, "%hu", &esd->OCRESID); + else if (!stricmp(fieldName, "URLstring")) { + esd->URLString = gf_strdup(val); + ret = 1; + } /*ignore*/ - else if (!stricmp(fieldName, "streamDependenceFlag") - || !stricmp(fieldName, "URL_Flag") - || !stricmp(fieldName, "OCRstreamFlag") - ) - ret = 1; + else if (!stricmp(fieldName, "streamDependenceFlag") + || !stricmp(fieldName, "URL_Flag") + || !stricmp(fieldName, "OCRstreamFlag") + ) + ret = 1; } - break; + break; case GF_ODF_SLC_TAG: { u32 ts; GF_SLConfig *slc = (GF_SLConfig*)desc; if (!stricmp(fieldName, "predefined")) GET_U8(slc->predefined) - else if (!stricmp(fieldName, "useAccessUnitStartFlag")) GET_BOOL(slc->useAccessUnitStartFlag) - else if (!stricmp(fieldName, "useAccessUnitEndFlag")) GET_BOOL(slc->useAccessUnitEndFlag) - else if (!stricmp(fieldName, "useRandomAccessPointFlag")) GET_BOOL(slc->useRandomAccessPointFlag) - else if (!stricmp(fieldName, "hasRandomAccessUnitsOnlyFlag") || !stricmp(fieldName, "useRandomAccessUnitsOnlyFlag")) GET_BOOL(slc->hasRandomAccessUnitsOnlyFlag) - else if (!stricmp(fieldName, "usePaddingFlag")) GET_BOOL(slc->usePaddingFlag) - else if (!stricmp(fieldName, "useTimeStampsFlag")) GET_BOOL(slc->useTimestampsFlag) - else if (!stricmp(fieldName, "useIdleFlag")) GET_BOOL(slc->useIdleFlag) - else if (!stricmp(fieldName, "timeStampResolution")) ret += sscanf(val, "%u", &slc->timestampResolution); - else if (!stricmp(fieldName, "OCRResolution")) ret += sscanf(val, "%u", &slc->OCRResolution); - else if (!stricmp(fieldName, "timeStampLength")) GET_U8(slc->timestampLength) - else if (!stricmp(fieldName, "OCRLength")) GET_U8(slc->OCRLength) - else if (!stricmp(fieldName, "AU_Length")) GET_U8(slc->AULength) - else if (!stricmp(fieldName, "instantBitrateLength")) GET_U8(slc->instantBitrateLength) - else if (!stricmp(fieldName, "degradationPriorityLength")) GET_U8(slc->degradationPriorityLength) - else if (!stricmp(fieldName, "AU_seqNumLength")) GET_U8(slc->AUSeqNumLength) - else if (!stricmp(fieldName, "packetSeqNumLength")) GET_U8(slc->packetSeqNumLength) - else if (!stricmp(fieldName, "timeScale")) ret += sscanf(val, "%u", &slc->timeScale); - else if (!stricmp(fieldName, "accessUnitDuration")) ret += sscanf(val, "%hu", &slc->AUDuration); - else if (!stricmp(fieldName, "compositionUnitDuration")) ret += sscanf(val, "%hu", &slc->CUDuration); - else if (!stricmp(fieldName, "startDecodingTimeStamp")) { - ret += sscanf(val, "%u", &ts); - slc->startDTS = ts; - } - else if (!stricmp(fieldName, "startCompositionTimeStamp")) { - ret += sscanf(val, "%u", &ts); - slc->startCTS = ts; - } - else if (!stricmp(fieldName, "durationFlag")) ret = 1; - } - break; + else if (!stricmp(fieldName, "useAccessUnitStartFlag")) GET_BOOL(slc->useAccessUnitStartFlag) + else if (!stricmp(fieldName, "useAccessUnitEndFlag")) GET_BOOL(slc->useAccessUnitEndFlag) + else if (!stricmp(fieldName, "useRandomAccessPointFlag")) GET_BOOL(slc->useRandomAccessPointFlag) + else if (!stricmp(fieldName, "hasRandomAccessUnitsOnlyFlag") || !stricmp(fieldName, "useRandomAccessUnitsOnlyFlag")) GET_BOOL(slc->hasRandomAccessUnitsOnlyFlag) + else if (!stricmp(fieldName, "usePaddingFlag")) GET_BOOL(slc->usePaddingFlag) + else if (!stricmp(fieldName, "useTimeStampsFlag")) GET_BOOL(slc->useTimestampsFlag) + else if (!stricmp(fieldName, "useIdleFlag")) GET_BOOL(slc->useIdleFlag) + else if (!stricmp(fieldName, "timeStampResolution")) ret += sscanf(val, "%u", &slc->timestampResolution); + else if (!stricmp(fieldName, "OCRResolution")) ret += sscanf(val, "%u", &slc->OCRResolution); + else if (!stricmp(fieldName, "timeStampLength")) GET_U8(slc->timestampLength) + else if (!stricmp(fieldName, "OCRLength")) GET_U8(slc->OCRLength) + else if (!stricmp(fieldName, "AU_Length")) GET_U8(slc->AULength) + else if (!stricmp(fieldName, "instantBitrateLength")) GET_U8(slc->instantBitrateLength) + else if (!stricmp(fieldName, "degradationPriorityLength")) GET_U8(slc->degradationPriorityLength) + else if (!stricmp(fieldName, "AU_seqNumLength")) GET_U8(slc->AUSeqNumLength) + else if (!stricmp(fieldName, "packetSeqNumLength")) GET_U8(slc->packetSeqNumLength) + else if (!stricmp(fieldName, "timeScale")) ret += sscanf(val, "%u", &slc->timeScale); + else if (!stricmp(fieldName, "accessUnitDuration")) ret += sscanf(val, "%hu", &slc->AUDuration); + else if (!stricmp(fieldName, "compositionUnitDuration")) ret += sscanf(val, "%hu", &slc->CUDuration); + else if (!stricmp(fieldName, "startDecodingTimeStamp")) { + ret += sscanf(val, "%u", &ts); + slc->startDTS = ts; + } + else if (!stricmp(fieldName, "startCompositionTimeStamp")) { + ret += sscanf(val, "%u", &ts); + slc->startCTS = ts; + } + else if (!stricmp(fieldName, "durationFlag")) ret = 1; + } + break; case GF_ODF_ELEM_MASK_TAG: { GF_ElementaryMask* em = (GF_ElementaryMask*)desc; @@ -370,7 +469,7 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) } else if (!stricmp(fieldName, "numDynFields")) ret = 1; } - break; + break; case GF_ODF_BIFS_CFG_TAG: { GF_BIFSConfig *bcd = (GF_BIFSConfig*)desc; @@ -378,49 +477,63 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) if (!stricmp(fieldName, "nodeIDbits")) ret += sscanf(val, "%hu", &bcd->nodeIDbits); else if (!stricmp(fieldName, "routeIDbits")) ret += sscanf(val, "%hu", &bcd->routeIDbits); else if (!stricmp(fieldName, "protoIDbits")) ret += sscanf(val, "%hu", &bcd->protoIDbits); - else if (!stricmp(fieldName, "isCommandStream")) { /*GET_BOOL(bcd->isCommandStream)*/ ret = 1; } + else if (!stricmp(fieldName, "isCommandStream")) { + /*GET_BOOL(bcd->isCommandStream)*/ ret = 1; + } else if (!stricmp(fieldName, "pixelMetric") || !stricmp(fieldName, "pixelMetrics")) GET_BOOL(bcd->pixelMetrics) - else if (!stricmp(fieldName, "pixelWidth")) ret += sscanf(val, "%hu", &bcd->pixelWidth); - else if (!stricmp(fieldName, "pixelHeight")) ret += sscanf(val, "%hu", &bcd->pixelHeight); - else if (!stricmp(fieldName, "use3DMeshCoding")) ret = 1; - else if (!stricmp(fieldName, "usePredictiveMFField")) ret = 1; - else if (!stricmp(fieldName, "randomAccess")) GET_BOOL(bcd->randomAccess) - else if (!stricmp(fieldName, "useNames")) GET_BOOL(bcd->useNames) - } - break; + else if (!stricmp(fieldName, "pixelWidth")) ret += sscanf(val, "%hu", &bcd->pixelWidth); + else if (!stricmp(fieldName, "pixelHeight")) ret += sscanf(val, "%hu", &bcd->pixelHeight); + else if (!stricmp(fieldName, "use3DMeshCoding")) ret = 1; + else if (!stricmp(fieldName, "usePredictiveMFField")) ret = 1; + else if (!stricmp(fieldName, "randomAccess")) GET_BOOL(bcd->randomAccess) + else if (!stricmp(fieldName, "useNames")) GET_BOOL(bcd->useNames) + } + break; case GF_ODF_MUXINFO_TAG: { GF_MuxInfo *mi = (GF_MuxInfo *)desc; if (!stricmp(fieldName, "fileName") || !stricmp(fieldName, "url")) GET_STRING(mi->file_name) - else if (!stricmp(fieldName, "streamFormat")) GET_STRING(mi->streamFormat) - else if (!stricmp(fieldName, "GroupID")) ret += sscanf(val, "%u", &mi->GroupID); - else if (!stricmp(fieldName, "startTime")) ret += sscanf(val, "%d", &mi->startTime); - else if (!stricmp(fieldName, "duration")) ret += sscanf(val, "%u", &mi->duration); - else if (!stricmp(fieldName, "carouselPeriod")) { - ret += sscanf(val, "%u", &mi->carousel_period_plus_one); - mi->carousel_period_plus_one += 1; - } - else if (!stricmp(fieldName, "aggregateOnESID")) ret += sscanf(val, "%hu", &mi->aggregate_on_esid); + else if (!stricmp(fieldName, "streamFormat")) GET_STRING(mi->streamFormat) + else if (!stricmp(fieldName, "GroupID")) ret += sscanf(val, "%u", &mi->GroupID); + else if (!stricmp(fieldName, "startTime")) ret += sscanf(val, "%d", &mi->startTime); + else if (!stricmp(fieldName, "duration")) ret += sscanf(val, "%u", &mi->duration); + else if (!stricmp(fieldName, "carouselPeriod")) { + ret += sscanf(val, "%u", &mi->carousel_period_plus_one); + mi->carousel_period_plus_one += 1; + } + else if (!stricmp(fieldName, "aggregateOnESID")) ret += sscanf(val, "%hu", &mi->aggregate_on_esid); #ifndef GPAC_DISABLE_MEDIA_IMPORT - else if (!stricmp(fieldName, "compactSize")) - { ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_COMPACT_SIZE; } - else if (!stricmp(fieldName, "useDataReference")) - { ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_DATAREF; } - else if (!stricmp(fieldName, "noFrameDrop")) - { ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_NO_FRAME_DROP; } - else if (!stricmp(fieldName, "SBR_Type")) { - ret = 1; - if (!stricmp(val, "implicit") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_SBR_IMPLICIT; - else if (!stricmp(val, "explicit") || !stricmp(val, "2")) mi->import_flags |= GF_IMPORT_SBR_EXPLICIT; - } + else if (!stricmp(fieldName, "compactSize")) + { + ret = 1; + if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_COMPACT_SIZE; + } + else if (!stricmp(fieldName, "useDataReference")) + { + ret = 1; + if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_DATAREF; + } + else if (!stricmp(fieldName, "noFrameDrop")) + { + ret = 1; + if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_NO_FRAME_DROP; + } + else if (!stricmp(fieldName, "SBR_Type")) { + ret = 1; + if (!stricmp(val, "implicit") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_SBR_IMPLICIT; + else if (!stricmp(val, "explicit") || !stricmp(val, "2")) mi->import_flags |= GF_IMPORT_SBR_EXPLICIT; + } #endif /*GPAC_DISABLE_MEDIA_IMPORT*/ - else if (!stricmp(fieldName, "textNode")) GET_STRING(mi->textNode) - else if (!stricmp(fieldName, "fontNode")) GET_STRING(mi->fontNode) - else if (!stricmp(fieldName, "frameRate")) { ret = 1; mi->frame_rate = atof(val); } + else if (!stricmp(fieldName, "textNode")) GET_STRING(mi->textNode) + else if (!stricmp(fieldName, "fontNode")) GET_STRING(mi->fontNode) + else if (!stricmp(fieldName, "frameRate")) { + ret = 1; + mi->frame_rate = atof(val); + } } - break; + break; case GF_ODF_DSI_TAG: { GF_DefaultDescriptor *dsi = (GF_DefaultDescriptor*)desc; @@ -448,176 +561,182 @@ GF_Err gf_odf_set_field(GF_Descriptor *desc, char *fieldName, char *val) } } } - break; + break; case GF_ODF_SEGMENT_TAG: { GF_Segment *sd = (GF_Segment*)desc; if (!stricmp(fieldName, "start") || !stricmp(fieldName, "startTime")) GET_DOUBLE(sd->startTime) - else if (!stricmp(fieldName, "duration")) GET_DOUBLE(sd->Duration) - else if (!stricmp(fieldName, "name") || !stricmp(fieldName, "segmentName")) GET_STRING(sd->SegmentName) - } - break; + else if (!stricmp(fieldName, "duration")) GET_DOUBLE(sd->Duration) + else if (!stricmp(fieldName, "name") || !stricmp(fieldName, "segmentName")) GET_STRING(sd->SegmentName) + } + break; case GF_ODF_UI_CFG_TAG: { GF_UIConfig *uic = (GF_UIConfig*)desc; if (!stricmp(fieldName, "deviceName")) GET_STRING(uic->deviceName) - else if (!stricmp(fieldName, "termChar")) GET_U8(uic->termChar) - else if (!stricmp(fieldName, "delChar")) GET_U8(uic->delChar) - else if (!stricmp(fieldName, "uiData")) { - /*only parse true hexa strings*/ - if (val[0] == '%') { - OD_ParseBinData(val, &uic->ui_data, &uic->ui_data_length); - ret = 1; - } else if (!strnicmp(val, "file:", 5)) { - OD_ParseFileData(val+5, &uic->ui_data, &uic->ui_data_length); - ret = 1; - } else { - ret = OD_ParseUIConfig(val, &uic->ui_data, &uic->ui_data_length); - } - } + else if (!stricmp(fieldName, "termChar")) GET_U8(uic->termChar) + else if (!stricmp(fieldName, "delChar")) GET_U8(uic->delChar) + else if (!stricmp(fieldName, "uiData")) { + /*only parse true hexa strings*/ + if (val[0] == '%') { + OD_ParseBinData(val, &uic->ui_data, &uic->ui_data_length); + ret = 1; + } else if (!strnicmp(val, "file:", 5)) { + OD_ParseFileData(val+5, &uic->ui_data, &uic->ui_data_length); + ret = 1; + } else { + ret = OD_ParseUIConfig(val, &uic->ui_data, &uic->ui_data_length); + } + } } - break; + break; case GF_ODF_ESD_INC_TAG: { GF_ES_ID_Inc *inc = (GF_ES_ID_Inc *)desc; if (!stricmp(fieldName, "trackID")) ret += sscanf(val, "%u", &inc->trackID); } - break; + break; case GF_ODF_ESD_REF_TAG: { GF_ES_ID_Ref *inc = (GF_ES_ID_Ref *)desc; if (!stricmp(fieldName, "trackID")) ret += sscanf(val, "%hu", &inc->trackRef); } - break; + break; case GF_ODF_TEXT_CFG_TAG: { GF_TextConfig *txt = (GF_TextConfig*)desc; if (!stricmp(fieldName, "3GPPBaseFormat")) GET_U8(txt->Base3GPPFormat) - else if (!stricmp(fieldName, "MPEGExtendedFormat")) GET_U8(txt->MPEGExtendedFormat) - else if (!stricmp(fieldName, "profileLevel")) GET_U8(txt->profileLevel) - else if (!stricmp(fieldName, "durationClock") || !stricmp(fieldName, "timescale") ) GET_U32(txt->timescale) - else if (!stricmp(fieldName, "layer")) GET_U32(txt->layer) - else if (!stricmp(fieldName, "text_width")) GET_U32(txt->text_width) - else if (!stricmp(fieldName, "text_height")) GET_U32(txt->text_height) - else if (!stricmp(fieldName, "video_width")) { - GET_U32(txt->video_width) - txt->has_vid_info = 1; - } - else if (!stricmp(fieldName, "video_height")) { - GET_U32(txt->video_height) - txt->has_vid_info = 1; - } - else if (!stricmp(fieldName, "horizontal_offset")) { - GET_S16(txt->horiz_offset) - txt->has_vid_info = 1; - } - else if (!stricmp(fieldName, "vertical_offset")) { - GET_S32(txt->vert_offset) - txt->has_vid_info = 1; - } + else if (!stricmp(fieldName, "MPEGExtendedFormat")) GET_U8(txt->MPEGExtendedFormat) + else if (!stricmp(fieldName, "profileLevel")) GET_U8(txt->profileLevel) + else if (!stricmp(fieldName, "durationClock") || !stricmp(fieldName, "timescale") ) GET_U32(txt->timescale) + else if (!stricmp(fieldName, "layer")) GET_U32(txt->layer) + else if (!stricmp(fieldName, "text_width")) GET_U32(txt->text_width) + else if (!stricmp(fieldName, "text_height")) GET_U32(txt->text_height) + else if (!stricmp(fieldName, "video_width")) { + GET_U32(txt->video_width) + txt->has_vid_info = 1; + } + else if (!stricmp(fieldName, "video_height")) { + GET_U32(txt->video_height) + txt->has_vid_info = 1; + } + else if (!stricmp(fieldName, "horizontal_offset")) { + GET_S16(txt->horiz_offset) + txt->has_vid_info = 1; + } + else if (!stricmp(fieldName, "vertical_offset")) { + GET_S32(txt->vert_offset) + txt->has_vid_info = 1; + } } - break; + break; case GF_ODF_TX3G_TAG: { GF_TextSampleDescriptor *sd = (GF_TextSampleDescriptor*)desc; if (!stricmp(fieldName, "displayFlags")) GET_U32(sd->displayFlags) - else if (!stricmp(fieldName, "horiz_justif")) GET_S32(sd->horiz_justif) - else if (!stricmp(fieldName, "vert_justif")) GET_S32(sd->vert_justif) - else if (!stricmp(fieldName, "back_color")) GET_S32(sd->back_color) - else if (!stricmp(fieldName, "top")) GET_S32(sd->default_pos.top) - else if (!stricmp(fieldName, "bottom")) GET_S32(sd->default_pos.bottom) - else if (!stricmp(fieldName, "left")) GET_S32(sd->default_pos.left) - else if (!stricmp(fieldName, "right")) GET_S32(sd->default_pos.right) - else if (!stricmp(fieldName, "style_font_ID")) GET_S32(sd->default_style.fontID) - else if (!stricmp(fieldName, "style_font_size")) GET_S32(sd->default_style.font_size) - else if (!stricmp(fieldName, "style_text_color")) GET_U32(sd->default_style.text_color) - else if (!stricmp(fieldName, "style_flags")) { - char szStyles[1024]; - strcpy(szStyles, val); - strlwr(szStyles); - if (strstr(szStyles, "bold")) sd->default_style.style_flags |= GF_TXT_STYLE_BOLD; - if (strstr(szStyles, "italic")) sd->default_style.style_flags |= GF_TXT_STYLE_ITALIC; - if (strstr(szStyles, "underlined")) sd->default_style.style_flags |= GF_TXT_STYLE_UNDERLINED; - ret = 1; - } - else if (!stricmp(fieldName, "fontID") || !stricmp(fieldName, "fontName")) { - /*check if we need a new entry*/ - if (!sd->font_count) { - sd->fonts = (GF_FontRecord*)gf_malloc(sizeof(GF_FontRecord)); - sd->font_count = 1; - sd->fonts[0].fontID = 0; - sd->fonts[0].fontName = NULL; - } else { - Bool realloc_fonts = 0; - if (!stricmp(fieldName, "fontID") && sd->fonts[sd->font_count-1].fontID) realloc_fonts = 1; - else if (!stricmp(fieldName, "fontName") && sd->fonts[sd->font_count-1].fontName) realloc_fonts = 1; - if (realloc_fonts) { - sd->font_count += 1; - sd->fonts = (GF_FontRecord*)gf_realloc(sd->fonts, sizeof(GF_FontRecord)*sd->font_count); - sd->fonts[sd->font_count-1].fontID = 0; - sd->fonts[sd->font_count-1].fontName = NULL; - } - } - if (!stricmp(fieldName, "fontID")) GET_U32(sd->fonts[sd->font_count-1].fontID) - if (!stricmp(fieldName, "fontName")) GET_STRING(sd->fonts[sd->font_count-1].fontName) - ret = 1; - } + else if (!stricmp(fieldName, "horiz_justif")) GET_S32(sd->horiz_justif) + else if (!stricmp(fieldName, "vert_justif")) GET_S32(sd->vert_justif) + else if (!stricmp(fieldName, "back_color")) GET_S32(sd->back_color) + else if (!stricmp(fieldName, "top")) GET_S32(sd->default_pos.top) + else if (!stricmp(fieldName, "bottom")) GET_S32(sd->default_pos.bottom) + else if (!stricmp(fieldName, "left")) GET_S32(sd->default_pos.left) + else if (!stricmp(fieldName, "right")) GET_S32(sd->default_pos.right) + else if (!stricmp(fieldName, "style_font_ID")) GET_S32(sd->default_style.fontID) + else if (!stricmp(fieldName, "style_font_size")) GET_S32(sd->default_style.font_size) + else if (!stricmp(fieldName, "style_text_color")) GET_U32(sd->default_style.text_color) + else if (!stricmp(fieldName, "style_flags")) { + char szStyles[1024]; + strcpy(szStyles, val); + strlwr(szStyles); + if (strstr(szStyles, "bold")) sd->default_style.style_flags |= GF_TXT_STYLE_BOLD; + if (strstr(szStyles, "italic")) sd->default_style.style_flags |= GF_TXT_STYLE_ITALIC; + if (strstr(szStyles, "underlined")) sd->default_style.style_flags |= GF_TXT_STYLE_UNDERLINED; + ret = 1; + } + else if (!stricmp(fieldName, "fontID") || !stricmp(fieldName, "fontName")) { + /*check if we need a new entry*/ + if (!sd->font_count) { + sd->fonts = (GF_FontRecord*)gf_malloc(sizeof(GF_FontRecord)); + sd->font_count = 1; + sd->fonts[0].fontID = 0; + sd->fonts[0].fontName = NULL; + } else { + Bool realloc_fonts = 0; + if (!stricmp(fieldName, "fontID") && sd->fonts[sd->font_count-1].fontID) realloc_fonts = 1; + else if (!stricmp(fieldName, "fontName") && sd->fonts[sd->font_count-1].fontName) realloc_fonts = 1; + if (realloc_fonts) { + sd->font_count += 1; + sd->fonts = (GF_FontRecord*)gf_realloc(sd->fonts, sizeof(GF_FontRecord)*sd->font_count); + sd->fonts[sd->font_count-1].fontID = 0; + sd->fonts[sd->font_count-1].fontName = NULL; + } + } + if (!stricmp(fieldName, "fontID")) GET_U32(sd->fonts[sd->font_count-1].fontID) + if (!stricmp(fieldName, "fontName")) GET_STRING(sd->fonts[sd->font_count-1].fontName) + ret = 1; + } } - break; + break; case GF_ODF_IPMP_TAG: { GF_IPMP_Descriptor *ipmp = (GF_IPMP_Descriptor*)desc; if (!stricmp(fieldName, "IPMP_DescriptorID")) GET_U8(ipmp->IPMP_DescriptorID) - else if (!stricmp(fieldName, "IPMPS_Type")) GET_U16(ipmp->IPMPS_Type) - else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) GET_U16(ipmp->IPMP_DescriptorIDEx) - else if (!stricmp(fieldName, "IPMP_ToolID")) { ret = 1; OD_ParseBin128(val, &ipmp->IPMP_ToolID); } - else if (!stricmp(fieldName, "controlPointCode")) GET_U8(ipmp->control_point) - else if (!stricmp(fieldName, "sequenceCode")) GET_U8(ipmp->cp_sequence_code) - } - break; + else if (!stricmp(fieldName, "IPMPS_Type")) GET_U16(ipmp->IPMPS_Type) + else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) GET_U16(ipmp->IPMP_DescriptorIDEx) + else if (!stricmp(fieldName, "IPMP_ToolID")) { + ret = 1; + OD_ParseBin128(val, &ipmp->IPMP_ToolID); + } + else if (!stricmp(fieldName, "controlPointCode")) GET_U8(ipmp->control_point) + else if (!stricmp(fieldName, "sequenceCode")) GET_U8(ipmp->cp_sequence_code) + } + break; case GF_ODF_IPMP_PTR_TAG: { GF_IPMPPtr *ipmpd = (GF_IPMPPtr*)desc; if (!stricmp(fieldName, "IPMP_DescriptorID")) GET_U8(ipmpd->IPMP_DescriptorID) - else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) ret += sscanf(val, "%hu", &ipmpd->IPMP_DescriptorIDEx); - else if (!stricmp(fieldName, "IPMP_ES_ID")) ret += sscanf(val, "%hu", &ipmpd->IPMP_ES_ID); + else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) ret += sscanf(val, "%hu", &ipmpd->IPMP_DescriptorIDEx); + else if (!stricmp(fieldName, "IPMP_ES_ID")) ret += sscanf(val, "%hu", &ipmpd->IPMP_ES_ID); } - break; + break; case GF_ODF_LANG_TAG: - { - GF_Language *ld = (GF_Language *)desc; - if (!stricmp(fieldName, "languageCode")) { - u32 li, l = (u32) strlen(val); - ld->langCode = 0; - for (li = 0; li < l; li++) { - /* Warning: sensitive to big endian, little endian */ - ld->langCode |= (val[li] << (l-li-1)*8); - } - ret++; + { + GF_Language *ld = (GF_Language *)desc; + if (!stricmp(fieldName, "languageCode")) { + u32 li, l = (u32) strlen(val); + ld->langCode = 0; + for (li = 0; li < l; li++) { + /* Warning: sensitive to big endian, little endian */ + ld->langCode |= (val[li] << (l-li-1)*8); } + ret++; } - break; + } + break; case GF_ODF_AUX_VIDEO_DATA: { GF_AuxVideoDescriptor *avd = (GF_AuxVideoDescriptor *)desc; if (!stricmp(fieldName, "aux_video_type")) GET_U8(avd->aux_video_type) - if (!stricmp(fieldName, "position_offset_h")) GET_U8(avd->aux_video_type) - if (!stricmp(fieldName, "position_offset_v")) GET_U8(avd->aux_video_type) - if (!stricmp(fieldName, "knear")) GET_U8(avd->aux_video_type) - if (!stricmp(fieldName, "kfar")) GET_U8(avd->aux_video_type) - if (!stricmp(fieldName, "parallax_zero")) GET_U16(avd->aux_video_type) - if (!stricmp(fieldName, "parallax_scale")) GET_U16(avd->aux_video_type) - if (!stricmp(fieldName, "dref")) GET_U16(avd->aux_video_type) - if (!stricmp(fieldName, "wref")) GET_U16(avd->aux_video_type) - } - break; + if (!stricmp(fieldName, "position_offset_h")) GET_U8(avd->aux_video_type) + if (!stricmp(fieldName, "position_offset_v")) GET_U8(avd->aux_video_type) + if (!stricmp(fieldName, "knear")) GET_U8(avd->aux_video_type) + if (!stricmp(fieldName, "kfar")) GET_U8(avd->aux_video_type) + if (!stricmp(fieldName, "parallax_zero")) GET_U16(avd->aux_video_type) + if (!stricmp(fieldName, "parallax_scale")) GET_U16(avd->aux_video_type) + if (!stricmp(fieldName, "dref")) GET_U16(avd->aux_video_type) + if (!stricmp(fieldName, "wref")) GET_U16(avd->aux_video_type) + } + break; case GF_ODF_IPMP_TOOL_TAG: { GF_IPMP_Tool *it = (GF_IPMP_Tool*)desc; - if (!stricmp(fieldName, "IPMP_ToolID")) { ret = 1; OD_ParseBin128(val, &it->IPMP_ToolID); } + if (!stricmp(fieldName, "IPMP_ToolID")) { + ret = 1; + OD_ParseBin128(val, &it->IPMP_ToolID); + } else if (!stricmp(fieldName, "ToolURL")) GET_STRING(it->tool_url) - } - break; + } + break; } return ret ? GF_OK : GF_BAD_PARAM; @@ -655,7 +774,7 @@ Bool OD_ParseUIConfig(char *val, char **out_data, u32 *out_data_size) continue; } if (pos>0) { - + nb_phonems ++; /*would be nicer with a phone book & use indexes*/ if (!stricmp(szItem, "vcl")) { diff --git a/src/odf/qos.c b/src/odf/qos.c index a7a8fd7..32bf1a8 100644 --- a/src/odf/qos.c +++ b/src/odf/qos.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -122,7 +122,7 @@ GF_Err gf_odf_write_qos_qual(GF_BitStream *bs, GF_QoS_Default *qos) { GF_Err e; if (!bs || !qos) return GF_BAD_PARAM; - + e = gf_odf_size_qos_qual(qos); if (e) return e; e = gf_odf_write_base_descriptor(bs, qos->tag, qos->size); @@ -365,7 +365,7 @@ GF_Err gf_odf_read_qos(GF_BitStream *bs, GF_QoS_Descriptor *qos, u32 DescSize) nbBytes += 1; if (qos->predefined) { - if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR; + if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR; return GF_OK; } @@ -394,9 +394,9 @@ GF_Err gf_odf_size_qos(GF_QoS_Descriptor *qos, u32 *outSize) GF_QoS_Default *tmp; if (!qos) return GF_BAD_PARAM; - + *outSize = 1; - + i=0; while ((tmp = (GF_QoS_Default *)gf_list_enum(qos->QoS_Qualifiers, &i))) { e = gf_odf_size_qos_qual(tmp); diff --git a/src/odf/slc.c b/src/odf/slc.c index 462df90..a4d43a4 100644 --- a/src/odf/slc.c +++ b/src/odf/slc.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -130,18 +130,18 @@ u32 SLIsPredefined(GF_SLConfig *sl) if (sl->predefined) return sl->predefined; if (!sl->useAccessUnitStartFlag - && !sl->useAccessUnitEndFlag - && !sl->usePaddingFlag - && sl->useTimestampsFlag - && !sl->useIdleFlag - && !sl->durationFlag - && !sl->timestampLength - && !sl->OCRLength - && !sl->AULength - && !sl->instantBitrateLength - && !sl->degradationPriorityLength - && !sl->AUSeqNumLength - && !sl->packetSeqNumLength) + && !sl->useAccessUnitEndFlag + && !sl->usePaddingFlag + && sl->useTimestampsFlag + && !sl->useIdleFlag + && !sl->durationFlag + && !sl->timestampLength + && !sl->OCRLength + && !sl->AULength + && !sl->instantBitrateLength + && !sl->degradationPriorityLength + && !sl->AUSeqNumLength + && !sl->packetSeqNumLength) return SLPredef_MP4; return 0; @@ -167,7 +167,7 @@ GF_Err gf_odf_read_slc(GF_BitStream *bs, GF_SLConfig *sl, u32 DescSize) { GF_Err e; u32 nbBytes = 0; - + if (!sl) return GF_BAD_PARAM; //APPLE fix @@ -207,7 +207,7 @@ GF_Err gf_odf_read_slc(GF_BitStream *bs, GF_SLConfig *sl, u32 DescSize) sl->OCRLength = gf_bs_read_int(bs, 8); if (sl->OCRLength > 64) return GF_ODF_INVALID_DESCRIPTOR; - + sl->AULength = gf_bs_read_int(bs, 8); if (sl->AULength > 32) return GF_ODF_INVALID_DESCRIPTOR; @@ -217,7 +217,7 @@ GF_Err gf_odf_read_slc(GF_BitStream *bs, GF_SLConfig *sl, u32 DescSize) if (sl->AUSeqNumLength > 16) return GF_ODF_INVALID_DESCRIPTOR; sl->packetSeqNumLength = gf_bs_read_int(bs, 5); if (sl->packetSeqNumLength > 16) return GF_ODF_INVALID_DESCRIPTOR; - + /*reserved = */gf_bs_read_int(bs, 2); nbBytes += 15; } @@ -233,7 +233,7 @@ GF_Err gf_odf_read_slc(GF_BitStream *bs, GF_SLConfig *sl, u32 DescSize) sl->startCTS = gf_bs_read_long_int(bs, sl->timestampLength); nbBytes += GetTSbytesLen(sl); } - + if (DescSize != nbBytes) return GF_ODF_INVALID_DESCRIPTOR; return GF_OK; } @@ -297,7 +297,7 @@ GF_Err gf_odf_write_slc(GF_BitStream *bs, GF_SLConfig *sl) gf_bs_write_long_int(bs, sl->startDTS, sl->timestampLength); gf_bs_write_long_int(bs, sl->startCTS, sl->timestampLength); } - + return GF_OK; } @@ -305,12 +305,12 @@ GF_Err gf_odf_write_slc(GF_BitStream *bs, GF_SLConfig *sl) /*allocates and writes the SL-PDU (Header + PDU) given the SLConfig and the GF_SLHeader for this PDU. AUs must be split in PDUs by another process if needed (packetizer).*/ GF_EXPORT -void gf_sl_packetize(GF_SLConfig* slConfig, - GF_SLHeader *Header, - char *PDU, - u32 size, - char **outPacket, - u32 *OutSize) +void gf_sl_packetize(GF_SLConfig* slConfig, + GF_SLHeader *Header, + char *PDU, + u32 size, + char **outPacket, + u32 *OutSize) { GF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); *OutSize = 0; @@ -438,8 +438,8 @@ void gf_sl_depacketize (GF_SLConfig *slConfig, GF_SLHeader *Header, const char * Header->compositionTimeStampFlag = gf_bs_read_int(bs, 1); } if (slConfig->instantBitrateLength > 0) Header->instantBitrateFlag = gf_bs_read_int(bs, 1); - if (Header->decodingTimeStampFlag) Header->decodingTimeStamp = gf_bs_read_long_int(bs, slConfig->timestampLength); - if (Header->compositionTimeStampFlag) Header->compositionTimeStamp = gf_bs_read_long_int(bs, slConfig->timestampLength); + if (Header->decodingTimeStampFlag) Header->decodingTimeStamp = gf_bs_read_long_int(bs, slConfig->timestampLength); + if (Header->compositionTimeStampFlag) Header->compositionTimeStamp = gf_bs_read_long_int(bs, slConfig->timestampLength); if (slConfig->AULength > 0) Header->accessUnitLength = gf_bs_read_int(bs, slConfig->AULength); if (Header->instantBitrateFlag) Header->instantBitrate = gf_bs_read_int(bs, slConfig->instantBitrateLength); } diff --git a/src/scene_manager/encode_isom.c b/src/scene_manager/encode_isom.c index 6b37b2a..0dae42a 100644 --- a/src/scene_manager/encode_isom.c +++ b/src/scene_manager/encode_isom.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -53,7 +53,7 @@ static void gf_sm_remove_mux_info(GF_ESD *src) static void gf_sm_finalize_mux(GF_ISOFile *mp4, GF_ESD *src, u32 offset_ts) { -#if !defined (GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_ISOM_WRITE) +#if !defined (GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_ISOM_WRITE) u32 track, mts, ts; GF_MuxInfo *mux = gf_sm_get_mux_info(src); if (!mux && !offset_ts) return; @@ -75,7 +75,7 @@ static void gf_sm_finalize_mux(GF_ISOFile *mp4, GF_ESD *src, u32 offset_ts) if (mux) { if (mux->GroupID) gf_isom_set_track_group(mp4, track, mux->GroupID); #ifndef GPAC_DISABLE_MEDIA_IMPORT - if (mux->import_flags & GF_IMPORT_USE_COMPACT_SIZE) + if (mux->import_flags & GF_IMPORT_USE_COMPACT_SIZE) gf_isom_use_compact_size(mp4, track, 1); #endif } @@ -186,7 +186,7 @@ static GF_Err gf_sm_import_stream(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_ESD /*special streams*/ if (src->decoderConfig) { /*InputSensor*/ - if (src->decoderConfig->decoderSpecificInfo && (src->decoderConfig->decoderSpecificInfo->tag == GF_ODF_UI_CFG_TAG)) + if (src->decoderConfig->decoderSpecificInfo && (src->decoderConfig->decoderSpecificInfo->tag == GF_ODF_UI_CFG_TAG)) src->decoderConfig->streamType = GF_STREAM_INTERACT; if (src->decoderConfig->streamType == GF_STREAM_INTERACT) return gf_sm_import_ui_stream(mp4, src, 0); } @@ -202,7 +202,7 @@ static GF_Err gf_sm_import_stream(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_ESD src->slConfig->predefined = 2; e = gf_isom_new_mpeg4_description(mp4, track, src, NULL, NULL, &di); if (e) return e; - if (mux && mux->duration) + if (mux && mux->duration) e = gf_isom_set_edit_segment(mp4, track, 0, mux->duration * gf_isom_get_timescale(mp4) / 1000, 0, GF_ISOM_EDIT_NORMAL); return e; } @@ -229,7 +229,7 @@ static GF_Err gf_sm_import_stream(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_ESD memset(&import, 0, sizeof(GF_MediaImporter)); strcpy(szName, mux->file_name); - ext = strrchr(szName, '.'); + ext = strrchr(szName, '.'); /*get track types for AVI*/ if (ext && !strnicmp(ext, ".avi", 4)) { @@ -291,9 +291,9 @@ static GF_Err gf_sm_import_stream_special(GF_SceneManager *ctx, GF_ESD *esd) GF_Err e; GF_MuxInfo *mux = gf_sm_get_mux_info(esd); if (!mux || !mux->file_name) return GF_OK; - + if (esd->decoderConfig && esd->decoderConfig->decoderSpecificInfo - && (esd->decoderConfig->decoderSpecificInfo->tag==GF_ODF_TEXT_CFG_TAG)) return GF_OK; + && (esd->decoderConfig->decoderSpecificInfo->tag==GF_ODF_TEXT_CFG_TAG)) return GF_OK; e = GF_OK; /*SRT/SUB BIFS import if text node unspecified*/ @@ -334,7 +334,7 @@ static GF_Err gf_sm_import_specials(GF_SceneManager *ctx) } } } - break; + break; case GF_ODF_ESD_UPDATE_TAG: { GF_ESD *imp_esd; @@ -345,7 +345,7 @@ static GF_Err gf_sm_import_specials(GF_SceneManager *ctx) if (e != GF_OK) return e; } } - break; + break; } } } @@ -386,7 +386,7 @@ static GF_ESD *gf_sm_locate_esd(GF_SceneManager *ctx, u16 ES_ID) } } } - break; + break; case GF_ODF_ESD_UPDATE_TAG: { GF_ESD *imp_esd; @@ -396,7 +396,7 @@ static GF_ESD *gf_sm_locate_esd(GF_SceneManager *ctx, u16 ES_ID) if (imp_esd->ESID == ES_ID) return imp_esd; } } - break; + break; } } } @@ -497,7 +497,7 @@ static GF_Err gf_sm_encode_scene(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_SMEnc return GF_NOT_SUPPORTED; #endif } - + if (scene_type==1) { #ifndef GPAC_DISABLE_LASER lsr_enc = gf_laser_encoder_new(ctx->scene_graph); @@ -560,7 +560,7 @@ static GF_Err gf_sm_encode_scene(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_SMEnc if ((com->tag == GF_SG_SCENE_REPLACE) && !com->node && !gf_list_count(com->new_proto_list)) au = NULL; } - } + } /*sanity check: remove first command if it is REPLACE SCENE BY NULL*/ if (au && !au->timing && !au->timing_sec && (gf_list_count(au->commands) > 1)) { @@ -597,7 +597,7 @@ force_scene_rap: esd->ESID = sc ? sc->ESID : 1; esd->decoderConfig->streamType = GF_STREAM_SCENE; } - + if (!esd->slConfig) esd->slConfig = (GF_SLConfig *) gf_odf_desc_new(GF_ODF_SLC_TAG); if (sc && sc->timeScale) esd->slConfig->timestampResolution = sc->timeScale; if (!esd->slConfig->timestampResolution) esd->slConfig->timestampResolution = 1000; @@ -660,9 +660,9 @@ force_scene_rap: gf_bifs_encoder_get_config(bifs_enc, esd->ESID, &data, &data_len); esd->decoderConfig->decoderSpecificInfo->data = data; esd->decoderConfig->decoderSpecificInfo->dataLength = data_len; - esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(bifs_enc, esd->ESID); + esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(bifs_enc, esd->ESID); #endif - } + } /*LASeR setup*/ #ifndef GPAC_DISABLE_LASER if (scene_type==1) { @@ -711,7 +711,7 @@ force_scene_rap: if (!sc) { samp = gf_isom_sample_new(); samp->IsRAP = 1; - + #ifndef GPAC_DISABLE_BIFS_ENC if (bifs_enc) e = gf_bifs_encoder_get_rap(bifs_enc, &samp->data, &samp->dataLength); @@ -788,7 +788,7 @@ force_scene_rap: if (lsr_enc) e = gf_laser_encoder_get_rap(lsr_enc, &rap_sample->data, &rap_sample->dataLength); #endif - + rap_sample->DTS = last_rap + rap_delay; rap_sample->IsRAP = 1; last_rap = rap_sample->DTS; @@ -807,7 +807,7 @@ force_scene_rap: } /*apply commands */ - if (samp->DTS > last_rap + rap_delay) { + if (samp->DTS > last_rap + rap_delay) { e = gf_sg_command_apply_list(ctx->scene_graph, au->commands, 0); } } @@ -817,7 +817,7 @@ force_scene_rap: if (samp->DTS - last_rap > rap_delay) { GF_ISOSample *car_samp = gf_isom_sample_new(); u64 r_dts = samp->DTS; - + /*then get RAP*/ #ifndef GPAC_DISABLE_BIFS_ENC if (bifs_enc) @@ -828,7 +828,7 @@ force_scene_rap: if (lsr_enc) e = gf_laser_encoder_get_rap(lsr_enc, &car_samp->data, &car_samp->dataLength); #endif - car_samp->IsRAP = 2; + car_samp->IsRAP = 2; while (1) { car_samp->DTS = last_rap+rap_delay; if (car_samp->DTS==prev_dts) car_samp->DTS++; @@ -856,7 +856,7 @@ force_scene_rap: rate = 0; time_slice = samp->DTS; } - + prev_dts = samp->DTS; gf_isom_sample_del(&samp); if (e) goto exit; @@ -974,7 +974,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media delete_desc = 0; i=0; - while ((sc = (GF_StreamContext*)gf_list_enum(ctx->streams, &i))){ + while ((sc = (GF_StreamContext*)gf_list_enum(ctx->streams, &i))) { if (sc->streamType != GF_STREAM_OD) continue; delete_desc = 0; @@ -984,7 +984,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media is_in_iod = 0; j=0; while ((esd = (GF_ESD*)gf_list_enum(iod->ESDescriptors, &j))) { - if (esd->decoderConfig->streamType != GF_STREAM_OD){ + if (esd->decoderConfig->streamType != GF_STREAM_OD) { esd = NULL; continue; } @@ -1024,7 +1024,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media rap_codec = gf_odf_codec_new(); rap_delay = opts->rap_freq * esd->slConfig->timestampResolution / 1000; } - + dur = avg_rate = 0; esd->decoderConfig->bufferSizeDB = 0; @@ -1067,7 +1067,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media switch (imp_esd->decoderConfig->streamType) { case GF_STREAM_SCENE: /*import AFX streams, but not others*/ - if (imp_esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_AFX) + if (imp_esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_AFX) break; continue; case GF_STREAM_OD: @@ -1102,7 +1102,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media } } } - break; + break; case GF_ODF_ESD_UPDATE_TAG: { GF_ESD *imp_esd; @@ -1134,7 +1134,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media } } } - break; + break; } /*add to codec*/ @@ -1276,7 +1276,7 @@ static GF_Err gf_sm_encode_od(GF_SceneManager *ctx, GF_ISOFile *mp4, char *media } } e = gf_isom_set_pl_indication(mp4, GF_ISOM_PL_OD, 1); - + err_exit: if (codec) gf_odf_codec_del(codec); if (rap_codec) gf_odf_codec_del(rap_codec); diff --git a/src/scene_manager/loader_bt.c b/src/scene_manager/loader_bt.c index c5a86a6..08284f3 100644 --- a/src/scene_manager/loader_bt.c +++ b/src/scene_manager/loader_bt.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -180,11 +181,18 @@ next_line: c2 = gzgetc(parser->gz_in); /*Little-endian order*/ if (parser->unicode_type==2) { - if (c2) { wchar = c2; wchar <<=8; wchar |= c1; } + if (c2) { + wchar = c2; + wchar <<=8; + wchar |= c1; + } else wchar = c1; } else { wchar = c1; - if (c2) { wchar <<= 8; wchar |= c2;} + if (c2) { + wchar <<= 8; + wchar |= c2; + } } *dst = wchar; if (wchar=='\r') is_ret = 1; @@ -228,7 +236,7 @@ next_line: } } else { if ((gzgets(parser->gz_in, parser->line_buffer, BT_LINE_SIZE) == NULL) - || (!strlen(parser->line_buffer) && gzeof(parser->gz_in))) { + || (!strlen(parser->line_buffer) && gzeof(parser->gz_in))) { parser->done = 1; return; } @@ -282,7 +290,7 @@ next_line: while ((parser->line_buffer[parser->line_pos]==' ') || (parser->line_buffer[parser->line_pos]=='\t')) parser->line_pos++; if ( (parser->line_buffer[parser->line_pos]=='#') - || ( (parser->line_buffer[parser->line_pos]=='/') && (parser->line_buffer[parser->line_pos+1]=='/')) ) { + || ( (parser->line_buffer[parser->line_pos]=='/') && (parser->line_buffer[parser->line_pos+1]=='/')) ) { if (parser->line==1) { if (strstr(parser->line_buffer, "VRML")) { @@ -467,7 +475,7 @@ char *gf_bt_get_string(GF_BTParser *parser, u8 string_delim) res = (char*)gf_realloc(res, sizeof(char) * (size+500+1)); \ size += 500; \ } \ - + res = (char*)gf_malloc(sizeof(char) * 500); size = 500; while (parser->line_buffer[parser->line_pos]==' ') parser->line_pos++; @@ -505,23 +513,35 @@ char *gf_bt_get_string(GF_BTParser *parser, u8 string_delim) } /*UTF8 2 bytes char*/ else if ( (c & 0xe0) == 0xc0) { - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC } /*UTF8 3 bytes char*/ else if ( (c & 0xf0) == 0xe0) { - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC } /*UTF8 4 bytes char*/ else if ( (c & 0xf8) == 0xf0) { - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC - res[i] = parser->line_buffer[parser->line_pos]; parser->line_pos++; i++; + res[i] = parser->line_buffer[parser->line_pos]; + parser->line_pos++; + i++; BT_STR_CHECK_ALLOC } } @@ -773,7 +793,7 @@ static void gf_bt_update_timenode(GF_BTParser *parser, GF_Node *node) gf_bt_check_time_offset(parser, node, &inf); } } - break; + break; } } @@ -881,7 +901,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) goto err; } } - break; + break; case GF_SG_VRML_SFURL: { u8 delim = 0; @@ -921,7 +941,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) ((SFURL *)info->far_ptr)->OD_ID = val; } } - break; + break; case GF_SG_VRML_SFCOMMANDBUFFER: { SFCommandBuffer *cb = (SFCommandBuffer *)info->far_ptr; @@ -934,7 +954,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) parser->cur_com = prev_com; } } - break; + break; case GF_SG_VRML_SFIMAGE: { u32 i, size, v; @@ -979,7 +999,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) } } } - break; + break; case GF_SG_VRML_SFSCRIPT: { SFScript *sc = (SFScript *) info->far_ptr; @@ -988,7 +1008,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) } sc->script_text = (char*)gf_bt_get_string(parser, '\"'); } - break; + break; case GF_SG_VRML_SFATTRREF: { SFAttrRef *ar = (SFAttrRef*) info->far_ptr; @@ -1007,7 +1027,7 @@ void gf_bt_sffield(GF_BTParser *parser, GF_FieldInfo *info, GF_Node *n) } } - break; + break; default: parser->last_error = GF_NOT_SUPPORTED; break; @@ -1113,12 +1133,12 @@ u32 gf_bt_get_def_id(GF_BTParser *parser, char *defName) return ID; } } - } + } ID = gf_bt_get_next_node_id(parser); if (n) { GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[BT Parsing] (line %d) Binary ID %d already assigned to %s - keeping internal ID %d", parser->line, gf_node_get_name(n), ID)); - } + } return ID; } @@ -1180,7 +1200,7 @@ u32 gf_bt_get_node_tag(GF_BTParser *parser, char *node_name) if (parser->is_wrl && !(parser->load->flags & GF_SM_LOAD_MPEG4_STRICT)) { #ifndef GPAC_DISABLE_X3D tag = gf_node_x3d_type_by_class_name(node_name); - if (!tag) + if (!tag) #endif tag = gf_node_mpeg4_type_by_class_name(node_name); if (tag) return tag; @@ -1293,11 +1313,11 @@ GF_Node *gf_bt_sf_node(GF_BTParser *parser, char *node_name, GF_Node *parent, ch if (!parser->parsing_proto) init_node = 1; } is_script = 0; - if ((tag==TAG_MPEG4_Script) + if ((tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (tag==TAG_X3D_Script) + || (tag==TAG_X3D_Script) #endif - ) + ) is_script = 1; if (!node) { @@ -1394,14 +1414,14 @@ GF_Node *gf_bt_sf_node(GF_BTParser *parser, char *node_name, GF_Node *parent, ch str = "children"; parser->last_error = gf_node_get_field_by_name(node, str, &info); } - else + else #endif - if (!strcmp(str, "collide")) { - SFBool b; - gf_bt_parse_bool(parser, "enabled", &b); - parser->last_error = GF_OK; - continue; - } + if (!strcmp(str, "collide")) { + SFBool b; + gf_bt_parse_bool(parser, "enabled", &b); + parser->last_error = GF_OK; + continue; + } } } @@ -1481,7 +1501,7 @@ GF_Node *gf_bt_sf_node(GF_BTParser *parser, char *node_name, GF_Node *parent, ch if (single_child) break; } } - break; + break; default: if (gf_sg_vrml_is_sf_field(info.fieldType)) { gf_bt_sffield(parser, &info, node); @@ -2035,7 +2055,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis com = NULL; pos = -2; /*REPLACE commands*/ - if (!strcmp(str, "REPLACE")) { + if (!strcmp(str, "REPLACE")) { str = gf_bt_get_next(parser, 1); if (!strcmp(str, "ROUTE")) { str = gf_bt_get_next(parser, 0); @@ -2147,7 +2167,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis gf_node_list_add_child_last(& inf->node_list, newnode, &last); } } - break; + break; default: inf->field_ptr = gf_sg_vrml_field_pointer_new(info.fieldType); info.far_ptr = inf->field_ptr; @@ -2181,7 +2201,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis if (!gf_bt_check_ndt(parser, &info, newnode, n)) goto err; inf->new_node = newnode; inf->field_ptr = &inf->new_node; - break; + break; default: info.fieldType = inf->fieldType; info.far_ptr = inf->field_ptr = gf_sg_vrml_field_pointer_new(inf->fieldType); @@ -2194,13 +2214,13 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis return parser->last_error; } /*XREPLACE commands*/ - if (!strcmp(str, "XREPLACE")) { + if (!strcmp(str, "XREPLACE")) { u32 j; Bool force_sf=0; char csep; GF_Node *targetNode, *idxNode, *childNode, *fromNode; GF_FieldInfo targetField, idxField, childField, fromField; - + targetNode = idxNode = childNode = fromNode = NULL; str = gf_bt_get_next(parser, 1); /*get source node*/ @@ -2230,7 +2250,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis /*get idx node*/ idxNode = gf_bt_peek_node(parser, str); if (!idxNode) return gf_bt_report(parser, GF_BAD_PARAM, "%s: unknown node", field); - if (!gf_bt_check_code(parser, '.')) + if (!gf_bt_check_code(parser, '.')) return gf_bt_report(parser, GF_BAD_PARAM, "XREPLACE: '.' expected"); /*get idx field*/ @@ -2242,7 +2262,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis } } gf_bt_check_code(parser, ']'); - + /*check if we have a child node*/ if (gf_bt_check_code(parser, '.')) { s32 apos = pos; @@ -2365,7 +2385,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis gf_node_list_add_child_last(& inf->node_list, newnode, &last); } } - break; + break; default: inf->field_ptr = gf_sg_vrml_field_pointer_new(inf->fieldType); info.far_ptr = inf->field_ptr; @@ -2597,7 +2617,7 @@ GF_Err gf_bt_parse_bifs_command(GF_BTParser *parser, char *name, GF_List *cmdLis gf_node_list_add_child_last( & inf->node_list, newnode, &last); } } - break; + break; default: info.far_ptr = inf->field_ptr = gf_sg_vrml_field_pointer_new(inf->fieldType); if (gf_sg_vrml_is_sf_field(info.fieldType)) { @@ -2936,7 +2956,7 @@ GF_Descriptor *gf_bt_parse_descriptor(GF_BTParser *parser, char *name) } } break; - /*IPMPX*/ + /*IPMPX*/ case GF_ODF_FT_IPMPX: if(desc->tag!=GF_ODF_IPMP_TOOL_TAG) { gf_bt_report(parser, GF_BAD_PARAM, "IPMPX_Data only allowed in GF_IPMP_Tool"); @@ -3043,7 +3063,7 @@ GF_Descriptor *gf_bt_parse_descriptor(GF_BTParser *parser, char *name) } else if (desc->tag==GF_ODF_MUXINFO_TAG) { GF_MuxInfo *mi = (GF_MuxInfo *)desc; if (mi->file_name) { - char *res_name = gf_url_concatenate(parser->load->fileName, mi->file_name); + char *res_name = gf_url_concatenate(parser->load->fileName, (const char *) mi->file_name); if (res_name) { gf_free(mi->file_name); mi->file_name = res_name; @@ -3066,7 +3086,7 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) GF_ODUpdate *odU; if (!gf_bt_check_code(parser, '[')) { gf_bt_report(parser, GF_BAD_PARAM, "[ expected"); - return; + return; } odU = (GF_ODUpdate *) gf_odf_com_new(GF_ODF_OD_UPDATE_TAG); gf_list_add(parser->od_au->commands, odU); @@ -3089,7 +3109,7 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) str = gf_bt_get_next(parser, 0); if (strcmp(str, "IN")) { gf_bt_report(parser, GF_BAD_PARAM, "IN expected got %s", str); - return; + return; } esdU = (GF_ESDUpdate *) gf_odf_com_new(GF_ODF_ESD_UPDATE_TAG); parser->last_error = gf_bt_parse_int(parser, "OD_ID", (SFInt32*)&val); @@ -3101,11 +3121,11 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) str = gf_bt_get_next(parser, 0); if (strcmp(str, "esDescr")) { gf_bt_report(parser, GF_BAD_PARAM, "esDescr expected got %s", str); - return; + return; } if (!gf_bt_check_code(parser, '[')) { gf_bt_report(parser, GF_BAD_PARAM, "[ expected"); - return; + return; } } @@ -3127,7 +3147,7 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) GF_IPMPUpdate *ipU; if (!gf_bt_check_code(parser, '[')) { gf_bt_report(parser, GF_BAD_PARAM, "[ expected"); - return; + return; } ipU = (GF_IPMPUpdate *) gf_odf_com_new(GF_ODF_IPMP_UPDATE_TAG); gf_list_add(parser->od_au->commands, ipU); @@ -3154,7 +3174,7 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) GF_ODRemove *odR; if (!gf_bt_check_code(parser, '[')) { gf_bt_report(parser, GF_BAD_PARAM, "[ expected"); - return; + return; } odR = (GF_ODRemove *) gf_odf_com_new(GF_ODF_OD_REMOVE_TAG); gf_list_add(parser->od_au->commands, odR); @@ -3176,14 +3196,14 @@ void gf_bt_parse_od_command(GF_BTParser *parser, char *name) str = gf_bt_get_next(parser, 0); if (strcmp(str, "FROM")) { gf_bt_report(parser, GF_BAD_PARAM, "FROM expected got %s", str); - return; + return; } gf_bt_parse_int(parser, "ODID", (SFInt32*)&odid); if (parser->last_error) return; if (!gf_bt_check_code(parser, '[')) { gf_bt_report(parser, GF_BAD_PARAM, "[ expected"); - return; + return; } esdR = (GF_ESDRemove *) gf_odf_com_new(GF_ODF_ESD_REMOVE_TAG); esdR->ODID = odid; @@ -3217,7 +3237,7 @@ GF_Err gf_bt_loader_run_intern(GF_BTParser *parser, GF_Command *init_com, Bool i vrml_root_node = NULL; has_id = 0; - + if (init_com) parser->in_com = 0 ; @@ -3369,10 +3389,10 @@ GF_Err gf_bt_loader_run_intern(GF_BTParser *parser, GF_Command *init_com, Bool i } /*BIFS commands*/ else if (!strcmp(str, "REPLACE") || !strcmp(str, "INSERT") || !strcmp(str, "APPEND") || !strcmp(str, "DELETE") - /*BIFS extended commands*/ - || !strcmp(str, "GLOBALQP") || !strcmp(str, "MULTIPLEREPLACE") || !strcmp(str, "MULTIPLEINDREPLACE") || !strcmp(str, "XDELETE") || !strcmp(str, "DELETEPROTO") || !strcmp(str, "INSERTPROTO") - || !strcmp(str, "XREPLACE") - ) { + /*BIFS extended commands*/ + || !strcmp(str, "GLOBALQP") || !strcmp(str, "MULTIPLEREPLACE") || !strcmp(str, "MULTIPLEINDREPLACE") || !strcmp(str, "XDELETE") || !strcmp(str, "DELETEPROTO") || !strcmp(str, "INSERTPROTO") + || !strcmp(str, "XREPLACE") + ) { Bool is_base_stream = parser->stream_id ? 0 : 1; if (!parser->stream_id) parser->stream_id = parser->base_bifs_id; @@ -3400,12 +3420,12 @@ GF_Err gf_bt_loader_run_intern(GF_BTParser *parser, GF_Command *init_com, Bool i } /*implicit BIFS command on SFTopNodes only*/ else if (!strcmp(str, "OrderedGroup") - || !strcmp(str, "Group") - || !strcmp(str, "Layer2D") - || !strcmp(str, "Layer3D") - /* VRML parsing: all nodes are allowed*/ - || parser->is_wrl - ) + || !strcmp(str, "Group") + || !strcmp(str, "Layer2D") + || !strcmp(str, "Layer3D") + /* VRML parsing: all nodes are allowed*/ + || parser->is_wrl + ) { node = gf_bt_sf_node(parser, str, vrml_root_node, has_id ? szDEFName : NULL); @@ -3465,9 +3485,9 @@ static GF_Err gf_sm_load_bt_initialize(GF_SceneLoader *load, const char *str, Bo GF_Err e; unsigned char BOM[5]; GF_BTParser *parser = load->loader_priv; - + parser->last_error = GF_OK; - + if (load->fileName) { FILE *test = gf_f64_open(load->fileName, "rb"); if (!test) return GF_URL_ERROR; @@ -3493,7 +3513,7 @@ static GF_Err gf_sm_load_bt_initialize(GF_SceneLoader *load, const char *str, Bo parser->initialized = 0; return GF_OK; } - strncpy((char *) BOM, str, 5); + strncpy((char *) BOM, str, 5); } /*0: no unicode, 1: UTF-16BE, 2: UTF-16LE*/ @@ -3519,13 +3539,13 @@ static GF_Err gf_sm_load_bt_initialize(GF_SceneLoader *load, const char *str, Bo if (parser->gz_in) gzseek(parser->gz_in, 3, SEEK_CUR); } parser->initialized = 1; - + if ( load->fileName ) { sep = strrchr(load->fileName, '.'); if (sep && !strnicmp(sep, ".wrl", 4)) parser->is_wrl = 1; } - + if (input_only) return GF_OK; /*initalize default streams in the context*/ @@ -3540,9 +3560,14 @@ static GF_Err gf_sm_load_bt_initialize(GF_SceneLoader *load, const char *str, Bo i=0; while ((sc = (GF_StreamContext*)gf_list_enum(load->ctx->streams, &i))) { switch (sc->streamType) { - case GF_STREAM_SCENE: if (!parser->bifs_es) parser->bifs_es = sc; break; - case GF_STREAM_OD: if (!parser->od_es) parser->od_es = sc; break; - default: break; + case GF_STREAM_SCENE: + if (!parser->bifs_es) parser->bifs_es = sc; + break; + case GF_STREAM_OD: + if (!parser->od_es) parser->od_es = sc; + break; + default: + break; } } /*need at least one scene stream*/ diff --git a/src/scene_manager/loader_isom.c b/src/scene_manager/loader_isom.c index 5a11a5b..a031637 100644 --- a/src/scene_manager/loader_isom.c +++ b/src/scene_manager/loader_isom.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -57,8 +57,8 @@ static void UpdateODCommand(GF_ISOFile *mp4, GF_ODCom *com) break; case GF_STREAM_SCENE: if ((esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_AFX) && - (esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) - ) { + (esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) + ) { import = 0; } break; @@ -75,7 +75,7 @@ static void UpdateODCommand(GF_ISOFile *mp4, GF_ODCom *com) mi->duration = (u32) (dur * 1000); import = 0; } - break; + break; default: break; } @@ -103,8 +103,8 @@ static void UpdateODCommand(GF_ISOFile *mp4, GF_ODCom *com) break; case GF_STREAM_SCENE: if ((esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_AFX) && - (esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) - ) { + (esd->decoderConfig->objectTypeIndication != GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) + ) { import = 0; } break; @@ -121,7 +121,7 @@ static void UpdateODCommand(GF_ISOFile *mp4, GF_ODCom *com) mi->duration = (u32) (dur * 1000); import = 0; } - break; + break; default: break; } @@ -210,8 +210,8 @@ static GF_Err gf_sm_load_run_isom(GF_SceneLoader *load) if ((esd->decoderConfig->objectTypeIndication == GPAC_OTI_SCENE_AFX) || - (esd->decoderConfig->objectTypeIndication == GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) - ) { + (esd->decoderConfig->objectTypeIndication == GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE) + ) { nb_samp += gf_isom_get_sample_count(load->isom, i+1); continue; } @@ -226,7 +226,7 @@ static GF_Err gf_sm_load_run_isom(GF_SceneLoader *load) #ifndef GPAC_DISABLE_BIFS /*BIFS*/ if (esd->decoderConfig->objectTypeIndication<=2) { - if (!esd->dependsOnESID && nbBifs && !i) + if (!esd->dependsOnESID && nbBifs && !i) mp4_report(load, GF_OK, "several scene namespaces used or improper scene dependencies in file - import may be incorrect"); if (!esd->decoderConfig->decoderSpecificInfo) { /* Hack for T-DMB non compliant streams */ @@ -242,7 +242,7 @@ static GF_Err gf_sm_load_run_isom(GF_SceneLoader *load) #ifndef GPAC_DISABLE_LASER /*LASER*/ if (esd->decoderConfig->objectTypeIndication==0x09) { - if (!esd->dependsOnESID && nbBifs && !i) + if (!esd->dependsOnESID && nbBifs && !i) mp4_report(load, GF_OK, "several scene namespaces used or improper scene dependencies in file - import may be incorrect"); e = gf_laser_decoder_configure_stream(lsr_dec, esd->ESID, esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength); if (e) goto exit; @@ -275,11 +275,11 @@ static GF_Err gf_sm_load_run_isom(GF_SceneLoader *load) if (esd->decoderConfig->streamType==GF_STREAM_SCENE) { #ifndef GPAC_DISABLE_BIFS - if (esd->decoderConfig->objectTypeIndication<=2) + if (esd->decoderConfig->objectTypeIndication<=2) e = gf_bifs_decode_command_list(bifs_dec, esd->ESID, samp->data, samp->dataLength, au->commands); #endif #ifndef GPAC_DISABLE_LASER - if (esd->decoderConfig->objectTypeIndication==0x09) + if (esd->decoderConfig->objectTypeIndication==0x09) e = gf_laser_decode_command_list(lsr_dec, esd->ESID, samp->data, samp->dataLength, au->commands); #endif } else { @@ -350,7 +350,7 @@ GF_Err gf_sm_load_init_isom(GF_SceneLoader *load) gf_odf_desc_del((GF_Descriptor *) load->ctx->root_od); load->ctx->root_od = NULL; } - + esd = NULL; /*get root scene stream*/ diff --git a/src/scene_manager/loader_qt.c b/src/scene_manager/loader_qt.c index 15270ff..84ebf7b 100644 --- a/src/scene_manager/loader_qt.c +++ b/src/scene_manager/loader_qt.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -166,7 +166,7 @@ GF_Err gf_sm_load_init_qt(GF_SceneLoader *load) mi->delete_file = 1; sprintf(szName, "%s_img%d.jpg", load->fileName, esd->ESID); mi->file_name = gf_strdup(szName); - + gf_list_add(od->ESDescriptors, esd); gf_list_add(odU->objectDescriptors, od); diff --git a/src/scene_manager/loader_svg.c b/src/scene_manager/loader_svg.c index be49d71..d33c86f 100644 --- a/src/scene_manager/loader_svg.c +++ b/src/scene_manager/loader_svg.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,7 +54,7 @@ typedef struct GF_Err last_error; GF_SAXParser *sax_parser; u32 has_root; - + /* stack of SVG nodes*/ GF_List *node_stack; @@ -70,7 +70,7 @@ typedef struct GF_AUContext *laser_au; GF_Command *command; - /*SAF AU maps to OD AU and is used for each new media declaration*/ + /*SAF AU maps to OD AU and is used for each new media declaration*/ GF_AUContext *saf_au; GF_StreamContext *saf_es; @@ -113,8 +113,8 @@ typedef struct { /*top of parsed sub-tree*/ SVG_Element *node; - /*the current element is animation that cannot be parsed completely - upon reception of start tag of element but for which we may be able + /*the current element is animation that cannot be parsed completely + upon reception of start tag of element but for which we may be able to parse at the end tag of the element (animateMotion)*/ SVG_DeferedAnimation *anim; /*depth of unknown elements being skipped*/ @@ -152,9 +152,9 @@ static void svg_progress(void *cbk, u64 done, u64 total) /*notify MediaEvent*/ if (parser->load && parser->load->is) { - parser->load->is->on_media_event(parser->load->is, GF_EVENT_MEDIA_PROGRESS); + parser->load->is->on_media_event(parser->load->is, GF_EVENT_MEDIA_PROGRESS); if (done == total) { - parser->load->is->on_media_event(parser->load->is, GF_EVENT_MEDIA_LOAD_DONE); + parser->load->is->on_media_event(parser->load->is, GF_EVENT_MEDIA_LOAD_DONE); } } gf_set_progress("SVG (Dynamic Attribute List) Parsing", done, total); @@ -211,7 +211,7 @@ static void svg_lsr_set_v2(GF_SVG_Parser *parser) static void svg_process_media_href(GF_SVG_Parser *parser, GF_Node *elt, XMLRI *iri) { u32 tag = gf_node_get_tag(elt); - + if ((tag==TAG_SVG_image) || (tag==TAG_SVG_video) || (tag==TAG_SVG_audio)) { SVG_SAFExternalStream *st = svg_saf_get_stream(parser, 0, iri->string+1); if (st) { @@ -356,11 +356,11 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De u8 anim_value_type = 0; if (anim->resolve_stage==0) { - /* Stage 0: parsing the animation attribute values + /* Stage 0: parsing the animation attribute values for that we need to resolve the target first */ /* if we don't have a target, try to get it */ - if (!anim->target) + if (!anim->target) anim->target = (SVG_Element *) gf_sg_find_node_by_name(sg, anim->target_id + 1); /* if now we have a target, create the xlink:href attribute on the animation element and set it to the found target */ @@ -405,7 +405,7 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De else if (gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_attributeName, GF_FALSE, GF_FALSE, &info) == GF_OK) { SMIL_AttributeName *attname = (SMIL_AttributeName *)info.far_ptr; - /*parse the attribute name even if the target is not found, because a namespace could be specified and + /*parse the attribute name even if the target is not found, because a namespace could be specified and only valid for the current node*/ if (!attname->type) { char *sep; @@ -451,23 +451,23 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De /* now that we have a target, if there is a to value to parse, create the attribute and parse it */ gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_to, GF_TRUE, GF_FALSE, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->to, anim_value_type); - if (anim_value_type==XMLRI_datatype) + if (anim_value_type==XMLRI_datatype) svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value); - } + } if (anim->from) { /* now that we have a target, if there is a from value to parse, create the attribute and parse it */ gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_from, GF_TRUE, GF_FALSE, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->from, anim_value_type); - if (anim_value_type==XMLRI_datatype) + if (anim_value_type==XMLRI_datatype) svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value); - } + } if (anim->by) { /* now that we have a target, if there is a by value to parse, create the attribute and parse it */ gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_by, GF_TRUE, GF_FALSE, &info); gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->by, anim_value_type); - if (anim_value_type==XMLRI_datatype) + if (anim_value_type==XMLRI_datatype) svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value); - } + } if (anim->values) { /* now that we have a target, if there is a 'values' value to parse, create the attribute and parse it */ gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_values, GF_TRUE, GF_FALSE, &info); @@ -487,7 +487,7 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De } if (anim->resolve_stage == 1) { - /* Stage 1: parsing the begin values + /* Stage 1: parsing the begin values we go into the next stage only if at least one begin value is resolved */ gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_begin, GF_TRUE, GF_FALSE, &info); if (gf_svg_resolve_smil_times((GF_Node *)anim->animation_elt, anim->target, *(GF_List **)info.far_ptr, GF_FALSE, nodeID)) { @@ -509,7 +509,7 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De } else { return GF_FALSE; } - + } static void svg_resolved_refs(GF_SVG_Parser *parser, GF_SceneGraph *sg, const char *nodeID) @@ -588,7 +588,7 @@ static void svg_init_root_element(GF_SVG_Parser *parser, SVG_Element *root_svg) u32 svg_w, svg_h; svg_w = svg_h = 0; if (!gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_width, GF_FALSE, GF_FALSE, &width_info) - && !gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_height, GF_FALSE, GF_FALSE, &height_info)) { + && !gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_height, GF_FALSE, GF_FALSE, &height_info)) { SVG_Length * w = (SVG_Length *)width_info.far_ptr; SVG_Length * h = (SVG_Length *)height_info.far_ptr; if (w->type == SVG_NUMBER_VALUE) svg_w = FIX2INT(w->value); @@ -625,7 +625,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c const char *ev_event, *ev_observer; SVG_DeferedAnimation *anim = NULL; char *ID = NULL; - + GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[SVG Parsing] Parsing node %s\n", name)); *has_ns = GF_FALSE; @@ -667,7 +667,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c return NULL; } } - + /* Translates the node type (called name) from a String into a unique numeric identifier in GPAC */ tag = xmlns ? gf_xml_get_element_tag(name, xmlns) : TAG_UndefinedNode; if (tag == TAG_UndefinedNode) { @@ -684,7 +684,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c has_id = GF_FALSE; count = gf_list_count(parser->peeked_nodes); if (count && ID) { - for (i=0; ipeeked_nodes, i); const char *n_id = gf_node_get_name(n); if (n_id && !strcmp(n_id, ID)) { @@ -733,7 +733,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c anim->target = anim->anim_parent = parent->node; } } else if (gf_svg_is_timing_tag(tag)) { - /* warning: we use the SVG_DeferedAnimation structure for some timing nodes which are not + /* warning: we use the SVG_DeferedAnimation structure for some timing nodes which are not animations, but we put the parse stage at 1 (timing) see svg_parse_animation. */ GF_SAFEALLOC(anim, SVG_DeferedAnimation); /*default anim target is parent node*/ @@ -768,7 +768,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c char *att_name = NULL; if (!att->value || !strlen(att->value)) continue; - /* first determine in which namespace is the attribute and store the result in ns, + /* first determine in which namespace is the attribute and store the result in ns, then shift the char buffer to point to the local name of the attribute*/ ns = xmlns; att_name = strchr(att->name, ':'); @@ -792,7 +792,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c if (!stricmp(att_name, "style")) { gf_svg_parse_style((GF_Node *)elt, att->value); continue; - } + } /* Some attributes of the animation elements cannot be parsed (into typed values) until the type of value is known, we defer the parsing and store them temporarily as strings */ @@ -821,9 +821,9 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c /* Special case for xlink:href attributes */ if ((ns == GF_XMLNS_XLINK) && !stricmp(att_name, "href") ) { - + if (gf_svg_is_animation_tag(tag)) { - /* For xlink:href in animation elements, + /* For xlink:href in animation elements, we try to locate the target of the xlink:href to determine the type of values to be animated */ assert(anim); anim->target_id = gf_strdup(att->value); @@ -844,24 +844,24 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c /* extract data URL and store as file */ svg_post_process_href(parser, iri); continue; - } + } } - } + } /* For the XML Event handler element, we need to defer the parsing of some attributes */ if ((tag == TAG_SVG_handler) && (ns == GF_XMLNS_XMLEV)) { if (!stricmp(att_name, "event") ) { ev_event = att->value; continue; - } + } if (!stricmp(att_name, "observer") ) { ev_observer = att->value; continue; - } + } } /*laser specific stuff*/ - if (ns == GF_XMLNS_LASER) { + if (ns == GF_XMLNS_LASER) { /* CHECK: we should probably check the namespace of the attribute here */ if (!stricmp(att_name, "scale") ) { if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, GF_TRUE, GF_TRUE, &info)==GF_OK) { @@ -871,7 +871,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c gf_mx2d_add_scale(&mat->mat, pt.x, pt.y); continue; } - } + } if (!stricmp(att_name, "translation") ) { if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, GF_TRUE, GF_TRUE, &info)==GF_OK) { SVG_Point pt; @@ -880,10 +880,10 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c gf_mx2d_add_translation(&mat->mat, pt.x, pt.y); continue; } - } + } } - /* For all attributes of the form 'on...', like 'onclick' we create a listener for the event on the current element, + /* For all attributes of the form 'on...', like 'onclick' we create a listener for the event on the current element, we connect the listener to a handler that contains the code in the 'on...' attribute. */ /* CHECK: we should probably check the namespace of the attribute and of the element here */ if (!strncmp(att_name, "on", 2)) { @@ -893,9 +893,9 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c gf_dom_add_text_node((GF_Node *)handler, gf_strdup(att->value) ); gf_node_init((GF_Node *)handler); continue; - } + } svg_report(parser, GF_OK, "Skipping unknown event handler %s on node %s", att->name, name); - } + } /* end of special cases of attributes */ @@ -908,8 +908,8 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c continue; } if (info.fieldType == SVG_ID_datatype) { - /*"when both 'id' and 'xml:id' are specified on the same element but with different values, - the SVGElement::id field must return either of the values but should give precedence to + /*"when both 'id' and 'xml:id' are specified on the same element but with different values, + the SVGElement::id field must return either of the values but should give precedence to the 'xml:id' attribute."*/ if (!node_name || (info.fieldIndex == TAG_XML_ATT_id)) { node_name = *(SVG_ID *)info.far_ptr; @@ -922,10 +922,10 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c } else { switch (info.fieldIndex) { case TAG_SVG_ATT_syncMaster: - case TAG_SVG_ATT_focusHighlight: - case TAG_SVG_ATT_initialVisibility: - case TAG_SVG_ATT_fullscreen: - case TAG_SVG_ATT_requiredFonts: + case TAG_SVG_ATT_focusHighlight: + case TAG_SVG_ATT_initialVisibility: + case TAG_SVG_ATT_fullscreen: + case TAG_SVG_ATT_requiredFonts: /*switch LASeR Configuration to v2 because these attributes are not part of v1*/ svg_lsr_set_v2(parser); break; @@ -933,7 +933,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c } #endif continue; - } + } /* all other attributes (??? failed to be created) should fall in this category */ svg_report(parser, GF_OK, "Skipping attribute %s on node %s", att->name, name); @@ -946,7 +946,7 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c u32 type; GF_FieldInfo info; listener = (SVG_Element *) gf_node_new(node->sgprivate->scenegraph, TAG_SVG_listener); - /*We don't want to insert the implicit listener in the DOM. However remember + /*We don't want to insert the implicit listener in the DOM. However remember the listener at the handler level in case the handler gets destroyed*/ gf_node_set_private(node, (GF_Node*)listener ); gf_node_register((GF_Node*)listener, NULL); @@ -969,9 +969,9 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, GF_TRUE, GF_FALSE, &info); ((XMLRI *)info.far_ptr)->target = parent->node; } - /* if the target was found (already parsed), we are fine, otherwise we need to try to find it again, + /* if the target was found (already parsed), we are fine, otherwise we need to try to find it again, we place the listener in the defered listener list */ - if ( ((XMLRI *)info.far_ptr)->target) + if ( ((XMLRI *)info.far_ptr)->target) gf_node_dom_listener_add(((XMLRI *)info.far_ptr)->target, (GF_Node *) listener); else gf_list_add(parser->defered_listeners, listener); @@ -991,12 +991,12 @@ static SVG_Element *svg_parse_element(GF_SVG_Parser *parser, const char *name, c if (anim) { /*FIXME - we need to parse from/to/values but not initialize the stack*/ // if (parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK) { - needs_init = GF_FALSE; - if (svg_parse_animation(parser, parser->load->scene_graph, anim, NULL, 0)) { - svg_delete_defered_anim(anim, NULL); - } else { - gf_list_add(parser->defered_animations, anim); - } + needs_init = GF_FALSE; + if (svg_parse_animation(parser, parser->load->scene_graph, anim, NULL, 0)) { + svg_delete_defered_anim(anim, NULL); + } else { + gf_list_add(parser->defered_animations, anim); + } // } else { // svg_delete_defered_anim(anim, NULL); // } @@ -1174,11 +1174,11 @@ static GF_Err lsr_parse_command(GF_SVG_Parser *parser, const GF_XMLAttribute *at info.fieldType = gf_xml_get_attribute_type(info.fieldIndex); #ifndef GPAC_DISABLE_LASER -/* - if (gf_lsr_anim_type_from_attribute(info.fieldIndex)<0) { - return svg_report(parser, GF_BAD_PARAM, "Attribute %s of element %s is not updatable\n", atAtt, gf_node_get_class_name(parser->command->node)); - } -*/ + /* + if (gf_lsr_anim_type_from_attribute(info.fieldIndex)<0) { + return svg_report(parser, GF_BAD_PARAM, "Attribute %s of element %s is not updatable\n", atAtt, gf_node_get_class_name(parser->command->node)); + } + */ #endif /*GPAC_DISABLE_LASER*/ } @@ -1291,7 +1291,7 @@ static GF_ESD *lsr_parse_header(GF_SVG_Parser *parser, const char *name, const c u32 i; if (!strcmp(name, "LASeRHeader")) { GF_LASERConfig *lsrc = (GF_LASERConfig *) gf_odf_desc_new(GF_ODF_LASER_CFG_TAG); - for (i=0; iname, "profile")) lsrc->profile = !strcmp(att->value, "full") ? 1 : 0; else if (!strcmp(att->name, "level")) lsrc->level = atoi(att->value); @@ -1338,23 +1338,23 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp parent = NULL; } - /* If the loader was created with the DIMS type and this is the root element, restore the stream and AU + /* If the loader was created with the DIMS type and this is the root element, restore the stream and AU context - in DIMS? we only have one stream an dcommands are stacked in the last AU of the stream*/ - if (!parent && (parser->load->type == GF_SM_LOAD_DIMS) && parser->load->ctx) { + if (!parent && (parser->load->type == GF_SM_LOAD_DIMS) && parser->load->ctx) { /*if not created, do it now*/ if (!gf_list_count(parser->load->ctx->streams)) { parser->laser_es = gf_sm_stream_new(parser->load->ctx, 1, GF_STREAM_SCENE, GPAC_OTI_SCENE_DIMS); parser->laser_es->timeScale = 1000; /* Create a default AU to behave as other streams (LASeR, BIFS) - but it is left empty, there is no notion of REPLACE Scene or NEw Scene, + but it is left empty, there is no notion of REPLACE Scene or NEw Scene, the RAP is the graph */ parser->laser_au = gf_sm_stream_au_new(parser->laser_es, 0, 0, GF_TRUE); } else { parser->laser_es = gf_list_get(parser->load->ctx->streams, 0); parser->laser_au = gf_list_last(parser->laser_es->AUs); } - } + } /*saf setup*/ if ((!parent && (parser->load->type!=GF_SM_LOAD_SVG)) || cond) { @@ -1381,20 +1381,20 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp time = 0; rap = GF_FALSE; if (!gf_list_count(parser->laser_es->AUs)) rap = GF_TRUE; - for (i=0; iname, "time")) time = atoi(att->value); else if (!strcmp(att->name, "rap")) rap = !strcmp(att->value, "yes") ? GF_TRUE : GF_FALSE; } /*create new laser unit*/ parser->laser_au = gf_sm_stream_au_new(parser->laser_es, time, 0, rap); - return; + return; } if (!strcmp(name, "StreamHeader") || !strcmp(name, "RemoteStreamHeader") - /*SAF & SAFML are just a pain ...*/ - || !strcmp(name, "mediaHeader") || !strcmp(name, "imageHeader") - ) { + /*SAF & SAFML are just a pain ...*/ + || !strcmp(name, "mediaHeader") || !strcmp(name, "imageHeader") + ) { char *url = NULL; char *src = NULL; const char *ID = NULL; @@ -1416,11 +1416,11 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp time = 0; ts_res = 1000; OTI = ST = 0; - for (i=0; iname, "time")) time = atoi(att->value); else if (!strcmp(att->name, "rap")) ;//rap = !strcmp(att->value, "yes") ? 1 : 0; - else if (!strcmp(att->name, "url")) url = gf_strdup(att->value); + else if (!strcmp(att->name, "url")) url = gf_strdup(att->value); else if (!strcmp(att->name, "streamID")) ID = att->value; else if (!strcmp(att->name, "objectTypeIndication")) OTI = atoi(att->value); else if (!strcmp(att->name, "streamType")) ST = atoi(att->value); @@ -1487,7 +1487,7 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp SVG_SAFExternalStream*st; u32 i, rap, time, offset, length; rap = time = offset = length = 0; - for (i=0; iname, "time")) time = atoi(att->value); else if (!strcmp(att->name, "source")) src = att->value; @@ -1516,7 +1516,7 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp char *id = NULL; u32 i; SVG_SAFExternalStream*st; - for (i=0; iname, "ref")) id = att->value; } @@ -1550,7 +1550,7 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp GF_Err e; parser->command = gf_sg_command_new(parser->load->scene_graph, com_type); - /*this is likely a conditional start - update unknown depth level*/ + /*this is likely a conditional start - update unknown depth level*/ top = (SVG_NodeStack*)gf_list_last(parser->node_stack); if (top) { top->unknown_depth ++; @@ -1593,7 +1593,7 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp if (!parent && !parser->command && (parser->load->flags & GF_SM_LOAD_CONTEXT_STREAMING)) { gf_sg_reset(parser->load->scene_graph); parser->has_root = 0; - } + } /*something not supported happened (bad command name, bad root, ...) */ if ((parser->has_root==1) && !parent && !parser->command) @@ -1614,10 +1614,10 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp stack->has_ns = has_ns; gf_list_add(parser->node_stack, stack); - if ( (gf_node_get_tag((GF_Node *)elt) == TAG_SVG_svg) && - (!parser->has_root || (parser->command && !parser->command->node) ) - ) { - + if ( (gf_node_get_tag((GF_Node *)elt) == TAG_SVG_svg) && + (!parser->has_root || (parser->command && !parser->command->node) ) + ) { + if (!parser->has_root) svg_init_root_element(parser, elt); if (parser->command) parser->command->node = (GF_Node*)elt; } else if (!parent && parser->has_root && parser->command) { @@ -1643,7 +1643,7 @@ static void svg_node_start(void *sax_cbck, const char *name, const char *name_sp } else { assert(parser->command->tag==GF_SG_LSR_NEW_SCENE); assert(gf_node_get_tag((GF_Node *)elt) == TAG_SVG_svg); - if(!parser->command->node) + if(!parser->command->node) parser->command->node = (GF_Node *)elt; } } else if (!parser->has_root ) { @@ -1686,14 +1686,14 @@ static void svg_node_end(void *sax_cbck, const char *name, const char *name_spac /*error*/ return; } - + #ifdef SKIP_UNKNOWN_NODES ns = parser->current_ns; - if (name_space) - ns = gf_sg_get_namespace_code(parser->load->scene_graph, (char *) name_space); + if (name_space) + ns = gf_sg_get_namespace_code(parser->load->scene_graph, (char *) name_space); /*only remove created nodes ... */ - if (gf_xml_get_element_tag(name, ns) != TAG_UndefinedNode) + if (gf_xml_get_element_tag(name, ns) != TAG_UndefinedNode) #endif { const char *the_name; @@ -1722,28 +1722,28 @@ static void svg_node_end(void *sax_cbck, const char *name, const char *name_spac if (parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK) { switch (node->sgprivate->tag) { case TAG_SVG_animateMotion: - /* - try to init animateMotion once all children have been parsed - to make sure we get the mpath child if any, however, we are still not sure - if the target is known. We can force initialisation - because mpath children (if any have been parsed) + /* + try to init animateMotion once all children have been parsed + to make sure we get the mpath child if any, however, we are still not sure + if the target is known. We can force initialisation + because mpath children (if any have been parsed) */ - { - u32 i, count; - SVG_DeferedAnimation *anim = NULL; - count = gf_list_count(parser->defered_animations); - for (i = 0; i < count; i++) { - anim = gf_list_get(parser->defered_animations, i); - if (anim->animation_elt == node) break; - else anim = NULL; - } - if (anim) { - if (svg_parse_animation(parser, gf_node_get_graph((GF_Node *)node), anim, NULL, 1)) { - svg_delete_defered_anim(anim, parser->defered_animations); - } - } + { + u32 i, count; + SVG_DeferedAnimation *anim = NULL; + count = gf_list_count(parser->defered_animations); + for (i = 0; i < count; i++) { + anim = gf_list_get(parser->defered_animations, i); + if (anim->animation_elt == node) break; + else anim = NULL; } - break; + if (anim) { + if (svg_parse_animation(parser, gf_node_get_graph((GF_Node *)node), anim, NULL, 1)) { + svg_delete_defered_anim(anim, parser->defered_animations); + } + } + } + break; case TAG_SVG_script: case TAG_SVG_handler: /*init script once text script is loaded*/ @@ -1803,7 +1803,7 @@ static void svg_text_content(void *sax_cbck, const char *text_content, Bool is_c field = (GF_CommandField *)gf_list_get(parser->command->command_fields, 0); if (parser->command->tag == GF_SG_LSR_NEW_SCENE || parser->command->tag == GF_SG_LSR_ADD) return; - + if (!field || field->field_ptr) return; if (field->new_node) { @@ -1853,7 +1853,7 @@ static void svg_text_content(void *sax_cbck, const char *text_content, Bool is_c } } } - break; + break; } if (!skip_text) { @@ -1962,8 +1962,11 @@ static GF_Err gf_sm_load_initialize_svg(GF_SceneLoader *load, const char *str_da i=0; while ((sc = (GF_StreamContext*)gf_list_enum(load->ctx->streams, &i))) { switch (sc->streamType) { - case GF_STREAM_SCENE: if (!parser->laser_es) parser->laser_es = sc; break; - default: break; + case GF_STREAM_SCENE: + if (!parser->laser_es) parser->laser_es = sc; + break; + default: + break; } } /*need at least one scene stream - FIXME - accept SVG as root? */ @@ -1973,10 +1976,10 @@ static GF_Err gf_sm_load_initialize_svg(GF_SceneLoader *load, const char *str_da GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("[Parser] %s Scene Parsing: %s\n", ((load->type==GF_SM_LOAD_SVG) ? "SVG" : ((load->type==GF_SM_LOAD_XSR) ? "LASeR" : "DIMS")), load->fileName)); } - if (str_data) + if (str_data) return gf_xml_sax_parse(parser->sax_parser, str_data); - - return GF_OK; + + return GF_OK; } @@ -2008,7 +2011,7 @@ static void load_svg_done(GF_SceneLoader *load) SVG_SAFExternalStream *st; GF_SVG_Parser *parser = (GF_SVG_Parser *)load->loader_priv; if (!parser) return; - + gf_sm_svg_flush_state(parser); gf_list_del(parser->node_stack); @@ -2082,7 +2085,7 @@ GF_Node *gf_sm_load_svg_from_string(GF_SceneGraph *in_scene, char *node_str) ctx.type = GF_SM_LOAD_SVG; e = gf_sm_load_initialize_svg(&ctx, node_str, GF_TRUE); - + parser = (GF_SVG_Parser *)ctx.loader_priv; node = parser->fragment_root; @@ -2091,7 +2094,7 @@ GF_Node *gf_sm_load_svg_from_string(GF_SceneGraph *in_scene, char *node_str) parser->fragment_root=NULL; load_svg_done(&ctx); return NULL; - } + } /*don't register*/ if (node) node->sgprivate->num_instances--; diff --git a/src/scene_manager/loader_xmt.c b/src/scene_manager/loader_xmt.c index dde9224..43677ce 100644 --- a/src/scene_manager/loader_xmt.c +++ b/src/scene_manager/loader_xmt.c @@ -11,21 +11,22 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ enum typedef struct -{ +{ /*1: XMT-A, 2: X3D, 3: XMT-O (not supported yet) */ u32 doc_type; /*0: not init, 1: header, 2: body*/ @@ -78,7 +79,7 @@ typedef struct GF_Err last_error; GF_SAXParser *sax_parser; XMTNodeStack *x3d_root; - + /* stack of nodes for SAX parsing*/ GF_List *nodes; /* stack of descriptors for SAX parsing*/ @@ -155,7 +156,7 @@ static void xmt_progress(void *cbk, u64 done, u64 total) { gf_set_progress("XMT Parsing", done, total); } -static Bool xmt_esid_available(GF_XMTParser *parser, u16 ESID) +static Bool xmt_esid_available(GF_XMTParser *parser, u16 ESID) { u32 i; XMT_ESDLink *esdl; @@ -166,7 +167,7 @@ static Bool xmt_esid_available(GF_XMTParser *parser, u16 ESID) return 1; } -static char *xmt_get_es_name(GF_XMTParser *parser, u16 ESID) +static char *xmt_get_es_name(GF_XMTParser *parser, u16 ESID) { u32 i; XMT_ESDLink *esdl; @@ -201,9 +202,9 @@ static void xmt_new_od_link(GF_XMTParser *parser, GF_ObjectDescriptor *od, char for (i=0; iod_links, i); if ( (ID && (odl->ID == ID)) - || (odl->od == od) - || (odl->desc_name && name && !strcmp(odl->desc_name, name)) - ) { + || (odl->od == od) + || (odl->desc_name && name && !strcmp(odl->desc_name, name)) + ) { if (!odl->od) odl->od = od; if (!odl->desc_name && name) odl->desc_name = gf_strdup(name); if (!od->objectDescriptorID) { @@ -211,7 +212,7 @@ static void xmt_new_od_link(GF_XMTParser *parser, GF_ObjectDescriptor *od, char } else if (ID && (od->objectDescriptorID != ID)) { xmt_report(parser, GF_BAD_PARAM, "Conflicting OD IDs %d vs %d\n", ID, od->objectDescriptorID); } - + for (j=i+1; jod_links, j); if (l2->od == od) { @@ -260,13 +261,13 @@ static void xmt_new_od_link_from_node(GF_XMTParser *parser, char *name, MFURL *u i = url->count - 1; url->vals[i].OD_ID = 0; url->vals->OD_ID = ID; - + i=0; while ((odl = (XMT_ODLink*)gf_list_enum(parser->od_links, &i))) { if ( (name && odl->desc_name && !strcmp(odl->desc_name, name)) - || (ID && odl->od && odl->od->objectDescriptorID==ID) - || (ID && (odl->ID==ID)) - ) { + || (ID && odl->od && odl->od->objectDescriptorID==ID) + || (ID && (odl->ID==ID)) + ) { if (url && (gf_list_find(odl->mf_urls, url)<0) ) gf_list_add(odl->mf_urls, url); return; } @@ -405,7 +406,7 @@ static u32 xmt_locate_stream(GF_XMTParser *parser, char *stream_name) gf_list_add(parser->esd_links, esdl); return esdl->ESID; } -static Bool xmt_odid_available(GF_XMTParser *parser, u16 ODID) +static Bool xmt_odid_available(GF_XMTParser *parser, u16 ODID) { u32 i; XMT_ODLink *l; @@ -452,7 +453,7 @@ static void xmt_resolve_od_links(GF_XMTParser *parser) esdl->esd->OCRESID = 0; if (!esdl->OCR_Name) continue; - + use_old_fmt = 0; ocr_id = atoi(esdl->OCR_Name); sprintf(szTest, "%d", ocr_id); @@ -485,7 +486,7 @@ static void xmt_resolve_od_links(GF_XMTParser *parser) esdl->esd->dependsOnESID = 0; if (!esdl->Depends_Name) continue; - + use_old_fmt = 0; dep_id = atoi(esdl->Depends_Name); sprintf(szTest, "%d", dep_id); @@ -561,7 +562,7 @@ static void xmt_resolve_od_links(GF_XMTParser *parser) if (l->ID) { if (l->desc_name) { xmt_report(parser, GF_OK, "WARNING: OD \"%s\" (ID %d) not assigned", l->desc_name, l->ID); - } else{ + } else { xmt_report(parser, GF_OK, "WARNING: OD ID %d not assigned", l->ID); } } @@ -601,7 +602,7 @@ static u32 xmt_get_next_node_id(GF_XMTParser *parser) GF_SceneGraph *sc = parser->load->scene_graph; if (parser->parsing_proto) sc = gf_sg_proto_get_graph(parser->parsing_proto); ID = gf_sg_get_next_available_node_id(sc); - if (parser->load->ctx && (ID>parser->load->ctx->max_node_id)) + if (parser->load->ctx && (ID>parser->load->ctx->max_node_id)) parser->load->ctx->max_node_id = ID; return ID; } @@ -626,7 +627,7 @@ static u32 xmt_get_node_id(GF_XMTParser *parser, char *name) return ID; } } - } + } ID = xmt_get_next_node_id(parser); if (n) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[XMT Parsing] (line %d) Binary ID %s already assigned to %s - keeping internal ID %d\n", gf_xml_sax_get_line(parser->sax_parser), name, gf_node_get_name(n), ID)); @@ -634,14 +635,14 @@ static u32 xmt_get_node_id(GF_XMTParser *parser, char *name) return ID; } -static u32 xmt_get_node_tag(GF_XMTParser *parser, const char *node_name) +static u32 xmt_get_node_tag(GF_XMTParser *parser, const char *node_name) { u32 tag; /*if VRML and allowing non MPEG4 nodes, use X3D*/ if ((parser->doc_type==2) && !(parser->load->flags & GF_SM_LOAD_MPEG4_STRICT)) { #ifndef GPAC_DISABLE_X3D tag = gf_node_x3d_type_by_class_name(node_name); - if (!tag) + if (!tag) #endif tag = gf_node_mpeg4_type_by_class_name(node_name); } else { @@ -764,7 +765,7 @@ static u32 xmt_parse_string(GF_XMTParser *parser, const char *name, SFString *va return len+1; } - /*now this is the REAL pain: + /*now this is the REAL pain: X3D allows '"String1" "String2"' and therefore '"String "test""' XMT allows '"String1" "String2"' and therefore '"String \"test\""' thus translating the string from xml to UTF may screw up the separators !! We need to identify them @@ -804,7 +805,7 @@ static u32 xmt_parse_string(GF_XMTParser *parser, const char *name, SFString *va } value[k] = 0; len = (u32) strlen(sep) + i; - + if (val->buffer) gf_free(val->buffer); val->buffer = NULL; if (strlen(value)) val->buffer = gf_strdup(value); @@ -870,7 +871,7 @@ static void xmt_check_time_offset(GF_XMTParser *parser, GF_Node *n, GF_FieldInfo { if (!(parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK)) return; if (gf_node_get_tag(n) != TAG_ProtoNode) { - if (!stricmp(info->name, "startTime") || !stricmp(info->name, "stopTime")) + if (!stricmp(info->name, "startTime") || !stricmp(info->name, "stopTime")) xmt_offset_time(parser, (Double *)info->far_ptr); } else if (gf_sg_proto_field_is_sftime_offset(n, info)) { xmt_offset_time(parser, (Double *)info->far_ptr); @@ -882,46 +883,46 @@ static u32 xmt_parse_sf_field(GF_XMTParser *parser, GF_FieldInfo *info, GF_Node u32 res = 0; switch (info->fieldType) { case GF_SG_VRML_SFINT32: - res = xmt_parse_int(parser, info->name, (SFInt32 *)info->far_ptr, a_value); + res = xmt_parse_int(parser, info->name, (SFInt32 *)info->far_ptr, a_value); break; case GF_SG_VRML_SFBOOL: - res = xmt_parse_bool(parser, info->name, (SFBool *)info->far_ptr, a_value); + res = xmt_parse_bool(parser, info->name, (SFBool *)info->far_ptr, a_value); break; case GF_SG_VRML_SFFLOAT: - res = xmt_parse_float(parser, info->name, (SFFloat *)info->far_ptr, a_value); + res = xmt_parse_float(parser, info->name, (SFFloat *)info->far_ptr, a_value); break; case GF_SG_VRML_SFTIME: - res = xmt_parse_time(parser, info->name, (SFTime *)info->far_ptr, a_value); + res = xmt_parse_time(parser, info->name, (SFTime *)info->far_ptr, a_value); xmt_check_time_offset(parser, n, info); break; case GF_SG_VRML_SFCOLOR: - res = xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->red, a_value); - res += xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->green, a_value + res); - res += xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->blue, a_value + res); + res = xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->red, a_value); + res += xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->green, a_value + res); + res += xmt_parse_float(parser, info->name, & ((SFColor *)info->far_ptr)->blue, a_value + res); break; case GF_SG_VRML_SFVEC2F: - res = xmt_parse_float(parser, info->name, & ((SFVec2f *)info->far_ptr)->x, a_value); - res += xmt_parse_float(parser, info->name, & ((SFVec2f *)info->far_ptr)->y, a_value + res); + res = xmt_parse_float(parser, info->name, & ((SFVec2f *)info->far_ptr)->x, a_value); + res += xmt_parse_float(parser, info->name, & ((SFVec2f *)info->far_ptr)->y, a_value + res); break; case GF_SG_VRML_SFVEC3F: - res = xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->x, a_value); - res += xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->y, a_value + res); - res += xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->z, a_value + res); + res = xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->x, a_value); + res += xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->y, a_value + res); + res += xmt_parse_float(parser, info->name, & ((SFVec3f *)info->far_ptr)->z, a_value + res); break; case GF_SG_VRML_SFROTATION: - res = xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->x, a_value); - res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->y, a_value + res); - res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->z, a_value + res); - res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->q, a_value + res); + res = xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->x, a_value); + res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->y, a_value + res); + res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->z, a_value + res); + res += xmt_parse_float(parser, info->name, & ((SFRotation *)info->far_ptr)->q, a_value + res); break; case GF_SG_VRML_SFSTRING: - res = xmt_parse_string(parser, info->name, (SFString*)info->far_ptr, 0, a_value); + res = xmt_parse_string(parser, info->name, (SFString*)info->far_ptr, 0, a_value); if (n && (n->sgprivate->tag==TAG_MPEG4_BitWrapper)) { gf_sm_update_bitwrapper_buffer(n, parser->load->fileName); } break; case GF_SG_VRML_SFSCRIPT: - res = xmt_parse_script(parser, info->name, (SFScript *)info->far_ptr, 0, a_value); + res = xmt_parse_script(parser, info->name, (SFScript *)info->far_ptr, 0, a_value); break; case GF_SG_VRML_SFCOMMANDBUFFER: { @@ -933,7 +934,7 @@ static u32 xmt_parse_sf_field(GF_XMTParser *parser, GF_FieldInfo *info, GF_Node } parser->command_buffer = cb; } - break; + break; case GF_SG_VRML_SFIMAGE: { @@ -983,7 +984,7 @@ static u32 xmt_parse_sf_field(GF_XMTParser *parser, GF_FieldInfo *info, GF_Node a_value += i; } } - break; + break; default: parser->last_error = GF_NOT_SUPPORTED; @@ -1012,11 +1013,11 @@ static void xmt_parse_mf_field(GF_XMTParser *parser, GF_FieldInfo *info, GF_Node /*special case for MF type based on string (MFString, MFURL and MFScript), we need to take care of all possible forms of XML multi string encoding*/ if (sfInfo.fieldType == GF_SG_VRML_SFSTRING) { - res = xmt_parse_string(parser, info->name, (SFString*)sfInfo.far_ptr, 1, value); + res = xmt_parse_string(parser, info->name, (SFString*)sfInfo.far_ptr, 1, value); } else if (sfInfo.fieldType == GF_SG_VRML_SFURL) { - res = xmt_parse_url(parser, info->name, (MFURL *)info->far_ptr, n, 1, value); + res = xmt_parse_url(parser, info->name, (MFURL *)info->far_ptr, n, 1, value); } else if (sfInfo.fieldType == GF_SG_VRML_SFSCRIPT) { - res = xmt_parse_script(parser, info->name, (SFScript*)sfInfo.far_ptr, 1, value); + res = xmt_parse_script(parser, info->name, (SFScript*)sfInfo.far_ptr, 1, value); } else { res = xmt_parse_sf_field(parser, &sfInfo, n, value); } @@ -1039,13 +1040,13 @@ static Bool xmt_has_been_def(GF_XMTParser *parser, char *node_name) return 0; } -static u32 xmt_get_route(GF_XMTParser *parser, char *name, Bool del_com) +static u32 xmt_get_route(GF_XMTParser *parser, char *name, Bool del_com) { u32 i; GF_Command *com; GF_Route *r = gf_sg_route_find_by_name(parser->load->scene_graph, name); if (r) return r->ID; - i=0; + i=0; while ((com = (GF_Command *)gf_list_enum(parser->inserted_routes, &i))) { if (com->def_name && !strcmp(com->def_name, name)) { if (del_com) gf_list_rem(parser->inserted_routes, i); @@ -1074,7 +1075,7 @@ static u32 xmt_get_next_route_id(GF_XMTParser *parser) if (parser->parsing_proto) sc = gf_sg_proto_get_graph(parser->parsing_proto); ID = gf_sg_get_next_available_route_id(sc); - if (parser->load->ctx && (ID>parser->load->ctx->max_route_id)) + if (parser->load->ctx && (ID>parser->load->ctx->max_route_id)) parser->load->ctx->max_route_id = ID; return ID; } @@ -1226,7 +1227,7 @@ static void xmt_update_timenode(GF_XMTParser *parser, GF_Node *node) xmt_check_time_offset(parser, node, &inf); } } - break; + break; } } @@ -1309,9 +1310,9 @@ static void xmt_parse_script_field(GF_XMTParser *parser, GF_Node *node, const GF for (i=0; ivalue || !strlen(att->value)) continue; - if (!strcmp(att->name, "name")) fieldName = att->value; - else if (!strcmp(att->name, "type")) fieldType = xmt_get_ft_by_name(att->value); - else if (!strcmp(att->name, "vrml97Hint") || !strcmp(att->name, "accessType")) eventType = xmt_get_script_et_by_name(att->value); + if (!strcmp(att->name, "name")) fieldName = att->value; + else if (!strcmp(att->name, "type")) fieldType = xmt_get_ft_by_name(att->value); + else if (!strcmp(att->name, "vrml97Hint") || !strcmp(att->name, "accessType")) eventType = xmt_get_script_et_by_name(att->value); else if (strstr(att->name, "value") || strstr(att->name, "Value")) val = att->value; } scfield = gf_sg_script_field_new(node, eventType, fieldType, fieldName); @@ -1336,7 +1337,7 @@ static u32 xmt_get_next_proto_id(GF_XMTParser *parser) GF_SceneGraph *sc = parser->load->scene_graph; if (parser->parsing_proto) sc = gf_sg_proto_get_graph(parser->parsing_proto); ID = gf_sg_get_next_available_proto_id(sc); - if (parser->load->ctx && (ID>parser->load->ctx->max_node_id)) + if (parser->load->ctx && (ID>parser->load->ctx->max_node_id)) parser->load->ctx->max_proto_id = ID; return ID; } @@ -1353,8 +1354,8 @@ static void xmt_parse_proto(GF_XMTParser *parser, const GF_XMLAttribute *attribu for (i=0; ivalue || !strlen(att->value)) continue; - if (!strcmp(att->name, "name")) szName = att->value; - else if (!strcmp(att->name, "protoID")) ID = atoi(att->value); + if (!strcmp(att->name, "name")) szName = att->value; + else if (!strcmp(att->name, "protoID")) ID = atoi(att->value); else if (!strcmp(att->name, "locations")) extURL = att->value; else if (!strcmp(att->name, "url")) extURL = att->value; } @@ -1437,11 +1438,11 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } return NULL; } - if (parent && parent->node && ((parent->node->sgprivate->tag==TAG_MPEG4_Script) + if (parent && parent->node && ((parent->node->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (parent->node->sgprivate->tag==TAG_X3D_Script) + || (parent->node->sgprivate->tag==TAG_X3D_Script) #endif - ) ) { + ) ) { is_script = 1; if (!strcmp(name, "field")) { xmt_parse_script_field(parser, parent->node, attributes, nb_attributes); @@ -1458,9 +1459,9 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } /*proto parsing*/ if (parser->parsing_proto) { - if (!strcmp(name, "IS")) + if (!strcmp(name, "IS")) return NULL; - + if (!strcmp(name, "field")) { char *fieldName = NULL; char *value = NULL; @@ -1486,7 +1487,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } } else if (gf_sg_vrml_get_sf_type(fType) != GF_SG_VRML_SFNODE) { /*value not specified for exter proto*/ - } + } /*SF/MFNode proto field: push node stack with container info but no parent*/ else { XMTNodeStack *pf_stack; @@ -1496,12 +1497,12 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } return NULL; } - + /*X3D style*/ - if (!strcmp(name, "ProtoInterface") || !strcmp(name, "ProtoBody")) + if (!strcmp(name, "ProtoInterface") || !strcmp(name, "ProtoBody")) return NULL; /*XMT1 decl for SFNode proto fields*/ - if (parser->proto_field && (!strcmp(name, "node") || !strcmp(name, "nodes")) ) + if (parser->proto_field && (!strcmp(name, "node") || !strcmp(name, "nodes")) ) return NULL; /*anim & QP info */ if (parser->proto_field && !strcmp(name, "InterfaceCodingParameters")) { @@ -1514,11 +1515,11 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * if (!att->value || !strlen(att->value)) continue; if (!strcmp(att->name, "quantCategory")) qp_type = xmt_get_protofield_qp_type(att->value); else if (!strcmp(att->name, "nbBits")) nbBits = atoi(att->value); - else if (!strncmp(att->name, "position3DM", 11) || !strncmp(att->name, "position2DM", 11) - || !strncmp(att->name, "drawOrderM", 10) || !strncmp(att->name, "colorM", 6) - || !strncmp(att->name, "textureCoordinateM", 18) || !strncmp(att->name, "angleM", 6) - || !strncmp(att->name, "scaleM", 6) || !strncmp(att->name, "keyM", 4) || !strncmp(att->name, "sizeM", 5) - ) { + else if (!strncmp(att->name, "position3DM", 11) || !strncmp(att->name, "position2DM", 11) + || !strncmp(att->name, "drawOrderM", 10) || !strncmp(att->name, "colorM", 6) + || !strncmp(att->name, "textureCoordinateM", 18) || !strncmp(att->name, "angleM", 6) + || !strncmp(att->name, "scaleM", 6) || !strncmp(att->name, "keyM", 4) || !strncmp(att->name, "sizeM", 5) + ) { hasMinMax = 1; if (strstr(att->name, "Min")) xmt_parse_float(parser, att->name, &ftMin, att->value); else xmt_parse_float(parser, att->name, &ftMax, att->value); @@ -1560,11 +1561,11 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } if ( (e = gf_node_get_field_by_name(last->node, atField, &nfield)) != GF_OK) { u32 l_tag = gf_node_get_tag(last->node); - if ((l_tag!=TAG_MPEG4_Script) + if ((l_tag!=TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - && (l_tag!=TAG_X3D_Script) + && (l_tag!=TAG_X3D_Script) #endif - ) { + ) { xmt_report(parser, e, "connect: %s not an field of node %s", atField, gf_node_get_class_name(last->node) ); return NULL; } @@ -1624,7 +1625,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * if (parent && parent->node && (parent->node->sgprivate->tag == TAG_ProtoNode) && (!strcmp(name, "node") || !strcmp(name, "nodes")) ) { return NULL; } - + ID = 0; def_name = NULL; tag = 0; @@ -1651,7 +1652,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * else if (!strcmp(att->name, "USE")) { node = xmt_find_node(parser, att->value); e = GF_OK; - if (!node) + if (!node) e = xmt_report(parser, GF_BAD_PARAM, "Warning: Cannot find node %s referenced in USE - skipping", att->value); if (e) return NULL; @@ -1662,7 +1663,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } } else { tag = xmt_get_node_tag(parser, name); - + if (!tag) { /*XMT-A weird syntax*/ if (parent) { @@ -1724,7 +1725,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * parser->current_node_tag = tag; if (parent) container = parent->container_field; - else { + else { container.far_ptr = NULL; container.fieldIndex = 0; container.fieldType = 0; @@ -1764,7 +1765,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * def_node = xmt_find_node(parser, att->value); e = GF_OK; - if (!def_node) + if (!def_node) e = xmt_report(parser, GF_BAD_PARAM, "Warning: Cannot find node %s referenced in USE - skipping", att->value); else if (tag != gf_node_get_tag(def_node)) { xmt_report(parser, GF_OK, "Warning: Node type %s doesn't match type %s of node %s", gf_node_get_class_name(node), gf_node_get_class_name(def_node), att->value); @@ -1793,7 +1794,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * } /*ignored ones*/ else if (!strcmp(att->name, "bboxCenter") || !strcmp(att->name, "bboxSize")) { - } + } /*all other fields*/ else { e = gf_node_get_field_by_name(node, att->name, &info); @@ -1814,7 +1815,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * if (is_script) { u32 last_field = gf_node_get_field_count(parent->node); gf_node_get_field(parent->node, last_field-1, &container); - } + } if (parent) { if (!container.far_ptr) { @@ -1841,7 +1842,7 @@ static GF_Node *xmt_parse_element(GF_XMTParser *parser, char *name, const char * assert(parent->node); gf_node_changed(parent->node, NULL); } - + if (!parser->parsing_proto && (tag || proto) ) gf_node_init(node); @@ -1917,7 +1918,7 @@ GF_Descriptor *xmt_parse_descriptor(GF_XMTParser *parser, char *name, const GF_X else if (!strcmp(att->name, "OCR_ES_ID")) ocr_ref = att->value; else if (!strcmp(att->name, "dependsOn_ES_ID")) dep_ref = att->value; else if ((desc->tag==GF_ODF_MUXINFO_TAG) && (!stricmp(att->name, "fileName") || !stricmp(att->name, "url"))) { - char *res_name = gf_url_concatenate(parser->load->fileName, att->value); + char *res_name = gf_url_concatenate(parser->load->fileName, (const char *)att->value); e = gf_odf_set_field(desc, att->name, res_name ? res_name : att->value); if (e) xmt_report(parser, e, "Warning: %s not a valid attribute for descriptor %s", att->name, name); if (res_name) @@ -1928,7 +1929,7 @@ GF_Descriptor *xmt_parse_descriptor(GF_XMTParser *parser, char *name, const GF_X } } if (binaryID || xmt_desc_name) { - if ((tag == GF_ODF_IOD_TAG) || (tag == GF_ODF_OD_TAG)) + if ((tag == GF_ODF_IOD_TAG) || (tag == GF_ODF_OD_TAG)) xmt_new_od_link(parser, (GF_ObjectDescriptor *)desc, xmt_desc_name, binaryID); else if (tag == GF_ODF_ESD_TAG) { xmt_new_esd_link(parser, (GF_ESD *) desc, xmt_desc_name, binaryID); @@ -2217,9 +2218,9 @@ static void xmt_parse_command(GF_XMTParser *parser, const char *name, const GF_X au_is_rap = 1; gf_list_reset(parser->def_nodes); } - else if (!strcmp(name, "Insert")) + else if (!strcmp(name, "Insert")) tag = GF_SG_ROUTE_INSERT; - + if (extended) { if (!strcmp(extended, "globalQuant")) { tag = GF_SG_GLOBAL_QUANTIZER; @@ -2353,10 +2354,10 @@ static void xmt_parse_command(GF_XMTParser *parser, const char *name, const GF_X field->fieldType = GF_SG_VRML_MFNODE; } else { field->fieldType = GF_SG_VRML_SFNODE; - } + } parser->state = XMT_STATE_ELEMENTS; } - } + } } else if (tag==GF_SG_NODE_INSERT) { field = gf_sg_command_field_new(parser->command); field->fieldType = GF_SG_VRML_SFNODE; @@ -2402,8 +2403,8 @@ static void xmt_parse_command(GF_XMTParser *parser, const char *name, const GF_X /*OD commands*/ if (!strcmp(name, "ObjectDescriptorUpdate") || !strcmp(name, "ObjectDescriptorRemove") - || !strcmp(name, "ES_DescriptorUpdate") || !strcmp(name, "ES_DescriptorRemove") - || !strcmp(name, "IPMP_DescriptorUpdate") || !strcmp(name, "IPMP_DescriptorRemove") ) { + || !strcmp(name, "ES_DescriptorUpdate") || !strcmp(name, "ES_DescriptorRemove") + || !strcmp(name, "IPMP_DescriptorUpdate") || !strcmp(name, "IPMP_DescriptorRemove") ) { u32 stream_id; u8 tag = 0; GF_StreamContext *stream; @@ -2447,7 +2448,7 @@ static void xmt_parse_command(GF_XMTParser *parser, const char *name, const GF_X parser->od_au = gf_sm_stream_au_new(parser->od_es, 0, au_time, au_is_rap); parser->od_command = gf_odf_com_new(tag); gf_list_add(parser->od_au->commands, parser->od_command); - + if (tag == GF_ODF_ESD_REMOVE_TAG) { char *sep; GF_ESDRemove *esdR = (GF_ESDRemove *) parser->od_command ; @@ -2498,7 +2499,7 @@ static void xmt_node_start(void *sax_cbck, const char *name, const char *name_sp if (parser->last_error) { gf_xml_sax_suspend(parser->sax_parser, 1); - if (parser->command_buffer) + if (parser->command_buffer) parser->command_buffer->buffer = NULL; return; } @@ -2540,13 +2541,13 @@ static void xmt_node_start(void *sax_cbck, const char *name, const char *name_sp } if (parser->state==XMT_STATE_END) { if (!strcmp(name, "head")) { - parser->state = XMT_STATE_HEAD; + parser->state = XMT_STATE_HEAD; } else { parser->state = XMT_STATE_COMMANDS; } } - /*scene content*/ + /*scene content*/ if (parser->state==XMT_STATE_BODY) { /*XMT-A body*/ if ((parser->doc_type == 1) && !strcmp(name, "Body")) parser->state = XMT_STATE_COMMANDS; @@ -2626,7 +2627,7 @@ static void xmt_node_end(void *sax_cbck, const char *name, const char *name_spac if ((parser->doc_type==1) && (parser->state==XMT_STATE_HEAD) && parser->load->ctx && !parser->load->ctx->root_od) { parser->load->ctx->root_od = (GF_ObjectDescriptor *)desc; - } + } else if (!parser->od_command) { xmt_report(parser, GF_OK, "Warning: descriptor %s defined outside scene scope - skipping", name); gf_odf_desc_del(desc); @@ -2712,8 +2713,8 @@ static void xmt_node_end(void *sax_cbck, const char *name, const char *name_spac } /*end OD command*/ else if (!strcmp(name, "ObjectDescriptorUpdate") || !strcmp(name, "ObjectDescriptorRemove") - || !strcmp(name, "ES_DescriptorUpdate") || !strcmp(name, "ES_DescriptorRemove") - || !strcmp(name, "IPMP_DescriptorUpdate") || !strcmp(name, "IPMP_DescriptorRemove") ) { + || !strcmp(name, "ES_DescriptorUpdate") || !strcmp(name, "ES_DescriptorRemove") + || !strcmp(name, "IPMP_DescriptorUpdate") || !strcmp(name, "IPMP_DescriptorRemove") ) { parser->od_command = NULL; } @@ -2873,7 +2874,7 @@ attach_node: break; } - } + } /*X3D*/ else if (parser->doc_type == 2) { if (parser->parsing_proto) { @@ -2904,11 +2905,11 @@ attach_node: if (parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK) { /*load scripts*/ if (!parser->parsing_proto) { - if ((tag==TAG_MPEG4_Script) + if ((tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (tag==TAG_X3D_Script) + || (tag==TAG_X3D_Script) #endif - ) { + ) { /*it may happen that the script uses itself as a field (not sure this is compliant since this implies a cyclic structure, but happens in some X3D conformance seq)*/ if (!top || (top->node != node)) { @@ -3000,18 +3001,18 @@ static GF_Err xmt_restore_context(GF_SceneLoader *load) /*restore context - note that base layer are ALWAYS declared BEFORE enhancement layers with gpac parsers*/ i=0; - while ((sc = (GF_StreamContext*)gf_list_enum(load->ctx->streams, &i))){ + while ((sc = (GF_StreamContext*)gf_list_enum(load->ctx->streams, &i))) { switch (sc->streamType) { case GF_STREAM_SCENE: case GF_STREAM_PRIVATE_SCENE: - if (!parser->scene_es) - parser->scene_es = sc; + if (!parser->scene_es) + parser->scene_es = sc; break; - case GF_STREAM_OD: - if (!parser->od_es) - parser->od_es = sc; + case GF_STREAM_OD: + if (!parser->od_es) + parser->od_es = sc; break; - default: + default: break; } } diff --git a/src/scene_manager/scene_dump.c b/src/scene_manager/scene_dump.c index bde2e69..8343279 100644 --- a/src/scene_manager/scene_dump.c +++ b/src/scene_manager/scene_dump.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -52,7 +52,7 @@ struct _scenedump FILE *trace; u32 indent; char *filename; - + u32 dump_mode; u16 CurrentESID; u8 ind_char; @@ -92,7 +92,7 @@ GF_SceneDumper *gf_sm_dumper_new(GF_SceneGraph *graph, char *_rad_name, char ind #ifndef GPAC_DISABLE_SVG if ((graph->RootNode && (graph->RootNode->sgprivate->tag>=GF_NODE_RANGE_LAST_VRML) ) - || (dump_mode==GF_SM_DUMP_LASER) || (dump_mode==GF_SM_DUMP_SVG)) { + || (dump_mode==GF_SM_DUMP_LASER) || (dump_mode==GF_SM_DUMP_SVG)) { tmp->XMLDump = 1; if (dump_mode==GF_SM_DUMP_LASER) tmp->LSRDump = 1; if (_rad_name) { @@ -108,7 +108,7 @@ GF_SceneDumper *gf_sm_dumper_new(GF_SceneGraph *graph, char *_rad_name, char ind } else { tmp->trace = stdout; } - } else + } else #endif { @@ -130,11 +130,25 @@ GF_SceneDumper *gf_sm_dumper_new(GF_SceneGraph *graph, char *_rad_name, char ind if (_rad_name) { const char* ext_name; switch (dump_mode) { - case GF_SM_DUMP_X3D_XML: ext_name = ".x3d"; tmp->XMLDump = 1; tmp->X3DDump = 1; break; - case GF_SM_DUMP_XMTA: ext_name = ".xmt"; tmp->XMLDump = 1; break; - case GF_SM_DUMP_X3D_VRML: ext_name = ".x3dv"; tmp->X3DDump = 1; break; - case GF_SM_DUMP_VRML: ext_name = ".wrl"; break; - default: ext_name = ".bt"; break; + case GF_SM_DUMP_X3D_XML: + ext_name = ".x3d"; + tmp->XMLDump = 1; + tmp->X3DDump = 1; + break; + case GF_SM_DUMP_XMTA: + ext_name = ".xmt"; + tmp->XMLDump = 1; + break; + case GF_SM_DUMP_X3D_VRML: + ext_name = ".x3dv"; + tmp->X3DDump = 1; + break; + case GF_SM_DUMP_VRML: + ext_name = ".wrl"; + break; + default: + ext_name = ".bt"; + break; } tmp->filename = gf_malloc(strlen(_rad_name ? _rad_name : "") + strlen(ext_name) + 1); strcpy(tmp->filename, _rad_name ? _rad_name : ""); @@ -147,10 +161,18 @@ GF_SceneDumper *gf_sm_dumper_new(GF_SceneGraph *graph, char *_rad_name, char ind } else { tmp->trace = stdout; switch (dump_mode) { - case GF_SM_DUMP_X3D_XML: tmp->XMLDump = 1; tmp->X3DDump = 1; break; - case GF_SM_DUMP_XMTA: tmp->XMLDump = 1; break; - case GF_SM_DUMP_X3D_VRML: tmp->X3DDump = 1; break; - default: break; + case GF_SM_DUMP_X3D_XML: + tmp->XMLDump = 1; + tmp->X3DDump = 1; + break; + case GF_SM_DUMP_XMTA: + tmp->XMLDump = 1; + break; + case GF_SM_DUMP_X3D_VRML: + tmp->X3DDump = 1; + break; + default: + break; } } } @@ -198,11 +220,11 @@ static void gf_dump_setup(GF_SceneDumper *sdump, GF_Descriptor *root_od) if (sdump->XMLDump) { fprintf(sdump->trace, "\n"); if (sdump->dump_mode==GF_SM_DUMP_XML) return; - fprintf(sdump->trace, "\n", - (sdump->dump_mode==GF_SM_DUMP_SVG) ? "SVG" : - (sdump->dump_mode==GF_SM_DUMP_LASER) ? "LASeR" : - sdump->X3DDump ? "X3D" : "XMT-A" - ); + fprintf(sdump->trace, "\n", + (sdump->dump_mode==GF_SM_DUMP_SVG) ? "SVG" : + (sdump->dump_mode==GF_SM_DUMP_LASER) ? "LASeR" : + sdump->X3DDump ? "X3D" : "XMT-A" + ); } if (sdump->dump_mode==GF_SM_DUMP_SVG) return; if (sdump->LSRDump) { @@ -374,7 +396,7 @@ static void StartList(GF_SceneDumper *sdump, const char *name) if (!sdump->trace) return; DUMP_IND(sdump); if (!sdump->XMLDump) { - if (name) + if (name) fprintf(sdump->trace, "%s [\n", name); else fprintf(sdump->trace, "[\n"); @@ -410,34 +432,34 @@ static void scene_dump_utf_string(GF_SceneDumper *sdump, Bool escape_xml, char * for (i=0; itrace, "\\"); switch (uniLine[i]) { - case '\'': - if (escape_xml) fprintf(sdump->trace, "'"); - else fprintf(sdump->trace, "'"); + case '\'': + if (escape_xml) fprintf(sdump->trace, "'"); + else fprintf(sdump->trace, "'"); break; - case '\"': - if (escape_xml) fprintf(sdump->trace, """); - else fprintf(sdump->trace, "\""); + case '\"': + if (escape_xml) fprintf(sdump->trace, """); + else fprintf(sdump->trace, "\""); break; - case '&': - fprintf(sdump->trace, "&"); + case '&': + fprintf(sdump->trace, "&"); break; - case '>': - fprintf(sdump->trace, ">"); + case '>': + fprintf(sdump->trace, ">"); break; - case '<': - fprintf(sdump->trace, "<"); + case '<': + fprintf(sdump->trace, "<"); break; case '\r': case '\n': - /* Does nothing : fprintf(sdump->trace, "");, fflush instead ?*/ - break; + /* Does nothing : fprintf(sdump->trace, "");, fflush instead ?*/ + break; default: - if (uniLine[i]<128) { - fprintf(sdump->trace, "%c", (u8) uniLine[i]); - } else { - fprintf(sdump->trace, "&#%d;", uniLine[i]); - } - break; + if (uniLine[i]<128) { + fprintf(sdump->trace, "%c", (u8) uniLine[i]); + } else { + fprintf(sdump->trace, "&#%d;", uniLine[i]); + } + break; } } } @@ -453,7 +475,7 @@ static void scene_dump_vrml_id(GF_SceneDumper *sdump, GF_Node *node) if (!sdump->trace) return; /*FIXME - optimize id/name fetch*/ node_name = gf_node_get_name_and_id(node, &id); - if (node_name) + if (node_name) fprintf(sdump->trace, "%s", node_name); else fprintf(sdump->trace, "N%d", id - 1); @@ -465,7 +487,10 @@ static Bool scene_dump_vrml_find_route_name(GF_SceneDumper *sdump, u32 ID, const u32 i; GF_Command *com; r = gf_sg_route_find(sdump->sg, ID); - if (r) { (*outName) = r->name; return 1; } + if (r) { + (*outName) = r->name; + return 1; + } i=0; while ((com = (GF_Command *)gf_list_enum(sdump->inserted_routes, &i))) { @@ -494,7 +519,7 @@ static void scene_dump_vrml_route_id(GF_SceneDumper *sdump, u32 routeID, char *r if (!sdump->trace) return; if (!rName) scene_dump_vrml_find_route_name(sdump, routeID, (const char **) &rName); - if (rName) + if (rName) fprintf(sdump->trace, "%s", rName); else fprintf(sdump->trace, "R%d", routeID - 1); @@ -551,7 +576,7 @@ static void gf_dump_vrml_sffield(GF_SceneDumper *sdump, u32 type, void *ptr, Boo fprintf(sdump->trace, ".%s", pinfo.name); } } - break; + break; case GF_SG_VRML_SFSCRIPT: { size_t _len; @@ -575,16 +600,22 @@ static void gf_dump_vrml_sffield(GF_SceneDumper *sdump, u32 type, void *ptr, Boo #endif } else { switch (uniLine[i]) { - case '&': fprintf(sdump->trace, "&"); break; - case '<': fprintf(sdump->trace, "<"); break; - case '>': fprintf(sdump->trace, ">"); break; - case '\'': - case '"': + case '&': + fprintf(sdump->trace, "&"); + break; + case '<': + fprintf(sdump->trace, "<"); + break; + case '>': + fprintf(sdump->trace, ">"); + break; + case '\'': + case '"': fprintf(sdump->trace, "'"); break; case 0: break; - /*FIXME: how the heck can we preserve newlines and spaces of JavaScript in + /*FIXME: how the heck can we preserve newlines and spaces of JavaScript in an XML attribute in any viewer ? */ default: if (uniLine[i]<128) { @@ -595,13 +626,13 @@ static void gf_dump_vrml_sffield(GF_SceneDumper *sdump, u32 type, void *ptr, Boo break; } } - } + } if (!sdump->XMLDump) fprintf(sdump->trace, "\"\n"); } gf_free(uniLine); DUMP_IND(sdump); } - break; + break; case GF_SG_VRML_SFSTRING: { @@ -652,7 +683,7 @@ static void gf_dump_vrml_sffield(GF_SceneDumper *sdump, u32 type, void *ptr, Boo fprintf(sdump->trace, "\""); } } - break; + break; case GF_SG_VRML_SFURL: if (((SFURL *)ptr)->url) { @@ -735,9 +766,9 @@ static void gf_dump_vrml_simple_field(GF_SceneDumper *sdump, GF_FieldInfo field, sdump->indent--; return; case GF_SG_VRML_SFCOMMANDBUFFER: - { - } - return; + { + } + return; } if (gf_sg_vrml_is_sf_field(field.fieldType)) { if (sdump->XMLDump) StartAttribute(sdump, "value"); @@ -795,7 +826,7 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf switch (field.fieldType) { case GF_SG_VRML_SFNODE: assert ( *(GF_Node **)field.far_ptr); - + if (sdump->XMLDump) { if (!sdump->X3DDump) { StartElement(sdump, (char *) field.name); @@ -806,7 +837,7 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf StartAttribute(sdump, field.name); } gf_dump_vrml_node(sdump, *(GF_Node **)field.far_ptr, 0, NULL); - + if (sdump->XMLDump) { if (!sdump->X3DDump) { sdump->indent--; @@ -854,7 +885,7 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf sdump->indent--; EndElement(sdump, (char *) field.name, 1); } - return; + return; case GF_SG_VRML_MFATTRREF: if (sdump->XMLDump) { @@ -877,7 +908,7 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf sdump->indent--; EndElement(sdump, (char *) field.name, 1); return; - } + } break; } @@ -912,7 +943,7 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf gf_dump_vrml_sffield(sdump, sf_type, slot_ptr, 1, node); } if (!sdump->XMLDump) fprintf(sdump->trace, "]"); - + if (sdump->XMLDump && sdump->X3DDump) { switch (sf_type) { case GF_SG_VRML_SFSTRING: @@ -933,55 +964,99 @@ static void gf_dump_vrml_field(GF_SceneDumper *sdump, GF_Node *node, GF_FieldInf static const char *GetXMTFieldTypeName(u32 fieldType) { switch (fieldType) { - case GF_SG_VRML_SFBOOL: return "Boolean"; - case GF_SG_VRML_SFINT32: return "Integer"; - case GF_SG_VRML_SFCOLOR: return "Color"; - case GF_SG_VRML_SFVEC2F: return "Vector2"; - case GF_SG_VRML_SFIMAGE: return "Image"; - case GF_SG_VRML_SFTIME: return "Time"; - case GF_SG_VRML_SFFLOAT: return "Float"; - case GF_SG_VRML_SFVEC3F: return "Vector3"; - case GF_SG_VRML_SFROTATION: return "Rotation"; - case GF_SG_VRML_SFSTRING: return "String"; - case GF_SG_VRML_SFNODE: return "Node"; - case GF_SG_VRML_MFBOOL: return "Booleans"; - case GF_SG_VRML_MFINT32: return "Integers"; - case GF_SG_VRML_MFCOLOR: return "Colors"; - case GF_SG_VRML_MFVEC2F: return "Vector2Array"; - case GF_SG_VRML_MFIMAGE: return "Images"; - case GF_SG_VRML_MFTIME: return "Times"; - case GF_SG_VRML_MFFLOAT: return "Floats"; - case GF_SG_VRML_MFVEC3F: return "Vector3Array"; - case GF_SG_VRML_MFROTATION: return "Rotations"; - case GF_SG_VRML_MFSTRING: return "Strings"; - case GF_SG_VRML_MFNODE: return "Nodes"; - default: return "unknown"; + case GF_SG_VRML_SFBOOL: + return "Boolean"; + case GF_SG_VRML_SFINT32: + return "Integer"; + case GF_SG_VRML_SFCOLOR: + return "Color"; + case GF_SG_VRML_SFVEC2F: + return "Vector2"; + case GF_SG_VRML_SFIMAGE: + return "Image"; + case GF_SG_VRML_SFTIME: + return "Time"; + case GF_SG_VRML_SFFLOAT: + return "Float"; + case GF_SG_VRML_SFVEC3F: + return "Vector3"; + case GF_SG_VRML_SFROTATION: + return "Rotation"; + case GF_SG_VRML_SFSTRING: + return "String"; + case GF_SG_VRML_SFNODE: + return "Node"; + case GF_SG_VRML_MFBOOL: + return "Booleans"; + case GF_SG_VRML_MFINT32: + return "Integers"; + case GF_SG_VRML_MFCOLOR: + return "Colors"; + case GF_SG_VRML_MFVEC2F: + return "Vector2Array"; + case GF_SG_VRML_MFIMAGE: + return "Images"; + case GF_SG_VRML_MFTIME: + return "Times"; + case GF_SG_VRML_MFFLOAT: + return "Floats"; + case GF_SG_VRML_MFVEC3F: + return "Vector3Array"; + case GF_SG_VRML_MFROTATION: + return "Rotations"; + case GF_SG_VRML_MFSTRING: + return "Strings"; + case GF_SG_VRML_MFNODE: + return "Nodes"; + default: + return "unknown"; } } static const char *GetXMTFieldTypeValueName(u32 fieldType) { switch (fieldType) { - case GF_SG_VRML_SFBOOL: return "booleanValue"; - case GF_SG_VRML_SFINT32: return "intValue"; - case GF_SG_VRML_SFCOLOR: return "colorValue"; - case GF_SG_VRML_SFVEC2F: return "vector2Value"; - case GF_SG_VRML_SFIMAGE: return "imageValue"; - case GF_SG_VRML_SFTIME: return "timeValue"; - case GF_SG_VRML_SFFLOAT: return "floatValue"; - case GF_SG_VRML_SFVEC3F: return "vector3Value"; - case GF_SG_VRML_SFROTATION: return "rotationValue"; - case GF_SG_VRML_SFSTRING: return "stringValue"; - case GF_SG_VRML_MFBOOL: return "booleanArrayValue"; - case GF_SG_VRML_MFINT32: return "intArrayValue"; - case GF_SG_VRML_MFCOLOR: return "colorArrayValue"; - case GF_SG_VRML_MFVEC2F: return "vector2ArrayValue"; - case GF_SG_VRML_MFIMAGE: return "imageArrayValue"; - case GF_SG_VRML_MFTIME: return "timeArrayValue"; - case GF_SG_VRML_MFFLOAT: return "floatArrayValue"; - case GF_SG_VRML_MFVEC3F: return "vector3ArrayValue"; - case GF_SG_VRML_MFROTATION: return "rotationArrayValue"; - case GF_SG_VRML_MFSTRING: return "stringArrayValue"; - default: return "unknown"; + case GF_SG_VRML_SFBOOL: + return "booleanValue"; + case GF_SG_VRML_SFINT32: + return "intValue"; + case GF_SG_VRML_SFCOLOR: + return "colorValue"; + case GF_SG_VRML_SFVEC2F: + return "vector2Value"; + case GF_SG_VRML_SFIMAGE: + return "imageValue"; + case GF_SG_VRML_SFTIME: + return "timeValue"; + case GF_SG_VRML_SFFLOAT: + return "floatValue"; + case GF_SG_VRML_SFVEC3F: + return "vector3Value"; + case GF_SG_VRML_SFROTATION: + return "rotationValue"; + case GF_SG_VRML_SFSTRING: + return "stringValue"; + case GF_SG_VRML_MFBOOL: + return "booleanArrayValue"; + case GF_SG_VRML_MFINT32: + return "intArrayValue"; + case GF_SG_VRML_MFCOLOR: + return "colorArrayValue"; + case GF_SG_VRML_MFVEC2F: + return "vector2ArrayValue"; + case GF_SG_VRML_MFIMAGE: + return "imageArrayValue"; + case GF_SG_VRML_MFTIME: + return "timeArrayValue"; + case GF_SG_VRML_MFFLOAT: + return "floatArrayValue"; + case GF_SG_VRML_MFVEC3F: + return "vector3ArrayValue"; + case GF_SG_VRML_MFROTATION: + return "rotationArrayValue"; + case GF_SG_VRML_MFSTRING: + return "stringArrayValue"; + default: + return "unknown"; } } @@ -989,22 +1064,37 @@ static const char *SD_GetQuantCatName(u32 QP_Type) { switch (QP_Type) { #ifndef GPAC_DISABLE_BIFS - case QC_3DPOS: return "position3D"; - case QC_2DPOS: return "position2D"; - case QC_ORDER: return "drawingOrder"; - case QC_COLOR: return "color"; - case QC_TEXTURE_COORD: return "textureCoordinate"; - case QC_ANGLE: return "angle"; - case QC_SCALE: return "scale"; - case QC_INTERPOL_KEYS: return "keys"; - case QC_NORMALS: return "normals"; - case QC_ROTATION: return "rotations"; - case QC_SIZE_3D: return "size3D"; - case QC_SIZE_2D: return "size2D"; - case QC_LINEAR_SCALAR: return "linear"; - case QC_COORD_INDEX: return "coordIndex"; + case QC_3DPOS: + return "position3D"; + case QC_2DPOS: + return "position2D"; + case QC_ORDER: + return "drawingOrder"; + case QC_COLOR: + return "color"; + case QC_TEXTURE_COORD: + return "textureCoordinate"; + case QC_ANGLE: + return "angle"; + case QC_SCALE: + return "scale"; + case QC_INTERPOL_KEYS: + return "keys"; + case QC_NORMALS: + return "normals"; + case QC_ROTATION: + return "rotations"; + case QC_SIZE_3D: + return "size3D"; + case QC_SIZE_2D: + return "size2D"; + case QC_LINEAR_SCALAR: + return "linear"; + case QC_COORD_INDEX: + return "coordIndex"; #endif - default: return "unknown"; + default: + return "unknown"; } } @@ -1020,10 +1110,10 @@ static void gf_dump_vrml_dyn_field(GF_SceneDumper *sdump, GF_Node *node, GF_Fiel if (sdump->XMLDump) { if (sdump->X3DDump) { fprintf(sdump->trace, "trace, "X3DDump) { fprintf(sdump->trace, "trace, "FromField.fieldIndex; gf_sg_proto_get_field(sdump->current_proto, NULL, &pfield); } - + if (!sdump->XMLDump) { DUMP_IND(sdump); if (isScript) fprintf(sdump->trace, "%s %s ", gf_sg_vrml_get_event_type_name(field.eventType, sdump->X3DDump), gf_sg_vrml_get_field_type_by_name(field.fieldType)); @@ -1313,7 +1403,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list char *name; GF_Node *base; GF_FieldInfo field, base_field; - + if (!node) { fprintf(sdump->trace, "NULL"); return; @@ -1402,10 +1492,10 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list } if (base) gf_node_register(base, NULL); - + hasISed = 0; to_dump = sub_el = 0; - for (i=0;i2) ? 2 : 1; @@ -1462,7 +1552,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list sub_el++; } } - break; + break; case GF_SG_VRML_MFATTRREF: { MFAttrRef *p = (MFAttrRef*)field.far_ptr; @@ -1472,7 +1562,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list sub_el++; } } - break; + break; default: if (isScript) { to_dump++; @@ -1543,7 +1633,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list } sdump->indent ++; - for (i=0;iXMLDump) { @@ -1585,7 +1675,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list EndElementHeader(sdump, 1); sdump->indent++; } - for (i=0;isgprivate->tag==TAG_X3D_Script) ) { if (*((GF_Node **)field.far_ptr)) gf_dump_vrml_field(sdump, node, field); - } else + } else #endif { gf_dump_vrml_dyn_field(sdump, node, field, 0); @@ -1630,7 +1720,7 @@ static void gf_dump_vrml_node(GF_SceneDumper *sdump, GF_Node *node, Bool in_list if (isScript && !sdump->XMLDump) { gf_node_get_field(node, 0, &field); gf_dump_vrml_field(sdump, node, field); - } + } sdump->indent --; if (!sdump->XMLDump && !in_list) { @@ -1703,7 +1793,7 @@ static GF_Err DumpMultipleReplace(GF_SceneDumper *sdump, GF_Command *com) fprintf(sdump->trace, "node); fprintf(sdump->trace, "\">\n"); - + sdump->indent++; i=0; while ((inf = (GF_CommandField *) gf_list_enum(com->command_fields, &i))) { @@ -1722,7 +1812,7 @@ static GF_Err DumpMultipleReplace(GF_SceneDumper *sdump, GF_Command *com) } } sdump->indent--; - + DUMP_IND(sdump); fprintf(sdump->trace, "\n"); } else { @@ -1786,7 +1876,9 @@ static GF_Err DumpNodeInsert(GF_SceneDumper *sdump, GF_Command *com) scene_dump_vrml_id(sdump, com->node); fprintf(sdump->trace, "\" position=\"%s\">", posname); } else { - if (inf->pos==-1) { fprintf(sdump->trace, "APPEND TO "); } + if (inf->pos==-1) { + fprintf(sdump->trace, "APPEND TO "); + } else fprintf(sdump->trace, "INSERT AT "); scene_dump_vrml_id(sdump, com->node); fprintf(sdump->trace, ".children"); @@ -1860,14 +1952,16 @@ static GF_Err DumpIndexInsert(GF_SceneDumper *sdump, GF_Command *com) scene_dump_vrml_id(sdump, com->node); fprintf(sdump->trace, "\" atField=\"%s\" position=\"%s\"", field.name, posname); } else { - if (inf->pos==-1) { fprintf(sdump->trace, "APPEND TO "); } + if (inf->pos==-1) { + fprintf(sdump->trace, "APPEND TO "); + } else fprintf(sdump->trace, "INSERT AT "); scene_dump_vrml_id(sdump, com->node); fprintf(sdump->trace, ".%s", field.name); if (inf->pos!=-1) fprintf(sdump->trace, "[%d]", inf->pos); fprintf(sdump->trace, " "); } - + memcpy(&sffield, &field, sizeof(GF_FieldInfo)); sffield.fieldType = gf_sg_vrml_get_sf_type(field.fieldType); @@ -2012,27 +2106,27 @@ static GF_Err DumpFieldReplace(GF_SceneDumper *sdump, GF_Command *com) else fprintf(sdump->trace, "\n"); break; case GF_SG_VRML_MFNODE: - { - GF_ChildNodeItem *tmp; - if (sdump->XMLDump) { - fprintf(sdump->trace, ">"); - } else { - fprintf(sdump->trace, " [\n"); - } - sdump->indent++; - tmp = inf->node_list; - while (tmp) { - gf_dump_vrml_node(sdump, tmp->node, 1, NULL); - tmp = tmp->next; - } - sdump->indent--; - if (sdump->XMLDump) { - fprintf(sdump->trace, ""); - } else { - EndList(sdump, NULL); - } + { + GF_ChildNodeItem *tmp; + if (sdump->XMLDump) { + fprintf(sdump->trace, ">"); + } else { + fprintf(sdump->trace, " [\n"); } - break; + sdump->indent++; + tmp = inf->node_list; + while (tmp) { + gf_dump_vrml_node(sdump, tmp->node, 1, NULL); + tmp = tmp->next; + } + sdump->indent--; + if (sdump->XMLDump) { + fprintf(sdump->trace, ""); + } else { + EndList(sdump, NULL); + } + } + break; case GF_SG_VRML_SFCOMMANDBUFFER: if (sdump->XMLDump) { SFCommandBuffer *cb = (SFCommandBuffer*)inf->field_ptr; @@ -2156,7 +2250,7 @@ static GF_Err DumpXReplace(GF_SceneDumper *sdump, GF_Command *com) fprintf(sdump->trace, "node); fprintf(sdump->trace, "\" atField=\"%s\"", field.name); - + if (toNode) { fprintf(sdump->trace, " atIndexNode=\""); scene_dump_vrml_id(sdump, toNode); @@ -2183,12 +2277,12 @@ static GF_Err DumpXReplace(GF_SceneDumper *sdump, GF_Command *com) field.fieldType = cfield.fieldType; } - + if (com->fromNodeID) { target = gf_sg_find_node(com->in_scene, com->fromNodeID); if (!target) return GF_NON_COMPLIANT_BITSTREAM; e = gf_node_get_field(target, com->fromFieldIndex, &idxField); - + fprintf(sdump->trace, " fromNode=\""); scene_dump_vrml_id(sdump, target); fprintf(sdump->trace, "\" fromField=\"%s\">\n", idxField.name); @@ -2279,9 +2373,9 @@ static GF_Err gf_dump_vrml_route(GF_SceneDumper *sdump, GF_Route *r, u32 dump_ty r->is_setup = 1; } if (!r->FromNode || !r->ToNode) return GF_BAD_PARAM; - + if (sdump->XMLDump || !dump_type) DUMP_IND(sdump); - + node_name = gf_node_get_name_and_id(r->FromNode, &id); if (node_name) { const char *to_name; @@ -2342,7 +2436,7 @@ static GF_Err DumpProtos(GF_SceneDumper *sdump, GF_List *protoList) i=0; while ((proto = (GF_Proto*)gf_list_enum(protoList, &i))) { sdump->current_proto = proto; - + DUMP_IND(sdump); if (!sdump->XMLDump) { fprintf(sdump->trace, proto->ExternProto.count ? "EXTERNPROTO " : "PROTO "); @@ -2370,11 +2464,11 @@ static GF_Err DumpProtos(GF_SceneDumper *sdump, GF_List *protoList) field.name = pf->FieldName; field.NDTtype = NDT_SFWorldNode; field.on_event_in = NULL; - + gf_dump_vrml_dyn_field(sdump, NULL, field, pf->QP_Type ? 1 : 0); if (!pf->QP_Type) continue; - + /*dump interface coding - BT/TXT extensions, not supported by any other tool*/ sdump->indent++; DUMP_IND(sdump); @@ -2413,7 +2507,7 @@ static GF_Err DumpProtos(GF_SceneDumper *sdump, GF_List *protoList) } } - + sdump->indent--; DUMP_IND(sdump); if (!sdump->XMLDump) { @@ -2435,7 +2529,7 @@ static GF_Err DumpProtos(GF_SceneDumper *sdump, GF_List *protoList) sdump->indent++; if (sdump->XMLDump && sdump->X3DDump) fprintf(sdump->trace, "\n"); - + e = DumpProtos(sdump, proto->sub_graph->protos); if (e) return e; @@ -2625,7 +2719,7 @@ static GF_Err DumpLSRAddReplaceInsert(GF_SceneDumper *sdump, GF_Command *com) } if (f->new_node && f->new_node->sgprivate->tag==TAG_DOMText) is_text = 1; /*if fieldIndex (eg attributeName) is set, this is children replacement*/ - if (f->fieldIndex>0) + if (f->fieldIndex>0) fprintf(sdump->trace, "attributeName=\"children\" "); fprintf(sdump->trace, ">"); @@ -2689,10 +2783,10 @@ static GF_Err DumpLSRSendEvent(GF_SceneDumper *sdump, GF_Command *com) char szID[1024]; char *lsrns = sd_get_lsr_namespace(com->in_scene); DUMP_IND(sdump); - fprintf(sdump->trace, "<%sSendEvent ref=\"%s\" event=\"%s\"", lsrns, - lsr_format_node_id(com->node, com->RouteID, szID), - gf_dom_event_get_name(com->send_event_name) - ); + fprintf(sdump->trace, "<%sSendEvent ref=\"%s\" event=\"%s\"", lsrns, + lsr_format_node_id(com->node, com->RouteID, szID), + gf_dom_event_get_name(com->send_event_name) + ); if (com->send_event_name <= GF_EVENT_MOUSEWHEEL) fprintf(sdump->trace, " pointvalue=\"%g %g\"", FIX2FLT(com->send_event_x), FIX2FLT(com->send_event_y) ); @@ -2776,22 +2870,42 @@ GF_Err gf_sm_dump_command_list(GF_SceneDumper *sdump, GF_List *comList, u32 inde switch (com->tag) { #ifndef GPAC_DISABLE_VRML /*insert commands*/ - case GF_SG_NODE_INSERT: e = DumpNodeInsert(sdump, com); break; - case GF_SG_INDEXED_INSERT: e = DumpIndexInsert(sdump, com); break; + case GF_SG_NODE_INSERT: + e = DumpNodeInsert(sdump, com); + break; + case GF_SG_INDEXED_INSERT: + e = DumpIndexInsert(sdump, com); + break; case GF_SG_ROUTE_INSERT: e = DumpRouteInsert(sdump, com, has_scene_replace); if (remain) remain--; break; /*delete commands*/ - case GF_SG_NODE_DELETE: e = DumpNodeDelete(sdump, com); break; - case GF_SG_INDEXED_DELETE: e = DumpIndexDelete(sdump, com); break; - case GF_SG_ROUTE_DELETE: e = DumpRouteDelete(sdump, com); break; + case GF_SG_NODE_DELETE: + e = DumpNodeDelete(sdump, com); + break; + case GF_SG_INDEXED_DELETE: + e = DumpIndexDelete(sdump, com); + break; + case GF_SG_ROUTE_DELETE: + e = DumpRouteDelete(sdump, com); + break; /*replace commands*/ - case GF_SG_NODE_REPLACE: e = DumpNodeReplace(sdump, com); break; - case GF_SG_FIELD_REPLACE: e = DumpFieldReplace(sdump, com); break; - case GF_SG_INDEXED_REPLACE: e = DumpIndexReplace(sdump, com); break; - case GF_SG_ROUTE_REPLACE: e = DumpRouteReplace(sdump, com); break; - case GF_SG_XREPLACE: e = DumpXReplace(sdump, com); break; + case GF_SG_NODE_REPLACE: + e = DumpNodeReplace(sdump, com); + break; + case GF_SG_FIELD_REPLACE: + e = DumpFieldReplace(sdump, com); + break; + case GF_SG_INDEXED_REPLACE: + e = DumpIndexReplace(sdump, com); + break; + case GF_SG_ROUTE_REPLACE: + e = DumpRouteReplace(sdump, com); + break; + case GF_SG_XREPLACE: + e = DumpXReplace(sdump, com); + break; case GF_SG_SCENE_REPLACE: /*we don't support replace scene in conditional*/ assert(!sdump->current_com_list); @@ -2802,7 +2916,9 @@ GF_Err gf_sm_dump_command_list(GF_SceneDumper *sdump, GF_List *comList, u32 inde remain = count - i - 1; break; /*extended commands*/ - case GF_SG_PROTO_INSERT: e = DumpProtoInsert(sdump, com); break; + case GF_SG_PROTO_INSERT: + e = DumpProtoInsert(sdump, com); + break; case GF_SG_PROTO_DELETE_ALL: DUMP_IND(sdump); if (sdump->XMLDump) { @@ -2832,29 +2948,55 @@ GF_Err gf_sm_dump_command_list(GF_SceneDumper *sdump, GF_List *comList, u32 inde } e = GF_OK; } + break; + case GF_SG_GLOBAL_QUANTIZER: + e = DumpGlobalQP(sdump, com); + break; + case GF_SG_MULTIPLE_REPLACE: + e = DumpMultipleReplace(sdump, com); + break; + case GF_SG_MULTIPLE_INDEXED_REPLACE: + e = DumpMultipleIndexedReplace(sdump, com); + break; + case GF_SG_NODE_DELETE_EX: + e = DumpNodeDelete(sdump, com); break; - case GF_SG_GLOBAL_QUANTIZER: e = DumpGlobalQP(sdump, com); break; - case GF_SG_MULTIPLE_REPLACE: e = DumpMultipleReplace(sdump, com); break; - case GF_SG_MULTIPLE_INDEXED_REPLACE: e = DumpMultipleIndexedReplace(sdump, com); break; - case GF_SG_NODE_DELETE_EX: e = DumpNodeDelete(sdump, com); break; #endif #ifndef GPAC_DISABLE_SVG /*laser commands*/ - case GF_SG_LSR_NEW_SCENE: e = DumpLSRNewScene(sdump, com); break; - case GF_SG_LSR_ADD: e = DumpLSRAddReplaceInsert(sdump, com); break; - case GF_SG_LSR_CLEAN: e = DumpLSRClean(sdump, com); break; - case GF_SG_LSR_REPLACE: e = DumpLSRAddReplaceInsert(sdump, com); break; - case GF_SG_LSR_DELETE: e = DumpLSRDelete(sdump, com); break; - case GF_SG_LSR_INSERT: e = DumpLSRAddReplaceInsert(sdump, com); break; - case GF_SG_LSR_RESTORE: e = DumpLSRRestore(sdump, com); break; - case GF_SG_LSR_SAVE: e = DumpLSRSave(sdump, com); break; - case GF_SG_LSR_SEND_EVENT: e = DumpLSRSendEvent(sdump, com); break; + case GF_SG_LSR_NEW_SCENE: + e = DumpLSRNewScene(sdump, com); + break; + case GF_SG_LSR_ADD: + e = DumpLSRAddReplaceInsert(sdump, com); + break; + case GF_SG_LSR_CLEAN: + e = DumpLSRClean(sdump, com); + break; + case GF_SG_LSR_REPLACE: + e = DumpLSRAddReplaceInsert(sdump, com); + break; + case GF_SG_LSR_DELETE: + e = DumpLSRDelete(sdump, com); + break; + case GF_SG_LSR_INSERT: + e = DumpLSRAddReplaceInsert(sdump, com); + break; + case GF_SG_LSR_RESTORE: + e = DumpLSRRestore(sdump, com); + break; + case GF_SG_LSR_SAVE: + e = DumpLSRSave(sdump, com); + break; + case GF_SG_LSR_SEND_EVENT: + e = DumpLSRSendEvent(sdump, com); + break; case GF_SG_LSR_ACTIVATE: case GF_SG_LSR_DEACTIVATE: - e = DumpLSRActivate(sdump, com); + e = DumpLSRActivate(sdump, com); break; #endif } @@ -2909,7 +3051,7 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo switch (tag) { case TAG_SVG_listener: if (0 && gf_node_get_attribute_by_tag(n, TAG_XMLEV_ATT_handler, 0, 0, &info)==GF_OK) { - if (((XMLRI*)info.far_ptr)->target && !gf_node_get_id(((XMLRI*)info.far_ptr)->target) ) + if (((XMLRI*)info.far_ptr)->target && !gf_node_get_id(((XMLRI*)info.far_ptr)->target) ) return; } break; @@ -2921,10 +3063,10 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo case TAG_DOMText: { GF_DOMText *txt = (GF_DOMText *)n; - if (txt->textContent) { + if (txt->textContent) { if ((txt->type==GF_DOM_TEXT_CDATA) || - (parent->sgprivate->tag == TAG_SVG_script) || - (parent->sgprivate->tag == TAG_SVG_handler)) { + (parent->sgprivate->tag == TAG_SVG_script) || + (parent->sgprivate->tag == TAG_SVG_handler)) { fprintf(sdump->trace, "trace, "%s", txt->textContent); fprintf(sdump->trace, "]]>"); @@ -2933,7 +3075,7 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo } } } - return; + return; } } @@ -2954,8 +3096,8 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo if (att->data_type==SVG_ID_datatype) { att = att->next; continue; - } - + } + info.fieldIndex = att->tag; info.fieldType = att->data_type; if (att->tag==TAG_DOM_ATT_any) { @@ -2995,7 +3137,7 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo attValue = gf_svg_dump_attribute((GF_Node*)svg, &info); if (/*strcmp(info.name, "xmlns") &&*/ (info.fieldType = (u32) strlen(attValue))) fprintf(sdump->trace, " %s=\"%s\"", info.name, attValue); - + if (attValue) gf_free(attValue); fflush(sdump->trace); @@ -3019,7 +3161,7 @@ void gf_dump_svg_element(GF_SceneDumper *sdump, GF_Node *n, GF_Node *parent, Boo gf_sm_dump_command_list(sdump, up->updates, sdump->indent, 0); } else if (up->data) { fprintf(sdump->trace, "\n"); - } + } } sdump->indent--; DUMP_IND(sdump); @@ -3086,11 +3228,11 @@ static void dump_od_to_saf(GF_SceneDumper *dumper, GF_AUContext *au, u32 indent) if (mux && mux->file_name) fprintf(dumper->trace, " source=\"%s\"", mux->file_name); fprintf(dumper->trace, "/>\n"); } - + } fprintf(dumper->trace, "\n"); -} +} static GF_Err SD_DumpDOMElement(GF_SceneDumper *sdump, GF_DOMFullNode *node) { @@ -3159,7 +3301,7 @@ GF_Err gf_sm_dump_graph(GF_SceneDumper *sdump, Bool skip_proto, Bool skip_routes tag = sdump->sg->RootNode->sgprivate->tag; - + if (tag<=GF_NODE_RANGE_LAST_X3D) { gf_dump_setup(sdump, NULL); @@ -3199,7 +3341,7 @@ GF_Err gf_sm_dump_graph(GF_SceneDumper *sdump, Bool skip_proto, Bool skip_routes EndElement(sdump, "Scene", 1); } #endif /*GPAC_DISABLE_VRML*/ - + gf_dump_finalize(sdump, NULL); return GF_OK; } @@ -3232,7 +3374,7 @@ static void ReorderAUContext(GF_List *sample_list, GF_AUContext *au, Bool lsr_du /* this happens when converting from bt to xmt - NOTE: Comment is wrong? this happens when just loading BT + NOTE: Comment is wrong? this happens when just loading BT */ if (!au->timing_sec) { au->timing_sec = (Double) (s64) au->timing; @@ -3248,16 +3390,16 @@ static void ReorderAUContext(GF_List *sample_list, GF_AUContext *au, Bool lsr_du autime = au->timing + au->owner->imp_exp_time; has_base = 0; - i=0; + i=0; while ((ptr = (GF_AUContext*)gf_list_enum(sample_list, &i))) { time = ptr->timing + ptr->owner->imp_exp_time; if ( - /*time ordered*/ - (time > autime) - /*set bifs first for first AU*/ - || (!has_base && (time == autime) && (ptr->owner->streamType < au->owner->streamType) ) - /*set OD first for laser*/ - || (lsr_dump && (au->owner->streamType==GF_STREAM_OD)) + /*time ordered*/ + (time > autime) + /*set bifs first for first AU*/ + || (!has_base && (time == autime) && (ptr->owner->streamType < au->owner->streamType) ) + /*set OD first for laser*/ + || (lsr_dump && (au->owner->streamType==GF_STREAM_OD)) ) { gf_list_insert(sample_list, au, i-1); return; @@ -3306,7 +3448,7 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode) default: continue; } - + j=0; while ((au = (GF_AUContext*)gf_list_enum(sc->AUs, &j))) { ReorderAUContext(sample_list, au, dumper->LSRDump); @@ -3347,13 +3489,13 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode) gf_list_rem(sample_list, 0); if (!dumper->XMLDump) { - + if (!first_bifs || (au->owner->streamType != GF_STREAM_SCENE) ) { if (au->flags & GF_SM_AU_RAP) fprintf(dumper->trace, "RAP "); fprintf(dumper->trace, "AT "LLD" ", LLD_CAST au->timing); if ( (au->owner->streamType==GF_STREAM_OD && num_od) || (au->owner->streamType==GF_STREAM_SCENE && num_scene)) { fprintf(dumper->trace, "IN %d ", au->owner->ESID); - } + } fprintf(dumper->trace, "{\n"); indent++; } @@ -3365,7 +3507,7 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode) } else { #ifndef GPAC_DISABLE_OD_DUMP e = gf_odf_dump_com_list(au->commands, dumper->trace, indent+1, 0); -#endif +#endif } break; case GF_STREAM_SCENE: @@ -3380,7 +3522,7 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode) indent--; fprintf(dumper->trace, "}\n\n"); } - } + } else { if (dumper->LSRDump) { if (time != au->timing_sec) { @@ -3416,14 +3558,14 @@ GF_Err gf_sm_dump(GF_SceneManager *ctx, char *rad_name, u32 dump_mode) break; case GF_STREAM_SCENE: if (gf_list_count(au->commands)) { - if (dumper->LSRDump) + if (dumper->LSRDump) gf_sm_dump_saf_hdr(dumper, "sceneUnit", au->timing, au->flags & GF_SM_AU_RAP); e = gf_sm_dump_command_list(dumper, au->commands, indent+1, first_bifs); first_bifs = 0; no_root_found = 0; - - if (dumper->LSRDump) + + if (dumper->LSRDump) fprintf(dumper->trace, "\n"); } break; diff --git a/src/scene_manager/scene_engine.c b/src/scene_manager/scene_engine.c index ab78711..563e6ff 100644 --- a/src/scene_manager/scene_engine.c +++ b/src/scene_manager/scene_engine.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -52,7 +52,7 @@ struct __tag_scene_engine GF_SceneManager *ctx; GF_SceneLoader loader; void *calling_object; - Bool owns_context; + Bool owns_context; #ifndef GPAC_DISABLE_BIFS_ENC GF_BifsEncoder *bifsenc; #endif @@ -62,11 +62,11 @@ struct __tag_scene_engine u32 start_time; - char *dump_path; + char *dump_path; - Bool embed_resources; - Bool dump_rap; - Bool first_dims_sent; + Bool embed_resources; + Bool dump_rap; + Bool first_dims_sent; }; #ifndef GPAC_DISABLE_BIFS_ENC @@ -133,12 +133,12 @@ static GF_Err gf_sm_setup_bifsenc(GF_SceneEngine *seng, GF_StreamContext *sc, GF esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); esd->decoderConfig->decoderSpecificInfo->data = data; esd->decoderConfig->decoderSpecificInfo->dataLength = data_len; - + sc->dec_cfg = gf_malloc(sizeof(char)*data_len); memcpy(sc->dec_cfg, data, data_len); sc->dec_cfg_len = data_len; - esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(seng->bifsenc, esd->ESID); + esd->decoderConfig->objectTypeIndication = gf_bifs_encoder_get_version(seng->bifsenc, esd->ESID); return GF_OK; } @@ -176,7 +176,7 @@ static GF_Err gf_sm_setup_lsrenc(GF_SceneEngine *seng, GF_StreamContext *sc, GF_ esd->decoderConfig->decoderSpecificInfo = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); esd->decoderConfig->decoderSpecificInfo->data = data; esd->decoderConfig->decoderSpecificInfo->dataLength = data_len; - + sc->dec_cfg = (char*)gf_malloc(sizeof(char)*data_len); memcpy(sc->dec_cfg, data, data_len); sc->dec_cfg_len = data_len; @@ -214,7 +214,7 @@ static GF_Err gf_sm_live_setup(GF_SceneEngine *seng) esd->decoderConfig->streamType = GF_STREAM_SCENE; esd->decoderConfig->objectTypeIndication = sc->objectType; gf_list_add(iod->ESDescriptors, esd); - + if (!sc->timeScale) sc->timeScale = 1000; esd->slConfig->timestampResolution = sc->timeScale; } @@ -236,7 +236,7 @@ static GF_Err gf_sm_live_setup(GF_SceneEngine *seng) if (!sc->timeScale) sc->timeScale = esd->slConfig->timestampResolution; - if (sc->streamType == GF_STREAM_SCENE) { + if (sc->streamType == GF_STREAM_SCENE) { switch (sc->objectType) { #ifndef GPAC_DISABLE_BIFS_ENC case GPAC_OTI_SCENE_BIFS: @@ -251,12 +251,12 @@ static GF_Err gf_sm_live_setup(GF_SceneEngine *seng) break; #endif case GPAC_OTI_SCENE_DIMS: - /* Nothing to be done here */ + /* Nothing to be done here */ break; default: e = GF_NOT_SUPPORTED; break; - } + } if (e) return e; } } @@ -317,30 +317,30 @@ static GF_Err gf_seng_encode_dims_au(GF_SceneEngine *seng, u16 ESID, GF_List *co compress_dims = 1; #ifdef DUMP_DIMS_LOG_WITH_TIME -start: +start: #endif - + if (commands && gf_list_count(commands)) { - sprintf(rad_name, "%s%c%s%s", cache_dir, GF_PATH_SEPARATOR, dump_name, "_update"); + sprintf(rad_name, "%s%c%s%s", cache_dir, GF_PATH_SEPARATOR, dump_name, "_update"); } else { #ifndef DUMP_DIMS_LOG_WITH_TIME sprintf(rad_name, "%s%c%s%s", cache_dir, GF_PATH_SEPARATOR, "rap_", dump_name); #else - char date_str[100], time_str[100]; - time_t now; - struct tm *tm_tot; - now = time(NULL); - tm_tot = localtime(&now); - strftime(date_str, 100, "%Yy%mm%dd", tm_tot); - strftime(time_str, 100, "%Hh%Mm%Ss", tm_tot); - sprintf(rad_name, "%s%c%s-%s-%s%s", cache_dir, GF_PATH_SEPARATOR, date_str, time_str, "rap_", dump_name); + char date_str[100], time_str[100]; + time_t now; + struct tm *tm_tot; + now = time(NULL); + tm_tot = localtime(&now); + strftime(date_str, 100, "%Yy%mm%dd", tm_tot); + strftime(time_str, 100, "%Hh%Mm%Ss", tm_tot); + sprintf(rad_name, "%s%c%s-%s-%s%s", cache_dir, GF_PATH_SEPARATOR, date_str, time_str, "rap_", dump_name); #endif } #ifndef GPAC_DISABLE_SCENE_DUMP dumper = gf_sm_dumper_new(seng->ctx->scene_graph, rad_name, ' ', GF_SM_DUMP_SVG); if (!dumper) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot create SVG dumper for %s.svg\n", rad_name)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot create SVG dumper for %s.svg\n", rad_name)); e = GF_IO_ERR; goto exit; } @@ -353,46 +353,46 @@ start: } gf_sm_dumper_del(dumper); - if(seng->dump_rap){ - GF_SceneDumper *dumper = NULL; - - sprintf(rad_name, "%s%c%s%s", cache_dir, GF_PATH_SEPARATOR, "rap_", dump_name); - - dumper = gf_sm_dumper_new(seng->ctx->scene_graph, rad_name, ' ', GF_SM_DUMP_SVG); - if (!dumper) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot create SVG dumper for %s.svg\n", rad_name)); - e = GF_IO_ERR; - goto exit; - } - e = gf_sm_dump_graph(dumper, 0, 0); - gf_sm_dumper_del(dumper); - } + if(seng->dump_rap) { + GF_SceneDumper *dumper = NULL; + + sprintf(rad_name, "%s%c%s%s", cache_dir, GF_PATH_SEPARATOR, "rap_", dump_name); + + dumper = gf_sm_dumper_new(seng->ctx->scene_graph, rad_name, ' ', GF_SM_DUMP_SVG); + if (!dumper) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot create SVG dumper for %s.svg\n", rad_name)); + e = GF_IO_ERR; + goto exit; + } + e = gf_sm_dump_graph(dumper, 0, 0); + gf_sm_dumper_del(dumper); + } if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot dump DIMS Commands\n")); + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot dump DIMS Commands\n")); goto exit; } #endif #ifdef DUMP_DIMS_LOG_WITH_TIME - if (do_dump_with_time) { - do_dump_with_time = 0; - goto start; - } + if (do_dump_with_time) { + do_dump_with_time = 0; + goto start; + } #endif - + sprintf(file_name, "%s.svg", rad_name); file = gf_f64_open(file_name, "rb"); if (!file) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot open SVG dump file %s\n", file_name)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] Cannot open SVG dump file %s\n", file_name)); e = GF_IO_ERR; goto exit; } gf_f64_seek(file, 0, SEEK_END); fsize = gf_f64_tell(file); - + if (fsize == 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] SVG dump %s is empty\n", file_name)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[SceneEngine] SVG dump %s is empty\n", file_name)); goto exit; } @@ -401,11 +401,11 @@ start: gf_f64_seek(file, 0, SEEK_SET); fsize = fread(buffer, sizeof(char), (size_t)fsize, file); fclose(file); - file = NULL; + file = NULL; /* Then, set DIMS unit header - TODO: notify redundant units*/ dims_header = 0; - if (commands && gf_list_count(commands)) { + if (commands && gf_list_count(commands)) { dims_header = GF_DIMS_UNIT_P; /* streamer->all_non_rap_critical ? 0 : GF_DIMS_UNIT_P;*/ } else { /*redundant RAP with complete scene*/ @@ -415,12 +415,12 @@ start: /* Then, if compression is asked, we do it */ buffer_len = (u32)fsize; assert(fsize < 1<<31); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[SceneEngine] Sending DIMS data - sizes: raw (%d)", buffer_len)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[SceneEngine] Sending DIMS data - sizes: raw (%d)", buffer_len)); if (compress_dims) { #ifndef GPAC_DISABLE_ZLIB dims_header |= GF_DIMS_UNIT_C; e = gf_gz_compress_payload(&buffer, buffer_len, &buffer_len); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("/ compressed (%d)", buffer_len)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("/ compressed (%d)", buffer_len)); if (e) goto exit; #else GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Error: your version of GPAC was compile with no libz support. Abort.")); @@ -428,18 +428,18 @@ start: goto exit; #endif } - GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("\n")); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("\n")); /* Then, prepare the DIMS data using a bitstream instead of direct manipulation for endianness - The new bitstream size should be: - the size of the (compressed) data + The new bitstream size should be: + the size of the (compressed) data + 1 bytes for the header + 2 bytes for the size + 4 bytes if the size is greater than 65535 */ - bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); + bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); if (buffer_len > 65535) { - GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[SceneEngine] Warning: DIMS Unit size too big !!!\n")); + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[SceneEngine] Warning: DIMS Unit size too big !!!\n")); gf_bs_write_u16(bs, 0); /* internal GPAC hack to indicate that the size is larger than 65535 */ gf_bs_write_u32(bs, buffer_len+1); } else { @@ -535,7 +535,7 @@ static GF_Err gf_sm_live_encode_scene_au(GF_SceneEngine *seng, gf_seng_callback e = GF_OK; nb_streams = gf_list_count(seng->ctx->streams); - for (i=0; ictx->streams, i); if (sc->streamType != GF_STREAM_SCENE) continue; @@ -564,7 +564,7 @@ static GF_Err gf_sm_live_encode_scene_au(GF_SceneEngine *seng, gf_seng_callback break; #endif case GPAC_OTI_SCENE_DIMS: - e = gf_seng_encode_dims_au(seng, sc->ESID, au->commands, &data, &size); + e = gf_seng_encode_dims_au(seng, sc->ESID, au->commands, &data, &size); break; default: @@ -589,8 +589,8 @@ GF_Err gf_seng_aggregate_context(GF_SceneEngine *seng, u16 ESID) GF_EXPORT GF_Err gf_seng_dump_rap_on(GF_SceneEngine *seng, Bool dump_rap) { - seng->dump_rap = dump_rap; - return 0; + seng->dump_rap = dump_rap; + return 0; } GF_EXPORT @@ -635,16 +635,16 @@ GF_Err gf_seng_save_context(GF_SceneEngine *seng, char *ctxFileName) #endif } -static GF_AUContext *gf_seng_create_new_au(GF_StreamContext *sc, u32 time) +static GF_AUContext *gf_seng_create_new_au(GF_StreamContext *sc, u32 time) { - GF_AUContext *new_au, *last_au; - last_au = gf_list_last(sc->AUs); - if (last_au && last_au->timing == time) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCENE, ("[SceneEngine] Forcing new AU\n")); - time++; - } - new_au = gf_sm_stream_au_new(sc, time, 0, 0); - return new_au; + GF_AUContext *new_au, *last_au; + last_au = gf_list_last(sc->AUs); + if (last_au && last_au->timing == time) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCENE, ("[SceneEngine] Forcing new AU\n")); + time++; + } + new_au = gf_sm_stream_au_new(sc, time, 0, 0); + return new_au; } GF_EXPORT @@ -653,7 +653,7 @@ GF_Err gf_seng_encode_from_string(GF_SceneEngine *seng, u16 ESID, Bool disable_a GF_StreamContext *sc; u32 i; GF_Err e; - + i = 0; while ((sc = (GF_StreamContext*)gf_list_enum(seng->ctx->streams, &i))) { sc->current_au_count = gf_list_count(sc->AUs); @@ -661,7 +661,7 @@ GF_Err gf_seng_encode_from_string(GF_SceneEngine *seng, u16 ESID, Bool disable_a } seng->loader.flags |= GF_SM_LOAD_CONTEXT_READY; seng->loader.force_es_id = ESID; - + /* We need to create an empty AU for the parser to correctly parse a LASeR Command without SceneUnit */ sc = gf_list_get(seng->ctx->streams, 0); if (sc->objectType == GPAC_OTI_SCENE_DIMS) { @@ -675,7 +675,7 @@ GF_Err gf_seng_encode_from_string(GF_SceneEngine *seng, u16 ESID, Bool disable_a while ((sc = (GF_StreamContext*)gf_list_enum(seng->ctx->streams, &i))) { sc->disable_aggregation = 0; } - e = gf_sm_live_encode_scene_au(seng, callback, 0); + e = gf_sm_live_encode_scene_au(seng, callback, 0); exit: return e; } @@ -687,71 +687,71 @@ GF_Err gf_seng_encode_from_commands(GF_SceneEngine *seng, u16 ESID, Bool disable GF_Err e; u32 size; char *data; - GF_StreamContext *sc; + GF_StreamContext *sc; u32 i, nb_streams; - GF_AUContext *new_au; + GF_AUContext *new_au; if (!callback) return GF_BAD_PARAM; - if (!commands || !gf_list_count(commands)) return GF_BAD_PARAM; + if (!commands || !gf_list_count(commands)) return GF_BAD_PARAM; e = GF_OK; - - /* if the ESID is not provided we try to use the first scene stream */ - sc = NULL; - nb_streams = gf_list_count(seng->ctx->streams); - for (i=0; ictx->streams, i); - if (tmp_sc->streamType != GF_STREAM_SCENE) continue; - sc = tmp_sc; - if (!ESID) break; - else if (sc->ESID == ESID) break; - } - if (!sc) return GF_BAD_PARAM; - /* We need to create an empty AU for the parser to correctly parse a LASeR Command without SceneUnit */ + + /* if the ESID is not provided we try to use the first scene stream */ + sc = NULL; + nb_streams = gf_list_count(seng->ctx->streams); + for (i=0; ictx->streams, i); + if (tmp_sc->streamType != GF_STREAM_SCENE) continue; + sc = tmp_sc; + if (!ESID) break; + else if (sc->ESID == ESID) break; + } + if (!sc) return GF_BAD_PARAM; + /* We need to create an empty AU for the parser to correctly parse a LASeR Command without SceneUnit */ new_au = gf_seng_create_new_au(sc, time); if (disable_aggregation) new_au->flags = GF_SM_AU_NOT_AGGREGATED; - + /* Removing the commands from the input list to avoid destruction - and setting the RAP flag */ - while (gf_list_count(commands)) { - GF_Command *com = gf_list_get(commands, 0); - gf_list_rem(commands, 0); - switch (com->tag) { - case GF_SG_SCENE_REPLACE: - case GF_SG_LSR_NEW_SCENE: - new_au->flags |= GF_SM_AU_RAP; - break; - } - gf_list_add(new_au->commands, com); - } - - data = NULL; + and setting the RAP flag */ + while (gf_list_count(commands)) { + GF_Command *com = gf_list_get(commands, 0); + gf_list_rem(commands, 0); + switch (com->tag) { + case GF_SG_SCENE_REPLACE: + case GF_SG_LSR_NEW_SCENE: + new_au->flags |= GF_SM_AU_RAP; + break; + } + gf_list_add(new_au->commands, com); + } + + data = NULL; size = 0; - switch(sc->objectType) { + switch(sc->objectType) { #ifndef GPAC_DISABLE_BIFS_ENC - case GPAC_OTI_SCENE_BIFS: - case GPAC_OTI_SCENE_BIFS_V2: - e = gf_bifs_encode_au(seng->bifsenc, ESID, new_au->commands, &data, &size); - break; + case GPAC_OTI_SCENE_BIFS: + case GPAC_OTI_SCENE_BIFS_V2: + e = gf_bifs_encode_au(seng->bifsenc, ESID, new_au->commands, &data, &size); + break; #endif #ifndef GPAC_DISABLE_LASER - case GPAC_OTI_SCENE_LASER: - e = gf_laser_encode_au(seng->lsrenc, ESID, new_au->commands, 0, &data, &size); - break; + case GPAC_OTI_SCENE_LASER: + e = gf_laser_encode_au(seng->lsrenc, ESID, new_au->commands, 0, &data, &size); + break; #endif - case GPAC_OTI_SCENE_DIMS: - e = gf_seng_encode_dims_au(seng, ESID, new_au->commands, &data, &size); - break; - default: - GF_LOG(GF_LOG_ERROR, GF_LOG_SCENE, ("Cannot encode commands for Scene OTI %x\n", sc->objectType)); - break; - } - callback(seng->calling_object, ESID, data, size, 0); + case GPAC_OTI_SCENE_DIMS: + e = gf_seng_encode_dims_au(seng, ESID, new_au->commands, &data, &size); + break; + default: + GF_LOG(GF_LOG_ERROR, GF_LOG_SCENE, ("Cannot encode commands for Scene OTI %x\n", sc->objectType)); + break; + } + callback(seng->calling_object, ESID, data, size, 0); gf_free(data); return e; } @@ -799,7 +799,7 @@ GF_Err gf_seng_encode_from_file(GF_SceneEngine *seng, u16 ESID, Bool disable_agg sc->disable_aggregation = 0; } - e = gf_sm_live_encode_scene_au(seng, callback, 0); + e = gf_sm_live_encode_scene_au(seng, callback, 0); if (e) goto exit; exit: return e; @@ -813,7 +813,7 @@ GF_Err gf_seng_encode_context(GF_SceneEngine *seng, gf_seng_callback callback) return GF_BAD_PARAM; } return gf_sm_live_encode_scene_au(seng, callback, 1); -} +} GF_EXPORT void gf_seng_terminate(GF_SceneEngine *seng) @@ -836,7 +836,7 @@ void gf_seng_terminate(GF_SceneEngine *seng) } GF_EXPORT -GF_Err gf_seng_get_stream_config(GF_SceneEngine *seng, u32 idx, u16 *ESID, char * * const config, u32 *config_len, u32 *streamType, u32 *objectType, u32 *timeScale) +GF_Err gf_seng_get_stream_config(GF_SceneEngine *seng, u32 idx, u16 *ESID, char ** const config, u32 *config_len, u32 *streamType, u32 *objectType, u32 *timeScale) { GF_StreamContext *sc = gf_list_get(seng->ctx->streams, idx); if (!sc || !ESID || !config || !config_len) return GF_BAD_PARAM; @@ -923,12 +923,12 @@ GF_SceneEngine *gf_seng_init(void *calling_object, char * inputContext, u32 load seng->sg = gf_sg_new(); gf_sg_set_node_callback(seng->sg, gf_seng_on_node_modified); gf_sg_set_private(seng->sg, seng); - seng->dump_path = dump_path; + seng->dump_path = dump_path; seng->ctx = gf_sm_new(seng->sg); seng->owns_context = 1; memset(&(seng->loader), 0, sizeof(GF_SceneLoader)); seng->loader.ctx = seng->ctx; - seng->loader.type = load_type; + seng->loader.type = load_type; /*since we're encoding in BIFS we must get MPEG-4 nodes only*/ seng->loader.flags = GF_SM_LOAD_MPEG4_STRICT; if (embed_resources) seng->loader.flags |= GF_SM_LOAD_EMBEDS_RES; @@ -965,7 +965,7 @@ GF_SceneEngine *gf_seng_init_from_context(void *calling_object, GF_SceneManager if (!seng) return NULL; seng->calling_object = calling_object; - seng->dump_path = dump_path; + seng->dump_path = dump_path; /*Step 1: create context and load input*/ seng->sg = ctx->scene_graph; seng->ctx = ctx; @@ -995,27 +995,27 @@ GF_SceneEngine *gf_seng_init_from_string(void *calling_object, char * inputConte if (!seng) return NULL; seng->calling_object = calling_object; - seng->dump_path = dump_path; - /*Step 1: create context and load input*/ + seng->dump_path = dump_path; + /*Step 1: create context and load input*/ seng->sg = gf_sg_new(); seng->ctx = gf_sm_new(seng->sg); seng->owns_context = 1; memset(& seng->loader, 0, sizeof(GF_SceneLoader)); seng->loader.ctx = seng->ctx; - seng->loader.type = load_type; + seng->loader.type = load_type; /*since we're encoding in BIFS we must get MPEG-4 nodes only*/ seng->loader.flags = GF_SM_LOAD_MPEG4_STRICT; - /* assign a loader type only if it was not requested (e.g. DIMS should not be overriden by SVG) */ - if (!seng->loader.type) { - if (inputContext[0] == '<') { - if (strstr(inputContext, "loader.type = GF_SM_LOAD_SVG; - else if (strstr(inputContext, "loader.type = GF_SM_LOAD_XSR; - else if (strstr(inputContext, "XMT-A") || strstr(inputContext, "X3D")) seng->loader.type = GF_SM_LOAD_XMTA; - } else { - seng->loader.type = GF_SM_LOAD_BT; - } - } + /* assign a loader type only if it was not requested (e.g. DIMS should not be overriden by SVG) */ + if (!seng->loader.type) { + if (inputContext[0] == '<') { + if (strstr(inputContext, "loader.type = GF_SM_LOAD_SVG; + else if (strstr(inputContext, "loader.type = GF_SM_LOAD_XSR; + else if (strstr(inputContext, "XMT-A") || strstr(inputContext, "X3D")) seng->loader.type = GF_SM_LOAD_XMTA; + } else { + seng->loader.type = GF_SM_LOAD_BT; + } + } e = gf_sm_load_string(&seng->loader, inputContext, 0); if (e) { @@ -1050,7 +1050,7 @@ GF_EXPORT GF_Err gf_seng_get_stream_carousel_info(GF_SceneEngine *seng, u16 ESID, u32 *carousel_period, u16 *aggregate_on_es_id) { u32 i=0; - GF_StreamContext *sc; + GF_StreamContext *sc; if (carousel_period) *carousel_period = (u32) -1; if (aggregate_on_es_id) *aggregate_on_es_id = 0; @@ -1062,14 +1062,14 @@ GF_Err gf_seng_get_stream_carousel_info(GF_SceneEngine *seng, u16 ESID, u32 *car return GF_OK; } } - return GF_OK; + return GF_OK; } GF_EXPORT char *gf_seng_get_base64_iod(GF_SceneEngine *seng) { u32 size, size64; - char *buffer, *buf64; + char *buffer, *buf64; u32 i=0; GF_StreamContext*sc = NULL; @@ -1081,12 +1081,12 @@ char *gf_seng_get_base64_iod(GF_SceneEngine *seng) } if (!sc) return NULL; - size = 0; - gf_odf_desc_write((GF_Descriptor *) seng->ctx->root_od, &buffer, &size); - buf64 = gf_malloc(size*2); - size64 = gf_base64_encode( buffer, size, buf64, size*2); - buf64[size64] = 0; - gf_free(buffer); + size = 0; + gf_odf_desc_write((GF_Descriptor *) seng->ctx->root_od, &buffer, &size); + buf64 = gf_malloc(size*2); + size64 = gf_base64_encode( buffer, size, buf64, size*2); + buf64[size64] = 0; + gf_free(buffer); return buf64; } diff --git a/src/scene_manager/scene_manager.c b/src/scene_manager/scene_manager.c index 840f099..55549c4 100644 --- a/src/scene_manager/scene_manager.c +++ b/src/scene_manager/scene_manager.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,7 +36,7 @@ GF_EXPORT GF_SceneManager *gf_sm_new(GF_SceneGraph *graph) { GF_SceneManager *tmp; - + if (!graph) return NULL; GF_SAFEALLOC(tmp, GF_SceneManager); tmp->streams = gf_list_new(); @@ -57,12 +57,12 @@ GF_StreamContext *gf_sm_stream_new(GF_SceneManager *ctx, u16 ES_ID, u8 streamTyp /*if no ESID/OTI specified this is a base layer (default stream created by parsers) if ESID/OTI specified this is a stream already setup */ - if ( tmp->ESID==ES_ID ){ + if ( tmp->ESID==ES_ID ) { //tmp->objectType = objectType; return tmp; } } - + GF_SAFEALLOC(tmp, GF_StreamContext); tmp->AUs = gf_list_new(); tmp->ESID = ES_ID; @@ -174,29 +174,29 @@ GF_AUContext *gf_sm_stream_au_new(GF_StreamContext *stream, u64 timing, Double t { u32 i; GF_AUContext *tmp; - u64 tmp_timing; - - tmp_timing = timing ? timing : (u64) (time_sec*1000); - if (stream->imp_exp_time >= tmp_timing) { - /*look for existing AU*/ - i=0; - while ((tmp = (GF_AUContext *)gf_list_enum(stream->AUs, &i))) { - if (timing && (tmp->timing==timing)) return tmp; - else if (time_sec && (tmp->timing_sec == time_sec)) return tmp; - else if (!time_sec && !timing && !tmp->timing && !tmp->timing_sec) return tmp; - /*insert AU*/ - else if ((time_sec && time_sectiming_sec) || (timing && timingtiming)) { - GF_SAFEALLOC(tmp, GF_AUContext); - tmp->commands = gf_list_new(); - if (isRap) tmp->flags = GF_SM_AU_RAP; - tmp->timing = timing; - tmp->timing_sec = time_sec; - tmp->owner = stream; - gf_list_insert(stream->AUs, tmp, i-1); - return tmp; - } - } - } + u64 tmp_timing; + + tmp_timing = timing ? timing : (u64) (time_sec*1000); + if (stream->imp_exp_time >= tmp_timing) { + /*look for existing AU*/ + i=0; + while ((tmp = (GF_AUContext *)gf_list_enum(stream->AUs, &i))) { + if (timing && (tmp->timing==timing)) return tmp; + else if (time_sec && (tmp->timing_sec == time_sec)) return tmp; + else if (!time_sec && !timing && !tmp->timing && !tmp->timing_sec) return tmp; + /*insert AU*/ + else if ((time_sec && time_sectiming_sec) || (timing && timingtiming)) { + GF_SAFEALLOC(tmp, GF_AUContext); + tmp->commands = gf_list_new(); + if (isRap) tmp->flags = GF_SM_AU_RAP; + tmp->timing = timing; + tmp->timing_sec = time_sec; + tmp->owner = stream; + gf_list_insert(stream->AUs, tmp, i-1); + return tmp; + } + } + } GF_SAFEALLOC(tmp, GF_AUContext); tmp->commands = gf_list_new(); if (isRap) tmp->flags = GF_SM_AU_RAP; @@ -205,12 +205,13 @@ GF_AUContext *gf_sm_stream_au_new(GF_StreamContext *stream, u64 timing, Double t tmp->owner = stream; if (stream->disable_aggregation) tmp->flags |= GF_SM_AU_NOT_AGGREGATED; gf_list_add(stream->AUs, tmp); - stream->imp_exp_time = tmp_timing; + stream->imp_exp_time = tmp_timing; return tmp; } static Bool node_in_commands_subtree(GF_Node *node, GF_List *commands) { +#ifndef GPAC_DISABLE_VRML u32 i, j, count, nb_fields; count = gf_list_count(commands); @@ -246,11 +247,13 @@ static Bool node_in_commands_subtree(GF_Node *node, GF_List *commands) } } } +#endif return 0; } static u32 store_or_aggregate(GF_StreamContext *sc, GF_Command *com, GF_List *commands, Bool *has_modif) { +#ifndef GPAC_DISABLE_VRML u32 i, count, j, nb_fields; GF_CommandField *field, *check_field; @@ -276,7 +279,9 @@ static u32 store_or_aggregate(GF_StreamContext *sc, GF_Command *com, GF_List *co /*we may aggregate an indexed insertion and a replace one*/ if (check_index) { if (check->tag == GF_SG_INDEXED_REPLACE) {} - else if (check->tag == GF_SG_INDEXED_INSERT) { original_is_index = 1; } + else if (check->tag == GF_SG_INDEXED_INSERT) { + original_is_index = 1; + } else { break; } @@ -343,6 +348,7 @@ static u32 store_or_aggregate(GF_StreamContext *sc, GF_Command *com, GF_List *co } /*the command modifies another stream than associated current carousel stream, we have to store it.*/ if (has_modif) *has_modif=1; +#endif return 1; } @@ -350,7 +356,7 @@ static GF_StreamContext *gf_sm_get_stream(GF_SceneManager *ctx, u16 ESID) { u32 i, count; count = gf_list_count(ctx->streams); - for (i=0;istreams, i); if (sc->ESID==ESID) return sc; } @@ -371,19 +377,19 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) e = GF_OK; #if DEBUG_RAP - com_count = 0; + com_count = 0; stream_count = gf_list_count(ctx->streams); - for (i=0; istreams, i); if (sc->streamType == GF_STREAM_SCENE) { - au_count = gf_list_count(sc->AUs); - for (j=0; jAUs); + for (j=0; jAUs, j); - com_count += gf_list_count(au->commands); - } - } - } - GF_LOG(GF_LOG_INFO, GF_LOG_SCENE, ("[SceneManager] Making RAP with %d commands\n", com_count)); + com_count += gf_list_count(au->commands); + } + } + } + GF_LOG(GF_LOG_INFO, GF_LOG_SCENE, ("[SceneManager] Making RAP with %d commands\n", com_count)); #endif stream_count = gf_list_count(ctx->streams); @@ -418,7 +424,7 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) Bool base_stream_found = 0; /*in DIMS we use an empty initial AU with no commands to signal the RAP*/ - if (sc->objectType == GPAC_OTI_SCENE_DIMS) base_stream_found = 1; + if (sc->objectType == GPAC_OTI_SCENE_DIMS) base_stream_found = 1; /*apply all commands - this will also apply the SceneReplace*/ while (gf_list_count(sc->AUs)) { @@ -452,7 +458,7 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) /*if stream doesn't carry a carousel or carries the base carousel (scene replace), always apply the command*/ if (base_stream_found || !sc->aggregate_on_esid) { store = 0; - } + } /*otherwise, check wether the command should be kept in this stream as is, or can be aggregated on this stream*/ else { switch (com->tag) { @@ -469,14 +475,14 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) case GF_SG_LSR_SAVE: case GF_SG_LSR_SEND_EVENT: case GF_SG_LSR_CLEAN: - /*todo check in which category to put these commands*/ + /*todo check in which category to put these commands*/ // case GF_SG_LSR_ACTIVATE: // case GF_SG_LSR_DEACTIVATE: store = 1; break; - /*other commands: + /*other commands: !!! we need to know if the target node of the command has been inserted in this stream !!! - + This is a tedious task, for now we will consider the following cases: - locate a similar command in the stored list: remove the similar one and aggregate on stream - by default all AUs are stored if the stream is in aggregate mode - we should fix that by checking insertion points: @@ -526,8 +532,8 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) case GPAC_OTI_SCENE_LASER: com = gf_sg_command_new(ctx->scene_graph, GF_SG_LSR_NEW_SCENE); break; - case GPAC_OTI_SCENE_DIMS: - /* We do not create a new command, empty AU is enough in DIMS*/ + case GPAC_OTI_SCENE_DIMS: + /* We do not create a new command, empty AU is enough in DIMS*/ default: com = NULL; break; @@ -539,7 +545,7 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) gf_list_del(com->new_proto_list); com->new_proto_list = ctx->scene_graph->protos; ctx->scene_graph->protos = NULL; - /*indicate the command is the aggregated scene graph, so that PROTOs and ROUTEs + /*indicate the command is the aggregated scene graph, so that PROTOs and ROUTEs are taken from the scenegraph when encoding*/ com->aggregated = 1; gf_list_add(au->commands, com); @@ -564,7 +570,7 @@ GF_Err gf_sm_aggregate(GF_SceneManager *ctx, u16 ESID) #ifndef GPAC_DISABLE_LOADER_BT GF_Err gf_sm_load_init_bt(GF_SceneLoader *load); -#endif +#endif #ifndef GPAC_DISABLE_LOADER_XMT GF_Err gf_sm_load_init_xmt(GF_SceneLoader *load); @@ -614,17 +620,17 @@ GF_Err gf_sm_load_init(GF_SceneLoader *load) GF_Err e = GF_NOT_SUPPORTED; char *ext, szExt[50]; /*we need at least a scene graph*/ - if (!load || (!load->ctx && !load->scene_graph) + if (!load || (!load->ctx && !load->scene_graph) #ifndef GPAC_DISABLE_ISOM - || (!load->fileName && !load->isom && !(load->flags & GF_SM_LOAD_FOR_PLAYBACK) ) + || (!load->fileName && !load->isom && !(load->flags & GF_SM_LOAD_FOR_PLAYBACK) ) #endif - ) return GF_BAD_PARAM; + ) return GF_BAD_PARAM; if (!load->type) { #ifndef GPAC_DISABLE_ISOM if (load->isom) { load->type = GF_SM_LOAD_MP4; - } else + } else #endif { ext = strrchr(load->fileName, '.'); @@ -669,7 +675,7 @@ GF_Err gf_sm_load_init(GF_SceneLoader *load) switch (load->type) { #ifndef GPAC_DISABLE_LOADER_BT - case GF_SM_LOAD_BT: + case GF_SM_LOAD_BT: case GF_SM_LOAD_VRML: case GF_SM_LOAD_X3DV: return gf_sm_load_init_bt(load); @@ -687,7 +693,7 @@ GF_Err gf_sm_load_init(GF_SceneLoader *load) case GF_SM_LOAD_DIMS: return gf_sm_load_init_svg(load); - case GF_SM_LOAD_XBL: + case GF_SM_LOAD_XBL: e = gf_sm_load_init_xbl(load); load->process = gf_sm_load_run_xbl;; @@ -696,7 +702,7 @@ GF_Err gf_sm_load_init(GF_SceneLoader *load) #endif #ifndef GPAC_DISABLE_SWF_IMPORT - case GF_SM_LOAD_SWF: + case GF_SM_LOAD_SWF: return gf_sm_load_init_swf(load); #endif @@ -706,7 +712,7 @@ GF_Err gf_sm_load_init(GF_SceneLoader *load) #endif #ifndef GPAC_DISABLE_QTVR - case GF_SM_LOAD_QT: + case GF_SM_LOAD_QT: return gf_sm_load_init_qt(load); #endif @@ -740,7 +746,7 @@ void gf_sm_update_bitwrapper_buffer(GF_Node *node, const char *fileName) { u32 data_size = 0; char *data = NULL; - char *buffer; + char *buffer; M_BitWrapper *bw = (M_BitWrapper *)node; if (!bw->buffer.buffer) return; @@ -769,11 +775,11 @@ void gf_sm_update_bitwrapper_buffer(GF_Node *node, const char *fileName) base_64 = strstr(bw->buffer.buffer, ";base64") ? 1 : 0; if (sep) buffer = sep+1; } - + if (base_64) { data_size = 2 * (u32) strlen(buffer); data = (char*)gf_malloc(sizeof(char)*data_size); - if (data) + if (data) data_size = gf_base64_decode(buffer, (u32) strlen(buffer), data, data_size); } else { u32 i, c; diff --git a/src/scene_manager/scene_stats.c b/src/scene_manager/scene_stats.c index a36ae00..268c601 100644 --- a/src/scene_manager/scene_stats.c +++ b/src/scene_manager/scene_stats.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -142,7 +142,7 @@ static void StatFixed(GF_SceneStatistics *stat, Fixed v, Bool scale) if (fracv) { frac_res = 1; - while ((fracv << frac_res) & 0x0000FFFF) + while ((fracv << frac_res) & 0x0000FFFF) frac_res++; } else { frac_res = 0; @@ -170,7 +170,7 @@ static void StatSVGPoint(GF_SceneStatistics *stat, SFVec2f *val) if (stat->min_2d.y > val->y) stat->min_2d.y = val->y; StatFixed(stat, val->x, 0); StatFixed(stat, val->y, 0); -} +} static void StatSFVec2f(GF_SceneStatistics *stat, SFVec2f *val) { @@ -179,7 +179,7 @@ static void StatSFVec2f(GF_SceneStatistics *stat, SFVec2f *val) if (stat->max_2d.y < val->y) stat->max_2d.y = val->y; if (stat->min_2d.x > val->x) stat->min_2d.x = val->x; if (stat->min_2d.y > val->y) stat->min_2d.y = val->y; -} +} static void StatSFVec3f(GF_SceneStatistics *stat, SFVec3f *val) { @@ -230,7 +230,7 @@ static void StatField(GF_SceneStatistics *stat, GF_FieldInfo *field) stat->count_2d ++; } } - break; + break; case GF_SG_VRML_MFVEC3F: { MFVec3f *mf3d = (MFVec3f *)field->far_ptr; @@ -239,7 +239,7 @@ static void StatField(GF_SceneStatistics *stat, GF_FieldInfo *field) stat->count_3d ++; } } - break; + break; } } @@ -264,71 +264,71 @@ static void StatSVGAttribute(GF_SceneStatistics *stat, GF_FieldInfo *field) switch (field->fieldType) { case SVG_PathData_datatype: - { + { #if USE_GF_PATH - SVG_PathData *d = (SVG_PathData *)field->far_ptr; - for (i=0; in_points; i++) { - StatSVGPoint(stat, &(d->points[i])); - stat->count_2d ++; - } + SVG_PathData *d = (SVG_PathData *)field->far_ptr; + for (i=0; in_points; i++) { + StatSVGPoint(stat, &(d->points[i])); + stat->count_2d ++; + } #else - SVG_PathData *d = (SVG_PathData *)field->far_ptr; - for (i=0; ipoints); i++) { - SVG_Point *p = (SVG_Point *)gf_list_get(d->points, i); - StatSVGPoint(stat, (SFVec2f *)p); - stat->count_2d ++; - } -#endif + SVG_PathData *d = (SVG_PathData *)field->far_ptr; + for (i=0; ipoints); i++) { + SVG_Point *p = (SVG_Point *)gf_list_get(d->points, i); + StatSVGPoint(stat, (SFVec2f *)p); + stat->count_2d ++; } - break; +#endif + } + break; case SVG_ViewBox_datatype: - { - SVG_ViewBox *vB = (SVG_ViewBox *)field->far_ptr; - StatFixed(stat, vB->x, 0); - StatFixed(stat, vB->y, 0); - StatFixed(stat, vB->width, 0); - StatFixed(stat, vB->height, 0); - } - break; + { + SVG_ViewBox *vB = (SVG_ViewBox *)field->far_ptr; + StatFixed(stat, vB->x, 0); + StatFixed(stat, vB->y, 0); + StatFixed(stat, vB->width, 0); + StatFixed(stat, vB->height, 0); + } + break; case SVG_Points_datatype: case SVG_Coordinates_datatype: - { - GF_List *points = *((GF_List **)field->far_ptr); - for (i=0; icount_2d ++; - } + { + GF_List *points = *((GF_List **)field->far_ptr); + for (i=0; icount_2d ++; } - break; + } + break; case SVG_Transform_datatype: - { - GF_Matrix2D *mx = &((SVG_Transform *)field->far_ptr)->mat; - if (!gf_mx2d_is_identity(*mx) && !(!mx->m[0] && !mx->m[1] && !mx->m[3] && !mx->m[4])) { - StatFixed(stat, mx->m[0], 1); - StatFixed(stat, mx->m[1], 1); - StatFixed(stat, mx->m[3], 1); - StatFixed(stat, mx->m[4], 1); - StatFixed(stat, mx->m[2], 0); - StatFixed(stat, mx->m[5], 0); - } + { + GF_Matrix2D *mx = &((SVG_Transform *)field->far_ptr)->mat; + if (!gf_mx2d_is_identity(*mx) && !(!mx->m[0] && !mx->m[1] && !mx->m[3] && !mx->m[4])) { + StatFixed(stat, mx->m[0], 1); + StatFixed(stat, mx->m[1], 1); + StatFixed(stat, mx->m[3], 1); + StatFixed(stat, mx->m[4], 1); + StatFixed(stat, mx->m[2], 0); + StatFixed(stat, mx->m[5], 0); } - break; + } + break; case SVG_Motion_datatype: - { - GF_Matrix2D *mx = (GF_Matrix2D *)field->far_ptr; - if (!gf_mx2d_is_identity(*mx) && !(!mx->m[0] && !mx->m[1] && !mx->m[3] && !mx->m[4])) { - StatFixed(stat, mx->m[0], 1); - StatFixed(stat, mx->m[1], 1); - StatFixed(stat, mx->m[3], 1); - StatFixed(stat, mx->m[4], 1); - StatFixed(stat, mx->m[2], 0); - StatFixed(stat, mx->m[5], 0); - } + { + GF_Matrix2D *mx = (GF_Matrix2D *)field->far_ptr; + if (!gf_mx2d_is_identity(*mx) && !(!mx->m[0] && !mx->m[1] && !mx->m[3] && !mx->m[4])) { + StatFixed(stat, mx->m[0], 1); + StatFixed(stat, mx->m[1], 1); + StatFixed(stat, mx->m[3], 1); + StatFixed(stat, mx->m[4], 1); + StatFixed(stat, mx->m[2], 0); + StatFixed(stat, mx->m[5], 0); } - break; + } + break; case SVG_Length_datatype: - case SVG_Coordinate_datatype: + case SVG_Coordinate_datatype: StatFixed(stat, ((SVG_Number *)field->far_ptr)->value, 0); break; } @@ -355,7 +355,7 @@ static void StatRemField(GF_SceneStatistics *stat, u32 fieldType, GF_FieldInfo * } -Bool StatIsUSE(GF_StatManager *st, GF_Node *n) +Bool StatIsUSE(GF_StatManager *st, GF_Node *n) { u32 i; GF_Node *ptr; @@ -396,7 +396,7 @@ static GF_Err StatNodeGraph(GF_StatManager *st, GF_Node *n) field.far_ptr = atts->data; field.fieldType = atts->data_type; field.fieldIndex = atts->tag; - field.name = NULL; + field.name = NULL; StatSVGAttribute(st->stats, &field); atts = atts->next; @@ -405,46 +405,46 @@ static GF_Err StatNodeGraph(GF_StatManager *st, GF_Node *n) StatNodeGraph(st, list->node); list = list->next; } - } else + } else #endif - if (n->sgprivate->tag == TAG_DOMText) { - } else if (n->sgprivate->tag == TAG_DOMFullNode) { - } + if (n->sgprivate->tag == TAG_DOMText) { + } else if (n->sgprivate->tag == TAG_DOMFullNode) { + } #ifndef GPAC_DISABLE_VRML - else if (n->sgprivate->tag<= GF_NODE_RANGE_LAST_X3D) { - GF_Node *child; - GF_ChildNodeItem *list; - u32 i, count; - GF_FieldInfo clone_field; - - count = gf_node_get_field_count(n); - - for (i=0; inode); - list = list->next; - } - break; - default: - gf_node_get_field(clone, i, &clone_field); - if (!gf_sg_vrml_field_equal(clone_field.far_ptr, field.far_ptr, field.fieldType)) { - StatField(st->stats, &field); + else if (n->sgprivate->tag<= GF_NODE_RANGE_LAST_X3D) { + GF_Node *child; + GF_ChildNodeItem *list; + u32 i, count; + GF_FieldInfo clone_field; + + count = gf_node_get_field_count(n); + + for (i=0; inode); + list = list->next; + } + break; + default: + gf_node_get_field(clone, i, &clone_field); + if (!gf_sg_vrml_field_equal(clone_field.far_ptr, field.far_ptr, field.fieldType)) { + StatField(st->stats, &field); + } + break; } - break; } } - } #endif gf_node_unregister(clone, NULL); @@ -461,7 +461,7 @@ GF_Err gf_sm_stats_for_command(GF_StatManager *stat, GF_Command *com) GF_Err e; GF_ChildNodeItem *list; GF_CommandField *inf = NULL; - if (gf_list_count(com->command_fields)) + if (gf_list_count(com->command_fields)) inf = (GF_CommandField*)gf_list_get(com->command_fields, 0); if (!com || !stat) return GF_BAD_PARAM; @@ -574,7 +574,7 @@ GF_Err gf_sm_stats_for_scene(GF_StatManager *stat, GF_SceneManager *sm) while ((sc = (GF_StreamContext*)gf_list_enum(sm->streams, &i))) { GF_AUContext *au; if (sc->streamType != GF_STREAM_SCENE) continue; - + if (!stat->stats->base_layer) stat->stats->base_layer = sc; diff --git a/src/scene_manager/swf_bifs.c b/src/scene_manager/swf_bifs.c index 04359c0..cb1009f 100644 --- a/src/scene_manager/swf_bifs.c +++ b/src/scene_manager/swf_bifs.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -586,7 +586,7 @@ static void s2b_merge_curve2d(M_Curve2D *s, M_Curve2D *tomerge) gf_sg_vrml_mf_append(&dest->point, GF_SG_VRML_MFVEC2F, &ptr); *((SFVec2f *)ptr) = pt; } - + i = 0; if (tomerge->type.vals[0] == 0) i=1; pt_idx = 1; @@ -669,7 +669,7 @@ static void s2b_insert_rec_in_coord(M_Coordinate2D *c, SWFShapeRec *srec) c->point.vals = gf_realloc(c->point.vals, sizeof(SFVec2f)*c->point.count); c->point.vals[j] = srec->path->pts[i]; } - srec->path->idx[i] = j; + srec->path->idx[i] = j; } } @@ -690,10 +690,10 @@ static GF_Err swf_bifs_define_shape(SWFReader *read, SWFShape *shape, SWFFont *p /*empty shape - for fonts, not a mistake, that's likelly space char*/ if (!shape) { - if (!parent_font) + if (!parent_font) return GF_OK; n = s2b_new_node(read, TAG_MPEG4_Shape); - } + } /*direct match, no top group*/ else if (last_sub_shape && (gf_list_count(shape->fill_left) + gf_list_count(shape->lines)<=1)) { Bool is_fill = 1; @@ -898,7 +898,7 @@ static GF_Err swf_bifs_define_text(SWFReader *read, SWFText *text) gf_free(str_w); gl = (M_Shape *) s2b_new_node(read, TAG_MPEG4_Shape); - gl->appearance = s2b_get_appearance(read, (GF_Node *) gl, gr->col, 0, 0); + gl->appearance = s2b_get_appearance(read, (GF_Node *) gl, gr->col, 0, 0); gl->geometry = (GF_Node *) t; gf_node_register(gl->geometry, (GF_Node *) gl); gf_node_insert_child((GF_Node *) par, (GF_Node *)gl, -1); @@ -1010,23 +1010,23 @@ static GF_Err swf_bifs_define_edit_text(SWFReader *read, SWFEditText *text) gf_sg_vrml_mf_append(&f->justify, GF_SG_VRML_MFSTRING, (void**)&ptr); switch (text->align) { case 0: - ((SFString*)ptr)->buffer = gf_strdup("BEGIN"); + ((SFString*)ptr)->buffer = gf_strdup("BEGIN"); break; case 1: - ((SFString*)ptr)->buffer = gf_strdup("END"); + ((SFString*)ptr)->buffer = gf_strdup("END"); break; case 3: - ((SFString*)ptr)->buffer = gf_strdup("JUSTIFY"); + ((SFString*)ptr)->buffer = gf_strdup("JUSTIFY"); break; default: - ((SFString*)ptr)->buffer = gf_strdup("MIDDLE"); + ((SFString*)ptr)->buffer = gf_strdup("MIDDLE"); break; } strcpy(styles, ""); if (!text->read_only) strcat(styles, "EDITABLE"); if (text->password) strcat(styles, "PASSWORD"); - + if (f->style.buffer) gf_free(f->style.buffer); f->style.buffer = gf_strdup(styles); @@ -1055,25 +1055,25 @@ static GF_Err swf_bifs_define_edit_text(SWFReader *read, SWFEditText *text) txt = (M_Shape *) s2b_new_node(read, TAG_MPEG4_Shape); - txt->appearance = s2b_get_appearance(read, (GF_Node *) txt, text->color, 0, 0); + txt->appearance = s2b_get_appearance(read, (GF_Node *) txt, text->color, 0, 0); txt->geometry = (GF_Node *) t; gf_node_register(txt->geometry, (GF_Node *) txt); - if (layout) { + if (layout) { gf_sg_vrml_mf_reset(&layout->justify, GF_SG_VRML_MFSTRING); gf_sg_vrml_mf_append(&layout->justify, GF_SG_VRML_MFSTRING, NULL); switch (text->align) { case 0: - layout->justify.vals[0] = gf_strdup("BEGIN"); + layout->justify.vals[0] = gf_strdup("BEGIN"); break; case 1: - layout->justify.vals[0] = gf_strdup("END"); + layout->justify.vals[0] = gf_strdup("END"); break; case 3: - layout->justify.vals[0] = gf_strdup("JUSTIFY"); + layout->justify.vals[0] = gf_strdup("JUSTIFY"); break; default: - layout->justify.vals[0] = gf_strdup("MIDDLE"); + layout->justify.vals[0] = gf_strdup("MIDDLE"); break; } if (text->multiline || text->word_wrap) layout->wrap = 1; @@ -1086,7 +1086,7 @@ static GF_Err swf_bifs_define_edit_text(SWFReader *read, SWFEditText *text) } else { gf_node_insert_child((GF_Node *) tr, (GF_Node *)txt, -1); gf_node_register((GF_Node *) txt, (GF_Node *) tr); - } + } if (tr) { char szDEF[1024]; u32 ID; @@ -1109,7 +1109,7 @@ static void swf_bifs_end_of_clip(SWFReader *read) GF_Command *com; GF_CommandField *f; GF_Node *empty; - + return; empty = gf_sg_find_node_by_name(read->load->scene_graph, "Shape0"); @@ -1417,7 +1417,7 @@ static GF_Err swf_bifs_setup_sound(SWFReader *read, SWFSound *snd, Bool soundstr /*if sprite always have the media active but controled by its mediaControl*/ if (read->current_sprite_id) { ((M_AudioClip*)n)->startTime = 0; - } + } /*otherwise start the media at the first soundstream block*/ else { ((M_AudioClip*)n)->startTime = snd->frame_delay_ms/1000.0; @@ -1453,7 +1453,7 @@ static GF_Err swf_bifs_setup_image(SWFReader *read, u32 ID, char *fileName) GF_Node *n, *par; GF_FieldInfo info; char szDEF[100]; - + e = swf_init_od(read, 0); if (e) return e; @@ -1587,7 +1587,7 @@ static void s2b_set_field(SWFReader *read, GF_List *dst, GF_Node *n, char *field f->pos = pos; f->fieldIndex = info.fieldIndex; - if (insert) + if (insert) gf_list_insert(dst, com, 0); else gf_list_add(dst, com); @@ -1773,7 +1773,7 @@ static GF_Err swf_bifs_show_frame(SWFReader *read) */ is_rap = (read->current_sprite_id || (read->flags & GF_SM_SWF_SPLIT_TIMELINE)) ? 1 : 0; #else - /*"The contents of the second frame are the cumulative effect of performing all the control tag operations from + /*"The contents of the second frame are the cumulative effect of performing all the control tag operations from the beginning of the file to the second ShowFrame tag, and so on" using RAP=0 forces reprocessing of previous frames when seeking/jumping*/ is_rap = 0; @@ -1788,10 +1788,10 @@ static GF_Err swf_bifs_show_frame(SWFReader *read) read->bifs_dict_au = gf_sm_stream_au_new(read->bifs_dict_es, ts, 0, 0); } /*if wait_frame is specified, aggregate all dictionary commands until frame is reached*/ - if (read->wait_frame && read->wait_frame<=read->current_frame) + if (read->wait_frame && read->wait_frame<=read->current_frame) read->wait_frame = 0; } - + return GF_OK; } @@ -1799,14 +1799,14 @@ static GF_Err swf_bifs_show_frame(SWFReader *read) static GF_Node *s2b_button_add_child(SWFReader *read, GF_Node *button, u32 tag, char *def_name, s32 pos) { GF_Node *n = s2b_new_node(read, tag); - + if (def_name) { u32 ID; read->load->ctx->max_node_id++; ID = read->load->ctx->max_node_id; gf_node_set_id((GF_Node *)n, ID, def_name); } - + gf_node_insert_child((GF_Node *)button, (GF_Node *)n, pos); gf_node_register((GF_Node *) n, (GF_Node *) button); return n; @@ -1850,7 +1850,7 @@ static GF_Err swf_bifs_define_button(SWFReader *read, SWF_Button *btn) gf_node_set_id((GF_Node *)btn_root, ID, szName); n = s2b_button_add_child(read, btn_root, TAG_MPEG4_ColorTransform, NULL, -1); - ((M_ColorTransform*)n)->maa = ((M_ColorTransform*)n)->mab = ((M_ColorTransform*)n)->mar = ((M_ColorTransform*)n)->mag = ((M_ColorTransform*)n)->ta = 0; + ((M_ColorTransform*)n)->maa = ((M_ColorTransform*)n)->mab = ((M_ColorTransform*)n)->mar = ((M_ColorTransform*)n)->mag = ((M_ColorTransform*)n)->ta = 0; /*locate hit buttons and add them to the color transform*/ for (i=0; icount; i++) { @@ -1973,7 +1973,7 @@ static void swf_bifs_finalize(SWFReader *read) { u32 i, count; - swf_bifs_end_of_clip(read); + swf_bifs_end_of_clip(read); while (gf_list_count(read->buttons)) { S2BBtnRec *btnrec = gf_list_get(read->buttons, 0); @@ -1982,7 +1982,7 @@ static void swf_bifs_finalize(SWFReader *read) } count = gf_list_count(read->fonts); - for (i=0;ifonts, i); while (gf_list_count(ft->glyphs)) { GF_Node *gl = (GF_Node *)gf_list_get(ft->glyphs, 0); @@ -2024,8 +2024,10 @@ Bool swf_bifs_action(SWFReader *read, SWFAction *act) break; case GF_SWF_AS3_GET_URL: n = gf_sg_find_node_by_name(read->load->scene_graph, "MOVIE_URL"); - sfurl.OD_ID = 0; sfurl.url = act->url; - url.count = 1; url.vals = &sfurl; + sfurl.OD_ID = 0; + sfurl.url = act->url; + url.count = 1; + url.vals = &sfurl; s2b_set_field(read, dst, n, "url", -1, GF_SG_VRML_MFURL, &url, 0); s2b_set_field(read, dst, n, "parameter", -1, GF_SG_VRML_MFSTRING, &url, 0); bval = 1; @@ -2111,13 +2113,13 @@ GF_Err swf_to_bifs_init(SWFReader *read) gf_node_set_id(n, 1, "BACKGROUND"); gf_node_insert_child(read->root, n, -1); gf_node_register(n, read->root); - + /*movie anchor*/ n = s2b_new_node(read, TAG_MPEG4_Anchor); gf_node_set_id(n, 2, "MOVIE_URL"); gf_node_insert_child(read->root, n, -1); gf_node_register(n, read->root); - + /*dictionary*/ n = s2b_new_node(read, TAG_MPEG4_Switch); gf_node_set_id(n, 3, "DICTIONARY"); @@ -2163,7 +2165,7 @@ GF_Err swf_to_bifs_init(SWFReader *read) url->url = gf_strdup("urn:inet:gpac:builtin:IndexedCurve2D"); gf_sg_proto_field_new(proto, GF_SG_VRML_SFNODE, GF_SG_EVENT_EXPOSED_FIELD, "coord"); - + pfield = gf_sg_proto_field_new(proto, GF_SG_VRML_SFFLOAT, GF_SG_EVENT_EXPOSED_FIELD, "fineness"); gf_sg_proto_field_get_field(pfield, &info); *((SFFloat*)info.far_ptr) = FIX_ONE/2; @@ -2172,7 +2174,7 @@ GF_Err swf_to_bifs_init(SWFReader *read) ftMin = 0; ftMax = 15*FIX_ONE; gf_bifs_proto_field_set_aq_info(pfield, 13, 1, GF_SG_VRML_SFINT32, &ftMin, &ftMax, 4); - + pfield = gf_sg_proto_field_new(proto, GF_SG_VRML_MFINT32, GF_SG_EVENT_EXPOSED_FIELD, "coordIndex"); ftMin = 0; ftMax = FIX_MAX; @@ -2250,10 +2252,4 @@ GF_Err swf_to_bifs_init(SWFReader *read) #endif /*GPAC_DISABLE_SWF_IMPORT*/ -#else -GF_Err swf_to_bifs_init(SWFReader *read) -{ - return GF_NOT_SUPPORTED; -} - #endif /*GPAC_DISABLE_VRML*/ diff --git a/src/scene_manager/swf_parse.c b/src/scene_manager/swf_parse.c index 7425d84..21698b0 100644 --- a/src/scene_manager/swf_parse.c +++ b/src/scene_manager/swf_parse.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -141,7 +141,7 @@ static s32 swf_read_sint(SWFReader *read, u32 nbBits) u32 i; if (!nbBits)return 0; r = -1 * (s32) swf_read_int(read, 1); - for (i=1; i>8)&0xFF); res<<=8; - res |= ((val>>16)&0xFF); res<<=8; + res = (val&0xFF); + res <<=8; + res |= ((val>>8)&0xFF); + res<<=8; + res |= ((val>>16)&0xFF); + res<<=8; res|= ((val>>24)&0xFF); return res; } @@ -189,7 +192,8 @@ static u16 swf_get_16(SWFReader *read) { u16 val, res; val = swf_read_int(read, 16); - res = (val&0xFF); res <<=8; + res = (val&0xFF); + res <<=8; res |= ((val>>8)&0xFF); return res; } @@ -200,7 +204,7 @@ static s16 swf_get_s16(SWFReader *read) u8 v1; v1 = swf_read_int(read, 8); val = swf_read_sint(read, 8); - val = (val<<8)&0xFF00; + val = (val<<8)&0xFF00; val |= (v1&0xFF); return val; } @@ -209,8 +213,10 @@ static u32 swf_get_color(SWFReader *read) { u32 res; res = 0xFF00; - res |= swf_read_int(read, 8); res<<=8; - res |= swf_read_int(read, 8); res<<=8; + res |= swf_read_int(read, 8); + res<<=8; + res |= swf_read_int(read, 8); + res<<=8; res |= swf_read_int(read, 8); return res; } @@ -218,8 +224,10 @@ static u32 swf_get_color(SWFReader *read) static u32 swf_get_argb(SWFReader *read) { u32 res, al; - res = swf_read_int(read, 8); res<<=8; - res |= swf_read_int(read, 8); res<<=8; + res = swf_read_int(read, 8); + res<<=8; + res |= swf_read_int(read, 8); + res<<=8; res |= swf_read_int(read, 8); al = swf_read_int(read, 8); return ((al<<24) | res); @@ -234,7 +242,7 @@ static u32 swf_get_matrix(SWFReader *read, GF_Matrix2D *mat) mat->m[0] = mat->m[4] = FIX_ONE; bits_read = swf_align(read); - + flag = swf_read_int(read, 1); bits_read += 1; if (flag) { @@ -300,14 +308,14 @@ static void swf_get_colormatrix(SWFReader *read, GF_ColorMatrix *cmat) cmat->m[19] = FLT2FIX( swf_read_sint(read, nbbits) * SWF_COLOR_SCALE ); } cmat->identity = 0; - if ((cmat->m[0] == cmat->m[6]) - && (cmat->m[0] == cmat->m[12]) - && (cmat->m[0] == cmat->m[18]) - && (cmat->m[0] == FIX_ONE) - && (cmat->m[4] == cmat->m[9]) - && (cmat->m[4] == cmat->m[14]) - && (cmat->m[4] == cmat->m[19]) - && (cmat->m[4] == 0)) + if ((cmat->m[0] == cmat->m[6]) + && (cmat->m[0] == cmat->m[12]) + && (cmat->m[0] == cmat->m[18]) + && (cmat->m[0] == FIX_ONE) + && (cmat->m[4] == cmat->m[9]) + && (cmat->m[4] == cmat->m[14]) + && (cmat->m[4] == cmat->m[19]) + && (cmat->m[4] == 0)) cmat->identity = 1; } @@ -363,7 +371,7 @@ static void swf_parse_styles(SWFReader *read, u32 revision, SWFShape *shape, u32 { u32 i, j, count; SWFShapeRec *style; - + swf_align(read); /*get fill styles*/ @@ -427,7 +435,7 @@ static void swf_parse_styles(SWFReader *read, u32 revision, SWFShape *shape, u32 } else { style->solid_col = 0xFF; } - } + } /*bitmap fill*/ else if (style->type & 0x40) { style->img_id = swf_get_16(read); @@ -437,7 +445,7 @@ static void swf_parse_styles(SWFReader *read, u32 revision, SWFShape *shape, u32 style->solid_col = 0xFF00FFFF; } swf_get_matrix(read, &style->mat); - } + } /*solid fill*/ else { if (revision==2) style->solid_col = swf_get_argb(read); @@ -643,7 +651,7 @@ restart: j=i+1; for (j=i+1; j < gf_list_count(paths); j++) { np = (SWFPath*)gf_list_get(paths, j); - + /*check if any next subpath ends at the same place we're starting*/ if ((np->pts[np->nbPts-1].x == p->pts[0].x) && (np->pts[np->nbPts-1].y == p->pts[0].y)) { u32 k; @@ -794,15 +802,15 @@ restart: } /* - Notes on SWF->BIFS conversion - some ideas taken from libswfdec + Notes on SWF->BIFS conversion - some ideas taken from libswfdec A single fillStyle has 2 associated path, one used for left fill, one for right fill This is then a 4 step process: 1- blindly parse swf shape, and add point/lines to the proper left/right path 2- for each fillStyles, revert the right path so that it becomes a left path 3- concatenate left and right paths 4- resort all subelements of the final path, making sure moveTo introduced by the SWF coding (due to style changes) - are removed. - Ex: if path is + are removed. + Ex: if path is A->C, B->A, C->B = moveTo(A), lineTo(C), moveTo(B), lineTo (A), moveTo(C), lineTo(B) we restort and remove unneeded moves to get A->C->B = moveTo(A), lineTo(C), lineTo(B), lineTo(A) @@ -922,7 +930,7 @@ static GF_Err swf_parse_shape_def(SWFReader *read, SWFFont *font, u32 revision) if (set_fill0) fill0 = swf_read_int(read, bits_fill); if (set_fill1) fill1 = swf_read_int(read, bits_fill); if (set_strike) strike = swf_read_int(read, bits_line); - /*looks like newStyle does not append styles but define a new set - old styles can no + /*looks like newStyle does not append styles but define a new set - old styles can no longer be referenced*/ if (new_style) { /*flush current shape record into BIFS*/ @@ -967,7 +975,7 @@ static GF_Err swf_parse_shape_def(SWFReader *read, SWFFont *font, u32 revision) end.y = FLT2FIX( y * SWF_TWIP_SCALE ); /*curveTo*/ comType = 2; - } + } /*straight line*/ else { nbBits = 2 + swf_read_int(read, 4); @@ -1043,7 +1051,7 @@ static DispShape *swf_get_depth_entry(SWFReader *read, u32 Depth, Bool create) memset(&tmp->mat, 0, sizeof(GF_Matrix2D)); tmp->mat.m[0] = tmp->mat.m[4] = FIX_ONE; - + memset(&tmp->cmat, 0, sizeof(GF_ColorMatrix)); tmp->cmat.m[0] = tmp->cmat.m[6] = tmp->cmat.m[12] = tmp->cmat.m[18] = FIX_ONE; tmp->cmat.identity = 1; @@ -1088,13 +1096,13 @@ static GF_Err swf_actions(SWFReader *read, u32 mask, u32 key) switch (action_code) { /* SWF 3 Action Model */ - case 0x81: /* goto frame */ + case 0x81: /* goto frame */ assert (length == 2); act.type = GF_SWF_AS3_GOTO_FRAME; act.frame_number = swf_get_16(read); read->action(read, &act); break; - case 0x83: /* get URL */ + case 0x83: /* get URL */ act.type = GF_SWF_AS3_GET_URL; act.url = swf_get_string(read); act.target = swf_get_string(read); @@ -1102,34 +1110,40 @@ static GF_Err swf_actions(SWFReader *read, u32 mask, u32 key) gf_free(act.url); gf_free(act.target); break; - /* next frame */ - case 0x04: DO_ACT(GF_SWF_AS3_NEXT_FRAME) - /* previous frame */ - case 0x05: DO_ACT(GF_SWF_AS3_PREV_FRAME) - /* play */ - case 0x06: DO_ACT(GF_SWF_AS3_PLAY) - /* stop */ - case 0x07: DO_ACT(GF_SWF_AS3_STOP) - /* toggle quality */ - case 0x08: DO_ACT(GF_SWF_AS3_TOGGLE_QUALITY) - /* stop sounds*/ - case 0x09: DO_ACT(GF_SWF_AS3_STOP_SOUNDS) - /* wait for frame */ - case 0x8A: + /* next frame */ + case 0x04: + DO_ACT(GF_SWF_AS3_NEXT_FRAME) + /* previous frame */ + case 0x05: + DO_ACT(GF_SWF_AS3_PREV_FRAME) + /* play */ + case 0x06: + DO_ACT(GF_SWF_AS3_PLAY) + /* stop */ + case 0x07: + DO_ACT(GF_SWF_AS3_STOP) + /* toggle quality */ + case 0x08: + DO_ACT(GF_SWF_AS3_TOGGLE_QUALITY) + /* stop sounds*/ + case 0x09: + DO_ACT(GF_SWF_AS3_STOP_SOUNDS) + /* wait for frame */ + case 0x8A: assert (length == 3); act.type = GF_SWF_AS3_WAIT_FOR_FRAME; act.frame_number = swf_get_16(read); skip_actions = swf_read_int(read, 8); if (read->action(read, &act)) skip_actions = 0; break; - /* set target */ + /* set target */ case 0x8B: act.type = GF_SWF_AS3_SET_TARGET; act.target = swf_get_string(read); read->action(read, &act); gf_free(act.target); break; - /* goto label */ + /* goto label */ case 0x8C: act.type = GF_SWF_AS3_GOTO_LABEL; act.target = swf_get_string(read); @@ -1146,7 +1160,7 @@ static GF_Err swf_actions(SWFReader *read, u32 mask, u32 key) } #undef DO_ACT - return GF_OK; + return GF_OK; } static GF_Err swf_def_button(SWFReader *read, u32 revision) @@ -1191,7 +1205,7 @@ static GF_Err swf_def_button(SWFReader *read, u32 revision) has_actions = swf_get_16(read); mask = 0; for (i=0; i<8; i++) { - if (swf_read_int(read, 1)) + if (swf_read_int(read, 1)) mask |= 1<place_obj(read, depth, shape_id, ds->char_id, type, - has_mat ? &mat : NULL, - has_cmat ? &cmat : NULL, - swf_mat_is_identity(&ds->mat) ? NULL : &ds->mat, - ds->cmat.identity ? NULL : &ds->cmat); + e = read->place_obj(read, depth, shape_id, ds->char_id, type, + has_mat ? &mat : NULL, + has_cmat ? &cmat : NULL, + swf_mat_is_identity(&ds->mat) ? NULL : &ds->mat, + ds->cmat.identity ? NULL : &ds->cmat); /*remember matrices*/ memcpy(&ds->mat, &mat, sizeof(GF_Matrix2D)); @@ -1410,7 +1424,7 @@ static GF_Err swf_def_font(SWFReader *read, u32 revision) count = swf_get_16(read); ft->nbGlyphs = count / 2; offset_table = (u32*)gf_malloc(sizeof(u32) * ft->nbGlyphs); - offset_table[0] = 0; + offset_table[0] = 0; for (i=1; inbGlyphs; i++) offset_table[i] = swf_get_16(read); for (i=0; inbGlyphs; i++) { @@ -1449,7 +1463,7 @@ static GF_Err swf_def_font(SWFReader *read, u32 revision) else offset_table[i] = swf_get_16(read); } } - + if (wide_offset) { code_offset = swf_get_32(read); } else { @@ -1512,7 +1526,7 @@ static GF_Err swf_def_font_info(SWFReader *read) SWFFont *ft; Bool wide_chars; u32 i, count; - + i = swf_get_16(read); ft = swf_find_font(read, i); if (!ft) { @@ -1606,7 +1620,7 @@ static GF_Err swf_def_text(SWFReader *read, u32 revision) has_col = swf_read_int(read, 1); has_y_off = swf_read_int(read, 1); has_x_off = swf_read_int(read, 1); - + /*end of rec*/ if (!has_font && !has_col && !has_y_off && !has_x_off) break; if (has_font) fontID = swf_get_16(read); @@ -1671,7 +1685,7 @@ static GF_Err swf_def_edit_text(SWFReader *read) /*reserved*/swf_read_int(read, 1); txt.html = swf_read_int(read, 1); txt.outlines = swf_read_int(read, 1); - + if (has_font) { txt.fontID = swf_get_16(read); txt.font_height = FLT2FIX( swf_get_16(read) * SWF_TWIP_SCALE ); @@ -1829,7 +1843,7 @@ typedef struct u32 sync_flags; u32 in_point, out_point; u32 nb_loops; -} SoundInfo; +} SoundInfo; static SoundInfo swf_skip_soundinfo(SWFReader *read) { @@ -1898,7 +1912,7 @@ static GF_Err swf_soundstream_hdr(SWFReader *read) swf_report(read, GF_BAD_PARAM, "More than one sound stream for current timeline!!"); return swf_func_skip(read); } - + GF_SAFEALLOC(snd, SWFSound); /*rec_mix = */swf_read_int(read, 8); @@ -1963,7 +1977,7 @@ static GF_Err swf_soundstream_block(SWFReader *read) /*error at setup*/ if (!read->sound_stream->output) { read->sound_stream->output = gf_f64_open(read->sound_stream->szFileName, "wb"); - if (!read->sound_stream->output) + if (!read->sound_stream->output) return swf_func_skip(read); } /*store TS of first AU*/ @@ -2029,7 +2043,7 @@ static GF_Err swf_def_bits_jpeg(SWFReader *read, u32 version) u32 skip = 0; u32 AlphaPlaneSize = 0; u32 size = read->size; - + ID = swf_get_16(read); size -= 2; if (version==3) { @@ -2045,7 +2059,7 @@ static GF_Err swf_def_bits_jpeg(SWFReader *read, u32 version) } else { sprintf(szName, "swf_jpeg_%d.jpg", ID); } - + if (version!=3) file = gf_f64_open(szName, "wb"); @@ -2063,10 +2077,10 @@ static GF_Err swf_def_bits_jpeg(SWFReader *read, u32 version) } else { u32 i; for (i=0; itag) { - case SWF_END: return GF_OK; - case SWF_PROTECT: return GF_OK; - case SWF_SETBACKGROUNDCOLOR: return swf_set_backcol(read); - case SWF_DEFINESHAPE: return swf_parse_shape_def(read, NULL, 0); - case SWF_DEFINESHAPE2: return swf_parse_shape_def(read, NULL, 1); - case SWF_DEFINESHAPE3: return swf_parse_shape_def(read, NULL, 2); - case SWF_PLACEOBJECT: return swf_place_obj(read, 0); - case SWF_PLACEOBJECT2: return swf_place_obj(read, 1); - case SWF_REMOVEOBJECT: return swf_remove_obj(read, 0); - case SWF_REMOVEOBJECT2: return swf_remove_obj(read, 1); - case SWF_SHOWFRAME: return swf_show_frame(read); - case SWF_DEFINEFONT: return swf_def_font(read, 0); - case SWF_DEFINEFONT2: return swf_def_font(read, 1); - case SWF_DEFINEFONTINFO: return swf_def_font_info(read); - case SWF_DEFINETEXT: return swf_def_text(read, 0); - case SWF_DEFINETEXT2: return swf_def_text(read, 1); - case SWF_DEFINEEDITTEXT: return swf_def_edit_text(read); - case SWF_DEFINESPRITE: return swf_def_sprite(read); + case SWF_END: + return GF_OK; + case SWF_PROTECT: + return GF_OK; + case SWF_SETBACKGROUNDCOLOR: + return swf_set_backcol(read); + case SWF_DEFINESHAPE: + return swf_parse_shape_def(read, NULL, 0); + case SWF_DEFINESHAPE2: + return swf_parse_shape_def(read, NULL, 1); + case SWF_DEFINESHAPE3: + return swf_parse_shape_def(read, NULL, 2); + case SWF_PLACEOBJECT: + return swf_place_obj(read, 0); + case SWF_PLACEOBJECT2: + return swf_place_obj(read, 1); + case SWF_REMOVEOBJECT: + return swf_remove_obj(read, 0); + case SWF_REMOVEOBJECT2: + return swf_remove_obj(read, 1); + case SWF_SHOWFRAME: + return swf_show_frame(read); + case SWF_DEFINEFONT: + return swf_def_font(read, 0); + case SWF_DEFINEFONT2: + return swf_def_font(read, 1); + case SWF_DEFINEFONTINFO: + return swf_def_font_info(read); + case SWF_DEFINETEXT: + return swf_def_text(read, 0); + case SWF_DEFINETEXT2: + return swf_def_text(read, 1); + case SWF_DEFINEEDITTEXT: + return swf_def_edit_text(read); + case SWF_DEFINESPRITE: + return swf_def_sprite(read); /*no revision needed*/ - case SWF_SOUNDSTREAMHEAD: + case SWF_SOUNDSTREAMHEAD: case SWF_SOUNDSTREAMHEAD2: return swf_soundstream_hdr(read); - case SWF_DEFINESOUND: return swf_def_sound(read); - case SWF_STARTSOUND: return swf_start_sound(read); - case SWF_SOUNDSTREAMBLOCK: return swf_soundstream_block(read); - - case SWF_DEFINEBUTTON: return swf_def_button(read, 0); - case SWF_DEFINEBUTTON2: return swf_def_button(read, 1); + case SWF_DEFINESOUND: + return swf_def_sound(read); + case SWF_STARTSOUND: + return swf_start_sound(read); + case SWF_SOUNDSTREAMBLOCK: + return swf_soundstream_block(read); + + case SWF_DEFINEBUTTON: + return swf_def_button(read, 0); + case SWF_DEFINEBUTTON2: + return swf_def_button(read, 1); // case SWF_DEFINEBUTTONSOUND: case SWF_DOACTION: return swf_actions(read, 0, 0); - case SWF_FRAMELABEL: - { - char *framelabel = swf_get_string(read); - gf_free(framelabel); - return GF_OK; - } + case SWF_FRAMELABEL: + { + char *framelabel = swf_get_string(read); + gf_free(framelabel); + return GF_OK; + } - case SWF_JPEGTABLES: return swf_def_hdr_jpeg(read); - case SWF_DEFINEBITSJPEG: return swf_def_bits_jpeg(read, 1); - case SWF_DEFINEBITSJPEG2: return swf_def_bits_jpeg(read, 2); - case SWF_DEFINEBITSJPEG3: return swf_def_bits_jpeg(read, 3); + case SWF_JPEGTABLES: + return swf_def_hdr_jpeg(read); + case SWF_DEFINEBITSJPEG: + return swf_def_bits_jpeg(read, 1); + case SWF_DEFINEBITSJPEG2: + return swf_def_bits_jpeg(read, 2); + case SWF_DEFINEBITSJPEG3: + return swf_def_bits_jpeg(read, 3); - default: return swf_unknown_tag(read); + default: + return swf_unknown_tag(read); } } @@ -2345,7 +2440,7 @@ GF_Err gf_sm_load_run_swf(GF_SceneLoader *load) if (e==GF_EOS) e = GF_OK; if (!e) { - if (read->flat_limit != 0) + if (read->flat_limit != 0) swf_report(read, GF_OK, "%d points removed while parsing shapes (Flattening limit %.4f)", read->flatten_points, read->flat_limit); if (read->no_as && read->has_interact) swf_report(read, GF_OK, "ActionScripts and interactions have been removed"); @@ -2439,9 +2534,9 @@ SWFReader *gf_swf_reader_new(const char *localPath, const char *inputName) return read; } -GF_Err gf_swf_reader_set_user_mode(SWFReader *read, void *user, - GF_Err (*add_sample)(void *user, const char *data, u32 length, u64 timestamp, Bool isRap), - GF_Err (*add_header)(void *user, const char *data, u32 length)) +GF_Err gf_swf_reader_set_user_mode(SWFReader *read, void *user, + GF_Err (*add_sample)(void *user, const char *data, u32 length, u64 timestamp, Bool isRap), + GF_Err (*add_header)(void *user, const char *data, u32 length)) { if (!read) return GF_BAD_PARAM; read->user = user; @@ -2474,7 +2569,7 @@ GF_Err gf_swf_read_header(SWFReader *read) swf_get_rec(read, &rc); read->width = rc.w; read->height = rc.h; - + swf_align(read); read->frame_rate = swf_get_16(read)>>8; read->frame_count = swf_get_16(read); @@ -2506,11 +2601,11 @@ GF_Err gf_sm_load_init_swf(GF_SceneLoader *load) read->no_as = 1; } - if (!(load->swf_import_flags & GF_SM_SWF_USE_SVG)) { - e = swf_to_bifs_init(read); - } else { - e = swf_to_svg_init(read, read->flags, load->swf_flatten_limit); - } + if (!(load->swf_import_flags & GF_SM_SWF_USE_SVG)) { + e = swf_to_bifs_init(read); + } else { + e = swf_to_svg_init(read, read->flags, load->swf_flatten_limit); + } if (e) goto exit; /*parse all tags*/ diff --git a/src/scene_manager/swf_svg.c b/src/scene_manager/swf_svg.c index 41cfcbd..1426260 100644 --- a/src/scene_manager/swf_svg.c +++ b/src/scene_manager/swf_svg.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -38,9 +38,9 @@ typedef struct _swf_svg_sample { - u64 start; - u64 end; - char *data; + u64 start; + u64 end; + char *data; } GF_SWF_SVG_Sample; static void swf_svg_print(SWFReader *read, const char *format, ...) { @@ -70,18 +70,18 @@ static void swf_svg_print(SWFReader *read, const char *format, ...) { static void swf_svg_print_color(SWFReader *read, u32 ARGB) { - SFColor val; - val.red = INT2FIX((ARGB>>16)&0xFF) / 255*100; - val.green = INT2FIX((ARGB>>8)&0xFF) / 255*100; - val.blue = INT2FIX((ARGB)&0xFF) / 255*100; - swf_svg_print(read, "rgb(%g%%,%g%%,%g%%)", FIX2FLT(val.red), FIX2FLT(val.green), FIX2FLT(val.blue)); + SFColor val; + val.red = INT2FIX((ARGB>>16)&0xFF) / 255*100; + val.green = INT2FIX((ARGB>>8)&0xFF) / 255*100; + val.blue = INT2FIX((ARGB)&0xFF) / 255*100; + swf_svg_print(read, "rgb(%g%%,%g%%,%g%%)", FIX2FLT(val.red), FIX2FLT(val.green), FIX2FLT(val.blue)); } static void swf_svg_print_alpha(SWFReader *read, u32 ARGB) { - Fixed alpha; - alpha = INT2FIX((ARGB>>24)&0xFF)/255; - swf_svg_print(read, "%g", FIX2FLT(alpha)); + Fixed alpha; + alpha = INT2FIX((ARGB>>24)&0xFF)/255; + swf_svg_print(read, "%g", FIX2FLT(alpha)); } static void swg_svg_print_shape_record_to_fill_stroke(SWFReader *read, SWFShapeRec *srec, Bool is_fill) @@ -91,253 +91,253 @@ static void swg_svg_print_shape_record_to_fill_stroke(SWFReader *read, SWFShapeR switch (srec->type) { /*solid/alpha fill*/ case 0x00: - swf_svg_print(read, "fill=\""); - swf_svg_print_color(read, srec->solid_col); - swf_svg_print(read, "\" "); - swf_svg_print(read, "fill-opacity=\""); - swf_svg_print_alpha(read, srec->solid_col); - swf_svg_print(read, "\" "); + swf_svg_print(read, "fill=\""); + swf_svg_print_color(read, srec->solid_col); + swf_svg_print(read, "\" "); + swf_svg_print(read, "fill-opacity=\""); + swf_svg_print_alpha(read, srec->solid_col); + swf_svg_print(read, "\" "); break; case 0x10: case 0x12: - //if (read->flags & GF_SM_SWF_NO_GRADIENT) { - // u32 col = srec->grad_col[srec->nbGrad/2]; - // col |= 0xFF000000; - // n->appearance = s2b_get_appearance(read, (GF_Node *) n, col, 0, 0); - //} else { - // n->appearance = s2b_get_gradient(read, (GF_Node *) n, shape, srec); - //} - //break; + //if (read->flags & GF_SM_SWF_NO_GRADIENT) { + // u32 col = srec->grad_col[srec->nbGrad/2]; + // col |= 0xFF000000; + // n->appearance = s2b_get_appearance(read, (GF_Node *) n, col, 0, 0); + //} else { + // n->appearance = s2b_get_gradient(read, (GF_Node *) n, shape, srec); + //} + //break; case 0x40: case 0x41: case 0x42: case 0x43: - //n->appearance = s2b_get_bitmap(read, (GF_Node *) n, shape, srec); - //break; + //n->appearance = s2b_get_bitmap(read, (GF_Node *) n, shape, srec); + //break; default: swf_report(read, GF_NOT_SUPPORTED, "fill_style %x not supported", srec->type); break; } } else { - swf_svg_print(read, "fill=\"none\" "); - swf_svg_print(read, "stroke=\""); - swf_svg_print_color(read, srec->solid_col); - swf_svg_print(read, "\" "); - swf_svg_print(read, "stroke-opacity=\""); - swf_svg_print_alpha(read, srec->solid_col); - swf_svg_print(read, "\" "); - swf_svg_print(read, "stroke-width=\"%g\" ", FIX2FLT(srec->width)); + swf_svg_print(read, "fill=\"none\" "); + swf_svg_print(read, "stroke=\""); + swf_svg_print_color(read, srec->solid_col); + swf_svg_print(read, "\" "); + swf_svg_print(read, "stroke-opacity=\""); + swf_svg_print_alpha(read, srec->solid_col); + swf_svg_print(read, "\" "); + swf_svg_print(read, "stroke-width=\"%g\" ", FIX2FLT(srec->width)); } } -static void swf_svg_print_shape_record_to_path_d(SWFReader *read, SWFShapeRec *srec) +static void swf_svg_print_shape_record_to_path_d(SWFReader *read, SWFShapeRec *srec) { - u32 pt_idx; - u32 i; - - pt_idx = 0; - for (i=0; ipath->nbType; i++) { - switch (srec->path->types[i]) { - /*moveTo*/ - case 0: - swf_svg_print(read, "M%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); - pt_idx++; - break; - /*lineTo*/ - case 1: - swf_svg_print(read, "L%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); - pt_idx++; - break; - /*curveTo*/ - case 2: - swf_svg_print(read, "Q%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); - pt_idx++; - swf_svg_print(read, ",%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); - pt_idx++; - break; - } - } + u32 pt_idx; + u32 i; + + pt_idx = 0; + for (i=0; ipath->nbType; i++) { + switch (srec->path->types[i]) { + /*moveTo*/ + case 0: + swf_svg_print(read, "M%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); + pt_idx++; + break; + /*lineTo*/ + case 1: + swf_svg_print(read, "L%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); + pt_idx++; + break; + /*curveTo*/ + case 2: + swf_svg_print(read, "Q%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); + pt_idx++; + swf_svg_print(read, ",%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y)); + pt_idx++; + break; + } + } } static void swf_svg_print_matrix(SWFReader *read, GF_Matrix2D *mat) { - if (!gf_mx2d_is_identity(*mat)) - { - GF_Point2D scale; - GF_Point2D translate; - Fixed rotate; - if( gf_mx2d_decompose(mat, &scale, &rotate, &translate)) - { - swf_svg_print(read, "transform=\""); - if (translate.x != 0 || translate.y != 0) - { - swf_svg_print(read, "translate(%g, %g) ", FIX2FLT(translate.x), FIX2FLT(translate.y)); - } - if (rotate != 0) - { - swf_svg_print(read, "rotate(%g) ", FIX2FLT(rotate)); - } - if (scale.x != FIX_ONE || scale.y != FIX_ONE) - { - swf_svg_print(read, "scale(%g, %g) ", FIX2FLT(scale.x), FIX2FLT(scale.y)); - } - swf_svg_print(read, "\" "); - } - else - { - swf_svg_print(read, "transform=\"matrix(%g,%g,%g,%g,%g,%g)\" ", FIX2FLT(mat->m[0]), FIX2FLT(mat->m[3]), FIX2FLT(mat->m[1]), FIX2FLT(mat->m[4]), FIX2FLT(mat->m[2]), FIX2FLT(mat->m[5]) ); - } - } + if (!gf_mx2d_is_identity(*mat)) + { + GF_Point2D scale; + GF_Point2D translate; + Fixed rotate; + if( gf_mx2d_decompose(mat, &scale, &rotate, &translate)) + { + swf_svg_print(read, "transform=\""); + if (translate.x != 0 || translate.y != 0) + { + swf_svg_print(read, "translate(%g, %g) ", FIX2FLT(translate.x), FIX2FLT(translate.y)); + } + if (rotate != 0) + { + swf_svg_print(read, "rotate(%g) ", FIX2FLT(rotate)); + } + if (scale.x != FIX_ONE || scale.y != FIX_ONE) + { + swf_svg_print(read, "scale(%g, %g) ", FIX2FLT(scale.x), FIX2FLT(scale.y)); + } + swf_svg_print(read, "\" "); + } + else + { + swf_svg_print(read, "transform=\"matrix(%g,%g,%g,%g,%g,%g)\" ", FIX2FLT(mat->m[0]), FIX2FLT(mat->m[3]), FIX2FLT(mat->m[1]), FIX2FLT(mat->m[4]), FIX2FLT(mat->m[2]), FIX2FLT(mat->m[5]) ); + } + } } /*translates Flash to SVG shapes*/ static GF_Err swf_svg_define_shape(SWFReader *read, SWFShape *shape, SWFFont *parent_font, Bool last_sub_shape) { - u32 i; - SWFShapeRec *srec; - - if (parent_font && (read->flags & GF_SM_SWF_NO_FONT)) - { - return GF_OK; - } - - if (!read->svg_shape_started) - { - swf_svg_print(read, "\n"); - if (!parent_font) - { - swf_svg_print(read, "\n", shape->ID); - } - else - { - char szGlyphId[256]; - sprintf(szGlyphId, "Font%d_Glyph%d", parent_font->fontID, gf_list_count(parent_font->glyphs)); - swf_svg_print(read, "\n", szGlyphId); - gf_list_add(parent_font->glyphs, szGlyphId); - } - } + u32 i; + SWFShapeRec *srec; + + if (parent_font && (read->flags & GF_SM_SWF_NO_FONT)) + { + return GF_OK; + } + + if (!read->svg_shape_started) + { + swf_svg_print(read, "\n"); + if (!parent_font) + { + swf_svg_print(read, "\n", shape->ID); + } + else + { + char szGlyphId[256]; + sprintf(szGlyphId, "Font%d_Glyph%d", parent_font->fontID, gf_list_count(parent_font->glyphs)); + swf_svg_print(read, "\n", szGlyphId); + gf_list_add(parent_font->glyphs, szGlyphId); + } + } read->empty_frame = GF_FALSE; - read->svg_shape_started = GF_TRUE; - - i=0; - while ((srec = (SWFShapeRec*)gf_list_enum(shape->fill_left, &i))) { - swf_svg_print(read, "\n"); - } - i=0; - while ((srec = (SWFShapeRec*)gf_list_enum(shape->lines, &i))) { - swf_svg_print(read, "\n"); - } - - if (last_sub_shape) - { - read->svg_shape_started = GF_FALSE; - swf_svg_print(read, "\n"); - swf_svg_print(read, "\n"); - } - return GF_OK; + read->svg_shape_started = GF_TRUE; + + i=0; + while ((srec = (SWFShapeRec*)gf_list_enum(shape->fill_left, &i))) { + swf_svg_print(read, "\n"); + } + i=0; + while ((srec = (SWFShapeRec*)gf_list_enum(shape->lines, &i))) { + swf_svg_print(read, "\n"); + } + + if (last_sub_shape) + { + read->svg_shape_started = GF_FALSE; + swf_svg_print(read, "\n"); + swf_svg_print(read, "\n"); + } + return GF_OK; } static GF_Err swf_svg_define_text(SWFReader *read, SWFText *text) { - Bool use_text; - u32 i; - u32 j; - SWFGlyphRec *gr; - SWFFont *ft; - - use_text = (read->flags & GF_SM_SWF_NO_FONT) ? 1 : 0; - - swf_svg_print(read, "\n"); - swf_svg_print(read, "ID); - swf_svg_print_matrix(read, &text->mat); - swf_svg_print(read, ">\n"); - - i=0; - while ((gr = (SWFGlyphRec*)gf_list_enum(text->text, &i))) - { - ft = NULL; - if (use_text) { - ft = swf_find_font(read, gr->fontID); - if (!ft->glyph_codes) { - use_text = 0; - swf_report(read, GF_BAD_PARAM, "Font glyphs are not defined, cannot reference extern font - Forcing glyph embedding"); - } - } - if (use_text) { - /*restore back the font height in pixels (it's currently in SWF glyph design units)*/ - swf_svg_print(read, "orig_x)); - swf_svg_print(read, "y=\"%g \" ", FIX2FLT(gr->orig_y)); - swf_svg_print(read, "font-size=\"%d\" ", (u32)(gr->fontSize * SWF_TWIP_SCALE)); - if (ft->fontName) - { - swf_svg_print(read, "font-family=\"%s\" ", ft->fontName); - } - if (ft->is_italic) - { - swf_svg_print(read, "font-style=\"italic\" "); - } - if (ft->is_bold) - { - swf_svg_print(read, "font-weight=\"bold\" "); - } - swf_svg_print(read, ">"); - /*convert to UTF-8*/ - { + Bool use_text; + u32 i; + u32 j; + SWFGlyphRec *gr; + SWFFont *ft; + + use_text = (read->flags & GF_SM_SWF_NO_FONT) ? 1 : 0; + + swf_svg_print(read, "\n"); + swf_svg_print(read, "ID); + swf_svg_print_matrix(read, &text->mat); + swf_svg_print(read, ">\n"); + + i=0; + while ((gr = (SWFGlyphRec*)gf_list_enum(text->text, &i))) + { + ft = NULL; + if (use_text) { + ft = swf_find_font(read, gr->fontID); + if (!ft->glyph_codes) { + use_text = 0; + swf_report(read, GF_BAD_PARAM, "Font glyphs are not defined, cannot reference extern font - Forcing glyph embedding"); + } + } + if (use_text) { + /*restore back the font height in pixels (it's currently in SWF glyph design units)*/ + swf_svg_print(read, "orig_x)); + swf_svg_print(read, "y=\"%g \" ", FIX2FLT(gr->orig_y)); + swf_svg_print(read, "font-size=\"%d\" ", (u32)(gr->fontSize * SWF_TWIP_SCALE)); + if (ft->fontName) + { + swf_svg_print(read, "font-family=\"%s\" ", ft->fontName); + } + if (ft->is_italic) + { + swf_svg_print(read, "font-style=\"italic\" "); + } + if (ft->is_bold) + { + swf_svg_print(read, "font-weight=\"bold\" "); + } + swf_svg_print(read, ">"); + /*convert to UTF-8*/ + { size_t _len; - u16 *str_w; - u16 *widestr; - char *str; - - str_w = (u16*)gf_malloc(sizeof(u16) * (gr->nbGlyphs+1)); - for (j=0; jnbGlyphs; j++) - { - str_w[j] = ft->glyph_codes[gr->indexes[j]]; - } - str_w[j] = 0; - str = (char*)gf_malloc(sizeof(char) * (gr->nbGlyphs+2)); - widestr = str_w; - _len = gf_utf8_wcstombs(str, sizeof(u8) * (gr->nbGlyphs+1), (const unsigned short **) &widestr); - if (_len != (size_t) -1) { - str[(u32) _len] = 0; - swf_svg_print(read, "%s", str); - } - } - swf_svg_print(read, "\n"); - } - else - { - /*convert glyphs*/ - Fixed dx; - swf_svg_print(read, "\n", FIX2FLT(gr->orig_x), FIX2FLT(gr->orig_y)); - - dx = 0; - for (j=0; jnbGlyphs; j++) - { - swf_svg_print(read, "\n", gr->fontID, gr->indexes[j], FIX2FLT(gf_divfix(dx, FLT2FIX(gr->fontSize * SWF_TEXT_SCALE)))); - dx += gr->dx[j]; - } - swf_svg_print(read, "\n"); - } - } + u16 *str_w; + u16 *widestr; + char *str; + + str_w = (u16*)gf_malloc(sizeof(u16) * (gr->nbGlyphs+1)); + for (j=0; jnbGlyphs; j++) + { + str_w[j] = ft->glyph_codes[gr->indexes[j]]; + } + str_w[j] = 0; + str = (char*)gf_malloc(sizeof(char) * (gr->nbGlyphs+2)); + widestr = str_w; + _len = gf_utf8_wcstombs(str, sizeof(u8) * (gr->nbGlyphs+1), (const unsigned short **) &widestr); + if (_len != (size_t) -1) { + str[(u32) _len] = 0; + swf_svg_print(read, "%s", str); + } + } + swf_svg_print(read, "\n"); + } + else + { + /*convert glyphs*/ + Fixed dx; + swf_svg_print(read, "\n", FIX2FLT(gr->orig_x), FIX2FLT(gr->orig_y)); + + dx = 0; + for (j=0; jnbGlyphs; j++) + { + swf_svg_print(read, "\n", gr->fontID, gr->indexes[j], FIX2FLT(gf_divfix(dx, FLT2FIX(gr->fontSize * SWF_TEXT_SCALE)))); + dx += gr->dx[j]; + } + swf_svg_print(read, "\n"); + } + } read->empty_frame = GF_FALSE; - swf_svg_print(read, "\n"); - swf_svg_print(read, "\n"); - return GF_OK; + swf_svg_print(read, "\n"); + swf_svg_print(read, "\n"); + return GF_OK; } static GF_Err swf_svg_define_edit_text(SWFReader *read, SWFEditText *text) { - return GF_OK; + return GF_OK; } #if 0 @@ -349,98 +349,98 @@ static void swf_svg_end_of_clip(SWFReader *read) static Bool swf_svg_allocate_depth(SWFReader *read, u32 depth) { - return GF_FALSE; + return GF_FALSE; } static GF_Err swf_svg_define_sprite(SWFReader *read, u32 nb_frames) { - return GF_OK; + return GF_OK; } static GF_Err swf_svg_setup_sound(SWFReader *read, SWFSound *snd, Bool soundstream_first_block) { - return GF_OK; + return GF_OK; } static GF_Err swf_svg_setup_image(SWFReader *read, u32 ID, char *fileName) { - swf_svg_print(read, "\n"); - swf_svg_print(read, "", ID, fileName); - swf_svg_print(read, "\n"); - return GF_OK; + swf_svg_print(read, "\n"); + swf_svg_print(read, "", ID, fileName); + swf_svg_print(read, "\n"); + return GF_OK; } static GF_Err swf_svg_set_backcol(SWFReader *read, u32 xrgb) { - //rgb.red = INT2FIX((xrgb>>16) & 0xFF) / 255; - //rgb.green = INT2FIX((xrgb>>8) & 0xFF) / 255; - //rgb.blue = INT2FIX((xrgb) & 0xFF) / 255; - return GF_OK; + //rgb.red = INT2FIX((xrgb>>16) & 0xFF) / 255; + //rgb.green = INT2FIX((xrgb>>8) & 0xFF) / 255; + //rgb.blue = INT2FIX((xrgb) & 0xFF) / 255; + return GF_OK; } static GF_Err swf_svg_start_sound(SWFReader *read, SWFSound *snd, Bool stop) { - return GF_OK; + return GF_OK; } static GF_Err swf_svg_place_obj(SWFReader *read, u32 depth, u32 ID, u32 prev_id, u32 type, GF_Matrix2D *mat, GF_ColorMatrix *cmat, GF_Matrix2D *prev_mat, GF_ColorMatrix *prev_cmat) { read->empty_frame = GF_FALSE; - return GF_OK; + return GF_OK; } static GF_Err swf_svg_remove_obj(SWFReader *read, u32 depth, u32 ID) { read->empty_frame = GF_FALSE; - return GF_OK; + return GF_OK; } static GF_Err swf_svg_show_frame(SWFReader *read) { - u32 i; - u32 len; - GF_List *sdl = gf_list_new(); // sorted display list - - /* sorting the display list because SVG/CSS z-index is not well supported */ - while (gf_list_count(read->display_list)) - { - Bool inserted = GF_FALSE; - DispShape *s; - - s = (DispShape *)gf_list_get(read->display_list, 0); - gf_list_rem(read->display_list, 0); - - for (i = 0; i < gf_list_count(sdl); i++) - { - DispShape *s2 = (DispShape *)gf_list_get(sdl, i); - if (s->depth < s2->depth) - { - gf_list_insert(sdl, s, i); - inserted = GF_TRUE; - break; - } - } - if (!inserted) - { - gf_list_add(sdl, s); - } - } - gf_list_del(read->display_list); - read->display_list = sdl; - - /* dumping the display list */ - len = gf_list_count(read->display_list); - for (i=0; idisplay_list, i); - swf_svg_print(read, "char_id); - //swf_svg_print(read, "z-index=\"%d\" ", s->depth); - swf_svg_print_matrix(read, &s->mat); - swf_svg_print(read, "/>\n"); + u32 i; + u32 len; + GF_List *sdl = gf_list_new(); // sorted display list + + /* sorting the display list because SVG/CSS z-index is not well supported */ + while (gf_list_count(read->display_list)) + { + Bool inserted = GF_FALSE; + DispShape *s; + + s = (DispShape *)gf_list_get(read->display_list, 0); + gf_list_rem(read->display_list, 0); + + for (i = 0; i < gf_list_count(sdl); i++) + { + DispShape *s2 = (DispShape *)gf_list_get(sdl, i); + if (s->depth < s2->depth) + { + gf_list_insert(sdl, s, i); + inserted = GF_TRUE; + break; + } + } + if (!inserted) + { + gf_list_add(sdl, s); + } + } + gf_list_del(read->display_list); + read->display_list = sdl; + + /* dumping the display list */ + len = gf_list_count(read->display_list); + for (i=0; idisplay_list, i); + swf_svg_print(read, "char_id); + //swf_svg_print(read, "z-index=\"%d\" ", s->depth); + swf_svg_print_matrix(read, &s->mat); + swf_svg_print(read, "/>\n"); read->empty_frame = GF_FALSE; - } + } if (!read->empty_frame) { read->print_frame_header = GF_TRUE; read->frame_header_offset = 0; @@ -463,7 +463,7 @@ static GF_Err swf_svg_show_frame(SWFReader *read) read->svg_data_size = 0; read->empty_frame = GF_TRUE; - return GF_OK; + return GF_OK; } static void swf_svg_finalize(SWFReader *read) @@ -472,34 +472,34 @@ static void swf_svg_finalize(SWFReader *read) static GF_Err swf_svg_define_button(SWFReader *read, SWF_Button *btn) { - return GF_OK; + return GF_OK; } Bool swf_svg_action(SWFReader *read, SWFAction *act) { - return GF_TRUE; + return GF_TRUE; } GF_Err swf_to_svg_init(SWFReader *read, u32 swf_flags, Float swf_flatten_angle) { if (!read->user) return GF_BAD_PARAM; - /*init callbacks*/ - read->show_frame = swf_svg_show_frame; - read->allocate_depth = swf_svg_allocate_depth; - read->place_obj = swf_svg_place_obj; - read->remove_obj = swf_svg_remove_obj; - read->define_shape = swf_svg_define_shape; - read->define_sprite = swf_svg_define_sprite; - read->set_backcol = swf_svg_set_backcol; - read->define_button = swf_svg_define_button; - read->define_text = swf_svg_define_text; - read->define_edit_text = swf_svg_define_edit_text; - read->setup_sound = swf_svg_setup_sound; - read->start_sound = swf_svg_start_sound; - read->setup_image = swf_svg_setup_image; - read->action = swf_svg_action; - read->finalize = swf_svg_finalize; + /*init callbacks*/ + read->show_frame = swf_svg_show_frame; + read->allocate_depth = swf_svg_allocate_depth; + read->place_obj = swf_svg_place_obj; + read->remove_obj = swf_svg_remove_obj; + read->define_shape = swf_svg_define_shape; + read->define_sprite = swf_svg_define_sprite; + read->set_backcol = swf_svg_set_backcol; + read->define_button = swf_svg_define_button; + read->define_text = swf_svg_define_text; + read->define_edit_text = swf_svg_define_edit_text; + read->setup_sound = swf_svg_setup_sound; + read->start_sound = swf_svg_start_sound; + read->setup_image = swf_svg_setup_image; + read->action = swf_svg_action; + read->finalize = swf_svg_finalize; read->flags = swf_flags; read->flat_limit = FLT2FIX(swf_flatten_angle); @@ -526,10 +526,4 @@ GF_Err swf_to_svg_init(SWFReader *read, u32 swf_flags, Float swf_flatten_angle) #endif /*GPAC_DISABLE_SWF_IMPORT*/ -#else -GF_Err swf_to_svg_init(SWFReader *read, u32 swf_flags, Float swf_flatten_angle) -{ - return GF_NOT_SUPPORTED; -} - #endif /*GPAC_DISABLE_VRML*/ diff --git a/src/scene_manager/text_to_bifs.c b/src/scene_manager/text_to_bifs.c index b1796d0..42c80bb 100644 --- a/src/scene_manager/text_to_bifs.c +++ b/src/scene_manager/text_to_bifs.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,7 +47,7 @@ enum if (strchr(__sep, __str[_len])) __str[_len] = 0; \ else break; \ } \ - + static GF_Err gf_text_guess_format(char *filename, u32 *fmt) { @@ -72,7 +72,7 @@ static GF_Err gf_text_guess_format(char *filename, u32 *fmt) if (!strnicmp(ext, ".ttxt", 5)) *fmt = GF_TEXT_IMPORT_TTXT; ext = strstr(szLine, "?>"); if (ext) ext += 2; - if (!ext[0]){ + if (!ext[0]) { if (!fgets(szLine, 2048, test)) szLine[0] = '\0'; } @@ -170,55 +170,55 @@ static GF_Err gf_text_import_srt_bifs(GF_SceneManager *ctx, GF_ESD *src, GF_MuxI if (sOK) REM_TRAIL_MARKS(szLine, "\r\n\t ") - if (!sOK || !strlen(szLine)) { - state = 0; - if (au) { - /*if italic or underscore do it*/ - if (font && (italic || underlined || bold)) { - com = gf_sg_command_new(ctx->scene_graph, GF_SG_FIELD_REPLACE); - com->node = font; - gf_node_register(font, NULL); - inf = gf_sg_command_field_new(com); - inf->fieldIndex = style.fieldIndex; - inf->fieldType = style.fieldType; - inf->field_ptr = gf_sg_vrml_field_pointer_new(style.fieldType); - sfstr = (SFString *)inf->field_ptr; - if (bold && italic && underlined) sfstr->buffer = gf_strdup("BOLDITALIC UNDERLINED"); - else if (italic && underlined) sfstr->buffer = gf_strdup("ITALIC UNDERLINED"); - else if (bold && underlined) sfstr->buffer = gf_strdup("BOLD UNDERLINED"); - else if (underlined) sfstr->buffer = gf_strdup("UNDERLINED"); - else if (bold && italic) sfstr->buffer = gf_strdup("BOLDITALIC"); - else if (bold) sfstr->buffer = gf_strdup("BOLD"); - else sfstr->buffer = gf_strdup("ITALIC"); - gf_list_add(au->commands, com); - } + if (!sOK || !strlen(szLine)) { + state = 0; + if (au) { + /*if italic or underscore do it*/ + if (font && (italic || underlined || bold)) { + com = gf_sg_command_new(ctx->scene_graph, GF_SG_FIELD_REPLACE); + com->node = font; + gf_node_register(font, NULL); + inf = gf_sg_command_field_new(com); + inf->fieldIndex = style.fieldIndex; + inf->fieldType = style.fieldType; + inf->field_ptr = gf_sg_vrml_field_pointer_new(style.fieldType); + sfstr = (SFString *)inf->field_ptr; + if (bold && italic && underlined) sfstr->buffer = gf_strdup("BOLDITALIC UNDERLINED"); + else if (italic && underlined) sfstr->buffer = gf_strdup("ITALIC UNDERLINED"); + else if (bold && underlined) sfstr->buffer = gf_strdup("BOLD UNDERLINED"); + else if (underlined) sfstr->buffer = gf_strdup("UNDERLINED"); + else if (bold && italic) sfstr->buffer = gf_strdup("BOLDITALIC"); + else if (bold) sfstr->buffer = gf_strdup("BOLD"); + else sfstr->buffer = gf_strdup("ITALIC"); + gf_list_add(au->commands, com); + } - au = gf_sm_stream_au_new(srt, end, 0, 1); - com = gf_sg_command_new(ctx->scene_graph, GF_SG_FIELD_REPLACE); - com->node = text; - gf_node_register(text, NULL); - inf = gf_sg_command_field_new(com); - inf->fieldIndex = string.fieldIndex; - inf->fieldType = string.fieldType; - inf->field_ptr = gf_sg_vrml_field_pointer_new(string.fieldType); - gf_list_add(au->commands, com); - /*reset font styles so that all AUs are true random access*/ - if (font) { + au = gf_sm_stream_au_new(srt, end, 0, 1); com = gf_sg_command_new(ctx->scene_graph, GF_SG_FIELD_REPLACE); - com->node = font; - gf_node_register(font, NULL); + com->node = text; + gf_node_register(text, NULL); inf = gf_sg_command_field_new(com); - inf->fieldIndex = style.fieldIndex; - inf->fieldType = style.fieldType; - inf->field_ptr = gf_sg_vrml_field_pointer_new(style.fieldType); + inf->fieldIndex = string.fieldIndex; + inf->fieldType = string.fieldType; + inf->field_ptr = gf_sg_vrml_field_pointer_new(string.fieldType); gf_list_add(au->commands, com); + /*reset font styles so that all AUs are true random access*/ + if (font) { + com = gf_sg_command_new(ctx->scene_graph, GF_SG_FIELD_REPLACE); + com->node = font; + gf_node_register(font, NULL); + inf = gf_sg_command_field_new(com); + inf->fieldIndex = style.fieldIndex; + inf->fieldType = style.fieldType; + inf->field_ptr = gf_sg_vrml_field_pointer_new(style.fieldType); + gf_list_add(au->commands, com); + } + au = NULL; } - au = NULL; + inf = NULL; + if (!sOK) break; + continue; } - inf = NULL; - if (!sOK) break; - continue; - } switch (state) { case 0: @@ -262,7 +262,7 @@ static GF_Err gf_text_import_srt_bifs(GF_SceneManager *ctx, GF_ESD *src, GF_MuxI au = gf_sm_stream_au_new(srt, start, 0, 1); com = NULL; - state = 2; + state = 2; italic = underlined = bold = 0; break; @@ -311,7 +311,7 @@ static GF_Err gf_text_import_srt_bifs(GF_SceneManager *ctx, GF_ESD *src, GF_MuxI szText[len] = 0xc0 | ( (ptr[i] >> 6) & 0x3 ); len++; ptr[i] &= 0xbf; - } + } /*we only handle UTF8 chars on 2 bytes (eg first byte is 0b110xxxxx)*/ else if ((ptr[i] & 0xe0) == 0xc0) { szText[len] = ptr[i]; @@ -424,7 +424,7 @@ static GF_Err gf_text_import_sub_bifs(GF_SceneManager *ctx, GF_ESD *src, GF_MuxI REM_TRAIL_MARKS(szLine, "\r\n\t ") line++; - len = (u32) strlen(szLine); + len = (u32) strlen(szLine); if (!len) continue; i=0; @@ -433,7 +433,10 @@ static GF_Err gf_text_import_sub_bifs(GF_SceneManager *ctx, GF_ESD *src, GF_MuxI e = GF_NON_COMPLIANT_BITSTREAM; break; } - while (szLine[i+1] && szLine[i+1]!='}') { szTime[i] = szLine[i+1]; i++; } + while (szLine[i+1] && szLine[i+1]!='}') { + szTime[i] = szLine[i+1]; + i++; + } szTime[i] = 0; start = atoi(szTime); if (startnode->sgprivate->scenegraph==sg) { gf_node_unregister(list->node, node); - + if (prev) prev->next = list->next; else *(GF_ChildNodeItem **) info.far_ptr = list->next; cur = list; @@ -251,7 +251,7 @@ void SG_GraphRemoved(GF_Node *node, GF_SceneGraph *sg) while (list) { if (list->node->sgprivate->scenegraph==sg) { gf_node_unregister(list->node, node); - + if (prev) prev->next = list->next; else f->node_list = list->next; cur = list; @@ -381,11 +381,11 @@ restart: while (reg_node) { Bool ignore = 0; GF_Node *node = reg_node->node; - if (!node + if (!node #ifndef GPAC_DISABLE_VRML - || (node==sg->global_qp) + || (node==sg->global_qp) #endif - ) { + ) { reg_node = reg_node->next; continue; } @@ -393,41 +393,41 @@ restart: /*first replace all instances in parents by NULL WITHOUT UNREGISTERING (to avoid destroying the node). This will take care of nodes referencing themselves*/ { - GF_ParentList *nlist = node->sgprivate->parents; + GF_ParentList *nlist = node->sgprivate->parents; #ifndef GPAC_DISABLE_SVG - type = (node->sgprivate->tag>GF_NODE_RANGE_LAST_VRML) ? 1 : 0; + type = (node->sgprivate->tag>GF_NODE_RANGE_LAST_VRML) ? 1 : 0; #endif - while (nlist) { - GF_ParentList *next = nlist->next; + while (nlist) { + GF_ParentList *next = nlist->next; #if 0 - /*parent is a DEF'ed node, try to clean-up properly?*/ - if ((nlist->node!=node) && SG_SearchForNode(sg, nlist->node) != NULL) { - ignore = 1; - break; - } + /*parent is a DEF'ed node, try to clean-up properly?*/ + if ((nlist->node!=node) && SG_SearchForNode(sg, nlist->node) != NULL) { + ignore = 1; + break; + } #endif #ifndef GPAC_DISABLE_SVG - if (type) { - ReplaceIRINode(nlist->node, node, NULL); - } else + if (type) { + ReplaceIRINode(nlist->node, node, NULL); + } else #endif - ReplaceDEFNode(nlist->node, reg_node->node, NULL, 0); + ReplaceDEFNode(nlist->node, reg_node->node, NULL, 0); - /*direct cyclic reference to ourselves, make sure we update the parentList to the next entry before freeing it - since the next parent node could be reg_node again (reg_node->reg_node)*/ - if (nlist->node==node) { - node->sgprivate->parents = next; + /*direct cyclic reference to ourselves, make sure we update the parentList to the next entry before freeing it + since the next parent node could be reg_node again (reg_node->reg_node)*/ + if (nlist->node==node) { + node->sgprivate->parents = next; + } + gf_free(nlist); + nlist = next; + } + if (ignore) { + node->sgprivate->parents = nlist; + continue; } - gf_free(nlist); - nlist = next; - } - if (ignore) { - node->sgprivate->parents = nlist; - continue; - } - node->sgprivate->parents = NULL; + node->sgprivate->parents = NULL; } //sg->node_registry[i-1] = NULL; count = get_num_id_nodes(sg); @@ -587,7 +587,7 @@ void remove_node_id(GF_SceneGraph *sg, GF_Node *node) NodeIDedItem *reg_node = sg->id_node; if (reg_node && (reg_node->node==node)) { sg->id_node = reg_node->next; - if (sg->id_node_last==reg_node) + if (sg->id_node_last==reg_node) sg->id_node_last = reg_node->next; if (reg_node->NodeName) gf_free(reg_node->NodeName); gf_free(reg_node); @@ -667,7 +667,7 @@ GF_Err gf_node_unregister(GF_Node *pNode, GF_Node *parentNode) /*unregister the instance*/ assert(pNode->sgprivate->num_instances); pNode->sgprivate->num_instances -= 1; - + /*this is just an instance removed*/ if (pNode->sgprivate->num_instances) { #ifdef GPAC_HAS_SPIDERMONKEY @@ -678,7 +678,7 @@ GF_Err gf_node_unregister(GF_Node *pNode, GF_Node *parentNode) #endif return GF_OK; } - + assert(pNode->sgprivate->parents==NULL); if (pSG) { @@ -800,7 +800,7 @@ static void ReplaceDEFNode(GF_Node *FromNode, GF_Node *node, GF_Node *newNode, B goto exit; } break; - /*not a node, continue*/ + /*not a node, continue*/ default: continue; } @@ -821,7 +821,7 @@ exit: break; } #endif - + gf_node_changed(FromNode, &field); } @@ -840,7 +840,7 @@ static void Replace_IRI(GF_SceneGraph *sg, GF_Node *old_node, GF_Node *newNode) i--; count--; } - } + } } } @@ -898,7 +898,7 @@ GF_Err gf_node_replace(GF_Node *node, GF_Node *new_node, Bool updateOrderedGroup #ifndef GPAC_DISABLE_VRML replace_proto = 0; if (node->sgprivate->scenegraph->pOwningProto - && (gf_list_find(node->sgprivate->scenegraph->pOwningProto->node_code, node)>=0)) { + && (gf_list_find(node->sgprivate->scenegraph->pOwningProto->node_code, node)>=0)) { replace_proto = 1; } #endif @@ -977,7 +977,7 @@ static GFINLINE void insert_node_def(GF_SceneGraph *sg, GF_Node *def, u32 ID, co GF_EXPORT GF_Err gf_node_set_id(GF_Node *p, u32 ID, const char *name) { - GF_SceneGraph *pSG; + GF_SceneGraph *pSG; if (!ID || !p || !p->sgprivate->scenegraph) return GF_BAD_PARAM; pSG = p->sgprivate->scenegraph; @@ -990,7 +990,7 @@ GF_Err gf_node_set_id(GF_Node *p, u32 ID, const char *name) if (!(p->sgprivate->flags & GF_NODE_IS_DEF) ) { p->sgprivate->flags |= GF_NODE_IS_DEF; insert_node_def(pSG, p, ID, name); - } + } /*reassigning ID, remove node def*/ else { char *_name = gf_strdup(name); @@ -1004,7 +1004,7 @@ GF_Err gf_node_set_id(GF_Node *p, u32 ID, const char *name) GF_EXPORT GF_Err gf_node_remove_id(GF_Node *p) { - GF_SceneGraph *pSG; + GF_SceneGraph *pSG; if (!p) return GF_BAD_PARAM; pSG = p->sgprivate->scenegraph; @@ -1018,7 +1018,7 @@ GF_Err gf_node_remove_id(GF_Node *p) remove_node_id(pSG, p); p->sgprivate->flags &= ~GF_NODE_IS_DEF; return GF_OK; - } + } return GF_BAD_PARAM; } @@ -1030,7 +1030,7 @@ void gf_node_traverse(GF_Node *node, void *renderStack) if (node->sgprivate->flags & GF_NODE_IS_DEACTIVATED) return; - if (node->sgprivate->UserCallback) { + if (node->sgprivate->UserCallback) { #ifdef GF_CYCLIC_TRAVERSE_ON if (node->sgprivate->flags & GF_NODE_IN_TRAVERSE) return; node->sgprivate->flags |= GF_NODE_IN_TRAVERSE; @@ -1168,7 +1168,7 @@ GF_Node *gf_sg_find_node_by_name(GF_SceneGraph *sg, char *name) GF_EXPORT -u32 gf_sg_get_next_available_node_id(GF_SceneGraph *sg) +u32 gf_sg_get_next_available_node_id(GF_SceneGraph *sg) { u32 ID; NodeIDedItem *reg_node; @@ -1218,7 +1218,7 @@ GF_EXPORT u32 gf_node_get_id(GF_Node*p) { NodeIDedItem *reg_node; - GF_SceneGraph *sg; + GF_SceneGraph *sg; assert(p); if (!(p->sgprivate->flags & GF_NODE_IS_DEF)) return 0; sg = p->sgprivate->scenegraph; @@ -1238,7 +1238,7 @@ u32 gf_node_get_id(GF_Node*p) GF_EXPORT const char *gf_node_get_name(GF_Node*p) { - GF_SceneGraph *sg; + GF_SceneGraph *sg; NodeIDedItem *reg_node; if (!p || !(p->sgprivate->flags & GF_NODE_IS_DEF)) return NULL; @@ -1259,7 +1259,7 @@ const char *gf_node_get_name(GF_Node*p) GF_EXPORT const char *gf_node_get_name_and_id(GF_Node*p, u32 *id) { - GF_SceneGraph *sg; + GF_SceneGraph *sg; NodeIDedItem *reg_node; assert(p); if (!(p->sgprivate->flags & GF_NODE_IS_DEF)) { @@ -1328,11 +1328,11 @@ GF_Err gf_node_list_insert_child(GF_ChildNodeItem **list, GF_Node *n, u32 pos) { GF_ChildNodeItem *child, *cur, *prev; u32 cur_pos = 0; - + assert(pos != (u32) -1); child = *list; - + cur = (GF_ChildNodeItem*) gf_malloc(sizeof(GF_ChildNodeItem)); if (!cur) return GF_OUT_OF_MEM; cur->node = n; @@ -1386,7 +1386,7 @@ GF_Err gf_node_list_add_child(GF_ChildNodeItem **list, GF_Node *n) GF_ChildNodeItem *child, *cur; child = *list; - + cur = (GF_ChildNodeItem*) gf_malloc(sizeof(GF_ChildNodeItem)); if (!cur) return GF_OUT_OF_MEM; cur->node = n; @@ -1407,7 +1407,7 @@ GF_Err gf_node_list_add_child_last(GF_ChildNodeItem **list, GF_Node *n, GF_Child GF_ChildNodeItem *child, *cur; child = *list; - + cur = (GF_ChildNodeItem*) gf_malloc(sizeof(GF_ChildNodeItem)); if (!cur) return GF_OUT_OF_MEM; cur->node = n; @@ -1424,7 +1424,7 @@ GF_Err gf_node_list_add_child_last(GF_ChildNodeItem **list, GF_Node *n, GF_Child } } else { *list = cur; - if (last_child) + if (last_child) *last_child = *list; } return GF_OK; @@ -1442,7 +1442,7 @@ Bool gf_node_list_del_child(GF_ChildNodeItem **list, GF_Node *n) gf_free(child); return 1; } - + while (child->next) { if (child->next->node!=n) { child = child->next; @@ -1471,7 +1471,7 @@ GF_Node *gf_node_list_del_child_idx(GF_ChildNodeItem **list, u32 pos) gf_free(child); return ret; } - + while (child->next) { if (cur_pos+1 != pos) { child = child->next; @@ -1510,7 +1510,7 @@ void gf_node_free(GF_Node *node) if (!node) return; if (node->sgprivate->UserCallback) node->sgprivate->UserCallback(node, NULL, 1); - + if (node->sgprivate->scenegraph && node->sgprivate->scenegraph->NodeCallback) node->sgprivate->scenegraph->NodeCallback(node->sgprivate->scenegraph->userpriv, GF_SG_CALLBACK_NODE_DESTROY, node, NULL); @@ -1547,7 +1547,10 @@ u32 gf_node_get_parent_count(GF_Node *node) { u32 count = 0; GF_ParentList *nlist = node->sgprivate->parents; - while (nlist) { count++; nlist = nlist->next; } + while (nlist) { + count++; + nlist = nlist->next; + } return count; } @@ -1559,11 +1562,14 @@ GF_Node *gf_node_get_parent(GF_Node *node, u32 idx) /*break cyclic graphs*/ if (node->sgprivate->scenegraph->RootNode==node) return NULL; #ifndef GPAC_DISABLE_VRML - if (node->sgprivate->scenegraph->pOwningProto && node->sgprivate->scenegraph->pOwningProto->RenderingNode==node) + if (node->sgprivate->scenegraph->pOwningProto && node->sgprivate->scenegraph->pOwningProto->RenderingNode==node) return NULL; #endif if (!nlist) return NULL; - while (idx) { nlist = nlist->next; idx--;} + while (idx) { + nlist = nlist->next; + idx--; + } return nlist ? nlist->node : NULL; } @@ -1572,7 +1578,7 @@ static void dirty_children(GF_Node *node) u32 i, count; GF_FieldInfo info; if (!node) return; - + node->sgprivate->flags &= GF_NODE_INTERNAL_FLAGS; if (node->sgprivate->tag>=GF_NODE_RANGE_LAST_VRML) { GF_ChildNodeItem *child = ((GF_ParentNode*)node)->children; @@ -1601,7 +1607,7 @@ static void dirty_parents(GF_Node *node) GF_ParentList *nlist; #if defined GPAC_ANDROID if ( !node || !node->sgprivate ) - return; + return; #else if (!node) return; #endif @@ -1647,7 +1653,7 @@ GF_EXPORT void gf_node_dirty_set(GF_Node *node, u32 flags, Bool and_dirty_parents) { if (!node) return; - + if (flags) node->sgprivate->flags |= (flags & (~GF_NODE_INTERNAL_FLAGS) ); else node->sgprivate->flags |= GF_SG_NODE_DIRTY; @@ -1684,8 +1690,10 @@ void gf_node_dirty_reset(GF_Node *node, Bool reset_children) node->sgprivate->flags &= GF_NODE_INTERNAL_FLAGS; if (reset_children) { dirty_children(node); +#ifndef GPAC_DISABLE_VRML } else if (node->sgprivate->tag==TAG_MPEG4_Appearance) { gf_node_dirty_reset( ((M_Appearance*)node)->material, 1); +#endif } } } @@ -1766,8 +1774,8 @@ void gf_node_changed(GF_Node *node, GF_FieldInfo *field) #ifndef GPAC_DISABLE_SVG /* we should avoid dispatching a DOMSubtreeModified event on insertion of time values in begin/end fields because this retriggers begin/end events and reinsertion */ - if ((field == NULL || ((field->fieldIndex != TAG_SVG_ATT_begin) && (field->fieldIndex != TAG_SVG_ATT_end))) && - node->sgprivate->tag >= GF_NODE_RANGE_FIRST_SVG && node->sgprivate->tag <= GF_NODE_RANGE_LAST_SVG) { + if ((field == NULL || ((field->fieldIndex != TAG_SVG_ATT_begin) && (field->fieldIndex != TAG_SVG_ATT_end))) && + node->sgprivate->tag >= GF_NODE_RANGE_FIRST_SVG && node->sgprivate->tag <= GF_NODE_RANGE_LAST_SVG) { GF_DOM_Event evt; evt.type = GF_EVENT_TREE_MODIFIED; evt.bubbles = 0; @@ -1785,7 +1793,7 @@ void gf_node_del(GF_Node *node) if (t->textContent) gf_free(t->textContent); gf_sg_parent_reset(node); gf_node_free(node); - } + } else if (node->sgprivate->tag==TAG_DOMUpdates) { u32 i, count; GF_DOMUpdates *up = (GF_DOMUpdates *)node; @@ -1798,7 +1806,7 @@ void gf_node_del(GF_Node *node) gf_list_del(up->updates); gf_sg_parent_reset(node); gf_node_free(node); - } + } else if (node->sgprivate->tag == TAG_DOMFullNode) { GF_DOMFullNode *n = (GF_DOMFullNode *)node; #ifndef GPAC_DISABLE_SVG @@ -1871,7 +1879,7 @@ const char *gf_node_get_class_name(GF_Node *node) GF_EXPORT u32 gf_sg_node_get_tag_by_class_name(const char *name, u32 ns) { - u32 tag; + u32 tag = TAG_UndefinedNode; /* TODO: handle name spaces */ #ifndef GPAC_DISABLE_VRML @@ -1879,7 +1887,7 @@ u32 gf_sg_node_get_tag_by_class_name(const char *name, u32 ns) if (tag) return tag; #ifndef GPAC_DISABLE_X3D - tag = gf_node_x3d_type_by_class_name(name); + tag = gf_node_x3d_type_by_class_name(name); if (tag) return tag; #endif @@ -1890,7 +1898,7 @@ u32 gf_sg_node_get_tag_by_class_name(const char *name, u32 ns) if (tag != TAG_UndefinedNode) return tag; #endif - return TAG_UndefinedNode; + return tag; } GF_EXPORT @@ -1954,11 +1962,11 @@ GF_Err gf_node_get_field(GF_Node *node, u32 FieldIndex, GF_FieldInfo *info) if (node->sgprivate->tag==TAG_UndefinedNode) return GF_BAD_PARAM; #ifndef GPAC_DISABLE_VRML else if (node->sgprivate->tag == TAG_ProtoNode) return gf_sg_proto_get_field(NULL, node, info); - else if ((node->sgprivate->tag == TAG_MPEG4_Script) + else if ((node->sgprivate->tag == TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (node->sgprivate->tag == TAG_X3D_Script) + || (node->sgprivate->tag == TAG_X3D_Script) #endif - ) + ) return gf_sg_script_get_field(node, info); else if (node->sgprivate->tag <= GF_NODE_RANGE_LAST_MPEG4) return gf_sg_mpeg4_node_get_field(node, info); #ifndef GPAC_DISABLE_X3D @@ -1983,7 +1991,7 @@ static GF_Err gf_node_get_field_by_name_enum(GF_Node *node, char *name, GF_Field assert(node); count = gf_node_get_field_count(node); memset(field, 0, sizeof(GF_FieldInfo)); - for (i=0; iname, name)) return GF_OK; } @@ -2000,11 +2008,11 @@ GF_Err gf_node_get_field_by_name(GF_Node *node, char *name, GF_FieldInfo *field) else if (node->sgprivate->tag == TAG_ProtoNode) { res = gf_sg_proto_get_field_index_by_name(NULL, node, name); } - else if ((node->sgprivate->tag == TAG_MPEG4_Script) + else if ((node->sgprivate->tag == TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (node->sgprivate->tag == TAG_X3D_Script) + || (node->sgprivate->tag == TAG_X3D_Script) #endif - ) { + ) { return gf_node_get_field_by_name_enum(node, name, field); } else if (node->sgprivate->tag <= GF_NODE_RANGE_LAST_MPEG4) res = gf_sg_mpeg4_node_get_field_index_by_name(node, name); @@ -2020,9 +2028,9 @@ GF_Err gf_node_get_field_by_name(GF_Node *node, char *name, GF_FieldInfo *field) return gf_node_get_field(node, (u32) res, field); } - + static char log_node_name[2+16+1]; -const char *gf_node_get_log_name(GF_Node *anim) +const char *gf_node_get_log_name(GF_Node *anim) { const char *name = gf_node_get_name(anim); if (name) return name; @@ -2042,7 +2050,7 @@ static GF_Err gf_node_deactivate_ex(GF_Node *node) GF_ChildNodeItem *item; if (node->sgprivate->tagsgprivate->flags & GF_NODE_IS_DEACTIVATED)) { - + node->sgprivate->flags |= GF_NODE_IS_DEACTIVATED; /*deactivate anmiations*/ @@ -2176,9 +2184,9 @@ GF_Err gf_sg_remove_namespace(GF_SceneGraph *sg, char *ns_name, char *q_name) for (i=0; ins, i); - if (!q_name && !ns->qname) + if (!q_name && !ns->qname) ok = 1; - else if (q_name && ns->qname && !strcmp(ns->qname, q_name) ) + else if (q_name && ns->qname && !strcmp(ns->qname, q_name) ) ok = 1; if (ok && ns->name && !strcmp(ns->name, ns_name)) { @@ -2199,10 +2207,10 @@ u32 gf_sg_get_namespace_code(GF_SceneGraph *sg, char *qname) count = sg->ns ? gf_list_count(sg->ns) : 0; for (i=0; ins, i); - if (!ns->qname && !qname) + if (!ns->qname && !qname) return ns->xmlns_id; - - if (ns->qname && qname && !strcmp(ns->qname, qname)) + + if (ns->qname && qname && !strcmp(ns->qname, qname)) return ns->xmlns_id; } if (qname) { @@ -2219,9 +2227,9 @@ u32 gf_sg_get_namespace_code_from_name(GF_SceneGraph *sg, char *name) count = sg->ns ? gf_list_count(sg->ns) : 0; for (i=0; ins, i); - if (ns->name && name && !strcmp(ns->name, name)) + if (ns->name && name && !strcmp(ns->name, name)) return ns->xmlns_id; - if (!ns->name && !name) + if (!ns->name && !name) return ns->xmlns_id; } return GF_XMLNS_UNDEFINED; @@ -2234,7 +2242,7 @@ const char *gf_sg_get_namespace_qname(GF_SceneGraph *sg, u32 xmlns_id) count = sg->ns ? gf_list_count(sg->ns) : 0; for (i=0; ins, i); - if (ns->xmlns_id == xmlns_id) + if (ns->xmlns_id == xmlns_id) return ns->qname; } if (xmlns_id==GF_XMLNS_XML) return "xml"; @@ -2249,7 +2257,7 @@ const char *gf_sg_get_namespace(GF_SceneGraph *sg, u32 xmlns_id) count = sg->ns ? gf_list_count(sg->ns) : 0; for (i=0; ins, i); - if (ns->xmlns_id == xmlns_id) + if (ns->xmlns_id == xmlns_id) return ns->name; } return NULL; @@ -2296,7 +2304,7 @@ GF_Err gf_node_replace_child(GF_Node *node, GF_ChildNodeItem **container, s32 po if (newNode) { child->node = newNode; #ifndef GPAC_DISABLE_VRML - if (tag==TAG_MPEG4_ColorTransform) + if (tag==TAG_MPEG4_ColorTransform) node->sgprivate->flags |= GF_SG_VRML_COLOR_DIRTY; #endif } else { @@ -2315,7 +2323,7 @@ Bool gf_node_parent_of(GF_Node *node, GF_Node *target) GF_FieldInfo info; if (!node) return 0; if (node==target) return 1; - + if (node->sgprivate->tag>=GF_NODE_RANGE_LAST_VRML) { GF_ChildNodeItem *child = ((GF_ParentNode*)node)->children; while (child) { diff --git a/src/scenegraph/commands.c b/src/scenegraph/commands.c index 2005268..5c75a6a 100644 --- a/src/scenegraph/commands.c +++ b/src/scenegraph/commands.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -131,11 +131,11 @@ static void SG_CheckFieldChange(GF_Node *node, GF_FieldInfo *field) /*and propagate eventIn if any*/ if (field->on_event_in) { field->on_event_in(node, NULL); - } + } #ifndef GPAC_DISABLE_VRML else if ((field->eventType==GF_SG_EVENT_IN) && (gf_node_get_tag(node) == TAG_MPEG4_Script)) { gf_sg_script_event_in(node, field); - } + } else { /*Notify eventOut in all cases to handle protos*/ gf_node_event_out(node, field->fieldIndex); @@ -164,13 +164,13 @@ GF_EXPORT GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_offset) { GF_Err e; - GF_CommandField *inf; #ifndef GPAC_DISABLE_VRML + GF_CommandField *inf; GF_FieldInfo field; void *slot_ptr; GF_Node *def; -#endif GF_Node *node; +#endif if (!com || !graph) return GF_BAD_PARAM; @@ -183,7 +183,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of /*unregister root*/ gf_node_unregister(graph->RootNode, NULL); /*remove all protos and routes*/ - while (gf_list_count(graph->routes_to_activate)) + while (gf_list_count(graph->routes_to_activate)) gf_list_rem(graph->routes_to_activate, 0); if (!com->aggregated) { @@ -287,13 +287,13 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of /*clone command list*/ sg = gf_node_get_graph(com->node); count = gf_list_count(cb_src->commandList); - for (i=0; icommandList, i); GF_Command *new_com = gf_sg_vrml_command_clone(sub_com, sg, 0); gf_list_add(cb_dst->commandList, new_com); } } - break; + break; default: /*this is a regular field, reset it and clone - we cannot switch pointers since the @@ -303,7 +303,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of } if (e) return e; gf_sg_vrml_field_copy(field.far_ptr, inf->field_ptr, field.fieldType); - + if ((field.fieldType==GF_SG_VRML_SFTIME) && !strstr(field.name, "media")) *(SFTime *)field.far_ptr = *(SFTime *)field.far_ptr + time_offset; break; @@ -470,16 +470,16 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of } return GF_OK; case GF_SG_PROTO_DELETE: - { - u32 i; - for (i=0; idel_proto_list_size; i++) { - /*note this will check for unregistered protos, but since IDs are unique we are sure we will - not destroy an unregistered one*/ - GF_Proto *proto = gf_sg_find_proto(graph, com->del_proto_list[i], NULL); - if (proto) gf_sg_proto_del(proto); - } + { + u32 i; + for (i=0; idel_proto_list_size; i++) { + /*note this will check for unregistered protos, but since IDs are unique we are sure we will + not destroy an unregistered one*/ + GF_Proto *proto = gf_sg_find_proto(graph, com->del_proto_list[i], NULL); + if (proto) gf_sg_proto_del(proto); } - return GF_OK; + } + return GF_OK; case GF_SG_PROTO_DELETE_ALL: /*destroy all proto*/ while (gf_list_count(graph->protos)) { @@ -492,7 +492,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of return GF_OK; case GF_SG_XREPLACE: { - s32 pos = -2; + s32 pos = -2; GF_Node *target = NULL; GF_ChildNodeItem *list, *cur, *prev; GF_FieldInfo value; @@ -509,7 +509,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of if (com->toNodeID) { GF_Node *idxNode = gf_sg_find_node(graph, com->toNodeID); if (!idxNode) return GF_SG_UNKNOWN_NODE; - + if (gf_node_get_field(idxNode, com->toFieldIndex, &idxField) != GF_OK) return GF_OK; pos = 0; switch (idxField.fieldType) { @@ -610,7 +610,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of } if (e) return e; gf_sg_vrml_field_clone(field.far_ptr, value.far_ptr, field.fieldType, graph); - + if ((field.fieldType==GF_SG_VRML_SFTIME) && !strstr(field.name, "media")) *(SFTime *)field.far_ptr = *(SFTime *)field.far_ptr + time_offset; break; @@ -618,7 +618,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of } SG_CheckFieldChange(target, &field); } - return GF_OK; + return GF_OK; /*only used by BIFS*/ case GF_SG_GLOBAL_QUANTIZER: return GF_OK; @@ -653,7 +653,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of inf = (GF_CommandField*)gf_list_get(com->command_fields, 0); if (!com->node || !inf) return GF_NON_COMPLIANT_BITSTREAM; if (inf->new_node) { - if (inf->pos<0) + if (inf->pos<0) gf_node_list_add_child(& ((SVG_Element *)com->node)->children, inf->new_node); else gf_node_list_insert_child(& ((SVG_Element *)com->node)->children, inf->new_node, inf->pos); @@ -724,7 +724,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of GF_Matrix2D *dest; gf_node_get_field_by_name(com->node, "transform", &a); dest = (GF_Matrix2D*)a.far_ptr; - + if (com->tag==GF_SG_LSR_REPLACE) { if (gf_mx2d_decompose(dest, &scale, &rotate, &translate)) { gf_mx2d_init(*dest); @@ -749,7 +749,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of char *str = *(SVG_String*)inf->field_ptr; if (com->tag == GF_SG_LSR_REPLACE) { - GF_DOMText *t = ((SVG_Element*)com->node)->children ? (GF_DOMText*) ((SVG_Element*)com->node)->children->node :NULL; + GF_DOMText *t = ((SVG_Element*)com->node)->children ? (GF_DOMText*) ((SVG_Element*)com->node)->children->node :NULL; if (t && (t->sgprivate->tag==TAG_DOMText)) { if (t->textContent) gf_free(t->textContent); t->textContent = NULL; @@ -761,10 +761,10 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of /*signal node modif*/ gf_node_changed(com->node, NULL); } - else if ((inf->fieldIndex==TAG_LSR_ATT_scale) - || (inf->fieldIndex==TAG_LSR_ATT_translation) - || (inf->fieldIndex==TAG_LSR_ATT_rotation) - ) { + else if ((inf->fieldIndex==TAG_LSR_ATT_scale) + || (inf->fieldIndex==TAG_LSR_ATT_translation) + || (inf->fieldIndex==TAG_LSR_ATT_rotation) + ) { SVG_Transform *mx; gf_node_get_attribute_by_tag(com->node, TAG_SVG_ATT_transform, 1, 0, &a); mx = a.far_ptr; @@ -814,7 +814,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of char *str = *(SVG_String*)inf->field_ptr; if (com->tag == GF_SG_LSR_REPLACE) { - GF_DOMText *t = ((SVG_Element*)com->node)->children ? (GF_DOMText*) ((SVG_Element*)com->node)->children->node :NULL; + GF_DOMText *t = ((SVG_Element*)com->node)->children ? (GF_DOMText*) ((SVG_Element*)com->node)->children->node :NULL; if (t && (t->sgprivate->tag==TAG_DOMText)) { if (t->textContent) gf_free(t->textContent); t->textContent = NULL; @@ -854,7 +854,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of evt.clientY = com->send_event_y; gf_dom_event_fire(com->node, &evt); } - break; + break; #endif default: @@ -905,7 +905,7 @@ GF_Command *gf_sg_vrml_command_clone(GF_Command *com, GF_SceneGraph *inGraph, Bo { u32 i, count; GF_Command *dest; - + /*FIXME - to do*/ if (gf_list_count(com->new_proto_list)) return NULL; dest = gf_sg_command_new(inGraph, com->tag); diff --git a/src/scenegraph/dom_events.c b/src/scenegraph/dom_events.c index 8d362f5..fb6a89f 100644 --- a/src/scenegraph/dom_events.c +++ b/src/scenegraph/dom_events.c @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -100,14 +100,14 @@ u32 gf_sg_get_dom_event_filter(GF_SceneGraph *sg) u32 gf_node_get_dom_event_filter(GF_Node *node) { - if (node) { - return node->sgprivate->scenegraph->dom_evt_filter; - } else { - return 0; - } + if (node) { + return node->sgprivate->scenegraph->dom_evt_filter; + } else { + return 0; + } } -/* Associate a listener node and a event target node +/* Associate a listener node and a event target node - adds the listener node in the list of event listener nodes for the target node - sets the target node as the user of the listener */ @@ -140,8 +140,8 @@ GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener) if (!node || !listener) return GF_BAD_PARAM; if (listener->sgprivate->tag!=TAG_SVG_listener) return GF_BAD_PARAM; - - if (!node->sgprivate->interact) + + if (!node->sgprivate->interact) GF_SAFEALLOC(node->sgprivate->interact, struct _node_interactive_ext); if (!node->sgprivate->interact->dom_evt) { @@ -167,7 +167,7 @@ GF_Err gf_dom_listener_del(GF_Node *listener, GF_DOMEventTarget *target) return GF_OK; } -GF_Err gf_dom_event_remove_listener_from_parent(GF_DOMEventTarget *event_target, GF_Node *listener) +GF_Err gf_dom_event_remove_listener_from_parent(GF_DOMEventTarget *event_target, GF_Node *listener) { if (!event_target) return GF_BAD_PARAM; if (event_target->ptr_type == GF_DOM_EVENT_TARGET_NODE) { @@ -188,7 +188,7 @@ GF_Err gf_dom_event_remove_listener_from_parent(GF_DOMEventTarget *event_target, return GF_OK; } -void gf_dom_event_remove_all_listeners(GF_DOMEventTarget *event_target) +void gf_dom_event_remove_all_listeners(GF_DOMEventTarget *event_target) { while (gf_list_count(event_target->listeners)) { GF_Node *n = (GF_Node *)gf_list_get(event_target->listeners, 0); @@ -297,8 +297,8 @@ static void dom_event_process(GF_Node *listen, GF_DOM_Event *event, GF_Node *obs if ((iri->type==XMLRI_STRING) && iri->string && !strnicmp(iri->string, "javascript:", 11)) { #ifdef GPAC_HAS_SPIDERMONKEY - if (listen->sgprivate->scenegraph->svg_js) - listen->sgprivate->scenegraph->svg_js->handler_execute(listen, event, observer, iri->string + 11); + if (listen->sgprivate->scenegraph->svg_js) + listen->sgprivate->scenegraph->svg_js->handler_execute(listen, event, observer, iri->string + 11); #endif return; } @@ -310,7 +310,7 @@ static void dom_event_process(GF_Node *listen, GF_DOM_Event *event, GF_Node *obs return; } } - break; + break; default: return; } @@ -338,7 +338,7 @@ static void dom_event_process(GF_Node *listen, GF_DOM_Event *event, GF_Node *obs handler->handle_event(hdl_node, event, observer); #endif } - break; + break; case TAG_LSR_conditional: if ( ((SVG_Element*)hdl_node)->children) gf_node_traverse(((SVG_Element*)hdl_node)->children->node, NULL); @@ -350,7 +350,7 @@ static void dom_event_process(GF_Node *listen, GF_DOM_Event *event, GF_Node *obs act.type = GF_EVENT_ACTIVATE; gf_dom_event_fire((GF_Node *)hdl_node, &act); } - break; + break; default: return; } @@ -360,94 +360,94 @@ GF_EXPORT Bool gf_sg_fire_dom_event(GF_DOMEventTarget *et, GF_DOM_Event *event, GF_SceneGraph *sg, GF_Node *n) { if (et) { - if (et->ptr_type==GF_DOM_EVENT_TARGET_NODE || - et->ptr_type == GF_DOM_EVENT_TARGET_DOCUMENT || - et->ptr_type == GF_DOM_EVENT_TARGET_XHR || - et->ptr_type == GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE || - et->ptr_type == GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER || - et->ptr_type == GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST ) { - GF_Node *observer = NULL; - u32 i, count, post_count; - if (et->ptr_type==GF_DOM_EVENT_TARGET_NODE) { - observer = (GF_Node *)et->ptr; - } - count = gf_list_count(et->listeners); - for (i=0; ilisteners, i); - - switch (listen->sgprivate->tag) { - case TAG_SVG_listener: - { - SVGAllAttributes atts; - gf_svg_flatten_attributes((SVG_Element*)listen, &atts); - listened_event = atts.event; - if (!listened_event) continue; - - if (atts.propagate && (*atts.propagate==XMLEVENT_PROPAGATE_STOP)) - event->event_phase |= GF_DOM_EVENT_PHASE_CANCEL; - if (atts.defaultAction && (*atts.defaultAction==XMLEVENT_DEFAULTACTION_CANCEL)) - event->event_phase |= GF_DOM_EVENT_PHASE_PREVENT; - } - break; - default: - continue; - } - if (listened_event->type <= GF_EVENT_MOUSEMOVE) event->has_ui_events=1; - if (listened_event->type != event->type) continue; - if (listened_event->parameter && (listened_event->parameter != event->detail)) continue; - event->currentTarget = et; - event->consumed ++; - - /*load event cannot bubble and can only be called once (on load :) ), remove it - to release some resources*/ - if (event->type==GF_EVENT_LOAD) { - dom_event_process(listen, event, observer); - /*delete listener*/ - //gf_dom_listener_del(listen, et); - } else if (n) { - assert(n->sgprivate->num_instances); - /*protect node*/ - n->sgprivate->num_instances++; - /*exec event*/ - dom_event_process(listen, event, observer); - /*the event has destroyed ourselves, abort propagation - THIS IS NOT DOM compliant, the event should propagate on the original target+ancestors path*/ - if (n->sgprivate->num_instances==1) { - /*unprotect node event*/ - gf_node_unregister(n, NULL); - return GF_FALSE; - } - n->sgprivate->num_instances--; - } else { - dom_event_process(listen, event, observer); - } - /*canceled*/ - if (event->event_phase & GF_DOM_EVENT_PHASE_CANCEL_ALL) { - gf_dom_listener_process_add(sg); - return GF_FALSE; - } - - /*if listeners have been removed, update count*/ - post_count = gf_list_count(et->listeners); - if (post_count < count) { - s32 pos = gf_list_find(et->listeners, listen); - if (pos>=0) i = pos; - /*FIXME this is not going to work in all cases...*/ - else i--; - count = post_count; - } - } - /*propagation stopped*/ - if (event->event_phase & (GF_DOM_EVENT_PHASE_CANCEL|GF_DOM_EVENT_PHASE_CANCEL_ALL) ) { - gf_dom_listener_process_add(sg); - return GF_FALSE; - } + if (et->ptr_type==GF_DOM_EVENT_TARGET_NODE || + et->ptr_type == GF_DOM_EVENT_TARGET_DOCUMENT || + et->ptr_type == GF_DOM_EVENT_TARGET_XHR || + et->ptr_type == GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE || + et->ptr_type == GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER || + et->ptr_type == GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST ) { + GF_Node *observer = NULL; + u32 i, count, post_count; + if (et->ptr_type==GF_DOM_EVENT_TARGET_NODE) { + observer = (GF_Node *)et->ptr; + } + count = gf_list_count(et->listeners); + for (i=0; ilisteners, i); + + switch (listen->sgprivate->tag) { + case TAG_SVG_listener: + { + SVGAllAttributes atts; + gf_svg_flatten_attributes((SVG_Element*)listen, &atts); + listened_event = atts.event; + if (!listened_event) continue; + + if (atts.propagate && (*atts.propagate==XMLEVENT_PROPAGATE_STOP)) + event->event_phase |= GF_DOM_EVENT_PHASE_CANCEL; + if (atts.defaultAction && (*atts.defaultAction==XMLEVENT_DEFAULTACTION_CANCEL)) + event->event_phase |= GF_DOM_EVENT_PHASE_PREVENT; + } + break; + default: + continue; + } + if (listened_event->type <= GF_EVENT_MOUSEMOVE) event->has_ui_events=1; + if (listened_event->type != event->type) continue; + if (listened_event->parameter && (listened_event->parameter != event->detail)) continue; + event->currentTarget = et; + event->consumed ++; + + /*load event cannot bubble and can only be called once (on load :) ), remove it + to release some resources*/ + if (event->type==GF_EVENT_LOAD) { + dom_event_process(listen, event, observer); + /*delete listener*/ + //gf_dom_listener_del(listen, et); + } else if (n) { + assert(n->sgprivate->num_instances); + /*protect node*/ + n->sgprivate->num_instances++; + /*exec event*/ + dom_event_process(listen, event, observer); + /*the event has destroyed ourselves, abort propagation + THIS IS NOT DOM compliant, the event should propagate on the original target+ancestors path*/ + if (n->sgprivate->num_instances==1) { + /*unprotect node event*/ + gf_node_unregister(n, NULL); + return GF_FALSE; + } + n->sgprivate->num_instances--; + } else { + dom_event_process(listen, event, observer); + } + /*canceled*/ + if (event->event_phase & GF_DOM_EVENT_PHASE_CANCEL_ALL) { + gf_dom_listener_process_add(sg); + return GF_FALSE; + } + + /*if listeners have been removed, update count*/ + post_count = gf_list_count(et->listeners); + if (post_count < count) { + s32 pos = gf_list_find(et->listeners, listen); + if (pos>=0) i = pos; + /*FIXME this is not going to work in all cases...*/ + else i--; + count = post_count; + } + } + /*propagation stopped*/ + if (event->event_phase & (GF_DOM_EVENT_PHASE_CANCEL|GF_DOM_EVENT_PHASE_CANCEL_ALL) ) { + gf_dom_listener_process_add(sg); + return GF_FALSE; + } } - gf_dom_listener_process_add(sg); - /*if the current target is a node, we can bubble*/ - return n ? GF_TRUE : GF_FALSE; - } else { + gf_dom_listener_process_add(sg); + /*if the current target is a node, we can bubble*/ + return n ? GF_TRUE : GF_FALSE; + } else { /* if the node does not have a event target, probably a parent will have, so let's bubble */ return GF_TRUE; } @@ -458,13 +458,13 @@ static void gf_sg_dom_event_bubble(GF_Node *node, GF_DOM_Event *event, GF_List * GF_Node *parent; if (!node || node->sgprivate->scenegraph->abort_bubbling) return; - + /*get the node's parent*/ parent = gf_node_get_parent(node, 0); if (!parent) { - /*top of the graph, use Document*/ + /*top of the graph, use Document*/ if (node->sgprivate->scenegraph->RootNode==node) gf_sg_fire_dom_event(node->sgprivate->scenegraph->dom_evt, event, node->sgprivate->scenegraph, NULL); return; @@ -615,7 +615,7 @@ GF_DOMHandler *gf_dom_listener_build_ex(GF_Node *node, u32 event_type, u32 event gf_node_register((GF_Node *)handler, (GF_Node *) listener); gf_node_list_add_child_last(& ((GF_ParentNode *)listener)->children, (GF_Node*)handler, &last); } - + gf_node_get_attribute_by_tag((GF_Node*)listener, TAG_XMLEV_ATT_event, GF_TRUE, GF_FALSE, &info); ((XMLEV_Event *)info.far_ptr)->type = event_type; ((XMLEV_Event *)info.far_ptr)->parameter = event_parameter; @@ -625,7 +625,7 @@ GF_DOMHandler *gf_dom_listener_build_ex(GF_Node *node, u32 event_type, u32 event gf_node_get_attribute_by_tag((GF_Node*)listener, TAG_XMLEV_ATT_target, GF_TRUE, GF_FALSE, &info); ((XMLRI *)info.far_ptr)->target = node; - + gf_node_dom_listener_add((GF_Node *) node, (GF_Node *) listener); if (out_listener) *out_listener = (GF_Node *) listener; @@ -670,7 +670,7 @@ static void gf_smil_handle_event(GF_Node *timed_elt, GF_FieldInfo *info, GF_DOM_ } /*only handle event if coming from the watched element*/ if (proto->element) { - if ((evt->currentTarget->ptr_type!=GF_DOM_EVENT_TARGET_NODE) || (proto->element!= (GF_Node*)evt->currentTarget->ptr)) + if ((evt->currentTarget->ptr_type!=GF_DOM_EVENT_TARGET_NODE) || (proto->element!= (GF_Node*)evt->currentTarget->ptr)) continue; } @@ -745,25 +745,25 @@ static void gf_smil_setup_event_list(GF_Node *node, GF_List *l, Bool is_begin) } else if (t->event.type==GF_EVENT_REPEAT) { t->event.type=GF_EVENT_REPEAT_EVENT; t->is_absolute_event = GF_TRUE; - } + } /*create a new listener*/ hdl = gf_dom_listener_build_ex(t->element, t->event.type, t->event.parameter, NULL, &t->listener); - /*register the listener so that we can handle cyclic references: + /*register the listener so that we can handle cyclic references: - If the anim node gets destroyed, the listener is removed through the SMIL_Time reference - If the target gets destroyed, the listener is removed through the regular way */ if (t->listener) gf_node_register(t->listener, NULL); - + if (hdl) { ((SVG_handlerElement *)hdl)->handle_event = is_begin ? gf_smil_handle_event_begin : gf_smil_handle_event_end; } else { continue; } - /*We don't want to insert the implicit listener in the DOM. However remember + /*We don't want to insert the implicit listener in the DOM. However remember the listener at the handler level in case the handler gets destroyed*/ gf_node_set_private((GF_Node *)hdl, node); gf_node_register((GF_Node*)node, NULL); @@ -868,7 +868,7 @@ GF_DOMUpdates *gf_dom_add_update_node(GF_Node *parent) return update; } -void gf_dom_event_dump_listeners(GF_Node *n, FILE *f) +void gf_dom_event_dump_listeners(GF_Node *n, FILE *f) { u32 i; u32 count; @@ -889,9 +889,9 @@ void gf_dom_event_dump_listeners(GF_Node *n, FILE *f) hdl = (SVG_handlerElement *) ((XMLRI*)info.far_ptr)->target; if (!hdl) continue; /*this handler was declared in the graph*/ - if (hdl->sgprivate->parents - && (hdl->sgprivate->parents->next || (hdl->sgprivate->parents->node != listener)) - ) + if (hdl->sgprivate->parents + && (hdl->sgprivate->parents->next || (hdl->sgprivate->parents->node != listener)) + ) continue; txt = hdl->children ? (GF_DOMText*)hdl->children->node : NULL; @@ -904,24 +904,24 @@ void gf_dom_event_dump_listeners(GF_Node *n, FILE *f) } } -GF_DOMEventTarget *gf_dom_event_target_new(GF_DOMEventTargetType type, void *obj) +GF_DOMEventTarget *gf_dom_event_target_new(GF_DOMEventTargetType type, void *obj) { - GF_DOMEventTarget *target; - GF_SAFEALLOC(target, GF_DOMEventTarget); - target->ptr_type = type; + GF_DOMEventTarget *target; + GF_SAFEALLOC(target, GF_DOMEventTarget); + target->ptr_type = type; target->listeners = gf_list_new(); - target->ptr = obj; - return target; + target->ptr = obj; + return target; } -void gf_dom_event_target_del(GF_DOMEventTarget *target) +void gf_dom_event_target_del(GF_DOMEventTarget *target) { - assert(gf_list_count(target->listeners) == 0); + assert(gf_list_count(target->listeners) == 0); gf_list_del(target->listeners); gf_free(target); } -GF_DOMEventTarget *gf_dom_event_get_target_from_node(GF_Node *n) +GF_DOMEventTarget *gf_dom_event_get_target_from_node(GF_Node *n) { GF_DOMEventTarget *target = NULL; //GF_HTML_MediaElement *me = html_media_element_get_from_node(c, n); diff --git a/src/scenegraph/dom_smjs.c b/src/scenegraph/dom_smjs.c index f60032c..6a6ad79 100644 --- a/src/scenegraph/dom_smjs.c +++ b/src/scenegraph/dom_smjs.c @@ -125,9 +125,9 @@ typedef struct GF_JSClass storageClass; - GF_JSClass htmlMediaElementClass; + GF_JSClass htmlMediaElementClass; - void *(*get_element_class)(GF_Node *n); + void *(*get_element_class)(GF_Node *n); void *(*get_document_class)(GF_SceneGraph *n); GF_List *handlers; } GF_DOMRuntime; @@ -417,10 +417,10 @@ static jsval dom_base_node_construct(JSContext *c, GF_JSClass *_class, GF_Node * new_obj = JS_NewObject(c, & _class->_class, 0, 0); SMJS_SET_PRIVATE(c, new_obj, n); - if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) - { - html_media_element_js_init(c, new_obj, n); - } + if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) + { + html_media_element_js_init(c, new_obj, n); + } if (!n->sgprivate->interact) GF_SAFEALLOC(n->sgprivate->interact, struct _node_interactive_ext); if (!n->sgprivate->interact->js_binding) { GF_SAFEALLOC(n->sgprivate->interact->js_binding, struct _node_js_binding); @@ -562,25 +562,25 @@ static jsval dom_nodelist_construct(JSContext *c, GF_ParentNode *n) static DECL_FINALIZE(dom_nodelist_finalize) - DOMNodeList *nl; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL) ) - return; +DOMNodeList *nl; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL) ) + return; - nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); - if (!nl) return; +nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); +if (!nl) return; - if (nl->owner) { - dom_unregister_node((GF_Node*)nl->owner); - } else { - /*unregister all nodes for created lists*/ - while (nl->child) { - GF_ChildNodeItem *child = nl->child; - nl->child = child->next; - dom_unregister_node(child->node); - gf_free(child); - } +if (nl->owner) { + dom_unregister_node((GF_Node*)nl->owner); +} else { + /*unregister all nodes for created lists*/ + while (nl->child) { + GF_ChildNodeItem *child = nl->child; + nl->child = child->next; + dom_unregister_node(child->node); + gf_free(child); } - gf_free(nl); +} +gf_free(nl); } static JSBool SMJS_FUNCTION(dom_nodelist_item) @@ -610,42 +610,42 @@ static JSBool SMJS_FUNCTION(dom_nodelist_item) static SMJS_FUNC_PROP_GET( dom_nodelist_getProperty) - DOMNodeList *nl; - u32 count; - s32 idx; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL)) { - return JS_TRUE; - } - nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); - count = gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child); +DOMNodeList *nl; +u32 count; +s32 idx; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL)) { + return JS_TRUE; +} +nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); +count = gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child); - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - switch (SMJS_ID_TO_INT(id)) { - case NODELIST_JSPROPERTY_LENGTH: - *vp = INT_TO_JSVAL( count ); +switch (SMJS_ID_TO_INT(id)) { +case NODELIST_JSPROPERTY_LENGTH: + *vp = INT_TO_JSVAL( count ); + return JS_TRUE; +default: + idx = SMJS_ID_TO_INT(id); + if ((idx<0) || ((u32) idx>=count)) { + *vp = JSVAL_VOID; + return JS_TRUE; + } else { + GF_Node *n; + n = gf_node_list_get_child(nl->owner ? nl->owner->children : nl->child, idx); + *vp = dom_node_construct(c, n); return JS_TRUE; - default: - idx = SMJS_ID_TO_INT(id); - if ((idx<0) || ((u32) idx>=count)) { - *vp = JSVAL_VOID; - return JS_TRUE; - } else { - GF_Node *n; - n = gf_node_list_get_child(nl->owner ? nl->owner->children : nl->child, idx); - *vp = dom_node_construct(c, n); - return JS_TRUE; - } } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET_NOVP( dom_nodelist_setProperty) - /*avoids gcc warning*/ - if (!obj) obj=NULL; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - /*no write prop*/ - return JS_TRUE; +/*avoids gcc warning*/ +if (!obj) obj=NULL; +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +/*no write prop*/ +return JS_TRUE; } @@ -672,8 +672,8 @@ static void dom_handler_remove(GF_Node *node, void *rs, Bool is_destroy) } } -static JSBool sg_js_get_event_target(JSContext *c, JSObject *obj, GF_EventType evtType, GF_Node *vrml_node, - GF_SceneGraph **sg, GF_DOMEventTarget **target, GF_Node **n) +static JSBool sg_js_get_event_target(JSContext *c, JSObject *obj, GF_EventType evtType, GF_Node *vrml_node, + GF_SceneGraph **sg, GF_DOMEventTarget **target, GF_Node **n) { Bool is_svg_document_class(JSContext *c, JSObject *obj); Bool is_svg_element_class(JSContext *c, JSObject *obj); @@ -686,14 +686,14 @@ static JSBool sg_js_get_event_target(JSContext *c, JSObject *obj, GF_EventType e void gf_html_media_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarget **target, GF_SceneGraph **sg); gf_html_media_get_event_target(c, obj, target, sg); if (*target && *sg) return JS_TRUE; - } - + } + if (gf_dom_event_get_category(evtType) == GF_DOM_EVENT_MEDIASOURCE) { void gf_mse_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarget **target, GF_SceneGraph **sg); gf_mse_get_event_target(c, obj, target, sg); if (*target && *sg) return JS_TRUE; - } - + } + if (GF_JS_InstanceOf(c, obj, &dom_rt->domDocumentClass, NULL) || is_svg_document_class(c, obj)) { /*document interface*/ *sg = dom_get_doc(c, obj); @@ -737,9 +737,9 @@ static JSBool sg_js_get_event_target(JSContext *c, JSObject *obj, GF_EventType e return JS_TRUE; } -static GF_Err sg_js_parse_event_args(JSContext *c, JSObject *obj, uintN argc, jsval *argv, - GF_EventType *evtType, - char **callback, jsval *funval, JSObject **evt_handler) { +static GF_Err sg_js_parse_event_args(JSContext *c, JSObject *obj, uintN argc, jsval *argv, + GF_EventType *evtType, + char **callback, jsval *funval, JSObject **evt_handler) { u32 offset = 0; char *type = NULL; char *inNS = NULL; @@ -799,7 +799,7 @@ err_exit: } static GF_Node *create_listener(GF_SceneGraph *sg, GF_EventType evtType, GF_Node *n, GF_Node *vrml_node, - JSContext *c, char *callback, jsval funval, JSObject *evt_handler) + JSContext *c, char *callback, jsval funval, JSObject *evt_handler) { GF_FieldInfo info; GF_Node *listener; @@ -811,7 +811,7 @@ static GF_Node *create_listener(GF_SceneGraph *sg, GF_EventType evtType, GF_Node /*!!! create the handler in the scene owning the script context !!! */ { - /* removed in harmonisation with XHR, was it really needed ? + /* removed in harmonisation with XHR, was it really needed ? GF_SceneGraph *sg = xml_get_scenegraph(c); */ handler = (SVG_handlerElement *) gf_node_new(sg, TAG_SVG_handler); @@ -868,8 +868,8 @@ static GF_Node *create_listener(GF_SceneGraph *sg, GF_EventType evtType, GF_Node JSBool SMJS_FUNCTION_EXT(gf_sg_js_event_add_listener, GF_Node *vrml_node) { GF_DOMEventTarget *target = NULL; - GF_Node *listener = NULL; - GF_EventType evtType = GF_EVENT_UNKNOWN; + GF_Node *listener = NULL; + GF_EventType evtType = GF_EVENT_UNKNOWN; GF_SceneGraph *sg = NULL; char *callback = NULL; jsval funval = JSVAL_NULL; @@ -885,7 +885,7 @@ JSBool SMJS_FUNCTION_EXT(gf_sg_js_event_add_listener, GF_Node *vrml_node) if (e != GF_OK) goto err_exit; /* First retrieve the scenegraph and the GF_DOMEventTarget object */ - sg_js_get_event_target(c, obj, evtType, vrml_node, &sg, &target, &n); + sg_js_get_event_target(c, obj, evtType, vrml_node, &sg, &target, &n); if (!sg || !target) goto err_exit; listener = create_listener(sg, evtType, n, vrml_node, c, callback, funval, evt_handler); @@ -899,8 +899,8 @@ JSBool SMJS_FUNCTION_EXT(gf_sg_js_event_add_listener, GF_Node *vrml_node) } err_exit: - if (callback) SMJS_FREE(c, callback); - return JS_TRUE; + if (callback) SMJS_FREE(c, callback); + return JS_TRUE; } @@ -928,7 +928,7 @@ JSBool SMJS_FUNCTION_EXT(gf_sg_js_event_remove_listener, GF_Node *vrml_node) if (e != GF_OK) goto err_exit; /* First retrieve the scenegraph and the GF_DOMEventTarget object */ - sg_js_get_event_target(c, obj, evtType, vrml_node, &sg, &target, &node); + sg_js_get_event_target(c, obj, evtType, vrml_node, &sg, &target, &node); if (!sg || !target) return JS_TRUE; /*flush all pending add_listener*/ @@ -951,9 +951,9 @@ JSBool SMJS_FUNCTION_EXT(gf_sg_js_event_remove_listener, GF_Node *vrml_node) if (!hdl) continue; if (! JSVAL_IS_NULL(funval) ) { #if (JS_VERSION>=185) - JSBool res = JS_FALSE; - if (! JS_StrictlyEqual(c, funval, *(jsval *)&hdl->js_fun_val, &res)) - continue; + JSBool res = JS_FALSE; + if (! JS_StrictlyEqual(c, funval, *(jsval *)&hdl->js_fun_val, &res)) + continue; #else if (funval != *(jsval *)&hdl->js_fun_val) continue; #endif @@ -984,16 +984,16 @@ JSBool SMJS_FUNCTION(dom_event_remove_listener) /*dom3 node*/ static DECL_FINALIZE( dom_node_finalize) - GF_Node *n = (GF_Node *) SMJS_GET_PRIVATE(c, obj); - /*the JS proto of the svgClass or a destroyed object*/ - if (!n) return; - if (!n->sgprivate) return; +GF_Node *n = (GF_Node *) SMJS_GET_PRIVATE(c, obj); +/*the JS proto of the svgClass or a destroyed object*/ +if (!n) return; +if (!n->sgprivate) return; - SMJS_SET_PRIVATE(c, obj, NULL); - gf_list_del_item(n->sgprivate->scenegraph->objects, obj); +SMJS_SET_PRIVATE(c, obj, NULL); +gf_list_del_item(n->sgprivate->scenegraph->objects, obj); - dom_js_pre_destroy(c, n->sgprivate->scenegraph, n); - dom_unregister_node(n); +dom_js_pre_destroy(c, n->sgprivate->scenegraph, n); +dom_unregister_node(n); } static Bool check_dom_parents(JSContext *c, GF_Node *n, GF_Node *parent) @@ -1056,7 +1056,7 @@ static void dom_node_inserted(JSContext *c, GF_Node *n, GF_Node *parent, s32 pos gf_dom_listener_build_ex(parent, 0, 0, n, NULL); } gf_node_init(n); - + #ifndef GPAC_DISABLE_SVG if (n->sgprivate->interact && n->sgprivate->interact->dom_evt) { @@ -1200,7 +1200,7 @@ static JSBool SMJS_FUNCTION(xml_node_remove_child) tag = gf_node_get_tag(n); if (tag==TAG_DOMText) return JS_TRUE; par = (GF_ParentNode*)n; - + /*if node is present in parent, unregister*/ if (gf_node_list_del_child(&par->children, old_node)) { gf_node_unregister(old_node, n); @@ -1333,173 +1333,173 @@ static u32 get_namespace_code_by_prefix(GF_Node *node, char *prefix) static SMJS_FUNC_PROP_GET( dom_node_getProperty) - u32 tag; - GF_Node *n; - GF_SceneGraph *sg = NULL; - GF_ParentNode *par; +u32 tag; +GF_Node *n; +GF_SceneGraph *sg = NULL; +GF_ParentNode *par; - n = dom_get_node(c, obj); - if (!n) { - sg = dom_get_doc(c, obj); - if (!sg) return JS_TRUE; - } +n = dom_get_node(c, obj); +if (!n) { + sg = dom_get_doc(c, obj); + if (!sg) return JS_TRUE; +} - /*not supported*/ - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +/*not supported*/ +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - tag = n ? gf_node_get_tag(n) : 0; - par = (GF_ParentNode*)n; +tag = n ? gf_node_get_tag(n) : 0; +par = (GF_ParentNode*)n; - switch (SMJS_ID_TO_INT(id)) { - case NODE_JSPROPERTY_NODENAME: - if (sg) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#document") ); - } - else if (tag==TAG_DOMText) { - GF_DOMText *txt = (GF_DOMText *)n; - if (txt->type==GF_DOM_TEXT_CDATA) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#cdata-section") ); - else *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#text") ); - } - else { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, gf_node_get_class_name(n) ) ); - } - return JS_TRUE; - case NODE_JSPROPERTY_NODEVALUE: - *vp = JSVAL_VOID; - if (tag==TAG_DOMText) { - GF_DOMText *txt = (GF_DOMText *)n; - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, txt->textContent) ); - } - return JS_TRUE; - case NODE_JSPROPERTY_NODETYPE: - if (sg) *vp = INT_TO_JSVAL(9); - else if (tag==TAG_DOMText) { - GF_DOMText *txt = (GF_DOMText *)n; - if (txt->type==GF_DOM_TEXT_CDATA) *vp = INT_TO_JSVAL(4); - else *vp = INT_TO_JSVAL(3); - } - else *vp = INT_TO_JSVAL(1); - return JS_TRUE; - case NODE_JSPROPERTY_PARENTNODE: - if (sg) { - *vp = JSVAL_NULL; - } - /*if root node of the tree, the parentNode is the document*/ - else if (n->sgprivate->scenegraph->RootNode==n) { - *vp = dom_document_construct(c, n->sgprivate->scenegraph); - } else { - *vp = dom_node_construct(c, gf_node_get_parent(n, 0) ); - } - return JS_TRUE; - case NODE_JSPROPERTY_CHILDNODES: - /*NOT SUPPORTED YET*/ - if (sg) *vp = JSVAL_VOID; - else if (tag==TAG_DOMText) *vp = JSVAL_NULL; - else *vp = dom_nodelist_construct(c, par); - return JS_TRUE; - case NODE_JSPROPERTY_FIRSTCHILD: - if (sg) *vp = dom_node_construct(c, sg->RootNode); - else if (tag==TAG_DOMText) *vp = JSVAL_NULL; - else if (!par->children) { - *vp = JSVAL_NULL; - } - else *vp = dom_node_construct(c, par->children->node); - return JS_TRUE; - case NODE_JSPROPERTY_LASTCHILD: - if (sg) *vp = dom_node_construct(c, sg->RootNode); - else if ((tag==TAG_DOMText) || !par->children) *vp = JSVAL_VOID; - else *vp = dom_node_construct(c, gf_node_list_get_child(par->children, -1) ); - return JS_TRUE; - case NODE_JSPROPERTY_PREVIOUSSIBLING: - /*works for doc as well since n is NULL*/ - *vp = dom_node_get_sibling(c, n, GF_TRUE, GF_FALSE); - return JS_TRUE; - case NODE_JSPROPERTY_NEXTSIBLING: - *vp = dom_node_get_sibling(c, n, GF_FALSE, GF_FALSE); - return JS_TRUE; - case NODE_JSPROPERTY_ATTRIBUTES: - /*NOT SUPPORTED YET*/ - *vp = JSVAL_VOID; - return JS_TRUE; - case NODE_JSPROPERTY_OWNERDOCUMENT: - if (sg) *vp = JSVAL_NULL; - else *vp = dom_document_construct(c, n->sgprivate->scenegraph); - return JS_TRUE; - case NODE_JSPROPERTY_NAMESPACEURI: +switch (SMJS_ID_TO_INT(id)) { +case NODE_JSPROPERTY_NODENAME: + if (sg) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#document") ); + } + else if (tag==TAG_DOMText) { + GF_DOMText *txt = (GF_DOMText *)n; + if (txt->type==GF_DOM_TEXT_CDATA) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#cdata-section") ); + else *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "#text") ); + } + else { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, gf_node_get_class_name(n) ) ); + } + return JS_TRUE; +case NODE_JSPROPERTY_NODEVALUE: + *vp = JSVAL_VOID; + if (tag==TAG_DOMText) { + GF_DOMText *txt = (GF_DOMText *)n; + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, txt->textContent) ); + } + return JS_TRUE; +case NODE_JSPROPERTY_NODETYPE: + if (sg) *vp = INT_TO_JSVAL(9); + else if (tag==TAG_DOMText) { + GF_DOMText *txt = (GF_DOMText *)n; + if (txt->type==GF_DOM_TEXT_CDATA) *vp = INT_TO_JSVAL(4); + else *vp = INT_TO_JSVAL(3); + } + else *vp = INT_TO_JSVAL(1); + return JS_TRUE; +case NODE_JSPROPERTY_PARENTNODE: + if (sg) { *vp = JSVAL_NULL; - if (!sg) { - tag = gf_xml_get_element_namespace(n); - if (tag) { - const char *xmlns = gf_sg_get_namespace(n->sgprivate->scenegraph, tag); - if (!xmlns) xmlns = node_lookup_namespace_by_tag(n, tag); - *vp = xmlns ? STRING_TO_JSVAL( JS_NewStringCopyZ(c, xmlns) ) : JSVAL_VOID; - } - } - return JS_TRUE; - case NODE_JSPROPERTY_PREFIX: - if (sg) tag = gf_sg_get_namespace_code(sg, NULL); - else tag = gf_xml_get_element_namespace(n); + } + /*if root node of the tree, the parentNode is the document*/ + else if (n->sgprivate->scenegraph->RootNode==n) { + *vp = dom_document_construct(c, n->sgprivate->scenegraph); + } else { + *vp = dom_node_construct(c, gf_node_get_parent(n, 0) ); + } + return JS_TRUE; +case NODE_JSPROPERTY_CHILDNODES: + /*NOT SUPPORTED YET*/ + if (sg) *vp = JSVAL_VOID; + else if (tag==TAG_DOMText) *vp = JSVAL_NULL; + else *vp = dom_nodelist_construct(c, par); + return JS_TRUE; +case NODE_JSPROPERTY_FIRSTCHILD: + if (sg) *vp = dom_node_construct(c, sg->RootNode); + else if (tag==TAG_DOMText) *vp = JSVAL_NULL; + else if (!par->children) { *vp = JSVAL_NULL; + } + else *vp = dom_node_construct(c, par->children->node); + return JS_TRUE; +case NODE_JSPROPERTY_LASTCHILD: + if (sg) *vp = dom_node_construct(c, sg->RootNode); + else if ((tag==TAG_DOMText) || !par->children) *vp = JSVAL_VOID; + else *vp = dom_node_construct(c, gf_node_list_get_child(par->children, -1) ); + return JS_TRUE; +case NODE_JSPROPERTY_PREVIOUSSIBLING: + /*works for doc as well since n is NULL*/ + *vp = dom_node_get_sibling(c, n, GF_TRUE, GF_FALSE); + return JS_TRUE; +case NODE_JSPROPERTY_NEXTSIBLING: + *vp = dom_node_get_sibling(c, n, GF_FALSE, GF_FALSE); + return JS_TRUE; +case NODE_JSPROPERTY_ATTRIBUTES: + /*NOT SUPPORTED YET*/ + *vp = JSVAL_VOID; + return JS_TRUE; +case NODE_JSPROPERTY_OWNERDOCUMENT: + if (sg) *vp = JSVAL_NULL; + else *vp = dom_document_construct(c, n->sgprivate->scenegraph); + return JS_TRUE; +case NODE_JSPROPERTY_NAMESPACEURI: + *vp = JSVAL_NULL; + if (!sg) { + tag = gf_xml_get_element_namespace(n); if (tag) { - char *xmlns = (char *)gf_sg_get_namespace_qname(sg ? sg : n->sgprivate->scenegraph, tag); - if (xmlns) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, xmlns) ); - } - return JS_TRUE; - case NODE_JSPROPERTY_LOCALNAME: - *vp = JSVAL_NULL; - if (!sg && (tag!=TAG_DOMText)) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, node_get_local_name(n) ) ); - } - return JS_TRUE; - case NODE_JSPROPERTY_BASEURI: - /*NOT SUPPORTED YET*/ - *vp = JSVAL_NULL; - return JS_TRUE; - case NODE_JSPROPERTY_TEXTCONTENT: - *vp = JSVAL_VOID; - if (!sg) { - char *res = gf_dom_flatten_textContent(n); - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, res) ); - gf_free(res); + const char *xmlns = gf_sg_get_namespace(n->sgprivate->scenegraph, tag); + if (!xmlns) xmlns = node_lookup_namespace_by_tag(n, tag); + *vp = xmlns ? STRING_TO_JSVAL( JS_NewStringCopyZ(c, xmlns) ) : JSVAL_VOID; } - return JS_TRUE; - case NODE_JSPROPERTY_FIRSTELEMENTCHILD: - *vp = JSVAL_NULL; - if (n->sgprivate->tag!=TAG_DOMText) { - GF_ChildNodeItem *child = ((GF_ParentNode*)n)->children; - while (child) { - if (child->node->sgprivate->tag != TAG_DOMText) { - *vp = dom_element_construct(c, child->node); - break; - } - child = child->next; + } + return JS_TRUE; +case NODE_JSPROPERTY_PREFIX: + if (sg) tag = gf_sg_get_namespace_code(sg, NULL); + else tag = gf_xml_get_element_namespace(n); + *vp = JSVAL_NULL; + if (tag) { + char *xmlns = (char *)gf_sg_get_namespace_qname(sg ? sg : n->sgprivate->scenegraph, tag); + if (xmlns) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, xmlns) ); + } + return JS_TRUE; +case NODE_JSPROPERTY_LOCALNAME: + *vp = JSVAL_NULL; + if (!sg && (tag!=TAG_DOMText)) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, node_get_local_name(n) ) ); + } + return JS_TRUE; +case NODE_JSPROPERTY_BASEURI: + /*NOT SUPPORTED YET*/ + *vp = JSVAL_NULL; + return JS_TRUE; +case NODE_JSPROPERTY_TEXTCONTENT: + *vp = JSVAL_VOID; + if (!sg) { + char *res = gf_dom_flatten_textContent(n); + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, res) ); + gf_free(res); + } + return JS_TRUE; +case NODE_JSPROPERTY_FIRSTELEMENTCHILD: + *vp = JSVAL_NULL; + if (n->sgprivate->tag!=TAG_DOMText) { + GF_ChildNodeItem *child = ((GF_ParentNode*)n)->children; + while (child) { + if (child->node->sgprivate->tag != TAG_DOMText) { + *vp = dom_element_construct(c, child->node); + break; } + child = child->next; } - return JS_TRUE; - case NODE_JSPROPERTY_LASTELEMENTCHILD: - *vp = JSVAL_NULL; - if (n->sgprivate->tag!=TAG_DOMText) { - GF_Node *last = NULL; - GF_ChildNodeItem *child = ((GF_ParentNode*)n)->children; - while (child) { - if (child->node->sgprivate->tag != TAG_DOMText) { - last = child->node; - } - child = child->next; + } + return JS_TRUE; +case NODE_JSPROPERTY_LASTELEMENTCHILD: + *vp = JSVAL_NULL; + if (n->sgprivate->tag!=TAG_DOMText) { + GF_Node *last = NULL; + GF_ChildNodeItem *child = ((GF_ParentNode*)n)->children; + while (child) { + if (child->node->sgprivate->tag != TAG_DOMText) { + last = child->node; } - if (last) *vp = dom_element_construct(c, last); + child = child->next; } - return JS_TRUE; - case NODE_JSPROPERTY_PREVIOUSELEMENTSIBLING: - *vp = dom_node_get_sibling(c, n, GF_TRUE, GF_TRUE); - return JS_TRUE; - case NODE_JSPROPERTY_NEXTELEMENTSIBLING: - *vp = dom_node_get_sibling(c, n, GF_FALSE, GF_TRUE); - return JS_TRUE; - + if (last) *vp = dom_element_construct(c, last); } - /*not supported*/ return JS_TRUE; +case NODE_JSPROPERTY_PREVIOUSELEMENTSIBLING: + *vp = dom_node_get_sibling(c, n, GF_TRUE, GF_TRUE); + return JS_TRUE; +case NODE_JSPROPERTY_NEXTELEMENTSIBLING: + *vp = dom_node_get_sibling(c, n, GF_FALSE, GF_TRUE); + return JS_TRUE; + +} +/*not supported*/ +return JS_TRUE; } void dom_node_set_textContent(GF_Node *n, char *text) @@ -1515,41 +1515,41 @@ void dom_node_set_textContent(GF_Node *n, char *text) static SMJS_FUNC_PROP_SET( dom_node_setProperty) - u32 tag; - GF_Node *n; +u32 tag; +GF_Node *n; - n = dom_get_node(c, obj); - /*note an element - we don't support property setting on document yet*/ - if (!n) return JS_TRUE; +n = dom_get_node(c, obj); +/*note an element - we don't support property setting on document yet*/ +if (!n) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - tag = n ? gf_node_get_tag(n) : 0; +tag = n ? gf_node_get_tag(n) : 0; - switch (SMJS_ID_TO_INT(id)) { - case NODE_JSPROPERTY_NODEVALUE: - if ((tag==TAG_DOMText) && JSVAL_CHECK_STRING(*vp)) { - GF_DOMText *txt = (GF_DOMText *)n; - if (txt->textContent) gf_free(txt->textContent); - txt->textContent = js_get_utf8(c, *vp); - dom_node_changed(n, GF_TRUE, NULL); - } - /*we only support element and sg in the Node interface, no set*/ - return JS_TRUE; - case NODE_JSPROPERTY_PREFIX: - /*NOT SUPPORTED YET*/ - return JS_TRUE; - case NODE_JSPROPERTY_TEXTCONTENT: - { - char *txt; - txt = js_get_utf8(c, *vp); - dom_node_set_textContent(n, txt); - if (txt) gf_free(txt); - } - return JS_TRUE; +switch (SMJS_ID_TO_INT(id)) { +case NODE_JSPROPERTY_NODEVALUE: + if ((tag==TAG_DOMText) && JSVAL_CHECK_STRING(*vp)) { + GF_DOMText *txt = (GF_DOMText *)n; + if (txt->textContent) gf_free(txt->textContent); + txt->textContent = js_get_utf8(c, *vp); + dom_node_changed(n, GF_TRUE, NULL); } - /*not supported*/ + /*we only support element and sg in the Node interface, no set*/ + return JS_TRUE; +case NODE_JSPROPERTY_PREFIX: + /*NOT SUPPORTED YET*/ return JS_TRUE; +case NODE_JSPROPERTY_TEXTCONTENT: +{ + char *txt; + txt = js_get_utf8(c, *vp); + dom_node_set_textContent(n, txt); + if (txt) gf_free(txt); +} +return JS_TRUE; +} +/*not supported*/ +return JS_TRUE; } @@ -1559,87 +1559,87 @@ static SMJS_FUNC_PROP_SET( dom_node_setProperty) fortunately a sg cannot be created like that...*/ DECL_FINALIZE(dom_document_finalize) - GF_SceneGraph *sg = dom_get_doc(c, obj); +GF_SceneGraph *sg = dom_get_doc(c, obj); - sg = (GF_SceneGraph*) SMJS_GET_PRIVATE(c, obj); - /*the JS proto of the svgClass or a destroyed object*/ - if (!sg) return; +sg = (GF_SceneGraph*) SMJS_GET_PRIVATE(c, obj); +/*the JS proto of the svgClass or a destroyed object*/ +if (!sg) return; - SMJS_SET_PRIVATE(c, sg->document, NULL); - sg->document = NULL; - if (sg->RootNode) { - gf_node_unregister(sg->RootNode, NULL); - if (sg->reference_count) { - sg->reference_count--; - if (!sg->reference_count) - gf_sg_del(sg); - } +SMJS_SET_PRIVATE(c, sg->document, NULL); +sg->document = NULL; +if (sg->RootNode) { + gf_node_unregister(sg->RootNode, NULL); + if (sg->reference_count) { + sg->reference_count--; + if (!sg->reference_count) + gf_sg_del(sg); } } +} static SMJS_FUNC_PROP_GET( dom_document_getProperty ) - u32 prop_id; - GF_SceneGraph *sg = dom_get_doc(c, obj); - if (!sg) return JS_TRUE; +u32 prop_id; +GF_SceneGraph *sg = dom_get_doc(c, obj); +if (!sg) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); - switch (prop_id) { - case DOCUMENT_JSPROPERTY_IMPLEMENTATION: - /*FIXME, this is wrong, we should have our own implementation - but at the current time we rely on the global object to provide it*/ - *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); - return JS_TRUE; - case DOCUMENT_JSPROPERTY_DOCUMENTELEMENT: - *vp = dom_element_construct(c, sg->RootNode); - return JS_TRUE; - case DOCUMENT_JSPROPERTY_GLOBAL: - *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); - return JS_TRUE; +switch (prop_id) { +case DOCUMENT_JSPROPERTY_IMPLEMENTATION: + /*FIXME, this is wrong, we should have our own implementation + but at the current time we rely on the global object to provide it*/ + *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); + return JS_TRUE; +case DOCUMENT_JSPROPERTY_DOCUMENTELEMENT: + *vp = dom_element_construct(c, sg->RootNode); + return JS_TRUE; +case DOCUMENT_JSPROPERTY_GLOBAL: + *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); + return JS_TRUE; /*NOT SUPPORTED YET*/ - case DOCUMENT_JSPROPERTY_DOCTYPE: - case DOCUMENT_JSPROPERTY_INPUTENCODING: - case DOCUMENT_JSPROPERTY_XMLENCODING: - case DOCUMENT_JSPROPERTY_XMLSTANDALONE: - case DOCUMENT_JSPROPERTY_XMLVERSION: - case DOCUMENT_JSPROPERTY_STRICTERRORCHECKING: - case DOCUMENT_JSPROPERTY_DOCUMENTURI: - case DOCUMENT_JSPROPERTY_LOCATION: - case DOCUMENT_JSPROPERTY_DOMCONFIG: - *vp = JSVAL_VOID; - return JS_TRUE; - } +case DOCUMENT_JSPROPERTY_DOCTYPE: +case DOCUMENT_JSPROPERTY_INPUTENCODING: +case DOCUMENT_JSPROPERTY_XMLENCODING: +case DOCUMENT_JSPROPERTY_XMLSTANDALONE: +case DOCUMENT_JSPROPERTY_XMLVERSION: +case DOCUMENT_JSPROPERTY_STRICTERRORCHECKING: +case DOCUMENT_JSPROPERTY_DOCUMENTURI: +case DOCUMENT_JSPROPERTY_LOCATION: +case DOCUMENT_JSPROPERTY_DOMCONFIG: + *vp = JSVAL_VOID; return JS_TRUE; } +return JS_TRUE; +} static SMJS_FUNC_PROP_SET_NOVP(dom_document_setProperty) - u32 prop_id; - GF_SceneGraph *sg = dom_get_doc(c, obj); - if (!sg) return JS_TRUE; - - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); - - switch (prop_id) { - case DOCUMENT_JSPROPERTY_XMLSTANDALONE: - break; - case DOCUMENT_JSPROPERTY_XMLVERSION: - break; - case DOCUMENT_JSPROPERTY_STRICTERRORCHECKING: - break; - case DOCUMENT_JSPROPERTY_DOCUMENTURI: - break; - case DOCUMENT_JSPROPERTY_DOMCONFIG: - break; +u32 prop_id; +GF_SceneGraph *sg = dom_get_doc(c, obj); +if (!sg) return JS_TRUE; + +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); + +switch (prop_id) { +case DOCUMENT_JSPROPERTY_XMLSTANDALONE: + break; +case DOCUMENT_JSPROPERTY_XMLVERSION: + break; +case DOCUMENT_JSPROPERTY_STRICTERRORCHECKING: + break; +case DOCUMENT_JSPROPERTY_DOCUMENTURI: + break; +case DOCUMENT_JSPROPERTY_DOMCONFIG: + break; /*the rest is read-only*/ - } - return JS_TRUE; +} +return JS_TRUE; } static JSBool SMJS_FUNCTION(xml_document_create_element) @@ -1792,28 +1792,28 @@ static JSBool SMJS_FUNCTION(xml_document_element_by_id) /*dom3 element*/ DECL_FINALIZE( dom_element_finalize) - dom_node_finalize(c, obj); +dom_node_finalize(c, obj); } -static SMJS_FUNC_PROP_GET( dom_element_getProperty) +static SMJS_FUNC_PROP_GET( dom_element_getProperty) - u32 prop_id; - GF_Node *n = dom_get_node(c, obj); - if (!n) return JS_TRUE; +u32 prop_id; +GF_Node *n = dom_get_node(c, obj); +if (!n) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); - switch (prop_id) { - case ELEMENT_JSPROPERTY_TAGNAME: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, gf_node_get_class_name(n) ) ); - return JS_TRUE; - case ELEMENT_JSPROPERTY_SCHEMATYPEINFO: - /*NOT SUPPORTED YET*/ - *vp = JSVAL_VOID; - return JS_TRUE; - } +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); +switch (prop_id) { +case ELEMENT_JSPROPERTY_TAGNAME: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, gf_node_get_class_name(n) ) ); + return JS_TRUE; +case ELEMENT_JSPROPERTY_SCHEMATYPEINFO: + /*NOT SUPPORTED YET*/ + *vp = JSVAL_VOID; return JS_TRUE; } +return JS_TRUE; +} static JSBool SMJS_FUNCTION(xml_element_get_attribute) { @@ -2009,7 +2009,7 @@ static void gf_dom_add_handler_listener(GF_Node *n, u32 evtType, char *handlerCo /*check if we're modifying an existing listener*/ SVG_handlerElement *handler; u32 i, count = gf_dom_listener_count(n); - for (i=0;itype != evtType)) continue; - /* found a listener for this event, override the handler + /* found a listener for this event, override the handler TODO: FIX this, there may be a listener/handler already set with JS, why overriding ? */ gf_node_get_attribute_by_tag(listen, TAG_XMLEV_ATT_handler, GF_FALSE, GF_FALSE, &info); assert(info.far_ptr); @@ -2067,7 +2067,7 @@ void gf_svg_set_attributeNS(GF_Node *n, u32 ns_code, char *name, char *val) if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_attributeName, GF_FALSE, GF_FALSE, &info) == GF_OK) { SMIL_AttributeName *attname = (SMIL_AttributeName *)info.far_ptr; - /*parse the attribute name even if the target is not found, because a namespace could be specified and + /*parse the attribute name even if the target is not found, because a namespace could be specified and only valid for the current node*/ if (!attname->type) { char *sep; @@ -2092,12 +2092,24 @@ void gf_svg_set_attributeNS(GF_Node *n, u32 ns_code, char *name, char *val) } switch(*(SVG_TransformType *) info.far_ptr) { - case SVG_TRANSFORM_TRANSLATE: anim_value_type = SVG_Transform_Translate_datatype; break; - case SVG_TRANSFORM_SCALE: anim_value_type = SVG_Transform_Scale_datatype; break; - case SVG_TRANSFORM_ROTATE: anim_value_type = SVG_Transform_Rotate_datatype; break; - case SVG_TRANSFORM_SKEWX: anim_value_type = SVG_Transform_SkewX_datatype; break; - case SVG_TRANSFORM_SKEWY: anim_value_type = SVG_Transform_SkewY_datatype; break; - case SVG_TRANSFORM_MATRIX: anim_value_type = SVG_Transform_datatype; break; + case SVG_TRANSFORM_TRANSLATE: + anim_value_type = SVG_Transform_Translate_datatype; + break; + case SVG_TRANSFORM_SCALE: + anim_value_type = SVG_Transform_Scale_datatype; + break; + case SVG_TRANSFORM_ROTATE: + anim_value_type = SVG_Transform_Rotate_datatype; + break; + case SVG_TRANSFORM_SKEWX: + anim_value_type = SVG_Transform_SkewX_datatype; + break; + case SVG_TRANSFORM_SKEWY: + anim_value_type = SVG_Transform_SkewY_datatype; + break; + case SVG_TRANSFORM_MATRIX: + anim_value_type = SVG_Transform_datatype; + break; default: return; } @@ -2112,7 +2124,7 @@ void gf_svg_set_attributeNS(GF_Node *n, u32 ns_code, char *name, char *val) GF_LOG(GF_LOG_WARNING, GF_LOG_SCRIPT, ("Cannot retrieve attribute 'attributeName'\n")); return; } - + attname = (SMIL_AttributeName *)attType.far_ptr; if (!attname->type && attname->name) { GF_Node *anim_target = gf_smil_anim_get_target(n); @@ -2165,7 +2177,7 @@ JSBool SMJS_FUNCTION(xml_element_set_attribute) if (!n) return JS_TRUE; if ((argc < 2)) return JS_TRUE; - if (!JSVAL_CHECK_STRING(argv[0])) + if (!JSVAL_CHECK_STRING(argv[0])) return JS_TRUE; idx = 1; @@ -2173,7 +2185,7 @@ JSBool SMJS_FUNCTION(xml_element_set_attribute) /*NS version*/ if (argc==3) { char *sep; - if (!JSVAL_CHECK_STRING(argv[1])) + if (!JSVAL_CHECK_STRING(argv[1])) return JS_TRUE; ns = js_get_utf8(c, argv[0]); gf_sg_add_namespace(n->sgprivate->scenegraph, ns, NULL); @@ -2204,7 +2216,7 @@ JSBool SMJS_FUNCTION(xml_element_set_attribute) } else { goto exit; } - if (!name || !val) + if (!name || !val) goto exit; @@ -2265,7 +2277,7 @@ static JSBool SMJS_FUNCTION(xml_element_elements_by_tag) new_obj = JS_NewObject(c, &dom_rt->domNodeListClass._class, 0, 0); SMJS_SET_PRIVATE(c, new_obj, nl); SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj) ); - + SMJS_FREE(c, name); return JS_TRUE; } @@ -2310,53 +2322,53 @@ static JSBool SMJS_FUNCTION(xml_element_set_id) /*dom3 character/text/comment*/ -static SMJS_FUNC_PROP_GET( dom_text_getProperty) +static SMJS_FUNC_PROP_GET( dom_text_getProperty) - u32 prop_id; - GF_DOMText *txt = (GF_DOMText*)dom_get_node(c, obj); - if (!txt || (txt->sgprivate->tag != TAG_DOMText)) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); +u32 prop_id; +GF_DOMText *txt = (GF_DOMText*)dom_get_node(c, obj); +if (!txt || (txt->sgprivate->tag != TAG_DOMText)) return JS_TRUE; +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); - switch (prop_id) { - case TEXT_JSPROPERTY_DATA: - if (txt->textContent) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, txt->textContent ) ); - else *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "") ); - return JS_TRUE; - case TEXT_JSPROPERTY_LENGTH: - *vp = INT_TO_JSVAL(txt->textContent ? strlen(txt->textContent) : 0); - return JS_TRUE; - case TEXT_JSPROPERTY_ISELEMENTCONTENTWHITESPACE: - *vp = BOOLEAN_TO_JSVAL(JS_FALSE); - return JS_TRUE; - case TEXT_JSPROPERTY_WHOLETEXT: - /*FIXME - this is wrong*/ - *vp = INT_TO_JSVAL(txt->textContent ? strlen(txt->textContent) : 0); - return JS_TRUE; - } +switch (prop_id) { +case TEXT_JSPROPERTY_DATA: + if (txt->textContent) *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, txt->textContent ) ); + else *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "") ); + return JS_TRUE; +case TEXT_JSPROPERTY_LENGTH: + *vp = INT_TO_JSVAL(txt->textContent ? strlen(txt->textContent) : 0); + return JS_TRUE; +case TEXT_JSPROPERTY_ISELEMENTCONTENTWHITESPACE: + *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + return JS_TRUE; +case TEXT_JSPROPERTY_WHOLETEXT: + /*FIXME - this is wrong*/ + *vp = INT_TO_JSVAL(txt->textContent ? strlen(txt->textContent) : 0); return JS_TRUE; } +return JS_TRUE; +} static SMJS_FUNC_PROP_SET( dom_text_setProperty) - u32 prop_id; - GF_DOMText *txt = (GF_DOMText*)dom_get_node(c, obj); - if (!txt || (txt->sgprivate->tag != TAG_DOMText)) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); - - switch (prop_id) { - case TEXT_JSPROPERTY_DATA: - if (txt->textContent) gf_free(txt->textContent); - txt->textContent = NULL; - if (JSVAL_CHECK_STRING(*vp)) { - char *str = js_get_utf8(c, *vp); - txt->textContent = str ? str : gf_strdup("" ); - } - dom_node_changed((GF_Node*)txt, GF_FALSE, NULL); - return JS_TRUE; - /*the rest is read-only*/ - } +u32 prop_id; +GF_DOMText *txt = (GF_DOMText*)dom_get_node(c, obj); +if (!txt || (txt->sgprivate->tag != TAG_DOMText)) return JS_TRUE; +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); + +switch (prop_id) { +case TEXT_JSPROPERTY_DATA: + if (txt->textContent) gf_free(txt->textContent); + txt->textContent = NULL; + if (JSVAL_CHECK_STRING(*vp)) { + char *str = js_get_utf8(c, *vp); + txt->textContent = str ? str : gf_strdup("" ); + } + dom_node_changed((GF_Node*)txt, GF_FALSE, NULL); return JS_TRUE; + /*the rest is read-only*/ +} +return JS_TRUE; } static JSBool SMJS_FUNCTION(event_stop_propagation) @@ -2386,177 +2398,193 @@ static JSBool SMJS_FUNCTION(event_prevent_default) static SMJS_FUNC_PROP_GET( event_getProperty) - JSString *s; - GF_DOM_Event *evt = (GF_DOM_Event *)SMJS_GET_PRIVATE(c, obj); - if (evt==NULL) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case EVENT_JSPROPERTY_TYPE: - s = JS_NewStringCopyZ(c, gf_dom_event_get_name(evt->type) ); - *vp = STRING_TO_JSVAL( s ); +JSString *s; +GF_DOM_Event *evt = (GF_DOM_Event *)SMJS_GET_PRIVATE(c, obj); +if (evt==NULL) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case EVENT_JSPROPERTY_TYPE: + s = JS_NewStringCopyZ(c, gf_dom_event_get_name(evt->type) ); + *vp = STRING_TO_JSVAL( s ); + break; + case EVENT_JSPROPERTY_TARGET: + if (evt->is_vrml) return JS_TRUE; + switch (evt->target_type) { + case GF_DOM_EVENT_TARGET_NODE: + *vp = dom_element_construct(c, (GF_Node*) evt->target); + break; + case GF_DOM_EVENT_TARGET_DOCUMENT: + *vp = dom_document_construct(c, (GF_SceneGraph *) evt->target); + break; + case GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE: + *vp = OBJECT_TO_JSVAL(((GF_HTML_MediaSource *)evt->target)->_this); + break; + case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER: + *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBuffer *)evt->target)->_this); + break; + case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST: + *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBufferList *)evt->target)->_this); + break; + default: break; - case EVENT_JSPROPERTY_TARGET: - if (evt->is_vrml) return JS_TRUE; - switch (evt->target_type) { - case GF_DOM_EVENT_TARGET_NODE: - *vp = dom_element_construct(c, (GF_Node*) evt->target); - break; - case GF_DOM_EVENT_TARGET_DOCUMENT: - *vp = dom_document_construct(c, (GF_SceneGraph *) evt->target); - break; - case GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE: - *vp = OBJECT_TO_JSVAL(((GF_HTML_MediaSource *)evt->target)->_this); - break; - case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER: - *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBuffer *)evt->target)->_this); - break; - case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST: - *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBufferList *)evt->target)->_this); - break; - default: - break; - } - return JS_TRUE; - case EVENT_JSPROPERTY_CURRENTTARGET: - if (evt->is_vrml) return JS_TRUE; - switch (evt->currentTarget->ptr_type) { - case GF_DOM_EVENT_TARGET_NODE: - *vp = dom_element_construct(c, (GF_Node*) evt->currentTarget->ptr); - break; - case GF_DOM_EVENT_TARGET_DOCUMENT: - *vp = dom_document_construct(c, (GF_SceneGraph *) evt->currentTarget->ptr); - break; - case GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE: - *vp = OBJECT_TO_JSVAL(((GF_HTML_MediaSource *)evt->target)->_this); - break; - case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER: - *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBuffer *)evt->target)->_this); - break; - case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST: - *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBufferList *)evt->target)->_this); - break; - default: - break; - } - return JS_TRUE; - case EVENT_JSPROPERTY_EVENTPHASE: - *vp = INT_TO_JSVAL( (evt->event_phase & 0x3) ); return JS_TRUE; - case EVENT_JSPROPERTY_BUBBLES: - *vp = BOOLEAN_TO_JSVAL(evt->bubbles ? JS_TRUE : JS_FALSE); return JS_TRUE; - case EVENT_JSPROPERTY_CANCELABLE: - *vp = BOOLEAN_TO_JSVAL(evt->cancelable ? JS_TRUE : JS_FALSE); return JS_TRUE; - case EVENT_JSPROPERTY_NAMESPACEURI: - *vp = JSVAL_NULL; - return JS_TRUE; - case EVENT_JSPROPERTY_TIMESTAMP: - *vp = JSVAL_VOID; - return JS_TRUE; - case EVENT_JSPROPERTY_DEFAULTPREVENTED: - *vp = BOOLEAN_TO_JSVAL((evt->event_phase & GF_DOM_EVENT_PHASE_PREVENT) ? JS_TRUE : JS_FALSE); return JS_TRUE; - case EVENT_JSPROPERTY_DETAIL: - *vp = INT_TO_JSVAL(evt->detail); return JS_TRUE; - case EVENT_JSPROPERTY_DATA: - { - u32 len; - s16 txt[2]; - const u16 *srcp; - char szData[5];; - txt[0] = evt->detail; - txt[1] = 0; - srcp = (const u16 *) txt; - len = (u32) gf_utf8_wcstombs(szData, 5, &srcp); - szData[len] = 0; - s = JS_NewStringCopyZ(c, szData); - *vp = STRING_TO_JSVAL( s ); } - return JS_TRUE; + return JS_TRUE; + case EVENT_JSPROPERTY_CURRENTTARGET: + if (evt->is_vrml) return JS_TRUE; + switch (evt->currentTarget->ptr_type) { + case GF_DOM_EVENT_TARGET_NODE: + *vp = dom_element_construct(c, (GF_Node*) evt->currentTarget->ptr); + break; + case GF_DOM_EVENT_TARGET_DOCUMENT: + *vp = dom_document_construct(c, (GF_SceneGraph *) evt->currentTarget->ptr); + break; + case GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE: + *vp = OBJECT_TO_JSVAL(((GF_HTML_MediaSource *)evt->target)->_this); + break; + case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER: + *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBuffer *)evt->target)->_this); + break; + case GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST: + *vp = OBJECT_TO_JSVAL(((GF_HTML_SourceBufferList *)evt->target)->_this); + break; + default: + break; + } + return JS_TRUE; + case EVENT_JSPROPERTY_EVENTPHASE: + *vp = INT_TO_JSVAL( (evt->event_phase & 0x3) ); + return JS_TRUE; + case EVENT_JSPROPERTY_BUBBLES: + *vp = BOOLEAN_TO_JSVAL(evt->bubbles ? JS_TRUE : JS_FALSE); + return JS_TRUE; + case EVENT_JSPROPERTY_CANCELABLE: + *vp = BOOLEAN_TO_JSVAL(evt->cancelable ? JS_TRUE : JS_FALSE); + return JS_TRUE; + case EVENT_JSPROPERTY_NAMESPACEURI: + *vp = JSVAL_NULL; + return JS_TRUE; + case EVENT_JSPROPERTY_TIMESTAMP: + *vp = JSVAL_VOID; + return JS_TRUE; + case EVENT_JSPROPERTY_DEFAULTPREVENTED: + *vp = BOOLEAN_TO_JSVAL((evt->event_phase & GF_DOM_EVENT_PHASE_PREVENT) ? JS_TRUE : JS_FALSE); + return JS_TRUE; + case EVENT_JSPROPERTY_DETAIL: + *vp = INT_TO_JSVAL(evt->detail); + return JS_TRUE; + case EVENT_JSPROPERTY_DATA: + { + u32 len; + s16 txt[2]; + const u16 *srcp; + char szData[5];; + txt[0] = evt->detail; + txt[1] = 0; + srcp = (const u16 *) txt; + len = (u32) gf_utf8_wcstombs(szData, 5, &srcp); + szData[len] = 0; + s = JS_NewStringCopyZ(c, szData); + *vp = STRING_TO_JSVAL( s ); + } + return JS_TRUE; - case EVENT_JSPROPERTY_SCREENX: - *vp = INT_TO_JSVAL(evt->screenX); return JS_TRUE; - case EVENT_JSPROPERTY_SCREENY: - *vp = INT_TO_JSVAL(evt->screenY); return JS_TRUE; - case EVENT_JSPROPERTY_CLIENTX: - *vp = INT_TO_JSVAL(evt->clientX); return JS_TRUE; - case EVENT_JSPROPERTY_CLIENTY: - *vp = INT_TO_JSVAL(evt->clientY); return JS_TRUE; - case EVENT_JSPROPERTY_BUTTON: - *vp = INT_TO_JSVAL(evt->button); return JS_TRUE; - case EVENT_JSPROPERTY_RELATEDTARGET: - if (evt->is_vrml) return JS_TRUE; - *vp = dom_element_construct(c, evt->relatedTarget); - return JS_TRUE; - case EVENT_JSPROPERTY_WHEELDELTA: - *vp = INT_TO_JSVAL(FIX2INT(evt->new_scale) ); return JS_TRUE; + case EVENT_JSPROPERTY_SCREENX: + *vp = INT_TO_JSVAL(evt->screenX); + return JS_TRUE; + case EVENT_JSPROPERTY_SCREENY: + *vp = INT_TO_JSVAL(evt->screenY); + return JS_TRUE; + case EVENT_JSPROPERTY_CLIENTX: + *vp = INT_TO_JSVAL(evt->clientX); + return JS_TRUE; + case EVENT_JSPROPERTY_CLIENTY: + *vp = INT_TO_JSVAL(evt->clientY); + return JS_TRUE; + case EVENT_JSPROPERTY_BUTTON: + *vp = INT_TO_JSVAL(evt->button); + return JS_TRUE; + case EVENT_JSPROPERTY_RELATEDTARGET: + if (evt->is_vrml) return JS_TRUE; + *vp = dom_element_construct(c, evt->relatedTarget); + return JS_TRUE; + case EVENT_JSPROPERTY_WHEELDELTA: + *vp = INT_TO_JSVAL(FIX2INT(evt->new_scale) ); + return JS_TRUE; - case EVENT_JSPROPERTY_KEYIDENTIFIER: - s = JS_NewStringCopyZ(c, gf_dom_get_key_name(evt->detail) ); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - /*Mozilla keyChar, charCode: wrap up to same value*/ - case EVENT_JSPROPERTY_KEYCHAR: - case EVENT_JSPROPERTY_CHARCODE: - *vp = INT_TO_JSVAL(evt->detail); return JS_TRUE; - case EVENT_JSPROPERTY_LOADED: - if (!evt->media_event) return JS_TRUE; - *vp = INT_TO_JSVAL( evt->media_event->loaded_size); - return JS_TRUE; - case EVENT_JSPROPERTY_TOTAL: - if (!evt->media_event) return JS_TRUE; - *vp = INT_TO_JSVAL( evt->media_event->total_size); - return JS_TRUE; - case EVENT_JSPROPERTY_BUFFERLEVELVALID: - if (!evt->media_event) return JS_TRUE; - *vp = BOOLEAN_TO_JSVAL( evt->media_event->bufferValid ? JS_TRUE : JS_FALSE); - return JS_TRUE; - case EVENT_JSPROPERTY_BUFFERLEVEL: - if (!evt->media_event) return JS_TRUE; - *vp = INT_TO_JSVAL( evt->media_event->level); - return JS_TRUE; - case EVENT_JSPROPERTY_BUFFERREMAININGTIME: - if (!evt->media_event) return JS_TRUE; - *vp = JS_MAKE_DOUBLE(c, evt->media_event->remaining_time); - return JS_TRUE; - case EVENT_JSPROPERTY_STATUS: - if (!evt->media_event) return JS_TRUE; - *vp = INT_TO_JSVAL( evt->media_event->status); - return JS_TRUE; + case EVENT_JSPROPERTY_KEYIDENTIFIER: + s = JS_NewStringCopyZ(c, gf_dom_get_key_name(evt->detail) ); + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; + /*Mozilla keyChar, charCode: wrap up to same value*/ + case EVENT_JSPROPERTY_KEYCHAR: + case EVENT_JSPROPERTY_CHARCODE: + *vp = INT_TO_JSVAL(evt->detail); + return JS_TRUE; + case EVENT_JSPROPERTY_LOADED: + if (!evt->media_event) return JS_TRUE; + *vp = INT_TO_JSVAL( evt->media_event->loaded_size); + return JS_TRUE; + case EVENT_JSPROPERTY_TOTAL: + if (!evt->media_event) return JS_TRUE; + *vp = INT_TO_JSVAL( evt->media_event->total_size); + return JS_TRUE; + case EVENT_JSPROPERTY_BUFFERLEVELVALID: + if (!evt->media_event) return JS_TRUE; + *vp = BOOLEAN_TO_JSVAL( evt->media_event->bufferValid ? JS_TRUE : JS_FALSE); + return JS_TRUE; + case EVENT_JSPROPERTY_BUFFERLEVEL: + if (!evt->media_event) return JS_TRUE; + *vp = INT_TO_JSVAL( evt->media_event->level); + return JS_TRUE; + case EVENT_JSPROPERTY_BUFFERREMAININGTIME: + if (!evt->media_event) return JS_TRUE; + *vp = JS_MAKE_DOUBLE(c, evt->media_event->remaining_time); + return JS_TRUE; + case EVENT_JSPROPERTY_STATUS: + if (!evt->media_event) return JS_TRUE; + *vp = INT_TO_JSVAL( evt->media_event->status); + return JS_TRUE; - /*VRML ones*/ - case EVENT_JSPROPERTY_WIDTH: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.width) ); - return JS_TRUE; - case EVENT_JSPROPERTY_HEIGHT: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.height) ); - return JS_TRUE; - case EVENT_JSPROPERTY_OFFSETX: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.x) ); - return JS_TRUE; - case EVENT_JSPROPERTY_OFFSETY: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.y) ); - return JS_TRUE; - case EVENT_JSPROPERTY_VPWIDTH: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->prev_translate.x) ); - return JS_TRUE; - case EVENT_JSPROPERTY_VPHEIGHT: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->prev_translate.y) ); - return JS_TRUE; - case EVENT_JSPROPERTY_TRANSLATIONX: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->new_translate.x) ); - return JS_TRUE; - case EVENT_JSPROPERTY_TRANSLATIONY: - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->new_translate.y) ); - return JS_TRUE; - case EVENT_JSPROPERTY_TYPE3D: - *vp = INT_TO_JSVAL(evt->detail); return JS_TRUE; - case EVENT_JSPROPERTY_ERROR: - *vp = INT_TO_JSVAL(evt->error_state); return JS_TRUE; - case EVENT_JSPROPERTY_DYNAMIC_SCENE: - *vp = INT_TO_JSVAL(evt->key_flags ? 1 : 0); return JS_TRUE; - - default: return JS_TRUE; - } + /*VRML ones*/ + case EVENT_JSPROPERTY_WIDTH: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.width) ); + return JS_TRUE; + case EVENT_JSPROPERTY_HEIGHT: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.height) ); + return JS_TRUE; + case EVENT_JSPROPERTY_OFFSETX: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.x) ); + return JS_TRUE; + case EVENT_JSPROPERTY_OFFSETY: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->screen_rect.y) ); + return JS_TRUE; + case EVENT_JSPROPERTY_VPWIDTH: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->prev_translate.x) ); + return JS_TRUE; + case EVENT_JSPROPERTY_VPHEIGHT: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->prev_translate.y) ); + return JS_TRUE; + case EVENT_JSPROPERTY_TRANSLATIONX: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->new_translate.x) ); + return JS_TRUE; + case EVENT_JSPROPERTY_TRANSLATIONY: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(evt->new_translate.y) ); + return JS_TRUE; + case EVENT_JSPROPERTY_TYPE3D: + *vp = INT_TO_JSVAL(evt->detail); + return JS_TRUE; + case EVENT_JSPROPERTY_ERROR: + *vp = INT_TO_JSVAL(evt->error_state); + return JS_TRUE; + case EVENT_JSPROPERTY_DYNAMIC_SCENE: + *vp = INT_TO_JSVAL(evt->key_flags ? 1 : 0); + return JS_TRUE; + + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } /************************************************************ @@ -2645,7 +2673,7 @@ struct __xhr_context GF_DownloadSession *sess; char *data; u32 size; - JSObject *arraybuffer; + JSObject *arraybuffer; GF_Err ret_code; u32 html_status; char *statusText; @@ -2715,43 +2743,43 @@ static void xml_http_append_send_header(XMLHTTPContext *ctx, char *hdr, char *va } /*ignore these ones*/ if (!stricmp(hdr, "Accept-Charset") - || !stricmp(hdr, "Accept-Encoding") - || !stricmp(hdr, "Content-Length") - || !stricmp(hdr, "Expect") - || !stricmp(hdr, "Date") - || !stricmp(hdr, "Host") - || !stricmp(hdr, "Keep-Alive") - || !stricmp(hdr, "Referer") - || !stricmp(hdr, "TE") - || !stricmp(hdr, "Trailer") - || !stricmp(hdr, "Transfer-Encoding") - || !stricmp(hdr, "Upgrade") - ) { + || !stricmp(hdr, "Accept-Encoding") + || !stricmp(hdr, "Content-Length") + || !stricmp(hdr, "Expect") + || !stricmp(hdr, "Date") + || !stricmp(hdr, "Host") + || !stricmp(hdr, "Keep-Alive") + || !stricmp(hdr, "Referer") + || !stricmp(hdr, "TE") + || !stricmp(hdr, "Trailer") + || !stricmp(hdr, "Transfer-Encoding") + || !stricmp(hdr, "Upgrade") + ) { return; } /*replace content for these ones*/ if (!stricmp(hdr, "Authorization") - || !stricmp(hdr, "Content-Base") - || !stricmp(hdr, "Content-Location") - || !stricmp(hdr, "Content-MD5") - || !stricmp(hdr, "Content-Range") - || !stricmp(hdr, "Content-Type") - || !stricmp(hdr, "Content-Version") - || !stricmp(hdr, "Delta-Base") - || !stricmp(hdr, "Depth") - || !stricmp(hdr, "Destination") - || !stricmp(hdr, "ETag") - || !stricmp(hdr, "From") - || !stricmp(hdr, "If-Modified-Since") - || !stricmp(hdr, "If-Range") - || !stricmp(hdr, "If-Unmodified-Since") - || !stricmp(hdr, "Max-Forwards") - || !stricmp(hdr, "MIME-Version") - || !stricmp(hdr, "Overwrite") - || !stricmp(hdr, "Proxy-Authorization") - || !stricmp(hdr, "SOAPAction") - || !stricmp(hdr, "Timeout") ) { + || !stricmp(hdr, "Content-Base") + || !stricmp(hdr, "Content-Location") + || !stricmp(hdr, "Content-MD5") + || !stricmp(hdr, "Content-Range") + || !stricmp(hdr, "Content-Type") + || !stricmp(hdr, "Content-Version") + || !stricmp(hdr, "Delta-Base") + || !stricmp(hdr, "Depth") + || !stricmp(hdr, "Destination") + || !stricmp(hdr, "ETag") + || !stricmp(hdr, "From") + || !stricmp(hdr, "If-Modified-Since") + || !stricmp(hdr, "If-Range") + || !stricmp(hdr, "If-Unmodified-Since") + || !stricmp(hdr, "Max-Forwards") + || !stricmp(hdr, "MIME-Version") + || !stricmp(hdr, "Overwrite") + || !stricmp(hdr, "Proxy-Authorization") + || !stricmp(hdr, "SOAPAction") + || !stricmp(hdr, "Timeout") ) { gf_free(ctx->headers[nb_hdr+1]); ctx->headers[nb_hdr+1] = gf_strdup(val); return; @@ -2815,8 +2843,14 @@ static void xml_http_reset_partial(XMLHTTPContext *ctx) static void xml_http_reset(XMLHTTPContext *ctx) { - if (ctx->method) { gf_free(ctx->method); ctx->method = NULL; } - if (ctx->url) { gf_free(ctx->url); ctx->url = NULL; } + if (ctx->method) { + gf_free(ctx->method); + ctx->method = NULL; + } + if (ctx->url) { + gf_free(ctx->url); + ctx->url = NULL; + } xml_http_reset_partial(ctx); @@ -2857,23 +2891,23 @@ static void xml_http_reset(XMLHTTPContext *ctx) static DECL_FINALIZE(xml_http_finalize) - XMLHTTPContext *ctx; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return; - ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); - if (ctx) { - if (! JSVAL_IS_NULL(ctx->onabort)) gf_js_remove_root(c, &(ctx->onabort), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onerror)) gf_js_remove_root(c, &(ctx->onerror), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onload)) gf_js_remove_root(c, &(ctx->onload), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onloadend)) gf_js_remove_root(c, &(ctx->onloadend), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onloadstart)) gf_js_remove_root(c, &(ctx->onloadstart), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onprogress)) gf_js_remove_root(c, &(ctx->onprogress), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->onreadystatechange)) gf_js_remove_root(c, &(ctx->onreadystatechange), GF_JSGC_VAL); - if (! JSVAL_IS_NULL(ctx->ontimeout)) gf_js_remove_root(c, &(ctx->ontimeout), GF_JSGC_VAL); - xml_http_reset(ctx); - gf_dom_event_target_del(ctx->event_target); - ctx->event_target = NULL; - gf_free(ctx); - } +XMLHTTPContext *ctx; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return; +ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); +if (ctx) { + if (! JSVAL_IS_NULL(ctx->onabort)) gf_js_remove_root(c, &(ctx->onabort), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onerror)) gf_js_remove_root(c, &(ctx->onerror), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onload)) gf_js_remove_root(c, &(ctx->onload), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onloadend)) gf_js_remove_root(c, &(ctx->onloadend), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onloadstart)) gf_js_remove_root(c, &(ctx->onloadstart), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onprogress)) gf_js_remove_root(c, &(ctx->onprogress), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->onreadystatechange)) gf_js_remove_root(c, &(ctx->onreadystatechange), GF_JSGC_VAL); + if (! JSVAL_IS_NULL(ctx->ontimeout)) gf_js_remove_root(c, &(ctx->ontimeout), GF_JSGC_VAL); + xml_http_reset(ctx); + gf_dom_event_target_del(ctx->event_target); + ctx->event_target = NULL; + gf_free(ctx); +} } static JSBool SMJS_FUNCTION(xml_http_constructor) { @@ -2886,6 +2920,15 @@ static JSBool SMJS_FUNCTION(xml_http_constructor) p->_this = obj; p->owning_graph = xml_get_scenegraph(c); p->event_target = gf_dom_event_target_new(GF_DOM_EVENT_TARGET_XHR, p); + p->onabort = JSVAL_NULL; + p->onerror = JSVAL_NULL; + p->onreadystatechange = JSVAL_NULL; + p->onload = JSVAL_NULL; + p->onloadstart = JSVAL_NULL; + p->onloadend = JSVAL_NULL; + p->onprogress = JSVAL_NULL; + p->ontimeout = JSVAL_NULL; + SMJS_SET_PRIVATE(c, obj, p); SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); return JS_TRUE; @@ -2906,7 +2949,7 @@ static void xml_http_state_change(XMLHTTPContext *ctx) GF_SceneGraph *scene; GF_Node *n; jsval rval; - + gf_sg_lock_javascript(ctx->c, GF_TRUE); if (! JSVAL_IS_NULL(ctx->onreadystatechange)) JS_CallFunctionValue(ctx->c, ctx->_this, ctx->onreadystatechange, 0, NULL, &rval); @@ -2949,13 +2992,13 @@ static JSBool SMJS_FUNCTION(xml_http_open) xml_http_reset(ctx); val = SMJS_CHARS(c, argv[0]); if (strcmp(val, "GET") && strcmp(val, "POST") && strcmp(val, "HEAD") - && strcmp(val, "PUT") && strcmp(val, "DELETE") && strcmp(val, "OPTIONS") ) { + && strcmp(val, "PUT") && strcmp(val, "DELETE") && strcmp(val, "OPTIONS") ) { SMJS_FREE(c, val); return JS_TRUE; } ctx->method = gf_strdup(val); - + SMJS_FREE(c, val); /*concatenate URL*/ @@ -3093,7 +3136,7 @@ static void xml_http_sax_text(void *sax_cbck, const char *content, Bool is_cdata #define USE_PROGRESSIVE_SAX 0 -static void xml_http_terminate(XMLHTTPContext *ctx, GF_Err error) +static void xml_http_terminate(XMLHTTPContext *ctx, GF_Err error) { /*if we get here, destroy downloader - FIXME we'll need a mutex here for sync case...*/ if (ctx->sess) { @@ -3129,14 +3172,14 @@ static void xml_http_on_data(void *usr_cbk, GF_NETIO_Parameter *parameter) /*make sure we can grab JS and the session is not destroyed*/ while (ctx->sess) { - if (gf_sg_try_lock_javascript(ctx->c) ){ + if (gf_sg_try_lock_javascript(ctx->c) ) { locked = GF_TRUE; break; } gf_sleep(1); } /*if session not set, we've had an abort*/ - if (!ctx->sess && !ctx->isFile){ + if (!ctx->sess && !ctx->isFile) { if (locked) gf_sg_lock_javascript(ctx->c, GF_FALSE); return; @@ -3202,18 +3245,18 @@ static void xml_http_on_data(void *usr_cbk, GF_NETIO_Parameter *parameter) /*prepare DOM*/ if (strcmp(parameter->name, "Content-Type")) return; if (!strncmp(parameter->value, "application/xml", 15) - || !strncmp(parameter->value, "text/xml", 8) - || strstr(parameter->value, "+xml") - || strstr(parameter->value, "/xml") + || !strncmp(parameter->value, "text/xml", 8) + || strstr(parameter->value, "+xml") + || strstr(parameter->value, "/xml") // || !strncmp(parameter->value, "text/plain", 10) - ) { + ) { assert(!ctx->sax); ctx->sax = gf_xml_sax_new(xml_http_sax_start, xml_http_sax_end, xml_http_sax_text, ctx); ctx->node_stack = gf_list_new(); ctx->document = gf_sg_new(); /*mark this doc as "nomade", and let it leave until all references to it are destroyed*/ ctx->document->reference_count = 1; - } + } return; case GF_NETIO_DATA_EXCHANGE: if (parameter->data && parameter->size) { @@ -3261,7 +3304,7 @@ static GF_Err xml_http_process_local(XMLHTTPContext *ctx) GF_NETIO_Parameter par; u64 fsize; FILE *responseFile; - + /*opera-style local host*/ if (!strnicmp(ctx->url, "file://localhost", 16)) responseFile = gf_f64_open(ctx->url+16, "rb"); /*regular-style local host*/ @@ -3283,17 +3326,17 @@ static GF_Err xml_http_process_local(XMLHTTPContext *ctx) par.msg_type = GF_NETIO_WAIT_FOR_REPLY; xml_http_on_data(ctx, &par); - + gf_f64_seek(responseFile, 0, SEEK_END); fsize = gf_f64_tell(responseFile); gf_f64_seek(responseFile, 0, SEEK_SET); - + ctx->data = (char *)gf_malloc(sizeof(char)*(size_t)(fsize+1)); fsize = fread(ctx->data, sizeof(char), (size_t)fsize, responseFile); fclose(responseFile); ctx->data[fsize] = 0; ctx->size = (u32)fsize; - + memset(&par, 0, sizeof(GF_NETIO_Parameter)); par.msg_type = GF_NETIO_PARSE_HEADER; par.name = "Content-Type"; @@ -3316,7 +3359,7 @@ static GF_Err xml_http_process_local(XMLHTTPContext *ctx) memset(&par, 0, sizeof(GF_NETIO_Parameter)); par.msg_type = GF_NETIO_DATA_TRANSFERED; - xml_http_on_data(ctx, &par); + xml_http_on_data(ctx, &par); if (!ctx->async) { xml_http_terminate(ctx, GF_OK); @@ -3366,17 +3409,17 @@ static JSBool SMJS_FUNCTION(xml_http_send) if (!strncmp(ctx->url, "http://", 7)) { u32 flags; - + flags = ctx->async ? 0 : GF_NETIO_SESSION_NOT_THREADED; if (ctx->cache != XHR_CACHETYPE_NORMAL) { if (ctx->cache == XHR_CACHETYPE_NONE) { flags |= GF_NETIO_SESSION_NOT_CACHED; - } + } if (ctx->cache == XHR_CACHETYPE_MEMORY) { flags |= GF_NETIO_SESSION_MEMORY_CACHE; } } - ctx->sess = gf_dm_sess_new(par.dnld_man, ctx->url, flags, xml_http_on_data, ctx, &e); + ctx->sess = gf_dm_sess_new(par.dnld_man, ctx->url, flags, xml_http_on_data, ctx, &e); if (!ctx->sess) return JS_TRUE; /*start our download (whether the session is threaded or not)*/ @@ -3523,191 +3566,191 @@ static JSBool SMJS_FUNCTION(xml_http_overrideMimeType) static SMJS_FUNC_PROP_GET(xml_http_getProperty) - JSString *s; - XMLHTTPContext *ctx; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); - if (!ctx) return JS_TRUE; +JSString *s; +XMLHTTPContext *ctx; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; +ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); +if (!ctx) return JS_TRUE; - s = NULL; - if (SMJS_ID_IS_INT(id)) { - *vp = JSVAL_VOID; - switch (SMJS_ID_TO_INT(id)) { - case XHR_ONABORT: - if (! JSVAL_IS_NULL(ctx->onabort)) { - *vp = ctx->onabort; - } - return JS_TRUE; - case XHR_ONERROR: - if (! JSVAL_IS_NULL(ctx->onerror)) { - *vp = ctx->onerror; - } - return JS_TRUE; - case XHR_ONLOAD: - if (! JSVAL_IS_NULL(ctx->onload)) { - *vp = ctx->onload; - } - return JS_TRUE; - case XHR_ONLOADSTART: - if (! JSVAL_IS_NULL(ctx->onloadstart) ) { - *vp = ctx->onloadstart; - } - return JS_TRUE; - case XHR_ONLOADEND: - if (! JSVAL_IS_NULL(ctx->onloadend)) { - *vp = ctx->onloadend; - } - return JS_TRUE; - case XHR_ONPROGRESS: - if (! JSVAL_IS_NULL(ctx->onprogress) ) { - *vp = ctx->onprogress; - } - return JS_TRUE; - case XHR_ONREADYSTATECHANGE: - if (! JSVAL_IS_NULL(ctx->onreadystatechange)) { - *vp = ctx->onreadystatechange; - } - return JS_TRUE; - case XHR_ONTIMEOUT: - if (! JSVAL_IS_NULL(ctx->ontimeout)) { - *vp = ctx->ontimeout; - } - return JS_TRUE; - case XHR_READYSTATE: - *vp = INT_TO_JSVAL(ctx->readyState); - return JS_TRUE; - case XHR_RESPONSETEXT: - if (ctx->readyStatedata) { - s = JS_NewStringCopyZ(c, ctx->data); - *vp = STRING_TO_JSVAL( s ); - } else { - *vp = JSVAL_VOID; - } - return JS_TRUE; - case XHR_RESPONSEXML: - if (ctx->readyStatedata && ctx->document) { - *vp = dom_document_construct(c, ctx->document); - } else { - *vp = JSVAL_VOID; - } - return JS_TRUE; - case XHR_RESPONSE: - if (ctx->readyStatedata) { - switch(ctx->responseType) - { - case XHR_RESPONSETYPE_NONE: - case XHR_RESPONSETYPE_TEXT: - s = JS_NewStringCopyZ(c, ctx->data); - *vp = STRING_TO_JSVAL( s ); - break; - case XHR_RESPONSETYPE_ARRAYBUFFER: - if (!ctx->arraybuffer) { - /* always return the same ArrayBuffer, is this correct? Probably not in chunked/loading mode */ - ctx->arraybuffer = gf_arraybuffer_js_new(c, ctx->data, ctx->size, obj); - } - *vp = OBJECT_TO_JSVAL( ctx->arraybuffer ); - break; - case XHR_RESPONSETYPE_DOCUMENT: - if (ctx->data && ctx->document) { - *vp = dom_document_construct(c, ctx->document); - } else { - *vp = JSVAL_VOID; - } - break; - default: - /*other types not supported */ - *vp = JSVAL_VOID; - } - } else { - *vp = JSVAL_VOID; - } - return JS_TRUE; - case XHR_STATUS: - *vp = INT_TO_JSVAL(ctx->html_status); - return JS_TRUE; - case XHR_STATUSTEXT: - if (ctx->statusText) { - s = JS_NewStringCopyZ(c, ctx->statusText); - *vp = STRING_TO_JSVAL( s ); - } else { - *vp = JSVAL_VOID; - } - return JS_TRUE; - case XHR_TIMEOUT: - *vp = INT_TO_JSVAL(ctx->timeout); - return JS_TRUE; - case XHR_WITHCREDENTIALS: - *vp = BOOLEAN_TO_JSVAL(ctx->withCredentials ? JS_TRUE : JS_FALSE); - return JS_TRUE; - case XHR_UPLOAD: - /* TODO */ - return JS_TRUE; - case XHR_RESPONSETYPE: - switch (ctx->responseType) - { - case XHR_RESPONSETYPE_NONE: - s = JS_NewStringCopyZ(c, ""); - break; - case XHR_RESPONSETYPE_ARRAYBUFFER: - s = JS_NewStringCopyZ(c, "arraybuffer"); - break; - case XHR_RESPONSETYPE_BLOB: - s = JS_NewStringCopyZ(c, "blob"); - break; - case XHR_RESPONSETYPE_DOCUMENT: - s = JS_NewStringCopyZ(c, "document"); - break; - case XHR_RESPONSETYPE_JSON: - s = JS_NewStringCopyZ(c, "json"); - break; - case XHR_RESPONSETYPE_TEXT: - s = JS_NewStringCopyZ(c, "text"); - break; - case XHR_RESPONSETYPE_STREAM: - s = JS_NewStringCopyZ(c, "stream"); - break; - } +s = NULL; +if (SMJS_ID_IS_INT(id)) { + *vp = JSVAL_VOID; + switch (SMJS_ID_TO_INT(id)) { + case XHR_ONABORT: + if (! JSVAL_IS_NULL(ctx->onabort)) { + *vp = ctx->onabort; + } + return JS_TRUE; + case XHR_ONERROR: + if (! JSVAL_IS_NULL(ctx->onerror)) { + *vp = ctx->onerror; + } + return JS_TRUE; + case XHR_ONLOAD: + if (! JSVAL_IS_NULL(ctx->onload)) { + *vp = ctx->onload; + } + return JS_TRUE; + case XHR_ONLOADSTART: + if (! JSVAL_IS_NULL(ctx->onloadstart) ) { + *vp = ctx->onloadstart; + } + return JS_TRUE; + case XHR_ONLOADEND: + if (! JSVAL_IS_NULL(ctx->onloadend)) { + *vp = ctx->onloadend; + } + return JS_TRUE; + case XHR_ONPROGRESS: + if (! JSVAL_IS_NULL(ctx->onprogress) ) { + *vp = ctx->onprogress; + } + return JS_TRUE; + case XHR_ONREADYSTATECHANGE: + if (! JSVAL_IS_NULL(ctx->onreadystatechange)) { + *vp = ctx->onreadystatechange; + } + return JS_TRUE; + case XHR_ONTIMEOUT: + if (! JSVAL_IS_NULL(ctx->ontimeout)) { + *vp = ctx->ontimeout; + } + return JS_TRUE; + case XHR_READYSTATE: + *vp = INT_TO_JSVAL(ctx->readyState); + return JS_TRUE; + case XHR_RESPONSETEXT: + if (ctx->readyStatedata) { + s = JS_NewStringCopyZ(c, ctx->data); *vp = STRING_TO_JSVAL( s ); + } else { + *vp = JSVAL_VOID; + } + return JS_TRUE; + case XHR_RESPONSEXML: + if (ctx->readyStatedata && ctx->document) { + *vp = dom_document_construct(c, ctx->document); + } else { + *vp = JSVAL_VOID; + } + return JS_TRUE; + case XHR_RESPONSE: + if (ctx->readyStatecache) { - case XHR_CACHETYPE_NORMAL: - s = JS_NewStringCopyZ(c, "normal"); + } + if (ctx->data) { + switch(ctx->responseType) + { + case XHR_RESPONSETYPE_NONE: + case XHR_RESPONSETYPE_TEXT: + s = JS_NewStringCopyZ(c, ctx->data); + *vp = STRING_TO_JSVAL( s ); break; - case XHR_CACHETYPE_NONE: - s = JS_NewStringCopyZ(c, "none"); + case XHR_RESPONSETYPE_ARRAYBUFFER: + if (!ctx->arraybuffer) { + /* always return the same ArrayBuffer, is this correct? Probably not in chunked/loading mode */ + ctx->arraybuffer = gf_arraybuffer_js_new(c, ctx->data, ctx->size, obj); + } + *vp = OBJECT_TO_JSVAL( ctx->arraybuffer ); break; - case XHR_CACHETYPE_MEMORY: - s = JS_NewStringCopyZ(c, "memory"); + case XHR_RESPONSETYPE_DOCUMENT: + if (ctx->data && ctx->document) { + *vp = dom_document_construct(c, ctx->document); + } else { + *vp = JSVAL_VOID; + } break; + default: + /*other types not supported */ + *vp = JSVAL_VOID; } - *vp = STRING_TO_JSVAL(s); - return JS_TRUE; - default: - return JS_TRUE; + } else { + *vp = JSVAL_VOID; + } + return JS_TRUE; + case XHR_STATUS: + *vp = INT_TO_JSVAL(ctx->html_status); + return JS_TRUE; + case XHR_STATUSTEXT: + if (ctx->statusText) { + s = JS_NewStringCopyZ(c, ctx->statusText); + *vp = STRING_TO_JSVAL( s ); + } else { + *vp = JSVAL_VOID; + } + return JS_TRUE; + case XHR_TIMEOUT: + *vp = INT_TO_JSVAL(ctx->timeout); + return JS_TRUE; + case XHR_WITHCREDENTIALS: + *vp = BOOLEAN_TO_JSVAL(ctx->withCredentials ? JS_TRUE : JS_FALSE); + return JS_TRUE; + case XHR_UPLOAD: + /* TODO */ + return JS_TRUE; + case XHR_RESPONSETYPE: + switch (ctx->responseType) + { + case XHR_RESPONSETYPE_NONE: + s = JS_NewStringCopyZ(c, ""); + break; + case XHR_RESPONSETYPE_ARRAYBUFFER: + s = JS_NewStringCopyZ(c, "arraybuffer"); + break; + case XHR_RESPONSETYPE_BLOB: + s = JS_NewStringCopyZ(c, "blob"); + break; + case XHR_RESPONSETYPE_DOCUMENT: + s = JS_NewStringCopyZ(c, "document"); + break; + case XHR_RESPONSETYPE_JSON: + s = JS_NewStringCopyZ(c, "json"); + break; + case XHR_RESPONSETYPE_TEXT: + s = JS_NewStringCopyZ(c, "text"); + break; + case XHR_RESPONSETYPE_STREAM: + s = JS_NewStringCopyZ(c, "stream"); + break; + } + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; + case XHR_STATIC_UNSENT: + *vp = INT_TO_JSVAL(XHR_READYSTATE_UNSENT); + return JS_TRUE; + case XHR_STATIC_OPENED: + *vp = INT_TO_JSVAL(XHR_READYSTATE_OPENED); + return JS_TRUE; + case XHR_STATIC_HEADERS_RECEIVED: + *vp = INT_TO_JSVAL(XHR_READYSTATE_HEADERS_RECEIVED); + return JS_TRUE; + case XHR_STATIC_LOADING: + *vp = INT_TO_JSVAL(XHR_READYSTATE_LOADING); + return JS_TRUE; + case XHR_STATIC_DONE: + *vp = INT_TO_JSVAL(XHR_READYSTATE_DONE); + return JS_TRUE; + case XHR_CACHE: + switch (ctx->cache) { + case XHR_CACHETYPE_NORMAL: + s = JS_NewStringCopyZ(c, "normal"); + break; + case XHR_CACHETYPE_NONE: + s = JS_NewStringCopyZ(c, "none"); + break; + case XHR_CACHETYPE_MEMORY: + s = JS_NewStringCopyZ(c, "memory"); + break; } + *vp = STRING_TO_JSVAL(s); + return JS_TRUE; + default: + return JS_TRUE; } - return SMJS_CALL_PROP_STUB(); +} +return SMJS_CALL_PROP_STUB(); } JSBool gf_set_js_eventhandler(JSContext *c, jsval vp, jsval *callbackfuncval) { @@ -3734,231 +3777,231 @@ JSBool gf_set_js_eventhandler(JSContext *c, jsval vp, jsval *callbackfuncval) { static SMJS_FUNC_PROP_SET( xml_http_setProperty) - XMLHTTPContext *ctx; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); - if (!ctx) return JS_TRUE; +XMLHTTPContext *ctx; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; +ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); +if (!ctx) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case XHR_ONERROR: - gf_set_js_eventhandler(c, *vp, &ctx->onerror); - break; - case XHR_ONABORT: - gf_set_js_eventhandler(c, *vp, &ctx->onabort); - break; - case XHR_ONLOAD: - gf_set_js_eventhandler(c, *vp, &ctx->onload); - break; - case XHR_ONLOADSTART: - gf_set_js_eventhandler(c, *vp, &ctx->onloadstart); - break; - case XHR_ONLOADEND: - gf_set_js_eventhandler(c, *vp, &ctx->onloadend); - break; - case XHR_ONPROGRESS: - gf_set_js_eventhandler(c, *vp, &ctx->onprogress); - break; - case XHR_ONREADYSTATECHANGE: - gf_set_js_eventhandler(c, *vp, &ctx->onreadystatechange); - break; - case XHR_ONTIMEOUT: - gf_set_js_eventhandler(c, *vp, &ctx->ontimeout); - break; - case XHR_TIMEOUT: - ctx->timeout = JSVAL_TO_INT(*vp); - return JS_TRUE; - case XHR_WITHCREDENTIALS: - ctx->withCredentials = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); - return JS_TRUE; - case XHR_RESPONSETYPE: - { - char *str = SMJS_CHARS(c, *vp); - if (!str) return JS_TRUE; - if (!strcmp(str, "")) { - ctx->responseType = XHR_RESPONSETYPE_NONE; - } else if (!strcmp(str, "arraybuffer")) { - ctx->responseType = XHR_RESPONSETYPE_ARRAYBUFFER; - } else if (!strcmp(str, "blob")) { - ctx->responseType = XHR_RESPONSETYPE_BLOB; - } else if (!strcmp(str, "document")) { - ctx->responseType = XHR_RESPONSETYPE_DOCUMENT; - } else if (!strcmp(str, "json")) { - ctx->responseType = XHR_RESPONSETYPE_JSON; - } else if (!strcmp(str, "text")) { - ctx->responseType = XHR_RESPONSETYPE_TEXT; - } else if (!strcmp(str, "stream")) { - ctx->responseType = XHR_RESPONSETYPE_STREAM; - } - break; - return JS_TRUE; - } - case XHR_CACHE: - { - char *str = SMJS_CHARS(c, *vp); - if (!str) return JS_TRUE; - if (!strcmp(str, "normal")) { - ctx->cache = XHR_CACHETYPE_NORMAL; - } else if (!strcmp(str, "none")) { - ctx->cache = XHR_CACHETYPE_NONE; - } else if (!strcmp(str, "memory")) { - ctx->cache = XHR_CACHETYPE_MEMORY; - } - break; - return JS_TRUE; - } - /*all other properties are read-only*/ - default: - return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case XHR_ONERROR: + gf_set_js_eventhandler(c, *vp, &ctx->onerror); + break; + case XHR_ONABORT: + gf_set_js_eventhandler(c, *vp, &ctx->onabort); + break; + case XHR_ONLOAD: + gf_set_js_eventhandler(c, *vp, &ctx->onload); + break; + case XHR_ONLOADSTART: + gf_set_js_eventhandler(c, *vp, &ctx->onloadstart); + break; + case XHR_ONLOADEND: + gf_set_js_eventhandler(c, *vp, &ctx->onloadend); + break; + case XHR_ONPROGRESS: + gf_set_js_eventhandler(c, *vp, &ctx->onprogress); + break; + case XHR_ONREADYSTATECHANGE: + gf_set_js_eventhandler(c, *vp, &ctx->onreadystatechange); + break; + case XHR_ONTIMEOUT: + gf_set_js_eventhandler(c, *vp, &ctx->ontimeout); + break; + case XHR_TIMEOUT: + ctx->timeout = JSVAL_TO_INT(*vp); + return JS_TRUE; + case XHR_WITHCREDENTIALS: + ctx->withCredentials = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); + return JS_TRUE; + case XHR_RESPONSETYPE: + { + char *str = SMJS_CHARS(c, *vp); + if (!str) return JS_TRUE; + if (!strcmp(str, "")) { + ctx->responseType = XHR_RESPONSETYPE_NONE; + } else if (!strcmp(str, "arraybuffer")) { + ctx->responseType = XHR_RESPONSETYPE_ARRAYBUFFER; + } else if (!strcmp(str, "blob")) { + ctx->responseType = XHR_RESPONSETYPE_BLOB; + } else if (!strcmp(str, "document")) { + ctx->responseType = XHR_RESPONSETYPE_DOCUMENT; + } else if (!strcmp(str, "json")) { + ctx->responseType = XHR_RESPONSETYPE_JSON; + } else if (!strcmp(str, "text")) { + ctx->responseType = XHR_RESPONSETYPE_TEXT; + } else if (!strcmp(str, "stream")) { + ctx->responseType = XHR_RESPONSETYPE_STREAM; } + break; + return JS_TRUE; + } + case XHR_CACHE: + { + char *str = SMJS_CHARS(c, *vp); + if (!str) return JS_TRUE; + if (!strcmp(str, "normal")) { + ctx->cache = XHR_CACHETYPE_NORMAL; + } else if (!strcmp(str, "none")) { + ctx->cache = XHR_CACHETYPE_NONE; + } else if (!strcmp(str, "memory")) { + ctx->cache = XHR_CACHETYPE_MEMORY; + } + break; + return JS_TRUE; + } + /*all other properties are read-only*/ + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(dcci_getProperty) - GF_DOMFullAttribute *att; - GF_ChildNodeItem *child; - GF_DOMFullNode *n; - char *value; - JSString *s; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; - n = (GF_DOMFullNode*) dom_get_node(c, obj); - if (!n) return JS_TRUE; +GF_DOMFullAttribute *att; +GF_ChildNodeItem *child; +GF_DOMFullNode *n; +char *value; +JSString *s; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; +n = (GF_DOMFullNode*) dom_get_node(c, obj); +if (!n) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case DCCI_JSPROPERTY_VALUE: - child = n->children; - while (child) { - if (child->node && (child->node->sgprivate->tag==TAG_DOMText)) { - GF_DOMText *txt = (GF_DOMText *)child->node; - if (txt->type==GF_DOM_TEXT_REGULAR) { - s = JS_NewStringCopyZ(c, txt->textContent); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - } +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case DCCI_JSPROPERTY_VALUE: + child = n->children; + while (child) { + if (child->node && (child->node->sgprivate->tag==TAG_DOMText)) { + GF_DOMText *txt = (GF_DOMText *)child->node; + if (txt->type==GF_DOM_TEXT_REGULAR) { + s = JS_NewStringCopyZ(c, txt->textContent); + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; } - child = child->next; } - *vp = JSVAL_NULL; - return JS_TRUE; - case DCCI_JSPROPERTY_VALUETYPE: - value = "DOMString"; - att = (GF_DOMFullAttribute*) n->attributes; - while (att) { - if (att->name && !strcmp(att->name, "valueType") && att->data) { - value = (char *)att->data; - break; - } - att = (GF_DOMFullAttribute*) att->next; + child = child->next; + } + *vp = JSVAL_NULL; + return JS_TRUE; + case DCCI_JSPROPERTY_VALUETYPE: + value = "DOMString"; + att = (GF_DOMFullAttribute*) n->attributes; + while (att) { + if (att->name && !strcmp(att->name, "valueType") && att->data) { + value = (char *)att->data; + break; } - s = JS_NewStringCopyZ(c, value); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - case DCCI_JSPROPERTY_PROPERTYTYPE: - value = "DOMString"; - att = (GF_DOMFullAttribute*) n->attributes; - while (att) { - if (att->name && !strcmp(att->name, "propertyType") && att->data) { - value = (char *)att->data; - break; - } - att = (GF_DOMFullAttribute*) att->next; + att = (GF_DOMFullAttribute*) att->next; + } + s = JS_NewStringCopyZ(c, value); + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; + case DCCI_JSPROPERTY_PROPERTYTYPE: + value = "DOMString"; + att = (GF_DOMFullAttribute*) n->attributes; + while (att) { + if (att->name && !strcmp(att->name, "propertyType") && att->data) { + value = (char *)att->data; + break; } - s = JS_NewStringCopyZ(c, value); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - case DCCI_JSPROPERTY_READONLY: - att = (GF_DOMFullAttribute*) n->attributes; - while (att) { - if (att->name && !strcmp(att->name, "readOnly") && att->data && !strcmp((const char *)att->data, "true")) { - *vp = BOOLEAN_TO_JSVAL(JS_TRUE); - return JS_TRUE; - } - att = (GF_DOMFullAttribute*) att->next; + att = (GF_DOMFullAttribute*) att->next; + } + s = JS_NewStringCopyZ(c, value); + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; + case DCCI_JSPROPERTY_READONLY: + att = (GF_DOMFullAttribute*) n->attributes; + while (att) { + if (att->name && !strcmp(att->name, "readOnly") && att->data && !strcmp((const char *)att->data, "true")) { + *vp = BOOLEAN_TO_JSVAL(JS_TRUE); + return JS_TRUE; } - *vp = BOOLEAN_TO_JSVAL(JS_FALSE); - return JS_TRUE; - case DCCI_JSPROPERTY_DCCIMETADATAINTERFACETYPE: - *vp = JSVAL_NULL; - return JS_TRUE; - case DCCI_JSPROPERTY_DCCIMETADATAINTERFACE: - *vp = JSVAL_NULL; - return JS_TRUE; - case DCCI_JSPROPERTY_VERSION: - s = JS_NewStringCopyZ(c, "1.0"); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - default: - return JS_TRUE; + att = (GF_DOMFullAttribute*) att->next; } + *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + return JS_TRUE; + case DCCI_JSPROPERTY_DCCIMETADATAINTERFACETYPE: + *vp = JSVAL_NULL; + return JS_TRUE; + case DCCI_JSPROPERTY_DCCIMETADATAINTERFACE: + *vp = JSVAL_NULL; + return JS_TRUE; + case DCCI_JSPROPERTY_VERSION: + s = JS_NewStringCopyZ(c, "1.0"); + *vp = STRING_TO_JSVAL( s ); + return JS_TRUE; + default: + return JS_TRUE; } - return SMJS_CALL_PROP_STUB(); +} +return SMJS_CALL_PROP_STUB(); } static SMJS_FUNC_PROP_SET( dcci_setProperty) - GF_ChildNodeItem *child; - GF_DOMFullNode *n; - GF_DOMFullAttribute*att; - GF_DOM_Event evt; - char *str; - Bool readonly; - if (!GF_JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; - n = (GF_DOMFullNode*) dom_get_node(c, obj); - if (!n) return JS_TRUE; +GF_ChildNodeItem *child; +GF_DOMFullNode *n; +GF_DOMFullAttribute*att; +GF_DOM_Event evt; +char *str; +Bool readonly; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; +n = (GF_DOMFullNode*) dom_get_node(c, obj); +if (!n) return JS_TRUE; - str = SMJS_CHARS(c, *vp); - if (!str) return JS_TRUE; - - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case DCCI_JSPROPERTY_VALUE: - readonly = GF_FALSE; - att = (GF_DOMFullAttribute*) n->attributes; - while (att) { - if (att->name && !strcmp(att->name, "readOnly") && att->data && !strcmp((const char *)att->data, "true")) { - readonly = GF_TRUE; - break; - } - att = (GF_DOMFullAttribute*) att->next; +str = SMJS_CHARS(c, *vp); +if (!str) return JS_TRUE; + +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case DCCI_JSPROPERTY_VALUE: + readonly = GF_FALSE; + att = (GF_DOMFullAttribute*) n->attributes; + while (att) { + if (att->name && !strcmp(att->name, "readOnly") && att->data && !strcmp((const char *)att->data, "true")) { + readonly = GF_TRUE; + break; } - if (readonly) break; - child = n->children; - while (child) { - if (child->node && (child->node->sgprivate->tag==TAG_DOMText)) { - GF_DOMText *txt = (GF_DOMText *)child->node; - if (txt->type==GF_DOM_TEXT_REGULAR) { - if (txt->textContent) gf_free(txt->textContent); - txt->textContent = gf_strdup(str); - break; + att = (GF_DOMFullAttribute*) att->next; + } + if (readonly) break; + child = n->children; + while (child) { + if (child->node && (child->node->sgprivate->tag==TAG_DOMText)) { + GF_DOMText *txt = (GF_DOMText *)child->node; + if (txt->type==GF_DOM_TEXT_REGULAR) { + if (txt->textContent) gf_free(txt->textContent); + txt->textContent = gf_strdup(str); + break; - } } - child = child->next; } - if (!child) - gf_dom_add_text_node((GF_Node*)n, gf_strdup(str) ); + child = child->next; + } + if (!child) + gf_dom_add_text_node((GF_Node*)n, gf_strdup(str) ); - memset(&evt, 0, sizeof(GF_DOM_Event)); - evt.type = GF_EVENT_DCCI_PROP_CHANGE; - evt.bubbles = 1; - evt.relatedNode = (GF_Node*)n; - gf_dom_event_fire((GF_Node*)n, &evt); - n->sgprivate->scenegraph->modified = GF_TRUE; - break; - case DCCI_JSPROPERTY_PROPERTYTYPE: - break; + memset(&evt, 0, sizeof(GF_DOM_Event)); + evt.type = GF_EVENT_DCCI_PROP_CHANGE; + evt.bubbles = 1; + evt.relatedNode = (GF_Node*)n; + gf_dom_event_fire((GF_Node*)n, &evt); + n->sgprivate->scenegraph->modified = GF_TRUE; + break; + case DCCI_JSPROPERTY_PROPERTYTYPE: + break; - /*all other properties are read-only*/ - default: - break; - } + /*all other properties are read-only*/ + default: + break; } - SMJS_FREE(c, str); - return JS_TRUE; +} +SMJS_FREE(c, str); +return JS_TRUE; } Bool dcci_prop_lookup(GF_DOMFullNode *n, char *ns, char *name, Bool deep, Bool first) @@ -4075,23 +4118,23 @@ static JSBool SMJS_FUNCTION(dcci_search_property) static SMJS_FUNC_PROP_GET( storage_getProperty) - /*avoids gcc warning*/ +/*avoids gcc warning*/ #ifndef GPAC_CONFIG_DARWIN - if (!id) id=0; +if (!id) id=0; #endif - if (!GF_JS_InstanceOf(c, obj, &dom_rt->storageClass, NULL) ) return JS_TRUE; - *vp = JSVAL_VOID; - return JS_TRUE; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->storageClass, NULL) ) return JS_TRUE; +*vp = JSVAL_VOID; +return JS_TRUE; } static SMJS_FUNC_PROP_SET_NOVP( storage_setProperty) - /*avoids gcc warning*/ +/*avoids gcc warning*/ #ifndef GPAC_CONFIG_DARWIN - if (!id) id=0; +if (!id) id=0; #endif - if (!GF_JS_InstanceOf(c, obj, &dom_rt->storageClass, NULL) ) return JS_TRUE; - return JS_TRUE; +if (!GF_JS_InstanceOf(c, obj, &dom_rt->storageClass, NULL) ) return JS_TRUE; +return JS_TRUE; } static JSBool SMJS_FUNCTION(storage_constructor) @@ -4104,13 +4147,13 @@ static JSBool SMJS_FUNCTION(storage_constructor) static DECL_FINALIZE( storage_finalize) - /*avoids GCC warning*/ - if (!c) c=NULL; +/*avoids GCC warning*/ +if (!c) c=NULL; } void dom_js_define_storage(JSContext *c, JSObject *parent_obj, const char *name) { - JS_DefineObject(c, parent_obj, name, &dom_rt->storageClass._class, 0, 0 ); + JS_DefineObject(c, parent_obj, name, &dom_rt->storageClass._class, 0, 0 ); } void dom_js_load(GF_SceneGraph *scene, JSContext *c, JSObject *global) @@ -4441,7 +4484,6 @@ void dom_js_load(GF_SceneGraph *scene, JSContext *c, JSObject *global) SMJS_FUNCTION_SPEC("wait", xml_http_wait, 0), /*eventTarget interface*/ JS_DOM3_EVENT_TARGET_INTERFACE - /*todo - addEventListener and removeEventListener*/ SMJS_FUNCTION_SPEC(0, 0, 0) }; GF_JS_InitClass(c, global, NULL, &dom_rt->xmlHTTPRequestClass, xml_http_constructor, 0, xmlHTTPRequestClassProps, xmlHTTPRequestClassFuncs, xmlHTTPRequestStaticClassProps, 0); @@ -4504,9 +4546,9 @@ void dom_js_pre_destroy(JSContext *c, GF_SceneGraph *sg, GF_Node *n) { u32 i, count; if (n) { - if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { - //html_media_element_js_finalize(c, n); - } + if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { + //html_media_element_js_finalize(c, n); + } if (n->sgprivate->interact && n->sgprivate->interact->js_binding && n->sgprivate->interact->js_binding->node) { JSObject *obj = (JSObject *)n->sgprivate->interact->js_binding->node; SMJS_SET_PRIVATE(c, obj, NULL); @@ -4581,10 +4623,18 @@ JSObject *gf_dom_new_event(JSContext *c) { return JS_NewObject(c, &dom_rt->domEventClass._class, 0, 0); } -JSObject *dom_js_get_node_proto(JSContext *c) { return dom_rt->domNodeClass._proto; } -JSObject *dom_js_get_element_proto(JSContext *c) { return dom_rt->domElementClass._proto; } -JSObject *dom_js_get_document_proto(JSContext *c) { return dom_rt->domDocumentClass._proto; } -JSObject *dom_js_get_event_proto(JSContext *c) { return dom_rt->domEventClass._proto; } +JSObject *dom_js_get_node_proto(JSContext *c) { + return dom_rt->domNodeClass._proto; +} +JSObject *dom_js_get_element_proto(JSContext *c) { + return dom_rt->domElementClass._proto; +} +JSObject *dom_js_get_document_proto(JSContext *c) { + return dom_rt->domDocumentClass._proto; +} +JSObject *dom_js_get_event_proto(JSContext *c) { + return dom_rt->domEventClass._proto; +} void dom_set_class_selector(JSContext *c, void *(*get_element_class)(GF_Node *n), void *(*get_document_class)(GF_SceneGraph *n) ) { diff --git a/src/scenegraph/html5_media_smjs.c b/src/scenegraph/html5_media_smjs.c index d94b170..6d51fe5 100644 --- a/src/scenegraph/html5_media_smjs.c +++ b/src/scenegraph/html5_media_smjs.c @@ -53,7 +53,7 @@ /*********************************************************** * - * DOM generic functions being used + * DOM generic functions being used * ***********************************************************/ #ifdef USE_FFDEV_15 @@ -82,74 +82,74 @@ static GF_HTML_MediaRuntime *html_media_rt = NULL; /* Enumeration of the property codes for use in JS Bindings for the the HTML5 MediaError interface */ typedef enum { - MEDIA_ERROR_PROP_ABORTED = -1, - MEDIA_ERROR_PROP_NETWORK = -2, - MEDIA_ERROR_PROP_DECODE = -3, - MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED = -4, - MEDIA_ERROR_PROP_CODE = -5 + MEDIA_ERROR_PROP_ABORTED = -1, + MEDIA_ERROR_PROP_NETWORK = -2, + MEDIA_ERROR_PROP_DECODE = -3, + MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED = -4, + MEDIA_ERROR_PROP_CODE = -5 } GF_HTML_MediaErrorPropEnum; /* Enumeration of the property codes for use in JS Bindings for the the HTML5 HTMLMediaElement interface */ -typedef enum +typedef enum { - HTML_MEDIA_PROP_SRC = -1, - HTML_MEDIA_PROP_CURRENTSRC = -2, - HTML_MEDIA_PROP_CROSSORIGIN = -3, - HTML_MEDIA_PROP_NETWORKSTATE = -4, - HTML_MEDIA_PROP_PRELOAD = -5, - HTML_MEDIA_PROP_BUFFERED = -6, - HTML_MEDIA_PROP_READYSTATE = -7, - HTML_MEDIA_PROP_SEEKING = -8, - HTML_MEDIA_PROP_CURRENTTIME = -9, - HTML_MEDIA_PROP_DURATION = -10, - HTML_MEDIA_PROP_STARTDATE = -11, - HTML_MEDIA_PROP_PAUSED = -12, - HTML_MEDIA_PROP_DEFAULTPLAYBACKRATE = -13, - HTML_MEDIA_PROP_PLAYBACKRATE = -14, - HTML_MEDIA_PROP_PLAYED = -15, - HTML_MEDIA_PROP_SEEKABLE = -16, - HTML_MEDIA_PROP_ENDED = -17, - HTML_MEDIA_PROP_AUTOPLAY = -18, - HTML_MEDIA_PROP_LOOP = -19, - HTML_MEDIA_PROP_MEDIAGROUP = -20, - HTML_MEDIA_PROP_CONTROLLER = -21, - HTML_MEDIA_PROP_CONTROLS = -22, - HTML_MEDIA_PROP_VOLUME = -23, - HTML_MEDIA_PROP_MUTED = -24, - HTML_MEDIA_PROP_DEFAULTMUTED = -25, - HTML_MEDIA_PROP_AUDIOTRACKS = -26, - HTML_MEDIA_PROP_VIDEOTRACKS = -27, - HTML_MEDIA_PROP_TEXTTRACKS = -28, - HTML_MEDIA_PROP_NETWORK_EMPTY = -29, - HTML_MEDIA_PROP_NETWORK_IDLE = -30, - HTML_MEDIA_PROP_NETWORK_LOADING = -31, - HTML_MEDIA_PROP_NETWORK_NO_SOURCE = -32, - HTML_MEDIA_PROP_HAVE_NOTHING = -33, - HTML_MEDIA_PROP_HAVE_METADATA = -34, - HTML_MEDIA_PROP_HAVE_CURRENT_DATA = -35, - HTML_MEDIA_PROP_HAVE_FUTURE_DATA = -36, - HTML_MEDIA_PROP_HAVE_ENOUGH_DATA = -37, - HTML_MEDIA_PROP_ERROR = -38 + HTML_MEDIA_PROP_SRC = -1, + HTML_MEDIA_PROP_CURRENTSRC = -2, + HTML_MEDIA_PROP_CROSSORIGIN = -3, + HTML_MEDIA_PROP_NETWORKSTATE = -4, + HTML_MEDIA_PROP_PRELOAD = -5, + HTML_MEDIA_PROP_BUFFERED = -6, + HTML_MEDIA_PROP_READYSTATE = -7, + HTML_MEDIA_PROP_SEEKING = -8, + HTML_MEDIA_PROP_CURRENTTIME = -9, + HTML_MEDIA_PROP_DURATION = -10, + HTML_MEDIA_PROP_STARTDATE = -11, + HTML_MEDIA_PROP_PAUSED = -12, + HTML_MEDIA_PROP_DEFAULTPLAYBACKRATE = -13, + HTML_MEDIA_PROP_PLAYBACKRATE = -14, + HTML_MEDIA_PROP_PLAYED = -15, + HTML_MEDIA_PROP_SEEKABLE = -16, + HTML_MEDIA_PROP_ENDED = -17, + HTML_MEDIA_PROP_AUTOPLAY = -18, + HTML_MEDIA_PROP_LOOP = -19, + HTML_MEDIA_PROP_MEDIAGROUP = -20, + HTML_MEDIA_PROP_CONTROLLER = -21, + HTML_MEDIA_PROP_CONTROLS = -22, + HTML_MEDIA_PROP_VOLUME = -23, + HTML_MEDIA_PROP_MUTED = -24, + HTML_MEDIA_PROP_DEFAULTMUTED = -25, + HTML_MEDIA_PROP_AUDIOTRACKS = -26, + HTML_MEDIA_PROP_VIDEOTRACKS = -27, + HTML_MEDIA_PROP_TEXTTRACKS = -28, + HTML_MEDIA_PROP_NETWORK_EMPTY = -29, + HTML_MEDIA_PROP_NETWORK_IDLE = -30, + HTML_MEDIA_PROP_NETWORK_LOADING = -31, + HTML_MEDIA_PROP_NETWORK_NO_SOURCE = -32, + HTML_MEDIA_PROP_HAVE_NOTHING = -33, + HTML_MEDIA_PROP_HAVE_METADATA = -34, + HTML_MEDIA_PROP_HAVE_CURRENT_DATA = -35, + HTML_MEDIA_PROP_HAVE_FUTURE_DATA = -36, + HTML_MEDIA_PROP_HAVE_ENOUGH_DATA = -37, + HTML_MEDIA_PROP_ERROR = -38 } GF_HTML_MediaEltPropEnum; /* Enumeration of the property codes for use in JS Bindings for the the HTML5 HTMLVideoElement interface */ typedef enum { - HTML_VIDEO_PROP_WIDTH = -1, - HTML_VIDEO_PROP_HEIGHT = -2, - HTML_VIDEO_PROP_VIDEOWIDTH = -3, - HTML_VIDEO_PROP_VIDEOHEIGHT = -4, - HTML_VIDEO_PROP_POSTER = -5 + HTML_VIDEO_PROP_WIDTH = -1, + HTML_VIDEO_PROP_HEIGHT = -2, + HTML_VIDEO_PROP_VIDEOWIDTH = -3, + HTML_VIDEO_PROP_VIDEOHEIGHT = -4, + HTML_VIDEO_PROP_POSTER = -5 } GF_HTML_VideoEltPropEnum; /* Enumeration of the property codes for use in JS Bindings for the the HTML5 HTMLTrackElement interface */ typedef enum { - HTML_TRACK_PROP_ID = -1, - HTML_TRACK_PROP_KIND = -2, - HTML_TRACK_PROP_LABEL = -3, - HTML_TRACK_PROP_LANGUAGE = -4, - HTML_TRACK_PROP_SELECTED = -5, - HTML_TRACK_PROP_ENABLED = -6, - HTML_TRACK_PROP_INBANDTYPE = -7 + HTML_TRACK_PROP_ID = -1, + HTML_TRACK_PROP_KIND = -2, + HTML_TRACK_PROP_LABEL = -3, + HTML_TRACK_PROP_LANGUAGE = -4, + HTML_TRACK_PROP_SELECTED = -5, + HTML_TRACK_PROP_ENABLED = -6, + HTML_TRACK_PROP_INBANDTYPE = -7 } GF_HTML_TrackPropEnum; #define HTML_MEDIA_JS_CHECK GF_HTML_MediaElement *me; \ @@ -171,7 +171,7 @@ typedef struct { GF_TextureHandler txh; struct _drawable *graph; - MFURL txurl; + MFURL txurl; Bool first_frame_fetched; GF_Node *audio; Bool audio_dirty; @@ -194,44 +194,47 @@ typedef struct */ static GF_MediaObject *gf_html_media_object(GF_Node *n) { - GF_MediaObject *mo = NULL; - if (n->sgprivate->tag == TAG_SVG_video) - { - SVG_video_stack *video_stack; - video_stack = (SVG_video_stack *)n->sgprivate->UserPrivate; - mo = video_stack->txh.stream; - } - else if (n->sgprivate->tag == TAG_SVG_audio) - { - SVG_audio_stack *audio_stack; - audio_stack = (SVG_audio_stack *)n->sgprivate->UserPrivate; - mo = audio_stack->input.stream; - } - return mo; + GF_MediaObject *mo = NULL; + if (n->sgprivate->tag == TAG_SVG_video) + { + SVG_video_stack *video_stack; + video_stack = (SVG_video_stack *)n->sgprivate->UserPrivate; + mo = video_stack->txh.stream; + } + else if (n->sgprivate->tag == TAG_SVG_audio) + { + SVG_audio_stack *audio_stack; + audio_stack = (SVG_audio_stack *)n->sgprivate->UserPrivate; + mo = audio_stack->input.stream; + } + return mo; } static void gf_html_track_init_js(GF_HTML_Track *track, JSContext *c, GF_HTML_TrackList *tracklist) { - JSObject *track_obj; - track->c = c; - if (track->type == HTML_MEDIA_TRACK_TYPE_AUDIO) - { - track_obj = JS_NewObject(c, &html_media_rt->audioTrackClass._class, NULL, tracklist->_this); - } - else if (track->type == HTML_MEDIA_TRACK_TYPE_VIDEO) - { - track_obj = JS_NewObject(c, &html_media_rt->videoTrackClass._class, NULL, tracklist->_this); - } - else if (track->type == HTML_MEDIA_TRACK_TYPE_TEXT) - { - track_obj = JS_NewObject(c, &html_media_rt->textTrackClass._class, NULL, tracklist->_this); - } - else - { - return; - } - track->_this = track_obj; - SMJS_SET_PRIVATE(c, track->_this, track); + JSObject *track_obj; + track->c = c; + if (track->type == HTML_MEDIA_TRACK_TYPE_AUDIO) + { + track_obj = JS_NewObject(c, &html_media_rt->audioTrackClass._class, NULL, tracklist->_this); + } + else if (track->type == HTML_MEDIA_TRACK_TYPE_VIDEO) + { + track_obj = JS_NewObject(c, &html_media_rt->videoTrackClass._class, NULL, tracklist->_this); + } + else if (track->type == HTML_MEDIA_TRACK_TYPE_TEXT) + { + track_obj = JS_NewObject(c, &html_media_rt->textTrackClass._class, NULL, tracklist->_this); + } + else + { + return; + } + tracklist->onchange = JSVAL_NULL; + tracklist->onaddtrack = JSVAL_NULL; + tracklist->onremovetrack = JSVAL_NULL; + track->_this = track_obj; + SMJS_SET_PRIVATE(c, track->_this, track); } /* Not yet used, removed for GCC warning @@ -254,51 +257,51 @@ static void gf_html_media_controller_init_js(GF_HTML_MediaController *mc, JSCont static void gf_html_media_element_init_js(GF_HTML_MediaElement *me, JSContext *c, JSObject *node_obj) { - me->c = c; - me->_this = JS_NewObject(c, &html_media_rt->htmlMediaElementClass._class, NULL, node_obj); - SMJS_SET_PRIVATE(c, me->_this, me); + me->c = c; + me->_this = JS_NewObject(c, &html_media_rt->htmlMediaElementClass._class, NULL, node_obj); + SMJS_SET_PRIVATE(c, me->_this, me); - me->error.c = c; - me->error._this = JS_NewObject(c, &html_media_rt->mediaErrorClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->error._this, &me->error); + me->error.c = c; + me->error._this = JS_NewObject(c, &html_media_rt->mediaErrorClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->error._this, &me->error); - me->audioTracks.c = c; - me->audioTracks._this = JS_NewObject(c, &html_media_rt->audioTrackListClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->audioTracks._this, &me->audioTracks); + me->audioTracks.c = c; + me->audioTracks._this = JS_NewObject(c, &html_media_rt->audioTrackListClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->audioTracks._this, &me->audioTracks); - me->videoTracks.c = c; - me->videoTracks._this = JS_NewObject(c, &html_media_rt->videoTrackListClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->videoTracks._this, &me->videoTracks); + me->videoTracks.c = c; + me->videoTracks._this = JS_NewObject(c, &html_media_rt->videoTrackListClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->videoTracks._this, &me->videoTracks); - me->textTracks.c = c; - me->textTracks._this = JS_NewObject(c, &html_media_rt->textTrackListClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->textTracks._this, &me->textTracks); + me->textTracks.c = c; + me->textTracks._this = JS_NewObject(c, &html_media_rt->textTrackListClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->textTracks._this, &me->textTracks); - me->buffered->c = c; - me->buffered->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->buffered->_this, me->buffered); + me->buffered->c = c; + me->buffered->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->buffered->_this, me->buffered); - me->played->c = c; - me->played->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->played->_this, me->played); + me->played->c = c; + me->played->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->played->_this, me->played); - me->seekable->c = c; - me->seekable->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); - SMJS_SET_PRIVATE(c, me->seekable->_this, me->seekable); + me->seekable->c = c; + me->seekable->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, me->_this); + SMJS_SET_PRIVATE(c, me->seekable->_this, me->seekable); } -/* Function to browse the tracks in the MediaObject associated with the Media Element and to create appropriate HTML Track objects - * +/* Function to browse the tracks in the MediaObject associated with the Media Element and to create appropriate HTML Track objects + * * \param c The JavaScript Context to create the new JS object - * \param me the HTMLMediaElement to update + * \param me the HTMLMediaElement to update */ static void html_media_element_populate_tracks(JSContext *c, GF_HTML_MediaElement *me) { - GF_HTML_Track *track; + GF_HTML_Track *track; GF_MediaObject *mo; - GF_ClientService *service; - GF_Scene *scene; - u32 i, count; + GF_ClientService *service; + GF_Scene *scene; + u32 i, count; if (!me || !me->node) { return; @@ -311,50 +314,50 @@ static void html_media_element_populate_tracks(JSContext *c, GF_HTML_MediaElemen scene = mo->odm->parentscene; count = gf_list_count(scene->resources); - for (i=0; iresources, i); - if (odm->net_service != service) continue; - if (!odm->mo || !odm->OD) continue; - for (j = 0; j < gf_list_count(odm->OD->ESDescriptors); j++) - { - char id[256]; - char *lang = ""; - GF_ESD *esd = (GF_ESD *)gf_list_get(odm->OD->ESDescriptors, j); - sprintf(id, "track%d", esd->ESID); - if (esd->langDesc) - { - lang = ""; - } - switch(odm->mo->type) - { - case GF_MEDIA_OBJECT_VIDEO: - if (!html_media_tracklist_has_track(&me->videoTracks, id)) - { - track = html_media_add_new_track_to_list(&me->videoTracks, HTML_MEDIA_TRACK_TYPE_VIDEO, - "video/mp4", GF_TRUE, id, "myKind", "myLabel", lang); - gf_html_track_init_js(track, c, &me->videoTracks); - } - break; - case GF_MEDIA_OBJECT_AUDIO: - if (!html_media_tracklist_has_track(&me->audioTracks, id)) - { - track = html_media_add_new_track_to_list(&me->audioTracks, HTML_MEDIA_TRACK_TYPE_AUDIO, - "audio/mp4", GF_TRUE, id, "myKind", "myLabel", lang); - gf_html_track_init_js(track, c, &me->audioTracks); - } - break; - case GF_MEDIA_OBJECT_TEXT: - if (!html_media_tracklist_has_track(&me->textTracks, id)) - { - track = html_media_add_new_track_to_list(&me->textTracks, HTML_MEDIA_TRACK_TYPE_TEXT, - "text/plain", GF_TRUE, id, "myKind", "myLabel", lang); - gf_html_track_init_js(track, c, &me->textTracks); - } - break; - } - } - } + for (i=0; iresources, i); + if (odm->net_service != service) continue; + if (!odm->mo || !odm->OD) continue; + for (j = 0; j < gf_list_count(odm->OD->ESDescriptors); j++) + { + char id[256]; + char *lang = ""; + GF_ESD *esd = (GF_ESD *)gf_list_get(odm->OD->ESDescriptors, j); + sprintf(id, "track%d", esd->ESID); + if (esd->langDesc) + { + lang = ""; + } + switch(odm->mo->type) + { + case GF_MEDIA_OBJECT_VIDEO: + if (!html_media_tracklist_has_track(&me->videoTracks, id)) + { + track = html_media_add_new_track_to_list(&me->videoTracks, HTML_MEDIA_TRACK_TYPE_VIDEO, + "video/mp4", GF_TRUE, id, "myKind", "myLabel", lang); + gf_html_track_init_js(track, c, &me->videoTracks); + } + break; + case GF_MEDIA_OBJECT_AUDIO: + if (!html_media_tracklist_has_track(&me->audioTracks, id)) + { + track = html_media_add_new_track_to_list(&me->audioTracks, HTML_MEDIA_TRACK_TYPE_AUDIO, + "audio/mp4", GF_TRUE, id, "myKind", "myLabel", lang); + gf_html_track_init_js(track, c, &me->audioTracks); + } + break; + case GF_MEDIA_OBJECT_TEXT: + if (!html_media_tracklist_has_track(&me->textTracks, id)) + { + track = html_media_add_new_track_to_list(&me->textTracks, HTML_MEDIA_TRACK_TYPE_TEXT, + "text/plain", GF_TRUE, id, "myKind", "myLabel", lang); + gf_html_track_init_js(track, c, &me->textTracks); + } + break; + } + } + } } /* Used to retrieve the structure implementing the GF_HTML_MediaElement interface associated with this node @@ -363,18 +366,18 @@ static void html_media_element_populate_tracks(JSContext *c, GF_HTML_MediaElemen * So, we store the structure implementing the GF_HTML_MediaElement interface in the JavaScript context of this node, * as a non enumeratable property named 'gpac_me_impl' * - * \param c the global JavaScript context + * \param c the global JavaScript context * \param n the audio or video node * \return the GF_HTML_MediaElement associated with this node in the given context */ static GF_HTML_MediaElement *html_media_element_get_from_node(JSContext *c, GF_Node *n) { - jsval vp; - JSObject *me_obj; - JSObject *node_obj; - GF_HTML_MediaElement *me = NULL; + jsval vp; + JSObject *me_obj; + JSObject *node_obj; + GF_HTML_MediaElement *me = NULL; - if ((n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) && n->sgprivate->interact && n->sgprivate->interact->js_binding) { + if ((n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) && n->sgprivate->interact && n->sgprivate->interact->js_binding) { node_obj = (JSObject *)n->sgprivate->interact->js_binding->node; if (node_obj) { JS_GetProperty(c, node_obj, "gpac_me_impl", &vp); @@ -382,16 +385,16 @@ static GF_HTML_MediaElement *html_media_element_get_from_node(JSContext *c, GF_N me = (GF_HTML_MediaElement *)SMJS_GET_PRIVATE(c, me_obj); } } - return me; + return me; } static JSBool SMJS_FUNCTION(html_media_load) { - SMJS_OBJ - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) - { + SMJS_OBJ + if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) + { MFURL mfurl; GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); GF_HTML_MediaElement *me = html_media_element_get_from_node(c, n); @@ -401,99 +404,99 @@ static JSBool SMJS_FUNCTION(html_media_load) mfurl.vals[0].OD_ID = GF_MEDIA_EXTERNAL_ID; gf_mo_register(n, &mfurl, GF_FALSE, GF_FALSE); gf_free(mfurl.vals); - return JS_TRUE; - } else { + return JS_TRUE; + } else { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } static JSBool SMJS_FUNCTION(html_media_canPlayType) { - SMJS_OBJ - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) - { - return JS_TRUE; - } else { + SMJS_OBJ + if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) + { + return JS_TRUE; + } else { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } static JSBool SMJS_FUNCTION(html_media_fastSeek) { - SMJS_OBJ - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) - { - return JS_TRUE; - } else { + SMJS_OBJ + if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) + { + return JS_TRUE; + } else { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } static JSBool SMJS_FUNCTION(html_media_addTextTrack) { - SMJS_OBJ - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) - { - return JS_TRUE; - } else { + SMJS_OBJ + if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL)) + { + return JS_TRUE; + } else { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } void *html_get_element_class(GF_Node *n) { - if (!n || !html_media_rt) - { - return NULL; - } else if (n->sgprivate->tag == TAG_SVG_video) { - return &html_media_rt->htmlVideoElementClass; - } else if (n->sgprivate->tag == TAG_SVG_audio) { - return &html_media_rt->htmlAudioElementClass; - } else { - return NULL; - } + if (!n || !html_media_rt) + { + return NULL; + } else if (n->sgprivate->tag == TAG_SVG_video) { + return &html_media_rt->htmlVideoElementClass; + } else if (n->sgprivate->tag == TAG_SVG_audio) { + return &html_media_rt->htmlAudioElementClass; + } else { + return NULL; + } } /* Creates the GF_HTML_MediaElement structure for this node * Store it in the JavaScript context of this node, as a non enumeratable property named 'gpac_me_impl' * see \ref html_media_element_get_from_node for retrieving it * - * \param c the global JavaScript context + * \param c the global JavaScript context * \param n the audio or video node * \param node_obj the JavaScript object representing the audio or video node */ void html_media_element_js_init(JSContext *c, JSObject *node_obj, GF_Node *n) { - if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { - GF_HTML_MediaElement *me; - me = gf_html_media_element_new(n, NULL); - gf_html_media_element_init_js(me, c, node_obj); - /* To be able to retrieve the Media Element interface from the Node element */ - JS_DefineProperty(c, node_obj, "gpac_me_impl", OBJECT_TO_JSVAL(me->_this), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); - } + if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { + GF_HTML_MediaElement *me; + me = gf_html_media_element_new(n, NULL); + gf_html_media_element_init_js(me, c, node_obj); + /* To be able to retrieve the Media Element interface from the Node element */ + JS_DefineProperty(c, node_obj, "gpac_me_impl", OBJECT_TO_JSVAL(me->_this), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); + } } /* Deletes the GF_HTML_MediaElement structure for this node * - * \param c the global JavaScript context + * \param c the global JavaScript context * \param n the audio or video node */ void html_media_element_js_finalize(JSContext *c, GF_Node *n) { - GF_HTML_MediaElement *me = html_media_element_get_from_node(c, n); - /* TODO: finalize child objects */ - gf_html_media_element_del(me); + GF_HTML_MediaElement *me = html_media_element_get_from_node(c, n); + /* TODO: finalize child objects */ + gf_html_media_element_del(me); } /* Gets The EventTarget and SceneGraph from the GF_HTML_MediaElement structure for a audio/video JS node * - * \param c the global JavaScript context + * \param c the global JavaScript context * \param obj the JS object representing the HTMLAudioElement or HTMLVideoElement * \param target the GF_DOMEventTarget object * \param sg the scene graph @@ -501,7 +504,7 @@ void html_media_element_js_finalize(JSContext *c, GF_Node *n) void gf_html_media_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarget **target, GF_SceneGraph **sg) { if (!sg || !target) return; if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || - GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) ) { + GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL) ) { GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); *target = gf_dom_event_get_target_from_node(n); *sg = n->sgprivate->scenegraph; @@ -512,643 +515,643 @@ void gf_html_media_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarg } static SMJS_FUNC_PROP_GET(html_media_error_get_code) - if (GF_JS_InstanceOf(c, obj, &html_media_rt->mediaErrorClass, NULL)) - { - GF_HTML_MediaError *error = (GF_HTML_MediaError*)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) { - return JS_TRUE; - } - switch (SMJS_ID_TO_INT(id)) - { - case MEDIA_ERROR_PROP_ABORTED: - *vp = INT_TO_JSVAL(MEDIA_ERR_ABORTED); - return JS_TRUE; - case MEDIA_ERROR_PROP_NETWORK: - *vp = INT_TO_JSVAL(MEDIA_ERR_NETWORK); - return JS_TRUE; - case MEDIA_ERROR_PROP_DECODE: - *vp = INT_TO_JSVAL(MEDIA_ERR_DECODE); - return JS_TRUE; - case MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED: - *vp = INT_TO_JSVAL(MEDIA_ERR_SRC_NOT_SUPPORTED); - return JS_TRUE; - case MEDIA_ERROR_PROP_CODE: - *vp = INT_TO_JSVAL(error->code); - return JS_TRUE; - } - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +if (GF_JS_InstanceOf(c, obj, &html_media_rt->mediaErrorClass, NULL)) +{ + GF_HTML_MediaError *error = (GF_HTML_MediaError*)SMJS_GET_PRIVATE(c, obj); + if (!SMJS_ID_IS_INT(id)) { + return JS_TRUE; } + switch (SMJS_ID_TO_INT(id)) + { + case MEDIA_ERROR_PROP_ABORTED: + *vp = INT_TO_JSVAL(MEDIA_ERR_ABORTED); + return JS_TRUE; + case MEDIA_ERROR_PROP_NETWORK: + *vp = INT_TO_JSVAL(MEDIA_ERR_NETWORK); + return JS_TRUE; + case MEDIA_ERROR_PROP_DECODE: + *vp = INT_TO_JSVAL(MEDIA_ERR_DECODE); + return JS_TRUE; + case MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED: + *vp = INT_TO_JSVAL(MEDIA_ERR_SRC_NOT_SUPPORTED); + return JS_TRUE; + case MEDIA_ERROR_PROP_CODE: + *vp = INT_TO_JSVAL(error->code); + return JS_TRUE; + } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_error) - HTML_MEDIA_JS_START - *vp = OBJECT_TO_JSVAL(me->error._this); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp = OBJECT_TO_JSVAL(me->error._this); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_src) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "href", GF_XMLNS_XLINK, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "href", GF_XMLNS_XLINK, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_src) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_XLINK, "href", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_XLINK, "href", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_cors) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "crossorigin", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "crossorigin", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_cors) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "crossorigin", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "crossorigin", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } void media_event_collect_info(GF_ClientService *net, GF_ObjectManager *odm, GF_DOMMediaEvent *media_event, u32 *min_time, u32 *min_buffer); static void html_media_get_states(GF_MediaObject *mo, GF_HTML_MediaReadyState *readyState, GF_HTML_NetworkState *networkState) { - GF_DOMMediaEvent media_event; - u32 min_time; - u32 min_buffer; - if (!mo) return; + GF_DOMMediaEvent media_event; + u32 min_time; + u32 min_buffer; + if (!mo) return; if (!mo->odm) { - *readyState = HAVE_NOTHING; - *networkState = NETWORK_EMPTY; + *readyState = HAVE_NOTHING; + *networkState = NETWORK_EMPTY; return; - } - - memset(&media_event, 0, sizeof(GF_DOMMediaEvent)); - media_event_collect_info(mo->odm->net_service, mo->odm, &media_event, &min_time, &min_buffer); - //GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] min_time: %d, min_buffer: %d loaded: "LLD"/"LLD"\n", - // min_time, min_buffer, media_event.loaded_size, media_event.total_size)); - if (min_buffer == 0) - { - *readyState = HAVE_NOTHING; - *networkState = NETWORK_EMPTY; - } - else - { - if (media_event.loaded_size != 0) - { - *readyState = HAVE_METADATA; - } - else if (media_event.loaded_size == media_event.total_size) - { - *readyState = HAVE_ENOUGH_DATA; - } - } + } + + memset(&media_event, 0, sizeof(GF_DOMMediaEvent)); + media_event_collect_info(mo->odm->net_service, mo->odm, &media_event, &min_time, &min_buffer); + //GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] min_time: %d, min_buffer: %d loaded: "LLD"/"LLD"\n", + // min_time, min_buffer, media_event.loaded_size, media_event.total_size)); + if (min_buffer == 0) + { + *readyState = HAVE_NOTHING; + *networkState = NETWORK_EMPTY; + } + else + { + if (media_event.loaded_size != 0) + { + *readyState = HAVE_METADATA; + } + else if (media_event.loaded_size == media_event.total_size) + { + *readyState = HAVE_ENOUGH_DATA; + } + } } static SMJS_FUNC_PROP_GET(html_media_get_ready_state) - GF_HTML_MediaReadyState readyState = HAVE_NOTHING; - GF_HTML_NetworkState networkState = NETWORK_EMPTY; - GF_MediaObject *mo = NULL; - HTML_MEDIA_JS_START - html_media_element_populate_tracks(c, me); - mo = gf_html_media_object(n); - html_media_get_states(mo, &readyState, &networkState); - *vp = INT_TO_JSVAL( readyState ); - return JS_TRUE; +GF_HTML_MediaReadyState readyState = HAVE_NOTHING; +GF_HTML_NetworkState networkState = NETWORK_EMPTY; +GF_MediaObject *mo = NULL; +HTML_MEDIA_JS_START +html_media_element_populate_tracks(c, me); +mo = gf_html_media_object(n); +html_media_get_states(mo, &readyState, &networkState); +*vp = INT_TO_JSVAL( readyState ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_network_state) - GF_HTML_MediaReadyState readyState = HAVE_NOTHING; - GF_HTML_NetworkState networkState = NETWORK_EMPTY; - GF_MediaObject *mo = NULL; - HTML_MEDIA_JS_START - mo = gf_html_media_object(n); - html_media_get_states(mo, &readyState, &networkState); - *vp = INT_TO_JSVAL( networkState ); - return JS_TRUE; +GF_HTML_MediaReadyState readyState = HAVE_NOTHING; +GF_HTML_NetworkState networkState = NETWORK_EMPTY; +GF_MediaObject *mo = NULL; +HTML_MEDIA_JS_START +mo = gf_html_media_object(n); +html_media_get_states(mo, &readyState, &networkState); +*vp = INT_TO_JSVAL( networkState ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_const) - u32 v = 0; - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL) || +u32 v = 0; +if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlMediaElementClass, NULL) || GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL) || GF_JS_InstanceOf(c, obj, &html_media_rt->htmlAudioElementClass, NULL)) - { - if (!SMJS_ID_IS_INT(id)) { - return JS_TRUE; - } - switch (SMJS_ID_TO_INT(id)) { - case HTML_MEDIA_PROP_NETWORK_EMPTY: - v = NETWORK_EMPTY; - break; - case HTML_MEDIA_PROP_NETWORK_IDLE: - v = NETWORK_IDLE; - break; - case HTML_MEDIA_PROP_NETWORK_LOADING: - v = NETWORK_LOADING; - break; - case HTML_MEDIA_PROP_NETWORK_NO_SOURCE: - v = NETWORK_NO_SOURCE; - break; - case HTML_MEDIA_PROP_HAVE_NOTHING: - v = HAVE_NOTHING; - break; - case HTML_MEDIA_PROP_HAVE_METADATA: - v = HAVE_METADATA; - break; - case HTML_MEDIA_PROP_HAVE_CURRENT_DATA: - v = HAVE_CURRENT_DATA; - break; - case HTML_MEDIA_PROP_HAVE_FUTURE_DATA: - v = HAVE_FUTURE_DATA; - break; - case HTML_MEDIA_PROP_HAVE_ENOUGH_DATA: - v = HAVE_ENOUGH_DATA; - break; - default: - return JS_TRUE; - } - *vp = INT_TO_JSVAL( v ); +{ + if (!SMJS_ID_IS_INT(id)) { return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } + switch (SMJS_ID_TO_INT(id)) { + case HTML_MEDIA_PROP_NETWORK_EMPTY: + v = NETWORK_EMPTY; + break; + case HTML_MEDIA_PROP_NETWORK_IDLE: + v = NETWORK_IDLE; + break; + case HTML_MEDIA_PROP_NETWORK_LOADING: + v = NETWORK_LOADING; + break; + case HTML_MEDIA_PROP_NETWORK_NO_SOURCE: + v = NETWORK_NO_SOURCE; + break; + case HTML_MEDIA_PROP_HAVE_NOTHING: + v = HAVE_NOTHING; + break; + case HTML_MEDIA_PROP_HAVE_METADATA: + v = HAVE_METADATA; + break; + case HTML_MEDIA_PROP_HAVE_CURRENT_DATA: + v = HAVE_CURRENT_DATA; + break; + case HTML_MEDIA_PROP_HAVE_FUTURE_DATA: + v = HAVE_FUTURE_DATA; + break; + case HTML_MEDIA_PROP_HAVE_ENOUGH_DATA: + v = HAVE_ENOUGH_DATA; + break; + default: + return JS_TRUE; + } + *vp = INT_TO_JSVAL( v ); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_preload) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "preload", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "preload", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_preload) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "preload", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "preload", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_buffered) - HTML_MEDIA_JS_START - *vp = OBJECT_TO_JSVAL( me->buffered->_this ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp = OBJECT_TO_JSVAL( me->buffered->_this ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_seeking) - HTML_MEDIA_JS_START - /* TODO: implement it for real */ - *vp = BOOLEAN_TO_JSVAL( (me->seeking ? JS_TRUE : JS_FALSE) ); - return JS_TRUE; +HTML_MEDIA_JS_START +/* TODO: implement it for real */ +*vp = BOOLEAN_TO_JSVAL( (me->seeking ? JS_TRUE : JS_FALSE) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_current_time) - u32 time_ms = 0; - Double time_s; - GF_MediaObject *mo = NULL; - HTML_MEDIA_JS_START - mo = gf_html_media_object(n); - gf_mo_get_object_time(mo, &time_ms); - time_s = time_ms / 1000.0; - *vp = JS_MAKE_DOUBLE(c, time_s ); - return JS_TRUE; +u32 time_ms = 0; +Double time_s; +GF_MediaObject *mo = NULL; +HTML_MEDIA_JS_START +mo = gf_html_media_object(n); +gf_mo_get_object_time(mo, &time_ms); +time_s = time_ms / 1000.0; +*vp = JS_MAKE_DOUBLE(c, time_s ); +return JS_TRUE; } static GFINLINE Bool ScriptAction(GF_SceneGraph *scene, u32 type, GF_Node *node, GF_JSAPIParam *param) { - if (scene->script_action) - { - return scene->script_action(scene->script_action_cbck, type, node, param); - } - return GF_FALSE; + if (scene->script_action) + { + return scene->script_action(scene->script_action_cbck, type, node, param); + } + return GF_FALSE; } static SMJS_FUNC_PROP_SET(html_media_set_current_time) - double d; - GF_JSAPIParam par; - HTML_MEDIA_JS_START - if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, *vp, &d); - par.time = d; - ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_TIME, (GF_Node *)n, &par); - return JS_TRUE; +double d; +GF_JSAPIParam par; +HTML_MEDIA_JS_START +if (!JSVAL_IS_NUMBER(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +JS_ValueToNumber(c, *vp, &d); +par.time = d; +ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_TIME, (GF_Node *)n, &par); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_duration) - Double dur; - GF_MediaObject *mo = NULL; - HTML_MEDIA_JS_START - mo = gf_html_media_object(n); - dur = gf_mo_get_duration(mo); - if (dur <= 0) { - *vp = JS_GetNaNValue(c); - } else { - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, dur)); - } - return JS_TRUE; +Double dur; +GF_MediaObject *mo = NULL; +HTML_MEDIA_JS_START +mo = gf_html_media_object(n); +dur = gf_mo_get_duration(mo); +if (dur <= 0) { + *vp = JS_GetNaNValue(c); +} else { + *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, dur)); +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_start_date) - HTML_MEDIA_JS_START - // SpiderMonkey 1.8.5 JSObject * JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); - *vp = JSVAL_NULL; - /* TODO */ - return JS_TRUE; +HTML_MEDIA_JS_START +// SpiderMonkey 1.8.5 JSObject * JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); +*vp = JSVAL_NULL; +/* TODO */ +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_paused) - HTML_MEDIA_JS_START - *vp =( BOOLEAN_TO_JSVAL( (me->paused ? JS_TRUE : JS_FALSE) ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( BOOLEAN_TO_JSVAL( (me->paused ? JS_TRUE : JS_FALSE) ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_default_playback_rate) - HTML_MEDIA_JS_START - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, me->defaultPlaybackRate)); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, me->defaultPlaybackRate)); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_default_playback_rate) - jsdouble d; - HTML_MEDIA_JS_START - if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, *vp, &d); - me->defaultPlaybackRate = d; - return JS_TRUE; +jsdouble d; +HTML_MEDIA_JS_START +if (!JSVAL_IS_NUMBER(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +JS_ValueToNumber(c, *vp, &d); +me->defaultPlaybackRate = d; +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_playback_rate) - Double speed; - GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); - GF_MediaObject *mo = gf_html_media_object(n); - speed = gf_mo_get_current_speed(mo); - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, speed)); - return JS_TRUE; +Double speed; +GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); +GF_MediaObject *mo = gf_html_media_object(n); +speed = gf_mo_get_current_speed(mo); +*vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, speed)); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_playback_rate) - jsdouble d; - Fixed speed; - GF_MediaObject *mo; - HTML_MEDIA_JS_START - mo = gf_html_media_object(n); - if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, *vp, &d); - speed = FLT2FIX(d); - gf_mo_set_speed(mo, speed); - return JS_TRUE; +jsdouble d; +Fixed speed; +GF_MediaObject *mo; +HTML_MEDIA_JS_START +mo = gf_html_media_object(n); +if (!JSVAL_IS_NUMBER(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +JS_ValueToNumber(c, *vp, &d); +speed = FLT2FIX(d); +gf_mo_set_speed(mo, speed); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_played) - HTML_MEDIA_JS_START - *vp =( OBJECT_TO_JSVAL( me->played->_this ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( OBJECT_TO_JSVAL( me->played->_this ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_seekable) - HTML_MEDIA_JS_START - *vp =( OBJECT_TO_JSVAL( me->seekable->_this ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( OBJECT_TO_JSVAL( me->seekable->_this ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_ended) - GF_MediaObject *mo; - HTML_MEDIA_JS_START - mo = gf_html_media_object(n); - *vp = BOOLEAN_TO_JSVAL( gf_mo_is_done(mo) ? JS_TRUE : JS_FALSE); - return JS_TRUE; +GF_MediaObject *mo; +HTML_MEDIA_JS_START +mo = gf_html_media_object(n); +*vp = BOOLEAN_TO_JSVAL( gf_mo_is_done(mo) ? JS_TRUE : JS_FALSE); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_autoplay) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "autoplay", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { - *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); - } - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "autoplay", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { + *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); + } else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); + } + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_autoplay) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "autoplay", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "autoplay", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_loop) - GF_FieldInfo info; - HTML_MEDIA_JS_START - /* TODO: gf_mo_get_loop */ - if (gf_node_get_attribute_by_name(n, "loop", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { - *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); - } - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +/* TODO: gf_mo_get_loop */ +if (gf_node_get_attribute_by_name(n, "loop", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { + *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); + } else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); + } + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_loop) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "loop", str); - //TODO: use gf_mo_get_loop - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "loop", str); + //TODO: use gf_mo_get_loop + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_mediagroup) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "mediagroup", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - *vp =( STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ) ); - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "mediagroup", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + *vp =( STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ) ); + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_mediagroup) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "mediagroup", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "mediagroup", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_controller) - HTML_MEDIA_JS_START - if (me->controller) { - *vp = OBJECT_TO_JSVAL( me->controller->_this ); - } else { - *vp = JSVAL_NULL; - } - return JS_TRUE; +HTML_MEDIA_JS_START +if (me->controller) { + *vp = OBJECT_TO_JSVAL( me->controller->_this ); +} else { + *vp = JSVAL_NULL; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_controller) - HTML_MEDIA_JS_START - if (JSVAL_IS_OBJECT(*vp)) { - me->controller = (GF_HTML_MediaController *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_IS_OBJECT(*vp)) { + me->controller = (GF_HTML_MediaController *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_controls) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "controls", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { - *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); - } - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "controls", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { + *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); + } else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); + } + if (szAtt) gf_free(szAtt); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_controls) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "controls", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "controls", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SVG_audio_stack *html_media_get_audio_stack(GF_Node *n) { - SVG_video_stack *video_stack = NULL; - SVG_audio_stack *audio_stack = NULL; - if (n->sgprivate->tag == TAG_SVG_video) { - video_stack = (SVG_video_stack *)n->sgprivate->UserPrivate; - if (video_stack->audio) { - audio_stack = (SVG_audio_stack *)video_stack->audio->sgprivate->UserPrivate; - } - } else if (n->sgprivate->tag == TAG_SVG_audio) { - audio_stack = (SVG_audio_stack *)n->sgprivate->UserPrivate; - } + SVG_video_stack *video_stack = NULL; + SVG_audio_stack *audio_stack = NULL; + if (n->sgprivate->tag == TAG_SVG_video) { + video_stack = (SVG_video_stack *)n->sgprivate->UserPrivate; + if (video_stack->audio) { + audio_stack = (SVG_audio_stack *)video_stack->audio->sgprivate->UserPrivate; + } + } else if (n->sgprivate->tag == TAG_SVG_audio) { + audio_stack = (SVG_audio_stack *)n->sgprivate->UserPrivate; + } return audio_stack; } static SMJS_FUNC_PROP_GET(html_media_get_volume) - Fixed volume = FIX_ONE; - SVG_audio_stack *audio_stack = NULL; - HTML_MEDIA_JS_CHECK - audio_stack = html_media_get_audio_stack(n); - if (audio_stack) { - audio_stack->input.input_ifce.GetChannelVolume(&audio_stack->input.input_ifce.callback, &volume); - } - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, FIX2FLT(volume))); - return JS_TRUE; +Fixed volume = FIX_ONE; +SVG_audio_stack *audio_stack = NULL; +HTML_MEDIA_JS_CHECK +audio_stack = html_media_get_audio_stack(n); +if (audio_stack) { + audio_stack->input.input_ifce.GetChannelVolume(&audio_stack->input.input_ifce.callback, &volume); +} +*vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, FIX2FLT(volume))); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_volume) - jsdouble volume; - SVG_audio_stack *audio_stack = NULL; - HTML_MEDIA_JS_CHECK - audio_stack = html_media_get_audio_stack(n); - if (audio_stack) { - JS_ValueToNumber(c, *vp, &volume); - audio_stack->input.intensity = FLT2FIX(volume); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +jsdouble volume; +SVG_audio_stack *audio_stack = NULL; +HTML_MEDIA_JS_CHECK +audio_stack = html_media_get_audio_stack(n); +if (audio_stack) { + JS_ValueToNumber(c, *vp, &volume); + audio_stack->input.intensity = FLT2FIX(volume); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_muted) - SVG_audio_stack *audio_stack = NULL; - HTML_MEDIA_JS_CHECK - audio_stack = html_media_get_audio_stack(n); - if (audio_stack) { - *vp = BOOLEAN_TO_JSVAL(audio_stack->input.is_muted ? JS_TRUE : JS_FALSE); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); - } - return JS_TRUE; +SVG_audio_stack *audio_stack = NULL; +HTML_MEDIA_JS_CHECK +audio_stack = html_media_get_audio_stack(n); +if (audio_stack) { + *vp = BOOLEAN_TO_JSVAL(audio_stack->input.is_muted ? JS_TRUE : JS_FALSE); +} else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_muted) - SVG_audio_stack *audio_stack = NULL; - HTML_MEDIA_JS_CHECK - audio_stack = html_media_get_audio_stack(n); - if (audio_stack) { - audio_stack->input.is_muted = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +SVG_audio_stack *audio_stack = NULL; +HTML_MEDIA_JS_CHECK +audio_stack = html_media_get_audio_stack(n); +if (audio_stack) { + audio_stack->input.is_muted = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_default_muted) - GF_FieldInfo info; - HTML_MEDIA_JS_START - if (gf_node_get_attribute_by_name(n, "muted", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { - *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); - } - if (szAtt) gf_free(szAtt); - } else { - *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); +GF_FieldInfo info; +HTML_MEDIA_JS_START +if (gf_node_get_attribute_by_name(n, "muted", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + if (!strcmp(szAtt, "true") || !strcmp(szAtt, "TRUE")) { + *vp =( BOOLEAN_TO_JSVAL( JS_TRUE ) ); + } else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); } - return JS_TRUE; + if (szAtt) gf_free(szAtt); +} else { + *vp =( BOOLEAN_TO_JSVAL( JS_FALSE ) ); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(html_media_set_default_muted) - HTML_MEDIA_JS_START - if (JSVAL_CHECK_STRING(*vp)) { - char *str = SMJS_CHARS(c, *vp); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "muted", str); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +HTML_MEDIA_JS_START +if (JSVAL_CHECK_STRING(*vp)) { + char *str = SMJS_CHARS(c, *vp); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "muted", str); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_media_get_audio_tracks) - HTML_MEDIA_JS_START - *vp =( OBJECT_TO_JSVAL( me->audioTracks._this ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( OBJECT_TO_JSVAL( me->audioTracks._this ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_video_tracks) - HTML_MEDIA_JS_START - *vp =( OBJECT_TO_JSVAL( me->videoTracks._this ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( OBJECT_TO_JSVAL( me->videoTracks._this ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_media_get_text_tracks) - HTML_MEDIA_JS_START - *vp =( OBJECT_TO_JSVAL( me->textTracks._this ) ); - return JS_TRUE; +HTML_MEDIA_JS_START +*vp =( OBJECT_TO_JSVAL( me->textTracks._this ) ); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(html_time_ranges_get_length) - GF_HTML_MediaTimeRanges *timeranges; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); - *vp = INT_TO_JSVAL( gf_list_count(timeranges->times)/2); - return JS_TRUE; +GF_HTML_MediaTimeRanges *timeranges; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); +*vp = INT_TO_JSVAL( gf_list_count(timeranges->times)/2); +return JS_TRUE; } static JSBool SMJS_FUNCTION(html_time_ranges_start) { - GF_HTML_MediaTimeRanges *timeranges; - SMJS_OBJ - SMJS_ARGS - if ((argc!=1) || !GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); - if (!timeranges) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (JSVAL_IS_INT(argv[0])) { - u32 i = JSVAL_TO_INT(argv[0]); - u64 *start_value = (u64 *)gf_list_get(timeranges->times, 2*i); - if (!start_value) { - return dom_throw_exception(c, GF_DOM_EXC_INDEX_SIZE_ERR); - } else { - SMJS_SET_RVAL(DOUBLE_TO_JSVAL(JS_NewDouble(c, (*start_value)*1.0/timeranges->timescale))); - } - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + GF_HTML_MediaTimeRanges *timeranges; + SMJS_OBJ + SMJS_ARGS + if ((argc!=1) || !GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); + if (!timeranges) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + if (JSVAL_IS_INT(argv[0])) { + u32 i = JSVAL_TO_INT(argv[0]); + u64 *start_value = (u64 *)gf_list_get(timeranges->times, 2*i); + if (!start_value) { + return dom_throw_exception(c, GF_DOM_EXC_INDEX_SIZE_ERR); + } else { + SMJS_SET_RVAL(DOUBLE_TO_JSVAL(JS_NewDouble(c, (*start_value)*1.0/timeranges->timescale))); + } + } else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } - return JS_TRUE; + return JS_TRUE; } static JSBool SMJS_FUNCTION(html_time_ranges_end) { - GF_HTML_MediaTimeRanges *timeranges; - SMJS_OBJ - SMJS_ARGS - if ((argc!=1) || !GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); - if (!timeranges) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (JSVAL_IS_INT(argv[0])) { - u32 i = JSVAL_TO_INT(argv[0]); - u64 *end_value = (u64 *)gf_list_get(timeranges->times, 2*i+1); - if (!end_value) { - return dom_throw_exception(c, GF_DOM_EXC_INDEX_SIZE_ERR); - } else { - SMJS_SET_RVAL(DOUBLE_TO_JSVAL(JS_NewDouble(c, (*end_value)*1.0/timeranges->timescale))); - } - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + GF_HTML_MediaTimeRanges *timeranges; + SMJS_OBJ + SMJS_ARGS + if ((argc!=1) || !GF_JS_InstanceOf(c, obj, &html_media_rt->timeRangesClass, NULL)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + timeranges = (GF_HTML_MediaTimeRanges *)SMJS_GET_PRIVATE(c, obj); + if (!timeranges) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + if (JSVAL_IS_INT(argv[0])) { + u32 i = JSVAL_TO_INT(argv[0]); + u64 *end_value = (u64 *)gf_list_get(timeranges->times, 2*i+1); + if (!end_value) { + return dom_throw_exception(c, GF_DOM_EXC_INDEX_SIZE_ERR); + } else { + SMJS_SET_RVAL(DOUBLE_TO_JSVAL(JS_NewDouble(c, (*end_value)*1.0/timeranges->timescale))); + } + } else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } - return JS_TRUE; + return JS_TRUE; } static Bool html_is_track_list(JSContext *c, JSObject *obj) { @@ -1159,284 +1162,284 @@ static Bool html_is_track_list(JSContext *c, JSObject *obj) { } static SMJS_FUNC_PROP_GET(html_track_list_get_length) - GF_HTML_TrackList *tracklist; - if (html_is_track_list(c, obj)) { - tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - if (tracklist) { - *vp = INT_TO_JSVAL( gf_list_count(tracklist->tracks) ); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +GF_HTML_TrackList *tracklist; +if (html_is_track_list(c, obj)) { + tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + if (tracklist) { + *vp = INT_TO_JSVAL( gf_list_count(tracklist->tracks) ); + return JS_TRUE; } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static JSBool SMJS_FUNCTION(html_track_list_get_track_by_id) { - SMJS_OBJ - SMJS_ARGS + SMJS_OBJ + SMJS_ARGS if (html_is_track_list(c, obj)) { GF_HTML_TrackList *tracklist; GF_HTML_Track *track; - char *str; + char *str; tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); str = SMJS_CHARS_FROM_STRING(c, JS_ValueToString(c, argv[0]) ); track = html_media_tracklist_get_track(tracklist, str); SMJS_FREE(c, str); if (track) { SMJS_SET_RVAL(OBJECT_TO_JSVAL(track->_this)); - return JS_TRUE; + return JS_TRUE; } else { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } } static SMJS_FUNC_PROP_GET(html_track_list_get_property) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist; - s32 index; - - tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - index = SMJS_ID_TO_INT(id); - if (index >= 0 && (u32)index < gf_list_count(tracklist->tracks)) { - GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, (u32)index); - *vp = OBJECT_TO_JSVAL(track->_this); - } - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist; + s32 index; + + tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + index = SMJS_ID_TO_INT(id); + if (index >= 0 && (u32)index < gf_list_count(tracklist->tracks)) { + GF_HTML_Track *track = (GF_HTML_Track *)gf_list_get(tracklist->tracks, (u32)index); + *vp = OBJECT_TO_JSVAL(track->_this); } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_track_list_get_selected_index) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - *vp = INT_TO_JSVAL(tracklist->selected_index); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + *vp = INT_TO_JSVAL(tracklist->selected_index); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_track_list_get_onchange) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - if (! JSVAL_IS_NULL(tracklist->onchange)) { - *vp = tracklist->onchange; - } else { - *vp = JSVAL_NULL; - } - return JS_TRUE; +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + if (! JSVAL_IS_NULL(tracklist->onchange)) { + *vp = tracklist->onchange; } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + *vp = JSVAL_NULL; } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } JSBool gf_set_js_eventhandler(JSContext *c, jsval vp, jsval *callbackfuncval); static SMJS_FUNC_PROP_SET(html_track_list_set_onchange) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - gf_set_js_eventhandler(c, *vp, &tracklist->onchange); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + gf_set_js_eventhandler(c, *vp, &tracklist->onchange); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_track_list_get_onaddtrack) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - if (! JSVAL_IS_NULL(tracklist->onaddtrack)) { - *vp = tracklist->onaddtrack; - } else { - *vp = JSVAL_NULL; - } - return JS_TRUE; +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + if (! JSVAL_IS_NULL(tracklist->onaddtrack)) { + *vp = tracklist->onaddtrack; } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + *vp = JSVAL_NULL; } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_SET(html_track_list_set_onaddtrack) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - gf_set_js_eventhandler(c, *vp, &tracklist->onaddtrack); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + gf_set_js_eventhandler(c, *vp, &tracklist->onaddtrack); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_track_list_get_onremovetrack) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - if (! JSVAL_IS_NULL(tracklist->onremovetrack) ) { - *vp = tracklist->onremovetrack; - } else { - *vp = JSVAL_NULL; - } - return JS_TRUE; +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + if (! JSVAL_IS_NULL(tracklist->onremovetrack) ) { + *vp = tracklist->onremovetrack; } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + *vp = JSVAL_NULL; } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_SET(html_track_list_set_onremovetrack) - if (html_is_track_list(c, obj)) { - GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); - gf_set_js_eventhandler(c, *vp, &tracklist->onremovetrack); - return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } +if (html_is_track_list(c, obj)) { + GF_HTML_TrackList *tracklist = (GF_HTML_TrackList *)SMJS_GET_PRIVATE(c, obj); + gf_set_js_eventhandler(c, *vp, &tracklist->onremovetrack); + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_track_get_property) - if (html_is_track_list(c, obj)) { - GF_HTML_Track *track = (GF_HTML_Track *)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - switch (SMJS_ID_TO_INT(id)) { - case HTML_TRACK_PROP_ID: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->id ? track->id : "") ); - return JS_TRUE; - case HTML_TRACK_PROP_KIND: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->kind ? track->kind : "") ); - return JS_TRUE; - case HTML_TRACK_PROP_LABEL: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->label ? track->label : "") ); - return JS_TRUE; - case HTML_TRACK_PROP_LANGUAGE: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->language ? track->language : "") ); - return JS_TRUE; - case HTML_TRACK_PROP_INBANDTYPE: - if (GF_JS_InstanceOf(c, obj, &html_media_rt->textTrackClass, NULL)) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->mime ? track->mime : "") ); - return JS_TRUE; - } - case HTML_TRACK_PROP_SELECTED: - if (GF_JS_InstanceOf(c, obj, &html_media_rt->videoTrackClass, NULL)) { - *vp = BOOLEAN_TO_JSVAL(track->enabled_or_selected ? JS_TRUE : JS_FALSE); - } - return JS_TRUE; - case HTML_TRACK_PROP_ENABLED: - if (GF_JS_InstanceOf(c, obj, &html_media_rt->audioTrackClass, NULL)) { - *vp = BOOLEAN_TO_JSVAL(track->enabled_or_selected ? JS_TRUE : JS_FALSE); - } - return JS_TRUE; - } +if (html_is_track_list(c, obj)) { + GF_HTML_Track *track = (GF_HTML_Track *)SMJS_GET_PRIVATE(c, obj); + if (!SMJS_ID_IS_INT(id)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + switch (SMJS_ID_TO_INT(id)) { + case HTML_TRACK_PROP_ID: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->id ? track->id : "") ); + return JS_TRUE; + case HTML_TRACK_PROP_KIND: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->kind ? track->kind : "") ); + return JS_TRUE; + case HTML_TRACK_PROP_LABEL: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->label ? track->label : "") ); + return JS_TRUE; + case HTML_TRACK_PROP_LANGUAGE: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->language ? track->language : "") ); + return JS_TRUE; + case HTML_TRACK_PROP_INBANDTYPE: + if (GF_JS_InstanceOf(c, obj, &html_media_rt->textTrackClass, NULL)) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, track->mime ? track->mime : "") ); + return JS_TRUE; + } + case HTML_TRACK_PROP_SELECTED: + if (GF_JS_InstanceOf(c, obj, &html_media_rt->videoTrackClass, NULL)) { + *vp = BOOLEAN_TO_JSVAL(track->enabled_or_selected ? JS_TRUE : JS_FALSE); + } + return JS_TRUE; + case HTML_TRACK_PROP_ENABLED: + if (GF_JS_InstanceOf(c, obj, &html_media_rt->audioTrackClass, NULL)) { + *vp = BOOLEAN_TO_JSVAL(track->enabled_or_selected ? JS_TRUE : JS_FALSE); + } return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_SET(html_track_set_property) - if (html_is_track_list(c, obj)) { - GF_HTML_Track *track = (GF_HTML_Track *)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - switch (SMJS_ID_TO_INT(id)) { - case HTML_TRACK_PROP_SELECTED: - if (GF_JS_InstanceOf(c, obj, &html_media_rt->videoTrackClass, NULL)) - { - track->enabled_or_selected = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); - } - return JS_TRUE; - case HTML_TRACK_PROP_ENABLED: - if (GF_JS_InstanceOf(c, obj, &html_media_rt->audioTrackClass, NULL)) - { - track->enabled_or_selected = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); - } - return JS_TRUE; - } +if (html_is_track_list(c, obj)) { + GF_HTML_Track *track = (GF_HTML_Track *)SMJS_GET_PRIVATE(c, obj); + if (!SMJS_ID_IS_INT(id)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + switch (SMJS_ID_TO_INT(id)) { + case HTML_TRACK_PROP_SELECTED: + if (GF_JS_InstanceOf(c, obj, &html_media_rt->videoTrackClass, NULL)) + { + track->enabled_or_selected = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); + } + return JS_TRUE; + case HTML_TRACK_PROP_ENABLED: + if (GF_JS_InstanceOf(c, obj, &html_media_rt->audioTrackClass, NULL)) + { + track->enabled_or_selected = (JSVAL_TO_BOOLEAN(*vp) == JS_TRUE ? GF_TRUE : GF_FALSE); + } return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_GET(html_video_get_property) - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL)) - { - GF_FieldInfo info; - SVG_video_stack *video; - GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); - if (!n) return JS_TRUE; - - video = (SVG_video_stack *)n->sgprivate->UserPrivate; - if (!SMJS_ID_IS_INT(id)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - switch (SMJS_ID_TO_INT(id)) { - case HTML_VIDEO_PROP_WIDTH: - if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_width, GF_TRUE, GF_TRUE, &info)==GF_OK) { - SVG_Length *length; - length = (SVG_Length *)info.far_ptr; - *vp = INT_TO_JSVAL( FIX2FLT(length->value) ); - } - return JS_TRUE; - case HTML_VIDEO_PROP_HEIGHT: - if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_height, GF_TRUE, GF_TRUE, &info)==GF_OK) { - SVG_Length *length; - length = (SVG_Length *)info.far_ptr; - *vp = INT_TO_JSVAL( FIX2FLT(length->value) ); - } - return JS_TRUE; - case HTML_VIDEO_PROP_VIDEOWIDTH: - *vp = INT_TO_JSVAL( video->txh.width ); - return JS_TRUE; - case HTML_VIDEO_PROP_VIDEOHEIGHT: - *vp = INT_TO_JSVAL( video->txh.height ); - return JS_TRUE; - case HTML_VIDEO_PROP_POSTER: - if (gf_node_get_attribute_by_name(n, "poster", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { - char *szAtt = gf_svg_dump_attribute(n, &info); - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); - if (szAtt) gf_free(szAtt); - } - return JS_TRUE; - } +if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL)) +{ + GF_FieldInfo info; + SVG_video_stack *video; + GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); + if (!n) return JS_TRUE; + + video = (SVG_video_stack *)n->sgprivate->UserPrivate; + if (!SMJS_ID_IS_INT(id)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + switch (SMJS_ID_TO_INT(id)) { + case HTML_VIDEO_PROP_WIDTH: + if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_width, GF_TRUE, GF_TRUE, &info)==GF_OK) { + SVG_Length *length; + length = (SVG_Length *)info.far_ptr; + *vp = INT_TO_JSVAL( FIX2FLT(length->value) ); + } + return JS_TRUE; + case HTML_VIDEO_PROP_HEIGHT: + if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_height, GF_TRUE, GF_TRUE, &info)==GF_OK) { + SVG_Length *length; + length = (SVG_Length *)info.far_ptr; + *vp = INT_TO_JSVAL( FIX2FLT(length->value) ); + } + return JS_TRUE; + case HTML_VIDEO_PROP_VIDEOWIDTH: + *vp = INT_TO_JSVAL( video->txh.width ); + return JS_TRUE; + case HTML_VIDEO_PROP_VIDEOHEIGHT: + *vp = INT_TO_JSVAL( video->txh.height ); + return JS_TRUE; + case HTML_VIDEO_PROP_POSTER: + if (gf_node_get_attribute_by_name(n, "poster", GF_XMLNS_SVG, GF_TRUE, GF_TRUE, &info)==GF_OK) { + char *szAtt = gf_svg_dump_attribute(n, &info); + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, szAtt) ); + if (szAtt) gf_free(szAtt); + } return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static SMJS_FUNC_PROP_SET(html_video_set_property) - if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL)) - { - GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - switch (SMJS_ID_TO_INT(id)) { - case HTML_VIDEO_PROP_WIDTH: - /* TODO: change value and dirty node */ - return JS_TRUE; - case HTML_VIDEO_PROP_HEIGHT: - /* TODO: change value and dirty node */ - return JS_TRUE; - case HTML_VIDEO_PROP_POSTER: - { - char *str = SMJS_CHARS_FROM_STRING(c, JS_ValueToString(c, *vp) ); - gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "poster", str); - SMJS_FREE(c, str); - return JS_TRUE; - } - } +if (GF_JS_InstanceOf(c, obj, &html_media_rt->htmlVideoElementClass, NULL)) +{ + GF_Node *n = (GF_Node *)SMJS_GET_PRIVATE(c, obj); + if (!SMJS_ID_IS_INT(id)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + switch (SMJS_ID_TO_INT(id)) { + case HTML_VIDEO_PROP_WIDTH: + /* TODO: change value and dirty node */ + return JS_TRUE; + case HTML_VIDEO_PROP_HEIGHT: + /* TODO: change value and dirty node */ + return JS_TRUE; + case HTML_VIDEO_PROP_POSTER: + { + char *str = SMJS_CHARS_FROM_STRING(c, JS_ValueToString(c, *vp) ); + gf_svg_set_attributeNS(n, GF_XMLNS_SVG, "poster", str); + SMJS_FREE(c, str); return JS_TRUE; - } else { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } + } + return JS_TRUE; +} else { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} } static JSBool SMJS_FUNCTION(html_media_event_add_listener) @@ -1459,258 +1462,258 @@ static JSBool SMJS_FUNCTION(html_media_event_dispatch) void html_media_source_init_js_api(JSContext *js_ctx, JSObject *global, GF_HTML_MediaRuntime *html_media_rt); void html_media_js_api_del() { - if (html_media_rt) { + if (html_media_rt) { gf_free(html_media_rt); html_media_rt = NULL; } } void html_media_init_js_api(GF_SceneGraph *scene) { - /* HTML Media Element */ - if (!html_media_rt) { - GF_SAFEALLOC(html_media_rt, GF_HTML_MediaRuntime); - - /* Setting up MediaError class (no constructor, no finalizer) */ - JS_SETUP_CLASS(html_media_rt->mediaErrorClass, "MediaError", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec mediaErrorClassProps[] = { - {"MEDIA_ERR_ABORTED", MEDIA_ERROR_PROP_ABORTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, - {"MEDIA_ERR_NETWORK", MEDIA_ERROR_PROP_NETWORK, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, - {"MEDIA_ERR_DECODE", MEDIA_ERROR_PROP_DECODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, - {"MEDIA_ERR_SRC_NOT_SUPPORTED", MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, - {"code", MEDIA_ERROR_PROP_CODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec mediaErrorClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->mediaErrorClass, 0, 0, mediaErrorClassProps, mediaErrorClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] MediaError class initialized\n")); - } - - /* Setting up TimeRanges class (no constructor, no finalizer) */ - JS_SETUP_CLASS(html_media_rt->timeRangesClass, "TimeRanges", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec timeRangesClassProps[] = { - {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_time_ranges_get_length, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec timeRangesClassFuncs[] = { - SMJS_FUNCTION_SPEC("start", html_time_ranges_start, 1), - SMJS_FUNCTION_SPEC("end", html_time_ranges_end, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->timeRangesClass, 0, 0, timeRangesClassProps, timeRangesClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TimeRanges class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->audioTrackClass, "AudioTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); - { - JSPropertySpec audioTrackClassProps[] = { - {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"enabled", HTML_TRACK_PROP_SELECTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec audioTrackClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->audioTrackClass, 0, 0, audioTrackClassProps, audioTrackClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] AudioTrack class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->videoTrackClass, "VideoTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); - { - JSPropertySpec videoTrackClassProps[] = { - {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"selected", HTML_TRACK_PROP_SELECTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec videoTrackClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->videoTrackClass, 0, 0, videoTrackClassProps, videoTrackClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] VideoTrack class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->textTrackClass, "TextTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); - { - JSPropertySpec textTrackClassProps[] = { - {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"inBandMetadataTrackDispatchType", HTML_TRACK_PROP_INBANDTYPE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec textTrackClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->textTrackClass, 0, 0, textTrackClassProps, textTrackClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TextTrack class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->audioTrackListClass, "AudioTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec audioTrackListClassProps[] = { - {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, - {"onchange", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onchange, html_track_list_set_onchange}, - {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, - {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec audioTrackListClassFuncs[] = { - SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->audioTrackListClass, 0, 0, audioTrackListClassProps, audioTrackListClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] AudioTrackList class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->videoTrackListClass, "VideoTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec videoTrackListClassProps[] = { - {"selectedIndex", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_selected_index, 0}, - {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, - {"onchange", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onchange, html_track_list_set_onchange}, - {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, - {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec videoTrackListClassFuncs[] = { - SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->videoTrackListClass, 0, 0, videoTrackListClassProps, videoTrackListClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] VideoTrackList class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->textTrackListClass, "TextTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec textTrackListClassProps[] = { - {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, - {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, - {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec textTrackListClassFuncs[] = { - SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->textTrackListClass, 0, 0, textTrackListClassProps, textTrackListClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TextTrackList class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->mediaControllerClass, "MediaController", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec mediaControllerClassProps[] = { - {0, 0, 0, 0, 0} - }; - JSFunctionSpec mediaControllerClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->mediaControllerClass, 0, 0, mediaControllerClassProps, mediaControllerClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] MediaController class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->htmlMediaElementClass, "HTMLMediaElement", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); - { - JSPropertySpec htmlMediaElementClassProps[] = { - {"error", HTML_MEDIA_PROP_ERROR, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_error, 0}, - {"src", HTML_MEDIA_PROP_SRC, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , html_media_get_src, html_media_set_src}, - {"currentSrc", HTML_MEDIA_PROP_CURRENTSRC, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_src, 0}, - {"crossOrigin", HTML_MEDIA_PROP_CROSSORIGIN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_cors, html_media_set_cors}, - {"NETWORK_EMPTY", HTML_MEDIA_PROP_NETWORK_EMPTY, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"NETWORK_IDLE", HTML_MEDIA_PROP_NETWORK_IDLE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"NETWORK_LOADING", HTML_MEDIA_PROP_NETWORK_LOADING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"NETWORK_NO_SOURCE", HTML_MEDIA_PROP_NETWORK_NO_SOURCE,JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"networkState", HTML_MEDIA_PROP_NETWORKSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_network_state, 0}, - {"preload", HTML_MEDIA_PROP_PRELOAD, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_preload, html_media_set_preload}, - {"buffered", HTML_MEDIA_PROP_BUFFERED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_buffered, 0}, - {"HAVE_NOTHING", HTML_MEDIA_PROP_HAVE_NOTHING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"HAVE_METADATA", HTML_MEDIA_PROP_HAVE_METADATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"HAVE_CURRENT_DATA", HTML_MEDIA_PROP_HAVE_CURRENT_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"HAVE_FUTURE_DATA", HTML_MEDIA_PROP_HAVE_FUTURE_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"HAVE_ENOUGH_DATA", HTML_MEDIA_PROP_HAVE_ENOUGH_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, - {"readyState", HTML_MEDIA_PROP_READYSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_ready_state, 0}, - {"seeking", HTML_MEDIA_PROP_SEEKING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_seeking, 0}, - {"currentTime", HTML_MEDIA_PROP_CURRENTTIME, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_current_time, html_media_set_current_time}, - {"duration", HTML_MEDIA_PROP_DURATION, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_duration, 0}, - {"startDate", HTML_MEDIA_PROP_STARTDATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_start_date, 0}, - {"paused", HTML_MEDIA_PROP_PAUSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_paused, 0}, - {"defaultPlaybackRate", HTML_MEDIA_PROP_DEFAULTPLAYBACKRATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_default_playback_rate, html_media_set_default_playback_rate}, - {"playbackRate", HTML_MEDIA_PROP_PLAYBACKRATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_playback_rate, html_media_set_playback_rate}, - {"played", HTML_MEDIA_PROP_PLAYED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_played, 0}, - {"seekable", HTML_MEDIA_PROP_SEEKABLE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_seekable, 0}, - {"ended", HTML_MEDIA_PROP_ENDED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_ended, 0}, - {"autoplay", HTML_MEDIA_PROP_AUTOPLAY, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_autoplay, html_media_set_autoplay}, - {"loop", HTML_MEDIA_PROP_LOOP, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_loop, html_media_set_loop}, - {"mediaGroup", HTML_MEDIA_PROP_MEDIAGROUP, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_mediagroup, html_media_set_mediagroup}, - {"controller", HTML_MEDIA_PROP_CONTROLLER, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_controller, html_media_set_controller}, - {"controls", HTML_MEDIA_PROP_CONTROLS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_controls, html_media_set_controls}, - {"volume", HTML_MEDIA_PROP_VOLUME, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_volume, html_media_set_volume}, - {"muted", HTML_MEDIA_PROP_MUTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_muted, html_media_set_muted}, - {"defaultMuted", HTML_MEDIA_PROP_DEFAULTMUTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_default_muted, html_media_set_default_muted}, - {"audioTracks", HTML_MEDIA_PROP_AUDIOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_audio_tracks, 0}, - {"videoTracks", HTML_MEDIA_PROP_VIDEOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_video_tracks, 0}, - {"textTracks", HTML_MEDIA_PROP_TEXTTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_text_tracks, 0}, - {0, 0, 0, 0, 0} - }; - JSBool SMJS_FUNCTION(svg_udom_smil_pause); - JSBool SMJS_FUNCTION(svg_udom_smil_begin); - JSBool SMJS_FUNCTION(svg_udom_smil_end); - JSFunctionSpec htmlMediaElementClassFuncs[] = { - SMJS_FUNCTION_SPEC("load", html_media_load, 0), - SMJS_FUNCTION_SPEC("canPlayType", html_media_canPlayType, 1), - SMJS_FUNCTION_SPEC("fastSeek", html_media_fastSeek, 1), - SMJS_FUNCTION_SPEC("play", svg_udom_smil_begin, 0), - SMJS_FUNCTION_SPEC("pause", svg_udom_smil_pause, 0), - SMJS_FUNCTION_SPEC("addTextTrack", html_media_addTextTrack, 1), + /* HTML Media Element */ + if (!html_media_rt) { + GF_SAFEALLOC(html_media_rt, GF_HTML_MediaRuntime); + + /* Setting up MediaError class (no constructor, no finalizer) */ + JS_SETUP_CLASS(html_media_rt->mediaErrorClass, "MediaError", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec mediaErrorClassProps[] = { + {"MEDIA_ERR_ABORTED", MEDIA_ERROR_PROP_ABORTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, + {"MEDIA_ERR_NETWORK", MEDIA_ERROR_PROP_NETWORK, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, + {"MEDIA_ERR_DECODE", MEDIA_ERROR_PROP_DECODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, + {"MEDIA_ERR_SRC_NOT_SUPPORTED", MEDIA_ERROR_PROP_SRC_NOT_SUPPORTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, + {"code", MEDIA_ERROR_PROP_CODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_error_get_code, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec mediaErrorClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->mediaErrorClass, 0, 0, mediaErrorClassProps, mediaErrorClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] MediaError class initialized\n")); + } + + /* Setting up TimeRanges class (no constructor, no finalizer) */ + JS_SETUP_CLASS(html_media_rt->timeRangesClass, "TimeRanges", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec timeRangesClassProps[] = { + {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_time_ranges_get_length, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec timeRangesClassFuncs[] = { + SMJS_FUNCTION_SPEC("start", html_time_ranges_start, 1), + SMJS_FUNCTION_SPEC("end", html_time_ranges_end, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->timeRangesClass, 0, 0, timeRangesClassProps, timeRangesClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TimeRanges class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->audioTrackClass, "AudioTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); + { + JSPropertySpec audioTrackClassProps[] = { + {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"enabled", HTML_TRACK_PROP_SELECTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec audioTrackClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->audioTrackClass, 0, 0, audioTrackClassProps, audioTrackClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] AudioTrack class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->videoTrackClass, "VideoTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); + { + JSPropertySpec videoTrackClassProps[] = { + {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"selected", HTML_TRACK_PROP_SELECTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec videoTrackClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->videoTrackClass, 0, 0, videoTrackClassProps, videoTrackClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] VideoTrack class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->textTrackClass, "TextTrack", JSCLASS_HAS_PRIVATE, html_track_get_property, html_track_set_property, JS_FinalizeStub); + { + JSPropertySpec textTrackClassProps[] = { + {"id", HTML_TRACK_PROP_ID, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"kind", HTML_TRACK_PROP_KIND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"label", HTML_TRACK_PROP_LABEL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"language", HTML_TRACK_PROP_LANGUAGE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"inBandMetadataTrackDispatchType", HTML_TRACK_PROP_INBANDTYPE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec textTrackClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->textTrackClass, 0, 0, textTrackClassProps, textTrackClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TextTrack class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->audioTrackListClass, "AudioTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec audioTrackListClassProps[] = { + {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, + {"onchange", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onchange, html_track_list_set_onchange}, + {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, + {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec audioTrackListClassFuncs[] = { + SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->audioTrackListClass, 0, 0, audioTrackListClassProps, audioTrackListClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] AudioTrackList class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->videoTrackListClass, "VideoTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec videoTrackListClassProps[] = { + {"selectedIndex", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_selected_index, 0}, + {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, + {"onchange", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onchange, html_track_list_set_onchange}, + {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, + {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec videoTrackListClassFuncs[] = { + SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->videoTrackListClass, 0, 0, videoTrackListClassProps, videoTrackListClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] VideoTrackList class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->textTrackListClass, "TextTrackList", JSCLASS_HAS_PRIVATE, html_track_list_get_property, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec textTrackListClassProps[] = { + {"length", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_track_list_get_length, 0}, + {"onaddtrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onaddtrack, html_track_list_set_onaddtrack}, + {"onremovetrack", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_track_list_get_onremovetrack, html_track_list_set_onremovetrack}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec textTrackListClassFuncs[] = { + SMJS_FUNCTION_SPEC("getTrackById", html_track_list_get_track_by_id, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->textTrackListClass, 0, 0, textTrackListClassProps, textTrackListClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] TextTrackList class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->mediaControllerClass, "MediaController", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec mediaControllerClassProps[] = { + {0, 0, 0, 0, 0} + }; + JSFunctionSpec mediaControllerClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, 0, &html_media_rt->mediaControllerClass, 0, 0, mediaControllerClassProps, mediaControllerClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] MediaController class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->htmlMediaElementClass, "HTMLMediaElement", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + { + JSPropertySpec htmlMediaElementClassProps[] = { + {"error", HTML_MEDIA_PROP_ERROR, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_error, 0}, + {"src", HTML_MEDIA_PROP_SRC, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , html_media_get_src, html_media_set_src}, + {"currentSrc", HTML_MEDIA_PROP_CURRENTSRC, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_src, 0}, + {"crossOrigin", HTML_MEDIA_PROP_CROSSORIGIN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_cors, html_media_set_cors}, + {"NETWORK_EMPTY", HTML_MEDIA_PROP_NETWORK_EMPTY, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"NETWORK_IDLE", HTML_MEDIA_PROP_NETWORK_IDLE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"NETWORK_LOADING", HTML_MEDIA_PROP_NETWORK_LOADING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"NETWORK_NO_SOURCE", HTML_MEDIA_PROP_NETWORK_NO_SOURCE,JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"networkState", HTML_MEDIA_PROP_NETWORKSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_network_state, 0}, + {"preload", HTML_MEDIA_PROP_PRELOAD, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_preload, html_media_set_preload}, + {"buffered", HTML_MEDIA_PROP_BUFFERED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_buffered, 0}, + {"HAVE_NOTHING", HTML_MEDIA_PROP_HAVE_NOTHING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"HAVE_METADATA", HTML_MEDIA_PROP_HAVE_METADATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"HAVE_CURRENT_DATA", HTML_MEDIA_PROP_HAVE_CURRENT_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"HAVE_FUTURE_DATA", HTML_MEDIA_PROP_HAVE_FUTURE_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"HAVE_ENOUGH_DATA", HTML_MEDIA_PROP_HAVE_ENOUGH_DATA, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_const, 0}, + {"readyState", HTML_MEDIA_PROP_READYSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_ready_state, 0}, + {"seeking", HTML_MEDIA_PROP_SEEKING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_seeking, 0}, + {"currentTime", HTML_MEDIA_PROP_CURRENTTIME, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_current_time, html_media_set_current_time}, + {"duration", HTML_MEDIA_PROP_DURATION, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_duration, 0}, + {"startDate", HTML_MEDIA_PROP_STARTDATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_start_date, 0}, + {"paused", HTML_MEDIA_PROP_PAUSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_paused, 0}, + {"defaultPlaybackRate", HTML_MEDIA_PROP_DEFAULTPLAYBACKRATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_default_playback_rate, html_media_set_default_playback_rate}, + {"playbackRate", HTML_MEDIA_PROP_PLAYBACKRATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_playback_rate, html_media_set_playback_rate}, + {"played", HTML_MEDIA_PROP_PLAYED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_played, 0}, + {"seekable", HTML_MEDIA_PROP_SEEKABLE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_seekable, 0}, + {"ended", HTML_MEDIA_PROP_ENDED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_ended, 0}, + {"autoplay", HTML_MEDIA_PROP_AUTOPLAY, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_autoplay, html_media_set_autoplay}, + {"loop", HTML_MEDIA_PROP_LOOP, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_loop, html_media_set_loop}, + {"mediaGroup", HTML_MEDIA_PROP_MEDIAGROUP, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_mediagroup, html_media_set_mediagroup}, + {"controller", HTML_MEDIA_PROP_CONTROLLER, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_controller, html_media_set_controller}, + {"controls", HTML_MEDIA_PROP_CONTROLS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_controls, html_media_set_controls}, + {"volume", HTML_MEDIA_PROP_VOLUME, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_volume, html_media_set_volume}, + {"muted", HTML_MEDIA_PROP_MUTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_muted, html_media_set_muted}, + {"defaultMuted", HTML_MEDIA_PROP_DEFAULTMUTED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, html_media_get_default_muted, html_media_set_default_muted}, + {"audioTracks", HTML_MEDIA_PROP_AUDIOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_audio_tracks, 0}, + {"videoTracks", HTML_MEDIA_PROP_VIDEOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_video_tracks, 0}, + {"textTracks", HTML_MEDIA_PROP_TEXTTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, html_media_get_text_tracks, 0}, + {0, 0, 0, 0, 0} + }; + JSBool SMJS_FUNCTION(svg_udom_smil_pause); + JSBool SMJS_FUNCTION(svg_udom_smil_begin); + JSBool SMJS_FUNCTION(svg_udom_smil_end); + JSFunctionSpec htmlMediaElementClassFuncs[] = { + SMJS_FUNCTION_SPEC("load", html_media_load, 0), + SMJS_FUNCTION_SPEC("canPlayType", html_media_canPlayType, 1), + SMJS_FUNCTION_SPEC("fastSeek", html_media_fastSeek, 1), + SMJS_FUNCTION_SPEC("play", svg_udom_smil_begin, 0), + SMJS_FUNCTION_SPEC("pause", svg_udom_smil_pause, 0), + SMJS_FUNCTION_SPEC("addTextTrack", html_media_addTextTrack, 1), SMJS_FUNCTION_SPEC("addEventListener", html_media_event_add_listener, 3), SMJS_FUNCTION_SPEC("removeEventListener", html_media_event_remove_listener, 3), SMJS_FUNCTION_SPEC("dispatchEvent", html_media_event_dispatch, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - JSObject *elt_proto = dom_js_get_element_proto(scene->svg_js->js_ctx); - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, elt_proto, &html_media_rt->htmlMediaElementClass, 0, 0, htmlMediaElementClassProps, htmlMediaElementClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLMediaElement class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->htmlVideoElementClass, "HTMLVideoElement", JSCLASS_HAS_PRIVATE, html_video_get_property, html_video_set_property, dom_element_finalize); - { - JSPropertySpec htmlVideoElementClassProps[] = { - {"width", HTML_VIDEO_PROP_WIDTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, - {"height", HTML_VIDEO_PROP_HEIGHT, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, - {"videoWidth", HTML_VIDEO_PROP_VIDEOWIDTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"videoHeight", HTML_VIDEO_PROP_VIDEOHEIGHT, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {"poster", HTML_VIDEO_PROP_POSTER, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec htmlVideoElementClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt->htmlMediaElementClass._proto, &html_media_rt->htmlVideoElementClass, 0, 0, htmlVideoElementClassProps, htmlVideoElementClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLVideoElement class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->htmlAudioElementClass, "HTMLAudioElement", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, dom_element_finalize); - { - JSPropertySpec htmlAudioElementClassProps[] = { - {0, 0, 0, 0, 0} - }; - JSFunctionSpec htmlAudioElementClassFuncs[] = { - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt->htmlMediaElementClass._proto, &html_media_rt->htmlAudioElementClass, 0, 0, htmlAudioElementClassProps, htmlAudioElementClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLAudioElement class initialized\n")); - } - html_media_source_init_js_api(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt); - } + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + JSObject *elt_proto = dom_js_get_element_proto(scene->svg_js->js_ctx); + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, elt_proto, &html_media_rt->htmlMediaElementClass, 0, 0, htmlMediaElementClassProps, htmlMediaElementClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLMediaElement class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->htmlVideoElementClass, "HTMLVideoElement", JSCLASS_HAS_PRIVATE, html_video_get_property, html_video_set_property, dom_element_finalize); + { + JSPropertySpec htmlVideoElementClassProps[] = { + {"width", HTML_VIDEO_PROP_WIDTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, + {"height", HTML_VIDEO_PROP_HEIGHT, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, + {"videoWidth", HTML_VIDEO_PROP_VIDEOWIDTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"videoHeight", HTML_VIDEO_PROP_VIDEOHEIGHT, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {"poster", HTML_VIDEO_PROP_POSTER, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED , 0, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec htmlVideoElementClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt->htmlMediaElementClass._proto, &html_media_rt->htmlVideoElementClass, 0, 0, htmlVideoElementClassProps, htmlVideoElementClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLVideoElement class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->htmlAudioElementClass, "HTMLAudioElement", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, dom_element_finalize); + { + JSPropertySpec htmlAudioElementClassProps[] = { + {0, 0, 0, 0, 0} + }; + JSFunctionSpec htmlAudioElementClassFuncs[] = { + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt->htmlMediaElementClass._proto, &html_media_rt->htmlAudioElementClass, 0, 0, htmlAudioElementClassProps, htmlAudioElementClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTMLMediaAPI] HTMLAudioElement class initialized\n")); + } + html_media_source_init_js_api(scene->svg_js->js_ctx, scene->svg_js->global, html_media_rt); + } } #endif /*GPAC_HAS_SPIDERMONKEY*/ diff --git a/src/scenegraph/html5_mse_smjs.c b/src/scenegraph/html5_mse_smjs.c index 6ecd526..7150770 100644 --- a/src/scenegraph/html5_mse_smjs.c +++ b/src/scenegraph/html5_mse_smjs.c @@ -39,26 +39,26 @@ #define JSVAL_CHECK_STRING(_v) (JSVAL_IS_STRING(_v) || JSVAL_IS_NULL(_v)) -typedef enum +typedef enum { - /* MediaSource properties */ - HTML_MEDIASOURCE_PROP_SOURCEBUFFERS = -1, - HTML_MEDIASOURCE_PROP_ACTIVESOURCEBUFFERS = -2, - HTML_MEDIASOURCE_PROP_DURATION = -3, - HTML_MEDIASOURCE_PROP_READYSTATE = -4, - /* SourceBuffer properties */ - HTML_SOURCEBUFFER_PROP_MODE = -5, - HTML_SOURCEBUFFER_PROP_UPDATING = -6, - HTML_SOURCEBUFFER_PROP_BUFFERED = -7, - HTML_SOURCEBUFFER_PROP_TIMESTAMPOFFSET = -8, - HTML_SOURCEBUFFER_PROP_TIMESCALE = -9, - HTML_SOURCEBUFFER_PROP_AUDIOTRACKS = -10, - HTML_SOURCEBUFFER_PROP_VIDEOTRACKS = -11, - HTML_SOURCEBUFFER_PROP_TEXTTRACKS = -12, - HTML_SOURCEBUFFER_PROP_APPENDWINDOWSTART = -13, - HTML_SOURCEBUFFER_PROP_APPENDWINDOWEND = -14, - /* SourceBufferList properties */ - HTML_SOURCEBUFFERLIST_PROP_LENGTH = -15, + /* MediaSource properties */ + HTML_MEDIASOURCE_PROP_SOURCEBUFFERS = -1, + HTML_MEDIASOURCE_PROP_ACTIVESOURCEBUFFERS = -2, + HTML_MEDIASOURCE_PROP_DURATION = -3, + HTML_MEDIASOURCE_PROP_READYSTATE = -4, + /* SourceBuffer properties */ + HTML_SOURCEBUFFER_PROP_MODE = -5, + HTML_SOURCEBUFFER_PROP_UPDATING = -6, + HTML_SOURCEBUFFER_PROP_BUFFERED = -7, + HTML_SOURCEBUFFER_PROP_TIMESTAMPOFFSET = -8, + HTML_SOURCEBUFFER_PROP_TIMESCALE = -9, + HTML_SOURCEBUFFER_PROP_AUDIOTRACKS = -10, + HTML_SOURCEBUFFER_PROP_VIDEOTRACKS = -11, + HTML_SOURCEBUFFER_PROP_TEXTTRACKS = -12, + HTML_SOURCEBUFFER_PROP_APPENDWINDOWSTART = -13, + HTML_SOURCEBUFFER_PROP_APPENDWINDOWEND = -14, + /* SourceBufferList properties */ + HTML_SOURCEBUFFERLIST_PROP_LENGTH = -15, } GF_HTML_MediaSourcePropEnum; static GF_HTML_MediaRuntime *html_media_rt = NULL; @@ -72,12 +72,12 @@ Bool gf_mse_is_mse_object(JSContext *c, JSObject *obj) { static GFINLINE GF_SceneGraph *mediasource_get_scenegraph(JSContext *c) { - GF_SceneGraph *scene; - JSObject *global = JS_GetGlobalObject(c); - assert(global); - scene = (GF_SceneGraph *)SMJS_GET_PRIVATE(c, global); - assert(scene); - return scene; + GF_SceneGraph *scene; + JSObject *global = JS_GetGlobalObject(c); + assert(global); + scene = (GF_SceneGraph *)SMJS_GET_PRIVATE(c, global); + assert(scene); + return scene; } void gf_mse_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarget **target, GF_SceneGraph **sg) { @@ -103,11 +103,11 @@ void gf_mse_get_event_target(JSContext *c, JSObject *obj, GF_DOMEventTarget **ta static void mediasource_sourceBuffer_initjs(JSContext *c, JSObject *ms_obj, GF_HTML_SourceBuffer *sb) { - sb->_this = JS_NewObject(c, &html_media_rt->sourceBufferClass._class, 0, 0); - //gf_js_add_root(c, &sb->_this, GF_JSGC_OBJECT); - SMJS_SET_PRIVATE(c, sb->_this, sb); - sb->buffered->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, sb->_this); - SMJS_SET_PRIVATE(c, sb->buffered->_this, sb->buffered); + sb->_this = JS_NewObject(c, &html_media_rt->sourceBufferClass._class, 0, 0); + //gf_js_add_root(c, &sb->_this, GF_JSGC_OBJECT); + SMJS_SET_PRIVATE(c, sb->_this, sb); + sb->buffered->_this = JS_NewObject(c, &html_media_rt->timeRangesClass._class, NULL, sb->_this); + SMJS_SET_PRIVATE(c, sb->buffered->_this, sb->buffered); } #include @@ -115,72 +115,72 @@ Bool gf_term_is_type_supported(GF_Terminal *term, const char* mime); static JSBool SMJS_FUNCTION(mediasource_is_type_supported) { - SMJS_ARGS - GF_SceneGraph *sg; - GF_JSAPIParam par; - Bool isSupported = GF_TRUE; - char *mime; - if (!argc || !JSVAL_CHECK_STRING(argv[0])) { + SMJS_ARGS + GF_SceneGraph *sg; + GF_JSAPIParam par; + Bool isSupported = GF_TRUE; + char *mime; + if (!argc || !JSVAL_CHECK_STRING(argv[0])) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - mime = SMJS_CHARS(c, argv[0]); - sg = mediasource_get_scenegraph(c); + } + mime = SMJS_CHARS(c, argv[0]); + sg = mediasource_get_scenegraph(c); assert(sg); - if (!strlen(mime)) { + if (!strlen(mime)) { isSupported = GF_FALSE; } else { sg->script_action(sg->script_action_cbck, GF_JSAPI_OP_GET_TERM, NULL, &par); isSupported = gf_term_is_type_supported((GF_Terminal *)par.term, mime); } - SMJS_SET_RVAL(BOOLEAN_TO_JSVAL(isSupported ? JS_TRUE : JS_FALSE)); + SMJS_SET_RVAL(BOOLEAN_TO_JSVAL(isSupported ? JS_TRUE : JS_FALSE)); SMJS_FREE(c, mime); - return JS_TRUE; + return JS_TRUE; } static JSBool SMJS_FUNCTION(mediasource_addSourceBuffer) { - SMJS_OBJ - SMJS_ARGS - GF_HTML_SourceBuffer *sb; - GF_HTML_MediaSource *ms; - const char *mime; + SMJS_OBJ + SMJS_ARGS + GF_HTML_SourceBuffer *sb; + GF_HTML_MediaSource *ms; + const char *mime; GF_Err e; u32 exception = 0; e = GF_OK; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (!argc || !JSVAL_CHECK_STRING(argv[0])) - { + if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - mime = SMJS_CHARS(c, argv[0]); - if (!strlen(mime)) { + } + if (!argc || !JSVAL_CHECK_STRING(argv[0])) + { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + mime = SMJS_CHARS(c, argv[0]); + if (!strlen(mime)) { exception = GF_DOM_EXC_INVALID_ACCESS_ERR; goto exit; - } - ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); + } + ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); if (!ms) { exception = GF_DOM_EXC_INVALID_ACCESS_ERR; goto exit; } else if (ms->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { exception = GF_DOM_EXC_INVALID_STATE_ERR; goto exit; - } - assert(ms->service); - /* + } + assert(ms->service); + /* if (gf_list_count(ms->sourceBuffers.list) > 0) { dom_throw_exception(c, GF_DOM_EXC_QUOTA_EXCEEDED_ERR); e = GF_BAD_PARAM; goto exit; } */ - sb = gf_mse_source_buffer_new(ms); + sb = gf_mse_source_buffer_new(ms); assert(sb); - e = gf_mse_source_buffer_load_parser(sb, mime); + e = gf_mse_source_buffer_load_parser(sb, mime); if (e == GF_OK) { - gf_mse_mediasource_add_source_buffer(ms, sb); + gf_mse_mediasource_add_source_buffer(ms, sb); mediasource_sourceBuffer_initjs(c, obj, sb); SMJS_SET_RVAL( OBJECT_TO_JSVAL(sb->_this) ); } else { @@ -188,7 +188,7 @@ static JSBool SMJS_FUNCTION(mediasource_addSourceBuffer) exception = GF_DOM_EXC_NOT_SUPPORTED_ERR; } exit: - if (mime) { + if (mime) { SMJS_FREE(c, (void *)mime); } if (exception) { @@ -200,49 +200,49 @@ exit: static JSBool SMJS_FUNCTION(mediasource_removeSourceBuffer) { - SMJS_OBJ - SMJS_ARGS - GF_HTML_MediaSource *ms; + SMJS_OBJ + SMJS_ARGS + GF_HTML_MediaSource *ms; GF_HTML_SourceBuffer *sb; JSObject *sb_obj; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); + if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); if (!ms) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } - if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { + if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - sb_obj = JSVAL_TO_OBJECT(argv[0]); - if (!GF_JS_InstanceOf(c, sb_obj, &html_media_rt->sourceBufferClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - sb = (GF_HTML_SourceBuffer *)SMJS_GET_PRIVATE(c, sb_obj); + } + sb_obj = JSVAL_TO_OBJECT(argv[0]); + if (!GF_JS_InstanceOf(c, sb_obj, &html_media_rt->sourceBufferClass, NULL) ) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + sb = (GF_HTML_SourceBuffer *)SMJS_GET_PRIVATE(c, sb_obj); if (!sb) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } else { GF_Err e = gf_mse_remove_source_buffer(ms, sb); if (e == GF_NOT_FOUND) { return dom_throw_exception(c, GF_DOM_EXC_NOT_FOUND_ERR); } } - return JS_TRUE; + return JS_TRUE; } static JSBool SMJS_FUNCTION(mediasource_endOfStream) { - SMJS_OBJ - SMJS_ARGS - GF_HTML_MediaSource *ms; + SMJS_OBJ + SMJS_ARGS + GF_HTML_MediaSource *ms; u32 i; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); + if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); if (!ms) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } if (ms->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); @@ -253,194 +253,194 @@ static JSBool SMJS_FUNCTION(mediasource_endOfStream) return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); } } - if (argc > 0) { + if (argc > 0) { char *error = NULL; if (!JSVAL_CHECK_STRING(argv[0])) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } - error = SMJS_CHARS(c, argv[0]); + error = SMJS_CHARS(c, argv[0]); if (strcmp(error, "decode") && strcmp(error, "network")) { SMJS_FREE(c, error); return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); } SMJS_FREE(c, error); - } + } gf_mse_mediasource_end(ms); - return JS_TRUE; + return JS_TRUE; } static JSBool SMJS_FUNCTION(media_source_constructor) { - GF_HTML_MediaSource *p; - SMJS_OBJ_CONSTRUCTOR(&html_media_rt->mediaSourceClass) + GF_HTML_MediaSource *p; + SMJS_OBJ_CONSTRUCTOR(&html_media_rt->mediaSourceClass) - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) return JS_TRUE; + if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) return JS_TRUE; - p = gf_mse_media_source_new(); - p->c = c; - p->_this = obj; - SMJS_SET_PRIVATE(c, obj, p); + p = gf_mse_media_source_new(); + p->c = c; + p->_this = obj; + SMJS_SET_PRIVATE(c, obj, p); - p->sourceBuffers._this = JS_NewObject(c, &html_media_rt->sourceBufferListClass._class, 0, 0); - SMJS_SET_PRIVATE(c, p->sourceBuffers._this, &p->sourceBuffers); + p->sourceBuffers._this = JS_NewObject(c, &html_media_rt->sourceBufferListClass._class, 0, 0); + SMJS_SET_PRIVATE(c, p->sourceBuffers._this, &p->sourceBuffers); - p->activeSourceBuffers._this = JS_NewObject(c, &html_media_rt->sourceBufferListClass._class, 0, 0); - SMJS_SET_PRIVATE(c, p->activeSourceBuffers._this, &p->activeSourceBuffers); + p->activeSourceBuffers._this = JS_NewObject(c, &html_media_rt->sourceBufferListClass._class, 0, 0); + SMJS_SET_PRIVATE(c, p->activeSourceBuffers._this, &p->activeSourceBuffers); - SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); - return JS_TRUE; + SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); + return JS_TRUE; } static DECL_FINALIZE(media_source_finalize) - GF_HTML_MediaSource *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) return; - p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - gf_mse_mediasource_del(p, GF_TRUE); +GF_HTML_MediaSource *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) return; +p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +gf_mse_mediasource_del(p, GF_TRUE); } static SMJS_FUNC_PROP_GET(media_source_get_source_buffers) - GF_HTML_MediaSource *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - if (!p) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } else { - *vp = OBJECT_TO_JSVAL(p->sourceBuffers._this); - return JS_TRUE; - } - return JS_TRUE; +GF_HTML_MediaSource *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +if (!p) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} else { + *vp = OBJECT_TO_JSVAL(p->sourceBuffers._this); + return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(media_source_get_active_source_buffers) - GF_HTML_MediaSource *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return JS_TRUE; - } - p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - if (p) { - *vp = OBJECT_TO_JSVAL(p->activeSourceBuffers._this); - return JS_TRUE; - } - return JS_TRUE; +GF_HTML_MediaSource *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return JS_TRUE; +} +p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +if (p) { + *vp = OBJECT_TO_JSVAL(p->activeSourceBuffers._this); + return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(media_source_get_ready_state) - GF_HTML_MediaSource *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - if (!p) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } else { - switch (p->readyState) - { - case MEDIA_SOURCE_READYSTATE_CLOSED: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "closed")); - break; - case MEDIA_SOURCE_READYSTATE_OPEN: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "open")); - break; - case MEDIA_SOURCE_READYSTATE_ENDED: - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "ended")); - break; - } - } - return JS_TRUE; +GF_HTML_MediaSource *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +if (!p) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} else { + switch (p->readyState) + { + case MEDIA_SOURCE_READYSTATE_CLOSED: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "closed")); + break; + case MEDIA_SOURCE_READYSTATE_OPEN: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "open")); + break; + case MEDIA_SOURCE_READYSTATE_ENDED: + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "ended")); + break; + } +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(media_source_get_duration) - GF_HTML_MediaSource *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { - return JS_TRUE; - } - p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - if (p) { - if (p->readyState == MEDIA_SOURCE_READYSTATE_CLOSED || p->durationType == DURATION_NAN) { - *vp = JS_GetNaNValue(c); - } else if (p->durationType == DURATION_INFINITY) { - *vp = JS_GetPositiveInfinityValue(c); - } else { - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, p->duration)); - } - return JS_TRUE; - } - return JS_TRUE; +GF_HTML_MediaSource *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL) ) { + return JS_TRUE; +} +p = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +if (p) { + if (p->readyState == MEDIA_SOURCE_READYSTATE_CLOSED || p->durationType == DURATION_NAN) { + *vp = JS_GetNaNValue(c); + } else if (p->durationType == DURATION_INFINITY) { + *vp = JS_GetPositiveInfinityValue(c); + } else { + *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, p->duration)); + } + return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(media_source_set_duration) - GF_HTML_MediaSource *ms; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); - if (!ms) { +GF_HTML_MediaSource *ms; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->mediaSourceClass, NULL)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, obj); +if (!ms) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} else { + if (ms->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); + } else if (!JSVAL_IS_NUMBER(*vp)) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } else { - if (ms->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } else if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } else { - u32 i, count; - count = gf_list_count(ms->sourceBuffers.list); - for (i = 0; i < count; i++) { - GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)gf_list_get(ms->sourceBuffers.list, i); - if (sb->updating) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } + } else { + u32 i, count; + count = gf_list_count(ms->sourceBuffers.list); + for (i = 0; i < count; i++) { + GF_HTML_SourceBuffer *sb = (GF_HTML_SourceBuffer *)gf_list_get(ms->sourceBuffers.list, i); + if (sb->updating) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); } - { - jsdouble durationValue; - JS_ValueToNumber(c, *vp, &durationValue); - if (durationValue < 0) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } else { - ms->duration = durationValue; - ms->durationType = DURATION_VALUE; - /* TODO: call the run duration algorithm */ - } + } + { + jsdouble durationValue; + JS_ValueToNumber(c, *vp, &durationValue); + if (durationValue < 0) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } else { + ms->duration = durationValue; + ms->durationType = DURATION_VALUE; + /* TODO: call the run duration algorithm */ } } } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET( sourcebufferlist_getProperty) - GF_HTML_SourceBufferList *p; - u32 count; - s32 idx; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->sourceBufferListClass, NULL) ) - { - return JS_TRUE; - } - p = (GF_HTML_SourceBufferList *)SMJS_GET_PRIVATE(c, obj); - if (p) { - count = gf_list_count(p->list); - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - - switch (SMJS_ID_TO_INT(id)) { - case HTML_SOURCEBUFFERLIST_PROP_LENGTH: - *vp = INT_TO_JSVAL(count); - break; - default: - idx = SMJS_ID_TO_INT(id); - if ((idx<0) || ((u32) idx>=count)) { - *vp = JSVAL_VOID; - return JS_TRUE; - } else { - GF_HTML_SourceBuffer *sb; - sb = (GF_HTML_SourceBuffer *)gf_list_get(p->list, idx); - *vp = OBJECT_TO_JSVAL(sb->_this); - return JS_TRUE; - } - +GF_HTML_SourceBufferList *p; +u32 count; +s32 idx; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->sourceBufferListClass, NULL) ) +{ + return JS_TRUE; +} +p = (GF_HTML_SourceBufferList *)SMJS_GET_PRIVATE(c, obj); +if (p) { + count = gf_list_count(p->list); + if (!SMJS_ID_IS_INT(id)) return JS_TRUE; + + switch (SMJS_ID_TO_INT(id)) { + case HTML_SOURCEBUFFERLIST_PROP_LENGTH: + *vp = INT_TO_JSVAL(count); + break; + default: + idx = SMJS_ID_TO_INT(id); + if ((idx<0) || ((u32) idx>=count)) { + *vp = JSVAL_VOID; + return JS_TRUE; + } else { + GF_HTML_SourceBuffer *sb; + sb = (GF_HTML_SourceBuffer *)gf_list_get(p->list, idx); + *vp = OBJECT_TO_JSVAL(sb->_this); + return JS_TRUE; } - } - return JS_TRUE; + + } +} +return JS_TRUE; } @@ -484,343 +484,343 @@ static DECL_FINALIZE(sourcebuffer_finalize) static JSBool SMJS_FUNCTION(sourcebuffer_appendBuffer) { - SMJS_OBJ - SMJS_ARGS - GF_HTML_ArrayBuffer *ab; - JSObject *js_ab; - - SB_UPDATING_CHECK - if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_CLOSED) { - return JS_TRUE; - } else if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { + SMJS_OBJ + SMJS_ARGS + GF_HTML_ArrayBuffer *ab; + JSObject *js_ab; + + SB_UPDATING_CHECK + if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_CLOSED) { + return JS_TRUE; + } else if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { gf_mse_mediasource_open(sb->mediasource, NULL); - } + } - if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { + if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - js_ab = JSVAL_TO_OBJECT(argv[0]); - if (!GF_JS_InstanceOf(c, js_ab, &html_media_rt->arrayBufferClass, NULL) ) - { + } + js_ab = JSVAL_TO_OBJECT(argv[0]); + if (!GF_JS_InstanceOf(c, js_ab, &html_media_rt->arrayBufferClass, NULL) ) + { return dom_throw_exception(c, GF_DOM_EXC_TYPE_MISMATCH_ERR); - } - ab = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, js_ab); - if (!ab->length) - { + } + ab = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, js_ab); + if (!ab->length) + { return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - /* TODO: handle buffer full flag case */ + } + /* TODO: handle buffer full flag case */ /* TODO: run the coded frame eviction algo */ - gf_mse_source_buffer_append_arraybuffer(sb, ab); - return JS_TRUE; + gf_mse_source_buffer_append_arraybuffer(sb, ab); + return JS_TRUE; } static JSBool SMJS_FUNCTION(sourcebuffer_appendStream) { - SMJS_OBJ - SB_UPDATING_CHECK - /* TODO */ - return JS_TRUE; + SMJS_OBJ + SB_UPDATING_CHECK + /* TODO */ + return JS_TRUE; } static JSBool SMJS_FUNCTION(sourcebuffer_abort) { - SMJS_OBJ - SB_BASIC_CHECK - if (gf_list_find(sb->mediasource->sourceBuffers.list, sb) < 0) { + SMJS_OBJ + SB_BASIC_CHECK + if (gf_list_find(sb->mediasource->sourceBuffers.list, sb) < 0) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - if (sb->mediasource->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { + } + if (sb->mediasource->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - if (gf_mse_source_buffer_abort(sb) != GF_OK) { - return JS_TRUE; - } - return JS_TRUE; + } + if (gf_mse_source_buffer_abort(sb) != GF_OK) { + return JS_TRUE; + } + return JS_TRUE; } static JSBool SMJS_FUNCTION(sourcebuffer_remove) { - SMJS_OBJ - SMJS_ARGS - jsdouble start, end; - SB_UPDATING_CHECK - if (argc < 2 || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, argv[0], &start); - JS_ValueToNumber(c, argv[1], &end); - if (start < 0 /* || start > sb->duration */ || start >= end) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (sb->mediasource->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { + SMJS_OBJ + SMJS_ARGS + jsdouble start, end; + SB_UPDATING_CHECK + if (argc < 2 || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + JS_ValueToNumber(c, argv[0], &start); + JS_ValueToNumber(c, argv[1], &end); + if (start < 0 /* || start > sb->duration */ || start >= end) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + if (sb->mediasource->readyState != MEDIA_SOURCE_READYSTATE_OPEN) { gf_mse_mediasource_open(sb->mediasource, NULL); - } + } gf_mse_remove(sb, start, end); - return JS_TRUE; + return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_mode) - SB_BASIC_CHECK - if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEGMENTS) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "segments")); - } else if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE) { - *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "sequence")); - } - return JS_TRUE; +SB_BASIC_CHECK +if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEGMENTS) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "segments")); +} else if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE) { + *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "sequence")); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(sourceBuffer_set_mode) - char *smode = NULL; - GF_HTML_MediaSource_AppendMode mode; - SB_BASIC_CHECK - if (!JSVAL_CHECK_STRING(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - smode = SMJS_CHARS(c, *vp); - if (stricmp(smode, "segments") && stricmp(smode, "sequence")) { - SMJS_FREE(c, smode); - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (!stricmp(smode, "segments")) { - mode = MEDIA_SOURCE_APPEND_MODE_SEGMENTS; - } else if (!stricmp(smode, "sequence")) { - mode = MEDIA_SOURCE_APPEND_MODE_SEQUENCE; - } +char *smode = NULL; +GF_HTML_MediaSource_AppendMode mode; +SB_BASIC_CHECK +if (!JSVAL_CHECK_STRING(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +smode = SMJS_CHARS(c, *vp); +if (stricmp(smode, "segments") && stricmp(smode, "sequence")) { SMJS_FREE(c, smode); - if (gf_list_find(sb->mediasource->sourceBuffers.list, sb) < 0) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - if (sb->updating) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { - gf_mse_mediasource_open(sb->mediasource, NULL); - } - if (sb->append_state == MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - sb->append_mode = mode; - if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE) { - sb->group_start_timestamp_flag = GF_TRUE; - sb->group_start_timestamp = sb->group_end_timestamp; - } - return JS_TRUE; + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +if (!stricmp(smode, "segments")) { + mode = MEDIA_SOURCE_APPEND_MODE_SEGMENTS; +} else if (!stricmp(smode, "sequence")) { + mode = MEDIA_SOURCE_APPEND_MODE_SEQUENCE; +} +SMJS_FREE(c, smode); +if (gf_list_find(sb->mediasource->sourceBuffers.list, sb) < 0) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); +} +if (sb->updating) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); +} +if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { + gf_mse_mediasource_open(sb->mediasource, NULL); +} +if (sb->append_state == MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); +} +sb->append_mode = mode; +if (sb->append_mode == MEDIA_SOURCE_APPEND_MODE_SEQUENCE) { + sb->group_start_timestamp_flag = GF_TRUE; + sb->group_start_timestamp = sb->group_end_timestamp; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_updating) - SB_BASIC_CHECK - *vp = BOOLEAN_TO_JSVAL(sb->updating ? JS_TRUE : JS_FALSE); - return JS_TRUE; +SB_BASIC_CHECK +*vp = BOOLEAN_TO_JSVAL(sb->updating ? JS_TRUE : JS_FALSE); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_timestampOffset) - SB_BASIC_CHECK - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->timestampOffset*1.0/sb->timescale)); - return JS_TRUE; +SB_BASIC_CHECK +*vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->timestampOffset*1.0/sb->timescale)); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(sourceBuffer_set_timestampOffset) - jsdouble d; - SB_UPDATING_CHECK - if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { - gf_mse_mediasource_open(sb->mediasource, NULL); - } - if (sb->append_state == MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); - } - JS_ValueToNumber(c, *vp, &d); - gf_mse_source_buffer_set_timestampOffset(sb, d); - return JS_TRUE; +jsdouble d; +SB_UPDATING_CHECK +if (sb->mediasource->readyState == MEDIA_SOURCE_READYSTATE_ENDED) { + gf_mse_mediasource_open(sb->mediasource, NULL); +} +if (sb->append_state == MEDIA_SOURCE_APPEND_STATE_PARSING_MEDIA_SEGMENT) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_STATE_ERR); +} +JS_ValueToNumber(c, *vp, &d); +gf_mse_source_buffer_set_timestampOffset(sb, d); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_timescale) - SB_BASIC_CHECK - *vp = INT_TO_JSVAL(sb->timescale); - return JS_TRUE; +SB_BASIC_CHECK +*vp = INT_TO_JSVAL(sb->timescale); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(sourceBuffer_set_timescale) - SB_BASIC_CHECK - gf_mse_source_buffer_set_timescale(sb, JSVAL_TO_INT(*vp)); - return JS_TRUE; +SB_BASIC_CHECK +gf_mse_source_buffer_set_timescale(sb, JSVAL_TO_INT(*vp)); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_appendWindowStart) - SB_BASIC_CHECK - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->appendWindowStart)); - return JS_TRUE; +SB_BASIC_CHECK +*vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->appendWindowStart)); +return JS_TRUE; } static SMJS_FUNC_PROP_SET(sourceBuffer_set_appendWindowStart) - jsdouble d; - SB_UPDATING_CHECK - if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, *vp, &d); - if (d < 0 || d >= sb->appendWindowEnd) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - sb->appendWindowStart = d; - return JS_TRUE; +jsdouble d; +SB_UPDATING_CHECK +if (!JSVAL_IS_NUMBER(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +JS_ValueToNumber(c, *vp, &d); +if (d < 0 || d >= sb->appendWindowEnd) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +sb->appendWindowStart = d; +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_appendWindowEnd) - SB_BASIC_CHECK - if (sb->appendWindowEnd == GF_MAX_DOUBLE) { - *vp = JS_GetPositiveInfinityValue(c); - } else { - *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->appendWindowEnd)); - } - return JS_TRUE; +SB_BASIC_CHECK +if (sb->appendWindowEnd == GF_MAX_DOUBLE) { + *vp = JS_GetPositiveInfinityValue(c); +} else { + *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, sb->appendWindowEnd)); +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(sourceBuffer_set_appendWindowEnd) - jsdouble d; - SB_UPDATING_CHECK - if (!JSVAL_IS_NUMBER(*vp)) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - JS_ValueToNumber(c, *vp, &d); - if (d <= sb->appendWindowStart) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - sb->appendWindowEnd = d; - return JS_TRUE; +jsdouble d; +SB_UPDATING_CHECK +if (!JSVAL_IS_NUMBER(*vp)) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +JS_ValueToNumber(c, *vp, &d); +if (d <= sb->appendWindowStart) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); +} +sb->appendWindowEnd = d; +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_buffered) - SB_BASIC_CHECK - gf_mse_source_buffer_update_buffered(sb); - *vp = OBJECT_TO_JSVAL(sb->buffered->_this); - return JS_TRUE; +SB_BASIC_CHECK +gf_mse_source_buffer_update_buffered(sb); +*vp = OBJECT_TO_JSVAL(sb->buffered->_this); +return JS_TRUE; } static SMJS_FUNC_PROP_GET(sourceBuffer_get_tracks) - SB_BASIC_CHECK - /* TODO */ - return JS_TRUE; +SB_BASIC_CHECK +/* TODO */ +return JS_TRUE; } static JSBool SMJS_FUNCTION(html_url_createObjectURL) { - SMJS_ARGS - JSObject *js_ms; - GF_HTML_MediaSource *ms; - char blobURI[256]; - - SMJS_SET_RVAL(JSVAL_NULL); - if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { - return JS_TRUE; - } - js_ms = JSVAL_TO_OBJECT(argv[0]); - if (!GF_JS_InstanceOf(c, js_ms, &html_media_rt->mediaSourceClass, NULL) ) - { - return JS_TRUE; - } - ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, js_ms); - sprintf(blobURI, "blob:%p", ms); - ms->blobURI = gf_strdup(blobURI); - SMJS_SET_RVAL(STRING_TO_JSVAL( JS_NewStringCopyZ(c, blobURI))); - return JS_TRUE; + SMJS_ARGS + JSObject *js_ms; + GF_HTML_MediaSource *ms; + char blobURI[256]; + + SMJS_SET_RVAL(JSVAL_NULL); + if (!argc || JSVAL_IS_NULL(argv[0]) || !JSVAL_IS_OBJECT(argv[0])) { + return JS_TRUE; + } + js_ms = JSVAL_TO_OBJECT(argv[0]); + if (!GF_JS_InstanceOf(c, js_ms, &html_media_rt->mediaSourceClass, NULL) ) + { + return JS_TRUE; + } + ms = (GF_HTML_MediaSource *)SMJS_GET_PRIVATE(c, js_ms); + sprintf(blobURI, "blob:%p", ms); + ms->blobURI = gf_strdup(blobURI); + SMJS_SET_RVAL(STRING_TO_JSVAL( JS_NewStringCopyZ(c, blobURI))); + return JS_TRUE; } GF_HTML_ArrayBuffer *gf_arraybuffer_new(char *data, u32 length) { - GF_HTML_ArrayBuffer *ab = NULL; - GF_SAFEALLOC(ab, GF_HTML_ArrayBuffer); - if (length > 0) { - ab->data = data; - ab->length = length; - } - ab->reference_count = 0; - return ab; + GF_HTML_ArrayBuffer *ab = NULL; + GF_SAFEALLOC(ab, GF_HTML_ArrayBuffer); + if (length > 0) { + ab->data = data; + ab->length = length; + } + ab->reference_count = 0; + return ab; } JSObject *gf_arraybuffer_js_new(JSContext *c, char *data, u32 length, JSObject *parent) { - JSObject *obj; - GF_HTML_ArrayBuffer *p; - if (!data) return NULL; - p = gf_arraybuffer_new(data, length); - obj = JS_NewObject(c, &html_media_rt->arrayBufferClass._class, NULL, parent); - if (!parent) { - p->reference_count = 0; - } - SMJS_SET_PRIVATE(c, obj, p); - p->c = c; - p->_this = obj; - return obj; + JSObject *obj; + GF_HTML_ArrayBuffer *p; + if (!data) return NULL; + p = gf_arraybuffer_new(data, length); + obj = JS_NewObject(c, &html_media_rt->arrayBufferClass._class, NULL, parent); + if (!parent) { + p->reference_count = 0; + } + SMJS_SET_PRIVATE(c, obj, p); + p->c = c; + p->_this = obj; + return obj; } void xhr_del_array_buffer(void *udta); -void gf_arraybuffer_del(GF_HTML_ArrayBuffer *buffer, Bool del_js) +void gf_arraybuffer_del(GF_HTML_ArrayBuffer *buffer, Bool del_js) { - if (buffer) { - if (del_js && buffer->_this) { + if (buffer) { + if (del_js && buffer->_this) { /*if we have a JS object, make sure the parent XHR doesn't point to us ...*/ - JSObject *xhro = JS_GetParent(buffer->c, buffer->_this); + JSObject *xhro = JS_GetParent(buffer->c, buffer->_this); if (xhro) { void *xhr_ctx = SMJS_GET_PRIVATE(buffer->c, xhro); xhr_del_array_buffer(xhr_ctx); } - /* finalize the object from the JS perspective */ - buffer->c = NULL; - buffer->_this = NULL; - } - /* but only delete if the data is not used elsewhere */ - if(!del_js && buffer->reference_count) { - buffer->reference_count--; - } - if (!buffer->reference_count && !buffer->_this) { - gf_free(buffer->data); + /* finalize the object from the JS perspective */ + buffer->c = NULL; + buffer->_this = NULL; + } + /* but only delete if the data is not used elsewhere */ + if(!del_js && buffer->reference_count) { + buffer->reference_count--; + } + if (!buffer->reference_count && !buffer->_this) { + gf_free(buffer->data); if (buffer->url) gf_free(buffer->url); - gf_free(buffer); - } - } + gf_free(buffer); + } + } } static JSBool SMJS_FUNCTION(arraybuffer_constructor) { - SMJS_ARGS - u32 length = 0; - SMJS_OBJ_CONSTRUCTOR(&html_media_rt->arrayBufferClass) + SMJS_ARGS + u32 length = 0; + SMJS_OBJ_CONSTRUCTOR(&html_media_rt->arrayBufferClass) - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL)) - { - return JS_TRUE; - } - if (argc && !JSVAL_IS_NULL(argv[0]) && JSVAL_IS_INT(argv[0])) { - length = JSVAL_TO_INT(argv[0]); - } - if (length > 0) { - gf_arraybuffer_js_new(c, (char *)gf_malloc(length), length, NULL); - } - return JS_TRUE; + if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL)) + { + return JS_TRUE; + } + if (argc && !JSVAL_IS_NULL(argv[0]) && JSVAL_IS_INT(argv[0])) { + length = JSVAL_TO_INT(argv[0]); + } + if (length > 0) { + gf_arraybuffer_js_new(c, (char *)gf_malloc(length), length, NULL); + } + return JS_TRUE; } static SMJS_FUNC_PROP_GET(arraybuffer_get_byteLength) - GF_HTML_ArrayBuffer *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL) ) { - return JS_TRUE; - } - p = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, obj); - if (p) { - *vp = INT_TO_JSVAL(p->length); - } - return JS_TRUE; +GF_HTML_ArrayBuffer *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL) ) { + return JS_TRUE; +} +p = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, obj); +if (p) { + *vp = INT_TO_JSVAL(p->length); +} +return JS_TRUE; } static DECL_FINALIZE(arraybuffer_finalize) - GF_HTML_ArrayBuffer *p; - if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL) ) return; - p = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, obj); - if (!p) return; - gf_arraybuffer_del(p, GF_TRUE); +GF_HTML_ArrayBuffer *p; +if (!GF_JS_InstanceOf(c, obj, &html_media_rt->arrayBufferClass, NULL) ) return; +p = (GF_HTML_ArrayBuffer *)SMJS_GET_PRIVATE(c, obj); +if (!p) return; +gf_arraybuffer_del(p, GF_TRUE); } static JSBool SMJS_FUNCTION(mse_event_add_listener) @@ -838,109 +838,109 @@ static JSBool SMJS_FUNCTION(mse_event_remove_listener) static JSBool SMJS_FUNCTION(mse_event_dispatch) { /* TODO */ - return JS_TRUE; + return JS_TRUE; } void html_media_source_init_js_api(JSContext *js_ctx, JSObject *global, GF_HTML_MediaRuntime *_html_media_rt) { - /* HTML Media Element */ - if (_html_media_rt) { - html_media_rt = _html_media_rt; - - JS_SETUP_CLASS(html_media_rt->arrayBufferClass, "ArrayBuffer", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, arraybuffer_finalize); - { - JSPropertySpec arrayBufferClassProps[] = { - {"byteLength", -1, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, arraybuffer_get_byteLength, 0}, - {0, 0, 0, 0, 0} - }; - GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->arrayBufferClass, arraybuffer_constructor, 0, arrayBufferClassProps, 0, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] ArrayBuffer class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->mediaSourceClass, "MediaSource", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, media_source_finalize); - { - JSPropertySpec htmlMediaSourceClassProps[] = { - {"sourceBuffers", HTML_MEDIASOURCE_PROP_SOURCEBUFFERS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_source_buffers, 0}, - {"activeSourceBuffers", HTML_MEDIASOURCE_PROP_ACTIVESOURCEBUFFERS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_active_source_buffers, 0}, - {"readyState", HTML_MEDIASOURCE_PROP_READYSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_ready_state, 0}, - {"duration", HTML_MEDIASOURCE_PROP_DURATION, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, media_source_get_duration, media_source_set_duration}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec htmlMediaSourceClassFuncs[] = { - SMJS_FUNCTION_SPEC("addSourceBuffer", mediasource_addSourceBuffer, 1), - SMJS_FUNCTION_SPEC("removeSourceBuffer", mediasource_removeSourceBuffer, 1), - SMJS_FUNCTION_SPEC("endOfStream", mediasource_endOfStream, 1), - SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), - SMJS_FUNCTION_SPEC("removeEventListener", mse_event_remove_listener, 3), - SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_dispatch, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - JSFunctionSpec htmlMediaSourceClassStaticFuncs[] = { - SMJS_FUNCTION_SPEC("isTypeSupported", mediasource_is_type_supported, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->mediaSourceClass, media_source_constructor, 0, htmlMediaSourceClassProps, htmlMediaSourceClassFuncs, 0, htmlMediaSourceClassStaticFuncs); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] MediaSource class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->sourceBufferClass, "SourceBuffer", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_PropertyStub); - { - JSPropertySpec SourceBufferClassProps[] = { - {"mode", HTML_SOURCEBUFFER_PROP_MODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_mode, sourceBuffer_set_mode}, - {"updating", HTML_SOURCEBUFFER_PROP_UPDATING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_updating, 0}, - {"buffered", HTML_SOURCEBUFFER_PROP_BUFFERED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_buffered, 0}, - {"timestampOffset", HTML_SOURCEBUFFER_PROP_TIMESTAMPOFFSET, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_timestampOffset, sourceBuffer_set_timestampOffset}, - {"timescale", HTML_SOURCEBUFFER_PROP_TIMESCALE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_timescale, sourceBuffer_set_timescale}, - {"appendWindowStart", HTML_SOURCEBUFFER_PROP_APPENDWINDOWSTART,JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_appendWindowStart, sourceBuffer_set_appendWindowStart}, - {"appendWindowEnd", HTML_SOURCEBUFFER_PROP_APPENDWINDOWEND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_appendWindowEnd, sourceBuffer_set_appendWindowEnd}, - {"audioTracks", HTML_SOURCEBUFFER_PROP_AUDIOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, - {"videoTracks", HTML_SOURCEBUFFER_PROP_VIDEOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, - {"textTracks", HTML_SOURCEBUFFER_PROP_TEXTTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec SourceBufferClassFuncs[] = { - SMJS_FUNCTION_SPEC("appendBuffer", sourcebuffer_appendBuffer, 1), - SMJS_FUNCTION_SPEC("appendStream", sourcebuffer_appendStream, 1), - SMJS_FUNCTION_SPEC("abort", sourcebuffer_abort, 0), - SMJS_FUNCTION_SPEC("remove", sourcebuffer_remove, 2), - SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), - SMJS_FUNCTION_SPEC("removeEventListener", mse_event_add_listener, 3), - SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_add_listener, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->sourceBufferClass, 0, 0, SourceBufferClassProps, SourceBufferClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] SourceBuffer class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->sourceBufferListClass, "SourceBufferList", JSCLASS_HAS_PRIVATE, sourcebufferlist_getProperty, JS_PropertyStub_forSetter, JS_PropertyStub); - { - JSPropertySpec SourceBufferListClassProps[] = { - {"length", HTML_SOURCEBUFFERLIST_PROP_LENGTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, - {0, 0, 0, 0, 0} - }; - JSFunctionSpec SourceBufferListClassFuncs[] = { - SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), - SMJS_FUNCTION_SPEC("removeEventListener", mse_event_add_listener, 3), - SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_add_listener, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->sourceBufferListClass, 0, 0, SourceBufferListClassProps, SourceBufferListClassFuncs, 0, 0); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] SourceBufferList class initialized\n")); - } - - JS_SETUP_CLASS(html_media_rt->URLClass, "URL", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_PropertyStub); - { - JSPropertySpec URLClassProps[] = { - {0, 0, 0, 0, 0} - }; - JSFunctionSpec URLClassFuncs[] = { - SMJS_FUNCTION_SPEC("createObjectURL", html_url_createObjectURL, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) - }; - GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->URLClass, 0, 0, URLClassProps, 0, 0, URLClassFuncs); - GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] URL class initialized\n")); - } - } + /* HTML Media Element */ + if (_html_media_rt) { + html_media_rt = _html_media_rt; + + JS_SETUP_CLASS(html_media_rt->arrayBufferClass, "ArrayBuffer", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, arraybuffer_finalize); + { + JSPropertySpec arrayBufferClassProps[] = { + {"byteLength", -1, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, arraybuffer_get_byteLength, 0}, + {0, 0, 0, 0, 0} + }; + GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->arrayBufferClass, arraybuffer_constructor, 0, arrayBufferClassProps, 0, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] ArrayBuffer class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->mediaSourceClass, "MediaSource", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, media_source_finalize); + { + JSPropertySpec htmlMediaSourceClassProps[] = { + {"sourceBuffers", HTML_MEDIASOURCE_PROP_SOURCEBUFFERS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_source_buffers, 0}, + {"activeSourceBuffers", HTML_MEDIASOURCE_PROP_ACTIVESOURCEBUFFERS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_active_source_buffers, 0}, + {"readyState", HTML_MEDIASOURCE_PROP_READYSTATE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, media_source_get_ready_state, 0}, + {"duration", HTML_MEDIASOURCE_PROP_DURATION, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, media_source_get_duration, media_source_set_duration}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec htmlMediaSourceClassFuncs[] = { + SMJS_FUNCTION_SPEC("addSourceBuffer", mediasource_addSourceBuffer, 1), + SMJS_FUNCTION_SPEC("removeSourceBuffer", mediasource_removeSourceBuffer, 1), + SMJS_FUNCTION_SPEC("endOfStream", mediasource_endOfStream, 1), + SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), + SMJS_FUNCTION_SPEC("removeEventListener", mse_event_remove_listener, 3), + SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_dispatch, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + JSFunctionSpec htmlMediaSourceClassStaticFuncs[] = { + SMJS_FUNCTION_SPEC("isTypeSupported", mediasource_is_type_supported, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->mediaSourceClass, media_source_constructor, 0, htmlMediaSourceClassProps, htmlMediaSourceClassFuncs, 0, htmlMediaSourceClassStaticFuncs); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] MediaSource class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->sourceBufferClass, "SourceBuffer", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_PropertyStub); + { + JSPropertySpec SourceBufferClassProps[] = { + {"mode", HTML_SOURCEBUFFER_PROP_MODE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_mode, sourceBuffer_set_mode}, + {"updating", HTML_SOURCEBUFFER_PROP_UPDATING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_updating, 0}, + {"buffered", HTML_SOURCEBUFFER_PROP_BUFFERED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_buffered, 0}, + {"timestampOffset", HTML_SOURCEBUFFER_PROP_TIMESTAMPOFFSET, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_timestampOffset, sourceBuffer_set_timestampOffset}, + {"timescale", HTML_SOURCEBUFFER_PROP_TIMESCALE, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_timescale, sourceBuffer_set_timescale}, + {"appendWindowStart", HTML_SOURCEBUFFER_PROP_APPENDWINDOWSTART,JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_appendWindowStart, sourceBuffer_set_appendWindowStart}, + {"appendWindowEnd", HTML_SOURCEBUFFER_PROP_APPENDWINDOWEND, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, sourceBuffer_get_appendWindowEnd, sourceBuffer_set_appendWindowEnd}, + {"audioTracks", HTML_SOURCEBUFFER_PROP_AUDIOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, + {"videoTracks", HTML_SOURCEBUFFER_PROP_VIDEOTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, + {"textTracks", HTML_SOURCEBUFFER_PROP_TEXTTRACKS, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, sourceBuffer_get_tracks, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec SourceBufferClassFuncs[] = { + SMJS_FUNCTION_SPEC("appendBuffer", sourcebuffer_appendBuffer, 1), + SMJS_FUNCTION_SPEC("appendStream", sourcebuffer_appendStream, 1), + SMJS_FUNCTION_SPEC("abort", sourcebuffer_abort, 0), + SMJS_FUNCTION_SPEC("remove", sourcebuffer_remove, 2), + SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), + SMJS_FUNCTION_SPEC("removeEventListener", mse_event_add_listener, 3), + SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_add_listener, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->sourceBufferClass, 0, 0, SourceBufferClassProps, SourceBufferClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] SourceBuffer class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->sourceBufferListClass, "SourceBufferList", JSCLASS_HAS_PRIVATE, sourcebufferlist_getProperty, JS_PropertyStub_forSetter, JS_PropertyStub); + { + JSPropertySpec SourceBufferListClassProps[] = { + {"length", HTML_SOURCEBUFFERLIST_PROP_LENGTH, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, + {0, 0, 0, 0, 0} + }; + JSFunctionSpec SourceBufferListClassFuncs[] = { + SMJS_FUNCTION_SPEC("addEventListener", mse_event_add_listener, 3), + SMJS_FUNCTION_SPEC("removeEventListener", mse_event_add_listener, 3), + SMJS_FUNCTION_SPEC("dispatchEvent", mse_event_add_listener, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->sourceBufferListClass, 0, 0, SourceBufferListClassProps, SourceBufferListClassFuncs, 0, 0); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] SourceBufferList class initialized\n")); + } + + JS_SETUP_CLASS(html_media_rt->URLClass, "URL", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_PropertyStub); + { + JSPropertySpec URLClassProps[] = { + {0, 0, 0, 0, 0} + }; + JSFunctionSpec URLClassFuncs[] = { + SMJS_FUNCTION_SPEC("createObjectURL", html_url_createObjectURL, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) + }; + GF_JS_InitClass(js_ctx, global, 0, &html_media_rt->URLClass, 0, 0, URLClassProps, 0, 0, URLClassFuncs); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[HTML Media Source API] URL class initialized\n")); + } + } } diff --git a/src/scenegraph/mpeg4_animators.c b/src/scenegraph/mpeg4_animators.c index 20156ac..412dab0 100644 --- a/src/scenegraph/mpeg4_animators.c +++ b/src/scenegraph/mpeg4_animators.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -128,8 +128,8 @@ static void anurbs_init(anim_nurbs *nurbs, u32 type, u32 nCtrl, u32 nKnots, Fixe break; } nurbs->p = nurbs->nknots - nurbs->npoints - 1; - if ((nurbs->p<=0) || (nurbs->p >= nurbs->nknots -1) - || ((nurbs->nweights>0) && (nurbs->npoints != nurbs->nweights)) ) { + if ((nurbs->p<=0) || (nurbs->p >= nurbs->nknots -1) + || ((nurbs->nweights>0) && (nurbs->npoints != nurbs->nweights)) ) { nurbs->valid = 0; } else { nurbs->valid = 1; @@ -151,7 +151,7 @@ static void anurbs_basis(anim_nurbs *nurbs, s32 span, Fixed t) nurbs->left[i] = t - nurbs->knots[span+1-i]; nurbs->right[i] = nurbs->knots[span+i]-t; saved = 0; - + for(j=0; jn[j], nurbs->right[j+1] + nurbs->left[i-j]); nurbs->n[j] = saved + gf_mulfix(nurbs->right[j+1], temp); @@ -172,18 +172,18 @@ static s32 anurbs_find_span(anim_nurbs *nurbs, Fixed u) span--; return span; #else - s32 low, high, mid; + s32 low, high, mid; if (u == nurbs->knots[nurbs->npoints]) return nurbs->npoints - 1; - low = nurbs->p; - high = nurbs->npoints; + low = nurbs->p; + high = nurbs->npoints; mid = (low + high)/2; - + while (u < nurbs->knots[mid] || u >= nurbs->knots[mid+1]) { - if (u < nurbs->knots[mid]) high = mid; + if (u < nurbs->knots[mid]) high = mid; else low = mid; mid = (low + high)/2; - } - return (mid); + } + return (mid); #endif } @@ -196,7 +196,7 @@ static SFVec3f anurbs_get_vec3f(anim_nurbs *nurbs, s32 span, SFVec3f *pts) tmp.x = tmp.y = tmp.z = 0; res = tmp; w=0; - for(i=0; i<=nurbs->p;i++) { + for(i=0; i<=nurbs->p; i++) { tmp = pts[span - nurbs->p + i]; if (nurbs->nweights>0) { wi = nurbs->weights[span - nurbs->p + i]; @@ -224,7 +224,7 @@ static SFVec2f anurbs_get_vec2f(anim_nurbs *nurbs, s32 span, SFVec2f *pts) tmp.x = tmp.y = 0; res = tmp; w=0; - for(i=0; i<=nurbs->p;i++) { + for(i=0; i<=nurbs->p; i++) { tmp = pts[span - nurbs->p + i]; if (nurbs->nweights>0) { wi = nurbs->weights[span - nurbs->p + i]; @@ -252,7 +252,7 @@ static Fixed anurbs_get_float(anim_nurbs *nurbs, s32 span, Fixed *vals) u32 i; res = tmp = 0; w=0; - for(i=0; i<=nurbs->p;i++) { + for(i=0; i<=nurbs->p; i++) { tmp = vals[span - nurbs->p + i]; if (nurbs->nweights>0) { wi = nurbs->weights[span - nurbs->p + i]; @@ -340,7 +340,7 @@ static void PA_Update(M_PositionAnimator *pa, AnimatorStack *stack) d.z = pa->keyValue.vals[i+1].z - pa->keyValue.vals[i].z; stack->length += gf_vec_len(d); } - } + } Animator_Update(stack, pa->keyValueType, pa->keyValue.count, &pa->keySpline, pa->weight.count, pa->weight.vals); } static void PA_SetFraction(GF_Node *node, GF_Route *route) @@ -368,8 +368,14 @@ static void PA_SetFraction(GF_Node *node, GF_Route *route) switch (stack->anim_type) { case ANIM_DEFAULT: if (nbKeys != nbVals) return; - if (frackey.vals[0]) { i=0; frac = 0; } - else if (frac>pa->key.vals[nbKeys-1]) { i=nbVals-2; frac = FIX_ONE; } + if (frackey.vals[0]) { + i=0; + frac = 0; + } + else if (frac>pa->key.vals[nbKeys-1]) { + i=nbVals-2; + frac = FIX_ONE; + } else { for (i=0; i=pa->key.vals[i]) && (frackey.vals[i+1])) break; @@ -436,7 +442,7 @@ static void PA_SetFraction(GF_Node *node, GF_Route *route) /*nothing to do for this one here*/ case ANIM_DEFAULT: /*not supported - use frac as is*/ - case ANIM_PACED: + case ANIM_PACED: default: break; } @@ -446,7 +452,7 @@ static void PA_SetFraction(GF_Node *node, GF_Route *route) pa->value_changed = anurbs_get_vec3f(&stack->anurbs, i, pa->keyValue.vals); break; /*not supported*/ - case ANIM_SPLINE: + case ANIM_SPLINE: default: return; } @@ -463,15 +469,15 @@ void PA_Modified(GF_Node *node, GF_FieldInfo *field) M_PositionAnimator *pa = (M_PositionAnimator *)node; if ( /*all fields impacting cached path len / nurbs*/ - (field->far_ptr == &pa->keyValue) - || (field->far_ptr == &pa->keyValueType) - || (field->far_ptr == &pa->key) - || (field->far_ptr == &pa->keyType) - || (field->far_ptr == &pa->keySpline) - || (field->far_ptr == &pa->weight) - || (field->far_ptr == &pa->key) - - ) stack->is_dirty = 1; + (field->far_ptr == &pa->keyValue) + || (field->far_ptr == &pa->keyValueType) + || (field->far_ptr == &pa->key) + || (field->far_ptr == &pa->keyType) + || (field->far_ptr == &pa->keySpline) + || (field->far_ptr == &pa->weight) + || (field->far_ptr == &pa->key) + + ) stack->is_dirty = 1; } void PA_Init(GF_Node *n) { @@ -500,7 +506,7 @@ static void PA2D_Update(M_PositionAnimator2D *pa, AnimatorStack *stack) dy = pa->keyValue.vals[i+1].y - pa->keyValue.vals[i].y; stack->length += gf_sqrt(gf_mulfix(dx, dx) + gf_mulfix(dy, dy)); } - } + } Animator_Update(stack, pa->keyValueType, pa->keyValue.count, &pa->keySpline, pa->weight.count, pa->weight.vals); } static void PA2D_SetFraction(GF_Node *node, GF_Route *route) @@ -528,8 +534,14 @@ static void PA2D_SetFraction(GF_Node *node, GF_Route *route) switch (stack->anim_type) { case ANIM_DEFAULT: if (nbKeys != nbVals) return; - if (frac<=pa->key.vals[0]) { i=0; frac = 0; } - else if (frac>=pa->key.vals[nbKeys-1]) { i=nbVals-2; frac=FIX_ONE; } + if (frac<=pa->key.vals[0]) { + i=0; + frac = 0; + } + else if (frac>=pa->key.vals[nbKeys-1]) { + i=nbVals-2; + frac=FIX_ONE; + } else { for (i=0; i=pa->key.vals[i]) && (frackey.vals[i+1])) break; @@ -594,7 +606,7 @@ static void PA2D_SetFraction(GF_Node *node, GF_Route *route) /*nothing to do for this one here*/ case ANIM_DEFAULT: /*not supported - use frac as is*/ - case ANIM_PACED: + case ANIM_PACED: default: break; } @@ -604,7 +616,7 @@ static void PA2D_SetFraction(GF_Node *node, GF_Route *route) pa->value_changed = anurbs_get_vec2f(&stack->anurbs, i, pa->keyValue.vals); break; /*not supported*/ - case ANIM_SPLINE: + case ANIM_SPLINE: default: return; } @@ -620,15 +632,15 @@ void PA2D_Modified(GF_Node *node, GF_FieldInfo *field) M_PositionAnimator2D *pa = (M_PositionAnimator2D *)node; if ( /*all fields impacting cached path len / nurbs*/ - (field->far_ptr == &pa->keyValue) - || (field->far_ptr == &pa->keyValueType) - || (field->far_ptr == &pa->key) - || (field->far_ptr == &pa->keyType) - || (field->far_ptr == &pa->keySpline) - || (field->far_ptr == &pa->weight) - || (field->far_ptr == &pa->key) - - ) stack->is_dirty = 1; + (field->far_ptr == &pa->keyValue) + || (field->far_ptr == &pa->keyValueType) + || (field->far_ptr == &pa->key) + || (field->far_ptr == &pa->keyType) + || (field->far_ptr == &pa->keySpline) + || (field->far_ptr == &pa->weight) + || (field->far_ptr == &pa->key) + + ) stack->is_dirty = 1; } void PA2D_Init(GF_Node *n) { @@ -656,7 +668,7 @@ static void SA_Update(M_ScalarAnimator *sa, AnimatorStack *stack) len = sa->keyValue.vals[i+1] - sa->keyValue.vals[i]; stack->length += ABS(len); } - } + } Animator_Update(stack, sa->keyValueType, sa->keyValue.count, &sa->keySpline, sa->weight.count, sa->weight.vals); } @@ -684,8 +696,14 @@ void SA_SetFraction(GF_Node *node, GF_Route *route) switch (stack->anim_type) { case ANIM_DEFAULT: if (nbKeys != nbVals) return; - if (frackey.vals[0]) { i=0; frac = 0; } - else if (frac>sa->key.vals[nbKeys-1]) { i=nbVals-2; frac=FIX_ONE; } + if (frackey.vals[0]) { + i=0; + frac = 0; + } + else if (frac>sa->key.vals[nbKeys-1]) { + i=nbVals-2; + frac=FIX_ONE; + } else { for (i=0; i=sa->key.vals[i]) && (frackey.vals[i+1])) break; @@ -746,7 +764,7 @@ void SA_SetFraction(GF_Node *node, GF_Route *route) /*nothing to do for this one here*/ case ANIM_DEFAULT: /*not supported - use frac as is*/ - case ANIM_PACED: + case ANIM_PACED: default: break; } @@ -756,7 +774,7 @@ void SA_SetFraction(GF_Node *node, GF_Route *route) sa->value_changed = anurbs_get_float(&stack->anurbs, i, sa->keyValue.vals); break; /*not supported*/ - case ANIM_SPLINE: + case ANIM_SPLINE: default: return; } @@ -771,15 +789,15 @@ void SA_Modified(GF_Node *node, GF_FieldInfo *field) M_ScalarAnimator *sa = (M_ScalarAnimator *)node; if ( /*all fields impacting cached path len / nurbs*/ - (field->far_ptr == &sa->keyValue) - || (field->far_ptr == &sa->keyValueType) - || (field->far_ptr == &sa->key) - || (field->far_ptr == &sa->keyType) - || (field->far_ptr == &sa->keySpline) - || (field->far_ptr == &sa->weight) - || (field->far_ptr == &sa->key) - - ) stack->is_dirty = 1; + (field->far_ptr == &sa->keyValue) + || (field->far_ptr == &sa->keyValueType) + || (field->far_ptr == &sa->key) + || (field->far_ptr == &sa->keyType) + || (field->far_ptr == &sa->keySpline) + || (field->far_ptr == &sa->weight) + || (field->far_ptr == &sa->key) + + ) stack->is_dirty = 1; } void SA_Init(GF_Node *n) diff --git a/src/scenegraph/mpeg4_nodes.c b/src/scenegraph/mpeg4_nodes.c index 7a999f8..fcfc011 100644 --- a/src/scenegraph/mpeg4_nodes.c +++ b/src/scenegraph/mpeg4_nodes.c @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -47,7 +47,7 @@ static void Anchor_Del(GF_Node *node) gf_sg_sfstring_del(p->description); gf_sg_mfstring_del(p->parameter); gf_sg_mfurl_del(p->url); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -58,10 +58,14 @@ static const u16 Anchor_Out2All[] = { 2, 3, 4, 5}; static u32 Anchor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -150,7 +154,7 @@ static s32 Anchor_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 5; if (!strcmp("activate", name)) return 6; return -1; - } +} static Bool Anchor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -193,10 +197,14 @@ static const u16 AnimationStream_Dyn2All[] = { 1}; static u32 AnimationStream_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -282,7 +290,7 @@ static s32 AnimationStream_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 5; if (!strcmp("isActive", name)) return 6; return -1; - } +} static Bool AnimationStream_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -321,9 +329,9 @@ GF_Node *AnimationStream_Create() static void Appearance_Del(GF_Node *node) { M_Appearance *p = (M_Appearance *) node; - gf_node_unregister((GF_Node *) p->material, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->textureTransform, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->material, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->textureTransform, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -334,10 +342,14 @@ static const u16 Appearance_Out2All[] = { 0, 1, 2}; static u32 Appearance_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -395,7 +407,7 @@ static s32 Appearance_get_field_index_by_name(char *name) if (!strcmp("texture", name)) return 1; if (!strcmp("textureTransform", name)) return 2; return -1; - } +} static Bool Appearance_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -425,7 +437,7 @@ GF_Node *Appearance_Create() static void AudioBuffer_Del(GF_Node *node) { M_AudioBuffer *p = (M_AudioBuffer *) node; - gf_node_unregister_children((GF_Node *) p, p->children); + gf_node_unregister_children((GF_Node *) p, p->children); gf_sg_mfint32_del(p->phaseGroup); gf_node_free((GF_Node *) p); } @@ -438,10 +450,14 @@ static const u16 AudioBuffer_Dyn2All[] = { 1}; static u32 AudioBuffer_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 10; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 10; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 10; } @@ -549,7 +565,7 @@ static s32 AudioBuffer_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 8; if (!strcmp("isActive", name)) return 9; return -1; - } +} static Bool AudioBuffer_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -631,10 +647,14 @@ static const u16 AudioClip_Dyn2All[] = { 2}; static u32 AudioClip_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 8; } @@ -727,7 +747,7 @@ static s32 AudioClip_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 6; if (!strcmp("isActive", name)) return 7; return -1; - } +} static Bool AudioClip_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -767,7 +787,7 @@ static void AudioDelay_Del(GF_Node *node) { M_AudioDelay *p = (M_AudioDelay *) node; gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -778,10 +798,14 @@ static const u16 AudioDelay_Out2All[] = { 2, 3}; static u32 AudioDelay_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -862,7 +886,7 @@ static s32 AudioDelay_get_field_index_by_name(char *name) if (!strcmp("numChan", name)) return 4; if (!strcmp("phaseGroup", name)) return 5; return -1; - } +} static Bool AudioDelay_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -913,7 +937,7 @@ static void AudioFX_Del(GF_Node *node) gf_sg_sfstring_del(p->score); gf_sg_mffloat_del(p->params); gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -925,10 +949,14 @@ static const u16 AudioFX_Dyn2All[] = { 5}; static u32 AudioFX_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 8; } @@ -1026,7 +1054,7 @@ static s32 AudioFX_get_field_index_by_name(char *name) if (!strcmp("numChan", name)) return 6; if (!strcmp("phaseGroup", name)) return 7; return -1; - } +} static Bool AudioFX_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1080,7 +1108,7 @@ static void AudioMix_Del(GF_Node *node) M_AudioMix *p = (M_AudioMix *) node; gf_sg_mffloat_del(p->matrix); gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -1092,10 +1120,14 @@ static const u16 AudioMix_Dyn2All[] = { 4}; static u32 AudioMix_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -1186,7 +1218,7 @@ static s32 AudioMix_get_field_index_by_name(char *name) if (!strcmp("numChan", name)) return 5; if (!strcmp("phaseGroup", name)) return 6; return -1; - } +} static Bool AudioMix_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1248,7 +1280,7 @@ static void AudioSource_Del(GF_Node *node) M_AudioSource *p = (M_AudioSource *) node; gf_sg_mfurl_del(p->url); gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -1260,10 +1292,14 @@ static const u16 AudioSource_Dyn2All[] = { 4, 5}; static u32 AudioSource_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 10; } @@ -1375,7 +1411,7 @@ static s32 AudioSource_get_field_index_by_name(char *name) if (!strcmp("numChan", name)) return 8; if (!strcmp("phaseGroup", name)) return 9; return -1; - } +} static Bool AudioSource_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1439,7 +1475,7 @@ static void AudioSwitch_Del(GF_Node *node) M_AudioSwitch *p = (M_AudioSwitch *) node; gf_sg_mfint32_del(p->whichChoice); gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -1450,10 +1486,14 @@ static const u16 AudioSwitch_Out2All[] = { 2, 3}; static u32 AudioSwitch_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -1534,7 +1574,7 @@ static s32 AudioSwitch_get_field_index_by_name(char *name) if (!strcmp("numChan", name)) return 4; if (!strcmp("phaseGroup", name)) return 5; return -1; - } +} static Bool AudioSwitch_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1608,10 +1648,14 @@ static const u16 Background_Dyn2All[] = { 1, 2, 9, 10}; static u32 Background_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 11; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 11; - case GF_SG_FIELD_CODING_DYN: return 4; + case GF_SG_FIELD_CODING_IN: + return 11; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 11; + case GF_SG_FIELD_CODING_DYN: + return 4; default: return 12; } @@ -1733,7 +1777,7 @@ static s32 Background_get_field_index_by_name(char *name) if (!strcmp("skyColor", name)) return 10; if (!strcmp("isBound", name)) return 11; return -1; - } +} static Bool Background_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1804,10 +1848,14 @@ static const u16 Background2D_Dyn2All[] = { 1}; static u32 Background2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 4; } @@ -1873,7 +1921,7 @@ static s32 Background2D_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("isBound", name)) return 3; return -1; - } +} static Bool Background2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -1912,7 +1960,7 @@ GF_Node *Background2D_Create() static void Billboard_Del(GF_Node *node) { M_Billboard *p = (M_Billboard *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -1924,10 +1972,14 @@ static const u16 Billboard_Dyn2All[] = { 3}; static u32 Billboard_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 4; } @@ -1997,7 +2049,7 @@ static s32 Billboard_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 2; if (!strcmp("axisOfRotation", name)) return 3; return -1; - } +} static Bool Billboard_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2046,10 +2098,14 @@ static const u16 Bitmap_Dyn2All[] = { 0}; static u32 Bitmap_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -2093,7 +2149,7 @@ static s32 Bitmap_get_field_index_by_name(char *name) { if (!strcmp("scale", name)) return 0; return -1; - } +} static Bool Bitmap_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2139,10 +2195,14 @@ static const u16 Box_Def2All[] = { 0}; static u32 Box_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 1; } @@ -2177,7 +2237,7 @@ static s32 Box_get_field_index_by_name(char *name) { if (!strcmp("size", name)) return 0; return -1; - } +} static Bool Box_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2227,10 +2287,14 @@ static const u16 Circle_Dyn2All[] = { 0}; static u32 Circle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -2274,7 +2338,7 @@ static s32 Circle_get_field_index_by_name(char *name) { if (!strcmp("radius", name)) return 0; return -1; - } +} static Bool Circle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2311,8 +2375,8 @@ GF_Node *Circle_Create() static void Collision_Del(GF_Node *node) { M_Collision *p = (M_Collision *) node; - gf_node_unregister((GF_Node *) p->proxy, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->proxy, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -2323,10 +2387,14 @@ static const u16 Collision_Out2All[] = { 2, 3, 5}; static u32 Collision_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -2408,7 +2476,7 @@ static s32 Collision_get_field_index_by_name(char *name) if (!strcmp("proxy", name)) return 4; if (!strcmp("collideTime", name)) return 5; return -1; - } +} static Bool Collision_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2452,10 +2520,14 @@ static const u16 Color_Dyn2All[] = { 0}; static u32 Color_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -2499,7 +2571,7 @@ static s32 Color_get_field_index_by_name(char *name) { if (!strcmp("color", name)) return 0; return -1; - } +} static Bool Color_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2547,10 +2619,14 @@ static const u16 ColorInterpolator_Out2All[] = { 1, 2, 3}; static u32 ColorInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -2613,7 +2689,7 @@ static s32 ColorInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool ColorInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2655,9 +2731,9 @@ GF_Node *ColorInterpolator_Create() static void CompositeTexture2D_Del(GF_Node *node) { M_CompositeTexture2D *p = (M_CompositeTexture2D *) node; - gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->viewport, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viewport, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -2668,10 +2744,14 @@ static const u16 CompositeTexture2D_Out2All[] = { 2, 3, 4, 5, 6}; static u32 CompositeTexture2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -2768,7 +2848,7 @@ static s32 CompositeTexture2D_get_field_index_by_name(char *name) if (!strcmp("viewport", name)) return 6; if (!strcmp("repeatSandT", name)) return 7; return -1; - } +} static Bool CompositeTexture2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -2823,11 +2903,11 @@ GF_Node *CompositeTexture2D_Create() static void CompositeTexture3D_Del(GF_Node *node) { M_CompositeTexture3D *p = (M_CompositeTexture3D *) node; - gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->fog, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->navigationInfo, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->viewpoint, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->fog, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->navigationInfo, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viewpoint, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -2838,10 +2918,14 @@ static const u16 CompositeTexture3D_Out2All[] = { 2, 3, 4, 5, 6, 7, 8}; static u32 CompositeTexture3D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 11; } @@ -2961,7 +3045,7 @@ static s32 CompositeTexture3D_get_field_index_by_name(char *name) if (!strcmp("repeatS", name)) return 9; if (!strcmp("repeatT", name)) return 10; return -1; - } +} static Bool CompositeTexture3D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3021,10 +3105,14 @@ static const u16 Conditional_Out2All[] = { 2, 3}; static u32 Conditional_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -3088,7 +3176,7 @@ static s32 Conditional_get_field_index_by_name(char *name) if (!strcmp("buffer", name)) return 2; if (!strcmp("isActive", name)) return 3; return -1; - } +} static Bool Conditional_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3105,7 +3193,7 @@ GF_Node *Conditional_Create() GF_SAFEALLOC(p, M_Conditional); if(!p) return NULL; gf_node_setup((GF_Node *)p, TAG_MPEG4_Conditional); - p->buffer.commandList = gf_list_new(); + p->buffer.commandList = gf_list_new(); /*default field values*/ return (GF_Node *)p; @@ -3127,10 +3215,14 @@ static const u16 Cone_Def2All[] = { 0, 1, 2, 3}; static u32 Cone_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -3186,7 +3278,7 @@ static s32 Cone_get_field_index_by_name(char *name) if (!strcmp("side", name)) return 2; if (!strcmp("bottom", name)) return 3; return -1; - } +} static Bool Cone_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3244,10 +3336,14 @@ static const u16 Coordinate_Dyn2All[] = { 0}; static u32 Coordinate_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -3291,7 +3387,7 @@ static s32 Coordinate_get_field_index_by_name(char *name) { if (!strcmp("point", name)) return 0; return -1; - } +} static Bool Coordinate_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3339,10 +3435,14 @@ static const u16 Coordinate2D_Dyn2All[] = { 0}; static u32 Coordinate2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -3386,7 +3486,7 @@ static s32 Coordinate2D_get_field_index_by_name(char *name) { if (!strcmp("point", name)) return 0; return -1; - } +} static Bool Coordinate2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3435,10 +3535,14 @@ static const u16 CoordinateInterpolator_Out2All[] = { 1, 2, 3}; static u32 CoordinateInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -3501,7 +3605,7 @@ static s32 CoordinateInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool CoordinateInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3556,10 +3660,14 @@ static const u16 CoordinateInterpolator2D_Out2All[] = { 1, 2, 3}; static u32 CoordinateInterpolator2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -3622,7 +3730,7 @@ static s32 CoordinateInterpolator2D_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool CoordinateInterpolator2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3664,7 +3772,7 @@ GF_Node *CoordinateInterpolator2D_Create() static void Curve2D_Del(GF_Node *node) { M_Curve2D *p = (M_Curve2D *) node; - gf_node_unregister((GF_Node *) p->point, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->point, (GF_Node *) p); gf_sg_mfint32_del(p->type); gf_node_free((GF_Node *) p); } @@ -3677,10 +3785,14 @@ static const u16 Curve2D_Dyn2All[] = { 1}; static u32 Curve2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 3; } @@ -3739,7 +3851,7 @@ static s32 Curve2D_get_field_index_by_name(char *name) if (!strcmp("fineness", name)) return 1; if (!strcmp("type", name)) return 2; return -1; - } +} static Bool Curve2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3791,10 +3903,14 @@ static const u16 Cylinder_Def2All[] = { 0, 1, 2, 3, 4}; static u32 Cylinder_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -3857,7 +3973,7 @@ static s32 Cylinder_get_field_index_by_name(char *name) if (!strcmp("side", name)) return 3; if (!strcmp("top", name)) return 4; return -1; - } +} static Bool Cylinder_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -3914,10 +4030,14 @@ static const u16 CylinderSensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; static u32 CylinderSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -4014,7 +4134,7 @@ static s32 CylinderSensor_get_field_index_by_name(char *name) if (!strcmp("rotation_changed", name)) return 7; if (!strcmp("trackPoint_changed", name)) return 8; return -1; - } +} static Bool CylinderSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -4085,10 +4205,14 @@ static const u16 DirectionalLight_Dyn2All[] = { 0, 1, 2, 3}; static u32 DirectionalLight_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 4; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 4; default: return 5; } @@ -4160,7 +4284,7 @@ static s32 DirectionalLight_get_field_index_by_name(char *name) if (!strcmp("intensity", name)) return 3; if (!strcmp("on", name)) return 4; return -1; - } +} static Bool DirectionalLight_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -4231,10 +4355,14 @@ static const u16 DiscSensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 DiscSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -4324,7 +4452,7 @@ static s32 DiscSensor_get_field_index_by_name(char *name) if (!strcmp("rotation_changed", name)) return 6; if (!strcmp("trackPoint_changed", name)) return 7; return -1; - } +} static Bool DiscSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -4378,9 +4506,9 @@ static void ElevationGrid_Del(GF_Node *node) { M_ElevationGrid *p = (M_ElevationGrid *) node; gf_sg_mffloat_del(p->set_height); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); gf_sg_mffloat_del(p->height); gf_node_free((GF_Node *) p); } @@ -4392,10 +4520,14 @@ static const u16 ElevationGrid_Out2All[] = { 1, 2, 3}; static u32 ElevationGrid_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 13; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 13; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 14; } @@ -4531,7 +4663,7 @@ static s32 ElevationGrid_get_field_index_by_name(char *name) if (!strcmp("zDimension", name)) return 12; if (!strcmp("zSpacing", name)) return 13; return -1; - } +} static Bool ElevationGrid_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -4616,10 +4748,14 @@ static const u16 Expression_Out2All[] = { 0, 1, 2, 3, 4, 5}; static u32 Expression_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -4695,7 +4831,7 @@ static s32 Expression_get_field_index_by_name(char *name) if (!strcmp("init_face", name)) return 4; if (!strcmp("expression_def", name)) return 5; return -1; - } +} static Bool Expression_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -4774,10 +4910,14 @@ static const u16 Extrusion_In2All[] = { 0, 1, 2, 3}; static u32 Extrusion_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 14; } @@ -4910,7 +5050,7 @@ static s32 Extrusion_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 12; if (!strcmp("spine", name)) return 13; return -1; - } +} static Bool Extrusion_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -5006,11 +5146,11 @@ GF_Node *Extrusion_Create() static void Face_Del(GF_Node *node) { M_Face *p = (M_Face *) node; - gf_node_unregister((GF_Node *) p->fap, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->fdp, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->fit, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->ttsSource, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->renderedFace); + gf_node_unregister((GF_Node *) p->fap, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->fdp, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->fit, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->ttsSource, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->renderedFace); gf_node_free((GF_Node *) p); } @@ -5021,10 +5161,14 @@ static const u16 Face_Out2All[] = { 0, 1, 2, 3, 4}; static u32 Face_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -5098,7 +5242,7 @@ static s32 Face_get_field_index_by_name(char *name) if (!strcmp("ttsSource", name)) return 3; if (!strcmp("renderedFace", name)) return 4; return -1; - } +} static Bool Face_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -5128,7 +5272,7 @@ GF_Node *Face_Create() static void FaceDefMesh_Del(GF_Node *node) { M_FaceDefMesh *p = (M_FaceDefMesh *) node; - gf_node_unregister((GF_Node *) p->faceSceneGraphNode, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->faceSceneGraphNode, (GF_Node *) p); gf_sg_mfint32_del(p->intervalBorders); gf_sg_mfint32_del(p->coordIndex); gf_sg_mfvec3f_del(p->displacements); @@ -5140,10 +5284,14 @@ static const u16 FaceDefMesh_Def2All[] = { 0, 1, 2, 3}; static u32 FaceDefMesh_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -5200,7 +5348,7 @@ static s32 FaceDefMesh_get_field_index_by_name(char *name) if (!strcmp("coordIndex", name)) return 2; if (!strcmp("displacements", name)) return 3; return -1; - } +} static Bool FaceDefMesh_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -5242,8 +5390,8 @@ GF_Node *FaceDefMesh_Create() static void FaceDefTables_Del(GF_Node *node) { M_FaceDefTables *p = (M_FaceDefTables *) node; - gf_node_unregister_children((GF_Node *) p, p->faceDefMesh); - gf_node_unregister_children((GF_Node *) p, p->faceDefTransform); + gf_node_unregister_children((GF_Node *) p, p->faceDefMesh); + gf_node_unregister_children((GF_Node *) p, p->faceDefTransform); gf_node_free((GF_Node *) p); } @@ -5254,10 +5402,14 @@ static const u16 FaceDefTables_Out2All[] = { 2, 3}; static u32 FaceDefTables_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -5321,7 +5473,7 @@ static s32 FaceDefTables_get_field_index_by_name(char *name) if (!strcmp("faceDefMesh", name)) return 2; if (!strcmp("faceDefTransform", name)) return 3; return -1; - } +} static Bool FaceDefTables_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -5367,7 +5519,7 @@ GF_Node *FaceDefTables_Create() static void FaceDefTransform_Del(GF_Node *node) { M_FaceDefTransform *p = (M_FaceDefTransform *) node; - gf_node_unregister((GF_Node *) p->faceSceneGraphNode, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->faceSceneGraphNode, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -5376,10 +5528,14 @@ static const u16 FaceDefTransform_Def2All[] = { 0, 1, 2, 3, 4}; static u32 FaceDefTransform_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -5443,7 +5599,7 @@ static s32 FaceDefTransform_get_field_index_by_name(char *name) if (!strcmp("scaleDef", name)) return 3; if (!strcmp("translationDef", name)) return 4; return -1; - } +} static Bool FaceDefTransform_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -5498,8 +5654,8 @@ GF_Node *FaceDefTransform_Create() static void FAP_Del(GF_Node *node) { M_FAP *p = (M_FAP *) node; - gf_node_unregister((GF_Node *) p->viseme, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->expression, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viseme, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->expression, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -5510,10 +5666,14 @@ static const u16 FAP_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, static u32 FAP_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 68; - case GF_SG_FIELD_CODING_DEF: return 68; - case GF_SG_FIELD_CODING_OUT: return 68; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 68; + case GF_SG_FIELD_CODING_DEF: + return 68; + case GF_SG_FIELD_CODING_OUT: + return 68; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 68; } @@ -6025,7 +6185,7 @@ static s32 FAP_get_field_index_by_name(char *name) if (!strcmp("pull_l_ear", name)) return 66; if (!strcmp("pull_r_ear", name)) return 67; return -1; - } +} static Bool FAP_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -6517,10 +6677,10 @@ GF_Node *FAP_Create() static void FDP_Del(GF_Node *node) { M_FDP *p = (M_FDP *) node; - gf_node_unregister((GF_Node *) p->featurePointsCoord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->textureCoord, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->faceDefTables); - gf_node_unregister_children((GF_Node *) p, p->faceSceneGraph); + gf_node_unregister((GF_Node *) p->featurePointsCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->textureCoord, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->faceDefTables); + gf_node_unregister_children((GF_Node *) p, p->faceSceneGraph); gf_node_free((GF_Node *) p); } @@ -6531,10 +6691,14 @@ static const u16 FDP_Out2All[] = { 0, 1, 2, 3}; static u32 FDP_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -6607,7 +6771,7 @@ static s32 FDP_get_field_index_by_name(char *name) if (!strcmp("faceSceneGraph", name)) return 3; if (!strcmp("useOrthoTexture", name)) return 4; return -1; - } +} static Bool FDP_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -6656,10 +6820,14 @@ static const u16 FIT_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; static u32 FIT_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -6756,7 +6924,7 @@ static s32 FIT_get_field_index_by_name(char *name) if (!strcmp("numeratorCoefs", name)) return 7; if (!strcmp("denominatorCoefs", name)) return 8; return -1; - } +} static Bool FIT_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -6847,10 +7015,14 @@ static const u16 Fog_Dyn2All[] = { 0, 2}; static u32 Fog_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 5; } @@ -6923,7 +7095,7 @@ static s32 Fog_get_field_index_by_name(char *name) if (!strcmp("set_bind", name)) return 3; if (!strcmp("isBound", name)) return 4; return -1; - } +} static Bool Fog_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -6985,10 +7157,14 @@ static const u16 FontStyle_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; static u32 FontStyle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -7085,7 +7261,7 @@ static s32 FontStyle_get_field_index_by_name(char *name) if (!strcmp("style", name)) return 7; if (!strcmp("topToBottom", name)) return 8; return -1; - } +} static Bool FontStyle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7145,7 +7321,7 @@ static void Form_Del(GF_Node *node) gf_sg_mfint32_del(p->groups); gf_sg_mfstring_del(p->constraints); gf_sg_mfint32_del(p->groupsIndex); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -7157,10 +7333,14 @@ static const u16 Form_Dyn2All[] = { 3}; static u32 Form_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -7251,7 +7431,7 @@ static s32 Form_get_field_index_by_name(char *name) if (!strcmp("constraints", name)) return 5; if (!strcmp("groupsIndex", name)) return 6; return -1; - } +} static Bool Form_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7304,7 +7484,7 @@ GF_Node *Form_Create() static void Group_Del(GF_Node *node) { M_Group *p = (M_Group *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -7315,10 +7495,14 @@ static const u16 Group_Out2All[] = { 2}; static u32 Group_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -7378,7 +7562,7 @@ static s32 Group_get_field_index_by_name(char *name) if (!strcmp("removeChildren", name)) return 1; if (!strcmp("children", name)) return 2; return -1; - } +} static Bool Group_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7420,10 +7604,14 @@ static const u16 ImageTexture_Out2All[] = { 0}; static u32 ImageTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -7478,7 +7666,7 @@ static s32 ImageTexture_get_field_index_by_name(char *name) if (!strcmp("repeatS", name)) return 1; if (!strcmp("repeatT", name)) return 2; return -1; - } +} static Bool ImageTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7514,10 +7702,10 @@ static void IndexedFaceSet_Del(GF_Node *node) gf_sg_mfint32_del(p->set_coordIndex); gf_sg_mfint32_del(p->set_normalIndex); gf_sg_mfint32_del(p->set_texCoordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); gf_sg_mfint32_del(p->normalIndex); @@ -7532,10 +7720,14 @@ static const u16 IndexedFaceSet_Out2All[] = { 4, 5, 6, 7}; static u32 IndexedFaceSet_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 14; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 14; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 18; } @@ -7703,7 +7895,7 @@ static s32 IndexedFaceSet_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 16; if (!strcmp("texCoordIndex", name)) return 17; return -1; - } +} static Bool IndexedFaceSet_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7772,9 +7964,9 @@ static void IndexedFaceSet2D_Del(GF_Node *node) gf_sg_mfint32_del(p->set_colorIndex); gf_sg_mfint32_del(p->set_coordIndex); gf_sg_mfint32_del(p->set_texCoordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); gf_sg_mfint32_del(p->texCoordIndex); @@ -7788,10 +7980,14 @@ static const u16 IndexedFaceSet2D_Out2All[] = { 3, 4, 5}; static u32 IndexedFaceSet2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 11; } @@ -7908,7 +8104,7 @@ static s32 IndexedFaceSet2D_get_field_index_by_name(char *name) if (!strcmp("coordIndex", name)) return 9; if (!strcmp("texCoordIndex", name)) return 10; return -1; - } +} static Bool IndexedFaceSet2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -7960,8 +8156,8 @@ static void IndexedLineSet_Del(GF_Node *node) M_IndexedLineSet *p = (M_IndexedLineSet *) node; gf_sg_mfint32_del(p->set_colorIndex); gf_sg_mfint32_del(p->set_coordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); gf_node_free((GF_Node *) p); @@ -7974,10 +8170,14 @@ static const u16 IndexedLineSet_Out2All[] = { 2, 3}; static u32 IndexedLineSet_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -8064,7 +8264,7 @@ static s32 IndexedLineSet_get_field_index_by_name(char *name) if (!strcmp("colorPerVertex", name)) return 5; if (!strcmp("coordIndex", name)) return 6; return -1; - } +} static Bool IndexedLineSet_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8109,8 +8309,8 @@ static void IndexedLineSet2D_Del(GF_Node *node) M_IndexedLineSet2D *p = (M_IndexedLineSet2D *) node; gf_sg_mfint32_del(p->set_colorIndex); gf_sg_mfint32_del(p->set_coordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); gf_node_free((GF_Node *) p); @@ -8123,10 +8323,14 @@ static const u16 IndexedLineSet2D_Out2All[] = { 2, 3}; static u32 IndexedLineSet2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -8213,7 +8417,7 @@ static s32 IndexedLineSet2D_get_field_index_by_name(char *name) if (!strcmp("colorPerVertex", name)) return 5; if (!strcmp("coordIndex", name)) return 6; return -1; - } +} static Bool IndexedLineSet2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8267,10 +8471,14 @@ static const u16 Inline_Out2All[] = { 0}; static u32 Inline_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 1; } @@ -8311,7 +8519,7 @@ static s32 Inline_get_field_index_by_name(char *name) { if (!strcmp("url", name)) return 0; return -1; - } +} static Bool Inline_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8341,7 +8549,7 @@ GF_Node *Inline_Create() static void LOD_Del(GF_Node *node) { M_LOD *p = (M_LOD *) node; - gf_node_unregister_children((GF_Node *) p, p->level); + gf_node_unregister_children((GF_Node *) p, p->level); gf_sg_mffloat_del(p->range); gf_node_free((GF_Node *) p); } @@ -8353,10 +8561,14 @@ static const u16 LOD_Out2All[] = { 0}; static u32 LOD_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -8412,7 +8624,7 @@ static s32 LOD_get_field_index_by_name(char *name) if (!strcmp("center", name)) return 1; if (!strcmp("range", name)) return 2; return -1; - } +} static Bool LOD_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8457,9 +8669,9 @@ GF_Node *LOD_Create() static void Layer2D_Del(GF_Node *node) { M_Layer2D *p = (M_Layer2D *) node; - gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->viewport, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viewport, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -8471,10 +8683,14 @@ static const u16 Layer2D_Dyn2All[] = { 3}; static u32 Layer2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 6; } @@ -8560,7 +8776,7 @@ static s32 Layer2D_get_field_index_by_name(char *name) if (!strcmp("background", name)) return 4; if (!strcmp("viewport", name)) return 5; return -1; - } +} static Bool Layer2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8599,11 +8815,11 @@ GF_Node *Layer2D_Create() static void Layer3D_Del(GF_Node *node) { M_Layer3D *p = (M_Layer3D *) node; - gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->fog, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->navigationInfo, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->viewpoint, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->background, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->fog, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->navigationInfo, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viewpoint, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -8615,10 +8831,14 @@ static const u16 Layer3D_Dyn2All[] = { 3}; static u32 Layer3D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 8; } @@ -8720,7 +8940,7 @@ static s32 Layer3D_get_field_index_by_name(char *name) if (!strcmp("navigationInfo", name)) return 6; if (!strcmp("viewpoint", name)) return 7; return -1; - } +} static Bool Layer3D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -8760,7 +8980,7 @@ static void Layout_Del(GF_Node *node) { M_Layout *p = (M_Layout *) node; gf_sg_mfstring_del(p->justify); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -8772,10 +8992,14 @@ static const u16 Layout_Dyn2All[] = { 4, 9, 13}; static u32 Layout_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 15; - case GF_SG_FIELD_CODING_DEF: return 13; - case GF_SG_FIELD_CODING_OUT: return 13; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 15; + case GF_SG_FIELD_CODING_DEF: + return 13; + case GF_SG_FIELD_CODING_OUT: + return 13; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 15; } @@ -8922,7 +9146,7 @@ static s32 Layout_get_field_index_by_name(char *name) if (!strcmp("scrollRate", name)) return 13; if (!strcmp("scrollMode", name)) return 14; return -1; - } +} static Bool Layout_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9002,10 +9226,14 @@ static const u16 LineProperties_Dyn2All[] = { 0, 2}; static u32 LineProperties_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 3; } @@ -9063,7 +9291,7 @@ static s32 LineProperties_get_field_index_by_name(char *name) if (!strcmp("lineStyle", name)) return 1; if (!strcmp("width", name)) return 2; return -1; - } +} static Bool LineProperties_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9129,10 +9357,14 @@ static const u16 ListeningPoint_Dyn2All[] = { 2, 3}; static u32 ListeningPoint_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 7; } @@ -9219,7 +9451,7 @@ static s32 ListeningPoint_get_field_index_by_name(char *name) if (!strcmp("bindTime", name)) return 5; if (!strcmp("isBound", name)) return 6; return -1; - } +} static Bool ListeningPoint_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9278,10 +9510,14 @@ static const u16 Material_Dyn2All[] = { 0, 1, 2, 3, 4, 5}; static u32 Material_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 6; } @@ -9360,7 +9596,7 @@ static s32 Material_get_field_index_by_name(char *name) if (!strcmp("specularColor", name)) return 4; if (!strcmp("transparency", name)) return 5; return -1; - } +} static Bool Material_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9438,7 +9674,7 @@ GF_Node *Material_Create() static void Material2D_Del(GF_Node *node) { M_Material2D *p = (M_Material2D *) node; - gf_node_unregister((GF_Node *) p->lineProps, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->lineProps, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -9450,10 +9686,14 @@ static const u16 Material2D_Dyn2All[] = { 0, 3}; static u32 Material2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 4; } @@ -9519,7 +9759,7 @@ static s32 Material2D_get_field_index_by_name(char *name) if (!strcmp("lineProps", name)) return 2; if (!strcmp("transparency", name)) return 3; return -1; - } +} static Bool Material2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9577,10 +9817,14 @@ static const u16 MovieTexture_Dyn2All[] = { 1}; static u32 MovieTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 9; } @@ -9680,7 +9924,7 @@ static s32 MovieTexture_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 7; if (!strcmp("isActive", name)) return 8; return -1; - } +} static Bool MovieTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9734,10 +9978,14 @@ static const u16 NavigationInfo_Dyn2All[] = { 5}; static u32 NavigationInfo_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -9824,7 +10072,7 @@ static s32 NavigationInfo_get_field_index_by_name(char *name) if (!strcmp("visibilityLimit", name)) return 5; if (!strcmp("isBound", name)) return 6; return -1; - } +} static Bool NavigationInfo_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9898,10 +10146,14 @@ static const u16 Normal_Dyn2All[] = { 0}; static u32 Normal_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -9945,7 +10197,7 @@ static s32 Normal_get_field_index_by_name(char *name) { if (!strcmp("vector", name)) return 0; return -1; - } +} static Bool Normal_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -9992,10 +10244,14 @@ static const u16 NormalInterpolator_Out2All[] = { 1, 2, 3}; static u32 NormalInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -10058,7 +10314,7 @@ static s32 NormalInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool NormalInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10101,7 +10357,7 @@ static void OrderedGroup_Del(GF_Node *node) { M_OrderedGroup *p = (M_OrderedGroup *) node; gf_sg_mffloat_del(p->order); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -10112,10 +10368,14 @@ static const u16 OrderedGroup_Out2All[] = { 2, 3}; static u32 OrderedGroup_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -10182,7 +10442,7 @@ static s32 OrderedGroup_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 2; if (!strcmp("order", name)) return 3; return -1; - } +} static Bool OrderedGroup_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10231,10 +10491,14 @@ static const u16 OrientationInterpolator_Out2All[] = { 1, 2, 3}; static u32 OrientationInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -10297,7 +10561,7 @@ static s32 OrientationInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool OrientationInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10350,10 +10614,14 @@ static const u16 PixelTexture_Out2All[] = { 0}; static u32 PixelTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -10408,7 +10676,7 @@ static s32 PixelTexture_get_field_index_by_name(char *name) if (!strcmp("repeatS", name)) return 1; if (!strcmp("repeatT", name)) return 2; return -1; - } +} static Bool PixelTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10454,10 +10722,14 @@ static const u16 PlaneSensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 PlaneSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -10547,7 +10819,7 @@ static s32 PlaneSensor_get_field_index_by_name(char *name) if (!strcmp("trackPoint_changed", name)) return 6; if (!strcmp("translation_changed", name)) return 7; return -1; - } +} static Bool PlaneSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10614,10 +10886,14 @@ static const u16 PlaneSensor2D_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 PlaneSensor2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -10707,7 +10983,7 @@ static s32 PlaneSensor2D_get_field_index_by_name(char *name) if (!strcmp("trackPoint_changed", name)) return 6; if (!strcmp("translation_changed", name)) return 7; return -1; - } +} static Bool PlaneSensor2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10774,10 +11050,14 @@ static const u16 PointLight_Dyn2All[] = { 0, 1, 2, 3, 4, 6}; static u32 PointLight_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 7; } @@ -10863,7 +11143,7 @@ static s32 PointLight_get_field_index_by_name(char *name) if (!strcmp("on", name)) return 5; if (!strcmp("radius", name)) return 6; return -1; - } +} static Bool PointLight_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -10942,8 +11222,8 @@ GF_Node *PointLight_Create() static void PointSet_Del(GF_Node *node) { M_PointSet *p = (M_PointSet *) node; - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -10954,10 +11234,14 @@ static const u16 PointSet_Out2All[] = { 0, 1}; static u32 PointSet_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -11007,7 +11291,7 @@ static s32 PointSet_get_field_index_by_name(char *name) if (!strcmp("color", name)) return 0; if (!strcmp("coord", name)) return 1; return -1; - } +} static Bool PointSet_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11037,8 +11321,8 @@ GF_Node *PointSet_Create() static void PointSet2D_Del(GF_Node *node) { M_PointSet2D *p = (M_PointSet2D *) node; - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -11049,10 +11333,14 @@ static const u16 PointSet2D_Out2All[] = { 0, 1}; static u32 PointSet2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -11102,7 +11390,7 @@ static s32 PointSet2D_get_field_index_by_name(char *name) if (!strcmp("color", name)) return 0; if (!strcmp("coord", name)) return 1; return -1; - } +} static Bool PointSet2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11144,10 +11432,14 @@ static const u16 PositionInterpolator_Out2All[] = { 1, 2, 3}; static u32 PositionInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -11210,7 +11502,7 @@ static s32 PositionInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool PositionInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11264,10 +11556,14 @@ static const u16 PositionInterpolator2D_Out2All[] = { 1, 2, 3}; static u32 PositionInterpolator2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -11330,7 +11626,7 @@ static s32 PositionInterpolator2D_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool PositionInterpolator2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11382,10 +11678,14 @@ static const u16 ProximitySensor2D_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 ProximitySensor2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -11475,7 +11775,7 @@ static s32 ProximitySensor2D_get_field_index_by_name(char *name) if (!strcmp("enterTime", name)) return 6; if (!strcmp("exitTime", name)) return 7; return -1; - } +} static Bool ProximitySensor2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11532,10 +11832,14 @@ static const u16 ProximitySensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 ProximitySensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -11625,7 +11929,7 @@ static s32 ProximitySensor_get_field_index_by_name(char *name) if (!strcmp("enterTime", name)) return 6; if (!strcmp("exitTime", name)) return 7; return -1; - } +} static Bool ProximitySensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -11682,10 +11986,14 @@ static const u16 QuantizationParameter_Def2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, static u32 QuantizationParameter_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 40; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 40; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 40; } @@ -11993,7 +12301,7 @@ static s32 QuantizationParameter_get_field_index_by_name(char *name) if (!strcmp("sizeNbBits", name)) return 38; if (!strcmp("useEfficientCoding", name)) return 39; return -1; - } +} static Bool QuantizationParameter_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12251,10 +12559,14 @@ static const u16 Rectangle_Dyn2All[] = { 0}; static u32 Rectangle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -12298,7 +12610,7 @@ static s32 Rectangle_get_field_index_by_name(char *name) { if (!strcmp("size", name)) return 0; return -1; - } +} static Bool Rectangle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12348,10 +12660,14 @@ static const u16 ScalarInterpolator_Out2All[] = { 1, 2, 3}; static u32 ScalarInterpolator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -12414,7 +12730,7 @@ static s32 ScalarInterpolator_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool ScalarInterpolator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12467,10 +12783,14 @@ static const u16 Script_Out2All[] = { 0}; static u32 Script_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -12525,7 +12845,7 @@ static s32 Script_get_field_index_by_name(char *name) if (!strcmp("directOutput", name)) return 1; if (!strcmp("mustEvaluate", name)) return 2; return -1; - } +} static Bool Script_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12555,8 +12875,8 @@ GF_Node *Script_Create() static void Shape_Del(GF_Node *node) { M_Shape *p = (M_Shape *) node; - gf_node_unregister((GF_Node *) p->appearance, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->appearance, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -12567,10 +12887,14 @@ static const u16 Shape_Out2All[] = { 0, 1}; static u32 Shape_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -12620,7 +12944,7 @@ static s32 Shape_get_field_index_by_name(char *name) if (!strcmp("appearance", name)) return 0; if (!strcmp("geometry", name)) return 1; return -1; - } +} static Bool Shape_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12650,7 +12974,7 @@ GF_Node *Shape_Create() static void Sound_Del(GF_Node *node) { M_Sound *p = (M_Sound *) node; - gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -12662,10 +12986,14 @@ static const u16 Sound_Dyn2All[] = { 1, 2, 3, 4, 5, 6}; static u32 Sound_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 10; } @@ -12773,7 +13101,7 @@ static s32 Sound_get_field_index_by_name(char *name) if (!strcmp("source", name)) return 8; if (!strcmp("spatialize", name)) return 9; return -1; - } +} static Bool Sound_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12864,7 +13192,7 @@ GF_Node *Sound_Create() static void Sound2D_Del(GF_Node *node) { M_Sound2D *p = (M_Sound2D *) node; - gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -12876,10 +13204,14 @@ static const u16 Sound2D_Dyn2All[] = { 0, 1}; static u32 Sound2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 4; } @@ -12945,7 +13277,7 @@ static s32 Sound2D_get_field_index_by_name(char *name) if (!strcmp("source", name)) return 2; if (!strcmp("spatialize", name)) return 3; return -1; - } +} static Bool Sound2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -12999,10 +13331,14 @@ static const u16 Sphere_Def2All[] = { 0}; static u32 Sphere_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 1; } @@ -13037,7 +13373,7 @@ static s32 Sphere_get_field_index_by_name(char *name) { if (!strcmp("radius", name)) return 0; return -1; - } +} static Bool Sphere_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13084,10 +13420,14 @@ static const u16 SphereSensor_Out2All[] = { 0, 1, 2, 3, 4, 5}; static u32 SphereSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -13163,7 +13503,7 @@ static s32 SphereSensor_get_field_index_by_name(char *name) if (!strcmp("rotation_changed", name)) return 4; if (!strcmp("trackPoint_changed", name)) return 5; return -1; - } +} static Bool SphereSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13216,10 +13556,14 @@ static const u16 SpotLight_Dyn2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 9}; static u32 SpotLight_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 10; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 10; - case GF_SG_FIELD_CODING_DYN: return 9; + case GF_SG_FIELD_CODING_IN: + return 10; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 10; + case GF_SG_FIELD_CODING_DYN: + return 9; default: return 10; } @@ -13326,7 +13670,7 @@ static s32 SpotLight_get_field_index_by_name(char *name) if (!strcmp("on", name)) return 8; if (!strcmp("radius", name)) return 9; return -1; - } +} static Bool SpotLight_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13428,7 +13772,7 @@ GF_Node *SpotLight_Create() static void Switch_Del(GF_Node *node) { M_Switch *p = (M_Switch *) node; - gf_node_unregister_children((GF_Node *) p, p->choice); + gf_node_unregister_children((GF_Node *) p, p->choice); gf_node_free((GF_Node *) p); } @@ -13439,10 +13783,14 @@ static const u16 Switch_Out2All[] = { 0, 1}; static u32 Switch_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -13491,7 +13839,7 @@ static s32 Switch_get_field_index_by_name(char *name) if (!strcmp("choice", name)) return 0; if (!strcmp("whichChoice", name)) return 1; return -1; - } +} static Bool Switch_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13539,10 +13887,14 @@ static const u16 TermCap_Out2All[] = { 1, 2}; static u32 TermCap_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -13598,7 +13950,7 @@ static s32 TermCap_get_field_index_by_name(char *name) if (!strcmp("capability", name)) return 1; if (!strcmp("value", name)) return 2; return -1; - } +} static Bool TermCap_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13645,7 +13997,7 @@ static void Text_Del(GF_Node *node) M_Text *p = (M_Text *) node; gf_sg_mfstring_del(p->string); gf_sg_mffloat_del(p->length); - gf_node_unregister((GF_Node *) p->fontStyle, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->fontStyle, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -13657,10 +14009,14 @@ static const u16 Text_Dyn2All[] = { 1, 3}; static u32 Text_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 4; } @@ -13726,7 +14082,7 @@ static s32 Text_get_field_index_by_name(char *name) if (!strcmp("fontStyle", name)) return 2; if (!strcmp("maxExtent", name)) return 3; return -1; - } +} static Bool Text_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13781,10 +14137,14 @@ static const u16 TextureCoordinate_Dyn2All[] = { 0}; static u32 TextureCoordinate_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -13828,7 +14188,7 @@ static s32 TextureCoordinate_get_field_index_by_name(char *name) { if (!strcmp("point", name)) return 0; return -1; - } +} static Bool TextureCoordinate_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -13875,10 +14235,14 @@ static const u16 TextureTransform_Dyn2All[] = { 0, 1, 2, 3}; static u32 TextureTransform_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 4; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 4; default: return 4; } @@ -13943,7 +14307,7 @@ static s32 TextureTransform_get_field_index_by_name(char *name) if (!strcmp("scale", name)) return 2; if (!strcmp("translation", name)) return 3; return -1; - } +} static Bool TextureTransform_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -14014,10 +14378,14 @@ static const u16 TimeSensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; static u32 TimeSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -14114,7 +14482,7 @@ static s32 TimeSensor_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 7; if (!strcmp("time", name)) return 8; return -1; - } +} static Bool TimeSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -14158,10 +14526,14 @@ static const u16 TouchSensor_Out2All[] = { 0, 1, 2, 3, 4, 5, 6}; static u32 TouchSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -14244,7 +14616,7 @@ static s32 TouchSensor_get_field_index_by_name(char *name) if (!strcmp("isOver", name)) return 5; if (!strcmp("touchTime", name)) return 6; return -1; - } +} static Bool TouchSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -14275,7 +14647,7 @@ GF_Node *TouchSensor_Create() static void Transform_Del(GF_Node *node) { M_Transform *p = (M_Transform *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -14287,10 +14659,14 @@ static const u16 Transform_Dyn2All[] = { 2, 4, 5, 6, 7}; static u32 Transform_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 8; } @@ -14388,7 +14764,7 @@ static s32 Transform_get_field_index_by_name(char *name) if (!strcmp("scaleOrientation", name)) return 6; if (!strcmp("translation", name)) return 7; return -1; - } +} static Bool Transform_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -14462,7 +14838,7 @@ GF_Node *Transform_Create() static void Transform2D_Del(GF_Node *node) { M_Transform2D *p = (M_Transform2D *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -14474,10 +14850,14 @@ static const u16 Transform2D_Dyn2All[] = { 3, 4, 5, 6, 7}; static u32 Transform2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 8; } @@ -14575,7 +14955,7 @@ static s32 Transform2D_get_field_index_by_name(char *name) if (!strcmp("scaleOrientation", name)) return 6; if (!strcmp("translation", name)) return 7; return -1; - } +} static Bool Transform2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -14670,10 +15050,14 @@ static const u16 Valuator_Out2All[] = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, static u32 Valuator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 25; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 25; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 25; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 25; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 41; } @@ -15010,7 +15394,7 @@ static s32 Valuator_get_field_index_by_name(char *name) if (!strcmp("Offset4", name)) return 39; if (!strcmp("Sum", name)) return 40; return -1; - } +} static Bool Valuator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15108,10 +15492,14 @@ static const u16 Viewpoint_Dyn2All[] = { 1, 3, 4}; static u32 Viewpoint_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 8; } @@ -15205,7 +15593,7 @@ static s32 Viewpoint_get_field_index_by_name(char *name) if (!strcmp("bindTime", name)) return 6; if (!strcmp("isBound", name)) return 7; return -1; - } +} static Bool Viewpoint_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15271,10 +15659,14 @@ static const u16 VisibilitySensor_Dyn2All[] = { 0, 2}; static u32 VisibilitySensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 6; } @@ -15353,7 +15745,7 @@ static s32 VisibilitySensor_get_field_index_by_name(char *name) if (!strcmp("exitTime", name)) return 4; if (!strcmp("isActive", name)) return 5; return -1; - } +} static Bool VisibilitySensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15412,10 +15804,14 @@ static const u16 Viseme_Out2All[] = { 0, 1, 2, 3}; static u32 Viseme_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -15477,7 +15873,7 @@ static s32 Viseme_get_field_index_by_name(char *name) if (!strcmp("viseme_blend", name)) return 2; if (!strcmp("viseme_def", name)) return 3; return -1; - } +} static Bool Viseme_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15541,10 +15937,14 @@ static const u16 WorldInfo_Def2All[] = { 0, 1}; static u32 WorldInfo_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -15586,7 +15986,7 @@ static s32 WorldInfo_get_field_index_by_name(char *name) if (!strcmp("info", name)) return 0; if (!strcmp("title", name)) return 1; return -1; - } +} static Bool WorldInfo_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15631,10 +16031,14 @@ static const u16 AcousticMaterial_Dyn2All[] = { 0, 1, 2, 3, 4, 5}; static u32 AcousticMaterial_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 10; } @@ -15741,7 +16145,7 @@ static s32 AcousticMaterial_get_field_index_by_name(char *name) if (!strcmp("refFrequency", name)) return 8; if (!strcmp("transFrequency", name)) return 9; return -1; - } +} static Bool AcousticMaterial_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -15868,10 +16272,14 @@ static const u16 AcousticScene_Dyn2All[] = { 4}; static u32 AcousticScene_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 6; } @@ -15950,7 +16358,7 @@ static s32 AcousticScene_get_field_index_by_name(char *name) if (!strcmp("reverbLevel", name)) return 4; if (!strcmp("reverbDelay", name)) return 5; return -1; - } +} static Bool AcousticScene_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -16044,10 +16452,14 @@ static const u16 ApplicationWindow_Dyn2All[] = { 6}; static u32 ApplicationWindow_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -16133,7 +16545,7 @@ static s32 ApplicationWindow_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 5; if (!strcmp("size", name)) return 6; return -1; - } +} static Bool ApplicationWindow_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -16195,10 +16607,14 @@ static const u16 BAP_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, static u32 BAP_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 296; - case GF_SG_FIELD_CODING_DEF: return 296; - case GF_SG_FIELD_CODING_OUT: return 296; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 296; + case GF_SG_FIELD_CODING_DEF: + return 296; + case GF_SG_FIELD_CODING_OUT: + return 296; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 296; } @@ -18304,7 +18720,7 @@ static s32 BAP_get_field_index_by_name(char *name) if (!strcmp("extensionBap295", name)) return 294; if (!strcmp("extensionBap296", name)) return 295; return -1; - } +} static Bool BAP_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -20406,8 +20822,8 @@ GF_Node *BAP_Create() static void BDP_Del(GF_Node *node) { M_BDP *p = (M_BDP *) node; - gf_node_unregister_children((GF_Node *) p, p->bodyDefTables); - gf_node_unregister_children((GF_Node *) p, p->bodySceneGraph); + gf_node_unregister_children((GF_Node *) p, p->bodyDefTables); + gf_node_unregister_children((GF_Node *) p, p->bodySceneGraph); gf_node_free((GF_Node *) p); } @@ -20418,10 +20834,14 @@ static const u16 BDP_Out2All[] = { 0, 1}; static u32 BDP_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -20471,7 +20891,7 @@ static s32 BDP_get_field_index_by_name(char *name) if (!strcmp("bodyDefTables", name)) return 0; if (!strcmp("bodySceneGraph", name)) return 1; return -1; - } +} static Bool BDP_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -20501,9 +20921,9 @@ GF_Node *BDP_Create() static void Body_Del(GF_Node *node) { M_Body *p = (M_Body *) node; - gf_node_unregister((GF_Node *) p->bdp, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->bap, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->renderedBody); + gf_node_unregister((GF_Node *) p->bdp, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->bap, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->renderedBody); gf_node_free((GF_Node *) p); } @@ -20514,10 +20934,14 @@ static const u16 Body_Out2All[] = { 0, 1, 2}; static u32 Body_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 3; } @@ -20575,7 +20999,7 @@ static s32 Body_get_field_index_by_name(char *name) if (!strcmp("bap", name)) return 1; if (!strcmp("renderedBody", name)) return 2; return -1; - } +} static Bool Body_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -20620,10 +21044,14 @@ static const u16 BodyDefTable_Out2All[] = { 0, 1, 2, 3, 4, 5}; static u32 BodyDefTable_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -20699,7 +21127,7 @@ static s32 BodyDefTable_get_field_index_by_name(char *name) if (!strcmp("displacements", name)) return 4; if (!strcmp("numInterpolateKeys", name)) return 5; return -1; - } +} static Bool BodyDefTable_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -20769,10 +21197,14 @@ static const u16 BodySegmentConnectionHint_Out2All[] = { 0, 1, 2, 3}; static u32 BodySegmentConnectionHint_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -20834,7 +21266,7 @@ static s32 BodySegmentConnectionHint_get_field_index_by_name(char *name) if (!strcmp("firstVertexIdList", name)) return 2; if (!strcmp("secondVertexIdList", name)) return 3; return -1; - } +} static Bool BodySegmentConnectionHint_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -20876,8 +21308,8 @@ GF_Node *BodySegmentConnectionHint_Create() static void DirectiveSound_Del(GF_Node *node) { M_DirectiveSound *p = (M_DirectiveSound *) node; - gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->perceptualParameters, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->perceptualParameters, (GF_Node *) p); gf_sg_mffloat_del(p->directivity); gf_sg_mffloat_del(p->angles); gf_sg_mffloat_del(p->frequency); @@ -20892,10 +21324,14 @@ static const u16 DirectiveSound_Dyn2All[] = { 0, 1, 2}; static u32 DirectiveSound_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 13; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 13; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 13; } @@ -21025,7 +21461,7 @@ static s32 DirectiveSound_get_field_index_by_name(char *name) if (!strcmp("distance", name)) return 11; if (!strcmp("useAirabs", name)) return 12; return -1; - } +} static Bool DirectiveSound_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -21130,10 +21566,14 @@ static const u16 Hierarchical3DMesh_Out2All[] = { 1, 3}; static u32 Hierarchical3DMesh_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -21196,7 +21636,7 @@ static s32 Hierarchical3DMesh_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("doneLoading", name)) return 3; return -1; - } +} static Bool Hierarchical3DMesh_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -21250,10 +21690,14 @@ static const u16 MaterialKey_Dyn2All[] = { 2, 3, 4, 5}; static u32 MaterialKey_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 4; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 4; default: return 6; } @@ -21332,7 +21776,7 @@ static s32 MaterialKey_get_field_index_by_name(char *name) if (!strcmp("highThreshold", name)) return 4; if (!strcmp("transparency", name)) return 5; return -1; - } +} static Bool MaterialKey_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -21408,10 +21852,14 @@ static const u16 PerceptualParameters_Dyn2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 static u32 PerceptualParameters_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 19; - case GF_SG_FIELD_CODING_DEF: return 19; - case GF_SG_FIELD_CODING_OUT: return 19; - case GF_SG_FIELD_CODING_DYN: return 15; + case GF_SG_FIELD_CODING_IN: + return 19; + case GF_SG_FIELD_CODING_DEF: + return 19; + case GF_SG_FIELD_CODING_OUT: + return 19; + case GF_SG_FIELD_CODING_DYN: + return 15; default: return 19; } @@ -21581,7 +22029,7 @@ static s32 PerceptualParameters_get_field_index_by_name(char *name) if (!strcmp("timeLimit3", name)) return 17; if (!strcmp("modalDensity", name)) return 18; return -1; - } +} static Bool PerceptualParameters_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -21757,7 +22205,7 @@ static void TemporalTransform_Del(GF_Node *node) gf_sg_mfurl_del(p->url); gf_sg_mfint32_del(p->stretchMode); gf_sg_mfint32_del(p->shrinkMode); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -21769,10 +22217,14 @@ static const u16 TemporalTransform_Dyn2All[] = { 7, 8}; static u32 TemporalTransform_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 12; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 11; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 12; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 11; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 13; } @@ -21905,7 +22357,7 @@ static s32 TemporalTransform_get_field_index_by_name(char *name) if (!strcmp("maxDelay", name)) return 11; if (!strcmp("actualDuration", name)) return 12; return -1; - } +} static Bool TemporalTransform_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -21975,7 +22427,7 @@ static void TemporalGroup_Del(GF_Node *node) { M_TemporalGroup *p = (M_TemporalGroup *) node; gf_sg_mffloat_del(p->priority); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -21986,10 +22438,14 @@ static const u16 TemporalGroup_Out2All[] = { 2, 6, 7, 8}; static u32 TemporalGroup_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -22091,7 +22547,7 @@ static s32 TemporalGroup_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 7; if (!strcmp("activeChild", name)) return 8; return -1; - } +} static Bool TemporalGroup_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22141,10 +22597,14 @@ static const u16 ServerCommand_Out2All[] = { 1, 2, 3}; static u32 ServerCommand_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -22207,7 +22667,7 @@ static s32 ServerCommand_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("command", name)) return 3; return -1; - } +} static Bool ServerCommand_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22249,10 +22709,14 @@ static const u16 InputSensor_Out2All[] = { 0, 1, 2, 3}; static u32 InputSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -22314,7 +22778,7 @@ static s32 InputSensor_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("eventTime", name)) return 3; return -1; - } +} static Bool InputSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22331,7 +22795,7 @@ GF_Node *InputSensor_Create() GF_SAFEALLOC(p, M_InputSensor); if(!p) return NULL; gf_node_setup((GF_Node *)p, TAG_MPEG4_InputSensor); - p->buffer.commandList = gf_list_new(); + p->buffer.commandList = gf_list_new(); /*default field values*/ p->enabled = 1; @@ -22346,9 +22810,9 @@ GF_Node *InputSensor_Create() static void MatteTexture_Del(GF_Node *node) { M_MatteTexture *p = (M_MatteTexture *) node; - gf_node_unregister((GF_Node *) p->surfaceA, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->surfaceB, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->alphaSurface, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->surfaceA, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->surfaceB, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->alphaSurface, (GF_Node *) p); gf_sg_sfstring_del(p->operation); gf_sg_mffloat_del(p->parameter); gf_node_free((GF_Node *) p); @@ -22361,10 +22825,14 @@ static const u16 MatteTexture_Out2All[] = { 3, 5, 6}; static u32 MatteTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -22450,7 +22918,7 @@ static s32 MatteTexture_get_field_index_by_name(char *name) if (!strcmp("fraction", name)) return 5; if (!strcmp("parameter", name)) return 6; return -1; - } +} static Bool MatteTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22495,10 +22963,14 @@ static const u16 MediaBuffer_Out2All[] = { 0, 1, 2, 3, 4, 5}; static u32 MediaBuffer_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -22574,7 +23046,7 @@ static s32 MediaBuffer_get_field_index_by_name(char *name) if (!strcmp("isBuffered", name)) return 4; if (!strcmp("enabled", name)) return 5; return -1; - } +} static Bool MediaBuffer_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22619,10 +23091,14 @@ static const u16 MediaControl_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; static u32 MediaControl_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -22719,7 +23195,7 @@ static s32 MediaControl_get_field_index_by_name(char *name) if (!strcmp("enabled", name)) return 7; if (!strcmp("isPreRolled", name)) return 8; return -1; - } +} static Bool MediaControl_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22766,10 +23242,14 @@ static const u16 MediaSensor_Out2All[] = { 0, 1, 2, 3, 4, 5}; static u32 MediaSensor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -22845,7 +23325,7 @@ static s32 MediaSensor_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 4; if (!strcmp("info", name)) return 5; return -1; - } +} static Bool MediaSensor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22875,7 +23355,7 @@ GF_Node *MediaSensor_Create() static void BitWrapper_Del(GF_Node *node) { M_BitWrapper *p = (M_BitWrapper *) node; - gf_node_unregister((GF_Node *) p->node, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->node, (GF_Node *) p); gf_sg_mfurl_del(p->url); gf_sg_sfstring_del(p->buffer); gf_node_free((GF_Node *) p); @@ -22886,10 +23366,14 @@ static const u16 BitWrapper_Def2All[] = { 0, 1, 2, 3}; static u32 BitWrapper_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -22946,7 +23430,7 @@ static s32 BitWrapper_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("buffer", name)) return 3; return -1; - } +} static Bool BitWrapper_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -22990,10 +23474,14 @@ static const u16 CoordinateInterpolator4D_Out2All[] = { 1, 2, 3}; static u32 CoordinateInterpolator4D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -23056,7 +23544,7 @@ static s32 CoordinateInterpolator4D_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool CoordinateInterpolator4D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23098,7 +23586,7 @@ GF_Node *CoordinateInterpolator4D_Create() static void DepthImage_Del(GF_Node *node) { M_DepthImage *p = (M_DepthImage *) node; - gf_node_unregister((GF_Node *) p->diTexture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->diTexture, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -23107,10 +23595,14 @@ static const u16 DepthImage_Def2All[] = { 0, 1, 2, 3, 4, 5, 6}; static u32 DepthImage_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -23188,7 +23680,7 @@ static s32 DepthImage_get_field_index_by_name(char *name) if (!strcmp("orthographic", name)) return 5; if (!strcmp("position", name)) return 6; return -1; - } +} static Bool DepthImage_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23234,7 +23726,7 @@ static void FFD_Del(GF_Node *node) gf_sg_mffloat_del(p->uKnot); gf_sg_mffloat_del(p->vKnot); gf_sg_mffloat_del(p->wKnot); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -23246,10 +23738,14 @@ static const u16 FFD_Dyn2All[] = { 3}; static u32 FFD_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 11; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 11; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 13; } @@ -23382,7 +23878,7 @@ static s32 FFD_get_field_index_by_name(char *name) if (!strcmp("wKnot", name)) return 11; if (!strcmp("wOrder", name)) return 12; return -1; - } +} static Bool FFD_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23480,10 +23976,14 @@ static const u16 Implicit_Dyn2All[] = { 0, 1}; static u32 Implicit_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 5; } @@ -23555,7 +24055,7 @@ static s32 Implicit_get_field_index_by_name(char *name) if (!strcmp("dual", name)) return 3; if (!strcmp("solid", name)) return 4; return -1; - } +} static Bool Implicit_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23600,10 +24100,10 @@ GF_Node *Implicit_Create() static void XXLFM_Appearance_Del(GF_Node *node) { M_XXLFM_Appearance *p = (M_XXLFM_Appearance *) node; - gf_node_unregister((GF_Node *) p->blendList, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->lightMapList); - gf_node_unregister_children((GF_Node *) p, p->tileList); - gf_node_unregister((GF_Node *) p->vertexFrameList, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->blendList, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->lightMapList); + gf_node_unregister_children((GF_Node *) p, p->tileList); + gf_node_unregister((GF_Node *) p->vertexFrameList, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -23614,10 +24114,14 @@ static const u16 XXLFM_Appearance_Out2All[] = { 0, 1, 2, 3}; static u32 XXLFM_Appearance_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -23683,7 +24187,7 @@ static s32 XXLFM_Appearance_get_field_index_by_name(char *name) if (!strcmp("tileList", name)) return 2; if (!strcmp("vertexFrameList", name)) return 3; return -1; - } +} static Bool XXLFM_Appearance_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23725,10 +24229,14 @@ static const u16 XXLFM_BlendList_Out2All[] = { 0, 1}; static u32 XXLFM_BlendList_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -23776,7 +24284,7 @@ static s32 XXLFM_BlendList_get_field_index_by_name(char *name) if (!strcmp("blendMode", name)) return 0; if (!strcmp("lightMapIndex", name)) return 1; return -1; - } +} static Bool XXLFM_BlendList_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23829,10 +24337,14 @@ static const u16 XXLFM_FrameList_Out2All[] = { 0, 1}; static u32 XXLFM_FrameList_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -23880,7 +24392,7 @@ static s32 XXLFM_FrameList_get_field_index_by_name(char *name) if (!strcmp("index", name)) return 0; if (!strcmp("frame", name)) return 1; return -1; - } +} static Bool XXLFM_FrameList_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -23934,8 +24446,8 @@ GF_Node *XXLFM_FrameList_Create() static void XXLFM_LightMap_Del(GF_Node *node) { M_XXLFM_LightMap *p = (M_XXLFM_LightMap *) node; - gf_node_unregister((GF_Node *) p->surfaceMapList, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->viewMapList, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->surfaceMapList, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->viewMapList, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -23946,10 +24458,14 @@ static const u16 XXLFM_LightMap_Out2All[] = { 0, 1, 2, 3, 4}; static u32 XXLFM_LightMap_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -24020,7 +24536,7 @@ static s32 XXLFM_LightMap_get_field_index_by_name(char *name) if (!strcmp("surfaceMapList", name)) return 3; if (!strcmp("viewMapList", name)) return 4; return -1; - } +} static Bool XXLFM_LightMap_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24077,7 +24593,7 @@ static void XXLFM_SurfaceMapList_Del(GF_Node *node) { M_XXLFM_SurfaceMapList *p = (M_XXLFM_SurfaceMapList *) node; gf_sg_mfint32_del(p->tileIndex); - gf_node_unregister((GF_Node *) p->triangleCoordinate, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->triangleCoordinate, (GF_Node *) p); gf_sg_mfint32_del(p->triangleIndex); gf_sg_mfint32_del(p->viewMapIndex); gf_node_free((GF_Node *) p); @@ -24090,10 +24606,14 @@ static const u16 XXLFM_SurfaceMapList_Out2All[] = { 0, 1, 2, 3}; static u32 XXLFM_SurfaceMapList_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -24156,7 +24676,7 @@ static s32 XXLFM_SurfaceMapList_get_field_index_by_name(char *name) if (!strcmp("triangleIndex", name)) return 2; if (!strcmp("viewMapIndex", name)) return 3; return -1; - } +} static Bool XXLFM_SurfaceMapList_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24198,8 +24718,8 @@ GF_Node *XXLFM_SurfaceMapList_Create() static void XXLFM_ViewMapList_Del(GF_Node *node) { M_XXLFM_ViewMapList *p = (M_XXLFM_ViewMapList *) node; - gf_node_unregister((GF_Node *) p->textureOrigin, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->textureSize, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->textureOrigin, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->textureSize, (GF_Node *) p); gf_sg_mfint32_del(p->tileIndex); gf_sg_mfint32_del(p->vertexIndex); gf_node_free((GF_Node *) p); @@ -24212,10 +24732,14 @@ static const u16 XXLFM_ViewMapList_Out2All[] = { 0, 1, 2, 3}; static u32 XXLFM_ViewMapList_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -24279,7 +24803,7 @@ static s32 XXLFM_ViewMapList_get_field_index_by_name(char *name) if (!strcmp("tileIndex", name)) return 2; if (!strcmp("vertexIndex", name)) return 3; return -1; - } +} static Bool XXLFM_ViewMapList_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24321,13 +24845,13 @@ static void MeshGrid_Del(GF_Node *node) gf_sg_mfint32_del(p->set_coordIndex); gf_sg_mfint32_del(p->set_normalIndex); gf_sg_mfint32_del(p->set_texCoordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->gridCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->gridCoord, (GF_Node *) p); gf_sg_mfint32_del(p->nLevels); - gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); gf_sg_mfint32_del(p->nSlices); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); gf_sg_mffloat_del(p->vertexOffset); gf_sg_mfint32_del(p->vertexLink); gf_sg_mfint32_del(p->colorIndex); @@ -24346,10 +24870,14 @@ static const u16 MeshGrid_Dyn2All[] = { 6, 7, 9, 10, 12, 14}; static u32 MeshGrid_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 16; - case GF_SG_FIELD_CODING_DEF: return 17; - case GF_SG_FIELD_CODING_OUT: return 14; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 16; + case GF_SG_FIELD_CODING_DEF: + return 17; + case GF_SG_FIELD_CODING_OUT: + return 14; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 23; } @@ -24556,7 +25084,7 @@ static s32 MeshGrid_get_field_index_by_name(char *name) if (!strcmp("isLoading", name)) return 21; if (!strcmp("nVertices", name)) return 22; return -1; - } +} static Bool MeshGrid_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24657,7 +25185,7 @@ static void NonLinearDeformer_Del(GF_Node *node) { M_NonLinearDeformer *p = (M_NonLinearDeformer *) node; gf_sg_mffloat_del(p->extend); - gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -24668,10 +25196,14 @@ static const u16 NonLinearDeformer_Out2All[] = { 0, 1, 2, 3, 4}; static u32 NonLinearDeformer_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -24741,7 +25273,7 @@ static s32 NonLinearDeformer_get_field_index_by_name(char *name) if (!strcmp("param", name)) return 3; if (!strcmp("type", name)) return 4; return -1; - } +} static Bool NonLinearDeformer_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24777,7 +25309,7 @@ static void NurbsCurve_Del(GF_Node *node) { M_NurbsCurve *p = (M_NurbsCurve *) node; gf_sg_mfint32_del(p->set_colorIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); gf_sg_mfvec4f_del(p->controlPoint); gf_sg_mfint32_del(p->colorIndex); gf_sg_mffloat_del(p->knot); @@ -24792,10 +25324,14 @@ static const u16 NurbsCurve_Dyn2All[] = { 2}; static u32 NurbsCurve_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 8; } @@ -24890,7 +25426,7 @@ static s32 NurbsCurve_get_field_index_by_name(char *name) if (!strcmp("knot", name)) return 6; if (!strcmp("order", name)) return 7; return -1; - } +} static Bool NurbsCurve_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -24941,7 +25477,7 @@ static void NurbsCurve2D_Del(GF_Node *node) { M_NurbsCurve2D *p = (M_NurbsCurve2D *) node; gf_sg_mfint32_del(p->set_colorIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); gf_sg_mfvec3f_del(p->controlPoint); gf_sg_mfint32_del(p->colorIndex); gf_sg_mffloat_del(p->knot); @@ -24956,10 +25492,14 @@ static const u16 NurbsCurve2D_Dyn2All[] = { 2}; static u32 NurbsCurve2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 8; } @@ -25054,7 +25594,7 @@ static s32 NurbsCurve2D_get_field_index_by_name(char *name) if (!strcmp("knot", name)) return 6; if (!strcmp("order", name)) return 7; return -1; - } +} static Bool NurbsCurve2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -25106,9 +25646,9 @@ static void NurbsSurface_Del(GF_Node *node) M_NurbsSurface *p = (M_NurbsSurface *) node; gf_sg_mfint32_del(p->set_colorIndex); gf_sg_mfint32_del(p->set_texColorIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); gf_sg_mfvec4f_del(p->controlPoint); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->texColorIndex); gf_sg_mffloat_del(p->uKnot); @@ -25124,10 +25664,14 @@ static const u16 NurbsSurface_Dyn2All[] = { 3}; static u32 NurbsSurface_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 16; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 16; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 18; } @@ -25294,7 +25838,7 @@ static s32 NurbsSurface_get_field_index_by_name(char *name) if (!strcmp("vKnot", name)) return 16; if (!strcmp("vOrder", name)) return 17; return -1; - } +} static Bool NurbsSurface_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -25375,7 +25919,7 @@ GF_Node *NurbsSurface_Create() static void OctreeImage_Del(GF_Node *node) { M_OctreeImage *p = (M_OctreeImage *) node; - gf_node_unregister_children((GF_Node *) p, p->images); + gf_node_unregister_children((GF_Node *) p, p->images); gf_sg_mfint32_del(p->octree); gf_sg_mfint32_del(p->voxelImageIndex); gf_node_free((GF_Node *) p); @@ -25386,10 +25930,14 @@ static const u16 OctreeImage_Def2All[] = { 0, 1, 2, 3}; static u32 OctreeImage_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -25446,7 +25994,7 @@ static s32 OctreeImage_get_field_index_by_name(char *name) if (!strcmp("octreeResolution", name)) return 2; if (!strcmp("voxelImageIndex", name)) return 3; return -1; - } +} static Bool OctreeImage_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -25491,9 +26039,9 @@ GF_Node *OctreeImage_Create() static void XXParticles_Del(GF_Node *node) { M_XXParticles *p = (M_XXParticles *) node; - gf_node_unregister_children((GF_Node *) p, p->influences); - gf_node_unregister((GF_Node *) p->init, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->primitive, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->influences); + gf_node_unregister((GF_Node *) p->init, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->primitive, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -25504,10 +26052,14 @@ static const u16 XXParticles_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, static u32 XXParticles_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 25; - case GF_SG_FIELD_CODING_DEF: return 25; - case GF_SG_FIELD_CODING_OUT: return 25; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 25; + case GF_SG_FIELD_CODING_DEF: + return 25; + case GF_SG_FIELD_CODING_OUT: + return 25; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 25; } @@ -25719,7 +26271,7 @@ static s32 XXParticles_get_field_index_by_name(char *name) if (!strcmp("particleRadiusRate", name)) return 23; if (!strcmp("particleRadiusVariation", name)) return 24; return -1; - } +} static Bool XXParticles_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -25795,10 +26347,14 @@ static const u16 XXParticleInitBox_Out2All[] = { 0, 1}; static u32 XXParticleInitBox_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -25846,7 +26402,7 @@ static s32 XXParticleInitBox_get_field_index_by_name(char *name) if (!strcmp("falloff", name)) return 0; if (!strcmp("size", name)) return 1; return -1; - } +} static Bool XXParticleInitBox_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -25890,10 +26446,14 @@ static const u16 XXPlanarObstacle_Out2All[] = { 0, 1, 2, 3}; static u32 XXPlanarObstacle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -25955,7 +26515,7 @@ static s32 XXPlanarObstacle_get_field_index_by_name(char *name) if (!strcmp("reflection", name)) return 2; if (!strcmp("absorption", name)) return 3; return -1; - } +} static Bool XXPlanarObstacle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26003,10 +26563,14 @@ static const u16 XXPointAttractor_Out2All[] = { 0, 1, 2, 3}; static u32 XXPointAttractor_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -26068,7 +26632,7 @@ static s32 XXPointAttractor_get_field_index_by_name(char *name) if (!strcmp("position", name)) return 2; if (!strcmp("rate", name)) return 3; return -1; - } +} static Bool XXPointAttractor_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26114,10 +26678,14 @@ static const u16 PointTexture_Def2All[] = { 0, 1, 2, 3, 4}; static u32 PointTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -26180,7 +26748,7 @@ static s32 PointTexture_get_field_index_by_name(char *name) if (!strcmp("height", name)) return 3; if (!strcmp("width", name)) return 4; return -1; - } +} static Bool PointTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26235,10 +26803,14 @@ static const u16 PositionAnimator_Out2All[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1 static u32 PositionAnimator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 10; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 12; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 10; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 12; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 13; } @@ -26364,7 +26936,7 @@ static s32 PositionAnimator_get_field_index_by_name(char *name) if (!strcmp("rotation_changed", name)) return 11; if (!strcmp("value_changed", name)) return 12; return -1; - } +} static Bool PositionAnimator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26443,10 +27015,14 @@ static const u16 PositionAnimator2D_Out2All[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, static u32 PositionAnimator2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 10; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 12; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 10; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 12; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 13; } @@ -26572,7 +27148,7 @@ static s32 PositionAnimator2D_get_field_index_by_name(char *name) if (!strcmp("rotation_changed", name)) return 11; if (!strcmp("value_changed", name)) return 12; return -1; - } +} static Bool PositionAnimator2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26649,10 +27225,14 @@ static const u16 PositionInterpolator4D_Out2All[] = { 1, 2, 3}; static u32 PositionInterpolator4D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -26715,7 +27295,7 @@ static s32 PositionInterpolator4D_get_field_index_by_name(char *name) if (!strcmp("keyValue", name)) return 2; if (!strcmp("value_changed", name)) return 3; return -1; - } +} static Bool PositionInterpolator4D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -26775,10 +27355,14 @@ static const u16 ProceduralTexture_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1 static u32 ProceduralTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 19; - case GF_SG_FIELD_CODING_DEF: return 19; - case GF_SG_FIELD_CODING_OUT: return 20; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 19; + case GF_SG_FIELD_CODING_DEF: + return 19; + case GF_SG_FIELD_CODING_OUT: + return 20; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 20; } @@ -26952,7 +27536,7 @@ static s32 ProceduralTexture_get_field_index_by_name(char *name) if (!strcmp("width", name)) return 18; if (!strcmp("image_changed", name)) return 19; return -1; - } +} static Bool ProceduralTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -27141,10 +27725,14 @@ static const u16 Quadric_Dyn2All[] = { 0, 3, 4, 5, 6, 7, 8}; static u32 Quadric_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 10; - case GF_SG_FIELD_CODING_DEF: return 10; - case GF_SG_FIELD_CODING_OUT: return 10; - case GF_SG_FIELD_CODING_DYN: return 7; + case GF_SG_FIELD_CODING_IN: + return 10; + case GF_SG_FIELD_CODING_DEF: + return 10; + case GF_SG_FIELD_CODING_OUT: + return 10; + case GF_SG_FIELD_CODING_DYN: + return 7; default: return 10; } @@ -27251,7 +27839,7 @@ static s32 Quadric_get_field_index_by_name(char *name) if (!strcmp("P5", name)) return 8; if (!strcmp("solid", name)) return 9; return -1; - } +} static Bool Quadric_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -27361,7 +27949,7 @@ static void SBBone_Del(GF_Node *node) gf_sg_mffloat_del(p->sectionPosition); gf_sg_mfint32_del(p->skinCoordIndex); gf_sg_mffloat_del(p->skinCoordWeight); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -27373,10 +27961,14 @@ static const u16 SBBone_Dyn2All[] = { 3, 5, 14, 16, 17, 23}; static u32 SBBone_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 24; - case GF_SG_FIELD_CODING_DEF: return 22; - case GF_SG_FIELD_CODING_OUT: return 22; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 24; + case GF_SG_FIELD_CODING_DEF: + return 22; + case GF_SG_FIELD_CODING_OUT: + return 22; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 24; } @@ -27586,7 +28178,7 @@ static s32 SBBone_get_field_index_by_name(char *name) if (!strcmp("skinCoordWeight", name)) return 22; if (!strcmp("translation", name)) return 23; return -1; - } +} static Bool SBBone_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -27697,7 +28289,7 @@ GF_Node *SBBone_Create() static void SBMuscle_Del(GF_Node *node) { M_SBMuscle *p = (M_SBMuscle *) node; - gf_node_unregister((GF_Node *) p->muscleCurve, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->muscleCurve, (GF_Node *) p); gf_sg_mfint32_del(p->skinCoordIndex); gf_sg_mffloat_del(p->skinCoordWeight); gf_node_free((GF_Node *) p); @@ -27711,10 +28303,14 @@ static const u16 SBMuscle_Dyn2All[] = { 3}; static u32 SBMuscle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 6; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 6; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 6; } @@ -27794,7 +28390,7 @@ static s32 SBMuscle_get_field_index_by_name(char *name) if (!strcmp("skinCoordIndex", name)) return 4; if (!strcmp("skinCoordWeight", name)) return 5; return -1; - } +} static Bool SBMuscle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -27853,7 +28449,7 @@ static void SBSegment_Del(GF_Node *node) M_SBSegment *p = (M_SBSegment *) node; gf_sg_mfvec3f_del(p->momentsOfInertia); gf_sg_sfstring_del(p->name); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -27865,10 +28461,14 @@ static const u16 SBSegment_Dyn2All[] = { 2}; static u32 SBSegment_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 7; } @@ -27959,7 +28559,7 @@ static s32 SBSegment_get_field_index_by_name(char *name) if (!strcmp("momentsOfInertia", name)) return 5; if (!strcmp("name", name)) return 6; return -1; - } +} static Bool SBSegment_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28010,7 +28610,7 @@ static void SBSite_Del(GF_Node *node) { M_SBSite *p = (M_SBSite *) node; gf_sg_sfstring_del(p->name); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -28022,10 +28622,14 @@ static const u16 SBSite_Dyn2All[] = { 2, 5, 6, 7, 8}; static u32 SBSite_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 9; } @@ -28130,7 +28734,7 @@ static s32 SBSite_get_field_index_by_name(char *name) if (!strcmp("scaleOrientation", name)) return 7; if (!strcmp("translation", name)) return 8; return -1; - } +} static Bool SBSite_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28198,16 +28802,16 @@ GF_Node *SBSite_Create() static void SBSkinnedModel_Del(GF_Node *node) { M_SBSkinnedModel *p = (M_SBSkinnedModel *) node; - gf_node_unregister_children((GF_Node *) p, p->bones); - gf_node_unregister_children((GF_Node *) p, p->muscles); + gf_node_unregister_children((GF_Node *) p, p->bones); + gf_node_unregister_children((GF_Node *) p, p->muscles); gf_sg_sfstring_del(p->name); - gf_node_unregister_children((GF_Node *) p, p->segments); - gf_node_unregister_children((GF_Node *) p, p->sites); - gf_node_unregister_children((GF_Node *) p, p->skeleton); - gf_node_unregister_children((GF_Node *) p, p->skin); - gf_node_unregister((GF_Node *) p->skinCoord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->skinNormal, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->weighsComputationSkinCoord, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->segments); + gf_node_unregister_children((GF_Node *) p, p->sites); + gf_node_unregister_children((GF_Node *) p, p->skeleton); + gf_node_unregister_children((GF_Node *) p, p->skin); + gf_node_unregister((GF_Node *) p->skinCoord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->skinNormal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->weighsComputationSkinCoord, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -28219,10 +28823,14 @@ static const u16 SBSkinnedModel_Dyn2All[] = { 1, 4, 6, 7, 13}; static u32 SBSkinnedModel_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 15; - case GF_SG_FIELD_CODING_DEF: return 15; - case GF_SG_FIELD_CODING_OUT: return 15; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 15; + case GF_SG_FIELD_CODING_DEF: + return 15; + case GF_SG_FIELD_CODING_OUT: + return 15; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 15; } @@ -28373,7 +28981,7 @@ static s32 SBSkinnedModel_get_field_index_by_name(char *name) if (!strcmp("translation", name)) return 13; if (!strcmp("weighsComputationSkinCoord", name)) return 14; return -1; - } +} static Bool SBSkinnedModel_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28441,7 +29049,7 @@ static void SBVCAnimation_Del(GF_Node *node) { M_SBVCAnimation *p = (M_SBVCAnimation *) node; gf_sg_mfurl_del(p->url); - gf_node_unregister_children((GF_Node *) p, p->virtualCharacters); + gf_node_unregister_children((GF_Node *) p, p->virtualCharacters); gf_node_free((GF_Node *) p); } @@ -28452,10 +29060,14 @@ static const u16 SBVCAnimation_Out2All[] = { 0, 1}; static u32 SBVCAnimation_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -28504,7 +29116,7 @@ static s32 SBVCAnimation_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 0; if (!strcmp("virtualCharacters", name)) return 1; return -1; - } +} static Bool SBVCAnimation_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28548,10 +29160,14 @@ static const u16 ScalarAnimator_Out2All[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; static u32 ScalarAnimator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 10; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 10; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 11; } @@ -28663,7 +29279,7 @@ static s32 ScalarAnimator_get_field_index_by_name(char *name) if (!strcmp("endValue", name)) return 9; if (!strcmp("value_changed", name)) return 10; return -1; - } +} static Bool ScalarAnimator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28720,8 +29336,8 @@ GF_Node *ScalarAnimator_Create() static void SimpleTexture_Del(GF_Node *node) { M_SimpleTexture *p = (M_SimpleTexture *) node; - gf_node_unregister((GF_Node *) p->depth, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->depth, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -28730,10 +29346,14 @@ static const u16 SimpleTexture_Def2All[] = { 0, 1}; static u32 SimpleTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -28777,7 +29397,7 @@ static s32 SimpleTexture_get_field_index_by_name(char *name) if (!strcmp("depth", name)) return 0; if (!strcmp("texture", name)) return 1; return -1; - } +} static Bool SimpleTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28808,7 +29428,7 @@ static void SolidRep_Del(GF_Node *node) { M_SolidRep *p = (M_SolidRep *) node; gf_sg_mfint32_del(p->densityList); - gf_node_unregister((GF_Node *) p->solidTree, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->solidTree, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -28820,10 +29440,14 @@ static const u16 SolidRep_Dyn2All[] = { 0}; static u32 SolidRep_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 3; } @@ -28882,7 +29506,7 @@ static s32 SolidRep_get_field_index_by_name(char *name) if (!strcmp("densityList", name)) return 1; if (!strcmp("solidTree", name)) return 2; return -1; - } +} static Bool SolidRep_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -28928,10 +29552,10 @@ static void SubdivisionSurface_Del(GF_Node *node) gf_sg_mfint32_del(p->set_creaseVertexIndex); gf_sg_mfint32_del(p->set_dartVertexIndex); gf_sg_mfint32_del(p->set_texCoordIndex); - gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->sectors); + gf_node_unregister((GF_Node *) p->color, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->coord, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texCoord, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->sectors); gf_sg_mfint32_del(p->invisibleEdgeIndex); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); @@ -28950,10 +29574,14 @@ static const u16 SubdivisionSurface_Out2All[] = { 7, 8, 9, 10, 11, 12, 13}; static u32 SubdivisionSurface_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 14; - case GF_SG_FIELD_CODING_DEF: return 19; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 14; + case GF_SG_FIELD_CODING_DEF: + return 19; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 26; } @@ -29180,7 +29808,7 @@ static s32 SubdivisionSurface_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 24; if (!strcmp("texCoordIndex", name)) return 25; return -1; - } +} static Bool SubdivisionSurface_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -29241,10 +29869,14 @@ static const u16 SubdivSurfaceSector_Out2All[] = { 0, 1, 2, 3, 4}; static u32 SubdivSurfaceSector_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -29327,7 +29959,7 @@ static s32 SubdivSurfaceSector_get_field_index_by_name(char *name) if (!strcmp("faceIndex", name)) return 5; if (!strcmp("vertexIndex", name)) return 6; return -1; - } +} static Bool SubdivSurfaceSector_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -29403,7 +30035,7 @@ GF_Node *SubdivSurfaceSector_Create() static void WaveletSubdivisionSurface_Del(GF_Node *node) { M_WaveletSubdivisionSurface *p = (M_WaveletSubdivisionSurface *) node; - gf_node_unregister((GF_Node *) p->baseMesh, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->baseMesh, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -29414,10 +30046,14 @@ static const u16 WaveletSubdivisionSurface_Out2All[] = { 0, 1, 2, 3}; static u32 WaveletSubdivisionSurface_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -29480,7 +30116,7 @@ static s32 WaveletSubdivisionSurface_get_field_index_by_name(char *name) if (!strcmp("frequency", name)) return 2; if (!strcmp("quality", name)) return 3; return -1; - } +} static Bool WaveletSubdivisionSurface_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -29513,9 +30149,9 @@ GF_Node *WaveletSubdivisionSurface_Create() static void Clipper2D_Del(GF_Node *node) { M_Clipper2D *p = (M_Clipper2D *) node; - gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -29526,10 +30162,14 @@ static const u16 Clipper2D_Out2All[] = { 2, 3, 4, 5, 6}; static u32 Clipper2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -29619,7 +30259,7 @@ static s32 Clipper2D_get_field_index_by_name(char *name) if (!strcmp("transform", name)) return 5; if (!strcmp("XOR", name)) return 6; return -1; - } +} static Bool Clipper2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -29651,7 +30291,7 @@ GF_Node *Clipper2D_Create() static void ColorTransform_Del(GF_Node *node) { M_ColorTransform *p = (M_ColorTransform *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -29663,10 +30303,14 @@ static const u16 ColorTransform_Dyn2All[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1 static u32 ColorTransform_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 23; - case GF_SG_FIELD_CODING_DEF: return 21; - case GF_SG_FIELD_CODING_OUT: return 21; - case GF_SG_FIELD_CODING_DYN: return 20; + case GF_SG_FIELD_CODING_IN: + return 23; + case GF_SG_FIELD_CODING_DEF: + return 21; + case GF_SG_FIELD_CODING_OUT: + return 21; + case GF_SG_FIELD_CODING_DYN: + return 20; default: return 23; } @@ -29869,7 +30513,7 @@ static s32 ColorTransform_get_field_index_by_name(char *name) if (!strcmp("maa", name)) return 21; if (!strcmp("ta", name)) return 22; return -1; - } +} static Bool ColorTransform_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30051,10 +30695,14 @@ static const u16 Ellipse_Dyn2All[] = { 0}; static u32 Ellipse_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 1; } @@ -30098,7 +30746,7 @@ static s32 Ellipse_get_field_index_by_name(char *name) { if (!strcmp("radius", name)) return 0; return -1; - } +} static Bool Ellipse_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30139,7 +30787,7 @@ static void LinearGradient_Del(GF_Node *node) gf_sg_mffloat_del(p->key); gf_sg_mfcolor_del(p->keyValue); gf_sg_mffloat_del(p->opacity); - gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -30151,10 +30799,14 @@ static const u16 LinearGradient_Dyn2All[] = { 0, 5}; static u32 LinearGradient_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 7; } @@ -30241,7 +30893,7 @@ static s32 LinearGradient_get_field_index_by_name(char *name) if (!strcmp("startPoint", name)) return 5; if (!strcmp("transform", name)) return 6; return -1; - } +} static Bool LinearGradient_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30316,9 +30968,9 @@ GF_Node *LinearGradient_Create() static void PathLayout_Del(GF_Node *node) { M_PathLayout *p = (M_PathLayout *) node; - gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); gf_sg_mfint32_del(p->alignment); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -30330,10 +30982,14 @@ static const u16 PathLayout_Dyn2All[] = { 5, 6}; static u32 PathLayout_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 10; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 10; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 10; } @@ -30446,7 +31102,7 @@ static s32 PathLayout_get_field_index_by_name(char *name) if (!strcmp("wrapMode", name)) return 8; if (!strcmp("splitText", name)) return 9; return -1; - } +} static Bool PathLayout_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30513,7 +31169,7 @@ static void RadialGradient_Del(GF_Node *node) gf_sg_mffloat_del(p->key); gf_sg_mfcolor_del(p->keyValue); gf_sg_mffloat_del(p->opacity); - gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->transform, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -30525,10 +31181,14 @@ static const u16 RadialGradient_Dyn2All[] = { 0, 1, 5}; static u32 RadialGradient_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 8; } @@ -30622,7 +31282,7 @@ static s32 RadialGradient_get_field_index_by_name(char *name) if (!strcmp("spreadMethod", name)) return 6; if (!strcmp("transform", name)) return 7; return -1; - } +} static Bool RadialGradient_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30718,10 +31378,14 @@ static const u16 SynthesizedTexture_Dyn2All[] = { 0, 1, 5}; static u32 SynthesizedTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 9; - case GF_SG_FIELD_CODING_OUT: return 11; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 9; + case GF_SG_FIELD_CODING_OUT: + return 11; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 11; } @@ -30835,7 +31499,7 @@ static s32 SynthesizedTexture_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 9; if (!strcmp("isActive", name)) return 10; return -1; - } +} static Bool SynthesizedTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -30902,7 +31566,7 @@ GF_Node *SynthesizedTexture_Create() static void TransformMatrix2D_Del(GF_Node *node) { M_TransformMatrix2D *p = (M_TransformMatrix2D *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -30914,10 +31578,14 @@ static const u16 TransformMatrix2D_Dyn2All[] = { 3, 4, 5, 6, 7, 8}; static u32 TransformMatrix2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 6; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 6; default: return 9; } @@ -31022,7 +31690,7 @@ static s32 TransformMatrix2D_get_field_index_by_name(char *name) if (!strcmp("myy", name)) return 7; if (!strcmp("ty", name)) return 8; return -1; - } +} static Bool TransformMatrix2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -31108,10 +31776,14 @@ static const u16 Viewport_Dyn2All[] = { 1, 2, 3}; static u32 Viewport_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 6; - case GF_SG_FIELD_CODING_DEF: return 6; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 6; + case GF_SG_FIELD_CODING_DEF: + return 6; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 9; } @@ -31212,7 +31884,7 @@ static s32 Viewport_get_field_index_by_name(char *name) if (!strcmp("bindTime", name)) return 7; if (!strcmp("isBound", name)) return 8; return -1; - } +} static Bool Viewport_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -31283,7 +31955,7 @@ GF_Node *Viewport_Create() static void XCurve2D_Del(GF_Node *node) { M_XCurve2D *p = (M_XCurve2D *) node; - gf_node_unregister((GF_Node *) p->point, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->point, (GF_Node *) p); gf_sg_mfint32_del(p->type); gf_node_free((GF_Node *) p); } @@ -31296,10 +31968,14 @@ static const u16 XCurve2D_Dyn2All[] = { 1}; static u32 XCurve2D_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 3; - case GF_SG_FIELD_CODING_OUT: return 3; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 3; + case GF_SG_FIELD_CODING_OUT: + return 3; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 3; } @@ -31358,7 +32034,7 @@ static s32 XCurve2D_get_field_index_by_name(char *name) if (!strcmp("fineness", name)) return 1; if (!strcmp("type", name)) return 2; return -1; - } +} static Bool XCurve2D_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -31421,10 +32097,14 @@ static const u16 XFontStyle_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, static u32 XFontStyle_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 17; - case GF_SG_FIELD_CODING_DEF: return 17; - case GF_SG_FIELD_CODING_OUT: return 17; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 17; + case GF_SG_FIELD_CODING_DEF: + return 17; + case GF_SG_FIELD_CODING_OUT: + return 17; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 17; } @@ -31577,7 +32257,7 @@ static s32 XFontStyle_get_field_index_by_name(char *name) if (!strcmp("featureLength", name)) return 15; if (!strcmp("featureValue", name)) return 16; return -1; - } +} static Bool XFontStyle_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -31646,8 +32326,8 @@ static void XLineProperties_Del(GF_Node *node) { M_XLineProperties *p = (M_XLineProperties *) node; gf_sg_mffloat_del(p->dashes); - gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->textureTransform, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->textureTransform, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -31659,10 +32339,14 @@ static const u16 XLineProperties_Dyn2All[] = { 0, 7, 8, 9, 10}; static u32 XLineProperties_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 13; - case GF_SG_FIELD_CODING_DEF: return 13; - case GF_SG_FIELD_CODING_OUT: return 13; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 13; + case GF_SG_FIELD_CODING_DEF: + return 13; + case GF_SG_FIELD_CODING_OUT: + return 13; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 13; } @@ -31792,7 +32476,7 @@ static s32 XLineProperties_get_field_index_by_name(char *name) if (!strcmp("texture", name)) return 11; if (!strcmp("textureTransform", name)) return 12; return -1; - } +} static Bool XLineProperties_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -31892,7 +32576,7 @@ static void AdvancedAudioBuffer_Del(GF_Node *node) { M_AdvancedAudioBuffer *p = (M_AdvancedAudioBuffer *) node; gf_sg_mfint32_del(p->phaseGroup); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -31904,10 +32588,14 @@ static const u16 AdvancedAudioBuffer_Dyn2All[] = { 4}; static u32 AdvancedAudioBuffer_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 14; - case GF_SG_FIELD_CODING_DEF: return 14; - case GF_SG_FIELD_CODING_OUT: return 14; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 14; + case GF_SG_FIELD_CODING_DEF: + return 14; + case GF_SG_FIELD_CODING_OUT: + return 14; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 18; } @@ -32075,7 +32763,7 @@ static s32 AdvancedAudioBuffer_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 16; if (!strcmp("isActive", name)) return 17; return -1; - } +} static Bool AdvancedAudioBuffer_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -32202,7 +32890,7 @@ static void AudioChannelConfig_Del(GF_Node *node) gf_sg_mfint32_del(p->ambComponentIndex); gf_sg_mffloat_del(p->ambBackwardMatrix); gf_sg_mfint32_del(p->ambSoundfieldResolution); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -32213,10 +32901,14 @@ static const u16 AudioChannelConfig_Out2All[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 static u32 AudioChannelConfig_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 21; - case GF_SG_FIELD_CODING_DEF: return 20; - case GF_SG_FIELD_CODING_OUT: return 19; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 21; + case GF_SG_FIELD_CODING_DEF: + return 20; + case GF_SG_FIELD_CODING_OUT: + return 19; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 22; } @@ -32409,7 +33101,7 @@ static s32 AudioChannelConfig_get_field_index_by_name(char *name) if (!strcmp("ambSoundfieldResolution", name)) return 20; if (!strcmp("numChannel", name)) return 21; return -1; - } +} static Bool AudioChannelConfig_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -32543,7 +33235,7 @@ GF_Node *AudioChannelConfig_Create() static void DepthImageV2_Del(GF_Node *node) { M_DepthImageV2 *p = (M_DepthImageV2 *) node; - gf_node_unregister((GF_Node *) p->diTexture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->diTexture, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -32552,10 +33244,14 @@ static const u16 DepthImageV2_Def2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 DepthImageV2_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -32640,7 +33336,7 @@ static s32 DepthImageV2_get_field_index_by_name(char *name) if (!strcmp("position", name)) return 6; if (!strcmp("splatMinMax", name)) return 7; return -1; - } +} static Bool DepthImageV2_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -32684,8 +33380,8 @@ GF_Node *DepthImageV2_Create() static void MorphShape_Del(GF_Node *node) { M_MorphShape *p = (M_MorphShape *) node; - gf_node_unregister((GF_Node *) p->baseShape, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->targetShapes); + gf_node_unregister((GF_Node *) p->baseShape, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->targetShapes); gf_sg_mffloat_del(p->weights); gf_node_free((GF_Node *) p); } @@ -32697,10 +33393,14 @@ static const u16 MorphShape_Out2All[] = { 0, 1, 2, 3}; static u32 MorphShape_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 4; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 4; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -32764,7 +33464,7 @@ static s32 MorphShape_get_field_index_by_name(char *name) if (!strcmp("targetShapes", name)) return 2; if (!strcmp("weights", name)) return 3; return -1; - } +} static Bool MorphShape_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -32805,7 +33505,7 @@ static void MultiTexture_Del(GF_Node *node) gf_sg_mfint32_del(p->function); gf_sg_mfint32_del(p->mode); gf_sg_mfint32_del(p->source); - gf_node_unregister_children((GF_Node *) p, p->texture); + gf_node_unregister_children((GF_Node *) p, p->texture); gf_sg_mfvec3f_del(p->cameraVector); gf_node_free((GF_Node *) p); } @@ -32817,10 +33517,14 @@ static const u16 MultiTexture_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 MultiTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -32911,7 +33615,7 @@ static s32 MultiTexture_get_field_index_by_name(char *name) if (!strcmp("cameraVector", name)) return 6; if (!strcmp("transparent", name)) return 7; return -1; - } +} static Bool MultiTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -32947,7 +33651,7 @@ static void PointTextureV2_Del(GF_Node *node) M_PointTextureV2 *p = (M_PointTextureV2 *) node; gf_sg_mfcolor_del(p->color); gf_sg_mfint32_del(p->depth); - gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); gf_sg_mfvec3f_del(p->splatU); gf_sg_mfvec3f_del(p->splatV); gf_node_free((GF_Node *) p); @@ -32958,10 +33662,14 @@ static const u16 PointTextureV2_Def2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 PointTextureV2_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -33046,7 +33754,7 @@ static s32 PointTextureV2_get_field_index_by_name(char *name) if (!strcmp("splatV", name)) return 6; if (!strcmp("width", name)) return 7; return -1; - } +} static Bool PointTextureV2_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -33100,7 +33808,7 @@ static void SBVCAnimationV2_Del(GF_Node *node) M_SBVCAnimationV2 *p = (M_SBVCAnimationV2 *) node; gf_sg_mfint32_del(p->activeUrlIndex); gf_sg_mfurl_del(p->url); - gf_node_unregister_children((GF_Node *) p, p->virtualCharacters); + gf_node_unregister_children((GF_Node *) p, p->virtualCharacters); gf_node_free((GF_Node *) p); } @@ -33112,10 +33820,14 @@ static const u16 SBVCAnimationV2_Dyn2All[] = { 2, 5}; static u32 SBVCAnimationV2_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 10; - case GF_SG_FIELD_CODING_DYN: return 2; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 10; + case GF_SG_FIELD_CODING_DYN: + return 2; default: return 10; } @@ -33223,7 +33935,7 @@ static s32 SBVCAnimationV2_get_field_index_by_name(char *name) if (!strcmp("duration_changed", name)) return 8; if (!strcmp("isActive", name)) return 9; return -1; - } +} static Bool SBVCAnimationV2_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -33269,11 +33981,11 @@ GF_Node *SBVCAnimationV2_Create() static void SimpleTextureV2_Del(GF_Node *node) { M_SimpleTextureV2 *p = (M_SimpleTextureV2 *) node; - gf_node_unregister((GF_Node *) p->depth, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->splatU, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->splatV, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->depth, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->normal, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->splatU, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->splatV, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->texture, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -33282,10 +33994,14 @@ static const u16 SimpleTextureV2_Def2All[] = { 0, 1, 2, 3, 4}; static u32 SimpleTextureV2_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 5; } @@ -33353,7 +34069,7 @@ static s32 SimpleTextureV2_get_field_index_by_name(char *name) if (!strcmp("splatV", name)) return 3; if (!strcmp("texture", name)) return 4; return -1; - } +} static Bool SimpleTextureV2_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -33383,7 +34099,7 @@ GF_Node *SimpleTextureV2_Create() static void SurroundingSound_Del(GF_Node *node) { M_SurroundingSound *p = (M_SurroundingSound *) node; - gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -33395,10 +34111,14 @@ static const u16 SurroundingSound_Dyn2All[] = { 1, 3, 5}; static u32 SurroundingSound_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 7; } @@ -33485,7 +34205,7 @@ static s32 SurroundingSound_get_field_index_by_name(char *name) if (!strcmp("orientation", name)) return 5; if (!strcmp("isTransformable", name)) return 6; return -1; - } +} static Bool SurroundingSound_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -33550,7 +34270,7 @@ GF_Node *SurroundingSound_Create() static void Transform3DAudio_Del(GF_Node *node) { M_Transform3DAudio *p = (M_Transform3DAudio *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -33562,10 +34282,14 @@ static const u16 Transform3DAudio_Dyn2All[] = { 3, 4, 5, 6, 7}; static u32 Transform3DAudio_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 7; - case GF_SG_FIELD_CODING_OUT: return 7; - case GF_SG_FIELD_CODING_DYN: return 5; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 7; + case GF_SG_FIELD_CODING_OUT: + return 7; + case GF_SG_FIELD_CODING_DYN: + return 5; default: return 9; } @@ -33670,7 +34394,7 @@ static s32 Transform3DAudio_get_field_index_by_name(char *name) if (!strcmp("thirdTranslationCoordinate", name)) return 7; if (!strcmp("coordinateTransform", name)) return 8; return -1; - } +} static Bool Transform3DAudio_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -33750,8 +34474,8 @@ GF_Node *Transform3DAudio_Create() static void WideSound_Del(GF_Node *node) { M_WideSound *p = (M_WideSound *) node; - gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->perceptualParameters, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->source, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->perceptualParameters, (GF_Node *) p); gf_sg_mffloat_del(p->size); gf_node_free((GF_Node *) p); } @@ -33764,10 +34488,14 @@ static const u16 WideSound_Dyn2All[] = { 1, 2, 8}; static u32 WideSound_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 12; - case GF_SG_FIELD_CODING_DEF: return 15; - case GF_SG_FIELD_CODING_OUT: return 12; - case GF_SG_FIELD_CODING_DYN: return 3; + case GF_SG_FIELD_CODING_IN: + return 12; + case GF_SG_FIELD_CODING_DEF: + return 15; + case GF_SG_FIELD_CODING_OUT: + return 12; + case GF_SG_FIELD_CODING_DYN: + return 3; default: return 15; } @@ -33911,7 +34639,7 @@ static s32 WideSound_get_field_index_by_name(char *name) if (!strcmp("distance", name)) return 13; if (!strcmp("useAirabs", name)) return 14; return -1; - } +} static Bool WideSound_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34001,8 +34729,8 @@ GF_Node *WideSound_Create() static void ScoreShape_Del(GF_Node *node) { M_ScoreShape *p = (M_ScoreShape *) node; - gf_node_unregister((GF_Node *) p->score, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->score, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->geometry, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -34013,10 +34741,14 @@ static const u16 ScoreShape_Out2All[] = { 0, 1}; static u32 ScoreShape_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -34066,7 +34798,7 @@ static s32 ScoreShape_get_field_index_by_name(char *name) if (!strcmp("score", name)) return 0; if (!strcmp("geometry", name)) return 1; return -1; - } +} static Bool ScoreShape_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34121,10 +34853,14 @@ static const u16 MusicScore_Dyn2All[] = { 14}; static u32 MusicScore_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 21; - case GF_SG_FIELD_CODING_DEF: return 16; - case GF_SG_FIELD_CODING_OUT: return 26; - case GF_SG_FIELD_CODING_DYN: return 1; + case GF_SG_FIELD_CODING_IN: + return 21; + case GF_SG_FIELD_CODING_DEF: + return 16; + case GF_SG_FIELD_CODING_OUT: + return 26; + case GF_SG_FIELD_CODING_DYN: + return 1; default: return 31; } @@ -34383,7 +35119,7 @@ static s32 MusicScore_get_field_index_by_name(char *name) if (!strcmp("numMeasures", name)) return 29; if (!strcmp("partNames", name)) return 30; return -1; - } +} static Bool MusicScore_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34428,7 +35164,7 @@ GF_Node *MusicScore_Create() static void FootPrintSetNode_Del(GF_Node *node) { M_FootPrintSetNode *p = (M_FootPrintSetNode *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -34439,10 +35175,14 @@ static const u16 FootPrintSetNode_Out2All[] = { 0}; static u32 FootPrintSetNode_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 1; - case GF_SG_FIELD_CODING_DEF: return 1; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 1; + case GF_SG_FIELD_CODING_DEF: + return 1; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 1; } @@ -34484,7 +35224,7 @@ static s32 FootPrintSetNode_get_field_index_by_name(char *name) { if (!strcmp("children", name)) return 0; return -1; - } +} static Bool FootPrintSetNode_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34515,7 +35255,7 @@ GF_Node *FootPrintSetNode_Create() static void FootPrintNode_Del(GF_Node *node) { M_FootPrintNode *p = (M_FootPrintNode *) node; - gf_node_unregister((GF_Node *) p->footprint, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->footprint, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -34526,10 +35266,14 @@ static const u16 FootPrintNode_Out2All[] = { 0, 1}; static u32 FootPrintNode_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 2; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 2; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 2; } @@ -34578,7 +35322,7 @@ static s32 FootPrintNode_get_field_index_by_name(char *name) if (!strcmp("index", name)) return 0; if (!strcmp("footprint", name)) return 1; return -1; - } +} static Bool FootPrintNode_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34609,10 +35353,10 @@ GF_Node *FootPrintNode_Create() static void BuildingPartNode_Del(GF_Node *node) { M_BuildingPartNode *p = (M_BuildingPartNode *) node; - gf_node_unregister((GF_Node *) p->footprint, (GF_Node *) p); - gf_node_unregister_children((GF_Node *) p, p->alternativeGeometry); - gf_node_unregister_children((GF_Node *) p, p->roofs); - gf_node_unregister_children((GF_Node *) p, p->facades); + gf_node_unregister((GF_Node *) p->footprint, (GF_Node *) p); + gf_node_unregister_children((GF_Node *) p, p->alternativeGeometry); + gf_node_unregister_children((GF_Node *) p, p->roofs); + gf_node_unregister_children((GF_Node *) p, p->facades); gf_node_free((GF_Node *) p); } @@ -34623,10 +35367,14 @@ static const u16 BuildingPartNode_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 BuildingPartNode_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 8; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 8; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -34720,7 +35468,7 @@ static s32 BuildingPartNode_get_field_index_by_name(char *name) if (!strcmp("roofs", name)) return 6; if (!strcmp("facades", name)) return 7; return -1; - } +} static Bool BuildingPartNode_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34766,10 +35514,14 @@ static const u16 RoofNode_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; static u32 RoofNode_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 12; - case GF_SG_FIELD_CODING_DEF: return 12; - case GF_SG_FIELD_CODING_OUT: return 12; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 12; + case GF_SG_FIELD_CODING_DEF: + return 12; + case GF_SG_FIELD_CODING_OUT: + return 12; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 12; } @@ -34887,7 +35639,7 @@ static s32 RoofNode_get_field_index_by_name(char *name) if (!strcmp("TextureYPosition", name)) return 10; if (!strcmp("TextureRotation", name)) return 11; return -1; - } +} static Bool RoofNode_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -34933,7 +35685,7 @@ static void FacadeNode_Del(GF_Node *node) gf_sg_sfurl_del(p->FacadePrimitive); gf_sg_mfint32_del(p->NbFacadeCellsByStorey); gf_sg_mffloat_del(p->StoreyHeight); - gf_node_unregister_children((GF_Node *) p, p->FacadeCellsArray); + gf_node_unregister_children((GF_Node *) p, p->FacadeCellsArray); gf_node_free((GF_Node *) p); } @@ -34944,10 +35696,14 @@ static const u16 FacadeNode_Out2All[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, static u32 FacadeNode_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 13; - case GF_SG_FIELD_CODING_DEF: return 13; - case GF_SG_FIELD_CODING_OUT: return 13; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 13; + case GF_SG_FIELD_CODING_DEF: + return 13; + case GF_SG_FIELD_CODING_OUT: + return 13; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 13; } @@ -35073,7 +35829,7 @@ static s32 FacadeNode_get_field_index_by_name(char *name) if (!strcmp("StoreyHeight", name)) return 11; if (!strcmp("FacadeCellsArray", name)) return 12; return -1; - } +} static Bool FacadeNode_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35117,7 +35873,7 @@ GF_Node *FacadeNode_Create() static void Shadow_Del(GF_Node *node) { M_Shadow *p = (M_Shadow *) node; - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -35128,10 +35884,14 @@ static const u16 Shadow_Out2All[] = { 2, 3, 4, 5, 6}; static u32 Shadow_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 7; - case GF_SG_FIELD_CODING_DEF: return 5; - case GF_SG_FIELD_CODING_OUT: return 5; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 7; + case GF_SG_FIELD_CODING_DEF: + return 5; + case GF_SG_FIELD_CODING_OUT: + return 5; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 7; } @@ -35219,7 +35979,7 @@ static s32 Shadow_get_field_index_by_name(char *name) if (!strcmp("receive", name)) return 5; if (!strcmp("penumbra", name)) return 6; return -1; - } +} static Bool Shadow_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35267,10 +36027,14 @@ static const u16 CacheTexture_Def2All[] = { 0, 1, 2, 3, 4, 5, 6, 7}; static u32 CacheTexture_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 0; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 0; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 0; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 0; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 8; } @@ -35354,7 +36118,7 @@ static s32 CacheTexture_get_field_index_by_name(char *name) if (!strcmp("repeatS", name)) return 6; if (!strcmp("repeatT", name)) return 7; return -1; - } +} static Bool CacheTexture_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35400,10 +36164,14 @@ static const u16 EnvironmentTest_Out2All[] = { 1, 2, 3, 4, 5, 6, 7, 8}; static u32 EnvironmentTest_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 5; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 8; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 5; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 8; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 9; } @@ -35501,7 +36269,7 @@ static s32 EnvironmentTest_get_field_index_by_name(char *name) if (!strcmp("valueSmaller", name)) return 7; if (!strcmp("parameterValue", name)) return 8; return -1; - } +} static Bool EnvironmentTest_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35534,13 +36302,13 @@ GF_Node *EnvironmentTest_Create() static void KeyNavigator_Del(GF_Node *node) { M_KeyNavigator *p = (M_KeyNavigator *) node; - gf_node_unregister((GF_Node *) p->sensor, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->left, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->right, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->up, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->down, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->select, (GF_Node *) p); - gf_node_unregister((GF_Node *) p->quit, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->sensor, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->left, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->right, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->up, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->down, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->select, (GF_Node *) p); + gf_node_unregister((GF_Node *) p->quit, (GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -35551,10 +36319,14 @@ static const u16 KeyNavigator_Out2All[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9}; static u32 KeyNavigator_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 9; - case GF_SG_FIELD_CODING_DEF: return 8; - case GF_SG_FIELD_CODING_OUT: return 9; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 9; + case GF_SG_FIELD_CODING_DEF: + return 8; + case GF_SG_FIELD_CODING_OUT: + return 9; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 10; } @@ -35666,7 +36438,7 @@ static s32 KeyNavigator_get_field_index_by_name(char *name) if (!strcmp("step", name)) return 8; if (!strcmp("focusSet", name)) return 9; return -1; - } +} static Bool KeyNavigator_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35698,7 +36470,7 @@ static void SpacePartition_Del(GF_Node *node) { M_SpacePartition *p = (M_SpacePartition *) node; gf_sg_sfurl_del(p->SPStream); - gf_sg_vrml_parent_destroy((GF_Node *) p); + gf_sg_vrml_parent_destroy((GF_Node *) p); gf_node_free((GF_Node *) p); } @@ -35709,10 +36481,14 @@ static const u16 SpacePartition_Out2All[] = { 2, 3}; static u32 SpacePartition_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 4; - case GF_SG_FIELD_CODING_DEF: return 2; - case GF_SG_FIELD_CODING_OUT: return 2; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 4; + case GF_SG_FIELD_CODING_DEF: + return 2; + case GF_SG_FIELD_CODING_OUT: + return 2; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 4; } @@ -35779,7 +36555,7 @@ static s32 SpacePartition_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 2; if (!strcmp("SPStream", name)) return 3; return -1; - } +} static Bool SpacePartition_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -35821,10 +36597,14 @@ static const u16 Storage_Out2All[] = { 2}; static u32 Storage_get_field_count(GF_Node *node, u8 IndexMode) { switch(IndexMode) { - case GF_SG_FIELD_CODING_IN: return 3; - case GF_SG_FIELD_CODING_DEF: return 4; - case GF_SG_FIELD_CODING_OUT: return 1; - case GF_SG_FIELD_CODING_DYN: return 0; + case GF_SG_FIELD_CODING_IN: + return 3; + case GF_SG_FIELD_CODING_DEF: + return 4; + case GF_SG_FIELD_CODING_OUT: + return 1; + case GF_SG_FIELD_CODING_DYN: + return 0; default: return 6; } @@ -35902,7 +36682,7 @@ static s32 Storage_get_field_index_by_name(char *name) if (!strcmp("name", name)) return 4; if (!strcmp("storageList", name)) return 5; return -1; - } +} static Bool Storage_get_aq_info(GF_Node *n, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) { switch (FieldIndex) { @@ -36729,395 +37509,590 @@ void gf_sg_mpeg4_node_del(GF_Node *node) { switch (node->sgprivate->tag) { case TAG_MPEG4_Anchor: - Anchor_Del(node); return; + Anchor_Del(node); + return; case TAG_MPEG4_AnimationStream: - AnimationStream_Del(node); return; + AnimationStream_Del(node); + return; case TAG_MPEG4_Appearance: - Appearance_Del(node); return; + Appearance_Del(node); + return; case TAG_MPEG4_AudioBuffer: - AudioBuffer_Del(node); return; + AudioBuffer_Del(node); + return; case TAG_MPEG4_AudioClip: - AudioClip_Del(node); return; + AudioClip_Del(node); + return; case TAG_MPEG4_AudioDelay: - AudioDelay_Del(node); return; + AudioDelay_Del(node); + return; case TAG_MPEG4_AudioFX: - AudioFX_Del(node); return; + AudioFX_Del(node); + return; case TAG_MPEG4_AudioMix: - AudioMix_Del(node); return; + AudioMix_Del(node); + return; case TAG_MPEG4_AudioSource: - AudioSource_Del(node); return; + AudioSource_Del(node); + return; case TAG_MPEG4_AudioSwitch: - AudioSwitch_Del(node); return; + AudioSwitch_Del(node); + return; case TAG_MPEG4_Background: - Background_Del(node); return; + Background_Del(node); + return; case TAG_MPEG4_Background2D: - Background2D_Del(node); return; + Background2D_Del(node); + return; case TAG_MPEG4_Billboard: - Billboard_Del(node); return; + Billboard_Del(node); + return; case TAG_MPEG4_Bitmap: - Bitmap_Del(node); return; + Bitmap_Del(node); + return; case TAG_MPEG4_Box: - Box_Del(node); return; + Box_Del(node); + return; case TAG_MPEG4_Circle: - Circle_Del(node); return; + Circle_Del(node); + return; case TAG_MPEG4_Collision: - Collision_Del(node); return; + Collision_Del(node); + return; case TAG_MPEG4_Color: - Color_Del(node); return; + Color_Del(node); + return; case TAG_MPEG4_ColorInterpolator: - ColorInterpolator_Del(node); return; + ColorInterpolator_Del(node); + return; case TAG_MPEG4_CompositeTexture2D: - CompositeTexture2D_Del(node); return; + CompositeTexture2D_Del(node); + return; case TAG_MPEG4_CompositeTexture3D: - CompositeTexture3D_Del(node); return; + CompositeTexture3D_Del(node); + return; case TAG_MPEG4_Conditional: - Conditional_Del(node); return; + Conditional_Del(node); + return; case TAG_MPEG4_Cone: - Cone_Del(node); return; + Cone_Del(node); + return; case TAG_MPEG4_Coordinate: - Coordinate_Del(node); return; + Coordinate_Del(node); + return; case TAG_MPEG4_Coordinate2D: - Coordinate2D_Del(node); return; + Coordinate2D_Del(node); + return; case TAG_MPEG4_CoordinateInterpolator: - CoordinateInterpolator_Del(node); return; + CoordinateInterpolator_Del(node); + return; case TAG_MPEG4_CoordinateInterpolator2D: - CoordinateInterpolator2D_Del(node); return; + CoordinateInterpolator2D_Del(node); + return; case TAG_MPEG4_Curve2D: - Curve2D_Del(node); return; + Curve2D_Del(node); + return; case TAG_MPEG4_Cylinder: - Cylinder_Del(node); return; + Cylinder_Del(node); + return; case TAG_MPEG4_CylinderSensor: - CylinderSensor_Del(node); return; + CylinderSensor_Del(node); + return; case TAG_MPEG4_DirectionalLight: - DirectionalLight_Del(node); return; + DirectionalLight_Del(node); + return; case TAG_MPEG4_DiscSensor: - DiscSensor_Del(node); return; + DiscSensor_Del(node); + return; case TAG_MPEG4_ElevationGrid: - ElevationGrid_Del(node); return; + ElevationGrid_Del(node); + return; case TAG_MPEG4_Expression: - Expression_Del(node); return; + Expression_Del(node); + return; case TAG_MPEG4_Extrusion: - Extrusion_Del(node); return; + Extrusion_Del(node); + return; case TAG_MPEG4_Face: - Face_Del(node); return; + Face_Del(node); + return; case TAG_MPEG4_FaceDefMesh: - FaceDefMesh_Del(node); return; + FaceDefMesh_Del(node); + return; case TAG_MPEG4_FaceDefTables: - FaceDefTables_Del(node); return; + FaceDefTables_Del(node); + return; case TAG_MPEG4_FaceDefTransform: - FaceDefTransform_Del(node); return; + FaceDefTransform_Del(node); + return; case TAG_MPEG4_FAP: - FAP_Del(node); return; + FAP_Del(node); + return; case TAG_MPEG4_FDP: - FDP_Del(node); return; + FDP_Del(node); + return; case TAG_MPEG4_FIT: - FIT_Del(node); return; + FIT_Del(node); + return; case TAG_MPEG4_Fog: - Fog_Del(node); return; + Fog_Del(node); + return; case TAG_MPEG4_FontStyle: - FontStyle_Del(node); return; + FontStyle_Del(node); + return; case TAG_MPEG4_Form: - Form_Del(node); return; + Form_Del(node); + return; case TAG_MPEG4_Group: - Group_Del(node); return; + Group_Del(node); + return; case TAG_MPEG4_ImageTexture: - ImageTexture_Del(node); return; + ImageTexture_Del(node); + return; case TAG_MPEG4_IndexedFaceSet: - IndexedFaceSet_Del(node); return; + IndexedFaceSet_Del(node); + return; case TAG_MPEG4_IndexedFaceSet2D: - IndexedFaceSet2D_Del(node); return; + IndexedFaceSet2D_Del(node); + return; case TAG_MPEG4_IndexedLineSet: - IndexedLineSet_Del(node); return; + IndexedLineSet_Del(node); + return; case TAG_MPEG4_IndexedLineSet2D: - IndexedLineSet2D_Del(node); return; + IndexedLineSet2D_Del(node); + return; case TAG_MPEG4_Inline: - Inline_Del(node); return; + Inline_Del(node); + return; case TAG_MPEG4_LOD: - LOD_Del(node); return; + LOD_Del(node); + return; case TAG_MPEG4_Layer2D: - Layer2D_Del(node); return; + Layer2D_Del(node); + return; case TAG_MPEG4_Layer3D: - Layer3D_Del(node); return; + Layer3D_Del(node); + return; case TAG_MPEG4_Layout: - Layout_Del(node); return; + Layout_Del(node); + return; case TAG_MPEG4_LineProperties: - LineProperties_Del(node); return; + LineProperties_Del(node); + return; case TAG_MPEG4_ListeningPoint: - ListeningPoint_Del(node); return; + ListeningPoint_Del(node); + return; case TAG_MPEG4_Material: - Material_Del(node); return; + Material_Del(node); + return; case TAG_MPEG4_Material2D: - Material2D_Del(node); return; + Material2D_Del(node); + return; case TAG_MPEG4_MovieTexture: - MovieTexture_Del(node); return; + MovieTexture_Del(node); + return; case TAG_MPEG4_NavigationInfo: - NavigationInfo_Del(node); return; + NavigationInfo_Del(node); + return; case TAG_MPEG4_Normal: - Normal_Del(node); return; + Normal_Del(node); + return; case TAG_MPEG4_NormalInterpolator: - NormalInterpolator_Del(node); return; + NormalInterpolator_Del(node); + return; case TAG_MPEG4_OrderedGroup: - OrderedGroup_Del(node); return; + OrderedGroup_Del(node); + return; case TAG_MPEG4_OrientationInterpolator: - OrientationInterpolator_Del(node); return; + OrientationInterpolator_Del(node); + return; case TAG_MPEG4_PixelTexture: - PixelTexture_Del(node); return; + PixelTexture_Del(node); + return; case TAG_MPEG4_PlaneSensor: - PlaneSensor_Del(node); return; + PlaneSensor_Del(node); + return; case TAG_MPEG4_PlaneSensor2D: - PlaneSensor2D_Del(node); return; + PlaneSensor2D_Del(node); + return; case TAG_MPEG4_PointLight: - PointLight_Del(node); return; + PointLight_Del(node); + return; case TAG_MPEG4_PointSet: - PointSet_Del(node); return; + PointSet_Del(node); + return; case TAG_MPEG4_PointSet2D: - PointSet2D_Del(node); return; + PointSet2D_Del(node); + return; case TAG_MPEG4_PositionInterpolator: - PositionInterpolator_Del(node); return; + PositionInterpolator_Del(node); + return; case TAG_MPEG4_PositionInterpolator2D: - PositionInterpolator2D_Del(node); return; + PositionInterpolator2D_Del(node); + return; case TAG_MPEG4_ProximitySensor2D: - ProximitySensor2D_Del(node); return; + ProximitySensor2D_Del(node); + return; case TAG_MPEG4_ProximitySensor: - ProximitySensor_Del(node); return; + ProximitySensor_Del(node); + return; case TAG_MPEG4_QuantizationParameter: - QuantizationParameter_Del(node); return; + QuantizationParameter_Del(node); + return; case TAG_MPEG4_Rectangle: - Rectangle_Del(node); return; + Rectangle_Del(node); + return; case TAG_MPEG4_ScalarInterpolator: - ScalarInterpolator_Del(node); return; + ScalarInterpolator_Del(node); + return; case TAG_MPEG4_Script: - Script_Del(node); return; + Script_Del(node); + return; case TAG_MPEG4_Shape: - Shape_Del(node); return; + Shape_Del(node); + return; case TAG_MPEG4_Sound: - Sound_Del(node); return; + Sound_Del(node); + return; case TAG_MPEG4_Sound2D: - Sound2D_Del(node); return; + Sound2D_Del(node); + return; case TAG_MPEG4_Sphere: - Sphere_Del(node); return; + Sphere_Del(node); + return; case TAG_MPEG4_SphereSensor: - SphereSensor_Del(node); return; + SphereSensor_Del(node); + return; case TAG_MPEG4_SpotLight: - SpotLight_Del(node); return; + SpotLight_Del(node); + return; case TAG_MPEG4_Switch: - Switch_Del(node); return; + Switch_Del(node); + return; case TAG_MPEG4_TermCap: - TermCap_Del(node); return; + TermCap_Del(node); + return; case TAG_MPEG4_Text: - Text_Del(node); return; + Text_Del(node); + return; case TAG_MPEG4_TextureCoordinate: - TextureCoordinate_Del(node); return; + TextureCoordinate_Del(node); + return; case TAG_MPEG4_TextureTransform: - TextureTransform_Del(node); return; + TextureTransform_Del(node); + return; case TAG_MPEG4_TimeSensor: - TimeSensor_Del(node); return; + TimeSensor_Del(node); + return; case TAG_MPEG4_TouchSensor: - TouchSensor_Del(node); return; + TouchSensor_Del(node); + return; case TAG_MPEG4_Transform: - Transform_Del(node); return; + Transform_Del(node); + return; case TAG_MPEG4_Transform2D: - Transform2D_Del(node); return; + Transform2D_Del(node); + return; case TAG_MPEG4_Valuator: - Valuator_Del(node); return; + Valuator_Del(node); + return; case TAG_MPEG4_Viewpoint: - Viewpoint_Del(node); return; + Viewpoint_Del(node); + return; case TAG_MPEG4_VisibilitySensor: - VisibilitySensor_Del(node); return; + VisibilitySensor_Del(node); + return; case TAG_MPEG4_Viseme: - Viseme_Del(node); return; + Viseme_Del(node); + return; case TAG_MPEG4_WorldInfo: - WorldInfo_Del(node); return; + WorldInfo_Del(node); + return; case TAG_MPEG4_AcousticMaterial: - AcousticMaterial_Del(node); return; + AcousticMaterial_Del(node); + return; case TAG_MPEG4_AcousticScene: - AcousticScene_Del(node); return; + AcousticScene_Del(node); + return; case TAG_MPEG4_ApplicationWindow: - ApplicationWindow_Del(node); return; + ApplicationWindow_Del(node); + return; case TAG_MPEG4_BAP: - BAP_Del(node); return; + BAP_Del(node); + return; case TAG_MPEG4_BDP: - BDP_Del(node); return; + BDP_Del(node); + return; case TAG_MPEG4_Body: - Body_Del(node); return; + Body_Del(node); + return; case TAG_MPEG4_BodyDefTable: - BodyDefTable_Del(node); return; + BodyDefTable_Del(node); + return; case TAG_MPEG4_BodySegmentConnectionHint: - BodySegmentConnectionHint_Del(node); return; + BodySegmentConnectionHint_Del(node); + return; case TAG_MPEG4_DirectiveSound: - DirectiveSound_Del(node); return; + DirectiveSound_Del(node); + return; case TAG_MPEG4_Hierarchical3DMesh: - Hierarchical3DMesh_Del(node); return; + Hierarchical3DMesh_Del(node); + return; case TAG_MPEG4_MaterialKey: - MaterialKey_Del(node); return; + MaterialKey_Del(node); + return; case TAG_MPEG4_PerceptualParameters: - PerceptualParameters_Del(node); return; + PerceptualParameters_Del(node); + return; case TAG_MPEG4_TemporalTransform: - TemporalTransform_Del(node); return; + TemporalTransform_Del(node); + return; case TAG_MPEG4_TemporalGroup: - TemporalGroup_Del(node); return; + TemporalGroup_Del(node); + return; case TAG_MPEG4_ServerCommand: - ServerCommand_Del(node); return; + ServerCommand_Del(node); + return; case TAG_MPEG4_InputSensor: - InputSensor_Del(node); return; + InputSensor_Del(node); + return; case TAG_MPEG4_MatteTexture: - MatteTexture_Del(node); return; + MatteTexture_Del(node); + return; case TAG_MPEG4_MediaBuffer: - MediaBuffer_Del(node); return; + MediaBuffer_Del(node); + return; case TAG_MPEG4_MediaControl: - MediaControl_Del(node); return; + MediaControl_Del(node); + return; case TAG_MPEG4_MediaSensor: - MediaSensor_Del(node); return; + MediaSensor_Del(node); + return; case TAG_MPEG4_BitWrapper: - BitWrapper_Del(node); return; + BitWrapper_Del(node); + return; case TAG_MPEG4_CoordinateInterpolator4D: - CoordinateInterpolator4D_Del(node); return; + CoordinateInterpolator4D_Del(node); + return; case TAG_MPEG4_DepthImage: - DepthImage_Del(node); return; + DepthImage_Del(node); + return; case TAG_MPEG4_FFD: - FFD_Del(node); return; + FFD_Del(node); + return; case TAG_MPEG4_Implicit: - Implicit_Del(node); return; + Implicit_Del(node); + return; case TAG_MPEG4_XXLFM_Appearance: - XXLFM_Appearance_Del(node); return; + XXLFM_Appearance_Del(node); + return; case TAG_MPEG4_XXLFM_BlendList: - XXLFM_BlendList_Del(node); return; + XXLFM_BlendList_Del(node); + return; case TAG_MPEG4_XXLFM_FrameList: - XXLFM_FrameList_Del(node); return; + XXLFM_FrameList_Del(node); + return; case TAG_MPEG4_XXLFM_LightMap: - XXLFM_LightMap_Del(node); return; + XXLFM_LightMap_Del(node); + return; case TAG_MPEG4_XXLFM_SurfaceMapList: - XXLFM_SurfaceMapList_Del(node); return; + XXLFM_SurfaceMapList_Del(node); + return; case TAG_MPEG4_XXLFM_ViewMapList: - XXLFM_ViewMapList_Del(node); return; + XXLFM_ViewMapList_Del(node); + return; case TAG_MPEG4_MeshGrid: - MeshGrid_Del(node); return; + MeshGrid_Del(node); + return; case TAG_MPEG4_NonLinearDeformer: - NonLinearDeformer_Del(node); return; + NonLinearDeformer_Del(node); + return; case TAG_MPEG4_NurbsCurve: - NurbsCurve_Del(node); return; + NurbsCurve_Del(node); + return; case TAG_MPEG4_NurbsCurve2D: - NurbsCurve2D_Del(node); return; + NurbsCurve2D_Del(node); + return; case TAG_MPEG4_NurbsSurface: - NurbsSurface_Del(node); return; + NurbsSurface_Del(node); + return; case TAG_MPEG4_OctreeImage: - OctreeImage_Del(node); return; + OctreeImage_Del(node); + return; case TAG_MPEG4_XXParticles: - XXParticles_Del(node); return; + XXParticles_Del(node); + return; case TAG_MPEG4_XXParticleInitBox: - XXParticleInitBox_Del(node); return; + XXParticleInitBox_Del(node); + return; case TAG_MPEG4_XXPlanarObstacle: - XXPlanarObstacle_Del(node); return; + XXPlanarObstacle_Del(node); + return; case TAG_MPEG4_XXPointAttractor: - XXPointAttractor_Del(node); return; + XXPointAttractor_Del(node); + return; case TAG_MPEG4_PointTexture: - PointTexture_Del(node); return; + PointTexture_Del(node); + return; case TAG_MPEG4_PositionAnimator: - PositionAnimator_Del(node); return; + PositionAnimator_Del(node); + return; case TAG_MPEG4_PositionAnimator2D: - PositionAnimator2D_Del(node); return; + PositionAnimator2D_Del(node); + return; case TAG_MPEG4_PositionInterpolator4D: - PositionInterpolator4D_Del(node); return; + PositionInterpolator4D_Del(node); + return; case TAG_MPEG4_ProceduralTexture: - ProceduralTexture_Del(node); return; + ProceduralTexture_Del(node); + return; case TAG_MPEG4_Quadric: - Quadric_Del(node); return; + Quadric_Del(node); + return; case TAG_MPEG4_SBBone: - SBBone_Del(node); return; + SBBone_Del(node); + return; case TAG_MPEG4_SBMuscle: - SBMuscle_Del(node); return; + SBMuscle_Del(node); + return; case TAG_MPEG4_SBSegment: - SBSegment_Del(node); return; + SBSegment_Del(node); + return; case TAG_MPEG4_SBSite: - SBSite_Del(node); return; + SBSite_Del(node); + return; case TAG_MPEG4_SBSkinnedModel: - SBSkinnedModel_Del(node); return; + SBSkinnedModel_Del(node); + return; case TAG_MPEG4_SBVCAnimation: - SBVCAnimation_Del(node); return; + SBVCAnimation_Del(node); + return; case TAG_MPEG4_ScalarAnimator: - ScalarAnimator_Del(node); return; + ScalarAnimator_Del(node); + return; case TAG_MPEG4_SimpleTexture: - SimpleTexture_Del(node); return; + SimpleTexture_Del(node); + return; case TAG_MPEG4_SolidRep: - SolidRep_Del(node); return; + SolidRep_Del(node); + return; case TAG_MPEG4_SubdivisionSurface: - SubdivisionSurface_Del(node); return; + SubdivisionSurface_Del(node); + return; case TAG_MPEG4_SubdivSurfaceSector: - SubdivSurfaceSector_Del(node); return; + SubdivSurfaceSector_Del(node); + return; case TAG_MPEG4_WaveletSubdivisionSurface: - WaveletSubdivisionSurface_Del(node); return; + WaveletSubdivisionSurface_Del(node); + return; case TAG_MPEG4_Clipper2D: - Clipper2D_Del(node); return; + Clipper2D_Del(node); + return; case TAG_MPEG4_ColorTransform: - ColorTransform_Del(node); return; + ColorTransform_Del(node); + return; case TAG_MPEG4_Ellipse: - Ellipse_Del(node); return; + Ellipse_Del(node); + return; case TAG_MPEG4_LinearGradient: - LinearGradient_Del(node); return; + LinearGradient_Del(node); + return; case TAG_MPEG4_PathLayout: - PathLayout_Del(node); return; + PathLayout_Del(node); + return; case TAG_MPEG4_RadialGradient: - RadialGradient_Del(node); return; + RadialGradient_Del(node); + return; case TAG_MPEG4_SynthesizedTexture: - SynthesizedTexture_Del(node); return; + SynthesizedTexture_Del(node); + return; case TAG_MPEG4_TransformMatrix2D: - TransformMatrix2D_Del(node); return; + TransformMatrix2D_Del(node); + return; case TAG_MPEG4_Viewport: - Viewport_Del(node); return; + Viewport_Del(node); + return; case TAG_MPEG4_XCurve2D: - XCurve2D_Del(node); return; + XCurve2D_Del(node); + return; case TAG_MPEG4_XFontStyle: - XFontStyle_Del(node); return; + XFontStyle_Del(node); + return; case TAG_MPEG4_XLineProperties: - XLineProperties_Del(node); return; + XLineProperties_Del(node); + return; case TAG_MPEG4_AdvancedAudioBuffer: - AdvancedAudioBuffer_Del(node); return; + AdvancedAudioBuffer_Del(node); + return; case TAG_MPEG4_AudioChannelConfig: - AudioChannelConfig_Del(node); return; + AudioChannelConfig_Del(node); + return; case TAG_MPEG4_DepthImageV2: - DepthImageV2_Del(node); return; + DepthImageV2_Del(node); + return; case TAG_MPEG4_MorphShape: - MorphShape_Del(node); return; + MorphShape_Del(node); + return; case TAG_MPEG4_MultiTexture: - MultiTexture_Del(node); return; + MultiTexture_Del(node); + return; case TAG_MPEG4_PointTextureV2: - PointTextureV2_Del(node); return; + PointTextureV2_Del(node); + return; case TAG_MPEG4_SBVCAnimationV2: - SBVCAnimationV2_Del(node); return; + SBVCAnimationV2_Del(node); + return; case TAG_MPEG4_SimpleTextureV2: - SimpleTextureV2_Del(node); return; + SimpleTextureV2_Del(node); + return; case TAG_MPEG4_SurroundingSound: - SurroundingSound_Del(node); return; + SurroundingSound_Del(node); + return; case TAG_MPEG4_Transform3DAudio: - Transform3DAudio_Del(node); return; + Transform3DAudio_Del(node); + return; case TAG_MPEG4_WideSound: - WideSound_Del(node); return; + WideSound_Del(node); + return; case TAG_MPEG4_ScoreShape: - ScoreShape_Del(node); return; + ScoreShape_Del(node); + return; case TAG_MPEG4_MusicScore: - MusicScore_Del(node); return; + MusicScore_Del(node); + return; case TAG_MPEG4_FootPrintSetNode: - FootPrintSetNode_Del(node); return; + FootPrintSetNode_Del(node); + return; case TAG_MPEG4_FootPrintNode: - FootPrintNode_Del(node); return; + FootPrintNode_Del(node); + return; case TAG_MPEG4_BuildingPartNode: - BuildingPartNode_Del(node); return; + BuildingPartNode_Del(node); + return; case TAG_MPEG4_RoofNode: - RoofNode_Del(node); return; + RoofNode_Del(node); + return; case TAG_MPEG4_FacadeNode: - FacadeNode_Del(node); return; + FacadeNode_Del(node); + return; case TAG_MPEG4_Shadow: - Shadow_Del(node); return; + Shadow_Del(node); + return; case TAG_MPEG4_CacheTexture: - CacheTexture_Del(node); return; + CacheTexture_Del(node); + return; case TAG_MPEG4_EnvironmentTest: - EnvironmentTest_Del(node); return; + EnvironmentTest_Del(node); + return; case TAG_MPEG4_KeyNavigator: - KeyNavigator_Del(node); return; + KeyNavigator_Del(node); + return; case TAG_MPEG4_SpacePartition: - SpacePartition_Del(node); return; + SpacePartition_Del(node); + return; case TAG_MPEG4_Storage: - Storage_Del(node); return; + Storage_Del(node); + return; default: return; } @@ -37126,1026 +38101,1859 @@ void gf_sg_mpeg4_node_del(GF_Node *node) u32 gf_sg_mpeg4_node_get_field_count(GF_Node *node, u8 code_mode) { switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor:return Anchor_get_field_count(node, code_mode); - case TAG_MPEG4_AnimationStream:return AnimationStream_get_field_count(node, code_mode); - case TAG_MPEG4_Appearance:return Appearance_get_field_count(node, code_mode); - case TAG_MPEG4_AudioBuffer:return AudioBuffer_get_field_count(node, code_mode); - case TAG_MPEG4_AudioClip:return AudioClip_get_field_count(node, code_mode); - case TAG_MPEG4_AudioDelay:return AudioDelay_get_field_count(node, code_mode); - case TAG_MPEG4_AudioFX:return AudioFX_get_field_count(node, code_mode); - case TAG_MPEG4_AudioMix:return AudioMix_get_field_count(node, code_mode); - case TAG_MPEG4_AudioSource:return AudioSource_get_field_count(node, code_mode); - case TAG_MPEG4_AudioSwitch:return AudioSwitch_get_field_count(node, code_mode); - case TAG_MPEG4_Background:return Background_get_field_count(node, code_mode); - case TAG_MPEG4_Background2D:return Background2D_get_field_count(node, code_mode); - case TAG_MPEG4_Billboard:return Billboard_get_field_count(node, code_mode); - case TAG_MPEG4_Bitmap:return Bitmap_get_field_count(node, code_mode); - case TAG_MPEG4_Box:return Box_get_field_count(node, code_mode); - case TAG_MPEG4_Circle:return Circle_get_field_count(node, code_mode); - case TAG_MPEG4_Collision:return Collision_get_field_count(node, code_mode); - case TAG_MPEG4_Color:return Color_get_field_count(node, code_mode); - case TAG_MPEG4_ColorInterpolator:return ColorInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_CompositeTexture2D:return CompositeTexture2D_get_field_count(node, code_mode); - case TAG_MPEG4_CompositeTexture3D:return CompositeTexture3D_get_field_count(node, code_mode); - case TAG_MPEG4_Conditional:return Conditional_get_field_count(node, code_mode); - case TAG_MPEG4_Cone:return Cone_get_field_count(node, code_mode); - case TAG_MPEG4_Coordinate:return Coordinate_get_field_count(node, code_mode); - case TAG_MPEG4_Coordinate2D:return Coordinate2D_get_field_count(node, code_mode); - case TAG_MPEG4_CoordinateInterpolator:return CoordinateInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_CoordinateInterpolator2D:return CoordinateInterpolator2D_get_field_count(node, code_mode); - case TAG_MPEG4_Curve2D:return Curve2D_get_field_count(node, code_mode); - case TAG_MPEG4_Cylinder:return Cylinder_get_field_count(node, code_mode); - case TAG_MPEG4_CylinderSensor:return CylinderSensor_get_field_count(node, code_mode); - case TAG_MPEG4_DirectionalLight:return DirectionalLight_get_field_count(node, code_mode); - case TAG_MPEG4_DiscSensor:return DiscSensor_get_field_count(node, code_mode); - case TAG_MPEG4_ElevationGrid:return ElevationGrid_get_field_count(node, code_mode); - case TAG_MPEG4_Expression:return Expression_get_field_count(node, code_mode); - case TAG_MPEG4_Extrusion:return Extrusion_get_field_count(node, code_mode); - case TAG_MPEG4_Face:return Face_get_field_count(node, code_mode); - case TAG_MPEG4_FaceDefMesh:return FaceDefMesh_get_field_count(node, code_mode); - case TAG_MPEG4_FaceDefTables:return FaceDefTables_get_field_count(node, code_mode); - case TAG_MPEG4_FaceDefTransform:return FaceDefTransform_get_field_count(node, code_mode); - case TAG_MPEG4_FAP:return FAP_get_field_count(node, code_mode); - case TAG_MPEG4_FDP:return FDP_get_field_count(node, code_mode); - case TAG_MPEG4_FIT:return FIT_get_field_count(node, code_mode); - case TAG_MPEG4_Fog:return Fog_get_field_count(node, code_mode); - case TAG_MPEG4_FontStyle:return FontStyle_get_field_count(node, code_mode); - case TAG_MPEG4_Form:return Form_get_field_count(node, code_mode); - case TAG_MPEG4_Group:return Group_get_field_count(node, code_mode); - case TAG_MPEG4_ImageTexture:return ImageTexture_get_field_count(node, code_mode); - case TAG_MPEG4_IndexedFaceSet:return IndexedFaceSet_get_field_count(node, code_mode); - case TAG_MPEG4_IndexedFaceSet2D:return IndexedFaceSet2D_get_field_count(node, code_mode); - case TAG_MPEG4_IndexedLineSet:return IndexedLineSet_get_field_count(node, code_mode); - case TAG_MPEG4_IndexedLineSet2D:return IndexedLineSet2D_get_field_count(node, code_mode); - case TAG_MPEG4_Inline:return Inline_get_field_count(node, code_mode); - case TAG_MPEG4_LOD:return LOD_get_field_count(node, code_mode); - case TAG_MPEG4_Layer2D:return Layer2D_get_field_count(node, code_mode); - case TAG_MPEG4_Layer3D:return Layer3D_get_field_count(node, code_mode); - case TAG_MPEG4_Layout:return Layout_get_field_count(node, code_mode); - case TAG_MPEG4_LineProperties:return LineProperties_get_field_count(node, code_mode); - case TAG_MPEG4_ListeningPoint:return ListeningPoint_get_field_count(node, code_mode); - case TAG_MPEG4_Material:return Material_get_field_count(node, code_mode); - case TAG_MPEG4_Material2D:return Material2D_get_field_count(node, code_mode); - case TAG_MPEG4_MovieTexture:return MovieTexture_get_field_count(node, code_mode); - case TAG_MPEG4_NavigationInfo:return NavigationInfo_get_field_count(node, code_mode); - case TAG_MPEG4_Normal:return Normal_get_field_count(node, code_mode); - case TAG_MPEG4_NormalInterpolator:return NormalInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_OrderedGroup:return OrderedGroup_get_field_count(node, code_mode); - case TAG_MPEG4_OrientationInterpolator:return OrientationInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_PixelTexture:return PixelTexture_get_field_count(node, code_mode); - case TAG_MPEG4_PlaneSensor:return PlaneSensor_get_field_count(node, code_mode); - case TAG_MPEG4_PlaneSensor2D:return PlaneSensor2D_get_field_count(node, code_mode); - case TAG_MPEG4_PointLight:return PointLight_get_field_count(node, code_mode); - case TAG_MPEG4_PointSet:return PointSet_get_field_count(node, code_mode); - case TAG_MPEG4_PointSet2D:return PointSet2D_get_field_count(node, code_mode); - case TAG_MPEG4_PositionInterpolator:return PositionInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_PositionInterpolator2D:return PositionInterpolator2D_get_field_count(node, code_mode); - case TAG_MPEG4_ProximitySensor2D:return ProximitySensor2D_get_field_count(node, code_mode); - case TAG_MPEG4_ProximitySensor:return ProximitySensor_get_field_count(node, code_mode); - case TAG_MPEG4_QuantizationParameter:return QuantizationParameter_get_field_count(node, code_mode); - case TAG_MPEG4_Rectangle:return Rectangle_get_field_count(node, code_mode); - case TAG_MPEG4_ScalarInterpolator:return ScalarInterpolator_get_field_count(node, code_mode); - case TAG_MPEG4_Script:return Script_get_field_count(node, code_mode); - case TAG_MPEG4_Shape:return Shape_get_field_count(node, code_mode); - case TAG_MPEG4_Sound:return Sound_get_field_count(node, code_mode); - case TAG_MPEG4_Sound2D:return Sound2D_get_field_count(node, code_mode); - case TAG_MPEG4_Sphere:return Sphere_get_field_count(node, code_mode); - case TAG_MPEG4_SphereSensor:return SphereSensor_get_field_count(node, code_mode); - case TAG_MPEG4_SpotLight:return SpotLight_get_field_count(node, code_mode); - case TAG_MPEG4_Switch:return Switch_get_field_count(node, code_mode); - case TAG_MPEG4_TermCap:return TermCap_get_field_count(node, code_mode); - case TAG_MPEG4_Text:return Text_get_field_count(node, code_mode); - case TAG_MPEG4_TextureCoordinate:return TextureCoordinate_get_field_count(node, code_mode); - case TAG_MPEG4_TextureTransform:return TextureTransform_get_field_count(node, code_mode); - case TAG_MPEG4_TimeSensor:return TimeSensor_get_field_count(node, code_mode); - case TAG_MPEG4_TouchSensor:return TouchSensor_get_field_count(node, code_mode); - case TAG_MPEG4_Transform:return Transform_get_field_count(node, code_mode); - case TAG_MPEG4_Transform2D:return Transform2D_get_field_count(node, code_mode); - case TAG_MPEG4_Valuator:return Valuator_get_field_count(node, code_mode); - case TAG_MPEG4_Viewpoint:return Viewpoint_get_field_count(node, code_mode); - case TAG_MPEG4_VisibilitySensor:return VisibilitySensor_get_field_count(node, code_mode); - case TAG_MPEG4_Viseme:return Viseme_get_field_count(node, code_mode); - case TAG_MPEG4_WorldInfo:return WorldInfo_get_field_count(node, code_mode); - case TAG_MPEG4_AcousticMaterial:return AcousticMaterial_get_field_count(node, code_mode); - case TAG_MPEG4_AcousticScene:return AcousticScene_get_field_count(node, code_mode); - case TAG_MPEG4_ApplicationWindow:return ApplicationWindow_get_field_count(node, code_mode); - case TAG_MPEG4_BAP:return BAP_get_field_count(node, code_mode); - case TAG_MPEG4_BDP:return BDP_get_field_count(node, code_mode); - case TAG_MPEG4_Body:return Body_get_field_count(node, code_mode); - case TAG_MPEG4_BodyDefTable:return BodyDefTable_get_field_count(node, code_mode); - case TAG_MPEG4_BodySegmentConnectionHint:return BodySegmentConnectionHint_get_field_count(node, code_mode); - case TAG_MPEG4_DirectiveSound:return DirectiveSound_get_field_count(node, code_mode); - case TAG_MPEG4_Hierarchical3DMesh:return Hierarchical3DMesh_get_field_count(node, code_mode); - case TAG_MPEG4_MaterialKey:return MaterialKey_get_field_count(node, code_mode); - case TAG_MPEG4_PerceptualParameters:return PerceptualParameters_get_field_count(node, code_mode); - case TAG_MPEG4_TemporalTransform:return TemporalTransform_get_field_count(node, code_mode); - case TAG_MPEG4_TemporalGroup:return TemporalGroup_get_field_count(node, code_mode); - case TAG_MPEG4_ServerCommand:return ServerCommand_get_field_count(node, code_mode); - case TAG_MPEG4_InputSensor:return InputSensor_get_field_count(node, code_mode); - case TAG_MPEG4_MatteTexture:return MatteTexture_get_field_count(node, code_mode); - case TAG_MPEG4_MediaBuffer:return MediaBuffer_get_field_count(node, code_mode); - case TAG_MPEG4_MediaControl:return MediaControl_get_field_count(node, code_mode); - case TAG_MPEG4_MediaSensor:return MediaSensor_get_field_count(node, code_mode); - case TAG_MPEG4_BitWrapper:return BitWrapper_get_field_count(node, code_mode); - case TAG_MPEG4_CoordinateInterpolator4D:return CoordinateInterpolator4D_get_field_count(node, code_mode); - case TAG_MPEG4_DepthImage:return DepthImage_get_field_count(node, code_mode); - case TAG_MPEG4_FFD:return FFD_get_field_count(node, code_mode); - case TAG_MPEG4_Implicit:return Implicit_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_Appearance:return XXLFM_Appearance_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_BlendList:return XXLFM_BlendList_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_FrameList:return XXLFM_FrameList_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_LightMap:return XXLFM_LightMap_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_SurfaceMapList:return XXLFM_SurfaceMapList_get_field_count(node, code_mode); - case TAG_MPEG4_XXLFM_ViewMapList:return XXLFM_ViewMapList_get_field_count(node, code_mode); - case TAG_MPEG4_MeshGrid:return MeshGrid_get_field_count(node, code_mode); - case TAG_MPEG4_NonLinearDeformer:return NonLinearDeformer_get_field_count(node, code_mode); - case TAG_MPEG4_NurbsCurve:return NurbsCurve_get_field_count(node, code_mode); - case TAG_MPEG4_NurbsCurve2D:return NurbsCurve2D_get_field_count(node, code_mode); - case TAG_MPEG4_NurbsSurface:return NurbsSurface_get_field_count(node, code_mode); - case TAG_MPEG4_OctreeImage:return OctreeImage_get_field_count(node, code_mode); - case TAG_MPEG4_XXParticles:return XXParticles_get_field_count(node, code_mode); - case TAG_MPEG4_XXParticleInitBox:return XXParticleInitBox_get_field_count(node, code_mode); - case TAG_MPEG4_XXPlanarObstacle:return XXPlanarObstacle_get_field_count(node, code_mode); - case TAG_MPEG4_XXPointAttractor:return XXPointAttractor_get_field_count(node, code_mode); - case TAG_MPEG4_PointTexture:return PointTexture_get_field_count(node, code_mode); - case TAG_MPEG4_PositionAnimator:return PositionAnimator_get_field_count(node, code_mode); - case TAG_MPEG4_PositionAnimator2D:return PositionAnimator2D_get_field_count(node, code_mode); - case TAG_MPEG4_PositionInterpolator4D:return PositionInterpolator4D_get_field_count(node, code_mode); - case TAG_MPEG4_ProceduralTexture:return ProceduralTexture_get_field_count(node, code_mode); - case TAG_MPEG4_Quadric:return Quadric_get_field_count(node, code_mode); - case TAG_MPEG4_SBBone:return SBBone_get_field_count(node, code_mode); - case TAG_MPEG4_SBMuscle:return SBMuscle_get_field_count(node, code_mode); - case TAG_MPEG4_SBSegment:return SBSegment_get_field_count(node, code_mode); - case TAG_MPEG4_SBSite:return SBSite_get_field_count(node, code_mode); - case TAG_MPEG4_SBSkinnedModel:return SBSkinnedModel_get_field_count(node, code_mode); - case TAG_MPEG4_SBVCAnimation:return SBVCAnimation_get_field_count(node, code_mode); - case TAG_MPEG4_ScalarAnimator:return ScalarAnimator_get_field_count(node, code_mode); - case TAG_MPEG4_SimpleTexture:return SimpleTexture_get_field_count(node, code_mode); - case TAG_MPEG4_SolidRep:return SolidRep_get_field_count(node, code_mode); - case TAG_MPEG4_SubdivisionSurface:return SubdivisionSurface_get_field_count(node, code_mode); - case TAG_MPEG4_SubdivSurfaceSector:return SubdivSurfaceSector_get_field_count(node, code_mode); - case TAG_MPEG4_WaveletSubdivisionSurface:return WaveletSubdivisionSurface_get_field_count(node, code_mode); - case TAG_MPEG4_Clipper2D:return Clipper2D_get_field_count(node, code_mode); - case TAG_MPEG4_ColorTransform:return ColorTransform_get_field_count(node, code_mode); - case TAG_MPEG4_Ellipse:return Ellipse_get_field_count(node, code_mode); - case TAG_MPEG4_LinearGradient:return LinearGradient_get_field_count(node, code_mode); - case TAG_MPEG4_PathLayout:return PathLayout_get_field_count(node, code_mode); - case TAG_MPEG4_RadialGradient:return RadialGradient_get_field_count(node, code_mode); - case TAG_MPEG4_SynthesizedTexture:return SynthesizedTexture_get_field_count(node, code_mode); - case TAG_MPEG4_TransformMatrix2D:return TransformMatrix2D_get_field_count(node, code_mode); - case TAG_MPEG4_Viewport:return Viewport_get_field_count(node, code_mode); - case TAG_MPEG4_XCurve2D:return XCurve2D_get_field_count(node, code_mode); - case TAG_MPEG4_XFontStyle:return XFontStyle_get_field_count(node, code_mode); - case TAG_MPEG4_XLineProperties:return XLineProperties_get_field_count(node, code_mode); - case TAG_MPEG4_AdvancedAudioBuffer:return AdvancedAudioBuffer_get_field_count(node, code_mode); - case TAG_MPEG4_AudioChannelConfig:return AudioChannelConfig_get_field_count(node, code_mode); - case TAG_MPEG4_DepthImageV2:return DepthImageV2_get_field_count(node, code_mode); - case TAG_MPEG4_MorphShape:return MorphShape_get_field_count(node, code_mode); - case TAG_MPEG4_MultiTexture:return MultiTexture_get_field_count(node, code_mode); - case TAG_MPEG4_PointTextureV2:return PointTextureV2_get_field_count(node, code_mode); - case TAG_MPEG4_SBVCAnimationV2:return SBVCAnimationV2_get_field_count(node, code_mode); - case TAG_MPEG4_SimpleTextureV2:return SimpleTextureV2_get_field_count(node, code_mode); - case TAG_MPEG4_SurroundingSound:return SurroundingSound_get_field_count(node, code_mode); - case TAG_MPEG4_Transform3DAudio:return Transform3DAudio_get_field_count(node, code_mode); - case TAG_MPEG4_WideSound:return WideSound_get_field_count(node, code_mode); - case TAG_MPEG4_ScoreShape:return ScoreShape_get_field_count(node, code_mode); - case TAG_MPEG4_MusicScore:return MusicScore_get_field_count(node, code_mode); - case TAG_MPEG4_FootPrintSetNode:return FootPrintSetNode_get_field_count(node, code_mode); - case TAG_MPEG4_FootPrintNode:return FootPrintNode_get_field_count(node, code_mode); - case TAG_MPEG4_BuildingPartNode:return BuildingPartNode_get_field_count(node, code_mode); - case TAG_MPEG4_RoofNode:return RoofNode_get_field_count(node, code_mode); - case TAG_MPEG4_FacadeNode:return FacadeNode_get_field_count(node, code_mode); - case TAG_MPEG4_Shadow:return Shadow_get_field_count(node, code_mode); - case TAG_MPEG4_CacheTexture:return CacheTexture_get_field_count(node, code_mode); - case TAG_MPEG4_EnvironmentTest:return EnvironmentTest_get_field_count(node, code_mode); - case TAG_MPEG4_KeyNavigator:return KeyNavigator_get_field_count(node, code_mode); - case TAG_MPEG4_SpacePartition:return SpacePartition_get_field_count(node, code_mode); - case TAG_MPEG4_Storage:return Storage_get_field_count(node, code_mode); - default: - return 0; - } -} - -GF_Err gf_sg_mpeg4_node_get_field(GF_Node *node, GF_FieldInfo *field) -{ - switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor: return Anchor_get_field(node, field); - case TAG_MPEG4_AnimationStream: return AnimationStream_get_field(node, field); - case TAG_MPEG4_Appearance: return Appearance_get_field(node, field); - case TAG_MPEG4_AudioBuffer: return AudioBuffer_get_field(node, field); - case TAG_MPEG4_AudioClip: return AudioClip_get_field(node, field); - case TAG_MPEG4_AudioDelay: return AudioDelay_get_field(node, field); - case TAG_MPEG4_AudioFX: return AudioFX_get_field(node, field); - case TAG_MPEG4_AudioMix: return AudioMix_get_field(node, field); - case TAG_MPEG4_AudioSource: return AudioSource_get_field(node, field); - case TAG_MPEG4_AudioSwitch: return AudioSwitch_get_field(node, field); - case TAG_MPEG4_Background: return Background_get_field(node, field); - case TAG_MPEG4_Background2D: return Background2D_get_field(node, field); - case TAG_MPEG4_Billboard: return Billboard_get_field(node, field); - case TAG_MPEG4_Bitmap: return Bitmap_get_field(node, field); - case TAG_MPEG4_Box: return Box_get_field(node, field); - case TAG_MPEG4_Circle: return Circle_get_field(node, field); - case TAG_MPEG4_Collision: return Collision_get_field(node, field); - case TAG_MPEG4_Color: return Color_get_field(node, field); - case TAG_MPEG4_ColorInterpolator: return ColorInterpolator_get_field(node, field); - case TAG_MPEG4_CompositeTexture2D: return CompositeTexture2D_get_field(node, field); - case TAG_MPEG4_CompositeTexture3D: return CompositeTexture3D_get_field(node, field); - case TAG_MPEG4_Conditional: return Conditional_get_field(node, field); - case TAG_MPEG4_Cone: return Cone_get_field(node, field); - case TAG_MPEG4_Coordinate: return Coordinate_get_field(node, field); - case TAG_MPEG4_Coordinate2D: return Coordinate2D_get_field(node, field); - case TAG_MPEG4_CoordinateInterpolator: return CoordinateInterpolator_get_field(node, field); - case TAG_MPEG4_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_field(node, field); - case TAG_MPEG4_Curve2D: return Curve2D_get_field(node, field); - case TAG_MPEG4_Cylinder: return Cylinder_get_field(node, field); - case TAG_MPEG4_CylinderSensor: return CylinderSensor_get_field(node, field); - case TAG_MPEG4_DirectionalLight: return DirectionalLight_get_field(node, field); - case TAG_MPEG4_DiscSensor: return DiscSensor_get_field(node, field); - case TAG_MPEG4_ElevationGrid: return ElevationGrid_get_field(node, field); - case TAG_MPEG4_Expression: return Expression_get_field(node, field); - case TAG_MPEG4_Extrusion: return Extrusion_get_field(node, field); - case TAG_MPEG4_Face: return Face_get_field(node, field); - case TAG_MPEG4_FaceDefMesh: return FaceDefMesh_get_field(node, field); - case TAG_MPEG4_FaceDefTables: return FaceDefTables_get_field(node, field); - case TAG_MPEG4_FaceDefTransform: return FaceDefTransform_get_field(node, field); - case TAG_MPEG4_FAP: return FAP_get_field(node, field); - case TAG_MPEG4_FDP: return FDP_get_field(node, field); - case TAG_MPEG4_FIT: return FIT_get_field(node, field); - case TAG_MPEG4_Fog: return Fog_get_field(node, field); - case TAG_MPEG4_FontStyle: return FontStyle_get_field(node, field); - case TAG_MPEG4_Form: return Form_get_field(node, field); - case TAG_MPEG4_Group: return Group_get_field(node, field); - case TAG_MPEG4_ImageTexture: return ImageTexture_get_field(node, field); - case TAG_MPEG4_IndexedFaceSet: return IndexedFaceSet_get_field(node, field); - case TAG_MPEG4_IndexedFaceSet2D: return IndexedFaceSet2D_get_field(node, field); - case TAG_MPEG4_IndexedLineSet: return IndexedLineSet_get_field(node, field); - case TAG_MPEG4_IndexedLineSet2D: return IndexedLineSet2D_get_field(node, field); - case TAG_MPEG4_Inline: return Inline_get_field(node, field); - case TAG_MPEG4_LOD: return LOD_get_field(node, field); - case TAG_MPEG4_Layer2D: return Layer2D_get_field(node, field); - case TAG_MPEG4_Layer3D: return Layer3D_get_field(node, field); - case TAG_MPEG4_Layout: return Layout_get_field(node, field); - case TAG_MPEG4_LineProperties: return LineProperties_get_field(node, field); - case TAG_MPEG4_ListeningPoint: return ListeningPoint_get_field(node, field); - case TAG_MPEG4_Material: return Material_get_field(node, field); - case TAG_MPEG4_Material2D: return Material2D_get_field(node, field); - case TAG_MPEG4_MovieTexture: return MovieTexture_get_field(node, field); - case TAG_MPEG4_NavigationInfo: return NavigationInfo_get_field(node, field); - case TAG_MPEG4_Normal: return Normal_get_field(node, field); - case TAG_MPEG4_NormalInterpolator: return NormalInterpolator_get_field(node, field); - case TAG_MPEG4_OrderedGroup: return OrderedGroup_get_field(node, field); - case TAG_MPEG4_OrientationInterpolator: return OrientationInterpolator_get_field(node, field); - case TAG_MPEG4_PixelTexture: return PixelTexture_get_field(node, field); - case TAG_MPEG4_PlaneSensor: return PlaneSensor_get_field(node, field); - case TAG_MPEG4_PlaneSensor2D: return PlaneSensor2D_get_field(node, field); - case TAG_MPEG4_PointLight: return PointLight_get_field(node, field); - case TAG_MPEG4_PointSet: return PointSet_get_field(node, field); - case TAG_MPEG4_PointSet2D: return PointSet2D_get_field(node, field); - case TAG_MPEG4_PositionInterpolator: return PositionInterpolator_get_field(node, field); - case TAG_MPEG4_PositionInterpolator2D: return PositionInterpolator2D_get_field(node, field); - case TAG_MPEG4_ProximitySensor2D: return ProximitySensor2D_get_field(node, field); - case TAG_MPEG4_ProximitySensor: return ProximitySensor_get_field(node, field); - case TAG_MPEG4_QuantizationParameter: return QuantizationParameter_get_field(node, field); - case TAG_MPEG4_Rectangle: return Rectangle_get_field(node, field); - case TAG_MPEG4_ScalarInterpolator: return ScalarInterpolator_get_field(node, field); - case TAG_MPEG4_Script: return Script_get_field(node, field); - case TAG_MPEG4_Shape: return Shape_get_field(node, field); - case TAG_MPEG4_Sound: return Sound_get_field(node, field); - case TAG_MPEG4_Sound2D: return Sound2D_get_field(node, field); - case TAG_MPEG4_Sphere: return Sphere_get_field(node, field); - case TAG_MPEG4_SphereSensor: return SphereSensor_get_field(node, field); - case TAG_MPEG4_SpotLight: return SpotLight_get_field(node, field); - case TAG_MPEG4_Switch: return Switch_get_field(node, field); - case TAG_MPEG4_TermCap: return TermCap_get_field(node, field); - case TAG_MPEG4_Text: return Text_get_field(node, field); - case TAG_MPEG4_TextureCoordinate: return TextureCoordinate_get_field(node, field); - case TAG_MPEG4_TextureTransform: return TextureTransform_get_field(node, field); - case TAG_MPEG4_TimeSensor: return TimeSensor_get_field(node, field); - case TAG_MPEG4_TouchSensor: return TouchSensor_get_field(node, field); - case TAG_MPEG4_Transform: return Transform_get_field(node, field); - case TAG_MPEG4_Transform2D: return Transform2D_get_field(node, field); - case TAG_MPEG4_Valuator: return Valuator_get_field(node, field); - case TAG_MPEG4_Viewpoint: return Viewpoint_get_field(node, field); - case TAG_MPEG4_VisibilitySensor: return VisibilitySensor_get_field(node, field); - case TAG_MPEG4_Viseme: return Viseme_get_field(node, field); - case TAG_MPEG4_WorldInfo: return WorldInfo_get_field(node, field); - case TAG_MPEG4_AcousticMaterial: return AcousticMaterial_get_field(node, field); - case TAG_MPEG4_AcousticScene: return AcousticScene_get_field(node, field); - case TAG_MPEG4_ApplicationWindow: return ApplicationWindow_get_field(node, field); - case TAG_MPEG4_BAP: return BAP_get_field(node, field); - case TAG_MPEG4_BDP: return BDP_get_field(node, field); - case TAG_MPEG4_Body: return Body_get_field(node, field); - case TAG_MPEG4_BodyDefTable: return BodyDefTable_get_field(node, field); - case TAG_MPEG4_BodySegmentConnectionHint: return BodySegmentConnectionHint_get_field(node, field); - case TAG_MPEG4_DirectiveSound: return DirectiveSound_get_field(node, field); - case TAG_MPEG4_Hierarchical3DMesh: return Hierarchical3DMesh_get_field(node, field); - case TAG_MPEG4_MaterialKey: return MaterialKey_get_field(node, field); - case TAG_MPEG4_PerceptualParameters: return PerceptualParameters_get_field(node, field); - case TAG_MPEG4_TemporalTransform: return TemporalTransform_get_field(node, field); - case TAG_MPEG4_TemporalGroup: return TemporalGroup_get_field(node, field); - case TAG_MPEG4_ServerCommand: return ServerCommand_get_field(node, field); - case TAG_MPEG4_InputSensor: return InputSensor_get_field(node, field); - case TAG_MPEG4_MatteTexture: return MatteTexture_get_field(node, field); - case TAG_MPEG4_MediaBuffer: return MediaBuffer_get_field(node, field); - case TAG_MPEG4_MediaControl: return MediaControl_get_field(node, field); - case TAG_MPEG4_MediaSensor: return MediaSensor_get_field(node, field); - case TAG_MPEG4_BitWrapper: return BitWrapper_get_field(node, field); - case TAG_MPEG4_CoordinateInterpolator4D: return CoordinateInterpolator4D_get_field(node, field); - case TAG_MPEG4_DepthImage: return DepthImage_get_field(node, field); - case TAG_MPEG4_FFD: return FFD_get_field(node, field); - case TAG_MPEG4_Implicit: return Implicit_get_field(node, field); - case TAG_MPEG4_XXLFM_Appearance: return XXLFM_Appearance_get_field(node, field); - case TAG_MPEG4_XXLFM_BlendList: return XXLFM_BlendList_get_field(node, field); - case TAG_MPEG4_XXLFM_FrameList: return XXLFM_FrameList_get_field(node, field); - case TAG_MPEG4_XXLFM_LightMap: return XXLFM_LightMap_get_field(node, field); - case TAG_MPEG4_XXLFM_SurfaceMapList: return XXLFM_SurfaceMapList_get_field(node, field); - case TAG_MPEG4_XXLFM_ViewMapList: return XXLFM_ViewMapList_get_field(node, field); - case TAG_MPEG4_MeshGrid: return MeshGrid_get_field(node, field); - case TAG_MPEG4_NonLinearDeformer: return NonLinearDeformer_get_field(node, field); - case TAG_MPEG4_NurbsCurve: return NurbsCurve_get_field(node, field); - case TAG_MPEG4_NurbsCurve2D: return NurbsCurve2D_get_field(node, field); - case TAG_MPEG4_NurbsSurface: return NurbsSurface_get_field(node, field); - case TAG_MPEG4_OctreeImage: return OctreeImage_get_field(node, field); - case TAG_MPEG4_XXParticles: return XXParticles_get_field(node, field); - case TAG_MPEG4_XXParticleInitBox: return XXParticleInitBox_get_field(node, field); - case TAG_MPEG4_XXPlanarObstacle: return XXPlanarObstacle_get_field(node, field); - case TAG_MPEG4_XXPointAttractor: return XXPointAttractor_get_field(node, field); - case TAG_MPEG4_PointTexture: return PointTexture_get_field(node, field); - case TAG_MPEG4_PositionAnimator: return PositionAnimator_get_field(node, field); - case TAG_MPEG4_PositionAnimator2D: return PositionAnimator2D_get_field(node, field); - case TAG_MPEG4_PositionInterpolator4D: return PositionInterpolator4D_get_field(node, field); - case TAG_MPEG4_ProceduralTexture: return ProceduralTexture_get_field(node, field); - case TAG_MPEG4_Quadric: return Quadric_get_field(node, field); - case TAG_MPEG4_SBBone: return SBBone_get_field(node, field); - case TAG_MPEG4_SBMuscle: return SBMuscle_get_field(node, field); - case TAG_MPEG4_SBSegment: return SBSegment_get_field(node, field); - case TAG_MPEG4_SBSite: return SBSite_get_field(node, field); - case TAG_MPEG4_SBSkinnedModel: return SBSkinnedModel_get_field(node, field); - case TAG_MPEG4_SBVCAnimation: return SBVCAnimation_get_field(node, field); - case TAG_MPEG4_ScalarAnimator: return ScalarAnimator_get_field(node, field); - case TAG_MPEG4_SimpleTexture: return SimpleTexture_get_field(node, field); - case TAG_MPEG4_SolidRep: return SolidRep_get_field(node, field); - case TAG_MPEG4_SubdivisionSurface: return SubdivisionSurface_get_field(node, field); - case TAG_MPEG4_SubdivSurfaceSector: return SubdivSurfaceSector_get_field(node, field); - case TAG_MPEG4_WaveletSubdivisionSurface: return WaveletSubdivisionSurface_get_field(node, field); - case TAG_MPEG4_Clipper2D: return Clipper2D_get_field(node, field); - case TAG_MPEG4_ColorTransform: return ColorTransform_get_field(node, field); - case TAG_MPEG4_Ellipse: return Ellipse_get_field(node, field); - case TAG_MPEG4_LinearGradient: return LinearGradient_get_field(node, field); - case TAG_MPEG4_PathLayout: return PathLayout_get_field(node, field); - case TAG_MPEG4_RadialGradient: return RadialGradient_get_field(node, field); - case TAG_MPEG4_SynthesizedTexture: return SynthesizedTexture_get_field(node, field); - case TAG_MPEG4_TransformMatrix2D: return TransformMatrix2D_get_field(node, field); - case TAG_MPEG4_Viewport: return Viewport_get_field(node, field); - case TAG_MPEG4_XCurve2D: return XCurve2D_get_field(node, field); - case TAG_MPEG4_XFontStyle: return XFontStyle_get_field(node, field); - case TAG_MPEG4_XLineProperties: return XLineProperties_get_field(node, field); - case TAG_MPEG4_AdvancedAudioBuffer: return AdvancedAudioBuffer_get_field(node, field); - case TAG_MPEG4_AudioChannelConfig: return AudioChannelConfig_get_field(node, field); - case TAG_MPEG4_DepthImageV2: return DepthImageV2_get_field(node, field); - case TAG_MPEG4_MorphShape: return MorphShape_get_field(node, field); - case TAG_MPEG4_MultiTexture: return MultiTexture_get_field(node, field); - case TAG_MPEG4_PointTextureV2: return PointTextureV2_get_field(node, field); - case TAG_MPEG4_SBVCAnimationV2: return SBVCAnimationV2_get_field(node, field); - case TAG_MPEG4_SimpleTextureV2: return SimpleTextureV2_get_field(node, field); - case TAG_MPEG4_SurroundingSound: return SurroundingSound_get_field(node, field); - case TAG_MPEG4_Transform3DAudio: return Transform3DAudio_get_field(node, field); - case TAG_MPEG4_WideSound: return WideSound_get_field(node, field); - case TAG_MPEG4_ScoreShape: return ScoreShape_get_field(node, field); - case TAG_MPEG4_MusicScore: return MusicScore_get_field(node, field); - case TAG_MPEG4_FootPrintSetNode: return FootPrintSetNode_get_field(node, field); - case TAG_MPEG4_FootPrintNode: return FootPrintNode_get_field(node, field); - case TAG_MPEG4_BuildingPartNode: return BuildingPartNode_get_field(node, field); - case TAG_MPEG4_RoofNode: return RoofNode_get_field(node, field); - case TAG_MPEG4_FacadeNode: return FacadeNode_get_field(node, field); - case TAG_MPEG4_Shadow: return Shadow_get_field(node, field); - case TAG_MPEG4_CacheTexture: return CacheTexture_get_field(node, field); - case TAG_MPEG4_EnvironmentTest: return EnvironmentTest_get_field(node, field); - case TAG_MPEG4_KeyNavigator: return KeyNavigator_get_field(node, field); - case TAG_MPEG4_SpacePartition: return SpacePartition_get_field(node, field); - case TAG_MPEG4_Storage: return Storage_get_field(node, field); - default: - return GF_BAD_PARAM; - } -} - -GF_Err gf_sg_mpeg4_node_get_field_index(GF_Node *node, u32 inField, u8 code_mode, u32 *fieldIndex) -{ - switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor: return Anchor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AnimationStream: return AnimationStream_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Appearance: return Appearance_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioBuffer: return AudioBuffer_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioClip: return AudioClip_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioDelay: return AudioDelay_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioFX: return AudioFX_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioMix: return AudioMix_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioSource: return AudioSource_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioSwitch: return AudioSwitch_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Background: return Background_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Background2D: return Background2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Billboard: return Billboard_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Bitmap: return Bitmap_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Box: return Box_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Circle: return Circle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Collision: return Collision_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Color: return Color_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ColorInterpolator: return ColorInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CompositeTexture2D: return CompositeTexture2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CompositeTexture3D: return CompositeTexture3D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Conditional: return Conditional_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Cone: return Cone_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Coordinate: return Coordinate_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Coordinate2D: return Coordinate2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CoordinateInterpolator: return CoordinateInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Curve2D: return Curve2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Cylinder: return Cylinder_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CylinderSensor: return CylinderSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_DirectionalLight: return DirectionalLight_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_DiscSensor: return DiscSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ElevationGrid: return ElevationGrid_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Expression: return Expression_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Extrusion: return Extrusion_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Face: return Face_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FaceDefMesh: return FaceDefMesh_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FaceDefTables: return FaceDefTables_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FaceDefTransform: return FaceDefTransform_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FAP: return FAP_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FDP: return FDP_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FIT: return FIT_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Fog: return Fog_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FontStyle: return FontStyle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Form: return Form_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Group: return Group_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ImageTexture: return ImageTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_IndexedFaceSet: return IndexedFaceSet_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_IndexedFaceSet2D: return IndexedFaceSet2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_IndexedLineSet: return IndexedLineSet_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_IndexedLineSet2D: return IndexedLineSet2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Inline: return Inline_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_LOD: return LOD_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Layer2D: return Layer2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Layer3D: return Layer3D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Layout: return Layout_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_LineProperties: return LineProperties_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ListeningPoint: return ListeningPoint_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Material: return Material_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Material2D: return Material2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MovieTexture: return MovieTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NavigationInfo: return NavigationInfo_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Normal: return Normal_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NormalInterpolator: return NormalInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_OrderedGroup: return OrderedGroup_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_OrientationInterpolator: return OrientationInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PixelTexture: return PixelTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PlaneSensor: return PlaneSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PlaneSensor2D: return PlaneSensor2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PointLight: return PointLight_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PointSet: return PointSet_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PointSet2D: return PointSet2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PositionInterpolator: return PositionInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PositionInterpolator2D: return PositionInterpolator2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ProximitySensor2D: return ProximitySensor2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ProximitySensor: return ProximitySensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_QuantizationParameter: return QuantizationParameter_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Rectangle: return Rectangle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ScalarInterpolator: return ScalarInterpolator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Script: return Script_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Shape: return Shape_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Sound: return Sound_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Sound2D: return Sound2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Sphere: return Sphere_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SphereSensor: return SphereSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SpotLight: return SpotLight_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Switch: return Switch_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TermCap: return TermCap_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Text: return Text_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TextureCoordinate: return TextureCoordinate_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TextureTransform: return TextureTransform_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TimeSensor: return TimeSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TouchSensor: return TouchSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Transform: return Transform_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Transform2D: return Transform2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Valuator: return Valuator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Viewpoint: return Viewpoint_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_VisibilitySensor: return VisibilitySensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Viseme: return Viseme_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_WorldInfo: return WorldInfo_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AcousticMaterial: return AcousticMaterial_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AcousticScene: return AcousticScene_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ApplicationWindow: return ApplicationWindow_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BAP: return BAP_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BDP: return BDP_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Body: return Body_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BodyDefTable: return BodyDefTable_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BodySegmentConnectionHint: return BodySegmentConnectionHint_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_DirectiveSound: return DirectiveSound_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Hierarchical3DMesh: return Hierarchical3DMesh_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MaterialKey: return MaterialKey_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PerceptualParameters: return PerceptualParameters_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TemporalTransform: return TemporalTransform_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TemporalGroup: return TemporalGroup_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ServerCommand: return ServerCommand_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_InputSensor: return InputSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MatteTexture: return MatteTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MediaBuffer: return MediaBuffer_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MediaControl: return MediaControl_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MediaSensor: return MediaSensor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BitWrapper: return BitWrapper_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CoordinateInterpolator4D: return CoordinateInterpolator4D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_DepthImage: return DepthImage_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FFD: return FFD_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Implicit: return Implicit_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_Appearance: return XXLFM_Appearance_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_BlendList: return XXLFM_BlendList_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_FrameList: return XXLFM_FrameList_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_LightMap: return XXLFM_LightMap_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_SurfaceMapList: return XXLFM_SurfaceMapList_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXLFM_ViewMapList: return XXLFM_ViewMapList_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MeshGrid: return MeshGrid_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NonLinearDeformer: return NonLinearDeformer_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NurbsCurve: return NurbsCurve_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NurbsCurve2D: return NurbsCurve2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_NurbsSurface: return NurbsSurface_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_OctreeImage: return OctreeImage_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXParticles: return XXParticles_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXParticleInitBox: return XXParticleInitBox_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXPlanarObstacle: return XXPlanarObstacle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XXPointAttractor: return XXPointAttractor_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PointTexture: return PointTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PositionAnimator: return PositionAnimator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PositionAnimator2D: return PositionAnimator2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PositionInterpolator4D: return PositionInterpolator4D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ProceduralTexture: return ProceduralTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Quadric: return Quadric_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBBone: return SBBone_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBMuscle: return SBMuscle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBSegment: return SBSegment_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBSite: return SBSite_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBSkinnedModel: return SBSkinnedModel_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBVCAnimation: return SBVCAnimation_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ScalarAnimator: return ScalarAnimator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SimpleTexture: return SimpleTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SolidRep: return SolidRep_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SubdivisionSurface: return SubdivisionSurface_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SubdivSurfaceSector: return SubdivSurfaceSector_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_WaveletSubdivisionSurface: return WaveletSubdivisionSurface_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Clipper2D: return Clipper2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ColorTransform: return ColorTransform_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Ellipse: return Ellipse_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_LinearGradient: return LinearGradient_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PathLayout: return PathLayout_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_RadialGradient: return RadialGradient_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SynthesizedTexture: return SynthesizedTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_TransformMatrix2D: return TransformMatrix2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Viewport: return Viewport_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XCurve2D: return XCurve2D_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XFontStyle: return XFontStyle_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_XLineProperties: return XLineProperties_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AdvancedAudioBuffer: return AdvancedAudioBuffer_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_AudioChannelConfig: return AudioChannelConfig_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_DepthImageV2: return DepthImageV2_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MorphShape: return MorphShape_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MultiTexture: return MultiTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_PointTextureV2: return PointTextureV2_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SBVCAnimationV2: return SBVCAnimationV2_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SimpleTextureV2: return SimpleTextureV2_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SurroundingSound: return SurroundingSound_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Transform3DAudio: return Transform3DAudio_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_WideSound: return WideSound_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_ScoreShape: return ScoreShape_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_MusicScore: return MusicScore_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FootPrintSetNode: return FootPrintSetNode_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FootPrintNode: return FootPrintNode_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_BuildingPartNode: return BuildingPartNode_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_RoofNode: return RoofNode_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_FacadeNode: return FacadeNode_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Shadow: return Shadow_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_CacheTexture: return CacheTexture_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_EnvironmentTest: return EnvironmentTest_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_KeyNavigator: return KeyNavigator_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_SpacePartition: return SpacePartition_get_field_index(node, inField, code_mode, fieldIndex); - case TAG_MPEG4_Storage: return Storage_get_field_index(node, inField, code_mode, fieldIndex); - default: - return GF_BAD_PARAM; - } -} - -Bool gf_sg_mpeg4_node_get_aq_info(GF_Node *node, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) -{ - switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor: return Anchor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AnimationStream: return AnimationStream_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Appearance: return Appearance_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioBuffer: return AudioBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioClip: return AudioClip_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioDelay: return AudioDelay_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioFX: return AudioFX_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioMix: return AudioMix_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioSource: return AudioSource_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioSwitch: return AudioSwitch_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Background: return Background_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Background2D: return Background2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Billboard: return Billboard_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Bitmap: return Bitmap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Box: return Box_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Circle: return Circle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Collision: return Collision_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Color: return Color_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ColorInterpolator: return ColorInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CompositeTexture2D: return CompositeTexture2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CompositeTexture3D: return CompositeTexture3D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Conditional: return Conditional_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Cone: return Cone_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Coordinate: return Coordinate_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Coordinate2D: return Coordinate2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CoordinateInterpolator: return CoordinateInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Curve2D: return Curve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Cylinder: return Cylinder_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CylinderSensor: return CylinderSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_DirectionalLight: return DirectionalLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_DiscSensor: return DiscSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ElevationGrid: return ElevationGrid_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Expression: return Expression_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Extrusion: return Extrusion_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Face: return Face_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FaceDefMesh: return FaceDefMesh_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FaceDefTables: return FaceDefTables_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FaceDefTransform: return FaceDefTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FAP: return FAP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FDP: return FDP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FIT: return FIT_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Fog: return Fog_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FontStyle: return FontStyle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Form: return Form_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Group: return Group_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ImageTexture: return ImageTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_IndexedFaceSet: return IndexedFaceSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_IndexedFaceSet2D: return IndexedFaceSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_IndexedLineSet: return IndexedLineSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_IndexedLineSet2D: return IndexedLineSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Inline: return Inline_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_LOD: return LOD_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Layer2D: return Layer2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Layer3D: return Layer3D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Layout: return Layout_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_LineProperties: return LineProperties_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ListeningPoint: return ListeningPoint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Material: return Material_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Material2D: return Material2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MovieTexture: return MovieTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NavigationInfo: return NavigationInfo_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Normal: return Normal_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NormalInterpolator: return NormalInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_OrderedGroup: return OrderedGroup_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_OrientationInterpolator: return OrientationInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PixelTexture: return PixelTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PlaneSensor: return PlaneSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PlaneSensor2D: return PlaneSensor2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PointLight: return PointLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PointSet: return PointSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PointSet2D: return PointSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PositionInterpolator: return PositionInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PositionInterpolator2D: return PositionInterpolator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ProximitySensor2D: return ProximitySensor2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ProximitySensor: return ProximitySensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_QuantizationParameter: return QuantizationParameter_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Rectangle: return Rectangle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ScalarInterpolator: return ScalarInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Script: return Script_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Shape: return Shape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Sound: return Sound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Sound2D: return Sound2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Sphere: return Sphere_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SphereSensor: return SphereSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SpotLight: return SpotLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Switch: return Switch_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TermCap: return TermCap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Text: return Text_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TextureCoordinate: return TextureCoordinate_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TextureTransform: return TextureTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TimeSensor: return TimeSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TouchSensor: return TouchSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Transform: return Transform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Transform2D: return Transform2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Valuator: return Valuator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Viewpoint: return Viewpoint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_VisibilitySensor: return VisibilitySensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Viseme: return Viseme_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_WorldInfo: return WorldInfo_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AcousticMaterial: return AcousticMaterial_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AcousticScene: return AcousticScene_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ApplicationWindow: return ApplicationWindow_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BAP: return BAP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BDP: return BDP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Body: return Body_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BodyDefTable: return BodyDefTable_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BodySegmentConnectionHint: return BodySegmentConnectionHint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_DirectiveSound: return DirectiveSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Hierarchical3DMesh: return Hierarchical3DMesh_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MaterialKey: return MaterialKey_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PerceptualParameters: return PerceptualParameters_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TemporalTransform: return TemporalTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TemporalGroup: return TemporalGroup_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ServerCommand: return ServerCommand_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_InputSensor: return InputSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MatteTexture: return MatteTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MediaBuffer: return MediaBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MediaControl: return MediaControl_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MediaSensor: return MediaSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BitWrapper: return BitWrapper_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CoordinateInterpolator4D: return CoordinateInterpolator4D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_DepthImage: return DepthImage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FFD: return FFD_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Implicit: return Implicit_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_Appearance: return XXLFM_Appearance_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_BlendList: return XXLFM_BlendList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_FrameList: return XXLFM_FrameList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_LightMap: return XXLFM_LightMap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_SurfaceMapList: return XXLFM_SurfaceMapList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXLFM_ViewMapList: return XXLFM_ViewMapList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MeshGrid: return MeshGrid_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NonLinearDeformer: return NonLinearDeformer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NurbsCurve: return NurbsCurve_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NurbsCurve2D: return NurbsCurve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_NurbsSurface: return NurbsSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_OctreeImage: return OctreeImage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXParticles: return XXParticles_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXParticleInitBox: return XXParticleInitBox_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXPlanarObstacle: return XXPlanarObstacle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XXPointAttractor: return XXPointAttractor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PointTexture: return PointTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PositionAnimator: return PositionAnimator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PositionAnimator2D: return PositionAnimator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PositionInterpolator4D: return PositionInterpolator4D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ProceduralTexture: return ProceduralTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Quadric: return Quadric_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBBone: return SBBone_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBMuscle: return SBMuscle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBSegment: return SBSegment_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBSite: return SBSite_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBSkinnedModel: return SBSkinnedModel_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBVCAnimation: return SBVCAnimation_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ScalarAnimator: return ScalarAnimator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SimpleTexture: return SimpleTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SolidRep: return SolidRep_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SubdivisionSurface: return SubdivisionSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SubdivSurfaceSector: return SubdivSurfaceSector_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_WaveletSubdivisionSurface: return WaveletSubdivisionSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Clipper2D: return Clipper2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ColorTransform: return ColorTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Ellipse: return Ellipse_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_LinearGradient: return LinearGradient_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PathLayout: return PathLayout_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_RadialGradient: return RadialGradient_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SynthesizedTexture: return SynthesizedTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_TransformMatrix2D: return TransformMatrix2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Viewport: return Viewport_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XCurve2D: return XCurve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XFontStyle: return XFontStyle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_XLineProperties: return XLineProperties_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AdvancedAudioBuffer: return AdvancedAudioBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_AudioChannelConfig: return AudioChannelConfig_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_DepthImageV2: return DepthImageV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MorphShape: return MorphShape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MultiTexture: return MultiTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_PointTextureV2: return PointTextureV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SBVCAnimationV2: return SBVCAnimationV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SimpleTextureV2: return SimpleTextureV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SurroundingSound: return SurroundingSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Transform3DAudio: return Transform3DAudio_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_WideSound: return WideSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_ScoreShape: return ScoreShape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_MusicScore: return MusicScore_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FootPrintSetNode: return FootPrintSetNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FootPrintNode: return FootPrintNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_BuildingPartNode: return BuildingPartNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_RoofNode: return RoofNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_FacadeNode: return FacadeNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Shadow: return Shadow_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_CacheTexture: return CacheTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_EnvironmentTest: return EnvironmentTest_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_KeyNavigator: return KeyNavigator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_SpacePartition: return SpacePartition_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - case TAG_MPEG4_Storage: return Storage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); - default: - return 0; - } -} - -u32 gf_sg_mpeg4_node_get_child_ndt(GF_Node *node) -{ - switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor: return NDT_SF3DNode; - case TAG_MPEG4_AudioBuffer: return NDT_SFAudioNode; - case TAG_MPEG4_AudioDelay: return NDT_SFAudioNode; - case TAG_MPEG4_AudioFX: return NDT_SFAudioNode; - case TAG_MPEG4_AudioMix: return NDT_SFAudioNode; - case TAG_MPEG4_AudioSource: return NDT_SFAudioNode; - case TAG_MPEG4_AudioSwitch: return NDT_SFAudioNode; - case TAG_MPEG4_Billboard: return NDT_SF3DNode; - case TAG_MPEG4_Collision: return NDT_SF3DNode; - case TAG_MPEG4_CompositeTexture2D: return NDT_SF2DNode; - case TAG_MPEG4_CompositeTexture3D: return NDT_SF3DNode; - case TAG_MPEG4_Face: return NDT_SF3DNode; - case TAG_MPEG4_FaceDefTables: return NDT_SFFaceDefMeshNode; - case TAG_MPEG4_FDP: return NDT_SFFaceDefTablesNode; - case TAG_MPEG4_Form: return NDT_SF2DNode; - case TAG_MPEG4_Group: return NDT_SF3DNode; - case TAG_MPEG4_LOD: return NDT_SF3DNode; - case TAG_MPEG4_Layer2D: return NDT_SF2DNode; - case TAG_MPEG4_Layer3D: return NDT_SF3DNode; - case TAG_MPEG4_Layout: return NDT_SF2DNode; - case TAG_MPEG4_OrderedGroup: return NDT_SF3DNode; - case TAG_MPEG4_Switch: return NDT_SF3DNode; - case TAG_MPEG4_Transform: return NDT_SF3DNode; - case TAG_MPEG4_Transform2D: return NDT_SF2DNode; - case TAG_MPEG4_BDP: return NDT_SFBodyDefTableNode; - case TAG_MPEG4_Body: return NDT_SF3DNode; - case TAG_MPEG4_TemporalTransform: return NDT_SF3DNode; - case TAG_MPEG4_TemporalGroup: return NDT_SFTemporalNode; - case TAG_MPEG4_FFD: return NDT_SF3DNode; - case TAG_MPEG4_XXLFM_Appearance: return NDT_SFLightMapNode; - case TAG_MPEG4_OctreeImage: return NDT_SFDepthImageNode; - case TAG_MPEG4_XXParticles: return NDT_SFInfluenceNode; - case TAG_MPEG4_SBBone: return NDT_SF3DNode; - case TAG_MPEG4_SBSegment: return NDT_SF3DNode; - case TAG_MPEG4_SBSite: return NDT_SF3DNode; - case TAG_MPEG4_SBSkinnedModel: return NDT_SFSBBoneNode; - case TAG_MPEG4_SBVCAnimation: return NDT_SF3DNode; - case TAG_MPEG4_SubdivisionSurface: return NDT_SFSubdivSurfaceSectorNode; - case TAG_MPEG4_Clipper2D: return NDT_SF2DNode; - case TAG_MPEG4_ColorTransform: return NDT_SF3DNode; - case TAG_MPEG4_PathLayout: return NDT_SF2DNode; - case TAG_MPEG4_TransformMatrix2D: return NDT_SF2DNode; - case TAG_MPEG4_AdvancedAudioBuffer: return NDT_SFAudioNode; - case TAG_MPEG4_AudioChannelConfig: return NDT_SFAudioNode; - case TAG_MPEG4_MorphShape: return NDT_SF3DNode; - case TAG_MPEG4_MultiTexture: return NDT_SFTextureNode; - case TAG_MPEG4_SBVCAnimationV2: return NDT_SF3DNode; - case TAG_MPEG4_Transform3DAudio: return NDT_SF3DNode; - case TAG_MPEG4_FootPrintSetNode: return NDT_SFGeometryNode; - case TAG_MPEG4_BuildingPartNode: return NDT_SFGeometryNode; - case TAG_MPEG4_FacadeNode: return NDT_SFGeometryNode; - case TAG_MPEG4_Shadow: return NDT_SF3DNode; - case TAG_MPEG4_SpacePartition: return NDT_SF3DNode; - default: - return 0; - } -} - - -GF_EXPORT -u32 gf_node_mpeg4_type_by_class_name(const char *node_name) -{ - if(!node_name) return 0; - if (!strcmp(node_name, "Anchor")) return TAG_MPEG4_Anchor; - if (!strcmp(node_name, "AnimationStream")) return TAG_MPEG4_AnimationStream; - if (!strcmp(node_name, "Appearance")) return TAG_MPEG4_Appearance; - if (!strcmp(node_name, "AudioBuffer")) return TAG_MPEG4_AudioBuffer; - if (!strcmp(node_name, "AudioClip")) return TAG_MPEG4_AudioClip; - if (!strcmp(node_name, "AudioDelay")) return TAG_MPEG4_AudioDelay; - if (!strcmp(node_name, "AudioFX")) return TAG_MPEG4_AudioFX; - if (!strcmp(node_name, "AudioMix")) return TAG_MPEG4_AudioMix; - if (!strcmp(node_name, "AudioSource")) return TAG_MPEG4_AudioSource; - if (!strcmp(node_name, "AudioSwitch")) return TAG_MPEG4_AudioSwitch; - if (!strcmp(node_name, "Background")) return TAG_MPEG4_Background; - if (!strcmp(node_name, "Background2D")) return TAG_MPEG4_Background2D; - if (!strcmp(node_name, "Billboard")) return TAG_MPEG4_Billboard; - if (!strcmp(node_name, "Bitmap")) return TAG_MPEG4_Bitmap; - if (!strcmp(node_name, "Box")) return TAG_MPEG4_Box; - if (!strcmp(node_name, "Circle")) return TAG_MPEG4_Circle; - if (!strcmp(node_name, "Collision")) return TAG_MPEG4_Collision; - if (!strcmp(node_name, "Color")) return TAG_MPEG4_Color; - if (!strcmp(node_name, "ColorInterpolator")) return TAG_MPEG4_ColorInterpolator; - if (!strcmp(node_name, "CompositeTexture2D")) return TAG_MPEG4_CompositeTexture2D; - if (!strcmp(node_name, "CompositeTexture3D")) return TAG_MPEG4_CompositeTexture3D; - if (!strcmp(node_name, "Conditional")) return TAG_MPEG4_Conditional; - if (!strcmp(node_name, "Cone")) return TAG_MPEG4_Cone; - if (!strcmp(node_name, "Coordinate")) return TAG_MPEG4_Coordinate; - if (!strcmp(node_name, "Coordinate2D")) return TAG_MPEG4_Coordinate2D; - if (!strcmp(node_name, "CoordinateInterpolator")) return TAG_MPEG4_CoordinateInterpolator; - if (!strcmp(node_name, "CoordinateInterpolator2D")) return TAG_MPEG4_CoordinateInterpolator2D; - if (!strcmp(node_name, "Curve2D")) return TAG_MPEG4_Curve2D; - if (!strcmp(node_name, "Cylinder")) return TAG_MPEG4_Cylinder; - if (!strcmp(node_name, "CylinderSensor")) return TAG_MPEG4_CylinderSensor; - if (!strcmp(node_name, "DirectionalLight")) return TAG_MPEG4_DirectionalLight; - if (!strcmp(node_name, "DiscSensor")) return TAG_MPEG4_DiscSensor; - if (!strcmp(node_name, "ElevationGrid")) return TAG_MPEG4_ElevationGrid; - if (!strcmp(node_name, "Expression")) return TAG_MPEG4_Expression; - if (!strcmp(node_name, "Extrusion")) return TAG_MPEG4_Extrusion; - if (!strcmp(node_name, "Face")) return TAG_MPEG4_Face; - if (!strcmp(node_name, "FaceDefMesh")) return TAG_MPEG4_FaceDefMesh; - if (!strcmp(node_name, "FaceDefTables")) return TAG_MPEG4_FaceDefTables; - if (!strcmp(node_name, "FaceDefTransform")) return TAG_MPEG4_FaceDefTransform; - if (!strcmp(node_name, "FAP")) return TAG_MPEG4_FAP; - if (!strcmp(node_name, "FDP")) return TAG_MPEG4_FDP; - if (!strcmp(node_name, "FIT")) return TAG_MPEG4_FIT; - if (!strcmp(node_name, "Fog")) return TAG_MPEG4_Fog; - if (!strcmp(node_name, "FontStyle")) return TAG_MPEG4_FontStyle; - if (!strcmp(node_name, "Form")) return TAG_MPEG4_Form; - if (!strcmp(node_name, "Group")) return TAG_MPEG4_Group; - if (!strcmp(node_name, "ImageTexture")) return TAG_MPEG4_ImageTexture; - if (!strcmp(node_name, "IndexedFaceSet")) return TAG_MPEG4_IndexedFaceSet; - if (!strcmp(node_name, "IndexedFaceSet2D")) return TAG_MPEG4_IndexedFaceSet2D; - if (!strcmp(node_name, "IndexedLineSet")) return TAG_MPEG4_IndexedLineSet; - if (!strcmp(node_name, "IndexedLineSet2D")) return TAG_MPEG4_IndexedLineSet2D; - if (!strcmp(node_name, "Inline")) return TAG_MPEG4_Inline; - if (!strcmp(node_name, "LOD")) return TAG_MPEG4_LOD; - if (!strcmp(node_name, "Layer2D")) return TAG_MPEG4_Layer2D; - if (!strcmp(node_name, "Layer3D")) return TAG_MPEG4_Layer3D; - if (!strcmp(node_name, "Layout")) return TAG_MPEG4_Layout; - if (!strcmp(node_name, "LineProperties")) return TAG_MPEG4_LineProperties; - if (!strcmp(node_name, "ListeningPoint")) return TAG_MPEG4_ListeningPoint; - if (!strcmp(node_name, "Material")) return TAG_MPEG4_Material; - if (!strcmp(node_name, "Material2D")) return TAG_MPEG4_Material2D; - if (!strcmp(node_name, "MovieTexture")) return TAG_MPEG4_MovieTexture; - if (!strcmp(node_name, "NavigationInfo")) return TAG_MPEG4_NavigationInfo; - if (!strcmp(node_name, "Normal")) return TAG_MPEG4_Normal; - if (!strcmp(node_name, "NormalInterpolator")) return TAG_MPEG4_NormalInterpolator; - if (!strcmp(node_name, "OrderedGroup")) return TAG_MPEG4_OrderedGroup; - if (!strcmp(node_name, "OrientationInterpolator")) return TAG_MPEG4_OrientationInterpolator; - if (!strcmp(node_name, "PixelTexture")) return TAG_MPEG4_PixelTexture; - if (!strcmp(node_name, "PlaneSensor")) return TAG_MPEG4_PlaneSensor; - if (!strcmp(node_name, "PlaneSensor2D")) return TAG_MPEG4_PlaneSensor2D; - if (!strcmp(node_name, "PointLight")) return TAG_MPEG4_PointLight; - if (!strcmp(node_name, "PointSet")) return TAG_MPEG4_PointSet; - if (!strcmp(node_name, "PointSet2D")) return TAG_MPEG4_PointSet2D; - if (!strcmp(node_name, "PositionInterpolator")) return TAG_MPEG4_PositionInterpolator; - if (!strcmp(node_name, "PositionInterpolator2D")) return TAG_MPEG4_PositionInterpolator2D; - if (!strcmp(node_name, "ProximitySensor2D")) return TAG_MPEG4_ProximitySensor2D; - if (!strcmp(node_name, "ProximitySensor")) return TAG_MPEG4_ProximitySensor; - if (!strcmp(node_name, "QuantizationParameter")) return TAG_MPEG4_QuantizationParameter; - if (!strcmp(node_name, "Rectangle")) return TAG_MPEG4_Rectangle; - if (!strcmp(node_name, "ScalarInterpolator")) return TAG_MPEG4_ScalarInterpolator; - if (!strcmp(node_name, "Script")) return TAG_MPEG4_Script; - if (!strcmp(node_name, "Shape")) return TAG_MPEG4_Shape; - if (!strcmp(node_name, "Sound")) return TAG_MPEG4_Sound; - if (!strcmp(node_name, "Sound2D")) return TAG_MPEG4_Sound2D; - if (!strcmp(node_name, "Sphere")) return TAG_MPEG4_Sphere; - if (!strcmp(node_name, "SphereSensor")) return TAG_MPEG4_SphereSensor; - if (!strcmp(node_name, "SpotLight")) return TAG_MPEG4_SpotLight; - if (!strcmp(node_name, "Switch")) return TAG_MPEG4_Switch; - if (!strcmp(node_name, "TermCap")) return TAG_MPEG4_TermCap; - if (!strcmp(node_name, "Text")) return TAG_MPEG4_Text; - if (!strcmp(node_name, "TextureCoordinate")) return TAG_MPEG4_TextureCoordinate; - if (!strcmp(node_name, "TextureTransform")) return TAG_MPEG4_TextureTransform; - if (!strcmp(node_name, "TimeSensor")) return TAG_MPEG4_TimeSensor; - if (!strcmp(node_name, "TouchSensor")) return TAG_MPEG4_TouchSensor; - if (!strcmp(node_name, "Transform")) return TAG_MPEG4_Transform; - if (!strcmp(node_name, "Transform2D")) return TAG_MPEG4_Transform2D; - if (!strcmp(node_name, "Valuator")) return TAG_MPEG4_Valuator; - if (!strcmp(node_name, "Viewpoint")) return TAG_MPEG4_Viewpoint; - if (!strcmp(node_name, "VisibilitySensor")) return TAG_MPEG4_VisibilitySensor; - if (!strcmp(node_name, "Viseme")) return TAG_MPEG4_Viseme; - if (!strcmp(node_name, "WorldInfo")) return TAG_MPEG4_WorldInfo; - if (!strcmp(node_name, "AcousticMaterial")) return TAG_MPEG4_AcousticMaterial; - if (!strcmp(node_name, "AcousticScene")) return TAG_MPEG4_AcousticScene; - if (!strcmp(node_name, "ApplicationWindow")) return TAG_MPEG4_ApplicationWindow; - if (!strcmp(node_name, "BAP")) return TAG_MPEG4_BAP; - if (!strcmp(node_name, "BDP")) return TAG_MPEG4_BDP; - if (!strcmp(node_name, "Body")) return TAG_MPEG4_Body; - if (!strcmp(node_name, "BodyDefTable")) return TAG_MPEG4_BodyDefTable; - if (!strcmp(node_name, "BodySegmentConnectionHint")) return TAG_MPEG4_BodySegmentConnectionHint; - if (!strcmp(node_name, "DirectiveSound")) return TAG_MPEG4_DirectiveSound; - if (!strcmp(node_name, "Hierarchical3DMesh")) return TAG_MPEG4_Hierarchical3DMesh; - if (!strcmp(node_name, "MaterialKey")) return TAG_MPEG4_MaterialKey; - if (!strcmp(node_name, "PerceptualParameters")) return TAG_MPEG4_PerceptualParameters; - if (!strcmp(node_name, "TemporalTransform")) return TAG_MPEG4_TemporalTransform; - if (!strcmp(node_name, "TemporalGroup")) return TAG_MPEG4_TemporalGroup; - if (!strcmp(node_name, "ServerCommand")) return TAG_MPEG4_ServerCommand; - if (!strcmp(node_name, "InputSensor")) return TAG_MPEG4_InputSensor; - if (!strcmp(node_name, "MatteTexture")) return TAG_MPEG4_MatteTexture; - if (!strcmp(node_name, "MediaBuffer")) return TAG_MPEG4_MediaBuffer; - if (!strcmp(node_name, "MediaControl")) return TAG_MPEG4_MediaControl; - if (!strcmp(node_name, "MediaSensor")) return TAG_MPEG4_MediaSensor; - if (!strcmp(node_name, "BitWrapper")) return TAG_MPEG4_BitWrapper; - if (!strcmp(node_name, "CoordinateInterpolator4D")) return TAG_MPEG4_CoordinateInterpolator4D; - if (!strcmp(node_name, "DepthImage")) return TAG_MPEG4_DepthImage; - if (!strcmp(node_name, "FFD")) return TAG_MPEG4_FFD; - if (!strcmp(node_name, "Implicit")) return TAG_MPEG4_Implicit; - if (!strcmp(node_name, "XXLFM_Appearance")) return TAG_MPEG4_XXLFM_Appearance; - if (!strcmp(node_name, "XXLFM_BlendList")) return TAG_MPEG4_XXLFM_BlendList; - if (!strcmp(node_name, "XXLFM_FrameList")) return TAG_MPEG4_XXLFM_FrameList; - if (!strcmp(node_name, "XXLFM_LightMap")) return TAG_MPEG4_XXLFM_LightMap; - if (!strcmp(node_name, "XXLFM_SurfaceMapList")) return TAG_MPEG4_XXLFM_SurfaceMapList; - if (!strcmp(node_name, "XXLFM_ViewMapList")) return TAG_MPEG4_XXLFM_ViewMapList; - if (!strcmp(node_name, "MeshGrid")) return TAG_MPEG4_MeshGrid; - if (!strcmp(node_name, "NonLinearDeformer")) return TAG_MPEG4_NonLinearDeformer; - if (!strcmp(node_name, "NurbsCurve")) return TAG_MPEG4_NurbsCurve; - if (!strcmp(node_name, "NurbsCurve2D")) return TAG_MPEG4_NurbsCurve2D; - if (!strcmp(node_name, "NurbsSurface")) return TAG_MPEG4_NurbsSurface; - if (!strcmp(node_name, "OctreeImage")) return TAG_MPEG4_OctreeImage; - if (!strcmp(node_name, "XXParticles")) return TAG_MPEG4_XXParticles; - if (!strcmp(node_name, "XXParticleInitBox")) return TAG_MPEG4_XXParticleInitBox; - if (!strcmp(node_name, "XXPlanarObstacle")) return TAG_MPEG4_XXPlanarObstacle; - if (!strcmp(node_name, "XXPointAttractor")) return TAG_MPEG4_XXPointAttractor; - if (!strcmp(node_name, "PointTexture")) return TAG_MPEG4_PointTexture; - if (!strcmp(node_name, "PositionAnimator")) return TAG_MPEG4_PositionAnimator; - if (!strcmp(node_name, "PositionAnimator2D")) return TAG_MPEG4_PositionAnimator2D; - if (!strcmp(node_name, "PositionInterpolator4D")) return TAG_MPEG4_PositionInterpolator4D; + case TAG_MPEG4_Anchor: + return Anchor_get_field_count(node, code_mode); + case TAG_MPEG4_AnimationStream: + return AnimationStream_get_field_count(node, code_mode); + case TAG_MPEG4_Appearance: + return Appearance_get_field_count(node, code_mode); + case TAG_MPEG4_AudioBuffer: + return AudioBuffer_get_field_count(node, code_mode); + case TAG_MPEG4_AudioClip: + return AudioClip_get_field_count(node, code_mode); + case TAG_MPEG4_AudioDelay: + return AudioDelay_get_field_count(node, code_mode); + case TAG_MPEG4_AudioFX: + return AudioFX_get_field_count(node, code_mode); + case TAG_MPEG4_AudioMix: + return AudioMix_get_field_count(node, code_mode); + case TAG_MPEG4_AudioSource: + return AudioSource_get_field_count(node, code_mode); + case TAG_MPEG4_AudioSwitch: + return AudioSwitch_get_field_count(node, code_mode); + case TAG_MPEG4_Background: + return Background_get_field_count(node, code_mode); + case TAG_MPEG4_Background2D: + return Background2D_get_field_count(node, code_mode); + case TAG_MPEG4_Billboard: + return Billboard_get_field_count(node, code_mode); + case TAG_MPEG4_Bitmap: + return Bitmap_get_field_count(node, code_mode); + case TAG_MPEG4_Box: + return Box_get_field_count(node, code_mode); + case TAG_MPEG4_Circle: + return Circle_get_field_count(node, code_mode); + case TAG_MPEG4_Collision: + return Collision_get_field_count(node, code_mode); + case TAG_MPEG4_Color: + return Color_get_field_count(node, code_mode); + case TAG_MPEG4_ColorInterpolator: + return ColorInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_CompositeTexture2D: + return CompositeTexture2D_get_field_count(node, code_mode); + case TAG_MPEG4_CompositeTexture3D: + return CompositeTexture3D_get_field_count(node, code_mode); + case TAG_MPEG4_Conditional: + return Conditional_get_field_count(node, code_mode); + case TAG_MPEG4_Cone: + return Cone_get_field_count(node, code_mode); + case TAG_MPEG4_Coordinate: + return Coordinate_get_field_count(node, code_mode); + case TAG_MPEG4_Coordinate2D: + return Coordinate2D_get_field_count(node, code_mode); + case TAG_MPEG4_CoordinateInterpolator: + return CoordinateInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field_count(node, code_mode); + case TAG_MPEG4_Curve2D: + return Curve2D_get_field_count(node, code_mode); + case TAG_MPEG4_Cylinder: + return Cylinder_get_field_count(node, code_mode); + case TAG_MPEG4_CylinderSensor: + return CylinderSensor_get_field_count(node, code_mode); + case TAG_MPEG4_DirectionalLight: + return DirectionalLight_get_field_count(node, code_mode); + case TAG_MPEG4_DiscSensor: + return DiscSensor_get_field_count(node, code_mode); + case TAG_MPEG4_ElevationGrid: + return ElevationGrid_get_field_count(node, code_mode); + case TAG_MPEG4_Expression: + return Expression_get_field_count(node, code_mode); + case TAG_MPEG4_Extrusion: + return Extrusion_get_field_count(node, code_mode); + case TAG_MPEG4_Face: + return Face_get_field_count(node, code_mode); + case TAG_MPEG4_FaceDefMesh: + return FaceDefMesh_get_field_count(node, code_mode); + case TAG_MPEG4_FaceDefTables: + return FaceDefTables_get_field_count(node, code_mode); + case TAG_MPEG4_FaceDefTransform: + return FaceDefTransform_get_field_count(node, code_mode); + case TAG_MPEG4_FAP: + return FAP_get_field_count(node, code_mode); + case TAG_MPEG4_FDP: + return FDP_get_field_count(node, code_mode); + case TAG_MPEG4_FIT: + return FIT_get_field_count(node, code_mode); + case TAG_MPEG4_Fog: + return Fog_get_field_count(node, code_mode); + case TAG_MPEG4_FontStyle: + return FontStyle_get_field_count(node, code_mode); + case TAG_MPEG4_Form: + return Form_get_field_count(node, code_mode); + case TAG_MPEG4_Group: + return Group_get_field_count(node, code_mode); + case TAG_MPEG4_ImageTexture: + return ImageTexture_get_field_count(node, code_mode); + case TAG_MPEG4_IndexedFaceSet: + return IndexedFaceSet_get_field_count(node, code_mode); + case TAG_MPEG4_IndexedFaceSet2D: + return IndexedFaceSet2D_get_field_count(node, code_mode); + case TAG_MPEG4_IndexedLineSet: + return IndexedLineSet_get_field_count(node, code_mode); + case TAG_MPEG4_IndexedLineSet2D: + return IndexedLineSet2D_get_field_count(node, code_mode); + case TAG_MPEG4_Inline: + return Inline_get_field_count(node, code_mode); + case TAG_MPEG4_LOD: + return LOD_get_field_count(node, code_mode); + case TAG_MPEG4_Layer2D: + return Layer2D_get_field_count(node, code_mode); + case TAG_MPEG4_Layer3D: + return Layer3D_get_field_count(node, code_mode); + case TAG_MPEG4_Layout: + return Layout_get_field_count(node, code_mode); + case TAG_MPEG4_LineProperties: + return LineProperties_get_field_count(node, code_mode); + case TAG_MPEG4_ListeningPoint: + return ListeningPoint_get_field_count(node, code_mode); + case TAG_MPEG4_Material: + return Material_get_field_count(node, code_mode); + case TAG_MPEG4_Material2D: + return Material2D_get_field_count(node, code_mode); + case TAG_MPEG4_MovieTexture: + return MovieTexture_get_field_count(node, code_mode); + case TAG_MPEG4_NavigationInfo: + return NavigationInfo_get_field_count(node, code_mode); + case TAG_MPEG4_Normal: + return Normal_get_field_count(node, code_mode); + case TAG_MPEG4_NormalInterpolator: + return NormalInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_OrderedGroup: + return OrderedGroup_get_field_count(node, code_mode); + case TAG_MPEG4_OrientationInterpolator: + return OrientationInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_PixelTexture: + return PixelTexture_get_field_count(node, code_mode); + case TAG_MPEG4_PlaneSensor: + return PlaneSensor_get_field_count(node, code_mode); + case TAG_MPEG4_PlaneSensor2D: + return PlaneSensor2D_get_field_count(node, code_mode); + case TAG_MPEG4_PointLight: + return PointLight_get_field_count(node, code_mode); + case TAG_MPEG4_PointSet: + return PointSet_get_field_count(node, code_mode); + case TAG_MPEG4_PointSet2D: + return PointSet2D_get_field_count(node, code_mode); + case TAG_MPEG4_PositionInterpolator: + return PositionInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_PositionInterpolator2D: + return PositionInterpolator2D_get_field_count(node, code_mode); + case TAG_MPEG4_ProximitySensor2D: + return ProximitySensor2D_get_field_count(node, code_mode); + case TAG_MPEG4_ProximitySensor: + return ProximitySensor_get_field_count(node, code_mode); + case TAG_MPEG4_QuantizationParameter: + return QuantizationParameter_get_field_count(node, code_mode); + case TAG_MPEG4_Rectangle: + return Rectangle_get_field_count(node, code_mode); + case TAG_MPEG4_ScalarInterpolator: + return ScalarInterpolator_get_field_count(node, code_mode); + case TAG_MPEG4_Script: + return Script_get_field_count(node, code_mode); + case TAG_MPEG4_Shape: + return Shape_get_field_count(node, code_mode); + case TAG_MPEG4_Sound: + return Sound_get_field_count(node, code_mode); + case TAG_MPEG4_Sound2D: + return Sound2D_get_field_count(node, code_mode); + case TAG_MPEG4_Sphere: + return Sphere_get_field_count(node, code_mode); + case TAG_MPEG4_SphereSensor: + return SphereSensor_get_field_count(node, code_mode); + case TAG_MPEG4_SpotLight: + return SpotLight_get_field_count(node, code_mode); + case TAG_MPEG4_Switch: + return Switch_get_field_count(node, code_mode); + case TAG_MPEG4_TermCap: + return TermCap_get_field_count(node, code_mode); + case TAG_MPEG4_Text: + return Text_get_field_count(node, code_mode); + case TAG_MPEG4_TextureCoordinate: + return TextureCoordinate_get_field_count(node, code_mode); + case TAG_MPEG4_TextureTransform: + return TextureTransform_get_field_count(node, code_mode); + case TAG_MPEG4_TimeSensor: + return TimeSensor_get_field_count(node, code_mode); + case TAG_MPEG4_TouchSensor: + return TouchSensor_get_field_count(node, code_mode); + case TAG_MPEG4_Transform: + return Transform_get_field_count(node, code_mode); + case TAG_MPEG4_Transform2D: + return Transform2D_get_field_count(node, code_mode); + case TAG_MPEG4_Valuator: + return Valuator_get_field_count(node, code_mode); + case TAG_MPEG4_Viewpoint: + return Viewpoint_get_field_count(node, code_mode); + case TAG_MPEG4_VisibilitySensor: + return VisibilitySensor_get_field_count(node, code_mode); + case TAG_MPEG4_Viseme: + return Viseme_get_field_count(node, code_mode); + case TAG_MPEG4_WorldInfo: + return WorldInfo_get_field_count(node, code_mode); + case TAG_MPEG4_AcousticMaterial: + return AcousticMaterial_get_field_count(node, code_mode); + case TAG_MPEG4_AcousticScene: + return AcousticScene_get_field_count(node, code_mode); + case TAG_MPEG4_ApplicationWindow: + return ApplicationWindow_get_field_count(node, code_mode); + case TAG_MPEG4_BAP: + return BAP_get_field_count(node, code_mode); + case TAG_MPEG4_BDP: + return BDP_get_field_count(node, code_mode); + case TAG_MPEG4_Body: + return Body_get_field_count(node, code_mode); + case TAG_MPEG4_BodyDefTable: + return BodyDefTable_get_field_count(node, code_mode); + case TAG_MPEG4_BodySegmentConnectionHint: + return BodySegmentConnectionHint_get_field_count(node, code_mode); + case TAG_MPEG4_DirectiveSound: + return DirectiveSound_get_field_count(node, code_mode); + case TAG_MPEG4_Hierarchical3DMesh: + return Hierarchical3DMesh_get_field_count(node, code_mode); + case TAG_MPEG4_MaterialKey: + return MaterialKey_get_field_count(node, code_mode); + case TAG_MPEG4_PerceptualParameters: + return PerceptualParameters_get_field_count(node, code_mode); + case TAG_MPEG4_TemporalTransform: + return TemporalTransform_get_field_count(node, code_mode); + case TAG_MPEG4_TemporalGroup: + return TemporalGroup_get_field_count(node, code_mode); + case TAG_MPEG4_ServerCommand: + return ServerCommand_get_field_count(node, code_mode); + case TAG_MPEG4_InputSensor: + return InputSensor_get_field_count(node, code_mode); + case TAG_MPEG4_MatteTexture: + return MatteTexture_get_field_count(node, code_mode); + case TAG_MPEG4_MediaBuffer: + return MediaBuffer_get_field_count(node, code_mode); + case TAG_MPEG4_MediaControl: + return MediaControl_get_field_count(node, code_mode); + case TAG_MPEG4_MediaSensor: + return MediaSensor_get_field_count(node, code_mode); + case TAG_MPEG4_BitWrapper: + return BitWrapper_get_field_count(node, code_mode); + case TAG_MPEG4_CoordinateInterpolator4D: + return CoordinateInterpolator4D_get_field_count(node, code_mode); + case TAG_MPEG4_DepthImage: + return DepthImage_get_field_count(node, code_mode); + case TAG_MPEG4_FFD: + return FFD_get_field_count(node, code_mode); + case TAG_MPEG4_Implicit: + return Implicit_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_Appearance: + return XXLFM_Appearance_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_BlendList: + return XXLFM_BlendList_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_FrameList: + return XXLFM_FrameList_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_LightMap: + return XXLFM_LightMap_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_SurfaceMapList: + return XXLFM_SurfaceMapList_get_field_count(node, code_mode); + case TAG_MPEG4_XXLFM_ViewMapList: + return XXLFM_ViewMapList_get_field_count(node, code_mode); + case TAG_MPEG4_MeshGrid: + return MeshGrid_get_field_count(node, code_mode); + case TAG_MPEG4_NonLinearDeformer: + return NonLinearDeformer_get_field_count(node, code_mode); + case TAG_MPEG4_NurbsCurve: + return NurbsCurve_get_field_count(node, code_mode); + case TAG_MPEG4_NurbsCurve2D: + return NurbsCurve2D_get_field_count(node, code_mode); + case TAG_MPEG4_NurbsSurface: + return NurbsSurface_get_field_count(node, code_mode); + case TAG_MPEG4_OctreeImage: + return OctreeImage_get_field_count(node, code_mode); + case TAG_MPEG4_XXParticles: + return XXParticles_get_field_count(node, code_mode); + case TAG_MPEG4_XXParticleInitBox: + return XXParticleInitBox_get_field_count(node, code_mode); + case TAG_MPEG4_XXPlanarObstacle: + return XXPlanarObstacle_get_field_count(node, code_mode); + case TAG_MPEG4_XXPointAttractor: + return XXPointAttractor_get_field_count(node, code_mode); + case TAG_MPEG4_PointTexture: + return PointTexture_get_field_count(node, code_mode); + case TAG_MPEG4_PositionAnimator: + return PositionAnimator_get_field_count(node, code_mode); + case TAG_MPEG4_PositionAnimator2D: + return PositionAnimator2D_get_field_count(node, code_mode); + case TAG_MPEG4_PositionInterpolator4D: + return PositionInterpolator4D_get_field_count(node, code_mode); + case TAG_MPEG4_ProceduralTexture: + return ProceduralTexture_get_field_count(node, code_mode); + case TAG_MPEG4_Quadric: + return Quadric_get_field_count(node, code_mode); + case TAG_MPEG4_SBBone: + return SBBone_get_field_count(node, code_mode); + case TAG_MPEG4_SBMuscle: + return SBMuscle_get_field_count(node, code_mode); + case TAG_MPEG4_SBSegment: + return SBSegment_get_field_count(node, code_mode); + case TAG_MPEG4_SBSite: + return SBSite_get_field_count(node, code_mode); + case TAG_MPEG4_SBSkinnedModel: + return SBSkinnedModel_get_field_count(node, code_mode); + case TAG_MPEG4_SBVCAnimation: + return SBVCAnimation_get_field_count(node, code_mode); + case TAG_MPEG4_ScalarAnimator: + return ScalarAnimator_get_field_count(node, code_mode); + case TAG_MPEG4_SimpleTexture: + return SimpleTexture_get_field_count(node, code_mode); + case TAG_MPEG4_SolidRep: + return SolidRep_get_field_count(node, code_mode); + case TAG_MPEG4_SubdivisionSurface: + return SubdivisionSurface_get_field_count(node, code_mode); + case TAG_MPEG4_SubdivSurfaceSector: + return SubdivSurfaceSector_get_field_count(node, code_mode); + case TAG_MPEG4_WaveletSubdivisionSurface: + return WaveletSubdivisionSurface_get_field_count(node, code_mode); + case TAG_MPEG4_Clipper2D: + return Clipper2D_get_field_count(node, code_mode); + case TAG_MPEG4_ColorTransform: + return ColorTransform_get_field_count(node, code_mode); + case TAG_MPEG4_Ellipse: + return Ellipse_get_field_count(node, code_mode); + case TAG_MPEG4_LinearGradient: + return LinearGradient_get_field_count(node, code_mode); + case TAG_MPEG4_PathLayout: + return PathLayout_get_field_count(node, code_mode); + case TAG_MPEG4_RadialGradient: + return RadialGradient_get_field_count(node, code_mode); + case TAG_MPEG4_SynthesizedTexture: + return SynthesizedTexture_get_field_count(node, code_mode); + case TAG_MPEG4_TransformMatrix2D: + return TransformMatrix2D_get_field_count(node, code_mode); + case TAG_MPEG4_Viewport: + return Viewport_get_field_count(node, code_mode); + case TAG_MPEG4_XCurve2D: + return XCurve2D_get_field_count(node, code_mode); + case TAG_MPEG4_XFontStyle: + return XFontStyle_get_field_count(node, code_mode); + case TAG_MPEG4_XLineProperties: + return XLineProperties_get_field_count(node, code_mode); + case TAG_MPEG4_AdvancedAudioBuffer: + return AdvancedAudioBuffer_get_field_count(node, code_mode); + case TAG_MPEG4_AudioChannelConfig: + return AudioChannelConfig_get_field_count(node, code_mode); + case TAG_MPEG4_DepthImageV2: + return DepthImageV2_get_field_count(node, code_mode); + case TAG_MPEG4_MorphShape: + return MorphShape_get_field_count(node, code_mode); + case TAG_MPEG4_MultiTexture: + return MultiTexture_get_field_count(node, code_mode); + case TAG_MPEG4_PointTextureV2: + return PointTextureV2_get_field_count(node, code_mode); + case TAG_MPEG4_SBVCAnimationV2: + return SBVCAnimationV2_get_field_count(node, code_mode); + case TAG_MPEG4_SimpleTextureV2: + return SimpleTextureV2_get_field_count(node, code_mode); + case TAG_MPEG4_SurroundingSound: + return SurroundingSound_get_field_count(node, code_mode); + case TAG_MPEG4_Transform3DAudio: + return Transform3DAudio_get_field_count(node, code_mode); + case TAG_MPEG4_WideSound: + return WideSound_get_field_count(node, code_mode); + case TAG_MPEG4_ScoreShape: + return ScoreShape_get_field_count(node, code_mode); + case TAG_MPEG4_MusicScore: + return MusicScore_get_field_count(node, code_mode); + case TAG_MPEG4_FootPrintSetNode: + return FootPrintSetNode_get_field_count(node, code_mode); + case TAG_MPEG4_FootPrintNode: + return FootPrintNode_get_field_count(node, code_mode); + case TAG_MPEG4_BuildingPartNode: + return BuildingPartNode_get_field_count(node, code_mode); + case TAG_MPEG4_RoofNode: + return RoofNode_get_field_count(node, code_mode); + case TAG_MPEG4_FacadeNode: + return FacadeNode_get_field_count(node, code_mode); + case TAG_MPEG4_Shadow: + return Shadow_get_field_count(node, code_mode); + case TAG_MPEG4_CacheTexture: + return CacheTexture_get_field_count(node, code_mode); + case TAG_MPEG4_EnvironmentTest: + return EnvironmentTest_get_field_count(node, code_mode); + case TAG_MPEG4_KeyNavigator: + return KeyNavigator_get_field_count(node, code_mode); + case TAG_MPEG4_SpacePartition: + return SpacePartition_get_field_count(node, code_mode); + case TAG_MPEG4_Storage: + return Storage_get_field_count(node, code_mode); + default: + return 0; + } +} + +GF_Err gf_sg_mpeg4_node_get_field(GF_Node *node, GF_FieldInfo *field) +{ + switch (node->sgprivate->tag) { + case TAG_MPEG4_Anchor: + return Anchor_get_field(node, field); + case TAG_MPEG4_AnimationStream: + return AnimationStream_get_field(node, field); + case TAG_MPEG4_Appearance: + return Appearance_get_field(node, field); + case TAG_MPEG4_AudioBuffer: + return AudioBuffer_get_field(node, field); + case TAG_MPEG4_AudioClip: + return AudioClip_get_field(node, field); + case TAG_MPEG4_AudioDelay: + return AudioDelay_get_field(node, field); + case TAG_MPEG4_AudioFX: + return AudioFX_get_field(node, field); + case TAG_MPEG4_AudioMix: + return AudioMix_get_field(node, field); + case TAG_MPEG4_AudioSource: + return AudioSource_get_field(node, field); + case TAG_MPEG4_AudioSwitch: + return AudioSwitch_get_field(node, field); + case TAG_MPEG4_Background: + return Background_get_field(node, field); + case TAG_MPEG4_Background2D: + return Background2D_get_field(node, field); + case TAG_MPEG4_Billboard: + return Billboard_get_field(node, field); + case TAG_MPEG4_Bitmap: + return Bitmap_get_field(node, field); + case TAG_MPEG4_Box: + return Box_get_field(node, field); + case TAG_MPEG4_Circle: + return Circle_get_field(node, field); + case TAG_MPEG4_Collision: + return Collision_get_field(node, field); + case TAG_MPEG4_Color: + return Color_get_field(node, field); + case TAG_MPEG4_ColorInterpolator: + return ColorInterpolator_get_field(node, field); + case TAG_MPEG4_CompositeTexture2D: + return CompositeTexture2D_get_field(node, field); + case TAG_MPEG4_CompositeTexture3D: + return CompositeTexture3D_get_field(node, field); + case TAG_MPEG4_Conditional: + return Conditional_get_field(node, field); + case TAG_MPEG4_Cone: + return Cone_get_field(node, field); + case TAG_MPEG4_Coordinate: + return Coordinate_get_field(node, field); + case TAG_MPEG4_Coordinate2D: + return Coordinate2D_get_field(node, field); + case TAG_MPEG4_CoordinateInterpolator: + return CoordinateInterpolator_get_field(node, field); + case TAG_MPEG4_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field(node, field); + case TAG_MPEG4_Curve2D: + return Curve2D_get_field(node, field); + case TAG_MPEG4_Cylinder: + return Cylinder_get_field(node, field); + case TAG_MPEG4_CylinderSensor: + return CylinderSensor_get_field(node, field); + case TAG_MPEG4_DirectionalLight: + return DirectionalLight_get_field(node, field); + case TAG_MPEG4_DiscSensor: + return DiscSensor_get_field(node, field); + case TAG_MPEG4_ElevationGrid: + return ElevationGrid_get_field(node, field); + case TAG_MPEG4_Expression: + return Expression_get_field(node, field); + case TAG_MPEG4_Extrusion: + return Extrusion_get_field(node, field); + case TAG_MPEG4_Face: + return Face_get_field(node, field); + case TAG_MPEG4_FaceDefMesh: + return FaceDefMesh_get_field(node, field); + case TAG_MPEG4_FaceDefTables: + return FaceDefTables_get_field(node, field); + case TAG_MPEG4_FaceDefTransform: + return FaceDefTransform_get_field(node, field); + case TAG_MPEG4_FAP: + return FAP_get_field(node, field); + case TAG_MPEG4_FDP: + return FDP_get_field(node, field); + case TAG_MPEG4_FIT: + return FIT_get_field(node, field); + case TAG_MPEG4_Fog: + return Fog_get_field(node, field); + case TAG_MPEG4_FontStyle: + return FontStyle_get_field(node, field); + case TAG_MPEG4_Form: + return Form_get_field(node, field); + case TAG_MPEG4_Group: + return Group_get_field(node, field); + case TAG_MPEG4_ImageTexture: + return ImageTexture_get_field(node, field); + case TAG_MPEG4_IndexedFaceSet: + return IndexedFaceSet_get_field(node, field); + case TAG_MPEG4_IndexedFaceSet2D: + return IndexedFaceSet2D_get_field(node, field); + case TAG_MPEG4_IndexedLineSet: + return IndexedLineSet_get_field(node, field); + case TAG_MPEG4_IndexedLineSet2D: + return IndexedLineSet2D_get_field(node, field); + case TAG_MPEG4_Inline: + return Inline_get_field(node, field); + case TAG_MPEG4_LOD: + return LOD_get_field(node, field); + case TAG_MPEG4_Layer2D: + return Layer2D_get_field(node, field); + case TAG_MPEG4_Layer3D: + return Layer3D_get_field(node, field); + case TAG_MPEG4_Layout: + return Layout_get_field(node, field); + case TAG_MPEG4_LineProperties: + return LineProperties_get_field(node, field); + case TAG_MPEG4_ListeningPoint: + return ListeningPoint_get_field(node, field); + case TAG_MPEG4_Material: + return Material_get_field(node, field); + case TAG_MPEG4_Material2D: + return Material2D_get_field(node, field); + case TAG_MPEG4_MovieTexture: + return MovieTexture_get_field(node, field); + case TAG_MPEG4_NavigationInfo: + return NavigationInfo_get_field(node, field); + case TAG_MPEG4_Normal: + return Normal_get_field(node, field); + case TAG_MPEG4_NormalInterpolator: + return NormalInterpolator_get_field(node, field); + case TAG_MPEG4_OrderedGroup: + return OrderedGroup_get_field(node, field); + case TAG_MPEG4_OrientationInterpolator: + return OrientationInterpolator_get_field(node, field); + case TAG_MPEG4_PixelTexture: + return PixelTexture_get_field(node, field); + case TAG_MPEG4_PlaneSensor: + return PlaneSensor_get_field(node, field); + case TAG_MPEG4_PlaneSensor2D: + return PlaneSensor2D_get_field(node, field); + case TAG_MPEG4_PointLight: + return PointLight_get_field(node, field); + case TAG_MPEG4_PointSet: + return PointSet_get_field(node, field); + case TAG_MPEG4_PointSet2D: + return PointSet2D_get_field(node, field); + case TAG_MPEG4_PositionInterpolator: + return PositionInterpolator_get_field(node, field); + case TAG_MPEG4_PositionInterpolator2D: + return PositionInterpolator2D_get_field(node, field); + case TAG_MPEG4_ProximitySensor2D: + return ProximitySensor2D_get_field(node, field); + case TAG_MPEG4_ProximitySensor: + return ProximitySensor_get_field(node, field); + case TAG_MPEG4_QuantizationParameter: + return QuantizationParameter_get_field(node, field); + case TAG_MPEG4_Rectangle: + return Rectangle_get_field(node, field); + case TAG_MPEG4_ScalarInterpolator: + return ScalarInterpolator_get_field(node, field); + case TAG_MPEG4_Script: + return Script_get_field(node, field); + case TAG_MPEG4_Shape: + return Shape_get_field(node, field); + case TAG_MPEG4_Sound: + return Sound_get_field(node, field); + case TAG_MPEG4_Sound2D: + return Sound2D_get_field(node, field); + case TAG_MPEG4_Sphere: + return Sphere_get_field(node, field); + case TAG_MPEG4_SphereSensor: + return SphereSensor_get_field(node, field); + case TAG_MPEG4_SpotLight: + return SpotLight_get_field(node, field); + case TAG_MPEG4_Switch: + return Switch_get_field(node, field); + case TAG_MPEG4_TermCap: + return TermCap_get_field(node, field); + case TAG_MPEG4_Text: + return Text_get_field(node, field); + case TAG_MPEG4_TextureCoordinate: + return TextureCoordinate_get_field(node, field); + case TAG_MPEG4_TextureTransform: + return TextureTransform_get_field(node, field); + case TAG_MPEG4_TimeSensor: + return TimeSensor_get_field(node, field); + case TAG_MPEG4_TouchSensor: + return TouchSensor_get_field(node, field); + case TAG_MPEG4_Transform: + return Transform_get_field(node, field); + case TAG_MPEG4_Transform2D: + return Transform2D_get_field(node, field); + case TAG_MPEG4_Valuator: + return Valuator_get_field(node, field); + case TAG_MPEG4_Viewpoint: + return Viewpoint_get_field(node, field); + case TAG_MPEG4_VisibilitySensor: + return VisibilitySensor_get_field(node, field); + case TAG_MPEG4_Viseme: + return Viseme_get_field(node, field); + case TAG_MPEG4_WorldInfo: + return WorldInfo_get_field(node, field); + case TAG_MPEG4_AcousticMaterial: + return AcousticMaterial_get_field(node, field); + case TAG_MPEG4_AcousticScene: + return AcousticScene_get_field(node, field); + case TAG_MPEG4_ApplicationWindow: + return ApplicationWindow_get_field(node, field); + case TAG_MPEG4_BAP: + return BAP_get_field(node, field); + case TAG_MPEG4_BDP: + return BDP_get_field(node, field); + case TAG_MPEG4_Body: + return Body_get_field(node, field); + case TAG_MPEG4_BodyDefTable: + return BodyDefTable_get_field(node, field); + case TAG_MPEG4_BodySegmentConnectionHint: + return BodySegmentConnectionHint_get_field(node, field); + case TAG_MPEG4_DirectiveSound: + return DirectiveSound_get_field(node, field); + case TAG_MPEG4_Hierarchical3DMesh: + return Hierarchical3DMesh_get_field(node, field); + case TAG_MPEG4_MaterialKey: + return MaterialKey_get_field(node, field); + case TAG_MPEG4_PerceptualParameters: + return PerceptualParameters_get_field(node, field); + case TAG_MPEG4_TemporalTransform: + return TemporalTransform_get_field(node, field); + case TAG_MPEG4_TemporalGroup: + return TemporalGroup_get_field(node, field); + case TAG_MPEG4_ServerCommand: + return ServerCommand_get_field(node, field); + case TAG_MPEG4_InputSensor: + return InputSensor_get_field(node, field); + case TAG_MPEG4_MatteTexture: + return MatteTexture_get_field(node, field); + case TAG_MPEG4_MediaBuffer: + return MediaBuffer_get_field(node, field); + case TAG_MPEG4_MediaControl: + return MediaControl_get_field(node, field); + case TAG_MPEG4_MediaSensor: + return MediaSensor_get_field(node, field); + case TAG_MPEG4_BitWrapper: + return BitWrapper_get_field(node, field); + case TAG_MPEG4_CoordinateInterpolator4D: + return CoordinateInterpolator4D_get_field(node, field); + case TAG_MPEG4_DepthImage: + return DepthImage_get_field(node, field); + case TAG_MPEG4_FFD: + return FFD_get_field(node, field); + case TAG_MPEG4_Implicit: + return Implicit_get_field(node, field); + case TAG_MPEG4_XXLFM_Appearance: + return XXLFM_Appearance_get_field(node, field); + case TAG_MPEG4_XXLFM_BlendList: + return XXLFM_BlendList_get_field(node, field); + case TAG_MPEG4_XXLFM_FrameList: + return XXLFM_FrameList_get_field(node, field); + case TAG_MPEG4_XXLFM_LightMap: + return XXLFM_LightMap_get_field(node, field); + case TAG_MPEG4_XXLFM_SurfaceMapList: + return XXLFM_SurfaceMapList_get_field(node, field); + case TAG_MPEG4_XXLFM_ViewMapList: + return XXLFM_ViewMapList_get_field(node, field); + case TAG_MPEG4_MeshGrid: + return MeshGrid_get_field(node, field); + case TAG_MPEG4_NonLinearDeformer: + return NonLinearDeformer_get_field(node, field); + case TAG_MPEG4_NurbsCurve: + return NurbsCurve_get_field(node, field); + case TAG_MPEG4_NurbsCurve2D: + return NurbsCurve2D_get_field(node, field); + case TAG_MPEG4_NurbsSurface: + return NurbsSurface_get_field(node, field); + case TAG_MPEG4_OctreeImage: + return OctreeImage_get_field(node, field); + case TAG_MPEG4_XXParticles: + return XXParticles_get_field(node, field); + case TAG_MPEG4_XXParticleInitBox: + return XXParticleInitBox_get_field(node, field); + case TAG_MPEG4_XXPlanarObstacle: + return XXPlanarObstacle_get_field(node, field); + case TAG_MPEG4_XXPointAttractor: + return XXPointAttractor_get_field(node, field); + case TAG_MPEG4_PointTexture: + return PointTexture_get_field(node, field); + case TAG_MPEG4_PositionAnimator: + return PositionAnimator_get_field(node, field); + case TAG_MPEG4_PositionAnimator2D: + return PositionAnimator2D_get_field(node, field); + case TAG_MPEG4_PositionInterpolator4D: + return PositionInterpolator4D_get_field(node, field); + case TAG_MPEG4_ProceduralTexture: + return ProceduralTexture_get_field(node, field); + case TAG_MPEG4_Quadric: + return Quadric_get_field(node, field); + case TAG_MPEG4_SBBone: + return SBBone_get_field(node, field); + case TAG_MPEG4_SBMuscle: + return SBMuscle_get_field(node, field); + case TAG_MPEG4_SBSegment: + return SBSegment_get_field(node, field); + case TAG_MPEG4_SBSite: + return SBSite_get_field(node, field); + case TAG_MPEG4_SBSkinnedModel: + return SBSkinnedModel_get_field(node, field); + case TAG_MPEG4_SBVCAnimation: + return SBVCAnimation_get_field(node, field); + case TAG_MPEG4_ScalarAnimator: + return ScalarAnimator_get_field(node, field); + case TAG_MPEG4_SimpleTexture: + return SimpleTexture_get_field(node, field); + case TAG_MPEG4_SolidRep: + return SolidRep_get_field(node, field); + case TAG_MPEG4_SubdivisionSurface: + return SubdivisionSurface_get_field(node, field); + case TAG_MPEG4_SubdivSurfaceSector: + return SubdivSurfaceSector_get_field(node, field); + case TAG_MPEG4_WaveletSubdivisionSurface: + return WaveletSubdivisionSurface_get_field(node, field); + case TAG_MPEG4_Clipper2D: + return Clipper2D_get_field(node, field); + case TAG_MPEG4_ColorTransform: + return ColorTransform_get_field(node, field); + case TAG_MPEG4_Ellipse: + return Ellipse_get_field(node, field); + case TAG_MPEG4_LinearGradient: + return LinearGradient_get_field(node, field); + case TAG_MPEG4_PathLayout: + return PathLayout_get_field(node, field); + case TAG_MPEG4_RadialGradient: + return RadialGradient_get_field(node, field); + case TAG_MPEG4_SynthesizedTexture: + return SynthesizedTexture_get_field(node, field); + case TAG_MPEG4_TransformMatrix2D: + return TransformMatrix2D_get_field(node, field); + case TAG_MPEG4_Viewport: + return Viewport_get_field(node, field); + case TAG_MPEG4_XCurve2D: + return XCurve2D_get_field(node, field); + case TAG_MPEG4_XFontStyle: + return XFontStyle_get_field(node, field); + case TAG_MPEG4_XLineProperties: + return XLineProperties_get_field(node, field); + case TAG_MPEG4_AdvancedAudioBuffer: + return AdvancedAudioBuffer_get_field(node, field); + case TAG_MPEG4_AudioChannelConfig: + return AudioChannelConfig_get_field(node, field); + case TAG_MPEG4_DepthImageV2: + return DepthImageV2_get_field(node, field); + case TAG_MPEG4_MorphShape: + return MorphShape_get_field(node, field); + case TAG_MPEG4_MultiTexture: + return MultiTexture_get_field(node, field); + case TAG_MPEG4_PointTextureV2: + return PointTextureV2_get_field(node, field); + case TAG_MPEG4_SBVCAnimationV2: + return SBVCAnimationV2_get_field(node, field); + case TAG_MPEG4_SimpleTextureV2: + return SimpleTextureV2_get_field(node, field); + case TAG_MPEG4_SurroundingSound: + return SurroundingSound_get_field(node, field); + case TAG_MPEG4_Transform3DAudio: + return Transform3DAudio_get_field(node, field); + case TAG_MPEG4_WideSound: + return WideSound_get_field(node, field); + case TAG_MPEG4_ScoreShape: + return ScoreShape_get_field(node, field); + case TAG_MPEG4_MusicScore: + return MusicScore_get_field(node, field); + case TAG_MPEG4_FootPrintSetNode: + return FootPrintSetNode_get_field(node, field); + case TAG_MPEG4_FootPrintNode: + return FootPrintNode_get_field(node, field); + case TAG_MPEG4_BuildingPartNode: + return BuildingPartNode_get_field(node, field); + case TAG_MPEG4_RoofNode: + return RoofNode_get_field(node, field); + case TAG_MPEG4_FacadeNode: + return FacadeNode_get_field(node, field); + case TAG_MPEG4_Shadow: + return Shadow_get_field(node, field); + case TAG_MPEG4_CacheTexture: + return CacheTexture_get_field(node, field); + case TAG_MPEG4_EnvironmentTest: + return EnvironmentTest_get_field(node, field); + case TAG_MPEG4_KeyNavigator: + return KeyNavigator_get_field(node, field); + case TAG_MPEG4_SpacePartition: + return SpacePartition_get_field(node, field); + case TAG_MPEG4_Storage: + return Storage_get_field(node, field); + default: + return GF_BAD_PARAM; + } +} + +GF_Err gf_sg_mpeg4_node_get_field_index(GF_Node *node, u32 inField, u8 code_mode, u32 *fieldIndex) +{ + switch (node->sgprivate->tag) { + case TAG_MPEG4_Anchor: + return Anchor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AnimationStream: + return AnimationStream_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Appearance: + return Appearance_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioBuffer: + return AudioBuffer_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioClip: + return AudioClip_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioDelay: + return AudioDelay_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioFX: + return AudioFX_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioMix: + return AudioMix_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioSource: + return AudioSource_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioSwitch: + return AudioSwitch_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Background: + return Background_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Background2D: + return Background2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Billboard: + return Billboard_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Bitmap: + return Bitmap_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Box: + return Box_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Circle: + return Circle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Collision: + return Collision_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Color: + return Color_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ColorInterpolator: + return ColorInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CompositeTexture2D: + return CompositeTexture2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CompositeTexture3D: + return CompositeTexture3D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Conditional: + return Conditional_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Cone: + return Cone_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Coordinate: + return Coordinate_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Coordinate2D: + return Coordinate2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CoordinateInterpolator: + return CoordinateInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Curve2D: + return Curve2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Cylinder: + return Cylinder_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CylinderSensor: + return CylinderSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_DirectionalLight: + return DirectionalLight_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_DiscSensor: + return DiscSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ElevationGrid: + return ElevationGrid_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Expression: + return Expression_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Extrusion: + return Extrusion_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Face: + return Face_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FaceDefMesh: + return FaceDefMesh_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FaceDefTables: + return FaceDefTables_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FaceDefTransform: + return FaceDefTransform_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FAP: + return FAP_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FDP: + return FDP_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FIT: + return FIT_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Fog: + return Fog_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FontStyle: + return FontStyle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Form: + return Form_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Group: + return Group_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ImageTexture: + return ImageTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_IndexedFaceSet: + return IndexedFaceSet_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_IndexedFaceSet2D: + return IndexedFaceSet2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_IndexedLineSet: + return IndexedLineSet_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_IndexedLineSet2D: + return IndexedLineSet2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Inline: + return Inline_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_LOD: + return LOD_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Layer2D: + return Layer2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Layer3D: + return Layer3D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Layout: + return Layout_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_LineProperties: + return LineProperties_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ListeningPoint: + return ListeningPoint_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Material: + return Material_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Material2D: + return Material2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MovieTexture: + return MovieTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NavigationInfo: + return NavigationInfo_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Normal: + return Normal_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NormalInterpolator: + return NormalInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_OrderedGroup: + return OrderedGroup_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_OrientationInterpolator: + return OrientationInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PixelTexture: + return PixelTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PlaneSensor: + return PlaneSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PlaneSensor2D: + return PlaneSensor2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PointLight: + return PointLight_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PointSet: + return PointSet_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PointSet2D: + return PointSet2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PositionInterpolator: + return PositionInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PositionInterpolator2D: + return PositionInterpolator2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ProximitySensor2D: + return ProximitySensor2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ProximitySensor: + return ProximitySensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_QuantizationParameter: + return QuantizationParameter_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Rectangle: + return Rectangle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ScalarInterpolator: + return ScalarInterpolator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Script: + return Script_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Shape: + return Shape_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Sound: + return Sound_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Sound2D: + return Sound2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Sphere: + return Sphere_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SphereSensor: + return SphereSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SpotLight: + return SpotLight_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Switch: + return Switch_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TermCap: + return TermCap_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Text: + return Text_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TextureCoordinate: + return TextureCoordinate_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TextureTransform: + return TextureTransform_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TimeSensor: + return TimeSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TouchSensor: + return TouchSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Transform: + return Transform_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Transform2D: + return Transform2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Valuator: + return Valuator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Viewpoint: + return Viewpoint_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_VisibilitySensor: + return VisibilitySensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Viseme: + return Viseme_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_WorldInfo: + return WorldInfo_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AcousticMaterial: + return AcousticMaterial_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AcousticScene: + return AcousticScene_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ApplicationWindow: + return ApplicationWindow_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BAP: + return BAP_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BDP: + return BDP_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Body: + return Body_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BodyDefTable: + return BodyDefTable_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BodySegmentConnectionHint: + return BodySegmentConnectionHint_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_DirectiveSound: + return DirectiveSound_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Hierarchical3DMesh: + return Hierarchical3DMesh_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MaterialKey: + return MaterialKey_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PerceptualParameters: + return PerceptualParameters_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TemporalTransform: + return TemporalTransform_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TemporalGroup: + return TemporalGroup_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ServerCommand: + return ServerCommand_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_InputSensor: + return InputSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MatteTexture: + return MatteTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MediaBuffer: + return MediaBuffer_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MediaControl: + return MediaControl_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MediaSensor: + return MediaSensor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BitWrapper: + return BitWrapper_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CoordinateInterpolator4D: + return CoordinateInterpolator4D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_DepthImage: + return DepthImage_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FFD: + return FFD_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Implicit: + return Implicit_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_Appearance: + return XXLFM_Appearance_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_BlendList: + return XXLFM_BlendList_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_FrameList: + return XXLFM_FrameList_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_LightMap: + return XXLFM_LightMap_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_SurfaceMapList: + return XXLFM_SurfaceMapList_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXLFM_ViewMapList: + return XXLFM_ViewMapList_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MeshGrid: + return MeshGrid_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NonLinearDeformer: + return NonLinearDeformer_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NurbsCurve: + return NurbsCurve_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NurbsCurve2D: + return NurbsCurve2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_NurbsSurface: + return NurbsSurface_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_OctreeImage: + return OctreeImage_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXParticles: + return XXParticles_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXParticleInitBox: + return XXParticleInitBox_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXPlanarObstacle: + return XXPlanarObstacle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XXPointAttractor: + return XXPointAttractor_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PointTexture: + return PointTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PositionAnimator: + return PositionAnimator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PositionAnimator2D: + return PositionAnimator2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PositionInterpolator4D: + return PositionInterpolator4D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ProceduralTexture: + return ProceduralTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Quadric: + return Quadric_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBBone: + return SBBone_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBMuscle: + return SBMuscle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBSegment: + return SBSegment_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBSite: + return SBSite_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBSkinnedModel: + return SBSkinnedModel_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBVCAnimation: + return SBVCAnimation_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ScalarAnimator: + return ScalarAnimator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SimpleTexture: + return SimpleTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SolidRep: + return SolidRep_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SubdivisionSurface: + return SubdivisionSurface_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SubdivSurfaceSector: + return SubdivSurfaceSector_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_WaveletSubdivisionSurface: + return WaveletSubdivisionSurface_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Clipper2D: + return Clipper2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ColorTransform: + return ColorTransform_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Ellipse: + return Ellipse_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_LinearGradient: + return LinearGradient_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PathLayout: + return PathLayout_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_RadialGradient: + return RadialGradient_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SynthesizedTexture: + return SynthesizedTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_TransformMatrix2D: + return TransformMatrix2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Viewport: + return Viewport_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XCurve2D: + return XCurve2D_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XFontStyle: + return XFontStyle_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_XLineProperties: + return XLineProperties_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AdvancedAudioBuffer: + return AdvancedAudioBuffer_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_AudioChannelConfig: + return AudioChannelConfig_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_DepthImageV2: + return DepthImageV2_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MorphShape: + return MorphShape_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MultiTexture: + return MultiTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_PointTextureV2: + return PointTextureV2_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SBVCAnimationV2: + return SBVCAnimationV2_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SimpleTextureV2: + return SimpleTextureV2_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SurroundingSound: + return SurroundingSound_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Transform3DAudio: + return Transform3DAudio_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_WideSound: + return WideSound_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_ScoreShape: + return ScoreShape_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_MusicScore: + return MusicScore_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FootPrintSetNode: + return FootPrintSetNode_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FootPrintNode: + return FootPrintNode_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_BuildingPartNode: + return BuildingPartNode_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_RoofNode: + return RoofNode_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_FacadeNode: + return FacadeNode_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Shadow: + return Shadow_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_CacheTexture: + return CacheTexture_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_EnvironmentTest: + return EnvironmentTest_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_KeyNavigator: + return KeyNavigator_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_SpacePartition: + return SpacePartition_get_field_index(node, inField, code_mode, fieldIndex); + case TAG_MPEG4_Storage: + return Storage_get_field_index(node, inField, code_mode, fieldIndex); + default: + return GF_BAD_PARAM; + } +} + +Bool gf_sg_mpeg4_node_get_aq_info(GF_Node *node, u32 FieldIndex, u8 *QType, u8 *AType, Fixed *b_min, Fixed *b_max, u32 *QT13_bits) +{ + switch (node->sgprivate->tag) { + case TAG_MPEG4_Anchor: + return Anchor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AnimationStream: + return AnimationStream_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Appearance: + return Appearance_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioBuffer: + return AudioBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioClip: + return AudioClip_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioDelay: + return AudioDelay_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioFX: + return AudioFX_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioMix: + return AudioMix_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioSource: + return AudioSource_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioSwitch: + return AudioSwitch_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Background: + return Background_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Background2D: + return Background2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Billboard: + return Billboard_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Bitmap: + return Bitmap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Box: + return Box_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Circle: + return Circle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Collision: + return Collision_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Color: + return Color_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ColorInterpolator: + return ColorInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CompositeTexture2D: + return CompositeTexture2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CompositeTexture3D: + return CompositeTexture3D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Conditional: + return Conditional_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Cone: + return Cone_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Coordinate: + return Coordinate_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Coordinate2D: + return Coordinate2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CoordinateInterpolator: + return CoordinateInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Curve2D: + return Curve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Cylinder: + return Cylinder_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CylinderSensor: + return CylinderSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_DirectionalLight: + return DirectionalLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_DiscSensor: + return DiscSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ElevationGrid: + return ElevationGrid_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Expression: + return Expression_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Extrusion: + return Extrusion_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Face: + return Face_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FaceDefMesh: + return FaceDefMesh_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FaceDefTables: + return FaceDefTables_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FaceDefTransform: + return FaceDefTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FAP: + return FAP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FDP: + return FDP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FIT: + return FIT_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Fog: + return Fog_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FontStyle: + return FontStyle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Form: + return Form_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Group: + return Group_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ImageTexture: + return ImageTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_IndexedFaceSet: + return IndexedFaceSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_IndexedFaceSet2D: + return IndexedFaceSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_IndexedLineSet: + return IndexedLineSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_IndexedLineSet2D: + return IndexedLineSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Inline: + return Inline_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_LOD: + return LOD_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Layer2D: + return Layer2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Layer3D: + return Layer3D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Layout: + return Layout_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_LineProperties: + return LineProperties_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ListeningPoint: + return ListeningPoint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Material: + return Material_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Material2D: + return Material2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MovieTexture: + return MovieTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NavigationInfo: + return NavigationInfo_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Normal: + return Normal_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NormalInterpolator: + return NormalInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_OrderedGroup: + return OrderedGroup_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_OrientationInterpolator: + return OrientationInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PixelTexture: + return PixelTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PlaneSensor: + return PlaneSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PlaneSensor2D: + return PlaneSensor2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PointLight: + return PointLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PointSet: + return PointSet_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PointSet2D: + return PointSet2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PositionInterpolator: + return PositionInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PositionInterpolator2D: + return PositionInterpolator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ProximitySensor2D: + return ProximitySensor2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ProximitySensor: + return ProximitySensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_QuantizationParameter: + return QuantizationParameter_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Rectangle: + return Rectangle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ScalarInterpolator: + return ScalarInterpolator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Script: + return Script_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Shape: + return Shape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Sound: + return Sound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Sound2D: + return Sound2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Sphere: + return Sphere_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SphereSensor: + return SphereSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SpotLight: + return SpotLight_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Switch: + return Switch_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TermCap: + return TermCap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Text: + return Text_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TextureCoordinate: + return TextureCoordinate_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TextureTransform: + return TextureTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TimeSensor: + return TimeSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TouchSensor: + return TouchSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Transform: + return Transform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Transform2D: + return Transform2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Valuator: + return Valuator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Viewpoint: + return Viewpoint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_VisibilitySensor: + return VisibilitySensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Viseme: + return Viseme_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_WorldInfo: + return WorldInfo_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AcousticMaterial: + return AcousticMaterial_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AcousticScene: + return AcousticScene_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ApplicationWindow: + return ApplicationWindow_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BAP: + return BAP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BDP: + return BDP_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Body: + return Body_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BodyDefTable: + return BodyDefTable_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BodySegmentConnectionHint: + return BodySegmentConnectionHint_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_DirectiveSound: + return DirectiveSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Hierarchical3DMesh: + return Hierarchical3DMesh_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MaterialKey: + return MaterialKey_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PerceptualParameters: + return PerceptualParameters_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TemporalTransform: + return TemporalTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TemporalGroup: + return TemporalGroup_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ServerCommand: + return ServerCommand_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_InputSensor: + return InputSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MatteTexture: + return MatteTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MediaBuffer: + return MediaBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MediaControl: + return MediaControl_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MediaSensor: + return MediaSensor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BitWrapper: + return BitWrapper_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CoordinateInterpolator4D: + return CoordinateInterpolator4D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_DepthImage: + return DepthImage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FFD: + return FFD_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Implicit: + return Implicit_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_Appearance: + return XXLFM_Appearance_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_BlendList: + return XXLFM_BlendList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_FrameList: + return XXLFM_FrameList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_LightMap: + return XXLFM_LightMap_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_SurfaceMapList: + return XXLFM_SurfaceMapList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXLFM_ViewMapList: + return XXLFM_ViewMapList_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MeshGrid: + return MeshGrid_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NonLinearDeformer: + return NonLinearDeformer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NurbsCurve: + return NurbsCurve_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NurbsCurve2D: + return NurbsCurve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_NurbsSurface: + return NurbsSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_OctreeImage: + return OctreeImage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXParticles: + return XXParticles_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXParticleInitBox: + return XXParticleInitBox_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXPlanarObstacle: + return XXPlanarObstacle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XXPointAttractor: + return XXPointAttractor_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PointTexture: + return PointTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PositionAnimator: + return PositionAnimator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PositionAnimator2D: + return PositionAnimator2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PositionInterpolator4D: + return PositionInterpolator4D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ProceduralTexture: + return ProceduralTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Quadric: + return Quadric_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBBone: + return SBBone_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBMuscle: + return SBMuscle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBSegment: + return SBSegment_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBSite: + return SBSite_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBSkinnedModel: + return SBSkinnedModel_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBVCAnimation: + return SBVCAnimation_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ScalarAnimator: + return ScalarAnimator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SimpleTexture: + return SimpleTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SolidRep: + return SolidRep_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SubdivisionSurface: + return SubdivisionSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SubdivSurfaceSector: + return SubdivSurfaceSector_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_WaveletSubdivisionSurface: + return WaveletSubdivisionSurface_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Clipper2D: + return Clipper2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ColorTransform: + return ColorTransform_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Ellipse: + return Ellipse_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_LinearGradient: + return LinearGradient_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PathLayout: + return PathLayout_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_RadialGradient: + return RadialGradient_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SynthesizedTexture: + return SynthesizedTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_TransformMatrix2D: + return TransformMatrix2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Viewport: + return Viewport_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XCurve2D: + return XCurve2D_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XFontStyle: + return XFontStyle_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_XLineProperties: + return XLineProperties_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AdvancedAudioBuffer: + return AdvancedAudioBuffer_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_AudioChannelConfig: + return AudioChannelConfig_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_DepthImageV2: + return DepthImageV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MorphShape: + return MorphShape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MultiTexture: + return MultiTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_PointTextureV2: + return PointTextureV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SBVCAnimationV2: + return SBVCAnimationV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SimpleTextureV2: + return SimpleTextureV2_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SurroundingSound: + return SurroundingSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Transform3DAudio: + return Transform3DAudio_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_WideSound: + return WideSound_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_ScoreShape: + return ScoreShape_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_MusicScore: + return MusicScore_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FootPrintSetNode: + return FootPrintSetNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FootPrintNode: + return FootPrintNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_BuildingPartNode: + return BuildingPartNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_RoofNode: + return RoofNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_FacadeNode: + return FacadeNode_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Shadow: + return Shadow_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_CacheTexture: + return CacheTexture_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_EnvironmentTest: + return EnvironmentTest_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_KeyNavigator: + return KeyNavigator_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_SpacePartition: + return SpacePartition_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + case TAG_MPEG4_Storage: + return Storage_get_aq_info(node, FieldIndex, QType, AType, b_min, b_max, QT13_bits); + default: + return 0; + } +} + +u32 gf_sg_mpeg4_node_get_child_ndt(GF_Node *node) +{ + switch (node->sgprivate->tag) { + case TAG_MPEG4_Anchor: + return NDT_SF3DNode; + case TAG_MPEG4_AudioBuffer: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioDelay: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioFX: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioMix: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioSource: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioSwitch: + return NDT_SFAudioNode; + case TAG_MPEG4_Billboard: + return NDT_SF3DNode; + case TAG_MPEG4_Collision: + return NDT_SF3DNode; + case TAG_MPEG4_CompositeTexture2D: + return NDT_SF2DNode; + case TAG_MPEG4_CompositeTexture3D: + return NDT_SF3DNode; + case TAG_MPEG4_Face: + return NDT_SF3DNode; + case TAG_MPEG4_FaceDefTables: + return NDT_SFFaceDefMeshNode; + case TAG_MPEG4_FDP: + return NDT_SFFaceDefTablesNode; + case TAG_MPEG4_Form: + return NDT_SF2DNode; + case TAG_MPEG4_Group: + return NDT_SF3DNode; + case TAG_MPEG4_LOD: + return NDT_SF3DNode; + case TAG_MPEG4_Layer2D: + return NDT_SF2DNode; + case TAG_MPEG4_Layer3D: + return NDT_SF3DNode; + case TAG_MPEG4_Layout: + return NDT_SF2DNode; + case TAG_MPEG4_OrderedGroup: + return NDT_SF3DNode; + case TAG_MPEG4_Switch: + return NDT_SF3DNode; + case TAG_MPEG4_Transform: + return NDT_SF3DNode; + case TAG_MPEG4_Transform2D: + return NDT_SF2DNode; + case TAG_MPEG4_BDP: + return NDT_SFBodyDefTableNode; + case TAG_MPEG4_Body: + return NDT_SF3DNode; + case TAG_MPEG4_TemporalTransform: + return NDT_SF3DNode; + case TAG_MPEG4_TemporalGroup: + return NDT_SFTemporalNode; + case TAG_MPEG4_FFD: + return NDT_SF3DNode; + case TAG_MPEG4_XXLFM_Appearance: + return NDT_SFLightMapNode; + case TAG_MPEG4_OctreeImage: + return NDT_SFDepthImageNode; + case TAG_MPEG4_XXParticles: + return NDT_SFInfluenceNode; + case TAG_MPEG4_SBBone: + return NDT_SF3DNode; + case TAG_MPEG4_SBSegment: + return NDT_SF3DNode; + case TAG_MPEG4_SBSite: + return NDT_SF3DNode; + case TAG_MPEG4_SBSkinnedModel: + return NDT_SFSBBoneNode; + case TAG_MPEG4_SBVCAnimation: + return NDT_SF3DNode; + case TAG_MPEG4_SubdivisionSurface: + return NDT_SFSubdivSurfaceSectorNode; + case TAG_MPEG4_Clipper2D: + return NDT_SF2DNode; + case TAG_MPEG4_ColorTransform: + return NDT_SF3DNode; + case TAG_MPEG4_PathLayout: + return NDT_SF2DNode; + case TAG_MPEG4_TransformMatrix2D: + return NDT_SF2DNode; + case TAG_MPEG4_AdvancedAudioBuffer: + return NDT_SFAudioNode; + case TAG_MPEG4_AudioChannelConfig: + return NDT_SFAudioNode; + case TAG_MPEG4_MorphShape: + return NDT_SF3DNode; + case TAG_MPEG4_MultiTexture: + return NDT_SFTextureNode; + case TAG_MPEG4_SBVCAnimationV2: + return NDT_SF3DNode; + case TAG_MPEG4_Transform3DAudio: + return NDT_SF3DNode; + case TAG_MPEG4_FootPrintSetNode: + return NDT_SFGeometryNode; + case TAG_MPEG4_BuildingPartNode: + return NDT_SFGeometryNode; + case TAG_MPEG4_FacadeNode: + return NDT_SFGeometryNode; + case TAG_MPEG4_Shadow: + return NDT_SF3DNode; + case TAG_MPEG4_SpacePartition: + return NDT_SF3DNode; + default: + return 0; + } +} + + +GF_EXPORT +u32 gf_node_mpeg4_type_by_class_name(const char *node_name) +{ + if(!node_name) return 0; + if (!strcmp(node_name, "Anchor")) return TAG_MPEG4_Anchor; + if (!strcmp(node_name, "AnimationStream")) return TAG_MPEG4_AnimationStream; + if (!strcmp(node_name, "Appearance")) return TAG_MPEG4_Appearance; + if (!strcmp(node_name, "AudioBuffer")) return TAG_MPEG4_AudioBuffer; + if (!strcmp(node_name, "AudioClip")) return TAG_MPEG4_AudioClip; + if (!strcmp(node_name, "AudioDelay")) return TAG_MPEG4_AudioDelay; + if (!strcmp(node_name, "AudioFX")) return TAG_MPEG4_AudioFX; + if (!strcmp(node_name, "AudioMix")) return TAG_MPEG4_AudioMix; + if (!strcmp(node_name, "AudioSource")) return TAG_MPEG4_AudioSource; + if (!strcmp(node_name, "AudioSwitch")) return TAG_MPEG4_AudioSwitch; + if (!strcmp(node_name, "Background")) return TAG_MPEG4_Background; + if (!strcmp(node_name, "Background2D")) return TAG_MPEG4_Background2D; + if (!strcmp(node_name, "Billboard")) return TAG_MPEG4_Billboard; + if (!strcmp(node_name, "Bitmap")) return TAG_MPEG4_Bitmap; + if (!strcmp(node_name, "Box")) return TAG_MPEG4_Box; + if (!strcmp(node_name, "Circle")) return TAG_MPEG4_Circle; + if (!strcmp(node_name, "Collision")) return TAG_MPEG4_Collision; + if (!strcmp(node_name, "Color")) return TAG_MPEG4_Color; + if (!strcmp(node_name, "ColorInterpolator")) return TAG_MPEG4_ColorInterpolator; + if (!strcmp(node_name, "CompositeTexture2D")) return TAG_MPEG4_CompositeTexture2D; + if (!strcmp(node_name, "CompositeTexture3D")) return TAG_MPEG4_CompositeTexture3D; + if (!strcmp(node_name, "Conditional")) return TAG_MPEG4_Conditional; + if (!strcmp(node_name, "Cone")) return TAG_MPEG4_Cone; + if (!strcmp(node_name, "Coordinate")) return TAG_MPEG4_Coordinate; + if (!strcmp(node_name, "Coordinate2D")) return TAG_MPEG4_Coordinate2D; + if (!strcmp(node_name, "CoordinateInterpolator")) return TAG_MPEG4_CoordinateInterpolator; + if (!strcmp(node_name, "CoordinateInterpolator2D")) return TAG_MPEG4_CoordinateInterpolator2D; + if (!strcmp(node_name, "Curve2D")) return TAG_MPEG4_Curve2D; + if (!strcmp(node_name, "Cylinder")) return TAG_MPEG4_Cylinder; + if (!strcmp(node_name, "CylinderSensor")) return TAG_MPEG4_CylinderSensor; + if (!strcmp(node_name, "DirectionalLight")) return TAG_MPEG4_DirectionalLight; + if (!strcmp(node_name, "DiscSensor")) return TAG_MPEG4_DiscSensor; + if (!strcmp(node_name, "ElevationGrid")) return TAG_MPEG4_ElevationGrid; + if (!strcmp(node_name, "Expression")) return TAG_MPEG4_Expression; + if (!strcmp(node_name, "Extrusion")) return TAG_MPEG4_Extrusion; + if (!strcmp(node_name, "Face")) return TAG_MPEG4_Face; + if (!strcmp(node_name, "FaceDefMesh")) return TAG_MPEG4_FaceDefMesh; + if (!strcmp(node_name, "FaceDefTables")) return TAG_MPEG4_FaceDefTables; + if (!strcmp(node_name, "FaceDefTransform")) return TAG_MPEG4_FaceDefTransform; + if (!strcmp(node_name, "FAP")) return TAG_MPEG4_FAP; + if (!strcmp(node_name, "FDP")) return TAG_MPEG4_FDP; + if (!strcmp(node_name, "FIT")) return TAG_MPEG4_FIT; + if (!strcmp(node_name, "Fog")) return TAG_MPEG4_Fog; + if (!strcmp(node_name, "FontStyle")) return TAG_MPEG4_FontStyle; + if (!strcmp(node_name, "Form")) return TAG_MPEG4_Form; + if (!strcmp(node_name, "Group")) return TAG_MPEG4_Group; + if (!strcmp(node_name, "ImageTexture")) return TAG_MPEG4_ImageTexture; + if (!strcmp(node_name, "IndexedFaceSet")) return TAG_MPEG4_IndexedFaceSet; + if (!strcmp(node_name, "IndexedFaceSet2D")) return TAG_MPEG4_IndexedFaceSet2D; + if (!strcmp(node_name, "IndexedLineSet")) return TAG_MPEG4_IndexedLineSet; + if (!strcmp(node_name, "IndexedLineSet2D")) return TAG_MPEG4_IndexedLineSet2D; + if (!strcmp(node_name, "Inline")) return TAG_MPEG4_Inline; + if (!strcmp(node_name, "LOD")) return TAG_MPEG4_LOD; + if (!strcmp(node_name, "Layer2D")) return TAG_MPEG4_Layer2D; + if (!strcmp(node_name, "Layer3D")) return TAG_MPEG4_Layer3D; + if (!strcmp(node_name, "Layout")) return TAG_MPEG4_Layout; + if (!strcmp(node_name, "LineProperties")) return TAG_MPEG4_LineProperties; + if (!strcmp(node_name, "ListeningPoint")) return TAG_MPEG4_ListeningPoint; + if (!strcmp(node_name, "Material")) return TAG_MPEG4_Material; + if (!strcmp(node_name, "Material2D")) return TAG_MPEG4_Material2D; + if (!strcmp(node_name, "MovieTexture")) return TAG_MPEG4_MovieTexture; + if (!strcmp(node_name, "NavigationInfo")) return TAG_MPEG4_NavigationInfo; + if (!strcmp(node_name, "Normal")) return TAG_MPEG4_Normal; + if (!strcmp(node_name, "NormalInterpolator")) return TAG_MPEG4_NormalInterpolator; + if (!strcmp(node_name, "OrderedGroup")) return TAG_MPEG4_OrderedGroup; + if (!strcmp(node_name, "OrientationInterpolator")) return TAG_MPEG4_OrientationInterpolator; + if (!strcmp(node_name, "PixelTexture")) return TAG_MPEG4_PixelTexture; + if (!strcmp(node_name, "PlaneSensor")) return TAG_MPEG4_PlaneSensor; + if (!strcmp(node_name, "PlaneSensor2D")) return TAG_MPEG4_PlaneSensor2D; + if (!strcmp(node_name, "PointLight")) return TAG_MPEG4_PointLight; + if (!strcmp(node_name, "PointSet")) return TAG_MPEG4_PointSet; + if (!strcmp(node_name, "PointSet2D")) return TAG_MPEG4_PointSet2D; + if (!strcmp(node_name, "PositionInterpolator")) return TAG_MPEG4_PositionInterpolator; + if (!strcmp(node_name, "PositionInterpolator2D")) return TAG_MPEG4_PositionInterpolator2D; + if (!strcmp(node_name, "ProximitySensor2D")) return TAG_MPEG4_ProximitySensor2D; + if (!strcmp(node_name, "ProximitySensor")) return TAG_MPEG4_ProximitySensor; + if (!strcmp(node_name, "QuantizationParameter")) return TAG_MPEG4_QuantizationParameter; + if (!strcmp(node_name, "Rectangle")) return TAG_MPEG4_Rectangle; + if (!strcmp(node_name, "ScalarInterpolator")) return TAG_MPEG4_ScalarInterpolator; + if (!strcmp(node_name, "Script")) return TAG_MPEG4_Script; + if (!strcmp(node_name, "Shape")) return TAG_MPEG4_Shape; + if (!strcmp(node_name, "Sound")) return TAG_MPEG4_Sound; + if (!strcmp(node_name, "Sound2D")) return TAG_MPEG4_Sound2D; + if (!strcmp(node_name, "Sphere")) return TAG_MPEG4_Sphere; + if (!strcmp(node_name, "SphereSensor")) return TAG_MPEG4_SphereSensor; + if (!strcmp(node_name, "SpotLight")) return TAG_MPEG4_SpotLight; + if (!strcmp(node_name, "Switch")) return TAG_MPEG4_Switch; + if (!strcmp(node_name, "TermCap")) return TAG_MPEG4_TermCap; + if (!strcmp(node_name, "Text")) return TAG_MPEG4_Text; + if (!strcmp(node_name, "TextureCoordinate")) return TAG_MPEG4_TextureCoordinate; + if (!strcmp(node_name, "TextureTransform")) return TAG_MPEG4_TextureTransform; + if (!strcmp(node_name, "TimeSensor")) return TAG_MPEG4_TimeSensor; + if (!strcmp(node_name, "TouchSensor")) return TAG_MPEG4_TouchSensor; + if (!strcmp(node_name, "Transform")) return TAG_MPEG4_Transform; + if (!strcmp(node_name, "Transform2D")) return TAG_MPEG4_Transform2D; + if (!strcmp(node_name, "Valuator")) return TAG_MPEG4_Valuator; + if (!strcmp(node_name, "Viewpoint")) return TAG_MPEG4_Viewpoint; + if (!strcmp(node_name, "VisibilitySensor")) return TAG_MPEG4_VisibilitySensor; + if (!strcmp(node_name, "Viseme")) return TAG_MPEG4_Viseme; + if (!strcmp(node_name, "WorldInfo")) return TAG_MPEG4_WorldInfo; + if (!strcmp(node_name, "AcousticMaterial")) return TAG_MPEG4_AcousticMaterial; + if (!strcmp(node_name, "AcousticScene")) return TAG_MPEG4_AcousticScene; + if (!strcmp(node_name, "ApplicationWindow")) return TAG_MPEG4_ApplicationWindow; + if (!strcmp(node_name, "BAP")) return TAG_MPEG4_BAP; + if (!strcmp(node_name, "BDP")) return TAG_MPEG4_BDP; + if (!strcmp(node_name, "Body")) return TAG_MPEG4_Body; + if (!strcmp(node_name, "BodyDefTable")) return TAG_MPEG4_BodyDefTable; + if (!strcmp(node_name, "BodySegmentConnectionHint")) return TAG_MPEG4_BodySegmentConnectionHint; + if (!strcmp(node_name, "DirectiveSound")) return TAG_MPEG4_DirectiveSound; + if (!strcmp(node_name, "Hierarchical3DMesh")) return TAG_MPEG4_Hierarchical3DMesh; + if (!strcmp(node_name, "MaterialKey")) return TAG_MPEG4_MaterialKey; + if (!strcmp(node_name, "PerceptualParameters")) return TAG_MPEG4_PerceptualParameters; + if (!strcmp(node_name, "TemporalTransform")) return TAG_MPEG4_TemporalTransform; + if (!strcmp(node_name, "TemporalGroup")) return TAG_MPEG4_TemporalGroup; + if (!strcmp(node_name, "ServerCommand")) return TAG_MPEG4_ServerCommand; + if (!strcmp(node_name, "InputSensor")) return TAG_MPEG4_InputSensor; + if (!strcmp(node_name, "MatteTexture")) return TAG_MPEG4_MatteTexture; + if (!strcmp(node_name, "MediaBuffer")) return TAG_MPEG4_MediaBuffer; + if (!strcmp(node_name, "MediaControl")) return TAG_MPEG4_MediaControl; + if (!strcmp(node_name, "MediaSensor")) return TAG_MPEG4_MediaSensor; + if (!strcmp(node_name, "BitWrapper")) return TAG_MPEG4_BitWrapper; + if (!strcmp(node_name, "CoordinateInterpolator4D")) return TAG_MPEG4_CoordinateInterpolator4D; + if (!strcmp(node_name, "DepthImage")) return TAG_MPEG4_DepthImage; + if (!strcmp(node_name, "FFD")) return TAG_MPEG4_FFD; + if (!strcmp(node_name, "Implicit")) return TAG_MPEG4_Implicit; + if (!strcmp(node_name, "XXLFM_Appearance")) return TAG_MPEG4_XXLFM_Appearance; + if (!strcmp(node_name, "XXLFM_BlendList")) return TAG_MPEG4_XXLFM_BlendList; + if (!strcmp(node_name, "XXLFM_FrameList")) return TAG_MPEG4_XXLFM_FrameList; + if (!strcmp(node_name, "XXLFM_LightMap")) return TAG_MPEG4_XXLFM_LightMap; + if (!strcmp(node_name, "XXLFM_SurfaceMapList")) return TAG_MPEG4_XXLFM_SurfaceMapList; + if (!strcmp(node_name, "XXLFM_ViewMapList")) return TAG_MPEG4_XXLFM_ViewMapList; + if (!strcmp(node_name, "MeshGrid")) return TAG_MPEG4_MeshGrid; + if (!strcmp(node_name, "NonLinearDeformer")) return TAG_MPEG4_NonLinearDeformer; + if (!strcmp(node_name, "NurbsCurve")) return TAG_MPEG4_NurbsCurve; + if (!strcmp(node_name, "NurbsCurve2D")) return TAG_MPEG4_NurbsCurve2D; + if (!strcmp(node_name, "NurbsSurface")) return TAG_MPEG4_NurbsSurface; + if (!strcmp(node_name, "OctreeImage")) return TAG_MPEG4_OctreeImage; + if (!strcmp(node_name, "XXParticles")) return TAG_MPEG4_XXParticles; + if (!strcmp(node_name, "XXParticleInitBox")) return TAG_MPEG4_XXParticleInitBox; + if (!strcmp(node_name, "XXPlanarObstacle")) return TAG_MPEG4_XXPlanarObstacle; + if (!strcmp(node_name, "XXPointAttractor")) return TAG_MPEG4_XXPointAttractor; + if (!strcmp(node_name, "PointTexture")) return TAG_MPEG4_PointTexture; + if (!strcmp(node_name, "PositionAnimator")) return TAG_MPEG4_PositionAnimator; + if (!strcmp(node_name, "PositionAnimator2D")) return TAG_MPEG4_PositionAnimator2D; + if (!strcmp(node_name, "PositionInterpolator4D")) return TAG_MPEG4_PositionInterpolator4D; if (!strcmp(node_name, "ProceduralTexture")) return TAG_MPEG4_ProceduralTexture; if (!strcmp(node_name, "Quadric")) return TAG_MPEG4_Quadric; if (!strcmp(node_name, "SBBone")) return TAG_MPEG4_SBBone; @@ -38202,201 +40010,396 @@ u32 gf_node_mpeg4_type_by_class_name(const char *node_name) s32 gf_sg_mpeg4_node_get_field_index_by_name(GF_Node *node, char *name) { switch (node->sgprivate->tag) { - case TAG_MPEG4_Anchor: return Anchor_get_field_index_by_name(name); - case TAG_MPEG4_AnimationStream: return AnimationStream_get_field_index_by_name(name); - case TAG_MPEG4_Appearance: return Appearance_get_field_index_by_name(name); - case TAG_MPEG4_AudioBuffer: return AudioBuffer_get_field_index_by_name(name); - case TAG_MPEG4_AudioClip: return AudioClip_get_field_index_by_name(name); - case TAG_MPEG4_AudioDelay: return AudioDelay_get_field_index_by_name(name); - case TAG_MPEG4_AudioFX: return AudioFX_get_field_index_by_name(name); - case TAG_MPEG4_AudioMix: return AudioMix_get_field_index_by_name(name); - case TAG_MPEG4_AudioSource: return AudioSource_get_field_index_by_name(name); - case TAG_MPEG4_AudioSwitch: return AudioSwitch_get_field_index_by_name(name); - case TAG_MPEG4_Background: return Background_get_field_index_by_name(name); - case TAG_MPEG4_Background2D: return Background2D_get_field_index_by_name(name); - case TAG_MPEG4_Billboard: return Billboard_get_field_index_by_name(name); - case TAG_MPEG4_Bitmap: return Bitmap_get_field_index_by_name(name); - case TAG_MPEG4_Box: return Box_get_field_index_by_name(name); - case TAG_MPEG4_Circle: return Circle_get_field_index_by_name(name); - case TAG_MPEG4_Collision: return Collision_get_field_index_by_name(name); - case TAG_MPEG4_Color: return Color_get_field_index_by_name(name); - case TAG_MPEG4_ColorInterpolator: return ColorInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_CompositeTexture2D: return CompositeTexture2D_get_field_index_by_name(name); - case TAG_MPEG4_CompositeTexture3D: return CompositeTexture3D_get_field_index_by_name(name); - case TAG_MPEG4_Conditional: return Conditional_get_field_index_by_name(name); - case TAG_MPEG4_Cone: return Cone_get_field_index_by_name(name); - case TAG_MPEG4_Coordinate: return Coordinate_get_field_index_by_name(name); - case TAG_MPEG4_Coordinate2D: return Coordinate2D_get_field_index_by_name(name); - case TAG_MPEG4_CoordinateInterpolator: return CoordinateInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_field_index_by_name(name); - case TAG_MPEG4_Curve2D: return Curve2D_get_field_index_by_name(name); - case TAG_MPEG4_Cylinder: return Cylinder_get_field_index_by_name(name); - case TAG_MPEG4_CylinderSensor: return CylinderSensor_get_field_index_by_name(name); - case TAG_MPEG4_DirectionalLight: return DirectionalLight_get_field_index_by_name(name); - case TAG_MPEG4_DiscSensor: return DiscSensor_get_field_index_by_name(name); - case TAG_MPEG4_ElevationGrid: return ElevationGrid_get_field_index_by_name(name); - case TAG_MPEG4_Expression: return Expression_get_field_index_by_name(name); - case TAG_MPEG4_Extrusion: return Extrusion_get_field_index_by_name(name); - case TAG_MPEG4_Face: return Face_get_field_index_by_name(name); - case TAG_MPEG4_FaceDefMesh: return FaceDefMesh_get_field_index_by_name(name); - case TAG_MPEG4_FaceDefTables: return FaceDefTables_get_field_index_by_name(name); - case TAG_MPEG4_FaceDefTransform: return FaceDefTransform_get_field_index_by_name(name); - case TAG_MPEG4_FAP: return FAP_get_field_index_by_name(name); - case TAG_MPEG4_FDP: return FDP_get_field_index_by_name(name); - case TAG_MPEG4_FIT: return FIT_get_field_index_by_name(name); - case TAG_MPEG4_Fog: return Fog_get_field_index_by_name(name); - case TAG_MPEG4_FontStyle: return FontStyle_get_field_index_by_name(name); - case TAG_MPEG4_Form: return Form_get_field_index_by_name(name); - case TAG_MPEG4_Group: return Group_get_field_index_by_name(name); - case TAG_MPEG4_ImageTexture: return ImageTexture_get_field_index_by_name(name); - case TAG_MPEG4_IndexedFaceSet: return IndexedFaceSet_get_field_index_by_name(name); - case TAG_MPEG4_IndexedFaceSet2D: return IndexedFaceSet2D_get_field_index_by_name(name); - case TAG_MPEG4_IndexedLineSet: return IndexedLineSet_get_field_index_by_name(name); - case TAG_MPEG4_IndexedLineSet2D: return IndexedLineSet2D_get_field_index_by_name(name); - case TAG_MPEG4_Inline: return Inline_get_field_index_by_name(name); - case TAG_MPEG4_LOD: return LOD_get_field_index_by_name(name); - case TAG_MPEG4_Layer2D: return Layer2D_get_field_index_by_name(name); - case TAG_MPEG4_Layer3D: return Layer3D_get_field_index_by_name(name); - case TAG_MPEG4_Layout: return Layout_get_field_index_by_name(name); - case TAG_MPEG4_LineProperties: return LineProperties_get_field_index_by_name(name); - case TAG_MPEG4_ListeningPoint: return ListeningPoint_get_field_index_by_name(name); - case TAG_MPEG4_Material: return Material_get_field_index_by_name(name); - case TAG_MPEG4_Material2D: return Material2D_get_field_index_by_name(name); - case TAG_MPEG4_MovieTexture: return MovieTexture_get_field_index_by_name(name); - case TAG_MPEG4_NavigationInfo: return NavigationInfo_get_field_index_by_name(name); - case TAG_MPEG4_Normal: return Normal_get_field_index_by_name(name); - case TAG_MPEG4_NormalInterpolator: return NormalInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_OrderedGroup: return OrderedGroup_get_field_index_by_name(name); - case TAG_MPEG4_OrientationInterpolator: return OrientationInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_PixelTexture: return PixelTexture_get_field_index_by_name(name); - case TAG_MPEG4_PlaneSensor: return PlaneSensor_get_field_index_by_name(name); - case TAG_MPEG4_PlaneSensor2D: return PlaneSensor2D_get_field_index_by_name(name); - case TAG_MPEG4_PointLight: return PointLight_get_field_index_by_name(name); - case TAG_MPEG4_PointSet: return PointSet_get_field_index_by_name(name); - case TAG_MPEG4_PointSet2D: return PointSet2D_get_field_index_by_name(name); - case TAG_MPEG4_PositionInterpolator: return PositionInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_PositionInterpolator2D: return PositionInterpolator2D_get_field_index_by_name(name); - case TAG_MPEG4_ProximitySensor2D: return ProximitySensor2D_get_field_index_by_name(name); - case TAG_MPEG4_ProximitySensor: return ProximitySensor_get_field_index_by_name(name); - case TAG_MPEG4_QuantizationParameter: return QuantizationParameter_get_field_index_by_name(name); - case TAG_MPEG4_Rectangle: return Rectangle_get_field_index_by_name(name); - case TAG_MPEG4_ScalarInterpolator: return ScalarInterpolator_get_field_index_by_name(name); - case TAG_MPEG4_Script: return Script_get_field_index_by_name(name); - case TAG_MPEG4_Shape: return Shape_get_field_index_by_name(name); - case TAG_MPEG4_Sound: return Sound_get_field_index_by_name(name); - case TAG_MPEG4_Sound2D: return Sound2D_get_field_index_by_name(name); - case TAG_MPEG4_Sphere: return Sphere_get_field_index_by_name(name); - case TAG_MPEG4_SphereSensor: return SphereSensor_get_field_index_by_name(name); - case TAG_MPEG4_SpotLight: return SpotLight_get_field_index_by_name(name); - case TAG_MPEG4_Switch: return Switch_get_field_index_by_name(name); - case TAG_MPEG4_TermCap: return TermCap_get_field_index_by_name(name); - case TAG_MPEG4_Text: return Text_get_field_index_by_name(name); - case TAG_MPEG4_TextureCoordinate: return TextureCoordinate_get_field_index_by_name(name); - case TAG_MPEG4_TextureTransform: return TextureTransform_get_field_index_by_name(name); - case TAG_MPEG4_TimeSensor: return TimeSensor_get_field_index_by_name(name); - case TAG_MPEG4_TouchSensor: return TouchSensor_get_field_index_by_name(name); - case TAG_MPEG4_Transform: return Transform_get_field_index_by_name(name); - case TAG_MPEG4_Transform2D: return Transform2D_get_field_index_by_name(name); - case TAG_MPEG4_Valuator: return Valuator_get_field_index_by_name(name); - case TAG_MPEG4_Viewpoint: return Viewpoint_get_field_index_by_name(name); - case TAG_MPEG4_VisibilitySensor: return VisibilitySensor_get_field_index_by_name(name); - case TAG_MPEG4_Viseme: return Viseme_get_field_index_by_name(name); - case TAG_MPEG4_WorldInfo: return WorldInfo_get_field_index_by_name(name); - case TAG_MPEG4_AcousticMaterial: return AcousticMaterial_get_field_index_by_name(name); - case TAG_MPEG4_AcousticScene: return AcousticScene_get_field_index_by_name(name); - case TAG_MPEG4_ApplicationWindow: return ApplicationWindow_get_field_index_by_name(name); - case TAG_MPEG4_BAP: return BAP_get_field_index_by_name(name); - case TAG_MPEG4_BDP: return BDP_get_field_index_by_name(name); - case TAG_MPEG4_Body: return Body_get_field_index_by_name(name); - case TAG_MPEG4_BodyDefTable: return BodyDefTable_get_field_index_by_name(name); - case TAG_MPEG4_BodySegmentConnectionHint: return BodySegmentConnectionHint_get_field_index_by_name(name); - case TAG_MPEG4_DirectiveSound: return DirectiveSound_get_field_index_by_name(name); - case TAG_MPEG4_Hierarchical3DMesh: return Hierarchical3DMesh_get_field_index_by_name(name); - case TAG_MPEG4_MaterialKey: return MaterialKey_get_field_index_by_name(name); - case TAG_MPEG4_PerceptualParameters: return PerceptualParameters_get_field_index_by_name(name); - case TAG_MPEG4_TemporalTransform: return TemporalTransform_get_field_index_by_name(name); - case TAG_MPEG4_TemporalGroup: return TemporalGroup_get_field_index_by_name(name); - case TAG_MPEG4_ServerCommand: return ServerCommand_get_field_index_by_name(name); - case TAG_MPEG4_InputSensor: return InputSensor_get_field_index_by_name(name); - case TAG_MPEG4_MatteTexture: return MatteTexture_get_field_index_by_name(name); - case TAG_MPEG4_MediaBuffer: return MediaBuffer_get_field_index_by_name(name); - case TAG_MPEG4_MediaControl: return MediaControl_get_field_index_by_name(name); - case TAG_MPEG4_MediaSensor: return MediaSensor_get_field_index_by_name(name); - case TAG_MPEG4_BitWrapper: return BitWrapper_get_field_index_by_name(name); - case TAG_MPEG4_CoordinateInterpolator4D: return CoordinateInterpolator4D_get_field_index_by_name(name); - case TAG_MPEG4_DepthImage: return DepthImage_get_field_index_by_name(name); - case TAG_MPEG4_FFD: return FFD_get_field_index_by_name(name); - case TAG_MPEG4_Implicit: return Implicit_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_Appearance: return XXLFM_Appearance_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_BlendList: return XXLFM_BlendList_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_FrameList: return XXLFM_FrameList_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_LightMap: return XXLFM_LightMap_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_SurfaceMapList: return XXLFM_SurfaceMapList_get_field_index_by_name(name); - case TAG_MPEG4_XXLFM_ViewMapList: return XXLFM_ViewMapList_get_field_index_by_name(name); - case TAG_MPEG4_MeshGrid: return MeshGrid_get_field_index_by_name(name); - case TAG_MPEG4_NonLinearDeformer: return NonLinearDeformer_get_field_index_by_name(name); - case TAG_MPEG4_NurbsCurve: return NurbsCurve_get_field_index_by_name(name); - case TAG_MPEG4_NurbsCurve2D: return NurbsCurve2D_get_field_index_by_name(name); - case TAG_MPEG4_NurbsSurface: return NurbsSurface_get_field_index_by_name(name); - case TAG_MPEG4_OctreeImage: return OctreeImage_get_field_index_by_name(name); - case TAG_MPEG4_XXParticles: return XXParticles_get_field_index_by_name(name); - case TAG_MPEG4_XXParticleInitBox: return XXParticleInitBox_get_field_index_by_name(name); - case TAG_MPEG4_XXPlanarObstacle: return XXPlanarObstacle_get_field_index_by_name(name); - case TAG_MPEG4_XXPointAttractor: return XXPointAttractor_get_field_index_by_name(name); - case TAG_MPEG4_PointTexture: return PointTexture_get_field_index_by_name(name); - case TAG_MPEG4_PositionAnimator: return PositionAnimator_get_field_index_by_name(name); - case TAG_MPEG4_PositionAnimator2D: return PositionAnimator2D_get_field_index_by_name(name); - case TAG_MPEG4_PositionInterpolator4D: return PositionInterpolator4D_get_field_index_by_name(name); - case TAG_MPEG4_ProceduralTexture: return ProceduralTexture_get_field_index_by_name(name); - case TAG_MPEG4_Quadric: return Quadric_get_field_index_by_name(name); - case TAG_MPEG4_SBBone: return SBBone_get_field_index_by_name(name); - case TAG_MPEG4_SBMuscle: return SBMuscle_get_field_index_by_name(name); - case TAG_MPEG4_SBSegment: return SBSegment_get_field_index_by_name(name); - case TAG_MPEG4_SBSite: return SBSite_get_field_index_by_name(name); - case TAG_MPEG4_SBSkinnedModel: return SBSkinnedModel_get_field_index_by_name(name); - case TAG_MPEG4_SBVCAnimation: return SBVCAnimation_get_field_index_by_name(name); - case TAG_MPEG4_ScalarAnimator: return ScalarAnimator_get_field_index_by_name(name); - case TAG_MPEG4_SimpleTexture: return SimpleTexture_get_field_index_by_name(name); - case TAG_MPEG4_SolidRep: return SolidRep_get_field_index_by_name(name); - case TAG_MPEG4_SubdivisionSurface: return SubdivisionSurface_get_field_index_by_name(name); - case TAG_MPEG4_SubdivSurfaceSector: return SubdivSurfaceSector_get_field_index_by_name(name); - case TAG_MPEG4_WaveletSubdivisionSurface: return WaveletSubdivisionSurface_get_field_index_by_name(name); - case TAG_MPEG4_Clipper2D: return Clipper2D_get_field_index_by_name(name); - case TAG_MPEG4_ColorTransform: return ColorTransform_get_field_index_by_name(name); - case TAG_MPEG4_Ellipse: return Ellipse_get_field_index_by_name(name); - case TAG_MPEG4_LinearGradient: return LinearGradient_get_field_index_by_name(name); - case TAG_MPEG4_PathLayout: return PathLayout_get_field_index_by_name(name); - case TAG_MPEG4_RadialGradient: return RadialGradient_get_field_index_by_name(name); - case TAG_MPEG4_SynthesizedTexture: return SynthesizedTexture_get_field_index_by_name(name); - case TAG_MPEG4_TransformMatrix2D: return TransformMatrix2D_get_field_index_by_name(name); - case TAG_MPEG4_Viewport: return Viewport_get_field_index_by_name(name); - case TAG_MPEG4_XCurve2D: return XCurve2D_get_field_index_by_name(name); - case TAG_MPEG4_XFontStyle: return XFontStyle_get_field_index_by_name(name); - case TAG_MPEG4_XLineProperties: return XLineProperties_get_field_index_by_name(name); - case TAG_MPEG4_AdvancedAudioBuffer: return AdvancedAudioBuffer_get_field_index_by_name(name); - case TAG_MPEG4_AudioChannelConfig: return AudioChannelConfig_get_field_index_by_name(name); - case TAG_MPEG4_DepthImageV2: return DepthImageV2_get_field_index_by_name(name); - case TAG_MPEG4_MorphShape: return MorphShape_get_field_index_by_name(name); - case TAG_MPEG4_MultiTexture: return MultiTexture_get_field_index_by_name(name); - case TAG_MPEG4_PointTextureV2: return PointTextureV2_get_field_index_by_name(name); - case TAG_MPEG4_SBVCAnimationV2: return SBVCAnimationV2_get_field_index_by_name(name); - case TAG_MPEG4_SimpleTextureV2: return SimpleTextureV2_get_field_index_by_name(name); - case TAG_MPEG4_SurroundingSound: return SurroundingSound_get_field_index_by_name(name); - case TAG_MPEG4_Transform3DAudio: return Transform3DAudio_get_field_index_by_name(name); - case TAG_MPEG4_WideSound: return WideSound_get_field_index_by_name(name); - case TAG_MPEG4_ScoreShape: return ScoreShape_get_field_index_by_name(name); - case TAG_MPEG4_MusicScore: return MusicScore_get_field_index_by_name(name); - case TAG_MPEG4_FootPrintSetNode: return FootPrintSetNode_get_field_index_by_name(name); - case TAG_MPEG4_FootPrintNode: return FootPrintNode_get_field_index_by_name(name); - case TAG_MPEG4_BuildingPartNode: return BuildingPartNode_get_field_index_by_name(name); - case TAG_MPEG4_RoofNode: return RoofNode_get_field_index_by_name(name); - case TAG_MPEG4_FacadeNode: return FacadeNode_get_field_index_by_name(name); - case TAG_MPEG4_Shadow: return Shadow_get_field_index_by_name(name); - case TAG_MPEG4_CacheTexture: return CacheTexture_get_field_index_by_name(name); - case TAG_MPEG4_EnvironmentTest: return EnvironmentTest_get_field_index_by_name(name); - case TAG_MPEG4_KeyNavigator: return KeyNavigator_get_field_index_by_name(name); - case TAG_MPEG4_SpacePartition: return SpacePartition_get_field_index_by_name(name); - case TAG_MPEG4_Storage: return Storage_get_field_index_by_name(name); + case TAG_MPEG4_Anchor: + return Anchor_get_field_index_by_name(name); + case TAG_MPEG4_AnimationStream: + return AnimationStream_get_field_index_by_name(name); + case TAG_MPEG4_Appearance: + return Appearance_get_field_index_by_name(name); + case TAG_MPEG4_AudioBuffer: + return AudioBuffer_get_field_index_by_name(name); + case TAG_MPEG4_AudioClip: + return AudioClip_get_field_index_by_name(name); + case TAG_MPEG4_AudioDelay: + return AudioDelay_get_field_index_by_name(name); + case TAG_MPEG4_AudioFX: + return AudioFX_get_field_index_by_name(name); + case TAG_MPEG4_AudioMix: + return AudioMix_get_field_index_by_name(name); + case TAG_MPEG4_AudioSource: + return AudioSource_get_field_index_by_name(name); + case TAG_MPEG4_AudioSwitch: + return AudioSwitch_get_field_index_by_name(name); + case TAG_MPEG4_Background: + return Background_get_field_index_by_name(name); + case TAG_MPEG4_Background2D: + return Background2D_get_field_index_by_name(name); + case TAG_MPEG4_Billboard: + return Billboard_get_field_index_by_name(name); + case TAG_MPEG4_Bitmap: + return Bitmap_get_field_index_by_name(name); + case TAG_MPEG4_Box: + return Box_get_field_index_by_name(name); + case TAG_MPEG4_Circle: + return Circle_get_field_index_by_name(name); + case TAG_MPEG4_Collision: + return Collision_get_field_index_by_name(name); + case TAG_MPEG4_Color: + return Color_get_field_index_by_name(name); + case TAG_MPEG4_ColorInterpolator: + return ColorInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_CompositeTexture2D: + return CompositeTexture2D_get_field_index_by_name(name); + case TAG_MPEG4_CompositeTexture3D: + return CompositeTexture3D_get_field_index_by_name(name); + case TAG_MPEG4_Conditional: + return Conditional_get_field_index_by_name(name); + case TAG_MPEG4_Cone: + return Cone_get_field_index_by_name(name); + case TAG_MPEG4_Coordinate: + return Coordinate_get_field_index_by_name(name); + case TAG_MPEG4_Coordinate2D: + return Coordinate2D_get_field_index_by_name(name); + case TAG_MPEG4_CoordinateInterpolator: + return CoordinateInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field_index_by_name(name); + case TAG_MPEG4_Curve2D: + return Curve2D_get_field_index_by_name(name); + case TAG_MPEG4_Cylinder: + return Cylinder_get_field_index_by_name(name); + case TAG_MPEG4_CylinderSensor: + return CylinderSensor_get_field_index_by_name(name); + case TAG_MPEG4_DirectionalLight: + return DirectionalLight_get_field_index_by_name(name); + case TAG_MPEG4_DiscSensor: + return DiscSensor_get_field_index_by_name(name); + case TAG_MPEG4_ElevationGrid: + return ElevationGrid_get_field_index_by_name(name); + case TAG_MPEG4_Expression: + return Expression_get_field_index_by_name(name); + case TAG_MPEG4_Extrusion: + return Extrusion_get_field_index_by_name(name); + case TAG_MPEG4_Face: + return Face_get_field_index_by_name(name); + case TAG_MPEG4_FaceDefMesh: + return FaceDefMesh_get_field_index_by_name(name); + case TAG_MPEG4_FaceDefTables: + return FaceDefTables_get_field_index_by_name(name); + case TAG_MPEG4_FaceDefTransform: + return FaceDefTransform_get_field_index_by_name(name); + case TAG_MPEG4_FAP: + return FAP_get_field_index_by_name(name); + case TAG_MPEG4_FDP: + return FDP_get_field_index_by_name(name); + case TAG_MPEG4_FIT: + return FIT_get_field_index_by_name(name); + case TAG_MPEG4_Fog: + return Fog_get_field_index_by_name(name); + case TAG_MPEG4_FontStyle: + return FontStyle_get_field_index_by_name(name); + case TAG_MPEG4_Form: + return Form_get_field_index_by_name(name); + case TAG_MPEG4_Group: + return Group_get_field_index_by_name(name); + case TAG_MPEG4_ImageTexture: + return ImageTexture_get_field_index_by_name(name); + case TAG_MPEG4_IndexedFaceSet: + return IndexedFaceSet_get_field_index_by_name(name); + case TAG_MPEG4_IndexedFaceSet2D: + return IndexedFaceSet2D_get_field_index_by_name(name); + case TAG_MPEG4_IndexedLineSet: + return IndexedLineSet_get_field_index_by_name(name); + case TAG_MPEG4_IndexedLineSet2D: + return IndexedLineSet2D_get_field_index_by_name(name); + case TAG_MPEG4_Inline: + return Inline_get_field_index_by_name(name); + case TAG_MPEG4_LOD: + return LOD_get_field_index_by_name(name); + case TAG_MPEG4_Layer2D: + return Layer2D_get_field_index_by_name(name); + case TAG_MPEG4_Layer3D: + return Layer3D_get_field_index_by_name(name); + case TAG_MPEG4_Layout: + return Layout_get_field_index_by_name(name); + case TAG_MPEG4_LineProperties: + return LineProperties_get_field_index_by_name(name); + case TAG_MPEG4_ListeningPoint: + return ListeningPoint_get_field_index_by_name(name); + case TAG_MPEG4_Material: + return Material_get_field_index_by_name(name); + case TAG_MPEG4_Material2D: + return Material2D_get_field_index_by_name(name); + case TAG_MPEG4_MovieTexture: + return MovieTexture_get_field_index_by_name(name); + case TAG_MPEG4_NavigationInfo: + return NavigationInfo_get_field_index_by_name(name); + case TAG_MPEG4_Normal: + return Normal_get_field_index_by_name(name); + case TAG_MPEG4_NormalInterpolator: + return NormalInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_OrderedGroup: + return OrderedGroup_get_field_index_by_name(name); + case TAG_MPEG4_OrientationInterpolator: + return OrientationInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_PixelTexture: + return PixelTexture_get_field_index_by_name(name); + case TAG_MPEG4_PlaneSensor: + return PlaneSensor_get_field_index_by_name(name); + case TAG_MPEG4_PlaneSensor2D: + return PlaneSensor2D_get_field_index_by_name(name); + case TAG_MPEG4_PointLight: + return PointLight_get_field_index_by_name(name); + case TAG_MPEG4_PointSet: + return PointSet_get_field_index_by_name(name); + case TAG_MPEG4_PointSet2D: + return PointSet2D_get_field_index_by_name(name); + case TAG_MPEG4_PositionInterpolator: + return PositionInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_PositionInterpolator2D: + return PositionInterpolator2D_get_field_index_by_name(name); + case TAG_MPEG4_ProximitySensor2D: + return ProximitySensor2D_get_field_index_by_name(name); + case TAG_MPEG4_ProximitySensor: + return ProximitySensor_get_field_index_by_name(name); + case TAG_MPEG4_QuantizationParameter: + return QuantizationParameter_get_field_index_by_name(name); + case TAG_MPEG4_Rectangle: + return Rectangle_get_field_index_by_name(name); + case TAG_MPEG4_ScalarInterpolator: + return ScalarInterpolator_get_field_index_by_name(name); + case TAG_MPEG4_Script: + return Script_get_field_index_by_name(name); + case TAG_MPEG4_Shape: + return Shape_get_field_index_by_name(name); + case TAG_MPEG4_Sound: + return Sound_get_field_index_by_name(name); + case TAG_MPEG4_Sound2D: + return Sound2D_get_field_index_by_name(name); + case TAG_MPEG4_Sphere: + return Sphere_get_field_index_by_name(name); + case TAG_MPEG4_SphereSensor: + return SphereSensor_get_field_index_by_name(name); + case TAG_MPEG4_SpotLight: + return SpotLight_get_field_index_by_name(name); + case TAG_MPEG4_Switch: + return Switch_get_field_index_by_name(name); + case TAG_MPEG4_TermCap: + return TermCap_get_field_index_by_name(name); + case TAG_MPEG4_Text: + return Text_get_field_index_by_name(name); + case TAG_MPEG4_TextureCoordinate: + return TextureCoordinate_get_field_index_by_name(name); + case TAG_MPEG4_TextureTransform: + return TextureTransform_get_field_index_by_name(name); + case TAG_MPEG4_TimeSensor: + return TimeSensor_get_field_index_by_name(name); + case TAG_MPEG4_TouchSensor: + return TouchSensor_get_field_index_by_name(name); + case TAG_MPEG4_Transform: + return Transform_get_field_index_by_name(name); + case TAG_MPEG4_Transform2D: + return Transform2D_get_field_index_by_name(name); + case TAG_MPEG4_Valuator: + return Valuator_get_field_index_by_name(name); + case TAG_MPEG4_Viewpoint: + return Viewpoint_get_field_index_by_name(name); + case TAG_MPEG4_VisibilitySensor: + return VisibilitySensor_get_field_index_by_name(name); + case TAG_MPEG4_Viseme: + return Viseme_get_field_index_by_name(name); + case TAG_MPEG4_WorldInfo: + return WorldInfo_get_field_index_by_name(name); + case TAG_MPEG4_AcousticMaterial: + return AcousticMaterial_get_field_index_by_name(name); + case TAG_MPEG4_AcousticScene: + return AcousticScene_get_field_index_by_name(name); + case TAG_MPEG4_ApplicationWindow: + return ApplicationWindow_get_field_index_by_name(name); + case TAG_MPEG4_BAP: + return BAP_get_field_index_by_name(name); + case TAG_MPEG4_BDP: + return BDP_get_field_index_by_name(name); + case TAG_MPEG4_Body: + return Body_get_field_index_by_name(name); + case TAG_MPEG4_BodyDefTable: + return BodyDefTable_get_field_index_by_name(name); + case TAG_MPEG4_BodySegmentConnectionHint: + return BodySegmentConnectionHint_get_field_index_by_name(name); + case TAG_MPEG4_DirectiveSound: + return DirectiveSound_get_field_index_by_name(name); + case TAG_MPEG4_Hierarchical3DMesh: + return Hierarchical3DMesh_get_field_index_by_name(name); + case TAG_MPEG4_MaterialKey: + return MaterialKey_get_field_index_by_name(name); + case TAG_MPEG4_PerceptualParameters: + return PerceptualParameters_get_field_index_by_name(name); + case TAG_MPEG4_TemporalTransform: + return TemporalTransform_get_field_index_by_name(name); + case TAG_MPEG4_TemporalGroup: + return TemporalGroup_get_field_index_by_name(name); + case TAG_MPEG4_ServerCommand: + return ServerCommand_get_field_index_by_name(name); + case TAG_MPEG4_InputSensor: + return InputSensor_get_field_index_by_name(name); + case TAG_MPEG4_MatteTexture: + return MatteTexture_get_field_index_by_name(name); + case TAG_MPEG4_MediaBuffer: + return MediaBuffer_get_field_index_by_name(name); + case TAG_MPEG4_MediaControl: + return MediaControl_get_field_index_by_name(name); + case TAG_MPEG4_MediaSensor: + return MediaSensor_get_field_index_by_name(name); + case TAG_MPEG4_BitWrapper: + return BitWrapper_get_field_index_by_name(name); + case TAG_MPEG4_CoordinateInterpolator4D: + return CoordinateInterpolator4D_get_field_index_by_name(name); + case TAG_MPEG4_DepthImage: + return DepthImage_get_field_index_by_name(name); + case TAG_MPEG4_FFD: + return FFD_get_field_index_by_name(name); + case TAG_MPEG4_Implicit: + return Implicit_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_Appearance: + return XXLFM_Appearance_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_BlendList: + return XXLFM_BlendList_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_FrameList: + return XXLFM_FrameList_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_LightMap: + return XXLFM_LightMap_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_SurfaceMapList: + return XXLFM_SurfaceMapList_get_field_index_by_name(name); + case TAG_MPEG4_XXLFM_ViewMapList: + return XXLFM_ViewMapList_get_field_index_by_name(name); + case TAG_MPEG4_MeshGrid: + return MeshGrid_get_field_index_by_name(name); + case TAG_MPEG4_NonLinearDeformer: + return NonLinearDeformer_get_field_index_by_name(name); + case TAG_MPEG4_NurbsCurve: + return NurbsCurve_get_field_index_by_name(name); + case TAG_MPEG4_NurbsCurve2D: + return NurbsCurve2D_get_field_index_by_name(name); + case TAG_MPEG4_NurbsSurface: + return NurbsSurface_get_field_index_by_name(name); + case TAG_MPEG4_OctreeImage: + return OctreeImage_get_field_index_by_name(name); + case TAG_MPEG4_XXParticles: + return XXParticles_get_field_index_by_name(name); + case TAG_MPEG4_XXParticleInitBox: + return XXParticleInitBox_get_field_index_by_name(name); + case TAG_MPEG4_XXPlanarObstacle: + return XXPlanarObstacle_get_field_index_by_name(name); + case TAG_MPEG4_XXPointAttractor: + return XXPointAttractor_get_field_index_by_name(name); + case TAG_MPEG4_PointTexture: + return PointTexture_get_field_index_by_name(name); + case TAG_MPEG4_PositionAnimator: + return PositionAnimator_get_field_index_by_name(name); + case TAG_MPEG4_PositionAnimator2D: + return PositionAnimator2D_get_field_index_by_name(name); + case TAG_MPEG4_PositionInterpolator4D: + return PositionInterpolator4D_get_field_index_by_name(name); + case TAG_MPEG4_ProceduralTexture: + return ProceduralTexture_get_field_index_by_name(name); + case TAG_MPEG4_Quadric: + return Quadric_get_field_index_by_name(name); + case TAG_MPEG4_SBBone: + return SBBone_get_field_index_by_name(name); + case TAG_MPEG4_SBMuscle: + return SBMuscle_get_field_index_by_name(name); + case TAG_MPEG4_SBSegment: + return SBSegment_get_field_index_by_name(name); + case TAG_MPEG4_SBSite: + return SBSite_get_field_index_by_name(name); + case TAG_MPEG4_SBSkinnedModel: + return SBSkinnedModel_get_field_index_by_name(name); + case TAG_MPEG4_SBVCAnimation: + return SBVCAnimation_get_field_index_by_name(name); + case TAG_MPEG4_ScalarAnimator: + return ScalarAnimator_get_field_index_by_name(name); + case TAG_MPEG4_SimpleTexture: + return SimpleTexture_get_field_index_by_name(name); + case TAG_MPEG4_SolidRep: + return SolidRep_get_field_index_by_name(name); + case TAG_MPEG4_SubdivisionSurface: + return SubdivisionSurface_get_field_index_by_name(name); + case TAG_MPEG4_SubdivSurfaceSector: + return SubdivSurfaceSector_get_field_index_by_name(name); + case TAG_MPEG4_WaveletSubdivisionSurface: + return WaveletSubdivisionSurface_get_field_index_by_name(name); + case TAG_MPEG4_Clipper2D: + return Clipper2D_get_field_index_by_name(name); + case TAG_MPEG4_ColorTransform: + return ColorTransform_get_field_index_by_name(name); + case TAG_MPEG4_Ellipse: + return Ellipse_get_field_index_by_name(name); + case TAG_MPEG4_LinearGradient: + return LinearGradient_get_field_index_by_name(name); + case TAG_MPEG4_PathLayout: + return PathLayout_get_field_index_by_name(name); + case TAG_MPEG4_RadialGradient: + return RadialGradient_get_field_index_by_name(name); + case TAG_MPEG4_SynthesizedTexture: + return SynthesizedTexture_get_field_index_by_name(name); + case TAG_MPEG4_TransformMatrix2D: + return TransformMatrix2D_get_field_index_by_name(name); + case TAG_MPEG4_Viewport: + return Viewport_get_field_index_by_name(name); + case TAG_MPEG4_XCurve2D: + return XCurve2D_get_field_index_by_name(name); + case TAG_MPEG4_XFontStyle: + return XFontStyle_get_field_index_by_name(name); + case TAG_MPEG4_XLineProperties: + return XLineProperties_get_field_index_by_name(name); + case TAG_MPEG4_AdvancedAudioBuffer: + return AdvancedAudioBuffer_get_field_index_by_name(name); + case TAG_MPEG4_AudioChannelConfig: + return AudioChannelConfig_get_field_index_by_name(name); + case TAG_MPEG4_DepthImageV2: + return DepthImageV2_get_field_index_by_name(name); + case TAG_MPEG4_MorphShape: + return MorphShape_get_field_index_by_name(name); + case TAG_MPEG4_MultiTexture: + return MultiTexture_get_field_index_by_name(name); + case TAG_MPEG4_PointTextureV2: + return PointTextureV2_get_field_index_by_name(name); + case TAG_MPEG4_SBVCAnimationV2: + return SBVCAnimationV2_get_field_index_by_name(name); + case TAG_MPEG4_SimpleTextureV2: + return SimpleTextureV2_get_field_index_by_name(name); + case TAG_MPEG4_SurroundingSound: + return SurroundingSound_get_field_index_by_name(name); + case TAG_MPEG4_Transform3DAudio: + return Transform3DAudio_get_field_index_by_name(name); + case TAG_MPEG4_WideSound: + return WideSound_get_field_index_by_name(name); + case TAG_MPEG4_ScoreShape: + return ScoreShape_get_field_index_by_name(name); + case TAG_MPEG4_MusicScore: + return MusicScore_get_field_index_by_name(name); + case TAG_MPEG4_FootPrintSetNode: + return FootPrintSetNode_get_field_index_by_name(name); + case TAG_MPEG4_FootPrintNode: + return FootPrintNode_get_field_index_by_name(name); + case TAG_MPEG4_BuildingPartNode: + return BuildingPartNode_get_field_index_by_name(name); + case TAG_MPEG4_RoofNode: + return RoofNode_get_field_index_by_name(name); + case TAG_MPEG4_FacadeNode: + return FacadeNode_get_field_index_by_name(name); + case TAG_MPEG4_Shadow: + return Shadow_get_field_index_by_name(name); + case TAG_MPEG4_CacheTexture: + return CacheTexture_get_field_index_by_name(name); + case TAG_MPEG4_EnvironmentTest: + return EnvironmentTest_get_field_index_by_name(name); + case TAG_MPEG4_KeyNavigator: + return KeyNavigator_get_field_index_by_name(name); + case TAG_MPEG4_SpacePartition: + return SpacePartition_get_field_index_by_name(name); + case TAG_MPEG4_Storage: + return Storage_get_field_index_by_name(name); default: return -1; } diff --git a/src/scenegraph/mpeg4_valuator.c b/src/scenegraph/mpeg4_valuator.c index dcda43d..5fe4050 100644 --- a/src/scenegraph/mpeg4_valuator.c +++ b/src/scenegraph/mpeg4_valuator.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -48,7 +48,7 @@ static void format_sftime_string(Fixed _val, char *str) static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType, Bool do_sum, u32 i, SFVec4f *output, u32 *num_out) { - + switch (inType) { case GF_SG_VRML_MFINT32: { @@ -59,7 +59,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->z = gf_mulfix(p->Factor3, vi) + p->Offset3; output->q = gf_mulfix(p->Factor4, vi) + p->Offset4; } - break; + break; case GF_SG_VRML_MFFLOAT: { Fixed sff = ((MFFloat *)inMFField)->vals[i]; @@ -68,7 +68,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->z = gf_mulfix(p->Factor3, sff) + p->Offset3; output->q = gf_mulfix(p->Factor4, sff) + p->Offset4; } - break; + break; case GF_SG_VRML_MFCOLOR: { SFColor sfc = ((MFColor *)inMFField)->vals[i]; @@ -78,7 +78,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->q = p->Offset4; *num_out = 3; } - break; + break; case GF_SG_VRML_MFVEC2F: { SFVec2f sfv = ((MFVec2f *)inMFField)->vals[i]; @@ -88,7 +88,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->q = p->Offset4; *num_out = 2; } - break; + break; case GF_SG_VRML_MFVEC3F: { SFVec3f sfv = ((MFVec3f *)inMFField)->vals[i]; @@ -98,7 +98,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->q = p->Offset4; *num_out = 3; } - break; + break; case GF_SG_VRML_MFVEC4F: case GF_SG_VRML_MFROTATION: { @@ -109,7 +109,7 @@ static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType output->q = gf_mulfix(p->Factor4, sfv.q) + p->Offset4; *num_out = 4; } - break; + break; case GF_SG_VRML_MFSTRING: /*cf below*/ output->x = output->y = output->z = output->q = 0; @@ -195,12 +195,13 @@ static void SetValuatorOutput(M_Valuator *p, SFVec4f *inSFField, GenMFField *inM } if (!i) sf_out = output; } - + gf_sg_vrml_mf_alloc(&p->outMFColor, GF_SG_VRML_MFCOLOR, count); gf_sg_vrml_mf_alloc(&p->outMFFloat, GF_SG_VRML_MFFLOAT, count); gf_sg_vrml_mf_alloc(&p->outMFInt32, GF_SG_VRML_MFINT32, count); gf_sg_vrml_mf_alloc(&p->outMFRotation, GF_SG_VRML_MFROTATION, count); - gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count); gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count); + gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count); + gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count); gf_sg_vrml_mf_alloc(&p->outMFVec3f, GF_SG_VRML_MFVEC3F, count); /*valuator is a special case, all routes are triggered*/ @@ -265,12 +266,12 @@ static void SetValuatorOutput(M_Valuator *p, SFVec4f *inSFField, GenMFField *inM case GF_SG_VRML_MFFLOAT: gf_sg_vrml_mf_alloc(&p->outMFFloat, GF_SG_VRML_MFFLOAT, count); - for (i=0; ioutMFFloat.vals[i] = mf_output->vals[i].x; break; case GF_SG_VRML_MFINT32: gf_sg_vrml_mf_alloc(&p->outMFInt32, GF_SG_VRML_MFINT32, count); - for (i=0; ioutMFInt32.vals[i] = FIX2INT(mf_output->vals[i].x); break; case GF_SG_VRML_MFCOLOR: @@ -306,7 +307,8 @@ static void SetValuatorOutput(M_Valuator *p, SFVec4f *inSFField, GenMFField *inM } break; case GF_SG_VRML_MFSTRING: - gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count); gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count); + gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count); + gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count); for (i=0; iinMFInt32, GF_SG_VRML_MFINT32); -} +} static void Valuator_SetInMFVec2f(GF_Node *n, GF_Route *route) { M_Valuator *_this = (M_Valuator *) n; @@ -501,7 +503,7 @@ Bool InitValuator(M_Valuator *node) gf_node_set_private((GF_Node*)node, temp); gf_node_set_callback_function((GF_Node*)node, valuator_destroy); - + return 1; } diff --git a/src/scenegraph/smil_anim.c b/src/scenegraph/smil_anim.c index 3a93fa5..04d3504 100644 --- a/src/scenegraph/smil_anim.c +++ b/src/scenegraph/smil_anim.c @@ -14,7 +14,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -82,7 +82,7 @@ GF_Err gf_node_animation_rem(GF_Node *node, u32 i) /************************************************************************************** * Helping functions for animation * **************************************************************************************/ -/* Sets the pointer to the attribute value with the pointer +/* Sets the pointer to the attribute value with the pointer to the value which passed (if unspecified) */ void gf_svg_attributes_resolve_unspecified(GF_FieldInfo *in, GF_FieldInfo *p, GF_FieldInfo *t) { @@ -97,20 +97,20 @@ void gf_svg_attributes_resolve_unspecified(GF_FieldInfo *in, GF_FieldInfo *p, GF } } -/* Replaces the pointer to the attribute value with the pointer +/* Replaces the pointer to the attribute value with the pointer to the value which is inherited (if inherited) */ void gf_svg_attributes_resolve_inherit(GF_FieldInfo *in, GF_FieldInfo *prop) { if (gf_svg_is_inherit(in)) *in = *prop; } -/* Replaces the pointer to the attribute value with the pointer +/* Replaces the pointer to the attribute value with the pointer to the value of the color attribute (if the current value is set to currentColor) */ void gf_svg_attributes_resolve_currentColor(GF_FieldInfo *in, GF_FieldInfo *current_color) { if ((in->fieldType == SVG_Paint_datatype) && gf_svg_is_current_color(in)) { *in = *current_color; - } + } } /************************************************************************************** @@ -146,34 +146,34 @@ static void gf_smil_anim_set(SMIL_Anim_RTI *rai) SMILAnimationAttributesPointers *animp = rai->animp; if (!animp->to) { - GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, - ("[SMIL Animation] Animation %s - set element without to attribute\n", - gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, + ("[SMIL Animation] Animation %s - set element without to attribute\n", + gf_node_get_log_name((GF_Node *)rai->anim_elt))); return; } if (!animp->to->type) { - GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, - ("[SMIL Animation] Animation %s - set element with an unparsed to attribute\n", - gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, + ("[SMIL Animation] Animation %s - set element with an unparsed to attribute\n", + gf_node_get_log_name((GF_Node *)rai->anim_elt))); return; } if (rai->change_detection_mode) { - /* if the set has been applied, unless next animations are additive we don't need + /* if the set has been applied, unless next animations are additive we don't need to apply it again */ if (rai->previous_coef > 0) rai->interpolated_value_changed = 0; else rai->interpolated_value_changed = 1; return; } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying set animation\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), - gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying set animation\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), + gf_node_get_log_name((GF_Node *)rai->anim_elt))); to_info.fieldType = animp->to->type; to_info.far_ptr = animp->to->value; /* we do not need to resolve currentColor values or inherit values here, - because no further interpolation is required for the animation and + because no further interpolation is required for the animation and because inheritance is applied after animations in the compositor. */ gf_svg_attributes_copy(&rai->interpolated_value, &to_info, 0); @@ -182,7 +182,7 @@ static void gf_smil_anim_set(SMIL_Anim_RTI *rai) } static void gf_smil_anim_use_keypoints_keytimes(SMIL_Anim_RTI *rai, Fixed normalized_simple_time, - Fixed *interpolation_coefficient, u32 *keyValueIndex) + Fixed *interpolation_coefficient, u32 *keyValueIndex) { SMILAnimationAttributesPointers *animp = rai->animp; u32 keyTimeIndex = 0; @@ -192,13 +192,13 @@ static void gf_smil_anim_use_keypoints_keytimes(SMIL_Anim_RTI *rai, Fixed normal /* Computing new interpolation coefficient */ if (rai->key_times_count) { - Fixed keyTimeBefore = 0, keyTimeAfter=0; + Fixed keyTimeBefore = 0, keyTimeAfter=0; for (keyTimeIndex = rai->previous_keytime_index; keyTimeIndex< rai->key_times_count; keyTimeIndex++) { Fixed *tm1, *t = (Fixed *)gf_list_get(*animp->keyTimes, keyTimeIndex); if (normalized_simple_time < *t) { rai->previous_keytime_index = keyTimeIndex; tm1 = (Fixed *) gf_list_get(*animp->keyTimes, keyTimeIndex-1); - if (tm1) keyTimeBefore = *tm1; + if (tm1) keyTimeBefore = *tm1; else keyTimeBefore = 0; keyTimeAfter = *t; break; @@ -207,19 +207,19 @@ static void gf_smil_anim_use_keypoints_keytimes(SMIL_Anim_RTI *rai, Fixed normal keyTimeIndex--; interval_duration = keyTimeAfter - keyTimeBefore; if (keyValueIndex) *keyValueIndex = keyTimeIndex; - if (interval_duration) + if (interval_duration) *interpolation_coefficient = gf_divfix(normalized_simple_time - keyTimeBefore, interval_duration); - else + else *interpolation_coefficient = FIX_ONE; if (!rai->change_detection_mode) - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - Using Key Times: index %d, interval duration %.2f, coeff: %.2f\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), - gf_node_get_log_name((GF_Node *)rai->anim_elt), - keyTimeIndex, - interval_duration, - interpolation_coefficient)); - } + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - Using Key Times: index %d, interval duration %.2f, coeff: %.2f\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), + gf_node_get_log_name((GF_Node *)rai->anim_elt), + keyTimeIndex, + interval_duration, + interpolation_coefficient)); + } if (rai->anim_elt->sgprivate->tag == TAG_SVG_animateMotion && rai->key_points_count) { Fixed *p1, *p2; @@ -228,14 +228,14 @@ static void gf_smil_anim_use_keypoints_keytimes(SMIL_Anim_RTI *rai, Fixed normal *interpolation_coefficient = *p1; } else { p2 = (Fixed *)gf_list_get(*animp->keyPoints, keyTimeIndex+1); - *interpolation_coefficient = gf_mulfix(FIX_ONE - *interpolation_coefficient, *p1) - + gf_mulfix(*interpolation_coefficient, (p2 ? *p2 : *p1)); + *interpolation_coefficient = gf_mulfix(FIX_ONE - *interpolation_coefficient, *p1) + + gf_mulfix(*interpolation_coefficient, (p2 ? *p2 : *p1)); } if (keyValueIndex) *keyValueIndex = 0; if (!rai->change_detection_mode) - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - Using Key Points: key Point Index %d, coeff: %.2f\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyTimeIndex, *interpolation_coefficient)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - Using Key Points: key Point Index %d, coeff: %.2f\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyTimeIndex, *interpolation_coefficient)); } } @@ -255,26 +255,26 @@ static void gf_smil_anim_animate_using_values(SMIL_Anim_RTI *rai, Fixed normaliz value_info_next = value_info; real_calcMode = (gf_svg_attribute_is_interpolatable(animp->values->type)? - (animp->calcMode ? *animp->calcMode : SMIL_CALCMODE_LINEAR): - SMIL_CALCMODE_DISCRETE - ); + (animp->calcMode ? *animp->calcMode : SMIL_CALCMODE_LINEAR): + SMIL_CALCMODE_DISCRETE + ); if (rai->values_count == 1) { if (rai->change_detection_mode) { - /* Since we have only 1 value, the previous key index should always be 0, + /* Since we have only 1 value, the previous key index should always be 0, unless the animation has not started or is reset (-1) */ if (rai->previous_key_index == 0) rai->interpolated_value_changed = 0; else rai->interpolated_value_changed = 1; return; } else { value_info.far_ptr = gf_list_get(values, 0); - /* no further interpolation needed + /* no further interpolation needed therefore no need to resolve inherit and currentColor */ gf_svg_attributes_copy(&rai->interpolated_value, &value_info, 0); rai->previous_key_index = 0; - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - Using values[0] as interpolation value\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - Using values[0] as interpolation value\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); return; } } @@ -312,9 +312,9 @@ static void gf_smil_anim_animate_using_values(SMIL_Anim_RTI *rai, Fixed normaliz if (rai->change_detection_mode) { if (real_calcMode == SMIL_CALCMODE_DISCRETE && rai->previous_key_index == (s32)keyValueIndex && rai->previous_coef != -FIX_ONE) { rai->interpolated_value_changed = 0; - } else if (rai->previous_key_index == (s32)keyValueIndex && rai->previous_coef == interpolation_coefficient) + } else if (rai->previous_key_index == (s32)keyValueIndex && rai->previous_coef == interpolation_coefficient) rai->interpolated_value_changed = 0; - else + else rai->interpolated_value_changed = 1; } else { rai->previous_key_index = keyValueIndex; @@ -322,48 +322,48 @@ static void gf_smil_anim_animate_using_values(SMIL_Anim_RTI *rai, Fixed normaliz switch (real_calcMode) { case SMIL_CALCMODE_DISCRETE: - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying discrete animation using values (key value index: %d)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying discrete animation using values (key value index: %d)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex)); value_info.far_ptr = gf_list_get(values, keyValueIndex); - /* no further interpolation needed + /* no further interpolation needed therefore no need to resolve inherit and currentColor */ gf_svg_attributes_copy(&rai->interpolated_value, &value_info, 0); break; case SMIL_CALCMODE_PACED: - /* TODO: at the moment assume it is linear */ + /* TODO: at the moment assume it is linear */ case SMIL_CALCMODE_SPLINE: - /* TODO: at the moment assume it is linear */ + /* TODO: at the moment assume it is linear */ case SMIL_CALCMODE_LINEAR: if (keyValueIndex == rai->values_count - 1) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying linear animation using values (setting last key value: %d)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying linear animation using values (setting last key value: %d)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex)); value_info.far_ptr = gf_list_get(values, rai->values_count - 1); - /* no further interpolation needed + /* no further interpolation needed therefore no need to resolve inherit and currentColor */ gf_svg_attributes_copy(&rai->interpolated_value, &value_info, 0); } else { - - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying linear animation using values (key value indices: %d, %d / coeff: %f)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex, keyValueIndex+1, interpolation_coefficient)); + + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying linear animation using values (key value indices: %d, %d / coeff: %f)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), keyValueIndex, keyValueIndex+1, interpolation_coefficient)); value_info.far_ptr = gf_list_get(values, keyValueIndex); if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(animp->values->type)) { - gf_svg_attributes_resolve_currentColor(&value_info, &rai->owner->current_color_value); + gf_svg_attributes_resolve_currentColor(&value_info, &rai->owner->current_color_value); gf_svg_attributes_resolve_inherit(&value_info, &rai->owner->parent_presentation_value); } - - value_info_next.far_ptr = gf_list_get(values, keyValueIndex+1); + + value_info_next.far_ptr = gf_list_get(values, keyValueIndex+1); if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(animp->values->type)) { gf_svg_attributes_resolve_currentColor(&value_info_next, &rai->owner->current_color_value); gf_svg_attributes_resolve_inherit(&value_info_next, &rai->owner->parent_presentation_value); } - gf_svg_attributes_interpolate(&value_info, - &value_info_next, - &rai->interpolated_value, - interpolation_coefficient, 1); + gf_svg_attributes_interpolate(&value_info, + &value_info_next, + &rai->interpolated_value, + interpolation_coefficient, 1); } break; } @@ -379,16 +379,16 @@ static void gf_smil_anim_animate_from_to(SMIL_Anim_RTI *rai, Fixed normalized_si u32 real_calcMode; real_calcMode = (animp->to && gf_svg_attribute_is_interpolatable(animp->to->type)? - (animp->calcMode ? *animp->calcMode : SMIL_CALCMODE_LINEAR): - SMIL_CALCMODE_DISCRETE - ); + (animp->calcMode ? *animp->calcMode : SMIL_CALCMODE_LINEAR): + SMIL_CALCMODE_DISCRETE + ); if (rai->change_detection_mode) { - if (rai->previous_coef == normalized_simple_time) + if (rai->previous_coef == normalized_simple_time) rai->interpolated_value_changed = 0; else { if (real_calcMode == SMIL_CALCMODE_DISCRETE && - useFrom == rai->previous_key_index) { + useFrom == rai->previous_key_index) { rai->interpolated_value_changed = 0; } else { rai->interpolated_value_changed = 1; @@ -404,14 +404,14 @@ static void gf_smil_anim_animate_from_to(SMIL_Anim_RTI *rai, Fixed normalized_si from_info.far_ptr = NULL; } - if (rai->is_first_anim) - gf_svg_attributes_resolve_unspecified(&from_info, - &rai->owner->specified_value, - &rai->default_transform_value); - else - gf_svg_attributes_resolve_unspecified(&from_info, - &rai->owner->presentation_value, - &rai->default_transform_value); + if (rai->is_first_anim) + gf_svg_attributes_resolve_unspecified(&from_info, + &rai->owner->specified_value, + &rai->default_transform_value); + else + gf_svg_attributes_resolve_unspecified(&from_info, + &rai->owner->presentation_value, + &rai->default_transform_value); if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(from_info.fieldType)) { gf_svg_attributes_resolve_currentColor(&from_info, &rai->owner->current_color_value); @@ -425,14 +425,14 @@ static void gf_smil_anim_animate_from_to(SMIL_Anim_RTI *rai, Fixed normalized_si to_info.far_ptr = NULL; } - if (rai->is_first_anim) - gf_svg_attributes_resolve_unspecified(&to_info, - &rai->owner->specified_value, - &rai->default_transform_value); - else - gf_svg_attributes_resolve_unspecified(&to_info, - &rai->owner->presentation_value, - &rai->default_transform_value); + if (rai->is_first_anim) + gf_svg_attributes_resolve_unspecified(&to_info, + &rai->owner->specified_value, + &rai->default_transform_value); + else + gf_svg_attributes_resolve_unspecified(&to_info, + &rai->owner->presentation_value, + &rai->default_transform_value); if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(to_info.fieldType)) { gf_svg_attributes_resolve_currentColor(&to_info, &rai->owner->current_color_value); @@ -445,22 +445,22 @@ static void gf_smil_anim_animate_from_to(SMIL_Anim_RTI *rai, Fixed normalized_si switch (real_calcMode) { case SMIL_CALCMODE_DISCRETE: - { - /* before half of the duration stay at 'from' and then switch to 'to' */ - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying from-to animation (using %s value)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), (useFrom?"from":"to"))); - gf_svg_attributes_copy(&rai->interpolated_value, (useFrom?&from_info:&to_info), 0); - rai->previous_key_index = useFrom; - } - break; + { + /* before half of the duration stay at 'from' and then switch to 'to' */ + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying from-to animation (using %s value)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), (useFrom?"from":"to"))); + gf_svg_attributes_copy(&rai->interpolated_value, (useFrom?&from_info:&to_info), 0); + rai->previous_key_index = useFrom; + } + break; case SMIL_CALCMODE_SPLINE: case SMIL_CALCMODE_PACED: case SMIL_CALCMODE_LINEAR: default: - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying from-to animation (linear interpolation, using coefficient %f)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), interpolation_coefficient)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying from-to animation (linear interpolation, using coefficient %f)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), interpolation_coefficient)); gf_svg_attributes_interpolate(&from_info, &to_info, &rai->interpolated_value, interpolation_coefficient, 1); break; } @@ -475,12 +475,12 @@ static void gf_smil_anim_animate_from_by(SMIL_Anim_RTI *rai, Fixed normalized_si s32 useFrom = (normalized_simple_time<=FIX_ONE/2); if (rai->change_detection_mode) { - if (rai->previous_coef == normalized_simple_time) + if (rai->previous_coef == normalized_simple_time) rai->interpolated_value_changed = 0; else { if (animp->calcMode && - *animp->calcMode == SMIL_CALCMODE_DISCRETE && - useFrom == rai->previous_key_index) { + *animp->calcMode == SMIL_CALCMODE_DISCRETE && + useFrom == rai->previous_key_index) { rai->interpolated_value_changed = 0; } else { rai->interpolated_value_changed = 1; @@ -496,20 +496,20 @@ static void gf_smil_anim_animate_from_by(SMIL_Anim_RTI *rai, Fixed normalized_si } else { from_info.fieldType = 0; from_info.far_ptr = NULL; - /* this is a by animation only, then, it is always additive, + /* this is a by animation only, then, it is always additive, we don't need the from value*/ - from_coef = 0; + from_coef = 0; } - if (rai->is_first_anim) - gf_svg_attributes_resolve_unspecified(&from_info, - &rai->owner->specified_value, - &rai->default_transform_value); - else - gf_svg_attributes_resolve_unspecified(&from_info, - &rai->owner->presentation_value, - &rai->default_transform_value); - + if (rai->is_first_anim) + gf_svg_attributes_resolve_unspecified(&from_info, + &rai->owner->specified_value, + &rai->default_transform_value); + else + gf_svg_attributes_resolve_unspecified(&from_info, + &rai->owner->presentation_value, + &rai->default_transform_value); + if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(from_info.fieldType)) { gf_svg_attributes_resolve_currentColor(&from_info, &rai->owner->current_color_value); gf_svg_attributes_resolve_inherit(&from_info, &rai->owner->parent_presentation_value); @@ -522,7 +522,7 @@ static void gf_smil_anim_animate_from_by(SMIL_Anim_RTI *rai, Fixed normalized_si by_info.fieldType = 0; by_info.far_ptr = NULL; } - + if (rai->owner->is_property && gf_svg_attribute_is_interpolatable(from_info.fieldType)) { gf_svg_attributes_resolve_currentColor(&by_info, &rai->owner->current_color_value); gf_svg_attributes_resolve_inherit(&by_info, &rai->owner->parent_presentation_value); @@ -530,41 +530,41 @@ static void gf_smil_anim_animate_from_by(SMIL_Anim_RTI *rai, Fixed normalized_si switch ((animp->calcMode ? *animp->calcMode : SMIL_CALCMODE_LINEAR)) { case SMIL_CALCMODE_DISCRETE: - { - /* before half of the duration stay at 'from' and then switch to 'to' */ - if (useFrom) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (setting from)", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); - gf_svg_attributes_muladd(from_coef, &from_info, 0, &by_info, &rai->interpolated_value, 0); - } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (setting from+by)", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); - gf_svg_attributes_muladd(from_coef, &from_info, FIX_ONE, &by_info, &rai->interpolated_value, 0); - } - rai->previous_key_index = useFrom; + { + /* before half of the duration stay at 'from' and then switch to 'to' */ + if (useFrom) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (setting from)", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + gf_svg_attributes_muladd(from_coef, &from_info, 0, &by_info, &rai->interpolated_value, 0); + } else { + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (setting from+by)", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + gf_svg_attributes_muladd(from_coef, &from_info, FIX_ONE, &by_info, &rai->interpolated_value, 0); } - break; + rai->previous_key_index = useFrom; + } + break; case SMIL_CALCMODE_SPLINE: case SMIL_CALCMODE_PACED: case SMIL_CALCMODE_LINEAR: default: - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (linear interpolation between from and from+by, coef: %f)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), normalized_simple_time)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying from-by animation (linear interpolation between from and from+by, coef: %f)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), normalized_simple_time)); gf_svg_attributes_muladd(from_coef, &from_info, normalized_simple_time, &by_info, &rai->interpolated_value, 0); break; } } } -static void gf_svg_compute_path_anim(SMIL_Anim_RTI *rai, GF_Matrix2D *m, Fixed normalized_simple_time) +static void gf_svg_compute_path_anim(SMIL_Anim_RTI *rai, GF_Matrix2D *m, Fixed normalized_simple_time) { Fixed offset; offset = gf_mulfix(normalized_simple_time, rai->length); gf_mx2d_init(*m); - + gf_path_iterator_get_transform(rai->path_iterator, offset, 1, m, 1, 0); //GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("offset: %f, position: (%f, %f)", offset, ((GF_Matrix2D *)rai->interpolated_value.far_ptr)->m[2], ((GF_Matrix2D *)rai->interpolated_value.far_ptr)->m[5])); switch (rai->rotate) { @@ -588,7 +588,7 @@ static void gf_smil_anim_animate_using_path(SMIL_Anim_RTI *rai, Fixed normalized gf_smil_anim_use_keypoints_keytimes(rai, normalized_simple_time, &interpolation_coefficient, NULL); if (rai->change_detection_mode) { - if (rai->previous_coef == interpolation_coefficient) + if (rai->previous_coef == interpolation_coefficient) rai->interpolated_value_changed = 0; else { rai->interpolated_value_changed = 1; @@ -596,10 +596,10 @@ static void gf_smil_anim_animate_using_path(SMIL_Anim_RTI *rai, Fixed normalized } else { rai->previous_coef = interpolation_coefficient; - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying path animation (coef: %f)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), normalized_simple_time)); - + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying path animation (coef: %f)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), normalized_simple_time)); + gf_svg_compute_path_anim(rai, (GF_Matrix2D*)rai->interpolated_value.far_ptr, interpolation_coefficient); } } @@ -611,27 +611,27 @@ static void gf_smil_anim_compute_interpolation_value(SMIL_Anim_RTI *rai, Fixed n if (rai->path) { gf_smil_anim_animate_using_path(rai, normalized_simple_time); } else if (rai->anim_elt->sgprivate->tag == TAG_SVG_set) { - gf_smil_anim_set(rai); + gf_smil_anim_set(rai); } else if (rai->values_count) { /* Ignore 'from'/'to'/'by'*/ gf_smil_anim_animate_using_values(rai, normalized_simple_time); } else if ((animp->by && animp->by->type) && (!animp->to || animp->to->type == 0)) { /* 'to' is not specified but 'by' is, so this is a 'by' animation or a 'from'-'by' animation */ gf_smil_anim_animate_from_by(rai, normalized_simple_time); - } else { + } else { /* Ignore 'by' if specified */ gf_smil_anim_animate_from_to(rai, normalized_simple_time); } #ifndef GPAC_DISABLE_LOG - if (0 && gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { + if (0 && gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { char *str; - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); str = gf_svg_dump_attribute(rai->anim_elt, &rai->interpolated_value); - gf_log("[SMIL Animation] Time %f - Animation %s - Interpolation value changed for attribute %s, new value: %s \n", - gf_node_get_scene_time(rai->anim_elt), gf_node_get_log_name(rai->anim_elt), - gf_svg_get_attribute_name(rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); + gf_log("[SMIL Animation] Time %f - Animation %s - Interpolation value changed for attribute %s, new value: %s \n", + gf_node_get_scene_time(rai->anim_elt), gf_node_get_log_name(rai->anim_elt), + gf_svg_get_attribute_name(rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); if (str) gf_free(str); } @@ -644,7 +644,7 @@ void gf_smil_anim_set_anim_runtime_in_timing(GF_Node *n) SVGTimedAnimBaseElement *timed_elt = NULL; SMIL_Timing_RTI *rti = NULL; GF_Node *target = NULL; - + if (!n) return; timed_elt = (SVGTimedAnimBaseElement *)n; @@ -681,16 +681,16 @@ static void gf_smil_anim_get_last_specified_value(SMIL_Anim_RTI *rai) if (!rai->last_specified_value.far_ptr) rai->last_specified_value.far_ptr = gf_malloc(sizeof(GF_Matrix2D)); gf_svg_compute_path_anim(rai, rai->last_specified_value.far_ptr, FIX_ONE); return; - } else if (rai->anim_elt->sgprivate->tag == TAG_SVG_set) { + } else if (rai->anim_elt->sgprivate->tag == TAG_SVG_set) { if (animp->to) { rai->last_specified_value.fieldType = animp->to->type; rai->last_specified_value.far_ptr = animp->to->value; } else { /* TODO ??? */ - GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, - ("[SMIL Animation] Animation %s - set element without to attribute\n", - gf_node_get_log_name((GF_Node *)rai->anim_elt))); - } + GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL, + ("[SMIL Animation] Animation %s - set element without to attribute\n", + gf_node_get_log_name((GF_Node *)rai->anim_elt))); + } return; } @@ -701,7 +701,7 @@ static void gf_smil_anim_get_last_specified_value(SMIL_Anim_RTI *rai) } else if ((animp->by && animp->by->type) && (!animp->to || animp->to->type == 0)) { rai->last_specified_value.fieldType = animp->by->type; rai->last_specified_value.far_ptr = animp->by->value; - } else if (animp->to) { + } else if (animp->to) { rai->last_specified_value.fieldType = animp->to->type; rai->last_specified_value.far_ptr = animp->to->value; } @@ -721,17 +721,17 @@ static void gf_smil_anim_get_last_specified_value(SMIL_Anim_RTI *rai) static void gf_smil_anim_apply_accumulate(SMIL_Anim_RTI *rai) { u32 nb_iterations; - + SMILAnimationAttributesPointers *animp = rai->animp; SMILTimingAttributesPointers *timingp = rai->timingp; nb_iterations = (timingp->runtime->current_interval ? timingp->runtime->current_interval->nb_iterations : 1); if (rai->change_detection_mode) { - if ((animp->accumulate && *animp->accumulate == SMIL_ACCUMULATE_SUM) - && nb_iterations > 0 - && rai->previous_iteration != (s32) nb_iterations) { - /* if we actually do accumulation and the number of iteration is different, + if ((animp->accumulate && *animp->accumulate == SMIL_ACCUMULATE_SUM) + && nb_iterations > 0 + && rai->previous_iteration != (s32) nb_iterations) { + /* if we actually do accumulation and the number of iteration is different, then we force the result as changed regardless of the result of the interpolation (TODO: check if this need to be improved)*/ rai->interpolated_value_changed = 1; @@ -744,26 +744,26 @@ static void gf_smil_anim_apply_accumulate(SMIL_Anim_RTI *rai) } if ((animp->accumulate && *animp->accumulate == SMIL_ACCUMULATE_SUM) && nb_iterations > 0) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying accumulation (iteration #%d)\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), nb_iterations)); - - gf_svg_attributes_muladd(FIX_ONE, &rai->interpolated_value, - INT2FIX(nb_iterations), &rai->last_specified_value, - &rai->interpolated_value, 1); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying accumulation (iteration #%d)\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt), nb_iterations)); + + gf_svg_attributes_muladd(FIX_ONE, &rai->interpolated_value, + INT2FIX(nb_iterations), &rai->last_specified_value, + &rai->interpolated_value, 1); if ((animp->from) && animp->by && (rai->last_specified_value.far_ptr == animp->by->value)) { /* this is a from-by animation, the last specified value is not the 'by' value but actually 'from'+'by', - we need to add nb_iterations times from to the interpolated_value + we need to add nb_iterations times from to the interpolated_value see (animate-elem-210-t.svg (upper two circles in the mid column, after 9s/14s */ GF_FieldInfo from_info; from_info.fieldType = rai->animp->from->type; from_info.far_ptr = rai->animp->from->value; - gf_svg_attributes_muladd(FIX_ONE, &rai->interpolated_value, - INT2FIX(nb_iterations), &from_info, - &rai->interpolated_value, 1); + gf_svg_attributes_muladd(FIX_ONE, &rai->interpolated_value, + INT2FIX(nb_iterations), &from_info, + &rai->interpolated_value, 1); } - } + } } } @@ -775,34 +775,34 @@ static void gf_smil_apply_additive(SMIL_Anim_RTI *rai) /* Apply additive behavior if required PV = (additive == sum ? PV + animp->IV : animp->IV); */ if (animp->additive && *animp->additive == SMIL_ADDITIVE_SUM) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying additive behavior\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying additive behavior\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); - gf_svg_attributes_add((rai->is_first_anim ? &rai->owner->specified_value : &rai->owner->presentation_value), - &rai->interpolated_value, - &rai->owner->presentation_value, - 1); + gf_svg_attributes_add((rai->is_first_anim ? &rai->owner->specified_value : &rai->owner->presentation_value), + &rai->interpolated_value, + &rai->owner->presentation_value, + 1); #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { - char *str; - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); - str = gf_svg_dump_attribute((GF_Node*)rai->anim_elt, &rai->owner->presentation_value); - gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), - gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); + if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { + char *str; + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); + str = gf_svg_dump_attribute((GF_Node*)rai->anim_elt, &rai->owner->presentation_value); + gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), + gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); - if (str) gf_free(str); - } + if (str) gf_free(str); + } #endif } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying non-additive behavior\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying non-additive behavior\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); - /* FIXME: if we switch pointers to avoid copying values, + /* FIXME: if we switch pointers to avoid copying values, we need to modify the address in the DOM node as well, we also need to take care about change detections. Not easy!! @@ -810,17 +810,17 @@ static void gf_smil_apply_additive(SMIL_Anim_RTI *rai) rai->owner->presentation_value.far_ptr = rai->interpolated_value.far_ptr; rai->interpolated_value.far_ptr = tmp; */ - + gf_svg_attributes_copy(&rai->owner->presentation_value, &rai->interpolated_value, 1); #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { char *str; - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); str = gf_svg_dump_attribute((GF_Node*)rai->anim_elt, &rai->owner->presentation_value); - gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), - gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); + gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), + gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); if (str) gf_free(str); } @@ -860,7 +860,7 @@ void gf_smil_anim_reset_variables(SMIL_Anim_RTI *rai) rai->anim_done = 0; } -/* copy/paste of the animate function +/* copy/paste of the animate function TODO: check if computations of interpolation value can be avoided. */ static void gf_smil_anim_freeze(SMIL_Timing_RTI *rti, Fixed normalized_simple_time) @@ -871,14 +871,14 @@ static void gf_smil_anim_freeze(SMIL_Timing_RTI *rti, Fixed normalized_simple_ti if (!rai || !animp) return; if (rai->change_detection_mode) { - if (rai->anim_done == 0) + if (rai->anim_done == 0) rai->interpolated_value_changed = 1; - else + else rai->interpolated_value_changed = 0; } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying freeze behavior\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying freeze behavior\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); gf_smil_anim_compute_interpolation_value(rai, normalized_simple_time); gf_smil_anim_apply_accumulate(rai); @@ -891,33 +891,33 @@ static void gf_smil_anim_remove(SMIL_Timing_RTI *rti, Fixed normalized_simple_ti { SMIL_Anim_RTI *rai = rti->rai; if (!rai) return; - + if (rai->change_detection_mode) { - if (rai->anim_done == 0) + if (rai->anim_done == 0) rai->interpolated_value_changed = 1; - else + else rai->interpolated_value_changed = 0; } else { - GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, - ("[SMIL Animation] Time %f - Animation %s - applying remove behavior\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, + ("[SMIL Animation] Time %f - Animation %s - applying remove behavior\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node *)rai->anim_elt))); /* TODO: see if we can avoid this copy by switching pointers */ gf_svg_attributes_copy(&rai->owner->presentation_value, &rai->owner->specified_value, 0); - /* TODO: check if we need to apply additive behavior even in fill='remove' + /* TODO: check if we need to apply additive behavior even in fill='remove' maybe (see animate-elem-211-t.svg) */ rai->anim_done = 1; #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { char *str; - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); str = gf_svg_dump_attribute((GF_Node*)rai->anim_elt, &rai->owner->presentation_value); - gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", - gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), - gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); + gf_log("[SMIL Animation] Time %f - Animation %s - Presentation value changed for attribute %s, new value: %s\n", + gf_node_get_scene_time((GF_Node*)rai->anim_elt), gf_node_get_log_name((GF_Node*)rai->anim_elt), + gf_svg_get_attribute_name((GF_Node*)rai->anim_elt, rai->owner->presentation_value.fieldIndex), str); if (str) gf_free(str); } #endif @@ -933,23 +933,23 @@ static void gf_smil_anim_evaluate(SMIL_Timing_RTI *rti, Fixed normalized_simple_ /* we are starting a new cycle of animation, therefore we need to reset the previous state variables like previous_keytime_index ... */ gf_smil_anim_reset_variables(rai); - case SMIL_TIMING_EVAL_UPDATE: + case SMIL_TIMING_EVAL_UPDATE: gf_smil_anim_animate(rti, normalized_simple_time); break; - case SMIL_TIMING_EVAL_FREEZE: + case SMIL_TIMING_EVAL_FREEZE: gf_smil_anim_freeze(rti, normalized_simple_time); break; - case SMIL_TIMING_EVAL_REMOVE: + case SMIL_TIMING_EVAL_REMOVE: gf_smil_anim_remove(rti, normalized_simple_time); break; - case SMIL_TIMING_EVAL_FRACTION: + case SMIL_TIMING_EVAL_FRACTION: gf_smil_anim_animate_with_fraction(rti, normalized_simple_time); break; -/* - discard should be done before in smil_notify_time - case SMIL_TIMING_EVAL_DISCARD: - break; -*/ + /* + discard should be done before in smil_notify_time + case SMIL_TIMING_EVAL_DISCARD: + break; + */ } } /************************************************************************************** @@ -963,7 +963,7 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr #ifndef GPAC_DISABLE_LOG u32 time=0; - if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { time = gf_sys_clock(); } #endif @@ -977,35 +977,35 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr SMIL_AttributeAnimations *aa; - aa = (SMIL_AttributeAnimations *)gf_node_animation_get(node, i); + aa = (SMIL_AttributeAnimations *)gf_node_animation_get(node, i); count = gf_list_count(aa->anims); if (!count) continue; - + aa->presentation_value_changed = 0; if (aa->is_property) { - /* Storing the pointer to the parent presentation value, + /* Storing the pointer to the parent presentation value, i.e. the presentation value produced at the parent level in the tree */ aa->parent_presentation_value = aa->presentation_value; - aa->parent_presentation_value.far_ptr = - gf_svg_get_property_pointer((SVG_Element *)node, aa->orig_dom_ptr, render_svg_props); + aa->parent_presentation_value.far_ptr = + gf_svg_get_property_pointer((SVG_Element *)node, aa->orig_dom_ptr, render_svg_props); - /* Storing also the pointer to the presentation value of the color property + /* Storing also the pointer to the presentation value of the color property (special handling of the keyword 'currentColor' if used in animation values) */ gf_node_get_attribute_by_tag(node, TAG_SVG_ATT_color, 1, 1, &info); aa->current_color_value.far_ptr = info.far_ptr; } - /* We start with the last animation (TODO in the execution order), then scan in the reverse order - up to the first animation which is not additive, to determine if the presentation value will change + /* We start with the last animation (TODO in the execution order), then scan in the reverse order + up to the first animation which is not additive, to determine if the presentation value will change We evaluate each animation, but only in the 'change_detection_mode' */ for (j = count-1; j >= 0; j--) { - SMIL_Anim_RTI *rai = (SMIL_Anim_RTI *)gf_list_get(aa->anims, j); + SMIL_Anim_RTI *rai = (SMIL_Anim_RTI *)gf_list_get(aa->anims, j); SMIL_Timing_RTI *rti = rai->timingp->runtime; rai->interpolated_value_changed = 0; - /* The evaluate_status has been updated when notifying the new scene time to this animation, + /* The evaluate_status has been updated when notifying the new scene time to this animation, i.e. before the scene tree traversal */ if (rti->evaluate_status) { rai->change_detection_mode = 1; @@ -1025,7 +1025,7 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr we start in the forward order from the j were the previous step stopped (i.e. the first anim in replace mode) and evaluate each animation, in the computation mode (change_detection_mode = 0)*/ for (j++; j<(s32)count; j++) { - SMIL_Anim_RTI *rai = (SMIL_Anim_RTI *)gf_list_get(aa->anims, j); + SMIL_Anim_RTI *rai = (SMIL_Anim_RTI *)gf_list_get(aa->anims, j); SMIL_Timing_RTI *rti = rai->timingp->runtime; if (j == 0) rai->is_first_anim = 1; @@ -1039,19 +1039,19 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr } } -/* DEBUG: uncomment this line to remove animation effect, and keep animation computation */ + /* DEBUG: uncomment this line to remove animation effect, and keep animation computation */ // gf_svg_attributes_copy(&aa->presentation_value, &aa->specified_value, 0); #ifndef GPAC_DISABLE_LOG if (aa->presentation_value_changed) { - if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_SMIL, GF_LOG_DEBUG)) { char *str; - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SMIL); str = gf_svg_dump_attribute(node, &aa->presentation_value); - gf_log("[SMIL Animation] Time %f - Element %s - Presentation value changed for attribute %s, new value: %s - dirty flags %x\n", - gf_node_get_scene_time(node), gf_node_get_log_name(node), - gf_svg_get_attribute_name(node, aa->presentation_value.fieldIndex), str, aa->dirty_flags); + gf_log("[SMIL Animation] Time %f - Element %s - Presentation value changed for attribute %s, new value: %s - dirty flags %x\n", + gf_node_get_scene_time(node), gf_node_get_log_name(node), + gf_svg_get_attribute_name(node, aa->presentation_value.fieldIndex), str, aa->dirty_flags); if (str) gf_free(str); } @@ -1059,7 +1059,7 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr #endif /* we only set dirty flags when a real flag is set to avoid unnecessary computation - for example, it is not necessary to set it when the anim is an animateTransform + for example, it is not necessary to set it when the anim is an animateTransform since there is no associated flag */ if (aa->dirty_flags) { if (aa->presentation_value_changed) { @@ -1072,7 +1072,7 @@ void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_pr } #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_RTI, GF_LOG_DEBUG)) { time_spent_in_anim += gf_sys_clock() - time; } #endif @@ -1087,9 +1087,9 @@ GF_Node *gf_smil_anim_get_target(GF_Node *e) return (xlinkp && xlinkp->href) ? xlinkp->href->target : NULL; } -/* Attributes from the animation elements are not easy to use during runtime, - the runtime info is a set of easy to use structures. - This function initializes them (interpolation values ...) +/* Attributes from the animation elements are not easy to use during runtime, + the runtime info is a set of easy to use structures. + This function initializes them (interpolation values ...) Needs to be called after gf_smil_timing_init_runtime_info */ void gf_smil_anim_init_runtime_info(GF_Node *e) { @@ -1124,7 +1124,7 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) } else { /* All animation elements should have a target attribute except for animateMotion cf http://www.w3.org/mid/u403c21ajf1sjqtk58g0g38eaep9f9g2ss@hive.bjoern.hoehrmann.de - "For animateMotion, the attributeName is implied and cannot be specified; + "For animateMotion, the attributeName is implied and cannot be specified; animateTransform requires specification of the attribute name and any attribute that is a transform-like attribute can be a target, e.g. gradientTransform."*/ @@ -1135,19 +1135,19 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) gf_mx2d_init(*(GF_Matrix2D *)target_attribute.far_ptr); break; default: - GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL, - ("[SMIL Animation] Missing attributeName attribute on element %s\n", - gf_node_get_log_name((GF_Node*)e) )); + GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL, + ("[SMIL Animation] Missing attributeName attribute on element %s\n", + gf_node_get_log_name((GF_Node*)e) )); return; } } - + if (animp->attributeType && *animp->attributeType == SMIL_ATTRIBUTETYPE_CSS) { /* see example animate-elem-219-t.svg from the SVG test suite, upper row */ if (!gf_svg_is_property(target, &target_attribute)) { - GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL, - ("[SMIL Animation] Using CSS attributeType for an animation on an attribute which is not a property %s\n", - gf_node_get_log_name((GF_Node*)e) )); + GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL, + ("[SMIL Animation] Using CSS attributeType for an animation on an attribute which is not a property %s\n", + gf_node_get_log_name((GF_Node*)e) )); return; } } @@ -1155,7 +1155,7 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) /* Creation and setup of the runtime structure for animation */ GF_SAFEALLOC(rai, SMIL_Anim_RTI) - rai->anim_elt = e; + rai->anim_elt = e; rai->animp = animp; rai->timingp = timingp; rai->xlinkp = xlinkp; @@ -1180,38 +1180,38 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) if (!rai->values_count && /* 'values' attribute not specified */ - (!animp->to || animp->to->type == 0) && /* 'to' attribute not specified */ - (!animp->from || animp->from->type == 0) && /* 'from' attribute not specified */ - (animp->by && animp->by->type != 0)) { /* 'by' attribute specified */ + (!animp->to || animp->to->type == 0) && /* 'to' attribute not specified */ + (!animp->from || animp->from->type == 0) && /* 'from' attribute not specified */ + (animp->by && animp->by->type != 0)) { /* 'by' attribute specified */ /* if this is a 'by' animation without from the animation is defined to be additive see http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#AnimationNS-FromToBy we override the additive attribute */ - if (!animp->additive) { + if (!animp->additive) { /* this case can only happen with dynamic allocation of attributes */ GF_FieldInfo info; gf_node_get_attribute_by_tag(e, TAG_SVG_ATT_additive, 1, 0, &info); animp->additive = info.far_ptr; - } + } if (*animp->additive == SMIL_ADDITIVE_REPLACE) { GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL, ("[SMIL Animation] Warning: by-animations cannot use additive=\"replace\"\n")); - } + } *animp->additive = SMIL_ADDITIVE_SUM; - } + } - /*TODO + /*TODO http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#animationNS-ToAnimation To animation defines its own kind of additive semantics, so the additive attribute is ignored. */ - /*TODO + /*TODO http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#animationNS-ToAnimation - Because to animation is defined in terms of absolute values of the target attribute, + Because to animation is defined in terms of absolute values of the target attribute, cumulative animation is not defined: */ - /* TODO + /* TODO http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#animationNS-setElement - The set element is non-additive. The additive and accumulate attributes are not allowed, + The set element is non-additive. The additive and accumulate attributes are not allowed, and will be ignored if specified. */ @@ -1232,22 +1232,22 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) } child = ((SVG_Element *)e)->children; - if ((!animp->to || animp->to->type == 0) && - (!animp->by || animp->by->type == 0) && - (!animp->values || animp->values->type == 0)) { + if ((!animp->to || animp->to->type == 0) && + (!animp->by || animp->by->type == 0) && + (!animp->values || animp->values->type == 0)) { #if USE_GF_PATH if (!gf_path_is_empty(the_path)) { rai->path = the_path; rai->path_iterator = gf_path_iterator_new(rai->path); rai->length = gf_path_iterator_get_length(rai->path_iterator); - } + } #else rai->path = gf_path_new(); if (gf_list_count(the_path->points)) { gf_svg_path_build(rai->path, the_path->commands, the_path->points); rai->path_iterator = gf_path_iterator_new(rai->path); rai->length = gf_path_iterator_get_length(rai->path_iterator); - } + } #endif else { while (child) { @@ -1258,27 +1258,27 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) if (gf_node_get_attribute_by_tag(child->node, TAG_XLINK_ATT_href, 0, 0, &info) == GF_OK) { XMLRI *iri = (XMLRI *)info.far_ptr; if (iri->target) used_path = iri->target; - else if (iri->string) used_path = - (GF_Node *)gf_sg_find_node_by_name(gf_node_get_graph(child->node), iri->string); + else if (iri->string) used_path = + (GF_Node *)gf_sg_find_node_by_name(gf_node_get_graph(child->node), iri->string); if (used_path && gf_node_get_tag(used_path) == TAG_SVG_path) { gf_node_get_attribute_by_tag(used_path, TAG_SVG_ATT_d, 1, 0, &info); #if USE_GF_PATH rai->path = (SVG_PathData *)info.far_ptr; #else - gf_svg_path_build(rai->path, - ((SVG_PathData *)info.far_ptr)->commands, - ((SVG_PathData *)info.far_ptr)->points); + gf_svg_path_build(rai->path, + ((SVG_PathData *)info.far_ptr)->commands, + ((SVG_PathData *)info.far_ptr)->points); #endif rai->path_iterator = gf_path_iterator_new(rai->path); rai->length = gf_path_iterator_get_length(rai->path_iterator); } - } + } break; } child = child->next; } } - } + } } /* for all animations, check if there is already one animation on this attribute, @@ -1299,8 +1299,8 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) aa->is_property = gf_svg_is_property(target, &target_attribute); aa->current_color_value.fieldType = SVG_Paint_datatype; - /* We copy (one copy for all animations on the same attribute) the DOM specified - value before any animation starts (because the animation will override it), + /* We copy (one copy for all animations on the same attribute) the DOM specified + value before any animation starts (because the animation will override it), we also save the initial memory address of the specified value (orig_dom_ptr) for inheritance hack */ aa->specified_value = target_attribute; @@ -1311,7 +1311,7 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) /* Now, the initial memory address of the specified value holds the presentation value, and the presentation value is initialized */ aa->presentation_value = target_attribute; - + aa->anims = gf_list_new(); gf_list_add(aa->anims, rai); gf_node_animation_add(target, aa); @@ -1328,8 +1328,8 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) rai->owner = aa; gf_smil_anim_get_last_specified_value(rai); - /* for animation (unlike other timed elements like video), the evaluation (i.e. interpolation) cannot be done - during timing evaluation, because due to inheritance, interpolation can only be computed + /* for animation (unlike other timed elements like video), the evaluation (i.e. interpolation) cannot be done + during timing evaluation, because due to inheritance, interpolation can only be computed during scene tree traversal, therefore we need to postpone evaluation of the timed element */ timingp->runtime->postpone = 1; @@ -1338,15 +1338,15 @@ void gf_smil_anim_init_runtime_info(GF_Node *e) void gf_smil_anim_delete_runtime_info(SMIL_Anim_RTI *rai) { - gf_svg_delete_attribute_value(rai->interpolated_value.fieldType, - rai->interpolated_value.far_ptr, - rai->anim_elt->sgprivate->scenegraph); + gf_svg_delete_attribute_value(rai->interpolated_value.fieldType, + rai->interpolated_value.far_ptr, + rai->anim_elt->sgprivate->scenegraph); if (rai->path) { - gf_svg_delete_attribute_value(rai->last_specified_value.fieldType, - rai->last_specified_value.far_ptr, - rai->anim_elt->sgprivate->scenegraph); + gf_svg_delete_attribute_value(rai->last_specified_value.fieldType, + rai->last_specified_value.far_ptr, + rai->anim_elt->sgprivate->scenegraph); } -#if USE_GF_PATH +#if USE_GF_PATH #else if (rai->path) gf_path_del(rai->path); #endif @@ -1371,9 +1371,9 @@ void gf_smil_anim_remove_from_target(GF_Node *anim, GF_Node *target) } if (gf_list_count(aa->anims) == 0) { gf_list_del(aa->anims); - gf_svg_delete_attribute_value(aa->specified_value.fieldType, - aa->specified_value.far_ptr, - target->sgprivate->scenegraph); + gf_svg_delete_attribute_value(aa->specified_value.fieldType, + aa->specified_value.far_ptr, + target->sgprivate->scenegraph); aa->presentation_value.far_ptr = aa->orig_dom_ptr; gf_node_animation_rem((GF_Node *)target, i); gf_free(aa); @@ -1388,14 +1388,14 @@ void gf_smil_anim_delete_animations(GF_Node *e) for (i = 0; i < gf_node_animation_count(e); i ++) { SMIL_Anim_RTI *rai; SMIL_AttributeAnimations *aa = (SMIL_AttributeAnimations *)gf_node_animation_get(e, i); - gf_svg_delete_attribute_value(aa->specified_value.fieldType, - aa->specified_value.far_ptr, - e->sgprivate->scenegraph); + gf_svg_delete_attribute_value(aa->specified_value.fieldType, + aa->specified_value.far_ptr, + e->sgprivate->scenegraph); j=0; while ((rai = (SMIL_Anim_RTI *)gf_list_enum(aa->anims, &j))) { rai->xlinkp->href->target = NULL; gf_smil_anim_delete_runtime_info(rai); - } + } gf_list_del(aa->anims); gf_free(aa); } @@ -1408,12 +1408,12 @@ void gf_smil_anim_init_discard(GF_Node *node) XLinkAttributesPointers *xlinkp = NULL; SVGTimedAnimBaseElement *e = (SVGTimedAnimBaseElement *)node; gf_smil_timing_init_runtime_info(node); - + gf_svg_flatten_attributes((SVG_Element *)e, &all_atts); GF_SAFEALLOC(e->xlinkp, XLinkAttributesPointers); xlinkp = e->xlinkp; xlinkp->href = all_atts.xlink_href; - xlinkp->type = all_atts.xlink_type; + xlinkp->type = all_atts.xlink_type; e->timingp->runtime->evaluate_status = SMIL_TIMING_EVAL_DISCARD; } @@ -1424,12 +1424,12 @@ void gf_smil_anim_init_node(GF_Node *node) SMILAnimationAttributesPointers *animp = NULL; SVGAllAttributes all_atts; SVGTimedAnimBaseElement *e = (SVGTimedAnimBaseElement *)node; - + gf_svg_flatten_attributes((SVG_Element *)e, &all_atts); e->xlinkp = gf_malloc(sizeof(XLinkAttributesPointers)); xlinkp = e->xlinkp; xlinkp->href = all_atts.xlink_href; - xlinkp->type = all_atts.xlink_type; + xlinkp->type = all_atts.xlink_type; /*perform init of default values When the xlink:href attribute of animation is not set, the target defaults to the parent element */ @@ -1441,12 +1441,12 @@ void gf_smil_anim_init_node(GF_Node *node) xlinkp->href->target = gf_node_get_parent(node, 0); } if (xlinkp->href->type == XMLRI_STRING) { - if (!xlinkp->href->string) { + if (!xlinkp->href->string) { GF_LOG(GF_LOG_ERROR, GF_LOG_SMIL,("Error: IRI not initialized\n")); return; } else { GF_Node *n; - + n = (GF_Node*)gf_sg_find_node_by_name(gf_node_get_graph(node), xlinkp->href->string); if (n) { xlinkp->href->type = XMLRI_ELEMENTID; @@ -1456,7 +1456,7 @@ void gf_smil_anim_init_node(GF_Node *node) return; } } - } + } if (!xlinkp->href->target) { GF_LOG(GF_LOG_WARNING, GF_LOG_SMIL,("Trying to initialize an animation when the target is not known\n")); return; @@ -1467,12 +1467,12 @@ void gf_smil_anim_init_node(GF_Node *node) goto end_init; } - /* if an attribute (to, from or by) is present but its type is not set + /* if an attribute (to, from or by) is present but its type is not set (e.g. it could not be determined before, the target was not known), we try to get the type from the target */ if ( (all_atts.to && (all_atts.to->type==0)) - || (all_atts.from && (all_atts.from->type==0)) - || (all_atts.by && (all_atts.by->type==0)) - ) { + || (all_atts.from && (all_atts.from->type==0)) + || (all_atts.by && (all_atts.by->type==0)) + ) { GF_FieldInfo info; if (gf_node_get_attribute_by_name((GF_Node *)xlinkp->href->target, all_atts.attributeName->name, 0, 1, 1, &info)==GF_OK) { u32 anim_value_type = info.fieldType; @@ -1480,9 +1480,15 @@ void gf_smil_anim_init_node(GF_Node *node) for (i=0; i<3; i++) { u32 tag = 0; switch (i) { - case 0: tag=TAG_SVG_ATT_to; break; - case 1: tag=TAG_SVG_ATT_from; break; - case 2: tag=TAG_SVG_ATT_by; break; + case 0: + tag=TAG_SVG_ATT_to; + break; + case 1: + tag=TAG_SVG_ATT_from; + break; + case 2: + tag=TAG_SVG_ATT_by; + break; } if (gf_node_get_attribute_by_tag((GF_Node *)node, tag, 0, 0, &info)==GF_OK) { SMIL_AnimateValue *attval = info.far_ptr; @@ -1525,7 +1531,7 @@ void gf_smil_anim_init_node(GF_Node *node) e->animp->path = NULL; e->animp->rotate = NULL; } - + end_init: gf_smil_timing_init_runtime_info(node); gf_smil_anim_init_runtime_info(node); diff --git a/src/scenegraph/smil_timing.c b/src/scenegraph/smil_timing.c index 18c20f8..8840807 100644 --- a/src/scenegraph/smil_timing.c +++ b/src/scenegraph/smil_timing.c @@ -14,7 +14,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -53,7 +53,7 @@ static void gf_smil_timing_compute_active_duration(SMIL_Timing_RTI *rti, SMIL_In /* TODO: check if the test on begin is right and needed */ if (!timingp/* || interval->begin == -1*/) return; - + switch (gf_node_get_tag((GF_Node *)rti->timed_elt)) { case TAG_SVG_discard: interval->active_duration = -1; @@ -82,14 +82,14 @@ static void gf_smil_timing_compute_active_duration(SMIL_Timing_RTI *rti, SMIL_In interval->repeat_duration = interval->simple_duration; } } else { - interval->repeat_duration = MIN(timingp->repeatDur->clock_value, - FIX2FLT(timingp->repeatCount->count) * interval->simple_duration); - } + interval->repeat_duration = MIN(timingp->repeatDur->clock_value, + FIX2FLT(timingp->repeatCount->count) * interval->simple_duration); + } } else { /* simple_duration is indefinite */ interval->simple_duration = -1; - + /* we can ignore repeatCount to compute active_duration */ if (!isRepeatDurDefined) { interval->repeat_duration = -1; @@ -99,38 +99,38 @@ static void gf_smil_timing_compute_active_duration(SMIL_Timing_RTI *rti, SMIL_In } interval->active_duration = interval->repeat_duration; - /* Step 2: if end is defined in the document, clamp active duration to end-begin + /* Step 2: if end is defined in the document, clamp active duration to end-begin otherwise return*/ if (interval->end < 0) { /* interval->active_duration stays as is */ } else { if (interval->active_duration >= 0) interval->active_duration = MIN(interval->active_duration, interval->end - interval->begin); - else + else interval->active_duration = interval->end - interval->begin; } - /* min and max check should be checked last, - to ensure that they have greater priority than the end attribute + /* min and max check should be checked last, + to ensure that they have greater priority than the end attribute see (animate-elem-223-t.svg) */ /* Step 3: clamp the active duration with min and max */ clamp_active_duration = 1; /* testing for presence of min and max because some elements may not have them: eg SVG audio */ isMinDefined = (timingp->min && timingp->min->type == SMIL_DURATION_DEFINED); isMaxDefined = (timingp->max && timingp->max->type == SMIL_DURATION_DEFINED); - if (isMinDefined && isMaxDefined && - timingp->max->clock_value < timingp->min->clock_value) { + if (isMinDefined && isMaxDefined && + timingp->max->clock_value < timingp->min->clock_value) { clamp_active_duration = 0; } if (clamp_active_duration) { if (isMinDefined) { - if ((interval->active_duration >= 0) && - (interval->active_duration <= timingp->min->clock_value)) { - /* see http://www.w3.org/TR/2005/REC-SMIL2-20051213/smil-timing.html#Timing-MinMax - - if repeat duration or simple duration is smaller than min, - then the (active ? / simple ?) duration shall be set to min + if ((interval->active_duration >= 0) && + (interval->active_duration <= timingp->min->clock_value)) { + /* see http://www.w3.org/TR/2005/REC-SMIL2-20051213/smil-timing.html#Timing-MinMax + - if repeat duration or simple duration is smaller than min, + then the (active ? / simple ?) duration shall be set to min (cf 6th row in animate-elem-65-t.svg) - - if the min > dur > end, the element is played normally for its simple duration + - if the min > dur > end, the element is played normally for its simple duration and then is frozen or not shown depending on the value of the fill attribute. (cf animate-elem-222-t.svg)*/ interval->active_duration = timingp->min->clock_value; @@ -139,7 +139,7 @@ static void gf_smil_timing_compute_active_duration(SMIL_Timing_RTI *rti, SMIL_In } if (isMaxDefined) { if ((interval->active_duration >= 0 && interval->active_duration >= timingp->max->clock_value) || - interval->active_duration == -1) { + interval->active_duration == -1) { interval->active_duration = timingp->max->clock_value; } } @@ -157,21 +157,21 @@ void gf_smil_set_media_duration(SMIL_Timing_RTI *rti, Double media_duration) } /* the end value of this interval needs to be initialized before computing the active duration - the begin value must be >= 0 + the begin value must be >= 0 The result can be: - a positive value meaning that a resolved and non-indefinite value was found - the value -1 meaning indefinite or unresolved TODO: we should make a difference between indefinite and unresolved because - if an interval is created with a value of indefinite, this value should not + if an interval is created with a value of indefinite, this value should not be replaced by a resolved event. (Not sure ?!!) - the value -2 meaning that a valid end value (including indefinite) could not be found -*/ +*/ static void gf_smil_timing_get_interval_end(SMIL_Timing_RTI *rti, SMIL_Interval *interval) { u32 end_count, j; - /* we set the value to indicate that this is an illegal end, - if it stays like that after searching through the values, + /* we set the value to indicate that this is an illegal end, + if it stays like that after searching through the values, then the whole interval must be discarded */ interval->end = -2; @@ -190,10 +190,10 @@ static void gf_smil_timing_get_interval_end(SMIL_Timing_RTI *rti, SMIL_Interval interval->end = -1; break; } - } + } } else { interval->end = -1; - } + } } static void gf_smil_timing_get_first_interval(SMIL_Timing_RTI *rti) @@ -209,7 +209,7 @@ static void gf_smil_timing_get_first_interval(SMIL_Timing_RTI *rti) break; } } - /*In SVG, if no 'begin' is specified, the default timing of the time container + /*In SVG, if no 'begin' is specified, the default timing of the time container is equivalent to an offset value of '0'.*/ if (rti->current_interval->begin == -1 && count == 0) { /* except for LASeR Conditional element*/ @@ -219,7 +219,7 @@ static void gf_smil_timing_get_first_interval(SMIL_Timing_RTI *rti) return; } } - + /* this is the first time we check the interval */ gf_smil_timing_get_interval_end(rti, rti->current_interval); if (0 && rti->current_interval->end == -2) { @@ -241,15 +241,15 @@ static Bool gf_smil_timing_get_next_interval(SMIL_Timing_RTI *rti, Bool current, memset(interval, 0, sizeof(SMIL_Interval)); interval->begin = -1; - + count = (rti->timingp->begin ? gf_list_count(*rti->timingp->begin) : 0); for (i = 0; i < count; i ++) { SMIL_Time *begin = (SMIL_Time*)gf_list_get(*rti->timingp->begin, i); if (GF_SMIL_TIME_IS_CLOCK(begin->type)) { if (rti->current_interval->begin != -1 && begin->clock <= rti->current_interval->begin) continue; // if (rti->current_interval->begin == -1 || begin->clock <= scene_time) { - interval->begin = begin->clock; - break; + interval->begin = begin->clock; + break; // } } } @@ -270,10 +270,10 @@ static Bool gf_smil_timing_get_next_interval(SMIL_Timing_RTI *rti, Bool current, } } -/* To reduce the process of notifying the time to all timed elements, we add to the scene graph - only the timed elements which have a resolved current interval, other timed elements will be +/* To reduce the process of notifying the time to all timed elements, we add to the scene graph + only the timed elements which have a resolved current interval, other timed elements will be added at runtime when an event leads to the creation of a new interval. - We also insert the new timed element in the order of the current_interval begin value, to stop + We also insert the new timed element in the order of the current_interval begin value, to stop the notification of time when not necessary */ static Bool gf_smil_timing_add_to_sg(GF_SceneGraph *sg, SMIL_Timing_RTI *rti) { @@ -291,8 +291,8 @@ static Bool gf_smil_timing_add_to_sg(GF_SceneGraph *sg, SMIL_Timing_RTI *rti) return 0; } -/* when a timed element restarts, since the list of timed elements in the scene graph, - to which scene time is notified at each rendering cycle, is sorted, we need to remove +/* when a timed element restarts, since the list of timed elements in the scene graph, + to which scene time is notified at each rendering cycle, is sorted, we need to remove and reinsert this timed element as if it was a new one, to make sure the sorting is correct */ static void gf_smil_mark_modified(SMIL_Timing_RTI *rti, Bool remove) { @@ -307,9 +307,9 @@ static void gf_smil_mark_modified(SMIL_Timing_RTI *rti, Bool remove) } } -/* Attributes from the timed elements are not easy to use during runtime, - the runtime info is a set of easy to use structures. - This function initializes them (intervals, status ...) +/* Attributes from the timed elements are not easy to use during runtime, + the runtime info is a set of easy to use structures. + This function initializes them (intervals, status ...) and registers the element with the scenegraph */ GF_EXPORT void gf_smil_timing_init_runtime_info(GF_Node *timed_elt) @@ -338,11 +338,11 @@ void gf_smil_timing_init_runtime_info(GF_Node *timed_elt) if (!timingp) return; if (tag == TAG_SVG_audio || tag == TAG_SVG_video) { - /* if the dur attribute is not set, then it should be set to media - as this is the default for media elements see + /* if the dur attribute is not set, then it should be set to media + as this is the default for media elements see http://www.w3.org/TR/2005/REC-SMIL2-20051213/smil-timing.html#Timing-DurValueSemantics - "For simple media elements that specify continuous media (i.e. media with an inherent notion of time), - the implicit duration is the intrinsic duration of the media itself - e.g. video and audio files + "For simple media elements that specify continuous media (i.e. media with an inherent notion of time), + the implicit duration is the intrinsic duration of the media itself - e.g. video and audio files have a defined duration." TODO: Check if this should work with the animation element */ if (!e->timingp->dur) { @@ -360,7 +360,7 @@ void gf_smil_timing_init_runtime_info(GF_Node *timed_elt) rti->timingp = timingp; rti->status = SMIL_STATUS_WAITING_TO_BEGIN; - rti->evaluate_status = SMIL_TIMING_EVAL_NONE; + rti->evaluate_status = SMIL_TIMING_EVAL_NONE; rti->evaluate = gf_smil_timing_null_timed_function; rti->scene_time = -1; rti->force_reevaluation = 0; @@ -418,12 +418,12 @@ void gf_smil_timing_delete_runtime_info(GF_Node *timed_elt, SMIL_Timing_RTI *rti /*remove all associated listeners*/ if (rti->timingp->begin) gf_smil_timing_reset_time_list(* rti->timingp->begin); if (rti->timingp->end) gf_smil_timing_reset_time_list(* rti->timingp->end); - + gf_free(rti); } GF_EXPORT -Bool gf_smil_timing_is_active(GF_Node *node) +Bool gf_smil_timing_is_active(GF_Node *node) { SMILTimingAttributesPointers *timingp = NULL; timingp = ((SVGTimedAnimBaseElement *)node)->timingp; @@ -434,7 +434,7 @@ Bool gf_smil_timing_is_active(GF_Node *node) /* This function notifies the scene time to all the timed elements from the list in the given scene graph. It returns the number of active timed elements. If no timed element is active, this means that from the timing point of view, the scene has not changed and no rendering refresh is needed, even if the time has changed. - It uses an additional list of modified timed elements to insure that no timing + It uses an additional list of modified timed elements to insure that no timing element was modified by the begin/end/repeat of another timed element. */ Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg) @@ -448,14 +448,14 @@ Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg) active_count = 0; /* - Note: whenever a timed element is active, we trigger a gf_node_dirty_parent_graph so that the parent graph + Note: whenever a timed element is active, we trigger a gf_node_dirty_parent_graph so that the parent graph is aware that some modifications may happen in the subtree. This is needed for cases where the subtree - is in an offscreen surface, to force retraversing of the subtree and thus apply the animation. + is in an offscreen surface, to force retraversing of the subtree and thus apply the animation. */ - - /* notify the new scene time to the register timed elements - this might modify other timed elements or the element itself + + /* notify the new scene time to the register timed elements + this might modify other timed elements or the element itself in which case it will be added to the list of modified elements */ i = 0; do_loop = 1; @@ -464,18 +464,18 @@ Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg) switch (ret) { case -1: /* special case for discard element - when a discard element is executed, it automatically removes itself from the list of timed element + when a discard element is executed, it automatically removes itself from the list of timed element in the scene graph, we need to fix the index i. */ i--; break; case -2: /* special return value, -2 means that the tested timed element is waiting to begin - Assuming that the timed elements are sorted by begin order, + Assuming that the timed elements are sorted by begin order, the next ones don't need to be checked */ do_loop = 0; break; case -3: - /* special case for animation elements which do not need to be notified anymore, + /* special case for animation elements which do not need to be notified anymore, but which require a tree traversal */ i--; active_count ++; @@ -491,7 +491,7 @@ Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg) } } - /* notify the timed elements which have been modified either since the previous frame (updates, scripts) or + /* notify the timed elements which have been modified either since the previous frame (updates, scripts) or because of the start/end/repeat of the previous notifications */ while (gf_list_count(sg->modified_smil_timed_elements)) { /* first remove the modified smil timed element */ @@ -529,7 +529,7 @@ Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg) return (active_count>0); } -/* evaluation function for the discard element +/* evaluation function for the discard element returns 1 if the discard was executed 0 otherwise */ @@ -542,7 +542,7 @@ static Bool gf_smil_discard(SMIL_Timing_RTI *rti, Fixed scene_time) GF_Node *target; if (!timingp) return 0; - + target = tb->xlinkp->href ? tb->xlinkp->href->target : NULL; begin = (timingp->begin ? (SMIL_Time *)gf_list_get(*timingp->begin, 0) : NULL); @@ -555,7 +555,7 @@ static Bool gf_smil_discard(SMIL_Timing_RTI *rti, Fixed scene_time) GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SVG Composer] discarding element %s at time %f\n", target ? gf_node_get_log_name(target) : "None", scene_time)); gf_smil_mark_modified(rti, 1); - + /*this takes care of cases where discard is a child of its target*/ gf_node_register(rti->timed_elt, NULL); nb_inst = gf_node_get_num_instances(rti->timed_elt); @@ -570,7 +570,7 @@ static Bool gf_smil_discard(SMIL_Timing_RTI *rti, Fixed scene_time) return 1; } -/* Animations are applied in their begin order first and then in document order. +/* Animations are applied in their begin order first and then in document order. Whenever an animation (re)starts, it is placed at the end of the queue (potentially after frozen animations) */ static void gf_smil_reorder_anim(SMIL_Timing_RTI *rti) { @@ -584,11 +584,11 @@ static void gf_smil_reorder_anim(SMIL_Timing_RTI *rti) /* Notifies the scene time to a timed element, potentially changing its status and triggering its evaluation Returns: - 0 if no rendering traversal is required, + 0 if no rendering traversal is required, 1 if a rendering traversal is required, -1 if the time node is a discard which has been deleted during this notification, -2 means that the timed element is waiting to begin, - -3 means that the timed element is active but does not need further notifications (set without dur) + -3 means that the timed element is active but does not need further notifications (set without dur) but still requires a rendering traversal */ s32 gf_smil_timing_notify_time(SMIL_Timing_RTI *rti, Double in_scene_time) { @@ -599,20 +599,20 @@ s32 gf_smil_timing_notify_time(SMIL_Timing_RTI *rti, Double in_scene_time) if (!timingp) return 0; - /* if the scene time is the same as it was during the previous notification, it means that the + /* if the scene time is the same as it was during the previous notification, it means that the animations are paused and we don't need to evaluate it again unless the force_reevaluation flag is set */ if ((rti->scene_time == in_scene_time) && (rti->force_reevaluation == 0)) return 0; if (!rti->paused) rti->scene_time = in_scene_time; rti->force_reevaluation = 0; /* for fraction events, in all cases we indicate that the scene needs redraw */ - if (rti->evaluate_status == SMIL_TIMING_EVAL_FRACTION) + if (rti->evaluate_status == SMIL_TIMING_EVAL_FRACTION) return 1; if (rti->evaluate_status == SMIL_TIMING_EVAL_DISCARD) { /* TODO: FIX ME discarding should send a begin event ? */ - /* Since the discard can only be evaluated once, it unregisters itself - from the list of timed elements to be notified, so for this special case + /* Since the discard can only be evaluated once, it unregisters itself + from the list of timed elements to be notified, so for this special case we return -1 when the discard has actually been executed */ if (gf_smil_discard(rti, FLT2FIX(rti->scene_time))) return -1; else return 0; @@ -622,8 +622,8 @@ s32 gf_smil_timing_notify_time(SMIL_Timing_RTI *rti, Double in_scene_time) waiting_to_begin: if (rti->status == SMIL_STATUS_WAITING_TO_BEGIN) { - if (rti->current_interval->begin != -1 && rti->scene_time >= rti->current_interval->begin) { - /* if there is a computed interval with a definite begin value + if (rti->current_interval->begin != -1 && rti->scene_time >= rti->current_interval->begin) { + /* if there is a computed interval with a definite begin value and if that value is lesser than the scene time, then the animation becomes active */ GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Activating\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); rti->status = SMIL_STATUS_ACTIVE; @@ -640,7 +640,7 @@ waiting_to_begin: memset(&evt, 0, sizeof(evt)); evt.type = GF_EVENT_BEGIN_EVENT; evt.smil_event_time = rti->current_interval->begin; - gf_dom_event_fire((GF_Node *)rti->timed_elt, &evt); + gf_dom_event_fire((GF_Node *)rti->timed_elt, &evt); } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Evaluating (Not starting)\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); ret = -2; @@ -651,8 +651,8 @@ waiting_to_begin: if (rti->status == SMIL_STATUS_ACTIVE) { u32 cur_id; - if (rti->current_interval->active_duration >= 0 - && rti->scene_time >= (rti->current_interval->begin + rti->current_interval->active_duration)) { + if (rti->current_interval->active_duration >= 0 + && rti->scene_time >= (rti->current_interval->begin + rti->current_interval->active_duration)) { force_end: GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Stopping \n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); @@ -685,28 +685,28 @@ force_end: if (!timingp->restart || *timingp->restart == SMIL_RESTART_ALWAYS) { GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Checking for restart (always)\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); - + if (rti->next_interval->begin != -1 && rti->next_interval->begin < rti->scene_time) { *rti->current_interval = *rti->next_interval; gf_smil_timing_get_next_interval(rti, 0, rti->next_interval, rti->scene_time); - /* mark that this element has been modified and + /* mark that this element has been modified and need to be reinserted at its proper place in the list of timed elements in the scenegraph */ gf_smil_mark_modified(rti, 0); - /* if this is animation, reinserting the animation in the list of animations - that targets this attribute, so that it is the last one */ + /* if this is animation, reinserting the animation in the list of animations + that targets this attribute, so that it is the last one */ gf_smil_reorder_anim(rti); memset(&evt, 0, sizeof(evt)); evt.type = GF_EVENT_BEGIN_EVENT; evt.smil_event_time = rti->current_interval->begin; - gf_dom_event_fire((GF_Node *)rti->timed_elt, &evt); - } + gf_dom_event_fire((GF_Node *)rti->timed_elt, &evt); + } } ret = rti->postpone; - + cur_id = rti->current_interval->nb_iterations; rti->normalized_simple_time = gf_smil_timing_get_normalized_simple_time(rti, rti->scene_time, &force_end); if (force_end) { @@ -721,7 +721,7 @@ force_end: evt.detail = rti->current_interval->nb_iterations; gf_dom_event_fire((GF_Node *)rti->timed_elt, &evt); - rti->evaluate_status = SMIL_TIMING_EVAL_REPEAT; + rti->evaluate_status = SMIL_TIMING_EVAL_REPEAT; } else { GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Preparing to update\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); rti->evaluate_status = SMIL_TIMING_EVAL_UPDATE; @@ -732,23 +732,23 @@ force_end: } /* special case for animations with unspecified simpleDur (not with media timed elements) - we need to indicate that this anim does not need to be notified anymore and that + we need to indicate that this anim does not need to be notified anymore and that it does not require tree traversal */ if (gf_svg_is_animation_tag(rti->timed_elt->sgprivate->tag) - && (rti->current_interval->simple_duration==-1) - && (rti->current_interval->active_duration==-1) - ) { + && (rti->current_interval->simple_duration==-1) + && (rti->current_interval->active_duration==-1) + ) { /*GF_SceneGraph * sg = rti->timed_elt->sgprivate->scenegraph; while (sg->parent_scene) sg = sg->parent_scene; gf_list_del_item(sg->smil_timed_elements, rti); ret = -3;*/ ret = 1; - } + } } } if ((rti->status == SMIL_STATUS_DONE) || (rti->status == SMIL_STATUS_FROZEN)) { - if (!timingp->restart || *timingp->restart != SMIL_RESTART_NEVER) { + if (!timingp->restart || *timingp->restart != SMIL_RESTART_NEVER) { /* Check changes in begin or end attributes */ GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Checking for restart when not active\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); if (rti->next_interval->begin != -1) { @@ -758,13 +758,13 @@ force_end: restart_timing = 1; /*switch intervals*/ - if (rti->next_interval->begin >= rti->current_interval->begin+rti->current_interval->active_duration) { + if (rti->next_interval->begin >= rti->current_interval->begin+rti->current_interval->active_duration) { *rti->current_interval = *rti->next_interval; - + gf_smil_timing_print_interval(rti, 1, rti->current_interval); gf_smil_timing_get_next_interval(rti, 0, rti->next_interval, rti->scene_time); - /* mark that this element has been modified and + /* mark that this element has been modified and need to be reinserted at its proper place in the list of timed elements in the scenegraph */ gf_smil_mark_modified(rti, 0); } else { @@ -788,8 +788,8 @@ force_end: /*??? what is this ???*/ //ret = 0; } - } else if ((rti->status == SMIL_STATUS_DONE) && - timingp->restart && (*timingp->restart == SMIL_RESTART_NEVER)) { + } else if ((rti->status == SMIL_STATUS_DONE) && + timingp->restart && (*timingp->restart == SMIL_RESTART_NEVER)) { /* the timed element is done and cannot restart, we don't need to evaluate it anymore */ GF_SceneGraph * sg = rti->timed_elt->sgprivate->scenegraph; while (sg->parent_scene) sg = sg->parent_scene; @@ -804,11 +804,11 @@ exit: } /* returns a fraction between 0 and 1 of the elapsed time in the simple duration */ -/* WARNING: According to SMIL (http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#animationNS-Fill, +/* WARNING: According to SMIL (http://www.w3.org/TR/2005/REC-SMIL2-20051213/animation.html#animationNS-Fill, see "Illustration of animation combining a partial repeat and fill="freeze"") When a element is frozen, its normalized simple time is not necessarily 1, an animation can be frozen in the middle of a repeatition */ -Fixed gf_smil_timing_get_normalized_simple_time(SMIL_Timing_RTI *rti, Double scene_time, Bool *force_end) +Fixed gf_smil_timing_get_normalized_simple_time(SMIL_Timing_RTI *rti, Double scene_time, Bool *force_end) { Double activeTime; Double simpleTime; @@ -827,7 +827,7 @@ Fixed gf_smil_timing_get_normalized_simple_time(SMIL_Timing_RTI *rti, Double sce /* if the simple duration is defined, then we can take iterations into account */ if (rti->current_interval->simple_duration>0) { - + if (activeTime == rti->current_interval->simple_duration*(rti->current_interval->nb_iterations+1)) { return FIX_ONE; } else { @@ -835,14 +835,14 @@ Fixed gf_smil_timing_get_normalized_simple_time(SMIL_Timing_RTI *rti, Double sce } } else { /* If the element does not define its simple duration, but it has an active duration, - and we are past this active duration, we assume it's blocked in final state + and we are past this active duration, we assume it's blocked in final state We should take into account fill behavior*/ rti->current_interval->nb_iterations = 0; if (rti->timingp->fill && *(rti->timingp->fill) == SMIL_FILL_FREEZE) { if (rti->current_interval->repeat_duration == rti->current_interval->simple_duration) { return FIX_ONE; } else { - return rti->normalized_simple_time; + return rti->normalized_simple_time; } } else { return 0; @@ -863,20 +863,20 @@ end: if (rti->current_interval->repeat_duration == rti->current_interval->simple_duration) { return FIX_ONE; } else { - return rti->normalized_simple_time; + return rti->normalized_simple_time; } } } /* we update the number of iterations */ rti->current_interval->nb_iterations = (u32)floor(activeTime / rti->current_interval->simple_duration); } else { - /* If the element does not define its simple duration, we assume it's blocked in final state + /* If the element does not define its simple duration, we assume it's blocked in final state Is this correct ? */ rti->current_interval->nb_iterations = 0; //GF_LOG(GF_LOG_DEBUG, GF_LOG_SMIL, ("[SMIL Timing ] Time %f - Timed element %s - Error Computing Normalized Simple Time while simple duration is indefinite\n", gf_node_get_scene_time((GF_Node *)rti->timed_elt), gf_node_get_log_name((GF_Node *)rti->timed_elt))); return FIX_ONE; } - + /* We compute the simple time by removing time taken by previous iterations */ simpleTime = activeTime - rti->current_interval->simple_duration * rti->current_interval->nb_iterations; @@ -895,9 +895,9 @@ void gf_smil_timing_modified(GF_Node *node, GF_FieldInfo *field) { SMILTimingAttributesPointers *timingp = NULL; SMIL_Timing_RTI *rti; - + timingp = ((SVGTimedAnimBaseElement *)node)->timingp; - + if (!timingp) return; rti = timingp->runtime; if (!rti) return; @@ -916,13 +916,13 @@ void gf_smil_timing_modified(GF_Node *node, GF_FieldInfo *field) rti->current_interval->end = -1; return; } - + gf_smil_timing_compute_active_duration(rti, rti->current_interval); gf_smil_timing_print_interval(rti, 1, rti->current_interval); } gf_smil_timing_get_next_interval(rti, 0, rti->next_interval, gf_node_get_scene_time((GF_Node*)rti->timed_elt)); - /* mark that this element has been modified and + /* mark that this element has been modified and need to be reinserted at its proper place in the list of timed elements in the scenegraph */ gf_smil_mark_modified(rti, 0); } @@ -930,8 +930,8 @@ void gf_smil_timing_modified(GF_Node *node, GF_FieldInfo *field) /* Tries to resolve event-based or sync-based time values Used in parsing, to determine if a timed element can be initialized */ -Bool gf_svg_resolve_smil_times(GF_Node *anim, void *event_base_element, - GF_List *smil_times, Bool is_end, const char *node_name) +Bool gf_svg_resolve_smil_times(GF_Node *anim, void *event_base_element, + GF_List *smil_times, Bool is_end, const char *node_name) { u32 i, done, count; @@ -951,7 +951,7 @@ Bool gf_svg_resolve_smil_times(GF_Node *anim, void *event_base_element, } /*commented out because it breaks regular anims (cf interact-pevents-07-t.svg)*/ // if (node_name && strcmp(node_name, t->element_id)) continue; - + t->element = gf_sg_find_node_by_name(anim->sgprivate->scenegraph, t->element_id); if (t->element) { gf_free(t->element_id); @@ -973,7 +973,7 @@ Bool gf_svg_resolve_smil_times(GF_Node *anim, void *event_base_element, return 1; } -/* Inserts a new resolved time instant in the begin or end attribute. +/* Inserts a new resolved time instant in the begin or end attribute. The insertion preserves the sorting and removes the previous insertions which have become obsolete WARNING: Only used for inserting time when an element, whose target is a timed element, is activated. */ @@ -1003,9 +1003,9 @@ void gf_smil_timing_insert_clock(GF_Node *elt, Bool is_end, Double clock) count--; continue; } - if ( (first->type == GF_SMIL_TIME_INDEFINITE) - || ( (first->type == GF_SMIL_TIME_CLOCK) && (first->clock > begin->clock) ) - ) { + if ( (first->type == GF_SMIL_TIME_INDEFINITE) + || ( (first->type == GF_SMIL_TIME_CLOCK) && (first->clock > begin->clock) ) + ) { gf_list_insert(l, begin, i); found = 1; break; @@ -1033,8 +1033,8 @@ void gf_smil_timing_resume(GF_Node *node) } } -void gf_smil_set_evaluation_callback(GF_Node *node, - void (*smil_evaluate)(struct _smil_timing_rti *rti, Fixed normalized_simple_time, u32 state)) +void gf_smil_set_evaluation_callback(GF_Node *node, + void (*smil_evaluate)(struct _smil_timing_rti *rti, Fixed normalized_simple_time, u32 state)) { if (node && ((SVGTimedAnimBaseElement *)node)->timingp && ((SVGTimedAnimBaseElement *)node)->timingp->runtime) { SMIL_Timing_RTI *rti = ((SVGTimedAnimBaseElement *)node)->timingp->runtime; diff --git a/src/scenegraph/svg_attributes.c b/src/scenegraph/svg_attributes.c index 5c6a9ea..7fc914c 100644 --- a/src/scenegraph/svg_attributes.c +++ b/src/scenegraph/svg_attributes.c @@ -34,7 +34,11 @@ #define DUMP_COORDINATES 1 -static const struct dom_event_def {GF_EventType event; const char *name; GF_DOMEventCategory category; } defined_dom_events [] = +static const struct dom_event_def { + GF_EventType event; + const char *name; + GF_DOMEventCategory category; +} defined_dom_events [] = { { GF_EVENT_ABORT, "abort", GF_DOM_EVENT_DOM }, { GF_EVENT_ERROR, "error", GF_DOM_EVENT_DOM }, @@ -131,7 +135,7 @@ static const struct dom_event_def {GF_EventType event; const char *name; GF_DOM { GF_EVENT_ABORT, "abort", GF_DOM_EVENT_MEDIA }, { GF_EVENT_ERROR, "error", GF_DOM_EVENT_MEDIA }, { GF_EVENT_MEDIA_EMPTIED, "emptied", GF_DOM_EVENT_MEDIA }, - { GF_EVENT_MEDIA_STALLED, "stalled", GF_DOM_EVENT_MEDIA }, + { GF_EVENT_MEDIA_STALLED, "stalled", GF_DOM_EVENT_MEDIA }, { GF_EVENT_MEDIA_LOADED_METADATA, "loadedmetadata", GF_DOM_EVENT_MEDIA }, { GF_EVENT_MEDIA_LODADED_DATA, "loadeddata", GF_DOM_EVENT_MEDIA }, { GF_EVENT_MEDIA_CANPLAY, "canplay", GF_DOM_EVENT_MEDIA }, @@ -172,7 +176,7 @@ GF_EventType gf_dom_event_type_by_name(const char *name) count = sizeof(defined_dom_events) / sizeof(struct dom_event_def); if (!name) return GF_EVENT_UNKNOWN; if ((name[0]=='o') && (name[1]=='n')) name += 2; - for (i=0;i': return GF_KEY_GREATERTHAN; - case '?': return GF_KEY_QUESTION; - case '[': return GF_KEY_LEFTSQUAREBRACKET; - case '\\': return GF_KEY_BACKSLASH; - case ']': return GF_KEY_RIGHTSQUAREBRACKET; - case '^': return GF_KEY_CIRCUM; - case '_': return GF_KEY_UNDERSCORE; - case '`': return GF_KEY_GRAVEACCENT; - case '{': return GF_KEY_LEFTCURLYBRACKET; - case '|': return GF_KEY_PIPE; - case '}': return GF_KEY_RIGHTCURLYBRACKET; - case 0xA1: return GF_KEY_INVERTEXCLAMATION; - default: return GF_KEY_UNIDENTIFIED; + case '@': + return GF_KEY_AT; + case '*': + return GF_KEY_STAR; + case '#': + return GF_KEY_NUMBER; + case ' ': + return GF_KEY_SPACE; + case '!': + return GF_KEY_EXCLAMATION; + case '"': + return GF_KEY_QUOTATION; + case '$': + return GF_KEY_DOLLAR; + case '&': + return GF_KEY_AMPERSAND; + case '\'': + return GF_KEY_APOSTROPHE; + case '(': + return GF_KEY_LEFTPARENTHESIS; + case ')': + return GF_KEY_RIGHTPARENTHESIS; + case '+': + return GF_KEY_PLUS; + case ',': + return GF_KEY_COMMA; + case '-': + return GF_KEY_HYPHEN; + case '.': + return GF_KEY_FULLSTOP; + case '/': + return GF_KEY_SLASH; + case ':': + return GF_KEY_COLON; + case ';': + return GF_KEY_SEMICOLON; + case '<': + return GF_KEY_LESSTHAN; + case '=': + return GF_KEY_EQUALS; + case '>': + return GF_KEY_GREATERTHAN; + case '?': + return GF_KEY_QUESTION; + case '[': + return GF_KEY_LEFTSQUAREBRACKET; + case '\\': + return GF_KEY_BACKSLASH; + case ']': + return GF_KEY_RIGHTSQUAREBRACKET; + case '^': + return GF_KEY_CIRCUM; + case '_': + return GF_KEY_UNDERSCORE; + case '`': + return GF_KEY_GRAVEACCENT; + case '{': + return GF_KEY_LEFTCURLYBRACKET; + case '|': + return GF_KEY_PIPE; + case '}': + return GF_KEY_RIGHTCURLYBRACKET; + case 0xA1: + return GF_KEY_INVERTEXCLAMATION; + default: + return GF_KEY_UNIDENTIFIED; } } else { u32 i, count; @@ -480,7 +520,12 @@ GF_KeyCode gf_dom_get_key_type(char *key_name) } /* Basic SVG datatype parsing functions */ -static const struct predef_col { const char *name; u8 r; u8 g; u8 b; } predefined_colors[] = +static const struct predef_col { + const char *name; + u8 r; + u8 g; + u8 b; +} predefined_colors[] = { {"aliceblue",240, 248, 255}, {"antiquewhite",250, 235, 215}, @@ -634,7 +679,10 @@ static const struct predef_col { const char *name; u8 r; u8 g; u8 b; } predefine /* Basic SVG datatype parsing functions */ -static const struct sys_col { const char *name; u8 type; } system_colors[] = +static const struct sys_col { + const char *name; + u8 type; +} system_colors[] = { {"ActiveBorder", SVG_COLOR_ACTIVE_BORDER}, {"ActiveCaption", SVG_COLOR_ACTIVE_CAPTION}, @@ -747,7 +795,8 @@ static void svg_parse_color(SVG_Color *col, char *attribute_content) if (strstr(str, "%")) is_percentage = 1; str = strstr(str, "("); str++; - sscanf(str, "%f", &_val); col->red = FLT2FIX(_val); + sscanf(str, "%f", &_val); + col->red = FLT2FIX(_val); str = strstr(str, ","); if (!str) { /* space separated colors/percentages are not allowed neither in SVG 1.1 nor in SVG T1.2 */ @@ -755,7 +804,8 @@ static void svg_parse_color(SVG_Color *col, char *attribute_content) return; } str++; - sscanf(str, "%f", &_val); col->green = FLT2FIX(_val); + sscanf(str, "%f", &_val); + col->green = FLT2FIX(_val); str = strstr(str, ","); if (!str) { /* space separated colors/percentages are not allowed neither in SVG 1.1 nor in SVG T1.2 */ @@ -763,7 +813,8 @@ static void svg_parse_color(SVG_Color *col, char *attribute_content) return; } str++; - sscanf(str, "%f", &_val); col->blue = FLT2FIX(_val); + sscanf(str, "%f", &_val); + col->blue = FLT2FIX(_val); if (is_percentage) { col->red /= 100; col->green /= 100; @@ -775,7 +826,7 @@ static void svg_parse_color(SVG_Color *col, char *attribute_content) } col->type = SVG_COLOR_RGBCOLOR; } else if ((str[0] >= 'a' && str[0] <= 'z') - || (str[0] >= 'A' && str[0] <= 'Z')) { + || (str[0] >= 'A' && str[0] <= 'Z')) { svg_parse_named_color(col, str); } else { Float _r, _g, _b; @@ -798,64 +849,64 @@ static void svg_parse_color(SVG_Color *col, char *attribute_content) */ static u32 svg_parse_number(char *d, Fixed *f, Bool is_angle) { - u32 nb_digit_before = 0; + u32 nb_digit_before = 0; u32 nb_digit_after = 0; - Bool has_fractional = 0; + Bool has_fractional = 0; Bool is_negative = 0; Float _val = 0; u32 i = 0; - /* warning the comma and semicolumn should not be there when parsing a number in a path */ + /* warning the comma and semicolumn should not be there when parsing a number in a path */ while ((d[i] != 0) && strchr(" ,;\r\n\t", d[i])) i++; - if (!d[i]) { - GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Parsing] Parsing number with empty string or only spaces: %s\n", d)); - return 0; - } - if (d[i] == '+') { - i++; - } else if (d[i] == '-') { + if (!d[i]) { + GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Parsing] Parsing number with empty string or only spaces: %s\n", d)); + return 0; + } + if (d[i] == '+') { + i++; + } else if (d[i] == '-') { is_negative = 1; i++; } - /* Warning: this is not normal, should be detected somehow by checking the BNF */ + /* Warning: this is not normal, should be detected somehow by checking the BNF */ /* if ((d[i]=='N') && (d[i+1]=='a') && (d[i+2]=='N')) { i+= 3; _val = 0; goto end; }*/ - /* read the digit-sequence token of the BNF */ + /* read the digit-sequence token of the BNF */ while (d[i] >= '0' && d[i] <= '9' && d[i] != 0) { _val = _val*10 + (d[i]-'0'); - nb_digit_before++; + nb_digit_before++; i++; } if (d[i] == '.') { - has_fractional = 1; + has_fractional = 1; i++; while (d[i] >= '0' && d[i] <= '9' && d[i] != 0) { _val = _val*10 + (d[i]-'0'); nb_digit_after++; i++; } - if (nb_digit_after) { - _val /= (Float)pow(10,nb_digit_after); - } else if (nb_digit_before == 0) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing number (expecting digits before or after a '.': %s\n", d)); - return 0; - } else { - /* dangling '.' without digits after. This is allowed by the BNF */ - } - } - if ((nb_digit_before == 0) && (has_fractional == 0)) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing number (expecting digits):%s\n", d)); - return 0; - } - /* reading the exponent */ + if (nb_digit_after) { + _val /= (Float)pow(10,nb_digit_after); + } else if (nb_digit_before == 0) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing number (expecting digits before or after a '.': %s\n", d)); + return 0; + } else { + /* dangling '.' without digits after. This is allowed by the BNF */ + } + } + if ((nb_digit_before == 0) && (has_fractional == 0)) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing number (expecting digits):%s\n", d)); + return 0; + } + /* reading the exponent */ if (d[i] == 'e' || d[i] == 'E') { Bool neg_exp = 0; u32 nb_exp_digits = 0; - s32 exp = 0; + s32 exp = 0; i++; if (d[i] == '+') i++; else if (d[i] == '-') { @@ -864,17 +915,17 @@ static u32 svg_parse_number(char *d, Fixed *f, Bool is_angle) } while (d[i] >= '0' && d[i] <= '9' && d[i] != 0) { exp = exp*10 + (d[i]-'0'); - nb_exp_digits++; + nb_exp_digits++; i++; } - if (nb_exp_digits) { - _val *= (Float)pow(10, neg_exp ? -exp : exp); - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing exponent, 'e' or 'E' should be followed by digits: %s\n", d)); - return 0; - } - } - /* We can now produce the final number */ + if (nb_exp_digits) { + _val *= (Float)pow(10, neg_exp ? -exp : exp); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing exponent, 'e' or 'E' should be followed by digits: %s\n", d)); + return 0; + } + } + /* We can now produce the final number */ if (is_negative) _val *= -1; if (is_angle) { _val/=180; @@ -883,7 +934,7 @@ static u32 svg_parse_number(char *d, Fixed *f, Bool is_angle) (*f) = FLT2FIX(_val); } - /* warning the comma and semicolumn should not be there when parsing a path number */ + /* warning the comma and semicolumn should not be there when parsing a path number */ while (d[i] != 0 && (d[i] == ' ' || d[i] == ',' || d[i] == ';')) i++; return i; } @@ -901,7 +952,10 @@ static GF_Err svg_parse_clock_value(char *d, Double *clock_value) if (!d[0]) return GF_BAD_PARAM; if (d[0] == '+') d++; - else if (d[0] == '-') { sign = -1; d++; } + else if (d[0] == '-') { + sign = -1; + d++; + } if (!d[0]) return GF_BAD_PARAM; @@ -970,7 +1024,7 @@ static GF_Err smil_parse_time(GF_Node *elt, SMIL_Time *v, char *d) char *tmp; /* Offset Values */ - if ((d[0] >= '0' && d[0] <= '9') || d[0] == '+' || d[0] == '-'){ + if ((d[0] >= '0' && d[0] <= '9') || d[0] == '+' || d[0] == '-') { v->type = GF_SMIL_TIME_CLOCK; return svg_parse_clock_value(d, &(v->clock)); } @@ -1073,7 +1127,10 @@ static GF_Err smil_parse_time(GF_Node *elt, SMIL_Time *v, char *d) char *tmp3 = tmp2; tmp2[0] = 0; tmp3--; - while (*tmp3==' ') { *tmp3=0; tmp3--; } + while (*tmp3==' ') { + *tmp3=0; + tmp3--; + } if (v->event.type == 0) v->event.type = gf_dom_event_type_by_name(tmp); if (!had_param && (v->event.type == GF_EVENT_REPEAT || v->event.type == GF_EVENT_REPEAT_EVENT)) v->event.parameter = 1; @@ -1097,7 +1154,7 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) GF_Matrix2D tmp; char *str; - u32 read_chars; + u32 read_chars; u32 i; gf_mx2d_init(*mat); @@ -1115,21 +1172,21 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) Fixed sx, sy; i++; read_chars = svg_parse_number(&(str[i]), &sx, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading sx component in scale: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading sx component in scale: %s\n", attribute_content)); + return 0; + } + i += read_chars; if (str[i] == ')') { sy = sx; } else { read_chars = svg_parse_number(&(str[i]), &sy, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading sy component in scale: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading sy component in scale: %s\n", attribute_content)); + return 0; + } + i += read_chars; } gf_mx2d_init(tmp); gf_mx2d_add_scale(&tmp, sx, sy); @@ -1139,12 +1196,12 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else if (strstr(str+i, "translate")==str+i) { i += 9; @@ -1153,20 +1210,20 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) Fixed tx, ty; i++; read_chars = svg_parse_number(&(str[i]), &tx, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading tx component in translate: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading tx component in translate: %s\n", attribute_content)); + return 0; + } + i += read_chars; if (str[i] == ')') { ty = 0; } else { read_chars = svg_parse_number(&(str[i]), &ty, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading ty component in translate: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading ty component in translate: %s\n", attribute_content)); + return 0; + } + i += read_chars; } gf_mx2d_init(tmp); gf_mx2d_add_translation(&tmp, tx, ty); @@ -1175,12 +1232,12 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else if (strstr(str+i, "rotate")==str+i) { i += 6; @@ -1189,26 +1246,26 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) Fixed angle, cx, cy; i++; read_chars = svg_parse_number(&(str[i]), &angle, 1); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle component in rotate: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle component in rotate: %s\n", attribute_content)); + return 0; + } + i += read_chars; if (str[i] == ')') { cx = cy = 0; } else { read_chars = svg_parse_number(&(str[i]), &cx, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading cx component in rotate: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading cx component in rotate: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &cy, 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading cy component in rotate: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading cy component in rotate: %s\n", attribute_content)); + return 0; + } + i += read_chars; } gf_mx2d_init(tmp); gf_mx2d_add_rotation(&tmp, cx, cy, angle); @@ -1217,12 +1274,12 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else if (strstr(str+i, "skewX")==str+i) { i += 5; @@ -1231,11 +1288,11 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) Fixed angle; i++; read_chars = svg_parse_number(&(str[i]), &angle, 1); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle in skewX: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle in skewX: %s\n", attribute_content)); + return 0; + } + i += read_chars; gf_mx2d_init(tmp); gf_mx2d_add_skew_x(&tmp, angle); gf_mx2d_add_matrix(&tmp, mat); @@ -1243,12 +1300,12 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else if (strstr(str+i, "skewY")==str+i) { i += 5; @@ -1257,11 +1314,11 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) Fixed angle; i++; read_chars = svg_parse_number(&(str[i]), &angle, 1); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle component in skewY: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading angle component in skewY: %s\n", attribute_content)); + return 0; + } + i += read_chars; gf_mx2d_init(tmp); gf_mx2d_add_skew_y(&tmp, angle); gf_mx2d_add_matrix(&tmp, mat); @@ -1269,12 +1326,12 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else if (strstr(str+i, "matrix")==str+i) { i+=6; @@ -1282,61 +1339,61 @@ Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content) if (str[i] == '(') { i++; read_chars = svg_parse_number(&(str[i]), &(tmp.m[0]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient a in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient a in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(tmp.m[3]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient b in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient b in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(tmp.m[1]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient c in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient c in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(tmp.m[4]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient d in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient d in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(tmp.m[2]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient e in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient e in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(tmp.m[5]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient f in matrix: %s\n", attribute_content)); - return 0; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient f in matrix: %s\n", attribute_content)); + return 0; + } + i += read_chars; gf_mx2d_add_matrix(&tmp, mat); gf_mx2d_copy(*mat, tmp); while(str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in transform attribute: %s\n", attribute_content)); - return 0; + return 0; } } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Unrecognized transofrm type in attribute %s\n", attribute_content)); - return 0; + return 0; } /*for svgView parsing*/ if (str[i] == ')') i++; } - return 1; + return 1; } /* Parses an SVG transform attribute and collapses all in the given matrix */ @@ -1344,7 +1401,7 @@ static GF_Err svg_parse_transform(SVG_Transform *t, char *attribute_content) { char *str; u32 i; - u32 read_chars; + u32 read_chars; str = attribute_content; i = 0; @@ -1359,43 +1416,43 @@ static GF_Err svg_parse_transform(SVG_Transform *t, char *attribute_content) if (str[i] == 's' && str[i+1] == 'v' && str[i+2] == 'g') { i+=3; while (str[i] == ' ') i++; - if (str[i] == ',') { - i++; - } else if (str[i] == ')') { + if (str[i] == ',') { + i++; + } else if (str[i] == ')') { i++; return GF_OK; } read_chars = svg_parse_number(&(str[i]), &(t->mat.m[2]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient tx in ref transform: %s\n", attribute_content)); - return GF_BAD_PARAM; - } - i += read_chars; + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient tx in ref transform: %s\n", attribute_content)); + return GF_BAD_PARAM; + } + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(t->mat.m[5]), 0); - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient ty in ref transform: %s\n", attribute_content)); - return GF_BAD_PARAM; - } - i += read_chars; - } else { + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error reading coefficient ty in ref transform: %s\n", attribute_content)); + return GF_BAD_PARAM; + } + i += read_chars; + } else { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Unsupported syntax for ref transform attribute")); - } + } while (str[i] == ' ') i++; if (str[i] == ')') i++; else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing closing parenthesis in transform attribute: %s\n", attribute_content)); } return GF_OK; } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in ref transform attribute: %s\n", attribute_content)); + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Missing opening parenthesis in ref transform attribute: %s\n", attribute_content)); return GF_BAD_PARAM; } } else { Bool res = gf_svg_parse_transformlist(&t->mat, attribute_content); - if (!res) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error parsing transform list: %s\n", attribute_content)); - return GF_BAD_PARAM; - } + if (!res) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error parsing transform list: %s\n", attribute_content)); + return GF_BAD_PARAM; + } } return GF_OK; } @@ -1410,10 +1467,10 @@ static void svg_parse_path(SVG_PathData *path, char *attribute_content) { char *d = attribute_content; - /* used to detect end of BNF production: - "The processing of the BNF must consume as much of a given BNF production as possible, - stopping at the point when a character is encountered which no longer satisfies the production." */ - u32 read_chars = 0; + /* used to detect end of BNF production: + "The processing of the BNF must consume as much of a given BNF production as possible, + stopping at the point when a character is encountered which no longer satisfies the production." */ + u32 read_chars = 0; /* Point used to start a new subpath when the previous subpath is closed */ SVG_Point prev_m_pt; @@ -1442,11 +1499,11 @@ next_command: case 'M': i++; read_chars = svg_parse_number(&(d[i]), &(orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'm') { orig.x += rel_ref_pt.x; orig.y += rel_ref_pt.y; @@ -1467,11 +1524,11 @@ next_command: case 'l': i++; read_chars = svg_parse_number(&(d[i]), &(orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'l') { orig.x += rel_ref_pt.x; orig.y += rel_ref_pt.y; @@ -1489,8 +1546,8 @@ next_command: case 'h': i++; read_chars = svg_parse_number(&(d[i]), &(orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'h') { orig.x += rel_ref_pt.x; } @@ -1508,8 +1565,8 @@ next_command: case 'v': i++; read_chars = svg_parse_number(&(d[i]), &(orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'v') { orig.y += rel_ref_pt.y; } @@ -1527,31 +1584,31 @@ next_command: case 'c': i++; read_chars = svg_parse_number(&(d[i]), &(ct_orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(ct_orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'c') { ct_orig.x += rel_ref_pt.x; ct_orig.y += rel_ref_pt.y; } read_chars = svg_parse_number(&(d[i]), &(ct_end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(ct_end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'c') { ct_end.x += rel_ref_pt.x; ct_end.y += rel_ref_pt.y; } read_chars = svg_parse_number(&(d[i]), &(end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'c') { end.x += rel_ref_pt.x; end.y += rel_ref_pt.y; @@ -1570,21 +1627,21 @@ next_command: ct_orig.x = 2*orig.x - ct_orig.x; ct_orig.y = 2*orig.y - ct_orig.y; read_chars = svg_parse_number(&(d[i]), &(ct_end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(ct_end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 's') { ct_end.x += rel_ref_pt.x; ct_end.y += rel_ref_pt.y; } read_chars = svg_parse_number(&(d[i]), &(end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 's') { end.x += rel_ref_pt.x; end.y += rel_ref_pt.y; @@ -1601,21 +1658,21 @@ next_command: case 'q': i++; read_chars = svg_parse_number(&(d[i]), &(ct_orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(ct_orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'q') { ct_orig.x += rel_ref_pt.x; ct_orig.y += rel_ref_pt.y; } read_chars = svg_parse_number(&(d[i]), &(end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'q') { end.x += rel_ref_pt.x; end.y += rel_ref_pt.y; @@ -1633,11 +1690,11 @@ next_command: ct_orig.x = 2*orig.x - ct_orig.x; ct_orig.y = 2*orig.y - ct_orig.y; read_chars = svg_parse_number(&(d[i]), &(end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 't') { end.x += rel_ref_pt.x; end.y += rel_ref_pt.y; @@ -1654,28 +1711,28 @@ next_command: i++; read_chars = svg_parse_number(&(d[i]), &(orig.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(orig.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(x_axis_rotation), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(large_arc_flag), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(sweep_flag), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(d[i]), &(end.y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; if (c == 'a') { end.x += rel_ref_pt.x; end.y += rel_ref_pt.y; @@ -1916,39 +1973,39 @@ next_command: break; case 'A': case 'a': - { - Fixed tmp; - i++; + { + Fixed tmp; + i++; #ifndef REMOVE_ALLOC - GF_SAFEALLOC(command, u8) - gf_list_add(d_commands, command); - *command = SVG_PATHCOMMAND_A; + GF_SAFEALLOC(command, u8) + gf_list_add(d_commands, command); + *command = SVG_PATHCOMMAND_A; - GF_SAFEALLOC(pt, SVG_Point) - gf_list_add(d_points, pt); + GF_SAFEALLOC(pt, SVG_Point) + gf_list_add(d_points, pt); #endif - i += svg_parse_number(&(d[i]), &(pt->x), 0); - i += svg_parse_number(&(d[i]), &(pt->y), 0); + i += svg_parse_number(&(d[i]), &(pt->x), 0); + i += svg_parse_number(&(d[i]), &(pt->y), 0); - i += svg_parse_number(&(d[i]), &(tmp), 0); - i += svg_parse_number(&(d[i]), &(tmp), 0); - i += svg_parse_number(&(d[i]), &(tmp), 0); + i += svg_parse_number(&(d[i]), &(tmp), 0); + i += svg_parse_number(&(d[i]), &(tmp), 0); + i += svg_parse_number(&(d[i]), &(tmp), 0); #ifndef REMOVE_ALLOC - GF_SAFEALLOC(pt, SVG_Point) - gf_list_add(d_points, pt); + GF_SAFEALLOC(pt, SVG_Point) + gf_list_add(d_points, pt); #endif - i += svg_parse_number(&(d[i]), &(pt->x), 0); - i += svg_parse_number(&(d[i]), &(pt->y), 0); - if (c == 'a') { - pt->x += cur_pt.x; - pt->y += cur_pt.y; - } - cur_pt.x = pt->x; - cur_pt.y = pt->y; + i += svg_parse_number(&(d[i]), &(pt->x), 0); + i += svg_parse_number(&(d[i]), &(pt->y), 0); + if (c == 'a') { + pt->x += cur_pt.x; + pt->y += cur_pt.y; } - prev_c = c; - break; + cur_pt.x = pt->x; + cur_pt.y = pt->y; + } + prev_c = c; + break; case 'Z': case 'z': i++; @@ -2034,12 +2091,12 @@ static void svg_parse_paint(GF_Node *n, SVG_Paint *paint, char *attribute_conten /* Parses a length which is a number with a unit */ static u32 svg_parse_length(SVG_Number *number, char *value_string, Bool clamp0to1) { - char c = '\0'; - char *unit = NULL; - u32 len = 0; - u32 unit_pos = 0; - u32 unit_len = 0; - u32 read_chars; + char c = '\0'; + char *unit = NULL; + u32 len = 0; + u32 unit_pos = 0; + u32 unit_len = 0; + u32 read_chars; if (!strcmp(value_string, "inherit")) { number->type = SVG_NUMBER_INHERIT; @@ -2052,7 +2109,7 @@ static u32 svg_parse_length(SVG_Number *number, char *value_string, Bool clamp0t return 12; } else if ((unit = strstr(value_string, "%")) ) { number->type = SVG_NUMBER_PERCENTAGE; - unit_len = 1; + unit_len = 1; } else if ((unit = strstr(value_string, "em"))) { number->type = SVG_NUMBER_EMS; } else if ((unit = strstr(value_string, "ex"))) { @@ -2072,23 +2129,23 @@ static u32 svg_parse_length(SVG_Number *number, char *value_string, Bool clamp0t } else { number->type = SVG_NUMBER_VALUE; } - if (unit) { - if (!unit_len) unit_len = 2; - unit_pos = (u32) (unit - value_string); - /* setting the first unit character to 0 for the svg_parse_number method to finish */ - c = value_string[unit_pos]; - value_string[unit_pos] = 0; - } + if (unit) { + if (!unit_len) unit_len = 2; + unit_pos = (u32) (unit - value_string); + /* setting the first unit character to 0 for the svg_parse_number method to finish */ + c = value_string[unit_pos]; + value_string[unit_pos] = 0; + } read_chars = svg_parse_number(value_string, &(number->value), 0); - if (unit) { - value_string[unit_pos] = c; - } - if (!read_chars) { - GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing: %s\n", value_string)); - len = 0; - } else { - len = unit_len + read_chars; - } + if (unit) { + value_string[unit_pos] = c; + } + if (!read_chars) { + GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Error in parsing: %s\n", value_string)); + len = 0; + } else { + len = unit_len + read_chars; + } if (clamp0to1) number->value = MAX(0, MIN(1, number->value)); return len; @@ -2448,7 +2505,7 @@ static void smil_parse_time_list(GF_Node *e, GF_List *values, char *begin_or_end value_string[len] = 0; GF_SAFEALLOC(value, SMIL_Time) - gf_list_add(values, value); + gf_list_add(values, value); if (smil_parse_time(e, value, value_string) != GF_OK) goto err; @@ -2651,7 +2708,7 @@ static void smil_parse_syncToleranceOrDefault(SMIL_SyncTolerance *value, char *v static void svg_parse_viewbox(SVG_ViewBox *value, char *value_string) { - u32 read_chars; + u32 read_chars; char *str = value_string; if (!strcmp(str, "none")) { value->is_set = 0; @@ -2659,17 +2716,17 @@ static void svg_parse_viewbox(SVG_ViewBox *value, char *value_string) u32 i = 0; value->is_set = 1; read_chars = svg_parse_number(&(str[i]), &(value->x), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(value->y), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(value->width), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; read_chars = svg_parse_number(&(str[i]), &(value->height), 0); - if (!read_chars) return; - i += read_chars; + if (!read_chars) return; + i += read_chars; } } @@ -2704,7 +2761,7 @@ u32 svg_parse_point(SVG_Point *p, char *value_string) { u32 i = 0, j = 0; i = svg_parse_number(&(value_string[i]), &(p->x), 0); - /* TODO: handle cases where a point has an invalid syntax */ + /* TODO: handle cases where a point has an invalid syntax */ j = svg_parse_number(&(value_string[i]), &(p->y), 0); /* we need to detect an odd number of coordinates in polygon points list cf. http://www.w3.org/TR/SVGMobile12/shapes.html#PolygonElement @@ -2718,9 +2775,9 @@ static u32 svg_parse_point_into_matrix(GF_Matrix2D *p, char *value_string) u32 i = 0, j = 0; gf_mx2d_init(*p); i = svg_parse_number(&(value_string[i]), &(p->m[2]), 0); - if (i == 0) return 0; + if (i == 0) return 0; j = svg_parse_number(&(value_string[i]), &(p->m[5]), 0); - if (j == 0) return 0; + if (j == 0) return 0; return i+j; } @@ -2753,7 +2810,7 @@ static void svg_parse_points(GF_List *values, char *value_string) /* Parses a list of numbers */ static void svg_parse_numbers(GF_List *values, char *value_string, Bool is_angle) { - u32 read_chars; + u32 read_chars; u32 i = 0; char *str = value_string; u32 len = (u32) strlen(str); @@ -2765,7 +2822,7 @@ static void svg_parse_numbers(GF_List *values, char *value_string, Bool is_angle gf_free(f); return; } - i += read_chars; + i += read_chars; gf_list_add(values, f); } } @@ -2818,7 +2875,7 @@ static void svg_parse_strings(GF_List *values, char *value_string, u32 string_ty static void svg_parse_strokedasharray(SVG_StrokeDashArray *value, char *value_string) { - u32 read_chars; + u32 read_chars; if (!strcmp(value_string, "none")) { value->type = SVG_STROKEDASHARRAY_NONE; } else if (!strcmp(value_string, "inherit")) { @@ -2833,11 +2890,11 @@ static void svg_parse_strokedasharray(SVG_StrokeDashArray *value, char *value_st SVG_Length *f; GF_SAFEALLOC(f, SVG_Length) read_chars = svg_parse_length(f, &(str[i]), 0); - if (!read_chars) { - gf_free(f); - return; - } - i += read_chars; + if (!read_chars) { + gf_free(f); + return; + } + i += read_chars; gf_list_add(values, f); } vals->count = gf_list_count(values); @@ -2846,7 +2903,7 @@ static void svg_parse_strokedasharray(SVG_StrokeDashArray *value, char *value_st for (i = 0; i < vals->count; i++) { SVG_Length *f = (SVG_Length *)gf_list_get(values, i); vals->vals[i] = f->value; - vals->units[i] = f->type; + vals->units[i] = f->type; gf_free(f); } gf_list_del(values); @@ -3077,7 +3134,7 @@ GF_Err gf_svg_parse_element_id(GF_Node *n, const char *nodename, Bool warning_if GF_EXPORT GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_content, u8 anim_value_type) { - /* for all attributes, except strings, apply some sort of white space normalization*/ + /* for all attributes, except strings, apply some sort of white space normalization*/ if (info->fieldType != DOM_String_datatype && strlen(attribute_content)) { u32 i, len; /*remove spaces at the begining*/ @@ -3102,15 +3159,15 @@ GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_co switch (info->fieldType) { case SVG_Boolean_datatype: svg_parse_boolean((SVG_Boolean *)info->far_ptr, attribute_content); - break; + break; case SVG_Color_datatype: svg_parse_color((SVG_Color *)info->far_ptr, attribute_content); - break; + break; case SVG_Paint_datatype: svg_parse_paint(n, (SVG_Paint *)info->far_ptr, attribute_content); break; -/* beginning of keyword type parsing */ + /* beginning of keyword type parsing */ case SVG_FillRule_datatype: svg_parse_clipfillrule((SVG_FillRule *)info->far_ptr, attribute_content); break; @@ -3233,14 +3290,14 @@ GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_co else *(u8*)info->far_ptr = SVG_FILTER_TRANSFER_IDENTITY; break; -/* end of keyword type parsing */ + /* end of keyword type parsing */ /* keyword | numbers (with possibly units) */ case SVG_Length_datatype: case SVG_Coordinate_datatype: case SVG_FontSize_datatype: case SVG_Rotate_datatype: - case SVG_Number_datatype: + case SVG_Number_datatype: svg_parse_length((SVG_Number*)info->far_ptr, attribute_content, 0); break; @@ -3300,49 +3357,49 @@ GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_co svg_parse_transform((SVG_Transform*)info->far_ptr, attribute_content); break; case SVG_Transform_Translate_datatype: - { - u32 i = 0; - SVG_Point *p = (SVG_Point *)info->far_ptr;; - i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); - if (attribute_content[i] == 0) { - p->y = 0; - } else { - i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); - } + { + u32 i = 0; + SVG_Point *p = (SVG_Point *)info->far_ptr;; + i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); + if (attribute_content[i] == 0) { + p->y = 0; + } else { + i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); } - break; + } + break; case SVG_Transform_Scale_datatype: - { - u32 i = 0; - SVG_Point *p = (SVG_Point *)info->far_ptr;; - i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); - if (attribute_content[i] == 0) { - p->y = p->x; - } else { - i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); - } + { + u32 i = 0; + SVG_Point *p = (SVG_Point *)info->far_ptr;; + i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); + if (attribute_content[i] == 0) { + p->y = p->x; + } else { + i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); } - break; + } + break; case SVG_Transform_SkewX_datatype: case SVG_Transform_SkewY_datatype: - { - Fixed *p = (Fixed *)info->far_ptr; - svg_parse_number(attribute_content, p, 1); - } - break; + { + Fixed *p = (Fixed *)info->far_ptr; + svg_parse_number(attribute_content, p, 1); + } + break; case SVG_Transform_Rotate_datatype: - { - u32 i = 0; - SVG_Point_Angle *p = (SVG_Point_Angle *)info->far_ptr;; - i+=svg_parse_number(&(attribute_content[i]), &(p->angle), 1); - if (attribute_content[i] == 0) { - p->y = p->x = 0; - } else { - i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); - i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); - } + { + u32 i = 0; + SVG_Point_Angle *p = (SVG_Point_Angle *)info->far_ptr;; + i+=svg_parse_number(&(attribute_content[i]), &(p->angle), 1); + if (attribute_content[i] == 0) { + p->y = p->x = 0; + } else { + i+=svg_parse_number(&(attribute_content[i]), &(p->x), 0); + i+=svg_parse_number(&(attribute_content[i]), &(p->y), 0); } - break; + } + break; case SVG_PreserveAspectRatio_datatype: svg_parse_preserveaspectratio((SVG_PreserveAspectRatio*)info->far_ptr, attribute_content); break; @@ -3389,7 +3446,7 @@ GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_co xml_ev->type = gf_dom_event_type_by_name(attribute_content); } } - break; + break; case SVG_Focus_datatype: svg_parse_focus(n, (SVG_Focus*)info->far_ptr, attribute_content); @@ -3466,26 +3523,26 @@ void *gf_svg_create_attribute_value(u32 attribute_type) { switch (attribute_type) { case SVG_Boolean_datatype: - { - SVG_Boolean *b; - GF_SAFEALLOC(b, SVG_Boolean) - return b; - } - break; + { + SVG_Boolean *b; + GF_SAFEALLOC(b, SVG_Boolean) + return b; + } + break; case SVG_Color_datatype: - { - SVG_Color *color; - GF_SAFEALLOC(color, SVG_Color) - return color; - } - break; + { + SVG_Color *color; + GF_SAFEALLOC(color, SVG_Color) + return color; + } + break; case SVG_Paint_datatype: - { - SVG_Paint *paint; - GF_SAFEALLOC(paint, SVG_Paint) - return paint; - } - break; + { + SVG_Paint *paint; + GF_SAFEALLOC(paint, SVG_Paint) + return paint; + } + break; /* keyword types */ case SVG_FillRule_datatype: @@ -3526,19 +3583,19 @@ void *gf_svg_create_attribute_value(u32 attribute_type) case SVG_SpreadMethod_datatype: case SVG_Focusable_datatype: case SVG_Filter_TransferType_datatype: - { - u8 *keyword; - GF_SAFEALLOC(keyword, u8) - return keyword; - } - break; + { + u8 *keyword; + GF_SAFEALLOC(keyword, u8) + return keyword; + } + break; case SMIL_SyncTolerance_datatype: - { - SMIL_SyncTolerance *st; - GF_SAFEALLOC(st, SMIL_SyncTolerance) - return st; - } - break; + { + SMIL_SyncTolerance *st; + GF_SAFEALLOC(st, SMIL_SyncTolerance) + return st; + } + break; /* inheritable floats */ case SVG_FontSize_datatype: @@ -3546,97 +3603,97 @@ void *gf_svg_create_attribute_value(u32 attribute_type) case SVG_Coordinate_datatype: case SVG_Rotate_datatype: case SVG_Number_datatype: - { - SVG_Number *number; - GF_SAFEALLOC(number, SVG_Number) - return number; - } - break; + { + SVG_Number *number; + GF_SAFEALLOC(number, SVG_Number) + return number; + } + break; case SVG_StrokeDashArray_datatype: - { - SVG_StrokeDashArray *array; - GF_SAFEALLOC(array, SVG_StrokeDashArray) - return array; - } - break; + { + SVG_StrokeDashArray *array; + GF_SAFEALLOC(array, SVG_StrokeDashArray) + return array; + } + break; case SVG_Motion_datatype: - { - GF_Matrix2D *p; - GF_SAFEALLOC(p, GF_Matrix2D) - gf_mx2d_init(*p); - return p; - } - break; + { + GF_Matrix2D *p; + GF_SAFEALLOC(p, GF_Matrix2D) + gf_mx2d_init(*p); + return p; + } + break; case SVG_Transform_datatype: - { - SVG_Transform *p; - GF_SAFEALLOC(p, SVG_Transform) - gf_mx2d_init(p->mat); - return p; - } - break; + { + SVG_Transform *p; + GF_SAFEALLOC(p, SVG_Transform) + gf_mx2d_init(p->mat); + return p; + } + break; case SVG_Transform_Translate_datatype: case SVG_Transform_Scale_datatype: - { - SVG_Point *p; - GF_SAFEALLOC(p, SVG_Point) - return p; - } - break; + { + SVG_Point *p; + GF_SAFEALLOC(p, SVG_Point) + return p; + } + break; case SVG_Transform_SkewX_datatype: case SVG_Transform_SkewY_datatype: - { - Fixed *p; - GF_SAFEALLOC(p, Fixed) - return p; - } - break; + { + Fixed *p; + GF_SAFEALLOC(p, Fixed) + return p; + } + break; case SVG_Transform_Rotate_datatype: - { - SVG_Point_Angle *p; - GF_SAFEALLOC(p, SVG_Point_Angle) - return p; - } - break; + { + SVG_Point_Angle *p; + GF_SAFEALLOC(p, SVG_Point_Angle) + return p; + } + break; case SVG_ViewBox_datatype: - { - SVG_ViewBox *viewbox; - GF_SAFEALLOC(viewbox, SVG_ViewBox) - return viewbox; - } - break; + { + SVG_ViewBox *viewbox; + GF_SAFEALLOC(viewbox, SVG_ViewBox) + return viewbox; + } + break; case XMLRI_datatype: case XML_IDREF_datatype: - { - XMLRI *iri; - GF_SAFEALLOC(iri, XMLRI) - return iri; - } - break; + { + XMLRI *iri; + GF_SAFEALLOC(iri, XMLRI) + return iri; + } + break; case SVG_FontFamily_datatype: - { - SVG_FontFamily *fontfamily; - GF_SAFEALLOC(fontfamily, SVG_FontFamily) - return fontfamily; - } - break; + { + SVG_FontFamily *fontfamily; + GF_SAFEALLOC(fontfamily, SVG_FontFamily) + return fontfamily; + } + break; case DOM_String_datatype: case SVG_ContentType_datatype: case SVG_LanguageID_datatype: case SVG_ID_datatype: - { - SVG_String *string; - GF_SAFEALLOC(string, SVG_String) - return string; - } - break; + { + SVG_String *string; + GF_SAFEALLOC(string, SVG_String) + return string; + } + break; case DOM_StringList_datatype: case XMLRI_List_datatype: case SVG_Points_datatype: @@ -3646,109 +3703,109 @@ void *gf_svg_create_attribute_value(u32 attribute_type) case SMIL_KeyTimes_datatype: case SMIL_KeyPoints_datatype: case SVG_Numbers_datatype: - { - ListOfXXX *list; - GF_SAFEALLOC(list, ListOfXXX) - *list = gf_list_new(); - return list; - } - break; + { + ListOfXXX *list; + GF_SAFEALLOC(list, ListOfXXX) + *list = gf_list_new(); + return list; + } + break; case SVG_PreserveAspectRatio_datatype: - { - SVG_PreserveAspectRatio *par; - GF_SAFEALLOC(par, SVG_PreserveAspectRatio) - return par; - } - break; + { + SVG_PreserveAspectRatio *par; + GF_SAFEALLOC(par, SVG_PreserveAspectRatio) + return par; + } + break; case SVG_PathData_datatype: - { - SVG_PathData *path; - GF_SAFEALLOC(path, SVG_PathData); + { + SVG_PathData *path; + GF_SAFEALLOC(path, SVG_PathData); #if USE_GF_PATH - gf_path_reset(path); - path->fineness = FIX_ONE; + gf_path_reset(path); + path->fineness = FIX_ONE; #else - path->commands = gf_list_new(); - path->points = gf_list_new(); + path->commands = gf_list_new(); + path->points = gf_list_new(); #endif - return path; - } - break; + return path; + } + break; case LASeR_Choice_datatype: - { - LASeR_Choice *ch; - GF_SAFEALLOC(ch, LASeR_Choice) - return ch; - } + { + LASeR_Choice *ch; + GF_SAFEALLOC(ch, LASeR_Choice) + return ch; + } case SVG_Focus_datatype: - { - SVG_Focus *foc; - GF_SAFEALLOC(foc, SVG_Focus) - return foc; - } + { + SVG_Focus *foc; + GF_SAFEALLOC(foc, SVG_Focus) + return foc; + } case SMIL_AttributeName_datatype: - { - SMIL_AttributeName *an; - GF_SAFEALLOC(an, SMIL_AttributeName) - return an; - } + { + SMIL_AttributeName *an; + GF_SAFEALLOC(an, SMIL_AttributeName) + return an; + } case SMIL_RepeatCount_datatype: - { - SMIL_RepeatCount *rc; - GF_SAFEALLOC(rc, SMIL_RepeatCount) - return rc; - } + { + SMIL_RepeatCount *rc; + GF_SAFEALLOC(rc, SMIL_RepeatCount) + return rc; + } case SMIL_Duration_datatype: - { - SMIL_Duration *sd; - GF_SAFEALLOC(sd, SMIL_Duration) - return sd; - } + { + SMIL_Duration *sd; + GF_SAFEALLOC(sd, SMIL_Duration) + return sd; + } case SMIL_AnimateValue_datatype: - { - SMIL_AnimateValue *av; - GF_SAFEALLOC(av, SMIL_AnimateValue) - return av; - } - break; + { + SMIL_AnimateValue *av; + GF_SAFEALLOC(av, SMIL_AnimateValue) + return av; + } + break; case SMIL_AnimateValues_datatype: - { - SMIL_AnimateValues *av; - GF_SAFEALLOC(av, SMIL_AnimateValues) - av->values = gf_list_new(); - return av; - } - break; + { + SMIL_AnimateValues *av; + GF_SAFEALLOC(av, SMIL_AnimateValues) + av->values = gf_list_new(); + return av; + } + break; case SVG_Clock_datatype: - { - SVG_Clock *ck; - GF_SAFEALLOC(ck, SVG_Clock) - return ck; - } - break; + { + SVG_Clock *ck; + GF_SAFEALLOC(ck, SVG_Clock) + return ck; + } + break; case XMLEV_Event_datatype: - { - XMLEV_Event *e; - GF_SAFEALLOC(e, XMLEV_Event); - return e; - } - break; + { + XMLEV_Event *e; + GF_SAFEALLOC(e, XMLEV_Event); + return e; + } + break; case LASeR_Size_datatype: - { - LASeR_Size *s; - GF_SAFEALLOC(s, LASeR_Size); - return s; - } - break; + { + LASeR_Size *s; + GF_SAFEALLOC(s, LASeR_Size); + return s; + } + break; case 0: - { - SVG_String *string; - GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Attributes] Unspecified attribute type - defaulting to string.\n")); - GF_SAFEALLOC(string, SVG_String); - return string; - } + { + SVG_String *string; + GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Attributes] Unspecified attribute type - defaulting to string.\n")); + GF_SAFEALLOC(string, SVG_String); + return string; + } default: @@ -3779,9 +3836,9 @@ static char *svg_dump_color(SVG_Color *col) b = FIX2INT(255*col->blue); for (i=0; icolor); } } - break; + break; -/* beginning of keyword type parsing */ + /* beginning of keyword type parsing */ case SVG_FillRule_datatype: if (intVal == SVG_FILLRULE_INHERIT) return gf_strdup("inherit"); else if (intVal == SVG_FILLRULE_NONZERO) return gf_strdup("nonzero"); @@ -4370,7 +4427,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) case LASeR_Size_datatype: sprintf(tmp, "%g %g", FIX2FLT(((LASeR_Size *)info->far_ptr)->width), FIX2FLT(((LASeR_Size *)info->far_ptr)->height)); return gf_strdup(tmp); -/* end of keyword type parsing */ + /* end of keyword type parsing */ /* inheritable floats */ case SVG_FontSize_datatype: @@ -4407,7 +4464,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) } return attVal; } - break; + break; case SVG_PathData_datatype: #if DUMP_COORDINATES @@ -4433,7 +4490,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) return attVal; #endif } - break; + break; case SMIL_KeyTimes_datatype: case SMIL_KeyPoints_datatype: case SMIL_KeySplines_datatype: @@ -4453,7 +4510,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) } return attVal; } - break; + break; case SVG_Coordinates_datatype: { #if DUMP_COORDINATES @@ -4474,7 +4531,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) return attVal; #endif } - break; + break; case SVG_ViewBox_datatype: { SVG_ViewBox *v = (SVG_ViewBox *)info->far_ptr; @@ -4484,7 +4541,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) } else return gf_strdup("none"); } - break; + break; case SVG_StrokeDashArray_datatype: { SVG_StrokeDashArray *p = (SVG_StrokeDashArray *)info->far_ptr; @@ -4496,9 +4553,9 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) attVal[0] = 0; for (i=0; iarray.count; i++) { char *szT; - SVG_Length l; - l.type = p->array.units[i]; - l.value = p->array.vals[i]; + SVG_Length l; + l.type = p->array.units[i]; + l.value = p->array.vals[i]; szT = svg_dump_number(&l); attVal = gf_realloc(attVal, sizeof(char)*(strlen(szT)+strlen(attVal)+ (i ? 2 : 1) )); if (i) strcat(attVal, " "); @@ -4507,7 +4564,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) return attVal; } } - break; + break; case SVG_FontFamily_datatype: { SVG_FontFamily *f = (SVG_FontFamily *)info->far_ptr; @@ -4557,7 +4614,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) return gf_strdup(tmp); } } - break; + break; case SVG_Focusable_datatype: { SVG_Focusable *f = (SVG_Focusable *)info->far_ptr; @@ -4602,78 +4659,78 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) return attVal; #endif } - break; + break; case SVG_Motion_datatype: - { + { #if DUMP_COORDINATES - GF_Matrix2D *m = (GF_Matrix2D *)info->far_ptr; - sprintf(tmp, "%g %g", FIX2FLT(m->m[2]), FIX2FLT(m->m[5])); - return gf_strdup(tmp); + GF_Matrix2D *m = (GF_Matrix2D *)info->far_ptr; + sprintf(tmp, "%g %g", FIX2FLT(m->m[2]), FIX2FLT(m->m[5])); + return gf_strdup(tmp); #endif - } - break; + } + break; case SVG_Transform_datatype: - { - SVG_Transform *t= (SVG_Transform *)info->far_ptr; - if (t->is_ref) { - sprintf(tmp, "ref(svg,%g,%g)", FIX2FLT(t->mat.m[2]), FIX2FLT(t->mat.m[5]) ); - return gf_strdup(tmp); - } else { - return gf_svg_dump_matrix(&t->mat); - } + { + SVG_Transform *t= (SVG_Transform *)info->far_ptr; + if (t->is_ref) { + sprintf(tmp, "ref(svg,%g,%g)", FIX2FLT(t->mat.m[2]), FIX2FLT(t->mat.m[5]) ); + return gf_strdup(tmp); + } else { + return gf_svg_dump_matrix(&t->mat); } - break; + } + break; case SVG_Transform_Translate_datatype: - { - SVG_Point *pt = (SVG_Point *)info->far_ptr; + { + SVG_Point *pt = (SVG_Point *)info->far_ptr; #if DUMP_COORDINATES - sprintf(tmp, "%g %g", FIX2FLT(pt->x), FIX2FLT(pt->y) ); - return gf_strdup(tmp); + sprintf(tmp, "%g %g", FIX2FLT(pt->x), FIX2FLT(pt->y) ); + return gf_strdup(tmp); #endif - } - break; + } + break; case SVG_Transform_Scale_datatype: - { - SVG_Point *pt = (SVG_Point *)info->far_ptr; + { + SVG_Point *pt = (SVG_Point *)info->far_ptr; #if DUMP_COORDINATES - if (pt->x == pt->y) { - sprintf(tmp, "%g", FIX2FLT(pt->x)); - } else { - sprintf(tmp, "%g %g", FIX2FLT(pt->x), FIX2FLT(pt->y) ); - } - return gf_strdup(tmp); -#endif + if (pt->x == pt->y) { + sprintf(tmp, "%g", FIX2FLT(pt->x)); + } else { + sprintf(tmp, "%g %g", FIX2FLT(pt->x), FIX2FLT(pt->y) ); } - break; + return gf_strdup(tmp); +#endif + } + break; case SVG_Transform_SkewX_datatype: case SVG_Transform_SkewY_datatype: - { - Fixed *f = (Fixed *)info->far_ptr; + { + Fixed *f = (Fixed *)info->far_ptr; #if DUMP_COORDINATES - sprintf(tmp, "%g", FIX2FLT( 180 * gf_divfix(*f, GF_PI) )); - return gf_strdup(tmp); + sprintf(tmp, "%g", FIX2FLT( 180 * gf_divfix(*f, GF_PI) )); + return gf_strdup(tmp); #endif - } - break; + } + break; case SVG_Transform_Rotate_datatype: - { - SVG_Point_Angle *pt = (SVG_Point_Angle *)info->far_ptr; + { + SVG_Point_Angle *pt = (SVG_Point_Angle *)info->far_ptr; #if DUMP_COORDINATES - if (pt->x || pt->y) { - sprintf(tmp, "%g %g %g", FIX2FLT( 180 * gf_divfix(pt->angle, GF_PI) ), FIX2FLT(pt->x), FIX2FLT(pt->y) ); - } else { - sprintf(tmp, "%g", FIX2FLT(gf_divfix(180 * pt->angle, GF_PI) )); - } - return gf_strdup(tmp); -#endif + if (pt->x || pt->y) { + sprintf(tmp, "%g %g %g", FIX2FLT( 180 * gf_divfix(pt->angle, GF_PI) ), FIX2FLT(pt->x), FIX2FLT(pt->y) ); + } else { + sprintf(tmp, "%g", FIX2FLT(gf_divfix(180 * pt->angle, GF_PI) )); } - break; + return gf_strdup(tmp); +#endif + } + break; case SMIL_AttributeName_datatype: { @@ -4684,7 +4741,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) if (att_name->tag) return gf_strdup( gf_svg_get_attribute_name(elt, att_name->tag) ); } - break; + break; case SMIL_Times_datatype: { @@ -4742,7 +4799,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) } return attVal; } - break; + break; case SMIL_Duration_datatype: { SMIL_Duration *dur = (SMIL_Duration *)info->far_ptr; @@ -4755,7 +4812,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Dumping] smil duration not assigned\n")); } } - break; + break; case SMIL_RepeatCount_datatype: { SMIL_RepeatCount *rep = (SMIL_RepeatCount *)info->far_ptr; @@ -4768,7 +4825,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Dumping] smil repeat count not assigned\n")); } } - break; + break; case SVG_TransformType_datatype: { SVG_TransformType tr = *(SVG_TransformType *)info->far_ptr; @@ -4779,7 +4836,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) else if (tr == SVG_TRANSFORM_SKEWX) return gf_strdup("skewX"); else if (tr == SVG_TRANSFORM_SKEWY) return gf_strdup("skewY"); } - break; + break; case SMIL_AnimateValue_datatype: { @@ -4791,7 +4848,7 @@ char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info) a_fi.far_ptr = av->value; return gf_svg_dump_attribute(elt, &a_fi); } - break; + break; case SMIL_AnimateValues_datatype: { GF_FieldInfo a_fi; @@ -4853,7 +4910,7 @@ char *gf_svg_dump_attribute_indexed(GF_Node *elt, GF_FieldInfo *info) return gf_strdup(tmp); #endif } - break; + break; case SMIL_KeyPoints_datatype: case SMIL_KeyTimes_datatype: case SMIL_KeySplines_datatype: @@ -4862,7 +4919,7 @@ char *gf_svg_dump_attribute_indexed(GF_Node *elt, GF_FieldInfo *info) sprintf(tmp, "%g", FIX2FLT(*p)); return gf_strdup(tmp); } - break; + break; case SVG_Coordinates_datatype: #if DUMP_COORDINATES return svg_dump_number((SVG_Length *) (SVG_Coordinate *)info->far_ptr); @@ -4874,15 +4931,15 @@ char *gf_svg_dump_attribute_indexed(GF_Node *elt, GF_FieldInfo *info) sprintf(tmp, "%g", FIX2FLT(*v)); return gf_strdup(tmp); } - break; + break; case SVG_StrokeDashArray_datatype: { - /*TODO: fix this: should be an SVG_Length*/ + /*TODO: fix this: should be an SVG_Length*/ Fixed *p = (Fixed *)info->far_ptr; sprintf(tmp, "%g", FIX2FLT(*p)); return gf_strdup(tmp); } - break; + break; case SMIL_Times_datatype: { SMIL_Time *t = (SMIL_Time *)info->far_ptr; @@ -5061,7 +5118,7 @@ Bool gf_svg_attributes_equal(GF_FieldInfo *f1, GF_FieldInfo *f2) else if (p1->type==SVG_PAINT_URI) return svg_iris_equal(&p1->iri, &p2->iri); return 1; } - break; + break; case SVG_FontSize_datatype: case SVG_Length_datatype: @@ -5191,42 +5248,42 @@ Bool gf_svg_attributes_equal(GF_FieldInfo *f1, GF_FieldInfo *f2) return svg_matrices_equal((GF_Matrix2D*)f1->far_ptr, (GF_Matrix2D*)f2->far_ptr); case SVG_Transform_datatype: - { - SVG_Transform *t1 = (SVG_Transform *)f1->far_ptr; - SVG_Transform *t2 = (SVG_Transform *)f2->far_ptr; - if (t1->is_ref == t2->is_ref) - return svg_matrices_equal(&t1->mat, &t2->mat); - else - return 0; - } + { + SVG_Transform *t1 = (SVG_Transform *)f1->far_ptr; + SVG_Transform *t2 = (SVG_Transform *)f2->far_ptr; + if (t1->is_ref == t2->is_ref) + return svg_matrices_equal(&t1->mat, &t2->mat); + else + return 0; + } case SVG_Transform_Translate_datatype: case SVG_Transform_Scale_datatype: - { - SVG_Point *p1 = (SVG_Point *)f1->far_ptr; - SVG_Point *p2 = (SVG_Point *)f2->far_ptr; - if (p1->x != p2->x) return 0; - if (p1->y != p2->y) return 0; - return 1; - } + { + SVG_Point *p1 = (SVG_Point *)f1->far_ptr; + SVG_Point *p2 = (SVG_Point *)f2->far_ptr; + if (p1->x != p2->x) return 0; + if (p1->y != p2->y) return 0; + return 1; + } case SVG_Transform_SkewX_datatype: case SVG_Transform_SkewY_datatype: - { - Fixed *p1 = (Fixed *)f1->far_ptr; - Fixed *p2 = (Fixed *)f2->far_ptr; - return (*p1 == *p2); - } + { + Fixed *p1 = (Fixed *)f1->far_ptr; + Fixed *p2 = (Fixed *)f2->far_ptr; + return (*p1 == *p2); + } case SVG_Transform_Rotate_datatype: - { - SVG_Point_Angle *p1 = (SVG_Point_Angle *)f1->far_ptr; - SVG_Point_Angle *p2 = (SVG_Point_Angle *)f2->far_ptr; - if (p1->x != p2->x) return 0; - if (p1->y != p2->y) return 0; - if (p1->angle != p2->angle) return 0; - return 1; - } + { + SVG_Point_Angle *p1 = (SVG_Point_Angle *)f1->far_ptr; + SVG_Point_Angle *p2 = (SVG_Point_Angle *)f2->far_ptr; + if (p1->x != p2->x) return 0; + if (p1->y != p2->y) return 0; + if (p1->angle != p2->angle) return 0; + return 1; + } case SVG_ID_datatype: @@ -5249,7 +5306,7 @@ Bool gf_svg_attributes_equal(GF_FieldInfo *f1, GF_FieldInfo *f2) if (foc1->type != SVG_FOCUS_IRI) return 1; return (foc1->target.string && foc2->target.string && !strcmp(foc1->target.string, foc2->target.string)) ? 1 : 0; } - break; + break; case DOM_StringList_datatype: { @@ -5331,7 +5388,7 @@ Bool gf_svg_attributes_equal(GF_FieldInfo *f1, GF_FieldInfo *f2) if (av1->value != av2->value) return 0; return 1; } - break; + break; case SMIL_AnimateValues_datatype: { @@ -5640,7 +5697,7 @@ static GF_Err svg_dasharray_muladd(Fixed alpha, SVG_StrokeDashArray *a, Fixed be c->array.vals = (Fixed *) gf_malloc(sizeof(Fixed)*c->array.count); for (i = 0; i < c->array.count; i++) { /* TODO: convert units if needed */ - c->array.units[i] = a->array.units[i]; + c->array.units[i] = a->array.units[i]; c->array.vals[i] = gf_mulfix(alpha, a->array.vals[i]) + gf_mulfix(beta, b->array.vals[i]); } return GF_OK; @@ -5698,21 +5755,21 @@ static GF_Err laser_size_muladd(Fixed alpha, LASeR_Size *sza, Fixed beta, LASeR_ /* c = alpha * a + beta * b */ GF_Err gf_svg_attributes_muladd(Fixed alpha, GF_FieldInfo *a, - Fixed beta, GF_FieldInfo *b, - GF_FieldInfo *c, - Bool clamp) + Fixed beta, GF_FieldInfo *b, + GF_FieldInfo *c, + Bool clamp) { if (!a->far_ptr || !b->far_ptr || !c->far_ptr) return GF_BAD_PARAM; if (a->fieldType != b->fieldType) { if (a->fieldType != SVG_Transform_datatype && - a->fieldType != SVG_Transform_Scale_datatype && - a->fieldType != SVG_Transform_Translate_datatype && - a->fieldType != SVG_Transform_Rotate_datatype && - a->fieldType != SVG_Transform_SkewX_datatype && - a->fieldType != SVG_Transform_SkewY_datatype && - a->fieldType != SVG_Motion_datatype) - return GF_BAD_PARAM; + a->fieldType != SVG_Transform_Scale_datatype && + a->fieldType != SVG_Transform_Translate_datatype && + a->fieldType != SVG_Transform_Rotate_datatype && + a->fieldType != SVG_Transform_SkewX_datatype && + a->fieldType != SVG_Transform_SkewY_datatype && + a->fieldType != SVG_Motion_datatype) + return GF_BAD_PARAM; } /* by default a and c are of the same type, except for matrix related types */ @@ -5725,17 +5782,17 @@ GF_Err gf_svg_attributes_muladd(Fixed alpha, GF_FieldInfo *a, return svg_color_muladd(alpha, (SVG_Color*)a->far_ptr, beta, (SVG_Color*)b->far_ptr, (SVG_Color*)c->far_ptr, clamp); case SVG_Paint_datatype: - { - SVG_Paint *pa = (SVG_Paint *)a->far_ptr; - SVG_Paint *pb = (SVG_Paint *)b->far_ptr; - SVG_Paint *pc = (SVG_Paint *)c->far_ptr; - if (pa->type != pb->type || pa->type != SVG_PAINT_COLOR || pb->type != SVG_PAINT_COLOR) { - GF_LOG(GF_LOG_ERROR, GF_LOG_INTERACT, ("[SVG Attributes] only color paints are additive\n")); - return GF_BAD_PARAM; - } - pc->type = SVG_PAINT_COLOR; - return svg_color_muladd(alpha, &pa->color, beta, &pb->color, &pc->color, clamp); + { + SVG_Paint *pa = (SVG_Paint *)a->far_ptr; + SVG_Paint *pb = (SVG_Paint *)b->far_ptr; + SVG_Paint *pc = (SVG_Paint *)c->far_ptr; + if (pa->type != pb->type || pa->type != SVG_PAINT_COLOR || pb->type != SVG_PAINT_COLOR) { + GF_LOG(GF_LOG_ERROR, GF_LOG_INTERACT, ("[SVG Attributes] only color paints are additive\n")); + return GF_BAD_PARAM; } + pc->type = SVG_PAINT_COLOR; + return svg_color_muladd(alpha, &pa->color, beta, &pb->color, &pc->color, clamp); + } case SVG_Number_datatype: case SVG_Length_datatype: @@ -5777,12 +5834,12 @@ GF_Err gf_svg_attributes_muladd(Fixed alpha, GF_FieldInfo *a, /* a and c are matrices but b is not */ GF_Matrix2D tmp; /*TOCHECK what is this test*/ -/* - if (alpha != FIX_ONE) { - GF_LOG(GF_LOG_ERROR, GF_LOG_INTERACT, ("[SVG Attributes] matrix operations not supported\n")); - return GF_NOT_SUPPORTED; - } -*/ + /* + if (alpha != FIX_ONE) { + GF_LOG(GF_LOG_ERROR, GF_LOG_INTERACT, ("[SVG Attributes] matrix operations not supported\n")); + return GF_NOT_SUPPORTED; + } + */ gf_mx2d_init(tmp); switch (b->fieldType) { case SVG_Transform_Translate_datatype: @@ -5879,7 +5936,7 @@ GF_Err gf_svg_attributes_muladd(Fixed alpha, GF_FieldInfo *a, if (*s_a) gf_free(*s_a); *s_a = res; } - break; + break; case LASeR_Size_datatype: laser_size_muladd(alpha, (LASeR_Size*)a->far_ptr, beta, (LASeR_Size*)b->far_ptr, (LASeR_Size*)c->far_ptr); break; @@ -5961,22 +6018,22 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) break; case SVG_Paint_datatype: - { - SVG_Paint *pa = (SVG_Paint *)a->far_ptr; - SVG_Paint *pb = (SVG_Paint *)b->far_ptr; - pa->type = pb->type; - if (pb->type == SVG_PAINT_URI) { - GF_FieldInfo tmp_a, tmp_b; - tmp_a.fieldType = tmp_b.fieldType = XMLRI_datatype; - tmp_a.far_ptr = &pa->iri; - tmp_b.far_ptr = &pb->iri; - gf_svg_attributes_copy(&tmp_a, &tmp_b, 0); - } else { - pa->color = pb->color; - } - return GF_OK; + { + SVG_Paint *pa = (SVG_Paint *)a->far_ptr; + SVG_Paint *pb = (SVG_Paint *)b->far_ptr; + pa->type = pb->type; + if (pb->type == SVG_PAINT_URI) { + GF_FieldInfo tmp_a, tmp_b; + tmp_a.fieldType = tmp_b.fieldType = XMLRI_datatype; + tmp_a.far_ptr = &pa->iri; + tmp_b.far_ptr = &pb->iri; + gf_svg_attributes_copy(&tmp_a, &tmp_b, 0); + } else { + pa->color = pb->color; } - break; + return GF_OK; + } + break; case SVG_Number_datatype: case SVG_Length_datatype: @@ -6085,7 +6142,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) case SVG_ContentType_datatype: case DOM_String_datatype: if (* (SVG_String *)a->far_ptr) gf_free(* (SVG_String *)a->far_ptr); - * (SVG_String *)a->far_ptr = *(SVG_String *)b->far_ptr ? gf_strdup(*(SVG_String *)b->far_ptr) : NULL; + * (SVG_String *)a->far_ptr = *(SVG_String *)b->far_ptr ? gf_strdup(*(SVG_String *)b->far_ptr) : NULL; return GF_OK; case SVG_FontFamily_datatype: @@ -6117,7 +6174,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) if ( ((SVG_Focus *)b->far_ptr)->target.string) ((SVG_Focus *)a->far_ptr)->target.string = gf_strdup( ((SVG_Focus *)b->far_ptr)->target.string); } - return GF_OK; + return GF_OK; case SMIL_Times_datatype: { @@ -6130,7 +6187,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) gf_free(t); } count = gf_list_count(src); - for (i=0;ifar_ptr; @@ -6147,7 +6204,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) saa->type = sab->type; saa->name = sab->name ? gf_strdup(sab->name) : NULL; } - break; + break; case SMIL_Duration_datatype: { SMIL_Duration *da = (SMIL_Duration*)a->far_ptr; @@ -6155,7 +6212,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) da->type = db->type; da->clock_value = db->clock_value; } - break; + break; case SMIL_AnimateValue_datatype: { SMIL_AnimateValue *sa = (SMIL_AnimateValue*)a->far_ptr; @@ -6171,7 +6228,7 @@ GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp) gf_svg_attributes_copy(&ava, &avb, 0); } } - break; + break; /* Unsupported types */ case XMLRI_List_datatype: @@ -6351,90 +6408,174 @@ Bool gf_svg_is_current_color(GF_FieldInfo *a) char *gf_svg_attribute_type_to_string(u32 att_type) { switch (att_type) { - case SVG_FillRule_datatype: return "FillRule"; - case SVG_StrokeLineJoin_datatype: return "StrokeLineJoin"; - case SVG_StrokeLineCap_datatype: return "StrokeLineCap"; - case SVG_FontStyle_datatype: return "FontStyle"; - case SVG_FontWeight_datatype: return "FontWeight"; - case SVG_FontVariant_datatype: return "FontVariant"; - case SVG_TextAnchor_datatype: return "TextAnchor"; - case SVG_TransformType_datatype: return "TransformType"; - case SVG_Display_datatype: return "Display"; - case SVG_Visibility_datatype: return "Visibility"; - case SVG_Overflow_datatype: return "Overflow"; - case SVG_ZoomAndPan_datatype: return "ZoomAndPan"; - case SVG_DisplayAlign_datatype: return "DisplayAlign"; - case SVG_PointerEvents_datatype: return "PointerEvents"; - case SVG_RenderingHint_datatype: return "RenderingHint"; - case SVG_VectorEffect_datatype: return "VectorEffect"; - case SVG_PlaybackOrder_datatype: return "PlaybackOrder"; - case SVG_TimelineBegin_datatype: return "TimelineBegin"; - case XML_Space_datatype: return "XML_Space"; - case XMLEV_Propagate_datatype: return "XMLEV_Propagate"; - case XMLEV_DefaultAction_datatype: return "XMLEV_DefaultAction"; - case XMLEV_Phase_datatype: return "XMLEV_Phase"; - case SMIL_SyncBehavior_datatype: return "SMIL_SyncBehavior"; - case SMIL_SyncTolerance_datatype: return "SMIL_SyncTolerance"; - case SMIL_AttributeType_datatype: return "SMIL_AttributeType"; - case SMIL_CalcMode_datatype: return "SMIL_CalcMode"; - case SMIL_Additive_datatype: return "SMIL_Additive"; - case SMIL_Accumulate_datatype: return "SMIL_Accumulate"; - case SMIL_Restart_datatype: return "SMIL_Restart"; - case SMIL_Fill_datatype: return "SMIL_Fill"; - case SVG_GradientUnit_datatype: return "GradientUnit"; - case SVG_InitialVisibility_datatype:return "InitialVisibility"; - case SVG_FocusHighlight_datatype: return "FocusHighlight"; - case SVG_Overlay_datatype: return "Overlay"; - case SVG_TransformBehavior_datatype:return "TransformBehavior"; - case SVG_SpreadMethod_datatype: return "SpreadMethod"; - case SVG_TextAlign_datatype: return "TextAlign"; - case SVG_Number_datatype: return "Number"; - case SVG_FontSize_datatype: return "FontSize"; - case SVG_Length_datatype: return "Length"; - case SVG_Coordinate_datatype: return "Coordinate"; - case SVG_Rotate_datatype: return "Rotate"; - case SVG_Numbers_datatype: return "Numbers"; - case SVG_Points_datatype: return "Points"; - case SVG_Coordinates_datatype: return "Coordinates"; - case DOM_StringList_datatype: return "StringList"; - case XMLRI_List_datatype: return "ListOfIRI"; - case SMIL_KeyTimes_datatype: return "SMIL_KeyTimes"; - case SMIL_KeySplines_datatype: return "SMIL_KeySplines"; - case SMIL_KeyPoints_datatype: return "SMIL_KeyPoints"; - case SMIL_Times_datatype: return "SMIL_Times"; - case SMIL_AnimateValue_datatype: return "SMIL_AnimateValue"; - case SMIL_AnimateValues_datatype: return "SMIL_AnimateValues"; - case SMIL_Duration_datatype: return "SMIL_Duration"; - case SMIL_RepeatCount_datatype: return "SMIL_RepeatCount"; - case SMIL_AttributeName_datatype: return "SMIL_AttributeName"; - case SVG_Boolean_datatype: return "Boolean"; - case SVG_Color_datatype: return "Color"; - case SVG_Paint_datatype: return "Paint"; - case SVG_PathData_datatype: return "PathData"; - case SVG_FontFamily_datatype: return "FontFamily"; - case SVG_ID_datatype: return "ID"; - case XMLRI_datatype: return "IRI"; - case XML_IDREF_datatype: return "IDREF"; - case SVG_StrokeDashArray_datatype: return "StrokeDashArray"; - case SVG_PreserveAspectRatio_datatype:return "PreserveAspectRatio"; - case SVG_ViewBox_datatype: return "ViewBox"; - case SVG_GradientOffset_datatype: return "GradientOffset"; - case SVG_Focus_datatype : return "Focus"; - case SVG_Clock_datatype : return "Clock"; - case DOM_String_datatype : return "String"; - case SVG_ContentType_datatype: return "ContentType"; - case SVG_LanguageID_datatype: return "LanguageID"; - case XMLEV_Event_datatype: return "XMLEV_Event"; - case SVG_Motion_datatype: return "Motion"; - case SVG_Transform_datatype: return "Transform"; - case SVG_Transform_Translate_datatype:return "Translate"; - case SVG_Transform_Scale_datatype: return "Scale"; - case SVG_Transform_SkewX_datatype: return "SkewX"; - case SVG_Transform_SkewY_datatype: return "SkewY"; - case SVG_Transform_Rotate_datatype: return "Rotate"; - case LASeR_Choice_datatype: return "LASeR_Choice"; - case LASeR_Size_datatype: return "LASeR_Size"; - default: return "UnknownType"; + case SVG_FillRule_datatype: + return "FillRule"; + case SVG_StrokeLineJoin_datatype: + return "StrokeLineJoin"; + case SVG_StrokeLineCap_datatype: + return "StrokeLineCap"; + case SVG_FontStyle_datatype: + return "FontStyle"; + case SVG_FontWeight_datatype: + return "FontWeight"; + case SVG_FontVariant_datatype: + return "FontVariant"; + case SVG_TextAnchor_datatype: + return "TextAnchor"; + case SVG_TransformType_datatype: + return "TransformType"; + case SVG_Display_datatype: + return "Display"; + case SVG_Visibility_datatype: + return "Visibility"; + case SVG_Overflow_datatype: + return "Overflow"; + case SVG_ZoomAndPan_datatype: + return "ZoomAndPan"; + case SVG_DisplayAlign_datatype: + return "DisplayAlign"; + case SVG_PointerEvents_datatype: + return "PointerEvents"; + case SVG_RenderingHint_datatype: + return "RenderingHint"; + case SVG_VectorEffect_datatype: + return "VectorEffect"; + case SVG_PlaybackOrder_datatype: + return "PlaybackOrder"; + case SVG_TimelineBegin_datatype: + return "TimelineBegin"; + case XML_Space_datatype: + return "XML_Space"; + case XMLEV_Propagate_datatype: + return "XMLEV_Propagate"; + case XMLEV_DefaultAction_datatype: + return "XMLEV_DefaultAction"; + case XMLEV_Phase_datatype: + return "XMLEV_Phase"; + case SMIL_SyncBehavior_datatype: + return "SMIL_SyncBehavior"; + case SMIL_SyncTolerance_datatype: + return "SMIL_SyncTolerance"; + case SMIL_AttributeType_datatype: + return "SMIL_AttributeType"; + case SMIL_CalcMode_datatype: + return "SMIL_CalcMode"; + case SMIL_Additive_datatype: + return "SMIL_Additive"; + case SMIL_Accumulate_datatype: + return "SMIL_Accumulate"; + case SMIL_Restart_datatype: + return "SMIL_Restart"; + case SMIL_Fill_datatype: + return "SMIL_Fill"; + case SVG_GradientUnit_datatype: + return "GradientUnit"; + case SVG_InitialVisibility_datatype: + return "InitialVisibility"; + case SVG_FocusHighlight_datatype: + return "FocusHighlight"; + case SVG_Overlay_datatype: + return "Overlay"; + case SVG_TransformBehavior_datatype: + return "TransformBehavior"; + case SVG_SpreadMethod_datatype: + return "SpreadMethod"; + case SVG_TextAlign_datatype: + return "TextAlign"; + case SVG_Number_datatype: + return "Number"; + case SVG_FontSize_datatype: + return "FontSize"; + case SVG_Length_datatype: + return "Length"; + case SVG_Coordinate_datatype: + return "Coordinate"; + case SVG_Rotate_datatype: + return "Rotate"; + case SVG_Numbers_datatype: + return "Numbers"; + case SVG_Points_datatype: + return "Points"; + case SVG_Coordinates_datatype: + return "Coordinates"; + case DOM_StringList_datatype: + return "StringList"; + case XMLRI_List_datatype: + return "ListOfIRI"; + case SMIL_KeyTimes_datatype: + return "SMIL_KeyTimes"; + case SMIL_KeySplines_datatype: + return "SMIL_KeySplines"; + case SMIL_KeyPoints_datatype: + return "SMIL_KeyPoints"; + case SMIL_Times_datatype: + return "SMIL_Times"; + case SMIL_AnimateValue_datatype: + return "SMIL_AnimateValue"; + case SMIL_AnimateValues_datatype: + return "SMIL_AnimateValues"; + case SMIL_Duration_datatype: + return "SMIL_Duration"; + case SMIL_RepeatCount_datatype: + return "SMIL_RepeatCount"; + case SMIL_AttributeName_datatype: + return "SMIL_AttributeName"; + case SVG_Boolean_datatype: + return "Boolean"; + case SVG_Color_datatype: + return "Color"; + case SVG_Paint_datatype: + return "Paint"; + case SVG_PathData_datatype: + return "PathData"; + case SVG_FontFamily_datatype: + return "FontFamily"; + case SVG_ID_datatype: + return "ID"; + case XMLRI_datatype: + return "IRI"; + case XML_IDREF_datatype: + return "IDREF"; + case SVG_StrokeDashArray_datatype: + return "StrokeDashArray"; + case SVG_PreserveAspectRatio_datatype: + return "PreserveAspectRatio"; + case SVG_ViewBox_datatype: + return "ViewBox"; + case SVG_GradientOffset_datatype: + return "GradientOffset"; + case SVG_Focus_datatype : + return "Focus"; + case SVG_Clock_datatype : + return "Clock"; + case DOM_String_datatype : + return "String"; + case SVG_ContentType_datatype: + return "ContentType"; + case SVG_LanguageID_datatype: + return "LanguageID"; + case XMLEV_Event_datatype: + return "XMLEV_Event"; + case SVG_Motion_datatype: + return "Motion"; + case SVG_Transform_datatype: + return "Transform"; + case SVG_Transform_Translate_datatype: + return "Translate"; + case SVG_Transform_Scale_datatype: + return "Scale"; + case SVG_Transform_SkewX_datatype: + return "SkewX"; + case SVG_Transform_SkewY_datatype: + return "SkewY"; + case SVG_Transform_Rotate_datatype: + return "Rotate"; + case LASeR_Choice_datatype: + return "LASeR_Choice"; + case LASeR_Size_datatype: + return "LASeR_Size"; + default: + return "UnknownType"; } } diff --git a/src/scenegraph/svg_properties.c b/src/scenegraph/svg_properties.c index 870359d..8f4e787 100644 --- a/src/scenegraph/svg_properties.c +++ b/src/scenegraph/svg_properties.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -29,13 +29,13 @@ #include #include -/* - Initialization of properties at the top level before any rendering +/* + Initialization of properties at the top level before any rendering The value shall not use the 'inherit' value, it uses the initial value. - The property values are then updated when going down the tree using svg_properties_apply + The property values are then updated when going down the tree using svg_properties_apply */ GF_EXPORT -void gf_svg_properties_init_pointers(SVGPropertiesPointers *svg_props) +void gf_svg_properties_init_pointers(SVGPropertiesPointers *svg_props) { if (!svg_props) return; @@ -66,7 +66,7 @@ void gf_svg_properties_init_pointers(SVGPropertiesPointers *svg_props) GF_SAFEALLOC(svg_props->fill_opacity, SVG_Number); svg_props->fill_opacity->type = SVG_NUMBER_VALUE; svg_props->fill_opacity->value = FIX_ONE; - + GF_SAFEALLOC(svg_props->fill_rule, SVG_FillRule); *svg_props->fill_rule = SVG_FILLRULE_NONZERO; @@ -229,49 +229,87 @@ void gf_svg_properties_reset_pointers(SVGPropertiesPointers *svg_props) void *gf_svg_get_property_pointer_from_tag(SVGPropertiesPointers *output_property_context, u32 prop_tag) { switch (prop_tag) { - case TAG_SVG_ATT_audio_level: return output_property_context->audio_level; - case TAG_SVG_ATT_color: return output_property_context->color; - case TAG_SVG_ATT_color_rendering: return output_property_context->color_rendering; - case TAG_SVG_ATT_display: return output_property_context->display; - case TAG_SVG_ATT_display_align: return output_property_context->display_align; - case TAG_SVG_ATT_fill: return output_property_context->fill; - case TAG_SVG_ATT_fill_opacity: return output_property_context->fill_opacity; - case TAG_SVG_ATT_fill_rule: return output_property_context->fill_rule; - case TAG_SVG_ATT_font_family: return output_property_context->font_family; - case TAG_SVG_ATT_font_size: return output_property_context->font_size; - case TAG_SVG_ATT_font_style: return output_property_context->font_style; - case TAG_SVG_ATT_font_variant: return output_property_context->font_variant; - case TAG_SVG_ATT_font_weight: return output_property_context->font_weight; - case TAG_SVG_ATT_image_rendering: return output_property_context->image_rendering; - case TAG_SVG_ATT_line_increment: return output_property_context->line_increment; - case TAG_SVG_ATT_opacity: return output_property_context->opacity; - case TAG_SVG_ATT_pointer_events: return output_property_context->pointer_events; - case TAG_SVG_ATT_shape_rendering: return output_property_context->shape_rendering; - case TAG_SVG_ATT_solid_color: return output_property_context->solid_color; - case TAG_SVG_ATT_solid_opacity: return output_property_context->solid_opacity; - case TAG_SVG_ATT_stop_color: return output_property_context->stop_color; - case TAG_SVG_ATT_stop_opacity: return output_property_context->stop_opacity; - case TAG_SVG_ATT_stroke: return output_property_context->stroke; - case TAG_SVG_ATT_stroke_dasharray: return output_property_context->stroke_dasharray; - case TAG_SVG_ATT_stroke_dashoffset: return output_property_context->stroke_dashoffset; - case TAG_SVG_ATT_stroke_linecap: return output_property_context->stroke_linecap; - case TAG_SVG_ATT_stroke_linejoin: return output_property_context->stroke_linejoin; - case TAG_SVG_ATT_stroke_miterlimit: return output_property_context->stroke_miterlimit; - case TAG_SVG_ATT_stroke_opacity: return output_property_context->stroke_opacity; - case TAG_SVG_ATT_stroke_width: return output_property_context->stroke_width; - case TAG_SVG_ATT_text_align: return output_property_context->text_align; - case TAG_SVG_ATT_text_anchor: return output_property_context->text_anchor; - case TAG_SVG_ATT_text_rendering: return output_property_context->text_rendering; - case TAG_SVG_ATT_vector_effect: return output_property_context->vector_effect; - case TAG_SVG_ATT_viewport_fill: return output_property_context->viewport_fill; - case TAG_SVG_ATT_viewport_fill_opacity: return output_property_context->viewport_fill_opacity; - case TAG_SVG_ATT_visibility: return output_property_context->visibility; - default:return NULL; + case TAG_SVG_ATT_audio_level: + return output_property_context->audio_level; + case TAG_SVG_ATT_color: + return output_property_context->color; + case TAG_SVG_ATT_color_rendering: + return output_property_context->color_rendering; + case TAG_SVG_ATT_display: + return output_property_context->display; + case TAG_SVG_ATT_display_align: + return output_property_context->display_align; + case TAG_SVG_ATT_fill: + return output_property_context->fill; + case TAG_SVG_ATT_fill_opacity: + return output_property_context->fill_opacity; + case TAG_SVG_ATT_fill_rule: + return output_property_context->fill_rule; + case TAG_SVG_ATT_font_family: + return output_property_context->font_family; + case TAG_SVG_ATT_font_size: + return output_property_context->font_size; + case TAG_SVG_ATT_font_style: + return output_property_context->font_style; + case TAG_SVG_ATT_font_variant: + return output_property_context->font_variant; + case TAG_SVG_ATT_font_weight: + return output_property_context->font_weight; + case TAG_SVG_ATT_image_rendering: + return output_property_context->image_rendering; + case TAG_SVG_ATT_line_increment: + return output_property_context->line_increment; + case TAG_SVG_ATT_opacity: + return output_property_context->opacity; + case TAG_SVG_ATT_pointer_events: + return output_property_context->pointer_events; + case TAG_SVG_ATT_shape_rendering: + return output_property_context->shape_rendering; + case TAG_SVG_ATT_solid_color: + return output_property_context->solid_color; + case TAG_SVG_ATT_solid_opacity: + return output_property_context->solid_opacity; + case TAG_SVG_ATT_stop_color: + return output_property_context->stop_color; + case TAG_SVG_ATT_stop_opacity: + return output_property_context->stop_opacity; + case TAG_SVG_ATT_stroke: + return output_property_context->stroke; + case TAG_SVG_ATT_stroke_dasharray: + return output_property_context->stroke_dasharray; + case TAG_SVG_ATT_stroke_dashoffset: + return output_property_context->stroke_dashoffset; + case TAG_SVG_ATT_stroke_linecap: + return output_property_context->stroke_linecap; + case TAG_SVG_ATT_stroke_linejoin: + return output_property_context->stroke_linejoin; + case TAG_SVG_ATT_stroke_miterlimit: + return output_property_context->stroke_miterlimit; + case TAG_SVG_ATT_stroke_opacity: + return output_property_context->stroke_opacity; + case TAG_SVG_ATT_stroke_width: + return output_property_context->stroke_width; + case TAG_SVG_ATT_text_align: + return output_property_context->text_align; + case TAG_SVG_ATT_text_anchor: + return output_property_context->text_anchor; + case TAG_SVG_ATT_text_rendering: + return output_property_context->text_rendering; + case TAG_SVG_ATT_vector_effect: + return output_property_context->vector_effect; + case TAG_SVG_ATT_viewport_fill: + return output_property_context->viewport_fill; + case TAG_SVG_ATT_viewport_fill_opacity: + return output_property_context->viewport_fill_opacity; + case TAG_SVG_ATT_visibility: + return output_property_context->visibility; + default: + return NULL; } } void *gf_svg_get_property_pointer(SVG_Element *elt, void *input_attribute, - SVGPropertiesPointers *output_property_context) + SVGPropertiesPointers *output_property_context) { SVGAttribute *att = elt->attributes; while (att) { @@ -295,48 +333,48 @@ Bool gf_svg_is_property(GF_Node *node, GF_FieldInfo *target_attribute) } if (!att) return 0; switch (att->tag) { - case TAG_SVG_ATT_audio_level: - case TAG_SVG_ATT_color: - case TAG_SVG_ATT_color_rendering: - case TAG_SVG_ATT_display: - case TAG_SVG_ATT_display_align: - case TAG_SVG_ATT_fill: - case TAG_SVG_ATT_fill_opacity: - case TAG_SVG_ATT_fill_rule: - case TAG_SVG_ATT_font_family: - case TAG_SVG_ATT_font_size: - case TAG_SVG_ATT_font_style: - case TAG_SVG_ATT_font_variant: - case TAG_SVG_ATT_font_weight: - case TAG_SVG_ATT_image_rendering: - case TAG_SVG_ATT_line_increment: - case TAG_SVG_ATT_opacity: - case TAG_SVG_ATT_pointer_events: - case TAG_SVG_ATT_shape_rendering: - case TAG_SVG_ATT_solid_color: - case TAG_SVG_ATT_solid_opacity: - case TAG_SVG_ATT_stop_color: - case TAG_SVG_ATT_stop_opacity: - case TAG_SVG_ATT_stroke: - case TAG_SVG_ATT_stroke_dasharray: - case TAG_SVG_ATT_stroke_dashoffset: - case TAG_SVG_ATT_stroke_linecap: - case TAG_SVG_ATT_stroke_linejoin: - case TAG_SVG_ATT_stroke_miterlimit: - case TAG_SVG_ATT_stroke_opacity: - case TAG_SVG_ATT_stroke_width: - case TAG_SVG_ATT_text_align: - case TAG_SVG_ATT_text_anchor: - case TAG_SVG_ATT_text_rendering: - case TAG_SVG_ATT_vector_effect: - case TAG_SVG_ATT_viewport_fill: - case TAG_SVG_ATT_viewport_fill_opacity: - case TAG_SVG_ATT_visibility: - return 1; - default: - return 0; + case TAG_SVG_ATT_audio_level: + case TAG_SVG_ATT_color: + case TAG_SVG_ATT_color_rendering: + case TAG_SVG_ATT_display: + case TAG_SVG_ATT_display_align: + case TAG_SVG_ATT_fill: + case TAG_SVG_ATT_fill_opacity: + case TAG_SVG_ATT_fill_rule: + case TAG_SVG_ATT_font_family: + case TAG_SVG_ATT_font_size: + case TAG_SVG_ATT_font_style: + case TAG_SVG_ATT_font_variant: + case TAG_SVG_ATT_font_weight: + case TAG_SVG_ATT_image_rendering: + case TAG_SVG_ATT_line_increment: + case TAG_SVG_ATT_opacity: + case TAG_SVG_ATT_pointer_events: + case TAG_SVG_ATT_shape_rendering: + case TAG_SVG_ATT_solid_color: + case TAG_SVG_ATT_solid_opacity: + case TAG_SVG_ATT_stop_color: + case TAG_SVG_ATT_stop_opacity: + case TAG_SVG_ATT_stroke: + case TAG_SVG_ATT_stroke_dasharray: + case TAG_SVG_ATT_stroke_dashoffset: + case TAG_SVG_ATT_stroke_linecap: + case TAG_SVG_ATT_stroke_linejoin: + case TAG_SVG_ATT_stroke_miterlimit: + case TAG_SVG_ATT_stroke_opacity: + case TAG_SVG_ATT_stroke_width: + case TAG_SVG_ATT_text_align: + case TAG_SVG_ATT_text_anchor: + case TAG_SVG_ATT_text_rendering: + case TAG_SVG_ATT_vector_effect: + case TAG_SVG_ATT_viewport_fill: + case TAG_SVG_ATT_viewport_fill_opacity: + case TAG_SVG_ATT_visibility: + return 1; + default: + return 0; } - } + } else { return 0; } @@ -416,7 +454,7 @@ u32 gf_svg_get_modification_flags(SVG_Element *n, GF_FieldInfo *info) { // return 0xFFFFFFFF; switch (info->fieldType) { - case SVG_Paint_datatype: + case SVG_Paint_datatype: if (info->fieldIndex == TAG_SVG_ATT_fill) return GF_SG_SVG_FILL_DIRTY; if (info->fieldIndex == TAG_SVG_ATT_stroke) return GF_SG_SVG_STROKE_DIRTY; if (info->fieldIndex == TAG_SVG_ATT_solid_color) return GF_SG_SVG_SOLIDCOLOR_OR_OPACITY_DIRTY; @@ -436,8 +474,8 @@ u32 gf_svg_get_modification_flags(SVG_Element *n, GF_FieldInfo *info) if (info->fieldIndex == TAG_SVG_ATT_stroke_dashoffset) return GF_SG_SVG_STROKEDASHOFFSET_DIRTY; if (info->fieldIndex == TAG_SVG_ATT_stroke_width) return GF_SG_SVG_STROKEWIDTH_DIRTY; break; - case SVG_DisplayAlign_datatype: - return GF_SG_SVG_DISPLAYALIGN_DIRTY; + case SVG_DisplayAlign_datatype: + return GF_SG_SVG_DISPLAYALIGN_DIRTY; case SVG_FillRule_datatype: return GF_SG_SVG_FILLRULE_DIRTY; case SVG_FontFamily_datatype: @@ -467,7 +505,7 @@ u32 gf_svg_get_modification_flags(SVG_Element *n, GF_FieldInfo *info) } /* this is not a property but a regular attribute, the animatable attributes are at the moment: - focusable, focusHighlight, gradientUnits, nav-*, target, xlink:href, xlink:type, + focusable, focusHighlight, gradientUnits, nav-*, target, xlink:href, xlink:type, the following affect the geometry of the element (some affect the positioning): @@ -477,38 +515,38 @@ u32 gf_svg_get_modification_flags(SVG_Element *n, GF_FieldInfo *info) transform, motion */ switch (info->fieldType) { - case SVG_Number_datatype: - case SVG_Length_datatype: - case SVG_Coordinate_datatype: - case SVG_Numbers_datatype: - case SVG_Points_datatype: - case SVG_Coordinates_datatype: - case SVG_PathData_datatype: - case SVG_Rotate_datatype: - return GF_SG_SVG_GEOMETRY_DIRTY; - - case XMLRI_datatype: - return GF_SG_SVG_XLINK_HREF_DIRTY; - /*for viewbox & PAR, use node dirty to force recomputing of the viewbox*/ - case SVG_PreserveAspectRatio_datatype: - case SVG_ViewBox_datatype: - return GF_SG_NODE_DIRTY; - - //case SVG_Matrix_datatype: - //case SVG_Motion_datatype: + case SVG_Number_datatype: + case SVG_Length_datatype: + case SVG_Coordinate_datatype: + case SVG_Numbers_datatype: + case SVG_Points_datatype: + case SVG_Coordinates_datatype: + case SVG_PathData_datatype: + case SVG_Rotate_datatype: + return GF_SG_SVG_GEOMETRY_DIRTY; + + case XMLRI_datatype: + return GF_SG_SVG_XLINK_HREF_DIRTY; + /*for viewbox & PAR, use node dirty to force recomputing of the viewbox*/ + case SVG_PreserveAspectRatio_datatype: + case SVG_ViewBox_datatype: + return GF_SG_NODE_DIRTY; + + //case SVG_Matrix_datatype: + //case SVG_Motion_datatype: - default: - return 0; + default: + return 0; } } -/* NOTE: Some properties (audio-level, display, opacity, solid*, stop*, vector-effect, viewport*) +/* NOTE: Some properties (audio-level, display, opacity, solid*, stop*, vector-effect, viewport*) are inherited only when they are specified with the value 'inherit' otherwise they default to their initial value which for the function below means NULL, the compositor will take care of the rest */ GF_EXPORT -u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers *render_svg_props) +u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers *render_svg_props) { u32 inherited_flags_mask = GF_SG_NODE_DIRTY | GF_SG_CHILD_DIRTY; if(!all_atts || !render_svg_props) return ~inherited_flags_mask; @@ -519,7 +557,7 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * Fixed par_val = render_svg_props->computed_audio_level; Fixed val = par_val; if (all_atts->audio_level->type != SVG_NUMBER_INHERIT) { - render_svg_props->audio_level = all_atts->audio_level; + render_svg_props->audio_level = all_atts->audio_level; val = all_atts->audio_level->value; } else if (render_svg_props->audio_level) { val = render_svg_props->audio_level->value; @@ -530,9 +568,9 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * val = MIN(FIX_ONE, MAX( val, 0)); render_svg_props->computed_audio_level = gf_mulfix(val, par_val); } - - if (all_atts->color && all_atts->color->type == SVG_PAINT_COLOR - && all_atts->color->color.type != SVG_COLOR_INHERIT) { + + if (all_atts->color && all_atts->color->type == SVG_PAINT_COLOR + && all_atts->color->color.type != SVG_COLOR_INHERIT) { render_svg_props->color = all_atts->color; } else { inherited_flags_mask |= GF_SG_SVG_COLOR_DIRTY; @@ -555,9 +593,9 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * } if (all_atts->fill && all_atts->fill->type != SVG_PAINT_INHERIT) { render_svg_props->fill = all_atts->fill; - if (all_atts->fill->type == SVG_PAINT_COLOR && - all_atts->fill->color.type == SVG_COLOR_CURRENTCOLOR) { - render_svg_props->fill = render_svg_props->color; + if (all_atts->fill->type == SVG_PAINT_COLOR && + all_atts->fill->color.type == SVG_COLOR_CURRENTCOLOR) { + render_svg_props->fill = render_svg_props->color; if (inherited_flags_mask & GF_SG_SVG_COLOR_DIRTY) { inherited_flags_mask |= GF_SG_SVG_FILL_DIRTY; } @@ -623,9 +661,9 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * render_svg_props->shape_rendering = all_atts->shape_rendering; } if (all_atts->solid_color && all_atts->solid_color->type != SVG_PAINT_INHERIT) { - render_svg_props->solid_color = all_atts->solid_color; - if (all_atts->solid_color->type == SVG_PAINT_COLOR && - all_atts->solid_color->color.type == SVG_COLOR_CURRENTCOLOR) { + render_svg_props->solid_color = all_atts->solid_color; + if (all_atts->solid_color->type == SVG_PAINT_COLOR && + all_atts->solid_color->color.type == SVG_COLOR_CURRENTCOLOR) { render_svg_props->solid_color = render_svg_props->color; if (inherited_flags_mask & GF_SG_SVG_COLOR_DIRTY) { inherited_flags_mask |= GF_SG_SVG_SOLIDCOLOR_OR_OPACITY_DIRTY; @@ -645,8 +683,8 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * } if (all_atts->stop_color && all_atts->stop_color->type != SVG_PAINT_INHERIT) { render_svg_props->stop_color = all_atts->stop_color; - if (all_atts->stop_color->type == SVG_PAINT_COLOR && - all_atts->stop_color->color.type == SVG_COLOR_CURRENTCOLOR) { + if (all_atts->stop_color->type == SVG_PAINT_COLOR && + all_atts->stop_color->color.type == SVG_COLOR_CURRENTCOLOR) { render_svg_props->stop_color = render_svg_props->color; if (inherited_flags_mask & GF_SG_SVG_COLOR_DIRTY) { inherited_flags_mask |= GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY; @@ -666,8 +704,8 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * } if (all_atts->stroke && all_atts->stroke->type != SVG_PAINT_INHERIT) { render_svg_props->stroke = all_atts->stroke; - if (all_atts->stroke->type == SVG_PAINT_COLOR && - all_atts->stroke->color.type == SVG_COLOR_CURRENTCOLOR) { + if (all_atts->stroke->type == SVG_PAINT_COLOR && + all_atts->stroke->color.type == SVG_COLOR_CURRENTCOLOR) { render_svg_props->stroke = render_svg_props->color; if (inherited_flags_mask & GF_SG_SVG_COLOR_DIRTY) { inherited_flags_mask |= GF_SG_SVG_STROKE_DIRTY; @@ -732,10 +770,10 @@ u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers * inherited_flags_mask |= GF_SG_SVG_VECTOREFFECT_DIRTY; } if (all_atts->viewport_fill && all_atts->viewport_fill->type != SVG_PAINT_INHERIT) { - render_svg_props->viewport_fill = all_atts->viewport_fill; + render_svg_props->viewport_fill = all_atts->viewport_fill; } else if (!all_atts->viewport_fill) { render_svg_props->viewport_fill = NULL; - } + } if (all_atts->viewport_fill_opacity && all_atts->viewport_fill_opacity->type != SVG_NUMBER_INHERIT) { render_svg_props->viewport_fill_opacity = all_atts->viewport_fill_opacity; } else if (!all_atts->viewport_fill_opacity) { @@ -758,217 +796,625 @@ void gf_svg_flatten_attributes(SVG_Element *e, SVGAllAttributes *all_atts) att = e->attributes; while (att) { switch(att->tag) { - case TAG_XML_ATT_id: all_atts->xml_id = (SVG_ID *)att->data; break; - case TAG_XML_ATT_base: all_atts->xml_base = (XMLRI *)att->data; break; - case TAG_XML_ATT_lang: all_atts->xml_lang = (SVG_LanguageID *)att->data; break; - case TAG_XML_ATT_space: all_atts->xml_space = (XML_Space *)att->data; break; - - case TAG_XLINK_ATT_type: all_atts->xlink_type = (SVG_String *)att->data; break; - case TAG_XLINK_ATT_role: all_atts->xlink_role = (XMLRI *)att->data; break; - case TAG_XLINK_ATT_arcrole: all_atts->xlink_arcrole = (XMLRI *)att->data; break; - case TAG_XLINK_ATT_title: all_atts->xlink_title = (SVG_String *)att->data; break; - case TAG_XLINK_ATT_href: all_atts->xlink_href = (XMLRI *)att->data; break; - case TAG_XLINK_ATT_show: all_atts->xlink_show = (SVG_String *)att->data; break; - case TAG_XLINK_ATT_actuate: all_atts->xlink_actuate = (SVG_String *)att->data; break; - - case TAG_XMLEV_ATT_event: all_atts->event = (XMLEV_Event *)att->data; break; - case TAG_XMLEV_ATT_phase: all_atts->phase = (XMLEV_Phase *)att->data; break; - case TAG_XMLEV_ATT_propagate: all_atts->propagate = (XMLEV_Propagate *)att->data; break; - case TAG_XMLEV_ATT_defaultAction: all_atts->defaultAction = (XMLEV_DefaultAction *)att->data; break; - case TAG_XMLEV_ATT_observer: all_atts->observer = (XML_IDREF *)att->data; break; - case TAG_XMLEV_ATT_target: all_atts->listener_target = (XML_IDREF *)att->data; break; - case TAG_XMLEV_ATT_handler: all_atts->handler = (XMLRI *)att->data; break; - - case TAG_LSR_ATT_enabled: all_atts->lsr_enabled = (SVG_Boolean *)att->data; break; - - case TAG_SVG_ATT_id: all_atts->id = (SVG_ID *)att->data; break; - case TAG_SVG_ATT__class: all_atts->_class = (SVG_String *)att->data; break; - case TAG_SVG_ATT_requiredFeatures: all_atts->requiredFeatures = (SVG_ListOfIRI *)att->data; break; - case TAG_SVG_ATT_requiredExtensions: all_atts->requiredExtensions = (SVG_ListOfIRI *)att->data; break; - case TAG_SVG_ATT_requiredFormats: all_atts->requiredFormats = (SVG_FormatList *)att->data; break; - case TAG_SVG_ATT_requiredFonts: all_atts->requiredFonts = (SVG_FontList *)att->data; break; - case TAG_SVG_ATT_systemLanguage: all_atts->systemLanguage = (SVG_LanguageIDs *)att->data; break; - case TAG_SVG_ATT_display: all_atts->display = (SVG_Display *)att->data; break; - case TAG_SVG_ATT_visibility: all_atts->visibility = (SVG_Visibility *)att->data; break; - case TAG_SVG_ATT_image_rendering: all_atts->image_rendering = (SVG_RenderingHint *)att->data; break; - case TAG_SVG_ATT_pointer_events: all_atts->pointer_events = (SVG_PointerEvents *)att->data; break; - case TAG_SVG_ATT_shape_rendering: all_atts->shape_rendering = (SVG_RenderingHint *)att->data; break; - case TAG_SVG_ATT_text_rendering: all_atts->text_rendering = (SVG_RenderingHint *)att->data; break; - case TAG_SVG_ATT_audio_level: all_atts->audio_level = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_viewport_fill: all_atts->viewport_fill = (SVG_Paint *)att->data; break; - case TAG_SVG_ATT_viewport_fill_opacity: all_atts->viewport_fill_opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_overflow: all_atts->overflow = (SVG_String *)att->data; break; - case TAG_SVG_ATT_fill_opacity: all_atts->fill_opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_stroke_opacity: all_atts->stroke_opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_fill: all_atts->fill = (SVG_Paint *)att->data; break; - case TAG_SVG_ATT_filter: all_atts->filter = (SVG_Paint *)att->data; break; - case TAG_SVG_ATT_fill_rule: all_atts->fill_rule = (SVG_FillRule *)att->data; break; - case TAG_SVG_ATT_stroke: all_atts->stroke = (SVG_Paint *)att->data; break; - case TAG_SVG_ATT_stroke_dasharray: all_atts->stroke_dasharray = (SVG_StrokeDashArray *)att->data; break; - case TAG_SVG_ATT_stroke_dashoffset: all_atts->stroke_dashoffset = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_stroke_linecap: all_atts->stroke_linecap = (SVG_StrokeLineCap *)att->data; break; - case TAG_SVG_ATT_stroke_linejoin: all_atts->stroke_linejoin = (SVG_StrokeLineJoin *)att->data; break; - case TAG_SVG_ATT_stroke_miterlimit: all_atts->stroke_miterlimit = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_stroke_width: all_atts->stroke_width = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_color: all_atts->color = (SVG_Paint *)att->data; break; - case TAG_SVG_ATT_color_rendering: all_atts->color_rendering = (SVG_RenderingHint *)att->data; break; - case TAG_SVG_ATT_vector_effect: all_atts->vector_effect = (SVG_VectorEffect *)att->data; break; - case TAG_SVG_ATT_solid_color: all_atts->solid_color = (SVG_SVGColor *)att->data; break; - case TAG_SVG_ATT_solid_opacity: all_atts->solid_opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_display_align: all_atts->display_align = (SVG_DisplayAlign *)att->data; break; - case TAG_SVG_ATT_line_increment: all_atts->line_increment = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_stop_color: all_atts->stop_color = (SVG_SVGColor *)att->data; break; - case TAG_SVG_ATT_stop_opacity: all_atts->stop_opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_font_family: all_atts->font_family = (SVG_FontFamily *)att->data; break; - case TAG_SVG_ATT_font_size: all_atts->font_size = (SVG_FontSize *)att->data; break; - case TAG_SVG_ATT_font_style: all_atts->font_style = (SVG_FontStyle *)att->data; break; - case TAG_SVG_ATT_font_variant: all_atts->font_variant = (SVG_FontVariant *)att->data; break; - case TAG_SVG_ATT_font_weight: all_atts->font_weight = (SVG_FontWeight *)att->data; break; - case TAG_SVG_ATT_text_anchor: all_atts->text_anchor = (SVG_TextAnchor *)att->data; break; - case TAG_SVG_ATT_text_align: all_atts->text_align = (SVG_TextAlign *)att->data; break; - case TAG_SVG_ATT_text_decoration: all_atts->text_decoration = (SVG_String *)att->data; break; - case TAG_SVG_ATT_focusHighlight: all_atts->focusHighlight = (SVG_FocusHighlight *)att->data; break; - case TAG_SVG_ATT_externalResourcesRequired: all_atts->externalResourcesRequired = (SVG_Boolean *)att->data; break; - case TAG_SVG_ATT_focusable: all_atts->focusable = (SVG_Focusable *)att->data; break; - case TAG_SVG_ATT_nav_next: all_atts->nav_next = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_prev: all_atts->nav_prev = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_up: all_atts->nav_up = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_up_right: all_atts->nav_up_right = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_right: all_atts->nav_right = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_down_right: all_atts->nav_down_right = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_down: all_atts->nav_down = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_down_left: all_atts->nav_down_left = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_left: all_atts->nav_left = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_nav_up_left: all_atts->nav_up_left = (SVG_Focus *)att->data; break; - case TAG_SVG_ATT_transform: all_atts->transform = (SVG_Transform *)att->data; break; - case TAG_SVG_ATT_target: all_atts->target = (SVG_String *)att->data; break; - case TAG_SVG_ATT_attributeName: all_atts->attributeName = (SMIL_AttributeName *)att->data; break; - case TAG_SVG_ATT_attributeType: all_atts->attributeType = (SMIL_AttributeType *)att->data; break; - case TAG_SVG_ATT_begin: all_atts->begin = (SMIL_Times *)att->data; break; - case TAG_SVG_ATT_dur: all_atts->dur = (SMIL_Duration *)att->data; break; - case TAG_SVG_ATT_end: all_atts->end = (SMIL_Times *)att->data; break; - case TAG_SVG_ATT_repeatCount: all_atts->repeatCount = (SMIL_RepeatCount *)att->data; break; - case TAG_SVG_ATT_repeatDur: all_atts->repeatDur = (SMIL_Duration *)att->data; break; - case TAG_SVG_ATT_restart: all_atts->restart = (SMIL_Restart *)att->data; break; - case TAG_SVG_ATT_smil_fill: all_atts->smil_fill = (SMIL_Fill *)att->data; break; - case TAG_SVG_ATT_min: all_atts->min = (SMIL_Duration *)att->data; break; - case TAG_SVG_ATT_max: all_atts->max = (SMIL_Duration *)att->data; break; - case TAG_SVG_ATT_to: all_atts->to = (SMIL_AnimateValue *)att->data; break; - case TAG_SVG_ATT_calcMode: all_atts->calcMode = (SMIL_CalcMode *)att->data; break; - case TAG_SVG_ATT_values: all_atts->values = (SMIL_AnimateValues *)att->data; break; - case TAG_SVG_ATT_keyTimes: all_atts->keyTimes = (SMIL_KeyTimes *)att->data; break; - case TAG_SVG_ATT_keySplines: all_atts->keySplines = (SMIL_KeySplines *)att->data; break; - case TAG_SVG_ATT_from: all_atts->from = (SMIL_AnimateValue *)att->data; break; - case TAG_SVG_ATT_by: all_atts->by = (SMIL_AnimateValue *)att->data; break; - case TAG_SVG_ATT_additive: all_atts->additive = (SMIL_Additive *)att->data; break; - case TAG_SVG_ATT_accumulate: all_atts->accumulate = (SMIL_Accumulate *)att->data; break; - case TAG_SVG_ATT_path: all_atts->path = (SVG_PathData *)att->data; break; - case TAG_SVG_ATT_keyPoints: all_atts->keyPoints = (SMIL_KeyPoints *)att->data; break; - case TAG_SVG_ATT_rotate: all_atts->rotate = (SVG_Rotate *)att->data; break; - case TAG_SVG_ATT_origin: all_atts->origin = (SVG_String *)att->data; break; - case TAG_SVG_ATT_transform_type: all_atts->transform_type = (SVG_TransformType *)att->data; break; - case TAG_SVG_ATT_clipBegin: all_atts->clipBegin = (SVG_Clock *)att->data; break; - case TAG_SVG_ATT_clipEnd: all_atts->clipEnd = (SVG_Clock *)att->data; break; - case TAG_SVG_ATT_syncBehavior: all_atts->syncBehavior = (SMIL_SyncBehavior *)att->data; break; - case TAG_SVG_ATT_syncTolerance: all_atts->syncTolerance = (SMIL_SyncTolerance *)att->data; break; - case TAG_SVG_ATT_syncMaster: all_atts->syncMaster = (SVG_Boolean *)att->data; break; - case TAG_SVG_ATT_syncReference: all_atts->syncReference = (XMLRI *)att->data; break; - case TAG_SVG_ATT_x: all_atts->x = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_y: all_atts->y = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_width: all_atts->width = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_height: all_atts->height = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_preserveAspectRatio: all_atts->preserveAspectRatio = (SVG_PreserveAspectRatio *)att->data; break; - case TAG_SVG_ATT_initialVisibility: all_atts->initialVisibility = (SVG_InitialVisibility *)att->data; break; - case TAG_SVG_ATT_type: all_atts->type = (SVG_ContentType *)att->data; break; - case TAG_SVG_ATT_cx: all_atts->cx = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_cy: all_atts->cy = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_r: all_atts->r = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_cursorManager_x: all_atts->cursorManager_x = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_cursorManager_y: all_atts->cursorManager_y = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_rx: all_atts->rx = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_ry: all_atts->ry = (SVG_Length *)att->data; break; - case TAG_SVG_ATT_horiz_adv_x: all_atts->horiz_adv_x = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_horiz_origin_x: all_atts->horiz_origin_x = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_font_stretch: all_atts->font_stretch = (SVG_String *)att->data; break; - case TAG_SVG_ATT_unicode_range: all_atts->unicode_range = (SVG_String *)att->data; break; - case TAG_SVG_ATT_panose_1: all_atts->panose_1 = (SVG_String *)att->data; break; - case TAG_SVG_ATT_widths: all_atts->widths = (SVG_String *)att->data; break; - case TAG_SVG_ATT_bbox: all_atts->bbox = (SVG_String *)att->data; break; - case TAG_SVG_ATT_units_per_em: all_atts->units_per_em = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_stemv: all_atts->stemv = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_stemh: all_atts->stemh = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_slope: all_atts->slope = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_cap_height: all_atts->cap_height = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_x_height: all_atts->x_height = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_accent_height: all_atts->accent_height = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_ascent: all_atts->ascent = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_descent: all_atts->descent = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_ideographic: all_atts->ideographic = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_alphabetic: all_atts->alphabetic = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_mathematical: all_atts->mathematical = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_hanging: all_atts->hanging = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_underline_position: all_atts->underline_position = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_underline_thickness: all_atts->underline_thickness = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_strikethrough_position: all_atts->strikethrough_position = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_strikethrough_thickness: all_atts->strikethrough_thickness = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_overline_position: all_atts->overline_position = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_overline_thickness: all_atts->overline_thickness = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_d: all_atts->d = (SVG_PathData *)att->data; break; - case TAG_SVG_ATT_unicode: all_atts->unicode = (SVG_String *)att->data; break; - case TAG_SVG_ATT_glyph_name: all_atts->glyph_name = (SVG_String *)att->data; break; - case TAG_SVG_ATT_arabic_form: all_atts->arabic_form = (SVG_String *)att->data; break; - case TAG_SVG_ATT_lang: all_atts->lang = (SVG_LanguageIDs *)att->data; break; - case TAG_SVG_ATT_u1: all_atts->u1 = (SVG_String *)att->data; break; - case TAG_SVG_ATT_g1: all_atts->g1 = (SVG_String *)att->data; break; - case TAG_SVG_ATT_u2: all_atts->u2 = (SVG_String *)att->data; break; - case TAG_SVG_ATT_g2: all_atts->g2 = (SVG_String *)att->data; break; - case TAG_SVG_ATT_k: all_atts->k = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_opacity: all_atts->opacity = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_x1: all_atts->x1 = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_y1: all_atts->y1 = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_x2: all_atts->x2 = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_y2: all_atts->y2 = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_gradientUnits: all_atts->gradientUnits = (SVG_GradientUnit *)att->data; break; - case TAG_SVG_ATT_filterUnits: all_atts->focusable = (SVG_GradientUnit *)att->data; break; - case TAG_SVG_ATT_spreadMethod: all_atts->spreadMethod = (SVG_SpreadMethod *)att->data; break; - case TAG_SVG_ATT_gradientTransform: all_atts->gradientTransform = (SVG_Transform *)att->data; break; - case TAG_SVG_ATT_pathLength: all_atts->pathLength = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_points: all_atts->points = (SVG_Points *)att->data; break; - case TAG_SVG_ATT_mediaSize: all_atts->mediaSize = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_mediaTime: all_atts->mediaTime = (SVG_String *)att->data; break; - case TAG_SVG_ATT_mediaCharacterEncoding: all_atts->mediaCharacterEncoding = (SVG_String *)att->data; break; - case TAG_SVG_ATT_mediaContentEncodings: all_atts->mediaContentEncodings = (SVG_String *)att->data; break; - case TAG_SVG_ATT_bandwidth: all_atts->bandwidth = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_fx: all_atts->fx = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_fy: all_atts->fy = (SVG_Coordinate *)att->data; break; - case TAG_SVG_ATT_size: all_atts->size = (LASeR_Size *)att->data; break; - case TAG_SVG_ATT_choice: all_atts->choice = (LASeR_Choice *)att->data; break; - case TAG_SVG_ATT_delta: all_atts->delta = (LASeR_Size *)att->data; break; - case TAG_SVG_ATT_offset: all_atts->offset = (SVG_Number *)att->data; break; - case TAG_SVG_ATT_syncBehaviorDefault: all_atts->syncBehaviorDefault = (SMIL_SyncBehavior *)att->data; break; - case TAG_SVG_ATT_syncToleranceDefault: all_atts->syncToleranceDefault = (SMIL_SyncTolerance *)att->data; break; - case TAG_SVG_ATT_viewBox: all_atts->viewBox = (SVG_ViewBox *)att->data; break; - case TAG_SVG_ATT_zoomAndPan: all_atts->zoomAndPan = (SVG_ZoomAndPan *)att->data; break; - case TAG_SVG_ATT_version: all_atts->version = (SVG_String *)att->data; break; - case TAG_SVG_ATT_baseProfile: all_atts->baseProfile = (SVG_String *)att->data; break; - case TAG_SVG_ATT_contentScriptType: all_atts->contentScriptType = (SVG_ContentType *)att->data; break; - case TAG_SVG_ATT_snapshotTime: all_atts->snapshotTime = (SVG_Clock *)att->data; break; - case TAG_SVG_ATT_timelineBegin: all_atts->timelineBegin = (SVG_TimelineBegin *)att->data; break; - case TAG_SVG_ATT_playbackOrder: all_atts->playbackOrder = (SVG_PlaybackOrder *)att->data; break; - case TAG_SVG_ATT_editable: all_atts->editable = (SVG_Boolean *)att->data; break; - case TAG_SVG_ATT_text_x: all_atts->text_x = (SVG_Coordinates *)att->data; break; - case TAG_SVG_ATT_text_y: all_atts->text_y = (SVG_Coordinates *)att->data; break; - case TAG_SVG_ATT_text_rotate: all_atts->text_rotate = (SVG_Numbers *)att->data; break; - case TAG_SVG_ATT_transformBehavior: all_atts->transformBehavior = (SVG_TransformBehavior *)att->data; break; - case TAG_SVG_ATT_overlay: all_atts->overlay = (SVG_Overlay *)att->data; break; - case TAG_SVG_ATT_fullscreen: all_atts->fullscreen = (SVG_Boolean *)att->data; break; - case TAG_SVG_ATT_motionTransform: all_atts->motionTransform = (SVG_Motion *)att->data; break; - - case TAG_GSVG_ATT_useAsPrimary: all_atts->gpac_useAsPrimary = (SVG_Boolean *)att->data; break; - case TAG_GSVG_ATT_depthOffset: all_atts->gpac_depthOffset = (SVG_Number *)att->data; break; - case TAG_GSVG_ATT_depthGain: all_atts->gpac_depthGain = (SVG_Number *)att->data; break; + case TAG_XML_ATT_id: + all_atts->xml_id = (SVG_ID *)att->data; + break; + case TAG_XML_ATT_base: + all_atts->xml_base = (XMLRI *)att->data; + break; + case TAG_XML_ATT_lang: + all_atts->xml_lang = (SVG_LanguageID *)att->data; + break; + case TAG_XML_ATT_space: + all_atts->xml_space = (XML_Space *)att->data; + break; + + case TAG_XLINK_ATT_type: + all_atts->xlink_type = (SVG_String *)att->data; + break; + case TAG_XLINK_ATT_role: + all_atts->xlink_role = (XMLRI *)att->data; + break; + case TAG_XLINK_ATT_arcrole: + all_atts->xlink_arcrole = (XMLRI *)att->data; + break; + case TAG_XLINK_ATT_title: + all_atts->xlink_title = (SVG_String *)att->data; + break; + case TAG_XLINK_ATT_href: + all_atts->xlink_href = (XMLRI *)att->data; + break; + case TAG_XLINK_ATT_show: + all_atts->xlink_show = (SVG_String *)att->data; + break; + case TAG_XLINK_ATT_actuate: + all_atts->xlink_actuate = (SVG_String *)att->data; + break; + + case TAG_XMLEV_ATT_event: + all_atts->event = (XMLEV_Event *)att->data; + break; + case TAG_XMLEV_ATT_phase: + all_atts->phase = (XMLEV_Phase *)att->data; + break; + case TAG_XMLEV_ATT_propagate: + all_atts->propagate = (XMLEV_Propagate *)att->data; + break; + case TAG_XMLEV_ATT_defaultAction: + all_atts->defaultAction = (XMLEV_DefaultAction *)att->data; + break; + case TAG_XMLEV_ATT_observer: + all_atts->observer = (XML_IDREF *)att->data; + break; + case TAG_XMLEV_ATT_target: + all_atts->listener_target = (XML_IDREF *)att->data; + break; + case TAG_XMLEV_ATT_handler: + all_atts->handler = (XMLRI *)att->data; + break; + + case TAG_LSR_ATT_enabled: + all_atts->lsr_enabled = (SVG_Boolean *)att->data; + break; + + case TAG_SVG_ATT_id: + all_atts->id = (SVG_ID *)att->data; + break; + case TAG_SVG_ATT__class: + all_atts->_class = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_requiredFeatures: + all_atts->requiredFeatures = (SVG_ListOfIRI *)att->data; + break; + case TAG_SVG_ATT_requiredExtensions: + all_atts->requiredExtensions = (SVG_ListOfIRI *)att->data; + break; + case TAG_SVG_ATT_requiredFormats: + all_atts->requiredFormats = (SVG_FormatList *)att->data; + break; + case TAG_SVG_ATT_requiredFonts: + all_atts->requiredFonts = (SVG_FontList *)att->data; + break; + case TAG_SVG_ATT_systemLanguage: + all_atts->systemLanguage = (SVG_LanguageIDs *)att->data; + break; + case TAG_SVG_ATT_display: + all_atts->display = (SVG_Display *)att->data; + break; + case TAG_SVG_ATT_visibility: + all_atts->visibility = (SVG_Visibility *)att->data; + break; + case TAG_SVG_ATT_image_rendering: + all_atts->image_rendering = (SVG_RenderingHint *)att->data; + break; + case TAG_SVG_ATT_pointer_events: + all_atts->pointer_events = (SVG_PointerEvents *)att->data; + break; + case TAG_SVG_ATT_shape_rendering: + all_atts->shape_rendering = (SVG_RenderingHint *)att->data; + break; + case TAG_SVG_ATT_text_rendering: + all_atts->text_rendering = (SVG_RenderingHint *)att->data; + break; + case TAG_SVG_ATT_audio_level: + all_atts->audio_level = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_viewport_fill: + all_atts->viewport_fill = (SVG_Paint *)att->data; + break; + case TAG_SVG_ATT_viewport_fill_opacity: + all_atts->viewport_fill_opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_overflow: + all_atts->overflow = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_fill_opacity: + all_atts->fill_opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_stroke_opacity: + all_atts->stroke_opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_fill: + all_atts->fill = (SVG_Paint *)att->data; + break; + case TAG_SVG_ATT_filter: + all_atts->filter = (SVG_Paint *)att->data; + break; + case TAG_SVG_ATT_fill_rule: + all_atts->fill_rule = (SVG_FillRule *)att->data; + break; + case TAG_SVG_ATT_stroke: + all_atts->stroke = (SVG_Paint *)att->data; + break; + case TAG_SVG_ATT_stroke_dasharray: + all_atts->stroke_dasharray = (SVG_StrokeDashArray *)att->data; + break; + case TAG_SVG_ATT_stroke_dashoffset: + all_atts->stroke_dashoffset = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_stroke_linecap: + all_atts->stroke_linecap = (SVG_StrokeLineCap *)att->data; + break; + case TAG_SVG_ATT_stroke_linejoin: + all_atts->stroke_linejoin = (SVG_StrokeLineJoin *)att->data; + break; + case TAG_SVG_ATT_stroke_miterlimit: + all_atts->stroke_miterlimit = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_stroke_width: + all_atts->stroke_width = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_color: + all_atts->color = (SVG_Paint *)att->data; + break; + case TAG_SVG_ATT_color_rendering: + all_atts->color_rendering = (SVG_RenderingHint *)att->data; + break; + case TAG_SVG_ATT_vector_effect: + all_atts->vector_effect = (SVG_VectorEffect *)att->data; + break; + case TAG_SVG_ATT_solid_color: + all_atts->solid_color = (SVG_SVGColor *)att->data; + break; + case TAG_SVG_ATT_solid_opacity: + all_atts->solid_opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_display_align: + all_atts->display_align = (SVG_DisplayAlign *)att->data; + break; + case TAG_SVG_ATT_line_increment: + all_atts->line_increment = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_stop_color: + all_atts->stop_color = (SVG_SVGColor *)att->data; + break; + case TAG_SVG_ATT_stop_opacity: + all_atts->stop_opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_font_family: + all_atts->font_family = (SVG_FontFamily *)att->data; + break; + case TAG_SVG_ATT_font_size: + all_atts->font_size = (SVG_FontSize *)att->data; + break; + case TAG_SVG_ATT_font_style: + all_atts->font_style = (SVG_FontStyle *)att->data; + break; + case TAG_SVG_ATT_font_variant: + all_atts->font_variant = (SVG_FontVariant *)att->data; + break; + case TAG_SVG_ATT_font_weight: + all_atts->font_weight = (SVG_FontWeight *)att->data; + break; + case TAG_SVG_ATT_text_anchor: + all_atts->text_anchor = (SVG_TextAnchor *)att->data; + break; + case TAG_SVG_ATT_text_align: + all_atts->text_align = (SVG_TextAlign *)att->data; + break; + case TAG_SVG_ATT_text_decoration: + all_atts->text_decoration = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_focusHighlight: + all_atts->focusHighlight = (SVG_FocusHighlight *)att->data; + break; + case TAG_SVG_ATT_externalResourcesRequired: + all_atts->externalResourcesRequired = (SVG_Boolean *)att->data; + break; + case TAG_SVG_ATT_focusable: + all_atts->focusable = (SVG_Focusable *)att->data; + break; + case TAG_SVG_ATT_nav_next: + all_atts->nav_next = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_prev: + all_atts->nav_prev = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_up: + all_atts->nav_up = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_up_right: + all_atts->nav_up_right = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_right: + all_atts->nav_right = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_down_right: + all_atts->nav_down_right = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_down: + all_atts->nav_down = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_down_left: + all_atts->nav_down_left = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_left: + all_atts->nav_left = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_nav_up_left: + all_atts->nav_up_left = (SVG_Focus *)att->data; + break; + case TAG_SVG_ATT_transform: + all_atts->transform = (SVG_Transform *)att->data; + break; + case TAG_SVG_ATT_target: + all_atts->target = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_attributeName: + all_atts->attributeName = (SMIL_AttributeName *)att->data; + break; + case TAG_SVG_ATT_attributeType: + all_atts->attributeType = (SMIL_AttributeType *)att->data; + break; + case TAG_SVG_ATT_begin: + all_atts->begin = (SMIL_Times *)att->data; + break; + case TAG_SVG_ATT_dur: + all_atts->dur = (SMIL_Duration *)att->data; + break; + case TAG_SVG_ATT_end: + all_atts->end = (SMIL_Times *)att->data; + break; + case TAG_SVG_ATT_repeatCount: + all_atts->repeatCount = (SMIL_RepeatCount *)att->data; + break; + case TAG_SVG_ATT_repeatDur: + all_atts->repeatDur = (SMIL_Duration *)att->data; + break; + case TAG_SVG_ATT_restart: + all_atts->restart = (SMIL_Restart *)att->data; + break; + case TAG_SVG_ATT_smil_fill: + all_atts->smil_fill = (SMIL_Fill *)att->data; + break; + case TAG_SVG_ATT_min: + all_atts->min = (SMIL_Duration *)att->data; + break; + case TAG_SVG_ATT_max: + all_atts->max = (SMIL_Duration *)att->data; + break; + case TAG_SVG_ATT_to: + all_atts->to = (SMIL_AnimateValue *)att->data; + break; + case TAG_SVG_ATT_calcMode: + all_atts->calcMode = (SMIL_CalcMode *)att->data; + break; + case TAG_SVG_ATT_values: + all_atts->values = (SMIL_AnimateValues *)att->data; + break; + case TAG_SVG_ATT_keyTimes: + all_atts->keyTimes = (SMIL_KeyTimes *)att->data; + break; + case TAG_SVG_ATT_keySplines: + all_atts->keySplines = (SMIL_KeySplines *)att->data; + break; + case TAG_SVG_ATT_from: + all_atts->from = (SMIL_AnimateValue *)att->data; + break; + case TAG_SVG_ATT_by: + all_atts->by = (SMIL_AnimateValue *)att->data; + break; + case TAG_SVG_ATT_additive: + all_atts->additive = (SMIL_Additive *)att->data; + break; + case TAG_SVG_ATT_accumulate: + all_atts->accumulate = (SMIL_Accumulate *)att->data; + break; + case TAG_SVG_ATT_path: + all_atts->path = (SVG_PathData *)att->data; + break; + case TAG_SVG_ATT_keyPoints: + all_atts->keyPoints = (SMIL_KeyPoints *)att->data; + break; + case TAG_SVG_ATT_rotate: + all_atts->rotate = (SVG_Rotate *)att->data; + break; + case TAG_SVG_ATT_origin: + all_atts->origin = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_transform_type: + all_atts->transform_type = (SVG_TransformType *)att->data; + break; + case TAG_SVG_ATT_clipBegin: + all_atts->clipBegin = (SVG_Clock *)att->data; + break; + case TAG_SVG_ATT_clipEnd: + all_atts->clipEnd = (SVG_Clock *)att->data; + break; + case TAG_SVG_ATT_syncBehavior: + all_atts->syncBehavior = (SMIL_SyncBehavior *)att->data; + break; + case TAG_SVG_ATT_syncTolerance: + all_atts->syncTolerance = (SMIL_SyncTolerance *)att->data; + break; + case TAG_SVG_ATT_syncMaster: + all_atts->syncMaster = (SVG_Boolean *)att->data; + break; + case TAG_SVG_ATT_syncReference: + all_atts->syncReference = (XMLRI *)att->data; + break; + case TAG_SVG_ATT_x: + all_atts->x = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_y: + all_atts->y = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_width: + all_atts->width = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_height: + all_atts->height = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_preserveAspectRatio: + all_atts->preserveAspectRatio = (SVG_PreserveAspectRatio *)att->data; + break; + case TAG_SVG_ATT_initialVisibility: + all_atts->initialVisibility = (SVG_InitialVisibility *)att->data; + break; + case TAG_SVG_ATT_type: + all_atts->type = (SVG_ContentType *)att->data; + break; + case TAG_SVG_ATT_cx: + all_atts->cx = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_cy: + all_atts->cy = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_r: + all_atts->r = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_cursorManager_x: + all_atts->cursorManager_x = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_cursorManager_y: + all_atts->cursorManager_y = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_rx: + all_atts->rx = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_ry: + all_atts->ry = (SVG_Length *)att->data; + break; + case TAG_SVG_ATT_horiz_adv_x: + all_atts->horiz_adv_x = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_horiz_origin_x: + all_atts->horiz_origin_x = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_font_stretch: + all_atts->font_stretch = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_unicode_range: + all_atts->unicode_range = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_panose_1: + all_atts->panose_1 = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_widths: + all_atts->widths = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_bbox: + all_atts->bbox = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_units_per_em: + all_atts->units_per_em = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_stemv: + all_atts->stemv = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_stemh: + all_atts->stemh = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_slope: + all_atts->slope = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_cap_height: + all_atts->cap_height = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_x_height: + all_atts->x_height = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_accent_height: + all_atts->accent_height = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_ascent: + all_atts->ascent = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_descent: + all_atts->descent = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_ideographic: + all_atts->ideographic = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_alphabetic: + all_atts->alphabetic = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_mathematical: + all_atts->mathematical = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_hanging: + all_atts->hanging = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_underline_position: + all_atts->underline_position = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_underline_thickness: + all_atts->underline_thickness = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_strikethrough_position: + all_atts->strikethrough_position = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_strikethrough_thickness: + all_atts->strikethrough_thickness = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_overline_position: + all_atts->overline_position = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_overline_thickness: + all_atts->overline_thickness = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_d: + all_atts->d = (SVG_PathData *)att->data; + break; + case TAG_SVG_ATT_unicode: + all_atts->unicode = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_glyph_name: + all_atts->glyph_name = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_arabic_form: + all_atts->arabic_form = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_lang: + all_atts->lang = (SVG_LanguageIDs *)att->data; + break; + case TAG_SVG_ATT_u1: + all_atts->u1 = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_g1: + all_atts->g1 = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_u2: + all_atts->u2 = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_g2: + all_atts->g2 = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_k: + all_atts->k = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_opacity: + all_atts->opacity = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_x1: + all_atts->x1 = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_y1: + all_atts->y1 = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_x2: + all_atts->x2 = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_y2: + all_atts->y2 = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_gradientUnits: + all_atts->gradientUnits = (SVG_GradientUnit *)att->data; + break; + case TAG_SVG_ATT_filterUnits: + all_atts->focusable = (SVG_GradientUnit *)att->data; + break; + case TAG_SVG_ATT_spreadMethod: + all_atts->spreadMethod = (SVG_SpreadMethod *)att->data; + break; + case TAG_SVG_ATT_gradientTransform: + all_atts->gradientTransform = (SVG_Transform *)att->data; + break; + case TAG_SVG_ATT_pathLength: + all_atts->pathLength = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_points: + all_atts->points = (SVG_Points *)att->data; + break; + case TAG_SVG_ATT_mediaSize: + all_atts->mediaSize = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_mediaTime: + all_atts->mediaTime = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_mediaCharacterEncoding: + all_atts->mediaCharacterEncoding = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_mediaContentEncodings: + all_atts->mediaContentEncodings = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_bandwidth: + all_atts->bandwidth = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_fx: + all_atts->fx = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_fy: + all_atts->fy = (SVG_Coordinate *)att->data; + break; + case TAG_SVG_ATT_size: + all_atts->size = (LASeR_Size *)att->data; + break; + case TAG_SVG_ATT_choice: + all_atts->choice = (LASeR_Choice *)att->data; + break; + case TAG_SVG_ATT_delta: + all_atts->delta = (LASeR_Size *)att->data; + break; + case TAG_SVG_ATT_offset: + all_atts->offset = (SVG_Number *)att->data; + break; + case TAG_SVG_ATT_syncBehaviorDefault: + all_atts->syncBehaviorDefault = (SMIL_SyncBehavior *)att->data; + break; + case TAG_SVG_ATT_syncToleranceDefault: + all_atts->syncToleranceDefault = (SMIL_SyncTolerance *)att->data; + break; + case TAG_SVG_ATT_viewBox: + all_atts->viewBox = (SVG_ViewBox *)att->data; + break; + case TAG_SVG_ATT_zoomAndPan: + all_atts->zoomAndPan = (SVG_ZoomAndPan *)att->data; + break; + case TAG_SVG_ATT_version: + all_atts->version = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_baseProfile: + all_atts->baseProfile = (SVG_String *)att->data; + break; + case TAG_SVG_ATT_contentScriptType: + all_atts->contentScriptType = (SVG_ContentType *)att->data; + break; + case TAG_SVG_ATT_snapshotTime: + all_atts->snapshotTime = (SVG_Clock *)att->data; + break; + case TAG_SVG_ATT_timelineBegin: + all_atts->timelineBegin = (SVG_TimelineBegin *)att->data; + break; + case TAG_SVG_ATT_playbackOrder: + all_atts->playbackOrder = (SVG_PlaybackOrder *)att->data; + break; + case TAG_SVG_ATT_editable: + all_atts->editable = (SVG_Boolean *)att->data; + break; + case TAG_SVG_ATT_text_x: + all_atts->text_x = (SVG_Coordinates *)att->data; + break; + case TAG_SVG_ATT_text_y: + all_atts->text_y = (SVG_Coordinates *)att->data; + break; + case TAG_SVG_ATT_text_rotate: + all_atts->text_rotate = (SVG_Numbers *)att->data; + break; + case TAG_SVG_ATT_transformBehavior: + all_atts->transformBehavior = (SVG_TransformBehavior *)att->data; + break; + case TAG_SVG_ATT_overlay: + all_atts->overlay = (SVG_Overlay *)att->data; + break; + case TAG_SVG_ATT_fullscreen: + all_atts->fullscreen = (SVG_Boolean *)att->data; + break; + case TAG_SVG_ATT_motionTransform: + all_atts->motionTransform = (SVG_Motion *)att->data; + break; + + case TAG_GSVG_ATT_useAsPrimary: + all_atts->gpac_useAsPrimary = (SVG_Boolean *)att->data; + break; + case TAG_GSVG_ATT_depthOffset: + all_atts->gpac_depthOffset = (SVG_Number *)att->data; + break; + case TAG_GSVG_ATT_depthGain: + all_atts->gpac_depthGain = (SVG_Number *)att->data; + break; } - + att = att->next; } } diff --git a/src/scenegraph/svg_smjs.c b/src/scenegraph/svg_smjs.c index 6dd11fe..56c9997 100644 --- a/src/scenegraph/svg_smjs.c +++ b/src/scenegraph/svg_smjs.c @@ -230,26 +230,26 @@ static void svg_define_udom_exception(JSContext *c, JSObject *global) static SMJS_FUNC_PROP_GET( global_getProperty) - GF_SceneGraph *sg; - if (!GF_JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL) ) - return JS_TRUE; +GF_SceneGraph *sg; +if (!GF_JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL) ) + return JS_TRUE; - sg = (GF_SceneGraph *)SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - /*namespaceURI*/ - case 0: - return JS_TRUE; - /*parent*/ - case 1: - *vp = JSVAL_VOID; - if (sg->parent_scene && sg->parent_scene->svg_js) *vp = OBJECT_TO_JSVAL(sg->parent_scene->svg_js->global); - return JS_TRUE; - default: - return JS_TRUE; - } +sg = (GF_SceneGraph *)SMJS_GET_PRIVATE(c, obj); +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + /*namespaceURI*/ + case 0: + return JS_TRUE; + /*parent*/ + case 1: + *vp = JSVAL_VOID; + if (sg->parent_scene && sg->parent_scene->svg_js) *vp = OBJECT_TO_JSVAL(sg->parent_scene->svg_js->global); + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } /*TODO - try to be more precise...*/ @@ -302,184 +302,184 @@ static GF_Node *get_corresponding_use(GF_Node *n) } static SMJS_FUNC_PROP_GET( svg_doc_getProperty) - u32 prop_id; - GF_SceneGraph *sg = dom_get_doc(c, obj); - if (!sg) return JS_TRUE; +u32 prop_id; +GF_SceneGraph *sg = dom_get_doc(c, obj); +if (!sg) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); - switch (prop_id) { - case 0:/*global*/ - *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); - return JS_TRUE; - } +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); +switch (prop_id) { +case 0:/*global*/ + *vp = OBJECT_TO_JSVAL( JS_GetGlobalObject(c) ); return JS_TRUE; } +return JS_TRUE; +} static SMJS_FUNC_PROP_GET(svg_element_getProperty) - u32 prop_id; - GF_JSAPIParam par; - JSString *s; - GF_Node *n = dom_get_element(c, obj); - if (!n) return JS_TRUE; +u32 prop_id; +GF_JSAPIParam par; +JSString *s; +GF_Node *n = dom_get_element(c, obj); +if (!n) return JS_TRUE; - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); - switch (prop_id) { - case 0: /*id*/ - { - const char *node_name = gf_node_get_name((GF_Node*)n); - if (node_name) { - s = JS_NewStringCopyZ(c, node_name); - *vp = STRING_TO_JSVAL( s ); - return JS_TRUE; - } +switch (prop_id) { +case 0: /*id*/ +{ + const char *node_name = gf_node_get_name((GF_Node*)n); + if (node_name) { + s = JS_NewStringCopyZ(c, node_name); + *vp = STRING_TO_JSVAL( s ); return JS_TRUE; } - case 5:/*currentScale*/ - if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_SCALE, (GF_Node *)n, &par)) { - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(par.val) ); - return JS_TRUE; - } - return JS_TRUE; - case 6:/*currentRotate*/ - if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_ROTATION, (GF_Node *)n, &par)) { - *vp = JS_MAKE_DOUBLE(c, FIX2FLT(par.val) ); - return JS_TRUE; - } - return JS_TRUE; - case 7:/*currentTranslate*/ - if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_TRANSLATE, (GF_Node *)n, &par)) { - JSObject *r = JS_NewObject(c, &svg_rt->pointClass._class, 0, 0); - pointCI *rc = (pointCI *)gf_malloc(sizeof(pointCI)); - rc->x = FIX2FLT(par.pt.x); - rc->y = FIX2FLT(par.pt.y); - rc->sg = n->sgprivate->scenegraph; - SMJS_SET_PRIVATE(c, r, rc); - *vp = OBJECT_TO_JSVAL(r); - return JS_TRUE; - } - return JS_TRUE; - case 8:/*viewport*/ - if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_VIEWPORT, (GF_Node *)n, &par)) { - JSObject *r = JS_NewObject(c, &svg_rt->rectClass._class, 0, 0); - rectCI *rc = (rectCI *)gf_malloc(sizeof(rectCI)); - rc->x = FIX2FLT(par.rc.x); - rc->y = FIX2FLT(par.rc.y); - rc->w = FIX2FLT(par.rc.width); - rc->h = FIX2FLT(par.rc.height); - rc->sg = n->sgprivate->scenegraph; - SMJS_SET_PRIVATE(c, r, rc); - *vp = OBJECT_TO_JSVAL(r); - return JS_TRUE; - } + return JS_TRUE; +} +case 5:/*currentScale*/ + if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_SCALE, (GF_Node *)n, &par)) { + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(par.val) ); return JS_TRUE; - case 9:/*currentTime*/ - *vp = JS_MAKE_DOUBLE(c, gf_node_get_scene_time((GF_Node *)n) ); + } + return JS_TRUE; +case 6:/*currentRotate*/ + if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_ROTATION, (GF_Node *)n, &par)) { + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(par.val) ); return JS_TRUE; - case 10:/*isPaused*/ - *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + } + return JS_TRUE; +case 7:/*currentTranslate*/ + if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_TRANSLATE, (GF_Node *)n, &par)) { + JSObject *r = JS_NewObject(c, &svg_rt->pointClass._class, 0, 0); + pointCI *rc = (pointCI *)gf_malloc(sizeof(pointCI)); + rc->x = FIX2FLT(par.pt.x); + rc->y = FIX2FLT(par.pt.y); + rc->sg = n->sgprivate->scenegraph; + SMJS_SET_PRIVATE(c, r, rc); + *vp = OBJECT_TO_JSVAL(r); return JS_TRUE; - case 11:/*ownerSVGElement*/ - while (1) { - GF_Node *par = gf_node_get_parent(n, 0); - if (!par) return JS_TRUE; - if (par->sgprivate->tag==TAG_SVG_svg) { - *vp = dom_element_construct(c, par); - return JS_TRUE; - } - n = par; - } + } + return JS_TRUE; +case 8:/*viewport*/ + if (n->sgprivate->tag!=TAG_SVG_svg) return JS_TRUE; + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_GET_VIEWPORT, (GF_Node *)n, &par)) { + JSObject *r = JS_NewObject(c, &svg_rt->rectClass._class, 0, 0); + rectCI *rc = (rectCI *)gf_malloc(sizeof(rectCI)); + rc->x = FIX2FLT(par.rc.x); + rc->y = FIX2FLT(par.rc.y); + rc->w = FIX2FLT(par.rc.width); + rc->h = FIX2FLT(par.rc.height); + rc->sg = n->sgprivate->scenegraph; + SMJS_SET_PRIVATE(c, r, rc); + *vp = OBJECT_TO_JSVAL(r); return JS_TRUE; - case 12:/*correspondingElement*/ - /*if we can find a corresponding element for this node, then this is an SVGElementInstance*/ - if (get_corresponding_use(n)) { - *vp = dom_element_construct(c, n); - } else { - *vp = dom_element_construct(c, NULL); + } + return JS_TRUE; +case 9:/*currentTime*/ + *vp = JS_MAKE_DOUBLE(c, gf_node_get_scene_time((GF_Node *)n) ); + return JS_TRUE; +case 10:/*isPaused*/ + *vp = BOOLEAN_TO_JSVAL(JS_FALSE); + return JS_TRUE; +case 11:/*ownerSVGElement*/ + while (1) { + GF_Node *par = gf_node_get_parent(n, 0); + if (!par) return JS_TRUE; + if (par->sgprivate->tag==TAG_SVG_svg) { + *vp = dom_element_construct(c, par); + return JS_TRUE; } - return JS_TRUE; - case 13:/*correspondingUseElement*/ - *vp = dom_element_construct(c, get_corresponding_use(n)); - return JS_TRUE; - default: - return JS_TRUE; + n = par; + } + return JS_TRUE; +case 12:/*correspondingElement*/ + /*if we can find a corresponding element for this node, then this is an SVGElementInstance*/ + if (get_corresponding_use(n)) { + *vp = dom_element_construct(c, n); + } else { + *vp = dom_element_construct(c, NULL); } return JS_TRUE; +case 13:/*correspondingUseElement*/ + *vp = dom_element_construct(c, get_corresponding_use(n)); + return JS_TRUE; +default: + return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( svg_element_setProperty) - GF_JSAPIParam par; - jsdouble d; - u32 prop_id; - GF_Node *n = dom_get_element(c, obj); - if (!n) return JS_TRUE; - - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - prop_id = SMJS_ID_TO_INT(id); - - switch (prop_id) { - case 0:/*id*/ - if (JSVAL_CHECK_STRING(*vp)) { - char *id = SMJS_CHARS(c, *vp); - if (id) { - GF_FieldInfo info; - u32 nid = gf_node_get_id(n); - if (!nid) nid = gf_sg_get_next_available_node_id(n->sgprivate->scenegraph); - gf_node_set_id(n, nid, id); - if (gf_node_get_attribute_by_tag(n, TAG_XML_ATT_id, GF_TRUE, GF_FALSE, &info)==GF_OK) { - if (*(DOM_String *)info.far_ptr) gf_free(*(DOM_String *)info.far_ptr); - *(DOM_String *)info.far_ptr = gf_strdup(id); - } - if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_id, GF_TRUE, GF_FALSE, &info)==GF_OK) { - if (*(DOM_String *)info.far_ptr) gf_free(*(DOM_String *)info.far_ptr); - *(DOM_String *)info.far_ptr = gf_strdup(id); - } - SMJS_FREE(c, id); +GF_JSAPIParam par; +jsdouble d; +u32 prop_id; +GF_Node *n = dom_get_element(c, obj); +if (!n) return JS_TRUE; + +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +prop_id = SMJS_ID_TO_INT(id); + +switch (prop_id) { +case 0:/*id*/ + if (JSVAL_CHECK_STRING(*vp)) { + char *id = SMJS_CHARS(c, *vp); + if (id) { + GF_FieldInfo info; + u32 nid = gf_node_get_id(n); + if (!nid) nid = gf_sg_get_next_available_node_id(n->sgprivate->scenegraph); + gf_node_set_id(n, nid, id); + if (gf_node_get_attribute_by_tag(n, TAG_XML_ATT_id, GF_TRUE, GF_FALSE, &info)==GF_OK) { + if (*(DOM_String *)info.far_ptr) gf_free(*(DOM_String *)info.far_ptr); + *(DOM_String *)info.far_ptr = gf_strdup(id); } + if (gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_id, GF_TRUE, GF_FALSE, &info)==GF_OK) { + if (*(DOM_String *)info.far_ptr) gf_free(*(DOM_String *)info.far_ptr); + *(DOM_String *)info.far_ptr = gf_strdup(id); + } + SMJS_FREE(c, id); } - return JS_TRUE; + } + return JS_TRUE; /*currentScale*/ - case 5: - if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; - JS_ValueToNumber(c, *vp, &d); - par.val = FLT2FIX(d); - if (!par.val) { - return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); - } - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_SCALE, (GF_Node *)n, &par)) { - return JS_TRUE; - } +case 5: + if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; + JS_ValueToNumber(c, *vp, &d); + par.val = FLT2FIX(d); + if (!par.val) { + return dom_throw_exception(c, GF_DOM_EXC_INVALID_ACCESS_ERR); + } + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_SCALE, (GF_Node *)n, &par)) { return JS_TRUE; + } + return JS_TRUE; /*currentRotate*/ - case 6: - if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; - JS_ValueToNumber(c, *vp, &d); - par.val = FLT2FIX(d); - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_ROTATION, (GF_Node *)n, &par)) { - return JS_TRUE; - } +case 6: + if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; + JS_ValueToNumber(c, *vp, &d); + par.val = FLT2FIX(d); + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_ROTATION, (GF_Node *)n, &par)) { return JS_TRUE; + } + return JS_TRUE; /*currentTime*/ - case 9: - if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; - JS_ValueToNumber(c, *vp, &d); - par.time = d; - if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_TIME, (GF_Node *)n, &par)) { - return JS_TRUE; - } - return JS_TRUE; - default: +case 9: + if (!JSVAL_IS_NUMBER(*vp) || (n->sgprivate->tag!=TAG_SVG_svg)) return JS_TRUE; + JS_ValueToNumber(c, *vp, &d); + par.time = d; + if (ScriptAction(n->sgprivate->scenegraph, GF_JSAPI_OP_SET_TIME, (GF_Node *)n, &par)) { return JS_TRUE; } return JS_TRUE; +default: + return JS_TRUE; +} +return JS_TRUE; } @@ -700,7 +700,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) /*Number*/ case SVG_Number_datatype: -/*all string traits*/ + /*all string traits*/ case SVG_Boolean_datatype: case SVG_FillRule_datatype: case SVG_StrokeLineJoin_datatype: @@ -734,8 +734,8 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) case SVG_VectorEffect_datatype: case SVG_PlaybackOrder_datatype: case SVG_TimelineBegin_datatype: -/*end of string traits*/ -/*DOM string traits*/ + /*end of string traits*/ + /*DOM string traits*/ case SVG_FontFamily_datatype: case XMLRI_datatype: case DOM_String_datatype: @@ -744,7 +744,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) case SVG_Focus_datatype: case SVG_ID_datatype: case SVG_GradientOffset_datatype: -/*end of DOM string traits*/ + /*end of DOM string traits*/ attValue = gf_svg_dump_attribute(n, &info); SMJS_SET_RVAL( STRING_TO_JSVAL( JS_NewStringCopyZ(c, attValue) ) ); if (attValue) gf_free(attValue); @@ -753,7 +753,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) break; #if 0 -/*SVGT 1.2 default traits*/ + /*SVGT 1.2 default traits*/ case SMIL_KeyTimes_datatype: case SMIL_KeyPoints_datatype: case SMIL_KeySplines_datatype: @@ -761,9 +761,9 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) case SVG_StrokeDashArray_datatype: case SVG_Points_datatype: case SVG_Motion_datatype: -/*end SVGT 1.2 default traits*/ + /*end SVGT 1.2 default traits*/ -/*unimplemented/unnkown/FIXME traits*/ + /*unimplemented/unnkown/FIXME traits*/ case SMIL_SyncTolerance_datatype: case SVG_TransformType_datatype: case SVG_TransformList_datatype: @@ -774,7 +774,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_trait) case SMIL_Duration_datatype: case SMIL_RepeatCount_datatype: default: -/*end unimplemented/unnkown/FIXME traits*/ + /*end unimplemented/unnkown/FIXME traits*/ return JS_TRUE; #endif } @@ -947,7 +947,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rgb_color_trait) SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) ); return JS_TRUE; } - break; + break; case SVG_Paint_datatype: { SVG_Paint *paint = (SVG_Paint *)info.far_ptr; @@ -1167,7 +1167,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_path_trait) if (!GF_JS_InstanceOf(c, pO, &svg_rt->pathClass, NULL) ) return JS_TRUE; path = SMJS_GET_PRIVATE(c, pO); if (!path) return JS_TRUE; - + szName = SMJS_CHARS(c, argv[0]); e = gf_node_get_field_by_name(n, szName, &info); SMJS_FREE(c, szName); @@ -1196,9 +1196,15 @@ JSBool SMJS_FUNCTION(svg_udom_set_path_trait) gf_list_add(d->commands, t); switch (*t) { case 0: - case 1: nb_pts++; break; - case 2: nb_pts+=3; break; - case 4: nb_pts+=2; break; + case 1: + nb_pts++; + break; + case 2: + nb_pts+=3; + break; + case 4: + nb_pts+=2; + break; } } for (i=0; irgbClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - rgbCI *col = (rgbCI *)SMJS_GET_PRIVATE(c, obj); - if (!col) return JS_TRUE; - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = INT_TO_JSVAL(col->r); return JS_TRUE; - case 1: *vp = INT_TO_JSVAL(col->g); return JS_TRUE; - case 2: *vp = INT_TO_JSVAL(col->b); return JS_TRUE; - default: - return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + rgbCI *col = (rgbCI *)SMJS_GET_PRIVATE(c, obj); + if (!col) return JS_TRUE; + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = INT_TO_JSVAL(col->r); + return JS_TRUE; + case 1: + *vp = INT_TO_JSVAL(col->g); + return JS_TRUE; + case 2: + *vp = INT_TO_JSVAL(col->b); + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( rgb_setProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - rgbCI *col = (rgbCI *)SMJS_GET_PRIVATE(c, obj); - if (!col) return JS_TRUE; - switch (SMJS_ID_TO_INT(id)) { - case 0: col->r = JSVAL_TO_INT(*vp); return JS_TRUE; - case 1: col->g = JSVAL_TO_INT(*vp); return JS_TRUE; - case 2: col->b = JSVAL_TO_INT(*vp); return JS_TRUE; - default: return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + rgbCI *col = (rgbCI *)SMJS_GET_PRIVATE(c, obj); + if (!col) return JS_TRUE; + switch (SMJS_ID_TO_INT(id)) { + case 0: + col->r = JSVAL_TO_INT(*vp); + return JS_TRUE; + case 1: + col->g = JSVAL_TO_INT(*vp); + return JS_TRUE; + case 2: + col->b = JSVAL_TO_INT(*vp); + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET(rect_getProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - rectCI *rc = (rectCI *)SMJS_GET_PRIVATE(c, obj); - if (!rc) return JS_TRUE; - if (rc->sg) { - GF_JSAPIParam par; - ScriptAction(rc->sg, GF_JSAPI_OP_GET_VIEWPORT, rc->sg->RootNode, &par); - rc->x = FIX2FLT(par.rc.x); - rc->y = FIX2FLT(par.rc.y); - rc->w = FIX2FLT(par.rc.width); - rc->h = FIX2FLT(par.rc.height); - } - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, rc->x); return JS_TRUE; - case 1: *vp = JS_MAKE_DOUBLE(c, rc->y); return JS_TRUE; - case 2: *vp = JS_MAKE_DOUBLE(c, rc->w); return JS_TRUE; - case 3: *vp = JS_MAKE_DOUBLE(c, rc->h); return JS_TRUE; - default: return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + rectCI *rc = (rectCI *)SMJS_GET_PRIVATE(c, obj); + if (!rc) return JS_TRUE; + if (rc->sg) { + GF_JSAPIParam par; + ScriptAction(rc->sg, GF_JSAPI_OP_GET_VIEWPORT, rc->sg->RootNode, &par); + rc->x = FIX2FLT(par.rc.x); + rc->y = FIX2FLT(par.rc.y); + rc->w = FIX2FLT(par.rc.width); + rc->h = FIX2FLT(par.rc.height); + } + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, rc->x); + return JS_TRUE; + case 1: + *vp = JS_MAKE_DOUBLE(c, rc->y); + return JS_TRUE; + case 2: + *vp = JS_MAKE_DOUBLE(c, rc->w); + return JS_TRUE; + case 3: + *vp = JS_MAKE_DOUBLE(c, rc->h); + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( rect_setProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - jsdouble d; - rectCI *rc = (rectCI *)SMJS_GET_PRIVATE(c, obj); - if (!rc) return JS_TRUE; - JS_ValueToNumber(c, *vp, &d); - switch (SMJS_ID_TO_INT(id)) { - case 0: rc->x = (Float) d; return JS_TRUE; - case 1: rc->y = (Float) d; return JS_TRUE; - case 2: rc->w = (Float) d; return JS_TRUE; - case 3: rc->h = (Float) d; return JS_TRUE; - default: return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + jsdouble d; + rectCI *rc = (rectCI *)SMJS_GET_PRIVATE(c, obj); + if (!rc) return JS_TRUE; + JS_ValueToNumber(c, *vp, &d); + switch (SMJS_ID_TO_INT(id)) { + case 0: + rc->x = (Float) d; + return JS_TRUE; + case 1: + rc->y = (Float) d; + return JS_TRUE; + case 2: + rc->w = (Float) d; + return JS_TRUE; + case 3: + rc->h = (Float) d; + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET( point_getProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - pointCI *pt = (pointCI *)SMJS_GET_PRIVATE(c, obj); - if (!pt) return JS_TRUE; - if (pt->sg) { - GF_JSAPIParam par; - ScriptAction(pt->sg, GF_JSAPI_OP_GET_TRANSLATE, pt->sg->RootNode, &par); - pt->x = FIX2FLT(par.pt.x); - pt->y = FIX2FLT(par.pt.y); - } - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, pt->x); return JS_TRUE; - case 1: *vp = JS_MAKE_DOUBLE(c, pt->y); return JS_TRUE; - default: return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + pointCI *pt = (pointCI *)SMJS_GET_PRIVATE(c, obj); + if (!pt) return JS_TRUE; + if (pt->sg) { + GF_JSAPIParam par; + ScriptAction(pt->sg, GF_JSAPI_OP_GET_TRANSLATE, pt->sg->RootNode, &par); + pt->x = FIX2FLT(par.pt.x); + pt->y = FIX2FLT(par.pt.y); } - return JS_TRUE; + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, pt->x); + return JS_TRUE; + case 1: + *vp = JS_MAKE_DOUBLE(c, pt->y); + return JS_TRUE; + default: + return JS_TRUE; + } +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( point_setProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - jsdouble d; - pointCI *pt = (pointCI *)SMJS_GET_PRIVATE(c, obj); - if (!pt) return JS_TRUE; - JS_ValueToNumber(c, *vp, &d); - switch (SMJS_ID_TO_INT(id)) { - case 0: pt->x = (Float) d; break; - case 1: pt->y = (Float) d; break; - default: return JS_TRUE; - } - if (pt->sg) { - GF_JSAPIParam par; - par.pt.x = FLT2FIX(pt->x); - par.pt.y = FLT2FIX(pt->y); - ScriptAction(pt->sg, GF_JSAPI_OP_SET_TRANSLATE, pt->sg->RootNode, &par); - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + jsdouble d; + pointCI *pt = (pointCI *)SMJS_GET_PRIVATE(c, obj); + if (!pt) return JS_TRUE; + JS_ValueToNumber(c, *vp, &d); + switch (SMJS_ID_TO_INT(id)) { + case 0: + pt->x = (Float) d; + break; + case 1: + pt->y = (Float) d; + break; + default: return JS_TRUE; } + if (pt->sg) { + GF_JSAPIParam par; + par.pt.x = FLT2FIX(pt->x); + par.pt.y = FLT2FIX(pt->y); + ScriptAction(pt->sg, GF_JSAPI_OP_SET_TRANSLATE, pt->sg->RootNode, &par); + } return JS_TRUE; } +return JS_TRUE; +} static JSObject *svg_new_path_object(JSContext *c, SVG_PathData *d) { @@ -1721,16 +1768,19 @@ static void pathCI_finalize(JSContext *c, JSObject *obj) static SMJS_FUNC_PROP_GET( path_getProperty) - if (!GF_JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - if (SMJS_ID_IS_INT(id)) { - pathCI *p = (pathCI *)SMJS_GET_PRIVATE(c, obj); - if (!p) return JS_TRUE; - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = INT_TO_JSVAL(p->nb_coms); return JS_TRUE; - default: return JS_TRUE; - } +if (!GF_JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; +if (SMJS_ID_IS_INT(id)) { + pathCI *p = (pathCI *)SMJS_GET_PRIVATE(c, obj); + if (!p) return JS_TRUE; + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = INT_TO_JSVAL(p->nb_coms); + return JS_TRUE; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static JSBool SMJS_FUNCTION(svg_path_get_segment) { @@ -1745,15 +1795,23 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment) idx = JSVAL_TO_INT(argv[0]); if (idx>=p->nb_coms) return JS_TRUE; switch (p->tags[idx]) { - case 0: SMJS_SET_RVAL( INT_TO_JSVAL(77)); return JS_TRUE; /* Move To */ - case 1: SMJS_SET_RVAL( INT_TO_JSVAL(76)); return JS_TRUE; /* Line To */ + case 0: + SMJS_SET_RVAL( INT_TO_JSVAL(77)); + return JS_TRUE; /* Move To */ + case 1: + SMJS_SET_RVAL( INT_TO_JSVAL(76)); + return JS_TRUE; /* Line To */ case 2:/* Curve To */ case 3:/* next Curve To */ - SMJS_SET_RVAL( INT_TO_JSVAL(67)); return JS_TRUE; + SMJS_SET_RVAL( INT_TO_JSVAL(67)); + return JS_TRUE; case 4:/* Quad To */ case 5:/* next Quad To */ - SMJS_SET_RVAL( INT_TO_JSVAL(81)); return JS_TRUE; - case 6: SMJS_SET_RVAL( INT_TO_JSVAL(90)); return JS_TRUE; /* Close */ + SMJS_SET_RVAL( INT_TO_JSVAL(81)); + return JS_TRUE; + case 6: + SMJS_SET_RVAL( INT_TO_JSVAL(90)); + return JS_TRUE; /* Close */ } return JS_TRUE; } @@ -1775,12 +1833,24 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment_param) pt_idx = 0; for (i=0; itags[i]) { - case 0: pt_idx++; break; - case 1: pt_idx++; break; - case 2: pt_idx+=3; break; - case 3: pt_idx+=2; break; - case 4: pt_idx+=2; break; - case 5: pt_idx+=1; break; + case 0: + pt_idx++; + break; + case 1: + pt_idx++; + break; + case 2: + pt_idx+=3; + break; + case 3: + pt_idx+=2; + break; + case 4: + pt_idx+=2; + break; + case 5: + pt_idx+=1; + break; } } switch (p->tags[idx]) { @@ -1822,7 +1892,7 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment_param) SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, param_idx ? pt->y : pt->x)); } return JS_TRUE; - /*spec is quite obscur here*/ + /*spec is quite obscur here*/ case 6: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, 0)); return JS_TRUE; @@ -1836,12 +1906,24 @@ static u32 svg_path_realloc_pts(pathCI *p, u32 nb_pts) orig_pts = 0; for (i=0; inb_coms; i++) { switch (p->tags[i]) { - case 0: orig_pts++; break; - case 1: orig_pts++; break; - case 2: orig_pts+=3; break; - case 3: orig_pts+=2; break; - case 4: orig_pts+=2; break; - case 5: orig_pts+=1; break; + case 0: + orig_pts++; + break; + case 1: + orig_pts++; + break; + case 2: + orig_pts+=3; + break; + case 3: + orig_pts+=2; + break; + case 4: + orig_pts+=2; + break; + case 5: + orig_pts+=1; + break; } } p->pts = (ptCI *)gf_realloc(p->pts, sizeof(ptCI)*(nb_pts+orig_pts)); @@ -1906,8 +1988,10 @@ static JSBool SMJS_FUNCTION(svg_path_quad_to) JS_ValueToNumber(c, argv[2], &x2); JS_ValueToNumber(c, argv[3], &y2); nb_pts = svg_path_realloc_pts(p, 2); - p->pts[nb_pts].x = (Float) x1; p->pts[nb_pts].y = (Float) y1; - p->pts[nb_pts+1].x = (Float) x2; p->pts[nb_pts+1].y = (Float) y2; + p->pts[nb_pts].x = (Float) x1; + p->pts[nb_pts].y = (Float) y1; + p->pts[nb_pts+1].x = (Float) x2; + p->pts[nb_pts+1].y = (Float) y2; p->tags = (u8 *)gf_realloc(p->tags, sizeof(u8)*(p->nb_coms+1) ); p->tags[p->nb_coms] = 4; p->nb_coms++; @@ -1931,9 +2015,12 @@ static JSBool SMJS_FUNCTION(svg_path_curve_to) JS_ValueToNumber(c, argv[4], &x); JS_ValueToNumber(c, argv[5], &y); nb_pts = svg_path_realloc_pts(p, 3); - p->pts[nb_pts].x = (Float) x1; p->pts[nb_pts].y = (Float) y1; - p->pts[nb_pts+1].x = (Float) x2; p->pts[nb_pts+1].y = (Float) y2; - p->pts[nb_pts+2].x = (Float) x; p->pts[nb_pts+2].y = (Float) y; + p->pts[nb_pts].x = (Float) x1; + p->pts[nb_pts].y = (Float) y1; + p->pts[nb_pts+1].x = (Float) x2; + p->pts[nb_pts+1].y = (Float) y2; + p->pts[nb_pts+2].x = (Float) x; + p->pts[nb_pts+2].y = (Float) y; p->tags = (u8 *)gf_realloc(p->tags, sizeof(u8)*(p->nb_coms+1) ); p->tags[p->nb_coms] = 2; p->nb_coms++; @@ -1955,42 +2042,68 @@ static JSBool SMJS_FUNCTION(svg_path_close) static SMJS_FUNC_PROP_GET( matrix_getProperty) - GF_Matrix2D *mx; - if (!GF_JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = (GF_Matrix2D *)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; +GF_Matrix2D *mx; +if (!GF_JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; +mx = (GF_Matrix2D *)SMJS_GET_PRIVATE(c, obj); +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - if (!mx) return JS_TRUE; - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[0])); return JS_TRUE; - case 1: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[3])); return JS_TRUE; - case 2: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[1])); return JS_TRUE; - case 3: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[4])); return JS_TRUE; - case 4: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[2])); return JS_TRUE; - case 5: *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[5])); return JS_TRUE; - default: return JS_TRUE; - } +if (!mx) return JS_TRUE; +switch (SMJS_ID_TO_INT(id)) { +case 0: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[0])); + return JS_TRUE; +case 1: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[3])); + return JS_TRUE; +case 2: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[1])); + return JS_TRUE; +case 3: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[4])); + return JS_TRUE; +case 4: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[2])); + return JS_TRUE; +case 5: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[5])); + return JS_TRUE; +default: return JS_TRUE; } +return JS_TRUE; +} static SMJS_FUNC_PROP_SET( matrix_setProperty) - jsdouble d; - GF_Matrix2D *mx; - if (!GF_JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = (GF_Matrix2D *)SMJS_GET_PRIVATE(c, obj); - if (!SMJS_ID_IS_INT(id)) return JS_TRUE; - - JS_ValueToNumber(c, *vp, &d); - switch (SMJS_ID_TO_INT(id)) { - case 0: mx->m[0] = FLT2FIX(d); break; - case 1: mx->m[3] = FLT2FIX(d); break; - case 2: mx->m[1] = FLT2FIX(d); break; - case 3: mx->m[4] = FLT2FIX(d); break; - case 4: mx->m[2] = FLT2FIX(d); break; - case 5: mx->m[5] = FLT2FIX(d); break; - default: return JS_TRUE; - } - return JS_TRUE; +jsdouble d; +GF_Matrix2D *mx; +if (!GF_JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; +mx = (GF_Matrix2D *)SMJS_GET_PRIVATE(c, obj); +if (!SMJS_ID_IS_INT(id)) return JS_TRUE; + +JS_ValueToNumber(c, *vp, &d); +switch (SMJS_ID_TO_INT(id)) { +case 0: + mx->m[0] = FLT2FIX(d); + break; +case 1: + mx->m[3] = FLT2FIX(d); + break; +case 2: + mx->m[1] = FLT2FIX(d); + break; +case 3: + mx->m[4] = FLT2FIX(d); + break; +case 4: + mx->m[2] = FLT2FIX(d); + break; +case 5: + mx->m[5] = FLT2FIX(d); + break; +default: + return JS_TRUE; +} +return JS_TRUE; } static JSBool SMJS_FUNCTION(svg_mx2d_get_component) { @@ -2002,12 +2115,24 @@ static JSBool SMJS_FUNCTION(svg_mx2d_get_component) if (!mx || (argc!=1)) return JS_TRUE; if (!JSVAL_IS_INT(argv[0])) return JS_TRUE; switch (JSVAL_TO_INT(argv[0])) { - case 0: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[0]))); return JS_TRUE; - case 1: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[3]))); return JS_TRUE; - case 2: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[1]))); return JS_TRUE; - case 3: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[4]))); return JS_TRUE; - case 4: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[2]))); return JS_TRUE; - case 5: SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[5]))); return JS_TRUE; + case 0: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[0]))); + return JS_TRUE; + case 1: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[3]))); + return JS_TRUE; + case 2: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[1]))); + return JS_TRUE; + case 3: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[4]))); + return JS_TRUE; + case 4: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[2]))); + return JS_TRUE; + case 5: + SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(mx->m[5]))); + return JS_TRUE; } return JS_TRUE; } @@ -2127,11 +2252,11 @@ void *svg_get_element_class(GF_Node *n) { if (!n) return NULL; if ((n->sgprivate->tag>=GF_NODE_RANGE_FIRST_SVG) && (n->sgprivate->tag<=GF_NODE_RANGE_LAST_SVG)) { - if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { - return html_get_element_class(n); - } + if (n->sgprivate->tag == TAG_SVG_video || n->sgprivate->tag == TAG_SVG_audio) { + return html_get_element_class(n); + } return &svg_rt->svgElement; - } + } return NULL; } void *svg_get_document_class(GF_SceneGraph *sg) @@ -2507,8 +2632,8 @@ GF_Err JSScript_CreateSVGContext(GF_SceneGraph *sg) /*load SVG & DOM APIs*/ svg_init_js_api(sg); - /* HTML */ - html_media_init_js_api(sg); + /* HTML */ + html_media_init_js_api(sg); svg_js->script_execute = svg_script_execute; svg_js->handler_execute = svg_script_execute_handler; @@ -2577,7 +2702,7 @@ static Bool svg_js_load_script(GF_Node *script, char *file) } gf_sg_lock_javascript(svg_js->js_ctx, GF_TRUE); - + ret = JS_EvaluateScript(svg_js->js_ctx, svg_js->global, jsscript, sizeof(char)*fsize, file, 0, &rval); if (svg_js->force_gc) { @@ -2691,7 +2816,7 @@ void dump_root(const char *name, void *rp, void *data) - text, outside of a node, obtained by some external means (XHR, ...) - utf8_script - already in the JS engine, in the form of: - an anonymous function (js_fun_val) - - a named function (js_fun) + - a named function (js_fun) */ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_Node *observer, char *utf8_script) { @@ -2719,7 +2844,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No svg_js = node->sgprivate->scenegraph->svg_js; #ifndef GPAC_DISABLE_LOG - if (gf_log_tool_level_on(GF_LOG_SCRIPT, GF_LOG_DEBUG)) { + if (gf_log_tool_level_on(GF_LOG_SCRIPT, GF_LOG_DEBUG)) { char *content, *_content = NULL; if (utf8_script) { content = utf8_script; @@ -2734,7 +2859,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No } else { content = "unknown"; } - gf_log_lt(GF_LOG_DEBUG, GF_LOG_SCRIPT); + gf_log_lt(GF_LOG_DEBUG, GF_LOG_SCRIPT); gf_log("[DOM Events ] Executing script code from handler: %s\n", content); SMJS_FREE(svg_js->js_ctx, _content); } @@ -2762,7 +2887,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No if (utf8_script) { ret = JS_EvaluateScript(svg_js->js_ctx, __this, utf8_script, (u32) strlen(utf8_script), 0, 0, &rval); - } + } else if (hdl->js_fun || hdl->js_fun_val || hdl->evt_listen_obj) { JSObject *evt; jsval argv[1]; diff --git a/src/scenegraph/svg_types.c b/src/scenegraph/svg_types.c index dd3ed0d..421369f 100644 --- a/src/scenegraph/svg_types.c +++ b/src/scenegraph/svg_types.c @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -31,22 +31,22 @@ Bool gf_svg_is_animation_tag(u32 tag) { return (tag == TAG_SVG_set || - tag == TAG_SVG_animate || - tag == TAG_SVG_animateColor || - tag == TAG_SVG_animateTransform || - tag == TAG_SVG_animateMotion || - tag == TAG_SVG_discard - ) ? 1 : 0; + tag == TAG_SVG_animate || + tag == TAG_SVG_animateColor || + tag == TAG_SVG_animateTransform || + tag == TAG_SVG_animateMotion || + tag == TAG_SVG_discard + ) ? 1 : 0; } Bool gf_svg_is_timing_tag(u32 tag) { if (gf_svg_is_animation_tag(tag)) return 1; else return (tag == TAG_SVG_animation || - tag == TAG_SVG_audio || - tag == TAG_LSR_conditional || - tag == TAG_LSR_updates || - tag == TAG_SVG_video)?1:0; + tag == TAG_SVG_audio || + tag == TAG_LSR_conditional || + tag == TAG_LSR_updates || + tag == TAG_SVG_video)?1:0; } SVG_Element *gf_svg_create_node(u32 ElementTag) @@ -54,11 +54,11 @@ SVG_Element *gf_svg_create_node(u32 ElementTag) SVG_Element *p; if (gf_svg_is_timing_tag(ElementTag)) { SVGTimedAnimBaseElement *tap; - GF_SAFEALLOC(tap, SVGTimedAnimBaseElement); + GF_SAFEALLOC(tap, SVGTimedAnimBaseElement); p = (SVG_Element *)tap; } else if (ElementTag == TAG_SVG_handler) { SVG_handlerElement *hdl; - GF_SAFEALLOC(hdl, SVG_handlerElement); + GF_SAFEALLOC(hdl, SVG_handlerElement); p = (SVG_Element *)hdl; } else { GF_SAFEALLOC(p, SVG_Element); @@ -79,7 +79,7 @@ void gf_svg_node_del(GF_Node *node) /*remove from target's listener list*/ gf_dom_event_remove_listener_from_parent((GF_DOMEventTarget *)node->sgprivate->UserPrivate, (GF_Node *)p); } - /*if this is a handler with a UserPrivate, this is a handler with an implicit listener + /*if this is a handler with a UserPrivate, this is a handler with an implicit listener (eg handler with ev:event=""). Destroy the associated listener*/ if (p->sgprivate->tag==TAG_SVG_handler) { GF_Node *listener = p->sgprivate->UserPrivate; @@ -115,7 +115,7 @@ void gf_svg_node_del(GF_Node *node) if (tap->timingp) { gf_smil_timing_delete_runtime_info((GF_Node *)tap, tap->timingp->runtime); gf_free(tap->timingp); - } + } if (tap->xlinkp) gf_free(tap->xlinkp); } @@ -128,12 +128,12 @@ Bool gf_svg_node_init(GF_Node *node) { switch (node->sgprivate->tag) { case TAG_SVG_script: - if (node->sgprivate->scenegraph->script_load) + if (node->sgprivate->scenegraph->script_load) node->sgprivate->scenegraph->script_load(node); return 1; case TAG_SVG_handler: - if (node->sgprivate->scenegraph->script_load) + if (node->sgprivate->scenegraph->script_load) node->sgprivate->scenegraph->script_load(node); if (node->sgprivate->scenegraph->script_action) ((SVG_handlerElement*)node)->handle_event = gf_sg_handle_dom_event; @@ -143,17 +143,17 @@ Bool gf_svg_node_init(GF_Node *node) gf_smil_setup_events(node); return 1; case TAG_SVG_animateMotion: - case TAG_SVG_set: - case TAG_SVG_animate: - case TAG_SVG_animateColor: - case TAG_SVG_animateTransform: + case TAG_SVG_set: + case TAG_SVG_animate: + case TAG_SVG_animateColor: + case TAG_SVG_animateTransform: gf_smil_anim_init_node(node); gf_smil_setup_events(node); /*we may get called several times depending on xlink:href resoling for events*/ return (node->sgprivate->UserPrivate || node->sgprivate->UserCallback) ? 1 : 0; - case TAG_SVG_audio: - case TAG_SVG_video: - case TAG_LSR_updates: + case TAG_SVG_audio: + case TAG_SVG_video: + case TAG_LSR_updates: gf_smil_timing_init_runtime_info(node); gf_smil_setup_events(node); /*we may get called several times depending on xlink:href resoling for events*/ @@ -163,7 +163,7 @@ Bool gf_svg_node_init(GF_Node *node) gf_smil_setup_events(node); return 0; /*discard is implemented as a special animation element */ - case TAG_SVG_discard: + case TAG_SVG_discard: gf_smil_anim_init_discard(node); gf_smil_setup_events(node); return 1; @@ -177,18 +177,18 @@ Bool gf_svg_node_changed(GF_Node *node, GF_FieldInfo *field) { switch (node->sgprivate->tag) { case TAG_SVG_animateMotion: - case TAG_SVG_discard: - case TAG_SVG_set: - case TAG_SVG_animate: - case TAG_SVG_animateColor: - case TAG_SVG_animateTransform: - case TAG_LSR_conditional: + case TAG_SVG_discard: + case TAG_SVG_set: + case TAG_SVG_animate: + case TAG_SVG_animateColor: + case TAG_SVG_animateTransform: + case TAG_LSR_conditional: gf_smil_timing_modified(node, field); return 1; - case TAG_SVG_animation: - case TAG_SVG_audio: - case TAG_SVG_video: - case TAG_LSR_updates: + case TAG_SVG_animation: + case TAG_SVG_audio: + case TAG_SVG_video: + case TAG_LSR_updates: gf_smil_timing_modified(node, field); /*used by compositors*/ return 0; @@ -197,7 +197,7 @@ Bool gf_svg_node_changed(GF_Node *node, GF_FieldInfo *field) } -void gf_svg_reset_path(SVG_PathData d) +void gf_svg_reset_path(SVG_PathData d) { #if USE_GF_PATH gf_path_reset(&d); @@ -218,7 +218,7 @@ void gf_svg_reset_path(SVG_PathData d) #endif } -/* TODO: update for elliptical arcs */ +/* TODO: update for elliptical arcs */ GF_EXPORT void gf_svg_path_build(GF_Path *path, GF_List *commands, GF_List *points) { @@ -236,7 +236,7 @@ void gf_svg_path_build(GF_Path *path, GF_List *commands, GF_List *points) gf_path_add_move_to(path, orig.x, orig.y); j++; /*provision for nextCurveTo when no curve is specified: - "If there is no previous command or if the previous command was not an C, c, S or s, + "If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point. */ ct_orig = orig; @@ -280,7 +280,7 @@ void gf_svg_path_build(GF_Path *path, GF_List *commands, GF_List *points) ct_orig = *tmp; tmp = (SVG_Point*)gf_list_get(points, j+1); end = *tmp; - gf_path_add_quadratic_to(path, ct_orig.x, ct_orig.y, end.x, end.y); + gf_path_add_quadratic_to(path, ct_orig.x, ct_orig.y, end.x, end.y); orig = end; j+=2; break; @@ -290,14 +290,14 @@ void gf_svg_path_build(GF_Path *path, GF_List *commands, GF_List *points) tmp = (SVG_Point*)gf_list_get(points, j); end = *tmp; gf_path_add_quadratic_to(path, ct_orig.x, ct_orig.y, end.x, end.y); - orig = end; - j++; + orig = end; + j++; break; case SVG_PATHCOMMAND_Z: /* Close */ gf_path_close(path); break; } - } + } } @@ -333,14 +333,14 @@ void gf_svg_delete_coordinates(GF_List *list) gf_list_del(list); } -void gf_svg_reset_iri(GF_SceneGraph *sg, XMLRI *iri) +void gf_svg_reset_iri(GF_SceneGraph *sg, XMLRI *iri) { if (!iri) return; if (iri->string) gf_free(iri->string); gf_node_unregister_iri(sg, iri); } -void gf_svg_delete_paint(GF_SceneGraph *sg, SVG_Paint *paint) +void gf_svg_delete_paint(GF_SceneGraph *sg, SVG_Paint *paint) { if (!paint) return; if (paint->type == SVG_PAINT_URI && sg) gf_svg_reset_iri(sg, &paint->iri); @@ -418,19 +418,19 @@ void gf_svg_delete_attribute_value(u32 type, void *value, GF_SceneGraph *sg) gf_free(value); break; case SVG_FontFamily_datatype: - { - SVG_FontFamily *ff = (SVG_FontFamily *)value; - if (ff->value) gf_free(ff->value); - gf_free(value); - } - break; + { + SVG_FontFamily *ff = (SVG_FontFamily *)value; + if (ff->value) gf_free(ff->value); + gf_free(value); + } + break; case SMIL_AttributeName_datatype: - { - SMIL_AttributeName *an = (SMIL_AttributeName *)value; - if (an->name) gf_free(an->name); - gf_free(value); - } - break; + { + SMIL_AttributeName *an = (SMIL_AttributeName *)value; + if (an->name) gf_free(an->name); + gf_free(value); + } + break; case SMIL_Times_datatype: gf_smil_delete_times(*(SMIL_Times *)value); gf_free(value); @@ -484,7 +484,7 @@ void gf_svg_delete_attribute_value(u32 type, void *value, GF_SceneGraph *sg) case SVG_Display_datatype: default: gf_free(value); - } + } } diff --git a/src/scenegraph/vrml_interpolators.c b/src/scenegraph/vrml_interpolators.c index e39ad3f..a3ab53c 100644 --- a/src/scenegraph/vrml_interpolators.c +++ b/src/scenegraph/vrml_interpolators.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,7 +56,7 @@ SFRotation gf_sg_sfrotation_interpolate(SFRotation kv1, SFRotation kv2, Fixed fr res.z = stzero ? kv2.z : kv1.z; } res.q = olda + gf_mulfix(fraction, newa - olda); - if (res.q > GF_2PI) { + if (res.q > GF_2PI) { res.q -= GF_2PI; } else if (res.q < GF_2PI) { res.q += GF_2PI; @@ -87,7 +87,7 @@ static void CI2D_SetFraction(GF_Node *n, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count % _this->key.count) return; - + numElemPerKey = _this->keyValue.count / _this->key.count; //set size if (_this->value_changed.count != numElemPerKey) @@ -109,11 +109,11 @@ static void CI2D_SetFraction(GF_Node *n, GF_Route *route) frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction); for (i=0; ivalue_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x, - _this->keyValue.vals[(j)*numElemPerKey + i].x, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].x, + frac); _this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y, - _this->keyValue.vals[(j)*numElemPerKey + i].y, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].y, + frac); } break; } @@ -143,7 +143,7 @@ static Bool CI_SetFraction(Fixed fraction, MFVec3f *vals, MFFloat *key, MFVec3f if (! key->count) return 0; if (keyValue->count % key->count) return 0; - + numElemPerKey = keyValue->count / key->count; if (vals->count != numElemPerKey) gf_sg_vrml_mf_alloc(vals, GF_SG_VRML_MFVEC3F, numElemPerKey); @@ -163,14 +163,14 @@ static Bool CI_SetFraction(Fixed fraction, MFVec3f *vals, MFFloat *key, MFVec3f frac = GetInterpolateFraction(key->vals[j-1], key->vals[j], fraction); for (i=0; ivals[i].x = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].x, - keyValue->vals[(j)*numElemPerKey + i].x, - frac); + keyValue->vals[(j)*numElemPerKey + i].x, + frac); vals->vals[i].y = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].y, - keyValue->vals[(j)*numElemPerKey + i].y, - frac); + keyValue->vals[(j)*numElemPerKey + i].y, + frac); vals->vals[i].z = Interpolate(keyValue->vals[(j-1)*numElemPerKey + i].z, - keyValue->vals[(j)*numElemPerKey + i].z, - frac); + keyValue->vals[(j)*numElemPerKey + i].z, + frac); } break; } @@ -183,7 +183,7 @@ static void CoordInt_SetFraction(GF_Node *n, GF_Route *route) { M_CoordinateInterpolator *_this = (M_CoordinateInterpolator *) n; - if (CI_SetFraction(_this->set_fraction, &_this->value_changed, &_this->key, &_this->keyValue)) + if (CI_SetFraction(_this->set_fraction, &_this->value_changed, &_this->key, &_this->keyValue)) gf_node_event_out(n, 3);//"value_changed" } @@ -223,7 +223,7 @@ static void ColorInt_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -236,15 +236,15 @@ static void ColorInt_SetFraction(GF_Node *node, GF_Route *route) if (_this->set_fraction >= _this->key.vals[i]) continue; frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction); - _this->value_changed.red = Interpolate(_this->keyValue.vals[i-1].red, - _this->keyValue.vals[i].red, - frac); + _this->value_changed.red = Interpolate(_this->keyValue.vals[i-1].red, + _this->keyValue.vals[i].red, + frac); _this->value_changed.green = Interpolate(_this->keyValue.vals[i-1].green, - _this->keyValue.vals[i].green, - frac); + _this->keyValue.vals[i].green, + frac); _this->value_changed.blue = Interpolate(_this->keyValue.vals[i-1].blue, - _this->keyValue.vals[i].blue, - frac); + _this->keyValue.vals[i].blue, + frac); break; } } @@ -253,7 +253,7 @@ static void ColorInt_SetFraction(GF_Node *node, GF_Route *route) Bool InitColorInterpolator(M_ColorInterpolator *node) { - node->on_set_fraction = ColorInt_SetFraction; + node->on_set_fraction = ColorInt_SetFraction; if (node->keyValue.count) node->value_changed = node->keyValue.vals[0]; return 1; } @@ -267,7 +267,7 @@ static void PosInt2D_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -290,7 +290,7 @@ static void PosInt2D_SetFraction(GF_Node *node, GF_Route *route) Bool InitPositionInterpolator2D(M_PositionInterpolator2D *node) { - node->on_set_fraction = PosInt2D_SetFraction; + node->on_set_fraction = PosInt2D_SetFraction; if (node->keyValue.count) node->value_changed = node->keyValue.vals[0]; return 1; } @@ -303,7 +303,7 @@ static void PosInt_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -327,7 +327,7 @@ static void PosInt_SetFraction(GF_Node *node, GF_Route *route) Bool InitPositionInterpolator(M_PositionInterpolator *node) { - node->on_set_fraction = PosInt_SetFraction; + node->on_set_fraction = PosInt_SetFraction; if (node->keyValue.count) node->value_changed = node->keyValue.vals[0]; return 1; } @@ -340,7 +340,7 @@ static void ScalarInt_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -361,7 +361,7 @@ static void ScalarInt_SetFraction(GF_Node *node, GF_Route *route) } Bool InitScalarInterpolator(M_ScalarInterpolator *node) { - node->on_set_fraction = ScalarInt_SetFraction; + node->on_set_fraction = ScalarInt_SetFraction; if (node->keyValue.count) node->value_changed = node->keyValue.vals[0]; return 1; } @@ -375,7 +375,7 @@ static void OrientInt_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -397,7 +397,7 @@ static void OrientInt_SetFraction(GF_Node *node, GF_Route *route) Bool InitOrientationInterpolator(M_OrientationInterpolator *node) { - node->on_set_fraction = OrientInt_SetFraction; + node->on_set_fraction = OrientInt_SetFraction; if (node->keyValue.count) node->value_changed = node->keyValue.vals[0]; return 1; } @@ -410,7 +410,7 @@ static void CI4D_SetFraction(GF_Node *n, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count % _this->key.count) return; - + numElemPerKey = _this->keyValue.count / _this->key.count; //set size if (_this->value_changed.count != numElemPerKey) @@ -432,17 +432,17 @@ static void CI4D_SetFraction(GF_Node *n, GF_Route *route) frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction); for (i=0; ivalue_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x, - _this->keyValue.vals[(j)*numElemPerKey + i].x, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].x, + frac); _this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y, - _this->keyValue.vals[(j)*numElemPerKey + i].y, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].y, + frac); _this->value_changed.vals[i].z = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].z, - _this->keyValue.vals[(j)*numElemPerKey + i].z, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].z, + frac); _this->value_changed.vals[i].q = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].q, - _this->keyValue.vals[(j)*numElemPerKey + i].q, - frac); + _this->keyValue.vals[(j)*numElemPerKey + i].q, + frac); } break; } @@ -472,7 +472,7 @@ static void PI4D_SetFraction(GF_Node *node, GF_Route *route) if (! _this->key.count) return; if (_this->keyValue.count != _this->key.count) return; - + // The given fraction is less than the specified range if (_this->set_fraction < _this->key.vals[0]) { _this->value_changed = _this->keyValue.vals[0]; @@ -533,7 +533,7 @@ static void BooleanSequencer_setFraction(GF_Node *n, GF_Route *route) X_BooleanSequencer *bs = (X_BooleanSequencer*)n; if (! bs->key.count) return; if (bs->keyValue.count != bs->key.count) return; - + if (bs->set_fraction < bs->key.vals[0]) { bs->value_changed = bs->keyValue.vals[0]; } else if (bs->set_fraction >= bs->key.vals[bs->key.count-1]) { @@ -626,7 +626,7 @@ static void IntegerSequencer_setFraction(GF_Node *n, GF_Route *route) X_IntegerSequencer *is = (X_IntegerSequencer *)n; if (! is->key.count) return; if (is->keyValue.count != is->key.count) return; - + if (is->set_fraction < is->key.vals[0]) { is->value_changed = is->keyValue.vals[0]; } else if (is->set_fraction >= is->key.vals[is->key.count-1]) { diff --git a/src/scenegraph/vrml_proto.c b/src/scenegraph/vrml_proto.c index f9208bc..197030e 100644 --- a/src/scenegraph/vrml_proto.c +++ b/src/scenegraph/vrml_proto.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -55,7 +55,7 @@ GF_Proto *gf_sg_proto_new(GF_SceneGraph *inScene, u32 ProtoID, char *name, Bool tmp->sub_graph = gf_sg_new_subscene(inScene); tmp->instances = gf_list_new(); - if (name) + if (name) tmp->Name = gf_strdup(name); else tmp->Name = gf_strdup("Unnamed Proto"); @@ -124,16 +124,16 @@ GF_Err gf_sg_proto_del(GF_Proto *proto) if (field->userpriv && field->OnDelete) field->OnDelete(field->userpriv); if (field->FieldType==GF_SG_VRML_SFNODE) { - if (field->def_sfnode_value) + if (field->def_sfnode_value) gf_node_unregister(field->def_sfnode_value, NULL); - } + } else if (field->FieldType==GF_SG_VRML_MFNODE) { if (field->def_mfnode_value) gf_node_unregister_children(NULL, field->def_mfnode_value); - } - else if (field->def_value) + } + else if (field->def_value) gf_sg_vrml_field_pointer_del(field->def_value, field->FieldType); - + if (field->FieldName) gf_free(field->FieldName); /*QP fields are SF fields, we can safely gf_free() them*/ @@ -156,7 +156,7 @@ GF_Err gf_sg_proto_del(GF_Proto *proto) if (proto->Name) gf_free(proto->Name); gf_sg_mfurl_del(proto->ExternProto); - gf_list_del(proto->instances); + gf_list_del(proto->instances); gf_free(proto); return GF_OK; } @@ -213,7 +213,7 @@ GF_ProtoFieldInterface *gf_sg_proto_field_new(GF_Proto *proto, u32 fieldType, u3 tmp->FieldType = fieldType; tmp->EventType = eventType; - + /*create container - can be NULL if SF node*/ if ( fieldType == GF_SG_VRML_SFNODE) { tmp->def_sfnode_value = NULL; @@ -224,9 +224,9 @@ GF_ProtoFieldInterface *gf_sg_proto_field_new(GF_Proto *proto, u32 fieldType, u3 } else { tmp->def_value = gf_sg_vrml_field_pointer_new(fieldType); } - + if (fieldName) tmp->FieldName = gf_strdup(fieldName); - + tmp->ALL_index = gf_list_count(proto->proto_fields); tmp->OUT_index = tmp->DEF_index = tmp->IN_index = (u32) -1; @@ -379,7 +379,7 @@ GF_Node *gf_vrml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clon strcpy(szNodeName, orig_name); strcat(szNodeName, inst_id_suffix); } - } + } else if (orig_name) szNodeName = gf_strdup(orig_name); } @@ -404,13 +404,13 @@ GF_Node *gf_vrml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clon count = gf_node_get_field_count(orig); is_script = 0; - if ((orig->sgprivate->tag==TAG_MPEG4_Script) + if ((orig->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (orig->sgprivate->tag==TAG_X3D_Script) + || (orig->sgprivate->tag==TAG_X3D_Script) #endif - ) + ) is_script = 1; - + if (is_script) gf_sg_script_prepare_clone(node, orig); @@ -467,20 +467,20 @@ GF_Node *gf_vrml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clon /*init node before creating ISed routes so the eventIn handler are in place*/ if (node->sgprivate->tag == TAG_MPEG4_Conditional) BIFS_SetupConditionalClone(node, orig); - else + else #endif if (node->sgprivate->tag != TAG_ProtoNode) gf_node_init(node); if (!inScene->pOwningProto) return node; proto = inScene->pOwningProto; - + /*create Routes for ISed fields*/ i=0; while ((r1 = (GF_Route*)gf_list_enum(proto->proto_interface->sub_graph->Routes, &i))) { r2 = NULL; /*locate only ISed routes*/ if (!r1->IS_route) continue; - + /*eventOut*/ if (r1->FromNode == orig) { r2 = gf_sg_route_new(inScene, node, r1->FromField.fieldIndex, (GF_Node *) proto, r1->ToField.fieldIndex); @@ -496,7 +496,7 @@ GF_Node *gf_vrml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clon gf_sg_route_activate(r2); } } - + /*remember scripts*/ if (is_script) gf_list_add(proto->scripts_to_load, node); @@ -575,15 +575,15 @@ void gf_sg_proto_instanciate(GF_ProtoInstance *proto_node) /*this is an hardcoded proto - all routes, node modifications and co are handled internally*/ if (extern_lib == GF_SG_INTERNAL_PROTO) { proto_node->sgprivate->flags |= GF_SG_NODE_DIRTY; - // take default values - count = gf_list_count(owner->proto_fields); - for (i=0; ifields, i); - if (!pf->has_been_accessed) { - pfi = (GF_ProtoFieldInterface*)gf_list_get(proto->proto_fields, i); - gf_sg_vrml_field_copy(pf->field_pointer, pfi->def_value, pfi->FieldType); - } - } + // take default values + count = gf_list_count(owner->proto_fields); + for (i=0; ifields, i); + if (!pf->has_been_accessed) { + pfi = (GF_ProtoFieldInterface*)gf_list_get(proto->proto_fields, i); + gf_sg_vrml_field_copy(pf->field_pointer, pfi->def_value, pfi->FieldType); + } + } owner->parent_graph->NodeCallback(owner->parent_graph->userpriv, GF_SG_CALLBACK_INIT, (GF_Node *) proto_node, NULL); proto_node->flags |= GF_SG_PROTO_LOADED; return; @@ -654,11 +654,11 @@ void gf_sg_proto_instanciate(GF_ProtoInstance *proto_node) while ((route = (GF_Route*)gf_list_enum(proto->sub_graph->Routes, &i))) { if (route->IS_route) continue; - r2 = gf_sg_route_new(proto_node->sgprivate->scenegraph, - gf_sg_find_node(proto_node->sgprivate->scenegraph, gf_node_get_id(route->FromNode) ), - route->FromField.fieldIndex, - gf_sg_find_node(proto_node->sgprivate->scenegraph, gf_node_get_id(route->ToNode) ), - route->ToField.fieldIndex); + r2 = gf_sg_route_new(proto_node->sgprivate->scenegraph, + gf_sg_find_node(proto_node->sgprivate->scenegraph, gf_node_get_id(route->FromNode) ), + route->FromField.fieldIndex, + gf_sg_find_node(proto_node->sgprivate->scenegraph, gf_node_get_id(route->ToNode) ), + route->ToField.fieldIndex); if (route->ID) gf_sg_route_set_id(r2, route->ID); if (route->name) gf_sg_route_set_name(r2, route->name); @@ -683,19 +683,19 @@ void gf_sg_proto_instanciate(GF_ProtoInstance *proto_node) i=0; while ((route = (GF_Route*)gf_list_enum(proto_node->sgprivate->scenegraph->Routes, &i))) { if (!route->IS_route || !route->ToNode) continue; -/* assert(route->is_setup); - if ((route->FromField.eventType == GF_SG_EVENT_OUT) || (route->FromField.eventType == GF_SG_EVENT_IN) ) continue; -*/ + /* assert(route->is_setup); + if ((route->FromField.eventType == GF_SG_EVENT_OUT) || (route->FromField.eventType == GF_SG_EVENT_IN) ) continue; + */ if (route->is_setup) { if ((route->ToField.eventType == GF_SG_EVENT_IN) && (route->FromField.eventType == GF_SG_EVENT_IN) ) continue; } - if ((route->ToNode->sgprivate->tag==TAG_MPEG4_Script) + if ((route->ToNode->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (route->ToNode->sgprivate->tag==TAG_X3D_Script) + || (route->ToNode->sgprivate->tag==TAG_X3D_Script) #endif - ) + ) gf_sg_route_activate(route); } @@ -713,7 +713,7 @@ void gf_sg_proto_instanciate(GF_ProtoInstance *proto_node) } void gf_sg_proto_mark_field_loaded(GF_Node *proto_inst, GF_FieldInfo *info) -{ +{ GF_ProtoInstance *inst= (proto_inst->sgprivate->tag==TAG_ProtoNode) ? (GF_ProtoInstance *)proto_inst : NULL; GF_ProtoField *pf = inst ? (GF_ProtoField *)gf_list_get(inst->fields, info->fieldIndex) : NULL; if (pf) pf->has_been_accessed = 1; @@ -798,10 +798,14 @@ u32 gf_sg_proto_get_num_fields(GF_Node *node, u8 code_mode) proto = (GF_ProtoInstance *)node; /*watchout for deletion case*/ switch (code_mode) { - case GF_SG_FIELD_CODING_IN: return proto->proto_interface ? proto->proto_interface->NumIn : 0; - case GF_SG_FIELD_CODING_OUT: return proto->proto_interface ? proto->proto_interface->NumOut : 0; - case GF_SG_FIELD_CODING_DEF: return proto->proto_interface ? proto->proto_interface->NumDef : 0; - case GF_SG_FIELD_CODING_ALL: return gf_list_count(proto->proto_interface ? proto->proto_interface->proto_fields : proto->fields); + case GF_SG_FIELD_CODING_IN: + return proto->proto_interface ? proto->proto_interface->NumIn : 0; + case GF_SG_FIELD_CODING_OUT: + return proto->proto_interface ? proto->proto_interface->NumOut : 0; + case GF_SG_FIELD_CODING_DEF: + return proto->proto_interface ? proto->proto_interface->NumDef : 0; + case GF_SG_FIELD_CODING_ALL: + return gf_list_count(proto->proto_interface ? proto->proto_interface->proto_fields : proto->fields); /*BIFS-ANIM not supported*/ case GF_SG_FIELD_CODING_DYN: default: @@ -873,7 +877,7 @@ void gf_sg_proto_del_instance(GF_ProtoInstance *inst) } /*Note on ISed fields: we cannot support fan-in on proto, eg we assume only one eventIn field can receive events -thus situations where a proto receives eventIn from outside and the node with ISed eventIn receives event +thus situations where a proto receives eventIn from outside and the node with ISed eventIn receives event from inside the proto are undefined*/ GF_Err gf_sg_proto_field_set_ised(GF_Proto *proto, u32 protoFieldIndex, GF_Node *node, u32 nodeFieldIndex) { @@ -960,7 +964,7 @@ GF_Err gf_sg_proto_instance_set_ised(GF_Node *protoinst, u32 protoFieldIndex, GF GF_Route *r; GF_FieldInfo field, nodeField; if (protoinst->sgprivate->tag != TAG_ProtoNode) return GF_BAD_PARAM; - + e = gf_node_get_field(protoinst, protoFieldIndex, &field); if (e) return e; e = gf_node_get_field(node, nodeFieldIndex, &nodeField); @@ -1038,13 +1042,13 @@ GF_Err gf_sg_proto_instance_set_ised(GF_Node *protoinst, u32 protoFieldIndex, GF } -GF_Err gf_bifs_proto_field_set_aq_info(GF_ProtoFieldInterface *field, - u32 QP_Type, - u32 hasMinMax, - u32 QPSFType, - void *qp_min_value, - void *qp_max_value, - u32 QP13_NumBits) +GF_Err gf_bifs_proto_field_set_aq_info(GF_ProtoFieldInterface *field, + u32 QP_Type, + u32 hasMinMax, + u32 QPSFType, + void *qp_min_value, + void *qp_max_value, + u32 QP13_NumBits) { if (!field) return GF_BAD_PARAM; @@ -1105,7 +1109,7 @@ GF_Err gf_sg_proto_get_field_index(GF_ProtoInstance *proto, u32 index, u32 code_ case GF_SG_FIELD_CODING_DYN: default: return GF_BAD_PARAM; - } + } } return GF_BAD_PARAM; } @@ -1141,7 +1145,7 @@ void gf_sg_proto_propagate_event(GF_Node *node, u32 fieldIndex, GF_Node *from_no if (!r->IS_route) continue; /*connecting from this node && field to a destination node other than the event source (this will break loops due to exposedFields)*/ if ((r->FromNode == node) && (r->FromField.fieldIndex == fieldIndex) && (r->ToNode != from_node) ) { - if (gf_sg_route_activate(r)) + if (gf_sg_route_activate(r)) gf_node_changed(r->ToNode, &r->ToField); } } @@ -1159,7 +1163,7 @@ Bool gf_sg_proto_get_aq_info(GF_Node *Node, u32 FieldIndex, u8 *QType, u8 *AType i=0; while ((proto_field = (GF_ProtoFieldInterface*)gf_list_enum(proto->proto_fields, &i))) { if (proto_field->ALL_index!=FieldIndex) continue; - + *QType = proto_field->QP_Type; *AType = proto_field->Anim_Type; *b_min = FIX_MIN; @@ -1292,7 +1296,7 @@ GF_Node *gf_node_get_proto_parent(GF_Node *node) if (node->sgprivate->scenegraph->pOwningProto) { GF_Node *the_node = (GF_Node *) node->sgprivate->scenegraph->pOwningProto; if (the_node != node) return the_node; - } + } return NULL; } diff --git a/src/scenegraph/vrml_route.c b/src/scenegraph/vrml_route.c index 759a57d..6beb960 100644 --- a/src/scenegraph/vrml_route.c +++ b/src/scenegraph/vrml_route.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -207,7 +207,7 @@ GF_Err gf_sg_route_set_id(GF_Route *route, u32 ID) route->ID = ID; return GF_OK; } -u32 gf_sg_route_get_id(GF_Route *route) +u32 gf_sg_route_get_id(GF_Route *route) { return route->ID; } @@ -227,7 +227,7 @@ char *gf_sg_route_get_name(GF_Route *route) return route->name; } -void gf_sg_route_setup(GF_Route *r) +void gf_sg_route_setup(GF_Route *r) { gf_node_get_field(r->FromNode, r->FromField.fieldIndex, &r->FromField); gf_node_get_field(r->ToNode, r->ToField.fieldIndex, &r->ToField); @@ -248,9 +248,9 @@ void gf_node_event_out_proto(GF_Node *node, u32 FieldIndex) u32 i; GF_Route *r; if (!node) return; - + if (!node->sgprivate->interact) return; - + //search for routes to activate in the order they where declared i=0; while ((r = (GF_Route*)gf_list_enum(node->sgprivate->interact->routes, &i))) { @@ -275,13 +275,13 @@ Bool gf_sg_route_activate(GF_Route *r) if (r->FromField.eventType == GF_SG_EVENT_OUT) return 0; if (r->ToField.eventType == GF_SG_EVENT_OUT) return 0; } - if (r->IS_route && ((r->ToNode->sgprivate->tag==TAG_MPEG4_Script) + if (r->IS_route && ((r->ToNode->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (r->ToNode->sgprivate->tag==TAG_X3D_Script) + || (r->ToNode->sgprivate->tag==TAG_X3D_Script) #endif - ) && ((r->ToField.eventType==GF_SG_EVENT_IN) /*|| (r->ToField.eventType==GF_SG_EVENT_FIELD)*/) - && r->FromField.eventType==GF_SG_EVENT_IN) { - return 0; + ) && ((r->ToField.eventType==GF_SG_EVENT_IN) /*|| (r->ToField.eventType==GF_SG_EVENT_FIELD)*/) + && r->FromField.eventType==GF_SG_EVENT_IN) { + return 0; } } #ifndef GPAC_DISABLE_LOG @@ -331,7 +331,7 @@ Bool gf_sg_route_activate(GF_Route *r) orig = orig->next; } } - break; + break; default: if (r->ToField.fieldType==r->FromField.fieldType) { @@ -341,7 +341,7 @@ Bool gf_sg_route_activate(GF_Route *r) } else { gf_sg_vrml_field_copy(r->ToField.far_ptr, r->FromField.far_ptr, r->FromField.fieldType); } - } + } /*typecast URL <-> string if needed*/ else { VRML_FieldCopyCast(r->ToField.far_ptr, r->ToField.fieldType, r->FromField.far_ptr, r->FromField.fieldType); @@ -354,11 +354,11 @@ Bool gf_sg_route_activate(GF_Route *r) r->ToField.on_event_in(r->ToNode, r); } //if this is a script eventIn call directly script - else if (((r->ToNode->sgprivate->tag==TAG_MPEG4_Script) + else if (((r->ToNode->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (r->ToNode->sgprivate->tag==TAG_X3D_Script) + || (r->ToNode->sgprivate->tag==TAG_X3D_Script) #endif - ) && ((r->ToField.eventType==GF_SG_EVENT_IN) /*|| (r->ToField.eventType==GF_SG_EVENT_FIELD)*/) ) { + ) && ((r->ToField.eventType==GF_SG_EVENT_IN) /*|| (r->ToField.eventType==GF_SG_EVENT_FIELD)*/) ) { gf_sg_script_event_in(r->ToNode, &r->ToField); } //check if ISed or not - this will notify the node of any changes @@ -368,12 +368,12 @@ Bool gf_sg_route_activate(GF_Route *r) if (r->ToField.eventType != GF_SG_EVENT_EXPOSED_FIELD) gf_sg_proto_propagate_event(r->ToNode, r->ToField.fieldIndex, r->FromNode); /*only happen on proto, an eventOut may route to an eventOut*/ - if (r->IS_route && r->ToField.eventType==GF_SG_EVENT_OUT) + if (r->IS_route && r->ToField.eventType==GF_SG_EVENT_OUT) gf_node_event_out(r->ToNode, r->ToField.fieldIndex); } /*and signal routes on exposed fields if field changed*/ - if (r->ToField.eventType == GF_SG_EVENT_EXPOSED_FIELD){ + if (r->ToField.eventType == GF_SG_EVENT_EXPOSED_FIELD) { if (r->IS_route) gf_node_event_out_proto(r->ToNode, r->ToField.fieldIndex); else @@ -389,10 +389,10 @@ void gf_node_event_out(GF_Node *node, u32 FieldIndex) u32 i; GF_Route *r; if (!node) return; - + /*node has no routes*/ if (!node->sgprivate->interact || !node->sgprivate->interact->routes) return; - + //search for routes to activate in the order they where declared i=0; while ((r = (GF_Route*)gf_list_enum(node->sgprivate->interact->routes, &i))) { @@ -401,7 +401,7 @@ void gf_node_event_out(GF_Node *node, u32 FieldIndex) /*no postpone for IS routes*/ if (r->IS_route) { - if (gf_sg_route_activate(r)) + if (gf_sg_route_activate(r)) gf_node_changed(r->ToNode, &r->ToField); } //queue diff --git a/src/scenegraph/vrml_script.c b/src/scenegraph/vrml_script.c index 2fdc4e7..31418c2 100644 --- a/src/scenegraph/vrml_script.c +++ b/src/scenegraph/vrml_script.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -32,7 +32,7 @@ #ifndef GPAC_DISABLE_VRML -static u32 script_get_nb_static_field(GF_Node *node) +static u32 script_get_nb_static_field(GF_Node *node) { return (node->sgprivate->tag==TAG_MPEG4_Script) ? 3 : 4; } @@ -41,11 +41,11 @@ void Script_PreDestroy(GF_Node *node, void *eff, Bool is_destroy) { GF_ScriptPriv *priv; GF_ScriptField *field; - + if (!is_destroy) return; priv = (GF_ScriptPriv *)node->sgprivate->UserPrivate; - + if (priv->JS_PreDestroy) priv->JS_PreDestroy(node); //destroy extra fields @@ -191,11 +191,11 @@ GF_ScriptField *gf_sg_script_field_new(GF_Node *node, u32 eventType, u32 fieldTy { GF_ScriptPriv *priv; GF_ScriptField *field; - if (!name || ((node->sgprivate->tag != TAG_MPEG4_Script) + if (!name || ((node->sgprivate->tag != TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - && (node->sgprivate->tag != TAG_X3D_Script) + && (node->sgprivate->tag != TAG_X3D_Script) #endif - )) + )) return NULL; if (eventType > GF_SG_SCRIPT_TYPE_EVENT_OUT) return NULL; @@ -231,7 +231,7 @@ GF_ScriptField *gf_sg_script_field_new(GF_Node *node, u32 eventType, u32 fieldTy if ((fieldType != GF_SG_VRML_SFNODE) && (fieldType != GF_SG_VRML_MFNODE) ) { field->pField = gf_sg_vrml_field_pointer_new(fieldType); } - + return field; } diff --git a/src/scenegraph/vrml_smjs.c b/src/scenegraph/vrml_smjs.c index 1a3504a..d258a7d 100644 --- a/src/scenegraph/vrml_smjs.c +++ b/src/scenegraph/vrml_smjs.c @@ -110,7 +110,7 @@ JSObject *gf_sg_js_global_object(JSContext *cx, GF_JSClass *__class) # endif #endif -/*define this macro to force Garbage Collection after each input to JS (script initialize/shutdown and all eventIn) +/*define this macro to force Garbage Collection after each input to JS (script initialize/shutdown and all eventIn) on latest SM, GC will crash if called from a different thread than the thread creating the contex, no clue why for iOS don't force GC (better performances according to Ivica) @@ -213,21 +213,21 @@ Bool gf_js_remove_root(JSContext *cx, void *rp, u32 type) case GF_JSGC_STRING: #ifdef USE_FFDEV_15 if (!cx) JS_RemoveStringRootRT(js_rt->js_runtime, rp); - else + else #endif JS_RemoveStringRoot(cx, rp); break; case GF_JSGC_OBJECT: #ifdef USE_FFDEV_15 if (!cx) JS_RemoveObjectRootRT(js_rt->js_runtime, rp); - else + else #endif JS_RemoveObjectRoot(cx, rp); break; case GF_JSGC_VAL: #ifdef USE_FFDEV_15 if (!cx) JS_RemoveValueRootRT(js_rt->js_runtime, rp); - else + else #endif JS_RemoveValueRoot(cx, (jsval *) rp); break; @@ -372,7 +372,7 @@ void gf_sg_ecmascript_del(JSContext *ctx) #if (JS_VERSION>=185) assert(js_rt); JS_SetRuntimeThread(js_rt->js_runtime); - JS_SetContextThread(ctx); + JS_SetContextThread(ctx); #endif #endif @@ -454,18 +454,18 @@ void gf_sg_js_call_gc(JSContext *c) } #ifdef FORCE_GC -void MyJSGC(JSContext *c) +void MyJSGC(JSContext *c) { gf_sg_js_call_gc(c); - + } #endif void SFColor_fromHSV(SFColor *col) { - Fixed f, q, t, p, hue, sat, val; - u32 i; + Fixed f, q, t, p, hue, sat, val; + u32 i; hue = col->red; sat = col->green; val = col->blue; @@ -473,21 +473,45 @@ void SFColor_fromHSV(SFColor *col) col->red = col->green = col->blue = val; return; } - if (hue == FIX_ONE) hue = 0; - else hue *= 6; - i = FIX2INT( gf_floor(hue) ); - f = hue-i; - p = gf_mulfix(val, FIX_ONE - sat); - q = gf_mulfix(val, FIX_ONE - gf_mulfix(sat,f)); - t = gf_mulfix(val, FIX_ONE - gf_mulfix(sat, FIX_ONE - f)); - switch (i) { - case 0: col->red = val; col->green = t; col->blue = p; break; - case 1: col->red = q; col->green = val; col->blue = p; break; - case 2: col->red = p; col->green = val; col->blue = t; break; - case 3: col->red = p; col->green = q; col->blue = val; break; - case 4: col->red = t; col->green = p; col->blue = val; break; - case 5: col->red = val; col->green = p; col->blue = q; break; - } + if (hue == FIX_ONE) hue = 0; + else hue *= 6; + i = FIX2INT( gf_floor(hue) ); + f = hue-i; + p = gf_mulfix(val, FIX_ONE - sat); + q = gf_mulfix(val, FIX_ONE - gf_mulfix(sat,f)); + t = gf_mulfix(val, FIX_ONE - gf_mulfix(sat, FIX_ONE - f)); + switch (i) { + case 0: + col->red = val; + col->green = t; + col->blue = p; + break; + case 1: + col->red = q; + col->green = val; + col->blue = p; + break; + case 2: + col->red = p; + col->green = val; + col->blue = t; + break; + case 3: + col->red = p; + col->green = q; + col->blue = val; + break; + case 4: + col->red = t; + col->green = p; + col->blue = val; + break; + case 5: + col->red = val; + col->green = p; + col->blue = q; + break; + } } void SFColor_toHSV(SFColor *col) @@ -544,7 +568,7 @@ static void script_error(JSContext *c, const char *msg, JSErrorReport *jserr) static JSBool SMJS_FUNCTION(JSPrint) { - SMJS_ARGS + SMJS_ARGS if (JSVAL_IS_STRING(argv[0])) { char *str = SMJS_CHARS(c, argv[0]); _ScriptMessage(c, str); @@ -865,11 +889,11 @@ static JSBool SMJS_FUNCTION(addRoute) f_id2 = atoi(f2+6); e = gf_node_get_field(n2, f_id2, &info); } else { - if ((n2->sgprivate->tag==TAG_MPEG4_Script) + if ((n2->sgprivate->tag==TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (n2->sgprivate->tag==TAG_X3D_Script) + || (n2->sgprivate->tag==TAG_X3D_Script) #endif - ) { + ) { GF_FieldInfo src = info; if (gf_node_get_field_by_name(n2, f2, &info) != GF_OK) { gf_sg_script_field_new(n2, GF_SG_SCRIPT_TYPE_EVENT_IN, src.fieldType, f2); @@ -894,11 +918,11 @@ static JSBool SMJS_FUNCTION(addRoute) fun_name = JS_GetFunctionName( JS_ValueToFunction(c, argv[3] ) ); if (fun_name && n1->sgprivate->interact && n1->sgprivate->interact->routes ) { while ( (r = (GF_RouteToFunction*)gf_list_enum(n1->sgprivate->interact->routes, &i) )) { - if ( (r->FromNode == n1) - && (r->FromField.fieldIndex == f_id1) - && (r->ToNode == (GF_Node*)JS_GetScript(c)) - && !stricmp(r->ToField.name, fun_name) - ) + if ( (r->FromNode == n1) + && (r->FromField.fieldIndex == f_id1) + && (r->ToNode == (GF_Node*)JS_GetScript(c)) + && !stricmp(r->ToField.name, fun_name) + ) break; } } @@ -918,10 +942,10 @@ static JSBool SMJS_FUNCTION(addRoute) r->ToField.name = fun_name; r->obj = JSVAL_TO_OBJECT( argv[2] ) ; - // gf_js_add_root(c, & r->obj); + // gf_js_add_root(c, & r->obj); r->fun = argv[3]; - // gf_js_add_root(c, &r->fun); + // gf_js_add_root(c, &r->fun); r->is_setup = 1; r->graph = n1->sgprivate->scenegraph; @@ -950,7 +974,7 @@ static JSBool SMJS_FUNCTION(deleteRoute) if (argc!=4) return JS_FALSE; if (!JSVAL_IS_OBJECT(argv[0]) || !GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - + if (JSVAL_IS_STRING(argv[1]) && JSVAL_IS_NULL(argv[2]) && JSVAL_IS_NULL(argv[3])) { ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); @@ -1183,11 +1207,11 @@ void Script_FieldChanged(JSContext *c, GF_Node *parent, GF_JSField *parent_owner if (!parent) return; script_field = 0; - if ((parent->sgprivate->tag == TAG_MPEG4_Script) + if ((parent->sgprivate->tag == TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (parent->sgprivate->tag == TAG_X3D_Script) + || (parent->sgprivate->tag == TAG_X3D_Script) #endif - ) { + ) { script_field = 1; if ( (GF_Node *) JS_GetContextPrivate(c) == parent) script_field = 2; } @@ -1204,7 +1228,7 @@ void Script_FieldChanged(JSContext *c, GF_Node *parent, GF_JSField *parent_owner gf_sg_proto_propagate_event(parent, field->fieldIndex, (GF_Node*)JS_GetScript(c)); /* Node exposedField can also be routed to another field */ gf_node_event_out_proto(parent, field->fieldIndex); - }else{ + } else { gf_node_event_out(parent, field->fieldIndex); gf_node_changed_internal(parent, field, 0); } @@ -1227,38 +1251,38 @@ void Script_FieldChanged(JSContext *c, GF_Node *parent, GF_JSField *parent_owner SMJS_FUNC_PROP_SET( gf_sg_script_eventout_set_prop) - u32 i; - char *eventName; - GF_ScriptPriv *script; - GF_Node *n; - GF_ScriptField *sf; - GF_FieldInfo info; - jsval idval; - JSString *str; - JS_IdToValue(c, id, &idval); - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - str = SMJS_ID_TO_STRING(id); - if (!str) return JS_FALSE; - /*avoids gcc warning*/ - if (!obj) obj=NULL; - - script = JS_GetScriptStack(c); - if (!script) return JS_FALSE; - n = (GF_Node *) JS_GetScript(c); - - eventName = SMJS_CHARS_FROM_STRING(c, str); - i=0; - while ((sf = gf_list_enum(script->fields, &i))) { - if (!stricmp(sf->name, eventName)) { - gf_node_get_field(n, sf->ALL_index, &info); - gf_sg_script_to_node_field(c, *vp, &info, n, NULL); - sf->activate_event_out = 1; - SMJS_FREE(c, eventName); - return JS_TRUE; - } +u32 i; +char *eventName; +GF_ScriptPriv *script; +GF_Node *n; +GF_ScriptField *sf; +GF_FieldInfo info; +jsval idval; +JSString *str; +JS_IdToValue(c, id, &idval); +if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; +str = SMJS_ID_TO_STRING(id); +if (!str) return JS_FALSE; +/*avoids gcc warning*/ +if (!obj) obj=NULL; + +script = JS_GetScriptStack(c); +if (!script) return JS_FALSE; +n = (GF_Node *) JS_GetScript(c); + +eventName = SMJS_CHARS_FROM_STRING(c, str); +i=0; +while ((sf = gf_list_enum(script->fields, &i))) { + if (!stricmp(sf->name, eventName)) { + gf_node_get_field(n, sf->ALL_index, &info); + gf_sg_script_to_node_field(c, *vp, &info, n, NULL); + sf->activate_event_out = 1; + SMJS_FREE(c, eventName); + return JS_TRUE; } - SMJS_FREE(c, eventName); - return JS_FALSE; +} +SMJS_FREE(c, eventName); +return JS_FALSE; } @@ -1321,11 +1345,11 @@ static void JS_ObjectDestroyed(JSContext *c, JSObject *obj, GF_JSField *ptr, Boo if (ptr) { /*if ptr is a node, remove node binding*/ if (ptr->node - && ptr->node->sgprivate->interact - && ptr->node->sgprivate->interact->js_binding - && (ptr->node->sgprivate->interact->js_binding->node == ptr) - ) { - ptr->node->sgprivate->interact->js_binding->node = NULL; + && ptr->node->sgprivate->interact + && ptr->node->sgprivate->interact->js_binding + && (ptr->node->sgprivate->interact->js_binding->node == ptr) + ) { + ptr->node->sgprivate->interact->js_binding->node = NULL; } /*if ptr is a field, remove field binding from parent*/ @@ -1398,7 +1422,7 @@ static JSBool SMJS_FUNCTION(field_toString) strcat(str, str_val); SMJS_FREE(c, str_val); } - break; + break; default: if (JSVAL_IS_OBJECT(item)) { GF_JSField *sf = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); @@ -1492,7 +1516,7 @@ locate_proto: } gf_node_init(new_node); } - + SMJS_FREE(c, node_name); obj = node_get_binding(priv, new_node, 1); @@ -1511,9 +1535,9 @@ static void node_finalize_ex(JSContext *c, JSObject * obj, Bool is_js_call) if (ptr) { JS_GetScript(ptr->js_ctx ? ptr->js_ctx : c); if (ptr->node - /*num_instances may be 0 if the node is the script being destroyed*/ - && ptr->node->sgprivate->num_instances - ) { + /*num_instances may be 0 if the node is the script being destroyed*/ + && ptr->node->sgprivate->num_instances + ) { GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[VRML JS] unregistering node %s (%s)\n", gf_node_get_name(ptr->node), gf_node_get_class_name(ptr->node))); //gf_node_unregister(ptr->node, (ptr->node==parent) ? NULL : parent); @@ -1525,127 +1549,127 @@ static void node_finalize_ex(JSContext *c, JSObject * obj, Bool is_js_call) static DECL_FINALIZE(node_finalize) - node_finalize_ex(c, obj, 1); +node_finalize_ex(c, obj, 1); } static SMJS_FUNC_PROP_GET(node_getProperty) - GF_Node *n; - u32 index; - JSString *str; - GF_FieldInfo info; - GF_JSField *ptr; - GF_ScriptPriv *priv; - - if (! GF_JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); - n = * ((GF_Node **)ptr->field.far_ptr); - priv = JS_GetScriptStack(c); - - if (n && SMJS_ID_IS_STRING(id) && ( (str = SMJS_ID_TO_STRING(id)) != 0) ) { - char *fieldName = SMJS_CHARS_FROM_STRING(c, str); - if (!strnicmp(fieldName, "toString", 8)) { - SMJS_FREE(c, fieldName); - return JS_TRUE; - } - /*fieldID indexing*/ - if (!strnicmp(fieldName, "_field", 6)) { - index = atoi(fieldName+6); - if ( gf_node_get_field(n, index, &info) == GF_OK) { - *vp = gf_sg_script_to_smjs_field(priv, &info, n, 0); - SMJS_FREE(c, fieldName); - return JS_TRUE; - } - } else if ( gf_node_get_field_by_name(n, fieldName, &info) == GF_OK) { +GF_Node *n; +u32 index; +JSString *str; +GF_FieldInfo info; +GF_JSField *ptr; +GF_ScriptPriv *priv; + +if (! GF_JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; +ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); +n = * ((GF_Node **)ptr->field.far_ptr); +priv = JS_GetScriptStack(c); + +if (n && SMJS_ID_IS_STRING(id) && ( (str = SMJS_ID_TO_STRING(id)) != 0) ) { + char *fieldName = SMJS_CHARS_FROM_STRING(c, str); + if (!strnicmp(fieldName, "toString", 8)) { + SMJS_FREE(c, fieldName); + return JS_TRUE; + } + /*fieldID indexing*/ + if (!strnicmp(fieldName, "_field", 6)) { + index = atoi(fieldName+6); + if ( gf_node_get_field(n, index, &info) == GF_OK) { *vp = gf_sg_script_to_smjs_field(priv, &info, n, 0); SMJS_FREE(c, fieldName); return JS_TRUE; } + } else if ( gf_node_get_field_by_name(n, fieldName, &info) == GF_OK) { + *vp = gf_sg_script_to_smjs_field(priv, &info, n, 0); + SMJS_FREE(c, fieldName); + return JS_TRUE; + } - if (!strcmp(fieldName, "_bounds")) { - GF_JSAPIParam par; - par.bbox.is_set = 0; - if (ScriptAction(c, n->sgprivate->scenegraph, GF_JSAPI_OP_GET_LOCAL_BBOX, (GF_Node *)n, &par) ) { - JSObject *_obj = JS_NewObject(priv->js_ctx, &js_rt->AnyClass._class, 0, 0); - Float x, y, w, h; - x = y = w = h = 0; - if (par.bbox.is_set) { - x = FIX2FLT(par.bbox.min_edge.x); - y = FIX2FLT(par.bbox.min_edge.y); - w = FIX2FLT(par.bbox.max_edge.x - par.bbox.min_edge.x); - h = FIX2FLT(par.bbox.max_edge.y - par.bbox.min_edge.y); - } - JS_DefineProperty(priv->js_ctx, _obj, "x", JS_MAKE_DOUBLE(c, x), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); - JS_DefineProperty(priv->js_ctx, _obj, "y", JS_MAKE_DOUBLE(c, y), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); - JS_DefineProperty(priv->js_ctx, _obj, "width", JS_MAKE_DOUBLE(c, w), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); - JS_DefineProperty(priv->js_ctx, _obj, "height", JS_MAKE_DOUBLE(c, h), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); - *vp = OBJECT_TO_JSVAL(_obj); - SMJS_FREE(c, fieldName); - return JS_TRUE; + if (!strcmp(fieldName, "_bounds")) { + GF_JSAPIParam par; + par.bbox.is_set = 0; + if (ScriptAction(c, n->sgprivate->scenegraph, GF_JSAPI_OP_GET_LOCAL_BBOX, (GF_Node *)n, &par) ) { + JSObject *_obj = JS_NewObject(priv->js_ctx, &js_rt->AnyClass._class, 0, 0); + Float x, y, w, h; + x = y = w = h = 0; + if (par.bbox.is_set) { + x = FIX2FLT(par.bbox.min_edge.x); + y = FIX2FLT(par.bbox.min_edge.y); + w = FIX2FLT(par.bbox.max_edge.x - par.bbox.min_edge.x); + h = FIX2FLT(par.bbox.max_edge.y - par.bbox.min_edge.y); } + JS_DefineProperty(priv->js_ctx, _obj, "x", JS_MAKE_DOUBLE(c, x), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); + JS_DefineProperty(priv->js_ctx, _obj, "y", JS_MAKE_DOUBLE(c, y), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); + JS_DefineProperty(priv->js_ctx, _obj, "width", JS_MAKE_DOUBLE(c, w), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); + JS_DefineProperty(priv->js_ctx, _obj, "height", JS_MAKE_DOUBLE(c, h), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); + *vp = OBJECT_TO_JSVAL(_obj); + SMJS_FREE(c, fieldName); + return JS_TRUE; } - SMJS_FREE(c, fieldName); - return JS_TRUE; - } + } + SMJS_FREE(c, fieldName); + return JS_TRUE; +} - return JS_FALSE; +return JS_FALSE; } static SMJS_FUNC_PROP_SET( node_setProperty) - GF_Node *n; - GF_FieldInfo info; - u32 index; - char *fieldname; - GF_JSField *ptr; +GF_Node *n; +GF_FieldInfo info; +u32 index; +char *fieldname; +GF_JSField *ptr; - if (! GF_JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (! GF_JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; +ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} - assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); - n = * ((GF_Node **)ptr->field.far_ptr); +assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); +n = * ((GF_Node **)ptr->field.far_ptr); - if (n && SMJS_ID_IS_STRING(id)) { - JSString *str = SMJS_ID_TO_STRING(id); - fieldname = SMJS_CHARS_FROM_STRING(c, str); +if (n && SMJS_ID_IS_STRING(id)) { + JSString *str = SMJS_ID_TO_STRING(id); + fieldname = SMJS_CHARS_FROM_STRING(c, str); - /*fieldID indexing*/ - if (!strnicmp(fieldname, "_field", 6)) { - index = atoi(fieldname+6); + /*fieldID indexing*/ + if (!strnicmp(fieldname, "_field", 6)) { + index = atoi(fieldname+6); + SMJS_FREE(c, fieldname); + if ( gf_node_get_field(n, index, &info) != GF_OK) { SMJS_FREE(c, fieldname); - if ( gf_node_get_field(n, index, &info) != GF_OK) { - SMJS_FREE(c, fieldname); - return JS_TRUE; - } - } else { - if (gf_node_get_field_by_name(n, fieldname, &info) != GF_OK) { - /*VRML style*/ - if (!strnicmp(fieldname, "set_", 4)) { - if (gf_node_get_field_by_name(n, fieldname + 4, &info) != GF_OK) { - SMJS_FREE(c, fieldname); - return JS_TRUE; - } - } else { + return JS_TRUE; + } + } else { + if (gf_node_get_field_by_name(n, fieldname, &info) != GF_OK) { + /*VRML style*/ + if (!strnicmp(fieldname, "set_", 4)) { + if (gf_node_get_field_by_name(n, fieldname + 4, &info) != GF_OK) { SMJS_FREE(c, fieldname); return JS_TRUE; } + } else { + SMJS_FREE(c, fieldname); + return JS_TRUE; } } - SMJS_FREE(c, fieldname); + } + SMJS_FREE(c, fieldname); - if (gf_node_get_tag(n)==TAG_ProtoNode) - gf_sg_proto_mark_field_loaded(n, &info); + if (gf_node_get_tag(n)==TAG_ProtoNode) + gf_sg_proto_mark_field_loaded(n, &info); - gf_sg_script_to_node_field(c, *vp, &info, n, ptr); - } - return JS_TRUE; + gf_sg_script_to_node_field(c, *vp, &info, n, ptr); +} +return JS_TRUE; } static JSBool SMJS_FUNCTION(node_toString) { @@ -1697,12 +1721,12 @@ static JSBool SMJS_FUNCTION(node_getTime) /* Generic field destructor */ static DECL_FINALIZE(field_finalize) - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - JS_ObjectDestroyed(c, obj, ptr, 1); - if (!ptr) return; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +JS_ObjectDestroyed(c, obj, ptr, 1); +if (!ptr) return; - if (ptr->field_ptr) gf_sg_vrml_field_pointer_del(ptr->field_ptr, ptr->field.fieldType); - gf_free(ptr); +if (ptr->field_ptr) gf_sg_vrml_field_pointer_del(ptr->field_ptr, ptr->field.fieldType); +gf_free(ptr); } @@ -1747,88 +1771,104 @@ static JSBool SMJS_FUNCTION(SFImageConstructor) static SMJS_FUNC_PROP_GET(image_getProperty) - GF_ScriptPriv *priv = JS_GetScriptStack(c); - GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - SFImage *sfi; - if (!val) return JS_FALSE; - sfi = (SFImage*)val->field.far_ptr; - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = INT_TO_JSVAL( sfi->width ); break; - case 1: *vp = INT_TO_JSVAL( sfi->height); break; - case 2: *vp = INT_TO_JSVAL( sfi->numComponents ); break; - case 3: - { - u32 i, len; - JSObject *an_obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj); - len = sfi->width*sfi->height*sfi->numComponents; - for (i=0; ipixels[i]); - JS_SetElement(priv->js_ctx, an_obj, (jsint) i, &newVal); - } - } - break; - default: - return JS_TRUE; +GF_ScriptPriv *priv = JS_GetScriptStack(c); +GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +SFImage *sfi; +if (!val) return JS_FALSE; +sfi = (SFImage*)val->field.far_ptr; +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = INT_TO_JSVAL( sfi->width ); + break; + case 1: + *vp = INT_TO_JSVAL( sfi->height); + break; + case 2: + *vp = INT_TO_JSVAL( sfi->numComponents ); + break; + case 3: + { + u32 i, len; + JSObject *an_obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj); + len = sfi->width*sfi->height*sfi->numComponents; + for (i=0; ipixels[i]); + JS_SetElement(priv->js_ctx, an_obj, (jsint) i, &newVal); } } - return JS_TRUE; + break; + default: + return JS_TRUE; + } +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( image_setProperty) - u32 ival; - Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - SFImage *sfi; +u32 ival; +Bool changed = 0; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +SFImage *sfi; - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } - sfi = (SFImage*)ptr->field.far_ptr; - - if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 4) { - switch (SMJS_ID_TO_INT(id)) { - case 0: - ival = JSVAL_TO_INT(*vp); - changed = ! (sfi->width == ival); - sfi->width = ival; - if (changed && sfi->pixels) { gf_free(sfi->pixels); sfi->pixels = NULL; } - break; - case 1: - ival = JSVAL_TO_INT(*vp); - changed = ! (sfi->height == ival); - sfi->height = ival; - if (changed && sfi->pixels) { gf_free(sfi->pixels); sfi->pixels = NULL; } - break; - case 2: - ival = JSVAL_TO_INT(*vp); - changed = ! (sfi->numComponents == ival); - sfi->numComponents = ival; - if (changed && sfi->pixels) { gf_free(sfi->pixels); sfi->pixels = NULL; } - break; - case 3: - { - MFInt32 *pixels; - u32 len, i; - if (!JSVAL_IS_OBJECT(*vp) || !GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->MFInt32Class, NULL)) return JS_FALSE; - pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr; - if (sfi->pixels) gf_free(sfi->pixels); - len = sfi->width*sfi->height*sfi->numComponents; - sfi->pixels = (unsigned char *) gf_malloc(sizeof(char)*len); - len = MAX(len, pixels->count); - for (i=0; ipixels[i] = (u8) pixels->vals[i]; - changed = 1; - break; +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} +sfi = (SFImage*)ptr->field.far_ptr; + +if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 4) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + ival = JSVAL_TO_INT(*vp); + changed = ! (sfi->width == ival); + sfi->width = ival; + if (changed && sfi->pixels) { + gf_free(sfi->pixels); + sfi->pixels = NULL; } - default: return JS_FALSE; + break; + case 1: + ival = JSVAL_TO_INT(*vp); + changed = ! (sfi->height == ival); + sfi->height = ival; + if (changed && sfi->pixels) { + gf_free(sfi->pixels); + sfi->pixels = NULL; } - if (changed) Script_FieldChanged(c, NULL, ptr, NULL); - return JS_TRUE; - } - return JS_FALSE; + break; + case 2: + ival = JSVAL_TO_INT(*vp); + changed = ! (sfi->numComponents == ival); + sfi->numComponents = ival; + if (changed && sfi->pixels) { + gf_free(sfi->pixels); + sfi->pixels = NULL; + } + break; + case 3: + { + MFInt32 *pixels; + u32 len, i; + if (!JSVAL_IS_OBJECT(*vp) || !GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->MFInt32Class, NULL)) return JS_FALSE; + pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr; + if (sfi->pixels) gf_free(sfi->pixels); + len = sfi->width*sfi->height*sfi->numComponents; + sfi->pixels = (unsigned char *) gf_malloc(sizeof(char)*len); + len = MAX(len, pixels->count); + for (i=0; ipixels[i] = (u8) pixels->vals[i]; + changed = 1; + break; + } + default: + return JS_FALSE; + } + if (changed) Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} +return JS_FALSE; } /*SFVec2f class functions */ @@ -1857,51 +1897,56 @@ static JSBool SMJS_FUNCTION(SFVec2fConstructor) } static SMJS_FUNC_PROP_GET(vec2f_getProperty) - GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec2f*)val->field.far_ptr)->x)); break; - case 1: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec2f*)val->field.far_ptr)->y)); break; - default: return JS_TRUE; - } +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec2f*)val->field.far_ptr)->x)); + break; + case 1: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec2f*)val->field.far_ptr)->y)); + break; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(vec2f_setProperty) - jsdouble d; - Fixed v; - Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +jsdouble d; +Fixed v; +Bool changed = 0; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} - if (SMJS_ID_IS_INT(id)) { - JS_ValueToNumber(c, *vp, &d); - switch (SMJS_ID_TO_INT(id)) { - case 0: - v = FLT2FIX( d); - changed = ! ( ((SFVec2f*)ptr->field.far_ptr)->x == v); - ((SFVec2f*)ptr->field.far_ptr)->x = v; - break; - case 1: - v = FLT2FIX( d); - changed = ! ( ((SFVec2f*)ptr->field.far_ptr)->y == v); - ((SFVec2f*)ptr->field.far_ptr)->y = v; - break; - default: - return JS_TRUE; - } - if (changed) Script_FieldChanged(c, NULL, ptr, NULL); +if (SMJS_ID_IS_INT(id)) { + JS_ValueToNumber(c, *vp, &d); + switch (SMJS_ID_TO_INT(id)) { + case 0: + v = FLT2FIX( d); + changed = ! ( ((SFVec2f*)ptr->field.far_ptr)->x == v); + ((SFVec2f*)ptr->field.far_ptr)->x = v; + break; + case 1: + v = FLT2FIX( d); + changed = ! ( ((SFVec2f*)ptr->field.far_ptr)->y == v); + ((SFVec2f*)ptr->field.far_ptr)->y = v; + break; + default: return JS_TRUE; - } - return JS_FALSE; + } + if (changed) Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} +return JS_FALSE; } static JSBool SMJS_FUNCTION(vec2f_add) @@ -1914,7 +1959,7 @@ static JSBool SMJS_FUNCTION(vec2f_add) return JS_FALSE; v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; pNew = JS_NewObject(c, &js_rt->SFVec2fClass._class, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); @@ -1930,7 +1975,7 @@ static JSBool SMJS_FUNCTION(vec2f_subtract) return JS_FALSE; v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; pNew = JS_NewObject(c, &js_rt->SFVec2fClass._class, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); @@ -2013,7 +2058,7 @@ static JSBool SMJS_FUNCTION(vec2f_dot) return JS_FALSE; v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT( gf_mulfix(v1->x, v2->x) + gf_mulfix(v1->y, v2->y) ) ) ); return JS_TRUE; } @@ -2047,53 +2092,61 @@ static JSBool SMJS_FUNCTION(SFVec3fConstructor) } static SMJS_FUNC_PROP_GET(vec3f_getProperty) - GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->x) ); break; - case 1: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->y) ); break; - case 2: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->z) ); break; - default: return JS_TRUE; - } +GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->x) ); + break; + case 1: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->y) ); + break; + case 2: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->z) ); + break; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( vec3f_setProperty ) - jsdouble d; - Fixed v; - Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +jsdouble d; +Fixed v; +Bool changed = 0; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} - if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 3 && JS_ValueToNumber(c, *vp, &d)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: - v = FLT2FIX( d); - changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->x == v); - ((SFVec3f*)ptr->field.far_ptr)->x = v; - break; - case 1: - v = FLT2FIX( d); - changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->y == v); - ((SFVec3f*)ptr->field.far_ptr)->y = v; - break; - case 2: - v = FLT2FIX( d); - changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->z == v); - ((SFVec3f*)ptr->field.far_ptr)->z = v; - break; - default: return JS_TRUE; - } - if (changed) Script_FieldChanged(c, NULL, ptr, NULL); +if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 3 && JS_ValueToNumber(c, *vp, &d)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + v = FLT2FIX( d); + changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->x == v); + ((SFVec3f*)ptr->field.far_ptr)->x = v; + break; + case 1: + v = FLT2FIX( d); + changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->y == v); + ((SFVec3f*)ptr->field.far_ptr)->y = v; + break; + case 2: + v = FLT2FIX( d); + changed = ! ( ((SFVec3f*)ptr->field.far_ptr)->z == v); + ((SFVec3f*)ptr->field.far_ptr)->z = v; + break; + default: return JS_TRUE; - } - return JS_FALSE; + } + if (changed) Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} +return JS_FALSE; } static JSBool SMJS_FUNCTION(vec3f_add) { @@ -2105,7 +2158,7 @@ static JSBool SMJS_FUNCTION(vec3f_add) return JS_FALSE; v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; pNew = JS_NewObject(c, &js_rt->SFVec3fClass._class, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y, v1->z + v2->z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); @@ -2121,7 +2174,7 @@ static JSBool SMJS_FUNCTION(vec3f_subtract) return JS_FALSE; v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; pNew = JS_NewObject(c, &js_rt->SFVec3fClass._class, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y, v1->z - v2->z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); @@ -2204,7 +2257,7 @@ static JSBool SMJS_FUNCTION(vec3f_dot) return JS_FALSE; v1 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(gf_vec_dot(v1, v2)) ) ); return JS_TRUE; } @@ -2218,7 +2271,7 @@ static JSBool SMJS_FUNCTION(vec3f_cross) return JS_FALSE; v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; - v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; pNew = JS_NewObject(c, &js_rt->SFVec3fClass._class, 0, SMJS_GET_PARENT(c, obj)); v3 = gf_vec_cross(v1, v2); SFVec3f_Create(c, pNew, v3.x, v3.y, v3.z); @@ -2285,67 +2338,77 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor) dot = gf_divfix(gf_vec_dot(v1, v2), gf_mulfix(l1, l2) ); a = gf_atan2(gf_sqrt(FIX_ONE - gf_mulfix(dot, dot)), dot); SFRotation_Create(c, obj, gf_mulfix(v1.y, v2.z) - gf_mulfix(v2.y, v1.z), - gf_mulfix(v1.z, v2.x) - gf_mulfix(v2.z, v1.x), - gf_mulfix(v1.x, v2.y) - gf_mulfix(v2.x, v1.y), - FLT2FIX(a)); + gf_mulfix(v1.z, v2.x) - gf_mulfix(v2.z, v1.x), + gf_mulfix(v1.x, v2.y) - gf_mulfix(v2.x, v1.y), + FLT2FIX(a)); return JS_TRUE; } static SMJS_FUNC_PROP_GET(rot_getProperty) - GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->x)); break; - case 1: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->y)); break; - case 2: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->z)); break; - case 3: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->q)); break; - default: return JS_TRUE; - } +GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->x)); + break; + case 1: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->y)); + break; + case 2: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->z)); + break; + case 3: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->q)); + break; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET( rot_setProperty ) - jsdouble d; - Fixed v; - Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +jsdouble d; +Fixed v; +Bool changed = 0; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} - if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 4 && JS_ValueToNumber(c, *vp, &d)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: - v = FLT2FIX(d); - changed = ! ( ((SFRotation*)ptr->field.far_ptr)->x == v); - ((SFRotation*)ptr->field.far_ptr)->x = v; - break; - case 1: - v = FLT2FIX(d); - changed = ! ( ((SFRotation*)ptr->field.far_ptr)->y == v); - ((SFRotation*)ptr->field.far_ptr)->y = v; - break; - case 2: - v = FLT2FIX(d); - changed = ! ( ((SFRotation*)ptr->field.far_ptr)->z == v); - ((SFRotation*)ptr->field.far_ptr)->z = v; - break; - case 3: - v = FLT2FIX(d); - changed = ! ( ((SFRotation*)ptr->field.far_ptr)->q == v); - ((SFRotation*)ptr->field.far_ptr)->q = v; - break; - default: return JS_TRUE; - } - if (changed) Script_FieldChanged(c, NULL, ptr, NULL); +if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 4 && JS_ValueToNumber(c, *vp, &d)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + v = FLT2FIX(d); + changed = ! ( ((SFRotation*)ptr->field.far_ptr)->x == v); + ((SFRotation*)ptr->field.far_ptr)->x = v; + break; + case 1: + v = FLT2FIX(d); + changed = ! ( ((SFRotation*)ptr->field.far_ptr)->y == v); + ((SFRotation*)ptr->field.far_ptr)->y = v; + break; + case 2: + v = FLT2FIX(d); + changed = ! ( ((SFRotation*)ptr->field.far_ptr)->z == v); + ((SFRotation*)ptr->field.far_ptr)->z = v; + break; + case 3: + v = FLT2FIX(d); + changed = ! ( ((SFRotation*)ptr->field.far_ptr)->q == v); + ((SFRotation*)ptr->field.far_ptr)->q = v; + break; + default: return JS_TRUE; - } - return JS_FALSE; + } + if (changed) Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} +return JS_FALSE; } static JSBool SMJS_FUNCTION(rot_getAxis) { @@ -2433,8 +2496,8 @@ static JSBool SMJS_FUNCTION(rot_setAxis) v = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - r->x = v.x; - r->y = v.y; + r->x = v.x; + r->y = v.y; r->z = v.z; Script_FieldChanged(c, NULL, ptr, NULL); return JS_TRUE; @@ -2492,54 +2555,61 @@ static JSBool SMJS_FUNCTION(SFColorConstructor) } static SMJS_FUNC_PROP_GET( color_getProperty ) - GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->red)); break; - case 1: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->green)); break; - case 2: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->blue)); break; - default: return JS_TRUE; - } +GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (SMJS_ID_IS_INT(id)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->red)); + break; + case 1: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->green)); + break; + case 2: + *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->blue)); + break; + default: + return JS_TRUE; } - return JS_TRUE; +} +return JS_TRUE; } static SMJS_FUNC_PROP_SET(color_setProperty) - jsdouble d; - Fixed v; - Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*this is the prototype*/ - if (!ptr) { - if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; - return JS_TRUE; - } +jsdouble d; +Fixed v; +Bool changed = 0; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +/*this is the prototype*/ +if (!ptr) { + if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; + return JS_TRUE; +} - if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 3 && JS_ValueToNumber(c, *vp, &d)) { - switch (SMJS_ID_TO_INT(id)) { - case 0: - v = FLT2FIX(d); - changed = ! ( ((SFColor*)ptr->field.far_ptr)->red == v); - ((SFColor*)ptr->field.far_ptr)->red = v; - break; - case 1: - v = FLT2FIX(d); - changed = ! ( ((SFColor*)ptr->field.far_ptr)->green == v); - ((SFColor*)ptr->field.far_ptr)->green = v; - break; - case 2: - v = FLT2FIX(d); - changed = ! ( ((SFColor*)ptr->field.far_ptr)->blue == v); - ((SFColor*)ptr->field.far_ptr)->blue = v; - break; - default: - return JS_TRUE; - } - if (changed) Script_FieldChanged(c, NULL, ptr, NULL); +if (SMJS_ID_IS_INT(id) && SMJS_ID_TO_INT(id) >= 0 && SMJS_ID_TO_INT(id) < 3 && JS_ValueToNumber(c, *vp, &d)) { + switch (SMJS_ID_TO_INT(id)) { + case 0: + v = FLT2FIX(d); + changed = ! ( ((SFColor*)ptr->field.far_ptr)->red == v); + ((SFColor*)ptr->field.far_ptr)->red = v; + break; + case 1: + v = FLT2FIX(d); + changed = ! ( ((SFColor*)ptr->field.far_ptr)->green == v); + ((SFColor*)ptr->field.far_ptr)->green = v; + break; + case 2: + v = FLT2FIX(d); + changed = ! ( ((SFColor*)ptr->field.far_ptr)->blue == v); + ((SFColor*)ptr->field.far_ptr)->blue = v; + break; + default: return JS_TRUE; - } - return JS_FALSE; + } + if (changed) Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} +return JS_FALSE; } static JSBool SMJS_FUNCTION(color_setHSV) { @@ -2600,7 +2670,7 @@ static void setup_js_array(JSContext *c, JSObject *obj, GF_JSField *ptr, uintN a SMJS_SET_PRIVATE(c, obj, ptr); \ SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); \ return obj == 0 ? JS_FALSE : JS_TRUE; \ - + static JSBool SMJS_FUNCTION(MFBoolConstructor) { MFARRAY_CONSTRUCTOR(&js_rt->MFBoolClass, GF_SG_VRML_MFBOOL); @@ -2659,328 +2729,350 @@ static void array_finalize_ex(JSContext *c, JSObject *obj, Bool is_js_call) static DECL_FINALIZE(array_finalize) - array_finalize_ex(c, obj, 1); +array_finalize_ex(c, obj, 1); } static SMJS_FUNC_PROP_GET( array_getElement ) - u32 i; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (SMJS_ID_IS_INT(id)) { - i = SMJS_ID_TO_INT(id); - if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { - GF_Node *node = gf_node_list_get_child(*(GF_ChildNodeItem **)ptr->field.far_ptr, i); - JSObject *anobj = node ? node_get_binding(JS_GetScriptStack(c), node, 0) : NULL; - if (anobj) *vp = OBJECT_TO_JSVAL(anobj); - } else { - JS_GetElement(c, ptr->js_list, (jsint) i, vp); - } +u32 i; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (SMJS_ID_IS_INT(id)) { + i = SMJS_ID_TO_INT(id); + if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { + GF_Node *node = gf_node_list_get_child(*(GF_ChildNodeItem **)ptr->field.far_ptr, i); + JSObject *anobj = node ? node_get_binding(JS_GetScriptStack(c), node, 0) : NULL; + if (anobj) *vp = OBJECT_TO_JSVAL(anobj); + } else { + JS_GetElement(c, ptr->js_list, (jsint) i, vp); } - return JS_TRUE; +} +return JS_TRUE; } //this could be overloaded for each MF type... static SMJS_FUNC_PROP_SET(array_setElement) - u32 ind; - jsuint len; - jsdouble d; - GF_JSField *from; - JSBool ret; - GF_JSClass *the_sf_class = NULL; - JSString *str; - char *str_val; - void *sf_slot; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - ind = SMJS_ID_TO_INT(id); - - ret = JS_GetArrayLength(c, ptr->js_list, &len); +u32 ind; +jsuint len; +jsdouble d; +GF_JSField *from; +JSBool ret; +GF_JSClass *the_sf_class = NULL; +JSString *str; +char *str_val; +void *sf_slot; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +ind = SMJS_ID_TO_INT(id); + +ret = JS_GetArrayLength(c, ptr->js_list, &len); +if (ret==JS_FALSE) return JS_FALSE; + +if (gf_sg_vrml_is_sf_field(ptr->field.fieldType)) return JS_FALSE; + + +switch (ptr->field.fieldType) { +case GF_SG_VRML_MFVEC2F: + the_sf_class = &js_rt->SFVec2fClass; + break; +case GF_SG_VRML_MFVEC3F: + the_sf_class = &js_rt->SFVec3fClass; + break; +case GF_SG_VRML_MFCOLOR: + the_sf_class = &js_rt->SFColorClass; + break; +case GF_SG_VRML_MFROTATION: + the_sf_class = &js_rt->SFRotationClass; + break; +} +/*dynamic expend*/ +if (ind>=len) { + ret = JS_SetArrayLength(c, ptr->js_list, len+1); if (ret==JS_FALSE) return JS_FALSE; - - if (gf_sg_vrml_is_sf_field(ptr->field.fieldType)) return JS_FALSE; - - - switch (ptr->field.fieldType) { - case GF_SG_VRML_MFVEC2F: the_sf_class = &js_rt->SFVec2fClass; break; - case GF_SG_VRML_MFVEC3F: the_sf_class = &js_rt->SFVec3fClass; break; - case GF_SG_VRML_MFCOLOR: the_sf_class = &js_rt->SFColorClass; break; - case GF_SG_VRML_MFROTATION: the_sf_class = &js_rt->SFRotationClass; break; - } - /*dynamic expend*/ - if (ind>=len) { - ret = JS_SetArrayLength(c, ptr->js_list, len+1); - if (ret==JS_FALSE) return JS_FALSE; - while (lenfield.fieldType) { - case GF_SG_VRML_MFBOOL: - a_val = BOOLEAN_TO_JSVAL(0); - break; - case GF_SG_VRML_MFINT32: - a_val = INT_TO_JSVAL(0); - break; - case GF_SG_VRML_MFFLOAT: - case GF_SG_VRML_MFTIME: - a_val = JS_MAKE_DOUBLE(c, 0); - break; - case GF_SG_VRML_MFSTRING: - case GF_SG_VRML_MFURL: - a_val = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "") ); - break; - case GF_SG_VRML_MFVEC2F: - case GF_SG_VRML_MFVEC3F: - case GF_SG_VRML_MFCOLOR: - case GF_SG_VRML_MFROTATION: - a_val = OBJECT_TO_JSVAL( SMJS_CONSTRUCT_OBJECT(c, the_sf_class, obj) ); - break; - default: - a_val = INT_TO_JSVAL(0); - break; - } - - if (ptr->field.fieldType!=GF_SG_VRML_MFNODE) { - gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, len); - JS_SetElement(c, ptr->js_list, len, &a_val); - } - len++; + while (lenfield.fieldType) { + case GF_SG_VRML_MFBOOL: + a_val = BOOLEAN_TO_JSVAL(0); + break; + case GF_SG_VRML_MFINT32: + a_val = INT_TO_JSVAL(0); + break; + case GF_SG_VRML_MFFLOAT: + case GF_SG_VRML_MFTIME: + a_val = JS_MAKE_DOUBLE(c, 0); + break; + case GF_SG_VRML_MFSTRING: + case GF_SG_VRML_MFURL: + a_val = STRING_TO_JSVAL( JS_NewStringCopyZ(c, "") ); + break; + case GF_SG_VRML_MFVEC2F: + case GF_SG_VRML_MFVEC3F: + case GF_SG_VRML_MFCOLOR: + case GF_SG_VRML_MFROTATION: + a_val = OBJECT_TO_JSVAL( SMJS_CONSTRUCT_OBJECT(c, the_sf_class, obj) ); + break; + default: + a_val = INT_TO_JSVAL(0); + break; } - if (ptr->field.far_ptr && (ptr->field.fieldType!=GF_SG_VRML_MFNODE)) - gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, ind); - } - if (ptr->field.far_ptr && (ptr->field.fieldType!=GF_SG_VRML_MFNODE)) { - u32 items = ((GenMFField *)ptr->field.far_ptr)->count; - while (ind>=items) { - gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, ind); - items++; + if (ptr->field.fieldType!=GF_SG_VRML_MFNODE) { + gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, len); + JS_SetElement(c, ptr->js_list, len, &a_val); } + len++; } + if (ptr->field.far_ptr && (ptr->field.fieldType!=GF_SG_VRML_MFNODE)) + gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, ind); +} - /*assign object*/ - if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { - if (JSVAL_IS_VOID(*vp) || JSVAL_IS_NULL(*vp) || !GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - } else if (the_sf_class) { - if (JSVAL_IS_VOID(*vp)) return JS_FALSE; - if (!GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), the_sf_class, NULL) ) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFBOOL) { - if (!JSVAL_IS_BOOLEAN(*vp)) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFINT32) { - if (!JSVAL_IS_INT(*vp)) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFFLOAT) { - if (!JSVAL_IS_NUMBER(*vp)) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFTIME) { - if (!JSVAL_IS_NUMBER(*vp)) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFSTRING) { - if (!JSVAL_IS_STRING(*vp)) return JS_FALSE; - } else if (ptr->field.fieldType==GF_SG_VRML_MFURL) { - if (!JSVAL_IS_STRING(*vp)) return JS_FALSE; - } - - - /*rewrite MFNode entry*/ - if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { - GF_Node *prev_n, *new_n; - - if (!ptr->owner) return JS_TRUE; - - /*get new node*/ - from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - new_n = *(GF_Node**)from->field.far_ptr; +if (ptr->field.far_ptr && (ptr->field.fieldType!=GF_SG_VRML_MFNODE)) { + u32 items = ((GenMFField *)ptr->field.far_ptr)->count; + while (ind>=items) { + gf_sg_vrml_mf_insert(ptr->field.far_ptr, ptr->field.fieldType, &sf_slot, ind); + items++; + } +} -#if 0 - anobj = node_get_binding(JS_GetScriptStack(c), from->node, 0); +/*assign object*/ +if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { + if (JSVAL_IS_VOID(*vp) || JSVAL_IS_NULL(*vp) || !GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; +} else if (the_sf_class) { + if (JSVAL_IS_VOID(*vp)) return JS_FALSE; + if (!GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), the_sf_class, NULL) ) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFBOOL) { + if (!JSVAL_IS_BOOLEAN(*vp)) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFINT32) { + if (!JSVAL_IS_INT(*vp)) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFFLOAT) { + if (!JSVAL_IS_NUMBER(*vp)) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFTIME) { + if (!JSVAL_IS_NUMBER(*vp)) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFSTRING) { + if (!JSVAL_IS_STRING(*vp)) return JS_FALSE; +} else if (ptr->field.fieldType==GF_SG_VRML_MFURL) { + if (!JSVAL_IS_STRING(*vp)) return JS_FALSE; +} - /*add it to the new object if needed*/ - ret = JS_SetElement(c, ptr->js_list, ind, vp); -#endif - /*get and delete previous node if any, but unregister later*/ - prev_n = gf_node_list_del_child_idx( (GF_ChildNodeItem **)ptr->field.far_ptr, ind); +/*rewrite MFNode entry*/ +if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { + GF_Node *prev_n, *new_n; - if (new_n) { - gf_node_list_insert_child( (GF_ChildNodeItem **)ptr->field.far_ptr , new_n, ind); - gf_node_register(new_n, ptr->owner); + if (!ptr->owner) return JS_TRUE; - /*node created from script and inserted in the tree, root it*/ - if (!from->is_rooted) - node_get_binding(JS_GetScriptStack(c), new_n, 0); - } - /*unregister previous node*/ - if (prev_n) gf_node_unregister(prev_n, ptr->owner); + /*get new node*/ + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + new_n = *(GF_Node**)from->field.far_ptr; - Script_FieldChanged(c, NULL, ptr, NULL); - return JS_TRUE; - } +#if 0 + anobj = node_get_binding(JS_GetScriptStack(c), from->node, 0); + /*add it to the new object if needed*/ ret = JS_SetElement(c, ptr->js_list, ind, vp); - if (ret==JS_FALSE) return JS_FALSE; +#endif - if (!ptr->owner) return JS_TRUE; + /*get and delete previous node if any, but unregister later*/ + prev_n = gf_node_list_del_child_idx( (GF_ChildNodeItem **)ptr->field.far_ptr, ind); - /*rewrite MF slot*/ - switch (ptr->field.fieldType) { - case GF_SG_VRML_MFBOOL: - ((MFBool *)ptr->field.far_ptr)->vals[ind] = (Bool) JSVAL_TO_BOOLEAN(*vp); - break; - case GF_SG_VRML_MFINT32: - ((MFInt32 *)ptr->field.far_ptr)->vals[ind] = (s32) JSVAL_TO_INT(*vp); - break; - case GF_SG_VRML_MFFLOAT: - JS_ValueToNumber(c, *vp, &d); - ((MFFloat *)ptr->field.far_ptr)->vals[ind] = FLT2FIX(d); - break; - case GF_SG_VRML_MFTIME: - JS_ValueToNumber(c, *vp, &d); - ((MFTime *)ptr->field.far_ptr)->vals[ind] = d; - break; - case GF_SG_VRML_MFSTRING: - if (((MFString *)ptr->field.far_ptr)->vals[ind]) { - gf_free(((MFString *)ptr->field.far_ptr)->vals[ind]); - ((MFString *)ptr->field.far_ptr)->vals[ind] = NULL; - } - str = JSVAL_IS_STRING(*vp) ? JSVAL_TO_STRING(*vp) : JS_ValueToString(c, *vp); - str_val = SMJS_CHARS_FROM_STRING(c, str); - ((MFString *)ptr->field.far_ptr)->vals[ind] = gf_strdup(str_val); - SMJS_FREE(c, str_val); - break; - - case GF_SG_VRML_MFURL: - if (((MFURL *)ptr->field.far_ptr)->vals[ind].url) { - gf_free(((MFURL *)ptr->field.far_ptr)->vals[ind].url); - ((MFURL *)ptr->field.far_ptr)->vals[ind].url = NULL; - } - str = JSVAL_IS_STRING(*vp) ? JSVAL_TO_STRING(*vp) : JS_ValueToString(c, *vp); - str_val = SMJS_CHARS_FROM_STRING(c, str); - ((MFURL *)ptr->field.far_ptr)->vals[ind].url = gf_strdup(str_val); - ((MFURL *)ptr->field.far_ptr)->vals[ind].OD_ID = 0; - SMJS_FREE(c, str_val); - break; + if (new_n) { + gf_node_list_insert_child( (GF_ChildNodeItem **)ptr->field.far_ptr , new_n, ind); + gf_node_register(new_n, ptr->owner); - case GF_SG_VRML_MFVEC2F: - from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - gf_sg_vrml_field_copy(& ((MFVec2f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); - break; - case GF_SG_VRML_MFVEC3F: - from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - gf_sg_vrml_field_copy(& ((MFVec3f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); - break; - case GF_SG_VRML_MFROTATION: - from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - gf_sg_vrml_field_copy(& ((MFRotation *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); - break; - case GF_SG_VRML_MFCOLOR: - from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); - gf_sg_vrml_field_copy(& ((MFColor *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); - break; + /*node created from script and inserted in the tree, root it*/ + if (!from->is_rooted) + node_get_binding(JS_GetScriptStack(c), new_n, 0); } + /*unregister previous node*/ + if (prev_n) gf_node_unregister(prev_n, ptr->owner); Script_FieldChanged(c, NULL, ptr, NULL); return JS_TRUE; } +ret = JS_SetElement(c, ptr->js_list, ind, vp); +if (ret==JS_FALSE) return JS_FALSE; + +if (!ptr->owner) return JS_TRUE; + +/*rewrite MF slot*/ +switch (ptr->field.fieldType) { +case GF_SG_VRML_MFBOOL: + ((MFBool *)ptr->field.far_ptr)->vals[ind] = (Bool) JSVAL_TO_BOOLEAN(*vp); + break; +case GF_SG_VRML_MFINT32: + ((MFInt32 *)ptr->field.far_ptr)->vals[ind] = (s32) JSVAL_TO_INT(*vp); + break; +case GF_SG_VRML_MFFLOAT: + JS_ValueToNumber(c, *vp, &d); + ((MFFloat *)ptr->field.far_ptr)->vals[ind] = FLT2FIX(d); + break; +case GF_SG_VRML_MFTIME: + JS_ValueToNumber(c, *vp, &d); + ((MFTime *)ptr->field.far_ptr)->vals[ind] = d; + break; +case GF_SG_VRML_MFSTRING: + if (((MFString *)ptr->field.far_ptr)->vals[ind]) { + gf_free(((MFString *)ptr->field.far_ptr)->vals[ind]); + ((MFString *)ptr->field.far_ptr)->vals[ind] = NULL; + } + str = JSVAL_IS_STRING(*vp) ? JSVAL_TO_STRING(*vp) : JS_ValueToString(c, *vp); + str_val = SMJS_CHARS_FROM_STRING(c, str); + ((MFString *)ptr->field.far_ptr)->vals[ind] = gf_strdup(str_val); + SMJS_FREE(c, str_val); + break; + +case GF_SG_VRML_MFURL: + if (((MFURL *)ptr->field.far_ptr)->vals[ind].url) { + gf_free(((MFURL *)ptr->field.far_ptr)->vals[ind].url); + ((MFURL *)ptr->field.far_ptr)->vals[ind].url = NULL; + } + str = JSVAL_IS_STRING(*vp) ? JSVAL_TO_STRING(*vp) : JS_ValueToString(c, *vp); + str_val = SMJS_CHARS_FROM_STRING(c, str); + ((MFURL *)ptr->field.far_ptr)->vals[ind].url = gf_strdup(str_val); + ((MFURL *)ptr->field.far_ptr)->vals[ind].OD_ID = 0; + SMJS_FREE(c, str_val); + break; + +case GF_SG_VRML_MFVEC2F: + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + gf_sg_vrml_field_copy(& ((MFVec2f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); + break; +case GF_SG_VRML_MFVEC3F: + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + gf_sg_vrml_field_copy(& ((MFVec3f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); + break; +case GF_SG_VRML_MFROTATION: + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + gf_sg_vrml_field_copy(& ((MFRotation *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); + break; +case GF_SG_VRML_MFCOLOR: + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)); + gf_sg_vrml_field_copy(& ((MFColor *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); + break; +} + +Script_FieldChanged(c, NULL, ptr, NULL); +return JS_TRUE; +} + static SMJS_FUNC_PROP_SET( array_setLength) - u32 len, i, sftype; - JSBool ret; - GF_JSClass *the_sf_class; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - if (!JSVAL_IS_INT(*vp) || JSVAL_TO_INT(*vp) < 0) return JS_FALSE; - /*avoids gcc warning*/ +u32 len, i, sftype; +JSBool ret; +GF_JSClass *the_sf_class; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +if (!JSVAL_IS_INT(*vp) || JSVAL_TO_INT(*vp) < 0) return JS_FALSE; +/*avoids gcc warning*/ #ifndef GPAC_CONFIG_DARWIN - if (!id) id=0; +if (!id) id=0; #endif - len = JSVAL_TO_INT(*vp); +len = JSVAL_TO_INT(*vp); - if (!len) { - if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { - gf_node_unregister_children(ptr->owner, *(GF_ChildNodeItem**)ptr->field.far_ptr); - *(GF_ChildNodeItem**)ptr->field.far_ptr = NULL; - } else { - gf_sg_vrml_mf_reset(ptr->field.far_ptr, ptr->field.fieldType); - } - JS_SetArrayLength(c, ptr->js_list, 0); - Script_FieldChanged(c, NULL, ptr, NULL); - return JS_TRUE; +if (!len) { + if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { + gf_node_unregister_children(ptr->owner, *(GF_ChildNodeItem**)ptr->field.far_ptr); + *(GF_ChildNodeItem**)ptr->field.far_ptr = NULL; + } else { + gf_sg_vrml_mf_reset(ptr->field.far_ptr, ptr->field.fieldType); } + JS_SetArrayLength(c, ptr->js_list, 0); + Script_FieldChanged(c, NULL, ptr, NULL); + return JS_TRUE; +} - ret = JS_SetArrayLength(c, ptr->js_list, len); - if (ret==JS_FALSE) return ret; +ret = JS_SetArrayLength(c, ptr->js_list, len); +if (ret==JS_FALSE) return ret; #if 0 - /*insert till index if needed*/ - if (ptr->field.fieldType != GF_SG_VRML_MFNODE) { - if (!ptr->field.far_ptr) ptr->field_ptr = ptr->field.far_ptr = gf_sg_vrml_field_pointer_new(ptr->field.fieldType); - gf_sg_vrml_mf_reset(ptr->field.far_ptr, ptr->field.fieldType); - gf_sg_vrml_mf_alloc(ptr->field.far_ptr, ptr->field.fieldType, len); - if (ptr->field_ptr) ptr->field_ptr = ptr->field.far_ptr; - } +/*insert till index if needed*/ +if (ptr->field.fieldType != GF_SG_VRML_MFNODE) { + if (!ptr->field.far_ptr) ptr->field_ptr = ptr->field.far_ptr = gf_sg_vrml_field_pointer_new(ptr->field.fieldType); + gf_sg_vrml_mf_reset(ptr->field.far_ptr, ptr->field.fieldType); + gf_sg_vrml_mf_alloc(ptr->field.far_ptr, ptr->field.fieldType, len); + if (ptr->field_ptr) ptr->field_ptr = ptr->field.far_ptr; +} #endif - the_sf_class = NULL; - switch (ptr->field.fieldType) { - case GF_SG_VRML_MFVEC2F: the_sf_class = &js_rt->SFVec2fClass; break; - case GF_SG_VRML_MFVEC3F: the_sf_class = &js_rt->SFVec3fClass; break; - case GF_SG_VRML_MFCOLOR: the_sf_class = &js_rt->SFColorClass; break; - case GF_SG_VRML_MFROTATION: the_sf_class = &js_rt->SFRotationClass; break; - case GF_SG_VRML_MFNODE: - { - u32 c = gf_node_list_get_count(*(GF_ChildNodeItem**)ptr->field.far_ptr); - while (len < c) { - GF_Node *n = gf_node_list_del_child_idx((GF_ChildNodeItem**)ptr->field.far_ptr, c-1); - if (n) gf_node_unregister(n, ptr->owner); - c--; - } - if (len>c) { - GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[VRML] MFARRAY EXPANSION NOT SUPPORTED!!!\n")); - } +the_sf_class = NULL; +switch (ptr->field.fieldType) { +case GF_SG_VRML_MFVEC2F: + the_sf_class = &js_rt->SFVec2fClass; + break; +case GF_SG_VRML_MFVEC3F: + the_sf_class = &js_rt->SFVec3fClass; + break; +case GF_SG_VRML_MFCOLOR: + the_sf_class = &js_rt->SFColorClass; + break; +case GF_SG_VRML_MFROTATION: + the_sf_class = &js_rt->SFRotationClass; + break; +case GF_SG_VRML_MFNODE: +{ + u32 c = gf_node_list_get_count(*(GF_ChildNodeItem**)ptr->field.far_ptr); + while (len < c) { + GF_Node *n = gf_node_list_del_child_idx((GF_ChildNodeItem**)ptr->field.far_ptr, c-1); + if (n) gf_node_unregister(n, ptr->owner); + c--; } - return JS_TRUE; + if (len>c) { + GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[VRML] MFARRAY EXPANSION NOT SUPPORTED!!!\n")); } - sftype = gf_sg_vrml_get_sf_type(ptr->field.fieldType); - for (i=0; ifield.fieldType); +for (i=0; ijs_list, i, &a_val); } - return JS_TRUE; + JS_SetElement(c, ptr->js_list, i, &a_val); +} +return JS_TRUE; } static SMJS_FUNC_PROP_GET( array_getLength) - JSBool ret; - jsuint len; - GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); - /*avoids gcc warning*/ +JSBool ret; +jsuint len; +GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); +/*avoids gcc warning*/ #ifndef GPAC_CONFIG_DARWIN - if (!id) id=0; +if (!id) id=0; #endif - if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { - len = gf_node_list_get_count(*(GF_ChildNodeItem **)ptr->field.far_ptr); - ret = JS_TRUE; - } else { - ret = JS_GetArrayLength(c, ptr->js_list, &len); - } - *vp = INT_TO_JSVAL(len); - return ret; +if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { + len = gf_node_list_get_count(*(GF_ChildNodeItem **)ptr->field.far_ptr); + ret = JS_TRUE; +} else { + ret = JS_GetArrayLength(c, ptr->js_list, &len); +} +*vp = INT_TO_JSVAL(len); +return ret; } @@ -3019,8 +3111,8 @@ static JSBool SMJS_FUNCTION(MFVec3fConstructor) u32 i; SMJS_ARGS GF_JSField *ptr; - SMJS_OBJ_CONSTRUCTOR(&js_rt->MFVec3fClass) - + SMJS_OBJ_CONSTRUCTOR(&js_rt->MFVec3fClass) + ptr = NewJSField(c); ptr->field.fieldType = GF_SG_VRML_MFVEC3F; setup_js_array(c, obj, ptr, 0, 0); @@ -3048,8 +3140,8 @@ static JSBool SMJS_FUNCTION(MFRotationConstructor) u32 i; SMJS_ARGS GF_JSField *ptr; - SMJS_OBJ_CONSTRUCTOR(&js_rt->MFRotationClass) - + SMJS_OBJ_CONSTRUCTOR(&js_rt->MFRotationClass) + ptr = NewJSField(c); ptr->field.fieldType = GF_SG_VRML_MFROTATION; setup_js_array(c, obj, ptr, 0, 0); @@ -3139,18 +3231,18 @@ static JSBool SMJS_FUNCTION(vrml_dom3_not_implemented) void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script) { JS_SETUP_CLASS(js_rt->globalClass, "global", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); JS_SETUP_CLASS(js_rt->AnyClass, "AnyClass", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); JS_SETUP_CLASS(js_rt->browserClass , "Browser", 0, - JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); + JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); #if 1 JS_SETUP_CLASS(js_rt->SFNodeClass, "SFNode", JSCLASS_HAS_PRIVATE, - node_getProperty, node_setProperty, node_finalize); + node_getProperty, node_setProperty, node_finalize); #else /*only used to debug JS_SETUP_CLASS at each of the numerous changes of JSAPI ............ */ memset(&js_rt->SFNodeClass, 0, sizeof(js_rt->SFNodeClass)); @@ -3168,52 +3260,52 @@ void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script) #endif JS_SETUP_CLASS(js_rt->SFVec2fClass , "SFVec2f", JSCLASS_HAS_PRIVATE, - vec2f_getProperty, vec2f_setProperty, field_finalize); + vec2f_getProperty, vec2f_setProperty, field_finalize); JS_SETUP_CLASS(js_rt->SFVec3fClass , "SFVec3f", JSCLASS_HAS_PRIVATE, - vec3f_getProperty, vec3f_setProperty, field_finalize); + vec3f_getProperty, vec3f_setProperty, field_finalize); JS_SETUP_CLASS(js_rt->SFRotationClass , "SFRotation", JSCLASS_HAS_PRIVATE, - rot_getProperty, rot_setProperty, field_finalize); + rot_getProperty, rot_setProperty, field_finalize); JS_SETUP_CLASS(js_rt->SFColorClass , "SFColor", JSCLASS_HAS_PRIVATE, - color_getProperty, color_setProperty, field_finalize); + color_getProperty, color_setProperty, field_finalize); JS_SETUP_CLASS(js_rt->SFImageClass , "SFImage", JSCLASS_HAS_PRIVATE, - image_getProperty, image_setProperty, field_finalize); + image_getProperty, image_setProperty, field_finalize); JS_SETUP_CLASS(js_rt->MFInt32Class , "MFInt32", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFBoolClass , "MFBool", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFTimeClass , "MFTime", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFFloatClass , "MFFloat", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFUrlClass , "MFUrl", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFStringClass , "MFString", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFNodeClass , "MFNode", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFVec2fClass , "MFVec2f", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFVec3fClass , "MFVec3f", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFRotationClass , "MFRotation", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SETUP_CLASS(js_rt->MFColorClass , "MFColor", JSCLASS_HAS_PRIVATE, - array_getElement, array_setElement, array_finalize); + array_getElement, array_setElement, array_finalize); JS_SetErrorReporter(sc->js_ctx, script_error); @@ -3242,25 +3334,25 @@ void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script) JS_DefineProperty(sc->js_ctx, sc->js_browser, "_this", PRIVATE_TO_JSVAL(script), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); { JSFunctionSpec browserFunctions[] = { - SMJS_FUNCTION_SPEC("getName", getName, 0), - SMJS_FUNCTION_SPEC("getVersion", getVersion, 0), - SMJS_FUNCTION_SPEC("getCurrentSpeed", getCurrentSpeed, 0), - SMJS_FUNCTION_SPEC("getCurrentFrameRate", getCurrentFrameRate, 0), - SMJS_FUNCTION_SPEC("getWorldURL", getWorldURL, 0), - SMJS_FUNCTION_SPEC("replaceWorld", replaceWorld, 1), - SMJS_FUNCTION_SPEC("addRoute", addRoute, 4), - SMJS_FUNCTION_SPEC("deleteRoute", deleteRoute, 4), - SMJS_FUNCTION_SPEC("loadURL", loadURL, 1), - SMJS_FUNCTION_SPEC("createVrmlFromString", createVrmlFromString, 1), - SMJS_FUNCTION_SPEC("setDescription", setDescription, 1), - SMJS_FUNCTION_SPEC("print", JSPrint, 1), - SMJS_FUNCTION_SPEC("getOption", getOption, 2), - SMJS_FUNCTION_SPEC("setOption", setOption, 3), - SMJS_FUNCTION_SPEC("getScript", getScript, 0), - SMJS_FUNCTION_SPEC("getProto", getProto, 0), - SMJS_FUNCTION_SPEC("loadScript", loadScript, 1), - SMJS_FUNCTION_SPEC("getElementById", getElementById, 1), - SMJS_FUNCTION_SPEC(0, 0, 0) + SMJS_FUNCTION_SPEC("getName", getName, 0), + SMJS_FUNCTION_SPEC("getVersion", getVersion, 0), + SMJS_FUNCTION_SPEC("getCurrentSpeed", getCurrentSpeed, 0), + SMJS_FUNCTION_SPEC("getCurrentFrameRate", getCurrentFrameRate, 0), + SMJS_FUNCTION_SPEC("getWorldURL", getWorldURL, 0), + SMJS_FUNCTION_SPEC("replaceWorld", replaceWorld, 1), + SMJS_FUNCTION_SPEC("addRoute", addRoute, 4), + SMJS_FUNCTION_SPEC("deleteRoute", deleteRoute, 4), + SMJS_FUNCTION_SPEC("loadURL", loadURL, 1), + SMJS_FUNCTION_SPEC("createVrmlFromString", createVrmlFromString, 1), + SMJS_FUNCTION_SPEC("setDescription", setDescription, 1), + SMJS_FUNCTION_SPEC("print", JSPrint, 1), + SMJS_FUNCTION_SPEC("getOption", getOption, 2), + SMJS_FUNCTION_SPEC("setOption", setOption, 3), + SMJS_FUNCTION_SPEC("getScript", getScript, 0), + SMJS_FUNCTION_SPEC("getProto", getProto, 0), + SMJS_FUNCTION_SPEC("loadScript", loadScript, 1), + SMJS_FUNCTION_SPEC("getElementById", getElementById, 1), + SMJS_FUNCTION_SPEC(0, 0, 0) }; JS_DefineFunctions(sc->js_ctx, sc->js_browser, browserFunctions); } @@ -3396,11 +3488,11 @@ void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script) GF_JS_InitClass(sc->js_ctx, sc->js_obj, 0, &js_rt->MFNodeClass, MFNodeConstructor, 0, MFArrayProp, MFArrayMethods, 0, 0); } -/* - cant get any doc specifying if these are supposed to be supported in MPEG4Script... - GF_JS_InitClass(sc->js_ctx, sc->js_obj, 0, &SFVec4fClass, SFVec4fConstructor, 0, SFVec4fProps, SFVec4fMethods, 0, 0); - GF_JS_InitClass(sc->js_ctx, sc->js_obj, 0, &MFVec4fClass, MFVec4fCons, 0, MFArrayProp, 0, 0, 0); -*/ + /* + cant get any doc specifying if these are supposed to be supported in MPEG4Script... + GF_JS_InitClass(sc->js_ctx, sc->js_obj, 0, &SFVec4fClass, SFVec4fConstructor, 0, SFVec4fProps, SFVec4fMethods, 0, 0); + GF_JS_InitClass(sc->js_ctx, sc->js_obj, 0, &MFVec4fClass, MFVec4fCons, 0, MFArrayProp, 0, 0, 0); + */ } @@ -3449,7 +3541,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF Script_FieldChanged(c, owner, parent, field); } return; - } + } case GF_SG_VRML_SFTIME: { if (JSVAL_IS_NUMBER(val) ) { @@ -3458,7 +3550,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF Script_FieldChanged(c, owner, parent, field); } return; - } + } case GF_SG_VRML_SFSTRING: { SFString *s = (SFString*)field->far_ptr; @@ -3589,20 +3681,20 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF //from here we handle only MF fields if ( !GF_JS_InstanceOf(c, obj, &js_rt->MFBoolClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFInt32Class, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFFloatClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFTimeClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFStringClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFUrlClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFVec2fClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFVec3fClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFRotationClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFColorClass, NULL) - && !GF_JS_InstanceOf(c, obj, &js_rt->MFNodeClass, NULL) -/* - && !GF_JS_InstanceOf(c, obj, &MFVec4fClass, NULL) -*/ - ) return; + && !GF_JS_InstanceOf(c, obj, &js_rt->MFInt32Class, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFFloatClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFTimeClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFStringClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFUrlClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFVec2fClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFVec3fClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFRotationClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFColorClass, NULL) + && !GF_JS_InstanceOf(c, obj, &js_rt->MFNodeClass, NULL) + /* + && !GF_JS_InstanceOf(c, obj, &MFVec4fClass, NULL) + */ + ) return; p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); @@ -3682,7 +3774,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF } SMJS_FREE(c, str_val); } - break; + break; case GF_SG_VRML_MFURL: { char *str_val; @@ -3694,7 +3786,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF mfu->vals[i].OD_ID = 0; SMJS_FREE(c, str_val); } - break; + break; case GF_SG_VRML_MFVEC2F: if ( JSVAL_IS_OBJECT(item) && GF_JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFVec2fClass, NULL) ) { @@ -3748,7 +3840,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; case GF_SG_VRML_MFINT32: { MFInt32 *f = (MFInt32 *) field->far_ptr; @@ -3759,7 +3851,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; case GF_SG_VRML_MFFLOAT: { MFFloat *f = (MFFloat *) field->far_ptr; @@ -3770,7 +3862,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; case GF_SG_VRML_MFTIME: { MFTime *f = (MFTime *) field->far_ptr; @@ -3781,7 +3873,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; case GF_SG_VRML_MFSTRING: { MFString *f = (MFString *) field->far_ptr; @@ -3793,7 +3885,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; case GF_SG_VRML_MFURL: { MFURL *f = (MFURL *) field->far_ptr; @@ -3811,61 +3903,61 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) i, &newVal); } } - break; + break; /* MFNode is tricky because in VRML/MPEG-4, SFNode are assigned by referenced, not copy. We therefore need to make sure we reuse existing SFNode object rather than blindly recreating them */ case GF_SG_VRML_MFNODE: - { + { #if 0 - GF_ChildNodeItem *f = *(GF_ChildNodeItem **) field->far_ptr; - u32 j; - jsuint count; - GF_List *temp_objs = gf_list_new(); + GF_ChildNodeItem *f = *(GF_ChildNodeItem **) field->far_ptr; + u32 j; + jsuint count; + GF_List *temp_objs = gf_list_new(); - /*1: find all existing objs for each node*/ - JS_GetArrayLength(priv->js_ctx, jsf->js_list, &count); + /*1: find all existing objs for each node*/ + JS_GetArrayLength(priv->js_ctx, jsf->js_list, &count); - /*this may introduce bugs when a child is being replaced through an update command, but it is way - too costly to handle in script*/ - if (gf_node_list_get_count(f)==count) return; + /*this may introduce bugs when a child is being replaced through an update command, but it is way + too costly to handle in script*/ + if (gf_node_list_get_count(f)==count) return; - fprintf(stderr, "rewriting MFNode cache\n"); - while (f) { - slot = NULL; - /*first look in the original array*/ - for (j=0; jjs_ctx, jsf->js_list, (jsint) j, &newVal); - an_obj = JSVAL_TO_OBJECT(newVal); - if (an_obj) slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj); - if (slot && (slot->node==f->node)) { - gf_list_add(temp_objs, an_obj); - break; - } - slot = NULL; - } - if (!slot) { - JSObject *an_obj = node_get_binding(priv, f->node, 0); + fprintf(stderr, "rewriting MFNode cache\n"); + while (f) { + slot = NULL; + /*first look in the original array*/ + for (j=0; jjs_ctx, jsf->js_list, (jsint) j, &newVal); + an_obj = JSVAL_TO_OBJECT(newVal); + if (an_obj) slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj); + if (slot && (slot->node==f->node)) { gf_list_add(temp_objs, an_obj); + break; } - f = f->next; + slot = NULL; } - /*2- and rewrite the final array*/ - count = gf_list_count(temp_objs); - if (JS_SetArrayLength(priv->js_ctx, jsf->js_list, count) != JS_TRUE) return; - for (j=0; jjs_ctx, an_obj); - newVal = OBJECT_TO_JSVAL(an_obj); - JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal); + if (!slot) { + JSObject *an_obj = node_get_binding(priv, f->node, 0); + gf_list_add(temp_objs, an_obj); } - gf_list_del(temp_objs); -#endif + f = f->next; } - break; + /*2- and rewrite the final array*/ + count = gf_list_count(temp_objs); + if (JS_SetArrayLength(priv->js_ctx, jsf->js_list, count) != JS_TRUE) return; + for (j=0; jjs_ctx, an_obj); + newVal = OBJECT_TO_JSVAL(an_obj); + JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal); + } + gf_list_del(temp_objs); +#endif + } + break; } jsf->field.NDTtype = 0; } @@ -3876,13 +3968,13 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj jsf = NewJSField(priv->js_ctx); \ jsf->owner = parent; \ if(parent) gf_node_get_field(parent, field->fieldIndex, &jsf->field); \ - + #define SETUP_MF_FIELD \ if (!obj) return JSVAL_NULL; \ jsf = (GF_JSField *) SMJS_GET_PRIVATE(priv->js_ctx, obj); \ jsf->owner = parent; \ if (parent) gf_node_get_field(parent, field->fieldIndex, &jsf->field); \ - + jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_Node *parent, Bool force_evaluate) @@ -3896,21 +3988,21 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No /*native types*/ switch (field->fieldType) { - case GF_SG_VRML_SFBOOL: + case GF_SG_VRML_SFBOOL: return BOOLEAN_TO_JSVAL( * ((SFBool *) field->far_ptr) ); case GF_SG_VRML_SFINT32: return INT_TO_JSVAL( * ((SFInt32 *) field->far_ptr)); - case GF_SG_VRML_SFFLOAT: + case GF_SG_VRML_SFFLOAT: return JS_MAKE_DOUBLE(priv->js_ctx, FIX2FLT(* ((SFFloat *) field->far_ptr) )); case GF_SG_VRML_SFTIME: return JS_MAKE_DOUBLE(priv->js_ctx, * ((SFTime *) field->far_ptr)); case GF_SG_VRML_SFSTRING: - { + { s = JS_NewStringCopyZ(priv->js_ctx, ((SFString *) field->far_ptr)->buffer); return STRING_TO_JSVAL( s ); - } + } case GF_SG_VRML_SFURL: - { + { SFURL *url = (SFURL *)field->far_ptr; if (url->OD_ID > 0) { char msg[30]; @@ -3920,7 +4012,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No s = JS_NewStringCopyZ(priv->js_ctx, (const char *) url->url); } return STRING_TO_JSVAL( s ); - } + } } @@ -3931,17 +4023,17 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No while ((jsf = gf_list_enum(parent->sgprivate->interact->js_binding->fields, &i))) { obj = jsf->obj; if ( - /*make sure we use the same JS context*/ - (jsf->js_ctx == priv->js_ctx) - && (jsf->owner == parent) + /*make sure we use the same JS context*/ + (jsf->js_ctx == priv->js_ctx) + && (jsf->owner == parent) #if 0 - && (jsf->field.fieldIndex == field->fieldIndex) - /*type check needed for MFNode entries*/ - && (jsf->field.fieldType==field->fieldType) + && (jsf->field.fieldIndex == field->fieldIndex) + /*type check needed for MFNode entries*/ + && (jsf->field.fieldType==field->fieldType) #else - && (jsf->field.far_ptr==field->far_ptr) + && (jsf->field.far_ptr==field->far_ptr) #endif - ) { + ) { GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[VRML JS] found cached jsobj %p (field %s) in script %s bank (%d entries)\n", obj, field->name, gf_node_get_log_name((GF_Node*)JS_GetScript(priv->js_ctx)), gf_list_count(priv->js_cache) ) ); if (!force_evaluate && !jsf->field.NDTtype) return OBJECT_TO_JSVAL(obj); @@ -3955,23 +4047,23 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[VRML JS] creating jsobj %s.%s\n", gf_node_get_name(parent), field->name) ); switch (field->fieldType) { - case GF_SG_VRML_SFVEC2F: + case GF_SG_VRML_SFVEC2F: SETUP_FIELD obj = JS_NewObject(priv->js_ctx, &js_rt->SFVec2fClass._class, 0, priv->js_obj); break; - case GF_SG_VRML_SFVEC3F: + case GF_SG_VRML_SFVEC3F: SETUP_FIELD obj = JS_NewObject(priv->js_ctx, &js_rt->SFVec3fClass._class, 0, priv->js_obj); break; - case GF_SG_VRML_SFROTATION: + case GF_SG_VRML_SFROTATION: SETUP_FIELD obj = JS_NewObject(priv->js_ctx, &js_rt->SFRotationClass._class, 0, priv->js_obj); break; - case GF_SG_VRML_SFCOLOR: + case GF_SG_VRML_SFCOLOR: SETUP_FIELD obj = JS_NewObject(priv->js_ctx, &js_rt->SFColorClass._class, 0, priv->js_obj); break; - case GF_SG_VRML_SFIMAGE: + case GF_SG_VRML_SFIMAGE: SETUP_FIELD obj = JS_NewObject(priv->js_ctx, &js_rt->SFImageClass._class, 0, priv->js_obj); break; @@ -4163,9 +4255,9 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No } //not supported - default: + default: return JSVAL_NULL; - } + } if (!obj) return JSVAL_NULL; //store field associated with object if needed @@ -4266,7 +4358,7 @@ static void JS_PreDestroy(GF_Node *node) GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[Script] Destroying script node %s", gf_node_get_log_name(node) )); - /*"shutdown" is no longer supported, as it is typically called when one of a parent node is destroyed through + /*"shutdown" is no longer supported, as it is typically called when one of a parent node is destroyed through a GC call. Calling JS_LookupProperty or JS_CallFunctionValue when GC is running will crash SpiderMonkey*/ #if 0 if (JS_LookupProperty(priv->js_ctx, priv->js_obj, "shutdown", &fval)) @@ -4275,7 +4367,7 @@ static void JS_PreDestroy(GF_Node *node) #endif gf_sg_lock_javascript(priv->js_ctx, 1); - + if (priv->event) gf_js_remove_root(priv->js_ctx, &priv->event, GF_JSGC_OBJECT); /*unprotect all cached objects from GC*/ @@ -4311,7 +4403,7 @@ static void JS_InitScriptFields(GF_ScriptPriv *priv, GF_Node *sc) GF_FieldInfo info; jsval val; - i=0; + i=0; while ((sf = gf_list_enum(priv->fields, &i))) { switch (sf->eventType) { @@ -4331,7 +4423,7 @@ static void JS_InitScriptFields(GF_ScriptPriv *priv, GF_Node *sc) JS_DefineProperty(priv->js_ctx, priv->js_obj, (const char *) sf->name, val, 0, 0, JSPROP_PERMANENT); break; } - } + } } void gf_js_vrml_flush_event_out(GF_Node *node, GF_ScriptPriv *priv) @@ -4385,7 +4477,7 @@ static void JS_EventIn(GF_Node *node, GF_FieldInfo *in_field) //locate function if (!JS_LookupProperty(priv->js_ctx, priv->js_obj, sf->name, &fval) || JSVAL_IS_VOID(fval) || - !JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, sf->name, &attr, &found) || found != JS_TRUE ){ + !JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, sf->name, &attr, &found) || found != JS_TRUE ) { gf_sg_lock_javascript(priv->js_ctx, 0); return; } @@ -4452,11 +4544,11 @@ static Bool vrml_js_load_script(M_Script *script, char *file, Bool primary_scrip if (ret==JS_FALSE) success = 0; if (success && primary_script - && JS_LookupProperty(priv->js_ctx, priv->js_obj, "initialize", &fval) && !JSVAL_IS_VOID(fval) - && JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, "initialize", &attr, &found) && found == JS_TRUE) { - - JS_CallFunctionValue(priv->js_ctx, priv->js_obj, fval, 0, NULL, &rval); - gf_js_vrml_flush_event_out((GF_Node *)script, priv); + && JS_LookupProperty(priv->js_ctx, priv->js_obj, "initialize", &fval) && !JSVAL_IS_VOID(fval) + && JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, "initialize", &attr, &found) && found == JS_TRUE) { + + JS_CallFunctionValue(priv->js_ctx, priv->js_obj, fval, 0, NULL, &rval); + gf_js_vrml_flush_event_out((GF_Node *)script, priv); } gf_free(jsscript); return success; @@ -4607,10 +4699,10 @@ static void JSScript_LoadVRML(GF_Node *node) if (ret==JS_TRUE) { /*call initialize if present*/ if (JS_LookupProperty(priv->js_ctx, priv->js_obj, "initialize", &fval) && !JSVAL_IS_VOID(fval) - && JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, "initialize", &attr, &found) && found == JS_TRUE) - + && JS_GetPropertyAttributes(priv->js_ctx, priv->js_obj, "initialize", &attr, &found) && found == JS_TRUE) + JS_CallFunctionValue(priv->js_ctx, priv->js_obj, fval, 0, NULL, &rval); - gf_js_vrml_flush_event_out(node, priv); + gf_js_vrml_flush_event_out(node, priv); } #endif @@ -4669,16 +4761,16 @@ static void JSScript_NodeModified(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo if (!info) { /*handle DOM case*/ - if ((node->sgprivate->tag>=GF_NODE_FIRST_PARENT_NODE_TAG) - && node->sgprivate->interact - && node->sgprivate->interact->js_binding - && node->sgprivate->interact->js_binding->node) + if ((node->sgprivate->tag>=GF_NODE_FIRST_PARENT_NODE_TAG) + && node->sgprivate->interact + && node->sgprivate->interact->js_binding + && node->sgprivate->interact->js_binding->node) { if (gf_list_del_item(sg->objects, node->sgprivate->interact->js_binding->node)>=0) { #ifndef GPAC_DISABLE_SVG gf_js_remove_root(sg->svg_js->js_ctx, &(node->sgprivate->interact->js_binding->node), GF_JSGC_OBJECT); - if (sg->svg_js->in_script) + if (sg->svg_js->in_script) sg->svg_js->force_gc = 1; else { @@ -4953,7 +5045,7 @@ Bool gf_sg_try_lock_javascript(struct JSContext *cx) #endif /* GPAC_HAS_SPIDERMONKEY */ -GF_Err gf_scene_execute_script(GF_SceneGraph *sg, const char *com) +GF_Err gf_scene_execute_script(GF_SceneGraph *sg, const char *com) { #ifdef GPAC_HAS_SPIDERMONKEY u32 tag; diff --git a/src/scenegraph/vrml_tools.c b/src/scenegraph/vrml_tools.c index 1ea8966..b70ca67 100644 --- a/src/scenegraph/vrml_tools.c +++ b/src/scenegraph/vrml_tools.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -42,17 +42,17 @@ Bool gf_node_in_table_by_tag(u32 tag, u32 NDTType) else if (tag<=GF_NODE_RANGE_LAST_MPEG4) { #ifndef GPAC_DISABLE_BIFS u32 i; - for (i=0;imax_defined_route_id = MAX(sg->max_defined_route_id, ID); } -u32 gf_sg_get_next_available_proto_id(GF_SceneGraph *sg) +u32 gf_sg_get_next_available_proto_id(GF_SceneGraph *sg) { u32 i, count; u32 ID = 0; @@ -236,7 +236,7 @@ GF_Err gf_node_insert_child(GF_Node *parent, GF_Node *new_child, s32 Position) } /*for V4Studio...*/ -GF_Err gf_node_remove_child(GF_Node *parent, GF_Node *toremove_child) +GF_Err gf_node_remove_child(GF_Node *parent, GF_Node *toremove_child) { if (!gf_node_list_del_child(& ((GF_ParentNode *) parent)->children, toremove_child)) return GF_BAD_PARAM; /*V4Studio doesn't handle DEF/USE properly yet...*/ @@ -476,74 +476,135 @@ static MFAttrRef *NewMFAttrRef() return tmp; } -void *gf_sg_vrml_field_pointer_new(u32 FieldType) +void *gf_sg_vrml_field_pointer_new(u32 FieldType) { switch (FieldType) { - case GF_SG_VRML_SFBOOL: return NewSFBool(); - case GF_SG_VRML_SFFLOAT: return NewSFFloat(); - case GF_SG_VRML_SFDOUBLE: return NewSFDouble(); - case GF_SG_VRML_SFTIME: return NewSFTime(); - case GF_SG_VRML_SFINT32: return NewSFInt32(); - case GF_SG_VRML_SFSTRING: return NewSFString(); - case GF_SG_VRML_SFVEC3F: return NewSFVec3f(); - case GF_SG_VRML_SFVEC2F: return NewSFVec2f(); - case GF_SG_VRML_SFVEC3D: return NewSFVec3d(); - case GF_SG_VRML_SFVEC2D: return NewSFVec2d(); - case GF_SG_VRML_SFCOLOR: return NewSFColor(); - case GF_SG_VRML_SFCOLORRGBA: return NewSFColorRGBA(); - case GF_SG_VRML_SFROTATION: return NewSFRotation(); - case GF_SG_VRML_SFIMAGE: return NewSFImage(); - case GF_SG_VRML_SFATTRREF: return NewSFAttrRef(); - case GF_SG_VRML_MFBOOL: return NewMFBool(); - case GF_SG_VRML_MFFLOAT: return NewMFFloat(); - case GF_SG_VRML_MFTIME: return NewMFTime(); - case GF_SG_VRML_MFINT32: return NewMFInt32(); - case GF_SG_VRML_MFSTRING: return NewMFString(); - case GF_SG_VRML_MFVEC3F: return NewMFVec3f(); - case GF_SG_VRML_MFVEC2F: return NewMFVec2f(); - case GF_SG_VRML_MFVEC3D: return NewMFVec3d(); - case GF_SG_VRML_MFVEC2D: return NewMFVec2d(); - case GF_SG_VRML_MFCOLOR: return NewMFColor(); - case GF_SG_VRML_MFCOLORRGBA: return NewMFColorRGBA(); + case GF_SG_VRML_SFBOOL: + return NewSFBool(); + case GF_SG_VRML_SFFLOAT: + return NewSFFloat(); + case GF_SG_VRML_SFDOUBLE: + return NewSFDouble(); + case GF_SG_VRML_SFTIME: + return NewSFTime(); + case GF_SG_VRML_SFINT32: + return NewSFInt32(); + case GF_SG_VRML_SFSTRING: + return NewSFString(); + case GF_SG_VRML_SFVEC3F: + return NewSFVec3f(); + case GF_SG_VRML_SFVEC2F: + return NewSFVec2f(); + case GF_SG_VRML_SFVEC3D: + return NewSFVec3d(); + case GF_SG_VRML_SFVEC2D: + return NewSFVec2d(); + case GF_SG_VRML_SFCOLOR: + return NewSFColor(); + case GF_SG_VRML_SFCOLORRGBA: + return NewSFColorRGBA(); + case GF_SG_VRML_SFROTATION: + return NewSFRotation(); + case GF_SG_VRML_SFIMAGE: + return NewSFImage(); + case GF_SG_VRML_SFATTRREF: + return NewSFAttrRef(); + case GF_SG_VRML_MFBOOL: + return NewMFBool(); + case GF_SG_VRML_MFFLOAT: + return NewMFFloat(); + case GF_SG_VRML_MFTIME: + return NewMFTime(); + case GF_SG_VRML_MFINT32: + return NewMFInt32(); + case GF_SG_VRML_MFSTRING: + return NewMFString(); + case GF_SG_VRML_MFVEC3F: + return NewMFVec3f(); + case GF_SG_VRML_MFVEC2F: + return NewMFVec2f(); + case GF_SG_VRML_MFVEC3D: + return NewMFVec3d(); + case GF_SG_VRML_MFVEC2D: + return NewMFVec2d(); + case GF_SG_VRML_MFCOLOR: + return NewMFColor(); + case GF_SG_VRML_MFCOLORRGBA: + return NewMFColorRGBA(); case GF_SG_VRML_MFROTATION: case GF_SG_VRML_MFVEC4F: return NewMFRotation(); - case GF_SG_VRML_MFATTRREF: return NewMFAttrRef(); + case GF_SG_VRML_MFATTRREF: + return NewMFAttrRef(); //used in commands case GF_SG_VRML_SFCOMMANDBUFFER: return NewSFCommandBuffer(); - case GF_SG_VRML_SFURL: + case GF_SG_VRML_SFURL: return NewSFURL(); case GF_SG_VRML_MFURL: return NewMFURL(); - case GF_SG_VRML_SFSCRIPT: + case GF_SG_VRML_SFSCRIPT: return NewSFScript(); - case GF_SG_VRML_MFSCRIPT: + case GF_SG_VRML_MFSCRIPT: return NewMFScript(); } return NULL; } -void gf_sg_mfint32_del(MFInt32 par) { gf_free(par.vals); } -void gf_sg_mffloat_del(MFFloat par) { gf_free(par.vals); } -void gf_sg_mfdouble_del(MFDouble par) { gf_free(par.vals); } -void gf_sg_mfbool_del(MFBool par) { gf_free(par.vals); } -void gf_sg_mfcolor_del(MFColor par) { gf_free(par.vals); } -void gf_sg_mfcolor_rgba_del(MFColorRGBA par) { gf_free(par.vals); } -void gf_sg_mfrotation_del(MFRotation par) { gf_free(par.vals); } -void gf_sg_mftime_del(MFTime par) { gf_free(par.vals); } -void gf_sg_mfvec2f_del(MFVec2f par) { gf_free(par.vals); } -void gf_sg_mfvec2d_del(MFVec2d par) { gf_free(par.vals); } -void gf_sg_mfvec3f_del(MFVec3f par) { gf_free(par.vals); } -void gf_sg_mfvec3d_del(MFVec3d par) { gf_free(par.vals); } -void gf_sg_mfvec4f_del(MFVec4f par) { gf_free(par.vals); } -void gf_sg_mfattrref_del(MFAttrRef par) { gf_free(par.vals); } -void gf_sg_sfimage_del(SFImage im) { gf_free(im.pixels); } -void gf_sg_sfstring_del(SFString par) { if (par.buffer) gf_free(par.buffer); } -void gf_sg_sfscript_del(SFScript par) { if (par.script_text) gf_free(par.script_text); } +void gf_sg_mfint32_del(MFInt32 par) { + gf_free(par.vals); +} +void gf_sg_mffloat_del(MFFloat par) { + gf_free(par.vals); +} +void gf_sg_mfdouble_del(MFDouble par) { + gf_free(par.vals); +} +void gf_sg_mfbool_del(MFBool par) { + gf_free(par.vals); +} +void gf_sg_mfcolor_del(MFColor par) { + gf_free(par.vals); +} +void gf_sg_mfcolor_rgba_del(MFColorRGBA par) { + gf_free(par.vals); +} +void gf_sg_mfrotation_del(MFRotation par) { + gf_free(par.vals); +} +void gf_sg_mftime_del(MFTime par) { + gf_free(par.vals); +} +void gf_sg_mfvec2f_del(MFVec2f par) { + gf_free(par.vals); +} +void gf_sg_mfvec2d_del(MFVec2d par) { + gf_free(par.vals); +} +void gf_sg_mfvec3f_del(MFVec3f par) { + gf_free(par.vals); +} +void gf_sg_mfvec3d_del(MFVec3d par) { + gf_free(par.vals); +} +void gf_sg_mfvec4f_del(MFVec4f par) { + gf_free(par.vals); +} +void gf_sg_mfattrref_del(MFAttrRef par) { + gf_free(par.vals); +} +void gf_sg_sfimage_del(SFImage im) { + gf_free(im.pixels); +} +void gf_sg_sfstring_del(SFString par) { + if (par.buffer) gf_free(par.buffer); +} +void gf_sg_sfscript_del(SFScript par) { + if (par.script_text) gf_free(par.script_text); +} void gf_sg_sfcommand_del(SFCommandBuffer cb) @@ -557,15 +618,15 @@ void gf_sg_sfcommand_del(SFCommandBuffer cb) if (cb.buffer) gf_free(cb.buffer); } -void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType) +void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType) { GF_Node *node; switch (FieldType) { - case GF_SG_VRML_SFBOOL: + case GF_SG_VRML_SFBOOL: case GF_SG_VRML_SFFLOAT: case GF_SG_VRML_SFDOUBLE: - case GF_SG_VRML_SFTIME: + case GF_SG_VRML_SFTIME: case GF_SG_VRML_SFINT32: case GF_SG_VRML_SFVEC3F: case GF_SG_VRML_SFVEC3D: @@ -583,24 +644,24 @@ void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType) gf_sg_sfimage_del(* ((SFImage *)field)); break; - case GF_SG_VRML_SFNODE: + case GF_SG_VRML_SFNODE: node = *(GF_Node **) field; if (node) gf_node_del(node); return; case GF_SG_VRML_SFCOMMANDBUFFER: gf_sg_sfcommand_del(*(SFCommandBuffer *)field); break; - + case GF_SG_VRML_MFBOOL: gf_sg_mfbool_del( * ((MFBool *) field)); break; - case GF_SG_VRML_MFFLOAT: + case GF_SG_VRML_MFFLOAT: gf_sg_mffloat_del( * ((MFFloat *) field)); break; - case GF_SG_VRML_MFDOUBLE: + case GF_SG_VRML_MFDOUBLE: gf_sg_mfdouble_del( * ((MFDouble *) field)); break; - case GF_SG_VRML_MFTIME: + case GF_SG_VRML_MFTIME: gf_sg_mftime_del( * ((MFTime *)field)); break; case GF_SG_VRML_MFINT32: @@ -636,17 +697,17 @@ void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType) break; case GF_SG_VRML_MFURL: gf_sg_mfurl_del( * ((MFURL *) field)); - break; + break; case GF_SG_VRML_MFATTRREF: gf_sg_mfattrref_del( * ((MFAttrRef *) field)); - break; + break; //used only in proto since this field is created by default for regular nodes - case GF_SG_VRML_MFNODE: + case GF_SG_VRML_MFNODE: assert(0); return; case GF_SG_VRML_MFSCRIPT: gf_sg_mfscript_del( * ((MFScript *) field)); - break; + break; default: assert(0); @@ -664,11 +725,16 @@ GF_EXPORT const char *gf_sg_vrml_get_event_type_name(u32 EventType, Bool forX3D) { switch (EventType) { - case GF_SG_EVENT_IN: return forX3D ? "inputOnly" : "eventIn"; - case GF_SG_EVENT_FIELD: return forX3D ? "initializeOnly" : "field"; - case GF_SG_EVENT_EXPOSED_FIELD: return forX3D ? "inputOutput" : "exposedField"; - case GF_SG_EVENT_OUT: return forX3D ? "outputOnly" : "eventOut"; - default: return "unknownEvent"; + case GF_SG_EVENT_IN: + return forX3D ? "inputOnly" : "eventIn"; + case GF_SG_EVENT_FIELD: + return forX3D ? "initializeOnly" : "field"; + case GF_SG_EVENT_EXPOSED_FIELD: + return forX3D ? "inputOutput" : "exposedField"; + case GF_SG_EVENT_OUT: + return forX3D ? "outputOnly" : "eventOut"; + default: + return "unknownEvent"; } } @@ -677,46 +743,86 @@ const char *gf_sg_vrml_get_field_type_by_name(u32 FieldType) { switch (FieldType) { - case GF_SG_VRML_SFBOOL: return "SFBool"; - case GF_SG_VRML_SFFLOAT: return "SFFloat"; - case GF_SG_VRML_SFDOUBLE: return "SFDouble"; - case GF_SG_VRML_SFTIME: return "SFTime"; - case GF_SG_VRML_SFINT32: return "SFInt32"; - case GF_SG_VRML_SFSTRING: return "SFString"; - case GF_SG_VRML_SFVEC3F: return "SFVec3f"; - case GF_SG_VRML_SFVEC2F: return "SFVec2f"; - case GF_SG_VRML_SFVEC3D: return "SFVec3d"; - case GF_SG_VRML_SFVEC2D: return "SFVec2d"; - case GF_SG_VRML_SFCOLOR: return "SFColor"; - case GF_SG_VRML_SFCOLORRGBA: return "SFColorRGBA"; - case GF_SG_VRML_SFROTATION: return "SFRotation"; - case GF_SG_VRML_SFIMAGE: return "SFImage"; - case GF_SG_VRML_SFNODE: return "SFNode"; - case GF_SG_VRML_SFVEC4F: return "SFVec4f"; - case GF_SG_VRML_SFATTRREF: return "SFAttrRef"; - case GF_SG_VRML_MFBOOL: return "MFBool"; - case GF_SG_VRML_MFFLOAT: return "MFFloat"; - case GF_SG_VRML_MFDOUBLE: return "MFDouble"; - case GF_SG_VRML_MFTIME: return "MFTime"; - case GF_SG_VRML_MFINT32: return "MFInt32"; - case GF_SG_VRML_MFSTRING: return "MFString"; - case GF_SG_VRML_MFVEC3F: return "MFVec3f"; - case GF_SG_VRML_MFVEC2F: return "MFVec2f"; - case GF_SG_VRML_MFVEC3D: return "MFVec3d"; - case GF_SG_VRML_MFVEC2D: return "MFVec2d"; - case GF_SG_VRML_MFCOLOR: return "MFColor"; - case GF_SG_VRML_MFCOLORRGBA: return "MFColorRGBA"; - case GF_SG_VRML_MFROTATION: return "MFRotation"; - case GF_SG_VRML_MFIMAGE: return "MFImage"; - case GF_SG_VRML_MFNODE: return "MFNode"; - case GF_SG_VRML_MFVEC4F: return "MFVec4f"; - case GF_SG_VRML_SFURL: return "SFURL"; - case GF_SG_VRML_MFURL: return "MFURL"; - case GF_SG_VRML_MFATTRREF: return "MFAttrRef"; - case GF_SG_VRML_SFCOMMANDBUFFER: return "SFCommandBuffer"; - case GF_SG_VRML_SFSCRIPT: return "SFScript"; - case GF_SG_VRML_MFSCRIPT: return "MFScript"; - default: return "UnknownType"; + case GF_SG_VRML_SFBOOL: + return "SFBool"; + case GF_SG_VRML_SFFLOAT: + return "SFFloat"; + case GF_SG_VRML_SFDOUBLE: + return "SFDouble"; + case GF_SG_VRML_SFTIME: + return "SFTime"; + case GF_SG_VRML_SFINT32: + return "SFInt32"; + case GF_SG_VRML_SFSTRING: + return "SFString"; + case GF_SG_VRML_SFVEC3F: + return "SFVec3f"; + case GF_SG_VRML_SFVEC2F: + return "SFVec2f"; + case GF_SG_VRML_SFVEC3D: + return "SFVec3d"; + case GF_SG_VRML_SFVEC2D: + return "SFVec2d"; + case GF_SG_VRML_SFCOLOR: + return "SFColor"; + case GF_SG_VRML_SFCOLORRGBA: + return "SFColorRGBA"; + case GF_SG_VRML_SFROTATION: + return "SFRotation"; + case GF_SG_VRML_SFIMAGE: + return "SFImage"; + case GF_SG_VRML_SFNODE: + return "SFNode"; + case GF_SG_VRML_SFVEC4F: + return "SFVec4f"; + case GF_SG_VRML_SFATTRREF: + return "SFAttrRef"; + case GF_SG_VRML_MFBOOL: + return "MFBool"; + case GF_SG_VRML_MFFLOAT: + return "MFFloat"; + case GF_SG_VRML_MFDOUBLE: + return "MFDouble"; + case GF_SG_VRML_MFTIME: + return "MFTime"; + case GF_SG_VRML_MFINT32: + return "MFInt32"; + case GF_SG_VRML_MFSTRING: + return "MFString"; + case GF_SG_VRML_MFVEC3F: + return "MFVec3f"; + case GF_SG_VRML_MFVEC2F: + return "MFVec2f"; + case GF_SG_VRML_MFVEC3D: + return "MFVec3d"; + case GF_SG_VRML_MFVEC2D: + return "MFVec2d"; + case GF_SG_VRML_MFCOLOR: + return "MFColor"; + case GF_SG_VRML_MFCOLORRGBA: + return "MFColorRGBA"; + case GF_SG_VRML_MFROTATION: + return "MFRotation"; + case GF_SG_VRML_MFIMAGE: + return "MFImage"; + case GF_SG_VRML_MFNODE: + return "MFNode"; + case GF_SG_VRML_MFVEC4F: + return "MFVec4f"; + case GF_SG_VRML_SFURL: + return "SFURL"; + case GF_SG_VRML_MFURL: + return "MFURL"; + case GF_SG_VRML_MFATTRREF: + return "MFAttrRef"; + case GF_SG_VRML_SFCOMMANDBUFFER: + return "SFCommandBuffer"; + case GF_SG_VRML_SFSCRIPT: + return "SFScript"; + case GF_SG_VRML_MFSCRIPT: + return "MFScript"; + default: + return "UnknownType"; } } @@ -761,7 +867,9 @@ u32 gf_sg_field_type_by_name(char *fieldType) #endif -void gf_sg_sfurl_del(SFURL url) { if (url.url) gf_free(url.url); } +void gf_sg_sfurl_del(SFURL url) { + if (url.url) gf_free(url.url); +} GF_EXPORT Bool gf_sg_vrml_is_sf_field(u32 FieldType) @@ -934,7 +1042,7 @@ u32 gf_sg_vrml_get_sf_type(u32 FieldType) } // -// Insert (+alloc) an MFField with a specified position for insertion and sets the ptr to the +// Insert (+alloc) an MFField with a specified position for insertion and sets the ptr to the // newly created slot // !! Doesnt work for MFNodes // InsertAt is the 0-based index for the new slot @@ -948,10 +1056,10 @@ GF_Err gf_sg_vrml_mf_insert(void *mf, u32 FieldType, void **new_ptr, u32 InsertA if (FieldType == GF_SG_VRML_MFNODE) return GF_BAD_PARAM; FieldSize = gf_sg_vrml_get_sf_size(FieldType); - + //field we can't copy if (!FieldSize) return GF_BAD_PARAM; - + //first item ever if (!mffield->count || !mffield->array) { if (mffield->array) gf_free(mffield->array); @@ -1035,7 +1143,7 @@ GF_Err gf_sg_vrml_mf_alloc(void *mf, u32 FieldType, u32 NbItems) if (FieldType == GF_SG_VRML_MFNODE) return GF_BAD_PARAM; FieldSize = gf_sg_vrml_get_sf_size(FieldType); - + //field we can't copy if (!FieldSize) return GF_BAD_PARAM; if (NbItems>MAX_MFFIELD_ALLOC) return GF_IO_ERR; @@ -1061,7 +1169,7 @@ GF_Err gf_sg_vrml_mf_get_item(void *mf, u32 FieldType, void **new_ptr, u32 ItemP if (FieldType == GF_SG_VRML_MFNODE) return GF_BAD_PARAM; FieldSize = gf_sg_vrml_get_sf_size(FieldType); - + //field we can't copy if (!FieldSize) return GF_BAD_PARAM; if (ItemPos >= mffield->count) return GF_BAD_PARAM; @@ -1086,7 +1194,7 @@ GF_Err gf_sg_vrml_mf_remove(void *mf, u32 FieldType, u32 RemoveFrom) GenMFField *mffield = (GenMFField *)mf; FieldSize = gf_sg_vrml_get_sf_size(FieldType); - + //field we can't copy if (!FieldSize) return GF_BAD_PARAM; @@ -1122,7 +1230,7 @@ void VRML_FieldCopyCast(void *dest, u32 dst_field_type, void *orig, u32 ori_fiel u32 size, i, sf_type_ori, sf_type_dst; void *dst_field, *orig_field; if (!dest || !orig) return; - + switch (dst_field_type) { case GF_SG_VRML_SFSTRING: if (ori_field_type == GF_SG_VRML_SFURL) { @@ -1147,9 +1255,9 @@ void VRML_FieldCopyCast(void *dest, u32 dst_field_type, void *orig, u32 ori_fiel url = ((SFURL *)dest); url->OD_ID = 0; if (url->url) gf_free(url->url); - if ( ((SFString*)orig)->buffer) + if ( ((SFString*)orig)->buffer) url->url = gf_strdup(((SFString*)orig)->buffer); - else + else url->url = NULL; return; case GF_SG_VRML_MFSTRING: @@ -1228,7 +1336,7 @@ void gf_sg_vrml_field_clone(void *dest, void *orig, u32 field_type, GF_SceneGrap case GF_SG_VRML_SFURL: if ( ((SFURL *)dest)->url ) gf_free( ((SFURL *)dest)->url ); ((SFURL *)dest)->OD_ID = ((SFURL *)orig)->OD_ID; - if (((SFURL *)orig)->url) + if (((SFURL *)orig)->url) ((SFURL *)dest)->url = gf_strdup(((SFURL *)orig)->url); else ((SFURL *)dest)->url = NULL; @@ -1257,18 +1365,18 @@ void gf_sg_vrml_field_clone(void *dest, void *orig, u32 field_type, GF_SceneGrap cb_dst->buffer = NULL; /*clone command list*/ c2 = gf_list_count(cb_src->commandList); - for (j=0; jcommandList, j); GF_Command *new_com = gf_sg_vrml_command_clone(sub_com, inScene, 0); gf_list_add(cb_dst->commandList, new_com); } } } - break; + break; /*simply copy text string*/ case GF_SG_VRML_SFSCRIPT: - if (((SFScript*)dest)->script_text) gf_free(((SFScript*)dest)->script_text); + if (((SFScript*)dest)->script_text) gf_free(((SFScript*)dest)->script_text); ((SFScript*)dest)->script_text = NULL; if ( ((SFScript*)orig)->script_text) ((SFScript *)dest)->script_text = (char *)gf_strdup( (char*) ((SFScript*)orig)->script_text ); @@ -1437,9 +1545,9 @@ u32 gf_node_get_num_fields_in_mode(GF_Node *Node, u8 IndexMode) if (Node->sgprivate->tag == TAG_ProtoNode) return gf_sg_proto_get_num_fields(Node, IndexMode); else if ((Node->sgprivate->tag == TAG_MPEG4_Script) #ifndef GPAC_DISABLE_X3D - || (Node->sgprivate->tag == TAG_X3D_Script) + || (Node->sgprivate->tag == TAG_X3D_Script) #endif - ) + ) return gf_sg_script_get_num_fields(Node, IndexMode); else if (Node->sgprivate->tag <= GF_NODE_RANGE_LAST_MPEG4) return gf_sg_mpeg4_node_get_field_count(Node, IndexMode); #ifndef GPAC_DISABLE_X3D @@ -1481,31 +1589,31 @@ void InitTimeTrigger(GF_Node *n); Bool gf_sg_vrml_node_init(GF_Node *node) { switch (node->sgprivate->tag) { - case TAG_MPEG4_ColorInterpolator: + case TAG_MPEG4_ColorInterpolator: #ifndef GPAC_DISABLE_X3D case TAG_X3D_ColorInterpolator: #endif return InitColorInterpolator((M_ColorInterpolator *)node); - case TAG_MPEG4_CoordinateInterpolator: + case TAG_MPEG4_CoordinateInterpolator: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_CoordinateInterpolator: + case TAG_X3D_CoordinateInterpolator: #endif return InitCoordinateInterpolator((M_CoordinateInterpolator *)node); - case TAG_MPEG4_CoordinateInterpolator2D: + case TAG_MPEG4_CoordinateInterpolator2D: return InitCoordinateInterpolator2D((M_CoordinateInterpolator2D *)node); - case TAG_MPEG4_NormalInterpolator: + case TAG_MPEG4_NormalInterpolator: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_NormalInterpolator: + case TAG_X3D_NormalInterpolator: #endif return InitNormalInterpolator((M_NormalInterpolator*)node); - case TAG_MPEG4_OrientationInterpolator: + case TAG_MPEG4_OrientationInterpolator: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_OrientationInterpolator: + case TAG_X3D_OrientationInterpolator: #endif return InitOrientationInterpolator((M_OrientationInterpolator*)node); - case TAG_MPEG4_PositionInterpolator: + case TAG_MPEG4_PositionInterpolator: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_PositionInterpolator: + case TAG_X3D_PositionInterpolator: #endif return InitPositionInterpolator((M_PositionInterpolator *)node); case TAG_MPEG4_PositionInterpolator2D: @@ -1513,37 +1621,54 @@ Bool gf_sg_vrml_node_init(GF_Node *node) case TAG_X3D_PositionInterpolator2D: #endif return InitPositionInterpolator2D((M_PositionInterpolator2D *)node); - case TAG_MPEG4_ScalarInterpolator: + case TAG_MPEG4_ScalarInterpolator: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_ScalarInterpolator: + case TAG_X3D_ScalarInterpolator: #endif return InitScalarInterpolator((M_ScalarInterpolator *)node); case TAG_MPEG4_Valuator: return InitValuator((M_Valuator *)node); - case TAG_MPEG4_PositionAnimator: - PA_Init(node); return 1; - case TAG_MPEG4_PositionAnimator2D: - PA2D_Init(node); return 1; - case TAG_MPEG4_ScalarAnimator: - SA_Init(node); return 1; - case TAG_MPEG4_PositionInterpolator4D: + case TAG_MPEG4_PositionAnimator: + PA_Init(node); + return 1; + case TAG_MPEG4_PositionAnimator2D: + PA2D_Init(node); + return 1; + case TAG_MPEG4_ScalarAnimator: + SA_Init(node); + return 1; + case TAG_MPEG4_PositionInterpolator4D: return InitPositionInterpolator4D((M_PositionInterpolator4D *)node); - case TAG_MPEG4_CoordinateInterpolator4D: + case TAG_MPEG4_CoordinateInterpolator4D: return InitCoordinateInterpolator4D((M_CoordinateInterpolator4D *)node); - case TAG_MPEG4_Script: + case TAG_MPEG4_Script: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Script: + case TAG_X3D_Script: #endif return 1; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_BooleanFilter: InitBooleanFilter(node); return 1; - case TAG_X3D_BooleanSequencer: InitBooleanSequencer(node); return 1; - case TAG_X3D_BooleanToggle: InitBooleanToggle(node); return 1; - case TAG_X3D_BooleanTrigger: InitBooleanTrigger(node); return 1; - case TAG_X3D_IntegerSequencer: InitIntegerSequencer(node); return 1; - case TAG_X3D_IntegerTrigger: InitIntegerTrigger(node); return 1; - case TAG_X3D_TimeTrigger: InitTimeTrigger(node); return 1; + case TAG_X3D_BooleanFilter: + InitBooleanFilter(node); + return 1; + case TAG_X3D_BooleanSequencer: + InitBooleanSequencer(node); + return 1; + case TAG_X3D_BooleanToggle: + InitBooleanToggle(node); + return 1; + case TAG_X3D_BooleanTrigger: + InitBooleanTrigger(node); + return 1; + case TAG_X3D_IntegerSequencer: + InitIntegerSequencer(node); + return 1; + case TAG_X3D_IntegerTrigger: + InitIntegerTrigger(node); + return 1; + case TAG_X3D_TimeTrigger: + InitTimeTrigger(node); + return 1; #endif } return 0; @@ -1555,25 +1680,25 @@ Bool gf_sg_vrml_node_changed(GF_Node *node, GF_FieldInfo *field) case TAG_ProtoNode: /*hardcoded protos need modification notifs*/ if (node->sgprivate->UserCallback) return 0; - case TAG_MPEG4_ColorInterpolator: - case TAG_MPEG4_CoordinateInterpolator: - case TAG_MPEG4_CoordinateInterpolator2D: - case TAG_MPEG4_NormalInterpolator: - case TAG_MPEG4_OrientationInterpolator: - case TAG_MPEG4_PositionInterpolator: - case TAG_MPEG4_PositionInterpolator2D: - case TAG_MPEG4_ScalarInterpolator: + case TAG_MPEG4_ColorInterpolator: + case TAG_MPEG4_CoordinateInterpolator: + case TAG_MPEG4_CoordinateInterpolator2D: + case TAG_MPEG4_NormalInterpolator: + case TAG_MPEG4_OrientationInterpolator: + case TAG_MPEG4_PositionInterpolator: + case TAG_MPEG4_PositionInterpolator2D: + case TAG_MPEG4_ScalarInterpolator: case TAG_MPEG4_Valuator: case TAG_MPEG4_PositionInterpolator4D: case TAG_MPEG4_CoordinateInterpolator4D: case TAG_MPEG4_Script: #ifndef GPAC_DISABLE_X3D case TAG_X3D_ColorInterpolator: - case TAG_X3D_CoordinateInterpolator: - case TAG_X3D_NormalInterpolator: - case TAG_X3D_OrientationInterpolator: - case TAG_X3D_PositionInterpolator: - case TAG_X3D_ScalarInterpolator: + case TAG_X3D_CoordinateInterpolator: + case TAG_X3D_NormalInterpolator: + case TAG_X3D_OrientationInterpolator: + case TAG_X3D_PositionInterpolator: + case TAG_X3D_ScalarInterpolator: case TAG_X3D_Script: case TAG_X3D_BooleanFilter: case TAG_X3D_BooleanSequencer: @@ -1584,9 +1709,15 @@ Bool gf_sg_vrml_node_changed(GF_Node *node, GF_FieldInfo *field) case TAG_X3D_TimeTrigger: #endif return 1; - case TAG_MPEG4_PositionAnimator: PA_Modified(node, field); return 1; - case TAG_MPEG4_PositionAnimator2D: PA2D_Modified(node, field); return 1; - case TAG_MPEG4_ScalarAnimator: SA_Modified(node, field); return 1; + case TAG_MPEG4_PositionAnimator: + PA_Modified(node, field); + return 1; + case TAG_MPEG4_PositionAnimator2D: + PA2D_Modified(node, field); + return 1; + case TAG_MPEG4_ScalarAnimator: + SA_Modified(node, field); + return 1; } return 0; } diff --git a/src/scenegraph/webvtt_smjs.c b/src/scenegraph/webvtt_smjs.c index 55f39cd..72b7452 100644 --- a/src/scenegraph/webvtt_smjs.c +++ b/src/scenegraph/webvtt_smjs.c @@ -32,18 +32,18 @@ #include -GF_EXPORT -GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, - const char *start, const char *end, - const char *settings, - const char *payload) +GF_EXPORT +GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, + const char *start, const char *end, + const char *settings, + const char *payload) { GF_Err e; JSBool found; JSContext *c = node->sgprivate->scenegraph->svg_js->js_ctx; JSObject *global = node->sgprivate->scenegraph->svg_js->global; jsval fun_val; - + gf_sg_lock_javascript(c, GF_TRUE); found = JS_LookupProperty(c, global, "addCue", &fun_val); if (!found || JSVAL_IS_VOID(fun_val) || !JSVAL_IS_OBJECT(fun_val) ) { @@ -76,7 +76,7 @@ GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, return e; } -GF_EXPORT +GF_EXPORT GF_Err gf_webvtt_js_removeCues(GF_Node *node) { GF_Err e; @@ -84,7 +84,7 @@ GF_Err gf_webvtt_js_removeCues(GF_Node *node) JSContext *c = node->sgprivate->scenegraph->svg_js->js_ctx; JSObject *global = node->sgprivate->scenegraph->svg_js->global; jsval fun_val; - + gf_sg_lock_javascript(c, GF_TRUE); found = JS_LookupProperty(c, global, "removeCues", &fun_val); if (!found || JSVAL_IS_VOID(fun_val) || !JSVAL_IS_OBJECT(fun_val) ) { @@ -110,16 +110,16 @@ GF_Err gf_webvtt_js_removeCues(GF_Node *node) } #else -GF_EXPORT -GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, - const char *start, const char *end, - const char *settings, - const char *payload) +GF_EXPORT +GF_Err gf_webvtt_js_addCue(GF_Node *node, const char *id, + const char *start, const char *end, + const char *settings, + const char *payload) { return GF_BAD_PARAM; } -GF_EXPORT +GF_EXPORT GF_Err gf_webvtt_js_removeCues() { return GF_BAD_PARAM; diff --git a/src/scenegraph/x3d_nodes.c b/src/scenegraph/x3d_nodes.c index 3ee64df..ea0cea5 100644 --- a/src/scenegraph/x3d_nodes.c +++ b/src/scenegraph/x3d_nodes.c @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to @@ -50,8 +50,8 @@ static void Anchor_Del(GF_Node *node) gf_sg_sfstring_del(p->description); gf_sg_mfstring_del(p->parameter); gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -128,7 +128,7 @@ static s32 Anchor_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *Anchor_Create() @@ -151,12 +151,12 @@ static GF_Node *Anchor_Create() static void Appearance_Del(GF_Node *node) { X_Appearance *p = (X_Appearance *) node; - gf_node_unregister((GF_Node *) p->material, node); - gf_node_unregister((GF_Node *) p->texture, node); - gf_node_unregister((GF_Node *) p->textureTransform, node); - gf_node_unregister((GF_Node *) p->fillProperties, node); - gf_node_unregister((GF_Node *) p->lineProperties, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->material, node); + gf_node_unregister((GF_Node *) p->texture, node); + gf_node_unregister((GF_Node *) p->textureTransform, node); + gf_node_unregister((GF_Node *) p->fillProperties, node); + gf_node_unregister((GF_Node *) p->lineProperties, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -226,7 +226,7 @@ static s32 Appearance_get_field_index_by_name(char *name) if (!strcmp("lineProperties", name)) return 4; if (!strcmp("metadata", name)) return 5; return -1; - } +} static GF_Node *Appearance_Create() @@ -248,7 +248,7 @@ static GF_Node *Appearance_Create() static void Arc2D_Del(GF_Node *node) { X_Arc2D *p = (X_Arc2D *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -299,7 +299,7 @@ static s32 Arc2D_get_field_index_by_name(char *name) if (!strcmp("startAngle", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *Arc2D_Create() @@ -325,7 +325,7 @@ static void ArcClose2D_Del(GF_Node *node) { X_ArcClose2D *p = (X_ArcClose2D *) node; gf_sg_sfstring_del(p->closureType); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -383,7 +383,7 @@ static s32 ArcClose2D_get_field_index_by_name(char *name) if (!strcmp("startAngle", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *ArcClose2D_Create() @@ -412,7 +412,7 @@ static void AudioClip_Del(GF_Node *node) X_AudioClip *p = (X_AudioClip *) node; gf_sg_sfstring_del(p->description); gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -526,7 +526,7 @@ static s32 AudioClip_get_field_index_by_name(char *name) if (!strcmp("elapsedTime", name)) return 11; if (!strcmp("isPaused", name)) return 12; return -1; - } +} static GF_Node *AudioClip_Create() @@ -563,7 +563,7 @@ static void Background_Del(GF_Node *node) gf_sg_mfurl_del(p->topUrl); gf_sg_mffloat_del(p->skyAngle); gf_sg_mfcolor_del(p->skyColor); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -685,7 +685,7 @@ static s32 Background_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 12; if (!strcmp("bindTime", name)) return 13; return -1; - } +} static GF_Node *Background_Create() @@ -712,8 +712,8 @@ static GF_Node *Background_Create() static void Billboard_Del(GF_Node *node) { X_Billboard *p = (X_Billboard *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -776,7 +776,7 @@ static s32 Billboard_get_field_index_by_name(char *name) if (!strcmp("axisOfRotation", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *Billboard_Create() @@ -802,7 +802,7 @@ static GF_Node *Billboard_Create() static void BooleanFilter_Del(GF_Node *node) { X_BooleanFilter *p = (X_BooleanFilter *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -861,7 +861,7 @@ static s32 BooleanFilter_get_field_index_by_name(char *name) if (!strcmp("inputTrue", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *BooleanFilter_Create() @@ -885,7 +885,7 @@ static void BooleanSequencer_Del(GF_Node *node) X_BooleanSequencer *p = (X_BooleanSequencer *) node; gf_sg_mffloat_del(p->key); gf_sg_mfbool_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -960,7 +960,7 @@ static s32 BooleanSequencer_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *BooleanSequencer_Create() @@ -982,7 +982,7 @@ static GF_Node *BooleanSequencer_Create() static void BooleanToggle_Del(GF_Node *node) { X_BooleanToggle *p = (X_BooleanToggle *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1027,7 +1027,7 @@ static s32 BooleanToggle_get_field_index_by_name(char *name) if (!strcmp("toggle", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *BooleanToggle_Create() @@ -1049,7 +1049,7 @@ static GF_Node *BooleanToggle_Create() static void BooleanTrigger_Del(GF_Node *node) { X_BooleanTrigger *p = (X_BooleanTrigger *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1094,7 +1094,7 @@ static s32 BooleanTrigger_get_field_index_by_name(char *name) if (!strcmp("triggerTrue", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *BooleanTrigger_Create() @@ -1116,7 +1116,7 @@ static GF_Node *BooleanTrigger_Create() static void Box_Del(GF_Node *node) { X_Box *p = (X_Box *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1153,7 +1153,7 @@ static s32 Box_get_field_index_by_name(char *name) if (!strcmp("size", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Box_Create() @@ -1178,7 +1178,7 @@ static GF_Node *Box_Create() static void Circle2D_Del(GF_Node *node) { X_Circle2D *p = (X_Circle2D *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1215,7 +1215,7 @@ static s32 Circle2D_get_field_index_by_name(char *name) if (!strcmp("radius", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Circle2D_Create() @@ -1238,9 +1238,9 @@ static GF_Node *Circle2D_Create() static void Collision_Del(GF_Node *node) { X_Collision *p = (X_Collision *) node; - gf_node_unregister((GF_Node *) p->proxy, node); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->proxy, node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -1325,7 +1325,7 @@ static s32 Collision_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 6; if (!strcmp("metadata", name)) return 7; return -1; - } +} static GF_Node *Collision_Create() @@ -1350,7 +1350,7 @@ static void Color_Del(GF_Node *node) { X_Color *p = (X_Color *) node; gf_sg_mfcolor_del(p->color); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1387,7 +1387,7 @@ static s32 Color_get_field_index_by_name(char *name) if (!strcmp("color", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Color_Create() @@ -1411,7 +1411,7 @@ static void ColorInterpolator_Del(GF_Node *node) X_ColorInterpolator *p = (X_ColorInterpolator *) node; gf_sg_mffloat_del(p->key); gf_sg_mfcolor_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1470,7 +1470,7 @@ static s32 ColorInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *ColorInterpolator_Create() @@ -1492,7 +1492,7 @@ static GF_Node *ColorInterpolator_Create() static void ColorRGBA_Del(GF_Node *node) { X_ColorRGBA *p = (X_ColorRGBA *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1529,7 +1529,7 @@ static s32 ColorRGBA_get_field_index_by_name(char *name) if (!strcmp("color", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *ColorRGBA_Create() @@ -1551,7 +1551,7 @@ static GF_Node *ColorRGBA_Create() static void Cone_Del(GF_Node *node) { X_Cone *p = (X_Cone *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1609,7 +1609,7 @@ static s32 Cone_get_field_index_by_name(char *name) if (!strcmp("bottom", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *Cone_Create() @@ -1635,8 +1635,8 @@ static GF_Node *Cone_Create() static void Contour2D_Del(GF_Node *node) { X_Contour2D *p = (X_Contour2D *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -1692,7 +1692,7 @@ static s32 Contour2D_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *Contour2D_Create() @@ -1716,7 +1716,7 @@ static void ContourPolyline2D_Del(GF_Node *node) { X_ContourPolyline2D *p = (X_ContourPolyline2D *) node; gf_sg_mfvec2f_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1753,7 +1753,7 @@ static s32 ContourPolyline2D_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *ContourPolyline2D_Create() @@ -1776,7 +1776,7 @@ static void Coordinate_Del(GF_Node *node) { X_Coordinate *p = (X_Coordinate *) node; gf_sg_mfvec3f_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1813,7 +1813,7 @@ static s32 Coordinate_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Coordinate_Create() @@ -1836,7 +1836,7 @@ static void CoordinateDouble_Del(GF_Node *node) { X_CoordinateDouble *p = (X_CoordinateDouble *) node; gf_sg_mfvec3d_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1873,7 +1873,7 @@ static s32 CoordinateDouble_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *CoordinateDouble_Create() @@ -1896,7 +1896,7 @@ static void Coordinate2D_Del(GF_Node *node) { X_Coordinate2D *p = (X_Coordinate2D *) node; gf_sg_mfvec2f_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -1933,7 +1933,7 @@ static s32 Coordinate2D_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Coordinate2D_Create() @@ -1958,7 +1958,7 @@ static void CoordinateInterpolator_Del(GF_Node *node) gf_sg_mffloat_del(p->key); gf_sg_mfvec3f_del(p->keyValue); gf_sg_mfvec3f_del(p->value_changed); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2017,7 +2017,7 @@ static s32 CoordinateInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *CoordinateInterpolator_Create() @@ -2042,7 +2042,7 @@ static void CoordinateInterpolator2D_Del(GF_Node *node) gf_sg_mffloat_del(p->key); gf_sg_mfvec2f_del(p->keyValue); gf_sg_mfvec2f_del(p->value_changed); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2101,7 +2101,7 @@ static s32 CoordinateInterpolator2D_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *CoordinateInterpolator2D_Create() @@ -2123,7 +2123,7 @@ static GF_Node *CoordinateInterpolator2D_Create() static void Cylinder_Del(GF_Node *node) { X_Cylinder *p = (X_Cylinder *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2188,7 +2188,7 @@ static s32 Cylinder_get_field_index_by_name(char *name) if (!strcmp("top", name)) return 4; if (!strcmp("metadata", name)) return 5; return -1; - } +} static GF_Node *Cylinder_Create() @@ -2215,7 +2215,7 @@ static GF_Node *Cylinder_Create() static void CylinderSensor_Del(GF_Node *node) { X_CylinderSensor *p = (X_CylinderSensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_sg_sfstring_del(p->description); gf_node_free((GF_Node *)p); } @@ -2323,7 +2323,7 @@ static s32 CylinderSensor_get_field_index_by_name(char *name) if (!strcmp("description", name)) return 10; if (!strcmp("isOver", name)) return 11; return -1; - } +} static GF_Node *CylinderSensor_Create() @@ -2351,7 +2351,7 @@ static GF_Node *CylinderSensor_Create() static void DirectionalLight_Del(GF_Node *node) { X_DirectionalLight *p = (X_DirectionalLight *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2416,7 +2416,7 @@ static s32 DirectionalLight_get_field_index_by_name(char *name) if (!strcmp("on", name)) return 4; if (!strcmp("metadata", name)) return 5; return -1; - } +} static GF_Node *DirectionalLight_Create() @@ -2447,7 +2447,7 @@ static GF_Node *DirectionalLight_Create() static void Disk2D_Del(GF_Node *node) { X_Disk2D *p = (X_Disk2D *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2491,7 +2491,7 @@ static s32 Disk2D_get_field_index_by_name(char *name) if (!strcmp("outerRadius", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *Disk2D_Create() @@ -2516,11 +2516,11 @@ static void ElevationGrid_Del(GF_Node *node) { X_ElevationGrid *p = (X_ElevationGrid *) node; gf_sg_mffloat_del(p->set_height); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mffloat_del(p->height); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -2652,7 +2652,7 @@ static s32 ElevationGrid_get_field_index_by_name(char *name) if (!strcmp("zSpacing", name)) return 13; if (!strcmp("metadata", name)) return 14; return -1; - } +} static GF_Node *ElevationGrid_Create() @@ -2692,8 +2692,8 @@ static void EspduTransform_Del(GF_Node *node) gf_sg_sfstring_del(p->marking); gf_sg_sfstring_del(p->multicastRelayHost); gf_sg_sfstring_del(p->networkMode); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -3331,7 +3331,7 @@ static s32 EspduTransform_get_field_index_by_name(char *name) if (!strcmp("timestamp", name)) return 84; if (!strcmp("metadata", name)) return 85; return -1; - } +} static GF_Node *EspduTransform_Create() @@ -3433,7 +3433,7 @@ static void Extrusion_Del(GF_Node *node) gf_sg_mfrotation_del(p->orientation); gf_sg_mfvec2f_del(p->scale); gf_sg_mfvec3f_del(p->spine); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -3565,7 +3565,7 @@ static s32 Extrusion_get_field_index_by_name(char *name) if (!strcmp("spine", name)) return 13; if (!strcmp("metadata", name)) return 14; return -1; - } +} static GF_Node *Extrusion_Create() @@ -3672,7 +3672,7 @@ static s32 FillProperties_get_field_index_by_name(char *name) if (!strcmp("hatched", name)) return 2; if (!strcmp("hatchStyle", name)) return 3; return -1; - } +} static GF_Node *FillProperties_Create() @@ -3701,7 +3701,7 @@ static void Fog_Del(GF_Node *node) { X_Fog *p = (X_Fog *) node; gf_sg_sfstring_del(p->fogType); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -3774,7 +3774,7 @@ static s32 Fog_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 5; if (!strcmp("bindTime", name)) return 6; return -1; - } +} static GF_Node *Fog_Create() @@ -3806,7 +3806,7 @@ static void FontStyle_Del(GF_Node *node) gf_sg_mfstring_del(p->justify); gf_sg_sfstring_del(p->language); gf_sg_sfstring_del(p->style); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -3899,7 +3899,7 @@ static s32 FontStyle_get_field_index_by_name(char *name) if (!strcmp("topToBottom", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *FontStyle_Create() @@ -3937,9 +3937,9 @@ static void GeoCoordinate_Del(GF_Node *node) { X_GeoCoordinate *p = (X_GeoCoordinate *) node; gf_sg_mfvec3d_del(p->point); - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -3991,7 +3991,7 @@ static s32 GeoCoordinate_get_field_index_by_name(char *name) if (!strcmp("geoSystem", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *GeoCoordinate_Create() @@ -4020,14 +4020,14 @@ static void GeoElevationGrid_Del(GF_Node *node) { X_GeoElevationGrid *p = (X_GeoElevationGrid *) node; gf_sg_mfdouble_del(p->set_height); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_sfstring_del(p->geoGridOrigin); - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); gf_sg_mfdouble_del(p->height); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4188,7 +4188,7 @@ static s32 GeoElevationGrid_get_field_index_by_name(char *name) if (!strcmp("zSpacing", name)) return 17; if (!strcmp("metadata", name)) return 18; return -1; - } +} static GF_Node *GeoElevationGrid_Create() @@ -4228,10 +4228,10 @@ static GF_Node *GeoElevationGrid_Create() static void GeoLocation_Del(GF_Node *node) { X_GeoLocation *p = (X_GeoLocation *) node; - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -4309,7 +4309,7 @@ static s32 GeoLocation_get_field_index_by_name(char *name) if (!strcmp("geoSystem", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *GeoLocation_Create() @@ -4345,12 +4345,12 @@ static void GeoLOD_Del(GF_Node *node) gf_sg_mfurl_del(p->child2Url); gf_sg_mfurl_del(p->child3Url); gf_sg_mfurl_del(p->child4Url); - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); gf_sg_mfurl_del(p->rootUrl); - gf_node_unregister_children(node, p->rootNode); - gf_node_unregister_children(node, p->children); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->rootNode); + gf_node_unregister_children(node, p->children); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4460,7 +4460,7 @@ static s32 GeoLOD_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 10; if (!strcmp("metadata", name)) return 11; return -1; - } +} static GF_Node *GeoLOD_Create() @@ -4492,10 +4492,10 @@ static GF_Node *GeoLOD_Create() static void GeoMetadata_Del(GF_Node *node) { X_GeoMetadata *p = (X_GeoMetadata *) node; - gf_node_unregister_children(node, p->data); + gf_node_unregister_children(node, p->data); gf_sg_mfstring_del(p->summary); gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4547,7 +4547,7 @@ static s32 GeoMetadata_get_field_index_by_name(char *name) if (!strcmp("url", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *GeoMetadata_Create() @@ -4570,7 +4570,7 @@ static void GeoOrigin_Del(GF_Node *node) { X_GeoOrigin *p = (X_GeoOrigin *) node; gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4621,7 +4621,7 @@ static s32 GeoOrigin_get_field_index_by_name(char *name) if (!strcmp("rotateYUp", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *GeoOrigin_Create() @@ -4654,9 +4654,9 @@ static void GeoPositionInterpolator_Del(GF_Node *node) X_GeoPositionInterpolator *p = (X_GeoPositionInterpolator *) node; gf_sg_mffloat_del(p->key); gf_sg_mfvec3d_del(p->keyValue); - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4737,7 +4737,7 @@ static s32 GeoPositionInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 6; if (!strcmp("metadata", name)) return 7; return -1; - } +} static GF_Node *GeoPositionInterpolator_Create() @@ -4765,9 +4765,9 @@ static GF_Node *GeoPositionInterpolator_Create() static void GeoTouchSensor_Del(GF_Node *node) { X_GeoTouchSensor *p = (X_GeoTouchSensor *) node; - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -4868,7 +4868,7 @@ static s32 GeoTouchSensor_get_field_index_by_name(char *name) if (!strcmp("touchTime", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *GeoTouchSensor_Create() @@ -4901,9 +4901,9 @@ static void GeoViewpoint_Del(GF_Node *node) gf_sg_sfstring_del(p->set_position); gf_sg_sfstring_del(p->description); gf_sg_mfstring_del(p->navType); - gf_node_unregister((GF_Node *) p->geoOrigin, node); + gf_node_unregister((GF_Node *) p->geoOrigin, node); gf_sg_mfstring_del(p->geoSystem); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -5042,7 +5042,7 @@ static s32 GeoViewpoint_get_field_index_by_name(char *name) if (!strcmp("speedFactor", name)) return 14; if (!strcmp("metadata", name)) return 15; return -1; - } +} static GF_Node *GeoViewpoint_Create() @@ -5087,8 +5087,8 @@ static GF_Node *GeoViewpoint_Create() static void Group_Del(GF_Node *node) { X_Group *p = (X_Group *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -5144,7 +5144,7 @@ static s32 Group_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *Group_Create() @@ -5170,7 +5170,7 @@ static void HAnimDisplacer_Del(GF_Node *node) gf_sg_mfint32_del(p->coordIndex); gf_sg_mfvec3f_del(p->displacements); gf_sg_sfstring_del(p->name); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -5228,7 +5228,7 @@ static s32 HAnimDisplacer_get_field_index_by_name(char *name) if (!strcmp("weight", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *HAnimDisplacer_Create() @@ -5252,17 +5252,17 @@ static void HAnimHumanoid_Del(GF_Node *node) { X_HAnimHumanoid *p = (X_HAnimHumanoid *) node; gf_sg_mfstring_del(p->info); - gf_node_unregister_children(node, p->joints); + gf_node_unregister_children(node, p->joints); gf_sg_sfstring_del(p->name); - gf_node_unregister_children(node, p->segments); - gf_node_unregister_children(node, p->sites); - gf_node_unregister_children(node, p->skeleton); - gf_node_unregister_children(node, p->skin); - gf_node_unregister((GF_Node *) p->skinCoord, node); - gf_node_unregister((GF_Node *) p->skinNormal, node); + gf_node_unregister_children(node, p->segments); + gf_node_unregister_children(node, p->sites); + gf_node_unregister_children(node, p->skeleton); + gf_node_unregister_children(node, p->skin); + gf_node_unregister((GF_Node *) p->skinCoord, node); + gf_node_unregister((GF_Node *) p->skinNormal, node); gf_sg_sfstring_del(p->version); - gf_node_unregister_children(node, p->viewpoints); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->viewpoints); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -5412,7 +5412,7 @@ static s32 HAnimHumanoid_get_field_index_by_name(char *name) if (!strcmp("viewpoints", name)) return 15; if (!strcmp("metadata", name)) return 16; return -1; - } +} static GF_Node *HAnimHumanoid_Create() @@ -5451,15 +5451,15 @@ static GF_Node *HAnimHumanoid_Create() static void HAnimJoint_Del(GF_Node *node) { X_HAnimJoint *p = (X_HAnimJoint *) node; - gf_node_unregister_children(node, p->displacers); + gf_node_unregister_children(node, p->displacers); gf_sg_mffloat_del(p->llimit); gf_sg_sfstring_del(p->name); gf_sg_mfint32_del(p->skinCoordIndex); gf_sg_mffloat_del(p->skinCoordWeight); gf_sg_mffloat_del(p->stiffness); gf_sg_mffloat_del(p->ulimit); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -5607,7 +5607,7 @@ static s32 HAnimJoint_get_field_index_by_name(char *name) if (!strcmp("ulimit", name)) return 15; if (!strcmp("metadata", name)) return 16; return -1; - } +} static GF_Node *HAnimJoint_Create() @@ -5656,12 +5656,12 @@ static GF_Node *HAnimJoint_Create() static void HAnimSegment_Del(GF_Node *node) { X_HAnimSegment *p = (X_HAnimSegment *) node; - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister_children(node, p->displacers); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister_children(node, p->displacers); gf_sg_mffloat_del(p->momentsOfInertia); gf_sg_sfstring_del(p->name); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -5761,7 +5761,7 @@ static s32 HAnimSegment_get_field_index_by_name(char *name) if (!strcmp("name", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *HAnimSegment_Create() @@ -5800,8 +5800,8 @@ static void HAnimSite_Del(GF_Node *node) { X_HAnimSite *p = (X_HAnimSite *) node; gf_sg_sfstring_del(p->name); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -5899,7 +5899,7 @@ static s32 HAnimSite_get_field_index_by_name(char *name) if (!strcmp("translation", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *HAnimSite_Create() @@ -5940,7 +5940,7 @@ static void ImageTexture_Del(GF_Node *node) { X_ImageTexture *p = (X_ImageTexture *) node; gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -5991,7 +5991,7 @@ static s32 ImageTexture_get_field_index_by_name(char *name) if (!strcmp("repeatT", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *ImageTexture_Create() @@ -6019,15 +6019,15 @@ static void IndexedFaceSet_Del(GF_Node *node) gf_sg_mfint32_del(p->set_coordIndex); gf_sg_mfint32_del(p->set_normalIndex); gf_sg_mfint32_del(p->set_texCoordIndex); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); gf_sg_mfint32_del(p->normalIndex); gf_sg_mfint32_del(p->texCoordIndex); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6191,7 +6191,7 @@ static s32 IndexedFaceSet_get_field_index_by_name(char *name) if (!strcmp("texCoordIndex", name)) return 17; if (!strcmp("metadata", name)) return 18; return -1; - } +} static GF_Node *IndexedFaceSet_Create() @@ -6221,11 +6221,11 @@ static void IndexedLineSet_Del(GF_Node *node) X_IndexedLineSet *p = (X_IndexedLineSet *) node; gf_sg_mfint32_del(p->set_colorIndex); gf_sg_mfint32_del(p->set_coordIndex); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); gf_sg_mfint32_del(p->colorIndex); gf_sg_mfint32_del(p->coordIndex); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6308,7 +6308,7 @@ static s32 IndexedLineSet_get_field_index_by_name(char *name) if (!strcmp("coordIndex", name)) return 6; if (!strcmp("metadata", name)) return 7; return -1; - } +} static GF_Node *IndexedLineSet_Create() @@ -6332,12 +6332,12 @@ static void IndexedTriangleFanSet_Del(GF_Node *node) { X_IndexedTriangleFanSet *p = (X_IndexedTriangleFanSet *) node; gf_sg_mfint32_del(p->set_index); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfint32_del(p->index); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6442,7 +6442,7 @@ static s32 IndexedTriangleFanSet_get_field_index_by_name(char *name) if (!strcmp("index", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *IndexedTriangleFanSet_Create() @@ -6469,12 +6469,12 @@ static void IndexedTriangleSet_Del(GF_Node *node) { X_IndexedTriangleSet *p = (X_IndexedTriangleSet *) node; gf_sg_mfint32_del(p->set_index); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfint32_del(p->index); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6579,7 +6579,7 @@ static s32 IndexedTriangleSet_get_field_index_by_name(char *name) if (!strcmp("index", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *IndexedTriangleSet_Create() @@ -6606,12 +6606,12 @@ static void IndexedTriangleStripSet_Del(GF_Node *node) { X_IndexedTriangleStripSet *p = (X_IndexedTriangleStripSet *) node; gf_sg_mfint32_del(p->set_index); - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfint32_del(p->index); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6716,7 +6716,7 @@ static s32 IndexedTriangleStripSet_get_field_index_by_name(char *name) if (!strcmp("index", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *IndexedTriangleStripSet_Create() @@ -6743,7 +6743,7 @@ static void Inline_Del(GF_Node *node) { X_Inline *p = (X_Inline *) node; gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6787,7 +6787,7 @@ static s32 Inline_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 1; if (!strcmp("load", name)) return 2; return -1; - } +} static GF_Node *Inline_Create() @@ -6812,7 +6812,7 @@ static void IntegerSequencer_Del(GF_Node *node) X_IntegerSequencer *p = (X_IntegerSequencer *) node; gf_sg_mffloat_del(p->key); gf_sg_mfint32_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6887,7 +6887,7 @@ static s32 IntegerSequencer_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *IntegerSequencer_Create() @@ -6909,7 +6909,7 @@ static GF_Node *IntegerSequencer_Create() static void IntegerTrigger_Del(GF_Node *node) { X_IntegerTrigger *p = (X_IntegerTrigger *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -6961,7 +6961,7 @@ static s32 IntegerTrigger_get_field_index_by_name(char *name) if (!strcmp("triggerValue", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *IntegerTrigger_Create() @@ -6986,7 +6986,7 @@ static void KeySensor_Del(GF_Node *node) X_KeySensor *p = (X_KeySensor *) node; gf_sg_sfstring_del(p->keyPress); gf_sg_sfstring_del(p->keyRelease); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7079,7 +7079,7 @@ static s32 KeySensor_get_field_index_by_name(char *name) if (!strcmp("shiftKey", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *KeySensor_Create() @@ -7102,7 +7102,7 @@ static GF_Node *KeySensor_Create() static void LineProperties_Del(GF_Node *node) { X_LineProperties *p = (X_LineProperties *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7153,7 +7153,7 @@ static s32 LineProperties_get_field_index_by_name(char *name) if (!strcmp("linewidthScaleFactor", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *LineProperties_Create() @@ -7178,10 +7178,10 @@ static GF_Node *LineProperties_Create() static void LineSet_Del(GF_Node *node) { X_LineSet *p = (X_LineSet *) node; - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); gf_sg_mfint32_del(p->vertexCount); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7234,7 +7234,7 @@ static s32 LineSet_get_field_index_by_name(char *name) if (!strcmp("vertexCount", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *LineSet_Create() @@ -7256,8 +7256,8 @@ static GF_Node *LineSet_Create() static void LoadSensor_Del(GF_Node *node) { X_LoadSensor *p = (X_LoadSensor *) node; - gf_node_unregister_children(node, p->watchList); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->watchList); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7337,7 +7337,7 @@ static s32 LoadSensor_get_field_index_by_name(char *name) if (!strcmp("progress", name)) return 6; if (!strcmp("metadata", name)) return 7; return -1; - } +} static GF_Node *LoadSensor_Create() @@ -7362,8 +7362,8 @@ static void LOD_Del(GF_Node *node) { X_LOD *p = (X_LOD *) node; gf_sg_mffloat_del(p->range); - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -7433,7 +7433,7 @@ static s32 LOD_get_field_index_by_name(char *name) if (!strcmp("range", name)) return 4; if (!strcmp("metadata", name)) return 5; return -1; - } +} static GF_Node *LOD_Create() @@ -7459,7 +7459,7 @@ static GF_Node *LOD_Create() static void Material_Del(GF_Node *node) { X_Material *p = (X_Material *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7531,7 +7531,7 @@ static s32 Material_get_field_index_by_name(char *name) if (!strcmp("transparency", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *Material_Create() @@ -7568,7 +7568,7 @@ static void MetadataDouble_Del(GF_Node *node) gf_sg_sfstring_del(p->name); gf_sg_sfstring_del(p->reference); gf_sg_mfdouble_del(p->value); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7619,7 +7619,7 @@ static s32 MetadataDouble_get_field_index_by_name(char *name) if (!strcmp("value", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *MetadataDouble_Create() @@ -7644,7 +7644,7 @@ static void MetadataFloat_Del(GF_Node *node) gf_sg_sfstring_del(p->name); gf_sg_sfstring_del(p->reference); gf_sg_mffloat_del(p->value); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7695,7 +7695,7 @@ static s32 MetadataFloat_get_field_index_by_name(char *name) if (!strcmp("value", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *MetadataFloat_Create() @@ -7720,7 +7720,7 @@ static void MetadataInteger_Del(GF_Node *node) gf_sg_sfstring_del(p->name); gf_sg_sfstring_del(p->reference); gf_sg_mfint32_del(p->value); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7771,7 +7771,7 @@ static s32 MetadataInteger_get_field_index_by_name(char *name) if (!strcmp("value", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *MetadataInteger_Create() @@ -7795,8 +7795,8 @@ static void MetadataSet_Del(GF_Node *node) X_MetadataSet *p = (X_MetadataSet *) node; gf_sg_sfstring_del(p->name); gf_sg_sfstring_del(p->reference); - gf_node_unregister_children(node, p->value); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->value); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7848,7 +7848,7 @@ static s32 MetadataSet_get_field_index_by_name(char *name) if (!strcmp("value", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *MetadataSet_Create() @@ -7873,7 +7873,7 @@ static void MetadataString_Del(GF_Node *node) gf_sg_sfstring_del(p->name); gf_sg_sfstring_del(p->reference); gf_sg_mfstring_del(p->value); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -7924,7 +7924,7 @@ static s32 MetadataString_get_field_index_by_name(char *name) if (!strcmp("value", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *MetadataString_Create() @@ -7947,7 +7947,7 @@ static void MovieTexture_Del(GF_Node *node) { X_MovieTexture *p = (X_MovieTexture *) node; gf_sg_mfurl_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8068,7 +8068,7 @@ static s32 MovieTexture_get_field_index_by_name(char *name) if (!strcmp("elapsedTime", name)) return 12; if (!strcmp("isPaused", name)) return 13; return -1; - } +} static GF_Node *MovieTexture_Create() @@ -8100,8 +8100,8 @@ static void MultiTexture_Del(GF_Node *node) gf_sg_mfstring_del(p->function); gf_sg_mfstring_del(p->mode); gf_sg_mfstring_del(p->source); - gf_node_unregister_children(node, p->texture); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->texture); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8174,7 +8174,7 @@ static s32 MultiTexture_get_field_index_by_name(char *name) if (!strcmp("texture", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *MultiTexture_Create() @@ -8200,8 +8200,8 @@ static GF_Node *MultiTexture_Create() static void MultiTextureCoordinate_Del(GF_Node *node) { X_MultiTextureCoordinate *p = (X_MultiTextureCoordinate *) node; - gf_node_unregister_children(node, p->texCoord); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->texCoord); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8239,7 +8239,7 @@ static s32 MultiTextureCoordinate_get_field_index_by_name(char *name) if (!strcmp("texCoord", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *MultiTextureCoordinate_Create() @@ -8261,8 +8261,8 @@ static GF_Node *MultiTextureCoordinate_Create() static void MultiTextureTransform_Del(GF_Node *node) { X_MultiTextureTransform *p = (X_MultiTextureTransform *) node; - gf_node_unregister_children(node, p->textureTransform); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->textureTransform); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8300,7 +8300,7 @@ static s32 MultiTextureTransform_get_field_index_by_name(char *name) if (!strcmp("textureTransform", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *MultiTextureTransform_Create() @@ -8324,7 +8324,7 @@ static void NavigationInfo_Del(GF_Node *node) X_NavigationInfo *p = (X_NavigationInfo *) node; gf_sg_mffloat_del(p->avatarSize); gf_sg_mfstring_del(p->type); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_sg_mfstring_del(p->transitionType); gf_node_free((GF_Node *)p); } @@ -8419,7 +8419,7 @@ static s32 NavigationInfo_get_field_index_by_name(char *name) if (!strcmp("transitionType", name)) return 8; if (!strcmp("bindTime", name)) return 9; return -1; - } +} static GF_Node *NavigationInfo_Create() @@ -8462,7 +8462,7 @@ static void Normal_Del(GF_Node *node) { X_Normal *p = (X_Normal *) node; gf_sg_mfvec3f_del(p->vector); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8499,7 +8499,7 @@ static s32 Normal_get_field_index_by_name(char *name) if (!strcmp("vector", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Normal_Create() @@ -8524,7 +8524,7 @@ static void NormalInterpolator_Del(GF_Node *node) gf_sg_mffloat_del(p->key); gf_sg_mfvec3f_del(p->keyValue); gf_sg_mfvec3f_del(p->value_changed); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8583,7 +8583,7 @@ static s32 NormalInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *NormalInterpolator_Create() @@ -8608,7 +8608,7 @@ static void NurbsCurve_Del(GF_Node *node) gf_sg_mfvec3f_del(p->controlPoint); gf_sg_mfdouble_del(p->weight); gf_sg_mffloat_del(p->knot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8680,7 +8680,7 @@ static s32 NurbsCurve_get_field_index_by_name(char *name) if (!strcmp("order", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *NurbsCurve_Create() @@ -8707,7 +8707,7 @@ static void NurbsCurve2D_Del(GF_Node *node) gf_sg_mfvec2f_del(p->controlPoint); gf_sg_mffloat_del(p->weight); gf_sg_mffloat_del(p->knot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8779,7 +8779,7 @@ static s32 NurbsCurve2D_get_field_index_by_name(char *name) if (!strcmp("closed", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *NurbsCurve2D_Create() @@ -8803,10 +8803,10 @@ static GF_Node *NurbsCurve2D_Create() static void NurbsOrientationInterpolator_Del(GF_Node *node) { X_NurbsOrientationInterpolator *p = (X_NurbsOrientationInterpolator *) node; - gf_node_unregister((GF_Node *) p->controlPoints, node); + gf_node_unregister((GF_Node *) p->controlPoints, node); gf_sg_mfdouble_del(p->knot); gf_sg_mfdouble_del(p->weight); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -8880,7 +8880,7 @@ static s32 NurbsOrientationInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *NurbsOrientationInterpolator_Create() @@ -8903,12 +8903,12 @@ static GF_Node *NurbsOrientationInterpolator_Create() static void NurbsPatchSurface_Del(GF_Node *node) { X_NurbsPatchSurface *p = (X_NurbsPatchSurface *) node; - gf_node_unregister((GF_Node *) p->controlPoint, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->controlPoint, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfdouble_del(p->weight); gf_sg_mfdouble_del(p->uKnot); gf_sg_mfdouble_del(p->vKnot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9038,7 +9038,7 @@ static s32 NurbsPatchSurface_get_field_index_by_name(char *name) if (!strcmp("vOrder", name)) return 13; if (!strcmp("metadata", name)) return 14; return -1; - } +} static GF_Node *NurbsPatchSurface_Create() @@ -9067,10 +9067,10 @@ static GF_Node *NurbsPatchSurface_Create() static void NurbsPositionInterpolator_Del(GF_Node *node) { X_NurbsPositionInterpolator *p = (X_NurbsPositionInterpolator *) node; - gf_node_unregister((GF_Node *) p->controlPoints, node); + gf_node_unregister((GF_Node *) p->controlPoints, node); gf_sg_mfdouble_del(p->knot); gf_sg_mfdouble_del(p->weight); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9144,7 +9144,7 @@ static s32 NurbsPositionInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *NurbsPositionInterpolator_Create() @@ -9167,10 +9167,10 @@ static GF_Node *NurbsPositionInterpolator_Create() static void NurbsSet_Del(GF_Node *node) { X_NurbsSet *p = (X_NurbsSet *) node; - gf_node_unregister_children(node, p->addGeometry); - gf_node_unregister_children(node, p->removeGeometry); - gf_node_unregister_children(node, p->geometry); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister_children(node, p->addGeometry); + gf_node_unregister_children(node, p->removeGeometry); + gf_node_unregister_children(node, p->geometry); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9233,7 +9233,7 @@ static s32 NurbsSet_get_field_index_by_name(char *name) if (!strcmp("tessellationScale", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *NurbsSet_Create() @@ -9256,11 +9256,11 @@ static GF_Node *NurbsSet_Create() static void NurbsSurfaceInterpolator_Del(GF_Node *node) { X_NurbsSurfaceInterpolator *p = (X_NurbsSurfaceInterpolator *) node; - gf_node_unregister((GF_Node *) p->controlPoints, node); + gf_node_unregister((GF_Node *) p->controlPoints, node); gf_sg_mfdouble_del(p->weight); gf_sg_mfdouble_del(p->uKnot); gf_sg_mfdouble_del(p->vKnot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9369,7 +9369,7 @@ static s32 NurbsSurfaceInterpolator_get_field_index_by_name(char *name) if (!strcmp("vOrder", name)) return 10; if (!strcmp("metadata", name)) return 11; return -1; - } +} static GF_Node *NurbsSurfaceInterpolator_Create() @@ -9395,9 +9395,9 @@ static GF_Node *NurbsSurfaceInterpolator_Create() static void NurbsSweptSurface_Del(GF_Node *node) { X_NurbsSweptSurface *p = (X_NurbsSweptSurface *) node; - gf_node_unregister((GF_Node *) p->crossSectionCurve, node); - gf_node_unregister((GF_Node *) p->trajectoryCurve, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->crossSectionCurve, node); + gf_node_unregister((GF_Node *) p->trajectoryCurve, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9457,7 +9457,7 @@ static s32 NurbsSweptSurface_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *NurbsSweptSurface_Create() @@ -9481,9 +9481,9 @@ static GF_Node *NurbsSweptSurface_Create() static void NurbsSwungSurface_Del(GF_Node *node) { X_NurbsSwungSurface *p = (X_NurbsSwungSurface *) node; - gf_node_unregister((GF_Node *) p->profileCurve, node); - gf_node_unregister((GF_Node *) p->trajectoryCurve, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->profileCurve, node); + gf_node_unregister((GF_Node *) p->trajectoryCurve, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9543,7 +9543,7 @@ static s32 NurbsSwungSurface_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *NurbsSwungSurface_Create() @@ -9571,7 +9571,7 @@ static void NurbsTextureCoordinate_Del(GF_Node *node) gf_sg_mffloat_del(p->weight); gf_sg_mfdouble_del(p->uKnot); gf_sg_mfdouble_del(p->vKnot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9657,7 +9657,7 @@ static s32 NurbsTextureCoordinate_get_field_index_by_name(char *name) if (!strcmp("vOrder", name)) return 7; if (!strcmp("metadata", name)) return 8; return -1; - } +} static GF_Node *NurbsTextureCoordinate_Create() @@ -9683,15 +9683,15 @@ static GF_Node *NurbsTextureCoordinate_Create() static void NurbsTrimmedSurface_Del(GF_Node *node) { X_NurbsTrimmedSurface *p = (X_NurbsTrimmedSurface *) node; - gf_node_unregister_children(node, p->addTrimmingContour); - gf_node_unregister_children(node, p->removeTrimmingContour); - gf_node_unregister_children(node, p->trimmingContour); - gf_node_unregister((GF_Node *) p->controlPoint, node); - gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister_children(node, p->addTrimmingContour); + gf_node_unregister_children(node, p->removeTrimmingContour); + gf_node_unregister_children(node, p->trimmingContour); + gf_node_unregister((GF_Node *) p->controlPoint, node); + gf_node_unregister((GF_Node *) p->texCoord, node); gf_sg_mfdouble_del(p->weight); gf_sg_mfdouble_del(p->uKnot); gf_sg_mfdouble_del(p->vKnot); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9847,7 +9847,7 @@ static s32 NurbsTrimmedSurface_get_field_index_by_name(char *name) if (!strcmp("vOrder", name)) return 16; if (!strcmp("metadata", name)) return 17; return -1; - } +} static GF_Node *NurbsTrimmedSurface_Create() @@ -9878,7 +9878,7 @@ static void OrientationInterpolator_Del(GF_Node *node) X_OrientationInterpolator *p = (X_OrientationInterpolator *) node; gf_sg_mffloat_del(p->key); gf_sg_mfrotation_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -9937,7 +9937,7 @@ static s32 OrientationInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *OrientationInterpolator_Create() @@ -9960,7 +9960,7 @@ static void PixelTexture_Del(GF_Node *node) { X_PixelTexture *p = (X_PixelTexture *) node; gf_sg_sfimage_del(p->image); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10011,7 +10011,7 @@ static s32 PixelTexture_get_field_index_by_name(char *name) if (!strcmp("repeatT", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *PixelTexture_Create() @@ -10035,7 +10035,7 @@ static GF_Node *PixelTexture_Create() static void PlaneSensor_Del(GF_Node *node) { X_PlaneSensor *p = (X_PlaneSensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_sg_sfstring_del(p->description); gf_node_free((GF_Node *)p); } @@ -10136,7 +10136,7 @@ static s32 PlaneSensor_get_field_index_by_name(char *name) if (!strcmp("description", name)) return 9; if (!strcmp("isOver", name)) return 10; return -1; - } +} static GF_Node *PlaneSensor_Create() @@ -10167,7 +10167,7 @@ static GF_Node *PlaneSensor_Create() static void PointLight_Del(GF_Node *node) { X_PointLight *p = (X_PointLight *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10246,7 +10246,7 @@ static s32 PointLight_get_field_index_by_name(char *name) if (!strcmp("radius", name)) return 6; if (!strcmp("metadata", name)) return 7; return -1; - } +} static GF_Node *PointLight_Create() @@ -10281,9 +10281,9 @@ static GF_Node *PointLight_Create() static void PointSet_Del(GF_Node *node) { X_PointSet *p = (X_PointSet *) node; - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10329,7 +10329,7 @@ static s32 PointSet_get_field_index_by_name(char *name) if (!strcmp("coord", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *PointSet_Create() @@ -10352,7 +10352,7 @@ static void Polyline2D_Del(GF_Node *node) { X_Polyline2D *p = (X_Polyline2D *) node; gf_sg_mfvec2f_del(p->lineSegments); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10389,7 +10389,7 @@ static s32 Polyline2D_get_field_index_by_name(char *name) if (!strcmp("lineSegments", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Polyline2D_Create() @@ -10412,7 +10412,7 @@ static void Polypoint2D_Del(GF_Node *node) { X_Polypoint2D *p = (X_Polypoint2D *) node; gf_sg_mfvec2f_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10449,7 +10449,7 @@ static s32 Polypoint2D_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Polypoint2D_Create() @@ -10473,7 +10473,7 @@ static void PositionInterpolator_Del(GF_Node *node) X_PositionInterpolator *p = (X_PositionInterpolator *) node; gf_sg_mffloat_del(p->key); gf_sg_mfvec3f_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10532,7 +10532,7 @@ static s32 PositionInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *PositionInterpolator_Create() @@ -10556,7 +10556,7 @@ static void PositionInterpolator2D_Del(GF_Node *node) X_PositionInterpolator2D *p = (X_PositionInterpolator2D *) node; gf_sg_mffloat_del(p->key); gf_sg_mfvec2f_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10615,7 +10615,7 @@ static s32 PositionInterpolator2D_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *PositionInterpolator2D_Create() @@ -10637,7 +10637,7 @@ static GF_Node *PositionInterpolator2D_Create() static void ProximitySensor_Del(GF_Node *node) { X_ProximitySensor *p = (X_ProximitySensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10730,7 +10730,7 @@ static s32 ProximitySensor_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 8; if (!strcmp("centerOfRotation_changed", name)) return 9; return -1; - } +} static GF_Node *ProximitySensor_Create() @@ -10762,7 +10762,7 @@ static void ReceiverPdu_Del(GF_Node *node) gf_sg_sfstring_del(p->address); gf_sg_sfstring_del(p->multicastRelayHost); gf_sg_sfstring_del(p->networkMode); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -10967,7 +10967,7 @@ static s32 ReceiverPdu_get_field_index_by_name(char *name) if (!strcmp("timestamp", name)) return 24; if (!strcmp("metadata", name)) return 25; return -1; - } +} static GF_Node *ReceiverPdu_Create() @@ -11008,7 +11008,7 @@ static GF_Node *ReceiverPdu_Create() static void Rectangle2D_Del(GF_Node *node) { X_Rectangle2D *p = (X_Rectangle2D *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11045,7 +11045,7 @@ static s32 Rectangle2D_get_field_index_by_name(char *name) if (!strcmp("size", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Rectangle2D_Create() @@ -11071,7 +11071,7 @@ static void ScalarInterpolator_Del(GF_Node *node) X_ScalarInterpolator *p = (X_ScalarInterpolator *) node; gf_sg_mffloat_del(p->key); gf_sg_mffloat_del(p->keyValue); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11130,7 +11130,7 @@ static s32 ScalarInterpolator_get_field_index_by_name(char *name) if (!strcmp("value_changed", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *ScalarInterpolator_Create() @@ -11153,7 +11153,7 @@ static void Script_Del(GF_Node *node) { X_Script *p = (X_Script *) node; gf_sg_mfscript_del(p->url); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11204,7 +11204,7 @@ static s32 Script_get_field_index_by_name(char *name) if (!strcmp("mustEvaluate", name)) return 2; if (!strcmp("metadata", name)) return 3; return -1; - } +} static GF_Node *Script_Create() @@ -11226,9 +11226,9 @@ static GF_Node *Script_Create() static void Shape_Del(GF_Node *node) { X_Shape *p = (X_Shape *) node; - gf_node_unregister((GF_Node *) p->appearance, node); - gf_node_unregister((GF_Node *) p->geometry, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->appearance, node); + gf_node_unregister((GF_Node *) p->geometry, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11274,7 +11274,7 @@ static s32 Shape_get_field_index_by_name(char *name) if (!strcmp("geometry", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *Shape_Create() @@ -11300,7 +11300,7 @@ static void SignalPdu_Del(GF_Node *node) gf_sg_mfint32_del(p->data); gf_sg_sfstring_del(p->multicastRelayHost); gf_sg_sfstring_del(p->networkMode); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11505,7 +11505,7 @@ static s32 SignalPdu_get_field_index_by_name(char *name) if (!strcmp("timestamp", name)) return 24; if (!strcmp("metadata", name)) return 25; return -1; - } +} static GF_Node *SignalPdu_Create() @@ -11545,8 +11545,8 @@ static GF_Node *SignalPdu_Create() static void Sound_Del(GF_Node *node) { X_Sound *p = (X_Sound *) node; - gf_node_unregister((GF_Node *) p->source, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->source, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11647,7 +11647,7 @@ static s32 Sound_get_field_index_by_name(char *name) if (!strcmp("spatialize", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *Sound_Create() @@ -11682,7 +11682,7 @@ static GF_Node *Sound_Create() static void Sphere_Del(GF_Node *node) { X_Sphere *p = (X_Sphere *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11719,7 +11719,7 @@ static s32 Sphere_get_field_index_by_name(char *name) if (!strcmp("radius", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *Sphere_Create() @@ -11742,7 +11742,7 @@ static GF_Node *Sphere_Create() static void SphereSensor_Del(GF_Node *node) { X_SphereSensor *p = (X_SphereSensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_sg_sfstring_del(p->description); gf_node_free((GF_Node *)p); } @@ -11829,7 +11829,7 @@ static s32 SphereSensor_get_field_index_by_name(char *name) if (!strcmp("description", name)) return 7; if (!strcmp("isOver", name)) return 8; return -1; - } +} static GF_Node *SphereSensor_Create() @@ -11857,7 +11857,7 @@ static GF_Node *SphereSensor_Create() static void SpotLight_Del(GF_Node *node) { X_SpotLight *p = (X_SpotLight *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -11957,7 +11957,7 @@ static s32 SpotLight_get_field_index_by_name(char *name) if (!strcmp("radius", name)) return 9; if (!strcmp("metadata", name)) return 10; return -1; - } +} static GF_Node *SpotLight_Create() @@ -11997,8 +11997,8 @@ static GF_Node *SpotLight_Create() static void StaticGroup_Del(GF_Node *node) { X_StaticGroup *p = (X_StaticGroup *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -12036,7 +12036,7 @@ static s32 StaticGroup_get_field_index_by_name(char *name) if (!strcmp("children", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *StaticGroup_Create() @@ -12061,7 +12061,7 @@ static void StringSensor_Del(GF_Node *node) X_StringSensor *p = (X_StringSensor *) node; gf_sg_sfstring_del(p->enteredText); gf_sg_sfstring_del(p->finalText); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12126,7 +12126,7 @@ static s32 StringSensor_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 4; if (!strcmp("metadata", name)) return 5; return -1; - } +} static GF_Node *StringSensor_Create() @@ -12150,8 +12150,8 @@ static GF_Node *StringSensor_Create() static void Switch_Del(GF_Node *node) { X_Switch *p = (X_Switch *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -12214,7 +12214,7 @@ static s32 Switch_get_field_index_by_name(char *name) if (!strcmp("whichChoice", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *Switch_Create() @@ -12240,8 +12240,8 @@ static void Text_Del(GF_Node *node) X_Text *p = (X_Text *) node; gf_sg_mfstring_del(p->string); gf_sg_mffloat_del(p->length); - gf_node_unregister((GF_Node *) p->fontStyle, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->fontStyle, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12300,7 +12300,7 @@ static s32 Text_get_field_index_by_name(char *name) if (!strcmp("maxExtent", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *Text_Create() @@ -12325,16 +12325,16 @@ static void TextureBackground_Del(GF_Node *node) X_TextureBackground *p = (X_TextureBackground *) node; gf_sg_mffloat_del(p->groundAngle); gf_sg_mfcolor_del(p->groundColor); - gf_node_unregister((GF_Node *) p->backTexture, node); - gf_node_unregister((GF_Node *) p->bottomTexture, node); - gf_node_unregister((GF_Node *) p->frontTexture, node); - gf_node_unregister((GF_Node *) p->leftTexture, node); - gf_node_unregister((GF_Node *) p->rightTexture, node); - gf_node_unregister((GF_Node *) p->topTexture, node); + gf_node_unregister((GF_Node *) p->backTexture, node); + gf_node_unregister((GF_Node *) p->bottomTexture, node); + gf_node_unregister((GF_Node *) p->frontTexture, node); + gf_node_unregister((GF_Node *) p->leftTexture, node); + gf_node_unregister((GF_Node *) p->rightTexture, node); + gf_node_unregister((GF_Node *) p->topTexture, node); gf_sg_mffloat_del(p->skyAngle); gf_sg_mfcolor_del(p->skyColor); gf_sg_mffloat_del(p->transparency); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12469,7 +12469,7 @@ static s32 TextureBackground_get_field_index_by_name(char *name) if (!strcmp("isBound", name)) return 13; if (!strcmp("metadata", name)) return 14; return -1; - } +} static GF_Node *TextureBackground_Create() @@ -12500,7 +12500,7 @@ static void TextureCoordinate_Del(GF_Node *node) { X_TextureCoordinate *p = (X_TextureCoordinate *) node; gf_sg_mfvec2f_del(p->point); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12537,7 +12537,7 @@ static s32 TextureCoordinate_get_field_index_by_name(char *name) if (!strcmp("point", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *TextureCoordinate_Create() @@ -12561,7 +12561,7 @@ static void TextureCoordinateGenerator_Del(GF_Node *node) X_TextureCoordinateGenerator *p = (X_TextureCoordinateGenerator *) node; gf_sg_sfstring_del(p->mode); gf_sg_mffloat_del(p->parameter); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12605,7 +12605,7 @@ static s32 TextureCoordinateGenerator_get_field_index_by_name(char *name) if (!strcmp("parameter", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *TextureCoordinateGenerator_Create() @@ -12629,7 +12629,7 @@ static GF_Node *TextureCoordinateGenerator_Create() static void TextureTransform_Del(GF_Node *node) { X_TextureTransform *p = (X_TextureTransform *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12687,7 +12687,7 @@ static s32 TextureTransform_get_field_index_by_name(char *name) if (!strcmp("translation", name)) return 3; if (!strcmp("metadata", name)) return 4; return -1; - } +} static GF_Node *TextureTransform_Create() @@ -12716,7 +12716,7 @@ static GF_Node *TextureTransform_Create() static void TimeSensor_Del(GF_Node *node) { X_TimeSensor *p = (X_TimeSensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12837,7 +12837,7 @@ static s32 TimeSensor_get_field_index_by_name(char *name) if (!strcmp("elapsedTime", name)) return 12; if (!strcmp("isPaused", name)) return 13; return -1; - } +} static GF_Node *TimeSensor_Create() @@ -12865,7 +12865,7 @@ static GF_Node *TimeSensor_Create() static void TimeTrigger_Del(GF_Node *node) { X_TimeTrigger *p = (X_TimeTrigger *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -12910,7 +12910,7 @@ static s32 TimeTrigger_get_field_index_by_name(char *name) if (!strcmp("triggerTime", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *TimeTrigger_Create() @@ -12932,7 +12932,7 @@ static GF_Node *TimeTrigger_Create() static void TouchSensor_Del(GF_Node *node) { X_TouchSensor *p = (X_TouchSensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_sg_sfstring_del(p->description); gf_node_free((GF_Node *)p); } @@ -13019,7 +13019,7 @@ static s32 TouchSensor_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 7; if (!strcmp("description", name)) return 8; return -1; - } +} static GF_Node *TouchSensor_Create() @@ -13042,8 +13042,8 @@ static GF_Node *TouchSensor_Create() static void Transform_Del(GF_Node *node) { X_Transform *p = (X_Transform *) node; - gf_node_unregister((GF_Node *) p->metadata, node); - gf_sg_vrml_parent_destroy(node); + gf_node_unregister((GF_Node *) p->metadata, node); + gf_sg_vrml_parent_destroy(node); gf_node_free((GF_Node *)p); } @@ -13134,7 +13134,7 @@ static s32 Transform_get_field_index_by_name(char *name) if (!strcmp("translation", name)) return 7; if (!strcmp("metadata", name)) return 8; return -1; - } +} static GF_Node *Transform_Create() @@ -13177,7 +13177,7 @@ static void TransmitterPdu_Del(GF_Node *node) gf_sg_sfstring_del(p->address); gf_sg_sfstring_del(p->multicastRelayHost); gf_sg_sfstring_del(p->networkMode); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -13494,7 +13494,7 @@ static s32 TransmitterPdu_get_field_index_by_name(char *name) if (!strcmp("timestamp", name)) return 40; if (!strcmp("metadata", name)) return 41; return -1; - } +} static GF_Node *TransmitterPdu_Create() @@ -13555,12 +13555,12 @@ static GF_Node *TransmitterPdu_Create() static void TriangleFanSet_Del(GF_Node *node) { X_TriangleFanSet *p = (X_TriangleFanSet *) node; - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); gf_sg_mfint32_del(p->fanCount); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -13657,7 +13657,7 @@ static s32 TriangleFanSet_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *TriangleFanSet_Create() @@ -13683,11 +13683,11 @@ static GF_Node *TriangleFanSet_Create() static void TriangleSet_Del(GF_Node *node) { X_TriangleSet *p = (X_TriangleSet *) node; - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); - gf_node_unregister((GF_Node *) p->texCoord, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -13777,7 +13777,7 @@ static s32 TriangleSet_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 7; if (!strcmp("metadata", name)) return 8; return -1; - } +} static GF_Node *TriangleSet_Create() @@ -13804,7 +13804,7 @@ static void TriangleSet2D_Del(GF_Node *node) { X_TriangleSet2D *p = (X_TriangleSet2D *) node; gf_sg_mfvec2f_del(p->vertices); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -13841,7 +13841,7 @@ static s32 TriangleSet2D_get_field_index_by_name(char *name) if (!strcmp("vertices", name)) return 0; if (!strcmp("metadata", name)) return 1; return -1; - } +} static GF_Node *TriangleSet2D_Create() @@ -13863,12 +13863,12 @@ static GF_Node *TriangleSet2D_Create() static void TriangleStripSet_Del(GF_Node *node) { X_TriangleStripSet *p = (X_TriangleStripSet *) node; - gf_node_unregister((GF_Node *) p->color, node); - gf_node_unregister((GF_Node *) p->coord, node); - gf_node_unregister((GF_Node *) p->normal, node); + gf_node_unregister((GF_Node *) p->color, node); + gf_node_unregister((GF_Node *) p->coord, node); + gf_node_unregister((GF_Node *) p->normal, node); gf_sg_mfint32_del(p->stripCount); - gf_node_unregister((GF_Node *) p->texCoord, node); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->texCoord, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -13965,7 +13965,7 @@ static s32 TriangleStripSet_get_field_index_by_name(char *name) if (!strcmp("solid", name)) return 8; if (!strcmp("metadata", name)) return 9; return -1; - } +} static GF_Node *TriangleStripSet_Create() @@ -13992,7 +13992,7 @@ static void Viewpoint_Del(GF_Node *node) { X_Viewpoint *p = (X_Viewpoint *) node; gf_sg_sfstring_del(p->description); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -14086,7 +14086,7 @@ static s32 Viewpoint_get_field_index_by_name(char *name) if (!strcmp("metadata", name)) return 8; if (!strcmp("centerOfRotation", name)) return 9; return -1; - } +} static GF_Node *Viewpoint_Create() @@ -14120,7 +14120,7 @@ static GF_Node *Viewpoint_Create() static void VisibilitySensor_Del(GF_Node *node) { X_VisibilitySensor *p = (X_VisibilitySensor *) node; - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -14192,7 +14192,7 @@ static s32 VisibilitySensor_get_field_index_by_name(char *name) if (!strcmp("isActive", name)) return 5; if (!strcmp("metadata", name)) return 6; return -1; - } +} static GF_Node *VisibilitySensor_Create() @@ -14223,7 +14223,7 @@ static void WorldInfo_Del(GF_Node *node) X_WorldInfo *p = (X_WorldInfo *) node; gf_sg_mfstring_del(p->info); gf_sg_sfstring_del(p->title); - gf_node_unregister((GF_Node *) p->metadata, node); + gf_node_unregister((GF_Node *) p->metadata, node); gf_node_free((GF_Node *)p); } @@ -14267,7 +14267,7 @@ static s32 WorldInfo_get_field_index_by_name(char *name) if (!strcmp("title", name)) return 1; if (!strcmp("metadata", name)) return 2; return -1; - } +} static GF_Node *WorldInfo_Create() @@ -14816,533 +14816,917 @@ void gf_sg_x3d_node_del(GF_Node *node) { switch (node->sgprivate->tag) { case TAG_X3D_Anchor: - Anchor_Del(node); return; + Anchor_Del(node); + return; + case TAG_X3D_Appearance: + Appearance_Del(node); + return; + case TAG_X3D_Arc2D: + Arc2D_Del(node); + return; + case TAG_X3D_ArcClose2D: + ArcClose2D_Del(node); + return; + case TAG_X3D_AudioClip: + AudioClip_Del(node); + return; + case TAG_X3D_Background: + Background_Del(node); + return; + case TAG_X3D_Billboard: + Billboard_Del(node); + return; + case TAG_X3D_BooleanFilter: + BooleanFilter_Del(node); + return; + case TAG_X3D_BooleanSequencer: + BooleanSequencer_Del(node); + return; + case TAG_X3D_BooleanToggle: + BooleanToggle_Del(node); + return; + case TAG_X3D_BooleanTrigger: + BooleanTrigger_Del(node); + return; + case TAG_X3D_Box: + Box_Del(node); + return; + case TAG_X3D_Circle2D: + Circle2D_Del(node); + return; + case TAG_X3D_Collision: + Collision_Del(node); + return; + case TAG_X3D_Color: + Color_Del(node); + return; + case TAG_X3D_ColorInterpolator: + ColorInterpolator_Del(node); + return; + case TAG_X3D_ColorRGBA: + ColorRGBA_Del(node); + return; + case TAG_X3D_Cone: + Cone_Del(node); + return; + case TAG_X3D_Contour2D: + Contour2D_Del(node); + return; + case TAG_X3D_ContourPolyline2D: + ContourPolyline2D_Del(node); + return; + case TAG_X3D_Coordinate: + Coordinate_Del(node); + return; + case TAG_X3D_CoordinateDouble: + CoordinateDouble_Del(node); + return; + case TAG_X3D_Coordinate2D: + Coordinate2D_Del(node); + return; + case TAG_X3D_CoordinateInterpolator: + CoordinateInterpolator_Del(node); + return; + case TAG_X3D_CoordinateInterpolator2D: + CoordinateInterpolator2D_Del(node); + return; + case TAG_X3D_Cylinder: + Cylinder_Del(node); + return; + case TAG_X3D_CylinderSensor: + CylinderSensor_Del(node); + return; + case TAG_X3D_DirectionalLight: + DirectionalLight_Del(node); + return; + case TAG_X3D_Disk2D: + Disk2D_Del(node); + return; + case TAG_X3D_ElevationGrid: + ElevationGrid_Del(node); + return; + case TAG_X3D_EspduTransform: + EspduTransform_Del(node); + return; + case TAG_X3D_Extrusion: + Extrusion_Del(node); + return; + case TAG_X3D_FillProperties: + FillProperties_Del(node); + return; + case TAG_X3D_Fog: + Fog_Del(node); + return; + case TAG_X3D_FontStyle: + FontStyle_Del(node); + return; + case TAG_X3D_GeoCoordinate: + GeoCoordinate_Del(node); + return; + case TAG_X3D_GeoElevationGrid: + GeoElevationGrid_Del(node); + return; + case TAG_X3D_GeoLocation: + GeoLocation_Del(node); + return; + case TAG_X3D_GeoLOD: + GeoLOD_Del(node); + return; + case TAG_X3D_GeoMetadata: + GeoMetadata_Del(node); + return; + case TAG_X3D_GeoOrigin: + GeoOrigin_Del(node); + return; + case TAG_X3D_GeoPositionInterpolator: + GeoPositionInterpolator_Del(node); + return; + case TAG_X3D_GeoTouchSensor: + GeoTouchSensor_Del(node); + return; + case TAG_X3D_GeoViewpoint: + GeoViewpoint_Del(node); + return; + case TAG_X3D_Group: + Group_Del(node); + return; + case TAG_X3D_HAnimDisplacer: + HAnimDisplacer_Del(node); + return; + case TAG_X3D_HAnimHumanoid: + HAnimHumanoid_Del(node); + return; + case TAG_X3D_HAnimJoint: + HAnimJoint_Del(node); + return; + case TAG_X3D_HAnimSegment: + HAnimSegment_Del(node); + return; + case TAG_X3D_HAnimSite: + HAnimSite_Del(node); + return; + case TAG_X3D_ImageTexture: + ImageTexture_Del(node); + return; + case TAG_X3D_IndexedFaceSet: + IndexedFaceSet_Del(node); + return; + case TAG_X3D_IndexedLineSet: + IndexedLineSet_Del(node); + return; + case TAG_X3D_IndexedTriangleFanSet: + IndexedTriangleFanSet_Del(node); + return; + case TAG_X3D_IndexedTriangleSet: + IndexedTriangleSet_Del(node); + return; + case TAG_X3D_IndexedTriangleStripSet: + IndexedTriangleStripSet_Del(node); + return; + case TAG_X3D_Inline: + Inline_Del(node); + return; + case TAG_X3D_IntegerSequencer: + IntegerSequencer_Del(node); + return; + case TAG_X3D_IntegerTrigger: + IntegerTrigger_Del(node); + return; + case TAG_X3D_KeySensor: + KeySensor_Del(node); + return; + case TAG_X3D_LineProperties: + LineProperties_Del(node); + return; + case TAG_X3D_LineSet: + LineSet_Del(node); + return; + case TAG_X3D_LoadSensor: + LoadSensor_Del(node); + return; + case TAG_X3D_LOD: + LOD_Del(node); + return; + case TAG_X3D_Material: + Material_Del(node); + return; + case TAG_X3D_MetadataDouble: + MetadataDouble_Del(node); + return; + case TAG_X3D_MetadataFloat: + MetadataFloat_Del(node); + return; + case TAG_X3D_MetadataInteger: + MetadataInteger_Del(node); + return; + case TAG_X3D_MetadataSet: + MetadataSet_Del(node); + return; + case TAG_X3D_MetadataString: + MetadataString_Del(node); + return; + case TAG_X3D_MovieTexture: + MovieTexture_Del(node); + return; + case TAG_X3D_MultiTexture: + MultiTexture_Del(node); + return; + case TAG_X3D_MultiTextureCoordinate: + MultiTextureCoordinate_Del(node); + return; + case TAG_X3D_MultiTextureTransform: + MultiTextureTransform_Del(node); + return; + case TAG_X3D_NavigationInfo: + NavigationInfo_Del(node); + return; + case TAG_X3D_Normal: + Normal_Del(node); + return; + case TAG_X3D_NormalInterpolator: + NormalInterpolator_Del(node); + return; + case TAG_X3D_NurbsCurve: + NurbsCurve_Del(node); + return; + case TAG_X3D_NurbsCurve2D: + NurbsCurve2D_Del(node); + return; + case TAG_X3D_NurbsOrientationInterpolator: + NurbsOrientationInterpolator_Del(node); + return; + case TAG_X3D_NurbsPatchSurface: + NurbsPatchSurface_Del(node); + return; + case TAG_X3D_NurbsPositionInterpolator: + NurbsPositionInterpolator_Del(node); + return; + case TAG_X3D_NurbsSet: + NurbsSet_Del(node); + return; + case TAG_X3D_NurbsSurfaceInterpolator: + NurbsSurfaceInterpolator_Del(node); + return; + case TAG_X3D_NurbsSweptSurface: + NurbsSweptSurface_Del(node); + return; + case TAG_X3D_NurbsSwungSurface: + NurbsSwungSurface_Del(node); + return; + case TAG_X3D_NurbsTextureCoordinate: + NurbsTextureCoordinate_Del(node); + return; + case TAG_X3D_NurbsTrimmedSurface: + NurbsTrimmedSurface_Del(node); + return; + case TAG_X3D_OrientationInterpolator: + OrientationInterpolator_Del(node); + return; + case TAG_X3D_PixelTexture: + PixelTexture_Del(node); + return; + case TAG_X3D_PlaneSensor: + PlaneSensor_Del(node); + return; + case TAG_X3D_PointLight: + PointLight_Del(node); + return; + case TAG_X3D_PointSet: + PointSet_Del(node); + return; + case TAG_X3D_Polyline2D: + Polyline2D_Del(node); + return; + case TAG_X3D_Polypoint2D: + Polypoint2D_Del(node); + return; + case TAG_X3D_PositionInterpolator: + PositionInterpolator_Del(node); + return; + case TAG_X3D_PositionInterpolator2D: + PositionInterpolator2D_Del(node); + return; + case TAG_X3D_ProximitySensor: + ProximitySensor_Del(node); + return; + case TAG_X3D_ReceiverPdu: + ReceiverPdu_Del(node); + return; + case TAG_X3D_Rectangle2D: + Rectangle2D_Del(node); + return; + case TAG_X3D_ScalarInterpolator: + ScalarInterpolator_Del(node); + return; + case TAG_X3D_Script: + Script_Del(node); + return; + case TAG_X3D_Shape: + Shape_Del(node); + return; + case TAG_X3D_SignalPdu: + SignalPdu_Del(node); + return; + case TAG_X3D_Sound: + Sound_Del(node); + return; + case TAG_X3D_Sphere: + Sphere_Del(node); + return; + case TAG_X3D_SphereSensor: + SphereSensor_Del(node); + return; + case TAG_X3D_SpotLight: + SpotLight_Del(node); + return; + case TAG_X3D_StaticGroup: + StaticGroup_Del(node); + return; + case TAG_X3D_StringSensor: + StringSensor_Del(node); + return; + case TAG_X3D_Switch: + Switch_Del(node); + return; + case TAG_X3D_Text: + Text_Del(node); + return; + case TAG_X3D_TextureBackground: + TextureBackground_Del(node); + return; + case TAG_X3D_TextureCoordinate: + TextureCoordinate_Del(node); + return; + case TAG_X3D_TextureCoordinateGenerator: + TextureCoordinateGenerator_Del(node); + return; + case TAG_X3D_TextureTransform: + TextureTransform_Del(node); + return; + case TAG_X3D_TimeSensor: + TimeSensor_Del(node); + return; + case TAG_X3D_TimeTrigger: + TimeTrigger_Del(node); + return; + case TAG_X3D_TouchSensor: + TouchSensor_Del(node); + return; + case TAG_X3D_Transform: + Transform_Del(node); + return; + case TAG_X3D_TransmitterPdu: + TransmitterPdu_Del(node); + return; + case TAG_X3D_TriangleFanSet: + TriangleFanSet_Del(node); + return; + case TAG_X3D_TriangleSet: + TriangleSet_Del(node); + return; + case TAG_X3D_TriangleSet2D: + TriangleSet2D_Del(node); + return; + case TAG_X3D_TriangleStripSet: + TriangleStripSet_Del(node); + return; + case TAG_X3D_Viewpoint: + Viewpoint_Del(node); + return; + case TAG_X3D_VisibilitySensor: + VisibilitySensor_Del(node); + return; + case TAG_X3D_WorldInfo: + WorldInfo_Del(node); + return; + default: + return; + } +} + +u32 gf_sg_x3d_node_get_field_count(GF_Node *node) +{ + switch (node->sgprivate->tag) { + case TAG_X3D_Anchor: + return Anchor_get_field_count(node, 0); + case TAG_X3D_Appearance: + return Appearance_get_field_count(node, 0); + case TAG_X3D_Arc2D: + return Arc2D_get_field_count(node, 0); + case TAG_X3D_ArcClose2D: + return ArcClose2D_get_field_count(node, 0); + case TAG_X3D_AudioClip: + return AudioClip_get_field_count(node, 0); + case TAG_X3D_Background: + return Background_get_field_count(node, 0); + case TAG_X3D_Billboard: + return Billboard_get_field_count(node, 0); + case TAG_X3D_BooleanFilter: + return BooleanFilter_get_field_count(node, 0); + case TAG_X3D_BooleanSequencer: + return BooleanSequencer_get_field_count(node, 0); + case TAG_X3D_BooleanToggle: + return BooleanToggle_get_field_count(node, 0); + case TAG_X3D_BooleanTrigger: + return BooleanTrigger_get_field_count(node, 0); + case TAG_X3D_Box: + return Box_get_field_count(node, 0); + case TAG_X3D_Circle2D: + return Circle2D_get_field_count(node, 0); + case TAG_X3D_Collision: + return Collision_get_field_count(node, 0); + case TAG_X3D_Color: + return Color_get_field_count(node, 0); + case TAG_X3D_ColorInterpolator: + return ColorInterpolator_get_field_count(node, 0); + case TAG_X3D_ColorRGBA: + return ColorRGBA_get_field_count(node, 0); + case TAG_X3D_Cone: + return Cone_get_field_count(node, 0); + case TAG_X3D_Contour2D: + return Contour2D_get_field_count(node, 0); + case TAG_X3D_ContourPolyline2D: + return ContourPolyline2D_get_field_count(node, 0); + case TAG_X3D_Coordinate: + return Coordinate_get_field_count(node, 0); + case TAG_X3D_CoordinateDouble: + return CoordinateDouble_get_field_count(node, 0); + case TAG_X3D_Coordinate2D: + return Coordinate2D_get_field_count(node, 0); + case TAG_X3D_CoordinateInterpolator: + return CoordinateInterpolator_get_field_count(node, 0); + case TAG_X3D_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field_count(node, 0); + case TAG_X3D_Cylinder: + return Cylinder_get_field_count(node, 0); + case TAG_X3D_CylinderSensor: + return CylinderSensor_get_field_count(node, 0); + case TAG_X3D_DirectionalLight: + return DirectionalLight_get_field_count(node, 0); + case TAG_X3D_Disk2D: + return Disk2D_get_field_count(node, 0); + case TAG_X3D_ElevationGrid: + return ElevationGrid_get_field_count(node, 0); + case TAG_X3D_EspduTransform: + return EspduTransform_get_field_count(node, 0); + case TAG_X3D_Extrusion: + return Extrusion_get_field_count(node, 0); + case TAG_X3D_FillProperties: + return FillProperties_get_field_count(node, 0); + case TAG_X3D_Fog: + return Fog_get_field_count(node, 0); + case TAG_X3D_FontStyle: + return FontStyle_get_field_count(node, 0); + case TAG_X3D_GeoCoordinate: + return GeoCoordinate_get_field_count(node, 0); + case TAG_X3D_GeoElevationGrid: + return GeoElevationGrid_get_field_count(node, 0); + case TAG_X3D_GeoLocation: + return GeoLocation_get_field_count(node, 0); + case TAG_X3D_GeoLOD: + return GeoLOD_get_field_count(node, 0); + case TAG_X3D_GeoMetadata: + return GeoMetadata_get_field_count(node, 0); + case TAG_X3D_GeoOrigin: + return GeoOrigin_get_field_count(node, 0); + case TAG_X3D_GeoPositionInterpolator: + return GeoPositionInterpolator_get_field_count(node, 0); + case TAG_X3D_GeoTouchSensor: + return GeoTouchSensor_get_field_count(node, 0); + case TAG_X3D_GeoViewpoint: + return GeoViewpoint_get_field_count(node, 0); + case TAG_X3D_Group: + return Group_get_field_count(node, 0); + case TAG_X3D_HAnimDisplacer: + return HAnimDisplacer_get_field_count(node, 0); + case TAG_X3D_HAnimHumanoid: + return HAnimHumanoid_get_field_count(node, 0); + case TAG_X3D_HAnimJoint: + return HAnimJoint_get_field_count(node, 0); + case TAG_X3D_HAnimSegment: + return HAnimSegment_get_field_count(node, 0); + case TAG_X3D_HAnimSite: + return HAnimSite_get_field_count(node, 0); + case TAG_X3D_ImageTexture: + return ImageTexture_get_field_count(node, 0); + case TAG_X3D_IndexedFaceSet: + return IndexedFaceSet_get_field_count(node, 0); + case TAG_X3D_IndexedLineSet: + return IndexedLineSet_get_field_count(node, 0); + case TAG_X3D_IndexedTriangleFanSet: + return IndexedTriangleFanSet_get_field_count(node, 0); + case TAG_X3D_IndexedTriangleSet: + return IndexedTriangleSet_get_field_count(node, 0); + case TAG_X3D_IndexedTriangleStripSet: + return IndexedTriangleStripSet_get_field_count(node, 0); + case TAG_X3D_Inline: + return Inline_get_field_count(node, 0); + case TAG_X3D_IntegerSequencer: + return IntegerSequencer_get_field_count(node, 0); + case TAG_X3D_IntegerTrigger: + return IntegerTrigger_get_field_count(node, 0); + case TAG_X3D_KeySensor: + return KeySensor_get_field_count(node, 0); + case TAG_X3D_LineProperties: + return LineProperties_get_field_count(node, 0); + case TAG_X3D_LineSet: + return LineSet_get_field_count(node, 0); + case TAG_X3D_LoadSensor: + return LoadSensor_get_field_count(node, 0); + case TAG_X3D_LOD: + return LOD_get_field_count(node, 0); + case TAG_X3D_Material: + return Material_get_field_count(node, 0); + case TAG_X3D_MetadataDouble: + return MetadataDouble_get_field_count(node, 0); + case TAG_X3D_MetadataFloat: + return MetadataFloat_get_field_count(node, 0); + case TAG_X3D_MetadataInteger: + return MetadataInteger_get_field_count(node, 0); + case TAG_X3D_MetadataSet: + return MetadataSet_get_field_count(node, 0); + case TAG_X3D_MetadataString: + return MetadataString_get_field_count(node, 0); + case TAG_X3D_MovieTexture: + return MovieTexture_get_field_count(node, 0); + case TAG_X3D_MultiTexture: + return MultiTexture_get_field_count(node, 0); + case TAG_X3D_MultiTextureCoordinate: + return MultiTextureCoordinate_get_field_count(node, 0); + case TAG_X3D_MultiTextureTransform: + return MultiTextureTransform_get_field_count(node, 0); + case TAG_X3D_NavigationInfo: + return NavigationInfo_get_field_count(node, 0); + case TAG_X3D_Normal: + return Normal_get_field_count(node, 0); + case TAG_X3D_NormalInterpolator: + return NormalInterpolator_get_field_count(node, 0); + case TAG_X3D_NurbsCurve: + return NurbsCurve_get_field_count(node, 0); + case TAG_X3D_NurbsCurve2D: + return NurbsCurve2D_get_field_count(node, 0); + case TAG_X3D_NurbsOrientationInterpolator: + return NurbsOrientationInterpolator_get_field_count(node, 0); + case TAG_X3D_NurbsPatchSurface: + return NurbsPatchSurface_get_field_count(node, 0); + case TAG_X3D_NurbsPositionInterpolator: + return NurbsPositionInterpolator_get_field_count(node, 0); + case TAG_X3D_NurbsSet: + return NurbsSet_get_field_count(node, 0); + case TAG_X3D_NurbsSurfaceInterpolator: + return NurbsSurfaceInterpolator_get_field_count(node, 0); + case TAG_X3D_NurbsSweptSurface: + return NurbsSweptSurface_get_field_count(node, 0); + case TAG_X3D_NurbsSwungSurface: + return NurbsSwungSurface_get_field_count(node, 0); + case TAG_X3D_NurbsTextureCoordinate: + return NurbsTextureCoordinate_get_field_count(node, 0); + case TAG_X3D_NurbsTrimmedSurface: + return NurbsTrimmedSurface_get_field_count(node, 0); + case TAG_X3D_OrientationInterpolator: + return OrientationInterpolator_get_field_count(node, 0); + case TAG_X3D_PixelTexture: + return PixelTexture_get_field_count(node, 0); + case TAG_X3D_PlaneSensor: + return PlaneSensor_get_field_count(node, 0); + case TAG_X3D_PointLight: + return PointLight_get_field_count(node, 0); + case TAG_X3D_PointSet: + return PointSet_get_field_count(node, 0); + case TAG_X3D_Polyline2D: + return Polyline2D_get_field_count(node, 0); + case TAG_X3D_Polypoint2D: + return Polypoint2D_get_field_count(node, 0); + case TAG_X3D_PositionInterpolator: + return PositionInterpolator_get_field_count(node, 0); + case TAG_X3D_PositionInterpolator2D: + return PositionInterpolator2D_get_field_count(node, 0); + case TAG_X3D_ProximitySensor: + return ProximitySensor_get_field_count(node, 0); + case TAG_X3D_ReceiverPdu: + return ReceiverPdu_get_field_count(node, 0); + case TAG_X3D_Rectangle2D: + return Rectangle2D_get_field_count(node, 0); + case TAG_X3D_ScalarInterpolator: + return ScalarInterpolator_get_field_count(node, 0); + case TAG_X3D_Script: + return Script_get_field_count(node, 0); + case TAG_X3D_Shape: + return Shape_get_field_count(node, 0); + case TAG_X3D_SignalPdu: + return SignalPdu_get_field_count(node, 0); + case TAG_X3D_Sound: + return Sound_get_field_count(node, 0); + case TAG_X3D_Sphere: + return Sphere_get_field_count(node, 0); + case TAG_X3D_SphereSensor: + return SphereSensor_get_field_count(node, 0); + case TAG_X3D_SpotLight: + return SpotLight_get_field_count(node, 0); + case TAG_X3D_StaticGroup: + return StaticGroup_get_field_count(node, 0); + case TAG_X3D_StringSensor: + return StringSensor_get_field_count(node, 0); + case TAG_X3D_Switch: + return Switch_get_field_count(node, 0); + case TAG_X3D_Text: + return Text_get_field_count(node, 0); + case TAG_X3D_TextureBackground: + return TextureBackground_get_field_count(node, 0); + case TAG_X3D_TextureCoordinate: + return TextureCoordinate_get_field_count(node, 0); + case TAG_X3D_TextureCoordinateGenerator: + return TextureCoordinateGenerator_get_field_count(node, 0); + case TAG_X3D_TextureTransform: + return TextureTransform_get_field_count(node, 0); + case TAG_X3D_TimeSensor: + return TimeSensor_get_field_count(node, 0); + case TAG_X3D_TimeTrigger: + return TimeTrigger_get_field_count(node, 0); + case TAG_X3D_TouchSensor: + return TouchSensor_get_field_count(node, 0); + case TAG_X3D_Transform: + return Transform_get_field_count(node, 0); + case TAG_X3D_TransmitterPdu: + return TransmitterPdu_get_field_count(node, 0); + case TAG_X3D_TriangleFanSet: + return TriangleFanSet_get_field_count(node, 0); + case TAG_X3D_TriangleSet: + return TriangleSet_get_field_count(node, 0); + case TAG_X3D_TriangleSet2D: + return TriangleSet2D_get_field_count(node, 0); + case TAG_X3D_TriangleStripSet: + return TriangleStripSet_get_field_count(node, 0); + case TAG_X3D_Viewpoint: + return Viewpoint_get_field_count(node, 0); + case TAG_X3D_VisibilitySensor: + return VisibilitySensor_get_field_count(node, 0); + case TAG_X3D_WorldInfo: + return WorldInfo_get_field_count(node, 0); + default: + return 0; + } +} + +GF_Err gf_sg_x3d_node_get_field(GF_Node *node, GF_FieldInfo *field) +{ + switch (node->sgprivate->tag) { + case TAG_X3D_Anchor: + return Anchor_get_field(node, field); case TAG_X3D_Appearance: - Appearance_Del(node); return; + return Appearance_get_field(node, field); case TAG_X3D_Arc2D: - Arc2D_Del(node); return; + return Arc2D_get_field(node, field); case TAG_X3D_ArcClose2D: - ArcClose2D_Del(node); return; + return ArcClose2D_get_field(node, field); case TAG_X3D_AudioClip: - AudioClip_Del(node); return; + return AudioClip_get_field(node, field); case TAG_X3D_Background: - Background_Del(node); return; + return Background_get_field(node, field); case TAG_X3D_Billboard: - Billboard_Del(node); return; + return Billboard_get_field(node, field); case TAG_X3D_BooleanFilter: - BooleanFilter_Del(node); return; + return BooleanFilter_get_field(node, field); case TAG_X3D_BooleanSequencer: - BooleanSequencer_Del(node); return; + return BooleanSequencer_get_field(node, field); case TAG_X3D_BooleanToggle: - BooleanToggle_Del(node); return; + return BooleanToggle_get_field(node, field); case TAG_X3D_BooleanTrigger: - BooleanTrigger_Del(node); return; + return BooleanTrigger_get_field(node, field); case TAG_X3D_Box: - Box_Del(node); return; + return Box_get_field(node, field); case TAG_X3D_Circle2D: - Circle2D_Del(node); return; + return Circle2D_get_field(node, field); case TAG_X3D_Collision: - Collision_Del(node); return; + return Collision_get_field(node, field); case TAG_X3D_Color: - Color_Del(node); return; + return Color_get_field(node, field); case TAG_X3D_ColorInterpolator: - ColorInterpolator_Del(node); return; + return ColorInterpolator_get_field(node, field); case TAG_X3D_ColorRGBA: - ColorRGBA_Del(node); return; + return ColorRGBA_get_field(node, field); case TAG_X3D_Cone: - Cone_Del(node); return; + return Cone_get_field(node, field); case TAG_X3D_Contour2D: - Contour2D_Del(node); return; + return Contour2D_get_field(node, field); case TAG_X3D_ContourPolyline2D: - ContourPolyline2D_Del(node); return; + return ContourPolyline2D_get_field(node, field); case TAG_X3D_Coordinate: - Coordinate_Del(node); return; + return Coordinate_get_field(node, field); case TAG_X3D_CoordinateDouble: - CoordinateDouble_Del(node); return; + return CoordinateDouble_get_field(node, field); case TAG_X3D_Coordinate2D: - Coordinate2D_Del(node); return; + return Coordinate2D_get_field(node, field); case TAG_X3D_CoordinateInterpolator: - CoordinateInterpolator_Del(node); return; + return CoordinateInterpolator_get_field(node, field); case TAG_X3D_CoordinateInterpolator2D: - CoordinateInterpolator2D_Del(node); return; + return CoordinateInterpolator2D_get_field(node, field); case TAG_X3D_Cylinder: - Cylinder_Del(node); return; + return Cylinder_get_field(node, field); case TAG_X3D_CylinderSensor: - CylinderSensor_Del(node); return; + return CylinderSensor_get_field(node, field); case TAG_X3D_DirectionalLight: - DirectionalLight_Del(node); return; + return DirectionalLight_get_field(node, field); case TAG_X3D_Disk2D: - Disk2D_Del(node); return; + return Disk2D_get_field(node, field); case TAG_X3D_ElevationGrid: - ElevationGrid_Del(node); return; + return ElevationGrid_get_field(node, field); case TAG_X3D_EspduTransform: - EspduTransform_Del(node); return; + return EspduTransform_get_field(node, field); case TAG_X3D_Extrusion: - Extrusion_Del(node); return; + return Extrusion_get_field(node, field); case TAG_X3D_FillProperties: - FillProperties_Del(node); return; + return FillProperties_get_field(node, field); case TAG_X3D_Fog: - Fog_Del(node); return; + return Fog_get_field(node, field); case TAG_X3D_FontStyle: - FontStyle_Del(node); return; + return FontStyle_get_field(node, field); case TAG_X3D_GeoCoordinate: - GeoCoordinate_Del(node); return; + return GeoCoordinate_get_field(node, field); case TAG_X3D_GeoElevationGrid: - GeoElevationGrid_Del(node); return; + return GeoElevationGrid_get_field(node, field); case TAG_X3D_GeoLocation: - GeoLocation_Del(node); return; + return GeoLocation_get_field(node, field); case TAG_X3D_GeoLOD: - GeoLOD_Del(node); return; + return GeoLOD_get_field(node, field); case TAG_X3D_GeoMetadata: - GeoMetadata_Del(node); return; + return GeoMetadata_get_field(node, field); case TAG_X3D_GeoOrigin: - GeoOrigin_Del(node); return; + return GeoOrigin_get_field(node, field); case TAG_X3D_GeoPositionInterpolator: - GeoPositionInterpolator_Del(node); return; + return GeoPositionInterpolator_get_field(node, field); case TAG_X3D_GeoTouchSensor: - GeoTouchSensor_Del(node); return; + return GeoTouchSensor_get_field(node, field); case TAG_X3D_GeoViewpoint: - GeoViewpoint_Del(node); return; + return GeoViewpoint_get_field(node, field); case TAG_X3D_Group: - Group_Del(node); return; + return Group_get_field(node, field); case TAG_X3D_HAnimDisplacer: - HAnimDisplacer_Del(node); return; + return HAnimDisplacer_get_field(node, field); case TAG_X3D_HAnimHumanoid: - HAnimHumanoid_Del(node); return; + return HAnimHumanoid_get_field(node, field); case TAG_X3D_HAnimJoint: - HAnimJoint_Del(node); return; + return HAnimJoint_get_field(node, field); case TAG_X3D_HAnimSegment: - HAnimSegment_Del(node); return; + return HAnimSegment_get_field(node, field); case TAG_X3D_HAnimSite: - HAnimSite_Del(node); return; + return HAnimSite_get_field(node, field); case TAG_X3D_ImageTexture: - ImageTexture_Del(node); return; + return ImageTexture_get_field(node, field); case TAG_X3D_IndexedFaceSet: - IndexedFaceSet_Del(node); return; + return IndexedFaceSet_get_field(node, field); case TAG_X3D_IndexedLineSet: - IndexedLineSet_Del(node); return; + return IndexedLineSet_get_field(node, field); case TAG_X3D_IndexedTriangleFanSet: - IndexedTriangleFanSet_Del(node); return; + return IndexedTriangleFanSet_get_field(node, field); case TAG_X3D_IndexedTriangleSet: - IndexedTriangleSet_Del(node); return; + return IndexedTriangleSet_get_field(node, field); case TAG_X3D_IndexedTriangleStripSet: - IndexedTriangleStripSet_Del(node); return; + return IndexedTriangleStripSet_get_field(node, field); case TAG_X3D_Inline: - Inline_Del(node); return; + return Inline_get_field(node, field); case TAG_X3D_IntegerSequencer: - IntegerSequencer_Del(node); return; + return IntegerSequencer_get_field(node, field); case TAG_X3D_IntegerTrigger: - IntegerTrigger_Del(node); return; + return IntegerTrigger_get_field(node, field); case TAG_X3D_KeySensor: - KeySensor_Del(node); return; + return KeySensor_get_field(node, field); case TAG_X3D_LineProperties: - LineProperties_Del(node); return; + return LineProperties_get_field(node, field); case TAG_X3D_LineSet: - LineSet_Del(node); return; + return LineSet_get_field(node, field); case TAG_X3D_LoadSensor: - LoadSensor_Del(node); return; + return LoadSensor_get_field(node, field); case TAG_X3D_LOD: - LOD_Del(node); return; + return LOD_get_field(node, field); case TAG_X3D_Material: - Material_Del(node); return; + return Material_get_field(node, field); case TAG_X3D_MetadataDouble: - MetadataDouble_Del(node); return; + return MetadataDouble_get_field(node, field); case TAG_X3D_MetadataFloat: - MetadataFloat_Del(node); return; + return MetadataFloat_get_field(node, field); case TAG_X3D_MetadataInteger: - MetadataInteger_Del(node); return; + return MetadataInteger_get_field(node, field); case TAG_X3D_MetadataSet: - MetadataSet_Del(node); return; + return MetadataSet_get_field(node, field); case TAG_X3D_MetadataString: - MetadataString_Del(node); return; + return MetadataString_get_field(node, field); case TAG_X3D_MovieTexture: - MovieTexture_Del(node); return; + return MovieTexture_get_field(node, field); case TAG_X3D_MultiTexture: - MultiTexture_Del(node); return; + return MultiTexture_get_field(node, field); case TAG_X3D_MultiTextureCoordinate: - MultiTextureCoordinate_Del(node); return; + return MultiTextureCoordinate_get_field(node, field); case TAG_X3D_MultiTextureTransform: - MultiTextureTransform_Del(node); return; + return MultiTextureTransform_get_field(node, field); case TAG_X3D_NavigationInfo: - NavigationInfo_Del(node); return; + return NavigationInfo_get_field(node, field); case TAG_X3D_Normal: - Normal_Del(node); return; + return Normal_get_field(node, field); case TAG_X3D_NormalInterpolator: - NormalInterpolator_Del(node); return; + return NormalInterpolator_get_field(node, field); case TAG_X3D_NurbsCurve: - NurbsCurve_Del(node); return; + return NurbsCurve_get_field(node, field); case TAG_X3D_NurbsCurve2D: - NurbsCurve2D_Del(node); return; + return NurbsCurve2D_get_field(node, field); case TAG_X3D_NurbsOrientationInterpolator: - NurbsOrientationInterpolator_Del(node); return; + return NurbsOrientationInterpolator_get_field(node, field); case TAG_X3D_NurbsPatchSurface: - NurbsPatchSurface_Del(node); return; + return NurbsPatchSurface_get_field(node, field); case TAG_X3D_NurbsPositionInterpolator: - NurbsPositionInterpolator_Del(node); return; + return NurbsPositionInterpolator_get_field(node, field); case TAG_X3D_NurbsSet: - NurbsSet_Del(node); return; + return NurbsSet_get_field(node, field); case TAG_X3D_NurbsSurfaceInterpolator: - NurbsSurfaceInterpolator_Del(node); return; + return NurbsSurfaceInterpolator_get_field(node, field); case TAG_X3D_NurbsSweptSurface: - NurbsSweptSurface_Del(node); return; + return NurbsSweptSurface_get_field(node, field); case TAG_X3D_NurbsSwungSurface: - NurbsSwungSurface_Del(node); return; + return NurbsSwungSurface_get_field(node, field); case TAG_X3D_NurbsTextureCoordinate: - NurbsTextureCoordinate_Del(node); return; + return NurbsTextureCoordinate_get_field(node, field); case TAG_X3D_NurbsTrimmedSurface: - NurbsTrimmedSurface_Del(node); return; + return NurbsTrimmedSurface_get_field(node, field); case TAG_X3D_OrientationInterpolator: - OrientationInterpolator_Del(node); return; + return OrientationInterpolator_get_field(node, field); case TAG_X3D_PixelTexture: - PixelTexture_Del(node); return; + return PixelTexture_get_field(node, field); case TAG_X3D_PlaneSensor: - PlaneSensor_Del(node); return; + return PlaneSensor_get_field(node, field); case TAG_X3D_PointLight: - PointLight_Del(node); return; + return PointLight_get_field(node, field); case TAG_X3D_PointSet: - PointSet_Del(node); return; + return PointSet_get_field(node, field); case TAG_X3D_Polyline2D: - Polyline2D_Del(node); return; + return Polyline2D_get_field(node, field); case TAG_X3D_Polypoint2D: - Polypoint2D_Del(node); return; + return Polypoint2D_get_field(node, field); case TAG_X3D_PositionInterpolator: - PositionInterpolator_Del(node); return; + return PositionInterpolator_get_field(node, field); case TAG_X3D_PositionInterpolator2D: - PositionInterpolator2D_Del(node); return; + return PositionInterpolator2D_get_field(node, field); case TAG_X3D_ProximitySensor: - ProximitySensor_Del(node); return; + return ProximitySensor_get_field(node, field); case TAG_X3D_ReceiverPdu: - ReceiverPdu_Del(node); return; + return ReceiverPdu_get_field(node, field); case TAG_X3D_Rectangle2D: - Rectangle2D_Del(node); return; + return Rectangle2D_get_field(node, field); case TAG_X3D_ScalarInterpolator: - ScalarInterpolator_Del(node); return; + return ScalarInterpolator_get_field(node, field); case TAG_X3D_Script: - Script_Del(node); return; + return Script_get_field(node, field); case TAG_X3D_Shape: - Shape_Del(node); return; + return Shape_get_field(node, field); case TAG_X3D_SignalPdu: - SignalPdu_Del(node); return; + return SignalPdu_get_field(node, field); case TAG_X3D_Sound: - Sound_Del(node); return; + return Sound_get_field(node, field); case TAG_X3D_Sphere: - Sphere_Del(node); return; + return Sphere_get_field(node, field); case TAG_X3D_SphereSensor: - SphereSensor_Del(node); return; + return SphereSensor_get_field(node, field); case TAG_X3D_SpotLight: - SpotLight_Del(node); return; + return SpotLight_get_field(node, field); case TAG_X3D_StaticGroup: - StaticGroup_Del(node); return; + return StaticGroup_get_field(node, field); case TAG_X3D_StringSensor: - StringSensor_Del(node); return; + return StringSensor_get_field(node, field); case TAG_X3D_Switch: - Switch_Del(node); return; + return Switch_get_field(node, field); case TAG_X3D_Text: - Text_Del(node); return; + return Text_get_field(node, field); case TAG_X3D_TextureBackground: - TextureBackground_Del(node); return; + return TextureBackground_get_field(node, field); case TAG_X3D_TextureCoordinate: - TextureCoordinate_Del(node); return; + return TextureCoordinate_get_field(node, field); case TAG_X3D_TextureCoordinateGenerator: - TextureCoordinateGenerator_Del(node); return; + return TextureCoordinateGenerator_get_field(node, field); case TAG_X3D_TextureTransform: - TextureTransform_Del(node); return; + return TextureTransform_get_field(node, field); case TAG_X3D_TimeSensor: - TimeSensor_Del(node); return; + return TimeSensor_get_field(node, field); case TAG_X3D_TimeTrigger: - TimeTrigger_Del(node); return; + return TimeTrigger_get_field(node, field); case TAG_X3D_TouchSensor: - TouchSensor_Del(node); return; + return TouchSensor_get_field(node, field); case TAG_X3D_Transform: - Transform_Del(node); return; + return Transform_get_field(node, field); case TAG_X3D_TransmitterPdu: - TransmitterPdu_Del(node); return; + return TransmitterPdu_get_field(node, field); case TAG_X3D_TriangleFanSet: - TriangleFanSet_Del(node); return; + return TriangleFanSet_get_field(node, field); case TAG_X3D_TriangleSet: - TriangleSet_Del(node); return; + return TriangleSet_get_field(node, field); case TAG_X3D_TriangleSet2D: - TriangleSet2D_Del(node); return; + return TriangleSet2D_get_field(node, field); case TAG_X3D_TriangleStripSet: - TriangleStripSet_Del(node); return; + return TriangleStripSet_get_field(node, field); case TAG_X3D_Viewpoint: - Viewpoint_Del(node); return; + return Viewpoint_get_field(node, field); case TAG_X3D_VisibilitySensor: - VisibilitySensor_Del(node); return; + return VisibilitySensor_get_field(node, field); case TAG_X3D_WorldInfo: - WorldInfo_Del(node); return; - default: - return; - } -} - -u32 gf_sg_x3d_node_get_field_count(GF_Node *node) -{ - switch (node->sgprivate->tag) { - case TAG_X3D_Anchor:return Anchor_get_field_count(node, 0); - case TAG_X3D_Appearance:return Appearance_get_field_count(node, 0); - case TAG_X3D_Arc2D:return Arc2D_get_field_count(node, 0); - case TAG_X3D_ArcClose2D:return ArcClose2D_get_field_count(node, 0); - case TAG_X3D_AudioClip:return AudioClip_get_field_count(node, 0); - case TAG_X3D_Background:return Background_get_field_count(node, 0); - case TAG_X3D_Billboard:return Billboard_get_field_count(node, 0); - case TAG_X3D_BooleanFilter:return BooleanFilter_get_field_count(node, 0); - case TAG_X3D_BooleanSequencer:return BooleanSequencer_get_field_count(node, 0); - case TAG_X3D_BooleanToggle:return BooleanToggle_get_field_count(node, 0); - case TAG_X3D_BooleanTrigger:return BooleanTrigger_get_field_count(node, 0); - case TAG_X3D_Box:return Box_get_field_count(node, 0); - case TAG_X3D_Circle2D:return Circle2D_get_field_count(node, 0); - case TAG_X3D_Collision:return Collision_get_field_count(node, 0); - case TAG_X3D_Color:return Color_get_field_count(node, 0); - case TAG_X3D_ColorInterpolator:return ColorInterpolator_get_field_count(node, 0); - case TAG_X3D_ColorRGBA:return ColorRGBA_get_field_count(node, 0); - case TAG_X3D_Cone:return Cone_get_field_count(node, 0); - case TAG_X3D_Contour2D:return Contour2D_get_field_count(node, 0); - case TAG_X3D_ContourPolyline2D:return ContourPolyline2D_get_field_count(node, 0); - case TAG_X3D_Coordinate:return Coordinate_get_field_count(node, 0); - case TAG_X3D_CoordinateDouble:return CoordinateDouble_get_field_count(node, 0); - case TAG_X3D_Coordinate2D:return Coordinate2D_get_field_count(node, 0); - case TAG_X3D_CoordinateInterpolator:return CoordinateInterpolator_get_field_count(node, 0); - case TAG_X3D_CoordinateInterpolator2D:return CoordinateInterpolator2D_get_field_count(node, 0); - case TAG_X3D_Cylinder:return Cylinder_get_field_count(node, 0); - case TAG_X3D_CylinderSensor:return CylinderSensor_get_field_count(node, 0); - case TAG_X3D_DirectionalLight:return DirectionalLight_get_field_count(node, 0); - case TAG_X3D_Disk2D:return Disk2D_get_field_count(node, 0); - case TAG_X3D_ElevationGrid:return ElevationGrid_get_field_count(node, 0); - case TAG_X3D_EspduTransform:return EspduTransform_get_field_count(node, 0); - case TAG_X3D_Extrusion:return Extrusion_get_field_count(node, 0); - case TAG_X3D_FillProperties:return FillProperties_get_field_count(node, 0); - case TAG_X3D_Fog:return Fog_get_field_count(node, 0); - case TAG_X3D_FontStyle:return FontStyle_get_field_count(node, 0); - case TAG_X3D_GeoCoordinate:return GeoCoordinate_get_field_count(node, 0); - case TAG_X3D_GeoElevationGrid:return GeoElevationGrid_get_field_count(node, 0); - case TAG_X3D_GeoLocation:return GeoLocation_get_field_count(node, 0); - case TAG_X3D_GeoLOD:return GeoLOD_get_field_count(node, 0); - case TAG_X3D_GeoMetadata:return GeoMetadata_get_field_count(node, 0); - case TAG_X3D_GeoOrigin:return GeoOrigin_get_field_count(node, 0); - case TAG_X3D_GeoPositionInterpolator:return GeoPositionInterpolator_get_field_count(node, 0); - case TAG_X3D_GeoTouchSensor:return GeoTouchSensor_get_field_count(node, 0); - case TAG_X3D_GeoViewpoint:return GeoViewpoint_get_field_count(node, 0); - case TAG_X3D_Group:return Group_get_field_count(node, 0); - case TAG_X3D_HAnimDisplacer:return HAnimDisplacer_get_field_count(node, 0); - case TAG_X3D_HAnimHumanoid:return HAnimHumanoid_get_field_count(node, 0); - case TAG_X3D_HAnimJoint:return HAnimJoint_get_field_count(node, 0); - case TAG_X3D_HAnimSegment:return HAnimSegment_get_field_count(node, 0); - case TAG_X3D_HAnimSite:return HAnimSite_get_field_count(node, 0); - case TAG_X3D_ImageTexture:return ImageTexture_get_field_count(node, 0); - case TAG_X3D_IndexedFaceSet:return IndexedFaceSet_get_field_count(node, 0); - case TAG_X3D_IndexedLineSet:return IndexedLineSet_get_field_count(node, 0); - case TAG_X3D_IndexedTriangleFanSet:return IndexedTriangleFanSet_get_field_count(node, 0); - case TAG_X3D_IndexedTriangleSet:return IndexedTriangleSet_get_field_count(node, 0); - case TAG_X3D_IndexedTriangleStripSet:return IndexedTriangleStripSet_get_field_count(node, 0); - case TAG_X3D_Inline:return Inline_get_field_count(node, 0); - case TAG_X3D_IntegerSequencer:return IntegerSequencer_get_field_count(node, 0); - case TAG_X3D_IntegerTrigger:return IntegerTrigger_get_field_count(node, 0); - case TAG_X3D_KeySensor:return KeySensor_get_field_count(node, 0); - case TAG_X3D_LineProperties:return LineProperties_get_field_count(node, 0); - case TAG_X3D_LineSet:return LineSet_get_field_count(node, 0); - case TAG_X3D_LoadSensor:return LoadSensor_get_field_count(node, 0); - case TAG_X3D_LOD:return LOD_get_field_count(node, 0); - case TAG_X3D_Material:return Material_get_field_count(node, 0); - case TAG_X3D_MetadataDouble:return MetadataDouble_get_field_count(node, 0); - case TAG_X3D_MetadataFloat:return MetadataFloat_get_field_count(node, 0); - case TAG_X3D_MetadataInteger:return MetadataInteger_get_field_count(node, 0); - case TAG_X3D_MetadataSet:return MetadataSet_get_field_count(node, 0); - case TAG_X3D_MetadataString:return MetadataString_get_field_count(node, 0); - case TAG_X3D_MovieTexture:return MovieTexture_get_field_count(node, 0); - case TAG_X3D_MultiTexture:return MultiTexture_get_field_count(node, 0); - case TAG_X3D_MultiTextureCoordinate:return MultiTextureCoordinate_get_field_count(node, 0); - case TAG_X3D_MultiTextureTransform:return MultiTextureTransform_get_field_count(node, 0); - case TAG_X3D_NavigationInfo:return NavigationInfo_get_field_count(node, 0); - case TAG_X3D_Normal:return Normal_get_field_count(node, 0); - case TAG_X3D_NormalInterpolator:return NormalInterpolator_get_field_count(node, 0); - case TAG_X3D_NurbsCurve:return NurbsCurve_get_field_count(node, 0); - case TAG_X3D_NurbsCurve2D:return NurbsCurve2D_get_field_count(node, 0); - case TAG_X3D_NurbsOrientationInterpolator:return NurbsOrientationInterpolator_get_field_count(node, 0); - case TAG_X3D_NurbsPatchSurface:return NurbsPatchSurface_get_field_count(node, 0); - case TAG_X3D_NurbsPositionInterpolator:return NurbsPositionInterpolator_get_field_count(node, 0); - case TAG_X3D_NurbsSet:return NurbsSet_get_field_count(node, 0); - case TAG_X3D_NurbsSurfaceInterpolator:return NurbsSurfaceInterpolator_get_field_count(node, 0); - case TAG_X3D_NurbsSweptSurface:return NurbsSweptSurface_get_field_count(node, 0); - case TAG_X3D_NurbsSwungSurface:return NurbsSwungSurface_get_field_count(node, 0); - case TAG_X3D_NurbsTextureCoordinate:return NurbsTextureCoordinate_get_field_count(node, 0); - case TAG_X3D_NurbsTrimmedSurface:return NurbsTrimmedSurface_get_field_count(node, 0); - case TAG_X3D_OrientationInterpolator:return OrientationInterpolator_get_field_count(node, 0); - case TAG_X3D_PixelTexture:return PixelTexture_get_field_count(node, 0); - case TAG_X3D_PlaneSensor:return PlaneSensor_get_field_count(node, 0); - case TAG_X3D_PointLight:return PointLight_get_field_count(node, 0); - case TAG_X3D_PointSet:return PointSet_get_field_count(node, 0); - case TAG_X3D_Polyline2D:return Polyline2D_get_field_count(node, 0); - case TAG_X3D_Polypoint2D:return Polypoint2D_get_field_count(node, 0); - case TAG_X3D_PositionInterpolator:return PositionInterpolator_get_field_count(node, 0); - case TAG_X3D_PositionInterpolator2D:return PositionInterpolator2D_get_field_count(node, 0); - case TAG_X3D_ProximitySensor:return ProximitySensor_get_field_count(node, 0); - case TAG_X3D_ReceiverPdu:return ReceiverPdu_get_field_count(node, 0); - case TAG_X3D_Rectangle2D:return Rectangle2D_get_field_count(node, 0); - case TAG_X3D_ScalarInterpolator:return ScalarInterpolator_get_field_count(node, 0); - case TAG_X3D_Script:return Script_get_field_count(node, 0); - case TAG_X3D_Shape:return Shape_get_field_count(node, 0); - case TAG_X3D_SignalPdu:return SignalPdu_get_field_count(node, 0); - case TAG_X3D_Sound:return Sound_get_field_count(node, 0); - case TAG_X3D_Sphere:return Sphere_get_field_count(node, 0); - case TAG_X3D_SphereSensor:return SphereSensor_get_field_count(node, 0); - case TAG_X3D_SpotLight:return SpotLight_get_field_count(node, 0); - case TAG_X3D_StaticGroup:return StaticGroup_get_field_count(node, 0); - case TAG_X3D_StringSensor:return StringSensor_get_field_count(node, 0); - case TAG_X3D_Switch:return Switch_get_field_count(node, 0); - case TAG_X3D_Text:return Text_get_field_count(node, 0); - case TAG_X3D_TextureBackground:return TextureBackground_get_field_count(node, 0); - case TAG_X3D_TextureCoordinate:return TextureCoordinate_get_field_count(node, 0); - case TAG_X3D_TextureCoordinateGenerator:return TextureCoordinateGenerator_get_field_count(node, 0); - case TAG_X3D_TextureTransform:return TextureTransform_get_field_count(node, 0); - case TAG_X3D_TimeSensor:return TimeSensor_get_field_count(node, 0); - case TAG_X3D_TimeTrigger:return TimeTrigger_get_field_count(node, 0); - case TAG_X3D_TouchSensor:return TouchSensor_get_field_count(node, 0); - case TAG_X3D_Transform:return Transform_get_field_count(node, 0); - case TAG_X3D_TransmitterPdu:return TransmitterPdu_get_field_count(node, 0); - case TAG_X3D_TriangleFanSet:return TriangleFanSet_get_field_count(node, 0); - case TAG_X3D_TriangleSet:return TriangleSet_get_field_count(node, 0); - case TAG_X3D_TriangleSet2D:return TriangleSet2D_get_field_count(node, 0); - case TAG_X3D_TriangleStripSet:return TriangleStripSet_get_field_count(node, 0); - case TAG_X3D_Viewpoint:return Viewpoint_get_field_count(node, 0); - case TAG_X3D_VisibilitySensor:return VisibilitySensor_get_field_count(node, 0); - case TAG_X3D_WorldInfo:return WorldInfo_get_field_count(node, 0); - default: - return 0; - } -} - -GF_Err gf_sg_x3d_node_get_field(GF_Node *node, GF_FieldInfo *field) -{ - switch (node->sgprivate->tag) { - case TAG_X3D_Anchor: return Anchor_get_field(node, field); - case TAG_X3D_Appearance: return Appearance_get_field(node, field); - case TAG_X3D_Arc2D: return Arc2D_get_field(node, field); - case TAG_X3D_ArcClose2D: return ArcClose2D_get_field(node, field); - case TAG_X3D_AudioClip: return AudioClip_get_field(node, field); - case TAG_X3D_Background: return Background_get_field(node, field); - case TAG_X3D_Billboard: return Billboard_get_field(node, field); - case TAG_X3D_BooleanFilter: return BooleanFilter_get_field(node, field); - case TAG_X3D_BooleanSequencer: return BooleanSequencer_get_field(node, field); - case TAG_X3D_BooleanToggle: return BooleanToggle_get_field(node, field); - case TAG_X3D_BooleanTrigger: return BooleanTrigger_get_field(node, field); - case TAG_X3D_Box: return Box_get_field(node, field); - case TAG_X3D_Circle2D: return Circle2D_get_field(node, field); - case TAG_X3D_Collision: return Collision_get_field(node, field); - case TAG_X3D_Color: return Color_get_field(node, field); - case TAG_X3D_ColorInterpolator: return ColorInterpolator_get_field(node, field); - case TAG_X3D_ColorRGBA: return ColorRGBA_get_field(node, field); - case TAG_X3D_Cone: return Cone_get_field(node, field); - case TAG_X3D_Contour2D: return Contour2D_get_field(node, field); - case TAG_X3D_ContourPolyline2D: return ContourPolyline2D_get_field(node, field); - case TAG_X3D_Coordinate: return Coordinate_get_field(node, field); - case TAG_X3D_CoordinateDouble: return CoordinateDouble_get_field(node, field); - case TAG_X3D_Coordinate2D: return Coordinate2D_get_field(node, field); - case TAG_X3D_CoordinateInterpolator: return CoordinateInterpolator_get_field(node, field); - case TAG_X3D_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_field(node, field); - case TAG_X3D_Cylinder: return Cylinder_get_field(node, field); - case TAG_X3D_CylinderSensor: return CylinderSensor_get_field(node, field); - case TAG_X3D_DirectionalLight: return DirectionalLight_get_field(node, field); - case TAG_X3D_Disk2D: return Disk2D_get_field(node, field); - case TAG_X3D_ElevationGrid: return ElevationGrid_get_field(node, field); - case TAG_X3D_EspduTransform: return EspduTransform_get_field(node, field); - case TAG_X3D_Extrusion: return Extrusion_get_field(node, field); - case TAG_X3D_FillProperties: return FillProperties_get_field(node, field); - case TAG_X3D_Fog: return Fog_get_field(node, field); - case TAG_X3D_FontStyle: return FontStyle_get_field(node, field); - case TAG_X3D_GeoCoordinate: return GeoCoordinate_get_field(node, field); - case TAG_X3D_GeoElevationGrid: return GeoElevationGrid_get_field(node, field); - case TAG_X3D_GeoLocation: return GeoLocation_get_field(node, field); - case TAG_X3D_GeoLOD: return GeoLOD_get_field(node, field); - case TAG_X3D_GeoMetadata: return GeoMetadata_get_field(node, field); - case TAG_X3D_GeoOrigin: return GeoOrigin_get_field(node, field); - case TAG_X3D_GeoPositionInterpolator: return GeoPositionInterpolator_get_field(node, field); - case TAG_X3D_GeoTouchSensor: return GeoTouchSensor_get_field(node, field); - case TAG_X3D_GeoViewpoint: return GeoViewpoint_get_field(node, field); - case TAG_X3D_Group: return Group_get_field(node, field); - case TAG_X3D_HAnimDisplacer: return HAnimDisplacer_get_field(node, field); - case TAG_X3D_HAnimHumanoid: return HAnimHumanoid_get_field(node, field); - case TAG_X3D_HAnimJoint: return HAnimJoint_get_field(node, field); - case TAG_X3D_HAnimSegment: return HAnimSegment_get_field(node, field); - case TAG_X3D_HAnimSite: return HAnimSite_get_field(node, field); - case TAG_X3D_ImageTexture: return ImageTexture_get_field(node, field); - case TAG_X3D_IndexedFaceSet: return IndexedFaceSet_get_field(node, field); - case TAG_X3D_IndexedLineSet: return IndexedLineSet_get_field(node, field); - case TAG_X3D_IndexedTriangleFanSet: return IndexedTriangleFanSet_get_field(node, field); - case TAG_X3D_IndexedTriangleSet: return IndexedTriangleSet_get_field(node, field); - case TAG_X3D_IndexedTriangleStripSet: return IndexedTriangleStripSet_get_field(node, field); - case TAG_X3D_Inline: return Inline_get_field(node, field); - case TAG_X3D_IntegerSequencer: return IntegerSequencer_get_field(node, field); - case TAG_X3D_IntegerTrigger: return IntegerTrigger_get_field(node, field); - case TAG_X3D_KeySensor: return KeySensor_get_field(node, field); - case TAG_X3D_LineProperties: return LineProperties_get_field(node, field); - case TAG_X3D_LineSet: return LineSet_get_field(node, field); - case TAG_X3D_LoadSensor: return LoadSensor_get_field(node, field); - case TAG_X3D_LOD: return LOD_get_field(node, field); - case TAG_X3D_Material: return Material_get_field(node, field); - case TAG_X3D_MetadataDouble: return MetadataDouble_get_field(node, field); - case TAG_X3D_MetadataFloat: return MetadataFloat_get_field(node, field); - case TAG_X3D_MetadataInteger: return MetadataInteger_get_field(node, field); - case TAG_X3D_MetadataSet: return MetadataSet_get_field(node, field); - case TAG_X3D_MetadataString: return MetadataString_get_field(node, field); - case TAG_X3D_MovieTexture: return MovieTexture_get_field(node, field); - case TAG_X3D_MultiTexture: return MultiTexture_get_field(node, field); - case TAG_X3D_MultiTextureCoordinate: return MultiTextureCoordinate_get_field(node, field); - case TAG_X3D_MultiTextureTransform: return MultiTextureTransform_get_field(node, field); - case TAG_X3D_NavigationInfo: return NavigationInfo_get_field(node, field); - case TAG_X3D_Normal: return Normal_get_field(node, field); - case TAG_X3D_NormalInterpolator: return NormalInterpolator_get_field(node, field); - case TAG_X3D_NurbsCurve: return NurbsCurve_get_field(node, field); - case TAG_X3D_NurbsCurve2D: return NurbsCurve2D_get_field(node, field); - case TAG_X3D_NurbsOrientationInterpolator: return NurbsOrientationInterpolator_get_field(node, field); - case TAG_X3D_NurbsPatchSurface: return NurbsPatchSurface_get_field(node, field); - case TAG_X3D_NurbsPositionInterpolator: return NurbsPositionInterpolator_get_field(node, field); - case TAG_X3D_NurbsSet: return NurbsSet_get_field(node, field); - case TAG_X3D_NurbsSurfaceInterpolator: return NurbsSurfaceInterpolator_get_field(node, field); - case TAG_X3D_NurbsSweptSurface: return NurbsSweptSurface_get_field(node, field); - case TAG_X3D_NurbsSwungSurface: return NurbsSwungSurface_get_field(node, field); - case TAG_X3D_NurbsTextureCoordinate: return NurbsTextureCoordinate_get_field(node, field); - case TAG_X3D_NurbsTrimmedSurface: return NurbsTrimmedSurface_get_field(node, field); - case TAG_X3D_OrientationInterpolator: return OrientationInterpolator_get_field(node, field); - case TAG_X3D_PixelTexture: return PixelTexture_get_field(node, field); - case TAG_X3D_PlaneSensor: return PlaneSensor_get_field(node, field); - case TAG_X3D_PointLight: return PointLight_get_field(node, field); - case TAG_X3D_PointSet: return PointSet_get_field(node, field); - case TAG_X3D_Polyline2D: return Polyline2D_get_field(node, field); - case TAG_X3D_Polypoint2D: return Polypoint2D_get_field(node, field); - case TAG_X3D_PositionInterpolator: return PositionInterpolator_get_field(node, field); - case TAG_X3D_PositionInterpolator2D: return PositionInterpolator2D_get_field(node, field); - case TAG_X3D_ProximitySensor: return ProximitySensor_get_field(node, field); - case TAG_X3D_ReceiverPdu: return ReceiverPdu_get_field(node, field); - case TAG_X3D_Rectangle2D: return Rectangle2D_get_field(node, field); - case TAG_X3D_ScalarInterpolator: return ScalarInterpolator_get_field(node, field); - case TAG_X3D_Script: return Script_get_field(node, field); - case TAG_X3D_Shape: return Shape_get_field(node, field); - case TAG_X3D_SignalPdu: return SignalPdu_get_field(node, field); - case TAG_X3D_Sound: return Sound_get_field(node, field); - case TAG_X3D_Sphere: return Sphere_get_field(node, field); - case TAG_X3D_SphereSensor: return SphereSensor_get_field(node, field); - case TAG_X3D_SpotLight: return SpotLight_get_field(node, field); - case TAG_X3D_StaticGroup: return StaticGroup_get_field(node, field); - case TAG_X3D_StringSensor: return StringSensor_get_field(node, field); - case TAG_X3D_Switch: return Switch_get_field(node, field); - case TAG_X3D_Text: return Text_get_field(node, field); - case TAG_X3D_TextureBackground: return TextureBackground_get_field(node, field); - case TAG_X3D_TextureCoordinate: return TextureCoordinate_get_field(node, field); - case TAG_X3D_TextureCoordinateGenerator: return TextureCoordinateGenerator_get_field(node, field); - case TAG_X3D_TextureTransform: return TextureTransform_get_field(node, field); - case TAG_X3D_TimeSensor: return TimeSensor_get_field(node, field); - case TAG_X3D_TimeTrigger: return TimeTrigger_get_field(node, field); - case TAG_X3D_TouchSensor: return TouchSensor_get_field(node, field); - case TAG_X3D_Transform: return Transform_get_field(node, field); - case TAG_X3D_TransmitterPdu: return TransmitterPdu_get_field(node, field); - case TAG_X3D_TriangleFanSet: return TriangleFanSet_get_field(node, field); - case TAG_X3D_TriangleSet: return TriangleSet_get_field(node, field); - case TAG_X3D_TriangleSet2D: return TriangleSet2D_get_field(node, field); - case TAG_X3D_TriangleStripSet: return TriangleStripSet_get_field(node, field); - case TAG_X3D_Viewpoint: return Viewpoint_get_field(node, field); - case TAG_X3D_VisibilitySensor: return VisibilitySensor_get_field(node, field); - case TAG_X3D_WorldInfo: return WorldInfo_get_field(node, field); + return WorldInfo_get_field(node, field); default: return GF_BAD_PARAM; } @@ -15487,134 +15871,262 @@ u32 gf_node_x3d_type_by_class_name(const char *node_name) s32 gf_sg_x3d_node_get_field_index_by_name(GF_Node *node, char *name) { switch (node->sgprivate->tag) { - case TAG_X3D_Anchor: return Anchor_get_field_index_by_name(name); - case TAG_X3D_Appearance: return Appearance_get_field_index_by_name(name); - case TAG_X3D_Arc2D: return Arc2D_get_field_index_by_name(name); - case TAG_X3D_ArcClose2D: return ArcClose2D_get_field_index_by_name(name); - case TAG_X3D_AudioClip: return AudioClip_get_field_index_by_name(name); - case TAG_X3D_Background: return Background_get_field_index_by_name(name); - case TAG_X3D_Billboard: return Billboard_get_field_index_by_name(name); - case TAG_X3D_BooleanFilter: return BooleanFilter_get_field_index_by_name(name); - case TAG_X3D_BooleanSequencer: return BooleanSequencer_get_field_index_by_name(name); - case TAG_X3D_BooleanToggle: return BooleanToggle_get_field_index_by_name(name); - case TAG_X3D_BooleanTrigger: return BooleanTrigger_get_field_index_by_name(name); - case TAG_X3D_Box: return Box_get_field_index_by_name(name); - case TAG_X3D_Circle2D: return Circle2D_get_field_index_by_name(name); - case TAG_X3D_Collision: return Collision_get_field_index_by_name(name); - case TAG_X3D_Color: return Color_get_field_index_by_name(name); - case TAG_X3D_ColorInterpolator: return ColorInterpolator_get_field_index_by_name(name); - case TAG_X3D_ColorRGBA: return ColorRGBA_get_field_index_by_name(name); - case TAG_X3D_Cone: return Cone_get_field_index_by_name(name); - case TAG_X3D_Contour2D: return Contour2D_get_field_index_by_name(name); - case TAG_X3D_ContourPolyline2D: return ContourPolyline2D_get_field_index_by_name(name); - case TAG_X3D_Coordinate: return Coordinate_get_field_index_by_name(name); - case TAG_X3D_CoordinateDouble: return CoordinateDouble_get_field_index_by_name(name); - case TAG_X3D_Coordinate2D: return Coordinate2D_get_field_index_by_name(name); - case TAG_X3D_CoordinateInterpolator: return CoordinateInterpolator_get_field_index_by_name(name); - case TAG_X3D_CoordinateInterpolator2D: return CoordinateInterpolator2D_get_field_index_by_name(name); - case TAG_X3D_Cylinder: return Cylinder_get_field_index_by_name(name); - case TAG_X3D_CylinderSensor: return CylinderSensor_get_field_index_by_name(name); - case TAG_X3D_DirectionalLight: return DirectionalLight_get_field_index_by_name(name); - case TAG_X3D_Disk2D: return Disk2D_get_field_index_by_name(name); - case TAG_X3D_ElevationGrid: return ElevationGrid_get_field_index_by_name(name); - case TAG_X3D_EspduTransform: return EspduTransform_get_field_index_by_name(name); - case TAG_X3D_Extrusion: return Extrusion_get_field_index_by_name(name); - case TAG_X3D_FillProperties: return FillProperties_get_field_index_by_name(name); - case TAG_X3D_Fog: return Fog_get_field_index_by_name(name); - case TAG_X3D_FontStyle: return FontStyle_get_field_index_by_name(name); - case TAG_X3D_GeoCoordinate: return GeoCoordinate_get_field_index_by_name(name); - case TAG_X3D_GeoElevationGrid: return GeoElevationGrid_get_field_index_by_name(name); - case TAG_X3D_GeoLocation: return GeoLocation_get_field_index_by_name(name); - case TAG_X3D_GeoLOD: return GeoLOD_get_field_index_by_name(name); - case TAG_X3D_GeoMetadata: return GeoMetadata_get_field_index_by_name(name); - case TAG_X3D_GeoOrigin: return GeoOrigin_get_field_index_by_name(name); - case TAG_X3D_GeoPositionInterpolator: return GeoPositionInterpolator_get_field_index_by_name(name); - case TAG_X3D_GeoTouchSensor: return GeoTouchSensor_get_field_index_by_name(name); - case TAG_X3D_GeoViewpoint: return GeoViewpoint_get_field_index_by_name(name); - case TAG_X3D_Group: return Group_get_field_index_by_name(name); - case TAG_X3D_HAnimDisplacer: return HAnimDisplacer_get_field_index_by_name(name); - case TAG_X3D_HAnimHumanoid: return HAnimHumanoid_get_field_index_by_name(name); - case TAG_X3D_HAnimJoint: return HAnimJoint_get_field_index_by_name(name); - case TAG_X3D_HAnimSegment: return HAnimSegment_get_field_index_by_name(name); - case TAG_X3D_HAnimSite: return HAnimSite_get_field_index_by_name(name); - case TAG_X3D_ImageTexture: return ImageTexture_get_field_index_by_name(name); - case TAG_X3D_IndexedFaceSet: return IndexedFaceSet_get_field_index_by_name(name); - case TAG_X3D_IndexedLineSet: return IndexedLineSet_get_field_index_by_name(name); - case TAG_X3D_IndexedTriangleFanSet: return IndexedTriangleFanSet_get_field_index_by_name(name); - case TAG_X3D_IndexedTriangleSet: return IndexedTriangleSet_get_field_index_by_name(name); - case TAG_X3D_IndexedTriangleStripSet: return IndexedTriangleStripSet_get_field_index_by_name(name); - case TAG_X3D_Inline: return Inline_get_field_index_by_name(name); - case TAG_X3D_IntegerSequencer: return IntegerSequencer_get_field_index_by_name(name); - case TAG_X3D_IntegerTrigger: return IntegerTrigger_get_field_index_by_name(name); - case TAG_X3D_KeySensor: return KeySensor_get_field_index_by_name(name); - case TAG_X3D_LineProperties: return LineProperties_get_field_index_by_name(name); - case TAG_X3D_LineSet: return LineSet_get_field_index_by_name(name); - case TAG_X3D_LoadSensor: return LoadSensor_get_field_index_by_name(name); - case TAG_X3D_LOD: return LOD_get_field_index_by_name(name); - case TAG_X3D_Material: return Material_get_field_index_by_name(name); - case TAG_X3D_MetadataDouble: return MetadataDouble_get_field_index_by_name(name); - case TAG_X3D_MetadataFloat: return MetadataFloat_get_field_index_by_name(name); - case TAG_X3D_MetadataInteger: return MetadataInteger_get_field_index_by_name(name); - case TAG_X3D_MetadataSet: return MetadataSet_get_field_index_by_name(name); - case TAG_X3D_MetadataString: return MetadataString_get_field_index_by_name(name); - case TAG_X3D_MovieTexture: return MovieTexture_get_field_index_by_name(name); - case TAG_X3D_MultiTexture: return MultiTexture_get_field_index_by_name(name); - case TAG_X3D_MultiTextureCoordinate: return MultiTextureCoordinate_get_field_index_by_name(name); - case TAG_X3D_MultiTextureTransform: return MultiTextureTransform_get_field_index_by_name(name); - case TAG_X3D_NavigationInfo: return NavigationInfo_get_field_index_by_name(name); - case TAG_X3D_Normal: return Normal_get_field_index_by_name(name); - case TAG_X3D_NormalInterpolator: return NormalInterpolator_get_field_index_by_name(name); - case TAG_X3D_NurbsCurve: return NurbsCurve_get_field_index_by_name(name); - case TAG_X3D_NurbsCurve2D: return NurbsCurve2D_get_field_index_by_name(name); - case TAG_X3D_NurbsOrientationInterpolator: return NurbsOrientationInterpolator_get_field_index_by_name(name); - case TAG_X3D_NurbsPatchSurface: return NurbsPatchSurface_get_field_index_by_name(name); - case TAG_X3D_NurbsPositionInterpolator: return NurbsPositionInterpolator_get_field_index_by_name(name); - case TAG_X3D_NurbsSet: return NurbsSet_get_field_index_by_name(name); - case TAG_X3D_NurbsSurfaceInterpolator: return NurbsSurfaceInterpolator_get_field_index_by_name(name); - case TAG_X3D_NurbsSweptSurface: return NurbsSweptSurface_get_field_index_by_name(name); - case TAG_X3D_NurbsSwungSurface: return NurbsSwungSurface_get_field_index_by_name(name); - case TAG_X3D_NurbsTextureCoordinate: return NurbsTextureCoordinate_get_field_index_by_name(name); - case TAG_X3D_NurbsTrimmedSurface: return NurbsTrimmedSurface_get_field_index_by_name(name); - case TAG_X3D_OrientationInterpolator: return OrientationInterpolator_get_field_index_by_name(name); - case TAG_X3D_PixelTexture: return PixelTexture_get_field_index_by_name(name); - case TAG_X3D_PlaneSensor: return PlaneSensor_get_field_index_by_name(name); - case TAG_X3D_PointLight: return PointLight_get_field_index_by_name(name); - case TAG_X3D_PointSet: return PointSet_get_field_index_by_name(name); - case TAG_X3D_Polyline2D: return Polyline2D_get_field_index_by_name(name); - case TAG_X3D_Polypoint2D: return Polypoint2D_get_field_index_by_name(name); - case TAG_X3D_PositionInterpolator: return PositionInterpolator_get_field_index_by_name(name); - case TAG_X3D_PositionInterpolator2D: return PositionInterpolator2D_get_field_index_by_name(name); - case TAG_X3D_ProximitySensor: return ProximitySensor_get_field_index_by_name(name); - case TAG_X3D_ReceiverPdu: return ReceiverPdu_get_field_index_by_name(name); - case TAG_X3D_Rectangle2D: return Rectangle2D_get_field_index_by_name(name); - case TAG_X3D_ScalarInterpolator: return ScalarInterpolator_get_field_index_by_name(name); - case TAG_X3D_Script: return Script_get_field_index_by_name(name); - case TAG_X3D_Shape: return Shape_get_field_index_by_name(name); - case TAG_X3D_SignalPdu: return SignalPdu_get_field_index_by_name(name); - case TAG_X3D_Sound: return Sound_get_field_index_by_name(name); - case TAG_X3D_Sphere: return Sphere_get_field_index_by_name(name); - case TAG_X3D_SphereSensor: return SphereSensor_get_field_index_by_name(name); - case TAG_X3D_SpotLight: return SpotLight_get_field_index_by_name(name); - case TAG_X3D_StaticGroup: return StaticGroup_get_field_index_by_name(name); - case TAG_X3D_StringSensor: return StringSensor_get_field_index_by_name(name); - case TAG_X3D_Switch: return Switch_get_field_index_by_name(name); - case TAG_X3D_Text: return Text_get_field_index_by_name(name); - case TAG_X3D_TextureBackground: return TextureBackground_get_field_index_by_name(name); - case TAG_X3D_TextureCoordinate: return TextureCoordinate_get_field_index_by_name(name); - case TAG_X3D_TextureCoordinateGenerator: return TextureCoordinateGenerator_get_field_index_by_name(name); - case TAG_X3D_TextureTransform: return TextureTransform_get_field_index_by_name(name); - case TAG_X3D_TimeSensor: return TimeSensor_get_field_index_by_name(name); - case TAG_X3D_TimeTrigger: return TimeTrigger_get_field_index_by_name(name); - case TAG_X3D_TouchSensor: return TouchSensor_get_field_index_by_name(name); - case TAG_X3D_Transform: return Transform_get_field_index_by_name(name); - case TAG_X3D_TransmitterPdu: return TransmitterPdu_get_field_index_by_name(name); - case TAG_X3D_TriangleFanSet: return TriangleFanSet_get_field_index_by_name(name); - case TAG_X3D_TriangleSet: return TriangleSet_get_field_index_by_name(name); - case TAG_X3D_TriangleSet2D: return TriangleSet2D_get_field_index_by_name(name); - case TAG_X3D_TriangleStripSet: return TriangleStripSet_get_field_index_by_name(name); - case TAG_X3D_Viewpoint: return Viewpoint_get_field_index_by_name(name); - case TAG_X3D_VisibilitySensor: return VisibilitySensor_get_field_index_by_name(name); - case TAG_X3D_WorldInfo: return WorldInfo_get_field_index_by_name(name); + case TAG_X3D_Anchor: + return Anchor_get_field_index_by_name(name); + case TAG_X3D_Appearance: + return Appearance_get_field_index_by_name(name); + case TAG_X3D_Arc2D: + return Arc2D_get_field_index_by_name(name); + case TAG_X3D_ArcClose2D: + return ArcClose2D_get_field_index_by_name(name); + case TAG_X3D_AudioClip: + return AudioClip_get_field_index_by_name(name); + case TAG_X3D_Background: + return Background_get_field_index_by_name(name); + case TAG_X3D_Billboard: + return Billboard_get_field_index_by_name(name); + case TAG_X3D_BooleanFilter: + return BooleanFilter_get_field_index_by_name(name); + case TAG_X3D_BooleanSequencer: + return BooleanSequencer_get_field_index_by_name(name); + case TAG_X3D_BooleanToggle: + return BooleanToggle_get_field_index_by_name(name); + case TAG_X3D_BooleanTrigger: + return BooleanTrigger_get_field_index_by_name(name); + case TAG_X3D_Box: + return Box_get_field_index_by_name(name); + case TAG_X3D_Circle2D: + return Circle2D_get_field_index_by_name(name); + case TAG_X3D_Collision: + return Collision_get_field_index_by_name(name); + case TAG_X3D_Color: + return Color_get_field_index_by_name(name); + case TAG_X3D_ColorInterpolator: + return ColorInterpolator_get_field_index_by_name(name); + case TAG_X3D_ColorRGBA: + return ColorRGBA_get_field_index_by_name(name); + case TAG_X3D_Cone: + return Cone_get_field_index_by_name(name); + case TAG_X3D_Contour2D: + return Contour2D_get_field_index_by_name(name); + case TAG_X3D_ContourPolyline2D: + return ContourPolyline2D_get_field_index_by_name(name); + case TAG_X3D_Coordinate: + return Coordinate_get_field_index_by_name(name); + case TAG_X3D_CoordinateDouble: + return CoordinateDouble_get_field_index_by_name(name); + case TAG_X3D_Coordinate2D: + return Coordinate2D_get_field_index_by_name(name); + case TAG_X3D_CoordinateInterpolator: + return CoordinateInterpolator_get_field_index_by_name(name); + case TAG_X3D_CoordinateInterpolator2D: + return CoordinateInterpolator2D_get_field_index_by_name(name); + case TAG_X3D_Cylinder: + return Cylinder_get_field_index_by_name(name); + case TAG_X3D_CylinderSensor: + return CylinderSensor_get_field_index_by_name(name); + case TAG_X3D_DirectionalLight: + return DirectionalLight_get_field_index_by_name(name); + case TAG_X3D_Disk2D: + return Disk2D_get_field_index_by_name(name); + case TAG_X3D_ElevationGrid: + return ElevationGrid_get_field_index_by_name(name); + case TAG_X3D_EspduTransform: + return EspduTransform_get_field_index_by_name(name); + case TAG_X3D_Extrusion: + return Extrusion_get_field_index_by_name(name); + case TAG_X3D_FillProperties: + return FillProperties_get_field_index_by_name(name); + case TAG_X3D_Fog: + return Fog_get_field_index_by_name(name); + case TAG_X3D_FontStyle: + return FontStyle_get_field_index_by_name(name); + case TAG_X3D_GeoCoordinate: + return GeoCoordinate_get_field_index_by_name(name); + case TAG_X3D_GeoElevationGrid: + return GeoElevationGrid_get_field_index_by_name(name); + case TAG_X3D_GeoLocation: + return GeoLocation_get_field_index_by_name(name); + case TAG_X3D_GeoLOD: + return GeoLOD_get_field_index_by_name(name); + case TAG_X3D_GeoMetadata: + return GeoMetadata_get_field_index_by_name(name); + case TAG_X3D_GeoOrigin: + return GeoOrigin_get_field_index_by_name(name); + case TAG_X3D_GeoPositionInterpolator: + return GeoPositionInterpolator_get_field_index_by_name(name); + case TAG_X3D_GeoTouchSensor: + return GeoTouchSensor_get_field_index_by_name(name); + case TAG_X3D_GeoViewpoint: + return GeoViewpoint_get_field_index_by_name(name); + case TAG_X3D_Group: + return Group_get_field_index_by_name(name); + case TAG_X3D_HAnimDisplacer: + return HAnimDisplacer_get_field_index_by_name(name); + case TAG_X3D_HAnimHumanoid: + return HAnimHumanoid_get_field_index_by_name(name); + case TAG_X3D_HAnimJoint: + return HAnimJoint_get_field_index_by_name(name); + case TAG_X3D_HAnimSegment: + return HAnimSegment_get_field_index_by_name(name); + case TAG_X3D_HAnimSite: + return HAnimSite_get_field_index_by_name(name); + case TAG_X3D_ImageTexture: + return ImageTexture_get_field_index_by_name(name); + case TAG_X3D_IndexedFaceSet: + return IndexedFaceSet_get_field_index_by_name(name); + case TAG_X3D_IndexedLineSet: + return IndexedLineSet_get_field_index_by_name(name); + case TAG_X3D_IndexedTriangleFanSet: + return IndexedTriangleFanSet_get_field_index_by_name(name); + case TAG_X3D_IndexedTriangleSet: + return IndexedTriangleSet_get_field_index_by_name(name); + case TAG_X3D_IndexedTriangleStripSet: + return IndexedTriangleStripSet_get_field_index_by_name(name); + case TAG_X3D_Inline: + return Inline_get_field_index_by_name(name); + case TAG_X3D_IntegerSequencer: + return IntegerSequencer_get_field_index_by_name(name); + case TAG_X3D_IntegerTrigger: + return IntegerTrigger_get_field_index_by_name(name); + case TAG_X3D_KeySensor: + return KeySensor_get_field_index_by_name(name); + case TAG_X3D_LineProperties: + return LineProperties_get_field_index_by_name(name); + case TAG_X3D_LineSet: + return LineSet_get_field_index_by_name(name); + case TAG_X3D_LoadSensor: + return LoadSensor_get_field_index_by_name(name); + case TAG_X3D_LOD: + return LOD_get_field_index_by_name(name); + case TAG_X3D_Material: + return Material_get_field_index_by_name(name); + case TAG_X3D_MetadataDouble: + return MetadataDouble_get_field_index_by_name(name); + case TAG_X3D_MetadataFloat: + return MetadataFloat_get_field_index_by_name(name); + case TAG_X3D_MetadataInteger: + return MetadataInteger_get_field_index_by_name(name); + case TAG_X3D_MetadataSet: + return MetadataSet_get_field_index_by_name(name); + case TAG_X3D_MetadataString: + return MetadataString_get_field_index_by_name(name); + case TAG_X3D_MovieTexture: + return MovieTexture_get_field_index_by_name(name); + case TAG_X3D_MultiTexture: + return MultiTexture_get_field_index_by_name(name); + case TAG_X3D_MultiTextureCoordinate: + return MultiTextureCoordinate_get_field_index_by_name(name); + case TAG_X3D_MultiTextureTransform: + return MultiTextureTransform_get_field_index_by_name(name); + case TAG_X3D_NavigationInfo: + return NavigationInfo_get_field_index_by_name(name); + case TAG_X3D_Normal: + return Normal_get_field_index_by_name(name); + case TAG_X3D_NormalInterpolator: + return NormalInterpolator_get_field_index_by_name(name); + case TAG_X3D_NurbsCurve: + return NurbsCurve_get_field_index_by_name(name); + case TAG_X3D_NurbsCurve2D: + return NurbsCurve2D_get_field_index_by_name(name); + case TAG_X3D_NurbsOrientationInterpolator: + return NurbsOrientationInterpolator_get_field_index_by_name(name); + case TAG_X3D_NurbsPatchSurface: + return NurbsPatchSurface_get_field_index_by_name(name); + case TAG_X3D_NurbsPositionInterpolator: + return NurbsPositionInterpolator_get_field_index_by_name(name); + case TAG_X3D_NurbsSet: + return NurbsSet_get_field_index_by_name(name); + case TAG_X3D_NurbsSurfaceInterpolator: + return NurbsSurfaceInterpolator_get_field_index_by_name(name); + case TAG_X3D_NurbsSweptSurface: + return NurbsSweptSurface_get_field_index_by_name(name); + case TAG_X3D_NurbsSwungSurface: + return NurbsSwungSurface_get_field_index_by_name(name); + case TAG_X3D_NurbsTextureCoordinate: + return NurbsTextureCoordinate_get_field_index_by_name(name); + case TAG_X3D_NurbsTrimmedSurface: + return NurbsTrimmedSurface_get_field_index_by_name(name); + case TAG_X3D_OrientationInterpolator: + return OrientationInterpolator_get_field_index_by_name(name); + case TAG_X3D_PixelTexture: + return PixelTexture_get_field_index_by_name(name); + case TAG_X3D_PlaneSensor: + return PlaneSensor_get_field_index_by_name(name); + case TAG_X3D_PointLight: + return PointLight_get_field_index_by_name(name); + case TAG_X3D_PointSet: + return PointSet_get_field_index_by_name(name); + case TAG_X3D_Polyline2D: + return Polyline2D_get_field_index_by_name(name); + case TAG_X3D_Polypoint2D: + return Polypoint2D_get_field_index_by_name(name); + case TAG_X3D_PositionInterpolator: + return PositionInterpolator_get_field_index_by_name(name); + case TAG_X3D_PositionInterpolator2D: + return PositionInterpolator2D_get_field_index_by_name(name); + case TAG_X3D_ProximitySensor: + return ProximitySensor_get_field_index_by_name(name); + case TAG_X3D_ReceiverPdu: + return ReceiverPdu_get_field_index_by_name(name); + case TAG_X3D_Rectangle2D: + return Rectangle2D_get_field_index_by_name(name); + case TAG_X3D_ScalarInterpolator: + return ScalarInterpolator_get_field_index_by_name(name); + case TAG_X3D_Script: + return Script_get_field_index_by_name(name); + case TAG_X3D_Shape: + return Shape_get_field_index_by_name(name); + case TAG_X3D_SignalPdu: + return SignalPdu_get_field_index_by_name(name); + case TAG_X3D_Sound: + return Sound_get_field_index_by_name(name); + case TAG_X3D_Sphere: + return Sphere_get_field_index_by_name(name); + case TAG_X3D_SphereSensor: + return SphereSensor_get_field_index_by_name(name); + case TAG_X3D_SpotLight: + return SpotLight_get_field_index_by_name(name); + case TAG_X3D_StaticGroup: + return StaticGroup_get_field_index_by_name(name); + case TAG_X3D_StringSensor: + return StringSensor_get_field_index_by_name(name); + case TAG_X3D_Switch: + return Switch_get_field_index_by_name(name); + case TAG_X3D_Text: + return Text_get_field_index_by_name(name); + case TAG_X3D_TextureBackground: + return TextureBackground_get_field_index_by_name(name); + case TAG_X3D_TextureCoordinate: + return TextureCoordinate_get_field_index_by_name(name); + case TAG_X3D_TextureCoordinateGenerator: + return TextureCoordinateGenerator_get_field_index_by_name(name); + case TAG_X3D_TextureTransform: + return TextureTransform_get_field_index_by_name(name); + case TAG_X3D_TimeSensor: + return TimeSensor_get_field_index_by_name(name); + case TAG_X3D_TimeTrigger: + return TimeTrigger_get_field_index_by_name(name); + case TAG_X3D_TouchSensor: + return TouchSensor_get_field_index_by_name(name); + case TAG_X3D_Transform: + return Transform_get_field_index_by_name(name); + case TAG_X3D_TransmitterPdu: + return TransmitterPdu_get_field_index_by_name(name); + case TAG_X3D_TriangleFanSet: + return TriangleFanSet_get_field_index_by_name(name); + case TAG_X3D_TriangleSet: + return TriangleSet_get_field_index_by_name(name); + case TAG_X3D_TriangleSet2D: + return TriangleSet2D_get_field_index_by_name(name); + case TAG_X3D_TriangleStripSet: + return TriangleStripSet_get_field_index_by_name(name); + case TAG_X3D_Viewpoint: + return Viewpoint_get_field_index_by_name(name); + case TAG_X3D_VisibilitySensor: + return VisibilitySensor_get_field_index_by_name(name); + case TAG_X3D_WorldInfo: + return WorldInfo_get_field_index_by_name(name); default: return -1; } @@ -15626,152 +16138,152 @@ s32 gf_sg_x3d_node_get_field_index_by_name(GF_Node *node, char *name) #define SFWorldNode_X3D_Count 127 static const u32 SFWorldNode_X3D_TypeToTag[127] = { - TAG_X3D_Anchor, TAG_X3D_Appearance, TAG_X3D_Arc2D, TAG_X3D_ArcClose2D, TAG_X3D_AudioClip, TAG_X3D_Background, TAG_X3D_Billboard, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_Box, TAG_X3D_Circle2D, TAG_X3D_Collision, TAG_X3D_Color, TAG_X3D_ColorInterpolator, TAG_X3D_ColorRGBA, TAG_X3D_Cone, TAG_X3D_Contour2D, TAG_X3D_ContourPolyline2D, TAG_X3D_Coordinate, TAG_X3D_CoordinateDouble, TAG_X3D_Coordinate2D, TAG_X3D_CoordinateInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_Cylinder, TAG_X3D_CylinderSensor, TAG_X3D_DirectionalLight, TAG_X3D_Disk2D, TAG_X3D_ElevationGrid, TAG_X3D_EspduTransform, TAG_X3D_Extrusion, TAG_X3D_FillProperties, TAG_X3D_Fog, TAG_X3D_FontStyle, TAG_X3D_GeoCoordinate, TAG_X3D_GeoElevationGrid, TAG_X3D_GeoLocation, TAG_X3D_GeoLOD, TAG_X3D_GeoMetadata, TAG_X3D_GeoPositionInterpolator, TAG_X3D_GeoTouchSensor, TAG_X3D_GeoViewpoint, TAG_X3D_Group, TAG_X3D_HAnimDisplacer, TAG_X3D_HAnimHumanoid, TAG_X3D_HAnimJoint, TAG_X3D_HAnimSegment, TAG_X3D_HAnimSite, TAG_X3D_ImageTexture, TAG_X3D_IndexedFaceSet, TAG_X3D_IndexedLineSet, TAG_X3D_IndexedTriangleFanSet, TAG_X3D_IndexedTriangleSet, TAG_X3D_IndexedTriangleStripSet, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LineProperties, TAG_X3D_LineSet, TAG_X3D_LoadSensor, TAG_X3D_LOD, TAG_X3D_Material, TAG_X3D_MetadataDouble, TAG_X3D_MetadataFloat, TAG_X3D_MetadataInteger, TAG_X3D_MetadataSet, TAG_X3D_MetadataString, TAG_X3D_MovieTexture, TAG_X3D_MultiTexture, TAG_X3D_MultiTextureCoordinate, TAG_X3D_MultiTextureTransform, TAG_X3D_NavigationInfo, TAG_X3D_Normal, TAG_X3D_NormalInterpolator, TAG_X3D_NurbsCurve, TAG_X3D_NurbsCurve2D, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTextureCoordinate, TAG_X3D_NurbsTrimmedSurface, TAG_X3D_OrientationInterpolator, TAG_X3D_PixelTexture, TAG_X3D_PlaneSensor, TAG_X3D_PointLight, TAG_X3D_PointSet, TAG_X3D_Polyline2D, TAG_X3D_Polypoint2D, TAG_X3D_PositionInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ProximitySensor, TAG_X3D_ReceiverPdu, TAG_X3D_Rectangle2D, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_Sound, TAG_X3D_Sphere, TAG_X3D_SphereSensor, TAG_X3D_SpotLight, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_Text, TAG_X3D_TextureBackground, TAG_X3D_TextureCoordinate, TAG_X3D_TextureCoordinateGenerator, TAG_X3D_TextureTransform, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_Transform, TAG_X3D_TransmitterPdu, TAG_X3D_TriangleFanSet, TAG_X3D_TriangleSet, TAG_X3D_TriangleSet2D, TAG_X3D_TriangleStripSet, TAG_X3D_Viewpoint, TAG_X3D_VisibilitySensor, TAG_X3D_WorldInfo + TAG_X3D_Anchor, TAG_X3D_Appearance, TAG_X3D_Arc2D, TAG_X3D_ArcClose2D, TAG_X3D_AudioClip, TAG_X3D_Background, TAG_X3D_Billboard, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_Box, TAG_X3D_Circle2D, TAG_X3D_Collision, TAG_X3D_Color, TAG_X3D_ColorInterpolator, TAG_X3D_ColorRGBA, TAG_X3D_Cone, TAG_X3D_Contour2D, TAG_X3D_ContourPolyline2D, TAG_X3D_Coordinate, TAG_X3D_CoordinateDouble, TAG_X3D_Coordinate2D, TAG_X3D_CoordinateInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_Cylinder, TAG_X3D_CylinderSensor, TAG_X3D_DirectionalLight, TAG_X3D_Disk2D, TAG_X3D_ElevationGrid, TAG_X3D_EspduTransform, TAG_X3D_Extrusion, TAG_X3D_FillProperties, TAG_X3D_Fog, TAG_X3D_FontStyle, TAG_X3D_GeoCoordinate, TAG_X3D_GeoElevationGrid, TAG_X3D_GeoLocation, TAG_X3D_GeoLOD, TAG_X3D_GeoMetadata, TAG_X3D_GeoPositionInterpolator, TAG_X3D_GeoTouchSensor, TAG_X3D_GeoViewpoint, TAG_X3D_Group, TAG_X3D_HAnimDisplacer, TAG_X3D_HAnimHumanoid, TAG_X3D_HAnimJoint, TAG_X3D_HAnimSegment, TAG_X3D_HAnimSite, TAG_X3D_ImageTexture, TAG_X3D_IndexedFaceSet, TAG_X3D_IndexedLineSet, TAG_X3D_IndexedTriangleFanSet, TAG_X3D_IndexedTriangleSet, TAG_X3D_IndexedTriangleStripSet, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LineProperties, TAG_X3D_LineSet, TAG_X3D_LoadSensor, TAG_X3D_LOD, TAG_X3D_Material, TAG_X3D_MetadataDouble, TAG_X3D_MetadataFloat, TAG_X3D_MetadataInteger, TAG_X3D_MetadataSet, TAG_X3D_MetadataString, TAG_X3D_MovieTexture, TAG_X3D_MultiTexture, TAG_X3D_MultiTextureCoordinate, TAG_X3D_MultiTextureTransform, TAG_X3D_NavigationInfo, TAG_X3D_Normal, TAG_X3D_NormalInterpolator, TAG_X3D_NurbsCurve, TAG_X3D_NurbsCurve2D, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTextureCoordinate, TAG_X3D_NurbsTrimmedSurface, TAG_X3D_OrientationInterpolator, TAG_X3D_PixelTexture, TAG_X3D_PlaneSensor, TAG_X3D_PointLight, TAG_X3D_PointSet, TAG_X3D_Polyline2D, TAG_X3D_Polypoint2D, TAG_X3D_PositionInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ProximitySensor, TAG_X3D_ReceiverPdu, TAG_X3D_Rectangle2D, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_Sound, TAG_X3D_Sphere, TAG_X3D_SphereSensor, TAG_X3D_SpotLight, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_Text, TAG_X3D_TextureBackground, TAG_X3D_TextureCoordinate, TAG_X3D_TextureCoordinateGenerator, TAG_X3D_TextureTransform, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_Transform, TAG_X3D_TransmitterPdu, TAG_X3D_TriangleFanSet, TAG_X3D_TriangleSet, TAG_X3D_TriangleSet2D, TAG_X3D_TriangleStripSet, TAG_X3D_Viewpoint, TAG_X3D_VisibilitySensor, TAG_X3D_WorldInfo }; #define SF3DNode_X3D_Count 60 static const u32 SF3DNode_X3D_TypeToTag[60] = { - TAG_X3D_Anchor, TAG_X3D_Background, TAG_X3D_Billboard, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_Collision, TAG_X3D_ColorInterpolator, TAG_X3D_CoordinateInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_CylinderSensor, TAG_X3D_DirectionalLight, TAG_X3D_EspduTransform, TAG_X3D_Fog, TAG_X3D_GeoLocation, TAG_X3D_GeoLOD, TAG_X3D_GeoMetadata, TAG_X3D_GeoPositionInterpolator, TAG_X3D_GeoTouchSensor, TAG_X3D_GeoViewpoint, TAG_X3D_Group, TAG_X3D_HAnimHumanoid, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LOD, TAG_X3D_NavigationInfo, TAG_X3D_NormalInterpolator, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_OrientationInterpolator, TAG_X3D_PlaneSensor, TAG_X3D_PointLight, TAG_X3D_PositionInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ProximitySensor, TAG_X3D_ReceiverPdu, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_Sound, TAG_X3D_SphereSensor, TAG_X3D_SpotLight, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_TextureBackground, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_Transform, TAG_X3D_TransmitterPdu, TAG_X3D_Viewpoint, TAG_X3D_VisibilitySensor, TAG_X3D_WorldInfo + TAG_X3D_Anchor, TAG_X3D_Background, TAG_X3D_Billboard, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_Collision, TAG_X3D_ColorInterpolator, TAG_X3D_CoordinateInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_CylinderSensor, TAG_X3D_DirectionalLight, TAG_X3D_EspduTransform, TAG_X3D_Fog, TAG_X3D_GeoLocation, TAG_X3D_GeoLOD, TAG_X3D_GeoMetadata, TAG_X3D_GeoPositionInterpolator, TAG_X3D_GeoTouchSensor, TAG_X3D_GeoViewpoint, TAG_X3D_Group, TAG_X3D_HAnimHumanoid, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LOD, TAG_X3D_NavigationInfo, TAG_X3D_NormalInterpolator, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_OrientationInterpolator, TAG_X3D_PlaneSensor, TAG_X3D_PointLight, TAG_X3D_PositionInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ProximitySensor, TAG_X3D_ReceiverPdu, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_Sound, TAG_X3D_SphereSensor, TAG_X3D_SpotLight, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_TextureBackground, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_Transform, TAG_X3D_TransmitterPdu, TAG_X3D_Viewpoint, TAG_X3D_VisibilitySensor, TAG_X3D_WorldInfo }; #define SF2DNode_X3D_Count 34 static const u32 SF2DNode_X3D_TypeToTag[34] = { - TAG_X3D_Anchor, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_ColorInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_EspduTransform, TAG_X3D_GeoMetadata, TAG_X3D_GeoTouchSensor, TAG_X3D_Group, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LOD, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ReceiverPdu, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_TransmitterPdu, TAG_X3D_WorldInfo + TAG_X3D_Anchor, TAG_X3D_BooleanFilter, TAG_X3D_BooleanSequencer, TAG_X3D_BooleanToggle, TAG_X3D_BooleanTrigger, TAG_X3D_ColorInterpolator, TAG_X3D_CoordinateInterpolator2D, TAG_X3D_EspduTransform, TAG_X3D_GeoMetadata, TAG_X3D_GeoTouchSensor, TAG_X3D_Group, TAG_X3D_Inline, TAG_X3D_IntegerSequencer, TAG_X3D_IntegerTrigger, TAG_X3D_KeySensor, TAG_X3D_LOD, TAG_X3D_NurbsOrientationInterpolator, TAG_X3D_NurbsPositionInterpolator, TAG_X3D_NurbsSet, TAG_X3D_NurbsSurfaceInterpolator, TAG_X3D_PositionInterpolator2D, TAG_X3D_ReceiverPdu, TAG_X3D_ScalarInterpolator, TAG_X3D_Script, TAG_X3D_Shape, TAG_X3D_SignalPdu, TAG_X3D_StaticGroup, TAG_X3D_StringSensor, TAG_X3D_Switch, TAG_X3D_TimeSensor, TAG_X3D_TimeTrigger, TAG_X3D_TouchSensor, TAG_X3D_TransmitterPdu, TAG_X3D_WorldInfo }; #define SFAppearanceNode_X3D_Count 1 static const u32 SFAppearanceNode_X3D_TypeToTag[1] = { - TAG_X3D_Appearance + TAG_X3D_Appearance }; #define SFGeometryNode_X3D_Count 31 static const u32 SFGeometryNode_X3D_TypeToTag[31] = { - TAG_X3D_Arc2D, TAG_X3D_ArcClose2D, TAG_X3D_Box, TAG_X3D_Circle2D, TAG_X3D_Cone, TAG_X3D_Cylinder, TAG_X3D_Disk2D, TAG_X3D_ElevationGrid, TAG_X3D_Extrusion, TAG_X3D_GeoElevationGrid, TAG_X3D_IndexedFaceSet, TAG_X3D_IndexedLineSet, TAG_X3D_IndexedTriangleFanSet, TAG_X3D_IndexedTriangleSet, TAG_X3D_IndexedTriangleStripSet, TAG_X3D_LineSet, TAG_X3D_NurbsCurve, TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTrimmedSurface, TAG_X3D_PointSet, TAG_X3D_Polyline2D, TAG_X3D_Polypoint2D, TAG_X3D_Rectangle2D, TAG_X3D_Sphere, TAG_X3D_Text, TAG_X3D_TriangleFanSet, TAG_X3D_TriangleSet, TAG_X3D_TriangleSet2D, TAG_X3D_TriangleStripSet + TAG_X3D_Arc2D, TAG_X3D_ArcClose2D, TAG_X3D_Box, TAG_X3D_Circle2D, TAG_X3D_Cone, TAG_X3D_Cylinder, TAG_X3D_Disk2D, TAG_X3D_ElevationGrid, TAG_X3D_Extrusion, TAG_X3D_GeoElevationGrid, TAG_X3D_IndexedFaceSet, TAG_X3D_IndexedLineSet, TAG_X3D_IndexedTriangleFanSet, TAG_X3D_IndexedTriangleSet, TAG_X3D_IndexedTriangleStripSet, TAG_X3D_LineSet, TAG_X3D_NurbsCurve, TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTrimmedSurface, TAG_X3D_PointSet, TAG_X3D_Polyline2D, TAG_X3D_Polypoint2D, TAG_X3D_Rectangle2D, TAG_X3D_Sphere, TAG_X3D_Text, TAG_X3D_TriangleFanSet, TAG_X3D_TriangleSet, TAG_X3D_TriangleSet2D, TAG_X3D_TriangleStripSet }; #define SFAudioNode_X3D_Count 1 static const u32 SFAudioNode_X3D_TypeToTag[1] = { - TAG_X3D_AudioClip + TAG_X3D_AudioClip }; #define SFStreamingNode_X3D_Count 4 static const u32 SFStreamingNode_X3D_TypeToTag[4] = { - TAG_X3D_AudioClip, TAG_X3D_Inline, TAG_X3D_LoadSensor, TAG_X3D_MovieTexture + TAG_X3D_AudioClip, TAG_X3D_Inline, TAG_X3D_LoadSensor, TAG_X3D_MovieTexture }; #define SFBackground3DNode_X3D_Count 2 static const u32 SFBackground3DNode_X3D_TypeToTag[2] = { - TAG_X3D_Background, TAG_X3D_TextureBackground + TAG_X3D_Background, TAG_X3D_TextureBackground }; #define SFColorNode_X3D_Count 2 static const u32 SFColorNode_X3D_TypeToTag[2] = { - TAG_X3D_Color, TAG_X3D_ColorRGBA + TAG_X3D_Color, TAG_X3D_ColorRGBA }; #define SFNurbsControlCurveNode_X3D_Count 3 static const u32 SFNurbsControlCurveNode_X3D_TypeToTag[3] = { - TAG_X3D_Contour2D, TAG_X3D_ContourPolyline2D, TAG_X3D_NurbsCurve2D + TAG_X3D_Contour2D, TAG_X3D_ContourPolyline2D, TAG_X3D_NurbsCurve2D }; #define SFCoordinateNode_X3D_Count 3 static const u32 SFCoordinateNode_X3D_TypeToTag[3] = { - TAG_X3D_Coordinate, TAG_X3D_CoordinateDouble, TAG_X3D_GeoCoordinate + TAG_X3D_Coordinate, TAG_X3D_CoordinateDouble, TAG_X3D_GeoCoordinate }; #define SFCoordinate2DNode_X3D_Count 1 static const u32 SFCoordinate2DNode_X3D_TypeToTag[1] = { - TAG_X3D_Coordinate2D + TAG_X3D_Coordinate2D }; #define SFFillPropertiesNode_X3D_Count 1 static const u32 SFFillPropertiesNode_X3D_TypeToTag[1] = { - TAG_X3D_FillProperties + TAG_X3D_FillProperties }; #define SFFogNode_X3D_Count 1 static const u32 SFFogNode_X3D_TypeToTag[1] = { - TAG_X3D_Fog + TAG_X3D_Fog }; #define SFFontStyleNode_X3D_Count 1 static const u32 SFFontStyleNode_X3D_TypeToTag[1] = { - TAG_X3D_FontStyle + TAG_X3D_FontStyle }; #define SFGeoOriginNode_X3D_Count 1 static const u32 SFGeoOriginNode_X3D_TypeToTag[1] = { - TAG_X3D_GeoOrigin + TAG_X3D_GeoOrigin }; #define SFViewpointNode_X3D_Count 2 static const u32 SFViewpointNode_X3D_TypeToTag[2] = { - TAG_X3D_GeoViewpoint, TAG_X3D_Viewpoint + TAG_X3D_GeoViewpoint, TAG_X3D_Viewpoint }; #define SFTopNode_X3D_Count 1 static const u32 SFTopNode_X3D_TypeToTag[1] = { - TAG_X3D_Group + TAG_X3D_Group }; #define SFHAnimDisplacerNode_X3D_Count 1 static const u32 SFHAnimDisplacerNode_X3D_TypeToTag[1] = { - TAG_X3D_HAnimDisplacer + TAG_X3D_HAnimDisplacer }; #define SFHAnimNode_X3D_Count 3 static const u32 SFHAnimNode_X3D_TypeToTag[3] = { - TAG_X3D_HAnimJoint, TAG_X3D_HAnimSegment, TAG_X3D_HAnimSite + TAG_X3D_HAnimJoint, TAG_X3D_HAnimSegment, TAG_X3D_HAnimSite }; #define SFTextureNode_X3D_Count 4 static const u32 SFTextureNode_X3D_TypeToTag[4] = { - TAG_X3D_ImageTexture, TAG_X3D_MovieTexture, TAG_X3D_MultiTexture, TAG_X3D_PixelTexture + TAG_X3D_ImageTexture, TAG_X3D_MovieTexture, TAG_X3D_MultiTexture, TAG_X3D_PixelTexture }; #define SFX3DLinePropertiesNode_X3D_Count 1 static const u32 SFX3DLinePropertiesNode_X3D_TypeToTag[1] = { - TAG_X3D_LineProperties + TAG_X3D_LineProperties }; #define SFMaterialNode_X3D_Count 1 static const u32 SFMaterialNode_X3D_TypeToTag[1] = { - TAG_X3D_Material + TAG_X3D_Material }; #define SFMetadataNode_X3D_Count 5 static const u32 SFMetadataNode_X3D_TypeToTag[5] = { - TAG_X3D_MetadataDouble, TAG_X3D_MetadataFloat, TAG_X3D_MetadataInteger, TAG_X3D_MetadataSet, TAG_X3D_MetadataString + TAG_X3D_MetadataDouble, TAG_X3D_MetadataFloat, TAG_X3D_MetadataInteger, TAG_X3D_MetadataSet, TAG_X3D_MetadataString }; #define SFTextureCoordinateNode_X3D_Count 4 static const u32 SFTextureCoordinateNode_X3D_TypeToTag[4] = { - TAG_X3D_MultiTextureCoordinate, TAG_X3D_NurbsTextureCoordinate, TAG_X3D_TextureCoordinate, TAG_X3D_TextureCoordinateGenerator + TAG_X3D_MultiTextureCoordinate, TAG_X3D_NurbsTextureCoordinate, TAG_X3D_TextureCoordinate, TAG_X3D_TextureCoordinateGenerator }; #define SFTextureTransformNode_X3D_Count 2 static const u32 SFTextureTransformNode_X3D_TypeToTag[2] = { - TAG_X3D_MultiTextureTransform, TAG_X3D_TextureTransform + TAG_X3D_MultiTextureTransform, TAG_X3D_TextureTransform }; #define SFNavigationInfoNode_X3D_Count 1 static const u32 SFNavigationInfoNode_X3D_TypeToTag[1] = { - TAG_X3D_NavigationInfo + TAG_X3D_NavigationInfo }; #define SFNormalNode_X3D_Count 1 static const u32 SFNormalNode_X3D_TypeToTag[1] = { - TAG_X3D_Normal + TAG_X3D_Normal }; #define SFNurbsCurveNode_X3D_Count 1 static const u32 SFNurbsCurveNode_X3D_TypeToTag[1] = { - TAG_X3D_NurbsCurve + TAG_X3D_NurbsCurve }; #define SFNurbsSurfaceNode_X3D_Count 4 static const u32 SFNurbsSurfaceNode_X3D_TypeToTag[4] = { - TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTrimmedSurface + TAG_X3D_NurbsPatchSurface, TAG_X3D_NurbsSweptSurface, TAG_X3D_NurbsSwungSurface, TAG_X3D_NurbsTrimmedSurface }; @@ -15782,72 +16294,135 @@ Bool gf_x3d_get_node_type(u32 NDT_Tag, u32 NodeTag) const u32 *types; u32 count, i; if (!NodeTag) return 0; - types = NULL; count = 0; + types = NULL; + count = 0; switch (NDT_Tag) { case NDT_SFWorldNode: - types = SFWorldNode_X3D_TypeToTag; count = SFWorldNode_X3D_Count; break; + types = SFWorldNode_X3D_TypeToTag; + count = SFWorldNode_X3D_Count; + break; case NDT_SF3DNode: - types = SF3DNode_X3D_TypeToTag; count = SF3DNode_X3D_Count; break; + types = SF3DNode_X3D_TypeToTag; + count = SF3DNode_X3D_Count; + break; case NDT_SF2DNode: - types = SF2DNode_X3D_TypeToTag; count = SF2DNode_X3D_Count; break; + types = SF2DNode_X3D_TypeToTag; + count = SF2DNode_X3D_Count; + break; case NDT_SFAppearanceNode: - types = SFAppearanceNode_X3D_TypeToTag; count = SFAppearanceNode_X3D_Count; break; + types = SFAppearanceNode_X3D_TypeToTag; + count = SFAppearanceNode_X3D_Count; + break; case NDT_SFGeometryNode: - types = SFGeometryNode_X3D_TypeToTag; count = SFGeometryNode_X3D_Count; break; + types = SFGeometryNode_X3D_TypeToTag; + count = SFGeometryNode_X3D_Count; + break; case NDT_SFAudioNode: - types = SFAudioNode_X3D_TypeToTag; count = SFAudioNode_X3D_Count; break; + types = SFAudioNode_X3D_TypeToTag; + count = SFAudioNode_X3D_Count; + break; case NDT_SFStreamingNode: - types = SFStreamingNode_X3D_TypeToTag; count = SFStreamingNode_X3D_Count; break; + types = SFStreamingNode_X3D_TypeToTag; + count = SFStreamingNode_X3D_Count; + break; case NDT_SFBackground3DNode: - types = SFBackground3DNode_X3D_TypeToTag; count = SFBackground3DNode_X3D_Count; break; + types = SFBackground3DNode_X3D_TypeToTag; + count = SFBackground3DNode_X3D_Count; + break; case NDT_SFColorNode: - types = SFColorNode_X3D_TypeToTag; count = SFColorNode_X3D_Count; break; + types = SFColorNode_X3D_TypeToTag; + count = SFColorNode_X3D_Count; + break; case NDT_SFNurbsControlCurveNode: - types = SFNurbsControlCurveNode_X3D_TypeToTag; count = SFNurbsControlCurveNode_X3D_Count; break; + types = SFNurbsControlCurveNode_X3D_TypeToTag; + count = SFNurbsControlCurveNode_X3D_Count; + break; case NDT_SFCoordinateNode: - types = SFCoordinateNode_X3D_TypeToTag; count = SFCoordinateNode_X3D_Count; break; + types = SFCoordinateNode_X3D_TypeToTag; + count = SFCoordinateNode_X3D_Count; + break; case NDT_SFCoordinate2DNode: - types = SFCoordinate2DNode_X3D_TypeToTag; count = SFCoordinate2DNode_X3D_Count; break; + types = SFCoordinate2DNode_X3D_TypeToTag; + count = SFCoordinate2DNode_X3D_Count; + break; case NDT_SFFillPropertiesNode: - types = SFFillPropertiesNode_X3D_TypeToTag; count = SFFillPropertiesNode_X3D_Count; break; + types = SFFillPropertiesNode_X3D_TypeToTag; + count = SFFillPropertiesNode_X3D_Count; + break; case NDT_SFFogNode: - types = SFFogNode_X3D_TypeToTag; count = SFFogNode_X3D_Count; break; + types = SFFogNode_X3D_TypeToTag; + count = SFFogNode_X3D_Count; + break; case NDT_SFFontStyleNode: - types = SFFontStyleNode_X3D_TypeToTag; count = SFFontStyleNode_X3D_Count; break; + types = SFFontStyleNode_X3D_TypeToTag; + count = SFFontStyleNode_X3D_Count; + break; case NDT_SFGeoOriginNode: - types = SFGeoOriginNode_X3D_TypeToTag; count = SFGeoOriginNode_X3D_Count; break; + types = SFGeoOriginNode_X3D_TypeToTag; + count = SFGeoOriginNode_X3D_Count; + break; case NDT_SFViewpointNode: - types = SFViewpointNode_X3D_TypeToTag; count = SFViewpointNode_X3D_Count; break; + types = SFViewpointNode_X3D_TypeToTag; + count = SFViewpointNode_X3D_Count; + break; case NDT_SFTopNode: - types = SFTopNode_X3D_TypeToTag; count = SFTopNode_X3D_Count; break; + types = SFTopNode_X3D_TypeToTag; + count = SFTopNode_X3D_Count; + break; case NDT_SFHAnimDisplacerNode: - types = SFHAnimDisplacerNode_X3D_TypeToTag; count = SFHAnimDisplacerNode_X3D_Count; break; + types = SFHAnimDisplacerNode_X3D_TypeToTag; + count = SFHAnimDisplacerNode_X3D_Count; + break; case NDT_SFHAnimNode: - types = SFHAnimNode_X3D_TypeToTag; count = SFHAnimNode_X3D_Count; break; + types = SFHAnimNode_X3D_TypeToTag; + count = SFHAnimNode_X3D_Count; + break; case NDT_SFTextureNode: - types = SFTextureNode_X3D_TypeToTag; count = SFTextureNode_X3D_Count; break; + types = SFTextureNode_X3D_TypeToTag; + count = SFTextureNode_X3D_Count; + break; case NDT_SFX3DLinePropertiesNode: - types = SFX3DLinePropertiesNode_X3D_TypeToTag; count = SFX3DLinePropertiesNode_X3D_Count; break; + types = SFX3DLinePropertiesNode_X3D_TypeToTag; + count = SFX3DLinePropertiesNode_X3D_Count; + break; case NDT_SFMaterialNode: - types = SFMaterialNode_X3D_TypeToTag; count = SFMaterialNode_X3D_Count; break; + types = SFMaterialNode_X3D_TypeToTag; + count = SFMaterialNode_X3D_Count; + break; case NDT_SFMetadataNode: - types = SFMetadataNode_X3D_TypeToTag; count = SFMetadataNode_X3D_Count; break; + types = SFMetadataNode_X3D_TypeToTag; + count = SFMetadataNode_X3D_Count; + break; case NDT_SFTextureCoordinateNode: - types = SFTextureCoordinateNode_X3D_TypeToTag; count = SFTextureCoordinateNode_X3D_Count; break; + types = SFTextureCoordinateNode_X3D_TypeToTag; + count = SFTextureCoordinateNode_X3D_Count; + break; case NDT_SFTextureTransformNode: - types = SFTextureTransformNode_X3D_TypeToTag; count = SFTextureTransformNode_X3D_Count; break; + types = SFTextureTransformNode_X3D_TypeToTag; + count = SFTextureTransformNode_X3D_Count; + break; case NDT_SFNavigationInfoNode: - types = SFNavigationInfoNode_X3D_TypeToTag; count = SFNavigationInfoNode_X3D_Count; break; + types = SFNavigationInfoNode_X3D_TypeToTag; + count = SFNavigationInfoNode_X3D_Count; + break; case NDT_SFNormalNode: - types = SFNormalNode_X3D_TypeToTag; count = SFNormalNode_X3D_Count; break; + types = SFNormalNode_X3D_TypeToTag; + count = SFNormalNode_X3D_Count; + break; case NDT_SFNurbsCurveNode: - types = SFNurbsCurveNode_X3D_TypeToTag; count = SFNurbsCurveNode_X3D_Count; break; + types = SFNurbsCurveNode_X3D_TypeToTag; + count = SFNurbsCurveNode_X3D_Count; + break; case NDT_SFNurbsSurfaceNode: - types = SFNurbsSurfaceNode_X3D_TypeToTag; count = SFNurbsSurfaceNode_X3D_Count; break; + types = SFNurbsSurfaceNode_X3D_TypeToTag; + count = SFNurbsSurfaceNode_X3D_Count; + break; default: return 0; } - for(i=0; i @@ -38,7 +38,7 @@ typedef struct GF_Err last_error; GF_SAXParser *sax_parser; XBL_Element *root; - + /* stack of XBL nodes*/ GF_List *node_stack; } GF_XBL_Parser; @@ -88,7 +88,7 @@ static XBL_Element *xbl_parse_element(GF_XBL_Parser *parser, const char *name, c { u32 tag, attribute_tag, i; XBL_Element *elt = NULL; - + // if (name_space && strlen(name_space)) return NULL; tag = gf_sg_node_get_tag_by_class_name(name, 0); @@ -151,7 +151,7 @@ static void xbl_node_end(void *sax_cbck, const char *name, const char *name_spac { GF_XBL_Parser *parser = (GF_XBL_Parser *)sax_cbck; XBL_NodeStack *top = (XBL_NodeStack *)gf_list_last(parser->node_stack); - + if (!top) return; if (/*!name_space && */gf_sg_node_get_tag_by_class_name(name, 0) != TAG_UndefinedNode) { const char *the_name; diff --git a/src/scenegraph/xml_ns.c b/src/scenegraph/xml_ns.c index 7e92118..73591c3 100644 --- a/src/scenegraph/xml_ns.c +++ b/src/scenegraph/xml_ns.c @@ -15,7 +15,7 @@ * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY, TYPE, 0 }, without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library, TYPE, 0 }, see the file COPYING. If not, write to @@ -46,7 +46,13 @@ enum GF_SVG_ATTOPT_FILTER = 5, } GF_SVGAttOption; -static const struct xml_att_def { const char *name; u32 tag; u32 type; u32 opts; u32 xmlns; } xml_attributes [] = +static const struct xml_att_def { + const char *name; + u32 tag; + u32 type; + u32 opts; + u32 xmlns; +} xml_attributes [] = { /*XML base*/ { "id", TAG_XML_ATT_id, SVG_ID_datatype, 0, GF_XMLNS_XML } , @@ -72,7 +78,7 @@ static const struct xml_att_def { const char *name; u32 tag; u32 type; u32 opts; { "target", TAG_XMLEV_ATT_target, XML_IDREF_datatype, 0, GF_XMLNS_XMLEV }, { "handler", TAG_XMLEV_ATT_handler, XMLRI_datatype, 0, GF_XMLNS_XMLEV }, - + { "id", TAG_SVG_ATT_id, SVG_ID_datatype, 0, GF_XMLNS_SVG } , { "class", TAG_SVG_ATT__class, DOM_String_datatype, 0, GF_XMLNS_SVG }, { "requiredFeatures", TAG_SVG_ATT_requiredFeatures, XMLRI_List_datatype, 0, GF_XMLNS_SVG }, @@ -130,7 +136,7 @@ static const struct xml_att_def { const char *name; u32 tag; u32 type; u32 opts; { "nav-down-left", TAG_SVG_ATT_nav_down_left, SVG_Focus_datatype, 0, GF_XMLNS_SVG }, { "nav-left", TAG_SVG_ATT_nav_left, SVG_Focus_datatype, 0, GF_XMLNS_SVG }, { "nav-up-left", TAG_SVG_ATT_nav_up_left, SVG_Focus_datatype, 0, GF_XMLNS_SVG }, - { "transform", TAG_SVG_ATT_transform, SVG_Transform_datatype, 0, GF_XMLNS_SVG }, + { "transform", TAG_SVG_ATT_transform, SVG_Transform_datatype, 0, GF_XMLNS_SVG }, { "target", TAG_SVG_ATT_target, DOM_String_datatype, 0, GF_XMLNS_SVG }, { "attributeName", TAG_SVG_ATT_attributeName, SMIL_AttributeName_datatype, 0, GF_XMLNS_SVG }, { "attributeType", TAG_SVG_ATT_attributeType, SMIL_AttributeType_datatype, 0, GF_XMLNS_SVG }, @@ -265,7 +271,7 @@ static const struct xml_att_def { const char *name; u32 tag; u32 type; u32 opts; { "y", TAG_SVG_ATT_text_y, SVG_Coordinates_datatype, GF_SVG_ATTOPT_TEXT, GF_XMLNS_SVG }, /*regular y position*/ { "y", TAG_SVG_ATT_y, SVG_Coordinate_datatype, 0, GF_XMLNS_SVG }, - + /*filters*/ { "tableValues", TAG_SVG_ATT_filter_table_values, SVG_Numbers_datatype, 0, GF_XMLNS_SVG }, { "intercept", TAG_SVG_ATT_filter_intercept, SVG_Number_datatype, 0, GF_XMLNS_SVG }, @@ -505,7 +511,11 @@ GF_DOMAttribute *gf_xml_create_attribute(GF_Node *node, u32 tag) return gf_node_create_attribute_from_datatype(type, tag); } -static const struct xml_elt_def { const char *name; u32 tag; u32 xmlns; } xml_elements [] = +static const struct xml_elt_def { + const char *name; + u32 tag; + u32 xmlns; +} xml_elements [] = { { "listener", TAG_SVG_listener, GF_XMLNS_XMLEV}, /*SVG*/ @@ -633,7 +643,7 @@ const char *gf_xml_get_element_name(GF_Node *n) for (i=0; isgprivate->tag==xml_elements[i].tag) { char *xmlns; - if (!n || (ns == xml_elements[i].xmlns)) + if (!n || (ns == xml_elements[i].xmlns)) return xml_elements[i].name; xmlns = (char *) gf_sg_get_namespace_qname(n->sgprivate->scenegraph, xml_elements[i].xmlns); @@ -675,7 +685,7 @@ u32 gf_node_get_attribute_count(GF_Node *node) return count; } -GF_Err gf_node_get_attribute_info(GF_Node *node, GF_FieldInfo *info) +GF_Err gf_node_get_attribute_info(GF_Node *node, GF_FieldInfo *info) { GF_DOMNode *dom = (GF_DOMNode *)node; GF_DOMAttribute *atts = dom->attributes; @@ -732,9 +742,9 @@ GF_Err gf_node_get_attribute_by_name(GF_Node *node, char *name, u32 xmlns_code, if (ns) len = (u32) strlen(ns); while (att) { - if (((u32) att->tag == TAG_DOM_ATT_any) && - ((!ns && !strcmp(name, att->name)) || (ns && !strncmp(att->name, ns, len) && !strcmp(att->name+len+1, name))) - ) { + if (((u32) att->tag == TAG_DOM_ATT_any) && + ((!ns && !strcmp(name, att->name)) || (ns && !strncmp(att->name, ns, len) && !strcmp(att->name+len+1, name))) + ) { field->fieldIndex = att->tag; field->fieldType = att->data_type; field->far_ptr = att->data; @@ -796,9 +806,9 @@ static void attributes_set_default_value(GF_Node *node, SVGAttribute *att) } break; case TAG_SVG_ATT_dur: - if (node_tag == TAG_SVG_video || - node_tag == TAG_SVG_audio || - node_tag == TAG_SVG_animation) + if (node_tag == TAG_SVG_video || + node_tag == TAG_SVG_audio || + node_tag == TAG_SVG_animation) { ((SMIL_Duration *)att->data)->type = SMIL_DURATION_MEDIA; } else { @@ -874,18 +884,18 @@ static void attributes_set_default_value(GF_Node *node, SVGAttribute *att) case TAG_SVG_ATT_zoomAndPan: *((SVG_ZoomAndPan *)att->data) = SVG_ZOOMANDPAN_MAGNIFY; break; - case TAG_SVG_ATT_stroke_linecap: - *(SVG_StrokeLineCap*)att->data = SVG_STROKELINECAP_INHERIT; + case TAG_SVG_ATT_stroke_linecap: + *(SVG_StrokeLineCap*)att->data = SVG_STROKELINECAP_INHERIT; break; - case TAG_SVG_ATT_stroke_linejoin: - *(SVG_StrokeLineJoin*)att->data = SVG_STROKELINEJOIN_INHERIT; + case TAG_SVG_ATT_stroke_linejoin: + *(SVG_StrokeLineJoin*)att->data = SVG_STROKELINEJOIN_INHERIT; break; - case TAG_SVG_ATT_transform: + case TAG_SVG_ATT_transform: gf_mx2d_init(((SVG_Transform*)att->data)->mat); break; - + /*all default=0 values (don't need init)*/ case TAG_SVG_ATT_font_family: case TAG_SVG_ATT_font_style: @@ -927,7 +937,7 @@ GF_Err gf_node_get_attribute_by_tag(GF_Node *node, u32 attribute_tag, Bool creat field->fieldType = att->data_type; field->fieldIndex = att->tag; /* attribute name should not be called, if needed use gf_svg_get_attribute_name(att->tag);*/ - field->name = NULL; + field->name = NULL; if (set_default) attributes_set_default_value(node, att); return GF_OK; } @@ -972,8 +982,8 @@ GF_Node *gf_xml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clone n_dst = (GF_DOMFullNode *)clone; n_dst->ns = n_src->ns; n_dst->name = gf_strdup(n_dst->name); - } - + } + att = ((GF_DOMNode *)orig)->attributes; while (att) { GF_FieldInfo dst, src; @@ -996,7 +1006,7 @@ GF_Node *gf_xml_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *clone } } att = att->next; - } + } } if (cloned_parent) { gf_node_list_add_child( & ((GF_ParentNode*)cloned_parent)->children, clone); @@ -1023,9 +1033,9 @@ static u32 check_existing_file(char *base_file, char *ext, char *data, u32 data_ char szFile[GF_MAX_PATH]; u64 fsize; FILE *f; - + sprintf(szFile, "%s%04X%s", base_file, idx, ext); - + f = gf_f64_open(szFile, "rb"); if (!f) return 0; @@ -1047,7 +1057,7 @@ static u32 check_existing_file(char *base_file, char *ext, char *data, u32 data_ if (!fsize) return 2; } if (f) - fclose(f); + fclose(f); return 1; } @@ -1107,9 +1117,9 @@ GF_Err gf_node_store_embedded_data(XMLRI *iri, const char *cache_dir, const char data_size = gf_base16_decode(sep, (u32) strlen(sep), data, data_size); } if (!data_size) return GF_OK; - + iri->type = XMLRI_STRING; - + existing = 0; idx = 0; while (1) { diff --git a/src/terminal/channel.c b/src/terminal/channel.c index 1193b21..7ae2553 100644 --- a/src/terminal/channel.c +++ b/src/terminal/channel.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -140,7 +140,7 @@ GF_Channel *gf_es_new(GF_ESD *esd) void gf_es_reconfig_sl(GF_Channel *ch, GF_SLConfig *slc, Bool use_m2ts_sections) { u32 nbBits; - + memcpy(ch->esd->slConfig, slc, sizeof(GF_SLConfig)); nbBits = sizeof(u32) * 8 - ch->esd->slConfig->AUSeqNumLength; @@ -205,7 +205,7 @@ GF_Err gf_es_start(GF_Channel *ch) case GF_ESM_ES_UNAVAILABLE: case GF_ESM_ES_SETUP: return GF_BAD_PARAM; - /*if the channel is already running, don't reset its settings. This only happens in the case of broadcast + /*if the channel is already running, don't reset its settings. This only happens in the case of broadcast objects started several times by the scene but not stopped at the ODManager level (cf gf_odm_stop)*/ case GF_ESM_ES_RUNNING: return GF_OK; @@ -215,7 +215,7 @@ GF_Err gf_es_start(GF_Channel *ch) GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] Starting ES %d\n", ch->esd->ESID)); /*reset clock if we own it*/ - if (gf_es_owns_clock(ch) && !ch->clock->no_time_ctrl) + if (gf_es_owns_clock(ch) && !ch->clock->no_time_ctrl) gf_clock_reset(ch->clock); /*reset channel*/ @@ -223,7 +223,7 @@ GF_Err gf_es_start(GF_Channel *ch) /*create pull buffer if needed*/ if (ch->is_pulling && !ch->AU_buffer_pull) ch->AU_buffer_pull = gf_db_unit_new(); - /*and start buffering - pull channels always turn off buffering immediately, otherwise + /*and start buffering - pull channels always turn off buffering immediately, otherwise buffering size is setup by the network service - except InputSensor*/ if ((ch->esd->decoderConfig->streamType != GF_STREAM_INTERACT) || ch->esd->URLString) { if (! ch->is_pulling) @@ -265,7 +265,7 @@ void Channel_WaitRAP(GF_Channel *ch) ch->pck_sn = 0; /*if using RAP signal and codec not resilient, wait for rap. If RAP isn't signaled, this will be ignored*/ - if (ch->codec_resilient != GF_CODEC_RESILIENT_ALWAYS) + if (ch->codec_resilient != GF_CODEC_RESILIENT_ALWAYS) ch->stream_state = 2; if (ch->buffer) gf_free(ch->buffer); ch->buffer = NULL; @@ -288,7 +288,7 @@ void gf_es_reset_buffers(GF_Channel *ch) ch->BufferTime = 0; gf_mx_v(ch->mx); - if (ch->odm->codec && ch->odm->codec->CB) + if (ch->odm->codec && ch->odm->codec->CB) gf_cm_reset(ch->odm->codec->CB); } @@ -328,7 +328,7 @@ static Bool Channel_NeedsBuffering(GF_Channel *ch, u32 ForRebuffering) u32 now = gf_term_get_time(ch->odm->term); /*data timeout (no data sent)*/ if (now > ch->last_au_time + ch->clock->data_timeout) { - gf_term_message(ch->odm->term, ch->service->url, "Data timeout - aborting buffering", GF_OK); + gf_term_message(ch->odm->term, ch->service->url, "Data timeout - aborting buffering", GF_OK); ch->MinBuffer = ch->MaxBuffer = 0; ch->au_duration = 0; gf_scene_buffering_info(ch->odm->parentscene ? ch->odm->parentscene : ch->odm->subscene); @@ -340,7 +340,7 @@ static Bool Channel_NeedsBuffering(GF_Channel *ch, u32 ForRebuffering) char szMsg[500]; ch->au_duration = now; sprintf(szMsg, "Buffering - Waiting for data (%d s)", now); - gf_term_message(ch->odm->term, ch->service->url, szMsg, GF_OK); + gf_term_message(ch->odm->term, ch->service->url, szMsg, GF_OK); } return 1; } @@ -352,11 +352,11 @@ static Bool Channel_NeedsBuffering(GF_Channel *ch, u32 ForRebuffering) u32 now = gf_term_get_time(ch->odm->term); /*if more than MaxBuffer sec since last AU don't buffer and prevent rebuffering on short streams this will also work for channels ignoring timing - we use MaxBuffer as some transport protocols (HTTP streaming, DVB-H) will work in burst modes of MaxBuffer + we use MaxBuffer as some transport protocols (HTTP streaming, DVB-H) will work in burst modes of MaxBuffer */ if (now > ch->last_au_time + 2*ch->MaxBuffer ) { /*this can be safely seen as a stream with very few updates (likely only one)*/ - if (!ch->AU_buffer_first && ch->first_au_fetched) + if (!ch->AU_buffer_first && ch->first_au_fetched) ch->MinBuffer = 0; return 0; } @@ -371,7 +371,7 @@ static void Channel_UpdateBuffering(GF_Channel *ch, Bool update_info) gf_term_service_media_event(ch->odm, GF_EVENT_MEDIA_PROGRESS); gf_term_service_media_event(ch->odm, GF_EVENT_MEDIA_TIME_UPDATE); - + if (!Channel_NeedsBuffering(ch, 0)) { gf_es_buffer_off(ch); if (ch->MaxBuffer && update_info) gf_scene_buffering_info(ch->odm->parentscene ? ch->odm->parentscene : ch->odm->subscene); @@ -410,7 +410,7 @@ static void Channel_UpdateBufferTime(GF_Channel *ch) if (ch->clock->speed != FIX_ONE) { ch->BufferTime = FIX2INT( gf_divfix( INT2FIX(ch->AU_buffer_last->DTS - ch->AU_buffer_first->DTS) , ch->clock->speed)) ; } - } else { + } else { ch->BufferTime = 0; } } @@ -465,7 +465,7 @@ static void Channel_DispatchAU(GF_Channel *ch, u32 duration) au->data = (char*)gf_realloc(au->data, sizeof(char) * (au->dataLength + ch->media_padding_bytes)); } if (ch->media_padding_bytes) memset(au->data + au->dataLength, 0, sizeof(char)*ch->media_padding_bytes); - + ch->len = ch->allocSize = 0; gf_es_lock(ch, 1); @@ -523,9 +523,9 @@ static void Channel_DispatchAU(GF_Channel *ch, u32 duration) } else { TS_diff = au_prev->next->CTS - au_prev->CTS; } - if (TS_diff && (TS_diffDTS < minCTS) minCTS = au_prev->CTS; @@ -567,7 +567,7 @@ static void Channel_DispatchAU(GF_Channel *ch, u32 duration) u32 au_dts_shift = ins_au->DTS - ins_au->CTS; if (au_dts_shift > dts_shift ) dts_shift = au_dts_shift; } - + if (dts_shift) { au_prev = ch->AU_buffer_first; /*locate first AU in buffer with DTS greater than new unit CTS*/ @@ -622,7 +622,7 @@ static void Channel_DispatchAU(GF_Channel *ch, u32 duration) GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ES%d (%s) - Dispatch AU DTS %d - CTS %d - RAP %d - size %d time %d Buffer %d Nb AUs %d - First AU relative timing %d\n", ch->esd->ESID, ch->odm->net_service->url, au->DTS, au->CTS, au->flags&1, au->dataLength, gf_clock_real_time(ch->clock), ch->BufferTime, ch->AU_Count, ch->AU_buffer_first ? ch->AU_buffer_first->DTS - gf_clock_time(ch->clock) : 0 )); /*little optimisation: if direct dispatching is possible, try to decode the AU - we must lock the media scheduler to avoid deadlocks with other codecs accessing the scene or + we must lock the media scheduler to avoid deadlocks with other codecs accessing the scene or media resources*/ if (ch->dispatch_after_db) { u32 retry = 100; @@ -637,7 +637,7 @@ static void Channel_DispatchAU(GF_Channel *ch, u32 duration) gf_codec_process(ch->odm->subscene->od_codec, 100); break; case GF_STREAM_SCENE: - if (ch->odm->codec) + if (ch->odm->codec) gf_codec_process(ch->odm->codec, 100); else gf_codec_process(ch->odm->subscene->scene_codec, 100); @@ -733,14 +733,14 @@ void Channel_ReceiveSkipSL(GF_ClientService *serv, GF_Channel *ch, const char *S static void gf_es_check_timing(GF_Channel *ch) { - /*the first data received inits the clock - this is needed to handle clock dependencies on non-initialized + /*the first data received inits the clock - this is needed to handle clock dependencies on non-initialized streams (eg, bifs/od depends on audio/video clock)*/ if (!ch->clock->clock_init) { if (!ch->clock->use_ocr) { gf_clock_set_time(ch->clock, ch->CTS); GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] ES%d: Forcing clock initialization at STB %d - AU DTS %d CTS %d\n", ch->esd->ESID, gf_term_get_time(ch->odm->term), ch->DTS, ch->CTS)); ch->IsClockInit = 1; - } + } } /*channel is the OCR, force a re-init of the clock since we cannot assume the AU used to init the clock was not sent ahead of time*/ @@ -812,7 +812,7 @@ void gf_es_dispatch_raw_media_au(GF_Channel *ch, char *payload, u32 payload_size gf_clock_buffer_off(ch->clock); gf_cm_abort_buffering(cb); } - /*since the CB is a simple pointer to the input frame, wait until it is released before getting + /*since the CB is a simple pointer to the input frame, wait until it is released before getting back to the caller module*/ if (size) { gf_sema_wait(ch->odm->raw_frame_sema); @@ -926,10 +926,10 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo pcr_diff = (s32) OCR_TS - (s32) ck; pcr_pcrprev_diff = pcr_diff - ch->prev_pcr_diff; - GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ES%d: At OTB %u got OCR %u (original TS "LLU") - diff %d%s\n", ch->esd->ESID, gf_clock_real_time(ch->clock), OCR_TS, hdr.objectClockReference, pcr_diff, (hdr.m2ts_pcr==2) ? " - PCR Discontinuity flag" : "" )); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ES%d: At OTB %u got OCR %u (original TS "LLU") - diff %d%s (diff with prev OCR %d)\n", ch->esd->ESID, gf_clock_real_time(ch->clock), OCR_TS, hdr.objectClockReference, pcr_diff, (hdr.m2ts_pcr==2) ? " - PCR Discontinuity flag" : "", pcr_pcrprev_diff)); //PCR loop or disc - use 10 sec as a threshold - it may happen that video is sent up to 4 or 5 seconds ahead of the PCR in some systems - if (ch->prev_pcr_diff && ABS(pcr_pcrprev_diff) > 10000) { + if (ch->IsClockInit && ABS(pcr_pcrprev_diff) > 10000) { GF_LOG(GF_LOG_WARNING, GF_LOG_SYNC, ("[SyncLayer] ES%d: At OTB %u detected PCR %s (PCR diff %d - last PCR diff %d)\n", ch->esd->ESID, gf_clock_real_time(ch->clock), (hdr.m2ts_pcr==2) ? "discontinuity" : "looping", pcr_diff, ch->prev_pcr_diff)); gf_clock_discontinuity(ch->clock, ch->odm->parentscene, (hdr.m2ts_pcr==2) ? GF_TRUE : GF_FALSE); @@ -954,7 +954,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo if (!ch->esd->slConfig->useAccessUnitStartFlag) { /*no AU signaling - each packet is an AU*/ - if (!ch->esd->slConfig->useAccessUnitEndFlag) + if (!ch->esd->slConfig->useAccessUnitEndFlag) hdr.accessUnitEndFlag = hdr.accessUnitStartFlag = 1; /*otherwise AU are signaled by end of previous packet*/ else @@ -1011,7 +1011,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo /*if not first packet but about to force a clock init, do init timestamps*/ else if (!ch->IsClockInit) { /*don't process anything until the clock is initialized*/ - if (ch->esd->dependsOnESID && !gf_es_owns_clock(ch)) + if (ch->esd->dependsOnESID && !gf_es_owns_clock(ch)) return; if (hdr.compositionTimeStampFlag) init_ts = 1; @@ -1044,9 +1044,9 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo #if 0 /*until clock is not init check seed ts*/ - if (!ch->IsClockInit && (ch->net_dts < ch->seed_ts)) + if (!ch->IsClockInit && (ch->net_dts < ch->seed_ts)) ch->seed_ts = ch->net_dts; -#endif +#endif if (ch->net_ctsseed_ts) { u64 diff = ch->seed_ts - ch->net_cts; @@ -1121,7 +1121,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo } /*carousel for repeated AUs.*/ if (ch->carousel_type) { -/* not used : Bool use_rap = hdr.randomAccessPointFlag; */ + /* not used : Bool use_rap = hdr.randomAccessPointFlag; */ if (ch->carousel_type==GF_ESM_CAROUSEL_MPEG2) { AUSeqNum = hdr.m2ts_version_number_plus_one-1; @@ -1156,7 +1156,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo if (ch->stream_state==2) { GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] ES%d: RAP Carousel found (TS %d) - recovering\n", ch->esd->ESID, ch->CTS)); ch->stream_state = 0; - } + } else { ch->skip_carousel_au = 1; GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] ES%d: RAP Carousel found (TS %d) - skipping\n", ch->esd->ESID, ch->CTS)); @@ -1168,10 +1168,10 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo if (ch->stream_state==2) { GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] ES%d: RAP Carousel found (TS %d) - recovering from previous errors\n", ch->esd->ESID, ch->CTS)); } - ch->au_sn = AUSeqNum; + ch->au_sn = AUSeqNum; ch->stream_state = 0; } - } + } /*regular AU but waiting for RAP*/ else if (ch->stream_state) { #if 0 @@ -1183,10 +1183,10 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo #endif } /*previous packet(s) loss: check for critical or non-critical AUs*/ - else if (reception_status == GF_REMOTE_SERVICE_ERROR) { + else if (reception_status == GF_REMOTE_SERVICE_ERROR) { if (ch->au_sn == AUSeqNum) { GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] ES%d: Lost a non critical packet\n", ch->esd->ESID)); - } + } /*Packet lost are critical*/ else { ch->stream_state = 2; @@ -1215,7 +1215,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo /*update the RAP marker on a packet base (to cope with AVC/H264 NALU->AU reconstruction)*/ if (hdr.randomAccessPointFlag) ch->IsRap = 1; - /*get AU end state*/ + /*get AU end state*/ OldLength = ch->buffer ? ch->len : 0; EndAU = hdr.accessUnitEndFlag; if (ch->AULength == OldLength + payload_size) EndAU = 1; @@ -1263,7 +1263,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo ch->len = 0; } if (!ch->esd->slConfig->usePaddingFlag) hdr.paddingFlag = 0; - + if (ch->ipmp_tool) { GF_Err e; GF_IPMPEvent evt; @@ -1301,7 +1301,7 @@ void gf_es_receive_sl_packet(GF_ClientService *serv, GF_Channel *ch, char *paylo gf_es_lock(ch, 1); - if (hdr.paddingFlag && !EndAU) { + if (hdr.paddingFlag && !EndAU) { /*to do - this shouldn't happen anyway */ } else { @@ -1331,12 +1331,13 @@ void gf_es_on_eos(GF_Channel *ch) { if (!ch || ch->IsEndOfStream) return; ch->IsEndOfStream = 1; - + /*flush buffer*/ gf_es_buffer_off(ch); if (ch->len) Channel_DispatchAU(ch, 0); + GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[ODM%d] Channel %d is end of stream\n", ch->odm->OD->objectDescriptorID, (u32) ch->esd->ESID)); gf_odm_on_eos(ch->odm, ch); } @@ -1347,12 +1348,14 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) Bool comp, is_new_data; GF_Err e, state; GF_SLHeader slh; + char *reagg_au; + u32 reagg_au_size; if (ch->es_state != GF_ESM_ES_RUNNING) return NULL; if (!ch->is_pulling) { gf_mx_p(ch->mx); - + if (!ch->AU_buffer_first || (ch->BufferTime < (s32) ch->MaxBuffer/2) ) { /*query buffer level, don't sleep if too low*/ GF_NetworkCommand com; @@ -1360,14 +1363,20 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) com.base.on_channel = ch; gf_term_service_command(ch->service, &com); } - + /*we must update buffering before fetching in order to stop buffering for streams with very few updates (especially streams with one update, like most of OD streams)*/ if (ch->BufferOn && ch->AU_buffer_first) Channel_UpdateBuffering(ch, 0); gf_mx_v(ch->mx); - + +#if 0 + if (ch->odm->parentscene->active_addon && !ch->odm->parentscene->active_addon->started) { + return NULL; + } +#endif + if (ch->BufferOn) { - if (ch->first_au_fetched || !ch->AU_buffer_first || !ch->AU_buffer_first->next) + if (ch->first_au_fetched || !ch->AU_buffer_first || !ch->AU_buffer_first->next || !ch->odm->parentscene->active_addon || !ch->odm->parentscene->active_addon->started) return NULL; } return ch->AU_buffer_first; @@ -1384,6 +1393,9 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) memset(&slh, 0, sizeof(GF_SLHeader)); + reagg_au = ch->AU_buffer_pull->data; + reagg_au_size = ch->AU_buffer_pull->dataLength; + e = gf_term_channel_get_sl_packet(ch->service, ch, (char **) &ch->AU_buffer_pull->data, &ch->AU_buffer_pull->dataLength, &slh, &comp, &state, &is_new_data); if (e) state = e; switch (state) { @@ -1407,19 +1419,24 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) case GF_OK: break; default: - { - char m[100]; - sprintf(m, "Data reception failure on channel %d", ch->esd->ESID); - gf_term_message(ch->odm->term, ch->service->url , m, state); - return NULL; - } + { + char m[100]; + sprintf(m, "Data reception failure on channel %d", ch->esd->ESID); + gf_term_message(ch->odm->term, ch->service->url , m, state); + return NULL; + } } assert(!comp); /*update timing if new stream data but send no data. in sase of encrypted data: we always need updating*/ if (is_new_data) { ch->IsRap = 0; gf_es_receive_sl_packet(ch->service, ch, NULL, 0, &slh, GF_OK); - + + if (ch->stream_state) { + gf_term_channel_release_sl_packet(ch->service, ch); + return NULL; + } + if (ch->ipmp_tool) { GF_IPMPEvent evt; memset(&evt, 0, sizeof(evt)); @@ -1454,9 +1471,16 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) return NULL; } } - GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ES%d (%s) - Dispatch Pull AU DTS %d - CTS %d - size %d time %d - UTC "LLU" ms\n", ch->esd->ESID, ch->odm->net_service->url, ch->DTS, ch->CTS, ch->AU_buffer_pull->dataLength, gf_clock_real_time(ch->clock), gf_net_get_utc() )); + GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ES%d (%s) at %d - Dispatch Pull AU DTS %d - CTS %d - size %d - RAP %d\n", ch->esd->ESID, ch->odm->net_service->url, gf_clock_real_time(ch->clock), ch->DTS, ch->CTS, ch->AU_buffer_pull->dataLength, ch->AU_buffer_pull->flags&1 ? 1 : 0)); + + ch->AU_buffer_pull->flags = 0; + if (ch->IsRap) ch->AU_buffer_pull->flags |= GF_DB_AU_RAP; + } else if (reagg_au) { + ch->AU_buffer_pull->data = reagg_au; + ch->AU_buffer_pull->dataLength = reagg_au_size; } + /*this may happen in file streaming when data has not arrived yet, in which case we discard the AU*/ if (!ch->AU_buffer_pull->data) { gf_term_channel_release_sl_packet(ch->service, ch); @@ -1465,8 +1489,6 @@ GF_DBUnit *gf_es_get_au(GF_Channel *ch) ch->AU_buffer_pull->CTS = (u32) ch->CTS; ch->AU_buffer_pull->DTS = (u32) ch->DTS; ch->AU_buffer_pull->PaddingBits = ch->padingBits; - ch->AU_buffer_pull->flags = 0; - if (ch->IsRap) ch->AU_buffer_pull->flags |= GF_DB_AU_RAP; if (ch->pull_forced_buffer) { assert(ch->BufferOn); @@ -1508,6 +1530,10 @@ void gf_es_drop_au(GF_Channel *ch) if (ch->is_pulling) { if (ch->AU_buffer_pull) { + //we have made a copy of the AU !! + if (ch->AU_buffer_pull->flags & GF_DB_AU_REAGGREGATED) { + gf_free(ch->AU_buffer_pull->data); + } gf_term_channel_release_sl_packet(ch->service, ch); ch->AU_buffer_pull->data = NULL; ch->AU_buffer_pull->dataLength = 0; @@ -1633,7 +1659,7 @@ void gf_es_on_connect(GF_Channel *ch) } /*signal channel state*/ - if (ch->es_state == GF_ESM_ES_WAIT_FOR_ACK) + if (ch->es_state == GF_ESM_ES_WAIT_FOR_ACK) ch->es_state = GF_ESM_ES_CONNECTED; /*signal only once connected to prevent PLAY trigger on connection callback*/ ch->odm->pending_channels--; @@ -1672,7 +1698,7 @@ void gf_es_on_connect(GF_Channel *ch) } if (ch->esd->decoderConfig->streamType == GF_STREAM_PRIVATE_SCENE && - ch->esd->decoderConfig->objectTypeIndication == GPAC_OTI_PRIVATE_SCENE_EPG) { + ch->esd->decoderConfig->objectTypeIndication == GPAC_OTI_PRIVATE_SCENE_EPG) { ch->bypass_sl_and_db = 1; } if (ch->clock->no_time_ctrl) { @@ -1722,9 +1748,9 @@ void gf_es_config_drm(GF_Channel *ch, GF_NetComDRMConfig *drm_cfg) cenc_cfg.scheme_type = drm_cfg->scheme_type; cenc_cfg.PSSH_count = drm_cfg->PSSH_count; cenc_cfg.PSSHs = drm_cfg->PSSHs; - evt.config_data = &cenc_cfg; + evt.config_data = &cenc_cfg; } else { - /*ISMA and OMA*/ + /*ISMA and OMA*/ if (drm_cfg->contentID) { evt.config_data_code = GF_4CC('o','d','r','m'); memset(&cfg, 0, sizeof(cfg)); @@ -1747,7 +1773,7 @@ void gf_es_config_drm(GF_Channel *ch, GF_NetComDRMConfig *drm_cfg) isma_cfg.scheme_type = drm_cfg->scheme_type; isma_cfg.scheme_uri = drm_cfg->scheme_uri; isma_cfg.kms_uri = drm_cfg->kms_uri; - evt.config_data = &isma_cfg; + evt.config_data = &isma_cfg; } } @@ -1773,7 +1799,7 @@ void gf_es_config_drm(GF_Channel *ch, GF_NetComDRMConfig *drm_cfg) gf_modules_close_interface((GF_BaseInterface *) ch->ipmp_tool); ch->ipmp_tool = NULL; } - GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[IPMP] No IPMP tool suitable to handle channel protection scheme %s (KMS URI %s)\n", drm_cfg->scheme_uri, drm_cfg->kms_uri)); + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[IPMP] No IPMP tool suitable to handle channel protection scheme %s (KMS URI %s)\n", drm_cfg->scheme_uri, drm_cfg->kms_uri)); gf_es_buffer_off(ch); } diff --git a/src/terminal/clock.c b/src/terminal/clock.c index a8e4521..c601713 100644 --- a/src/terminal/clock.c +++ b/src/terminal/clock.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC scene distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -154,8 +154,8 @@ void gf_clock_reset(GF_Clock *ck) ck->clock_init = 0; ck->drift = 0; ck->discontinuity_time = 0; - //do NOT reset buffering flag, because RESET scene called only - //for the stream owning the clock, and other streams may + //do NOT reset buffering flag, because RESET scene called only + //for the stream owning the clock, and other streams may //have signaled buffering on this clock ck->init_time = 0; ck->StartTime = 0; @@ -208,7 +208,7 @@ void gf_clock_resume(GF_Clock *ck) assert(!ck->Buffering); } ck->Paused -= 1; - if (!ck->Paused) + if (!ck->Paused) ck->StartTime += gf_term_get_time(ck->term) - ck->PauseTime; gf_mx_v(ck->mx); } @@ -223,7 +223,12 @@ u32 gf_clock_real_time(GF_Clock *ck) #ifdef GPAC_FIXED_POINT time = ck->discontinuity_time + ck->init_time + (time - ck->StartTime) * FIX2INT(100*ck->speed) / 100; #else - time = ck->discontinuity_time + ck->init_time + (u32) (ck->speed * (time - ck->StartTime) ); + if ((ck->speed < 0) && ((s32) ck->init_time < (-ck->speed) * (time - ck->StartTime))) { + time = 0; + } + else { + time = ck->discontinuity_time + (u32) ( ck->init_time + ck->speed * (time - ck->StartTime) ); + } #endif return time; } @@ -302,6 +307,9 @@ void gf_clock_discontinuity(GF_Clock *ck, GF_Scene *scene, Bool is_pcr_discontin } j=0; while ((odm = (GF_ObjectManager*)gf_list_enum(scene->resources, &j))) { + if (odm->state==GF_ODM_STATE_STOP) + continue; + i=0; while ((ch = (GF_Channel*)gf_list_enum(odm->channels, &i))) { if (ch->clock == ck) { @@ -318,8 +326,7 @@ void gf_clock_discontinuity(GF_Clock *ck, GF_Scene *scene, Bool is_pcr_discontin gf_es_reset_buffers(ch); ch->IsClockInit = 0; - gf_term_lock_codec(odm->codec, GF_FALSE, GF_FALSE); - + GF_LOG(GF_LOG_WARNING, GF_LOG_SYNC, ("[SyncLayer] Reinitializing timing for ES%d\n", ch->esd->ESID)); } diff --git a/src/terminal/decoder.c b/src/terminal/decoder.c index de45583..81fd459 100644 --- a/src/terminal/decoder.c +++ b/src/terminal/decoder.c @@ -74,11 +74,12 @@ GF_Codec *gf_codec_new(GF_ObjectManager *odm, GF_ESD *base_layer, s32 PL, GF_Err } /*remember codec type*/ tmp->type = base_layer->decoderConfig->streamType; + tmp->oti = base_layer->decoderConfig->objectTypeIndication; tmp->inChannels = gf_list_new(); tmp->Status = GF_ESM_CODEC_STOP; if (tmp->type==GF_STREAM_PRIVATE_MEDIA) tmp->type = GF_STREAM_VISUAL; - + if (tmp->type==GF_STREAM_VISUAL) { GF_CodecCapability cap; cap.CapCode = GF_CODEC_DISPLAY_BPP; @@ -185,6 +186,8 @@ GF_Err gf_codec_add_channel(GF_Codec *codec, GF_Channel *ch) cap.cap.valueInt = 1; gf_codec_get_capability(codec, &cap); max = cap.cap.valueInt; + //this may happen in sysetm bench mode since we dont configure codecs + if (!max) max = 1; break; case GF_STREAM_ND_SUBPIC: max = 1; @@ -209,7 +212,7 @@ GF_Err gf_codec_add_channel(GF_Codec *codec, GF_Channel *ch) max = 1; no_alloc = 1; } - //very low latency + //very low latency else if (ch->MaxBuffer<=300) { // max /= MAX(max/2, 2); } @@ -232,7 +235,7 @@ GF_Err gf_codec_add_channel(GF_Codec *codec, GF_Channel *ch) cap.CapCode = GF_CODEC_TRUSTED_CTS; if (gf_codec_get_capability(codec, &cap) == GF_OK) codec->trusted_cts = cap.cap.valueInt; - + } if (codec->flags & GF_ESM_CODEC_IS_RAW_MEDIA) { @@ -271,7 +274,7 @@ GF_Err gf_codec_add_channel(GF_Codec *codec, GF_Channel *ch) break; } } - + } } else if (codec->flags & GF_ESM_CODEC_IS_RAW_MEDIA) { cap.CapCode = GF_CODEC_OUTPUT_SIZE; @@ -330,7 +333,7 @@ Bool gf_codec_is_scene_or_image(GF_Codec *codec) Bool gf_codec_remove_channel(GF_Codec *codec, struct _es_channel *ch) { - s32 i; + s32 i; assert( codec ); assert( codec->inChannels); assert(ch); @@ -352,12 +355,19 @@ static void codec_update_stats(GF_Codec *codec, u32 dataLength, u64 dec_time, u3 { codec->total_dec_time += dec_time; codec->last_frame_time = gf_sys_clock(); - if (!codec->nb_dec_frames) + if (!codec->nb_dec_frames) { codec->first_frame_time = codec->last_frame_time; + codec->min_frame_dur = 0; + } codec->nb_dec_frames++; if (dec_time>codec->max_dec_time) codec->max_dec_time = dec_time; + + if (DTS - codec->last_unit_dts > codec->min_frame_dur) { + codec->min_frame_dur = DTS - codec->last_unit_dts; + } + if (dataLength) { if (codec->last_stat_start + 2000 <= DTS) { if (!codec->cur_bit_size) { @@ -383,7 +393,9 @@ static void MediaDecoder_GetNextAU(GF_Codec *codec, GF_Channel **activeChannel, GF_DBUnit *AU; GF_List *src_channels = codec->inChannels; GF_ObjectManager *current_odm = codec->odm; - u32 count, curCTS, i; + u32 count, curCTS, i, stream_state; + Bool scalable_check = 0; + s32 cts_diff; *nextAU = NULL; *activeChannel = NULL; @@ -395,7 +407,7 @@ browse_scalable: if (!count) return; /*browse from base to top layer*/ - for (i=0;itype==GF_STREAM_OCR) && ch->IsClockInit) { @@ -407,12 +419,29 @@ browse_scalable: return; } refetch_AU: + stream_state = ch->stream_state; AU = gf_es_get_au(ch); if (!AU) { + if (scalable_check==1) { + if (*nextAU && ((*nextAU)->flags & GF_DB_AU_REAGGREGATED)) { + scalable_check=2; + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Warning, No AU in enhancement layer for this AU\n")); + } + } if (! (*activeChannel)) *activeChannel = ch; + /*we have received the first AU of enhencement layer, wait for a moment for aggregation + if (ch->AU_buffer_first && (ch->esd->dependsOnESID == (*activeChannel)->esd->ESID)) { + *nextAU = NULL; + return; + }*/ continue; } + cts_diff = AU->CTS; + cts_diff -= curCTS; + if (cts_diff < 0) cts_diff = -cts_diff; + /*aggregate all AUs with the same timestamp on the base AU and delete the upper layers)*/ if (! *nextAU) { if (ch->esd->dependsOnESID) { @@ -423,19 +452,29 @@ refetch_AU: *nextAU = AU; *activeChannel = ch; curCTS = AU->CTS; - } else if (AU->CTS == curCTS) { + } + //we allow for +/- 1ms drift due to timestamp rounding when converting to milliseconds units + else if (cts_diff<=1) { GF_DBUnit *baseAU = *nextAU; assert(baseAU); - - baseAU->data = gf_realloc(baseAU->data, baseAU->dataLength + AU->dataLength); - memcpy(baseAU->data + baseAU->dataLength , AU->data, AU->dataLength); + if ((*activeChannel)->is_pulling && !(baseAU->flags & GF_DB_AU_REAGGREGATED)) { + char *base_au = baseAU->data; + baseAU->data = gf_malloc(baseAU->dataLength + AU->dataLength); + memcpy(baseAU->data, base_au, baseAU->dataLength); + memcpy(baseAU->data + baseAU->dataLength , AU->data, AU->dataLength); + } else { + baseAU->data = gf_realloc(baseAU->data, baseAU->dataLength + AU->dataLength); + memcpy(baseAU->data + baseAU->dataLength , AU->data, AU->dataLength); + } baseAU->dataLength += AU->dataLength; GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] ODM%d#CH%d (%s) AU DTS %d reaggregated on base layer %d\n", codec->decio->module_name, codec->odm->OD->objectDescriptorID, ch->esd->ESID, ch->odm->net_service->url, AU->DTS, (*activeChannel)->esd->ESID)); gf_es_drop_au(ch); ch->first_au_fetched = 1; + scalable_check = 2; + (*nextAU)->flags |= GF_DB_AU_REAGGREGATED; } //not the same TS for base and enhancement - either temporal scalability is used or we had a frame loss - else { + else { //we cannot rely on DTS - to check if this is temporal scalability, check next CTS if (ch->recompute_dts) { Bool au_match_base_ts = GF_FALSE; @@ -450,7 +489,7 @@ refetch_AU: } //no AU found with the same CTS as the current base, we likely had a drop in the enhancement - aggregate from base if (!au_match_base_ts) { - } + } // AU found with the same CTS as the current base, we either had a drop on the base or some temporal scalability - aggregate from current channel. else { //we cannot tell whether this is a loss or temporal scalable, don't attempt to discard the AU @@ -463,12 +502,16 @@ refetch_AU: //we can rely on DTS - if DTS is earlier on the enhencement, this is a loss or temporal scalability else if (AU->DTS < (*nextAU)->DTS) { //Sample with the same DTS of this AU has been decoded. This is a loss, we need to drop it and re-fetch this channel - if (AU->DTS <= codec->last_unit_dts) - { + if ((AU->DTS <= codec->last_unit_dts) + //we also prevent detecting temporal scalability until at least one frame from the base has been decoded + || !codec->first_frame_processed) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] ODM%d#CH%d %s AU DTS %d but base DTS %d: loss detected - re-fetch channel\n", codec->decio->module_name, codec->odm->OD->objectDescriptorID, ch->esd->ESID, ch->odm->net_service->url, AU->DTS, (*nextAU)->DTS)); gf_es_drop_au(ch); + //restore stream state in case we got a RAP this time but we discard the AU, we need to wait again for the next RAP with the right timing + ch->stream_state = stream_state; + goto refetch_AU; - } + } //This is a temporal scalability so we re-aggregate from the enhencement else { GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] ODM%d#CH%d (%s) AU DTS %d selected as first layer (CTS %d)\n", codec->decio->module_name, codec->odm->OD->objectDescriptorID, ch->esd->ESID, ch->odm->net_service->url, AU->DTS, AU->CTS)); @@ -476,16 +519,30 @@ refetch_AU: *activeChannel = ch; curCTS = AU->CTS; } + } else { + if ((*nextAU)->flags & GF_DB_AU_REAGGREGATED) { + scalable_check = 2; + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("AU in enhancement layer DTS %d - CTS %d too early for this AU\n", AU->DTS, AU->CTS)); + } } } } //scalable addon, browse channels in scalable object if (current_odm->scalable_odm) { + if (*nextAU) { + gf_scene_check_addon_restart(current_odm->scalable_odm->parentscene->root_od->addon, (*nextAU)->CTS, (*nextAU)->DTS); + } current_odm = current_odm->scalable_odm; src_channels = current_odm->channels; + scalable_check = 1; goto browse_scalable; } + if (scalable_check==1) { + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Warning, could not find enhancement layer for this AU\n")); + } + if (codec->is_reordering && *nextAU && codec->first_frame_dispatched) { if ((*activeChannel)->esd->slConfig->no_dts_signaling) { u32 CTS = (*nextAU)->CTS; @@ -496,11 +553,11 @@ refetch_AU: diff = codec->recomputed_cts - CTS; } - prev_ts_diff = (CTS > codec->last_unit_cts) ? (CTS - codec->last_unit_cts) : (codec->last_unit_cts - CTS); + prev_ts_diff = (CTS > codec->last_unit_cts) ? (CTS - codec->last_unit_cts) : (codec->last_unit_cts - CTS); if (!diff) diff = prev_ts_diff; else if (prev_ts_diff && (prev_ts_diff < diff) ) diff = prev_ts_diff; - if (!codec->min_au_duration || (diff < codec->min_au_duration)) + if (!codec->min_au_duration || (diff < codec->min_au_duration)) codec->min_au_duration = diff; } else { codec->min_au_duration = 0; @@ -525,7 +582,7 @@ static void Decoder_GetNextAU(GF_Codec *codec, GF_Channel **activeChannel, GF_DB minDTS = 0; /*reverse browsing to make sure we fill enhancement before base layer*/ - for (i=count;i>0;i--) { + for (i=count; i>0; i--) { ch = (GF_Channel*)gf_list_get(codec->inChannels, i-1); if ((codec->type==GF_STREAM_OCR) && ch->IsClockInit) { @@ -652,7 +709,7 @@ check_unit: /*lock scene*/ if (!scene_locked) { scene_locked = codec->odm->subscene ? codec->odm->subscene : codec->odm->parentscene; - if (!gf_mx_try_lock(scene_locked->root_od->term->compositor->mx)) + if (!gf_mx_try_lock(scene_locked->root_od->term->compositor->mx)) return GF_OK; /*if terminal is paused, force step-mode: it won't hurt in regular pause/play and ensures proper frame dumping*/ if (codec->odm->term->play_state) codec->odm->term->compositor->step_mode=1; @@ -760,13 +817,13 @@ static GF_Err PrivateScene_Process(GF_Codec *codec, u32 TimeAvailable) if (!gf_mx_try_lock(scene_locked->root_od->term->compositor->mx)) return GF_OK; - now = gf_sys_clock_high_res(); + now = gf_sys_clock_high_res(); if (codec->odm->term->bench_mode == 2) { e = GF_OK; } else { e = sdec->ProcessData(sdec, NULL, 0, ch->esd->ESID, codec->odm->current_time, GF_CODEC_LEVEL_NORMAL); } - now = gf_sys_clock_high_res() - now; + now = gf_sys_clock_high_res() - now; codec->last_unit_dts ++; /*resume on error*/ if (e && (codec->last_unit_dts<2) ) { @@ -862,7 +919,7 @@ GF_Err gf_codec_resize_composition_buffer(GF_Codec *dec, u32 NewSize) dec->CB->Min = unit_count/3; if (!dec->CB->Min) dec->CB->Min = 1; } - if ((dec->type==GF_STREAM_VISUAL) && dec->odm->parentscene->is_dynamic_scene) { + if ((dec->type==GF_STREAM_VISUAL) && dec->odm->parentscene->is_dynamic_scene && !dec->odm->parentscene->root_od->addon) { gf_scene_force_size_to_video(dec->odm->parentscene, dec->odm->mo); } return GF_OK; @@ -892,7 +949,7 @@ static GF_Err MediaCodec_Process(GF_Codec *codec, u32 TimeAvailable) } entryTime = gf_sys_clock_high_res(); - if (!codec->odm->term->bench_mode && (codec->odm->term->flags & GF_TERM_DROP_LATE_FRAMES)) + if (!codec->odm->term->bench_mode && (codec->odm->term->flags & GF_TERM_DROP_LATE_FRAMES)) drop_late_frames = 1; @@ -973,10 +1030,11 @@ static GF_Err MediaCodec_Process(GF_Codec *codec, u32 TimeAvailable) } + TimeAvailable*=1000; /*try to refill the full buffer*/ first = 1; while (codec->CB->Capacity > codec->CB->UnitCount) { - /*set media processing level*/ + /*set media processing level*/ ch->last_au_was_seek = 0; mmlevel = GF_CODEC_LEVEL_NORMAL; /*SEEK: if the last frame had the same TS, we are seeking. Ask the codec to drop*/ @@ -986,9 +1044,9 @@ static GF_Err MediaCodec_Process(GF_Codec *codec, u32 TimeAvailable) /*object clock is paused by media control or terminal is paused: exact frame seek*/ if ( #ifndef GPAC_DISABLE_VRML - (codec->ck->mc && codec->ck->mc->paused) || + (codec->ck->mc && codec->ck->mc->paused) || #endif - (codec->odm->term->play_state) + (codec->odm->term->play_state) ) { gf_cm_rewind_input(codec->CB); mmlevel = GF_CODEC_LEVEL_NORMAL; @@ -997,7 +1055,7 @@ static GF_Err MediaCodec_Process(GF_Codec *codec, u32 TimeAvailable) } } /*only perform drop in normal playback*/ - else if (codec->CB->Status == CB_PLAY) { + else if ((codec->ck->speed>0) && (codec->CB->Status == CB_PLAY)) { /*extremely late, set the level to drop NOTE: the 100 ms safety gard is to avoid discarding audio*/ if (!ch->skip_sl && (AU->CTS + (codec->is_reordering ? 1000 : 100) < obj_time) ) { @@ -1081,9 +1139,9 @@ scalable_retry: if (drop_late_frames) { unit_size = 0; codec->nb_droped++; - } else + } else ch->clock->last_TS_rendered = codec->CB->LastRenderedTS; - } + } e = UnlockCompositionUnit(codec, CU, unit_size); GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] ODM%d ES%d at %d decoded packed frame TS %d in "LLU" us\n", codec->decio->module_name, codec->odm->OD->objectDescriptorID, ch->esd->ESID, gf_clock_real_time(ch->clock), AU->CTS, now)); @@ -1198,9 +1256,9 @@ scalable_retry: if (drop_late_frames || (mmlevel == GF_CODEC_LEVEL_SEEK) ) { unit_size = 0; if (drop_late_frames) codec->nb_droped++; - } else + } else ch->clock->last_TS_rendered = codec->CB->LastRenderedTS; - } + } UnlockCompositionUnit(codec, CU, unit_size); if (!ch || !AU) { @@ -1211,11 +1269,11 @@ scalable_retry: /*escape from decoding loop only if above critical limit - this is to avoid starvation on audio*/ if (!ch->esd->dependsOnESID && (codec->CB->UnitCount > codec->CB->Min)) { if (now >= TimeAvailable) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] Exit decode loop because time is up: %d vs %d available\n", codec->decio->module_name, now, TimeAvailable)); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] Exit decode loop because time is up: %d vs %d us available\n", codec->decio->module_name, now, TimeAvailable)); return GF_OK; } - } else if (now >= 10000*TimeAvailable) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] Exit decode loop because running for too long: %d vs %d available\n", codec->decio->module_name, now/1000, TimeAvailable)); + } else if (now >= TimeAvailable) { + GF_LOG(GF_LOG_DEBUG, GF_LOG_CODEC, ("[%s] Exit decode loop because running for too long: %d vs %d us available\n", codec->decio->module_name, now, TimeAvailable)); return GF_OK; } else if (codec->odm->term->bench_mode) { return GF_OK; @@ -1227,7 +1285,7 @@ scalable_retry: GF_Err gf_codec_process_private_media(GF_Codec *codec, u32 TimeAvailable) { - + if (codec->ck && codec->ck->Paused) { u32 i; for (i=0; iodm->channels); i++) { @@ -1237,7 +1295,7 @@ GF_Err gf_codec_process_private_media(GF_Codec *codec, u32 TimeAvailable) gf_clock_buffer_off(ch->clock); } } - if (codec->CB) + if (codec->CB) gf_cm_abort_buffering(codec->CB); } return GF_OK; @@ -1257,7 +1315,7 @@ GF_Err gf_codec_process_raw_media_pull(GF_Codec *codec, u32 TimeAvailable) gf_clock_buffer_off(ch->clock); } } - if (codec->CB) + if (codec->CB) gf_cm_abort_buffering(codec->CB); } @@ -1329,7 +1387,7 @@ GF_Err gf_codec_get_capability(GF_Codec *codec, GF_CodecCapability *cap) h = gf_bs_read_u16(bs); out_size = gf_bs_read_u32(bs); stride = gf_bs_read_u32(bs); - is_flipped = gf_bs_read_u8(bs); + is_flipped = gf_bs_read_u8(bs); } else { sr = gf_bs_read_u32(bs); nb_ch = gf_bs_read_u16(bs); @@ -1351,9 +1409,9 @@ GF_Err gf_codec_get_capability(GF_Codec *codec, GF_CodecCapability *cap) case GF_CODEC_PIXEL_FORMAT: cap->cap.valueInt = pf; return GF_OK; - case GF_CODEC_FLIP: - cap->cap.valueInt = is_flipped; - return GF_OK; + case GF_CODEC_FLIP: + cap->cap.valueInt = is_flipped; + return GF_OK; case GF_CODEC_OUTPUT_SIZE: cap->cap.valueInt = out_size; return GF_OK; @@ -1451,17 +1509,17 @@ static GF_Err Codec_LoadModule(GF_Codec *codec, GF_ESD *esd, u32 PL) case GF_STREAM_VISUAL: case GF_STREAM_ND_SUBPIC: ifce_type = GF_MEDIA_DECODER_INTERFACE; - codec->process = MediaCodec_Process; + codec->process = MediaCodec_Process; break; case GF_STREAM_PRIVATE_MEDIA: ifce_type = GF_PRIVATE_MEDIA_DECODER_INTERFACE; - codec->process = gf_codec_process_private_media; + codec->process = gf_codec_process_private_media; break; case GF_STREAM_PRIVATE_SCENE: ifce_type = GF_SCENE_DECODER_INTERFACE; codec->process = PrivateScene_Process; break; - default: + default: ifce_type = GF_SCENE_DECODER_INTERFACE; codec->process = SystemCodec_Process; if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_SCENE_AFX) { @@ -1555,7 +1613,7 @@ static GF_Err Codec_LoadModule(GF_Codec *codec, GF_ESD *esd, u32 PL) ifce = (GF_BaseDecoder *) gf_modules_load_interface(term->user->modules, i, ifce_type); if (!ifce) continue; if (ifce->CanHandleStream) { - u32 conf = ifce->CanHandleStream(ifce, esd->decoderConfig->streamType, esd, PL); + u32 conf = ifce->CanHandleStream(ifce, esd->decoderConfig->streamType, esd, PL); if ((conf!=GF_CODEC_NOT_SUPPORTED) && (conf>dec_confidence)) { /*switch*/ @@ -1601,7 +1659,7 @@ GF_Err Codec_Load(GF_Codec *codec, GF_ESD *esd, u32 PL) case GF_STREAM_AUDIO: if (!esd->decoderConfig->objectTypeIndication) return GF_NON_COMPLIANT_BITSTREAM; - + if (esd->decoderConfig->objectTypeIndication==GPAC_OTI_RAW_MEDIA_STREAM) { codec->flags |= GF_ESM_CODEC_IS_RAW_MEDIA; codec->process = gf_codec_process_private_media; @@ -1616,12 +1674,12 @@ GF_Err Codec_Load(GF_Codec *codec, GF_ESD *esd, u32 PL) void gf_codec_del(GF_Codec *codec) { if (!codec || !codec->inChannels) - return; + return; if (gf_list_count(codec->inChannels)) return; if (!(codec->flags & GF_ESM_CODEC_IS_USE)) { switch (codec->type) { - /*input sensor streams are handled internally for now*/ + /*input sensor streams are handled internally for now*/ #ifndef GPAC_DISABLE_VRML case GF_STREAM_INTERACT: gf_mx_p(codec->odm->term->net_mx); diff --git a/src/terminal/input_sensor.c b/src/terminal/input_sensor.c index ca053a0..f0b5bd6 100644 --- a/src/terminal/input_sensor.c +++ b/src/terminal/input_sensor.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -91,7 +91,7 @@ static void isdev_dispatch_frame(struct __input_device *dev, u8 *data, u32 data_ slh.accessUnitStartFlag = slh.accessUnitEndFlag = 1; slh.compositionTimeStampFlag = 1; /*note we could use an exact TS but it's not needed: since the input is generated locally - we want it to be decoded as soon as possible, thus using 0 emulates permanent seeking on + we want it to be decoded as soon as possible, thus using 0 emulates permanent seeking on InputSensor stream, hence forces input frame resync*/ slh.compositionTimeStamp = 0; @@ -206,8 +206,8 @@ static GF_Err IS_SetCapabilities(GF_BaseDecoder *plug, const GF_CodecCapability return GF_OK; } -static GF_Err IS_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, - u16 ES_ID, u32 AU_time, u32 mmlevel) +static GF_Err IS_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, + u16 ES_ID, u32 AU_time, u32 mmlevel) { u32 i, j, count; Double scene_time; @@ -226,10 +226,18 @@ static GF_Err IS_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 in /*parse val ourselves (we don't want to depend on bifs codec)*/ if (field->eventType) { switch (field->fieldType) { - case GF_SG_VRML_SFBOOL: * ((SFBool *) field->far_ptr) = (SFBool) gf_bs_read_int(bs, 1); break; - case GF_SG_VRML_SFFLOAT: *((SFFloat *)field->far_ptr) = FLT2FIX( gf_bs_read_float(bs) ); break; - case GF_SG_VRML_SFINT32: *((SFInt32 *)field->far_ptr) = (s32) gf_bs_read_int(bs, 32); break; - case GF_SG_VRML_SFTIME: *((SFTime *)field->far_ptr) = gf_bs_read_double(bs); break; + case GF_SG_VRML_SFBOOL: + * ((SFBool *) field->far_ptr) = (SFBool) gf_bs_read_int(bs, 1); + break; + case GF_SG_VRML_SFFLOAT: + *((SFFloat *)field->far_ptr) = FLT2FIX( gf_bs_read_float(bs) ); + break; + case GF_SG_VRML_SFINT32: + *((SFInt32 *)field->far_ptr) = (s32) gf_bs_read_int(bs, 32); + break; + case GF_SG_VRML_SFTIME: + *((SFTime *)field->far_ptr) = gf_bs_read_double(bs); + break; case GF_SG_VRML_SFVEC2F: ((SFVec2f *)field->far_ptr)->x = FLT2FIX( gf_bs_read_float(bs) ); ((SFVec2f *)field->far_ptr)->y = FLT2FIX( gf_bs_read_float(bs) ); @@ -263,10 +271,10 @@ static GF_Err IS_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 in ((SFString *)field->far_ptr)->buffer = (char*)gf_malloc(sizeof(char)*(length+1)); memset(((SFString *)field->far_ptr)->buffer , 0, length+1); for (j=0; jfar_ptr)->buffer[j] = gf_bs_read_int(bs, 8); + ((SFString *)field->far_ptr)->buffer[j] = gf_bs_read_int(bs, 8); } } - break; + break; } } } @@ -367,7 +375,7 @@ GF_BaseDecoder *gf_isdec_new(GF_ESD *esd, u32 PL) { ISPriv *priv; GF_SceneDecoder *tmp; - + tmp = (GF_SceneDecoder*) gf_malloc(sizeof(GF_SceneDecoder)); if (!tmp) return NULL; memset(tmp, 0, sizeof(GF_SceneDecoder)); @@ -402,7 +410,7 @@ static void IS_Unregister(GF_Node *node, ISStack *st) ISPriv *is_dec; gf_mo_unregister(node, st->mo); - + odm = st->mo->odm; if (!odm) return; @@ -496,12 +504,12 @@ void InputSensorModified(GF_Node *node) ISStack *st = (ISStack *)gf_node_get_private(node); mo = gf_mo_register(node, &st->is->url, 0, 0); - if ((mo!=st->mo) || !st->registered){ + if ((mo!=st->mo) || !st->registered) { if (mo!=st->mo) { if (st->mo) IS_Unregister(node, st); st->mo = mo; } - if (st->is->enabled) + if (st->is->enabled) IS_Register(node); else return; @@ -547,9 +555,13 @@ void gf_term_mouse_input(GF_Terminal *term, GF_EventMouse *event) else if (event->button==GF_MOUSE_MIDDLE) middle_but_down = 1; else if (event->button==GF_MOUSE_LEFT) left_but_down = 1; break; - case GF_EVENT_MOUSEWHEEL: wheel_pos = event->wheel_pos; break; - case GF_EVENT_MOUSEMOVE: break; - default: return; + case GF_EVENT_MOUSEWHEEL: + wheel_pos = event->wheel_pos; + break; + case GF_EVENT_MOUSEMOVE: + break; + default: + return; } /*get BIFS coordinates*/ @@ -588,7 +600,7 @@ void gf_term_mouse_input(GF_Terminal *term, GF_EventMouse *event) slh.accessUnitStartFlag = slh.accessUnitEndFlag = 1; slh.compositionTimeStampFlag = 1; /*note we could use an exact TS but it's not needed: since the input is generated locally - we want it to be decoded as soon as possible, thus using 0 emulates permanent seeking on + we want it to be decoded as soon as possible, thus using 0 emulates permanent seeking on InputSensor stream, hence forces input frame resync*/ slh.compositionTimeStamp = 0; @@ -633,26 +645,66 @@ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool i keyPressed = keyReleased = actionKeyPressed = actionKeyReleased = 0; /*key-sensor codes*/ switch (key_code) { - case GF_KEY_F1: actionKey = 1; break; - case GF_KEY_F2: actionKey = 2; break; - case GF_KEY_F3: actionKey = 3; break; - case GF_KEY_F4: actionKey = 4; break; - case GF_KEY_F5: actionKey = 5; break; - case GF_KEY_F6: actionKey = 6; break; - case GF_KEY_F7: actionKey = 7; break; - case GF_KEY_F8: actionKey = 8; break; - case GF_KEY_F9: actionKey = 9; break; - case GF_KEY_F10: actionKey = 10; break; - case GF_KEY_F11: actionKey = 11; break; - case GF_KEY_F12: actionKey = 12; break; - case GF_KEY_HOME: actionKey = 13; break; - case GF_KEY_END: actionKey = 14; break; - case GF_KEY_PAGEUP: actionKey = 15; break; - case GF_KEY_PAGEDOWN: actionKey = 16; break; - case GF_KEY_UP: actionKey = 17; break; - case GF_KEY_DOWN: actionKey = 18; break; - case GF_KEY_LEFT: actionKey = 19; break; - case GF_KEY_RIGHT: actionKey = 20; break; + case GF_KEY_F1: + actionKey = 1; + break; + case GF_KEY_F2: + actionKey = 2; + break; + case GF_KEY_F3: + actionKey = 3; + break; + case GF_KEY_F4: + actionKey = 4; + break; + case GF_KEY_F5: + actionKey = 5; + break; + case GF_KEY_F6: + actionKey = 6; + break; + case GF_KEY_F7: + actionKey = 7; + break; + case GF_KEY_F8: + actionKey = 8; + break; + case GF_KEY_F9: + actionKey = 9; + break; + case GF_KEY_F10: + actionKey = 10; + break; + case GF_KEY_F11: + actionKey = 11; + break; + case GF_KEY_F12: + actionKey = 12; + break; + case GF_KEY_HOME: + actionKey = 13; + break; + case GF_KEY_END: + actionKey = 14; + break; + case GF_KEY_PAGEUP: + actionKey = 15; + break; + case GF_KEY_PAGEDOWN: + actionKey = 16; + break; + case GF_KEY_UP: + actionKey = 17; + break; + case GF_KEY_DOWN: + actionKey = 18; + break; + case GF_KEY_LEFT: + actionKey = 19; + break; + case GF_KEY_RIGHT: + actionKey = 20; + break; case GF_KEY_SHIFT: actionKey = 0; shiftKeyDown = isKeyUp ? 1 : 2; @@ -666,38 +718,40 @@ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool i altKeyDown = isKeyUp ? 1 : 2; break; - default: actionKey = 0; break; + default: + actionKey = 0; + break; } if (actionKey) { - if (isKeyUp) + if (isKeyUp) actionKeyReleased = actionKey; - else + else actionKeyPressed = actionKey; } else { /*handle numeric pad*/ if ((key_code>=GF_KEY_0) && (key_code<=GF_KEY_9) ) { key_code = key_code + 0x30 - GF_KEY_0; - } - else + } + else key_code = hw_code; if (isKeyUp) keyReleased = key_code; else keyPressed = key_code; } - gf_bs_write_int(bs, keyPressed ? 1 : 0, 1); + gf_bs_write_int(bs, keyPressed ? 1 : 0, 1); if (keyPressed) gf_bs_write_int(bs, keyPressed, 32); - gf_bs_write_int(bs, keyReleased ? 1 : 0, 1); + gf_bs_write_int(bs, keyReleased ? 1 : 0, 1); if (keyReleased) gf_bs_write_int(bs, keyReleased, 32); - gf_bs_write_int(bs, actionKeyPressed ? 1 : 0, 1); + gf_bs_write_int(bs, actionKeyPressed ? 1 : 0, 1); if (actionKeyPressed) gf_bs_write_int(bs, actionKeyPressed, 32); - gf_bs_write_int(bs, actionKeyReleased ? 1 : 0, 1); + gf_bs_write_int(bs, actionKeyReleased ? 1 : 0, 1); if (actionKeyReleased) gf_bs_write_int(bs, actionKeyReleased, 32); - gf_bs_write_int(bs, shiftKeyDown ? 1 : 0 , 1); + gf_bs_write_int(bs, shiftKeyDown ? 1 : 0 , 1); if (shiftKeyDown) gf_bs_write_int(bs, shiftKeyDown-1, 1); - gf_bs_write_int(bs, controlKeyDown ? 1 : 0 , 1); + gf_bs_write_int(bs, controlKeyDown ? 1 : 0 , 1); if (controlKeyDown) gf_bs_write_int(bs, controlKeyDown-1, 1); - gf_bs_write_int(bs, altKeyDown ? 1 : 0 , 1); + gf_bs_write_int(bs, altKeyDown ? 1 : 0 , 1); if (altKeyDown) gf_bs_write_int(bs, altKeyDown, 1); gf_bs_align(bs); @@ -716,7 +770,7 @@ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool i } } gf_free(buf); - + #ifndef GPAC_DISABLE_X3D i=0; while ((n = (X_KeySensor*)gf_list_enum(term->x3d_sensors, &i))) { @@ -729,7 +783,8 @@ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool i if (keyPressed) { if (n->keyPress.buffer) gf_free(n->keyPress.buffer); - tc[0] = keyPressed; tc[1] = 0; + tc[0] = keyPressed; + tc[1] = 0; ptr = tc; len = (u32) gf_utf8_wcstombs(szStr, 10, &ptr); n->keyPress.buffer = (char*)gf_malloc(sizeof(char) * (len+1)); @@ -739,7 +794,8 @@ Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool i } if (keyReleased) { if (n->keyRelease.buffer) gf_free(n->keyRelease.buffer); - tc[0] = keyReleased; tc[1] = 0; + tc[0] = keyReleased; + tc[1] = 0; ptr = tc; len = (u32) gf_utf8_wcstombs(szStr, 10, &ptr); n->keyRelease.buffer = (char*)gf_malloc(sizeof(char) * (len+1)); @@ -820,10 +876,10 @@ void gf_term_string_input(GF_Terminal *term, u32 character) gf_bs_align(bs); gf_bs_get_content(bs, &buf, &buf_size); gf_bs_del(bs); - + // gf_es_receive_sl_packet(ch->service, ch, buf, buf_size, &slh, GF_OK); IS_ProcessData((GF_SceneDecoder*)cod->decio, buf, buf_size, 0, 0, 0); - + gf_free(buf); } } @@ -915,8 +971,9 @@ void InitStringSensor(GF_Scene *scene, GF_Node *node) void gf_term_mouse_input(GF_Terminal *term, GF_EventMouse *event) { } -void gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool isKeyUp) +Bool gf_term_keyboard_input(GF_Terminal *term, u32 key_code, u32 hw_code, Bool isKeyUp) { + return GF_TRUE; } void gf_term_string_input(GF_Terminal *term, u32 character) { diff --git a/src/terminal/input_sensor.h b/src/terminal/input_sensor.h index 7333654..4e5c21e 100644 --- a/src/terminal/input_sensor.h +++ b/src/terminal/input_sensor.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ diff --git a/src/terminal/media_control.c b/src/terminal/media_control.c index 2612298..fb1b87d 100644 --- a/src/terminal/media_control.c +++ b/src/terminal/media_control.c @@ -11,21 +11,22 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "media_control.h" #include +#include void mediacontrol_restart(GF_ObjectManager *odm) @@ -115,7 +116,7 @@ Bool MC_URLChanged(MFURL *old_url, MFURL *new_url) u32 i; if (gf_mo_get_od_id(old_url) != gf_mo_get_od_id(new_url)) return 1; if (old_url->count != new_url->count) return 1; - + for (i=0; icount; i++) { if (old_url->vals[i].url || new_url->vals[i].url) { if (!old_url->vals[i].url || !new_url->vals[i].url) return 1; @@ -236,7 +237,7 @@ void MC_GetRange(MediaControlStack *ctrl, Double *start_range, Double *end_range prev_seg = desc; last_seg = NULL; duration = desc->Duration; - i=1+ctrl->current_seg; + i=1+ctrl->current_seg; while ((last_seg = (GF_Segment *)gf_list_enum(ctrl->seg, &i))) { if (prev_seg->startTime + prev_seg->Duration != last_seg->startTime) { last_seg = NULL; @@ -268,6 +269,7 @@ void RenderMediaControl(GF_Node *node, void *rs, Bool is_destroy) Bool shall_restart, need_restart; GF_MediaObject *prev; GF_ObjectManager *odm; + GF_TraverseState *tr_state = (GF_TraverseState *)rs; MediaControlStack *stack =(MediaControlStack *) gf_node_get_private(node); if (is_destroy) { @@ -288,20 +290,22 @@ void RenderMediaControl(GF_Node *node, void *rs, Bool is_destroy) gf_free(stack); return; } + //we need to disable culling otherwise we may never be called back again ... + tr_state->disable_cull = 1; /*not changed nothing to do - note we need to register with stream yet for control switching...*/ if (stack->stream && (!stack->changed || !stack->control->enabled)) return; need_restart = (stack->changed==2) ? 1 : 0; shall_restart = (stack->control->mediaStartTime>=0) ? 1 : 0; - + /*check url target*/ if (stack->stream) { if (MC_URLChanged(&stack->url, &stack->control->url)) { gf_sg_vrml_mf_reset(&stack->url, GF_SG_VRML_MFURL); prev = stack->stream; - if (gf_list_find(stack->parent->scene_objects, prev)<0) + if (gf_list_find(stack->parent->scene_objects, prev)<0) prev = NULL; stack->stream = gf_scene_get_media_object(stack->parent, &stack->control->url, GF_MEDIA_OBJECT_UNDEF, 0); @@ -318,7 +322,7 @@ void RenderMediaControl(GF_Node *node, void *rs, Bool is_destroy) /*register with new*/ /*if we assigned the media control to an exiting object - force the state of the object*/ gf_odm_set_mediacontrol((GF_ObjectManager *) stack->stream->odm, stack); - + while (gf_list_count(stack->seg)) gf_list_rem(stack->seg, 0); gf_odm_init_segments((GF_ObjectManager *) stack->stream->odm, stack->seg, &stack->control->url); @@ -333,7 +337,7 @@ void RenderMediaControl(GF_Node *node, void *rs, Bool is_destroy) } /*MediaControl has been detached*/ else { - if (prev) + if (prev) gf_odm_remove_mediacontrol(prev->odm, stack); return; } @@ -374,7 +378,7 @@ void RenderMediaControl(GF_Node *node, void *rs, Bool is_destroy) stack->enabled = 1; need_restart = gf_odm_switch_mediacontrol(stack->stream->odm, stack); } - + stack->changed = 0; if (!stack->control->mediaSpeed) shall_restart = 0; @@ -468,10 +472,10 @@ void MC_Modified(GF_Node *node) if (!stack) return; if (stack->changed!=2) { /*check URL*/ - if (MC_URLChanged(&stack->url, &stack->control->url)) + if (MC_URLChanged(&stack->url, &stack->control->url)) stack->changed = 2; /*check speed (play/pause)*/ - else if (stack->media_speed != stack->control->mediaSpeed) + else if (stack->media_speed != stack->control->mediaSpeed) stack->changed = 1; /*check mediaStartTime (seek)*/ else if (stack->media_start != stack->control->mediaStartTime) { @@ -542,7 +546,7 @@ void gf_odm_remove_mediacontrol(GF_ObjectManager *odm, MediaControlStack *ctrl) /*removed. Note the spec doesn't say what to do in this case...*/ if (odm->media_ctrl == ctrl) { /*we're about to release the media control from this object - if paused, force a resume (as if no MC was set)*/ - if (ctrl->paused) + if (ctrl->paused) mediacontrol_resume(odm); gf_odm_set_mediacontrol(odm, NULL); } @@ -603,14 +607,14 @@ Bool gf_odm_check_segment_switch(GF_ObjectManager *odm) for (i=ctrl->current_seg; iseg, i); if ( - /*if next seg start is after cur seg start*/ - (cur->startTime < next->startTime) - /*if next seg start is before cur seg end*/ - && (cur->startTime + cur->Duration > next->startTime) - /*if next seg start is already passed*/ - && (1000*next->startTime < odm->current_time) - /*then next segment was taken into account when requesting play*/ - ) { + /*if next seg start is after cur seg start*/ + (cur->startTime < next->startTime) + /*if next seg start is before cur seg end*/ + && (cur->startTime + cur->Duration > next->startTime) + /*if next seg start is already passed*/ + && (1000*next->startTime < odm->current_time) + /*then next segment was taken into account when requesting play*/ + ) { cur = next; ctrl->current_seg ++; } diff --git a/src/terminal/media_control.h b/src/terminal/media_control.h index 781d498..84cef6d 100644 --- a/src/terminal/media_control.h +++ b/src/terminal/media_control.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -54,7 +54,7 @@ typedef struct _media_control Fixed media_speed; Bool enabled; MFURL url; - + GF_Scene *parent; /*stream owner*/ GF_MediaObject *stream; diff --git a/src/terminal/media_manager.c b/src/terminal/media_manager.c index 9598962..f7c0353 100644 --- a/src/terminal/media_manager.c +++ b/src/terminal/media_manager.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -60,16 +60,17 @@ GF_Err gf_term_init_scheduler(GF_Terminal *term, u32 threading_mode) term->frame_duration = 33; switch (threading_mode) { - case GF_TERM_THREAD_SINGLE: term->flags |= GF_TERM_SINGLE_THREAD; + case GF_TERM_THREAD_SINGLE: + term->flags |= GF_TERM_SINGLE_THREAD; break; - case GF_TERM_THREAD_MULTI: + case GF_TERM_THREAD_MULTI: term->flags |= GF_TERM_MULTI_THREAD; break; default: break; } - if (term->user->init_flags & GF_TERM_NO_DECODER_THREAD) + if (term->user->init_flags & GF_TERM_NO_DECODER_THREAD) return GF_OK; term->mm_thread = gf_th_new("MediaManager"); @@ -85,7 +86,7 @@ void gf_term_stop_scheduler(GF_Terminal *term) u32 count, i; term->flags &= ~GF_TERM_RUNNING; - while (!(term->flags & GF_TERM_DEAD) ) + while (!(term->flags & GF_TERM_DEAD) ) gf_sleep(2); count = gf_list_count(term->codecs); @@ -138,9 +139,9 @@ void gf_term_add_codec(GF_Terminal *term, GF_Codec *codec) GF_SAFEALLOC(cd, CodecEntry); cd->dec = codec; - if (!cd->dec->Priority) + if (!cd->dec->Priority) cd->dec->Priority = 1; - + /*we force audio codecs to be threaded in free mode, so that we avoid waiting in the audio renderer if another decoder is locking the main mutex this can happen when the audio decoder is running late*/ if (codec->type==GF_STREAM_AUDIO) { @@ -151,7 +152,7 @@ void gf_term_add_codec(GF_Terminal *term, GF_Codec *codec) gf_codec_get_capability(codec, &cap); threaded = cap.cap.valueInt; } - + if (threaded) cd->flags |= GF_MM_CE_REQ_THREAD; @@ -160,9 +161,9 @@ void gf_term_add_codec(GF_Terminal *term, GF_Codec *codec) } else if (term->flags & GF_TERM_SINGLE_THREAD) { threaded = 0; } - if (codec->flags & GF_ESM_CODEC_IS_RAW_MEDIA) + if (codec->flags & GF_ESM_CODEC_IS_RAW_MEDIA) threaded = 0; - + if (threaded) { cd->thread = gf_th_new(cd->dec->decio->module_name); cd->mx = gf_mx_new(cd->dec->decio->module_name); @@ -276,7 +277,7 @@ static u32 MM_SimulationStep_Decoder(GF_Terminal *term, u32 *nb_active_decs) GF_Err e; u32 count, remain; u32 time_taken, time_slice, time_left; - + #ifndef GF_DISABLE_LOG term->compositor->networks_time = gf_sys_clock(); #endif @@ -368,7 +369,7 @@ u32 MM_Loop(void *par) u32 left = 0; if (do_codec) left = MM_SimulationStep_Decoder(term, &nb_decs); else left = term->frame_duration; - + if (do_scene) { u32 ms_until_next=0; u32 time_taken = gf_sys_clock(); @@ -376,7 +377,7 @@ u32 MM_Loop(void *par) time_taken = gf_sys_clock() - time_taken; if (ms_until_nextframe_duration/2) { left = 0; - } else if (left>time_taken) + } else if (left>time_taken) left -= time_taken; else left = 0; @@ -386,7 +387,7 @@ u32 MM_Loop(void *par) gf_sleep(0); } else { if (left==term->frame_duration) { - //if nothing was done during this pass but we have active decoder, just yield. We don't want to sleep since + //if nothing was done during this pass but we have active decoder, just yield. We don't want to sleep since //composition memory could be released at any time. We should have a signal here, rather than a wait gf_sleep(nb_decs ? 0 : term->frame_duration/2); } @@ -416,9 +417,9 @@ u32 RunSingleDec(void *ptr) time_taken = gf_sys_clock_high_res() - time_taken; - /*no priority boost this way for systems codecs, priority is dynamically set by not releasing the + /*no priority boost this way for systems codecs, priority is dynamically set by not releasing the graph when late and moving on*/ - if (!ce->dec->CB || (ce->dec->CB->UnitCount == ce->dec->CB->Capacity)) + if (!ce->dec->CB || (ce->dec->CB->UnitCount == ce->dec->CB->Capacity)) ce->dec->PriorityBoost = 0; /*while on don't sleep*/ @@ -433,7 +434,7 @@ u32 RunSingleDec(void *ptr) } /*NOTE: when starting/stoping a decoder we only lock the decoder mutex, NOT the media manager. This -avoids deadlocking in case a system codec waits for the scene graph and the compositor requests +avoids deadlocking in case a system codec waits for the scene graph and the compositor requests a stop/start on a media*/ void gf_term_start_codec(GF_Codec *codec, Bool is_resume) { @@ -490,7 +491,7 @@ void gf_term_stop_codec(GF_Codec *codec, Bool is_pause) if (ce->mx) gf_mx_p(ce->mx); /*We must make sure: - 1- media codecs are synchrounously stop otherwise we could destroy the composition memory while + 1- media codecs are synchrounously stop otherwise we could destroy the composition memory while the codec writes to it 2- prevent deadlock for other codecs waiting for the scene graph */ @@ -505,7 +506,7 @@ void gf_term_stop_codec(GF_Codec *codec, Bool is_pause) cap.CapCode = GF_CODEC_ABORT; cap.cap.valueInt = 0; gf_codec_set_capability(codec, cap); - + if (codec->decio && codec->odm->mo && (codec->odm->mo->flags & GF_MO_DISPLAY_REMOVE) ) { cap.CapCode = GF_CODEC_SHOW_SCENE; cap.cap.valueInt = 0; @@ -519,9 +520,10 @@ void gf_term_stop_codec(GF_Codec *codec, Bool is_pause) /*don't wait for end of thread since this can be triggered within the decoding thread*/ if (ce->flags & GF_MM_CE_RUNNING) { ce->flags &= ~GF_MM_CE_RUNNING; - if (!ce->thread) + if (!ce->thread) term->cumulated_priority -= codec->Priority+1; } + if (codec->CB) gf_cm_abort_buffering(codec->CB); if (ce->mx) gf_mx_v(ce->mx); /*cf note above*/ @@ -535,12 +537,12 @@ void gf_term_set_threading(GF_Terminal *term, u32 mode) CodecEntry *ce; switch (mode) { - case GF_TERM_THREAD_SINGLE: + case GF_TERM_THREAD_SINGLE: if (term->flags & GF_TERM_SINGLE_THREAD) return; term->flags &= ~GF_TERM_MULTI_THREAD; term->flags |= GF_TERM_SINGLE_THREAD; break; - case GF_TERM_THREAD_MULTI: + case GF_TERM_THREAD_MULTI: if (term->flags & GF_TERM_MULTI_THREAD) return; term->flags &= ~GF_TERM_SINGLE_THREAD; term->flags |= GF_TERM_MULTI_THREAD; @@ -660,7 +662,7 @@ u32 gf_term_process_step(GF_Terminal *term) if (term->flags & GF_TERM_NO_DECODER_THREAD) { MM_SimulationStep_Decoder(term, &nb_decs); - } + } if (term->flags & GF_TERM_NO_COMPOSITOR_THREAD) { u32 ms_until_next; @@ -693,7 +695,7 @@ GF_Err gf_term_process_flush(GF_Terminal *term) /*update till frame mature*/ while (1) { - + if (term->flags & GF_TERM_NO_DECODER_THREAD) { gf_term_handle_services(term); gf_mx_p(term->mm_mx); diff --git a/src/terminal/media_memory.c b/src/terminal/media_memory.c index 9b74865..358b877 100644 --- a/src/terminal/media_memory.c +++ b/src/terminal/media_memory.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -88,7 +88,7 @@ static GFINLINE void my_large_gf_free(void *ptr) { static void gf_cm_unit_del(GF_CMUnit *cb, Bool no_data_allocation) { if (!cb) - return; + return; if (cb->next) gf_cm_unit_del(cb->next, no_data_allocation); cb->next = NULL; if (cb->data) { @@ -106,7 +106,7 @@ GF_CompositionMemory *gf_cm_new(u32 UnitSize, u32 capacity, Bool no_allocation) GF_CMUnit *cu, *prev; u32 i; if (!capacity) return NULL; - + GF_SAFEALLOC(tmp, GF_CompositionMemory) tmp->Capacity = capacity; @@ -137,7 +137,7 @@ GF_CompositionMemory *gf_cm_new(u32 UnitSize, u32 capacity, Bool no_allocation) cu->next = tmp->input; tmp->input->prev = cu; - /*close the loop. The output is the input as the first item + /*close the loop. The output is the input as the first item that will be ready for composition will be filled in the input*/ tmp->output = tmp->input; @@ -153,11 +153,11 @@ void gf_cm_del(GF_CompositionMemory *cb) gf_clock_buffer_off(cb->odm->codec->ck); GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] CB destroy - ODM%d: buffering off at %d (nb buffering on clock: %d)\n", cb->odm->OD->objectDescriptorID, gf_term_get_time(cb->odm->term), cb->odm->codec->ck->Buffering)); } - if (cb->input){ - /*break the loop and destroy*/ - cb->input->prev->next = NULL; - gf_cm_unit_del(cb->input, cb->no_allocation); - cb->input = NULL; + if (cb->input) { + /*break the loop and destroy*/ + cb->input->prev->next = NULL; + gf_cm_unit_del(cb->input, cb->no_allocation); + cb->input = NULL; } gf_odm_lock(cb->odm, 0); gf_free(cb); @@ -168,7 +168,7 @@ void gf_cm_rewind_input(GF_CompositionMemory *cb) if (cb->UnitCount) { cb->UnitCount--; cb->input = cb->input->prev; - cb->input->dataLength = 0; + cb->input->dataLength = 0; } } @@ -181,7 +181,7 @@ GF_CMUnit *gf_cm_lock_input(GF_CompositionMemory *cb, u32 TS, Bool codec_reorder #endif /*there is still something in the input buffer*/ if (cb->input->dataLength) { - if (cb->input->TS==TS) + if (cb->input->TS==TS) return cb->input; return NULL; } @@ -194,7 +194,7 @@ GF_CMUnit *gf_cm_lock_input(GF_CompositionMemory *cb, u32 TS, Bool codec_reorder /*spatial scalable, go backward to fetch same TS*/ cu = cb->input; while (1) { - if (cu->TS == TS) + if (cu->TS == TS) return cu; cu = cu->prev; if (cu == cb->input) break; @@ -223,7 +223,7 @@ static void check_temporal(GF_CompositionMemory *cb) if (cu->next==cb->output) break; assert(!cu->next->dataLength || (cu->TS < cu->next->TS)); assert(!cu(>TS || (cu->TS >= cb->LastRenderedTS)); - cu = cu->next; + cu = cu->next; } } #endif @@ -270,9 +270,9 @@ static GF_CMUnit *gf_cm_reorder_unit(GF_CompositionMemory *cb, GF_CMUnit *unit, } /*previous unit is the active one - check one further*/ if (cu->prev == unit) { - if (!unit->prev->dataLength || (unit->prev->TS < unit->TS)) + if (!unit->prev->dataLength || (unit->prev->TS < unit->TS)) break; - } + } /*no previous unit or our unit is just after the previous unit*/ else if (!cu->prev->dataLength || (cu->prev->TS < unit->TS)) { break; @@ -283,10 +283,10 @@ static GF_CMUnit *gf_cm_reorder_unit(GF_CompositionMemory *cb, GF_CMUnit *unit, /*go on*/ cu = cu->prev; /*done (should never happen)*/ - if (cu == cb->input) + if (cu == cb->input) goto exit; } - + /*remove unit from the list*/ unit->prev->next = unit->next; unit->next->prev = unit->prev; @@ -297,7 +297,7 @@ static GF_CMUnit *gf_cm_reorder_unit(GF_CompositionMemory *cb, GF_CMUnit *unit, unit->next->prev = unit; unit->prev->next = unit; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("Swapping CU buffer\n")); - + exit: /*perform sanity check on output ordering*/ @@ -355,13 +355,13 @@ void gf_cm_unlock_input(GF_CompositionMemory *cb, GF_CMUnit *cu, u32 cu_size, Bo cu->dataLength = cu_size; cu->RenderedLength = 0; - /*turn off buffering for audio - this must be done now rather than when fetching first output frame since we're not + /*turn off buffering for audio - this must be done now rather than when fetching first output frame since we're not sure output is fetched (Switch node, ...)*/ if ( (cb->Status == CB_BUFFER) && (cb->UnitCount >= cb->Capacity) && (cb->odm->codec->type == GF_STREAM_AUDIO)) { /*done with buffering, signal to the clock (ONLY ONCE !)*/ cb->Status = CB_BUFFER_DONE; cb_set_buffer_off(cb); - } + } //new FPS regulation doesn't need this signaling #if 0 @@ -375,7 +375,7 @@ void gf_cm_unlock_input(GF_CompositionMemory *cb, GF_CMUnit *cu, u32 cu_size, Bo } -/*Reset composition memory. Note we don't reset the content of each frame since it would lead to green frames +/*Reset composition memory. Note we don't reset the content of each frame since it would lead to green frames when using bitmap (visual), where data is not cached*/ void gf_cm_reset(GF_CompositionMemory *cb) { @@ -388,7 +388,7 @@ void gf_cm_reset(GF_CompositionMemory *cb) cu->dataLength = 0; gf_sema_notify(cb->odm->raw_frame_sema, 1); } - + cu->dataLength = 0; cu->TS = 0; cu = cu->next; @@ -454,8 +454,8 @@ void gf_cm_resize(GF_CompositionMemory *cb, u32 newCapacity) } cu->dataLength = 0; cu = cu->next; - } - + } + cb->UnitCount = 0; cb->output = cb->input; gf_odm_lock(cb->odm, 0); @@ -471,11 +471,11 @@ void gf_cm_reinit(GF_CompositionMemory *cb, u32 UnitSize, u32 Capacity) if (!Capacity || !UnitSize) return; gf_odm_lock(cb->odm, 1); - if (cb->input){ - /*break the loop and destroy*/ - cb->input->prev->next = NULL; - gf_cm_unit_del(cb->input, cb->no_allocation); - cb->input = NULL; + if (cb->input) { + /*break the loop and destroy*/ + cb->input->prev->next = NULL; + gf_cm_unit_del(cb->input, cb->no_allocation); + cb->input = NULL; } cu = NULL; @@ -547,7 +547,7 @@ GF_CMUnit *gf_cm_get_output(GF_CompositionMemory *cb) /*handle visual object - EOS if no more data (we keep the last CU for rendering, so check next one)*/ if (cb->HasSeenEOS && (!cb->output->next->dataLength || (cb->Capacity==1))) { - GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[ODM%d] Switching composition memory to stop state - time %d\n", cb->odm->OD->objectDescriptorID, (u32) cb->odm->media_stop_time)); + GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[ODM%d] Switching composition memory to stop state - time %d\n", cb->odm->OD->objectDescriptorID, (u32) cb->odm->media_stop_time)); cb->Status = CB_STOP; cb->odm->current_time = (u32) cb->odm->media_stop_time; #ifndef GPAC_DISABLE_VRML @@ -583,7 +583,7 @@ void gf_cm_drop_output(GF_CompositionMemory *cb) return; } - /*WARNING: in RAW mode, we (for the moment) only have one unit - setting output->dataLength to 0 means the input is available + /*WARNING: in RAW mode, we (for the moment) only have one unit - setting output->dataLength to 0 means the input is available for the raw channel - we have to make sure the output is completely reseted before releasing the sema*/ /*on visual streams (except raw oness), always keep the last AU*/ @@ -605,7 +605,7 @@ void gf_cm_drop_output(GF_CompositionMemory *cb) } } } - + /*reset the output*/ cb->output->dataLength = 0; cb->output->TS = 0; @@ -623,7 +623,7 @@ void gf_cm_drop_output(GF_CompositionMemory *cb) void gf_cm_set_status(GF_CompositionMemory *cb, u32 Status) { - if (cb->Status == Status) + if (cb->Status == Status) return; gf_odm_lock(cb->odm, 1); @@ -668,8 +668,8 @@ void gf_cm_set_status(GF_CompositionMemory *cb, u32 Status) void gf_cm_set_eos(GF_CompositionMemory *cb) { gf_odm_lock(cb->odm, 1); - /*we may have a pb if the stream is so short that the EOS is signaled - while we're buffering. In this case we shall turn the clock on and + /*we may have a pb if the stream is so short that the EOS is signaled + while we're buffering. In this case we shall turn the clock on and keep a trace of the EOS notif*/ if (cb->Status == CB_BUFFER) { cb->Status = CB_BUFFER_DONE; @@ -699,8 +699,8 @@ Bool gf_cm_is_running(GF_CompositionMemory *cb) } if ((cb->odm->codec->type == GF_STREAM_VISUAL) - && (cb->Status == CB_STOP) - && cb->output->dataLength) return 1; + && (cb->Status == CB_STOP) + && cb->output->dataLength) return 1; return 0; } @@ -708,8 +708,8 @@ Bool gf_cm_is_running(GF_CompositionMemory *cb) Bool gf_cm_is_eos(GF_CompositionMemory *cb) { - if (cb->HasSeenEOS) - return ( (cb->Status == CB_STOP) || (cb->UnitCount==0)) ? 1 : 0; + if ( (cb->Status == CB_STOP) || (cb->HasSeenEOS && (cb->UnitCount==0)) ) + return 1; return 0; } diff --git a/src/terminal/media_memory.h b/src/terminal/media_memory.h index 6470384..c079bed 100644 --- a/src/terminal/media_memory.h +++ b/src/terminal/media_memory.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -37,15 +37,17 @@ enum { /*AU is RAP*/ GF_DB_AU_RAP = 1, - /*special flag for systems streams: we may receive a CTS in a carousel, to indicate the + /*special flag for systems streams: we may receive a CTS in a carousel, to indicate the SFTime init time*/ GF_DB_AU_CTS_IN_PAST = 1<<1, /*hack for some DMB streams not signaling TS for BIFS*/ - GF_DB_AU_NO_TIMESTAMPS = 1<<2 + GF_DB_AU_NO_TIMESTAMPS = 1<<2, + /*for debuging AU reassembly in scalable coding*/ + GF_DB_AU_REAGGREGATED = 1<<3 }; /*compressed media unit*/ -typedef struct _decoding_buffer +typedef struct _decoding_buffer { struct _decoding_buffer *next; @@ -99,8 +101,8 @@ typedef struct _composition_unit { /*composition buffer (circular buffer of CUs)*/ struct _composition_memory { - /*input is used by the decoder to deliver CUs. - if temporal scalability is enabled, this is the LAST DELIVERED CU + /*input is used by the decoder to deliver CUs. + if temporal scalability is enabled, this is the LAST DELIVERED CU otherwise this is the next available CU slot*/ GF_CMUnit *input; /*output is the next available frme for rendering*/ @@ -136,7 +138,7 @@ void gf_cm_del(GF_CompositionMemory *cb); /*re-inits complete cb*/ void gf_cm_reinit(GF_CompositionMemory *cb, u32 UnitSize, u32 Capacity); -/*locks available input for desired TS (needed for scalability) - return NULL if no +/*locks available input for desired TS (needed for scalability) - return NULL if no input is available (buffer full)*/ GF_CMUnit *gf_cm_lock_input(GF_CompositionMemory *cb, u32 TS, Bool codec_reordering); /*dispatch data in input. If NbBytes is 0, no data is dispatched. TS is needed for re-ordering diff --git a/src/terminal/media_object.c b/src/terminal/media_object.c index 374ef63..4d99873 100644 --- a/src/terminal/media_object.c +++ b/src/terminal/media_object.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -59,13 +59,13 @@ static GF_MediaObject *get_sync_reference(GF_Scene *scene, XMLRI *iri, u32 o_typ switch (ref->sgprivate->tag) { case TAG_SVG_audio: - o_type = GF_MEDIA_OBJECT_AUDIO; + o_type = GF_MEDIA_OBJECT_AUDIO; if (gf_node_get_attribute_by_tag(ref, TAG_XLINK_ATT_href, GF_FALSE, GF_FALSE, &info)==GF_OK) { return get_sync_reference(scene, (XMLRI *)info.far_ptr, o_type, orig_ref ? orig_ref : ref, post_pone); } return NULL; case TAG_SVG_video: - o_type = GF_MEDIA_OBJECT_VIDEO; + o_type = GF_MEDIA_OBJECT_VIDEO; if (gf_node_get_attribute_by_tag(ref, TAG_XLINK_ATT_href, GF_FALSE, GF_FALSE, &info)==GF_OK) { return get_sync_reference(scene, (XMLRI *)info.far_ptr, o_type, orig_ref ? orig_ref : ref, post_pone); } @@ -109,74 +109,76 @@ GF_MediaObject *gf_mo_register(GF_Node *node, MFURL *url, Bool lock_timelines, B switch (gf_node_get_tag(node)) { #ifndef GPAC_DISABLE_VRML /*MPEG-4 / VRML / X3D only*/ - case TAG_MPEG4_AudioClip: - case TAG_MPEG4_AudioSource: + case TAG_MPEG4_AudioClip: + case TAG_MPEG4_AudioSource: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_AudioClip: + case TAG_X3D_AudioClip: #endif - obj_type = GF_MEDIA_OBJECT_AUDIO; + obj_type = GF_MEDIA_OBJECT_AUDIO; break; - case TAG_MPEG4_SBVCAnimation: - case TAG_MPEG4_AnimationStream: - obj_type = GF_MEDIA_OBJECT_UPDATES; + case TAG_MPEG4_SBVCAnimation: + case TAG_MPEG4_AnimationStream: + obj_type = GF_MEDIA_OBJECT_UPDATES; break; case TAG_MPEG4_BitWrapper: obj_type = GF_MEDIA_OBJECT_SCENE; break; - case TAG_MPEG4_InputSensor: - obj_type = GF_MEDIA_OBJECT_INTERACT; + case TAG_MPEG4_InputSensor: + obj_type = GF_MEDIA_OBJECT_INTERACT; break; - case TAG_MPEG4_Background2D: - case TAG_MPEG4_Background: + case TAG_MPEG4_Background2D: + case TAG_MPEG4_Background: case TAG_MPEG4_ImageTexture: case TAG_MPEG4_CacheTexture: - case TAG_MPEG4_MovieTexture: + case TAG_MPEG4_MovieTexture: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Background: + case TAG_X3D_Background: case TAG_X3D_ImageTexture: case TAG_X3D_MovieTexture: #endif - obj_type = GF_MEDIA_OBJECT_VIDEO; + obj_type = GF_MEDIA_OBJECT_VIDEO; break; - case TAG_MPEG4_Inline: + case TAG_MPEG4_Inline: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Inline: + case TAG_X3D_Inline: #endif - obj_type = GF_MEDIA_OBJECT_SCENE; + obj_type = GF_MEDIA_OBJECT_SCENE; break; #endif /*GPAC_DISABLE_VRML*/ - /*SVG*/ + /*SVG*/ #ifndef GPAC_DISABLE_SVG - case TAG_SVG_audio: - obj_type = GF_MEDIA_OBJECT_AUDIO; + case TAG_SVG_audio: + obj_type = GF_MEDIA_OBJECT_AUDIO; if (gf_node_get_attribute_by_tag(node, TAG_SVG_ATT_syncReference, GF_FALSE, GF_FALSE, &info)==GF_OK) { syncRef = get_sync_reference(scene, (XMLRI *)info.far_ptr, GF_MEDIA_OBJECT_UNDEF, node, &post_pone); /*syncRef is specified but doesn't exist yet, post-pone*/ if (post_pone) return NULL; } break; - case TAG_SVG_video: - obj_type = GF_MEDIA_OBJECT_VIDEO; + case TAG_SVG_video: + obj_type = GF_MEDIA_OBJECT_VIDEO; if (gf_node_get_attribute_by_tag(node, TAG_SVG_ATT_syncReference, GF_FALSE, GF_FALSE, &info)==GF_OK) { syncRef = get_sync_reference(scene, (XMLRI *)info.far_ptr, GF_MEDIA_OBJECT_UNDEF, node, &post_pone); /*syncRef is specified but doesn't exist yet, post-pone*/ if (post_pone) return NULL; } break; - case TAG_SVG_image: - obj_type = GF_MEDIA_OBJECT_VIDEO; + case TAG_SVG_image: + obj_type = GF_MEDIA_OBJECT_VIDEO; break; - case TAG_SVG_foreignObject: - case TAG_SVG_animation: - obj_type = GF_MEDIA_OBJECT_SCENE; + case TAG_SVG_foreignObject: + case TAG_SVG_animation: + obj_type = GF_MEDIA_OBJECT_SCENE; break; - case TAG_LSR_updates: - obj_type = GF_MEDIA_OBJECT_UPDATES; + case TAG_LSR_updates: + obj_type = GF_MEDIA_OBJECT_UPDATES; break; #endif - default: obj_type = GF_MEDIA_OBJECT_UNDEF; break; + default: + obj_type = GF_MEDIA_OBJECT_UNDEF; + break; } /*move to primary resource handler*/ @@ -225,13 +227,13 @@ Bool gf_mo_get_visual_info(GF_MediaObject *mo, u32 *width, u32 *height, u32 *str *height = cap.cap.valueInt; } if (mo->type==GF_MEDIA_OBJECT_TEXT) return GF_TRUE; - - if (is_flipped) { - cap.CapCode = GF_CODEC_FLIP; - cap.cap.valueInt = 0; + + if (is_flipped) { + cap.CapCode = GF_CODEC_FLIP; + cap.cap.valueInt = 0; gf_codec_get_capability(mo->odm->codec, &cap); *is_flipped = cap.cap.valueInt ? GF_TRUE : GF_FALSE; - } + } if (stride) { cap.CapCode = GF_CODEC_STRIDE; @@ -244,6 +246,7 @@ Bool gf_mo_get_visual_info(GF_MediaObject *mo, u32 *width, u32 *height, u32 *str *pixelFormat = cap.cap.valueInt; if (mo->odm && mo->odm->parentscene->is_dynamic_scene) { +#ifndef GPAC_DISABLE_VRML const char *name = gf_node_get_name(gf_event_target_get_node(gf_mo_event_target_get(mo, 0))); if (name && !strcmp(name, "DYN_VIDEO")) { const char *opt; @@ -271,6 +274,7 @@ Bool gf_mo_get_visual_info(GF_MediaObject *mo, u32 *width, u32 *height, u32 *str gf_node_dirty_set((GF_Node *)back, 0, GF_TRUE); } } +#endif } } /*get PAR settings*/ @@ -376,7 +380,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam if (ms_until_pres) *ms_until_pres = mo->ms_until_pres; if (ms_until_next) *ms_until_next = mo->ms_until_next; - if (!gf_odm_lock_mo(mo)) + if (!gf_odm_lock_mo(mo)) return NULL; if (!mo->odm->codec || !mo->odm->codec->CB) { @@ -418,7 +422,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam /*fast forward, bench mode with composition memory: force decode if no data is available*/ if (! *eos && ((codec->ck->speed > FIX_ONE) || (codec->odm->term->bench_mode && !codec->CB->no_allocation) || (codec->type==GF_STREAM_AUDIO) ) ) force_decode = GF_TRUE; - + if (force_decode) { u32 retry=100; @@ -467,18 +471,26 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam obj_time = gf_clock_time(codec->ck); //no drop mode: all frames are presented, we discard the current output only if already presented and next frame time is mature - if (!(mo->odm->term->flags & GF_TERM_DROP_LATE_FRAMES) && (mo->type==GF_MEDIA_OBJECT_VIDEO)) { + if ((codec->ck->speed>0) && !(mo->odm->term->flags & GF_TERM_DROP_LATE_FRAMES) && (mo->type==GF_MEDIA_OBJECT_VIDEO)) { resync=GF_FALSE; - if (gf_clock_is_started(mo->odm->codec->ck) && (mo->timestamp==CU->TS) && CU->next->dataLength && (CU->next->TS <= obj_time) ) { + if (/*gf_clock_is_started(mo->odm->codec->ck) && */ (mo->timestamp==CU->TS) && CU->next->dataLength && (CU->next->TS <= obj_time) ) { gf_cm_drop_output(codec->CB); CU = gf_cm_get_output(codec->CB); + if (!CU) { + gf_odm_lock(mo->odm, 0); + return NULL; + } } } if (resync) { u32 nb_droped = 0; - while (CU->TS < obj_time) { + while (1) { u32 diff; + + if (CU->TS*codec->ck->speed >= obj_time*codec->ck->speed) + break; + if (!CU->next->dataLength) { if (force_decode) { obj_time = gf_clock_time(codec->ck); @@ -488,22 +500,31 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam gf_term_lock_codec(codec, GF_FALSE, GF_TRUE); } gf_odm_lock(mo->odm, 1); - if (!CU->next->dataLength) + if (!CU->next->dataLength) break; } else { break; } } - diff = CU->next->TS; - diff -= CU->TS; - if (CU->TS + codec->CB->Capacity*diff > obj_time) { - break; + + diff = codec->ck->speed > 0 ? CU->next->TS - CU->TS : CU->TS - CU->next->TS; + + if (codec->ck->speed>0) { + if (CU->TS + codec->CB->Capacity*diff > obj_time) { + break; + } + } else { + if (CU->TS + codec->CB->Capacity*diff < obj_time) { + break; + } } + /*figure out closest time*/ - if (CU->next->TS > obj_time) { + if (codec->ck->speed*CU->next->TS > codec->ck->speed*obj_time) { *eos = GF_FALSE; break; } + nb_droped ++; if (nb_droped>1) { GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[ODM%d] At OTB %u dropped frame TS %u\n", mo->odm->OD->objectDescriptorID, obj_time, CU->TS)); @@ -517,7 +538,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam CU = gf_cm_get_output(codec->CB); *eos = gf_cm_is_eos(codec->CB); } - } + } mo->framesize = CU->dataLength - CU->RenderedLength; mo->frame = CU->data + CU->RenderedLength; @@ -528,14 +549,16 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam } else { mo->ms_until_next = 1; } - diff = (s32) (CU->TS) - (s32) obj_time; + diff = mo->speed > 0 ? (s32) (CU->TS) - (s32) obj_time : (s32) obj_time - (s32) (CU->TS); mo->ms_until_pres = FIX2INT(diff * mo->speed); + if (mo->timestamp != CU->TS) { #ifndef GPAC_DISABLE_VRML - mediasensor_update_timing(mo->odm, codec->CB->HasSeenEOS); + if (! gf_cm_is_eos(codec->CB)) + mediasensor_update_timing(mo->odm, 0); #endif - + if (mo->odm->parentscene->is_dynamic_scene) mo->odm->parentscene->root_od->current_time = mo->odm->current_time; @@ -553,7 +576,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam // mo->timestamp = gf_clock_time(codec->ck); mo->ms_until_pres = -1; mo->ms_until_next = 1; - } + } mo->nb_fetch ++; @@ -562,7 +585,7 @@ char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestam if (ms_until_pres) *ms_until_pres = mo->ms_until_pres; if (ms_until_next) *ms_until_next = mo->ms_until_next; gf_term_service_media_event(mo->odm, GF_EVENT_MEDIA_TIME_UPDATE); - + gf_odm_lock(mo->odm, 0); if (codec->direct_vout) return (char *) codec->CB->pY; return mo->frame; @@ -596,15 +619,15 @@ void gf_mo_release_data(GF_MediaObject *mo, u32 nb_bytes, s32 drop_mode) return; } -/* if ((drop_mode==0) && !(mo->odm->term->flags & GF_TERM_DROP_LATE_FRAMES) && (mo->type==GF_MEDIA_OBJECT_VIDEO)) - drop_mode=1; - else -*/ + /* if ((drop_mode==0) && !(mo->odm->term->flags & GF_TERM_DROP_LATE_FRAMES) && (mo->type==GF_MEDIA_OBJECT_VIDEO)) + drop_mode=1; + else + */ if (mo->odm->codec->CB->no_allocation) drop_mode = 1; - - /*perform a sanity check on TS since the CB may have changed status - this may happen in + + /*perform a sanity check on TS since the CB may have changed status - this may happen in temporal scalability only*/ if (mo->odm->codec->CB->output->dataLength ) { if (nb_bytes==0xFFFFFFFF) { @@ -648,7 +671,7 @@ void gf_mo_get_object_time(GF_MediaObject *mo, u32 *obj_time) /*regular media codec...*/ if (mo->odm->codec) { /*get absolute clock (without drift) for audio*/ - if (mo->odm->codec->type==GF_STREAM_AUDIO) + if (mo->odm->codec->type==GF_STREAM_AUDIO) *obj_time = gf_clock_real_time(mo->odm->codec->ck); else *obj_time = gf_clock_time(mo->odm->codec->ck); @@ -656,7 +679,7 @@ void gf_mo_get_object_time(GF_MediaObject *mo, u32 *obj_time) /*BIFS object */ else if (mo->odm->subscene && mo->odm->subscene->scene_codec) { *obj_time = gf_clock_time(mo->odm->subscene->scene_codec->ck); - } + } /*unknown / unsupported object*/ else { *obj_time = 0; @@ -742,13 +765,13 @@ Bool gf_mo_stop(GF_MediaObject *mo) if (gf_list_find(mo->odm->term->media_queue, mo->odm)<0) { gf_list_add(mo->odm->term->media_queue, mo->odm); } - + /*signal STOP request*/ if ((mo->OD_ID==GF_MEDIA_EXTERNAL_ID) || (mo->odm && mo->odm->OD && (mo->odm->OD->objectDescriptorID==GF_MEDIA_EXTERNAL_ID))) { mo->odm->action_type = GF_ODM_ACTION_DELETE; ret = GF_TRUE; } - else + else mo->odm->action_type = GF_ODM_ACTION_STOP; gf_term_lock_media_queue(mo->odm->term, GF_FALSE); @@ -789,7 +812,7 @@ u32 gf_mo_get_od_id(MFURL *url) u32 id = 0; if (!url) return 0; - + for (i=0; icount; i++) { if (url->vals[i].OD_ID) { /*works because OD ID 0 is forbidden in MPEG4*/ @@ -878,7 +901,7 @@ Bool gf_mo_is_same_url(GF_MediaObject *obj, MFURL *an_url, Bool *keep_fragment, /*if the fragment is a node which can be found, this is the same resource*/ if (obj->odm->subscene && (gf_sg_find_node_by_name(obj->odm->subscene->graph, frag+1)!=NULL) ) return GF_TRUE; - + /*if the expected type is an existing segment (undefined media type), this is the same resource*/ if (!obj_hint_type && gf_odm_find_segment(obj->odm, frag+1)) return GF_TRUE; @@ -982,6 +1005,12 @@ Fixed gf_mo_get_current_speed(GF_MediaObject *mo) return (mo && mo->odm && mo->odm->codec && mo->odm->codec->ck) ? mo->odm->codec->ck->speed : FIX_ONE; } +GF_EXPORT +u32 gf_mo_get_min_frame_dur(GF_MediaObject *mo) +{ + return (mo && mo->odm && mo->odm->codec) ? mo->odm->codec->min_frame_dur : 0; +} + GF_EXPORT Fixed gf_mo_get_speed(GF_MediaObject *mo, Fixed in_speed) @@ -1011,7 +1040,7 @@ Bool gf_mo_get_loop(GF_MediaObject *mo, Bool in_loop) MediaControlStack *ctrl; #endif if (!gf_odm_lock_mo(mo)) return in_loop; - + /*get control*/ #ifndef GPAC_DISABLE_VRML ctrl = gf_odm_get_mediacontrol(mo->odm); @@ -1023,10 +1052,10 @@ Bool gf_mo_get_loop(GF_MediaObject *mo, Bool in_loop) if (gf_odm_shares_clock(mo->odm, ck)) { in_loop = GF_FALSE; #ifndef GPAC_DISABLE_VRML -/* - if (ctrl && ctrl->stream->odm && ctrl->stream->odm->subscene) - gf_term_invalidate_compositor(mo->odm->term); -*/ + /* + if (ctrl && ctrl->stream->odm && ctrl->stream->odm->subscene) + gf_term_invalidate_compositor(mo->odm->term); + */ #endif } gf_odm_lock(mo->odm, 0); @@ -1052,8 +1081,9 @@ Bool gf_mo_should_deactivate(GF_MediaObject *mo) #endif if (!gf_odm_lock_mo(mo)) return GF_FALSE; - - if (!mo->odm->state) { + + + if (!mo->odm->state || (mo->odm->parentscene && mo->odm->parentscene->is_dynamic_scene)) { gf_odm_lock(mo->odm, 0); return GF_FALSE; } @@ -1066,8 +1096,8 @@ Bool gf_mo_should_deactivate(GF_MediaObject *mo) else if (ctrl->stream->odm != mo->odm) res = GF_FALSE; /*this is currently under discussion in MPEG. for now we deny deactivation as soon as a mediaControl is here*/ else if (ctrl->stream->odm->state) res = GF_FALSE; - /*otherwise allow*/ - else + /*otherwise allow*/ + else #endif res = GF_TRUE; @@ -1138,7 +1168,7 @@ GF_EXPORT void gf_mo_set_flag(GF_MediaObject *mo, u32 flag, Bool set_on) { if (mo) { - if (set_on) + if (set_on) mo->flags |= flag; else mo->flags &= ~flag; @@ -1202,7 +1232,7 @@ u32 gf_mo_has_audio(GF_MediaObject *mo) ext = odm->mo->URLs.count ? odm->mo->URLs.vals[0].url : NULL; if (ext) ext = strchr(ext, '#'); if (!ext || strcmp(sub_url, ext)) continue; - } + } /*there is already an audio object in this service, do not recreate one*/ if (odm->mo->type == GF_MEDIA_OBJECT_AUDIO) return 0; } @@ -1226,8 +1256,8 @@ GF_EXPORT GF_DOMEventTarget *gf_mo_event_target_add_node(GF_MediaObject *mo, GF_Node *n) { #ifndef GPAC_DISABLE_SVG - GF_DOMEventTarget *target = NULL; - if (!mo ||!n) return NULL; + GF_DOMEventTarget *target = NULL; + if (!mo ||!n) return NULL; target = gf_dom_event_get_target_from_node(n); gf_list_add(mo->evt_targets, target); return target; @@ -1238,89 +1268,89 @@ GF_DOMEventTarget *gf_mo_event_target_add_node(GF_MediaObject *mo, GF_Node *n) GF_Err gf_mo_event_target_remove(GF_MediaObject *mo, GF_DOMEventTarget *target) { - if (!mo || !target) return GF_BAD_PARAM; - gf_list_del_item(mo->evt_targets, target); - return GF_OK; + if (!mo || !target) return GF_BAD_PARAM; + gf_list_del_item(mo->evt_targets, target); + return GF_OK; } GF_Err gf_mo_event_target_remove_by_index(GF_MediaObject *mo, u32 i) { - if (!mo) return GF_BAD_PARAM; - gf_list_rem(mo->evt_targets, i); - return GF_OK; + if (!mo) return GF_BAD_PARAM; + gf_list_rem(mo->evt_targets, i); + return GF_OK; } GF_Node *gf_mo_event_target_enum_node(GF_MediaObject *mo, u32 *i) { - GF_DOMEventTarget *target; - if (!mo || !i) return NULL; - target = (GF_DOMEventTarget *)gf_list_enum(mo->evt_targets, i); - if (!target) return NULL; + GF_DOMEventTarget *target; + if (!mo || !i) return NULL; + target = (GF_DOMEventTarget *)gf_list_enum(mo->evt_targets, i); + if (!target) return NULL; //if (target->ptr_type != GF_DOM_EVENT_TARGET_NODE) return NULL; - return (GF_Node *)target->ptr; + return (GF_Node *)target->ptr; } s32 gf_mo_event_target_find_by_node(GF_MediaObject *mo, GF_Node *node) { - u32 i, count; - count = gf_list_count(mo->evt_targets); - for (i = 0; i < count; i++) { - GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); - if (target->ptr == node) { - return i; - } - } - return -1; + u32 i, count; + count = gf_list_count(mo->evt_targets); + for (i = 0; i < count; i++) { + GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); + if (target->ptr == node) { + return i; + } + } + return -1; } GF_EXPORT GF_Err gf_mo_event_target_remove_by_node(GF_MediaObject *mo, GF_Node *node) { - u32 i, count; - count = gf_list_count(mo->evt_targets); - for (i = 0; i < count; i++) { - GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); - if (target->ptr == node) { - gf_list_del_item(mo->evt_targets, target); - i--; + u32 i, count; + count = gf_list_count(mo->evt_targets); + for (i = 0; i < count; i++) { + GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); + if (target->ptr == node) { + gf_list_del_item(mo->evt_targets, target); + i--; count--; //return GF_OK; - } - } - return GF_BAD_PARAM; + } + } + return GF_BAD_PARAM; } GF_EXPORT GF_Node *gf_event_target_get_node(GF_DOMEventTarget *target) { - if (target && (target->ptr_type == GF_DOM_EVENT_TARGET_NODE)) { - return (GF_Node *)target->ptr; - } - return NULL; + if (target && (target->ptr_type == GF_DOM_EVENT_TARGET_NODE)) { + return (GF_Node *)target->ptr; + } + return NULL; } GF_EXPORT GF_DOMEventTarget *gf_mo_event_target_get(GF_MediaObject *mo, u32 i) { - GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); - return target; + GF_DOMEventTarget *target = (GF_DOMEventTarget *)gf_list_get(mo->evt_targets, i); + return target; } void gf_mo_event_target_reset(GF_MediaObject *mo) { - if (mo->evt_targets) gf_list_reset(mo->evt_targets); + if (mo->evt_targets) gf_list_reset(mo->evt_targets); } u32 gf_mo_event_target_count(GF_MediaObject *mo) { - if (!mo) return 0; - return gf_list_count(mo->evt_targets); + if (!mo) return 0; + return gf_list_count(mo->evt_targets); } void gf_mo_del(GF_MediaObject *mo) { assert(gf_list_count(mo->evt_targets) == 0); - gf_list_del(mo->evt_targets); - gf_free(mo); + gf_list_del(mo->evt_targets); + gf_free(mo); } diff --git a/src/terminal/media_sensor.c b/src/terminal/media_sensor.c index 1068b48..7f6e41d 100644 --- a/src/terminal/media_sensor.c +++ b/src/terminal/media_sensor.c @@ -11,39 +11,43 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "media_control.h" #include +#include #ifndef GPAC_DISABLE_VRML /*render : setup media sensor and update timing in case of inline scenes*/ void RenderMediaSensor(GF_Node *node, void *rs, Bool is_destroy) { + GF_TraverseState *tr_state = (GF_TraverseState *)rs; GF_Clock *ck; MediaSensorStack *st = (MediaSensorStack *)gf_node_get_private(node); if (is_destroy) { /*unlink from OD*/ - if (st->stream && st->stream->odm) + if (st->stream && st->stream->odm) gf_list_del_item(st->stream->odm->ms_stack, st); gf_list_del(st->seg); gf_free(st); return; } + //we need to disable culling otherwise we may never be called back again ... + tr_state->disable_cull = 1; if (!st->stream) st->stream = gf_mo_register(node, &st->sensor->url, 0, 0); if (!st->stream || !st->stream->odm) return; @@ -53,7 +57,7 @@ void RenderMediaSensor(GF_Node *node, void *rs, Bool is_destroy) gf_odm_init_segments(st->stream->odm, st->seg, &st->sensor->url); st->is_init = 1; st->active_seg = 0; - + } /*media sensor bound to natural media (audio, video) is updated when fetching the stream data for rendering.*/ @@ -97,12 +101,12 @@ void MS_Modified(GF_Node *node) { MediaSensorStack *st = (MediaSensorStack *)gf_node_get_private(node); if (!st) return; - + while (gf_list_count(st->seg)) gf_list_rem(st->seg, 0); if (st->stream) { /*unlink from OD*/ - if (st->stream->odm && st->stream->odm->ms_stack) + if (st->stream->odm && st->stream->odm->ms_stack) gf_list_del_item(st->stream->odm->ms_stack, st); gf_mo_unregister(node, st->stream); @@ -141,7 +145,7 @@ void mediasensor_update_timing(GF_ObjectManager *odm, Bool is_eos) Double time; ms_count = gf_list_count(odm->ms_stack); if (!ms_count) return; - + time = odm->current_time / 1000.0; //dirty hack to get timing of frame when very late (openhevc debug) if (odm->subscene && odm->subscene->dyn_ck && odm->subscene->dyn_ck->last_TS_rendered) @@ -151,7 +155,7 @@ void mediasensor_update_timing(GF_ObjectManager *odm, Bool is_eos) MediaSensorStack *media_sens = (MediaSensorStack *)gf_list_get(odm->ms_stack, j); if (!media_sens->is_init) continue; count = gf_list_count(media_sens->seg); - + /*full object controled*/ if (!media_sens->active_seg && !count) { /*check for end of scene (MediaSensor on inline)*/ diff --git a/src/terminal/mpeg4_inline.c b/src/terminal/mpeg4_inline.c index 4fbd637..0c4d197 100644 --- a/src/terminal/mpeg4_inline.c +++ b/src/terminal/mpeg4_inline.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -124,7 +124,7 @@ void gf_inline_on_modified(GF_Node *node) } } else { gf_term_lock_media_queue(scene->root_od->term, GF_TRUE); - + /*external media are completely unloaded*/ if (scene->root_od->OD->objectDescriptorID==GF_MEDIA_EXTERNAL_ID) { scene->root_od->action_type = GF_ODM_ACTION_DELETE; @@ -139,8 +139,8 @@ void gf_inline_on_modified(GF_Node *node) } } } - } - /*force a redraw and load scene at next pass - we cannot load the scene now because + } + /*force a redraw and load scene at next pass - we cannot load the scene now because - we can be in a JS call (eg JS mutex blocked) - locating scene objects matching the new url needs exclusive access to the MediaObject list, achieved with the term net mutex - another service may already be setting up objects (eg exclusive access to the net mutex grabbed), which can trigger event forwarding @@ -179,7 +179,8 @@ static void gf_inline_check_restart(GF_Scene *scene) } else { Double s, e; - s = now; s/=1000; + s = now; + s/=1000; e = -1; MC_GetRange(scene->root_od->media_ctrl, &s, &e); if ((e>=0) && (enum_open) { gf_term_lock_media_queue(scene->root_od->term, GF_TRUE); - /*this is unspecified in the spec: whenever an inline not using the + /*this is unspecified in the spec: whenever an inline not using the OD framework is destroyed, destroy the associated resource*/ if (mo->OD_ID == GF_MEDIA_EXTERNAL_ID) { /*get parent scene and remove MediaObject in case the ressource @@ -255,7 +256,10 @@ static void gf_inline_traverse(GF_Node *n, void *rs, Bool is_destroy) GF_Scene *parent_scene = (GF_Scene *)gf_sg_get_private(gf_node_get_graph((GF_Node *) n) ); if (gf_list_del_item(parent_scene->scene_objects, mo)>=0) { gf_sg_vrml_mf_reset(&mo->URLs, GF_SG_VRML_MFURL); - if (mo->odm) mo->odm->mo = NULL; + if (mo->odm) { + gf_odm_reset_media_control(mo->odm, 1); + mo->odm->mo = NULL; + } gf_mo_del(mo); } scene->root_od->action_type = GF_ODM_ACTION_DELETE; @@ -323,8 +327,8 @@ static void gf_inline_traverse(GF_Node *n, void *rs, Bool is_destroy) gf_node_dirty_set(n, 0, GF_TRUE); return; - } - + } + } @@ -335,7 +339,7 @@ static Bool gf_inline_is_hardcoded_proto(GF_Terminal *term, MFURL *url) if (!url->vals[i].url) continue; if (strstr(url->vals[i].url, "urn:inet:gpac:builtin")) return GF_TRUE; - if (gf_sc_uri_is_hardcoded_proto(term->compositor, url->vals[i].url)) + if (gf_sc_uri_is_hardcoded_proto(term->compositor, url->vals[i].url)) return GF_TRUE; } return GF_FALSE; @@ -397,7 +401,7 @@ GF_SceneGraph *gf_inline_get_proto_lib(void *_is, MFURL *lib_url) /*internal, don't waste ressources*/ if (gf_inline_is_hardcoded_proto(scene->root_od->term, lib_url)) return NULL; - + i=0; while ((pl = (GF_ProtoLink*)gf_list_enum(scene->extern_protos, &i)) ) { if (pl->url == lib_url) return NULL; @@ -439,10 +443,10 @@ Bool gf_inline_is_default_viewpoint(GF_Node *node) /*check any viewpoint*/ seg_name = strrchr(scene->root_od->net_service->url, '#'); - + /*check the URL of the parent*/ if (!seg_name && scene->current_url) { - if (scene->current_url->count && scene->current_url->vals[0].url) + if (scene->current_url->count && scene->current_url->vals[0].url) seg_name = strrchr(scene->current_url->vals[0].url, '#'); } else if (!seg_name && scene->root_od->mo && scene->root_od->mo->URLs.count && scene->root_od->mo->URLs.vals[0].url) { seg_name = strrchr(scene->root_od->mo->URLs.vals[0].url, '#'); @@ -693,7 +697,7 @@ static void gf_storage_traverse(GF_Node *n, void *rs, Bool is_destroy) if (is_destroy) { GF_Scene *scene = (GF_Scene *)gf_node_get_private(n); GF_ClientService *net_service = scene->root_od->net_service; - while (scene->root_od->parentscene) { + while (scene->root_od->parentscene) { if (scene->root_od->parentscene->root_od->net_service != net_service) break; scene = scene->root_od->parentscene; @@ -725,7 +729,7 @@ void gf_scene_init_storage(GF_Scene *scene, GF_Node *node) gf_node_set_private(node, scene); net_service = scene->root_od->net_service; - while (scene->root_od->parentscene) { + while (scene->root_od->parentscene) { if (scene->root_od->parentscene->root_od->net_service != net_service) break; scene = scene->root_od->parentscene; diff --git a/src/terminal/network_service.c b/src/terminal/network_service.c index bc61081..e596bbb 100644 --- a/src/terminal/network_service.c +++ b/src/terminal/network_service.c @@ -42,34 +42,11 @@ static GFINLINE GF_Channel *gf_term_get_channel(GF_ClientService *service, LPNET return ch; } -static void term_on_message(void *user_priv, GF_ClientService *service, GF_Err error, const char *message) -{ - GET_TERM(); - - /*check for UDP timeout*/ - if (error==GF_IP_UDP_TIMEOUT) { - const char *sOpt = gf_cfg_get_key(term->user->config, "Network", "AutoReconfigUDP"); - if (sOpt && !stricmp(sOpt, "yes")) { - char szMsg[1024]; - sprintf(szMsg, "!! UDP down (%s) - Retrying with TCP !!\n", message); - gf_term_message(term, service->url, szMsg, GF_IP_NETWORK_FAILURE); - - /*reload scene - FIXME this shall work on inline nodes, not on the root !*/ - if (term->reload_url) gf_free(term->reload_url); - term->reload_state = 1; - term->reload_url = gf_strdup(term->root_scene->root_od->net_service->url); - gf_cfg_set_key(term->user->config, "Network", "UDPNotAvailable", "yes"); - return; - } - } - gf_term_message(term, service->url, message, error); -} - -static void term_on_connect(void *user_priv, GF_ClientService *service, LPNETCHANNEL netch, GF_Err err) +static void term_on_connect(GF_ClientService *service, LPNETCHANNEL netch, GF_Err err) { GF_Channel *ch; GF_ObjectManager *root; - GET_TERM(); + GF_Terminal *term = service->term; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] %s connection ACK received from %s - %s\n", netch ? "Channel" : "Service", service->url, gf_error_to_string(err) )); @@ -95,7 +72,7 @@ static void term_on_connect(void *user_priv, GF_ClientService *service, LPNETCHA root->net_service = NULL; if (service->owner && service->nb_odm_users) service->nb_odm_users--; service->owner = NULL; - /*depends on module: some module could forget to call gf_term_on_disconnect */ + /*depends on module: some module could forget to call gf_service_disconnect_ack */ if ( gf_list_del_item(term->net_services, service) >= 0) { /*and queue for destroy*/ gf_list_add(term->net_services_to_remove, service); @@ -179,7 +156,7 @@ static void term_on_connect(void *user_priv, GF_ClientService *service, LPNETCHA if (err && ((err!=GF_STREAM_NOT_FOUND) || (ch->esd->decoderConfig->streamType!=GF_STREAM_INTERACT))) { GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Terminal] Channel %d connection error: %s\n", ch->esd->ESID, gf_error_to_string(err) )); ch->es_state = GF_ESM_ES_UNAVAILABLE; -/* return;*/ + /* return;*/ } if (ch->odm->mo) { @@ -192,8 +169,8 @@ static void term_on_connect(void *user_priv, GF_ClientService *service, LPNETCHA 2-this is a channel of the root OD */ if ( (ch->odm->mo && ch->odm->mo->num_open) - || !ch->odm->parentscene - ) { + || !ch->odm->parentscene + ) { gf_odm_start(ch->odm, 0); } #if 0 @@ -203,12 +180,12 @@ static void term_on_connect(void *user_priv, GF_ClientService *service, LPNETCHA #endif } -static void term_on_disconnect(void *user_priv, GF_ClientService *service, LPNETCHANNEL netch, GF_Err response) +static void term_on_disconnect(GF_ClientService *service, LPNETCHANNEL netch, GF_Err response) { GF_ObjectManager *root; GF_Channel *ch; - GET_TERM(); - + GF_Terminal *term = service->term; + /*may be null upon destroy*/ root = service->owner; if (root && (root->net_service != service)) { @@ -243,10 +220,9 @@ static void term_on_disconnect(void *user_priv, GF_ClientService *service, LPNET ch->es_state = GF_ESM_ES_DISCONNECTED; } -static void term_on_slp_received(void *user_priv, GF_ClientService *service, LPNETCHANNEL netch, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status) +static void term_on_data_packet(GF_ClientService *service, LPNETCHANNEL netch, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status) { GF_Channel *ch; - GET_TERM(); ch = gf_term_get_channel(service, netch); if (!ch) @@ -274,23 +250,23 @@ static Bool is_same_od(GF_ObjectDescriptor *od1, GF_ObjectDescriptor *od2) return 1; } -static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_check) +static void term_on_media_add(GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_check) { u32 i, min_od_id; GF_MediaObject *the_mo; GF_Scene *scene; GF_ObjectManager *odm, *root; GF_ObjectDescriptor *od; - GET_TERM(); + GF_Terminal *term = service->term; root = service->owner; if (!root) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Service %s] has not root, aborting !\n", service->url)); - return; + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Service %s] has not root, aborting !\n", service->url)); + return; } if (root->flags & GF_ODM_DESTROYED) { - GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Service %s] root has been scheduled for destruction - aborting !\n", service->url)); - return; + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Service %s] root has been scheduled for destruction - aborting !\n", service->url)); + return; } scene = root->subscene ? root->subscene : root->parentscene; @@ -314,7 +290,7 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des gf_term_lock_net(term, 1); /*object declared this way are not part of an OD stream and are considered as dynamic*/ -/* od->objectDescriptorID = GF_MEDIA_EXTERNAL_ID; */ + /* od->objectDescriptorID = GF_MEDIA_EXTERNAL_ID; */ /*check if we have a mediaObject in the scene not attached and matching this object*/ the_mo = NULL; @@ -327,7 +303,7 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des u32 match_esid = 0; GF_MediaObject *mo = gf_list_get(scene->scene_objects, i); - if ((mo->OD_ID != GF_MEDIA_EXTERNAL_ID) && (min_od_idOD_ID)) + if ((mo->OD_ID != GF_MEDIA_EXTERNAL_ID) && (min_od_idOD_ID)) min_od_id = mo->OD_ID; if (!mo->odm) continue; @@ -376,7 +352,7 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des if (ext) ext[0] = '#'; esd = gf_list_get(od->ESDescriptors, 0); - if (match_esid && (esd->ESID != match_esid)) + if (match_esid && (esd->ESID != match_esid)) continue; /*match type*/ switch (esd->decoderConfig->streamType) { @@ -408,13 +384,13 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des break; } - /*add a pass on scene->resource to check for min_od_id, + /*add a pass on scene->resource to check for min_od_id, otherwise we may have another modules declaring an object with ID 0 from another thread, which will assert (only one object with a givne OD ID)*/ for (i=0; iresources); i++) { GF_ObjectManager *an_odm = gf_list_get(scene->resources, i); - if (an_odm->OD && (an_odm->OD->objectDescriptorID != GF_MEDIA_EXTERNAL_ID) && (min_od_id < an_odm->OD->objectDescriptorID)) + if (an_odm->OD && (an_odm->OD->objectDescriptorID != GF_MEDIA_EXTERNAL_ID) && (min_od_id < an_odm->OD->objectDescriptorID)) min_od_id = an_odm->OD->objectDescriptorID; } @@ -432,11 +408,11 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des } if (the_mo) the_mo->OD_ID = od->objectDescriptorID; - if (!scene->selected_service_id) + if (!scene->selected_service_id) scene->selected_service_id = od->ServiceID; - /*net is unlocked before seting up the object as this might trigger events going into JS and deadlocks + /*net is unlocked before seting up the object as this might trigger events going into JS and deadlocks with the compositor*/ gf_term_lock_net(term, 0); @@ -447,7 +423,7 @@ static void term_on_media_add(void *user_priv, GF_ClientService *service, GF_Des if (!no_scene_check && scene->is_dynamic_scene) gf_scene_regenerate(scene); } -static void gather_buffer_level(GF_ObjectManager *odm, GF_ClientService *service, GF_NetworkCommand *com, s32 *max_buffer_time) +static void gather_buffer_level(GF_ObjectManager *odm, GF_ClientService *service, GF_NetworkCommand *com, u32 *max_buffer_time) { u32 j, count = gf_list_count(odm->channels); for (j=0; jterm; if (com->command_type==GF_NET_BUFFER_QUERY) { GF_List *od_list; @@ -516,7 +492,7 @@ static void term_on_command(void *user_priv, GF_ClientService *service, GF_Netwo } gf_mx_v(term->mm_mx); if (com->buffer.occupancy==(u32) -1) com->buffer.occupancy = 0; - + //in bench mode return the 1 if one of the buffer is full (eg sleep until all buffers are not full), 0 otherwise if (term->bench_mode) { com->buffer.occupancy = (max_buffer_time>com->buffer.max) ? 2 : 0; @@ -535,25 +511,49 @@ static void term_on_command(void *user_priv, GF_ClientService *service, GF_Netwo gf_sc_get_av_caps(term->compositor, &com->mcaps.width, &com->mcaps.height, &com->mcaps.display_bit_depth, &com->mcaps.audio_bpp, &com->mcaps.channels, &com->mcaps.sample_rate); return; } + if (com->command_type==GF_NET_SERVICE_EVENT) { + /*check for UDP timeout*/ + if (com->send_event.evt.message.error == GF_IP_UDP_TIMEOUT) { + const char *sOpt = gf_cfg_get_key(term->user->config, "Network", "AutoReconfigUDP"); + if (sOpt && !stricmp(sOpt, "yes")) { + char szMsg[1024]; + sprintf(szMsg, "!! UDP down (%s) - Retrying with TCP !!\n", com->send_event.evt.message.message); + gf_term_message(term, service->url, szMsg, GF_IP_NETWORK_FAILURE); + + /*reload scene - FIXME this shall work on inline nodes, not on the root !*/ + if (term->reload_url) gf_free(term->reload_url); + term->reload_state = 1; + term->reload_url = gf_strdup(term->root_scene->root_od->net_service->url); + gf_cfg_set_key(term->user->config, "Network", "UDPNotAvailable", "yes"); + return; + } + } + + com->send_event.res = 0; + if (term->user->EventProc) com->send_event.res = term->user->EventProc(term->user->opaque, &com->send_event.evt); + return; + } if (com->command_type==GF_NET_ASSOCIATED_CONTENT_LOCATION) { - GF_Scene *scene; + GF_Scene *scene = NULL; if (service->owner->subscene) { scene = service->owner->subscene; } else if (service->owner->parentscene) { scene = service->owner->parentscene; } - gf_scene_register_associated_media(scene, &com->addon_info); + if (scene) + gf_scene_register_associated_media(scene, &com->addon_info); return; } if (com->command_type==GF_NET_ASSOCIATED_CONTENT_TIMING) { - GF_Scene *scene; + GF_Scene *scene = NULL; if (service->owner->subscene) { scene = service->owner->subscene; } else if (service->owner->parentscene) { scene = service->owner->parentscene; } - gf_scene_notify_associated_media_timeline(scene, &com->addon_time); + if (scene) + gf_scene_notify_associated_media_timeline(scene, &com->addon_time); return; } @@ -586,7 +586,7 @@ static void term_on_command(void *user_priv, GF_ClientService *service, GF_Netwo if (com->map_time.reset_buffers) { gf_es_reset_buffers(ch); } - /*if we were reassembling an AU, do not perform clock init check when dispatching it since we computed its timestamps + /*if we were reassembling an AU, do not perform clock init check when dispatching it since we computed its timestamps according to the previous clock origin*/ else { gf_mx_p(ch->mx); @@ -689,7 +689,7 @@ static char *get_mime_type(GF_Terminal *term, const char *url, GF_Err *ret_code, if (gf_dm_sess_get_status(sess)>=GF_NETIO_DATA_EXCHANGE) { const char * mime = gf_dm_sess_mime_type(sess); /* The mime type is returned lower case */ - if (mime){ + if (mime) { ret = gf_strdup(mime); } break; @@ -784,11 +784,11 @@ static GF_InputService *gf_term_can_handle_service(GF_Terminal *term, const char } if (mime_type && - (!stricmp(mime_type, "text/plain") - || !stricmp(mime_type, "video/quicktime") - || !stricmp(mime_type, "application/octet-stream") - ) - ) { + (!stricmp(mime_type, "text/plain") + || !stricmp(mime_type, "video/quicktime") + || !stricmp(mime_type, "application/octet-stream") + ) + ) { skip_mime = 1; } @@ -874,7 +874,7 @@ static GF_InputService *gf_term_can_handle_service(GF_Terminal *term, const char GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Trying module[%i]=%s, mime=%s\n", i, sPlug, sMime)); ifce = (GF_InputService *) gf_modules_load_interface_by_name(term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); - if (!ifce){ + if (!ifce) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] module[%i]=%s, mime=%s, cannot be loaded for GF_NET_CLIENT_INTERFACE.\n", i, sPlug, sMime)); continue; } @@ -909,11 +909,11 @@ static GF_InputService *gf_term_can_handle_service(GF_Terminal *term, const char } } exit: - if (!ifce){ - GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Terminal] Did not find any input plugin for URL %s (%s)\n", sURL ? sURL : url, mime_type ? mime_type : "no mime type")); - if (sURL) gf_free(sURL); + if (!ifce) { + GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Terminal] Did not find any input plugin for URL %s (%s)\n", sURL ? sURL : url, mime_type ? mime_type : "no mime type")); + if (sURL) gf_free(sURL); if ( (*ret_code) == GF_OK) (*ret_code) = GF_NOT_SUPPORTED; - *out_url = NULL; + *out_url = NULL; if (the_session && *the_session) { gf_dm_sess_del(*the_session); @@ -923,11 +923,11 @@ exit: if (*out_mime_type) gf_free(*out_mime_type); *out_mime_type = NULL; } else { - *out_url = sURL; - GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[Terminal] Found input plugin %s for URL %s (%s)\n", ifce->module_name, sURL, mime_type ? mime_type : "no mime type")); + *out_url = sURL; + GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[Terminal] Found input plugin %s for URL %s (%s)\n", ifce->module_name, sURL, mime_type ? mime_type : "no mime type")); } if (mime_type) - *out_mime_type = mime_type; + *out_mime_type = mime_type; return ifce; } @@ -952,6 +952,12 @@ GF_ClientService *gf_term_service_new(GF_Terminal *term, struct _od_manager *own gf_list_add(term->net_services, serv); + + serv->fn_connect_ack = term_on_connect; + serv->fn_disconnect_ack = term_on_disconnect; + serv->fn_command = term_on_command; + serv->fn_data_packet = term_on_data_packet; + serv->fn_add_media = term_on_media_add; return serv; } @@ -998,54 +1004,41 @@ GF_Err gf_term_channel_release_sl_packet(GF_ClientService *ns, LPNETCHANNEL chan } GF_EXPORT -void gf_term_on_message(GF_ClientService *service, GF_Err error, const char *message) +void gf_service_connect_ack(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response) { assert(service); - term_on_message(service->term, service, error, message); -} -GF_EXPORT -void gf_term_on_connect(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response) -{ - assert(service); - term_on_connect(service->term, service, ns, response); -} -GF_EXPORT -void gf_term_on_disconnect(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response) -{ - assert(service); - term_on_disconnect(service->term, service, ns, response); + service->fn_connect_ack(service, ns, response); } + GF_EXPORT -void gf_term_on_command(GF_ClientService *service, GF_NetworkCommand *com, GF_Err response) +void gf_service_disconnect_ack(GF_ClientService *service, LPNETCHANNEL ns, GF_Err response) { assert(service); - term_on_command(service->term, service, com, response); + service->fn_disconnect_ack(service, ns, response); } - GF_EXPORT -Bool gf_term_on_service_event(GF_ClientService *service, GF_Event *service_event) +void gf_service_command(GF_ClientService *service, GF_NetworkCommand *com, GF_Err response) { assert(service); - if (service->term->user->EventProc) return service->term->user->EventProc(service->term->user->opaque, service_event); - return 0; + service->fn_command(service, com, response); } GF_EXPORT -void gf_term_on_sl_packet(GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status) +void gf_service_send_packet(GF_ClientService *service, LPNETCHANNEL ns, char *data, u32 data_size, GF_SLHeader *hdr, GF_Err reception_status) { assert(service); - term_on_slp_received(service->term, service, ns, data, data_size, hdr, reception_status); + service->fn_data_packet(service, ns, data, data_size, hdr, reception_status); } GF_EXPORT -void gf_term_add_media(GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_check) +void gf_service_declare_media(GF_ClientService *service, GF_Descriptor *media_desc, Bool no_scene_check) { assert(service); - term_on_media_add(service->term, service, media_desc, no_scene_check); + service->fn_add_media(service, media_desc, no_scene_check); } GF_EXPORT -const char *gf_term_get_service_url(GF_ClientService *service) +const char *gf_service_get_url(GF_ClientService *service) { if (!service) return NULL; return service->url; @@ -1081,20 +1074,20 @@ void gf_term_delete_net_service(GF_ClientService *ns) } GF_EXPORT -GF_InputService *gf_term_get_service_interface(GF_ClientService *serv) +GF_InputService *gf_service_get_interface(GF_ClientService *serv) { return serv ? serv->ifce : NULL; } GF_EXPORT -GF_DownloadSession *gf_term_download_new(GF_ClientService *service, const char *url, u32 flags, gf_dm_user_io user_io, void *cbk) +GF_DownloadSession *gf_service_download_new(GF_ClientService *service, const char *url, u32 flags, gf_dm_user_io user_io, void *cbk) { GF_Err e; GF_DownloadSession * sess; char *sURL, *orig_url; - if (!service){ - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] service is null, cannot create new download session for %s.\n", url)); - return NULL; + if (!service) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] service is null, cannot create new download session for %s.\n", url)); + return NULL; } sURL = gf_url_concatenate(service->url, url); @@ -1116,7 +1109,7 @@ GF_DownloadSession *gf_term_download_new(GF_ClientService *service, const char * } if (orig_url) gf_free(orig_url); - if (!sess){ + if (!sess) { GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] session could not be created for %s : %s. service url=%s, url=%s.\n", sURL, gf_error_to_string(e), service->url, url)); gf_free(sURL); sURL = NULL; @@ -1130,7 +1123,7 @@ GF_DownloadSession *gf_term_download_new(GF_ClientService *service, const char * } GF_EXPORT -void gf_term_download_del(GF_DownloadSession * sess) +void gf_service_download_del(GF_DownloadSession * sess) { Bool locked; GF_ClientService *serv; @@ -1154,7 +1147,7 @@ void gf_term_download_del(GF_DownloadSession * sess) } GF_EXPORT -void gf_term_download_update_stats(GF_DownloadSession * sess) +void gf_service_download_update_stats(GF_DownloadSession * sess) { GF_ClientService *serv; const char *szURI; @@ -1167,16 +1160,16 @@ void gf_term_download_update_stats(GF_DownloadSession * sess) serv = (GF_ClientService *)gf_dm_sess_get_private(sess); switch (net_status) { case GF_NETIO_SETUP: - gf_term_on_message(serv, GF_OK, "Connecting"); + gf_term_message(serv->term, serv->url, "Connecting", GF_OK); break; case GF_NETIO_CONNECTED: - gf_term_on_message(serv, GF_OK, "Connected"); + gf_term_message(serv->term, serv->url, "Connected", GF_OK); break; case GF_NETIO_WAIT_FOR_REPLY: - gf_term_on_message(serv, GF_OK, "Waiting for reply..."); + gf_term_message(serv->term, serv->url, "Waiting for reply...", GF_OK); break; case GF_NETIO_PARSE_REPLY: - gf_term_on_message(serv, GF_OK, "Starting download..."); + gf_term_message(serv->term, serv->url, "Starting download...", GF_OK); break; case GF_NETIO_DATA_EXCHANGE: /*notify some connection / ...*/ @@ -1201,7 +1194,9 @@ void gf_term_download_update_stats(GF_DownloadSession * sess) GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP Resource] Done retrieving file - resuming playback\n")); if (serv->is_paused) { serv->is_paused = 0; +#ifndef GPAC_DISABLE_VRML mediacontrol_resume(serv->owner); +#endif } } } @@ -1222,7 +1217,7 @@ void gf_term_service_del(GF_ClientService *ns) } GF_EXPORT -void gf_term_register_mime_type(const GF_InputService *ifce, const char *mimeType, const char *extList, const char *description) +void gf_service_register_mime(const GF_InputService *ifce, const char *mimeType, const char *extList, const char *description) { u32 len; char *buf; @@ -1241,7 +1236,7 @@ void gf_term_register_mime_type(const GF_InputService *ifce, const char *mimeTyp } GF_EXPORT -Bool gf_term_check_extension(GF_InputService *ifce, const char *mimeType, const char *extList, const char *description, const char *fileExt) +Bool gf_service_check_mime_register(GF_InputService *ifce, const char *mimeType, const char *extList, const char *description, const char *fileExt) { const char *szExtList; char *ext, szExt[500]; @@ -1258,7 +1253,7 @@ Bool gf_term_check_extension(GF_InputService *ifce, const char *mimeType, const szExtList = gf_modules_get_option((GF_BaseInterface *)(GF_BaseInterface *)ifce, "MimeTypes", mimeType); if (!szExtList) { - gf_term_register_mime_type(ifce, mimeType, extList, description); + gf_service_register_mime(ifce, mimeType, extList, description); szExtList = gf_modules_get_option((GF_BaseInterface *)(GF_BaseInterface *)ifce, "MimeTypes", mimeType); } if (!strstr(szExtList, ifce->module_name)) return 0; @@ -1315,7 +1310,11 @@ GF_Err gf_term_service_cache_load(GF_ClientService *ns) if (sep) sep[0] = 0; for (i=0; iroot_scene, odm); } + +/*select given object when stream selection is available*/ +GF_EXPORT +void gf_term_select_service(GF_Terminal *term, GF_ObjectManager *odm, u32 service_id) +{ + if (!term || !odm || !odm->subscene) return; + if (!gf_term_check_odm(term, odm)) return; + +#ifndef GPAC_DISABLE_VRML + gf_scene_set_service_id(odm->subscene, service_id); +#endif +} + + +/*select given object when stream selection is available*/ +GF_EXPORT +void gf_term_toggle_addons(GF_Terminal *term, Bool show_addons) +{ + if (!term || !term->root_scene || !term->root_scene->is_dynamic_scene) return; +#ifndef GPAC_DISABLE_VRML + gf_scene_toggle_addons(term->root_scene, show_addons); +#endif +} + GF_EXPORT u32 gf_term_get_current_service_id(GF_Terminal *term) { @@ -164,7 +188,6 @@ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_Medi } else { info->current_time = gf_clock_time(odm->codec->ck); } - info->current_time -= odm->codec->ck->init_time; } info->current_time /= 1000; info->nb_droped = odm->codec->nb_droped; @@ -200,7 +223,7 @@ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_Medi } else if (odm->state) { u32 i, buf; GF_Clock *ck; - + ck = gf_odm_get_media_clock(odm); /*no clock means setup failed*/ if (!ck) { @@ -228,12 +251,12 @@ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_Medi info->has_profiles = (odm->flags & GF_ODM_HAS_PROFILES) ? 1 : 0; if (info->has_profiles) { info->inline_pl = (odm->flags & GF_ODM_INLINE_PROFILES) ? 1 : 0; - info->OD_pl = odm->OD_PL; + info->OD_pl = odm->OD_PL; info->scene_pl = odm->Scene_PL; info->audio_pl = odm->Audio_PL; info->visual_pl = odm->Visual_PL; info->graphics_pl = odm->Graphics_PL; - } + } if (odm->net_service) { info->service_handler = odm->net_service->ifce->module_name; @@ -259,8 +282,8 @@ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_Medi info->direct_video_memory = 1; } } - } - + } + if (odm->subscene && odm->subscene->scene_codec) { GF_BaseDecoder *dec = odm->subscene->scene_codec->decio; assert(odm->subscene->root_od==odm) ; @@ -361,7 +384,7 @@ const char *gf_term_get_world_info(GF_Terminal *term, GF_ObjectManager *scene_od info = (GF_Node*) (scene_od->subscene ? scene_od->subscene->world_info : scene_od->parentscene->world_info); } if (!info) return NULL; - + if (gf_node_get_tag(info) == TAG_SVG_title) { /*FIXME*/ //return ((SVG_titleElement *) info)->textContent; @@ -400,7 +423,7 @@ GF_Err gf_term_dump_scene(GF_Terminal *term, char *rad_name, char **filename, Bo odm = term->root_scene->root_od; } else { odm = scene_od; - if (!gf_term_check_odm(term, scene_od)) + if (!gf_term_check_odm(term, scene_od)) odm = term->root_scene->root_od; } diff --git a/src/terminal/object_manager.c b/src/terminal/object_manager.c index 4aa2ebe..5b98ac9 100644 --- a/src/terminal/object_manager.c +++ b/src/terminal/object_manager.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -56,43 +56,54 @@ GF_ObjectManager *gf_odm_new() return tmp; } +void gf_odm_reset_media_control(GF_ObjectManager *odm, Bool signal_reset) + { + #ifndef GPAC_DISABLE_VRML + u32 i; + MediaSensorStack *media_sens; + MediaControlStack *media_ctrl; + + i=0; + while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i))) { + MS_Stop(media_sens); + /*and detach from stream object*/ + media_sens->stream = NULL; + } + + i=0; + while ((media_ctrl = (MediaControlStack *)gf_list_enum(odm->mc_stack, &i))) { + if (signal_reset) + gf_odm_remove_mediacontrol(odm, media_ctrl); + media_ctrl->stream = NULL; + media_ctrl->ck = NULL; + } + #endif +} + void gf_odm_del(GF_ObjectManager *odm) { -#ifndef GPAC_DISABLE_VRML - u32 i; - MediaSensorStack *media_sens; - MediaControlStack *media_ctrl; -#endif - + if (odm->addon && (odm->addon->root_od==odm)) { + odm->addon->root_od = NULL; + odm->addon->started = 0; + } /*make sure we are not in the media queue*/ gf_term_lock_media_queue(odm->term, GF_TRUE); gf_list_del_item(odm->term->media_queue, odm); gf_term_check_connections_for_delete(odm->term, odm); gf_term_lock_media_queue(odm->term, GF_FALSE); - /*detach media object as referenced by the scene - this should ensures that any attempt to lock the ODM from the + /*detach media object as referenced by the scene - this should ensures that any attempt to lock the ODM from the compositor will fail as the media object is no longer linked to object manager*/ gf_mx_p(odm->mx); if (odm->mo) odm->mo->odm = NULL; gf_mx_v(odm->mx); - + /*relock the mutex for final object destruction*/ gf_mx_p(odm->mx); #ifndef GPAC_DISABLE_VRML - i=0; - while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i))) { - MS_Stop(media_sens); - /*and detach from stream object*/ - media_sens->stream = NULL; - } + gf_odm_reset_media_control(odm, 0); gf_list_del(odm->ms_stack); - - i=0; - while ((media_ctrl = (MediaControlStack *)gf_list_enum(odm->mc_stack, &i))) { - media_ctrl->stream = NULL; - media_ctrl->ck = NULL; - } gf_list_del(odm->mc_stack); #endif @@ -112,7 +123,7 @@ void gf_odm_del(GF_ObjectManager *odm) void gf_odm_lock(GF_ObjectManager *odm, u32 LockIt) { assert(odm); - if (LockIt) + if (LockIt) gf_mx_p(odm->mx); else gf_mx_v(odm->mx); @@ -259,7 +270,7 @@ void gf_odm_disconnect(GF_ObjectManager *odm, u32 do_remove) gf_term_lock_net(term, GF_FALSE); return; } - + /*this is the scene root OD (may be a remote OD ..) */ if (odm->term->root_scene) { GF_Event evt; @@ -314,7 +325,7 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url if (ext) sub_url = ext; } - desc = odm->net_service->ifce->GetServiceDescriptor(odm->net_service->ifce, od_type, sub_url); + desc = odm->net_service->ifce->GetServiceDescriptor(odm->net_service->ifce, od_type, sub_url); /*entry point is already setup (bad design in GPAC, happens with BIFS TS and DASH*/ if (odm->OD) { @@ -329,7 +340,7 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url } if (!desc) { - if (odm->OD && !gf_list_count(odm->OD->ESDescriptors)) + if (odm->OD && !gf_list_count(odm->OD->ESDescriptors)) return; /*if desc is NULL for a media, the media will be declared later by the service (gf_term_media_add)*/ @@ -371,7 +382,7 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url gf_odf_desc_del((GF_Descriptor *) the_iod->IPMPToolList); gf_free(the_iod); } - break; + break; case GF_ODF_OD_TAG: odm->Audio_PL = odm->Graphics_PL = odm->OD_PL = odm->Scene_PL = odm->Visual_PL = (u8) -1; odm->OD = (GF_ObjectDescriptor *)desc; @@ -382,14 +393,14 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url gf_term_message(odm->term, odm->net_service->url, "MPEG4 Service Setup Failure", GF_ODF_INVALID_DESCRIPTOR); goto err_exit; } - + gf_odm_setup_object(odm, odm->net_service); if (redirect_url && !strnicmp(redirect_url, "views://", 8)) { - + gf_scene_generate_views(odm->subscene ? odm->subscene : odm->parentscene , (char *) redirect_url + 8, (char*)odm->parentscene ? odm->parentscene->root_od->net_service->url : NULL); } - /*it may happen that this object was inserted in a dynamic scene from a service through a URL redirect. In which case, + /*it may happen that this object was inserted in a dynamic scene from a service through a URL redirect. In which case, the scene regeneration might not have been completed since the redirection was not done yet - force a scene regenerate*/ else if (odm->parentscene && odm->parentscene->is_dynamic_scene) gf_scene_regenerate(odm->parentscene); @@ -502,26 +513,36 @@ GF_Err ODM_ValidateOD(GF_ObjectManager *odm, Bool *hasInline) case GF_STREAM_OD: nb_od++; break; - case GF_STREAM_OCR: - nb_ocr++; + case GF_STREAM_OCR: + nb_ocr++; break; - case GF_STREAM_SCENE: + case GF_STREAM_SCENE: switch (esd->decoderConfig->objectTypeIndication) { case GPAC_OTI_SCENE_AFX: case GPAC_OTI_SCENE_SYNTHESIZED_TEXTURE: break; default: - nb_scene++; + nb_scene++; break; } break; - case GF_STREAM_MPEG7: nb_mp7++; break; - case GF_STREAM_IPMP: nb_ipmp++; break; - case GF_STREAM_OCI: nb_oci++; break; - case GF_STREAM_MPEGJ: nb_mpj++; break; - case GF_STREAM_PRIVATE_SCENE: nb_scene++; break; + case GF_STREAM_MPEG7: + nb_mp7++; + break; + case GF_STREAM_IPMP: + nb_ipmp++; + break; + case GF_STREAM_OCI: + nb_oci++; + break; + case GF_STREAM_MPEGJ: + nb_mpj++; + break; + case GF_STREAM_PRIVATE_SCENE: + nb_scene++; + break; /*all other streams shall not be mixed: text, video, audio, interaction, font*/ - default: + default: if (esd->decoderConfig->streamType!=prev_st) nb_other++; prev_st = esd->decoderConfig->streamType; break; @@ -568,7 +589,7 @@ GF_Err ODM_ValidateOD(GF_ObjectManager *odm, Bool *hasInline) while ( (esd = (GF_ESD *)gf_list_enum(odm->OD->ESDescriptors, &i)) ) { switch (esd->decoderConfig->streamType) { case GF_STREAM_PRIVATE_SCENE: - case GF_STREAM_SCENE: + case GF_STREAM_SCENE: base_scene = esd; break; default: @@ -576,7 +597,7 @@ GF_Err ODM_ValidateOD(GF_ObjectManager *odm, Bool *hasInline) } if (base_scene) break; } - + /*we have a scene stream without dependancies, this is an inline*/ if (!base_scene || !base_scene->dependsOnESID) return GF_OK; @@ -640,9 +661,9 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) } odm->net_service = serv; assert(odm->OD); - if (!odm->OD->URLString) + if (!odm->OD->URLString) odm->net_service->nb_odm_users++; - } + } /*if this is a remote OD, we need a new manager and a new service...*/ assert(odm->OD); if (odm->OD->URLString) { @@ -657,7 +678,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) odm->OD = NULL; odm->net_service = NULL; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Object redirection to %s (MO %08x)\n", url, odm->mo)); - + /*if object is a scene, create the inline before connecting the object. This is needed in irder to register the nodes using the resource for event propagation (stored at the inline level) @@ -703,7 +724,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) odm->flags |= GF_ODM_INHERIT_TIMELINE; } - /*if there is a BIFS stream in the OD, we need an GF_Scene (except if we already + /*if there is a BIFS stream in the OD, we need an GF_Scene (except if we already have one, which means this is the first IOD)*/ if (hasInline && !odm->subscene) { odm->subscene = gf_scene_new(odm->parentscene); @@ -738,7 +759,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) } odm->state = GF_ODM_STATE_STOP; gf_odm_lock(odm, 0); - } + } /*setup mediaobject info except for top-level OD*/ if (odm->parentscene) { GF_Event evt; @@ -768,7 +789,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) GF_Event evt; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[ODM] Root object connected !\n", odm->net_service->url)); - + gf_term_lock_net(odm->term, GF_FALSE); evt.type = GF_EVENT_CONNECT; @@ -790,8 +811,8 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) else if (odm->ocr_codec) { gf_odm_start(odm, 0); } - /*case 3: if the object is inserted from a broadcast, start it if not already done. This covers cases where the scene (BIFS, LASeR) and - the media (images) are both carrouseled and the carrousels are interleaved. If we wait for the scene to trigger a PLAY, we will likely + /*case 3: if the object is inserted from a broadcast, start it if not already done. This covers cases where the scene (BIFS, LASeR) and + the media (images) are both carrouseled and the carrousels are interleaved. If we wait for the scene to trigger a PLAY, we will likely have to wait for an entire image carousel period to start filling the buffers, which is sub-optimal we also force a prefetch for object declared outside the OD stream to make sure we don't loose any data before object declaration and play as can be the case with MPEG2 TS (first video packet right after the PMT) - this should be refined*/ @@ -812,12 +833,12 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) gf_odm_start(odm, 2); } } - + /*for objects inserted by user (subs & co), auto select*/ - if (odm->parentscene && odm->parentscene->is_dynamic_scene - && (odm->OD->objectDescriptorID==GF_MEDIA_EXTERNAL_ID) - && (odm->flags & GF_ODM_REMOTE_OD) - ) { + if (odm->parentscene && odm->parentscene->is_dynamic_scene + && (odm->OD->objectDescriptorID==GF_MEDIA_EXTERNAL_ID) + && (odm->flags & GF_ODM_REMOTE_OD) + ) { GF_Event evt; if (odm->OD_PL) { gf_scene_select_object(odm->parentscene, odm); @@ -834,7 +855,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) } return; } - + if (odm->parentscene==odm->term->root_scene) { gf_term_lock_net(odm->term, GF_FALSE); @@ -844,6 +865,14 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) } } + /*if object codec is prefered one, auto select*/ + if (odm->parentscene && odm->parentscene->is_dynamic_scene + && odm->codec && (odm->codec->oti==odm->term->prefered_audio_codec_oti) + && (odm->parentscene->selected_service_id == odm->OD->ServiceID) + ) { + gf_scene_select_object(odm->parentscene, odm); + } + gf_term_lock_net(odm->term, GF_FALSE); } @@ -853,7 +882,7 @@ void ODM_CheckChannelService(GF_Channel *ch) { if (ch->service == ch->odm->net_service) return; /*if the stream has created a service check if close is needed or not*/ - if (ch->esd->URLString && !ch->service->nb_ch_users) + if (ch->esd->URLString && !ch->service->nb_ch_users) gf_term_close_service(ch->odm->term, ch->service); } @@ -893,7 +922,7 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser while (odm_par) { if (odm_par->subscene->scene_codec) ck = odm_par->subscene->scene_codec->ck; - else + else ck = odm_par->subscene->dyn_ck; if (ck) break; @@ -910,7 +939,7 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser scene = odm->subscene ? odm->subscene : odm->parentscene; ck_namespace = odm->net_service->Clocks; - /*little trick for non-OD addressing: if object is a remote one, and service owner already has clocks, + /*little trick for non-OD addressing: if object is a remote one, and service owner already has clocks, override OCR. This will solve addressing like file.avi#audio and file.avi#video*/ if (!esd->OCRESID && (odm->flags & GF_ODM_REMOTE_OD) && (gf_list_count(ck_namespace)==1) ) { ck = (GF_Clock*)gf_list_get(ck_namespace, 0); @@ -921,8 +950,10 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser GF_ObjectManager *parent_od = odm->parentscene->root_od; if (parent_od->net_service && (gf_list_count(parent_od->net_service->Clocks)==1)) { ck = (GF_Clock*)gf_list_get(parent_od->net_service->Clocks, 0); - esd->OCRESID = ck->clockID; - goto clock_setup; + if (!odm->OD->ServiceID || (odm->OD->ServiceID==ck->service_id)) { + esd->OCRESID = ck->clockID; + goto clock_setup; + } } } @@ -958,6 +989,7 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser ck = gf_clock_attach(ck_namespace, scene, clockID, esd->ESID, flag); if (!ck) return GF_OUT_OF_MEM; esd->OCRESID = ck->clockID; + ck->service_id = odm->OD->ServiceID; /*special case for non-dynamic scenes forcing clock share of all subscene, we assign the parent scene clock to the first clock created in the sunscenes*/ if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline && !scene->root_od->parentscene->dyn_ck) @@ -986,7 +1018,7 @@ clock_setup: if (! odm->subscene->od_codec) { odm->subscene->od_codec = gf_codec_new(odm, esd, odm->OD_PL, &e); if (!e) gf_term_add_codec(odm->term, odm->subscene->od_codec); - } + } dec = odm->subscene->od_codec; break; case GF_STREAM_OCR: @@ -1035,7 +1067,7 @@ clock_setup: dec = odm->codec; break; - /*interaction stream*/ + /*interaction stream*/ #ifndef GPAC_DISABLE_VRML case GF_STREAM_INTERACT: if (!odm->codec) { @@ -1063,7 +1095,7 @@ clock_setup: } dec = odm->subscene->scene_codec; } else { - /*this is a bit tricky: the scene decoder needs to be called with the dummy streams of this + /*this is a bit tricky: the scene decoder needs to be called with the dummy streams of this object, so we associate the main decoder to this object*/ odm->codec = dec = gf_codec_use_codec(odm->parentscene->scene_codec, odm); gf_term_add_codec(odm->term, odm->codec); @@ -1103,7 +1135,7 @@ clock_setup: } } } - + ch->es_state = GF_ESM_ES_SETUP; ch->odm = odm; @@ -1136,16 +1168,16 @@ clock_setup: /*service redirection*/ if (esd->URLString) { GF_ChannelSetup *cs; - /*here we have a pb with the MPEG4 model: streams are supposed to be attachable as soon as the OD + /*here we have a pb with the MPEG4 model: streams are supposed to be attachable as soon as the OD update is received, but this is not true with ESD URLs, where service setup may take some time (file - downloading, authentification, etc...). We therefore need to wait for the service connect response before + downloading, authentification, etc...). We therefore need to wait for the service connect response before setting up the channel...*/ cs = (GF_ChannelSetup*)gf_malloc(sizeof(GF_ChannelSetup)); cs->ch = ch; cs->dec = dec; /*HACK: special case when OD resources are statically described in the ESD itself (ISMA streaming)*/ - if (dec && (ch->esd->decoderConfig->streamType==GF_STREAM_OD) && strstr(ch->esd->URLString, "data:application/mpeg4-od-au;") ) + if (dec && (ch->esd->decoderConfig->streamType==GF_STREAM_OD) && strstr(ch->esd->URLString, "data:application/mpeg4-od-au;") ) dec->flags |= GF_ESM_CODEC_IS_STATIC_OD; gf_term_lock_net(odm->term, 1); @@ -1201,7 +1233,7 @@ GF_Err gf_odm_post_es_setup(GF_Channel *ch, GF_Codec *dec, GF_Err had_err) network config...*/ e = ch->service->ifce->ConnectChannel(ch->service->ifce, ch, szURL, ch->esd->decoderConfig->upstream); - /*special case (not really specified in specs ...): if the stream is not found and is an Interaction + /*special case (not really specified in specs ...): if the stream is not found and is an Interaction one (ie, used by an InputSensor), consider this means the stream shall be generated by the IS device*/ if ((e==GF_STREAM_NOT_FOUND) && (ch->esd->decoderConfig->streamType==GF_STREAM_INTERACT)) e = GF_OK; } else { @@ -1227,7 +1259,7 @@ GF_Err gf_odm_post_es_setup(GF_Channel *ch, GF_Codec *dec, GF_Err had_err) } gf_list_del_item(ch->odm->channels, ch); /*disconnect*/ - ch->service->ifce->DisconnectChannel(ch->service->ifce, ch); + ch->service->ifce->DisconnectChannel(ch->service->ifce, ch); if (ch->esd->URLString) { assert(ch->service->nb_ch_users); ch->service->nb_ch_users--; @@ -1285,7 +1317,7 @@ void ODM_DeleteChannel(GF_ObjectManager *odm, GF_Channel *ch) for (i=0; ichannels, i); if (ch2 == ch) { - ch_pos = i; + ch_pos = i; if (ck) continue; break; } @@ -1297,7 +1329,7 @@ void ODM_DeleteChannel(GF_ObjectManager *odm, GF_Channel *ch) /*remove from the codec*/ count = 0; - if (!count && odm->codec) + if (!count && odm->codec) count = gf_codec_remove_channel(odm->codec, ch); if (!count && odm->ocr_codec) count = gf_codec_remove_channel(odm->ocr_codec, ch); @@ -1310,7 +1342,7 @@ void ODM_DeleteChannel(GF_ObjectManager *odm, GF_Channel *ch) if (!count) count = gf_codec_remove_channel(odm->subscene->od_codec, ch); } if (ch->service) { - ch->service->ifce->DisconnectChannel(ch->service->ifce, ch); + ch->service->ifce->DisconnectChannel(ch->service->ifce, ch); if (ch->esd->URLString) { assert(ch->service->nb_ch_users); ch->service->nb_ch_users--; @@ -1349,7 +1381,7 @@ esd_found: gf_odf_desc_del((GF_Descriptor *) esd); } -/*this is the tricky part: make sure the net is locked before doing anything since an async service +/*this is the tricky part: make sure the net is locked before doing anything since an async service reply could destroy the object we're queuing for play*/ void gf_odm_start(GF_ObjectManager *odm, u32 media_queue_state) { @@ -1389,10 +1421,10 @@ void gf_odm_start(GF_ObjectManager *odm, u32 media_queue_state) skip_register = 0; } - //wait for end of setup + //do not issue a play request, wait for end of setup else if (odm->state==GF_ODM_STATE_IN_SETUP) { media_queue_state=0; - skip_register = 0; + skip_register = 1; } /*object is already started - only reinsert in media queue if this function was called on an object already in the queue*/ else { @@ -1456,7 +1488,7 @@ void gf_odm_play(GF_ObjectManager *odm) /*send play command*/ memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = GF_NET_CHAN_PLAY; - + if (odm->flags & GF_ODM_INITIAL_BROADCAST_PLAY) { odm->flags &= ~GF_ODM_INITIAL_BROADCAST_PLAY; com.play.initial_broadcast_play = 1; @@ -1484,6 +1516,7 @@ void gf_odm_play(GF_ObjectManager *odm) com.base.on_channel = ch; com.play.speed = 1.0; + /*play from requested time (seeking or non-mpeg4 media control)*/ if (odm->media_start_time && !ch->clock->clock_init) { ck_time = (Double) (s64) odm->media_start_time; @@ -1495,20 +1528,20 @@ void gf_odm_play(GF_ObjectManager *odm) } /*play from current time*/ else { - ck_time = gf_clock_time(ch->clock); if (odm->parentscene && odm->parentscene->root_od->addon) { - ck_time = gf_scene_adjust_time_for_addon(odm->parentscene, (u32) ck_time, odm->parentscene->root_od->addon); + ck_time = gf_scene_adjust_time_for_addon(odm->parentscene, gf_clock_time(ch->clock), odm->parentscene->root_od->addon, &com.play.is_timestamp_based); if (odm->scalable_addon) { //this is a scalable extension to an object in the parent scene gf_scene_select_scalable_addon(odm->parentscene->root_od->parentscene, odm); } - + } else { + ck_time = gf_clock_time(ch->clock); + ck_time /= 1000; } - ck_time /= 1000; /*handle initial start - MPEG-4 is a bit annoying here, streams are not started through OD but through - scene nodes. If the stream runs on the BIFS/OD clock, the clock is already started at this point and we're + scene nodes. If the stream runs on the BIFS/OD clock, the clock is already started at this point and we're sure to get at least a one-frame delay in PLAY, so just remove it - note we're generous but this shouldn't hurt*/ if (ck_time<=0.5) ck_time = 0; } @@ -1518,14 +1551,16 @@ void gf_odm_play(GF_ObjectManager *odm) com.play.end_range = (s64) range_end / 1000.0; } else { if (!odm->subscene && gf_odm_shares_clock(odm->parentscene->root_od, ch->clock) - && (odm->parentscene->root_od->media_stop_time != odm->parentscene->root_od->duration) - ) { + && (odm->parentscene->root_od->media_stop_time != odm->parentscene->root_od->duration) + ) { com.play.end_range = (s64) odm->parentscene->root_od->media_stop_time / 1000.0; } else { com.play.end_range = -1; } } + com.play.speed = ch->clock->speed; + #ifndef GPAC_DISABLE_VRML /*if object shares parent scene clock, do not use media control*/ ctrl = parent_ck ? NULL : gf_odm_get_mediacontrol(odm); @@ -1540,8 +1575,10 @@ void gf_odm_play(GF_ObjectManager *odm) if (ctrl->paused) media_control_paused = 1; gf_clock_set_speed(ch->clock, ctrl->control->mediaSpeed); + if (odm->mo) odm->mo->speed = ctrl->control->mediaSpeed; + /*if requested seek time AND media control, adjust start range to current play time*/ - if (odm->media_start_time) { + if ((com.play.speed>=0) && odm->media_start_time) { if ((com.play.start_range>=0) && (com.play.end_range>com.play.start_range)) { if (ctrl->control->loop) { Double active_dur = com.play.end_range - com.play.start_range; @@ -1558,9 +1595,13 @@ void gf_odm_play(GF_ObjectManager *odm) /*full object playback*/ if (com.play.end_range<=0) { - odm->media_stop_time = odm->subscene ? 0 : odm->duration; + if (com.play.speed<0) { + odm->media_stop_time = 0; + } else { + odm->media_stop_time = odm->subscene ? 0 : odm->duration; + } } else { - /*segment playback - since our timing is in ms whereas segment ranges are double precision, + /*segment playback - since our timing is in ms whereas segment ranges are double precision, make sure we have a LARGER range in ms, otherwise media sensors won't deactivate properly*/ odm->media_stop_time = (u64) ceil(1000 * com.play.end_range); } @@ -1569,7 +1610,7 @@ void gf_odm_play(GF_ObjectManager *odm) if (!ch->service || (skip_od_st && (ch->esd->decoderConfig->streamType==GF_STREAM_OD))) { Bool gf_es_owns_clock(GF_Channel *ch); - if (gf_es_owns_clock(ch) ) + if (gf_es_owns_clock(ch) ) gf_clock_set_time(ch->clock, (u32) (com.play.start_range*1000)); ch->IsClockInit = 1; @@ -1584,6 +1625,9 @@ void gf_odm_play(GF_ObjectManager *odm) } // odm->media_start_time = 0; + if (odm->parentscene && odm->parentscene->root_od->addon) { + odm->parentscene->root_od->addon->started = 1; + } if (nb_failure) { odm->state = GF_ODM_STATE_BLOCKED; return; @@ -1614,7 +1658,7 @@ void gf_odm_play(GF_ObjectManager *odm) gf_odm_pause(odm); } -Bool gf_odm_owns_clock(GF_ObjectManager *odm, GF_Clock *ck) +Bool gf_odm_owns_clock(GF_ObjectManager *odm, GF_Clock *ck) { u32 i, j; GF_ObjectManager *od; @@ -1643,7 +1687,7 @@ void gf_odm_stop(GF_ObjectManager *odm, Bool force_close) #endif GF_NetworkCommand com; - + if (!odm->state) return; #if 0 @@ -1651,7 +1695,7 @@ void gf_odm_stop(GF_ObjectManager *odm, Bool force_close) comes from the scene*/ if (odm->no_time_ctrl && !force_close) { GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[ODM%d] - broadcast detected, ignoring Stop from scene\n", odm->OD->objectDescriptorID); - return; + return; } #endif @@ -1725,7 +1769,7 @@ void gf_odm_stop(GF_ObjectManager *odm, Bool force_close) evt.channel = ch; ch->ipmp_tool->process(ch->ipmp_tool, &evt); } - + if (ch->service) { com.base.on_channel = ch; gf_term_service_command(ch->service, &com); @@ -1752,7 +1796,7 @@ void gf_odm_stop(GF_ObjectManager *odm, Bool force_close) #ifndef GPAC_DISABLE_VRML /*reset media sensor(s)*/ i = 0; - while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i))){ + while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i))) { MS_Stop(media_sens); } /*reset media control state*/ @@ -1795,12 +1839,14 @@ void gf_odm_on_eos(GF_ObjectManager *odm, GF_Channel *on_channel) } else { if (nb_eos != count) return; } + + gf_term_service_media_event(odm, GF_EVENT_MEDIA_LOAD_DONE); - + if (odm->codec && (on_channel->esd->decoderConfig->streamType==odm->codec->type)) { gf_codec_set_status(odm->codec, GF_ESM_CODEC_EOS); return; - } + } if (on_channel->esd->decoderConfig->streamType==GF_STREAM_OCR) { gf_codec_set_status(odm->ocr_codec, GF_ESM_CODEC_EOS); return; @@ -1834,8 +1880,8 @@ void gf_odm_set_duration(GF_ObjectManager *odm, GF_Channel *ch, u64 stream_durat odm->duration = stream_duration; } else if (odm->subscene && odm->subscene->scene_codec) { //if (gf_list_find(odm->subscene->scene_codec->inChannels, ch) >= 0) { - if (odm->duration/1000 != stream_duration/1000) - odm->duration = stream_duration; + if (odm->duration/1000 != stream_duration/1000) + odm->duration = stream_duration; //} } @@ -1946,25 +1992,29 @@ void gf_odm_resume(GF_ObjectManager *odm) if (odm->oci_codec) gf_term_start_codec(odm->oci_codec, 1); #endif +#ifndef GPAC_DISABLE_VRML ctrl = gf_odm_get_mediacontrol(odm); +#endif com.command_type = GF_NET_CHAN_RESUME; i=0; - while ((ch = (GF_Channel*)gf_list_enum(odm->channels, &i)) ){ + while ((ch = (GF_Channel*)gf_list_enum(odm->channels, &i)) ) { gf_clock_resume(ch->clock); com.base.on_channel = ch; gf_term_service_command(ch->service, &com); GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[ODM%d] CH%d: At OTB %u requesting RESUME (clock init %d)\n", odm->OD->objectDescriptorID, ch->esd->ESID, gf_clock_time(ch->clock), ch->clock->clock_init )); +#ifndef GPAC_DISABLE_VRML /*override speed with MC*/ if (ctrl) { gf_clock_set_speed(ch->clock, ctrl->control->mediaSpeed); } +#endif } #ifndef GPAC_DISABLE_VRML /*mediaSensor shall generate isActive TRUE when resumed*/ i=0; - while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i)) ){ + while ((media_sens = (MediaSensorStack *)gf_list_enum(odm->ms_stack, &i)) ) { if (media_sens && !media_sens->sensor->isActive) { media_sens->sensor->isActive = 1; gf_node_event_out_str((GF_Node *) media_sens->sensor, "isActive"); @@ -1996,7 +2046,7 @@ GF_Segment *gf_odm_find_segment(GF_ObjectManager *odm, char *descName) GF_Segment *desc; u32 i = 0; if (!odm->OD) return NULL; - while ( (desc = (GF_Segment *)gf_list_enum(odm->OD->OCIDescriptors, &i)) ){ + while ( (desc = (GF_Segment *)gf_list_enum(odm->OD->OCIDescriptors, &i)) ) { if (desc->tag != GF_ODF_SEGMENT_TAG) continue; if (!stricmp(desc->SegmentName, descName)) return desc; } @@ -2043,7 +2093,7 @@ void gf_odm_init_segments(GF_ObjectManager *odm, GF_List *list, MFURL *url) first_seg = gf_odm_find_segment(odm, seg1); if (!first_seg) continue; last_seg = gf_odm_find_segment(odm, seg2); - } + } /*segment open range*/ else if ((sep = strstr(seg_url, "+")) ) { sep[0] = 0; @@ -2051,7 +2101,7 @@ void gf_odm_init_segments(GF_ObjectManager *odm, GF_List *list, MFURL *url) first_seg = gf_odm_find_segment(odm, seg_url); if (!first_seg) continue; last_seg = NULL; - } + } /*single segment*/ else { first_seg = gf_odm_find_segment(odm, seg_url); @@ -2078,7 +2128,7 @@ void gf_odm_signal_eos(GF_ObjectManager *odm) if (odm->parentscene && (odm->parentscene != odm->term->root_scene) ) { GF_ObjectManager *root = odm->parentscene->root_od; Bool is_over = 0; - + if (!gf_scene_check_clocks(root->net_service, root->subscene)) return; if (root->subscene->is_dynamic_scene) is_over = 1; diff --git a/src/terminal/scene.c b/src/terminal/scene.c index 8557116..e0d932b 100644 --- a/src/terminal/scene.c +++ b/src/terminal/scene.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -69,7 +69,7 @@ void gf_storage_save(M_Storage *storage); static void inline_on_media_event(GF_Scene *scene, u32 type) { - gf_term_service_media_event(scene->scene_codec->odm, type); + gf_term_service_media_event(scene->scene_codec->odm, type); } GF_EXPORT @@ -97,10 +97,10 @@ GF_Scene *gf_scene_new(GF_Scene *parentScene) #ifndef GPAC_DISABLE_VRML tmp->extern_protos = gf_list_new(); gf_sg_set_proto_loader(tmp->graph, gf_inline_get_proto_lib); - + tmp->storages = gf_list_new(); tmp->keynavigators = gf_list_new(); - + #endif tmp->on_media_event = inline_on_media_event; return tmp; @@ -195,7 +195,7 @@ void gf_scene_disconnect(GF_Scene *scene, Bool for_shutdown) GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Scene] disconnecting\n")); gf_term_lock_compositor(scene->root_od->term, GF_TRUE); - + /*force unregistering of inline nodes (for safety)*/ if (for_shutdown && scene->root_od->mo) { /*reset private stack of all inline nodes still registered*/ @@ -226,17 +226,17 @@ void gf_scene_disconnect(GF_Scene *scene, Bool for_shutdown) GF_Node *n = (GF_Node *)gf_event_target_get_node(gf_mo_event_target_get(obj, 0)); if (n) { switch (gf_node_get_tag(n)) { - case TAG_MPEG4_InputSensor: - { - M_InputSensor* is = (M_InputSensor*)n; - is->enabled = 0; - InputSensorModified(n); - break; - } + case TAG_MPEG4_InputSensor: + { + M_InputSensor* is = (M_InputSensor*)n; + is->enabled = 0; + InputSensorModified(n); + break; + } } } gf_mo_event_target_remove_by_index(obj, 0); - } + } } } } @@ -254,7 +254,7 @@ void gf_scene_disconnect(GF_Scene *scene, Bool for_shutdown) gf_list_rem(scene->storages, 0); if (storage->_auto) gf_storage_save(storage); } -#endif +#endif if (scene->root_od->term->root_scene == scene) { gf_sc_set_scene(scene->root_od->term->compositor, NULL); @@ -287,7 +287,7 @@ void gf_scene_disconnect(GF_Scene *scene, Bool for_shutdown) } } else { while (gf_list_count(scene->resources)) { - odm = (GF_ObjectManager *)gf_list_get(scene->resources, 0); + odm = (GF_ObjectManager *)gf_list_get(scene->resources, 0); gf_odm_disconnect(odm, (for_shutdown || !scene->static_media_ressources) ? 2 : 0); } #ifndef GPAC_DISABLE_VRML @@ -414,12 +414,12 @@ void gf_scene_remove_object(GF_Scene *scene, GF_ObjectManager *odm, u32 for_shut i=0; while ((obj = (GF_MediaObject*)gf_list_enum(scene->scene_objects, &i))) { if ( - /*assigned object*/ - (obj->odm==odm) || - /*remote OD*/ - ((obj->OD_ID!=GF_MEDIA_EXTERNAL_ID) && odm->OD && (obj->OD_ID == odm->OD->objectDescriptorID) ) || - /*dynamic OD*/ - (obj->URLs.count && odm->OD && odm->OD->URLString && !stricmp(obj->URLs.vals[0].url, odm->OD->URLString)) + /*assigned object*/ + (obj->odm==odm) || + /*remote OD*/ + ((obj->OD_ID!=GF_MEDIA_EXTERNAL_ID) && odm->OD && (obj->OD_ID == odm->OD->objectDescriptorID) ) || + /*dynamic OD*/ + (obj->URLs.count && odm->OD && odm->OD->URLString && !stricmp(obj->URLs.vals[0].url, odm->OD->URLString)) ) { u32 discard_obj = 0; gf_odm_lock(odm, 1); @@ -458,7 +458,7 @@ void gf_scene_remove_object(GF_Scene *scene, GF_ObjectManager *odm, u32 for_shut /*discard media object*/ else if (for_shutdown==2) discard_obj = 1; - + /*reset private stack of all inline nodes still registered*/ if (discard_obj) { while (gf_mo_event_target_count(obj)) { @@ -568,7 +568,7 @@ void gf_scene_notify_event(GF_Scene *scene, u32 event_type, GF_Node *n, void *_e evt.detail = 1; break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Group: + case TAG_X3D_Group: evt.detail = 2; break; #endif @@ -592,9 +592,9 @@ void gf_scene_notify_event(GF_Scene *scene, u32 event_type, GF_Node *n, void *_e gf_sc_queue_dom_event(scene->root_od->term->compositor, root, dom_event); } } - + count=scene->root_od->mo ? gf_mo_event_target_count(scene->root_od->mo) : 0; - for (i=0;iroot_od->mo, i)); if (no_queueing) { gf_dom_event_fire(an, dom_event); @@ -624,10 +624,10 @@ void gf_scene_attach_to_compositor(GF_Scene *scene) if (scene->fragment_uri) { gf_free(scene->fragment_uri); scene->fragment_uri = NULL; - } - url = strchr(scene->root_od->net_service->url, '#'); - if (url) scene->fragment_uri = gf_strdup(url+1); - } + } + url = strchr(scene->root_od->net_service->url, '#'); + if (url) scene->fragment_uri = gf_strdup(url+1); + } /*main display scene, setup compositor*/ if (scene->root_od->term->root_scene == scene) { @@ -636,7 +636,7 @@ void gf_scene_attach_to_compositor(GF_Scene *scene) else { u32 i, count; count = scene->root_od->mo ? gf_mo_event_target_count(scene->root_od->mo) : 0; - for (i=0;iroot_od->mo, i))); } gf_term_invalidate_compositor(scene->root_od->term); @@ -686,10 +686,10 @@ GF_MediaObject *gf_scene_get_media_object_ex(GF_Scene *scene, MFURL *url, u32 ob gf_term_lock_net(scene->root_od->term, GF_TRUE); /*we may have overriden the time lines in parent scene, thus all objects in this scene have the same clock*/ - if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline) + if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline) lock_timelines = GF_TRUE; - /*the first pass is needed to detect objects already inserted and registered with the given nodes, regardless of + /*the first pass is needed to detect objects already inserted and registered with the given nodes, regardless of the force_new_if_not_attached flag. This ty^pically occurs when a resource is first created then linked to an animation/inline*/ restart: obj = NULL; @@ -698,19 +698,19 @@ restart: Bool odm_matches = GF_FALSE; if ( - /*regular OD scheme*/ - (OD_ID != GF_MEDIA_EXTERNAL_ID && (obj->OD_ID==OD_ID)) - || - /*dynamic OD scheme - !! obj->OD_ID may different from GF_MEDIA_EXTERNAL_ID when ODs are - directly added to the terminal by the service*/ - ((OD_ID == GF_MEDIA_EXTERNAL_ID) - /*if object type unknown (media control, media sensor), return first obj matching URL - otherwise check types*/ - && is_match_obj_type(obj->type, obj_type_hint) - /*locate sub-url in given one and handle fragments (viewpoint/segments/...)*/ - && gf_mo_is_same_url(obj, url, &keep_fragment, obj_type_hint) - ) - ) { + /*regular OD scheme*/ + (OD_ID != GF_MEDIA_EXTERNAL_ID && (obj->OD_ID==OD_ID)) + || + /*dynamic OD scheme - !! obj->OD_ID may different from GF_MEDIA_EXTERNAL_ID when ODs are + directly added to the terminal by the service*/ + ((OD_ID == GF_MEDIA_EXTERNAL_ID) + /*if object type unknown (media control, media sensor), return first obj matching URL + otherwise check types*/ + && is_match_obj_type(obj->type, obj_type_hint) + /*locate sub-url in given one and handle fragments (viewpoint/segments/...)*/ + && gf_mo_is_same_url(obj, url, &keep_fragment, obj_type_hint) + ) + ) { odm_matches = GF_TRUE; } @@ -719,7 +719,7 @@ restart: if (obj->odm) { Bool can_reuse = GF_TRUE; Bool timeline_locked = (obj->odm->flags & GF_ODM_INHERIT_TIMELINE) ? GF_TRUE : GF_FALSE; - + //addon object always share the timeline if (obj->odm->addon || obj->odm->parentscene->root_od->addon) timeline_locked = lock_timelines = 1; @@ -731,9 +731,9 @@ restart: if (obj->odm->flags & GF_ODM_DESTROYED) can_reuse = GF_FALSE; else if (obj->odm->action_type == GF_ODM_ACTION_DELETE) { /*check if object is being destroyed (no longer in the queue)*/ - if (gf_list_del_item(scene->root_od->term->media_queue, obj->odm)<0) { + if (gf_list_del_item(scene->root_od->term->media_queue, obj->odm)<0) { can_reuse = GF_FALSE; - } + } /*otherwise reuse object, discard current destroy command*/ else { obj->odm->action_type = GF_ODM_ACTION_PLAY; @@ -778,9 +778,9 @@ restart: original_parent_scene = (GF_Scene*) gf_sg_get_private(gf_node_get_graph(node)); } - + /*if animation stream object, remember originating node - !! FIXME - this should be cleaned up !! + !! FIXME - this should be cleaned up !! */ if (obj->type == GF_MEDIA_OBJECT_UPDATES) obj->node_ptr = node; @@ -796,7 +796,7 @@ restart: } if (obj->odm==NULL) { - gf_list_del_item(scene->scene_objects, obj); + gf_list_del_item(scene->scene_objects, obj); gf_mo_del(obj); gf_term_lock_net(scene->root_od->term, GF_FALSE); return NULL; @@ -857,7 +857,7 @@ existing: else if (odm->codec->type == GF_STREAM_AUDIO) odm->mo->type = GF_MEDIA_OBJECT_AUDIO; else if (odm->codec->type == GF_STREAM_TEXT) odm->mo->type = GF_MEDIA_OBJECT_TEXT; else if (odm->codec->type == GF_STREAM_SCENE) odm->mo->type = GF_MEDIA_OBJECT_UPDATES; - + /*update info*/ gf_mo_update_caps(odm->mo); /*media object playback has already been requested by the scene, trigger media start*/ @@ -865,7 +865,7 @@ existing: gf_odm_start(odm, 0); if (odm->mo->speed != FIX_ONE) gf_odm_set_speed(odm, odm->mo->speed); } - if ((odm->mo->type==GF_MEDIA_OBJECT_VIDEO) && scene->is_dynamic_scene) { + if ((odm->mo->type==GF_MEDIA_OBJECT_VIDEO) && scene->is_dynamic_scene && !odm->parentscene->root_od->addon) { gf_scene_force_size_to_video(scene, odm->mo); } /*invalidate scene for all nodes using the OD*/ @@ -902,7 +902,7 @@ void gf_scene_set_duration(GF_Scene *scene) dur = (Double) (s64) scene->duration; dur /= 1000; - + #ifndef GPAC_DISABLE_VRML i=0; while ((media_sens = (MediaSensorStack*)gf_list_enum(scene->root_od->ms_stack, &i))) { @@ -1048,12 +1048,18 @@ static void set_media_url(GF_Scene *scene, SFURL *media_url, GF_Node *node, MFU u32 w, h; SFURL *sfu; Bool url_changed = 0; + /*scene url is not set, find the first one*/ - if (!media_url->OD_ID) { - u32 i=0; + if (!media_url->OD_ID ) { + u32 count, i; GF_ObjectManager *odm = NULL; - while ((odm = (GF_ObjectManager*)gf_list_enum(scene->resources, &i))) { - if (odm->scalable_addon) + count = gf_list_count(scene->resources); + for (i=0;iresources, i); + if (odm->scalable_addon || !odm->OD) + continue; + + if (scene->selected_service_id && (scene->selected_service_id != odm->OD->ServiceID)) continue; if (type==GF_STREAM_TEXT) { @@ -1062,11 +1068,23 @@ static void set_media_url(GF_Scene *scene, SFURL *media_url, GF_Node *node, MFU else if (type==GF_STREAM_SCENE) { if (!odm->subscene || (!odm->subscene->scene_codec && !odm->subscene->is_dynamic_scene) ) continue; - if (odm->subscene->root_od->addon) + if (odm->subscene->root_od->addon) continue; } else { if (!odm->codec || (odm->codec->type!=type)) continue; + + //browse from this ODM on untill we find an object with the desired OTI (if any) + if ((type==GF_STREAM_AUDIO) && odm->term->prefered_audio_codec_oti) { + u32 j; + for (j=i; jresources, j); + if (an_odm->codec && (an_odm->codec->oti==odm->term->prefered_audio_codec_oti)) { + odm = an_odm; + break; + } + } + } } media_url->OD_ID = odm->OD->objectDescriptorID; @@ -1140,7 +1158,7 @@ void gf_scene_regenerate(GF_Scene *scene) gf_sc_lock(scene->root_od->term->compositor, 1); ac = (M_AudioClip *) gf_sg_find_node_by_name(scene->graph, "DYN_AUDIO"); - + /*this is the first time, generate a scene graph*/ if (!ac) { /*create an OrderedGroup*/ @@ -1170,7 +1188,7 @@ void gf_scene_regenerate(GF_Scene *scene) gf_node_list_add_child( &((GF_ParentNode *)n1)->children, n2); gf_node_register(n2, n1); n1 = n2; - + /*create a shape and bitmap node*/ n2 = is_create_node(scene->graph, TAG_MPEG4_Shape, NULL); gf_node_list_add_child( &((GF_ParentNode *)n1)->children, n2); @@ -1234,7 +1252,7 @@ void gf_scene_regenerate(GF_Scene *scene) set_media_url(scene, &scene->dims_url, (GF_Node*)dims, &dims->url, GF_STREAM_SCENE); gf_sc_lock(scene->root_od->term->compositor, 0); - + /*disconnect to force resize*/ if (scene->root_od->term->root_scene == scene) { gf_sc_set_scene(scene->root_od->term->compositor, scene->graph); @@ -1248,6 +1266,25 @@ void gf_scene_regenerate(GF_Scene *scene) gf_term_invalidate_compositor(scene->root_od->term); } } + +void gf_scene_toggle_addons(GF_Scene *scene, Bool show_addons) +{ + M_Inline *dscene = (M_Inline *) gf_sg_find_node_by_name(scene->graph, "ADDON_SCENE"); + + if (show_addons) { + GF_AssociatedContentLocation addon_info; + memset(&addon_info, 0, sizeof(GF_AssociatedContentLocation)); + addon_info.timeline_id = -100; + gf_scene_register_associated_media(scene, &addon_info); + +// gf_sg_vrml_field_copy(&dscene->url, &scene->addon_url, GF_SG_VRML_MFURL); + + } else { + gf_sg_vrml_mf_reset(&dscene->url, GF_SG_VRML_MFURL); + } + gf_node_changed((GF_Node *)dscene, NULL); +} + #else /*!!fixme - we would need an SVG scene in case no VRML support is present !!!*/ void gf_scene_regenerate(GF_Scene *scene) {} @@ -1274,15 +1311,39 @@ static Bool check_odm_deactivate(SFURL *url, GF_ObjectManager *odm, GF_Node *n) return 1; } +void gf_scene_set_service_id(GF_Scene *scene, u32 service_id) +{ + if (!scene->is_dynamic_scene) return; + + gf_sc_lock(scene->root_od->term->compositor, 1); + if (scene->selected_service_id != service_id) { + scene->selected_service_id = service_id; + scene->audio_url.OD_ID = 0; + scene->visual_url.OD_ID = 0; + scene->text_url.OD_ID = 0; + scene->dims_url.OD_ID = 0; + //reset clock since we change service IDs + scene->dyn_ck = NULL; + gf_scene_regenerate(scene); + } + gf_sc_lock(scene->root_od->term->compositor, 0); +} + void gf_scene_select_object(GF_Scene *scene, GF_ObjectManager *odm) { char *url; if (!scene->is_dynamic_scene || !scene->graph_attached || !odm) return; - + if (!odm->codec) { if (!odm->addon) return; } + if (odm->OD->ServiceID && scene->selected_service_id && (scene->selected_service_id != odm->OD->ServiceID)) { + gf_scene_set_service_id(scene, odm->OD->ServiceID); + return; + } + + if (odm->state) { if (check_odm_deactivate(&scene->audio_url, odm, gf_sg_find_node_by_name(scene->graph, "DYN_AUDIO")) ) return; if (check_odm_deactivate(&scene->visual_url, odm, gf_sg_find_node_by_name(scene->graph, "DYN_VIDEO") )) return; @@ -1292,7 +1353,6 @@ void gf_scene_select_object(GF_Scene *scene, GF_ObjectManager *odm) if (!odm->codec && odm->subscene) { M_Inline *dscene = (M_Inline *) gf_sg_find_node_by_name(scene->graph, "ADDON_SCENE"); - gf_sg_vrml_field_copy(&dscene->url, &odm->mo->URLs, GF_SG_VRML_MFURL); gf_node_changed((GF_Node *)dscene, NULL); IS_UpdateVideoPos(scene); @@ -1309,7 +1369,7 @@ void gf_scene_select_object(GF_Scene *scene, GF_ObjectManager *odm) ac->url.vals[0].OD_ID = odm->OD->objectDescriptorID; if (ac->url.vals[0].url) { gf_free(ac->url.vals[0].url); - ac->url.vals[0].url = NULL; + ac->url.vals[0].url = NULL; } url = odm->mo->URLs.count ? odm->mo->URLs.vals[0].url : NULL; if (url) { @@ -1431,9 +1491,9 @@ void gf_scene_force_size(GF_Scene *scene, u32 width, u32 height) { /*for now only allowed when no scene info*/ if (!scene->is_dynamic_scene) return; - + GF_LOG(GF_LOG_INFO, GF_LOG_COMPOSE, ("[Compositor] Changing scene size to %d x %d\n", width, height)); - + if (scene->root_od->term->root_scene == scene) { GF_NetworkCommand com; @@ -1497,7 +1557,7 @@ Bool gf_scene_process_anchor(GF_Node *caller, GF_Event *evt) } if (!scene->root_od->mo) return 1; - + /*FIXME this is too restrictive, we assume the navigate URL is really a presentation one...*/ #ifndef GPAC_DISABLE_VRML i=0; @@ -1510,7 +1570,7 @@ Bool gf_scene_process_anchor(GF_Node *caller, GF_Event *evt) gf_sg_vrml_mf_reset(&inl->url, GF_SG_VRML_MFURL); gf_sg_vrml_mf_alloc(&inl->url, GF_SG_VRML_MFURL, 1); inl->url.vals[0].url = gf_strdup(evt->navigate.to_url ? evt->navigate.to_url : ""); - /*signal URL change but don't destroy inline scene now since we got this event from inside the scene, + /*signal URL change but don't destroy inline scene now since we got this event from inside the scene, this could crash compositors*/ scene->needs_restart = 2; break; @@ -1558,9 +1618,9 @@ GF_Node *gf_scene_get_subscene_root(GF_Node *node) if (!node) return NULL; switch (gf_node_get_tag(node)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_Inline: + case TAG_MPEG4_Inline: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Inline: + case TAG_X3D_Inline: #endif break; #endif @@ -1645,6 +1705,7 @@ Bool gf_scene_is_dynamic_scene(GF_SceneGraph *sg) void gf_scene_generate_views(GF_Scene *scene, char *url, char *parent_path) { +#ifndef GPAC_DISABLE_VRML char *url_search; Bool use_old_syntax = 1; GF_Node *n1, *switcher; @@ -1657,7 +1718,7 @@ void gf_scene_generate_views(GF_Scene *scene, char *url, char *parent_path) GF_Event evt; gf_sc_node_destroy(scene->root_od->term->compositor, NULL, scene->graph); gf_sg_reset(scene->graph); - + scene->force_single_timeline = 1; n1 = is_create_node(scene->graph, TAG_MPEG4_OrderedGroup, NULL); gf_sg_set_root_node(scene->graph, n1); @@ -1673,7 +1734,7 @@ void gf_scene_generate_views(GF_Scene *scene, char *url, char *parent_path) url_search = url; while (1) { char *sep; - + if (use_old_syntax) { sep = strchr(url_search, ':'); /*if :// or :\ is found, skip it*/ @@ -1739,6 +1800,7 @@ void gf_scene_generate_views(GF_Scene *scene, char *url, char *parent_path) evt.type = GF_EVENT_CONNECT; evt.connect.is_connected = 1; gf_term_send_event(scene->root_od->term, &evt); +#endif } void scene_reset_addon(GF_AddonMedia *addon, Bool disconnect) @@ -1779,8 +1841,7 @@ static void load_associated_media(GF_Scene *scene, GF_AddonMedia *addon) mo = gf_scene_get_media_object(scene, &url, GF_MEDIA_OBJECT_SCENE, GF_TRUE); if (!mo) return; - gf_free(addon->url); - addon->url = NULL; + addon->root_od = mo->odm; mo->odm->addon = addon; } @@ -1790,7 +1851,7 @@ void gf_scene_register_associated_media(GF_Scene *scene, GF_AssociatedContentLoc GF_AddonMedia *addon; GF_Event evt; u32 i, count; - + if (!scene->is_dynamic_scene) return; count = gf_list_count(scene->declared_addons); @@ -1800,6 +1861,10 @@ void gf_scene_register_associated_media(GF_Scene *scene, GF_AssociatedContentLoc if (addon_info->reload_external) { //send message to service handler } + //restart addon + if (!addon->root_od && addon->timeline_ready) { + load_associated_media(scene, addon); + } return; } } @@ -1822,25 +1887,26 @@ void gf_scene_register_associated_media(GF_Scene *scene, GF_AssociatedContentLoc addon->timeline_ready = (addon_info->timeline_id<0) ? 1 : 0; if (addon->timeline_ready && !scene->active_addon) scene->active_addon = addon; gf_list_add(scene->declared_addons, addon); - + evt.type = GF_EVENT_ADDON_DETECTED; evt.addon_connect.addon_url = addon->url; addon->enabled = gf_term_send_event(scene->root_od->term,&evt); - - if (addon->timeline_ready) + + if (addon->timeline_ready) load_associated_media(scene, addon); } void gf_scene_notify_associated_media_timeline(GF_Scene *scene, GF_AssociatedContentTiming *addon_time) { + Double prev_time; GF_AddonMedia *addon = scene->active_addon; //locate the active timeline if (!scene->active_addon || (scene->active_addon->timeline_id!=addon_time->timeline_id)) { u32 i, count = gf_list_count(scene->declared_addons); for (i=0; ideclared_addons, i); - if (addon->timeline_id==addon_time->timeline_id) + if (addon->timeline_id==addon_time->timeline_id) break; addon = NULL; } @@ -1851,10 +1917,9 @@ void gf_scene_notify_associated_media_timeline(GF_Scene *scene, GF_AssociatedCon GF_AddonMedia *prev_addon = gf_list_get(scene->declared_addons, i); //we are adding a non splicing point: discard all previously declared addons if (!addon->is_splicing - //this is a splicing point, discard all previsously declared splicing addons - || prev_addon->is_splicing - ) { - Bool discard = GF_FALSE; + //this is a splicing point, discard all previsously declared splicing addons + || prev_addon->is_splicing + ) { scene_reset_addon(prev_addon, GF_TRUE); gf_list_rem(scene->declared_addons, i); i--; @@ -1869,25 +1934,90 @@ void gf_scene_notify_associated_media_timeline(GF_Scene *scene, GF_AssociatedCon } } + gf_mx_p(scene->active_addon->root_od->mx); + prev_time = (Double) scene->active_addon->media_timestamp; + prev_time /= scene->active_addon->media_timescale; + assert(scene->active_addon->timeline_id == addon_time->timeline_id); - scene->active_addon->media_pts = addon_time->media_pts; - scene->active_addon->media_timestamp = addon_time->media_timestamp; - scene->active_addon->media_timescale = addon_time->media_timescale; + + //loop has been detected + if ( prev_time * addon_time->media_timescale > addon_time->media_timestamp + 1.5 * addon_time->media_timescale ) { + if (!scene->active_addon->loop_detected) { + scene->active_addon->loop_detected = GF_TRUE; + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Loop detected in addon - PTS "LLD" (CTS %d) - media time "LLD"\n", addon_time->media_pts, addon_time->media_pts/90, addon_time->media_timestamp)); + scene->active_addon->past_media_pts = addon_time->media_pts; + scene->active_addon->past_media_timestamp = addon_time->media_timestamp; + scene->active_addon->past_media_timescale = addon_time->media_timescale; + scene->active_addon->past_media_pts_scaled = addon_time->media_pts/90; + } + } else if (!scene->active_addon->loop_detected) { + scene->active_addon->media_pts = addon_time->media_pts; + scene->active_addon->media_timestamp = addon_time->media_timestamp; + scene->active_addon->media_timescale = addon_time->media_timescale; + assert(addon_time->media_timescale); + assert(!scene->active_addon->loop_detected); + } + gf_mx_v(scene->active_addon->root_od->mx); } -u32 gf_scene_adjust_time_for_addon(GF_Scene *scene, u32 clock_time, GF_AddonMedia *addon) +void gf_scene_check_addon_restart(GF_AddonMedia *addon, u64 cts, u64 dts) { - s64 media_ts_ms; + u32 i; + GF_ObjectManager*odm; + GF_Scene *subscene; + + if (!addon || !addon->loop_detected) return; + //warning, we need to compare to media PTS/90 since we already rounded the media_ts to milliseconds (otherwise we would get rounding errors). + if ((cts == addon->past_media_pts_scaled) || (dts>=addon->past_media_pts_scaled) ) { + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Loop not yet active - CTS "LLD" DTS "LLD" media TS "LLD" \n", cts, dts, addon->past_media_pts_scaled)); + return; + } + + gf_mx_p(addon->root_od->mx); + + addon->loop_detected = 0; + addon->media_pts = addon->past_media_pts; + addon->media_timestamp = addon->past_media_timestamp; + addon->media_timescale = addon->past_media_timescale; + assert(addon->past_media_timescale); + addon->past_media_pts = 0; + addon->past_media_timestamp = 0; + addon->past_media_timescale = 0; + + subscene = addon->root_od->subscene; + + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Looping addon - CTS "LLD" - addon media TS "LLD" (CTS "LLD") addon media time "LLD"\n", cts, addon->media_pts, addon->media_pts/90, addon->media_timestamp)); + + gf_mx_v(addon->root_od->mx); + + i=0; + while ((odm = (GF_ObjectManager*)gf_list_enum(subscene->resources, &i))) { + gf_odm_play(odm); + } + +} + +Double gf_scene_adjust_time_for_addon(GF_Scene *scene, u32 clock_time, GF_AddonMedia *addon, Bool *timestamp_based) +{ + Double media_time; if (!addon->timeline_ready) return clock_time; assert(scene->root_od->addon); assert(scene->root_od->addon==addon); - media_ts_ms = clock_time; - - media_ts_ms -= (addon->media_pts/90); - media_ts_ms += (addon->media_timestamp*1000) / addon->media_timescale; - return (u32) media_ts_ms; + if (timestamp_based) + *timestamp_based = (addon->timeline_id>=0) ? 0 : 1; + + //get PTS diff (clock is in ms, pt is in 90k) + media_time = clock_time; + media_time -= addon->media_pts/90; + media_time *= addon->media_timescale; + media_time /= 1000; + media_time += addon->media_timestamp; + media_time /= addon->media_timescale; + GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("Addon about to start - media time %g\n", media_time)); + return media_time; } u64 gf_scene_adjust_timestamp_for_addon(GF_Scene *scene, u64 orig_ts, GF_AddonMedia *addon) @@ -1909,7 +2039,7 @@ void gf_scene_select_scalable_addon(GF_Scene *scene, GF_ObjectManager *odm) GF_NetworkCommand com; GF_CodecCapability caps; Bool nalu_annex_b; - GF_Channel *ch; + GF_Channel *ch, *base_ch; GF_ObjectManager *odm_base = NULL; u32 i, count, mtype; ch = gf_list_get(odm->channels, 0); @@ -1924,12 +2054,12 @@ void gf_scene_select_scalable_addon(GF_Scene *scene, GF_ObjectManager *odm) //todo check if we use compatible formats, for now we only do demos with hevc/shvc } if (!odm_base) return; - + odm_base->scalable_odm = odm; - + nalu_annex_b = 1; - ch = gf_list_get(odm_base->channels, 0); - if (ch->esd->decoderConfig->decoderSpecificInfo && ch->esd->decoderConfig->decoderSpecificInfo->dataLength) + base_ch = gf_list_get(odm_base->channels, 0); + if (base_ch->esd->decoderConfig->decoderSpecificInfo && base_ch->esd->decoderConfig->decoderSpecificInfo->dataLength) nalu_annex_b = 0; memset(&com, 0, sizeof(GF_NetworkCommand)); @@ -1938,11 +2068,15 @@ void gf_scene_select_scalable_addon(GF_Scene *scene, GF_ObjectManager *odm) count = gf_list_count(odm->channels); for (i=0; ichannels, i); + //we must wait for RAP otherwise we won't be able to detect temporal scalability correctly + ch->stream_state = 1; + ch->media_padding_bytes = base_ch->media_padding_bytes; gf_term_service_command(ch->service, &com); + } //signal to the base decoder that we will want full quality caps.CapCode = GF_CODEC_MEDIA_SWITCH_QUALITY; caps.cap.valueInt = 2; -// odm_base->codec->decio->SetCapabilities(odm_base->codec->decio, caps); + odm_base->codec->decio->SetCapabilities(odm_base->codec->decio, caps); } diff --git a/src/terminal/svg_external.c b/src/terminal/svg_external.c index 9fa8b06..f049501 100644 --- a/src/terminal/svg_external.c +++ b/src/terminal/svg_external.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -70,7 +70,7 @@ char *gf_term_resolve_xlink(GF_Node *node, char *the_url) } gf_free(url); return the_url; - } + } return url; } @@ -172,7 +172,7 @@ GF_MediaObject *gf_mo_load_xlink_resource(GF_Node *node, Bool primary_resource, SVGAllAttributes all_atts; XLinkAttributesPointers xlinkp; SMILSyncAttributesPointers syncp; - GF_Scene *scene = gf_sg_get_private(gf_node_get_graph(node)); + GF_Scene *scene = gf_sg_get_private(gf_node_get_graph(node)); if (!scene) return NULL; gf_svg_flatten_attributes((SVG_Element *)node, &all_atts); @@ -201,7 +201,7 @@ GF_MediaObject *gf_mo_load_xlink_resource(GF_Node *node, Bool primary_resource, /*play*/ gf_mo_play(new_resource->root_od->mo, 0, -1, 0); - return new_resource->root_od->mo; + return new_resource->root_od->mo; } void gf_mo_unload_xlink_resource(GF_Node *node, GF_MediaObject *mo) diff --git a/src/terminal/term_node_init.c b/src/terminal/term_node_init.c index f4b4f76..a8aa102 100644 --- a/src/terminal/term_node_init.c +++ b/src/terminal/term_node_init.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -205,23 +205,33 @@ void gf_term_on_node_init(void *_scene, GF_Node *node) { GF_Scene *scene = (GF_Scene *)_scene; if (!node || !scene) return; - + switch (gf_node_get_tag(node)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_Inline: + case TAG_MPEG4_Inline: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Inline: + case TAG_X3D_Inline: #endif - gf_init_inline(scene, node); break; - case TAG_MPEG4_MediaBuffer: break; - case TAG_MPEG4_MediaControl: InitMediaControl(scene, node); break; - case TAG_MPEG4_MediaSensor: InitMediaSensor(scene, node); break; - case TAG_MPEG4_InputSensor: InitInputSensor(scene, node); break; + gf_init_inline(scene, node); + break; + case TAG_MPEG4_MediaBuffer: + break; + case TAG_MPEG4_MediaControl: + InitMediaControl(scene, node); + break; + case TAG_MPEG4_MediaSensor: + InitMediaSensor(scene, node); + break; + case TAG_MPEG4_InputSensor: + InitInputSensor(scene, node); + break; /*BIFS nodes, get back to codec, but filter externProtos*/ - case TAG_MPEG4_Conditional: break; - case TAG_MPEG4_QuantizationParameter: break; + case TAG_MPEG4_Conditional: + break; + case TAG_MPEG4_QuantizationParameter: + break; /*world info is stored at the inline scene level*/ case TAG_MPEG4_WorldInfo: #ifndef GPAC_DISABLE_X3D @@ -232,15 +242,21 @@ void gf_term_on_node_init(void *_scene, GF_Node *node) break; #ifndef GPAC_DISABLE_X3D - case TAG_X3D_KeySensor: InitKeySensor(scene, node); break; - case TAG_X3D_StringSensor: InitStringSensor(scene, node); break; + case TAG_X3D_KeySensor: + InitKeySensor(scene, node); + break; + case TAG_X3D_StringSensor: + InitStringSensor(scene, node); + break; #endif - case TAG_MPEG4_TermCap: - InitTermCap(scene, node); break; + case TAG_MPEG4_TermCap: + InitTermCap(scene, node); + break; - case TAG_MPEG4_Storage: - gf_scene_init_storage(scene, node); break; + case TAG_MPEG4_Storage: + gf_scene_init_storage(scene, node); + break; case TAG_MPEG4_KeyNavigator: gf_node_set_callback_function(node, TraverseKeyNavigator); @@ -248,18 +264,20 @@ void gf_term_on_node_init(void *_scene, GF_Node *node) gf_list_add(scene->keynavigators, node); ((M_KeyNavigator*)node)->on_setFocus = on_kn_set_focus; break; - + #endif #ifndef GPAC_DISABLE_SVG - case TAG_SVG_title: + case TAG_SVG_title: gf_node_set_callback_function(node, svg_traverse_title); gf_node_set_private(node, scene); break; #endif - default: gf_sc_on_node_init(scene->root_od->term->compositor, node); break; + default: + gf_sc_on_node_init(scene->root_od->term->compositor, node); + break; } } @@ -268,35 +286,37 @@ void gf_term_on_node_modified(void *_is, GF_Node *node) GF_Scene *scene = (GF_Scene *)_is; if (!scene) return; if (!node) { - gf_sc_invalidate(scene->root_od->term->compositor, NULL); + gf_sc_invalidate(scene->root_od->term->compositor, NULL); return; } - + switch (gf_node_get_tag(node)) { #ifndef GPAC_DISABLE_VRML - case TAG_MPEG4_Inline: + case TAG_MPEG4_Inline: #ifndef GPAC_DISABLE_X3D - case TAG_X3D_Inline: + case TAG_X3D_Inline: #endif - gf_inline_on_modified(node); + gf_inline_on_modified(node); break; - case TAG_MPEG4_MediaBuffer: + case TAG_MPEG4_MediaBuffer: break; - case TAG_MPEG4_MediaControl: - MC_Modified(node); + case TAG_MPEG4_MediaControl: + MC_Modified(node); break; - case TAG_MPEG4_MediaSensor: - MS_Modified(node); + case TAG_MPEG4_MediaSensor: + MS_Modified(node); break; - case TAG_MPEG4_InputSensor: - InputSensorModified(node); + case TAG_MPEG4_InputSensor: + InputSensorModified(node); break; - case TAG_MPEG4_Conditional: + case TAG_MPEG4_Conditional: break; - case TAG_MPEG4_Storage: + case TAG_MPEG4_Storage: break; #endif - default: gf_sc_invalidate(scene->root_od->term->compositor, node); break; + default: + gf_sc_invalidate(scene->root_od->term->compositor, node); + break; } } @@ -304,7 +324,7 @@ static void gf_term_on_node_destroyed(void *_is, GF_Node *node) { GF_Scene *scene = (GF_Scene *)_is; if (!scene) return; - gf_sc_node_destroy(scene->root_od->term->compositor, node, NULL); + gf_sc_node_destroy(scene->root_od->term->compositor, node, NULL); } GF_EXPORT @@ -332,6 +352,6 @@ void gf_term_node_callback(void *_is, u32 type, GF_Node *n, void *param) } } } - break; + break; } } diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 4e6cdee..5c93256 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -239,8 +240,8 @@ static Bool term_check_locales(void *__self, const char *locales_parent_path, co } /*Checks if the absolute path is really absolute and points to a local file (no http or else) */ - if (!locales_parent_path || - (locales_parent_path && (locales_parent_path[0] != '/') && strstr(locales_parent_path, "://") && strnicmp(locales_parent_path, "file://", 7))) { + if (!locales_parent_path || + (locales_parent_path && (locales_parent_path[0] != '/') && strstr(locales_parent_path, "://") && strnicmp(locales_parent_path, "file://", 7))) { return 0; } opt = gf_cfg_get_key(loc->term->user->config, "Systems", "Language2CC"); @@ -263,7 +264,7 @@ static Bool term_check_locales(void *__self, const char *locales_parent_path, co if (sep_lang) { sep_lang[0] = ';'; opt = sep_lang+1; - } else { + } else { opt = NULL; } @@ -274,7 +275,7 @@ static Bool term_check_locales(void *__self, const char *locales_parent_path, co } sprintf(path, "locales/%s/%s", lan, rel_path); - if (term_find_res(loc, (char *) locales_parent_path, (char *) path, relocated_path, localized_rel_path)) + if (term_find_res(loc, (char *) locales_parent_path, (char *) path, relocated_path, localized_rel_path)) return 1; /*recursively remove region (sub)tags*/ @@ -283,12 +284,12 @@ static Bool term_check_locales(void *__self, const char *locales_parent_path, co if (!sep) break; sep[0] = 0; sprintf(path, "locales/%s/%s", lan, rel_path); - if (term_find_res(loc, (char *) locales_parent_path, (char *) path, relocated_path, localized_rel_path)) + if (term_find_res(loc, (char *) locales_parent_path, (char *) path, relocated_path, localized_rel_path)) return 1; } } - if (term_find_res(loc, (char *) locales_parent_path, (char *) rel_path, relocated_path, localized_rel_path)) + if (term_find_res(loc, (char *) locales_parent_path, (char *) rel_path, relocated_path, localized_rel_path)) return 1; /* if we did not find the localized file, both the relocated and localized strings are NULL */ strcpy(localized_rel_path, ""); @@ -304,7 +305,7 @@ static void gf_term_reload_cfg(GF_Terminal *term) s32 prio; if (!term) return; - + /*reload term part*/ sOpt = gf_cfg_get_key(term->user->config, "Systems", "DrawLateFrames"); @@ -314,7 +315,7 @@ static void gf_term_reload_cfg(GF_Terminal *term) term->flags &= ~GF_TERM_DROP_LATE_FRAMES; sOpt = gf_cfg_get_key(term->user->config, "Systems", "ForceSingleClock"); - if (sOpt && !stricmp(sOpt, "yes")) + if (sOpt && !stricmp(sOpt, "yes")) term->flags |= GF_TERM_SINGLE_CLOCK; else term->flags &= ~GF_TERM_SINGLE_CLOCK; @@ -326,7 +327,7 @@ static void gf_term_reload_cfg(GF_Terminal *term) } term->frame_duration = atoi(sOpt); - if (!(term->user->init_flags & GF_TERM_NO_DECODER_THREAD) ){ + if (!(term->user->init_flags & GF_TERM_NO_DECODER_THREAD) ) { prio = GF_THREAD_PRIORITY_NORMAL; sOpt = gf_cfg_get_key(term->user->config, "Systems", "Priority"); if (sOpt) { @@ -350,6 +351,14 @@ static void gf_term_reload_cfg(GF_Terminal *term) gf_term_set_threading(term, GF_TERM_THREAD_SINGLE); } + term->prefered_audio_codec_oti = 0; + sOpt = gf_cfg_get_key(term->user->config, "Systems", "DefAudioOTI"); + if (sOpt) { + if (sscanf(sOpt, "0x%x", & term->prefered_audio_codec_oti) != 1) { + sscanf(sOpt, "%x", & term->prefered_audio_codec_oti); + } + } + /*default data timeout is 20 sec*/ term->net_data_timeout = 20000; sOpt = gf_cfg_get_key(term->user->config, "Network", "DataTimeout"); @@ -363,7 +372,7 @@ static void gf_term_reload_cfg(GF_Terminal *term) gf_sg_reload_xml_doc(sOpt, term->dcci_doc); } #endif - + gf_term_load_shortcuts(term); /*reload compositor config*/ @@ -412,7 +421,7 @@ static void gf_term_set_play_state(GF_Terminal *term, u32 PlayState, Bool reset_ else gf_sc_set_option(term->compositor, GF_OPT_PLAY_STATE, PlayState); - /* if the current play state in the terminal is the same as the requested play state, we don't touch the clocks + /* if the current play state in the terminal is the same as the requested play state, we don't touch the clocks in particular, if the request is a step, if the clocks are paused, we leave them paused */ if (PlayState==GF_STATE_STEP_PAUSE) { //PlayState = term->play_state ? GF_STATE_PLAYING : GF_STATE_PAUSED; @@ -507,7 +516,7 @@ void gf_term_refresh_cache(GF_Config *cfg) sscanf(opt, "%u", &exp); gf_net_get_ntp(&sec, &frac); if (exp && (expextensions, i); i--; continue; - } - + } + if (ifce->caps & GF_TERM_EXTENSION_NOT_THREADED) gf_list_add(tmp->unthreaded_extensions, ifce); } @@ -654,7 +663,7 @@ GF_Terminal *gf_term_new(GF_User *user) } gf_term_lock_media_queue(tmp, 0); - if (0 == gf_cfg_get_key_count(user->config, "MimeTypes")){ + if (0 == gf_cfg_get_key_count(user->config, "MimeTypes")) { GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[Terminal] Initializing Mime Types...")); /* No mime-types detected, probably the first launch */ for (i=0; i< gf_modules_get_count(user->modules); i++) { @@ -662,7 +671,7 @@ GF_Terminal *gf_term_new(GF_User *user) if (ifce) { GF_InputService * service = (GF_InputService*) ifce; GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] Asking mime types supported for new module %s...\n", ifce->module_name)); - if (service->RegisterMimeTypes){ + if (service->RegisterMimeTypes) { u32 num = service->RegisterMimeTypes(service); GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] module %s has registered %u new mime-types.\n", ifce->module_name, num)); } else { @@ -717,7 +726,7 @@ GF_Err gf_term_del(GF_Terminal * term) assert(!gf_list_count(term->net_services)); assert(!gf_list_count(term->net_services_to_remove)); e = GF_OK; - } + } GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] All network services deleted\n")); /*unload extensions*/ @@ -764,7 +773,7 @@ GF_Err gf_term_del(GF_Terminal * term) assert(!term->nodes_pending); gf_list_del(term->media_queue); if (term->downloader) gf_dm_del(term->downloader); - + gf_mx_del(term->media_queue_mx); if (term->locales.szAbsRelocatedPath) gf_free(term->locales.szAbsRelocatedPath); @@ -868,11 +877,11 @@ void gf_term_disconnect(GF_Terminal *term) term->root_scene = NULL; } handle_services = 0; - if (term->flags & GF_TERM_NO_DECODER_THREAD) + if (term->flags & GF_TERM_NO_DECODER_THREAD) handle_services = 1; /*if an unthreaded term extension decides to disconnect the scene (validator does so), we must flush services now because we are called from gf_term_handle_services*/ - if (term->thread_id_handling_services == gf_th_id()) + if (term->thread_id_handling_services == gf_th_id()) handle_services = 1; while (term->root_scene || gf_list_count(term->net_services_to_remove) || gf_list_count(term->connection_tasks) || gf_list_count(term->media_queue) ) { @@ -932,7 +941,7 @@ GF_Err gf_term_set_option(GF_Terminal * term, u32 type, u32 value) return GF_OK; case GF_OPT_VIDEO_BENCH: term->bench_mode = value; - //fallthrough + //fallthrough default: return gf_sc_set_option(term->compositor, type, value); } @@ -979,10 +988,13 @@ u32 gf_term_get_option(GF_Terminal * term, u32 type) { if (!term) return 0; switch (type) { - case GF_OPT_HAS_JAVASCRIPT: return gf_sg_has_scripting(); - case GF_OPT_IS_FINISHED: return gf_term_check_end_of_scene(term, 0); - case GF_OPT_IS_OVER: return gf_term_check_end_of_scene(term, 1); - case GF_OPT_PLAY_STATE: + case GF_OPT_HAS_JAVASCRIPT: + return gf_sg_has_scripting(); + case GF_OPT_IS_FINISHED: + return gf_term_check_end_of_scene(term, 0); + case GF_OPT_IS_OVER: + return gf_term_check_end_of_scene(term, 1); + case GF_OPT_PLAY_STATE: if (term->compositor->step_mode) return GF_STATE_STEP_PAUSE; if (term->root_scene) { GF_Clock *ck = term->root_scene->dyn_ck; @@ -996,15 +1008,19 @@ u32 gf_term_get_option(GF_Terminal * term, u32 type) } if (term->play_state != GF_STATE_PLAYING) return GF_STATE_PAUSED; return GF_STATE_PLAYING; - case GF_OPT_MEDIA_CACHE: + case GF_OPT_MEDIA_CACHE: if (!term->enable_cache) return GF_MEDIA_CACHE_DISABLED; else if (term->root_scene && term->root_scene->root_od->net_service->cache) return GF_MEDIA_CACHE_RUNNING; else return GF_MEDIA_CACHE_ENABLED; - case GF_OPT_CAN_SELECT_STREAMS: return (term->root_scene && term->root_scene->is_dynamic_scene) ? 1 : 0; - case GF_OPT_HTTP_MAX_RATE: return gf_dm_get_data_rate(term->downloader); - case GF_OPT_VIDEO_BENCH: return term->bench_mode ? GF_TRUE : GF_FALSE; + case GF_OPT_CAN_SELECT_STREAMS: + return (term->root_scene && term->root_scene->is_dynamic_scene) ? 1 : 0; + case GF_OPT_HTTP_MAX_RATE: + return gf_dm_get_data_rate(term->downloader); + case GF_OPT_VIDEO_BENCH: + return term->bench_mode ? GF_TRUE : GF_FALSE; - default: return gf_sc_get_option(term->compositor, type); + default: + return gf_sc_get_option(term->compositor, type); } } @@ -1040,7 +1056,7 @@ void gf_term_handle_services(GF_Terminal *term) /*we could run into a deadlock if some thread has requested opening of a URL. If we cannot grab the media queue now, we'll do our management at the next cycle*/ if (!gf_mx_try_lock(term->media_queue_mx)) - return; + return; term->thread_id_handling_services = gf_th_id(); @@ -1057,7 +1073,7 @@ void gf_term_handle_services(GF_Terminal *term) odm->action_type = GF_ODM_ACTION_PLAY; switch (act_type) { case GF_ODM_ACTION_STOP: - if (odm->mo /*&& odm->codec && odm->codec->CB && (odm->codec->CB->Capacity==1)*/) + if (odm->mo /*&& odm->codec && odm->codec->CB && (odm->codec->CB->Capacity==1)*/) { if (odm->mo->OD_ID==GF_MEDIA_EXTERNAL_ID) destroy = 1; else if (odm->OD && (odm->OD->objectDescriptorID==GF_MEDIA_EXTERNAL_ID)) destroy = 1; @@ -1084,20 +1100,22 @@ void gf_term_handle_services(GF_Terminal *term) gf_scene_disconnect(odm->subscene, 0); break; case GF_ODM_ACTION_SCENE_INLINE_RESTART: +#ifndef GPAC_DISABLE_VRML gf_scene_mpeg4_inline_restart(odm->subscene); +#endif break; } - + /*relock before sending play/pause*/ gf_term_lock_media_queue(term, 1); } - /*finally process all connection tasks - we MUST do that after processing ODM tasks, as an ODM might have just destroyed + /*finally process all connection tasks - we MUST do that after processing ODM tasks, as an ODM might have just destroyed a service we could query during the connection step*/ while (gf_list_count(term->connection_tasks)) { GF_TermConnectObject *connect = gf_list_get(term->connection_tasks, 0); gf_list_rem(term->connection_tasks, 0); - + /*unlock media queue before sending connect*/ gf_term_lock_media_queue(term, 0); @@ -1109,7 +1127,7 @@ void gf_term_handle_services(GF_Terminal *term) } // gf_mx_v(term->net_mx); - + gf_free(connect->service_url); if (connect->parent_url) gf_free(connect->parent_url); gf_free(connect); @@ -1159,7 +1177,7 @@ void gf_term_handle_services(GF_Terminal *term) } gf_term_lock_media_queue(term, 0); - + /*need to reload*/ if (term->reload_state == 1) { term->reload_state = 0; @@ -1219,7 +1237,7 @@ void gf_term_close_service(GF_Terminal *term, GF_ClientService *ns) GF_Err e; /*prevent the media manager / term to access the list of services to destroy, otherwise - we could unload the module while poping its CloseService() call stack which can lead to + we could unload the module while poping its CloseService() call stack which can lead to random crashes (return adresses no longer valid) - cf any "stress mode" playback of a playlist*/ gf_term_lock_media_queue(term, 1); @@ -1296,7 +1314,7 @@ void media_event_collect_info(GF_ClientService *net, GF_ObjectManager *odm, GF_D } else { if (*min_buffer > 100) *min_buffer = 100; } - if (*min_time > (u32) ch->BufferTime) + if (*min_time > (u32) ch->BufferTime) *min_time = ch->BufferTime; } else { *min_time = 0; @@ -1321,11 +1339,11 @@ void gf_term_service_media_event_with_download(GF_ObjectManager *odm, GF_EventTy //for dynamic scenes, check if we have listeners on the root object of the scene containing this media if (!count - && odm->parentscene - && odm->parentscene->is_dynamic_scene - && odm->parentscene->root_od->mo - && (odm->parentscene->root_od->net_service==odm->net_service) - ) { + && odm->parentscene + && odm->parentscene->is_dynamic_scene + && odm->parentscene->root_od->mo + && (odm->parentscene->root_od->net_service==odm->net_service) + ) { odm = odm->parentscene->root_od; count = gf_mo_event_target_count(odm->mo); } @@ -1364,12 +1382,12 @@ void gf_term_service_media_event_with_download(GF_ObjectManager *odm, GF_EventTy evt.type = event_type; evt.bubbles = 0; /*the spec says yes but we force it to NO*/ - //these events may be triggered from any input or decoding threads. Sync processing cannot be - //achieved in most cases, because we may run into deadlocks, especially if the event + //these events may be triggered from any input or decoding threads. Sync processing cannot be + //achieved in most cases, because we may run into deadlocks, especially if the event //was triggered by a service opened by JS for (i=0; imo->evt_targets, i); - if (target) + if (target) gf_sc_queue_dom_event_on_target(scene->root_od->term->compositor, &evt, target, scene->graph); } if (!count) { @@ -1386,7 +1404,7 @@ void gf_term_service_media_event(GF_ObjectManager *odm, GF_EventType event_type) /* Browses all registered relocators (ZIP-based, ISOFF-based or file-system-based to relocate a URI based on the locale */ GF_EXPORT -Bool gf_term_relocate_url(GF_Terminal *term, const char *service_url, const char *parent_url, char *out_relocated_url, char *out_localized_url) +Bool gf_term_relocate_url(GF_Terminal *term, const char *service_url, const char *parent_url, char *out_relocated_url, char *out_localized_url) { u32 i, count; @@ -1423,7 +1441,7 @@ static void gf_term_connect_object(GF_Terminal *term, GF_ObjectManager *odm, cha GF_ClientService *ns; u32 i, count; GF_Err e; - Bool reloc_result, net_locked; + Bool reloc_result, net_locked; char relocated_url[GF_MAX_PATH], localized_url[GF_MAX_PATH]; /*try to relocate the url*/ @@ -1500,7 +1518,7 @@ static void gf_term_connect_object(GF_Terminal *term, GF_ObjectManager *odm, cha if (ns->owner->OD) break; gf_sleep(5); } - + gf_mx_p(term->net_mx); if (odm->net_service) { gf_mx_v(term->net_mx); @@ -1518,7 +1536,7 @@ static void gf_term_connect_object(GF_Terminal *term, GF_ObjectManager *odm, cha return; } } - if (net_locked) + if (net_locked) gf_term_lock_net(term, 0); odm->net_service = gf_term_service_new(term, odm, serviceURL, reloc_result ? NULL : parent_url, &e); @@ -1597,7 +1615,7 @@ u32 gf_term_play_from_time(GF_Terminal *term, u64 from_time, u32 pause_at_first_ pause_at_first_frame = 0; } - /*for dynamic scene OD ressources are static and all object use the same clock, so don't restart the root + /*for dynamic scene OD ressources are static and all object use the same clock, so don't restart the root OD, just act as a mediaControl on all playing streams*/ if (term->root_scene->is_dynamic_scene) { @@ -1611,7 +1629,7 @@ u32 gf_term_play_from_time(GF_Terminal *term, u64 from_time, u32 pause_at_first_ gf_scene_restart_dynamic(term->root_scene, from_time); gf_sc_lock(term->compositor, 0); return 2; - } + } /*pause everything*/ gf_term_set_play_state(term, GF_STATE_PAUSED, 0, 1); @@ -1624,7 +1642,7 @@ u32 gf_term_play_from_time(GF_Terminal *term, u64 from_time, u32 pause_at_first_ gf_odm_start(term->root_scene->root_od, 0); gf_term_set_play_state(term, GF_STATE_PLAYING, 0, 1); - if (pause_at_first_frame) + if (pause_at_first_frame) gf_sc_set_option(term->compositor, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE); return 2; } @@ -1673,7 +1691,7 @@ void gf_term_navigate_to(GF_Terminal *term, const char *toURL) if (term->reload_url) gf_free(term->reload_url); term->reload_url = NULL; if (toURL) { - if (term->root_scene && term->root_scene->root_od && term->root_scene->root_od->net_service) + if (term->root_scene && term->root_scene->root_od && term->root_scene->root_od->net_service) term->reload_url = gf_url_concatenate(term->root_scene->root_od->net_service->url, toURL); if (!term->reload_url) term->reload_url = gf_strdup(toURL); } @@ -1737,7 +1755,7 @@ void gf_term_attach_service(GF_Terminal *term, GF_InputService *service_hdl) if (term->root_scene) gf_term_disconnect(term); gf_term_lock_net(term, 1); - + /*create a new scene*/ scene = gf_scene_new(NULL); odm = gf_odm_new(); @@ -1779,7 +1797,7 @@ GF_Err gf_term_scene_update(GF_Terminal *term, char *type, char *com) GF_SceneLoader load; if (!term) return GF_BAD_PARAM; - + if (type && (!stricmp(type, "application/ecmascript") || !stricmp(type, "js")) ) { return gf_scene_execute_script(term->root_scene->graph, com); } @@ -1791,8 +1809,15 @@ GF_Err gf_term_scene_update(GF_Terminal *term, char *type, char *com) GF_AssociatedContentLocation addon_info; memset(&addon_info, 0, sizeof(GF_AssociatedContentLocation)); addon_info.external_URL = com + 4; - addon_info.timeline_id = -1; + addon_info.timeline_id = -100; gf_scene_register_associated_media(term->root_scene, &addon_info); + return GF_OK; + } + //new add-on + if (term->root_scene && !strncmp(com, "select ", 7)) { + u32 idx = atoi(com+7); + gf_term_select_object(term, gf_list_get(term->root_scene->resources, idx)); + return GF_OK; } return GF_OK; } @@ -1943,7 +1968,7 @@ GF_EXPORT Bool gf_term_forward_event(GF_Terminal *term, GF_Event *evt, Bool consumed, Bool forward_only) { if (!term) return 0; - + if (term->event_filters) { GF_TermEventFilter *ef; u32 i=0; @@ -1960,7 +1985,7 @@ Bool gf_term_forward_event(GF_Terminal *term, GF_Event *evt, Bool consumed, Bool term->in_event_filter --; } - if (!forward_only && !consumed && term->user->EventProc) + if (!forward_only && !consumed && term->user->EventProc) return term->user->EventProc(term->user->opaque, evt); return 0; @@ -2051,7 +2076,10 @@ void gf_term_set_speed(GF_Terminal *term, Fixed speed) u32 i, j; const char *opt; GF_ClientService *ns; - if (!speed) return; + Bool restart = 0; + u32 scene_time = gf_term_get_time_in_ms(term); + + if (!speed) return; /*adjust all clocks on all services*/ i=0; @@ -2059,12 +2087,23 @@ void gf_term_set_speed(GF_Terminal *term, Fixed speed) GF_Clock *ck; j=0; while ( (ck = (GF_Clock *)gf_list_enum(ns->Clocks, &j)) ) { + if ( gf_mulfix(ck->speed,speed) < 0) restart = 1; gf_clock_set_speed(ck, speed); } } + if (restart) { + if (term->root_scene->is_dynamic_scene) { + gf_scene_restart_dynamic(term->root_scene, scene_time); + } else { + } + } + + if (speed<0) + speed = -speed; + opt = gf_cfg_get_key(term->user->config, "Systems", "TimeSlice"); - if (!opt) opt="30"; + if (!opt) opt="30"; i = (u32) ( atoi(opt) / FIX2FLT(speed) ); if (!i) i = 1; term->frame_duration = i; @@ -2085,7 +2124,7 @@ void gf_term_process_shortcut(GF_Terminal *term, GF_Event *ev) u8 mod = 0; if (ev->key.flags & GF_KEY_MOD_CTRL) mod |= GF_KEY_MOD_CTRL; if (ev->key.flags & GF_KEY_MOD_ALT) mod |= GF_KEY_MOD_ALT; - + for (i=0; ishortcuts[i].code) break; @@ -2294,7 +2333,7 @@ void gf_scene_switch_quality(GF_Scene *scene, Bool up) net_cmd.switch_quality.on_channel = NULL; net_cmd.switch_quality.up = up; if (scene->root_od->net_service) { - root_service = scene->root_od->net_service; + root_service = scene->root_od->net_service; root_service->ifce->ServiceCommand(root_service->ifce, &net_cmd); } @@ -2306,7 +2345,7 @@ void gf_scene_switch_quality(GF_Scene *scene, Bool up) } i=0; while (NULL != (odm = gf_list_enum(scene->resources, &i))) { - if (odm->codec) + if (odm->codec) odm->codec->decio->SetCapabilities(odm->codec->decio, caps); if (odm->net_service && (odm->net_service != root_service) ) odm->net_service->ifce->ServiceCommand(odm->net_service->ifce, &net_cmd); diff --git a/src/utils/alloc.c b/src/utils/alloc.c index 83d26f5..7ebde6a 100644 --- a/src/utils/alloc.c +++ b/src/utils/alloc.c @@ -2,7 +2,7 @@ * GPAC - Multimedia Framework C SDK * * Authors: Romain Bouqueau - Jean Le Feuvre - * Copyright (c) Telecom ParisTech 2010-20XX + * Copyright (c) Telecom ParisTech 2010-20XX * All rights reserved * * This file is part of GPAC / common tools sub-project @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -73,7 +73,7 @@ #endif #if (USE_MALLOC==INTEL_MALLOC) -#define CDECL +#define CDECL CDECL void * scalable_malloc(size_t size); CDECL void * scalable_realloc(void* ptr, size_t size); CDECL void * scalable_calloc(size_t num, size_t size); @@ -91,8 +91,8 @@ CDECL void scalable_free(void* ptr); #endif -#ifndef CDECL -#define CDECL +#ifndef CDECL +#define CDECL #endif #ifndef SYMBOL_EXPORT @@ -317,25 +317,25 @@ MY_GF_EXPORT void *gf_mem_calloc(size_t num, size_t size_of, char *filename, int return gf_mem_calloc_proto(num, size_of, filename, line); } -MY_GF_EXPORT +MY_GF_EXPORT void *gf_mem_realloc(void *ptr, size_t size, char *filename, int line) { return gf_mem_realloc_proto(ptr, size, filename, line); } -MY_GF_EXPORT +MY_GF_EXPORT void gf_mem_free(void *ptr, char *filename, int line) { gf_mem_free_proto(ptr, filename, line); } -MY_GF_EXPORT +MY_GF_EXPORT char *gf_mem_strdup(const char *str, char *filename, int line) { return gf_mem_strdup_proto(str, filename, line); } -MY_GF_EXPORT +MY_GF_EXPORT void gf_mem_enable_tracker() { gf_mem_malloc_proto = gf_mem_malloc_tracker; @@ -548,7 +548,7 @@ static void register_address(void *ptr, size_t size, char *filename, int line) /*update stats*/ gpac_allocated_memory += size; gpac_nb_alloc_blocs++; - + /*gf_memory_log(GF_MEMORY_DEBUG, "[MemTracker] register %6d bytes at %p (%8d Bytes in %4d Blocks allocated)\n", size, ptr, gpac_allocated_memory, gpac_nb_alloc_blocs);*/ /*unlock*/ @@ -759,7 +759,7 @@ int gf_asprintf(char **strp, const char *fmt, ...) size = gf_vasprintf(strp, fmt, args); #else size = asprintf(strp, fmt, args); -#endif +#endif va_end(args); return size; } diff --git a/src/utils/base_encoding.c b/src/utils/base_encoding.c index 97afacb..8ea602f 100644 --- a/src/utils/base_encoding.c +++ b/src/utils/base_encoding.c @@ -11,21 +11,23 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include +#ifndef GPAC_DISABLE_CORE_TOOLS + static const char base_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; GF_EXPORT @@ -35,7 +37,7 @@ u32 gf_base64_encode(char *_in, u32 inSize, char *_out, u32 outSize) u32 i = 0, j = 0; unsigned char *in = (unsigned char *)_in; unsigned char *out = (unsigned char *)_out; - + if (outSize < (inSize * 4 / 3)) return 0; while (i < inSize) { @@ -50,7 +52,7 @@ u32 gf_base64_encode(char *_in, u32 inSize, char *_out, u32 outSize) out[j+1] = base_64[((in[i] & 0x03) << 4) | ((in[i+1] & 0xf0) >> 4)]; out[j+2] = base_64[(in[i+1] & 0x0f) << 2]; out[j+3] = '='; - } else{ + } else { out[j] = base_64[in[i]>>2]; out[j+1] = base_64[((in[i] & 0x03) << 4) | ((in[i+1] & 0xf0) >> 4)]; out[j+2] = base_64[((in[i+1] & 0x0f) << 2) | ((in[i+2] & 0xc0) >> 6)]; @@ -63,37 +65,40 @@ u32 gf_base64_encode(char *_in, u32 inSize, char *_out, u32 outSize) } static const unsigned char index_64[128] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62, 0xff, 0xff, 0xff, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62, 0xff, 0xff, 0xff, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff }; #define char64(c) ((c > 127) ? (char) 0xff : index_64[(c)]) /*denoise input*/ -u32 load_block(char *in, u32 size, u32 pos, char *out) -{ - u32 i, len; +u32 load_block(char *in, u32 size, u32 pos, char *out) +{ + u32 i, len; u8 c; len = i = 0; while ((len<4) && ((pos+i)='A') && (c<='Z')) - || ((c>='a') && (c<='z')) - || ((c>='0') && (c<='9')) - || (c=='=') || (c=='+') || (c=='/') - ) { + || ((c>='a') && (c<='z')) + || ((c>='0') && (c<='9')) + || (c=='=') || (c=='+') || (c=='/') + ) { out[len] = c; len++; } i++; } - while (len<4) { out[len] = (char) 0xFF; len++; } + while (len<4) { + out[len] = (char) 0xFF; + len++; + } return pos+i; } @@ -108,13 +113,13 @@ u32 gf_base64_decode(char *in_buf, u32 inSize, char *out, u32 outSize) while ((i + 3) < inSize) { padding = 0; i = load_block(in_buf, inSize, i, (char*)in); - c[0] = char64(in[0]); + c[0] = char64(in[0]); padding += (c[0] == 0xff); c[1] = char64(in[1]); padding += (c[1] == 0xff); c[2] = char64(in[2]); padding += (c[2] == 0xff); - c[3] = char64(in[3]); + c[3] = char64(in[3]); padding += (c[3] == 0xff); if (padding == 2) { out[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4); @@ -144,12 +149,12 @@ u32 gf_base16_encode(char *_in, u32 inSize, char *_out, u32 outSize) if (outSize < (inSize * 2)+1) return 0; - for (i=0;i> 4)]; - out[2*i+1] = base_16[(in[i] & 0x0f)]; + out[2*i+1] = base_16[(in[i] & 0x0f)]; } out[(inSize * 2)] = 0; - + return i; } @@ -163,14 +168,14 @@ u32 gf_base16_decode(char *in, u32 inSize, char *out, u32 outSize) if (outSize < (inSize / 2)) return 0; if ((inSize % 2) != 0) return 0; - - for (j=0;joriginal[bs->position++]; } - if (bs->buffer_io) + if (bs->buffer_io) bs_flush_cache(bs); /*we are in FILE mode, test for end of file*/ @@ -232,9 +232,9 @@ static u32 bits_mask[] = {0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F}; GF_EXPORT u8 gf_bs_read_bit(GF_BitStream *bs) { - if (bs->nbBits == 8) { + if (bs->nbBits == 8) { bs->current = BS_ReadByte(bs); - bs->nbBits = 0; + bs->nbBits = 0; } #ifdef NO_OPTS { @@ -258,7 +258,7 @@ u32 gf_bs_read_int(GF_BitStream *bs, u32 nBits) #ifndef NO_OPTS if (nBits + bs->nbBits <= 8) { bs->nbBits += nBits; - ret = (bs->current >> (8 - bs->nbBits) ) & bits_mask[nBits]; + ret = (bs->current >> (8 - bs->nbBits) ) & bits_mask[nBits]; return ret; } #endif @@ -278,14 +278,14 @@ u32 gf_bs_read_u8(GF_BitStream *bs) } GF_EXPORT -u32 gf_bs_read_u8_until_delimiter(GF_BitStream *bs, u8 delimiter, u8* out, u32 max_length){ +u32 gf_bs_read_u8_until_delimiter(GF_BitStream *bs, u8 delimiter, u8* out, u32 max_length) { u32 i = 0; char token; u64 cur_pos = gf_bs_get_position(bs); if (!max_length) out = NULL; - while(gf_bs_available(bs) && (!max_length || i < max_length)){ + while(gf_bs_available(bs) && (!max_length || i < max_length)) { gf_bs_read_data(bs, &token, 1); if (token == delimiter) goto found; if (out) out[i] = token; @@ -305,7 +305,8 @@ u32 gf_bs_read_u16(GF_BitStream *bs) { u32 ret; assert(bs->nbBits==8); - ret = BS_ReadByte(bs); ret<<=8; + ret = BS_ReadByte(bs); + ret<<=8; ret |= BS_ReadByte(bs); return ret; } @@ -316,8 +317,10 @@ u32 gf_bs_read_u24(GF_BitStream *bs) { u32 ret; assert(bs->nbBits==8); - ret = BS_ReadByte(bs); ret<<=8; - ret |= BS_ReadByte(bs); ret<<=8; + ret = BS_ReadByte(bs); + ret<<=8; + ret |= BS_ReadByte(bs); + ret<<=8; ret |= BS_ReadByte(bs); return ret; } @@ -327,9 +330,12 @@ u32 gf_bs_read_u32(GF_BitStream *bs) { u32 ret; assert(bs->nbBits==8); - ret = BS_ReadByte(bs); ret<<=8; - ret |= BS_ReadByte(bs); ret<<=8; - ret |= BS_ReadByte(bs); ret<<=8; + ret = BS_ReadByte(bs); + ret<<=8; + ret |= BS_ReadByte(bs); + ret<<=8; + ret |= BS_ReadByte(bs); + ret<<=8; ret |= BS_ReadByte(bs); return ret; } @@ -338,7 +344,8 @@ GF_EXPORT u64 gf_bs_read_u64(GF_BitStream *bs) { u64 ret; - ret = gf_bs_read_u32(bs); ret<<=32; + ret = gf_bs_read_u32(bs); + ret<<=32; ret |= gf_bs_read_u32(bs); return ret; } @@ -362,7 +369,7 @@ u64 gf_bs_read_long_int(GF_BitStream *bs, u32 nBits) GF_EXPORT Float gf_bs_read_float(GF_BitStream *bs) -{ +{ char buf [4] = "\0\0\0"; #ifdef NO_OPTS s32 i; @@ -404,7 +411,7 @@ u32 gf_bs_read_data(GF_BitStream *bs, char *data, u32 nbBytes) return nbBytes; case GF_BITSTREAM_FILE_READ: case GF_BITSTREAM_FILE_WRITE: - if (bs->buffer_io) + if (bs->buffer_io) bs_flush_cache(bs); nbBytes = (u32) fread(data, 1, nbBytes, bs->stream); bs->position += nbBytes; @@ -554,7 +561,7 @@ u32 gf_bs_write_byte(GF_BitStream *bs, u8 byte, u32 repeat_count) switch (bs->bsmode) { case GF_BITSTREAM_WRITE: - if (bs->position + repeat_count > bs->size) + if (bs->position + repeat_count > bs->size) return 0; memset(bs->original + bs->position, byte, repeat_count); bs->position += repeat_count; @@ -565,12 +572,12 @@ u32 gf_bs_write_byte(GF_BitStream *bs, u8 byte, u32 repeat_count) u32 new_size = (u32) (bs->size*2); if (!new_size) new_size = BS_MEM_BLOCK_ALLOC_SIZE; - if (bs->size + repeat_count > 0xFFFFFFFF) + if (bs->size + repeat_count > 0xFFFFFFFF) return 0; while (new_size < (u32) ( bs->size + repeat_count)) new_size *= 2; bs->original = (char*)gf_realloc(bs->original, sizeof(u32)*new_size); - if (!bs->original) + if (!bs->original) return 0; bs->size = new_size; } @@ -631,7 +638,7 @@ u32 gf_bs_write_data(GF_BitStream *bs, const char *data, u32 nbBytes) if (BS_IsAlign(bs)) { switch (bs->bsmode) { case GF_BITSTREAM_WRITE: - if (bs->position+nbBytes > bs->size) + if (bs->position+nbBytes > bs->size) return 0; memcpy(bs->original + bs->position, data, nbBytes); bs->position += nbBytes; @@ -641,14 +648,14 @@ u32 gf_bs_write_data(GF_BitStream *bs, const char *data, u32 nbBytes) if (bs->position+nbBytes > bs->size) { u32 new_size = (u32) (bs->size*2); if (!new_size) new_size = BS_MEM_BLOCK_ALLOC_SIZE; - - if (bs->size + nbBytes > 0xFFFFFFFF) + + if (bs->size + nbBytes > 0xFFFFFFFF) return 0; while (new_size < (u32) ( bs->size + nbBytes)) new_size *= 2; bs->original = (char*)gf_realloc(bs->original, sizeof(u32)*new_size); - if (!bs->original) + if (!bs->original) return 0; bs->size = new_size; } @@ -712,9 +719,9 @@ u64 gf_bs_available(GF_BitStream *bs) s64 cur, end; /*in WRITE mode only, this should not be called, but return something big in case ...*/ - if ( (bs->bsmode == GF_BITSTREAM_WRITE) - || (bs->bsmode == GF_BITSTREAM_WRITE_DYN) - ) + if ( (bs->bsmode == GF_BITSTREAM_WRITE) + || (bs->bsmode == GF_BITSTREAM_WRITE_DYN) + ) return (u64) -1; /*we are in MEM mode*/ @@ -733,16 +740,16 @@ u64 gf_bs_available(GF_BitStream *bs) cur = gf_f64_tell(bs->stream); gf_f64_seek(bs->stream, 0, SEEK_END); end = gf_f64_tell(bs->stream); - gf_f64_seek(bs->stream, cur, SEEK_SET); + gf_f64_seek(bs->stream, cur, SEEK_SET); return (u64) (end - cur); } -/*call this funct to set the buffer size to the nb of bytes written +/*call this funct to set the buffer size to the nb of bytes written Used only in WRITE mode, as we don't know the real size during allocation... return -1 for bad param or gf_malloc failed return nbBytes cut*/ static s32 BS_CutBuffer(GF_BitStream *bs) -{ +{ s32 nbBytes; if ( (bs->bsmode != GF_BITSTREAM_WRITE_DYN) && (bs->bsmode != GF_BITSTREAM_WRITE)) return (u32) -1; /*Align our buffer or we're dead!*/ @@ -750,10 +757,10 @@ static s32 BS_CutBuffer(GF_BitStream *bs) nbBytes = (u32) (bs->size - bs->position); if (!nbBytes || (nbBytes == 0xFFFFFFFF) || (bs->position >= 0xFFFFFFFF)) return 0; -/* - bs->original = (char*)gf_realloc(bs->original, (u32) bs->position); - if (! bs->original) return (u32) -1; -*/ + /* + bs->original = (char*)gf_realloc(bs->original, (u32) bs->position); + if (! bs->original) return (u32) -1; + */ /*just in case, re-adjust..*/ bs->size = bs->position; return nbBytes; @@ -771,10 +778,10 @@ void gf_bs_get_content(GF_BitStream *bs, char **output, u32 *outSize) gf_free(bs->original); } else { s32 copy = BS_CutBuffer(bs); - if (copy < 0){ - *output = NULL; + if (copy < 0) { + *output = NULL; } else - *output = bs->original; + *output = bs->original; *outSize = (u32) bs->size; } bs->original = NULL; @@ -782,7 +789,7 @@ void gf_bs_get_content(GF_BitStream *bs, char **output, u32 *outSize) bs->position = 0; } -/* Skip nbytes. +/* Skip nbytes. Align If READ (MEM or FILE) mode, just read n times 8 bit If WRITE (MEM or FILE) mode, write n times 0 on 8 bit @@ -793,7 +800,7 @@ void gf_bs_skip_bytes(GF_BitStream *bs, u64 nbBytes) if (!bs || !nbBytes) return; gf_bs_align(bs); - + /*special case for file skipping...*/ if ((bs->bsmode == GF_BITSTREAM_FILE_WRITE) || (bs->bsmode == GF_BITSTREAM_FILE_READ)) { if (bs->buffer_io) @@ -965,9 +972,15 @@ u32 gf_bs_read_u32_le(GF_BitStream *bs) { u32 ret, v; ret = gf_bs_read_int(bs, 8); - v = gf_bs_read_int(bs, 8); v<<=8; ret |= v; - v = gf_bs_read_int(bs, 8); v<<=16; ret |= v; - v = gf_bs_read_int(bs, 8); v<<=24; ret |= v; + v = gf_bs_read_int(bs, 8); + v<<=8; + ret |= v; + v = gf_bs_read_int(bs, 8); + v<<=16; + ret |= v; + v = gf_bs_read_int(bs, 8); + v<<=24; + ret |= v; return ret; } @@ -976,7 +989,9 @@ u16 gf_bs_read_u16_le(GF_BitStream *bs) { u32 ret, v; ret = gf_bs_read_int(bs, 8); - v = gf_bs_read_int(bs, 8); v<<=8; ret |= v; + v = gf_bs_read_int(bs, 8); + v<<=8; + ret |= v; return ret; } diff --git a/src/utils/cache.c b/src/utils/cache.c index a98e333..927dee3 100644 --- a/src/utils/cache.c +++ b/src/utils/cache.c @@ -23,6 +23,8 @@ * */ +#ifndef GPAC_DISABLE_CORE_TOOLS + #include #include #include @@ -382,14 +384,14 @@ DownloadedCacheEntry gf_cache_create_entry ( GF_DownloadManager * dm, const char DownloadedCacheEntry entry = NULL; if ( !dm || !url || !cache_directory) { GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, - ("[CACHE] gf_cache_create_entry :%d, dm=%p, url=%s cache_directory=%s, aborting.\n", __LINE__, dm, url, cache_directory)); + ("[CACHE] gf_cache_create_entry :%d, dm=%p, url=%s cache_directory=%s, aborting.\n", __LINE__, dm, url, cache_directory)); return entry; } sz = (u32) strlen ( url ); if ( sz > _CACHE_TMP_SIZE ) { GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, - ("[CACHE] gf_cache_create_entry:%d : ERROR, URL is too long (%d chars), more than %d chars.\n", __LINE__, sz, _CACHE_TMP_SIZE )); + ("[CACHE] gf_cache_create_entry:%d : ERROR, URL is too long (%d chars), more than %d chars.\n", __LINE__, sz, _CACHE_TMP_SIZE )); return entry; } tmp[0] = '\0'; @@ -470,7 +472,7 @@ DownloadedCacheEntry gf_cache_create_entry ( GF_DownloadManager * dm, const char if (entry->memory_stored) { sprintf(entry->cache_filename, "gmem://%d@%p", entry->contentLength, entry->mem_storage); - return entry; + return entry; } @@ -557,7 +559,7 @@ GF_Err gf_cache_close_write_cache( const DownloadedCacheEntry entry, const GF_Do assert( sess == entry->write_session ); if (entry->writeFilePtr) { GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, - ("[CACHE] Closing file %s, %d bytes written.\n", entry->cache_filename, entry->written_in_cache)); + ("[CACHE] Closing file %s, %d bytes written.\n", entry->cache_filename, entry->written_in_cache)); if (fflush( entry->writeFilePtr ) || fclose( entry->writeFilePtr )) e = GF_IO_ERR; e|= gf_cache_flush_disk_cache(entry); @@ -619,7 +621,7 @@ GF_Err gf_cache_open_write_cache( const DownloadedCacheEntry entry, const GF_Dow entry->writeFilePtr = gf_f64_open(entry->cache_filename, entry->continue_file ? "a+b" : "wb"); if (!entry->writeFilePtr) { GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, - ("[CACHE] Error while opening cache file %s for writting.\n", entry->cache_filename)); + ("[CACHE] Error while opening cache file %s for writting.\n", entry->cache_filename)); entry->write_session = NULL; #ifdef ENABLE_WRITE_MX gf_mx_v(entry->write_mutex); @@ -640,7 +642,7 @@ GF_Err gf_cache_write_to_cache( const DownloadedCacheEntry entry, const GF_Downl GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("Incorrect parameter : data=%p, writeFilePtr=%p mem_storage=%p at "__FILE__"\n", data, entry->writeFilePtr, entry->mem_storage)); return GF_BAD_PARAM; } - + if (entry->memory_stored) { if (entry->written_in_cache + size > entry->mem_allocated) { u32 new_size = MAX(entry->mem_allocated*2, entry->written_in_cache + size); @@ -664,14 +666,14 @@ GF_Err gf_cache_write_to_cache( const DownloadedCacheEntry entry, const GF_Downl if (read != size) { /* Something bad happened */ GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, - ("[CACHE] Error while writting %d bytes of data to cache : has written only %d bytes.", size, read)); + ("[CACHE] Error while writting %d bytes of data to cache : has written only %d bytes.", size, read)); gf_cache_close_write_cache(entry, sess, 0); gf_delete_file(entry->cache_filename); return GF_IO_ERR; } if (fflush(entry->writeFilePtr)) { GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, - ("[CACHE] Error while flushing data bytes to cache file : %s.", entry->cache_filename)); + ("[CACHE] Error while flushing data bytes to cache file : %s.", entry->cache_filename)); gf_cache_close_write_cache(entry, sess, 0); gf_delete_file(entry->cache_filename); return GF_IO_ERR; @@ -789,7 +791,7 @@ GF_Err gf_cache_delete_entry ( const DownloadedCacheEntry entry ) gf_free ( entry->mimeType ); entry->mimeType = NULL; } - if (entry->mem_storage) { + if (entry->mem_storage) { gf_free(entry->mem_storage); } @@ -869,7 +871,7 @@ s32 gf_cache_remove_session_from_cache_entry(DownloadedCacheEntry entry, GF_Down /* OK, this is not optimal to close it since we are in a mutex, * but we don't want to risk to have another session opening * a not fully closed cache entry */ - if (entry->writeFilePtr){ + if (entry->writeFilePtr) { if (fclose(entry->writeFilePtr)) { GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] gf_cache_remove_session_from_cache_entry:%d, Failed to properly fclose cache file '%s' of url '%s', cache may be corrupted !\n", __LINE__, entry->cache_filename, entry->url)); } @@ -907,7 +909,7 @@ s32 gf_cache_add_session_to_cache_entry(DownloadedCacheEntry entry, GF_DownloadS return count + 1; } -FILE *gf_cache_get_file_pointer(const DownloadedCacheEntry entry) +FILE *gf_cache_get_file_pointer(const DownloadedCacheEntry entry) { if (entry) return entry->writeFilePtr; return NULL; @@ -925,7 +927,9 @@ Bool gf_cache_is_in_progress(const DownloadedCacheEntry entry) { if (!entry) return 0; if (entry->writeFilePtr) return 1; - if (entry->mem_storage && entry->written_in_cache && entry->contentLength && (entry->written_in_cachecontentLength) ) + if (entry->mem_storage && entry->written_in_cache && entry->contentLength && (entry->written_in_cachecontentLength) ) return 1; return 0; } + +#endif diff --git a/src/utils/color.c b/src/utils/color.c index 3ed6cb2..f7d91f8 100644 --- a/src/utils/color.c +++ b/src/utils/color.c @@ -202,7 +202,7 @@ static void gf_yuv_load_lines_packed(unsigned char *dst, s32 dststride, unsigned static void gf_yuva_load_lines(unsigned char *dst, s32 dststride, unsigned char *y_src, unsigned char *u_src, unsigned char *v_src, unsigned char *a_src, - s32 y_stride, s32 uv_stride, s32 width) + s32 y_stride, s32 uv_stride, s32 width) { u32 hw, x; unsigned char *dst2 = dst + dststride; @@ -277,7 +277,10 @@ static void copy_row_rgb_555(u8 *src, u32 src_w, u8 *_dst, u32 dst_w, s32 h_inc, pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } if (a) *dst = GF_COL_555(r, g, b); @@ -296,7 +299,10 @@ static void copy_row_rgb_565(u8 *src, u32 src_w, u8 *_dst, u32 dst_w, s32 h_inc, pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } if (a) *dst = GF_COL_565(r, g, b); @@ -315,10 +321,17 @@ static void copy_row_rgb_24(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } - if (a) { dst[0] = r; dst[1] = g; dst[2] = b; } + if (a) { + dst[0] = r; + dst[1] = g; + dst[2] = b; + } dst += x_pitch; pos += h_inc; dst_w--; @@ -333,10 +346,17 @@ static void copy_row_bgr_24(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } - if (a) { dst[0] = b; dst[1] = g; dst[2] = r; } + if (a) { + dst[0] = b; + dst[1] = g; + dst[2] = r; + } dst += x_pitch; pos += h_inc; dst_w--; @@ -350,7 +370,10 @@ static void copy_row_bgrx(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s32 while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } if (a) { @@ -372,7 +395,10 @@ static void copy_row_rgbx(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s32 while ( dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } if (a) { @@ -394,7 +420,10 @@ static void copy_row_rgbd(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s32 while ( dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } dst[0] = r; @@ -418,7 +447,10 @@ static void merge_row_rgb_555(u8 *src, u32 src_w, u8 *_dst, u32 dst_w, s32 h_inc pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; a = mul255(a, alpha); } @@ -447,7 +479,10 @@ static void merge_row_rgb_565(u8 *src, u32 src_w, u8 *_dst, u32 dst_w, s32 h_inc pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; a = mul255(a, alpha); } @@ -476,12 +511,17 @@ static void merge_row_rgb_24(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; a = mul255(a, alpha); } if (a) { - _r = dst[0]; _g = dst[0]; _b = dst[0]; + _r = dst[0]; + _g = dst[0]; + _b = dst[0]; dst[0] = mul255(a, r - _r) + _r; dst[1] = mul255(a, g - _g) + _g; dst[2] = mul255(a, b - _b) + _b; @@ -500,14 +540,17 @@ static void merge_row_bgr_24(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; } if (a && alpha) { _b = dst[0]; _g = dst[1]; - _r = dst[2]; + _r = dst[2]; a = mul255(a, alpha); dst[0] = mul255(a, b - _b) + _b; dst[1] = mul255(a, g - _g) + _g; @@ -528,7 +571,10 @@ static void merge_row_bgrx(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s3 pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; a = mul255(a, alpha); pos -= 0x10000L; } @@ -541,7 +587,7 @@ static void merge_row_bgrx(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s3 _r = mul255(a, r - _r) + _r; _g = mul255(a, g - _g) + _g; _b = mul255(a, b - _b) + _b; - + dst[0] = _b; dst[1] = _g; dst[2] = _r; @@ -561,7 +607,10 @@ static void merge_row_rgbx(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s3 pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; a = mul255(a, alpha); pos -= 0x10000L; } @@ -593,7 +642,10 @@ static void merge_row_bgra(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s3 pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; a = mul255(a, alpha); } @@ -631,7 +683,10 @@ static void merge_row_rgba(u8 *src, u32 src_w, u8 *dst, u32 dst_w, s32 h_inc, s3 pos = 0x10000; while (dst_w) { while ( pos >= 0x10000L ) { - r = *src++; g = *src++; b = *src++; a = *src++; + r = *src++; + g = *src++; + b = *src++; + a = *src++; pos -= 0x10000L; a = mul255(a, alpha); } @@ -687,8 +742,8 @@ static void load_line_alpha_grey(u8 *src_bits, u32 x_offset, u32 y_offset, u32 y static GFINLINE u8 colmask(s32 a, s32 n) { - s32 mask = (1 << n) - 1; - return (u8) (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); + s32 mask = (1 << n) - 1; + return (u8) (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); } static void load_line_rgb_555(u8 *src_bits, u32 x_offset, u32 y_offset, u32 y_pitch, u32 width, u32 height, u8 *dst_bits) @@ -908,7 +963,7 @@ static void load_line_YUV420SP(u8 *src_bits, u32 x_offset, u32 y_offset, u32 y_p b = 262143; *((u32*)dst_bits) = 0xff000000 | ((b << 6) & 0xff0000) - | ((g >> 2) & 0xff00) | ((r >> 10) & 0xff); + | ((g >> 2) & 0xff00) | ((r >> 10) & 0xff); dst_bits+=4; } } @@ -1134,9 +1189,12 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds for (i=0; i<2*src_w; i++) { u32 idx = 4*i; s32 thres, v; - v = tmp[idx]-kr; thres = ABS(v); - v = tmp[idx+1]-kg; thres += ABS(v); - v = tmp[idx+2]-kb; thres += ABS(v); + v = tmp[idx]-kr; + thres = ABS(v); + v = tmp[idx+1]-kg; + thres += ABS(v); + v = tmp[idx+2]-kb; + thres += ABS(v); thres/=3; #ifdef COLORKEY_MPEG4_STRICT if (thres < kl) tmp[idx+3] = 0; @@ -1171,9 +1229,12 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds for (i=0; i<2*src_w; i++) { u32 idx = 4*i; s32 thres, v; - v = tmp[idx]-kr; thres = ABS(v); - v = tmp[idx+1]-kg; thres += ABS(v); - v = tmp[idx+2]-kb; thres += ABS(v); + v = tmp[idx]-kr; + thres = ABS(v); + v = tmp[idx+1]-kg; + thres += ABS(v); + v = tmp[idx+2]-kb; + thres += ABS(v); thres/=3; #ifdef COLORKEY_MPEG4_STRICT if (thres < kl) tmp[idx+3] = 0; @@ -1199,9 +1260,12 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds for (i=0; im[0] = c1; _this->m[1] = c2; _this->m[2] = c3; _this->m[3] = c4; _this->m[4] = c5; - _this->m[5] = c6; _this->m[6] = c7; _this->m[7] = c8; _this->m[8] = c9; _this->m[9] = c10; - _this->m[10] = c11; _this->m[11] = c12; _this->m[12] = c13; _this->m[13] = c14; _this->m[14] = c15; - _this->m[15] = c16; _this->m[16] = c17; _this->m[17] = c18; _this->m[18] = c19; _this->m[19] = c20; + _this->m[0] = c1; + _this->m[1] = c2; + _this->m[2] = c3; + _this->m[3] = c4; + _this->m[4] = c5; + _this->m[5] = c6; + _this->m[6] = c7; + _this->m[7] = c8; + _this->m[8] = c9; + _this->m[9] = c10; + _this->m[10] = c11; + _this->m[11] = c12; + _this->m[12] = c13; + _this->m[13] = c14; + _this->m[14] = c15; + _this->m[15] = c16; + _this->m[16] = c17; + _this->m[17] = c18; + _this->m[18] = c19; + _this->m[19] = c20; gf_cmx_identity(_this); } @@ -1367,10 +1447,14 @@ GF_Color gf_cmx_apply(GF_ColorMatrix *_this, GF_Color col) Fixed _a, _r, _g, _b, a, r, g, b; if (!_this || _this->identity) return col; - a = INT2FIX(col>>24); a /= 255; - r = INT2FIX((col>>16)&0xFF); r /= 255; - g = INT2FIX((col>>8)&0xFF); g /= 255; - b = INT2FIX((col)&0xFF); b /= 255; + a = INT2FIX(col>>24); + a /= 255; + r = INT2FIX((col>>16)&0xFF); + r /= 255; + g = INT2FIX((col>>8)&0xFF); + g /= 255; + b = INT2FIX((col)&0xFF); + b /= 255; _r = gf_mulfix(r, _this->m[0]) + gf_mulfix(g, _this->m[1]) + gf_mulfix(b, _this->m[2]) + gf_mulfix(a, _this->m[3]) + _this->m[4]; _g = gf_mulfix(r, _this->m[5]) + gf_mulfix(g, _this->m[6]) + gf_mulfix(b, _this->m[7]) + gf_mulfix(a, _this->m[8]) + _this->m[9]; _b = gf_mulfix(r, _this->m[10]) + gf_mulfix(g, _this->m[11]) + gf_mulfix(b, _this->m[12]) + gf_mulfix(a, _this->m[13]) + _this->m[14]; @@ -1434,17 +1518,17 @@ static GF_Err gf_color_write_yv12_10_to_yuv_intrin(GF_VideoSurface *vs_dst, uns src1 = (__m128i *)(pY + i*src_stride); src2 = src1+1; dst = (__m128i *)(vs_dst->video_buffer + i*vs_dst->pitch_y); - + for (j=0; jvideo_buffer + 5*vs_dst->pitch_y * vs_dst->height/4 + i*vs_dst->pitch_y/2); - + for (j=0; jvideo_buffer + vs_dst->pitch_y)%8 == 0) - && (GFINTCAST (vs_dst->video_buffer + vs_dst->pitch_y * vs_dst->height + vs_dst->pitch_y/2)%8 == 0) - && (GFINTCAST (pU + src_stride/2)%8 == 0) - && (GFINTCAST (pV + src_stride/2)%8 == 0) - ) { + && (GFINTCAST (vs_dst->video_buffer + vs_dst->pitch_y)%8 == 0) + && (GFINTCAST (vs_dst->video_buffer + vs_dst->pitch_y * vs_dst->height + vs_dst->pitch_y/2)%8 == 0) + && (GFINTCAST (pU + src_stride/2)%8 == 0) + && (GFINTCAST (pV + src_stride/2)%8 == 0) + ) { return gf_color_write_yv12_10_to_yuv_intrin(vs_dst, pY, pU, pV, src_stride, src_width, src_height, _src_wnd); } #endif @@ -1531,7 +1615,7 @@ GF_Err gf_color_write_yv12_10_to_yuv(GF_VideoSurface *vs_dst, unsigned char *pY u16 *src = (u16 *) (pY + i*src_stride); u8 *dst = (u8 *) vs_dst->video_buffer + i*vs_dst->pitch_y; - for (j=0; j> 2; dst++; src++; @@ -1542,7 +1626,7 @@ GF_Err gf_color_write_yv12_10_to_yuv(GF_VideoSurface *vs_dst, unsigned char *pY u16 *src = (u16 *) (pU + i*src_stride/2); u8 *dst = (u8 *) vs_dst->video_buffer + vs_dst->pitch_y * vs_dst->height + i*vs_dst->pitch_y/2; - for (j=0; j> 2; dst++; src++; @@ -1553,7 +1637,7 @@ GF_Err gf_color_write_yv12_10_to_yuv(GF_VideoSurface *vs_dst, unsigned char *pY u16 *src = (u16 *) (pV + i*src_stride/2); u8 *dst = (u8 *) vs_dst->video_buffer + 5*vs_dst->pitch_y * vs_dst->height/4 + i*vs_dst->pitch_y/2; - for (j=0; j> 2; dst++; src++; diff --git a/src/utils/configfile.c b/src/utils/configfile.c index caa47a2..a6d5aaa 100644 --- a/src/utils/configfile.c +++ b/src/utils/configfile.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -71,16 +71,16 @@ static void DelSection(IniSection *ptr) * \brief Clear the structure * \param iniFile The structure to clear */ -static void gf_cfg_clear(GF_Config * iniFile){ +static void gf_cfg_clear(GF_Config * iniFile) { IniSection *p; if (!iniFile) return; - if (iniFile->sections){ - while (gf_list_count(iniFile->sections)) { - p = (IniSection *) gf_list_get(iniFile->sections, 0); - DelSection(p); - gf_list_rem(iniFile->sections, 0); - } - gf_list_del(iniFile->sections); + if (iniFile->sections) { + while (gf_list_count(iniFile->sections)) { + p = (IniSection *) gf_list_get(iniFile->sections, 0); + DelSection(p); + gf_list_rem(iniFile->sections, 0); + } + gf_list_del(iniFile->sections); } if (iniFile->fileName) gf_free(iniFile->fileName); @@ -115,7 +115,7 @@ GF_Err gf_cfg_parse_config_file(GF_Config * tmp, const char * filePath, const ch tmp->sections = gf_list_new(); file = gf_f64_open(fileName, "rt"); if (!file) - return GF_IO_ERR; + return GF_IO_ERR; /* load the file */ p = NULL; line = gf_malloc(sizeof(char)*line_alloc); @@ -143,7 +143,7 @@ GF_Err gf_cfg_parse_config_file(GF_Config * tmp, const char * filePath, const ch if (!strlen(line)) continue; if (line[0] == '#') continue; - + /* new section */ if (line[0] == '[') { p = (IniSection *) gf_malloc(sizeof(IniSection)); @@ -189,7 +189,7 @@ GF_Err gf_cfg_parse_config_file(GF_Config * tmp, const char * filePath, const ch } GF_EXPORT -GF_Config *gf_cfg_force_new(const char *filePath, const char* file_name){ +GF_Config *gf_cfg_force_new(const char *filePath, const char* file_name) { GF_Config *tmp = (GF_Config *)gf_malloc(sizeof(GF_Config)); memset((void *)tmp, 0, sizeof(GF_Config)); gf_cfg_parse_config_file(tmp, filePath, file_name); @@ -207,23 +207,23 @@ GF_Config *gf_cfg_new(const char *filePath, const char* file_name) return tmp; } - if (gf_cfg_parse_config_file(tmp, filePath, file_name)){ + if (gf_cfg_parse_config_file(tmp, filePath, file_name)) { gf_cfg_clear(tmp); gf_free(tmp); - tmp = NULL; + tmp = NULL; } return tmp; } -GF_EXPORT +GF_EXPORT char * gf_cfg_get_filename(GF_Config *iniFile) { - if (!iniFile) - return NULL; - return iniFile->fileName ? gf_strdup(iniFile->fileName) : NULL; + if (!iniFile) + return NULL; + return iniFile->fileName ? gf_strdup(iniFile->fileName) : NULL; } -GF_EXPORT +GF_EXPORT GF_Err gf_cfg_save(GF_Config *iniFile) { u32 i, j; @@ -255,7 +255,7 @@ GF_Err gf_cfg_save(GF_Config *iniFile) return GF_OK; } -GF_EXPORT +GF_EXPORT GF_Err gf_cfg_discard_changes(GF_Config *iniFile) { if (!iniFile) return GF_BAD_PARAM; @@ -305,22 +305,22 @@ get_key: GF_EXPORT const char *gf_cfg_get_ikey(GF_Config *iniFile, const char *secName, const char *keyName) { - u32 i; - IniSection *sec; - IniKey *key; + u32 i; + IniSection *sec; + IniKey *key; - i=0; - while ( (sec = (IniSection *) gf_list_enum(iniFile->sections, &i)) ) { - if (!stricmp(secName, sec->section_name)) goto get_key; - } - return NULL; + i=0; + while ( (sec = (IniSection *) gf_list_enum(iniFile->sections, &i)) ) { + if (!stricmp(secName, sec->section_name)) goto get_key; + } + return NULL; get_key: - i=0; - while ( (key = (IniKey *) gf_list_enum(sec->keys, &i)) ) { - if (!stricmp(key->name, keyName)) return key->value; - } - return NULL; + i=0; + while ( (key = (IniKey *) gf_list_enum(sec->keys, &i)) ) { + if (!stricmp(key->name, keyName)) return key->value; + } + return NULL; } @@ -469,15 +469,15 @@ const char *gf_cfg_get_sub_key(GF_Config *iniFile, const char *secName, const ch char *subKeyValue, *returnKey; char *keyValue; - + keyValue = gf_strdup(gf_cfg_get_key(iniFile, secName, keyName)); - if (!keyValue){ + if (!keyValue) { return NULL; } j = 0; - subKeyValue = strtok((char*)keyValue,";"); - while (subKeyValue!=NULL) { + subKeyValue = strtok((char*)keyValue,";"); + while (subKeyValue!=NULL) { if (j==sub_index) { returnKey = gf_strdup(subKeyValue); gf_free(keyValue); diff --git a/src/utils/dlmalloc.c b/src/utils/dlmalloc.c index 33fe1ab..23860d7 100644 --- a/src/utils/dlmalloc.c +++ b/src/utils/dlmalloc.c @@ -708,16 +708,16 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP #ifndef STRUCT_MALLINFO_DECLARED #define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; #endif /* STRUCT_MALLINFO_DECLARED */ #endif /* HAVE_USR_INCLUDE_MALLOC_H */ @@ -729,34 +729,34 @@ struct mallinfo { */ #ifdef WIN64 - #undef FORCEINLINE +#undef FORCEINLINE #endif #ifndef FORCEINLINE - #if defined(__GNUC__) +#if defined(__GNUC__) #define FORCEINLINE __inline __attribute__ ((always_inline)) - #elif defined(_MSC_VER) - #define FORCEINLINE __forceinline - #endif +#elif defined(_MSC_VER) +#define FORCEINLINE __forceinline +#endif #endif #ifndef NOINLINE - #if defined(__GNUC__) - #define NOINLINE __attribute__ ((noinline)) - #elif defined(_MSC_VER) - #define NOINLINE __declspec(noinline) - #else - #define NOINLINE - #endif +#if defined(__GNUC__) +#define NOINLINE __attribute__ ((noinline)) +#elif defined(_MSC_VER) +#define NOINLINE __declspec(noinline) +#else +#define NOINLINE +#endif #endif #ifdef __cplusplus extern "C" { #ifndef FORCEINLINE - #define FORCEINLINE inline +#define FORCEINLINE inline #endif #endif /* __cplusplus */ #ifndef FORCEINLINE - #define FORCEINLINE +#define FORCEINLINE #endif @@ -1255,7 +1255,7 @@ struct mallinfo mspace_mallinfo(mspace msp); /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ - size_t mspace_usable_size(void* mem); +size_t mspace_usable_size(void* mem); /* mspace_malloc_stats behaves as malloc_stats, but reports @@ -1407,7 +1407,7 @@ unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); # define malloc_getpagesize sysconf(_SC_PAGE_SIZE) # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); +extern size_t getpagesize(); # define malloc_getpagesize getpagesize() # else # ifdef WIN32 /* use supplied emulation of getpagesize */ @@ -1516,33 +1516,33 @@ static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ /* Win32 MMAP via VirtualAlloc */ static FORCEINLINE void* win32mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + return (ptr != 0)? ptr: MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static FORCEINLINE void* win32direct_mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; + void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + return (ptr != 0)? ptr: MFAIL; } /* This function supports releasing coalesed segments */ static FORCEINLINE int win32munmap(void* ptr, size_t size) { - MEMORY_BASIC_INFORMATION minfo; - char* cptr = (char*)ptr; - while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; - if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || - minfo.State != MEM_COMMIT || minfo.RegionSize > size) - return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; - cptr += minfo.RegionSize; - size -= minfo.RegionSize; - } - return 0; + MEMORY_BASIC_INFORMATION minfo; + char* cptr = (char*)ptr; + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + return 0; } #define MMAP_DEFAULT(s) win32mmap(s) @@ -1562,58 +1562,58 @@ static FORCEINLINE int win32munmap(void* ptr, size_t size) { * Define CALL_MORECORE */ #if HAVE_MORECORE - #ifdef MORECORE - #define CALL_MORECORE(S) MORECORE(S) - #else /* MORECORE */ - #define CALL_MORECORE(S) MORECORE_DEFAULT(S) - #endif /* MORECORE */ +#ifdef MORECORE +#define CALL_MORECORE(S) MORECORE(S) +#else /* MORECORE */ +#define CALL_MORECORE(S) MORECORE_DEFAULT(S) +#endif /* MORECORE */ #else /* HAVE_MORECORE */ - #define CALL_MORECORE(S) MFAIL +#define CALL_MORECORE(S) MFAIL #endif /* HAVE_MORECORE */ /** * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP */ #if HAVE_MMAP - #define USE_MMAP_BIT (SIZE_T_ONE) - - #ifdef MMAP - #define CALL_MMAP(s) MMAP(s) - #else /* MMAP */ - #define CALL_MMAP(s) MMAP_DEFAULT(s) - #endif /* MMAP */ - #ifdef MUNMAP - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) - #else /* MUNMAP */ - #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) - #endif /* MUNMAP */ - #ifdef DIRECT_MMAP - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #else /* DIRECT_MMAP */ - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) - #endif /* DIRECT_MMAP */ +#define USE_MMAP_BIT (SIZE_T_ONE) + +#ifdef MMAP +#define CALL_MMAP(s) MMAP(s) +#else /* MMAP */ +#define CALL_MMAP(s) MMAP_DEFAULT(s) +#endif /* MMAP */ +#ifdef MUNMAP +#define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#else /* MUNMAP */ +#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) +#endif /* MUNMAP */ +#ifdef DIRECT_MMAP +#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) +#else /* DIRECT_MMAP */ +#define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) +#endif /* DIRECT_MMAP */ #else /* HAVE_MMAP */ - #define USE_MMAP_BIT (SIZE_T_ZERO) - - #define MMAP(s) MFAIL - #define MUNMAP(a, s) (-1) - #define DIRECT_MMAP(s) MFAIL - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #define CALL_MMAP(s) MMAP(s) - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#define USE_MMAP_BIT (SIZE_T_ZERO) + +#define MMAP(s) MFAIL +#define MUNMAP(a, s) (-1) +#define DIRECT_MMAP(s) MFAIL +#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) +#define CALL_MMAP(s) MMAP(s) +#define CALL_MUNMAP(a, s) MUNMAP((a), (s)) #endif /* HAVE_MMAP */ /** * Define CALL_MREMAP */ #if HAVE_MMAP && HAVE_MREMAP - #ifdef MREMAP - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) - #else /* MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) - #endif /* MREMAP */ +#ifdef MREMAP +#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) +#else /* MREMAP */ +#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) +#endif /* MREMAP */ #else /* HAVE_MMAP && HAVE_MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL #endif /* HAVE_MMAP && HAVE_MREMAP */ /* mstate bit set if continguous morecore disabled or failed */ @@ -1662,9 +1662,9 @@ static FORCEINLINE int win32munmap(void* ptr, size_t size) { /* Custom pthread-style spin locks on x86 and x64 for gcc */ struct pthread_mlock_t { - volatile unsigned int l; - unsigned int c; - pthread_t threadid; + volatile unsigned int l; + unsigned int c; + pthread_t threadid; }; #define MLOCK_T struct pthread_mlock_t #define CURRENT_THREAD pthread_self() @@ -1677,93 +1677,93 @@ struct pthread_mlock_t { static MLOCK_T malloc_global_mutex = { 0, 0, 0}; static FORCEINLINE int pthread_acquire_lock (MLOCK_T *sl) { - int spins = 0; - volatile unsigned int* lp = &sl->l; - for (;;) { - if (*lp != 0) { - if (sl->threadid == CURRENT_THREAD) { - ++sl->c; - return 0; - } - } - else { - /* place args to cmpxchgl in locals to evade oddities in some gccs */ - int cmp = 0; - int val = 1; - int ret; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (val), "m" (*(lp)), "0"(cmp) - : "memory", "cc"); - if (!ret) { - assert(!sl->threadid); - sl->threadid = CURRENT_THREAD; - sl->c = 1; - return 0; - } - } - if ((++spins & SPINS_PER_YIELD) == 0) { + int spins = 0; + volatile unsigned int* lp = &sl->l; + for (;;) { + if (*lp != 0) { + if (sl->threadid == CURRENT_THREAD) { + ++sl->c; + return 0; + } + } + else { + /* place args to cmpxchgl in locals to evade oddities in some gccs */ + int cmp = 0; + int val = 1; + int ret; + __asm__ __volatile__ ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (val), "m" (*(lp)), "0"(cmp) + : "memory", "cc"); + if (!ret) { + assert(!sl->threadid); + sl->threadid = CURRENT_THREAD; + sl->c = 1; + return 0; + } + } + if ((++spins & SPINS_PER_YIELD) == 0) { #if defined (__SVR4) && defined (__sun) /* solaris */ - thr_yield(); + thr_yield(); #else #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) - sched_yield(); + sched_yield(); #else /* no-op yield on unknown systems */ - ; + ; #endif /* __linux__ || __FreeBSD__ || __APPLE__ */ #endif /* solaris */ - } - } + } + } } static FORCEINLINE void pthread_release_lock (MLOCK_T *sl) { - volatile unsigned int* lp = &sl->l; - assert(*lp != 0); - assert(sl->threadid == CURRENT_THREAD); - if (--sl->c == 0) { - sl->threadid = 0; - int prev = 0; - int ret; - __asm__ __volatile__ ("lock; xchgl %0, %1" - : "=r" (ret) - : "m" (*(lp)), "0"(prev) - : "memory"); - } + volatile unsigned int* lp = &sl->l; + assert(*lp != 0); + assert(sl->threadid == CURRENT_THREAD); + if (--sl->c == 0) { + sl->threadid = 0; + int prev = 0; + int ret; + __asm__ __volatile__ ("lock; xchgl %0, %1" + : "=r" (ret) + : "m" (*(lp)), "0"(prev) + : "memory"); + } } static FORCEINLINE int pthread_try_lock (MLOCK_T *sl) { - volatile unsigned int* lp = &sl->l; - if (*lp != 0) { - if (sl->threadid == CURRENT_THREAD) { - ++sl->c; - return 1; - } - } - else { - int cmp = 0; - int val = 1; - int ret; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (val), "m" (*(lp)), "0"(cmp) - : "memory", "cc"); - if (!ret) { - assert(!sl->threadid); - sl->threadid = CURRENT_THREAD; - sl->c = 1; - return 1; - } - } - return 0; + volatile unsigned int* lp = &sl->l; + if (*lp != 0) { + if (sl->threadid == CURRENT_THREAD) { + ++sl->c; + return 1; + } + } + else { + int cmp = 0; + int val = 1; + int ret; + __asm__ __volatile__ ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (val), "m" (*(lp)), "0"(cmp) + : "memory", "cc"); + if (!ret) { + assert(!sl->threadid); + sl->threadid = CURRENT_THREAD; + sl->c = 1; + return 1; + } + } + return 0; } #else /* WIN32 */ /* Custom win32-style spin locks on x86 and x64 for MSC */ struct win32_mlock_t { - volatile long l; - unsigned int c; - long threadid; + volatile long l; + unsigned int c; + long threadid; }; #define MLOCK_T struct win32_mlock_t @@ -1777,52 +1777,52 @@ struct win32_mlock_t { static MLOCK_T malloc_global_mutex = { 0, 0, 0}; static FORCEINLINE int win32_acquire_lock (MLOCK_T *sl) { - int spins = 0; - for (;;) { - if (sl->l != 0) { - if (sl->threadid == CURRENT_THREAD) { - ++sl->c; - return 0; - } - } - else { - if (!interlockedexchange(&sl->l, 1)) { - assert(!sl->threadid); - sl->threadid = CURRENT_THREAD; - sl->c = 1; - return 0; - } - } - if ((++spins & SPINS_PER_YIELD) == 0) - SleepEx(0, FALSE); - } + int spins = 0; + for (;;) { + if (sl->l != 0) { + if (sl->threadid == CURRENT_THREAD) { + ++sl->c; + return 0; + } + } + else { + if (!interlockedexchange(&sl->l, 1)) { + assert(!sl->threadid); + sl->threadid = CURRENT_THREAD; + sl->c = 1; + return 0; + } + } + if ((++spins & SPINS_PER_YIELD) == 0) + SleepEx(0, FALSE); + } } static FORCEINLINE void win32_release_lock (MLOCK_T *sl) { - assert(sl->threadid == CURRENT_THREAD); - assert(sl->l != 0); - if (--sl->c == 0) { - sl->threadid = 0; - interlockedexchange (&sl->l, 0); - } + assert(sl->threadid == CURRENT_THREAD); + assert(sl->l != 0); + if (--sl->c == 0) { + sl->threadid = 0; + interlockedexchange (&sl->l, 0); + } } static FORCEINLINE int win32_try_lock (MLOCK_T *sl) { - if (sl->l != 0) { - if (sl->threadid == CURRENT_THREAD) { - ++sl->c; - return 1; - } - } - else { - if (!interlockedexchange(&sl->l, 1)){ - assert(!sl->threadid); - sl->threadid = CURRENT_THREAD; - sl->c = 1; - return 1; - } - } - return 0; + if (sl->l != 0) { + if (sl->threadid == CURRENT_THREAD) { + ++sl->c; + return 1; + } + } + else { + if (!interlockedexchange(&sl->l, 1)) { + assert(!sl->threadid); + sl->threadid = CURRENT_THREAD; + sl->c = 1; + return 1; + } + } + return 0; } #endif /* WIN32 */ @@ -1845,19 +1845,19 @@ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; #ifdef linux #ifndef PTHREAD_MUTEX_RECURSIVE extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, - int __kind)); + int __kind)); #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP #define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) #endif #endif static int pthread_init_lock (MLOCK_T *sl) { - pthread_mutexattr_t attr; - if (pthread_mutexattr_init(&attr)) return 1; - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; - if (pthread_mutex_init(sl, &attr)) return 1; - if (pthread_mutexattr_destroy(&attr)) return 1; - return 0; + pthread_mutexattr_t attr; + if (pthread_mutexattr_init(&attr)) return 1; + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; + if (pthread_mutex_init(sl, &attr)) return 1; + if (pthread_mutexattr_destroy(&attr)) return 1; + return 0; } #else /* WIN32 */ @@ -1875,19 +1875,19 @@ static volatile long malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { - for (;;) { - long stat = malloc_global_mutex_status; - if (stat > 0) - return; - /* transition to < 0 while initializing, then to > 0) */ - if (stat == 0 && - interlockedcompareexchange(&malloc_global_mutex_status, -1, 0) == 0) { - InitializeCriticalSection(&malloc_global_mutex); - interlockedexchange(&malloc_global_mutex_status,1); - return; - } - SleepEx(0, FALSE); - } + for (;;) { + long stat = malloc_global_mutex_status; + if (stat > 0) + return; + /* transition to < 0 while initializing, then to > 0) */ + if (stat == 0 && + interlockedcompareexchange(&malloc_global_mutex_status, -1, 0) == 0) { + InitializeCriticalSection(&malloc_global_mutex); + interlockedexchange(&malloc_global_mutex_status,1); + return; + } + SleepEx(0, FALSE); + } } #endif /* WIN32 */ @@ -2065,10 +2065,10 @@ static void init_malloc_global_mutex() { */ struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; }; typedef struct malloc_chunk mchunk; @@ -2271,15 +2271,15 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ - size_t prev_foot; - size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; - - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; - bindex_t index; + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; + + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; + bindex_t index; }; typedef struct malloc_tree_chunk tchunk; @@ -2347,10 +2347,10 @@ typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ */ struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ }; #define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) @@ -2454,27 +2454,27 @@ typedef struct malloc_segment* msegmentptr; #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t release_checks; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - flag_t mflags; + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + flag_t mflags; #if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ + MLOCK_T mutex; /* locate lock among fields that rarely change */ #endif /* USE_LOCKS */ - msegment seg; - void* extp; /* Unused but available for extensions */ - size_t exts; + msegment seg; + void* extp; /* Unused but available for extensions */ + size_t exts; }; typedef struct malloc_state* mstate; @@ -2489,12 +2489,12 @@ typedef struct malloc_state* mstate; */ struct malloc_params { - volatile size_t magic; - size_t page_size; - size_t granularity; - size_t mmap_threshold; - size_t trim_threshold; - flag_t default_mflags; + volatile size_t magic; + size_t page_size; + size_t granularity; + size_t mmap_threshold; + size_t trim_threshold; + flag_t default_mflags; }; static struct malloc_params mparams; @@ -2564,24 +2564,24 @@ static struct malloc_state _gm_; /* Return segment holding given address */ static msegmentptr segment_holding(mstate m, char* addr) { - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { - msegmentptr sp = &m->seg; - for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; - } + msegmentptr sp = &m->seg; + for (;;) { + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } } #ifndef MORECORE_CANNOT_TRIM @@ -2962,110 +2962,110 @@ static size_t traverse_and_check(mstate m); /* Initialize mparams */ static int init_mparams(void) { #ifdef NEED_GLOBAL_LOCK_INIT - if (malloc_global_mutex_status <= 0) - init_malloc_global_mutex(); + if (malloc_global_mutex_status <= 0) + init_malloc_global_mutex(); #endif - ACQUIRE_MALLOC_GLOBAL_LOCK(); - if (mparams.magic == 0) { - size_t magic; - size_t psize; - size_t gsize; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + if (mparams.magic == 0) { + size_t magic; + size_t psize; + size_t gsize; #ifndef WIN32 - psize = malloc_getpagesize; - gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); + psize = malloc_getpagesize; + gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); #else /* WIN32 */ - { - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - psize = system_info.dwPageSize; - gsize = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); - } + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + psize = system_info.dwPageSize; + gsize = ((DEFAULT_GRANULARITY != 0)? + DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); + } #endif /* WIN32 */ - /* Sanity-check configuration: - size_t must be unsigned and as wide as pointer type. - ints must be at least 4 bytes. - alignment must be at least 8. - Alignment, min chunk size, and page size must all be powers of 2. - */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((gsize & (gsize-SIZE_T_ONE)) != 0) || - ((psize & (psize-SIZE_T_ONE)) != 0)) - ABORT; - - mparams.granularity = gsize; - mparams.page_size = psize; - mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; - mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; + /* Sanity-check configuration: + size_t must be unsigned and as wide as pointer type. + ints must be at least 4 bytes. + alignment must be at least 8. + Alignment, min chunk size, and page size must all be powers of 2. + */ + if ((sizeof(size_t) != sizeof(char*)) || + (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || + ((gsize & (gsize-SIZE_T_ONE)) != 0) || + ((psize & (psize-SIZE_T_ONE)) != 0)) + ABORT; + + mparams.granularity = gsize; + mparams.page_size = psize; + mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; + mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; #else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; #endif /* MORECORE_CONTIGUOUS */ #if !ONLY_MSPACES - /* Set up lock for main malloc area */ - gm->mflags = mparams.default_mflags; - INITIAL_LOCK(&gm->mutex); + /* Set up lock for main malloc area */ + gm->mflags = mparams.default_mflags; + INITIAL_LOCK(&gm->mutex); #endif - { + { #if USE_DEV_RANDOM - int fd; - unsigned char buf[sizeof(size_t)]; - /* Try to use /dev/urandom, else fall back on using time */ - if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && - read(fd, buf, sizeof(buf)) == sizeof(buf)) { - magic = *((size_t *) buf); - close(fd); - } - else + int fd; + unsigned char buf[sizeof(size_t)]; + /* Try to use /dev/urandom, else fall back on using time */ + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && + read(fd, buf, sizeof(buf)) == sizeof(buf)) { + magic = *((size_t *) buf); + close(fd); + } + else #endif /* USE_DEV_RANDOM */ #ifdef WIN32 - magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); #else - magic = (size_t)(time(0) ^ (size_t)0x55555555U); + magic = (size_t)(time(0) ^ (size_t)0x55555555U); #endif - magic |= (size_t)8U; /* ensure nonzero */ - magic &= ~(size_t)7U; /* improve chances of fault for bad values */ - mparams.magic = magic; - } - } - - RELEASE_MALLOC_GLOBAL_LOCK(); - return 1; + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + mparams.magic = magic; + } + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + return 1; } /* support for mallopt */ static int change_mparam(int param_number, int value) { - size_t val; - ensure_initialization(); - val = (value == -1)? MAX_SIZE_T : (size_t)value; - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; - return 1; - } - else - return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; - } + size_t val; + ensure_initialization(); + val = (value == -1)? MAX_SIZE_T : (size_t)value; + switch(param_number) { + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; + return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val-1)) == 0)) { + mparams.granularity = val; + return 1; + } + else + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: + return 0; + } } #if DEBUG @@ -3073,266 +3073,266 @@ static int change_mparam(int param_number, int value) { /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ - assert(sp != 0); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(sz == m->topsize); - assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); - assert(pinuse(p)); - assert(!pinuse(chunk_plus_offset(p, sz))); + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!pinuse(chunk_plus_offset(p, sz))); } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); - size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); - assert(is_mmapped(p)); - assert(use_mmap(m)); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); - assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); + size_t sz = chunksize(p); + size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk(m, p); - assert(is_inuse(p)); - assert(next_pinuse(p)); - /* If not pinuse and not mmapped, previous chunk has OK offset */ - assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); + do_check_any_chunk(m, p); + assert(is_inuse(p)); + assert(next_pinuse(p)); + /* If not pinuse and not mmapped, previous chunk has OK offset */ + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); - mchunkptr next = chunk_plus_offset(p, sz); - do_check_any_chunk(m, p); - assert(!is_inuse(p)); - assert(!next_pinuse(p)); - assert (!is_mmapped(p)); - if (p != m->dv && p != m->top) { - if (sz >= MIN_CHUNK_SIZE) { - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(is_aligned(chunk2mem(p))); - assert(next->prev_foot == sz); - assert(pinuse(p)); - assert (next == m->top || is_inuse(next)); - assert(p->fd->bk == p); - assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_T_SIZE */ - assert(sz == SIZE_T_SIZE); - } + size_t sz = chunksize(p); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!is_inuse(p)); + assert(!next_pinuse(p)); + assert (!is_mmapped(p)); + if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert (next == m->top || is_inuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); + } + else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } } /* Check properties of malloced chunks at the point they are malloced */ static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~INUSE_BITS; - do_check_inuse_chunk(m, p); - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(sz >= MIN_CHUNK_SIZE); - assert(sz >= s); - /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ - assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); - } + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t sz = p->head & ~INUSE_BITS; + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); + /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { - tchunkptr head = 0; - tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; - compute_tree_index(tsize, idx); - assert(tindex == idx); - assert(tsize >= MIN_LARGE_SIZE); - assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); - - do { /* traverse through chain of same-sized nodes */ - do_check_any_chunk(m, ((mchunkptr)u)); - assert(u->index == tindex); - assert(chunksize(u) == tsize); - assert(!is_inuse(u)); - assert(!next_pinuse(u)); - assert(u->fd->bk == u); - assert(u->bk->fd == u); - if (u->parent == 0) { - assert(u->child[0] == 0); - assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ - head = u; - assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); - if (u->child[0] != 0) { - assert(u->child[0]->parent == u); - assert(u->child[0] != u); - do_check_tree(m, u->child[0]); - } - if (u->child[1] != 0) { - assert(u->child[1]->parent == u); - assert(u->child[1] != u); - do_check_tree(m, u->child[1]); - } - if (u->child[0] != 0 && u->child[1] != 0) { - assert(chunksize(u->child[0]) < chunksize(u->child[1])); - } - } - u = u->fd; - } while (u != t); - assert(head != 0); + tchunkptr head = 0; + tchunkptr u = t; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + + do { /* traverse through chain of same-sized nodes */ + do_check_any_chunk(m, ((mchunkptr)u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!is_inuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); + if (u->parent == 0) { + assert(u->child[0] == 0); + assert(u->child[1] == 0); + } + else { + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert (u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr*)(u->parent)) == u); + if (u->child[0] != 0) { + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); - tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); + tbinptr* tb = treebin_at(m, i); + tchunkptr t = *tb; + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) + assert(empty); + if (!empty) + do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; - unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); - if (!empty) { - for (; p != b; p = p->bk) { - size_t size = chunksize(p); - mchunkptr q; - /* each chunk claims to be free */ - do_check_free_chunk(m, p); - /* chunk belongs in bin */ - assert(small_index(size) == i); - assert(p->bk == b || chunksize(p->bk) == chunksize(p)); - /* chunk is followed by an inuse chunk */ - q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); - } - } + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; + unsigned int empty = (m->smallmap & (1U << i)) == 0; + if (p == b) + assert(empty); + if (!empty) { + for (; p != b; p = p->bk) { + size_t size = chunksize(p); + mchunkptr q; + /* each chunk claims to be free */ + do_check_free_chunk(m, p); + /* chunk belongs in bin */ + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); + /* chunk is followed by an inuse chunk */ + q = next_chunk(p); + if (q->head != FENCEPOST_HEAD) + do_check_inuse_chunk(m, q); + } + } } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { - size_t size = chunksize(x); - if (is_small(size)) { - bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); - if (smallmap_is_marked(m, sidx)) { - mchunkptr p = b; - do { - if (p == x) - return 1; - } while ((p = p->fd) != b); - } - } - else { - bindex_t tidx; - compute_tree_index(size, tidx); - if (treemap_is_marked(m, tidx)) { - tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); - while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - sizebits <<= 1; - } - if (t != 0) { - tchunkptr u = t; - do { - if (u == (tchunkptr)x) - return 1; - } while ((u = u->fd) != t); - } - } - } - return 0; + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; + do { + if (p == x) + return 1; + } while ((p = p->fd) != b); + } + } + else { + bindex_t tidx; + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) { + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; + do { + if (u == (tchunkptr)x) + return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { - size_t sum = 0; - if (is_initialized(m)) { - msegmentptr s = &m->seg; - sum += m->topsize + TOP_FOOT_SIZE; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - mchunkptr lastq = 0; - assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - sum += chunksize(q); - if (is_inuse(q)) { - assert(!bin_find(m, q)); - do_check_inuse_chunk(m, q); - } - else { - assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ - do_check_free_chunk(m, q); - } - lastq = q; - q = next_chunk(q); - } - s = s->next; - } - } - return sum; + size_t sum = 0; + if (is_initialized(m)) { + msegmentptr s = &m->seg; + sum += m->topsize + TOP_FOOT_SIZE; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + mchunkptr lastq = 0; + assert(pinuse(q)); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); + if (is_inuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); + } + else { + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); + } + lastq = q; + q = next_chunk(q); + } + s = s->next; + } + } + return sum; } /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { - bindex_t i; - size_t total; - /* check bins */ - for (i = 0; i < NSMALLBINS; ++i) - do_check_smallbin(m, i); - for (i = 0; i < NTREEBINS; ++i) - do_check_treebin(m, i); - - if (m->dvsize != 0) { /* check dv chunk */ - do_check_any_chunk(m, m->dv); - assert(m->dvsize == chunksize(m->dv)); - assert(m->dvsize >= MIN_CHUNK_SIZE); - assert(bin_find(m, m->dv) == 0); - } - - if (m->top != 0) { /* check top chunk */ - do_check_top_chunk(m, m->top); - /*assert(m->topsize == chunksize(m->top)); redundant */ - assert(m->topsize > 0); - assert(bin_find(m, m->top) == 0); - } - - total = traverse_and_check(m); - assert(total <= m->footprint); - assert(m->footprint <= m->max_footprint); + bindex_t i; + size_t total; + /* check bins */ + for (i = 0; i < NSMALLBINS; ++i) + do_check_smallbin(m, i); + for (i = 0; i < NTREEBINS; ++i) + do_check_treebin(m, i); + + if (m->dvsize != 0) { /* check dv chunk */ + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); + } + + if (m->top != 0) { /* check top chunk */ + do_check_top_chunk(m, m->top); + /*assert(m->topsize == chunksize(m->top)); redundant */ + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); + } + + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); } #endif /* DEBUG */ @@ -3340,76 +3340,76 @@ static void do_check_malloc_state(mstate m) { #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - ensure_initialization(); - if (!PREACTION(m)) { - check_malloc_state(m); - if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; - msegmentptr s = &m->seg; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - size_t sz = chunksize(q); - sum += sz; - if (!is_inuse(q)) { - mfree += sz; - ++nfree; - } - q = next_chunk(q); - } - s = s->next; - } - - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; - nm.uordblks = m->footprint - mfree; - nm.fordblks = mfree; - nm.keepcost = m->topsize; - } - - POSTACTION(m); - } - return nm; + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ensure_initialization(); + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; + msegmentptr s = &m->seg; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); + sum += sz; + if (!is_inuse(q)) { + mfree += sz; + ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } + + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; + nm.uordblks = m->footprint - mfree; + nm.fordblks = mfree; + nm.keepcost = m->topsize; + } + + POSTACTION(m); + } + return nm; } #endif /* !NO_MALLINFO */ static void internal_malloc_stats(mstate m) { - ensure_initialization(); - if (!PREACTION(m)) { - size_t maxfp = 0; - size_t fp = 0; - size_t used = 0; - check_malloc_state(m); - if (is_initialized(m)) { - msegmentptr s = &m->seg; - maxfp = m->max_footprint; - fp = m->footprint; - used = fp - (m->topsize + TOP_FOOT_SIZE); - - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!is_inuse(q)) - used -= chunksize(q); - q = next_chunk(q); - } - s = s->next; - } - } - - fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); - fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); - fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); - - POSTACTION(m); - } + ensure_initialization(); + if (!PREACTION(m)) { + size_t maxfp = 0; + size_t fp = 0; + size_t used = 0; + check_malloc_state(m); + if (is_initialized(m)) { + msegmentptr s = &m->seg; + maxfp = m->max_footprint; + fp = m->footprint; + used = fp - (m->topsize + TOP_FOOT_SIZE); + + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + if (!is_inuse(q)) + used -= chunksize(q); + q = next_chunk(q); + } + s = s->next; + } + } + + fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + + POSTACTION(m); + } } /* ----------------------- Operations on smallbins ----------------------- */ @@ -3639,7 +3639,7 @@ static void internal_malloc_stats(mstate m) { #define insert_chunk(M, P, S)\ if (is_small(S)) insert_small_chunk(M, P, S)\ else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - + #define unlink_chunk(M, P, S)\ if (is_small(S)) unlink_small_chunk(M, P, S)\ @@ -3675,521 +3675,521 @@ static void internal_malloc_stats(mstate m) { /* Malloc using mmap */ static void* mmap_alloc(mstate m, size_t nb) { - size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); - if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; - mchunkptr p = (mchunkptr)(mm + offset); - p->prev_foot = offset; - p->head = psize; - mark_inuse_foot(m, p, psize); - chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - - if (m->least_addr == 0 || mm < m->least_addr) - m->least_addr = mm; - if ((m->footprint += mmsize) > m->max_footprint) - m->max_footprint = m->footprint; - assert(is_aligned(chunk2mem(p))); - check_mmapped_chunk(m, p); - return chunk2mem(p); - } - } - return 0; + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset; + p->head = psize; + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + + if (m->least_addr == 0 || mm < m->least_addr) + m->least_addr = mm; + if ((m->footprint += mmsize) > m->max_footprint) + m->max_footprint = m->footprint; + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); + } + } + return 0; } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) { - size_t oldsize = chunksize(oldp); - if (is_small(nb)) /* Can't shrink mmap regions below small size */ - return 0; - /* Keep old chunk if big enough but not too big */ - if (oldsize >= nb + SIZE_T_SIZE && - (oldsize - nb) <= (mparams.granularity << 1)) - return oldp; - else { - size_t offset = oldp->prev_foot; - size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; - size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, 1); - if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; - newp->head = psize; - mark_inuse_foot(m, newp, psize); - chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - - if (cp < m->least_addr) - m->least_addr = cp; - if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) - m->max_footprint = m->footprint; - check_mmapped_chunk(m, newp); - return newp; - } - } - return 0; + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink mmap regions below small size */ + return 0; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (mparams.granularity << 1)) + return oldp; + else { + size_t offset = oldp->prev_foot; + size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; + size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, + oldmmsize, newmmsize, 1); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + newp->head = psize; + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + + if (cp < m->least_addr) + m->least_addr = cp; + if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) + m->max_footprint = m->footprint; + check_mmapped_chunk(m, newp); + return newp; + } + } + return 0; } /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { - /* Ensure alignment */ - size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); - psize -= offset; - - m->top = p; - m->topsize = psize; - p->head = psize | PINUSE_BIT; - /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char*)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { - /* Establish circular links for smallbins */ - bindex_t i; - for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); - bin->fd = bin->bk = bin; - } + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; ++i) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } } #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { - int i; - ++malloc_corruption_error_count; - /* Reinitialize fields to forget about all memory */ - m->smallbins = m->treebins = 0; - m->dvsize = m->topsize = 0; - m->seg.base = 0; - m->seg.size = 0; - m->seg.next = 0; - m->top = m->dv = 0; - for (i = 0; i < NTREEBINS; ++i) - *treebin_at(m, i) = 0; - init_bins(m); + int i; + ++malloc_corruption_error_count; + /* Reinitialize fields to forget about all memory */ + m->smallbins = m->treebins = 0; + m->dvsize = m->topsize = 0; + m->seg.base = 0; + m->seg.size = 0; + m->seg.next = 0; + m->top = m->dv = 0; + for (i = 0; i < NTREEBINS; ++i) + *treebin_at(m, i) = 0; + init_bins(m); } #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ static void* prepend_alloc(mstate m, char* newbase, char* oldbase, size_t nb) { - mchunkptr p = align_as_chunk(newbase); - mchunkptr oldfirst = align_as_chunk(oldbase); - bindex_t psize = (bindex_t)((char*)oldfirst - (char*)p); - mchunkptr q = chunk_plus_offset(p, nb); - bindex_t qsize = psize - (bindex_t)nb; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - - assert((char*)oldfirst > (char*)q); - assert(pinuse(oldfirst)); - assert(qsize >= MIN_CHUNK_SIZE); - - /* consolidate remainder with first chunk of old base */ - if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; - m->top = q; - q->head = tsize | PINUSE_BIT; - check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { - size_t dsize = m->dvsize += qsize; - m->dv = q; - set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { - if (!is_inuse(oldfirst)) { - bindex_t nsize = chunksize(oldfirst); - unlink_chunk(m, oldfirst, nsize); - oldfirst = chunk_plus_offset(oldfirst, nsize); - qsize += nsize; - } - set_free_with_pinuse(q, qsize, oldfirst); - insert_chunk(m, q, qsize); - check_free_chunk(m, q); - } - - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + bindex_t psize = (bindex_t)((char*)oldfirst - (char*)p); + mchunkptr q = chunk_plus_offset(p, nb); + bindex_t qsize = psize - (bindex_t)nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char*)oldfirst > (char*)q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + check_top_chunk(m, q); + } + else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } + else { + if (!is_inuse(oldfirst)) { + bindex_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); + } + + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); } /* Add a segment to hold a new noncontiguous region */ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { - /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; - msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; - msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; - - /* reset top to new space */ - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - - /* Set up segment record */ - assert(is_aligned(ss)); - set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ - m->seg.base = tbase; - m->seg.size = tsize; - m->seg.sflags = mmapped; - m->seg.next = ss; - - /* Insert trailing fenceposts */ - for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); - p->head = FENCEPOST_HEAD; - ++nfences; - if ((char*)(&(nextp->head)) < old_end) - p = nextp; - else - break; - } - assert(nfences >= 2); - - /* Insert the rest of old top into a bin as an ordinary free chunk */ - if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - bindex_t psize = (bindex_t)(csp - old_top); - mchunkptr tn = chunk_plus_offset(q, psize); - set_free_with_pinuse(q, psize, tn); - insert_chunk(m, q, psize); - } - - check_top_chunk(m, m->top); + /* Determine locations and sizes of segment, fenceposts, old top */ + char* old_top = (char*)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmapped; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + ++nfences; + if ((char*)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + assert(nfences >= 2); + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + bindex_t psize = (bindex_t)(csp - old_top); + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } + + check_top_chunk(m, m->top); } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; - size_t tsize = 0; - flag_t mmap_flag = 0; - - ensure_initialization(); - - /* Directly map large chunks, but only if already initialized */ - if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; - } - - /* - Try getting memory in any of three ways (in most-preferred to - least-preferred order): - 1. A call to MORECORE that can normally contiguously extend memory. - (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or - or main space is mmapped or a previous contiguous call failed) - 2. A call to MMAP new space (disabled if not HAVE_MMAP). - Note that under the default settings, if MORECORE is unable to - fulfill a request, and HAVE_MMAP is true, then mmap is - used as a noncontiguous system allocator. This is a useful backup - strategy for systems with holes in address spaces -- in this case - sbrk cannot contiguously expand the heap, but mmap may be able to - find space. - 3. A call to MORECORE that cannot usually contiguously extend memory. - (disabled if not HAVE_MORECORE) - - In all cases, we need to request enough bytes from system to ensure - we can malloc nb bytes upon success, so pad with enough space for - top_foot, plus alignment-pad to make sure we don't lose bytes if - not on boundary, and round this up to a granularity unit. - */ - - if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); - size_t asize = 0; - ACQUIRE_MALLOC_GLOBAL_LOCK(); - - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); - if (base != CMFAIL) { - asize = granularity_align(nb + SYS_ALLOC_PADDING); - /* Adjust to end on a page boundary */ - if (!is_page_aligned(base)) - asize += (page_align((size_t)base) - (size_t)base); - /* Can't call MORECORE if size is negative when treated as signed */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == base) { - tbase = base; - tsize = asize; - } - } - } - else { - /* Subtract out existing available top space from MORECORE request. */ - asize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); - /* Use mem here only if it did continuously extend old space */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { - tbase = br; - tsize = asize; - } - } - - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (asize < HALF_MAX_SIZE_T && - asize < nb + SYS_ALLOC_PADDING) { - size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - asize); - if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); - if (end != CMFAIL) - asize += esize; - else { /* Can't use; try to release */ - (void) CALL_MORECORE(-asize); - br = CMFAIL; - } - } - } - } - if (br != CMFAIL) { /* Use the space we did get */ - tbase = br; - tsize = asize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ - } - - RELEASE_MALLOC_GLOBAL_LOCK(); - } - - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - size_t rsize = granularity_align(nb + SYS_ALLOC_PADDING); - if (rsize > nb) { /* Fail if wraps around zero */ - char* mp = (char*)(CALL_MMAP(rsize)); - if (mp != CMFAIL) { - tbase = mp; - tsize = rsize; - mmap_flag = USE_MMAP_BIT; - } - } - } - - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ - size_t asize = granularity_align(nb + SYS_ALLOC_PADDING); - if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; - ACQUIRE_MALLOC_GLOBAL_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); - RELEASE_MALLOC_GLOBAL_LOCK(); - if (br != CMFAIL && end != CMFAIL && br < end) { - size_t ssize = end - br; - if (ssize > nb + TOP_FOOT_SIZE) { - tbase = br; - tsize = ssize; - } - } - } - } - - if (tbase != CMFAIL) { - - if ((m->footprint += tsize) > m->max_footprint) - m->max_footprint = m->footprint; - - if (!is_initialized(m)) { /* first-time initialization */ - if (m->least_addr == 0 || tbase < m->least_addr) - m->least_addr = tbase; - m->seg.base = tbase; - m->seg.size = tsize; - m->seg.sflags = mmap_flag; - m->magic = mparams.magic; - m->release_checks = MAX_RELEASE_CHECK_RATE; - init_bins(m); + char* tbase = CMFAIL; + size_t tsize = 0; + flag_t mmap_flag = 0; + + ensure_initialization(); + + /* Directly map large chunks, but only if already initialized */ + if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { + void* mem = mmap_alloc(m, nb); + if (mem != 0) + return mem; + } + + /* + Try getting memory in any of three ways (in most-preferred to + least-preferred order): + 1. A call to MORECORE that can normally contiguously extend memory. + (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or + or main space is mmapped or a previous contiguous call failed) + 2. A call to MMAP new space (disabled if not HAVE_MMAP). + Note that under the default settings, if MORECORE is unable to + fulfill a request, and HAVE_MMAP is true, then mmap is + used as a noncontiguous system allocator. This is a useful backup + strategy for systems with holes in address spaces -- in this case + sbrk cannot contiguously expand the heap, but mmap may be able to + find space. + 3. A call to MORECORE that cannot usually contiguously extend memory. + (disabled if not HAVE_MORECORE) + + In all cases, we need to request enough bytes from system to ensure + we can malloc nb bytes upon success, so pad with enough space for + top_foot, plus alignment-pad to make sure we don't lose bytes if + not on boundary, and round this up to a granularity unit. + */ + + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { + char* br = CMFAIL; + msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + size_t asize = 0; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); + if (base != CMFAIL) { + asize = granularity_align(nb + SYS_ALLOC_PADDING); + /* Adjust to end on a page boundary */ + if (!is_page_aligned(base)) + asize += (page_align((size_t)base) - (size_t)base); + /* Can't call MORECORE if size is negative when treated as signed */ + if (asize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(asize))) == base) { + tbase = base; + tsize = asize; + } + } + } + else { + /* Subtract out existing available top space from MORECORE request. */ + asize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); + /* Use mem here only if it did continuously extend old space */ + if (asize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { + tbase = br; + tsize = asize; + } + } + + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (asize < HALF_MAX_SIZE_T && + asize < nb + SYS_ALLOC_PADDING) { + size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - asize); + if (esize < HALF_MAX_SIZE_T) { + char* end = (char*)CALL_MORECORE(esize); + if (end != CMFAIL) + asize += esize; + else { /* Can't use; try to release */ + (void) CALL_MORECORE(-asize); + br = CMFAIL; + } + } + } + } + if (br != CMFAIL) { /* Use the space we did get */ + tbase = br; + tsize = asize; + } + else + disable_contiguous(m); /* Don't try contiguous path in the future */ + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + } + + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + size_t rsize = granularity_align(nb + SYS_ALLOC_PADDING); + if (rsize > nb) { /* Fail if wraps around zero */ + char* mp = (char*)(CALL_MMAP(rsize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = rsize; + mmap_flag = USE_MMAP_BIT; + } + } + } + + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + size_t asize = granularity_align(nb + SYS_ALLOC_PADDING); + if (asize < HALF_MAX_SIZE_T) { + char* br = CMFAIL; + char* end = CMFAIL; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); + RELEASE_MALLOC_GLOBAL_LOCK(); + if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; + if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; + tsize = ssize; + } + } + } + } + + if (tbase != CMFAIL) { + + if ((m->footprint += tsize) > m->max_footprint) + m->max_footprint = m->footprint; + + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) + m->least_addr = tbase; + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmap_flag; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + init_bins(m); #if !ONLY_MSPACES - if (is_global(m)) - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - else + if (is_global(m)) + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + else #endif - { - /* Offset top by embedded malloc_state */ - mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); - } - } - - else { - /* Try to merge with an existing segment */ - msegmentptr sp = &m->seg; - /* Only consider most recent segment if traversal suppressed */ - while (sp != 0 && tbase != sp->base + sp->size) - sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & USE_MMAP_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ - sp->size += tsize; - init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; - sp = &m->seg; - while (sp != 0 && sp->base != tbase + tsize) - sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & USE_MMAP_BIT) == mmap_flag) { - char* oldbase = sp->base; - sp->base = tbase; - sp->size += tsize; - return prepend_alloc(m, tbase, oldbase, nb); - } - else - add_segment(m, tbase, tsize, mmap_flag); - } - } - - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; - mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - check_top_chunk(m, m->top); - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); - } - } - - MALLOC_FAILURE_ACTION; - return 0; + { + /* Offset top by embedded malloc_state */ + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + } + } + + else { + /* Try to merge with an existing segment */ + msegmentptr sp = &m->seg; + /* Only consider most recent segment if traversal suppressed */ + while (sp != 0 && tbase != sp->base + sp->size) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag && + segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } + else { + if (tbase < m->least_addr) + m->least_addr = tbase; + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag) { + char* oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } + else + add_segment(m, tbase, tsize, mmap_flag); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); + } + } + + MALLOC_FAILURE_ACTION; + return 0; } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { - size_t released = 0; - int nsegs = 0; - msegmentptr pred = &m->seg; - msegmentptr sp = pred->next; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - msegmentptr next = sp->next; - ++nsegs; - if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); - /* Can unmap if first chunk holds entire segment and not pinned */ - if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { - tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); - if (p == m->dv) { - m->dv = 0; - m->dvsize = 0; - } - else { - unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; - m->footprint -= size; - /* unlink obsoleted record */ - sp = pred; - sp->next = next; - } - else { /* back out if cannot unmap */ - insert_large_chunk(m, tp, psize); - } - } - } - if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ - break; - pred = sp; - sp = next; - } - /* Reset check counter */ - m->release_checks = ((nsegs > MAX_RELEASE_CHECK_RATE)? - nsegs : MAX_RELEASE_CHECK_RATE); - return released; + size_t released = 0; + int nsegs = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + ++nsegs; + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + assert(segment_holds(sp, (char*)sp)); + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + m->footprint -= size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } + else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + break; + pred = sp; + sp = next; + } + /* Reset check counter */ + m->release_checks = ((nsegs > MAX_RELEASE_CHECK_RATE)? + nsegs : MAX_RELEASE_CHECK_RATE); + return released; } static int sys_trim(mstate m, size_t pad) { - size_t released = 0; - ensure_initialization(); - if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ - - if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ - size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); - - if (!is_extern_segment(sp)) { - if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ - size_t newsize = sp->size - extra; - /* Prefer mremap, fall back to munmap */ - if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || - (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; - } - } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ - extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; - ACQUIRE_MALLOC_GLOBAL_LOCK(); - { - /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); - if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); - if (rel_br != CMFAIL && new_br < old_br) - released = old_br - new_br; - } - } - RELEASE_MALLOC_GLOBAL_LOCK(); - } - } - - if (released != 0) { - sp->size -= released; - m->footprint -= released; - init_top(m, m->top, m->topsize - released); - check_top_chunk(m, m->top); - } - } - - /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); - - /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0 && m->topsize > m->trim_check) - m->trim_check = MAX_SIZE_T; - } - - return (released != 0)? 1 : 0; + size_t released = 0; + ensure_initialization(); + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = mparams.granularity; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && + sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + } + else if (HAVE_MORECORE) { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + { + /* Make sure end of memory is where we last set it. */ + char* old_br = (char*)(CALL_MORECORE(0)); + if (old_br == sp->base + sp->size) { + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); + if (rel_br != CMFAIL && new_br < old_br) + released = old_br - new_br; + } + } + RELEASE_MALLOC_GLOBAL_LOCK(); + } + } + + if (released != 0) { + sp->size -= released; + m->footprint -= released; + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); + } + } + + /* Unmap any unused mmapped segments */ + if (HAVE_MMAP) + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; } @@ -4197,273 +4197,273 @@ static int sys_trim(mstate m, size_t pad) { /* allocate a large request from the best fitting chunk in a treebin */ static void* tmalloc_large(mstate m, size_t nb) { - tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ - tchunkptr t; - bindex_t idx; - compute_tree_index(nb, idx); - if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ - for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) - break; - } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; - if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ - break; - } - sizebits <<= 1; - } - } - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; - if (leftbits != 0) { - bindex_t i; - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - t = *treebin_at(m, i); - } - } - - while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - t = leftmost_child(t); - } - - /* If dv is a better fit, return 0 so malloc will use it */ - if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - insert_chunk(m, r, rsize); - } - return chunk2mem(v); - } - } - CORRUPTION_ERROR_ACTION(m); - } - return 0; + tchunkptr v = 0; + size_t rsize = -nb; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) { + bindex_t i; + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); + } + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return 0 so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; } /* allocate a small request from the best fitting chunk in a treebin */ static void* tmalloc_small(mstate m, size_t nb) { - tchunkptr t, v; - bindex_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); - compute_bit2idx(leastbit, i); - v = t = *treebin_at(m, i); - rsize = (bindex_t)(chunksize(t) - nb); - - while ((t = leftmost_child(t)) != 0) { - bindex_t trem = chunksize(t) - (bindex_t)nb; - if (trem < rsize) { - rsize = trem; - v = t; - } - } - - if (RTCHECK(ok_address(m, v))) { - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(m, r, rsize); - } - return chunk2mem(v); - } - } - - CORRUPTION_ERROR_ACTION(m); - return 0; + tchunkptr t, v; + bindex_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + v = t = *treebin_at(m, i); + rsize = (bindex_t)(chunksize(t) - nb); + + while ((t = leftmost_child(t)) != 0) { + bindex_t trem = chunksize(t) - (bindex_t)nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } + + CORRUPTION_ERROR_ACTION(m); + return 0; } /* --------------------------- realloc support --------------------------- */ static void* internal_realloc(mstate m, void* oldmem, size_t bytes) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - return 0; - } - if (!PREACTION(m)) { - mchunkptr oldp = mem2chunk(oldmem); - size_t oldsize = chunksize(oldp); - mchunkptr next = chunk_plus_offset(oldp, oldsize); - mchunkptr newp = 0; - void* extra = 0; - - /* Try to either shrink or extend into top. Else malloc-copy-free */ - - if (RTCHECK(ok_address(m, oldp) && ok_inuse(oldp) && - ok_next(oldp, next) && ok_pinuse(next))) { - size_t nb = request2size(bytes); - if (is_mmapped(oldp)) - newp = mmap_resize(m, oldp, nb); - else if (oldsize >= nb) { /* already big enough */ - size_t rsize = oldsize - nb; - newp = oldp; - if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr remainder = chunk_plus_offset(newp, nb); - set_inuse(m, newp, nb); - set_inuse_and_pinuse(m, remainder, rsize); - extra = chunk2mem(remainder); - } - } - else if (next == m->top && oldsize + m->topsize > nb) { - /* Expand into top */ - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset(oldp, nb); - set_inuse(m, oldp, nb); - newtop->head = newtopsize |PINUSE_BIT; - m->top = newtop; - m->topsize = newtopsize; - newp = oldp; - } - } - else { - USAGE_ERROR_ACTION(m, oldmem); - POSTACTION(m); - return 0; - } + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + return 0; + } + if (!PREACTION(m)) { + mchunkptr oldp = mem2chunk(oldmem); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); + mchunkptr newp = 0; + void* extra = 0; + + /* Try to either shrink or extend into top. Else malloc-copy-free */ + + if (RTCHECK(ok_address(m, oldp) && ok_inuse(oldp) && + ok_next(oldp, next) && ok_pinuse(next))) { + size_t nb = request2size(bytes); + if (is_mmapped(oldp)) + newp = mmap_resize(m, oldp, nb); + else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + newp = oldp; + if (rsize >= MIN_CHUNK_SIZE) { + mchunkptr remainder = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse_and_pinuse(m, remainder, rsize); + extra = chunk2mem(remainder); + } + } + else if (next == m->top && oldsize + m->topsize > nb) { + /* Expand into top */ + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = oldp; + } + } + else { + USAGE_ERROR_ACTION(m, oldmem); + POSTACTION(m); + return 0; + } #if DEBUG - if (newp != 0) { - check_inuse_chunk(m, newp); /* Check requires lock */ - } + if (newp != 0) { + check_inuse_chunk(m, newp); /* Check requires lock */ + } #endif - POSTACTION(m); - - if (newp != 0) { - if (extra != 0) { - internal_free(m, extra); - } - return chunk2mem(newp); - } - else { - void* newmem = internal_malloc(m, bytes); - if (newmem != 0) { - size_t oc = oldsize - overhead_for(oldp); - memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); - internal_free(m, oldmem); - } - return newmem; - } - } - return 0; + POSTACTION(m); + + if (newp != 0) { + if (extra != 0) { + internal_free(m, extra); + } + return chunk2mem(newp); + } + else { + void* newmem = internal_malloc(m, bytes); + if (newmem != 0) { + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); + internal_free(m, oldmem); + } + return newmem; + } + } + return 0; } /* --------------------------- memalign support -------------------------- */ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ - return internal_malloc(m, bytes); - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ - alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ - size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; - alignment = a; - } - - if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ - MALLOC_FAILURE_ACTION; - } - } - else { - size_t nb = request2size(bytes); - size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; - char* mem = (char*)internal_malloc(m, req); - if (mem != 0) { - void* leader = 0; - void* trailer = 0; - mchunkptr p = mem2chunk(mem); - - if (PREACTION(m)) return 0; - if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ - /* - Find an aligned spot inside chunk. Since we need to give - back leading space in a chunk of at least MIN_CHUNK_SIZE, if - the first calculation places us at a spot with less than - MIN_CHUNK_SIZE leader, we can move to the next aligned spot. - We've allocated enough total room so that this is always - possible. - */ - char* br = (char*)mem2chunk((size_t)(((size_t)(mem + - alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; - mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; - - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ - newp->prev_foot = p->prev_foot + leadsize; - newp->head = newsize; - } - else { /* Otherwise, give back leader, use the rest */ - set_inuse(m, newp, newsize); - set_inuse(m, p, leadsize); - leader = chunk2mem(p); - } - p = newp; - } - - /* Give back spare room at the end */ - if (!is_mmapped(p)) { - size_t size = chunksize(p); - if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; - mchunkptr remainder = chunk_plus_offset(p, nb); - set_inuse(m, p, nb); - set_inuse(m, remainder, remainder_size); - trailer = chunk2mem(remainder); - } - } - - assert (chunksize(p) >= nb); - assert((((size_t)(chunk2mem(p))) % alignment) == 0); - check_inuse_chunk(m, p); - POSTACTION(m); - if (leader != 0) { - internal_free(m, leader); - } - if (trailer != 0) { - internal_free(m, trailer); - } - return chunk2mem(p); - } - } - return 0; + if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ + return internal_malloc(m, bytes); + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ + alignment = MIN_CHUNK_SIZE; + if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + size_t a = MALLOC_ALIGNMENT << 1; + while (a < alignment) a <<= 1; + alignment = a; + } + + if (bytes >= MAX_REQUEST - alignment) { + if (m != 0) { /* Test isn't needed but avoids compiler warning */ + MALLOC_FAILURE_ACTION; + } + } + else { + size_t nb = request2size(bytes); + size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; + char* mem = (char*)internal_malloc(m, req); + if (mem != 0) { + void* leader = 0; + void* trailer = 0; + mchunkptr p = mem2chunk(mem); + + if (PREACTION(m)) return 0; + if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ + /* + Find an aligned spot inside chunk. Since we need to give + back leading space in a chunk of at least MIN_CHUNK_SIZE, if + the first calculation places us at a spot with less than + MIN_CHUNK_SIZE leader, we can move to the next aligned spot. + We've allocated enough total room so that this is always + possible. + */ + char* br = (char*)mem2chunk((size_t)(((size_t)(mem + + alignment - + SIZE_T_ONE)) & + -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? + br : br+alignment; + mchunkptr newp = (mchunkptr)pos; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + newp->prev_foot = p->prev_foot + leadsize; + newp->head = newsize; + } + else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + leader = chunk2mem(p); + } + p = newp; + } + + /* Give back spare room at the end */ + if (!is_mmapped(p)) { + size_t size = chunksize(p); + if (size > nb + MIN_CHUNK_SIZE) { + size_t remainder_size = size - nb; + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + trailer = chunk2mem(remainder); + } + } + + assert (chunksize(p) >= nb); + assert((((size_t)(chunk2mem(p))) % alignment) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); + if (leader != 0) { + internal_free(m, leader); + } + if (trailer != 0) { + internal_free(m, trailer); + } + return chunk2mem(p); + } + } + return 0; } /* ------------------------ comalloc/coalloc support --------------------- */ @@ -4473,126 +4473,126 @@ static void** ialloc(mstate m, size_t* sizes, int opts, void* chunks[]) { - /* - This provides common support for independent_X routines, handling - all of the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed - */ - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ - size_t size; - size_t i; - - ensure_initialization(); - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); - marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); - } - - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } - - size = contents_size + array_size; - - /* - Allocate the aggregate chunk. First disable direct-mmapping so - malloc won't use it, since we would not be able to later - free/realloc space internal to a segregated mmap region. - */ - was_enabled = use_mmap(m); - disable_mmap(m); - mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; - - if (PREACTION(m)) return 0; - p = mem2chunk(mem); - remainder_size = chunksize(p); - - assert(!is_mmapped(p)); - - if (opts & 0x2) { /* optionally clear the elements */ - memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); - } - - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - size_t array_chunk_size; - array_chunk = chunk_plus_offset(p, contents_size); - array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); - set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); - remainder_size = contents_size; - } - - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_size_and_pinuse_of_inuse_chunk(m, p, size); - p = chunk_plus_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ - set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); - break; - } - } + /* + This provides common support for independent_X routines, handling + all of the combinations that can result. + + The opts arg has: + bit 0 set if all elements are same size (using sizes[0]) + bit 1 set if elements should be zeroed + */ + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ + size_t size; + size_t i; + + ensure_initialization(); + /* compute array length, if needed */ + if (chunks != 0) { + if (n_elements == 0) + return chunks; /* nothing to do */ + marray = chunks; + array_size = 0; + } + else { + /* if empty req, must still return chunk representing empty array */ + if (n_elements == 0) + return (void**)internal_malloc(m, 0); + marray = 0; + array_size = request2size(n_elements * (sizeof(void*))); + } + + /* compute total element size */ + if (opts & 0x1) { /* all-same-size */ + element_size = request2size(*sizes); + contents_size = n_elements * element_size; + } + else { /* add up all the sizes */ + element_size = 0; + contents_size = 0; + for (i = 0; i != n_elements; ++i) + contents_size += request2size(sizes[i]); + } + + size = contents_size + array_size; + + /* + Allocate the aggregate chunk. First disable direct-mmapping so + malloc won't use it, since we would not be able to later + free/realloc space internal to a segregated mmap region. + */ + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); + if (was_enabled) + enable_mmap(m); + if (mem == 0) + return 0; + + if (PREACTION(m)) return 0; + p = mem2chunk(mem); + remainder_size = chunksize(p); + + assert(!is_mmapped(p)); + + if (opts & 0x2) { /* optionally clear the elements */ + memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + } + + /* If not provided, allocate the pointer array as final part of chunk */ + if (marray == 0) { + size_t array_chunk_size; + array_chunk = chunk_plus_offset(p, contents_size); + array_chunk_size = remainder_size - contents_size; + marray = (void**) (chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); + remainder_size = contents_size; + } + + /* split out elements */ + for (i = 0; ; ++i) { + marray[i] = chunk2mem(p); + if (i != n_elements-1) { + if (element_size != 0) + size = element_size; + else + size = request2size(sizes[i]); + remainder_size -= size; + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); + } + else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); + break; + } + } #if DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) { - assert(remainder_size == element_size); - } - else { - assert(remainder_size == request2size(sizes[i])); - } - check_inuse_chunk(m, mem2chunk(marray)); - } - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(m, mem2chunk(marray[i])); + if (marray != chunks) { + /* final element must have exactly exhausted chunk */ + if (element_size != 0) { + assert(remainder_size == element_size); + } + else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) + check_inuse_chunk(m, mem2chunk(marray[i])); #endif /* DEBUG */ - POSTACTION(m); - return marray; + POSTACTION(m); + return marray; } @@ -4601,358 +4601,358 @@ static void** ialloc(mstate m, #if !ONLY_MSPACES void* dlmalloc(size_t bytes) { - /* - Basic algorithm: - If a small request (< 256 bytes minus per-chunk overhead): - 1. If one exists, use a remainderless chunk in associated smallbin. - (Remainderless means that there are too few excess bytes to - represent as a chunk.) - 2. If it is big enough, use the dv chunk, which is normally the - chunk adjacent to the one used for the most recent small request. - 3. If one exists, split the smallest available chunk in a bin, - saving remainder in dv. - 4. If it is big enough, use the top chunk. - 5. If available, get memory from system and use it - Otherwise, for a large request: - 1. Find the smallest available binned chunk that fits, and use it - if it is better fitting than dv chunk, splitting if necessary. - 2. If better fitting than any binned chunk, use the dv chunk. - 3. If it is big enough, use the top chunk. - 4. If request size >= mmap threshold, try to directly mmap this chunk. - 5. If available, get memory from system and use it - - The ugly goto's here ensure that postaction occurs along all paths. - */ + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ #if USE_LOCKS - ensure_initialization(); /* initialize in sys_alloc if not using locks */ + ensure_initialization(); /* initialize in sys_alloc if not using locks */ #endif - if (!PREACTION(gm)) { - void* mem; - bindex_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = gm->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(gm, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(gm, b, p, idx); - set_inuse_and_pinuse(gm, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - bindex_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(gm, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(gm, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(gm, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(gm, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - - if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; - mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = gm->dv = chunk_plus_offset(p, nb); - gm->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ - size_t dvs = gm->dvsize; - gm->dvsize = 0; - gm->dv = 0; - set_inuse_and_pinuse(gm, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; - mchunkptr p = gm->top; - mchunkptr r = gm->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - mem = chunk2mem(p); - check_top_chunk(gm, gm->top); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - - mem = sys_alloc(gm, nb); - - postaction: - POSTACTION(gm); - return mem; - } - - return 0; + if (!PREACTION(gm)) { + void* mem; + bindex_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = gm->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(gm, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb > gm->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + bindex_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(gm, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + + if (nb <= gm->dvsize) { + size_t rsize = gm->dvsize - nb; + mchunkptr p = gm->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); + gm->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + } + else { /* exhaust dv */ + size_t dvs = gm->dvsize; + gm->dvsize = 0; + gm->dv = 0; + set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; + mchunkptr p = gm->top; + mchunkptr r = gm->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + mem = sys_alloc(gm, nb); + +postaction: + POSTACTION(gm); + return mem; + } + + return 0; } void dlfree(void* mem) { - /* - Consolidate freed chunks with preceeding or succeeding bordering - free chunks, if they exist, and then place in a bin. Intermixed - with special cases for top, dv, mmapped chunks, and usage errors. - */ - - if (mem != 0) { - mchunkptr p = mem2chunk(mem); + /* + Consolidate freed chunks with preceeding or succeeding bordering + free chunks, if they exist, and then place in a bin. Intermixed + with special cases for top, dv, mmapped chunks, and usage errors. + */ + + if (mem != 0) { + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for(p); - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } #else /* FOOTERS */ #define fm gm #endif /* FOOTERS */ - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - bindex_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - bindex_t prevsize = (bindex_t)p->prev_foot; - if (is_mmapped(p)) { - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - bindex_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - - if (is_small(psize)) { - insert_small_chunk(fm, p, psize); - check_free_chunk(fm, p); - } - else { - tchunkptr tp = (tchunkptr)p; - insert_large_chunk(fm, tp, psize); - check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); - } - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + bindex_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + bindex_t prevsize = (bindex_t)p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + bindex_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } +erroraction: + USAGE_ERROR_ACTION(fm, p); +postaction: + POSTACTION(fm); + } + } #if !FOOTERS #undef fm #endif /* FOOTERS */ } void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = dlmalloc(req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; + void* mem; + size_t req = 0; + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; } void* dlrealloc(void* oldmem, size_t bytes) { - if (oldmem == 0) - return dlmalloc(bytes); + if (oldmem == 0) + return dlmalloc(bytes); #ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - dlfree(oldmem); - return 0; - } + if (bytes == 0) { + dlfree(oldmem); + return 0; + } #endif /* REALLOC_ZERO_BYTES_FREES */ - else { + else { #if ! FOOTERS - mstate m = gm; + mstate m = gm; #else /* FOOTERS */ - mstate m = get_mstate_for(mem2chunk(oldmem)); - if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); - return 0; - } + mstate m = get_mstate_for(mem2chunk(oldmem)); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } #endif /* FOOTERS */ - return internal_realloc(m, oldmem, bytes); - } + return internal_realloc(m, oldmem, bytes); + } } void* dlmemalign(size_t alignment, size_t bytes) { - return internal_memalign(gm, alignment, bytes); + return internal_memalign(gm, alignment, bytes); } void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - return ialloc(gm, n_elements, &sz, 3, chunks); + void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + return ialloc(gm, n_elements, &sz, 3, chunks); } void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { - return ialloc(gm, n_elements, sizes, 0, chunks); + void* chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); } void* dlvalloc(size_t bytes) { - size_t pagesz; - ensure_initialization(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, bytes); + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, bytes); } void* dlpvalloc(size_t bytes) { - size_t pagesz; - ensure_initialization(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } int dlmalloc_trim(size_t pad) { - int result = 0; - ensure_initialization(); - if (!PREACTION(gm)) { - result = sys_trim(gm, pad); - POSTACTION(gm); - } - return result; + int result = 0; + ensure_initialization(); + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); + } + return result; } size_t dlmalloc_footprint(void) { - return gm->footprint; + return gm->footprint; } size_t dlmalloc_max_footprint(void) { - return gm->max_footprint; + return gm->max_footprint; } #if !NO_MALLINFO struct mallinfo dlmallinfo(void) { - return internal_mallinfo(gm); + return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ void dlmalloc_stats() { - internal_malloc_stats(gm); + internal_malloc_stats(gm); } int dlmallopt(int param_number, int value) { - return change_mparam(param_number, value); + return change_mparam(param_number, value); } #endif /* !ONLY_MSPACES */ size_t dlmalloc_usable_size(void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); - } - return 0; + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; } /* ----------------------------- user mspaces ---------------------------- */ @@ -4960,95 +4960,95 @@ size_t dlmalloc_usable_size(void* mem) { #if MSPACES static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); - mchunkptr mn; - mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); - memset(m, 0, msize); - INITIAL_LOCK(&m->mutex); - msp->head = (msize|INUSE_BITS); - m->seg.base = m->least_addr = tbase; - m->seg.size = m->footprint = m->max_footprint = tsize; - m->magic = mparams.magic; - m->release_checks = MAX_RELEASE_CHECK_RATE; - m->mflags = mparams.default_mflags; - m->extp = 0; - m->exts = 0; - disable_contiguous(m); - init_bins(m); - mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); - check_top_chunk(m, m->top); - return m; + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + INITIAL_LOCK(&m->mutex); + msp->head = (msize|INUSE_BITS); + m->seg.base = m->least_addr = tbase; + m->seg.size = m->footprint = m->max_footprint = tsize; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + m->mflags = mparams.default_mflags; + m->extp = 0; + m->exts = 0; + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); + return m; } mspace create_mspace(size_t capacity, int locked) { - mstate m = 0; - size_t msize; - ensure_initialization(); - msize = pad_request(sizeof(struct malloc_state)); - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); - size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); - if (tbase != CMFAIL) { - m = init_user_mstate(tbase, tsize); - m->seg.sflags = USE_MMAP_BIT; - set_lock(m, locked); - } - } - return (mspace)m; + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0)? mparams.granularity : + (capacity + TOP_FOOT_SIZE + msize)); + size_t tsize = granularity_align(rs); + char* tbase = (char*)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); + m->seg.sflags = USE_MMAP_BIT; + set_lock(m, locked); + } + } + return (mspace)m; } mspace create_mspace_with_base(void* base, size_t capacity, int locked) { - mstate m = 0; - size_t msize; - ensure_initialization(); - msize = pad_request(sizeof(struct malloc_state)); - if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); - m->seg.sflags = EXTERN_BIT; - set_lock(m, locked); - } - return (mspace)m; + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity > msize + TOP_FOOT_SIZE && + capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); + m->seg.sflags = EXTERN_BIT; + set_lock(m, locked); + } + return (mspace)m; } int mspace_track_large_chunks(mspace msp, int enable) { - int ret = 0; - mstate ms = (mstate)msp; - if (!PREACTION(ms)) { - if (!use_mmap(ms)) - ret = 1; - if (!enable) - enable_mmap(ms); - else - disable_mmap(ms); - POSTACTION(ms); - } - return ret; + int ret = 0; + mstate ms = (mstate)msp; + if (!PREACTION(ms)) { + if (!use_mmap(ms)) + ret = 1; + if (!enable) + enable_mmap(ms); + else + disable_mmap(ms); + POSTACTION(ms); + } + return ret; } size_t destroy_mspace(mspace msp) { - size_t freed = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - msegmentptr sp = &ms->seg; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - flag_t flag = sp->sflags; - sp = sp->next; - if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && - CALL_MUNMAP(base, size) == 0) - freed += size; - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return freed; + size_t freed = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = sp->sflags; + sp = sp->next; + if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && + CALL_MUNMAP(base, size) == 0) + freed += size; + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return freed; } /* @@ -5058,366 +5058,366 @@ size_t destroy_mspace(mspace msp) { void* mspace_malloc(mspace msp, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (!PREACTION(ms)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = ms->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(ms, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(ms, b, p, idx); - set_inuse_and_pinuse(ms, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(ms, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(ms, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(ms, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - - if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; - mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset(p, nb); - ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ - size_t dvs = ms->dvsize; - ms->dvsize = 0; - ms->dv = 0; - set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; - mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - mem = chunk2mem(p); - check_top_chunk(ms, ms->top); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - - mem = sys_alloc(ms, nb); - - postaction: - POSTACTION(ms); - return mem; - } - - return 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (!PREACTION(ms)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(ms, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } + else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + mem = sys_alloc(ms, nb); + +postaction: + POSTACTION(ms); + return mem; + } + + return 0; } void mspace_free(mspace msp, void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); + if (mem != 0) { + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for(p); - msp = msp; /* placate people compiling -Wunused */ + mstate fm = get_mstate_for(p); + msp = msp; /* placate people compiling -Wunused */ #else /* FOOTERS */ - mstate fm = (mstate)msp; + mstate fm = (mstate)msp; #endif /* FOOTERS */ - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if (is_mmapped(p)) { - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - - if (is_small(psize)) { - insert_small_chunk(fm, p, psize); - check_free_chunk(fm, p); - } - else { - tchunkptr tp = (tchunkptr)p; - insert_large_chunk(fm, tp, psize); - check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); - } - goto postaction; - } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); - } - } + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } +erroraction: + USAGE_ERROR_ACTION(fm, p); +postaction: + POSTACTION(fm); + } + } } void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = internal_malloc(ms, req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; + void* mem; + size_t req = 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); + return mem; } void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - if (oldmem == 0) - return mspace_malloc(msp, bytes); + if (oldmem == 0) + return mspace_malloc(msp, bytes); #ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - mspace_free(msp, oldmem); - return 0; - } + if (bytes == 0) { + mspace_free(msp, oldmem); + return 0; + } #endif /* REALLOC_ZERO_BYTES_FREES */ - else { + else { #if FOOTERS - mchunkptr p = mem2chunk(oldmem); - mstate ms = get_mstate_for(p); + mchunkptr p = mem2chunk(oldmem); + mstate ms = get_mstate_for(p); #else /* FOOTERS */ - mstate ms = (mstate)msp; + mstate ms = (mstate)msp; #endif /* FOOTERS */ - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_realloc(ms, oldmem, bytes); - } + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return internal_realloc(ms, oldmem, bytes); + } } void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_memalign(ms, alignment, bytes); + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return internal_memalign(ms, alignment, bytes); } void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, &sz, 3, chunks); + size_t sz = elem_size; /* serves as 1-element array */ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); } void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, sizes, 0, chunks); + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); } int mspace_trim(mspace msp, size_t pad) { - int result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - if (!PREACTION(ms)) { - result = sys_trim(ms, pad); - POSTACTION(ms); - } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; + int result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; } void mspace_malloc_stats(mspace msp) { - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - internal_malloc_stats(ms); - } - else { - USAGE_ERROR_ACTION(ms,ms); - } + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + internal_malloc_stats(ms); + } + else { + USAGE_ERROR_ACTION(ms,ms); + } } size_t mspace_footprint(mspace msp) { - size_t result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->footprint; - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; } size_t mspace_max_footprint(mspace msp) { - size_t result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->max_footprint; - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->max_footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; } #if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } - return internal_mallinfo(ms); + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + } + return internal_mallinfo(ms); } #endif /* NO_MALLINFO */ size_t mspace_usable_size(void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); - } - return 0; + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; } int mspace_mallopt(int param_number, int value) { - return change_mparam(param_number, value); + return change_mparam(param_number, value); } #endif /* MSPACES */ diff --git a/src/utils/downloader.c b/src/utils/downloader.c index 19476e5..0e9bfc8 100644 --- a/src/utils/downloader.c +++ b/src/utils/downloader.c @@ -33,6 +33,8 @@ #include #include +#ifndef GPAC_DISABLE_CORE_TOOLS + #ifdef GPAC_HAS_SSL #include #include @@ -80,8 +82,8 @@ typedef struct __gf_user_credentials enum REQUEST_TYPE { GET = 0, - HEAD = 1, - OTHER = 2 + HEAD = 1, + OTHER = 2 }; /*!the structure used to store an HTTP header*/ @@ -96,111 +98,111 @@ typedef struct * This structure handles partial downloads */ typedef struct __partialDownloadStruct { - char * url; - u64 startOffset; - u64 endOffset; - char * filename; + char * url; + u64 startOffset; + u64 endOffset; + char * filename; } GF_PartialDownload ; struct __gf_download_session { - /*this is always 0 and helps differenciating downloads from other interfaces (interfaceType != 0)*/ - u32 reserved; + /*this is always 0 and helps differenciating downloads from other interfaces (interfaceType != 0)*/ + u32 reserved; - struct __gf_download_manager *dm; - GF_Thread *th; - GF_Mutex *mx; + struct __gf_download_manager *dm; + GF_Thread *th; + GF_Mutex *mx; - Bool in_callback, destroy; - u32 proxy_enabled; + Bool in_callback, destroy; + u32 proxy_enabled; - char *server_name; - u16 port; + char *server_name; + u16 port; - char *orig_url; - char *orig_url_before_redirect; - char *remote_path; - gf_user_credentials_struct * creds; - char cookie[GF_MAX_PATH]; - DownloadedCacheEntry cache_entry; + char *orig_url; + char *orig_url_before_redirect; + char *remote_path; + gf_user_credentials_struct * creds; + char cookie[GF_MAX_PATH]; + DownloadedCacheEntry cache_entry; Bool reused_cache_entry; //mime type, only used when the session is not cached. char *mime_type; - GF_List *headers; + GF_List *headers; - GF_Socket *sock; - u32 num_retry; + GF_Socket *sock; + u32 num_retry; GF_NetIOStatus status; - u32 flags; - u32 total_size, bytes_done, start_time, icy_metaint, icy_count, icy_bytes; - u32 bytes_per_sec; + u32 flags; + u32 total_size, bytes_done, start_time, icy_metaint, icy_count, icy_bytes; + u32 bytes_per_sec; u64 start_time_utc; Bool connection_close; Bool is_range_continuation; /*0: no cache reconfig before next GET request: 1: try to rematch the cache entry: 2: force to create a new cache entry (for byte-range cases*/ u32 needs_cache_reconfig; - /* Range information if needed for the download (cf flag) */ - Bool needs_range; - u64 range_start, range_end; - - /*0: GET - 1: HEAD - 2: all the rest - */ - enum REQUEST_TYPE http_read_type; - - GF_Err last_error; - char *init_data; - u32 init_data_size; - Bool server_only_understand_get; - /* True if cache file must be stored on disk */ - Bool use_cache_file; + /* Range information if needed for the download (cf flag) */ + Bool needs_range; + u64 range_start, range_end; + + /*0: GET + 1: HEAD + 2: all the rest + */ + enum REQUEST_TYPE http_read_type; + + GF_Err last_error; + char *init_data; + u32 init_data_size; + Bool server_only_understand_get; + /* True if cache file must be stored on disk */ + Bool use_cache_file; Bool disable_cache; /*forces notification of data exchange to be sent regardless of threading mode*/ Bool force_data_write_callback; #ifdef GPAC_HAS_SSL - SSL *ssl; + SSL *ssl; #endif - void (*do_requests)(struct __gf_download_session *); + void (*do_requests)(struct __gf_download_session *); - /*callback for data reception - may not be NULL*/ - gf_dm_user_io user_proc; - void *usr_cbk; + /*callback for data reception - may not be NULL*/ + gf_dm_user_io user_proc; + void *usr_cbk; Bool reassigned; Bool chunked; u32 nb_left_in_chunk; u32 request_time; - /*private extension*/ - void *ext; + /*private extension*/ + void *ext; }; struct __gf_download_manager { - GF_Mutex *cache_mx; - char *cache_directory; - char szCookieDir[GF_MAX_PATH]; + GF_Mutex *cache_mx; + char *cache_directory; + char szCookieDir[GF_MAX_PATH]; - Bool (*GetUserPassword)(void *usr_cbk, const char *site_url, char *usr_name, char *password); - void *usr_cbk; + Bool (*GetUserPassword)(void *usr_cbk, const char *site_url, char *usr_name, char *password); + void *usr_cbk; u32 head_timeout, request_timeout; - GF_Config *cfg; - GF_List *sessions; + GF_Config *cfg; + GF_List *sessions; Bool disable_cache; - u32 limit_data_rate; + u32 limit_data_rate; - GF_List *skip_proxy_servers; - GF_List *credentials; - GF_List *cache_entries; - /* FIXME : should be placed in DownloadedCacheEntry maybe... */ - GF_List * partial_downloads; + GF_List *skip_proxy_servers; + GF_List *credentials; + GF_List *cache_entries; + /* FIXME : should be placed in DownloadedCacheEntry maybe... */ + GF_List * partial_downloads; #ifdef GPAC_HAS_SSL - SSL_CTX *ssl_ctx; + SSL_CTX *ssl_ctx; #endif }; @@ -209,23 +211,23 @@ struct __gf_download_manager static void init_prng (void) { - char namebuf[256]; - const char *random_file; + char namebuf[256]; + const char *random_file; - if (RAND_status ()) return; + if (RAND_status ()) return; - namebuf[0] = '\0'; - random_file = RAND_file_name (namebuf, sizeof (namebuf)); + namebuf[0] = '\0'; + random_file = RAND_file_name (namebuf, sizeof (namebuf)); - if (random_file && *random_file) - RAND_load_file(random_file, 16384); + if (random_file && *random_file) + RAND_load_file(random_file, 16384); - if (RAND_status ()) return; + if (RAND_status ()) return; #ifdef WIN32 - RAND_screen (); - if (RAND_status ()) - return; + RAND_screen (); + if (RAND_status ()) + return; #endif } @@ -239,7 +241,7 @@ static void init_prng (void) * \brief Write data to cache * Writes data to the cache. A call to gf_cache_open_write_cache should have been issued before calling this function. * \param entry The entry to use - * \param sess The download session + * \param sess The download session * \param data data to write * \param size number of elements to write * \return GF_OK is everything went fine, GF_BAD_PARAM if cache has not been opened, GF_IO_ERR if a failure occurs @@ -250,7 +252,7 @@ GF_Err gf_cache_write_to_cache( const DownloadedCacheEntry entry, const GF_Downl * \brief Close the write file pointer of cache * This function also flushes all buffers, so cache will always be consistent after * \param entry The entry to use - * \param sess The download session + * \param sess The download session * \param success 1 if cache write is success, false otherwise * \return GF_OK is everything went fine, GF_BAD_PARAM if entry is NULL, GF_IO_ERR if a failure occurs */ @@ -260,7 +262,7 @@ GF_Err gf_cache_close_write_cache( const DownloadedCacheEntry entry, const GF_Do * \brief Open the write file pointer of cache * This function prepares calls for gf_cache_write_to_cache * \param entry The entry to use - * \param sess The download session + * \param sess The download session * \return GF_OK is everything went fine, GF_BAD_PARAM if entry is NULL, GF_IO_ERR if a failure occurs */ GF_Err gf_cache_open_write_cache( const DownloadedCacheEntry entry, const GF_DownloadSession * sess ); @@ -284,17 +286,17 @@ Bool gf_cache_is_in_progress(const DownloadedCacheEntry entry); */ static gf_user_credentials_struct * gf_find_user_credentials_for_site(GF_DownloadManager *dm, const char * server_name) { - u32 count, i; - if (!dm || !dm->credentials || !server_name || !strlen(server_name)) - return NULL; - count = gf_list_count( dm->credentials); - for (i = 0 ; i < count; i++) { - gf_user_credentials_struct * cred = gf_list_get(dm->credentials, i ); - assert( cred ); - if (!strcmp(cred->site, server_name)) - return cred; - } - return NULL; + u32 count, i; + if (!dm || !dm->credentials || !server_name || !strlen(server_name)) + return NULL; + count = gf_list_count( dm->credentials); + for (i = 0 ; i < count; i++) { + gf_user_credentials_struct * cred = gf_list_get(dm->credentials, i ); + assert( cred ); + if (!strcmp(cred->site, server_name)) + return cred; + } + return NULL; } /** @@ -305,16 +307,16 @@ gf_user_credentials_struct * gf_find_user_credentials_for_site(GF_DownloadManage */ static GF_Err gf_user_credentials_save_digest( GF_DownloadManager * dm, gf_user_credentials_struct * creds, const char * password) { - int size; - char pass_buf[1024], range_buf[1024]; - if (!dm || !creds || !password) - return GF_BAD_PARAM; - sprintf(pass_buf, "%s:%s", creds->username, password); - size = gf_base64_encode(pass_buf, (u32) strlen(pass_buf), range_buf, 1024); - range_buf[size] = 0; - strcpy(creds->digest, range_buf); - creds->valid = 1; - return GF_OK; + int size; + char pass_buf[1024], range_buf[1024]; + if (!dm || !creds || !password) + return GF_BAD_PARAM; + sprintf(pass_buf, "%s:%s", creds->username, password); + size = gf_base64_encode(pass_buf, (u32) strlen(pass_buf), range_buf, 1024); + range_buf[size] = 0; + strcpy(creds->digest, range_buf); + creds->valid = 1; + return GF_OK; } /** @@ -326,48 +328,48 @@ GF_Err gf_user_credentials_save_digest( GF_DownloadManager * dm, gf_user_credent static GF_Err gf_user_credentials_ask_password( GF_DownloadManager * dm, gf_user_credentials_struct * creds) { - char szPASS[50]; - if (!dm || !creds) - return GF_BAD_PARAM; - memset(szPASS, 0, 50); - if (!dm->GetUserPassword || !dm->GetUserPassword(dm->usr_cbk, creds->site, creds->username, szPASS)) { - return GF_AUTHENTICATION_FAILURE; - } - return gf_user_credentials_save_digest(dm, creds, szPASS); - return GF_OK; + char szPASS[50]; + if (!dm || !creds) + return GF_BAD_PARAM; + memset(szPASS, 0, 50); + if (!dm->GetUserPassword || !dm->GetUserPassword(dm->usr_cbk, creds->site, creds->username, szPASS)) { + return GF_AUTHENTICATION_FAILURE; + } + return gf_user_credentials_save_digest(dm, creds, szPASS); + return GF_OK; } static gf_user_credentials_struct * gf_user_credentials_register(GF_DownloadManager * dm, const char * server_name, const char * username, const char * password, Bool valid) { - gf_user_credentials_struct * creds; - if (!dm) - return NULL; - assert( server_name ); - creds = gf_find_user_credentials_for_site(dm, server_name); - /* If none found, we create one */ - if (!creds) { - creds = (gf_user_credentials_struct*)gf_malloc(sizeof( gf_user_credentials_struct)); - if (!creds) - return NULL; - gf_list_insert(dm->credentials, creds, 0); - } - creds->valid = valid; - strncpy(creds->username, username ? username : "", 50); - strcpy(creds->site, server_name); - if (username && password && valid) - gf_user_credentials_save_digest(dm, creds, password); - else { - if (GF_OK != gf_user_credentials_ask_password(dm, creds)) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, - ("[HTTP] Failed to get password information.\n")); - gf_list_rem( dm->credentials, 0); - gf_free( creds ); - creds = NULL; - } - } - return creds; + gf_user_credentials_struct * creds; + if (!dm) + return NULL; + assert( server_name ); + creds = gf_find_user_credentials_for_site(dm, server_name); + /* If none found, we create one */ + if (!creds) { + creds = (gf_user_credentials_struct*)gf_malloc(sizeof( gf_user_credentials_struct)); + if (!creds) + return NULL; + gf_list_insert(dm->credentials, creds, 0); + } + creds->valid = valid; + strncpy(creds->username, username ? username : "", 50); + strcpy(creds->site, server_name); + if (username && password && valid) + gf_user_credentials_save_digest(dm, creds, password); + else { + if (GF_OK != gf_user_credentials_ask_password(dm, creds)) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, + ("[HTTP] Failed to get password information.\n")); + gf_list_rem( dm->credentials, 0); + gf_free( creds ); + creds = NULL; + } + } + return creds; } #ifdef GPAC_HAS_SSL @@ -379,82 +381,82 @@ static Bool _ssl_is_initialized = 0; * \return 0 if everyhing is OK, 1 otherwise */ static Bool init_ssl_lib() { - if (_ssl_is_initialized) - return 0; - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[HTTPS] Initializing SSL library...\n")); - init_prng(); - if (RAND_status() != 1) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTPS] Error while initializing Random Number generator, failed to init SSL !\n")); - return 1; - } - SSL_library_init(); - SSL_load_error_strings(); - SSLeay_add_all_algorithms(); - SSLeay_add_ssl_algorithms(); - _ssl_is_initialized = 1; - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[HTTPS] Initalization of SSL library complete.\n")); - return 0; + if (_ssl_is_initialized) + return 0; + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[HTTPS] Initializing SSL library...\n")); + init_prng(); + if (RAND_status() != 1) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTPS] Error while initializing Random Number generator, failed to init SSL !\n")); + return 1; + } + SSL_library_init(); + SSL_load_error_strings(); + SSLeay_add_all_algorithms(); + SSLeay_add_ssl_algorithms(); + _ssl_is_initialized = 1; + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[HTTPS] Initalization of SSL library complete.\n")); + return 0; } static int ssl_init(GF_DownloadManager *dm, u32 mode) { #if OPENSSL_VERSION_NUMBER > 0x00909000 - const + const #endif - SSL_METHOD *meth; - - if (!dm) return 0; - gf_mx_p(dm->cache_mx); - /* The SSL has already been initialized. */ - if (dm->ssl_ctx) { - gf_mx_v(dm->cache_mx); - return 1; - } - /* Init the PRNG. If that fails, bail out. */ - if (init_ssl_lib()) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTPS] Failed to properly initialize SSL library\n")); - goto error; - } - - switch (mode) { - case 0: - meth = SSLv23_client_method(); - break; + SSL_METHOD *meth; + + if (!dm) return 0; + gf_mx_p(dm->cache_mx); + /* The SSL has already been initialized. */ + if (dm->ssl_ctx) { + gf_mx_v(dm->cache_mx); + return 1; + } + /* Init the PRNG. If that fails, bail out. */ + if (init_ssl_lib()) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTPS] Failed to properly initialize SSL library\n")); + goto error; + } + + switch (mode) { + case 0: + meth = SSLv23_client_method(); + break; #if 0 /*SSL v2 is no longer supported in OpenSSL 1.0*/ - case 1: - meth = SSLv2_client_method(); - break; + case 1: + meth = SSLv2_client_method(); + break; #endif - case 2: - meth = SSLv3_client_method(); - break; - case 3: - meth = TLSv1_client_method(); - break; - default: - goto error; - } - - dm->ssl_ctx = SSL_CTX_new(meth); - if (!dm->ssl_ctx) goto error; - SSL_CTX_set_default_verify_paths(dm->ssl_ctx); - SSL_CTX_load_verify_locations (dm->ssl_ctx, NULL, NULL); - /* SSL_VERIFY_NONE instructs OpenSSL not to abort SSL_connect if the - certificate is invalid. We verify the certificate separately in - ssl_check_certificate, which provides much better diagnostics - than examining the error stack after a failed SSL_connect. */ - SSL_CTX_set_verify(dm->ssl_ctx, SSL_VERIFY_NONE, NULL); - - /* Since fd_write unconditionally assumes partial writes (and handles them correctly), - allow them in OpenSSL. */ - SSL_CTX_set_mode(dm->ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE); - gf_mx_v(dm->cache_mx); - return 1; + case 2: + meth = SSLv3_client_method(); + break; + case 3: + meth = TLSv1_client_method(); + break; + default: + goto error; + } + + dm->ssl_ctx = SSL_CTX_new(meth); + if (!dm->ssl_ctx) goto error; + SSL_CTX_set_default_verify_paths(dm->ssl_ctx); + SSL_CTX_load_verify_locations (dm->ssl_ctx, NULL, NULL); + /* SSL_VERIFY_NONE instructs OpenSSL not to abort SSL_connect if the + certificate is invalid. We verify the certificate separately in + ssl_check_certificate, which provides much better diagnostics + than examining the error stack after a failed SSL_connect. */ + SSL_CTX_set_verify(dm->ssl_ctx, SSL_VERIFY_NONE, NULL); + + /* Since fd_write unconditionally assumes partial writes (and handles them correctly), + allow them in OpenSSL. */ + SSL_CTX_set_mode(dm->ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE); + gf_mx_v(dm->cache_mx); + return 1; error: - if (dm->ssl_ctx) SSL_CTX_free(dm->ssl_ctx); - dm->ssl_ctx = NULL; - gf_mx_v(dm->cache_mx); - return 0; + if (dm->ssl_ctx) SSL_CTX_free(dm->ssl_ctx); + dm->ssl_ctx = NULL; + gf_mx_v(dm->cache_mx); + return 0; } #endif /* GPAC_HAS_SSL */ @@ -462,18 +464,18 @@ error: static Bool gf_dm_is_local(GF_DownloadManager *dm, const char *url) { - if (!strnicmp(url, "file://", 7)) return 1; - if (!strstr(url, "://")) return 1; - return 0; + if (!strnicmp(url, "file://", 7)) return 1; + if (!strstr(url, "://")) return 1; + return 0; } static Bool gf_dm_can_handle_url(GF_DownloadManager *dm, const char *url) { - if (!strnicmp(url, "http://", 7)) return 1; + if (!strnicmp(url, "http://", 7)) return 1; #ifdef GPAC_HAS_SSL - if (!strnicmp(url, "https://", 8)) return 1; + if (!strnicmp(url, "https://", 8)) return 1; #endif - return 0; + return 0; } /*! @@ -482,17 +484,17 @@ static Bool gf_dm_can_handle_url(GF_DownloadManager *dm, const char *url) * \return NULL if none found, the DownloadedCacheEntry otherwise */ DownloadedCacheEntry gf_dm_find_cached_entry_by_url(GF_DownloadSession * sess) { - u32 i, count; - assert( sess && sess->dm && sess->dm->cache_entries ); - gf_mx_p( sess->dm->cache_mx ); - count = gf_list_count(sess->dm->cache_entries); - for (i = 0 ; i < count; i++) { - const char * url; - DownloadedCacheEntry e = gf_list_get(sess->dm->cache_entries, i); - assert(e); - url = gf_cache_get_url(e); - assert( url ); - if (strcmp(url, sess->orig_url)) continue; + u32 i, count; + assert( sess && sess->dm && sess->dm->cache_entries ); + gf_mx_p( sess->dm->cache_mx ); + count = gf_list_count(sess->dm->cache_entries); + for (i = 0 ; i < count; i++) { + const char * url; + DownloadedCacheEntry e = gf_list_get(sess->dm->cache_entries, i); + assert(e); + url = gf_cache_get_url(e); + assert( url ); + if (strcmp(url, sess->orig_url)) continue; if (sess->needs_cache_reconfig==2) continue; @@ -503,9 +505,9 @@ DownloadedCacheEntry gf_dm_find_cached_entry_by_url(GF_DownloadSession * sess) { /*OK that's ours*/ gf_mx_v( sess->dm->cache_mx ); return e; - } - gf_mx_v( sess->dm->cache_mx ); - return NULL; + } + gf_mx_v( sess->dm->cache_mx ); + return NULL; } /** @@ -534,29 +536,29 @@ s32 gf_cache_remove_session_from_cache_entry(DownloadedCacheEntry entry, GF_Down * removed (so some modules using a streaming like cache will still work). */ void gf_dm_remove_cache_entry_from_session(GF_DownloadSession * sess) { - if (sess && sess->cache_entry) { - gf_cache_remove_session_from_cache_entry(sess->cache_entry, sess); - if (sess->dm - /*JLF - not sure what the rationale of this test is, and it prevents cleanup of cache entry - which then results to crash when restarting the session (entry->writeFilePtr i snot set back to NULL)*/ - && gf_cache_entry_is_delete_files_when_deleted(sess->cache_entry) - - && (0 == gf_cache_get_sessions_count_for_cache_entry(sess->cache_entry))) - { - u32 i, count; - gf_mx_p( sess->dm->cache_mx ); - count = gf_list_count( sess->dm->cache_entries ); - for (i = 0; i < count; i++) { - DownloadedCacheEntry ex = gf_list_get(sess->dm->cache_entries, i); - if (ex == sess->cache_entry) { - gf_list_rem(sess->dm->cache_entries, i); - gf_cache_delete_entry( sess->cache_entry ); - break; - } - } - gf_mx_v( sess->dm->cache_mx ); - } - } + if (sess && sess->cache_entry) { + gf_cache_remove_session_from_cache_entry(sess->cache_entry, sess); + if (sess->dm + /*JLF - not sure what the rationale of this test is, and it prevents cleanup of cache entry + which then results to crash when restarting the session (entry->writeFilePtr i snot set back to NULL)*/ + && gf_cache_entry_is_delete_files_when_deleted(sess->cache_entry) + + && (0 == gf_cache_get_sessions_count_for_cache_entry(sess->cache_entry))) + { + u32 i, count; + gf_mx_p( sess->dm->cache_mx ); + count = gf_list_count( sess->dm->cache_entries ); + for (i = 0; i < count; i++) { + DownloadedCacheEntry ex = gf_list_get(sess->dm->cache_entries, i); + if (ex == sess->cache_entry) { + gf_list_rem(sess->dm->cache_entries, i); + gf_cache_delete_entry( sess->cache_entry ); + break; + } + } + gf_mx_v( sess->dm->cache_mx ); + } + } } /*! @@ -570,9 +572,9 @@ s32 gf_cache_add_session_to_cache_entry(DownloadedCacheEntry entry, GF_DownloadS void gf_dm_configure_cache(GF_DownloadSession *sess) { - DownloadedCacheEntry entry; - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_configure_cache(%p), cached=%s\n", sess, sess->flags & GF_NETIO_SESSION_NOT_CACHED ? "no" : "yes" )); - gf_dm_remove_cache_entry_from_session(sess); + DownloadedCacheEntry entry; + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_configure_cache(%p), cached=%s\n", sess, sess->flags & GF_NETIO_SESSION_NOT_CACHED ? "no" : "yes" )); + gf_dm_remove_cache_entry_from_session(sess); if (sess->flags & GF_NETIO_SESSION_NOT_CACHED) { sess->cache_entry = NULL; } else { @@ -595,56 +597,56 @@ void gf_dm_configure_cache(GF_DownloadSession *sess) void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * url) { - GF_Err e; - u32 count, i; - char * realURL; - GF_URL_Info info; - if (!url || !dm) - return; - gf_mx_p( dm->cache_mx ); - gf_dm_url_info_init(&info); - e = gf_dm_get_url_info(url, &info, NULL); - if (e != GF_OK) { - gf_mx_p( dm->cache_mx ); - gf_dm_url_info_del(&info); - return; - } - realURL = gf_strdup(info.canonicalRepresentation); - gf_dm_url_info_del(&info); - assert( realURL ); - count = gf_list_count(dm->cache_entries); - for (i = 0 ; i < count; i++) { - const char * e_url; - DownloadedCacheEntry e = gf_list_get(dm->cache_entries, i); - assert(e); - e_url = gf_cache_get_url(e); - assert( e_url ); - if (!strcmp(e_url, realURL)) { - /* We found the existing session */ - gf_cache_entry_set_delete_files_when_deleted(e); - if (0 == gf_cache_get_sessions_count_for_cache_entry( e )) { - /* No session attached anymore... we can delete it */ - gf_list_rem(dm->cache_entries, i); - gf_cache_delete_entry(e); - } - /* If deleted or not, we don't search further */ - gf_mx_v( dm->cache_mx ); - gf_free(realURL); - return; - } - } - /* If we are heren it means we did not found this URL in cache */ - gf_mx_v( dm->cache_mx ); - gf_free(realURL); - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[CACHE] Cannot find URL %s, cache file won't be deleted.\n", url)); + GF_Err e; + u32 count, i; + char * realURL; + GF_URL_Info info; + if (!url || !dm) + return; + gf_mx_p( dm->cache_mx ); + gf_dm_url_info_init(&info); + e = gf_dm_get_url_info(url, &info, NULL); + if (e != GF_OK) { + gf_mx_p( dm->cache_mx ); + gf_dm_url_info_del(&info); + return; + } + realURL = gf_strdup(info.canonicalRepresentation); + gf_dm_url_info_del(&info); + assert( realURL ); + count = gf_list_count(dm->cache_entries); + for (i = 0 ; i < count; i++) { + const char * e_url; + DownloadedCacheEntry e = gf_list_get(dm->cache_entries, i); + assert(e); + e_url = gf_cache_get_url(e); + assert( e_url ); + if (!strcmp(e_url, realURL)) { + /* We found the existing session */ + gf_cache_entry_set_delete_files_when_deleted(e); + if (0 == gf_cache_get_sessions_count_for_cache_entry( e )) { + /* No session attached anymore... we can delete it */ + gf_list_rem(dm->cache_entries, i); + gf_cache_delete_entry(e); + } + /* If deleted or not, we don't search further */ + gf_mx_v( dm->cache_mx ); + gf_free(realURL); + return; + } + } + /* If we are heren it means we did not found this URL in cache */ + gf_mx_v( dm->cache_mx ); + gf_free(realURL); + GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[CACHE] Cannot find URL %s, cache file won't be deleted.\n", url)); } GF_EXPORT void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url) { - if (sess && sess->dm && url) { - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[CACHE] Requesting deletion for %s\n", url)); - gf_dm_delete_cached_file_entry(sess->dm, url); - } + if (sess && sess->dm && url) { + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[CACHE] Requesting deletion for %s\n", url)); + gf_dm_delete_cached_file_entry(sess->dm, url); + } } @@ -666,15 +668,15 @@ static void gf_dm_clear_headers(GF_DownloadSession *sess) static void gf_dm_disconnect(GF_DownloadSession *sess, Bool force_close) { - assert( sess ); + assert( sess ); if (sess->connection_close) force_close=1; sess->connection_close = 0; - if (sess->status >= GF_NETIO_DISCONNECTED) + if (sess->status >= GF_NETIO_DISCONNECTED) return; - GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Downloader] gf_dm_disconnect(%p)\n", sess )); - if (sess->mx) - gf_mx_p(sess->mx); + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Downloader] gf_dm_disconnect(%p)\n", sess )); + if (sess->mx) + gf_mx_p(sess->mx); if (force_close || !(sess->flags & GF_NETIO_SESSION_PERSISTENT)) { #ifdef GPAC_HAS_SSL @@ -690,125 +692,125 @@ static void gf_dm_disconnect(GF_DownloadSession *sess, Bool force_close) gf_sk_del(sx); } } - sess->status = GF_NETIO_DISCONNECTED; - if (sess->num_retry) sess->num_retry--; - if (sess->mx) - gf_mx_v(sess->mx); + sess->status = GF_NETIO_DISCONNECTED; + if (sess->num_retry) sess->num_retry--; + if (sess->mx) + gf_mx_v(sess->mx); } GF_EXPORT void gf_dm_sess_del(GF_DownloadSession *sess) { - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p)\n", sess )); - if (!sess) - return; - /*self-destruction, let the download manager destroy us*/ - if (sess->th && sess->in_callback) { - sess->destroy = 1; - return; - } - gf_dm_disconnect(sess, 1); + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p)\n", sess )); + if (!sess) + return; + /*self-destruction, let the download manager destroy us*/ + if (sess->th && sess->in_callback) { + sess->destroy = 1; + return; + } + gf_dm_disconnect(sess, 1); gf_dm_clear_headers(sess); - /*if threaded wait for thread exit*/ - if (sess->th) { - while (!(sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD)) - gf_sleep(1); - gf_th_stop(sess->th); - gf_th_del(sess->th); - if (sess->mx) - gf_mx_del(sess->mx); - sess->th = NULL; - sess->mx = NULL; - } + /*if threaded wait for thread exit*/ + if (sess->th) { + while (!(sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD)) + gf_sleep(1); + gf_th_stop(sess->th); + gf_th_del(sess->th); + if (sess->mx) + gf_mx_del(sess->mx); + sess->th = NULL; + sess->mx = NULL; + } - if (sess->dm) gf_list_del_item(sess->dm->sessions, sess); + if (sess->dm) gf_list_del_item(sess->dm->sessions, sess); gf_dm_remove_cache_entry_from_session(sess); - sess->cache_entry = NULL; - if (sess->orig_url) gf_free(sess->orig_url); - if (sess->orig_url_before_redirect) gf_free(sess->orig_url_before_redirect); - if (sess->server_name) gf_free(sess->server_name); - sess->server_name = NULL; - if (sess->remote_path) gf_free(sess->remote_path); - /* Credentials are stored into the sess->dm */ - if (sess->creds) sess->creds = NULL; - if (sess->init_data) gf_free(sess->init_data); - sess->orig_url = sess->server_name = sess->remote_path; - sess->creds = NULL; - if (sess->sock) + sess->cache_entry = NULL; + if (sess->orig_url) gf_free(sess->orig_url); + if (sess->orig_url_before_redirect) gf_free(sess->orig_url_before_redirect); + if (sess->server_name) gf_free(sess->server_name); + sess->server_name = NULL; + if (sess->remote_path) gf_free(sess->remote_path); + /* Credentials are stored into the sess->dm */ + if (sess->creds) sess->creds = NULL; + if (sess->init_data) gf_free(sess->init_data); + sess->orig_url = sess->server_name = sess->remote_path; + sess->creds = NULL; + if (sess->sock) gf_sk_del(sess->sock); gf_list_del(sess->headers); - gf_free(sess); - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p) : DONE\n", sess )); + gf_free(sess); + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p) : DONE\n", sess )); } void http_do_requests(GF_DownloadSession *sess); static void gf_dm_sess_notify_state(GF_DownloadSession *sess, GF_NetIOStatus dnload_status, GF_Err error) { - if (sess->user_proc) { - GF_NETIO_Parameter par; - sess->in_callback = 1; - memset(&par, 0, sizeof(GF_NETIO_Parameter)); - par.msg_type = dnload_status; - par.error = error; + if (sess->user_proc) { + GF_NETIO_Parameter par; + sess->in_callback = 1; + memset(&par, 0, sizeof(GF_NETIO_Parameter)); + par.msg_type = dnload_status; + par.error = error; par.sess = sess; - sess->user_proc(sess->usr_cbk, &par); - sess->in_callback = 0; - } + sess->user_proc(sess->usr_cbk, &par); + sess->in_callback = 0; + } } static void gf_dm_sess_user_io(GF_DownloadSession *sess, GF_NETIO_Parameter *par) { - if (sess->user_proc) { - sess->in_callback = 1; + if (sess->user_proc) { + sess->in_callback = 1; par->sess = sess; - sess->user_proc(sess->usr_cbk, par); - sess->in_callback = 0; - } + sess->user_proc(sess->usr_cbk, par); + sess->in_callback = 0; + } } GF_EXPORT Bool gf_dm_is_thread_dead(GF_DownloadSession *sess) { - if (!sess) return 1; - return (sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD) ? 1 : 0; + if (!sess) return 1; + return (sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD) ? 1 : 0; } GF_EXPORT GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess) { - if (!sess) return GF_BAD_PARAM; - return sess->last_error; + if (!sess) return GF_BAD_PARAM; + return sess->last_error; } GF_EXPORT void gf_dm_url_info_init(GF_URL_Info * info) { - info->password = NULL; - info->userName = NULL; - info->canonicalRepresentation = NULL; - info->protocol = NULL; - info->port = 0; - info->remotePath = NULL; - info->server_name = NULL; + info->password = NULL; + info->userName = NULL; + info->canonicalRepresentation = NULL; + info->protocol = NULL; + info->port = 0; + info->remotePath = NULL; + info->server_name = NULL; } GF_EXPORT void gf_dm_url_info_del(GF_URL_Info * info) { - if (!info) - return; - if (info->canonicalRepresentation) - gf_free(info->canonicalRepresentation); - if (info->password) - gf_free(info->password); - if (info->userName) - gf_free(info->userName); - if (info->remotePath) - gf_free(info->remotePath); - if (info->server_name) - gf_free(info->server_name); - gf_dm_url_info_init(info); + if (!info) + return; + if (info->canonicalRepresentation) + gf_free(info->canonicalRepresentation); + if (info->password) + gf_free(info->password); + if (info->userName) + gf_free(info->userName); + if (info->remotePath) + gf_free(info->remotePath); + if (info->server_name) + gf_free(info->server_name); + gf_dm_url_info_init(info); } /** @@ -816,152 +818,152 @@ void gf_dm_url_info_del(GF_URL_Info * info) { * \param info The info to fill * \return Returns the offset in url of the protocol found -1 if not found */ -static s32 gf_dm_parse_protocol(const char * url, GF_URL_Info * info){ - assert(info); - assert(url); - if (!strnicmp(url, "http://", 7)) { - info->port = 80; - info->protocol = "http://"; - return 7; - } - else if (!strnicmp(url, "https://", 8)) { - info->port = 443; +static s32 gf_dm_parse_protocol(const char * url, GF_URL_Info * info) { + assert(info); + assert(url); + if (!strnicmp(url, "http://", 7)) { + info->port = 80; + info->protocol = "http://"; + return 7; + } + else if (!strnicmp(url, "https://", 8)) { + info->port = 443; #ifndef GPAC_HAS_SSL - return -1; + return -1; #endif - info->protocol = "https://"; - return 8; - } - else if (!strnicmp(url, "ftp://", 6)) { - info->port = 21; - info->protocol = "ftp://"; - return -1; - } - return -1; + info->protocol = "https://"; + return 8; + } + else if (!strnicmp(url, "ftp://", 6)) { + info->port = 21; + info->protocol = "ftp://"; + return -1; + } + return -1; } GF_EXPORT GF_Err gf_dm_get_url_info(const char * url, GF_URL_Info * info, const char * baseURL) { - char *tmp, *tmp_url, *current_pos, *urlConcatenateWithBaseURL; - char * copyOfUrl; - s32 proto_offset; - gf_dm_url_info_del(info); - urlConcatenateWithBaseURL = NULL; - proto_offset = gf_dm_parse_protocol(url, info); - if (proto_offset > 0){ - url += proto_offset; - } else { - /*relative URL*/ - if (!strstr(url, "://")) { - u32 i; - info->protocol = "file://"; - if (baseURL) { - urlConcatenateWithBaseURL = gf_url_concatenate(baseURL, url); - /*relative file path*/ - if (!strstr(baseURL, "://")) { - info->canonicalRepresentation = urlConcatenateWithBaseURL; + char *tmp, *tmp_url, *current_pos, *urlConcatenateWithBaseURL; + char * copyOfUrl; + s32 proto_offset; + gf_dm_url_info_del(info); + urlConcatenateWithBaseURL = NULL; + proto_offset = gf_dm_parse_protocol(url, info); + if (proto_offset > 0) { + url += proto_offset; + } else { + /*relative URL*/ + if (!strstr(url, "://")) { + u32 i; + info->protocol = "file://"; + if (baseURL) { + urlConcatenateWithBaseURL = gf_url_concatenate(baseURL, url); + /*relative file path*/ + if (!strstr(baseURL, "://")) { + info->canonicalRepresentation = urlConcatenateWithBaseURL; + return GF_OK; + } + proto_offset = gf_dm_parse_protocol(urlConcatenateWithBaseURL, info); + } else { + proto_offset = -1; + } + + if (proto_offset < 0) { + tmp = urlConcatenateWithBaseURL; + assert( ! info->remotePath ); + info->remotePath = gf_url_percent_encode(tmp); + gf_free( urlConcatenateWithBaseURL ); + urlConcatenateWithBaseURL = NULL; + for (i=0; iremotePath); i++) + if (info->remotePath[i]=='\\') info->remotePath[i]='/'; + info->canonicalRepresentation = gf_malloc(strlen(info->protocol) + strlen(info->remotePath) + 1); + strcpy(info->canonicalRepresentation, info->protocol); + strcat(info->canonicalRepresentation, info->remotePath); + if (urlConcatenateWithBaseURL) + gf_free(urlConcatenateWithBaseURL); return GF_OK; + } else { + /* We continue the parsing as usual */ + url = urlConcatenateWithBaseURL + proto_offset; } - proto_offset = gf_dm_parse_protocol(urlConcatenateWithBaseURL, info); - } else { - proto_offset = -1; - } - - if (proto_offset < 0){ - tmp = urlConcatenateWithBaseURL; - assert( ! info->remotePath ); - info->remotePath = gf_url_percent_encode(tmp); - gf_free( urlConcatenateWithBaseURL ); - urlConcatenateWithBaseURL = NULL; - for (i=0; iremotePath); i++) - if (info->remotePath[i]=='\\') info->remotePath[i]='/'; - info->canonicalRepresentation = gf_malloc(strlen(info->protocol) + strlen(info->remotePath) + 1); - strcpy(info->canonicalRepresentation, info->protocol); - strcat(info->canonicalRepresentation, info->remotePath); - if (urlConcatenateWithBaseURL) - gf_free(urlConcatenateWithBaseURL); - return GF_OK; - } else { - /* We continue the parsing as usual */ - url = urlConcatenateWithBaseURL + proto_offset; - } - } else { - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[PROTOCOL] : cannot find any protocol in url %s\n", url)); - return GF_BAD_PARAM; - } - } - assert( proto_offset >= 0 ); - tmp = strchr(url, '/'); - assert( !info->remotePath ); - info->remotePath = gf_url_percent_encode(tmp ? tmp : "/"); - if (tmp) { - tmp[0] = 0; - copyOfUrl = gf_strdup(url); - tmp[0] = '/'; - } else { - copyOfUrl = gf_strdup(url); - } - tmp_url = copyOfUrl; - current_pos = tmp_url; - tmp = strrchr(tmp_url, '@'); - if (tmp) { - current_pos = tmp + 1; - assert( ! info->server_name ); - info->server_name = gf_strdup(current_pos); - tmp[0] = 0; - tmp = strchr(tmp_url, ':'); - - if (tmp) { - tmp[0] = 0; - info->password = gf_strdup(tmp+1); - } - info->userName = gf_strdup(tmp_url); - } else { - assert( ! info->server_name ); - info->server_name = gf_strdup(tmp_url); - } - - tmp = strrchr(current_pos, ':'); - if (tmp) { - info->port = atoi(tmp+1); - tmp[0] = 0; - if (info->server_name) { - gf_free(info->server_name); - } - info->server_name = gf_strdup(current_pos); - } - - /* builds orig_url */ - /* We dont't want orig_url to contain user/passwords for security reasons or mismatch in cache hit */ - { - char port[8]; - snprintf(port, sizeof(port)-1, ":%d", info->port); - info->canonicalRepresentation = gf_malloc(strlen(info->protocol)+strlen(info->server_name)+1+strlen(port)+strlen(info->remotePath)); - strcpy(info->canonicalRepresentation, info->protocol); - strcat(info->canonicalRepresentation, info->server_name); - strcat(info->canonicalRepresentation, port); - strcat(info->canonicalRepresentation, info->remotePath); - } - gf_free(copyOfUrl); - if (urlConcatenateWithBaseURL) - gf_free(urlConcatenateWithBaseURL); - return GF_OK; + } else { + GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[PROTOCOL] : cannot find any protocol in url %s\n", url)); + return GF_BAD_PARAM; + } + } + assert( proto_offset >= 0 ); + tmp = strchr(url, '/'); + assert( !info->remotePath ); + info->remotePath = gf_url_percent_encode(tmp ? tmp : "/"); + if (tmp) { + tmp[0] = 0; + copyOfUrl = gf_strdup(url); + tmp[0] = '/'; + } else { + copyOfUrl = gf_strdup(url); + } + tmp_url = copyOfUrl; + current_pos = tmp_url; + tmp = strrchr(tmp_url, '@'); + if (tmp) { + current_pos = tmp + 1; + assert( ! info->server_name ); + info->server_name = gf_strdup(current_pos); + tmp[0] = 0; + tmp = strchr(tmp_url, ':'); + + if (tmp) { + tmp[0] = 0; + info->password = gf_strdup(tmp+1); + } + info->userName = gf_strdup(tmp_url); + } else { + assert( ! info->server_name ); + info->server_name = gf_strdup(tmp_url); + } + + tmp = strrchr(current_pos, ':'); + if (tmp) { + info->port = atoi(tmp+1); + tmp[0] = 0; + if (info->server_name) { + gf_free(info->server_name); + } + info->server_name = gf_strdup(current_pos); + } + + /* builds orig_url */ + /* We dont't want orig_url to contain user/passwords for security reasons or mismatch in cache hit */ + { + char port[8]; + snprintf(port, sizeof(port)-1, ":%d", info->port); + info->canonicalRepresentation = gf_malloc(strlen(info->protocol)+strlen(info->server_name)+1+strlen(port)+strlen(info->remotePath)); + strcpy(info->canonicalRepresentation, info->protocol); + strcat(info->canonicalRepresentation, info->server_name); + strcat(info->canonicalRepresentation, port); + strcat(info->canonicalRepresentation, info->remotePath); + } + gf_free(copyOfUrl); + if (urlConcatenateWithBaseURL) + gf_free(urlConcatenateWithBaseURL); + return GF_OK; } GF_EXPORT GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url) { Bool socket_changed = 0; - GF_URL_Info info; + GF_URL_Info info; if (!url) return GF_BAD_PARAM; gf_dm_clear_headers(sess); - gf_dm_url_info_init(&info); + gf_dm_url_info_init(&info); if (!sess->sock) socket_changed = 1; - else if (sess->status>GF_NETIO_DISCONNECTED) + else if (sess->status>GF_NETIO_DISCONNECTED) socket_changed = 1; sess->last_error = gf_dm_get_url_info(url, &info, sess->remote_path); @@ -972,23 +974,23 @@ GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url) sess->port = info.port; } - if (!strcmp("http://", info.protocol) || !strcmp("https://", info.protocol)) { + if (!strcmp("http://", info.protocol) || !strcmp("https://", info.protocol)) { if (sess->do_requests != http_do_requests) { - sess->do_requests = http_do_requests; + sess->do_requests = http_do_requests; socket_changed = 1; } if (!strcmp("https://", info.protocol)) { if (!(sess->flags & GF_DOWNLOAD_SESSION_USE_SSL)) { - sess->flags |= GF_DOWNLOAD_SESSION_USE_SSL; + sess->flags |= GF_DOWNLOAD_SESSION_USE_SSL; socket_changed = 1; } } else if (sess->flags & GF_DOWNLOAD_SESSION_USE_SSL) { - sess->flags &= ~GF_DOWNLOAD_SESSION_USE_SSL; + sess->flags &= ~GF_DOWNLOAD_SESSION_USE_SSL; socket_changed = 1; } - } else { - sess->do_requests = NULL; - } + } else { + sess->do_requests = NULL; + } if (sess->server_name && info.server_name && !strcmp(sess->server_name, info.server_name)) { } else { @@ -1002,9 +1004,9 @@ GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url) if (!sess->orig_url_before_redirect) sess->orig_url_before_redirect = gf_strdup(url); - - if (sess->remote_path) gf_free(sess->remote_path); - sess->remote_path = gf_strdup(info.remotePath); + + if (sess->remote_path) gf_free(sess->remote_path); + sess->remote_path = gf_strdup(info.remotePath); if (!socket_changed && info.userName && sess->creds->username && !strcmp(info.userName, sess->creds->username)) { } else { @@ -1016,49 +1018,49 @@ GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url) sess->creds = gf_user_credentials_register(sess->dm, sess->server_name, info.userName, info.password, info.userName && info.password); } } - gf_dm_url_info_del(&info); + gf_dm_url_info_del(&info); if (sess->sock && !socket_changed) { sess->status = GF_NETIO_CONNECTED; - sess->num_retry = SESSION_RETRY_COUNT; + sess->num_retry = SESSION_RETRY_COUNT; sess->needs_cache_reconfig = 1; } else { if (sess->sock) gf_sk_del(sess->sock); sess->sock = NULL; sess->status = GF_NETIO_SETUP; } - return sess->last_error; + return sess->last_error; } static u32 gf_dm_session_thread(void *par) { - GF_DownloadSession *sess = (GF_DownloadSession *)par; - - GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Downloader] Entering thread ID %d\n", gf_th_id() )); - sess->flags &= ~GF_DOWNLOAD_SESSION_THREAD_DEAD; - while (!sess->destroy) { - gf_mx_p(sess->mx); - if (sess->status >= GF_NETIO_DISCONNECTED) { - gf_mx_v(sess->mx); - break; - } - if (sess->status < GF_NETIO_CONNECTED) { - gf_dm_connect(sess); - } else { - if (sess->status == GF_NETIO_WAIT_FOR_REPLY) gf_sleep(GF_WAIT_REPLY_SLEEP); - sess->do_requests(sess); - } - gf_mx_v(sess->mx); - gf_sleep(2); - } - /*destroy all sessions*/ - gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = 0; - sess->flags |= GF_DOWNLOAD_SESSION_THREAD_DEAD; - return 1; + GF_DownloadSession *sess = (GF_DownloadSession *)par; + + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Downloader] Entering thread ID %d\n", gf_th_id() )); + sess->flags &= ~GF_DOWNLOAD_SESSION_THREAD_DEAD; + while (!sess->destroy) { + gf_mx_p(sess->mx); + if (sess->status >= GF_NETIO_DISCONNECTED) { + gf_mx_v(sess->mx); + break; + } + if (sess->status < GF_NETIO_CONNECTED) { + gf_dm_connect(sess); + } else { + if (sess->status == GF_NETIO_WAIT_FOR_REPLY) gf_sleep(GF_WAIT_REPLY_SLEEP); + sess->do_requests(sess); + } + gf_mx_v(sess->mx); + gf_sleep(2); + } + /*destroy all sessions*/ + gf_dm_disconnect(sess, 0); + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = 0; + sess->flags |= GF_DOWNLOAD_SESSION_THREAD_DEAD; + return 1; } @@ -1068,32 +1070,32 @@ GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *u void *usr_cbk, GF_Err *e) { - GF_DownloadSession *sess; - GF_SAFEALLOC(sess, GF_DownloadSession); - if (!sess){ - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("%s:%d Cannot allocate session for URL %s: OUT OF MEMORY!\n", __FILE__, __LINE__, url)); - return NULL; - } + GF_DownloadSession *sess; + GF_SAFEALLOC(sess, GF_DownloadSession); + if (!sess) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("%s:%d Cannot allocate session for URL %s: OUT OF MEMORY!\n", __FILE__, __LINE__, url)); + return NULL; + } sess->headers = gf_list_new(); - sess->flags = dl_flags; + sess->flags = dl_flags; if (dm && !dm->head_timeout) sess->server_only_understand_get = 1; - sess->user_proc = user_io; - sess->usr_cbk = usr_cbk; - sess->creds = NULL; - sess->dm = dm; + sess->user_proc = user_io; + sess->usr_cbk = usr_cbk; + sess->creds = NULL; + sess->dm = dm; sess->disable_cache = dm->disable_cache; - assert( dm ); - - *e = gf_dm_sess_setup_from_url(sess, url); - if (*e) { - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("%s:%d gf_dm_sess_new_simple: error=%s at setup for '%s'\n", __FILE__, __LINE__, gf_error_to_string(*e), url)); - gf_dm_sess_del(sess); - return NULL; - } - assert( sess ); - sess->num_retry = SESSION_RETRY_COUNT; + assert( dm ); + + *e = gf_dm_sess_setup_from_url(sess, url); + if (*e) { + GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("%s:%d gf_dm_sess_new_simple: error=%s at setup for '%s'\n", __FILE__, __LINE__, gf_error_to_string(*e), url)); + gf_dm_sess_del(sess); + return NULL; + } + assert( sess ); + sess->num_retry = SESSION_RETRY_COUNT; /*threaded session must be started with gf_dm_sess_process*/ - return sess; + return sess; } GF_EXPORT @@ -1102,43 +1104,43 @@ GF_DownloadSession *gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 void *usr_cbk, GF_Err *e) { - GF_DownloadSession *sess; - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("%s:%d gf_dm_sess_new(%s)\n", __FILE__, __LINE__, url)); - *e = GF_OK; - if (gf_dm_is_local(dm, url)) return NULL; - - if (!gf_dm_can_handle_url(dm, url)) { - *e = GF_NOT_SUPPORTED; - return NULL; - } - sess = gf_dm_sess_new_simple(dm, url, dl_flags, user_io, usr_cbk, e); - if (sess) { - sess->dm = dm; - gf_list_add(dm->sessions, sess); - } - return sess; + GF_DownloadSession *sess; + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("%s:%d gf_dm_sess_new(%s)\n", __FILE__, __LINE__, url)); + *e = GF_OK; + if (gf_dm_is_local(dm, url)) return NULL; + + if (!gf_dm_can_handle_url(dm, url)) { + *e = GF_NOT_SUPPORTED; + return NULL; + } + sess = gf_dm_sess_new_simple(dm, url, dl_flags, user_io, usr_cbk, e); + if (sess) { + sess->dm = dm; + gf_list_add(dm->sessions, sess); + } + return sess; } static GF_Err gf_dm_read_data(GF_DownloadSession *sess, char *data, u32 data_size, u32 *out_read) { - GF_Err e; + GF_Err e; if (!sess) - return GF_BAD_PARAM; + return GF_BAD_PARAM; #ifdef GPAC_HAS_SSL - if (sess->ssl) { - s32 size = SSL_read(sess->ssl, data, data_size); - if (size < 0) + if (sess->ssl) { + s32 size = SSL_read(sess->ssl, data, data_size); + if (size < 0) e = GF_IO_ERR; - else if (!size) + else if (!size) e = GF_IP_NETWORK_EMPTY; else { e = GF_OK; - data[size] = 0; - *out_read = size; + data[size] = 0; + *out_read = size; } - return e; - } + return e; + } #endif @@ -1151,15 +1153,15 @@ static GF_Err gf_dm_read_data(GF_DownloadSession *sess, char *data, u32 data_siz } #endif - if (!sess->sock) - return GF_NETIO_DISCONNECTED; - e = gf_sk_receive(sess->sock, data, data_size, 0, out_read); + if (!sess->sock) + return GF_NETIO_DISCONNECTED; + e = gf_sk_receive(sess->sock, data, data_size, 0, out_read); - if (e==GF_IP_NETWORK_EMPTY) { + if (e==GF_IP_NETWORK_EMPTY) { gf_sleep(1); } - return e; + return e; } @@ -1169,7 +1171,7 @@ static GF_Err gf_dm_read_data(GF_DownloadSession *sess, char *data, u32 data_siz static Bool rfc2818_match(const char *pattern, const char *string) { - char c, d; + char c, d; u32 i=0, k=0; while (1) { c = LWR(pattern[i]); @@ -1183,13 +1185,13 @@ static Bool rfc2818_match(const char *pattern, const char *string) } /*look for same c character*/ while (1) { - d = LWR(string[k]); + d = LWR(string[k]); if (d == '\0') break; /*matched c character, check following substrings*/ - if ((d == c) && rfc2818_match (&pattern[i], &string[k])) - return 1; - else if (d == '.') - return 0; + if ((d == c) && rfc2818_match (&pattern[i], &string[k])) + return 1; + else if (d == '.') + return 0; k++; } @@ -1209,65 +1211,65 @@ static Bool rfc2818_match(const char *pattern, const char *string) static void gf_dm_connect(GF_DownloadSession *sess) { - GF_Err e; - u16 proxy_port = 0; - const char *proxy, *ip; - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("gf_dm_connect"":%d\n", __LINE__)); - if (!sess->sock) { - sess->num_retry = 40; - sess->sock = gf_sk_new(GF_SOCK_TYPE_TCP); - } - - /*connect*/ - sess->status = GF_NETIO_SETUP; - gf_dm_sess_notify_state(sess, sess->status, GF_OK); - - /*PROXY setup*/ - if (sess->proxy_enabled!=2 && sess->dm && sess->dm->cfg) { - proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Enabled"); - if (proxy && !strcmp(proxy, "yes")) { - u32 i; - Bool use_proxy=1; - for (i=0; idm->skip_proxy_servers); i++) { - char *skip = gf_list_get(sess->dm->skip_proxy_servers, i); - if (!strcmp(skip, sess->server_name)) { - use_proxy=0; - break; - } - } - if (use_proxy) { - proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Port"); - proxy_port = proxy ? atoi(proxy) : 80; - proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Name"); - sess->proxy_enabled = 1; - } else { - proxy = NULL; - } - } else { - proxy = NULL; - sess->proxy_enabled = 0; - } - } else { - proxy = NULL; - } - - - if (sess->dm && sess->dm->cfg) { - ip = gf_cfg_get_key(sess->dm->cfg, "Network", "MobileIPEnabled"); - if (ip && !strcmp(ip, "yes")) { - ip = gf_cfg_get_key(sess->dm->cfg, "Network", "MobileIP"); - } else { - ip = NULL; - } - } else { - ip = NULL; - } - - if (!proxy) { - proxy = sess->server_name; - proxy_port = sess->port; - } - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Connecting to %s:%d\n", proxy, proxy_port)); + GF_Err e; + u16 proxy_port = 0; + const char *proxy, *ip; + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("gf_dm_connect"":%d\n", __LINE__)); + if (!sess->sock) { + sess->num_retry = 40; + sess->sock = gf_sk_new(GF_SOCK_TYPE_TCP); + } + + /*connect*/ + sess->status = GF_NETIO_SETUP; + gf_dm_sess_notify_state(sess, sess->status, GF_OK); + + /*PROXY setup*/ + if (sess->proxy_enabled!=2 && sess->dm && sess->dm->cfg) { + proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Enabled"); + if (proxy && !strcmp(proxy, "yes")) { + u32 i; + Bool use_proxy=1; + for (i=0; idm->skip_proxy_servers); i++) { + char *skip = gf_list_get(sess->dm->skip_proxy_servers, i); + if (!strcmp(skip, sess->server_name)) { + use_proxy=0; + break; + } + } + if (use_proxy) { + proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Port"); + proxy_port = proxy ? atoi(proxy) : 80; + proxy = gf_cfg_get_key(sess->dm->cfg, "HTTPProxy", "Name"); + sess->proxy_enabled = 1; + } else { + proxy = NULL; + } + } else { + proxy = NULL; + sess->proxy_enabled = 0; + } + } else { + proxy = NULL; + } + + + if (sess->dm && sess->dm->cfg) { + ip = gf_cfg_get_key(sess->dm->cfg, "Network", "MobileIPEnabled"); + if (ip && !strcmp(ip, "yes")) { + ip = gf_cfg_get_key(sess->dm->cfg, "Network", "MobileIP"); + } else { + ip = NULL; + } + } else { + ip = NULL; + } + + if (!proxy) { + proxy = sess->server_name; + proxy_port = sess->port; + } + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Connecting to %s:%d\n", proxy, proxy_port)); if (sess->status == GF_NETIO_SETUP) { e = gf_sk_connect(sess->sock, (char *) proxy, proxy_port, (char *)ip); @@ -1287,45 +1289,45 @@ static void gf_dm_connect(GF_DownloadSession *sess) return; } - sess->status = GF_NETIO_CONNECTED; + sess->status = GF_NETIO_CONNECTED; gf_dm_sess_notify_state(sess, GF_NETIO_CONNECTED, GF_OK); gf_sk_set_buffer_size(sess->sock, 1, GF_DOWNLOAD_BUFFER_SIZE); gf_sk_set_buffer_size(sess->sock, 0, GF_DOWNLOAD_BUFFER_SIZE); } #ifdef GPAC_HAS_SSL - if (!sess->ssl && (sess->flags & GF_DOWNLOAD_SESSION_USE_SSL)) { - if (!sess->dm->ssl_ctx) - ssl_init(sess->dm, 0); - /*socket is connected, configure SSL layer*/ - if (sess->dm->ssl_ctx) { - int ret; - long vresult; - char common_name[256]; - X509 *cert; - Bool success = 1; + if (!sess->ssl && (sess->flags & GF_DOWNLOAD_SESSION_USE_SSL)) { + if (!sess->dm->ssl_ctx) + ssl_init(sess->dm, 0); + /*socket is connected, configure SSL layer*/ + if (sess->dm->ssl_ctx) { + int ret; + long vresult; + char common_name[256]; + X509 *cert; + Bool success = 1; sess->ssl = SSL_new(sess->dm->ssl_ctx); - SSL_set_fd(sess->ssl, gf_sk_get_handle(sess->sock)); - SSL_set_connect_state(sess->ssl); - ret = SSL_connect(sess->ssl); - assert(ret>0); - - cert = SSL_get_peer_certificate(sess->ssl); - /*if we have a cert, check it*/ - if (cert) { - SSL_set_verify_result(sess->ssl, 0); - vresult = SSL_get_verify_result(sess->ssl); - + SSL_set_fd(sess->ssl, gf_sk_get_handle(sess->sock)); + SSL_set_connect_state(sess->ssl); + ret = SSL_connect(sess->ssl); + assert(ret>0); + + cert = SSL_get_peer_certificate(sess->ssl); + /*if we have a cert, check it*/ + if (cert) { + SSL_set_verify_result(sess->ssl, 0); + vresult = SSL_get_verify_result(sess->ssl); + if (vresult == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[SSL] Cannot locate issuer's certificate on the local system, will not attempt to validate\n")); + GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[SSL] Cannot locate issuer's certificate on the local system, will not attempt to validate\n")); SSL_set_verify_result(sess->ssl, 0); - vresult = SSL_get_verify_result(sess->ssl); + vresult = SSL_get_verify_result(sess->ssl); } if (vresult == X509_V_OK) { - common_name[0] = 0; - X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, common_name, sizeof (common_name)); + common_name[0] = 0; + X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, common_name, sizeof (common_name)); if (!rfc2818_match(common_name, sess->server_name)) { success = 0; GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[SSL] Mismatch in certificate names: got %s expected %s\n", common_name, sess->server_name)); @@ -1335,96 +1337,96 @@ static void gf_dm_connect(GF_DownloadSession *sess) GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[SSL] Error verifying certificate %x\n", vresult)); } - X509_free(cert); - - if (!success) { - gf_dm_disconnect(sess, 1); - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = GF_AUTHENTICATION_FAILURE; - gf_dm_sess_notify_state(sess, sess->status, sess->last_error); - } - } - } - } + X509_free(cert); + + if (!success) { + gf_dm_disconnect(sess, 1); + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = GF_AUTHENTICATION_FAILURE; + gf_dm_sess_notify_state(sess, sess->status, sess->last_error); + } + } + } + } #endif /*this should be done when building HTTP GET request in case we have range directives*/ - gf_dm_configure_cache(sess); + gf_dm_configure_cache(sess); } DownloadedCacheEntry gf_dm_refresh_cache_entry(GF_DownloadSession *sess) { - Bool go; - u32 timer = 0; - u32 flags = sess->flags; - sess->flags |= GF_NETIO_SESSION_NOT_CACHED; - go = 1; - while (go) { - switch (sess->status) { - /*setup download*/ - case GF_NETIO_SETUP: - gf_dm_connect(sess); - if (sess->status == GF_NETIO_SETUP) - gf_sleep(16); - break; - case GF_NETIO_WAIT_FOR_REPLY: - if (timer == 0) - timer = gf_sys_clock(); - gf_sleep(16); - { - u32 timer2 = gf_sys_clock(); - if (timer2 - timer > 5000) { - GF_Err e; - /* Since HEAD is not understood by this server, we use a GET instead */ - sess->http_read_type = GET; - sess->flags |= GF_NETIO_SESSION_NOT_CACHED; - gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_SETUP; - sess->server_only_understand_get = 1; - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("gf_dm_refresh_cache_entry() : Timeout with HEAD, try with GET\n")); - e = gf_dm_sess_setup_from_url(sess, sess->orig_url); - if (e) { - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("gf_dm_refresh_cache_entry() : Error with GET %d\n", e)); - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - } else { - timer = 0; - continue; - } - } - } - case GF_NETIO_CONNECTED: - sess->do_requests(sess); - break; - case GF_NETIO_DATA_EXCHANGE: - case GF_NETIO_DISCONNECTED: - case GF_NETIO_STATE_ERROR: - go = 0; - break; - default: - break; - } - } - sess->flags = flags; - if (sess->status==GF_NETIO_STATE_ERROR) return NULL; - return sess->cache_entry; + Bool go; + u32 timer = 0; + u32 flags = sess->flags; + sess->flags |= GF_NETIO_SESSION_NOT_CACHED; + go = 1; + while (go) { + switch (sess->status) { + /*setup download*/ + case GF_NETIO_SETUP: + gf_dm_connect(sess); + if (sess->status == GF_NETIO_SETUP) + gf_sleep(16); + break; + case GF_NETIO_WAIT_FOR_REPLY: + if (timer == 0) + timer = gf_sys_clock(); + gf_sleep(16); + { + u32 timer2 = gf_sys_clock(); + if (timer2 - timer > 5000) { + GF_Err e; + /* Since HEAD is not understood by this server, we use a GET instead */ + sess->http_read_type = GET; + sess->flags |= GF_NETIO_SESSION_NOT_CACHED; + gf_dm_disconnect(sess, 0); + sess->status = GF_NETIO_SETUP; + sess->server_only_understand_get = 1; + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("gf_dm_refresh_cache_entry() : Timeout with HEAD, try with GET\n")); + e = gf_dm_sess_setup_from_url(sess, sess->orig_url); + if (e) { + GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("gf_dm_refresh_cache_entry() : Error with GET %d\n", e)); + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + } else { + timer = 0; + continue; + } + } + } + case GF_NETIO_CONNECTED: + sess->do_requests(sess); + break; + case GF_NETIO_DATA_EXCHANGE: + case GF_NETIO_DISCONNECTED: + case GF_NETIO_STATE_ERROR: + go = 0; + break; + default: + break; + } + } + sess->flags = flags; + if (sess->status==GF_NETIO_STATE_ERROR) return NULL; + return sess->cache_entry; } GF_EXPORT const char *gf_dm_sess_mime_type(GF_DownloadSession *sess) { - DownloadedCacheEntry entry; - if (sess->cache_entry) { - const char * oldMimeIfAny = gf_cache_get_mime_type(sess->cache_entry); - if (oldMimeIfAny) - return oldMimeIfAny; - } - entry = gf_dm_refresh_cache_entry (sess); - if (!entry) + DownloadedCacheEntry entry; + if (sess->cache_entry) { + const char * oldMimeIfAny = gf_cache_get_mime_type(sess->cache_entry); + if (oldMimeIfAny) + return oldMimeIfAny; + } + entry = gf_dm_refresh_cache_entry (sess); + if (!entry) return sess->mime_type; - assert( entry == sess->cache_entry && entry); - return gf_cache_get_mime_type( sess->cache_entry ); + assert( entry == sess->cache_entry && entry); + return gf_cache_get_mime_type( sess->cache_entry ); } GF_EXPORT @@ -1433,7 +1435,7 @@ GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_r if (!sess) return GF_BAD_PARAM; if (sess->cache_entry) { if (!discontinue_cache) { - if (gf_cache_get_end_range(sess->cache_entry) + 1 != start_range) + if (gf_cache_get_end_range(sess->cache_entry) + 1 != start_range) return GF_NOT_SUPPORTED; } if (!sess->sock) @@ -1444,7 +1446,7 @@ GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_r } } sess->status = GF_NETIO_CONNECTED; - sess->num_retry = SESSION_RETRY_COUNT; + sess->num_retry = SESSION_RETRY_COUNT; if (!discontinue_cache) { gf_cache_set_end_range(sess->cache_entry, end_range); /*remember this in case we get disconnected*/ @@ -1458,14 +1460,14 @@ GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_r } sess->range_start = start_range; sess->range_end = end_range; - sess->needs_range = 1; + sess->needs_range = 1; return GF_OK; } GF_EXPORT GF_Err gf_dm_sess_process(GF_DownloadSession *sess) { - Bool go; + Bool go; /*if session is threaded, start thread*/ if (! (sess->flags & GF_NETIO_SESSION_NOT_THREADED)) { @@ -1481,69 +1483,69 @@ GF_Err gf_dm_sess_process(GF_DownloadSession *sess) return GF_OK; } /*otherwise do a synchronous download*/ - go = 1; - while (go) { - switch (sess->status) { - /*setup download*/ - case GF_NETIO_SETUP: - gf_dm_connect(sess); - if (sess->status == GF_NETIO_SETUP) - gf_sleep(16); - break; - case GF_NETIO_WAIT_FOR_REPLY: - gf_sleep(16); - case GF_NETIO_CONNECTED: - case GF_NETIO_DATA_EXCHANGE: - sess->do_requests(sess); - break; - case GF_NETIO_DISCONNECTED: - case GF_NETIO_STATE_ERROR: - go = 0; - break; - default: - break; - } - } - return sess->last_error; + go = 1; + while (go) { + switch (sess->status) { + /*setup download*/ + case GF_NETIO_SETUP: + gf_dm_connect(sess); + if (sess->status == GF_NETIO_SETUP) + gf_sleep(16); + break; + case GF_NETIO_WAIT_FOR_REPLY: + gf_sleep(16); + case GF_NETIO_CONNECTED: + case GF_NETIO_DATA_EXCHANGE: + sess->do_requests(sess); + break; + case GF_NETIO_DISCONNECTED: + case GF_NETIO_STATE_ERROR: + go = 0; + break; + default: + break; + } + } + return sess->last_error; } GF_EXPORT GF_Err gf_dm_sess_process_headers(GF_DownloadSession *sess) { - Bool go; - go = 1; - while (go) { - switch (sess->status) { - /*setup download*/ - case GF_NETIO_SETUP: - gf_dm_connect(sess); - if (sess->status == GF_NETIO_SETUP) - gf_sleep(16); - break; - case GF_NETIO_WAIT_FOR_REPLY: + Bool go; + go = 1; + while (go) { + switch (sess->status) { + /*setup download*/ + case GF_NETIO_SETUP: + gf_dm_connect(sess); + if (sess->status == GF_NETIO_SETUP) + gf_sleep(16); + break; + case GF_NETIO_WAIT_FOR_REPLY: // gf_sleep(16); - gf_sleep(1); - case GF_NETIO_CONNECTED: - sess->do_requests(sess); - break; + gf_sleep(1); + case GF_NETIO_CONNECTED: + sess->do_requests(sess); + break; case GF_NETIO_DATA_EXCHANGE: - case GF_NETIO_DISCONNECTED: - case GF_NETIO_STATE_ERROR: - go = 0; - break; - default: - break; - } - } - return sess->last_error; + case GF_NETIO_DISCONNECTED: + case GF_NETIO_STATE_ERROR: + go = 0; + break; + default: + break; + } + } + return sess->last_error; } static Bool gf_dm_needs_to_delete_cache(GF_DownloadManager * dm) { - const char * opt; - if (!dm || !dm->cfg) - return 0; - opt = gf_cfg_get_key(dm->cfg, "Downloader", "CleanCache"); - return opt && (!strncmp("yes", opt, 3) || !strncmp("true", opt, 4) || !strncmp("1", opt, 1)); + const char * opt; + if (!dm || !dm->cfg) + return 0; + opt = gf_cfg_get_key(dm->cfg, "Downloader", "CleanCache"); + return opt && (!strncmp("yes", opt, 3) || !strncmp("true", opt, 4) || !strncmp("1", opt, 1)); } #ifdef BUGGY_gf_cache_cleanup_cache @@ -1558,9 +1560,9 @@ static Bool gf_dm_needs_to_delete_cache(GF_DownloadManager * dm) { * \param dm The GF_DownloadManager */ static void gf_cache_cleanup_cache(GF_DownloadManager * dm) { - if (gf_dm_needs_to_delete_cache(dm)) { - gf_cache_delete_all_cached_files(dm->cache_directory); - } + if (gf_dm_needs_to_delete_cache(dm)) { + gf_cache_delete_all_cached_files(dm->cache_directory); + } } #endif @@ -1568,35 +1570,35 @@ static void gf_cache_cleanup_cache(GF_DownloadManager * dm) { GF_EXPORT GF_DownloadManager *gf_dm_new(GF_Config *cfg) { - const char *opt; - char * default_cache_dir; - GF_DownloadManager *dm; - GF_SAFEALLOC(dm, GF_DownloadManager); - dm->sessions = gf_list_new(); - dm->cache_entries = gf_list_new(); - dm->credentials = gf_list_new(); - dm->skip_proxy_servers = gf_list_new(); - dm->partial_downloads = gf_list_new(); - dm->cfg = cfg; - dm->cache_mx = gf_mx_new("download_manager_cache_mx"); - default_cache_dir = NULL; - gf_mx_p( dm->cache_mx ); - if (cfg) - opt = gf_cfg_get_key(cfg, "General", "CacheDirectory"); - else - opt = NULL; - if (!opt) { - default_cache_dir = gf_get_default_cache_directory(); - opt = default_cache_dir; - } - if (opt[strlen(opt)-1] != GF_PATH_SEPARATOR) { - dm->cache_directory = (char *) gf_malloc(sizeof(char)* (strlen(opt)+2)); - sprintf(dm->cache_directory, "%s%c", opt, GF_PATH_SEPARATOR); - } else { - dm->cache_directory = gf_strdup(opt); - - } - + const char *opt; + char * default_cache_dir; + GF_DownloadManager *dm; + GF_SAFEALLOC(dm, GF_DownloadManager); + dm->sessions = gf_list_new(); + dm->cache_entries = gf_list_new(); + dm->credentials = gf_list_new(); + dm->skip_proxy_servers = gf_list_new(); + dm->partial_downloads = gf_list_new(); + dm->cfg = cfg; + dm->cache_mx = gf_mx_new("download_manager_cache_mx"); + default_cache_dir = NULL; + gf_mx_p( dm->cache_mx ); + if (cfg) + opt = gf_cfg_get_key(cfg, "General", "CacheDirectory"); + else + opt = NULL; + if (!opt) { + default_cache_dir = gf_get_default_cache_directory(); + opt = default_cache_dir; + } + if (opt[strlen(opt)-1] != GF_PATH_SEPARATOR) { + dm->cache_directory = (char *) gf_malloc(sizeof(char)* (strlen(opt)+2)); + sprintf(dm->cache_directory, "%s%c", opt, GF_PATH_SEPARATOR); + } else { + dm->cache_directory = gf_strdup(opt); + + } + opt = cfg ? gf_cfg_get_key(cfg, "Downloader", "MaxRate") : NULL; /*use it in in BYTES per second*/ if (opt) dm->limit_data_rate = 1000 * atoi(opt) / 8; @@ -1609,117 +1611,117 @@ GF_DownloadManager *gf_dm_new(GF_Config *cfg) dm->head_timeout = 5000; if (cfg) { - opt = gf_cfg_get_key(cfg, "Downloader", "HTTPHeadTimeout"); + opt = gf_cfg_get_key(cfg, "Downloader", "HTTPHeadTimeout"); if (opt) { dm->head_timeout = atoi(opt); } } dm->request_timeout = 20000; if (cfg) { - opt = gf_cfg_get_key(cfg, "Downloader", "HTTPRequestTimeout"); + opt = gf_cfg_get_key(cfg, "Downloader", "HTTPRequestTimeout"); if (opt) { dm->request_timeout = atoi(opt); } } - gf_mx_v( dm->cache_mx ); - if (default_cache_dir) - gf_free(default_cache_dir); + gf_mx_v( dm->cache_mx ); + if (default_cache_dir) + gf_free(default_cache_dir); #ifdef GPAC_HAS_SSL - dm->ssl_ctx = NULL; + dm->ssl_ctx = NULL; #endif - /* TODO: Not ready for now, we should find a locking strategy between several GPAC instances... - * gf_cache_cleanup_cache(dm); - */ - return dm; + /* TODO: Not ready for now, we should find a locking strategy between several GPAC instances... + * gf_cache_cleanup_cache(dm); + */ + return dm; } void gf_dm_set_auth_callback(GF_DownloadManager *dm, Bool (*GetUserPassword)(void *usr_cbk, const char *site_url, char *usr_name, char *password), void *usr_cbk) { - if (dm) { - dm->GetUserPassword = GetUserPassword; - dm->usr_cbk = usr_cbk; - } + if (dm) { + dm->GetUserPassword = GetUserPassword; + dm->usr_cbk = usr_cbk; + } } GF_EXPORT void gf_dm_del(GF_DownloadManager *dm) { - if (!dm) - return; - assert( dm->sessions); - assert( dm->cache_mx ); - gf_mx_p( dm->cache_mx ); - - while (gf_list_count(dm->partial_downloads)) { - GF_PartialDownload * entry = gf_list_get( dm->partial_downloads, 0); - gf_list_rem( dm->partial_downloads, 0); - assert( entry->filename ); - gf_delete_file( entry->filename ); - gf_free(entry->filename ); - entry->filename = NULL; - entry->url = NULL; - gf_free( entry ); - } - - /*destroy all pending sessions*/ - while (gf_list_count(dm->sessions)) { - GF_DownloadSession *sess = (GF_DownloadSession *) gf_list_get(dm->sessions, 0); - gf_dm_sess_del(sess); - } - gf_list_del(dm->sessions); - dm->sessions = NULL; - assert( dm->skip_proxy_servers ); - while (gf_list_count(dm->skip_proxy_servers)) { - char *serv = gf_list_get(dm->skip_proxy_servers, 0); - gf_list_rem(dm->skip_proxy_servers, 0); - gf_free(serv); - } - gf_list_del(dm->skip_proxy_servers); - dm->skip_proxy_servers = NULL; - assert( dm->credentials); - while (gf_list_count(dm->credentials)) { - gf_user_credentials_struct * cred = gf_list_get( dm->credentials, 0); - gf_list_rem( dm->credentials, 0); - gf_free( cred ); - } - gf_list_del( dm->credentials); - dm->credentials = NULL; - assert( dm->cache_entries ); - { - /* Deletes DownloadedCacheEntry and associated files if required */ - Bool delete_my_files = gf_dm_needs_to_delete_cache(dm); - while (gf_list_count(dm->cache_entries)) { - const DownloadedCacheEntry entry = gf_list_get( dm->cache_entries, 0); - gf_list_rem( dm->cache_entries, 0); - if (delete_my_files) - gf_cache_entry_set_delete_files_when_deleted(entry); - gf_cache_delete_entry(entry); - } - gf_list_del( dm->cache_entries ); - dm->cache_entries = NULL; - } - - gf_list_del( dm->partial_downloads ); - dm->partial_downloads = NULL; - /* TODO: Not ready for now, we should find a locking strategy between several GPAC instances... - * gf_cache_cleanup_cache(dm); - */ - if (dm->cache_directory) - gf_free(dm->cache_directory); - dm->cache_directory = NULL; + if (!dm) + return; + assert( dm->sessions); + assert( dm->cache_mx ); + gf_mx_p( dm->cache_mx ); + + while (gf_list_count(dm->partial_downloads)) { + GF_PartialDownload * entry = gf_list_get( dm->partial_downloads, 0); + gf_list_rem( dm->partial_downloads, 0); + assert( entry->filename ); + gf_delete_file( entry->filename ); + gf_free(entry->filename ); + entry->filename = NULL; + entry->url = NULL; + gf_free( entry ); + } + + /*destroy all pending sessions*/ + while (gf_list_count(dm->sessions)) { + GF_DownloadSession *sess = (GF_DownloadSession *) gf_list_get(dm->sessions, 0); + gf_dm_sess_del(sess); + } + gf_list_del(dm->sessions); + dm->sessions = NULL; + assert( dm->skip_proxy_servers ); + while (gf_list_count(dm->skip_proxy_servers)) { + char *serv = gf_list_get(dm->skip_proxy_servers, 0); + gf_list_rem(dm->skip_proxy_servers, 0); + gf_free(serv); + } + gf_list_del(dm->skip_proxy_servers); + dm->skip_proxy_servers = NULL; + assert( dm->credentials); + while (gf_list_count(dm->credentials)) { + gf_user_credentials_struct * cred = gf_list_get( dm->credentials, 0); + gf_list_rem( dm->credentials, 0); + gf_free( cred ); + } + gf_list_del( dm->credentials); + dm->credentials = NULL; + assert( dm->cache_entries ); + { + /* Deletes DownloadedCacheEntry and associated files if required */ + Bool delete_my_files = gf_dm_needs_to_delete_cache(dm); + while (gf_list_count(dm->cache_entries)) { + const DownloadedCacheEntry entry = gf_list_get( dm->cache_entries, 0); + gf_list_rem( dm->cache_entries, 0); + if (delete_my_files) + gf_cache_entry_set_delete_files_when_deleted(entry); + gf_cache_delete_entry(entry); + } + gf_list_del( dm->cache_entries ); + dm->cache_entries = NULL; + } + + gf_list_del( dm->partial_downloads ); + dm->partial_downloads = NULL; + /* TODO: Not ready for now, we should find a locking strategy between several GPAC instances... + * gf_cache_cleanup_cache(dm); + */ + if (dm->cache_directory) + gf_free(dm->cache_directory); + dm->cache_directory = NULL; #ifdef GPAC_HAS_SSL - if (dm->ssl_ctx) SSL_CTX_free(dm->ssl_ctx); + if (dm->ssl_ctx) SSL_CTX_free(dm->ssl_ctx); #endif - /* Stored elsewhere, no need to free */ - dm->cfg = NULL; - gf_mx_v( dm->cache_mx ); - gf_mx_del( dm->cache_mx); - dm->cache_mx = NULL; - gf_free(dm); + /* Stored elsewhere, no need to free */ + dm->cfg = NULL; + gf_mx_v( dm->cache_mx ); + gf_mx_del( dm->cache_mx); + dm->cache_mx = NULL; + gf_free(dm); } /*! @@ -1732,55 +1734,55 @@ void gf_dm_del(GF_DownloadManager *dm) * \param nbBytes The number of bytes contained into data */ static void gf_icy_skip_data(GF_DownloadSession * sess, u32 icy_metaint, const char * data, u32 nbBytes) { - assert( icy_metaint > 0 ); - while (nbBytes) { - if (sess->icy_bytes == icy_metaint) { - sess->icy_count = 1 + 16* (u8) data[0]; - /*skip icy metadata*/ - if (sess->icy_count > nbBytes) { - sess->icy_count -= nbBytes; - nbBytes = 0; - } else { - if (sess->icy_count > 1) { - GF_NETIO_Parameter par; - char szData[4096]; - memset(szData, 0, 4096); - memcpy(szData, data+1, sess->icy_count-1); - szData[sess->icy_count] = 0; - - par.error = 0; - par.msg_type = GF_NETIO_PARSE_HEADER; - par.name = "icy-meta"; - par.value = szData; + assert( icy_metaint > 0 ); + while (nbBytes) { + if (sess->icy_bytes == icy_metaint) { + sess->icy_count = 1 + 16* (u8) data[0]; + /*skip icy metadata*/ + if (sess->icy_count > nbBytes) { + sess->icy_count -= nbBytes; + nbBytes = 0; + } else { + if (sess->icy_count > 1) { + GF_NETIO_Parameter par; + char szData[4096]; + memset(szData, 0, 4096); + memcpy(szData, data+1, sess->icy_count-1); + szData[sess->icy_count] = 0; + + par.error = 0; + par.msg_type = GF_NETIO_PARSE_HEADER; + par.name = "icy-meta"; + par.value = szData; par.sess = sess; - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[ICY] Found metainfo in stream=%s, (every %d bytes)\n", szData, icy_metaint)); - gf_dm_sess_user_io(sess, &par); - } - nbBytes -= sess->icy_count; - data += sess->icy_count; - sess->icy_count = 0; - sess->icy_bytes = 0; - } - } else { - GF_NETIO_Parameter par; - u32 left = icy_metaint - sess->icy_bytes; - if (left > nbBytes) { - left = nbBytes; - sess->icy_bytes += left; - nbBytes = 0; - } else { - sess->icy_bytes = icy_metaint; - nbBytes -= left; - } - - par.msg_type = GF_NETIO_DATA_EXCHANGE; - par.data = data; - par.size = left; - gf_dm_sess_user_io(sess, &par); - - data += left; - } - } + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[ICY] Found metainfo in stream=%s, (every %d bytes)\n", szData, icy_metaint)); + gf_dm_sess_user_io(sess, &par); + } + nbBytes -= sess->icy_count; + data += sess->icy_count; + sess->icy_count = 0; + sess->icy_bytes = 0; + } + } else { + GF_NETIO_Parameter par; + u32 left = icy_metaint - sess->icy_bytes; + if (left > nbBytes) { + left = nbBytes; + sess->icy_bytes += left; + nbBytes = 0; + } else { + sess->icy_bytes = icy_metaint; + nbBytes -= left; + } + + par.msg_type = GF_NETIO_DATA_EXCHANGE; + par.data = data; + par.size = left; + gf_dm_sess_user_io(sess, &par); + + data += left; + } + } } @@ -1801,7 +1803,7 @@ static char *gf_dm_get_chunk_data(GF_DownloadSession *sess, char *body_start, u3 *header_size = 0; return body_start; } - + te_header = strstr((char *) body_start, "\r\n"); if (!te_header) return NULL; @@ -1816,7 +1818,7 @@ static char *gf_dm_get_chunk_data(GF_DownloadSession *sess, char *body_start, u3 *payload_size = size; GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Chunk Start: Header \"%s\" - header size %d - payload size %d\n", body_start, 2+strlen(body_start), size)); - + te_header[0] = '\r'; return te_header+2; } @@ -1826,8 +1828,8 @@ static GFINLINE void gf_dm_data_received(GF_DownloadSession *sess, u8 *payload, u32 nbBytes, hdr_size, remaining; u8 *data; Bool flush_chunk = 0; - GF_NETIO_Parameter par; - u32 runtime, rcv; + GF_NETIO_Parameter par; + u32 runtime, rcv; nbBytes = payload_size; hdr_size = 0; @@ -1836,7 +1838,7 @@ static GFINLINE void gf_dm_data_received(GF_DownloadSession *sess, u8 *payload, data = (u8 *) gf_dm_get_chunk_data(sess, (char *) payload, &nbBytes, &hdr_size); if (hdr_size + nbBytes + 2 > payload_size) { remaining = nbBytes + 2 - payload_size + hdr_size; - nbBytes = payload_size - hdr_size; + nbBytes = payload_size - hdr_size; payload_size = 0; payload = NULL; } else { @@ -1896,19 +1898,19 @@ static GFINLINE void gf_dm_data_received(GF_DownloadSession *sess, u8 *payload, } if (sess->total_size && (sess->bytes_done == sess->total_size)) { - gf_dm_disconnect(sess, 0); - par.msg_type = GF_NETIO_DATA_TRANSFERED; - par.error = GF_OK; + gf_dm_disconnect(sess, 0); + par.msg_type = GF_NETIO_DATA_TRANSFERED; + par.error = GF_OK; + - gf_dm_sess_user_io(sess, &par); - if (sess->use_cache_file) { - gf_cache_close_write_cache(sess->cache_entry, sess, 1); - GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, - ("[CACHE] url %s saved as %s\n", gf_cache_get_url(sess->cache_entry), gf_cache_get_cache_filename(sess->cache_entry))); - } + if (sess->use_cache_file) { + gf_cache_close_write_cache(sess->cache_entry, sess, 1); + GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, + ("[CACHE] url %s saved as %s\n", gf_cache_get_url(sess->cache_entry), gf_cache_get_cache_filename(sess->cache_entry))); + } GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] url %s downloaded in %d ms (%d kbps)\n", gf_cache_get_url(sess->cache_entry), gf_sys_clock() - sess->start_time, 8*sess->bytes_per_sec/1024 )); - } + } if (rewrite_size && sess->chunked) { //use memmove since regions overlap @@ -1928,127 +1930,127 @@ static GFINLINE void gf_dm_data_received(GF_DownloadSession *sess, u8 *payload, GF_EXPORT GF_Err gf_dm_sess_fetch_data(GF_DownloadSession *sess, char *buffer, u32 buffer_size, u32 *read_size) { - u32 size; - GF_Err e; - if (/*sess->cache || */ !buffer || !buffer_size) return GF_BAD_PARAM; - if (sess->th) return GF_BAD_PARAM; - if (sess->status == GF_NETIO_DISCONNECTED) return GF_EOS; - if (sess->status > GF_NETIO_DATA_TRANSFERED) return GF_BAD_PARAM; - - *read_size = 0; - if (sess->status == GF_NETIO_DATA_TRANSFERED) return GF_EOS; - - if (sess->status == GF_NETIO_SETUP) { - gf_dm_connect(sess); + u32 size; + GF_Err e; + if (/*sess->cache || */ !buffer || !buffer_size) return GF_BAD_PARAM; + if (sess->th) return GF_BAD_PARAM; + if (sess->status == GF_NETIO_DISCONNECTED) return GF_EOS; + if (sess->status > GF_NETIO_DATA_TRANSFERED) return GF_BAD_PARAM; + + *read_size = 0; + if (sess->status == GF_NETIO_DATA_TRANSFERED) return GF_EOS; + + if (sess->status == GF_NETIO_SETUP) { + gf_dm_connect(sess); if (sess->last_error) return sess->last_error; - return GF_OK; - } else if (sess->status < GF_NETIO_DATA_EXCHANGE) { - sess->do_requests(sess); + return GF_OK; + } else if (sess->status < GF_NETIO_DATA_EXCHANGE) { + sess->do_requests(sess); return sess->last_error; - } - /*we're running but we had data previously*/ - if (sess->init_data) { - if (sess->init_data_size<=buffer_size) { - memcpy(buffer, sess->init_data, sizeof(char)*sess->init_data_size); - *read_size = sess->init_data_size; - gf_free(sess->init_data); - sess->init_data = NULL; - sess->init_data_size = 0; - } else { - memcpy(buffer, sess->init_data, sizeof(char)*buffer_size); - *read_size = buffer_size; - sess->init_data_size -= buffer_size; - memcpy(sess->init_data, sess->init_data+buffer_size, sizeof(char)*sess->init_data_size); - } - return GF_OK; - } - - e = gf_dm_read_data(sess, buffer, buffer_size, read_size); - if (e) return e; - size = *read_size; - *read_size = 0; - gf_dm_data_received(sess, (u8 *) buffer, size, 0, read_size); - return GF_OK; + } + /*we're running but we had data previously*/ + if (sess->init_data) { + if (sess->init_data_size<=buffer_size) { + memcpy(buffer, sess->init_data, sizeof(char)*sess->init_data_size); + *read_size = sess->init_data_size; + gf_free(sess->init_data); + sess->init_data = NULL; + sess->init_data_size = 0; + } else { + memcpy(buffer, sess->init_data, sizeof(char)*buffer_size); + *read_size = buffer_size; + sess->init_data_size -= buffer_size; + memcpy(sess->init_data, sess->init_data+buffer_size, sizeof(char)*sess->init_data_size); + } + return GF_OK; + } + + e = gf_dm_read_data(sess, buffer, buffer_size, read_size); + if (e) return e; + size = *read_size; + *read_size = 0; + gf_dm_data_received(sess, (u8 *) buffer, size, 0, read_size); + return GF_OK; } GF_EXPORT GF_Err gf_dm_sess_get_stats(GF_DownloadSession * sess, const char **server, const char **path, u32 *total_size, u32 *bytes_done, u32 *bytes_per_sec, GF_NetIOStatus *net_status) { - if (!sess) return GF_BAD_PARAM; - if (server) *server = sess->server_name; - if (path) *path = sess->remote_path; + if (!sess) return GF_BAD_PARAM; + if (server) *server = sess->server_name; + if (path) *path = sess->remote_path; if (total_size) { if (sess->total_size==SIZE_IN_STREAM) *total_size = 0; else *total_size = sess->total_size; } - if (bytes_done) *bytes_done = sess->bytes_done; - if (bytes_per_sec) *bytes_per_sec = sess->bytes_per_sec; - if (net_status) *net_status = sess->status; - if (sess->status == GF_NETIO_DISCONNECTED) return GF_EOS; - else if (sess->status == GF_NETIO_STATE_ERROR) return GF_SERVICE_ERROR; - return GF_OK; + if (bytes_done) *bytes_done = sess->bytes_done; + if (bytes_per_sec) *bytes_per_sec = sess->bytes_per_sec; + if (net_status) *net_status = sess->status; + if (sess->status == GF_NETIO_DISCONNECTED) return GF_EOS; + else if (sess->status == GF_NETIO_STATE_ERROR) return GF_SERVICE_ERROR; + return GF_OK; } GF_EXPORT u64 gf_dm_sess_get_utc_start(GF_DownloadSession * sess) { - if (!sess) return 0; + if (!sess) return 0; return sess->start_time_utc; } GF_EXPORT const char *gf_dm_sess_get_cache_name(GF_DownloadSession * sess) { - if (!sess) return NULL; - if (! sess->cache_entry || sess->needs_cache_reconfig) return NULL; - return gf_cache_get_cache_filename(sess->cache_entry); + if (!sess) return NULL; + if (! sess->cache_entry || sess->needs_cache_reconfig) return NULL; + return gf_cache_get_cache_filename(sess->cache_entry); } GF_EXPORT Bool gf_dm_sess_can_be_cached_on_disk(const GF_DownloadSession *sess) { - if (!sess) return 0; - return gf_cache_get_content_length(sess->cache_entry) != 0; + if (!sess) return 0; + return gf_cache_get_content_length(sess->cache_entry) != 0; } GF_EXPORT void gf_dm_sess_abort(GF_DownloadSession * sess) { - assert(sess); - if (sess->mx) { - gf_mx_p(sess->mx); - gf_dm_disconnect(sess, 1); - sess->status = GF_NETIO_STATE_ERROR; - gf_mx_v(sess->mx); - } else { - gf_dm_disconnect(sess, 1); - } + assert(sess); + if (sess->mx) { + gf_mx_p(sess->mx); + gf_dm_disconnect(sess, 1); + sess->status = GF_NETIO_STATE_ERROR; + gf_mx_v(sess->mx); + } else { + gf_dm_disconnect(sess, 1); + } } void *gf_dm_sess_get_private(GF_DownloadSession * sess) { - return sess ? sess->ext : NULL; + return sess ? sess->ext : NULL; } void gf_dm_sess_set_private(GF_DownloadSession * sess, void *private_data) { - if (sess) sess->ext = private_data; + if (sess) sess->ext = private_data; } /* HTTP(S) stuff*/ static GFINLINE u32 http_skip_space(char *val) { - u32 ret = 0; - while (val[ret] == ' ') ret+=1; - return ret; + u32 ret = 0; + while (val[ret] == ' ') ret+=1; + return ret; } static GFINLINE char *http_is_header(char *line, char *header_name) { - char *res; - if (strnicmp(line, header_name, strlen(header_name))) return NULL; - res = line + strlen(header_name); - while ((res[0] == ':') || (res[0] == ' ')) res+=1; - return res; + char *res; + if (strnicmp(line, header_name, strlen(header_name))) return NULL; + res = line + strlen(header_name); + while ((res[0] == ':') || (res[0] == ' ')) res+=1; + return res; } /*! @@ -2058,16 +2060,16 @@ static GFINLINE char *http_is_header(char *line, char *header_name) * \return GF_OK if everything went fine, the error otherwise */ static GF_Err http_send_headers(GF_DownloadSession *sess, char * sHTTP) { - GF_Err e; - GF_NETIO_Parameter par; - char range_buf[1024]; - char pass_buf[1024]; - const char *user_agent; - const char *url; - const char *user_profile; - const char *param_string; - Bool has_accept, has_connection, has_range, has_agent, has_language, send_profile, has_mime; - assert (sess->status == GF_NETIO_CONNECTED); + GF_Err e; + GF_NETIO_Parameter par; + char range_buf[1024]; + char pass_buf[1024]; + const char *user_agent; + const char *url; + const char *user_profile; + const char *param_string; + Bool has_accept, has_connection, has_range, has_agent, has_language, send_profile, has_mime; + assert (sess->status == GF_NETIO_CONNECTED); gf_dm_clear_headers(sess); @@ -2076,237 +2078,237 @@ static GF_Err http_send_headers(GF_DownloadSession *sess, char * sHTTP) { sess->needs_cache_reconfig = 0; } - /*setup authentification*/ - strcpy(pass_buf, ""); - sess->creds = gf_find_user_credentials_for_site( sess->dm, sess->server_name ); - if (sess->creds && sess->creds->valid) { - sprintf(pass_buf, "Authorization: Basic %s", sess->creds->digest); - } - if (sess->dm && sess->dm->cfg) - user_agent = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserAgent"); - else - user_agent = NULL; - if (!user_agent) user_agent = GF_DOWNLOAD_AGENT_NAME; - - - par.error = 0; - par.msg_type = GF_NETIO_GET_METHOD; - par.name = NULL; - gf_dm_sess_user_io(sess, &par); - if (!par.name || sess->server_only_understand_get) { - par.name = "GET"; - } - - if (par.name) { - if (!strcmp(par.name, "GET")) sess->http_read_type = GET; - else if (!strcmp(par.name, "HEAD")) sess->http_read_type = HEAD; - else sess->http_read_type = OTHER; - } else { - sess->http_read_type = GET; - } - - url = (sess->proxy_enabled==1) ? sess->orig_url : sess->remote_path; - if (sess->dm && sess->dm->cfg) - param_string = gf_cfg_get_key(sess->dm->cfg, "Downloader", "ParamString"); - else - param_string = NULL; - if (param_string) { - if (strchr(sess->remote_path, '?')) { - sprintf(sHTTP, "%s %s&%s HTTP/1.0\r\nHost: %s\r\n" , - par.name ? par.name : "GET", url, param_string, sess->server_name); - } else { - sprintf(sHTTP, "%s %s?%s HTTP/1.0\r\nHost: %s\r\n" , - par.name ? par.name : "GET", url, param_string, sess->server_name); - } - } else { - sprintf(sHTTP, "%s %s HTTP/1.1\r\nHost: %s\r\n" , - par.name ? par.name : "GET", url, sess->server_name); - } - - /*get all headers*/ - has_agent = has_accept = has_connection = has_range = has_language = has_mime = 0; - while (1) { - par.msg_type = GF_NETIO_GET_HEADER; - par.value = NULL; - gf_dm_sess_user_io(sess, &par); - if (!par.value) break; - strcat(sHTTP, par.name); - strcat(sHTTP, ": "); - strcat(sHTTP, par.value); - strcat(sHTTP, "\r\n"); - if (!strcmp(par.name, "Accept")) has_accept = 1; - else if (!strcmp(par.name, "Connection")) has_connection = 1; - else if (!strcmp(par.name, "Range")) has_range = 1; - else if (!strcmp(par.name, "User-Agent")) has_agent = 1; - else if (!strcmp(par.name, "Accept-Language")) has_language = 1; - else if (!strcmp(par.name, "Content-Type")) has_mime = 1; - if (!par.msg_type) break; - } - if (!has_agent) { - strcat(sHTTP, "User-Agent: "); - strcat(sHTTP, user_agent); - strcat(sHTTP, "\r\n"); - } + /*setup authentification*/ + strcpy(pass_buf, ""); + sess->creds = gf_find_user_credentials_for_site( sess->dm, sess->server_name ); + if (sess->creds && sess->creds->valid) { + sprintf(pass_buf, "Authorization: Basic %s", sess->creds->digest); + } + if (sess->dm && sess->dm->cfg) + user_agent = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserAgent"); + else + user_agent = NULL; + if (!user_agent) user_agent = GF_DOWNLOAD_AGENT_NAME; + + + par.error = 0; + par.msg_type = GF_NETIO_GET_METHOD; + par.name = NULL; + gf_dm_sess_user_io(sess, &par); + if (!par.name || sess->server_only_understand_get) { + par.name = "GET"; + } + + if (par.name) { + if (!strcmp(par.name, "GET")) sess->http_read_type = GET; + else if (!strcmp(par.name, "HEAD")) sess->http_read_type = HEAD; + else sess->http_read_type = OTHER; + } else { + sess->http_read_type = GET; + } + + url = (sess->proxy_enabled==1) ? sess->orig_url : sess->remote_path; + if (sess->dm && sess->dm->cfg) + param_string = gf_cfg_get_key(sess->dm->cfg, "Downloader", "ParamString"); + else + param_string = NULL; + if (param_string) { + if (strchr(sess->remote_path, '?')) { + sprintf(sHTTP, "%s %s&%s HTTP/1.0\r\nHost: %s\r\n" , + par.name ? par.name : "GET", url, param_string, sess->server_name); + } else { + sprintf(sHTTP, "%s %s?%s HTTP/1.0\r\nHost: %s\r\n" , + par.name ? par.name : "GET", url, param_string, sess->server_name); + } + } else { + sprintf(sHTTP, "%s %s HTTP/1.1\r\nHost: %s\r\n" , + par.name ? par.name : "GET", url, sess->server_name); + } + + /*get all headers*/ + has_agent = has_accept = has_connection = has_range = has_language = has_mime = 0; + while (1) { + par.msg_type = GF_NETIO_GET_HEADER; + par.value = NULL; + gf_dm_sess_user_io(sess, &par); + if (!par.value) break; + strcat(sHTTP, par.name); + strcat(sHTTP, ": "); + strcat(sHTTP, par.value); + strcat(sHTTP, "\r\n"); + if (!strcmp(par.name, "Accept")) has_accept = 1; + else if (!strcmp(par.name, "Connection")) has_connection = 1; + else if (!strcmp(par.name, "Range")) has_range = 1; + else if (!strcmp(par.name, "User-Agent")) has_agent = 1; + else if (!strcmp(par.name, "Accept-Language")) has_language = 1; + else if (!strcmp(par.name, "Content-Type")) has_mime = 1; + if (!par.msg_type) break; + } + if (!has_agent) { + strcat(sHTTP, "User-Agent: "); + strcat(sHTTP, user_agent); + strcat(sHTTP, "\r\n"); + } /*no mime and POST/PUT, default to octet stream*/ if (!has_mime && (sess->http_read_type==OTHER)) strcat(sHTTP, "Content-Type: application/octet-stream\r\n"); - if (!has_accept && (sess->http_read_type!=OTHER) ) strcat(sHTTP, "Accept: */*\r\n"); - if (sess->proxy_enabled==1) strcat(sHTTP, "Proxy-Connection: Keep-alive\r\n"); - else if (!has_connection) strcat(sHTTP, "Connection: Keep-Alive\r\n"); - if (!has_range && sess->needs_range) { - if (!sess->range_end) sprintf(range_buf, "Range: bytes="LLD"-\r\n", sess->range_start); - else sprintf(range_buf, "Range: bytes="LLD"-"LLD"\r\n", sess->range_start, sess->range_end); - /* FIXME : cache should not be used here */ - strcat(sHTTP, range_buf); - } - if (!has_language) { - const char *opt; - - if (sess->dm && sess->dm->cfg) - opt = gf_cfg_get_key(sess->dm->cfg, "Systems", "Language2CC"); - else - opt = NULL; - if (opt) { - strcat(sHTTP, "Accept-Language: "); - strcat(sHTTP, opt); - strcat(sHTTP, "\r\n"); - } - } - - - if (strlen(pass_buf)) { - strcat(sHTTP, pass_buf); - strcat(sHTTP, "\r\n"); - } - - par.msg_type = GF_NETIO_GET_CONTENT; - par.data = NULL; - par.size = 0; - - /*check if we have personalization info*/ - send_profile = 0; - if (sess->dm && sess->dm->cfg) - user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfileID"); - else - user_profile = NULL; - if (user_profile) { - strcat(sHTTP, "X-UserProfileID: "); - strcat(sHTTP, user_profile); - strcat(sHTTP, "\r\n"); - } else { - if (sess->dm && sess->dm->cfg) - user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfile"); - else - user_profile = NULL; - if (user_profile) { - FILE *profile = gf_f64_open(user_profile, "rt"); - if (profile) { - gf_f64_seek(profile, 0, SEEK_END); - par.size = (u32) gf_f64_tell(profile); - fclose(profile); - sprintf(range_buf, "Content-Length: %d\r\n", par.size); - strcat(sHTTP, range_buf); - strcat(sHTTP, "Content-Type: text/xml\r\n"); - send_profile = 1; - } - } - } - - - if (!send_profile) { - gf_dm_sess_user_io(sess, &par); - if (par.data && par.size) { - sprintf(range_buf, "Content-Length: %d\r\n", par.size); - strcat(sHTTP, range_buf); - } - } + if (!has_accept && (sess->http_read_type!=OTHER) ) strcat(sHTTP, "Accept: */*\r\n"); + if (sess->proxy_enabled==1) strcat(sHTTP, "Proxy-Connection: Keep-alive\r\n"); + else if (!has_connection) strcat(sHTTP, "Connection: Keep-Alive\r\n"); + if (!has_range && sess->needs_range) { + if (!sess->range_end) sprintf(range_buf, "Range: bytes="LLD"-\r\n", sess->range_start); + else sprintf(range_buf, "Range: bytes="LLD"-"LLD"\r\n", sess->range_start, sess->range_end); + /* FIXME : cache should not be used here */ + strcat(sHTTP, range_buf); + } + if (!has_language) { + const char *opt; + + if (sess->dm && sess->dm->cfg) + opt = gf_cfg_get_key(sess->dm->cfg, "Systems", "Language2CC"); + else + opt = NULL; + if (opt) { + strcat(sHTTP, "Accept-Language: "); + strcat(sHTTP, opt); + strcat(sHTTP, "\r\n"); + } + } + + + if (strlen(pass_buf)) { + strcat(sHTTP, pass_buf); + strcat(sHTTP, "\r\n"); + } + + par.msg_type = GF_NETIO_GET_CONTENT; + par.data = NULL; + par.size = 0; + + /*check if we have personalization info*/ + send_profile = 0; + if (sess->dm && sess->dm->cfg) + user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfileID"); + else + user_profile = NULL; + if (user_profile) { + strcat(sHTTP, "X-UserProfileID: "); + strcat(sHTTP, user_profile); + strcat(sHTTP, "\r\n"); + } else { + if (sess->dm && sess->dm->cfg) + user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfile"); + else + user_profile = NULL; + if (user_profile) { + FILE *profile = gf_f64_open(user_profile, "rt"); + if (profile) { + gf_f64_seek(profile, 0, SEEK_END); + par.size = (u32) gf_f64_tell(profile); + fclose(profile); + sprintf(range_buf, "Content-Length: %d\r\n", par.size); + strcat(sHTTP, range_buf); + strcat(sHTTP, "Content-Type: text/xml\r\n"); + send_profile = 1; + } + } + } + + + if (!send_profile) { + gf_dm_sess_user_io(sess, &par); + if (par.data && par.size) { + sprintf(range_buf, "Content-Length: %d\r\n", par.size); + strcat(sHTTP, range_buf); + } + } if (sess->http_read_type!=OTHER) { /*signal we support title streaming*/ if (!strcmp(sess->remote_path, "/")) strcat(sHTTP, "icy-metadata:1\r\n"); - /* This will force the server to respond with Icy-Metaint */ + /* This will force the server to respond with Icy-Metaint */ strcat(sHTTP, "Icy-Metadata: 1\r\n"); /*cached headers are not appended in POST*/ if (!sess->disable_cache && (GF_OK < appendHttpCacheHeaders( sess->cache_entry, sHTTP)) ) { - GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("Cache Entry : %p, FAILED to append cache directives.", sess->cache_entry)); - } - } - - strcat(sHTTP, "\r\n"); - - if (send_profile || par.data) { - u32 len = (u32) strlen(sHTTP); - char *tmp_buf = gf_malloc(sizeof(char)*(len+par.size+1)); - strcpy(tmp_buf, sHTTP); - if (par.data) { - memcpy(tmp_buf+len, par.data, par.size); - tmp_buf[len+par.size] = 0; - } else { - FILE *profile; - assert( sess->dm ); - assert( sess->dm->cfg ); - user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfile"); - assert (user_profile); - profile = gf_f64_open(user_profile, "rt"); - if (profile) { - u32 readen = (u32) fread(tmp_buf+len, sizeof(char), par.size, profile); - if (readencache_entry)); + } + } + + strcat(sHTTP, "\r\n"); + + if (send_profile || par.data) { + u32 len = (u32) strlen(sHTTP); + char *tmp_buf = gf_malloc(sizeof(char)*(len+par.size+1)); + strcpy(tmp_buf, sHTTP); + if (par.data) { + memcpy(tmp_buf+len, par.data, par.size); + tmp_buf[len+par.size] = 0; + } else { + FILE *profile; + assert( sess->dm ); + assert( sess->dm->cfg ); + user_profile = gf_cfg_get_key(sess->dm->cfg, "Downloader", "UserProfile"); + assert (user_profile); + profile = gf_f64_open(user_profile, "rt"); + if (profile) { + u32 readen = (u32) fread(tmp_buf+len, sizeof(char), par.size, profile); + if (readenssl) { - u32 writelen = len+par.size; + if (sess->ssl) { + u32 writelen = len+par.size; e = GF_OK; if (writelen != SSL_write(sess->ssl, tmp_buf, writelen)) e = GF_IP_NETWORK_FAILURE; - } else + } else #endif - e = gf_sk_send(sess->sock, tmp_buf, len+par.size); + e = gf_sk_send(sess->sock, tmp_buf, len+par.size); - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending request %s\n\n", tmp_buf)); - gf_free(tmp_buf); - } else { + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending request %s\n\n", tmp_buf)); + gf_free(tmp_buf); + } else { #ifdef GPAC_HAS_SSL - if (sess->ssl) { - u32 len = strlen(sHTTP); + if (sess->ssl) { + u32 len = strlen(sHTTP); e = GF_OK; if (len != SSL_write(sess->ssl, sHTTP, len)) e = GF_IP_NETWORK_FAILURE; - } else + } else #endif - e = gf_sk_send(sess->sock, sHTTP, (u32) strlen(sHTTP)); + e = gf_sk_send(sess->sock, sHTTP, (u32) strlen(sHTTP)); #ifndef GPAC_DISABLE_LOG - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Error sending request %s\n", gf_error_to_string(e) )); - } else { - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending request %s\n\n", sHTTP)); - } + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Error sending request %s\n", gf_error_to_string(e) )); + } else { + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending request %s\n\n", sHTTP)); + } #endif } sess->request_time = gf_sys_clock(); - if (e) { - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, GF_NETIO_STATE_ERROR, e); - return e; - } + if (e) { + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, GF_NETIO_STATE_ERROR, e); + return e; + } - sess->status = GF_NETIO_WAIT_FOR_REPLY; - gf_dm_sess_notify_state(sess, GF_NETIO_WAIT_FOR_REPLY, GF_OK); - return GF_OK; + sess->status = GF_NETIO_WAIT_FOR_REPLY; + gf_dm_sess_notify_state(sess, GF_NETIO_WAIT_FOR_REPLY, GF_OK); + return GF_OK; } @@ -2317,49 +2319,49 @@ static GF_Err http_send_headers(GF_DownloadSession *sess, char * sHTTP) { * \return The error code if any */ static GF_Err http_parse_remaining_body(GF_DownloadSession * sess, char * sHTTP) { - u32 size; - GF_Err e; - while (1) { - if (sess->status>=GF_NETIO_DISCONNECTED) - return GF_REMOTE_SERVICE_ERROR; + u32 size; + GF_Err e; + while (1) { + if (sess->status>=GF_NETIO_DISCONNECTED) + return GF_REMOTE_SERVICE_ERROR; if (sess->dm && sess->dm->limit_data_rate && sess->bytes_per_sec) { - if (sess->bytes_per_sec > sess->dm->limit_data_rate) { - /*update state*/ - u32 runtime = gf_sys_clock() - sess->start_time; + if (sess->bytes_per_sec > sess->dm->limit_data_rate) { + /*update state*/ + u32 runtime = gf_sys_clock() - sess->start_time; u64 nb_bytes = sess->bytes_done; sess->bytes_per_sec = (u32) (1000*nb_bytes / runtime); - if (sess->bytes_per_sec > sess->dm->limit_data_rate) return GF_OK; - } - } + if (sess->bytes_per_sec > sess->dm->limit_data_rate) return GF_OK; + } + } e = gf_dm_read_data(sess, sHTTP, GF_DOWNLOAD_BUFFER_SIZE, &size); - if (e!= GF_IP_CONNECTION_CLOSED && (!size || e == GF_IP_NETWORK_EMPTY)) { + if (e!= GF_IP_CONNECTION_CLOSED && (!size || e == GF_IP_NETWORK_EMPTY)) { if (e == GF_IP_CONNECTION_CLOSED || (!sess->total_size && !sess->chunked && (gf_sys_clock() - sess->start_time > 5000))) { - sess->total_size = sess->bytes_done; - gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); + sess->total_size = sess->bytes_done; + gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); assert(sess->server_name); GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Disconnected from %s: %s\n", sess->server_name, gf_error_to_string(e))); - gf_dm_disconnect(sess, (e == GF_IP_CONNECTION_CLOSED) ? 1 : 0); - } - return GF_OK; - } + gf_dm_disconnect(sess, (e == GF_IP_CONNECTION_CLOSED) ? 1 : 0); + } + return GF_OK; + } if (e) { - if (e == GF_IP_CONNECTION_CLOSED){ + if (e == GF_IP_CONNECTION_CLOSED) { u32 len = gf_cache_get_content_length(sess->cache_entry); if (size > 0) gf_dm_data_received(sess, (u8 *) sHTTP, size, 0, NULL); - if ( ( (len == 0) && sess->use_cache_file) - /*ivica patch*/ - || (size==0) - ) { + if ( ( (len == 0) && sess->use_cache_file) + /*ivica patch*/ + || (size==0) + ) { sess->total_size = sess->bytes_done; // HTTP 1.1 without content length... gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); assert(sess->server_name); GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Disconnected from %s: %s\n", sess->server_name, gf_error_to_string(e))); - if (sess->use_cache_file) + if (sess->use_cache_file) gf_cache_set_content_length(sess->cache_entry, sess->bytes_done); e = GF_OK; } @@ -2371,31 +2373,31 @@ static GF_Err http_parse_remaining_body(GF_DownloadSession * sess, char * sHTTP) } gf_dm_data_received(sess, (u8 *) sHTTP, size, 0, NULL); - /*socket empty*/ - if (size < GF_DOWNLOAD_BUFFER_SIZE) { + /*socket empty*/ + if (size < GF_DOWNLOAD_BUFFER_SIZE) { gf_sleep(1); return GF_OK; } - } + } } static void notify_headers(GF_DownloadSession *sess, char * sHTTP, s32 bytesRead, s32 BodyStart) { - GF_NETIO_Parameter par; - u32 i, count; + GF_NETIO_Parameter par; + u32 i, count; count = gf_list_count(sess->headers); memset(&par, 0, sizeof(GF_NETIO_Parameter)); - + for (i=0; iheaders, i); par.name = hdrp->name; par.value = hdrp->value; - par.error = 0; - par.msg_type = GF_NETIO_PARSE_HEADER; - gf_dm_sess_user_io(sess, &par); - } + par.error = 0; + par.msg_type = GF_NETIO_PARSE_HEADER; + gf_dm_sess_user_io(sess, &par); + } } /*! @@ -2405,127 +2407,127 @@ static void notify_headers(GF_DownloadSession *sess, char * sHTTP, s32 bytesRead */ static GF_Err wait_for_header_and_parse(GF_DownloadSession *sess, char * sHTTP) { - GF_NETIO_Parameter par; - s32 bytesRead, BodyStart; - u32 res, i; - s32 LinePos, Pos; - u32 rsp_code, ContentLength, first_byte, last_byte, total_size, range, no_range; + GF_NETIO_Parameter par; + s32 bytesRead, BodyStart; + u32 res, i; + s32 LinePos, Pos; + u32 rsp_code, ContentLength, first_byte, last_byte, total_size, range, no_range; Bool connection_closed = 0; - char buf[1025]; - char comp[400]; - GF_Err e; - char * new_location; - assert( sess->status == GF_NETIO_WAIT_FOR_REPLY ); - bytesRead = res = 0; - new_location = NULL; + char buf[1025]; + char comp[400]; + GF_Err e; + char * new_location; + assert( sess->status == GF_NETIO_WAIT_FOR_REPLY ); + bytesRead = res = 0; + new_location = NULL; if (!(sess->flags & GF_NETIO_SESSION_NOT_CACHED)) { - sess->use_cache_file = 1; + sess->use_cache_file = 1; } //always set start time to the time at last attempt reply parsing - sess->start_time = gf_sys_clock(); + sess->start_time = gf_sys_clock(); sess->start_time_utc = gf_net_get_utc(); - while (1) { - e = gf_dm_read_data(sess, sHTTP + bytesRead, GF_DOWNLOAD_BUFFER_SIZE - bytesRead, &res); - switch (e) { - case GF_IP_NETWORK_EMPTY: - if (!bytesRead) { + while (1) { + e = gf_dm_read_data(sess, sHTTP + bytesRead, GF_DOWNLOAD_BUFFER_SIZE - bytesRead, &res); + switch (e) { + case GF_IP_NETWORK_EMPTY: + if (!bytesRead) { if (gf_sys_clock() - sess->request_time > sess->dm->request_timeout) { - sess->last_error = GF_IP_NETWORK_EMPTY; - sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = GF_IP_NETWORK_EMPTY; + sess->status = GF_NETIO_STATE_ERROR; return GF_IP_NETWORK_EMPTY; } return GF_OK; } - continue; - /*socket has been closed while configuring, retry (not sure if the server got the GET)*/ - case GF_IP_CONNECTION_CLOSED: - if (sess->http_read_type == HEAD) { - /* Some servers such as shoutcast directly close connection if HEAD or an unknown method is issued */ - sess->server_only_understand_get = 1; - } + continue; + /*socket has been closed while configuring, retry (not sure if the server got the GET)*/ + case GF_IP_CONNECTION_CLOSED: + if (sess->http_read_type == HEAD) { + /* Some servers such as shoutcast directly close connection if HEAD or an unknown method is issued */ + sess->server_only_understand_get = 1; + } GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Connection closed by server when getting %s - retrying\n", sess->remote_path)); - gf_dm_disconnect(sess, 1); + gf_dm_disconnect(sess, 1); if (sess->num_retry) - sess->status = GF_NETIO_SETUP; - else { - sess->last_error = e; - sess->status = GF_NETIO_STATE_ERROR; - } - return e; - case GF_OK: - if (!res) return GF_OK; - break; - default: - goto exit; - } - bytesRead += res; - - /*locate body start*/ - BodyStart = gf_token_find(sHTTP, 0, bytesRead, "\r\n\r\n"); - if (BodyStart > 0) { + sess->status = GF_NETIO_SETUP; + else { + sess->last_error = e; + sess->status = GF_NETIO_STATE_ERROR; + } + return e; + case GF_OK: + if (!res) return GF_OK; + break; + default: + goto exit; + } + bytesRead += res; + + /*locate body start*/ + BodyStart = gf_token_find(sHTTP, 0, bytesRead, "\r\n\r\n"); + if (BodyStart > 0) { BodyStart += 4; break; } - BodyStart = gf_token_find(sHTTP, 0, bytesRead, "\n\n"); - if (BodyStart > 0) { + BodyStart = gf_token_find(sHTTP, 0, bytesRead, "\n\n"); + if (BodyStart > 0) { BodyStart += 2; break; } - BodyStart=0; - } - if (bytesRead < 0) { - e = GF_REMOTE_SERVICE_ERROR; - goto exit; - } - if (!BodyStart) - BodyStart = bytesRead; - - sHTTP[BodyStart-1] = 0; - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] %s\n\n", sHTTP)); - - LinePos = gf_token_get_line(sHTTP, 0, bytesRead, buf, 1024); - Pos = gf_token_get(buf, 0, " \t\r\n", comp, 400); - - if (!strncmp("ICY", comp, 3)) { - sess->use_cache_file = 0; - /*be prepared not to receive any mime type from ShoutCast servers*/ - if (!gf_cache_get_mime_type(sess->cache_entry)) - gf_cache_set_mime_type(sess->cache_entry, "audio/mpeg"); - } else if ((strncmp("HTTP", comp, 4) != 0)) { - e = GF_REMOTE_SERVICE_ERROR; - goto exit; - } - Pos = gf_token_get(buf, Pos, " ", comp, 400); - if (Pos <= 0) { - e = GF_REMOTE_SERVICE_ERROR; - goto exit; - } - rsp_code = (u32) atoi(comp); - Pos = gf_token_get(buf, Pos, " \r\n", comp, 400); - - no_range = range = ContentLength = first_byte = last_byte = total_size = 0; - /* parse headers*/ - while (1) { + BodyStart=0; + } + if (bytesRead < 0) { + e = GF_REMOTE_SERVICE_ERROR; + goto exit; + } + if (!BodyStart) + BodyStart = bytesRead; + + sHTTP[BodyStart-1] = 0; + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] %s\n\n", sHTTP)); + + LinePos = gf_token_get_line(sHTTP, 0, bytesRead, buf, 1024); + Pos = gf_token_get(buf, 0, " \t\r\n", comp, 400); + + if (!strncmp("ICY", comp, 3)) { + sess->use_cache_file = 0; + /*be prepared not to receive any mime type from ShoutCast servers*/ + if (!gf_cache_get_mime_type(sess->cache_entry)) + gf_cache_set_mime_type(sess->cache_entry, "audio/mpeg"); + } else if ((strncmp("HTTP", comp, 4) != 0)) { + e = GF_REMOTE_SERVICE_ERROR; + goto exit; + } + Pos = gf_token_get(buf, Pos, " ", comp, 400); + if (Pos <= 0) { + e = GF_REMOTE_SERVICE_ERROR; + goto exit; + } + rsp_code = (u32) atoi(comp); + Pos = gf_token_get(buf, Pos, " \r\n", comp, 400); + + no_range = range = ContentLength = first_byte = last_byte = total_size = 0; + /* parse headers*/ + while (1) { GF_HTTPHeader *hdrp; - char *sep, *hdr_sep, *hdr, *hdr_val; - if ( (s32) LinePos + 4 > BodyStart) break; - LinePos = gf_token_get_line(sHTTP, LinePos , bytesRead, buf, 1024); - if (LinePos < 0) break; - - hdr_sep = NULL; - hdr_val = NULL; - hdr = buf; - sep = strchr(buf, ':'); - if (sep) { - sep[0]=0; - hdr_val = sep+1; - while (hdr_val[0]==' ') hdr_val++; - hdr_sep = strrchr(hdr_val, '\r'); - if (hdr_sep) hdr_sep[0] = 0; - } + char *sep, *hdr_sep, *hdr, *hdr_val; + if ( (s32) LinePos + 4 > BodyStart) break; + LinePos = gf_token_get_line(sHTTP, LinePos , bytesRead, buf, 1024); + if (LinePos < 0) break; + + hdr_sep = NULL; + hdr_val = NULL; + hdr = buf; + sep = strchr(buf, ':'); + if (sep) { + sep[0]=0; + hdr_val = sep+1; + while (hdr_val[0]==' ') hdr_val++; + hdr_sep = strrchr(hdr_val, '\r'); + if (hdr_sep) hdr_sep[0] = 0; + } GF_SAFEALLOC(hdrp, GF_HTTPHeader); hdrp->name = gf_strdup(hdr); @@ -2533,7 +2535,7 @@ static GF_Err wait_for_header_and_parse(GF_DownloadSession *sess, char * sHTTP) gf_list_add(sess->headers, hdrp); if (sep) sep[0]=':'; - if (hdr_sep) hdr_sep[0] = '\r'; + if (hdr_sep) hdr_sep[0] = '\r'; } //default pre-processing of headers - needs cleanup, not all of these have to be parsed before checking reply code @@ -2543,112 +2545,112 @@ static GF_Err wait_for_header_and_parse(GF_DownloadSession *sess, char * sHTTP) if (!stricmp(hdrp->name, "Content-Length") ) { ContentLength = (u32) atoi(hdrp->value); - + if (rsp_code<300) gf_cache_set_content_length(sess->cache_entry, ContentLength); - - } - else if (!stricmp(hdrp->name, "Content-Type")) { - char * mime_type = gf_strdup(hdrp->value); - while (1) { - u32 len = (u32) strlen(mime_type); - char c = len ? mime_type[len-1] : 0; - if ((c=='\r') || (c=='\n')) { - mime_type[len-1] = 0; - } else { - break; - } - } - val = strchr(mime_type, ';'); - if (val) val[0] = 0; + + } + else if (!stricmp(hdrp->name, "Content-Type")) { + char * mime_type = gf_strdup(hdrp->value); + while (1) { + u32 len = (u32) strlen(mime_type); + char c = len ? mime_type[len-1] : 0; + if ((c=='\r') || (c=='\n')) { + mime_type[len-1] = 0; + } else { + break; + } + } + val = strchr(mime_type, ';'); + if (val) val[0] = 0; strlwr(mime_type); if (rsp_code<300) { - if (sess->cache_entry) { + if (sess->cache_entry) { gf_cache_set_mime_type(sess->cache_entry, mime_type); } else { sess->mime_type = mime_type; mime_type = NULL; } } - if (mime_type) gf_free(mime_type); - } - else if (!stricmp(hdrp->name, "Content-Range")) { - range = 1; - if (!strncmp(hdrp->value, "bytes", 5)) { - val = hdrp->value + 5; - if (val[0] == ':') val += 1; - val += http_skip_space(val); - if (val[0] == '*') { + if (mime_type) gf_free(mime_type); + } + else if (!stricmp(hdrp->name, "Content-Range")) { + range = 1; + if (!strncmp(hdrp->value, "bytes", 5)) { + val = hdrp->value + 5; + if (val[0] == ':') val += 1; + val += http_skip_space(val); + if (val[0] == '*') { sscanf(val, "*/%u", &total_size); - } else { - sscanf(val, "%u-%u/%u", &first_byte, &last_byte, &total_size); - } - } - } - else if (!stricmp(hdrp->name, "Accept-Ranges")) { + } else { + sscanf(val, "%u-%u/%u", &first_byte, &last_byte, &total_size); + } + } + } + else if (!stricmp(hdrp->name, "Accept-Ranges")) { if (strstr(hdrp->value, "none")) no_range = 1; - } - else if (!stricmp(hdrp->name, "Location")) - new_location = gf_strdup(hdrp->value); - else if (!strnicmp(hdrp->name, "ice", 3) || !strnicmp(hdrp->name, "icy", 3) ) { - /* For HTTP icy servers, we disable cache */ - if (sess->icy_metaint == 0) - sess->icy_metaint = -1; - sess->use_cache_file = 0; - if (!stricmp(hdrp->name, "icy-metaint")) { - sess->icy_metaint = atoi(hdrp->value); - } - } - else if (!stricmp(hdrp->name, "Cache-Control")) { - } - else if (!stricmp(hdrp->name, "ETag")) { + } + else if (!stricmp(hdrp->name, "Location")) + new_location = gf_strdup(hdrp->value); + else if (!strnicmp(hdrp->name, "ice", 3) || !strnicmp(hdrp->name, "icy", 3) ) { + /* For HTTP icy servers, we disable cache */ + if (sess->icy_metaint == 0) + sess->icy_metaint = -1; + sess->use_cache_file = 0; + if (!stricmp(hdrp->name, "icy-metaint")) { + sess->icy_metaint = atoi(hdrp->value); + } + } + else if (!stricmp(hdrp->name, "Cache-Control")) { + } + else if (!stricmp(hdrp->name, "ETag")) { if (rsp_code<300) - gf_cache_set_etag_on_server(sess->cache_entry, hdrp->value); - } - else if (!stricmp(hdrp->name, "Last-Modified")) { + gf_cache_set_etag_on_server(sess->cache_entry, hdrp->value); + } + else if (!stricmp(hdrp->name, "Last-Modified")) { if (rsp_code<300) - gf_cache_set_last_modified_on_server(sess->cache_entry, hdrp->value); - } - else if (!stricmp(hdrp->name, "Transfer-Encoding")) { + gf_cache_set_last_modified_on_server(sess->cache_entry, hdrp->value); + } + else if (!stricmp(hdrp->name, "Transfer-Encoding")) { if (!stricmp(hdrp->value, "chunked")) sess->chunked = GF_TRUE; - } - else if (!stricmp(hdrp->name, "X-UserProfileID") ) { - if (sess->dm && sess->dm->cfg) - gf_cfg_set_key(sess->dm->cfg, "Downloader", "UserProfileID", hdrp->value); - } - else if (!stricmp(hdrp->name, "Connection") ) { - if (strstr(hdrp->value, "close")) - connection_closed = 1; - } - - if (sess->status==GF_NETIO_DISCONNECTED) return GF_OK; - } - if (no_range) first_byte = 0; - - par.msg_type = GF_NETIO_PARSE_REPLY; - par.error = GF_OK; - par.reply = rsp_code; - par.value = comp; - /* - * If response is correct, it means our credentials are correct - */ - if (sess->creds && rsp_code != 304) - sess->creds->valid = 1; + } + else if (!stricmp(hdrp->name, "X-UserProfileID") ) { + if (sess->dm && sess->dm->cfg) + gf_cfg_set_key(sess->dm->cfg, "Downloader", "UserProfileID", hdrp->value); + } + else if (!stricmp(hdrp->name, "Connection") ) { + if (strstr(hdrp->value, "close")) + connection_closed = 1; + } + + if (sess->status==GF_NETIO_DISCONNECTED) return GF_OK; + } + if (no_range) first_byte = 0; + + par.msg_type = GF_NETIO_PARSE_REPLY; + par.error = GF_OK; + par.reply = rsp_code; + par.value = comp; + /* + * If response is correct, it means our credentials are correct + */ + if (sess->creds && rsp_code != 304) + sess->creds->valid = 1; /*try to flush body */ if (rsp_code>=300) { u32 start = gf_sys_clock(); while (BodyStart + ContentLength > (u32) bytesRead) { - e = gf_dm_read_data(sess, sHTTP + bytesRead, GF_DOWNLOAD_BUFFER_SIZE - bytesRead, &res); + e = gf_dm_read_data(sess, sHTTP + bytesRead, GF_DOWNLOAD_BUFFER_SIZE - bytesRead, &res); switch (e) { case GF_IP_NETWORK_EMPTY: gf_sleep(1); continue; case GF_OK: - bytesRead += res; + bytesRead += res; break; default: start=0; @@ -2671,211 +2673,211 @@ static GF_Err wait_for_header_and_parse(GF_DownloadSession *sess, char * sHTTP) //remember if we can keep the session alive after the transfer is done sess->connection_close = connection_closed; - switch (rsp_code) { - case 200: - case 201: - case 202: - case 206: - gf_dm_sess_user_io(sess, &par); - e = GF_OK; - if (sess->proxy_enabled==2) { - sess->proxy_enabled=0; - if (sess->dm) - gf_list_add(sess->dm->skip_proxy_servers, gf_strdup(sess->server_name)); - } - break; - /*redirection: extract the new location*/ - case 301: - case 302: - case 307: - if (!new_location || !strlen(new_location) ) { - gf_dm_sess_user_io(sess, &par); - e = GF_URL_ERROR; - goto exit; - } - while ( - (new_location[strlen(new_location)-1] == '\n') - || (new_location[strlen(new_location)-1] == '\r') ) - new_location[strlen(new_location)-1] = 0; - - /*reset and reconnect*/ - gf_dm_disconnect(sess, 1); - sess->status = GF_NETIO_SETUP; - e = gf_dm_sess_setup_from_url(sess, new_location); - if (e) { - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - } - return e; - case 304: - { - sess->status = GF_NETIO_PARSE_REPLY; - gf_dm_sess_notify_state(sess, GF_NETIO_PARSE_REPLY, GF_OK); - gf_dm_disconnect(sess, 0); - if (sess->user_proc) { - /* For modules that do not use cache and have problems with GF_NETIO_DATA_TRANSFERED ... */ - const char * filename; - FILE * f; - filename = gf_cache_get_cache_filename(sess->cache_entry); - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending data to modules from %s...\n", filename)); - f = gf_f64_open(filename, "rb"); - assert(filename); - if (!f) { - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] FAILED to open cache file %s for reading contents !\n", filename)); - /* Ooops, no cache, redowload everything ! */ - gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_SETUP; - e = gf_dm_sess_setup_from_url(sess, sess->orig_url); - sess->total_size = gf_cache_get_cache_filesize(sess->cache_entry); - if (e) { - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - } - return e; - } - - par.error = 0; - par.msg_type = GF_NETIO_PARSE_HEADER; - par.name = "Content-Type"; - par.value = (char *) gf_cache_get_mime_type(sess->cache_entry); - gf_dm_sess_user_io(sess, &par); - - sess->status = GF_NETIO_DATA_EXCHANGE; + switch (rsp_code) { + case 200: + case 201: + case 202: + case 206: + gf_dm_sess_user_io(sess, &par); + e = GF_OK; + if (sess->proxy_enabled==2) { + sess->proxy_enabled=0; + if (sess->dm) + gf_list_add(sess->dm->skip_proxy_servers, gf_strdup(sess->server_name)); + } + break; + /*redirection: extract the new location*/ + case 301: + case 302: + case 307: + if (!new_location || !strlen(new_location) ) { + gf_dm_sess_user_io(sess, &par); + e = GF_URL_ERROR; + goto exit; + } + while ( + (new_location[strlen(new_location)-1] == '\n') + || (new_location[strlen(new_location)-1] == '\r') ) + new_location[strlen(new_location)-1] = 0; + + /*reset and reconnect*/ + gf_dm_disconnect(sess, 1); + sess->status = GF_NETIO_SETUP; + e = gf_dm_sess_setup_from_url(sess, new_location); + if (e) { + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + } + return e; + case 304: + { + sess->status = GF_NETIO_PARSE_REPLY; + gf_dm_sess_notify_state(sess, GF_NETIO_PARSE_REPLY, GF_OK); + gf_dm_disconnect(sess, 0); + if (sess->user_proc) { + /* For modules that do not use cache and have problems with GF_NETIO_DATA_TRANSFERED ... */ + const char * filename; + FILE * f; + filename = gf_cache_get_cache_filename(sess->cache_entry); + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] Sending data to modules from %s...\n", filename)); + f = gf_f64_open(filename, "rb"); + assert(filename); + if (!f) { + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] FAILED to open cache file %s for reading contents !\n", filename)); + /* Ooops, no cache, redowload everything ! */ + gf_dm_disconnect(sess, 0); + sess->status = GF_NETIO_SETUP; + e = gf_dm_sess_setup_from_url(sess, sess->orig_url); + sess->total_size = gf_cache_get_cache_filesize(sess->cache_entry); + if (e) { + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + } + return e; + } + + par.error = 0; + par.msg_type = GF_NETIO_PARSE_HEADER; + par.name = "Content-Type"; + par.value = (char *) gf_cache_get_mime_type(sess->cache_entry); + gf_dm_sess_user_io(sess, &par); + + sess->status = GF_NETIO_DATA_EXCHANGE; if (! (sess->flags & GF_NETIO_SESSION_NOT_THREADED) || sess->force_data_write_callback) { - char file_cache_buff[16384]; - int read = 0; - u32 total_size = gf_cache_get_cache_filesize(sess->cache_entry); - do { - read = (u32) fread(file_cache_buff, sizeof(char), 16384, f); - if (read > 0) { - sess->bytes_done += read; - sess->total_size = total_size; + char file_cache_buff[16384]; + int read = 0; + u32 total_size = gf_cache_get_cache_filesize(sess->cache_entry); + do { + read = (u32) fread(file_cache_buff, sizeof(char), 16384, f); + if (read > 0) { + sess->bytes_done += read; + sess->total_size = total_size; sess->bytes_per_sec = 0xFFFFFFFF; - par.size = read; - par.msg_type = GF_NETIO_DATA_EXCHANGE; - par.error = GF_EOS; - par.reply = 2; - par.data = file_cache_buff; - gf_dm_sess_user_io(sess, &par); - } - } while ( read > 0); - } - fclose(f); - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] all data has been sent to modules from %s.\n", filename)); - } - /* Cache file is the most recent */ - sess->status = GF_NETIO_DATA_TRANSFERED; - gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); - gf_dm_disconnect(sess, 0); - par.msg_type = GF_NETIO_DATA_TRANSFERED; - par.error = GF_OK; - gf_dm_sess_user_io(sess, &par); - return GF_OK; - } - case 401: - { - /* Do we have a credentials struct ? */ - sess->creds = gf_user_credentials_register(sess->dm, sess->server_name, NULL, NULL, 0); - if (!sess->creds) { - /* User credentials have not been filled properly, we have to abort */ - gf_dm_disconnect(sess, 1); - sess->status = GF_NETIO_STATE_ERROR; - par.error = GF_AUTHENTICATION_FAILURE; - par.msg_type = GF_NETIO_DISCONNECTED; - gf_dm_sess_user_io(sess, &par); - e = GF_AUTHENTICATION_FAILURE; - sess->last_error = e; - goto exit; - } - gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_SETUP; - e = gf_dm_sess_setup_from_url(sess, sess->orig_url); - if (e) { - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - } - return e; - } - case 404: - /* File not found */ - gf_dm_sess_user_io(sess, &par); + par.size = read; + par.msg_type = GF_NETIO_DATA_EXCHANGE; + par.error = GF_EOS; + par.reply = 2; + par.data = file_cache_buff; + gf_dm_sess_user_io(sess, &par); + } + } while ( read > 0); + } + fclose(f); + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] all data has been sent to modules from %s.\n", filename)); + } + /* Cache file is the most recent */ + sess->status = GF_NETIO_DATA_TRANSFERED; + gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); + gf_dm_disconnect(sess, 0); + par.msg_type = GF_NETIO_DATA_TRANSFERED; + par.error = GF_OK; + gf_dm_sess_user_io(sess, &par); + return GF_OK; + } + case 401: + { + /* Do we have a credentials struct ? */ + sess->creds = gf_user_credentials_register(sess->dm, sess->server_name, NULL, NULL, 0); + if (!sess->creds) { + /* User credentials have not been filled properly, we have to abort */ + gf_dm_disconnect(sess, 1); + sess->status = GF_NETIO_STATE_ERROR; + par.error = GF_AUTHENTICATION_FAILURE; + par.msg_type = GF_NETIO_DISCONNECTED; + gf_dm_sess_user_io(sess, &par); + e = GF_AUTHENTICATION_FAILURE; + sess->last_error = e; + goto exit; + } + gf_dm_disconnect(sess, 0); + sess->status = GF_NETIO_SETUP; + e = gf_dm_sess_setup_from_url(sess, sess->orig_url); + if (e) { + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + } + return e; + } + case 404: + /* File not found */ + gf_dm_sess_user_io(sess, &par); if ((BodyStart < (s32) bytesRead)) { sHTTP[bytesRead] = 0; GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Failure: %s\n", sHTTP + BodyStart)); } notify_headers(sess, sHTTP, bytesRead, BodyStart); e = GF_URL_ERROR; - goto exit; - break; - case 416: - /* Range not accepted */ - gf_dm_sess_user_io(sess, &par); + goto exit; + break; + case 416: + /* Range not accepted */ + gf_dm_sess_user_io(sess, &par); notify_headers(sess, sHTTP, bytesRead, BodyStart); e = GF_SERVICE_ERROR; - goto exit; - break; - case 400: - case 501: - /* Method not implemented ! */ - if (sess->http_read_type == HEAD) { - /* Since HEAD is not understood by this server, we use a GET instead */ - sess->http_read_type = GET; - sess->flags |= GF_NETIO_SESSION_NOT_CACHED; - gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_SETUP; - sess->server_only_understand_get = 1; - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("Method not supported, try with GET.\n")); - e = gf_dm_sess_setup_from_url(sess, sess->orig_url); - if (e) { - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - } - return e; - } - - gf_dm_sess_user_io(sess, &par); + goto exit; + break; + case 400: + case 501: + /* Method not implemented ! */ + if (sess->http_read_type == HEAD) { + /* Since HEAD is not understood by this server, we use a GET instead */ + sess->http_read_type = GET; + sess->flags |= GF_NETIO_SESSION_NOT_CACHED; + gf_dm_disconnect(sess, 0); + sess->status = GF_NETIO_SETUP; + sess->server_only_understand_get = 1; + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("Method not supported, try with GET.\n")); + e = gf_dm_sess_setup_from_url(sess, sess->orig_url); + if (e) { + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + } + return e; + } + + gf_dm_sess_user_io(sess, &par); notify_headers(sess, sHTTP, bytesRead, BodyStart); - e = GF_REMOTE_SERVICE_ERROR; - goto exit; - - case 503: - /*retry without proxy*/ - if (sess->proxy_enabled==1) { - sess->proxy_enabled=2; - gf_dm_disconnect(sess, 1); - sess->status = GF_NETIO_SETUP; - return GF_OK; - } - default: - gf_dm_sess_user_io(sess, &par); + e = GF_REMOTE_SERVICE_ERROR; + goto exit; + + case 503: + /*retry without proxy*/ + if (sess->proxy_enabled==1) { + sess->proxy_enabled=2; + gf_dm_disconnect(sess, 1); + sess->status = GF_NETIO_SETUP; + return GF_OK; + } + default: + gf_dm_sess_user_io(sess, &par); notify_headers(sess, sHTTP, bytesRead, BodyStart); - e = GF_REMOTE_SERVICE_ERROR; - goto exit; - } + e = GF_REMOTE_SERVICE_ERROR; + goto exit; + } notify_headers(sess, sHTTP, bytesRead, BodyStart); - if (sess->http_read_type != GET) - sess->use_cache_file = 0; - - if (sess->http_read_type==HEAD) { - gf_dm_disconnect(sess, 0); - gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); - sess->http_read_type = 0; - return GF_OK; - } - { - const char * mime_type = gf_cache_get_mime_type(sess->cache_entry); - if (!ContentLength && mime_type && ((strstr(mime_type, "ogg") || (!strcmp(mime_type, "audio/mpeg"))))) { - if (0 == sess->icy_metaint) - sess->icy_metaint = -1; - sess->use_cache_file = 0; - } + if (sess->http_read_type != GET) + sess->use_cache_file = 0; + + if (sess->http_read_type==HEAD) { + gf_dm_disconnect(sess, 0); + gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); + sess->http_read_type = 0; + return GF_OK; + } + { + const char * mime_type = gf_cache_get_mime_type(sess->cache_entry); + if (!ContentLength && mime_type && ((strstr(mime_type, "ogg") || (!strcmp(mime_type, "audio/mpeg"))))) { + if (0 == sess->icy_metaint) + sess->icy_metaint = -1; + sess->use_cache_file = 0; + } #ifndef GPAC_DISABLE_LOGS if (e) { @@ -2885,62 +2887,62 @@ static GF_Err wait_for_header_and_parse(GF_DownloadSession *sess, char * sHTTP) } #endif - /*some servers may reply without content length, but we MUST have it*/ - if (e) goto exit; - if (sess->icy_metaint != 0) { - assert( ! sess->use_cache_file ); - GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] ICY protocol detected\n")); - if (mime_type && !stricmp(mime_type, "video/nsv")) { - gf_cache_set_mime_type(sess->cache_entry, "audio/aac"); - } - sess->icy_bytes = 0; - sess->total_size = SIZE_IN_STREAM; - sess->status = GF_NETIO_DATA_EXCHANGE; + /*some servers may reply without content length, but we MUST have it*/ + if (e) goto exit; + if (sess->icy_metaint != 0) { + assert( ! sess->use_cache_file ); + GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[HTTP] ICY protocol detected\n")); + if (mime_type && !stricmp(mime_type, "video/nsv")) { + gf_cache_set_mime_type(sess->cache_entry, "audio/aac"); + } + sess->icy_bytes = 0; + sess->total_size = SIZE_IN_STREAM; + sess->status = GF_NETIO_DATA_EXCHANGE; } else if (!ContentLength && !sess->chunked) { - if (sess->http_read_type == GET) { - sess->total_size = SIZE_IN_STREAM; - sess->use_cache_file = 0; - sess->status = GF_NETIO_DATA_EXCHANGE; - sess->bytes_done = 0; - } else { - gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); - gf_dm_disconnect(sess, 0); - return GF_OK; - } - } else { - sess->total_size = ContentLength; - if (sess->use_cache_file && sess->http_read_type == GET ) { - e = gf_cache_open_write_cache(sess->cache_entry, sess); - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ( "[CACHE] Failed to open cache, error=%d\n", e)); - goto exit; - } - } - sess->status = GF_NETIO_DATA_EXCHANGE; - sess->bytes_done = 0; - } - } - - /* we may have existing data in this buffer ... */ - if (!e && (BodyStart < (s32) bytesRead)) { - if (sess->init_data) gf_free(sess->init_data); - sess->init_data_size = 0; - sess->init_data = NULL; + if (sess->http_read_type == GET) { + sess->total_size = SIZE_IN_STREAM; + sess->use_cache_file = 0; + sess->status = GF_NETIO_DATA_EXCHANGE; + sess->bytes_done = 0; + } else { + gf_dm_sess_notify_state(sess, GF_NETIO_DATA_TRANSFERED, GF_OK); + gf_dm_disconnect(sess, 0); + return GF_OK; + } + } else { + sess->total_size = ContentLength; + if (sess->use_cache_file && sess->http_read_type == GET ) { + e = gf_cache_open_write_cache(sess->cache_entry, sess); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ( "[CACHE] Failed to open cache, error=%d\n", e)); + goto exit; + } + } + sess->status = GF_NETIO_DATA_EXCHANGE; + sess->bytes_done = 0; + } + } + + /* we may have existing data in this buffer ... */ + if (!e && (BodyStart < (s32) bytesRead)) { + if (sess->init_data) gf_free(sess->init_data); + sess->init_data_size = 0; + sess->init_data = NULL; gf_dm_data_received(sess, (u8 *) sHTTP + BodyStart, bytesRead - BodyStart, 1, NULL); - } + } exit: - if (e) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Error parsing reply: %s for URL %s\n", gf_error_to_string(e), sess->orig_url )); + if (e) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTP] Error parsing reply: %s for URL %s\n", gf_error_to_string(e), sess->orig_url )); gf_cache_entry_set_delete_files_when_deleted(sess->cache_entry); gf_dm_remove_cache_entry_from_session(sess); sess->cache_entry = NULL; gf_dm_disconnect(sess, 0); - sess->status = GF_NETIO_STATE_ERROR; - sess->last_error = e; - gf_dm_sess_notify_state(sess, sess->status, e); - return e; - } + sess->status = GF_NETIO_STATE_ERROR; + sess->last_error = e; + gf_dm_sess_notify_state(sess, sess->status, e); + return e; + } /*DO NOT call parse_body yet, as the final user may not be connected to our session*/ return GF_OK; } @@ -2951,7 +2953,7 @@ exit: */ void http_do_requests(GF_DownloadSession *sess) { - char sHTTP[GF_DOWNLOAD_BUFFER_SIZE+1]; + char sHTTP[GF_DOWNLOAD_BUFFER_SIZE+1]; if (sess->reused_cache_entry) { if (!gf_cache_is_in_progress(sess->cache_entry)) { @@ -2961,21 +2963,21 @@ void http_do_requests(GF_DownloadSession *sess) return; } - switch (sess->status) { - case GF_NETIO_CONNECTED: - http_send_headers(sess, sHTTP); - break; - case GF_NETIO_WAIT_FOR_REPLY: - wait_for_header_and_parse(sess, sHTTP); - break; - case GF_NETIO_DATA_EXCHANGE: + switch (sess->status) { + case GF_NETIO_CONNECTED: + http_send_headers(sess, sHTTP); + break; + case GF_NETIO_WAIT_FOR_REPLY: + wait_for_header_and_parse(sess, sHTTP); + break; + case GF_NETIO_DATA_EXCHANGE: /*session has been reassigned, resend data retrieved in first GET reply to user but don't write to cache*/ if (sess->reassigned) { if (sess->icy_metaint > 0) { gf_icy_skip_data(sess, sess->icy_metaint, sess->init_data, sess->init_data_size); } else { - GF_NETIO_Parameter par; + GF_NETIO_Parameter par; par.msg_type = GF_NETIO_DATA_EXCHANGE; par.error = GF_OK; par.data = sess->init_data; @@ -2984,11 +2986,11 @@ void http_do_requests(GF_DownloadSession *sess) } sess->reassigned = 0; } - http_parse_remaining_body(sess, sHTTP); - break; - default: - break; - } + http_parse_remaining_body(sess, sHTTP); + break; + default: + break; + } } @@ -3023,7 +3025,7 @@ GF_Err gf_dm_wget(const char *url, const char *filename, u64 start_range, u64 en } GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, - const char *url, const char *filename, u64 start_range, u64 end_range) + const char *url, const char *filename, u64 start_range, u64 end_range) { GF_Err e; FILE * f; @@ -3031,9 +3033,9 @@ GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, if (!filename || !url || !dm) return GF_BAD_PARAM; f= fopen(filename, "w"); - if (!f){ - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[WGET] Failed to open file %s for write.\n", filename)); - return GF_IO_ERR; + if (!f) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[WGET] Failed to open file %s for write.\n", filename)); + return GF_IO_ERR; } dnload = gf_dm_sess_new_simple(dm, (char *)url, GF_NETIO_SESSION_NOT_THREADED, &wget_NetIO, f, &e); if (!dnload) { @@ -3044,7 +3046,7 @@ GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, if (end_range) { dnload->range_start = start_range; dnload->range_end = end_range; - dnload->needs_range = 1; + dnload->needs_range = 1; } if (e == GF_OK) { e = gf_dm_sess_process(dnload); @@ -3060,9 +3062,9 @@ GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, ch { GF_Err e; FILE * f; - GF_DownloadSession *dnload; + GF_DownloadSession *dnload; GF_DownloadManager *dm; - + if (!url || !out_data || !out_size) return GF_BAD_PARAM; f = gf_temp_file_new(); @@ -3076,7 +3078,7 @@ GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, ch fclose(f); return GF_OUT_OF_MEM; } - + dnload = gf_dm_sess_new_simple(dm, (char *)url, GF_NETIO_SESSION_NOT_THREADED, &wget_NetIO, f, &e); if (!dnload) { gf_dm_del(dm); @@ -3084,12 +3086,12 @@ GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, ch } dnload->use_cache_file = 0; dnload->disable_cache = 1; - if (!e) + if (!e) e = gf_dm_sess_process(dnload); - if (!e) + if (!e) e = gf_cache_close_write_cache(dnload->cache_entry, dnload, e == GF_OK); - + if (!e) { u32 size = ftell(f), read; *out_size = size; @@ -3132,110 +3134,110 @@ u32 gf_dm_sess_get_status(GF_DownloadSession *dnload) GF_Err gf_dm_sess_reset(GF_DownloadSession *sess) { - if (!sess) return GF_BAD_PARAM; - sess->status = GF_NETIO_SETUP; - sess->needs_range = 0; - sess->range_start = sess->range_end = 0; - sess->bytes_done = sess->bytes_per_sec = 0; - if (sess->init_data) gf_free(sess->init_data); - sess->init_data = NULL; - sess->init_data_size = 0; - sess->last_error = GF_OK; - sess->total_size = 0; - sess->start_time = 0; + if (!sess) return GF_BAD_PARAM; + sess->status = GF_NETIO_SETUP; + sess->needs_range = 0; + sess->range_start = sess->range_end = 0; + sess->bytes_done = sess->bytes_per_sec = 0; + if (sess->init_data) gf_free(sess->init_data); + sess->init_data = NULL; + sess->init_data_size = 0; + sess->last_error = GF_OK; + sess->total_size = 0; + sess->start_time = 0; sess->start_time_utc = 0; - return GF_OK; + return GF_OK; } const char * gf_cache_get_cache_filename_range( const GF_DownloadSession * sess, u64 startOffset, u64 endOffset ) { - u32 i, count; - if (!sess || !sess->dm || endOffset < startOffset) - return NULL; - count = gf_list_count(sess->dm->partial_downloads); - for (i = 0 ; i < count ; i++) { - GF_PartialDownload * pd = gf_list_get(sess->dm->partial_downloads, i); - assert( pd->filename && pd->url); - if (!strcmp(pd->url, sess->orig_url) && pd->startOffset == startOffset && pd->endOffset == endOffset) { - /* File already created, just return the file */ - return pd->filename; - } - } - { - /* Not found, we are gonna create the file */ - char * newFilename; - GF_PartialDownload * partial; - FILE * fw, *fr; - u32 maxLen; - const char * orig = gf_cache_get_cache_filename(sess->cache_entry); - if (orig == NULL) - return NULL; - /* 22 if 1G + 1G + 2 dashes */ - maxLen = (u32) strlen(orig) + 22; - newFilename = (char*)gf_malloc( maxLen ); - if (newFilename == NULL) - return NULL; - snprintf(newFilename, maxLen, "%s " LLU LLU, orig, startOffset, endOffset); - fw = gf_f64_open(newFilename, "wb"); - if (!fw) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot open partial cache file %s for write\n", newFilename)); - gf_free( newFilename ); - return NULL; - } - fr = gf_f64_open(orig, "rb"); - if (!fr) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot open full cache file %s\n", orig)); - gf_free( newFilename ); - fclose( fw ); - } - /* Now, we copy ! */ - { - char copyBuff[GF_DOWNLOAD_BUFFER_SIZE+1]; - s64 read, write, total; - total = endOffset - startOffset; - read = gf_f64_seek(fr, startOffset, SEEK_SET); - if (read != startOffset) { - GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot seek at right start offset in %s\n", orig)); - fclose( fr ); - fclose( fw ); - gf_free( newFilename ); - return NULL; - } - do { - read = fread(copyBuff, sizeof(char), MIN(sizeof(copyBuff), (size_t) total), fr); - if (read > 0) { - total-= read; - write = gf_fwrite(copyBuff, sizeof(char), (size_t) read, fw); - if (write != read) { - /* Something bad happened */ - fclose( fw ); - fclose (fr ); - gf_free( newFilename ); - return NULL; - } - } else { - if (read < 0) { - fclose( fw ); - fclose( fr ); - gf_free( newFilename ); - return NULL; - } - } - } while (total > 0); - fclose( fr ); - fclose (fw); - partial = gf_malloc( sizeof(GF_PartialDownload)); - if (partial == NULL) { - gf_free(newFilename); - return NULL; - } - partial->filename = newFilename; - partial->url = sess->orig_url; - partial->endOffset = endOffset; - partial->startOffset = startOffset; - gf_list_add(sess->dm->partial_downloads, partial); - return newFilename; - } - } + u32 i, count; + if (!sess || !sess->dm || endOffset < startOffset) + return NULL; + count = gf_list_count(sess->dm->partial_downloads); + for (i = 0 ; i < count ; i++) { + GF_PartialDownload * pd = gf_list_get(sess->dm->partial_downloads, i); + assert( pd->filename && pd->url); + if (!strcmp(pd->url, sess->orig_url) && pd->startOffset == startOffset && pd->endOffset == endOffset) { + /* File already created, just return the file */ + return pd->filename; + } + } + { + /* Not found, we are gonna create the file */ + char * newFilename; + GF_PartialDownload * partial; + FILE * fw, *fr; + u32 maxLen; + const char * orig = gf_cache_get_cache_filename(sess->cache_entry); + if (orig == NULL) + return NULL; + /* 22 if 1G + 1G + 2 dashes */ + maxLen = (u32) strlen(orig) + 22; + newFilename = (char*)gf_malloc( maxLen ); + if (newFilename == NULL) + return NULL; + snprintf(newFilename, maxLen, "%s " LLU LLU, orig, startOffset, endOffset); + fw = gf_f64_open(newFilename, "wb"); + if (!fw) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot open partial cache file %s for write\n", newFilename)); + gf_free( newFilename ); + return NULL; + } + fr = gf_f64_open(orig, "rb"); + if (!fr) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot open full cache file %s\n", orig)); + gf_free( newFilename ); + fclose( fw ); + } + /* Now, we copy ! */ + { + char copyBuff[GF_DOWNLOAD_BUFFER_SIZE+1]; + s64 read, write, total; + total = endOffset - startOffset; + read = gf_f64_seek(fr, startOffset, SEEK_SET); + if (read != startOffset) { + GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[CACHE] Cannot seek at right start offset in %s\n", orig)); + fclose( fr ); + fclose( fw ); + gf_free( newFilename ); + return NULL; + } + do { + read = fread(copyBuff, sizeof(char), MIN(sizeof(copyBuff), (size_t) total), fr); + if (read > 0) { + total-= read; + write = gf_fwrite(copyBuff, sizeof(char), (size_t) read, fw); + if (write != read) { + /* Something bad happened */ + fclose( fw ); + fclose (fr ); + gf_free( newFilename ); + return NULL; + } + } else { + if (read < 0) { + fclose( fw ); + fclose( fr ); + gf_free( newFilename ); + return NULL; + } + } + } while (total > 0); + fclose( fr ); + fclose (fw); + partial = gf_malloc( sizeof(GF_PartialDownload)); + if (partial == NULL) { + gf_free(newFilename); + return NULL; + } + partial->filename = newFilename; + partial->url = sess->orig_url; + partial->endOffset = endOffset; + partial->startOffset = startOffset; + gf_list_add(sess->dm->partial_downloads, partial); + return newFilename; + } + } } GF_EXPORT @@ -3258,7 +3260,7 @@ GF_Err gf_dm_sess_reassign(GF_DownloadSession *sess, u32 flags, gf_dm_user_io us sess->init_data = gf_malloc(sess->init_data_size); sess->init_data_size = fread(sess->init_data, 1, sess->init_data_size, fptr); gf_cache_close_write_cache(sess->cache_entry, sess, 0); - } + } gf_dm_remove_cache_entry_from_session(sess); sess->cache_entry = NULL; } @@ -3330,7 +3332,9 @@ const char *gf_dm_sess_get_header(GF_DownloadSession *sess, const char *name) count = gf_list_count(sess->headers); for (i=0; iheaders, i); - if (!strcmp(header->name, name)) return header->value; + if (!strcmp(header->name, name)) return header->value; } return NULL; } + +#endif diff --git a/src/utils/error.c b/src/utils/error.c index 1278d29..e28c224 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -90,7 +90,10 @@ static void gf_on_progress_std(const char *_title, u64 done, u64 total) } if (done==total) { u32 len = (u32) strlen(szT) + 40; - while (len) { fprintf(stderr, " "); len--; }; + while (len) { + fprintf(stderr, " "); + len--; + }; fprintf(stderr, "\r"); } else { @@ -128,7 +131,11 @@ void gf_set_progress_callback(void *_user_cbk, gf_on_progress_cbk _prog_cbk) } /*ENTRIES MUST BE IN THE SAME ORDER AS LOG_TOOL DECLARATION IN */ -static struct log_tool_info {u32 type; const char *name; u32 level; } global_log_tools [] = +static struct log_tool_info { + u32 type; + const char *name; + u32 level; +} global_log_tools [] = { { GF_LOG_CORE, "core", GF_LOG_WARNING }, { GF_LOG_CODING, "coding", GF_LOG_WARNING }, @@ -200,7 +207,7 @@ GF_Err gf_log_modify_tools_levels(const char *val) fprintf(stderr, "Unknown log level specified: %s\n", sep_level+1); return GF_BAD_PARAM; } - + sep_level[0] = 0; tools = val; while (tools) { @@ -210,7 +217,7 @@ GF_Err gf_log_modify_tools_levels(const char *val) if (sep) sep[0] = 0; if (!stricmp(tools, "all")) { - for (i=0; i= log_level) return GF_TRUE; return GF_FALSE; } @@ -329,7 +336,7 @@ Bool gf_log_tool_level_on(u32 log_tool, u32 log_level) void default_log_callback(void *cbck, u32 level, u32 tool, const char* fmt, va_list vlist) { #ifndef _WIN32_WCE - vfprintf(stderr, fmt, vlist); + vfprintf(stderr, fmt, vlist); #endif } @@ -357,7 +364,7 @@ void gf_log_set_strict_error(Bool strict) GF_EXPORT void gf_log_set_tool_level(u32 tool, u32 level) { - assert(tool<=GF_LOG_TOOL_MAX); + assert(tool<=GF_LOG_TOOL_MAX); if (tool==GF_LOG_ALL) { u32 i; for (i=0; i> 24) ^ *data++) & 0xff]; + for (i=0; i> 24) ^ *data++) & 0xff]; - return crc; + return crc; } @@ -575,126 +582,126 @@ const char *gpac_features() { const char *features = "" #ifdef GPAC_X64 - "GPAC_X64 " + "GPAC_X64 " #endif #ifdef GPAC_FIXED_POINT - "GPAC_FIXED_POINT " + "GPAC_FIXED_POINT " #endif #ifdef GPAC_MEMORY_TRACKING - "GPAC_MEMORY_TRACKING " + "GPAC_MEMORY_TRACKING " #endif #ifdef GPAC_BIG_ENDIAN - "GPAC_BIG_ENDIAN " + "GPAC_BIG_ENDIAN " #endif #ifdef GPAC_HAS_SSL - "GPAC_HAS_SSL " + "GPAC_HAS_SSL " #endif #ifdef GPAC_HAS_SPIDERMONKEY - "GPAC_HAS_SPIDERMONKEY " + "GPAC_HAS_SPIDERMONKEY " #endif #ifdef GPAC_HAS_JPEG - "GPAC_HAS_JPEG " + "GPAC_HAS_JPEG " #endif #ifdef GPAC_HAS_PNG - "GPAC_HAS_PNG " + "GPAC_HAS_PNG " #endif #ifdef GPAC_DISABLE_3D - "GPAC_DISABLE_3D " + "GPAC_DISABLE_3D " #endif #ifdef GPAC_USE_TINYGL - "GPAC_USE_TINYGL " + "GPAC_USE_TINYGL " #endif #ifdef GPAC_USE_OGL_ES - "GPAC_USE_OGL_ES " + "GPAC_USE_OGL_ES " #endif #if defined(_WIN32_WCE) #ifdef GPAC_USE_IGPP - "GPAC_USE_IGPP " + "GPAC_USE_IGPP " #endif #ifdef GPAC_USE_IGPP_HP - "GPAC_USE_IGPP_HP " + "GPAC_USE_IGPP_HP " #endif #endif #ifdef GPAC_DISABLE_SVG - "GPAC_DISABLE_SVG " + "GPAC_DISABLE_SVG " #endif #ifdef GPAC_DISABLE_VRML - "GPAC_DISABLE_VRML " + "GPAC_DISABLE_VRML " #endif #ifdef GPAC_MINIMAL_ODF - "GPAC_MINIMAL_ODF " + "GPAC_MINIMAL_ODF " #endif #ifdef GPAC_DISABLE_BIFS - "GPAC_DISABLE_BIFS " + "GPAC_DISABLE_BIFS " #endif #ifdef GPAC_DISABLE_QTVR - "GPAC_DISABLE_QTVR " + "GPAC_DISABLE_QTVR " #endif #ifdef GPAC_DISABLE_AVILIB - "GPAC_DISABLE_AVILIB " + "GPAC_DISABLE_AVILIB " #endif #ifdef GPAC_DISABLE_OGG - "GPAC_DISABLE_OGG " + "GPAC_DISABLE_OGG " #endif #ifdef GPAC_DISABLE_MPEG2PS - "GPAC_DISABLE_MPEG2PS " + "GPAC_DISABLE_MPEG2PS " #endif #ifdef GPAC_DISABLE_MPEG2PS - "GPAC_DISABLE_MPEG2TS " + "GPAC_DISABLE_MPEG2TS " #endif #ifdef GPAC_DISABLE_SENG - "GPAC_DISABLE_SENG " + "GPAC_DISABLE_SENG " #endif #ifdef GPAC_DISABLE_MEDIA_IMPORT - "GPAC_DISABLE_MEDIA_IMPORT " + "GPAC_DISABLE_MEDIA_IMPORT " #endif #ifdef GPAC_DISABLE_AV_PARSERS - "GPAC_DISABLE_AV_PARSERS " + "GPAC_DISABLE_AV_PARSERS " #endif #ifdef GPAC_DISABLE_MEDIA_EXPORT - "GPAC_DISABLE_MEDIA_EXPORT " + "GPAC_DISABLE_MEDIA_EXPORT " #endif #ifdef GPAC_DISABLE_SWF_IMPORT - "GPAC_DISABLE_SWF_IMPORT " + "GPAC_DISABLE_SWF_IMPORT " #endif #ifdef GPAC_DISABLE_SCENE_STATS - "GPAC_DISABLE_SCENE_STATS " + "GPAC_DISABLE_SCENE_STATS " #endif #ifdef GPAC_DISABLE_SCENE_DUMP - "GPAC_DISABLE_SCENE_DUMP " + "GPAC_DISABLE_SCENE_DUMP " #endif #ifdef GPAC_DISABLE_SCENE_ENCODER - "GPAC_DISABLE_SCENE_ENCODER " + "GPAC_DISABLE_SCENE_ENCODER " #endif #ifdef GPAC_DISABLE_LOADER_ISOM - "GPAC_DISABLE_LOADER_ISOM " + "GPAC_DISABLE_LOADER_ISOM " #endif #ifdef GPAC_DISABLE_OD_DUMP - "GPAC_DISABLE_OD_DUMP " + "GPAC_DISABLE_OD_DUMP " #endif #ifdef GPAC_DISABLE_MCRYPT - "GPAC_DISABLE_MCRYPT " + "GPAC_DISABLE_MCRYPT " #endif #ifdef GPAC_DISABLE_ISOM - "GPAC_DISABLE_MCRYPT " + "GPAC_DISABLE_MCRYPT " #endif #ifdef GPAC_DISABLE_ISOM_HINTING - "GPAC_DISABLE_ISOM_HINTING " + "GPAC_DISABLE_ISOM_HINTING " #endif #ifdef GPAC_DISABLE_ISOM_WRITE - "GPAC_DISABLE_ISOM_WRITE " + "GPAC_DISABLE_ISOM_WRITE " #endif #ifdef GPAC_DISABLE_ISOM_FRAGMENTS - "GPAC_DISABLE_ISOM_FRAGMENTS " + "GPAC_DISABLE_ISOM_FRAGMENTS " #endif #ifdef GPAC_DISABLE_LASER - "GPAC_DISABLE_LASER " + "GPAC_DISABLE_LASER " #endif #ifdef GPAC_DISABLE_STREAMING - "GPAC_DISABLE_STREAMING " + "GPAC_DISABLE_STREAMING " #endif -; + ; return features; } diff --git a/src/utils/gzio.cpp b/src/utils/gzio.cpp index 3b71742..b5bd2e1 100644 --- a/src/utils/gzio.cpp +++ b/src/utils/gzio.cpp @@ -21,7 +21,9 @@ typedef voidp gzFile; #ifndef NO_DUMMY_DECL #ifndef __SYMBIAN32__ -struct internal_state {int dummy;}; /* for buggy compilers */ +struct internal_state { + int dummy; +}; /* for buggy compilers */ #endif #endif @@ -38,7 +40,7 @@ struct internal_state {int dummy;}; /* for buggy compilers */ #ifdef __MVS__ # pragma map (fdopen , "\174\174FDOPEN") - FILE *fdopen(int, const char *); +FILE *fdopen(int, const char *); #endif #ifndef STDC @@ -61,16 +63,17 @@ static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; + "need dictionary", /* Z_NEED_DICT 2 */ + "stream end", /* Z_STREAM_END 1 */ + "", /* Z_OK 0 */ + "file error", /* Z_ERRNO (-1) */ + "stream error", /* Z_STREAM_ERROR (-2) */ + "data error", /* Z_DATA_ERROR (-3) */ + "insufficient memory", /* Z_MEM_ERROR (-4) */ + "buffer error", /* Z_BUF_ERROR (-5) */ + "incompatible version",/* Z_VERSION_ERROR (-6) */ + "" +}; #ifdef __SYMBIAN32__ #define GZ_EXPORT EXPORT_C @@ -79,22 +82,22 @@ const char * const z_errmsg[10] = { #endif typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - z_off_t start; /* start of compressed data in file (header skipped) */ - z_off_t in; /* bytes into deflate or inflate */ - z_off_t out; /* bytes out of deflate or inflate */ - int back; /* one character push-back */ - int last; /* true if push-back is last character */ + z_stream stream; + int z_err; /* error code for last stream operation */ + int z_eof; /* set if end of input file */ + FILE *file; /* .gz file */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ + uLong crc; /* crc32 of uncompressed data */ + char *msg; /* error message */ + char *path; /* path name for debugging only */ + int transparent; /* 1 if input file is not a .gz file */ + char mode; /* 'w' or 'r' */ + z_off_t start; /* start of compressed data in file (header skipped) */ + z_off_t in; /* bytes into deflate or inflate */ + z_off_t out; /* bytes out of deflate or inflate */ + int back; /* one character push-back */ + int last; /* true if push-back is last character */ } gz_stream; @@ -117,111 +120,111 @@ local uLong getLong OF((gz_stream *s)); */ local gzFile gz_open (const char *path, const char *mode, int fd) { - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->in = 0; - s->out = 0; - s->back = EOF; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - //} else if (*p == 'R') { - // strategy = Z_RLE; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { + int err; + int level = Z_DEFAULT_COMPRESSION; /* compression level */ + int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ + char *p = (char*)mode; + gz_stream *s; + char fmode[80]; /* copy of mode, without the compression level */ + char *m = fmode; + + if (!path || !mode) return Z_NULL; + + s = (gz_stream *)ALLOC(sizeof(gz_stream)); + if (!s) return Z_NULL; + + s->stream.zalloc = (alloc_func)0; + s->stream.zfree = (free_func)0; + s->stream.opaque = (voidpf)0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; + s->file = NULL; + s->z_err = Z_OK; + s->z_eof = 0; + s->in = 0; + s->out = 0; + s->back = EOF; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + + s->path = (char*)ALLOC(strlen(path)+1); + if (s->path == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + strcpy(s->path, path); /* do this early for debugging */ + + s->mode = '\0'; + do { + if (*p == 'r') s->mode = 'r'; + if (*p == 'w' || *p == 'a') s->mode = 'w'; + if (*p >= '0' && *p <= '9') { + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + //} else if (*p == 'R') { + // strategy = Z_RLE; + } else { + *m++ = *p; /* copy the mode */ + } + } while (*p++ && m != fmode + sizeof(fmode)); + if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; + + if (s->mode == 'w') { #ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; + err = Z_STREAM_ERROR; #else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ + err = deflateInit2(&(s->stream), level, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); + /* windowBits is passed < 0 to suppress zlib header */ - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); #endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->start = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * start anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->start = ftell(s->file) - s->stream.avail_in; - } - - return (gzFile)s; + if (err != Z_OK || s->outbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } else { + s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); + + err = inflateInit2(&(s->stream), -MAX_WBITS); + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are + * present after the compressed stream. + */ + if (err != Z_OK || s->inbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } + s->stream.avail_out = Z_BUFSIZE; + + errno = 0; + s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); + + if (s->file == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + if (s->mode == 'w') { + /* Write a very simple .gz header: + */ + fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + s->start = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * start anyway in write mode, so this initialization is not + * necessary. + */ + } else { + check_header(s); /* skip the .gz header */ + s->start = ftell(s->file) - s->stream.avail_in; + } + + return (gzFile)s; } /* =========================================================================== @@ -230,7 +233,7 @@ local gzFile gz_open (const char *path, const char *mode, int fd) GZ_EXPORT gzFile gzopen (const char *path, const char *mode) { - return gz_open (path, mode, -1); + return gz_open (path, mode, -1); } /* =========================================================================== @@ -240,12 +243,12 @@ gzFile gzopen (const char *path, const char *mode) GZ_EXPORT gzFile gzdopen (int fd, const char *mode) { - char name[46]; /* allow for up to 128-bit integers */ + char name[46]; /* allow for up to 128-bit integers */ - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "", fd); /* for debugging */ + if (fd < 0) return (gzFile)Z_NULL; + sprintf(name, "", fd); /* for debugging */ - return gz_open (name, mode, fd); + return gz_open (name, mode, fd); } /* =========================================================================== @@ -253,21 +256,21 @@ gzFile gzdopen (int fd, const char *mode) */ int gzsetparams (gzFile file, int level, int strategy) { - gz_stream *s = (gz_stream*)file; + gz_stream *s = (gz_stream*)file; - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { + /* Make room to allow flushing */ + if (s->stream.avail_out == 0) { - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + } + s->stream.avail_out = Z_BUFSIZE; + } - return deflateParams (&(s->stream), level, strategy); + return deflateParams (&(s->stream), level, strategy); } /* =========================================================================== @@ -277,19 +280,19 @@ int gzsetparams (gzFile file, int level, int strategy) */ local int get_byte(gz_stream *s) { - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; + if (s->z_eof) return EOF; + if (s->stream.avail_in == 0) { + errno = 0; + s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; } /* =========================================================================== @@ -303,205 +306,205 @@ local int get_byte(gz_stream *s) */ local void check_header(gz_stream *s) { - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Assure two bytes in the buffer so we can peek ahead -- handle case - where first byte of header is at the end of the buffer after the last - gzip segment */ - len = s->stream.avail_in; - if (len < 2) { - if (len) s->inbuf[0] = s->stream.next_in[0]; - errno = 0; - len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; - s->stream.avail_in += len; - s->stream.next_in = s->inbuf; - if (s->stream.avail_in < 2) { - s->transparent = s->stream.avail_in; - return; - } - } - - /* Peek ahead to check the gzip magic header */ - if (s->stream.next_in[0] != gz_magic[0] || - s->stream.next_in[1] != gz_magic[1]) { - s->transparent = 1; - return; - } - s->stream.avail_in -= 2; - s->stream.next_in += 2; - - /* Check the rest of the gzip header */ - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; + + /* Assure two bytes in the buffer so we can peek ahead -- handle case + where first byte of header is at the end of the buffer after the last + gzip segment */ + len = s->stream.avail_in; + if (len < 2) { + if (len) s->inbuf[0] = s->stream.next_in[0]; + errno = 0; + len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); + if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; + s->stream.avail_in += len; + s->stream.next_in = s->inbuf; + if (s->stream.avail_in < 2) { + s->transparent = s->stream.avail_in; + return; + } + } + + /* Peek ahead to check the gzip magic header */ + if (s->stream.next_in[0] != gz_magic[0] || + s->stream.next_in[1] != gz_magic[1]) { + s->transparent = 1; + return; + } + s->stream.avail_in -= 2; + s->stream.next_in += 2; + + /* Check the rest of the gzip header */ + method = get_byte(s); + flags = get_byte(s); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + s->z_err = Z_DATA_ERROR; + return; + } + + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) (void)get_byte(s); + + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) (void)get_byte(s); + } + s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; } - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ +/* =========================================================================== +* Cleanup then free the given gz_stream. Return a zlib error code. + Try freeing in the reverse order of allocations. +*/ local int destroy (gz_stream *s) { - int err = Z_OK; + int err = Z_OK; - if (!s) return Z_STREAM_ERROR; + if (!s) return Z_STREAM_ERROR; - TRYFREE(s->msg); + TRYFREE(s->msg); - if (s->stream.state != NULL) { - if (s->mode == 'w') { + if (s->stream.state != NULL) { + if (s->mode == 'w') { #ifdef NO_GZCOMPRESS - err = Z_STREAM_ERROR; + err = Z_STREAM_ERROR; #else - err = deflateEnd(&(s->stream)); + err = deflateEnd(&(s->stream)); #endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } + } + if (s->file != NULL && fclose(s->file)) { #ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ #endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; + err = Z_ERRNO; + } + if (s->z_err < 0) err = s->z_err; + + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s->path); + TRYFREE(s); + return err; } GZ_EXPORT int gzread (gzFile file, voidp buf, unsigned len) { - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - if (s->stream.avail_out && s->back != EOF) { - *next_out++ = s->back; - s->stream.next_out++; - s->stream.avail_out--; - s->back = EOF; - s->out++; - start++; - if (s->last) { - s->z_err = Z_STREAM_END; - return 1; - } - } - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= - (uInt)fread(next_out, 1, s->stream.avail_out, s->file); - } - len -= s->stream.avail_out; - s->in += len; - s->out += len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may be - * different from s->out in case of concatenated .gz files. - * Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - inflateReset(&(s->stream)); - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - if (len == s->stream.avail_out && - (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) - return -1; - return (int)(len - s->stream.avail_out); + gz_stream *s = (gz_stream*)file; + Bytef *start = (Bytef*)buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + + if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; + + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; + if (s->z_err == Z_STREAM_END) return 0; /* EOF */ + + next_out = (Byte*)buf; + s->stream.next_out = (Bytef*)buf; + s->stream.avail_out = len; + + if (s->stream.avail_out && s->back != EOF) { + *next_out++ = s->back; + s->stream.next_out++; + s->stream.avail_out--; + s->back = EOF; + s->out++; + start++; + if (s->last) { + s->z_err = Z_STREAM_END; + return 1; + } + } + + while (s->stream.avail_out != 0) { + + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= + (uInt)fread(next_out, 1, s->stream.avail_out, s->file); + } + len -= s->stream.avail_out; + s->in += len; + s->out += len; + if (len == 0) s->z_eof = 1; + return (int)len; + } + if (s->stream.avail_in == 0 && !s->z_eof) { + + errno = 0; + s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) { + s->z_err = Z_ERRNO; + break; + } + } + s->stream.next_in = s->inbuf; + } + s->in += s->stream.avail_in; + s->out += s->stream.avail_out; + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + s->in -= s->stream.avail_in; + s->out -= s->stream.avail_out; + + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; + + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); + /* The uncompressed length returned by above getlong() may be + * different from s->out in case of concatenated .gz files. + * Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + inflateReset(&(s->stream)); + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) break; + } + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + + if (len == s->stream.avail_out && + (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) + return -1; + return (int)(len - s->stream.avail_out); } @@ -511,9 +514,9 @@ int gzread (gzFile file, voidp buf, unsigned len) */ int gzgetc(gzFile file) { - unsigned char c; + unsigned char c; - return gzread(file, &c, 1) == 1 ? c : -1; + return gzread(file, &c, 1) == 1 ? c : -1; } @@ -522,15 +525,15 @@ int gzgetc(gzFile file) */ int gzungetc(int c, gzFile file) { - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; - s->back = c; - s->out--; - s->last = (s->z_err == Z_STREAM_END); - if (s->last) s->z_err = Z_OK; - s->z_eof = 0; - return c; + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; + s->back = c; + s->out--; + s->last = (s->z_err == Z_STREAM_END); + if (s->last) s->z_err = Z_OK; + s->z_eof = 0; + return c; } @@ -545,12 +548,12 @@ int gzungetc(int c, gzFile file) */ char * gzgets(gzFile file, char *buf, int len) { - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; + char *b = buf; + if (buf == Z_NULL || len <= 0) return Z_NULL; - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; + while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; + *buf = '\0'; + return b == buf && len > 0 ? Z_NULL : b; } @@ -561,34 +564,34 @@ char * gzgets(gzFile file, char *buf, int len) */ int gzwrite (gzFile file, void *const buf, unsigned len) { - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->in += s->stream.avail_in; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - s->in -= s->stream.avail_in; - s->out -= s->stream.avail_out; - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.next_in = (Bytef*)buf; + s->stream.avail_in = len; + + while (s->stream.avail_in != 0) { + + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + break; + } + s->stream.avail_out = Z_BUFSIZE; + } + s->in += s->stream.avail_in; + s->out += s->stream.avail_out; + s->z_err = deflate(&(s->stream), Z_NO_FLUSH); + s->in -= s->stream.avail_in; + s->out -= s->stream.avail_out; + if (s->z_err != Z_OK) break; + } + s->crc = crc32(s->crc, (const Bytef *)buf, len); + + return (int)(len - s->stream.avail_in); } @@ -602,69 +605,69 @@ int gzwrite (gzFile file, void *const buf, unsigned len) int gzprintf (gzFile file, const char *format, /* args */ ...) { - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len = 0; + char buf[Z_PRINTF_BUFSIZE]; + va_list va; + int len = 0; - buf[sizeof(buf) - 1] = 0; - va_start(va, format); + buf[sizeof(buf) - 1] = 0; + va_start(va, format); #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void - (void)vsprintf(buf, format, va); - va_end(va); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; + (void)vsprintf(buf, format, va); + va_end(va); + for (len = 0; len < sizeof(buf); len++) + if (buf[len] == 0) break; # else - len = vsprintf(buf, format, va); - va_end(va); + len = vsprintf(buf, format, va); + va_end(va); # endif #else # ifdef HAS_vsnprintf_void - (void)vsnprintf(buf, sizeof(buf), format, va); - va_end(va); - len = strlen(buf); + (void)vsnprintf(buf, sizeof(buf), format, va); + va_end(va); + len = strlen(buf); # else /*Benoit: to be checked if needed*/ - //len = vsnprintf(buf, sizeof(buf), format, va); - //va_end(va); + //len = vsnprintf(buf, sizeof(buf), format, va); + //va_end(va); # endif #endif - if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, (unsigned)len); + if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) + return 0; + return gzwrite(file, buf, (unsigned)len); } #else /* not ANSI C */ int gzprintf (gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, - int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20) + int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20) { - char buf[Z_PRINTF_BUFSIZE]; - int len; + char buf[Z_PRINTF_BUFSIZE]; + int len; - buf[sizeof(buf) - 1] = 0; + buf[sizeof(buf) - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < sizeof(buf); len++) - if (buf[len] == 0) break; + sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + for (len = 0; len < sizeof(buf); len++) + if (buf[len] == 0) break; # else - len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else # ifdef HAS_snprintf_void - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(buf); + snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(buf); # else - len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #endif - if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) - return 0; - return gzwrite(file, buf, len); + if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) + return 0; + return gzwrite(file, buf, len); } #endif @@ -674,9 +677,9 @@ int gzprintf (gzFile file, const char *format, int a1, int a2, int a3, int a4, i */ int gzputc(gzFile file, int c) { - unsigned char cc = (unsigned char) c; /* required for big endian systems */ + unsigned char cc = (unsigned char) c; /* required for big endian systems */ - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; + return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; } @@ -687,7 +690,7 @@ int gzputc(gzFile file, int c) */ int gzputs(gzFile file, const char *s) { - return gzwrite(file, (char*)s, (unsigned)strlen(s)); + return gzwrite(file, (char*)s, (unsigned)strlen(s)); } @@ -697,51 +700,51 @@ int gzputs(gzFile file, const char *s) */ local int do_flush (gzFile file, int flush) { - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->out += s->stream.avail_out; - s->z_err = deflate(&(s->stream), flush); - s->out -= s->stream.avail_out; - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; + uInt len; + int done = 0; + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.avail_in = 0; /* should be zero already anyway */ + + for (;;) { + len = Z_BUFSIZE - s->stream.avail_out; + + if (len != 0) { + if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) break; + s->out += s->stream.avail_out; + s->z_err = deflate(&(s->stream), flush); + s->out -= s->stream.avail_out; + + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; + + /* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; + } + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } int gzflush (gzFile file, int flush) { - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); + gz_stream *s = (gz_stream*)file; + int err = do_flush (file, flush); - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; + if (err) return err; + fflush(s->file); + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } #endif /* NO_GZCOMPRESS */ @@ -750,20 +753,20 @@ int gzflush (gzFile file, int flush) */ int gzrewind (gzFile file) { - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - if (!s->transparent) (void)inflateReset(&s->stream); - s->in = 0; - s->out = 0; - return fseek(s->file, s->start, SEEK_SET); + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'r') return -1; + + s->z_err = Z_OK; + s->z_eof = 0; + s->back = EOF; + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + s->crc = crc32(0L, Z_NULL, 0); + if (!s->transparent) (void)inflateReset(&s->stream); + s->in = 0; + s->out = 0; + return fseek(s->file, s->start, SEEK_SET); } /* =========================================================================== @@ -776,86 +779,86 @@ int gzrewind (gzFile file) */ z_off_t gzseek (gzFile file, z_off_t offset, int whence) { - gz_stream *s = (gz_stream*)file; + gz_stream *s = (gz_stream*)file; - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } + if (s == NULL || whence == SEEK_END || + s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { + return -1L; + } - if (s->mode == 'w') { + if (s->mode == 'w') { #ifdef NO_GZCOMPRESS - return -1L; + return -1L; #else - if (whence == SEEK_SET) { - offset -= s->in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - if (s->inbuf == Z_NULL) return -1L; - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return s->in; + if (whence == SEEK_SET) { + offset -= s->in; + } + if (offset < 0) return -1L; + + /* At this point, offset is the number of zero bytes to write. */ + if (s->inbuf == Z_NULL) { + s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ + if (s->inbuf == Z_NULL) return -1L; + zmemzero(s->inbuf, Z_BUFSIZE); + } + while (offset > 0) { + uInt size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (uInt)offset; + + size = gzwrite(file, s->inbuf, size); + if (size == 0) return -1L; + + offset -= size; + } + return s->in; #endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->back = EOF; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->in = s->out = offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if (offset >= s->out) { - offset -= s->out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - if (s->outbuf == Z_NULL) return -1L; - } - if (offset && s->back != EOF) { - s->back = EOF; - s->out++; - offset--; - if (s->last) s->z_err = Z_STREAM_END; - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return s->out; + } + /* Rest of function is for reading only */ + + /* compute absolute position */ + if (whence == SEEK_CUR) { + offset += s->out; + } + if (offset < 0) return -1L; + + if (s->transparent) { + /* map to fseek */ + s->back = EOF; + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; + + s->in = s->out = offset; + return offset; + } + + /* For a negative seek, rewind and use positive seek */ + if (offset >= s->out) { + offset -= s->out; + } else if (gzrewind(file) < 0) { + return -1L; + } + /* offset is now the number of bytes to skip. */ + + if (offset != 0 && s->outbuf == Z_NULL) { + s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + if (s->outbuf == Z_NULL) return -1L; + } + if (offset && s->back != EOF) { + s->back = EOF; + s->out++; + offset--; + if (s->last) s->z_err = Z_STREAM_END; + } + while (offset > 0) { + int size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (int)offset; + + size = gzread(file, s->outbuf, (uInt)size); + if (size <= 0) return -1L; + offset -= size; + } + return s->out; } /* =========================================================================== @@ -865,7 +868,7 @@ z_off_t gzseek (gzFile file, z_off_t offset, int whence) */ z_off_t gztell (gzFile file) { - return gzseek(file, 0L, SEEK_CUR); + return gzseek(file, 0L, SEEK_CUR); } /* =========================================================================== @@ -875,15 +878,15 @@ z_off_t gztell (gzFile file) GZ_EXPORT int gzeof (gzFile file) { - gz_stream *s = (gz_stream*)file; - - /* With concatenated compressed files that can have embedded - * crc trailers, z_eof is no longer the only/best indicator of EOF - * on a gz_stream. Handle end-of-stream error explicitly here. - */ - if (s == NULL || s->mode != 'r') return 0; - if (s->z_eof) return 1; - return s->z_err == Z_STREAM_END; + gz_stream *s = (gz_stream*)file; + + /* With concatenated compressed files that can have embedded + * crc trailers, z_eof is no longer the only/best indicator of EOF + * on a gz_stream. Handle end-of-stream error explicitly here. + */ + if (s == NULL || s->mode != 'r') return 0; + if (s->z_eof) return 1; + return s->z_err == Z_STREAM_END; } /* =========================================================================== @@ -891,10 +894,10 @@ int gzeof (gzFile file) */ int gzdirect (gzFile file) { - gz_stream *s = (gz_stream*)file; + gz_stream *s = (gz_stream*)file; - if (s == NULL || s->mode != 'r') return 0; - return s->transparent; + if (s == NULL || s->mode != 'r') return 0; + return s->transparent; } /* =========================================================================== @@ -902,11 +905,11 @@ int gzdirect (gzFile file) */ local void putLong (FILE *file, uLong x) { - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } + int n; + for (n = 0; n < 4; n++) { + fputc((int)(x & 0xff), file); + x >>= 8; + } } /* =========================================================================== @@ -915,15 +918,15 @@ local void putLong (FILE *file, uLong x) */ local uLong getLong (gz_stream *s) { - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; + uLong x = (uLong)get_byte(s); + int c; + + x += ((uLong)get_byte(s))<<8; + x += ((uLong)get_byte(s))<<16; + c = get_byte(s); + if (c == EOF) s->z_err = Z_DATA_ERROR; + x += ((uLong)c)<<24; + return x; } /* =========================================================================== @@ -933,22 +936,22 @@ local uLong getLong (gz_stream *s) GZ_EXPORT int gzclose (gzFile file) { - gz_stream *s = (gz_stream*)file; + gz_stream *s = (gz_stream*)file; - if (s == NULL) return Z_STREAM_ERROR; + if (s == NULL) return Z_STREAM_ERROR; - if (s->mode == 'w') { + if (s->mode == 'w') { #ifdef NO_GZCOMPRESS - return Z_STREAM_ERROR; + return Z_STREAM_ERROR; #else - if (do_flush (file, Z_FINISH) != Z_OK) - return destroy((gz_stream*)file); + if (do_flush (file, Z_FINISH) != Z_OK) + return destroy((gz_stream*)file); - putLong (s->file, s->crc); - putLong (s->file, (uLong)(s->in & 0xffffffff)); + putLong (s->file, s->crc); + putLong (s->file, (uLong)(s->in & 0xffffffff)); #endif - } - return destroy((gz_stream*)file); + } + return destroy((gz_stream*)file); } #ifdef STDC @@ -966,27 +969,27 @@ int gzclose (gzFile file) */ const char * gzerror (gzFile file, int *errnum) { - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; + char *m; + gz_stream *s = (gz_stream*)file; + + if (s == NULL) { + *errnum = Z_STREAM_ERROR; + return (const char*)ERR_MSG(Z_STREAM_ERROR); + } + *errnum = s->z_err; + if (*errnum == Z_OK) return (const char*)""; + + m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); + + if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); + + TRYFREE(s->msg); + s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); + if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); + strcpy(s->msg, s->path); + strcat(s->msg, ": "); + strcat(s->msg, m); + return (const char*)s->msg; } /* =========================================================================== @@ -994,10 +997,10 @@ const char * gzerror (gzFile file, int *errnum) */ void gzclearerr (gzFile file) { - gz_stream *s = (gz_stream*)file; + gz_stream *s = (gz_stream*)file; - if (s == NULL) return; - if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; - s->z_eof = 0; - clearerr(s->file); + if (s == NULL) return; + if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; + s->z_eof = 0; + clearerr(s->file); } diff --git a/src/utils/list.c b/src/utils/list.c index 39d7b12..36b69d9 100644 --- a/src/utils/list.c +++ b/src/utils/list.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -99,7 +99,7 @@ GF_EXPORT GF_Err gf_list_add(GF_List *ptr, void* item) { ItemSlot *entry; - if (! ptr) return GF_BAD_PARAM; + if (! ptr) return GF_BAD_PARAM; entry = (ItemSlot *) gf_malloc(sizeof(ItemSlot)); if (!entry) return GF_OUT_OF_MEM; entry->data = item; @@ -162,7 +162,7 @@ GF_Err gf_list_rem(GF_List *ptr, u32 itemNumber) u32 i; /* !! if head is null (empty list)*/ - if ( (! ptr) || (! ptr->head) || (ptr->head && !ptr->entryCount) || (itemNumber >= ptr->entryCount) ) + if ( (! ptr) || (! ptr->head) || (ptr->head && !ptr->entryCount) || (itemNumber >= ptr->entryCount) ) return GF_BAD_PARAM; /*we delete the head*/ @@ -297,7 +297,7 @@ GF_EXPORT GF_Err gf_list_add(GF_List *ptr, void* item) { ItemSlot *entry; - if (! ptr) return GF_BAD_PARAM; + if (! ptr) return GF_BAD_PARAM; entry = (ItemSlot *) gf_malloc(sizeof(ItemSlot)); if (!entry) return GF_OUT_OF_MEM; entry->data = item; @@ -368,7 +368,7 @@ GF_Err gf_list_rem(GF_List *ptr, u32 itemNumber) u32 i; /* !! if head is null (empty list)*/ - if ( (! ptr) || (! ptr->head) || (ptr->head && !ptr->entryCount) || (itemNumber >= ptr->entryCount) ) + if ( (! ptr) || (! ptr->head) || (ptr->head && !ptr->entryCount) || (itemNumber >= ptr->entryCount) ) return GF_BAD_PARAM; /*we delete the head*/ @@ -501,7 +501,7 @@ void gf_list_del(GF_List *ptr) GF_EXPORT GF_Err gf_list_add(GF_List *ptr, void* item) { - if (! ptr) return GF_BAD_PARAM; + if (! ptr) return GF_BAD_PARAM; ptr->entryCount ++; ptr->slots = (void **) gf_realloc(ptr->slots, ptr->entryCount*sizeof(void*)); @@ -601,7 +601,7 @@ GF_List * gf_list_new() nlist = (GF_List *) gf_malloc(sizeof(GF_List)); if (! nlist) return NULL; - + nlist->slots = NULL; nlist->entryCount = 0; nlist->allocSize = 0; @@ -625,7 +625,7 @@ static void realloc_chain(GF_List *ptr) GF_EXPORT GF_Err gf_list_add(GF_List *ptr, void* item) { - if (! ptr) return GF_BAD_PARAM; + if (! ptr) return GF_BAD_PARAM; if (ptr->allocSize==ptr->entryCount) realloc_chain(ptr); if (!ptr->slots) return GF_OUT_OF_MEM; @@ -733,7 +733,7 @@ void *gf_list_enum(GF_List *ptr, u32 *pos) } GF_EXPORT -void *gf_list_rev_enum(GF_List *ptr, u32 *pos){ +void *gf_list_rev_enum(GF_List *ptr, u32 *pos) { void *res; if (!ptr || !pos) return NULL; res = gf_list_get(ptr, gf_list_count (ptr) - *pos - 1 ); @@ -785,7 +785,7 @@ GF_Err gf_list_transfer(GF_List *l1, GF_List *l2) } GF_EXPORT -GF_List* gf_list_clone(GF_List *ptr){ +GF_List* gf_list_clone(GF_List *ptr) { GF_List* new_list; u32 i = 0; void* item; @@ -798,7 +798,7 @@ GF_List* gf_list_clone(GF_List *ptr){ } GF_EXPORT -void gf_list_reverse(GF_List *ptr){ +void gf_list_reverse(GF_List *ptr) { GF_List* saved_order; void* item; u32 i = 0; @@ -806,7 +806,7 @@ void gf_list_reverse(GF_List *ptr){ saved_order = gf_list_clone(ptr); gf_list_reset(ptr); - while ((item = gf_list_enum(saved_order, &i))){ + while ((item = gf_list_enum(saved_order, &i))) { gf_list_insert(ptr, item, 0); } @@ -814,10 +814,10 @@ void gf_list_reverse(GF_List *ptr){ } GF_EXPORT -void* gf_list_pop_front(GF_List *ptr){ +void* gf_list_pop_front(GF_List *ptr) { void * item; if (!ptr) return NULL; - + item = gf_list_get(ptr, 0); gf_list_rem(ptr, 0); @@ -825,10 +825,10 @@ void* gf_list_pop_front(GF_List *ptr){ } GF_EXPORT -void* gf_list_pop_back(GF_List *ptr){ +void* gf_list_pop_back(GF_List *ptr) { void * item; if (!ptr) return NULL; - + item = gf_list_last(ptr); gf_list_rem_last(ptr); diff --git a/src/utils/map.c b/src/utils/map.c index 62bcfa0..e1a55ff 100644 --- a/src/utils/map.c +++ b/src/utils/map.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -32,7 +32,7 @@ struct _tag_map }; GF_EXPORT -GF_Err gf_map_iter_set(GF_Map* map, GF_It_Map* it){ +GF_Err gf_map_iter_set(GF_Map* map, GF_It_Map* it) { /* Iterator must be associated to a map */ if (!map || !it) return GF_BAD_PARAM; @@ -44,15 +44,15 @@ GF_Err gf_map_iter_set(GF_Map* map, GF_It_Map* it){ } GF_EXPORT -void* gf_map_iter_has_next(GF_It_Map* it){ +void* gf_map_iter_has_next(GF_It_Map* it) { GF_Pair* next_pair = NULL; /* No iterator or iterator out of map */ if (!it || !(it->hash < it->map->hash_capacity)) return NULL; next_pair = (GF_Pair*)gf_list_get(it->map->pairs[it->hash], it->ilist); - - if (next_pair){ + + if (next_pair) { /* Next element founds in the same hash */ it->ilist++; return next_pair->value; @@ -65,7 +65,7 @@ void* gf_map_iter_has_next(GF_It_Map* it){ } GF_EXPORT -GF_Err gf_map_iter_reset(GF_It_Map* it){ +GF_Err gf_map_iter_reset(GF_It_Map* it) { if (!it) return GF_BAD_PARAM; it->hash = 0; it->ilist = 0; @@ -73,7 +73,7 @@ GF_Err gf_map_iter_reset(GF_It_Map* it){ } -GF_Pair* gf_pair_new(const char* key, u32 key_len, void* item){ +GF_Pair* gf_pair_new(const char* key, u32 key_len, void* item) { GF_Pair* new_pair; /* Allocate space for a new pair */ @@ -94,7 +94,7 @@ GF_Pair* gf_pair_new(const char* key, u32 key_len, void* item){ return new_pair; } -void gf_pair_del(GF_Pair* pair){ +void gf_pair_del(GF_Pair* pair) { gf_free(pair->key); gf_free(pair); } @@ -121,7 +121,7 @@ static Bool gf_pair_rem(GF_List* pairs, const char *key) u32 index = 0; while ((pair = (GF_Pair*)gf_list_get(pairs, index))) { - if (pair->key && !strcmp(pair->key, key)){ + if (pair->key && !strcmp(pair->key, key)) { gf_list_rem(pairs, index); gf_pair_del(pair); return GF_TRUE; @@ -175,7 +175,7 @@ void gf_map_del(GF_Map *ptr) if (!ptr) return; /* Iterate through the map and delete content */ - for (i = 0; i < ptr->hash_capacity; i++){ + for (i = 0; i < ptr->hash_capacity; i++) { bucket = ptr->pairs[i]; /* Bucket has not be allocated */ @@ -197,13 +197,13 @@ void gf_map_del(GF_Map *ptr) } GF_EXPORT -void gf_map_reset(GF_Map *ptr){ +void gf_map_reset(GF_Map *ptr) { u32 i, j; GF_Pair *pair; GF_List *bucket; /* Iterate through the map and delete content */ - for (i = 0; i < ptr->hash_capacity; i++){ + for (i = 0; i < ptr->hash_capacity; i++) { bucket = ptr->pairs[i]; /* Bucket has not be allocated */ @@ -224,7 +224,7 @@ void gf_map_reset(GF_Map *ptr){ } GF_EXPORT -void* gf_map_find(GF_Map *ptr, const char* key){ +void* gf_map_find(GF_Map *ptr, const char* key) { u32 index; GF_List *bucket; GF_Pair *pair; @@ -244,7 +244,7 @@ void* gf_map_find(GF_Map *ptr, const char* key){ GF_EXPORT -GF_Err gf_map_insert(GF_Map *ptr, const char* key, void* item){ +GF_Err gf_map_insert(GF_Map *ptr, const char* key, void* item) { u32 key_len, index; GF_List *bucket; GF_Pair *pair; @@ -264,7 +264,7 @@ GF_Err gf_map_insert(GF_Map *ptr, const char* key, void* item){ return GF_NOT_SUPPORTED; } - if (!bucket){ + if (!bucket) { /* No bucket has been assigned yet */ bucket = gf_list_new(); if (!bucket) return GF_OUT_OF_MEM; @@ -274,13 +274,13 @@ GF_Err gf_map_insert(GF_Map *ptr, const char* key, void* item){ pair = gf_pair_new(key, key_len, item); - if (!pair){ + if (!pair) { return GF_OUT_OF_MEM; } /* Store the new pair in the bucket */ err = gf_list_add(bucket, pair); - if(err != GF_OK){ + if(err != GF_OK) { gf_free(pair); return GF_OUT_OF_MEM; } @@ -304,7 +304,7 @@ Bool gf_map_rem(GF_Map *ptr, const char* key) } GF_EXPORT -u32 gf_map_count(const GF_Map *ptr){ +u32 gf_map_count(const GF_Map *ptr) { u32 i = 0; u32 count = 0; @@ -312,7 +312,7 @@ u32 gf_map_count(const GF_Map *ptr){ if (!ptr) return GF_BAD_PARAM; /* Iterate through all bucket of the map and count pair */ - for (; i < ptr->hash_capacity; i++ ){ + for (; i < ptr->hash_capacity; i++ ) { count += gf_list_count(ptr->pairs[i]); } @@ -320,7 +320,7 @@ u32 gf_map_count(const GF_Map *ptr){ } GF_EXPORT -Bool gf_map_has_key(GF_Map *ptr, const char* key){ +Bool gf_map_has_key(GF_Map *ptr, const char* key) { unsigned int index; GF_List *bucket; diff --git a/src/utils/math.c b/src/utils/math.c index f73a3ab..fac3c18 100644 --- a/src/utils/math.c +++ b/src/utils/math.c @@ -11,19 +11,19 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * * fixed-point trigo routines taken from freetype - * Copyright 1996-2001, 2002, 2004 by + * Copyright 1996-2001, 2002, 2004 by * David Turner, Robert Wilhelm, and Werner Lemberg. * License: FTL or GPL * @@ -84,15 +84,15 @@ static GFINLINE s32 gf_trig_prenorm(GF_Point2D *vec) z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y ); shift = 0; if ( z < ( 1L << 27 ) ) { - do { - shift++; - z <<= 1; - } - while ( z < ( 1L << 27 ) ); - - vec->x = x << shift; - vec->y = y << shift; - } + do { + shift++; + z <<= 1; + } + while ( z < ( 1L << 27 ) ); + + vec->x = x << shift; + vec->y = y << shift; + } else if ( z > ( 1L << 28 ) ) { do { shift++; @@ -102,8 +102,8 @@ static GFINLINE s32 gf_trig_prenorm(GF_Point2D *vec) vec->x = x >> shift; vec->y = y >> shift; shift = -shift; - } - return shift; + } + return shift; } #define ANGLE_RAD_TO_DEG(_th) ((s32) ( (((fix_s64)_th)*5729582)/100000)) @@ -165,7 +165,7 @@ static GFINLINE void gf_trig_pseudo_polarize(GF_Point2D *vec) while ( ++i < GF_TRIG_MAX_ITERS ); /* round theta */ - if ( theta >= 0 ) + if ( theta >= 0 ) theta = GF_PAD_ROUND( theta, 32 ); else theta = - GF_PAD_ROUND( -theta, 32 ); @@ -211,7 +211,7 @@ Fixed gf_divfix(Fixed a, Fixed b) { Fixed res; if (!a) return 0; - else if (!b) return (a<0) ? -(s32)0x7FFFFFFFL : (s32)0x7FFFFFFFL; + else if (!b) return (a<0) ? -(s32)0x7FFFFFFFL : (s32)0x7FFFFFFFL; else if (a==FIX_ONE) gppInv_16_32s(b, &res); else gppDiv_16_32s(a, b, &res); return res; @@ -287,8 +287,8 @@ GF_Point2D gf_v2d_from_polar(Fixed length, Fixed angle) #else gppSinCosLP_16_32s(angle, &sina, &cosa); #endif - vec.x = gf_mulfix(length, cosa); - vec.y = gf_mulfix(length, sina); + vec.x = gf_mulfix(length, cosa); + vec.y = gf_mulfix(length, sina); return vec; } @@ -323,18 +323,24 @@ Fixed gf_divfix(Fixed a, Fixed b) s32 s; u32 q; if (!a) return 0; - s = 1; - if ( a < 0 ) { a = -a; s = -1; } - if ( b < 0 ) { b = -b; s = -s; } + s = 1; + if ( a < 0 ) { + a = -a; + s = -1; + } + if ( b < 0 ) { + b = -b; + s = -s; + } - if ( b == 0 ) + if ( b == 0 ) /* check for division by 0 */ q = 0x7FFFFFFFL; - else { + else { /* compute result directly */ q = (u32)( ( ( (fix_s64)a << 16 ) + ( b >> 1 ) ) / b ); } - return ( s < 0 ? -(s32)q : (s32)q ); + return ( s < 0 ? -(s32)q : (s32)q ); } GF_EXPORT @@ -345,8 +351,10 @@ Fixed gf_mulfix(Fixed a, Fixed b) if ( !a || (b == 0x10000L)) return a; if (!b) return 0; - s = a; a = ABS(a); - s ^= b; b = ABS(b); + s = a; + a = ABS(a); + s ^= b; + b = ABS(b); ua = (u32)a; ub = (u32)b; @@ -407,45 +415,45 @@ static Fixed gf_trig_downscale(Fixed val) static void gf_trig_pseudo_rotate(GF_Point2D* vec, Fixed theta) { - s32 i; - Fixed x, y, xtemp; - const Fixed *arctanptr; + s32 i; + Fixed x, y, xtemp; + const Fixed *arctanptr; /*trig funcs are in degrees*/ theta = ANGLE_RAD_TO_DEG(theta); - x = vec->x; - y = vec->y; + x = vec->x; + y = vec->y; - /* Get angle between -90 and 90 degrees */ - while ( theta <= -GF_ANGLE_PI2 ) { + /* Get angle between -90 and 90 degrees */ + while ( theta <= -GF_ANGLE_PI2 ) { x = -x; y = -y; theta += GF_ANGLE_PI; - } + } - while ( theta > GF_ANGLE_PI2 ) { + while ( theta > GF_ANGLE_PI2 ) { x = -x; y = -y; theta -= GF_ANGLE_PI; - } + } - /* Initial pseudorotation, with left shift */ - arctanptr = gf_trig_arctan_table; - if ( theta < 0 ) { + /* Initial pseudorotation, with left shift */ + arctanptr = gf_trig_arctan_table; + if ( theta < 0 ) { xtemp = x + ( y << 1 ); y = y - ( x << 1 ); x = xtemp; theta += *arctanptr++; - } else { + } else { xtemp = x - ( y << 1 ); y = y + ( x << 1 ); x = xtemp; theta -= *arctanptr++; - } - /* Subsequent pseudorotations, with right shifts */ - i = 0; - do { + } + /* Subsequent pseudorotations, with right shifts */ + i = 0; + do { if ( theta < 0 ) { xtemp = x + ( y >> i ); y = y - ( x >> i ); @@ -457,10 +465,10 @@ static void gf_trig_pseudo_rotate(GF_Point2D* vec, Fixed theta) x = xtemp; theta -= *arctanptr++; } - } while ( ++i < GF_TRIG_MAX_ITERS ); + } while ( ++i < GF_TRIG_MAX_ITERS ); - vec->x = x; - vec->y = y; + vec->x = x; + vec->y = y; } /* these macros return 0 for positive numbers, and -1 for negative ones */ @@ -471,13 +479,13 @@ static void gf_trig_pseudo_rotate(GF_Point2D* vec, Fixed theta) static void gf_v2d_rotate(GF_Point2D *vec, Fixed angle) { - s32 shift; - GF_Point2D v; - + s32 shift; + GF_Point2D v; + v.x = vec->x; - v.y = vec->y; - - if ( angle && ( v.x != 0 || v.y != 0 ) ) { + v.y = vec->y; + + if ( angle && ( v.x != 0 || v.y != 0 ) ) { shift = gf_trig_prenorm( &v ); gf_trig_pseudo_rotate( &v, angle ); v.x = gf_trig_downscale( v.x ); @@ -493,57 +501,57 @@ static void gf_v2d_rotate(GF_Point2D *vec, Fixed angle) vec->x = v.x << shift; vec->y = v.y << shift; } - } + } } GF_EXPORT Fixed gf_v2d_len(GF_Point2D *vec) { - s32 shift; + s32 shift; GF_Point2D v; - v = *vec; + v = *vec; - /* handle trivial cases */ - if ( v.x == 0 ) { + /* handle trivial cases */ + if ( v.x == 0 ) { return ( v.y >= 0 ) ? v.y : -v.y; - } else if ( v.y == 0 ) { + } else if ( v.y == 0 ) { return ( v.x >= 0 ) ? v.x : -v.x; - } + } - /* general case */ - shift = gf_trig_prenorm( &v ); - gf_trig_pseudo_polarize( &v ); - v.x = gf_trig_downscale( v.x ); - if ( shift > 0 ) + /* general case */ + shift = gf_trig_prenorm( &v ); + gf_trig_pseudo_polarize( &v ); + v.x = gf_trig_downscale( v.x ); + if ( shift > 0 ) return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift; - return v.x << -shift; + return v.x << -shift; } GF_EXPORT void gf_v2d_polarize(GF_Point2D *vec, Fixed *length, Fixed *angle) { - s32 shift; + s32 shift; GF_Point2D v; - v = *vec; - if ( v.x == 0 && v.y == 0 ) + v = *vec; + if ( v.x == 0 && v.y == 0 ) return; - shift = gf_trig_prenorm( &v ); - gf_trig_pseudo_polarize( &v ); - v.x = gf_trig_downscale( v.x ); - *length = ( shift >= 0 ) ? ( v.x >> shift ) : ( v.x << -shift ); - *angle = v.y; + shift = gf_trig_prenorm( &v ); + gf_trig_pseudo_polarize( &v ); + v.x = gf_trig_downscale( v.x ); + *length = ( shift >= 0 ) ? ( v.x >> shift ) : ( v.x << -shift ); + *angle = v.y; } GF_EXPORT GF_Point2D gf_v2d_from_polar(Fixed length, Fixed angle) { GF_Point2D vec; - vec.x = length; - vec.y = 0; - gf_v2d_rotate(&vec, angle); + vec.x = length; + vec.y = 0; + gf_v2d_rotate(&vec, angle); return vec; } @@ -565,10 +573,10 @@ GF_EXPORT Fixed gf_tan(Fixed angle) { GF_Point2D v; - v.x = GF_TRIG_COSCALE >> 2; - v.y = 0; - gf_trig_pseudo_rotate( &v, angle ); - return gf_divfix( v.y, v.x ); + v.x = GF_TRIG_COSCALE >> 2; + v.y = 0; + gf_trig_pseudo_rotate( &v, angle ); + return gf_divfix( v.y, v.x ); } #endif @@ -577,15 +585,24 @@ Fixed gf_tan(Fixed angle) GF_EXPORT Fixed gf_muldiv(Fixed a, Fixed b, Fixed c) { - s32 s, d; + s32 s, d; if (!b || !a) return 0; - s = 1; - if ( a < 0 ) { a = -a; s = -1; } - if ( b < 0 ) { b = -b; s = -s; } - if ( c < 0 ) { c = -c; s = -s; } + s = 1; + if ( a < 0 ) { + a = -a; + s = -1; + } + if ( b < 0 ) { + b = -b; + s = -s; + } + if ( c < 0 ) { + c = -c; + s = -s; + } - d = (s32)( c > 0 ? ( (fix_s64)a * b + ( c >> 1 ) ) / c : 0x7FFFFFFFL); - return (Fixed) (( s > 0 ) ? d : -d); + d = (s32)( c > 0 ? ( (fix_s64)a * b + ( c >> 1 ) ) / c : 0x7FFFFFFFL); + return (Fixed) (( s > 0 ) ? d : -d); } @@ -598,7 +615,7 @@ Fixed gf_ceil(Fixed a) GF_EXPORT Fixed gf_floor(Fixed a) { - return (a >= 0) ? (a & ~0xFFFFL) : -((-a) & ~0xFFFFL); + return (a >= 0) ? (a & ~0xFFFFL) : -((-a) & ~0xFFFFL); } @@ -624,8 +641,8 @@ GF_EXPORT GF_Point2D gf_v2d_from_polar(Fixed length, Fixed angle) { GF_Point2D vec; - vec.x = length*(Float) cos(angle); - vec.y = length*(Float) sin(angle); + vec.x = length*(Float) cos(angle); + vec.y = length*(Float) sin(angle); return vec; } @@ -665,16 +682,16 @@ Fixed gf_v2d_distance(GF_Point2D *a, GF_Point2D *b) GF_EXPORT Fixed gf_angle_diff(Fixed angle1, Fixed angle2) { - Fixed delta = angle2 - angle1; + Fixed delta = angle2 - angle1; #ifdef GPAC_FIXED_POINT - delta %= GF_2PI; + delta %= GF_2PI; if (delta < 0) delta += GF_2PI; - if (delta > GF_PI) delta -= GF_2PI; + if (delta > GF_PI) delta -= GF_2PI; #else while (delta < 0) delta += GF_2PI; - while (delta > GF_PI) delta -= GF_2PI; + while (delta > GF_PI) delta -= GF_2PI; #endif - return delta; + return delta; } @@ -745,7 +762,7 @@ void gf_mx2d_add_rotation(GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle) gf_mx2d_init(tmp); gf_mx2d_add_translation(_this, -cx, -cy); - + tmp.m[0] = gf_cos(angle); tmp.m[4] = tmp.m[0]; tmp.m[3] = gf_sin(angle); @@ -960,13 +977,22 @@ GF_IRect gf_rect_pixelize(GF_Rect *r) /*adds @rc2 to @rc1 - the new @rc1 contains the old @rc1 and @rc2*/ GF_EXPORT -void gf_rect_union(GF_Rect *rc1, GF_Rect *rc2) +void gf_rect_union(GF_Rect *rc1, GF_Rect *rc2) { - if (!rc1->width || !rc1->height) {*rc1=*rc2; return;} + if (!rc1->width || !rc1->height) { + *rc1=*rc2; + return; + } if (!rc2->width || !rc2->height) return; - if (rc2->x < rc1->x) { rc1->width += rc1->x - rc2->x; rc1->x = rc2->x; } + if (rc2->x < rc1->x) { + rc1->width += rc1->x - rc2->x; + rc1->x = rc2->x; + } if (rc2->x + rc2->width > rc1->x+rc1->width) rc1->width = rc2->x + rc2->width - rc1->x; - if (rc2->y > rc1->y) { rc1->height += rc2->y - rc1->y; rc1->y = rc2->y; } + if (rc2->y > rc1->y) { + rc1->height += rc2->y - rc1->y; + rc1->y = rc2->y; + } if (rc2->y - rc2->height < rc1->y - rc1->height) rc1->height = rc1->y - rc2->y + rc2->height; } @@ -974,7 +1000,10 @@ GF_EXPORT GF_Rect gf_rect_center(Fixed w, Fixed h) { GF_Rect rc; - rc.x=-w/2; rc.y=h/2; rc.width=w; rc.height=h; + rc.x=-w/2; + rc.y=h/2; + rc.width=w; + rc.height=h; return rc; } @@ -990,8 +1019,8 @@ Bool gf_rect_overlaps(GF_Rect rc1, GF_Rect rc2) } GF_EXPORT -Bool gf_rect_equal(GF_Rect rc1, GF_Rect rc2) -{ +Bool gf_rect_equal(GF_Rect rc1, GF_Rect rc2) +{ if ( (rc1.x == rc2.x) && (rc1.y == rc2.y) && (rc1.width == rc2.width) && (rc1.height == rc2.height) ) return GF_TRUE; return GF_FALSE; @@ -1052,7 +1081,7 @@ Fixed gf_vec_lensq(GF_Vec v) return ( gf_mulfix(v.x, v.x) + gf_mulfix(v.y, v.y) + gf_mulfix(v.z, v.z) ) << 16; } return gf_mulfix(v.x, v.x) + gf_mulfix(v.y, v.y) + gf_mulfix(v.z, v.z); - + #endif } @@ -1072,8 +1101,12 @@ Fixed gf_vec_dot(GF_Vec v1, GF_Vec v2) /*both high-magnitude vectors, use low precision on frac part to avoid overflow if only one is, the dot product should still be in proper range*/ if (0&&VEC_HIGH_MAG(v1) && VEC_HIGH_MAG(v2)) { - v1.x>>=4; v1.y>>=4; v1.z>>=4; - v2.x>>=4; v2.y>>=4; v2.z>>=4; + v1.x>>=4; + v1.y>>=4; + v1.z>>=4; + v2.x>>=4; + v2.y>>=4; + v2.z>>=4; return ( gf_mulfix(v1.x, v2.x) + gf_mulfix(v1.y, v2.y) + gf_mulfix(v1.z, v2.z) ) << 8; } return gf_mulfix(v1.x, v2.x) + gf_mulfix(v1.y, v2.y) + gf_mulfix(v1.z, v2.z); @@ -1090,7 +1123,7 @@ void gf_vec_norm(GF_Vec *v) gppVec3DNormalize_16_32s((GPP_VEC3D *) &v); #else Fixed __res = gf_vec_len(*v); - v->x = gf_divfix(v->x, __res); + v->x = gf_divfix(v->x, __res); v->y = gf_divfix(v->y, __res); v->z = gf_divfix(v->z, __res); #endif @@ -1100,8 +1133,8 @@ GF_EXPORT GF_Vec gf_vec_scale(GF_Vec v, Fixed f) { GF_Vec res; - res.x = gf_mulfix(v.x, f); - res.y = gf_mulfix(v.y, f); + res.x = gf_mulfix(v.x, f); + res.y = gf_mulfix(v.y, f); res.z = gf_mulfix(v.z, f); return res; } @@ -1125,8 +1158,12 @@ GF_Vec gf_vec_cross(GF_Vec v1, GF_Vec v2) /*both high-magnitude vectors, use low precision on frac part to avoid overflow if only one is, the cross product should still be in proper range*/ if (VEC_HIGH_MAG(v1) && VEC_HIGH_MAG(v2)) { - v1.x>>=8; v1.y>>=8; v1.z>>=8; - v2.x>>=8; v2.y>>=8; v2.z>>=8; + v1.x>>=8; + v1.y>>=8; + v1.z>>=8; + v2.x>>=8; + v2.y>>=8; + v2.z>>=8; res.x = gf_mulfix(v1.y, v2.z) - gf_mulfix(v2.y, v1.z); res.y = gf_mulfix(v2.x, v1.z) - gf_mulfix(v1.x, v2.z); res.z = gf_mulfix(v1.x, v2.y) - gf_mulfix(v2.x, v1.y); @@ -1146,11 +1183,17 @@ GF_Vec gf_vec_cross(GF_Vec v1, GF_Vec v2) #else GF_EXPORT -Fixed gf_vec_len(GF_Vec v) { return gf_sqrt(v.x*v.x + v.y*v.y + v.z*v.z); } +Fixed gf_vec_len(GF_Vec v) { + return gf_sqrt(v.x*v.x + v.y*v.y + v.z*v.z); +} GF_EXPORT -Fixed gf_vec_lensq(GF_Vec v) { return v.x*v.x + v.y*v.y + v.z*v.z; } +Fixed gf_vec_lensq(GF_Vec v) { + return v.x*v.x + v.y*v.y + v.z*v.z; +} GF_EXPORT -Fixed gf_vec_dot(GF_Vec v1, GF_Vec v2) { return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; } +Fixed gf_vec_dot(GF_Vec v1, GF_Vec v2) { + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; +} GF_EXPORT void gf_vec_norm(GF_Vec *v) { @@ -1158,7 +1201,7 @@ void gf_vec_norm(GF_Vec *v) if (!__res ) return; if (__res == FIX_ONE) return; __res = 1.0f/__res; - v->x *= __res; + v->x *= __res; v->y *= __res; v->z *= __res; } @@ -1167,8 +1210,8 @@ GF_EXPORT GF_Vec gf_vec_scale(GF_Vec v, Fixed f) { GF_Vec res = v; - res.x *= f; - res.y *= f; + res.x *= f; + res.y *= f; res.z *= f; return res; } @@ -1209,42 +1252,42 @@ void gf_mx_apply_rect(GF_Matrix *mat, GF_Rect *rc) GF_EXPORT void gf_mx_add_matrix(GF_Matrix *mat, GF_Matrix *mul) { - GF_Matrix tmp; + GF_Matrix tmp; gf_mx_init(tmp); - tmp.m[0] = gf_mulfix(mat->m[0],mul->m[0]) + gf_mulfix(mat->m[4],mul->m[1]) + gf_mulfix(mat->m[8],mul->m[2]); - tmp.m[4] = gf_mulfix(mat->m[0],mul->m[4]) + gf_mulfix(mat->m[4],mul->m[5]) + gf_mulfix(mat->m[8],mul->m[6]); - tmp.m[8] = gf_mulfix(mat->m[0],mul->m[8]) + gf_mulfix(mat->m[4],mul->m[9]) + gf_mulfix(mat->m[8],mul->m[10]); - tmp.m[12]= gf_mulfix(mat->m[0],mul->m[12]) + gf_mulfix(mat->m[4],mul->m[13]) + gf_mulfix(mat->m[8],mul->m[14]) + mat->m[12]; - tmp.m[1] = gf_mulfix(mat->m[1],mul->m[0]) + gf_mulfix(mat->m[5],mul->m[1]) + gf_mulfix(mat->m[9],mul->m[2]); - tmp.m[5] = gf_mulfix(mat->m[1],mul->m[4]) + gf_mulfix(mat->m[5],mul->m[5]) + gf_mulfix(mat->m[9],mul->m[6]); - tmp.m[9] = gf_mulfix(mat->m[1],mul->m[8]) + gf_mulfix(mat->m[5],mul->m[9]) + gf_mulfix(mat->m[9],mul->m[10]); - tmp.m[13]= gf_mulfix(mat->m[1],mul->m[12]) + gf_mulfix(mat->m[5],mul->m[13]) + gf_mulfix(mat->m[9],mul->m[14]) + mat->m[13]; - tmp.m[2] = gf_mulfix(mat->m[2],mul->m[0]) + gf_mulfix(mat->m[6],mul->m[1]) + gf_mulfix(mat->m[10],mul->m[2]); - tmp.m[6] = gf_mulfix(mat->m[2],mul->m[4]) + gf_mulfix(mat->m[6],mul->m[5]) + gf_mulfix(mat->m[10],mul->m[6]); - tmp.m[10]= gf_mulfix(mat->m[2],mul->m[8]) + gf_mulfix(mat->m[6],mul->m[9]) + gf_mulfix(mat->m[10],mul->m[10]); - tmp.m[14]= gf_mulfix(mat->m[2],mul->m[12]) + gf_mulfix(mat->m[6],mul->m[13]) + gf_mulfix(mat->m[10],mul->m[14]) + mat->m[14]; + tmp.m[0] = gf_mulfix(mat->m[0],mul->m[0]) + gf_mulfix(mat->m[4],mul->m[1]) + gf_mulfix(mat->m[8],mul->m[2]); + tmp.m[4] = gf_mulfix(mat->m[0],mul->m[4]) + gf_mulfix(mat->m[4],mul->m[5]) + gf_mulfix(mat->m[8],mul->m[6]); + tmp.m[8] = gf_mulfix(mat->m[0],mul->m[8]) + gf_mulfix(mat->m[4],mul->m[9]) + gf_mulfix(mat->m[8],mul->m[10]); + tmp.m[12]= gf_mulfix(mat->m[0],mul->m[12]) + gf_mulfix(mat->m[4],mul->m[13]) + gf_mulfix(mat->m[8],mul->m[14]) + mat->m[12]; + tmp.m[1] = gf_mulfix(mat->m[1],mul->m[0]) + gf_mulfix(mat->m[5],mul->m[1]) + gf_mulfix(mat->m[9],mul->m[2]); + tmp.m[5] = gf_mulfix(mat->m[1],mul->m[4]) + gf_mulfix(mat->m[5],mul->m[5]) + gf_mulfix(mat->m[9],mul->m[6]); + tmp.m[9] = gf_mulfix(mat->m[1],mul->m[8]) + gf_mulfix(mat->m[5],mul->m[9]) + gf_mulfix(mat->m[9],mul->m[10]); + tmp.m[13]= gf_mulfix(mat->m[1],mul->m[12]) + gf_mulfix(mat->m[5],mul->m[13]) + gf_mulfix(mat->m[9],mul->m[14]) + mat->m[13]; + tmp.m[2] = gf_mulfix(mat->m[2],mul->m[0]) + gf_mulfix(mat->m[6],mul->m[1]) + gf_mulfix(mat->m[10],mul->m[2]); + tmp.m[6] = gf_mulfix(mat->m[2],mul->m[4]) + gf_mulfix(mat->m[6],mul->m[5]) + gf_mulfix(mat->m[10],mul->m[6]); + tmp.m[10]= gf_mulfix(mat->m[2],mul->m[8]) + gf_mulfix(mat->m[6],mul->m[9]) + gf_mulfix(mat->m[10],mul->m[10]); + tmp.m[14]= gf_mulfix(mat->m[2],mul->m[12]) + gf_mulfix(mat->m[6],mul->m[13]) + gf_mulfix(mat->m[10],mul->m[14]) + mat->m[14]; memcpy(mat->m, tmp.m, sizeof(Fixed)*16); } GF_EXPORT void gf_mx_add_matrix_2d(GF_Matrix *mat, GF_Matrix2D *mat2D) { - GF_Matrix tmp; + GF_Matrix tmp; gf_mx_init(tmp); - tmp.m[0] = gf_mulfix(mat->m[0],mat2D->m[0]) + gf_mulfix(mat->m[4],mat2D->m[3]); - tmp.m[4] = gf_mulfix(mat->m[0],mat2D->m[1]) + gf_mulfix(mat->m[4],mat2D->m[4]); - tmp.m[8] = mat->m[8]; - tmp.m[12]= gf_mulfix(mat->m[0],mat2D->m[2]) + gf_mulfix(mat->m[4],mat2D->m[5]) + mat->m[12]; - tmp.m[1] = gf_mulfix(mat->m[1],mat2D->m[0]) + gf_mulfix(mat->m[5],mat2D->m[3]); - tmp.m[5] = gf_mulfix(mat->m[1],mat2D->m[1]) + gf_mulfix(mat->m[5],mat2D->m[4]); - tmp.m[9] = mat->m[9]; - tmp.m[13]= gf_mulfix(mat->m[1],mat2D->m[2]) + gf_mulfix(mat->m[5],mat2D->m[5]) + mat->m[13]; - tmp.m[2] = gf_mulfix(mat->m[2],mat2D->m[0]) + gf_mulfix(mat->m[6],mat2D->m[3]); - tmp.m[6] = gf_mulfix(mat->m[2],mat2D->m[1]) + gf_mulfix(mat->m[6],mat2D->m[4]); - tmp.m[10]= mat->m[10]; - tmp.m[14]= gf_mulfix(mat->m[2],mat2D->m[2]) + gf_mulfix(mat->m[6],mat2D->m[5]) + mat->m[14]; + tmp.m[0] = gf_mulfix(mat->m[0],mat2D->m[0]) + gf_mulfix(mat->m[4],mat2D->m[3]); + tmp.m[4] = gf_mulfix(mat->m[0],mat2D->m[1]) + gf_mulfix(mat->m[4],mat2D->m[4]); + tmp.m[8] = mat->m[8]; + tmp.m[12]= gf_mulfix(mat->m[0],mat2D->m[2]) + gf_mulfix(mat->m[4],mat2D->m[5]) + mat->m[12]; + tmp.m[1] = gf_mulfix(mat->m[1],mat2D->m[0]) + gf_mulfix(mat->m[5],mat2D->m[3]); + tmp.m[5] = gf_mulfix(mat->m[1],mat2D->m[1]) + gf_mulfix(mat->m[5],mat2D->m[4]); + tmp.m[9] = mat->m[9]; + tmp.m[13]= gf_mulfix(mat->m[1],mat2D->m[2]) + gf_mulfix(mat->m[5],mat2D->m[5]) + mat->m[13]; + tmp.m[2] = gf_mulfix(mat->m[2],mat2D->m[0]) + gf_mulfix(mat->m[6],mat2D->m[3]); + tmp.m[6] = gf_mulfix(mat->m[2],mat2D->m[1]) + gf_mulfix(mat->m[6],mat2D->m[4]); + tmp.m[10]= mat->m[10]; + tmp.m[14]= gf_mulfix(mat->m[2],mat2D->m[2]) + gf_mulfix(mat->m[6],mat2D->m[5]) + mat->m[14]; memcpy(mat->m, tmp.m, sizeof(Fixed)*16); } @@ -1271,9 +1314,9 @@ void gf_mx_add_scale(GF_Matrix *mat, Fixed sx, Fixed sy, Fixed sz) Fixed tmp[3]; u32 i, j; - tmp[0] = sx; - tmp[1] = sy; - tmp[2] = sz; + tmp[0] = sx; + tmp[1] = sy; + tmp[2] = sz; for (i=0; i<3; i++) { for (j=0; j<3; j++) { @@ -1292,24 +1335,29 @@ void gf_mx_add_rotation(GF_Matrix *mat, Fixed angle, Fixed x, Fixed y, Fixed z) Fixed sin_a = gf_sin(angle); Fixed icos_a = FIX_ONE - cos_a; - if (nor && (nor!=FIX_ONE)) { - x = gf_divfix(x, nor); - y = gf_divfix(y, nor); - z = gf_divfix(z, nor); + if (nor && (nor!=FIX_ONE)) { + x = gf_divfix(x, nor); + y = gf_divfix(y, nor); + z = gf_divfix(z, nor); } - xx = gf_mulfix(x,x); yy = gf_mulfix(y,y); zz = gf_mulfix(z,z); xy = gf_mulfix(x,y); xz = gf_mulfix(x,z); yz = gf_mulfix(y,z); + xx = gf_mulfix(x,x); + yy = gf_mulfix(y,y); + zz = gf_mulfix(z,z); + xy = gf_mulfix(x,y); + xz = gf_mulfix(x,z); + yz = gf_mulfix(y,z); gf_mx_init(tmp); - tmp.m[0] = gf_mulfix(icos_a,xx) + cos_a; - tmp.m[1] = gf_mulfix(xy,icos_a) + gf_mulfix(z,sin_a); - tmp.m[2] = gf_mulfix(xz,icos_a) - gf_mulfix(y,sin_a); - + tmp.m[0] = gf_mulfix(icos_a,xx) + cos_a; + tmp.m[1] = gf_mulfix(xy,icos_a) + gf_mulfix(z,sin_a); + tmp.m[2] = gf_mulfix(xz,icos_a) - gf_mulfix(y,sin_a); + tmp.m[4] = gf_mulfix(xy,icos_a) - gf_mulfix(z,sin_a); - tmp.m[5] = gf_mulfix(icos_a,yy) + cos_a; - tmp.m[6] = gf_mulfix(yz,icos_a) + gf_mulfix(x,sin_a); + tmp.m[5] = gf_mulfix(icos_a,yy) + cos_a; + tmp.m[6] = gf_mulfix(yz,icos_a) + gf_mulfix(x,sin_a); tmp.m[8] = gf_mulfix(xz,icos_a) + gf_mulfix(y,sin_a); - tmp.m[9] = gf_mulfix(yz,icos_a) - gf_mulfix(x,sin_a); - tmp.m[10]= gf_mulfix(icos_a,zz) + cos_a; + tmp.m[9] = gf_mulfix(yz,icos_a) - gf_mulfix(x,sin_a); + tmp.m[10]= gf_mulfix(icos_a,zz) + cos_a; gf_mx_add_matrix(mat, &tmp); } @@ -1469,7 +1517,7 @@ GF_EXPORT void gf_mx_lookat(GF_Matrix *mx, GF_Vec eye, GF_Vec center, GF_Vec upVector) { GF_Vec f, s, u; - + gf_vec_diff(f, center, eye); gf_vec_norm(&f); gf_vec_norm(&upVector); @@ -1477,7 +1525,7 @@ void gf_mx_lookat(GF_Matrix *mx, GF_Vec eye, GF_Vec center, GF_Vec upVector) s = gf_vec_cross(f, upVector); u = gf_vec_cross(s, f); gf_mx_init(*mx); - + mx->m[0] = s.x; mx->m[1] = u.x; mx->m[2] = -f.x; @@ -1501,54 +1549,66 @@ void gf_mx_decompose(GF_Matrix *mx, GF_Vec *translate, GF_Vec *scale, GF_Vec4 *r Fixed locmat[16]; GF_Matrix tmp; GF_Vec row0, row1, row2; - Fixed shear_xy, shear_xz, shear_yz; + Fixed shear_xy, shear_xz, shear_yz; assert(mx->m[15]); memcpy(locmat, mx->m, sizeof(Fixed)*16); /*no perspective*/ - locmat[3] = locmat[7] = locmat[11] = 0; + locmat[3] = locmat[7] = locmat[11] = 0; /*normalize*/ - for (i=0; i<4; i++) { - for (j=0; j<4; j++) { - locmat[4*i+j] = gf_divfix(locmat[4*i+j], locmat[15]); - } - } - translate->x = locmat[12]; - translate->y = locmat[13]; - translate->z = locmat[14]; - locmat[12] = locmat[13] = locmat[14] = 0; - row0.x = locmat[0]; row0.y = locmat[1]; row0.z = locmat[2]; - row1.x = locmat[4]; row1.y = locmat[5]; row1.z = locmat[6]; - row2.x = locmat[8]; row2.y = locmat[9]; row2.z = locmat[10]; - - scale->x = gf_vec_len(row0); - gf_vec_norm(&row0); - shear_xy = gf_vec_dot(row0, row1); - row1.x -= gf_mulfix(row0.x, shear_xy); - row1.y -= gf_mulfix(row0.y, shear_xy); - row1.z -= gf_mulfix(row0.z, shear_xy); - - scale->y = gf_vec_len(row1); - gf_vec_norm(&row1); - shear->x = gf_divfix(shear_xy, scale->y); - - shear_xz = gf_vec_dot(row0, row2); - row2.x -= gf_mulfix(row0.x, shear_xz); - row2.y -= gf_mulfix(row0.y, shear_xz); - row2.z -= gf_mulfix(row0.z, shear_xz); - shear_yz = gf_vec_dot(row1, row2); - row2.x -= gf_mulfix(row1.x, shear_yz); - row2.y -= gf_mulfix(row1.y, shear_yz); - row2.z -= gf_mulfix(row1.z, shear_yz); - - scale->z = gf_vec_len(row2); - gf_vec_norm(&row2); - shear->y = gf_divfix(shear_xz, scale->z); - shear->z = gf_divfix(shear_yz, scale->z); - - locmat[0] = row0.x; locmat[4] = row1.x; locmat[8] = row2.x; - locmat[1] = row0.y; locmat[5] = row1.y; locmat[9] = row2.y; - locmat[2] = row0.z; locmat[6] = row1.z; locmat[10] = row2.z; + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { + locmat[4*i+j] = gf_divfix(locmat[4*i+j], locmat[15]); + } + } + translate->x = locmat[12]; + translate->y = locmat[13]; + translate->z = locmat[14]; + locmat[12] = locmat[13] = locmat[14] = 0; + row0.x = locmat[0]; + row0.y = locmat[1]; + row0.z = locmat[2]; + row1.x = locmat[4]; + row1.y = locmat[5]; + row1.z = locmat[6]; + row2.x = locmat[8]; + row2.y = locmat[9]; + row2.z = locmat[10]; + + scale->x = gf_vec_len(row0); + gf_vec_norm(&row0); + shear_xy = gf_vec_dot(row0, row1); + row1.x -= gf_mulfix(row0.x, shear_xy); + row1.y -= gf_mulfix(row0.y, shear_xy); + row1.z -= gf_mulfix(row0.z, shear_xy); + + scale->y = gf_vec_len(row1); + gf_vec_norm(&row1); + shear->x = gf_divfix(shear_xy, scale->y); + + shear_xz = gf_vec_dot(row0, row2); + row2.x -= gf_mulfix(row0.x, shear_xz); + row2.y -= gf_mulfix(row0.y, shear_xz); + row2.z -= gf_mulfix(row0.z, shear_xz); + shear_yz = gf_vec_dot(row1, row2); + row2.x -= gf_mulfix(row1.x, shear_yz); + row2.y -= gf_mulfix(row1.y, shear_yz); + row2.z -= gf_mulfix(row1.z, shear_yz); + + scale->z = gf_vec_len(row2); + gf_vec_norm(&row2); + shear->y = gf_divfix(shear_xz, scale->z); + shear->z = gf_divfix(shear_yz, scale->z); + + locmat[0] = row0.x; + locmat[4] = row1.x; + locmat[8] = row2.x; + locmat[1] = row0.y; + locmat[5] = row1.y; + locmat[9] = row2.y; + locmat[2] = row0.z; + locmat[6] = row1.z; + locmat[10] = row2.z; memcpy(tmp.m, locmat, sizeof(Fixed)*16); quat = gf_quat_from_matrix(&tmp); @@ -1562,17 +1622,23 @@ void gf_mx_apply_bbox_sphere(GF_Matrix *mx, GF_BBox *box) gf_mx_apply_vec(mx, &box->min_edge); gf_mx_apply_vec(mx, &box->max_edge); - if (box->min_edge.x > box->max_edge.x) + if (box->min_edge.x > box->max_edge.x) { - var = box->min_edge.x; box->min_edge.x = box->max_edge.x; box->max_edge.x = var; + var = box->min_edge.x; + box->min_edge.x = box->max_edge.x; + box->max_edge.x = var; } - if (box->min_edge.y > box->max_edge.y) + if (box->min_edge.y > box->max_edge.y) { - var = box->min_edge.y; box->min_edge.y = box->max_edge.y; box->max_edge.y = var; + var = box->min_edge.y; + box->min_edge.y = box->max_edge.y; + box->max_edge.y = var; } - if (box->min_edge.z > box->max_edge.z) + if (box->min_edge.z > box->max_edge.z) { - var = box->min_edge.z; box->min_edge.z = box->max_edge.z; box->max_edge.z = var; + var = box->min_edge.z; + box->min_edge.z = box->max_edge.z; + box->max_edge.z = var; } gf_bbox_refresh(box); } @@ -1583,12 +1649,15 @@ void gf_mx_apply_bbox(GF_Matrix *mx, GF_BBox *box) u32 i; GF_Vec v[4]; v[0] = box->min_edge; - v[1] = box->min_edge; v[1].x = box->max_edge.x; - v[2] = box->min_edge; v[2].y = box->max_edge.y; - v[3] = box->min_edge; v[3].z = box->max_edge.z; + v[1] = box->min_edge; + v[1].x = box->max_edge.x; + v[2] = box->min_edge; + v[2].y = box->max_edge.y; + v[3] = box->min_edge; + v[3].z = box->max_edge.z; box->max_edge.x = box->max_edge.y = box->max_edge.z = -FIX_MAX; box->min_edge.x = box->min_edge.y = box->min_edge.z = FIX_MAX; - for (i=0;i<4; i++) { + for (i=0; i<4; i++) { gf_mx_apply_vec(mx, &v[i]); if (box->min_edge.x > v[i].x) box->min_edge.x = v[i].x; if (box->min_edge.y > v[i].y) box->min_edge.y = v[i].y; @@ -1620,10 +1689,22 @@ void gf_mx_rotate_vector(GF_Matrix *mx, GF_Vec *pt) GF_EXPORT void gf_mx_rotation_matrix_from_vectors(GF_Matrix *mx, GF_Vec x, GF_Vec y, GF_Vec z) { - mx->m[0] = x.x; mx->m[1] = y.x; mx->m[2] = z.x; mx->m[3] = 0; - mx->m[4] = x.y; mx->m[5] = y.y; mx->m[6] = z.y; mx->m[7] = 0; - mx->m[8] = x.z; mx->m[9] = y.z; mx->m[10] = z.z; mx->m[11] = 0; - mx->m[12] = 0; mx->m[13] = 0; mx->m[14] = 0; mx->m[15] = FIX_ONE; + mx->m[0] = x.x; + mx->m[1] = y.x; + mx->m[2] = z.x; + mx->m[3] = 0; + mx->m[4] = x.y; + mx->m[5] = y.y; + mx->m[6] = z.y; + mx->m[7] = 0; + mx->m[8] = x.z; + mx->m[9] = y.z; + mx->m[10] = z.z; + mx->m[11] = 0; + mx->m[12] = 0; + mx->m[13] = 0; + mx->m[14] = 0; + mx->m[15] = FIX_ONE; } @@ -1631,24 +1712,24 @@ void gf_mx_rotation_matrix_from_vectors(GF_Matrix *mx, GF_Vec x, GF_Vec y, GF_Ve GF_EXPORT void gf_mx_add_matrix_4x4(GF_Matrix *mat, GF_Matrix *mul) { - GF_Matrix tmp; + GF_Matrix tmp; gf_mx_init(tmp); - tmp.m[0] = gf_mulfix(mat->m[0],mul->m[0]) + gf_mulfix(mat->m[4],mul->m[1]) + gf_mulfix(mat->m[8],mul->m[2]) + gf_mulfix(mat->m[12],mul->m[3]); - tmp.m[1] = gf_mulfix(mat->m[1],mul->m[0]) + gf_mulfix(mat->m[5],mul->m[1]) + gf_mulfix(mat->m[9],mul->m[2]) + gf_mulfix(mat->m[13],mul->m[3]); - tmp.m[2] = gf_mulfix(mat->m[2],mul->m[0]) + gf_mulfix(mat->m[6],mul->m[1]) + gf_mulfix(mat->m[10],mul->m[2]) + gf_mulfix(mat->m[14],mul->m[3]); - tmp.m[3] = gf_mulfix(mat->m[3],mul->m[0]) + gf_mulfix(mat->m[7],mul->m[1]) + gf_mulfix(mat->m[11],mul->m[2]) + gf_mulfix(mat->m[15],mul->m[3]); - tmp.m[4] = gf_mulfix(mat->m[0],mul->m[4]) + gf_mulfix(mat->m[4],mul->m[5]) + gf_mulfix(mat->m[8],mul->m[6]) + gf_mulfix(mat->m[12],mul->m[7]); - tmp.m[5] = gf_mulfix(mat->m[1],mul->m[4]) + gf_mulfix(mat->m[5],mul->m[5]) + gf_mulfix(mat->m[9],mul->m[6]) + gf_mulfix(mat->m[13],mul->m[7]); - tmp.m[6] = gf_mulfix(mat->m[2],mul->m[4]) + gf_mulfix(mat->m[6],mul->m[5]) + gf_mulfix(mat->m[10],mul->m[6]) + gf_mulfix(mat->m[14],mul->m[7]); - tmp.m[7] = gf_mulfix(mat->m[3],mul->m[4]) + gf_mulfix(mat->m[7],mul->m[5]) + gf_mulfix(mat->m[11],mul->m[6]) + gf_mulfix(mat->m[15],mul->m[7]); - tmp.m[8] = gf_mulfix(mat->m[0],mul->m[8]) + gf_mulfix(mat->m[4],mul->m[9]) + gf_mulfix(mat->m[8],mul->m[10]) + gf_mulfix(mat->m[12],mul->m[11]); - tmp.m[9] = gf_mulfix(mat->m[1],mul->m[8]) + gf_mulfix(mat->m[5],mul->m[9]) + gf_mulfix(mat->m[9],mul->m[10]) + gf_mulfix(mat->m[13],mul->m[11]); - tmp.m[10] = gf_mulfix(mat->m[2],mul->m[8]) + gf_mulfix(mat->m[6],mul->m[9]) + gf_mulfix(mat->m[10],mul->m[10]) + gf_mulfix(mat->m[14],mul->m[11]); - tmp.m[11] = gf_mulfix(mat->m[3],mul->m[8]) + gf_mulfix(mat->m[7],mul->m[9]) + gf_mulfix(mat->m[11],mul->m[10]) + gf_mulfix(mat->m[15],mul->m[11]); - tmp.m[12] = gf_mulfix(mat->m[0],mul->m[12]) + gf_mulfix(mat->m[4],mul->m[13]) + gf_mulfix(mat->m[8],mul->m[14]) + gf_mulfix(mat->m[12],mul->m[15]); - tmp.m[13] = gf_mulfix(mat->m[1],mul->m[12]) + gf_mulfix(mat->m[5],mul->m[13]) + gf_mulfix(mat->m[9],mul->m[14]) + gf_mulfix(mat->m[13],mul->m[15]); - tmp.m[14] = gf_mulfix(mat->m[2],mul->m[12]) + gf_mulfix(mat->m[6],mul->m[13]) + gf_mulfix(mat->m[10],mul->m[14]) + gf_mulfix(mat->m[14],mul->m[15]); - tmp.m[15] = gf_mulfix(mat->m[3],mul->m[12]) + gf_mulfix(mat->m[7],mul->m[13]) + gf_mulfix(mat->m[11],mul->m[14]) + gf_mulfix(mat->m[15],mul->m[15]); + tmp.m[0] = gf_mulfix(mat->m[0],mul->m[0]) + gf_mulfix(mat->m[4],mul->m[1]) + gf_mulfix(mat->m[8],mul->m[2]) + gf_mulfix(mat->m[12],mul->m[3]); + tmp.m[1] = gf_mulfix(mat->m[1],mul->m[0]) + gf_mulfix(mat->m[5],mul->m[1]) + gf_mulfix(mat->m[9],mul->m[2]) + gf_mulfix(mat->m[13],mul->m[3]); + tmp.m[2] = gf_mulfix(mat->m[2],mul->m[0]) + gf_mulfix(mat->m[6],mul->m[1]) + gf_mulfix(mat->m[10],mul->m[2]) + gf_mulfix(mat->m[14],mul->m[3]); + tmp.m[3] = gf_mulfix(mat->m[3],mul->m[0]) + gf_mulfix(mat->m[7],mul->m[1]) + gf_mulfix(mat->m[11],mul->m[2]) + gf_mulfix(mat->m[15],mul->m[3]); + tmp.m[4] = gf_mulfix(mat->m[0],mul->m[4]) + gf_mulfix(mat->m[4],mul->m[5]) + gf_mulfix(mat->m[8],mul->m[6]) + gf_mulfix(mat->m[12],mul->m[7]); + tmp.m[5] = gf_mulfix(mat->m[1],mul->m[4]) + gf_mulfix(mat->m[5],mul->m[5]) + gf_mulfix(mat->m[9],mul->m[6]) + gf_mulfix(mat->m[13],mul->m[7]); + tmp.m[6] = gf_mulfix(mat->m[2],mul->m[4]) + gf_mulfix(mat->m[6],mul->m[5]) + gf_mulfix(mat->m[10],mul->m[6]) + gf_mulfix(mat->m[14],mul->m[7]); + tmp.m[7] = gf_mulfix(mat->m[3],mul->m[4]) + gf_mulfix(mat->m[7],mul->m[5]) + gf_mulfix(mat->m[11],mul->m[6]) + gf_mulfix(mat->m[15],mul->m[7]); + tmp.m[8] = gf_mulfix(mat->m[0],mul->m[8]) + gf_mulfix(mat->m[4],mul->m[9]) + gf_mulfix(mat->m[8],mul->m[10]) + gf_mulfix(mat->m[12],mul->m[11]); + tmp.m[9] = gf_mulfix(mat->m[1],mul->m[8]) + gf_mulfix(mat->m[5],mul->m[9]) + gf_mulfix(mat->m[9],mul->m[10]) + gf_mulfix(mat->m[13],mul->m[11]); + tmp.m[10] = gf_mulfix(mat->m[2],mul->m[8]) + gf_mulfix(mat->m[6],mul->m[9]) + gf_mulfix(mat->m[10],mul->m[10]) + gf_mulfix(mat->m[14],mul->m[11]); + tmp.m[11] = gf_mulfix(mat->m[3],mul->m[8]) + gf_mulfix(mat->m[7],mul->m[9]) + gf_mulfix(mat->m[11],mul->m[10]) + gf_mulfix(mat->m[15],mul->m[11]); + tmp.m[12] = gf_mulfix(mat->m[0],mul->m[12]) + gf_mulfix(mat->m[4],mul->m[13]) + gf_mulfix(mat->m[8],mul->m[14]) + gf_mulfix(mat->m[12],mul->m[15]); + tmp.m[13] = gf_mulfix(mat->m[1],mul->m[12]) + gf_mulfix(mat->m[5],mul->m[13]) + gf_mulfix(mat->m[9],mul->m[14]) + gf_mulfix(mat->m[13],mul->m[15]); + tmp.m[14] = gf_mulfix(mat->m[2],mul->m[12]) + gf_mulfix(mat->m[6],mul->m[13]) + gf_mulfix(mat->m[10],mul->m[14]) + gf_mulfix(mat->m[14],mul->m[15]); + tmp.m[15] = gf_mulfix(mat->m[3],mul->m[12]) + gf_mulfix(mat->m[7],mul->m[13]) + gf_mulfix(mat->m[11],mul->m[14]) + gf_mulfix(mat->m[15],mul->m[15]); memcpy(mat->m, tmp.m, sizeof(Fixed)*16); } @@ -1682,17 +1763,37 @@ Bool gf_mx_inverse_4x4(GF_Matrix *mx) Fixed *r0, *r1, *r2, *r3; GF_Matrix res; r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; - r0[0] = mx->m[0]; r0[1] = mx->m[4]; r0[2] = mx->m[8]; r0[3] = mx->m[12]; r0[4] = FIX_ONE; r0[5] = r0[6] = r0[7] = 0; - r1[0] = mx->m[1]; r1[1] = mx->m[5]; r1[2] = mx->m[9]; r1[3] = mx->m[13]; r1[5] = FIX_ONE; r1[4] = r1[6] = r1[7] = 0; - r2[0] = mx->m[2]; r2[1] = mx->m[6]; r2[2] = mx->m[10]; r2[3] = mx->m[14]; r2[6] = FIX_ONE; r2[4] = r2[5] = r2[7] = 0; - r3[0] = mx->m[3]; r3[1] = mx->m[7]; r3[2] = mx->m[11]; r3[3] = mx->m[15]; r3[7] = FIX_ONE; r3[4] = r3[5] = r3[6] = 0; + r0[0] = mx->m[0]; + r0[1] = mx->m[4]; + r0[2] = mx->m[8]; + r0[3] = mx->m[12]; + r0[4] = FIX_ONE; + r0[5] = r0[6] = r0[7] = 0; + r1[0] = mx->m[1]; + r1[1] = mx->m[5]; + r1[2] = mx->m[9]; + r1[3] = mx->m[13]; + r1[5] = FIX_ONE; + r1[4] = r1[6] = r1[7] = 0; + r2[0] = mx->m[2]; + r2[1] = mx->m[6]; + r2[2] = mx->m[10]; + r2[3] = mx->m[14]; + r2[6] = FIX_ONE; + r2[4] = r2[5] = r2[7] = 0; + r3[0] = mx->m[3]; + r3[1] = mx->m[7]; + r3[2] = mx->m[11]; + r3[3] = mx->m[15]; + r3[7] = FIX_ONE; + r3[4] = r3[5] = r3[6] = 0; /* choose pivot - or die */ if (ABS(r3[0]) > ABS(r2[0])) SWAP_ROWS(r3, r2); if (ABS(r2[0]) > ABS(r1[0])) SWAP_ROWS(r2, r1); if (ABS(r1[0]) > ABS(r0[0])) SWAP_ROWS(r1, r0); if (r0[0]==0) return 0; - + /*eliminate first variable*/ m1 = gf_divfix(r1[0], r0[0]); m2 = gf_divfix(r2[0], r0[0]); @@ -1738,7 +1839,7 @@ Bool gf_mx_inverse_4x4(GF_Matrix *mx) if (fabs(r3[1]) > fabs(r2[1])) SWAP_ROWS(r3, r2); if (fabs(r2[1]) > fabs(r1[1])) SWAP_ROWS(r2, r1); if (r1[1]==0) return 0; - + /* eliminate second variable */ m2 = gf_divfix(r2[1], r1[1]); m3 = gf_divfix(r3[1], r1[1]); @@ -1773,8 +1874,11 @@ Bool gf_mx_inverse_4x4(GF_Matrix *mx) /* eliminate third variable */ m3 = gf_divfix(r3[2], r2[2]); - r3[3] -= gf_mulfix(m3, r2[3]); r3[4] -= gf_mulfix(m3, r2[4]); r3[5] -= gf_mulfix(m3, r2[5]); - r3[6] -= gf_mulfix(m3, r2[6]); r3[7] -= gf_mulfix(m3, r2[7]); + r3[3] -= gf_mulfix(m3, r2[3]); + r3[4] -= gf_mulfix(m3, r2[4]); + r3[5] -= gf_mulfix(m3, r2[5]); + r3[6] -= gf_mulfix(m3, r2[6]); + r3[7] -= gf_mulfix(m3, r2[7]); /* last check */ if (r3[3]==0) return 0; @@ -1783,17 +1887,23 @@ Bool gf_mx_inverse_4x4(GF_Matrix *mx) r3[5] = gf_mulfix(r3[5], s); r3[6] = gf_mulfix(r3[6], s); r3[7] = gf_mulfix(r3[7], s); - + m2 = r2[3]; /* now back substitute row 2 */ s = gf_invfix(r2[2]); r2[4] = gf_mulfix(s, r2[4] - gf_mulfix(r3[4], m2)); r2[5] = gf_mulfix(s, r2[5] - gf_mulfix(r3[5], m2)); r2[6] = gf_mulfix(s, r2[6] - gf_mulfix(r3[6], m2)); r2[7] = gf_mulfix(s, r2[7] - gf_mulfix(r3[7], m2)); - m1 = r1[3]; - r1[4] -= gf_mulfix(r3[4], m1); r1[5] -= gf_mulfix(r3[5], m1); r1[6] -= gf_mulfix(r3[6], m1); r1[7] -= gf_mulfix(r3[7], m1); + m1 = r1[3]; + r1[4] -= gf_mulfix(r3[4], m1); + r1[5] -= gf_mulfix(r3[5], m1); + r1[6] -= gf_mulfix(r3[6], m1); + r1[7] -= gf_mulfix(r3[7], m1); m0 = r0[3]; - r0[4] -= gf_mulfix(r3[4], m0); r0[5] -= gf_mulfix(r3[5], m0); r0[6] -= gf_mulfix(r3[6], m0); r0[7] -= gf_mulfix(r3[7], m0); + r0[4] -= gf_mulfix(r3[4], m0); + r0[5] -= gf_mulfix(r3[5], m0); + r0[6] -= gf_mulfix(r3[6], m0); + r0[7] -= gf_mulfix(r3[7], m0); m1 = r1[2]; /* now back substitute row 1 */ s = gf_invfix(r1[1]); @@ -1802,20 +1912,34 @@ Bool gf_mx_inverse_4x4(GF_Matrix *mx) r1[6] = gf_mulfix(s, r1[6] - gf_mulfix(r2[6], m1)); r1[7] = gf_mulfix(s, r1[7] - gf_mulfix(r2[7], m1)); m0 = r0[2]; - r0[4] -= gf_mulfix(r2[4], m0); r0[5] -= gf_mulfix(r2[5], m0); r0[6] -= gf_mulfix(r2[6], m0); r0[7] -= gf_mulfix(r2[7], m0); + r0[4] -= gf_mulfix(r2[4], m0); + r0[5] -= gf_mulfix(r2[5], m0); + r0[6] -= gf_mulfix(r2[6], m0); + r0[7] -= gf_mulfix(r2[7], m0); m0 = r0[1]; /* now back substitute row 0 */ s = gf_invfix(r0[0]); r0[4] = gf_mulfix(s, r0[4] - gf_mulfix(r1[4], m0)); - r0[5] = gf_mulfix(s, r0[5] - gf_mulfix(r1[5], m0)); + r0[5] = gf_mulfix(s, r0[5] - gf_mulfix(r1[5], m0)); r0[6] = gf_mulfix(s, r0[6] - gf_mulfix(r1[6], m0)); r0[7] = gf_mulfix(s, r0[7] - gf_mulfix(r1[7], m0)); gf_mx_init(res) - res.m[0] = r0[4]; res.m[4] = r0[5]; res.m[8] = r0[6]; res.m[12] = r0[7]; - res.m[1] = r1[4]; res.m[5] = r1[5], res.m[9] = r1[6]; res.m[13] = r1[7]; - res.m[2] = r2[4]; res.m[6] = r2[5]; res.m[10] = r2[6]; res.m[14] = r2[7]; - res.m[3] = r3[4]; res.m[7] = r3[5]; res.m[11] = r3[6]; res.m[15] = r3[7]; + res.m[0] = r0[4]; + res.m[4] = r0[5]; + res.m[8] = r0[6]; + res.m[12] = r0[7]; + res.m[1] = r1[4]; + res.m[5] = r1[5], res.m[9] = r1[6]; + res.m[13] = r1[7]; + res.m[2] = r2[4]; + res.m[6] = r2[5]; + res.m[10] = r2[6]; + res.m[14] = r2[7]; + res.m[3] = r3[4]; + res.m[7] = r3[5]; + res.m[11] = r3[6]; + res.m[15] = r3[7]; gf_mx_copy(*mx, res); return 1; #undef SWAP_ROWS @@ -1907,7 +2031,7 @@ Bool gf_ray_hit_box(GF_Ray *ray, GF_Vec box_min, GF_Vec box_max, GF_Vec *outPoin Fixed t1, t2, tNEAR=FIX_MIN, tFAR=FIX_MAX; Fixed temp; //s8 xyorz, sign; - + if (ray->dir.x == 0) { if ((ray->orig.x < box_min.x) || (ray->orig.x > box_max.x)) return 0; @@ -1930,7 +2054,7 @@ Bool gf_ray_hit_box(GF_Ray *ray, GF_Vec box_min, GF_Vec box_max, GF_Vec *outPoin } if (ray->dir.y == 0) { - if ((ray->orig.y < box_min.y) || (ray->orig.y > box_max.y)) + if ((ray->orig.y < box_min.y) || (ray->orig.y > box_max.y)) return 0; } else { tNEAR=FIX_MIN; @@ -1997,10 +2121,10 @@ Bool gf_ray_hit_sphere(GF_Ray *ray, GF_Vec *center, Fixed radius, GF_Vec *outPoi dist = gf_vec_len(radv); center_proj = gf_vec_dot(radv, ray->dir); if (radius + ABS(center_proj) < dist ) return 0; - + center_proj_sq = gf_mulfix(center_proj, center_proj); hcord = center_proj_sq - gf_mulfix(dist, dist) + gf_mulfix(radius , radius); - if (hcord < 0) return 0; + if (hcord < 0) return 0; if (center_proj_sq < hcord) return 0; if (outPoint) { center_proj -= gf_sqrt(hcord); @@ -2012,7 +2136,7 @@ Bool gf_ray_hit_sphere(GF_Ray *ray, GF_Vec *center, Fixed radius, GF_Vec *outPoi /* * Tomas M�ller and Ben Trumbore. - * Fast, minimum storage ray-triangle intersection. + * Fast, minimum storage ray-triangle intersection. * Journal of graphics tools, 2(1):21-28, 1997 * */ @@ -2098,32 +2222,41 @@ GF_Vec4 gf_quat_from_matrix(GF_Matrix *mx) { GF_Vec4 res; Fixed diagonal, s; - diagonal = mx->m[0] + mx->m[5] + mx->m[10]; - - if (diagonal > 0) { - s = gf_sqrt(diagonal + FIX_ONE); - res.q = s / 2; - s = gf_invfix(2*s); - res.x = gf_mulfix(mx->m[6] - mx->m[9], s); - res.y = gf_mulfix(mx->m[8] - mx->m[2], s); - res.z = gf_mulfix(mx->m[1] - mx->m[4], s); - } else { + diagonal = mx->m[0] + mx->m[5] + mx->m[10]; + + if (diagonal > 0) { + s = gf_sqrt(diagonal + FIX_ONE); + res.q = s / 2; + s = gf_invfix(2*s); + res.x = gf_mulfix(mx->m[6] - mx->m[9], s); + res.y = gf_mulfix(mx->m[8] - mx->m[2], s); + res.z = gf_mulfix(mx->m[1] - mx->m[4], s); + } else { Fixed q[4]; - u32 i, j, k; - static const u32 next[3] = { 1, 2, 0 }; - i = 0; - if (mx->m[5] > mx->m[0]) { i = 1; } - if (mx->m[10] > mx->m[4*i+i]) { i = 2; } - j = next[i]; - k = next[j]; - s = gf_sqrt(FIX_ONE + mx->m[4*i + i] - (mx->m[4*j+j] + mx->m[4*k+k]) ); - q[i] = s / 2; - if (s != 0) { s = gf_invfix(2*s); } - q[3] = gf_mulfix(mx->m[4*j+k] - mx->m[4*k+j], s); - q[j] = gf_mulfix(mx->m[4*i+j] + mx->m[4*j+i], s); - q[k] = gf_mulfix(mx->m[4*i+k] + mx->m[4*k+i], s); - res.x = q[0]; res.y = q[1]; res.z = q[2]; res.q = q[3]; - } + u32 i, j, k; + static const u32 next[3] = { 1, 2, 0 }; + i = 0; + if (mx->m[5] > mx->m[0]) { + i = 1; + } + if (mx->m[10] > mx->m[4*i+i]) { + i = 2; + } + j = next[i]; + k = next[j]; + s = gf_sqrt(FIX_ONE + mx->m[4*i + i] - (mx->m[4*j+j] + mx->m[4*k+k]) ); + q[i] = s / 2; + if (s != 0) { + s = gf_invfix(2*s); + } + q[3] = gf_mulfix(mx->m[4*j+k] - mx->m[4*k+j], s); + q[j] = gf_mulfix(mx->m[4*i+j] + mx->m[4*j+i], s); + q[k] = gf_mulfix(mx->m[4*i+k] + mx->m[4*k+i], s); + res.x = q[0]; + res.y = q[1]; + res.z = q[2]; + res.q = q[3]; + } return res; } @@ -2131,23 +2264,23 @@ GF_EXPORT GF_Vec4 gf_quat_to_rotation(GF_Vec4 *quat) { GF_Vec4 r; - Fixed val = gf_acos(quat->q); - if (val == 0) { - r.x = r.y = 0; - r.z = FIX_ONE; + Fixed val = gf_acos(quat->q); + if (val == 0) { + r.x = r.y = 0; + r.z = FIX_ONE; r.q = 0; - } else { + } else { GF_Vec axis; - Fixed sin_val = gf_sin(val); - axis.x = gf_divfix(quat->x, sin_val); - axis.y = gf_divfix(quat->y, sin_val); - axis.z = gf_divfix(quat->z, sin_val); + Fixed sin_val = gf_sin(val); + axis.x = gf_divfix(quat->x, sin_val); + axis.y = gf_divfix(quat->y, sin_val); + axis.z = gf_divfix(quat->z, sin_val); gf_vec_norm(&axis); r.x = axis.x; r.y = axis.y; r.z = axis.z; - r.q= 2 * val; - } + r.q= 2 * val; + } return r; } @@ -2181,7 +2314,9 @@ GF_Vec4 gf_quat_from_axis_cos(GF_Vec axis, Fixed cos_a) GF_Vec4 r; if (cos_a < -FIX_ONE) cos_a = -FIX_ONE; else if (cos_a > FIX_ONE) cos_a = FIX_ONE; - r.x = axis.x; r.y = axis.y; r.z = axis.z; + r.x = axis.x; + r.y = axis.y; + r.z = axis.z; r.q = gf_acos(cos_a); return gf_quat_from_rotation(r); } @@ -2347,8 +2482,8 @@ GF_EXPORT Bool gf_bbox_point_inside(GF_BBox *box, GF_Vec *p) { return (p->x >= box->min_edge.x && p->x <= box->max_edge.x && - p->y >= box->min_edge.y && p->y <= box->max_edge.y && - p->z >= box->min_edge.z && p->z <= box->max_edge.z); + p->y >= box->min_edge.y && p->y <= box->max_edge.y && + p->z >= box->min_edge.z && p->z <= box->max_edge.z); } /*vertices are ordered to respect p vertex indexes (vertex from bbox closer to plane) diff --git a/src/utils/module.c b/src/utils/module.c index 2cd3dbd..71ec817 100644 --- a/src/utils/module.c +++ b/src/utils/module.c @@ -39,7 +39,7 @@ static void load_all_modules(GF_ModuleManager *mgr) } else {\ gf_list_add(mgr->plugin_registry, pr); \ } \ - } + } #ifdef GPAC_STATIC_MODULES GF_InterfaceRegister *pr; @@ -48,14 +48,14 @@ static void load_all_modules(GF_ModuleManager *mgr) LOAD_PLUGIN(aac_in); #endif #ifdef GPAC_HAS_AC3 - LOAD_PLUGIN(ac3); + LOAD_PLUGIN(ac3); #endif #ifdef GPAC_HAS_ALSA - LOAD_PLUGIN(alsa); + LOAD_PLUGIN(alsa); #endif - LOAD_PLUGIN(audio_filter); + LOAD_PLUGIN(audio_filter); LOAD_PLUGIN(bifs); -#ifndef GPAC_DISABLE_SMGR +#ifndef GPAC_DISABLE_SMGR LOAD_PLUGIN(ctx_load); #endif #ifdef GPAC_HAS_DIRECTFB @@ -78,27 +78,27 @@ static void load_all_modules(GF_ModuleManager *mgr) LOAD_PLUGIN(gpac_js); #endif LOAD_PLUGIN(img_in); - LOAD_PLUGIN(isma_ea); + LOAD_PLUGIN(isma_ea); LOAD_PLUGIN(isom); #ifdef GPAC_HAS_JACK LOAD_PLUGIN(jack); #endif #ifndef GPAC_DISABLE_SVG LOAD_PLUGIN(laser); -#endif +#endif #ifdef GPAC_HAS_MAD LOAD_PLUGIN(mp3_in); #endif - LOAD_PLUGIN(mpd_in); + LOAD_PLUGIN(mpd_in); #ifndef GPAC_DISABLE_MEDIA_IMPORT LOAD_PLUGIN(mpegts_in); #endif #ifdef GPAC_HAS_SPIDERMONKEY - LOAD_PLUGIN(mse_in); -#endif + LOAD_PLUGIN(mse_in); +#endif LOAD_PLUGIN(odf_dec); #ifdef GPAC_HAS_OGG - LOAD_PLUGIN(ogg_in); + LOAD_PLUGIN(ogg_in); #endif #ifdef GPAC_HAS_OPENHEVC LOAD_PLUGIN(openhevc); @@ -115,21 +115,21 @@ static void load_all_modules(GF_ModuleManager *mgr) #ifdef GPAC_HAS_PULSEAUDIO LOAD_PLUGIN(pulseaudio); #endif - LOAD_PLUGIN(raw_out); + LOAD_PLUGIN(raw_out); #ifdef GPAC_HAS_FFMPEG - // LOAD_PLUGIN(redirect_av); + // LOAD_PLUGIN(redirect_av); #endif LOAD_PLUGIN(rtp_in); - LOAD_PLUGIN(saf_in); + LOAD_PLUGIN(saf_in); #ifdef GPAC_HAS_SDL - LOAD_PLUGIN(sdl_out); + LOAD_PLUGIN(sdl_out); #endif LOAD_PLUGIN(soft_raster); -#if !defined(GPAC_DISABLE_SMGR) && !defined(GPAC_DISABLE_SVG) +#if !defined(GPAC_DISABLE_SMGR) && !defined(GPAC_DISABLE_SVG) LOAD_PLUGIN(svg_in); -#endif - LOAD_PLUGIN(timedtext); - LOAD_PLUGIN(validator); +#endif + LOAD_PLUGIN(timedtext); + LOAD_PLUGIN(validator); #ifdef GPAC_HAS_WAVEOUT LOAD_PLUGIN(wave_out); #endif @@ -143,9 +143,9 @@ static void load_all_modules(GF_ModuleManager *mgr) LOAD_PLUGIN(x11_out); #endif #ifdef GPAC_HAS_XVID - LOAD_PLUGIN(xvid); + LOAD_PLUGIN(xvid); #endif - + //todo fix project for iOS #ifdef GPAC_IPHONE // LOAD_PLUGIN(ios_cam); @@ -156,7 +156,7 @@ static void load_all_modules(GF_ModuleManager *mgr) #endif //GPAC_STATIC_MODULES #undef LOAD_PLUGIN - + } @@ -218,7 +218,7 @@ void gf_modules_del(GF_ModuleManager *pm) } /* Delete module directories*/ - for (i = 0; i < pm->num_dirs; i++){ + for (i = 0; i < pm->num_dirs; i++) { gf_free((void*)pm->dirs[i]); } @@ -247,17 +247,17 @@ u32 gf_modules_get_count(GF_ModuleManager *pm) } GF_EXPORT -const char **gf_modules_get_module_directories(GF_ModuleManager *pm, u32* num_dirs){ +const char **gf_modules_get_module_directories(GF_ModuleManager *pm, u32* num_dirs) { char* directories; char* tmp_dirs; char * pch; if (!pm) return NULL; - if (pm->num_dirs > 0 ){ + if (pm->num_dirs > 0 ) { *num_dirs = pm->num_dirs; return pm->dirs; } if (!pm->cfg) return NULL; - + /* Get directory from config file */ directories = (char*)gf_cfg_get_key(pm->cfg, "General", "ModulesDirectory"); if (! directories) { @@ -270,7 +270,7 @@ const char **gf_modules_get_module_directories(GF_ModuleManager *pm, u32* num_di while (pch != NULL) { - if (pm->num_dirs == MAX_MODULE_DIRS){ + if (pm->num_dirs == MAX_MODULE_DIRS) { GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("Reach maximum number of module directories - check the configuration file and the \"ModulesDirectory\" key.\n")); break; } @@ -292,20 +292,20 @@ GF_BaseInterface *gf_modules_load_interface(GF_ModuleManager *pm, u32 whichplug, ModuleInstance *inst; GF_BaseInterface *ifce; - if (!pm){ + if (!pm) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] gf_modules_load_interface() : No Module Manager set\n")); return NULL; } gf_mx_p(pm->mutex); inst = (ModuleInstance *) gf_list_get(pm->plug_list, whichplug); - if (!inst){ + if (!inst) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] gf_modules_load_interface() : no module %d exist.\n", whichplug)); gf_mx_v(pm->mutex); return NULL; } GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Load interface...%s\n", inst->name)); /*look in cache*/ - if (!pm->cfg){ + if (!pm->cfg) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] No pm->cfg has been set !!!\n")); gf_mx_v(pm->mutex); return NULL; @@ -314,7 +314,7 @@ GF_BaseInterface *gf_modules_load_interface(GF_ModuleManager *pm, u32 whichplug, if (opt) { const char * ifce_str = gf_4cc_to_str(InterfaceFamily); snprintf(szKey, 32, "%s:yes", ifce_str ? ifce_str : "(null)"); - if (!strstr(opt, szKey)){ + if (!strstr(opt, szKey)) { gf_mx_v(pm->mutex); return NULL; } @@ -389,7 +389,7 @@ GF_BaseInterface *gf_modules_load_interface_by_name(GF_ModuleManager *pm, const const char *file_name; u32 i, count; GF_BaseInterface *ifce; - if (!pm || !plug_name || !pm->plug_list || !pm->cfg){ + if (!pm || !plug_name || !pm->plug_list || !pm->cfg) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] gf_modules_load_interface_by_name has bad parameters pm=%p, plug_name=%s.\n", pm, plug_name)); return NULL; } diff --git a/src/utils/module_wrap.h b/src/utils/module_wrap.h index bc68ddb..48ead16 100644 --- a/src/utils/module_wrap.h +++ b/src/utils/module_wrap.h @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -43,7 +43,7 @@ typedef struct struct __tag_mod_man *plugman; char *name; GF_List *interfaces; - + /*for static modules*/ GF_InterfaceRegister *ifce_reg; @@ -77,7 +77,7 @@ struct __tag_mod_man #ifdef __cplusplus extern "C" { #endif - + /*returns 1 if a module with the same filename is already loaded*/ Bool gf_module_is_loaded(GF_ModuleManager *pm, char *filename); diff --git a/src/utils/os_config_init.c b/src/utils/os_config_init.c index c57978d..9c07409 100644 --- a/src/utils/os_config_init.c +++ b/src/utils/os_config_init.c @@ -19,10 +19,12 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#ifndef GPAC_DISABLE_CORE_TOOLS + #include @@ -65,7 +67,7 @@ static Bool enum_mod_dir(void *cbck, char *item_name, char *item_path) { if (!strnicmp(item_name, "gm_", 3)) { -printf("Found %s\n", item_name); + printf("Found %s\n", item_name); *(Bool *) cbck = GF_TRUE; } return GF_FALSE; @@ -108,8 +110,8 @@ static Bool get_default_install_path(char *file_path, u32 path_type) FILE *f; char *sep; char szPath[GF_MAX_PATH]; - - + + #ifdef _WIN32_WCE TCHAR w_szPath[GF_MAX_PATH]; GetModuleFileName(NULL, w_szPath, GF_MAX_PATH); @@ -117,7 +119,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) #else GetModuleFileNameA(NULL, file_path, GF_MAX_PATH); #endif - + /*remove exe name*/ if (strstr(file_path, ".exe")) { sep = strrchr(file_path, '\\'); @@ -127,12 +129,12 @@ static Bool get_default_install_path(char *file_path, u32 path_type) strcpy(szPath, file_path); strlwr(szPath); - /*if this is run from a browser, we do not get our app path - fortunately on Windows, we always use 'GPAC' in the + /*if this is run from a browser, we do not get our app path - fortunately on Windows, we always use 'GPAC' in the installation path*/ if (!strstr(file_path, "gpac")) { HKEY hKey = NULL; DWORD dwSize = GF_MAX_PATH; - + /*locate the key in current user, then in local machine*/ #ifdef _WIN32_WCE DWORD dwType = REG_SZ; @@ -147,7 +149,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) #else if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\GPAC", 0, KEY_READ, &hKey) != ERROR_SUCCESS) RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\GPAC", 0, KEY_READ, &hKey); - + dwSize = GF_MAX_PATH; #ifdef _DEBUG @@ -161,7 +163,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) if (path_type==GF_PATH_APP) return 1; - + if (path_type==GF_PATH_GUI) { char *sep; strcat(file_path, "\\gui"); @@ -202,7 +204,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) f = gf_f64_open(szPath, "wb"); /*COMPLETE FAILURE*/ if (!f) return 0; - + fclose(f); gf_delete_file(szPath); return 1; @@ -221,7 +223,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) return 1; } - + #elif defined(__SYMBIAN__) #if defined(__SERIES60_3X__) @@ -256,19 +258,19 @@ static Bool get_default_install_path(char *file_path, u32 path_type) if (path_type==GF_PATH_CFG) { char *user_home = getenv("HOME"); #ifdef GPAC_IPHONE - char buf[PATH_MAX]; - char *res; + char buf[PATH_MAX]; + char *res; #endif if (!user_home) return 0; #ifdef GPAC_IPHONE - res = realpath(user_home, buf); - if (res) { - strcpy(file_path, buf); - } else + res = realpath(user_home, buf); + if (res) { + strcpy(file_path, buf); + } else #endif - strcpy(file_path, user_home); + strcpy(file_path, user_home); if (file_path[strlen(file_path)-1] == '/') file_path[strlen(file_path)-1] = 0; - return 1; + return 1; } if (path_type==GF_PATH_APP) { @@ -282,7 +284,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) #elif defined(GPAC_CONFIG_LINUX) size = readlink("/proc/self/exe", file_path, GF_MAX_PATH); - if (size>0) { + if (size>0) { char *sep = strrchr(file_path, '/'); if (sep) sep[0] = 0; return 1; @@ -291,7 +293,7 @@ static Bool get_default_install_path(char *file_path, u32 path_type) return 0; } - + /*locate the app*/ if (!get_default_install_path(app_path, GF_PATH_APP)) return 0; @@ -363,9 +365,9 @@ static Bool get_default_install_path(char *file_path, u32 path_type) get_default_install_path(app_path, GF_PATH_APP); strcat(app_path, "/gui"); if (check_file_exists("gui_old.bt", app_path, file_path)) return 1; -#endif +#endif } - else { // (path_type==GF_PATH_MODULES) + else { // (path_type==GF_PATH_MODULES) strcat(app_path, "/Contents/MacOS/modules"); if (check_file_exists(TEST_MODULE, app_path, file_path)) return 1; } @@ -390,7 +392,7 @@ static GF_Config *create_default_config(char *file_path) } /*Create the config file*/ sprintf(szPath, "%s%c%s", file_path, GF_PATH_SEPARATOR, CFG_FILE_NAME); - fprintf(stderr, "Trying to create config file: %s", szPath); + fprintf(stderr, "Trying to create config file: %s", szPath); f = gf_f64_open(szPath, "wt"); if (!f) return NULL; fclose(f); @@ -461,7 +463,7 @@ static GF_Config *create_default_config(char *file_path) gf_cfg_set_key(cfg, "Audio", "DriverName", "SDL Audio Output"); #endif #ifdef GPAC_IPHONE - gf_cfg_set_key(cfg, "Compositor", "DisableGLUScale", "yes"); + gf_cfg_set_key(cfg, "Compositor", "DisableGLUScale", "yes"); #endif gf_cfg_set_key(cfg, "Video", "SwitchResolution", "no"); @@ -487,7 +489,7 @@ static GF_Config *create_default_config(char *file_path) } /*check if modules directory has changed in the config file -this is mainly intended for OSX where we can have an install in /usr/... and an install in /Applications/Osmo4.app +this is mainly intended for OSX where we can have an install in /usr/... and an install in /Applications/Osmo4.app */ static void check_modules_dir(GF_Config *cfg) { @@ -501,7 +503,7 @@ static void check_modules_dir(GF_Config *cfg) #endif } - /*if startup file was disabled, do not attempt to correct it*/ + /*if startup file was disabled, do not attempt to correct it*/ if (gf_cfg_get_key(cfg, "General", "StartupFile")==NULL) return; if ( get_default_install_path(path, GF_PATH_GUI) ) { @@ -565,3 +567,4 @@ GF_Config *gf_cfg_init(const char *file, Bool *new_cfg) return cfg; } +#endif diff --git a/src/utils/os_divers.c b/src/utils/os_divers.c index 042d41c..51033f4 100644 --- a/src/utils/os_divers.c +++ b/src/utils/os_divers.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -159,14 +159,14 @@ GF_Err gf_rmdir(char *DirPathName) return GF_IO_ERR; } #else - int res = rmdir(DirPathName); + int res = rmdir(DirPathName); if (res==-1) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot delete director %s: last error %d\n", DirPathName, errno )); return GF_IO_ERR; } #endif return GF_OK; -} +} GF_EXPORT GF_Err gf_mkdir(char* DirPathName) @@ -180,19 +180,19 @@ GF_Err gf_mkdir(char* DirPathName) int err = GetLastError(); GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot create directory %s: last error %d\n", DirPathName, err )); } -#elif defined (WIN32) +#elif defined (WIN32) int res = mkdir(DirPathName); if (res==-1) { int err = GetLastError(); GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot create directory %s: last error %d\n", DirPathName, err )); } -#else - int res = mkdir(DirPathName, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - if (res==-1) { - if(errno == 17){ +#else + int res = mkdir(DirPathName, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + if (res==-1) { + if(errno == 17) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot create directory %s, it already exists: last error %d \n", DirPathName, errno )); return GF_BAD_PARAM; - }else{ + } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot create directory %s: last error %d\n", DirPathName, errno )); return GF_IO_ERR; } @@ -205,12 +205,12 @@ static Bool delete_dir(void *cbck, char *item_name, char *item_path) { Bool directory_clean_mode = *(Bool*)cbck; - if(directory_clean_mode){ - gf_cleanup_dir(item_path); - gf_rmdir(item_path); - }else{ - gf_delete_file(item_path); - } + if(directory_clean_mode) { + gf_cleanup_dir(item_path); + gf_rmdir(item_path); + } else { + gf_delete_file(item_path); + } return 0; } @@ -219,7 +219,7 @@ GF_Err gf_cleanup_dir(char* DirPathName) Bool directory_clean_mode; directory_clean_mode = 1; - gf_enum_directory(DirPathName, 1, delete_dir, &directory_clean_mode, NULL); + gf_enum_directory(DirPathName, 1, delete_dir, &directory_clean_mode, NULL); directory_clean_mode = 0; gf_enum_directory(DirPathName, 0, delete_dir, &directory_clean_mode, NULL); @@ -263,8 +263,8 @@ struct tm #ifndef _TIMEZONE_DEFINED struct timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ }; #define _TIMEZONE_DEFINED #endif /* _TIMEZONE_DEFINED */ @@ -278,53 +278,53 @@ struct timezone int gettimeofday(struct timeval *tp, struct timezone *tzp) { - SYSTEMTIME st; - FILETIME ft; - LARGE_INTEGER li; - TIME_ZONE_INFORMATION tzi; - __int64 t; - static int tzflag; - - if (NULL != tp) - { - GetSystemTime(&st); - SystemTimeToFileTime(&st, &ft); - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - t = li.QuadPart; /* In 100-nanosecond intervals */ - t -= EPOCHFILETIME; /* Offset to the Epoch time */ - t /= 10; /* In microseconds */ - tp->tv_sec = (long)(t / 1000000); - tp->tv_usec = (long)(t % 1000000); - } - - if (NULL != tzp) - { - GetTimeZoneInformation(&tzi); - - tzp->tz_minuteswest = tzi.Bias; - if (tzi.StandardDate.wMonth != 0) - { - tzp->tz_minuteswest += tzi.StandardBias * 60; - } - - if (tzi.DaylightDate.wMonth != 0) - { - tzp->tz_dsttime = 1; - } - else - { - tzp->tz_dsttime = 0; - } - } - - return 0; + SYSTEMTIME st; + FILETIME ft; + LARGE_INTEGER li; + TIME_ZONE_INFORMATION tzi; + __int64 t; + static int tzflag; + + if (NULL != tp) + { + GetSystemTime(&st); + SystemTimeToFileTime(&st, &ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; /* In 100-nanosecond intervals */ + t -= EPOCHFILETIME; /* Offset to the Epoch time */ + t /= 10; /* In microseconds */ + tp->tv_sec = (long)(t / 1000000); + tp->tv_usec = (long)(t % 1000000); + } + + if (NULL != tzp) + { + GetTimeZoneInformation(&tzi); + + tzp->tz_minuteswest = tzi.Bias; + if (tzi.StandardDate.wMonth != 0) + { + tzp->tz_minuteswest += tzi.StandardBias * 60; + } + + if (tzi.DaylightDate.wMonth != 0) + { + tzp->tz_dsttime = 1; + } + else + { + tzp->tz_dsttime = 0; + } + } + + return 0; } #if _GPAC_UNUSED /* - time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds + time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds FILETIME in Win32 is from jan 1, 1601 */ @@ -348,9 +348,9 @@ s32 __gettimeofday(struct timeval *tp, void *tz) #elif defined(WIN32) -s32 gettimeofday(struct timeval *tp, void *tz) +static s32 gettimeofday(struct timeval *tp, void *tz) { - struct _timeb timebuffer; + struct _timeb timebuffer; _ftime( &timebuffer ); tp->tv_sec = (long) (timebuffer.time); @@ -404,6 +404,26 @@ GF_Err gf_delete_file(const char *fileName) #endif } +/** + * Remove existing single-quote from a single-quoted string. + * The caller is responsible for deallocating the returns string with gf_free() + */ +static char* gf_sanetize_single_quoted_string(const char *src) { + int i, j; + char *out = gf_malloc(4*strlen(src)+3); + out[0] = '\''; + for (i=0, j=1; (out[j]=src[i]); ++i, ++j) { + if (src[i]=='\'') { + out[++j]='\\'; + out[++j]='\''; + out[++j]='\''; + } + } + out[j++] = '\''; + out[j++] = 0; + return out; +} + GF_EXPORT GF_Err gf_move_file(const char *fileName, const char *newFileName) { @@ -417,12 +437,18 @@ GF_Err gf_move_file(const char *fileName, const char *newFileName) /* success if != 0 */ return (MoveFile(fileName, newFileName) == 0 ) ? GF_IO_ERR : GF_OK; #else - /* success is == 0 */ - char cmd[1024]; + GF_Err e = GF_IO_ERR; + char cmd[1024], *arg1, *arg2; if (!fileName || !newFileName) return GF_IO_ERR; - snprintf(cmd, sizeof(cmd), "mv '%s' '%s' > /dev/null 2>&1", fileName, newFileName); - return ( system(cmd) == 0) ? GF_OK : GF_IO_ERR; + arg1 = gf_sanetize_single_quoted_string(fileName); + arg2 = gf_sanetize_single_quoted_string(newFileName); + if (snprintf(cmd, sizeof cmd, "mv %s %s", arg1, arg2) >= sizeof cmd) goto error; + e = (system(cmd) == 0) ? GF_OK : GF_IO_ERR; +error: + gf_free(arg1); + gf_free(arg2); + return e; #endif } @@ -453,8 +479,8 @@ u32 gf_rand() GF_EXPORT u64 gf_file_modification_time(const char *filename) { -#if defined(_WIN32_WCE) - WCHAR _file[GF_MAX_PATH]; +#if defined(_WIN32_WCE) + WCHAR _file[GF_MAX_PATH]; WIN32_FIND_DATA FindData; HANDLE fh; ULARGE_INTEGER uli; @@ -507,13 +533,13 @@ FILE *gf_temp_file_new() GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Win32] system failure for tmpfile(): 0x%08x\n", err)); } /*tmpfile() may fail under vista ...*/ - if (!GetEnvironmentVariable("TEMP",tmp,MAX_PATH)) + if (!GetEnvironmentVariable("TEMP",tmp,MAX_PATH)) return NULL; sprintf(t_file, "\\gpac_%08x.tmp", (u32) tmp); strcat(tmp, t_file); return gf_f64_open(tmp, "w+b"); #else - return tmpfile(); + return tmpfile(); #endif } @@ -575,7 +601,7 @@ GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item #ifdef WIN32 WIN32_FIND_DATA FindData; HANDLE SearchH; -#else +#else DIR *the_dir; struct dirent* the_file; struct stat st; @@ -607,7 +633,7 @@ GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item TDriveList aList; iFs.Connect(); iFs.DriveList(aList); - for (TInt i=0;id_name); - GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Checking file %s for enum\n", item_path)); - + GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Checking file %s for enum\n", item_path)); + if (stat( item_path, &st ) != 0) goto next; if (enum_directory && ( (st.st_mode & S_IFMT) != S_IFDIR)) goto next; if (!enum_directory && ((st.st_mode & S_IFMT) == S_IFDIR)) goto next; @@ -856,8 +882,8 @@ FILE *gf_f64_open(const char *file_name, const char *mode) #endif GF_EXPORT -size_t gf_fwrite(const void *ptr, size_t size, size_t nmemb, - FILE *stream) +size_t gf_fwrite(const void *ptr, size_t size, size_t nmemb, + FILE *stream) { size_t result = fwrite(ptr, size, nmemb, stream); if (result != nmemb) { @@ -898,8 +924,12 @@ Bool gf_prompt_has_input() { return 0; } -char gf_prompt_get_char() { return 0; } -void gf_prompt_set_echo_off(Bool echo_off) { return; } +char gf_prompt_get_char() { + return 0; +} +void gf_prompt_set_echo_off(Bool echo_off) { + return; +} #else @@ -916,7 +946,7 @@ char gf_prompt_get_char() return getchar(); } -void gf_prompt_set_echo_off(Bool echo_off) +void gf_prompt_set_echo_off(Bool echo_off) { DWORD flags; HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -954,8 +984,8 @@ static void close_keyboard(Bool new_line) if (new_line) fprintf(stderr, "\n"); } -void gf_prompt_set_echo_off(Bool echo_off) -{ +void gf_prompt_set_echo_off(Bool echo_off) +{ init_keyboard(); if (echo_off) t_orig.c_lflag &= ~ECHO; else t_orig.c_lflag |= ECHO; @@ -1037,8 +1067,8 @@ typedef int(WINAPI* NTQuerySystemInfo)(ULONG,PVOID,ULONG,PULONG); NTQuerySystemInfo MyQuerySystemInfo = NULL; #ifndef PROCESS_MEMORY_COUNTERS -typedef struct _PROCESS_MEMORY_COUNTERS -{ +typedef struct _PROCESS_MEMORY_COUNTERS +{ DWORD cb; DWORD PageFaultCount; SIZE_T PeakWorkingSetSize; @@ -1053,7 +1083,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS #endif #ifndef SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION -typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION +typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { LARGE_INTEGER IdleTime; LARGE_INTEGER KernelTime; @@ -1065,7 +1095,7 @@ typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION #else - + static u64 last_cpu_u_k_time = 0; static u64 last_cpu_idle_time = 0; static u64 mem_at_startup = 0; @@ -1107,8 +1137,8 @@ static u64 OS_GetSysClockHIGHRES_FULL() return (u64) ((now.QuadPart * 1000000) / frequency.QuadPart); } -static u32 OS_GetSysClockNORMAL() -{ +static u32 OS_GetSysClockNORMAL() +{ #ifdef _WIN32_WCE return GetTickCount(); #else @@ -1116,22 +1146,22 @@ static u32 OS_GetSysClockNORMAL() #endif } -static u64 OS_GetSysClockNORMAL_FULL() -{ +static u64 OS_GetSysClockNORMAL_FULL() +{ u64 res = OS_GetSysClockNORMAL(); return res*1000; } #endif /* WIN32 */ -#if defined(__sh__) +#if defined(__sh__) /* Avoid exception for denormalized floating point values */ static int sh4_get_fpscr() { - int ret; - asm volatile ("sts fpscr,%0" : "=r" (ret)); - return ret; + int ret; + asm volatile ("sts fpscr,%0" : "=r" (ret)); + return ret; } static void @@ -1153,20 +1183,20 @@ extern int __fpscr_values[2]; void sh4_change_fpscr(int off, int on) { - int b = sh4_get_fpscr(); - off = ~off; - off |= 0x00180000; - on &= ~ 0x00180000; - b &= off; - b |= on; - sh4_put_fpscr(b); - __fpscr_values[0] &= off; - __fpscr_values[0] |= on; - __fpscr_values[1] &= off; - __fpscr_values[1] |= on; + int b = sh4_get_fpscr(); + off = ~off; + off |= 0x00180000; + on &= ~ 0x00180000; + b &= off; + b |= on; + sh4_put_fpscr(b); + __fpscr_values[0] &= off; + __fpscr_values[0] |= on; + __fpscr_values[1] &= off; + __fpscr_values[1] |= on; } -#endif +#endif #ifdef GPAC_MEMORY_TRACKING void gf_mem_enable_tracker(); @@ -1265,7 +1295,7 @@ void gf_sys_init(Bool enable_memory_tracker) #ifdef GPAC_CONFIG_FREEBSD { s32 flags[4]; - size_t len = sizeof(u32); + size_t len = sizeof(u32); flags[0] = CTL_HW; flags[1] = HW_AVAILCPU; sysctl(flags, 2, &the_rti.nb_cores, &len, NULL, 0); @@ -1285,7 +1315,7 @@ void gf_sys_init(Bool enable_memory_tracker) GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[core] process id %d\n", the_rti.pid)); #ifndef _WIN32_WCE - setlocale( LC_NUMERIC, "C" ); + setlocale( LC_NUMERIC, "C" ); #endif } sys_init += 1; @@ -1311,7 +1341,7 @@ void gf_sys_close() #if defined(WIN32) && !defined(_WIN32_WCE) timeEndPeriod(1); - + MyGetSystemTimes = NULL; MyGetProcessMemoryInfo = NULL; MyQuerySystemInfo = NULL; @@ -1338,7 +1368,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #if defined(_WIN32_WCE) THREADENTRY32 tentry; u64 total_cpu_time, process_cpu_time; - DWORD orig_perm; + DWORD orig_perm; #endif MEMORYSTATUS ms; u64 creation, exit, kernel, user, process_k_u_time, proc_idle_time, proc_k_u_time; @@ -1377,9 +1407,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) /*get a snapshot of all running threads*/ orig_perm = GetCurrentPermissions(); SetProcPermissions(0xFFFFFFFF); - hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); + hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if (hSnapShot) { - tentry.dwSize = sizeof(THREADENTRY32); + tentry.dwSize = sizeof(THREADENTRY32); the_rti.thread_count = 0; /*note we always act as if GF_RTI_ALL_PROCESSES_TIMES flag is set, since there is no other way to enumerate threads from a process, and GetProcessTimes doesn't exist on CE*/ @@ -1395,15 +1425,15 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } } while (Thread32Next(hSnapShot, &tentry)); } - CloseToolhelp32Snapshot(hSnapShot); + CloseToolhelp32Snapshot(hSnapShot); } if (flags & GF_RTI_PROCESS_MEMORY) { HEAPLIST32 hlentry; HEAPENTRY32 hentry; the_rti.process_memory = 0; - hlentry.dwSize = sizeof(HEAPLIST32); - hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST, the_rti.pid); + hlentry.dwSize = sizeof(HEAPLIST32); + hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST, the_rti.pid); if (hSnapShot && Heap32ListFirst(hSnapShot, &hlentry)) { do { hentry.dwSize = sizeof(hentry); @@ -1414,7 +1444,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } } while (Heap32ListNext(hSnapShot, &hlentry)); } - CloseToolhelp32Snapshot(hSnapShot); + CloseToolhelp32Snapshot(hSnapShot); } SetProcPermissions(orig_perm); total_cpu_time /= 10; @@ -1434,7 +1464,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) else if (MyQuerySystemInfo) { DWORD ret; SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION info; - MyQuerySystemInfo(0x8 /*SystemProcessorPerformanceInformation*/, &info, sizeof(info), &ret); + MyQuerySystemInfo(0x8 /*SystemProcessorPerformanceInformation*/, &info, sizeof(info), &ret); if (ret && (ret<=sizeof(info))) { proc_idle_time = info.IdleTime.QuadPart / 10; proc_k_u_time = (info.KernelTime.QuadPart + info.UserTime.QuadPart) / 10; @@ -1442,11 +1472,11 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } /*no special API available, ONLY FETCH TIMES if requested (may eat up some time)*/ else if (flags & GF_RTI_ALL_PROCESSES_TIMES) { - PROCESSENTRY32 pentry; + PROCESSENTRY32 pentry; /*get a snapshot of all running threads*/ - hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (!hSnapShot) return 0; - pentry.dwSize = sizeof(PROCESSENTRY32); + pentry.dwSize = sizeof(PROCESSENTRY32); if (Process32First(hSnapShot, &pentry)) { do { HANDLE procH = NULL; @@ -1462,9 +1492,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) if (procH) CloseHandle(procH); } while (Process32Next(hSnapShot, &pentry)); } - CloseHandle(hSnapShot); + CloseHandle(hSnapShot); proc_k_u_time /= 10; - } + } if (!process_k_u_time) { @@ -1490,8 +1520,8 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) HEAPLIST32 hlentry; HEAPENTRY32 hentry; the_rti.process_memory = 0; - hlentry.dwSize = sizeof(HEAPLIST32); - hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST, the_rti.pid); + hlentry.dwSize = sizeof(HEAPLIST32); + hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST, the_rti.pid); if (hSnapShot && Heap32ListFirst(hSnapShot, &hlentry)) { do { hentry.dwSize = sizeof(hentry); @@ -1502,7 +1532,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } } while (Heap32ListNext(hSnapShot, &hlentry)); } - CloseHandle(hSnapShot); + CloseHandle(hSnapShot); } #endif @@ -1515,9 +1545,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #if defined(_WIN32_WCE) the_rti.total_cpu_time_diff = (u32) ((total_cpu_time - last_total_k_u_time)/1000); /*we're not that accurate....*/ - if (the_rti.total_cpu_time_diff > the_rti.sampling_period_duration) + if (the_rti.total_cpu_time_diff > the_rti.sampling_period_duration) the_rti.sampling_period_duration = the_rti.total_cpu_time_diff; - + /*rough values*/ the_rti.cpu_idle_time = the_rti.sampling_period_duration - the_rti.total_cpu_time_diff; the_rti.total_cpu_usage = (u32) (100 * the_rti.total_cpu_time_diff / the_rti.sampling_period_duration); @@ -1540,9 +1570,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) if (the_rti.total_cpu_time_diff > the_rti.sampling_period_duration) { the_rti.sampling_period_duration = the_rti.total_cpu_time_diff; } - - if (!proc_idle_time) - proc_idle_time = last_proc_idle_time + (the_rti.sampling_period_duration - the_rti.total_cpu_time_diff); + + if (!proc_idle_time) + proc_idle_time = last_proc_idle_time + (the_rti.sampling_period_duration - the_rti.total_cpu_time_diff); samp_sys_time = proc_k_u_time - last_proc_k_u_time; idle = proc_idle_time - last_proc_idle_time; @@ -1564,7 +1594,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #endif the_rti.physical_memory_avail = ms.dwAvailPhys; -#if defined(_WIN32_WCE) +#if defined(_WIN32_WCE) last_total_k_u_time = total_cpu_time; if (!the_rti.process_memory) the_rti.process_memory = mem_usage_at_startup - ms.dwAvailPhys; #else @@ -1578,7 +1608,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) return 1; } - + #elif defined(GPAC_CONFIG_DARWIN) && !defined(GPAC_IPHONE) #include @@ -1651,9 +1681,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } } the_rti.physical_memory = total_physical_memory; - + error = task_for_pid(mach_task_self(), the_rti.pid, &task); - if (error) { + if (error) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] Cannot get process task for PID %d: error %d\n", the_rti.pid, error)); return 0; } @@ -1663,7 +1693,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] Cannot get process task info (PID %d): error %d\n", the_rti.pid, error)); return 0; } - + percent = 0; utime = ti.user_time.seconds + ti.user_time.microseconds * 1e-6; stime = ti.system_time.seconds + ti.system_time.microseconds * 1e-6; @@ -1689,15 +1719,15 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } error = vm_deallocate(mach_task_self(), (vm_offset_t)thread_table, table_size * sizeof(thread_array_t)); mach_port_deallocate(mach_task_self(), task); - + process_u_k_time = utime + stime; - + the_rti.sampling_instant = last_update_time; - + if (last_update_time) { the_rti.sampling_period_duration = (entry_time - last_update_time); the_rti.process_cpu_time_diff = (process_u_k_time - last_process_k_u_time) * 10; - + the_rti.total_cpu_time_diff = the_rti.sampling_period_duration; /*TODO*/ the_rti.cpu_idle_time = 0; @@ -1713,12 +1743,12 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #ifdef GPAC_MEMORY_TRACKING the_rti.gpac_memory = gpac_allocated_memory; #endif - + last_process_k_u_time = process_u_k_time; last_cpu_idle_time = 0; last_update_time = entry_time; memcpy(rti, &the_rti, sizeof(GF_SystemRTInfo)); - return 1; + return 1; } //linux @@ -1726,160 +1756,160 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) { - u32 entry_time; - u64 process_u_k_time; - u32 u_k_time, idle_time; + u32 entry_time; + u64 process_u_k_time; + u32 u_k_time, idle_time; #if 0 - char szProc[100]; -#endif - char line[2048]; - FILE *f; - - assert(sys_init); - - entry_time = gf_sys_clock(); - if (last_update_time && (entry_time - last_update_time < refresh_time_ms)) { - memcpy(rti, &the_rti, sizeof(GF_SystemRTInfo)); - return 0; - } - - u_k_time = idle_time = 0; - f = gf_f64_open("/proc/stat", "r"); - if (f) { - u32 k_time, nice_time, u_time; - if (fgets(line, 128, f) != NULL) { - if (sscanf(line, "cpu %u %u %u %u\n", &u_time, &k_time, &nice_time, &idle_time) == 4) { - u_k_time = u_time + k_time + nice_time; - } - } - fclose(f); - } - - process_u_k_time = 0; - the_rti.process_memory = 0; - - /*FIXME? under LinuxThreads this will only fetch stats for the calling thread, we would have to enumerate /proc to get - the complete CPU usage of all therads of the process...*/ + char szProc[100]; +#endif + char line[2048]; + FILE *f; + + assert(sys_init); + + entry_time = gf_sys_clock(); + if (last_update_time && (entry_time - last_update_time < refresh_time_ms)) { + memcpy(rti, &the_rti, sizeof(GF_SystemRTInfo)); + return 0; + } + + u_k_time = idle_time = 0; + f = gf_f64_open("/proc/stat", "r"); + if (f) { + u32 k_time, nice_time, u_time; + if (fgets(line, 128, f) != NULL) { + if (sscanf(line, "cpu %u %u %u %u\n", &u_time, &k_time, &nice_time, &idle_time) == 4) { + u_k_time = u_time + k_time + nice_time; + } + } + fclose(f); + } + + process_u_k_time = 0; + the_rti.process_memory = 0; + + /*FIXME? under LinuxThreads this will only fetch stats for the calling thread, we would have to enumerate /proc to get + the complete CPU usage of all therads of the process...*/ #if 0 - sprintf(szProc, "/proc/%d/stat", the_rti.pid); - f = gf_f64_open(szProc, "r"); - if (f) { - fflush(f); - if (fgets(line, 2048, f) != NULL) { - char state; - char *start; - long cutime, cstime, priority, nice, itrealvalue, rss; - int exit_signal, processor; - unsigned long flags, minflt, cminflt, majflt, cmajflt, utime, stime,starttime, vsize, rlim, startcode, endcode, startstack, kstkesp, kstkeip, signal, blocked, sigignore, sigcatch, wchan, nswap, cnswap, rem; - int ppid, pgrp ,session, tty_nr, tty_pgrp, res; - start = strchr(line, ')'); - if (start) start += 2; - else { - start = strchr(line, ' '); - start++; - } - res = sscanf(start,"%c %d %d %d %d %d %lu %lu %lu %lu \ + sprintf(szProc, "/proc/%d/stat", the_rti.pid); + f = gf_f64_open(szProc, "r"); + if (f) { + fflush(f); + if (fgets(line, 2048, f) != NULL) { + char state; + char *start; + long cutime, cstime, priority, nice, itrealvalue, rss; + int exit_signal, processor; + unsigned long flags, minflt, cminflt, majflt, cmajflt, utime, stime,starttime, vsize, rlim, startcode, endcode, startstack, kstkesp, kstkeip, signal, blocked, sigignore, sigcatch, wchan, nswap, cnswap, rem; + int ppid, pgrp ,session, tty_nr, tty_pgrp, res; + start = strchr(line, ')'); + if (start) start += 2; + else { + start = strchr(line, ' '); + start++; + } + res = sscanf(start,"%c %d %d %d %d %d %lu %lu %lu %lu \ %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu \ %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %d %d", - &state, &ppid, &pgrp, &session, &tty_nr, &tty_pgrp, &flags, &minflt, &cminflt, &majflt, - &cmajflt, &utime, &stime, &cutime, &cstime, &priority, &nice, &itrealvalue, &rem, &starttime, - &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, - &sigignore, &sigcatch, &wchan, &nswap, &cnswap, &exit_signal, &processor); - - if (res) process_u_k_time = (u64) (cutime + cstime); - else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] PROC %s parse error\n", szProc)); - } - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] error reading pid/stat\n\n", szProc)); - } - fclose(f); - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open %s\n", szProc)); - } - sprintf(szProc, "/proc/%d/status", the_rti.pid); - f = gf_f64_open(szProc, "r"); - if (f) { - while (fgets(line, 1024, f) != NULL) { - if (!strnicmp(line, "VmSize:", 7)) { - sscanf(line, "VmSize: %"LLD" kB", &the_rti.process_memory); - the_rti.process_memory *= 1024; - } - } - fclose(f); - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open %s\n", szProc)); - } -#endif - - - the_rti.physical_memory = the_rti.physical_memory_avail = 0; - f = gf_f64_open("/proc/meminfo", "r"); - if (f) { - while (fgets(line, 1024, f) != NULL) { - if (!strnicmp(line, "MemTotal:", 9)) { - sscanf(line, "MemTotal: "LLU" kB", &the_rti.physical_memory); - the_rti.physical_memory *= 1024; - }else if (!strnicmp(line, "MemFree:", 8)) { - sscanf(line, "MemFree: "LLU" kB", &the_rti.physical_memory_avail); - the_rti.physical_memory_avail *= 1024; - break; - } - } - fclose(f); - } else { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open /proc/meminfo\n")); - } - - - the_rti.sampling_instant = last_update_time; - - if (last_update_time) { - the_rti.sampling_period_duration = (entry_time - last_update_time); - the_rti.process_cpu_time_diff = (process_u_k_time - last_process_k_u_time) * 10; - - /*oops, we have no choice but to assume 100% cpu usage during this period*/ - if (!u_k_time) { - the_rti.total_cpu_time_diff = the_rti.sampling_period_duration; - u_k_time = last_cpu_u_k_time + the_rti.sampling_period_duration; - the_rti.cpu_idle_time = 0; - the_rti.total_cpu_usage = 100; - if (!the_rti.process_cpu_time_diff) the_rti.process_cpu_time_diff = the_rti.total_cpu_time_diff; - the_rti.process_cpu_usage = (u32) ( 100 * the_rti.process_cpu_time_diff / the_rti.sampling_period_duration); - } else { - u64 samp_sys_time; - /*move to ms (/proc/stat gives times in 100 ms unit*/ - the_rti.total_cpu_time_diff = (u_k_time - last_cpu_u_k_time)*10; - - /*we're not that accurate....*/ - if (the_rti.total_cpu_time_diff > the_rti.sampling_period_duration) - the_rti.sampling_period_duration = the_rti.total_cpu_time_diff; - - - if (!idle_time) idle_time = (the_rti.sampling_period_duration - the_rti.total_cpu_time_diff)/10; - samp_sys_time = u_k_time - last_cpu_u_k_time; - the_rti.cpu_idle_time = idle_time - last_cpu_idle_time; - the_rti.total_cpu_usage = (u32) ( 100 * samp_sys_time / (the_rti.cpu_idle_time + samp_sys_time ) ); - /*move to ms (/proc/stat gives times in 100 ms unit*/ - the_rti.cpu_idle_time *= 10; - if (!the_rti.process_cpu_time_diff) the_rti.process_cpu_time_diff = the_rti.total_cpu_time_diff; - the_rti.process_cpu_usage = (u32) ( 100 * the_rti.process_cpu_time_diff / (the_rti.cpu_idle_time + 10*samp_sys_time ) ); - } - } else { - mem_at_startup = the_rti.physical_memory_avail; - } - the_rti.process_memory = mem_at_startup - the_rti.physical_memory_avail; + &state, &ppid, &pgrp, &session, &tty_nr, &tty_pgrp, &flags, &minflt, &cminflt, &majflt, + &cmajflt, &utime, &stime, &cutime, &cstime, &priority, &nice, &itrealvalue, &rem, &starttime, + &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, + &sigignore, &sigcatch, &wchan, &nswap, &cnswap, &exit_signal, &processor); + + if (res) process_u_k_time = (u64) (cutime + cstime); + else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] PROC %s parse error\n", szProc)); + } + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] error reading pid/stat\n\n", szProc)); + } + fclose(f); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open %s\n", szProc)); + } + sprintf(szProc, "/proc/%d/status", the_rti.pid); + f = gf_f64_open(szProc, "r"); + if (f) { + while (fgets(line, 1024, f) != NULL) { + if (!strnicmp(line, "VmSize:", 7)) { + sscanf(line, "VmSize: %"LLD" kB", &the_rti.process_memory); + the_rti.process_memory *= 1024; + } + } + fclose(f); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open %s\n", szProc)); + } +#endif + + + the_rti.physical_memory = the_rti.physical_memory_avail = 0; + f = gf_f64_open("/proc/meminfo", "r"); + if (f) { + while (fgets(line, 1024, f) != NULL) { + if (!strnicmp(line, "MemTotal:", 9)) { + sscanf(line, "MemTotal: "LLU" kB", &the_rti.physical_memory); + the_rti.physical_memory *= 1024; + } else if (!strnicmp(line, "MemFree:", 8)) { + sscanf(line, "MemFree: "LLU" kB", &the_rti.physical_memory_avail); + the_rti.physical_memory_avail *= 1024; + break; + } + } + fclose(f); + } else { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[RTI] cannot open /proc/meminfo\n")); + } + + + the_rti.sampling_instant = last_update_time; + + if (last_update_time) { + the_rti.sampling_period_duration = (entry_time - last_update_time); + the_rti.process_cpu_time_diff = (process_u_k_time - last_process_k_u_time) * 10; + + /*oops, we have no choice but to assume 100% cpu usage during this period*/ + if (!u_k_time) { + the_rti.total_cpu_time_diff = the_rti.sampling_period_duration; + u_k_time = last_cpu_u_k_time + the_rti.sampling_period_duration; + the_rti.cpu_idle_time = 0; + the_rti.total_cpu_usage = 100; + if (!the_rti.process_cpu_time_diff) the_rti.process_cpu_time_diff = the_rti.total_cpu_time_diff; + the_rti.process_cpu_usage = (u32) ( 100 * the_rti.process_cpu_time_diff / the_rti.sampling_period_duration); + } else { + u64 samp_sys_time; + /*move to ms (/proc/stat gives times in 100 ms unit*/ + the_rti.total_cpu_time_diff = (u_k_time - last_cpu_u_k_time)*10; + + /*we're not that accurate....*/ + if (the_rti.total_cpu_time_diff > the_rti.sampling_period_duration) + the_rti.sampling_period_duration = the_rti.total_cpu_time_diff; + + + if (!idle_time) idle_time = (the_rti.sampling_period_duration - the_rti.total_cpu_time_diff)/10; + samp_sys_time = u_k_time - last_cpu_u_k_time; + the_rti.cpu_idle_time = idle_time - last_cpu_idle_time; + the_rti.total_cpu_usage = (u32) ( 100 * samp_sys_time / (the_rti.cpu_idle_time + samp_sys_time ) ); + /*move to ms (/proc/stat gives times in 100 ms unit*/ + the_rti.cpu_idle_time *= 10; + if (!the_rti.process_cpu_time_diff) the_rti.process_cpu_time_diff = the_rti.total_cpu_time_diff; + the_rti.process_cpu_usage = (u32) ( 100 * the_rti.process_cpu_time_diff / (the_rti.cpu_idle_time + 10*samp_sys_time ) ); + } + } else { + mem_at_startup = the_rti.physical_memory_avail; + } + the_rti.process_memory = mem_at_startup - the_rti.physical_memory_avail; #ifdef GPAC_MEMORY_TRACKING - the_rti.gpac_memory = gpac_allocated_memory; + the_rti.gpac_memory = gpac_allocated_memory; #endif - last_process_k_u_time = process_u_k_time; - last_cpu_idle_time = idle_time; - last_cpu_u_k_time = u_k_time; - last_update_time = entry_time; - memcpy(rti, &the_rti, sizeof(GF_SystemRTInfo)); - return 1; + last_process_k_u_time = process_u_k_time; + last_cpu_idle_time = idle_time; + last_cpu_u_k_time = u_k_time; + last_update_time = entry_time; + memcpy(rti, &the_rti, sizeof(GF_SystemRTInfo)); + return 1; } #endif @@ -1896,7 +1926,7 @@ Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } -char * gf_get_default_cache_directory(){ +char * gf_get_default_cache_directory() { #ifdef _WIN32_WCE return gf_strdup( "\\windows\\temp" ); #elif defined(WIN32) @@ -1911,7 +1941,7 @@ char * gf_get_default_cache_directory(){ GF_EXPORT -Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32*level, u32 *batteryLifeTime, u32 *batteryFullLifeTime) +Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32*level, u32 *batteryLifeTime, u32 *batteryFullLifeTime) { #if defined(_WIN32_WCE) SYSTEM_POWER_STATUS_EX sps; @@ -1966,7 +1996,7 @@ GF_GlobalLock * gf_create_PID_file( const char * resourceName ) { const char *res; char * pid = &(pidfile[strlen(pidfile)]); - for (res = resourceName; *res ; res++){ + for (res = resourceName; *res ; res++) { if (*res >= 'A' && *res <= 'z') *pid = * res; else @@ -1980,14 +2010,14 @@ GF_GlobalLock * gf_create_PID_file( const char * resourceName ) goto exit; /* Get the flags */ flags = fcntl(fd, F_GETFD); - if (flags == -1){ + if (flags == -1) { goto exit; } /* Set FD_CLOEXEC, so exclusive lock will be removed on exit, so even if GPAC crashes, * lock will be allowed for next instance */ flags |= FD_CLOEXEC; /* Now, update the flags */ - if (fcntl(fd, F_SETFD, flags) == -1){ + if (fcntl(fd, F_SETFD, flags) == -1) { goto exit; } @@ -2004,7 +2034,7 @@ GF_GlobalLock * gf_create_PID_file( const char * resourceName ) goto exit; } - if (ftruncate(fd, 0) == -1){ + if (ftruncate(fd, 0) == -1) { goto exit; } /* Write the PID */ @@ -2012,7 +2042,7 @@ GF_GlobalLock * gf_create_PID_file( const char * resourceName ) int sz = 100; char * buf = gf_malloc( sz ); sz = snprintf(buf, sz, "%ld\n", (long) getpid()); - if (write(fd, buf, sz) != sz){ + if (write(fd, buf, sz) != sz) { gf_free(buf); goto exit; } @@ -2038,7 +2068,7 @@ struct _GF_GlobalLock_opaque { #endif GF_EXPORT -GF_GlobalLock * gf_global_resource_lock(const char * resourceName){ +GF_GlobalLock * gf_global_resource_lock(const char * resourceName) { #ifdef WIN32 #ifdef _WIN32_WCE unsigned short sWResourceName[MAX_PATH]; @@ -2075,7 +2105,7 @@ GF_GlobalLock * gf_global_resource_lock(const char * resourceName){ return lock; #else /* WIN32 */ - return gf_create_PID_file(resourceName); + return gf_create_PID_file(resourceName); #endif /* WIN32 */ } @@ -2085,7 +2115,7 @@ GF_GlobalLock * gf_global_resource_lock(const char * resourceName){ * \return GF_OK if evertything went fine */ GF_EXPORT -GF_Err gf_global_resource_unlock(GF_GlobalLock * lock){ +GF_Err gf_global_resource_unlock(GF_GlobalLock * lock) { if (!lock) return GF_BAD_PARAM; #ifndef WIN32 @@ -2135,6 +2165,11 @@ void gf_fm_request_call(u32 type, u32 param, int *value) { #endif //GPAC_ANDROID +GF_EXPORT +s32 gf_gettimeofday(struct timeval *tp, void *tz) { + return gettimeofday(tp, tz); +} + /* NTP tools */ @@ -2143,9 +2178,6 @@ void gf_net_get_ntp(u32 *sec, u32 *frac) { u64 frac_part; struct timeval now; -#ifdef WIN32 - s32 gettimeofday(struct timeval *tp, void *tz); -#endif gettimeofday(&now, NULL); *sec = (u32) (now.tv_sec) + GF_NTP_SEC_1900_TO_1970; // *frac = (u32) ( (now.tv_usec << 12) + (now.tv_usec << 8) - ((now.tv_usec * 3650) >> 6) ); @@ -2167,7 +2199,7 @@ s32 gf_net_get_timezone() t_time = time(NULL); t_gmt = *gmtime(&t_time); t_local = *localtime(&t_time); - + t_timezone = (t_gmt.tm_hour - t_local.tm_hour) * 3600; return t_timezone; } @@ -2272,6 +2304,12 @@ u64 gf_net_parse_date(const char *val) else if (!strcmp(szDay, "Sat") || !strcmp(szDay, "Saturday")) t.tm_wday = 5; else if (!strcmp(szDay, "Sun") || !strcmp(szDay, "Sunday")) t.tm_wday = 6; } + +#ifdef GPAC_ANDROID + /* strange issue in Android, we have to indicate DST is not applied in our time struct*/ + t.tm_isdst = -1; +#endif + current_time = mktime(&t) - gf_net_get_timezone(); #endif @@ -2308,6 +2346,12 @@ u64 gf_net_get_utc() #ifndef _WIN32_WCE gtime = sec - GF_NTP_SEC_1900_TO_1970; _t = * gmtime(>ime); + +#ifdef GPAC_ANDROID + /* strange issue in Android, we have to indicate DST is not applied in our time struct*/ + _t.tm_isdst = -1; +#endif + current_time = mktime(&_t) - gf_net_get_timezone(); #else GetSystemTime(&syst); diff --git a/src/utils/os_module.c b/src/utils/os_module.c index 579d8f1..1cecf53 100644 --- a/src/utils/os_module.c +++ b/src/utils/os_module.c @@ -53,7 +53,7 @@ void gf_modules_free_module(ModuleInstance *inst) if (inst->interfaces) gf_list_del(inst->interfaces); inst->interfaces = NULL; - + if (inst->name && !inst->ifce_reg) { gf_free(inst->name); inst->name = NULL; @@ -144,17 +144,17 @@ Bool gf_modules_load_library(ModuleInstance *inst) inst->query_func = (QueryInterfaces) dlsym(inst->lib_handle, "QueryInterfaces"); error = dlerror(); if (error) - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol QueryInterfaces in module file %s, error is %s\n", path, error)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol QueryInterfaces in module file %s, error is %s\n", path, error)); inst->load_func = (LoadInterface) dlsym(inst->lib_handle, "LoadInterface"); error = dlerror(); if (error) - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol LoadInterface in module file %s, error is %s\n", path, error)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol LoadInterface in module file %s, error is %s\n", path, error)); inst->destroy_func = (ShutdownInterface) dlsym(inst->lib_handle, "ShutdownInterface"); error = dlerror(); if (error) - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol ShutdownInterface in module file %s, error is %s\n", path, error)); + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot resolve symbol ShutdownInterface in module file %s, error is %s\n", path, error)); #endif - GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] Load module file %s : DONE\n", inst->name)); + GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] Load module file %s : DONE\n", inst->name)); return GF_TRUE; } @@ -229,10 +229,10 @@ Bool enum_modules(void *cbck, char *item_name, char *item_path) #endif ModuleLib = dlopen(item_name, _flags); - if (!ModuleLib) { - GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot load module file %s, error is %s\n", item_name, dlerror())); - goto next; - } + if (!ModuleLib) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Cannot load module file %s, error is %s\n", item_name, dlerror())); + goto next; + } query_func = (QueryInterface) dlsym(ModuleLib, "QueryInterface"); load_func = (LoadInterface) dlsym(ModuleLib, "LoadInterface"); @@ -240,12 +240,12 @@ Bool enum_modules(void *cbck, char *item_name, char *item_path) dlclose(ModuleLib); #endif - if (!load_func || !query_func || !del_func){ - GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, - ("[Core] Could not find some signatures in module %s: QueryInterface=%p, LoadInterface=%p, ShutdownInterface=%p\n", - item_name, load_func, query_func, del_func)); - return 0; - } + if (!load_func || !query_func || !del_func) { + GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, + ("[Core] Could not find some signatures in module %s: QueryInterface=%p, LoadInterface=%p, ShutdownInterface=%p\n", + item_name, load_func, query_func, del_func)); + return 0; + } #endif @@ -254,7 +254,7 @@ Bool enum_modules(void *cbck, char *item_name, char *item_path) inst->plugman = pm; inst->name = gf_strdup(item_name); inst->dir = gf_strdup(item_path); - gf_url_get_resource_path(item_path, inst->dir); + gf_url_get_resource_path(item_path, inst->dir); GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] Added module %s.\n", inst->name)); gf_list_add(pm->plug_list, inst); return GF_FALSE; @@ -288,18 +288,18 @@ u32 gf_modules_refresh(GF_ModuleManager *pm) /*load all static modules*/ load_static_modules(pm); - for (i =0; i < pm->num_dirs; i++){ + for (i =0; i < pm->num_dirs; i++) { #ifdef WIN32 - gf_enum_directory(pm->dirs[i], GF_FALSE, enum_modules, pm, ".dll"); + gf_enum_directory(pm->dirs[i], GF_FALSE, enum_modules, pm, ".dll"); #elif defined(__APPLE__) #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) - /*we are in static build for modules by default*/ + /*we are in static build for modules by default*/ #else - gf_enum_directory(pm->dirs[i], 0, enum_modules, pm, ".dylib"); + gf_enum_directory(pm->dirs[i], 0, enum_modules, pm, ".dylib"); #endif #else - GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dirs[i])); - gf_enum_directory(pm->dirs[i], 0, enum_modules, pm, ".so"); + GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dirs[i])); + gf_enum_directory(pm->dirs[i], 0, enum_modules, pm, ".so"); #endif } diff --git a/src/utils/os_net.c b/src/utils/os_net.c index 77f5e06..b9a5b96 100644 --- a/src/utils/os_net.c +++ b/src/utils/os_net.c @@ -23,6 +23,7 @@ * */ +#ifndef GPAC_DISABLE_CORE_TOOLS #if defined(WIN32) || defined(_WIN32_WCE) @@ -255,17 +256,17 @@ static struct addrinfo *gf_sk_get_ipv6_addr(const char *PeerName, u16 PortNumber char *service, *dest; service = dest = NULL; #ifdef WIN32 - if (!wsa_init) { - WSADATA Data; - if (WSAStartup(0x0202, &Data)!=0) return NULL; - wsa_init = 1; - } + if (!wsa_init) { + WSADATA Data; + if (WSAStartup(0x0202, &Data)!=0) return NULL; + wsa_init = 1; + } #endif service = dest = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = sock_type; - hints.ai_family = family; + hints.ai_family = family; hints.ai_flags = flags; if (PortNumber) { @@ -273,11 +274,11 @@ static struct addrinfo *gf_sk_get_ipv6_addr(const char *PeerName, u16 PortNumber service = (char *)portstring; } if (PeerName) { - strncpy(node, PeerName, MAX_PEER_NAME_LEN); - if (node[0]=='[') { - node[strlen(node)-1] = 0; - strncpy(node, &node[1], MAX_PEER_NAME_LEN); - } + strncpy(node, PeerName, MAX_PEER_NAME_LEN); + if (node[0]=='[') { + node[strlen(node)-1] = 0; + strncpy(node, &node[1], MAX_PEER_NAME_LEN); + } node[MAX_PEER_NAME_LEN - 1] = 0; dest = (char *) node; } @@ -289,7 +290,7 @@ static Bool gf_sk_ipv6_set_remote_address(GF_Socket *sock, const char *address, { struct addrinfo *res = gf_sk_get_ipv6_addr(address, PortNumber, AF_UNSPEC, 0, (sock->flags & GF_SOCK_IS_TCP) ? SOCK_STREAM : SOCK_DGRAM); if (!res) return 0; - memcpy(&sock->dest_addr, res->ai_addr, res->ai_addrlen); + memcpy(&sock->dest_addr, res->ai_addr, res->ai_addrlen); sock->dest_addr_len = (u32) res->ai_addrlen; freeaddrinfo(res); return 1; @@ -421,7 +422,7 @@ static void gf_sk_free(GF_Socket *sock) #ifdef GPAC_HAS_IPV6 struct sockaddr *addr = (struct sockaddr *)&sock->dest_addr; if (addr->sa_family==AF_INET6) { - struct ipv6_mreq mreq6; + struct ipv6_mreq mreq6; memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); mreq6.ipv6mr_interface= 0; setsockopt(sock->socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *) &mreq6, sizeof(mreq6)); @@ -565,10 +566,12 @@ GF_Err gf_sk_connect(GF_Socket *sock, const char *PeerName, u16 PortNumber, cons if (Host == NULL) { switch (LASTSOCKERROR) { #ifndef __SYMBIAN32__ - case ENETDOWN: return GF_IP_NETWORK_FAILURE; - //case ENOHOST: return GF_IP_ADDRESS_NOT_FOUND; + case ENETDOWN: + return GF_IP_NETWORK_FAILURE; + //case ENOHOST: return GF_IP_ADDRESS_NOT_FOUND; #endif - default: return GF_IP_NETWORK_FAILURE; + default: + return GF_IP_NETWORK_FAILURE; } } memcpy((char *) &sock->dest_addr.sin_addr, Host->h_addr_list[0], sizeof(u32)); @@ -580,19 +583,27 @@ GF_Err gf_sk_connect(GF_Socket *sock, const char *PeerName, u16 PortNumber, cons u32 res = LASTSOCKERROR; GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[Core] Couldn't connect socket - last sock error %d\n", res)); switch (res) { - case EAGAIN: return GF_IP_SOCK_WOULD_BLOCK; + case EAGAIN: + return GF_IP_SOCK_WOULD_BLOCK; #ifdef WIN32 case WSAEINVAL: if (sock->flags & GF_SOCK_NON_BLOCKING) return GF_IP_SOCK_WOULD_BLOCK; #endif - case EISCONN: return GF_OK; - case ENOTCONN: return GF_IP_CONNECTION_FAILURE; - case ECONNRESET: return GF_IP_CONNECTION_FAILURE; - case EMSGSIZE: return GF_IP_CONNECTION_FAILURE; - case ECONNABORTED: return GF_IP_CONNECTION_FAILURE; - case ENETDOWN: return GF_IP_CONNECTION_FAILURE; - default: return GF_IP_CONNECTION_FAILURE; + case EISCONN: + return GF_OK; + case ENOTCONN: + return GF_IP_CONNECTION_FAILURE; + case ECONNRESET: + return GF_IP_CONNECTION_FAILURE; + case EMSGSIZE: + return GF_IP_CONNECTION_FAILURE; + case ECONNABORTED: + return GF_IP_CONNECTION_FAILURE; + case ENETDOWN: + return GF_IP_CONNECTION_FAILURE; + default: + return GF_IP_CONNECTION_FAILURE; } } } @@ -625,10 +636,10 @@ GF_Err gf_sk_bind(GF_Socket *sock, const char *local_ip, u16 port, const char *p if (!sock || sock->socket) return GF_BAD_PARAM; -#ifndef WIN32 - if(!local_ip){ - if(!peer_name || !strcmp(peer_name,"localhost")){ - peer_name="127.0.0.1"; +#ifndef WIN32 + if(!local_ip) { + if(!peer_name || !strcmp(peer_name,"localhost")) { + peer_name="127.0.0.1"; } } #endif @@ -875,7 +886,7 @@ u32 gf_sk_is_multicast_address(const char *multi_IPAdd) { #ifdef GPAC_HAS_IPV6 u32 val; - char *sep; + char *sep; struct addrinfo *res; if (!multi_IPAdd) return 0; /*IPV6 multicast address*/ @@ -887,7 +898,7 @@ u32 gf_sk_is_multicast_address(const char *multi_IPAdd) if (!res) return 0; val = 0; if (res->ai_addr->sa_family == AF_INET) { - val = IN_MULTICAST(ntohl(((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr)); + val = IN_MULTICAST(ntohl(((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr)); } else if (res->ai_addr->sa_family == AF_INET6) { val = IN6_IS_ADDR_MULTICAST(& ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr); } @@ -1151,7 +1162,7 @@ GF_Err gf_sk_receive(GF_Socket *sock, char *buffer, u32 length, u32 startFrom, u else { res = recv(sock->socket, (char *) buffer + startFrom, length - startFrom, 0); if (res == 0) - return GF_IP_CONNECTION_CLOSED; + return GF_IP_CONNECTION_CLOSED; } if (res == SOCKET_ERROR) { @@ -1281,11 +1292,11 @@ GF_Err gf_sk_get_local_info(GF_Socket *sock, u16 *Port, u32 *Familly) #endif } if (Familly) { -/* size = 4; - if (getsockopt(sock->socket, SOL_SOCKET, SO_TYPE, (char *) &fam, &size) == SOCKET_ERROR) - return GF_IP_NETWORK_FAILURE; - *Familly = fam; -*/ + /* size = 4; + if (getsockopt(sock->socket, SOL_SOCKET, SO_TYPE, (char *) &fam, &size) == SOCKET_ERROR) + return GF_IP_NETWORK_FAILURE; + *Familly = fam; + */ if (sock->flags & GF_SOCK_IS_TCP) *Familly = GF_SOCK_TYPE_TCP; else *Familly = GF_SOCK_TYPE_UDP; } @@ -1312,7 +1323,7 @@ GF_Err gf_sk_get_remote_address(GF_Socket *sock, char *buf) { #ifdef GPAC_HAS_IPV6 char clienthost[NI_MAXHOST]; - struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr_len); + struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr_len); if (!sock || sock->socket) return GF_BAD_PARAM; if (getnameinfo((struct sockaddr *)addrptr, sock->dest_addr_len, clienthost, sizeof(clienthost), NULL, 0, NI_NUMERICHOST)) return GF_IP_ADDRESS_NOT_FOUND; @@ -1382,7 +1393,7 @@ GF_Err gf_sk_send_to(GF_Socket *sock, const char *buffer, u32 length, char *remo freeaddrinfo(res); } else { struct sockaddr_in6 *remotePtr = (struct sockaddr_in6 *)&remote_add; - struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr); + struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr); remotePtr->sin6_port = addrptr->sin6_port; remotePtr->sin6_addr = addrptr->sin6_addr; remote_add_len = sock->dest_addr_len; @@ -1531,3 +1542,4 @@ GF_Err gf_sk_send_wait(GF_Socket *sock, const char *buffer, u32 length, u32 Seco } +#endif /*GPAC_DISABLE_CORE_TOOLS*/ diff --git a/src/utils/os_thread.c b/src/utils/os_thread.c index 2069b6f..6b054f7 100644 --- a/src/utils/os_thread.c +++ b/src/utils/os_thread.c @@ -23,6 +23,7 @@ * */ +#ifndef GPAC_DISABLE_CORE_TOOLS #ifdef GPAC_ANDROID #include @@ -146,13 +147,13 @@ GF_Err gf_register_before_exit_function(GF_Thread *t, u32 (*toRunBeforePthreadEx static void currentThreadInfoKey_alloc() { int err; - /* We do not use any destructor */ - if (err = pthread_key_create(¤tThreadInfoKey, NULL)) - GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex] pthread_key_create() failed with error %d\n", err)); + /* We do not use any destructor */ + if (err = pthread_key_create(¤tThreadInfoKey, NULL)) + GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex] pthread_key_create() failed with error %d\n", err)); } -GF_Thread * gf_th_current(){ - return pthread_getspecific(currentThreadInfoKey); +GF_Thread * gf_th_current() { + return pthread_getspecific(currentThreadInfoKey); } #endif /* GPAC_ANDROID */ @@ -205,9 +206,9 @@ exit: #else #ifdef GPAC_ANDROID - #ifndef GPAC_DISABLE_LOG - GF_LOG(GF_LOG_INFO, GF_LOG_MUTEX, ("[Thread %s] RunBeforeExit=%p\n", t->log_name, t->RunBeforeExit)); - #endif +#ifndef GPAC_DISABLE_LOG + GF_LOG(GF_LOG_INFO, GF_LOG_MUTEX, ("[Thread %s] RunBeforeExit=%p\n", t->log_name, t->RunBeforeExit)); +#endif if (t->RunBeforeExit) t->RunBeforeExit(t->args); #endif /* GPAC_ANDROID */ @@ -321,7 +322,7 @@ void gf_th_del(GF_Thread *t) #else /* It is necessary to free pthread handle */ if (t->threadH) - pthread_detach(t->threadH); + pthread_detach(t->threadH); t->threadH = 0; #endif @@ -552,9 +553,9 @@ u32 gf_mx_p(GF_Mutex *mx) if (retCode != 0 ) { #ifndef GPAC_DISABLE_LOG if (retCode == EINVAL) - GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex %p=%s] Not properly initialized.\n", mx, mx->log_name)); + GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex %p=%s] Not properly initialized.\n", mx, mx->log_name)); if (retCode == EDEADLK) - GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex %p=%s] Deadlock detected.\n", mx, mx->log_name)); + GF_LOG(GF_LOG_ERROR, GF_LOG_MUTEX, ("[Mutex %p=%s] Deadlock detected.\n", mx, mx->log_name)); #endif /* GPAC_DISABLE_LOG */ assert(0); return 0; @@ -688,11 +689,11 @@ void gf_sema_del(GF_Semaphore *sm) } #elif defined(__DARWIN__) || defined(__APPLE__) #ifdef GPAC_IPHONE - sem_close(sm->hSemaphore); + sem_close(sm->hSemaphore); #else sem_destroy(sm->hSemaphore); #endif - gf_free(sm->SemName); + gf_free(sm->SemName); #else sem_destroy(sm->hSemaphore); #endif @@ -768,3 +769,5 @@ Bool gf_sema_wait_for(GF_Semaphore *sm, u32 TimeOut) return 0; #endif } + +#endif diff --git a/src/utils/path2d.c b/src/utils/path2d.c index e7ba3c0..928da64 100644 --- a/src/utils/path2d.c +++ b/src/utils/path2d.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -58,11 +58,23 @@ GF_Path *gf_path_clone(GF_Path *gp) GF_SAFEALLOC(dst, GF_Path); if (!dst) return NULL; dst->contours = (u32 *)gf_malloc(sizeof(u32)*gp->n_contours); - if (!dst->contours) { gf_free(dst); return NULL; } + if (!dst->contours) { + gf_free(dst); + return NULL; + } dst->points = (GF_Point2D *) gf_malloc(sizeof(GF_Point2D)*gp->n_points); - if (!dst->points) { gf_free(dst->contours); gf_free(dst); return NULL; } + if (!dst->points) { + gf_free(dst->contours); + gf_free(dst); + return NULL; + } dst->tags = (u8 *) gf_malloc(sizeof(u8)*gp->n_points); - if (!dst->tags) { gf_free(dst->points); gf_free(dst->contours); gf_free(dst); return NULL; } + if (!dst->tags) { + gf_free(dst->points); + gf_free(dst->contours); + gf_free(dst); + return NULL; + } memcpy(dst->contours, gp->contours, sizeof(u32)*gp->n_contours); dst->n_contours = gp->n_contours; memcpy(dst->points, gp->points, sizeof(GF_Point2D)*gp->n_points); @@ -90,7 +102,7 @@ void gf_path_del(GF_Path *gp) _gp->points = (GF_Point2D *)gf_realloc(_gp->points, sizeof(GF_Point2D)*(_gp->n_alloc_points)); \ _gp->tags = (u8 *) gf_realloc(_gp->tags, sizeof(u8)*(_gp->n_alloc_points)); \ } \ - + GF_EXPORT GF_Err gf_path_add_move_to(GF_Path *gp, Fixed x, Fixed y) @@ -122,7 +134,9 @@ GF_Err gf_path_add_move_to(GF_Path *gp, Fixed x, Fixed y) } GF_EXPORT -GF_Err gf_path_add_move_to_vec(GF_Path *gp, GF_Point2D *pt) { return gf_path_add_move_to(gp, pt->x, pt->y); } +GF_Err gf_path_add_move_to_vec(GF_Path *gp, GF_Point2D *pt) { + return gf_path_add_move_to(gp, pt->x, pt->y); +} GF_EXPORT GF_Err gf_path_add_line_to(GF_Path *gp, Fixed x, Fixed y) @@ -142,7 +156,9 @@ GF_Err gf_path_add_line_to(GF_Path *gp, Fixed x, Fixed y) } GF_EXPORT -GF_Err gf_path_add_line_to_vec(GF_Path *gp, GF_Point2D *pt) { return gf_path_add_line_to(gp, pt->x, pt->y); } +GF_Err gf_path_add_line_to_vec(GF_Path *gp, GF_Point2D *pt) { + return gf_path_add_line_to(gp, pt->x, pt->y); +} GF_EXPORT GF_Err gf_path_close(GF_Path *gp) @@ -150,7 +166,7 @@ GF_Err gf_path_close(GF_Path *gp) Fixed diff; GF_Point2D start, end; if (!gp || !gp->n_contours) return GF_BAD_PARAM; - + if (gp->n_contours<=1) start = gp->points[0]; else start = gp->points[gp->contours[gp->n_contours-2] + 1]; end = gp->points[gp->n_points-1]; @@ -289,7 +305,7 @@ GF_Err gf_path_add_subpath(GF_Path *gp, GF_Path *src, GF_Matrix2D *mx) if (!gp->tags) return GF_OUT_OF_MEM; memcpy(gp->points + gp->n_points, src->points, sizeof(GF_Point2D)*src->n_points); if (mx) { - for (i=0;in_points; i++) { + for (i=0; in_points; i++) { gf_mx2d_apply_coords(mx, &gp->points[i+gp->n_points].x, &gp->points[i+gp->n_points].y); } } @@ -310,7 +326,7 @@ static void NBezier(GF_Point2D *pts, s32 n, Double mu, GF_Point2D *pt_out) muk = 1; munk = pow(1-mu,(Double)n); - for (k=0;k<=n;k++) { + for (k=0; k<=n; k++) { nn = n; kn = k; nkn = n - k; @@ -358,7 +374,7 @@ GF_Err gf_path_add_bezier(GF_Path *gp, GF_Point2D *pts, u32 nbPoints) newpts = (GF_Point2D *) gf_malloc(sizeof(GF_Point2D) * (nbPoints+1)); newpts[0] = gp->points[gp->n_points-1]; memcpy(&newpts[1], pts, sizeof(GF_Point2D) * nbPoints); - + gf_add_n_bezier(gp, newpts, nbPoints + 1); gf_free(newpts); @@ -397,7 +413,7 @@ GF_Err gf_path_add_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed fa_x, Fix end_angle = gf_atan2(end_y, end_x); tmp = gf_mulfix((start_x - fa_x), (start_x - fa_x)) + gf_mulfix((start_y - fa_y), (start_y - fa_y)); axis_w = gf_sqrt(tmp); - tmp = gf_mulfix((start_x - fb_x) , (start_x - fb_x)) + gf_mulfix((start_y - fb_y), (start_y - fb_y)); + tmp = gf_mulfix((start_x - fb_x) , (start_x - fb_x)) + gf_mulfix((start_y - fb_y), (start_y - fb_y)); axis_w += gf_sqrt(tmp); axis_w /= 2; axis_h = gf_sqrt(gf_mulfix(axis_w, axis_w) - gf_mulfix(fa_x,fa_x)); @@ -479,22 +495,22 @@ GF_Err gf_path_add_svg_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, r_y = gf_mulfix(gf_sqrt(radius_scale), r_y); rxsq = gf_mulfix(r_x, r_x); rysq = gf_mulfix(r_y, r_y); - } + } #if 0 - /* Old code with overflow problems in fixed point, + /* Old code with overflow problems in fixed point, sign was sometimes negative (cf tango SVG icons appointment-new.svg)*/ sign = gf_mulfix(rxsq,ymidpsq) + gf_mulfix(rysq, xmidpsq); scale = FIX_ONE; /*FIXME - what if scale is 0 ??*/ if (sign) scale = gf_divfix( - (gf_mulfix(rxsq,rysq) - gf_mulfix(rxsq, ymidpsq) - gf_mulfix(rysq,xmidpsq)), - sign - ); + (gf_mulfix(rxsq,rysq) - gf_mulfix(rxsq, ymidpsq) - gf_mulfix(rysq,xmidpsq)), + sign + ); #else - /* New code: the sign variable computation is split into simpler cases and - the expression is divided by rxsq to reduce the range */ + /* New code: the sign variable computation is split into simpler cases and + the expression is divided by rxsq to reduce the range */ if ((rxsq == 0 || ymidpsq ==0) && (rysq == 0 || xmidpsq == 0)) { scale = FIX_ONE; } else if (rxsq == 0 || ymidpsq ==0) { @@ -522,7 +538,7 @@ GF_Err gf_path_add_svg_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, ux = FIX_ONE; uy = 0; normu = FIX_ONE; - + vx = gf_divfix(xmidp-cxp,r_x); vy = gf_divfix(ymidp-cyp,r_y); normv = gf_sqrt(gf_mulfix(vx, vx) + gf_mulfix(vy,vy)); @@ -534,11 +550,11 @@ GF_Err gf_path_add_svg_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, ux = vx; uy = vy; normu = normv; - + vx = gf_divfix(-xmidp-cxp,r_x); vy = gf_divfix(-ymidp-cyp,r_y); normu = gf_sqrt(gf_mulfix(ux, ux) + gf_mulfix(uy,uy)); - + sign = gf_mulfix(ux, vy) - gf_mulfix(uy, vx); sweep_angle = gf_divfix( gf_mulfix(ux,vx) + gf_mulfix(uy, vy), gf_mulfix(normu, normv) ); /*numerical stability safety*/ @@ -546,9 +562,9 @@ GF_Err gf_path_add_svg_arc_to(GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, sweep_angle = gf_acos(sweep_angle); sweep_angle = (sign > 0 ? sweep_angle: -sweep_angle); if (sweep_flag == 0) { - if (sweep_angle > 0) sweep_angle -= GF_2PI; + if (sweep_angle > 0) sweep_angle -= GF_2PI; } else { - if (sweep_angle < 0) sweep_angle += GF_2PI; + if (sweep_angle < 0) sweep_angle += GF_2PI; } num_steps = GF_2D_DEFAULT_RES/2; @@ -650,7 +666,7 @@ GF_Err gf_path_get_control_bounds(GF_Path *gp, GF_Rect *rc) /* * conic bbox computing taken from freetype - * Copyright 1996-2001, 2002, 2004 by + * Copyright 1996-2001, 2002, 2004 by * David Turner, Robert Wilhelm, and Werner Lemberg. * License: FTL or GPL */ @@ -681,7 +697,7 @@ Suite: /* * cubic bbox computing taken from freetype - * Copyright 1996-2001, 2002, 2004 by + * Copyright 1996-2001, 2002, 2004 by * David Turner, Robert Wilhelm, and Werner Lemberg. * License: FTL or GPL @@ -701,7 +717,7 @@ static void gf_cubic_check(Fixed p1, Fixed p2, Fixed p3, Fixed p4, Fixed *min, F Fixed y2 = arc[1]; Fixed y3 = arc[2]; Fixed y4 = arc[3]; - + if (ABS(y1) xMax) || (cyMin < yMin) || (cyMax > yMax)) { + if ((cxMin < xMin) || (cxMax > xMax) || (cyMin < yMin) || (cyMax > yMax)) { /*decompose all control points*/ pt = gp->points; for (i=1 ; i < gp->n_points; ) { @@ -814,8 +830,8 @@ GF_Err gf_path_get_bounds(GF_Path *gp, GF_Rect *rc) end = &gp->points[i+1]; if ((ctrl1->x < xMin) || (ctrl1->x > xMax)) gf_conic_check(pt->x, ctrl1->x, end->x, &xMin, &xMax); - - if ((ctrl1->y < yMin) || (ctrl1->y > yMax)) + + if ((ctrl1->y < yMin) || (ctrl1->y > yMax)) gf_conic_check(pt->y, ctrl1->y, end->y, &yMin, &yMax); /*and move*/ @@ -829,8 +845,8 @@ GF_Err gf_path_get_bounds(GF_Path *gp, GF_Rect *rc) end = &gp->points[i+2]; if ((ctrl1->x < xMin) || (ctrl1->x > xMax) || (ctrl2->x < xMin) || (ctrl2->x > xMax)) gf_cubic_check(pt->x, ctrl1->x, ctrl2->x, end->x, &xMin, &xMax); - - if ((ctrl1->y < yMin) || (ctrl1->y > yMax) || (ctrl2->y < yMin) || (ctrl2->y > yMax)) + + if ((ctrl1->y < yMin) || (ctrl1->y > yMax) || (ctrl2->y < yMin) || (ctrl2->y > yMax)) gf_cubic_check(pt->y, ctrl1->y, ctrl2->y, end->y, &yMin, &yMax); /*and move*/ @@ -867,7 +883,7 @@ static GF_Err gf_subdivide_cubic(GF_Path *gp, Fixed x0, Fixed y0, Fixed x1, Fixe pt.y = y1 - y0; z1_0 = gf_v2d_len(&pt); - if ((z3_0*100 < FIX_ONE) && (z1_0*100 < FIX_ONE)) + if ((z3_0*100 < FIX_ONE) && (z1_0*100 < FIX_ONE)) goto nosubdivide; /* perp is distance from line, multiplied by dist z0-z3 */ @@ -968,7 +984,7 @@ GF_Path *gf_path_get_flatten(GF_Path *gp) if (gp->tags[i+1]==GF_PATH_CLOSE) gf_path_close(ngp); i+=2; } - break; + break; case GF_PATH_CURVE_CUBIC: gf_subdivide_cubic(ngp, pt->x, pt->y, gp->points[i].x, gp->points[i].y, gp->points[i+1].x, gp->points[i+1].y, gp->points[i+2].x, gp->points[i+2].y, fineness); pt = &gp->points[i+2]; @@ -1039,12 +1055,12 @@ static void gf_subdivide_cubic_hit_test(Fixed h_x, Fixed h_y, Fixed x0, Fixed y0 if (s.y<=pt.y) { if (e.y>pt.y) { - if (isLeft(s, e, pt) > 0) + if (isLeft(s, e, pt) > 0) (*wn)++; } } else if (e.y<=pt.y) { - if (isLeft(s, e, pt) < 0) + if (isLeft(s, e, pt) < 0) (*wn)--; } } @@ -1062,7 +1078,7 @@ Bool gf_path_point_over(GF_Path *gp, Fixed x, Fixed y) if ((xrc.y) || (x>rc.x+rc.width) || (yn_points<2)) return 0; - + pt.x = x; pt.y = y; wn = 0; @@ -1097,8 +1113,8 @@ Bool gf_path_point_over(GF_Path *gp, Fixed x, Fixed y) gf_subdivide_cubic_hit_test(x, y, s.x, s.y, c1.x, c1.y, c2.x, c2.y, end->x, end->y, &wn); s = *end; } - i+=2; - break; + i+=2; + break; case GF_PATH_CURVE_CUBIC: gf_subdivide_cubic_hit_test(x, y, s.x, s.y, gp->points[i].x, gp->points[i].y, gp->points[i+1].x, gp->points[i+1].y, gp->points[i+2].x, gp->points[i+2].y, &wn); s = gp->points[i+2]; @@ -1137,8 +1153,8 @@ Bool gf_path_is_empty(GF_Path *gp) return 1; } -/*iteration info*/ -typedef struct +/*iteration info*/ +typedef struct { Fixed len; Fixed dx, dy; @@ -1292,7 +1308,7 @@ void gf_path_iterator_del(GF_PathIterator *it) pcur = pts[iread++]; \ delta.x = pcur.x - pprev.x; \ delta.y = pcur.y - pprev.y; \ - + #define ConvexCross(p, q) gf_mulfix(p.x,q.y) - gf_mulfix(p.y,q.x); #define ConvexCheckTriple \ @@ -1313,47 +1329,47 @@ void gf_path_iterator_del(GF_PathIterator *it) pSecond = pThird; \ dprev.x = dcur.x; \ dprev.y = dcur.y; \ - + GF_EXPORT u32 gf_polygone2d_get_convexity(GF_Point2D *pts, u32 len) { s32 curDir, thisDir = 0, dirChanges = 0, angleSign = 0; u32 iread; - Fixed cross; + Fixed cross; GF_Point2D pSecond, pThird, pSaveSecond; GF_Point2D dprev, dcur; - /* Get different point, return if less than 3 diff points. */ - if (len < 3 ) return GF_POLYGON_CONVEX_LINE; - iread = 1; + /* Get different point, return if less than 3 diff points. */ + if (len < 3 ) return GF_POLYGON_CONVEX_LINE; + iread = 1; ConvexGetPointDelta(dprev, (pts[0]), pSecond); - pSaveSecond = pSecond; + pSaveSecond = pSecond; /*initial direction */ - curDir = ConvexCompare(dprev); - while ( iread < len) { + curDir = ConvexCompare(dprev); + while ( iread < len) { /* Get different point, break if no more points */ ConvexGetPointDelta(dcur, pSecond, pThird ); if ( (dcur.x == 0) && (dcur.y == 0) ) continue; /* Check current three points */ ConvexCheckTriple; - } + } - /* Must check for direction changes from last vertex back to first */ + /* Must check for direction changes from last vertex back to first */ /* Prepare for 'ConvexCheckTriple' */ - pThird = pts[0]; - dcur.x = pThird.x - pSecond.x; - dcur.y = pThird.y - pSecond.y; - if ( ConvexCompare(dcur) ) ConvexCheckTriple; - - /* and check for direction changes back to second vertex */ - dcur.x = pSaveSecond.x - pSecond.x; - dcur.y = pSaveSecond.y - pSecond.y; + pThird = pts[0]; + dcur.x = pThird.x - pSecond.x; + dcur.y = pThird.y - pSecond.y; + if ( ConvexCompare(dcur) ) ConvexCheckTriple; + + /* and check for direction changes back to second vertex */ + dcur.x = pSaveSecond.x - pSecond.x; + dcur.y = pSaveSecond.y - pSecond.y; /* Don't care about 'pThird' now */ - ConvexCheckTriple; + ConvexCheckTriple; - /* Decide on polygon type given accumulated status */ - if ( dirChanges > 2 ) return GF_POLYGON_COMPLEX; - if ( angleSign > 0 ) return GF_POLYGON_CONVEX_CCW; - if ( angleSign < 0 ) return GF_POLYGON_CONVEX_CW; - return GF_POLYGON_CONVEX_LINE; + /* Decide on polygon type given accumulated status */ + if ( dirChanges > 2 ) return GF_POLYGON_COMPLEX; + if ( angleSign > 0 ) return GF_POLYGON_CONVEX_CCW; + if ( angleSign < 0 ) return GF_POLYGON_CONVEX_CW; + return GF_POLYGON_CONVEX_LINE; } diff --git a/src/utils/path2d_stroker.c b/src/utils/path2d_stroker.c index 05b95ef..292acf3 100644 --- a/src/utils/path2d_stroker.c +++ b/src/utils/path2d_stroker.c @@ -61,7 +61,7 @@ static Bool ft_conic_is_small_enough( GF_Point2D* base, Fixed *angle_in, Fixed d2.y = base[0].y - base[1].y; close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y ); close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y ); - + if ( close1 ) { if ( close2 ) *angle_in = *angle_out = 0; @@ -80,70 +80,70 @@ static Bool ft_conic_is_small_enough( GF_Point2D* base, Fixed *angle_in, Fixed static void ft_cubic_split( GF_Point2D* base ) { - Fixed a, b, c, d; - base[6].x = base[3].x; - c = base[1].x; - d = base[2].x; - base[1].x = a = ( base[0].x + c ) / 2; - base[5].x = b = ( base[3].x + d ) / 2; - c = ( c + d ) / 2; - base[2].x = a = ( a + c ) / 2; - base[4].x = b = ( b + c ) / 2; - base[3].x = ( a + b ) / 2; - - base[6].y = base[3].y; - c = base[1].y; - d = base[2].y; - base[1].y = a = ( base[0].y + c ) / 2; - base[5].y = b = ( base[3].y + d ) / 2; - c = ( c + d ) / 2; - base[2].y = a = ( a + c ) / 2; - base[4].y = b = ( b + c ) / 2; - base[3].y = ( a + b ) / 2; + Fixed a, b, c, d; + base[6].x = base[3].x; + c = base[1].x; + d = base[2].x; + base[1].x = a = ( base[0].x + c ) / 2; + base[5].x = b = ( base[3].x + d ) / 2; + c = ( c + d ) / 2; + base[2].x = a = ( a + c ) / 2; + base[4].x = b = ( b + c ) / 2; + base[3].x = ( a + b ) / 2; + + base[6].y = base[3].y; + c = base[1].y; + d = base[2].y; + base[1].y = a = ( base[0].y + c ) / 2; + base[5].y = b = ( base[3].y + d ) / 2; + c = ( c + d ) / 2; + base[2].y = a = ( a + c ) / 2; + base[4].y = b = ( b + c ) / 2; + base[3].y = ( a + b ) / 2; } static Bool ft_cubic_is_small_enough(GF_Point2D *base, Fixed *angle_in, Fixed *angle_mid, Fixed *angle_out) { - GF_Point2D d1, d2, d3; - Fixed theta1, theta2; - s32 close1, close2, close3; - d1.x = base[2].x - base[3].x; - d1.y = base[2].y - base[3].y; - d2.x = base[1].x - base[2].x; - d2.y = base[1].y - base[2].y; - d3.x = base[0].x - base[1].x; - d3.y = base[0].y - base[1].y; - - close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y ); - close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y ); - close3 = FT_IS_SMALL( d3.x ) && FT_IS_SMALL( d3.y ); - - if ( close1 || close3 ) { + GF_Point2D d1, d2, d3; + Fixed theta1, theta2; + s32 close1, close2, close3; + d1.x = base[2].x - base[3].x; + d1.y = base[2].y - base[3].y; + d2.x = base[1].x - base[2].x; + d2.y = base[1].y - base[2].y; + d3.x = base[0].x - base[1].x; + d3.y = base[0].y - base[1].y; + + close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y ); + close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y ); + close3 = FT_IS_SMALL( d3.x ) && FT_IS_SMALL( d3.y ); + + if ( close1 || close3 ) { if ( close2 ) { /* basically a point */ *angle_in = *angle_out = *angle_mid = 0; } else if ( close1 ) { *angle_in = *angle_mid = gf_atan2( d2.y, d2.x); *angle_out = gf_atan2( d3.y, d3.x); - } - /* close2 */ + } + /* close2 */ else { *angle_in = gf_atan2(d1.y, d1.x); *angle_mid = *angle_out = gf_atan2(d2.y, d2.x); } - } - else if ( close2 ) { + } + else if ( close2 ) { *angle_in = *angle_mid = gf_atan2(d1.y, d1.x); *angle_out = gf_atan2(d3.y, d3.x); - } else { + } else { *angle_in = gf_atan2(d1.y, d1.x); *angle_mid = gf_atan2(d2.y, d2.x); *angle_out = gf_atan2(d3.y, d3.x); - } - theta1 = ABS( gf_angle_diff( *angle_in, *angle_mid ) ); - theta2 = ABS( gf_angle_diff( *angle_mid, *angle_out ) ); - return ((theta1 < FT_SMALL_CUBIC_THRESHOLD) && (theta2 < FT_SMALL_CUBIC_THRESHOLD )) ? 1 : 0; + } + theta1 = ABS( gf_angle_diff( *angle_in, *angle_mid ) ); + theta2 = ABS( gf_angle_diff( *angle_mid, *angle_out ) ); + return ((theta1 < FT_SMALL_CUBIC_THRESHOLD) && (theta2 < FT_SMALL_CUBIC_THRESHOLD )) ? 1 : 0; } @@ -229,8 +229,8 @@ static s32 ft_stroke_border_lineto( FT_StrokeBorder border, GF_Point2D* t static s32 ft_stroke_border_conicto( FT_StrokeBorder border, GF_Point2D* control, GF_Point2D* to ) { - assert( border->start >= 0 ); - if (ft_stroke_border_grow( border, 2 )==0) { + assert( border->start >= 0 ); + if (ft_stroke_border_grow( border, 2 )==0) { GF_Point2D* vec = border->points + border->num_points; u8 *tag = border->tags + border->num_points; @@ -241,17 +241,17 @@ static s32 ft_stroke_border_conicto( FT_StrokeBorder border, GF_Point2D* tag[1] = FT_STROKE_TAG_ON; border->num_points += 2; - } else { + } else { return -1; } - border->movable = 0; - return 0; + border->movable = 0; + return 0; } static s32 ft_stroke_border_cubicto( FT_StrokeBorder border, - GF_Point2D* control1, - GF_Point2D* control2, - GF_Point2D* to ) + GF_Point2D* control1, + GF_Point2D* control2, + GF_Point2D* to ) { assert( border->start >= 0 ); @@ -278,10 +278,10 @@ static s32 ft_stroke_border_cubicto( FT_StrokeBorder border, static s32 ft_stroke_border_arcto( FT_StrokeBorder border, - GF_Point2D* center, - Fixed radius, - Fixed angle_start, - Fixed angle_diff ) + GF_Point2D* center, + Fixed radius, + Fixed angle_start, + Fixed angle_diff ) { Fixed total, angle, step, rotate, next, theta; GF_Point2D a, b, a2, b2; @@ -301,7 +301,7 @@ static s32 ft_stroke_border_arcto( FT_StrokeBorder border, step = FT_ARC_CUBIC_ANGLE; else if ( step < -FT_ARC_CUBIC_ANGLE ) step = -FT_ARC_CUBIC_ANGLE; - + next = angle + step; theta = step; if ( theta < 0 ) @@ -343,19 +343,19 @@ static s32 ft_stroke_border_arcto( FT_StrokeBorder border, static s32 ft_stroke_border_moveto(FT_StrokeBorder border, GF_Point2D* to ) { - /* close current open path if any ? */ - if ( border->start >= 0 ) + /* close current open path if any ? */ + if ( border->start >= 0 ) ft_stroke_border_close( border ); - border->start = border->num_points; - border->movable = 0; - return ft_stroke_border_lineto( border, to, 0 ); + border->start = border->num_points; + border->movable = 0; + return ft_stroke_border_lineto( border, to, 0 ); } static s32 ft_stroke_border_get_counts(FT_StrokeBorder border, - u32 *anum_points, - u32 *anum_contours ) + u32 *anum_points, + u32 *anum_contours ) { s32 error = 0; u32 num_points = 0; @@ -372,9 +372,9 @@ static s32 ft_stroke_border_get_counts(FT_StrokeBorder border, in_contour = 1; } else if ( in_contour == 0 ) goto Fail; - + if ( tags[0] & FT_STROKE_TAG_END ) { - if ( in_contour == 0 ) + if ( in_contour == 0 ) goto Fail; in_contour = 0; num_contours++; @@ -405,7 +405,7 @@ static void ft_stroke_border_export( FT_StrokeBorder border, GF_Path* outl /* copy point locations */ memcpy(outline->points + outline->n_points, border->points, sizeof(GF_Point2D)*border->num_points); - + /* copy tags */ { u32 count = border->num_points; @@ -440,13 +440,13 @@ static void ft_stroke_border_export( FT_StrokeBorder border, GF_Path* outl } - /***************************************************************************/ - /***************************************************************************/ - /***** *****/ - /***** STROKER *****/ - /***** *****/ - /***************************************************************************/ - /***************************************************************************/ +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** STROKER *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ #define FT_SIDE_TO_ROTATE( s ) ( GF_PI2 - (s) * GF_PI ) @@ -469,30 +469,30 @@ typedef struct FT_StrokerRec_ } FT_StrokerRec, FT_Stroker; - /* creates a circular arc at a corner or cap */ +/* creates a circular arc at a corner or cap */ static s32 ft_stroker_arcto( FT_Stroker *stroker, s32 side ) { - Fixed total, rotate; - Fixed radius = stroker->radius; - s32 error = 0; - FT_StrokeBorder border = stroker->borders + side; - rotate = FT_SIDE_TO_ROTATE( side ); - total = gf_angle_diff( stroker->angle_in, stroker->angle_out); - if ( total == GF_PI ) total = -rotate * 2; - error = ft_stroke_border_arcto( border, - &stroker->center, - radius, - stroker->angle_in + rotate, - total ); - border->movable = 0; - return error; + Fixed total, rotate; + Fixed radius = stroker->radius; + s32 error = 0; + FT_StrokeBorder border = stroker->borders + side; + rotate = FT_SIDE_TO_ROTATE( side ); + total = gf_angle_diff( stroker->angle_in, stroker->angle_out); + if ( total == GF_PI ) total = -rotate * 2; + error = ft_stroke_border_arcto( border, + &stroker->center, + radius, + stroker->angle_in + rotate, + total ); + border->movable = 0; + return error; } - /* adds a cap at the end of an opened path */ +/* adds a cap at the end of an opened path */ static s32 ft_stroker_cap(FT_Stroker *stroker, Fixed angle, s32 side) { - s32 error = 0; - if ( stroker->line_cap == GF_LINE_CAP_ROUND) { + s32 error = 0; + if ( stroker->line_cap == GF_LINE_CAP_ROUND) { /* OK we cheat a bit here compared to FT original code, and use a rough cubic cap instead of a circle to deal with arbitrary orientation of regular paths where arc cap is not always properly oriented. Rather than computing orientation we simply approximate to conic - btw this takes less memory than @@ -544,7 +544,7 @@ static s32 ft_stroker_cap(FT_Stroker *stroker, Fixed angle, s32 side) delta.y += delta2.y + stroker->center.y; error = ft_stroke_border_lineto( border, &delta, 0 ); - } else if ( stroker->line_cap == GF_LINE_CAP_TRIANGLE) { + } else if ( stroker->line_cap == GF_LINE_CAP_TRIANGLE) { /* add a triangle cap */ GF_Point2D delta; Fixed radius = stroker->radius; @@ -554,10 +554,10 @@ static s32 ft_stroker_cap(FT_Stroker *stroker, Fixed angle, s32 side) delta.x += stroker->center.x; delta.y += stroker->center.y; error = ft_stroke_border_lineto(border, &delta, 0); - } + } Exit: - return error; + return error; } @@ -600,7 +600,7 @@ static s32 ft_stroker_inside(FT_Stroker *stroker, s32 side) } - /* process an outside corner, i.e. compute bevel/miter/round */ +/* process an outside corner, i.e. compute bevel/miter/round */ static s32 ft_stroker_outside( FT_Stroker *stroker, s32 side ) { FT_StrokeBorder border = stroker->borders + side; @@ -613,7 +613,7 @@ static s32 ft_stroker_outside( FT_Stroker *stroker, s32 side ) join = GF_LINE_JOIN_MITER; sin_theta = gf_sin(gf_angle_diff( stroker->angle_out - GF_PI, stroker->angle_in) / 2 ); if (sin_theta) { - inv_sin_theta = gf_invfix(sin_theta); + inv_sin_theta = gf_invfix(sin_theta); if (inv_sin_theta > stroker->miter_limit) join = GF_LINE_JOIN_BEVEL; } else { join = GF_LINE_JOIN_BEVEL; @@ -655,7 +655,7 @@ static s32 ft_stroker_outside( FT_Stroker *stroker, s32 side ) if ( sigma >= FIX_ONE ) { miter = 0; - } + } /* this is a miter (broken angle) */ if ( miter ) { @@ -727,62 +727,62 @@ static s32 ft_stroker_process_corner(FT_Stroker *stroker ) { s32 error = 0; Fixed turn; - s32 inside_side; + s32 inside_side; turn = gf_angle_diff( stroker->angle_in, stroker->angle_out ); - /* no specific corner processing is required if the turn is 0 */ - if ( turn == 0 ) + /* no specific corner processing is required if the turn is 0 */ + if ( turn == 0 ) goto Exit; - /* when we turn to the right, the inside side is 0 */ - inside_side = 0; - /* otherwise, the inside side is 1 */ - if (turn < 0 ) + /* when we turn to the right, the inside side is 0 */ + inside_side = 0; + /* otherwise, the inside side is 1 */ + if (turn < 0 ) inside_side = 1; - /* process the inside side */ + /* process the inside side */ error = ft_stroker_inside( stroker, inside_side ); if ( error ) goto Exit; - /* process the outside side */ - error = ft_stroker_outside( stroker, 1 - inside_side ); + /* process the outside side */ + error = ft_stroker_outside( stroker, 1 - inside_side ); Exit: - return error; + return error; } - /* add two points to the left and right borders corresponding to the */ - /* start of the subpath.. */ +/* add two points to the left and right borders corresponding to the */ +/* start of the subpath.. */ static s32 ft_stroker_subpath_start( FT_Stroker *stroker, Fixed start_angle ) { GF_Point2D delta; GF_Point2D point; s32 error; FT_StrokeBorder border; - + delta = gf_v2d_from_polar(stroker->radius, start_angle + GF_PI2 ); - point.x = stroker->center.x + delta.x; - point.y = stroker->center.y + delta.y; + point.x = stroker->center.x + delta.x; + point.y = stroker->center.y + delta.y; - border = stroker->borders; - error = ft_stroke_border_moveto( border, &point ); - if ( error ) + border = stroker->borders; + error = ft_stroke_border_moveto( border, &point ); + if ( error ) goto Exit; - point.x = stroker->center.x - delta.x; - point.y = stroker->center.y - delta.y; + point.x = stroker->center.x - delta.x; + point.y = stroker->center.y - delta.y; - border++; - error = ft_stroke_border_moveto( border, &point ); + border++; + error = ft_stroke_border_moveto( border, &point ); - /* save angle for last cap */ - stroker->subpath_angle = start_angle; - stroker->first_point = 0; + /* save angle for last cap */ + stroker->subpath_angle = start_angle; + stroker->first_point = 0; Exit: - return error; + return error; } @@ -794,31 +794,31 @@ static s32 FT_Stroker_LineTo( FT_Stroker *stroker, GF_Point2D* to, Bool is_last Fixed angle; s32 side; - delta.x = to->x - stroker->center.x; - delta.y = to->y - stroker->center.y; + delta.x = to->x - stroker->center.x; + delta.y = to->y - stroker->center.y; if (!is_last && !delta.x && !delta.y) return 0; - angle = gf_atan2( delta.y, delta.x); - delta = gf_v2d_from_polar(stroker->radius, angle + GF_PI2 ); + angle = gf_atan2( delta.y, delta.x); + delta = gf_v2d_from_polar(stroker->radius, angle + GF_PI2 ); - /* process corner if necessary */ - if ( stroker->first_point ) { + /* process corner if necessary */ + if ( stroker->first_point ) { /* This is the first segment of a subpath. We need to */ /* add a point to each border at their respective starting */ /* point locations. */ error = ft_stroker_subpath_start( stroker, angle ); if ( error ) goto Exit; - } else { + } else { /* process the current corner */ stroker->angle_out = angle; error = ft_stroker_process_corner( stroker ); - if ( error ) + if ( error ) goto Exit; - } + } - /* now add a line segment to both the "inside" and "outside" paths */ - for ( border = stroker->borders, side = 1; side >= 0; side--, border++ ) { + /* now add a line segment to both the "inside" and "outside" paths */ + for ( border = stroker->borders, side = 1; side >= 0; side--, border++ ) { GF_Point2D point; point.x = to->x + delta.x; point.y = to->y + delta.y; @@ -829,36 +829,36 @@ static s32 FT_Stroker_LineTo( FT_Stroker *stroker, GF_Point2D* to, Bool is_last delta.x = -delta.x; delta.y = -delta.y; - } - stroker->angle_in = angle; - stroker->center = *to; + } + stroker->angle_in = angle; + stroker->center = *to; Exit: - return error; + return error; } static s32 FT_Stroker_ConicTo(FT_Stroker *stroker, GF_Point2D* control, GF_Point2D * to) { s32 error = 0; - GF_Point2D bez_stack[34]; - GF_Point2D* arc; - GF_Point2D* limit = bez_stack + 30; - Fixed start_angle; - Bool first_arc = 1; + GF_Point2D bez_stack[34]; + GF_Point2D* arc; + GF_Point2D* limit = bez_stack + 30; + Fixed start_angle; + Bool first_arc = 1; - arc = bez_stack; - arc[0] = *to; - arc[1] = *control; - arc[2] = stroker->center; + arc = bez_stack; + arc[0] = *to; + arc[1] = *control; + arc[2] = stroker->center; - while ( arc >= bez_stack ) { + while ( arc >= bez_stack ) { Fixed angle_in, angle_out; angle_in = angle_out = 0; /* remove compiler warnings */ if ( arc < limit && - !ft_conic_is_small_enough( arc, &angle_in, &angle_out ) ) + !ft_conic_is_small_enough( arc, &angle_in, &angle_out ) ) { ft_conic_split( arc ); arc += 2; @@ -881,7 +881,7 @@ static s32 FT_Stroker_ConicTo(FT_Stroker *stroker, GF_Point2D* control, GF_Poin /* the arc's angle is small enough; we can add it directly to each */ /* border */ - { + { GF_Point2D ctrl, end; Fixed theta, phi, rotate; Fixed length; @@ -914,39 +914,39 @@ static s32 FT_Stroker_ConicTo(FT_Stroker *stroker, GF_Point2D* control, GF_Poin if ( arc < bez_stack ) stroker->angle_in = angle_out; - } + } - stroker->center = *to; + stroker->center = *to; Exit: - return error; + return error; } static s32 FT_Stroker_CubicTo(FT_Stroker *stroker, - GF_Point2D* control1, - GF_Point2D* control2, - GF_Point2D* to ) + GF_Point2D* control1, + GF_Point2D* control2, + GF_Point2D* to ) { - s32 error = 0; + s32 error = 0; GF_Point2D bez_stack[37]; - GF_Point2D* arc; - GF_Point2D* limit = bez_stack + 32; - Fixed start_angle; - Bool first_arc = 1; - - arc = bez_stack; - arc[0] = *to; - arc[1] = *control2; - arc[2] = *control1; - arc[3] = stroker->center; - - while ( arc >= bez_stack ) { + GF_Point2D* arc; + GF_Point2D* limit = bez_stack + 32; + Fixed start_angle; + Bool first_arc = 1; + + arc = bez_stack; + arc[0] = *to; + arc[1] = *control2; + arc[2] = *control1; + arc[3] = stroker->center; + + while ( arc >= bez_stack ) { Fixed angle_in, angle_mid, angle_out; /* remove compiler warnings */ angle_in = angle_out = angle_mid = 0; - if (arc < limit && - !ft_cubic_is_small_enough( arc, &angle_in, &angle_mid, &angle_out ) ) + if (arc < limit && + !ft_cubic_is_small_enough( arc, &angle_in, &angle_mid, &angle_out ) ) { ft_cubic_split( arc ); arc += 3; @@ -1003,7 +1003,7 @@ static s32 FT_Stroker_CubicTo(FT_Stroker *stroker, end.y += arc[0].y; error = ft_stroke_border_cubicto( stroker->borders + side, - &ctrl1, &ctrl2, &end ); + &ctrl1, &ctrl2, &end ); if ( error ) goto Exit; } @@ -1012,41 +1012,41 @@ static s32 FT_Stroker_CubicTo(FT_Stroker *stroker, arc -= 3; if ( arc < bez_stack ) stroker->angle_in = angle_out; - } + } - stroker->center = *to; + stroker->center = *to; Exit: - return error; + return error; } static s32 FT_Stroker_BeginSubPath(FT_Stroker *stroker, GF_Point2D* to) { - /* We cannot process the first point, because there is not enough */ - /* information regarding its corner/cap. The latter will be processed */ - /* in the "end_subpath" routine. */ - /* */ - stroker->first_point = 1; - stroker->center = *to; - - /* record the subpath start point index for each border */ - stroker->subpath_start = *to; - return 0; + /* We cannot process the first point, because there is not enough */ + /* information regarding its corner/cap. The latter will be processed */ + /* in the "end_subpath" routine. */ + /* */ + stroker->first_point = 1; + stroker->center = *to; + + /* record the subpath start point index for each border */ + stroker->subpath_start = *to; + return 0; } static s32 ft_stroker_add_reverse_left( FT_Stroker *stroker, Bool open ) { - FT_StrokeBorder right = stroker->borders + 0; - FT_StrokeBorder left = stroker->borders + 1; - s32 new_points; - s32 error = 0; + FT_StrokeBorder right = stroker->borders + 0; + FT_StrokeBorder left = stroker->borders + 1; + s32 new_points; + s32 error = 0; if (!left->num_points) return 0; - assert( left->start >= 0 ); - new_points = left->num_points - left->start; - if ( new_points > 0 ) { + assert( left->start >= 0 ); + new_points = left->num_points - left->start; + if ( new_points > 0 ) { error = ft_stroke_border_grow( right, (u32)new_points ); if ( error ) goto Exit; @@ -1063,7 +1063,7 @@ static s32 ft_stroker_add_reverse_left( FT_Stroker *stroker, Bool open ) if ( open ) dst_tag[0] &= ~( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END ); - else { + else { /* switch begin/end tags if necessary.. */ if ( dst_tag[0] & ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END ) ) dst_tag[0] ^= ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END ); @@ -1081,16 +1081,16 @@ static s32 ft_stroker_add_reverse_left( FT_Stroker *stroker, Bool open ) right->movable = 0; left->movable = 0; - } + } Exit: - return error; + return error; } /* there's a lot of magic in this function! */ static s32 FT_Stroker_EndSubPath( FT_Stroker *stroker, Bool do_close) { - s32 error = 0; + s32 error = 0; FT_StrokeBorder right = stroker->borders; if (do_close) { Fixed turn; @@ -1138,7 +1138,7 @@ static s32 FT_Stroker_EndSubPath( FT_Stroker *stroker, Bool do_close) /* now add the final cap */ stroker->center = stroker->subpath_start; error = ft_stroker_cap( stroker, - stroker->subpath_angle + GF_PI, 0 ); + stroker->subpath_angle + GF_PI, 0 ); if ( error ) goto Exit; @@ -1154,21 +1154,21 @@ Exit: static s32 FT_Stroker_GetCounts( FT_Stroker *stroker, u32 *anum_points, u32 *anum_contours ) { - u32 count1, count2, num_points = 0; - u32 count3, count4, num_contours = 0; - s32 error; - + u32 count1, count2, num_points = 0; + u32 count3, count4, num_contours = 0; + s32 error; + error = ft_stroke_border_get_counts( stroker->borders + 0, &count1, &count2 ); if ( error ) goto Exit; - error = ft_stroke_border_get_counts( stroker->borders + 1, &count3, &count4 ); - if ( error ) goto Exit; - num_points = count1 + count3; - num_contours = count2 + count4; + error = ft_stroke_border_get_counts( stroker->borders + 1, &count3, &count4 ); + if ( error ) goto Exit; + num_points = count1 + count3; + num_contours = count2 + count4; Exit: - *anum_points = num_points; - *anum_contours = num_contours; - return error; + *anum_points = num_points; + *anum_contours = num_contours; + return error; } /* @@ -1189,159 +1189,159 @@ static s32 FT_Stroker_ParseOutline(FT_Stroker *stroker, GF_Path* outline) s32 tag; /* current point's state */ if ( !outline || !stroker ) - return -1; + return -1; first = 0; for ( n = 0; n < outline->n_contours; n++ ) { - s32 closed_subpath; - s32 last; /* index of last point in contour */ - - last = outline->contours[n]; - limit = outline->points + last; - - v_start = outline->points[first]; - v_last = outline->points[last]; - - v_control = v_start; - - point = outline->points + first; - tags = outline->tags + first; - tag = tags[0]; - - /* A contour cannot start with a cubic control point! */ - if ( tag == GF_PATH_CURVE_CUBIC ) - goto Invalid_Outline; - - /* check first point to determine origin */ - if ( tag == GF_PATH_CURVE_CONIC ) { - /* First point is conic control. Yes, this happens. */ - if ( outline->tags[last] & GF_PATH_CURVE_ON ) { - /* start at last point if it is on the curve */ - v_start = v_last; - limit--; - } else { - /* if both first and last points are conic, */ - /* start at their middle and record its position */ - /* for closure */ - v_start.x = ( v_start.x + v_last.x ) / 2; - v_start.y = ( v_start.y + v_last.y ) / 2; - - v_last = v_start; - } - point--; - tags--; - } - closed_subpath = (outline->tags[outline->contours[n]]==GF_PATH_CLOSE) ? 1 : 0; - - error = FT_Stroker_BeginSubPath(stroker, &v_start); - if ( error ) - goto Exit; - - /*subpath is a single point, force a lineTo to start for the stroker to compute lineCap*/ - if (point==limit) { - error = FT_Stroker_LineTo(stroker, &v_start, 1); - closed_subpath = 0; - goto Close; - } - - while ( point < limit ) { - point++; - tags++; - - tag = tags[0]; - switch ( tag ) { - case GF_PATH_CURVE_ON: /* emit a single line_to */ - case GF_PATH_CLOSE: /* emit a single line_to */ - { - GF_Point2D vec; - vec.x = point->x; - vec.y = point->y; - - error = FT_Stroker_LineTo( stroker, &vec, (point == limit) ? 1 : 0 ); - if ( error ) - goto Exit; - continue; - } - - case GF_PATH_CURVE_CONIC: /* consume conic arcs */ - v_control.x = point->x; - v_control.y = point->y; - - Do_Conic: - if ( point < limit ) { - GF_Point2D vec; - GF_Point2D v_middle; - - - point++; - tags++; - tag = tags[0]; - - vec = point[0]; - - if ( tag & GF_PATH_CURVE_ON) { - - error = FT_Stroker_ConicTo( stroker, &v_control, &vec ); - if ( error ) - goto Exit; - continue; - } - - if ( tag != GF_PATH_CURVE_CONIC ) - goto Invalid_Outline; - - v_middle.x = ( v_control.x + vec.x ) / 2; - v_middle.y = ( v_control.y + vec.y ) / 2; - - error = FT_Stroker_ConicTo( stroker, &v_control, &v_middle ); - if ( error ) - goto Exit; - - v_control = vec; - goto Do_Conic; - } - error = FT_Stroker_ConicTo( stroker, &v_control, &v_start ); - goto Close; - - default: /* GF_PATH_CURVE_CUBIC */ - { - GF_Point2D vec1, vec2; - - if ( point + 1 > limit || - tags[1] != GF_PATH_CURVE_CUBIC ) - goto Invalid_Outline; - - point += 2; - tags += 2; - - vec1 = point[-2]; - vec2 = point[-1]; - - if ( point <= limit ) { - GF_Point2D vec; - vec = point[0]; - - error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec ); - if ( error ) - goto Exit; - continue; - } - error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start ); - goto Close; - } - break; - } - } + s32 closed_subpath; + s32 last; /* index of last point in contour */ + + last = outline->contours[n]; + limit = outline->points + last; + + v_start = outline->points[first]; + v_last = outline->points[last]; + + v_control = v_start; + + point = outline->points + first; + tags = outline->tags + first; + tag = tags[0]; + + /* A contour cannot start with a cubic control point! */ + if ( tag == GF_PATH_CURVE_CUBIC ) + goto Invalid_Outline; + + /* check first point to determine origin */ + if ( tag == GF_PATH_CURVE_CONIC ) { + /* First point is conic control. Yes, this happens. */ + if ( outline->tags[last] & GF_PATH_CURVE_ON ) { + /* start at last point if it is on the curve */ + v_start = v_last; + limit--; + } else { + /* if both first and last points are conic, */ + /* start at their middle and record its position */ + /* for closure */ + v_start.x = ( v_start.x + v_last.x ) / 2; + v_start.y = ( v_start.y + v_last.y ) / 2; + + v_last = v_start; + } + point--; + tags--; + } + closed_subpath = (outline->tags[outline->contours[n]]==GF_PATH_CLOSE) ? 1 : 0; + + error = FT_Stroker_BeginSubPath(stroker, &v_start); + if ( error ) + goto Exit; + + /*subpath is a single point, force a lineTo to start for the stroker to compute lineCap*/ + if (point==limit) { + error = FT_Stroker_LineTo(stroker, &v_start, 1); + closed_subpath = 0; + goto Close; + } + + while ( point < limit ) { + point++; + tags++; + + tag = tags[0]; + switch ( tag ) { + case GF_PATH_CURVE_ON: /* emit a single line_to */ + case GF_PATH_CLOSE: /* emit a single line_to */ + { + GF_Point2D vec; + vec.x = point->x; + vec.y = point->y; + + error = FT_Stroker_LineTo( stroker, &vec, (point == limit) ? 1 : 0 ); + if ( error ) + goto Exit; + continue; + } + + case GF_PATH_CURVE_CONIC: /* consume conic arcs */ + v_control.x = point->x; + v_control.y = point->y; + +Do_Conic: + if ( point < limit ) { + GF_Point2D vec; + GF_Point2D v_middle; + + + point++; + tags++; + tag = tags[0]; + + vec = point[0]; + + if ( tag & GF_PATH_CURVE_ON) { + + error = FT_Stroker_ConicTo( stroker, &v_control, &vec ); + if ( error ) + goto Exit; + continue; + } + + if ( tag != GF_PATH_CURVE_CONIC ) + goto Invalid_Outline; + + v_middle.x = ( v_control.x + vec.x ) / 2; + v_middle.y = ( v_control.y + vec.y ) / 2; + + error = FT_Stroker_ConicTo( stroker, &v_control, &v_middle ); + if ( error ) + goto Exit; + + v_control = vec; + goto Do_Conic; + } + error = FT_Stroker_ConicTo( stroker, &v_control, &v_start ); + goto Close; + + default: /* GF_PATH_CURVE_CUBIC */ + { + GF_Point2D vec1, vec2; + + if ( point + 1 > limit || + tags[1] != GF_PATH_CURVE_CUBIC ) + goto Invalid_Outline; + + point += 2; + tags += 2; + + vec1 = point[-2]; + vec2 = point[-1]; + + if ( point <= limit ) { + GF_Point2D vec; + vec = point[0]; + + error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec ); + if ( error ) + goto Exit; + continue; + } + error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start ); + goto Close; + } + break; + } + } Close: - if ( error ) goto Exit; + if ( error ) goto Exit; - error = FT_Stroker_EndSubPath(stroker, closed_subpath); - if ( error ) - goto Exit; + error = FT_Stroker_EndSubPath(stroker, closed_subpath); + if ( error ) + goto Exit; - first = last + 1; + first = last + 1; } return 0; @@ -1432,7 +1432,7 @@ static GF_Err gf_path_mergedashes(GF_Path *gp, u32 start_contour_index) dash_first_pt = 0; } /*skip first point of first dash in subpath (same as last point of last dash)*/ - for (i=1;ipoints[dash_first_pt + i]); if (e) return e; } @@ -1442,16 +1442,16 @@ static GF_Err gf_path_mergedashes(GF_Path *gp, u32 start_contour_index) memmove(gp->tags + dash_first_pt, gp->tags + dash_first_pt + dash_nb_pts, sizeof(u8)*(gp->n_points - dash_first_pt)); for (i=start_contour_index; in_contours-1; i++) { - gp->contours[i] = gp->contours[i+1] - dash_nb_pts; + gp->contours[i] = gp->contours[i+1] - dash_nb_pts; } gp->n_contours--; gp->contours = (u32 *)gf_realloc(gp->contours, sizeof(u32)*gp->n_contours); -/* - gp->points = gf_realloc(gp->points, sizeof(GF_Point2D)*gp->n_points); - gp->tags = gf_realloc(gp->tags, sizeof(u8)*gp->n_points); - gp->n_alloc_points = gp->n_points; -*/ + /* + gp->points = gf_realloc(gp->points, sizeof(GF_Point2D)*gp->n_points); + gp->tags = gf_realloc(gp->tags, sizeof(u8)*gp->n_points); + gp->n_alloc_points = gp->n_points; + */ return GF_OK; } @@ -1471,10 +1471,10 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ u32 i, start_ind; Fixed phase; s32 offset, toggle; - + dists = (Fixed *)gf_malloc(sizeof (Fixed) * nb_pts); if (dists == NULL) return GF_OUT_OF_MEM; - + /* initial values */ toggleinit = 1; offsetinit = 0; @@ -1533,7 +1533,7 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ if (pen->dash_offset > dists[i]) { pen->dash_offset -= dists[i]; dists[i] = 0; - } + } else if (pen->dash_offset) { Fixed a, x, y, dx, dy; @@ -1558,27 +1558,27 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ /* subpath fits within first dash and no offset*/ if (!dist && totaldist <= dash) { if (toggleinit) { - gf_path_add_move_to_vec(dashed, &pts[0]); + gf_path_add_move_to_vec(dashed, &pts[0]); for (i=1; in_contours - 1; } - + while (i < nb_pts - 1) { /* dash boundary is next */ if (dists[i] - dist > dash - phase) { @@ -1589,7 +1589,7 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ dy = pts[i + 1].y - pts[i].y; x = pts[i].x + gf_mulfix(a, dx); y = pts[i].y + gf_mulfix(a, dy); - + if (!toggle_check || ((x != pts[i].x) || (y != pts[i].y))) { if (toggle) { e = gf_path_add_line_to(dashed, x, y); @@ -1600,7 +1600,7 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ if (e) goto err_exit; } } - + /* advance to next dash */ toggle = !toggle; phase = 0; @@ -1618,7 +1618,7 @@ static GF_Err evg_dash_subpath(GF_Path *dashed, GF_Point2D *pts, u32 nb_pts, GF_ e = gf_path_add_line_to_vec(dashed, &pts[i]); if (e) goto err_exit; toggle_check = 1; - + if ( (firstindex>=0) && (i == (nb_pts - 1) && ((firstindex + 1) != (s32) start_ind ) )) { /*merge if closed path*/ if ((pts[0].x==pts[nb_pts-1].x) && (pts[0].y==pts[nb_pts-1].y)) { @@ -1689,8 +1689,8 @@ GF_Path *gf_path_get_outline(GF_Path *path, GF_PenSettings pen) if (!path || !pen.width) return NULL; memset(&stroker, 0, sizeof(stroker)); - stroker.borders[0].start = -1; - stroker.borders[1].start = -1; + stroker.borders[0].start = -1; + stroker.borders[1].start = -1; stroker.line_cap = pen.cap; stroker.line_join = pen.join; stroker.miter_limit = pen.miterLimit; @@ -1775,7 +1775,7 @@ GF_Path *gf_path_get_outline(GF_Path *path, GF_PenSettings pen) if (stroker.borders[0].tags) gf_free(stroker.borders[0].tags); if (stroker.borders[1].points) gf_free(stroker.borders[1].points); if (stroker.borders[1].tags) gf_free(stroker.borders[1].tags); - + if (dashed) gf_path_del(dashed); if (scaled) gf_path_del(scaled); diff --git a/src/utils/ringbuffer.c b/src/utils/ringbuffer.c index d578674..c60a1ee 100644 --- a/src/utils/ringbuffer.c +++ b/src/utils/ringbuffer.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include @@ -27,29 +27,29 @@ GF_EXPORT GF_Ringbuffer * gf_ringbuffer_new(u32 sz) { - GF_Ringbuffer *rb; - - rb = gf_malloc (sizeof (GF_Ringbuffer)); - if (sz % 2 != 0) - sz++; - rb->size = sz; - rb->size_mask = rb->size; - rb->size_mask -= 1; - rb->write_ptr = 0; - rb->read_ptr = 0; - rb->buf = gf_malloc (rb->size); - rb->mx = gf_mx_new("RingBufferMutex"); - return rb; + GF_Ringbuffer *rb; + + rb = gf_malloc (sizeof (GF_Ringbuffer)); + if (sz % 2 != 0) + sz++; + rb->size = sz; + rb->size_mask = rb->size; + rb->size_mask -= 1; + rb->write_ptr = 0; + rb->read_ptr = 0; + rb->buf = gf_malloc (rb->size); + rb->mx = gf_mx_new("RingBufferMutex"); + return rb; } GF_EXPORT -void gf_ringbuffer_del(GF_Ringbuffer * ringbuffer){ - if (!ringbuffer) - return; - gf_mx_p(ringbuffer->mx); - gf_free( ringbuffer->buf); - ringbuffer->mx = NULL; - gf_mx_v(ringbuffer->mx); +void gf_ringbuffer_del(GF_Ringbuffer * ringbuffer) { + if (!ringbuffer) + return; + gf_mx_p(ringbuffer->mx); + gf_free( ringbuffer->buf); + ringbuffer->mx = NULL; + gf_mx_v(ringbuffer->mx); } /*! @@ -61,99 +61,99 @@ void gf_ringbuffer_del(GF_Ringbuffer * ringbuffer){ GF_EXPORT u32 gf_ringbuffer_available_for_write (GF_Ringbuffer * rb) { - u32 w, r; - - w = rb->write_ptr; - r = rb->read_ptr; - - if (w > r) { - return ((r - w + rb->size) & rb->size_mask) - 1; - } else if (w < r) { - return (r - w) - 1; - } else { - return rb->size - 1; - } + u32 w, r; + + w = rb->write_ptr; + r = rb->read_ptr; + + if (w > r) { + return ((r - w + rb->size) & rb->size_mask) - 1; + } else if (w < r) { + return (r - w) - 1; + } else { + return rb->size - 1; + } } GF_EXPORT u32 gf_ringbuffer_available_for_read (GF_Ringbuffer * rb) { - size_t w, r; + size_t w, r; - w = rb->write_ptr; - r = rb->read_ptr; + w = rb->write_ptr; + r = rb->read_ptr; - if (w > r) { - return (u32) (w - r); - } else { - return (u32) (w - r + rb->size) & rb->size_mask; - } + if (w > r) { + return (u32) (w - r); + } else { + return (u32) (w - r + rb->size) & rb->size_mask; + } } GF_EXPORT u32 gf_ringbuffer_read(GF_Ringbuffer *rb, u8 *dest, u32 szDest) { - u32 free_sz, sz2, to_read, n1, n2; + u32 free_sz, sz2, to_read, n1, n2; - if ((free_sz = gf_ringbuffer_available_for_read(rb)) == 0) { - return 0; - } + if ((free_sz = gf_ringbuffer_available_for_read(rb)) == 0) { + return 0; + } - to_read = szDest > free_sz ? free_sz : szDest; + to_read = szDest > free_sz ? free_sz : szDest; - sz2 = rb->read_ptr + to_read; + sz2 = rb->read_ptr + to_read; - if (sz2 > rb->size) { - n1 = rb->size - rb->read_ptr; - n2 = sz2 & rb->size_mask; - } else { - n1 = to_read; - n2 = 0; - } + if (sz2 > rb->size) { + n1 = rb->size - rb->read_ptr; + n2 = sz2 & rb->size_mask; + } else { + n1 = to_read; + n2 = 0; + } - memcpy (dest, &(rb->buf[rb->read_ptr]), n1); - rb->read_ptr += n1; - rb->read_ptr &= rb->size_mask; + memcpy (dest, &(rb->buf[rb->read_ptr]), n1); + rb->read_ptr += n1; + rb->read_ptr &= rb->size_mask; - if (n2) { - memcpy (dest + n1, &(rb->buf[rb->read_ptr]), n2); - rb->read_ptr += n2; - rb->read_ptr &= rb->size_mask; - } + if (n2) { + memcpy (dest + n1, &(rb->buf[rb->read_ptr]), n2); + rb->read_ptr += n2; + rb->read_ptr &= rb->size_mask; + } - return to_read; + return to_read; } GF_EXPORT u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u8 *src, u32 sz) { - u32 free_sz, sz2, to_write, n1, n2; - - if ((free_sz = gf_ringbuffer_available_for_write(rb)) == 0) { - return 0; - } - - to_write = sz > free_sz ? free_sz : sz; - - sz2 = rb->write_ptr + to_write; - - if (sz2 > rb->size) { - n1 = rb->size - rb->write_ptr; - n2 = sz2 & rb->size_mask; - } else { - n1 = to_write; - n2 = 0; - } - - memcpy (&(rb->buf[rb->write_ptr]), src, n1); - rb->write_ptr += n1; - rb->write_ptr &= rb->size_mask; - - if (n2) { - memcpy (&(rb->buf[rb->write_ptr]), src + n1, n2); - rb->write_ptr += n2; - rb->write_ptr &= rb->size_mask; - } - return to_write; + u32 free_sz, sz2, to_write, n1, n2; + + if ((free_sz = gf_ringbuffer_available_for_write(rb)) == 0) { + return 0; + } + + to_write = sz > free_sz ? free_sz : sz; + + sz2 = rb->write_ptr + to_write; + + if (sz2 > rb->size) { + n1 = rb->size - rb->write_ptr; + n2 = sz2 & rb->size_mask; + } else { + n1 = to_write; + n2 = 0; + } + + memcpy (&(rb->buf[rb->write_ptr]), src, n1); + rb->write_ptr += n1; + rb->write_ptr &= rb->size_mask; + + if (n2) { + memcpy (&(rb->buf[rb->write_ptr]), src + n1, n2); + rb->write_ptr += n2; + rb->write_ptr &= rb->size_mask; + } + return to_write; } diff --git a/src/utils/sha1.c b/src/utils/sha1.c index 9f7c336..51400cc 100644 --- a/src/utils/sha1.c +++ b/src/utils/sha1.c @@ -1,3 +1,5 @@ +#ifndef GPAC_DISABLE_CORE_TOOLS + #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif @@ -43,9 +45,9 @@ struct __sha1_context { - u32 total[2]; - u32 state[5]; - u8 buffer[64]; + u32 total[2]; + u32 state[5]; + u8 buffer[64]; }; /* @@ -68,37 +70,37 @@ GF_SHA1Context *gf_sha1_starts() { GF_SHA1Context *ctx; GF_SAFEALLOC(ctx, GF_SHA1Context); - ctx->total[0] = 0; - ctx->total[1] = 0; - - ctx->state[0] = 0x67452301; - ctx->state[1] = 0xEFCDAB89; - ctx->state[2] = 0x98BADCFE; - ctx->state[3] = 0x10325476; - ctx->state[4] = 0xC3D2E1F0; + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xC3D2E1F0; return ctx; } static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) { - u32 temp, W[16], A, B, C, D, E; - - GET_UINT32_BE( W[0], data, 0 ); - GET_UINT32_BE( W[1], data, 4 ); - GET_UINT32_BE( W[2], data, 8 ); - GET_UINT32_BE( W[3], data, 12 ); - GET_UINT32_BE( W[4], data, 16 ); - GET_UINT32_BE( W[5], data, 20 ); - GET_UINT32_BE( W[6], data, 24 ); - GET_UINT32_BE( W[7], data, 28 ); - GET_UINT32_BE( W[8], data, 32 ); - GET_UINT32_BE( W[9], data, 36 ); - GET_UINT32_BE( W[10], data, 40 ); - GET_UINT32_BE( W[11], data, 44 ); - GET_UINT32_BE( W[12], data, 48 ); - GET_UINT32_BE( W[13], data, 52 ); - GET_UINT32_BE( W[14], data, 56 ); - GET_UINT32_BE( W[15], data, 60 ); + u32 temp, W[16], A, B, C, D, E; + + GET_UINT32_BE( W[0], data, 0 ); + GET_UINT32_BE( W[1], data, 4 ); + GET_UINT32_BE( W[2], data, 8 ); + GET_UINT32_BE( W[3], data, 12 ); + GET_UINT32_BE( W[4], data, 16 ); + GET_UINT32_BE( W[5], data, 20 ); + GET_UINT32_BE( W[6], data, 24 ); + GET_UINT32_BE( W[7], data, 28 ); + GET_UINT32_BE( W[8], data, 32 ); + GET_UINT32_BE( W[9], data, 36 ); + GET_UINT32_BE( W[10], data, 40 ); + GET_UINT32_BE( W[11], data, 44 ); + GET_UINT32_BE( W[12], data, 48 ); + GET_UINT32_BE( W[13], data, 52 ); + GET_UINT32_BE( W[14], data, 56 ); + GET_UINT32_BE( W[15], data, 60 ); #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) @@ -114,35 +116,35 @@ static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ } - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - E = ctx->state[4]; + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; #define F(x,y,z) (z ^ (x & (y ^ z))) #define K 0x5A827999 - P( A, B, C, D, E, W[0] ); - P( E, A, B, C, D, W[1] ); - P( D, E, A, B, C, W[2] ); - P( C, D, E, A, B, W[3] ); - P( B, C, D, E, A, W[4] ); - P( A, B, C, D, E, W[5] ); - P( E, A, B, C, D, W[6] ); - P( D, E, A, B, C, W[7] ); - P( C, D, E, A, B, W[8] ); - P( B, C, D, E, A, W[9] ); - P( A, B, C, D, E, W[10] ); - P( E, A, B, C, D, W[11] ); - P( D, E, A, B, C, W[12] ); - P( C, D, E, A, B, W[13] ); - P( B, C, D, E, A, W[14] ); - P( A, B, C, D, E, W[15] ); - P( E, A, B, C, D, R(16) ); - P( D, E, A, B, C, R(17) ); - P( C, D, E, A, B, R(18) ); - P( B, C, D, E, A, R(19) ); + P( A, B, C, D, E, W[0] ); + P( E, A, B, C, D, W[1] ); + P( D, E, A, B, C, W[2] ); + P( C, D, E, A, B, W[3] ); + P( B, C, D, E, A, W[4] ); + P( A, B, C, D, E, W[5] ); + P( E, A, B, C, D, W[6] ); + P( D, E, A, B, C, W[7] ); + P( C, D, E, A, B, W[8] ); + P( B, C, D, E, A, W[9] ); + P( A, B, C, D, E, W[10] ); + P( E, A, B, C, D, W[11] ); + P( D, E, A, B, C, W[12] ); + P( C, D, E, A, B, W[13] ); + P( B, C, D, E, A, W[14] ); + P( A, B, C, D, E, W[15] ); + P( E, A, B, C, D, R(16) ); + P( D, E, A, B, C, R(17) ); + P( C, D, E, A, B, R(18) ); + P( B, C, D, E, A, R(19) ); #undef K #undef F @@ -150,26 +152,26 @@ static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) #define F(x,y,z) (x ^ y ^ z) #define K 0x6ED9EBA1 - P( A, B, C, D, E, R(20) ); - P( E, A, B, C, D, R(21) ); - P( D, E, A, B, C, R(22) ); - P( C, D, E, A, B, R(23) ); - P( B, C, D, E, A, R(24) ); - P( A, B, C, D, E, R(25) ); - P( E, A, B, C, D, R(26) ); - P( D, E, A, B, C, R(27) ); - P( C, D, E, A, B, R(28) ); - P( B, C, D, E, A, R(29) ); - P( A, B, C, D, E, R(30) ); - P( E, A, B, C, D, R(31) ); - P( D, E, A, B, C, R(32) ); - P( C, D, E, A, B, R(33) ); - P( B, C, D, E, A, R(34) ); - P( A, B, C, D, E, R(35) ); - P( E, A, B, C, D, R(36) ); - P( D, E, A, B, C, R(37) ); - P( C, D, E, A, B, R(38) ); - P( B, C, D, E, A, R(39) ); + P( A, B, C, D, E, R(20) ); + P( E, A, B, C, D, R(21) ); + P( D, E, A, B, C, R(22) ); + P( C, D, E, A, B, R(23) ); + P( B, C, D, E, A, R(24) ); + P( A, B, C, D, E, R(25) ); + P( E, A, B, C, D, R(26) ); + P( D, E, A, B, C, R(27) ); + P( C, D, E, A, B, R(28) ); + P( B, C, D, E, A, R(29) ); + P( A, B, C, D, E, R(30) ); + P( E, A, B, C, D, R(31) ); + P( D, E, A, B, C, R(32) ); + P( C, D, E, A, B, R(33) ); + P( B, C, D, E, A, R(34) ); + P( A, B, C, D, E, R(35) ); + P( E, A, B, C, D, R(36) ); + P( D, E, A, B, C, R(37) ); + P( C, D, E, A, B, R(38) ); + P( B, C, D, E, A, R(39) ); #undef K #undef F @@ -177,26 +179,26 @@ static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) #define F(x,y,z) ((x & y) | (z & (x | y))) #define K 0x8F1BBCDC - P( A, B, C, D, E, R(40) ); - P( E, A, B, C, D, R(41) ); - P( D, E, A, B, C, R(42) ); - P( C, D, E, A, B, R(43) ); - P( B, C, D, E, A, R(44) ); - P( A, B, C, D, E, R(45) ); - P( E, A, B, C, D, R(46) ); - P( D, E, A, B, C, R(47) ); - P( C, D, E, A, B, R(48) ); - P( B, C, D, E, A, R(49) ); - P( A, B, C, D, E, R(50) ); - P( E, A, B, C, D, R(51) ); - P( D, E, A, B, C, R(52) ); - P( C, D, E, A, B, R(53) ); - P( B, C, D, E, A, R(54) ); - P( A, B, C, D, E, R(55) ); - P( E, A, B, C, D, R(56) ); - P( D, E, A, B, C, R(57) ); - P( C, D, E, A, B, R(58) ); - P( B, C, D, E, A, R(59) ); + P( A, B, C, D, E, R(40) ); + P( E, A, B, C, D, R(41) ); + P( D, E, A, B, C, R(42) ); + P( C, D, E, A, B, R(43) ); + P( B, C, D, E, A, R(44) ); + P( A, B, C, D, E, R(45) ); + P( E, A, B, C, D, R(46) ); + P( D, E, A, B, C, R(47) ); + P( C, D, E, A, B, R(48) ); + P( B, C, D, E, A, R(49) ); + P( A, B, C, D, E, R(50) ); + P( E, A, B, C, D, R(51) ); + P( D, E, A, B, C, R(52) ); + P( C, D, E, A, B, R(53) ); + P( B, C, D, E, A, R(54) ); + P( A, B, C, D, E, R(55) ); + P( E, A, B, C, D, R(56) ); + P( D, E, A, B, C, R(57) ); + P( C, D, E, A, B, R(58) ); + P( B, C, D, E, A, R(59) ); #undef K #undef F @@ -204,35 +206,35 @@ static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) #define F(x,y,z) (x ^ y ^ z) #define K 0xCA62C1D6 - P( A, B, C, D, E, R(60) ); - P( E, A, B, C, D, R(61) ); - P( D, E, A, B, C, R(62) ); - P( C, D, E, A, B, R(63) ); - P( B, C, D, E, A, R(64) ); - P( A, B, C, D, E, R(65) ); - P( E, A, B, C, D, R(66) ); - P( D, E, A, B, C, R(67) ); - P( C, D, E, A, B, R(68) ); - P( B, C, D, E, A, R(69) ); - P( A, B, C, D, E, R(70) ); - P( E, A, B, C, D, R(71) ); - P( D, E, A, B, C, R(72) ); - P( C, D, E, A, B, R(73) ); - P( B, C, D, E, A, R(74) ); - P( A, B, C, D, E, R(75) ); - P( E, A, B, C, D, R(76) ); - P( D, E, A, B, C, R(77) ); - P( C, D, E, A, B, R(78) ); - P( B, C, D, E, A, R(79) ); + P( A, B, C, D, E, R(60) ); + P( E, A, B, C, D, R(61) ); + P( D, E, A, B, C, R(62) ); + P( C, D, E, A, B, R(63) ); + P( B, C, D, E, A, R(64) ); + P( A, B, C, D, E, R(65) ); + P( E, A, B, C, D, R(66) ); + P( D, E, A, B, C, R(67) ); + P( C, D, E, A, B, R(68) ); + P( B, C, D, E, A, R(69) ); + P( A, B, C, D, E, R(70) ); + P( E, A, B, C, D, R(71) ); + P( D, E, A, B, C, R(72) ); + P( C, D, E, A, B, R(73) ); + P( B, C, D, E, A, R(74) ); + P( A, B, C, D, E, R(75) ); + P( E, A, B, C, D, R(76) ); + P( D, E, A, B, C, R(77) ); + P( C, D, E, A, B, R(78) ); + P( B, C, D, E, A, R(79) ); #undef K #undef F - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; - ctx->state[4] += E; + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; } /* @@ -240,51 +242,51 @@ static void sha1_process(GF_SHA1Context *ctx, u8 data[64] ) */ void gf_sha1_update(GF_SHA1Context *ctx, u8 *input, u32 ilen ) { - s32 fill; - u32 left; - - if( ilen <= 0 ) - return; - - left = ctx->total[0] & 0x3F; - fill = 64 - left; - - ctx->total[0] += ilen; - ctx->total[0] &= 0xFFFFFFFF; - - if( ctx->total[0] < (u32) ilen ) - ctx->total[1]++; - - if( left && (s32) ilen >= fill ) - { - memcpy( (void *) (ctx->buffer + left), - (void *) input, fill ); - sha1_process( ctx, ctx->buffer ); - input += fill; - ilen -= fill; - left = 0; - } - - while( ilen >= 64 ) - { - sha1_process( ctx, input ); - input += 64; - ilen -= 64; - } - - if( ilen > 0 ) - { - memcpy( (void *) (ctx->buffer + left), - (void *) input, ilen ); - } + s32 fill; + u32 left; + + if( ilen <= 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if( ctx->total[0] < (u32) ilen ) + ctx->total[1]++; + + if( left && (s32) ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), + (void *) input, fill ); + sha1_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while( ilen >= 64 ) + { + sha1_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if( ilen > 0 ) + { + memcpy( (void *) (ctx->buffer + left), + (void *) input, ilen ); + } } static const u8 sha1_padding[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* @@ -292,28 +294,28 @@ static const u8 sha1_padding[64] = */ void gf_sha1_finish(GF_SHA1Context *ctx, u8 output[20] ) { - u32 last, padn; - u32 high, low; - u8 msglen[8]; + u32 last, padn; + u32 high, low; + u8 msglen[8]; - high = ( ctx->total[0] >> 29 ) - | ( ctx->total[1] << 3 ); - low = ( ctx->total[0] << 3 ); + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); - PUT_UINT32_BE( high, msglen, 0 ); - PUT_UINT32_BE( low, msglen, 4 ); + PUT_UINT32_BE( high, msglen, 0 ); + PUT_UINT32_BE( low, msglen, 4 ); - last = ctx->total[0] & 0x3F; - padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - gf_sha1_update( ctx, (u8 *) sha1_padding, padn ); - gf_sha1_update( ctx, msglen, 8 ); + gf_sha1_update( ctx, (u8 *) sha1_padding, padn ); + gf_sha1_update( ctx, msglen, 8 ); - PUT_UINT32_BE( ctx->state[0], output, 0 ); - PUT_UINT32_BE( ctx->state[1], output, 4 ); - PUT_UINT32_BE( ctx->state[2], output, 8 ); - PUT_UINT32_BE( ctx->state[3], output, 12 ); - PUT_UINT32_BE( ctx->state[4], output, 16 ); + PUT_UINT32_BE( ctx->state[0], output, 0 ); + PUT_UINT32_BE( ctx->state[1], output, 4 ); + PUT_UINT32_BE( ctx->state[2], output, 8 ); + PUT_UINT32_BE( ctx->state[3], output, 12 ); + PUT_UINT32_BE( ctx->state[4], output, 16 ); gf_free(ctx); } @@ -327,17 +329,17 @@ void gf_sha1_finish(GF_SHA1Context *ctx, u8 output[20] ) * All Rights Reserved * * Freeware Public License (FPL) - * + * * This software is licensed as "freeware." Permission to distribute - * this software in source and binary forms, including incorporation - * into other products, is hereby granted without a fee. THIS SOFTWARE - * IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE HELD - * LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER - * DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA + * this software in source and binary forms, including incorporation + * into other products, is hereby granted without a fee. THIS SOFTWARE + * IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE HELD + * LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER + * DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA * OR DATA BEING RENDERED INACCURATE. - * + * ***************************************************************************** * $Id: sha1.c 12 2009-06-22 19:34:25Z paulej $ ***************************************************************************** @@ -371,22 +373,22 @@ void gf_sha1_finish(GF_SHA1Context *ctx, u8 output[20] ) * */ -/* +/* * This structure will hold context information for the hashing * operation */ struct __sha1_context { - unsigned Message_Digest[5]; /* Message Digest (output) */ + unsigned Message_Digest[5]; /* Message Digest (output) */ - unsigned Length_Low; /* Message length in bits */ - unsigned Length_High; /* Message length in bits */ + unsigned Length_Low; /* Message length in bits */ + unsigned Length_High; /* Message length in bits */ - unsigned char Message_Block[64]; /* 512-bit message blocks */ - int Message_Block_Index; /* Index into message block array */ + unsigned char Message_Block[64]; /* 512-bit message blocks */ + int Message_Block_Index; /* Index into message block array */ - int Computed; /* Is the digest computed? */ - int Corrupted; /* Is the message digest corruped? */ + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corruped? */ }; /* @@ -397,7 +399,7 @@ struct __sha1_context ((word) >> (32-(bits)))) -/* +/* * SHA1ProcessMessageBlock * * Description: @@ -414,106 +416,106 @@ struct __sha1_context * Many of the variable names in the SHAContext, especially the * single character names, were used because those were the names * used in the publication. - * + * * */ void SHA1ProcessMessageBlock(GF_SHA1Context *context) { - const unsigned K[] = /* Constants defined in SHA-1 */ - { - 0x5A827999, - 0x6ED9EBA1, - 0x8F1BBCDC, - 0xCA62C1D6 - }; - int t; /* Loop counter */ - unsigned temp; /* Temporary word value */ - unsigned W[80]; /* Word sequence */ - unsigned A, B, C, D, E; /* Word buffers */ - - /* - * Initialize the first 16 words in the array W - */ - for(t = 0; t < 16; t++) - { - W[t] = ((unsigned) context->Message_Block[t * 4]) << 24; - W[t] |= ((unsigned) context->Message_Block[t * 4 + 1]) << 16; - W[t] |= ((unsigned) context->Message_Block[t * 4 + 2]) << 8; - W[t] |= ((unsigned) context->Message_Block[t * 4 + 3]); - } - - for(t = 16; t < 80; t++) - { - W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); - } - - A = context->Message_Digest[0]; - B = context->Message_Digest[1]; - C = context->Message_Digest[2]; - D = context->Message_Digest[3]; - E = context->Message_Digest[4]; - - for(t = 0; t < 20; t++) - { - temp = SHA1CircularShift(5,A) + - ((B & C) | ((~B) & D)) + E + W[t] + K[0]; - temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - for(t = 20; t < 40; t++) - { - temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; - temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - for(t = 40; t < 60; t++) - { - temp = SHA1CircularShift(5,A) + - ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; - temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - for(t = 60; t < 80; t++) - { - temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; - temp &= 0xFFFFFFFF; - E = D; - D = C; - C = SHA1CircularShift(30,B); - B = A; - A = temp; - } - - context->Message_Digest[0] = - (context->Message_Digest[0] + A) & 0xFFFFFFFF; - context->Message_Digest[1] = - (context->Message_Digest[1] + B) & 0xFFFFFFFF; - context->Message_Digest[2] = - (context->Message_Digest[2] + C) & 0xFFFFFFFF; - context->Message_Digest[3] = - (context->Message_Digest[3] + D) & 0xFFFFFFFF; - context->Message_Digest[4] = - (context->Message_Digest[4] + E) & 0xFFFFFFFF; - - context->Message_Block_Index = 0; + const unsigned K[] = /* Constants defined in SHA-1 */ + { + 0x5A827999, + 0x6ED9EBA1, + 0x8F1BBCDC, + 0xCA62C1D6 + }; + int t; /* Loop counter */ + unsigned temp; /* Temporary word value */ + unsigned W[80]; /* Word sequence */ + unsigned A, B, C, D, E; /* Word buffers */ + + /* + * Initialize the first 16 words in the array W + */ + for(t = 0; t < 16; t++) + { + W[t] = ((unsigned) context->Message_Block[t * 4]) << 24; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 1]) << 16; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 2]) << 8; + W[t] |= ((unsigned) context->Message_Block[t * 4 + 3]); + } + + for(t = 16; t < 80; t++) + { + W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); + } + + A = context->Message_Digest[0]; + B = context->Message_Digest[1]; + C = context->Message_Digest[2]; + D = context->Message_Digest[3]; + E = context->Message_Digest[4]; + + for(t = 0; t < 20; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 20; t < 40; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 40; t < 60; t++) + { + temp = SHA1CircularShift(5,A) + + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + for(t = 60; t < 80; t++) + { + temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; + temp &= 0xFFFFFFFF; + E = D; + D = C; + C = SHA1CircularShift(30,B); + B = A; + A = temp; + } + + context->Message_Digest[0] = + (context->Message_Digest[0] + A) & 0xFFFFFFFF; + context->Message_Digest[1] = + (context->Message_Digest[1] + B) & 0xFFFFFFFF; + context->Message_Digest[2] = + (context->Message_Digest[2] + C) & 0xFFFFFFFF; + context->Message_Digest[3] = + (context->Message_Digest[3] + D) & 0xFFFFFFFF; + context->Message_Digest[4] = + (context->Message_Digest[4] + E) & 0xFFFFFFFF; + + context->Message_Block_Index = 0; } -/* +/* * SHA1PadMessage * * Description: @@ -538,51 +540,51 @@ void SHA1ProcessMessageBlock(GF_SHA1Context *context) */ static void SHA1PadMessage(GF_SHA1Context *context) { - /* - * Check to see if the current message block is too small to hold - * the initial padding bits and length. If so, we will pad the - * block, process it, and then continue padding into a second - * block. - */ - if (context->Message_Block_Index > 55) - { - context->Message_Block[context->Message_Block_Index++] = 0x80; - while(context->Message_Block_Index < 64) - { - context->Message_Block[context->Message_Block_Index++] = 0; - } - - SHA1ProcessMessageBlock(context); - - while(context->Message_Block_Index < 56) - { - context->Message_Block[context->Message_Block_Index++] = 0; - } - } - else - { - context->Message_Block[context->Message_Block_Index++] = 0x80; - while(context->Message_Block_Index < 56) - { - context->Message_Block[context->Message_Block_Index++] = 0; - } - } - - /* - * Store the message length as the last 8 octets - */ - context->Message_Block[56] = (context->Length_High >> 24) & 0xFF; - context->Message_Block[57] = (context->Length_High >> 16) & 0xFF; - context->Message_Block[58] = (context->Length_High >> 8) & 0xFF; - context->Message_Block[59] = (context->Length_High) & 0xFF; - context->Message_Block[60] = (context->Length_Low >> 24) & 0xFF; - context->Message_Block[61] = (context->Length_Low >> 16) & 0xFF; - context->Message_Block[62] = (context->Length_Low >> 8) & 0xFF; - context->Message_Block[63] = (context->Length_Low) & 0xFF; - - SHA1ProcessMessageBlock(context); + /* + * Check to see if the current message block is too small to hold + * the initial padding bits and length. If so, we will pad the + * block, process it, and then continue padding into a second + * block. + */ + if (context->Message_Block_Index > 55) + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 64) + { + context->Message_Block[context->Message_Block_Index++] = 0; + } + + SHA1ProcessMessageBlock(context); + + while(context->Message_Block_Index < 56) + { + context->Message_Block[context->Message_Block_Index++] = 0; + } + } + else + { + context->Message_Block[context->Message_Block_Index++] = 0x80; + while(context->Message_Block_Index < 56) + { + context->Message_Block[context->Message_Block_Index++] = 0; + } + } + + /* + * Store the message length as the last 8 octets + */ + context->Message_Block[56] = (context->Length_High >> 24) & 0xFF; + context->Message_Block[57] = (context->Length_High >> 16) & 0xFF; + context->Message_Block[58] = (context->Length_High >> 8) & 0xFF; + context->Message_Block[59] = (context->Length_High) & 0xFF; + context->Message_Block[60] = (context->Length_Low >> 24) & 0xFF; + context->Message_Block[61] = (context->Length_Low >> 16) & 0xFF; + context->Message_Block[62] = (context->Length_Low >> 8) & 0xFF; + context->Message_Block[63] = (context->Length_Low) & 0xFF; + + SHA1ProcessMessageBlock(context); } -/* +/* * SHA1Reset * * Description: @@ -603,79 +605,79 @@ GF_SHA1Context *gf_sha1_starts() { GF_SHA1Context *context; GF_SAFEALLOC(context, GF_SHA1Context); - context->Length_Low = 0; - context->Length_High = 0; - context->Message_Block_Index = 0; - - context->Message_Digest[0] = 0x67452301; - context->Message_Digest[1] = 0xEFCDAB89; - context->Message_Digest[2] = 0x98BADCFE; - context->Message_Digest[3] = 0x10325476; - context->Message_Digest[4] = 0xC3D2E1F0; - - context->Computed = 0; - context->Corrupted = 0; + context->Length_Low = 0; + context->Length_High = 0; + context->Message_Block_Index = 0; + + context->Message_Digest[0] = 0x67452301; + context->Message_Digest[1] = 0xEFCDAB89; + context->Message_Digest[2] = 0x98BADCFE; + context->Message_Digest[3] = 0x10325476; + context->Message_Digest[4] = 0xC3D2E1F0; + + context->Computed = 0; + context->Corrupted = 0; return context; } void gf_sha1_update(GF_SHA1Context *context, u8 *message_array, u32 length ) { - if (!length) - { - return; - } - - if (context->Computed || context->Corrupted) - { - context->Corrupted = 1; - return; - } - - while(length-- && !context->Corrupted) - { - context->Message_Block[context->Message_Block_Index++] = - (*message_array & 0xFF); - - context->Length_Low += 8; - /* Force it to 32 bits */ - context->Length_Low &= 0xFFFFFFFF; - if (context->Length_Low == 0) - { - context->Length_High++; - /* Force it to 32 bits */ - context->Length_High &= 0xFFFFFFFF; - if (context->Length_High == 0) - { - /* Message is too long */ - context->Corrupted = 1; - } - } - - if (context->Message_Block_Index == 64) - { - SHA1ProcessMessageBlock(context); - } - - message_array++; - } + if (!length) + { + return; + } + + if (context->Computed || context->Corrupted) + { + context->Corrupted = 1; + return; + } + + while(length-- && !context->Corrupted) + { + context->Message_Block[context->Message_Block_Index++] = + (*message_array & 0xFF); + + context->Length_Low += 8; + /* Force it to 32 bits */ + context->Length_Low &= 0xFFFFFFFF; + if (context->Length_Low == 0) + { + context->Length_High++; + /* Force it to 32 bits */ + context->Length_High &= 0xFFFFFFFF; + if (context->Length_High == 0) + { + /* Message is too long */ + context->Corrupted = 1; + } + } + + if (context->Message_Block_Index == 64) + { + SHA1ProcessMessageBlock(context); + } + + message_array++; + } } void gf_sha1_finish(GF_SHA1Context *context, u8 output[20] ) { - if (context->Corrupted) - { - return; - } - - if (!context->Computed) - { - SHA1PadMessage(context); - context->Computed = 1; - } - PUT_UINT32_BE( context->Message_Digest[0], output, 0 ); - PUT_UINT32_BE( context->Message_Digest[1], output, 4 ); - PUT_UINT32_BE( context->Message_Digest[2], output, 8 ); - PUT_UINT32_BE( context->Message_Digest[3], output, 12 ); - PUT_UINT32_BE( context->Message_Digest[4], output, 16 ); + if (context->Corrupted) + { + return; + } + + if (!context->Computed) + { + SHA1PadMessage(context); + context->Computed = 1; + } + PUT_UINT32_BE( context->Message_Digest[0], output, 0 ); + PUT_UINT32_BE( context->Message_Digest[1], output, 4 ); + PUT_UINT32_BE( context->Message_Digest[2], output, 8 ); + PUT_UINT32_BE( context->Message_Digest[3], output, 12 ); + PUT_UINT32_BE( context->Message_Digest[4], output, 16 ); gf_free(context); } @@ -688,33 +690,33 @@ void gf_sha1_finish(GF_SHA1Context *context, u8 output[20] ) GF_EXPORT s32 gf_sha1_file( const char *path, u8 output[20] ) { - FILE *f; - size_t n; - GF_SHA1Context *ctx; - u8 buf[1024]; + FILE *f; + size_t n; + GF_SHA1Context *ctx; + u8 buf[1024]; if (!strncmp(path, "gmem://", 7)) { u32 size; u8 *mem_address; if (sscanf(path, "gmem://%d@%p", &size, &mem_address) != 2) { return GF_IO_ERR; - } + } gf_sha1_csum(mem_address, size, output); return 0; } - if( ( f = gf_f64_open( path, "rb" ) ) == NULL ) - return( 1 ); + if( ( f = gf_f64_open( path, "rb" ) ) == NULL ) + return( 1 ); - ctx = gf_sha1_starts(); + ctx = gf_sha1_starts(); - while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) - gf_sha1_update(ctx, buf, (s32) n ); + while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) + gf_sha1_update(ctx, buf, (s32) n ); - gf_sha1_finish(ctx, output ); + gf_sha1_finish(ctx, output ); - fclose( f ); - return( 0 ); + fclose( f ); + return( 0 ); } /* @@ -723,15 +725,15 @@ s32 gf_sha1_file( const char *path, u8 output[20] ) GF_EXPORT void gf_sha1_csum( u8 *input, u32 ilen, u8 output[20] ) { - GF_SHA1Context *ctx; + GF_SHA1Context *ctx; - ctx = gf_sha1_starts(); - gf_sha1_update(ctx, input, ilen ); - gf_sha1_finish(ctx, output ); + ctx = gf_sha1_starts(); + gf_sha1_update(ctx, input, ilen ); + gf_sha1_finish(ctx, output ); } GF_EXPORT -void gf_sha1_csum_hexa(u8 *buf, u32 buflen, u8 digest[41]){ +void gf_sha1_csum_hexa(u8 *buf, u32 buflen, u8 digest[41]) { u8 tmp[20]; gf_sha1_csum (buf, buflen, tmp ); digest[0] = 0; @@ -746,3 +748,5 @@ void gf_sha1_csum_hexa(u8 *buf, u32 buflen, u8 digest[41]){ } } } + +#endif \ No newline at end of file diff --git a/src/utils/symbian_net.cpp b/src/utils/symbian_net.cpp index fe4f7a0..ddb0729 100644 --- a/src/utils/symbian_net.cpp +++ b/src/utils/symbian_net.cpp @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -71,7 +71,7 @@ static int wsa_init = 0; #include #include #include - + #ifndef __BEOS__ #include #endif @@ -97,7 +97,7 @@ typedef s32 SOCKET; #endif #ifdef __SYMBIAN32__ -#define SSO_CAST +#define SSO_CAST #else #define SSO_CAST (const char *) #endif @@ -171,7 +171,7 @@ u32 gf_net_has_ipv6() #ifdef WIN32 if (!wsa_init) WSACleanup(); #endif - } + } return (ipv6_check_state==2); #else return 0; @@ -188,19 +188,19 @@ static struct addrinfo *gf_sk_get_ipv6_addr(char *PeerName, u16 PortNumber, int service = dest = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = sock_type; - hints.ai_family = family; - hints.ai_flags = flags; + hints.ai_family = family; + hints.ai_flags = flags; if (PortNumber) { sprintf (portstring, "%d", PortNumber); service = (char *)portstring; } if (PeerName) { - strcpy(node, PeerName); - if (node[0]=='[') { - node[strlen(node)-1] = 0; - strcpy(node, &node[1]); - } + strcpy(node, PeerName); + if (node[0]=='[') { + node[strlen(node)-1] = 0; + strcpy(node, &node[1]); + } dest = (char *) node; } if (getaddrinfo((const char *)dest, (const char *)service, &hints, &res) != 0) return NULL; @@ -211,7 +211,7 @@ static Bool gf_sk_ipv6_set_remote_address(GF_Socket *sock, char *address, u16 Po { struct addrinfo *res = gf_sk_get_ipv6_addr(address, PortNumber, AF_UNSPEC, 0, (sock->flags & GF_SOCK_IS_TCP) ? SOCK_STREAM : SOCK_DGRAM); if (!res) return 0; - memcpy(&sock->dest_addr, res->ai_addr, res->ai_addrlen); + memcpy(&sock->dest_addr, res->ai_addr, res->ai_addrlen); sock->dest_addr_len = res->ai_addrlen; freeaddrinfo(res); return 1; @@ -229,11 +229,11 @@ GF_Err gf_sk_get_local_ip(GF_Socket *sock, char *buffer) { #ifdef GPAC_HAS_IPV6 char clienthost[NI_MAXHOST]; - struct sockaddr_storage clientaddr; - socklen_t addrlen = sizeof(clientaddr); - if (getsockname(sock->socket, (struct sockaddr *)&clientaddr, &addrlen)) return GF_IP_NETWORK_FAILURE; + struct sockaddr_storage clientaddr; + socklen_t addrlen = sizeof(clientaddr); + if (getsockname(sock->socket, (struct sockaddr *)&clientaddr, &addrlen)) return GF_IP_NETWORK_FAILURE; - if (getnameinfo((struct sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), NULL, 0, NI_NUMERICHOST)) + if (getnameinfo((struct sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), NULL, 0, NI_NUMERICHOST)) return GF_IP_NETWORK_FAILURE; strcpy(buffer, clienthost); #else @@ -317,7 +317,7 @@ static void gf_sk_gf_free(GF_Socket *sock) #ifdef GPAC_HAS_IPV6 struct sockaddr *addr = (struct sockaddr *)&sock->dest_addr; if (addr->sa_family==AF_INET6) { - struct ipv6_mreq mreq6; + struct ipv6_mreq mreq6; memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); mreq6.ipv6mr_interface= 0; setsockopt(sock->socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *) &mreq6, sizeof(mreq6)); @@ -352,7 +352,7 @@ void gf_sk_reset(GF_Socket *sock) if (sock) setsockopt(sock->socket, SOL_SOCKET, SO_ERROR, (char *) &clear, sizeof(u32) ); } -s32 gf_sk_get_handle(GF_Socket *sock) +s32 gf_sk_get_handle(GF_Socket *sock) { return sock->socket; } @@ -399,10 +399,10 @@ GF_Err gf_sk_connect(GF_Socket *sock, char *PeerName, u16 PortNumber, char *loca freeaddrinfo(res); return GF_IP_CONNECTION_FAILURE; -#else +#else struct hostent *Host; - - if (!sock->socket) + + if (!sock->socket) sock->socket = socket(AF_INET, (sock->flags & GF_SOCK_IS_TCP) ? SOCK_STREAM : SOCK_DGRAM, 0); /*setup the address*/ @@ -415,10 +415,12 @@ GF_Err gf_sk_connect(GF_Socket *sock, char *PeerName, u16 PortNumber, char *loca if (Host == NULL) { switch (LASTSOCKERROR) { #ifndef __SYMBIAN32__ - case ENETDOWN: return GF_IP_NETWORK_FAILURE; - //case ENOHOST: return GF_IP_ADDRESS_NOT_FOUND; + case ENETDOWN: + return GF_IP_NETWORK_FAILURE; + //case ENOHOST: return GF_IP_ADDRESS_NOT_FOUND; #endif - default: return GF_IP_NETWORK_FAILURE; + default: + return GF_IP_NETWORK_FAILURE; } } memcpy((char *) &sock->dest_addr.sin_addr, Host->h_addr_list[0], sizeof(u32)); @@ -428,9 +430,12 @@ GF_Err gf_sk_connect(GF_Socket *sock, char *PeerName, u16 PortNumber, char *loca ret = connect(sock->socket, (struct sockaddr *) &sock->dest_addr, sizeof(struct sockaddr)); if (ret == SOCKET_ERROR) { switch (LASTSOCKERROR) { - case EAGAIN: return GF_IP_SOCK_WOULD_BLOCK; - case EISCONN: return GF_OK; - default: return GF_IP_CONNECTION_FAILURE; + case EAGAIN: + return GF_IP_SOCK_WOULD_BLOCK; + case EISCONN: + return GF_OK; + default: + return GF_IP_CONNECTION_FAILURE; } } } @@ -457,7 +462,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u1 s32 optval; if (!sock || sock->socket) return GF_BAD_PARAM; - + #ifdef GPAC_HAS_IPV6 type = (sock->flags & GF_SOCK_IS_TCP) ? SOCK_STREAM : SOCK_DGRAM; af = (options & GF_SOCK_FORCE_IPV6) ? PF_INET6 : PF_UNSPEC; @@ -467,7 +472,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u1 res = gf_sk_get_ipv6_addr(peer_name, peer_port, af, AI_PASSIVE, type); if (!res) return GF_IP_CONNECTION_FAILURE; #ifdef WIN32 - /*win32 has troubles redirecting IPV4 datagrams to IPV6 sockets, so override + /*win32 has troubles redirecting IPV4 datagrams to IPV6 sockets, so override local family type to avoid IPV4(S)->IPV6(C) UDP*/ af = res->ai_family; #endif @@ -475,7 +480,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u1 sock->dest_addr_len = res->ai_addrlen; freeaddrinfo(res); } - + res = gf_sk_get_ipv6_addr(NULL, port, af, AI_PASSIVE, type); if (!res) return GF_IP_CONNECTION_FAILURE; @@ -484,7 +489,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u1 if (type != (u32) aip->ai_socktype) continue; #ifdef WIN32 - /*recurrent pb with win32: this is not a true dual-stack, listening with a v6 socket for v4 source is + /*recurrent pb with win32: this is not a true dual-stack, listening with a v6 socket for v4 source is most of the time failing. On win32, only move for connection-less V6 sockets if no other way available*/ if (aip->ai_next && (aip->ai_next->ai_family==PF_INET)) continue; #endif @@ -510,7 +515,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u1 if (aip->ai_family==PF_INET6) sock->flags |= GF_SOCK_IS_IPV6; else sock->flags &= ~GF_SOCK_IS_IPV6; - if (peer_name && peer_port) + if (peer_name && peer_port) sock->flags |= GF_SOCK_HAS_SOURCE; freeaddrinfo(res); @@ -633,13 +638,13 @@ u32 gf_sk_is_multicast_address(char *multi_IPAdd) { #ifdef GPAC_HAS_IPV6 u32 val; - struct addrinfo *res; + struct addrinfo *res; if (!multi_IPAdd) return 0; res = gf_sk_get_ipv6_addr(multi_IPAdd, 0, AF_UNSPEC, AI_PASSIVE, SOCK_STREAM); if (!res) return 0; val = 0; if (res->ai_addr->sa_family == AF_INET) { - val = IN_MULTICAST(ntohl(((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr)); + val = IN_MULTICAST(ntohl(((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr)); } else if (res->ai_addr->sa_family == AF_INET6) { val = IN6_IS_ADDR_MULTICAST(& ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr); } @@ -647,14 +652,14 @@ u32 gf_sk_is_multicast_address(char *multi_IPAdd) return val; #else if (!multi_IPAdd) return 0; - return ((htonl(inet_addr(multi_IPAdd)) >> 8) & 0x00f00000) == 0x00e00000; + return ((htonl(inet_addr(multi_IPAdd)) >> 8) & 0x00f00000) == 0x00e00000; #endif } GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNumber, u32 TTL, Bool NoBind, char *local_interface_ip) { s32 ret; - u32 flag; + u32 flag; struct ip_mreq M_req; u32 optval; #ifdef GPAC_HAS_IPV6 @@ -668,7 +673,7 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNu if (!sock || sock->socket) return GF_BAD_PARAM; if (TTL > 255) TTL = 255; - + /*check the address*/ if (!gf_sk_is_multicast_address(multi_IPAdd)) return GF_BAD_PARAM; @@ -698,7 +703,7 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNu /*TODO: copy over other properties (recption buffer size & co)*/ if (sock->flags & GF_SOCK_NON_BLOCKING) gf_sk_set_block_mode(sock, 1); - memcpy(&sock->dest_addr, aip->ai_addr, aip->ai_addrlen); + memcpy(&sock->dest_addr, aip->ai_addr, aip->ai_addrlen); sock->dest_addr_len = aip->ai_addrlen; if (!NoBind) { @@ -716,13 +721,13 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNu freeaddrinfo(res); if (!sock->socket) return GF_IP_CONNECTION_FAILURE; - if (!gf_sk_ipv6_set_remote_address(sock, multi_IPAdd, MultiPortNumber)) + if (!gf_sk_ipv6_set_remote_address(sock, multi_IPAdd, MultiPortNumber)) return GF_IP_CONNECTION_FAILURE; addr = (struct sockaddr *)&sock->dest_addr; if (addr->sa_family == AF_INET) { - M_req.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; - M_req.imr_interface.s_addr = INADDR_ANY; + M_req.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; + M_req.imr_interface.s_addr = INADDR_ANY; ret = setsockopt(sock->socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &M_req, sizeof(M_req)); if (ret == SOCKET_ERROR) return GF_IP_CONNECTION_FAILURE; /*set TTL*/ @@ -735,9 +740,9 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNu } if (addr->sa_family == AF_INET6) { struct ipv6_mreq M_reqV6; - memcpy(&M_reqV6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); - M_reqV6.ipv6mr_interface = 0; - ret = setsockopt(sock->socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *) &M_reqV6, sizeof(M_reqV6)); + memcpy(&M_reqV6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); + M_reqV6.ipv6mr_interface = 0; + ret = setsockopt(sock->socket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *) &M_reqV6, sizeof(M_reqV6)); if (ret == SOCKET_ERROR) return GF_IP_CONNECTION_FAILURE; /*set TTL*/ ret = setsockopt(sock->socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &TTL, sizeof(TTL)); @@ -746,7 +751,7 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, char *multi_IPAdd, u16 MultiPortNu flag = 1; ret = setsockopt(sock->socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *) &flag, sizeof(flag)); if (ret == SOCKET_ERROR) return GF_IP_CONNECTION_FAILURE; - } + } #else /*enable address reuse*/ @@ -894,7 +899,7 @@ GF_Err gf_sk_accept(GF_Socket *sock, GF_Socket **newConnection) #endif #ifndef __SYMBIAN32__ u32 res; - #endif +#endif *newConnection = NULL; if (!sock || !(sock->flags & GF_SOCK_IS_LISTENING) ) return GF_BAD_PARAM; @@ -933,7 +938,7 @@ GF_Err gf_sk_accept(GF_Socket *sock, GF_Socket **newConnection) return GF_IP_SOCK_WOULD_BLOCK; default: return GF_IP_NETWORK_FAILURE; - } + } } (*newConnection) = (GF_Socket *) gf_malloc(sizeof(GF_Socket)); @@ -973,18 +978,18 @@ GF_Err gf_sk_get_local_info(GF_Socket *sock, u16 *Port, u32 *Familly) #endif } if (Familly) { -/* size = 4; - if (getsockopt(sock->socket, SOL_SOCKET, SO_TYPE, (char *) &fam, &size) == SOCKET_ERROR) - return GF_IP_NETWORK_FAILURE; - *Familly = fam; -*/ + /* size = 4; + if (getsockopt(sock->socket, SOL_SOCKET, SO_TYPE, (char *) &fam, &size) == SOCKET_ERROR) + return GF_IP_NETWORK_FAILURE; + *Familly = fam; + */ if (sock->flags & GF_SOCK_IS_TCP) *Familly = GF_SOCK_TYPE_TCP; else *Familly = GF_SOCK_TYPE_UDP; } return GF_OK; } -//we have to do this for the server sockets as we use only one thread +//we have to do this for the server sockets as we use only one thread GF_Err gf_sk_server_mode(GF_Socket *sock, Bool serverOn) { u32 one; @@ -1004,16 +1009,16 @@ GF_Err gf_sk_get_remote_address(GF_Socket *sock, char *buf) { #ifdef GPAC_HAS_IPV6 char clienthost[NI_MAXHOST]; - struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr_len); + struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr_len); if (!sock || sock->socket) return GF_BAD_PARAM; - if (getnameinfo((struct sockaddr *)addrptr, sock->dest_addr_len, clienthost, sizeof(clienthost), NULL, 0, NI_NUMERICHOST)) + if (getnameinfo((struct sockaddr *)addrptr, sock->dest_addr_len, clienthost, sizeof(clienthost), NULL, 0, NI_NUMERICHOST)) return GF_IP_ADDRESS_NOT_FOUND; strcpy(buf, clienthost); #else if (!sock || !sock->socket) return GF_BAD_PARAM; strcpy(buf, inet_ntoa(sock->dest_addr.sin_addr)); #endif - return GF_OK; + return GF_OK; } @@ -1073,7 +1078,7 @@ GF_Err gf_sk_send_to(GF_Socket *sock, char *buffer, u32 length, char *remoteHost freeaddrinfo(res); } else { struct sockaddr_in6 *remotePtr = (struct sockaddr_in6 *)&remote_add; - struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr); + struct sockaddr_in6 * addrptr = (struct sockaddr_in6 *)(&sock->dest_addr); remotePtr->sin6_port = addrptr->sin6_port; remotePtr->sin6_addr = addrptr->sin6_addr; remote_add_len = sock->dest_addr_len; @@ -1093,10 +1098,10 @@ GF_Err gf_sk_send_to(GF_Socket *sock, char *buffer, u32 length, char *remoteHost remote_add.sin_port = sock->dest_addr.sin_port; remote_add.sin_addr.s_addr = sock->dest_addr.sin_addr.s_addr; } -#endif +#endif Count = 0; while (Count < length) { - Res = sendto(sock->socket, (char *) &buffer[Count], length - Count, 0, (struct sockaddr *) &remote_add, remote_add_len); + Res = sendto(sock->socket, (char *) &buffer[Count], length - Count, 0, (struct sockaddr *) &remote_add, remote_add_len); if (Res == SOCKET_ERROR) { switch (LASTSOCKERROR) { case EAGAIN: @@ -1213,7 +1218,7 @@ GF_Err gf_sk_send_wait(GF_Socket *sock, char *buffer, u32 length, u32 Second ) case EAGAIN: return GF_IP_SOCK_WOULD_BLOCK; #ifndef __SYMBIAN32__ - case ECONNRESET: + case ECONNRESET: return GF_IP_CONNECTION_CLOSED; #endif default: @@ -1242,7 +1247,7 @@ typedef struct __tag_sock_group #define GF_SOCK_GROUP_WRITE 1 GF_SocketGroup *NewSockGroup() -{ +{ GF_SocketGroup *tmp = (GF_SocketGroup*)gf_malloc(sizeof(GF_SocketGroup)); if (!tmp) return NULL; FD_ZERO(&tmp->ReadGroup); diff --git a/src/utils/symbian_os.cpp b/src/utils/symbian_os.cpp index 9a2e3aa..afcefda 100644 --- a/src/utils/symbian_os.cpp +++ b/src/utils/symbian_os.cpp @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -36,15 +36,15 @@ #include #include /*symbian stdlib*/ -#include +#include /*symbian core (for scheduler & trap cleanup)*/ -#include +#include /*hardware abstraction layer*/ #include - + /*gpac module internals*/ #include "module_wrap.h" -#include +#include // Exported Functions (DLL entry point) @@ -79,21 +79,21 @@ void gf_sleep(u32 ms) TTimeIntervalMicroSeconds32 inter; inter = (TInt) (1000*ms); #ifdef __SERIES60_3X__ - User::AfterHighRes(inter); + User::AfterHighRes(inter); #else - User::After(inter); + User::After(inter); #endif #if 0 TInt error; - CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle); + CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle); RTimer timer; TRequestStatus timerStatus; timer.CreateLocal(); - + timer.After(timerStatus,ms*1000); - User::WaitForRequest(timerStatus); + User::WaitForRequest(timerStatus); #endif } @@ -125,7 +125,7 @@ u32 gf_rand() GF_EXPORT FILE *gf_temp_file_new() { - return tmpfile(); + return tmpfile(); } #endif @@ -307,7 +307,7 @@ static void *RunThread(void *ptr) t->status = GF_THREAD_STATUS_DEAD; gf_sema_notify(t->_signal, 1); goto exit; - } + } #ifndef GPAC_DISABLE_LOG GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Thread %s] Installing ActiveScheduler\n", t->log_name)); #endif @@ -370,7 +370,7 @@ GF_Err gf_th_run(GF_Thread *t, u32 (*Run)(void *param), void *param) threadName.Format(_L("GTH%d"), (u32) t); t->threadH = new RThread(); - if ( t->threadH->Create(threadName, (TThreadFunction)RunThread, KDefaultStackSize, KThreadMinHeapSize, KThreadMaxHeapSize, (void *)t, EOwnerProcess) != KErrNone){ + if ( t->threadH->Create(threadName, (TThreadFunction)RunThread, KDefaultStackSize, KThreadMinHeapSize, KThreadMaxHeapSize, (void *)t, EOwnerProcess) != KErrNone) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] Unable to create thread\n")); t->status = GF_THREAD_STATUS_DEAD; return GF_IO_ERR; @@ -378,7 +378,7 @@ GF_Err gf_th_run(GF_Thread *t, u32 (*Run)(void *param), void *param) t->threadH->Resume(); /*wait for the child function to call us - do NOT return before, otherwise the thread status would - be unknown*/ + be unknown*/ //GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Waiting for thread to start\n")); gf_sema_wait(t->_signal); gf_sema_del(t->_signal); @@ -391,11 +391,11 @@ GF_Err gf_th_run(GF_Thread *t, u32 (*Run)(void *param), void *param) static void Thread_Stop(GF_Thread *t, Bool Destroy) { if (gf_th_status(t) == GF_THREAD_STATUS_RUN) { - if (Destroy){ + if (Destroy) { t->threadH->Terminate(0); t->threadH = NULL; } - else{ + else { t->threadH->Suspend(); } } @@ -468,9 +468,9 @@ GF_Mutex *gf_mx_new(const char *name) GF_Mutex *tmp = (GF_Mutex *)gf_malloc(sizeof(GF_Mutex)); if (!tmp) return NULL; memset(tmp, 0, sizeof(GF_Mutex)); - + tmp->hMutex = new RMutex(); - if( tmp->hMutex->CreateLocal() != KErrNone){ + if( tmp->hMutex->CreateLocal() != KErrNone) { gf_free(tmp); return NULL; } @@ -671,7 +671,7 @@ Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) if (rti->sampling_instant + refresh_time_ms > now) return 0; rti->sampling_period_duration = now - rti->sampling_instant; rti->sampling_instant = now; - + if (cur_th.Process(cur_process) != KErrNone) { return 0; } @@ -694,8 +694,8 @@ Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) rti->process_cpu_usage = 100*rti->process_cpu_time_diff / rti->sampling_period_duration; if (rti->process_cpu_usage > 100) rti->process_cpu_usage = 100; - HAL::Get(HALData::EMemoryRAM, ram); - HAL::Get(HALData::EMemoryRAMFree, ram_free); + HAL::Get(HALData::EMemoryRAM, ram); + HAL::Get(HALData::EMemoryRAMFree, ram_free); rti->physical_memory = ram; rti->physical_memory_avail = ram_free; #ifdef GPAC_MEMORY_TRACKING @@ -705,7 +705,7 @@ Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) } GF_EXPORT -Bool gf_sys_get_battery_state(Bool *onBattery, u32 *state, u32*level) +Bool gf_sys_get_battery_state(Bool *onBattery, u32 *state, u32*level) { return 1; } @@ -720,7 +720,7 @@ void gf_modules_free_module(ModuleInstance *inst) gf_list_rem(inst->interfaces, 0); inst->destroy_func(objinterface); } - if (inst->lib_handle){ + if (inst->lib_handle) { RLibrary* pLibrary = (RLibrary *) inst->lib_handle; pLibrary->Close(); } @@ -730,11 +730,11 @@ void gf_modules_free_module(ModuleInstance *inst) Bool gf_modules_load_library(ModuleInstance *inst) { - const TUid KGPACModuleUid={0x10000080}; + const TUid KGPACModuleUid= {0x10000080}; char s_path[GF_MAX_PATH]; HBufC *path; - TInt e; - + TInt e; + if (inst->lib_handle) return 1; sprintf(s_path, "%s%c%s", inst->plugman->dir, GF_PATH_SEPARATOR, inst->szName); @@ -761,7 +761,7 @@ Bool gf_modules_load_library(ModuleInstance *inst) inst->query_func = (QueryInterfaces) pLibrary->Lookup(1); inst->load_func = (LoadInterface) pLibrary->Lookup(2); inst->destroy_func = (ShutdownInterface) pLibrary->Lookup(3); - + if ((inst->query_func==NULL) || (inst->load_func==NULL) || (inst->destroy_func==NULL) ) { GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Library %s has invalid interfaces", inst->szName)); pLibrary->Close(); @@ -775,7 +775,7 @@ Bool gf_modules_load_library(ModuleInstance *inst) return 1; err_exit: - gf_cfg_set_key(inst->plugman->cfg, "SymbianDLLs", inst->szName, "no"); + gf_cfg_set_key(inst->plugman->cfg, "SymbianDLLs", inst->szName, "no"); return 0; } @@ -786,7 +786,7 @@ void gf_modules_unload_library(ModuleInstance *inst) RLibrary* pLibrary = (RLibrary *) inst->lib_handle; pLibrary->Close(); delete pLibrary; - + inst->lib_handle = NULL; inst->load_func = NULL; inst->destroy_func = NULL; @@ -825,11 +825,11 @@ u32 gf_modules_refresh(GF_ModuleManager *pm) gf_enum_directory((char*)pm->dir, 0, enum_modules, pm, ".dll"); #else u32 i, mod_count; - + mod_count = gf_cfg_get_key_count(pm->cfg, "SymbianDLLs"); for (i=0; icfg, "SymbianDLLs", i); - if (stricmp(gf_cfg_get_key(pm->cfg, "SymbianDLLs", mod), "yes")) continue; + if (stricmp(gf_cfg_get_key(pm->cfg, "SymbianDLLs", mod), "yes")) continue; enum_modules(pm, (char*)mod, NULL); } #endif diff --git a/src/utils/token.c b/src/utils/token.c index c480cc3..f7ae2d9 100644 --- a/src/utils/token.c +++ b/src/utils/token.c @@ -11,18 +11,20 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#ifndef GPAC_DISABLE_CORE_TOOLS + #include static GFINLINE s32 gf_tok_is_char_in_set(const char TestChar, const char *TestSet) @@ -46,7 +48,7 @@ s32 gf_token_get(const char *Buffer, s32 Start, const char *Separator, char *C } start = i; if (i == Len) return( -1 ); - + for (i=start; i= Size) return -1; - + Len = (u32) strlen(Pattern); if ( Len <= 0 ) return -1; if (Size - Start < (u32) Len) return -1; @@ -131,3 +133,4 @@ s32 gf_token_find(const char *Buffer, u32 Start, u32 Size, const char *Pattern) return -1; } +#endif diff --git a/src/utils/uni_bidi.c b/src/utils/uni_bidi.c index 4496735..2651c38 100644 --- a/src/utils/uni_bidi.c +++ b/src/utils/uni_bidi.c @@ -34,36 +34,36 @@ ------------------------------------------------------------------------*/ enum { - // input types - // ON MUST be zero, code relies on ON = N = 0 - ON = 0, // Other Neutral - L, // Left Letter - R, // Right Letter - AN, // Arabic Number - EN, // European Number - AL, // Arabic Letter (Right-to-left) - NSM, // Non-spacing Mark - CS, // Common Separator - ES, // European Separator - ET, // European Terminator (post/prefix e.g. $ and %) + // input types + // ON MUST be zero, code relies on ON = N = 0 + ON = 0, // Other Neutral + L, // Left Letter + R, // Right Letter + AN, // Arabic Number + EN, // European Number + AL, // Arabic Letter (Right-to-left) + NSM, // Non-spacing Mark + CS, // Common Separator + ES, // European Separator + ET, // European Terminator (post/prefix e.g. $ and %) // resolved types - BN, // Boundary neutral (type of RLE etc after explicit levels) + BN, // Boundary neutral (type of RLE etc after explicit levels) // input types, - S, // Segment Separator (TAB) // used only in L1 - WS, // White space // used only in L1 - B, // Paragraph Separator (aka as PS) + S, // Segment Separator (TAB) // used only in L1 + WS, // White space // used only in L1 + B, // Paragraph Separator (aka as PS) // types for explicit controls - RLO, // these are used only in X1-X9 - RLE, - LRO, - LRE, - PDF, + RLO, // these are used only in X1-X9 + RLE, + LRO, + LRE, + PDF, // resolved types, also resolved directions - N = ON, // alias, where ON, WS and S are treated the same + N = ON, // alias, where ON, WS and S are treated the same }; /*---------------------------------------------------------------------- @@ -94,12 +94,18 @@ Bool gf_utf8_is_right_to_left(u16 *utf_string) u32 c = utf_string[i]; if (!c) return 0; switch (bidi_get_class(c)) { - case L: return 0; - case R: return 1; - case AN: return 1; - case EN: return 0; - case AL: return 1; - default: break; + case L: + return 0; + case R: + return 1; + case AN: + return 1; + case EN: + return 0; + case AL: + return 1; + default: + break; } i++; } diff --git a/src/utils/unicode.c b/src/utils/unicode.c index a416526..812b6ab 100644 --- a/src/utils/unicode.c +++ b/src/utils/unicode.c @@ -45,8 +45,9 @@ u32 utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf) while (utf8_buf != utf8_endbuf) { - if ((*utf8_buf & 0x80) == 0x00) { /* ASCII chars no - * conversion needed */ + if ((*utf8_buf & 0x80) == 0x00) { + /* ASCII chars no + * conversion needed */ *ucs4_buf++ = (u32) * utf8_buf; utf8_buf++; ucs_len++; @@ -54,45 +55,49 @@ u32 utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf) //In the 2 byte utf - 8 range { *ucs4_buf++ = (u32) (((*utf8_buf - 0xC0) * 0x40) - + (*(utf8_buf + 1) - 0x80)); + + (*(utf8_buf + 1) - 0x80)); utf8_buf += 2; ucs_len++; - } else if ((*utf8_buf & 0xF0) == 0xE0) { /* In the 3 byte utf-8 - * range */ + } else if ((*utf8_buf & 0xF0) == 0xE0) { + /* In the 3 byte utf-8 + * range */ *ucs4_buf++ = (u32) (((*utf8_buf - 0xE0) * 0x1000) - + ((*(utf8_buf + 1) - 0x80) * 0x40) - + (*(utf8_buf + 2) - 0x80)); + + ((*(utf8_buf + 1) - 0x80) * 0x40) + + (*(utf8_buf + 2) - 0x80)); utf8_buf += 3; ucs_len++; - } else if ((*utf8_buf & 0xF8) == 0xF0) { /* In the 4 byte utf-8 - * range */ + } else if ((*utf8_buf & 0xF8) == 0xF0) { + /* In the 4 byte utf-8 + * range */ *ucs4_buf++ = (u32) - (((*utf8_buf - 0xF0) * 0x040000) - + ((*(utf8_buf + 1) - 0x80) * 0x1000) - + ((*(utf8_buf + 2) - 0x80) * 0x40) - + (*(utf8_buf + 3) - 0x80)); + (((*utf8_buf - 0xF0) * 0x040000) + + ((*(utf8_buf + 1) - 0x80) * 0x1000) + + ((*(utf8_buf + 2) - 0x80) * 0x40) + + (*(utf8_buf + 3) - 0x80)); utf8_buf += 4; ucs_len++; - } else if ((*utf8_buf & 0xFC) == 0xF8) { /* In the 5 byte utf-8 - * range */ + } else if ((*utf8_buf & 0xFC) == 0xF8) { + /* In the 5 byte utf-8 + * range */ *ucs4_buf++ = (u32) - (((*utf8_buf - 0xF8) * 0x01000000) - + ((*(utf8_buf + 1) - 0x80) * 0x040000) - + ((*(utf8_buf + 2) - 0x80) * 0x1000) - + ((*(utf8_buf + 3) - 0x80) * 0x40) - + (*(utf8_buf + 4) - 0x80)); + (((*utf8_buf - 0xF8) * 0x01000000) + + ((*(utf8_buf + 1) - 0x80) * 0x040000) + + ((*(utf8_buf + 2) - 0x80) * 0x1000) + + ((*(utf8_buf + 3) - 0x80) * 0x40) + + (*(utf8_buf + 4) - 0x80)); utf8_buf += 5; ucs_len++; - } else if ((*utf8_buf & 0xFE) == 0xFC) { /* In the 6 byte utf-8 - * range */ + } else if ((*utf8_buf & 0xFE) == 0xFC) { + /* In the 6 byte utf-8 + * range */ *ucs4_buf++ = (u32) - (((*utf8_buf - 0xFC) * 0x40000000) - + ((*(utf8_buf + 1) - 0x80) * 0x010000000) - + ((*(utf8_buf + 2) - 0x80) * 0x040000) - + ((*(utf8_buf + 3) - 0x80) * 0x1000) - + ((*(utf8_buf + 4) - 0x80) * 0x40) - + (*(utf8_buf + 5) - 0x80)); + (((*utf8_buf - 0xFC) * 0x40000000) + + ((*(utf8_buf + 1) - 0x80) * 0x010000000) + + ((*(utf8_buf + 2) - 0x80) * 0x040000) + + ((*(utf8_buf + 3) - 0x80) * 0x1000) + + ((*(utf8_buf + 4) - 0x80) * 0x40) + + (*(utf8_buf + 5) - 0x80)); utf8_buf += 6; ucs_len++; } diff --git a/src/utils/url.c b/src/utils/url.c index bad9741..27e6fd0 100644 --- a/src/utils/url.c +++ b/src/utils/url.c @@ -11,15 +11,15 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -47,15 +47,15 @@ static u32 URL_GetProtocolType(const char *pathName) char *begin; if (!pathName) return GF_URL_TYPE_ANY; - if ((pathName[0] == '/') || (pathName[0] == '\\') - || (pathName[1] == ':') - || ((pathName[0] == ':') && (pathName[1] == ':')) - ) return GF_URL_TYPE_FILE; + if ((pathName[0] == '/') || (pathName[0] == '\\') + || (pathName[1] == ':') + || ((pathName[0] == ':') && (pathName[1] == ':')) + ) return GF_URL_TYPE_FILE; - if (!strncmp(pathName, "blob:", 5)) return GF_URL_TYPE_BLOB; + if (!strncmp(pathName, "blob:", 5)) return GF_URL_TYPE_BLOB; begin = strstr(pathName, "://"); - if (!begin) begin = strstr(pathName, "|//"); + if (!begin) begin = strstr(pathName, "|//"); if (!begin) return GF_URL_TYPE_RELATIVE; if (!strnicmp(pathName, "file", 4)) return GF_URL_TYPE_FILE; return GF_URL_TYPE_ANY; @@ -74,7 +74,7 @@ char *gf_url_get_absolute_path(const char *pathName, const char *parentPath) /*abs path name*/ if (prot_type == GF_URL_TYPE_FILE) { - /*abs path*/ + /*abs path*/ if (!strstr(pathName, "://") && !strstr(pathName, "|//")) return gf_strdup(pathName); pathName += 6; /*not sure if "file:///C:\..." is std, but let's handle it anyway*/ @@ -192,15 +192,15 @@ char *gf_url_concatenate(const char *parentName, const char *pathName) } for (i = 0; i< strlen(pathName) - 2; i++) { /*current dir*/ - if ( (pathName[i] == '.') - && ( (pathName[i+1] == GF_PATH_SEPARATOR) || (pathName[i+1] == '/') ) ) { + if ( (pathName[i] == '.') + && ( (pathName[i+1] == GF_PATH_SEPARATOR) || (pathName[i+1] == '/') ) ) { i++; continue; } /*parent dir*/ - if ( (pathName[i] == '.') && (pathName[i+1] == '.') - && ( (pathName[i+2] == GF_PATH_SEPARATOR) || (pathName[i+2] == '/') ) - ) { + if ( (pathName[i] == '.') && (pathName[i+1] == '.') + && ( (pathName[i+2] == GF_PATH_SEPARATOR) || (pathName[i+2] == '/') ) + ) { pathSepCount ++; i+=2; name = (char *) &pathName[i+1]; @@ -242,7 +242,7 @@ char *gf_url_concatenate(const char *parentName, const char *pathName) sprintf(outPath, "%s%s", tmp, name); /*cleanup paths sep for win32*/ - for (i = 0; i @@ -31,9 +33,9 @@ /* * Copyright 2001-2004 Unicode, Inc. - * + * * Disclaimer - * + * * This source code is provided as is by Unicode, Inc. No claims are * made as to fitness for any particular purpose. No warranties of any * kind are expressed or implied. The recipient agrees to determine @@ -41,9 +43,9 @@ * purchased on magnetic or optical media from Unicode, Inc., the * sole remedy for any claim will be exchange of defective media * within 90 days of receipt. - * + * * Limitations on Rights to Redistribute This Code - * + * * Unicode, Inc. hereby grants the right to freely use the information * supplied in this file in the creation of products supporting the * Unicode Standard, and to make copies of this file in any form @@ -113,14 +115,14 @@ static const UTF32 halfMask = 0x3FFUL; * allowed in earlier algorithms. */ static const char trailingBytesForUTF8[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 }; /* @@ -128,8 +130,9 @@ static const char trailingBytesForUTF8[256] = { * This table contains as many values as there might be trailing bytes * in a UTF-8 sequence. */ -static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; /* * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed @@ -153,71 +156,85 @@ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF16toUTF8 ( - const UTF16** sourceStart, const UTF16* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF16* source = *sourceStart; - UTF8* target = *targetStart; - while (source < sourceEnd) { - UTF32 ch; - unsigned short bytesToWrite = 0; - const UTF32 byteMask = 0xBF; - const UTF32 byteMark = 0x80; - const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ - ch = *source++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { - /* If the 16 bits following the high surrogate are in the source buffer... */ - if (source < sourceEnd) { - UTF32 ch2 = *source; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { - ch = ((ch - UNI_SUR_HIGH_START) << halfShift) - + (ch2 - UNI_SUR_LOW_START) + halfBase; - ++source; - } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { + bytesToWrite = 4; + } else { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; } - } else { /* We don't have the 16 bits following the high surrogate. */ - --source; /* return to the high surrogate */ - result = sourceExhausted; - break; - } - } else if (flags == strictConversion) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { - --source; /* return to the illegal value itself */ - result = sourceIllegal; - break; - } - } - /* Figure out how many bytes the result will require */ - if (ch < (UTF32)0x80) { bytesToWrite = 1; - } else if (ch < (UTF32)0x800) { bytesToWrite = 2; - } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; - } else if (ch < (UTF32)0x110000) { bytesToWrite = 4; - } else { bytesToWrite = 3; - ch = UNI_REPLACEMENT_CHAR; - } - target += bytesToWrite; - if (target > targetEnd) { - source = oldSource; /* Back up source pointer! */ - target -= bytesToWrite; result = targetExhausted; break; - } - switch (bytesToWrite) { /* note: everything falls through. */ - case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; - case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; + result = targetExhausted; + break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (UTF8)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; } - target += bytesToWrite; - } - *sourceStart = source; - *targetStart = target; - return result; + *sourceStart = source; + *targetStart = target; + return result; } /* @@ -232,101 +249,129 @@ ConversionResult ConvertUTF16toUTF8 ( */ static Boolean isLegalUTF8(const UTF8 *source, int length) { - UTF8 a; - const UTF8 *srcptr = source+length; - switch (length) { - default: return false; + UTF8 a; + const UTF8 *srcptr = source+length; + switch (length) { + default: + return false; /* Everything else falls through when "true"... */ - case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: if ((a = (*--srcptr)) > 0xBF) return false; - - switch (*source) { - /* no fall-through in this inner switch */ - case 0xE0: if (a < 0xA0) return false; break; - case 0xED: if (a > 0x9F) return false; break; - case 0xF0: if (a < 0x90) return false; break; - case 0xF4: if (a > 0x8F) return false; break; - default: if (a < 0x80) return false; - } + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) return false; + break; + case 0xED: + if (a > 0x9F) return false; + break; + case 0xF0: + if (a < 0x90) return false; + break; + case 0xF4: + if (a > 0x8F) return false; + break; + default: + if (a < 0x80) return false; + } - case 1: if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; + case 1: + if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; } /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF8toUTF16 ( - const UTF8** sourceStart, const UTF8* sourceEnd, - UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { - ConversionResult result = conversionOK; - const UTF8* source = *sourceStart; - UTF16* target = *targetStart; - while (source < sourceEnd) { - UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; - if (source + extraBytesToRead >= sourceEnd) { - result = sourceExhausted; break; - } - /* Do this check whether lenient or strict */ - if (! isLegalUTF8(source, extraBytesToRead+1)) { - result = sourceIllegal; - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extraBytesToRead) { - case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ - case 3: ch += *source++; ch <<= 6; - case 2: ch += *source++; ch <<= 6; - case 1: ch += *source++; ch <<= 6; - case 0: ch += *source++; - } - ch -= offsetsFromUTF8[extraBytesToRead]; + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 4: + ch += *source++; + ch <<= 6; /* remember, illegal UTF-8 */ + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; - if (target >= targetEnd) { - source -= (extraBytesToRead+1); /* Back up source pointer! */ - result = targetExhausted; break; - } - if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { - if (flags == strictConversion) { - source -= (extraBytesToRead+1); /* return to the illegal value itself */ - result = sourceIllegal; - break; + if (target >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead+1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } } else { - *target++ = UNI_REPLACEMENT_CHAR; + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); } - } else { - *target++ = (UTF16)ch; /* normal case */ - } - } else if (ch > UNI_MAX_UTF16) { - if (flags == strictConversion) { - result = sourceIllegal; - source -= (extraBytesToRead+1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } else { - *target++ = UNI_REPLACEMENT_CHAR; - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - if (target + 1 >= targetEnd) { - source -= (extraBytesToRead+1); /* Back up source pointer! */ - result = targetExhausted; break; - } - ch -= halfBase; - *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); - *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); } - } - *sourceStart = source; - *targetStart = target; - return result; + *sourceStart = source; + *targetStart = target; + return result; } @@ -334,10 +379,10 @@ ConversionResult ConvertUTF8toUTF16 ( GF_EXPORT size_t gf_utf8_wcslen (const unsigned short *s) { - const unsigned short* ptr; - for (ptr = s; *ptr != (unsigned short)'\0'; ptr++) { - } - return ptr - s; + const unsigned short* ptr; + for (ptr = s; *ptr != (unsigned short)'\0'; ptr++) { + } + return ptr - s; } GF_EXPORT @@ -360,7 +405,7 @@ GF_EXPORT size_t gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp) { const UTF8** sourceStart = (const UTF8**) srcp; - const UTF8* sourceEnd = (const UTF8*) ( *srcp + strlen( *srcp) ); + const UTF8* sourceEnd = (const UTF8*) ( *srcp + strlen( *srcp) ); UTF16* targetStart = (UTF16* ) dest; UTF16* targetEnd = (UTF16* ) (dest + len); ConversionFlags flags = strictConversion; @@ -377,10 +422,10 @@ size_t gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp) GF_EXPORT size_t gf_utf8_wcslen (const unsigned short *s) { - const unsigned short* ptr; - for (ptr = s; *ptr != (unsigned short)'\0'; ptr++) { - } - return ptr - s; + const unsigned short* ptr; + for (ptr = s; *ptr != (unsigned short)'\0'; ptr++) { + } + return ptr - s; } GF_EXPORT @@ -394,7 +439,7 @@ size_t gf_utf8_wcstombs(char* dest, size_t len, const unsigned short** srcp) if (dest != NULL) { char* destptr = dest; - for (;; src++) { + for (;; src++) { unsigned char c; unsigned short wc = *src; if (wc < 0x80) { @@ -426,12 +471,12 @@ size_t gf_utf8_wcstombs(char* dest, size_t len, const unsigned short** srcp) do { *destptr++ = (unsigned char)(((wc >> (6 * --count)) & 0x3F) | 0x80); } while (count > 0); - } - return destptr - dest; + } + return destptr - dest; } else { - /* Ignore dest and len. */ - size_t totalcount = 0; - for (;; src++) { + /* Ignore dest and len. */ + size_t totalcount = 0; + for (;; src++) { unsigned short wc = *src; size_t count; if (wc < 0x80) { @@ -446,8 +491,8 @@ size_t gf_utf8_wcstombs(char* dest, size_t len, const unsigned short** srcp) count = 3; } totalcount += count; - } - return totalcount; + } + return totalcount; } } @@ -456,10 +501,10 @@ typedef struct { u32 count : 16; /* number of bytes remaining to be processed */ u32 value : 16; /* if count > 0: partial wide character */ -/* - If WCHAR_T_BITS == 16, need 2 bits for count, - 12 bits for value (10 for mbstowcs direction, 12 for wcstombs direction). -*/ + /* + If WCHAR_T_BITS == 16, need 2 bits for count, + 12 bits for value (10 for mbstowcs direction, 12 for wcstombs direction). + */ } gf_utf8_mbstate_t; static gf_utf8_mbstate_t internal; @@ -470,8 +515,8 @@ size_t gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp) gf_utf8_mbstate_t* ps = &internal; const char *src = *srcp; - unsigned short* destptr = dest; - for (; len > 0; destptr++, len--) { + unsigned short* destptr = dest; + for (; len > 0; destptr++, len--) { const char* backup_src = src; unsigned char c; unsigned short wc; @@ -523,9 +568,9 @@ size_t gf_utf8_mbstowcs(unsigned short* dest, size_t len, const char** srcp) bad_input_backup: src = backup_src; goto bad_input; - } - *srcp = src; - return destptr-dest; + } + *srcp = src; + return destptr-dest; bad_input: *srcp = src; @@ -533,3 +578,4 @@ bad_input: } #endif +#endif /* GPAC_DISABLE_CORE_TOOLS */ \ No newline at end of file diff --git a/src/utils/xml_parser.c b/src/utils/xml_parser.c index 9c45c87..750db8e 100644 --- a/src/utils/xml_parser.c +++ b/src/utils/xml_parser.c @@ -11,22 +11,23 @@ * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */ - #include #include +#ifndef GPAC_DISABLE_CORE_TOOLS + #ifndef GPAC_DISABLE_ZLIB /*since 0.2.2, we use zlib for xmt/x3d reading to handle gz files*/ #include @@ -39,6 +40,9 @@ #endif +#define XML_INPUT_SIZE 4096 + + static GF_Err gf_xml_sax_parse_intern(GF_SAXParser *parser, char *current); static char *xml_translate_xml_string(char *str) @@ -100,11 +104,13 @@ static char *xml_translate_xml_string(char *str) i+= 6; } else { value[j] = str[i]; - j++; i++; + j++; + i++; } } else { value[j] = str[i]; - j++; i++; + j++; + i++; } } value[j] = 0; @@ -199,7 +205,7 @@ static void xml_sax_swap(GF_SAXParser *parser) assert(parser->line_size >= parser->current_pos); parser->line_size -= parser->current_pos; parser->file_pos += parser->current_pos; - if (parser->line_size) memmove(parser->buffer, parser->buffer + parser->current_pos, sizeof(char)*parser->line_size); + if (parser->line_size) memmove(parser->buffer, parser->buffer + parser->current_pos, sizeof(char)*parser->line_size); parser->buffer[parser->line_size] = 0; parser->current_pos = 0; } @@ -214,7 +220,7 @@ static void format_sax_error(GF_SAXParser *parser, u32 linepos, const char* fmt, va_start(args, fmt); vsprintf(parser->err_msg, fmt, args); va_end(args); - + sprintf(szM, " - Line %d: ", parser->line + 1); strcat(parser->err_msg, szM); len = (u32) strlen(parser->err_msg); @@ -236,7 +242,7 @@ static void xml_sax_node_end(GF_SAXParser *parser, Bool had_children) c = parser->buffer[parser->elt_name_end - 1]; parser->buffer[parser->elt_name_end - 1] = 0; name = parser->buffer + parser->elt_name_start - 1; - + if (parser->sax_node_end) { sep = strchr(name, ':'); if (sep) { @@ -265,7 +271,7 @@ static void xml_sax_node_start(GF_SAXParser *parser) parser->buffer[parser->elt_name_end - 1] = 0; name = parser->buffer + parser->elt_name_start - 1; - for (i=0;inb_attrs; i++) { + for (i=0; inb_attrs; i++) { parser->attrs[i].name = parser->buffer + parser->sax_attrs[i].name_start - 1; parser->buffer[parser->sax_attrs[i].name_end-1] = 0; parser->attrs[i].value = parser->buffer + parser->sax_attrs[i].val_start - 1; @@ -294,7 +300,7 @@ static void xml_sax_node_start(GF_SAXParser *parser) parser->buffer[parser->elt_name_end - 1] = c; parser->node_depth++; if (has_entities) { - for (i=0;inb_attrs; i++) { + for (i=0; inb_attrs; i++) { if (parser->sax_attrs[i].has_entities) { parser->sax_attrs[i].has_entities = 0; gf_free(parser->attrs[i].value); @@ -455,7 +461,7 @@ static Bool xml_sax_parse_attribute(GF_SAXParser *parser) } } - + if (parser->sax_state == SAX_STATE_ATT_VALUE) { att = &parser->sax_attrs[parser->nb_attrs-1]; /*looking for first delimiter*/ @@ -482,7 +488,7 @@ static Bool xml_sax_parse_attribute(GF_SAXParser *parser) if (parser->att_sep) break; } if (parser->current_pos == parser->line_size) return 1; - } + } att_retry: @@ -739,7 +745,13 @@ restart: } i++; if (c=='\n') parser->line++; - if (parser->current_pos+i==parser->line_size) goto exit; + + if (parser->current_pos+i==parser->line_size) { + if ((parser->line_size>=2*XML_INPUT_SIZE) && !parser->init_state) + parser->sax_state = SAX_STATE_SYNTAX_ERROR; + + goto exit; + } } if (is_text && i) { xml_sax_store_text(parser, i); @@ -754,11 +766,11 @@ restart: cdata_sep = 0; while (1) { char c = parser->buffer[parser->current_pos+1+i]; - if (!strncmp(parser->buffer+parser->current_pos+1+i, "!--", 3)) { - parser->sax_state = SAX_STATE_COMMENT; - i += 3; - break; - } + if (!strncmp(parser->buffer+parser->current_pos+1+i, "!--", 3)) { + parser->sax_state = SAX_STATE_COMMENT; + i += 3; + break; + } if (!c) { i = 0; goto exit; @@ -785,14 +797,14 @@ restart: is_end = !i ? 1 : 2; i++; } else if (c=='<') { - if (parser->sax_state != SAX_STATE_COMMENT) { - parser->sax_state = SAX_STATE_SYNTAX_ERROR; - return GF_CORRUPTED_DATA; - } + if (parser->sax_state != SAX_STATE_COMMENT) { + parser->sax_state = SAX_STATE_SYNTAX_ERROR; + return GF_CORRUPTED_DATA; + } } else { i++; } -/* if ((c=='[') && (parser->buffer[parser->elt_name_start-1 + i-2]=='A') ) break; */ + /* if ((c=='[') && (parser->buffer[parser->elt_name_start-1 + i-2]=='A') ) break; */ if (parser->current_pos+1+i==parser->line_size) { i=0; goto exit; @@ -803,7 +815,7 @@ restart: if (is_end==1) parser->elt_name_start ++; if (is_end==2) parser->elt_name_end = parser->current_pos+1+i; else parser->elt_name_end = parser->current_pos+1+i + 1; - } + } if (is_end) { xml_sax_flush_text(parser); parser->elt_end_pos = parser->file_pos + parser->current_pos + i; @@ -828,7 +840,7 @@ restart: assert(parser->elt_start_pos <= parser->file_pos + parser->current_pos); parser->elt_start_pos = parser->file_pos + parser->current_pos; - if (!strncmp(elt, "!--", 3)) { + if (!strncmp(elt, "!--", 3)) { xml_sax_flush_text(parser); parser->sax_state = SAX_STATE_COMMENT; if (i>3) parser->current_pos -= (i-3); @@ -837,7 +849,7 @@ restart: else if (!strcmp(elt, "!DOCTYPE")) parser->init_state = 2; else if (!strcmp(elt, "!ENTITY")) parser->sax_state = SAX_STATE_ENTITY; else if (!strcmp(elt, "!ATTLIST") || !strcmp(elt, "!ELEMENT")) parser->sax_state = SAX_STATE_SKIP_DOCTYPE; - else if (!strcmp(elt, "![CDATA[")) + else if (!strcmp(elt, "![CDATA[")) parser->sax_state = SAX_STATE_CDATA; else if (elt[0]=='?') parser->sax_state = SAX_STATE_XML_PROC; /*node found*/ @@ -845,7 +857,7 @@ restart: xml_sax_flush_text(parser); if (parser->init_state) { parser->init_state = 0; - /*that's a bit ugly: since we solve entities when appending text, we need to + /*that's a bit ugly: since we solve entities when appending text, we need to reparse the current buffer*/ if (gf_list_count(parser->entities)) { char *orig_buf; @@ -873,7 +885,7 @@ restart: break; case SAX_STATE_ATT_NAME: case SAX_STATE_ATT_VALUE: - if (xml_sax_parse_attribute(parser)) + if (xml_sax_parse_attribute(parser)) goto exit; break; case SAX_STATE_ENTITY: @@ -903,22 +915,22 @@ exit: #endif xml_sax_swap(parser); - if (parser->sax_state==SAX_STATE_SYNTAX_ERROR) - return GF_CORRUPTED_DATA; - else - return GF_OK; + if (parser->sax_state==SAX_STATE_SYNTAX_ERROR) + return GF_CORRUPTED_DATA; + else + return GF_OK; } static GF_Err xml_sax_append_string(GF_SAXParser *parser, char *string) { u32 size = parser->line_size; u32 nl_size = (u32) strlen(string); - + if (!nl_size) return GF_OK; - if ( (parser->alloc_size < size+nl_size+1) -/* || (parser->alloc_size / 2 ) > size+nl_size+1 */ - ) + if ( (parser->alloc_size < size+nl_size+1) + /* || (parser->alloc_size / 2 ) > size+nl_size+1 */ + ) { parser->alloc_size = size+nl_size+1; parser->alloc_size = 3 * parser->alloc_size / 2; @@ -1038,7 +1050,7 @@ GF_Err gf_xml_sax_parse(GF_SAXParser *parser, const void *string) GF_Err e; char *current; char *utf_conv = NULL; - + if (parser->unicode_type < 0) return GF_BAD_PARAM; if (parser->unicode_type>1) { @@ -1116,7 +1128,6 @@ static void xml_sax_reset(GF_SAXParser *parser) parser->nb_alloc_attrs = parser->nb_attrs = 0; } -#define XML_INPUT_SIZE 4096 static GF_Err xml_sax_read_file(GF_SAXParser *parser) { @@ -1138,13 +1149,13 @@ static GF_Err xml_sax_read_file(GF_SAXParser *parser) #endif if ((read<=0) /*&& !parser->node_depth*/) break; szLine[read] = 0; - szLine[read+1] = 0; + szLine[read+1] = 0; e = gf_xml_sax_parse(parser, szLine); if (e) break; if (parser->file_pos > parser->file_size) parser->file_size = parser->file_pos + 1; if (parser->on_progress) parser->on_progress(parser->sax_cbck, parser->file_pos, parser->file_size); } - + #ifdef NO_GZIP if (feof(parser->f_in)) { #else @@ -1191,7 +1202,7 @@ GF_Err gf_xml_sax_parse_file(GF_SAXParser *parser, const char *fileName, gf_xml_ u8 *xml_mem_address; if (sscanf(fileName, "gmem://%d@%p", &size, &xml_mem_address) != 2) { return GF_URL_ERROR; - } + } parser->file_size = size; memcpy(szLine, xml_mem_address, 3); @@ -1216,7 +1227,7 @@ GF_Err gf_xml_sax_parse_file(GF_SAXParser *parser, const char *fileName, gf_xml_ parser->file_size = 0; parser->line_size = 0; return e; - } + } /*check file exists and gets its size (zlib doesn't support SEEK_END)*/ test = gf_f64_open(fileName, "rb"); @@ -1260,10 +1271,10 @@ Bool gf_xml_sax_binary_file(GF_SAXParser *parser) } GF_EXPORT -GF_SAXParser *gf_xml_sax_new(gf_xml_sax_node_start on_node_start, - gf_xml_sax_node_end on_node_end, - gf_xml_sax_text_content on_text_content, - void *cbck) +GF_SAXParser *gf_xml_sax_new(gf_xml_sax_node_start on_node_start, + gf_xml_sax_node_end on_node_end, + gf_xml_sax_text_content on_text_content, + void *cbck) { GF_SAXParser *parser; GF_SAFEALLOC(parser, GF_SAXParser); @@ -1307,32 +1318,34 @@ GF_Err gf_xml_sax_suspend(GF_SAXParser *parser, Bool do_suspend) GF_EXPORT -u32 gf_xml_sax_get_line(GF_SAXParser *parser) { return parser->line + 1 ; } +u32 gf_xml_sax_get_line(GF_SAXParser *parser) { + return parser->line + 1 ; +} GF_EXPORT -u32 gf_xml_sax_get_file_size(GF_SAXParser *parser) -{ +u32 gf_xml_sax_get_file_size(GF_SAXParser *parser) +{ #ifdef NO_GZIP - return parser->f_in ? parser->file_size : 0; + return parser->f_in ? parser->file_size : 0; #else - return parser->gz_in ? parser->file_size : 0; + return parser->gz_in ? parser->file_size : 0; #endif } GF_EXPORT -u32 gf_xml_sax_get_file_pos(GF_SAXParser *parser) +u32 gf_xml_sax_get_file_pos(GF_SAXParser *parser) { #ifdef NO_GZIP - return parser->f_in ? parser->file_pos : 0; + return parser->f_in ? parser->file_pos : 0; #else - return parser->gz_in ? parser->file_pos : 0; + return parser->gz_in ? parser->file_pos : 0; #endif } GF_EXPORT char *gf_xml_sax_peek_node(GF_SAXParser *parser, char *att_name, char *att_value, char *substitute, char *get_attr, char *end_pattern, Bool *is_substitute) { - u32 state, att_len, alloc_size; + u32 state, att_len, alloc_size, _len; #ifdef NO_GZIP u64 pos; #else @@ -1343,14 +1356,15 @@ char *gf_xml_sax_peek_node(GF_SAXParser *parser, char *att_name, char *att_value char szLine1[XML_INPUT_SIZE+2], szLine2[XML_INPUT_SIZE+2], *szLine, *cur_line, *sep, *start, first_c, *result; -#define CPYCAT_ALLOC(__str, __is_copy) if ( strlen(__str) + (__is_copy ? 0 : strlen(szLine))>=alloc_size) {\ +#define CPYCAT_ALLOC(__str, __is_copy) _len = (u32) strlen(__str);\ + if ( _len + (__is_copy ? 0 : strlen(szLine))>=alloc_size) {\ alloc_size = 1 + (u32) strlen(__str); \ if (!__is_copy) alloc_size += (u32) strlen(szLine); \ szLine = gf_realloc(szLine, alloc_size); \ }\ - if (__is_copy) strcpy(szLine, __str); \ + if (__is_copy) { memcpy(szLine, __str, sizeof(char)*_len); szLine[_len] = 0; }\ else strcat(szLine, __str); \ - + from_buffer=0; #ifdef NO_GZIP if (!parser->f_in) from_buffer=1; @@ -1456,7 +1470,7 @@ retry: sep++; while (sep[0] && strchr(" \n\r\t", sep[0]) ) sep++; if (!sep[0]) continue; - if (!strchr(sep, sep_char)) + if (!strchr(sep, sep_char)) continue; /*found*/ @@ -1545,7 +1559,7 @@ char *gf_xml_get_root_type(const char *file, GF_Err *ret) GF_EXPORT u32 gf_xml_sax_get_node_start_pos(GF_SAXParser *parser) -{ +{ return parser->elt_start_pos; } @@ -1679,7 +1693,7 @@ static void gf_xml_dom_reset(GF_DOMParser *dom, Bool full_reset) if (dom->root==n) dom->root = NULL; gf_xml_dom_node_del(n); } - gf_list_del(dom->stack); + gf_list_del(dom->stack); dom->stack = NULL; } if (full_reset && dom->root) { @@ -1736,7 +1750,7 @@ GF_Err gf_xml_dom_parse_string(GF_DOMParser *dom, char *string) } GF_EXPORT -GF_XMLNode *gf_xml_dom_create_root(GF_DOMParser *parser, const char* name){ +GF_XMLNode *gf_xml_dom_create_root(GF_DOMParser *parser, const char* name) { GF_XMLNode * root; if (!parser) return NULL; @@ -1767,7 +1781,7 @@ static void gf_xml_dom_node_serialize(GF_XMLNode *node, Bool content_only, char { u32 i, count, vlen; char *name; - + #define SET_STRING(v) \ vlen = (u32) strlen(v); \ if (vlen+ (*size) >= (*alloc_size)) { \ @@ -1777,7 +1791,7 @@ static void gf_xml_dom_node_serialize(GF_XMLNode *node, Bool content_only, char } \ strcat((*str), v); \ *size += vlen; \ - + switch (node->type) { case GF_XML_CDATA_TYPE: SET_STRING("![CDATA["); @@ -1808,7 +1822,7 @@ static void gf_xml_dom_node_serialize(GF_XMLNode *node, Bool content_only, char SET_STRING(att->value); SET_STRING("\" "); } - + if (!gf_list_count(node->content)) { SET_STRING("/>"); return; @@ -1843,14 +1857,14 @@ char *gf_xml_dom_serialize(GF_XMLNode *node, Bool content_only) } GF_EXPORT -GF_XMLAttribute *gf_xml_dom_set_attribute(GF_XMLNode *node, const char* name, const char* value){ +GF_XMLAttribute *gf_xml_dom_set_attribute(GF_XMLNode *node, const char* name, const char* value) { GF_XMLAttribute *att; if (!name || !value) return NULL; if (!node->attributes) { node->attributes = gf_list_new(); if (!node->attributes) return NULL; } - + GF_SAFEALLOC(att, GF_XMLAttribute); if (!att) return NULL; @@ -1861,13 +1875,13 @@ GF_XMLAttribute *gf_xml_dom_set_attribute(GF_XMLNode *node, const char* name, co } GF_EXPORT -GF_XMLAttribute *gf_xml_dom_get_attribute(GF_XMLNode *node, const char* name){ +GF_XMLAttribute *gf_xml_dom_get_attribute(GF_XMLNode *node, const char* name) { u32 i = 0; GF_XMLAttribute *att; if (!node | !name) return NULL; while ( (att = (GF_XMLAttribute*)gf_list_enum(node->attributes, &i))) { - if (!strcmp(att->name, name)){ + if (!strcmp(att->name, name)) { return att; } } @@ -1876,9 +1890,9 @@ GF_XMLAttribute *gf_xml_dom_get_attribute(GF_XMLNode *node, const char* name){ } GF_EXPORT -GF_Err gf_xml_dom_append_child(GF_XMLNode *node, GF_XMLNode *child){ +GF_Err gf_xml_dom_append_child(GF_XMLNode *node, GF_XMLNode *child) { if (!node | !child) return GF_BAD_PARAM; - if (!node->content){ + if (!node->content) { node->content = gf_list_new(); if (!node->content) return GF_OUT_OF_MEM; } @@ -1886,21 +1900,21 @@ GF_Err gf_xml_dom_append_child(GF_XMLNode *node, GF_XMLNode *child){ } GF_EXPORT -GF_XMLNode* gf_xml_dom_node_new(const char* ns, const char* name){ +GF_XMLNode* gf_xml_dom_node_new(const char* ns, const char* name) { GF_XMLNode* node; GF_SAFEALLOC(node, GF_XMLNode); if (!node) return NULL; - if (ns){ + if (ns) { node->ns = gf_strdup(ns); - if (!node->ns){ + if (!node->ns) { gf_free(node); return NULL; } } - if (name){ + if (name) { node->name = gf_strdup(name); - if (!node->name){ + if (!node->name) { gf_free(node->ns); gf_free(node); return NULL; @@ -1919,7 +1933,7 @@ GF_XMLNode* gf_xml_dom_node_new(const char* ns, const char* name){ else if (strstr(att->value, "0X")) { u32 __i; sscanf(att->value+2, "%X", &__i); _value = __i; }\ else sscanf(att->value, _fmt, &_value); \ }\ - + GF_EXPORT GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specInfoSize) @@ -1940,8 +1954,8 @@ GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specI Bool use_word128 = GF_FALSE; Bool use_text = GF_FALSE; Bool big_endian = GF_TRUE; - const char *szFile = NULL; - const char *szString = NULL; + const char *szFile = NULL; + const char *szString = NULL; const char *szBase64 = NULL; const char *szData = NULL; if (node->type) continue; @@ -1966,7 +1980,7 @@ GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specI nb_bits = 32; } else if (!stricmp(att->name, "ID128")) { gf_bin128_parse(att->value, word128); - use_word128 = GF_TRUE; + use_word128 = GF_TRUE; } else if (!stricmp(att->name, "textmode")) { if (!strcmp(att->value, "yes")) use_text = GF_TRUE; } else if (!stricmp(att->name, "data64")) { @@ -1989,7 +2003,7 @@ GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specI } else if (szBase64) { u32 len = (u32) strlen(szBase64); char *data = (char *) gf_malloc(sizeof(char)*len); - u32 ret = (u32) gf_base64_decode((char *)szBase64, len, data, len); + u32 ret = (u32) gf_base64_decode((char *)szBase64, len, data, len); if ((s32) ret >=0) { gf_bs_write_int(bs, ret, nb_bits); gf_bs_write_data(bs, data, ret); @@ -2017,7 +2031,7 @@ GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specI else if (nb_bits == 32) gf_bs_write_u32_le(bs, (u32)value); else - GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[XML/NHML] Little-endian values can only be 16 or 32-bit\n")); + GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[XML/NHML] Little-endian values can only be 16 or 32-bit\n")); } else { if (nb_bits<33) gf_bs_write_int(bs, (s32) value, nb_bits); @@ -2054,3 +2068,5 @@ GF_Err gf_xml_parse_bit_sequence(GF_XMLNode *bsroot, char **specInfo, u32 *specI return GF_OK; } + +#endif diff --git a/src/utils/zlib_symbian_ext.h b/src/utils/zlib_symbian_ext.h index 049c20a..878f5e1 100644 --- a/src/utils/zlib_symbian_ext.h +++ b/src/utils/zlib_symbian_ext.h @@ -29,7 +29,7 @@ */ /* -This is an extended version of the zlib library designed to run on EPOC +This is an extended version of the zlib library designed to run on EPOC Symbian Markr 5/11/99 */ @@ -145,7 +145,7 @@ int gzflush OF((gzFile file, int flush)); */ z_off_t gzseek OF((gzFile file, z_off_t offset, int whence)); -/* +/* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); diff --git a/src/utils/zutil.c b/src/utils/zutil.c index 93d7317..3e0d894 100644 --- a/src/utils/zutil.c +++ b/src/utils/zutil.c @@ -8,108 +8,135 @@ #include "zutil.h" #ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ +struct internal_state { + int dummy; +}; /* for buggy compilers */ #endif const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; + "need dictionary", /* Z_NEED_DICT 2 */ + "stream end", /* Z_STREAM_END 1 */ + "", /* Z_OK 0 */ + "file error", /* Z_ERRNO (-1) */ + "stream error", /* Z_STREAM_ERROR (-2) */ + "data error", /* Z_DATA_ERROR (-3) */ + "insufficient memory", /* Z_MEM_ERROR (-4) */ + "buffer error", /* Z_BUF_ERROR (-5) */ + "incompatible version",/* Z_VERSION_ERROR (-6) */ + "" +}; const char * ZEXPORT zlibVersion() { - return ZLIB_VERSION; + return ZLIB_VERSION; } uLong ZEXPORT zlibCompileFlags() { - uLong flags; - - flags = 0; - switch (sizeof(uInt)) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch (sizeof(uLong)) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch (sizeof(voidpf)) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch (sizeof(z_off_t)) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } + uLong flags; + + flags = 0; + switch (sizeof(uInt)) { + case 2: + break; + case 4: + flags += 1; + break; + case 8: + flags += 2; + break; + default: + flags += 3; + } + switch (sizeof(uLong)) { + case 2: + break; + case 4: + flags += 1 << 2; + break; + case 8: + flags += 2 << 2; + break; + default: + flags += 3 << 2; + } + switch (sizeof(voidpf)) { + case 2: + break; + case 4: + flags += 1 << 4; + break; + case 8: + flags += 2 << 4; + break; + default: + flags += 3 << 4; + } + switch (sizeof(z_off_t)) { + case 2: + break; + case 4: + flags += 1 << 6; + break; + case 8: + flags += 2 << 6; + break; + default: + flags += 3 << 6; + } #ifdef DEBUG - flags += 1 << 8; + flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; + flags += 1 << 9; #endif #ifdef ZLIB_WINAPI - flags += 1 << 10; + flags += 1 << 10; #endif #ifdef BUILDFIXED - flags += 1 << 12; + flags += 1 << 12; #endif #ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; + flags += 1 << 13; #endif #ifdef NO_GZCOMPRESS - flags += 1L << 16; + flags += 1L << 16; #endif #ifdef NO_GZIP - flags += 1L << 17; + flags += 1L << 17; #endif #ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; + flags += 1L << 20; #endif #ifdef FASTEST - flags += 1L << 21; + flags += 1L << 21; #endif #ifdef STDC # ifdef NO_vsnprintf - flags += 1L << 25; + flags += 1L << 25; # ifdef HAS_vsprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # endif #else - flags += 1L << 24; + flags += 1L << 24; # ifdef NO_snprintf - flags += 1L << 25; + flags += 1L << 25; # ifdef HAS_sprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void - flags += 1L << 26; + flags += 1L << 26; # endif # endif #endif - return flags; + return flags; } #ifdef DEBUG @@ -120,10 +147,10 @@ uLong ZEXPORT zlibCompileFlags() int z_verbose = verbose; void z_error (m) - char *m; +char *m; { - fprintf(stderr, "%s\n", m); - exit(1); + fprintf(stderr, "%s\n", m); + exit(1); } #endif @@ -131,53 +158,53 @@ void z_error (m) * uncompress() */ const char * ZEXPORT zError(err) - int err; +int err; { - return ERR_MSG(err); + return ERR_MSG(err); } #if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; +/* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. + */ +int errno = 0; #endif #ifndef HAVE_MEMCPY void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; +Bytef* dest; +const Bytef* source; +uInt len; { - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); } int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; +const Bytef* s1; +const Bytef* s2; +uInt len; { - uInt j; + uInt j; - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; } void zmemzero(dest, len) - Bytef* dest; - uInt len; +Bytef* dest; +uInt len; { - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); } #endif @@ -201,8 +228,8 @@ void zmemzero(dest, len) local int next_ptr = 0; typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; + voidpf org_ptr; + voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; @@ -215,48 +242,48 @@ local ptr_table table[MAX_PTR]; voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; } void zcgf_free(voidpf opaque, voidpf ptr) { - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - fargf_free(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - fargf_free(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + fargf_free(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + fargf_free(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ @@ -274,14 +301,14 @@ void zcgf_free(voidpf opaque, voidpf ptr) voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); } void zcgf_free(voidpf opaque, voidpf ptr) { - if (opaque) opaque = 0; /* to make compiler happy */ - _hgf_free(ptr); + if (opaque) opaque = 0; /* to make compiler happy */ + _hgf_free(ptr); } #endif /* M_I86 */ @@ -298,21 +325,21 @@ extern void free OF((voidpf ptr)); #endif voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; +voidpf opaque; +unsigned items; +unsigned size; { - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)gf_malloc(items * size) : - (voidpf)gf_calloc(items, size); + if (opaque) items += size - size; /* make compiler happy */ + return sizeof(uInt) > 2 ? (voidpf)gf_malloc(items * size) : + (voidpf)gf_calloc(items, size); } void zcgf_free(opaque, ptr) - voidpf opaque; - voidpf ptr; +voidpf opaque; +voidpf ptr; { - gf_free(ptr); - if (opaque) return; /* make compiler happy */ + gf_free(ptr); + if (opaque) return; /* make compiler happy */ } #endif /* MY_ZCALLOC */ diff --git a/src/utils/zutil.h b/src/utils/zutil.h index ba95f4f..235e646 100644 --- a/src/utils/zutil.h +++ b/src/utils/zutil.h @@ -29,14 +29,14 @@ extern "C" { #endif #ifdef NO_ERRNO_H # ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ +/* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. We rename it to + * avoid conflict with other libraries that use the same workaround. + */ # define errno z_errno # endif - extern int errno; +extern int errno; #else # ifndef _WIN32_WCE # include @@ -63,7 +63,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ return (strm->msg = (char*)ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ - /* common constants */ +/* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS @@ -88,15 +88,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - /* target dependencies */ +/* target dependencies */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) # define OS_CODE 0x00 # if defined(__TURBOC__) || defined(__BORLANDC__) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl fargf_free( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); +/* Allow compilation with ANSI keywords only enabled */ +void _Cdecl fargf_free( void *block ); +void *_Cdecl farmalloc( unsigned long nbytes ); # else # include # endif @@ -122,7 +122,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #ifdef OS2 # define OS_CODE 0x06 # ifdef M_I86 - #include +#include # endif #endif @@ -159,7 +159,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # if defined(_WIN32_WCE) # define fdopen(fd,mode) NULL /* No fdopen() */ # ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; +typedef int ptrdiff_t; # define _PTRDIFF_T_DEFINED # endif # else @@ -167,7 +167,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif - /* common defaults */ +/* common defaults */ #ifndef OS_CODE # define OS_CODE 0x03 /* assume Unix */ @@ -177,7 +177,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define F_OPEN(name, mode) fopen((name), (mode)) #endif - /* functions */ +/* functions */ #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) # ifndef HAVE_VSNPRINTF @@ -191,15 +191,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #ifndef HAVE_VSNPRINTF # ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ # define NO_vsnprintf # endif # ifdef __TURBOC__ # define NO_vsnprintf # endif # ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ # if !defined(vsnprintf) && !defined(NO_vsnprintf) # define vsnprintf _vsnprintf # endif @@ -216,10 +216,10 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ +/* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) @@ -236,16 +236,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); +extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); +extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); +extern void zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef DEBUG # include - extern int z_verbose; - extern void z_error OF((char *m)); +extern int z_verbose; +extern void z_error OF((char *m)); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} diff --git a/version.bat b/version.bat index d0a1bcc..6ced6ac 100644 --- a/version.bat +++ b/version.bat @@ -1,10 +1,16 @@ @echo off +set OLDDIR=%CD% cd /d %~dp0 for /f "delims=" %%a in ('svnversion') do echo #define GPAC_SVN_REVISION "%%a" > test.h if not exist include\gpac\revision.h goto create ECHO n|COMP test.h include\gpac\revision.h > nul if errorlevel 1 goto create DEL test.h -exit/b +goto done + :create MOVE /Y test.h include\gpac\revision.h + +:done +cd /d %OLDDIR% +exit/b -- 2.30.2